text stringlengths 157 7.64M | meta dict |
|---|---|
theory ResTerm
imports Main
begin
section‹Resource Terms›
text‹
Resource terms describe resources with atoms drawn from two types, linear and copyable, combined
in a number of ways:
▪ Parallel resources represent their simultaneous presence,
▪ Non-deterministic resource represent exactly one of two options,
▪ Executable resources represent a single potential execution of a process transforming one
resource into another,
▪ Repeatably executable resources represent an unlimited amount of such potential executions.
We define two distinguished resources on top of the atoms:
▪ Empty, to represent the absence of a resource and serve as the unit for parallel combination,
▪ Anything, to represent a resource about which we have no information.
›
datatype (discs_sels) ('a, 'b) res_term =
Res 'a
― ‹Linear resource atom›
| Copyable 'b
― ‹Copyable resource atom›
| is_Empty: Empty
― ‹The absence of a resource›
| is_Anything: Anything
― ‹Resource about which we know nothing›
| Parallel "('a, 'b) res_term list"
― ‹Parallel combination›
| NonD "('a, 'b) res_term" "('a, 'b) res_term"
― ‹Non-deterministic combination›
| Executable "('a, 'b) res_term" "('a, 'b) res_term"
― ‹Executable resource›
| Repeatable "('a, 'b) res_term" "('a, 'b) res_term"
― ‹Repeatably executable resource›
text‹Every child of @{const Parallel} is smaller than it›
lemma parallel_child_smaller:
"x ∈ set xs ⟹ size_res_term f g x < size_res_term f g (Parallel xs)"
proof (induct xs)
(*goals:
1. ‹x ∈ set [] ⟹ size_res_term f g x < size_res_term f g (Parallel [])›
2. ‹⋀a xs. ⟦x ∈ set xs ⟹ size_res_term f g x < size_res_term f g (Parallel xs); x ∈ set (a # xs)⟧ ⟹ size_res_term f g x < size_res_term f g (Parallel (a # xs))›*)
case Nil (*‹(x::('a::type, 'b::type) res_term) ∈ set []›*)
then show "?case"
(*goal: ‹size_res_term f g x < size_res_term f g (Parallel [])›*)
by simp
next
(*goal: ‹⋀a xs. ⟦x ∈ set xs ⟹ size_res_term f g x < size_res_term f g (Parallel xs); x ∈ set (a # xs)⟧ ⟹ size_res_term f g x < size_res_term f g (Parallel (a # xs))›*)
case (Cons a xs) (*‹x ∈ set xs ⟹ size_res_term f g x < size_res_term f g (Parallel xs)› ‹(x::('a, 'b) res_term) ∈ set ((a::('a, 'b) res_term) # (xs::('a, 'b) res_term list))›*)
then show "?case"
(*goal: ‹size_res_term f g x < size_res_term f g (Parallel (a # xs))›*)
apply simp
(*goal: ‹size_res_term f g x < size_res_term f g (Parallel (a # xs))›*)
by (metis add_Suc_right (*‹?m + Suc ?n = Suc (?m + ?n)›*) less_SucI (*‹?m < ?n ⟹ ?m < Suc ?n›*) less_add_Suc1 (*‹?i < Suc (?i + ?m)›*) trans_less_add2 (*‹?i < ?j ⟹ ?i < ?m + ?j›*))
qed
text‹No singleton @{const Parallel} is equal to its own child, because the child has to be smaller›
lemma parallel_neq_single [simp]:
"Parallel [a] ≠ a"
proof (-)
(*goal: ‹Parallel [a] ≠ a›*)
have "⋀f g. size_res_term f g a < size_res_term f g (Parallel [a])"
using parallel_child_smaller (*‹?x ∈ set ?xs ⟹ size_res_term ?f ?g ?x < size_res_term ?f ?g (Parallel ?xs)›*) by simp
then show "?thesis"
(*goal: ‹Parallel [a] ≠ a›*)
by fastforce
qed
subsection‹Resource Term Equivalence›
text‹
Some resource terms are different descriptions of the same situation.
We express this by relating resource terms as follows:
▪ @{term "Parallel []"} with @{term "Empty"}
▪ @{term "Parallel [x]"} with @{term "x"}
▪ @{term "Parallel (xs @ [Parallel ys] @ zs)"} with @{term "Parallel (xs @ ys @ zs)"}
We extend this with the reflexive base cases, recursive cases and symmetric-transitive closure.
As a result, we get an equivalence relation on resource terms, which we will later use to quotient
the terms and form a type of resources.
›
inductive res_term_equiv :: "('a, 'b) res_term ⇒ ('a, 'b) res_term ⇒ bool" (infix "∼" 100)
where
nil: "Parallel [] ∼ Empty"
| singleton: "Parallel [a] ∼ a"
| merge: "Parallel (x @ [Parallel y] @ z) ∼ Parallel (x @ y @ z)"
| empty: "Empty ∼ Empty"
| anything: "Anything ∼ Anything"
| res: "Res x ∼ Res x"
| copyable: "Copyable x ∼ Copyable x"
| parallel: "list_all2 (∼) xs ys ⟹ Parallel xs ∼ Parallel ys"
| nondet: "⟦x ∼ y; u ∼ v⟧ ⟹ NonD x u ∼ NonD y v"
| executable: "⟦x ∼ y; u ∼ v⟧ ⟹ Executable x u ∼ Executable y v"
| repeatable: "⟦x ∼ y; u ∼ v⟧ ⟹ Repeatable x u ∼ Repeatable y v"
| sym [sym]: "x ∼ y ⟹ y ∼ x"
| trans [trans]: "⟦x ∼ y; y ∼ z⟧ ⟹ x ∼ z"
text‹Add some of the rules for the simplifier›
lemmas [simp] =
nil nil[symmetric]
singleton singleton[symmetric]
text‹Constrain all these rules to the resource term equivalence namespace›
hide_fact (open) empty anything res copyable nil singleton merge parallel nondet executable
repeatable sym trans
text‹Next we derive a handful of rules for the equivalence, placing them in its namespace›
setup ‹Sign.mandatory_path "res_term_equiv"›
text‹It can be shown to be reflexive›
lemma refl [simp]:
"a ∼ a"
apply (induct a)
(*goals:
1. ‹⋀x::'a. Res x ∼ Res x›
2. ‹⋀x::'b. Copyable x ∼ Copyable x›
3. ‹Empty ∼ Empty›
4. ‹Anything ∼ Anything›
5. ‹⋀x::('a, 'b) res_term list. (⋀xa::('a, 'b) res_term. xa ∈ set x ⟹ xa ∼ xa) ⟹ Parallel x ∼ Parallel x›
6. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦a1 ∼ a1; a2 ∼ a2⟧ ⟹ NonD a1 a2 ∼ NonD a1 a2›
7. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦a1 ∼ a1; a2 ∼ a2⟧ ⟹ Executable a1 a2 ∼ Executable a1 a2›
8. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦a1 ∼ a1; a2 ∼ a2⟧ ⟹ Repeatable a1 a2 ∼ Repeatable a1 a2›
discuss goal 1*)
apply (rule res_term_equiv.intros (*‹Parallel [] ∼ Empty› ‹Parallel [?a] ∼ ?a› ‹Parallel (?x @ [Parallel ?y] @ ?z) ∼ Parallel (?x @ ?y @ ?z)› ‹Empty ∼ Empty› ‹Anything ∼ Anything› ‹Res ?x ∼ Res ?x› ‹Copyable ?x ∼ Copyable ?x› ‹list_all2 (∼) ?xs ?ys ⟹ Parallel ?xs ∼ Parallel ?ys› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ NonD ?x ?u ∼ NonD ?y ?v› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Executable ?x ?u ∼ Executable ?y ?v› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Repeatable ?x ?u ∼ Repeatable ?y ?v› ‹?x ∼ ?y ⟹ ?y ∼ ?x› and more 1 facts*))
(*discuss goal 2*)
apply (rule res_term_equiv.intros (*‹Parallel [] ∼ Empty› ‹Parallel [?a] ∼ ?a› ‹Parallel (?x @ [Parallel ?y] @ ?z) ∼ Parallel (?x @ ?y @ ?z)› ‹Empty ∼ Empty› ‹Anything ∼ Anything› ‹Res ?x ∼ Res ?x› ‹Copyable ?x ∼ Copyable ?x› ‹list_all2 (∼) ?xs ?ys ⟹ Parallel ?xs ∼ Parallel ?ys› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ NonD ?x ?u ∼ NonD ?y ?v› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Executable ?x ?u ∼ Executable ?y ?v› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Repeatable ?x ?u ∼ Repeatable ?y ?v› ‹?x ∼ ?y ⟹ ?y ∼ ?x› and more 1 facts*))
(*discuss goal 3*)
apply (rule res_term_equiv.intros (*‹Parallel [] ∼ Empty› ‹Parallel [?a::(?'a::type, ?'b::type) res_term] ∼ ?a› ‹Parallel ((?x::(?'a::type, ?'b::type) res_term list) @ [Parallel (?y::(?'a::type, ?'b::type) res_term list)] @ (?z::(?'a::type, ?'b::type) res_term list)) ∼ Parallel (?x @ ?y @ ?z)› ‹Empty ∼ Empty› ‹Anything ∼ Anything› ‹Res (?x::?'a::type) ∼ Res ?x› ‹Copyable (?x::?'b::type) ∼ Copyable ?x› ‹list_all2 (∼) (?xs::(?'a::type, ?'b::type) res_term list) (?ys::(?'a::type, ?'b::type) res_term list) ⟹ Parallel ?xs ∼ Parallel ?ys› ‹⟦(?x::(?'a::type, ?'b::type) res_term) ∼ (?y::(?'a::type, ?'b::type) res_term); (?u::(?'a::type, ?'b::type) res_term) ∼ (?v::(?'a::type, ?'b::type) res_term)⟧ ⟹ NonD ?x ?u ∼ NonD ?y ?v› ‹⟦(?x::(?'a::type, ?'b::type) res_term) ∼ (?y::(?'a::type, ?'b::type) res_term); (?u::(?'a::type, ?'b::type) res_term) ∼ (?v::(?'a::type, ?'b::type) res_term)⟧ ⟹ Executable ?x ?u ∼ Executable ?y ?v› ‹⟦(?x::(?'a::type, ?'b::type) res_term) ∼ (?y::(?'a::type, ?'b::type) res_term); (?u::(?'a::type, ?'b::type) res_term) ∼ (?v::(?'a::type, ?'b::type) res_term)⟧ ⟹ Repeatable ?x ?u ∼ Repeatable ?y ?v› ‹(?x::(?'a::type, ?'b::type) res_term) ∼ (?y::(?'a::type, ?'b::type) res_term) ⟹ ?y ∼ ?x› and more 1 facts*))
(*discuss goal 4*)
apply (rule res_term_equiv.intros (*‹Parallel [] ∼ Empty› ‹Parallel [?a] ∼ ?a› ‹Parallel (?x @ [Parallel ?y] @ ?z) ∼ Parallel (?x @ ?y @ ?z)› ‹Empty ∼ Empty› ‹Anything ∼ Anything› ‹Res ?x ∼ Res ?x› ‹Copyable ?x ∼ Copyable ?x› ‹list_all2 (∼) ?xs ?ys ⟹ Parallel ?xs ∼ Parallel ?ys› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ NonD ?x ?u ∼ NonD ?y ?v› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Executable ?x ?u ∼ Executable ?y ?v› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Repeatable ?x ?u ∼ Repeatable ?y ?v› ‹?x ∼ ?y ⟹ ?y ∼ ?x› and more 1 facts*))
(*discuss goal 5*)
apply (rule res_term_equiv.intros (*‹Parallel [] ∼ Empty› ‹Parallel [?a] ∼ ?a› ‹Parallel (?x @ [Parallel ?y] @ ?z) ∼ Parallel (?x @ ?y @ ?z)› ‹Empty ∼ Empty› ‹Anything ∼ Anything› ‹Res ?x ∼ Res ?x› ‹Copyable ?x ∼ Copyable ?x› ‹list_all2 (∼) ?xs ?ys ⟹ Parallel ?xs ∼ Parallel ?ys› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ NonD ?x ?u ∼ NonD ?y ?v› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Executable ?x ?u ∼ Executable ?y ?v› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Repeatable ?x ?u ∼ Repeatable ?y ?v› ‹?x ∼ ?y ⟹ ?y ∼ ?x› and more 1 facts*))
(*top goal: ‹⋀x. (⋀xa. xa ∈ set x ⟹ xa ∼ xa) ⟹ Parallel x ∼ Parallel x› and 3 goals remain*)
apply (simp add: list_all2_same (*‹list_all2 ?P ?xs ?xs = (∀x∈set ?xs. ?P x x)›*))
(*discuss goal 6*)
apply (rule res_term_equiv.intros (*‹Parallel [] ∼ Empty› ‹Parallel [?a] ∼ ?a› ‹Parallel (?x @ [Parallel ?y] @ ?z) ∼ Parallel (?x @ ?y @ ?z)› ‹Empty ∼ Empty› ‹Anything ∼ Anything› ‹Res ?x ∼ Res ?x› ‹Copyable ?x ∼ Copyable ?x› ‹list_all2 (∼) ?xs ?ys ⟹ Parallel ?xs ∼ Parallel ?ys› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ NonD ?x ?u ∼ NonD ?y ?v› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Executable ?x ?u ∼ Executable ?y ?v› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Repeatable ?x ?u ∼ Repeatable ?y ?v› ‹?x ∼ ?y ⟹ ?y ∼ ?x› and more 1 facts*))
(*goals:
1. ‹⋀a1 a2. ⟦a1 ∼ a1; a2 ∼ a2⟧ ⟹ a1 ∼ a1›
2. ‹⋀a1 a2. ⟦a1 ∼ a1; a2 ∼ a2⟧ ⟹ a2 ∼ a2›
discuss goal 1*)
apply (simp add: list_all2_same (*‹list_all2 ?P ?xs ?xs = (∀x∈set ?xs. ?P x x)›*))
(*discuss goal 2*)
apply (simp add: list_all2_same (*‹list_all2 ?P ?xs ?xs = (∀x∈set ?xs. ?P x x)›*))
(*proven 2 subgoals*)
(*discuss goal 7*)
apply (rule res_term_equiv.intros (*‹Parallel [] ∼ Empty› ‹Parallel [?a] ∼ ?a› ‹Parallel (?x @ [Parallel ?y] @ ?z) ∼ Parallel (?x @ ?y @ ?z)› ‹Empty ∼ Empty› ‹Anything ∼ Anything› ‹Res ?x ∼ Res ?x› ‹Copyable ?x ∼ Copyable ?x› ‹list_all2 (∼) ?xs ?ys ⟹ Parallel ?xs ∼ Parallel ?ys› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ NonD ?x ?u ∼ NonD ?y ?v› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Executable ?x ?u ∼ Executable ?y ?v› ‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Repeatable ?x ?u ∼ Repeatable ?y ?v› ‹?x ∼ ?y ⟹ ?y ∼ ?x› and more 1 facts*))
(*goals:
1. ‹⋀a1 a2. ⟦a1 ∼ a1; a2 ∼ a2⟧ ⟹ a1 ∼ a1›
2. ‹⋀a1 a2. ⟦a1 ∼ a1; a2 ∼ a2⟧ ⟹ a2 ∼ a2›
discuss goal 1*)
apply (simp add: list_all2_same (*‹list_all2 ?P ?xs ?xs = (∀x∈set ?xs. ?P x x)›*))
(*discuss goal 2*)
apply (simp add: list_all2_same (*‹list_all2 ?P ?xs ?xs = (∀x∈set ?xs. ?P x x)›*))
(*proven 2 subgoals*)
(*discuss goal 8*)
apply (rule res_term_equiv.intros (*‹Parallel [] ∼ Empty› ‹Parallel [?a::(?'a::type, ?'b::type) res_term] ∼ ?a› ‹Parallel ((?x::(?'a::type, ?'b::type) res_term list) @ [Parallel (?y::(?'a::type, ?'b::type) res_term list)] @ (?z::(?'a::type, ?'b::type) res_term list)) ∼ Parallel (?x @ ?y @ ?z)› ‹Empty ∼ Empty› ‹Anything ∼ Anything› ‹Res (?x::?'a::type) ∼ Res ?x› ‹Copyable (?x::?'b::type) ∼ Copyable ?x› ‹list_all2 (∼) (?xs::(?'a::type, ?'b::type) res_term list) (?ys::(?'a::type, ?'b::type) res_term list) ⟹ Parallel ?xs ∼ Parallel ?ys› ‹⟦(?x::(?'a::type, ?'b::type) res_term) ∼ (?y::(?'a::type, ?'b::type) res_term); (?u::(?'a::type, ?'b::type) res_term) ∼ (?v::(?'a::type, ?'b::type) res_term)⟧ ⟹ NonD ?x ?u ∼ NonD ?y ?v› ‹⟦(?x::(?'a::type, ?'b::type) res_term) ∼ (?y::(?'a::type, ?'b::type) res_term); (?u::(?'a::type, ?'b::type) res_term) ∼ (?v::(?'a::type, ?'b::type) res_term)⟧ ⟹ Executable ?x ?u ∼ Executable ?y ?v› ‹⟦(?x::(?'a::type, ?'b::type) res_term) ∼ (?y::(?'a::type, ?'b::type) res_term); (?u::(?'a::type, ?'b::type) res_term) ∼ (?v::(?'a::type, ?'b::type) res_term)⟧ ⟹ Repeatable ?x ?u ∼ Repeatable ?y ?v› ‹(?x::(?'a::type, ?'b::type) res_term) ∼ (?y::(?'a::type, ?'b::type) res_term) ⟹ ?y ∼ ?x› and more 1 facts*))
(*goals:
1. ‹⋀a1 a2. ⟦a1 ∼ a1; a2 ∼ a2⟧ ⟹ a1 ∼ a1›
2. ‹⋀a1 a2. ⟦a1 ∼ a1; a2 ∼ a2⟧ ⟹ a2 ∼ a2›
discuss goal 1*)
apply (simp add: list_all2_same (*‹list_all2 ?P ?xs ?xs = (∀x∈set ?xs. ?P x x)›*))
(*discuss goal 2*)
apply (simp add: list_all2_same (*‹list_all2 ?P ?xs ?xs = (∀x∈set ?xs. ?P x x)›*))
(*proven 2 subgoals*)
(*proven 8 subgoals*) .
lemma reflI:
"a = b ⟹ a ∼ b"
by simp
lemma equivp [simp]:
"equivp res_term_equiv"
by (simp add: equivpI (*‹⟦reflp ?R; symp ?R; transp ?R⟧ ⟹ equivp ?R›*) reflpI (*‹(⋀x. ?R x x) ⟹ reflp ?R›*) res_term_equiv.sym (*‹?x ∼ ?y ⟹ ?y ∼ ?x›*) res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*) sympI (*‹(⋀x y. ?R x y ⟹ ?R y x) ⟹ symp ?R›*) transpI (*‹(⋀x y z. ⟦?R x y; ?R y z⟧ ⟹ ?R x z) ⟹ transp ?R›*))
text‹Parallel resource terms can be related by splitting them into parts›
lemma decompose:
assumes "Parallel x1 ∼ Parallel y1"
and "Parallel x2 ∼ Parallel y2"
shows "Parallel (x1 @ x2) ∼ Parallel (y1 @ y2)"
proof (-)
(*goal: ‹Parallel ((x1::('a, 'b) res_term list) @ (x2::('a, 'b) res_term list)) ∼ Parallel ((y1::('a, 'b) res_term list) @ (y2::('a, 'b) res_term list))›*)
have "Parallel [Parallel x1, Parallel x2] ∼ Parallel [Parallel y1, Parallel y2]"
by (simp add: assms (*‹Parallel x1 ∼ Parallel y1› ‹Parallel x2 ∼ Parallel y2›*) res_term_equiv.parallel (*‹list_all2 (∼) ?xs ?ys ⟹ Parallel ?xs ∼ Parallel ?ys›*))
then have "Parallel (Parallel x1 # x2) ∼ Parallel (Parallel y1 # y2)"
using res_term_equiv.merge[of "[Parallel x1]" x2 Nil, simplified] (*‹Parallel [Parallel x1, Parallel x2] ∼ Parallel (Parallel x1 # x2)›*) res_term_equiv.merge[of "[Parallel y1]" y2 Nil, simplified] (*‹Parallel [Parallel y1, Parallel y2] ∼ Parallel (Parallel y1 # y2)›*) by (meson res_term_equiv.sym (*‹?x ∼ ?y ⟹ ?y ∼ ?x›*) res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*))
then show "Parallel (x1 @ x2) ∼ Parallel (y1 @ y2)"
using res_term_equiv.merge[of Nil y1 y2, simplified] (*‹Parallel (Parallel y1 # y2) ∼ Parallel (y1 @ y2)›*) res_term_equiv.merge[of Nil x1 x2, simplified] (*‹Parallel (Parallel x1 # x2) ∼ Parallel (x1 @ x2)›*) by (meson res_term_equiv.sym (*‹?x ∼ ?y ⟹ ?y ∼ ?x›*) res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*))
qed
text‹We can drop a unit from any parallel resource term›
lemma drop:
"Parallel (x @ [Empty] @ y) ∼ Parallel (x @ y)"
proof (-)
(*goal: ‹Parallel (x @ [Empty] @ y) ∼ Parallel (x @ y)›*)
have "Parallel [Empty] ∼ Parallel [Parallel []]"
using res_term_equiv.nil (*‹Parallel [] ∼ Empty›*) res_term_equiv.sym (*‹?x ∼ ?y ⟹ ?y ∼ ?x›*) res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*) res_term_equiv.singleton (*‹Parallel [?a] ∼ ?a›*) by blast
then have "Parallel (x @ [Empty] @ y) ∼ Parallel (x @ [Parallel []] @ y)"
using res_term_equiv.decompose[OF res_term_equiv.refl, of "[Empty] @ y" "[Parallel []] @ y" x] (*‹Parallel ([Empty] @ y) ∼ Parallel ([Parallel []] @ y) ⟹ Parallel (x @ [Empty] @ y) ∼ Parallel (x @ [Parallel []] @ y)›*) res_term_equiv.decompose[OF _ res_term_equiv.refl, of "[Empty]" "[Parallel []]" y] (*‹Parallel [Empty] ∼ Parallel [Parallel []] ⟹ Parallel ([Empty] @ y) ∼ Parallel ([Parallel []] @ y)›*) by blast
then show "?thesis"
(*goal: ‹Parallel (x @ [Empty] @ y) ∼ Parallel (x @ y)›*)
using res_term_equiv.merge (*‹Parallel (?x @ [Parallel ?y] @ ?z) ∼ Parallel (?x @ ?y @ ?z)›*) res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*) by fastforce
qed
text‹Equivalent resource terms remain equivalent wrapped in a parallel›
lemma singleton_both:
"x ∼ y ⟹ Parallel [x] ∼ Parallel [y]"
by (simp add: res_term_equiv.parallel (*‹list_all2 (∼) (?xs::(?'a::type, ?'b::type) res_term list) (?ys::(?'a::type, ?'b::type) res_term list) ⟹ Parallel ?xs ∼ Parallel ?ys›*))
text‹We can reduce a resource term equivalence given equivalences for both sides›
lemma trans_both:
"⟦a ∼ x; y ∼ b; x ∼ y⟧ ⟹ a ∼ b"
apply (rule res_term_equiv.trans[OF res_term_equiv.trans] (*‹⟦(?x::(?'a::type, ?'b::type) res_term) ∼ (?y1::(?'a::type, ?'b::type) res_term); ?y1 ∼ (?y::(?'a::type, ?'b::type) res_term); ?y ∼ (?z::(?'a::type, ?'b::type) res_term)⟧ ⟹ ?x ∼ ?z›*))
(*goals:
1. ‹⟦a ∼ x; y ∼ b; x ∼ y⟧ ⟹ a ∼ ?y1›
2. ‹⟦a ∼ x; y ∼ b; x ∼ y⟧ ⟹ ?y1 ∼ ?y›
3. ‹⟦a ∼ x; y ∼ b; x ∼ y⟧ ⟹ ?y ∼ b›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*)
apply ((assumption)[1])
(*discuss goal 3*) .
(*proven 3 subgoals*)
setup ‹Sign.parent_path›
experiment begin
lemma "Parallel [Parallel [], Empty] ∼ Empty"
proof (-)
(*goal: ‹Parallel [Parallel [], Empty] ∼ Empty›*)
have "Parallel [Parallel [], Empty] ∼ Parallel [Parallel []]"
using res_term_equiv.drop[of "[Parallel []]"] (*‹Parallel ([Parallel []] @ [Empty] @ ?y) ∼ Parallel ([Parallel []] @ ?y)›*) by simp
also (*calculation: ‹Parallel [Parallel [], Empty] ∼ Parallel [Parallel []]›*) have "... ∼ Parallel []"
by simp
also (*calculation: ‹Parallel [Parallel [], Empty] ∼ Parallel []›*) have "... ∼ Empty"
by simp
finally (*calculation: ‹Parallel [Parallel [], Empty] ∼ Empty›*) show "?thesis"
(*goal: ‹Parallel [Parallel [], Empty] ∼ Empty›*) .
qed
end
text‹Inserting equivalent terms anywhere in equivalent parallel terms preserves the equivalence›
lemma res_term_parallel_insert:
assumes "Parallel x ∼ Parallel y"
and "Parallel u ∼ Parallel v"
and "a ∼ b"
shows "Parallel (x @ [a] @ u) ∼ Parallel (y @ [b] @ v)"
by (meson assms (*‹Parallel x ∼ Parallel y› ‹Parallel u ∼ Parallel v› ‹a ∼ b›*) res_term_equiv.decompose (*‹⟦Parallel ?x1.0 ∼ Parallel ?y1.0; Parallel ?x2.0 ∼ Parallel ?y2.0⟧ ⟹ Parallel (?x1.0 @ ?x2.0) ∼ Parallel (?y1.0 @ ?y2.0)›*) res_term_equiv.singleton_both (*‹?x ∼ ?y ⟹ Parallel [?x] ∼ Parallel [?y]›*))
text‹With inserting at the start being just a special case›
lemma res_term_parallel_cons:
assumes "Parallel x ∼ Parallel y"
and "a ∼ b"
shows "Parallel (a # x) ∼ Parallel (b # y)"
using res_term_parallel_insert[OF res_term_equiv.refl assms, of Nil] (*‹Parallel ([] @ [a] @ x) ∼ Parallel ([] @ [b] @ y)›*) by simp
text‹@{const Empty} is a unit for binary @{const Parallel}›
lemma res_term_parallel_emptyR [simp]: "Parallel [x, Empty] ∼ x"
using res_term_equiv.drop[of "[x]" Nil] (*‹Parallel ([x] @ [Empty] @ []) ∼ Parallel ([x] @ [])›*) by (simp add: res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*))
lemma res_term_parallel_emptyL [simp]: "Parallel [Empty, x] ∼ x"
using res_term_equiv.drop[of Nil "[x]"] (*‹Parallel ([] @ [Empty] @ [x]) ∼ Parallel ([] @ [x])›*) by (simp add: res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*))
text‹Term equivalence is preserved by parallel on either side›
lemma res_term_equiv_parallel [simp]:
"x ∼ y ⟹ x ∼ Parallel [y]"
using res_term_equiv.singleton (*‹Parallel [?a] ∼ ?a›*) res_term_equiv.sym (*‹?x ∼ ?y ⟹ ?y ∼ ?x›*) res_term_equiv.trans (*‹⟦(?x::(?'a, ?'b) res_term) ∼ (?y::(?'a, ?'b) res_term); ?y ∼ (?z::(?'a, ?'b) res_term)⟧ ⟹ ?x ∼ ?z›*) by blast
lemmas [simp] = res_term_equiv_parallel[symmetric]
text‹Resource term map preserves equivalence:›
lemma map_res_term_preserves_equiv [simp]:
"x ∼ y ⟹ map_res_term f g x ∼ map_res_term f g y"
proof (induct rule: res_term_equiv.induct (*‹⟦?x1.0 ∼ ?x2.0; ?P (Parallel []) Empty; ⋀a. ?P (Parallel [a]) a; ⋀x y z. ?P (Parallel (x @ [Parallel y] @ z)) (Parallel (x @ y @ z)); ?P Empty Empty; ?P Anything Anything; ⋀x. ?P (Res x) (Res x); ⋀x. ?P (Copyable x) (Copyable x); ⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ ?P x1 x2) xs ys ⟹ ?P (Parallel xs) (Parallel ys); ⋀x y u v. ⟦x ∼ y; ?P x y; u ∼ v; ?P u v⟧ ⟹ ?P (NonD x u) (NonD y v); ⋀x y u v. ⟦x ∼ y; ?P x y; u ∼ v; ?P u v⟧ ⟹ ?P (Executable x u) (Executable y v); ⋀x y u v. ⟦x ∼ y; ?P x y; u ∼ v; ?P u v⟧ ⟹ ?P (Repeatable x u) (Repeatable y v); ⋀x y. ⟦x ∼ y; ?P x y⟧ ⟹ ?P y x; ⋀x y z. ⟦x ∼ y; ?P x y; y ∼ z; ?P y z⟧ ⟹ ?P x z⟧ ⟹ ?P ?x1.0 ?x2.0›*))
(*goals:
1. ‹map_res_term f g (Parallel []) ∼ map_res_term f g Empty›
2. ‹⋀a. map_res_term f g (Parallel [a]) ∼ map_res_term f g a›
3. ‹⋀x y z. map_res_term f g (Parallel (x @ [Parallel y] @ z)) ∼ map_res_term f g (Parallel (x @ y @ z))›
4. ‹map_res_term f g Empty ∼ map_res_term f g Empty›
5. ‹map_res_term f g Anything ∼ map_res_term f g Anything›
6. ‹⋀x. map_res_term f g (Res x) ∼ map_res_term f g (Res x)›
7. ‹⋀x. map_res_term f g (Copyable x) ∼ map_res_term f g (Copyable x)›
8. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ map_res_term f g x1 ∼ map_res_term f g x2) xs ys ⟹ map_res_term f g (Parallel xs) ∼ map_res_term f g (Parallel ys)›
9. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (NonD x u) ∼ map_res_term f g (NonD y v)›
10. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Executable x u) ∼ map_res_term f g (Executable y v)›
11. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Repeatable x u) ∼ map_res_term f g (Repeatable y v)›
12. ‹⋀x y. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y⟧ ⟹ map_res_term f g y ∼ map_res_term f g x›
13. ‹⋀x y z. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; y ∼ z; map_res_term f g y ∼ map_res_term f g z⟧ ⟹ map_res_term f g x ∼ map_res_term f g z›*)
case empty (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹map_res_term f g Empty ∼ map_res_term f g Empty›*)
by simp
next
(*goals:
1. ‹map_res_term f g (Parallel []) ∼ map_res_term f g Empty›
2. ‹⋀a. map_res_term f g (Parallel [a]) ∼ map_res_term f g a›
3. ‹⋀x y z. map_res_term f g (Parallel (x @ [Parallel y] @ z)) ∼ map_res_term f g (Parallel (x @ y @ z))›
4. ‹map_res_term f g Anything ∼ map_res_term f g Anything›
5. ‹⋀x. map_res_term f g (Res x) ∼ map_res_term f g (Res x)›
6. ‹⋀x. map_res_term f g (Copyable x) ∼ map_res_term f g (Copyable x)›
7. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ map_res_term f g x1 ∼ map_res_term f g x2) xs ys ⟹ map_res_term f g (Parallel xs) ∼ map_res_term f g (Parallel ys)›
8. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (NonD x u) ∼ map_res_term f g (NonD y v)›
9. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Executable x u) ∼ map_res_term f g (Executable y v)›
10. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Repeatable x u) ∼ map_res_term f g (Repeatable y v)›
11. ‹⋀x y. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y⟧ ⟹ map_res_term f g y ∼ map_res_term f g x›
12. ‹⋀x y z. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; y ∼ z; map_res_term f g y ∼ map_res_term f g z⟧ ⟹ map_res_term f g x ∼ map_res_term f g z›*)
case anything (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹map_res_term f g Anything ∼ map_res_term f g Anything›*)
by simp
next
(*goals:
1. ‹map_res_term (f::'a::type ⇒ 'c::type) (g::'b::type ⇒ 'd::type) (Parallel []) ∼ map_res_term f g Empty›
2. ‹⋀a::('a::type, 'b::type) res_term. map_res_term (f::'a::type ⇒ 'c::type) (g::'b::type ⇒ 'd::type) (Parallel [a]) ∼ map_res_term f g a›
3. ‹⋀(x::('a::type, 'b::type) res_term list) (y::('a::type, 'b::type) res_term list) z::('a::type, 'b::type) res_term list. map_res_term (f::'a::type ⇒ 'c::type) (g::'b::type ⇒ 'd::type) (Parallel (x @ [Parallel y] @ z)) ∼ map_res_term f g (Parallel (x @ y @ z))›
4. ‹⋀x::'a::type. map_res_term (f::'a::type ⇒ 'c::type) (g::'b::type ⇒ 'd::type) (Res x) ∼ map_res_term f g (Res x)›
5. ‹⋀x::'b::type. map_res_term (f::'a::type ⇒ 'c::type) (g::'b::type ⇒ 'd::type) (Copyable x) ∼ map_res_term f g (Copyable x)›
6. ‹⋀(xs::('a::type, 'b::type) res_term list) ys::('a::type, 'b::type) res_term list. list_all2 (λ(x1::('a::type, 'b::type) res_term) x2::('a::type, 'b::type) res_term. x1 ∼ x2 ∧ map_res_term (f::'a::type ⇒ 'c::type) (g::'b::type ⇒ 'd::type) x1 ∼ map_res_term f g x2) xs ys ⟹ map_res_term f g (Parallel xs) ∼ map_res_term f g (Parallel ys)›
7. ‹⋀(x::('a::type, 'b::type) res_term) (y::('a::type, 'b::type) res_term) (u::('a::type, 'b::type) res_term) v::('a::type, 'b::type) res_term. ⟦x ∼ y; map_res_term (f::'a::type ⇒ 'c::type) (g::'b::type ⇒ 'd::type) x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (NonD x u) ∼ map_res_term f g (NonD y v)›
8. ‹⋀(x::('a::type, 'b::type) res_term) (y::('a::type, 'b::type) res_term) (u::('a::type, 'b::type) res_term) v::('a::type, 'b::type) res_term. ⟦x ∼ y; map_res_term (f::'a::type ⇒ 'c::type) (g::'b::type ⇒ 'd::type) x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Executable x u) ∼ map_res_term f g (Executable y v)›
9. ‹⋀(x::('a::type, 'b::type) res_term) (y::('a::type, 'b::type) res_term) (u::('a::type, 'b::type) res_term) v::('a::type, 'b::type) res_term. ⟦x ∼ y; map_res_term (f::'a::type ⇒ 'c::type) (g::'b::type ⇒ 'd::type) x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Repeatable x u) ∼ map_res_term f g (Repeatable y v)›
10. ‹⋀(x::('a::type, 'b::type) res_term) y::('a::type, 'b::type) res_term. ⟦x ∼ y; map_res_term (f::'a::type ⇒ 'c::type) (g::'b::type ⇒ 'd::type) x ∼ map_res_term f g y⟧ ⟹ map_res_term f g y ∼ map_res_term f g x›
11. ‹⋀(x::('a::type, 'b::type) res_term) (y::('a::type, 'b::type) res_term) z::('a::type, 'b::type) res_term. ⟦x ∼ y; map_res_term (f::'a::type ⇒ 'c::type) (g::'b::type ⇒ 'd::type) x ∼ map_res_term f g y; y ∼ z; map_res_term f g y ∼ map_res_term f g z⟧ ⟹ map_res_term f g x ∼ map_res_term f g z›*)
case (res x) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹map_res_term f g (Res x) ∼ map_res_term f g (Res x)›*)
by simp
next
(*goals:
1. ‹map_res_term f g (Parallel []) ∼ map_res_term f g Empty›
2. ‹⋀a. map_res_term f g (Parallel [a]) ∼ map_res_term f g a›
3. ‹⋀x y z. map_res_term f g (Parallel (x @ [Parallel y] @ z)) ∼ map_res_term f g (Parallel (x @ y @ z))›
4. ‹⋀x. map_res_term f g (Copyable x) ∼ map_res_term f g (Copyable x)›
5. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ map_res_term f g x1 ∼ map_res_term f g x2) xs ys ⟹ map_res_term f g (Parallel xs) ∼ map_res_term f g (Parallel ys)›
6. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (NonD x u) ∼ map_res_term f g (NonD y v)›
7. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Executable x u) ∼ map_res_term f g (Executable y v)›
8. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Repeatable x u) ∼ map_res_term f g (Repeatable y v)›
9. ‹⋀x y. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y⟧ ⟹ map_res_term f g y ∼ map_res_term f g x›
10. ‹⋀x y z. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; y ∼ z; map_res_term f g y ∼ map_res_term f g z⟧ ⟹ map_res_term f g x ∼ map_res_term f g z›*)
case (copyable x) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹map_res_term f g (Copyable x) ∼ map_res_term f g (Copyable x)›*)
by simp
next
(*goals:
1. ‹map_res_term f g (Parallel []) ∼ map_res_term f g Empty›
2. ‹⋀a. map_res_term f g (Parallel [a]) ∼ map_res_term f g a›
3. ‹⋀x y z. map_res_term f g (Parallel (x @ [Parallel y] @ z)) ∼ map_res_term f g (Parallel (x @ y @ z))›
4. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ map_res_term f g x1 ∼ map_res_term f g x2) xs ys ⟹ map_res_term f g (Parallel xs) ∼ map_res_term f g (Parallel ys)›
5. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (NonD x u) ∼ map_res_term f g (NonD y v)›
6. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Executable x u) ∼ map_res_term f g (Executable y v)›
7. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Repeatable x u) ∼ map_res_term f g (Repeatable y v)›
8. ‹⋀x y. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y⟧ ⟹ map_res_term f g y ∼ map_res_term f g x›
9. ‹⋀x y z. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; y ∼ z; map_res_term f g y ∼ map_res_term f g z⟧ ⟹ map_res_term f g x ∼ map_res_term f g z›*)
case nil (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹map_res_term f g (Parallel []) ∼ map_res_term f g Empty›*)
by simp
next
(*goals:
1. ‹⋀a. map_res_term f g (Parallel [a]) ∼ map_res_term f g a›
2. ‹⋀x y z. map_res_term f g (Parallel (x @ [Parallel y] @ z)) ∼ map_res_term f g (Parallel (x @ y @ z))›
3. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ map_res_term f g x1 ∼ map_res_term f g x2) xs ys ⟹ map_res_term f g (Parallel xs) ∼ map_res_term f g (Parallel ys)›
4. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (NonD x u) ∼ map_res_term f g (NonD y v)›
5. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Executable x u) ∼ map_res_term f g (Executable y v)›
6. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Repeatable x u) ∼ map_res_term f g (Repeatable y v)›
7. ‹⋀x y. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y⟧ ⟹ map_res_term f g y ∼ map_res_term f g x›
8. ‹⋀x y z. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; y ∼ z; map_res_term f g y ∼ map_res_term f g z⟧ ⟹ map_res_term f g x ∼ map_res_term f g z›*)
case (singleton a) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹map_res_term (f::'a ⇒ 'c) (g::'b ⇒ 'd) (Parallel [a::('a, 'b) res_term]) ∼ map_res_term f g a›*)
by simp
next
(*goals:
1. ‹⋀x y z. map_res_term f g (Parallel (x @ [Parallel y] @ z)) ∼ map_res_term f g (Parallel (x @ y @ z))›
2. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ map_res_term f g x1 ∼ map_res_term f g x2) xs ys ⟹ map_res_term f g (Parallel xs) ∼ map_res_term f g (Parallel ys)›
3. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (NonD x u) ∼ map_res_term f g (NonD y v)›
4. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Executable x u) ∼ map_res_term f g (Executable y v)›
5. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Repeatable x u) ∼ map_res_term f g (Repeatable y v)›
6. ‹⋀x y. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y⟧ ⟹ map_res_term f g y ∼ map_res_term f g x›
7. ‹⋀x y z. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; y ∼ z; map_res_term f g y ∼ map_res_term f g z⟧ ⟹ map_res_term f g x ∼ map_res_term f g z›*)
case (merge x y z) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹map_res_term (f::'a ⇒ 'c) (g::'b ⇒ 'd) (Parallel ((x::('a, 'b) res_term list) @ [Parallel (y::('a, 'b) res_term list)] @ (z::('a, 'b) res_term list))) ∼ map_res_term f g (Parallel (x @ y @ z))›*)
using res_term_equiv.merge (*‹Parallel (?x @ [Parallel ?y] @ ?z) ∼ Parallel (?x @ ?y @ ?z)›*) by fastforce
next
(*goals:
1. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ map_res_term f g x1 ∼ map_res_term f g x2) xs ys ⟹ map_res_term f g (Parallel xs) ∼ map_res_term f g (Parallel ys)›
2. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (NonD x u) ∼ map_res_term f g (NonD y v)›
3. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Executable x u) ∼ map_res_term f g (Executable y v)›
4. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Repeatable x u) ∼ map_res_term f g (Repeatable y v)›
5. ‹⋀x y. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y⟧ ⟹ map_res_term f g y ∼ map_res_term f g x›
6. ‹⋀x y z. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; y ∼ z; map_res_term f g y ∼ map_res_term f g z⟧ ⟹ map_res_term f g x ∼ map_res_term f g z›*)
case (parallel xs ys) (*‹list_all2 (λx1 x2. x1 ∼ x2 ∧ map_res_term f g x1 ∼ map_res_term f g x2) xs ys›*)
then show "?case"
(*goal: ‹map_res_term f g (Parallel xs) ∼ map_res_term f g (Parallel ys)›*)
by (simp add: list_all2_conv_all_nth (*‹list_all2 (?P::?'a ⇒ ?'b ⇒ bool) (?xs::?'a list) (?ys::?'b list) = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*) res_term_equiv.parallel (*‹list_all2 (∼) (?xs::(?'a, ?'b) res_term list) (?ys::(?'a, ?'b) res_term list) ⟹ Parallel ?xs ∼ Parallel ?ys›*))
next
(*goals:
1. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; map_res_term (f::'a ⇒ 'c) (g::'b ⇒ 'd) x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (NonD x u) ∼ map_res_term f g (NonD y v)›
2. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; map_res_term (f::'a ⇒ 'c) (g::'b ⇒ 'd) x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Executable x u) ∼ map_res_term f g (Executable y v)›
3. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; map_res_term (f::'a ⇒ 'c) (g::'b ⇒ 'd) x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Repeatable x u) ∼ map_res_term f g (Repeatable y v)›
4. ‹⋀(x::('a, 'b) res_term) y::('a, 'b) res_term. ⟦x ∼ y; map_res_term (f::'a ⇒ 'c) (g::'b ⇒ 'd) x ∼ map_res_term f g y⟧ ⟹ map_res_term f g y ∼ map_res_term f g x›
5. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) z::('a, 'b) res_term. ⟦x ∼ y; map_res_term (f::'a ⇒ 'c) (g::'b ⇒ 'd) x ∼ map_res_term f g y; y ∼ z; map_res_term f g y ∼ map_res_term f g z⟧ ⟹ map_res_term f g x ∼ map_res_term f g z›*)
case (nondet x y u v) (*‹x ∼ y› ‹map_res_term f g x ∼ map_res_term f g y› ‹u ∼ v› ‹map_res_term (f::'a ⇒ 'c) (g::'b ⇒ 'd) (u::('a, 'b) res_term) ∼ map_res_term f g (v::('a, 'b) res_term)›*)
then show "?case"
(*goal: ‹map_res_term f g (NonD x u) ∼ map_res_term f g (NonD y v)›*)
by (simp add: res_term_equiv.nondet (*‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ NonD ?x ?u ∼ NonD ?y ?v›*))
next
(*goals:
1. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Executable x u) ∼ map_res_term f g (Executable y v)›
2. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Repeatable x u) ∼ map_res_term f g (Repeatable y v)›
3. ‹⋀x y. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y⟧ ⟹ map_res_term f g y ∼ map_res_term f g x›
4. ‹⋀x y z. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; y ∼ z; map_res_term f g y ∼ map_res_term f g z⟧ ⟹ map_res_term f g x ∼ map_res_term f g z›*)
case (executable x y u v) (*‹(x::('a::type, 'b::type) res_term) ∼ (y::('a::type, 'b::type) res_term)› ‹map_res_term f g x ∼ map_res_term f g y› ‹u ∼ v› ‹map_res_term f g u ∼ map_res_term f g v›*)
then show "?case"
(*goal: ‹map_res_term f g (Executable x u) ∼ map_res_term f g (Executable y v)›*)
by (simp add: res_term_equiv.executable (*‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Executable ?x ?u ∼ Executable ?y ?v›*))
next
(*goals:
1. ‹⋀x y u v. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; u ∼ v; map_res_term f g u ∼ map_res_term f g v⟧ ⟹ map_res_term f g (Repeatable x u) ∼ map_res_term f g (Repeatable y v)›
2. ‹⋀x y. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y⟧ ⟹ map_res_term f g y ∼ map_res_term f g x›
3. ‹⋀x y z. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; y ∼ z; map_res_term f g y ∼ map_res_term f g z⟧ ⟹ map_res_term f g x ∼ map_res_term f g z›*)
case (repeatable x y u v) (*‹x ∼ y› ‹map_res_term f g x ∼ map_res_term f g y› ‹(u::('a, 'b) res_term) ∼ (v::('a, 'b) res_term)› ‹map_res_term (f::'a ⇒ 'c) (g::'b ⇒ 'd) (u::('a, 'b) res_term) ∼ map_res_term f g (v::('a, 'b) res_term)›*)
then show "?case"
(*goal: ‹map_res_term f g (Repeatable x u) ∼ map_res_term f g (Repeatable y v)›*)
by (simp add: res_term_equiv.repeatable (*‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Repeatable ?x ?u ∼ Repeatable ?y ?v›*))
next
(*goals:
1. ‹⋀x y. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y⟧ ⟹ map_res_term f g y ∼ map_res_term f g x›
2. ‹⋀x y z. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; y ∼ z; map_res_term f g y ∼ map_res_term f g z⟧ ⟹ map_res_term f g x ∼ map_res_term f g z›*)
case (sym x y) (*‹x ∼ y› ‹map_res_term f g x ∼ map_res_term f g y›*)
then show "?case"
(*goal: ‹map_res_term f g y ∼ map_res_term f g x›*)
by (simp add: res_term_equiv.sym (*‹?x ∼ ?y ⟹ ?y ∼ ?x›*))
next
(*goal: ‹⋀x y z. ⟦x ∼ y; map_res_term f g x ∼ map_res_term f g y; y ∼ z; map_res_term f g y ∼ map_res_term f g z⟧ ⟹ map_res_term f g x ∼ map_res_term f g z›*)
case (trans x y z) (*‹(x::('a::type, 'b::type) res_term) ∼ (y::('a::type, 'b::type) res_term)› ‹map_res_term (f::'a ⇒ 'c) (g::'b ⇒ 'd) (x::('a, 'b) res_term) ∼ map_res_term f g (y::('a, 'b) res_term)› ‹y ∼ z› ‹map_res_term f g y ∼ map_res_term f g z›*)
then show "?case"
(*goal: ‹map_res_term (f::'a ⇒ 'c) (g::'b ⇒ 'd) (x::('a, 'b) res_term) ∼ map_res_term f g (z::('a, 'b) res_term)›*)
using res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*) by blast
qed
text‹
The other direction is not true in general, because they may be new equivalences created by
mapping different atoms to the same one.
However, the counter-example proof requires a decision procedure for the equivalence to prove
that two distinct atoms are not equivalent terms.
As such, we delay it until normalisation for the terms is established.
›
subsection‹Parallel Parts›
text‹
Parallel resources often arise in processes, because they describe the frequent situation of
having multiple resources be simultaneously present.
With resource terms, the way this situation is expressed can get complex.
To simplify it, we define a function to extract the list of parallel resource terms, traversing
nested @{const Parallel} terms and dropping any @{const Empty} resources in them.
We call these the parallel parts.
›
primrec parallel_parts :: "('a, 'b) res_term ⇒ ('a, 'b) res_term list"
where
"parallel_parts Empty = []"
| "parallel_parts Anything = [Anything]"
| "parallel_parts (Res a) = [Res a]"
| "parallel_parts (Copyable a) = [Copyable a]"
| "parallel_parts (Parallel xs) = concat (map parallel_parts xs)"
| "parallel_parts (NonD a b) = [NonD a b]"
| "parallel_parts (Executable a b) = [Executable a b]"
| "parallel_parts (Repeatable a b) = [Repeatable a b]"
text‹Every resource is equivalent to combining its parallel parts in parallel›
lemma parallel_parts_eq:
"x ∼ Parallel (parallel_parts x)"
proof (induct x)
(*goals:
1. ‹⋀x::'a. Res x ∼ Parallel (parallel_parts (Res x))›
2. ‹⋀x::'b. Copyable x ∼ Parallel (parallel_parts (Copyable x))›
3. ‹Empty ∼ Parallel (parallel_parts Empty)›
4. ‹Anything ∼ Parallel (parallel_parts Anything)›
5. ‹⋀x::('a, 'b) res_term list. (⋀xa::('a, 'b) res_term. xa ∈ set x ⟹ xa ∼ Parallel (parallel_parts xa)) ⟹ Parallel x ∼ Parallel (parallel_parts (Parallel x))›
6. ‹⋀(x1::('a, 'b) res_term) x2::('a, 'b) res_term. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ NonD x1 x2 ∼ Parallel (parallel_parts (NonD x1 x2))›
7. ‹⋀(x1::('a, 'b) res_term) x2::('a, 'b) res_term. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Executable x1 x2 ∼ Parallel (parallel_parts (Executable x1 x2))›
8. ‹⋀(x1::('a, 'b) res_term) x2::('a, 'b) res_term. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Repeatable x1 x2 ∼ Parallel (parallel_parts (Repeatable x1 x2))›*)
case Empty (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹Empty ∼ Parallel (parallel_parts Empty)›*)
by simp
next
(*goals:
1. ‹⋀x. Res x ∼ Parallel (parallel_parts (Res x))›
2. ‹⋀x. Copyable x ∼ Parallel (parallel_parts (Copyable x))›
3. ‹Anything ∼ Parallel (parallel_parts Anything)›
4. ‹⋀x. (⋀xa. xa ∈ set x ⟹ xa ∼ Parallel (parallel_parts xa)) ⟹ Parallel x ∼ Parallel (parallel_parts (Parallel x))›
5. ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ NonD x1 x2 ∼ Parallel (parallel_parts (NonD x1 x2))›
6. ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Executable x1 x2 ∼ Parallel (parallel_parts (Executable x1 x2))›
7. ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Repeatable x1 x2 ∼ Parallel (parallel_parts (Repeatable x1 x2))›*)
case Anything (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹Anything ∼ Parallel (parallel_parts Anything)›*)
by simp
next
(*goals:
1. ‹⋀x. Res x ∼ Parallel (parallel_parts (Res x))›
2. ‹⋀x. Copyable x ∼ Parallel (parallel_parts (Copyable x))›
3. ‹⋀x. (⋀xa. xa ∈ set x ⟹ xa ∼ Parallel (parallel_parts xa)) ⟹ Parallel x ∼ Parallel (parallel_parts (Parallel x))›
4. ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ NonD x1 x2 ∼ Parallel (parallel_parts (NonD x1 x2))›
5. ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Executable x1 x2 ∼ Parallel (parallel_parts (Executable x1 x2))›
6. ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Repeatable x1 x2 ∼ Parallel (parallel_parts (Repeatable x1 x2))›*)
case (Res x) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹Res x ∼ Parallel (parallel_parts (Res x))›*)
by simp
next
(*goals:
1. ‹⋀x. Copyable x ∼ Parallel (parallel_parts (Copyable x))›
2. ‹⋀x. (⋀xa. xa ∈ set x ⟹ xa ∼ Parallel (parallel_parts xa)) ⟹ Parallel x ∼ Parallel (parallel_parts (Parallel x))›
3. ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ NonD x1 x2 ∼ Parallel (parallel_parts (NonD x1 x2))›
4. ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Executable x1 x2 ∼ Parallel (parallel_parts (Executable x1 x2))›
5. ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Repeatable x1 x2 ∼ Parallel (parallel_parts (Repeatable x1 x2))›*)
case (Copyable x) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹Copyable x ∼ Parallel (parallel_parts (Copyable x))›*)
by simp
next
(*goals:
1. ‹⋀x. (⋀xa. xa ∈ set x ⟹ xa ∼ Parallel (parallel_parts xa)) ⟹ Parallel x ∼ Parallel (parallel_parts (Parallel x))›
2. ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ NonD x1 x2 ∼ Parallel (parallel_parts (NonD x1 x2))›
3. ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Executable x1 x2 ∼ Parallel (parallel_parts (Executable x1 x2))›
4. ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Repeatable x1 x2 ∼ Parallel (parallel_parts (Repeatable x1 x2))›*)
case (Parallel xs) (*‹?xa ∈ set xs ⟹ ?xa ∼ Parallel (parallel_parts ?xa)›*)
then show "?case"
(*goal: ‹Parallel xs ∼ Parallel (parallel_parts (Parallel xs))›*)
proof (induct xs)
(*goals:
1. ‹(⋀xa. xa ∈ set [] ⟹ xa ∼ Parallel (parallel_parts xa)) ⟹ Parallel [] ∼ Parallel (parallel_parts (Parallel []))›
2. ‹⋀a xs. ⟦(⋀xa. xa ∈ set xs ⟹ xa ∼ Parallel (parallel_parts xa)) ⟹ Parallel xs ∼ Parallel (parallel_parts (Parallel xs)); ⋀xa. xa ∈ set (a # xs) ⟹ xa ∼ Parallel (parallel_parts xa)⟧ ⟹ Parallel (a # xs) ∼ Parallel (parallel_parts (Parallel (a # xs)))›*)
case Nil (*‹?xa ∈ set [] ⟹ ?xa ∼ Parallel (parallel_parts ?xa)›*)
then show "?case"
(*goal: ‹Parallel [] ∼ Parallel (parallel_parts (Parallel []))›*)
by simp
next
(*goal: ‹⋀a xs. ⟦(⋀xa. xa ∈ set xs ⟹ xa ∼ Parallel (parallel_parts xa)) ⟹ Parallel xs ∼ Parallel (parallel_parts (Parallel xs)); ⋀xa. xa ∈ set (a # xs) ⟹ xa ∼ Parallel (parallel_parts xa)⟧ ⟹ Parallel (a # xs) ∼ Parallel (parallel_parts (Parallel (a # xs)))›*)
case (Cons a x) (*‹(⋀xaa. xaa ∈ set x ⟹ xaa ∼ Parallel (parallel_parts xaa)) ⟹ Parallel x ∼ Parallel (parallel_parts (Parallel x))› ‹?xa ∈ set (a # x) ⟹ ?xa ∼ Parallel (parallel_parts ?xa)›*)
then have a1: "a ∼ Parallel (parallel_parts a)" and a2: "Parallel x ∼ Parallel (parallel_parts (Parallel x))"
apply -
(*goals:
1. ‹⟦(⋀xaa. xaa ∈ set x ⟹ xaa ∼ Parallel (parallel_parts xaa)) ⟹ Parallel x ∼ Parallel (parallel_parts (Parallel x)); ⋀xaa. xaa ∈ set (a # x) ⟹ xaa ∼ Parallel (parallel_parts xaa)⟧ ⟹ a ∼ Parallel (parallel_parts a)›
2. ‹⟦(⋀xaa. xaa ∈ set x ⟹ xaa ∼ Parallel (parallel_parts xaa)) ⟹ Parallel x ∼ Parallel (parallel_parts (Parallel x)); ⋀xaa. xaa ∈ set (a # x) ⟹ xaa ∼ Parallel (parallel_parts xaa)⟧ ⟹ Parallel x ∼ Parallel (parallel_parts (Parallel x))›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
have "Parallel [a] ∼ Parallel (parallel_parts a)"
using a1 (*‹(a::('a::type, 'b::type) res_term) ∼ Parallel (parallel_parts a)›*) res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*) res_term_equiv.singleton (*‹Parallel [?a] ∼ ?a›*) by blast
then have "Parallel (a # x) ∼ Parallel (parallel_parts a @ parallel_parts (Parallel x))"
using res_term_equiv.decompose[OF _ a2, of "[a]"] (*‹Parallel [a] ∼ Parallel ?y1.0 ⟹ Parallel ([a] @ x) ∼ Parallel (?y1.0 @ parallel_parts (Parallel x))›*) by simp
then show "?case"
(*goal: ‹Parallel (a # x) ∼ Parallel (parallel_parts (Parallel (a # x)))›*)
by simp
qed
next
(*goals:
1. ‹⋀(x1::('a, 'b) res_term) x2::('a, 'b) res_term. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ NonD x1 x2 ∼ Parallel (parallel_parts (NonD x1 x2))›
2. ‹⋀(x1::('a, 'b) res_term) x2::('a, 'b) res_term. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Executable x1 x2 ∼ Parallel (parallel_parts (Executable x1 x2))›
3. ‹⋀(x1::('a, 'b) res_term) x2::('a, 'b) res_term. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Repeatable x1 x2 ∼ Parallel (parallel_parts (Repeatable x1 x2))›*)
case (NonD x1 x2) (*‹x1 ∼ Parallel (parallel_parts x1)› ‹x2 ∼ Parallel (parallel_parts x2)›*)
then show "?case"
(*goal: ‹NonD x1 x2 ∼ Parallel (parallel_parts (NonD x1 x2))›*)
by simp
next
(*goals:
1. ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Executable x1 x2 ∼ Parallel (parallel_parts (Executable x1 x2))›
2. ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Repeatable x1 x2 ∼ Parallel (parallel_parts (Repeatable x1 x2))›*)
case (Executable x1 x2) (*‹x1 ∼ Parallel (parallel_parts x1)› ‹x2 ∼ Parallel (parallel_parts x2)›*)
then show "?case"
(*goal: ‹Executable (x1::('a::type, 'b::type) res_term) (x2::('a::type, 'b::type) res_term) ∼ Parallel (parallel_parts (Executable x1 x2))›*)
by simp
next
(*goal: ‹⋀x1 x2. ⟦x1 ∼ Parallel (parallel_parts x1); x2 ∼ Parallel (parallel_parts x2)⟧ ⟹ Repeatable x1 x2 ∼ Parallel (parallel_parts (Repeatable x1 x2))›*)
case (Repeatable x1 x2) (*‹x1 ∼ Parallel (parallel_parts x1)› ‹(x2::('a, 'b) res_term) ∼ Parallel (parallel_parts x2)›*)
then show "?case"
(*goal: ‹Repeatable (x1::('a, 'b) res_term) (x2::('a, 'b) res_term) ∼ Parallel (parallel_parts (Repeatable x1 x2))›*)
by simp
qed
text‹Equivalent parallel parts is the same as equivalent resource terms›
lemma equiv_parallel_parts:
"list_all2 (∼) (parallel_parts a) (parallel_parts b) = a ∼ b"
proof (standard)
(*goals:
1. ‹list_all2 (∼) (parallel_parts a) (parallel_parts b) ⟹ a ∼ b›
2. ‹a ∼ b ⟹ list_all2 (∼) (parallel_parts a) (parallel_parts b)›*)
show "list_all2 (∼) (parallel_parts a) (parallel_parts b) ⟹ a ∼ b"
by (meson res_term_equiv.parallel (*‹list_all2 (∼) ?xs ?ys ⟹ Parallel ?xs ∼ Parallel ?ys›*) parallel_parts_eq (*‹?x ∼ Parallel (parallel_parts ?x)›*) res_term_equiv.sym (*‹?x ∼ ?y ⟹ ?y ∼ ?x›*) res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*))
show "a ∼ b ⟹ list_all2 (∼) (parallel_parts a) (parallel_parts b)"
proof (induct rule: res_term_equiv.induct (*‹⟦(?x1.0::(?'a, ?'b) res_term) ∼ (?x2.0::(?'a, ?'b) res_term); (?P::(?'a, ?'b) res_term ⇒ (?'a, ?'b) res_term ⇒ bool) (Parallel []) Empty; ⋀a::(?'a, ?'b) res_term. ?P (Parallel [a]) a; ⋀(x::(?'a, ?'b) res_term list) (y::(?'a, ?'b) res_term list) z::(?'a, ?'b) res_term list. ?P (Parallel (x @ [Parallel y] @ z)) (Parallel (x @ y @ z)); ?P Empty Empty; ?P Anything Anything; ⋀x::?'a. ?P (Res x) (Res x); ⋀x::?'b. ?P (Copyable x) (Copyable x); ⋀(xs::(?'a, ?'b) res_term list) ys::(?'a, ?'b) res_term list. list_all2 (λ(x1::(?'a, ?'b) res_term) x2::(?'a, ?'b) res_term. x1 ∼ x2 ∧ ?P x1 x2) xs ys ⟹ ?P (Parallel xs) (Parallel ys); ⋀(x::(?'a, ?'b) res_term) (y::(?'a, ?'b) res_term) (u::(?'a, ?'b) res_term) v::(?'a, ?'b) res_term. ⟦x ∼ y; ?P x y; u ∼ v; ?P u v⟧ ⟹ ?P (NonD x u) (NonD y v); ⋀(x::(?'a, ?'b) res_term) (y::(?'a, ?'b) res_term) (u::(?'a, ?'b) res_term) v::(?'a, ?'b) res_term. ⟦x ∼ y; ?P x y; u ∼ v; ?P u v⟧ ⟹ ?P (Executable x u) (Executable y v); ⋀(x::(?'a, ?'b) res_term) (y::(?'a, ?'b) res_term) (u::(?'a, ?'b) res_term) v::(?'a, ?'b) res_term. ⟦x ∼ y; ?P x y; u ∼ v; ?P u v⟧ ⟹ ?P (Repeatable x u) (Repeatable y v); ⋀(x::(?'a, ?'b) res_term) y::(?'a, ?'b) res_term. ⟦x ∼ y; ?P x y⟧ ⟹ ?P y x; ⋀(x::(?'a, ?'b) res_term) (y::(?'a, ?'b) res_term) z::(?'a, ?'b) res_term. ⟦x ∼ y; ?P x y; y ∼ z; ?P y z⟧ ⟹ ?P x z⟧ ⟹ ?P ?x1.0 ?x2.0›*))
(*goals:
1. ‹list_all2 (∼) (parallel_parts (Parallel [])) (parallel_parts Empty)›
2. ‹⋀a. list_all2 (∼) (parallel_parts (Parallel [a])) (parallel_parts a)›
3. ‹⋀x y z. list_all2 (∼) (parallel_parts (Parallel (x @ [Parallel y] @ z))) (parallel_parts (Parallel (x @ y @ z)))›
4. ‹list_all2 (∼) (parallel_parts Empty) (parallel_parts Empty)›
5. ‹list_all2 (∼) (parallel_parts Anything) (parallel_parts Anything)›
6. ‹⋀x. list_all2 (∼) (parallel_parts (Res x)) (parallel_parts (Res x))›
7. ‹⋀x. list_all2 (∼) (parallel_parts (Copyable x)) (parallel_parts (Copyable x))›
8. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ list_all2 (∼) (parallel_parts x1) (parallel_parts x2)) xs ys ⟹ list_all2 (∼) (parallel_parts (Parallel xs)) (parallel_parts (Parallel ys))›
9. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (NonD x u)) (parallel_parts (NonD y v))›
10. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Executable x u)) (parallel_parts (Executable y v))›
11. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Repeatable x u)) (parallel_parts (Repeatable y v))›
12. ‹⋀x y. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y)⟧ ⟹ list_all2 (∼) (parallel_parts y) (parallel_parts x)›
13. ‹⋀x y z. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); y ∼ z; list_all2 (∼) (parallel_parts y) (parallel_parts z)⟧ ⟹ list_all2 (∼) (parallel_parts x) (parallel_parts z)›*)
case empty (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹list_all2 (∼) (parallel_parts Empty) (parallel_parts Empty)›*)
by simp
next
(*goals:
1. ‹list_all2 (∼) (parallel_parts (Parallel [])) (parallel_parts Empty)›
2. ‹⋀a. list_all2 (∼) (parallel_parts (Parallel [a])) (parallel_parts a)›
3. ‹⋀x y z. list_all2 (∼) (parallel_parts (Parallel (x @ [Parallel y] @ z))) (parallel_parts (Parallel (x @ y @ z)))›
4. ‹list_all2 (∼) (parallel_parts Anything) (parallel_parts Anything)›
5. ‹⋀x. list_all2 (∼) (parallel_parts (Res x)) (parallel_parts (Res x))›
6. ‹⋀x. list_all2 (∼) (parallel_parts (Copyable x)) (parallel_parts (Copyable x))›
7. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ list_all2 (∼) (parallel_parts x1) (parallel_parts x2)) xs ys ⟹ list_all2 (∼) (parallel_parts (Parallel xs)) (parallel_parts (Parallel ys))›
8. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (NonD x u)) (parallel_parts (NonD y v))›
9. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Executable x u)) (parallel_parts (Executable y v))›
10. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Repeatable x u)) (parallel_parts (Repeatable y v))›
11. ‹⋀x y. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y)⟧ ⟹ list_all2 (∼) (parallel_parts y) (parallel_parts x)›
12. ‹⋀x y z. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); y ∼ z; list_all2 (∼) (parallel_parts y) (parallel_parts z)⟧ ⟹ list_all2 (∼) (parallel_parts x) (parallel_parts z)›*)
case anything (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹list_all2 (∼) (parallel_parts Anything) (parallel_parts Anything)›*)
by simp
next
(*goals:
1. ‹list_all2 (∼) (parallel_parts (Parallel [])) (parallel_parts Empty)›
2. ‹⋀a. list_all2 (∼) (parallel_parts (Parallel [a])) (parallel_parts a)›
3. ‹⋀x y z. list_all2 (∼) (parallel_parts (Parallel (x @ [Parallel y] @ z))) (parallel_parts (Parallel (x @ y @ z)))›
4. ‹⋀x. list_all2 (∼) (parallel_parts (Res x)) (parallel_parts (Res x))›
5. ‹⋀x. list_all2 (∼) (parallel_parts (Copyable x)) (parallel_parts (Copyable x))›
6. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ list_all2 (∼) (parallel_parts x1) (parallel_parts x2)) xs ys ⟹ list_all2 (∼) (parallel_parts (Parallel xs)) (parallel_parts (Parallel ys))›
7. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (NonD x u)) (parallel_parts (NonD y v))›
8. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Executable x u)) (parallel_parts (Executable y v))›
9. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Repeatable x u)) (parallel_parts (Repeatable y v))›
10. ‹⋀x y. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y)⟧ ⟹ list_all2 (∼) (parallel_parts y) (parallel_parts x)›
11. ‹⋀x y z. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); y ∼ z; list_all2 (∼) (parallel_parts y) (parallel_parts z)⟧ ⟹ list_all2 (∼) (parallel_parts x) (parallel_parts z)›*)
case (res x) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹list_all2 (∼) (parallel_parts (Res x)) (parallel_parts (Res x))›*)
by simp
next
(*goals:
1. ‹list_all2 (∼) (parallel_parts (Parallel [])) (parallel_parts Empty)›
2. ‹⋀a. list_all2 (∼) (parallel_parts (Parallel [a])) (parallel_parts a)›
3. ‹⋀x y z. list_all2 (∼) (parallel_parts (Parallel (x @ [Parallel y] @ z))) (parallel_parts (Parallel (x @ y @ z)))›
4. ‹⋀x. list_all2 (∼) (parallel_parts (Copyable x)) (parallel_parts (Copyable x))›
5. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ list_all2 (∼) (parallel_parts x1) (parallel_parts x2)) xs ys ⟹ list_all2 (∼) (parallel_parts (Parallel xs)) (parallel_parts (Parallel ys))›
6. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (NonD x u)) (parallel_parts (NonD y v))›
7. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Executable x u)) (parallel_parts (Executable y v))›
8. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Repeatable x u)) (parallel_parts (Repeatable y v))›
9. ‹⋀x y. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y)⟧ ⟹ list_all2 (∼) (parallel_parts y) (parallel_parts x)›
10. ‹⋀x y z. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); y ∼ z; list_all2 (∼) (parallel_parts y) (parallel_parts z)⟧ ⟹ list_all2 (∼) (parallel_parts x) (parallel_parts z)›*)
case (copyable x) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹list_all2 (∼) (parallel_parts (Copyable x)) (parallel_parts (Copyable x))›*)
by simp
next
(*goals:
1. ‹list_all2 (∼) (parallel_parts (Parallel [])) (parallel_parts Empty)›
2. ‹⋀a. list_all2 (∼) (parallel_parts (Parallel [a])) (parallel_parts a)›
3. ‹⋀x y z. list_all2 (∼) (parallel_parts (Parallel (x @ [Parallel y] @ z))) (parallel_parts (Parallel (x @ y @ z)))›
4. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ list_all2 (∼) (parallel_parts x1) (parallel_parts x2)) xs ys ⟹ list_all2 (∼) (parallel_parts (Parallel xs)) (parallel_parts (Parallel ys))›
5. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (NonD x u)) (parallel_parts (NonD y v))›
6. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Executable x u)) (parallel_parts (Executable y v))›
7. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Repeatable x u)) (parallel_parts (Repeatable y v))›
8. ‹⋀x y. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y)⟧ ⟹ list_all2 (∼) (parallel_parts y) (parallel_parts x)›
9. ‹⋀x y z. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); y ∼ z; list_all2 (∼) (parallel_parts y) (parallel_parts z)⟧ ⟹ list_all2 (∼) (parallel_parts x) (parallel_parts z)›*)
case nil (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹list_all2 (∼) (parallel_parts (Parallel [])) (parallel_parts Empty)›*)
by simp
next
(*goals:
1. ‹⋀a. list_all2 (∼) (parallel_parts (Parallel [a])) (parallel_parts a)›
2. ‹⋀x y z. list_all2 (∼) (parallel_parts (Parallel (x @ [Parallel y] @ z))) (parallel_parts (Parallel (x @ y @ z)))›
3. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ list_all2 (∼) (parallel_parts x1) (parallel_parts x2)) xs ys ⟹ list_all2 (∼) (parallel_parts (Parallel xs)) (parallel_parts (Parallel ys))›
4. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (NonD x u)) (parallel_parts (NonD y v))›
5. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Executable x u)) (parallel_parts (Executable y v))›
6. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Repeatable x u)) (parallel_parts (Repeatable y v))›
7. ‹⋀x y. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y)⟧ ⟹ list_all2 (∼) (parallel_parts y) (parallel_parts x)›
8. ‹⋀x y z. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); y ∼ z; list_all2 (∼) (parallel_parts y) (parallel_parts z)⟧ ⟹ list_all2 (∼) (parallel_parts x) (parallel_parts z)›*)
case (singleton a) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹list_all2 (∼) (parallel_parts (Parallel [a::('a::type, 'b::type) res_term])) (parallel_parts a)›*)
by (simp add: list_all2_refl (*‹(⋀x::?'a. (?P::?'a ⇒ ?'a ⇒ bool) x x) ⟹ list_all2 ?P (?xs::?'a list) ?xs›*))
next
(*goals:
1. ‹⋀(x::('a, 'b) res_term list) (y::('a, 'b) res_term list) z::('a, 'b) res_term list. list_all2 (∼) (parallel_parts (Parallel (x @ [Parallel y] @ z))) (parallel_parts (Parallel (x @ y @ z)))›
2. ‹⋀(xs::('a, 'b) res_term list) ys::('a, 'b) res_term list. list_all2 (λ(x1::('a, 'b) res_term) x2::('a, 'b) res_term. x1 ∼ x2 ∧ list_all2 (∼) (parallel_parts x1) (parallel_parts x2)) xs ys ⟹ list_all2 (∼) (parallel_parts (Parallel xs)) (parallel_parts (Parallel ys))›
3. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (NonD x u)) (parallel_parts (NonD y v))›
4. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Executable x u)) (parallel_parts (Executable y v))›
5. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Repeatable x u)) (parallel_parts (Repeatable y v))›
6. ‹⋀(x::('a, 'b) res_term) y::('a, 'b) res_term. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y)⟧ ⟹ list_all2 (∼) (parallel_parts y) (parallel_parts x)›
7. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) z::('a, 'b) res_term. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); y ∼ z; list_all2 (∼) (parallel_parts y) (parallel_parts z)⟧ ⟹ list_all2 (∼) (parallel_parts x) (parallel_parts z)›*)
case (merge x y z) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹list_all2 (∼) (parallel_parts (Parallel (x @ [Parallel y] @ z))) (parallel_parts (Parallel (x @ y @ z)))›*)
by (simp add: list_all2_refl (*‹(⋀x. ?P x x) ⟹ list_all2 ?P ?xs ?xs›*))
next
(*goals:
1. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ list_all2 (∼) (parallel_parts x1) (parallel_parts x2)) xs ys ⟹ list_all2 (∼) (parallel_parts (Parallel xs)) (parallel_parts (Parallel ys))›
2. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (NonD x u)) (parallel_parts (NonD y v))›
3. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Executable x u)) (parallel_parts (Executable y v))›
4. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Repeatable x u)) (parallel_parts (Repeatable y v))›
5. ‹⋀x y. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y)⟧ ⟹ list_all2 (∼) (parallel_parts y) (parallel_parts x)›
6. ‹⋀x y z. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); y ∼ z; list_all2 (∼) (parallel_parts y) (parallel_parts z)⟧ ⟹ list_all2 (∼) (parallel_parts x) (parallel_parts z)›*)
case (parallel xs ys) (*‹list_all2 (λx1 x2. x1 ∼ x2 ∧ list_all2 (∼) (parallel_parts x1) (parallel_parts x2)) xs ys›*)
then show "?case"
(*goal: ‹list_all2 (∼) (parallel_parts (Parallel xs)) (parallel_parts (Parallel ys))›*)
apply (induct rule: list_all2_induct (*‹⟦list_all2 ?P ?xs ?ys; ?R [] []; ⋀x xs y ys. ⟦?P x y; list_all2 ?P xs ys; ?R xs ys⟧ ⟹ ?R (x # xs) (y # ys)⟧ ⟹ ?R ?xs ?ys›*))
(*goals:
1. ‹list_all2 (∼) (parallel_parts (Parallel [])) (parallel_parts (Parallel []))›
2. ‹⋀x xs y ys. ⟦x ∼ y ∧ list_all2 (∼) (parallel_parts x) (parallel_parts y); list_all2 (λx1 x2. x1 ∼ x2 ∧ list_all2 (∼) (parallel_parts x1) (parallel_parts x2)) xs ys; list_all2 (∼) (parallel_parts (Parallel xs)) (parallel_parts (Parallel ys))⟧ ⟹ list_all2 (∼) (parallel_parts (Parallel (x # xs))) (parallel_parts (Parallel (y # ys)))›
discuss goal 1*)
apply (simp add: list_all2_appendI (*‹⟦list_all2 ?P ?a ?b; list_all2 ?P ?c ?d⟧ ⟹ list_all2 ?P (?a @ ?c) (?b @ ?d)›*))
(*discuss goal 2*)
apply (simp add: list_all2_appendI (*‹⟦list_all2 ?P ?a ?b; list_all2 ?P ?c ?d⟧ ⟹ list_all2 ?P (?a @ ?c) (?b @ ?d)›*))
(*proven 2 subgoals*) .
next
(*goals:
1. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (NonD x u)) (parallel_parts (NonD y v))›
2. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Executable x u)) (parallel_parts (Executable y v))›
3. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Repeatable x u)) (parallel_parts (Repeatable y v))›
4. ‹⋀x y. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y)⟧ ⟹ list_all2 (∼) (parallel_parts y) (parallel_parts x)›
5. ‹⋀x y z. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); y ∼ z; list_all2 (∼) (parallel_parts y) (parallel_parts z)⟧ ⟹ list_all2 (∼) (parallel_parts x) (parallel_parts z)›*)
case (nondet x y u v) (*‹x ∼ y› ‹list_all2 (∼) (parallel_parts x) (parallel_parts y)› ‹(u::('a, 'b) res_term) ∼ (v::('a, 'b) res_term)› ‹list_all2 (∼) (parallel_parts u) (parallel_parts v)›*)
then show "?case"
(*goal: ‹list_all2 (∼) (parallel_parts (NonD x u)) (parallel_parts (NonD y v))›*)
by (simp add: res_term_equiv.nondet (*‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ NonD ?x ?u ∼ NonD ?y ?v›*))
next
(*goals:
1. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Executable x u)) (parallel_parts (Executable y v))›
2. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Repeatable x u)) (parallel_parts (Repeatable y v))›
3. ‹⋀x y. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y)⟧ ⟹ list_all2 (∼) (parallel_parts y) (parallel_parts x)›
4. ‹⋀x y z. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); y ∼ z; list_all2 (∼) (parallel_parts y) (parallel_parts z)⟧ ⟹ list_all2 (∼) (parallel_parts x) (parallel_parts z)›*)
case (executable x y u v) (*‹x ∼ y› ‹list_all2 (∼) (parallel_parts x) (parallel_parts y)› ‹u ∼ v› ‹list_all2 (∼) (parallel_parts u) (parallel_parts v)›*)
then show "?case"
(*goal: ‹list_all2 (∼) (parallel_parts (Executable x u)) (parallel_parts (Executable y v))›*)
by (simp add: res_term_equiv.executable (*‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Executable ?x ?u ∼ Executable ?y ?v›*))
next
(*goals:
1. ‹⋀x y u v. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); u ∼ v; list_all2 (∼) (parallel_parts u) (parallel_parts v)⟧ ⟹ list_all2 (∼) (parallel_parts (Repeatable x u)) (parallel_parts (Repeatable y v))›
2. ‹⋀x y. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y)⟧ ⟹ list_all2 (∼) (parallel_parts y) (parallel_parts x)›
3. ‹⋀x y z. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); y ∼ z; list_all2 (∼) (parallel_parts y) (parallel_parts z)⟧ ⟹ list_all2 (∼) (parallel_parts x) (parallel_parts z)›*)
case (repeatable x y u v) (*‹x ∼ y› ‹list_all2 (∼) (parallel_parts x) (parallel_parts y)› ‹u ∼ v› ‹list_all2 (∼) (parallel_parts u) (parallel_parts v)›*)
then show "?case"
(*goal: ‹list_all2 (∼) (parallel_parts (Repeatable (x::('a, 'b) res_term) (u::('a, 'b) res_term))) (parallel_parts (Repeatable (y::('a, 'b) res_term) (v::('a, 'b) res_term)))›*)
by (simp add: res_term_equiv.repeatable (*‹⟦(?x::(?'a, ?'b) res_term) ∼ (?y::(?'a, ?'b) res_term); (?u::(?'a, ?'b) res_term) ∼ (?v::(?'a, ?'b) res_term)⟧ ⟹ Repeatable ?x ?u ∼ Repeatable ?y ?v›*))
next
(*goals:
1. ‹⋀x y. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y)⟧ ⟹ list_all2 (∼) (parallel_parts y) (parallel_parts x)›
2. ‹⋀x y z. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); y ∼ z; list_all2 (∼) (parallel_parts y) (parallel_parts z)⟧ ⟹ list_all2 (∼) (parallel_parts x) (parallel_parts z)›*)
case (sym x y) (*‹x ∼ y› ‹list_all2 (∼) (parallel_parts x) (parallel_parts y)›*)
then show "?case"
(*goal: ‹list_all2 (∼) (parallel_parts y) (parallel_parts x)›*)
by (simp add: list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*) res_term_equiv.sym (*‹?x ∼ ?y ⟹ ?y ∼ ?x›*))
next
(*goal: ‹⋀x y z. ⟦x ∼ y; list_all2 (∼) (parallel_parts x) (parallel_parts y); y ∼ z; list_all2 (∼) (parallel_parts y) (parallel_parts z)⟧ ⟹ list_all2 (∼) (parallel_parts x) (parallel_parts z)›*)
case (trans x y z) (*‹x ∼ y› ‹list_all2 (∼) (parallel_parts x) (parallel_parts y)› ‹y ∼ z› ‹list_all2 (∼) (parallel_parts y) (parallel_parts z)›*)
then show "?case"
(*goal: ‹list_all2 (∼) (parallel_parts x) (parallel_parts z)›*)
using res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*) list_all2_trans (*‹⟦⋀(a::?'a) (b::?'b) c::?'c. ⟦(?P1.0::?'a ⇒ ?'b ⇒ bool) a b; (?P2.0::?'b ⇒ ?'c ⇒ bool) b c⟧ ⟹ (?P3.0::?'a ⇒ ?'c ⇒ bool) a c; list_all2 ?P1.0 (?as::?'a list) (?bs::?'b list); list_all2 ?P2.0 ?bs (?cs::?'c list)⟧ ⟹ list_all2 ?P3.0 ?as ?cs›*) by blast
qed
qed
text‹Note that resource term equivalence does not imply parallel parts equality›
lemma
obtains x y where "x ∼ y" and "parallel_parts x ≠ parallel_parts y"
proof (standard)
(*goals:
1. ‹(⋀x y. ⟦x ∼ y; parallel_parts x ≠ parallel_parts y⟧ ⟹ thesis) ⟹ ?x2 ∼ ?y2›
2. ‹(⋀x y. ⟦x ∼ y; parallel_parts x ≠ parallel_parts y⟧ ⟹ thesis) ⟹ parallel_parts ?x2 ≠ parallel_parts ?y2›*)
let ?x = "NonD (Parallel [Anything, Empty]) (Parallel [])"
let ?y = "NonD Anything Empty"
show "?x ∼ ?y"
by (simp add: res_term_equiv.nondet (*‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ NonD ?x ?u ∼ NonD ?y ?v›*))
show "parallel_parts ?x ≠ parallel_parts ?y"
by simp
qed
text‹But it does imply that both have equal number of parallel parts›
lemma parallel_parts_length_eq:
"x ∼ y ⟹ length (parallel_parts x) = length (parallel_parts y)"
using equiv_parallel_parts (*‹list_all2 (∼) (parallel_parts (?a::(?'a, ?'b) res_term)) (parallel_parts (?b::(?'a, ?'b) res_term)) = ?a ∼ ?b›*) list_all2_lengthD (*‹list_all2 ?P ?xs ?ys ⟹ length ?xs = length ?ys›*) by blast
text‹Empty parallel parts, however, is the same as equivalence to the unit›
lemma parallel_parts_nil_equiv_empty:
"(parallel_parts a = []) = a ∼ Empty"
using equiv_parallel_parts (*‹list_all2 (∼) (parallel_parts ?a) (parallel_parts ?b) = ?a ∼ ?b›*) list.rel_sel (*‹list_all2 ?R ?a ?b = ((?a = []) = (?b = []) ∧ (?a ≠ [] ⟶ ?b ≠ [] ⟶ ?R (hd ?a) (hd ?b) ∧ list_all2 ?R (tl ?a) (tl ?b)))›*) parallel_parts.simps(1) (*‹parallel_parts Empty = []›*) by blast
text‹Singleton parallel parts imply equivalence to the one element›
lemma parallel_parts_single_equiv_element:
"parallel_parts a = [x] ⟹ a ∼ x"
using parallel_parts_eq (*‹(?x::(?'a::type, ?'b::type) res_term) ∼ Parallel (parallel_parts ?x)›*) res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*) by force
text‹No element of parallel parts is @{const Parallel} or @{const Empty}›
lemma parallel_parts_have_no_empty:
"x ∈ set (parallel_parts a) ⟹ ¬ is_Empty x"
apply (induct a)
(*goals:
1. ‹⋀xa::'a::type. (x::('a::type, 'b::type) res_term) ∈ set (parallel_parts (Res xa)) ⟹ ¬ is_Empty x›
2. ‹⋀xa::'b::type. (x::('a::type, 'b::type) res_term) ∈ set (parallel_parts (Copyable xa)) ⟹ ¬ is_Empty x›
3. ‹(x::('a::type, 'b::type) res_term) ∈ set (parallel_parts Empty) ⟹ ¬ is_Empty x›
4. ‹(x::('a::type, 'b::type) res_term) ∈ set (parallel_parts Anything) ⟹ ¬ is_Empty x›
5. ‹⋀xa::('a::type, 'b::type) res_term list. ⟦⋀xaa::('a::type, 'b::type) res_term. ⟦xaa ∈ set xa; (x::('a::type, 'b::type) res_term) ∈ set (parallel_parts xaa)⟧ ⟹ ¬ is_Empty x; x ∈ set (parallel_parts (Parallel xa))⟧ ⟹ ¬ is_Empty x›
6. ‹⋀(a1::('a::type, 'b::type) res_term) a2::('a::type, 'b::type) res_term. ⟦(x::('a::type, 'b::type) res_term) ∈ set (parallel_parts a1) ⟹ ¬ is_Empty x; x ∈ set (parallel_parts a2) ⟹ ¬ is_Empty x; x ∈ set (parallel_parts (NonD a1 a2))⟧ ⟹ ¬ is_Empty x›
7. ‹⋀(a1::('a::type, 'b::type) res_term) a2::('a::type, 'b::type) res_term. ⟦(x::('a::type, 'b::type) res_term) ∈ set (parallel_parts a1) ⟹ ¬ is_Empty x; x ∈ set (parallel_parts a2) ⟹ ¬ is_Empty x; x ∈ set (parallel_parts (Executable a1 a2))⟧ ⟹ ¬ is_Empty x›
8. ‹⋀(a1::('a::type, 'b::type) res_term) a2::('a::type, 'b::type) res_term. ⟦(x::('a::type, 'b::type) res_term) ∈ set (parallel_parts a1) ⟹ ¬ is_Empty x; x ∈ set (parallel_parts a2) ⟹ ¬ is_Empty x; x ∈ set (parallel_parts (Repeatable a1 a2))⟧ ⟹ ¬ is_Empty x›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply fastforce
(*discuss goal 3*)
apply fastforce
(*discuss goal 4*)
apply fastforce
(*discuss goal 5*)
apply fastforce
(*discuss goal 6*)
apply fastforce
(*discuss goal 7*)
apply fastforce
(*discuss goal 8*)
apply fastforce
(*proven 8 subgoals*) .
lemma parallel_parts_have_no_par:
"x ∈ set (parallel_parts a) ⟹ ¬ is_Parallel x"
apply (induct a)
(*goals:
1. ‹⋀xa. x ∈ set (parallel_parts (Res xa)) ⟹ ¬ is_Parallel x›
2. ‹⋀xa. x ∈ set (parallel_parts (Copyable xa)) ⟹ ¬ is_Parallel x›
3. ‹x ∈ set (parallel_parts Empty) ⟹ ¬ is_Parallel x›
4. ‹x ∈ set (parallel_parts Anything) ⟹ ¬ is_Parallel x›
5. ‹⋀xa. ⟦⋀xaa. ⟦xaa ∈ set xa; x ∈ set (parallel_parts xaa)⟧ ⟹ ¬ is_Parallel x; x ∈ set (parallel_parts (Parallel xa))⟧ ⟹ ¬ is_Parallel x›
6. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ ¬ is_Parallel x; x ∈ set (parallel_parts a2) ⟹ ¬ is_Parallel x; x ∈ set (parallel_parts (NonD a1 a2))⟧ ⟹ ¬ is_Parallel x›
7. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ ¬ is_Parallel x; x ∈ set (parallel_parts a2) ⟹ ¬ is_Parallel x; x ∈ set (parallel_parts (Executable a1 a2))⟧ ⟹ ¬ is_Parallel x›
8. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ ¬ is_Parallel x; x ∈ set (parallel_parts a2) ⟹ ¬ is_Parallel x; x ∈ set (parallel_parts (Repeatable a1 a2))⟧ ⟹ ¬ is_Parallel x›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply fastforce
(*discuss goal 3*)
apply fastforce
(*discuss goal 4*)
apply fastforce
(*discuss goal 5*)
apply fastforce
(*discuss goal 6*)
apply fastforce
(*discuss goal 7*)
apply fastforce
(*discuss goal 8*)
apply fastforce
(*proven 8 subgoals*) .
text‹Every parallel part of a resource is at most as big as it›
lemma parallel_parts_not_bigger:
"x ∈ set (parallel_parts a) ⟹ size_res_term f g x ≤ (size_res_term f g a)"
proof (induct a)
(*goals:
1. ‹⋀xa. x ∈ set (parallel_parts (Res xa)) ⟹ size_res_term f g x ≤ size_res_term f g (Res xa)›
2. ‹⋀xa. x ∈ set (parallel_parts (Copyable xa)) ⟹ size_res_term f g x ≤ size_res_term f g (Copyable xa)›
3. ‹x ∈ set (parallel_parts Empty) ⟹ size_res_term f g x ≤ size_res_term f g Empty›
4. ‹x ∈ set (parallel_parts Anything) ⟹ size_res_term f g x ≤ size_res_term f g Anything›
5. ‹⋀xa. ⟦⋀xaa. ⟦xaa ∈ set xa; x ∈ set (parallel_parts xaa)⟧ ⟹ size_res_term f g x ≤ size_res_term f g xaa; x ∈ set (parallel_parts (Parallel xa))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Parallel xa)›
6. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (NonD a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (NonD a1 a2)›
7. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Executable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Executable a1 a2)›
8. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Repeatable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Repeatable a1 a2)›*)
case Empty (*‹x ∈ set (parallel_parts Empty)›*)
then show "?case"
(*goal: ‹size_res_term (f::'a::type ⇒ nat) (g::'b::type ⇒ nat) (x::('a::type, 'b::type) res_term) ≤ size_res_term f g Empty›*)
by simp
next
(*goals:
1. ‹⋀xa. x ∈ set (parallel_parts (Res xa)) ⟹ size_res_term f g x ≤ size_res_term f g (Res xa)›
2. ‹⋀xa. x ∈ set (parallel_parts (Copyable xa)) ⟹ size_res_term f g x ≤ size_res_term f g (Copyable xa)›
3. ‹x ∈ set (parallel_parts Anything) ⟹ size_res_term f g x ≤ size_res_term f g Anything›
4. ‹⋀xa. ⟦⋀xaa. ⟦xaa ∈ set xa; x ∈ set (parallel_parts xaa)⟧ ⟹ size_res_term f g x ≤ size_res_term f g xaa; x ∈ set (parallel_parts (Parallel xa))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Parallel xa)›
5. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (NonD a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (NonD a1 a2)›
6. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Executable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Executable a1 a2)›
7. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Repeatable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Repeatable a1 a2)›*)
case Anything (*‹x ∈ set (parallel_parts Anything)›*)
then show "?case"
(*goal: ‹size_res_term (f::'a ⇒ nat) (g::'b ⇒ nat) (x::('a, 'b) res_term) ≤ size_res_term f g Anything›*)
by simp
next
(*goals:
1. ‹⋀xa. x ∈ set (parallel_parts (Res xa)) ⟹ size_res_term f g x ≤ size_res_term f g (Res xa)›
2. ‹⋀xa. x ∈ set (parallel_parts (Copyable xa)) ⟹ size_res_term f g x ≤ size_res_term f g (Copyable xa)›
3. ‹⋀xa. ⟦⋀xaa. ⟦xaa ∈ set xa; x ∈ set (parallel_parts xaa)⟧ ⟹ size_res_term f g x ≤ size_res_term f g xaa; x ∈ set (parallel_parts (Parallel xa))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Parallel xa)›
4. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (NonD a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (NonD a1 a2)›
5. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Executable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Executable a1 a2)›
6. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Repeatable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Repeatable a1 a2)›*)
case (Res x) (*‹x ∈ set (parallel_parts (Res x))›*)
then show "?case"
(*goal: ‹size_res_term f g x ≤ size_res_term f g (Res x)›*)
by simp
next
(*goals:
1. ‹⋀xa::'b. (x::('a, 'b) res_term) ∈ set (parallel_parts (Copyable xa)) ⟹ size_res_term (f::'a ⇒ nat) (g::'b ⇒ nat) x ≤ size_res_term f g (Copyable xa)›
2. ‹⋀xa::('a, 'b) res_term list. ⟦⋀xaa::('a, 'b) res_term. ⟦xaa ∈ set xa; (x::('a, 'b) res_term) ∈ set (parallel_parts xaa)⟧ ⟹ size_res_term (f::'a ⇒ nat) (g::'b ⇒ nat) x ≤ size_res_term f g xaa; x ∈ set (parallel_parts (Parallel xa))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Parallel xa)›
3. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦(x::('a, 'b) res_term) ∈ set (parallel_parts a1) ⟹ size_res_term (f::'a ⇒ nat) (g::'b ⇒ nat) x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (NonD a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (NonD a1 a2)›
4. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦(x::('a, 'b) res_term) ∈ set (parallel_parts a1) ⟹ size_res_term (f::'a ⇒ nat) (g::'b ⇒ nat) x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Executable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Executable a1 a2)›
5. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦(x::('a, 'b) res_term) ∈ set (parallel_parts a1) ⟹ size_res_term (f::'a ⇒ nat) (g::'b ⇒ nat) x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Repeatable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Repeatable a1 a2)›*)
case (Copyable x) (*‹x ∈ set (parallel_parts (Copyable x))›*)
then show "?case"
(*goal: ‹size_res_term f g x ≤ size_res_term f g (Copyable x)›*)
by simp
next
(*goals:
1. ‹⋀xa. ⟦⋀xaa. ⟦xaa ∈ set xa; x ∈ set (parallel_parts xaa)⟧ ⟹ size_res_term f g x ≤ size_res_term f g xaa; x ∈ set (parallel_parts (Parallel xa))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Parallel xa)›
2. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (NonD a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (NonD a1 a2)›
3. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Executable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Executable a1 a2)›
4. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Repeatable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Repeatable a1 a2)›*)
case (Parallel x) (*‹⟦?xa ∈ set x; x ∈ set (parallel_parts ?xa)⟧ ⟹ size_res_term f g x ≤ size_res_term f g ?xa› ‹x ∈ set (parallel_parts (Parallel x))›*)
then show "?case"
(*goal: ‹size_res_term f g x ≤ size_res_term f g (Parallel x)›*)
by (clarsimp simp add: le_SucI (*‹?m ≤ ?n ⟹ ?m ≤ Suc ?n›*) size_list_estimation' (*‹⟦?x ∈ set ?xs; ?y ≤ ?f ?x⟧ ⟹ ?y ≤ size_list ?f ?xs›*))
next
(*goals:
1. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (NonD a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (NonD a1 a2)›
2. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Executable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Executable a1 a2)›
3. ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Repeatable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Repeatable a1 a2)›*)
case (NonD a1 a2) (*‹(x::('a, 'b) res_term) ∈ set (parallel_parts (a1::('a, 'b) res_term)) ⟹ size_res_term (f::'a ⇒ nat) (g::'b ⇒ nat) x ≤ size_res_term f g a1› ‹x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2› ‹x ∈ set (parallel_parts (NonD a1 a2))›*)
then show "?case"
(*goal: ‹size_res_term f g x ≤ size_res_term f g (NonD a1 a2)›*)
by simp
next
(*goals:
1. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦(x::('a, 'b) res_term) ∈ set (parallel_parts a1) ⟹ size_res_term (f::'a ⇒ nat) (g::'b ⇒ nat) x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Executable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Executable a1 a2)›
2. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦(x::('a, 'b) res_term) ∈ set (parallel_parts a1) ⟹ size_res_term (f::'a ⇒ nat) (g::'b ⇒ nat) x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Repeatable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Repeatable a1 a2)›*)
case (Executable a1 a2) (*‹x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1› ‹x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2› ‹x ∈ set (parallel_parts (Executable a1 a2))›*)
then show "?case"
(*goal: ‹size_res_term f g x ≤ size_res_term f g (Executable a1 a2)›*)
by simp
next
(*goal: ‹⋀a1 a2. ⟦x ∈ set (parallel_parts a1) ⟹ size_res_term f g x ≤ size_res_term f g a1; x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2; x ∈ set (parallel_parts (Repeatable a1 a2))⟧ ⟹ size_res_term f g x ≤ size_res_term f g (Repeatable a1 a2)›*)
case (Repeatable a1 a2) (*‹(x::('a, 'b) res_term) ∈ set (parallel_parts (a1::('a, 'b) res_term)) ⟹ size_res_term (f::'a ⇒ nat) (g::'b ⇒ nat) x ≤ size_res_term f g a1› ‹x ∈ set (parallel_parts a2) ⟹ size_res_term f g x ≤ size_res_term f g a2› ‹x ∈ set (parallel_parts (Repeatable a1 a2))›*)
then show "?case"
(*goal: ‹size_res_term f g x ≤ size_res_term f g (Repeatable a1 a2)›*)
by simp
qed
text‹Any resource that is not @{const Empty} or @{const Parallel} has itself as parallel part›
lemma parallel_parts_self [simp]:
"⟦¬ is_Empty x; ¬ is_Parallel x⟧ ⟹ parallel_parts x = [x]"
apply (cases x)
(*goals:
1. ‹⋀x1. ⟦¬ is_Empty x; ¬ is_Parallel x; x = Res x1⟧ ⟹ parallel_parts x = [x]›
2. ‹⋀x2. ⟦¬ is_Empty x; ¬ is_Parallel x; x = Copyable x2⟧ ⟹ parallel_parts x = [x]›
3. ‹⟦¬ is_Empty x; ¬ is_Parallel x; x = Empty⟧ ⟹ parallel_parts x = [x]›
4. ‹⟦¬ is_Empty x; ¬ is_Parallel x; x = Anything⟧ ⟹ parallel_parts x = [x]›
5. ‹⋀x5. ⟦¬ is_Empty x; ¬ is_Parallel x; x = Parallel x5⟧ ⟹ parallel_parts x = [x]›
6. ‹⋀x61 x62. ⟦¬ is_Empty x; ¬ is_Parallel x; x = NonD x61 x62⟧ ⟹ parallel_parts x = [x]›
7. ‹⋀x71 x72. ⟦¬ is_Empty x; ¬ is_Parallel x; x = Executable x71 x72⟧ ⟹ parallel_parts x = [x]›
8. ‹⋀x81 x82. ⟦¬ is_Empty x; ¬ is_Parallel x; x = Repeatable x81 x82⟧ ⟹ parallel_parts x = [x]›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
text‹
List of terms with no @{const Empty} or @{const Parallel} elements is the same as parallel parts
of the @{const Parallel} term build from it
›
lemma parallel_parts_no_empty_parallel:
assumes "¬ list_ex is_Empty xs"
and "¬ list_ex is_Parallel xs"
shows "parallel_parts (Parallel xs) = xs"
using assms (*‹¬ list_ex is_Empty (xs::('a::type, 'b::type) res_term list)› ‹¬ list_ex is_Parallel xs›*) proof (induct xs)
(*goals:
1. ‹⟦¬ list_ex is_Empty []; ¬ list_ex is_Parallel []⟧ ⟹ parallel_parts (Parallel []) = []›
2. ‹⋀a xs. ⟦⟦¬ list_ex is_Empty xs; ¬ list_ex is_Parallel xs⟧ ⟹ parallel_parts (Parallel xs) = xs; ¬ list_ex is_Empty (a # xs); ¬ list_ex is_Parallel (a # xs)⟧ ⟹ parallel_parts (Parallel (a # xs)) = a # xs›*)
case Nil (*‹¬ list_ex is_Empty []› ‹¬ list_ex is_Parallel []›*)
then show "?case"
(*goal: ‹parallel_parts (Parallel []) = []›*)
by simp
next
(*goal: ‹⋀a xs. ⟦⟦¬ list_ex is_Empty xs; ¬ list_ex is_Parallel xs⟧ ⟹ parallel_parts (Parallel xs) = xs; ¬ list_ex is_Empty (a # xs); ¬ list_ex is_Parallel (a # xs)⟧ ⟹ parallel_parts (Parallel (a # xs)) = a # xs›*)
case (Cons a xs) (*‹⟦¬ list_ex is_Empty (xs::('a, 'b) res_term list); ¬ list_ex is_Parallel xs⟧ ⟹ parallel_parts (Parallel xs) = xs› ‹¬ list_ex is_Empty ((a::('a, 'b) res_term) # (xs::('a, 'b) res_term list))› ‹¬ list_ex is_Parallel (a # xs)›*)
then show "?case"
(*goal: ‹parallel_parts (Parallel (a # xs)) = a # xs›*)
apply (cases a)
(*goals:
1. ‹⋀x1. ⟦⟦¬ list_ex is_Empty xs; ¬ list_ex is_Parallel xs⟧ ⟹ parallel_parts (Parallel xs) = xs; ¬ list_ex is_Empty (a # xs); ¬ list_ex is_Parallel (a # xs); a = Res x1⟧ ⟹ parallel_parts (Parallel (a # xs)) = a # xs›
2. ‹⋀x2. ⟦⟦¬ list_ex is_Empty xs; ¬ list_ex is_Parallel xs⟧ ⟹ parallel_parts (Parallel xs) = xs; ¬ list_ex is_Empty (a # xs); ¬ list_ex is_Parallel (a # xs); a = Copyable x2⟧ ⟹ parallel_parts (Parallel (a # xs)) = a # xs›
3. ‹⟦⟦¬ list_ex is_Empty xs; ¬ list_ex is_Parallel xs⟧ ⟹ parallel_parts (Parallel xs) = xs; ¬ list_ex is_Empty (a # xs); ¬ list_ex is_Parallel (a # xs); a = Empty⟧ ⟹ parallel_parts (Parallel (a # xs)) = a # xs›
4. ‹⟦⟦¬ list_ex is_Empty xs; ¬ list_ex is_Parallel xs⟧ ⟹ parallel_parts (Parallel xs) = xs; ¬ list_ex is_Empty (a # xs); ¬ list_ex is_Parallel (a # xs); a = Anything⟧ ⟹ parallel_parts (Parallel (a # xs)) = a # xs›
5. ‹⋀x5. ⟦⟦¬ list_ex is_Empty xs; ¬ list_ex is_Parallel xs⟧ ⟹ parallel_parts (Parallel xs) = xs; ¬ list_ex is_Empty (a # xs); ¬ list_ex is_Parallel (a # xs); a = Parallel x5⟧ ⟹ parallel_parts (Parallel (a # xs)) = a # xs›
6. ‹⋀x61 x62. ⟦⟦¬ list_ex is_Empty xs; ¬ list_ex is_Parallel xs⟧ ⟹ parallel_parts (Parallel xs) = xs; ¬ list_ex is_Empty (a # xs); ¬ list_ex is_Parallel (a # xs); a = NonD x61 x62⟧ ⟹ parallel_parts (Parallel (a # xs)) = a # xs›
7. ‹⋀x71 x72. ⟦⟦¬ list_ex is_Empty xs; ¬ list_ex is_Parallel xs⟧ ⟹ parallel_parts (Parallel xs) = xs; ¬ list_ex is_Empty (a # xs); ¬ list_ex is_Parallel (a # xs); a = Executable x71 x72⟧ ⟹ parallel_parts (Parallel (a # xs)) = a # xs›
8. ‹⋀x81 x82. ⟦⟦¬ list_ex is_Empty xs; ¬ list_ex is_Parallel xs⟧ ⟹ parallel_parts (Parallel xs) = xs; ¬ list_ex is_Empty (a # xs); ¬ list_ex is_Parallel (a # xs); a = Repeatable x81 x82⟧ ⟹ parallel_parts (Parallel (a # xs)) = a # xs›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
qed
subsection‹Parallelisation›
text‹
In the opposite direction of parallel parts, we can take a list of resource terms and combine them
in parallel in a way smarter than just using @{const Parallel}.
This rests in checking the list length, using the @{const Empty} resource if it is empty and
skipping the wrapping in @{const Parallel} if it has only a single element.
We call this parallelisation.
›
fun parallelise :: "('a, 'b) res_term list ⇒ ('a, 'b) res_term"
where
"parallelise [] = Empty"
| "parallelise [x] = x"
| "parallelise xs = Parallel xs"
text‹This produces equivalent results to the @{const Parallel} constructor›
lemma parallelise_equiv:
"parallelise xs ∼ Parallel xs"
apply (cases xs rule: parallelise.cases (*‹⟦?x = [] ⟹ ?P; ⋀x. ?x = [x] ⟹ ?P; ⋀v vb vc. ?x = v # vb # vc ⟹ ?P⟧ ⟹ ?P›*))
(*goals:
1. ‹xs = [] ⟹ parallelise xs ∼ Parallel xs›
2. ‹⋀x. xs = [x] ⟹ parallelise xs ∼ Parallel xs›
3. ‹⋀v vb vc. xs = v # vb # vc ⟹ parallelise xs ∼ Parallel xs›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*) .
text‹Lists of equal length that parallelise to the same term must have been equal›
lemma parallelise_same_length:
"⟦parallelise x = parallelise y; length x = length y⟧ ⟹ x = y"
apply (elim parallelise.elims (*‹⟦parallelise (?x::(?'a, ?'b) res_term list) = (?y::(?'a, ?'b) res_term); ⟦?x = []; ?y = Empty⟧ ⟹ ?P::bool; ⋀x::(?'a, ?'b) res_term. ⟦?x = [x]; ?y = x⟧ ⟹ ?P; ⋀(v::(?'a, ?'b) res_term) (vb::(?'a, ?'b) res_term) vc::(?'a, ?'b) res_term list. ⟦?x = v # vb # vc; ?y = Parallel (v # vb # vc)⟧ ⟹ ?P⟧ ⟹ ?P›*))
(*goals:
1. ‹⟦length x = length y; x = []; y = []; Empty = Empty⟧ ⟹ x = y›
2. ‹⋀xa. ⟦length x = length y; x = []; y = [xa]; Empty = xa⟧ ⟹ x = y›
3. ‹⋀v vb vc. ⟦length x = length y; x = []; y = v # vb # vc; Empty = Parallel (v # vb # vc)⟧ ⟹ x = y›
4. ‹⋀xa. ⟦length x = length y; x = [xa]; y = []; xa = Empty⟧ ⟹ x = y›
5. ‹⋀xa xaa. ⟦length x = length y; x = [xa]; y = [xaa]; xa = xaa⟧ ⟹ x = y›
6. ‹⋀xa v vb vc. ⟦length x = length y; x = [xa]; y = v # vb # vc; xa = Parallel (v # vb # vc)⟧ ⟹ x = y›
7. ‹⋀v vb vc. ⟦length x = length y; x = v # vb # vc; y = []; Parallel (v # vb # vc) = Empty⟧ ⟹ x = y›
8. ‹⋀v vb vc xa. ⟦length x = length y; x = v # vb # vc; y = [xa]; Parallel (v # vb # vc) = xa⟧ ⟹ x = y›
9. ‹⋀v vb vc va vba vca. ⟦length x = length y; x = v # vb # vc; y = va # vba # vca; Parallel (v # vb # vc) = Parallel (va # vba # vca)⟧ ⟹ x = y›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*discuss goal 9*)
apply simp
(*proven 9 subgoals*) .
text‹Parallelisation and naive parallel combination have the same parallel parts›
lemma parallel_parts_parallelise_eq:
"parallel_parts (parallelise xs) = parallel_parts (Parallel xs)"
apply (cases xs rule: parallelise.cases (*‹⟦?x = [] ⟹ ?P; ⋀x. ?x = [x] ⟹ ?P; ⋀v vb vc. ?x = v # vb # vc ⟹ ?P⟧ ⟹ ?P›*))
(*goals:
1. ‹xs = [] ⟹ parallel_parts (parallelise xs) = parallel_parts (Parallel xs)›
2. ‹⋀x. xs = [x] ⟹ parallel_parts (parallelise xs) = parallel_parts (Parallel xs)›
3. ‹⋀v vb vc. xs = v # vb # vc ⟹ parallel_parts (parallelise xs) = parallel_parts (Parallel xs)›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*) .
text‹
Parallelising to a @{const Parallel} term means the input is either:
▪ A singleton set containing just that resulting @{const Parallel} term, or
▪ Exactly the children of the output and with at least two elements.
›
lemma parallelise_to_parallel_conv:
"(parallelise xs = Parallel ys) = (xs = [Parallel ys] ∨ (1 < length xs ∧ xs = ys))"
proof (standard)
(*goals:
1. ‹parallelise (xs::('a::type, 'b::type) res_term list) = Parallel (ys::('a::type, 'b::type) res_term list) ⟹ xs = [Parallel ys] ∨ (1::nat) < length xs ∧ xs = ys›
2. ‹(xs::('a::type, 'b::type) res_term list) = [Parallel (ys::('a::type, 'b::type) res_term list)] ∨ (1::nat) < length xs ∧ xs = ys ⟹ parallelise xs = Parallel ys›*)
show "parallelise xs = Parallel ys ⟹ xs = [Parallel ys] ∨ 1 < length xs ∧ xs = ys"
by (fastforce elim: parallelise.elims (*‹⟦parallelise (?x::(?'a, ?'b) res_term list) = (?y::(?'a, ?'b) res_term); ⟦?x = []; ?y = Empty⟧ ⟹ ?P::bool; ⋀x::(?'a, ?'b) res_term. ⟦?x = [x]; ?y = x⟧ ⟹ ?P; ⋀(v::(?'a, ?'b) res_term) (vb::(?'a, ?'b) res_term) vc::(?'a, ?'b) res_term list. ⟦?x = v # vb # vc; ?y = Parallel (v # vb # vc)⟧ ⟹ ?P⟧ ⟹ ?P›*))
have "xs = [Parallel ys] ⟹ parallelise xs = Parallel ys"
by simp
moreover have "1 < length xs ∧ xs = ys ⟹ parallelise xs = Parallel ys"
apply simp
(*goal: ‹(1::nat) < length (xs::('a::type, 'b::type) res_term list) ∧ xs = (ys::('a::type, 'b::type) res_term list) ⟹ parallelise xs = Parallel ys›*)
by (metis Suc_lessD (*‹Suc ?m < ?n ⟹ ?m < ?n›*) length_Cons (*‹length (?x # ?xs) = Suc (length ?xs)›*) list.size( (*‹length [] = 0›*) 3) nat_neq_iff (*‹(?m ≠ ?n) = (?m < ?n ∨ ?n < ?m)›*) parallelise.elims (*‹⟦parallelise ?x = ?y; ⟦?x = []; ?y = Empty⟧ ⟹ ?P; ⋀x. ⟦?x = [x]; ?y = x⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v # vb # vc; ?y = Parallel (v # vb # vc)⟧ ⟹ ?P⟧ ⟹ ?P›*))
ultimately show "xs = [Parallel ys] ∨ 1 < length xs ∧ xs = ys ⟹ parallelise xs = Parallel ys"
by blast
qed
text‹
So parallelising to a @{const Parallel} term with the same children is the same as the list having
at least two elements
›
lemma parallelise_to_parallel_same_length:
"(parallelise xs = Parallel xs) = (1 < length xs)"
apply (simp add: parallelise_to_parallel_conv (*‹(parallelise ?xs = Parallel ?ys) = (?xs = [Parallel ?ys] ∨ 1 < length ?xs ∧ ?xs = ?ys)›*))
(*goal: ‹(parallelise xs = Parallel xs) = (1 < length xs)›*)
by (metis parallel_neq_single (*‹Parallel [?a] ≠ ?a›*))
text‹
If the output of parallelisation contains a nested @{const Parallel} term then so must have the
input list
›
lemma parallelise_to_parallel_has_paralell:
assumes "parallelise xs = Parallel ys"
and "list_ex is_Parallel ys"
shows "list_ex is_Parallel xs"
using assms (*‹parallelise xs = Parallel ys› ‹list_ex is_Parallel ys›*) apply (induct xs rule: parallelise.induct (*‹⟦?P []; ⋀x. ?P [x]; ⋀v vb vc. ?P (v # vb # vc)⟧ ⟹ ?P ?a0.0›*))
(*goals:
1. ‹⟦parallelise [] = Parallel ys; list_ex is_Parallel ys⟧ ⟹ list_ex is_Parallel []›
2. ‹⋀x. ⟦parallelise [x] = Parallel ys; list_ex is_Parallel ys⟧ ⟹ list_ex is_Parallel [x]›
3. ‹⋀v vb vc. ⟦parallelise (v # vb # vc) = Parallel ys; list_ex is_Parallel ys⟧ ⟹ list_ex is_Parallel (v # vb # vc)›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*) .
text‹If the output of parallelisation contains @{const Empty} then so must have the input›
lemma parallelise_to_parallel_has_empty:
assumes "parallelise xs = Parallel ys"
obtains "xs = [Parallel ys]"
| "xs = ys"
using assms (*‹parallelise xs = Parallel ys›*) parallelise_to_parallel_conv (*‹(parallelise ?xs = Parallel ?ys) = (?xs = [Parallel ?ys] ∨ 1 < length ?xs ∧ ?xs = ?ys)›*) by blast
text‹Parallelising to @{const Empty} means the input list was either empty or contained just that›
lemma parallelise_to_empty_eq:
assumes "parallelise xs = Empty"
obtains "xs = []"
| "xs = [Empty]"
using assms (*‹parallelise (xs::('a, 'b) res_term list) = Empty›*) parallelise.elims (*‹⟦parallelise ?x = ?y; ⟦?x = []; ?y = Empty⟧ ⟹ ?P; ⋀x. ⟦?x = [x]; ?y = x⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v # vb # vc; ?y = Parallel (v # vb # vc)⟧ ⟹ ?P⟧ ⟹ ?P›*) by blast
text‹
If a list parallelises to anything but @{const Parallel} or @{const Empty}, then it must have been
a singleton of that term
›
lemma parallelise_to_single_eq:
assumes "parallelise xs = a"
and "¬ is_Empty a"
and "¬ is_Parallel a"
shows "xs = [a]"
using assms (*‹parallelise xs = a› ‹¬ is_Empty a› ‹¬ is_Parallel a›*) apply (cases xs rule: parallelise.cases (*‹⟦?x = [] ⟹ ?P; ⋀x. ?x = [x] ⟹ ?P; ⋀v vb vc. ?x = v # vb # vc ⟹ ?P⟧ ⟹ ?P›*))
(*goals:
1. ‹⟦parallelise xs = a; ¬ is_Empty a; ¬ is_Parallel a; xs = []⟧ ⟹ xs = [a]›
2. ‹⋀x. ⟦parallelise xs = a; ¬ is_Empty a; ¬ is_Parallel a; xs = [x]⟧ ⟹ xs = [a]›
3. ‹⋀v vb vc. ⟦parallelise xs = a; ¬ is_Empty a; ¬ is_Parallel a; xs = v # vb # vc⟧ ⟹ xs = [a]›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply fastforce
(*discuss goal 3*)
apply fastforce
(*proven 3 subgoals*) .
text‹Sets of atoms after parallelisation are unions of those atoms sets for the inputs›
lemma set1_res_term_parallelise [simp]:
"set1_res_term (ResTerm.parallelise xs) = ⋃(set1_res_term ` set xs)"
apply (induct xs rule: parallelise.induct (*‹⟦?P []; ⋀x. ?P [x]; ⋀v vb vc. ?P (v # vb # vc)⟧ ⟹ ?P ?a0.0›*))
(*goals:
1. ‹set1_res_term (parallelise []) = ⋃ (set1_res_term ` set [])›
2. ‹⋀x::('a::type, 'b::type) res_term. set1_res_term (parallelise [x]) = ⋃ (set1_res_term ` set [x])›
3. ‹⋀(v::('a::type, 'b::type) res_term) (vb::('a::type, 'b::type) res_term) vc::('a::type, 'b::type) res_term list. set1_res_term (parallelise (v # vb # vc)) = ⋃ (set1_res_term ` set (v # vb # vc))›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*) .
lemma set2_res_term_parallelise [simp]:
"set2_res_term (ResTerm.parallelise xs) = ⋃(set2_res_term ` set xs)"
apply (induct xs rule: parallelise.induct (*‹⟦?P []; ⋀x. ?P [x]; ⋀v vb vc. ?P (v # vb # vc)⟧ ⟹ ?P ?a0.0›*))
(*goals:
1. ‹set2_res_term (parallelise []) = ⋃ (set2_res_term ` set [])›
2. ‹⋀x. set2_res_term (parallelise [x]) = ⋃ (set2_res_term ` set [x])›
3. ‹⋀v vb vc. set2_res_term (parallelise (v # vb # vc)) = ⋃ (set2_res_term ` set (v # vb # vc))›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*) .
subsection‹Refinement›
text‹
Resource term refinement applies two functions to the linear and copyable atoms in a term.
Unlike @{const map_res_term}, the first function (applied to linear atoms) is allowed to produce
full resource terms, not just other atoms.
(The second function must still produce other atoms, because we cannot replace a copyable atom
with an arbitrary, possibly not copyable, resource.)
This allows us to refine atoms into potentially complex terms.
›
primrec refine_res_term ::
"('a ⇒ ('x, 'y) res_term) ⇒ ('b ⇒ 'y) ⇒ ('a, 'b) res_term ⇒ ('x, 'y) res_term"
where
"refine_res_term f g Empty = Empty"
| "refine_res_term f g Anything = Anything"
| "refine_res_term f g (Res a) = f a"
| "refine_res_term f g (Copyable x) = Copyable (g x)"
| "refine_res_term f g (Parallel xs) = Parallel (map (refine_res_term f g) xs)"
| "refine_res_term f g (NonD x y) = NonD (refine_res_term f g x) (refine_res_term f g y)"
| "refine_res_term f g (Executable x y) =
Executable (refine_res_term f g x) (refine_res_term f g y)"
| "refine_res_term f g (Repeatable x y) =
Repeatable (refine_res_term f g x) (refine_res_term f g y)"
text‹
Two refined resources are equivalent if:
▪ the original resources were equivalent,
▪ the linear atom refinements produce equivalent terms and
▪ the copyable atom refinements produce identical atoms.
›
lemma refine_res_term_eq:
assumes "x ∼ y"
and "⋀x. f x ∼ f' x"
and "⋀x. g x = g' x"
shows "refine_res_term f g x ∼ refine_res_term f' g' y"
proof (-)
(*goal: ‹refine_res_term f g x ∼ refine_res_term f' g' y›*)
have reflexivity: "refine_res_term f g a ∼ refine_res_term f' g' a" for a
proof (induct a)
(*goals:
1. ‹⋀x. refine_res_term f g (Res x) ∼ refine_res_term f' g' (Res x)›
2. ‹⋀x. refine_res_term f g (Copyable x) ∼ refine_res_term f' g' (Copyable x)›
3. ‹refine_res_term f g Empty ∼ refine_res_term f' g' Empty›
4. ‹refine_res_term f g Anything ∼ refine_res_term f' g' Anything›
5. ‹⋀x. (⋀xa. xa ∈ set x ⟹ refine_res_term f g xa ∼ refine_res_term f' g' xa) ⟹ refine_res_term f g (Parallel x) ∼ refine_res_term f' g' (Parallel x)›
6. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (NonD a1 a2) ∼ refine_res_term f' g' (NonD a1 a2)›
7. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Executable a1 a2) ∼ refine_res_term f' g' (Executable a1 a2)›
8. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Repeatable a1 a2) ∼ refine_res_term f' g' (Repeatable a1 a2)›*)
case Empty (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹refine_res_term f g Empty ∼ refine_res_term f' g' Empty›*)
by simp
next
(*goals:
1. ‹⋀x. refine_res_term f g (Res x) ∼ refine_res_term f' g' (Res x)›
2. ‹⋀x. refine_res_term f g (Copyable x) ∼ refine_res_term f' g' (Copyable x)›
3. ‹refine_res_term f g Anything ∼ refine_res_term f' g' Anything›
4. ‹⋀x. (⋀xa. xa ∈ set x ⟹ refine_res_term f g xa ∼ refine_res_term f' g' xa) ⟹ refine_res_term f g (Parallel x) ∼ refine_res_term f' g' (Parallel x)›
5. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (NonD a1 a2) ∼ refine_res_term f' g' (NonD a1 a2)›
6. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Executable a1 a2) ∼ refine_res_term f' g' (Executable a1 a2)›
7. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Repeatable a1 a2) ∼ refine_res_term f' g' (Repeatable a1 a2)›*)
case Anything (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹refine_res_term f g Anything ∼ refine_res_term f' g' Anything›*)
by simp
next
(*goals:
1. ‹⋀x. refine_res_term f g (Res x) ∼ refine_res_term f' g' (Res x)›
2. ‹⋀x. refine_res_term f g (Copyable x) ∼ refine_res_term f' g' (Copyable x)›
3. ‹⋀x. (⋀xa. xa ∈ set x ⟹ refine_res_term f g xa ∼ refine_res_term f' g' xa) ⟹ refine_res_term f g (Parallel x) ∼ refine_res_term f' g' (Parallel x)›
4. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (NonD a1 a2) ∼ refine_res_term f' g' (NonD a1 a2)›
5. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Executable a1 a2) ∼ refine_res_term f' g' (Executable a1 a2)›
6. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Repeatable a1 a2) ∼ refine_res_term f' g' (Repeatable a1 a2)›*)
case (Res x) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹refine_res_term f g (Res x) ∼ refine_res_term f' g' (Res x)›*)
using assms(2) (*‹f ?x ∼ f' ?x›*) by simp
next
(*goals:
1. ‹⋀x. refine_res_term f g (Copyable x) ∼ refine_res_term f' g' (Copyable x)›
2. ‹⋀x. (⋀xa. xa ∈ set x ⟹ refine_res_term f g xa ∼ refine_res_term f' g' xa) ⟹ refine_res_term f g (Parallel x) ∼ refine_res_term f' g' (Parallel x)›
3. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (NonD a1 a2) ∼ refine_res_term f' g' (NonD a1 a2)›
4. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Executable a1 a2) ∼ refine_res_term f' g' (Executable a1 a2)›
5. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Repeatable a1 a2) ∼ refine_res_term f' g' (Repeatable a1 a2)›*)
case (Copyable x) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹refine_res_term f g (Copyable x) ∼ refine_res_term f' g' (Copyable x)›*)
using assms(3) (*‹(g::'b ⇒ 'd) (?x::'b) = (g'::'b ⇒ 'd) ?x›*) by simp
next
(*goals:
1. ‹⋀x. (⋀xa. xa ∈ set x ⟹ refine_res_term f g xa ∼ refine_res_term f' g' xa) ⟹ refine_res_term f g (Parallel x) ∼ refine_res_term f' g' (Parallel x)›
2. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (NonD a1 a2) ∼ refine_res_term f' g' (NonD a1 a2)›
3. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Executable a1 a2) ∼ refine_res_term f' g' (Executable a1 a2)›
4. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Repeatable a1 a2) ∼ refine_res_term f' g' (Repeatable a1 a2)›*)
case (Parallel x) (*‹?xa ∈ set x ⟹ refine_res_term f g ?xa ∼ refine_res_term f' g' ?xa›*)
then show "?case"
(*goal: ‹refine_res_term f g (Parallel x) ∼ refine_res_term f' g' (Parallel x)›*)
apply (clarsimp intro!: res_term_equiv.parallel (*‹list_all2 (∼) ?xs ?ys ⟹ Parallel ?xs ∼ Parallel ?ys›*))
(*goal: ‹refine_res_term f g (Parallel x) ∼ refine_res_term f' g' (Parallel x)›*)
by (metis (mono_tags, lifting) length_map (*‹length (map ?f ?xs) = length ?xs›*) list_all2_all_nthI (*‹⟦length ?a = length ?b; ⋀n. n < length ?a ⟹ ?P (?a ! n) (?b ! n)⟧ ⟹ list_all2 ?P ?a ?b›*) nth_map (*‹?n < length ?xs ⟹ map ?f ?xs ! ?n = ?f (?xs ! ?n)›*) nth_mem (*‹?n < length ?xs ⟹ ?xs ! ?n ∈ set ?xs›*))
next
(*goals:
1. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (NonD a1 a2) ∼ refine_res_term f' g' (NonD a1 a2)›
2. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Executable a1 a2) ∼ refine_res_term f' g' (Executable a1 a2)›
3. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Repeatable a1 a2) ∼ refine_res_term f' g' (Repeatable a1 a2)›*)
case (NonD a1 a2) (*‹refine_res_term f g a1 ∼ refine_res_term f' g' a1› ‹refine_res_term f g a2 ∼ refine_res_term f' g' a2›*)
then show "?case"
(*goal: ‹refine_res_term f g (NonD a1 a2) ∼ refine_res_term f' g' (NonD a1 a2)›*)
by (simp add: res_term_equiv.nondet (*‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ NonD ?x ?u ∼ NonD ?y ?v›*))
next
(*goals:
1. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Executable a1 a2) ∼ refine_res_term f' g' (Executable a1 a2)›
2. ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Repeatable a1 a2) ∼ refine_res_term f' g' (Repeatable a1 a2)›*)
case (Executable a1 a2) (*‹refine_res_term f g a1 ∼ refine_res_term f' g' a1› ‹refine_res_term (f::'a ⇒ ('c, 'd) res_term) (g::'b ⇒ 'd) (a2::('a, 'b) res_term) ∼ refine_res_term (f'::'a ⇒ ('c, 'd) res_term) (g'::'b ⇒ 'd) a2›*)
then show "?case"
(*goal: ‹refine_res_term f g (Executable a1 a2) ∼ refine_res_term f' g' (Executable a1 a2)›*)
by (simp add: res_term_equiv.executable (*‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Executable ?x ?u ∼ Executable ?y ?v›*))
next
(*goal: ‹⋀a1 a2. ⟦refine_res_term f g a1 ∼ refine_res_term f' g' a1; refine_res_term f g a2 ∼ refine_res_term f' g' a2⟧ ⟹ refine_res_term f g (Repeatable a1 a2) ∼ refine_res_term f' g' (Repeatable a1 a2)›*)
case (Repeatable a1 a2) (*‹refine_res_term f g a1 ∼ refine_res_term f' g' a1› ‹refine_res_term f g a2 ∼ refine_res_term f' g' a2›*)
then show "?case"
(*goal: ‹refine_res_term f g (Repeatable a1 a2) ∼ refine_res_term f' g' (Repeatable a1 a2)›*)
by (simp add: res_term_equiv.repeatable (*‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Repeatable ?x ?u ∼ Repeatable ?y ?v›*))
qed
from assms (*‹x ∼ y› ‹f ?x ∼ f' ?x› ‹(g::'b ⇒ 'd) (?x::'b) = (g'::'b ⇒ 'd) ?x›*) show "?thesis"
(*goal: ‹refine_res_term f g x ∼ refine_res_term f' g' y›*)
proof (induct rule: res_term_equiv.induct (*‹⟦?x1.0 ∼ ?x2.0; ?P (Parallel []) Empty; ⋀a. ?P (Parallel [a]) a; ⋀x y z. ?P (Parallel (x @ [Parallel y] @ z)) (Parallel (x @ y @ z)); ?P Empty Empty; ?P Anything Anything; ⋀x. ?P (Res x) (Res x); ⋀x. ?P (Copyable x) (Copyable x); ⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ ?P x1 x2) xs ys ⟹ ?P (Parallel xs) (Parallel ys); ⋀x y u v. ⟦x ∼ y; ?P x y; u ∼ v; ?P u v⟧ ⟹ ?P (NonD x u) (NonD y v); ⋀x y u v. ⟦x ∼ y; ?P x y; u ∼ v; ?P u v⟧ ⟹ ?P (Executable x u) (Executable y v); ⋀x y u v. ⟦x ∼ y; ?P x y; u ∼ v; ?P u v⟧ ⟹ ?P (Repeatable x u) (Repeatable y v); ⋀x y. ⟦x ∼ y; ?P x y⟧ ⟹ ?P y x; ⋀x y z. ⟦x ∼ y; ?P x y; y ∼ z; ?P y z⟧ ⟹ ?P x z⟧ ⟹ ?P ?x1.0 ?x2.0›*))
(*goals:
1. ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel []) ∼ refine_res_term f' g' Empty›
2. ‹⋀a. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel [a]) ∼ refine_res_term f' g' a›
3. ‹⋀x y z. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel (x @ [Parallel y] @ z)) ∼ refine_res_term f' g' (Parallel (x @ y @ z))›
4. ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g Empty ∼ refine_res_term f' g' Empty›
5. ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g Anything ∼ refine_res_term f' g' Anything›
6. ‹⋀x. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Res x) ∼ refine_res_term f' g' (Res x)›
7. ‹⋀x. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Copyable x) ∼ refine_res_term f' g' (Copyable x)›
8. ‹⋀xs ys. ⟦list_all2 (λx1 x2. x1 ∼ x2 ∧ ((∀x. f x ∼ f' x) ⟶ (∀x. g x = g' x) ⟶ refine_res_term f g x1 ∼ refine_res_term f' g' x2)) xs ys; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel xs) ∼ refine_res_term f' g' (Parallel ys)›
9. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (NonD x u) ∼ refine_res_term f' g' (NonD y v)›
10. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Executable x u) ∼ refine_res_term f' g' (Executable y v)›
11. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Repeatable x u) ∼ refine_res_term f' g' (Repeatable y v)›
12. ‹⋀x y. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' x›
13. ‹⋀x y z. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; y ∼ z; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' z; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' z›*)
case empty (*‹f ?x ∼ f' ?x› ‹g ?x = g' ?x›*)
then show "?case"
(*goal: ‹refine_res_term f g Empty ∼ refine_res_term f' g' Empty›*)
by simp
next
(*goals:
1. ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel []) ∼ refine_res_term f' g' Empty›
2. ‹⋀a. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel [a]) ∼ refine_res_term f' g' a›
3. ‹⋀x y z. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel (x @ [Parallel y] @ z)) ∼ refine_res_term f' g' (Parallel (x @ y @ z))›
4. ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g Anything ∼ refine_res_term f' g' Anything›
5. ‹⋀x. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Res x) ∼ refine_res_term f' g' (Res x)›
6. ‹⋀x. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Copyable x) ∼ refine_res_term f' g' (Copyable x)›
7. ‹⋀xs ys. ⟦list_all2 (λx1 x2. x1 ∼ x2 ∧ ((∀x. f x ∼ f' x) ⟶ (∀x. g x = g' x) ⟶ refine_res_term f g x1 ∼ refine_res_term f' g' x2)) xs ys; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel xs) ∼ refine_res_term f' g' (Parallel ys)›
8. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (NonD x u) ∼ refine_res_term f' g' (NonD y v)›
9. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Executable x u) ∼ refine_res_term f' g' (Executable y v)›
10. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Repeatable x u) ∼ refine_res_term f' g' (Repeatable y v)›
11. ‹⋀x y. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' x›
12. ‹⋀x y z. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; y ∼ z; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' z; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' z›*)
case anything (*‹f ?x ∼ f' ?x› ‹g ?x = g' ?x›*)
then show "?case"
(*goal: ‹refine_res_term f g Anything ∼ refine_res_term f' g' Anything›*)
by simp
next
(*goals:
1. ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel []) ∼ refine_res_term f' g' Empty›
2. ‹⋀a. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel [a]) ∼ refine_res_term f' g' a›
3. ‹⋀x y z. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel (x @ [Parallel y] @ z)) ∼ refine_res_term f' g' (Parallel (x @ y @ z))›
4. ‹⋀x. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Res x) ∼ refine_res_term f' g' (Res x)›
5. ‹⋀x. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Copyable x) ∼ refine_res_term f' g' (Copyable x)›
6. ‹⋀xs ys. ⟦list_all2 (λx1 x2. x1 ∼ x2 ∧ ((∀x. f x ∼ f' x) ⟶ (∀x. g x = g' x) ⟶ refine_res_term f g x1 ∼ refine_res_term f' g' x2)) xs ys; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel xs) ∼ refine_res_term f' g' (Parallel ys)›
7. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (NonD x u) ∼ refine_res_term f' g' (NonD y v)›
8. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Executable x u) ∼ refine_res_term f' g' (Executable y v)›
9. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Repeatable x u) ∼ refine_res_term f' g' (Repeatable y v)›
10. ‹⋀x y. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' x›
11. ‹⋀x y z. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; y ∼ z; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' z; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' z›*)
case (res x) (*‹f ?x ∼ f' ?x› ‹g ?x = g' ?x›*)
then show "?case"
(*goal: ‹refine_res_term (f::'a::type ⇒ ('c::type, 'd::type) res_term) (g::'b::type ⇒ 'd::type) (Res (x::'a::type)) ∼ refine_res_term (f'::'a::type ⇒ ('c::type, 'd::type) res_term) (g'::'b::type ⇒ 'd::type) (Res x)›*)
by simp
next
(*goals:
1. ‹⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g (Parallel []) ∼ refine_res_term f' g' Empty›
2. ‹⋀a::('a, 'b) res_term. ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g (Parallel [a]) ∼ refine_res_term f' g' a›
3. ‹⋀(x::('a, 'b) res_term list) (y::('a, 'b) res_term list) z::('a, 'b) res_term list. ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g (Parallel (x @ [Parallel y] @ z)) ∼ refine_res_term f' g' (Parallel (x @ y @ z))›
4. ‹⋀x::'b. ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g (Copyable x) ∼ refine_res_term f' g' (Copyable x)›
5. ‹⋀(xs::('a, 'b) res_term list) ys::('a, 'b) res_term list. ⟦list_all2 (λ(x1::('a, 'b) res_term) x2::('a, 'b) res_term. x1 ∼ x2 ∧ ((∀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x) ⟶ (∀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x) ⟶ refine_res_term f g x1 ∼ refine_res_term f' g' x2)) xs ys; ⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g (Parallel xs) ∼ refine_res_term f' g' (Parallel ys)›
6. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g (NonD x u) ∼ refine_res_term f' g' (NonD y v)›
7. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g (Executable x u) ∼ refine_res_term f' g' (Executable y v)›
8. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g (Repeatable x u) ∼ refine_res_term f' g' (Repeatable y v)›
9. ‹⋀(x::('a, 'b) res_term) y::('a, 'b) res_term. ⟦x ∼ y; ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; ⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' x›
10. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) z::('a, 'b) res_term. ⟦x ∼ y; ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; y ∼ z; ⟦⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' z; ⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' z›*)
case (copyable x) (*‹f ?x ∼ f' ?x› ‹(g::'b ⇒ 'd) (?x::'b) = (g'::'b ⇒ 'd) ?x›*)
then show "?case"
(*goal: ‹refine_res_term f g (Copyable x) ∼ refine_res_term f' g' (Copyable x)›*)
by simp
next
(*goals:
1. ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel []) ∼ refine_res_term f' g' Empty›
2. ‹⋀a. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel [a]) ∼ refine_res_term f' g' a›
3. ‹⋀x y z. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel (x @ [Parallel y] @ z)) ∼ refine_res_term f' g' (Parallel (x @ y @ z))›
4. ‹⋀xs ys. ⟦list_all2 (λx1 x2. x1 ∼ x2 ∧ ((∀x. f x ∼ f' x) ⟶ (∀x. g x = g' x) ⟶ refine_res_term f g x1 ∼ refine_res_term f' g' x2)) xs ys; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel xs) ∼ refine_res_term f' g' (Parallel ys)›
5. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (NonD x u) ∼ refine_res_term f' g' (NonD y v)›
6. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Executable x u) ∼ refine_res_term f' g' (Executable y v)›
7. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Repeatable x u) ∼ refine_res_term f' g' (Repeatable y v)›
8. ‹⋀x y. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' x›
9. ‹⋀x y z. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; y ∼ z; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' z; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' z›*)
case nil (*‹f ?x ∼ f' ?x› ‹g ?x = g' ?x›*)
then show "?case"
(*goal: ‹refine_res_term f g (Parallel []) ∼ refine_res_term f' g' Empty›*)
by simp
next
(*goals:
1. ‹⋀a::('a, 'b) res_term. ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g (Parallel [a]) ∼ refine_res_term f' g' a›
2. ‹⋀(x::('a, 'b) res_term list) (y::('a, 'b) res_term list) z::('a, 'b) res_term list. ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g (Parallel (x @ [Parallel y] @ z)) ∼ refine_res_term f' g' (Parallel (x @ y @ z))›
3. ‹⋀(xs::('a, 'b) res_term list) ys::('a, 'b) res_term list. ⟦list_all2 (λ(x1::('a, 'b) res_term) x2::('a, 'b) res_term. x1 ∼ x2 ∧ ((∀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x) ⟶ (∀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x) ⟶ refine_res_term f g x1 ∼ refine_res_term f' g' x2)) xs ys; ⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g (Parallel xs) ∼ refine_res_term f' g' (Parallel ys)›
4. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g (NonD x u) ∼ refine_res_term f' g' (NonD y v)›
5. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g (Executable x u) ∼ refine_res_term f' g' (Executable y v)›
6. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g (Repeatable x u) ∼ refine_res_term f' g' (Repeatable y v)›
7. ‹⋀(x::('a, 'b) res_term) y::('a, 'b) res_term. ⟦x ∼ y; ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; ⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' x›
8. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) z::('a, 'b) res_term. ⟦x ∼ y; ⟦⋀x::'a. (f::'a ⇒ ('c, 'd) res_term) x ∼ (f'::'a ⇒ ('c, 'd) res_term) x; ⋀x::'b. (g::'b ⇒ 'd) x = (g'::'b ⇒ 'd) x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; y ∼ z; ⟦⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' z; ⋀x::'a. f x ∼ f' x; ⋀x::'b. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' z›*)
case (singleton a) (*‹f ?x ∼ f' ?x› ‹g ?x = g' ?x›*)
then have "refine_res_term f g (Parallel [a]) ∼ refine_res_term f g a"
by simp
then show "?case"
(*goal: ‹refine_res_term f g (Parallel [a]) ∼ refine_res_term f' g' a›*)
using reflexivity (*‹refine_res_term (f::'a ⇒ ('c, 'd) res_term) (g::'b ⇒ 'd) (?a::('a, 'b) res_term) ∼ refine_res_term (f'::'a ⇒ ('c, 'd) res_term) (g'::'b ⇒ 'd) ?a›*) res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*) by metis
next
(*goals:
1. ‹⋀x y z. ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel (x @ [Parallel y] @ z)) ∼ refine_res_term f' g' (Parallel (x @ y @ z))›
2. ‹⋀xs ys. ⟦list_all2 (λx1 x2. x1 ∼ x2 ∧ ((∀x. f x ∼ f' x) ⟶ (∀x. g x = g' x) ⟶ refine_res_term f g x1 ∼ refine_res_term f' g' x2)) xs ys; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel xs) ∼ refine_res_term f' g' (Parallel ys)›
3. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (NonD x u) ∼ refine_res_term f' g' (NonD y v)›
4. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Executable x u) ∼ refine_res_term f' g' (Executable y v)›
5. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Repeatable x u) ∼ refine_res_term f' g' (Repeatable y v)›
6. ‹⋀x y. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' x›
7. ‹⋀x y z. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; y ∼ z; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' z; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' z›*)
case (merge x y z) (*‹f ?x ∼ f' ?x› ‹g ?x = g' ?x›*)
have " length (map (refine_res_term f g') x @
map (refine_res_term f g') y @ map (refine_res_term f g') z)
= length (map (refine_res_term f' g') x @
map (refine_res_term f' g') y @ map (refine_res_term f' g') z)"
by simp
moreover have " ((map (refine_res_term f g) x @
map (refine_res_term f g) y @ map (refine_res_term f g) z) ! i)
∼ ((map (refine_res_term f' g') x @
map (refine_res_term f' g') y @ map (refine_res_term f' g') z) ! i)" if "i < length x + length y + length z" for i
by (metis append.assoc (*‹(?a @ ?b) @ ?c = ?a @ ?b @ ?c›*) length_append (*‹length (?xs @ ?ys) = length ?xs + length ?ys›*) map_append (*‹map ?f (?xs @ ?ys) = map ?f ?xs @ map ?f ?ys›*) nth_map (*‹?n < length ?xs ⟹ map ?f ?xs ! ?n = ?f (?xs ! ?n)›*) reflexivity (*‹refine_res_term f g ?a ∼ refine_res_term f' g' ?a›*) that (*‹i < length x + length y + length z›*))
ultimately have " list_all2 (∼)
( map (refine_res_term f g) x
@ map (refine_res_term f g) y
@ map (refine_res_term f g) z)
( map (refine_res_term f' g') x
@ map (refine_res_term f' g') y
@ map (refine_res_term f' g') z)"
by (smt (verit, del_insts) append_assoc (*‹(?xs @ ?ys) @ ?zs = ?xs @ ?ys @ ?zs›*) length_append (*‹length (?xs @ ?ys) = length ?xs + length ?ys›*) length_map (*‹length (map ?f ?xs) = length ?xs›*) list_all2_all_nthI (*‹⟦length ?a = length ?b; ⋀n. n < length ?a ⟹ ?P (?a ! n) (?b ! n)⟧ ⟹ list_all2 ?P ?a ?b›*))
then have " Parallel (map (refine_res_term f g) x @
[Parallel (map (refine_res_term f g) y)] @ map (refine_res_term f g) z)
∼ Parallel (map (refine_res_term f' g') x @
map (refine_res_term f' g') y @ map (refine_res_term f' g') z)"
using res_term_equiv.merge (*‹Parallel ((?x::(?'a, ?'b) res_term list) @ [Parallel (?y::(?'a, ?'b) res_term list)] @ (?z::(?'a, ?'b) res_term list)) ∼ Parallel (?x @ ?y @ ?z)›*) res_term_equiv.parallel (*‹list_all2 (∼) ?xs ?ys ⟹ Parallel ?xs ∼ Parallel ?ys›*) res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*) by blast
then show "?case"
(*goal: ‹refine_res_term f g (Parallel (x @ [Parallel y] @ z)) ∼ refine_res_term f' g' (Parallel (x @ y @ z))›*)
by simp
next
(*goals:
1. ‹⋀xs ys. ⟦list_all2 (λx1 x2. x1 ∼ x2 ∧ ((∀x. f x ∼ f' x) ⟶ (∀x. g x = g' x) ⟶ refine_res_term f g x1 ∼ refine_res_term f' g' x2)) xs ys; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Parallel xs) ∼ refine_res_term f' g' (Parallel ys)›
2. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (NonD x u) ∼ refine_res_term f' g' (NonD y v)›
3. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Executable x u) ∼ refine_res_term f' g' (Executable y v)›
4. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Repeatable x u) ∼ refine_res_term f' g' (Repeatable y v)›
5. ‹⋀x y. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' x›
6. ‹⋀x y z. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; y ∼ z; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' z; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' z›*)
case (parallel xs ys) (*‹list_all2 (λx1 x2. x1 ∼ x2 ∧ ((∀x. f x ∼ f' x) ⟶ (∀x. g x = g' x) ⟶ refine_res_term f g x1 ∼ refine_res_term f' g' x2)) xs ys› ‹f ?x ∼ f' ?x› ‹g ?x = g' ?x›*)
then show "?case"
(*goal: ‹refine_res_term f g (Parallel xs) ∼ refine_res_term f' g' (Parallel ys)›*)
by (simp add: res_term_equiv.parallel (*‹list_all2 (∼) (?xs::(?'a, ?'b) res_term list) (?ys::(?'a, ?'b) res_term list) ⟹ Parallel ?xs ∼ Parallel ?ys›*) list_all2_conv_all_nth (*‹list_all2 (?P::?'a ⇒ ?'b ⇒ bool) (?xs::?'a list) (?ys::?'b list) = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*))
next
(*goals:
1. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (NonD x u) ∼ refine_res_term f' g' (NonD y v)›
2. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Executable x u) ∼ refine_res_term f' g' (Executable y v)›
3. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Repeatable x u) ∼ refine_res_term f' g' (Repeatable y v)›
4. ‹⋀x y. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' x›
5. ‹⋀x y z. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; y ∼ z; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' z; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' z›*)
case (nondet x y u v) (*‹x ∼ y› ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y› ‹u ∼ v› ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v› ‹f ?x ∼ f' ?x› ‹g ?x = g' ?x›*)
then show "?case"
(*goal: ‹refine_res_term (f::'a ⇒ ('c, 'd) res_term) (g::'b ⇒ 'd) (NonD (x::('a, 'b) res_term) (u::('a, 'b) res_term)) ∼ refine_res_term (f'::'a ⇒ ('c, 'd) res_term) (g'::'b ⇒ 'd) (NonD (y::('a, 'b) res_term) (v::('a, 'b) res_term))›*)
by (simp add: res_term_equiv.nondet (*‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ NonD ?x ?u ∼ NonD ?y ?v›*))
next
(*goals:
1. ‹⋀(x::('a::type, 'b::type) res_term) (y::('a::type, 'b::type) res_term) (u::('a::type, 'b::type) res_term) v::('a::type, 'b::type) res_term. ⟦x ∼ y; ⟦⋀x::'a::type. (f::'a::type ⇒ ('c::type, 'd::type) res_term) x ∼ (f'::'a::type ⇒ ('c::type, 'd::type) res_term) x; ⋀x::'b::type. (g::'b::type ⇒ 'd::type) x = (g'::'b::type ⇒ 'd::type) x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x::'a::type. f x ∼ f' x; ⋀x::'b::type. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x::'a::type. f x ∼ f' x; ⋀x::'b::type. g x = g' x⟧ ⟹ refine_res_term f g (Executable x u) ∼ refine_res_term f' g' (Executable y v)›
2. ‹⋀(x::('a::type, 'b::type) res_term) (y::('a::type, 'b::type) res_term) (u::('a::type, 'b::type) res_term) v::('a::type, 'b::type) res_term. ⟦x ∼ y; ⟦⋀x::'a::type. (f::'a::type ⇒ ('c::type, 'd::type) res_term) x ∼ (f'::'a::type ⇒ ('c::type, 'd::type) res_term) x; ⋀x::'b::type. (g::'b::type ⇒ 'd::type) x = (g'::'b::type ⇒ 'd::type) x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x::'a::type. f x ∼ f' x; ⋀x::'b::type. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x::'a::type. f x ∼ f' x; ⋀x::'b::type. g x = g' x⟧ ⟹ refine_res_term f g (Repeatable x u) ∼ refine_res_term f' g' (Repeatable y v)›
3. ‹⋀(x::('a::type, 'b::type) res_term) y::('a::type, 'b::type) res_term. ⟦x ∼ y; ⟦⋀x::'a::type. (f::'a::type ⇒ ('c::type, 'd::type) res_term) x ∼ (f'::'a::type ⇒ ('c::type, 'd::type) res_term) x; ⋀x::'b::type. (g::'b::type ⇒ 'd::type) x = (g'::'b::type ⇒ 'd::type) x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; ⋀x::'a::type. f x ∼ f' x; ⋀x::'b::type. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' x›
4. ‹⋀(x::('a::type, 'b::type) res_term) (y::('a::type, 'b::type) res_term) z::('a::type, 'b::type) res_term. ⟦x ∼ y; ⟦⋀x::'a::type. (f::'a::type ⇒ ('c::type, 'd::type) res_term) x ∼ (f'::'a::type ⇒ ('c::type, 'd::type) res_term) x; ⋀x::'b::type. (g::'b::type ⇒ 'd::type) x = (g'::'b::type ⇒ 'd::type) x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; y ∼ z; ⟦⋀x::'a::type. f x ∼ f' x; ⋀x::'b::type. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' z; ⋀x::'a::type. f x ∼ f' x; ⋀x::'b::type. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' z›*)
case (executable x y u v) (*‹x ∼ y› ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y› ‹u ∼ v› ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v› ‹(f::'a ⇒ ('c, 'd) res_term) (?x::'a) ∼ (f'::'a ⇒ ('c, 'd) res_term) ?x› ‹g ?x = g' ?x›*)
then show "?case"
(*goal: ‹refine_res_term (f::'a ⇒ ('c, 'd) res_term) (g::'b ⇒ 'd) (Executable (x::('a, 'b) res_term) (u::('a, 'b) res_term)) ∼ refine_res_term (f'::'a ⇒ ('c, 'd) res_term) (g'::'b ⇒ 'd) (Executable (y::('a, 'b) res_term) (v::('a, 'b) res_term))›*)
by (simp add: res_term_equiv.executable (*‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Executable ?x ?u ∼ Executable ?y ?v›*))
next
(*goals:
1. ‹⋀x y u v. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; u ∼ v; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g (Repeatable x u) ∼ refine_res_term f' g' (Repeatable y v)›
2. ‹⋀x y. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' x›
3. ‹⋀x y z. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; y ∼ z; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' z; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' z›*)
case (repeatable x y u v) (*‹x ∼ y› ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y› ‹u ∼ v› ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g u ∼ refine_res_term f' g' v› ‹f ?x ∼ f' ?x› ‹g ?x = g' ?x›*)
then show "?case"
(*goal: ‹refine_res_term f g (Repeatable x u) ∼ refine_res_term f' g' (Repeatable y v)›*)
by (simp add: res_term_equiv.repeatable (*‹⟦(?x::(?'a::type, ?'b::type) res_term) ∼ (?y::(?'a::type, ?'b::type) res_term); (?u::(?'a::type, ?'b::type) res_term) ∼ (?v::(?'a::type, ?'b::type) res_term)⟧ ⟹ Repeatable ?x ?u ∼ Repeatable ?y ?v›*))
next
(*goals:
1. ‹⋀x y. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' x›
2. ‹⋀x y z. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; y ∼ z; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' z; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' z›*)
case (sym x y) (*‹(x::('a::type, 'b::type) res_term) ∼ (y::('a::type, 'b::type) res_term)› ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y› ‹f ?x ∼ f' ?x› ‹g ?x = g' ?x›*)
then show "?case"
(*goal: ‹refine_res_term f g y ∼ refine_res_term f' g' x›*)
by (metis res_term_equiv.sym (*‹?x ∼ ?y ⟹ ?y ∼ ?x›*) res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*) reflexivity (*‹refine_res_term f g ?a ∼ refine_res_term f' g' ?a›*))
next
(*goal: ‹⋀x y z. ⟦x ∼ y; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y; y ∼ z; ⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' z; ⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' z›*)
case (trans x y z) (*‹x ∼ y› ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g x ∼ refine_res_term f' g' y› ‹y ∼ z› ‹⟦⋀x. f x ∼ f' x; ⋀x. g x = g' x⟧ ⟹ refine_res_term f g y ∼ refine_res_term f' g' z› ‹f ?x ∼ f' ?x› ‹g ?x = g' ?x›*)
then show "?case"
(*goal: ‹refine_res_term f g x ∼ refine_res_term f' g' z›*)
by (metis res_term_equiv.sym (*‹(?x::(?'a, ?'b) res_term) ∼ (?y::(?'a, ?'b) res_term) ⟹ ?y ∼ ?x›*) res_term_equiv.trans (*‹⟦(?x::(?'a, ?'b) res_term) ∼ (?y::(?'a, ?'b) res_term); ?y ∼ (?z::(?'a, ?'b) res_term)⟧ ⟹ ?x ∼ ?z›*) reflexivity (*‹refine_res_term (f::'a ⇒ ('c, 'd) res_term) (g::'b ⇒ 'd) (?a::('a, 'b) res_term) ∼ refine_res_term (f'::'a ⇒ ('c, 'd) res_term) (g'::'b ⇒ 'd) ?a›*))
qed
qed
subsection‹Removing @{const Empty} Terms From a List›
text‹
As part of simplifying resource terms, it is sometimes useful to be able to take a list of terms
and drop from it any empty resource.
›
primrec remove_all_empty :: "('a, 'b) res_term list ⇒ ('a, 'b) res_term list"
where
"remove_all_empty [] = []"
| "remove_all_empty (x#xs) = (if is_Empty x then remove_all_empty xs else x#remove_all_empty xs)"
text‹
The result of dropping @{const Empty} terms from a list of resource terms is a subset of the
original list
›
lemma remove_all_empty_subset:
"x ∈ set (remove_all_empty xs) ⟹ x ∈ set xs"
proof (induct xs)
(*goals:
1. ‹(x::('a, 'b) res_term) ∈ set (remove_all_empty []) ⟹ x ∈ set []›
2. ‹⋀(a::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦(x::('a, 'b) res_term) ∈ set (remove_all_empty xs) ⟹ x ∈ set xs; x ∈ set (remove_all_empty (a # xs))⟧ ⟹ x ∈ set (a # xs)›*)
case Nil (*‹x ∈ set (remove_all_empty [])›*)
then show "?case"
(*goal: ‹x ∈ set []›*)
by simp
next
(*goal: ‹⋀a xs. ⟦x ∈ set (remove_all_empty xs) ⟹ x ∈ set xs; x ∈ set (remove_all_empty (a # xs))⟧ ⟹ x ∈ set (a # xs)›*)
case (Cons a xs) (*‹x ∈ set (remove_all_empty xs) ⟹ x ∈ set xs› ‹x ∈ set (remove_all_empty (a # xs))›*)
then show "?case"
(*goal: ‹x ∈ set (a # xs)›*)
apply simp
(*goal: ‹x ∈ set (a # xs)›*)
by (metis (full_types) set_ConsD (*‹?y ∈ set (?x # ?xs) ⟹ ?y = ?x ∨ ?y ∈ set ?xs›*))
qed
text‹If there are no @{const Empty} terms then removing them is the same as not doing anything›
lemma remove_all_empty_none:
"¬ list_ex is_Empty xs ⟹ remove_all_empty xs = xs"
apply (induct xs)
(*goals:
1. ‹¬ list_ex is_Empty [] ⟹ remove_all_empty [] = []›
2. ‹⋀a xs. ⟦¬ list_ex is_Empty xs ⟹ remove_all_empty xs = xs; ¬ list_ex is_Empty (a # xs)⟧ ⟹ remove_all_empty (a # xs) = a # xs›
discuss goal 1*)
apply force
(*discuss goal 2*)
apply force
(*proven 2 subgoals*) .
text‹There are no @{const Empty} terms left after they are removed›
lemma remove_all_empty_result:
"¬ list_ex is_Empty (remove_all_empty xs)"
proof (induct xs)
(*goals:
1. ‹¬ list_ex is_Empty (remove_all_empty [])›
2. ‹⋀a xs. ¬ list_ex is_Empty (remove_all_empty xs) ⟹ ¬ list_ex is_Empty (remove_all_empty (a # xs))›*)
case Nil (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹¬ list_ex is_Empty (remove_all_empty [])›*)
by simp
next
(*goal: ‹⋀a xs. ¬ list_ex is_Empty (remove_all_empty xs) ⟹ ¬ list_ex is_Empty (remove_all_empty (a # xs))›*)
case (Cons a xs) (*‹¬ list_ex is_Empty (remove_all_empty xs)›*)
then show "?case"
(*goal: ‹¬ list_ex is_Empty (remove_all_empty (a # xs))›*)
apply (cases a)
(*goals:
1. ‹⋀x1. ⟦¬ list_ex is_Empty (remove_all_empty xs); a = Res x1⟧ ⟹ ¬ list_ex is_Empty (remove_all_empty (a # xs))›
2. ‹⋀x2. ⟦¬ list_ex is_Empty (remove_all_empty xs); a = Copyable x2⟧ ⟹ ¬ list_ex is_Empty (remove_all_empty (a # xs))›
3. ‹⟦¬ list_ex is_Empty (remove_all_empty xs); a = Empty⟧ ⟹ ¬ list_ex is_Empty (remove_all_empty (a # xs))›
4. ‹⟦¬ list_ex is_Empty (remove_all_empty xs); a = Anything⟧ ⟹ ¬ list_ex is_Empty (remove_all_empty (a # xs))›
5. ‹⋀x5. ⟦¬ list_ex is_Empty (remove_all_empty xs); a = Parallel x5⟧ ⟹ ¬ list_ex is_Empty (remove_all_empty (a # xs))›
6. ‹⋀x61 x62. ⟦¬ list_ex is_Empty (remove_all_empty xs); a = NonD x61 x62⟧ ⟹ ¬ list_ex is_Empty (remove_all_empty (a # xs))›
7. ‹⋀x71 x72. ⟦¬ list_ex is_Empty (remove_all_empty xs); a = Executable x71 x72⟧ ⟹ ¬ list_ex is_Empty (remove_all_empty (a # xs))›
8. ‹⋀x81 x82. ⟦¬ list_ex is_Empty (remove_all_empty xs); a = Repeatable x81 x82⟧ ⟹ ¬ list_ex is_Empty (remove_all_empty (a # xs))›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
qed
text‹Removing @{const Empty} terms distributes over appending lists›
lemma remove_all_empty_append:
"remove_all_empty (xs @ ys) = remove_all_empty xs @ remove_all_empty ys"
proof (induct xs arbitrary: ys)
(*goals:
1. ‹⋀ys. remove_all_empty ([] @ ys) = remove_all_empty [] @ remove_all_empty ys›
2. ‹⋀a xs ys. (⋀ys. remove_all_empty (xs @ ys) = remove_all_empty xs @ remove_all_empty ys) ⟹ remove_all_empty ((a # xs) @ ys) = remove_all_empty (a # xs) @ remove_all_empty ys›*)
case Nil (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹remove_all_empty ([] @ (ys::('a::type, 'b::type) res_term list)) = remove_all_empty [] @ remove_all_empty ys›*)
by simp
next
(*goal: ‹⋀a xs ys. (⋀ys. remove_all_empty (xs @ ys) = remove_all_empty xs @ remove_all_empty ys) ⟹ remove_all_empty ((a # xs) @ ys) = remove_all_empty (a # xs) @ remove_all_empty ys›*)
case (Cons a xs) (*‹remove_all_empty (xs @ ?ys) = remove_all_empty xs @ remove_all_empty ?ys›*)
then show "?case"
(*goal: ‹remove_all_empty (((a::('a, 'b) res_term) # (xs::('a, 'b) res_term list)) @ (ys::('a, 'b) res_term list)) = remove_all_empty (a # xs) @ remove_all_empty ys›*)
apply (cases a)
(*goals:
1. ‹⋀x1. ⟦⋀ys. remove_all_empty (xs @ ys) = remove_all_empty xs @ remove_all_empty ys; a = Res x1⟧ ⟹ remove_all_empty ((a # xs) @ ys) = remove_all_empty (a # xs) @ remove_all_empty ys›
2. ‹⋀x2. ⟦⋀ys. remove_all_empty (xs @ ys) = remove_all_empty xs @ remove_all_empty ys; a = Copyable x2⟧ ⟹ remove_all_empty ((a # xs) @ ys) = remove_all_empty (a # xs) @ remove_all_empty ys›
3. ‹⟦⋀ys. remove_all_empty (xs @ ys) = remove_all_empty xs @ remove_all_empty ys; a = Empty⟧ ⟹ remove_all_empty ((a # xs) @ ys) = remove_all_empty (a # xs) @ remove_all_empty ys›
4. ‹⟦⋀ys. remove_all_empty (xs @ ys) = remove_all_empty xs @ remove_all_empty ys; a = Anything⟧ ⟹ remove_all_empty ((a # xs) @ ys) = remove_all_empty (a # xs) @ remove_all_empty ys›
5. ‹⋀x5. ⟦⋀ys. remove_all_empty (xs @ ys) = remove_all_empty xs @ remove_all_empty ys; a = Parallel x5⟧ ⟹ remove_all_empty ((a # xs) @ ys) = remove_all_empty (a # xs) @ remove_all_empty ys›
6. ‹⋀x61 x62. ⟦⋀ys. remove_all_empty (xs @ ys) = remove_all_empty xs @ remove_all_empty ys; a = NonD x61 x62⟧ ⟹ remove_all_empty ((a # xs) @ ys) = remove_all_empty (a # xs) @ remove_all_empty ys›
7. ‹⋀x71 x72. ⟦⋀ys. remove_all_empty (xs @ ys) = remove_all_empty xs @ remove_all_empty ys; a = Executable x71 x72⟧ ⟹ remove_all_empty ((a # xs) @ ys) = remove_all_empty (a # xs) @ remove_all_empty ys›
8. ‹⋀x81 x82. ⟦⋀ys. remove_all_empty (xs @ ys) = remove_all_empty xs @ remove_all_empty ys; a = Repeatable x81 x82⟧ ⟹ remove_all_empty ((a # xs) @ ys) = remove_all_empty (a # xs) @ remove_all_empty ys›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
qed
text‹Removing @{const Empty} terms distributes over constructing lists›
lemma remove_all_empty_Cons:
"remove_all_empty (x # xs) = remove_all_empty [x] @ remove_all_empty xs"
using remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) by (metis append.left_neutral (*‹[] @ ?a = ?a›*) append_Cons (*‹(?x # ?xs) @ ?ys = ?x # ?xs @ ?ys›*))
text‹
Removing @{const Empty} terms from children of a parallel resource term results in an equivalent
term
›
lemma remove_all_empty_equiv:
"Parallel xs ∼ Parallel (remove_all_empty xs)"
proof (induct xs)
(*goals:
1. ‹Parallel [] ∼ Parallel (remove_all_empty [])›
2. ‹⋀a xs. Parallel xs ∼ Parallel (remove_all_empty xs) ⟹ Parallel (a # xs) ∼ Parallel (remove_all_empty (a # xs))›*)
case Nil (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹Parallel [] ∼ Parallel (remove_all_empty [])›*)
by simp
next
(*goal: ‹⋀a xs. Parallel xs ∼ Parallel (remove_all_empty xs) ⟹ Parallel (a # xs) ∼ Parallel (remove_all_empty (a # xs))›*)
case (Cons a xs) (*‹Parallel xs ∼ Parallel (remove_all_empty xs)›*)
then show "?case"
(*goal: ‹Parallel (a # xs) ∼ Parallel (remove_all_empty (a # xs))›*)
by (metis append.left_neutral (*‹[] @ ?a = ?a›*) append_Cons (*‹(?x # ?xs) @ ?ys = ?x # ?xs @ ?ys›*) remove_all_empty.simps( (*‹remove_all_empty (?x # ?xs) = (if is_Empty ?x then remove_all_empty ?xs else ?x # remove_all_empty ?xs)›*) 2) res_term_equiv.drop (*‹Parallel (?x @ [Empty] @ ?y) ∼ Parallel (?x @ ?y)›*) res_term_equiv.refl (*‹?a ∼ ?a›*) res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*) res_term_parallel_cons (*‹⟦Parallel ?x ∼ Parallel ?y; ?a ∼ ?b⟧ ⟹ Parallel (?a # ?x) ∼ Parallel (?b # ?y)›*) is_Empty_def (*‹is_Empty ?res_term = (?res_term = Empty)›*))
qed
text‹Removing @{const Empty} terms does not affect the atom sets›
lemma set1_res_term_remove_all_empty [simp]:
"⋃(set1_res_term ` set (remove_all_empty xs)) = ⋃(set1_res_term ` set xs)"
proof (induct xs)
(*goals:
1. ‹⋃ (set1_res_term ` set (remove_all_empty [])) = ⋃ (set1_res_term ` set [])›
2. ‹⋀(a::('a, 'b) res_term) xs::('a, 'b) res_term list. ⋃ (set1_res_term ` set (remove_all_empty xs)) = ⋃ (set1_res_term ` set xs) ⟹ ⋃ (set1_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›*)
case Nil (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹⋃ (set1_res_term ` set (remove_all_empty [])) = ⋃ (set1_res_term ` set [])›*)
by simp
next
(*goal: ‹⋀a xs. ⋃ (set1_res_term ` set (remove_all_empty xs)) = ⋃ (set1_res_term ` set xs) ⟹ ⋃ (set1_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›*)
case (Cons a xs) (*‹⋃ (set1_res_term ` set (remove_all_empty xs)) = ⋃ (set1_res_term ` set xs)›*)
then show "?case"
(*goal: ‹⋃ (set1_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›*)
apply (cases a)
(*goals:
1. ‹⋀x1. ⟦⋃ (set1_res_term ` set (remove_all_empty xs)) = ⋃ (set1_res_term ` set xs); a = Res x1⟧ ⟹ ⋃ (set1_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
2. ‹⋀x2. ⟦⋃ (set1_res_term ` set (remove_all_empty xs)) = ⋃ (set1_res_term ` set xs); a = Copyable x2⟧ ⟹ ⋃ (set1_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
3. ‹⟦⋃ (set1_res_term ` set (remove_all_empty xs)) = ⋃ (set1_res_term ` set xs); a = Empty⟧ ⟹ ⋃ (set1_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
4. ‹⟦⋃ (set1_res_term ` set (remove_all_empty xs)) = ⋃ (set1_res_term ` set xs); a = Anything⟧ ⟹ ⋃ (set1_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
5. ‹⋀x5. ⟦⋃ (set1_res_term ` set (remove_all_empty xs)) = ⋃ (set1_res_term ` set xs); a = Parallel x5⟧ ⟹ ⋃ (set1_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
6. ‹⋀x61 x62. ⟦⋃ (set1_res_term ` set (remove_all_empty xs)) = ⋃ (set1_res_term ` set xs); a = NonD x61 x62⟧ ⟹ ⋃ (set1_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
7. ‹⋀x71 x72. ⟦⋃ (set1_res_term ` set (remove_all_empty xs)) = ⋃ (set1_res_term ` set xs); a = Executable x71 x72⟧ ⟹ ⋃ (set1_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
8. ‹⋀x81 x82. ⟦⋃ (set1_res_term ` set (remove_all_empty xs)) = ⋃ (set1_res_term ` set xs); a = Repeatable x81 x82⟧ ⟹ ⋃ (set1_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
qed
lemma set2_res_term_remove_all_empty [simp]:
"⋃(set2_res_term ` set (remove_all_empty xs)) = ⋃(set2_res_term ` set xs)"
proof (induct xs)
(*goals:
1. ‹⋃ (set2_res_term ` set (remove_all_empty [])) = ⋃ (set2_res_term ` set [])›
2. ‹⋀a xs. ⋃ (set2_res_term ` set (remove_all_empty xs)) = ⋃ (set2_res_term ` set xs) ⟹ ⋃ (set2_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›*)
case Nil (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹⋃ (set2_res_term ` set (remove_all_empty [])) = ⋃ (set2_res_term ` set [])›*)
by simp
next
(*goal: ‹⋀a xs. ⋃ (set2_res_term ` set (remove_all_empty xs)) = ⋃ (set2_res_term ` set xs) ⟹ ⋃ (set2_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›*)
case (Cons a xs) (*‹⋃ (set2_res_term ` set (remove_all_empty (xs::('b, 'a) res_term list))) = ⋃ (set2_res_term ` set xs)›*)
then show "?case"
(*goal: ‹⋃ (set2_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›*)
apply (cases a)
(*goals:
1. ‹⋀x1. ⟦⋃ (set2_res_term ` set (remove_all_empty xs)) = ⋃ (set2_res_term ` set xs); a = Res x1⟧ ⟹ ⋃ (set2_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
2. ‹⋀x2. ⟦⋃ (set2_res_term ` set (remove_all_empty xs)) = ⋃ (set2_res_term ` set xs); a = Copyable x2⟧ ⟹ ⋃ (set2_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
3. ‹⟦⋃ (set2_res_term ` set (remove_all_empty xs)) = ⋃ (set2_res_term ` set xs); a = Empty⟧ ⟹ ⋃ (set2_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
4. ‹⟦⋃ (set2_res_term ` set (remove_all_empty xs)) = ⋃ (set2_res_term ` set xs); a = Anything⟧ ⟹ ⋃ (set2_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
5. ‹⋀x5. ⟦⋃ (set2_res_term ` set (remove_all_empty xs)) = ⋃ (set2_res_term ` set xs); a = Parallel x5⟧ ⟹ ⋃ (set2_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
6. ‹⋀x61 x62. ⟦⋃ (set2_res_term ` set (remove_all_empty xs)) = ⋃ (set2_res_term ` set xs); a = NonD x61 x62⟧ ⟹ ⋃ (set2_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
7. ‹⋀x71 x72. ⟦⋃ (set2_res_term ` set (remove_all_empty xs)) = ⋃ (set2_res_term ` set xs); a = Executable x71 x72⟧ ⟹ ⋃ (set2_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
8. ‹⋀x81 x82. ⟦⋃ (set2_res_term ` set (remove_all_empty xs)) = ⋃ (set2_res_term ` set xs); a = Repeatable x81 x82⟧ ⟹ ⋃ (set2_res_term ` set (remove_all_empty (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
qed
subsection‹Merging Nested @{const Parallel} Terms in a List›
text‹
Similarly, it is sometimes useful to be able to take a list of terms and merge the children of any
@{const Parallel} term in it up into the list itself
›
primrec merge_all_parallel :: "('a, 'b) res_term list ⇒ ('a, 'b) res_term list"
where
"merge_all_parallel [] = []"
| "merge_all_parallel (x#xs) =
(case x of Parallel y ⇒ y @ merge_all_parallel xs | _ ⇒ x # merge_all_parallel xs)"
text‹If there are no @{const Parallel} terms then merging them is the same as not doing anything›
lemma merge_all_parallel_none:
"¬ list_ex is_Parallel xs ⟹ merge_all_parallel xs = xs"
proof (induct xs)
(*goals:
1. ‹¬ list_ex is_Parallel [] ⟹ merge_all_parallel [] = []›
2. ‹⋀(a::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦¬ list_ex is_Parallel xs ⟹ merge_all_parallel xs = xs; ¬ list_ex is_Parallel (a # xs)⟧ ⟹ merge_all_parallel (a # xs) = a # xs›*)
case Nil (*‹¬ list_ex is_Parallel []›*)
then show "?case"
(*goal: ‹merge_all_parallel [] = []›*)
by simp
next
(*goal: ‹⋀a xs. ⟦¬ list_ex is_Parallel xs ⟹ merge_all_parallel xs = xs; ¬ list_ex is_Parallel (a # xs)⟧ ⟹ merge_all_parallel (a # xs) = a # xs›*)
case (Cons a xs) (*‹¬ list_ex is_Parallel xs ⟹ merge_all_parallel xs = xs› ‹¬ list_ex is_Parallel (a # xs)›*)
then show "?case"
(*goal: ‹merge_all_parallel ((a::('a, 'b) res_term) # (xs::('a, 'b) res_term list)) = a # xs›*)
apply (cases a)
(*goals:
1. ‹⋀x1. ⟦¬ list_ex is_Parallel xs ⟹ merge_all_parallel xs = xs; ¬ list_ex is_Parallel (a # xs); a = Res x1⟧ ⟹ merge_all_parallel (a # xs) = a # xs›
2. ‹⋀x2. ⟦¬ list_ex is_Parallel xs ⟹ merge_all_parallel xs = xs; ¬ list_ex is_Parallel (a # xs); a = Copyable x2⟧ ⟹ merge_all_parallel (a # xs) = a # xs›
3. ‹⟦¬ list_ex is_Parallel xs ⟹ merge_all_parallel xs = xs; ¬ list_ex is_Parallel (a # xs); a = Empty⟧ ⟹ merge_all_parallel (a # xs) = a # xs›
4. ‹⟦¬ list_ex is_Parallel xs ⟹ merge_all_parallel xs = xs; ¬ list_ex is_Parallel (a # xs); a = Anything⟧ ⟹ merge_all_parallel (a # xs) = a # xs›
5. ‹⋀x5. ⟦¬ list_ex is_Parallel xs ⟹ merge_all_parallel xs = xs; ¬ list_ex is_Parallel (a # xs); a = Parallel x5⟧ ⟹ merge_all_parallel (a # xs) = a # xs›
6. ‹⋀x61 x62. ⟦¬ list_ex is_Parallel xs ⟹ merge_all_parallel xs = xs; ¬ list_ex is_Parallel (a # xs); a = NonD x61 x62⟧ ⟹ merge_all_parallel (a # xs) = a # xs›
7. ‹⋀x71 x72. ⟦¬ list_ex is_Parallel xs ⟹ merge_all_parallel xs = xs; ¬ list_ex is_Parallel (a # xs); a = Executable x71 x72⟧ ⟹ merge_all_parallel (a # xs) = a # xs›
8. ‹⋀x81 x82. ⟦¬ list_ex is_Parallel xs ⟹ merge_all_parallel xs = xs; ¬ list_ex is_Parallel (a # xs); a = Repeatable x81 x82⟧ ⟹ merge_all_parallel (a # xs) = a # xs›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
qed
text‹
If no element of the input list has itself nested @{const Parallel} terms then there will be none
left after merging @{const Parallel} terms in the list
›
lemma merge_all_parallel_result:
assumes "⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Parallel ys"
shows "¬ list_ex is_Parallel (merge_all_parallel xs)"
using assms (*‹Parallel ?ys ∈ set xs ⟹ ¬ list_ex is_Parallel ?ys›*) proof (induct xs)
(*goals:
1. ‹(⋀ys::('a, 'b) res_term list. Parallel ys ∈ set [] ⟹ ¬ list_ex is_Parallel ys) ⟹ ¬ list_ex is_Parallel (merge_all_parallel [])›
2. ‹⋀(a::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦(⋀ys::('a, 'b) res_term list. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Parallel ys) ⟹ ¬ list_ex is_Parallel (merge_all_parallel xs); ⋀ys::('a, 'b) res_term list. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Parallel ys⟧ ⟹ ¬ list_ex is_Parallel (merge_all_parallel (a # xs))›*)
case Nil (*‹Parallel (?ys::('a::type, 'b::type) res_term list) ∈ set [] ⟹ ¬ list_ex is_Parallel ?ys›*)
then show "?case"
(*goal: ‹¬ list_ex is_Parallel (merge_all_parallel [])›*)
by simp
next
(*goal: ‹⋀a xs. ⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Parallel ys) ⟹ ¬ list_ex is_Parallel (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Parallel ys⟧ ⟹ ¬ list_ex is_Parallel (merge_all_parallel (a # xs))›*)
case (Cons a xs) (*‹(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Parallel ys) ⟹ ¬ list_ex is_Parallel (merge_all_parallel xs)› ‹Parallel ?ys ∈ set (a # xs) ⟹ ¬ list_ex is_Parallel ?ys›*)
then show "?case"
(*goal: ‹¬ list_ex is_Parallel (merge_all_parallel (a # xs))›*)
apply (cases a)
(*goals:
1. ‹⋀x1. ⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Parallel ys) ⟹ ¬ list_ex is_Parallel (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Parallel ys; a = Res x1⟧ ⟹ ¬ list_ex is_Parallel (merge_all_parallel (a # xs))›
2. ‹⋀x2. ⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Parallel ys) ⟹ ¬ list_ex is_Parallel (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Parallel ys; a = Copyable x2⟧ ⟹ ¬ list_ex is_Parallel (merge_all_parallel (a # xs))›
3. ‹⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Parallel ys) ⟹ ¬ list_ex is_Parallel (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Parallel ys; a = Empty⟧ ⟹ ¬ list_ex is_Parallel (merge_all_parallel (a # xs))›
4. ‹⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Parallel ys) ⟹ ¬ list_ex is_Parallel (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Parallel ys; a = Anything⟧ ⟹ ¬ list_ex is_Parallel (merge_all_parallel (a # xs))›
5. ‹⋀x5. ⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Parallel ys) ⟹ ¬ list_ex is_Parallel (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Parallel ys; a = Parallel x5⟧ ⟹ ¬ list_ex is_Parallel (merge_all_parallel (a # xs))›
6. ‹⋀x61 x62. ⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Parallel ys) ⟹ ¬ list_ex is_Parallel (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Parallel ys; a = NonD x61 x62⟧ ⟹ ¬ list_ex is_Parallel (merge_all_parallel (a # xs))›
7. ‹⋀x71 x72. ⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Parallel ys) ⟹ ¬ list_ex is_Parallel (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Parallel ys; a = Executable x71 x72⟧ ⟹ ¬ list_ex is_Parallel (merge_all_parallel (a # xs))›
8. ‹⋀x81 x82. ⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Parallel ys) ⟹ ¬ list_ex is_Parallel (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Parallel ys; a = Repeatable x81 x82⟧ ⟹ ¬ list_ex is_Parallel (merge_all_parallel (a # xs))›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply fastforce
(*discuss goal 3*)
apply fastforce
(*discuss goal 4*)
apply fastforce
(*discuss goal 5*)
apply fastforce
(*discuss goal 6*)
apply fastforce
(*discuss goal 7*)
apply fastforce
(*discuss goal 8*)
apply fastforce
(*proven 8 subgoals*) .
qed
text‹Merging nested @{const Parallel} terms distributes over appending lists›
lemma merge_all_parallel_append:
"merge_all_parallel (xs @ ys) = merge_all_parallel xs @ merge_all_parallel ys"
proof (induct xs arbitrary: ys)
(*goals:
1. ‹⋀ys. merge_all_parallel ([] @ ys) = merge_all_parallel [] @ merge_all_parallel ys›
2. ‹⋀a xs ys. (⋀ys. merge_all_parallel (xs @ ys) = merge_all_parallel xs @ merge_all_parallel ys) ⟹ merge_all_parallel ((a # xs) @ ys) = merge_all_parallel (a # xs) @ merge_all_parallel ys›*)
case Nil (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹merge_all_parallel ([] @ ys) = merge_all_parallel [] @ merge_all_parallel ys›*)
by simp
next
(*goal: ‹⋀a xs ys. (⋀ys. merge_all_parallel (xs @ ys) = merge_all_parallel xs @ merge_all_parallel ys) ⟹ merge_all_parallel ((a # xs) @ ys) = merge_all_parallel (a # xs) @ merge_all_parallel ys›*)
case (Cons a xs) (*‹merge_all_parallel (xs @ ?ys) = merge_all_parallel xs @ merge_all_parallel ?ys›*)
then show "?case"
(*goal: ‹merge_all_parallel ((a # xs) @ ys) = merge_all_parallel (a # xs) @ merge_all_parallel ys›*)
apply (cases a)
(*goals:
1. ‹⋀x1. ⟦⋀ys. merge_all_parallel (xs @ ys) = merge_all_parallel xs @ merge_all_parallel ys; a = Res x1⟧ ⟹ merge_all_parallel ((a # xs) @ ys) = merge_all_parallel (a # xs) @ merge_all_parallel ys›
2. ‹⋀x2. ⟦⋀ys. merge_all_parallel (xs @ ys) = merge_all_parallel xs @ merge_all_parallel ys; a = Copyable x2⟧ ⟹ merge_all_parallel ((a # xs) @ ys) = merge_all_parallel (a # xs) @ merge_all_parallel ys›
3. ‹⟦⋀ys. merge_all_parallel (xs @ ys) = merge_all_parallel xs @ merge_all_parallel ys; a = Empty⟧ ⟹ merge_all_parallel ((a # xs) @ ys) = merge_all_parallel (a # xs) @ merge_all_parallel ys›
4. ‹⟦⋀ys. merge_all_parallel (xs @ ys) = merge_all_parallel xs @ merge_all_parallel ys; a = Anything⟧ ⟹ merge_all_parallel ((a # xs) @ ys) = merge_all_parallel (a # xs) @ merge_all_parallel ys›
5. ‹⋀x5. ⟦⋀ys. merge_all_parallel (xs @ ys) = merge_all_parallel xs @ merge_all_parallel ys; a = Parallel x5⟧ ⟹ merge_all_parallel ((a # xs) @ ys) = merge_all_parallel (a # xs) @ merge_all_parallel ys›
6. ‹⋀x61 x62. ⟦⋀ys. merge_all_parallel (xs @ ys) = merge_all_parallel xs @ merge_all_parallel ys; a = NonD x61 x62⟧ ⟹ merge_all_parallel ((a # xs) @ ys) = merge_all_parallel (a # xs) @ merge_all_parallel ys›
7. ‹⋀x71 x72. ⟦⋀ys. merge_all_parallel (xs @ ys) = merge_all_parallel xs @ merge_all_parallel ys; a = Executable x71 x72⟧ ⟹ merge_all_parallel ((a # xs) @ ys) = merge_all_parallel (a # xs) @ merge_all_parallel ys›
8. ‹⋀x81 x82. ⟦⋀ys. merge_all_parallel (xs @ ys) = merge_all_parallel xs @ merge_all_parallel ys; a = Repeatable x81 x82⟧ ⟹ merge_all_parallel ((a # xs) @ ys) = merge_all_parallel (a # xs) @ merge_all_parallel ys›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
qed
text‹Merging @{const Parallel} terms distributes over constructing lists›
lemma merge_all_parallel_Cons:
"merge_all_parallel (x # xs) = merge_all_parallel [x] @ merge_all_parallel xs"
using merge_all_parallel_append (*‹merge_all_parallel (?xs @ ?ys) = merge_all_parallel ?xs @ merge_all_parallel ?ys›*) by (metis append.left_neutral (*‹[] @ ?a = ?a›*) append_Cons (*‹(?x # ?xs) @ ?ys = ?x # ?xs @ ?ys›*))
text‹
Merging @{const Parallel} terms nested in another @{const Parallel} term results in an equivalent
term
›
lemma merge_all_parallel_equiv:
"Parallel xs ∼ Parallel (merge_all_parallel xs)"
proof (induct xs)
(*goals:
1. ‹Parallel [] ∼ Parallel (merge_all_parallel [])›
2. ‹⋀a xs. Parallel xs ∼ Parallel (merge_all_parallel xs) ⟹ Parallel (a # xs) ∼ Parallel (merge_all_parallel (a # xs))›*)
case Nil (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹Parallel [] ∼ Parallel (merge_all_parallel [])›*)
by simp
next
(*goal: ‹⋀(a::('a::type, 'b::type) res_term) xs::('a::type, 'b::type) res_term list. Parallel xs ∼ Parallel (merge_all_parallel xs) ⟹ Parallel (a # xs) ∼ Parallel (merge_all_parallel (a # xs))›*)
case (Cons a xs) (*‹Parallel xs ∼ Parallel (merge_all_parallel xs)›*)
have "?case" if "a = Parallel as" for as
using Cons (*‹Parallel xs ∼ Parallel (merge_all_parallel xs)›*) apply (simp add: that (*‹a = Parallel as›*))
(*goal: ‹Parallel (a # xs) ∼ Parallel (merge_all_parallel (a # xs))›*)
by (metis append.left_neutral (*‹[] @ (?a::?'a list) = ?a›*) append_Cons (*‹((?x::?'a) # (?xs::?'a list)) @ (?ys::?'a list) = ?x # ?xs @ ?ys›*) res_term_equiv.decompose (*‹⟦Parallel (?x1.0::(?'a, ?'b) res_term list) ∼ Parallel (?y1.0::(?'a, ?'b) res_term list); Parallel (?x2.0::(?'a, ?'b) res_term list) ∼ Parallel (?y2.0::(?'a, ?'b) res_term list)⟧ ⟹ Parallel (?x1.0 @ ?x2.0) ∼ Parallel (?y1.0 @ ?y2.0)›*) res_term_equiv.singleton (*‹Parallel [?a::(?'a, ?'b) res_term] ∼ ?a›*))
moreover have "?case" if "⋀as. a ≠ Parallel as"
using Cons (*‹Parallel xs ∼ Parallel (merge_all_parallel xs)›*) apply (cases a)
(*goals:
1. ‹⋀x1. ⟦Parallel xs ∼ Parallel (merge_all_parallel xs); a = Res x1⟧ ⟹ Parallel (a # xs) ∼ Parallel (merge_all_parallel (a # xs))›
2. ‹⋀x2. ⟦Parallel xs ∼ Parallel (merge_all_parallel xs); a = Copyable x2⟧ ⟹ Parallel (a # xs) ∼ Parallel (merge_all_parallel (a # xs))›
3. ‹⟦Parallel xs ∼ Parallel (merge_all_parallel xs); a = Empty⟧ ⟹ Parallel (a # xs) ∼ Parallel (merge_all_parallel (a # xs))›
4. ‹⟦Parallel xs ∼ Parallel (merge_all_parallel xs); a = Anything⟧ ⟹ Parallel (a # xs) ∼ Parallel (merge_all_parallel (a # xs))›
5. ‹⋀x5. ⟦Parallel xs ∼ Parallel (merge_all_parallel xs); a = Parallel x5⟧ ⟹ Parallel (a # xs) ∼ Parallel (merge_all_parallel (a # xs))›
6. ‹⋀x61 x62. ⟦Parallel xs ∼ Parallel (merge_all_parallel xs); a = NonD x61 x62⟧ ⟹ Parallel (a # xs) ∼ Parallel (merge_all_parallel (a # xs))›
7. ‹⋀x71 x72. ⟦Parallel xs ∼ Parallel (merge_all_parallel xs); a = Executable x71 x72⟧ ⟹ Parallel (a # xs) ∼ Parallel (merge_all_parallel (a # xs))›
8. ‹⋀x81 x82. ⟦Parallel xs ∼ Parallel (merge_all_parallel xs); a = Repeatable x81 x82⟧ ⟹ Parallel (a # xs) ∼ Parallel (merge_all_parallel (a # xs))›
discuss goal 1*)
apply (simp add: that (*‹a ≠ Parallel ?as›*) res_term_parallel_cons (*‹⟦Parallel ?x ∼ Parallel ?y; ?a ∼ ?b⟧ ⟹ Parallel (?a # ?x) ∼ Parallel (?b # ?y)›*))
(*discuss goal 2*)
apply (simp add: that (*‹a ≠ Parallel ?as›*) res_term_parallel_cons (*‹⟦Parallel ?x ∼ Parallel ?y; ?a ∼ ?b⟧ ⟹ Parallel (?a # ?x) ∼ Parallel (?b # ?y)›*))
(*discuss goal 3*)
apply (simp add: that (*‹a ≠ Parallel ?as›*) res_term_parallel_cons (*‹⟦Parallel ?x ∼ Parallel ?y; ?a ∼ ?b⟧ ⟹ Parallel (?a # ?x) ∼ Parallel (?b # ?y)›*))
(*discuss goal 4*)
apply (simp add: that (*‹a ≠ Parallel ?as›*) res_term_parallel_cons (*‹⟦Parallel ?x ∼ Parallel ?y; ?a ∼ ?b⟧ ⟹ Parallel (?a # ?x) ∼ Parallel (?b # ?y)›*))
(*discuss goal 5*)
apply (simp add: that (*‹a ≠ Parallel ?as›*) res_term_parallel_cons (*‹⟦Parallel ?x ∼ Parallel ?y; ?a ∼ ?b⟧ ⟹ Parallel (?a # ?x) ∼ Parallel (?b # ?y)›*))
(*discuss goal 6*)
apply (simp add: that (*‹a ≠ Parallel ?as›*) res_term_parallel_cons (*‹⟦Parallel ?x ∼ Parallel ?y; ?a ∼ ?b⟧ ⟹ Parallel (?a # ?x) ∼ Parallel (?b # ?y)›*))
(*discuss goal 7*)
apply (simp add: that (*‹a ≠ Parallel ?as›*) res_term_parallel_cons (*‹⟦Parallel ?x ∼ Parallel ?y; ?a ∼ ?b⟧ ⟹ Parallel (?a # ?x) ∼ Parallel (?b # ?y)›*))
(*discuss goal 8*)
apply (simp add: that (*‹(a::('a::type, 'b::type) res_term) ≠ Parallel (?as::('a::type, 'b::type) res_term list)›*) res_term_parallel_cons (*‹⟦Parallel (?x::(?'a::type, ?'b::type) res_term list) ∼ Parallel (?y::(?'a::type, ?'b::type) res_term list); (?a::(?'a::type, ?'b::type) res_term) ∼ (?b::(?'a::type, ?'b::type) res_term)⟧ ⟹ Parallel (?a # ?x) ∼ Parallel (?b # ?y)›*))
(*proven 8 subgoals*) .
ultimately show "?case"
(*goal: ‹Parallel (a # xs) ∼ Parallel (merge_all_parallel (a # xs))›*)
by metis
qed
text‹
If the output of @{const merge_all_parallel} contains @{const Empty} then:
▪ It was nested in one of the input elements, or
▪ It was in the input.
›
lemma merge_all_parallel_has_empty:
assumes "list_ex is_Empty (merge_all_parallel xs)"
obtains ys where "Parallel ys ∈ set xs" and "list_ex is_Empty ys"
| "list_ex is_Empty xs"
using assms (*‹list_ex is_Empty (merge_all_parallel xs)›*) proof (induct xs)
(*goals:
1. ‹⟦⋀ys. ⟦Parallel ys ∈ set []; list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty [] ⟹ thesis; list_ex is_Empty (merge_all_parallel [])⟧ ⟹ thesis›
2. ‹⋀a xs. ⟦⟦⋀ys. ⟦Parallel ys ∈ set xs; list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty xs ⟹ thesis; list_ex is_Empty (merge_all_parallel xs)⟧ ⟹ thesis; ⋀ys. ⟦Parallel ys ∈ set (a # xs); list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty (a # xs) ⟹ thesis; list_ex is_Empty (merge_all_parallel (a # xs))⟧ ⟹ thesis›*)
case Nil (*‹⟦Parallel ?ys ∈ set []; list_ex is_Empty ?ys⟧ ⟹ thesis› ‹list_ex is_Empty [] ⟹ thesis› ‹list_ex is_Empty (merge_all_parallel [])›*)
then show "?case"
(*goal: ‹thesis›*)
by simp
next
(*goal: ‹⋀a xs. ⟦⟦⋀ys. ⟦Parallel ys ∈ set xs; list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty xs ⟹ thesis; list_ex is_Empty (merge_all_parallel xs)⟧ ⟹ thesis; ⋀ys. ⟦Parallel ys ∈ set (a # xs); list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty (a # xs) ⟹ thesis; list_ex is_Empty (merge_all_parallel (a # xs))⟧ ⟹ thesis›*)
case (Cons a xs) (*‹⟦⋀ys. ⟦Parallel ys ∈ set xs; list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty xs ⟹ thesis; list_ex is_Empty (merge_all_parallel xs)⟧ ⟹ thesis› ‹⟦Parallel ?ys ∈ set (a # xs); list_ex is_Empty ?ys⟧ ⟹ thesis› ‹list_ex is_Empty ((a::('a, 'b) res_term) # (xs::('a, 'b) res_term list)) ⟹ thesis::bool› ‹list_ex is_Empty (merge_all_parallel (a # xs))›*)
then show "?case"
(*goal: ‹thesis::bool›*)
apply (cases a)
(*goals:
1. ‹⋀x1. ⟦⟦⋀ys. ⟦Parallel ys ∈ set xs; list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty xs ⟹ thesis; list_ex is_Empty (merge_all_parallel xs)⟧ ⟹ thesis; ⋀ys. ⟦Parallel ys ∈ set (a # xs); list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty (a # xs) ⟹ thesis; list_ex is_Empty (merge_all_parallel (a # xs)); a = Res x1⟧ ⟹ thesis›
2. ‹⋀x2. ⟦⟦⋀ys. ⟦Parallel ys ∈ set xs; list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty xs ⟹ thesis; list_ex is_Empty (merge_all_parallel xs)⟧ ⟹ thesis; ⋀ys. ⟦Parallel ys ∈ set (a # xs); list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty (a # xs) ⟹ thesis; list_ex is_Empty (merge_all_parallel (a # xs)); a = Copyable x2⟧ ⟹ thesis›
3. ‹⟦⟦⋀ys. ⟦Parallel ys ∈ set xs; list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty xs ⟹ thesis; list_ex is_Empty (merge_all_parallel xs)⟧ ⟹ thesis; ⋀ys. ⟦Parallel ys ∈ set (a # xs); list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty (a # xs) ⟹ thesis; list_ex is_Empty (merge_all_parallel (a # xs)); a = Empty⟧ ⟹ thesis›
4. ‹⟦⟦⋀ys. ⟦Parallel ys ∈ set xs; list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty xs ⟹ thesis; list_ex is_Empty (merge_all_parallel xs)⟧ ⟹ thesis; ⋀ys. ⟦Parallel ys ∈ set (a # xs); list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty (a # xs) ⟹ thesis; list_ex is_Empty (merge_all_parallel (a # xs)); a = Anything⟧ ⟹ thesis›
5. ‹⋀x5. ⟦⟦⋀ys. ⟦Parallel ys ∈ set xs; list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty xs ⟹ thesis; list_ex is_Empty (merge_all_parallel xs)⟧ ⟹ thesis; ⋀ys. ⟦Parallel ys ∈ set (a # xs); list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty (a # xs) ⟹ thesis; list_ex is_Empty (merge_all_parallel (a # xs)); a = Parallel x5⟧ ⟹ thesis›
6. ‹⋀x61 x62. ⟦⟦⋀ys. ⟦Parallel ys ∈ set xs; list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty xs ⟹ thesis; list_ex is_Empty (merge_all_parallel xs)⟧ ⟹ thesis; ⋀ys. ⟦Parallel ys ∈ set (a # xs); list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty (a # xs) ⟹ thesis; list_ex is_Empty (merge_all_parallel (a # xs)); a = NonD x61 x62⟧ ⟹ thesis›
7. ‹⋀x71 x72. ⟦⟦⋀ys. ⟦Parallel ys ∈ set xs; list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty xs ⟹ thesis; list_ex is_Empty (merge_all_parallel xs)⟧ ⟹ thesis; ⋀ys. ⟦Parallel ys ∈ set (a # xs); list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty (a # xs) ⟹ thesis; list_ex is_Empty (merge_all_parallel (a # xs)); a = Executable x71 x72⟧ ⟹ thesis›
8. ‹⋀x81 x82. ⟦⟦⋀ys. ⟦Parallel ys ∈ set xs; list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty xs ⟹ thesis; list_ex is_Empty (merge_all_parallel xs)⟧ ⟹ thesis; ⋀ys. ⟦Parallel ys ∈ set (a # xs); list_ex is_Empty ys⟧ ⟹ thesis; list_ex is_Empty (a # xs) ⟹ thesis; list_ex is_Empty (merge_all_parallel (a # xs)); a = Repeatable x81 x82⟧ ⟹ thesis›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply fastforce
(*discuss goal 3*)
apply fastforce
(*discuss goal 4*)
apply fastforce
(*discuss goal 5*)
apply fastforce
(*discuss goal 6*)
apply fastforce
(*discuss goal 7*)
apply fastforce
(*discuss goal 8*)
apply fastforce
(*proven 8 subgoals*) .
qed
text‹Merging @{const Parallel} terms does not affect the atom sets›
lemma set1_res_term_merge_all_parallel [simp]:
"⋃(set1_res_term ` set (merge_all_parallel xs)) = ⋃(set1_res_term ` set xs)"
proof (induct xs)
(*goals:
1. ‹⋃ (set1_res_term ` set (merge_all_parallel [])) = ⋃ (set1_res_term ` set [])›
2. ‹⋀(a::('a, 'b) res_term) xs::('a, 'b) res_term list. ⋃ (set1_res_term ` set (merge_all_parallel xs)) = ⋃ (set1_res_term ` set xs) ⟹ ⋃ (set1_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›*)
case Nil (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹⋃ (set1_res_term ` set (merge_all_parallel [])) = ⋃ (set1_res_term ` set [])›*)
by simp
next
(*goal: ‹⋀a xs. ⋃ (set1_res_term ` set (merge_all_parallel xs)) = ⋃ (set1_res_term ` set xs) ⟹ ⋃ (set1_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›*)
case (Cons a xs) (*‹⋃ (set1_res_term ` set (merge_all_parallel xs)) = ⋃ (set1_res_term ` set xs)›*)
then show "?case"
(*goal: ‹⋃ (set1_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›*)
apply (cases a)
(*goals:
1. ‹⋀x1. ⟦⋃ (set1_res_term ` set (merge_all_parallel xs)) = ⋃ (set1_res_term ` set xs); a = Res x1⟧ ⟹ ⋃ (set1_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
2. ‹⋀x2. ⟦⋃ (set1_res_term ` set (merge_all_parallel xs)) = ⋃ (set1_res_term ` set xs); a = Copyable x2⟧ ⟹ ⋃ (set1_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
3. ‹⟦⋃ (set1_res_term ` set (merge_all_parallel xs)) = ⋃ (set1_res_term ` set xs); a = Empty⟧ ⟹ ⋃ (set1_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
4. ‹⟦⋃ (set1_res_term ` set (merge_all_parallel xs)) = ⋃ (set1_res_term ` set xs); a = Anything⟧ ⟹ ⋃ (set1_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
5. ‹⋀x5. ⟦⋃ (set1_res_term ` set (merge_all_parallel xs)) = ⋃ (set1_res_term ` set xs); a = Parallel x5⟧ ⟹ ⋃ (set1_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
6. ‹⋀x61 x62. ⟦⋃ (set1_res_term ` set (merge_all_parallel xs)) = ⋃ (set1_res_term ` set xs); a = NonD x61 x62⟧ ⟹ ⋃ (set1_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
7. ‹⋀x71 x72. ⟦⋃ (set1_res_term ` set (merge_all_parallel xs)) = ⋃ (set1_res_term ` set xs); a = Executable x71 x72⟧ ⟹ ⋃ (set1_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
8. ‹⋀x81 x82. ⟦⋃ (set1_res_term ` set (merge_all_parallel xs)) = ⋃ (set1_res_term ` set xs); a = Repeatable x81 x82⟧ ⟹ ⋃ (set1_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set1_res_term ` set (a # xs))›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
qed
lemma set2_res_term_merge_all_parallel [simp]:
"⋃(set2_res_term ` set (merge_all_parallel xs)) = ⋃(set2_res_term ` set xs)"
proof (induct xs)
(*goals:
1. ‹⋃ (set2_res_term ` set (merge_all_parallel [])) = ⋃ (set2_res_term ` set [])›
2. ‹⋀a xs. ⋃ (set2_res_term ` set (merge_all_parallel xs)) = ⋃ (set2_res_term ` set xs) ⟹ ⋃ (set2_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›*)
case Nil (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹⋃ (set2_res_term ` set (merge_all_parallel [])) = ⋃ (set2_res_term ` set [])›*)
by simp
next
(*goal: ‹⋀a xs. ⋃ (set2_res_term ` set (merge_all_parallel xs)) = ⋃ (set2_res_term ` set xs) ⟹ ⋃ (set2_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›*)
case (Cons a xs) (*‹⋃ (set2_res_term ` set (merge_all_parallel xs)) = ⋃ (set2_res_term ` set xs)›*)
then show "?case"
(*goal: ‹⋃ (set2_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›*)
apply (cases a)
(*goals:
1. ‹⋀x1. ⟦⋃ (set2_res_term ` set (merge_all_parallel xs)) = ⋃ (set2_res_term ` set xs); a = Res x1⟧ ⟹ ⋃ (set2_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
2. ‹⋀x2. ⟦⋃ (set2_res_term ` set (merge_all_parallel xs)) = ⋃ (set2_res_term ` set xs); a = Copyable x2⟧ ⟹ ⋃ (set2_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
3. ‹⟦⋃ (set2_res_term ` set (merge_all_parallel xs)) = ⋃ (set2_res_term ` set xs); a = Empty⟧ ⟹ ⋃ (set2_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
4. ‹⟦⋃ (set2_res_term ` set (merge_all_parallel xs)) = ⋃ (set2_res_term ` set xs); a = Anything⟧ ⟹ ⋃ (set2_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
5. ‹⋀x5. ⟦⋃ (set2_res_term ` set (merge_all_parallel xs)) = ⋃ (set2_res_term ` set xs); a = Parallel x5⟧ ⟹ ⋃ (set2_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
6. ‹⋀x61 x62. ⟦⋃ (set2_res_term ` set (merge_all_parallel xs)) = ⋃ (set2_res_term ` set xs); a = NonD x61 x62⟧ ⟹ ⋃ (set2_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
7. ‹⋀x71 x72. ⟦⋃ (set2_res_term ` set (merge_all_parallel xs)) = ⋃ (set2_res_term ` set xs); a = Executable x71 x72⟧ ⟹ ⋃ (set2_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
8. ‹⋀x81 x82. ⟦⋃ (set2_res_term ` set (merge_all_parallel xs)) = ⋃ (set2_res_term ` set xs); a = Repeatable x81 x82⟧ ⟹ ⋃ (set2_res_term ` set (merge_all_parallel (a # xs))) = ⋃ (set2_res_term ` set (a # xs))›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
qed
end | {
"path": "afp-2025-02-12/thys/ProcessComposition/ResTerm.thy",
"repo": "afp-2025-02-12",
"sha": "4303ec6b6de06ddbcb4307b2fea6343a1a9a63f1c6d986e8ed157063c01ff65b"
} |
(*
Title: Generalizations2.thy
Author: Jose Divasón <jose.divasonm at unirioja.es>
Author: Jesús Aransay <jesus-maria.aransay at unirioja.es>
*)
section‹Generalization of the Second Part of the Fundamental Theorem of Linear Algebra›
theory Generalizations2
imports
Rank_Nullity_Theorem.Fundamental_Subspaces
begin
subsection‹Conjugate class›
class cnj = field +
fixes cnj :: "'a⇒'a"
assumes cnj_idem[simp]: "cnj (cnj a) = a"
and cnj_add: "cnj (a+b) = cnj a + cnj b"
and cnj_mult: "cnj (a * b) = cnj a * cnj b"
begin
lemma two_not_one: "2 ≠ (1::'a)"
apply (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*))
(*goal: ‹2 ≠ 1›*)
proof (simp)
(*goal: ‹2 = 1 ⟹ False›*)
assume "2 = (1::'a)" (*‹(2::'a) = (1::'a)›*)
hence "2 - 1 = 1 - (1::'a)"
by auto
hence "1 = (0::'a)"
by auto
thus False
using one_neq_zero (*‹1 ≠ 0›*) by contradiction
qed
lemma cnj_0[simp]: "cnj 0 = 0"
proof (-)
(*goal: ‹cnj_class.cnj 0 = 0›*)
have "cnj 0 = cnj (0 + 0)"
by auto
also (*calculation: ‹cnj_class.cnj 0 = cnj_class.cnj (0 + 0)›*) have "... = cnj 0 + cnj 0"
unfolding cnj_add
(*goal: ‹cnj_class.cnj (0::'a) + cnj_class.cnj (0::'a) = cnj_class.cnj (0::'a) + cnj_class.cnj (0::'a)›*)
by standard
also (*calculation: ‹cnj_class.cnj 0 = cnj_class.cnj 0 + cnj_class.cnj 0›*) have "... = 2 * (cnj 0)"
by (simp add: local.mult_2 (*‹2 * ?z = ?z + ?z›*))
finally (*calculation: ‹cnj_class.cnj 0 = 2 * cnj_class.cnj 0›*) have "cnj 0 = 2 * cnj 0" .
thus "?thesis"
(*goal: ‹cnj_class.cnj 0 = 0›*)
by (auto simp add: two_not_one (*‹(2::'a) ≠ (1::'a)›*))
qed
lemma cnj_0_eq[simp]: "(cnj a = 0) = (a = 0)"
proof (auto)
(*goal: ‹0 = cnj_class.cnj a ⟹ a = cnj_class.cnj a›*)
assume cnj_rw: "0 = cnj a" (*‹(0::'a) = cnj_class.cnj (a::'a)›*)
have "cnj (cnj a) = a"
using cnj_idem (*‹cnj_class.cnj (cnj_class.cnj ?a) = ?a›*) by simp
hence "cnj 0 = a"
unfolding cnj_rw
(*goal: ‹cnj_class.cnj (cnj_class.cnj a) = a›*) .
hence "a = 0"
by simp
thus "a = cnj a"
using cnj_rw (*‹0 = cnj_class.cnj a›*) by simp
qed
lemma a_cnj_a_0: "(a*cnj a = 0) = (a = 0)"
by simp
end
lemma cnj_sum: "cnj (∑xa∈A. ((f xa))) = (∑xa∈A. cnj (f xa))"
apply (cases "finite A")
(*goals:
1. ‹finite A ⟹ cnj_class.cnj (sum f A) = (∑xa∈A. cnj_class.cnj (f xa))›
2. ‹infinite A ⟹ cnj_class.cnj (sum f A) = (∑xa∈A. cnj_class.cnj (f xa))›
discuss goal 1*)
apply (induct set: finite)
(*goals:
1. ‹cnj_class.cnj (sum f {}) = (∑xa∈{}. cnj_class.cnj (f xa))›
2. ‹⋀x F. ⟦finite F; x ∉ F; cnj_class.cnj (sum f F) = (∑xa∈F. cnj_class.cnj (f xa))⟧ ⟹ cnj_class.cnj (sum f (insert x F)) = (∑xa∈insert x F. cnj_class.cnj (f xa))›
discuss goal 1*)
apply ((auto simp add: cnj_add (*‹cnj_class.cnj (?a + ?b) = cnj_class.cnj ?a + cnj_class.cnj ?b›*))[1])
(*discuss goal 2*)
apply ((auto simp add: cnj_add (*‹cnj_class.cnj ((?a::?'a::cnj) + (?b::?'a::cnj)) = cnj_class.cnj ?a + cnj_class.cnj ?b›*))[1])
(*proven 2 subgoals*)
(*discuss goal 2*)
apply ((auto simp add: cnj_add (*‹cnj_class.cnj ((?a::?'a) + (?b::?'a)) = cnj_class.cnj ?a + cnj_class.cnj ?b›*))[1])
(*proven 2 subgoals*) .
instantiation real :: cnj
begin
definition "(cnj_real :: real⇒real)= id"
instance
by (intro_classes, auto simp add: cnj_real_def)
end
instantiation complex :: cnj
begin
definition "(cnj_complex :: complex⇒complex)= Complex.cnj"
instance
by (intro_classes, auto simp add: cnj_complex_def)
end
subsection‹Real\_of\_extended class›
class real_of_extended = real_vector + cnj +
fixes real_of :: "'a ⇒ real"
assumes real_add:"real_of ((a::'a) + b) = real_of a + real_of b"
and real_uminus: "real_of (-a) = - real_of a"
and real_scalar_mult: "real_of (c *⇩R a) = c * (real_of a)"
and real_a_cnj_ge_0: "real_of (a*cnj a)≥0"
begin
lemma real_minus: "real_of (a - b) = real_of a - real_of b"
proof (-)
(*goal: ‹real_of (a - b) = real_of a - real_of b›*)
have "real_of (a - b) = real_of (a + - b)"
by simp
also (*calculation: ‹real_of (a - b) = real_of (a + - b)›*) have "... = real_of a + real_of (- b)"
unfolding real_add
(*goal: ‹real_of a + real_of (- b) = real_of a + real_of (- b)›*)
by standard
also (*calculation: ‹real_of (a - b) = real_of a + real_of (- b)›*) have "... = real_of a + - real_of b"
unfolding real_uminus
(*goal: ‹real_of a + - real_of b = real_of a + - real_of b›*)
by standard
also (*calculation: ‹real_of (a - b) = real_of a + - real_of b›*) have "... = real_of a - real_of b"
by simp
finally (*calculation: ‹real_of (a - b) = real_of a - real_of b›*) show "?thesis"
(*goal: ‹real_of (a - b) = real_of a - real_of b›*) .
qed
lemma real_0[simp]: "real_of 0 = 0"
proof (-)
(*goal: ‹real_of 0 = 0›*)
have "real_of 0 = real_of (0+0)"
by auto
also (*calculation: ‹real_of 0 = real_of (0 + 0)›*) have "... = real_of 0 + real_of 0"
unfolding real_add
(*goal: ‹real_of 0 + real_of 0 = real_of 0 + real_of 0›*)
by standard
also (*calculation: ‹real_of 0 = real_of 0 + real_of 0›*) have "... = 2*(real_of 0)"
by auto
finally (*calculation: ‹real_of 0 = 2 * real_of 0›*) have "real_of 0 = 2* real_of 0" .
thus "?thesis"
(*goal: ‹real_of 0 = 0›*)
by (auto simp add: two_not_one (*‹(2::'a) ≠ (1::'a)›*))
qed
lemma real_sum:
"real_of (sum (λi. f i) A) = sum (λi. real_of (f i)) A"
proof (cases "finite A")
(*goals:
1. ‹finite A ⟹ real_of (sum f A) = (∑i∈A. real_of (f i))›
2. ‹infinite A ⟹ real_of (sum f A) = (∑i∈A. real_of (f i))›*)
case False (*‹infinite A›*)
thus "?thesis"
(*goal: ‹real_of (sum f A) = (∑i∈A. real_of (f i))›*)
by auto
next
(*goal: ‹finite (A::'b set) ⟹ real_of (sum (f::'b ⇒ 'a) A) = (∑i::'b∈A. real_of (f i))›*)
case True (*‹finite A›*)
thus "?thesis"
(*goal: ‹real_of (sum (f::'b ⇒ 'a) (A::'b set)) = (∑i::'b∈A. real_of (f i))›*)
apply induct
(*goals:
1. ‹real_of (sum f {}) = (∑i∈{}. real_of (f i))›
2. ‹⋀x F. ⟦finite F; x ∉ F; real_of (sum f F) = (∑i∈F. real_of (f i))⟧ ⟹ real_of (sum f (insert x F)) = (∑i∈insert x F. real_of (f i))›
discuss goal 1*)
apply ((auto simp add: real_add (*‹real_of (?a + ?b) = real_of ?a + real_of ?b›*))[1])
(*discuss goal 2*)
apply ((auto simp add: real_add (*‹real_of (?a + ?b) = real_of ?a + real_of ?b›*))[1])
(*proven 2 subgoals*) .
qed
end
instantiation real :: real_of_extended
begin
definition real_of_real :: "real ⇒ real" where "real_of_real = id"
instance
by (intro_classes, auto simp add: real_of_real_def cnj_real_def)
end
instantiation complex :: real_of_extended
begin
definition real_of_complex :: "complex ⇒ real" where "real_of_complex = Re"
instance
by (intro_classes, auto simp add: real_of_complex_def cnj_complex_def)
end
subsection‹Generalizing HMA›
subsubsection‹Inner product spaces›
text‹We generalize the ‹real_inner class› to more general inner product spaces.›
locale inner_product_space = vector_space scale
for scale :: "('a::{field, cnj, real_of_extended} => 'b::ab_group_add => 'b)" +
fixes inner :: "'b ⇒ 'b ⇒ 'a"
assumes inner_commute: "inner x y = cnj (inner y x)"
and inner_add_left: "inner (x+y) z = inner x z + inner y z"
and inner_scaleR_left [simp]:"inner (scale r x) y = r * inner x y"
and inner_ge_zero [simp]:"0 ≤ real_of (inner x x)"
and inner_eq_zero_iff [simp]: "inner x x = 0 ⟷ x=0"
(*Properties related to real and inner that must be assumed.*)
and real_scalar_mult2: "real_of (inner x x) *⇩R A = inner x x * A"
and inner_gt_zero_iff: "0 < real_of (inner x x) ⟷ x ≠ 0"
interpretation RV_inner: inner_product_space scaleR inner
apply unfold_locales
(*goals:
1. ‹⋀(x::'a) y::'a. x ∙ y = cnj_class.cnj (y ∙ x)›
2. ‹⋀(x::'a) (y::'a) z::'a. (x + y) ∙ z = x ∙ z + y ∙ z›
3. ‹⋀(r::real) (x::'a) y::'a. r *⇩R x ∙ y = r * (x ∙ y)›
4. ‹⋀x::'a. (0::real) ≤ real_of (x ∙ x)›
5. ‹⋀x::'a. (x ∙ x = (0::real)) = (x = (0::'a))›
6. ‹⋀(x::'a) A::real. real_of (x ∙ x) *⇩R A = x ∙ x * A›
7. ‹⋀x::'a. ((0::real) < real_of (x ∙ x)) = (x ≠ (0::'a))›
discuss goal 1*)
apply ((auto simp: cnj_real_def (*‹cnj_class.cnj = id›*) inner_add_left (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z›*) real_of_real_def (*‹real_of = id›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 38 facts*) inner_commute (*‹?x ∙ ?y = ?y ∙ ?x›*))[1])
(*discuss goal 2*)
apply ((auto simp: cnj_real_def (*‹cnj_class.cnj = id›*) inner_add_left (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z›*) real_of_real_def (*‹real_of = id›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 38 facts*) inner_commute (*‹?x ∙ ?y = ?y ∙ ?x›*))[1])
(*discuss goal 3*)
apply ((auto simp: cnj_real_def (*‹cnj_class.cnj = id›*) inner_add_left (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z›*) real_of_real_def (*‹real_of = id›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 38 facts*) inner_commute (*‹?x ∙ ?y = ?y ∙ ?x›*))[1])
(*discuss goal 4*)
apply ((auto simp: cnj_real_def (*‹cnj_class.cnj = id›*) inner_add_left (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z›*) real_of_real_def (*‹real_of = id›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 38 facts*) inner_commute (*‹?x ∙ ?y = ?y ∙ ?x›*))[1])
(*discuss goal 5*)
apply ((auto simp: cnj_real_def (*‹cnj_class.cnj = id›*) inner_add_left (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z›*) real_of_real_def (*‹real_of = id›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 38 facts*) inner_commute (*‹?x ∙ ?y = ?y ∙ ?x›*))[1])
(*discuss goal 6*)
apply ((auto simp: cnj_real_def (*‹cnj_class.cnj = id›*) inner_add_left (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z›*) real_of_real_def (*‹real_of = id›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 38 facts*) inner_commute (*‹?x ∙ ?y = ?y ∙ ?x›*))[1])
(*discuss goal 7*)
apply ((auto simp: cnj_real_def (*‹cnj_class.cnj = id›*) inner_add_left (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z›*) real_of_real_def (*‹real_of = id›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 38 facts*) inner_commute (*‹?x ∙ ?y = ?y ∙ ?x›*))[1])
(*proven 7 subgoals*) .
interpretation RR_inner: inner_product_space scaleR "(*)"
apply unfold_locales
(*goals:
1. ‹⋀x y. x * y = cnj_class.cnj (y * x)›
2. ‹⋀x y z. (x + y) * z = x * z + y * z›
3. ‹⋀r x y. r *⇩R x * y = r * (x * y)›
4. ‹⋀x. 0 ≤ real_of (x * x)›
5. ‹⋀x. (x * x = 0) = (x = 0)›
6. ‹⋀x A. real_of (x * x) *⇩R A = x * x * A›
7. ‹⋀x. (0 < real_of (x * x)) = (x ≠ 0)›
discuss goal 1*)
apply ((auto simp add: cnj_real_def (*‹cnj_class.cnj = id›*) distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) real_of_real_def (*‹real_of = id›*))[1])
(*discuss goal 2*)
apply ((auto simp add: cnj_real_def (*‹cnj_class.cnj = id›*) distrib_right (*‹((?a::?'a) + (?b::?'a)) * (?c::?'a) = ?a * ?c + ?b * ?c›*) real_of_real_def (*‹real_of = id›*))[1])
(*discuss goal 3*)
apply ((auto simp add: cnj_real_def (*‹cnj_class.cnj = id›*) distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) real_of_real_def (*‹real_of = id›*))[1])
(*discuss goal 4*)
apply ((auto simp add: cnj_real_def (*‹cnj_class.cnj = id›*) distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) real_of_real_def (*‹real_of = id›*))[1])
(*discuss goal 5*)
apply ((auto simp add: cnj_real_def (*‹cnj_class.cnj = id›*) distrib_right (*‹((?a::?'a) + (?b::?'a)) * (?c::?'a) = ?a * ?c + ?b * ?c›*) real_of_real_def (*‹real_of = id›*))[1])
(*discuss goal 6*)
apply ((auto simp add: cnj_real_def (*‹cnj_class.cnj = id›*) distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) real_of_real_def (*‹real_of = id›*))[1])
(*discuss goal 7*)
apply ((auto simp add: cnj_real_def (*‹cnj_class.cnj = id›*) distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) real_of_real_def (*‹real_of = id›*))[1])
(*goal: ‹⋀x. (0 < real_of (x * x)) = (x ≠ 0)›*)
apply (metis not_real_square_gt_zero (*‹(¬ (0::real) < (?x::real) * ?x) = (?x = (0::real))›*))
(*proven 7 subgoals*) .
interpretation CC_inner: inner_product_space "((*)::complex⇒complex⇒complex)" "λx y. x*cnj y"
apply unfold_locales
(*goals:
1. ‹⋀x y. x * cnj_class.cnj y = cnj_class.cnj (y * cnj_class.cnj x)›
2. ‹⋀x y z. (x + y) * cnj_class.cnj z = x * cnj_class.cnj z + y * cnj_class.cnj z›
3. ‹⋀r x y. r * x * cnj_class.cnj y = r * (x * cnj_class.cnj y)›
4. ‹⋀x. 0 ≤ real_of (x * cnj_class.cnj x)›
5. ‹⋀x. (x * cnj_class.cnj x = 0) = (x = 0)›
6. ‹⋀x A. real_of (x * cnj_class.cnj x) *⇩R A = x * cnj_class.cnj x * A›
7. ‹⋀x. (0 < real_of (x * cnj_class.cnj x)) = (x ≠ 0)›
discuss goal 1*)
apply ((auto simp add: real_of_complex_def (*‹real_of = Re›*) cnj_complex_def (*‹cnj_class.cnj = Complex.cnj›*) distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) complex_mult_cnj (*‹?z * Complex.cnj ?z = complex_of_real ((Re ?z)² + (Im ?z)²)›*) complex_neq_0 (*‹(?z ≠ 0) = (0 < (Re ?z)² + (Im ?z)²)›*) cmod_power2 (*‹(cmod ?z)² = (Re ?z)² + (Im ?z)²›*) complex_norm_square (*‹complex_of_real ((cmod ?z)²) = ?z * Complex.cnj ?z›*))[1])
(*discuss goal 2*)
apply ((auto simp add: real_of_complex_def (*‹real_of = Re›*) cnj_complex_def (*‹cnj_class.cnj = Complex.cnj›*) distrib_left (*‹(?a::?'a::semiring) * ((?b::?'a::semiring) + (?c::?'a::semiring)) = ?a * ?b + ?a * ?c›*) distrib_right (*‹((?a::?'a::semiring) + (?b::?'a::semiring)) * (?c::?'a::semiring) = ?a * ?c + ?b * ?c›*) complex_mult_cnj (*‹(?z::complex) * Complex.cnj ?z = complex_of_real ((Re ?z)² + (Im ?z)²)›*) complex_neq_0 (*‹((?z::complex) ≠ (0::complex)) = ((0::real) < (Re ?z)² + (Im ?z)²)›*) cmod_power2 (*‹(cmod (?z::complex))² = (Re ?z)² + (Im ?z)²›*) complex_norm_square (*‹complex_of_real ((cmod (?z::complex))²) = ?z * Complex.cnj ?z›*))[1])
(*discuss goal 3*)
apply ((auto simp add: real_of_complex_def (*‹real_of = Re›*) cnj_complex_def (*‹cnj_class.cnj = Complex.cnj›*) distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) complex_mult_cnj (*‹?z * Complex.cnj ?z = complex_of_real ((Re ?z)² + (Im ?z)²)›*) complex_neq_0 (*‹(?z ≠ 0) = (0 < (Re ?z)² + (Im ?z)²)›*) cmod_power2 (*‹(cmod ?z)² = (Re ?z)² + (Im ?z)²›*) complex_norm_square (*‹complex_of_real ((cmod ?z)²) = ?z * Complex.cnj ?z›*))[1])
(*discuss goal 4*)
apply ((auto simp add: real_of_complex_def (*‹real_of = Re›*) cnj_complex_def (*‹cnj_class.cnj = Complex.cnj›*) distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) complex_mult_cnj (*‹?z * Complex.cnj ?z = complex_of_real ((Re ?z)² + (Im ?z)²)›*) complex_neq_0 (*‹(?z ≠ 0) = (0 < (Re ?z)² + (Im ?z)²)›*) cmod_power2 (*‹(cmod ?z)² = (Re ?z)² + (Im ?z)²›*) complex_norm_square (*‹complex_of_real ((cmod ?z)²) = ?z * Complex.cnj ?z›*))[1])
(*discuss goal 5*)
apply ((auto simp add: real_of_complex_def (*‹real_of = Re›*) cnj_complex_def (*‹cnj_class.cnj = Complex.cnj›*) distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) complex_mult_cnj (*‹?z * Complex.cnj ?z = complex_of_real ((Re ?z)² + (Im ?z)²)›*) complex_neq_0 (*‹(?z ≠ 0) = (0 < (Re ?z)² + (Im ?z)²)›*) cmod_power2 (*‹(cmod ?z)² = (Re ?z)² + (Im ?z)²›*) complex_norm_square (*‹complex_of_real ((cmod ?z)²) = ?z * Complex.cnj ?z›*))[1])
(*top goal: ‹⋀x. (x * cnj_class.cnj x = 0) = (x = 0)› and 2 goals remain*)
apply (metis Re_complex_of_real (*‹Re (complex_of_real (?z::real)) = ?z›*) complex_neq_0 (*‹((?z::complex) ≠ (0::complex)) = ((0::real) < (Re ?z)² + (Im ?z)²)›*) less_numeral_extra( (*‹¬ (0::?'a) < (0::?'a)›*) 3) of_real_add (*‹of_real ((?x::real) + (?y::real)) = of_real ?x + of_real ?y›*) of_real_power (*‹of_real ((?x::real) ^ (?n::nat)) = of_real ?x ^ ?n›*) zero_complex.simps( (*‹Re (0::complex) = (0::real)›*) 1))
(*discuss goal 6*)
apply ((auto simp add: real_of_complex_def (*‹real_of = Re›*) cnj_complex_def (*‹cnj_class.cnj = Complex.cnj›*) distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) complex_mult_cnj (*‹?z * Complex.cnj ?z = complex_of_real ((Re ?z)² + (Im ?z)²)›*) complex_neq_0 (*‹(?z ≠ 0) = (0 < (Re ?z)² + (Im ?z)²)›*) cmod_power2 (*‹(cmod ?z)² = (Re ?z)² + (Im ?z)²›*) complex_norm_square (*‹complex_of_real ((cmod ?z)²) = ?z * Complex.cnj ?z›*))[1])
(*top goal: ‹⋀x A. real_of (x * cnj_class.cnj x) *⇩R A = x * cnj_class.cnj x * A› and 1 goal remains*)
apply (simp add: distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) mult.commute (*‹?a * ?b = ?b * ?a›*) scaleR_conv_of_real (*‹?r *⇩R ?x = of_real ?r * ?x›*))
(*discuss goal 7*)
apply ((auto simp add: real_of_complex_def (*‹real_of = Re›*) cnj_complex_def (*‹cnj_class.cnj = Complex.cnj›*) distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) complex_mult_cnj (*‹?z * Complex.cnj ?z = complex_of_real ((Re ?z)² + (Im ?z)²)›*) complex_neq_0 (*‹(?z ≠ 0) = (0 < (Re ?z)² + (Im ?z)²)›*) cmod_power2 (*‹(cmod ?z)² = (Re ?z)² + (Im ?z)²›*) complex_norm_square (*‹complex_of_real ((cmod ?z)²) = ?z * Complex.cnj ?z›*))[1])
(*proven 7 subgoals*) .
context inner_product_space
begin
lemma inner_zero_left [simp]: "inner 0 x = 0"
using inner_add_left[of 0 0 x] (*‹inner (0 + 0) x = inner 0 x + inner 0 x›*) by (auto simp add: two_not_one (*‹2 ≠ 1›*))
lemma inner_minus_left [simp]: "inner (- x) y = - inner x y"
using inner_add_left[of x "- x" y] (*‹inner (x + - x) y = inner x y + inner (- x) y›*) using add_eq_0_iff (*‹(?a + ?b = 0) = (?b = - ?a)›*) by force
lemma inner_diff_left: "inner (x - y) z = inner x z - inner y z"
using inner_add_left[of x "- y" z] (*‹inner (x + - y) z = inner x z + inner (- y) z›*) by simp
lemma inner_sum_left: "inner (∑x∈A. f x) y = (∑x∈A. inner (f x) y)"
apply (cases "finite A")
(*goals:
1. ‹finite A ⟹ inner (sum f A) y = (∑x∈A. inner (f x) y)›
2. ‹infinite A ⟹ inner (sum f A) y = (∑x∈A. inner (f x) y)›
discuss goal 1*)
apply (induct set: finite)
(*goals:
1. ‹inner (sum f {}) y = (∑x∈{}. inner (f x) y)›
2. ‹⋀x F. ⟦finite F; x ∉ F; inner (sum f F) y = (∑x∈F. inner (f x) y)⟧ ⟹ inner (sum f (insert x F)) y = (∑x∈insert x F. inner (f x) y)›
discuss goal 1*)
apply (simp add: inner_add_left (*‹(inner::'b ⇒ 'b ⇒ 'a) ((?x::'b) + (?y::'b)) (?z::'b) = inner ?x ?z + inner ?y ?z›*))
(*discuss goal 2*)
apply (simp add: inner_add_left (*‹inner (?x + ?y) ?z = inner ?x ?z + inner ?y ?z›*))
(*proven 2 subgoals*)
(*discuss goal 2*)
apply (simp add: inner_add_left (*‹inner (?x + ?y) ?z = inner ?x ?z + inner ?y ?z›*))
(*proven 2 subgoals*) .
text ‹Transfer distributivity rules to right argument.›
lemma inner_add_right: "inner x (y + z) = inner x y + inner x z"
proof (-)
(*goal: ‹inner x (y + z) = inner x y + inner x z›*)
have "inner x (y + z) = cnj (inner (y + z) x)"
using inner_commute (*‹(inner::'b::ab_group_add ⇒ 'b::ab_group_add ⇒ 'a::real_of_extended) (?x::'b::ab_group_add) (?y::'b::ab_group_add) = cnj_class.cnj (inner ?y ?x)›*) by blast
also (*calculation: ‹inner x (y + z) = cnj_class.cnj (inner (y + z) x)›*) have "... = cnj ((inner y x) +(inner z x))"
using inner_add_left (*‹(inner::'b ⇒ 'b ⇒ 'a) ((?x::'b) + (?y::'b)) (?z::'b) = inner ?x ?z + inner ?y ?z›*) by simp
also (*calculation: ‹inner x (y + z) = cnj_class.cnj (inner y x + inner z x)›*) have "... = cnj (inner y x) + cnj (inner z x)"
using cnj_add (*‹cnj_class.cnj (?a + ?b) = cnj_class.cnj ?a + cnj_class.cnj ?b›*) by blast
also (*calculation: ‹inner x (y + z) = cnj_class.cnj (inner y x) + cnj_class.cnj (inner z x)›*) have "... = inner x y + inner x z"
using inner_commute[of x y] (*‹inner x y = cnj_class.cnj (inner y x)›*) using inner_commute[of x z] (*‹inner x z = cnj_class.cnj (inner z x)›*) by simp
finally (*calculation: ‹inner x (y + z) = inner x y + inner x z›*) show "?thesis"
(*goal: ‹inner x (y + z) = inner x y + inner x z›*) .
qed
lemma inner_scaleR_right [simp]: "inner x (scale r y) = (cnj r) * (inner x y)"
using inner_scaleR_left[of r y x] (*‹(inner::'b ⇒ 'b ⇒ 'a) ((scale::'a ⇒ 'b ⇒ 'b) (r::'a) (y::'b)) (x::'b) = r * inner y x›*) by (metis (no_types) cnj_mult (*‹cnj_class.cnj (?a * ?b) = cnj_class.cnj ?a * cnj_class.cnj ?b›*) local.inner_commute (*‹inner ?x ?y = cnj_class.cnj (inner ?y ?x)›*))
lemma inner_zero_right [simp]: "inner x 0 = 0"
using inner_zero_left[of x] (*‹inner 0 x = 0›*) by (metis local.inner_commute (*‹inner ?x ?y = cnj_class.cnj (inner ?y ?x)›*) local.inner_eq_zero_iff (*‹(inner ?x ?x = 0) = (?x = 0)›*))
lemma inner_minus_right [simp]: "inner x (- y) = - inner x y"
using inner_minus_left[of y x] (*‹inner (- y) x = - inner y x›*) by (metis (no_types) add_eq_0_iff (*‹(?a + ?b = 0) = (?b = - ?a)›*) local.inner_add_right (*‹inner ?x (?y + ?z) = inner ?x ?y + inner ?x ?z›*) local.inner_zero_right (*‹inner ?x 0 = 0›*))
lemma inner_diff_right: "inner x (y - z) = inner x y - inner x z"
using inner_diff_left[of y z x] (*‹(inner::'b ⇒ 'b ⇒ 'a) ((y::'b) - (z::'b)) (x::'b) = inner y x - inner z x›*) by (metis add_uminus_conv_diff (*‹?a + - ?b = ?a - ?b›*) local.inner_add_right (*‹inner ?x (?y + ?z) = inner ?x ?y + inner ?x ?z›*) local.inner_minus_right (*‹inner ?x (- ?y) = - inner ?x ?y›*))
lemma inner_sum_right: "inner x (∑y∈A. f y) = (∑y∈A. inner x (f y))"
proof (-)
(*goal: ‹inner x (sum f A) = (∑y∈A. inner x (f y))›*)
have "inner x (∑y∈A. f y) = cnj (inner (∑y∈A. f y) x)"
using inner_commute (*‹inner ?x ?y = cnj_class.cnj (inner ?y ?x)›*) by blast
also (*calculation: ‹inner x (sum f A) = cnj_class.cnj (inner (sum f A) x)›*) have "... = cnj (∑xa∈A. inner (f xa) x)"
unfolding inner_sum_left[of f A x]
(*goal: ‹cnj_class.cnj (∑xa∈A. inner (f xa) x) = cnj_class.cnj (∑xa∈A. inner (f xa) x)›*)
by standard
also (*calculation: ‹inner x (sum f A) = cnj_class.cnj (∑xa∈A. inner (f xa) x)›*) have "... = (∑xa∈A. cnj (inner (f xa) x))"
unfolding cnj_sum
(*goal: ‹(∑xa∈A. cnj_class.cnj (inner (f xa) x)) = (∑xa∈A. cnj_class.cnj (inner (f xa) x))›*)
by standard
also (*calculation: ‹inner x (sum f A) = (∑xa∈A. cnj_class.cnj (inner (f xa) x))›*) have "... = (∑xa∈A. inner x (f xa))"
apply (rule sum.cong (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B ⟹ (?g::?'b ⇒ ?'a) x = (?h::?'b ⇒ ?'a) x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*goals:
1. ‹(A::'c::type set) = A›
2. ‹⋀xa::'c::type. xa ∈ (A::'c::type set) ⟹ cnj_class.cnj ((inner::'b::ab_group_add ⇒ 'b::ab_group_add ⇒ 'a::real_of_extended) ((f::'c::type ⇒ 'b::ab_group_add) xa) (x::'b::ab_group_add)) = inner x (f xa)›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (metis inner_commute (*‹inner ?x ?y = cnj_class.cnj (inner ?y ?x)›*))
(*proven 2 subgoals*) .
finally (*calculation: ‹inner x (sum f A) = (∑xa∈A. inner x (f xa))›*) show "?thesis"
(*goal: ‹inner x (sum f A) = (∑y∈A. inner x (f y))›*) .
qed
lemmas inner_add [algebra_simps] = inner_add_left inner_add_right
lemmas inner_diff [algebra_simps] = inner_diff_left inner_diff_right
lemmas inner_scaleR = inner_scaleR_left inner_scaleR_right
text ‹Legacy theorem names›
lemmas inner_left_distrib = inner_add_left
lemmas inner_right_distrib = inner_add_right
lemmas inner_distrib = inner_left_distrib inner_right_distrib
lemma aux_Cauchy:
shows "0 ≤ real_of (inner x x + (cnj a) * (inner x y) + a * ((cnj (inner x y)) + (cnj a) * (inner y y)))"
proof (-)
(*goal: ‹0 ≤ real_of (inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y))›*)
have "(inner (x+scale a y) (x+scale a y)) = (inner (x+scale a y) x) + (inner (x+scale a y) (scale a y))"
unfolding inner_add_right
(*goal: ‹inner (x + scale a y) x + inner (x + scale a y) (scale a y) = inner (x + scale a y) x + inner (x + scale a y) (scale a y)›*)
by standard
also (*calculation: ‹inner (x + scale a y) (x + scale a y) = inner (x + scale a y) x + inner (x + scale a y) (scale a y)›*) have "... = inner x x + (cnj a) * (inner x y) + a * ((cnj (inner x y)) + (cnj a) * (inner y y))"
unfolding inner_add_left
(*goal: ‹inner x x + inner (scale a y) x + (inner x (scale a y) + inner (scale a y) (scale a y)) = inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y)›*)
unfolding inner_scaleR_left
(*goal: ‹inner x x + a * inner y x + (inner x (scale a y) + a * inner y (scale a y)) = inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y)›*)
unfolding inner_scaleR_right
(*goal: ‹inner x x + a * inner y x + (cnj_class.cnj a * inner x y + a * (cnj_class.cnj a * inner y y)) = inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y)›*)
unfolding inner_commute[of y x]
(*goal: ‹inner x x + a * cnj_class.cnj (inner x y) + (cnj_class.cnj a * inner x y + a * (cnj_class.cnj a * inner y y)) = inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y)›*)
unfolding distrib_left
(*goal: ‹(inner::'b ⇒ 'b ⇒ 'a) (x::'b) x + (a::'a) * cnj_class.cnj (inner x (y::'b)) + (cnj_class.cnj a * inner x y + a * (cnj_class.cnj a * inner y y)) = inner x x + cnj_class.cnj a * inner x y + (a * cnj_class.cnj (inner x y) + a * (cnj_class.cnj a * inner y y))›*)
by auto
finally (*calculation: ‹inner (x + scale a y) (x + scale a y) = inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y)›*) show "?thesis"
(*goal: ‹(0::real) ≤ real_of ((inner::'b::ab_group_add ⇒ 'b::ab_group_add ⇒ 'a::real_of_extended) (x::'b::ab_group_add) x + cnj_class.cnj (a::'a::real_of_extended) * inner x (y::'b::ab_group_add) + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y))›*)
by (metis inner_ge_zero (*‹0 ≤ real_of (inner ?x ?x)›*))
qed
lemma real_inner_inner: "real_of (inner x x * inner y y) = real_of (inner x x) * real_of (inner y y)"
by (metis real_scalar_mult (*‹real_of (?c *⇩R ?a) = ?c * real_of ?a›*) real_scalar_mult2 (*‹real_of (inner ?x ?x) *⇩R ?A = inner ?x ?x * ?A›*))
lemma Cauchy_Schwarz_ineq:
"real_of (cnj (inner x y) * inner x y) ≤ real_of (inner x x) * real_of (inner y y)"
sorry
end
hide_const (open) norm
context inner_product_space
begin
definition "norm x = (sqrt (real_of (inner x x)))"
lemmas norm_eq_sqrt_inner = norm_def
lemma inner_cnj_ge_zero[simp]: "real_of ((inner x y) * cnj (inner x y)) ≥ 0"
using real_a_cnj_ge_0 (*‹0 ≤ real_of (?a * cnj_class.cnj ?a)›*) by auto
lemma power2_norm_eq_inner: "(norm x)² = real_of (inner x x)"
by (simp add: norm_def (*‹norm ?x = sqrt (real_of (inner ?x ?x))›*))
lemma Cauchy_Schwarz_ineq2:
"sqrt (real_of (cnj (inner x y) * inner x y)) ≤ norm x * norm y"
proof (rule power2_le_imp_le (*‹⟦(?x::?'a::linordered_semidom)² ≤ (?y::?'a::linordered_semidom)²; (0::?'a::linordered_semidom) ≤ ?y⟧ ⟹ ?x ≤ ?y›*))
(*goals:
1. ‹(sqrt (real_of (cnj_class.cnj (inner x y) * inner x y)))² ≤ (norm x * norm y)²›
2. ‹0 ≤ norm x * norm y›*)
have eq: "0 ≤ real_of (cnj (inner x y) * inner x y)"
by (simp add: mult.commute (*‹?a * ?b = ?b * ?a›*))
have "real_of (cnj (inner x y) * inner x y) ≤ real_of (inner x x) * real_of (inner y y)"
using Cauchy_Schwarz_ineq (*‹real_of (cnj_class.cnj (inner ?x ?y) * inner ?x ?y) ≤ real_of (inner ?x ?x) * real_of (inner ?y ?y)›*) .
thus "(sqrt (real_of (cnj (inner x y) * inner x y)))² ≤ (norm x * norm y)²"
unfolding power_mult_distrib
(*goal: ‹(sqrt (real_of (cnj_class.cnj (inner x y) * inner x y)))² ≤ (norm x)² * (norm y)²›*)
unfolding power2_norm_eq_inner
(*goal: ‹(sqrt (real_of (cnj_class.cnj ((inner::'b::ab_group_add ⇒ 'b::ab_group_add ⇒ 'a::real_of_extended) (x::'b::ab_group_add) (y::'b::ab_group_add)) * inner x y)))² ≤ real_of (inner x x) * real_of (inner y y)›*)
unfolding real_sqrt_pow2[OF eq]
(*goal: ‹real_of (cnj_class.cnj ((inner::'b ⇒ 'b ⇒ 'a) (x::'b) (y::'b)) * inner x y) ≤ real_of (inner x x) * real_of (inner y y)›*) .
show "0 ≤ norm x * norm y"
unfolding norm_eq_sqrt_inner
(*goal: ‹(0::real) ≤ sqrt (real_of ((inner::'b::ab_group_add ⇒ 'b::ab_group_add ⇒ 'a::real_of_extended) (x::'b::ab_group_add) x)) * sqrt (real_of (inner (y::'b::ab_group_add) y))›*)
by (intro mult_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a * ?b›*) real_sqrt_ge_zero (*‹0 ≤ ?x ⟹ 0 ≤ sqrt ?x›*) inner_ge_zero (*‹0 ≤ real_of (inner ?x ?x)›*))
qed
end
subsubsection‹Orthogonality›
hide_const (open) orthogonal
context inner_product_space
begin
definition "orthogonal x y ⟷ inner x y = 0"
lemma orthogonal_clauses:
"orthogonal a 0"
"orthogonal a x ⟹ orthogonal a (scale c x)"
"orthogonal a x ⟹ orthogonal a (- x)"
"orthogonal a x ⟹ orthogonal a y ⟹ orthogonal a (x + y)"
"orthogonal a x ⟹ orthogonal a y ⟹ orthogonal a (x - y)"
"orthogonal 0 a"
"orthogonal x a ⟹ orthogonal (scale c x) a"
"orthogonal x a ⟹ orthogonal (- x) a"
"orthogonal x a ⟹ orthogonal y a ⟹ orthogonal (x + y) a"
"orthogonal x a ⟹ orthogonal y a ⟹ orthogonal (x - y) a"
unfolding orthogonal_def inner_add inner_diff
(*goals:
1. ‹inner a 0 = 0›
2. ‹inner a x = 0 ⟹ inner a (scale c x) = 0›
3. ‹inner a x = 0 ⟹ inner a (- x) = 0›
4. ‹⟦inner a x = 0; inner a y = 0⟧ ⟹ inner a x + inner a y = 0›
5. ‹⟦inner a x = 0; inner a y = 0⟧ ⟹ inner a x - inner a y = 0›
6. ‹inner 0 a = 0›
7. ‹inner x a = 0 ⟹ inner (scale c x) a = 0›
8. ‹inner x a = 0 ⟹ inner (- x) a = 0›
9. ‹⟦inner x a = 0; inner y a = 0⟧ ⟹ inner x a + inner y a = 0›
10. ‹⟦inner x a = 0; inner y a = 0⟧ ⟹ inner x a - inner y a = 0›*)
(*goals:
1. ‹inner a 0 = 0›
2. ‹inner a x = 0 ⟹ inner a (scale c x) = 0›
3. ‹inner a x = 0 ⟹ inner a (- x) = 0›
4. ‹⟦inner a x = 0; inner a y = 0⟧ ⟹ inner a x + inner a y = 0›
5. ‹⟦inner a x = 0; inner a y = 0⟧ ⟹ inner a x - inner a y = 0›
6. ‹inner 0 a = 0›
7. ‹inner x a = 0 ⟹ inner (scale c x) a = 0›
8. ‹inner x a = 0 ⟹ inner (- x) a = 0›
9. ‹⟦inner x a = 0; inner y a = 0⟧ ⟹ inner x a + inner y a = 0›
10. ‹⟦inner x a = 0; inner y a = 0⟧ ⟹ inner x a - inner y a = 0›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*discuss goal 6*)
apply ((auto)[1])
(*discuss goal 7*)
apply ((auto)[1])
(*discuss goal 8*)
apply ((auto)[1])
(*discuss goal 9*)
apply ((auto)[1])
(*discuss goal 10*)
apply ((auto)[1])
(*proven 10 subgoals*) .
lemma inner_commute_zero: "(inner xa x = 0) = (inner x xa = 0)"
by (metis cnj_0 (*‹cnj_class.cnj 0 = 0›*) local.inner_commute (*‹inner ?x ?y = cnj_class.cnj (inner ?y ?x)›*))
lemma vector_sub_project_orthogonal:
"inner b (x - scale (inner x b / (inner b b)) b) = 0"
proof (-)
(*goal: ‹(inner::'b ⇒ 'b ⇒ 'a) (b::'b) ((x::'b) - (scale::'a ⇒ 'b ⇒ 'b) (inner x b / inner b b) b) = (0::'a)›*)
have f1: "⋀b a ba. inner b (scale a ba) = cnj (a * inner ba b)"
by (metis local.inner_commute (*‹inner ?x ?y = cnj_class.cnj (inner ?y ?x)›*) local.inner_scaleR_left (*‹inner (scale ?r ?x) ?y = ?r * inner ?x ?y›*))
{
assume "b ≠ 0" (*‹(b::'b) ≠ (0::'b)›*)
hence "cnj (inner x b) = inner b x ∧ inner b b ≠ 0"
by (metis (no_types) local.inner_commute (*‹inner ?x ?y = cnj_class.cnj (inner ?y ?x)›*) local.inner_eq_zero_iff (*‹(inner ?x ?x = 0) = (?x = 0)›*))
hence "inner b (x - scale (inner x b / inner b b) b) = 0"
using f1 (*‹inner ?b (scale ?a ?ba) = cnj_class.cnj (?a * inner ?ba ?b)›*) local.inner_diff_right (*‹inner ?x (?y - ?z) = inner ?x ?y - inner ?x ?z›*) by force
}
thus "?thesis"
(*goal: ‹inner b (x - scale (inner x b / inner b b) b) = 0›*)
by fastforce
qed
lemma orthogonal_commute: "orthogonal x y ⟷ orthogonal y x"
unfolding orthogonal_def
(*goal: ‹(inner x y = 0) = (inner y x = 0)›*)
using inner_commute_zero (*‹(inner ?xa ?x = 0) = (inner ?x ?xa = 0)›*) by auto
lemma pairwise_orthogonal_insert:
assumes "pairwise orthogonal S"
and "⋀y. y ∈ S ⟹ orthogonal x y"
shows "pairwise orthogonal (insert x S)"
using assms (*‹pairwise orthogonal (S::'b set)› ‹?y ∈ S ⟹ orthogonal x ?y›*) unfolding pairwise_def
(*goal: ‹∀xa∈insert x S. ∀y∈insert x S. xa ≠ y ⟶ orthogonal xa y›*)
by (auto simp add: orthogonal_commute (*‹orthogonal ?x ?y = orthogonal ?y ?x›*))
end
lemma sum_0_all:
assumes a: "∀a∈A. f a ≥ (0 :: real)"
and s0: "sum f A = 0" and f: "finite A"
shows "∀a∈A. f a = 0"
using a (*‹∀a∈A. 0 ≤ f a›*) f (*‹finite A›*) s0 (*‹sum f A = 0›*) sum_nonneg_eq_0_iff (*‹⟦finite ?A; ⋀x. x ∈ ?A ⟹ 0 ≤ ?f x⟧ ⟹ (sum ?f ?A = 0) = (∀x∈?A. ?f x = 0)›*) by blast
subsection‹Vecs as inner product spaces›
locale vec_real_inner = F?: inner_product_space "((*) :: 'a⇒'a⇒'a)" inner_field
for inner_field :: "'a⇒'a⇒'a::{field,cnj,real_of_extended}"
+ fixes inner :: "'a^'n ⇒ 'a^'n ⇒'a"
assumes inner_vec_def: "inner x y = sum (λi. inner_field (x$i) (y$i)) UNIV"
begin
lemma inner_ge_zero [simp]: "0 ≤ real_of (inner x x)"
by (auto simp add: inner_vec_def (*‹inner ?x ?y = (∑i∈UNIV. inner_field (?x $ i) (?y $ i))›*) real_sum (*‹real_of (sum ?f ?A) = (∑i∈?A. real_of (?f i))›*) sum_nonneg (*‹(⋀x. x ∈ ?A ⟹ 0 ≤ ?f x) ⟹ 0 ≤ sum ?f ?A›*))
lemma real_scalar_mult2: "real_of (inner x x) *⇩R A = inner x x * A"
apply (auto simp add: inner_vec_def (*‹inner ?x ?y = (∑i∈UNIV. inner_field (?x $ i) (?y $ i))›*))
(*goal: ‹real_of (inner x x) *⇩R A = inner x x * A›*)
by (metis (mono_tags, lifting) Finite_Cartesian_Product.sum_cong_aux (*‹(⋀x. x ∈ ?A ⟹ ?f x = ?g x) ⟹ sum ?f ?A = sum ?g ?A›*) real_scalar_mult2 (*‹real_of (inner_field ?x ?x) *⇩R ?A = inner_field ?x ?x * ?A›*) real_sum (*‹real_of (sum ?f ?A) = (∑i∈?A. real_of (?f i))›*) scaleR_left.sum (*‹sum ?g ?A *⇩R ?x = (∑x∈?A. ?g x *⇩R ?x)›*) scale_sum_left (*‹sum ?f ?A * ?x = (∑a∈?A. ?f a * ?x)›*))
lemma i1: "inner x y = cnj (inner y x)"
apply (auto simp add: inner_vec_def (*‹inner ?x ?y = (∑i∈UNIV. inner_field (?x $ i) (?y $ i))›*) cnj_sum (*‹cnj_class.cnj (sum ?f ?A) = (∑xa∈?A. cnj_class.cnj (?f xa))›*) cnj_mult (*‹cnj_class.cnj (?a * ?b) = cnj_class.cnj ?a * cnj_class.cnj ?b›*) mult.commute (*‹?a * ?b = ?b * ?a›*))
(*goal: ‹(inner::('a, 'n) vec ⇒ ('a, 'n) vec ⇒ 'a) (x::('a, 'n) vec) (y::('a, 'n) vec) = cnj_class.cnj (inner y x)›*)
by (meson local.inner_commute (*‹inner_field ?x ?y = cnj_class.cnj (inner_field ?y ?x)›*))
lemma i2: "inner (x + y) z = inner x z + inner y z"
using local.inner_left_distrib (*‹inner_field (?x + ?y) ?z = inner_field ?x ?z + inner_field ?y ?z›*) sum.distrib (*‹(∑x::?'b∈(?A::?'b set). (?g::?'b ⇒ ?'a) x + (?h::?'b ⇒ ?'a) x) = sum ?g ?A + sum ?h ?A›*) inner_vec_def (*‹inner ?x ?y = (∑i∈UNIV. inner_field (?x $ i) (?y $ i))›*) by force
lemma i3: "inner (r *s x) y = r * inner x y"
by (auto simp add: inner_vec_def (*‹(inner::('a, 'n) vec ⇒ ('a, 'n) vec ⇒ 'a) (?x::('a, 'n) vec) (?y::('a, 'n) vec) = (∑i::'n∈UNIV. (inner_field::'a ⇒ 'a ⇒ 'a) (?x $ i) (?y $ i))›*) scale_sum_right (*‹(?a::'a) * sum (?f::?'c ⇒ 'a) (?A::?'c set) = (∑x::?'c∈?A. ?a * ?f x)›*))
lemma i4: assumes "inner x x = 0"
shows "x = 0"
apply (unfold vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*))
(*goal: ‹x = 0›*)
apply clarify
(*goal: ‹∀i::'n::finite. (x::('a::real_of_extended, 'n::finite) vec) $ i = (0::('a::real_of_extended, 'n::finite) vec) $ i›*)
proof (simp)
(*goal: ‹⋀i. x $ i = 0›*)
fix a
have "0 = real_of (∑i∈UNIV. inner_field (x $ i) (x $ i))"
using assms (*‹inner x x = 0›*) by (simp add: inner_vec_def (*‹inner ?x ?y = (∑i∈UNIV. inner_field (?x $ i) (?y $ i))›*))
also (*calculation: ‹0 = real_of (∑i∈UNIV. inner_field (x $ i) (x $ i))›*) have "... = (∑i∈UNIV. real_of (inner_field (x $ i) (x $ i)))"
using real_sum (*‹real_of (sum ?f ?A) = (∑i∈?A. real_of (?f i))›*) by auto
finally (*calculation: ‹0 = (∑i∈UNIV. real_of (inner_field (x $ i) (x $ i)))›*) have "0 = (∑i∈UNIV. real_of (inner_field (x $ i) (x $ i)))" .
hence "real_of (inner_field (x $ a) (x $ a)) = 0"
using sum_0_all (*‹⟦∀a::?'a∈?A::?'a set. (0::real) ≤ (?f::?'a ⇒ real) a; sum ?f ?A = (0::real); finite ?A⟧ ⟹ ∀a::?'a∈?A. ?f a = (0::real)›*) F.inner_ge_zero (*‹(0::real) ≤ real_of ((inner_field::'a ⇒ 'a ⇒ 'a) (?x::'a) ?x)›*) by (metis (no_types, lifting) finite (*‹finite ?A›*) iso_tuple_UNIV_I (*‹?x ∈ UNIV ≡ True›*))
then show "x $ a = 0"
by (metis F.inner_eq_zero_iff (*‹(inner_field ?x ?x = 0) = (?x = 0)›*) F.inner_gt_zero_iff (*‹(0 < real_of (inner_field ?x ?x)) = (?x ≠ 0)›*) real_0 (*‹real_of 0 = 0›*))
qed
lemma inner_0_0[simp]: "inner 0 0 = 0"
unfolding inner_vec_def
(*goal: ‹(∑i∈UNIV. inner_field (0 $ i) (0 $ i)) = 0›*)
by auto
sublocale v?: inner_product_space "((*s) :: 'a ⇒ 'a^'n ⇒ 'a^'n)" "inner"
proof (unfold_locales, auto simp add: real_scalar_mult2 (*‹real_of (inner ?x ?x) *⇩R ?A = inner ?x ?x * ?A›*))
(*goals:
1. ‹⋀x y. inner x y = cnj_class.cnj (inner y x)›
2. ‹⋀x y z. inner (x + y) z = inner x z + inner y z›
3. ‹⋀r x y. inner (r *s x) y = r * inner x y›
4. ‹⋀x. inner x x = 0 ⟹ x = 0›
5. ‹⋀x. x ≠ 0 ⟹ 0 < real_of (inner x x)›*)
fix x :: "'a^'n" and y :: "'a^'n" and z :: "'a^'n" and r
show "inner x y = cnj (inner y x)"
using i1[of x y] (*‹inner x y = cnj_class.cnj (inner y x)›*) by simp
show "inner (x + y) z = inner x z + inner y z"
using i2 (*‹(inner::('a, 'n) vec ⇒ ('a, 'n) vec ⇒ 'a) ((?x::('a, 'n) vec) + (?y::('a, 'n) vec)) (?z::('a, 'n) vec) = inner ?x ?z + inner ?y ?z›*) by blast
show "inner (r *s x) y = r * inner x y"
using i3 (*‹inner (?r *s ?x) ?y = ?r * inner ?x ?y›*) by blast
show i: "inner x x = 0 ⟹ x = 0"
using i4 (*‹(inner::('a::real_of_extended, 'n::finite) vec ⇒ ('a::real_of_extended, 'n::finite) vec ⇒ 'a::real_of_extended) (?x::('a::real_of_extended, 'n::finite) vec) ?x = (0::'a::real_of_extended) ⟹ ?x = (0::('a::real_of_extended, 'n::finite) vec)›*) by blast
assume "x ≠ 0" (*‹(x::('a, 'n) vec) ≠ (0::('a, 'n) vec)›*)
thus "0 < real_of (inner x x)"
by (metis i (*‹inner x x = 0 ⟹ x = 0›*) ‹x ≠ 0› inner_0_0 (*‹inner 0 0 = 0›*) local.inner_ge_zero (*‹0 ≤ real_of (inner ?x ?x)›*) local.real_scalar_mult2 (*‹real_of (inner ?x ?x) *⇩R ?A = inner ?x ?x * ?A›*) mult.commute (*‹?a * ?b = ?b * ?a›*) mult_1_left (*‹1 * ?a = ?a›*) order.not_eq_order_implies_strict (*‹⟦?a ≠ ?b; ?a ≤ ?b⟧ ⟹ ?a < ?b›*) real_0 (*‹real_of 0 = 0›*))
qed
end
subsection‹Matrices and inner product›
locale matrix =
COLS?: vec_real_inner "λx y. x * cnj y" inner_cols
+ ROWS?: vec_real_inner "λx y. x * cnj y" inner_rows
for inner_cols :: "'a^'cols::{finite, wellorder} ⇒ 'a^'cols::{finite, wellorder} ⇒ 'a::{field, cnj, real_of_extended}"
and inner_rows :: "'a^'rows::{finite, wellorder} ⇒ 'a^'rows::{finite, wellorder} ⇒ 'a"
begin
lemma dot_lmul_matrix: "inner_rows (x v* A) y = inner_cols x ((χ i j. cnj (A $ i $ j)) *v y)"
apply (simp add: COLS.inner_vec_def (*‹inner_cols ?x ?y = (∑i∈UNIV. ?x $ i * cnj_class.cnj (?y $ i))›*) ROWS.inner_vec_def (*‹inner_rows ?x ?y = (∑i∈UNIV. ?x $ i * cnj_class.cnj (?y $ i))›*) matrix_vector_mult_def (*‹?m *v ?x ≡ χi. ∑j∈UNIV. ?m $ i $ j * ?x $ j›*) vector_matrix_mult_def (*‹?v v* ?m ≡ χj. ∑i∈UNIV. ?m $ i $ j * ?v $ i›*) sum_distrib_right (*‹sum ?f ?A * ?r = (∑n∈?A. ?f n * ?r)›*) cnj_sum (*‹cnj_class.cnj (sum ?f ?A) = (∑xa∈?A. cnj_class.cnj (?f xa))›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 43 facts*))
(*goal: ‹inner_rows (x v* A) y = inner_cols x ((χi j. cnj_class.cnj (A $ i $ j)) *v y)›*)
proof (unfold sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*), subst sum.swap (*‹(∑i∈?A. sum (?g i) ?B) = (∑j∈?B. ∑i∈?A. ?g i j)›*), rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*), simp)
(*goal: ‹⋀xa. xa ∈ UNIV ⟹ (∑i∈UNIV. cnj_class.cnj (y $ i) * (x $ xa * A $ xa $ i)) = (∑n∈UNIV. x $ xa * cnj_class.cnj (y $ n * cnj_class.cnj (A $ xa $ n)))›*)
fix xa :: 'cols
show "(∑i∈UNIV. cnj (y $ i) * (x $ xa * A $ xa $ i))
= (∑n∈UNIV. x $ xa * cnj (y $ n * cnj (A $ xa $ n)))"
proof (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*), simp)
(*goal: ‹⋀xb. xb ∈ UNIV ⟹ cnj_class.cnj (y $ xb) * (x $ xa * A $ xa $ xb) = x $ xa * cnj_class.cnj (y $ xb * cnj_class.cnj (A $ xa $ xb))›*)
fix xb :: 'rows
show "cnj_class.cnj (y $ xb) * (x $ xa * A $ xa $ xb)
= x $ xa * cnj_class.cnj (y $ xb * cnj_class.cnj (A $ xa $ xb))"
unfolding cnj_mult cnj_idem
(*goal: ‹cnj_class.cnj (y $ xb) * (x $ xa * A $ xa $ xb) = x $ xa * (cnj_class.cnj (y $ xb) * A $ xa $ xb)›*)
unfolding mult.assoc
(*goal: ‹cnj_class.cnj (y $ xb) * (x $ xa * A $ xa $ xb) = x $ xa * (cnj_class.cnj (y $ xb) * A $ xa $ xb)›*)
unfolding mult.commute[of "A $ xa $ xb"]
(*goal: ‹cnj_class.cnj (y $ xb) * (x $ xa * A $ xa $ xb) = x $ xa * (cnj_class.cnj (y $ xb) * A $ xa $ xb)›*)
by auto
qed
qed
end
subsection‹Orthogonal complement generalized›
context inner_product_space
begin
definition "orthogonal_complement W = {x. ∀y ∈ W. orthogonal y x}"
lemma subspace_orthogonal_complement: "subspace (orthogonal_complement W)"
unfolding subspace_def orthogonal_complement_def
(*goal: ‹0 ∈ {x. ∀y∈W. orthogonal y x} ∧ (∀x∈{x. ∀y∈W. orthogonal y x}. ∀y∈{x. ∀y∈W. orthogonal y x}. x + y ∈ {x. ∀y∈W. orthogonal y x}) ∧ (∀c. ∀x∈{x. ∀y∈W. orthogonal y x}. scale c x ∈ {x. ∀y∈W. orthogonal y x})›*)
by (auto simp add: orthogonal_def (*‹orthogonal ?x ?y = (inner ?x ?y = 0)›*) local.inner_right_distrib (*‹inner ?x (?y + ?z) = inner ?x ?y + inner ?x ?z›*))
lemma orthogonal_complement_mono:
assumes A_in_B: "A ⊆ B"
shows "orthogonal_complement B ⊆ orthogonal_complement A"
proof (standard)
(*goal: ‹⋀x. x ∈ orthogonal_complement B ⟹ x ∈ orthogonal_complement A›*)
fix x
assume x: "x ∈ orthogonal_complement B" (*‹(x::'b) ∈ orthogonal_complement (B::'b set)›*)
show "x ∈ orthogonal_complement A"
using x (*‹(x::'b) ∈ orthogonal_complement (B::'b set)›*) unfolding orthogonal_complement_def
(*goal: ‹x ∈ {x. ∀y∈A. orthogonal y x}›*)
apply (simp add: orthogonal_def (*‹orthogonal ?x ?y = (inner ?x ?y = 0)›*))
(*goal: ‹x ∈ {x. ∀y∈A. orthogonal y x}›*)
by (metis A_in_B (*‹A ⊆ B›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*))
qed
lemma B_in_orthogonal_complement_of_orthogonal_complement:
shows "B ⊆ orthogonal_complement (orthogonal_complement B)"
by (auto simp add: orthogonal_complement_def (*‹orthogonal_complement (?W::'b::ab_group_add set) = {x::'b::ab_group_add. ∀y::'b::ab_group_add∈?W. orthogonal y x}›*) orthogonal_def (*‹orthogonal (?x::'b::ab_group_add) (?y::'b::ab_group_add) = ((inner::'b::ab_group_add ⇒ 'b::ab_group_add ⇒ 'a::real_of_extended) ?x ?y = (0::'a::real_of_extended))›*) inner_commute_zero (*‹((inner::'b::ab_group_add ⇒ 'b::ab_group_add ⇒ 'a::real_of_extended) (?xa::'b::ab_group_add) (?x::'b::ab_group_add) = (0::'a::real_of_extended)) = (inner ?x ?xa = (0::'a::real_of_extended))›*))
end
subsection‹Generalizing projections›
context inner_product_space
begin
text‹Projection of two vectors: v onto u›
definition "proj v u = scale (inner v u / inner u u) u"
text‹Projection of a onto S›
definition "proj_onto a S = (sum (λx. proj a x) S)"
lemma vector_sub_project_orthogonal_proj:
shows "inner b (x - proj x b) = 0"
using vector_sub_project_orthogonal (*‹inner ?b (?x - scale (inner ?x ?b / inner ?b ?b) ?b) = 0›*) unfolding proj_def
(*goal: ‹inner b (x - scale (inner x b / inner b b) b) = 0›*)
by simp
lemma orthogonal_proj_set:
assumes yC: "y∈C" and C: "finite C" and p: "pairwise orthogonal C"
shows "orthogonal (a - proj_onto a C) y"
proof (-)
(*goal: ‹orthogonal (a - proj_onto a C) y›*)
have Cy: "C = insert y (C - {y})"
using yC (*‹y ∈ C›*) by blast
have fth: "finite (C - {y})"
using C (*‹finite C›*) by simp
show "orthogonal (a - proj_onto a C) y"
unfolding orthogonal_def
(*goal: ‹inner (a - proj_onto a C) y = 0›*)
unfolding proj_onto_def
(*goal: ‹inner (a - sum (proj a) C) y = 0›*)
unfolding proj_def[abs_def]
(*goal: ‹(inner::'b ⇒ 'b ⇒ 'a) ((a::'b) - (∑u::'b∈(C::'b set). (scale::'a ⇒ 'b ⇒ 'b) (inner a u / inner u u) u)) (y::'b) = (0::'a)›*)
unfolding inner_diff
(*goal: ‹inner a y - inner (∑u∈C. scale (inner a u / inner u u) u) y = 0›*)
unfolding inner_sum_left
(*goal: ‹(inner::'b::ab_group_add ⇒ 'b::ab_group_add ⇒ 'a::real_of_extended) (a::'b::ab_group_add) (y::'b::ab_group_add) - (∑x::'b::ab_group_add∈(C::'b::ab_group_add set). inner ((scale::'a::real_of_extended ⇒ 'b::ab_group_add ⇒ 'b::ab_group_add) (inner a x / inner x x) x) y) = (0::'a::real_of_extended)›*)
unfolding right_minus_eq
(*goal: ‹(inner::'b ⇒ 'b ⇒ 'a) (a::'b) (y::'b) = (∑x::'b∈(C::'b set). inner ((scale::'a ⇒ 'b ⇒ 'b) (inner a x / inner x x) x) y)›*)
unfolding sum.remove[OF C yC]
(*goal: ‹inner a y = inner (scale (inner a y / inner y y) y) y + (∑x∈C - {y}. inner (scale (inner a x / inner x x) x) y)›*)
apply (clarsimp simp add: inner_commute[of y a] (*‹(inner::'b ⇒ 'b ⇒ 'a) (y::'b) (a::'b) = cnj_class.cnj (inner a y)›*))
(*goal: ‹(inner::'b ⇒ 'b ⇒ 'a) (a::'b) (y::'b) = inner ((scale::'a ⇒ 'b ⇒ 'b) (inner a y / inner y y) y) y + (∑x::'b∈(C::'b set) - {y}. inner (scale (inner a x / inner x x) x) y)›*)
apply (rule sum.neutral (*‹∀x∈?A. ?g x = 0 ⟹ sum ?g ?A = 0›*))
(*goal: ‹y ≠ 0 ⟹ (∑x∈C - {y}. inner a x * inner x y / inner x x) = 0›*)
apply clarsimp
(*goal: ‹y ≠ 0 ⟹ ∀x∈C - {y}. inner a x * inner x y / inner x x = 0›*)
apply (rule p[unfolded pairwise_def orthogonal_def, rule_format] (*‹⟦?x ∈ C; ?y ∈ C; ?x ≠ ?y⟧ ⟹ inner ?x ?y = 0›*))
(*goal: ‹⋀x. ⟦y ≠ 0; x ∈ C; x ≠ y; inner a x ≠ 0; x ≠ 0⟧ ⟹ inner x y = 0›*)
using yC (*‹y ∈ C›*) apply -
(*goals:
1. ‹⋀x. ⟦y ≠ 0; x ∈ C; x ≠ y; inner a x ≠ 0; x ≠ 0; y ∈ C⟧ ⟹ x ∈ C›
2. ‹⋀x. ⟦y ≠ 0; x ∈ C; x ≠ y; inner a x ≠ 0; x ≠ 0; y ∈ C⟧ ⟹ y ∈ C›
3. ‹⋀x. ⟦y ≠ 0; x ∈ C; x ≠ y; inner a x ≠ 0; x ≠ 0; y ∈ C⟧ ⟹ x ≠ y›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
qed
lemma pairwise_orthogonal_proj_set:
assumes C: "finite C" and p: "pairwise orthogonal C"
shows "pairwise orthogonal (insert (a - proj_onto a C) C)"
apply (rule pairwise_orthogonal_insert[OF p] (*‹(⋀y. y ∈ C ⟹ orthogonal ?x y) ⟹ pairwise orthogonal (insert ?x C)›*))
(*goal: ‹pairwise orthogonal (insert ((a::'b) - proj_onto a (C::'b set)) C)›*)
by (auto simp add: orthogonal_proj_set (*‹⟦?y ∈ ?C; finite ?C; pairwise orthogonal ?C⟧ ⟹ orthogonal (?a - proj_onto ?a ?C) ?y›*) C (*‹finite C›*) p (*‹pairwise orthogonal C›*))
end
lemma orthogonal_real_eq: "RV_inner.orthogonal = real_inner_class.orthogonal"
unfolding RV_inner.orthogonal_def[abs_def]
(*goal: ‹(λx y. x ∙ y = 0) = real_inner_class.orthogonal›*)
unfolding real_inner_class.orthogonal_def[abs_def]
(*goal: ‹(λx y. x ∙ y = 0) = (λx y. x ∙ y = 0)›*)
by standard
subsection‹Second Part of the Fundamental Theorem of Linear Algebra generalized›
context matrix
begin
lemma cnj_cnj_matrix[simp]: "(χ i j. cnj ((χ i j. cnj (A $ i $ j)) $ i $ j)) = A"
unfolding vec_eq_iff
(*goal: ‹∀i ia. (χi j. cnj_class.cnj ((χi j. cnj_class.cnj (A $ i $ j)) $ i $ j)) $ i $ ia = A $ i $ ia›*)
by auto
lemma cnj_transpose[simp]: "(χ i j. cnj (transpose A $ i $ j)) = transpose (χ i j. cnj (A $ i $ j))"
unfolding vec_eq_iff transpose_def
(*goal: ‹∀i ia. (χi j. cnj_class.cnj ((χi j. A $ j $ i) $ i $ j)) $ i $ ia = (χi j. (χi j. cnj_class.cnj (A $ i $ j)) $ j $ i) $ i $ ia›*)
by auto
lemma null_space_orthogonal_complement_row_space:
fixes A::"'a^'cols::{finite, wellorder}^'rows::{finite, wellorder}"
shows "null_space A = COLS.v.orthogonal_complement (row_space (χ i j. cnj (A $ i $ j)))"
proof (-)
(*goal: ‹null_space (A::(('a::real_of_extended, 'cols::{finite,wellorder}) vec, 'rows::{finite,wellorder}) vec) = COLS.v.orthogonal_complement (row_space (χ(i::'rows::{finite,wellorder}) j::'cols::{finite,wellorder}. cnj_class.cnj (A $ i $ j)))›*)
interpret m: matrix inner_rows inner_cols
by unfold_locales
let ?A = "(χ i j. cnj (A $ i $ j))"
show "?thesis"
(*goal: ‹null_space A = COLS.v.orthogonal_complement (row_space (χi j. cnj_class.cnj (A $ i $ j)))›*)
proof (unfold null_space_def (*‹null_space (?A::((?'a, ?'n) vec, ?'m) vec) = {x::(?'a, ?'n) vec. ?A *v x = (0::(?'a, ?'m) vec)}›*) COLS.v.orthogonal_complement_def (*‹COLS.v.orthogonal_complement (?W::('a, 'cols) vec set) = {x::('a, 'cols) vec. ∀y::('a, 'cols) vec∈?W. COLS.v.orthogonal y x}›*), auto)
(*goals:
1. ‹⋀x y. ⟦A *v x = 0; y ∈ row_space (χi j. cnj_class.cnj (A $ i $ j))⟧ ⟹ COLS.v.orthogonal y x›
2. ‹⋀x. ∀y∈row_space (χi j. cnj_class.cnj (A $ i $ j)). COLS.v.orthogonal y x ⟹ A *v x = 0›*)
fix x and xa
assume Ax: "A *v x = 0" and xa: "xa ∈ row_space (χ i j. cnj (A $ i $ j))" (*‹(A::(('a, 'cols) vec, 'rows) vec) *v (x::('a, 'cols) vec) = (0::('a, 'rows) vec)› ‹(xa::('a, 'cols) vec) ∈ row_space (χ(i::'rows) j::'cols. cnj_class.cnj ((A::(('a, 'cols) vec, 'rows) vec) $ i $ j))›*)
obtain y where y: "xa = transpose (χ i j. cnj (A $ i $ j)) *v y"
(*goal: ‹(⋀y. xa = Finite_Cartesian_Product.transpose (χi j. cnj_class.cnj (A $ i $ j)) *v y ⟹ thesis) ⟹ thesis›*)
using xa (*‹xa ∈ row_space (χi j. cnj_class.cnj (A $ i $ j))›*) unfolding row_space_eq
(*goal: ‹(⋀y. xa = Finite_Cartesian_Product.transpose (χi j. cnj_class.cnj (A $ i $ j)) *v y ⟹ thesis) ⟹ thesis›*)
by blast
have y2: "y v* (χ i j. cnj (A $ i $ j)) = xa"
using transpose_vector (*‹?x v* ?A = Finite_Cartesian_Product.transpose ?A *v ?x›*) y (*‹(xa::('a, 'cols) vec) = Finite_Cartesian_Product.transpose (χ(i::'rows) j::'cols. cnj_class.cnj ((A::(('a, 'cols) vec, 'rows) vec) $ i $ j)) *v (y::('a, 'rows) vec)›*) by fastforce
show "COLS.v.orthogonal xa x"
using m.dot_lmul_matrix[of y ?A x] (*‹inner_cols (y v* (χi j. cnj_class.cnj (A $ i $ j))) x = inner_rows y ((χi j. cnj_class.cnj ((χi j. cnj_class.cnj (A $ i $ j)) $ i $ j)) *v x)›*) unfolding cnj_cnj_matrix Ax ROWS.v.inner_zero_right
(*goal: ‹COLS.v.orthogonal xa x›*)
unfolding y2
(*goal: ‹COLS.v.orthogonal (xa::('a, 'cols) vec) (x::('a, 'cols) vec)›*)
unfolding COLS.v.orthogonal_def
(*goal: ‹inner_cols xa x = 0›*) .
next
(*goal: ‹⋀x::('a, 'cols) vec. ∀y::('a, 'cols) vec∈row_space (χ(i::'rows) j::'cols. cnj_class.cnj ((A::(('a, 'cols) vec, 'rows) vec) $ i $ j)). COLS.v.orthogonal y x ⟹ A *v x = (0::('a, 'rows) vec)›*)
fix x
assume xa: "∀xa∈row_space (χ i j. cnj (A $ i $ j)). COLS.v.orthogonal xa x" (*‹∀xa::('a, 'cols) vec∈row_space (χ(i::'rows) j::'cols. cnj_class.cnj ((A::(('a, 'cols) vec, 'rows) vec) $ i $ j)). COLS.v.orthogonal xa (x::('a, 'cols) vec)›*)
show "A *v x = 0"
using xa (*‹∀xa∈row_space (χi j. cnj_class.cnj (A $ i $ j)). COLS.v.orthogonal xa x›*) unfolding row_space_eq COLS.v.orthogonal_def
(*goal: ‹A *v x = 0›*)
using COLS.v.inner_eq_zero_iff (*‹(inner_cols ?x ?x = 0) = (?x = 0)›*) using m.dot_lmul_matrix[of _ ?A] (*‹inner_cols (?x v* (χi j. cnj_class.cnj (A $ i $ j))) ?y = inner_rows ?x ((χi j. cnj_class.cnj ((χi j. cnj_class.cnj (A $ i $ j)) $ i $ j)) *v ?y)›*) unfolding transpose_vector
(*goal: ‹A *v x = 0›*)
apply auto
(*goal: ‹(A::(('a, 'cols) vec, 'rows) vec) *v (x::('a, 'cols) vec) = (0::('a, 'rows) vec)›*)
by (metis ROWS.i4 (*‹(inner_rows::('a, 'rows) vec ⇒ ('a, 'rows) vec ⇒ 'a) (?x::('a, 'rows) vec) ?x = (0::'a) ⟹ ?x = (0::('a, 'rows) vec)›*) m.cnj_cnj_matrix (*‹(χ(i::?'d) j::?'c. cnj_class.cnj ((χ(i::?'d) j::?'c. cnj_class.cnj ((?A::((?'b, ?'c) vec, ?'d) vec) $ i $ j)) $ i $ j)) = ?A›*) m.dot_lmul_matrix (*‹(inner_cols::('a, 'cols) vec ⇒ ('a, 'cols) vec ⇒ 'a) ((?x::('a, 'rows) vec) v* (?A::(('a, 'cols) vec, 'rows) vec)) (?y::('a, 'cols) vec) = (inner_rows::('a, 'rows) vec ⇒ ('a, 'rows) vec ⇒ 'a) ?x ((χ(i::'rows) j::'cols. cnj_class.cnj (?A $ i $ j)) *v ?y)›*) transpose_vector (*‹(?x::(?'a, ?'c) vec) v* (?A::((?'a, ?'b) vec, ?'c) vec) = Finite_Cartesian_Product.transpose ?A *v ?x›*))
qed
qed
lemma left_null_space_orthogonal_complement_col_space:
fixes A::"'a^'cols::{finite, wellorder}^'rows::{finite, wellorder}"
shows "left_null_space A = ROWS.v.orthogonal_complement (col_space (χ i j. cnj (A $ i $ j)))"
proof (-)
(*goal: ‹left_null_space A = ROWS.v.orthogonal_complement (col_space (χi j. cnj_class.cnj (A $ i $ j)))›*)
interpret m: matrix inner_rows inner_cols
by unfold_locales
show "?thesis"
(*goal: ‹left_null_space A = ROWS.v.orthogonal_complement (col_space (χi j. cnj_class.cnj (A $ i $ j)))›*)
using m.null_space_orthogonal_complement_row_space[of "transpose A"] (*‹null_space (Finite_Cartesian_Product.transpose A) = ROWS.v.orthogonal_complement (row_space (χi j. cnj_class.cnj (Finite_Cartesian_Product.transpose A $ i $ j)))›*) unfolding left_null_space_eq_null_space_transpose
(*goal: ‹null_space (Finite_Cartesian_Product.transpose A) = ROWS.v.orthogonal_complement (col_space (χi j. cnj_class.cnj (A $ i $ j)))›*)
unfolding col_space_eq_row_space_transpose
(*goal: ‹null_space (Finite_Cartesian_Product.transpose A) = ROWS.v.orthogonal_complement (row_space (Finite_Cartesian_Product.transpose (χi j. cnj_class.cnj (A $ i $ j))))›*)
by auto
qed
end
text‹We can get the explicit results for complex and real matrices›
interpretation real_matrix: matrix "λx y::real^'cols::{finite,wellorder}.
sum (λi. (x$i) * (y$i)) UNIV" "λx y. sum (λi. (x$i) * (y$i)) UNIV"
apply (unfold_locales, auto simp add: cnj_real_def (*‹cnj_class.cnj = id›*) real_of_real_def (*‹real_of = id›*) distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*))
(*goal: ‹Generalizations2.matrix (λx y. ∑i∈UNIV. x $ i * y $ i) (λx y. ∑i∈UNIV. x $ i * y $ i)›*)
using not_real_square_gt_zero (*‹(¬ 0 < ?x * ?x) = (?x = 0)›*) by blast
interpretation complex_matrix: matrix "λx y::complex^'cols::{finite,wellorder}.
sum (λi. (x$i) * cnj (y$i)) UNIV" "λx y. sum (λi. (x$i) * cnj (y$i)) UNIV"
apply unfold_locales
(*goals:
1. ‹⋀x y. (∑i∈UNIV. x $ i * cnj_class.cnj (y $ i)) = (∑i∈UNIV. x $ i * cnj_class.cnj (y $ i))›
2. ‹⋀x y. (∑i∈UNIV. x $ i * cnj_class.cnj (y $ i)) = (∑i∈UNIV. x $ i * cnj_class.cnj (y $ i))›
discuss goal 1*)
apply ((auto simp add: distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*))[1])
(*discuss goal 2*)
apply ((auto simp add: distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*))[1])
(*proven 2 subgoals*) .
lemma null_space_orthogonal_complement_row_space_complex:
fixes A::"complex^'cols::{finite,wellorder}^'rows::{finite,wellorder}"
shows "null_space A = complex_matrix.orthogonal_complement (row_space (χ i j. cnj (A $ i $ j)))"
using complex_matrix.null_space_orthogonal_complement_row_space (*‹null_space (?A::((complex, ?'cols) vec, ?'a) vec) = complex_matrix.orthogonal_complement (row_space (χ(i::?'a) j::?'cols. cnj_class.cnj (?A $ i $ j)))›*) .
lemma left_null_space_orthogonal_complement_col_space_complex:
fixes A::"complex^'cols::{finite, wellorder}^'rows::{finite, wellorder}"
shows "left_null_space A = complex_matrix.orthogonal_complement (col_space (χ i j. cnj (A $ i $ j)))"
using complex_matrix.left_null_space_orthogonal_complement_col_space (*‹left_null_space ?A = complex_matrix.orthogonal_complement (col_space (χi j. cnj_class.cnj (?A $ i $ j)))›*) .
lemma null_space_orthogonal_complement_row_space_reals:
fixes A::"real^'cols::{finite,wellorder}^'rows::{finite,wellorder}"
shows "null_space A = real_matrix.orthogonal_complement (row_space A)"
using real_matrix.null_space_orthogonal_complement_row_space[of A] (*‹null_space A = real_matrix.v.orthogonal_complement (row_space (χi j. cnj_class.cnj (A $ i $ j)))›*) unfolding cnj_real_def
(*goal: ‹null_space (A::((real, 'cols::{finite,wellorder}) vec, 'rows::{finite,wellorder}) vec) = real_matrix.v.orthogonal_complement (row_space A)›*)
by (simp add: vec_lambda_eta (*‹(χi. ?g $ i) = ?g›*))
lemma left_null_space_orthogonal_complement_col_space_real:
fixes A::"real^'cols::{finite, wellorder}^'rows::{finite, wellorder}"
shows "left_null_space A = real_matrix.orthogonal_complement (col_space A)"
using real_matrix.left_null_space_orthogonal_complement_col_space[of A] (*‹left_null_space A = real_matrix.v.orthogonal_complement (col_space (χi j. cnj_class.cnj (A $ i $ j)))›*) by (simp add: cnj_real_def (*‹cnj_class.cnj = id›*) vec_lambda_eta (*‹(χi::?'b::finite. (?g::(?'a::type, ?'b::finite) vec) $ i) = ?g›*))
end
| {
"path": "afp-2025-02-12/thys/QR_Decomposition/Generalizations2.thy",
"repo": "afp-2025-02-12",
"sha": "ad756ac6c1e9ca077f4d8f627b13b43cf57d2d4043068c9bf20400efa4eed625"
} |
(* Title: Infinite Matrix Model of Kleene Algebra
Author: Alasdair Armstrong, Georg Struth, Tjark Weber
Maintainer: Georg Struth <g.struth at sheffield.ac.uk>
Tjark Weber <tjark.weber at it.uu.se>
*)
section ‹Infinite Matrices›
theory Inf_Matrix
imports Finite_Suprema
begin
text ‹Matrices are functions from two index sets into some suitable
algebra. We consider arbitrary index sets, not necessarily the
positive natural numbers up to some bounds; our coefficient algebra is
a dioid. Our only restriction is that summation in the product of
matrices is over a finite index set. This follows essentially Droste
and Kuich's introductory article in the Handbook of Weighted Automata~\<^cite>‹"weightedautomata09"›.
Under these assumptions we show that dioids are closed under matrix
formation. Our proofs are similar to those for formal power series,
but simpler.›
type_synonym ('a, 'b, 'c) matrix = "'a ⇒ 'b ⇒ 'c"
definition mat_one :: "('a, 'a, 'c::dioid_one_zero) matrix" ("ε") where
"ε i j ≡ (if (i = j) then 1 else 0)"
definition mat_zero :: "('a, 'b, 'c::dioid_one_zero) matrix" ("δ") where
"δ ≡ λj i. 0"
definition mat_add :: "('a, 'b, 'c::dioid_one_zero) matrix ⇒ ('a, 'b, 'c) matrix ⇒ ('a, 'b, 'c) matrix" (infixl "⊕" 70) where
"(f ⊕ g) ≡ λi j. (f i j) + (g i j)"
lemma mat_add_assoc: "(f ⊕ g) ⊕ h = f ⊕ (g ⊕ h)"
by (auto simp add: mat_add_def (*‹?f ⊕ ?g ≡ λi j. ?f i j + ?g i j›*) join.sup_assoc (*‹?x + ?y + ?z = ?x + (?y + ?z)›*))
lemma mat_add_comm: "f ⊕ g = g ⊕ f"
sorry
lemma mat_add_idem[simp]: "f ⊕ f = f"
by (auto simp add: mat_add_def (*‹?f ⊕ ?g ≡ λi j. ?f i j + ?g i j›*))
lemma mat_zerol[simp]: "f ⊕ δ = f"
by (auto simp add: mat_add_def (*‹?f ⊕ ?g ≡ λi j. ?f i j + ?g i j›*) mat_zero_def (*‹δ ≡ λj i. 0›*))
lemma mat_zeror[simp]: "δ ⊕ f = f"
by (auto simp add: mat_add_def (*‹?f ⊕ ?g ≡ λi j. ?f i j + ?g i j›*) mat_zero_def (*‹δ ≡ λj i. 0›*))
definition mat_mult :: "('a, 'k::finite, 'c::dioid_one_zero) matrix ⇒ ('k, 'b, 'c) matrix ⇒ ('a, 'b, 'c) matrix" (infixl "⊗" 60) where
"(f ⊗ g) i j ≡ ∑ {(f i k) ⋅ (g k j) | k. k ∈ UNIV}"
lemma mat_annil[simp]: "δ ⊗ f = δ"
apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*))
(*goal: ‹δ ⊗ f = δ›*)
by (auto simp add: mat_mult_def (*‹(?f ⊗ ?g) ?i ?j ≡ ∑ {?f ?i k ⋅ ?g k ?j |k. k ∈ UNIV}›*) mat_zero_def (*‹δ ≡ λj i. 0›*))
lemma mat_annir[simp]: "f ⊗ δ = δ"
apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*))
(*goal: ‹f ⊗ δ = δ›*)
by (auto simp add: mat_mult_def (*‹(?f ⊗ ?g) ?i ?j ≡ ∑ {?f ?i k ⋅ ?g k ?j |k. k ∈ UNIV}›*) mat_zero_def (*‹δ ≡ λj i. 0›*))
lemma mat_distl: "f ⊗ (g ⊕ h) = (f ⊗ g) ⊕ (f ⊗ h)"
proof (-)
(*goal: ‹f ⊗ g ⊕ h = (f ⊗ g) ⊕ (f ⊗ h)›*)
{
fix i and j
have "(f ⊗ (g ⊕ h)) i j = ∑{f i k ⋅ (g k j + h k j) |k. k ∈ UNIV}"
by (simp only: mat_mult_def (*‹(?f ⊗ ?g) ?i ?j ≡ ∑ {?f ?i k ⋅ ?g k ?j |k. k ∈ UNIV}›*) mat_add_def (*‹?f ⊕ ?g ≡ λi j. ?f i j + ?g i j›*))
also (*calculation: ‹((f::'a::type ⇒ 'd::finite ⇒ 'c::dioid_one_zero) ⊗ (g::'d::finite ⇒ 'b::type ⇒ 'c::dioid_one_zero) ⊕ (h::'d::finite ⇒ 'b::type ⇒ 'c::dioid_one_zero)) (i::'a::type) (j::'b::type) = ∑ {f i k ⋅ (g k j + h k j) |k::'d::finite. k ∈ UNIV}›*) have "... = ∑{f i k ⋅ g k j + f i k ⋅ h k j |k. k ∈ UNIV}"
by (simp only: distrib_left (*‹?a ⋅ (?b + ?c) = ?a ⋅ ?b + ?a ⋅ ?c›*))
also (*calculation: ‹(f ⊗ g ⊕ h) i j = ∑ {f i k ⋅ g k j + f i k ⋅ h k j |k. k ∈ UNIV}›*) have "... = ∑{f i k ⋅ g k j |k. k ∈ UNIV} + ∑{f i k ⋅ h k j |k. k ∈ UNIV}"
by (simp only: fset_to_im (*‹{(?f::?'b::type ⇒ ?'a::type) x |x::?'b::type. x ∈ (?X::?'b::type set)} = ?f ` ?X›*) sum_fun_sum (*‹finite (?A::?'a::type set) ⟹ ∑ ((λx::?'a::type. (?f::?'a::type ⇒ ?'b::join_semilattice_zero) x + (?g::?'a::type ⇒ ?'b::join_semilattice_zero) x) ` ?A) = ∑ (?f ` ?A) + ∑ (?g ` ?A)›*) finite_UNIV (*‹finite UNIV›*))
finally (*calculation: ‹(f ⊗ g ⊕ h) i j = ∑ {f i k ⋅ g k j |k. k ∈ UNIV} + ∑ {f i k ⋅ h k j |k. k ∈ UNIV}›*) have "(f ⊗ (g ⊕ h)) i j = ((f ⊗ g) ⊕ (f ⊗ h)) i j"
by (simp only: mat_mult_def (*‹(?f ⊗ ?g) ?i ?j ≡ ∑ {?f ?i k ⋅ ?g k ?j |k. k ∈ UNIV}›*) mat_add_def (*‹?f ⊕ ?g ≡ λi j. ?f i j + ?g i j›*))
}
thus "?thesis"
(*goal: ‹(f::'a ⇒ 'd ⇒ 'c) ⊗ (g::'d ⇒ 'b ⇒ 'c) ⊕ (h::'d ⇒ 'b ⇒ 'c) = (f ⊗ g) ⊕ (f ⊗ h)›*)
by auto
qed
lemma mat_distr: "(f ⊕ g) ⊗ h = (f ⊗ h) ⊕ (g ⊗ h)"
proof (-)
(*goal: ‹(f::'a ⇒ 'd ⇒ 'c) ⊕ (g::'a ⇒ 'd ⇒ 'c) ⊗ (h::'d ⇒ 'b ⇒ 'c) = (f ⊗ h) ⊕ (g ⊗ h)›*)
{
fix i and j
have "((f ⊕ g) ⊗ h) i j = ∑{(f i k + g i k) ⋅ h k j |k. k ∈ UNIV}"
by (simp only: mat_mult_def (*‹(?f ⊗ ?g) ?i ?j ≡ ∑ {?f ?i k ⋅ ?g k ?j |k. k ∈ UNIV}›*) mat_add_def (*‹?f ⊕ ?g ≡ λi j. ?f i j + ?g i j›*))
also (*calculation: ‹(f ⊕ g ⊗ h) i j = ∑ {(f i k + g i k) ⋅ h k j |k. k ∈ UNIV}›*) have "... = ∑{f i k ⋅ h k j + g i k ⋅ h k j |k. k ∈ UNIV}"
by (simp only: distrib_right (*‹(?a + ?b) ⋅ ?c = ?a ⋅ ?c + ?b ⋅ ?c›*))
also (*calculation: ‹(f ⊕ g ⊗ h) i j = ∑ {f i k ⋅ h k j + g i k ⋅ h k j |k. k ∈ UNIV}›*) have "... = ∑{f i k ⋅ h k j |k. k ∈ UNIV} + ∑{g i k ⋅ h k j |k. k ∈ UNIV}"
by (simp only: fset_to_im (*‹{?f x |x. x ∈ ?X} = ?f ` ?X›*) sum_fun_sum (*‹finite ?A ⟹ ∑ ((λx. ?f x + ?g x) ` ?A) = ∑ (?f ` ?A) + ∑ (?g ` ?A)›*) finite_UNIV (*‹finite UNIV›*))
finally (*calculation: ‹(f ⊕ g ⊗ h) i j = ∑ {f i k ⋅ h k j |k. k ∈ UNIV} + ∑ {g i k ⋅ h k j |k. k ∈ UNIV}›*) have "((f ⊕ g) ⊗ h) i j = ((f ⊗ h) ⊕ (g ⊗ h)) i j"
by (simp only: mat_mult_def (*‹(?f ⊗ ?g) ?i ?j ≡ ∑ {?f ?i k ⋅ ?g k ?j |k. k ∈ UNIV}›*) mat_add_def (*‹?f ⊕ ?g ≡ λi j. ?f i j + ?g i j›*))
}
thus "?thesis"
(*goal: ‹f ⊕ g ⊗ h = (f ⊗ h) ⊕ (g ⊗ h)›*)
by auto
qed
lemma logic_aux1: "(∃k. (i = k ⟶ x = f i j) ∧ (i ≠ k ⟶ x = 0)) ⟷ (∃k. i = k ∧ x = f i j) ∨ (∃k. i ≠ k ∧ x = 0)"
by blast
lemma logic_aux2: "(∃k. (k = j ⟶ x = f i j) ∧ (k ≠ j ⟶ x = 0)) ⟷ (∃k. k = j ∧ x = f i j) ∨ (∃k. k ≠ j ∧ x = 0)"
by blast
lemma mat_onel[simp]: "ε ⊗ f = f"
proof (-)
(*goal: ‹ε ⊗ f = f›*)
{
fix i and j
have "(ε ⊗ f) i j = ∑{x. (∃k. (i = k ⟶ x = f i j) ∧ (i ≠ k ⟶ x = 0))}"
by (auto simp add: mat_mult_def (*‹(?f ⊗ ?g) ?i ?j ≡ ∑ {?f ?i k ⋅ ?g k ?j |k. k ∈ UNIV}›*) mat_one_def (*‹ε ?i ?j ≡ if ?i = ?j then 1 else 0›*))
also (*calculation: ‹(ε ⊗ f) i j = ∑ {x. ∃k. (i = k ⟶ x = f i j) ∧ (i ≠ k ⟶ x = 0)}›*) have "... = ∑({x. ∃k. (i = k ∧ x = f i j)} ∪ {x. ∃k. (i ≠ k ∧ x = 0)})"
by (simp only: Collect_disj_eq (*‹{x. ?P x ∨ ?Q x} = {x. ?P x} ∪ {x. ?Q x}›*) logic_aux1 (*‹(∃k. (?i = k ⟶ ?x = ?f ?i ?j) ∧ (?i ≠ k ⟶ ?x = 0)) = ((∃k. ?i = k ∧ ?x = ?f ?i ?j) ∨ (∃k. ?i ≠ k ∧ ?x = 0))›*))
also (*calculation: ‹(ε ⊗ f) i j = ∑ ({x. ∃k. i = k ∧ x = f i j} ∪ {x. ∃k. i ≠ k ∧ x = 0})›*) have "... = ∑{x. ∃k. (i = k ∧ x = f i j)} + ∑{x. ∃k. (i ≠ k ∧ x = 0)}"
apply (rule sum_union (*‹⟦finite ?A; finite ?B⟧ ⟹ ∑ (?A ∪ ?B) = ∑ ?A + ∑ ?B›*))
(*goals:
1. ‹finite {x. ∃k. i = k ∧ x = f i j}›
2. ‹finite {x. ∃k. i ≠ k ∧ x = 0}›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
finally (*calculation: ‹(ε ⊗ f) i j = ∑ {x. ∃k. i = k ∧ x = f i j} + ∑ {x. ∃k. i ≠ k ∧ x = 0}›*) have "(ε ⊗ f) i j = f i j"
by (auto simp add: sum.neutral (*‹∀x∈?A. ?g x = 0 ⟹ sum ?g ?A = 0›*))
}
thus "?thesis"
(*goal: ‹ε ⊗ f = f›*)
by auto
qed
lemma mat_oner[simp]: "f ⊗ ε = f"
proof (-)
(*goal: ‹(f::'a::type ⇒ 'b::finite ⇒ 'c::dioid_one_zero) ⊗ ε = f›*)
{
fix i and j
have "(f ⊗ ε) i j = ∑{x. (∃k. (k = j ⟶ x = f i j) ∧ (k ≠ j ⟶ x = 0))}"
by (auto simp add: mat_mult_def (*‹(?f ⊗ ?g) ?i ?j ≡ ∑ {?f ?i k ⋅ ?g k ?j |k. k ∈ UNIV}›*) mat_one_def (*‹ε ?i ?j ≡ if ?i = ?j then 1 else 0›*))
also (*calculation: ‹(f ⊗ ε) i j = ∑ {x. ∃k. (k = j ⟶ x = f i j) ∧ (k ≠ j ⟶ x = 0)}›*) have "... = ∑({x. ∃k. (k = j ∧ x = f i j)} ∪ {x. ∃k. (k ≠ j ∧ x = 0)})"
by (simp only: Collect_disj_eq (*‹{x. ?P x ∨ ?Q x} = {x. ?P x} ∪ {x. ?Q x}›*) logic_aux2 (*‹(∃k. (k = ?j ⟶ ?x = ?f ?i ?j) ∧ (k ≠ ?j ⟶ ?x = 0)) = ((∃k. k = ?j ∧ ?x = ?f ?i ?j) ∨ (∃k. k ≠ ?j ∧ ?x = 0))›*))
also (*calculation: ‹(f ⊗ ε) i j = ∑ ({x. ∃k. k = j ∧ x = f i j} ∪ {x. ∃k. k ≠ j ∧ x = 0})›*) have "... = ∑{x. ∃k. (k = j ∧ x = f i j)} + ∑{x. ∃k. (k ≠ j ∧ x = 0)}"
apply (rule sum_union (*‹⟦finite (?A::?'a::join_semilattice_zero set); finite (?B::?'a::join_semilattice_zero set)⟧ ⟹ ∑ (?A ∪ ?B) = ∑ ?A + ∑ ?B›*))
(*goals:
1. ‹finite {x. ∃k. k = j ∧ x = f i j}›
2. ‹finite {x. ∃k. k ≠ j ∧ x = 0}›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
finally (*calculation: ‹((f::'a::type ⇒ 'b::finite ⇒ 'c::dioid_one_zero) ⊗ ε) (i::'a::type) (j::'b::finite) = ∑ {x::'c::dioid_one_zero. ∃k::'b::finite. k = j ∧ x = f i j} + ∑ {x::'c::dioid_one_zero. ∃k::'b::finite. k ≠ j ∧ x = (0::'c::dioid_one_zero)}›*) have "(f ⊗ ε) i j = f i j"
by (auto simp add: sum.neutral (*‹∀x∈?A. ?g x = 0 ⟹ sum ?g ?A = 0›*))
}
thus "?thesis"
(*goal: ‹f ⊗ ε = f›*)
by auto
qed
lemma mat_rearrange:
fixes F :: "'a ⇒ 'k1 ⇒ 'k2 ⇒ 'b ⇒ 'c::dioid_one_zero"
assumes fUNk1: "finite (UNIV::'k1 set)"
assumes fUNk2: "finite (UNIV::'k2 set)"
shows "∑{∑{F i k1 k2 j |k2. k2 ∈ (UNIV::'k2 set)} |k1. k1 ∈ (UNIV::'k1 set)} = ∑{∑{F i k1 k2 j |k1. k1 ∈ UNIV} |k2. k2 ∈ UNIV}"
proof (-)
(*goal: ‹∑ {∑ {F i k1 k2 j |k2. k2 ∈ UNIV} |k1. k1 ∈ UNIV} = ∑ {∑ {F i k1 k2 j |k1. k1 ∈ UNIV} |k2. k2 ∈ UNIV}›*)
{
fix z :: 'c
let ?lhs = "∑{∑{F i k1 k2 j |k2. k2 ∈ UNIV} |k1. k1 ∈ UNIV}"
let ?rhs = "∑{∑{F i k1 k2 j |k1. k1 ∈ UNIV} |k2. k2 ∈ UNIV}"
have "?lhs ≤ z ⟷ (∀k1 k2. F i k1 k2 j ≤ z)"
apply (simp only: fset_to_im (*‹{?f x |x. x ∈ ?X} = ?f ` ?X›*) sum_fun_image_sup (*‹finite ?A ⟹ (∑ (?f ` ?A) ≤ ?z) = (∀a∈?A. ?f a ≤ ?z)›*) fUNk1 (*‹finite UNIV›*) fUNk2 (*‹finite UNIV›*))
(*goal: ‹(∑ {∑ {(F::'a ⇒ 'k1 ⇒ 'k2 ⇒ 'b ⇒ 'c) (i::'a) k1 k2 (j::'b) |k2::'k2. k2 ∈ UNIV} |k1::'k1. k1 ∈ UNIV} ≤ (z::'c)) = (∀(k1::'k1) k2::'k2. F i k1 k2 j ≤ z)›*)
by auto
hence "?lhs ≤ z ⟷ ?rhs ≤ z"
apply (simp only: fset_to_im (*‹{?f x |x. x ∈ ?X} = ?f ` ?X›*) sum_fun_image_sup (*‹finite ?A ⟹ (∑ (?f ` ?A) ≤ ?z) = (∀a∈?A. ?f a ≤ ?z)›*) fUNk1 (*‹finite UNIV›*) fUNk2 (*‹finite UNIV›*))
(*goal: ‹(∑ {∑ {F i k1 k2 j |k2. k2 ∈ UNIV} |k1. k1 ∈ UNIV} ≤ z) = (∑ {∑ {F i k1 k2 j |k1. k1 ∈ UNIV} |k2. k2 ∈ UNIV} ≤ z)›*)
by auto
}
thus "?thesis"
(*goal: ‹∑ {∑ {(F::'a ⇒ 'k1 ⇒ 'k2 ⇒ 'b ⇒ 'c) (i::'a) k1 k2 (j::'b) |k2::'k2. k2 ∈ UNIV} |k1::'k1. k1 ∈ UNIV} = ∑ {∑ {F i k1 k2 j |k1::'k1. k1 ∈ UNIV} |k2::'k2. k2 ∈ UNIV}›*)
by (simp add: eq_iff (*‹(?a = ?b) = (?a ≤ ?b ∧ ?b ≤ ?a)›*))
qed
lemma mat_mult_assoc: "f ⊗ (g ⊗ h) = (f ⊗ g) ⊗ h"
proof (-)
(*goal: ‹(f::'a ⇒ 'd ⇒ 'c) ⊗ ((g::'d ⇒ 'e ⇒ 'c) ⊗ (h::'e ⇒ 'b ⇒ 'c)) = f ⊗ g ⊗ h›*)
{
fix i and j
have "(f ⊗ (g ⊗ h)) i j = ∑{f i k1 ⋅ ∑{g k1 k2 ⋅ h k2 j |k2. k2 ∈ UNIV} |k1. k1 ∈ UNIV}"
by (simp only: mat_mult_def (*‹(?f ⊗ ?g) ?i ?j ≡ ∑ {?f ?i k ⋅ ?g k ?j |k. k ∈ UNIV}›*))
also (*calculation: ‹(f ⊗ (g ⊗ h)) i j = ∑ {f i k1 ⋅ ∑ {g k1 k2 ⋅ h k2 j |k2. k2 ∈ UNIV} |k1. k1 ∈ UNIV}›*) have "... = ∑{∑{f i k1 ⋅ g k1 k2 ⋅ h k2 j |k2. k2 ∈ UNIV} |k1. k1 ∈ UNIV}"
by (simp only: fset_to_im (*‹{(?f::?'b::type ⇒ ?'a::type) x |x::?'b::type. x ∈ (?X::?'b::type set)} = ?f ` ?X›*) sum_fun_distl (*‹finite (?Y::?'a::type set) ⟹ (?x::?'b::dioid_one_zero) ⋅ ∑ ((?f::?'a::type ⇒ ?'b::dioid_one_zero) ` ?Y) = ∑ {?x ⋅ ?f y |y::?'a::type. y ∈ ?Y}›*) finite_UNIV (*‹finite UNIV›*) mult.assoc (*‹(?a::?'a::semigroup_mult) ⋅ (?b::?'a::semigroup_mult) ⋅ (?c::?'a::semigroup_mult) = ?a ⋅ (?b ⋅ ?c)›*))
also (*calculation: ‹(f ⊗ (g ⊗ h)) i j = ∑ {∑ {f i k1 ⋅ g k1 k2 ⋅ h k2 j |k2. k2 ∈ UNIV} |k1. k1 ∈ UNIV}›*) have "... = ∑{∑{(f i k1 ⋅ g k1 k2) ⋅ h k2 j|k1. k1 ∈ UNIV} |k2. k2 ∈ UNIV}"
apply (rule mat_rearrange (*‹⟦finite UNIV; finite UNIV⟧ ⟹ ∑ {∑ {?F ?i k1 k2 ?j |k2. k2 ∈ UNIV} |k1. k1 ∈ UNIV} = ∑ {∑ {?F ?i k1 k2 ?j |k1. k1 ∈ UNIV} |k2. k2 ∈ UNIV}›*))
(*goals:
1. ‹finite UNIV›
2. ‹finite UNIV›
discuss goal 1*)
apply ((auto simp add: finite_UNIV (*‹finite UNIV›*))[1])
(*discuss goal 2*)
apply ((auto simp add: finite_UNIV (*‹finite UNIV›*))[1])
(*proven 2 subgoals*) .
also (*calculation: ‹(f ⊗ (g ⊗ h)) i j = ∑ {∑ {f i k1 ⋅ g k1 k2 ⋅ h k2 j |k1. k1 ∈ UNIV} |k2. k2 ∈ UNIV}›*) have "... = ∑{∑{f i k1 ⋅ g k1 k2 |k1. k1 ∈ UNIV} ⋅ h k2 j |k2. k2 ∈ UNIV}"
by (simp only: fset_to_im (*‹{(?f::?'b ⇒ ?'a) x |x::?'b. x ∈ (?X::?'b set)} = ?f ` ?X›*) sum_fun_distr (*‹finite (?X::?'a set) ⟹ ∑ ((?f::?'a ⇒ ?'b) ` ?X) ⋅ (?y::?'b) = ∑ {?f x ⋅ ?y |x::?'a. x ∈ ?X}›*) finite_UNIV (*‹finite UNIV›*))
finally (*calculation: ‹(f ⊗ (g ⊗ h)) i j = ∑ {∑ {f i k1 ⋅ g k1 k2 |k1. k1 ∈ UNIV} ⋅ h k2 j |k2. k2 ∈ UNIV}›*) have "(f ⊗ (g ⊗ h)) i j = ((f ⊗ g) ⊗ h) i j "
by (simp only: mat_mult_def (*‹((?f::?'a ⇒ ?'k ⇒ ?'c) ⊗ (?g::?'k ⇒ ?'b ⇒ ?'c)) (?i::?'a) (?j::?'b) ≡ ∑ {?f ?i k ⋅ ?g k ?j |k::?'k. k ∈ UNIV}›*))
}
thus "?thesis"
(*goal: ‹f ⊗ (g ⊗ h) = f ⊗ g ⊗ h›*)
by auto
qed
definition mat_less_eq :: "('a, 'b, 'c::dioid_one_zero) matrix ⇒ ('a, 'b, 'c) matrix ⇒ bool" where
"mat_less_eq f g = (f ⊕ g = g)"
definition mat_less :: "('a, 'b, 'c::dioid_one_zero) matrix ⇒ ('a, 'b, 'c) matrix ⇒ bool" where
"mat_less f g = (mat_less_eq f g ∧ f ≠ g)"
interpretation matrix_dioid: dioid_one_zero mat_add mat_mult mat_one mat_zero mat_less_eq mat_less
apply unfold_locales
(*goals:
1. ‹⋀a b c. a ⊕ b ⊕ c = a ⊕ (b ⊕ c)›
2. ‹⋀a b. a ⊕ b = b ⊕ a›
3. ‹⋀a b c. a ⊗ b ⊗ c = a ⊗ (b ⊗ c)›
4. ‹⋀x y z. x ⊕ y ⊗ z = (x ⊗ z) ⊕ (y ⊗ z)›
5. ‹⋀x. ε ⊗ x = x›
6. ‹⋀x. x ⊗ ε = x›
7. ‹⋀x. δ ⊕ x = x›
8. ‹⋀x. δ ⊗ x = δ›
9. ‹⋀x. x ⊗ δ = δ›
10. ‹⋀x y. mat_less_eq x y = (x ⊕ y = y)›
11. ‹⋀x y. mat_less x y = (mat_less_eq x y ∧ x ≠ y)›
12. ‹⋀x. x ⊕ x = x›
13. ‹⋀a b c. a ⊗ b ⊕ c = (a ⊗ b) ⊕ (a ⊗ c)›
discuss goal 1*)
apply (metis mat_add_assoc (*‹?f ⊕ ?g ⊕ ?h = ?f ⊕ (?g ⊕ ?h)›*) mat_add_comm (*‹?f ⊕ ?g = ?g ⊕ ?f›*) mat_mult_assoc[symmetric] (*‹?f ⊗ ?g ⊗ ?h = ?f ⊗ (?g ⊗ ?h)›*) mat_distr (*‹?f ⊕ ?g ⊗ ?h = (?f ⊗ ?h) ⊕ (?g ⊗ ?h)›*) mat_onel (*‹ε ⊗ ?f = ?f›*) mat_oner (*‹?f ⊗ ε = ?f›*) mat_zeror (*‹δ ⊕ ?f = ?f›*) mat_annil (*‹δ ⊗ ?f = δ›*) mat_annir (*‹?f ⊗ δ = δ›*) mat_less_eq_def (*‹mat_less_eq ?f ?g = (?f ⊕ ?g = ?g)›*) mat_less_def (*‹mat_less ?f ?g = (mat_less_eq ?f ?g ∧ ?f ≠ ?g)›*) mat_add_idem (*‹?f ⊕ ?f = ?f›*) mat_distl (*‹?f ⊗ ?g ⊕ ?h = (?f ⊗ ?g) ⊕ (?f ⊗ ?h)›*))
(*discuss goal 2*)
apply (metis mat_add_assoc (*‹?f ⊕ ?g ⊕ ?h = ?f ⊕ (?g ⊕ ?h)›*) mat_add_comm (*‹?f ⊕ ?g = ?g ⊕ ?f›*) mat_mult_assoc[symmetric] (*‹?f ⊗ ?g ⊗ ?h = ?f ⊗ (?g ⊗ ?h)›*) mat_distr (*‹?f ⊕ ?g ⊗ ?h = (?f ⊗ ?h) ⊕ (?g ⊗ ?h)›*) mat_onel (*‹ε ⊗ ?f = ?f›*) mat_oner (*‹?f ⊗ ε = ?f›*) mat_zeror (*‹δ ⊕ ?f = ?f›*) mat_annil (*‹δ ⊗ ?f = δ›*) mat_annir (*‹?f ⊗ δ = δ›*) mat_less_eq_def (*‹mat_less_eq ?f ?g = (?f ⊕ ?g = ?g)›*) mat_less_def (*‹mat_less ?f ?g = (mat_less_eq ?f ?g ∧ ?f ≠ ?g)›*) mat_add_idem (*‹?f ⊕ ?f = ?f›*) mat_distl (*‹?f ⊗ ?g ⊕ ?h = (?f ⊗ ?g) ⊕ (?f ⊗ ?h)›*))
(*discuss goal 3*)
apply (metis mat_add_assoc (*‹?f ⊕ ?g ⊕ ?h = ?f ⊕ (?g ⊕ ?h)›*) mat_add_comm (*‹?f ⊕ ?g = ?g ⊕ ?f›*) mat_mult_assoc[symmetric] (*‹?f ⊗ ?g ⊗ ?h = ?f ⊗ (?g ⊗ ?h)›*) mat_distr (*‹?f ⊕ ?g ⊗ ?h = (?f ⊗ ?h) ⊕ (?g ⊗ ?h)›*) mat_onel (*‹ε ⊗ ?f = ?f›*) mat_oner (*‹?f ⊗ ε = ?f›*) mat_zeror (*‹δ ⊕ ?f = ?f›*) mat_annil (*‹δ ⊗ ?f = δ›*) mat_annir (*‹?f ⊗ δ = δ›*) mat_less_eq_def (*‹mat_less_eq ?f ?g = (?f ⊕ ?g = ?g)›*) mat_less_def (*‹mat_less ?f ?g = (mat_less_eq ?f ?g ∧ ?f ≠ ?g)›*) mat_add_idem (*‹?f ⊕ ?f = ?f›*) mat_distl (*‹?f ⊗ ?g ⊕ ?h = (?f ⊗ ?g) ⊕ (?f ⊗ ?h)›*))
(*discuss goal 4*)
apply (metis mat_add_assoc (*‹?f ⊕ ?g ⊕ ?h = ?f ⊕ (?g ⊕ ?h)›*) mat_add_comm (*‹?f ⊕ ?g = ?g ⊕ ?f›*) mat_mult_assoc[symmetric] (*‹?f ⊗ ?g ⊗ ?h = ?f ⊗ (?g ⊗ ?h)›*) mat_distr (*‹?f ⊕ ?g ⊗ ?h = (?f ⊗ ?h) ⊕ (?g ⊗ ?h)›*) mat_onel (*‹ε ⊗ ?f = ?f›*) mat_oner (*‹?f ⊗ ε = ?f›*) mat_zeror (*‹δ ⊕ ?f = ?f›*) mat_annil (*‹δ ⊗ ?f = δ›*) mat_annir (*‹?f ⊗ δ = δ›*) mat_less_eq_def (*‹mat_less_eq ?f ?g = (?f ⊕ ?g = ?g)›*) mat_less_def (*‹mat_less ?f ?g = (mat_less_eq ?f ?g ∧ ?f ≠ ?g)›*) mat_add_idem (*‹?f ⊕ ?f = ?f›*) mat_distl (*‹?f ⊗ ?g ⊕ ?h = (?f ⊗ ?g) ⊕ (?f ⊗ ?h)›*))
(*discuss goal 5*)
apply (metis mat_add_assoc (*‹?f ⊕ ?g ⊕ ?h = ?f ⊕ (?g ⊕ ?h)›*) mat_add_comm (*‹?f ⊕ ?g = ?g ⊕ ?f›*) mat_mult_assoc[symmetric] (*‹?f ⊗ ?g ⊗ ?h = ?f ⊗ (?g ⊗ ?h)›*) mat_distr (*‹?f ⊕ ?g ⊗ ?h = (?f ⊗ ?h) ⊕ (?g ⊗ ?h)›*) mat_onel (*‹ε ⊗ ?f = ?f›*) mat_oner (*‹?f ⊗ ε = ?f›*) mat_zeror (*‹δ ⊕ ?f = ?f›*) mat_annil (*‹δ ⊗ ?f = δ›*) mat_annir (*‹?f ⊗ δ = δ›*) mat_less_eq_def (*‹mat_less_eq ?f ?g = (?f ⊕ ?g = ?g)›*) mat_less_def (*‹mat_less ?f ?g = (mat_less_eq ?f ?g ∧ ?f ≠ ?g)›*) mat_add_idem (*‹?f ⊕ ?f = ?f›*) mat_distl (*‹?f ⊗ ?g ⊕ ?h = (?f ⊗ ?g) ⊕ (?f ⊗ ?h)›*))
(*discuss goal 6*)
apply (metis mat_add_assoc (*‹?f ⊕ ?g ⊕ ?h = ?f ⊕ (?g ⊕ ?h)›*) mat_add_comm (*‹?f ⊕ ?g = ?g ⊕ ?f›*) mat_mult_assoc[symmetric] (*‹?f ⊗ ?g ⊗ ?h = ?f ⊗ (?g ⊗ ?h)›*) mat_distr (*‹?f ⊕ ?g ⊗ ?h = (?f ⊗ ?h) ⊕ (?g ⊗ ?h)›*) mat_onel (*‹ε ⊗ ?f = ?f›*) mat_oner (*‹?f ⊗ ε = ?f›*) mat_zeror (*‹δ ⊕ ?f = ?f›*) mat_annil (*‹δ ⊗ ?f = δ›*) mat_annir (*‹?f ⊗ δ = δ›*) mat_less_eq_def (*‹mat_less_eq ?f ?g = (?f ⊕ ?g = ?g)›*) mat_less_def (*‹mat_less ?f ?g = (mat_less_eq ?f ?g ∧ ?f ≠ ?g)›*) mat_add_idem (*‹?f ⊕ ?f = ?f›*) mat_distl (*‹?f ⊗ ?g ⊕ ?h = (?f ⊗ ?g) ⊕ (?f ⊗ ?h)›*))
(*discuss goal 7*)
apply (metis mat_add_assoc (*‹?f ⊕ ?g ⊕ ?h = ?f ⊕ (?g ⊕ ?h)›*) mat_add_comm (*‹?f ⊕ ?g = ?g ⊕ ?f›*) mat_mult_assoc[symmetric] (*‹?f ⊗ ?g ⊗ ?h = ?f ⊗ (?g ⊗ ?h)›*) mat_distr (*‹?f ⊕ ?g ⊗ ?h = (?f ⊗ ?h) ⊕ (?g ⊗ ?h)›*) mat_onel (*‹ε ⊗ ?f = ?f›*) mat_oner (*‹?f ⊗ ε = ?f›*) mat_zeror (*‹δ ⊕ ?f = ?f›*) mat_annil (*‹δ ⊗ ?f = δ›*) mat_annir (*‹?f ⊗ δ = δ›*) mat_less_eq_def (*‹mat_less_eq ?f ?g = (?f ⊕ ?g = ?g)›*) mat_less_def (*‹mat_less ?f ?g = (mat_less_eq ?f ?g ∧ ?f ≠ ?g)›*) mat_add_idem (*‹?f ⊕ ?f = ?f›*) mat_distl (*‹?f ⊗ ?g ⊕ ?h = (?f ⊗ ?g) ⊕ (?f ⊗ ?h)›*))
(*discuss goal 8*)
apply (metis mat_add_assoc (*‹(?f::?'a ⇒ ?'b ⇒ ?'c) ⊕ (?g::?'a ⇒ ?'b ⇒ ?'c) ⊕ (?h::?'a ⇒ ?'b ⇒ ?'c) = ?f ⊕ (?g ⊕ ?h)›*) mat_add_comm (*‹(?f::?'a ⇒ ?'b ⇒ ?'c) ⊕ (?g::?'a ⇒ ?'b ⇒ ?'c) = ?g ⊕ ?f›*) mat_mult_assoc[symmetric] (*‹(?f::?'a ⇒ ?'d ⇒ ?'c) ⊗ (?g::?'d ⇒ ?'e ⇒ ?'c) ⊗ (?h::?'e ⇒ ?'b ⇒ ?'c) = ?f ⊗ (?g ⊗ ?h)›*) mat_distr (*‹(?f::?'a ⇒ ?'d ⇒ ?'c) ⊕ (?g::?'a ⇒ ?'d ⇒ ?'c) ⊗ (?h::?'d ⇒ ?'b ⇒ ?'c) = (?f ⊗ ?h) ⊕ (?g ⊗ ?h)›*) mat_onel (*‹ε ⊗ (?f::?'a ⇒ ?'b ⇒ ?'c) = ?f›*) mat_oner (*‹(?f::?'a ⇒ ?'b ⇒ ?'c) ⊗ ε = ?f›*) mat_zeror (*‹δ ⊕ (?f::?'a ⇒ ?'b ⇒ ?'c) = ?f›*) mat_annil (*‹δ ⊗ (?f::?'d ⇒ ?'b ⇒ ?'c) = δ›*) mat_annir (*‹(?f::?'a ⇒ ?'d ⇒ ?'c) ⊗ δ = δ›*) mat_less_eq_def (*‹mat_less_eq (?f::?'a ⇒ ?'b ⇒ ?'c) (?g::?'a ⇒ ?'b ⇒ ?'c) = (?f ⊕ ?g = ?g)›*) mat_less_def (*‹mat_less (?f::?'a ⇒ ?'b ⇒ ?'c) (?g::?'a ⇒ ?'b ⇒ ?'c) = (mat_less_eq ?f ?g ∧ ?f ≠ ?g)›*) mat_add_idem (*‹(?f::?'a ⇒ ?'b ⇒ ?'c) ⊕ ?f = ?f›*) mat_distl (*‹(?f::?'a ⇒ ?'d ⇒ ?'c) ⊗ (?g::?'d ⇒ ?'b ⇒ ?'c) ⊕ (?h::?'d ⇒ ?'b ⇒ ?'c) = (?f ⊗ ?g) ⊕ (?f ⊗ ?h)›*))
(*discuss goal 9*)
apply (metis mat_add_assoc (*‹?f ⊕ ?g ⊕ ?h = ?f ⊕ (?g ⊕ ?h)›*) mat_add_comm (*‹?f ⊕ ?g = ?g ⊕ ?f›*) mat_mult_assoc[symmetric] (*‹?f ⊗ ?g ⊗ ?h = ?f ⊗ (?g ⊗ ?h)›*) mat_distr (*‹?f ⊕ ?g ⊗ ?h = (?f ⊗ ?h) ⊕ (?g ⊗ ?h)›*) mat_onel (*‹ε ⊗ ?f = ?f›*) mat_oner (*‹?f ⊗ ε = ?f›*) mat_zeror (*‹δ ⊕ ?f = ?f›*) mat_annil (*‹δ ⊗ ?f = δ›*) mat_annir (*‹?f ⊗ δ = δ›*) mat_less_eq_def (*‹mat_less_eq ?f ?g = (?f ⊕ ?g = ?g)›*) mat_less_def (*‹mat_less ?f ?g = (mat_less_eq ?f ?g ∧ ?f ≠ ?g)›*) mat_add_idem (*‹?f ⊕ ?f = ?f›*) mat_distl (*‹?f ⊗ ?g ⊕ ?h = (?f ⊗ ?g) ⊕ (?f ⊗ ?h)›*))
(*discuss goal 10*)
apply (metis mat_add_assoc (*‹?f ⊕ ?g ⊕ ?h = ?f ⊕ (?g ⊕ ?h)›*) mat_add_comm (*‹?f ⊕ ?g = ?g ⊕ ?f›*) mat_mult_assoc[symmetric] (*‹?f ⊗ ?g ⊗ ?h = ?f ⊗ (?g ⊗ ?h)›*) mat_distr (*‹?f ⊕ ?g ⊗ ?h = (?f ⊗ ?h) ⊕ (?g ⊗ ?h)›*) mat_onel (*‹ε ⊗ ?f = ?f›*) mat_oner (*‹?f ⊗ ε = ?f›*) mat_zeror (*‹δ ⊕ ?f = ?f›*) mat_annil (*‹δ ⊗ ?f = δ›*) mat_annir (*‹?f ⊗ δ = δ›*) mat_less_eq_def (*‹mat_less_eq ?f ?g = (?f ⊕ ?g = ?g)›*) mat_less_def (*‹mat_less ?f ?g = (mat_less_eq ?f ?g ∧ ?f ≠ ?g)›*) mat_add_idem (*‹?f ⊕ ?f = ?f›*) mat_distl (*‹?f ⊗ ?g ⊕ ?h = (?f ⊗ ?g) ⊕ (?f ⊗ ?h)›*))
(*discuss goal 11*)
apply (metis mat_add_assoc (*‹?f ⊕ ?g ⊕ ?h = ?f ⊕ (?g ⊕ ?h)›*) mat_add_comm (*‹?f ⊕ ?g = ?g ⊕ ?f›*) mat_mult_assoc[symmetric] (*‹?f ⊗ ?g ⊗ ?h = ?f ⊗ (?g ⊗ ?h)›*) mat_distr (*‹?f ⊕ ?g ⊗ ?h = (?f ⊗ ?h) ⊕ (?g ⊗ ?h)›*) mat_onel (*‹ε ⊗ ?f = ?f›*) mat_oner (*‹?f ⊗ ε = ?f›*) mat_zeror (*‹δ ⊕ ?f = ?f›*) mat_annil (*‹δ ⊗ ?f = δ›*) mat_annir (*‹?f ⊗ δ = δ›*) mat_less_eq_def (*‹mat_less_eq ?f ?g = (?f ⊕ ?g = ?g)›*) mat_less_def (*‹mat_less ?f ?g = (mat_less_eq ?f ?g ∧ ?f ≠ ?g)›*) mat_add_idem (*‹?f ⊕ ?f = ?f›*) mat_distl (*‹?f ⊗ ?g ⊕ ?h = (?f ⊗ ?g) ⊕ (?f ⊗ ?h)›*))
(*discuss goal 12*)
apply (metis mat_add_assoc (*‹(?f::?'a::type ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) ⊕ (?g::?'a::type ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) ⊕ (?h::?'a::type ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) = ?f ⊕ (?g ⊕ ?h)›*) mat_add_comm (*‹(?f::?'a::type ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) ⊕ (?g::?'a::type ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) = ?g ⊕ ?f›*) mat_mult_assoc[symmetric] (*‹(?f::?'a::type ⇒ ?'d::finite ⇒ ?'c::dioid_one_zero) ⊗ (?g::?'d::finite ⇒ ?'e::finite ⇒ ?'c::dioid_one_zero) ⊗ (?h::?'e::finite ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) = ?f ⊗ (?g ⊗ ?h)›*) mat_distr (*‹(?f::?'a::type ⇒ ?'d::finite ⇒ ?'c::dioid_one_zero) ⊕ (?g::?'a::type ⇒ ?'d::finite ⇒ ?'c::dioid_one_zero) ⊗ (?h::?'d::finite ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) = (?f ⊗ ?h) ⊕ (?g ⊗ ?h)›*) mat_onel (*‹ε ⊗ (?f::?'a::finite ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) = ?f›*) mat_oner (*‹(?f::?'a::type ⇒ ?'b::finite ⇒ ?'c::dioid_one_zero) ⊗ ε = ?f›*) mat_zeror (*‹δ ⊕ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) = ?f›*) mat_annil (*‹δ ⊗ (?f::?'d::finite ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) = δ›*) mat_annir (*‹(?f::?'a::type ⇒ ?'d::finite ⇒ ?'c::dioid_one_zero) ⊗ δ = δ›*) mat_less_eq_def (*‹mat_less_eq (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) (?g::?'a::type ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) = (?f ⊕ ?g = ?g)›*) mat_less_def (*‹mat_less (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) (?g::?'a::type ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) = (mat_less_eq ?f ?g ∧ ?f ≠ ?g)›*) mat_add_idem (*‹(?f::?'a::type ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) ⊕ ?f = ?f›*) mat_distl (*‹(?f::?'a::type ⇒ ?'d::finite ⇒ ?'c::dioid_one_zero) ⊗ (?g::?'d::finite ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) ⊕ (?h::?'d::finite ⇒ ?'b::type ⇒ ?'c::dioid_one_zero) = (?f ⊗ ?g) ⊕ (?f ⊗ ?h)›*))
(*discuss goal 13*)
apply (metis mat_add_assoc (*‹?f ⊕ ?g ⊕ ?h = ?f ⊕ (?g ⊕ ?h)›*) mat_add_comm (*‹?f ⊕ ?g = ?g ⊕ ?f›*) mat_mult_assoc[symmetric] (*‹?f ⊗ ?g ⊗ ?h = ?f ⊗ (?g ⊗ ?h)›*) mat_distr (*‹?f ⊕ ?g ⊗ ?h = (?f ⊗ ?h) ⊕ (?g ⊗ ?h)›*) mat_onel (*‹ε ⊗ ?f = ?f›*) mat_oner (*‹?f ⊗ ε = ?f›*) mat_zeror (*‹δ ⊕ ?f = ?f›*) mat_annil (*‹δ ⊗ ?f = δ›*) mat_annir (*‹?f ⊗ δ = δ›*) mat_less_eq_def (*‹mat_less_eq ?f ?g = (?f ⊕ ?g = ?g)›*) mat_less_def (*‹mat_less ?f ?g = (mat_less_eq ?f ?g ∧ ?f ≠ ?g)›*) mat_add_idem (*‹?f ⊕ ?f = ?f›*) mat_distl (*‹?f ⊗ ?g ⊕ ?h = (?f ⊗ ?g) ⊕ (?f ⊗ ?h)›*))
(*proven 13 subgoals*) .
text ‹As in the case of formal power series we currently do not
implement the Kleene star of matrices, since this is complicated.›
end
| {
"path": "afp-2025-02-12/thys/Kleene_Algebra/Inf_Matrix.thy",
"repo": "afp-2025-02-12",
"sha": "1f8f5cdb75fa1d7a6a1c14a928bb13a486533a75f03624b8fd5a35780cb5765f"
} |
section ‹Equalizers and Subobjects›
theory Equalizer
imports Terminal
begin
subsection ‹Equalizers›
definition equalizer :: "cset ⇒ cfunc ⇒ cfunc ⇒ cfunc ⇒ bool" where
"equalizer E m f g ⟷ (∃ X Y. (f : X → Y) ∧ (g : X → Y) ∧ (m : E → X)
∧ (f ∘⇩c m = g ∘⇩c m)
∧ (∀ h F. ((h : F → X) ∧ (f ∘⇩c h = g ∘⇩c h)) ⟶ (∃! k. (k : F → E) ∧ m ∘⇩c k = h)))"
lemma equalizer_def2:
assumes "f : X → Y" "g : X → Y" "m : E → X"
shows "equalizer E m f g ⟷ ((f ∘⇩c m = g ∘⇩c m)
∧ (∀ h F. ((h : F → X) ∧ (f ∘⇩c h = g ∘⇩c h)) ⟶ (∃! k. (k : F → E) ∧ m ∘⇩c k = h)))"
using assms (*‹f : X → Y› ‹(g::cfunc) : (X::cset) → (Y::cset)› ‹m : E → X›*) unfolding equalizer_def
(*goal: ‹(∃X Y. f : X → Y ∧ g : X → Y ∧ m : E → X ∧ f ∘⇩c m = g ∘⇩c m ∧ (∀h F. h : F → X ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h))) = (f ∘⇩c m = g ∘⇩c m ∧ (∀h F. h : F → X ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h)))›*)
by (auto simp add: cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*))
lemma equalizer_eq:
assumes "f : X → Y" "g : X → Y" "m : E → X"
assumes "equalizer E m f g"
shows "f ∘⇩c m = g ∘⇩c m"
using assms (*‹f : X → Y› ‹g : X → Y› ‹m : E → X› ‹equalizer (E::cset) (m::cfunc) (f::cfunc) (g::cfunc)›*) equalizer_def2 (*‹⟦?f : ?X → ?Y; ?g : ?X → ?Y; ?m : ?E → ?X⟧ ⟹ equalizer ?E ?m ?f ?g = (?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → ?X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) by auto
lemma similar_equalizers:
assumes "f : X → Y" "g : X → Y" "m : E → X"
assumes "equalizer E m f g"
assumes "h : F → X" "f ∘⇩c h = g ∘⇩c h"
shows "∃! k. k : F → E ∧ m ∘⇩c k = h"
using assms (*‹f : X → Y› ‹g : X → Y› ‹m : E → X› ‹equalizer E m f g› ‹h : F → X› ‹(f::cfunc) ∘⇩c (h::cfunc) = (g::cfunc) ∘⇩c h›*) equalizer_def2 (*‹⟦(?f::cfunc) : (?X::cset) → (?Y::cset); (?g::cfunc) : ?X → ?Y; (?m::cfunc) : (?E::cset) → ?X⟧ ⟹ equalizer ?E ?m ?f ?g = (?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀(h::cfunc) F::cset. h : F → ?X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k::cfunc. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) by auto
text ‹The definition above and the axiomatization below correspond to Axiom 4 (Equalizers) in Halvorson.›
axiomatization where
equalizer_exists: "f : X → Y ⟹ g : X → Y ⟹ ∃ E m. equalizer E m f g"
lemma equalizer_exists2:
assumes "f : X → Y" "g : X → Y"
shows "∃ E m. m : E → X ∧ f ∘⇩c m = g ∘⇩c m ∧ (∀ h F. ((h : F → X) ∧ (f ∘⇩c h = g ∘⇩c h)) ⟶ (∃! k. (k : F → E) ∧ m ∘⇩c k = h))"
proof (-)
(*goal: ‹∃E m. m : E → X ∧ f ∘⇩c m = g ∘⇩c m ∧ (∀h F. h : F → X ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h))›*)
obtain E and m where "equalizer E m f g"
(*goal: ‹(⋀(E::cset) m::cfunc. equalizer E m (f::cfunc) (g::cfunc) ⟹ thesis::bool) ⟹ thesis›*)
using assms (*‹f : X → Y› ‹g : X → Y›*) equalizer_exists (*‹⟦?f : ?X → ?Y; ?g : ?X → ?Y⟧ ⟹ ∃E m. equalizer E m ?f ?g›*) by blast
then show "?thesis"
(*goal: ‹∃E m. m : E → X ∧ f ∘⇩c m = g ∘⇩c m ∧ (∀h F. h : F → X ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h))›*)
unfolding equalizer_def
(*goal: ‹∃E m. m : E → X ∧ f ∘⇩c m = g ∘⇩c m ∧ (∀h F. h : F → X ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h))›*)
proof (intro exI[where x=E] (*‹(?P::cset ⇒ bool) (E::cset) ⟹ ∃x::cset. ?P x›*), intro exI[where x=m] (*‹?P m ⟹ ∃x. ?P x›*), safe)
(*goals:
1. ‹⋀Xa Xaa Xb Y Ya Yb. ⟦f : Xa → Y; f : Xaa → Ya; f : Xb → Yb; g : Xa → Y; g : Xaa → Ya; g : Xb → Yb; m : E → Xa; m : E → Xaa; m : E → Xb; f ∘⇩c m = g ∘⇩c m; ∀h F. h : F → Xa ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h); f ∘⇩c m = g ∘⇩c m; ∀h F. h : F → Xaa ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h); f ∘⇩c m = g ∘⇩c m; ∀h F. h : F → Xb ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h)⟧ ⟹ m : E → X›
2. ‹⋀Xa Xaa Xb Y Ya Yb h F. ⟦f : Xa → Y; f : Xaa → Ya; f : Xb → Yb; g : Xa → Y; g : Xaa → Ya; g : Xb → Yb; m : E → Xa; m : E → Xaa; m : E → Xb; f ∘⇩c m = g ∘⇩c m; ∀h F. h : F → Xa ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h); f ∘⇩c m = g ∘⇩c m; ∀h F. h : F → Xaa ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h); f ∘⇩c m = g ∘⇩c m; ∀h F. h : F → Xb ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h); h : F → X; f ∘⇩c h = g ∘⇩c h⟧ ⟹ ∃k. k : F → E ∧ m ∘⇩c k = h›
3. ‹⋀Xa Xaa Xb Y Ya Yb h F k y. ⟦f : Xa → Y; f : Xaa → Ya; f : Xb → Yb; g : Xa → Y; g : Xaa → Ya; g : Xb → Yb; m : E → Xa; m : E → Xaa; m : E → Xb; f ∘⇩c m = g ∘⇩c m; ∀h F. h : F → Xa ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h); f ∘⇩c m = g ∘⇩c m; ∀h F. h : F → Xaa ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h); f ∘⇩c m = g ∘⇩c m; ∀h F. h : F → Xb ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h); m ∘⇩c k : F → X; f ∘⇩c m ∘⇩c k = g ∘⇩c m ∘⇩c k; k : F → E; y : F → E; m ∘⇩c y = m ∘⇩c k⟧ ⟹ k = y›*)
fix X' and Y'
assume f_type2: "f : X' → Y'" (*‹(f::cfunc) : (X'::cset) → (Y'::cset)›*)
assume g_type2: "g : X' → Y'" (*‹(g::cfunc) : (X'::cset) → (Y'::cset)›*)
assume m_type: "m : E → X'" (*‹(m::cfunc) : (E::cset) → (X'::cset)›*)
assume fm_eq_gm: "f ∘⇩c m = g ∘⇩c m" (*‹(f::cfunc) ∘⇩c (m::cfunc) = (g::cfunc) ∘⇩c m›*)
assume equalizer_unique: "∀h F. h : F → X' ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h)" (*‹∀(h::cfunc) F::cset. h : F → (X'::cset) ∧ (f::cfunc) ∘⇩c h = (g::cfunc) ∘⇩c h ⟶ (∃!k::cfunc. k : F → (E::cset) ∧ (m::cfunc) ∘⇩c k = h)›*)
show m_type2: "m : E → X"
using assms(2) (*‹g : X → Y›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) g_type2 (*‹g : X' → Y'›*) m_type (*‹m : E → X'›*) by auto
show "⋀ h F. h : F → X ⟹ f ∘⇩c h = g ∘⇩c h ⟹ ∃k. k : F → E ∧ m ∘⇩c k = h"
by (metis m_type2 (*‹m : E → X›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) equalizer_unique (*‹∀h F. h : F → X' ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h)›*) m_type (*‹m : E → X'›*))
show "⋀ F k y. m ∘⇩c k : F → X ⟹ f ∘⇩c m ∘⇩c k = g ∘⇩c m ∘⇩c k ⟹ k : F → E ⟹ y : F → E
⟹ m ∘⇩c y = m ∘⇩c k ⟹ k = y"
using comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) equalizer_unique (*‹∀(h::cfunc) F::cset. h : F → (X'::cset) ∧ (f::cfunc) ∘⇩c h = (g::cfunc) ∘⇩c h ⟶ (∃!k::cfunc. k : F → (E::cset) ∧ (m::cfunc) ∘⇩c k = h)›*) m_type (*‹m : E → X'›*) by blast
qed
qed
text ‹The lemma below corresponds to Exercise 2.1.31 in Halvorson.›
lemma equalizers_isomorphic:
assumes "equalizer E m f g" "equalizer E' m' f g"
shows "∃ k. k : E → E' ∧ isomorphism k ∧ m = m' ∘⇩c k"
proof (-)
(*goal: ‹∃k. k : E → E' ∧ isomorphism k ∧ m = m' ∘⇩c k›*)
have fm_eq_gm: "f ∘⇩c m = g ∘⇩c m"
using assms(1) (*‹equalizer E m f g›*) equalizer_def (*‹equalizer ?E ?m ?f ?g = (∃X Y. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) by blast
have fm'_eq_gm': "f ∘⇩c m' = g ∘⇩c m'"
using assms(2) (*‹equalizer E' m' f g›*) equalizer_def (*‹equalizer (?E::cset) (?m::cfunc) (?f::cfunc) (?g::cfunc) = (∃(X::cset) Y::cset. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀(h::cfunc) F::cset. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k::cfunc. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) by blast
obtain X and Y where f_type: "f : X → Y" and g_type: "g : X → Y" and m_type: "m : E → X"
(*goal: ‹(⋀(X::cset) Y::cset. ⟦(f::cfunc) : X → Y; (g::cfunc) : X → Y; (m::cfunc) : (E::cset) → X⟧ ⟹ thesis::bool) ⟹ thesis›*)
using assms(1) (*‹equalizer E m f g›*) unfolding equalizer_def
(*goal: ‹(⋀X Y. ⟦f : X → Y; g : X → Y; m : E → X⟧ ⟹ thesis) ⟹ thesis›*)
by auto
obtain k where k_type: "k : E' → E" and mk_eq_m': "m ∘⇩c k = m'"
(*goal: ‹(⋀k. ⟦k : E' → E; m ∘⇩c k = m'⟧ ⟹ thesis) ⟹ thesis›*)
by (metis assms (*‹equalizer (E::cset) (m::cfunc) (f::cfunc) (g::cfunc)› ‹equalizer (E'::cset) (m'::cfunc) (f::cfunc) (g::cfunc)›*) cfunc_type_def (*‹((?f::cfunc) : (?X::cset) → (?Y::cset)) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) equalizer_def (*‹equalizer (?E::cset) (?m::cfunc) (?f::cfunc) (?g::cfunc) = (∃(X::cset) Y::cset. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀(h::cfunc) F::cset. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k::cfunc. k : F → ?E ∧ ?m ∘⇩c k = h)))›*))
obtain k' where k'_type: "k' : E → E'" and m'k_eq_m: "m' ∘⇩c k' = m"
(*goal: ‹(⋀k'. ⟦k' : E → E'; m' ∘⇩c k' = m⟧ ⟹ thesis) ⟹ thesis›*)
by (metis assms (*‹equalizer E m f g› ‹equalizer E' m' f g›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) equalizer_def (*‹equalizer ?E ?m ?f ?g = (∃X Y. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*))
have "f ∘⇩c m ∘⇩c k ∘⇩c k' = g ∘⇩c m ∘⇩c k ∘⇩c k'"
using comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) m_type (*‹m : E → X›*) fm_eq_gm (*‹f ∘⇩c m = g ∘⇩c m›*) k'_type (*‹(k'::cfunc) : (E::cset) → (E'::cset)›*) k_type (*‹k : E' → E›*) m'k_eq_m (*‹m' ∘⇩c k' = m›*) mk_eq_m' (*‹(m::cfunc) ∘⇩c (k::cfunc) = (m'::cfunc)›*) by auto
have "k ∘⇩c k' : E → E ∧ m ∘⇩c k ∘⇩c k' = m"
using comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) k'_type (*‹k' : E → E'›*) k_type (*‹k : E' → E›*) m_type (*‹m : E → X›*) m'k_eq_m (*‹m' ∘⇩c k' = m›*) mk_eq_m' (*‹m ∘⇩c k = m'›*) by auto
then have kk'_eq_id: "k ∘⇩c k' = id E"
using assms(1) (*‹equalizer E m f g›*) equalizer_def (*‹equalizer ?E ?m ?f ?g = (∃X Y. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) id_right_unit2 (*‹(?f::cfunc) : (?X::cset) → (?Y::cset) ⟹ ?f ∘⇩c id⇩c ?X = ?f›*) id_type (*‹id⇩c ?X : ?X → ?X›*) by blast
have "k' ∘⇩c k : E' → E' ∧ m' ∘⇩c k' ∘⇩c k = m'"
by (smt comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) k'_type (*‹k' : E → E'›*) k_type (*‹k : E' → E›*) m'k_eq_m (*‹m' ∘⇩c k' = m›*) m_type (*‹m : E → X›*) mk_eq_m' (*‹m ∘⇩c k = m'›*))
then have k'k_eq_id: "k' ∘⇩c k = id E'"
using assms(2) (*‹equalizer E' m' f g›*) equalizer_def (*‹equalizer ?E ?m ?f ?g = (∃X Y. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) id_right_unit2 (*‹?f : ?X → ?Y ⟹ ?f ∘⇩c id⇩c ?X = ?f›*) id_type (*‹id⇩c ?X : ?X → ?X›*) by blast
show "∃k. k : E → E' ∧ isomorphism k ∧ m = m' ∘⇩c k"
using cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) isomorphism_def (*‹isomorphism ?f = (∃g. domain g = codomain ?f ∧ codomain g = domain ?f ∧ g ∘⇩c ?f = id⇩c (domain ?f) ∧ ?f ∘⇩c g = id⇩c (domain g))›*) k'_type (*‹(k'::cfunc) : (E::cset) → (E'::cset)›*) k'k_eq_id (*‹(k'::cfunc) ∘⇩c (k::cfunc) = id⇩c (E'::cset)›*) k_type (*‹k : E' → E›*) kk'_eq_id (*‹k ∘⇩c k' = id⇩c E›*) m'k_eq_m (*‹(m'::cfunc) ∘⇩c (k'::cfunc) = (m::cfunc)›*) apply (intro exI[where x=k'] (*‹?P k' ⟹ ∃x. ?P x›*))
(*goal: ‹∃k. k : E → E' ∧ isomorphism k ∧ m = m' ∘⇩c k›*)
by auto
qed
lemma isomorphic_to_equalizer_is_equalizer:
assumes "φ: E' → E"
assumes "isomorphism φ"
assumes "equalizer E m f g"
assumes "f : X → Y"
assumes "g : X → Y"
assumes "m : E → X"
shows "equalizer E' (m ∘⇩c φ) f g"
proof (-)
(*goal: ‹equalizer E' (m ∘⇩c φ) f g›*)
obtain φ_inv where "φ_inv_type"[type_rule]: "φ_inv : E → E'" and "φ_inv_φ": "φ_inv ∘⇩c φ = id(E')" and "φφ_inv": "φ ∘⇩c φ_inv = id(E)"
(*goal: ‹(⋀φ_inv. ⟦φ_inv : E → E'; φ_inv ∘⇩c φ = id⇩c E'; φ ∘⇩c φ_inv = id⇩c E⟧ ⟹ thesis) ⟹ thesis›*)
using assms(1,2) (*‹φ : E' → E› ‹isomorphism (φ::cfunc)›*) cfunc_type_def (*‹((?f::cfunc) : (?X::cset) → (?Y::cset)) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) isomorphism_def (*‹isomorphism ?f = (∃g. domain g = codomain ?f ∧ codomain g = domain ?f ∧ g ∘⇩c ?f = id⇩c (domain ?f) ∧ ?f ∘⇩c g = id⇩c (domain g))›*) by auto
have equalizes: "f ∘⇩c m ∘⇩c φ = g ∘⇩c m ∘⇩c φ"
using assms (*‹φ : E' → E› ‹isomorphism φ› ‹equalizer E m f g› ‹(f::cfunc) : (X::cset) → (Y::cset)› ‹g : X → Y› ‹m : E → X›*) comp_associative2 (*‹⟦(?f::cfunc) : (?X::cset) → (?Y::cset); (?g::cfunc) : ?Y → (?Z::cset); (?h::cfunc) : ?Z → (?W::cset)⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) equalizer_def (*‹equalizer (?E::cset) (?m::cfunc) (?f::cfunc) (?g::cfunc) = (∃(X::cset) Y::cset. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀(h::cfunc) F::cset. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k::cfunc. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) by force
have "∀h F. h : F → X ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E' ∧ (m ∘⇩c φ) ∘⇩c k = h)"
proof (safe)
(*goals:
1. ‹⋀h F. ⟦h : F → X; f ∘⇩c h = g ∘⇩c h⟧ ⟹ ∃k. k : F → E' ∧ (m ∘⇩c φ) ∘⇩c k = h›
2. ‹⋀h F k y. ⟦(m ∘⇩c φ) ∘⇩c k : F → X; f ∘⇩c (m ∘⇩c φ) ∘⇩c k = g ∘⇩c (m ∘⇩c φ) ∘⇩c k; k : F → E'; y : F → E'; (m ∘⇩c φ) ∘⇩c y = (m ∘⇩c φ) ∘⇩c k⟧ ⟹ k = y›*)
fix h and F
assume h_type[type_rule]: "h : F → X" (*‹(h::cfunc) : (F::cset) → (X::cset)›*)
assume h_equalizes: "f ∘⇩c h = g ∘⇩c h" (*‹(f::cfunc) ∘⇩c (h::cfunc) = (g::cfunc) ∘⇩c h›*)
have k_exists_uniquely: "∃! k. k: F → E ∧ m ∘⇩c k = h"
using assms (*‹φ : E' → E› ‹isomorphism φ› ‹equalizer E m f g› ‹f : X → Y› ‹g : X → Y› ‹m : E → X›*) equalizer_def2 (*‹⟦?f : ?X → ?Y; ?g : ?X → ?Y; ?m : ?E → ?X⟧ ⟹ equalizer ?E ?m ?f ?g = (?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → ?X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) h_equalizes (*‹f ∘⇩c h = g ∘⇩c h›*) apply -
(*goal: ‹∃!k. k : F → E ∧ m ∘⇩c k = h›*)
apply typecheck_cfuncs
(*goal: ‹⟦φ : E' → E; isomorphism φ; equalizer E m f g; f : X → Y; g : X → Y; m : E → X; ⋀f X Y g m E. ⟦f : X → Y; g : X → Y; m : E → X⟧ ⟹ equalizer E m f g = (f ∘⇩c m = g ∘⇩c m ∧ (∀h F. h : F → X ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h))); f ∘⇩c h = g ∘⇩c h⟧ ⟹ ∃!k. k : F → E ∧ m ∘⇩c k = h›*)
by auto
then obtain k where k_type[type_rule]: "k: F → E" and k_def: "m ∘⇩c k = h"
(*goal: ‹(⋀k. ⟦k : F → E; m ∘⇩c k = h⟧ ⟹ thesis) ⟹ thesis›*)
by blast
then show "∃k. k : F → E' ∧ (m ∘⇩c φ) ∘⇩c k = h"
using assms (*‹φ : E' → E› ‹isomorphism φ› ‹equalizer E m f g› ‹(f::cfunc) : (X::cset) → (Y::cset)› ‹g : X → Y› ‹m : E → X›*) apply typecheck_cfuncs
(*goal: ‹∃k. k : F → E' ∧ (m ∘⇩c φ) ∘⇩c k = h›*)
by (smt (z3) φφ_inv (*‹φ ∘⇩c φ_inv = id⇩c E›*) φ_inv_type (*‹φ_inv : E → E'›*) comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) id_right_unit2 (*‹?f : ?X → ?Y ⟹ ?f ∘⇩c id⇩c ?X = ?f›*) k_exists_uniquely (*‹∃!k. k : F → E ∧ m ∘⇩c k = h›*))
next
(*goal: ‹⋀h F k y. ⟦(m ∘⇩c φ) ∘⇩c k : F → X; f ∘⇩c (m ∘⇩c φ) ∘⇩c k = g ∘⇩c (m ∘⇩c φ) ∘⇩c k; k : F → E'; y : F → E'; (m ∘⇩c φ) ∘⇩c y = (m ∘⇩c φ) ∘⇩c k⟧ ⟹ k = y›*)
fix F and k and y
assume "(m ∘⇩c φ) ∘⇩c k : F → X" (*‹((m::cfunc) ∘⇩c (φ::cfunc)) ∘⇩c (k::cfunc) : (F::cset) → (X::cset)›*)
assume "f ∘⇩c (m ∘⇩c φ) ∘⇩c k = g ∘⇩c (m ∘⇩c φ) ∘⇩c k" (*‹(f::cfunc) ∘⇩c ((m::cfunc) ∘⇩c (φ::cfunc)) ∘⇩c (k::cfunc) = (g::cfunc) ∘⇩c (m ∘⇩c φ) ∘⇩c k›*)
assume k_type[type_rule]: "k : F → E'" (*‹(k::cfunc) : (F::cset) → (E'::cset)›*)
assume y_type[type_rule]: "y : F → E'" (*‹(y::cfunc) : (F::cset) → (E'::cset)›*)
assume "(m ∘⇩c φ) ∘⇩c y = (m ∘⇩c φ) ∘⇩c k" (*‹((m::cfunc) ∘⇩c (φ::cfunc)) ∘⇩c (y::cfunc) = (m ∘⇩c φ) ∘⇩c (k::cfunc)›*)
then show "k = y"
apply -
(*goal: ‹k = y›*)
apply typecheck_cfuncs
(*goal: ‹(m ∘⇩c φ) ∘⇩c y = (m ∘⇩c φ) ∘⇩c k ⟹ k = y›*)
by (smt (verit, ccfv_threshold) assms( (*‹φ : E' → E› ‹isomorphism φ› ‹equalizer E m f g›*) 1,2,3) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_associative (*‹⟦domain ?h = codomain ?g; domain ?g = codomain ?f⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) equalizer_def (*‹equalizer ?E ?m ?f ?g = (∃X Y. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) id_left_unit2 (*‹?f : ?X → ?Y ⟹ id⇩c ?Y ∘⇩c ?f = ?f›*) isomorphism_def (*‹isomorphism ?f = (∃g. domain g = codomain ?f ∧ codomain g = domain ?f ∧ g ∘⇩c ?f = id⇩c (domain ?f) ∧ ?f ∘⇩c g = id⇩c (domain g))›*))
qed
then show "?thesis"
(*goal: ‹equalizer E' (m ∘⇩c φ) f g›*)
by (smt (verit, best) assms( (*‹φ : E' → E› ‹f : X → Y› ‹g : X → Y› ‹m : E → X›*) 1,4,5,6) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) equalizer_def (*‹equalizer ?E ?m ?f ?g = (∃X Y. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) equalizes (*‹f ∘⇩c m ∘⇩c φ = g ∘⇩c m ∘⇩c φ›*))
qed
text ‹The lemma below corresponds to Exercise 2.1.34 in Halvorson.›
lemma equalizer_is_monomorphism:
"equalizer E m f g ⟹ monomorphism(m)"
unfolding equalizer_def monomorphism_def
(*goal: ‹∃X Y. f : X → Y ∧ g : X → Y ∧ m : E → X ∧ f ∘⇩c m = g ∘⇩c m ∧ (∀h F. h : F → X ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h)) ⟹ ∀g h. codomain g = domain m ∧ codomain h = domain m ⟶ m ∘⇩c g = m ∘⇩c h ⟶ g = h›*)
proof (clarify)
(*goal: ‹⋀(X::cset) (Y::cset) (ga::cfunc) h::cfunc. ⟦(f::cfunc) : X → Y; (g::cfunc) : X → Y; (m::cfunc) : (E::cset) → X; f ∘⇩c m = g ∘⇩c m; ∀(h::cfunc) F::cset. h : F → X ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k::cfunc. k : F → E ∧ m ∘⇩c k = h); codomain ga = domain m; codomain h = domain m; m ∘⇩c ga = m ∘⇩c h⟧ ⟹ ga = h›*)
fix h1 and h2 and X and Y
assume f_type: "f : X → Y" (*‹(f::cfunc) : (X::cset) → (Y::cset)›*)
assume g_type: "g : X → Y" (*‹(g::cfunc) : (X::cset) → (Y::cset)›*)
assume m_type: "m : E → X" (*‹(m::cfunc) : (E::cset) → (X::cset)›*)
assume fm_gm: "f ∘⇩c m = g ∘⇩c m" (*‹(f::cfunc) ∘⇩c (m::cfunc) = (g::cfunc) ∘⇩c m›*)
assume uniqueness: "∀h F. h : F → X ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h)" (*‹∀(h::cfunc) F::cset. h : F → (X::cset) ∧ (f::cfunc) ∘⇩c h = (g::cfunc) ∘⇩c h ⟶ (∃!k::cfunc. k : F → (E::cset) ∧ (m::cfunc) ∘⇩c k = h)›*)
assume relation_ga: "codomain h1 = domain m" (*‹codomain (h1::cfunc) = domain (m::cfunc)›*)
assume relation_h: "codomain h2 = domain m" (*‹codomain (h2::cfunc) = domain (m::cfunc)›*)
assume m_ga_mh: "m ∘⇩c h1 = m ∘⇩c h2" (*‹(m::cfunc) ∘⇩c (h1::cfunc) = m ∘⇩c (h2::cfunc)›*)
have "f ∘⇩c m ∘⇩c h1 = g ∘⇩c m ∘⇩c h2"
using cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_associative (*‹⟦domain ?h = codomain ?g; domain ?g = codomain ?f⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) f_type (*‹f : X → Y›*) fm_gm (*‹f ∘⇩c m = g ∘⇩c m›*) g_type (*‹(g::cfunc) : (X::cset) → (Y::cset)›*) m_ga_mh (*‹(m::cfunc) ∘⇩c (h1::cfunc) = m ∘⇩c (h2::cfunc)›*) m_type (*‹m : E → X›*) relation_h (*‹codomain (h2::cfunc) = domain (m::cfunc)›*) by auto
then obtain z where "z: domain(h1) → E ∧ m ∘⇩c z = m ∘⇩c h1 ∧
(∀ j. j:domain(h1) → E ∧ m ∘⇩c j = m ∘⇩c h1 ⟶ j = z)"
(*goal: ‹(⋀z. z : domain h1 → E ∧ m ∘⇩c z = m ∘⇩c h1 ∧ (∀j. j : domain h1 → E ∧ m ∘⇩c j = m ∘⇩c h1 ⟶ j = z) ⟹ thesis) ⟹ thesis›*)
using uniqueness (*‹∀h F. h : F → X ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h)›*) by (smt cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) codomain_comp (*‹domain ?g = codomain ?f ⟹ codomain (?g ∘⇩c ?f) = codomain ?g›*) domain_comp (*‹domain ?g = codomain ?f ⟹ domain (?g ∘⇩c ?f) = domain ?f›*) m_ga_mh (*‹m ∘⇩c h1 = m ∘⇩c h2›*) m_type (*‹m : E → X›*) relation_ga (*‹codomain h1 = domain m›*))
then show "h1 = h2"
by (metis cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) domain_comp (*‹domain ?g = codomain ?f ⟹ domain (?g ∘⇩c ?f) = domain ?f›*) m_ga_mh (*‹m ∘⇩c h1 = m ∘⇩c h2›*) m_type (*‹m : E → X›*) relation_ga (*‹codomain h1 = domain m›*) relation_h (*‹codomain h2 = domain m›*))
qed
text ‹The definition below corresponds to Definition 2.1.35 in Halvorson.›
definition regular_monomorphism :: "cfunc ⇒ bool"
where "regular_monomorphism f ⟷
(∃ g h. domain g = codomain f ∧ domain h = codomain f ∧ equalizer (domain f) f g h)"
text ‹The lemma below corresponds to Exercise 2.1.36 in Halvorson.›
lemma epi_regmon_is_iso:
assumes "epimorphism f" "regular_monomorphism f"
shows "isomorphism f"
proof (-)
(*goal: ‹isomorphism f›*)
obtain g and h where g_type: "domain g = codomain f" and h_type: "domain h = codomain f" and f_equalizer: "equalizer (domain f) f g h"
(*goal: ‹(⋀g h. ⟦domain g = codomain f; domain h = codomain f; equalizer (domain f) f g h⟧ ⟹ thesis) ⟹ thesis›*)
using assms(2) (*‹regular_monomorphism f›*) regular_monomorphism_def (*‹regular_monomorphism ?f = (∃g h. domain g = codomain ?f ∧ domain h = codomain ?f ∧ equalizer (domain ?f) ?f g h)›*) by auto
then have "g ∘⇩c f = h ∘⇩c f"
using equalizer_def (*‹equalizer (?E::cset) (?m::cfunc) (?f::cfunc) (?g::cfunc) = (∃(X::cset) Y::cset. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀(h::cfunc) F::cset. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k::cfunc. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) by blast
then have "g = h"
using assms(1) (*‹epimorphism f›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) epimorphism_def (*‹epimorphism ?f = (∀g h. domain g = codomain ?f ∧ domain h = codomain ?f ⟶ g ∘⇩c ?f = h ∘⇩c ?f ⟶ g = h)›*) equalizer_def (*‹equalizer ?E ?m ?f ?g = (∃X Y. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) f_equalizer (*‹equalizer (domain f) f g h›*) by auto
then have "g ∘⇩c id(codomain f) = h ∘⇩c id(codomain f)"
by simp
then obtain k where k_type: "f ∘⇩c k = id(codomain(f)) ∧ codomain k = domain f"
(*goal: ‹(⋀k. f ∘⇩c k = id⇩c (codomain f) ∧ codomain k = domain f ⟹ thesis) ⟹ thesis›*)
by (metis cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) equalizer_def (*‹equalizer ?E ?m ?f ?g = (∃X Y. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) f_equalizer (*‹equalizer (domain f) f g h›*) id_type (*‹id⇩c ?X : ?X → ?X›*))
then have "f ∘⇩c id(domain(f)) = f ∘⇩c (k ∘⇩c f)"
by (metis comp_associative (*‹⟦domain ?h = codomain ?g; domain ?g = codomain ?f⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) domain_comp (*‹domain ?g = codomain ?f ⟹ domain (?g ∘⇩c ?f) = domain ?f›*) id_domain (*‹domain (id⇩c ?X) = ?X›*) id_left_unit (*‹id⇩c (codomain ?f) ∘⇩c ?f = ?f›*) id_right_unit (*‹?f ∘⇩c id⇩c (domain ?f) = ?f›*))
then have "monomorphism f ⟹ k ∘⇩c f = id(domain f)"
by (metis (mono_tags) codomain_comp (*‹domain (?g::cfunc) = codomain (?f::cfunc) ⟹ codomain (?g ∘⇩c ?f) = codomain ?g›*) domain_comp (*‹domain (?g::cfunc) = codomain (?f::cfunc) ⟹ domain (?g ∘⇩c ?f) = domain ?f›*) id_codomain (*‹codomain (id⇩c (?X::cset)) = ?X›*) id_domain (*‹domain (id⇩c (?X::cset)) = ?X›*) k_type (*‹(f::cfunc) ∘⇩c (k::cfunc) = id⇩c (codomain f) ∧ codomain k = domain f›*) monomorphism_def (*‹monomorphism (?f::cfunc) = (∀(g::cfunc) h::cfunc. codomain g = domain ?f ∧ codomain h = domain ?f ⟶ ?f ∘⇩c g = ?f ∘⇩c h ⟶ g = h)›*))
then have "k ∘⇩c f = id(domain f)"
using equalizer_is_monomorphism (*‹equalizer (?E::cset) (?m::cfunc) (?f::cfunc) (?g::cfunc) ⟹ monomorphism ?m›*) f_equalizer (*‹equalizer (domain (f::cfunc)) f (g::cfunc) (h::cfunc)›*) by blast
then show "isomorphism f"
by (metis domain_comp (*‹domain (?g::cfunc) = codomain (?f::cfunc) ⟹ domain (?g ∘⇩c ?f) = domain ?f›*) id_domain (*‹domain (id⇩c (?X::cset)) = ?X›*) isomorphism_def (*‹isomorphism (?f::cfunc) = (∃g::cfunc. domain g = codomain ?f ∧ codomain g = domain ?f ∧ g ∘⇩c ?f = id⇩c (domain ?f) ∧ ?f ∘⇩c g = id⇩c (domain g))›*) k_type (*‹(f::cfunc) ∘⇩c (k::cfunc) = id⇩c (codomain f) ∧ codomain k = domain f›*))
qed
subsection ‹Subobjects›
text ‹The definition below corresponds to Definition 2.1.32 in Halvorson.›
definition factors_through :: "cfunc ⇒ cfunc ⇒ bool" (infix "factorsthru" 90)
where "g factorsthru f ⟷ (∃ h. (h: domain(g)→ domain(f)) ∧ f ∘⇩c h = g)"
lemma factors_through_def2:
assumes "g : X → Z" "f : Y → Z"
shows "g factorsthru f ⟷ (∃ h. h: X → Y ∧ f ∘⇩c h = g)"
unfolding factors_through_def
(*goal: ‹(∃h. h : domain g → domain f ∧ f ∘⇩c h = g) = (∃h. h : X → Y ∧ f ∘⇩c h = g)›*)
using assms (*‹g : X → Z› ‹f : Y → Z›*) by (simp add: cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*))
text ‹The lemma below corresponds to Exercise 2.1.33 in Halvorson.›
lemma xfactorthru_equalizer_iff_fx_eq_gx:
assumes "f: X→ Y" "g:X → Y" "equalizer E m f g" "x∈⇩c X"
shows "x factorsthru m ⟷ f ∘⇩c x = g ∘⇩c x"
proof (safe)
(*goals:
1. ‹x factorsthru m ⟹ f ∘⇩c x = g ∘⇩c x›
2. ‹f ∘⇩c x = g ∘⇩c x ⟹ x factorsthru m›*)
assume LHS: "x factorsthru m" (*‹(x::cfunc) factorsthru (m::cfunc)›*)
then show "f ∘⇩c x = g ∘⇩c x"
using assms(3) (*‹equalizer E m f g›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_associative (*‹⟦domain ?h = codomain ?g; domain ?g = codomain ?f⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) equalizer_def (*‹equalizer ?E ?m ?f ?g = (∃X Y. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) factors_through_def (*‹?g factorsthru ?f = (∃h. h : domain ?g → domain ?f ∧ ?f ∘⇩c h = ?g)›*) by auto
next
(*goal: ‹(f::cfunc) ∘⇩c (x::cfunc) = (g::cfunc) ∘⇩c x ⟹ x factorsthru (m::cfunc)›*)
assume RHS: "f ∘⇩c x = g ∘⇩c x" (*‹(f::cfunc) ∘⇩c (x::cfunc) = (g::cfunc) ∘⇩c x›*)
then show "x factorsthru m"
unfolding cfunc_type_def factors_through_def
(*goal: ‹∃h::cfunc. (domain h = domain (x::cfunc) ∧ codomain h = domain (m::cfunc)) ∧ m ∘⇩c h = x›*)
by (metis RHS (*‹f ∘⇩c x = g ∘⇩c x›*) assms( (*‹f : X → Y› ‹equalizer E m f g› ‹x ∈⇩c X›*) 1,3,4) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) equalizer_def (*‹equalizer ?E ?m ?f ?g = (∃X Y. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*))
qed
text ‹The definition below corresponds to Definition 2.1.37 in Halvorson.›
definition subobject_of :: "cset × cfunc ⇒ cset ⇒ bool" (infix "⊆⇩c" 50)
where "B ⊆⇩c X ⟷ (snd B : fst B → X ∧ monomorphism (snd B))"
lemma subobject_of_def2:
"(B,m) ⊆⇩c X = (m : B → X ∧ monomorphism m)"
by (simp add: subobject_of_def (*‹(?B ⊆⇩c ?X) = (snd ?B : fst ?B → ?X ∧ monomorphism (snd ?B))›*))
definition relative_subset :: "cset × cfunc ⇒ cset ⇒ cset × cfunc ⇒ bool" ("_⊆⇘_⇙_" [51,50,51]50)
where "B ⊆⇘X⇙ A ⟷
(snd B : fst B → X ∧ monomorphism (snd B) ∧ snd A : fst A → X ∧ monomorphism (snd A)
∧ (∃ k. k: fst B → fst A ∧ snd A ∘⇩c k = snd B))"
lemma relative_subset_def2:
"(B,m) ⊆⇘X⇙ (A,n) = (m : B → X ∧ monomorphism m ∧ n : A → X ∧ monomorphism n
∧ (∃ k. k: B → A ∧ n ∘⇩c k = m))"
unfolding relative_subset_def
(*goal: ‹(snd (B, m) : fst (B, m) → X ∧ monomorphism (snd (B, m)) ∧ snd (A, n) : fst (A, n) → X ∧ monomorphism (snd (A, n)) ∧ (∃k. k : fst (B, m) → fst (A, n) ∧ snd (A, n) ∘⇩c k = snd (B, m))) = (m : B → X ∧ monomorphism m ∧ n : A → X ∧ monomorphism n ∧ (∃k. k : B → A ∧ n ∘⇩c k = m))›*)
by auto
lemma subobject_is_relative_subset: "(B,m) ⊆⇩c A ⟷ (B,m) ⊆⇘A⇙ (A, id(A))"
unfolding relative_subset_def2 subobject_of_def2
(*goal: ‹(m : B → A ∧ monomorphism m) = (m : B → A ∧ monomorphism m ∧ id⇩c A : A → A ∧ monomorphism (id⇩c A) ∧ (∃k. k : B → A ∧ id⇩c A ∘⇩c k = m))›*)
using cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) id_isomorphism (*‹isomorphism (id⇩c ?X)›*) id_left_unit (*‹id⇩c (codomain ?f) ∘⇩c ?f = ?f›*) id_type (*‹id⇩c ?X : ?X → ?X›*) iso_imp_epi_and_monic (*‹isomorphism ?f ⟹ epimorphism ?f ∧ monomorphism ?f›*) by auto
text ‹The definition below corresponds to Definition 2.1.39 in Halvorson.›
definition relative_member :: "cfunc ⇒ cset ⇒ cset × cfunc ⇒ bool" ("_ ∈⇘_⇙ _" [51,50,51]50) where
"x ∈⇘X⇙ B ⟷ (x ∈⇩c X ∧ monomorphism (snd B) ∧ snd B : fst B → X ∧ x factorsthru (snd B))"
lemma relative_member_def2:
"x ∈⇘X⇙ (B, m) = (x ∈⇩c X ∧ monomorphism m ∧ m : B → X ∧ x factorsthru m)"
unfolding relative_member_def
(*goal: ‹(x ∈⇩c X ∧ monomorphism (snd (B, m)) ∧ snd (B, m) : fst (B, m) → X ∧ x factorsthru snd (B, m)) = (x ∈⇩c X ∧ monomorphism m ∧ m : B → X ∧ x factorsthru m)›*)
by auto
text ‹The lemma below corresponds to Proposition 2.1.40 in Halvorson.›
lemma relative_subobject_member:
assumes "(A,n) ⊆⇘X⇙ (B,m)" "x ∈⇩c X"
shows "x ∈⇘X⇙ (A,n) ⟹ x ∈⇘X⇙ (B,m)"
using assms (*‹(A, n)⊆⇘X⇙(B, m)› ‹x ∈⇩c X›*) unfolding relative_member_def2 relative_subset_def2
(*goal: ‹x ∈⇩c X ∧ monomorphism n ∧ n : A → X ∧ x factorsthru n ⟹ x ∈⇩c X ∧ monomorphism m ∧ m : B → X ∧ x factorsthru m›*)
proof (clarify)
(*goal: ‹⋀k. ⟦x ∈⇩c X; x ∈⇩c X; m ∘⇩c k : A → X; monomorphism (m ∘⇩c k); monomorphism (m ∘⇩c k); m ∘⇩c k : A → X; x factorsthru (m ∘⇩c k); m : B → X; monomorphism m; k : A → B; n = m ∘⇩c k⟧ ⟹ x factorsthru m›*)
fix k
assume m_type: "m : B → X" (*‹(m::cfunc) : (B::cset) → (X::cset)›*)
assume k_type: "k : A → B" (*‹(k::cfunc) : (A::cset) → (B::cset)›*)
assume m_monomorphism: "monomorphism m" (*‹monomorphism (m::cfunc)›*)
assume mk_monomorphism: "monomorphism (m ∘⇩c k)" (*‹monomorphism ((m::cfunc) ∘⇩c (k::cfunc))›*)
assume n_eq_mk: "n = m ∘⇩c k" (*‹(n::cfunc) = (m::cfunc) ∘⇩c (k::cfunc)›*)
assume factorsthru_mk: "x factorsthru (m ∘⇩c k)" (*‹(x::cfunc) factorsthru ((m::cfunc) ∘⇩c (k::cfunc))›*)
obtain a where a_assms: "a ∈⇩c A ∧ (m ∘⇩c k) ∘⇩c a = x"
(*goal: ‹(⋀a. a ∈⇩c A ∧ (m ∘⇩c k) ∘⇩c a = x ⟹ thesis) ⟹ thesis›*)
using assms(2) (*‹x ∈⇩c X›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) domain_comp (*‹domain ?g = codomain ?f ⟹ domain (?g ∘⇩c ?f) = domain ?f›*) factors_through_def (*‹?g factorsthru ?f = (∃h. h : domain ?g → domain ?f ∧ ?f ∘⇩c h = ?g)›*) factorsthru_mk (*‹x factorsthru (m ∘⇩c k)›*) k_type (*‹k : A → B›*) m_type (*‹(m::cfunc) : (B::cset) → (X::cset)›*) by auto
then show "x factorsthru m "
unfolding factors_through_def
(*goal: ‹∃h. h : domain x → domain m ∧ m ∘⇩c h = x›*)
using cfunc_type_def (*‹((?f::cfunc) : (?X::cset) → (?Y::cset)) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) k_type (*‹k : A → B›*) m_type (*‹(m::cfunc) : (B::cset) → (X::cset)›*) comp_associative (*‹⟦domain ?h = codomain ?g; domain ?g = codomain ?f⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) apply (intro exI[where x="k ∘⇩c a"] (*‹?P (k ∘⇩c a) ⟹ ∃x. ?P x›*))
(*goal: ‹∃h. h : domain x → domain m ∧ m ∘⇩c h = x›*)
by auto
qed
subsection ‹Inverse Image›
text‹The definition below corresponds to a definition given by a diagram between Definition 2.1.37 and Proposition 2.1.38 in Halvorson.›
definition inverse_image :: "cfunc ⇒ cset ⇒ cfunc ⇒ cset" ("_⁻¹⦇_⦈⇘_⇙" [101,0,0]100) where
"inverse_image f B m = (SOME A. ∃ X Y k. f : X → Y ∧ m : B → Y ∧ monomorphism m ∧
equalizer A k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B))"
lemma inverse_image_is_equalizer:
assumes "m : B → Y" "f : X → Y" "monomorphism m"
shows "∃k. equalizer (f⁻¹⦇B⦈⇘m⇙) k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)"
proof (-)
(*goal: ‹∃k::cfunc. equalizer ((f::cfunc)⁻¹⦇B::cset⦈⇘m::cfunc⇙) k (f ∘⇩c left_cart_proj (X::cset) B) (m ∘⇩c right_cart_proj X B)›*)
obtain A and k where "equalizer A k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)"
(*goal: ‹(⋀A k. equalizer A k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B) ⟹ thesis) ⟹ thesis›*)
by (meson assms( (*‹(m::cfunc) : (B::cset) → (Y::cset)› ‹(f::cfunc) : (X::cset) → (Y::cset)›*) 1,2) comp_type (*‹⟦(?f::cfunc) : (?X::cset) → (?Y::cset); (?g::cfunc) : ?Y → (?Z::cset)⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) equalizer_exists (*‹⟦(?f::cfunc) : (?X::cset) → (?Y::cset); (?g::cfunc) : ?X → ?Y⟧ ⟹ ∃(E::cset) m::cfunc. equalizer E m ?f ?g›*) left_cart_proj_type (*‹left_cart_proj (?X::cset) (?Y::cset) : ?X ×⇩c ?Y → ?X›*) right_cart_proj_type (*‹right_cart_proj (?X::cset) (?Y::cset) : ?X ×⇩c ?Y → ?Y›*))
then show "∃k. equalizer (inverse_image f B m) k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)"
unfolding inverse_image_def
(*goal: ‹∃k. equalizer (SOME A. ∃X Y k. f : X → Y ∧ m : B → Y ∧ monomorphism m ∧ equalizer A k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)) k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)›*)
using assms (*‹(m::cfunc) : (B::cset) → (Y::cset)› ‹f : X → Y› ‹monomorphism m›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) apply (subst someI2_ex (*‹⟦∃a. ?P a; ⋀x. ?P x ⟹ ?Q x⟧ ⟹ ?Q (SOME x. ?P x)›*))
(*goals:
1. ‹⟦equalizer A k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B); m : B → Y; f : X → Y; monomorphism m; ⋀f X Y. (f : X → Y) = (domain f = X ∧ codomain f = Y)⟧ ⟹ ∃a X Y k. f : X → Y ∧ m : B → Y ∧ monomorphism m ∧ equalizer a k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)›
2. ‹⋀x. ⟦equalizer A k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B); m : B → Y; f : X → Y; monomorphism m; ⋀f X Y. (f : X → Y) = (domain f = X ∧ codomain f = Y); ∃X Y k. f : X → Y ∧ m : B → Y ∧ monomorphism m ∧ equalizer x k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)⟧ ⟹ ∃k. equalizer x k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)›
3. ‹⟦equalizer A k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B); m : B → Y; f : X → Y; monomorphism m; ⋀f X Y. (f : X → Y) = (domain f = X ∧ codomain f = Y)⟧ ⟹ True›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
qed
definition inverse_image_mapping :: "cfunc ⇒ cset ⇒ cfunc ⇒ cfunc" where
"inverse_image_mapping f B m = (SOME k. ∃ X Y. f : X → Y ∧ m : B → Y ∧ monomorphism m ∧
equalizer (inverse_image f B m) k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B))"
lemma inverse_image_is_equalizer2:
assumes "m : B → Y" "f : X → Y" "monomorphism m"
shows "equalizer (inverse_image f B m) (inverse_image_mapping f B m) (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)"
proof (-)
(*goal: ‹equalizer (f⁻¹⦇B⦈⇘m⇙) (inverse_image_mapping f B m) (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)›*)
obtain k where "equalizer (inverse_image f B m) k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)"
(*goal: ‹(⋀k. equalizer (f⁻¹⦇B⦈⇘m⇙) k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B) ⟹ thesis) ⟹ thesis›*)
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism m›*) inverse_image_is_equalizer (*‹⟦?m : ?B → ?Y; ?f : ?X → ?Y; monomorphism ?m⟧ ⟹ ∃k. equalizer (?f⁻¹⦇?B⦈⇘?m⇙) k (?f ∘⇩c left_cart_proj ?X ?B) (?m ∘⇩c right_cart_proj ?X ?B)›*) by blast
then have "∃ X Y. f : X → Y ∧ m : B → Y ∧ monomorphism m ∧
equalizer (inverse_image f B m) (inverse_image_mapping f B m) (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)"
unfolding inverse_image_mapping_def
(*goal: ‹∃X Y. f : X → Y ∧ m : B → Y ∧ monomorphism m ∧ equalizer (f⁻¹⦇B⦈⇘m⇙) (SOME k. ∃X Y. f : X → Y ∧ m : B → Y ∧ monomorphism m ∧ equalizer (f⁻¹⦇B⦈⇘m⇙) k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)) (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)›*)
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism (m::cfunc)›*) apply (subst someI_ex (*‹∃x. ?P x ⟹ ?P (SOME x. ?P x)›*))
(*goals:
1. ‹⟦equalizer (f⁻¹⦇B⦈⇘m⇙) k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B); m : B → Y; f : X → Y; monomorphism m⟧ ⟹ ∃x X Y. f : X → Y ∧ m : B → Y ∧ monomorphism m ∧ equalizer (f⁻¹⦇B⦈⇘m⇙) x (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)›
2. ‹⟦equalizer (f⁻¹⦇B⦈⇘m⇙) k (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B); m : B → Y; f : X → Y; monomorphism m⟧ ⟹ True›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
then show "equalizer (inverse_image f B m) (inverse_image_mapping f B m) (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)"
using assms(2) (*‹f : X → Y›*) cfunc_type_def (*‹((?f::cfunc) : (?X::cset) → (?Y::cset)) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) by auto
qed
lemma inverse_image_mapping_type[type_rule]:
assumes "m : B → Y" "f : X → Y" "monomorphism m"
shows "inverse_image_mapping f B m : (inverse_image f B m) → X ×⇩c B"
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism m›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) domain_comp (*‹domain ?g = codomain ?f ⟹ domain (?g ∘⇩c ?f) = domain ?f›*) equalizer_def (*‹equalizer (?E::cset) (?m::cfunc) (?f::cfunc) (?g::cfunc) = (∃(X::cset) Y::cset. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀(h::cfunc) F::cset. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k::cfunc. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) inverse_image_is_equalizer2 (*‹⟦?m : ?B → ?Y; ?f : ?X → ?Y; monomorphism ?m⟧ ⟹ equalizer (?f⁻¹⦇?B⦈⇘?m⇙) (inverse_image_mapping ?f ?B ?m) (?f ∘⇩c left_cart_proj ?X ?B) (?m ∘⇩c right_cart_proj ?X ?B)›*) left_cart_proj_type (*‹left_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?X›*) by auto
lemma inverse_image_mapping_eq:
assumes "m : B → Y" "f : X → Y" "monomorphism m"
shows "f ∘⇩c left_cart_proj X B ∘⇩c inverse_image_mapping f B m
= m ∘⇩c right_cart_proj X B ∘⇩c inverse_image_mapping f B m"
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism (m::cfunc)›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_associative (*‹⟦domain (?h::cfunc) = codomain (?g::cfunc); domain ?g = codomain (?f::cfunc)⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) equalizer_def (*‹equalizer ?E ?m ?f ?g = (∃X Y. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) inverse_image_is_equalizer2 (*‹⟦(?m::cfunc) : (?B::cset) → (?Y::cset); (?f::cfunc) : (?X::cset) → ?Y; monomorphism ?m⟧ ⟹ equalizer (?f⁻¹⦇?B⦈⇘?m⇙) (inverse_image_mapping ?f ?B ?m) (?f ∘⇩c left_cart_proj ?X ?B) (?m ∘⇩c right_cart_proj ?X ?B)›*) apply -
(*goal: ‹f ∘⇩c left_cart_proj X B ∘⇩c inverse_image_mapping f B m = m ∘⇩c right_cart_proj X B ∘⇩c inverse_image_mapping f B m›*)
apply typecheck_cfuncs
(*goal: ‹⟦m : B → Y; f : X → Y; monomorphism m; ⋀f X Y. (f : X → Y) = (domain f = X ∧ codomain f = Y); ⋀h g f. ⟦domain h = codomain g; domain g = codomain f⟧ ⟹ h ∘⇩c g ∘⇩c f = (h ∘⇩c g) ∘⇩c f; ⋀E m f g. equalizer E m f g = (∃X Y. f : X → Y ∧ g : X → Y ∧ m : E → X ∧ f ∘⇩c m = g ∘⇩c m ∧ (∀h F. h : F → X ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h))); ⋀m B Y f X. ⟦m : B → Y; f : X → Y; monomorphism m⟧ ⟹ equalizer (f⁻¹⦇B⦈⇘m⇙) (inverse_image_mapping f B m) (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B)⟧ ⟹ f ∘⇩c left_cart_proj X B ∘⇩c inverse_image_mapping f B m = m ∘⇩c right_cart_proj X B ∘⇩c inverse_image_mapping f B m›*)
by (smt (verit))
lemma inverse_image_mapping_monomorphism:
assumes "m : B → Y" "f : X → Y" "monomorphism m"
shows "monomorphism (inverse_image_mapping f B m)"
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism m›*) equalizer_is_monomorphism (*‹equalizer ?E ?m ?f ?g ⟹ monomorphism ?m›*) inverse_image_is_equalizer2 (*‹⟦?m : ?B → ?Y; ?f : ?X → ?Y; monomorphism ?m⟧ ⟹ equalizer (?f⁻¹⦇?B⦈⇘?m⇙) (inverse_image_mapping ?f ?B ?m) (?f ∘⇩c left_cart_proj ?X ?B) (?m ∘⇩c right_cart_proj ?X ?B)›*) by blast
text ‹The lemma below is the dual of Proposition 2.1.38 in Halvorson.›
lemma inverse_image_monomorphism:
assumes "m : B → Y" "f : X → Y" "monomorphism m"
shows "monomorphism (left_cart_proj X B ∘⇩c inverse_image_mapping f B m)"
using assms (*‹m : B → Y› ‹(f::cfunc) : (X::cset) → (Y::cset)› ‹monomorphism m›*) apply typecheck_cfuncs
(*goal: ‹monomorphism (left_cart_proj X B ∘⇩c inverse_image_mapping f B m)›*)
apply (unfold monomorphism_def3 (*‹?f : ?X → ?Y ⟹ monomorphism ?f = (∀g h A. g : A → ?X ∧ h : A → ?X ⟶ ?f ∘⇩c g = ?f ∘⇩c h ⟶ g = h)›*))
(*goal: ‹⟦left_cart_proj (X::cset) (B::cset) ∘⇩c inverse_image_mapping (f::cfunc) B (m::cfunc) : f⁻¹⦇B⦈⇘m⇙ → X; left_cart_proj X B : X ×⇩c B → X; inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X ×⇩c B; f : X → (Y::cset); m : B → Y⟧ ⟹ monomorphism (left_cart_proj X B ∘⇩c inverse_image_mapping f B m)›*)
proof (clarify)
(*goal: ‹⋀g h A. ⟦left_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X; left_cart_proj X B : X ×⇩c B → X; inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X ×⇩c B; f : X → Y; m : B → Y; g : A → f⁻¹⦇B⦈⇘m⇙; h : A → f⁻¹⦇B⦈⇘m⇙; (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c g = (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h⟧ ⟹ g = h›*)
fix g and h and A
assume g_type: "g : A → (f⁻¹⦇B⦈⇘m⇙)" (*‹(g::cfunc) : (A::cset) → (f::cfunc)⁻¹⦇B::cset⦈⇘m::cfunc⇙›*)
assume h_type: "h : A → (f⁻¹⦇B⦈⇘m⇙)" (*‹(h::cfunc) : (A::cset) → (f::cfunc)⁻¹⦇B::cset⦈⇘m::cfunc⇙›*)
assume left_eq: "(left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c g
= (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h" (*‹(left_cart_proj (X::cset) (B::cset) ∘⇩c inverse_image_mapping (f::cfunc) B (m::cfunc)) ∘⇩c (g::cfunc) = (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c (h::cfunc)›*)
then have "f ∘⇩c (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c g
= f ∘⇩c (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h"
by auto
then have "m ∘⇩c (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c g
= m ∘⇩c (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h"
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism m›*) g_type (*‹g : A → f⁻¹⦇B⦈⇘m⇙›*) h_type (*‹h : A → f⁻¹⦇B⦈⇘m⇙›*) apply -
(*goal: ‹m ∘⇩c (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c g = m ∘⇩c (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h›*)
apply typecheck_cfuncs
(*goal: ‹⟦f ∘⇩c (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c g = f ∘⇩c (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h; m : B → Y; f : X → Y; monomorphism m; g : A → f⁻¹⦇B⦈⇘m⇙; h : A → f⁻¹⦇B⦈⇘m⇙⟧ ⟹ m ∘⇩c (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c g = m ∘⇩c (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h›*)
by (smt cfunc_type_def (*‹((?f::cfunc) : (?X::cset) → (?Y::cset)) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) codomain_comp (*‹domain (?g::cfunc) = codomain (?f::cfunc) ⟹ codomain (?g ∘⇩c ?f) = codomain ?g›*) comp_associative (*‹⟦domain (?h::cfunc) = codomain (?g::cfunc); domain ?g = codomain (?f::cfunc)⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) domain_comp (*‹domain (?g::cfunc) = codomain (?f::cfunc) ⟹ domain (?g ∘⇩c ?f) = domain ?f›*) inverse_image_mapping_eq (*‹⟦(?m::cfunc) : (?B::cset) → (?Y::cset); (?f::cfunc) : (?X::cset) → ?Y; monomorphism ?m⟧ ⟹ ?f ∘⇩c left_cart_proj ?X ?B ∘⇩c inverse_image_mapping ?f ?B ?m = ?m ∘⇩c right_cart_proj ?X ?B ∘⇩c inverse_image_mapping ?f ?B ?m›*) left_cart_proj_type (*‹left_cart_proj (?X::cset) (?Y::cset) : ?X ×⇩c ?Y → ?X›*))
then have right_eq: "(right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c g
= (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h"
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism m›*) g_type (*‹g : A → f⁻¹⦇B⦈⇘m⇙›*) h_type (*‹h : A → f⁻¹⦇B⦈⇘m⇙›*) monomorphism_def3 (*‹?f : ?X → ?Y ⟹ monomorphism ?f = (∀g h A. g : A → ?X ∧ h : A → ?X ⟶ ?f ∘⇩c g = ?f ∘⇩c h ⟶ g = h)›*) apply -
(*goal: ‹(right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c g = (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h›*)
apply typecheck_cfuncs
(*goal: ‹⟦m ∘⇩c (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c g = m ∘⇩c (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h; m : B → Y; f : X → Y; monomorphism m; g : A → f⁻¹⦇B⦈⇘m⇙; h : A → f⁻¹⦇B⦈⇘m⇙; ⋀f X Y. f : X → Y ⟹ monomorphism f = (∀g h A. g : A → X ∧ h : A → X ⟶ f ∘⇩c g = f ∘⇩c h ⟶ g = h)⟧ ⟹ (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c g = (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h›*)
by auto
then have "inverse_image_mapping f B m ∘⇩c g = inverse_image_mapping f B m ∘⇩c h"
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism m›*) g_type (*‹(g::cfunc) : (A::cset) → (f::cfunc)⁻¹⦇B::cset⦈⇘m::cfunc⇙›*) h_type (*‹h : A → f⁻¹⦇B⦈⇘m⇙›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_associative (*‹⟦domain ?h = codomain ?g; domain ?g = codomain ?f⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) left_eq (*‹(left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c g = (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h›*) left_cart_proj_type (*‹left_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?X›*) right_cart_proj_type (*‹right_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?Y›*) by (typecheck_cfuncs, subst cart_prod_eq (*‹⟦?a : ?Z → ?X ×⇩c ?Y; ?b : ?Z → ?X ×⇩c ?Y⟧ ⟹ (?a = ?b) = (left_cart_proj ?X ?Y ∘⇩c ?a = left_cart_proj ?X ?Y ∘⇩c ?b ∧ right_cart_proj ?X ?Y ∘⇩c ?a = right_cart_proj ?X ?Y ∘⇩c ?b)›*), auto)
then show "g = h"
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism m›*) g_type (*‹g : A → f⁻¹⦇B⦈⇘m⇙›*) h_type (*‹h : A → f⁻¹⦇B⦈⇘m⇙›*) inverse_image_mapping_monomorphism (*‹⟦?m : ?B → ?Y; ?f : ?X → ?Y; monomorphism ?m⟧ ⟹ monomorphism (inverse_image_mapping ?f ?B ?m)›*) inverse_image_mapping_type (*‹⟦?m : ?B → ?Y; ?f : ?X → ?Y; monomorphism ?m⟧ ⟹ inverse_image_mapping ?f ?B ?m : ?f⁻¹⦇?B⦈⇘?m⇙ → ?X ×⇩c ?B›*) monomorphism_def3 (*‹?f : ?X → ?Y ⟹ monomorphism ?f = (∀g h A. g : A → ?X ∧ h : A → ?X ⟶ ?f ∘⇩c g = ?f ∘⇩c h ⟶ g = h)›*) by blast
qed
definition inverse_image_subobject_mapping :: "cfunc ⇒ cset ⇒ cfunc ⇒ cfunc" ("[_⁻¹⦇_⦈⇘_⇙]map" [101,0,0]100) where
"[f⁻¹⦇B⦈⇘m⇙]map = left_cart_proj (domain f) B ∘⇩c inverse_image_mapping f B m"
lemma inverse_image_subobject_mapping_def2:
assumes "f : X → Y"
shows "[f⁻¹⦇B⦈⇘m⇙]map = left_cart_proj X B ∘⇩c inverse_image_mapping f B m"
using assms (*‹f : X → Y›*) unfolding inverse_image_subobject_mapping_def cfunc_type_def
(*goal: ‹left_cart_proj (domain f) B ∘⇩c inverse_image_mapping f B m = left_cart_proj X B ∘⇩c inverse_image_mapping f B m›*)
by auto
lemma inverse_image_subobject_mapping_type[type_rule]:
assumes "f : X → Y" "m : B → Y" "monomorphism m"
shows "[f⁻¹⦇B⦈⇘m⇙]map : f⁻¹⦇B⦈⇘m⇙ → X"
by (smt (verit, best) assms (*‹f : X → Y› ‹m : B → Y› ‹monomorphism m›*) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) inverse_image_mapping_type (*‹⟦?m : ?B → ?Y; ?f : ?X → ?Y; monomorphism ?m⟧ ⟹ inverse_image_mapping ?f ?B ?m : ?f⁻¹⦇?B⦈⇘?m⇙ → ?X ×⇩c ?B›*) inverse_image_subobject_mapping_def2 (*‹?f : ?X → ?Y ⟹ [?f⁻¹⦇?B⦈⇘?m⇙]map = left_cart_proj ?X ?B ∘⇩c inverse_image_mapping ?f ?B ?m›*) left_cart_proj_type (*‹left_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?X›*))
lemma inverse_image_subobject_mapping_mono:
assumes "f : X → Y" "m : B → Y" "monomorphism m"
shows "monomorphism ([f⁻¹⦇B⦈⇘m⇙]map)"
using assms (*‹f : X → Y› ‹m : B → Y› ‹monomorphism (m::cfunc)›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) inverse_image_monomorphism (*‹⟦(?m::cfunc) : (?B::cset) → (?Y::cset); (?f::cfunc) : (?X::cset) → ?Y; monomorphism ?m⟧ ⟹ monomorphism (left_cart_proj ?X ?B ∘⇩c inverse_image_mapping ?f ?B ?m)›*) inverse_image_subobject_mapping_def (*‹[(?f::cfunc)⁻¹⦇?B::cset⦈⇘?m::cfunc⇙]map = left_cart_proj (domain ?f) ?B ∘⇩c inverse_image_mapping ?f ?B ?m›*) by fastforce
lemma inverse_image_subobject:
assumes "m : B → Y" "f : X → Y" "monomorphism m"
shows "(f⁻¹⦇B⦈⇘m⇙, [f⁻¹⦇B⦈⇘m⇙]map) ⊆⇩c X"
unfolding subobject_of_def2
(*goal: ‹[f⁻¹⦇B⦈⇘m⇙]map : f⁻¹⦇B⦈⇘m⇙ → X ∧ monomorphism ([f⁻¹⦇B⦈⇘m⇙]map)›*)
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism m›*) inverse_image_subobject_mapping_mono (*‹⟦?f : ?X → ?Y; ?m : ?B → ?Y; monomorphism ?m⟧ ⟹ monomorphism ([?f⁻¹⦇?B⦈⇘?m⇙]map)›*) inverse_image_subobject_mapping_type (*‹⟦?f : ?X → ?Y; ?m : ?B → ?Y; monomorphism ?m⟧ ⟹ [?f⁻¹⦇?B⦈⇘?m⇙]map : ?f⁻¹⦇?B⦈⇘?m⇙ → ?X›*) by force
lemma inverse_image_pullback:
assumes "m : B → Y" "f : X → Y" "monomorphism m"
shows "is_pullback (f⁻¹⦇B⦈⇘m⇙) B X Y
(right_cart_proj X B ∘⇩c inverse_image_mapping f B m) m
(left_cart_proj X B ∘⇩c inverse_image_mapping f B m) f"
unfolding is_pullback_def
(*goal: ‹right_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → B ∧ m : B → Y ∧ left_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X ∧ f : X → Y ∧ m ∘⇩c right_cart_proj X B ∘⇩c inverse_image_mapping f B m = f ∘⇩c left_cart_proj X B ∘⇩c inverse_image_mapping f B m ∧ (∀Z k h. k : Z → B ∧ h : Z → X ∧ m ∘⇩c k = f ∘⇩c h ⟶ (∃!j. j : Z → f⁻¹⦇B⦈⇘m⇙ ∧ (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = k ∧ (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = h))›*)
using assms (*‹(m::cfunc) : (B::cset) → (Y::cset)› ‹f : X → Y› ‹monomorphism m›*) proof (safe)
(*goals:
1. ‹⟦m : B → Y; f : X → Y; monomorphism m⟧ ⟹ right_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → B›
2. ‹⟦m : B → Y; f : X → Y; monomorphism m⟧ ⟹ left_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X›
3. ‹⟦m : B → Y; f : X → Y; monomorphism m⟧ ⟹ m ∘⇩c right_cart_proj X B ∘⇩c inverse_image_mapping f B m = f ∘⇩c left_cart_proj X B ∘⇩c inverse_image_mapping f B m›
4. ‹⋀Z k h. ⟦m : B → Y; f : X → Y; monomorphism m; k : Z → B; h : Z → X; m ∘⇩c k = f ∘⇩c h⟧ ⟹ ∃j. j : Z → f⁻¹⦇B⦈⇘m⇙ ∧ (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = k ∧ (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = h›
5. ‹⋀Z k h j y. ⟦m : B → Y; f : X → Y; monomorphism m; (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j : Z → B; (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j : Z → X; m ∘⇩c (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = f ∘⇩c (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j; j : Z → f⁻¹⦇B⦈⇘m⇙; y : Z → f⁻¹⦇B⦈⇘m⇙; (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c y = (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j; (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c y = (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j⟧ ⟹ j = y›*)
show right_type: "right_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → B"
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism m›*) cfunc_type_def (*‹((?f::cfunc) : (?X::cset) → (?Y::cset)) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) codomain_comp (*‹domain ?g = codomain ?f ⟹ codomain (?g ∘⇩c ?f) = codomain ?g›*) domain_comp (*‹domain ?g = codomain ?f ⟹ domain (?g ∘⇩c ?f) = domain ?f›*) inverse_image_mapping_type (*‹⟦?m : ?B → ?Y; ?f : ?X → ?Y; monomorphism ?m⟧ ⟹ inverse_image_mapping ?f ?B ?m : ?f⁻¹⦇?B⦈⇘?m⇙ → ?X ×⇩c ?B›*) right_cart_proj_type (*‹right_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?Y›*) by auto
show left_type: "left_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X"
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism m›*) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) inverse_image_subobject (*‹⟦?m : ?B → ?Y; ?f : ?X → ?Y; monomorphism ?m⟧ ⟹ (?f⁻¹⦇?B⦈⇘?m⇙, [?f⁻¹⦇?B⦈⇘?m⇙]map) ⊆⇩c ?X›*) subobject_of_def (*‹(?B ⊆⇩c ?X) = (snd ?B : fst ?B → ?X ∧ monomorphism (snd ?B))›*) by typecheck_cfuncs
show "m ∘⇩c right_cart_proj X B ∘⇩c inverse_image_mapping f B m =
f ∘⇩c left_cart_proj X B ∘⇩c inverse_image_mapping f B m"
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism m›*) inverse_image_mapping_eq (*‹⟦?m : ?B → ?Y; ?f : ?X → ?Y; monomorphism ?m⟧ ⟹ ?f ∘⇩c left_cart_proj ?X ?B ∘⇩c inverse_image_mapping ?f ?B ?m = ?m ∘⇩c right_cart_proj ?X ?B ∘⇩c inverse_image_mapping ?f ?B ?m›*) by auto
next
(*goals:
1. ‹⋀Z k h. ⟦m : B → Y; f : X → Y; monomorphism m; k : Z → B; h : Z → X; m ∘⇩c k = f ∘⇩c h⟧ ⟹ ∃j. j : Z → f⁻¹⦇B⦈⇘m⇙ ∧ (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = k ∧ (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = h›
2. ‹⋀Z k h j y. ⟦m : B → Y; f : X → Y; monomorphism m; (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j : Z → B; (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j : Z → X; m ∘⇩c (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = f ∘⇩c (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j; j : Z → f⁻¹⦇B⦈⇘m⇙; y : Z → f⁻¹⦇B⦈⇘m⇙; (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c y = (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j; (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c y = (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j⟧ ⟹ j = y›*)
fix Z and k and h
assume k_type: "k : Z → B" and h_type: "h : Z → X" (*‹(k::cfunc) : (Z::cset) → (B::cset)› ‹(h::cfunc) : (Z::cset) → (X::cset)›*)
assume mk_eq_fh: "m ∘⇩c k = f ∘⇩c h" (*‹(m::cfunc) ∘⇩c (k::cfunc) = (f::cfunc) ∘⇩c (h::cfunc)›*)
have "equalizer (f⁻¹⦇B⦈⇘m⇙) (inverse_image_mapping f B m) (f ∘⇩c left_cart_proj X B) (m ∘⇩c right_cart_proj X B )"
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism (m::cfunc)›*) inverse_image_is_equalizer2 (*‹⟦?m : ?B → ?Y; ?f : ?X → ?Y; monomorphism ?m⟧ ⟹ equalizer (?f⁻¹⦇?B⦈⇘?m⇙) (inverse_image_mapping ?f ?B ?m) (?f ∘⇩c left_cart_proj ?X ?B) (?m ∘⇩c right_cart_proj ?X ?B)›*) by blast
then have "∀h F. h : F → (X ×⇩c B)
∧ (f ∘⇩c left_cart_proj X B) ∘⇩c h = (m ∘⇩c right_cart_proj X B) ∘⇩c h ⟶
(∃!u. u : F → (f⁻¹⦇B⦈⇘m⇙) ∧ inverse_image_mapping f B m ∘⇩c u = h)"
unfolding equalizer_def
(*goal: ‹∀h F. h : F → X ×⇩c B ∧ (f ∘⇩c left_cart_proj X B) ∘⇩c h = (m ∘⇩c right_cart_proj X B) ∘⇩c h ⟶ (∃!u. u : F → f⁻¹⦇B⦈⇘m⇙ ∧ inverse_image_mapping f B m ∘⇩c u = h)›*)
using assms(2) (*‹f : X → Y›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) domain_comp (*‹domain ?g = codomain ?f ⟹ domain (?g ∘⇩c ?f) = domain ?f›*) left_cart_proj_type (*‹left_cart_proj (?X::cset) (?Y::cset) : ?X ×⇩c ?Y → ?X›*) by auto
then have "⟨h,k⟩ : Z → X ×⇩c B ⟹
(f ∘⇩c left_cart_proj X B) ∘⇩c ⟨h,k⟩ = (m ∘⇩c right_cart_proj X B) ∘⇩c ⟨h,k⟩ ⟹
(∃!u. u : Z → (f⁻¹⦇B⦈⇘m⇙) ∧ inverse_image_mapping f B m ∘⇩c u = ⟨h,k⟩)"
by auto
then have "∃!u. u : Z → (f⁻¹⦇B⦈⇘m⇙) ∧ inverse_image_mapping f B m ∘⇩c u = ⟨h,k⟩"
using k_type (*‹k : Z → B›*) h_type (*‹(h::cfunc) : (Z::cset) → (X::cset)›*) assms (*‹(m::cfunc) : (B::cset) → (Y::cset)› ‹(f::cfunc) : (X::cset) → (Y::cset)› ‹monomorphism m›*) apply -
(*goal: ‹∃!u. u : Z → f⁻¹⦇B⦈⇘m⇙ ∧ inverse_image_mapping f B m ∘⇩c u = ⟨h,k⟩›*)
apply typecheck_cfuncs
(*goal: ‹⟦⟦⟨h,k⟩ : Z → X ×⇩c B; (f ∘⇩c left_cart_proj X B) ∘⇩c ⟨h,k⟩ = (m ∘⇩c right_cart_proj X B) ∘⇩c ⟨h,k⟩⟧ ⟹ ∃!u. u : Z → f⁻¹⦇B⦈⇘m⇙ ∧ inverse_image_mapping f B m ∘⇩c u = ⟨h,k⟩; k : Z → B; h : Z → X; m : B → Y; f : X → Y; monomorphism m⟧ ⟹ ∃!u. u : Z → f⁻¹⦇B⦈⇘m⇙ ∧ inverse_image_mapping f B m ∘⇩c u = ⟨h,k⟩›*)
by (smt comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) left_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ left_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?f›*) left_cart_proj_type (*‹left_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?X›*) mk_eq_fh (*‹m ∘⇩c k = f ∘⇩c h›*) right_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ right_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?g›*) right_cart_proj_type (*‹right_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?Y›*))
then show "∃j. j : Z → (f⁻¹⦇B⦈⇘m⇙) ∧
(right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = k ∧
(left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = h"
proof (clarify)
(*goal: ‹⋀u. ⟦∀y y'. (y : Z → f⁻¹⦇B⦈⇘m⇙ ∧ inverse_image_mapping f B m ∘⇩c y = ⟨h,k⟩) ∧ y' : Z → f⁻¹⦇B⦈⇘m⇙ ∧ inverse_image_mapping f B m ∘⇩c y' = ⟨h,k⟩ ⟶ y = y'; u : Z → f⁻¹⦇B⦈⇘m⇙; inverse_image_mapping f B m ∘⇩c u = ⟨h,k⟩⟧ ⟹ ∃j. j : Z → f⁻¹⦇B⦈⇘m⇙ ∧ (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = k ∧ (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = h›*)
fix u
assume u_type[type_rule]: "u : Z → (f⁻¹⦇B⦈⇘m⇙)" (*‹(u::cfunc) : (Z::cset) → (f::cfunc)⁻¹⦇B::cset⦈⇘m::cfunc⇙›*)
assume u_eq: "inverse_image_mapping f B m ∘⇩c u = ⟨h,k⟩" (*‹inverse_image_mapping (f::cfunc) (B::cset) (m::cfunc) ∘⇩c (u::cfunc) = ⟨h::cfunc,k::cfunc⟩›*)
show "∃j. j : Z → f⁻¹⦇B⦈⇘m⇙ ∧
(right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = k ∧
(left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = h"
proof (rule exI[where x=u] (*‹(?P::cfunc ⇒ bool) (u::cfunc) ⟹ ∃x::cfunc. ?P x›*), typecheck_cfuncs, safe)
(*goals:
1. ‹⟦u : Z → f⁻¹⦇B⦈⇘m⇙; ⋀Za. right_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → Za ⟹ (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c u : Z → Za; ⋀Xa. inverse_image_mapping f B m : Xa → X ×⇩c B ⟹ right_cart_proj X B ∘⇩c inverse_image_mapping f B m : Xa → B; right_cart_proj X B : X ×⇩c B → B; ⋀Y X. ⟦m : B → Y; f : X → Y; monomorphism m⟧ ⟹ inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X ×⇩c B; u : Z → f⁻¹⦇B⦈⇘m⇙; ⋀Za. left_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → Za ⟹ (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c u : Z → Za; ⋀Xa. inverse_image_mapping f B m : Xa → X ×⇩c B ⟹ left_cart_proj X B ∘⇩c inverse_image_mapping f B m : Xa → X; left_cart_proj X B : X ×⇩c B → X; ⋀Y X. ⟦m : B → Y; f : X → Y; monomorphism m⟧ ⟹ inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X ×⇩c B; u : Z → f⁻¹⦇B⦈⇘m⇙⟧ ⟹ (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c u = k›
2. ‹⟦u : Z → f⁻¹⦇B⦈⇘m⇙; ⋀Za. right_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → Za ⟹ (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c u : Z → Za; ⋀Xa. inverse_image_mapping f B m : Xa → X ×⇩c B ⟹ right_cart_proj X B ∘⇩c inverse_image_mapping f B m : Xa → B; right_cart_proj X B : X ×⇩c B → B; ⋀Y X. ⟦m : B → Y; f : X → Y; monomorphism m⟧ ⟹ inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X ×⇩c B; u : Z → f⁻¹⦇B⦈⇘m⇙; ⋀Za. left_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → Za ⟹ (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c u : Z → Za; ⋀Xa. inverse_image_mapping f B m : Xa → X ×⇩c B ⟹ left_cart_proj X B ∘⇩c inverse_image_mapping f B m : Xa → X; left_cart_proj X B : X ×⇩c B → X; ⋀Y X. ⟦m : B → Y; f : X → Y; monomorphism m⟧ ⟹ inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X ×⇩c B; u : Z → f⁻¹⦇B⦈⇘m⇙⟧ ⟹ (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c u = h›*)
show "(right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c u = k"
using assms (*‹m : B → Y› ‹(f::cfunc) : (X::cset) → (Y::cset)› ‹monomorphism m›*) u_type (*‹u : Z → f⁻¹⦇B⦈⇘m⇙›*) h_type (*‹h : Z → X›*) k_type (*‹(k::cfunc) : (Z::cset) → (B::cset)›*) u_eq (*‹inverse_image_mapping f B m ∘⇩c u = ⟨h,k⟩›*) apply -
(*goal: ‹(right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c u = k›*)
apply typecheck_cfuncs
(*goal: ‹⟦m : B → Y; f : X → Y; monomorphism m; u : Z → f⁻¹⦇B⦈⇘m⇙; h : Z → X; k : Z → B; inverse_image_mapping f B m ∘⇩c u = ⟨h,k⟩⟧ ⟹ (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c u = k›*)
by (metis (full_types) comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) right_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ right_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?g›*))
show "(left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c u = h"
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism m›*) u_type (*‹u : Z → f⁻¹⦇B⦈⇘m⇙›*) h_type (*‹h : Z → X›*) k_type (*‹k : Z → B›*) u_eq (*‹inverse_image_mapping (f::cfunc) (B::cset) (m::cfunc) ∘⇩c (u::cfunc) = ⟨h::cfunc,k::cfunc⟩›*) apply -
(*goal: ‹(left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c u = h›*)
apply typecheck_cfuncs
(*goal: ‹⟦(m::cfunc) : (B::cset) → (Y::cset); (f::cfunc) : (X::cset) → Y; monomorphism m; (u::cfunc) : (Z::cset) → f⁻¹⦇B⦈⇘m⇙; (h::cfunc) : Z → X; (k::cfunc) : Z → B; inverse_image_mapping f B m ∘⇩c u = ⟨h,k⟩⟧ ⟹ (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c u = h›*)
by (metis (full_types) comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) left_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ left_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?f›*))
qed
qed
next
(*goal: ‹⋀Z k h j y. ⟦m : B → Y; f : X → Y; monomorphism m; (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j : Z → B; (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j : Z → X; m ∘⇩c (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = f ∘⇩c (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j; j : Z → f⁻¹⦇B⦈⇘m⇙; y : Z → f⁻¹⦇B⦈⇘m⇙; (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c y = (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j; (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c y = (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j⟧ ⟹ j = y›*)
fix Z and j and y
assume j_type: "j : Z → (f⁻¹⦇B⦈⇘m⇙)" (*‹(j::cfunc) : (Z::cset) → (f::cfunc)⁻¹⦇B::cset⦈⇘m::cfunc⇙›*)
assume y_type: "y : Z → (f⁻¹⦇B⦈⇘m⇙)" (*‹(y::cfunc) : (Z::cset) → (f::cfunc)⁻¹⦇B::cset⦈⇘m::cfunc⇙›*)
assume "(left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c y =
(left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j" (*‹(left_cart_proj (X::cset) (B::cset) ∘⇩c inverse_image_mapping (f::cfunc) B (m::cfunc)) ∘⇩c (y::cfunc) = (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c (j::cfunc)›*)
then show "j = y"
using assms (*‹m : B → Y› ‹f : X → Y› ‹monomorphism (m::cfunc)›*) j_type (*‹(j::cfunc) : (Z::cset) → (f::cfunc)⁻¹⦇B::cset⦈⇘m::cfunc⇙›*) y_type (*‹y : Z → f⁻¹⦇B⦈⇘m⇙›*) inverse_image_mapping_type (*‹⟦(?m::cfunc) : (?B::cset) → (?Y::cset); (?f::cfunc) : (?X::cset) → ?Y; monomorphism ?m⟧ ⟹ inverse_image_mapping ?f ?B ?m : ?f⁻¹⦇?B⦈⇘?m⇙ → ?X ×⇩c ?B›*) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) by (smt (verit, ccfv_threshold) inverse_image_monomorphism (*‹⟦(?m::cfunc) : (?B::cset) → (?Y::cset); (?f::cfunc) : (?X::cset) → ?Y; monomorphism ?m⟧ ⟹ monomorphism (left_cart_proj ?X ?B ∘⇩c inverse_image_mapping ?f ?B ?m)›*) left_cart_proj_type (*‹left_cart_proj (?X::cset) (?Y::cset) : ?X ×⇩c ?Y → ?X›*) monomorphism_def3 (*‹(?f::cfunc) : (?X::cset) → (?Y::cset) ⟹ monomorphism ?f = (∀(g::cfunc) (h::cfunc) A::cset. g : A → ?X ∧ h : A → ?X ⟶ ?f ∘⇩c g = ?f ∘⇩c h ⟶ g = h)›*))
qed
text ‹The lemma below corresponds to Proposition 2.1.41 in Halvorson.›
lemma in_inverse_image:
assumes "f : X → Y" "(B,m) ⊆⇩c Y" "x ∈⇩c X"
shows "(x ∈⇘X⇙ (f⁻¹⦇B⦈⇘m⇙, left_cart_proj X B ∘⇩c inverse_image_mapping f B m)) = (f ∘⇩c x ∈⇘Y⇙ (B,m))"
proof (standard)
(*goals:
1. ‹x ∈⇘X⇙ (f⁻¹⦇B⦈⇘m⇙, left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ⟹ f ∘⇩c x ∈⇘Y⇙ (B, m)›
2. ‹f ∘⇩c x ∈⇘Y⇙ (B, m) ⟹ x ∈⇘X⇙ (f⁻¹⦇B⦈⇘m⇙, left_cart_proj X B ∘⇩c inverse_image_mapping f B m)›*)
have m_type: "m : B → Y" "monomorphism m"
using assms(2) (*‹(B, m) ⊆⇩c Y›*) unfolding subobject_of_def2
(*goals:
1. ‹m : B → Y›
2. ‹monomorphism m›*)
apply -
(*goals:
1. ‹m : B → Y ∧ monomorphism m ⟹ m : B → Y›
2. ‹m : B → Y ∧ monomorphism m ⟹ monomorphism m›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
assume "x ∈⇘X⇙ (f⁻¹⦇B⦈⇘m⇙, left_cart_proj X B ∘⇩c inverse_image_mapping f B m)" (*‹(x::cfunc) ∈⇘(X::cset)⇙ ((f::cfunc)⁻¹⦇B::cset⦈⇘m::cfunc⇙, left_cart_proj X B ∘⇩c inverse_image_mapping f B m)›*)
then obtain h where h_type: "h ∈⇩c (f⁻¹⦇B⦈⇘m⇙)" and h_def: "(left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h = x"
(*goal: ‹(⋀h. ⟦h ∈⇩c f⁻¹⦇B⦈⇘m⇙; (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h = x⟧ ⟹ thesis) ⟹ thesis›*)
unfolding relative_member_def2 factors_through_def
(*goal: ‹(⋀h. ⟦h ∈⇩c f⁻¹⦇B⦈⇘m⇙; (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h = x⟧ ⟹ thesis) ⟹ thesis›*)
by (auto simp add: cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*))
then have "f ∘⇩c x = f ∘⇩c left_cart_proj X B ∘⇩c inverse_image_mapping f B m ∘⇩c h"
using assms (*‹(f::cfunc) : (X::cset) → (Y::cset)› ‹(B, m) ⊆⇩c Y› ‹x ∈⇩c X›*) m_type (*‹m : B → Y› ‹monomorphism m›*) apply typecheck_cfuncs
(*goal: ‹f ∘⇩c x = f ∘⇩c left_cart_proj X B ∘⇩c inverse_image_mapping f B m ∘⇩c h›*)
by (simp add: comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) h_def (*‹(left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h = x›*))
then have "f ∘⇩c x = (f ∘⇩c left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h"
using assms (*‹f : X → Y› ‹(B, m) ⊆⇩c Y› ‹(x::cfunc) ∈⇩c (X::cset)›*) m_type (*‹m : B → Y› ‹monomorphism m›*) h_type (*‹h ∈⇩c f⁻¹⦇B⦈⇘m⇙›*) h_def (*‹(left_cart_proj (X::cset) (B::cset) ∘⇩c inverse_image_mapping (f::cfunc) B (m::cfunc)) ∘⇩c (h::cfunc) = (x::cfunc)›*) comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) apply -
(*goal: ‹f ∘⇩c x = (f ∘⇩c left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h›*)
apply typecheck_cfuncs
(*goal: ‹⟦(f::cfunc) ∘⇩c (x::cfunc) = f ∘⇩c left_cart_proj (X::cset) (B::cset) ∘⇩c inverse_image_mapping f B (m::cfunc) ∘⇩c (h::cfunc); f : X → (Y::cset); (B, m) ⊆⇩c Y; x ∈⇩c X; m : B → Y; monomorphism m; h ∈⇩c f⁻¹⦇B⦈⇘m⇙; (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h = x; ⋀(f::cfunc) (X::cset) (Y::cset) (g::cfunc) (Z::cset) (h::cfunc) W::cset. ⟦f : X → Y; g : Y → Z; h : Z → W⟧ ⟹ h ∘⇩c g ∘⇩c f = (h ∘⇩c g) ∘⇩c f⟧ ⟹ f ∘⇩c x = (f ∘⇩c left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h›*)
by blast
then have "f ∘⇩c x = (m ∘⇩c right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h"
using assms (*‹f : X → Y› ‹(B::cset, m::cfunc) ⊆⇩c (Y::cset)› ‹x ∈⇩c X›*) h_type (*‹h ∈⇩c f⁻¹⦇B⦈⇘m⇙›*) m_type (*‹m : B → Y› ‹monomorphism (m::cfunc)›*) apply -
(*goal: ‹f ∘⇩c x = (m ∘⇩c right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h›*)
apply typecheck_cfuncs
(*goal: ‹⟦f ∘⇩c x = (f ∘⇩c left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h; f : X → Y; (B, m) ⊆⇩c Y; x ∈⇩c X; h ∈⇩c f⁻¹⦇B⦈⇘m⇙; m : B → Y; monomorphism m⟧ ⟹ f ∘⇩c x = (m ∘⇩c right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h›*)
by (simp add: inverse_image_mapping_eq (*‹⟦?m : ?B → ?Y; ?f : ?X → ?Y; monomorphism ?m⟧ ⟹ ?f ∘⇩c left_cart_proj ?X ?B ∘⇩c inverse_image_mapping ?f ?B ?m = ?m ∘⇩c right_cart_proj ?X ?B ∘⇩c inverse_image_mapping ?f ?B ?m›*) m_type (*‹m : B → Y› ‹monomorphism m›*))
then have "f ∘⇩c x = m ∘⇩c right_cart_proj X B ∘⇩c inverse_image_mapping f B m ∘⇩c h"
using assms (*‹(f::cfunc) : (X::cset) → (Y::cset)› ‹(B, m) ⊆⇩c Y› ‹(x::cfunc) ∈⇩c (X::cset)›*) m_type (*‹m : B → Y› ‹monomorphism (m::cfunc)›*) h_type (*‹h ∈⇩c f⁻¹⦇B⦈⇘m⇙›*) apply -
(*goal: ‹(f::cfunc) ∘⇩c (x::cfunc) = (m::cfunc) ∘⇩c right_cart_proj (X::cset) (B::cset) ∘⇩c inverse_image_mapping f B m ∘⇩c (h::cfunc)›*)
apply typecheck_cfuncs
(*goal: ‹⟦f ∘⇩c x = (m ∘⇩c right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c h; f : X → Y; (B, m) ⊆⇩c Y; x ∈⇩c X; m : B → Y; monomorphism m; h ∈⇩c f⁻¹⦇B⦈⇘m⇙⟧ ⟹ f ∘⇩c x = m ∘⇩c right_cart_proj X B ∘⇩c inverse_image_mapping f B m ∘⇩c h›*)
by (smt cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_associative (*‹⟦domain ?h = codomain ?g; domain ?g = codomain ?f⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) domain_comp (*‹domain ?g = codomain ?f ⟹ domain (?g ∘⇩c ?f) = domain ?f›*))
then have "(f ∘⇩c x) factorsthru m"
unfolding factors_through_def
(*goal: ‹∃h. h : domain (f ∘⇩c x) → domain m ∧ m ∘⇩c h = f ∘⇩c x›*)
using assms (*‹f : X → Y› ‹(B::cset, m::cfunc) ⊆⇩c (Y::cset)› ‹x ∈⇩c X›*) h_type (*‹h ∈⇩c f⁻¹⦇B⦈⇘m⇙›*) m_type (*‹m : B → Y› ‹monomorphism m›*) apply (intro exI[where x="right_cart_proj X B ∘⇩c inverse_image_mapping f B m ∘⇩c h"] (*‹?P (right_cart_proj X B ∘⇩c inverse_image_mapping f B m ∘⇩c h) ⟹ ∃x. ?P x›*))
(*goal: ‹∃h::cfunc. h : domain ((f::cfunc) ∘⇩c (x::cfunc)) → domain (m::cfunc) ∧ m ∘⇩c h = f ∘⇩c x›*)
apply typecheck_cfuncs
(*goal: ‹⟦f ∘⇩c x = m ∘⇩c right_cart_proj X B ∘⇩c inverse_image_mapping f B m ∘⇩c h; f : X → Y; (B, m) ⊆⇩c Y; x ∈⇩c X; h ∈⇩c f⁻¹⦇B⦈⇘m⇙; m : B → Y; monomorphism m⟧ ⟹ right_cart_proj X B ∘⇩c inverse_image_mapping f B m ∘⇩c h : domain (f ∘⇩c x) → domain m ∧ m ∘⇩c right_cart_proj X B ∘⇩c inverse_image_mapping f B m ∘⇩c h = f ∘⇩c x›*)
by (auto simp add: cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*))
then show "f ∘⇩c x ∈⇘Y⇙ (B, m)"
unfolding relative_member_def2
(*goal: ‹f ∘⇩c x ∈⇩c Y ∧ monomorphism m ∧ m : B → Y ∧ (f ∘⇩c x) factorsthru m›*)
using assms (*‹f : X → Y› ‹(B, m) ⊆⇩c Y› ‹x ∈⇩c X›*) m_type (*‹m : B → Y› ‹monomorphism m›*) apply -
(*goal: ‹f ∘⇩c x ∈⇩c Y ∧ monomorphism m ∧ m : B → Y ∧ (f ∘⇩c x) factorsthru m›*)
by (msorry)
next
(*goal: ‹f ∘⇩c x ∈⇘Y⇙ (B, m) ⟹ x ∈⇘X⇙ (f⁻¹⦇B⦈⇘m⇙, left_cart_proj X B ∘⇩c inverse_image_mapping f B m)›*)
have m_type: "m : B → Y" "monomorphism m"
using assms(2) (*‹(B, m) ⊆⇩c Y›*) unfolding subobject_of_def2
(*goals:
1. ‹m : B → Y›
2. ‹monomorphism m›*)
apply -
(*goals:
1. ‹(m::cfunc) : (B::cset) → (Y::cset) ∧ monomorphism m ⟹ m : B → Y›
2. ‹(m::cfunc) : (B::cset) → (Y::cset) ∧ monomorphism m ⟹ monomorphism m›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
assume "f ∘⇩c x ∈⇘Y⇙ (B, m)" (*‹(f::cfunc) ∘⇩c (x::cfunc) ∈⇘(Y::cset)⇙ (B::cset, m::cfunc)›*)
then have "∃h. h : domain (f ∘⇩c x) → domain m ∧ m ∘⇩c h = f ∘⇩c x"
unfolding relative_member_def2 factors_through_def
(*goal: ‹∃h. h : domain (f ∘⇩c x) → domain m ∧ m ∘⇩c h = f ∘⇩c x›*)
by auto
then obtain h where h_type: "h ∈⇩c B" and h_def: "m ∘⇩c h = f ∘⇩c x"
(*goal: ‹(⋀h. ⟦h ∈⇩c B; m ∘⇩c h = f ∘⇩c x⟧ ⟹ thesis) ⟹ thesis›*)
unfolding relative_member_def2 factors_through_def
(*goal: ‹(⋀h. ⟦h ∈⇩c B; m ∘⇩c h = f ∘⇩c x⟧ ⟹ thesis) ⟹ thesis›*)
using assms (*‹f : X → Y› ‹(B, m) ⊆⇩c Y› ‹x ∈⇩c X›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) domain_comp (*‹domain ?g = codomain ?f ⟹ domain (?g ∘⇩c ?f) = domain ?f›*) m_type (*‹m : B → Y› ‹monomorphism m›*) by auto
then have "∃j. j ∈⇩c (f⁻¹⦇B⦈⇘m⇙) ∧
(right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = h ∧
(left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = x"
using inverse_image_pullback (*‹⟦?m : ?B → ?Y; ?f : ?X → ?Y; monomorphism ?m⟧ ⟹ is_pullback (?f⁻¹⦇?B⦈⇘?m⇙) ?B ?X ?Y (right_cart_proj ?X ?B ∘⇩c inverse_image_mapping ?f ?B ?m) ?m (left_cart_proj ?X ?B ∘⇩c inverse_image_mapping ?f ?B ?m) ?f›*) assms (*‹f : X → Y› ‹(B, m) ⊆⇩c Y› ‹x ∈⇩c X›*) m_type (*‹m : B → Y› ‹monomorphism m›*) unfolding is_pullback_def
(*goal: ‹∃j. j ∈⇩c f⁻¹⦇B⦈⇘m⇙ ∧ (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = h ∧ (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = x›*)
by blast
then have "x factorsthru (left_cart_proj X B ∘⇩c inverse_image_mapping f B m)"
using m_type (*‹(m::cfunc) : (B::cset) → (Y::cset)› ‹monomorphism m›*) assms (*‹f : X → Y› ‹(B, m) ⊆⇩c Y› ‹x ∈⇩c X›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) apply -
(*goal: ‹x factorsthru (left_cart_proj X B ∘⇩c inverse_image_mapping f B m)›*)
apply typecheck_cfuncs
(*goal: ‹⟦∃j::cfunc. j ∈⇩c (f::cfunc)⁻¹⦇B::cset⦈⇘m::cfunc⇙ ∧ (right_cart_proj (X::cset) B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = (h::cfunc) ∧ (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j = (x::cfunc); m : B → (Y::cset); monomorphism m; f : X → Y; (B, m) ⊆⇩c Y; x ∈⇩c X; ⋀(f::cfunc) (X::cset) Y::cset. (f : X → Y) = (domain f = X ∧ codomain f = Y)⟧ ⟹ x factorsthru (left_cart_proj X B ∘⇩c inverse_image_mapping f B m)›*)
apply (unfold factors_through_def (*‹(?g::cfunc) factorsthru (?f::cfunc) = (∃h::cfunc. h : domain ?g → domain ?f ∧ ?f ∘⇩c h = ?g)›*))
(*goal: ‹⋀j. ⟦m : B → Y; monomorphism m; f : X → Y; (B, m) ⊆⇩c Y; (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j ∈⇩c X; ⋀f X Y. (f : X → Y) = (domain f = X ∧ codomain f = Y); f : X → Y; m : B → Y; right_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → B; right_cart_proj X B : X ×⇩c B → B; inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X ×⇩c B; f : X → Y; m : B → Y; left_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X; left_cart_proj X B : X ×⇩c B → X; inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X ×⇩c B; f : X → Y; m : B → Y; (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j ∈⇩c X; m : B → Y; m : B → Y; f : X → Y; m : B → Y; (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j ∈⇩c X; (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j ∈⇩c X; left_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X; left_cart_proj X B : X ×⇩c B → X; inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X ×⇩c B; f : X → Y; m : B → Y; j ∈⇩c f⁻¹⦇B⦈⇘m⇙; h = (right_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j; x = (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j⟧ ⟹ ((left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∘⇩c j) factorsthru (left_cart_proj X B ∘⇩c inverse_image_mapping f B m)›*)
by auto
then show "x ∈⇘X⇙ (f⁻¹⦇B⦈⇘m⇙, left_cart_proj X B ∘⇩c inverse_image_mapping f B m)"
unfolding relative_member_def2
(*goal: ‹x ∈⇩c X ∧ monomorphism (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∧ left_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X ∧ x factorsthru (left_cart_proj X B ∘⇩c inverse_image_mapping f B m)›*)
using m_type (*‹m : B → Y› ‹monomorphism m›*) assms (*‹f : X → Y› ‹(B, m) ⊆⇩c Y› ‹x ∈⇩c X›*) apply -
(*goal: ‹x ∈⇩c X ∧ monomorphism (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∧ left_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X ∧ x factorsthru (left_cart_proj X B ∘⇩c inverse_image_mapping f B m)›*)
apply typecheck_cfuncs
(*goal: ‹⟦x factorsthru (left_cart_proj X B ∘⇩c inverse_image_mapping f B m); m : B → Y; monomorphism m; f : X → Y; (B, m) ⊆⇩c Y; x ∈⇩c X⟧ ⟹ x ∈⇩c X ∧ monomorphism (left_cart_proj X B ∘⇩c inverse_image_mapping f B m) ∧ left_cart_proj X B ∘⇩c inverse_image_mapping f B m : f⁻¹⦇B⦈⇘m⇙ → X ∧ x factorsthru (left_cart_proj X B ∘⇩c inverse_image_mapping f B m)›*)
by (simp add: inverse_image_monomorphism (*‹⟦?m : ?B → ?Y; ?f : ?X → ?Y; monomorphism ?m⟧ ⟹ monomorphism (left_cart_proj ?X ?B ∘⇩c inverse_image_mapping ?f ?B ?m)›*))
qed
subsection ‹Fibered Products›
text ‹The definition below corresponds to Definition 2.1.42 in Halvorson.›
definition fibered_product :: "cset ⇒ cfunc ⇒ cfunc ⇒ cset ⇒ cset" ("_ ⇘_⇙×⇩c⇘_⇙ _" [66,50,50,65]65) where
"X ⇘f⇙×⇩c⇘g⇙ Y = (SOME E. ∃ Z m. f : X → Z ∧ g : Y → Z ∧
equalizer E m (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y))"
lemma fibered_product_equalizer:
assumes "f : X → Z" "g : Y → Z"
shows "∃ m. equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) m (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)"
proof (-)
(*goal: ‹∃m. equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) m (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)›*)
obtain E and m where "equalizer E m (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)"
(*goal: ‹(⋀E m. equalizer E m (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y) ⟹ thesis) ⟹ thesis›*)
using assms (*‹f : X → Z› ‹(g::cfunc) : (Y::cset) → (Z::cset)›*) equalizer_exists (*‹⟦(?f::cfunc) : (?X::cset) → (?Y::cset); (?g::cfunc) : ?X → ?Y⟧ ⟹ ∃(E::cset) m::cfunc. equalizer E m ?f ?g›*) apply -
(*goal: ‹(⋀E m. equalizer E m (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y) ⟹ thesis) ⟹ thesis›*)
apply typecheck_cfuncs
(*goal: ‹⟦⋀(E::cset) m::cfunc. equalizer E m ((f::cfunc) ∘⇩c left_cart_proj (X::cset) (Y::cset)) ((g::cfunc) ∘⇩c right_cart_proj X Y) ⟹ thesis::bool; f : X → (Z::cset); g : Y → Z; ⋀(f::cfunc) (X::cset) (Y::cset) g::cfunc. ⟦f : X → Y; g : X → Y⟧ ⟹ ∃(E::cset) m::cfunc. equalizer E m f g⟧ ⟹ thesis›*)
by blast
then have "∃x Z m. f : X → Z ∧ g : Y → Z ∧
equalizer x m (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)"
using assms (*‹f : X → Z› ‹g : Y → Z›*) by blast
then have "∃ Z m. f : X → Z ∧ g : Y → Z ∧
equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) m (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)"
unfolding fibered_product_def
(*goal: ‹∃Z m. f : X → Z ∧ g : Y → Z ∧ equalizer (SOME E. ∃Z m. f : X → Z ∧ g : Y → Z ∧ equalizer E m (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)) m (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)›*)
by (rule someI_ex (*‹∃x. ?P x ⟹ ?P (SOME x. ?P x)›*))
then show "∃m. equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) m (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)"
by auto
qed
definition fibered_product_morphism :: "cset ⇒ cfunc ⇒ cfunc ⇒ cset ⇒ cfunc" where
"fibered_product_morphism X f g Y = (SOME m. ∃ Z. f : X → Z ∧ g : Y → Z ∧
equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) m (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y))"
lemma fibered_product_morphism_equalizer:
assumes "f : X → Z" "g : Y → Z"
shows "equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) (fibered_product_morphism X f g Y) (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)"
proof (-)
(*goal: ‹equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) (fibered_product_morphism X f g Y) (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)›*)
have "∃x Z. f : X → Z ∧
g : Y → Z ∧ equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) x (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)"
using assms (*‹f : X → Z› ‹g : Y → Z›*) fibered_product_equalizer (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ ∃m. equalizer (?X ⇘?f⇙×⇩c⇘?g⇙ ?Y) m (?f ∘⇩c left_cart_proj ?X ?Y) (?g ∘⇩c right_cart_proj ?X ?Y)›*) by blast
then have "∃Z. f : X → Z ∧ g : Y → Z ∧
equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) (fibered_product_morphism X f g Y) (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)"
unfolding fibered_product_morphism_def
(*goal: ‹∃Z. f : X → Z ∧ g : Y → Z ∧ equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) (SOME m. ∃Z. f : X → Z ∧ g : Y → Z ∧ equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) m (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)) (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)›*)
by (rule someI_ex (*‹∃x::?'a::type. (?P::?'a::type ⇒ bool) x ⟹ ?P (SOME x::?'a::type. ?P x)›*))
then show "equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) (fibered_product_morphism X f g Y) (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)"
by auto
qed
lemma fibered_product_morphism_type[type_rule]:
assumes "f : X → Z" "g : Y → Z"
shows "fibered_product_morphism X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X ×⇩c Y"
using assms (*‹f : X → Z› ‹g : Y → Z›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) domain_comp (*‹domain ?g = codomain ?f ⟹ domain (?g ∘⇩c ?f) = domain ?f›*) equalizer_def (*‹equalizer (?E::cset) (?m::cfunc) (?f::cfunc) (?g::cfunc) = (∃(X::cset) Y::cset. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀(h::cfunc) F::cset. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k::cfunc. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) fibered_product_morphism_equalizer (*‹⟦(?f::cfunc) : (?X::cset) → (?Z::cset); (?g::cfunc) : (?Y::cset) → ?Z⟧ ⟹ equalizer (?X ⇘?f⇙×⇩c⇘?g⇙ ?Y) (fibered_product_morphism ?X ?f ?g ?Y) (?f ∘⇩c left_cart_proj ?X ?Y) (?g ∘⇩c right_cart_proj ?X ?Y)›*) left_cart_proj_type (*‹left_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?X›*) by auto
lemma fibered_product_morphism_monomorphism:
assumes "f : X → Z" "g : Y → Z"
shows "monomorphism (fibered_product_morphism X f g Y)"
using assms (*‹f : X → Z› ‹(g::cfunc) : (Y::cset) → (Z::cset)›*) equalizer_is_monomorphism (*‹equalizer ?E ?m ?f ?g ⟹ monomorphism ?m›*) fibered_product_morphism_equalizer (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ equalizer (?X ⇘?f⇙×⇩c⇘?g⇙ ?Y) (fibered_product_morphism ?X ?f ?g ?Y) (?f ∘⇩c left_cart_proj ?X ?Y) (?g ∘⇩c right_cart_proj ?X ?Y)›*) by blast
definition fibered_product_left_proj :: "cset ⇒ cfunc ⇒ cfunc ⇒ cset ⇒ cfunc" where
"fibered_product_left_proj X f g Y = (left_cart_proj X Y) ∘⇩c (fibered_product_morphism X f g Y)"
lemma fibered_product_left_proj_type[type_rule]:
assumes "f : X → Z" "g : Y → Z"
shows "fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X"
by (metis assms (*‹f : X → Z› ‹g : Y → Z›*) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) fibered_product_left_proj_def (*‹fibered_product_left_proj ?X ?f ?g ?Y = left_cart_proj ?X ?Y ∘⇩c fibered_product_morphism ?X ?f ?g ?Y›*) fibered_product_morphism_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*) left_cart_proj_type (*‹left_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?X›*))
definition fibered_product_right_proj :: "cset ⇒ cfunc ⇒ cfunc ⇒ cset ⇒ cfunc" where
"fibered_product_right_proj X f g Y = (right_cart_proj X Y) ∘⇩c (fibered_product_morphism X f g Y)"
lemma fibered_product_right_proj_type[type_rule]:
assumes "f : X → Z" "g : Y → Z"
shows "fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y"
by (metis assms (*‹f : X → Z› ‹g : Y → Z›*) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) fibered_product_right_proj_def (*‹fibered_product_right_proj ?X ?f ?g ?Y = right_cart_proj ?X ?Y ∘⇩c fibered_product_morphism ?X ?f ?g ?Y›*) fibered_product_morphism_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*) right_cart_proj_type (*‹right_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?Y›*))
lemma pair_factorsthru_fibered_product_morphism:
assumes "f : X → Z" "g : Y → Z" "x : A → X" "y : A → Y"
shows "f ∘⇩c x = g ∘⇩c y ⟹ ⟨x,y⟩ factorsthru fibered_product_morphism X f g Y"
unfolding factors_through_def
(*goal: ‹f ∘⇩c x = g ∘⇩c y ⟹ ∃h. h : domain ⟨x,y⟩ → domain (fibered_product_morphism X f g Y) ∧ fibered_product_morphism X f g Y ∘⇩c h = ⟨x,y⟩›*)
proof (-)
(*goal: ‹f ∘⇩c x = g ∘⇩c y ⟹ ∃h. h : domain ⟨x,y⟩ → domain (fibered_product_morphism X f g Y) ∧ fibered_product_morphism X f g Y ∘⇩c h = ⟨x,y⟩›*)
have equalizer: "equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) (fibered_product_morphism X f g Y) (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)"
using fibered_product_morphism_equalizer (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ equalizer (?X ⇘?f⇙×⇩c⇘?g⇙ ?Y) (fibered_product_morphism ?X ?f ?g ?Y) (?f ∘⇩c left_cart_proj ?X ?Y) (?g ∘⇩c right_cart_proj ?X ?Y)›*) assms (*‹(f::cfunc) : (X::cset) → (Z::cset)› ‹g : Y → Z› ‹x : A → X› ‹y : A → Y›*) apply -
(*goal: ‹equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) (fibered_product_morphism X f g Y) (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)›*)
apply typecheck_cfuncs
(*goal: ‹⟦⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) (fibered_product_morphism X f g Y) (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y); f : X → Z; g : Y → Z; x : A → X; y : A → Y⟧ ⟹ equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) (fibered_product_morphism X f g Y) (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)›*)
by auto
assume "f ∘⇩c x = g ∘⇩c y" (*‹(f::cfunc) ∘⇩c (x::cfunc) = (g::cfunc) ∘⇩c (y::cfunc)›*)
then have "(f ∘⇩c left_cart_proj X Y) ∘⇩c ⟨x,y⟩ = (g ∘⇩c right_cart_proj X Y) ∘⇩c ⟨x,y⟩"
using assms (*‹f : X → Z› ‹g : Y → Z› ‹x : A → X› ‹y : A → Y›*) apply -
(*goal: ‹(f ∘⇩c left_cart_proj X Y) ∘⇩c ⟨x,y⟩ = (g ∘⇩c right_cart_proj X Y) ∘⇩c ⟨x,y⟩›*)
apply typecheck_cfuncs
(*goal: ‹⟦(f::cfunc) ∘⇩c (x::cfunc) = (g::cfunc) ∘⇩c (y::cfunc); f : (X::cset) → (Z::cset); g : (Y::cset) → Z; x : (A::cset) → X; y : A → Y⟧ ⟹ (f ∘⇩c left_cart_proj X Y) ∘⇩c ⟨x,y⟩ = (g ∘⇩c right_cart_proj X Y) ∘⇩c ⟨x,y⟩›*)
by (smt comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) left_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ left_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?f›*) right_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ right_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?g›*))
then have "∃! h. h : A → X ⇘f⇙×⇩c⇘g⇙ Y ∧ fibered_product_morphism X f g Y ∘⇩c h = ⟨x,y⟩"
using assms (*‹f : X → Z› ‹(g::cfunc) : (Y::cset) → (Z::cset)› ‹x : A → X› ‹y : A → Y›*) similar_equalizers (*‹⟦?f : ?X → ?Y; ?g : ?X → ?Y; ?m : ?E → ?X; equalizer ?E ?m ?f ?g; ?h : ?F → ?X; ?f ∘⇩c ?h = ?g ∘⇩c ?h⟧ ⟹ ∃!k. k : ?F → ?E ∧ ?m ∘⇩c k = ?h›*) apply -
(*goal: ‹∃!h::cfunc. h : (A::cset) → (X::cset) ⇘(f::cfunc)⇙×⇩c⇘(g::cfunc)⇙ (Y::cset) ∧ fibered_product_morphism X f g Y ∘⇩c h = ⟨x::cfunc,y::cfunc⟩›*)
apply typecheck_cfuncs
(*goal: ‹⟦(f ∘⇩c left_cart_proj X Y) ∘⇩c ⟨x,y⟩ = (g ∘⇩c right_cart_proj X Y) ∘⇩c ⟨x,y⟩; f : X → Z; g : Y → Z; x : A → X; y : A → Y; ⋀f X Y g m E h F. ⟦f : X → Y; g : X → Y; m : E → X; equalizer E m f g; h : F → X; f ∘⇩c h = g ∘⇩c h⟧ ⟹ ∃!k. k : F → E ∧ m ∘⇩c k = h⟧ ⟹ ∃!h. h : A → X ⇘f⇙×⇩c⇘g⇙ Y ∧ fibered_product_morphism X f g Y ∘⇩c h = ⟨x,y⟩›*)
by (smt (verit, del_insts) cfunc_type_def (*‹((?f::cfunc) : (?X::cset) → (?Y::cset)) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) equalizer (*‹equalizer ((X::cset) ⇘(f::cfunc)⇙×⇩c⇘(g::cfunc)⇙ (Y::cset)) (fibered_product_morphism X f g Y) (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)›*) equalizer_def (*‹equalizer (?E::cset) (?m::cfunc) (?f::cfunc) (?g::cfunc) = (∃(X::cset) Y::cset. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀(h::cfunc) F::cset. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k::cfunc. k : F → ?E ∧ ?m ∘⇩c k = h)))›*))
then show "∃h. h : domain ⟨x,y⟩ → domain (fibered_product_morphism X f g Y) ∧
fibered_product_morphism X f g Y ∘⇩c h = ⟨x,y⟩"
by (metis assms( (*‹f : X → Z› ‹g : Y → Z›*) 1,2) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) domain_comp (*‹domain ?g = codomain ?f ⟹ domain (?g ∘⇩c ?f) = domain ?f›*) fibered_product_morphism_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*))
qed
lemma fibered_product_is_pullback:
assumes f_type[type_rule]: "f : X → Z" and g_type[type_rule]: "g : Y → Z"
shows "is_pullback (X ⇘f⇙×⇩c⇘g⇙ Y) Y X Z (fibered_product_right_proj X f g Y) g (fibered_product_left_proj X f g Y) f"
unfolding is_pullback_def
(*goal: ‹fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y ∧ g : Y → Z ∧ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X ∧ f : X → Z ∧ g ∘⇩c fibered_product_right_proj X f g Y = f ∘⇩c fibered_product_left_proj X f g Y ∧ (∀Z k h. k : Z → Y ∧ h : Z → X ∧ g ∘⇩c k = f ∘⇩c h ⟶ (∃!j. j : Z → X ⇘f⇙×⇩c⇘g⇙ Y ∧ fibered_product_right_proj X f g Y ∘⇩c j = k ∧ fibered_product_left_proj X f g Y ∘⇩c j = h))›*)
using assms (*‹f : X → Z› ‹g : Y → Z›*) fibered_product_left_proj_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_left_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X›*) fibered_product_right_proj_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_right_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?Y›*) proof (safe)
(*goals:
1. ‹⟦f : X → Z; g : Y → Z; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y›
2. ‹⟦f : X → Z; g : Y → Z; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X›
3. ‹⟦f : X → Z; g : Y → Z; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y⟧ ⟹ g ∘⇩c fibered_product_right_proj X f g Y = f ∘⇩c fibered_product_left_proj X f g Y›
4. ‹⋀Za k h. ⟦f : X → Z; g : Y → Z; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y; k : Za → Y; h : Za → X; g ∘⇩c k = f ∘⇩c h⟧ ⟹ ∃j. j : Za → X ⇘f⇙×⇩c⇘g⇙ Y ∧ fibered_product_right_proj X f g Y ∘⇩c j = k ∧ fibered_product_left_proj X f g Y ∘⇩c j = h›
5. ‹⋀Za k h j y. ⟦f : X → Z; g : Y → Z; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y; fibered_product_right_proj X f g Y ∘⇩c j : Za → Y; fibered_product_left_proj X f g Y ∘⇩c j : Za → X; g ∘⇩c fibered_product_right_proj X f g Y ∘⇩c j = f ∘⇩c fibered_product_left_proj X f g Y ∘⇩c j; j : Za → X ⇘f⇙×⇩c⇘g⇙ Y; y : Za → X ⇘f⇙×⇩c⇘g⇙ Y; fibered_product_right_proj X f g Y ∘⇩c y = fibered_product_right_proj X f g Y ∘⇩c j; fibered_product_left_proj X f g Y ∘⇩c y = fibered_product_left_proj X f g Y ∘⇩c j⟧ ⟹ j = y›*)
show "g ∘⇩c fibered_product_right_proj X f g Y = f ∘⇩c fibered_product_left_proj X f g Y"
unfolding fibered_product_right_proj_def fibered_product_left_proj_def
(*goal: ‹g ∘⇩c right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y = f ∘⇩c left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y›*)
using cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) equalizer_def (*‹equalizer ?E ?m ?f ?g = (∃X Y. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) fibered_product_morphism_equalizer (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ equalizer (?X ⇘?f⇙×⇩c⇘?g⇙ ?Y) (fibered_product_morphism ?X ?f ?g ?Y) (?f ∘⇩c left_cart_proj ?X ?Y) (?g ∘⇩c right_cart_proj ?X ?Y)›*) apply -
(*goal: ‹(g::cfunc) ∘⇩c right_cart_proj (X::cset) (Y::cset) ∘⇩c fibered_product_morphism X (f::cfunc) g Y = f ∘⇩c left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y›*)
apply typecheck_cfuncs
(*goal: ‹⟦⋀f X Y. (f : X → Y) = (domain f = X ∧ codomain f = Y); ⋀f X Y g Z h W. ⟦f : X → Y; g : Y → Z; h : Z → W⟧ ⟹ h ∘⇩c g ∘⇩c f = (h ∘⇩c g) ∘⇩c f; ⋀E m f g. equalizer E m f g = (∃X Y. f : X → Y ∧ g : X → Y ∧ m : E → X ∧ f ∘⇩c m = g ∘⇩c m ∧ (∀h F. h : F → X ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h))); ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) (fibered_product_morphism X f g Y) (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)⟧ ⟹ g ∘⇩c right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y = f ∘⇩c left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y›*)
by auto
next
(*goals:
1. ‹⟦(f::cfunc) : (X::cset) → (Z::cset); (g::cfunc) : (Y::cset) → Z; ⋀(f::cfunc) (X::cset) (Z::cset) (g::cfunc) Y::cset. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X; ⋀(f::cfunc) (X::cset) (Z::cset) (g::cfunc) Y::cset. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y›
2. ‹⟦(f::cfunc) : (X::cset) → (Z::cset); (g::cfunc) : (Y::cset) → Z; ⋀(f::cfunc) (X::cset) (Z::cset) (g::cfunc) Y::cset. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X; ⋀(f::cfunc) (X::cset) (Z::cset) (g::cfunc) Y::cset. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X›
3. ‹⋀(Za::cset) (k::cfunc) h::cfunc. ⟦(f::cfunc) : (X::cset) → (Z::cset); (g::cfunc) : (Y::cset) → Z; ⋀(f::cfunc) (X::cset) (Z::cset) (g::cfunc) Y::cset. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X; ⋀(f::cfunc) (X::cset) (Z::cset) (g::cfunc) Y::cset. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y; k : Za → Y; h : Za → X; g ∘⇩c k = f ∘⇩c h⟧ ⟹ ∃j::cfunc. j : Za → X ⇘f⇙×⇩c⇘g⇙ Y ∧ fibered_product_right_proj X f g Y ∘⇩c j = k ∧ fibered_product_left_proj X f g Y ∘⇩c j = h›
4. ‹⋀(Za::cset) (k::cfunc) (h::cfunc) (j::cfunc) y::cfunc. ⟦(f::cfunc) : (X::cset) → (Z::cset); (g::cfunc) : (Y::cset) → Z; ⋀(f::cfunc) (X::cset) (Z::cset) (g::cfunc) Y::cset. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X; ⋀(f::cfunc) (X::cset) (Z::cset) (g::cfunc) Y::cset. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y; fibered_product_right_proj X f g Y ∘⇩c j : Za → Y; fibered_product_left_proj X f g Y ∘⇩c j : Za → X; g ∘⇩c fibered_product_right_proj X f g Y ∘⇩c j = f ∘⇩c fibered_product_left_proj X f g Y ∘⇩c j; j : Za → X ⇘f⇙×⇩c⇘g⇙ Y; y : Za → X ⇘f⇙×⇩c⇘g⇙ Y; fibered_product_right_proj X f g Y ∘⇩c y = fibered_product_right_proj X f g Y ∘⇩c j; fibered_product_left_proj X f g Y ∘⇩c y = fibered_product_left_proj X f g Y ∘⇩c j⟧ ⟹ j = y›*)
fix A and k and h
assume k_type: "k : A → Y" and h_type: "h : A → X" (*‹(k::cfunc) : (A::cset) → (Y::cset)› ‹(h::cfunc) : (A::cset) → (X::cset)›*)
assume k_h_commutes: "g ∘⇩c k = f ∘⇩c h" (*‹(g::cfunc) ∘⇩c (k::cfunc) = (f::cfunc) ∘⇩c (h::cfunc)›*)
have "⟨h,k⟩ factorsthru fibered_product_morphism X f g Y"
using assms (*‹f : X → Z› ‹g : Y → Z›*) h_type (*‹(h::cfunc) : (A::cset) → (X::cset)›*) k_h_commutes (*‹g ∘⇩c k = f ∘⇩c h›*) k_type (*‹k : A → Y›*) pair_factorsthru_fibered_product_morphism (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z; ?x : ?A → ?X; ?y : ?A → ?Y; ?f ∘⇩c ?x = ?g ∘⇩c ?y⟧ ⟹ ⟨?x,?y⟩ factorsthru fibered_product_morphism ?X ?f ?g ?Y›*) by auto
then have f1: "∃j. j : A → X ⇘f⇙×⇩c⇘g⇙ Y ∧ fibered_product_morphism X f g Y ∘⇩c j = ⟨h,k⟩"
by (meson assms (*‹f : X → Z› ‹g : Y → Z›*) cfunc_prod_type (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ ⟨?f,?g⟩ : ?Z → ?X ×⇩c ?Y›*) factors_through_def2 (*‹⟦?g : ?X → ?Z; ?f : ?Y → ?Z⟧ ⟹ ?g factorsthru ?f = (∃h. h : ?X → ?Y ∧ ?f ∘⇩c h = ?g)›*) fibered_product_morphism_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*) h_type (*‹h : A → X›*) k_type (*‹k : A → Y›*))
then show "∃j. j : A → X ⇘f⇙×⇩c⇘g⇙ Y ∧
fibered_product_right_proj X f g Y ∘⇩c j = k ∧ fibered_product_left_proj X f g Y ∘⇩c j = h"
unfolding fibered_product_right_proj_def fibered_product_left_proj_def
(*goal: ‹∃j. j : A → X ⇘f⇙×⇩c⇘g⇙ Y ∧ (right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c j = k ∧ (left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c j = h›*)
proof (clarify, safe)
(*goal: ‹⋀j ja. ⟦j : A → X ⇘f⇙×⇩c⇘g⇙ Y; fibered_product_morphism X f g Y ∘⇩c j = ⟨h,k⟩; ja : A → X ⇘f⇙×⇩c⇘g⇙ Y; fibered_product_morphism X f g Y ∘⇩c ja = ⟨h,k⟩⟧ ⟹ ∃j. j : A → X ⇘f⇙×⇩c⇘g⇙ Y ∧ (right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c j = k ∧ (left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c j = h›*)
fix j
assume j_type: "j : A → X ⇘f⇙×⇩c⇘g⇙ Y" (*‹(j::cfunc) : (A::cset) → (X::cset) ⇘(f::cfunc)⇙×⇩c⇘(g::cfunc)⇙ (Y::cset)›*)
show "∃j. j : A → X ⇘f⇙×⇩c⇘g⇙ Y ∧
(right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c j = k ∧ (left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c j = h"
apply typecheck_cfuncs
(*goal: ‹∃j. j : A → X ⇘f⇙×⇩c⇘g⇙ Y ∧ (right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c j = k ∧ (left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c j = h›*)
by (smt (verit, best) f1 (*‹∃j. j : A → X ⇘f⇙×⇩c⇘g⇙ Y ∧ fibered_product_morphism X f g Y ∘⇩c j = ⟨h,k⟩›*) comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) h_type (*‹h : A → X›*) k_type (*‹k : A → Y›*) left_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ left_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?f›*) right_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ right_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?g›*))
qed
next
(*goals:
1. ‹⟦f : X → Z; g : Y → Z; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y›
2. ‹⟦f : X → Z; g : Y → Z; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X›
3. ‹⋀Za k h j y. ⟦f : X → Z; g : Y → Z; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_left_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_right_proj X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → Y; fibered_product_right_proj X f g Y ∘⇩c j : Za → Y; fibered_product_left_proj X f g Y ∘⇩c j : Za → X; g ∘⇩c fibered_product_right_proj X f g Y ∘⇩c j = f ∘⇩c fibered_product_left_proj X f g Y ∘⇩c j; j : Za → X ⇘f⇙×⇩c⇘g⇙ Y; y : Za → X ⇘f⇙×⇩c⇘g⇙ Y; fibered_product_right_proj X f g Y ∘⇩c y = fibered_product_right_proj X f g Y ∘⇩c j; fibered_product_left_proj X f g Y ∘⇩c y = fibered_product_left_proj X f g Y ∘⇩c j⟧ ⟹ j = y›*)
fix A and j and y
assume j_type: "j : A → X ⇘f⇙×⇩c⇘g⇙ Y" and y_type: "y : A → X ⇘f⇙×⇩c⇘g⇙ Y" (*‹(j::cfunc) : (A::cset) → (X::cset) ⇘(f::cfunc)⇙×⇩c⇘(g::cfunc)⇙ (Y::cset)› ‹(y::cfunc) : (A::cset) → (X::cset) ⇘(f::cfunc)⇙×⇩c⇘(g::cfunc)⇙ (Y::cset)›*)
assume "fibered_product_right_proj X f g Y ∘⇩c y = fibered_product_right_proj X f g Y ∘⇩c j" (*‹fibered_product_right_proj (X::cset) (f::cfunc) (g::cfunc) (Y::cset) ∘⇩c (y::cfunc) = fibered_product_right_proj X f g Y ∘⇩c (j::cfunc)›*)
then have right_eq: "right_cart_proj X Y ∘⇩c (fibered_product_morphism X f g Y ∘⇩c y) =
right_cart_proj X Y ∘⇩c (fibered_product_morphism X f g Y ∘⇩c j)"
unfolding fibered_product_right_proj_def
(*goal: ‹right_cart_proj (X::cset) (Y::cset) ∘⇩c fibered_product_morphism X (f::cfunc) (g::cfunc) Y ∘⇩c (y::cfunc) = right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c (j::cfunc)›*)
using assms (*‹f : X → Z› ‹(g::cfunc) : (Y::cset) → (Z::cset)›*) j_type (*‹j : A → X ⇘f⇙×⇩c⇘g⇙ Y›*) y_type (*‹y : A → X ⇘f⇙×⇩c⇘g⇙ Y›*) apply -
(*goal: ‹right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c y = right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j›*)
apply typecheck_cfuncs
(*goal: ‹⟦(right_cart_proj (X::cset) (Y::cset) ∘⇩c fibered_product_morphism X (f::cfunc) (g::cfunc) Y) ∘⇩c (y::cfunc) = (right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c (j::cfunc); f : X → (Z::cset); g : Y → Z; j : (A::cset) → X ⇘f⇙×⇩c⇘g⇙ Y; y : A → X ⇘f⇙×⇩c⇘g⇙ Y⟧ ⟹ right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c y = right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j›*)
by (simp add: comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*))
assume "fibered_product_left_proj X f g Y ∘⇩c y = fibered_product_left_proj X f g Y ∘⇩c j" (*‹fibered_product_left_proj (X::cset) (f::cfunc) (g::cfunc) (Y::cset) ∘⇩c (y::cfunc) = fibered_product_left_proj X f g Y ∘⇩c (j::cfunc)›*)
then have left_eq: "left_cart_proj X Y ∘⇩c (fibered_product_morphism X f g Y ∘⇩c y) =
left_cart_proj X Y ∘⇩c (fibered_product_morphism X f g Y ∘⇩c j)"
unfolding fibered_product_left_proj_def
(*goal: ‹left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c y = left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j›*)
using assms (*‹f : X → Z› ‹g : Y → Z›*) j_type (*‹j : A → X ⇘f⇙×⇩c⇘g⇙ Y›*) y_type (*‹y : A → X ⇘f⇙×⇩c⇘g⇙ Y›*) apply -
(*goal: ‹left_cart_proj (X::cset) (Y::cset) ∘⇩c fibered_product_morphism X (f::cfunc) (g::cfunc) Y ∘⇩c (y::cfunc) = left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c (j::cfunc)›*)
apply typecheck_cfuncs
(*goal: ‹⟦(left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c y = (left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c j; f : X → Z; g : Y → Z; j : A → X ⇘f⇙×⇩c⇘g⇙ Y; y : A → X ⇘f⇙×⇩c⇘g⇙ Y⟧ ⟹ left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c y = left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j›*)
by (simp add: comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*))
have mono: "monomorphism (fibered_product_morphism X f g Y)"
using assms (*‹f : X → Z› ‹g : Y → Z›*) fibered_product_morphism_monomorphism (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ monomorphism (fibered_product_morphism ?X ?f ?g ?Y)›*) by auto
have "fibered_product_morphism X f g Y ∘⇩c y = fibered_product_morphism X f g Y ∘⇩c j"
using right_eq (*‹right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c y = right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j›*) left_eq (*‹left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c y = left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j›*) cart_prod_eq (*‹⟦?a : ?Z → ?X ×⇩c ?Y; ?b : ?Z → ?X ×⇩c ?Y⟧ ⟹ (?a = ?b) = (left_cart_proj ?X ?Y ∘⇩c ?a = left_cart_proj ?X ?Y ∘⇩c ?b ∧ right_cart_proj ?X ?Y ∘⇩c ?a = right_cart_proj ?X ?Y ∘⇩c ?b)›*) fibered_product_morphism_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*) y_type (*‹(y::cfunc) : (A::cset) → (X::cset) ⇘(f::cfunc)⇙×⇩c⇘(g::cfunc)⇙ (Y::cset)›*) j_type (*‹j : A → X ⇘f⇙×⇩c⇘g⇙ Y›*) assms (*‹f : X → Z› ‹g : Y → Z›*) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) apply (subst cart_prod_eq[where Z=A, where X=X, where Y=Y] (*‹⟦(?a::cfunc) : (A::cset) → (X::cset) ×⇩c (Y::cset); (?b::cfunc) : A → X ×⇩c Y⟧ ⟹ (?a = ?b) = (left_cart_proj X Y ∘⇩c ?a = left_cart_proj X Y ∘⇩c ?b ∧ right_cart_proj X Y ∘⇩c ?a = right_cart_proj X Y ∘⇩c ?b)›*))
(*goals:
1. ‹⟦right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c y = right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j; left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c y = left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j; ⋀a Z X Y b. ⟦a : Z → X ×⇩c Y; b : Z → X ×⇩c Y⟧ ⟹ (a = b) = (left_cart_proj X Y ∘⇩c a = left_cart_proj X Y ∘⇩c b ∧ right_cart_proj X Y ∘⇩c a = right_cart_proj X Y ∘⇩c b); ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_morphism X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X ×⇩c Y; y : A → X ⇘f⇙×⇩c⇘g⇙ Y; j : A → X ⇘f⇙×⇩c⇘g⇙ Y; f : X → Z; g : Y → Z; ⋀f X Y g Z. ⟦f : X → Y; g : Y → Z⟧ ⟹ g ∘⇩c f : X → Z⟧ ⟹ fibered_product_morphism X f g Y ∘⇩c y : A → X ×⇩c Y›
2. ‹⟦right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c y = right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j; left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c y = left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j; ⋀a Z X Y b. ⟦a : Z → X ×⇩c Y; b : Z → X ×⇩c Y⟧ ⟹ (a = b) = (left_cart_proj X Y ∘⇩c a = left_cart_proj X Y ∘⇩c b ∧ right_cart_proj X Y ∘⇩c a = right_cart_proj X Y ∘⇩c b); ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_morphism X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X ×⇩c Y; y : A → X ⇘f⇙×⇩c⇘g⇙ Y; j : A → X ⇘f⇙×⇩c⇘g⇙ Y; f : X → Z; g : Y → Z; ⋀f X Y g Z. ⟦f : X → Y; g : Y → Z⟧ ⟹ g ∘⇩c f : X → Z⟧ ⟹ fibered_product_morphism X f g Y ∘⇩c j : A → X ×⇩c Y›
3. ‹⟦right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c y = right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j; left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c y = left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j; ⋀a Z X Y b. ⟦a : Z → X ×⇩c Y; b : Z → X ×⇩c Y⟧ ⟹ (a = b) = (left_cart_proj X Y ∘⇩c a = left_cart_proj X Y ∘⇩c b ∧ right_cart_proj X Y ∘⇩c a = right_cart_proj X Y ∘⇩c b); ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ fibered_product_morphism X f g Y : X ⇘f⇙×⇩c⇘g⇙ Y → X ×⇩c Y; y : A → X ⇘f⇙×⇩c⇘g⇙ Y; j : A → X ⇘f⇙×⇩c⇘g⇙ Y; f : X → Z; g : Y → Z; ⋀f X Y g Z. ⟦f : X → Y; g : Y → Z⟧ ⟹ g ∘⇩c f : X → Z⟧ ⟹ left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c y = left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j ∧ right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c y = right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
then show "j = y"
using mono (*‹monomorphism (fibered_product_morphism X f g Y)›*) assms (*‹f : X → Z› ‹g : Y → Z›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) fibered_product_morphism_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*) j_type (*‹j : A → X ⇘f⇙×⇩c⇘g⇙ Y›*) y_type (*‹y : A → X ⇘f⇙×⇩c⇘g⇙ Y›*) unfolding monomorphism_def
(*goal: ‹j = y›*)
by auto
qed
lemma fibered_product_proj_eq:
assumes "f : X → Z" "g : Y → Z"
shows "f ∘⇩c fibered_product_left_proj X f g Y = g ∘⇩c fibered_product_right_proj X f g Y"
using fibered_product_is_pullback (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ is_pullback (?X ⇘?f⇙×⇩c⇘?g⇙ ?Y) ?Y ?X ?Z (fibered_product_right_proj ?X ?f ?g ?Y) ?g (fibered_product_left_proj ?X ?f ?g ?Y) ?f›*) assms (*‹f : X → Z› ‹g : Y → Z›*) unfolding is_pullback_def
(*goal: ‹(f::cfunc) ∘⇩c fibered_product_left_proj (X::cset) f (g::cfunc) (Y::cset) = g ∘⇩c fibered_product_right_proj X f g Y›*)
by auto
lemma fibered_product_pair_member:
assumes "f : X → Z" "g : Y → Z" "x ∈⇩c X" "y ∈⇩c Y"
shows "(⟨x, y⟩ ∈⇘X ×⇩c Y⇙ (X⇘f⇙×⇩c⇘g⇙Y, fibered_product_morphism X f g Y)) = (f ∘⇩c x = g ∘⇩c y)"
proof (standard)
(*goals:
1. ‹⟨x,y⟩ ∈⇘X ×⇩c Y⇙ (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y) ⟹ f ∘⇩c x = g ∘⇩c y›
2. ‹f ∘⇩c x = g ∘⇩c y ⟹ ⟨x,y⟩ ∈⇘X ×⇩c Y⇙ (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y)›*)
assume "⟨x,y⟩ ∈⇘X ×⇩c Y⇙ (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y)" (*‹⟨x::cfunc,y::cfunc⟩ ∈⇘(X::cset) ×⇩c (Y::cset)⇙ (X ⇘(f::cfunc)⇙×⇩c⇘(g::cfunc)⇙ Y, fibered_product_morphism X f g Y)›*)
then obtain h where h_type: "h ∈⇩c X⇘f⇙×⇩c⇘g⇙Y" and h_eq: "fibered_product_morphism X f g Y ∘⇩c h = ⟨x,y⟩"
(*goal: ‹(⋀h. ⟦h ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y; fibered_product_morphism X f g Y ∘⇩c h = ⟨x,y⟩⟧ ⟹ thesis) ⟹ thesis›*)
unfolding relative_member_def2 factors_through_def
(*goal: ‹(⋀h. ⟦h ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y; fibered_product_morphism X f g Y ∘⇩c h = ⟨x,y⟩⟧ ⟹ thesis) ⟹ thesis›*)
using assms(3,4) (*‹x ∈⇩c X› ‹y ∈⇩c Y›*) cfunc_prod_type (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ ⟨?f,?g⟩ : ?Z → ?X ×⇩c ?Y›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) by auto
have left_eq: "fibered_product_left_proj X f g Y ∘⇩c h = x"
unfolding fibered_product_left_proj_def
(*goal: ‹(left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c h = x›*)
using assms (*‹f : X → Z› ‹(g::cfunc) : (Y::cset) → (Z::cset)› ‹x ∈⇩c X› ‹(y::cfunc) ∈⇩c (Y::cset)›*) h_type (*‹h ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y›*) apply -
(*goal: ‹(left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c h = x›*)
apply typecheck_cfuncs
(*goal: ‹⟦f : X → Z; g : Y → Z; x ∈⇩c X; y ∈⇩c Y; h ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y⟧ ⟹ (left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c h = x›*)
by (smt comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) h_eq (*‹fibered_product_morphism X f g Y ∘⇩c h = ⟨x,y⟩›*) left_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ left_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?f›*))
have right_eq: "fibered_product_right_proj X f g Y ∘⇩c h = y"
unfolding fibered_product_right_proj_def
(*goal: ‹(right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c h = y›*)
using assms (*‹f : X → Z› ‹g : Y → Z› ‹x ∈⇩c X› ‹y ∈⇩c Y›*) h_type (*‹h ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y›*) apply -
(*goal: ‹(right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c h = y›*)
apply typecheck_cfuncs
(*goal: ‹⟦f : X → Z; g : Y → Z; x ∈⇩c X; y ∈⇩c Y; h ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y⟧ ⟹ (right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c h = y›*)
by (smt comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) h_eq (*‹fibered_product_morphism X f g Y ∘⇩c h = ⟨x,y⟩›*) right_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ right_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?g›*))
have "f ∘⇩c fibered_product_left_proj X f g Y ∘⇩c h = g ∘⇩c fibered_product_right_proj X f g Y ∘⇩c h"
using assms (*‹(f::cfunc) : (X::cset) → (Z::cset)› ‹g : Y → Z› ‹x ∈⇩c X› ‹y ∈⇩c Y›*) h_type (*‹h ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y›*) apply typecheck_cfuncs
(*goal: ‹f ∘⇩c fibered_product_left_proj X f g Y ∘⇩c h = g ∘⇩c fibered_product_right_proj X f g Y ∘⇩c h›*)
by (simp add: comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) fibered_product_proj_eq (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ ?f ∘⇩c fibered_product_left_proj ?X ?f ?g ?Y = ?g ∘⇩c fibered_product_right_proj ?X ?f ?g ?Y›*))
then show "f ∘⇩c x = g ∘⇩c y"
using left_eq (*‹fibered_product_left_proj X f g Y ∘⇩c h = x›*) right_eq (*‹fibered_product_right_proj X f g Y ∘⇩c h = y›*) by auto
next
(*goal: ‹f ∘⇩c x = g ∘⇩c y ⟹ ⟨x,y⟩ ∈⇘X ×⇩c Y⇙ (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y)›*)
assume f_g_eq: "f ∘⇩c x = g ∘⇩c y" (*‹(f::cfunc) ∘⇩c (x::cfunc) = (g::cfunc) ∘⇩c (y::cfunc)›*)
show "⟨x,y⟩ ∈⇘X ×⇩c Y⇙ (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y)"
unfolding relative_member_def factors_through_def
(*goal: ‹⟨x::cfunc,y::cfunc⟩ ∈⇩c (X::cset) ×⇩c (Y::cset) ∧ monomorphism (snd (X ⇘(f::cfunc)⇙×⇩c⇘(g::cfunc)⇙ Y, fibered_product_morphism X f g Y)) ∧ snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y) : fst (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y) → X ×⇩c Y ∧ (∃h::cfunc. h : domain ⟨x,y⟩ → domain (snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y)) ∧ snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y) ∘⇩c h = ⟨x,y⟩)›*)
proof (safe)
(*goals:
1. ‹⟨x,y⟩ ∈⇩c X ×⇩c Y›
2. ‹monomorphism (snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y))›
3. ‹snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y) : fst (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y) → X ×⇩c Y›
4. ‹∃h. h : domain ⟨x,y⟩ → domain (snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y)) ∧ snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y) ∘⇩c h = ⟨x,y⟩›*)
show "⟨x,y⟩ ∈⇩c X ×⇩c Y"
using assms (*‹f : X → Z› ‹g : Y → Z› ‹x ∈⇩c X› ‹y ∈⇩c Y›*) by typecheck_cfuncs
show "monomorphism (snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y))"
using assms(1,2) (*‹f : X → Z› ‹(g::cfunc) : (Y::cset) → (Z::cset)›*) fibered_product_morphism_monomorphism (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ monomorphism (fibered_product_morphism ?X ?f ?g ?Y)›*) by auto
show "snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y) : fst (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y) → X ×⇩c Y"
using assms(1,2) (*‹f : X → Z› ‹(g::cfunc) : (Y::cset) → (Z::cset)›*) fibered_product_morphism_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*) by force
have j_exists: "⋀ Z k h. k : Z → Y ⟹ h : Z → X ⟹ g ∘⇩c k = f ∘⇩c h ⟹
(∃!j. j : Z → X ⇘f⇙×⇩c⇘g⇙ Y ∧
fibered_product_right_proj X f g Y ∘⇩c j = k ∧
fibered_product_left_proj X f g Y ∘⇩c j = h)"
using fibered_product_is_pullback (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ is_pullback (?X ⇘?f⇙×⇩c⇘?g⇙ ?Y) ?Y ?X ?Z (fibered_product_right_proj ?X ?f ?g ?Y) ?g (fibered_product_left_proj ?X ?f ?g ?Y) ?f›*) assms (*‹f : X → Z› ‹g : Y → Z› ‹x ∈⇩c X› ‹(y::cfunc) ∈⇩c (Y::cset)›*) unfolding is_pullback_def
(*goal: ‹⋀Z k h. ⟦k : Z → Y; h : Z → X; g ∘⇩c k = f ∘⇩c h⟧ ⟹ ∃!j. j : Z → X ⇘f⇙×⇩c⇘g⇙ Y ∧ fibered_product_right_proj X f g Y ∘⇩c j = k ∧ fibered_product_left_proj X f g Y ∘⇩c j = h›*)
by auto
obtain j where j_type: "j ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y" and j_projs: "fibered_product_right_proj X f g Y ∘⇩c j = y" "fibered_product_left_proj X f g Y ∘⇩c j = x"
(*goal: ‹(⋀j. ⟦j ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y; fibered_product_right_proj X f g Y ∘⇩c j = y; fibered_product_left_proj X f g Y ∘⇩c j = x⟧ ⟹ thesis) ⟹ thesis›*)
using j_exists[where Z = 𝟭, where k = y, where h = x] (*‹⟦y ∈⇩c Y; x ∈⇩c X; g ∘⇩c y = f ∘⇩c x⟧ ⟹ ∃!j. j ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y ∧ fibered_product_right_proj X f g Y ∘⇩c j = y ∧ fibered_product_left_proj X f g Y ∘⇩c j = x›*) assms (*‹f : X → Z› ‹(g::cfunc) : (Y::cset) → (Z::cset)› ‹x ∈⇩c X› ‹y ∈⇩c Y›*) f_g_eq (*‹f ∘⇩c x = g ∘⇩c y›*) by auto
show "∃h. h : domain ⟨x,y⟩ → domain (snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y)) ∧
snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y) ∘⇩c h = ⟨x,y⟩"
proof (intro exI[where x=j] (*‹?P j ⟹ ∃x. ?P x›*), safe)
(*goals:
1. ‹j : domain ⟨x,y⟩ → domain (snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y))›
2. ‹snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y) ∘⇩c j = ⟨x,y⟩›*)
show "j : domain ⟨x,y⟩ → domain (snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y))"
using assms (*‹f : X → Z› ‹(g::cfunc) : (Y::cset) → (Z::cset)› ‹x ∈⇩c X› ‹y ∈⇩c Y›*) j_type (*‹j ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) apply -
(*goal: ‹j : domain ⟨x,y⟩ → domain (snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y))›*)
apply typecheck_cfuncs
(*goal: ‹⟦f : X → Z; g : Y → Z; x ∈⇩c X; y ∈⇩c Y; j ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y; ⋀f X Y. (f : X → Y) = (domain f = X ∧ codomain f = Y)⟧ ⟹ j : domain ⟨x,y⟩ → domain (snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y))›*)
by auto
have left_eq: "left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j = x"
using j_projs (*‹fibered_product_right_proj X f g Y ∘⇩c j = y› ‹fibered_product_left_proj X f g Y ∘⇩c j = x›*) assms (*‹f : X → Z› ‹g : Y → Z› ‹x ∈⇩c X› ‹y ∈⇩c Y›*) j_type (*‹j ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y›*) comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) unfolding fibered_product_left_proj_def
(*goal: ‹left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j = x›*)
apply -
(*goal: ‹left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j = x›*)
apply typecheck_cfuncs
(*goal: ‹⟦fibered_product_right_proj X f g Y ∘⇩c j = y; (left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y) ∘⇩c j = x; f : X → Z; g : Y → Z; x ∈⇩c X; y ∈⇩c Y; j ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y; ⋀f X Y g Z h W. ⟦f : X → Y; g : Y → Z; h : Z → W⟧ ⟹ h ∘⇩c g ∘⇩c f = (h ∘⇩c g) ∘⇩c f⟧ ⟹ left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j = x›*)
by auto
have right_eq: "right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j = y"
using j_projs (*‹fibered_product_right_proj X f g Y ∘⇩c j = y› ‹fibered_product_left_proj (X::cset) (f::cfunc) (g::cfunc) (Y::cset) ∘⇩c (j::cfunc) = (x::cfunc)›*) assms (*‹f : X → Z› ‹g : Y → Z› ‹x ∈⇩c X› ‹y ∈⇩c Y›*) j_type (*‹j ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y›*) comp_associative2 (*‹⟦(?f::cfunc) : (?X::cset) → (?Y::cset); (?g::cfunc) : ?Y → (?Z::cset); (?h::cfunc) : ?Z → (?W::cset)⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) unfolding fibered_product_right_proj_def
(*goal: ‹right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j = y›*)
apply -
(*goal: ‹right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j = y›*)
apply typecheck_cfuncs
(*goal: ‹⟦(right_cart_proj (X::cset) (Y::cset) ∘⇩c fibered_product_morphism X (f::cfunc) (g::cfunc) Y) ∘⇩c (j::cfunc) = (y::cfunc); fibered_product_left_proj X f g Y ∘⇩c j = (x::cfunc); f : X → (Z::cset); g : Y → Z; x ∈⇩c X; y ∈⇩c Y; j ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y; ⋀(f::cfunc) (X::cset) (Y::cset) (g::cfunc) (Z::cset) (h::cfunc) W::cset. ⟦f : X → Y; g : Y → Z; h : Z → W⟧ ⟹ h ∘⇩c g ∘⇩c f = (h ∘⇩c g) ∘⇩c f⟧ ⟹ right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j = y›*)
by auto
show "snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y) ∘⇩c j = ⟨x,y⟩"
using left_eq (*‹left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j = x›*) right_eq (*‹right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j = y›*) assms (*‹f : X → Z› ‹g : Y → Z› ‹x ∈⇩c X› ‹(y::cfunc) ∈⇩c (Y::cset)›*) j_type (*‹j ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y›*) apply -
(*goal: ‹snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y) ∘⇩c j = ⟨x,y⟩›*)
apply typecheck_cfuncs
(*goal: ‹⟦left_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j = x; right_cart_proj X Y ∘⇩c fibered_product_morphism X f g Y ∘⇩c j = y; f : X → Z; g : Y → Z; x ∈⇩c X; y ∈⇩c Y; j ∈⇩c X ⇘f⇙×⇩c⇘g⇙ Y⟧ ⟹ snd (X ⇘f⇙×⇩c⇘g⇙ Y, fibered_product_morphism X f g Y) ∘⇩c j = ⟨x,y⟩›*)
by (simp add: cfunc_prod_unique (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y; ?h : ?Z → ?X ×⇩c ?Y; left_cart_proj ?X ?Y ∘⇩c ?h = ?f; right_cart_proj ?X ?Y ∘⇩c ?h = ?g⟧ ⟹ ?h = ⟨?f,?g⟩›*))
qed
qed
qed
lemma fibered_product_pair_member2:
assumes "f : X → Y" "g : X → E" "x ∈⇩c X" "y ∈⇩c X"
assumes "g ∘⇩c fibered_product_left_proj X f f X = g ∘⇩c fibered_product_right_proj X f f X"
shows "∀x y. x ∈⇩c X ⟶ y ∈⇩c X ⟶ ⟨x,y⟩ ∈⇘X ×⇩c X⇙ (X ⇘f⇙×⇩c⇘f⇙ X, fibered_product_morphism X f f X) ⟶ g ∘⇩c x = g ∘⇩c y"
proof (clarify)
(*goal: ‹⋀x y. ⟦x ∈⇩c X; y ∈⇩c X; ⟨x,y⟩ ∈⇘X ×⇩c X⇙ (X ⇘f⇙×⇩c⇘f⇙ X, fibered_product_morphism X f f X)⟧ ⟹ g ∘⇩c x = g ∘⇩c y›*)
fix x and y
assume x_type[type_rule]: "x ∈⇩c X" (*‹(x::cfunc) ∈⇩c (X::cset)›*)
assume y_type[type_rule]: "y ∈⇩c X" (*‹(y::cfunc) ∈⇩c (X::cset)›*)
assume a3: "⟨x,y⟩ ∈⇘X ×⇩c X⇙ (X ⇘f⇙×⇩c⇘f⇙ X, fibered_product_morphism X f f X)" (*‹⟨x::cfunc,y::cfunc⟩ ∈⇘(X::cset) ×⇩c X⇙ (X ⇘(f::cfunc)⇙×⇩c⇘f⇙ X, fibered_product_morphism X f f X)›*)
then obtain h where h_type: "h ∈⇩c X⇘f⇙×⇩c⇘f⇙X" and h_eq: "fibered_product_morphism X f f X ∘⇩c h = ⟨x,y⟩"
(*goal: ‹(⋀h. ⟦h ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X; fibered_product_morphism X f f X ∘⇩c h = ⟨x,y⟩⟧ ⟹ thesis) ⟹ thesis›*)
by (meson factors_through_def2 (*‹⟦?g : ?X → ?Z; ?f : ?Y → ?Z⟧ ⟹ ?g factorsthru ?f = (∃h. h : ?X → ?Y ∧ ?f ∘⇩c h = ?g)›*) relative_member_def2 (*‹(?x ∈⇘?X⇙ (?B, ?m)) = (?x ∈⇩c ?X ∧ monomorphism ?m ∧ ?m : ?B → ?X ∧ ?x factorsthru ?m)›*))
have left_eq: "fibered_product_left_proj X f f X ∘⇩c h = x"
unfolding fibered_product_left_proj_def
(*goal: ‹(left_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c h = x›*)
apply typecheck_cfuncs
(*goal: ‹(left_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c h = x›*)
by (smt (z3) assms( (*‹f : X → Y›*) 1) comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) h_eq (*‹fibered_product_morphism X f f X ∘⇩c h = ⟨x,y⟩›*) h_type (*‹h ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X›*) left_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ left_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?f›*) y_type (*‹y ∈⇩c X›*))
have right_eq: "fibered_product_right_proj X f f X ∘⇩c h = y"
unfolding fibered_product_right_proj_def
(*goal: ‹(right_cart_proj (X::cset) X ∘⇩c fibered_product_morphism X (f::cfunc) f X) ∘⇩c (h::cfunc) = (y::cfunc)›*)
apply typecheck_cfuncs
(*goal: ‹(right_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c h = y›*)
by (metis (full_types) a3 (*‹⟨x,y⟩ ∈⇘X ×⇩c X⇙ (X ⇘f⇙×⇩c⇘f⇙ X, fibered_product_morphism X f f X)›*) comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) h_eq (*‹fibered_product_morphism X f f X ∘⇩c h = ⟨x,y⟩›*) h_type (*‹h ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X›*) relative_member_def2 (*‹(?x ∈⇘?X⇙ (?B, ?m)) = (?x ∈⇩c ?X ∧ monomorphism ?m ∧ ?m : ?B → ?X ∧ ?x factorsthru ?m)›*) right_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ right_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?g›*) x_type (*‹x ∈⇩c X›*))
then show "g ∘⇩c x = g ∘⇩c y"
using assms(1,2,5) (*‹f : X → Y› ‹g : X → E› ‹g ∘⇩c fibered_product_left_proj X f f X = g ∘⇩c fibered_product_right_proj X f f X›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_associative (*‹⟦domain ?h = codomain ?g; domain ?g = codomain ?f⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) fibered_product_left_proj_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_left_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X›*) fibered_product_right_proj_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_right_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?Y›*) h_type (*‹h ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X›*) left_eq (*‹fibered_product_left_proj X f f X ∘⇩c h = x›*) right_eq (*‹fibered_product_right_proj (X::cset) (f::cfunc) f X ∘⇩c (h::cfunc) = (y::cfunc)›*) by fastforce
qed
lemma kernel_pair_subset:
assumes "f: X → Y"
shows "(X ⇘f⇙×⇩c⇘f⇙ X, fibered_product_morphism X f f X) ⊆⇩c X ×⇩c X"
using assms (*‹f : X → Y›*) fibered_product_morphism_monomorphism (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ monomorphism (fibered_product_morphism ?X ?f ?g ?Y)›*) fibered_product_morphism_type (*‹⟦(?f::cfunc) : (?X::cset) → (?Z::cset); (?g::cfunc) : (?Y::cset) → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*) subobject_of_def2 (*‹((?B, ?m) ⊆⇩c ?X) = (?m : ?B → ?X ∧ monomorphism ?m)›*) by auto
text ‹The three lemmas below correspond to Exercise 2.1.44 in Halvorson.›
lemma kern_pair_proj_iso_TFAE1:
assumes "f: X → Y" "monomorphism f"
shows "(fibered_product_left_proj X f f X) = (fibered_product_right_proj X f f X)"
proof (cases "∃x. x∈⇩c X⇘f⇙×⇩c⇘f⇙X", clarify)
(*goals:
1. ‹⋀x. x ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X ⟹ fibered_product_left_proj X f f X = fibered_product_right_proj X f f X›
2. ‹∄x. x ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X ⟹ fibered_product_left_proj X f f X = fibered_product_right_proj X f f X›*)
fix x
assume x_type: "x∈⇩c X⇘f⇙×⇩c⇘f⇙X" (*‹(x::cfunc) ∈⇩c (X::cset) ⇘(f::cfunc)⇙×⇩c⇘f⇙ X›*)
then have "(f ∘⇩c (fibered_product_left_proj X f f X))∘⇩c x = (f∘⇩c (fibered_product_right_proj X f f X))∘⇩c x"
using assms (*‹f : X → Y› ‹monomorphism f›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_associative (*‹⟦domain ?h = codomain ?g; domain ?g = codomain ?f⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) equalizer_def (*‹equalizer ?E ?m ?f ?g = (∃X Y. ?f : X → Y ∧ ?g : X → Y ∧ ?m : ?E → X ∧ ?f ∘⇩c ?m = ?g ∘⇩c ?m ∧ (∀h F. h : F → X ∧ ?f ∘⇩c h = ?g ∘⇩c h ⟶ (∃!k. k : F → ?E ∧ ?m ∘⇩c k = h)))›*) fibered_product_morphism_equalizer (*‹⟦(?f::cfunc) : (?X::cset) → (?Z::cset); (?g::cfunc) : (?Y::cset) → ?Z⟧ ⟹ equalizer (?X ⇘?f⇙×⇩c⇘?g⇙ ?Y) (fibered_product_morphism ?X ?f ?g ?Y) (?f ∘⇩c left_cart_proj ?X ?Y) (?g ∘⇩c right_cart_proj ?X ?Y)›*) unfolding fibered_product_right_proj_def fibered_product_left_proj_def
(*goal: ‹(f ∘⇩c left_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c x = (f ∘⇩c right_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c x›*)
apply -
(*goal: ‹(f ∘⇩c left_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c x = (f ∘⇩c right_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c x›*)
apply typecheck_cfuncs
(*goal: ‹⟦x ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X; f : X → Y; monomorphism f; ⋀f X Y. (f : X → Y) = (domain f = X ∧ codomain f = Y); ⋀h g f. ⟦domain h = codomain g; domain g = codomain f⟧ ⟹ h ∘⇩c g ∘⇩c f = (h ∘⇩c g) ∘⇩c f; ⋀E m f g. equalizer E m f g = (∃X Y. f : X → Y ∧ g : X → Y ∧ m : E → X ∧ f ∘⇩c m = g ∘⇩c m ∧ (∀h F. h : F → X ∧ f ∘⇩c h = g ∘⇩c h ⟶ (∃!k. k : F → E ∧ m ∘⇩c k = h))); ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ equalizer (X ⇘f⇙×⇩c⇘g⇙ Y) (fibered_product_morphism X f g Y) (f ∘⇩c left_cart_proj X Y) (g ∘⇩c right_cart_proj X Y)⟧ ⟹ (f ∘⇩c left_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c x = (f ∘⇩c right_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c x›*)
by (smt (verit))
then have "f ∘⇩c (fibered_product_left_proj X f f X) = f∘⇩c (fibered_product_right_proj X f f X)"
using assms (*‹(f::cfunc) : (X::cset) → (Y::cset)› ‹monomorphism f›*) fibered_product_is_pullback (*‹⟦(?f::cfunc) : (?X::cset) → (?Z::cset); (?g::cfunc) : (?Y::cset) → ?Z⟧ ⟹ is_pullback (?X ⇘?f⇙×⇩c⇘?g⇙ ?Y) ?Y ?X ?Z (fibered_product_right_proj ?X ?f ?g ?Y) ?g (fibered_product_left_proj ?X ?f ?g ?Y) ?f›*) is_pullback_def (*‹is_pullback ?A ?B ?C ?D ?ab ?bd ?ac ?cd = (?ab : ?A → ?B ∧ ?bd : ?B → ?D ∧ ?ac : ?A → ?C ∧ ?cd : ?C → ?D ∧ ?bd ∘⇩c ?ab = ?cd ∘⇩c ?ac ∧ (∀Z k h. k : Z → ?B ∧ h : Z → ?C ∧ ?bd ∘⇩c k = ?cd ∘⇩c h ⟶ (∃!j. j : Z → ?A ∧ ?ab ∘⇩c j = k ∧ ?ac ∘⇩c j = h)))›*) by auto
then show "(fibered_product_left_proj X f f X) = (fibered_product_right_proj X f f X)"
using assms (*‹f : X → Y› ‹monomorphism f›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) fibered_product_left_proj_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_left_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X›*) fibered_product_right_proj_type (*‹⟦(?f::cfunc) : (?X::cset) → (?Z::cset); (?g::cfunc) : (?Y::cset) → ?Z⟧ ⟹ fibered_product_right_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?Y›*) monomorphism_def (*‹monomorphism ?f = (∀g h. codomain g = domain ?f ∧ codomain h = domain ?f ⟶ ?f ∘⇩c g = ?f ∘⇩c h ⟶ g = h)›*) by auto
next
(*goal: ‹∄x. x ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X ⟹ fibered_product_left_proj X f f X = fibered_product_right_proj X f f X›*)
assume "∄x. x ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X" (*‹∄x::cfunc. x ∈⇩c (X::cset) ⇘(f::cfunc)⇙×⇩c⇘f⇙ X›*)
then show "fibered_product_left_proj X f f X = fibered_product_right_proj X f f X"
using assms (*‹f : X → Y› ‹monomorphism f›*) fibered_product_left_proj_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_left_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X›*) fibered_product_right_proj_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_right_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?Y›*) one_separator (*‹⟦?f : ?X → ?Y; ?g : ?X → ?Y; ⋀x. x ∈⇩c ?X ⟹ ?f ∘⇩c x = ?g ∘⇩c x⟧ ⟹ ?f = ?g›*) by blast
qed
lemma kern_pair_proj_iso_TFAE2:
assumes "f: X → Y" "fibered_product_left_proj X f f X = fibered_product_right_proj X f f X"
shows "monomorphism f ∧ isomorphism (fibered_product_left_proj X f f X) ∧ isomorphism (fibered_product_right_proj X f f X)"
using assms (*‹f : X → Y› ‹fibered_product_left_proj X f f X = fibered_product_right_proj X f f X›*) proof (safe)
(*goals:
1. ‹⟦f : X → Y; fibered_product_left_proj X f f X = fibered_product_right_proj X f f X⟧ ⟹ monomorphism f›
2. ‹⟦f : X → Y; fibered_product_left_proj X f f X = fibered_product_right_proj X f f X⟧ ⟹ isomorphism (fibered_product_left_proj X f f X)›
3. ‹⟦f : X → Y; fibered_product_left_proj X f f X = fibered_product_right_proj X f f X⟧ ⟹ isomorphism (fibered_product_right_proj X f f X)›*)
have "injective f"
unfolding injective_def
(*goal: ‹∀x y. x ∈⇩c domain f ∧ y ∈⇩c domain f ∧ f ∘⇩c x = f ∘⇩c y ⟶ x = y›*)
proof (clarify)
(*goal: ‹⋀(x::cfunc) y::cfunc. ⟦x ∈⇩c domain (f::cfunc); y ∈⇩c domain f; f ∘⇩c x = f ∘⇩c y⟧ ⟹ x = y›*)
fix x and y
assume x_type: "x ∈⇩c domain f" and y_type: "y ∈⇩c domain f" (*‹(x::cfunc) ∈⇩c domain (f::cfunc)› ‹(y::cfunc) ∈⇩c domain (f::cfunc)›*)
then have x_type2: "x ∈⇩c X" and y_type2: "y ∈⇩c X"
using assms(1) (*‹f : X → Y›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) apply -
(*goals:
1. ‹⟦x ∈⇩c domain f; y ∈⇩c domain f; f : X → Y; ⋀f X Y. (f : X → Y) = (domain f = X ∧ codomain f = Y)⟧ ⟹ x ∈⇩c X›
2. ‹⟦x ∈⇩c domain f; y ∈⇩c domain f; f : X → Y; ⋀f X Y. (f : X → Y) = (domain f = X ∧ codomain f = Y)⟧ ⟹ y ∈⇩c X›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
have x_y_type: "⟨x,y⟩ : 𝟭 → X ×⇩c X"
using x_type2 (*‹x ∈⇩c X›*) y_type2 (*‹(y::cfunc) ∈⇩c (X::cset)›*) by typecheck_cfuncs
have fibered_product_type: "fibered_product_morphism X f f X : X ⇘f⇙×⇩c⇘f⇙ X → X ×⇩c X"
using assms (*‹f : X → Y› ‹fibered_product_left_proj X f f X = fibered_product_right_proj X f f X›*) by typecheck_cfuncs
assume "f ∘⇩c x = f ∘⇩c y" (*‹(f::cfunc) ∘⇩c (x::cfunc) = f ∘⇩c (y::cfunc)›*)
then have factorsthru: "⟨x,y⟩ factorsthru fibered_product_morphism X f f X"
using assms(1) (*‹f : X → Y›*) pair_factorsthru_fibered_product_morphism (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z; ?x : ?A → ?X; ?y : ?A → ?Y; ?f ∘⇩c ?x = ?g ∘⇩c ?y⟧ ⟹ ⟨?x,?y⟩ factorsthru fibered_product_morphism ?X ?f ?g ?Y›*) x_type2 (*‹x ∈⇩c X›*) y_type2 (*‹(y::cfunc) ∈⇩c (X::cset)›*) by auto
then obtain xy where xy_assms: "xy : 𝟭 → X ⇘f⇙×⇩c⇘f⇙ X" "fibered_product_morphism X f f X ∘⇩c xy = ⟨x,y⟩"
(*goal: ‹(⋀xy. ⟦xy ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X; fibered_product_morphism X f f X ∘⇩c xy = ⟨x,y⟩⟧ ⟹ thesis) ⟹ thesis›*)
using factors_through_def2 (*‹⟦?g : ?X → ?Z; ?f : ?Y → ?Z⟧ ⟹ ?g factorsthru ?f = (∃h. h : ?X → ?Y ∧ ?f ∘⇩c h = ?g)›*) fibered_product_type (*‹fibered_product_morphism (X::cset) (f::cfunc) f X : X ⇘f⇙×⇩c⇘f⇙ X → X ×⇩c X›*) x_y_type (*‹⟨x,y⟩ ∈⇩c X ×⇩c X›*) by blast
have left_proj: "fibered_product_left_proj X f f X ∘⇩c xy = x"
unfolding fibered_product_left_proj_def
(*goal: ‹(left_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c xy = x›*)
using assms (*‹(f::cfunc) : (X::cset) → (Y::cset)› ‹fibered_product_left_proj X f f X = fibered_product_right_proj X f f X›*) xy_assms (*‹xy ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X› ‹fibered_product_morphism X f f X ∘⇩c xy = ⟨x,y⟩›*) apply typecheck_cfuncs
(*goal: ‹(left_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c xy = x›*)
by (metis cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_associative (*‹⟦domain ?h = codomain ?g; domain ?g = codomain ?f⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) left_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ left_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?f›*) x_type2 (*‹x ∈⇩c X›*) xy_assms( (*‹fibered_product_morphism X f f X ∘⇩c xy = ⟨x,y⟩›*) 2) y_type2 (*‹y ∈⇩c X›*))
have right_proj: "fibered_product_right_proj X f f X ∘⇩c xy = y"
unfolding fibered_product_right_proj_def
(*goal: ‹(right_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c xy = y›*)
using assms (*‹f : X → Y› ‹fibered_product_left_proj X f f X = fibered_product_right_proj X f f X›*) xy_assms (*‹(xy::cfunc) ∈⇩c (X::cset) ⇘(f::cfunc)⇙×⇩c⇘f⇙ X› ‹fibered_product_morphism X f f X ∘⇩c xy = ⟨x,y⟩›*) apply typecheck_cfuncs
(*goal: ‹(right_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c xy = y›*)
by (metis cfunc_type_def (*‹((?f::cfunc) : (?X::cset) → (?Y::cset)) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_associative (*‹⟦domain (?h::cfunc) = codomain (?g::cfunc); domain ?g = codomain (?f::cfunc)⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) right_cart_proj_cfunc_prod (*‹⟦(?f::cfunc) : (?Z::cset) → (?X::cset); (?g::cfunc) : ?Z → (?Y::cset)⟧ ⟹ right_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?g›*) x_type2 (*‹(x::cfunc) ∈⇩c (X::cset)›*) xy_assms( (*‹fibered_product_morphism (X::cset) (f::cfunc) f X ∘⇩c (xy::cfunc) = ⟨x::cfunc,y::cfunc⟩›*) 2) y_type2 (*‹(y::cfunc) ∈⇩c (X::cset)›*))
show "x = y"
using assms(2) (*‹fibered_product_left_proj X f f X = fibered_product_right_proj X f f X›*) left_proj (*‹fibered_product_left_proj (X::cset) (f::cfunc) f X ∘⇩c (xy::cfunc) = (x::cfunc)›*) right_proj (*‹fibered_product_right_proj (X::cset) (f::cfunc) f X ∘⇩c (xy::cfunc) = (y::cfunc)›*) by auto
qed
then show "monomorphism f"
using injective_imp_monomorphism (*‹injective ?f ⟹ monomorphism ?f›*) by blast
next
(*goals:
1. ‹⟦f : X → Y; fibered_product_left_proj X f f X = fibered_product_right_proj X f f X⟧ ⟹ isomorphism (fibered_product_left_proj X f f X)›
2. ‹⟦f : X → Y; fibered_product_left_proj X f f X = fibered_product_right_proj X f f X⟧ ⟹ isomorphism (fibered_product_right_proj X f f X)›*)
have "diagonal X factorsthru fibered_product_morphism X f f X"
using assms(1) (*‹f : X → Y›*) diagonal_def (*‹diagonal ?X = ⟨id⇩c ?X,id⇩c ?X⟩›*) id_type (*‹id⇩c ?X : ?X → ?X›*) pair_factorsthru_fibered_product_morphism (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z; ?x : ?A → ?X; ?y : ?A → ?Y; ?f ∘⇩c ?x = ?g ∘⇩c ?y⟧ ⟹ ⟨?x,?y⟩ factorsthru fibered_product_morphism ?X ?f ?g ?Y›*) by fastforce
then obtain xx where xx_assms: "xx : X → X ⇘f⇙×⇩c⇘f⇙ X" "diagonal X = fibered_product_morphism X f f X ∘⇩c xx"
(*goal: ‹(⋀xx. ⟦xx : X → X ⇘f⇙×⇩c⇘f⇙ X; diagonal X = fibered_product_morphism X f f X ∘⇩c xx⟧ ⟹ thesis) ⟹ thesis›*)
using assms(1) (*‹f : X → Y›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) diagonal_type (*‹diagonal ?X : ?X → ?X ×⇩c ?X›*) factors_through_def (*‹(?g::cfunc) factorsthru (?f::cfunc) = (∃h::cfunc. h : domain ?g → domain ?f ∧ ?f ∘⇩c h = ?g)›*) fibered_product_morphism_type (*‹⟦(?f::cfunc) : (?X::cset) → (?Z::cset); (?g::cfunc) : (?Y::cset) → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*) by fastforce
have eq1: "fibered_product_right_proj X f f X ∘⇩c xx = id X"
by (smt assms( (*‹f : X → Y›*) 1) comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) diagonal_def (*‹diagonal ?X = ⟨id⇩c ?X,id⇩c ?X⟩›*) fibered_product_morphism_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*) fibered_product_right_proj_def (*‹fibered_product_right_proj ?X ?f ?g ?Y = right_cart_proj ?X ?Y ∘⇩c fibered_product_morphism ?X ?f ?g ?Y›*) id_type (*‹id⇩c ?X : ?X → ?X›*) right_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ right_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?g›*) right_cart_proj_type (*‹right_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?Y›*) xx_assms (*‹xx : X → X ⇘f⇙×⇩c⇘f⇙ X› ‹diagonal X = fibered_product_morphism X f f X ∘⇩c xx›*))
have eq2: "xx ∘⇩c fibered_product_right_proj X f f X = id (X ⇘f⇙×⇩c⇘f⇙ X)"
proof (rule one_separator[where X="X ⇘f⇙×⇩c⇘f⇙ X", where Y="X ⇘f⇙×⇩c⇘f⇙ X"] (*‹⟦(?f::cfunc) : (X::cset) ⇘(f::cfunc)⇙×⇩c⇘f⇙ X → X ⇘f⇙×⇩c⇘f⇙ X; (?g::cfunc) : X ⇘f⇙×⇩c⇘f⇙ X → X ⇘f⇙×⇩c⇘f⇙ X; ⋀x::cfunc. x ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X ⟹ ?f ∘⇩c x = ?g ∘⇩c x⟧ ⟹ ?f = ?g›*))
(*goals:
1. ‹xx ∘⇩c fibered_product_right_proj X f f X : X ⇘f⇙×⇩c⇘f⇙ X → X ⇘f⇙×⇩c⇘f⇙ X›
2. ‹id⇩c (X ⇘f⇙×⇩c⇘f⇙ X) : X ⇘f⇙×⇩c⇘f⇙ X → X ⇘f⇙×⇩c⇘f⇙ X›
3. ‹⋀x. x ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X ⟹ (xx ∘⇩c fibered_product_right_proj X f f X) ∘⇩c x = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X) ∘⇩c x›*)
show "xx ∘⇩c fibered_product_right_proj X f f X : X ⇘f⇙×⇩c⇘f⇙ X → X ⇘f⇙×⇩c⇘f⇙ X"
using assms(1) (*‹f : X → Y›*) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) fibered_product_right_proj_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_right_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?Y›*) xx_assms (*‹xx : X → X ⇘f⇙×⇩c⇘f⇙ X› ‹diagonal X = fibered_product_morphism X f f X ∘⇩c xx›*) by blast
show "id⇩c (X ⇘f⇙×⇩c⇘f⇙ X) : X ⇘f⇙×⇩c⇘f⇙ X → X ⇘f⇙×⇩c⇘f⇙ X"
by (simp add: id_type (*‹id⇩c ?X : ?X → ?X›*))
next
(*goal: ‹⋀x. x ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X ⟹ (xx ∘⇩c fibered_product_right_proj X f f X) ∘⇩c x = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X) ∘⇩c x›*)
fix x
assume x_type: "x ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X" (*‹(x::cfunc) ∈⇩c (X::cset) ⇘(f::cfunc)⇙×⇩c⇘f⇙ X›*)
then obtain a where a_assms: "⟨a,a⟩ = fibered_product_morphism X f f X ∘⇩c x" "a ∈⇩c X"
(*goal: ‹(⋀a. ⟦⟨a,a⟩ = fibered_product_morphism X f f X ∘⇩c x; a ∈⇩c X⟧ ⟹ thesis) ⟹ thesis›*)
by (smt assms (*‹f : X → Y› ‹fibered_product_left_proj X f f X = fibered_product_right_proj X f f X›*) cfunc_prod_comp (*‹⟦?f : ?X → ?Y; ?a : ?Y → ?A; ?b : ?Y → ?B⟧ ⟹ ⟨?a,?b⟩ ∘⇩c ?f = ⟨?a ∘⇩c ?f,?b ∘⇩c ?f⟩›*) cfunc_prod_unique (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y; ?h : ?Z → ?X ×⇩c ?Y; left_cart_proj ?X ?Y ∘⇩c ?h = ?f; right_cart_proj ?X ?Y ∘⇩c ?h = ?g⟧ ⟹ ?h = ⟨?f,?g⟩›*) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) fibered_product_left_proj_def (*‹fibered_product_left_proj ?X ?f ?g ?Y = left_cart_proj ?X ?Y ∘⇩c fibered_product_morphism ?X ?f ?g ?Y›*) fibered_product_morphism_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*) fibered_product_right_proj_def (*‹fibered_product_right_proj ?X ?f ?g ?Y = right_cart_proj ?X ?Y ∘⇩c fibered_product_morphism ?X ?f ?g ?Y›*) fibered_product_right_proj_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_right_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?Y›*))
have "(xx ∘⇩c fibered_product_right_proj X f f X) ∘⇩c x = xx ∘⇩c right_cart_proj X X ∘⇩c ⟨a,a⟩"
using xx_assms (*‹xx : X → X ⇘f⇙×⇩c⇘f⇙ X› ‹diagonal (X::cset) = fibered_product_morphism X (f::cfunc) f X ∘⇩c (xx::cfunc)›*) x_type (*‹x ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X›*) a_assms (*‹⟨a,a⟩ = fibered_product_morphism X f f X ∘⇩c x› ‹(a::cfunc) ∈⇩c (X::cset)›*) assms (*‹f : X → Y› ‹fibered_product_left_proj (X::cset) (f::cfunc) f X = fibered_product_right_proj X f f X›*) comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) unfolding fibered_product_right_proj_def
(*goal: ‹((xx::cfunc) ∘⇩c right_cart_proj (X::cset) X ∘⇩c fibered_product_morphism X (f::cfunc) f X) ∘⇩c (x::cfunc) = xx ∘⇩c right_cart_proj X X ∘⇩c ⟨a::cfunc,a⟩›*)
apply -
(*goal: ‹(xx ∘⇩c right_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c x = xx ∘⇩c right_cart_proj X X ∘⇩c ⟨a,a⟩›*)
apply typecheck_cfuncs
(*goal: ‹⟦(xx::cfunc) : (X::cset) → X ⇘(f::cfunc)⇙×⇩c⇘f⇙ X; diagonal X = fibered_product_morphism X f f X ∘⇩c xx; (x::cfunc) ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X; ⟨a::cfunc,a⟩ = fibered_product_morphism X f f X ∘⇩c x; a ∈⇩c X; f : X → (Y::cset); fibered_product_left_proj X f f X = right_cart_proj X X ∘⇩c fibered_product_morphism X f f X; ⋀(f::cfunc) (X::cset) (Y::cset) (g::cfunc) (Z::cset) (h::cfunc) W::cset. ⟦f : X → Y; g : Y → Z; h : Z → W⟧ ⟹ h ∘⇩c g ∘⇩c f = (h ∘⇩c g) ∘⇩c f⟧ ⟹ (xx ∘⇩c right_cart_proj X X ∘⇩c fibered_product_morphism X f f X) ∘⇩c x = xx ∘⇩c right_cart_proj X X ∘⇩c ⟨a,a⟩›*)
by auto
also (*calculation: ‹(xx ∘⇩c fibered_product_right_proj X f f X) ∘⇩c x = xx ∘⇩c right_cart_proj X X ∘⇩c ⟨a,a⟩›*) have "... = xx ∘⇩c a"
using a_assms(2) (*‹(a::cfunc) ∈⇩c (X::cset)›*) right_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ right_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?g›*) by auto
also (*calculation: ‹(xx ∘⇩c fibered_product_right_proj X f f X) ∘⇩c x = xx ∘⇩c a›*) have "... = x"
proof (-)
(*goal: ‹xx ∘⇩c a = x›*)
have f2: "∀c. c : 𝟭 → X ⟶ fibered_product_morphism X f f X ∘⇩c xx ∘⇩c c = diagonal X ∘⇩c c"
proof (safe)
(*goal: ‹⋀c. c ∈⇩c X ⟹ fibered_product_morphism X f f X ∘⇩c xx ∘⇩c c = diagonal X ∘⇩c c›*)
fix c
assume "c ∈⇩c X" (*‹(c::cfunc) ∈⇩c (X::cset)›*)
then show "fibered_product_morphism X f f X ∘⇩c xx ∘⇩c c = diagonal X ∘⇩c c"
using assms (*‹f : X → Y› ‹fibered_product_left_proj X f f X = fibered_product_right_proj X f f X›*) xx_assms (*‹xx : X → X ⇘f⇙×⇩c⇘f⇙ X› ‹diagonal (X::cset) = fibered_product_morphism X (f::cfunc) f X ∘⇩c (xx::cfunc)›*) apply typecheck_cfuncs
(*goal: ‹fibered_product_morphism X f f X ∘⇩c xx ∘⇩c c = diagonal X ∘⇩c c›*)
by (simp add: comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) xx_assms( (*‹diagonal X = fibered_product_morphism X f f X ∘⇩c xx›*) 2))
qed
have f4: "xx : X → codomain xx"
using cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) xx_assms (*‹xx : X → X ⇘f⇙×⇩c⇘f⇙ X› ‹diagonal X = fibered_product_morphism X f f X ∘⇩c xx›*) by presburger
have f5: "diagonal X ∘⇩c a = ⟨a,a⟩"
using a_assms (*‹⟨a,a⟩ = fibered_product_morphism X f f X ∘⇩c x› ‹a ∈⇩c X›*) diag_on_elements (*‹?x ∈⇩c ?X ⟹ diagonal ?X ∘⇩c ?x = ⟨?x,?x⟩›*) by blast
have f6: "codomain (xx ∘⇩c a) = codomain xx"
using f4 (*‹xx : X → codomain xx›*) by (meson a_assms (*‹⟨a,a⟩ = fibered_product_morphism X f f X ∘⇩c x› ‹a ∈⇩c X›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*))
then have f9: "x : domain x → codomain xx"
using cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) x_type (*‹x ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X›*) xx_assms (*‹xx : X → X ⇘f⇙×⇩c⇘f⇙ X› ‹diagonal X = fibered_product_morphism X f f X ∘⇩c xx›*) by auto
have f10: "∀c ca. domain (ca ∘⇩c a) = 𝟭 ∨ ¬ ca : X → c"
by (meson a_assms (*‹⟨a::cfunc,a⟩ = fibered_product_morphism (X::cset) (f::cfunc) f X ∘⇩c (x::cfunc)› ‹(a::cfunc) ∈⇩c (X::cset)›*) cfunc_type_def (*‹((?f::cfunc) : (?X::cset) → (?Y::cset)) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_type (*‹⟦(?f::cfunc) : (?X::cset) → (?Y::cset); (?g::cfunc) : ?Y → (?Z::cset)⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*))
then have "domain ⟨a,a⟩ = 𝟭"
using diagonal_type (*‹diagonal ?X : ?X → ?X ×⇩c ?X›*) f5 (*‹diagonal (X::cset) ∘⇩c (a::cfunc) = ⟨a,a⟩›*) by force
then have f11: "domain x = 𝟭"
using cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) x_type (*‹x ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X›*) by blast
have "xx ∘⇩c a ∈⇩c codomain xx"
using a_assms (*‹⟨a,a⟩ = fibered_product_morphism X f f X ∘⇩c x› ‹a ∈⇩c X›*) comp_type (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z⟧ ⟹ ?g ∘⇩c ?f : ?X → ?Z›*) f4 (*‹xx : X → codomain xx›*) by auto
then show "?thesis"
(*goal: ‹(xx::cfunc) ∘⇩c (a::cfunc) = (x::cfunc)›*)
using f11 (*‹domain x = 𝟭›*) f9 (*‹x : domain x → codomain xx›*) f5 (*‹diagonal (X::cset) ∘⇩c (a::cfunc) = ⟨a,a⟩›*) f2 (*‹∀c::cfunc. c ∈⇩c (X::cset) ⟶ fibered_product_morphism X (f::cfunc) f X ∘⇩c (xx::cfunc) ∘⇩c c = diagonal X ∘⇩c c›*) a_assms (*‹⟨a,a⟩ = fibered_product_morphism X f f X ∘⇩c x› ‹a ∈⇩c X›*) assms(1) (*‹f : X → Y›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) fibered_product_morphism_monomorphism (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ monomorphism (fibered_product_morphism ?X ?f ?g ?Y)›*) fibered_product_morphism_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*) monomorphism_def (*‹monomorphism ?f = (∀g h. codomain g = domain ?f ∧ codomain h = domain ?f ⟶ ?f ∘⇩c g = ?f ∘⇩c h ⟶ g = h)›*) x_type (*‹x ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X›*) by auto
qed
also (*calculation: ‹(xx ∘⇩c fibered_product_right_proj X f f X) ∘⇩c x = x›*) have "... = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X) ∘⇩c x"
by (metis cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) id_left_unit (*‹id⇩c (codomain ?f) ∘⇩c ?f = ?f›*) x_type (*‹x ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X›*))
finally (*calculation: ‹((xx::cfunc) ∘⇩c fibered_product_right_proj (X::cset) (f::cfunc) f X) ∘⇩c (x::cfunc) = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X) ∘⇩c x›*) show "(xx ∘⇩c fibered_product_right_proj X f f X) ∘⇩c x = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X) ∘⇩c x" .
qed
show "isomorphism (fibered_product_left_proj X f f X)"
unfolding isomorphism_def
(*goal: ‹∃g. domain g = codomain (fibered_product_left_proj X f f X) ∧ codomain g = domain (fibered_product_left_proj X f f X) ∧ g ∘⇩c fibered_product_left_proj X f f X = id⇩c (domain (fibered_product_left_proj X f f X)) ∧ fibered_product_left_proj X f f X ∘⇩c g = id⇩c (domain g)›*)
by (metis assms (*‹f : X → Y› ‹fibered_product_left_proj X f f X = fibered_product_right_proj X f f X›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) eq1 (*‹fibered_product_right_proj X f f X ∘⇩c xx = id⇩c X›*) eq2 (*‹xx ∘⇩c fibered_product_right_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)›*) fibered_product_right_proj_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_right_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?Y›*) xx_assms( (*‹xx : X → X ⇘f⇙×⇩c⇘f⇙ X›*) 1))
then show "isomorphism (fibered_product_right_proj X f f X)"
unfolding isomorphism_def
(*goal: ‹∃g. domain g = codomain (fibered_product_right_proj X f f X) ∧ codomain g = domain (fibered_product_right_proj X f f X) ∧ g ∘⇩c fibered_product_right_proj X f f X = id⇩c (domain (fibered_product_right_proj X f f X)) ∧ fibered_product_right_proj X f f X ∘⇩c g = id⇩c (domain g)›*)
using assms(2) (*‹fibered_product_left_proj X f f X = fibered_product_right_proj X f f X›*) isomorphism_def (*‹isomorphism ?f = (∃g. domain g = codomain ?f ∧ codomain g = domain ?f ∧ g ∘⇩c ?f = id⇩c (domain ?f) ∧ ?f ∘⇩c g = id⇩c (domain g))›*) by auto
qed
lemma kern_pair_proj_iso_TFAE3:
assumes "f: X → Y"
assumes "isomorphism (fibered_product_left_proj X f f X)" "isomorphism (fibered_product_right_proj X f f X)"
shows "fibered_product_left_proj X f f X = fibered_product_right_proj X f f X"
proof (-)
(*goal: ‹fibered_product_left_proj X f f X = fibered_product_right_proj X f f X›*)
obtain q0 where q0_assms: "q0 : X → X ⇘f⇙×⇩c⇘f⇙ X" "fibered_product_left_proj X f f X ∘⇩c q0 = id X" "q0 ∘⇩c fibered_product_left_proj X f f X = id (X ⇘f⇙×⇩c⇘f⇙ X)"
(*goal: ‹(⋀q0. ⟦q0 : X → X ⇘f⇙×⇩c⇘f⇙ X; fibered_product_left_proj X f f X ∘⇩c q0 = id⇩c X; q0 ∘⇩c fibered_product_left_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)⟧ ⟹ thesis) ⟹ thesis›*)
using assms(1,2) (*‹f : X → Y› ‹isomorphism (fibered_product_left_proj X f f X)›*) cfunc_type_def (*‹((?f::cfunc) : (?X::cset) → (?Y::cset)) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) isomorphism_def (*‹isomorphism ?f = (∃g. domain g = codomain ?f ∧ codomain g = domain ?f ∧ g ∘⇩c ?f = id⇩c (domain ?f) ∧ ?f ∘⇩c g = id⇩c (domain g))›*) apply -
(*goal: ‹(⋀q0. ⟦q0 : X → X ⇘f⇙×⇩c⇘f⇙ X; fibered_product_left_proj X f f X ∘⇩c q0 = id⇩c X; q0 ∘⇩c fibered_product_left_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)⟧ ⟹ thesis) ⟹ thesis›*)
apply typecheck_cfuncs
(*goal: ‹⟦⋀q0. ⟦q0 : X → X ⇘f⇙×⇩c⇘f⇙ X; fibered_product_left_proj X f f X ∘⇩c q0 = id⇩c X; q0 ∘⇩c fibered_product_left_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)⟧ ⟹ thesis; f : X → Y; isomorphism (fibered_product_left_proj X f f X); ⋀f X Y. (f : X → Y) = (domain f = X ∧ codomain f = Y); ⋀f. isomorphism f = (∃g. domain g = codomain f ∧ codomain g = domain f ∧ g ∘⇩c f = id⇩c (domain f) ∧ f ∘⇩c g = id⇩c (domain g))⟧ ⟹ thesis›*)
by force
obtain q1 where q1_assms: "q1 : X → X ⇘f⇙×⇩c⇘f⇙ X" "fibered_product_right_proj X f f X ∘⇩c q1 = id X" "q1 ∘⇩c fibered_product_right_proj X f f X = id (X ⇘f⇙×⇩c⇘f⇙ X)"
(*goal: ‹(⋀q1. ⟦q1 : X → X ⇘f⇙×⇩c⇘f⇙ X; fibered_product_right_proj X f f X ∘⇩c q1 = id⇩c X; q1 ∘⇩c fibered_product_right_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)⟧ ⟹ thesis) ⟹ thesis›*)
using assms(1,3) (*‹f : X → Y› ‹isomorphism (fibered_product_right_proj X f f X)›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) isomorphism_def (*‹isomorphism (?f::cfunc) = (∃g::cfunc. domain g = codomain ?f ∧ codomain g = domain ?f ∧ g ∘⇩c ?f = id⇩c (domain ?f) ∧ ?f ∘⇩c g = id⇩c (domain g))›*) apply -
(*goal: ‹(⋀q1. ⟦q1 : X → X ⇘f⇙×⇩c⇘f⇙ X; fibered_product_right_proj X f f X ∘⇩c q1 = id⇩c X; q1 ∘⇩c fibered_product_right_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)⟧ ⟹ thesis) ⟹ thesis›*)
apply typecheck_cfuncs
(*goal: ‹⟦⋀q1::cfunc. ⟦q1 : (X::cset) → X ⇘(f::cfunc)⇙×⇩c⇘f⇙ X; fibered_product_right_proj X f f X ∘⇩c q1 = id⇩c X; q1 ∘⇩c fibered_product_right_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)⟧ ⟹ thesis::bool; f : X → (Y::cset); isomorphism (fibered_product_right_proj X f f X); ⋀(f::cfunc) (X::cset) Y::cset. (f : X → Y) = (domain f = X ∧ codomain f = Y); ⋀f::cfunc. isomorphism f = (∃g::cfunc. domain g = codomain f ∧ codomain g = domain f ∧ g ∘⇩c f = id⇩c (domain f) ∧ f ∘⇩c g = id⇩c (domain g))⟧ ⟹ thesis›*)
by force
have "⋀x. x ∈⇩c domain f ⟹ q0 ∘⇩c x = q1 ∘⇩c x"
proof (-)
(*goal: ‹⋀x. x ∈⇩c domain f ⟹ q0 ∘⇩c x = q1 ∘⇩c x›*)
fix x
have fxfx: "f∘⇩c x = f∘⇩c x"
by simp
assume x_type: "x ∈⇩c domain f" (*‹(x::cfunc) ∈⇩c domain (f::cfunc)›*)
have factorsthru: "⟨x,x⟩ factorsthru fibered_product_morphism X f f X"
using assms(1) (*‹(f::cfunc) : (X::cset) → (Y::cset)›*) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) fxfx (*‹f ∘⇩c x = f ∘⇩c x›*) pair_factorsthru_fibered_product_morphism (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z; ?x : ?A → ?X; ?y : ?A → ?Y; ?f ∘⇩c ?x = ?g ∘⇩c ?y⟧ ⟹ ⟨?x,?y⟩ factorsthru fibered_product_morphism ?X ?f ?g ?Y›*) x_type (*‹x ∈⇩c domain f›*) by auto
then obtain xx where xx_assms: "xx : 𝟭 → X ⇘f⇙×⇩c⇘f⇙ X" "⟨x,x⟩ = fibered_product_morphism X f f X ∘⇩c xx"
(*goal: ‹(⋀xx. ⟦xx ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X; ⟨x,x⟩ = fibered_product_morphism X f f X ∘⇩c xx⟧ ⟹ thesis) ⟹ thesis›*)
by (smt assms( (*‹f : X → Y›*) 1) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) diag_on_elements (*‹?x ∈⇩c ?X ⟹ diagonal ?X ∘⇩c ?x = ⟨?x,?x⟩›*) diagonal_type (*‹diagonal ?X : ?X → ?X ×⇩c ?X›*) domain_comp (*‹domain ?g = codomain ?f ⟹ domain (?g ∘⇩c ?f) = domain ?f›*) factors_through_def (*‹?g factorsthru ?f = (∃h. h : domain ?g → domain ?f ∧ ?f ∘⇩c h = ?g)›*) factorsthru (*‹⟨x,x⟩ factorsthru fibered_product_morphism X f f X›*) fibered_product_morphism_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*) x_type (*‹x ∈⇩c domain f›*))
have projection_prop: "q0 ∘⇩c ((fibered_product_left_proj X f f X)∘⇩c xx) =
q1 ∘⇩c ((fibered_product_right_proj X f f X)∘⇩c xx)"
using q0_assms (*‹q0 : X → X ⇘f⇙×⇩c⇘f⇙ X› ‹fibered_product_left_proj X f f X ∘⇩c q0 = id⇩c X› ‹q0 ∘⇩c fibered_product_left_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)›*) q1_assms (*‹q1 : X → X ⇘f⇙×⇩c⇘f⇙ X› ‹fibered_product_right_proj (X::cset) (f::cfunc) f X ∘⇩c (q1::cfunc) = id⇩c X› ‹q1 ∘⇩c fibered_product_right_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)›*) xx_assms (*‹xx ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X› ‹⟨x,x⟩ = fibered_product_morphism X f f X ∘⇩c xx›*) assms (*‹f : X → Y› ‹isomorphism (fibered_product_left_proj (X::cset) (f::cfunc) f X)› ‹isomorphism (fibered_product_right_proj X f f X)›*) apply -
(*goal: ‹(q0::cfunc) ∘⇩c fibered_product_left_proj (X::cset) (f::cfunc) f X ∘⇩c (xx::cfunc) = (q1::cfunc) ∘⇩c fibered_product_right_proj X f f X ∘⇩c xx›*)
apply typecheck_cfuncs
(*goal: ‹⟦q0 : X → X ⇘f⇙×⇩c⇘f⇙ X; fibered_product_left_proj X f f X ∘⇩c q0 = id⇩c X; q0 ∘⇩c fibered_product_left_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X); q1 : X → X ⇘f⇙×⇩c⇘f⇙ X; fibered_product_right_proj X f f X ∘⇩c q1 = id⇩c X; q1 ∘⇩c fibered_product_right_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X); xx ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X; ⟨x,x⟩ = fibered_product_morphism X f f X ∘⇩c xx; f : X → Y; isomorphism (fibered_product_left_proj X f f X); isomorphism (fibered_product_right_proj X f f X)⟧ ⟹ q0 ∘⇩c fibered_product_left_proj X f f X ∘⇩c xx = q1 ∘⇩c fibered_product_right_proj X f f X ∘⇩c xx›*)
by (simp add: comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*))
then have fun_fact: "x = ((fibered_product_left_proj X f f X) ∘⇩c q1)∘⇩c (((fibered_product_left_proj X f f X)∘⇩c xx))"
by (smt assms( (*‹f : X → Y›*) 1) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) fibered_product_left_proj_def (*‹fibered_product_left_proj ?X ?f ?g ?Y = left_cart_proj ?X ?Y ∘⇩c fibered_product_morphism ?X ?f ?g ?Y›*) fibered_product_left_proj_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_left_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X›*) fibered_product_morphism_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*) fibered_product_right_proj_def (*‹fibered_product_right_proj ?X ?f ?g ?Y = right_cart_proj ?X ?Y ∘⇩c fibered_product_morphism ?X ?f ?g ?Y›*) fibered_product_right_proj_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_right_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?Y›*) id_left_unit2 (*‹?f : ?X → ?Y ⟹ id⇩c ?Y ∘⇩c ?f = ?f›*) left_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ left_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?f›*) left_cart_proj_type (*‹left_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?X›*) q1_assms (*‹q1 : X → X ⇘f⇙×⇩c⇘f⇙ X› ‹fibered_product_right_proj X f f X ∘⇩c q1 = id⇩c X› ‹q1 ∘⇩c fibered_product_right_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)›*) right_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ right_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?g›*) right_cart_proj_type (*‹right_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?Y›*) x_type (*‹x ∈⇩c domain f›*) xx_assms (*‹xx ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X› ‹⟨x,x⟩ = fibered_product_morphism X f f X ∘⇩c xx›*))
then have "q1 ∘⇩c ((fibered_product_left_proj X f f X)∘⇩c xx) =
q0 ∘⇩c ((fibered_product_left_proj X f f X)∘⇩c xx)"
using q0_assms (*‹q0 : X → X ⇘f⇙×⇩c⇘f⇙ X› ‹fibered_product_left_proj X f f X ∘⇩c q0 = id⇩c X› ‹q0 ∘⇩c fibered_product_left_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)›*) q1_assms (*‹(q1::cfunc) : (X::cset) → X ⇘(f::cfunc)⇙×⇩c⇘f⇙ X› ‹fibered_product_right_proj X f f X ∘⇩c q1 = id⇩c X› ‹q1 ∘⇩c fibered_product_right_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)›*) xx_assms (*‹xx ∈⇩c X ⇘f⇙×⇩c⇘f⇙ X› ‹⟨x,x⟩ = fibered_product_morphism X f f X ∘⇩c xx›*) assms (*‹f : X → Y› ‹isomorphism (fibered_product_left_proj X f f X)› ‹isomorphism (fibered_product_right_proj X f f X)›*) apply typecheck_cfuncs
(*goal: ‹q1 ∘⇩c fibered_product_left_proj X f f X ∘⇩c xx = q0 ∘⇩c fibered_product_left_proj X f f X ∘⇩c xx›*)
by (smt cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) fibered_product_left_proj_def (*‹fibered_product_left_proj ?X ?f ?g ?Y = left_cart_proj ?X ?Y ∘⇩c fibered_product_morphism ?X ?f ?g ?Y›*) fibered_product_morphism_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_morphism ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X ×⇩c ?Y›*) fibered_product_right_proj_def (*‹fibered_product_right_proj ?X ?f ?g ?Y = right_cart_proj ?X ?Y ∘⇩c fibered_product_morphism ?X ?f ?g ?Y›*) left_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ left_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?f›*) left_cart_proj_type (*‹left_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?X›*) projection_prop (*‹q0 ∘⇩c fibered_product_left_proj X f f X ∘⇩c xx = q1 ∘⇩c fibered_product_right_proj X f f X ∘⇩c xx›*) right_cart_proj_cfunc_prod (*‹⟦?f : ?Z → ?X; ?g : ?Z → ?Y⟧ ⟹ right_cart_proj ?X ?Y ∘⇩c ⟨?f,?g⟩ = ?g›*) right_cart_proj_type (*‹right_cart_proj ?X ?Y : ?X ×⇩c ?Y → ?Y›*) x_type (*‹x ∈⇩c domain f›*) xx_assms( (*‹⟨x,x⟩ = fibered_product_morphism X f f X ∘⇩c xx›*) 2))
then show "q0 ∘⇩c x = q1 ∘⇩c x"
by (smt assms( (*‹(f::cfunc) : (X::cset) → (Y::cset)›*) 1) cfunc_type_def (*‹((?f::cfunc) : (?X::cset) → (?Y::cset)) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) codomain_comp (*‹domain (?g::cfunc) = codomain (?f::cfunc) ⟹ codomain (?g ∘⇩c ?f) = codomain ?g›*) comp_associative (*‹⟦domain (?h::cfunc) = codomain (?g::cfunc); domain ?g = codomain (?f::cfunc)⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) fibered_product_left_proj_type (*‹⟦(?f::cfunc) : (?X::cset) → (?Z::cset); (?g::cfunc) : (?Y::cset) → ?Z⟧ ⟹ fibered_product_left_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X›*) fun_fact (*‹(x::cfunc) = (fibered_product_left_proj (X::cset) (f::cfunc) f X ∘⇩c (q1::cfunc)) ∘⇩c fibered_product_left_proj X f f X ∘⇩c (xx::cfunc)›*) id_left_unit2 (*‹(?f::cfunc) : (?X::cset) → (?Y::cset) ⟹ id⇩c ?Y ∘⇩c ?f = ?f›*) q0_assms (*‹(q0::cfunc) : (X::cset) → X ⇘(f::cfunc)⇙×⇩c⇘f⇙ X› ‹fibered_product_left_proj (X::cset) (f::cfunc) f X ∘⇩c (q0::cfunc) = id⇩c X› ‹(q0::cfunc) ∘⇩c fibered_product_left_proj (X::cset) (f::cfunc) f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)›*) q1_assms (*‹(q1::cfunc) : (X::cset) → X ⇘(f::cfunc)⇙×⇩c⇘f⇙ X› ‹fibered_product_right_proj (X::cset) (f::cfunc) f X ∘⇩c (q1::cfunc) = id⇩c X› ‹(q1::cfunc) ∘⇩c fibered_product_right_proj (X::cset) (f::cfunc) f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)›*) xx_assms (*‹(xx::cfunc) ∈⇩c (X::cset) ⇘(f::cfunc)⇙×⇩c⇘f⇙ X› ‹⟨x::cfunc,x⟩ = fibered_product_morphism (X::cset) (f::cfunc) f X ∘⇩c (xx::cfunc)›*))
qed
then have "q0 = q1"
by (metis assms( (*‹f : X → Y›*) 1) cfunc_type_def (*‹(?f : ?X → ?Y) = (domain ?f = ?X ∧ codomain ?f = ?Y)›*) one_separator_contrapos (*‹⟦?f : ?X → ?Y; ?g : ?X → ?Y; ?f ≠ ?g⟧ ⟹ ∃x. x ∈⇩c ?X ∧ ?f ∘⇩c x ≠ ?g ∘⇩c x›*) q0_assms( (*‹q0 : X → X ⇘f⇙×⇩c⇘f⇙ X›*) 1) q1_assms( (*‹q1 : X → X ⇘f⇙×⇩c⇘f⇙ X›*) 1))
then show "fibered_product_left_proj X f f X = fibered_product_right_proj X f f X"
by (smt assms( (*‹f : X → Y›*) 1) comp_associative2 (*‹⟦?f : ?X → ?Y; ?g : ?Y → ?Z; ?h : ?Z → ?W⟧ ⟹ ?h ∘⇩c ?g ∘⇩c ?f = (?h ∘⇩c ?g) ∘⇩c ?f›*) fibered_product_left_proj_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_left_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?X›*) fibered_product_right_proj_type (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ fibered_product_right_proj ?X ?f ?g ?Y : ?X ⇘?f⇙×⇩c⇘?g⇙ ?Y → ?Y›*) id_left_unit2 (*‹?f : ?X → ?Y ⟹ id⇩c ?Y ∘⇩c ?f = ?f›*) id_right_unit2 (*‹?f : ?X → ?Y ⟹ ?f ∘⇩c id⇩c ?X = ?f›*) q0_assms (*‹q0 : X → X ⇘f⇙×⇩c⇘f⇙ X› ‹fibered_product_left_proj X f f X ∘⇩c q0 = id⇩c X› ‹q0 ∘⇩c fibered_product_left_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)›*) q1_assms (*‹q1 : X → X ⇘f⇙×⇩c⇘f⇙ X› ‹fibered_product_right_proj X f f X ∘⇩c q1 = id⇩c X› ‹q1 ∘⇩c fibered_product_right_proj X f f X = id⇩c (X ⇘f⇙×⇩c⇘f⇙ X)›*))
qed
lemma terminal_fib_prod_iso:
assumes "terminal_object(T)"
assumes f_type: "f : Y → T"
assumes g_type: "g : X → T"
shows "(X ⇘g⇙×⇩c⇘f⇙ Y) ≅ X ×⇩c Y"
proof (-)
(*goal: ‹X ⇘g⇙×⇩c⇘f⇙ Y ≅ X ×⇩c Y›*)
have "(is_pullback (X ⇘g⇙×⇩c⇘f⇙ Y) Y X T (fibered_product_right_proj X g f Y) f (fibered_product_left_proj X g f Y) g)"
using assms (*‹terminal_object T› ‹f : Y → T› ‹g : X → T›*) pullback_iff_product (*‹⟦terminal_object ?T; ?f : ?Y → ?T; ?g : ?X → ?T⟧ ⟹ is_pullback ?P ?Y ?X ?T ?pY ?f ?pX ?g = is_cart_prod ?P ?pX ?pY ?X ?Y›*) fibered_product_is_pullback (*‹⟦?f : ?X → ?Z; ?g : ?Y → ?Z⟧ ⟹ is_pullback (?X ⇘?f⇙×⇩c⇘?g⇙ ?Y) ?Y ?X ?Z (fibered_product_right_proj ?X ?f ?g ?Y) ?g (fibered_product_left_proj ?X ?f ?g ?Y) ?f›*) apply -
(*goal: ‹is_pullback (X ⇘g⇙×⇩c⇘f⇙ Y) Y X T (fibered_product_right_proj X g f Y) f (fibered_product_left_proj X g f Y) g›*)
apply typecheck_cfuncs
(*goal: ‹⟦terminal_object T; f : Y → T; g : X → T; ⋀T f Y g X P pY pX. ⟦terminal_object T; f : Y → T; g : X → T⟧ ⟹ is_pullback P Y X T pY f pX g = is_cart_prod P pX pY X Y; ⋀f X Z g Y. ⟦f : X → Z; g : Y → Z⟧ ⟹ is_pullback (X ⇘f⇙×⇩c⇘g⇙ Y) Y X Z (fibered_product_right_proj X f g Y) g (fibered_product_left_proj X f g Y) f⟧ ⟹ is_pullback (X ⇘g⇙×⇩c⇘f⇙ Y) Y X T (fibered_product_right_proj X g f Y) f (fibered_product_left_proj X g f Y) g›*)
by blast
then have "(is_cart_prod (X ⇘g⇙×⇩c⇘f⇙ Y) (fibered_product_left_proj X g f Y) (fibered_product_right_proj X g f Y) X Y)"
using assms (*‹terminal_object T› ‹f : Y → T› ‹g : X → T›*) by (meson one_terminal_object (*‹terminal_object 𝟭›*) pullback_iff_product (*‹⟦terminal_object ?T; ?f : ?Y → ?T; ?g : ?X → ?T⟧ ⟹ is_pullback ?P ?Y ?X ?T ?pY ?f ?pX ?g = is_cart_prod ?P ?pX ?pY ?X ?Y›*) terminal_func_type (*‹β⇘?X⇙ : ?X → 𝟭›*))
then show "?thesis"
(*goal: ‹(X::cset) ⇘(g::cfunc)⇙×⇩c⇘(f::cfunc)⇙ (Y::cset) ≅ X ×⇩c Y›*)
using assms (*‹terminal_object T› ‹f : Y → T› ‹g : X → T›*) by (metis canonical_cart_prod_is_cart_prod (*‹is_cart_prod (?X ×⇩c ?Y) (left_cart_proj ?X ?Y) (right_cart_proj ?X ?Y) ?X ?Y›*) cart_prods_isomorphic (*‹⟦is_cart_prod_triple (?W, ?π₀, ?π₁) ?X ?Y; is_cart_prod_triple (?W', ?π'₀, ?π'₁) ?X ?Y⟧ ⟹ ∃f. f : ?W → ?W' ∧ isomorphism f ∧ ?π'₀ ∘⇩c f = ?π₀ ∧ ?π'₁ ∘⇩c f = ?π₁›*) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) is_isomorphic_def (*‹(?X ≅ ?Y) = (∃f. f : ?X → ?Y ∧ isomorphism f)›*) snd_conv (*‹snd (?x1.0, ?x2.0) = ?x2.0›*))
qed
end | {
"path": "afp-2025-02-12/thys/Category_Set/Equalizer.thy",
"repo": "afp-2025-02-12",
"sha": "35febde2d53f50b8c8974ba0ddad84afdf18778ed133ff85c34b34159b665633"
} |
section‹Homology, I: Simplices›
theory "Simplices"
imports
"HOL-Analysis.Function_Metric"
"HOL-Analysis.Abstract_Euclidean_Space"
"HOL-Algebra.Free_Abelian_Groups"
begin
subsection‹Standard simplices, all of which are topological subspaces of @{text"R^n"}. ›
type_synonym 'a chain = "((nat ⇒ real) ⇒ 'a) ⇒₀ int"
definition standard_simplex :: "nat ⇒ (nat ⇒ real) set" where
"standard_simplex p ≡
{x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>p. x i = 0) ∧ (∑i≤p. x i) = 1}"
lemma topspace_standard_simplex:
"topspace(subtopology (powertop_real UNIV) (standard_simplex p))
= standard_simplex p"
by simp
lemma basis_in_standard_simplex [simp]:
"(λj. if j = i then 1 else 0) ∈ standard_simplex p ⟷ i ≤ p"
by (auto simp: standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*))
lemma nonempty_standard_simplex: "standard_simplex p ≠ {}"
using basis_in_standard_simplex (*‹((λj. if j = ?i then 1 else 0) ∈ standard_simplex ?p) = (?i ≤ ?p)›*) by blast
lemma standard_simplex_0: "standard_simplex 0 = {(λj. if j = 0 then 1 else 0)}"
by (auto simp: standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*))
lemma standard_simplex_mono:
assumes "p ≤ q"
shows "standard_simplex p ⊆ standard_simplex q"
using assms (*‹p ≤ q›*) proof (clarsimp simp: standard_simplex_def (*‹standard_simplex (?p::nat) ≡ {x::nat ⇒ real. (∀i::nat. (0::real) ≤ x i ∧ x i ≤ (1::real)) ∧ (∀i>?p. x i = (0::real)) ∧ sum x {..?p} = (1::real)}›*))
(*goal: ‹⋀x. ⟦p ≤ q; ∀i. 0 ≤ x i ∧ x i ≤ 1; ∀i>p. x i = 0; sum x {..p} = 1⟧ ⟹ sum x {..q} = 1›*)
fix x :: "nat ⇒ real"
assume "∀i. 0 ≤ x i ∧ x i ≤ 1" and "∀i>p. x i = 0" and "sum x {..p} = 1" (*‹∀i::nat. (0::real) ≤ (x::nat ⇒ real) i ∧ x i ≤ (1::real)› ‹∀i>p::nat. (x::nat ⇒ real) i = (0::real)› ‹sum (x::nat ⇒ real) {..p::nat} = (1::real)›*)
then show "sum x {..q} = 1"
using sum.mono_neutral_left[of "{..q}" "{..p}" x] (*‹⟦finite {..q}; {..p} ⊆ {..q}; ∀i∈{..q} - {..p}. x i = 0⟧ ⟹ sum x {..p} = sum x {..q}›*) assms (*‹(p::nat) ≤ (q::nat)›*) by auto
qed
lemma closedin_standard_simplex:
"closedin (powertop_real UNIV) (standard_simplex p)"
(is "closedin ?X ?S")
proof (-)
(*goal: ‹closedin (powertop_real UNIV) (standard_simplex p)›*)
have eq: "standard_simplex p =
(⋂i. {x. x ∈ topspace ?X ∧ x i ∈ {0..1}}) ∩
(⋂i ∈ {p<..}. {x ∈ topspace ?X. x i ∈ {0}}) ∩
{x ∈ topspace ?X. (∑i≤p. x i) ∈ {1}}"
by (auto simp: standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*) topspace_product_topology (*‹topspace (product_topology ?T ?I) = (Π⇩E i∈?I. topspace (?T i))›*))
show "?thesis"
(*goal: ‹closedin (powertop_real UNIV) (standard_simplex p)›*)
unfolding eq
(*goal: ‹closedin (powertop_real UNIV) ((⋂i. {x ∈ topspace (powertop_real UNIV). x i ∈ {0..1}}) ∩ (⋂i∈{p<..}. {x ∈ topspace (powertop_real UNIV). x i ∈ {0}}) ∩ {x ∈ topspace (powertop_real UNIV). sum x {..p} ∈ {1}})›*)
apply (rule closedin_Int (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∩ ?T)›*) closedin_Inter (*‹⟦?K ≠ {}; ⋀S. S ∈ ?K ⟹ closedin ?U S⟧ ⟹ closedin ?U (⋂ ?K)›*) continuous_map_sum (*‹⟦finite ?I; ⋀i. i ∈ ?I ⟹ continuous_map ?X euclidean (λx. ?f x i)⟧ ⟹ continuous_map ?X euclidean (λx. sum (?f x) ?I)›*) continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*) closedin_continuous_map_preimage (*‹⟦continuous_map ?X ?Y ?f; closedin ?Y ?C⟧ ⟹ closedin ?X {x ∈ topspace ?X. ?f x ∈ ?C}›*))
(*goals:
1. ‹closedin (powertop_real UNIV) ((⋂i. {x ∈ topspace (powertop_real UNIV). x i ∈ {0..1}}) ∩ (⋂i∈{p<..}. {x ∈ topspace (powertop_real UNIV). x i ∈ {0}}))›
2. ‹closedin (powertop_real UNIV) {x ∈ topspace (powertop_real UNIV). sum x {..p} ∈ {1}}›
discuss goal 1*)
apply (rule closedin_Int (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∩ ?T)›*) closedin_Inter (*‹⟦?K ≠ {}; ⋀S. S ∈ ?K ⟹ closedin ?U S⟧ ⟹ closedin ?U (⋂ ?K)›*) continuous_map_sum (*‹⟦finite ?I; ⋀i. i ∈ ?I ⟹ continuous_map ?X euclidean (λx. ?f x i)⟧ ⟹ continuous_map ?X euclidean (λx. sum (?f x) ?I)›*) continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*) closedin_continuous_map_preimage (*‹⟦continuous_map ?X ?Y ?f; closedin ?Y ?C⟧ ⟹ closedin ?X {x ∈ topspace ?X. ?f x ∈ ?C}›*))
(*goals:
1. ‹closedin (powertop_real UNIV) (⋂i. {x ∈ topspace (powertop_real UNIV). x i ∈ {0..1}})›
2. ‹closedin (powertop_real UNIV) (⋂i∈{p<..}. {x ∈ topspace (powertop_real UNIV). x i ∈ {0}})›
discuss goal 1*)
apply (rule closedin_Int (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∩ ?T)›*) closedin_Inter (*‹⟦?K ≠ {}; ⋀S. S ∈ ?K ⟹ closedin ?U S⟧ ⟹ closedin ?U (⋂ ?K)›*) continuous_map_sum (*‹⟦finite ?I; ⋀i. i ∈ ?I ⟹ continuous_map ?X euclidean (λx. ?f x i)⟧ ⟹ continuous_map ?X euclidean (λx. sum (?f x) ?I)›*) continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*) closedin_continuous_map_preimage (*‹⟦continuous_map ?X ?Y ?f; closedin ?Y ?C⟧ ⟹ closedin ?X {x ∈ topspace ?X. ?f x ∈ ?C}›*))
(*goals:
1. ‹range (λi. {x ∈ topspace (powertop_real UNIV). x i ∈ {0..1}}) ≠ {}›
2. ‹⋀S. S ∈ range (λi. {x ∈ topspace (powertop_real UNIV). x i ∈ {0..1}}) ⟹ closedin (powertop_real UNIV) S›
discuss goal 1*)
apply force
(*discuss goal 2*)
apply clarify
(*top goal: ‹⋀S. S ∈ range (λi. {x ∈ topspace (powertop_real UNIV). x i ∈ {0..1}}) ⟹ closedin (powertop_real UNIV) S› and 2 goals remain*)
apply (rule closedin_Int (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∩ ?T)›*) closedin_Inter (*‹⟦?K ≠ {}; ⋀S. S ∈ ?K ⟹ closedin ?U S⟧ ⟹ closedin ?U (⋂ ?K)›*) continuous_map_sum (*‹⟦finite ?I; ⋀i. i ∈ ?I ⟹ continuous_map ?X euclidean (λx. ?f x i)⟧ ⟹ continuous_map ?X euclidean (λx. sum (?f x) ?I)›*) continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*) closedin_continuous_map_preimage (*‹⟦continuous_map ?X ?Y ?f; closedin ?Y ?C⟧ ⟹ closedin ?X {x ∈ topspace ?X. ?f x ∈ ?C}›*))
(*goals:
1. ‹⋀S i. i ∈ UNIV ⟹ continuous_map (powertop_real UNIV) (?Y18 S i) (λx. x i)›
2. ‹⋀S i. i ∈ UNIV ⟹ closedin (?Y18 S i) {0..1}›
discuss goal 1*)
apply (rule closedin_Int (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∩ ?T)›*) closedin_Inter (*‹⟦?K ≠ {}; ⋀S. S ∈ ?K ⟹ closedin ?U S⟧ ⟹ closedin ?U (⋂ ?K)›*) continuous_map_sum (*‹⟦finite ?I; ⋀i. i ∈ ?I ⟹ continuous_map ?X euclidean (λx. ?f x i)⟧ ⟹ continuous_map ?X euclidean (λx. sum (?f x) ?I)›*) continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*) closedin_continuous_map_preimage (*‹⟦continuous_map ?X ?Y ?f; closedin ?Y ?C⟧ ⟹ closedin ?X {x ∈ topspace ?X. ?f x ∈ ?C}›*))
(*top goal: ‹⋀S i. i ∈ UNIV ⟹ continuous_map (powertop_real UNIV) (?Y18 S i) (λx. x i)› and 3 goals remain*)
apply force
(*discuss goal 2*)
apply force
(*proven 2 subgoals*)
(*proven 2 subgoals*)
(*discuss goal 2*)
apply (rule closedin_Int (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∩ ?T)›*) closedin_Inter (*‹⟦?K ≠ {}; ⋀S. S ∈ ?K ⟹ closedin ?U S⟧ ⟹ closedin ?U (⋂ ?K)›*) continuous_map_sum (*‹⟦finite ?I; ⋀i. i ∈ ?I ⟹ continuous_map ?X euclidean (λx. ?f x i)⟧ ⟹ continuous_map ?X euclidean (λx. sum (?f x) ?I)›*) continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*) closedin_continuous_map_preimage (*‹⟦continuous_map ?X ?Y ?f; closedin ?Y ?C⟧ ⟹ closedin ?X {x ∈ topspace ?X. ?f x ∈ ?C}›*))
(*goals:
1. ‹(λi::nat. {x::nat ⇒ real ∈ topspace (powertop_real UNIV). x i ∈ {0::real}}) ` {p::nat<..} ≠ {}›
2. ‹⋀S::(nat ⇒ real) set. S ∈ (λi::nat. {x::nat ⇒ real ∈ topspace (powertop_real UNIV). x i ∈ {0::real}}) ` {p::nat<..} ⟹ closedin (powertop_real UNIV) S›
discuss goal 1*)
apply force
(*discuss goal 2*)
apply clarify
(*top goal: ‹⋀S. S ∈ (λi. {x ∈ topspace (powertop_real UNIV). x i ∈ {0}}) ` {p<..} ⟹ closedin (powertop_real UNIV) S› and 1 goal remains*)
apply (rule closedin_Int (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∩ ?T)›*) closedin_Inter (*‹⟦?K ≠ {}; ⋀S. S ∈ ?K ⟹ closedin ?U S⟧ ⟹ closedin ?U (⋂ ?K)›*) continuous_map_sum (*‹⟦finite ?I; ⋀i. i ∈ ?I ⟹ continuous_map ?X euclidean (λx. ?f x i)⟧ ⟹ continuous_map ?X euclidean (λx. sum (?f x) ?I)›*) continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*) closedin_continuous_map_preimage (*‹⟦continuous_map ?X ?Y ?f; closedin ?Y ?C⟧ ⟹ closedin ?X {x ∈ topspace ?X. ?f x ∈ ?C}›*))
(*goals:
1. ‹⋀S i. p < i ⟹ continuous_map (powertop_real UNIV) (?Y39 S i) (λx. x i)›
2. ‹⋀S i. p < i ⟹ closedin (?Y39 S i) {0}›
discuss goal 1*)
apply (rule closedin_Int (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∩ ?T)›*) closedin_Inter (*‹⟦?K ≠ {}; ⋀S. S ∈ ?K ⟹ closedin ?U S⟧ ⟹ closedin ?U (⋂ ?K)›*) continuous_map_sum (*‹⟦finite ?I; ⋀i. i ∈ ?I ⟹ continuous_map ?X euclidean (λx. ?f x i)⟧ ⟹ continuous_map ?X euclidean (λx. sum (?f x) ?I)›*) continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*) closedin_continuous_map_preimage (*‹⟦continuous_map ?X ?Y ?f; closedin ?Y ?C⟧ ⟹ closedin ?X {x ∈ topspace ?X. ?f x ∈ ?C}›*))
(*top goal: ‹⋀S i. p < i ⟹ continuous_map (powertop_real UNIV) (?Y39 S i) (λx. x i)› and 2 goals remain*)
apply force
(*discuss goal 2*)
apply force
(*proven 2 subgoals*)
(*proven 2 subgoals*)
(*proven 2 subgoals*)
(*discuss goal 2*)
apply (rule closedin_Int (*‹⟦closedin (?U::?'a topology) (?S::?'a set); closedin ?U (?T::?'a set)⟧ ⟹ closedin ?U (?S ∩ ?T)›*) closedin_Inter (*‹⟦(?K::?'a set set) ≠ {}; ⋀S::?'a set. S ∈ ?K ⟹ closedin (?U::?'a topology) S⟧ ⟹ closedin ?U (⋂ ?K)›*) continuous_map_sum (*‹⟦finite (?I::?'b set); ⋀i::?'b. i ∈ ?I ⟹ continuous_map (?X::?'a topology) euclidean (λx::?'a. (?f::?'a ⇒ ?'b ⇒ ?'c) x i)⟧ ⟹ continuous_map ?X euclidean (λx::?'a. sum (?f x) ?I)›*) continuous_map_product_projection (*‹(?k::?'a) ∈ (?I::?'a set) ⟹ continuous_map (product_topology (?X::?'a ⇒ ?'b topology) ?I) (?X ?k) (λx::?'a ⇒ ?'b. x ?k)›*) closedin_continuous_map_preimage (*‹⟦continuous_map (?X::?'a topology) (?Y::?'b topology) (?f::?'a ⇒ ?'b); closedin ?Y (?C::?'b set)⟧ ⟹ closedin ?X {x::?'a ∈ topspace ?X. ?f x ∈ ?C}›*))
(*goals:
1. ‹continuous_map (powertop_real UNIV) ?Y48 (λx. sum x {..p})›
2. ‹closedin ?Y48 {1}›
discuss goal 1*)
apply (rule closedin_Int (*‹⟦closedin (?U::?'a topology) (?S::?'a set); closedin ?U (?T::?'a set)⟧ ⟹ closedin ?U (?S ∩ ?T)›*) closedin_Inter (*‹⟦(?K::?'a set set) ≠ {}; ⋀S::?'a set. S ∈ ?K ⟹ closedin (?U::?'a topology) S⟧ ⟹ closedin ?U (⋂ ?K)›*) continuous_map_sum (*‹⟦finite (?I::?'b set); ⋀i::?'b. i ∈ ?I ⟹ continuous_map (?X::?'a topology) euclidean (λx::?'a. (?f::?'a ⇒ ?'b ⇒ ?'c) x i)⟧ ⟹ continuous_map ?X euclidean (λx::?'a. sum (?f x) ?I)›*) continuous_map_product_projection (*‹(?k::?'a) ∈ (?I::?'a set) ⟹ continuous_map (product_topology (?X::?'a ⇒ ?'b topology) ?I) (?X ?k) (λx::?'a ⇒ ?'b. x ?k)›*) closedin_continuous_map_preimage (*‹⟦continuous_map (?X::?'a topology) (?Y::?'b topology) (?f::?'a ⇒ ?'b); closedin ?Y (?C::?'b set)⟧ ⟹ closedin ?X {x::?'a ∈ topspace ?X. ?f x ∈ ?C}›*))
(*goals:
1. ‹finite {..p}›
2. ‹⋀i. i ∈ {..p} ⟹ continuous_map (powertop_real UNIV) euclideanreal (λx. x i)›
discuss goal 1*)
apply force
(*discuss goal 2*)
apply (rule closedin_Int (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∩ ?T)›*) closedin_Inter (*‹⟦?K ≠ {}; ⋀S. S ∈ ?K ⟹ closedin ?U S⟧ ⟹ closedin ?U (⋂ ?K)›*) continuous_map_sum (*‹⟦finite ?I; ⋀i. i ∈ ?I ⟹ continuous_map ?X euclidean (λx. ?f x i)⟧ ⟹ continuous_map ?X euclidean (λx. sum (?f x) ?I)›*) continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*) closedin_continuous_map_preimage (*‹⟦continuous_map ?X ?Y ?f; closedin ?Y ?C⟧ ⟹ closedin ?X {x ∈ topspace ?X. ?f x ∈ ?C}›*))
(*top goal: ‹⋀i::nat. i ∈ {..p::nat} ⟹ continuous_map (powertop_real UNIV) euclideanreal (λx::nat ⇒ real. x i)› and 1 goal remains*)
apply force
(*proven 2 subgoals*)
(*discuss goal 2*)
apply force
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
qed
lemma standard_simplex_01: "standard_simplex p ⊆ UNIV →⇩E {0..1}"
using standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*) by auto
lemma compactin_standard_simplex:
"compactin (powertop_real UNIV) (standard_simplex p)"
proof (rule closed_compactin (*‹⟦compactin ?X ?K; ?C ⊆ ?K; closedin ?X ?C⟧ ⟹ compactin ?X ?C›*))
(*goals:
1. ‹compactin (powertop_real UNIV) ?K›
2. ‹standard_simplex p ⊆ ?K›
3. ‹closedin (powertop_real UNIV) (standard_simplex p)›*)
show "compactin (powertop_real UNIV) (UNIV →⇩E {0..1})"
by (simp add: compactin_PiE (*‹compactin (product_topology (?X::?'a ⇒ ?'b topology) (?I::?'a set)) (Pi⇩E ?I (?S::?'a ⇒ ?'b set)) = (Pi⇩E ?I ?S = {} ∨ (∀i::?'a∈?I. compactin (?X i) (?S i)))›*))
show "standard_simplex p ⊆ UNIV →⇩E {0..1}"
by (simp add: standard_simplex_01 (*‹standard_simplex ?p ⊆ UNIV →⇩E {0..1}›*))
show "closedin (powertop_real UNIV) (standard_simplex p)"
by (simp add: closedin_standard_simplex (*‹closedin (powertop_real UNIV) (standard_simplex ?p)›*))
qed
lemma convex_standard_simplex:
"⟦x ∈ standard_simplex p; y ∈ standard_simplex p;
0 ≤ u; u ≤ 1⟧
⟹ (λi. (1 - u) * x i + u * y i) ∈ standard_simplex p"
by (simp add: standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*) sum.distrib (*‹(∑x∈?A. ?g x + ?h x) = sum ?g ?A + sum ?h ?A›*) convex_bound_le (*‹⟦?x ≤ ?a; ?y ≤ ?a; 0 ≤ ?u; 0 ≤ ?v; ?u + ?v = 1⟧ ⟹ ?u * ?x + ?v * ?y ≤ ?a›*) flip: sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*))
lemma path_connectedin_standard_simplex:
"path_connectedin (powertop_real UNIV) (standard_simplex p)"
proof (-)
(*goal: ‹path_connectedin (powertop_real UNIV) (standard_simplex p)›*)
define g where "g ≡ λx y::nat⇒real. λu i. (1 - u) * x i + u * y i"
have "continuous_map
(subtopology euclideanreal {0..1}) (powertop_real UNIV)
(g x y)" if "x ∈ standard_simplex p" "y ∈ standard_simplex p" for x and y
unfolding g_def continuous_map_componentwise
(*goal: ‹(λu i. (1 - u) * x i + u * y i) ` topspace (top_of_set {0..1}) ⊆ extensional UNIV ∧ (∀k∈UNIV. continuous_map (top_of_set {0..1}) euclideanreal (λxa. (1 - xa) * x k + xa * y k))›*)
by (force intro: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 190 facts*))
moreover have "g x y ` {0..1} ⊆ standard_simplex p" "g x y 0 = x" "g x y 1 = y" if "x ∈ standard_simplex p" "y ∈ standard_simplex p" for x and y
using that (*‹x ∈ standard_simplex p› ‹y ∈ standard_simplex p›*) apply -
(*goals:
1. ‹⟦x ∈ standard_simplex p; y ∈ standard_simplex p⟧ ⟹ g x y ` {0..1} ⊆ standard_simplex p›
2. ‹⟦x ∈ standard_simplex p; y ∈ standard_simplex p⟧ ⟹ g x y 0 = x›
3. ‹⟦x ∈ standard_simplex p; y ∈ standard_simplex p⟧ ⟹ g x y 1 = y›
discuss goal 1*)
apply ((auto simp: convex_standard_simplex (*‹⟦?x ∈ standard_simplex ?p; ?y ∈ standard_simplex ?p; 0 ≤ ?u; ?u ≤ 1⟧ ⟹ (λi. (1 - ?u) * ?x i + ?u * ?y i) ∈ standard_simplex ?p›*) g_def (*‹g ≡ λx y u i. (1 - u) * x i + u * y i›*))[1])
(*discuss goal 2*)
apply ((auto simp: convex_standard_simplex (*‹⟦?x ∈ standard_simplex ?p; ?y ∈ standard_simplex ?p; 0 ≤ ?u; ?u ≤ 1⟧ ⟹ (λi. (1 - ?u) * ?x i + ?u * ?y i) ∈ standard_simplex ?p›*) g_def (*‹g ≡ λx y u i. (1 - u) * x i + u * y i›*))[1])
(*discuss goal 3*)
apply ((auto simp: convex_standard_simplex (*‹⟦?x ∈ standard_simplex ?p; ?y ∈ standard_simplex ?p; 0 ≤ ?u; ?u ≤ 1⟧ ⟹ (λi. (1 - ?u) * ?x i + ?u * ?y i) ∈ standard_simplex ?p›*) g_def (*‹g ≡ λx y u i. (1 - u) * x i + u * y i›*))[1])
(*proven 3 subgoals*) .
ultimately show "?thesis"
(*goal: ‹path_connectedin (powertop_real UNIV) (standard_simplex p)›*)
unfolding path_connectedin_def path_connected_space_def pathin_def
(*goal: ‹standard_simplex p ⊆ topspace (powertop_real UNIV) ∧ (∀x∈topspace (subtopology (powertop_real UNIV) (standard_simplex p)). ∀y∈topspace (subtopology (powertop_real UNIV) (standard_simplex p)). ∃g. continuous_map (top_of_set {0..1}) (subtopology (powertop_real UNIV) (standard_simplex p)) g ∧ g 0 = x ∧ g 1 = y)›*)
by (metis continuous_map_in_subtopology (*‹continuous_map ?X (subtopology ?X' ?S) ?f = (continuous_map ?X ?X' ?f ∧ ?f ` topspace ?X ⊆ ?S)›*) euclidean_product_topology (*‹product_topology (λi. euclidean) UNIV = euclidean›*) top_greatest (*‹?a ≤ top_class.top›*) topspace_euclidean (*‹topspace euclidean = UNIV›*) topspace_euclidean_subtopology (*‹topspace (top_of_set ?S) = ?S›*))
qed
lemma connectedin_standard_simplex:
"connectedin (powertop_real UNIV) (standard_simplex p)"
by (simp add: path_connectedin_imp_connectedin (*‹path_connectedin ?X ?S ⟹ connectedin ?X ?S›*) path_connectedin_standard_simplex (*‹path_connectedin (powertop_real UNIV) (standard_simplex ?p)›*))
subsection‹Face map›
definition simplical_face :: "nat ⇒ (nat ⇒ 'a) ⇒ nat ⇒ 'a::comm_monoid_add" where
"simplical_face k x ≡ λi. if i < k then x i else if i = k then 0 else x(i -1)"
lemma simplical_face_in_standard_simplex:
assumes "1 ≤ p" "k ≤ p" "x ∈ standard_simplex (p - Suc 0)"
shows "(simplical_face k x) ∈ standard_simplex p"
proof (-)
(*goal: ‹simplical_face (k::nat) (x::nat ⇒ real) ∈ standard_simplex (p::nat)›*)
have x01: "⋀i. 0 ≤ x i ∧ x i ≤ 1" and sumx: "sum x {..p - Suc 0} = 1"
using assms (*‹1 ≤ p› ‹k ≤ p› ‹x ∈ standard_simplex (p - Suc 0)›*) apply -
(*goals:
1. ‹⋀i. ⟦1 ≤ p; k ≤ p; x ∈ standard_simplex (p - Suc 0)⟧ ⟹ 0 ≤ x i ∧ x i ≤ 1›
2. ‹⟦1 ≤ p; k ≤ p; x ∈ standard_simplex (p - Suc 0)⟧ ⟹ sum x {..p - Suc 0} = 1›
discuss goal 1*)
apply ((auto simp: standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*) simplical_face_def (*‹simplical_face ?k ?x ≡ λi. if i < ?k then ?x i else if i = ?k then 0 else ?x (i - 1)›*))[1])
(*discuss goal 2*)
apply ((auto simp: standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*) simplical_face_def (*‹simplical_face ?k ?x ≡ λi. if i < ?k then ?x i else if i = ?k then 0 else ?x (i - 1)›*))[1])
(*proven 2 subgoals*) .
have gg: "⋀g. sum g {..p} = sum g {..<k} + sum g {k..p}"
using ‹k ≤ p› (*‹(k::nat) ≤ (p::nat)›*) sum.union_disjoint[of "{..<k}" "{k..p}"] (*‹⟦finite {..<k}; finite {k..p}; {..<k} ∩ {k..p} = {}⟧ ⟹ sum ?g ({..<k} ∪ {k..p}) = sum ?g {..<k} + sum ?g {k..p}›*) by (force simp: ivl_disj_un (*‹{?l} ∪ {?l<..} = {?l..}› ‹{..<?u} ∪ {?u} = {..?u}› ‹?l < ?u ⟹ {?l} ∪ {?l<..<?u} = {?l..<?u}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u} = {?l<..?u}› ‹?l ≤ ?u ⟹ {?l} ∪ {?l<..?u} = {?l..?u}› ‹?l ≤ ?u ⟹ {?l..<?u} ∪ {?u} = {?l..?u}› ‹?l < ?u ⟹ {..?l} ∪ {?l<..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..?l} ∪ {?l<..?u} = {..?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..?u} = {..?u}› ‹?l ≤ ?u ⟹ {?l<..?u} ∪ {?u<..} = {?l<..}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u..} = {?l<..}› and more 14 facts*) ivl_disj_int (*‹{..?l} ∩ {?l<..<?u} = {}› ‹{..<?l} ∩ {?l..<?u} = {}› ‹{..?l} ∩ {?l<..?u} = {}› ‹{..<?l} ∩ {?l..?u} = {}› ‹{?l<..?u} ∩ {?u<..} = {}› ‹{?l<..<?u} ∩ {?u..} = {}› ‹{?l..?u} ∩ {?u<..} = {}› ‹{?l..<?u} ∩ {?u..} = {}› ‹{?l<..<?m} ∩ {?m..<?u} = {}› ‹{?l<..?m} ∩ {?m<..<?u} = {}› ‹{?l..<?m} ∩ {?m..<?u} = {}› ‹{?l..?m} ∩ {?m<..<?u} = {}› and more 4 facts*))
have eq: "(∑i≤p. if i < k then x i else if i = k then 0 else x (i -1))
= (∑i < k. x i) + (∑i ∈ {k..p}. if i = k then 0 else x (i -1))"
by (simp add: gg (*‹sum ?g {..p} = sum ?g {..<k} + sum ?g {k..p}›*))
consider "k ≤ p - Suc 0" | "k = p"
(*goal: ‹⟦k ≤ p - Suc 0 ⟹ thesis; k = p ⟹ thesis⟧ ⟹ thesis›*)
using ‹k ≤ p› (*‹(k::nat) ≤ (p::nat)›*) by linarith
then have "(∑i≤p. if i < k then x i else if i = k then 0 else x (i -1)) = 1"
proof (cases)
(*goals:
1. ‹(k::nat) ≤ (p::nat) - Suc (0::nat) ⟹ (∑i::nat≤p. if i < k then (x::nat ⇒ real) i else if i = k then 0::real else x (i - (1::nat))) = (1::real)›
2. ‹(k::nat) = (p::nat) ⟹ (∑i::nat≤p. if i < k then (x::nat ⇒ real) i else if i = k then 0::real else x (i - (1::nat))) = (1::real)›*)
case 1 (*‹k ≤ p - Suc 0›*)
have [simp]: "Suc (p - Suc 0) = p"
using ‹1 ≤ p› (*‹1 ≤ p›*) by auto
have "(∑i = k..p. if i = k then 0 else x (i -1)) = (∑i = k+1..p. if i = k then 0 else x (i -1))"
apply (rule sum.mono_neutral_right (*‹⟦finite (?T::?'b set); (?S::?'b set) ⊆ ?T; ∀i::?'b∈?T - ?S. (?g::?'b ⇒ ?'a) i = (0::?'a)⟧ ⟹ sum ?g ?T = sum ?g ?S›*))
(*goals:
1. ‹finite {k::nat..p::nat}›
2. ‹{(k::nat) + (1::nat)..p::nat} ⊆ {k..p}›
3. ‹∀i::nat∈{k::nat..p::nat} - {k + (1::nat)..p}. (if i = k then 0::real else (x::nat ⇒ real) (i - (1::nat))) = (0::real)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
also (*calculation: ‹(∑i = k..p. if i = k then 0 else x (i - 1)) = (∑i = k + 1..p. if i = k then 0 else x (i - 1))›*) have "… = (∑i = k+1..p. x (i -1))"
by simp
also (*calculation: ‹(∑i = k..p. if i = k then 0 else x (i - 1)) = (∑i = k + 1..p. x (i - 1))›*) have "… = (∑i = k..p-1. x i)"
using sum.atLeastAtMost_reindex[of Suc k "p-1" "λi. x (i - Suc 0)"] (*‹bij_betw Suc {k..p - 1} {Suc k..Suc (p - 1)} ⟹ (∑i = Suc k..Suc (p - 1). x (i - Suc 0)) = sum ((λi. x (i - Suc 0)) ∘ Suc) {k..p - 1}›*) "1" (*‹k ≤ p - Suc 0›*) by simp
finally (*calculation: ‹(∑i = k..p. if i = k then 0 else x (i - 1)) = sum x {k..p - 1}›*) have eq2: "(∑i = k..p. if i = k then 0 else x (i -1)) = (∑i = k..p-1. x i)" .
with "1" (*‹k ≤ p - Suc 0›*) show "?thesis"
(*goal: ‹(∑i::nat≤p::nat. if i < (k::nat) then (x::nat ⇒ real) i else if i = k then 0::real else x (i - (1::nat))) = (1::real)›*)
by (metis (no_types, lifting) One_nat_def (*‹(1::nat) = Suc (0::nat)›*) eq (*‹(∑i::nat≤p::nat. if i < (k::nat) then (x::nat ⇒ real) i else if i = k then 0::real else x (i - (1::nat))) = sum x {..<k} + (∑i::nat = k..p. if i = k then 0::real else x (i - (1::nat)))›*) finite_atLeastAtMost (*‹finite {?l::nat..?u::nat}›*) finite_lessThan (*‹finite {..<?k::nat}›*) ivl_disj_int( (*‹{..<?l::?'a} ∩ {?l..?u::?'a} = {}›*) 4) ivl_disj_un( (*‹(?l::?'a) ≤ (?u::?'a) ⟹ {..<?l} ∪ {?l..?u} = {..?u}›*) 10) sum.union_disjoint (*‹⟦finite (?A::?'b set); finite (?B::?'b set); ?A ∩ ?B = {}⟧ ⟹ sum (?g::?'b ⇒ ?'a) (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*) sumx (*‹sum (x::nat ⇒ real) {..(p::nat) - Suc (0::nat)} = (1::real)›*))
next
(*goal: ‹(k::nat) = (p::nat) ⟹ (∑i::nat≤p. if i < k then (x::nat ⇒ real) i else if i = k then 0::real else x (i - (1::nat))) = (1::real)›*)
case 2 (*‹k = p›*)
have [simp]: "({..p} ∩ {x. x < p}) = {..p - Suc 0}"
using assms (*‹1 ≤ p› ‹(k::nat) ≤ (p::nat)› ‹x ∈ standard_simplex (p - Suc 0)›*) by auto
have "(∑i≤p. if i < p then x i else if i = k then 0 else x (i -1)) = (∑i≤p. if i < p then x i else 0)"
apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*goals:
1. ‹{..p} = {..p}›
2. ‹⋀xa. xa ∈ {..p} ⟹ (if xa < p then x xa else if xa = k then 0 else x (xa - 1)) = (if xa < p then x xa else 0)›
discuss goal 1*)
apply ((auto simp: 2 (*‹k = p›*))[1])
(*discuss goal 2*)
apply ((auto simp: 2 (*‹k = p›*))[1])
(*proven 2 subgoals*) .
also (*calculation: ‹(∑i≤p. if i < p then x i else if i = k then 0 else x (i - 1)) = (∑i≤p. if i < p then x i else 0)›*) have "… = sum x {..p-1}"
by (simp add: sum.If_cases (*‹finite ?A ⟹ (∑x∈?A. if ?P x then ?h x else ?g x) = sum ?h (?A ∩ {x. ?P x}) + sum ?g (?A ∩ - {x. ?P x})›*))
also (*calculation: ‹(∑i≤p. if i < p then x i else if i = k then 0 else x (i - 1)) = sum x {..p - 1}›*) have "… = 1"
by (simp add: sumx (*‹sum (x::nat ⇒ real) {..(p::nat) - Suc (0::nat)} = (1::real)›*))
finally (*calculation: ‹(∑i≤p. if i < p then x i else if i = k then 0 else x (i - 1)) = 1›*) show "?thesis"
(*goal: ‹(∑i≤p. if i < k then x i else if i = k then 0 else x (i - 1)) = 1›*)
using "2" (*‹k = p›*) by simp
qed
then show "?thesis"
(*goal: ‹simplical_face k x ∈ standard_simplex p›*)
using assms (*‹1 ≤ p› ‹k ≤ p› ‹x ∈ standard_simplex (p - Suc 0)›*) by (auto simp: standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*) simplical_face_def (*‹simplical_face ?k ?x ≡ λi. if i < ?k then ?x i else if i = ?k then 0 else ?x (i - 1)›*))
qed
subsection‹Singular simplices, forcing canonicity outside the intended domain›
definition singular_simplex :: "nat ⇒ 'a topology ⇒ ((nat ⇒ real) ⇒ 'a) ⇒ bool" where
"singular_simplex p X f ≡
continuous_map(subtopology (powertop_real UNIV) (standard_simplex p)) X f
∧ f ∈ extensional (standard_simplex p)"
abbreviation singular_simplex_set :: "nat ⇒ 'a topology ⇒ ((nat ⇒ real) ⇒ 'a) set" where
"singular_simplex_set p X ≡ Collect (singular_simplex p X)"
lemma singular_simplex_empty:
"topspace X = {} ⟹ ¬ singular_simplex p X f"
by (simp add: singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*) continuous_map (*‹continuous_map ?X ?Y ?f = (?f ` topspace ?X ⊆ topspace ?Y ∧ (∀U. openin ?Y U ⟶ openin ?X {x ∈ topspace ?X. ?f x ∈ U}))›*) nonempty_standard_simplex (*‹standard_simplex ?p ≠ {}›*))
lemma singular_simplex_mono:
"⟦singular_simplex p (subtopology X T) f; T ⊆ S⟧ ⟹ singular_simplex p (subtopology X S) f"
by (auto simp: singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*) continuous_map_in_subtopology (*‹continuous_map ?X (subtopology ?X' ?S) ?f = (continuous_map ?X ?X' ?f ∧ ?f ` topspace ?X ⊆ ?S)›*))
lemma singular_simplex_subtopology:
"singular_simplex p (subtopology X S) f ⟷
singular_simplex p X f ∧ f ` (standard_simplex p) ⊆ S"
by (auto simp: singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*) continuous_map_in_subtopology (*‹continuous_map ?X (subtopology ?X' ?S) ?f = (continuous_map ?X ?X' ?f ∧ ?f ` topspace ?X ⊆ ?S)›*))
subsubsection‹Singular face›
definition singular_face :: "nat ⇒ nat ⇒ ((nat ⇒ real) ⇒ 'a) ⇒ (nat ⇒ real) ⇒ 'a"
where "singular_face p k f ≡ restrict (f ∘ simplical_face k) (standard_simplex (p - Suc 0))"
lemma singular_simplex_singular_face:
assumes f: "singular_simplex p X f" and "1 ≤ p" "k ≤ p"
shows "singular_simplex (p - Suc 0) X (singular_face p k f)"
proof (-)
(*goal: ‹singular_simplex (p - Suc 0) X (singular_face p k f)›*)
let ?PT = "(powertop_real UNIV)"
have 0: "simplical_face k ` standard_simplex (p - Suc 0) ⊆ standard_simplex p"
using assms (*‹singular_simplex p X f› ‹1 ≤ p› ‹(k::nat) ≤ (p::nat)›*) simplical_face_in_standard_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p; ?x ∈ standard_simplex (?p - Suc 0)⟧ ⟹ simplical_face ?k ?x ∈ standard_simplex ?p›*) by auto
have 1: "continuous_map (subtopology ?PT (standard_simplex (p - Suc 0)))
(subtopology ?PT (standard_simplex p))
(simplical_face k)"
proof (clarsimp simp add: continuous_map_in_subtopology (*‹continuous_map (?X::?'a topology) (subtopology (?X'::?'b topology) (?S::?'b set)) (?f::?'a ⇒ ?'b) = (continuous_map ?X ?X' ?f ∧ ?f ` topspace ?X ⊆ ?S)›*) simplical_face_in_standard_simplex (*‹⟦(1::nat) ≤ (?p::nat); (?k::nat) ≤ ?p; (?x::nat ⇒ real) ∈ standard_simplex (?p - Suc (0::nat))⟧ ⟹ simplical_face ?k ?x ∈ standard_simplex ?p›*) continuous_map_componentwise (*‹continuous_map (?X::?'a topology) (product_topology (?Y::?'b ⇒ ?'c topology) (?I::?'b set)) (?f::?'a ⇒ ?'b ⇒ ?'c) = (?f ` topspace ?X ⊆ extensional ?I ∧ (∀k::?'b∈?I. continuous_map ?X (?Y k) (λx::?'a. ?f x k)))›*) 0 (*‹simplical_face (k::nat) ` standard_simplex ((p::nat) - Suc (0::nat)) ⊆ standard_simplex p›*))
(*goal: ‹⋀ka. continuous_map (subtopology (powertop_real UNIV) (standard_simplex (p - Suc 0))) euclideanreal (λx. simplical_face k x ka)›*)
fix i
have "continuous_map ?PT euclideanreal (λx. if i < k then x i else if i = k then 0 else x (i -1))"
by (auto intro: continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*))
then show "continuous_map (subtopology ?PT (standard_simplex (p - Suc 0))) euclideanreal
(λx. simplical_face k x i)"
by (simp add: simplical_face_def (*‹simplical_face (?k::nat) (?x::nat ⇒ ?'a::comm_monoid_add) ≡ λi::nat. if i < ?k then ?x i else if i = ?k then 0::?'a::comm_monoid_add else ?x (i - (1::nat))›*) continuous_map_from_subtopology (*‹continuous_map (?X::?'a::type topology) (?Y::?'b::type topology) (?f::?'a::type ⇒ ?'b::type) ⟹ continuous_map (subtopology ?X (?S::?'a::type set)) ?Y ?f›*))
qed
have 2: "continuous_map (subtopology ?PT (standard_simplex p)) X f"
using assms(1) (*‹singular_simplex p X f›*) singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*) by blast
show "?thesis"
(*goal: ‹singular_simplex ((p::nat) - Suc (0::nat)) (X::'a topology) (singular_face p (k::nat) (f::(nat ⇒ real) ⇒ 'a))›*)
by (simp add: singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*) singular_face_def (*‹singular_face ?p ?k ?f ≡ restrict (?f ∘ simplical_face ?k) (standard_simplex (?p - Suc 0))›*) continuous_map_compose [OF 1 2] (*‹continuous_map (subtopology (powertop_real UNIV) (standard_simplex (p - Suc 0))) X (f ∘ simplical_face k)›*))
qed
subsection‹Singular chains›
definition singular_chain :: "[nat, 'a topology, 'a chain] ⇒ bool"
where "singular_chain p X c ≡ Poly_Mapping.keys c ⊆ singular_simplex_set p X"
abbreviation singular_chain_set :: "[nat, 'a topology] ⇒ ('a chain) set"
where "singular_chain_set p X ≡ Collect (singular_chain p X)"
lemma singular_chain_empty:
"topspace X = {} ⟹ singular_chain p X c ⟷ c = 0"
by (auto simp: singular_chain_def (*‹singular_chain (?p::nat) (?X::?'a::type topology) (?c::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int) ≡ Poly_Mapping.keys ?c ⊆ singular_simplex_set ?p ?X›*) singular_simplex_empty (*‹topspace (?X::?'a::type topology) = {} ⟹ ¬ singular_simplex (?p::nat) ?X (?f::(nat ⇒ real) ⇒ ?'a::type)›*) subset_eq (*‹((?A::?'a::type set) ⊆ (?B::?'a::type set)) = (∀x::?'a::type∈?A. x ∈ ?B)›*) poly_mapping_eqI (*‹(⋀k::?'a::type. poly_mapping.lookup (?f::?'a::type ⇒₀ ?'b::zero) k = poly_mapping.lookup (?g::?'a::type ⇒₀ ?'b::zero) k) ⟹ ?f = ?g›*))
lemma singular_chain_mono:
"⟦singular_chain p (subtopology X T) c; T ⊆ S⟧
⟹ singular_chain p (subtopology X S) c"
unfolding singular_chain_def
(*goal: ‹⟦Poly_Mapping.keys c ⊆ singular_simplex_set p (subtopology X T); T ⊆ S⟧ ⟹ Poly_Mapping.keys c ⊆ singular_simplex_set p (subtopology X S)›*)
using singular_simplex_mono (*‹⟦singular_simplex ?p (subtopology ?X ?T) ?f; ?T ⊆ ?S⟧ ⟹ singular_simplex ?p (subtopology ?X ?S) ?f›*) by blast
lemma singular_chain_subtopology:
"singular_chain p (subtopology X S) c ⟷
singular_chain p X c ∧ (∀f ∈ Poly_Mapping.keys c. f ` (standard_simplex p) ⊆ S)"
unfolding singular_chain_def
(*goal: ‹(Poly_Mapping.keys c ⊆ singular_simplex_set p (subtopology X S)) = (Poly_Mapping.keys c ⊆ singular_simplex_set p X ∧ (∀f∈Poly_Mapping.keys c. f ` standard_simplex p ⊆ S))›*)
by (fastforce simp add: singular_simplex_subtopology (*‹singular_simplex ?p (subtopology ?X ?S) ?f = (singular_simplex ?p ?X ?f ∧ ?f ` standard_simplex ?p ⊆ ?S)›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*))
lemma singular_chain_0 [iff]: "singular_chain p X 0"
by (auto simp: singular_chain_def (*‹singular_chain ?p ?X ?c ≡ Poly_Mapping.keys ?c ⊆ singular_simplex_set ?p ?X›*))
lemma singular_chain_of:
"singular_chain p X (frag_of c) ⟷ singular_simplex p X c"
by (auto simp: singular_chain_def (*‹singular_chain (?p::nat) (?X::?'a topology) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ≡ Poly_Mapping.keys ?c ⊆ singular_simplex_set ?p ?X›*))
lemma singular_chain_cmul:
"singular_chain p X c ⟹ singular_chain p X (frag_cmul a c)"
by (auto simp: singular_chain_def (*‹singular_chain ?p ?X ?c ≡ Poly_Mapping.keys ?c ⊆ singular_simplex_set ?p ?X›*))
lemma singular_chain_minus:
"singular_chain p X (-c) ⟷ singular_chain p X c"
by (auto simp: singular_chain_def (*‹singular_chain ?p ?X ?c ≡ Poly_Mapping.keys ?c ⊆ singular_simplex_set ?p ?X›*))
lemma singular_chain_add:
"⟦singular_chain p X a; singular_chain p X b⟧ ⟹ singular_chain p X (a+b)"
unfolding singular_chain_def
(*goal: ‹⟦Poly_Mapping.keys a ⊆ singular_simplex_set p X; Poly_Mapping.keys b ⊆ singular_simplex_set p X⟧ ⟹ Poly_Mapping.keys (a + b) ⊆ singular_simplex_set p X›*)
using keys_add[of a b] (*‹Poly_Mapping.keys ((a::((nat ⇒ real) ⇒ 'a) ⇒₀ int) + (b::((nat ⇒ real) ⇒ 'a) ⇒₀ int)) ⊆ Poly_Mapping.keys a ∪ Poly_Mapping.keys b›*) by blast
lemma singular_chain_diff:
"⟦singular_chain p X a; singular_chain p X b⟧ ⟹ singular_chain p X (a-b)"
unfolding singular_chain_def
(*goal: ‹⟦Poly_Mapping.keys a ⊆ singular_simplex_set p X; Poly_Mapping.keys b ⊆ singular_simplex_set p X⟧ ⟹ Poly_Mapping.keys (a - b) ⊆ singular_simplex_set p X›*)
using keys_diff[of a b] (*‹Poly_Mapping.keys (a - b) ⊆ Poly_Mapping.keys a ∪ Poly_Mapping.keys b›*) by blast
lemma singular_chain_sum:
"(⋀i. i ∈ I ⟹ singular_chain p X (f i)) ⟹ singular_chain p X (∑i∈I. f i)"
unfolding singular_chain_def
(*goal: ‹(⋀i. i ∈ I ⟹ Poly_Mapping.keys (f i) ⊆ singular_simplex_set p X) ⟹ Poly_Mapping.keys (sum f I) ⊆ singular_simplex_set p X›*)
using keys_sum[of f I] (*‹Poly_Mapping.keys (sum f I) ⊆ (⋃i∈I. Poly_Mapping.keys (f i))›*) by blast
lemma singular_chain_extend:
"(⋀c. c ∈ Poly_Mapping.keys x ⟹ singular_chain p X (f c))
⟹ singular_chain p X (frag_extend f x)"
by (simp add: frag_extend_def (*‹frag_extend (?b::?'b ⇒ ?'a ⇒₀ int) (?x::?'b ⇒₀ int) ≡ ∑i::?'b∈Poly_Mapping.keys ?x. frag_cmul (poly_mapping.lookup ?x i) (?b i)›*) singular_chain_cmul (*‹singular_chain (?p::nat) (?X::?'a topology) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ⟹ singular_chain ?p ?X (frag_cmul (?a::int) ?c)›*) singular_chain_sum (*‹(⋀i::?'a. i ∈ (?I::?'a set) ⟹ singular_chain (?p::nat) (?X::?'b topology) ((?f::?'a ⇒ ((nat ⇒ real) ⇒ ?'b) ⇒₀ int) i)) ⟹ singular_chain ?p ?X (sum ?f ?I)›*))
subsection‹Boundary homomorphism for singular chains›
definition chain_boundary :: "nat ⇒ ('a chain) ⇒ 'a chain"
where "chain_boundary p c ≡
(if p = 0 then 0 else
frag_extend (λf. (∑k≤p. frag_cmul ((-1) ^ k) (frag_of(singular_face p k f)))) c)"
lemma singular_chain_boundary:
assumes "singular_chain p X c"
shows "singular_chain (p - Suc 0) X (chain_boundary p c)"
unfolding chain_boundary_def
(*goal: ‹singular_chain (p - Suc 0) X (if p = 0 then 0 else frag_extend (λf. ∑k≤p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k f))) c)›*)
proof (clarsimp intro!: singular_chain_extend (*‹(⋀c. c ∈ Poly_Mapping.keys ?x ⟹ singular_chain ?p ?X (?f c)) ⟹ singular_chain ?p ?X (frag_extend ?f ?x)›*) singular_chain_sum (*‹(⋀i. i ∈ ?I ⟹ singular_chain ?p ?X (?f i)) ⟹ singular_chain ?p ?X (sum ?f ?I)›*) singular_chain_cmul (*‹singular_chain ?p ?X ?c ⟹ singular_chain ?p ?X (frag_cmul ?a ?c)›*))
(*goal: ‹⋀ca k. ⟦0 < p; ca ∈ Poly_Mapping.keys c; k ≤ p⟧ ⟹ singular_chain (p - Suc 0) X (frag_of (singular_face p k ca))›*)
show "⋀d k. ⟦0 < p; d ∈ Poly_Mapping.keys c; k ≤ p⟧
⟹ singular_chain (p - Suc 0) X (frag_of (singular_face p k d))"
using assms (*‹singular_chain p X c›*) by (auto simp: singular_chain_def (*‹singular_chain ?p ?X ?c ≡ Poly_Mapping.keys ?c ⊆ singular_simplex_set ?p ?X›*) intro: singular_simplex_singular_face (*‹⟦singular_simplex ?p ?X ?f; 1 ≤ ?p; ?k ≤ ?p⟧ ⟹ singular_simplex (?p - Suc 0) ?X (singular_face ?p ?k ?f)›*))
qed
lemma singular_chain_boundary_alt:
"singular_chain (Suc p) X c ⟹ singular_chain p X (chain_boundary (Suc p) c)"
using singular_chain_boundary (*‹singular_chain ?p ?X ?c ⟹ singular_chain (?p - Suc 0) ?X (chain_boundary ?p ?c)›*) by force
lemma chain_boundary_0 [simp]: "chain_boundary p 0 = 0"
by (simp add: chain_boundary_def (*‹chain_boundary (?p::nat) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ≡ if ?p = (0::nat) then 0::((nat ⇒ real) ⇒ ?'a) ⇒₀ int else frag_extend (λf::(nat ⇒ real) ⇒ ?'a. ∑k::nat≤?p. frag_cmul ((- (1::int)) ^ k) (frag_of (singular_face ?p k f))) ?c›*))
lemma chain_boundary_cmul:
"chain_boundary p (frag_cmul k c) = frag_cmul k (chain_boundary p c)"
by (auto simp: chain_boundary_def (*‹chain_boundary ?p ?c ≡ if ?p = 0 then 0 else frag_extend (λf. ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k f))) ?c›*) frag_extend_cmul (*‹frag_extend ?f (frag_cmul ?c ?x) = frag_cmul ?c (frag_extend ?f ?x)›*))
lemma chain_boundary_minus:
"chain_boundary p (- c) = - (chain_boundary p c)"
by (metis chain_boundary_cmul (*‹chain_boundary ?p (frag_cmul ?k ?c) = frag_cmul ?k (chain_boundary ?p ?c)›*) frag_cmul_minus_one (*‹frag_cmul (- 1) ?x = - ?x›*))
lemma chain_boundary_add:
"chain_boundary p (a+b) = chain_boundary p a + chain_boundary p b"
by (simp add: chain_boundary_def (*‹chain_boundary ?p ?c ≡ if ?p = 0 then 0 else frag_extend (λf. ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k f))) ?c›*) frag_extend_add (*‹frag_extend ?f (?a + ?b) = frag_extend ?f ?a + frag_extend ?f ?b›*))
lemma chain_boundary_diff:
"chain_boundary p (a-b) = chain_boundary p a - chain_boundary p b"
using chain_boundary_add[of p a "-b"] (*‹chain_boundary p (a + - b) = chain_boundary p a + chain_boundary p (- b)›*) by (simp add: chain_boundary_minus (*‹chain_boundary ?p (- ?c) = - chain_boundary ?p ?c›*))
lemma chain_boundary_sum:
"chain_boundary p (sum g I) = sum (chain_boundary p ∘ g) I"
apply (induction I rule: infinite_finite_induct (*‹⟦⋀A. infinite A ⟹ ?P A; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?A›*))
(*goals:
1. ‹⋀A. infinite A ⟹ chain_boundary p (sum g A) = sum (chain_boundary p ∘ g) A›
2. ‹chain_boundary p (sum g {}) = sum (chain_boundary p ∘ g) {}›
3. ‹⋀x F. ⟦finite F; x ∉ F; chain_boundary p (sum g F) = sum (chain_boundary p ∘ g) F⟧ ⟹ chain_boundary p (sum g (insert x F)) = sum (chain_boundary p ∘ g) (insert x F)›
discuss goal 1*)
apply (simp add: chain_boundary_add (*‹chain_boundary ?p (?a + ?b) = chain_boundary ?p ?a + chain_boundary ?p ?b›*))
(*discuss goal 2*)
apply (simp add: chain_boundary_add (*‹chain_boundary ?p (?a + ?b) = chain_boundary ?p ?a + chain_boundary ?p ?b›*))
(*discuss goal 3*)
apply (simp add: chain_boundary_add (*‹chain_boundary ?p (?a + ?b) = chain_boundary ?p ?a + chain_boundary ?p ?b›*))
(*proven 3 subgoals*) .
lemma chain_boundary_sum':
"finite I ⟹ chain_boundary p (sum' g I) = sum' (chain_boundary p ∘ g) I"
apply (induction I rule: finite_induct (*‹⟦finite ?F; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?F›*))
(*goals:
1. ‹chain_boundary p (sum' g {}) = sum' (chain_boundary p ∘ g) {}›
2. ‹⋀x F. ⟦finite F; x ∉ F; chain_boundary p (sum' g F) = sum' (chain_boundary p ∘ g) F⟧ ⟹ chain_boundary p (sum' g (insert x F)) = sum' (chain_boundary p ∘ g) (insert x F)›
discuss goal 1*)
apply (simp add: chain_boundary_add (*‹chain_boundary ?p (?a + ?b) = chain_boundary ?p ?a + chain_boundary ?p ?b›*))
(*discuss goal 2*)
apply (simp add: chain_boundary_add (*‹chain_boundary ?p (?a + ?b) = chain_boundary ?p ?a + chain_boundary ?p ?b›*))
(*proven 2 subgoals*) .
lemma chain_boundary_of:
"chain_boundary p (frag_of f) =
(if p = 0 then 0
else (∑k≤p. frag_cmul ((-1) ^ k) (frag_of(singular_face p k f))))"
by (simp add: chain_boundary_def (*‹chain_boundary ?p ?c ≡ if ?p = 0 then 0 else frag_extend (λf. ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k f))) ?c›*))
subsection‹Factoring out chains in a subtopology for relative homology›
definition mod_subset
where "mod_subset p X ≡ {(a,b). singular_chain p X (a - b)}"
lemma mod_subset_empty [simp]:
"(a,b) ∈ (mod_subset p (subtopology X {})) ⟷ a = b"
by (simp add: mod_subset_def (*‹mod_subset ?p ?X ≡ {(a, b). singular_chain ?p ?X (a - b)}›*) singular_chain_empty (*‹topspace ?X = {} ⟹ singular_chain ?p ?X ?c = (?c = 0)›*))
lemma mod_subset_refl [simp]: "(c,c) ∈ mod_subset p X"
by (auto simp: mod_subset_def (*‹mod_subset ?p ?X ≡ {(a, b). singular_chain ?p ?X (a - b)}›*))
lemma mod_subset_cmul:
assumes "(a,b) ∈ mod_subset p X"
shows "(frag_cmul k a, frag_cmul k b) ∈ mod_subset p X"
using assms (*‹(a, b) ∈ mod_subset p X›*) apply (simp add: mod_subset_def (*‹mod_subset ?p ?X ≡ {(a, b). singular_chain ?p ?X (a - b)}›*))
(*goal: ‹(frag_cmul (k::int) (a::((nat ⇒ real) ⇒ 'a) ⇒₀ int), frag_cmul k (b::((nat ⇒ real) ⇒ 'a) ⇒₀ int)) ∈ mod_subset (p::nat) (X::'a topology)›*)
by (metis (no_types, lifting) add_diff_cancel (*‹?a + ?b - ?b = ?a›*) diff_add_cancel (*‹?a - ?b + ?b = ?a›*) frag_cmul_distrib2 (*‹frag_cmul ?c (?a + ?b) = frag_cmul ?c ?a + frag_cmul ?c ?b›*) singular_chain_cmul (*‹singular_chain ?p ?X ?c ⟹ singular_chain ?p ?X (frag_cmul ?a ?c)›*))
lemma mod_subset_add:
"⟦(c1,c2) ∈ mod_subset p X; (d1,d2) ∈ mod_subset p X⟧ ⟹ (c1+d1, c2+d2) ∈ mod_subset p X"
by (simp add: mod_subset_def (*‹mod_subset ?p ?X ≡ {(a, b). singular_chain ?p ?X (a - b)}›*) add_diff_add (*‹?a + ?c - (?b + ?d) = ?a - ?b + (?c - ?d)›*) singular_chain_add (*‹⟦singular_chain ?p ?X ?a; singular_chain ?p ?X ?b⟧ ⟹ singular_chain ?p ?X (?a + ?b)›*))
subsection‹Relative cycles $Z_pX (S)$ where $X$ is a topology and $S$ a subset ›
definition singular_relcycle :: "nat ⇒ 'a topology ⇒ 'a set ⇒ ('a chain) ⇒ bool"
where "singular_relcycle p X S ≡
λc. singular_chain p X c ∧ (chain_boundary p c, 0) ∈ mod_subset (p-1) (subtopology X S)"
abbreviation singular_relcycle_set
where "singular_relcycle_set p X S ≡ Collect (singular_relcycle p X S)"
lemma singular_relcycle_restrict [simp]:
"singular_relcycle p X (topspace X ∩ S) = singular_relcycle p X S"
proof (-)
(*goal: ‹singular_relcycle p X (topspace X ∩ S) = singular_relcycle p X S›*)
have eq: "subtopology X (topspace X ∩ S) = subtopology X S"
by (metis subtopology_subtopology (*‹subtopology (subtopology ?X ?S) ?T = subtopology ?X (?S ∩ ?T)›*) subtopology_topspace (*‹subtopology ?U (topspace ?U) = ?U›*))
show "?thesis"
(*goal: ‹singular_relcycle p X (topspace X ∩ S) = singular_relcycle p X S›*)
by (force simp: singular_relcycle_def (*‹singular_relcycle ?p ?X ?S ≡ λc. singular_chain ?p ?X c ∧ (chain_boundary ?p c, 0) ∈ mod_subset (?p - 1) (subtopology ?X ?S)›*) eq (*‹subtopology X (topspace X ∩ S) = subtopology X S›*))
qed
lemma singular_relcycle:
"singular_relcycle p X S c ⟷
singular_chain p X c ∧ singular_chain (p-1) (subtopology X S) (chain_boundary p c)"
by (simp add: singular_relcycle_def (*‹singular_relcycle (?p::nat) (?X::?'a::type topology) (?S::?'a::type set) ≡ λc::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int. singular_chain ?p ?X c ∧ (chain_boundary ?p c, 0::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int) ∈ mod_subset (?p - (1::nat)) (subtopology ?X ?S)›*) mod_subset_def (*‹mod_subset (?p::nat) (?X::?'a::type topology) ≡ {(a::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int, b::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int). singular_chain ?p ?X (a - b)}›*))
lemma singular_relcycle_0 [simp]: "singular_relcycle p X S 0"
by (auto simp: singular_relcycle_def (*‹singular_relcycle ?p ?X ?S ≡ λc. singular_chain ?p ?X c ∧ (chain_boundary ?p c, 0) ∈ mod_subset (?p - 1) (subtopology ?X ?S)›*))
lemma singular_relcycle_cmul:
"singular_relcycle p X S c ⟹ singular_relcycle p X S (frag_cmul k c)"
by (auto simp: singular_relcycle_def (*‹singular_relcycle ?p ?X ?S ≡ λc. singular_chain ?p ?X c ∧ (chain_boundary ?p c, 0) ∈ mod_subset (?p - 1) (subtopology ?X ?S)›*) chain_boundary_cmul (*‹chain_boundary ?p (frag_cmul ?k ?c) = frag_cmul ?k (chain_boundary ?p ?c)›*) dest: singular_chain_cmul (*‹singular_chain ?p ?X ?c ⟹ singular_chain ?p ?X (frag_cmul ?a ?c)›*) mod_subset_cmul (*‹(?a, ?b) ∈ mod_subset ?p ?X ⟹ (frag_cmul ?k ?a, frag_cmul ?k ?b) ∈ mod_subset ?p ?X›*))
lemma singular_relcycle_minus:
"singular_relcycle p X S (-c) ⟷ singular_relcycle p X S c"
by (simp add: chain_boundary_minus (*‹chain_boundary ?p (- ?c) = - chain_boundary ?p ?c›*) singular_chain_minus (*‹singular_chain ?p ?X (- ?c) = singular_chain ?p ?X ?c›*) singular_relcycle (*‹singular_relcycle ?p ?X ?S ?c = (singular_chain ?p ?X ?c ∧ singular_chain (?p - 1) (subtopology ?X ?S) (chain_boundary ?p ?c))›*))
lemma singular_relcycle_add:
"⟦singular_relcycle p X S a; singular_relcycle p X S b⟧
⟹ singular_relcycle p X S (a+b)"
by (simp add: singular_relcycle_def (*‹singular_relcycle ?p ?X ?S ≡ λc. singular_chain ?p ?X c ∧ (chain_boundary ?p c, 0) ∈ mod_subset (?p - 1) (subtopology ?X ?S)›*) chain_boundary_add (*‹chain_boundary ?p (?a + ?b) = chain_boundary ?p ?a + chain_boundary ?p ?b›*) mod_subset_def (*‹mod_subset ?p ?X ≡ {(a, b). singular_chain ?p ?X (a - b)}›*) singular_chain_add (*‹⟦singular_chain ?p ?X ?a; singular_chain ?p ?X ?b⟧ ⟹ singular_chain ?p ?X (?a + ?b)›*))
lemma singular_relcycle_sum:
"⟦⋀i. i ∈ I ⟹ singular_relcycle p X S (f i)⟧
⟹ singular_relcycle p X S (sum f I)"
apply (induction I rule: infinite_finite_induct (*‹⟦⋀A. infinite A ⟹ ?P A; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?A›*))
(*goals:
1. ‹⋀A::'a set. ⟦infinite A; ⋀i::'a. i ∈ A ⟹ singular_relcycle (p::nat) (X::'b topology) (S::'b set) ((f::'a ⇒ ((nat ⇒ real) ⇒ 'b) ⇒₀ int) i)⟧ ⟹ singular_relcycle p X S (sum f A)›
2. ‹(⋀i::'a. i ∈ {} ⟹ singular_relcycle (p::nat) (X::'b topology) (S::'b set) ((f::'a ⇒ ((nat ⇒ real) ⇒ 'b) ⇒₀ int) i)) ⟹ singular_relcycle p X S (sum f {})›
3. ‹⋀(x::'a) F::'a set. ⟦finite F; x ∉ F; (⋀i::'a. i ∈ F ⟹ singular_relcycle (p::nat) (X::'b topology) (S::'b set) ((f::'a ⇒ ((nat ⇒ real) ⇒ 'b) ⇒₀ int) i)) ⟹ singular_relcycle p X S (sum f F); ⋀i::'a. i ∈ insert x F ⟹ singular_relcycle p X S (f i)⟧ ⟹ singular_relcycle p X S (sum f (insert x F))›
discuss goal 1*)
apply ((auto simp: singular_relcycle_add (*‹⟦singular_relcycle ?p ?X ?S ?a; singular_relcycle ?p ?X ?S ?b⟧ ⟹ singular_relcycle ?p ?X ?S (?a + ?b)›*))[1])
(*discuss goal 2*)
apply ((auto simp: singular_relcycle_add (*‹⟦singular_relcycle ?p ?X ?S ?a; singular_relcycle ?p ?X ?S ?b⟧ ⟹ singular_relcycle ?p ?X ?S (?a + ?b)›*))[1])
(*discuss goal 3*)
apply ((auto simp: singular_relcycle_add (*‹⟦singular_relcycle (?p::nat) (?X::?'a topology) (?S::?'a set) (?a::((nat ⇒ real) ⇒ ?'a) ⇒₀ int); singular_relcycle ?p ?X ?S (?b::((nat ⇒ real) ⇒ ?'a) ⇒₀ int)⟧ ⟹ singular_relcycle ?p ?X ?S (?a + ?b)›*))[1])
(*proven 3 subgoals*) .
lemma singular_relcycle_diff:
"⟦singular_relcycle p X S a; singular_relcycle p X S b⟧
⟹ singular_relcycle p X S (a-b)"
by (metis singular_relcycle_add (*‹⟦singular_relcycle ?p ?X ?S ?a; singular_relcycle ?p ?X ?S ?b⟧ ⟹ singular_relcycle ?p ?X ?S (?a + ?b)›*) singular_relcycle_minus (*‹singular_relcycle ?p ?X ?S (- ?c) = singular_relcycle ?p ?X ?S ?c›*) uminus_add_conv_diff (*‹- ?a + ?b = ?b - ?a›*))
lemma singular_cycle:
"singular_relcycle p X {} c ⟷ singular_chain p X c ∧ chain_boundary p c = 0"
using mod_subset_empty (*‹((?a, ?b) ∈ mod_subset ?p (subtopology ?X {})) = (?a = ?b)›*) by (auto simp: singular_relcycle_def (*‹singular_relcycle ?p ?X ?S ≡ λc. singular_chain ?p ?X c ∧ (chain_boundary ?p c, 0) ∈ mod_subset (?p - 1) (subtopology ?X ?S)›*))
lemma singular_cycle_mono:
"⟦singular_relcycle p (subtopology X T) {} c; T ⊆ S⟧
⟹ singular_relcycle p (subtopology X S) {} c"
by (auto simp: singular_cycle (*‹singular_relcycle ?p ?X {} ?c = (singular_chain ?p ?X ?c ∧ chain_boundary ?p ?c = 0)›*) elim: singular_chain_mono (*‹⟦singular_chain ?p (subtopology ?X ?T) ?c; ?T ⊆ ?S⟧ ⟹ singular_chain ?p (subtopology ?X ?S) ?c›*))
subsection‹Relative boundaries $B_p X S$, where $X$ is a topology and $S$ a subset.›
definition singular_relboundary :: "nat ⇒ 'a topology ⇒ 'a set ⇒ ('a chain) ⇒ bool"
where
"singular_relboundary p X S ≡
λc. ∃d. singular_chain (Suc p) X d ∧ (chain_boundary (Suc p) d, c) ∈ (mod_subset p (subtopology X S))"
abbreviation singular_relboundary_set :: "nat ⇒ 'a topology ⇒ 'a set ⇒ ('a chain) set"
where "singular_relboundary_set p X S ≡ Collect (singular_relboundary p X S)"
lemma singular_relboundary_restrict [simp]:
"singular_relboundary p X (topspace X ∩ S) = singular_relboundary p X S"
unfolding singular_relboundary_def
(*goal: ‹(λc. ∃d. singular_chain (Suc p) X d ∧ (chain_boundary (Suc p) d, c) ∈ mod_subset p (subtopology X (topspace X ∩ S))) = (λc. ∃d. singular_chain (Suc p) X d ∧ (chain_boundary (Suc p) d, c) ∈ mod_subset p (subtopology X S))›*)
by (metis (no_types, opaque_lifting) subtopology_subtopology (*‹subtopology (subtopology (?X::?'a topology) (?S::?'a set)) (?T::?'a set) = subtopology ?X (?S ∩ ?T)›*) subtopology_topspace (*‹subtopology (?U::?'a topology) (topspace ?U) = ?U›*))
lemma singular_relboundary_alt:
"singular_relboundary p X S c ⟷
(∃d e. singular_chain (Suc p) X d ∧ singular_chain p (subtopology X S) e ∧
chain_boundary (Suc p) d = c + e)"
unfolding singular_relboundary_def mod_subset_def
(*goal: ‹(∃d. singular_chain (Suc p) X d ∧ (chain_boundary (Suc p) d, c) ∈ {(a, b). singular_chain p (subtopology X S) (a - b)}) = (∃d e. singular_chain (Suc p) X d ∧ singular_chain p (subtopology X S) e ∧ chain_boundary (Suc p) d = c + e)›*)
by fastforce
lemma singular_relboundary:
"singular_relboundary p X S c ⟷
(∃d e. singular_chain (Suc p) X d ∧ singular_chain p (subtopology X S) e ∧
(chain_boundary (Suc p) d) + e = c)"
using singular_chain_minus (*‹singular_chain (?p::nat) (?X::?'a::type topology) (- (?c::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int)) = singular_chain ?p ?X ?c›*) by (fastforce simp add: singular_relboundary_alt (*‹singular_relboundary ?p ?X ?S ?c = (∃d e. singular_chain (Suc ?p) ?X d ∧ singular_chain ?p (subtopology ?X ?S) e ∧ chain_boundary (Suc ?p) d = ?c + e)›*))
lemma singular_boundary:
"singular_relboundary p X {} c ⟷
(∃d. singular_chain (Suc p) X d ∧ chain_boundary (Suc p) d = c)"
by (meson mod_subset_empty (*‹((?a, ?b) ∈ mod_subset ?p (subtopology ?X {})) = (?a = ?b)›*) singular_relboundary_def (*‹singular_relboundary ?p ?X ?S ≡ λc. ∃d. singular_chain (Suc ?p) ?X d ∧ (chain_boundary (Suc ?p) d, c) ∈ mod_subset ?p (subtopology ?X ?S)›*))
lemma singular_boundary_imp_chain:
"singular_relboundary p X {} c ⟹ singular_chain p X c"
by (auto simp: singular_relboundary (*‹singular_relboundary ?p ?X ?S ?c = (∃d e. singular_chain (Suc ?p) ?X d ∧ singular_chain ?p (subtopology ?X ?S) e ∧ chain_boundary (Suc ?p) d + e = ?c)›*) singular_chain_boundary_alt (*‹singular_chain (Suc ?p) ?X ?c ⟹ singular_chain ?p ?X (chain_boundary (Suc ?p) ?c)›*) singular_chain_empty (*‹topspace ?X = {} ⟹ singular_chain ?p ?X ?c = (?c = 0)›*))
lemma singular_boundary_mono:
"⟦T ⊆ S; singular_relboundary p (subtopology X T) {} c⟧
⟹ singular_relboundary p (subtopology X S) {} c"
by (metis mod_subset_empty (*‹((?a, ?b) ∈ mod_subset ?p (subtopology ?X {})) = (?a = ?b)›*) singular_chain_mono (*‹⟦singular_chain ?p (subtopology ?X ?T) ?c; ?T ⊆ ?S⟧ ⟹ singular_chain ?p (subtopology ?X ?S) ?c›*) singular_relboundary_def (*‹singular_relboundary ?p ?X ?S ≡ λc. ∃d. singular_chain (Suc ?p) ?X d ∧ (chain_boundary (Suc ?p) d, c) ∈ mod_subset ?p (subtopology ?X ?S)›*))
lemma singular_relboundary_imp_chain:
"singular_relboundary p X S c ⟹ singular_chain p X c"
unfolding singular_relboundary singular_chain_subtopology
(*goal: ‹∃d e. singular_chain (Suc p) X d ∧ (singular_chain p X e ∧ (∀f∈Poly_Mapping.keys e. f ` standard_simplex p ⊆ S)) ∧ chain_boundary (Suc p) d + e = c ⟹ singular_chain p X c›*)
by (blast intro: singular_chain_add (*‹⟦singular_chain ?p ?X ?a; singular_chain ?p ?X ?b⟧ ⟹ singular_chain ?p ?X (?a + ?b)›*) singular_chain_boundary_alt (*‹singular_chain (Suc ?p) ?X ?c ⟹ singular_chain ?p ?X (chain_boundary (Suc ?p) ?c)›*))
lemma singular_chain_imp_relboundary:
"singular_chain p (subtopology X S) c ⟹ singular_relboundary p X S c"
unfolding singular_relboundary_def
(*goal: ‹singular_chain (p::nat) (subtopology (X::'a topology) (S::'a set)) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⟹ ∃d::((nat ⇒ real) ⇒ 'a) ⇒₀ int. singular_chain (Suc p) X d ∧ (chain_boundary (Suc p) d, c) ∈ mod_subset p (subtopology X S)›*)
using mod_subset_def (*‹mod_subset ?p ?X ≡ {(a, b). singular_chain ?p ?X (a - b)}›*) singular_chain_minus (*‹singular_chain ?p ?X (- ?c) = singular_chain ?p ?X ?c›*) by fastforce
lemma singular_relboundary_0 [simp]: "singular_relboundary p X S 0"
unfolding singular_relboundary_def
(*goal: ‹∃d. singular_chain (Suc p) X d ∧ (chain_boundary (Suc p) d, 0) ∈ mod_subset p (subtopology X S)›*)
apply (rule_tac x=0 in exI (*‹?P ?x ⟹ ∃x. ?P x›*))
(*goal: ‹∃d. singular_chain (Suc p) X d ∧ (chain_boundary (Suc p) d, 0) ∈ mod_subset p (subtopology X S)›*)
by auto
lemma singular_relboundary_cmul:
"singular_relboundary p X S c ⟹ singular_relboundary p X S (frag_cmul a c)"
unfolding singular_relboundary_def
(*goal: ‹∃d. singular_chain (Suc p) X d ∧ (chain_boundary (Suc p) d, c) ∈ mod_subset p (subtopology X S) ⟹ ∃d. singular_chain (Suc p) X d ∧ (chain_boundary (Suc p) d, frag_cmul a c) ∈ mod_subset p (subtopology X S)›*)
by (metis chain_boundary_cmul (*‹chain_boundary ?p (frag_cmul ?k ?c) = frag_cmul ?k (chain_boundary ?p ?c)›*) mod_subset_cmul (*‹(?a, ?b) ∈ mod_subset ?p ?X ⟹ (frag_cmul ?k ?a, frag_cmul ?k ?b) ∈ mod_subset ?p ?X›*) singular_chain_cmul (*‹singular_chain ?p ?X ?c ⟹ singular_chain ?p ?X (frag_cmul ?a ?c)›*))
lemma singular_relboundary_minus:
"singular_relboundary p X S (-c) ⟷ singular_relboundary p X S c"
using singular_relboundary_cmul (*‹singular_relboundary (?p::nat) (?X::?'a topology) (?S::?'a set) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ⟹ singular_relboundary ?p ?X ?S (frag_cmul (?a::int) ?c)›*) by (metis add.inverse_inverse (*‹- (- ?a) = ?a›*) frag_cmul_minus_one (*‹frag_cmul (- 1) ?x = - ?x›*))
lemma singular_relboundary_add:
"⟦singular_relboundary p X S a; singular_relboundary p X S b⟧ ⟹ singular_relboundary p X S (a+b)"
unfolding singular_relboundary_def
(*goal: ‹⟦∃d::((nat ⇒ real) ⇒ 'a) ⇒₀ int. singular_chain (Suc (p::nat)) (X::'a topology) d ∧ (chain_boundary (Suc p) d, a::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ∈ mod_subset p (subtopology X (S::'a set)); ∃d::((nat ⇒ real) ⇒ 'a) ⇒₀ int. singular_chain (Suc p) X d ∧ (chain_boundary (Suc p) d, b::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ∈ mod_subset p (subtopology X S)⟧ ⟹ ∃d::((nat ⇒ real) ⇒ 'a) ⇒₀ int. singular_chain (Suc p) X d ∧ (chain_boundary (Suc p) d, a + b) ∈ mod_subset p (subtopology X S)›*)
by (metis chain_boundary_add (*‹chain_boundary ?p (?a + ?b) = chain_boundary ?p ?a + chain_boundary ?p ?b›*) mod_subset_add (*‹⟦(?c1.0, ?c2.0) ∈ mod_subset ?p ?X; (?d1.0, ?d2.0) ∈ mod_subset ?p ?X⟧ ⟹ (?c1.0 + ?d1.0, ?c2.0 + ?d2.0) ∈ mod_subset ?p ?X›*) singular_chain_add (*‹⟦singular_chain ?p ?X ?a; singular_chain ?p ?X ?b⟧ ⟹ singular_chain ?p ?X (?a + ?b)›*))
lemma singular_relboundary_diff:
"⟦singular_relboundary p X S a; singular_relboundary p X S b⟧ ⟹ singular_relboundary p X S (a-b)"
by (metis uminus_add_conv_diff (*‹- ?a + ?b = ?b - ?a›*) singular_relboundary_minus (*‹singular_relboundary ?p ?X ?S (- ?c) = singular_relboundary ?p ?X ?S ?c›*) singular_relboundary_add (*‹⟦singular_relboundary ?p ?X ?S ?a; singular_relboundary ?p ?X ?S ?b⟧ ⟹ singular_relboundary ?p ?X ?S (?a + ?b)›*))
subsection‹The (relative) homology relation›
definition homologous_rel :: "[nat,'a topology,'a set,'a chain,'a chain] ⇒ bool"
where "homologous_rel p X S ≡ λa b. singular_relboundary p X S (a-b)"
abbreviation homologous_rel_set
where "homologous_rel_set p X S a ≡ Collect (homologous_rel p X S a)"
lemma homologous_rel_restrict [simp]:
"homologous_rel p X (topspace X ∩ S) = homologous_rel p X S"
unfolding homologous_rel_def
(*goal: ‹(λ(a::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) b::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. singular_relboundary (p::nat) (X::'a::type topology) (topspace X ∩ (S::'a::type set)) (a - b)) = (λ(a::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) b::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. singular_relboundary p X S (a - b))›*)
by (metis singular_relboundary_restrict (*‹singular_relboundary ?p ?X (topspace ?X ∩ ?S) = singular_relboundary ?p ?X ?S›*))
lemma homologous_rel_refl [simp]: "homologous_rel p X S c c"
unfolding homologous_rel_def
(*goal: ‹singular_relboundary p X S (c - c)›*)
by auto
lemma homologous_rel_sym:
"homologous_rel p X S a b = homologous_rel p X S b a"
unfolding homologous_rel_def
(*goal: ‹singular_relboundary p X S (a - b) = singular_relboundary p X S (b - a)›*)
using singular_relboundary_minus (*‹singular_relboundary ?p ?X ?S (- ?c) = singular_relboundary ?p ?X ?S ?c›*) by fastforce
lemma homologous_rel_trans:
assumes "homologous_rel p X S b c" "homologous_rel p X S a b"
shows "homologous_rel p X S a c"
using homologous_rel_def (*‹homologous_rel ?p ?X ?S ≡ λa b. singular_relboundary ?p ?X ?S (a - b)›*) proof (-)
(*goal: ‹(⋀p X S. homologous_rel p X S ≡ λa b. singular_relboundary p X S (a - b)) ⟹ homologous_rel p X S a c›*)
have "singular_relboundary p X S (b - c)"
using assms (*‹homologous_rel p X S b c› ‹homologous_rel (p::nat) (X::'a topology) (S::'a set) (a::((nat ⇒ real) ⇒ 'a) ⇒₀ int) (b::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*) unfolding homologous_rel_def
(*goal: ‹singular_relboundary p X S (b - c)›*)
by blast
moreover have "singular_relboundary p X S (b - a)"
using assms (*‹homologous_rel p X S b c› ‹homologous_rel p X S a b›*) by (meson homologous_rel_def (*‹homologous_rel ?p ?X ?S ≡ λa b. singular_relboundary ?p ?X ?S (a - b)›*) homologous_rel_sym (*‹homologous_rel ?p ?X ?S ?a ?b = homologous_rel ?p ?X ?S ?b ?a›*))
ultimately have "singular_relboundary p X S (c - a)"
using singular_relboundary_diff (*‹⟦singular_relboundary ?p ?X ?S ?a; singular_relboundary ?p ?X ?S ?b⟧ ⟹ singular_relboundary ?p ?X ?S (?a - ?b)›*) by fastforce
then show "?thesis"
(*goal: ‹homologous_rel p X S a c›*)
by (meson homologous_rel_def (*‹homologous_rel ?p ?X ?S ≡ λa b. singular_relboundary ?p ?X ?S (a - b)›*) homologous_rel_sym (*‹homologous_rel ?p ?X ?S ?a ?b = homologous_rel ?p ?X ?S ?b ?a›*))
qed
lemma homologous_rel_eq:
"homologous_rel p X S a = homologous_rel p X S b ⟷
homologous_rel p X S a b"
using homologous_rel_sym (*‹homologous_rel ?p ?X ?S ?a ?b = homologous_rel ?p ?X ?S ?b ?a›*) homologous_rel_trans (*‹⟦homologous_rel ?p ?X ?S ?b ?c; homologous_rel ?p ?X ?S ?a ?b⟧ ⟹ homologous_rel ?p ?X ?S ?a ?c›*) by fastforce
lemma homologous_rel_set_eq:
"homologous_rel_set p X S a = homologous_rel_set p X S b ⟷
homologous_rel p X S a b"
by (metis homologous_rel_eq (*‹(homologous_rel ?p ?X ?S ?a = homologous_rel ?p ?X ?S ?b) = homologous_rel ?p ?X ?S ?a ?b›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*))
lemma homologous_rel_singular_chain:
"homologous_rel p X S a b ⟹ (singular_chain p X a ⟷ singular_chain p X b)"
unfolding homologous_rel_def
(*goal: ‹singular_relboundary p X S (a - b) ⟹ singular_chain p X a = singular_chain p X b›*)
using singular_chain_diff (*‹⟦singular_chain ?p ?X ?a; singular_chain ?p ?X ?b⟧ ⟹ singular_chain ?p ?X (?a - ?b)›*) singular_chain_add (*‹⟦singular_chain ?p ?X ?a; singular_chain ?p ?X ?b⟧ ⟹ singular_chain ?p ?X (?a + ?b)›*) by (fastforce dest: singular_relboundary_imp_chain (*‹singular_relboundary (?p::nat) (?X::?'a::type topology) (?S::?'a::type set) (?c::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int) ⟹ singular_chain ?p ?X ?c›*))
lemma homologous_rel_add:
"⟦homologous_rel p X S a a'; homologous_rel p X S b b'⟧
⟹ homologous_rel p X S (a+b) (a'+b')"
unfolding homologous_rel_def
(*goal: ‹⟦singular_relboundary (p::nat) (X::'a topology) (S::'a set) ((a::((nat ⇒ real) ⇒ 'a) ⇒₀ int) - (a'::((nat ⇒ real) ⇒ 'a) ⇒₀ int)); singular_relboundary p X S ((b::((nat ⇒ real) ⇒ 'a) ⇒₀ int) - (b'::((nat ⇒ real) ⇒ 'a) ⇒₀ int))⟧ ⟹ singular_relboundary p X S (a + b - (a' + b'))›*)
by (simp add: add_diff_add (*‹?a + ?c - (?b + ?d) = ?a - ?b + (?c - ?d)›*) singular_relboundary_add (*‹⟦singular_relboundary ?p ?X ?S ?a; singular_relboundary ?p ?X ?S ?b⟧ ⟹ singular_relboundary ?p ?X ?S (?a + ?b)›*))
lemma homologous_rel_diff:
assumes "homologous_rel p X S a a'" "homologous_rel p X S b b'"
shows "homologous_rel p X S (a - b) (a' - b')"
proof (-)
(*goal: ‹homologous_rel p X S (a - b) (a' - b')›*)
have "singular_relboundary p X S ((a - a') - (b - b'))"
using assms (*‹homologous_rel p X S a a'› ‹homologous_rel p X S b b'›*) singular_relboundary_diff (*‹⟦singular_relboundary ?p ?X ?S ?a; singular_relboundary ?p ?X ?S ?b⟧ ⟹ singular_relboundary ?p ?X ?S (?a - ?b)›*) unfolding homologous_rel_def
(*goal: ‹singular_relboundary p X S (a - a' - (b - b'))›*)
by blast
then show "?thesis"
(*goal: ‹homologous_rel (p::nat) (X::'a topology) (S::'a set) ((a::((nat ⇒ real) ⇒ 'a) ⇒₀ int) - (b::((nat ⇒ real) ⇒ 'a) ⇒₀ int)) ((a'::((nat ⇒ real) ⇒ 'a) ⇒₀ int) - (b'::((nat ⇒ real) ⇒ 'a) ⇒₀ int))›*)
by (simp add: homologous_rel_def (*‹homologous_rel ?p ?X ?S ≡ λa b. singular_relboundary ?p ?X ?S (a - b)›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 33 facts*))
qed
lemma homologous_rel_sum:
assumes f: "finite {i ∈ I. f i ≠ 0}" and g: "finite {i ∈ I. g i ≠ 0}"
and h: "⋀i. i ∈ I ⟹ homologous_rel p X S (f i) (g i)"
shows "homologous_rel p X S (sum f I) (sum g I)"
proof (cases "finite I")
(*goals:
1. ‹finite I ⟹ homologous_rel p X S (sum f I) (sum g I)›
2. ‹infinite I ⟹ homologous_rel p X S (sum f I) (sum g I)›*)
case True (*‹finite I›*)
let ?L = "{i ∈ I. f i ≠ 0} ∪ {i ∈ I. g i ≠ 0}"
have L: "finite ?L" "?L ⊆ I"
using f (*‹finite {i ∈ I. f i ≠ 0}›*) g (*‹finite {i::'a ∈ I::'a set. (g::'a ⇒ ((nat ⇒ real) ⇒ 'b) ⇒₀ int) i ≠ (0::((nat ⇒ real) ⇒ 'b) ⇒₀ int)}›*)
(*goals:
1. ‹finite ({i ∈ I. f i ≠ 0} ∪ {i ∈ I. g i ≠ 0})›
2. ‹{i ∈ I. f i ≠ 0} ∪ {i ∈ I. g i ≠ 0} ⊆ I›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
have "sum f I = sum f ?L"
apply (rule comm_monoid_add_class.sum.mono_neutral_right [OF True] (*‹⟦?S ⊆ I; ∀i∈I - ?S. ?g i = 0⟧ ⟹ sum ?g I = sum ?g ?S›*))
(*goals:
1. ‹{i::'a::type ∈ I::'a::type set. (f::'a::type ⇒ ((nat ⇒ real) ⇒ 'b::type) ⇒₀ int) i ≠ (0::((nat ⇒ real) ⇒ 'b::type) ⇒₀ int)} ∪ {i::'a::type ∈ I. (g::'a::type ⇒ ((nat ⇒ real) ⇒ 'b::type) ⇒₀ int) i ≠ (0::((nat ⇒ real) ⇒ 'b::type) ⇒₀ int)} ⊆ I›
2. ‹∀i::'a::type∈(I::'a::type set) - ({i::'a::type ∈ I. (f::'a::type ⇒ ((nat ⇒ real) ⇒ 'b::type) ⇒₀ int) i ≠ (0::((nat ⇒ real) ⇒ 'b::type) ⇒₀ int)} ∪ {i::'a::type ∈ I. (g::'a::type ⇒ ((nat ⇒ real) ⇒ 'b::type) ⇒₀ int) i ≠ (0::((nat ⇒ real) ⇒ 'b::type) ⇒₀ int)}). f i = (0::((nat ⇒ real) ⇒ 'b::type) ⇒₀ int)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
moreover have "sum g I = sum g ?L"
apply (rule comm_monoid_add_class.sum.mono_neutral_right [OF True] (*‹⟦?S ⊆ I; ∀i∈I - ?S. ?g i = 0⟧ ⟹ sum ?g I = sum ?g ?S›*))
(*goals:
1. ‹{i ∈ I. f i ≠ 0} ∪ {i ∈ I. g i ≠ 0} ⊆ I›
2. ‹∀i∈I - ({i ∈ I. f i ≠ 0} ∪ {i ∈ I. g i ≠ 0}). g i = 0›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
moreover have "*": "homologous_rel p X S (f i) (g i)" if "i ∈ ?L" for i
using h (*‹?i ∈ I ⟹ homologous_rel p X S (f ?i) (g ?i)›*) that (*‹i ∈ {i ∈ I. f i ≠ 0} ∪ {i ∈ I. g i ≠ 0}›*) by auto
have "homologous_rel p X S (sum f ?L) (sum g ?L)"
using L (*‹finite ({i ∈ I. f i ≠ 0} ∪ {i ∈ I. g i ≠ 0})› ‹{i::'a ∈ I::'a set. (f::'a ⇒ ((nat ⇒ real) ⇒ 'b) ⇒₀ int) i ≠ (0::((nat ⇒ real) ⇒ 'b) ⇒₀ int)} ∪ {i::'a ∈ I. (g::'a ⇒ ((nat ⇒ real) ⇒ 'b) ⇒₀ int) i ≠ (0::((nat ⇒ real) ⇒ 'b) ⇒₀ int)} ⊆ I›*) proof (induction)
(*goals:
1. ‹{} ⊆ I ⟹ homologous_rel p X S (sum f {}) (sum g {})›
2. ‹⋀x F. ⟦finite F; x ∉ F; F ⊆ I ⟹ homologous_rel p X S (sum f F) (sum g F); insert x F ⊆ I⟧ ⟹ homologous_rel p X S (sum f (insert x F)) (sum g (insert x F))›*)
case (insert j J) (*‹finite (J::'a::type set)› ‹j ∉ J› ‹J ⊆ I ⟹ homologous_rel p X S (sum f J) (sum g J)› ‹insert (j::'a) (J::'a set) ⊆ (I::'a set)›*)
then show "?case"
(*goal: ‹homologous_rel p X S (sum f (insert j J)) (sum g (insert j J))›*)
by (simp add: h (*‹?i ∈ I ⟹ homologous_rel p X S (f ?i) (g ?i)›*) homologous_rel_add (*‹⟦homologous_rel ?p ?X ?S ?a ?a'; homologous_rel ?p ?X ?S ?b ?b'⟧ ⟹ homologous_rel ?p ?X ?S (?a + ?b) (?a' + ?b')›*))
qed (auto)
(*solved the remaining goal: ‹{} ⊆ I ⟹ homologous_rel p X S (sum f {}) (sum g {})›*)
ultimately show "?thesis"
(*goal: ‹homologous_rel (p::nat) (X::'b::type topology) (S::'b::type set) (sum (f::'a::type ⇒ ((nat ⇒ real) ⇒ 'b::type) ⇒₀ int) (I::'a::type set)) (sum (g::'a::type ⇒ ((nat ⇒ real) ⇒ 'b::type) ⇒₀ int) I)›*)
by simp
qed (auto)
(*solved the remaining goal: ‹infinite I ⟹ homologous_rel p X S (sum f I) (sum g I)›*)
lemma chain_homotopic_imp_homologous_rel:
assumes
"⋀c. singular_chain p X c ⟹ singular_chain (Suc p) X' (h c)"
"⋀c. singular_chain (p -1) (subtopology X S) c ⟹ singular_chain p (subtopology X' T) (h' c)"
"⋀c. singular_chain p X c
⟹ (chain_boundary (Suc p) (h c)) + (h'(chain_boundary p c)) = f c - g c"
"singular_relcycle p X S c"
shows "homologous_rel p X' T (f c) (g c)"
proof (-)
(*goal: ‹homologous_rel p X' T (f c) (g c)›*)
have "singular_chain p (subtopology X' T) (chain_boundary (Suc p) (h c) - (f c - g c))"
using assms (*‹singular_chain p X ?c ⟹ singular_chain (Suc p) X' (h ?c)› ‹singular_chain ((p::nat) - (1::nat)) (subtopology (X::'a::type topology) (S::'a::type set)) (?c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⟹ singular_chain p (subtopology (X'::'b::type topology) (T::'b::type set)) ((h'::(((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'b::type) ⇒₀ int) ?c)› ‹singular_chain p X ?c ⟹ chain_boundary (Suc p) (h ?c) + h' (chain_boundary p ?c) = f ?c - g ?c› ‹singular_relcycle p X S c›*) by (metis (no_types, lifting) add_diff_cancel_left' (*‹?a + ?b - ?a = ?b›*) minus_diff_eq (*‹- (?a - ?b) = ?b - ?a›*) singular_chain_minus (*‹singular_chain ?p ?X (- ?c) = singular_chain ?p ?X ?c›*) singular_relcycle (*‹singular_relcycle ?p ?X ?S ?c = (singular_chain ?p ?X ?c ∧ singular_chain (?p - 1) (subtopology ?X ?S) (chain_boundary ?p ?c))›*))
then show "?thesis"
(*goal: ‹homologous_rel p X' T (f c) (g c)›*)
using assms (*‹singular_chain p X ?c ⟹ singular_chain (Suc p) X' (h ?c)› ‹singular_chain (p - 1) (subtopology X S) ?c ⟹ singular_chain p (subtopology X' T) (h' ?c)› ‹singular_chain p X ?c ⟹ chain_boundary (Suc p) (h ?c) + h' (chain_boundary p ?c) = f ?c - g ?c› ‹singular_relcycle p X S c›*) by (metis homologous_rel_def (*‹homologous_rel ?p ?X ?S ≡ λa b. singular_relboundary ?p ?X ?S (a - b)›*) singular_relboundary (*‹singular_relboundary ?p ?X ?S ?c = (∃d e. singular_chain (Suc ?p) ?X d ∧ singular_chain ?p (subtopology ?X ?S) e ∧ chain_boundary (Suc ?p) d + e = ?c)›*) singular_relcycle (*‹singular_relcycle ?p ?X ?S ?c = (singular_chain ?p ?X ?c ∧ singular_chain (?p - 1) (subtopology ?X ?S) (chain_boundary ?p ?c))›*))
qed
subsection‹Show that all boundaries are cycles, the key "chain complex" property.›
lemma chain_boundary_boundary:
assumes "singular_chain p X c"
shows "chain_boundary (p - Suc 0) (chain_boundary p c) = 0"
proof (cases "p -1 = 0")
(*goals:
1. ‹p - 1 = 0 ⟹ chain_boundary (p - Suc 0) (chain_boundary p c) = 0›
2. ‹p - 1 ≠ 0 ⟹ chain_boundary (p - Suc 0) (chain_boundary p c) = 0›*)
case False (*‹p - 1 ≠ 0›*)
then have "2 ≤ p"
by auto
show "?thesis"
(*goal: ‹chain_boundary (p - Suc 0) (chain_boundary p c) = 0›*)
using assms (*‹singular_chain p X c›*) unfolding singular_chain_def
(*goal: ‹chain_boundary (p - Suc 0) (chain_boundary p c) = 0›*)
proof (induction rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹chain_boundary (p - Suc 0) (chain_boundary p 0) = 0›
2. ‹⋀x. x ∈ singular_simplex_set p X ⟹ chain_boundary (p - Suc 0) (chain_boundary p (frag_of x)) = 0›
3. ‹⋀a b. ⟦chain_boundary (p - Suc 0) (chain_boundary p a) = 0; chain_boundary (p - Suc 0) (chain_boundary p b) = 0⟧ ⟹ chain_boundary (p - Suc 0) (chain_boundary p (a - b)) = 0›*)
case (one g) (*‹g ∈ singular_simplex_set p X›*)
then have ss: "singular_simplex p X g"
by simp
have eql: "{..p} × {..p - Suc 0} ∩ {(x, y). y < x} = (λ(j,i). (Suc i, j)) ` {(i,j). i ≤ j ∧ j ≤ p -1}"
using False (*‹(p::nat) - (1::nat) ≠ (0::nat)›*) apply (auto simp: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*goal: ‹{..p} × {..p - Suc 0} ∩ {(x, y). y < x} = (λ(j, i). (Suc i, j)) ` {(i, j). i ≤ j ∧ j ≤ p - 1}›*)
by (metis One_nat_def (*‹1 = Suc 0›*) diff_Suc_1 (*‹Suc ?n - 1 = ?n›*) diff_le_mono (*‹?m ≤ ?n ⟹ ?m - ?l ≤ ?n - ?l›*) le_refl (*‹?n ≤ ?n›*) lessE (*‹⟦?i < ?k; ?k = Suc ?i ⟹ ?P; ⋀j. ⟦?i < j; ?k = Suc j⟧ ⟹ ?P⟧ ⟹ ?P›*) less_imp_le_nat (*‹?m < ?n ⟹ ?m ≤ ?n›*))
have eqr: "{..p} × {..p - Suc 0} - {(x, y). y < x} = {(i,j). i ≤ j ∧ j ≤ p -1}"
by auto
have eqf: "singular_face (p - Suc 0) i (singular_face p (Suc j) g) =
singular_face (p - Suc 0) j (singular_face p i g)" if "i ≤ j" "j ≤ p - Suc 0" for i and j
proof (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*))
(*goal: ‹⋀x. singular_face (p - Suc 0) i (singular_face p (Suc j) g) x = singular_face (p - Suc 0) j (singular_face p i g) x›*)
fix t
show "singular_face (p - Suc 0) i (singular_face p (Suc j) g) t =
singular_face (p - Suc 0) j (singular_face p i g) t"
proof (cases "t ∈ standard_simplex (p -1 -1)")
(*goals:
1. ‹(t::nat ⇒ real) ∈ standard_simplex ((p::nat) - (1::nat) - (1::nat)) ⟹ singular_face (p - Suc (0::nat)) (i::nat) (singular_face p (Suc (j::nat)) (g::(nat ⇒ real) ⇒ 'a::type)) t = singular_face (p - Suc (0::nat)) j (singular_face p i g) t›
2. ‹(t::nat ⇒ real) ∉ standard_simplex ((p::nat) - (1::nat) - (1::nat)) ⟹ singular_face (p - Suc (0::nat)) (i::nat) (singular_face p (Suc (j::nat)) (g::(nat ⇒ real) ⇒ 'a::type)) t = singular_face (p - Suc (0::nat)) j (singular_face p i g) t›*)
case True (*‹t ∈ standard_simplex (p - 1 - 1)›*)
have fi: "simplical_face i t ∈ standard_simplex (p - Suc 0)"
using False (*‹(p::nat) - (1::nat) ≠ (0::nat)›*) True (*‹(t::nat ⇒ real) ∈ standard_simplex ((p::nat) - (1::nat) - (1::nat))›*) simplical_face_in_standard_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p; ?x ∈ standard_simplex (?p - Suc 0)⟧ ⟹ simplical_face ?k ?x ∈ standard_simplex ?p›*) that (*‹(i::nat) ≤ (j::nat)› ‹j ≤ p - Suc 0›*) by force
have fj: "simplical_face j t ∈ standard_simplex (p - Suc 0)"
by (metis False (*‹p - 1 ≠ 0›*) One_nat_def (*‹1 = Suc 0›*) True (*‹t ∈ standard_simplex (p - 1 - 1)›*) simplical_face_in_standard_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p; ?x ∈ standard_simplex (?p - Suc 0)⟧ ⟹ simplical_face ?k ?x ∈ standard_simplex ?p›*) less_one (*‹(?n < 1) = (?n = 0)›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) that( (*‹j ≤ p - Suc 0›*) 2))
have eq: "simplical_face (Suc j) (simplical_face i t) = simplical_face i (simplical_face j t)"
using True (*‹(t::nat ⇒ real) ∈ standard_simplex ((p::nat) - (1::nat) - (1::nat))›*) that (*‹i ≤ j› ‹j ≤ p - Suc 0›*) ss (*‹singular_simplex p X g›*) unfolding standard_simplex_def simplical_face_def
(*goal: ‹(λia. if ia < Suc j then if ia < i then t ia else if ia = i then 0 else t (ia - 1) else if ia = Suc j then 0 else if ia - 1 < i then t (ia - 1) else if ia - 1 = i then 0 else t (ia - 1 - 1)) = (λia. if ia < i then if ia < j then t ia else if ia = j then 0 else t (ia - 1) else if ia = i then 0 else if ia - 1 < j then t (ia - 1) else if ia - 1 = j then 0 else t (ia - 1 - 1))›*)
by fastforce
show "?thesis"
(*goal: ‹singular_face (p - Suc 0) i (singular_face p (Suc j) g) t = singular_face (p - Suc 0) j (singular_face p i g) t›*)
by (simp add: singular_face_def (*‹singular_face ?p ?k ?f ≡ restrict (?f ∘ simplical_face ?k) (standard_simplex (?p - Suc 0))›*) fi (*‹simplical_face i t ∈ standard_simplex (p - Suc 0)›*) fj (*‹simplical_face j t ∈ standard_simplex (p - Suc 0)›*) eq (*‹simplical_face (Suc j) (simplical_face i t) = simplical_face i (simplical_face j t)›*))
qed (simp add: singular_face_def (*‹singular_face ?p ?k ?f ≡ restrict (?f ∘ simplical_face ?k) (standard_simplex (?p - Suc 0))›*))
(*solved the remaining goal: ‹t ∉ standard_simplex (p - 1 - 1) ⟹ singular_face (p - Suc 0) i (singular_face p (Suc j) g) t = singular_face (p - Suc 0) j (singular_face p i g) t›*)
qed
show "?case"
(*goal: ‹chain_boundary (p - Suc 0) (chain_boundary p (frag_of g)) = 0›*)
proof (cases "p = 1")
(*goals:
1. ‹p = 1 ⟹ chain_boundary (p - Suc 0) (chain_boundary p (frag_of g)) = 0›
2. ‹p ≠ 1 ⟹ chain_boundary (p - Suc 0) (chain_boundary p (frag_of g)) = 0›*)
case False (*‹p ≠ 1›*)
have eq0: "frag_cmul (-1) a = b ⟹ a + b = 0" for a and b
by (simp add: neg_eq_iff_add_eq_0 (*‹(- ?a = ?b) = (?a + ?b = 0)›*))
have "*": "(∑x≤p. ∑i≤p - Suc 0.
frag_cmul ((-1) ^ (x + i)) (frag_of (singular_face (p - Suc 0) i (singular_face p x g))))
= 0"
apply (simp add: sum.cartesian_product (*‹(∑x::?'b∈(?A::?'b set). sum ((?g::?'b ⇒ ?'c ⇒ ?'a) x) (?B::?'c set)) = (∑(x::?'b, y::?'c)∈?A × ?B. ?g x y)›*) sum.Int_Diff [of "_ × _" _ "{(x,y). y < x}"] (*‹finite ((?uu5::?'b1 set) × (?uua5::?'b1 set)) ⟹ sum (?g::?'b1 × ?'b1 ⇒ ?'a) (?uu5 × ?uua5) = sum ?g (?uu5 × ?uua5 ∩ {(x::?'b1, y::?'b1). y < x}) + sum ?g (?uu5 × ?uua5 - {(x::?'b1, y::?'b1). y < x})›*))
(*goal: ‹(∑x≤p. ∑i≤p - Suc 0. frag_cmul ((- 1) ^ (x + i)) (frag_of (singular_face (p - Suc 0) i (singular_face p x g)))) = 0›*)
apply (rule eq0 (*‹frag_cmul (- 1) ?a1 = ?b1 ⟹ ?a1 + ?b1 = 0›*))
(*goal: ‹(∑x∈{..p} × {..p - Suc 0} ∩ {(x, y). y < x}. case x of (x, i) ⇒ frag_cmul ((- 1) ^ (x + i)) (frag_of (singular_face (p - Suc 0) i (singular_face p x g)))) + (∑x∈{..p} × {..p - Suc 0} - {(x, y). y < x}. case x of (x, i) ⇒ frag_cmul ((- 1) ^ (x + i)) (frag_of (singular_face (p - Suc 0) i (singular_face p x g)))) = 0›*)
unfolding frag_cmul_sum prod.case_distrib[of "frag_cmul (-1)"] frag_cmul_cmul eql eqr
(*goal: ‹(∑i∈(λ(j, i). (Suc i, j)) ` {(i, j). i ≤ j ∧ j ≤ p - 1}. case i of (x1, x2) ⇒ frag_cmul (- 1 * (- 1) ^ (x1 + x2)) (frag_of (singular_face (p - Suc 0) x2 (singular_face p x1 g)))) = (∑x∈{(i, j). i ≤ j ∧ j ≤ p - 1}. case x of (x, i) ⇒ frag_cmul ((- 1) ^ (x + i)) (frag_of (singular_face (p - Suc 0) i (singular_face p x g))))›*)
by (force simp: inj_on_def (*‹inj_on (?f::?'a ⇒ ?'b) (?A::?'a set) = (∀x::?'a∈?A. ∀y::?'a∈?A. ?f x = ?f y ⟶ x = y)›*) sum.reindex (*‹inj_on (?h::?'b ⇒ ?'c) (?A::?'b set) ⟹ sum (?g::?'c ⇒ ?'a) (?h ` ?A) = sum (?g ∘ ?h) ?A›*) add.commute (*‹(?a::?'a) + (?b::?'a) = ?b + ?a›*) eqf (*‹⟦(?i::nat) ≤ (?j::nat); ?j ≤ (p::nat) - Suc (0::nat)⟧ ⟹ singular_face (p - Suc (0::nat)) ?i (singular_face p (Suc ?j) (g::(nat ⇒ real) ⇒ 'a)) = singular_face (p - Suc (0::nat)) ?j (singular_face p ?i g)›*) intro: sum.cong (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B ⟹ (?g::?'b ⇒ ?'a) x = (?h::?'b ⇒ ?'a) x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
show "?thesis"
(*goal: ‹chain_boundary (p - Suc 0) (chain_boundary p (frag_of g)) = 0›*)
using False (*‹p ≠ 1›*) by (simp add: chain_boundary_of (*‹chain_boundary ?p (frag_of ?f) = (if ?p = 0 then 0 else ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k ?f)))›*) chain_boundary_sum (*‹chain_boundary ?p (sum ?g ?I) = sum (chain_boundary ?p ∘ ?g) ?I›*) chain_boundary_cmul (*‹chain_boundary ?p (frag_cmul ?k ?c) = frag_cmul ?k (chain_boundary ?p ?c)›*) frag_cmul_sum (*‹frag_cmul ?a (sum ?b ?I) = (∑i∈?I. frag_cmul ?a (?b i))›*) * (*‹(∑x≤p. ∑i≤p - Suc 0. frag_cmul ((- 1) ^ (x + i)) (frag_of (singular_face (p - Suc 0) i (singular_face p x g)))) = 0›*) flip: power_add (*‹?a ^ (?m + ?n) = ?a ^ ?m * ?a ^ ?n›*))
qed (simp add: chain_boundary_def (*‹chain_boundary ?p ?c ≡ if ?p = 0 then 0 else frag_extend (λf. ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k f))) ?c›*))
(*solved the remaining goal: ‹p = 1 ⟹ chain_boundary (p - Suc 0) (chain_boundary p (frag_of g)) = 0›*)
next
(*goals:
1. ‹chain_boundary (p - Suc 0) (chain_boundary p 0) = 0›
2. ‹⋀a b. ⟦chain_boundary (p - Suc 0) (chain_boundary p a) = 0; chain_boundary (p - Suc 0) (chain_boundary p b) = 0⟧ ⟹ chain_boundary (p - Suc 0) (chain_boundary p (a - b)) = 0›*)
case (diff a b) (*‹chain_boundary (p - Suc 0) (chain_boundary p a) = 0› ‹chain_boundary (p - Suc 0) (chain_boundary p b) = 0›*)
then show "?case"
(*goal: ‹chain_boundary (p - Suc 0) (chain_boundary p (a - b)) = 0›*)
by (simp add: chain_boundary_diff (*‹chain_boundary ?p (?a - ?b) = chain_boundary ?p ?a - chain_boundary ?p ?b›*))
qed (auto)
(*solved the remaining goal: ‹chain_boundary (p - Suc 0) (chain_boundary p 0) = 0›*)
qed (simp add: chain_boundary_def (*‹chain_boundary ?p ?c ≡ if ?p = 0 then 0 else frag_extend (λf. ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k f))) ?c›*))
(*solved the remaining goal: ‹p - 1 = 0 ⟹ chain_boundary (p - Suc 0) (chain_boundary p c) = 0›*)
lemma chain_boundary_boundary_alt:
"singular_chain (Suc p) X c ⟹ chain_boundary p (chain_boundary (Suc p) c) = 0"
using chain_boundary_boundary (*‹singular_chain (?p::nat) (?X::?'a topology) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ⟹ chain_boundary (?p - Suc (0::nat)) (chain_boundary ?p ?c) = (0::((nat ⇒ real) ⇒ ?'a) ⇒₀ int)›*) by force
lemma singular_relboundary_imp_relcycle:
assumes "singular_relboundary p X S c"
shows "singular_relcycle p X S c"
proof (-)
(*goal: ‹singular_relcycle (p::nat) (X::'a topology) (S::'a set) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*)
obtain d and e where d: "singular_chain (Suc p) X d" and e: "singular_chain p (subtopology X S) e" and c: "c = chain_boundary (Suc p) d + e"
(*goal: ‹(⋀d e. ⟦singular_chain (Suc p) X d; singular_chain p (subtopology X S) e; c = chain_boundary (Suc p) d + e⟧ ⟹ thesis) ⟹ thesis›*)
using assms (*‹singular_relboundary p X S c›*) by (auto simp: singular_relboundary (*‹singular_relboundary (?p::nat) (?X::?'a topology) (?S::?'a set) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) = (∃(d::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) e::((nat ⇒ real) ⇒ ?'a) ⇒₀ int. singular_chain (Suc ?p) ?X d ∧ singular_chain ?p (subtopology ?X ?S) e ∧ chain_boundary (Suc ?p) d + e = ?c)›*) singular_relcycle (*‹singular_relcycle (?p::nat) (?X::?'a topology) (?S::?'a set) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) = (singular_chain ?p ?X ?c ∧ singular_chain (?p - (1::nat)) (subtopology ?X ?S) (chain_boundary ?p ?c))›*))
have 1: "singular_chain (p - Suc 0) (subtopology X S) (chain_boundary p (chain_boundary (Suc p) d))"
using d (*‹singular_chain (Suc p) X d›*) chain_boundary_boundary_alt (*‹singular_chain (Suc ?p) ?X ?c ⟹ chain_boundary ?p (chain_boundary (Suc ?p) ?c) = 0›*) by fastforce
have 2: "singular_chain (p - Suc 0) (subtopology X S) (chain_boundary p e)"
using ‹singular_chain p (subtopology X S) e› (*‹singular_chain p (subtopology X S) e›*) singular_chain_boundary (*‹singular_chain (?p::nat) (?X::?'a::type topology) (?c::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int) ⟹ singular_chain (?p - Suc (0::nat)) ?X (chain_boundary ?p ?c)›*) by auto
have "singular_chain p X c"
using assms (*‹singular_relboundary p X S c›*) singular_relboundary_imp_chain (*‹singular_relboundary (?p::nat) (?X::?'a topology) (?S::?'a set) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ⟹ singular_chain ?p ?X ?c›*) by auto
moreover have "singular_chain (p - Suc 0) (subtopology X S) (chain_boundary p c)"
by (simp add: c (*‹c = chain_boundary (Suc p) d + e›*) chain_boundary_add (*‹chain_boundary ?p (?a + ?b) = chain_boundary ?p ?a + chain_boundary ?p ?b›*) singular_chain_add (*‹⟦singular_chain ?p ?X ?a; singular_chain ?p ?X ?b⟧ ⟹ singular_chain ?p ?X (?a + ?b)›*) 1 (*‹singular_chain (p - Suc 0) (subtopology X S) (chain_boundary p (chain_boundary (Suc p) d))›*) 2 (*‹singular_chain (p - Suc 0) (subtopology X S) (chain_boundary p e)›*))
ultimately show "?thesis"
(*goal: ‹singular_relcycle (p::nat) (X::'a topology) (S::'a set) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*)
by (simp add: singular_relcycle (*‹singular_relcycle ?p ?X ?S ?c = (singular_chain ?p ?X ?c ∧ singular_chain (?p - 1) (subtopology ?X ?S) (chain_boundary ?p ?c))›*))
qed
lemma homologous_rel_singular_relcycle_1:
assumes "homologous_rel p X S c1 c2" "singular_relcycle p X S c1"
shows "singular_relcycle p X S c2"
using assms (*‹homologous_rel p X S c1 c2› ‹singular_relcycle p X S c1›*) by (metis diff_add_cancel (*‹?a - ?b + ?b = ?a›*) homologous_rel_def (*‹homologous_rel ?p ?X ?S ≡ λa b. singular_relboundary ?p ?X ?S (a - b)›*) homologous_rel_sym (*‹homologous_rel ?p ?X ?S ?a ?b = homologous_rel ?p ?X ?S ?b ?a›*) singular_relboundary_imp_relcycle (*‹singular_relboundary ?p ?X ?S ?c ⟹ singular_relcycle ?p ?X ?S ?c›*) singular_relcycle_add (*‹⟦singular_relcycle ?p ?X ?S ?a; singular_relcycle ?p ?X ?S ?b⟧ ⟹ singular_relcycle ?p ?X ?S (?a + ?b)›*))
lemma homologous_rel_singular_relcycle:
assumes "homologous_rel p X S c1 c2"
shows "singular_relcycle p X S c1 = singular_relcycle p X S c2"
using assms (*‹homologous_rel (p::nat) (X::'a topology) (S::'a set) (c1::((nat ⇒ real) ⇒ 'a) ⇒₀ int) (c2::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*) homologous_rel_singular_relcycle_1 (*‹⟦homologous_rel ?p ?X ?S ?c1.0 ?c2.0; singular_relcycle ?p ?X ?S ?c1.0⟧ ⟹ singular_relcycle ?p ?X ?S ?c2.0›*) using homologous_rel_sym (*‹homologous_rel (?p::nat) (?X::?'a topology) (?S::?'a set) (?a::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) (?b::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) = homologous_rel ?p ?X ?S ?b ?a›*) by blast
subsection‹Operations induced by a continuous map g between topological spaces›
definition simplex_map :: "nat ⇒ ('b ⇒ 'a) ⇒ ((nat ⇒ real) ⇒ 'b) ⇒ (nat ⇒ real) ⇒ 'a"
where "simplex_map p g c ≡ restrict (g ∘ c) (standard_simplex p)"
lemma singular_simplex_simplex_map:
"⟦singular_simplex p X f; continuous_map X X' g⟧
⟹ singular_simplex p X' (simplex_map p g f)"
unfolding singular_simplex_def simplex_map_def
(*goal: ‹⟦continuous_map (subtopology (powertop_real UNIV) (standard_simplex p)) X f ∧ f ∈ extensional (standard_simplex p); continuous_map X X' g⟧ ⟹ continuous_map (subtopology (powertop_real UNIV) (standard_simplex p)) X' (restrict (g ∘ f) (standard_simplex p)) ∧ restrict (g ∘ f) (standard_simplex p) ∈ extensional (standard_simplex p)›*)
by (auto simp: continuous_map_compose (*‹⟦continuous_map ?X ?X' ?f; continuous_map ?X' ?X'' ?g⟧ ⟹ continuous_map ?X ?X'' (?g ∘ ?f)›*))
lemma simplex_map_eq:
"⟦singular_simplex p X c;
⋀x. x ∈ topspace X ⟹ f x = g x⟧
⟹ simplex_map p f c = simplex_map p g c"
by (auto simp: singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*) simplex_map_def (*‹simplex_map ?p ?g ?c ≡ restrict (?g ∘ ?c) (standard_simplex ?p)›*) continuous_map_def (*‹continuous_map ?X ?Y ?f ≡ ?f ∈ topspace ?X → topspace ?Y ∧ (∀U. openin ?Y U ⟶ openin ?X {x ∈ topspace ?X. ?f x ∈ U})›*) Pi_iff (*‹(?f ∈ Pi ?I ?X) = (∀i∈?I. ?f i ∈ ?X i)›*))
lemma simplex_map_id_gen:
"⟦singular_simplex p X c;
⋀x. x ∈ topspace X ⟹ f x = x⟧
⟹ simplex_map p f c = c"
unfolding singular_simplex_def simplex_map_def continuous_map_def
(*goal: ‹⟦((c::(nat ⇒ real) ⇒ 'a) ∈ topspace (subtopology (powertop_real UNIV) (standard_simplex (p::nat))) → topspace (X::'a topology) ∧ (∀U::'a set. openin X U ⟶ openin (subtopology (powertop_real UNIV) (standard_simplex p)) {x::nat ⇒ real ∈ topspace (subtopology (powertop_real UNIV) (standard_simplex p)). c x ∈ U})) ∧ c ∈ extensional (standard_simplex p); ⋀x::'a. x ∈ topspace X ⟹ (f::'a ⇒ 'a) x = x⟧ ⟹ restrict (f ∘ c) (standard_simplex p) = c›*)
using extensional_arb (*‹⟦(?f::?'a ⇒ ?'b) ∈ extensional (?A::?'a set); (?x::?'a) ∉ ?A⟧ ⟹ ?f ?x = undefined›*) by fastforce
lemma simplex_map_id [simp]:
"simplex_map p id = (λc. restrict c (standard_simplex p))"
by (auto simp: simplex_map_def (*‹simplex_map ?p ?g ?c ≡ restrict (?g ∘ ?c) (standard_simplex ?p)›*))
lemma simplex_map_compose:
"simplex_map p (h ∘ g) = simplex_map p h ∘ simplex_map p g"
unfolding simplex_map_def
(*goal: ‹(λc. restrict (h ∘ g ∘ c) (standard_simplex p)) = (λc. restrict (h ∘ c) (standard_simplex p)) ∘ (λc. restrict (g ∘ c) (standard_simplex p))›*)
by force
lemma singular_face_simplex_map:
"⟦1 ≤ p; k ≤ p⟧
⟹ singular_face p k (simplex_map p f c) = simplex_map (p - Suc 0) f (c ∘ simplical_face k)"
unfolding simplex_map_def singular_face_def
(*goal: ‹⟦(1::nat) ≤ (p::nat); (k::nat) ≤ p⟧ ⟹ restrict (restrict ((f::'b::type ⇒ 'a::type) ∘ (c::(nat ⇒ real) ⇒ 'b::type)) (standard_simplex p) ∘ simplical_face k) (standard_simplex (p - Suc (0::nat))) = restrict (f ∘ (c ∘ simplical_face k)) (standard_simplex (p - Suc (0::nat)))›*)
by (force simp: simplical_face_in_standard_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p; ?x ∈ standard_simplex (?p - Suc 0)⟧ ⟹ simplical_face ?k ?x ∈ standard_simplex ?p›*))
lemma singular_face_restrict [simp]:
assumes "p > 0" "i ≤ p"
shows "singular_face p i (restrict f (standard_simplex p)) = singular_face p i f"
by (metis assms (*‹0 < p› ‹i ≤ p›*) One_nat_def (*‹1 = Suc 0›*) Suc_leI (*‹?m < ?n ⟹ Suc ?m ≤ ?n›*) simplex_map_id (*‹simplex_map ?p id = (λc. restrict c (standard_simplex ?p))›*) singular_face_def (*‹singular_face ?p ?k ?f ≡ restrict (?f ∘ simplical_face ?k) (standard_simplex (?p - Suc 0))›*) singular_face_simplex_map (*‹⟦1 ≤ ?p; ?k ≤ ?p⟧ ⟹ singular_face ?p ?k (simplex_map ?p ?f ?c) = simplex_map (?p - Suc 0) ?f (?c ∘ simplical_face ?k)›*))
definition chain_map :: "nat ⇒ ('b ⇒ 'a) ⇒ (((nat ⇒ real) ⇒ 'b) ⇒₀ int) ⇒ 'a chain"
where "chain_map p g c ≡ frag_extend (frag_of ∘ simplex_map p g) c"
lemma singular_chain_chain_map:
"⟦singular_chain p X c; continuous_map X X' g⟧ ⟹ singular_chain p X' (chain_map p g c)"
unfolding chain_map_def
(*goal: ‹⟦singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int); continuous_map X (X'::'b topology) (g::'a ⇒ 'b)⟧ ⟹ singular_chain p X' (frag_extend (frag_of ∘ simplex_map p g) c)›*)
by (force simp add: singular_chain_def (*‹singular_chain (?p::nat) (?X::?'a topology) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ≡ Poly_Mapping.keys ?c ⊆ singular_simplex_set ?p ?X›*) subset_iff (*‹((?A::?'a set) ⊆ (?B::?'a set)) = (∀t::?'a. t ∈ ?A ⟶ t ∈ ?B)›*) intro!: singular_chain_extend (*‹(⋀c::?'a. c ∈ Poly_Mapping.keys (?x::?'a ⇒₀ int) ⟹ singular_chain (?p::nat) (?X::?'b topology) ((?f::?'a ⇒ ((nat ⇒ real) ⇒ ?'b) ⇒₀ int) c)) ⟹ singular_chain ?p ?X (frag_extend ?f ?x)›*) singular_simplex_simplex_map (*‹⟦singular_simplex (?p::nat) (?X::?'a topology) (?f::(nat ⇒ real) ⇒ ?'a); continuous_map ?X (?X'::?'b topology) (?g::?'a ⇒ ?'b)⟧ ⟹ singular_simplex ?p ?X' (simplex_map ?p ?g ?f)›*))
lemma chain_map_0 [simp]: "chain_map p g 0 = 0"
by (auto simp: chain_map_def (*‹chain_map ?p ?g ?c ≡ frag_extend (frag_of ∘ simplex_map ?p ?g) ?c›*))
lemma chain_map_of [simp]: "chain_map p g (frag_of f) = frag_of (simplex_map p g f)"
by (simp add: chain_map_def (*‹chain_map ?p ?g ?c ≡ frag_extend (frag_of ∘ simplex_map ?p ?g) ?c›*))
lemma chain_map_cmul [simp]:
"chain_map p g (frag_cmul a c) = frag_cmul a (chain_map p g c)"
by (simp add: frag_extend_cmul (*‹frag_extend ?f (frag_cmul ?c ?x) = frag_cmul ?c (frag_extend ?f ?x)›*) chain_map_def (*‹chain_map ?p ?g ?c ≡ frag_extend (frag_of ∘ simplex_map ?p ?g) ?c›*))
lemma chain_map_minus: "chain_map p g (-c) = - (chain_map p g c)"
by (simp add: frag_extend_minus (*‹frag_extend (?f::?'b ⇒ ?'a ⇒₀ int) (- (?x::?'b ⇒₀ int)) = - frag_extend ?f ?x›*) chain_map_def (*‹chain_map (?p::nat) (?g::?'b ⇒ ?'a) (?c::((nat ⇒ real) ⇒ ?'b) ⇒₀ int) ≡ frag_extend (frag_of ∘ simplex_map ?p ?g) ?c›*))
lemma chain_map_add:
"chain_map p g (a+b) = chain_map p g a + chain_map p g b"
by (simp add: frag_extend_add (*‹frag_extend ?f (?a + ?b) = frag_extend ?f ?a + frag_extend ?f ?b›*) chain_map_def (*‹chain_map ?p ?g ?c ≡ frag_extend (frag_of ∘ simplex_map ?p ?g) ?c›*))
lemma chain_map_diff:
"chain_map p g (a-b) = chain_map p g a - chain_map p g b"
by (simp add: frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*) chain_map_def (*‹chain_map ?p ?g ?c ≡ frag_extend (frag_of ∘ simplex_map ?p ?g) ?c›*))
lemma chain_map_sum:
"finite I ⟹ chain_map p g (sum f I) = sum (chain_map p g ∘ f) I"
by (simp add: frag_extend_sum (*‹finite ?I ⟹ frag_extend ?f (sum ?g ?I) = sum (frag_extend ?f ∘ ?g) ?I›*) chain_map_def (*‹chain_map ?p ?g ?c ≡ frag_extend (frag_of ∘ simplex_map ?p ?g) ?c›*))
lemma chain_map_eq:
"⟦singular_chain p X c; ⋀x. x ∈ topspace X ⟹ f x = g x⟧
⟹ chain_map p f c = chain_map p g c"
unfolding singular_chain_def
(*goal: ‹⟦Poly_Mapping.keys c ⊆ singular_simplex_set p X; ⋀x. x ∈ topspace X ⟹ f x = g x⟧ ⟹ chain_map p f c = chain_map p g c›*)
proof (induction rule: frag_induction (*‹⟦Poly_Mapping.keys (?c::?'a ⇒₀ int) ⊆ (?S::?'a set); (?P::(?'a ⇒₀ int) ⇒ bool) (0::?'a ⇒₀ int); ⋀x::?'a. x ∈ ?S ⟹ ?P (frag_of x); ⋀(a::?'a ⇒₀ int) b::?'a ⇒₀ int. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹(⋀x::'a. x ∈ topspace (X::'a topology) ⟹ (f::'a ⇒ 'b) x = (g::'a ⇒ 'b) x) ⟹ chain_map (p::nat) f (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int) = chain_map p g (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›
2. ‹⋀x::(nat ⇒ real) ⇒ 'a. ⟦x ∈ singular_simplex_set (p::nat) (X::'a topology); ⋀x::'a. x ∈ topspace X ⟹ (f::'a ⇒ 'b) x = (g::'a ⇒ 'b) x⟧ ⟹ chain_map p f (frag_of x) = chain_map p g (frag_of x)›
3. ‹⋀(a::((nat ⇒ real) ⇒ 'a) ⇒₀ int) b::((nat ⇒ real) ⇒ 'a) ⇒₀ int. ⟦(⋀x::'a. x ∈ topspace (X::'a topology) ⟹ (f::'a ⇒ 'b) x = (g::'a ⇒ 'b) x) ⟹ chain_map (p::nat) f a = chain_map p g a; (⋀x::'a. x ∈ topspace X ⟹ f x = g x) ⟹ chain_map p f b = chain_map p g b; ⋀x::'a. x ∈ topspace X ⟹ f x = g x⟧ ⟹ chain_map p f (a - b) = chain_map p g (a - b)›*)
case (one x) (*‹x ∈ singular_simplex_set p X› ‹?x ∈ topspace X ⟹ f ?x = g ?x›*)
then show "?case"
(*goal: ‹chain_map (p::nat) (f::'a ⇒ 'b) (frag_of (x::(nat ⇒ real) ⇒ 'a)) = chain_map p (g::'a ⇒ 'b) (frag_of x)›*)
by (metis (no_types, lifting) chain_map_of (*‹chain_map ?p ?g (frag_of ?f) = frag_of (simplex_map ?p ?g ?f)›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) simplex_map_eq (*‹⟦singular_simplex ?p ?X ?c; ⋀x. x ∈ topspace ?X ⟹ ?f x = ?g x⟧ ⟹ simplex_map ?p ?f ?c = simplex_map ?p ?g ?c›*))
qed (auto simp: chain_map_diff (*‹chain_map ?p ?g (?a - ?b) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*))
(*solves the remaining goals:
1. ‹(⋀x. x ∈ topspace X ⟹ f x = g x) ⟹ chain_map p f 0 = chain_map p g 0›
2. ‹⋀a b. ⟦(⋀x. x ∈ topspace X ⟹ f x = g x) ⟹ chain_map p f a = chain_map p g a; (⋀x. x ∈ topspace X ⟹ f x = g x) ⟹ chain_map p f b = chain_map p g b; ⋀x. x ∈ topspace X ⟹ f x = g x⟧ ⟹ chain_map p f (a - b) = chain_map p g (a - b)›*)
lemma chain_map_id_gen:
"⟦singular_chain p X c; ⋀x. x ∈ topspace X ⟹ f x = x⟧
⟹ chain_map p f c = c"
unfolding singular_chain_def
(*goal: ‹⟦Poly_Mapping.keys c ⊆ singular_simplex_set p X; ⋀x. x ∈ topspace X ⟹ f x = x⟧ ⟹ chain_map p f c = c›*)
apply (erule frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹(⋀x::'a::type. x ∈ topspace (X::'a::type topology) ⟹ (f::'a::type ⇒ 'a::type) x = x) ⟹ chain_map (p::nat) f (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) = (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)›
2. ‹⋀x::(nat ⇒ real) ⇒ 'a::type. ⟦⋀x::'a::type. x ∈ topspace (X::'a::type topology) ⟹ (f::'a::type ⇒ 'a::type) x = x; x ∈ singular_simplex_set (p::nat) X⟧ ⟹ chain_map p f (frag_of x) = frag_of x›
3. ‹⋀(a::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) b::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. ⟦⋀x::'a::type. x ∈ topspace (X::'a::type topology) ⟹ (f::'a::type ⇒ 'a::type) x = x; chain_map (p::nat) f a = a; chain_map p f b = b⟧ ⟹ chain_map p f (a - b) = a - b›
discuss goal 1*)
apply ((auto simp: chain_map_diff (*‹chain_map (?p::nat) (?g::?'b ⇒ ?'a) ((?a::((nat ⇒ real) ⇒ ?'b) ⇒₀ int) - (?b::((nat ⇒ real) ⇒ ?'b) ⇒₀ int)) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*) simplex_map_id_gen (*‹⟦singular_simplex (?p::nat) (?X::?'a topology) (?c::(nat ⇒ real) ⇒ ?'a); ⋀x::?'a. x ∈ topspace ?X ⟹ (?f::?'a ⇒ ?'a) x = x⟧ ⟹ simplex_map ?p ?f ?c = ?c›*))[1])
(*discuss goal 2*)
apply ((auto simp: chain_map_diff (*‹chain_map (?p::nat) (?g::?'b ⇒ ?'a) ((?a::((nat ⇒ real) ⇒ ?'b) ⇒₀ int) - (?b::((nat ⇒ real) ⇒ ?'b) ⇒₀ int)) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*) simplex_map_id_gen (*‹⟦singular_simplex (?p::nat) (?X::?'a topology) (?c::(nat ⇒ real) ⇒ ?'a); ⋀x::?'a. x ∈ topspace ?X ⟹ (?f::?'a ⇒ ?'a) x = x⟧ ⟹ simplex_map ?p ?f ?c = ?c›*))[1])
(*discuss goal 3*)
apply ((auto simp: chain_map_diff (*‹chain_map (?p::nat) (?g::?'b ⇒ ?'a) ((?a::((nat ⇒ real) ⇒ ?'b) ⇒₀ int) - (?b::((nat ⇒ real) ⇒ ?'b) ⇒₀ int)) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*) simplex_map_id_gen (*‹⟦singular_simplex (?p::nat) (?X::?'a topology) (?c::(nat ⇒ real) ⇒ ?'a); ⋀x::?'a. x ∈ topspace ?X ⟹ (?f::?'a ⇒ ?'a) x = x⟧ ⟹ simplex_map ?p ?f ?c = ?c›*))[1])
(*proven 3 subgoals*) .
lemma chain_map_ident:
"singular_chain p X c ⟹ chain_map p id c = c"
by (simp add: chain_map_id_gen (*‹⟦singular_chain ?p ?X ?c; ⋀x. x ∈ topspace ?X ⟹ ?f x = x⟧ ⟹ chain_map ?p ?f ?c = ?c›*))
lemma chain_map_id:
"chain_map p id = frag_extend (frag_of ∘ (λf. restrict f (standard_simplex p)))"
by (auto simp: chain_map_def (*‹chain_map ?p ?g ?c ≡ frag_extend (frag_of ∘ simplex_map ?p ?g) ?c›*))
lemma chain_map_compose:
"chain_map p (h ∘ g) = chain_map p h ∘ chain_map p g"
proof (standard)
(*goal: ‹⋀x::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. chain_map (p::nat) ((h::'c::type ⇒ 'b::type) ∘ (g::'a::type ⇒ 'c::type)) x = (chain_map p h ∘ chain_map p g) x›*)
show "chain_map p (h ∘ g) c = (chain_map p h ∘ chain_map p g) c" for c
using subset_UNIV (*‹?A ⊆ UNIV›*) proof (induction c rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹chain_map p (h ∘ g) 0 = (chain_map p h ∘ chain_map p g) 0›
2. ‹⋀x. x ∈ UNIV ⟹ chain_map p (h ∘ g) (frag_of x) = (chain_map p h ∘ chain_map p g) (frag_of x)›
3. ‹⋀a b. ⟦chain_map p (h ∘ g) a = (chain_map p h ∘ chain_map p g) a; chain_map p (h ∘ g) b = (chain_map p h ∘ chain_map p g) b⟧ ⟹ chain_map p (h ∘ g) (a - b) = (chain_map p h ∘ chain_map p g) (a - b)›*)
case (one x) (*‹(x::(nat ⇒ real) ⇒ 'a) ∈ UNIV›*)
then show "?case"
(*goal: ‹chain_map (p::nat) ((h::'c::type ⇒ 'b::type) ∘ (g::'a::type ⇒ 'c::type)) (frag_of (x::(nat ⇒ real) ⇒ 'a::type)) = (chain_map p h ∘ chain_map p g) (frag_of x)›*)
apply simp
(*goal: ‹chain_map (p::nat) ((h::'c ⇒ 'b) ∘ (g::'a ⇒ 'c)) (frag_of (x::(nat ⇒ real) ⇒ 'a)) = (chain_map p h ∘ chain_map p g) (frag_of x)›*)
by (metis (mono_tags, lifting) comp_eq_dest_lhs (*‹?a ∘ ?b = ?c ⟹ ?a (?b ?v) = ?c ?v›*) restrict_apply (*‹restrict ?f ?A ?x = (if ?x ∈ ?A then ?f ?x else undefined)›*) simplex_map_def (*‹simplex_map ?p ?g ?c ≡ restrict (?g ∘ ?c) (standard_simplex ?p)›*))
next
(*goals:
1. ‹chain_map p (h ∘ g) 0 = (chain_map p h ∘ chain_map p g) 0›
2. ‹⋀a b. ⟦chain_map p (h ∘ g) a = (chain_map p h ∘ chain_map p g) a; chain_map p (h ∘ g) b = (chain_map p h ∘ chain_map p g) b⟧ ⟹ chain_map p (h ∘ g) (a - b) = (chain_map p h ∘ chain_map p g) (a - b)›*)
case (diff a b) (*‹chain_map p (h ∘ g) a = (chain_map p h ∘ chain_map p g) a› ‹chain_map p (h ∘ g) b = (chain_map p h ∘ chain_map p g) b›*)
then show "?case"
(*goal: ‹chain_map p (h ∘ g) (a - b) = (chain_map p h ∘ chain_map p g) (a - b)›*)
by (simp add: chain_map_diff (*‹chain_map ?p ?g (?a - ?b) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*))
qed (auto)
(*solved the remaining goal: ‹chain_map (p::nat) ((h::'c::type ⇒ 'b::type) ∘ (g::'a::type ⇒ 'c::type)) (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) = (chain_map p h ∘ chain_map p g) (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)›*)
qed
lemma singular_simplex_chain_map_id:
assumes "singular_simplex p X f"
shows "chain_map p f (frag_of (restrict id (standard_simplex p))) = frag_of f"
proof (-)
(*goal: ‹chain_map p f (frag_of (restrict id (standard_simplex p))) = frag_of f›*)
have "(restrict (f ∘ restrict id (standard_simplex p)) (standard_simplex p)) = f"
apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*))
(*goal: ‹restrict (f ∘ restrict id (standard_simplex p)) (standard_simplex p) = f›*)
by (metis assms (*‹singular_simplex p X f›*) comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) extensional_arb (*‹⟦?f ∈ extensional ?A; ?x ∉ ?A⟧ ⟹ ?f ?x = undefined›*) id_apply (*‹id ?x = ?x›*) restrict_apply (*‹restrict ?f ?A ?x = (if ?x ∈ ?A then ?f ?x else undefined)›*) singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*))
then show "?thesis"
(*goal: ‹chain_map p f (frag_of (restrict id (standard_simplex p))) = frag_of f›*)
by (simp add: simplex_map_def (*‹simplex_map ?p ?g ?c ≡ restrict (?g ∘ ?c) (standard_simplex ?p)›*))
qed
lemma chain_boundary_chain_map:
assumes "singular_chain p X c"
shows "chain_boundary p (chain_map p g c) = chain_map (p - Suc 0) g (chain_boundary p c)"
using assms (*‹singular_chain p X c›*) unfolding singular_chain_def
(*goal: ‹chain_boundary (p::nat) (chain_map p (g::'a ⇒ 'b) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)) = chain_map (p - Suc (0::nat)) g (chain_boundary p c)›*)
proof (induction c rule: frag_induction (*‹⟦Poly_Mapping.keys (?c::?'a::type ⇒₀ int) ⊆ (?S::?'a::type set); (?P::(?'a::type ⇒₀ int) ⇒ bool) (0::?'a::type ⇒₀ int); ⋀x::?'a::type. x ∈ ?S ⟹ ?P (frag_of x); ⋀(a::?'a::type ⇒₀ int) b::?'a::type ⇒₀ int. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹chain_boundary (p::nat) (chain_map p (g::'a ⇒ 'b) (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int)) = chain_map (p - Suc (0::nat)) g (chain_boundary p (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int))›
2. ‹⋀x::(nat ⇒ real) ⇒ 'a. x ∈ singular_simplex_set (p::nat) (X::'a topology) ⟹ chain_boundary p (chain_map p (g::'a ⇒ 'b) (frag_of x)) = chain_map (p - Suc (0::nat)) g (chain_boundary p (frag_of x))›
3. ‹⋀(a::((nat ⇒ real) ⇒ 'a) ⇒₀ int) b::((nat ⇒ real) ⇒ 'a) ⇒₀ int. ⟦chain_boundary (p::nat) (chain_map p (g::'a ⇒ 'b) a) = chain_map (p - Suc (0::nat)) g (chain_boundary p a); chain_boundary p (chain_map p g b) = chain_map (p - Suc (0::nat)) g (chain_boundary p b)⟧ ⟹ chain_boundary p (chain_map p g (a - b)) = chain_map (p - Suc (0::nat)) g (chain_boundary p (a - b))›*)
case (one x) (*‹(x::(nat ⇒ real) ⇒ 'a::type) ∈ singular_simplex_set (p::nat) (X::'a::type topology)›*)
then have "singular_face p i (simplex_map p g x) = simplex_map (p - Suc 0) g (singular_face p i x)" if "0 ≤ i" "i ≤ p" "p ≠ 0" for i
using that (*‹0 ≤ i› ‹i ≤ p› ‹(p::nat) ≠ (0::nat)›*) by (fastforce simp add: singular_face_def (*‹singular_face ?p ?k ?f ≡ restrict (?f ∘ simplical_face ?k) (standard_simplex (?p - Suc 0))›*) simplex_map_def (*‹simplex_map ?p ?g ?c ≡ restrict (?g ∘ ?c) (standard_simplex ?p)›*) simplical_face_in_standard_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p; ?x ∈ standard_simplex (?p - Suc 0)⟧ ⟹ simplical_face ?k ?x ∈ standard_simplex ?p›*))
then show "?case"
(*goal: ‹chain_boundary (p::nat) (chain_map p (g::'a::type ⇒ 'b::type) (frag_of (x::(nat ⇒ real) ⇒ 'a::type))) = chain_map (p - Suc (0::nat)) g (chain_boundary p (frag_of x))›*)
by (auto simp: chain_boundary_of (*‹chain_boundary ?p (frag_of ?f) = (if ?p = 0 then 0 else ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k ?f)))›*) chain_map_sum (*‹finite ?I ⟹ chain_map ?p ?g (sum ?f ?I) = sum (chain_map ?p ?g ∘ ?f) ?I›*))
next
(*goals:
1. ‹chain_boundary p (chain_map p g 0) = chain_map (p - Suc 0) g (chain_boundary p 0)›
2. ‹⋀a b. ⟦chain_boundary p (chain_map p g a) = chain_map (p - Suc 0) g (chain_boundary p a); chain_boundary p (chain_map p g b) = chain_map (p - Suc 0) g (chain_boundary p b)⟧ ⟹ chain_boundary p (chain_map p g (a - b)) = chain_map (p - Suc 0) g (chain_boundary p (a - b))›*)
case (diff a b) (*‹chain_boundary (p::nat) (chain_map p (g::'a ⇒ 'b) (a::((nat ⇒ real) ⇒ 'a) ⇒₀ int)) = chain_map (p - Suc (0::nat)) g (chain_boundary p a)› ‹chain_boundary (p::nat) (chain_map p (g::'a ⇒ 'b) (b::((nat ⇒ real) ⇒ 'a) ⇒₀ int)) = chain_map (p - Suc (0::nat)) g (chain_boundary p b)›*)
then show "?case"
(*goal: ‹chain_boundary p (chain_map p g (a - b)) = chain_map (p - Suc 0) g (chain_boundary p (a - b))›*)
by (simp add: chain_boundary_diff (*‹chain_boundary ?p (?a - ?b) = chain_boundary ?p ?a - chain_boundary ?p ?b›*) chain_map_diff (*‹chain_map ?p ?g (?a - ?b) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*))
qed (auto)
(*solved the remaining goal: ‹chain_boundary p (chain_map p g 0) = chain_map (p - Suc 0) g (chain_boundary p 0)›*)
lemma singular_relcycle_chain_map:
assumes "singular_relcycle p X S c" "continuous_map X X' g" "g ` S ⊆ T"
shows "singular_relcycle p X' T (chain_map p g c)"
proof (-)
(*goal: ‹singular_relcycle p X' T (chain_map p g c)›*)
have "continuous_map (subtopology X S) (subtopology X' T) g"
using assms (*‹singular_relcycle p X S c› ‹continuous_map (X::'a topology) (X'::'b topology) (g::'a ⇒ 'b)› ‹g ` S ⊆ T›*) using continuous_map_from_subtopology (*‹continuous_map ?X ?Y ?f ⟹ continuous_map (subtopology ?X ?S) ?Y ?f›*) continuous_map_in_subtopology (*‹continuous_map ?X (subtopology ?X' ?S) ?f = (continuous_map ?X ?X' ?f ∧ ?f ` topspace ?X ⊆ ?S)›*) topspace_subtopology (*‹topspace (subtopology ?U ?V) = topspace ?U ∩ ?V›*) by fastforce
then show "?thesis"
(*goal: ‹singular_relcycle p X' T (chain_map p g c)›*)
using chain_boundary_chain_map[of p X c g] (*‹singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⟹ chain_boundary p (chain_map p (g::'a ⇒ 'b) c) = chain_map (p - Suc (0::nat)) g (chain_boundary p c)›*) by (metis One_nat_def (*‹1 = Suc 0›*) assms( (*‹singular_relcycle p X S c›*) 1) assms( (*‹continuous_map X X' g›*) 2) singular_chain_chain_map (*‹⟦singular_chain ?p ?X ?c; continuous_map ?X ?X' ?g⟧ ⟹ singular_chain ?p ?X' (chain_map ?p ?g ?c)›*) singular_relcycle (*‹singular_relcycle ?p ?X ?S ?c = (singular_chain ?p ?X ?c ∧ singular_chain (?p - 1) (subtopology ?X ?S) (chain_boundary ?p ?c))›*))
qed
lemma singular_relboundary_chain_map:
assumes "singular_relboundary p X S c" "continuous_map X X' g" "g ` S ⊆ T"
shows "singular_relboundary p X' T (chain_map p g c)"
proof (-)
(*goal: ‹singular_relboundary p X' T (chain_map p g c)›*)
obtain d and e where d: "singular_chain (Suc p) X d" and e: "singular_chain p (subtopology X S) e" and c: "c = chain_boundary (Suc p) d + e"
(*goal: ‹(⋀d e. ⟦singular_chain (Suc p) X d; singular_chain p (subtopology X S) e; c = chain_boundary (Suc p) d + e⟧ ⟹ thesis) ⟹ thesis›*)
using assms (*‹singular_relboundary p X S c› ‹continuous_map X X' g› ‹g ` S ⊆ T›*) by (auto simp: singular_relboundary (*‹singular_relboundary (?p::nat) (?X::?'a topology) (?S::?'a set) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) = (∃(d::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) e::((nat ⇒ real) ⇒ ?'a) ⇒₀ int. singular_chain (Suc ?p) ?X d ∧ singular_chain ?p (subtopology ?X ?S) e ∧ chain_boundary (Suc ?p) d + e = ?c)›*))
have "singular_chain (Suc p) X' (chain_map (Suc p) g d)"
using assms(2) (*‹continuous_map X X' g›*) d (*‹singular_chain (Suc p) X d›*) singular_chain_chain_map (*‹⟦singular_chain ?p ?X ?c; continuous_map ?X ?X' ?g⟧ ⟹ singular_chain ?p ?X' (chain_map ?p ?g ?c)›*) by blast
moreover have "singular_chain p (subtopology X' T) (chain_map p g e)"
proof (-)
(*goal: ‹singular_chain p (subtopology X' T) (chain_map p g e)›*)
have "∀t. g ` topspace (subtopology t S) ⊆ T"
by (metis assms( (*‹g ` S ⊆ T›*) 3) closure_of_subset_subtopology (*‹subtopology ?X ?S closure_of ?T ⊆ ?S›*) closure_of_topspace (*‹?X closure_of topspace ?X = topspace ?X›*) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) image_mono (*‹?A ⊆ ?B ⟹ ?f ` ?A ⊆ ?f ` ?B›*))
then show "?thesis"
(*goal: ‹singular_chain p (subtopology X' T) (chain_map p g e)›*)
by (meson assms( (*‹continuous_map X X' g›*) 2) continuous_map_from_subtopology (*‹continuous_map ?X ?Y ?f ⟹ continuous_map (subtopology ?X ?S) ?Y ?f›*) continuous_map_in_subtopology (*‹continuous_map ?X (subtopology ?X' ?S) ?f = (continuous_map ?X ?X' ?f ∧ ?f ` topspace ?X ⊆ ?S)›*) e (*‹singular_chain p (subtopology X S) e›*) singular_chain_chain_map (*‹⟦singular_chain ?p ?X ?c; continuous_map ?X ?X' ?g⟧ ⟹ singular_chain ?p ?X' (chain_map ?p ?g ?c)›*))
qed
moreover have "chain_boundary (Suc p) (chain_map (Suc p) g d) + chain_map p g e =
chain_map p g (chain_boundary (Suc p) d + e)"
by (metis One_nat_def (*‹1 = Suc 0›*) chain_boundary_chain_map (*‹singular_chain ?p ?X ?c ⟹ chain_boundary ?p (chain_map ?p ?g ?c) = chain_map (?p - Suc 0) ?g (chain_boundary ?p ?c)›*) chain_map_add (*‹chain_map ?p ?g (?a + ?b) = chain_map ?p ?g ?a + chain_map ?p ?g ?b›*) d (*‹singular_chain (Suc p) X d›*) diff_Suc_1 (*‹Suc ?n - 1 = ?n›*))
ultimately show "?thesis"
(*goal: ‹singular_relboundary (p::nat) (X'::'b topology) (T::'b set) (chain_map p (g::'a ⇒ 'b) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int))›*)
unfolding singular_relboundary
(*goal: ‹∃d e. singular_chain (Suc p) X' d ∧ singular_chain p (subtopology X' T) e ∧ chain_boundary (Suc p) d + e = chain_map p g c›*)
using c (*‹c = chain_boundary (Suc p) d + e›*) by blast
qed
subsection‹Homology of one-point spaces degenerates except for $p = 0$.›
lemma singular_simplex_singleton:
assumes "topspace X = {a}"
shows "singular_simplex p X f ⟷ f = restrict (λx. a) (standard_simplex p)" (is "?lhs = ?rhs")
proof (standard)
(*goals:
1. ‹singular_simplex p X f ⟹ f = (λx∈standard_simplex p. a)›
2. ‹f = (λx∈standard_simplex p. a) ⟹ singular_simplex p X f›*)
assume L: "?lhs" (*‹singular_simplex (p::nat) (X::'a topology) (f::(nat ⇒ real) ⇒ 'a)›*)
then show "?rhs"
proof (-)
(*goal: ‹singular_simplex p X f ⟹ f = (λx∈standard_simplex p. a)›*)
have "continuous_map (subtopology (product_topology (λn. euclideanreal) UNIV) (standard_simplex p)) X f"
using ‹singular_simplex p X f› (*‹singular_simplex (p::nat) (X::'a topology) (f::(nat ⇒ real) ⇒ 'a)›*) singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*) by blast
then have "⋀c. c ∉ standard_simplex p ∨ f c = a"
by (simp add: assms (*‹topspace (X::'a topology) = {a::'a}›*) continuous_map_def (*‹continuous_map (?X::?'a topology) (?Y::?'b topology) (?f::?'a ⇒ ?'b) ≡ ?f ∈ topspace ?X → topspace ?Y ∧ (∀U::?'b set. openin ?Y U ⟶ openin ?X {x::?'a ∈ topspace ?X. ?f x ∈ U})›*) Pi_iff (*‹((?f::?'a ⇒ ?'b) ∈ Pi (?I::?'a set) (?X::?'a ⇒ ?'b set)) = (∀i::?'a∈?I. ?f i ∈ ?X i)›*))
then show "?thesis"
(*goal: ‹f = (λx∈standard_simplex p. a)›*)
by (metis (no_types) L (*‹singular_simplex p X f›*) extensional_restrict (*‹?f ∈ extensional ?A ⟹ restrict ?f ?A = ?f›*) restrict_ext (*‹(⋀x. x ∈ ?A ⟹ ?f x = ?g x) ⟹ restrict ?f ?A = restrict ?g ?A›*) singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*))
qed
next
(*goal: ‹f = (λx∈standard_simplex p. a) ⟹ singular_simplex p X f›*)
assume "?rhs" (*‹(f::(nat ⇒ real) ⇒ 'a) = (λx::nat ⇒ real∈standard_simplex (p::nat). a::'a)›*)
with assms (*‹topspace X = {a}›*) show "?lhs"
by (auto simp: singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*))
qed
lemma singular_chain_singleton:
assumes "topspace X = {a}"
shows "singular_chain p X c ⟷
(∃b. c = frag_cmul b (frag_of(restrict (λx. a) (standard_simplex p))))"
(is "?lhs = ?rhs")
proof (standard)
(*goals:
1. ‹singular_chain p X c ⟹ ∃b. c = frag_cmul b (frag_of (λx∈standard_simplex p. a))›
2. ‹∃b. c = frag_cmul b (frag_of (λx∈standard_simplex p. a)) ⟹ singular_chain p X c›*)
let ?f = "restrict (λx. a) (standard_simplex p)"
assume L: "?lhs" (*‹singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*)
with assms (*‹topspace X = {a}›*) have "Poly_Mapping.keys c ⊆ {?f}"
by (auto simp: singular_chain_def (*‹singular_chain (?p::nat) (?X::?'a::type topology) (?c::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int) ≡ Poly_Mapping.keys ?c ⊆ singular_simplex_set ?p ?X›*) singular_simplex_singleton (*‹topspace (?X::?'a::type topology) = {?a::?'a::type} ⟹ singular_simplex (?p::nat) ?X (?f::(nat ⇒ real) ⇒ ?'a::type) = (?f = (λx::nat ⇒ real∈standard_simplex ?p. ?a))›*))
then consider "Poly_Mapping.keys c = {}" | "Poly_Mapping.keys c = {?f}"
(*goal: ‹⟦Poly_Mapping.keys c = {} ⟹ thesis; Poly_Mapping.keys c = {λx∈standard_simplex p. a} ⟹ thesis⟧ ⟹ thesis›*)
by blast
then show "?rhs"
proof (cases)
(*goals:
1. ‹Poly_Mapping.keys c = {} ⟹ ∃b. c = frag_cmul b (frag_of (λx∈standard_simplex p. a))›
2. ‹Poly_Mapping.keys c = {λx∈standard_simplex p. a} ⟹ ∃b. c = frag_cmul b (frag_of (λx∈standard_simplex p. a))›*)
case 1 (*‹Poly_Mapping.keys c = {}›*)
with L (*‹singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*) show "?thesis"
(*goal: ‹∃b::int. (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) = frag_cmul b (frag_of (λx::nat ⇒ real∈standard_simplex (p::nat). a::'a))›*)
by (metis frag_cmul_zero (*‹frag_cmul 0 ?x = 0›*) keys_eq_empty (*‹(Poly_Mapping.keys ?c = {}) = (?c = 0)›*))
next
(*goal: ‹Poly_Mapping.keys c = {λx∈standard_simplex p. a} ⟹ ∃b. c = frag_cmul b (frag_of (λx∈standard_simplex p. a))›*)
case 2 (*‹Poly_Mapping.keys c = {λx∈standard_simplex p. a}›*)
then have "∃b. frag_extend frag_of c = frag_cmul b (frag_of (λx∈standard_simplex p. a))"
by (force simp: frag_extend_def (*‹frag_extend ?b ?x ≡ ∑i∈Poly_Mapping.keys ?x. frag_cmul (poly_mapping.lookup ?x i) (?b i)›*))
then show "?thesis"
(*goal: ‹∃b. c = frag_cmul b (frag_of (λx∈standard_simplex p. a))›*)
by (metis frag_expansion (*‹(?a::?'a ⇒₀ int) = frag_extend frag_of ?a›*))
qed
next
(*goal: ‹∃b. c = frag_cmul b (frag_of (λx∈standard_simplex p. a)) ⟹ singular_chain p X c›*)
assume "?rhs" (*‹∃b::int. (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) = frag_cmul b (frag_of (λx::nat ⇒ real∈standard_simplex (p::nat). a::'a))›*)
with assms (*‹topspace X = {a}›*) show "?lhs"
by (auto simp: singular_chain_def (*‹singular_chain (?p::nat) (?X::?'a::type topology) (?c::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int) ≡ Poly_Mapping.keys ?c ⊆ singular_simplex_set ?p ?X›*) singular_simplex_singleton (*‹topspace (?X::?'a::type topology) = {?a::?'a::type} ⟹ singular_simplex (?p::nat) ?X (?f::(nat ⇒ real) ⇒ ?'a::type) = (?f = (λx::nat ⇒ real∈standard_simplex ?p. ?a))›*))
qed
lemma chain_boundary_of_singleton:
assumes tX: "topspace X = {a}" and sc: "singular_chain p X c"
shows "chain_boundary p c =
(if p = 0 ∨ odd p then 0
else frag_extend (λf. frag_of(restrict (λx. a) (standard_simplex (p -1)))) c)"
(is "?lhs = ?rhs")
proof (cases "p = 0")
(*goals:
1. ‹(p::nat) = (0::nat) ⟹ chain_boundary p (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) = (if p = (0::nat) ∨ odd p then 0::((nat ⇒ real) ⇒ 'a) ⇒₀ int else frag_extend (λf::(nat ⇒ real) ⇒ 'a. frag_of (λx::nat ⇒ real∈standard_simplex (p - (1::nat)). a::'a)) c)›
2. ‹(p::nat) ≠ (0::nat) ⟹ chain_boundary p (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) = (if p = (0::nat) ∨ odd p then 0::((nat ⇒ real) ⇒ 'a) ⇒₀ int else frag_extend (λf::(nat ⇒ real) ⇒ 'a. frag_of (λx::nat ⇒ real∈standard_simplex (p - (1::nat)). a::'a)) c)›*)
case False (*‹p ≠ 0›*)
have "?lhs = frag_extend (λf. if odd p then 0 else frag_of(restrict (λx. a) (standard_simplex (p -1)))) c"
apply (simp only: chain_boundary_def (*‹chain_boundary ?p ?c ≡ if ?p = 0 then 0 else frag_extend (λf. ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k f))) ?c›*) False (*‹p ≠ 0›*) if_False (*‹(if False then ?x else ?y) = ?y›*))
(*goal: ‹chain_boundary (p::nat) (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) = frag_extend (λf::(nat ⇒ real) ⇒ 'a::type. if odd p then 0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int else frag_of (λx::nat ⇒ real∈standard_simplex (p - (1::nat)). a::'a::type)) c›*)
proof (rule frag_extend_eq (*‹(⋀f::?'a. f ∈ Poly_Mapping.keys (?c::?'a ⇒₀ int) ⟹ (?g::?'a ⇒ ?'b ⇒₀ int) f = (?h::?'a ⇒ ?'b ⇒₀ int) f) ⟹ frag_extend ?g ?c = frag_extend ?h ?c›*))
(*goal: ‹⋀f. f ∈ Poly_Mapping.keys c ⟹ (∑k≤p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k f))) = (if odd p then 0 else frag_of (λx∈standard_simplex (p - 1). a))›*)
fix f
assume "f ∈ Poly_Mapping.keys c" (*‹(f::(nat ⇒ real) ⇒ 'a) ∈ Poly_Mapping.keys (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*)
with assms (*‹topspace X = {a}› ‹singular_chain p X c›*) have "singular_simplex p X f"
by (auto simp: singular_chain_def (*‹singular_chain ?p ?X ?c ≡ Poly_Mapping.keys ?c ⊆ singular_simplex_set ?p ?X›*))
then have "*": "⋀k. k ≤ p ⟹ singular_face p k f = (λx∈standard_simplex (p -1). a)"
using False (*‹(p::nat) ≠ (0::nat)›*) singular_simplex_singular_face (*‹⟦singular_simplex (?p::nat) (?X::?'a topology) (?f::(nat ⇒ real) ⇒ ?'a); (1::nat) ≤ ?p; (?k::nat) ≤ ?p⟧ ⟹ singular_simplex (?p - Suc (0::nat)) ?X (singular_face ?p ?k ?f)›*) by (fastforce simp flip: singular_simplex_singleton [OF tX] (*‹singular_simplex ?p X ?f = (?f = (λx∈standard_simplex ?p. a))›*))
define c where "c ≡ frag_of (λx∈standard_simplex (p -1). a)"
have "(∑k≤p. frag_cmul ((-1) ^ k) (frag_of (singular_face p k f)))
= (∑k≤p. frag_cmul ((-1) ^ k) c)"
by (auto simp: c_def (*‹c ≡ frag_of (λx∈standard_simplex (p - 1). a)›*) * (*‹?k ≤ p ⟹ singular_face p ?k f = (λx∈standard_simplex (p - 1). a)›*) intro: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
also (*calculation: ‹(∑k≤p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k f))) = (∑k≤p. frag_cmul ((- 1) ^ k) c)›*) have "… = (if odd p then 0 else c)"
apply (induction p)
(*goals:
1. ‹(∑k≤0. frag_cmul ((- 1) ^ k) c) = (if odd 0 then 0 else c)›
2. ‹⋀p. (∑k≤p. frag_cmul ((- 1) ^ k) c) = (if odd p then 0 else c) ⟹ (∑k≤Suc p. frag_cmul ((- 1) ^ k) c) = (if odd (Suc p) then 0 else c)›
discuss goal 1*)
apply ((auto simp: c_def (*‹c ≡ frag_of (λx∈standard_simplex (p - 1). a)›*) restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*))[1])
(*discuss goal 2*)
apply ((auto simp: c_def (*‹c ≡ frag_of (λx∈standard_simplex (p - 1). a)›*) restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*))[1])
(*proven 2 subgoals*) .
finally (*calculation: ‹(∑k≤p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k f))) = (if odd p then 0 else c)›*) show "(∑k≤p. frag_cmul ((-1) ^ k) (frag_of (singular_face p k f)))
= (if odd p then 0 else frag_of (λx∈standard_simplex (p -1). a))"
unfolding c_def
(*goal: ‹(∑k≤p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k f))) = (if odd p then 0 else frag_of (λx∈standard_simplex (p - 1). a))›*) .
qed
also (*calculation: ‹chain_boundary p c = frag_extend (λf. if odd p then 0 else frag_of (λx∈standard_simplex (p - 1). a)) c›*) have "… = ?rhs"
by (auto simp: False (*‹p ≠ 0›*) frag_extend_eq_0 (*‹(⋀x. x ∈ Poly_Mapping.keys ?c ⟹ ?f x = 0) ⟹ frag_extend ?f ?c = 0›*))
finally (*calculation: ‹chain_boundary p c = (if p = 0 ∨ odd p then 0 else frag_extend (λf. frag_of (λx∈standard_simplex (p - 1). a)) c)›*) show "?thesis"
(*goal: ‹chain_boundary p c = (if p = 0 ∨ odd p then 0 else frag_extend (λf. frag_of (λx∈standard_simplex (p - 1). a)) c)›*) .
qed (simp add: chain_boundary_def (*‹chain_boundary ?p ?c ≡ if ?p = 0 then 0 else frag_extend (λf. ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k f))) ?c›*))
(*solved the remaining goal: ‹p = 0 ⟹ chain_boundary p c = (if p = 0 ∨ odd p then 0 else frag_extend (λf. frag_of (λx∈standard_simplex (p - 1). a)) c)›*)
lemma singular_cycle_singleton:
assumes "topspace X = {a}"
shows "singular_relcycle p X {} c ⟷ singular_chain p X c ∧ (p = 0 ∨ odd p ∨ c = 0)"
proof (-)
(*goal: ‹singular_relcycle p X {} c = (singular_chain p X c ∧ (p = 0 ∨ odd p ∨ c = 0))›*)
have "c = 0" if "singular_chain p X c" and "chain_boundary p c = 0" and "even p" and "p ≠ 0"
using that (*‹singular_chain p X c› ‹chain_boundary p c = 0› ‹even (p::nat)› ‹(p::nat) ≠ (0::nat)›*) assms (*‹topspace X = {a}›*) singular_chain_singleton[of X a p c] (*‹topspace X = {a} ⟹ singular_chain p X c = (∃b. c = frag_cmul b (frag_of (λx∈standard_simplex p. a)))›*) chain_boundary_of_singleton[OF assms] (*‹singular_chain (?p::nat) (X::'a topology) (?c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⟹ chain_boundary ?p ?c = (if ?p = (0::nat) ∨ odd ?p then 0::((nat ⇒ real) ⇒ 'a) ⇒₀ int else frag_extend (λf::(nat ⇒ real) ⇒ 'a. frag_of (λx::nat ⇒ real∈standard_simplex (?p - (1::nat)). a::'a)) ?c)›*) by (auto simp: frag_extend_cmul (*‹frag_extend ?f (frag_cmul ?c ?x) = frag_cmul ?c (frag_extend ?f ?x)›*))
moreover have "chain_boundary p c = 0" if sc: "singular_chain p X c" and "odd p"
by (simp add: chain_boundary_of_singleton [OF assms sc] (*‹chain_boundary p c = (if p = 0 ∨ odd p then 0 else frag_extend (λf. frag_of (λx∈standard_simplex (p - 1). a)) c)›*) that (*‹singular_chain p X c› ‹odd p›*))
moreover have "chain_boundary 0 c = 0" if "singular_chain 0 X c" and "p = 0"
by (simp add: chain_boundary_def (*‹chain_boundary ?p ?c ≡ if ?p = 0 then 0 else frag_extend (λf. ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k f))) ?c›*))
ultimately show "?thesis"
(*goal: ‹singular_relcycle p X {} c = (singular_chain p X c ∧ (p = 0 ∨ odd p ∨ c = 0))›*)
using assms (*‹topspace X = {a}›*) by (auto simp: singular_cycle (*‹singular_relcycle ?p ?X {} ?c = (singular_chain ?p ?X ?c ∧ chain_boundary ?p ?c = 0)›*))
qed
lemma singular_boundary_singleton:
assumes "topspace X = {a}"
shows "singular_relboundary p X {} c ⟷ singular_chain p X c ∧ (odd p ∨ c = 0)"
proof (cases "singular_chain p X c")
(*goals:
1. ‹singular_chain p X c ⟹ singular_relboundary p X {} c = (singular_chain p X c ∧ (odd p ∨ c = 0))›
2. ‹¬ singular_chain p X c ⟹ singular_relboundary p X {} c = (singular_chain p X c ∧ (odd p ∨ c = 0))›*)
case True (*‹singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*)
have "∃d. singular_chain (Suc p) X d ∧ chain_boundary (Suc p) d = c" if "singular_chain p X c" and "odd p"
proof (-)
(*goal: ‹∃d. singular_chain (Suc p) X d ∧ chain_boundary (Suc p) d = c›*)
obtain b where b: "c = frag_cmul b (frag_of(restrict (λx. a) (standard_simplex p)))"
(*goal: ‹(⋀b. c = frag_cmul b (frag_of (λx∈standard_simplex p. a)) ⟹ thesis) ⟹ thesis›*)
by (metis True (*‹singular_chain p X c›*) assms (*‹topspace X = {a}›*) singular_chain_singleton (*‹topspace ?X = {?a} ⟹ singular_chain ?p ?X ?c = (∃b. ?c = frag_cmul b (frag_of (λx∈standard_simplex ?p. ?a)))›*))
let ?d = "frag_cmul b (frag_of (λx∈standard_simplex (Suc p). a))"
have scd: "singular_chain (Suc p) X ?d"
by (metis assms (*‹topspace X = {a}›*) singular_chain_singleton (*‹topspace ?X = {?a} ⟹ singular_chain ?p ?X ?c = (∃b. ?c = frag_cmul b (frag_of (λx∈standard_simplex ?p. ?a)))›*))
moreover have "chain_boundary (Suc p) ?d = c"
by (simp add: assms (*‹topspace X = {a}›*) scd (*‹singular_chain (Suc p) X (frag_cmul b (frag_of (λx∈standard_simplex (Suc p). a)))›*) chain_boundary_of_singleton [of X a "Suc p"] (*‹⟦topspace X = {a}; singular_chain (Suc p) X ?c⟧ ⟹ chain_boundary (Suc p) ?c = (if Suc p = 0 ∨ odd (Suc p) then 0 else frag_extend (λf. frag_of (λx∈standard_simplex (Suc p - 1). a)) ?c)›*) b (*‹c = frag_cmul b (frag_of (λx∈standard_simplex p. a))›*) frag_extend_cmul (*‹frag_extend ?f (frag_cmul ?c ?x) = frag_cmul ?c (frag_extend ?f ?x)›*) ‹odd p›)
ultimately show "?thesis"
(*goal: ‹∃d. singular_chain (Suc p) X d ∧ chain_boundary (Suc p) d = c›*)
by metis
qed
with True (*‹singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*) assms (*‹topspace X = {a}›*) show "?thesis"
(*goal: ‹singular_relboundary p X {} c = (singular_chain p X c ∧ (odd p ∨ c = 0))›*)
by (auto simp: singular_boundary (*‹singular_relboundary ?p ?X {} ?c = (∃d. singular_chain (Suc ?p) ?X d ∧ chain_boundary (Suc ?p) d = ?c)›*) chain_boundary_of_singleton (*‹⟦topspace ?X = {?a}; singular_chain ?p ?X ?c⟧ ⟹ chain_boundary ?p ?c = (if ?p = 0 ∨ odd ?p then 0 else frag_extend (λf. frag_of (λx∈standard_simplex (?p - 1). ?a)) ?c)›*))
next
(*goal: ‹¬ singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⟹ singular_relboundary p X {} c = (singular_chain p X c ∧ (odd p ∨ c = (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int)))›*)
case False (*‹¬ singular_chain p X c›*)
with assms (*‹topspace X = {a}›*) singular_boundary_imp_chain (*‹singular_relboundary ?p ?X {} ?c ⟹ singular_chain ?p ?X ?c›*) show "?thesis"
(*goal: ‹singular_relboundary (p::nat) (X::'a topology) {} (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) = (singular_chain p X c ∧ (odd p ∨ c = (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int)))›*)
by metis
qed
lemma singular_boundary_eq_cycle_singleton:
assumes "topspace X = {a}" "1 ≤ p"
shows "singular_relboundary p X {} c ⟷ singular_relcycle p X {} c" (is "?lhs = ?rhs")
proof (standard)
(*goals:
1. ‹singular_relboundary p X {} c ⟹ singular_relcycle p X {} c›
2. ‹singular_relcycle p X {} c ⟹ singular_relboundary p X {} c›*)
show "?lhs ⟹ ?rhs"
by (simp add: singular_relboundary_imp_relcycle (*‹singular_relboundary (?p::nat) (?X::?'a topology) (?S::?'a set) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ⟹ singular_relcycle ?p ?X ?S ?c›*))
show "?rhs ⟹ ?lhs"
by (metis assms (*‹topspace (X::'a topology) = {a::'a}› ‹(1::nat) ≤ (p::nat)›*) not_one_le_zero (*‹¬ (1::?'a) ≤ (0::?'a)›*) singular_boundary_singleton (*‹topspace (?X::?'a topology) = {?a::?'a} ⟹ singular_relboundary (?p::nat) ?X {} (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) = (singular_chain ?p ?X ?c ∧ (odd ?p ∨ ?c = (0::((nat ⇒ real) ⇒ ?'a) ⇒₀ int)))›*) singular_cycle_singleton (*‹topspace (?X::?'a topology) = {?a::?'a} ⟹ singular_relcycle (?p::nat) ?X {} (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) = (singular_chain ?p ?X ?c ∧ (?p = (0::nat) ∨ odd ?p ∨ ?c = (0::((nat ⇒ real) ⇒ ?'a) ⇒₀ int)))›*))
qed
lemma singular_boundary_set_eq_cycle_singleton:
assumes "topspace X = {a}" "1 ≤ p"
shows "singular_relboundary_set p X {} = singular_relcycle_set p X {}"
using singular_boundary_eq_cycle_singleton[OF assms] (*‹singular_relboundary p X {} ?c = singular_relcycle p X {} ?c›*) by blast
subsection‹Simplicial chains›
text‹Simplicial chains, effectively those resulting from linear maps.
We still allow the map to be singular, so the name is questionable.
These are intended as building-blocks for singular subdivision, rather than as a axis
for 1 simplicial homology.›
definition oriented_simplex
where "oriented_simplex p l ≡ (λx∈standard_simplex p. λi. (∑j≤p. l j i * x j))"
definition simplicial_simplex
where
"simplicial_simplex p S f ≡
singular_simplex p (subtopology (powertop_real UNIV) S) f ∧
(∃l. f = oriented_simplex p l)"
lemma simplicial_simplex:
"simplicial_simplex p S f ⟷ f ` (standard_simplex p) ⊆ S ∧ (∃l. f = oriented_simplex p l)"
(is "?lhs = ?rhs")
proof (standard)
(*goals:
1. ‹simplicial_simplex p S f ⟹ f ` standard_simplex p ⊆ S ∧ (∃l. f = oriented_simplex p l)›
2. ‹f ` standard_simplex p ⊆ S ∧ (∃l. f = oriented_simplex p l) ⟹ simplicial_simplex p S f›*)
assume R: "?rhs" (*‹(f::(nat ⇒ real) ⇒ 'a ⇒ real) ` standard_simplex (p::nat) ⊆ (S::('a ⇒ real) set) ∧ (∃l::nat ⇒ 'a ⇒ real. f = oriented_simplex p l)›*)
have "continuous_map (subtopology (powertop_real UNIV) (standard_simplex p))
(powertop_real UNIV) (λx i. ∑j≤p. l j i * x j)" for l :: " nat ⇒ 'a ⇒ real"
unfolding continuous_map_componentwise
(*goal: ‹(λ(x::nat ⇒ real) i::'a::type. ∑j::nat≤p::nat. (l::nat ⇒ 'a::type ⇒ real) j i * x j) ` topspace (subtopology (powertop_real UNIV) (standard_simplex p)) ⊆ extensional UNIV ∧ (∀k::'a::type∈UNIV. continuous_map (subtopology (powertop_real UNIV) (standard_simplex p)) euclideanreal (λx::nat ⇒ real. ∑j::nat≤p. l j k * x j))›*)
by (force intro: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 190 facts*) continuous_map_from_subtopology (*‹continuous_map ?X ?Y ?f ⟹ continuous_map (subtopology ?X ?S) ?Y ?f›*) continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*))
with R (*‹f ` standard_simplex p ⊆ S ∧ (∃l. f = oriented_simplex p l)›*) show "?lhs"
unfolding simplicial_simplex_def singular_simplex_subtopology
(*goal: ‹(singular_simplex (p::nat) (powertop_real UNIV) (f::(nat ⇒ real) ⇒ 'a ⇒ real) ∧ f ` standard_simplex p ⊆ (S::('a ⇒ real) set)) ∧ (∃l::nat ⇒ 'a ⇒ real. f = oriented_simplex p l)›*)
by (auto simp add: singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*) oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*))
qed (simp add: simplicial_simplex_def (*‹simplicial_simplex ?p ?S ?f ≡ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f ∧ (∃l. ?f = oriented_simplex ?p l)›*) singular_simplex_subtopology (*‹singular_simplex ?p (subtopology ?X ?S) ?f = (singular_simplex ?p ?X ?f ∧ ?f ` standard_simplex ?p ⊆ ?S)›*))
(*solved the remaining goal: ‹simplicial_simplex p S f ⟹ f ` standard_simplex p ⊆ S ∧ (∃l. f = oriented_simplex p l)›*)
lemma simplicial_simplex_empty [simp]: "¬ simplicial_simplex p {} f"
by (simp add: nonempty_standard_simplex (*‹standard_simplex ?p ≠ {}›*) simplicial_simplex (*‹simplicial_simplex ?p ?S ?f = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l. ?f = oriented_simplex ?p l))›*))
definition simplicial_chain
where "simplicial_chain p S c ≡ Poly_Mapping.keys c ⊆ Collect (simplicial_simplex p S)"
lemma simplicial_chain_0 [simp]: "simplicial_chain p S 0"
by (simp add: simplicial_chain_def (*‹simplicial_chain (?p::nat) (?S::(?'a ⇒ real) set) (?c::((nat ⇒ real) ⇒ ?'a ⇒ real) ⇒₀ ?'b) ≡ Poly_Mapping.keys ?c ⊆ Collect (simplicial_simplex ?p ?S)›*))
lemma simplicial_chain_of [simp]:
"simplicial_chain p S (frag_of c) ⟷ simplicial_simplex p S c"
by (simp add: simplicial_chain_def (*‹simplicial_chain ?p ?S ?c ≡ Poly_Mapping.keys ?c ⊆ Collect (simplicial_simplex ?p ?S)›*))
lemma simplicial_chain_cmul:
"simplicial_chain p S c ⟹ simplicial_chain p S (frag_cmul a c)"
by (auto simp: simplicial_chain_def (*‹simplicial_chain (?p::nat) (?S::(?'a::type ⇒ real) set) (?c::((nat ⇒ real) ⇒ ?'a::type ⇒ real) ⇒₀ ?'b::zero) ≡ Poly_Mapping.keys ?c ⊆ Collect (simplicial_simplex ?p ?S)›*))
lemma simplicial_chain_diff:
"⟦simplicial_chain p S c1; simplicial_chain p S c2⟧ ⟹ simplicial_chain p S (c1 - c2)"
unfolding simplicial_chain_def
(*goal: ‹⟦Poly_Mapping.keys c1 ⊆ Collect (simplicial_simplex p S); Poly_Mapping.keys c2 ⊆ Collect (simplicial_simplex p S)⟧ ⟹ Poly_Mapping.keys (c1 - c2) ⊆ Collect (simplicial_simplex p S)›*)
by (meson UnE (*‹⟦(?c::?'a::type) ∈ (?A::?'a::type set) ∪ (?B::?'a::type set); ?c ∈ ?A ⟹ ?P::bool; ?c ∈ ?B ⟹ ?P⟧ ⟹ ?P›*) keys_diff (*‹Poly_Mapping.keys ((?a::?'a::type ⇒₀ ?'b::cancel_comm_monoid_add) - (?b::?'a::type ⇒₀ ?'b::cancel_comm_monoid_add)) ⊆ Poly_Mapping.keys ?a ∪ Poly_Mapping.keys ?b›*) subset_iff (*‹((?A::?'a::type set) ⊆ (?B::?'a::type set)) = (∀t::?'a::type. t ∈ ?A ⟶ t ∈ ?B)›*))
lemma simplicial_chain_sum:
"(⋀i. i ∈ I ⟹ simplicial_chain p S (f i)) ⟹ simplicial_chain p S (sum f I)"
unfolding simplicial_chain_def
(*goal: ‹(⋀i. i ∈ I ⟹ Poly_Mapping.keys (f i) ⊆ Collect (simplicial_simplex p S)) ⟹ Poly_Mapping.keys (sum f I) ⊆ Collect (simplicial_simplex p S)›*)
using order_trans[OF keys_sum [ of f I ]] (*‹(⋃i∈I. Poly_Mapping.keys (f i)) ⊆ ?z ⟹ Poly_Mapping.keys (sum f I) ⊆ ?z›*) by (simp add: UN_least (*‹(⋀x. x ∈ ?A ⟹ ?B x ⊆ ?C) ⟹ ⋃ (?B ` ?A) ⊆ ?C›*))
lemma simplicial_simplex_oriented_simplex:
"simplicial_simplex p S (oriented_simplex p l)
⟷ ((λx i. ∑j≤p. l j i * x j) ` standard_simplex p ⊆ S)"
by (auto simp: simplicial_simplex (*‹simplicial_simplex ?p ?S ?f = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l. ?f = oriented_simplex ?p l))›*) oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*))
lemma simplicial_imp_singular_simplex:
"simplicial_simplex p S f
⟹ singular_simplex p (subtopology (powertop_real UNIV) S) f"
by (simp add: simplicial_simplex_def (*‹simplicial_simplex ?p ?S ?f ≡ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f ∧ (∃l. ?f = oriented_simplex ?p l)›*))
lemma simplicial_imp_singular_chain:
"simplicial_chain p S c
⟹ singular_chain p (subtopology (powertop_real UNIV) S) c"
unfolding simplicial_chain_def singular_chain_def
(*goal: ‹Poly_Mapping.keys c ⊆ Collect (simplicial_simplex p S) ⟹ Poly_Mapping.keys c ⊆ singular_simplex_set p (subtopology (powertop_real UNIV) S)›*)
by (auto intro: simplicial_imp_singular_simplex (*‹simplicial_simplex (?p::nat) (?S::(?'a ⇒ real) set) (?f::(nat ⇒ real) ⇒ ?'a ⇒ real) ⟹ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f›*))
lemma oriented_simplex_eq:
"oriented_simplex p l = oriented_simplex p l' ⟷ (∀i. i ≤ p ⟶ l i = l' i)"
(is "?lhs = ?rhs")
proof (standard)
(*goals:
1. ‹oriented_simplex p l = oriented_simplex p l' ⟹ ∀i≤p. l i = l' i›
2. ‹∀i≤p. l i = l' i ⟹ oriented_simplex p l = oriented_simplex p l'›*)
assume L: "?lhs" (*‹oriented_simplex (p::nat) (l::nat ⇒ 'a ⇒ real) = oriented_simplex p (l'::nat ⇒ 'a ⇒ real)›*)
show "?rhs"
proof (clarify)
(*goal: ‹⋀i. i ≤ p ⟹ l i = l' i›*)
fix i
assume "i ≤ p" (*‹(i::nat) ≤ (p::nat)›*)
let ?fi = "(λj. if j = i then 1 else 0)"
have "(∑j≤p. l j k * ?fi j) = (∑j≤p. l' j k * ?fi j)" for k
using L (*‹oriented_simplex p l = oriented_simplex p l'›*) ‹i ≤ p› (*‹(i::nat) ≤ (p::nat)›*) by (simp add: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
with ‹i ≤ p› (*‹i ≤ p›*) show "l i = l' i"
by (simp add: if_distrib (*‹?f (if ?c then ?x else ?y) = (if ?c then ?f ?x else ?f ?y)›*) ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
qed
qed (auto simp: oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*))
(*solved the remaining goal: ‹∀i≤p. l i = l' i ⟹ oriented_simplex p l = oriented_simplex p l'›*)
lemma singular_face_oriented_simplex:
assumes "1 ≤ p" "k ≤ p"
shows "singular_face p k (oriented_simplex p l) =
oriented_simplex (p -1) (λj. if j < k then l j else l (Suc j))"
proof (-)
(*goal: ‹singular_face p k (oriented_simplex p l) = oriented_simplex (p - 1) (λj. if j < k then l j else l (Suc j))›*)
have "(∑j≤p. l j i * simplical_face k x j)
= (∑j≤p - Suc 0. (if j < k then l j else l (Suc j)) i * x j)" if "x ∈ standard_simplex (p - Suc 0)" for i and x
proof (-)
(*goal: ‹(∑j≤p. l j i * simplical_face k x j) = (∑j≤p - Suc 0. (if j < k then l j else l (Suc j)) i * x j)›*)
show "?thesis"
(*goal: ‹(∑j::nat≤p::nat. (l::nat ⇒ 'a ⇒ real) j (i::'a) * simplical_face (k::nat) (x::nat ⇒ real) j) = (∑j::nat≤p - Suc (0::nat). (if j < k then l j else l (Suc j)) i * x j)›*)
unfolding simplical_face_def
(*goal: ‹(∑j≤p. l j i * (if j < k then x j else if j = k then 0 else x (j - 1))) = (∑j≤p - Suc 0. (if j < k then l j else l (Suc j)) i * x j)›*)
using sum.zero_middle[OF assms, where 'a = real, symmetric] (*‹(∑j≤p - Suc 0. if j < k then ?g j else ?h j) = (∑j≤p. if j < k then ?g j else if j = k then 0 else ?h (j - Suc 0))›*) by (simp add: if_distrib [of "λx. _ * x"] (*‹?uu5 * (if ?c then ?x else ?y) = (if ?c then ?uu5 * ?x else ?uu5 * ?y)›*) if_distrib [of "λf. f i * _"] (*‹(if ?c then ?x else ?y) i * ?uu5 = (if ?c then ?x i * ?uu5 else ?y i * ?uu5)›*) atLeast0AtMost (*‹{0..?n} = {..?n}›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
qed
then show "?thesis"
(*goal: ‹singular_face p k (oriented_simplex p l) = oriented_simplex (p - 1) (λj. if j < k then l j else l (Suc j))›*)
using simplical_face_in_standard_simplex (*‹⟦(1::nat) ≤ (?p::nat); (?k::nat) ≤ ?p; (?x::nat ⇒ real) ∈ standard_simplex (?p - Suc (0::nat))⟧ ⟹ simplical_face ?k ?x ∈ standard_simplex ?p›*) assms (*‹1 ≤ p› ‹(k::nat) ≤ (p::nat)›*) by (auto simp: singular_face_def (*‹singular_face ?p ?k ?f ≡ restrict (?f ∘ simplical_face ?k) (standard_simplex (?p - Suc 0))›*) oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*))
qed
lemma simplicial_simplex_singular_face:
fixes f :: "(nat ⇒ real) ⇒ nat ⇒ real"
assumes ss: "simplicial_simplex p S f" and p: "1 ≤ p" "k ≤ p"
shows "simplicial_simplex (p - Suc 0) S (singular_face p k f)"
proof (-)
(*goal: ‹simplicial_simplex (p - Suc 0) S (singular_face p k f)›*)
let ?X = "subtopology (powertop_real UNIV) S"
obtain m where l: "singular_simplex p ?X (oriented_simplex p m)" and feq: "f = oriented_simplex p m"
(*goal: ‹(⋀m. ⟦singular_simplex p (subtopology (powertop_real UNIV) S) (oriented_simplex p m); f = oriented_simplex p m⟧ ⟹ thesis) ⟹ thesis›*)
using assms (*‹simplicial_simplex p S f› ‹1 ≤ p› ‹k ≤ p›*) by (force simp: simplicial_simplex_def (*‹simplicial_simplex ?p ?S ?f ≡ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f ∧ (∃l. ?f = oriented_simplex ?p l)›*))
moreover have "singular_face p k f = oriented_simplex (p - Suc 0) (λi. if i < k then m i else m (Suc i))"
using feq (*‹(f::(nat ⇒ real) ⇒ nat ⇒ real) = oriented_simplex (p::nat) (m::nat ⇒ nat ⇒ real)›*) p (*‹1 ≤ p› ‹k ≤ p›*) singular_face_oriented_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p⟧ ⟹ singular_face ?p ?k (oriented_simplex ?p ?l) = oriented_simplex (?p - 1) (λj. if j < ?k then ?l j else ?l (Suc j))›*) by auto
ultimately show "?thesis"
(*goal: ‹simplicial_simplex (p - Suc 0) S (singular_face p k f)›*)
using p (*‹1 ≤ p› ‹k ≤ p›*) simplicial_simplex_def (*‹simplicial_simplex ?p ?S ?f ≡ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f ∧ (∃l. ?f = oriented_simplex ?p l)›*) singular_simplex_singular_face (*‹⟦singular_simplex ?p ?X ?f; 1 ≤ ?p; ?k ≤ ?p⟧ ⟹ singular_simplex (?p - Suc 0) ?X (singular_face ?p ?k ?f)›*) by blast
qed
lemma simplicial_chain_boundary:
"simplicial_chain p S c ⟹ simplicial_chain (p -1) S (chain_boundary p c)"
unfolding simplicial_chain_def
(*goal: ‹Poly_Mapping.keys c ⊆ Collect (simplicial_simplex p S) ⟹ Poly_Mapping.keys (chain_boundary p c) ⊆ Collect (simplicial_simplex (p - 1) S)›*)
proof (induction rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹Poly_Mapping.keys (chain_boundary (p::nat) (0::((nat ⇒ real) ⇒ 'a ⇒ real) ⇒₀ int)) ⊆ {a::(nat ⇒ real) ⇒ 'a ⇒ real. simplicial_simplex (p - (1::nat)) (S::('a ⇒ real) set) a}›
2. ‹⋀x::(nat ⇒ real) ⇒ 'a ⇒ real. x ∈ Collect (simplicial_simplex (p::nat) (S::('a ⇒ real) set)) ⟹ Poly_Mapping.keys (chain_boundary p (frag_of x)) ⊆ {a::(nat ⇒ real) ⇒ 'a ⇒ real. simplicial_simplex (p - (1::nat)) S a}›
3. ‹⋀(a::((nat ⇒ real) ⇒ 'a ⇒ real) ⇒₀ int) b::((nat ⇒ real) ⇒ 'a ⇒ real) ⇒₀ int. ⟦Poly_Mapping.keys (chain_boundary (p::nat) a) ⊆ {a::(nat ⇒ real) ⇒ 'a ⇒ real. simplicial_simplex (p - (1::nat)) (S::('a ⇒ real) set) a}; Poly_Mapping.keys (chain_boundary p b) ⊆ {a::(nat ⇒ real) ⇒ 'a ⇒ real. simplicial_simplex (p - (1::nat)) S a}⟧ ⟹ Poly_Mapping.keys (chain_boundary p (a - b)) ⊆ {a::(nat ⇒ real) ⇒ 'a ⇒ real. simplicial_simplex (p - (1::nat)) S a}›*)
case (one f) (*‹f ∈ Collect (simplicial_simplex p S)›*)
then have "simplicial_simplex p S f"
by simp
have "simplicial_chain (p - Suc 0) S (frag_of (singular_face p i f))" if "0 < p" "i ≤ p" for i
using that (*‹0 < p› ‹i ≤ p›*) one (*‹f ∈ Collect (simplicial_simplex p S)›*) by (force simp: simplicial_simplex_def (*‹simplicial_simplex ?p ?S ?f ≡ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f ∧ (∃l. ?f = oriented_simplex ?p l)›*) singular_simplex_singular_face (*‹⟦singular_simplex ?p ?X ?f; 1 ≤ ?p; ?k ≤ ?p⟧ ⟹ singular_simplex (?p - Suc 0) ?X (singular_face ?p ?k ?f)›*) singular_face_oriented_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p⟧ ⟹ singular_face ?p ?k (oriented_simplex ?p ?l) = oriented_simplex (?p - 1) (λj. if j < ?k then ?l j else ?l (Suc j))›*))
then have "simplicial_chain (p - Suc 0) S (chain_boundary p (frag_of f))"
unfolding chain_boundary_def frag_extend_of
(*goal: ‹simplicial_chain (p - Suc 0) S (if p = 0 then 0 else ∑k≤p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k f)))›*)
by (auto intro!: simplicial_chain_cmul (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain ?p ?S (frag_cmul ?a ?c)›*) simplicial_chain_sum (*‹(⋀i. i ∈ ?I ⟹ simplicial_chain ?p ?S (?f i)) ⟹ simplicial_chain ?p ?S (sum ?f ?I)›*))
then show "?case"
(*goal: ‹Poly_Mapping.keys (chain_boundary p (frag_of f)) ⊆ {a. simplicial_simplex (p - 1) S a}›*)
by (simp add: simplicial_chain_def [symmetric] (*‹Poly_Mapping.keys ?c ⊆ Collect (simplicial_simplex ?p ?S) ≡ simplicial_chain ?p ?S ?c›*))
next
(*goals:
1. ‹Poly_Mapping.keys (chain_boundary p 0) ⊆ {a. simplicial_simplex (p - 1) S a}›
2. ‹⋀a b. ⟦Poly_Mapping.keys (chain_boundary p a) ⊆ {a. simplicial_simplex (p - 1) S a}; Poly_Mapping.keys (chain_boundary p b) ⊆ {a. simplicial_simplex (p - 1) S a}⟧ ⟹ Poly_Mapping.keys (chain_boundary p (a - b)) ⊆ {a. simplicial_simplex (p - 1) S a}›*)
case (diff a b) (*‹Poly_Mapping.keys (chain_boundary (p::nat) (a::((nat ⇒ real) ⇒ 'a ⇒ real) ⇒₀ int)) ⊆ {a::(nat ⇒ real) ⇒ 'a ⇒ real. simplicial_simplex (p - (1::nat)) (S::('a ⇒ real) set) a}› ‹Poly_Mapping.keys (chain_boundary p b) ⊆ {a. simplicial_simplex (p - 1) S a}›*)
then show "?case"
(*goal: ‹Poly_Mapping.keys (chain_boundary p (a - b)) ⊆ {a. simplicial_simplex (p - 1) S a}›*)
by (metis chain_boundary_diff (*‹chain_boundary ?p (?a - ?b) = chain_boundary ?p ?a - chain_boundary ?p ?b›*) simplicial_chain_def (*‹simplicial_chain ?p ?S ?c ≡ Poly_Mapping.keys ?c ⊆ Collect (simplicial_simplex ?p ?S)›*) simplicial_chain_diff (*‹⟦simplicial_chain ?p ?S ?c1.0; simplicial_chain ?p ?S ?c2.0⟧ ⟹ simplicial_chain ?p ?S (?c1.0 - ?c2.0)›*))
qed (auto)
(*solved the remaining goal: ‹Poly_Mapping.keys (chain_boundary p 0) ⊆ {a. simplicial_simplex (p - 1) S a}›*)
subsection‹The cone construction on simplicial simplices.›
consts simplex_cone :: "[nat, nat ⇒ real, [nat ⇒ real, nat] ⇒ real, nat ⇒ real, nat] ⇒ real"
specification (simplex_cone)
simplex_cone:
"⋀p v l. simplex_cone p v (oriented_simplex p l) =
oriented_simplex (Suc p) (λi. if i = 0 then v else l(i -1))"
proof -
have *: "⋀x. ∀xv. ∃y. (λl. oriented_simplex (Suc x)
(λi. if i = 0 then xv else l (i - 1))) =
y ∘ oriented_simplex x"
by (simp add: oriented_simplex_eq flip: choice_iff function_factors_left)
then show ?thesis
unfolding o_def by (metis(no_types))
qed
lemma simplicial_simplex_simplex_cone:
assumes f: "simplicial_simplex p S f"
and T: "⋀x u. ⟦0 ≤ u; u ≤ 1; x ∈ S⟧ ⟹ (λi. (1 - u) * v i + u * x i) ∈ T"
shows "simplicial_simplex (Suc p) T (simplex_cone p v f)"
proof (-)
(*goal: ‹simplicial_simplex (Suc p) T (simplex_cone p v f)›*)
obtain l where l: "⋀x. x ∈ standard_simplex p ⟹ oriented_simplex p l x ∈ S" and feq: "f = oriented_simplex p l"
(*goal: ‹(⋀l. ⟦⋀x. x ∈ standard_simplex p ⟹ oriented_simplex p l x ∈ S; f = oriented_simplex p l⟧ ⟹ thesis) ⟹ thesis›*)
using f (*‹simplicial_simplex p S f›*) by (auto simp: simplicial_simplex (*‹simplicial_simplex ?p ?S ?f = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l. ?f = oriented_simplex ?p l))›*))
have "oriented_simplex p l x ∈ S" if "x ∈ standard_simplex p" for x
using f (*‹simplicial_simplex p S f›*) that (*‹x ∈ standard_simplex p›*) by (auto simp: simplicial_simplex (*‹simplicial_simplex ?p ?S ?f = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l. ?f = oriented_simplex ?p l))›*) feq (*‹f = oriented_simplex p l›*))
then have S: "⋀x. ⟦⋀i. 0 ≤ x i ∧ x i ≤ 1; ⋀i. i>p ⟹ x i = 0; sum x {..p} = 1⟧
⟹ (λi. ∑j≤p. l j i * x j) ∈ S"
by (simp add: oriented_simplex_def (*‹oriented_simplex (?p::nat) (?l::nat ⇒ ?'a::type ⇒ real) ≡ λx::nat ⇒ real∈standard_simplex ?p. λi::?'a::type. ∑j::nat≤?p. ?l j i * x j›*) standard_simplex_def (*‹standard_simplex (?p::nat) ≡ {x::nat ⇒ real. (∀i::nat. (0::real) ≤ x i ∧ x i ≤ (1::real)) ∧ (∀i>?p. x i = (0::real)) ∧ sum x {..?p} = (1::real)}›*))
have "oriented_simplex (Suc p) (λi. if i = 0 then v else l (i -1)) x ∈ T" if "x ∈ standard_simplex (Suc p)" for x
proof (simp add: that (*‹x ∈ standard_simplex (Suc p)›*) oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) sum.atMost_Suc_shift (*‹sum ?g {..Suc ?n} = ?g 0 + (∑i≤?n. ?g (Suc i))›*) del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
(*goal: ‹(λi. v i * x 0 + (∑ia≤p. l ia i * x (Suc ia))) ∈ T›*)
have x01: "⋀i. 0 ≤ x i ∧ x i ≤ 1" and x0: "⋀i. i > Suc p ⟹ x i = 0" and x1: "sum x {..Suc p} = 1"
using that (*‹(x::nat ⇒ real) ∈ standard_simplex (Suc (p::nat))›*) apply -
(*goals:
1. ‹⋀i. x ∈ standard_simplex (Suc p) ⟹ 0 ≤ x i ∧ x i ≤ 1›
2. ‹⋀i. ⟦Suc p < i; x ∈ standard_simplex (Suc p)⟧ ⟹ x i = 0›
3. ‹x ∈ standard_simplex (Suc p) ⟹ sum x {..Suc p} = 1›
discuss goal 1*)
apply ((auto simp: oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*))[1])
(*discuss goal 2*)
apply ((auto simp: oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*))[1])
(*discuss goal 3*)
apply ((auto simp: oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*))[1])
(*proven 3 subgoals*) .
obtain a where "a ∈ S"
(*goal: ‹(⋀a. a ∈ S ⟹ thesis) ⟹ thesis›*)
using f (*‹simplicial_simplex (p::nat) (S::(nat ⇒ real) set) (f::(nat ⇒ real) ⇒ nat ⇒ real)›*) by force
show "(λi. v i * x 0 + (∑j≤p. l j i * x (Suc j))) ∈ T"
proof (cases "x 0 = 1")
(*goals:
1. ‹(x::nat ⇒ real) (0::nat) = (1::real) ⟹ (λi::nat. (v::nat ⇒ real) i * x (0::nat) + (∑j::nat≤p::nat. (l::nat ⇒ nat ⇒ real) j i * x (Suc j))) ∈ (T::(nat ⇒ real) set)›
2. ‹(x::nat ⇒ real) (0::nat) ≠ (1::real) ⟹ (λi::nat. (v::nat ⇒ real) i * x (0::nat) + (∑j::nat≤p::nat. (l::nat ⇒ nat ⇒ real) j i * x (Suc j))) ∈ (T::(nat ⇒ real) set)›*)
case True (*‹x 0 = 1›*)
then have "sum x {Suc 0..Suc p} = 0"
using x1 (*‹sum (x::nat ⇒ real) {..Suc (p::nat)} = (1::real)›*) by (simp add: atMost_atLeast0 (*‹{..?n::nat} = {0::nat..?n}›*) sum.atLeast_Suc_atMost (*‹(?m::nat) ≤ (?n::nat) ⟹ sum (?g::nat ⇒ ?'a) {?m..?n} = ?g ?m + sum ?g {Suc ?m..?n}›*))
then have [simp]: "x (Suc j) = 0" if "j≤p" for j
unfolding sum.atLeast_Suc_atMost_Suc_shift
(*goal: ‹x (Suc j) = 0›*)
using x01 (*‹(0::real) ≤ (x::nat ⇒ real) (?i::nat) ∧ x ?i ≤ (1::real)›*) that (*‹(j::nat) ≤ (p::nat)›*) by (simp add: sum_nonneg_eq_0_iff (*‹⟦finite ?A; ⋀x. x ∈ ?A ⟹ 0 ≤ ?f x⟧ ⟹ (sum ?f ?A = 0) = (∀x∈?A. ?f x = 0)›*))
then show "?thesis"
(*goal: ‹(λi. v i * x 0 + (∑j≤p. l j i * x (Suc j))) ∈ T›*)
using T[of 0 a] (*‹⟦0 ≤ 0; 0 ≤ 1; a ∈ S⟧ ⟹ (λi. (1 - 0) * v i + 0 * a i) ∈ T›*) ‹a ∈ S› (*‹a ∈ S›*) by (auto simp: True (*‹(x::nat ⇒ real) (0::nat) = (1::real)›*))
next
(*goal: ‹(x::nat ⇒ real) (0::nat) ≠ (1::real) ⟹ (λi::nat. (v::nat ⇒ real) i * x (0::nat) + (∑j::nat≤p::nat. (l::nat ⇒ nat ⇒ real) j i * x (Suc j))) ∈ (T::(nat ⇒ real) set)›*)
case False (*‹(x::nat ⇒ real) (0::nat) ≠ (1::real)›*)
then have "(λi. v i * x 0 + (∑j≤p. l j i * x (Suc j))) = (λi. (1 - (1 - x 0)) * v i + (1 - x 0) * (inverse (1 - x 0) * (∑j≤p. l j i * x (Suc j))))"
by (force simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))
also (*calculation: ‹(λi. v i * x 0 + (∑j≤p. l j i * x (Suc j))) = (λi. (1 - (1 - x 0)) * v i + (1 - x 0) * (inverse (1 - x 0) * (∑j≤p. l j i * x (Suc j))))›*) have "… ∈ T"
proof (rule T (*‹⟦0 ≤ ?u; ?u ≤ 1; ?x ∈ S⟧ ⟹ (λi. (1 - ?u) * v i + ?u * ?x i) ∈ T›*))
(*goals:
1. ‹0 ≤ 1 - x 0›
2. ‹1 - x 0 ≤ 1›
3. ‹(λi. inverse (1 - x 0) * (∑j≤p. l j i * x (Suc j))) ∈ S›*)
have "x 0 < 1"
by (simp add: False (*‹x 0 ≠ 1›*) less_le (*‹(?x < ?y) = (?x ≤ ?y ∧ ?x ≠ ?y)›*) x01 (*‹0 ≤ x ?i ∧ x ?i ≤ 1›*))
have xle: "x (Suc i) ≤ (1 - x 0)" for i
proof (cases "i ≤ p")
(*goals:
1. ‹(i::nat) ≤ (p::nat) ⟹ (x::nat ⇒ real) (Suc i) ≤ (1::real) - x (0::nat)›
2. ‹¬ (i::nat) ≤ (p::nat) ⟹ (x::nat ⇒ real) (Suc i) ≤ (1::real) - x (0::nat)›*)
case True (*‹i ≤ p›*)
have "sum x {0, Suc i} ≤ sum x {..Suc p}"
apply (rule sum_mono2 (*‹⟦finite ?B; ?A ⊆ ?B; ⋀b. b ∈ ?B - ?A ⟹ 0 ≤ ?f b⟧ ⟹ sum ?f ?A ≤ sum ?f ?B›*))
(*goals:
1. ‹finite {..Suc p}›
2. ‹{0, Suc i} ⊆ {..Suc p}›
3. ‹⋀b. b ∈ {..Suc p} - {0, Suc i} ⟹ 0 ≤ x b›
discuss goal 1*)
apply ((auto simp: True (*‹(i::nat) ≤ (p::nat)›*) x01 (*‹(0::real) ≤ (x::nat ⇒ real) (?i::nat) ∧ x ?i ≤ (1::real)›*))[1])
(*discuss goal 2*)
apply ((auto simp: True (*‹i ≤ p›*) x01 (*‹0 ≤ x ?i ∧ x ?i ≤ 1›*))[1])
(*discuss goal 3*)
apply ((auto simp: True (*‹i ≤ p›*) x01 (*‹0 ≤ x ?i ∧ x ?i ≤ 1›*))[1])
(*proven 3 subgoals*) .
then show "?thesis"
(*goal: ‹x (Suc i) ≤ 1 - x 0›*)
using x1 (*‹sum x {..Suc p} = 1›*) x01 (*‹0 ≤ x ?i ∧ x ?i ≤ 1›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 33 facts*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*))
qed (simp add: x0 (*‹Suc (p::nat) < (?i::nat) ⟹ (x::nat ⇒ real) ?i = (0::real)›*) x01 (*‹(0::real) ≤ (x::nat ⇒ real) (?i::nat) ∧ x ?i ≤ (1::real)›*))
(*solved the remaining goal: ‹¬ i ≤ p ⟹ x (Suc i) ≤ 1 - x 0›*)
have "(λi. (∑j≤p. l j i * (x (Suc j) * inverse (1 - x 0)))) ∈ S"
proof (rule S (*‹⟦⋀i. 0 ≤ ?x i ∧ ?x i ≤ 1; ⋀i. p < i ⟹ ?x i = 0; sum ?x {..p} = 1⟧ ⟹ (λi. ∑j≤p. l j i * ?x j) ∈ S›*))
(*goals:
1. ‹⋀i. 0 ≤ x (Suc i) * inverse (1 - x 0) ∧ x (Suc i) * inverse (1 - x 0) ≤ 1›
2. ‹⋀i. p < i ⟹ x (Suc i) * inverse (1 - x 0) = 0›
3. ‹(∑j≤p. x (Suc j) * inverse (1 - x 0)) = 1›*)
have "x 0 + (∑j≤p. x (Suc j)) = sum x {..Suc p}"
by (metis sum.atMost_Suc_shift (*‹sum ?g {..Suc ?n} = ?g 0 + (∑i≤?n. ?g (Suc i))›*))
with x1 (*‹sum x {..Suc p} = 1›*) have "(∑j≤p. x (Suc j)) = 1 - x 0"
by simp
with False (*‹x 0 ≠ 1›*) show "(∑j≤p. x (Suc j) * inverse (1 - x 0)) = 1"
by (metis add_diff_cancel_left' (*‹?a + ?b - ?a = ?b›*) diff_diff_eq2 (*‹?a - (?b - ?c) = ?a + ?c - ?b›*) diff_zero (*‹?a - 0 = ?a›*) right_inverse (*‹?a ≠ 0 ⟹ ?a * inverse ?a = 1›*) sum_distrib_right (*‹sum ?f ?A * ?r = (∑n∈?A. ?f n * ?r)›*))
qed (use x01 x0 xle ‹x 0 < 1› in ‹auto simp: field_split_simps›)
(*solves the remaining goals:
1. ‹⋀i. 0 ≤ x (Suc i) * inverse (1 - x 0) ∧ x (Suc i) * inverse (1 - x 0) ≤ 1›
2. ‹⋀i. p < i ⟹ x (Suc i) * inverse (1 - x 0) = 0›*)
then show "(λi. inverse (1 - x 0) * (∑j≤p. l j i * x (Suc j))) ∈ S"
by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) sum_divide_distrib (*‹sum ?f ?A / ?r = (∑n∈?A. ?f n / ?r)›*))
qed (use x01 in auto)
(*solves the remaining goals:
1. ‹0 ≤ 1 - x 0›
2. ‹1 - x 0 ≤ 1›*)
finally (*calculation: ‹(λi. v i * x 0 + (∑j≤p. l j i * x (Suc j))) ∈ T›*) show "?thesis"
(*goal: ‹(λi. v i * x 0 + (∑j≤p. l j i * x (Suc j))) ∈ T›*) .
qed
qed
then show "?thesis"
(*goal: ‹simplicial_simplex (Suc p) T (simplex_cone p v f)›*)
by (auto simp: simplicial_simplex (*‹simplicial_simplex ?p ?S ?f = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l. ?f = oriented_simplex ?p l))›*) feq (*‹f = oriented_simplex p l›*) simplex_cone (*‹simplex_cone ?p ?v (oriented_simplex ?p ?l) = oriented_simplex (Suc ?p) (λi. if i = 0 then ?v else ?l (i - 1))›*))
qed
definition simplicial_cone
where "simplicial_cone p v ≡ frag_extend (frag_of ∘ simplex_cone p v)"
lemma simplicial_chain_simplicial_cone:
assumes c: "simplicial_chain p S c"
and T: "⋀x u. ⟦0 ≤ u; u ≤ 1; x ∈ S⟧ ⟹ (λi. (1 - u) * v i + u * x i) ∈ T"
shows "simplicial_chain (Suc p) T (simplicial_cone p v c)"
using c (*‹simplicial_chain p S c›*) unfolding simplicial_chain_def simplicial_cone_def
(*goal: ‹Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone p v) c) ⊆ Collect (simplicial_simplex (Suc p) T)›*)
proof (induction rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone (p::nat) (v::nat ⇒ real)) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) ⊆ {a::(nat ⇒ real) ⇒ nat ⇒ real. simplicial_simplex (Suc p) (T::(nat ⇒ real) set) a}›
2. ‹⋀x::(nat ⇒ real) ⇒ nat ⇒ real. x ∈ Collect (simplicial_simplex (p::nat) (S::(nat ⇒ real) set)) ⟹ Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone p (v::nat ⇒ real)) (frag_of x)) ⊆ {a::(nat ⇒ real) ⇒ nat ⇒ real. simplicial_simplex (Suc p) (T::(nat ⇒ real) set) a}›
3. ‹⋀(a::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) b::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int. ⟦Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone (p::nat) (v::nat ⇒ real)) a) ⊆ {a::(nat ⇒ real) ⇒ nat ⇒ real. simplicial_simplex (Suc p) (T::(nat ⇒ real) set) a}; Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone p v) b) ⊆ {a::(nat ⇒ real) ⇒ nat ⇒ real. simplicial_simplex (Suc p) T a}⟧ ⟹ Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone p v) (a - b)) ⊆ {a::(nat ⇒ real) ⇒ nat ⇒ real. simplicial_simplex (Suc p) T a}›*)
case (one x) (*‹x ∈ Collect (simplicial_simplex p S)›*)
then show "?case"
(*goal: ‹Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone p v) (frag_of x)) ⊆ {a. simplicial_simplex (Suc p) T a}›*)
by (simp add: T (*‹⟦0 ≤ ?u; ?u ≤ 1; ?x ∈ S⟧ ⟹ (λi. (1 - ?u) * v i + ?u * ?x i) ∈ T›*) simplicial_simplex_simplex_cone (*‹⟦simplicial_simplex ?p ?S ?f; ⋀x u. ⟦0 ≤ u; u ≤ 1; x ∈ ?S⟧ ⟹ (λi. (1 - u) * ?v i + u * x i) ∈ ?T⟧ ⟹ simplicial_simplex (Suc ?p) ?T (simplex_cone ?p ?v ?f)›*))
next
(*goals:
1. ‹Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone p v) 0) ⊆ {a. simplicial_simplex (Suc p) T a}›
2. ‹⋀a b. ⟦Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone p v) a) ⊆ {a. simplicial_simplex (Suc p) T a}; Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone p v) b) ⊆ {a. simplicial_simplex (Suc p) T a}⟧ ⟹ Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone p v) (a - b)) ⊆ {a. simplicial_simplex (Suc p) T a}›*)
case (diff a b) (*‹Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone p v) a) ⊆ {a. simplicial_simplex (Suc p) T a}› ‹Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone p v) b) ⊆ {a. simplicial_simplex (Suc p) T a}›*)
then show "?case"
(*goal: ‹Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone (p::nat) (v::nat ⇒ real)) ((a::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) - (b::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int))) ⊆ {a::(nat ⇒ real) ⇒ nat ⇒ real. simplicial_simplex (Suc p) (T::(nat ⇒ real) set) a}›*)
by (metis frag_extend_diff (*‹frag_extend (?f::?'b ⇒ ?'a ⇒₀ int) ((?a::?'b ⇒₀ int) - (?b::?'b ⇒₀ int)) = frag_extend ?f ?a - frag_extend ?f ?b›*) simplicial_chain_def (*‹simplicial_chain (?p::nat) (?S::(?'a ⇒ real) set) (?c::((nat ⇒ real) ⇒ ?'a ⇒ real) ⇒₀ ?'b) ≡ Poly_Mapping.keys ?c ⊆ Collect (simplicial_simplex ?p ?S)›*) simplicial_chain_diff (*‹⟦simplicial_chain (?p::nat) (?S::(?'a ⇒ real) set) (?c1.0::((nat ⇒ real) ⇒ ?'a ⇒ real) ⇒₀ ?'b); simplicial_chain ?p ?S (?c2.0::((nat ⇒ real) ⇒ ?'a ⇒ real) ⇒₀ ?'b)⟧ ⟹ simplicial_chain ?p ?S (?c1.0 - ?c2.0)›*))
qed (auto)
(*solved the remaining goal: ‹Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone p v) 0) ⊆ {a. simplicial_simplex (Suc p) T a}›*)
lemma chain_boundary_simplicial_cone_of':
assumes "f = oriented_simplex p l"
shows "chain_boundary (Suc p) (simplicial_cone p v (frag_of f)) =
frag_of f
- (if p = 0 then frag_of (λu∈standard_simplex p. v)
else simplicial_cone (p -1) v (chain_boundary p (frag_of f)))"
proof (simp, intro impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹p = 0 ⟹ chain_boundary (Suc 0) (simplicial_cone 0 v (frag_of f)) = frag_of f - frag_of (λu∈standard_simplex 0. v)›
2. ‹0 < p ⟹ chain_boundary (Suc p) (simplicial_cone p v (frag_of f)) = frag_of f - simplicial_cone (p - Suc 0) v (chain_boundary p (frag_of f))›*)
assume "p = 0" (*‹(p::nat) = (0::nat)›*)
have eq: "(oriented_simplex 0 (λj. if j = 0 then v else l j)) = (λu∈standard_simplex 0. v)"
by (force simp: oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*))
show "chain_boundary (Suc 0) (simplicial_cone 0 v (frag_of f))
= frag_of f - frag_of (λu∈standard_simplex 0. v)"
by (simp add: assms (*‹f = oriented_simplex p l›*) simplicial_cone_def (*‹simplicial_cone ?p ?v ≡ frag_extend (frag_of ∘ simplex_cone ?p ?v)›*) chain_boundary_of (*‹chain_boundary ?p (frag_of ?f) = (if ?p = 0 then 0 else ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k ?f)))›*) ‹p = 0› simplex_cone (*‹simplex_cone ?p ?v (oriented_simplex ?p ?l) = oriented_simplex (Suc ?p) (λi. if i = 0 then ?v else ?l (i - 1))›*) singular_face_oriented_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p⟧ ⟹ singular_face ?p ?k (oriented_simplex ?p ?l) = oriented_simplex (?p - 1) (λj. if j < ?k then ?l j else ?l (Suc j))›*) eq (*‹oriented_simplex 0 (λj. if j = 0 then v else l j) = (λu∈standard_simplex 0. v)›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
next
(*goal: ‹(0::nat) < (p::nat) ⟹ chain_boundary (Suc p) (simplicial_cone p (v::nat ⇒ real) (frag_of (f::(nat ⇒ real) ⇒ nat ⇒ real))) = frag_of f - simplicial_cone (p - Suc (0::nat)) v (chain_boundary p (frag_of f))›*)
assume "0 < p" (*‹(0::nat) < (p::nat)›*)
have 0: "simplex_cone (p - Suc 0) v (singular_face p x (oriented_simplex p l))
= oriented_simplex p
(λj. if j < Suc x
then if j = 0 then v else l (j -1)
else if Suc j = 0 then v else l (Suc j -1))" if "x ≤ p" for x
using ‹0 < p› (*‹0 < p›*) that (*‹x ≤ p›*) by (auto simp: Suc_leI (*‹?m < ?n ⟹ Suc ?m ≤ ?n›*) singular_face_oriented_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p⟧ ⟹ singular_face ?p ?k (oriented_simplex ?p ?l) = oriented_simplex (?p - 1) (λj. if j < ?k then ?l j else ?l (Suc j))›*) simplex_cone (*‹simplex_cone ?p ?v (oriented_simplex ?p ?l) = oriented_simplex (Suc ?p) (λi. if i = 0 then ?v else ?l (i - 1))›*) oriented_simplex_eq (*‹(oriented_simplex ?p ?l = oriented_simplex ?p ?l') = (∀i≤?p. ?l i = ?l' i)›*))
have 1: "frag_extend (frag_of ∘ simplex_cone (p - Suc 0) v)
(∑k = 0..p. frag_cmul ((-1) ^ k) (frag_of (singular_face p k (oriented_simplex p l))))
= - (∑k = Suc 0..Suc p. frag_cmul ((-1) ^ k)
(frag_of (singular_face (Suc p) k (simplex_cone p v (oriented_simplex p l)))))"
unfolding sum.atLeast_Suc_atMost_Suc_shift
(*goal: ‹frag_extend (frag_of ∘ simplex_cone (p - Suc 0) v) (∑k = 0..p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k (oriented_simplex p l)))) = - sum ((λk. frag_cmul ((- 1) ^ k) (frag_of (singular_face (Suc p) k (simplex_cone p v (oriented_simplex p l))))) ∘ Suc) {0..p}›*)
by (auto simp: 0 (*‹?x ≤ p ⟹ simplex_cone (p - Suc 0) v (singular_face p ?x (oriented_simplex p l)) = oriented_simplex p (λj. if j < Suc ?x then if j = 0 then v else l (j - 1) else if Suc j = 0 then v else l (Suc j - 1))›*) simplex_cone (*‹simplex_cone ?p ?v (oriented_simplex ?p ?l) = oriented_simplex (Suc ?p) (λi. if i = 0 then ?v else ?l (i - 1))›*) singular_face_oriented_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p⟧ ⟹ singular_face ?p ?k (oriented_simplex ?p ?l) = oriented_simplex (?p - 1) (λj. if j < ?k then ?l j else ?l (Suc j))›*) frag_extend_sum (*‹finite ?I ⟹ frag_extend ?f (sum ?g ?I) = sum (frag_extend ?f ∘ ?g) ?I›*) frag_extend_cmul (*‹frag_extend ?f (frag_cmul ?c ?x) = frag_cmul ?c (frag_extend ?f ?x)›*) simp flip: sum_negf (*‹(∑x∈?A. - ?f x) = - sum ?f ?A›*))
moreover have 2: "singular_face (Suc p) 0 (simplex_cone p v (oriented_simplex p l))
= oriented_simplex p l"
by (simp add: simplex_cone (*‹simplex_cone (?p::nat) (?v::nat ⇒ real) (oriented_simplex ?p (?l::nat ⇒ nat ⇒ real)) = oriented_simplex (Suc ?p) (λi::nat. if i = (0::nat) then ?v else ?l (i - (1::nat)))›*) singular_face_oriented_simplex (*‹⟦(1::nat) ≤ (?p::nat); (?k::nat) ≤ ?p⟧ ⟹ singular_face ?p ?k (oriented_simplex ?p (?l::nat ⇒ ?'a ⇒ real)) = oriented_simplex (?p - (1::nat)) (λj::nat. if j < ?k then ?l j else ?l (Suc j))›*))
show "chain_boundary (Suc p) (simplicial_cone p v (frag_of f))
= frag_of f - simplicial_cone (p - Suc 0) v (chain_boundary p (frag_of f))"
using ‹p > 0› (*‹0 < p›*) apply (simp add: assms (*‹f = oriented_simplex p l›*) simplicial_cone_def (*‹simplicial_cone ?p ?v ≡ frag_extend (frag_of ∘ simplex_cone ?p ?v)›*) chain_boundary_of (*‹chain_boundary ?p (frag_of ?f) = (if ?p = 0 then 0 else ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k ?f)))›*) atMost_atLeast0 (*‹{..?n} = {0..?n}›*) del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
(*goal: ‹chain_boundary (Suc p) (simplicial_cone p v (frag_of f)) = frag_of f - simplicial_cone (p - Suc 0) v (chain_boundary p (frag_of f))›*)
apply (subst sum.atLeast_Suc_atMost [of 0] (*‹(0::nat) ≤ (?n::nat) ⟹ sum (?g::nat ⇒ ?'a) {0::nat..?n} = ?g (0::nat) + sum ?g {Suc (0::nat)..?n}›*))
(*goals:
1. ‹0 < p ⟹ 0 ≤ p›
2. ‹0 < p ⟹ frag_cmul ((- 1) ^ 0) (frag_of (singular_face (Suc p) 0 (simplex_cone p v (oriented_simplex p l)))) + (∑k = Suc 0..p. frag_cmul ((- 1) ^ k) (frag_of (singular_face (Suc p) k (simplex_cone p v (oriented_simplex p l))))) + frag_cmul (- ((- 1) ^ p)) (frag_of (singular_face (Suc p) (Suc p) (simplex_cone p v (oriented_simplex p l)))) = frag_of (oriented_simplex p l) - frag_extend (frag_of ∘ simplex_cone (p - Suc 0) v) (∑k = 0..p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k (oriented_simplex p l))))›
discuss goal 1*)
apply (simp add: 1 (*‹frag_extend (frag_of ∘ simplex_cone (p - Suc 0) v) (∑k = 0..p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k (oriented_simplex p l)))) = - (∑k = Suc 0..Suc p. frag_cmul ((- 1) ^ k) (frag_of (singular_face (Suc p) k (simplex_cone p v (oriented_simplex p l)))))›*) 2 (*‹singular_face (Suc p) 0 (simplex_cone p v (oriented_simplex p l)) = oriented_simplex p l›*) del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
(*discuss goal 2*)
apply (simp add: 1 (*‹frag_extend (frag_of ∘ simplex_cone (p - Suc 0) v) (∑k = 0..p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k (oriented_simplex p l)))) = - (∑k = Suc 0..Suc p. frag_cmul ((- 1) ^ k) (frag_of (singular_face (Suc p) k (simplex_cone p v (oriented_simplex p l)))))›*) 2 (*‹singular_face (Suc p) 0 (simplex_cone p v (oriented_simplex p l)) = oriented_simplex p l›*) del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
(*proven 2 subgoals*) .
qed
lemma chain_boundary_simplicial_cone_of:
assumes "simplicial_simplex p S f"
shows "chain_boundary (Suc p) (simplicial_cone p v (frag_of f)) =
frag_of f
- (if p = 0 then frag_of (λu∈standard_simplex p. v)
else simplicial_cone (p -1) v (chain_boundary p (frag_of f)))"
using chain_boundary_simplicial_cone_of' (*‹?f = oriented_simplex ?p ?l ⟹ chain_boundary (Suc ?p) (simplicial_cone ?p ?v (frag_of ?f)) = frag_of ?f - (if ?p = 0 then frag_of (λu∈standard_simplex ?p. ?v) else simplicial_cone (?p - 1) ?v (chain_boundary ?p (frag_of ?f)))›*) assms (*‹simplicial_simplex (p::nat) (S::(nat ⇒ real) set) (f::(nat ⇒ real) ⇒ nat ⇒ real)›*) unfolding simplicial_simplex_def
(*goal: ‹chain_boundary (Suc p) (simplicial_cone p v (frag_of f)) = frag_of f - (if p = 0 then frag_of (λu∈standard_simplex p. v) else simplicial_cone (p - 1) v (chain_boundary p (frag_of f)))›*)
by blast
lemma chain_boundary_simplicial_cone:
"simplicial_chain p S c
⟹ chain_boundary (Suc p) (simplicial_cone p v c) =
c - (if p = 0 then frag_extend (λf. frag_of (λu∈standard_simplex p. v)) c
else simplicial_cone (p -1) v (chain_boundary p c))"
unfolding simplicial_chain_def
(*goal: ‹Poly_Mapping.keys c ⊆ Collect (simplicial_simplex p S) ⟹ chain_boundary (Suc p) (simplicial_cone p v c) = c - (if p = 0 then frag_extend (λf. frag_of (λu∈standard_simplex p. v)) c else simplicial_cone (p - 1) v (chain_boundary p c))›*)
proof (induction rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹chain_boundary (Suc p) (simplicial_cone p v 0) = 0 - (if p = 0 then frag_extend (λf. frag_of (λu∈standard_simplex p. v)) 0 else simplicial_cone (p - 1) v (chain_boundary p 0))›
2. ‹⋀x. x ∈ Collect (simplicial_simplex p S) ⟹ chain_boundary (Suc p) (simplicial_cone p v (frag_of x)) = frag_of x - (if p = 0 then frag_extend (λf. frag_of (λu∈standard_simplex p. v)) (frag_of x) else simplicial_cone (p - 1) v (chain_boundary p (frag_of x)))›
3. ‹⋀a b. ⟦chain_boundary (Suc p) (simplicial_cone p v a) = a - (if p = 0 then frag_extend (λf. frag_of (λu∈standard_simplex p. v)) a else simplicial_cone (p - 1) v (chain_boundary p a)); chain_boundary (Suc p) (simplicial_cone p v b) = b - (if p = 0 then frag_extend (λf. frag_of (λu∈standard_simplex p. v)) b else simplicial_cone (p - 1) v (chain_boundary p b))⟧ ⟹ chain_boundary (Suc p) (simplicial_cone p v (a - b)) = a - b - (if p = 0 then frag_extend (λf. frag_of (λu∈standard_simplex p. v)) (a - b) else simplicial_cone (p - 1) v (chain_boundary p (a - b)))›*)
case (one x) (*‹x ∈ Collect (simplicial_simplex p S)›*)
then show "?case"
(*goal: ‹chain_boundary (Suc (p::nat)) (simplicial_cone p (v::nat ⇒ real) (frag_of (x::(nat ⇒ real) ⇒ nat ⇒ real))) = frag_of x - (if p = (0::nat) then frag_extend (λf::(nat ⇒ real) ⇒ nat ⇒ real. frag_of (λu::nat ⇒ real∈standard_simplex p. v)) (frag_of x) else simplicial_cone (p - (1::nat)) v (chain_boundary p (frag_of x)))›*)
by (auto simp: chain_boundary_simplicial_cone_of (*‹simplicial_simplex ?p ?S ?f ⟹ chain_boundary (Suc ?p) (simplicial_cone ?p ?v (frag_of ?f)) = frag_of ?f - (if ?p = 0 then frag_of (λu∈standard_simplex ?p. ?v) else simplicial_cone (?p - 1) ?v (chain_boundary ?p (frag_of ?f)))›*))
qed (auto simp: chain_boundary_diff (*‹chain_boundary ?p (?a - ?b) = chain_boundary ?p ?a - chain_boundary ?p ?b›*) simplicial_cone_def (*‹simplicial_cone ?p ?v ≡ frag_extend (frag_of ∘ simplex_cone ?p ?v)›*) frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*))
(*solves the remaining goals:
1. ‹chain_boundary (Suc (p::nat)) (simplicial_cone p (v::nat ⇒ real) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) = (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) - (if p = (0::nat) then frag_extend (λf::(nat ⇒ real) ⇒ nat ⇒ real. frag_of (λu::nat ⇒ real∈standard_simplex p. v)) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) else simplicial_cone (p - (1::nat)) v (chain_boundary p (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)))›
2. ‹⋀(a::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) b::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int. ⟦chain_boundary (Suc (p::nat)) (simplicial_cone p (v::nat ⇒ real) a) = a - (if p = (0::nat) then frag_extend (λf::(nat ⇒ real) ⇒ nat ⇒ real. frag_of (λu::nat ⇒ real∈standard_simplex p. v)) a else simplicial_cone (p - (1::nat)) v (chain_boundary p a)); chain_boundary (Suc p) (simplicial_cone p v b) = b - (if p = (0::nat) then frag_extend (λf::(nat ⇒ real) ⇒ nat ⇒ real. frag_of (λu::nat ⇒ real∈standard_simplex p. v)) b else simplicial_cone (p - (1::nat)) v (chain_boundary p b))⟧ ⟹ chain_boundary (Suc p) (simplicial_cone p v (a - b)) = a - b - (if p = (0::nat) then frag_extend (λf::(nat ⇒ real) ⇒ nat ⇒ real. frag_of (λu::nat ⇒ real∈standard_simplex p. v)) (a - b) else simplicial_cone (p - (1::nat)) v (chain_boundary p (a - b)))›*)
lemma simplex_map_oriented_simplex:
assumes l: "simplicial_simplex p (standard_simplex q) (oriented_simplex p l)"
and g: "simplicial_simplex r S g" and "q ≤ r"
shows "simplex_map p g (oriented_simplex p l) = oriented_simplex p (g ∘ l)"
proof (-)
(*goal: ‹simplex_map p g (oriented_simplex p l) = oriented_simplex p (g ∘ l)›*)
obtain m where geq: "g = oriented_simplex r m"
(*goal: ‹(⋀m. g = oriented_simplex r m ⟹ thesis) ⟹ thesis›*)
using g (*‹simplicial_simplex r S g›*) by (auto simp: simplicial_simplex_def (*‹simplicial_simplex ?p ?S ?f ≡ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f ∧ (∃l. ?f = oriented_simplex ?p l)›*))
have "g (λi. ∑j≤p. l j i * x j) i = (∑j≤p. g (l j) i * x j)" if "x ∈ standard_simplex p" for x and i
proof (-)
(*goal: ‹g (λi. ∑j≤p. l j i * x j) i = (∑j≤p. g (l j) i * x j)›*)
have ssr: "(λi. ∑j≤p. l j i * x j) ∈ standard_simplex r"
using l (*‹simplicial_simplex p (standard_simplex q) (oriented_simplex p l)›*) that (*‹x ∈ standard_simplex p›*) standard_simplex_mono[OF ‹q ≤ r›] (*‹standard_simplex q ⊆ standard_simplex r›*) unfolding simplicial_simplex_oriented_simplex
(*goal: ‹(λi. ∑j≤p. l j i * x j) ∈ standard_simplex r›*)
by auto
have lss: "l j ∈ standard_simplex r" if "j≤p" for j
proof (-)
(*goal: ‹l j ∈ standard_simplex r›*)
have q: "(λx i. ∑j≤p. l j i * x j) ` standard_simplex p ⊆ standard_simplex q"
using l (*‹simplicial_simplex p (standard_simplex q) (oriented_simplex p l)›*) by (simp add: simplicial_simplex_oriented_simplex (*‹simplicial_simplex ?p ?S (oriented_simplex ?p ?l) = ((λx i. ∑j≤?p. ?l j i * x j) ` standard_simplex ?p ⊆ ?S)›*))
let ?x = "(λi. if i = j then 1 else 0)"
have p: "l j ∈ (λx i. ∑j≤p. l j i * x j) ` standard_simplex p"
proof (standard)
(*goals:
1. ‹(l::nat ⇒ nat ⇒ real) (j::nat) = (λi::nat. ∑j::nat≤p::nat. l j i * (?x::nat ⇒ real) j)›
2. ‹(?x::nat ⇒ real) ∈ standard_simplex (p::nat)›*)
show "l j = (λi. ∑j≤p. l j i * ?x j)"
using ‹j≤p› (*‹j ≤ p›*) by (force simp: if_distrib (*‹(?f::?'b::type ⇒ ?'a::type) (if ?c::bool then ?x::?'b::type else (?y::?'b::type)) = (if ?c then ?f ?x else ?f ?y)›*) cong: if_cong (*‹⟦(?b::bool) = (?c::bool); ?c ⟹ (?x::?'a::type) = (?u::?'a::type); ¬ ?c ⟹ (?y::?'a::type) = (?v::?'a::type)⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
show "?x ∈ standard_simplex p"
by (simp add: that (*‹j ≤ p›*))
qed
show "?thesis"
(*goal: ‹l j ∈ standard_simplex r›*)
using standard_simplex_mono[OF ‹q ≤ r›] (*‹standard_simplex q ⊆ standard_simplex r›*) q (*‹(λx i. ∑j≤p. l j i * x j) ` standard_simplex p ⊆ standard_simplex q›*) p (*‹l j ∈ (λx i. ∑j≤p. l j i * x j) ` standard_simplex p›*) by blast
qed
have "g (λi. ∑j≤p. l j i * x j) i = (∑j≤r. ∑n≤p. m j i * (l n j * x n))"
by (simp add: geq (*‹g = oriented_simplex r m›*) oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*) ssr (*‹(λi. ∑j≤p. l j i * x j) ∈ standard_simplex r›*))
also (*calculation: ‹g (λi. ∑j≤p. l j i * x j) i = (∑j≤r. ∑n≤p. m j i * (l n j * x n))›*) have "... = (∑j≤p. ∑n≤r. m n i * (l j n * x j))"
by (rule sum.swap (*‹(∑i∈?A. sum (?g i) ?B) = (∑j∈?B. ∑i∈?A. ?g i j)›*))
also (*calculation: ‹g (λi. ∑j≤p. l j i * x j) i = (∑j≤p. ∑n≤r. m n i * (l j n * x j))›*) have "... = (∑j≤p. g (l j) i * x j)"
by (simp add: geq (*‹g = oriented_simplex r m›*) oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) sum_distrib_right (*‹sum ?f ?A * ?r = (∑n∈?A. ?f n * ?r)›*) mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*) lss (*‹?j ≤ p ⟹ l ?j ∈ standard_simplex r›*))
finally (*calculation: ‹g (λi. ∑j≤p. l j i * x j) i = (∑j≤p. g (l j) i * x j)›*) show "?thesis"
(*goal: ‹(g::(nat ⇒ real) ⇒ 'a ⇒ real) (λi::nat. ∑j::nat≤p::nat. (l::nat ⇒ nat ⇒ real) j i * (x::nat ⇒ real) j) (i::'a) = (∑j::nat≤p. g (l j) i * x j)›*) .
qed
then show "?thesis"
(*goal: ‹simplex_map p g (oriented_simplex p l) = oriented_simplex p (g ∘ l)›*)
by (force simp: oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) simplex_map_def (*‹simplex_map ?p ?g ?c ≡ restrict (?g ∘ ?c) (standard_simplex ?p)›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*))
qed
lemma chain_map_simplicial_cone:
assumes g: "simplicial_simplex r S g"
and c: "simplicial_chain p (standard_simplex q) c"
and v: "v ∈ standard_simplex q" and "q ≤ r"
shows "chain_map (Suc p) g (simplicial_cone p v c) = simplicial_cone p (g v) (chain_map p g c)"
proof (-)
(*goal: ‹chain_map (Suc p) g (simplicial_cone p v c) = simplicial_cone p (g v) (chain_map p g c)›*)
have "*": "simplex_map (Suc p) g (simplex_cone p v f) = simplex_cone p (g v) (simplex_map p g f)" if "f ∈ Poly_Mapping.keys c" for f
proof (-)
(*goal: ‹simplex_map (Suc p) g (simplex_cone p v f) = simplex_cone p (g v) (simplex_map p g f)›*)
have "simplicial_simplex p (standard_simplex q) f"
using c (*‹simplicial_chain p (standard_simplex q) c›*) that (*‹(f::(nat ⇒ real) ⇒ nat ⇒ real) ∈ Poly_Mapping.keys (c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)›*) by (auto simp: simplicial_chain_def (*‹simplicial_chain ?p ?S ?c ≡ Poly_Mapping.keys ?c ⊆ Collect (simplicial_simplex ?p ?S)›*))
then obtain m where feq: "f = oriented_simplex p m"
(*goal: ‹(⋀m. f = oriented_simplex p m ⟹ thesis) ⟹ thesis›*)
by (auto simp: simplicial_simplex (*‹simplicial_simplex ?p ?S ?f = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l. ?f = oriented_simplex ?p l))›*))
have 0: "simplicial_simplex p (standard_simplex q) (oriented_simplex p m)"
using ‹simplicial_simplex p (standard_simplex q) f› (*‹simplicial_simplex p (standard_simplex q) f›*) feq (*‹(f::(nat ⇒ real) ⇒ nat ⇒ real) = oriented_simplex (p::nat) (m::nat ⇒ nat ⇒ real)›*) by blast
then have 1: "simplicial_simplex (Suc p) (standard_simplex q)
(oriented_simplex (Suc p) (λi. if i = 0 then v else m (i -1)))"
using convex_standard_simplex (*‹⟦?x ∈ standard_simplex ?p; ?y ∈ standard_simplex ?p; 0 ≤ ?u; ?u ≤ 1⟧ ⟹ (λi. (1 - ?u) * ?x i + ?u * ?y i) ∈ standard_simplex ?p›*) v (*‹v ∈ standard_simplex q›*) by (simp flip: simplex_cone (*‹simplex_cone ?p ?v (oriented_simplex ?p ?l) = oriented_simplex (Suc ?p) (λi. if i = 0 then ?v else ?l (i - 1))›*) add: simplicial_simplex_simplex_cone (*‹⟦simplicial_simplex ?p ?S ?f; ⋀x u. ⟦0 ≤ u; u ≤ 1; x ∈ ?S⟧ ⟹ (λi. (1 - u) * ?v i + u * x i) ∈ ?T⟧ ⟹ simplicial_simplex (Suc ?p) ?T (simplex_cone ?p ?v ?f)›*))
show "?thesis"
(*goal: ‹simplex_map (Suc p) g (simplex_cone p v f) = simplex_cone p (g v) (simplex_map p g f)›*)
using simplex_map_oriented_simplex[OF 1 g ‹q ≤ r›] (*‹simplex_map (Suc p) g (oriented_simplex (Suc p) (λi. if i = 0 then v else m (i - 1))) = oriented_simplex (Suc p) (g ∘ (λi. if i = 0 then v else m (i - 1)))›*) simplex_map_oriented_simplex[of p q m r S g, OF 0 g ‹q ≤ r›] (*‹simplex_map p g (oriented_simplex p m) = oriented_simplex p (g ∘ m)›*) by (simp add: feq (*‹f = oriented_simplex p m›*) oriented_simplex_eq (*‹(oriented_simplex ?p ?l = oriented_simplex ?p ?l') = (∀i≤?p. ?l i = ?l' i)›*) simplex_cone (*‹simplex_cone ?p ?v (oriented_simplex ?p ?l) = oriented_simplex (Suc ?p) (λi. if i = 0 then ?v else ?l (i - 1))›*))
qed
show "?thesis"
(*goal: ‹chain_map (Suc p) g (simplicial_cone p v c) = simplicial_cone p (g v) (chain_map p g c)›*)
by (auto simp: chain_map_def (*‹chain_map ?p ?g ?c ≡ frag_extend (frag_of ∘ simplex_map ?p ?g) ?c›*) simplicial_cone_def (*‹simplicial_cone ?p ?v ≡ frag_extend (frag_of ∘ simplex_cone ?p ?v)›*) frag_extend_compose (*‹frag_extend ?f (frag_extend (frag_of ∘ ?g) ?c) = frag_extend (?f ∘ ?g) ?c›*) * (*‹?f ∈ Poly_Mapping.keys c ⟹ simplex_map (Suc p) g (simplex_cone p v ?f) = simplex_cone p (g v) (simplex_map p g ?f)›*) intro: frag_extend_eq (*‹(⋀f. f ∈ Poly_Mapping.keys ?c ⟹ ?g f = ?h f) ⟹ frag_extend ?g ?c = frag_extend ?h ?c›*))
qed
subsection‹Barycentric subdivision of a linear ("simplicial") simplex's image›
definition simplicial_vertex
where "simplicial_vertex i f = f(λj. if j = i then 1 else 0)"
lemma simplicial_vertex_oriented_simplex:
"simplicial_vertex i (oriented_simplex p l) = (if i ≤ p then l i else undefined)"
by (simp add: simplicial_vertex_def (*‹simplicial_vertex (?i::?'b) (?f::(?'b ⇒ ?'c) ⇒ ?'a) = ?f (λj::?'b. if j = ?i then 1::?'c else (0::?'c))›*) oriented_simplex_def (*‹oriented_simplex (?p::nat) (?l::nat ⇒ ?'a ⇒ real) ≡ λx::nat ⇒ real∈standard_simplex ?p. λi::?'a. ∑j::nat≤?p. ?l j i * x j›*) if_distrib (*‹(?f::?'b ⇒ ?'a) (if ?c::bool then ?x::?'b else (?y::?'b)) = (if ?c then ?f ?x else ?f ?y)›*) cong: if_cong (*‹⟦(?b::bool) = (?c::bool); ?c ⟹ (?x::?'a) = (?u::?'a); ¬ ?c ⟹ (?y::?'a) = (?v::?'a)⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
primrec simplicial_subdivision
where
"simplicial_subdivision 0 = id"
| "simplicial_subdivision (Suc p) =
frag_extend
(λf. simplicial_cone p
(λi. (∑j≤Suc p. simplicial_vertex j f i) / (p + 2))
(simplicial_subdivision p (chain_boundary (Suc p) (frag_of f))))"
lemma simplicial_subdivision_0 [simp]:
"simplicial_subdivision p 0 = 0"
apply (induction p)
(*goals:
1. ‹simplicial_subdivision 0 0 = 0›
2. ‹⋀p. simplicial_subdivision p 0 = 0 ⟹ simplicial_subdivision (Suc p) 0 = 0›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma simplicial_subdivision_diff:
"simplicial_subdivision p (c1-c2) = simplicial_subdivision p c1 - simplicial_subdivision p c2"
apply (induction p)
(*goals:
1. ‹simplicial_subdivision (0::nat) ((c1::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) - (c2::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) = simplicial_subdivision (0::nat) c1 - simplicial_subdivision (0::nat) c2›
2. ‹⋀p::nat. simplicial_subdivision p ((c1::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) - (c2::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) = simplicial_subdivision p c1 - simplicial_subdivision p c2 ⟹ simplicial_subdivision (Suc p) (c1 - c2) = simplicial_subdivision (Suc p) c1 - simplicial_subdivision (Suc p) c2›
discuss goal 1*)
apply ((auto simp: frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*))[1])
(*discuss goal 2*)
apply ((auto simp: frag_extend_diff (*‹frag_extend (?f::?'b::type ⇒ ?'a::type ⇒₀ int) ((?a::?'b::type ⇒₀ int) - (?b::?'b::type ⇒₀ int)) = frag_extend ?f ?a - frag_extend ?f ?b›*))[1])
(*proven 2 subgoals*) .
lemma simplicial_subdivision_of:
"simplicial_subdivision p (frag_of f) =
(if p = 0 then frag_of f
else simplicial_cone (p -1)
(λi. (∑j≤p. simplicial_vertex j f i) / (Suc p))
(simplicial_subdivision (p -1) (chain_boundary p (frag_of f))))"
apply (induction p)
(*goals:
1. ‹simplicial_subdivision 0 (frag_of f) = (if 0 = 0 then frag_of f else simplicial_cone (0 - 1) (λi. (∑j≤0. simplicial_vertex j f i) / real (Suc 0)) (simplicial_subdivision (0 - 1) (chain_boundary 0 (frag_of f))))›
2. ‹⋀p. simplicial_subdivision p (frag_of f) = (if p = 0 then frag_of f else simplicial_cone (p - 1) (λi. (∑j≤p. simplicial_vertex j f i) / real (Suc p)) (simplicial_subdivision (p - 1) (chain_boundary p (frag_of f)))) ⟹ simplicial_subdivision (Suc p) (frag_of f) = (if Suc p = 0 then frag_of f else simplicial_cone (Suc p - 1) (λi. (∑j≤Suc p. simplicial_vertex j f i) / real (Suc (Suc p))) (simplicial_subdivision (Suc p - 1) (chain_boundary (Suc p) (frag_of f))))›
discuss goal 1*)
apply ((auto simp: add.commute (*‹(?a::?'a) + (?b::?'a) = ?b + ?a›*))[1])
(*discuss goal 2*)
apply ((auto simp: add.commute (*‹?a + ?b = ?b + ?a›*))[1])
(*proven 2 subgoals*) .
lemma simplicial_chain_simplicial_subdivision:
"simplicial_chain p S c
⟹ simplicial_chain p S (simplicial_subdivision p c)"
proof (induction p arbitrary: S c)
(*goals:
1. ‹⋀S c. simplicial_chain 0 S c ⟹ simplicial_chain 0 S (simplicial_subdivision 0 c)›
2. ‹⋀p S c. ⟦⋀S c. simplicial_chain p S c ⟹ simplicial_chain p S (simplicial_subdivision p c); simplicial_chain (Suc p) S c⟧ ⟹ simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) c)›*)
case (Suc p) (*‹simplicial_chain p ?S ?c ⟹ simplicial_chain p ?S (simplicial_subdivision p ?c)› ‹simplicial_chain (Suc p) S c›*)
show "?case"
(*goal: ‹simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) c)›*)
using Suc.prems[unfolded simplicial_chain_def] (*‹Poly_Mapping.keys c ⊆ Collect (simplicial_simplex (Suc p) S)›*) proof (induction c rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) 0)›
2. ‹⋀x. x ∈ Collect (simplicial_simplex (Suc p) S) ⟹ simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) (frag_of x))›
3. ‹⋀a b. ⟦simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) a); simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) b)⟧ ⟹ simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) (a - b))›*)
case (one f) (*‹f ∈ Collect (simplicial_simplex (Suc p) S)›*)
then have f: "simplicial_simplex (Suc p) S f"
by auto
then have "simplicial_chain p (f ` standard_simplex (Suc p))
(simplicial_subdivision p (chain_boundary (Suc p) (frag_of f)))"
by (metis Suc.IH (*‹simplicial_chain p ?S ?c ⟹ simplicial_chain p ?S (simplicial_subdivision p ?c)›*) diff_Suc_1 (*‹Suc ?n - 1 = ?n›*) simplicial_chain_boundary (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain (?p - 1) ?S (chain_boundary ?p ?c)›*) simplicial_chain_of (*‹simplicial_chain ?p ?S (frag_of ?c) = simplicial_simplex ?p ?S ?c›*) simplicial_simplex (*‹simplicial_simplex ?p ?S ?f = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l. ?f = oriented_simplex ?p l))›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*))
moreover obtain l where l: "⋀x. x ∈ standard_simplex (Suc p) ⟹ (λi. (∑j≤Suc p. l j i * x j)) ∈ S" and feq: "f = oriented_simplex (Suc p) l"
(*goal: ‹(⋀l. ⟦⋀x. x ∈ standard_simplex (Suc p) ⟹ (λi. ∑j≤Suc p. l j i * x j) ∈ S; f = oriented_simplex (Suc p) l⟧ ⟹ thesis) ⟹ thesis›*)
using f (*‹simplicial_simplex (Suc p) S f›*) by (fastforce simp: simplicial_simplex (*‹simplicial_simplex ?p ?S ?f = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l. ?f = oriented_simplex ?p l))›*) oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) simp del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
have "(λi. (1 - u) * ((∑j≤Suc p. simplicial_vertex j f i) / (real p + 2)) + u * y i) ∈ S" if "0 ≤ u" "u ≤ 1" and y: "y ∈ f ` standard_simplex (Suc p)" for y and u
proof (-)
(*goal: ‹(λi. (1 - u) * ((∑j≤Suc p. simplicial_vertex j f i) / (real p + 2)) + u * y i) ∈ S›*)
obtain x where x: "x ∈ standard_simplex (Suc p)" and yeq: "y = oriented_simplex (Suc p) l x"
(*goal: ‹(⋀x::nat ⇒ real. ⟦x ∈ standard_simplex (Suc (p::nat)); (y::nat ⇒ real) = oriented_simplex (Suc p) (l::nat ⇒ nat ⇒ real) x⟧ ⟹ thesis::bool) ⟹ thesis›*)
using y (*‹y ∈ f ` standard_simplex (Suc p)›*) feq (*‹f = oriented_simplex (Suc p) l›*) by blast
have "(λi. ∑j≤Suc p. l j i * ((if j ≤ Suc p then (1 - u) * inverse (p + 2) + u * x j else 0))) ∈ S"
proof (rule l (*‹?x ∈ standard_simplex (Suc p) ⟹ (λi. ∑j≤Suc p. l j i * ?x j) ∈ S›*))
(*goal: ‹(λj::nat. if j ≤ Suc (p::nat) then ((1::real) - (u::real)) * inverse (real (p + (2::nat))) + u * (x::nat ⇒ real) j else (0::real)) ∈ standard_simplex (Suc p)›*)
have "inverse (2 + real p) ≤ 1" "(2 + real p) * ((1 - u) * inverse (2 + real p)) + u = 1"
(*goals:
1. ‹inverse (2 + real p) ≤ 1›
2. ‹(2 + real p) * ((1 - u) * inverse (2 + real p)) + u = 1›
discuss goal 1*)
apply ((auto simp add: field_split_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 65 facts*))[1])
(*discuss goal 2*)
apply ((auto simp add: field_split_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 65 facts*))[1])
(*proven 2 subgoals*) .
then show "(λj. if j ≤ Suc p then (1 - u) * inverse (real (p + 2)) + u * x j else 0) ∈ standard_simplex (Suc p)"
using x (*‹x ∈ standard_simplex (Suc p)›*) ‹0 ≤ u› (*‹0 ≤ u›*) ‹u ≤ 1› (*‹u ≤ 1›*) by (simp add: sum.distrib (*‹(∑x∈?A. ?g x + ?h x) = sum ?g ?A + sum ?h ?A›*) standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*) linepath_le_1 (*‹⟦?a ≤ 1; ?b ≤ 1; 0 ≤ ?u; ?u ≤ 1⟧ ⟹ (1 - ?u) * ?a + ?u * ?b ≤ 1›*) flip: sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*) del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
qed
moreover have "(λi. ∑j≤Suc p. l j i * ((1 - u) * inverse (2 + real p) + u * x j))
= (λi. (1 - u) * (∑j≤Suc p. l j i) / (real p + 2) + u * (∑j≤Suc p. l j i * x j))"
proof (standard)
(*goal: ‹⋀i. (∑j≤Suc p. l j i * ((1 - u) * inverse (2 + real p) + u * x j)) = (1 - u) * (∑j≤Suc p. l j i) / (real p + 2) + u * (∑j≤Suc p. l j i * x j)›*)
fix i
have "(∑j≤Suc p. l j i * ((1 - u) * inverse (2 + real p) + u * x j))
= (∑j≤Suc p. (1 - u) * l j i / (real p + 2) + u * l j i * x j)" (is "?lhs = _")
by (simp add: field_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 77 facts*) cong: sum.cong (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B ⟹ (?g::?'b ⇒ ?'a) x = (?h::?'b ⇒ ?'a) x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
also (*calculation: ‹(∑j≤Suc p. l j i * ((1 - u) * inverse (2 + real p) + u * x j)) = (∑j≤Suc p. (1 - u) * l j i / (real p + 2) + u * l j i * x j)›*) have "… = (1 - u) * (∑j≤Suc p. l j i) / (real p + 2) + u * (∑j≤Suc p. l j i * x j)" (is "_ = ?rhs")
by (simp add: sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*) sum.distrib (*‹(∑x∈?A. ?g x + ?h x) = sum ?g ?A + sum ?h ?A›*) sum_divide_distrib (*‹sum ?f ?A / ?r = (∑n∈?A. ?f n / ?r)›*) mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*) del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
finally (*calculation: ‹(∑j≤Suc p. l j i * ((1 - u) * inverse (2 + real p) + u * x j)) = (1 - u) * (∑j≤Suc p. l j i) / (real p + 2) + u * (∑j≤Suc p. l j i * x j)›*) show "?lhs = ?rhs" .
qed
ultimately show "?thesis"
(*goal: ‹(λi. (1 - u) * ((∑j≤Suc p. simplicial_vertex j f i) / (real p + 2)) + u * y i) ∈ S›*)
using feq (*‹f = oriented_simplex (Suc p) l›*) x (*‹x ∈ standard_simplex (Suc p)›*) yeq (*‹y = oriented_simplex (Suc p) l x›*) apply (simp add: simplicial_vertex_oriented_simplex (*‹simplicial_vertex (?i::nat) (oriented_simplex (?p::nat) (?l::nat ⇒ ?'a ⇒ real)) = (if ?i ≤ ?p then ?l ?i else undefined)›*))
(*goal: ‹(λi. (1 - u) * ((∑j≤Suc p. simplicial_vertex j f i) / (real p + 2)) + u * y i) ∈ S›*)
by (simp add: oriented_simplex_def (*‹oriented_simplex (?p::nat) (?l::nat ⇒ ?'a ⇒ real) ≡ λx::nat ⇒ real∈standard_simplex ?p. λi::?'a. ∑j::nat≤?p. ?l j i * x j›*))
qed
ultimately show "?case"
(*goal: ‹simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) (frag_of f))›*)
by (simp add: simplicial_chain_simplicial_cone (*‹⟦simplicial_chain ?p ?S ?c; ⋀x u. ⟦0 ≤ u; u ≤ 1; x ∈ ?S⟧ ⟹ (λi. (1 - u) * ?v i + u * x i) ∈ ?T⟧ ⟹ simplicial_chain (Suc ?p) ?T (simplicial_cone ?p ?v ?c)›*))
next
(*goals:
1. ‹simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) 0)›
2. ‹⋀a b. ⟦simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) a); simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) b)⟧ ⟹ simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) (a - b))›*)
case (diff a b) (*‹simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) a)› ‹simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) b)›*)
then show "?case"
(*goal: ‹simplicial_chain (Suc (p::nat)) (S::(nat ⇒ real) set) (simplicial_subdivision (Suc p) ((a::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) - (b::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)))›*)
by (metis simplicial_chain_diff (*‹⟦simplicial_chain ?p ?S ?c1.0; simplicial_chain ?p ?S ?c2.0⟧ ⟹ simplicial_chain ?p ?S (?c1.0 - ?c2.0)›*) simplicial_subdivision_diff (*‹simplicial_subdivision ?p (?c1.0 - ?c2.0) = simplicial_subdivision ?p ?c1.0 - simplicial_subdivision ?p ?c2.0›*))
qed (auto)
(*solved the remaining goal: ‹simplicial_chain (Suc p) S (simplicial_subdivision (Suc p) 0)›*)
qed (auto)
(*solved the remaining goal: ‹⋀S c. simplicial_chain 0 S c ⟹ simplicial_chain 0 S (simplicial_subdivision 0 c)›*)
lemma chain_boundary_simplicial_subdivision:
"simplicial_chain p S c
⟹ chain_boundary p (simplicial_subdivision p c) = simplicial_subdivision (p -1) (chain_boundary p c)"
proof (induction p arbitrary: c)
(*goals:
1. ‹⋀c. simplicial_chain 0 S c ⟹ chain_boundary 0 (simplicial_subdivision 0 c) = simplicial_subdivision (0 - 1) (chain_boundary 0 c)›
2. ‹⋀p c. ⟦⋀c. simplicial_chain p S c ⟹ chain_boundary p (simplicial_subdivision p c) = simplicial_subdivision (p - 1) (chain_boundary p c); simplicial_chain (Suc p) S c⟧ ⟹ chain_boundary (Suc p) (simplicial_subdivision (Suc p) c) = simplicial_subdivision (Suc p - 1) (chain_boundary (Suc p) c)›*)
case (Suc p) (*‹simplicial_chain (p::nat) (S::(nat ⇒ real) set) (?c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) ⟹ chain_boundary p (simplicial_subdivision p ?c) = simplicial_subdivision (p - (1::nat)) (chain_boundary p ?c)› ‹simplicial_chain (Suc (p::nat)) (S::(nat ⇒ real) set) (c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)›*)
show "?case"
(*goal: ‹chain_boundary (Suc (p::nat)) (simplicial_subdivision (Suc p) (c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) = simplicial_subdivision (Suc p - (1::nat)) (chain_boundary (Suc p) c)›*)
using Suc.prems[unfolded simplicial_chain_def] (*‹Poly_Mapping.keys c ⊆ Collect (simplicial_simplex (Suc p) S)›*) proof (induction c rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹chain_boundary (Suc (p::nat)) (simplicial_subdivision (Suc p) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) = simplicial_subdivision (Suc p - (1::nat)) (chain_boundary (Suc p) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int))›
2. ‹⋀x::(nat ⇒ real) ⇒ nat ⇒ real. x ∈ Collect (simplicial_simplex (Suc (p::nat)) (S::(nat ⇒ real) set)) ⟹ chain_boundary (Suc p) (simplicial_subdivision (Suc p) (frag_of x)) = simplicial_subdivision (Suc p - (1::nat)) (chain_boundary (Suc p) (frag_of x))›
3. ‹⋀(a::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) b::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int. ⟦chain_boundary (Suc (p::nat)) (simplicial_subdivision (Suc p) a) = simplicial_subdivision (Suc p - (1::nat)) (chain_boundary (Suc p) a); chain_boundary (Suc p) (simplicial_subdivision (Suc p) b) = simplicial_subdivision (Suc p - (1::nat)) (chain_boundary (Suc p) b)⟧ ⟹ chain_boundary (Suc p) (simplicial_subdivision (Suc p) (a - b)) = simplicial_subdivision (Suc p - (1::nat)) (chain_boundary (Suc p) (a - b))›*)
case (one f) (*‹f ∈ Collect (simplicial_simplex (Suc p) S)›*)
then have f: "simplicial_simplex (Suc p) S f"
by simp
then have "simplicial_chain p S (simplicial_subdivision p (chain_boundary (Suc p) (frag_of f)))"
by (metis diff_Suc_1 (*‹Suc ?n - 1 = ?n›*) simplicial_chain_boundary (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain (?p - 1) ?S (chain_boundary ?p ?c)›*) simplicial_chain_of (*‹simplicial_chain ?p ?S (frag_of ?c) = simplicial_simplex ?p ?S ?c›*) simplicial_chain_simplicial_subdivision (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain ?p ?S (simplicial_subdivision ?p ?c)›*))
moreover have "simplicial_chain p S (chain_boundary (Suc p) (frag_of f))"
using one (*‹f ∈ Collect (simplicial_simplex (Suc p) S)›*) simplicial_chain_boundary (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain (?p - 1) ?S (chain_boundary ?p ?c)›*) simplicial_chain_of (*‹simplicial_chain ?p ?S (frag_of ?c) = simplicial_simplex ?p ?S ?c›*) by fastforce
moreover have "simplicial_subdivision (p - Suc 0) (chain_boundary p (chain_boundary (Suc p) (frag_of f))) = 0"
by (metis f (*‹simplicial_simplex (Suc p) S f›*) chain_boundary_boundary_alt (*‹singular_chain (Suc ?p) ?X ?c ⟹ chain_boundary ?p (chain_boundary (Suc ?p) ?c) = 0›*) simplicial_simplex_def (*‹simplicial_simplex ?p ?S ?f ≡ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f ∧ (∃l. ?f = oriented_simplex ?p l)›*) simplicial_subdivision_0 (*‹simplicial_subdivision ?p 0 = 0›*) singular_chain_of (*‹singular_chain ?p ?X (frag_of ?c) = singular_simplex ?p ?X ?c›*))
ultimately show "?case"
(*goal: ‹chain_boundary (Suc p) (simplicial_subdivision (Suc p) (frag_of f)) = simplicial_subdivision (Suc p - 1) (chain_boundary (Suc p) (frag_of f))›*)
using chain_boundary_simplicial_cone (*‹simplicial_chain ?p ?S ?c ⟹ chain_boundary (Suc ?p) (simplicial_cone ?p ?v ?c) = ?c - (if ?p = 0 then frag_extend (λf. frag_of (λu∈standard_simplex ?p. ?v)) ?c else simplicial_cone (?p - 1) ?v (chain_boundary ?p ?c))›*) Suc (*‹simplicial_chain (p::nat) (S::(nat ⇒ real) set) (?c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) ⟹ chain_boundary p (simplicial_subdivision p ?c) = simplicial_subdivision (p - (1::nat)) (chain_boundary p ?c)› ‹simplicial_chain (Suc (p::nat)) (S::(nat ⇒ real) set) (c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)›*) by (auto simp: chain_boundary_of (*‹chain_boundary (?p::nat) (frag_of (?f::(nat ⇒ real) ⇒ ?'a::type)) = (if ?p = (0::nat) then 0::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int else ∑k::nat≤?p. frag_cmul ((- (1::int)) ^ k) (frag_of (singular_face ?p k ?f)))›*) frag_extend_diff (*‹frag_extend (?f::?'b::type ⇒ ?'a::type ⇒₀ int) ((?a::?'b::type ⇒₀ int) - (?b::?'b::type ⇒₀ int)) = frag_extend ?f ?a - frag_extend ?f ?b›*) simplicial_cone_def (*‹simplicial_cone (?p::nat) (?v::nat ⇒ real) ≡ frag_extend (frag_of ∘ simplex_cone ?p ?v)›*))
next
(*goals:
1. ‹chain_boundary (Suc p) (simplicial_subdivision (Suc p) 0) = simplicial_subdivision (Suc p - 1) (chain_boundary (Suc p) 0)›
2. ‹⋀a b. ⟦chain_boundary (Suc p) (simplicial_subdivision (Suc p) a) = simplicial_subdivision (Suc p - 1) (chain_boundary (Suc p) a); chain_boundary (Suc p) (simplicial_subdivision (Suc p) b) = simplicial_subdivision (Suc p - 1) (chain_boundary (Suc p) b)⟧ ⟹ chain_boundary (Suc p) (simplicial_subdivision (Suc p) (a - b)) = simplicial_subdivision (Suc p - 1) (chain_boundary (Suc p) (a - b))›*)
case (diff a b) (*‹chain_boundary (Suc p) (simplicial_subdivision (Suc p) a) = simplicial_subdivision (Suc p - 1) (chain_boundary (Suc p) a)› ‹chain_boundary (Suc p) (simplicial_subdivision (Suc p) b) = simplicial_subdivision (Suc p - 1) (chain_boundary (Suc p) b)›*)
then show "?case"
(*goal: ‹chain_boundary (Suc p) (simplicial_subdivision (Suc p) (a - b)) = simplicial_subdivision (Suc p - 1) (chain_boundary (Suc p) (a - b))›*)
by (simp add: simplicial_subdivision_diff (*‹simplicial_subdivision (?p::nat) ((?c1.0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) - (?c2.0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) = simplicial_subdivision ?p ?c1.0 - simplicial_subdivision ?p ?c2.0›*) chain_boundary_diff (*‹chain_boundary (?p::nat) ((?a::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int) - (?b::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int)) = chain_boundary ?p ?a - chain_boundary ?p ?b›*) frag_extend_diff (*‹frag_extend (?f::?'b::type ⇒ ?'a::type ⇒₀ int) ((?a::?'b::type ⇒₀ int) - (?b::?'b::type ⇒₀ int)) = frag_extend ?f ?a - frag_extend ?f ?b›*))
qed (auto)
(*solved the remaining goal: ‹chain_boundary (Suc (p::nat)) (simplicial_subdivision (Suc p) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) = simplicial_subdivision (Suc p - (1::nat)) (chain_boundary (Suc p) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int))›*)
qed (auto)
(*solved the remaining goal: ‹⋀c. simplicial_chain 0 S c ⟹ chain_boundary 0 (simplicial_subdivision 0 c) = simplicial_subdivision (0 - 1) (chain_boundary 0 c)›*)
text ‹A MESS AND USED ONLY ONCE›
lemma simplicial_subdivision_shrinks:
"⟦simplicial_chain p S c;
⋀f x y. ⟦f ∈ Poly_Mapping.keys c; x ∈ standard_simplex p; y ∈ standard_simplex p⟧ ⟹ ¦f x k - f y k¦ ≤ d;
f ∈ Poly_Mapping.keys(simplicial_subdivision p c);
x ∈ standard_simplex p; y ∈ standard_simplex p⟧
⟹ ¦f x k - f y k¦ ≤ (p / (Suc p)) * d"
proof (induction p arbitrary: d c f x y)
(*goals:
1. ‹⋀d c f x y. ⟦simplicial_chain 0 S c; ⋀f x y. ⟦f ∈ Poly_Mapping.keys c; x ∈ standard_simplex 0; y ∈ standard_simplex 0⟧ ⟹ ¦f x k - f y k¦ ≤ d; f ∈ Poly_Mapping.keys (simplicial_subdivision 0 c); x ∈ standard_simplex 0; y ∈ standard_simplex 0⟧ ⟹ ¦f x k - f y k¦ ≤ real 0 / real (Suc 0) * d›
2. ‹⋀p d c f x y. ⟦⋀d c f x y. ⟦simplicial_chain p S c; ⋀f x y. ⟦f ∈ Poly_Mapping.keys c; x ∈ standard_simplex p; y ∈ standard_simplex p⟧ ⟹ ¦f x k - f y k¦ ≤ d; f ∈ Poly_Mapping.keys (simplicial_subdivision p c); x ∈ standard_simplex p; y ∈ standard_simplex p⟧ ⟹ ¦f x k - f y k¦ ≤ real p / real (Suc p) * d; simplicial_chain (Suc p) S c; ⋀f x y. ⟦f ∈ Poly_Mapping.keys c; x ∈ standard_simplex (Suc p); y ∈ standard_simplex (Suc p)⟧ ⟹ ¦f x k - f y k¦ ≤ d; f ∈ Poly_Mapping.keys (simplicial_subdivision (Suc p) c); x ∈ standard_simplex (Suc p); y ∈ standard_simplex (Suc p)⟧ ⟹ ¦f x k - f y k¦ ≤ real (Suc p) / real (Suc (Suc p)) * d›*)
case (Suc p) (*‹⟦simplicial_chain p S ?c; ⋀f x y. ⟦f ∈ Poly_Mapping.keys ?c; x ∈ standard_simplex p; y ∈ standard_simplex p⟧ ⟹ ¦f x k - f y k¦ ≤ ?d; ?f ∈ Poly_Mapping.keys (simplicial_subdivision p ?c); ?x ∈ standard_simplex p; ?y ∈ standard_simplex p⟧ ⟹ ¦?f ?x k - ?f ?y k¦ ≤ real p / real (Suc p) * ?d› ‹simplicial_chain (Suc p) S c› ‹⟦(?f::(nat ⇒ real) ⇒ nat ⇒ real) ∈ Poly_Mapping.keys (c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int); (?x::nat ⇒ real) ∈ standard_simplex (Suc (p::nat)); (?y::nat ⇒ real) ∈ standard_simplex (Suc p)⟧ ⟹ ¦?f ?x (k::nat) - ?f ?y k¦ ≤ (d::real)› ‹f ∈ Poly_Mapping.keys (simplicial_subdivision (Suc p) c)› ‹(x::nat ⇒ real) ∈ standard_simplex (Suc (p::nat))› ‹y ∈ standard_simplex (Suc p)›*)
define Sigp where "Sigp ≡ λf:: (nat ⇒ real) ⇒ nat ⇒ real. λi. (∑j≤Suc p. simplicial_vertex j f i) / real (p + 2)"
define CB where "CB ≡ λf::(nat ⇒ real) ⇒ nat ⇒ real. chain_boundary (Suc p) (frag_of f)"
have "*": "Poly_Mapping.keys
(simplicial_cone p (Sigp f)
(simplicial_subdivision p (CB f)))
⊆ {f. ∀x∈standard_simplex (Suc p). ∀y∈standard_simplex (Suc p).
¦f x k - f y k¦ ≤ Suc p / (real p + 2) * d}" (is "?lhs ⊆ ?rhs") if f: "f ∈ Poly_Mapping.keys c" for f
proof (-)
(*goal: ‹Poly_Mapping.keys (simplicial_cone p (Sigp f) (simplicial_subdivision p (CB f))) ⊆ {f. ∀x∈standard_simplex (Suc p). ∀y∈standard_simplex (Suc p). ¦f x k - f y k¦ ≤ real (Suc p) / (real p + 2) * d}›*)
have ssf: "simplicial_simplex (Suc p) S f"
using Suc.prems(1) (*‹simplicial_chain (Suc (p::nat)) (S::(nat ⇒ real) set) (c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)›*) simplicial_chain_def (*‹simplicial_chain ?p ?S ?c ≡ Poly_Mapping.keys ?c ⊆ Collect (simplicial_simplex ?p ?S)›*) that (*‹f ∈ Poly_Mapping.keys c›*) by auto
have 2: "⋀x y. ⟦x ∈ standard_simplex (Suc p); y ∈ standard_simplex (Suc p)⟧ ⟹ ¦f x k - f y k¦ ≤ d"
by (meson Suc.prems( (*‹⟦?f ∈ Poly_Mapping.keys c; ?x ∈ standard_simplex (Suc p); ?y ∈ standard_simplex (Suc p)⟧ ⟹ ¦?f ?x k - ?f ?y k¦ ≤ d›*) 2) f (*‹f ∈ Poly_Mapping.keys c›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) le_Suc_eq (*‹(?m ≤ Suc ?n) = (?m ≤ ?n ∨ ?m = Suc ?n)›*) order_refl (*‹?x ≤ ?x›*) standard_simplex_mono (*‹?p ≤ ?q ⟹ standard_simplex ?p ⊆ standard_simplex ?q›*))
have sub: "Poly_Mapping.keys ((frag_of ∘ simplex_cone p (Sigp f)) g) ⊆ ?rhs" if "g ∈ Poly_Mapping.keys (simplicial_subdivision p (CB f))" for g
proof (-)
(*goal: ‹Poly_Mapping.keys ((frag_of ∘ simplex_cone p (Sigp f)) g) ⊆ {f. ∀x∈standard_simplex (Suc p). ∀y∈standard_simplex (Suc p). ¦f x k - f y k¦ ≤ real (Suc p) / (real p + 2) * d}›*)
have 1: "simplicial_chain p S (CB f)"
unfolding CB_def
(*goal: ‹simplicial_chain p S (chain_boundary (Suc p) (frag_of f))›*)
using ssf (*‹simplicial_simplex (Suc (p::nat)) (S::(nat ⇒ real) set) (f::(nat ⇒ real) ⇒ nat ⇒ real)›*) simplicial_chain_boundary (*‹simplicial_chain (?p::nat) (?S::(?'a ⇒ real) set) (?c::((nat ⇒ real) ⇒ ?'a ⇒ real) ⇒₀ int) ⟹ simplicial_chain (?p - (1::nat)) ?S (chain_boundary ?p ?c)›*) simplicial_chain_of (*‹simplicial_chain ?p ?S (frag_of ?c) = simplicial_simplex ?p ?S ?c›*) by fastforce
have "simplicial_chain (Suc p) (f ` standard_simplex(Suc p)) (frag_of f)"
by (metis simplicial_chain_of (*‹simplicial_chain (?p::nat) (?S::(?'a::type ⇒ real) set) (frag_of (?c::(nat ⇒ real) ⇒ ?'a::type ⇒ real)) = simplicial_simplex ?p ?S ?c›*) simplicial_simplex (*‹simplicial_simplex (?p::nat) (?S::(?'a::type ⇒ real) set) (?f::(nat ⇒ real) ⇒ ?'a::type ⇒ real) = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l::nat ⇒ ?'a::type ⇒ real. ?f = oriented_simplex ?p l))›*) ssf (*‹simplicial_simplex (Suc (p::nat)) (S::(nat ⇒ real) set) (f::(nat ⇒ real) ⇒ nat ⇒ real)›*) subset_refl (*‹(?A::?'a::type set) ⊆ ?A›*))
then have sc_sub: "Poly_Mapping.keys (CB f)
⊆ Collect (simplicial_simplex p (f ` standard_simplex (Suc p)))"
by (metis diff_Suc_1 (*‹Suc ?n - 1 = ?n›*) simplicial_chain_boundary (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain (?p - 1) ?S (chain_boundary ?p ?c)›*) simplicial_chain_def (*‹simplicial_chain ?p ?S ?c ≡ Poly_Mapping.keys ?c ⊆ Collect (simplicial_simplex ?p ?S)›*) CB_def (*‹CB ≡ λf. chain_boundary (Suc p) (frag_of f)›*))
have led: "⋀h x y. ⟦h ∈ Poly_Mapping.keys (CB f);
x ∈ standard_simplex p; y ∈ standard_simplex p⟧ ⟹ ¦h x k - h y k¦ ≤ d"
using Suc.prems(2) (*‹⟦?f ∈ Poly_Mapping.keys c; ?x ∈ standard_simplex (Suc p); ?y ∈ standard_simplex (Suc p)⟧ ⟹ ¦?f ?x k - ?f ?y k¦ ≤ d›*) f (*‹(f::(nat ⇒ real) ⇒ nat ⇒ real) ∈ Poly_Mapping.keys (c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)›*) sc_sub (*‹Poly_Mapping.keys (CB f) ⊆ Collect (simplicial_simplex p (f ` standard_simplex (Suc p)))›*) apply (simp add: simplicial_simplex (*‹simplicial_simplex ?p ?S ?f = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l. ?f = oriented_simplex ?p l))›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*))
(*goal: ‹⋀h x y. ⟦h ∈ Poly_Mapping.keys (CB f); x ∈ standard_simplex p; y ∈ standard_simplex p⟧ ⟹ ¦h x k - h y k¦ ≤ d›*)
by metis
have "⋀f' x y. ⟦f' ∈ Poly_Mapping.keys (simplicial_subdivision p (CB f));
x ∈ standard_simplex p; y ∈ standard_simplex p⟧
⟹ ¦f' x k - f' y k¦ ≤ (p / (Suc p)) * d"
by (blast intro: led (*‹⟦?h ∈ Poly_Mapping.keys (CB f); ?x ∈ standard_simplex p; ?y ∈ standard_simplex p⟧ ⟹ ¦?h ?x k - ?h ?y k¦ ≤ d›*) Suc.IH [of "CB f", OF 1] (*‹⟦⋀f x y. ⟦f ∈ Poly_Mapping.keys (CB f); x ∈ standard_simplex p; y ∈ standard_simplex p⟧ ⟹ ¦f x k - f y k¦ ≤ ?d; ?f ∈ Poly_Mapping.keys (simplicial_subdivision p (CB f)); ?x ∈ standard_simplex p; ?y ∈ standard_simplex p⟧ ⟹ ¦?f ?x k - ?f ?y k¦ ≤ real p / real (Suc p) * ?d›*))
then have g: "⋀x y. ⟦x ∈ standard_simplex p; y ∈ standard_simplex p⟧ ⟹ ¦g x k - g y k¦ ≤ (p / (Suc p)) * d"
using that (*‹(g::(nat ⇒ real) ⇒ nat ⇒ real) ∈ Poly_Mapping.keys (simplicial_subdivision (p::nat) ((CB::((nat ⇒ real) ⇒ nat ⇒ real) ⇒ ((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) (f::(nat ⇒ real) ⇒ nat ⇒ real)))›*) by blast
have "d ≥ 0"
using Suc.prems(2)[OF f] (*‹⟦(?x::nat ⇒ real) ∈ standard_simplex (Suc (p::nat)); (?y::nat ⇒ real) ∈ standard_simplex (Suc p)⟧ ⟹ ¦(f::(nat ⇒ real) ⇒ nat ⇒ real) ?x (k::nat) - f ?y k¦ ≤ (d::real)›*) ‹x ∈ standard_simplex (Suc p)› (*‹x ∈ standard_simplex (Suc p)›*) by force
have 3: "simplex_cone p (Sigp f) g ∈ ?rhs"
proof (-)
(*goal: ‹simplex_cone (p::nat) ((Sigp::((nat ⇒ real) ⇒ nat ⇒ real) ⇒ nat ⇒ real) (f::(nat ⇒ real) ⇒ nat ⇒ real)) (g::(nat ⇒ real) ⇒ nat ⇒ real) ∈ {f::(nat ⇒ real) ⇒ nat ⇒ real. ∀x::nat ⇒ real∈standard_simplex (Suc p). ∀y::nat ⇒ real∈standard_simplex (Suc p). ¦f x (k::nat) - f y k¦ ≤ real (Suc p) / (real p + (2::real)) * (d::real)}›*)
have "simplicial_simplex p (f ` standard_simplex(Suc p)) g"
by (metis (mono_tags, opaque_lifting) sc_sub (*‹Poly_Mapping.keys (CB f) ⊆ Collect (simplicial_simplex p (f ` standard_simplex (Suc p)))›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) simplicial_chain_def (*‹simplicial_chain ?p ?S ?c ≡ Poly_Mapping.keys ?c ⊆ Collect (simplicial_simplex ?p ?S)›*) simplicial_chain_simplicial_subdivision (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain ?p ?S (simplicial_subdivision ?p ?c)›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) that (*‹g ∈ Poly_Mapping.keys (simplicial_subdivision p (CB f))›*))
then obtain m where m: "g ` standard_simplex p ⊆ f ` standard_simplex (Suc p)" and geq: "g = oriented_simplex p m"
(*goal: ‹(⋀m. ⟦g ` standard_simplex p ⊆ f ` standard_simplex (Suc p); g = oriented_simplex p m⟧ ⟹ thesis) ⟹ thesis›*)
using ssf (*‹simplicial_simplex (Suc p) S f›*) by (auto simp: simplicial_simplex (*‹simplicial_simplex (?p::nat) (?S::(?'a ⇒ real) set) (?f::(nat ⇒ real) ⇒ ?'a ⇒ real) = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l::nat ⇒ ?'a ⇒ real. ?f = oriented_simplex ?p l))›*))
have m_in_gim: "m i ∈ g ` standard_simplex p" if "i ≤ p" for i
proof (standard)
(*goals:
1. ‹m i = g ?x›
2. ‹?x ∈ standard_simplex p›*)
show "m i = g (λj. if j = i then 1 else 0)"
by (simp add: geq (*‹g = oriented_simplex p m›*) oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) that (*‹i ≤ p›*) if_distrib (*‹?f (if ?c then ?x else ?y) = (if ?c then ?f ?x else ?f ?y)›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
show "(λj. if j = i then 1 else 0) ∈ standard_simplex p"
by (simp add: oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) that (*‹i ≤ p›*))
qed
obtain l where l: "f ` standard_simplex (Suc p) ⊆ S" and feq: "f = oriented_simplex (Suc p) l"
(*goal: ‹(⋀l. ⟦f ` standard_simplex (Suc p) ⊆ S; f = oriented_simplex (Suc p) l⟧ ⟹ thesis) ⟹ thesis›*)
using ssf (*‹simplicial_simplex (Suc p) S f›*) by (auto simp: simplicial_simplex (*‹simplicial_simplex ?p ?S ?f = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l. ?f = oriented_simplex ?p l))›*))
show "?thesis"
(*goal: ‹simplex_cone p (Sigp f) g ∈ {f. ∀x∈standard_simplex (Suc p). ∀y∈standard_simplex (Suc p). ¦f x k - f y k¦ ≤ real (Suc p) / (real p + 2) * d}›*)
proof (clarsimp simp add: geq (*‹g = oriented_simplex p m›*) simp del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
(*goal: ‹⋀x y. ⟦x ∈ standard_simplex (Suc p); y ∈ standard_simplex (Suc p)⟧ ⟹ ¦simplex_cone p (Sigp f) (oriented_simplex p m) x k - simplex_cone p (Sigp f) (oriented_simplex p m) y k¦ ≤ (1 + real p) * d / (real p + 2)›*)
fix x and y
assume x: "x ∈ standard_simplex (Suc p)" and y: "y ∈ standard_simplex (Suc p)" (*‹(x::nat ⇒ real) ∈ standard_simplex (Suc (p::nat))› ‹(y::nat ⇒ real) ∈ standard_simplex (Suc (p::nat))›*)
then have x': "(∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>Suc p. x i = 0) ∧ (∑i≤Suc p. x i) = 1" and y': "(∀i. 0 ≤ y i ∧ y i ≤ 1) ∧ (∀i>Suc p. y i = 0) ∧ (∑i≤Suc p. y i) = 1"
apply -
(*goals:
1. ‹⟦x ∈ standard_simplex (Suc p); y ∈ standard_simplex (Suc p)⟧ ⟹ (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>Suc p. x i = 0) ∧ sum x {..Suc p} = 1›
2. ‹⟦x ∈ standard_simplex (Suc p); y ∈ standard_simplex (Suc p)⟧ ⟹ (∀i. 0 ≤ y i ∧ y i ≤ 1) ∧ (∀i>Suc p. y i = 0) ∧ sum y {..Suc p} = 1›
discuss goal 1*)
apply ((auto simp: standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*))[1])
(*discuss goal 2*)
apply ((auto simp: standard_simplex_def (*‹standard_simplex (?p::nat) ≡ {x::nat ⇒ real. (∀i::nat. (0::real) ≤ x i ∧ x i ≤ (1::real)) ∧ (∀i>?p. x i = (0::real)) ∧ sum x {..?p} = (1::real)}›*))[1])
(*proven 2 subgoals*) .
have "¦(∑j≤Suc p. (if j = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (j -1)) k * x j) -
(∑j≤Suc p. (if j = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (j -1)) k * y j)¦
≤ (1 + real p) * d / (2 + real p)"
proof (-)
(*goal: ‹¦(∑j≤Suc p. (if j = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (j - 1)) k * x j) - (∑j≤Suc p. (if j = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (j - 1)) k * y j)¦ ≤ (1 + real p) * d / (2 + real p)›*)
have zero: "¦m (s - Suc 0) k - (∑j≤Suc p. l j k) / (2 + real p)¦ ≤ (1 + real p) * d / (2 + real p)" if "0 < s" and "s ≤ Suc p" for s
proof (-)
(*goal: ‹¦m (s - Suc 0) k - (∑j≤Suc p. l j k) / (2 + real p)¦ ≤ (1 + real p) * d / (2 + real p)›*)
have "m (s - Suc 0) ∈ f ` standard_simplex (Suc p)"
using m (*‹g ` standard_simplex p ⊆ f ` standard_simplex (Suc p)›*) m_in_gim (*‹?i ≤ p ⟹ m ?i ∈ g ` standard_simplex p›*) that(2) (*‹s ≤ Suc p›*) by auto
then obtain z where eq: "m (s - Suc 0) = (λi. ∑j≤Suc p. l j i * z j)" and z: "z ∈ standard_simplex (Suc p)"
(*goal: ‹(⋀z. ⟦m (s - Suc 0) = (λi. ∑j≤Suc p. l j i * z j); z ∈ standard_simplex (Suc p)⟧ ⟹ thesis) ⟹ thesis›*)
using feq (*‹f = oriented_simplex (Suc p) l›*) unfolding oriented_simplex_def
(*goal: ‹(⋀z. ⟦m (s - Suc 0) = (λi. ∑j≤Suc p. l j i * z j); z ∈ standard_simplex (Suc p)⟧ ⟹ thesis) ⟹ thesis›*)
by auto
show "?thesis"
(*goal: ‹¦(m::nat ⇒ nat ⇒ real) ((s::nat) - Suc (0::nat)) (k::nat) - (∑j::nat≤Suc (p::nat). (l::nat ⇒ nat ⇒ real) j k) / ((2::real) + real p)¦ ≤ ((1::real) + real p) * (d::real) / ((2::real) + real p)›*)
unfolding eq
(*goal: ‹¦(∑j::nat≤Suc (p::nat). (l::nat ⇒ nat ⇒ real) j (k::nat) * (z::nat ⇒ real) j) - (∑j::nat≤Suc p. l j k) / ((2::real) + real p)¦ ≤ ((1::real) + real p) * (d::real) / ((2::real) + real p)›*)
proof (rule convex_sum_bound_le (*‹⟦⋀i. i ∈ ?I ⟹ 0 ≤ ?x i; sum ?x ?I = 1; ⋀i. i ∈ ?I ⟹ ¦?a i - ?b¦ ≤ ?δ⟧ ⟹ ¦(∑i∈?I. ?a i * ?x i) - ?b¦ ≤ ?δ›*))
(*goals:
1. ‹⋀j. j ∈ {..Suc p} ⟹ 0 ≤ z j›
2. ‹sum z {..Suc p} = 1›
3. ‹⋀j. j ∈ {..Suc p} ⟹ ¦l j k - (∑j≤Suc p. l j k) / (2 + real p)¦ ≤ (1 + real p) * d / (2 + real p)›*)
fix i
assume i: "i ∈ {..Suc p}" (*‹(i::nat) ∈ {..Suc (p::nat)}›*)
then have [simp]: "card ({..Suc p} - {i}) = Suc p"
by (simp add: card_Suc_Diff1 (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ Suc (card (?A - {?x})) = card ?A›*))
have "(∑j≤Suc p. ¦l i k / (p + 2) - l j k / (p + 2)¦) = (∑j≤Suc p. ¦l i k - l j k¦ / (p + 2))"
apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*goals:
1. ‹{..Suc p} = {..Suc p}›
2. ‹⋀x. x ∈ {..Suc p} ⟹ ¦l i k / real (p + 2) - l x k / real (p + 2)¦ = ¦l i k - l x k¦ / real (p + 2)›
discuss goal 1*)
apply (simp add: flip: diff_divide_distrib (*‹(?a - ?b) / ?c = ?a / ?c - ?b / ?c›*))
(*discuss goal 2*)
apply (simp add: flip: diff_divide_distrib (*‹(?a - ?b) / ?c = ?a / ?c - ?b / ?c›*))
(*proven 2 subgoals*) .
also (*calculation: ‹(∑j≤Suc p. ¦l i k / real (p + 2) - l j k / real (p + 2)¦) = (∑j≤Suc p. ¦l i k - l j k¦ / real (p + 2))›*) have "… = (∑j ∈ {..Suc p} - {i}. ¦l i k - l j k¦ / (p + 2))"
apply (rule sum.mono_neutral_right (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?g i = 0⟧ ⟹ sum ?g ?T = sum ?g ?S›*))
(*goals:
1. ‹finite {..Suc p}›
2. ‹{..Suc p} - {i} ⊆ {..Suc p}›
3. ‹∀ia∈{..Suc p} - ({..Suc p} - {i}). ¦l i k - l ia k¦ / real (p + 2) = 0›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
also (*calculation: ‹(∑j≤Suc p. ¦l i k / real (p + 2) - l j k / real (p + 2)¦) = (∑j∈{..Suc p} - {i}. ¦l i k - l j k¦ / real (p + 2))›*) have "… ≤ (1 + real p) * d / (p + 2)"
proof (rule sum_bounded_above_divide (*‹⟦⋀i. i ∈ ?A ⟹ ?f i ≤ ?K / of_nat (card ?A); finite ?A; ?A ≠ {}⟧ ⟹ sum ?f ?A ≤ ?K›*))
(*goals:
1. ‹⋀ia::nat. ia ∈ {..Suc (p::nat)} - {i::nat} ⟹ ¦(l::nat ⇒ nat ⇒ real) i (k::nat) - l ia k¦ / real (p + (2::nat)) ≤ ((1::real) + real p) * (d::real) / real (p + (2::nat)) / real (card ({..Suc p} - {i}))›
2. ‹finite ({..Suc (p::nat)} - {i::nat})›
3. ‹{..Suc (p::nat)} - {i::nat} ≠ {}›*)
fix i' :: nat
assume i': "i' ∈ {..Suc p} - {i}" (*‹(i'::nat) ∈ {..Suc (p::nat)} - {i::nat}›*)
have lf: "l r ∈ f ` standard_simplex(Suc p)" if "r ≤ Suc p" for r
proof (standard)
(*goals:
1. ‹l r = f ?x›
2. ‹?x ∈ standard_simplex (Suc p)›*)
show "l r = f (λj. if j = r then 1 else 0)"
using that (*‹r ≤ Suc p›*) by (simp add: feq (*‹f = oriented_simplex (Suc p) l›*) oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) if_distrib (*‹?f (if ?c then ?x else ?y) = (if ?c then ?f ?x else ?f ?y)›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
show "(λj. if j = r then 1 else 0) ∈ standard_simplex (Suc p)"
by (auto simp: oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) that (*‹r ≤ Suc p›*))
qed
show "¦l i k - l i' k¦ / real (p + 2) ≤ (1 + real p) * d / real (p + 2) / real (card ({..Suc p} - {i}))"
using i (*‹i ∈ {..Suc p}›*) i' (*‹(i'::nat) ∈ {..Suc (p::nat)} - {i::nat}›*) lf[of i] (*‹i ≤ Suc p ⟹ l i ∈ f ` standard_simplex (Suc p)›*) lf[of i'] (*‹i' ≤ Suc p ⟹ l i' ∈ f ` standard_simplex (Suc p)›*) "2" (*‹⟦?x ∈ standard_simplex (Suc p); ?y ∈ standard_simplex (Suc p)⟧ ⟹ ¦f ?x k - f ?y k¦ ≤ d›*) by (auto simp: image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*))
qed (auto)
(*solves the remaining goals:
1. ‹finite ({..Suc p} - {i})›
2. ‹{..Suc p} - {i} ≠ {}›*)
finally (*calculation: ‹(∑j≤Suc p. ¦l i k / real (p + 2) - l j k / real (p + 2)¦) ≤ (1 + real p) * d / real (p + 2)›*) have "(∑j≤Suc p. ¦l i k / (p + 2) - l j k / (p + 2)¦) ≤ (1 + real p) * d / (p + 2)" .
then have "¦∑j≤Suc p. l i k / (p + 2) - l j k / (p + 2)¦ ≤ (1 + real p) * d / (p + 2)"
by (rule order_trans [OF sum_abs] (*‹(∑i∈?A1. ¦?f1 i¦) ≤ ?z ⟹ ¦sum ?f1 ?A1¦ ≤ ?z›*))
then show "¦l i k - (∑j≤Suc p. l j k) / (2 + real p)¦ ≤ (1 + real p) * d / (2 + real p)"
by (simp add: sum_subtractf (*‹(∑x∈?A. ?f x - ?g x) = sum ?f ?A - sum ?g ?A›*) sum_divide_distrib (*‹sum ?f ?A / ?r = (∑n∈?A. ?f n / ?r)›*) del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
qed (use standard_simplex_def z in auto)
(*solves the remaining goals:
1. ‹⋀j::nat. j ∈ {..Suc (p::nat)} ⟹ (0::real) ≤ (z::nat ⇒ real) j›
2. ‹sum (z::nat ⇒ real) {..Suc (p::nat)} = (1::real)›*)
qed
have nonz: "¦m (s - Suc 0) k - m (r - Suc 0) k¦ ≤ (1 + real p) * d / (2 + real p)" (is "?lhs ≤ ?rhs") if "r < s" and "0 < r" and "r ≤ Suc p" and "s ≤ Suc p" for r and s
proof (-)
(*goal: ‹¦m (s - Suc 0) k - m (r - Suc 0) k¦ ≤ (1 + real p) * d / (2 + real p)›*)
have "?lhs ≤ (p / (Suc p)) * d"
using m_in_gim[of "r - Suc 0"] (*‹r - Suc 0 ≤ p ⟹ m (r - Suc 0) ∈ g ` standard_simplex p›*) m_in_gim[of "s - Suc 0"] (*‹s - Suc 0 ≤ p ⟹ m (s - Suc 0) ∈ g ` standard_simplex p›*) that (*‹r < s› ‹0 < r› ‹r ≤ Suc p› ‹(s::nat) ≤ Suc (p::nat)›*) g (*‹⟦?x ∈ standard_simplex p; ?y ∈ standard_simplex p⟧ ⟹ ¦g ?x k - g ?y k¦ ≤ real p / real (Suc p) * d›*) by fastforce
also (*calculation: ‹¦m (s - Suc 0) k - m (r - Suc 0) k¦ ≤ real p / real (Suc p) * d›*) have "… ≤ ?rhs"
by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) ‹0 ≤ d›)
finally (*calculation: ‹¦m (s - Suc 0) k - m (r - Suc 0) k¦ ≤ (1 + real p) * d / (2 + real p)›*) show "?thesis"
(*goal: ‹¦m (s - Suc 0) k - m (r - Suc 0) k¦ ≤ (1 + real p) * d / (2 + real p)›*) .
qed
have jj: "j ≤ Suc p ∧ j' ≤ Suc p
⟶ ¦(if j' = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (j' -1)) k -
(if j = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (j -1)) k¦
≤ (1 + real p) * d / (2 + real p)" for j and j'
using ‹0 ≤ d› (*‹0 ≤ d›*) apply (rule_tac a=j and b = "j'" in linorder_less_wlog (*‹⟦⋀a b. a < b ⟹ ?P a b; ⋀a. ?P a a; ⋀a b. ?P b a ⟹ ?P a b⟧ ⟹ ?P ?a ?b›*))
(*goals:
1. ‹⋀a b. ⟦0 ≤ d; a < b⟧ ⟹ a ≤ Suc p ∧ b ≤ Suc p ⟶ ¦(if b = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (b - 1)) k - (if a = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (a - 1)) k¦ ≤ (1 + real p) * d / (2 + real p)›
2. ‹⋀a. 0 ≤ d ⟹ a ≤ Suc p ∧ a ≤ Suc p ⟶ ¦(if a = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (a - 1)) k - (if a = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (a - 1)) k¦ ≤ (1 + real p) * d / (2 + real p)›
3. ‹⋀a b. ⟦0 ≤ d; b ≤ Suc p ∧ a ≤ Suc p ⟶ ¦(if a = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (a - 1)) k - (if b = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (b - 1)) k¦ ≤ (1 + real p) * d / (2 + real p)⟧ ⟹ a ≤ Suc p ∧ b ≤ Suc p ⟶ ¦(if b = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (b - 1)) k - (if a = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (a - 1)) k¦ ≤ (1 + real p) * d / (2 + real p)›
discuss goal 1*)
apply (force simp: zero (*‹⟦0 < ?s; ?s ≤ Suc p⟧ ⟹ ¦m (?s - Suc 0) k - (∑j≤Suc p. l j k) / (2 + real p)¦ ≤ (1 + real p) * d / (2 + real p)›*) nonz (*‹⟦?r < ?s; 0 < ?r; ?r ≤ Suc p; ?s ≤ Suc p⟧ ⟹ ¦m (?s - Suc 0) k - m (?r - Suc 0) k¦ ≤ (1 + real p) * d / (2 + real p)›*) simp del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
(*discuss goal 2*)
apply (force simp: zero (*‹⟦0 < ?s; ?s ≤ Suc p⟧ ⟹ ¦m (?s - Suc 0) k - (∑j≤Suc p. l j k) / (2 + real p)¦ ≤ (1 + real p) * d / (2 + real p)›*) nonz (*‹⟦?r < ?s; 0 < ?r; ?r ≤ Suc p; ?s ≤ Suc p⟧ ⟹ ¦m (?s - Suc 0) k - m (?r - Suc 0) k¦ ≤ (1 + real p) * d / (2 + real p)›*) simp del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
(*discuss goal 3*)
apply (force simp: zero (*‹⟦(0::nat) < (?s::nat); ?s ≤ Suc (p::nat)⟧ ⟹ ¦(m::nat ⇒ nat ⇒ real) (?s - Suc (0::nat)) (k::nat) - (∑j::nat≤Suc p. (l::nat ⇒ nat ⇒ real) j k) / ((2::real) + real p)¦ ≤ ((1::real) + real p) * (d::real) / ((2::real) + real p)›*) nonz (*‹⟦(?r::nat) < (?s::nat); (0::nat) < ?r; ?r ≤ Suc (p::nat); ?s ≤ Suc p⟧ ⟹ ¦(m::nat ⇒ nat ⇒ real) (?s - Suc (0::nat)) (k::nat) - m (?r - Suc (0::nat)) k¦ ≤ ((1::real) + real p) * (d::real) / ((2::real) + real p)›*) simp del: sum.atMost_Suc (*‹sum (?g::nat ⇒ ?'a::comm_monoid_add) {..Suc (?n::nat)} = sum ?g {..?n} + ?g (Suc ?n)›*))
(*proven 3 subgoals*) .
show "?thesis"
(*goal: ‹¦(∑j≤Suc p. (if j = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (j - 1)) k * x j) - (∑j≤Suc p. (if j = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (j - 1)) k * y j)¦ ≤ (1 + real p) * d / (2 + real p)›*)
apply (rule convex_sum_bound_le (*‹⟦⋀i. i ∈ ?I ⟹ 0 ≤ ?x i; sum ?x ?I = 1; ⋀i. i ∈ ?I ⟹ ¦?a i - ?b¦ ≤ ?δ⟧ ⟹ ¦(∑i∈?I. ?a i * ?x i) - ?b¦ ≤ ?δ›*))
(*goal: ‹¦(∑j::nat≤Suc p. (if j = (0::nat) then λi::nat. (∑j::nat≤Suc (p::nat). (l::nat ⇒ nat ⇒ real) j i) / ((2::real) + real p) else (m::nat ⇒ nat ⇒ real) (j - (1::nat))) (k::nat) * (x::nat ⇒ real) j) - (∑j::nat≤Suc p. (if j = (0::nat) then λi::nat. (∑j::nat≤Suc p. l j i) / ((2::real) + real p) else m (j - (1::nat))) k * (y::nat ⇒ real) j)¦ ≤ ((1::real) + real p) * (d::real) / ((2::real) + real p)›*)
using x' (*‹(∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>Suc p. x i = 0) ∧ sum x {..Suc p} = 1›*) apply blast
(*top goal: ‹⋀j. j ∈ {..Suc p} ⟹ 0 ≤ x j› and 2 goals remain*)
using x' (*‹(∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>Suc p. x i = 0) ∧ sum x {..Suc p} = 1›*) apply blast
(*top goal: ‹sum (x::nat ⇒ real) {..Suc (p::nat)} = (1::real)› and 1 goal remains*)
apply (subst abs_minus_commute (*‹¦(?a::?'a) - (?b::?'a)¦ = ¦?b - ?a¦›*))
(*goal: ‹⋀j. j ∈ {..Suc p} ⟹ ¦(if j = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (j - 1)) k - (∑j≤Suc p. (if j = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (j - 1)) k * y j)¦ ≤ (1 + real p) * d / (2 + real p)›*)
apply (rule convex_sum_bound_le (*‹⟦⋀i. i ∈ ?I ⟹ 0 ≤ ?x i; sum ?x ?I = 1; ⋀i. i ∈ ?I ⟹ ¦?a i - ?b¦ ≤ ?δ⟧ ⟹ ¦(∑i∈?I. ?a i * ?x i) - ?b¦ ≤ ?δ›*))
(*goal: ‹⋀j::nat. j ∈ {..Suc (p::nat)} ⟹ ¦(∑j::nat≤Suc p. (if j = (0::nat) then λi::nat. (∑j::nat≤Suc p. (l::nat ⇒ nat ⇒ real) j i) / ((2::real) + real p) else (m::nat ⇒ nat ⇒ real) (j - (1::nat))) (k::nat) * (y::nat ⇒ real) j) - (if j = (0::nat) then λi::nat. (∑j::nat≤Suc p. l j i) / ((2::real) + real p) else m (j - (1::nat))) k¦ ≤ ((1::real) + real p) * (d::real) / ((2::real) + real p)›*)
using y' (*‹(∀i. 0 ≤ y i ∧ y i ≤ 1) ∧ (∀i>Suc p. y i = 0) ∧ sum y {..Suc p} = 1›*) apply blast
(*top goal: ‹⋀j ja. ⟦j ∈ {..Suc p}; ja ∈ {..Suc p}⟧ ⟹ 0 ≤ y ja› and 2 goals remain*)
using y' (*‹(∀i::nat. (0::real) ≤ (y::nat ⇒ real) i ∧ y i ≤ (1::real)) ∧ (∀i>Suc (p::nat). y i = (0::real)) ∧ sum y {..Suc p} = (1::real)›*) apply blast
(*top goal: ‹⋀j. j ∈ {..Suc p} ⟹ sum y {..Suc p} = 1› and 1 goal remains*)
using jj (*‹?j ≤ Suc p ∧ ?j' ≤ Suc p ⟶ ¦(if ?j' = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (?j' - 1)) k - (if ?j = 0 then λi. (∑j≤Suc p. l j i) / (2 + real p) else m (?j - 1)) k¦ ≤ (1 + real p) * d / (2 + real p)›*) by blast
qed
then show "¦simplex_cone p (Sigp f) (oriented_simplex p m) x k - simplex_cone p (Sigp f) (oriented_simplex p m) y k¦
≤ (1 + real p) * d / (real p + 2)"
apply (simp add: feq (*‹f = oriented_simplex (Suc p) l›*) Sigp_def (*‹Sigp ≡ λf i. (∑j≤Suc p. simplicial_vertex j f i) / real (p + 2)›*) simplicial_vertex_oriented_simplex (*‹simplicial_vertex ?i (oriented_simplex ?p ?l) = (if ?i ≤ ?p then ?l ?i else undefined)›*) simplex_cone (*‹simplex_cone ?p ?v (oriented_simplex ?p ?l) = oriented_simplex (Suc ?p) (λi. if i = 0 then ?v else ?l (i - 1))›*) del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
(*goal: ‹¦simplex_cone p (Sigp f) (oriented_simplex p m) x k - simplex_cone p (Sigp f) (oriented_simplex p m) y k¦ ≤ (1 + real p) * d / (real p + 2)›*)
by (simp add: oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 33 facts*) x (*‹x ∈ standard_simplex (Suc p)›*) y (*‹y ∈ standard_simplex (Suc p)›*) del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
qed
qed
show "?thesis"
(*goal: ‹Poly_Mapping.keys ((frag_of ∘ simplex_cone p (Sigp f)) g) ⊆ {f. ∀x∈standard_simplex (Suc p). ∀y∈standard_simplex (Suc p). ¦f x k - f y k¦ ≤ real (Suc p) / (real p + 2) * d}›*)
using Suc.IH[OF 1, where f = g] (*‹⟦⋀f x y. ⟦f ∈ Poly_Mapping.keys (CB f); x ∈ standard_simplex p; y ∈ standard_simplex p⟧ ⟹ ¦f x k - f y k¦ ≤ ?d; g ∈ Poly_Mapping.keys (simplicial_subdivision p (CB f)); ?x ∈ standard_simplex p; ?y ∈ standard_simplex p⟧ ⟹ ¦g ?x k - g ?y k¦ ≤ real p / real (Suc p) * ?d›*) "2" (*‹⟦(?x::nat ⇒ real) ∈ standard_simplex (Suc (p::nat)); (?y::nat ⇒ real) ∈ standard_simplex (Suc p)⟧ ⟹ ¦(f::(nat ⇒ real) ⇒ nat ⇒ real) ?x (k::nat) - f ?y k¦ ≤ (d::real)›*) "3" (*‹simplex_cone p (Sigp f) g ∈ {f. ∀x∈standard_simplex (Suc p). ∀y∈standard_simplex (Suc p). ¦f x k - f y k¦ ≤ real (Suc p) / (real p + 2) * d}›*) by simp
qed
then show "?thesis"
(*goal: ‹Poly_Mapping.keys (simplicial_cone (p::nat) ((Sigp::((nat ⇒ real) ⇒ nat ⇒ real) ⇒ nat ⇒ real) (f::(nat ⇒ real) ⇒ nat ⇒ real)) (simplicial_subdivision p ((CB::((nat ⇒ real) ⇒ nat ⇒ real) ⇒ ((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) f))) ⊆ {f::(nat ⇒ real) ⇒ nat ⇒ real. ∀x::nat ⇒ real∈standard_simplex (Suc p). ∀y::nat ⇒ real∈standard_simplex (Suc p). ¦f x (k::nat) - f y k¦ ≤ real (Suc p) / (real p + (2::real)) * (d::real)}›*)
unfolding simplicial_chain_def simplicial_cone_def
(*goal: ‹Poly_Mapping.keys (frag_extend (frag_of ∘ simplex_cone p (Sigp f)) (simplicial_subdivision p (CB f))) ⊆ {f. ∀x∈standard_simplex (Suc p). ∀y∈standard_simplex (Suc p). ¦f x k - f y k¦ ≤ real (Suc p) / (real p + 2) * d}›*)
by (simp add: order_trans [OF keys_frag_extend] (*‹(⋃x∈Poly_Mapping.keys ?c1. Poly_Mapping.keys (?f1 x)) ⊆ ?z ⟹ Poly_Mapping.keys (frag_extend ?f1 ?c1) ⊆ ?z›*) sub (*‹?g ∈ Poly_Mapping.keys (simplicial_subdivision p (CB f)) ⟹ Poly_Mapping.keys ((frag_of ∘ simplex_cone p (Sigp f)) ?g) ⊆ {f. ∀x∈standard_simplex (Suc p). ∀y∈standard_simplex (Suc p). ¦f x k - f y k¦ ≤ real (Suc p) / (real p + 2) * d}›*) UN_subset_iff (*‹(⋃ (?A ` ?I) ⊆ ?B) = (∀i∈?I. ?A i ⊆ ?B)›*))
qed
obtain ff where "ff ∈ Poly_Mapping.keys c" "f ∈ Poly_Mapping.keys
(simplicial_cone p
(λi. (∑j≤Suc p. simplicial_vertex j ff i) /
(real p + 2))
(simplicial_subdivision p (CB ff)))"
(*goal: ‹(⋀ff. ⟦ff ∈ Poly_Mapping.keys c; f ∈ Poly_Mapping.keys (simplicial_cone p (λi. (∑j≤Suc p. simplicial_vertex j ff i) / (real p + 2)) (simplicial_subdivision p (CB ff)))⟧ ⟹ thesis) ⟹ thesis›*)
using Suc.prems(3) (*‹f ∈ Poly_Mapping.keys (simplicial_subdivision (Suc p) c)›*) subsetD[OF keys_frag_extend] (*‹?c ∈ Poly_Mapping.keys (frag_extend ?f1 ?c1) ⟹ ?c ∈ (⋃x∈Poly_Mapping.keys ?c1. Poly_Mapping.keys (?f1 x))›*) by (force simp: CB_def (*‹CB ≡ λf. chain_boundary (Suc p) (frag_of f)›*) simp del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
then show "?case"
(*goal: ‹¦(f::(nat ⇒ real) ⇒ nat ⇒ real) (x::nat ⇒ real) (k::nat) - f (y::nat ⇒ real) k¦ ≤ real (Suc (p::nat)) / real (Suc (Suc p)) * (d::real)›*)
using Suc (*‹⟦simplicial_chain p S ?c; ⋀f x y. ⟦f ∈ Poly_Mapping.keys ?c; x ∈ standard_simplex p; y ∈ standard_simplex p⟧ ⟹ ¦f x k - f y k¦ ≤ ?d; ?f ∈ Poly_Mapping.keys (simplicial_subdivision p ?c); ?x ∈ standard_simplex p; ?y ∈ standard_simplex p⟧ ⟹ ¦?f ?x k - ?f ?y k¦ ≤ real p / real (Suc p) * ?d› ‹simplicial_chain (Suc p) S c› ‹⟦?f ∈ Poly_Mapping.keys c; ?x ∈ standard_simplex (Suc p); ?y ∈ standard_simplex (Suc p)⟧ ⟹ ¦?f ?x k - ?f ?y k¦ ≤ d› ‹f ∈ Poly_Mapping.keys (simplicial_subdivision (Suc p) c)› ‹(x::nat ⇒ real) ∈ standard_simplex (Suc (p::nat))› ‹y ∈ standard_simplex (Suc p)›*) "*" (*‹?f ∈ Poly_Mapping.keys c ⟹ Poly_Mapping.keys (simplicial_cone p (Sigp ?f) (simplicial_subdivision p (CB ?f))) ⊆ {f. ∀x∈standard_simplex (Suc p). ∀y∈standard_simplex (Suc p). ¦f x k - f y k¦ ≤ real (Suc p) / (real p + 2) * d}›*) by (simp add: add.commute (*‹?a + ?b = ?b + ?a›*) Sigp_def (*‹Sigp ≡ λf i. (∑j≤Suc p. simplicial_vertex j f i) / real (p + 2)›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*))
qed (auto simp: standard_simplex_0 (*‹standard_simplex (0::nat) = {λj::nat. if j = (0::nat) then 1::real else (0::real)}›*))
(*solved the remaining goal: ‹⋀d c f x y. ⟦simplicial_chain 0 S c; ⋀f x y. ⟦f ∈ Poly_Mapping.keys c; x ∈ standard_simplex 0; y ∈ standard_simplex 0⟧ ⟹ ¦f x k - f y k¦ ≤ d; f ∈ Poly_Mapping.keys (simplicial_subdivision 0 c); x ∈ standard_simplex 0; y ∈ standard_simplex 0⟧ ⟹ ¦f x k - f y k¦ ≤ real 0 / real (Suc 0) * d›*)
subsection‹Singular subdivision›
definition singular_subdivision
where "singular_subdivision p ≡
frag_extend
(λf. chain_map p f
(simplicial_subdivision p
(frag_of(restrict id (standard_simplex p)))))"
lemma singular_subdivision_0 [simp]: "singular_subdivision p 0 = 0"
by (simp add: singular_subdivision_def (*‹singular_subdivision (?p::nat) ≡ frag_extend (λf::(nat ⇒ real) ⇒ ?'a. chain_map ?p f (simplicial_subdivision ?p (frag_of (restrict id (standard_simplex ?p)))))›*))
lemma singular_subdivision_add:
"singular_subdivision p (a + b) = singular_subdivision p a + singular_subdivision p b"
by (simp add: singular_subdivision_def (*‹singular_subdivision ?p ≡ frag_extend (λf. chain_map ?p f (simplicial_subdivision ?p (frag_of (restrict id (standard_simplex ?p)))))›*) frag_extend_add (*‹frag_extend ?f (?a + ?b) = frag_extend ?f ?a + frag_extend ?f ?b›*))
lemma singular_subdivision_diff:
"singular_subdivision p (a - b) = singular_subdivision p a - singular_subdivision p b"
by (simp add: singular_subdivision_def (*‹singular_subdivision ?p ≡ frag_extend (λf. chain_map ?p f (simplicial_subdivision ?p (frag_of (restrict id (standard_simplex ?p)))))›*) frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*))
lemma simplicial_simplex_id [simp]:
"simplicial_simplex p S (restrict id (standard_simplex p)) ⟷ standard_simplex p ⊆ S"
(is "?lhs = ?rhs")
proof (standard)
(*goals:
1. ‹simplicial_simplex (p::nat) (S::(nat ⇒ real) set) (restrict id (standard_simplex p)) ⟹ standard_simplex p ⊆ S›
2. ‹standard_simplex (p::nat) ⊆ (S::(nat ⇒ real) set) ⟹ simplicial_simplex p S (restrict id (standard_simplex p))›*)
assume "?lhs" (*‹simplicial_simplex (p::nat) (S::(nat ⇒ real) set) (restrict id (standard_simplex p))›*)
then show "?rhs"
by (simp add: simplicial_simplex_def (*‹simplicial_simplex (?p::nat) (?S::(?'a ⇒ real) set) (?f::(nat ⇒ real) ⇒ ?'a ⇒ real) ≡ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f ∧ (∃l::nat ⇒ ?'a ⇒ real. ?f = oriented_simplex ?p l)›*) singular_simplex_def (*‹singular_simplex (?p::nat) (?X::?'a topology) (?f::(nat ⇒ real) ⇒ ?'a) ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*) continuous_map_in_subtopology (*‹continuous_map (?X::?'a topology) (subtopology (?X'::?'b topology) (?S::?'b set)) (?f::?'a ⇒ ?'b) = (continuous_map ?X ?X' ?f ∧ ?f ` topspace ?X ⊆ ?S)›*) set_mp (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); (?c::?'a) ∈ ?A⟧ ⟹ ?c ∈ ?B›*))
next
(*goal: ‹standard_simplex p ⊆ S ⟹ simplicial_simplex p S (restrict id (standard_simplex p))›*)
assume R: "?rhs" (*‹standard_simplex (p::nat) ⊆ (S::(nat ⇒ real) set)›*)
then have cm: "continuous_map
(subtopology (powertop_real UNIV) (standard_simplex p))
(subtopology (powertop_real UNIV) S) id"
using continuous_map_from_subtopology_mono (*‹⟦continuous_map (subtopology ?X ?T) ?Y ?f; ?S ⊆ ?T⟧ ⟹ continuous_map (subtopology ?X ?S) ?Y ?f›*) continuous_map_id (*‹continuous_map ?X ?X id›*) by blast
moreover have "∃l. restrict id (standard_simplex p) = oriented_simplex p l"
proof (standard)
(*goal: ‹restrict id (standard_simplex p) = oriented_simplex p ?l›*)
show "restrict id (standard_simplex p) = oriented_simplex p (λi j. if i = j then 1 else 0)"
by (force simp: oriented_simplex_def (*‹oriented_simplex (?p::nat) (?l::nat ⇒ ?'a::type ⇒ real) ≡ λx::nat ⇒ real∈standard_simplex ?p. λi::?'a::type. ∑j::nat≤?p. ?l j i * x j›*) standard_simplex_def (*‹standard_simplex (?p::nat) ≡ {x::nat ⇒ real. (∀i::nat. (0::real) ≤ x i ∧ x i ≤ (1::real)) ∧ (∀i>?p. x i = (0::real)) ∧ sum x {..?p} = (1::real)}›*) if_distrib [of "λu. u * _"] (*‹(if ?c::bool then ?x::?'a1::times else (?y::?'a1::times)) * (?uu5::?'a1::times) = (if ?c then ?x * ?uu5 else ?y * ?uu5)›*) cong: if_cong (*‹⟦(?b::bool) = (?c::bool); ?c ⟹ (?x::?'a::type) = (?u::?'a::type); ¬ ?c ⟹ (?y::?'a::type) = (?v::?'a::type)⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
qed
ultimately show "?lhs"
by (simp add: simplicial_simplex_def (*‹simplicial_simplex (?p::nat) (?S::(?'a ⇒ real) set) (?f::(nat ⇒ real) ⇒ ?'a ⇒ real) ≡ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f ∧ (∃l::nat ⇒ ?'a ⇒ real. ?f = oriented_simplex ?p l)›*) singular_simplex_def (*‹singular_simplex (?p::nat) (?X::?'a topology) (?f::(nat ⇒ real) ⇒ ?'a) ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*))
qed
lemma singular_chain_singular_subdivision:
assumes "singular_chain p X c"
shows "singular_chain p X (singular_subdivision p c)"
unfolding singular_subdivision_def
(*goal: ‹singular_chain p X (frag_extend (λf. chain_map p f (simplicial_subdivision p (frag_of (restrict id (standard_simplex p))))) c)›*)
proof (rule singular_chain_extend (*‹(⋀c. c ∈ Poly_Mapping.keys ?x ⟹ singular_chain ?p ?X (?f c)) ⟹ singular_chain ?p ?X (frag_extend ?f ?x)›*))
(*goal: ‹⋀ca. ca ∈ Poly_Mapping.keys c ⟹ singular_chain p X (chain_map p ca (simplicial_subdivision p (frag_of (restrict id (standard_simplex p)))))›*)
fix ca
assume "ca ∈ Poly_Mapping.keys c" (*‹(ca::(nat ⇒ real) ⇒ 'a) ∈ Poly_Mapping.keys (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*)
with assms (*‹singular_chain (p::nat) (X::'a::type topology) (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)›*) have "singular_simplex p X ca"
by (simp add: singular_chain_def (*‹singular_chain (?p::nat) (?X::?'a topology) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ≡ Poly_Mapping.keys ?c ⊆ singular_simplex_set ?p ?X›*) subset_iff (*‹((?A::?'a set) ⊆ (?B::?'a set)) = (∀t::?'a. t ∈ ?A ⟶ t ∈ ?B)›*))
then show "singular_chain p X (chain_map p ca (simplicial_subdivision p (frag_of (restrict id (standard_simplex p)))))"
unfolding singular_simplex_def
(*goal: ‹singular_chain p X (chain_map p ca (simplicial_subdivision p (frag_of (restrict id (standard_simplex p)))))›*)
by (metis order_refl (*‹?x ≤ ?x›*) simplicial_chain_of (*‹simplicial_chain ?p ?S (frag_of ?c) = simplicial_simplex ?p ?S ?c›*) simplicial_chain_simplicial_subdivision (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain ?p ?S (simplicial_subdivision ?p ?c)›*) simplicial_imp_singular_chain (*‹simplicial_chain ?p ?S ?c ⟹ singular_chain ?p (subtopology (powertop_real UNIV) ?S) ?c›*) simplicial_simplex_id (*‹simplicial_simplex ?p ?S (restrict id (standard_simplex ?p)) = (standard_simplex ?p ⊆ ?S)›*) singular_chain_chain_map (*‹⟦singular_chain ?p ?X ?c; continuous_map ?X ?X' ?g⟧ ⟹ singular_chain ?p ?X' (chain_map ?p ?g ?c)›*))
qed
lemma naturality_singular_subdivision:
"singular_chain p X c
⟹ singular_subdivision p (chain_map p g c) = chain_map p g (singular_subdivision p c)"
unfolding singular_chain_def
(*goal: ‹Poly_Mapping.keys c ⊆ singular_simplex_set p X ⟹ singular_subdivision p (chain_map p g c) = chain_map p g (singular_subdivision p c)›*)
proof (induction rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹singular_subdivision p (chain_map p g 0) = chain_map p g (singular_subdivision p 0)›
2. ‹⋀x. x ∈ singular_simplex_set p X ⟹ singular_subdivision p (chain_map p g (frag_of x)) = chain_map p g (singular_subdivision p (frag_of x))›
3. ‹⋀a b. ⟦singular_subdivision p (chain_map p g a) = chain_map p g (singular_subdivision p a); singular_subdivision p (chain_map p g b) = chain_map p g (singular_subdivision p b)⟧ ⟹ singular_subdivision p (chain_map p g (a - b)) = chain_map p g (singular_subdivision p (a - b))›*)
case (one f) (*‹f ∈ singular_simplex_set p X›*)
then have "singular_simplex p X f"
by auto
have "⟦simplicial_chain p (standard_simplex p) d⟧
⟹ chain_map p (simplex_map p g f) d = chain_map p g (chain_map p f d)" for d
unfolding simplicial_chain_def
(*goal: ‹Poly_Mapping.keys (d::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) ⊆ Collect (simplicial_simplex (p::nat) (standard_simplex p)) ⟹ chain_map p (simplex_map p (g::'a ⇒ 'b) (f::(nat ⇒ real) ⇒ 'a)) d = chain_map p g (chain_map p f d)›*)
proof (induction rule: frag_induction (*‹⟦Poly_Mapping.keys (?c::?'a::type ⇒₀ int) ⊆ (?S::?'a::type set); (?P::(?'a::type ⇒₀ int) ⇒ bool) (0::?'a::type ⇒₀ int); ⋀x::?'a::type. x ∈ ?S ⟹ ?P (frag_of x); ⋀(a::?'a::type ⇒₀ int) b::?'a::type ⇒₀ int. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹chain_map p (simplex_map p g f) 0 = chain_map p g (chain_map p f 0)›
2. ‹⋀x. x ∈ Collect (simplicial_simplex p (standard_simplex p)) ⟹ chain_map p (simplex_map p g f) (frag_of x) = chain_map p g (chain_map p f (frag_of x))›
3. ‹⋀a b. ⟦chain_map p (simplex_map p g f) a = chain_map p g (chain_map p f a); chain_map p (simplex_map p g f) b = chain_map p g (chain_map p f b)⟧ ⟹ chain_map p (simplex_map p g f) (a - b) = chain_map p g (chain_map p f (a - b))›*)
case (one x) (*‹x ∈ Collect (simplicial_simplex p (standard_simplex p))›*)
then have "simplex_map p (simplex_map p g f) x = simplex_map p g (simplex_map p f x)"
by (force simp: simplex_map_def (*‹simplex_map ?p ?g ?c ≡ restrict (?g ∘ ?c) (standard_simplex ?p)›*) restrict_compose_left (*‹?f ` ?S ⊆ ?T ⟹ restrict (restrict ?g ?T ∘ ?f) ?S = restrict (?g ∘ ?f) ?S›*) simplicial_simplex (*‹simplicial_simplex ?p ?S ?f = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l. ?f = oriented_simplex ?p l))›*))
then show "?case"
(*goal: ‹chain_map (p::nat) (simplex_map p (g::'a ⇒ 'b) (f::(nat ⇒ real) ⇒ 'a)) (frag_of (x::(nat ⇒ real) ⇒ nat ⇒ real)) = chain_map p g (chain_map p f (frag_of x))›*)
by auto
qed (auto simp: chain_map_diff (*‹chain_map ?p ?g (?a - ?b) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*))
(*solves the remaining goals:
1. ‹chain_map p (simplex_map p g f) 0 = chain_map p g (chain_map p f 0)›
2. ‹⋀a b. ⟦chain_map p (simplex_map p g f) a = chain_map p g (chain_map p f a); chain_map p (simplex_map p g f) b = chain_map p g (chain_map p f b)⟧ ⟹ chain_map p (simplex_map p g f) (a - b) = chain_map p g (chain_map p f (a - b))›*)
then show "?case"
(*goal: ‹singular_subdivision p (chain_map p g (frag_of f)) = chain_map p g (singular_subdivision p (frag_of f))›*)
using simplicial_chain_simplicial_subdivision[of p "standard_simplex p" "frag_of (restrict id (standard_simplex p))"] (*‹simplicial_chain (p::nat) (standard_simplex p) (frag_of (restrict id (standard_simplex p))) ⟹ simplicial_chain p (standard_simplex p) (simplicial_subdivision p (frag_of (restrict id (standard_simplex p))))›*) by (simp add: singular_subdivision_def (*‹singular_subdivision ?p ≡ frag_extend (λf. chain_map ?p f (simplicial_subdivision ?p (frag_of (restrict id (standard_simplex ?p)))))›*))
next
(*goals:
1. ‹singular_subdivision p (chain_map p g 0) = chain_map p g (singular_subdivision p 0)›
2. ‹⋀a b. ⟦singular_subdivision p (chain_map p g a) = chain_map p g (singular_subdivision p a); singular_subdivision p (chain_map p g b) = chain_map p g (singular_subdivision p b)⟧ ⟹ singular_subdivision p (chain_map p g (a - b)) = chain_map p g (singular_subdivision p (a - b))›*)
case (diff a b) (*‹singular_subdivision p (chain_map p g a) = chain_map p g (singular_subdivision p a)› ‹singular_subdivision p (chain_map p g b) = chain_map p g (singular_subdivision p b)›*)
then show "?case"
(*goal: ‹singular_subdivision p (chain_map p g (a - b)) = chain_map p g (singular_subdivision p (a - b))›*)
by (simp add: chain_map_diff (*‹chain_map ?p ?g (?a - ?b) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*) singular_subdivision_diff (*‹singular_subdivision ?p (?a - ?b) = singular_subdivision ?p ?a - singular_subdivision ?p ?b›*))
qed (auto)
(*solved the remaining goal: ‹singular_subdivision p (chain_map p g 0) = chain_map p g (singular_subdivision p 0)›*)
lemma simplicial_chain_chain_map:
assumes f: "simplicial_simplex q X f" and c: "simplicial_chain p (standard_simplex q) c"
shows "simplicial_chain p X (chain_map p f c)"
using c (*‹simplicial_chain (p::nat) (standard_simplex (q::nat)) (c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)›*) unfolding simplicial_chain_def
(*goal: ‹Poly_Mapping.keys (chain_map p f c) ⊆ Collect (simplicial_simplex p X)›*)
proof (induction c rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹Poly_Mapping.keys (chain_map p f 0) ⊆ {a. simplicial_simplex p X a}›
2. ‹⋀x. x ∈ Collect (simplicial_simplex p (standard_simplex q)) ⟹ Poly_Mapping.keys (chain_map p f (frag_of x)) ⊆ {a. simplicial_simplex p X a}›
3. ‹⋀a b. ⟦Poly_Mapping.keys (chain_map p f a) ⊆ {a. simplicial_simplex p X a}; Poly_Mapping.keys (chain_map p f b) ⊆ {a. simplicial_simplex p X a}⟧ ⟹ Poly_Mapping.keys (chain_map p f (a - b)) ⊆ {a. simplicial_simplex p X a}›*)
case (one g) (*‹g ∈ Collect (simplicial_simplex p (standard_simplex q))›*)
have "∃n. simplex_map p (oriented_simplex q l)
(oriented_simplex p m) = oriented_simplex p n" if m: "singular_simplex p
(subtopology (powertop_real UNIV) (standard_simplex q)) (oriented_simplex p m)" for l and m
proof (-)
(*goal: ‹∃n::nat ⇒ 'b ⇒ real. simplex_map (p::nat) (oriented_simplex (q::nat) (l::nat ⇒ 'b ⇒ real)) (oriented_simplex p (m::nat ⇒ nat ⇒ real)) = oriented_simplex p n›*)
have "(λi. ∑j≤p. m j i * x j) ∈ standard_simplex q" if "x ∈ standard_simplex p" for x
using that (*‹(x::nat ⇒ real) ∈ standard_simplex (p::nat)›*) m (*‹singular_simplex p (subtopology (powertop_real UNIV) (standard_simplex q)) (oriented_simplex p m)›*) unfolding oriented_simplex_def singular_simplex_def
(*goal: ‹(λi::nat. ∑j::nat≤p::nat. (m::nat ⇒ nat ⇒ real) j i * (x::nat ⇒ real) j) ∈ standard_simplex (q::nat)›*)
by (auto simp: continuous_map_in_subtopology (*‹continuous_map ?X (subtopology ?X' ?S) ?f = (continuous_map ?X ?X' ?f ∧ ?f ` topspace ?X ⊆ ?S)›*) image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*))
then show "?thesis"
(*goal: ‹∃n. simplex_map p (oriented_simplex q l) (oriented_simplex p m) = oriented_simplex p n›*)
unfolding oriented_simplex_def simplex_map_def
(*goal: ‹∃n. restrict ((λx∈standard_simplex q. λi. ∑j≤q. l j i * x j) ∘ (λx∈standard_simplex p. λi. ∑j≤p. m j i * x j)) (standard_simplex p) = (λx∈standard_simplex p. λi. ∑j≤p. n j i * x j)›*)
apply (rule_tac x="λj k. (∑i≤q. l i k * m j i)" in exI (*‹?P ?x ⟹ ∃x. ?P x›*))
(*goal: ‹∃n. restrict ((λx∈standard_simplex q. λi. ∑j≤q. l j i * x j) ∘ (λx∈standard_simplex p. λi. ∑j≤p. m j i * x j)) (standard_simplex p) = (λx∈standard_simplex p. λi. ∑j≤p. n j i * x j)›*)
by (force simp: sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*) sum_distrib_right (*‹sum ?f ?A * ?r = (∑n∈?A. ?f n * ?r)›*) mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*) intro: sum.swap (*‹(∑i∈?A. sum (?g i) ?B) = (∑j∈?B. ∑i∈?A. ?g i j)›*))
qed
then show "?case"
(*goal: ‹Poly_Mapping.keys (chain_map p f (frag_of g)) ⊆ {a. simplicial_simplex p X a}›*)
using f (*‹simplicial_simplex q X f›*) one (*‹(g::(nat ⇒ real) ⇒ nat ⇒ real) ∈ Collect (simplicial_simplex (p::nat) (standard_simplex (q::nat)))›*) apply (simp add: simplicial_simplex_def (*‹simplicial_simplex ?p ?S ?f ≡ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f ∧ (∃l. ?f = oriented_simplex ?p l)›*))
(*goal: ‹Poly_Mapping.keys (chain_map p f (frag_of g)) ⊆ {a. simplicial_simplex p X a}›*)
using singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*) singular_simplex_simplex_map (*‹⟦singular_simplex (?p::nat) (?X::?'a topology) (?f::(nat ⇒ real) ⇒ ?'a); continuous_map ?X (?X'::?'b topology) (?g::?'a ⇒ ?'b)⟧ ⟹ singular_simplex ?p ?X' (simplex_map ?p ?g ?f)›*) by blast
next
(*goals:
1. ‹Poly_Mapping.keys (chain_map p f 0) ⊆ {a. simplicial_simplex p X a}›
2. ‹⋀a b. ⟦Poly_Mapping.keys (chain_map p f a) ⊆ {a. simplicial_simplex p X a}; Poly_Mapping.keys (chain_map p f b) ⊆ {a. simplicial_simplex p X a}⟧ ⟹ Poly_Mapping.keys (chain_map p f (a - b)) ⊆ {a. simplicial_simplex p X a}›*)
case (diff a b) (*‹Poly_Mapping.keys (chain_map p f a) ⊆ {a. simplicial_simplex p X a}› ‹Poly_Mapping.keys (chain_map (p::nat) (f::(nat ⇒ real) ⇒ 'a::type ⇒ real) (b::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) ⊆ {a::(nat ⇒ real) ⇒ 'a::type ⇒ real. simplicial_simplex p (X::('a::type ⇒ real) set) a}›*)
then show "?case"
(*goal: ‹Poly_Mapping.keys (chain_map p f (a - b)) ⊆ {a. simplicial_simplex p X a}›*)
by (metis chain_map_diff (*‹chain_map ?p ?g (?a - ?b) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*) simplicial_chain_def (*‹simplicial_chain ?p ?S ?c ≡ Poly_Mapping.keys ?c ⊆ Collect (simplicial_simplex ?p ?S)›*) simplicial_chain_diff (*‹⟦simplicial_chain ?p ?S ?c1.0; simplicial_chain ?p ?S ?c2.0⟧ ⟹ simplicial_chain ?p ?S (?c1.0 - ?c2.0)›*))
qed (auto)
(*solved the remaining goal: ‹Poly_Mapping.keys (chain_map p f 0) ⊆ {a. simplicial_simplex p X a}›*)
lemma singular_subdivision_simplicial_simplex:
"simplicial_chain p S c
⟹ singular_subdivision p c = simplicial_subdivision p c"
proof (induction p arbitrary: S c)
(*goals:
1. ‹⋀S c. simplicial_chain 0 S c ⟹ singular_subdivision 0 c = simplicial_subdivision 0 c›
2. ‹⋀p S c. ⟦⋀S c. simplicial_chain p S c ⟹ singular_subdivision p c = simplicial_subdivision p c; simplicial_chain (Suc p) S c⟧ ⟹ singular_subdivision (Suc p) c = simplicial_subdivision (Suc p) c›*)
case 0 (*‹simplicial_chain 0 S c›*)
then show "?case"
(*goal: ‹singular_subdivision 0 c = simplicial_subdivision 0 c›*)
unfolding simplicial_chain_def
(*goal: ‹singular_subdivision (0::nat) (c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) = simplicial_subdivision (0::nat) c›*)
proof (induction rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹singular_subdivision 0 0 = simplicial_subdivision 0 0›
2. ‹⋀x. x ∈ Collect (simplicial_simplex 0 S) ⟹ singular_subdivision 0 (frag_of x) = simplicial_subdivision 0 (frag_of x)›
3. ‹⋀a b. ⟦singular_subdivision 0 a = simplicial_subdivision 0 a; singular_subdivision 0 b = simplicial_subdivision 0 b⟧ ⟹ singular_subdivision 0 (a - b) = simplicial_subdivision 0 (a - b)›*)
case (one x) (*‹(x::(nat ⇒ real) ⇒ nat ⇒ real) ∈ Collect (simplicial_simplex (0::nat) (S::(nat ⇒ real) set))›*)
then show "?case"
(*goal: ‹singular_subdivision 0 (frag_of x) = simplicial_subdivision 0 (frag_of x)›*)
using singular_simplex_chain_map_id (*‹singular_simplex (?p::nat) (?X::?'a::type topology) (?f::(nat ⇒ real) ⇒ ?'a::type) ⟹ chain_map ?p ?f (frag_of (restrict id (standard_simplex ?p))) = frag_of ?f›*) simplicial_imp_singular_simplex (*‹simplicial_simplex (?p::nat) (?S::(?'a ⇒ real) set) (?f::(nat ⇒ real) ⇒ ?'a ⇒ real) ⟹ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f›*) by (fastforce simp: singular_subdivision_def (*‹singular_subdivision ?p ≡ frag_extend (λf. chain_map ?p f (simplicial_subdivision ?p (frag_of (restrict id (standard_simplex ?p)))))›*) simplicial_subdivision_def (*‹simplicial_subdivision ≡ rec_nat id (λp pa. frag_extend (λf. simplicial_cone p (λi. (∑j≤Suc p. simplicial_vertex j f i) / (real p + 2)) (pa (chain_boundary (Suc p) (frag_of f)))))›*))
qed (auto simp: singular_subdivision_diff (*‹singular_subdivision (?p::nat) ((?a::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) - (?b::((nat ⇒ real) ⇒ ?'a) ⇒₀ int)) = singular_subdivision ?p ?a - singular_subdivision ?p ?b›*))
(*solves the remaining goals:
1. ‹singular_subdivision 0 0 = simplicial_subdivision 0 0›
2. ‹⋀a b. ⟦singular_subdivision 0 a = simplicial_subdivision 0 a; singular_subdivision 0 b = simplicial_subdivision 0 b⟧ ⟹ singular_subdivision 0 (a - b) = simplicial_subdivision 0 (a - b)›*)
next
(*goal: ‹⋀(p::nat) (S::(nat ⇒ real) set) c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int. ⟦⋀(S::(nat ⇒ real) set) c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int. simplicial_chain p S c ⟹ singular_subdivision p c = simplicial_subdivision p c; simplicial_chain (Suc p) S c⟧ ⟹ singular_subdivision (Suc p) c = simplicial_subdivision (Suc p) c›*)
case (Suc p) (*‹simplicial_chain (p::nat) (?S::(nat ⇒ real) set) (?c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) ⟹ singular_subdivision p ?c = simplicial_subdivision p ?c› ‹simplicial_chain (Suc p) S c›*)
show "?case"
(*goal: ‹singular_subdivision (Suc p) c = simplicial_subdivision (Suc p) c›*)
using Suc.prems (*‹simplicial_chain (Suc p) S c›*) unfolding simplicial_chain_def
(*goal: ‹singular_subdivision (Suc p) c = simplicial_subdivision (Suc p) c›*)
proof (induction rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹singular_subdivision (Suc p) 0 = simplicial_subdivision (Suc p) 0›
2. ‹⋀x. x ∈ Collect (simplicial_simplex (Suc p) S) ⟹ singular_subdivision (Suc p) (frag_of x) = simplicial_subdivision (Suc p) (frag_of x)›
3. ‹⋀a b. ⟦singular_subdivision (Suc p) a = simplicial_subdivision (Suc p) a; singular_subdivision (Suc p) b = simplicial_subdivision (Suc p) b⟧ ⟹ singular_subdivision (Suc p) (a - b) = simplicial_subdivision (Suc p) (a - b)›*)
case (one f) (*‹(f::(nat ⇒ real) ⇒ nat ⇒ real) ∈ Collect (simplicial_simplex (Suc (p::nat)) (S::(nat ⇒ real) set))›*)
then have ssf: "simplicial_simplex (Suc p) S f"
by (auto simp: simplicial_simplex (*‹simplicial_simplex ?p ?S ?f = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l. ?f = oriented_simplex ?p l))›*))
then have 1: "simplicial_chain p (standard_simplex (Suc p))
(simplicial_subdivision p
(chain_boundary (Suc p)
(frag_of (restrict id (standard_simplex (Suc p))))))"
by (metis diff_Suc_1 (*‹Suc ?n - 1 = ?n›*) order_refl (*‹?x ≤ ?x›*) simplicial_chain_boundary (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain (?p - 1) ?S (chain_boundary ?p ?c)›*) simplicial_chain_of (*‹simplicial_chain ?p ?S (frag_of ?c) = simplicial_simplex ?p ?S ?c›*) simplicial_chain_simplicial_subdivision (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain ?p ?S (simplicial_subdivision ?p ?c)›*) simplicial_simplex_id (*‹simplicial_simplex ?p ?S (restrict id (standard_simplex ?p)) = (standard_simplex ?p ⊆ ?S)›*))
have 2: "(λi. (∑j≤Suc p. simplicial_vertex j (restrict id (standard_simplex (Suc p))) i) / (real p + 2))
∈ standard_simplex (Suc p)"
by (simp add: simplicial_vertex_def (*‹simplicial_vertex ?i ?f = ?f (λj. if j = ?i then 1 else 0)›*) standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*) del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
have ss_Sp: "(λi. (if i ≤ Suc p then 1 else 0) / (real p + 2)) ∈ standard_simplex (Suc p)"
by (simp add: standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*) field_split_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 65 facts*))
obtain l where feq: "f = oriented_simplex (Suc p) l"
(*goal: ‹(⋀l. f = oriented_simplex (Suc p) l ⟹ thesis) ⟹ thesis›*)
using one (*‹f ∈ Collect (simplicial_simplex (Suc p) S)›*) unfolding simplicial_simplex
(*goal: ‹(⋀l. f = oriented_simplex (Suc p) l ⟹ thesis) ⟹ thesis›*)
by blast
then have 3: "f (λi. (∑j≤Suc p. simplicial_vertex j (restrict id (standard_simplex (Suc p))) i) / (real p + 2))
= (λi. (∑j≤Suc p. simplicial_vertex j f i) / (real p + 2))"
unfolding simplicial_vertex_def oriented_simplex_def
(*goal: ‹f (λi. (∑j≤Suc p. restrict id (standard_simplex (Suc p)) (λja. if ja = j then 1 else 0) i) / (real p + 2)) = (λi. (∑j≤Suc p. f (λja. if ja = j then 1 else 0) i) / (real p + 2))›*)
by (simp add: ss_Sp (*‹(λi::nat. (if i ≤ Suc (p::nat) then 1::real else (0::real)) / (real p + (2::real))) ∈ standard_simplex (Suc p)›*) if_distrib [of "λx. _ * x"] (*‹(?uu5::?'a1) * (if ?c::bool then ?x::?'a1 else (?y::?'a1)) = (if ?c then ?uu5 * ?x else ?uu5 * ?y)›*) sum_divide_distrib (*‹sum (?f::?'b ⇒ ?'a) (?A::?'b set) / (?r::?'a) = (∑n::?'b∈?A. ?f n / ?r)›*) del: sum.atMost_Suc (*‹sum (?g::nat ⇒ ?'a) {..Suc (?n::nat)} = sum ?g {..?n} + ?g (Suc ?n)›*) cong: if_cong (*‹⟦(?b::bool) = (?c::bool); ?c ⟹ (?x::?'a) = (?u::?'a); ¬ ?c ⟹ (?y::?'a) = (?v::?'a)⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
have scp: "singular_chain (Suc p)
(subtopology (powertop_real UNIV) (standard_simplex (Suc p)))
(frag_of (restrict id (standard_simplex (Suc p))))"
by (simp add: simplicial_imp_singular_chain (*‹simplicial_chain ?p ?S ?c ⟹ singular_chain ?p (subtopology (powertop_real UNIV) ?S) ?c›*))
have scps: "simplicial_chain p (standard_simplex (Suc p))
(chain_boundary (Suc p) (frag_of (restrict id (standard_simplex (Suc p)))))"
by (metis diff_Suc_1 (*‹Suc ?n - 1 = ?n›*) order_refl (*‹?x ≤ ?x›*) simplicial_chain_boundary (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain (?p - 1) ?S (chain_boundary ?p ?c)›*) simplicial_chain_of (*‹simplicial_chain ?p ?S (frag_of ?c) = simplicial_simplex ?p ?S ?c›*) simplicial_simplex_id (*‹simplicial_simplex ?p ?S (restrict id (standard_simplex ?p)) = (standard_simplex ?p ⊆ ?S)›*))
have scpf: "simplicial_chain p S
(chain_map p f
(chain_boundary (Suc p) (frag_of (restrict id (standard_simplex (Suc p))))))"
using scps (*‹simplicial_chain p (standard_simplex (Suc p)) (chain_boundary (Suc p) (frag_of (restrict id (standard_simplex (Suc p)))))›*) simplicial_chain_chain_map (*‹⟦simplicial_simplex ?q ?X ?f; simplicial_chain ?p (standard_simplex ?q) ?c⟧ ⟹ simplicial_chain ?p ?X (chain_map ?p ?f ?c)›*) ssf (*‹simplicial_simplex (Suc p) S f›*) by blast
have 4: "chain_map p f
(simplicial_subdivision p
(chain_boundary (Suc p) (frag_of (restrict id (standard_simplex (Suc p))))))
= simplicial_subdivision p (chain_boundary (Suc p) (frag_of f))"
proof (-)
(*goal: ‹chain_map p f (simplicial_subdivision p (chain_boundary (Suc p) (frag_of (restrict id (standard_simplex (Suc p)))))) = simplicial_subdivision p (chain_boundary (Suc p) (frag_of f))›*)
have "singular_simplex (Suc p) (subtopology (powertop_real UNIV) S) f"
using simplicial_simplex_def (*‹simplicial_simplex (?p::nat) (?S::(?'a::type ⇒ real) set) (?f::(nat ⇒ real) ⇒ ?'a::type ⇒ real) ≡ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f ∧ (∃l::nat ⇒ ?'a::type ⇒ real. ?f = oriented_simplex ?p l)›*) ssf (*‹simplicial_simplex (Suc p) S f›*) by blast
then have "chain_map (Suc p) f (frag_of (restrict id (standard_simplex (Suc p)))) = frag_of f"
using singular_simplex_chain_map_id (*‹singular_simplex ?p ?X ?f ⟹ chain_map ?p ?f (frag_of (restrict id (standard_simplex ?p))) = frag_of ?f›*) by blast
then show "?thesis"
(*goal: ‹chain_map p f (simplicial_subdivision p (chain_boundary (Suc p) (frag_of (restrict id (standard_simplex (Suc p)))))) = simplicial_subdivision p (chain_boundary (Suc p) (frag_of f))›*)
by (metis (no_types) Suc.IH (*‹simplicial_chain p ?S ?c ⟹ singular_subdivision p ?c = simplicial_subdivision p ?c›*) chain_boundary_chain_map (*‹singular_chain ?p ?X ?c ⟹ chain_boundary ?p (chain_map ?p ?g ?c) = chain_map (?p - Suc 0) ?g (chain_boundary ?p ?c)›*) diff_Suc_Suc (*‹Suc ?m - Suc ?n = ?m - ?n›*) diff_zero (*‹?a - 0 = ?a›*) naturality_singular_subdivision (*‹singular_chain ?p ?X ?c ⟹ singular_subdivision ?p (chain_map ?p ?g ?c) = chain_map ?p ?g (singular_subdivision ?p ?c)›*) scp (*‹singular_chain (Suc p) (subtopology (powertop_real UNIV) (standard_simplex (Suc p))) (frag_of (restrict id (standard_simplex (Suc p))))›*) scpf (*‹simplicial_chain p S (chain_map p f (chain_boundary (Suc p) (frag_of (restrict id (standard_simplex (Suc p))))))›*) scps (*‹simplicial_chain p (standard_simplex (Suc p)) (chain_boundary (Suc p) (frag_of (restrict id (standard_simplex (Suc p)))))›*) simplicial_imp_singular_chain (*‹simplicial_chain ?p ?S ?c ⟹ singular_chain ?p (subtopology (powertop_real UNIV) ?S) ?c›*))
qed
show "?case"
(*goal: ‹singular_subdivision (Suc p) (frag_of f) = simplicial_subdivision (Suc p) (frag_of f)›*)
apply (simp add: singular_subdivision_def (*‹singular_subdivision (?p::nat) ≡ frag_extend (λf::(nat ⇒ real) ⇒ ?'a. chain_map ?p f (simplicial_subdivision ?p (frag_of (restrict id (standard_simplex ?p)))))›*) del: sum.atMost_Suc (*‹sum (?g::nat ⇒ ?'a) {..Suc (?n::nat)} = sum ?g {..?n} + ?g (Suc ?n)›*))
(*goal: ‹singular_subdivision (Suc p) (frag_of f) = simplicial_subdivision (Suc p) (frag_of f)›*)
by (simp only: ssf (*‹simplicial_simplex (Suc p) S f›*) 1 (*‹simplicial_chain p (standard_simplex (Suc p)) (simplicial_subdivision p (chain_boundary (Suc p) (frag_of (restrict id (standard_simplex (Suc p))))))›*) 2 (*‹(λi. (∑j≤Suc p. simplicial_vertex j (restrict id (standard_simplex (Suc p))) i) / (real p + 2)) ∈ standard_simplex (Suc p)›*) 3 (*‹f (λi. (∑j≤Suc p. simplicial_vertex j (restrict id (standard_simplex (Suc p))) i) / (real p + 2)) = (λi. (∑j≤Suc p. simplicial_vertex j f i) / (real p + 2))›*) 4 (*‹chain_map p f (simplicial_subdivision p (chain_boundary (Suc p) (frag_of (restrict id (standard_simplex (Suc p)))))) = simplicial_subdivision p (chain_boundary (Suc p) (frag_of f))›*) chain_map_simplicial_cone [of "Suc p" S _ p "Suc p"] (*‹⟦simplicial_simplex (Suc p) S ?g; simplicial_chain p (standard_simplex (Suc p)) ?c; ?v ∈ standard_simplex (Suc p); Suc p ≤ Suc p⟧ ⟹ chain_map (Suc p) ?g (simplicial_cone p ?v ?c) = simplicial_cone p (?g ?v) (chain_map p ?g ?c)›*))
qed (auto simp: frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*) singular_subdivision_diff (*‹singular_subdivision ?p (?a - ?b) = singular_subdivision ?p ?a - singular_subdivision ?p ?b›*))
(*solves the remaining goals:
1. ‹singular_subdivision (Suc (p::nat)) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) = simplicial_subdivision (Suc p) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)›
2. ‹⋀(a::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) b::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int. ⟦singular_subdivision (Suc (p::nat)) a = simplicial_subdivision (Suc p) a; singular_subdivision (Suc p) b = simplicial_subdivision (Suc p) b⟧ ⟹ singular_subdivision (Suc p) (a - b) = simplicial_subdivision (Suc p) (a - b)›*)
qed
lemma naturality_simplicial_subdivision:
"⟦simplicial_chain p (standard_simplex q) c; simplicial_simplex q S g⟧
⟹ simplicial_subdivision p (chain_map p g c) = chain_map p g (simplicial_subdivision p c)"
by (metis naturality_singular_subdivision (*‹singular_chain ?p ?X ?c ⟹ singular_subdivision ?p (chain_map ?p ?g ?c) = chain_map ?p ?g (singular_subdivision ?p ?c)›*) simplicial_chain_chain_map (*‹⟦simplicial_simplex ?q ?X ?f; simplicial_chain ?p (standard_simplex ?q) ?c⟧ ⟹ simplicial_chain ?p ?X (chain_map ?p ?f ?c)›*) simplicial_imp_singular_chain (*‹simplicial_chain ?p ?S ?c ⟹ singular_chain ?p (subtopology (powertop_real UNIV) ?S) ?c›*) singular_subdivision_simplicial_simplex (*‹simplicial_chain ?p ?S ?c ⟹ singular_subdivision ?p ?c = simplicial_subdivision ?p ?c›*))
lemma chain_boundary_singular_subdivision:
"singular_chain p X c
⟹ chain_boundary p (singular_subdivision p c) =
singular_subdivision (p - Suc 0) (chain_boundary p c)"
unfolding singular_chain_def
(*goal: ‹Poly_Mapping.keys c ⊆ singular_simplex_set p X ⟹ chain_boundary p (singular_subdivision p c) = singular_subdivision (p - Suc 0) (chain_boundary p c)›*)
proof (induction rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹chain_boundary (p::nat) (singular_subdivision p (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)) = singular_subdivision (p - Suc (0::nat)) (chain_boundary p (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int))›
2. ‹⋀x::(nat ⇒ real) ⇒ 'a::type. x ∈ singular_simplex_set (p::nat) (X::'a::type topology) ⟹ chain_boundary p (singular_subdivision p (frag_of x)) = singular_subdivision (p - Suc (0::nat)) (chain_boundary p (frag_of x))›
3. ‹⋀(a::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) b::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. ⟦chain_boundary (p::nat) (singular_subdivision p a) = singular_subdivision (p - Suc (0::nat)) (chain_boundary p a); chain_boundary p (singular_subdivision p b) = singular_subdivision (p - Suc (0::nat)) (chain_boundary p b)⟧ ⟹ chain_boundary p (singular_subdivision p (a - b)) = singular_subdivision (p - Suc (0::nat)) (chain_boundary p (a - b))›*)
case (one f) (*‹f ∈ singular_simplex_set p X›*)
then have ssf: "singular_simplex p X f"
by (auto simp: singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*))
then have scp: "simplicial_chain p (standard_simplex p) (frag_of (restrict id (standard_simplex p)))"
by simp
have scp1: "simplicial_chain (p - Suc 0) (standard_simplex p)
(chain_boundary p (frag_of (restrict id (standard_simplex p))))"
using simplicial_chain_boundary (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain (?p - 1) ?S (chain_boundary ?p ?c)›*) by force
have sgp1: "singular_chain (p - Suc 0)
(subtopology (powertop_real UNIV) (standard_simplex p))
(chain_boundary p (frag_of (restrict id (standard_simplex p))))"
using scp1 (*‹simplicial_chain (p - Suc 0) (standard_simplex p) (chain_boundary p (frag_of (restrict id (standard_simplex p))))›*) simplicial_imp_singular_chain (*‹simplicial_chain ?p ?S ?c ⟹ singular_chain ?p (subtopology (powertop_real UNIV) ?S) ?c›*) by blast
have scpp: "singular_chain p (subtopology (powertop_real UNIV) (standard_simplex p))
(frag_of (restrict id (standard_simplex p)))"
using scp (*‹simplicial_chain p (standard_simplex p) (frag_of (restrict id (standard_simplex p)))›*) simplicial_imp_singular_chain (*‹simplicial_chain ?p ?S ?c ⟹ singular_chain ?p (subtopology (powertop_real UNIV) ?S) ?c›*) by blast
then show "?case"
(*goal: ‹chain_boundary (p::nat) (singular_subdivision p (frag_of (f::(nat ⇒ real) ⇒ 'a))) = singular_subdivision (p - Suc (0::nat)) (chain_boundary p (frag_of f))›*)
unfolding singular_subdivision_def
(*goal: ‹chain_boundary p (frag_extend (λf. chain_map p f (simplicial_subdivision p (frag_of (restrict id (standard_simplex p))))) (frag_of f)) = frag_extend (λf. chain_map (p - Suc 0) f (simplicial_subdivision (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f))›*)
using chain_boundary_chain_map[of p "subtopology (powertop_real UNIV)
(standard_simplex p)" _ f] (*‹singular_chain p (subtopology (powertop_real UNIV) (standard_simplex p)) ?c ⟹ chain_boundary p (chain_map p f ?c) = chain_map (p - Suc 0) f (chain_boundary p ?c)›*) apply (simp add: simplicial_chain_simplicial_subdivision (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain ?p ?S (simplicial_subdivision ?p ?c)›*) simplicial_imp_singular_chain (*‹simplicial_chain ?p ?S ?c ⟹ singular_chain ?p (subtopology (powertop_real UNIV) ?S) ?c›*) chain_boundary_simplicial_subdivision [OF scp] (*‹chain_boundary p (simplicial_subdivision p (frag_of (restrict id (standard_simplex p)))) = simplicial_subdivision (p - 1) (chain_boundary p (frag_of (restrict id (standard_simplex p))))›*) flip: singular_subdivision_simplicial_simplex [OF scp1] (*‹singular_subdivision (p - Suc 0) (chain_boundary p (frag_of (restrict id (standard_simplex p)))) = simplicial_subdivision (p - Suc 0) (chain_boundary p (frag_of (restrict id (standard_simplex p))))›*) naturality_singular_subdivision [OF sgp1] (*‹singular_subdivision (p - Suc 0) (chain_map (p - Suc 0) ?g (chain_boundary p (frag_of (restrict id (standard_simplex p))))) = chain_map (p - Suc 0) ?g (singular_subdivision (p - Suc 0) (chain_boundary p (frag_of (restrict id (standard_simplex p)))))›*))
(*goal: ‹chain_boundary p (frag_extend (λf. chain_map p f (simplicial_subdivision p (frag_of (restrict id (standard_simplex p))))) (frag_of f)) = frag_extend (λf. chain_map (p - Suc 0) f (simplicial_subdivision (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f))›*)
by (metis (full_types) singular_subdivision_def (*‹singular_subdivision ?p ≡ frag_extend (λf. chain_map ?p f (simplicial_subdivision ?p (frag_of (restrict id (standard_simplex ?p)))))›*) chain_boundary_chain_map [OF scpp] (*‹chain_boundary p (chain_map p ?g (frag_of (restrict id (standard_simplex p)))) = chain_map (p - Suc 0) ?g (chain_boundary p (frag_of (restrict id (standard_simplex p))))›*) singular_simplex_chain_map_id [OF ssf] (*‹chain_map p f (frag_of (restrict id (standard_simplex p))) = frag_of f›*))
qed (auto simp: singular_subdivision_def (*‹singular_subdivision (?p::nat) ≡ frag_extend (λf::(nat ⇒ real) ⇒ ?'a::type. chain_map ?p f (simplicial_subdivision ?p (frag_of (restrict id (standard_simplex ?p)))))›*) frag_extend_diff (*‹frag_extend (?f::?'b::type ⇒ ?'a::type ⇒₀ int) ((?a::?'b::type ⇒₀ int) - (?b::?'b::type ⇒₀ int)) = frag_extend ?f ?a - frag_extend ?f ?b›*) chain_boundary_diff (*‹chain_boundary (?p::nat) ((?a::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int) - (?b::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int)) = chain_boundary ?p ?a - chain_boundary ?p ?b›*))
(*solves the remaining goals:
1. ‹chain_boundary p (singular_subdivision p 0) = singular_subdivision (p - Suc 0) (chain_boundary p 0)›
2. ‹⋀a b. ⟦chain_boundary p (singular_subdivision p a) = singular_subdivision (p - Suc 0) (chain_boundary p a); chain_boundary p (singular_subdivision p b) = singular_subdivision (p - Suc 0) (chain_boundary p b)⟧ ⟹ chain_boundary p (singular_subdivision p (a - b)) = singular_subdivision (p - Suc 0) (chain_boundary p (a - b))›*)
lemma singular_subdivision_zero:
"singular_chain 0 X c ⟹ singular_subdivision 0 c = c"
unfolding singular_chain_def
(*goal: ‹Poly_Mapping.keys (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⊆ singular_simplex_set (0::nat) (X::'a::type topology) ⟹ singular_subdivision (0::nat) c = c›*)
proof (induction rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹singular_subdivision 0 0 = 0›
2. ‹⋀x. x ∈ singular_simplex_set 0 X ⟹ singular_subdivision 0 (frag_of x) = frag_of x›
3. ‹⋀a b. ⟦singular_subdivision 0 a = a; singular_subdivision 0 b = b⟧ ⟹ singular_subdivision 0 (a - b) = a - b›*)
case (one f) (*‹(f::(nat ⇒ real) ⇒ 'a::type) ∈ singular_simplex_set (0::nat) (X::'a::type topology)›*)
then have "restrict (f ∘ restrict id (standard_simplex 0)) (standard_simplex 0) = f"
by (simp add: extensional_restrict (*‹(?f::?'a ⇒ ?'b) ∈ extensional (?A::?'a set) ⟹ restrict ?f ?A = ?f›*) restrict_compose_right (*‹restrict ((?g::?'c ⇒ ?'b) ∘ restrict (?f::?'a ⇒ ?'c) (?S::?'a set)) ?S = restrict (?g ∘ ?f) ?S›*) singular_simplex_def (*‹singular_simplex (?p::nat) (?X::?'a topology) (?f::(nat ⇒ real) ⇒ ?'a) ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*))
then show "?case"
(*goal: ‹singular_subdivision 0 (frag_of f) = frag_of f›*)
by (auto simp: singular_subdivision_def (*‹singular_subdivision (?p::nat) ≡ frag_extend (λf::(nat ⇒ real) ⇒ ?'a. chain_map ?p f (simplicial_subdivision ?p (frag_of (restrict id (standard_simplex ?p)))))›*) simplex_map_def (*‹simplex_map (?p::nat) (?g::?'b ⇒ ?'a) (?c::(nat ⇒ real) ⇒ ?'b) ≡ restrict (?g ∘ ?c) (standard_simplex ?p)›*))
qed (auto simp: singular_subdivision_def (*‹singular_subdivision ?p ≡ frag_extend (λf. chain_map ?p f (simplicial_subdivision ?p (frag_of (restrict id (standard_simplex ?p)))))›*) frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*))
(*solves the remaining goals:
1. ‹singular_subdivision 0 0 = 0›
2. ‹⋀a b. ⟦singular_subdivision 0 a = a; singular_subdivision 0 b = b⟧ ⟹ singular_subdivision 0 (a - b) = a - b›*)
primrec subd where
"subd 0 = (λx. 0)"
| "subd (Suc p) =
frag_extend
(λf. simplicial_cone (Suc p) (λi. (∑j≤Suc p. simplicial_vertex j f i) / real (Suc p + 1))
(simplicial_subdivision (Suc p) (frag_of f) - frag_of f -
subd p (chain_boundary (Suc p) (frag_of f))))"
lemma subd_0 [simp]: "subd p 0 = 0"
apply (induction p)
(*goals:
1. ‹subd 0 0 = 0›
2. ‹⋀p. subd p 0 = 0 ⟹ subd (Suc p) 0 = 0›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma subd_diff [simp]: "subd p (c1 - c2) = subd p c1 - subd p c2"
apply (induction p)
(*goals:
1. ‹subd 0 (c1 - c2) = subd 0 c1 - subd 0 c2›
2. ‹⋀p. subd p (c1 - c2) = subd p c1 - subd p c2 ⟹ subd (Suc p) (c1 - c2) = subd (Suc p) c1 - subd (Suc p) c2›
discuss goal 1*)
apply ((auto simp: frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*))[1])
(*discuss goal 2*)
apply ((auto simp: frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*))[1])
(*proven 2 subgoals*) .
lemma subd_uminus [simp]: "subd p (-c) = - subd p c"
by (metis diff_0 (*‹(0::?'a) - (?a::?'a) = - ?a›*) subd_0 (*‹subd (?p::nat) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) = (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)›*) subd_diff (*‹subd (?p::nat) ((?c1.0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) - (?c2.0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) = subd ?p ?c1.0 - subd ?p ?c2.0›*))
lemma subd_power_uminus: "subd p (frag_cmul ((-1) ^ k) c) = frag_cmul ((-1) ^ k) (subd p c)"
proof (induction k)
(*goals:
1. ‹subd p (frag_cmul ((- 1) ^ 0) c) = frag_cmul ((- 1) ^ 0) (subd p c)›
2. ‹⋀k. subd p (frag_cmul ((- 1) ^ k) c) = frag_cmul ((- 1) ^ k) (subd p c) ⟹ subd p (frag_cmul ((- 1) ^ Suc k) c) = frag_cmul ((- 1) ^ Suc k) (subd p c)›*)
case 0 (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹subd p (frag_cmul ((- 1) ^ 0) c) = frag_cmul ((- 1) ^ 0) (subd p c)›*)
by simp
next
(*goal: ‹⋀k. subd p (frag_cmul ((- 1) ^ k) c) = frag_cmul ((- 1) ^ k) (subd p c) ⟹ subd p (frag_cmul ((- 1) ^ Suc k) c) = frag_cmul ((- 1) ^ Suc k) (subd p c)›*)
case (Suc k) (*‹subd p (frag_cmul ((- 1) ^ k) c) = frag_cmul ((- 1) ^ k) (subd p c)›*)
then show "?case"
(*goal: ‹subd p (frag_cmul ((- 1) ^ Suc k) c) = frag_cmul ((- 1) ^ Suc k) (subd p c)›*)
by (metis frag_cmul_cmul (*‹frag_cmul ?c (frag_cmul ?d ?x) = frag_cmul (?c * ?d) ?x›*) frag_cmul_minus_one (*‹frag_cmul (- 1) ?x = - ?x›*) power_Suc (*‹?a ^ Suc ?n = ?a * ?a ^ ?n›*) subd_uminus (*‹subd ?p (- ?c) = - subd ?p ?c›*))
qed
lemma subd_power_sum: "subd p (sum f I) = sum (subd p ∘ f) I"
proof (induction I rule: infinite_finite_induct (*‹⟦⋀A. infinite A ⟹ ?P A; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?A›*))
(*goals:
1. ‹⋀A. infinite A ⟹ subd p (sum f A) = sum (subd p ∘ f) A›
2. ‹subd p (sum f {}) = sum (subd p ∘ f) {}›
3. ‹⋀x F. ⟦finite F; x ∉ F; subd p (sum f F) = sum (subd p ∘ f) F⟧ ⟹ subd p (sum f (insert x F)) = sum (subd p ∘ f) (insert x F)›*)
case (insert i I) (*‹finite I› ‹i ∉ I› ‹subd (p::nat) (sum (f::'a ⇒ ((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) (I::'a set)) = sum (subd p ∘ f) I›*)
then show "?case"
(*goal: ‹subd p (sum f (insert i I)) = sum (subd p ∘ f) (insert i I)›*)
by (metis (no_types, lifting) comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) diff_minus_eq_add (*‹?a - - ?b = ?a + ?b›*) subd_diff (*‹subd ?p (?c1.0 - ?c2.0) = subd ?p ?c1.0 - subd ?p ?c2.0›*) subd_uminus (*‹subd ?p (- ?c) = - subd ?p ?c›*) sum.insert (*‹⟦finite ?A; ?x ∉ ?A⟧ ⟹ sum ?g (insert ?x ?A) = ?g ?x + sum ?g ?A›*))
qed (auto)
(*solves the remaining goals:
1. ‹⋀A. infinite A ⟹ subd p (sum f A) = sum (subd p ∘ f) A›
2. ‹subd p (sum f {}) = sum (subd p ∘ f) {}›*)
lemma subd: "simplicial_chain p (standard_simplex s) c
⟹ (∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc p) g (subd p c) = subd p (chain_map p g c))
∧ simplicial_chain (Suc p) (standard_simplex s) (subd p c)
∧ (chain_boundary (Suc p) (subd p c)) + (subd (p - Suc 0) (chain_boundary p c)) = (simplicial_subdivision p c) - c"
proof (induction p arbitrary: c)
(*goals:
1. ‹⋀c. simplicial_chain 0 (standard_simplex s) c ⟹ (∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc 0) g (subd 0 c) = subd 0 (chain_map 0 g c)) ∧ simplicial_chain (Suc 0) (standard_simplex s) (subd 0 c) ∧ chain_boundary (Suc 0) (subd 0 c) + subd (0 - Suc 0) (chain_boundary 0 c) = simplicial_subdivision 0 c - c›
2. ‹⋀p c. ⟦⋀c. simplicial_chain p (standard_simplex s) c ⟹ (∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc p) g (subd p c) = subd p (chain_map p g c)) ∧ simplicial_chain (Suc p) (standard_simplex s) (subd p c) ∧ chain_boundary (Suc p) (subd p c) + subd (p - Suc 0) (chain_boundary p c) = simplicial_subdivision p c - c; simplicial_chain (Suc p) (standard_simplex s) c⟧ ⟹ (∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) c) = subd (Suc p) (chain_map (Suc p) g c)) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) c) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) c) + subd (Suc p - Suc 0) (chain_boundary (Suc p) c) = simplicial_subdivision (Suc p) c - c›*)
case (Suc p) (*‹simplicial_chain p (standard_simplex s) ?c ⟹ (∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc p) g (subd p ?c) = subd p (chain_map p g ?c)) ∧ simplicial_chain (Suc p) (standard_simplex s) (subd p ?c) ∧ chain_boundary (Suc p) (subd p ?c) + subd (p - Suc 0) (chain_boundary p ?c) = simplicial_subdivision p ?c - ?c› ‹simplicial_chain (Suc (p::nat)) (standard_simplex (s::nat)) (c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)›*)
show "?case"
(*goal: ‹(∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) c) = subd (Suc p) (chain_map (Suc p) g c)) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) c) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) c) + subd (Suc p - Suc 0) (chain_boundary (Suc p) c) = simplicial_subdivision (Suc p) c - c›*)
using Suc.prems[unfolded simplicial_chain_def] (*‹Poly_Mapping.keys c ⊆ Collect (simplicial_simplex (Suc p) (standard_simplex s))›*) proof (induction rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹(∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) 0) = subd (Suc p) (chain_map (Suc p) g 0)) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) 0) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) 0) + subd (Suc p - Suc 0) (chain_boundary (Suc p) 0) = simplicial_subdivision (Suc p) 0 - 0›
2. ‹⋀x. x ∈ Collect (simplicial_simplex (Suc p) (standard_simplex s)) ⟹ (∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) (frag_of x)) = subd (Suc p) (chain_map (Suc p) g (frag_of x))) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) (frag_of x)) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) (frag_of x)) + subd (Suc p - Suc 0) (chain_boundary (Suc p) (frag_of x)) = simplicial_subdivision (Suc p) (frag_of x) - frag_of x›
3. ‹⋀a b. ⟦(∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) a) = subd (Suc p) (chain_map (Suc p) g a)) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) a) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) a) + subd (Suc p - Suc 0) (chain_boundary (Suc p) a) = simplicial_subdivision (Suc p) a - a; (∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) b) = subd (Suc p) (chain_map (Suc p) g b)) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) b) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) b) + subd (Suc p - Suc 0) (chain_boundary (Suc p) b) = simplicial_subdivision (Suc p) b - b⟧ ⟹ (∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) (a - b)) = subd (Suc p) (chain_map (Suc p) g (a - b))) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) (a - b)) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) (a - b)) + subd (Suc p - Suc 0) (chain_boundary (Suc p) (a - b)) = simplicial_subdivision (Suc p) (a - b) - (a - b)›*)
case (one f) (*‹f ∈ Collect (simplicial_simplex (Suc p) (standard_simplex s))›*)
then obtain l where l: "(λx i. ∑j≤Suc p. l j i * x j) ` standard_simplex (Suc p) ⊆ standard_simplex s" and feq: "f = oriented_simplex (Suc p) l"
(*goal: ‹(⋀l. ⟦(λx i. ∑j≤Suc p. l j i * x j) ` standard_simplex (Suc p) ⊆ standard_simplex s; f = oriented_simplex (Suc p) l⟧ ⟹ thesis) ⟹ thesis›*)
by (metis (mono_tags) mem_Collect_eq (*‹((?a::?'a) ∈ Collect (?P::?'a ⇒ bool)) = ?P ?a›*) simplicial_simplex (*‹simplicial_simplex (?p::nat) (?S::(?'a ⇒ real) set) (?f::(nat ⇒ real) ⇒ ?'a ⇒ real) = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l::nat ⇒ ?'a ⇒ real. ?f = oriented_simplex ?p l))›*) simplicial_simplex_oriented_simplex (*‹simplicial_simplex (?p::nat) (?S::(?'a ⇒ real) set) (oriented_simplex ?p (?l::nat ⇒ ?'a ⇒ real)) = ((λ(x::nat ⇒ real) i::?'a. ∑j::nat≤?p. ?l j i * x j) ` standard_simplex ?p ⊆ ?S)›*))
have scf: "simplicial_chain (Suc p) (standard_simplex s) (frag_of f)"
using one (*‹f ∈ Collect (simplicial_simplex (Suc p) (standard_simplex s))›*) by simp
have lss: "l i ∈ standard_simplex s" if "i ≤ Suc p" for i
proof (-)
(*goal: ‹l i ∈ standard_simplex s›*)
have "(λi'. ∑j≤Suc p. l j i' * (if j = i then 1 else 0)) ∈ standard_simplex s"
using subsetD[OF l] (*‹?c ∈ (λx i. ∑j≤Suc p. l j i * x j) ` standard_simplex (Suc p) ⟹ ?c ∈ standard_simplex s›*) basis_in_standard_simplex (*‹((λj. if j = ?i then 1 else 0) ∈ standard_simplex ?p) = (?i ≤ ?p)›*) that (*‹i ≤ Suc p›*) by blast
moreover have "(λi'. ∑j≤Suc p. l j i' * (if j = i then 1 else 0)) = l i"
using that (*‹i ≤ Suc p›*) by (simp add: if_distrib [of "λx. _ * x"] (*‹?uu5 * (if ?c then ?x else ?y) = (if ?c then ?uu5 * ?x else ?uu5 * ?y)›*) del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
ultimately show "?thesis"
(*goal: ‹l i ∈ standard_simplex s›*)
by simp
qed
have "*": "(⋀i. i ≤ n ⟹ l i ∈ standard_simplex s)
⟹ (λi. (∑j≤n. l j i) / (Suc n)) ∈ standard_simplex s" for n
proof (induction n)
(*goals:
1. ‹(⋀i. i ≤ 0 ⟹ l i ∈ standard_simplex s) ⟹ (λi. (∑j≤0. l j i) / real (Suc 0)) ∈ standard_simplex s›
2. ‹⋀n. ⟦(⋀i. i ≤ n ⟹ l i ∈ standard_simplex s) ⟹ (λi. (∑j≤n. l j i) / real (Suc n)) ∈ standard_simplex s; ⋀i. i ≤ Suc n ⟹ l i ∈ standard_simplex s⟧ ⟹ (λi. (∑j≤Suc n. l j i) / real (Suc (Suc n))) ∈ standard_simplex s›*)
case (Suc n) (*‹(⋀i. i ≤ n ⟹ l i ∈ standard_simplex s) ⟹ (λi. (∑j≤n. l j i) / real (Suc n)) ∈ standard_simplex s› ‹?i ≤ Suc n ⟹ l ?i ∈ standard_simplex s›*)
let ?x = "λi. (1 - inverse (n + 2)) * ((∑j≤n. l j i) / (Suc n)) + inverse (n + 2) * l (Suc n) i"
have "?x ∈ standard_simplex s"
proof (rule convex_standard_simplex (*‹⟦?x ∈ standard_simplex ?p; ?y ∈ standard_simplex ?p; 0 ≤ ?u; ?u ≤ 1⟧ ⟹ (λi. (1 - ?u) * ?x i + ?u * ?y i) ∈ standard_simplex ?p›*))
(*goals:
1. ‹(λi. (∑j≤n. l j i) / real (Suc n)) ∈ standard_simplex s›
2. ‹l (Suc n) ∈ standard_simplex s›
3. ‹0 ≤ inverse (real (n + 2))›
4. ‹inverse (real (n + 2)) ≤ 1›*)
show "(λi. (∑j≤n. l j i) / real (Suc n)) ∈ standard_simplex s"
using Suc (*‹(⋀i. i ≤ n ⟹ l i ∈ standard_simplex s) ⟹ (λi. (∑j≤n. l j i) / real (Suc n)) ∈ standard_simplex s› ‹?i ≤ Suc n ⟹ l ?i ∈ standard_simplex s›*) by simp
qed (auto simp: lss (*‹?i ≤ Suc p ⟹ l ?i ∈ standard_simplex s›*) Suc (*‹(⋀i. i ≤ n ⟹ l i ∈ standard_simplex s) ⟹ (λi. (∑j≤n. l j i) / real (Suc n)) ∈ standard_simplex s› ‹?i ≤ Suc n ⟹ l ?i ∈ standard_simplex s›*) inverse_le_1_iff (*‹(inverse ?x ≤ 1) = (?x ≤ 0 ∨ 1 ≤ ?x)›*))
(*solves the remaining goals:
1. ‹l (Suc n) ∈ standard_simplex s›
2. ‹0 ≤ inverse (real (n + 2))›
3. ‹inverse (real (n + 2)) ≤ 1›*)
moreover have "?x = (λi. (∑j≤Suc n. l j i) / real (Suc (Suc n)))"
by (force simp: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*))
ultimately show "?case"
(*goal: ‹(λi. (∑j≤Suc n. l j i) / real (Suc (Suc n))) ∈ standard_simplex s›*)
by simp
qed (auto)
(*solved the remaining goal: ‹(⋀i. i ≤ 0 ⟹ l i ∈ standard_simplex s) ⟹ (λi. (∑j≤0. l j i) / real (Suc 0)) ∈ standard_simplex s›*)
have "**": "(λi. (∑j≤Suc p. simplicial_vertex j f i) / (2 + real p)) ∈ standard_simplex s"
using "*"[of "Suc p"] (*‹(⋀i. i ≤ Suc p ⟹ l i ∈ standard_simplex s) ⟹ (λi. (∑j≤Suc p. l j i) / real (Suc (Suc p))) ∈ standard_simplex s›*) lss (*‹?i ≤ Suc p ⟹ l ?i ∈ standard_simplex s›*) by (simp add: simplicial_vertex_oriented_simplex (*‹simplicial_vertex ?i (oriented_simplex ?p ?l) = (if ?i ≤ ?p then ?l ?i else undefined)›*) feq (*‹f = oriented_simplex (Suc p) l›*))
show "?case"
(*goal: ‹(∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) (frag_of f)) = subd (Suc p) (chain_map (Suc p) g (frag_of f))) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) (frag_of f)) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) (frag_of f)) + subd (Suc p - Suc 0) (chain_boundary (Suc p) (frag_of f)) = simplicial_subdivision (Suc p) (frag_of f) - frag_of f›*)
proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*))
(*goals:
1. ‹⋀r g. simplicial_simplex s (standard_simplex r) g ⟹ chain_map (Suc (Suc p)) g (subd (Suc p) (frag_of f)) = subd (Suc p) (chain_map (Suc p) g (frag_of f))›
2. ‹simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) (frag_of f))›
3. ‹chain_boundary (Suc (Suc p)) (subd (Suc p) (frag_of f)) + subd (Suc p - Suc 0) (chain_boundary (Suc p) (frag_of f)) = simplicial_subdivision (Suc p) (frag_of f) - frag_of f›*)
fix r and g
assume g: "simplicial_simplex s (standard_simplex r) g" (*‹simplicial_simplex (s::nat) (standard_simplex (r::nat)) (g::(nat ⇒ real) ⇒ nat ⇒ real)›*)
then obtain m where geq: "g = oriented_simplex s m"
(*goal: ‹(⋀m. g = oriented_simplex s m ⟹ thesis) ⟹ thesis›*)
using simplicial_simplex (*‹simplicial_simplex ?p ?S ?f = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l. ?f = oriented_simplex ?p l))›*) by blast
have 1: "simplicial_chain (Suc p) (standard_simplex s) (simplicial_subdivision (Suc p) (frag_of f))"
by (metis mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) one.hyps (*‹f ∈ Collect (simplicial_simplex (Suc p) (standard_simplex s))›*) simplicial_chain_of (*‹simplicial_chain ?p ?S (frag_of ?c) = simplicial_simplex ?p ?S ?c›*) simplicial_chain_simplicial_subdivision (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain ?p ?S (simplicial_subdivision ?p ?c)›*))
have 2: "(∑j≤Suc p. ∑i≤s. m i k * simplicial_vertex j f i)
= (∑j≤Suc p. simplicial_vertex j
(simplex_map (Suc p) (oriented_simplex s m) f) k)" for k
proof (rule sum.cong [OF refl] (*‹(⋀x. x ∈ ?A ⟹ ?g x = ?h x) ⟹ sum ?g ?A = sum ?h ?A›*))
(*goal: ‹⋀x. x ∈ {..Suc p} ⟹ (∑i≤s. m i k * simplicial_vertex x f i) = simplicial_vertex x (simplex_map (Suc p) (oriented_simplex s m) f) k›*)
fix j
assume j: "j ∈ {..Suc p}" (*‹(j::nat) ∈ {..Suc (p::nat)}›*)
have eq: "simplex_map (Suc p) (oriented_simplex s m) (oriented_simplex (Suc p) l)
= oriented_simplex (Suc p) (oriented_simplex s m ∘ l)"
proof (rule simplex_map_oriented_simplex (*‹⟦simplicial_simplex ?p (standard_simplex ?q) (oriented_simplex ?p ?l); simplicial_simplex ?r ?S ?g; ?q ≤ ?r⟧ ⟹ simplex_map ?p ?g (oriented_simplex ?p ?l) = oriented_simplex ?p (?g ∘ ?l)›*))
(*goals:
1. ‹simplicial_simplex (Suc (p::nat)) (standard_simplex (?q::nat)) (oriented_simplex (Suc p) (l::nat ⇒ nat ⇒ real))›
2. ‹simplicial_simplex (?r::nat) (?S::(nat ⇒ real) set) (oriented_simplex (s::nat) (m::nat ⇒ nat ⇒ real))›
3. ‹(?q::nat) ≤ (?r::nat)›*)
show "simplicial_simplex (Suc p) (standard_simplex s) (oriented_simplex (Suc p) l)"
using one (*‹f ∈ Collect (simplicial_simplex (Suc p) (standard_simplex s))›*) by (simp add: feq (*‹f = oriented_simplex (Suc p) l›*) flip: oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*))
show "simplicial_simplex s (standard_simplex r) (oriented_simplex s m)"
using g (*‹simplicial_simplex s (standard_simplex r) g›*) by (simp add: geq (*‹g = oriented_simplex s m›*))
qed (auto)
(*solved the remaining goal: ‹s ≤ s›*)
show "(∑i≤s. m i k * simplicial_vertex j f i)
= simplicial_vertex j (simplex_map (Suc p) (oriented_simplex s m) f) k"
using one (*‹(f::(nat ⇒ real) ⇒ nat ⇒ real) ∈ Collect (simplicial_simplex (Suc (p::nat)) (standard_simplex (s::nat)))›*) j (*‹j ∈ {..Suc p}›*) apply (simp add: feq (*‹(f::(nat ⇒ real) ⇒ nat ⇒ real) = oriented_simplex (Suc (p::nat)) (l::nat ⇒ nat ⇒ real)›*) eq (*‹simplex_map (Suc (p::nat)) (oriented_simplex (s::nat) (m::nat ⇒ nat ⇒ real)) (oriented_simplex (Suc p) (l::nat ⇒ nat ⇒ real)) = oriented_simplex (Suc p) (oriented_simplex s m ∘ l)›*) simplicial_vertex_oriented_simplex (*‹simplicial_vertex (?i::nat) (oriented_simplex (?p::nat) (?l::nat ⇒ ?'a ⇒ real)) = (if ?i ≤ ?p then ?l ?i else undefined)›*) simplicial_simplex_oriented_simplex (*‹simplicial_simplex (?p::nat) (?S::(?'a ⇒ real) set) (oriented_simplex ?p (?l::nat ⇒ ?'a ⇒ real)) = ((λ(x::nat ⇒ real) i::?'a. ∑j::nat≤?p. ?l j i * x j) ` standard_simplex ?p ⊆ ?S)›*) image_subset_iff (*‹((?f::?'b ⇒ ?'a) ` (?A::?'b set) ⊆ (?B::?'a set)) = (∀x::?'b∈?A. ?f x ∈ ?B)›*))
(*goal: ‹(∑i≤s. m i k * simplicial_vertex j f i) = simplicial_vertex j (simplex_map (Suc p) (oriented_simplex s m) f) k›*)
apply (drule_tac x="(λi. if i = j then 1 else 0)" in bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))
(*goals:
1. ‹(j::nat) ≤ Suc (p::nat) ⟹ (λi::nat. if i = j then 1::real else (0::real)) ∈ standard_simplex (Suc p)›
2. ‹⟦(j::nat) ≤ Suc (p::nat); (λi::nat. (∑ja::nat≤p. (l::nat ⇒ nat ⇒ real) ja i * (if ja = j then 1::real else (0::real))) + l (Suc p) i * (if Suc p = j then 1::real else (0::real))) ∈ standard_simplex (s::nat)⟧ ⟹ (∑i::nat≤s. (m::nat ⇒ nat ⇒ real) i (k::nat) * l j i) = oriented_simplex s m (l j) k›
discuss goal 1*)
apply ((auto simp: oriented_simplex_def (*‹oriented_simplex (?p::nat) (?l::nat ⇒ ?'a ⇒ real) ≡ λx::nat ⇒ real∈standard_simplex ?p. λi::?'a. ∑j::nat≤?p. ?l j i * x j›*) lss (*‹(?i::nat) ≤ Suc (p::nat) ⟹ (l::nat ⇒ nat ⇒ real) ?i ∈ standard_simplex (s::nat)›*))[1])
(*discuss goal 2*)
apply ((auto simp: oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) lss (*‹?i ≤ Suc p ⟹ l ?i ∈ standard_simplex s›*))[1])
(*proven 2 subgoals*) .
qed
have 4: "chain_map (Suc p) g (subd p (chain_boundary (Suc p) (frag_of f)))
= subd p (chain_boundary (Suc p) (frag_of (simplex_map (Suc p) g f)))"
by (metis (no_types) One_nat_def (*‹1 = Suc 0›*) scf (*‹simplicial_chain (Suc p) (standard_simplex s) (frag_of f)›*) Suc.IH (*‹simplicial_chain p (standard_simplex s) ?c ⟹ (∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc p) g (subd p ?c) = subd p (chain_map p g ?c)) ∧ simplicial_chain (Suc p) (standard_simplex s) (subd p ?c) ∧ chain_boundary (Suc p) (subd p ?c) + subd (p - Suc 0) (chain_boundary p ?c) = simplicial_subdivision p ?c - ?c›*) chain_boundary_chain_map (*‹singular_chain ?p ?X ?c ⟹ chain_boundary ?p (chain_map ?p ?g ?c) = chain_map (?p - Suc 0) ?g (chain_boundary ?p ?c)›*) chain_map_of (*‹chain_map ?p ?g (frag_of ?f) = frag_of (simplex_map ?p ?g ?f)›*) diff_Suc_Suc (*‹Suc ?m - Suc ?n = ?m - ?n›*) diff_zero (*‹?a - 0 = ?a›*) g (*‹simplicial_simplex s (standard_simplex r) g›*) simplicial_chain_boundary (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain (?p - 1) ?S (chain_boundary ?p ?c)›*) simplicial_imp_singular_chain (*‹simplicial_chain ?p ?S ?c ⟹ singular_chain ?p (subtopology (powertop_real UNIV) ?S) ?c›*))
show "chain_map (Suc (Suc p)) g (subd (Suc p) (frag_of f)) = subd (Suc p) (chain_map (Suc p) g (frag_of f))"
unfolding subd.simps frag_extend_of
(*goal: ‹chain_map (Suc (Suc p)) g (simplicial_cone (Suc p) (λi. (∑j≤Suc p. simplicial_vertex j f i) / real (Suc p + 1)) (simplicial_subdivision (Suc p) (frag_of f) - frag_of f - subd p (chain_boundary (Suc p) (frag_of f)))) = frag_extend (λf. simplicial_cone (Suc p) (λi. (∑j≤Suc p. simplicial_vertex j f i) / real (Suc p + 1)) (simplicial_subdivision (Suc p) (frag_of f) - frag_of f - subd p (chain_boundary (Suc p) (frag_of f)))) (chain_map (Suc p) g (frag_of f))›*)
using g (*‹simplicial_simplex s (standard_simplex r) g›*) apply (subst chain_map_simplicial_cone [of s "standard_simplex r" _ "Suc p" s] (*‹⟦simplicial_simplex (s::nat) (standard_simplex (r::nat)) (?g::(nat ⇒ real) ⇒ nat ⇒ real); simplicial_chain (Suc (p::nat)) (standard_simplex s) (?c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int); (?v::nat ⇒ real) ∈ standard_simplex s; s ≤ s⟧ ⟹ chain_map (Suc (Suc p)) ?g (simplicial_cone (Suc p) ?v ?c) = simplicial_cone (Suc p) (?g ?v) (chain_map (Suc p) ?g ?c)›*), assumption)
(*goal: ‹chain_map (Suc (Suc p)) g (simplicial_cone (Suc p) (λi. (∑j≤Suc p. simplicial_vertex j f i) / real (Suc p + 1)) (simplicial_subdivision (Suc p) (frag_of f) - frag_of f - subd p (chain_boundary (Suc p) (frag_of f)))) = frag_extend (λf. simplicial_cone (Suc p) (λi. (∑j≤Suc p. simplicial_vertex j f i) / real (Suc p + 1)) (simplicial_subdivision (Suc p) (frag_of f) - frag_of f - subd p (chain_boundary (Suc p) (frag_of f)))) (chain_map (Suc p) g (frag_of f))›*)
apply (metis "1" (*‹simplicial_chain (Suc (p::nat)) (standard_simplex (s::nat)) (simplicial_subdivision (Suc p) (frag_of (f::(nat ⇒ real) ⇒ nat ⇒ real)))›*) Suc.IH (*‹simplicial_chain (p::nat) (standard_simplex (s::nat)) (?c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) ⟹ (∀(r::nat) g::(nat ⇒ real) ⇒ nat ⇒ real. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc p) g (subd p ?c) = subd p (chain_map p g ?c)) ∧ simplicial_chain (Suc p) (standard_simplex s) (subd p ?c) ∧ chain_boundary (Suc p) (subd p ?c) + subd (p - Suc (0::nat)) (chain_boundary p ?c) = simplicial_subdivision p ?c - ?c›*) diff_Suc_1 (*‹Suc (?n::nat) - (1::nat) = ?n›*) scf (*‹simplicial_chain (Suc (p::nat)) (standard_simplex (s::nat)) (frag_of (f::(nat ⇒ real) ⇒ nat ⇒ real))›*) simplicial_chain_boundary (*‹simplicial_chain (?p::nat) (?S::(?'a ⇒ real) set) (?c::((nat ⇒ real) ⇒ ?'a ⇒ real) ⇒₀ int) ⟹ simplicial_chain (?p - (1::nat)) ?S (chain_boundary ?p ?c)›*) simplicial_chain_diff (*‹⟦simplicial_chain (?p::nat) (?S::(?'a ⇒ real) set) (?c1.0::((nat ⇒ real) ⇒ ?'a ⇒ real) ⇒₀ ?'b); simplicial_chain ?p ?S (?c2.0::((nat ⇒ real) ⇒ ?'a ⇒ real) ⇒₀ ?'b)⟧ ⟹ simplicial_chain ?p ?S (?c1.0 - ?c2.0)›*))
(*top goal: ‹simplicial_simplex s (standard_simplex r) g ⟹ simplicial_chain (Suc p) (standard_simplex s) (simplicial_subdivision (Suc p) (frag_of f) - frag_of f - subd p (chain_boundary (Suc p) (frag_of f)))› and 3 goals remain*)
using "**" (*‹(λi::nat. (∑j::nat≤Suc (p::nat). simplicial_vertex j (f::(nat ⇒ real) ⇒ nat ⇒ real) i) / ((2::real) + real p)) ∈ standard_simplex (s::nat)›*) apply ((auto)[1])
(*top goal: ‹simplicial_simplex s (standard_simplex r) g ⟹ (λi. (∑j≤Suc p. simplicial_vertex j f i) / real (Suc p + 1)) ∈ standard_simplex s› and 2 goals remain*)
apply (rule order_refl (*‹?x ≤ ?x›*))
(*top goal: ‹simplicial_simplex s (standard_simplex r) g ⟹ s ≤ s› and 1 goal remains*)
unfolding chain_map_of frag_extend_of
(*goal: ‹simplicial_simplex s (standard_simplex r) g ⟹ simplicial_cone (Suc p) (g (λi. (∑j≤Suc p. simplicial_vertex j f i) / real (Suc p + 1))) (chain_map (Suc p) g (simplicial_subdivision (Suc p) (frag_of f) - frag_of f - subd p (chain_boundary (Suc p) (frag_of f)))) = simplicial_cone (Suc p) (λi. (∑j≤Suc p. simplicial_vertex j (simplex_map (Suc p) g f) i) / real (Suc p + 1)) (simplicial_subdivision (Suc p) (frag_of (simplex_map (Suc p) g f)) - frag_of (simplex_map (Suc p) g f) - subd p (chain_boundary (Suc p) (frag_of (simplex_map (Suc p) g f))))›*)
apply (rule arg_cong2 [where f = "simplicial_cone (Suc p)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ simplicial_cone (Suc p) ?a ?c = simplicial_cone (Suc p) ?b ?d›*))
(*goal: ‹simplicial_simplex (s::nat) (standard_simplex (r::nat)) (g::(nat ⇒ real) ⇒ nat ⇒ real) ⟹ simplicial_cone (Suc (p::nat)) (g (λi::nat. (∑j::nat≤Suc p. simplicial_vertex j (f::(nat ⇒ real) ⇒ nat ⇒ real) i) / real (Suc p + (1::nat)))) (chain_map (Suc p) g (simplicial_subdivision (Suc p) (frag_of f) - frag_of f - subd p (chain_boundary (Suc p) (frag_of f)))) = simplicial_cone (Suc p) (λi::nat. (∑j::nat≤Suc p. simplicial_vertex j (simplex_map (Suc p) g f) i) / real (Suc p + (1::nat))) (simplicial_subdivision (Suc p) (frag_of (simplex_map (Suc p) g f)) - frag_of (simplex_map (Suc p) g f) - subd p (chain_boundary (Suc p) (frag_of (simplex_map (Suc p) g f))))›*)
apply (simp add: geq (*‹g = oriented_simplex s m›*) sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*) oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) ** (*‹(λi. (∑j≤Suc p. simplicial_vertex j f i) / (2 + real p)) ∈ standard_simplex s›*) del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*) flip: sum_divide_distrib (*‹sum ?f ?A / ?r = (∑n∈?A. ?f n / ?r)›*))
(*top goal: ‹simplicial_simplex (s::nat) (standard_simplex (r::nat)) (g::(nat ⇒ real) ⇒ nat ⇒ real) ⟹ g (λi::nat. (∑j::nat≤Suc (p::nat). simplicial_vertex j (f::(nat ⇒ real) ⇒ nat ⇒ real) i) / real (Suc p + (1::nat))) = (λi::nat. (∑j::nat≤Suc p. simplicial_vertex j (simplex_map (Suc p) g f) i) / real (Suc p + (1::nat)))› and 1 goal remains*)
using "2" (*‹(∑j≤Suc p. ∑i≤s. m i ?k * simplicial_vertex j f i) = (∑j≤Suc p. simplicial_vertex j (simplex_map (Suc p) (oriented_simplex s m) f) ?k)›*) apply (simp only: oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) sum.swap [where A = "{..s}"] (*‹(∑i≤s. sum (?g i) ?B) = (∑j∈?B. ∑i≤s. ?g i j)›*))
(*top goal: ‹simplicial_simplex s (standard_simplex r) (λx∈standard_simplex s. λi. ∑j≤s. m j i * x j) ⟹ (λi. (∑j≤s. ∑n≤Suc p. m j i * simplicial_vertex n f j) / (2 + real p)) = (λi. (∑j≤Suc p. simplicial_vertex j (simplex_map (Suc p) (λx∈standard_simplex s. λi. ∑j≤s. m j i * x j) f) i) / (2 + real p))› and 1 goal remains*)
using naturality_simplicial_subdivision (*‹⟦simplicial_chain ?p (standard_simplex ?q) ?c; simplicial_simplex ?q ?S ?g⟧ ⟹ simplicial_subdivision ?p (chain_map ?p ?g ?c) = chain_map ?p ?g (simplicial_subdivision ?p ?c)›*) scf (*‹simplicial_chain (Suc p) (standard_simplex s) (frag_of f)›*) by (fastforce simp add: 4 (*‹chain_map (Suc p) g (subd p (chain_boundary (Suc p) (frag_of f))) = subd p (chain_boundary (Suc p) (frag_of (simplex_map (Suc p) g f)))›*) chain_map_diff (*‹chain_map ?p ?g (?a - ?b) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*))
next
(*goals:
1. ‹simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) (frag_of f))›
2. ‹chain_boundary (Suc (Suc p)) (subd (Suc p) (frag_of f)) + subd (Suc p - Suc 0) (chain_boundary (Suc p) (frag_of f)) = simplicial_subdivision (Suc p) (frag_of f) - frag_of f›*)
have sc: "simplicial_chain (Suc p) (standard_simplex s)
(simplicial_cone p
(λi. (∑j≤Suc p. simplicial_vertex j f i) / (Suc (Suc p)))
(simplicial_subdivision p
(chain_boundary (Suc p) (frag_of f))))"
by (metis diff_Suc_1 (*‹Suc ?n - 1 = ?n›*) nat.simps( (*‹Suc ?x2.0 ≠ 0›*) 3) simplicial_subdivision_of (*‹simplicial_subdivision ?p (frag_of ?f) = (if ?p = 0 then frag_of ?f else simplicial_cone (?p - 1) (λi. (∑j≤?p. simplicial_vertex j ?f i) / real (Suc ?p)) (simplicial_subdivision (?p - 1) (chain_boundary ?p (frag_of ?f))))›*) scf (*‹simplicial_chain (Suc p) (standard_simplex s) (frag_of f)›*) simplicial_chain_simplicial_subdivision (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain ?p ?S (simplicial_subdivision ?p ?c)›*))
have ff: "simplicial_chain (Suc p) (standard_simplex s) (subd p (chain_boundary (Suc p) (frag_of f)))"
by (metis (no_types) Suc.IH (*‹simplicial_chain p (standard_simplex s) ?c ⟹ (∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc p) g (subd p ?c) = subd p (chain_map p g ?c)) ∧ simplicial_chain (Suc p) (standard_simplex s) (subd p ?c) ∧ chain_boundary (Suc p) (subd p ?c) + subd (p - Suc 0) (chain_boundary p ?c) = simplicial_subdivision p ?c - ?c›*) diff_Suc_1 (*‹Suc ?n - 1 = ?n›*) scf (*‹simplicial_chain (Suc p) (standard_simplex s) (frag_of f)›*) simplicial_chain_boundary (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain (?p - 1) ?S (chain_boundary ?p ?c)›*))
show "simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) (frag_of f))"
using one (*‹f ∈ Collect (simplicial_simplex (Suc p) (standard_simplex s))›*) unfolding subd.simps frag_extend_of
(*goal: ‹simplicial_chain (Suc (Suc p)) (standard_simplex s) (simplicial_cone (Suc p) (λi. (∑j≤Suc p. simplicial_vertex j f i) / real (Suc p + 1)) (simplicial_subdivision (Suc p) (frag_of f) - frag_of f - subd p (chain_boundary (Suc p) (frag_of f))))›*)
apply (rule_tac S="standard_simplex s" in simplicial_chain_simplicial_cone (*‹⟦simplicial_chain ?p ?S ?c; ⋀x u. ⟦0 ≤ u; u ≤ 1; x ∈ ?S⟧ ⟹ (λi. (1 - u) * ?v i + u * x i) ∈ ?T⟧ ⟹ simplicial_chain (Suc ?p) ?T (simplicial_cone ?p ?v ?c)›*))
(*goal: ‹simplicial_chain (Suc (Suc p)) (standard_simplex s) (simplicial_cone (Suc p) (λi. (∑j≤Suc p. simplicial_vertex j f i) / real (Suc p + 1)) (simplicial_subdivision (Suc p) (frag_of f) - frag_of f - subd p (chain_boundary (Suc p) (frag_of f))))›*)
apply (meson ff (*‹simplicial_chain (Suc p) (standard_simplex s) (subd p (chain_boundary (Suc p) (frag_of f)))›*) scf (*‹simplicial_chain (Suc p) (standard_simplex s) (frag_of f)›*) simplicial_chain_diff (*‹⟦simplicial_chain ?p ?S ?c1.0; simplicial_chain ?p ?S ?c2.0⟧ ⟹ simplicial_chain ?p ?S (?c1.0 - ?c2.0)›*) simplicial_chain_simplicial_subdivision (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain ?p ?S (simplicial_subdivision ?p ?c)›*))
(*top goal: ‹f ∈ Collect (simplicial_simplex (Suc p) (standard_simplex s)) ⟹ simplicial_chain (Suc p) (standard_simplex s) (simplicial_subdivision (Suc p) (frag_of f) - frag_of f - subd p (chain_boundary (Suc p) (frag_of f)))› and 1 goal remains*)
using "**" (*‹(λi. (∑j≤Suc p. simplicial_vertex j f i) / (2 + real p)) ∈ standard_simplex s›*) convex_standard_simplex (*‹⟦?x ∈ standard_simplex ?p; ?y ∈ standard_simplex ?p; 0 ≤ ?u; ?u ≤ 1⟧ ⟹ (λi. (1 - ?u) * ?x i + ?u * ?y i) ∈ standard_simplex ?p›*) by force
have "simplicial_chain p (standard_simplex s) (chain_boundary (Suc p) (frag_of f))"
using scf (*‹simplicial_chain (Suc p) (standard_simplex s) (frag_of f)›*) simplicial_chain_boundary (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain (?p - 1) ?S (chain_boundary ?p ?c)›*) by fastforce
then have "chain_boundary (Suc p) (simplicial_subdivision (Suc p) (frag_of f) - frag_of f
- subd p (chain_boundary (Suc p) (frag_of f))) = 0"
unfolding chain_boundary_diff
(*goal: ‹chain_boundary (Suc p) (simplicial_subdivision (Suc p) (frag_of f)) - chain_boundary (Suc p) (frag_of f) - chain_boundary (Suc p) (subd p (chain_boundary (Suc p) (frag_of f))) = 0›*)
using Suc.IH (*‹simplicial_chain p (standard_simplex s) ?c ⟹ (∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc p) g (subd p ?c) = subd p (chain_map p g ?c)) ∧ simplicial_chain (Suc p) (standard_simplex s) (subd p ?c) ∧ chain_boundary (Suc p) (subd p ?c) + subd (p - Suc 0) (chain_boundary p ?c) = simplicial_subdivision p ?c - ?c›*) chain_boundary_boundary (*‹singular_chain (?p::nat) (?X::?'a topology) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ⟹ chain_boundary (?p - Suc (0::nat)) (chain_boundary ?p ?c) = (0::((nat ⇒ real) ⇒ ?'a) ⇒₀ int)›*) by (metis One_nat_def (*‹1 = Suc 0›*) add_diff_cancel_left' (*‹?a + ?b - ?a = ?b›*) chain_boundary_simplicial_subdivision (*‹simplicial_chain ?p ?S ?c ⟹ chain_boundary ?p (simplicial_subdivision ?p ?c) = simplicial_subdivision (?p - 1) (chain_boundary ?p ?c)›*) diff_Suc_1 (*‹Suc ?n - 1 = ?n›*) scf (*‹simplicial_chain (Suc p) (standard_simplex s) (frag_of f)›*) simplicial_imp_singular_chain (*‹simplicial_chain ?p ?S ?c ⟹ singular_chain ?p (subtopology (powertop_real UNIV) ?S) ?c›*) subd_0 (*‹subd ?p 0 = 0›*))
moreover have "simplicial_chain (Suc p) (standard_simplex s)
(simplicial_subdivision (Suc p) (frag_of f) - frag_of f -
subd p (chain_boundary (Suc p) (frag_of f)))"
by (meson ff (*‹simplicial_chain (Suc (p::nat)) (standard_simplex (s::nat)) (subd p (chain_boundary (Suc p) (frag_of (f::(nat ⇒ real) ⇒ nat ⇒ real))))›*) scf (*‹simplicial_chain (Suc (p::nat)) (standard_simplex (s::nat)) (frag_of (f::(nat ⇒ real) ⇒ nat ⇒ real))›*) simplicial_chain_diff (*‹⟦simplicial_chain (?p::nat) (?S::(?'a ⇒ real) set) (?c1.0::((nat ⇒ real) ⇒ ?'a ⇒ real) ⇒₀ ?'b); simplicial_chain ?p ?S (?c2.0::((nat ⇒ real) ⇒ ?'a ⇒ real) ⇒₀ ?'b)⟧ ⟹ simplicial_chain ?p ?S (?c1.0 - ?c2.0)›*) simplicial_chain_simplicial_subdivision (*‹simplicial_chain (?p::nat) (?S::(nat ⇒ real) set) (?c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) ⟹ simplicial_chain ?p ?S (simplicial_subdivision ?p ?c)›*))
ultimately show "chain_boundary (Suc (Suc p)) (subd (Suc p) (frag_of f))
+ subd (Suc p - Suc 0) (chain_boundary (Suc p) (frag_of f))
= simplicial_subdivision (Suc p) (frag_of f) - frag_of f"
unfolding subd.simps frag_extend_of
(*goal: ‹chain_boundary (Suc (Suc (p::nat))) (simplicial_cone (Suc p) (λi::nat. (∑j::nat≤Suc p. simplicial_vertex j (f::(nat ⇒ real) ⇒ nat ⇒ real) i) / real (Suc p + (1::nat))) (simplicial_subdivision (Suc p) (frag_of f) - frag_of f - subd p (chain_boundary (Suc p) (frag_of f)))) + subd (Suc p - Suc (0::nat)) (chain_boundary (Suc p) (frag_of f)) = simplicial_subdivision (Suc p) (frag_of f) - frag_of f›*)
apply (simp add: chain_boundary_simplicial_cone (*‹simplicial_chain ?p ?S ?c ⟹ chain_boundary (Suc ?p) (simplicial_cone ?p ?v ?c) = ?c - (if ?p = 0 then frag_extend (λf. frag_of (λu∈standard_simplex ?p. ?v)) ?c else simplicial_cone (?p - 1) ?v (chain_boundary ?p ?c))›*))
(*goal: ‹chain_boundary (Suc (Suc (p::nat))) (simplicial_cone (Suc p) (λi::nat. (∑j::nat≤Suc p. simplicial_vertex j (f::(nat ⇒ real) ⇒ nat ⇒ real) i) / real (Suc p + (1::nat))) (simplicial_subdivision (Suc p) (frag_of f) - frag_of f - subd p (chain_boundary (Suc p) (frag_of f)))) + subd (Suc p - Suc (0::nat)) (chain_boundary (Suc p) (frag_of f)) = simplicial_subdivision (Suc p) (frag_of f) - frag_of f›*)
by (simp add: simplicial_cone_def (*‹simplicial_cone ?p ?v ≡ frag_extend (frag_of ∘ simplex_cone ?p ?v)›*) del: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*) simplicial_subdivision.simps (*‹simplicial_subdivision 0 = id› ‹simplicial_subdivision (Suc ?p) = frag_extend (λf. simplicial_cone ?p (λi. (∑j≤Suc ?p. simplicial_vertex j f i) / (real ?p + 2)) (simplicial_subdivision ?p (chain_boundary (Suc ?p) (frag_of f))))›*))
qed
next
(*goals:
1. ‹(∀(r::nat) g::(nat ⇒ real) ⇒ nat ⇒ real. simplicial_simplex (s::nat) (standard_simplex r) g ⟶ chain_map (Suc (Suc (p::nat))) g (subd (Suc p) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) = subd (Suc p) (chain_map (Suc p) g (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int))) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) + subd (Suc p - Suc (0::nat)) (chain_boundary (Suc p) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) = simplicial_subdivision (Suc p) (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) - (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)›
2. ‹⋀(a::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) b::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int. ⟦(∀(r::nat) g::(nat ⇒ real) ⇒ nat ⇒ real. simplicial_simplex (s::nat) (standard_simplex r) g ⟶ chain_map (Suc (Suc (p::nat))) g (subd (Suc p) a) = subd (Suc p) (chain_map (Suc p) g a)) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) a) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) a) + subd (Suc p - Suc (0::nat)) (chain_boundary (Suc p) a) = simplicial_subdivision (Suc p) a - a; (∀(r::nat) g::(nat ⇒ real) ⇒ nat ⇒ real. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) b) = subd (Suc p) (chain_map (Suc p) g b)) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) b) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) b) + subd (Suc p - Suc (0::nat)) (chain_boundary (Suc p) b) = simplicial_subdivision (Suc p) b - b⟧ ⟹ (∀(r::nat) g::(nat ⇒ real) ⇒ nat ⇒ real. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) (a - b)) = subd (Suc p) (chain_map (Suc p) g (a - b))) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) (a - b)) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) (a - b)) + subd (Suc p - Suc (0::nat)) (chain_boundary (Suc p) (a - b)) = simplicial_subdivision (Suc p) (a - b) - (a - b)›*)
case (diff a b) (*‹(∀(r::nat) g::(nat ⇒ real) ⇒ nat ⇒ real. simplicial_simplex (s::nat) (standard_simplex r) g ⟶ chain_map (Suc (Suc (p::nat))) g (subd (Suc p) (a::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) = subd (Suc p) (chain_map (Suc p) g a)) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) a) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) a) + subd (Suc p - Suc (0::nat)) (chain_boundary (Suc p) a) = simplicial_subdivision (Suc p) a - a› ‹(∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) b) = subd (Suc p) (chain_map (Suc p) g b)) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) b) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) b) + subd (Suc p - Suc 0) (chain_boundary (Suc p) b) = simplicial_subdivision (Suc p) b - b›*)
then show "?case"
(*goal: ‹(∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) (a - b)) = subd (Suc p) (chain_map (Suc p) g (a - b))) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) (a - b)) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) (a - b)) + subd (Suc p - Suc 0) (chain_boundary (Suc p) (a - b)) = simplicial_subdivision (Suc p) (a - b) - (a - b)›*)
apply safe
(*goals:
1. ‹⋀r g. ⟦∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) a) = subd (Suc p) (chain_map (Suc p) g a); ∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) b) = subd (Suc p) (chain_map (Suc p) g b); simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) a); chain_boundary (Suc (Suc p)) (subd (Suc p) a) + subd (Suc p - Suc 0) (chain_boundary (Suc p) a) = simplicial_subdivision (Suc p) a - a; simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) b); chain_boundary (Suc (Suc p)) (subd (Suc p) b) + subd (Suc p - Suc 0) (chain_boundary (Suc p) b) = simplicial_subdivision (Suc p) b - b; simplicial_simplex s (standard_simplex r) g⟧ ⟹ chain_map (Suc (Suc p)) g (subd (Suc p) (a - b)) = subd (Suc p) (chain_map (Suc p) g (a - b))›
2. ‹⟦∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) a) = subd (Suc p) (chain_map (Suc p) g a); ∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) b) = subd (Suc p) (chain_map (Suc p) g b); simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) a); chain_boundary (Suc (Suc p)) (subd (Suc p) a) + subd (Suc p - Suc 0) (chain_boundary (Suc p) a) = simplicial_subdivision (Suc p) a - a; simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) b); chain_boundary (Suc (Suc p)) (subd (Suc p) b) + subd (Suc p - Suc 0) (chain_boundary (Suc p) b) = simplicial_subdivision (Suc p) b - b⟧ ⟹ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) (a - b))›
3. ‹⟦∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) a) = subd (Suc p) (chain_map (Suc p) g a); ∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) b) = subd (Suc p) (chain_map (Suc p) g b); simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) a); chain_boundary (Suc (Suc p)) (subd (Suc p) a) + subd (Suc p - Suc 0) (chain_boundary (Suc p) a) = simplicial_subdivision (Suc p) a - a; simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) b); chain_boundary (Suc (Suc p)) (subd (Suc p) b) + subd (Suc p - Suc 0) (chain_boundary (Suc p) b) = simplicial_subdivision (Suc p) b - b⟧ ⟹ chain_boundary (Suc (Suc p)) (subd (Suc p) (a - b)) + subd (Suc p - Suc 0) (chain_boundary (Suc p) (a - b)) = simplicial_subdivision (Suc p) (a - b) - (a - b)›
discuss goal 1*)
apply (metis chain_map_diff (*‹chain_map ?p ?g (?a - ?b) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*) subd_diff (*‹subd ?p (?c1.0 - ?c2.0) = subd ?p ?c1.0 - subd ?p ?c2.0›*))
(*discuss goal 2*)
apply (metis simplicial_chain_diff (*‹⟦simplicial_chain ?p ?S ?c1.0; simplicial_chain ?p ?S ?c2.0⟧ ⟹ simplicial_chain ?p ?S (?c1.0 - ?c2.0)›*) subd_diff (*‹subd ?p (?c1.0 - ?c2.0) = subd ?p ?c1.0 - subd ?p ?c2.0›*))
(*discuss goal 3*)
apply (smt (verit, ccfv_threshold) add_diff_add (*‹?a + ?c - (?b + ?d) = ?a - ?b + (?c - ?d)›*) chain_boundary_diff (*‹chain_boundary ?p (?a - ?b) = chain_boundary ?p ?a - chain_boundary ?p ?b›*) diff_add_cancel (*‹?a - ?b + ?b = ?a›*) simplicial_subdivision_diff (*‹simplicial_subdivision ?p (?c1.0 - ?c2.0) = simplicial_subdivision ?p ?c1.0 - simplicial_subdivision ?p ?c2.0›*) subd_diff (*‹subd ?p (?c1.0 - ?c2.0) = subd ?p ?c1.0 - subd ?p ?c2.0›*))
(*proven 3 subgoals*) .
qed (auto)
(*solved the remaining goal: ‹(∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc (Suc p)) g (subd (Suc p) 0) = subd (Suc p) (chain_map (Suc p) g 0)) ∧ simplicial_chain (Suc (Suc p)) (standard_simplex s) (subd (Suc p) 0) ∧ chain_boundary (Suc (Suc p)) (subd (Suc p) 0) + subd (Suc p - Suc 0) (chain_boundary (Suc p) 0) = simplicial_subdivision (Suc p) 0 - 0›*)
qed (simp)
(*solved the remaining goal: ‹⋀c. simplicial_chain 0 (standard_simplex s) c ⟹ (∀r g. simplicial_simplex s (standard_simplex r) g ⟶ chain_map (Suc 0) g (subd 0 c) = subd 0 (chain_map 0 g c)) ∧ simplicial_chain (Suc 0) (standard_simplex s) (subd 0 c) ∧ chain_boundary (Suc 0) (subd 0 c) + subd (0 - Suc 0) (chain_boundary 0 c) = simplicial_subdivision 0 c - c›*)
lemma chain_homotopic_simplicial_subdivision1:
"⟦simplicial_chain p (standard_simplex q) c; simplicial_simplex q (standard_simplex r) g⟧
⟹ chain_map (Suc p) g (subd p c) = subd p (chain_map p g c)"
by (simp add: subd (*‹simplicial_chain (?p::nat) (standard_simplex (?s::nat)) (?c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) ⟹ (∀(r::nat) g::(nat ⇒ real) ⇒ nat ⇒ real. simplicial_simplex ?s (standard_simplex r) g ⟶ chain_map (Suc ?p) g (subd ?p ?c) = subd ?p (chain_map ?p g ?c)) ∧ simplicial_chain (Suc ?p) (standard_simplex ?s) (subd ?p ?c) ∧ chain_boundary (Suc ?p) (subd ?p ?c) + subd (?p - Suc (0::nat)) (chain_boundary ?p ?c) = simplicial_subdivision ?p ?c - ?c›*))
lemma chain_homotopic_simplicial_subdivision2:
"simplicial_chain p (standard_simplex q) c
⟹ simplicial_chain (Suc p) (standard_simplex q) (subd p c)"
by (simp add: subd (*‹simplicial_chain ?p (standard_simplex ?s) ?c ⟹ (∀r g. simplicial_simplex ?s (standard_simplex r) g ⟶ chain_map (Suc ?p) g (subd ?p ?c) = subd ?p (chain_map ?p g ?c)) ∧ simplicial_chain (Suc ?p) (standard_simplex ?s) (subd ?p ?c) ∧ chain_boundary (Suc ?p) (subd ?p ?c) + subd (?p - Suc 0) (chain_boundary ?p ?c) = simplicial_subdivision ?p ?c - ?c›*))
lemma chain_homotopic_simplicial_subdivision3:
"simplicial_chain p (standard_simplex q) c
⟹ chain_boundary (Suc p) (subd p c) = (simplicial_subdivision p c) - c - subd (p - Suc 0) (chain_boundary p c)"
by (simp add: subd (*‹simplicial_chain ?p (standard_simplex ?s) ?c ⟹ (∀r g. simplicial_simplex ?s (standard_simplex r) g ⟶ chain_map (Suc ?p) g (subd ?p ?c) = subd ?p (chain_map ?p g ?c)) ∧ simplicial_chain (Suc ?p) (standard_simplex ?s) (subd ?p ?c) ∧ chain_boundary (Suc ?p) (subd ?p ?c) + subd (?p - Suc 0) (chain_boundary ?p ?c) = simplicial_subdivision ?p ?c - ?c›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 33 facts*))
lemma chain_homotopic_simplicial_subdivision:
"∃h. (∀p. h p 0 = 0) ∧
(∀p c1 c2. h p (c1-c2) = h p c1 - h p c2) ∧
(∀p q r g c.
simplicial_chain p (standard_simplex q) c
⟶ simplicial_simplex q (standard_simplex r) g
⟶ chain_map (Suc p) g (h p c) = h p (chain_map p g c)) ∧
(∀p q c. simplicial_chain p (standard_simplex q) c
⟶ simplicial_chain (Suc p) (standard_simplex q) (h p c)) ∧
(∀p q c. simplicial_chain p (standard_simplex q) c
⟶ chain_boundary (Suc p) (h p c) + h (p - Suc 0) (chain_boundary p c)
= (simplicial_subdivision p c) - c)"
apply (rule_tac x=subd in exI (*‹?P ?x ⟹ ∃x. ?P x›*))
(*goal: ‹∃h::nat ⇒ (((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int. (∀p::nat. h p (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) = (0::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)) ∧ (∀(p::nat) (c1::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) c2::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int. h p (c1 - c2) = h p c1 - h p c2) ∧ (∀(p::nat) (q::nat) (r::nat) (g::(nat ⇒ real) ⇒ nat ⇒ real) c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int. simplicial_chain p (standard_simplex q) c ⟶ simplicial_simplex q (standard_simplex r) g ⟶ chain_map (Suc p) g (h p c) = h p (chain_map p g c)) ∧ (∀(p::nat) (q::nat) c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int. simplicial_chain p (standard_simplex q) c ⟶ simplicial_chain (Suc p) (standard_simplex q) (h p c)) ∧ (∀(p::nat) (q::nat) c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int. simplicial_chain p (standard_simplex q) c ⟶ chain_boundary (Suc p) (h p c) + h (p - Suc (0::nat)) (chain_boundary p c) = simplicial_subdivision p c - c)›*)
by (fastforce simp: subd (*‹simplicial_chain ?p (standard_simplex ?s) ?c ⟹ (∀r g. simplicial_simplex ?s (standard_simplex r) g ⟶ chain_map (Suc ?p) g (subd ?p ?c) = subd ?p (chain_map ?p g ?c)) ∧ simplicial_chain (Suc ?p) (standard_simplex ?s) (subd ?p ?c) ∧ chain_boundary (Suc ?p) (subd ?p ?c) + subd (?p - Suc 0) (chain_boundary ?p ?c) = simplicial_subdivision ?p ?c - ?c›*))
lemma chain_homotopic_singular_subdivision:
obtains h where
"⋀p. h p 0 = 0"
"⋀p c1 c2. h p (c1-c2) = h p c1 - h p c2"
"⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X (h p c)"
"⋀p X c. singular_chain p X c
⟹ chain_boundary (Suc p) (h p c) + h (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c"
proof (-)
(*goal: ‹(⋀h. ⟦⋀p. h p 0 = 0; ⋀p c1 c2. h p (c1 - c2) = h p c1 - h p c2; ⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X (h p c); ⋀p X c. singular_chain p X c ⟹ chain_boundary (Suc p) (h p c) + h (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c⟧ ⟹ thesis) ⟹ thesis›*)
define k where "k ≡ λp. frag_extend (λf:: (nat ⇒ real) ⇒ 'a. chain_map (Suc p) f (subd p (frag_of(restrict id (standard_simplex p)))))"
show "?thesis"
(*goal: ‹thesis›*)
proof (standard)
(*goals:
1. ‹⋀p. ?h p 0 = 0›
2. ‹⋀p c1 c2. ?h p (c1 - c2) = ?h p c1 - ?h p c2›
3. ‹⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X (?h p c)›
4. ‹⋀p X c. singular_chain p X c ⟹ chain_boundary (Suc p) (?h p c) + ?h (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c›*)
fix p and X and c :: "'a chain"
assume c: "singular_chain p X c" (*‹singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*)
have "singular_chain (Suc p) X (k p c) ∧
chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c"
using c[unfolded singular_chain_def] (*‹Poly_Mapping.keys c ⊆ singular_simplex_set p X›*) proof (induction rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹singular_chain (Suc p) X (k p 0) ∧ chain_boundary (Suc p) (k p 0) + k (p - Suc 0) (chain_boundary p 0) = singular_subdivision p 0 - 0›
2. ‹⋀x. x ∈ singular_simplex_set p X ⟹ singular_chain (Suc p) X (k p (frag_of x)) ∧ chain_boundary (Suc p) (k p (frag_of x)) + k (p - Suc 0) (chain_boundary p (frag_of x)) = singular_subdivision p (frag_of x) - frag_of x›
3. ‹⋀a b. ⟦singular_chain (Suc p) X (k p a) ∧ chain_boundary (Suc p) (k p a) + k (p - Suc 0) (chain_boundary p a) = singular_subdivision p a - a; singular_chain (Suc p) X (k p b) ∧ chain_boundary (Suc p) (k p b) + k (p - Suc 0) (chain_boundary p b) = singular_subdivision p b - b⟧ ⟹ singular_chain (Suc p) X (k p (a - b)) ∧ chain_boundary (Suc p) (k p (a - b)) + k (p - Suc 0) (chain_boundary p (a - b)) = singular_subdivision p (a - b) - (a - b)›*)
case (one f) (*‹f ∈ singular_simplex_set p X›*)
let ?X = "subtopology (powertop_real UNIV) (standard_simplex p)"
show "?case"
(*goal: ‹singular_chain (Suc (p::nat)) (X::'a::type topology) ((k::nat ⇒ (((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) p (frag_of (f::(nat ⇒ real) ⇒ 'a::type))) ∧ chain_boundary (Suc p) (k p (frag_of f)) + k (p - Suc (0::nat)) (chain_boundary p (frag_of f)) = singular_subdivision p (frag_of f) - frag_of f›*)
proof (simp add: k_def (*‹k::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int ≡ λp::nat. frag_extend (λf::(nat ⇒ real) ⇒ 'a. chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p)))))›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹singular_chain (Suc p) X (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p)))))›
2. ‹chain_boundary (Suc p) (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) + frag_extend (λf. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f)) = singular_subdivision p (frag_of f) - frag_of f›*)
show "singular_chain (Suc p) X (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p)))))"
proof (rule singular_chain_chain_map (*‹⟦singular_chain ?p ?X ?c; continuous_map ?X ?X' ?g⟧ ⟹ singular_chain ?p ?X' (chain_map ?p ?g ?c)›*))
(*goals:
1. ‹singular_chain (Suc p) ?X (subd p (frag_of (restrict id (standard_simplex p))))›
2. ‹continuous_map ?X X f›*)
show "singular_chain (Suc p) ?X (subd p (frag_of (restrict id (standard_simplex p))))"
by (simp add: chain_homotopic_simplicial_subdivision2 (*‹simplicial_chain ?p (standard_simplex ?q) ?c ⟹ simplicial_chain (Suc ?p) (standard_simplex ?q) (subd ?p ?c)›*) simplicial_imp_singular_chain (*‹simplicial_chain ?p ?S ?c ⟹ singular_chain ?p (subtopology (powertop_real UNIV) ?S) ?c›*))
show "continuous_map ?X X f"
using one.hyps (*‹f ∈ singular_simplex_set p X›*) singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*) by auto
qed
next
(*goal: ‹chain_boundary (Suc (p::nat)) (chain_map (Suc p) (f::(nat ⇒ real) ⇒ 'a) (subd p (frag_of (restrict id (standard_simplex p))))) + frag_extend (λf::(nat ⇒ real) ⇒ 'a. chain_map (Suc (p - Suc (0::nat))) f (subd (p - Suc (0::nat)) (frag_of (restrict id (standard_simplex (p - Suc (0::nat))))))) (chain_boundary p (frag_of f)) = singular_subdivision p (frag_of f) - frag_of f›*)
have scp: "singular_chain (Suc p) ?X (subd p (frag_of (restrict id (standard_simplex p))))"
by (simp add: chain_homotopic_simplicial_subdivision2 (*‹simplicial_chain ?p (standard_simplex ?q) ?c ⟹ simplicial_chain (Suc ?p) (standard_simplex ?q) (subd ?p ?c)›*) simplicial_imp_singular_chain (*‹simplicial_chain ?p ?S ?c ⟹ singular_chain ?p (subtopology (powertop_real UNIV) ?S) ?c›*))
have feqf: "frag_of (simplex_map p f (restrict id (standard_simplex p))) = frag_of f"
using one.hyps (*‹f ∈ singular_simplex_set p X›*) singular_simplex_chain_map_id (*‹singular_simplex (?p::nat) (?X::?'a topology) (?f::(nat ⇒ real) ⇒ ?'a) ⟹ chain_map ?p ?f (frag_of (restrict id (standard_simplex ?p))) = frag_of ?f›*) by auto
have "*": "chain_map p f
(subd (p - Suc 0)
(∑k≤p. frag_cmul ((-1) ^ k) (frag_of (singular_face p k id))))
= (∑x≤p. frag_cmul ((-1) ^ x)
(chain_map p (singular_face p x f)
(subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))" (is "?lhs = ?rhs") if "p > 0"
proof (-)
(*goal: ‹chain_map p f (subd (p - Suc 0) (∑k≤p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (∑x≤p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))›*)
have eqc: "subd (p - Suc 0) (frag_of (singular_face p i id))
= chain_map p (singular_face p i id)
(subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))" if "i ≤ p" for i
proof (-)
(*goal: ‹subd ((p::nat) - Suc (0::nat)) (frag_of (singular_face p (i::nat) id)) = chain_map p (singular_face p i id) (subd (p - Suc (0::nat)) (frag_of (restrict id (standard_simplex (p - Suc (0::nat))))))›*)
have 1: "simplicial_chain (p - Suc 0) (standard_simplex (p - Suc 0))
(frag_of (restrict id (standard_simplex (p - Suc 0))))"
by simp
have 2: "simplicial_simplex (p - Suc 0) (standard_simplex p) (singular_face p i id)"
by (metis One_nat_def (*‹1 = Suc 0›*) Suc_leI (*‹?m < ?n ⟹ Suc ?m ≤ ?n›*) ‹0 < p› simplicial_simplex_id (*‹simplicial_simplex ?p ?S (restrict id (standard_simplex ?p)) = (standard_simplex ?p ⊆ ?S)›*) simplicial_simplex_singular_face (*‹⟦simplicial_simplex ?p ?S ?f; 1 ≤ ?p; ?k ≤ ?p⟧ ⟹ simplicial_simplex (?p - Suc 0) ?S (singular_face ?p ?k ?f)›*) singular_face_restrict (*‹⟦0 < ?p; ?i ≤ ?p⟧ ⟹ singular_face ?p ?i (restrict ?f (standard_simplex ?p)) = singular_face ?p ?i ?f›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) that (*‹i ≤ p›*))
have 3: "simplex_map (p - Suc 0) (singular_face p i id) (restrict id (standard_simplex (p - Suc 0)))
= singular_face p i id"
by (force simp: simplex_map_def (*‹simplex_map ?p ?g ?c ≡ restrict (?g ∘ ?c) (standard_simplex ?p)›*) singular_face_def (*‹singular_face ?p ?k ?f ≡ restrict (?f ∘ simplical_face ?k) (standard_simplex (?p - Suc 0))›*))
show "?thesis"
(*goal: ‹subd (p - Suc 0) (frag_of (singular_face p i id)) = chain_map p (singular_face p i id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))›*)
using chain_homotopic_simplicial_subdivision1[OF 1 2] (*‹chain_map (Suc (p - Suc 0)) (singular_face p i id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0))))) = subd (p - Suc 0) (chain_map (p - Suc 0) (singular_face p i id) (frag_of (restrict id (standard_simplex (p - Suc 0)))))›*) that (*‹(i::nat) ≤ (p::nat)›*) ‹p > 0› (*‹0 < p›*) by (simp add: 3 (*‹simplex_map (p - Suc 0) (singular_face p i id) (restrict id (standard_simplex (p - Suc 0))) = singular_face p i id›*))
qed
have xx: "simplicial_chain p (standard_simplex(p - Suc 0))
(subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))"
by (metis Suc_pred (*‹(0::nat) < (?n::nat) ⟹ Suc (?n - Suc (0::nat)) = ?n›*) chain_homotopic_simplicial_subdivision2 (*‹simplicial_chain (?p::nat) (standard_simplex (?q::nat)) (?c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) ⟹ simplicial_chain (Suc ?p) (standard_simplex ?q) (subd ?p ?c)›*) order_refl (*‹(?x::?'a) ≤ ?x›*) simplicial_chain_of (*‹simplicial_chain (?p::nat) (?S::(?'a ⇒ real) set) (frag_of (?c::(nat ⇒ real) ⇒ ?'a ⇒ real)) = simplicial_simplex ?p ?S ?c›*) simplicial_simplex_id (*‹simplicial_simplex (?p::nat) (?S::(nat ⇒ real) set) (restrict id (standard_simplex ?p)) = (standard_simplex ?p ⊆ ?S)›*) that (*‹(0::nat) < (p::nat)›*))
have yy: "⋀k. k ≤ p ⟹
chain_map p f
(chain_map p (singular_face p k id) h) = chain_map p (singular_face p k f) h" if "simplicial_chain p (standard_simplex(p - Suc 0)) h" for h
using that (*‹simplicial_chain (p::nat) (standard_simplex (p - Suc (0::nat))) (h::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int)›*) unfolding simplicial_chain_def
(*goal: ‹⋀k. k ≤ p ⟹ chain_map p f (chain_map p (singular_face p k id) h) = chain_map p (singular_face p k f) h›*)
proof (induction h rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹⋀k. k ≤ p ⟹ chain_map p f (chain_map p (singular_face p k id) 0) = chain_map p (singular_face p k f) 0›
2. ‹⋀x k. ⟦x ∈ Collect (simplicial_simplex p (standard_simplex (p - Suc 0))); k ≤ p⟧ ⟹ chain_map p f (chain_map p (singular_face p k id) (frag_of x)) = chain_map p (singular_face p k f) (frag_of x)›
3. ‹⋀a b k. ⟦⋀k. k ≤ p ⟹ chain_map p f (chain_map p (singular_face p k id) a) = chain_map p (singular_face p k f) a; ⋀k. k ≤ p ⟹ chain_map p f (chain_map p (singular_face p k id) b) = chain_map p (singular_face p k f) b; k ≤ p⟧ ⟹ chain_map p f (chain_map p (singular_face p k id) (a - b)) = chain_map p (singular_face p k f) (a - b)›*)
case (one x) (*‹x ∈ Collect (simplicial_simplex p (standard_simplex (p - Suc 0)))› ‹k ≤ p›*)
then show "?case"
(*goal: ‹chain_map p f (chain_map p (singular_face p k id) (frag_of x)) = chain_map p (singular_face p k f) (frag_of x)›*)
using one (*‹x ∈ Collect (simplicial_simplex p (standard_simplex (p - Suc 0)))› ‹k ≤ p›*) apply -
(*goal: ‹chain_map p f (chain_map p (singular_face p k id) (frag_of x)) = chain_map p (singular_face p k f) (frag_of x)›*)
apply (simp add: chain_map_of (*‹chain_map ?p ?g (frag_of ?f) = frag_of (simplex_map ?p ?g ?f)›*) singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*) simplicial_simplex_def (*‹simplicial_simplex ?p ?S ?f ≡ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f ∧ (∃l. ?f = oriented_simplex ?p l)›*))
(*goal: ‹⟦x ∈ Collect (simplicial_simplex p (standard_simplex (p - Suc 0))); k ≤ p; x ∈ Collect (simplicial_simplex p (standard_simplex (p - Suc 0))); k ≤ p⟧ ⟹ chain_map p f (chain_map p (singular_face p k id) (frag_of x)) = chain_map p (singular_face p k f) (frag_of x)›*)
apply auto
(*goal: ‹⟦continuous_map (subtopology (powertop_real UNIV) (standard_simplex p)) (subtopology (powertop_real UNIV) (standard_simplex (p - Suc 0))) x ∧ x ∈ extensional (standard_simplex p) ∧ (∃l. x = oriented_simplex p l); k ≤ p⟧ ⟹ frag_of (simplex_map p f (simplex_map p (singular_face p k (λa. a)) x)) = frag_of (simplex_map p (singular_face p k f) x)›*)
apply (rule arg_cong [where f=frag_of] (*‹?x = ?y ⟹ frag_of ?x = frag_of ?y›*))
(*goal: ‹⋀l. ⟦k ≤ p; continuous_map (subtopology (powertop_real UNIV) (standard_simplex p)) (subtopology (powertop_real UNIV) (standard_simplex (p - Suc 0))) (oriented_simplex p l); oriented_simplex p l ∈ extensional (standard_simplex p); x = oriented_simplex p l⟧ ⟹ frag_of (simplex_map p f (simplex_map p (singular_face p k (λa. a)) (oriented_simplex p l))) = frag_of (simplex_map p (singular_face p k f) (oriented_simplex p l))›*)
apply (auto simp: image_subset_iff (*‹((?f::?'b ⇒ ?'a) ` (?A::?'b set) ⊆ (?B::?'a set)) = (∀x::?'b∈?A. ?f x ∈ ?B)›*) simplex_map_def (*‹simplex_map (?p::nat) (?g::?'b ⇒ ?'a) (?c::(nat ⇒ real) ⇒ ?'b) ≡ restrict (?g ∘ ?c) (standard_simplex ?p)›*) simplicial_simplex (*‹simplicial_simplex (?p::nat) (?S::(?'a ⇒ real) set) (?f::(nat ⇒ real) ⇒ ?'a ⇒ real) = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l::nat ⇒ ?'a ⇒ real. ?f = oriented_simplex ?p l))›*) singular_face_def (*‹singular_face (?p::nat) (?k::nat) (?f::(nat ⇒ real) ⇒ ?'a) ≡ restrict (?f ∘ simplical_face ?k) (standard_simplex (?p - Suc (0::nat)))›*))
(*goal: ‹⋀l. ⟦k ≤ p; continuous_map (subtopology (powertop_real UNIV) (standard_simplex p)) (subtopology (powertop_real UNIV) (standard_simplex (p - Suc 0))) (oriented_simplex p l); oriented_simplex p l ∈ extensional (standard_simplex p); x = oriented_simplex p l⟧ ⟹ simplex_map p f (simplex_map p (singular_face p k (λa. a)) (oriented_simplex p l)) = simplex_map p (singular_face p k f) (oriented_simplex p l)›*)
by (msorry)
qed (auto simp: chain_map_diff (*‹chain_map ?p ?g (?a - ?b) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*))
(*solves the remaining goals:
1. ‹⋀k. k ≤ p ⟹ chain_map p f (chain_map p (singular_face p k id) 0) = chain_map p (singular_face p k f) 0›
2. ‹⋀a b k. ⟦⋀k. k ≤ p ⟹ chain_map p f (chain_map p (singular_face p k id) a) = chain_map p (singular_face p k f) a; ⋀k. k ≤ p ⟹ chain_map p f (chain_map p (singular_face p k id) b) = chain_map p (singular_face p k f) b; k ≤ p⟧ ⟹ chain_map p f (chain_map p (singular_face p k id) (a - b)) = chain_map p (singular_face p k f) (a - b)›*)
have "?lhs
= chain_map p f
(∑k≤p. frag_cmul ((-1) ^ k)
(chain_map p (singular_face p k id)
(subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))"
by (simp add: subd_power_sum (*‹subd ?p (sum ?f ?I) = sum (subd ?p ∘ ?f) ?I›*) subd_power_uminus (*‹subd ?p (frag_cmul ((- 1) ^ ?k) ?c) = frag_cmul ((- 1) ^ ?k) (subd ?p ?c)›*) eqc (*‹?i ≤ p ⟹ subd (p - Suc 0) (frag_of (singular_face p ?i id)) = chain_map p (singular_face p ?i id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))›*))
also (*calculation: ‹chain_map (p::nat) (f::(nat ⇒ real) ⇒ 'a) (subd (p - Suc (0::nat)) (∑k::nat≤p. frag_cmul ((- (1::int)) ^ k) (frag_of (singular_face p k id)))) = chain_map p f (∑k::nat≤p. frag_cmul ((- (1::int)) ^ k) (chain_map p (singular_face p k id) (subd (p - Suc (0::nat)) (frag_of (restrict id (standard_simplex (p - Suc (0::nat))))))))›*) have "… = ?rhs"
by (simp add: chain_map_sum (*‹finite ?I ⟹ chain_map ?p ?g (sum ?f ?I) = sum (chain_map ?p ?g ∘ ?f) ?I›*) xx (*‹simplicial_chain p (standard_simplex (p - Suc 0)) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))›*) yy (*‹⟦simplicial_chain p (standard_simplex (p - Suc 0)) ?h1; ?k ≤ p⟧ ⟹ chain_map p f (chain_map p (singular_face p ?k id) ?h1) = chain_map p (singular_face p ?k f) ?h1›*))
finally (*calculation: ‹chain_map p f (subd (p - Suc 0) (∑k≤p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (∑x≤p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))›*) show "?thesis"
(*goal: ‹chain_map p f (subd (p - Suc 0) (∑k≤p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (∑x≤p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))›*) .
qed
have "chain_map p f
(simplicial_subdivision p (frag_of (restrict id (standard_simplex p)))
- subd (p - Suc 0) (chain_boundary p (frag_of (restrict id (standard_simplex p)))))
= singular_subdivision p (frag_of f)
- frag_extend
(λf. chain_map (Suc (p - Suc 0)) f
(subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0))))))
(chain_boundary p (frag_of f))"
apply (simp add: singular_subdivision_def (*‹singular_subdivision (?p::nat) ≡ frag_extend (λf::(nat ⇒ real) ⇒ ?'a. chain_map ?p f (simplicial_subdivision ?p (frag_of (restrict id (standard_simplex ?p)))))›*) chain_map_diff (*‹chain_map (?p::nat) (?g::?'b ⇒ ?'a) ((?a::((nat ⇒ real) ⇒ ?'b) ⇒₀ int) - (?b::((nat ⇒ real) ⇒ ?'b) ⇒₀ int)) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*))
(*goal: ‹chain_map (p::nat) (f::(nat ⇒ real) ⇒ 'a::type) (simplicial_subdivision p (frag_of (restrict id (standard_simplex p))) - subd (p - Suc (0::nat)) (chain_boundary p (frag_of (restrict id (standard_simplex p))))) = singular_subdivision p (frag_of f) - frag_extend (λf::(nat ⇒ real) ⇒ 'a::type. chain_map (Suc (p - Suc (0::nat))) f (subd (p - Suc (0::nat)) (frag_of (restrict id (standard_simplex (p - Suc (0::nat))))))) (chain_boundary p (frag_of f))›*)
apply (clarsimp simp add: chain_boundary_def (*‹chain_boundary ?p ?c ≡ if ?p = 0 then 0 else frag_extend (λf. ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k f))) ?c›*))
(*goal: ‹chain_map (p::nat) (f::(nat ⇒ real) ⇒ 'a) (subd (p - Suc (0::nat)) (chain_boundary p (frag_of (restrict id (standard_simplex p))))) = frag_extend (λf::(nat ⇒ real) ⇒ 'a. chain_map (Suc (p - Suc (0::nat))) f (subd (p - Suc (0::nat)) (frag_of (restrict id (standard_simplex (p - Suc (0::nat))))))) (chain_boundary p (frag_of f))›*)
by (simp add: frag_extend_sum (*‹finite ?I ⟹ frag_extend ?f (sum ?g ?I) = sum (frag_extend ?f ∘ ?g) ?I›*) frag_extend_cmul (*‹frag_extend ?f (frag_cmul ?c ?x) = frag_cmul ?c (frag_extend ?f ?x)›*) * (*‹0 < p ⟹ chain_map p f (subd (p - Suc 0) (∑k≤p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (∑x≤p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))›*))
then show "chain_boundary (Suc p) (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p)))))
+ frag_extend
(λf. chain_map (Suc (p - Suc 0)) f
(subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0))))))
(chain_boundary p (frag_of f))
= singular_subdivision p (frag_of f) - frag_of f"
by (simp add: chain_boundary_chain_map [OF scp] (*‹chain_boundary (Suc p) (chain_map (Suc p) ?g (subd p (frag_of (restrict id (standard_simplex p))))) = chain_map (Suc p - Suc 0) ?g (chain_boundary (Suc p) (subd p (frag_of (restrict id (standard_simplex p)))))›*) chain_homotopic_simplicial_subdivision3 [where q=p] (*‹simplicial_chain ?p (standard_simplex p) ?c ⟹ chain_boundary (Suc ?p) (subd ?p ?c) = simplicial_subdivision ?p ?c - ?c - subd (?p - Suc 0) (chain_boundary ?p ?c)›*) chain_map_diff (*‹chain_map ?p ?g (?a - ?b) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*) feqf (*‹frag_of (simplex_map p f (restrict id (standard_simplex p))) = frag_of f›*))
qed
next
(*goals:
1. ‹singular_chain (Suc p) X (k p 0) ∧ chain_boundary (Suc p) (k p 0) + k (p - Suc 0) (chain_boundary p 0) = singular_subdivision p 0 - 0›
2. ‹⋀a b. ⟦singular_chain (Suc p) X (k p a) ∧ chain_boundary (Suc p) (k p a) + k (p - Suc 0) (chain_boundary p a) = singular_subdivision p a - a; singular_chain (Suc p) X (k p b) ∧ chain_boundary (Suc p) (k p b) + k (p - Suc 0) (chain_boundary p b) = singular_subdivision p b - b⟧ ⟹ singular_chain (Suc p) X (k p (a - b)) ∧ chain_boundary (Suc p) (k p (a - b)) + k (p - Suc 0) (chain_boundary p (a - b)) = singular_subdivision p (a - b) - (a - b)›*)
case (diff a b) (*‹singular_chain (Suc p) X (k p a) ∧ chain_boundary (Suc p) (k p a) + k (p - Suc 0) (chain_boundary p a) = singular_subdivision p a - a› ‹singular_chain (Suc (p::nat)) (X::'a topology) ((k::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int) p (b::((nat ⇒ real) ⇒ 'a) ⇒₀ int)) ∧ chain_boundary (Suc p) (k p b) + k (p - Suc (0::nat)) (chain_boundary p b) = singular_subdivision p b - b›*)
then show "?case"
(*goal: ‹singular_chain (Suc (p::nat)) (X::'a topology) ((k::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int) p ((a::((nat ⇒ real) ⇒ 'a) ⇒₀ int) - (b::((nat ⇒ real) ⇒ 'a) ⇒₀ int))) ∧ chain_boundary (Suc p) (k p (a - b)) + k (p - Suc (0::nat)) (chain_boundary p (a - b)) = singular_subdivision p (a - b) - (a - b)›*)
apply (simp only: k_def (*‹k ≡ λp. frag_extend (λf. chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p)))))›*) singular_chain_diff (*‹⟦singular_chain ?p ?X ?a; singular_chain ?p ?X ?b⟧ ⟹ singular_chain ?p ?X (?a - ?b)›*) chain_boundary_diff (*‹chain_boundary ?p (?a - ?b) = chain_boundary ?p ?a - chain_boundary ?p ?b›*) frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*) singular_subdivision_diff (*‹singular_subdivision ?p (?a - ?b) = singular_subdivision ?p ?a - singular_subdivision ?p ?b›*))
(*goal: ‹singular_chain (Suc (p::nat)) (X::'a topology) ((k::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int) p ((a::((nat ⇒ real) ⇒ 'a) ⇒₀ int) - (b::((nat ⇒ real) ⇒ 'a) ⇒₀ int))) ∧ chain_boundary (Suc p) (k p (a - b)) + k (p - Suc (0::nat)) (chain_boundary p (a - b)) = singular_subdivision p (a - b) - (a - b)›*)
by (metis (no_types, lifting) add_diff_add (*‹(?a::?'a) + (?c::?'a) - ((?b::?'a) + (?d::?'a)) = ?a - ?b + (?c - ?d)›*) diff_add_cancel (*‹(?a::?'a) - (?b::?'a) + ?b = ?a›*))
qed (auto simp: k_def (*‹k::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int ≡ λp::nat. frag_extend (λf::(nat ⇒ real) ⇒ 'a. chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p)))))›*))
(*solved the remaining goal: ‹singular_chain (Suc (p::nat)) (X::'a::type topology) ((k::nat ⇒ (((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) p (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)) ∧ chain_boundary (Suc p) (k p (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)) + k (p - Suc (0::nat)) (chain_boundary p (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)) = singular_subdivision p (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) - (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)›*)
then show "singular_chain (Suc p) X (k p c)" "chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c"
apply -
(*goals:
1. ‹singular_chain (Suc p) X (k p c) ∧ chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c ⟹ singular_chain (Suc p) X (k p c)›
2. ‹singular_chain (Suc p) X (k p c) ∧ chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c ⟹ chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
qed (auto simp: k_def (*‹k ≡ λp. frag_extend (λf. chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p)))))›*) frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*))
(*solves the remaining goals:
1. ‹⋀p. k p 0 = 0›
2. ‹⋀p c1 c2. k p (c1 - c2) = k p c1 - k p c2›*)
qed
lemma homologous_rel_singular_subdivision:
assumes "singular_relcycle p X T c"
shows "homologous_rel p X T (singular_subdivision p c) c"
proof (cases "p = 0")
(*goals:
1. ‹p = 0 ⟹ homologous_rel p X T (singular_subdivision p c) c›
2. ‹p ≠ 0 ⟹ homologous_rel p X T (singular_subdivision p c) c›*)
case True (*‹p = 0›*)
with assms (*‹singular_relcycle p X T c›*) show "?thesis"
(*goal: ‹homologous_rel p X T (singular_subdivision p c) c›*)
by (auto simp: singular_relcycle_def (*‹singular_relcycle ?p ?X ?S ≡ λc. singular_chain ?p ?X c ∧ (chain_boundary ?p c, 0) ∈ mod_subset (?p - 1) (subtopology ?X ?S)›*) singular_subdivision_zero (*‹singular_chain 0 ?X ?c ⟹ singular_subdivision 0 ?c = ?c›*))
next
(*goal: ‹(p::nat) ≠ (0::nat) ⟹ homologous_rel p (X::'a::type topology) (T::'a::type set) (singular_subdivision p (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)) c›*)
case False (*‹p ≠ 0›*)
with assms (*‹singular_relcycle p X T c›*) show "?thesis"
(*goal: ‹homologous_rel p X T (singular_subdivision p c) c›*)
unfolding homologous_rel_def singular_relboundary singular_relcycle
(*goal: ‹∃d e. singular_chain (Suc p) X d ∧ singular_chain p (subtopology X T) e ∧ chain_boundary (Suc p) d + e = singular_subdivision p c - c›*)
by (metis One_nat_def (*‹(1::nat) = Suc (0::nat)›*) Suc_diff_1 (*‹(0::nat) < (?n::nat) ⟹ Suc (?n - (1::nat)) = ?n›*) chain_homotopic_singular_subdivision (*‹(⋀h::nat ⇒ (((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ ?'a) ⇒₀ int. ⟦⋀p::nat. h p (0::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) = (0::((nat ⇒ real) ⇒ ?'a) ⇒₀ int); ⋀(p::nat) (c1::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) c2::((nat ⇒ real) ⇒ ?'a) ⇒₀ int. h p (c1 - c2) = h p c1 - h p c2; ⋀(p::nat) (X::?'a topology) c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int. singular_chain p X c ⟹ singular_chain (Suc p) X (h p c); ⋀(p::nat) (X::?'a topology) c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int. singular_chain p X c ⟹ chain_boundary (Suc p) (h p c) + h (p - Suc (0::nat)) (chain_boundary p c) = singular_subdivision p c - c⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) gr_zeroI (*‹((?n::?'a) = (0::?'a) ⟹ False) ⟹ (0::?'a) < ?n›*))
qed
subsection‹Excision argument that we keep doing singular subdivision›
lemma singular_subdivision_power_0 [simp]: "(singular_subdivision p ^^ n) 0 = 0"
apply (induction n)
(*goals:
1. ‹(singular_subdivision p ^^ 0) 0 = 0›
2. ‹⋀n. (singular_subdivision p ^^ n) 0 = 0 ⟹ (singular_subdivision p ^^ Suc n) 0 = 0›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma singular_subdivision_power_diff:
"(singular_subdivision p ^^ n) (a - b) = (singular_subdivision p ^^ n) a - (singular_subdivision p ^^ n) b"
apply (induction n)
(*goals:
1. ‹(singular_subdivision p ^^ 0) (a - b) = (singular_subdivision p ^^ 0) a - (singular_subdivision p ^^ 0) b›
2. ‹⋀n. (singular_subdivision p ^^ n) (a - b) = (singular_subdivision p ^^ n) a - (singular_subdivision p ^^ n) b ⟹ (singular_subdivision p ^^ Suc n) (a - b) = (singular_subdivision p ^^ Suc n) a - (singular_subdivision p ^^ Suc n) b›
discuss goal 1*)
apply ((auto simp: singular_subdivision_diff (*‹singular_subdivision ?p (?a - ?b) = singular_subdivision ?p ?a - singular_subdivision ?p ?b›*))[1])
(*discuss goal 2*)
apply ((auto simp: singular_subdivision_diff (*‹singular_subdivision ?p (?a - ?b) = singular_subdivision ?p ?a - singular_subdivision ?p ?b›*))[1])
(*proven 2 subgoals*) .
lemma iterated_singular_subdivision:
"singular_chain p X c
⟹ (singular_subdivision p ^^ n) c =
frag_extend
(λf. chain_map p f
((simplicial_subdivision p ^^ n)
(frag_of(restrict id (standard_simplex p))))) c"
proof (induction n arbitrary: c)
(*goals:
1. ‹⋀c. singular_chain p X c ⟹ (singular_subdivision p ^^ 0) c = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p))))) c›
2. ‹⋀n c. ⟦⋀c. singular_chain p X c ⟹ (singular_subdivision p ^^ n) c = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p))))) c; singular_chain p X c⟧ ⟹ (singular_subdivision p ^^ Suc n) c = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))) c›*)
case 0 (*‹singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*)
then show "?case"
(*goal: ‹(singular_subdivision (p::nat) ^^ (0::nat)) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) = frag_extend (λf::(nat ⇒ real) ⇒ 'a. chain_map p f ((simplicial_subdivision p ^^ (0::nat)) (frag_of (restrict id (standard_simplex p))))) c›*)
unfolding singular_chain_def
(*goal: ‹(singular_subdivision p ^^ 0) c = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p))))) c›*)
proof (induction c rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹(singular_subdivision p ^^ 0) 0 = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p))))) 0›
2. ‹⋀x. x ∈ singular_simplex_set p X ⟹ (singular_subdivision p ^^ 0) (frag_of x) = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p))))) (frag_of x)›
3. ‹⋀a b. ⟦(singular_subdivision p ^^ 0) a = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p))))) a; (singular_subdivision p ^^ 0) b = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p))))) b⟧ ⟹ (singular_subdivision p ^^ 0) (a - b) = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p))))) (a - b)›*)
case (one f) (*‹(f::(nat ⇒ real) ⇒ 'a::type) ∈ singular_simplex_set (p::nat) (X::'a::type topology)›*)
then have "restrict f (standard_simplex p) = f"
by (simp add: extensional_restrict (*‹?f ∈ extensional ?A ⟹ restrict ?f ?A = ?f›*) singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*))
then show "?case"
(*goal: ‹(singular_subdivision p ^^ 0) (frag_of f) = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p))))) (frag_of f)›*)
by (auto simp: simplex_map_def (*‹simplex_map (?p::nat) (?g::?'b ⇒ ?'a) (?c::(nat ⇒ real) ⇒ ?'b) ≡ restrict (?g ∘ ?c) (standard_simplex ?p)›*) cong: restrict_cong (*‹⟦(?I::?'a set) = (?J::?'a set); ⋀i::?'a. i ∈ ?J =simp=> (?f::?'a ⇒ ?'b) i = (?g::?'a ⇒ ?'b) i⟧ ⟹ restrict ?f ?I = restrict ?g ?J›*))
qed (auto simp: frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*))
(*solves the remaining goals:
1. ‹(singular_subdivision p ^^ 0) 0 = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p))))) 0›
2. ‹⋀a b. ⟦(singular_subdivision p ^^ 0) a = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p))))) a; (singular_subdivision p ^^ 0) b = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p))))) b⟧ ⟹ (singular_subdivision p ^^ 0) (a - b) = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p))))) (a - b)›*)
next
(*goal: ‹⋀n c. ⟦⋀c. singular_chain p X c ⟹ (singular_subdivision p ^^ n) c = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p))))) c; singular_chain p X c⟧ ⟹ (singular_subdivision p ^^ Suc n) c = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))) c›*)
case (Suc n) (*‹singular_chain p X ?c ⟹ (singular_subdivision p ^^ n) ?c = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p))))) ?c› ‹singular_chain p X c›*)
show "?case"
(*goal: ‹(singular_subdivision p ^^ Suc n) c = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))) c›*)
using Suc.prems (*‹singular_chain p X c›*) unfolding singular_chain_def
(*goal: ‹(singular_subdivision p ^^ Suc n) c = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))) c›*)
proof (induction c rule: frag_induction (*‹⟦Poly_Mapping.keys (?c::?'a ⇒₀ int) ⊆ (?S::?'a set); (?P::(?'a ⇒₀ int) ⇒ bool) (0::?'a ⇒₀ int); ⋀x::?'a. x ∈ ?S ⟹ ?P (frag_of x); ⋀(a::?'a ⇒₀ int) b::?'a ⇒₀ int. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹(singular_subdivision p ^^ Suc n) 0 = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))) 0›
2. ‹⋀x. x ∈ singular_simplex_set p X ⟹ (singular_subdivision p ^^ Suc n) (frag_of x) = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))) (frag_of x)›
3. ‹⋀a b. ⟦(singular_subdivision p ^^ Suc n) a = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))) a; (singular_subdivision p ^^ Suc n) b = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))) b⟧ ⟹ (singular_subdivision p ^^ Suc n) (a - b) = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))) (a - b)›*)
case (one f) (*‹f ∈ singular_simplex_set p X›*)
then have "singular_simplex p X f"
by simp
have scp: "simplicial_chain p (standard_simplex p)
((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p))))"
proof (induction n)
(*goals:
1. ‹simplicial_chain (p::nat) (standard_simplex p) ((simplicial_subdivision p ^^ (0::nat)) (frag_of (restrict id (standard_simplex p))))›
2. ‹⋀n::nat. simplicial_chain (p::nat) (standard_simplex p) ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p)))) ⟹ simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))›*)
case 0 (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p))))›*)
by (metis funpow_0 (*‹(?f ^^ 0) ?x = ?x›*) order_refl (*‹?x ≤ ?x›*) simplicial_chain_of (*‹simplicial_chain ?p ?S (frag_of ?c) = simplicial_simplex ?p ?S ?c›*) simplicial_simplex_id (*‹simplicial_simplex ?p ?S (restrict id (standard_simplex ?p)) = (standard_simplex ?p ⊆ ?S)›*))
next
(*goal: ‹⋀n. simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p)))) ⟹ simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))›*)
case (Suc n) (*‹simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p))))›*)
then show "?case"
(*goal: ‹simplicial_chain (p::nat) (standard_simplex p) ((simplicial_subdivision p ^^ Suc (n::nat)) (frag_of (restrict id (standard_simplex p))))›*)
by (simp add: simplicial_chain_simplicial_subdivision (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain ?p ?S (simplicial_subdivision ?p ?c)›*))
qed
have scnp: "simplicial_chain p (standard_simplex p)
((simplicial_subdivision p ^^ n) (frag_of (λx∈standard_simplex p. x)))"
proof (induction n)
(*goals:
1. ‹simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ 0) (frag_of (λx∈standard_simplex p. x)))›
2. ‹⋀n. simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ n) (frag_of (λx∈standard_simplex p. x))) ⟹ simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ Suc n) (frag_of (λx∈standard_simplex p. x)))›*)
case 0 (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹simplicial_chain (p::nat) (standard_simplex p) ((simplicial_subdivision p ^^ (0::nat)) (frag_of (λx::nat ⇒ real∈standard_simplex p. x)))›*)
by (metis eq_id_iff (*‹(∀x. ?f x = x) = (?f = id)›*) funpow_0 (*‹(?f ^^ 0) ?x = ?x›*) order_refl (*‹?x ≤ ?x›*) simplicial_chain_of (*‹simplicial_chain ?p ?S (frag_of ?c) = simplicial_simplex ?p ?S ?c›*) simplicial_simplex_id (*‹simplicial_simplex ?p ?S (restrict id (standard_simplex ?p)) = (standard_simplex ?p ⊆ ?S)›*))
next
(*goal: ‹⋀n. simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ n) (frag_of (λx∈standard_simplex p. x))) ⟹ simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ Suc n) (frag_of (λx∈standard_simplex p. x)))›*)
case (Suc n) (*‹simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ n) (frag_of (λx∈standard_simplex p. x)))›*)
then show "?case"
(*goal: ‹simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ Suc n) (frag_of (λx∈standard_simplex p. x)))›*)
by (simp add: simplicial_chain_simplicial_subdivision (*‹simplicial_chain ?p ?S ?c ⟹ simplicial_chain ?p ?S (simplicial_subdivision ?p ?c)›*))
qed
have sff: "singular_chain p X (frag_of f)"
by (simp add: ‹singular_simplex p X f› singular_chain_of (*‹singular_chain (?p::nat) (?X::?'a topology) (frag_of (?c::(nat ⇒ real) ⇒ ?'a)) = singular_simplex ?p ?X ?c›*))
then show "?case"
(*goal: ‹(singular_subdivision p ^^ Suc n) (frag_of f) = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))) (frag_of f)›*)
using Suc.IH[OF sff] (*‹(singular_subdivision p ^^ n) (frag_of f) = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p))))) (frag_of f)›*) naturality_singular_subdivision[OF simplicial_imp_singular_chain [ OF scp ], of f] (*‹singular_subdivision p (chain_map p f ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p))))) = chain_map p f (singular_subdivision p ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p)))))›*) singular_subdivision_simplicial_simplex[OF scnp] (*‹singular_subdivision p ((simplicial_subdivision p ^^ n) (frag_of (λx∈standard_simplex p. x))) = simplicial_subdivision p ((simplicial_subdivision p ^^ n) (frag_of (λx∈standard_simplex p. x)))›*) by (simp add: singular_chain_of (*‹singular_chain ?p ?X (frag_of ?c) = singular_simplex ?p ?X ?c›*) id_def (*‹id = (λx. x)›*) del: restrict_apply (*‹restrict ?f ?A ?x = (if ?x ∈ ?A then ?f ?x else undefined)›*))
qed (auto simp: singular_subdivision_power_diff (*‹(singular_subdivision ?p ^^ ?n) (?a - ?b) = (singular_subdivision ?p ^^ ?n) ?a - (singular_subdivision ?p ^^ ?n) ?b›*) singular_subdivision_diff (*‹singular_subdivision ?p (?a - ?b) = singular_subdivision ?p ?a - singular_subdivision ?p ?b›*) frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*))
(*solves the remaining goals:
1. ‹(singular_subdivision (p::nat) ^^ Suc (n::nat)) (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) = frag_extend (λf::(nat ⇒ real) ⇒ 'a::type. chain_map p f ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))) (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)›
2. ‹⋀(a::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) b::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. ⟦(singular_subdivision (p::nat) ^^ Suc (n::nat)) a = frag_extend (λf::(nat ⇒ real) ⇒ 'a::type. chain_map p f ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))) a; (singular_subdivision p ^^ Suc n) b = frag_extend (λf::(nat ⇒ real) ⇒ 'a::type. chain_map p f ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))) b⟧ ⟹ (singular_subdivision p ^^ Suc n) (a - b) = frag_extend (λf::(nat ⇒ real) ⇒ 'a::type. chain_map p f ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p))))) (a - b)›*)
qed
lemma chain_homotopic_iterated_singular_subdivision:
obtains h where
"⋀p. h p 0 = (0 :: 'a chain)"
"⋀p c1 c2. h p (c1-c2) = h p c1 - h p c2"
"⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X (h p c)"
"⋀p X c. singular_chain p X c
⟹ chain_boundary (Suc p) (h p c) + h (p - Suc 0) (chain_boundary p c)
= (singular_subdivision p ^^ n) c - c"
proof (induction n arbitrary: thesis)
(*goals:
1. ‹⋀thesis::bool. (⋀h::nat ⇒ (((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. ⟦⋀p::nat. h p (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) = (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int); ⋀(p::nat) (c1::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) c2::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. h p (c1 - c2) = h p c1 - h p c2; ⋀(p::nat) (X::'a::type topology) c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. singular_chain p X c ⟹ singular_chain (Suc p) X (h p c); ⋀(p::nat) (X::'a::type topology) c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. singular_chain p X c ⟹ chain_boundary (Suc p) (h p c) + h (p - Suc (0::nat)) (chain_boundary p c) = (singular_subdivision p ^^ (0::nat)) c - c⟧ ⟹ thesis) ⟹ thesis›
2. ‹⋀(n::nat) thesis::bool. ⟦⋀thesis::bool. (⋀h::nat ⇒ (((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. ⟦⋀p::nat. h p (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) = (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int); ⋀(p::nat) (c1::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) c2::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. h p (c1 - c2) = h p c1 - h p c2; ⋀(p::nat) (X::'a::type topology) c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. singular_chain p X c ⟹ singular_chain (Suc p) X (h p c); ⋀(p::nat) (X::'a::type topology) c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. singular_chain p X c ⟹ chain_boundary (Suc p) (h p c) + h (p - Suc (0::nat)) (chain_boundary p c) = (singular_subdivision p ^^ n) c - c⟧ ⟹ thesis) ⟹ thesis; ⋀h::nat ⇒ (((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. ⟦⋀p::nat. h p (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) = (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int); ⋀(p::nat) (c1::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) c2::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. h p (c1 - c2) = h p c1 - h p c2; ⋀(p::nat) (X::'a::type topology) c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. singular_chain p X c ⟹ singular_chain (Suc p) X (h p c); ⋀(p::nat) (X::'a::type topology) c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. singular_chain p X c ⟹ chain_boundary (Suc p) (h p c) + h (p - Suc (0::nat)) (chain_boundary p c) = (singular_subdivision p ^^ Suc n) c - c⟧ ⟹ thesis⟧ ⟹ thesis›*)
case 0 (*‹⟦⋀p. ?h p 0 = 0; ⋀p c1 c2. ?h p (c1 - c2) = ?h p c1 - ?h p c2; ⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X (?h p c); ⋀p X c. singular_chain p X c ⟹ chain_boundary (Suc p) (?h p c) + ?h (p - Suc 0) (chain_boundary p c) = (singular_subdivision p ^^ 0) c - c⟧ ⟹ thesis›*)
show "?case"
(*goal: ‹thesis›*)
apply (rule 0 [of "(λp x. 0)"] (*‹⟦⋀p::nat. (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int) = (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int); ⋀(p::nat) (c1::((nat ⇒ real) ⇒ 'a) ⇒₀ int) c2::((nat ⇒ real) ⇒ 'a) ⇒₀ int. (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int) = (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int) - (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int); ⋀(p::nat) (X::'a topology) c::((nat ⇒ real) ⇒ 'a) ⇒₀ int. singular_chain p X c ⟹ singular_chain (Suc p) X (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int); ⋀(p::nat) (X::'a topology) c::((nat ⇒ real) ⇒ 'a) ⇒₀ int. singular_chain p X c ⟹ chain_boundary (Suc p) (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int) + (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int) = (singular_subdivision p ^^ (0::nat)) c - c⟧ ⟹ thesis::bool›*))
(*goals:
1. ‹⋀p. 0 = 0›
2. ‹⋀p c1 c2. 0 = 0 - 0›
3. ‹⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X 0›
4. ‹⋀p X c. singular_chain p X c ⟹ chain_boundary (Suc p) 0 + 0 = (singular_subdivision p ^^ 0) c - c›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*proven 4 subgoals*) .
next
(*goal: ‹⋀n thesis. ⟦⋀thesis. (⋀h. ⟦⋀p. h p 0 = 0; ⋀p c1 c2. h p (c1 - c2) = h p c1 - h p c2; ⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X (h p c); ⋀p X c. singular_chain p X c ⟹ chain_boundary (Suc p) (h p c) + h (p - Suc 0) (chain_boundary p c) = (singular_subdivision p ^^ n) c - c⟧ ⟹ thesis) ⟹ thesis; ⋀h. ⟦⋀p. h p 0 = 0; ⋀p c1 c2. h p (c1 - c2) = h p c1 - h p c2; ⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X (h p c); ⋀p X c. singular_chain p X c ⟹ chain_boundary (Suc p) (h p c) + h (p - Suc 0) (chain_boundary p c) = (singular_subdivision p ^^ Suc n) c - c⟧ ⟹ thesis⟧ ⟹ thesis›*)
case (Suc n) (*‹(⋀h. ⟦⋀p. h p 0 = 0; ⋀p c1 c2. h p (c1 - c2) = h p c1 - h p c2; ⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X (h p c); ⋀p X c. singular_chain p X c ⟹ chain_boundary (Suc p) (h p c) + h (p - Suc 0) (chain_boundary p c) = (singular_subdivision p ^^ n) c - c⟧ ⟹ ?thesis) ⟹ ?thesis› ‹⟦⋀p. ?h p 0 = 0; ⋀p c1 c2. ?h p (c1 - c2) = ?h p c1 - ?h p c2; ⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X (?h p c); ⋀p X c. singular_chain p X c ⟹ chain_boundary (Suc p) (?h p c) + ?h (p - Suc 0) (chain_boundary p c) = (singular_subdivision p ^^ Suc n) c - c⟧ ⟹ thesis›*)
then obtain k where k: "⋀p. k p 0 = (0 :: 'a chain)" "⋀p c1 c2. k p (c1-c2) = k p c1 - k p c2" "⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X (k p c)" "⋀p X c. singular_chain p X c
⟹ chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c)
= (singular_subdivision p ^^ n) c - c"
(*goal: ‹(⋀k::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int. ⟦⋀p::nat. k p (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int) = (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int); ⋀(p::nat) (c1::((nat ⇒ real) ⇒ 'a) ⇒₀ int) c2::((nat ⇒ real) ⇒ 'a) ⇒₀ int. k p (c1 - c2) = k p c1 - k p c2; ⋀(p::nat) (X::'a topology) c::((nat ⇒ real) ⇒ 'a) ⇒₀ int. singular_chain p X c ⟹ singular_chain (Suc p) X (k p c); ⋀(p::nat) (X::'a topology) c::((nat ⇒ real) ⇒ 'a) ⇒₀ int. singular_chain p X c ⟹ chain_boundary (Suc p) (k p c) + k (p - Suc (0::nat)) (chain_boundary p c) = (singular_subdivision p ^^ (n::nat)) c - c⟧ ⟹ thesis::bool) ⟹ thesis›*)
by metis
obtain h where h: "⋀p. h p 0 = (0 :: 'a chain)" "⋀p c1 c2. h p (c1-c2) = h p c1 - h p c2" "⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X (h p c)" "⋀p X c. singular_chain p X c
⟹ chain_boundary (Suc p) (h p c) + h (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c"
(*goal: ‹(⋀h::nat ⇒ (((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. ⟦⋀p::nat. h p (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) = (0::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int); ⋀(p::nat) (c1::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) c2::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. h p (c1 - c2) = h p c1 - h p c2; ⋀(p::nat) (X::'a::type topology) c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. singular_chain p X c ⟹ singular_chain (Suc p) X (h p c); ⋀(p::nat) (X::'a::type topology) c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. singular_chain p X c ⟹ chain_boundary (Suc p) (h p c) + h (p - Suc (0::nat)) (chain_boundary p c) = singular_subdivision p c - c⟧ ⟹ thesis::bool) ⟹ thesis›*)
by (blast intro: chain_homotopic_singular_subdivision (*‹(⋀h. ⟦⋀p. h p 0 = 0; ⋀p c1 c2. h p (c1 - c2) = h p c1 - h p c2; ⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X (h p c); ⋀p X c. singular_chain p X c ⟹ chain_boundary (Suc p) (h p c) + h (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c⟧ ⟹ ?thesis) ⟹ ?thesis›*))
let ?h = "(λp c. singular_subdivision (Suc p) (k p c) + h p c)"
show "?case"
(*goal: ‹thesis›*)
proof (rule Suc.prems (*‹⟦⋀p. ?h p 0 = 0; ⋀p c1 c2. ?h p (c1 - c2) = ?h p c1 - ?h p c2; ⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X (?h p c); ⋀p X c. singular_chain p X c ⟹ chain_boundary (Suc p) (?h p c) + ?h (p - Suc 0) (chain_boundary p c) = (singular_subdivision p ^^ Suc n) c - c⟧ ⟹ thesis›*))
(*goals:
1. ‹⋀p. ?h p 0 = 0›
2. ‹⋀p c1 c2. ?h p (c1 - c2) = ?h p c1 - ?h p c2›
3. ‹⋀p X c. singular_chain p X c ⟹ singular_chain (Suc p) X (?h p c)›
4. ‹⋀p X c. singular_chain p X c ⟹ chain_boundary (Suc p) (?h p c) + ?h (p - Suc 0) (chain_boundary p c) = (singular_subdivision p ^^ Suc n) c - c›*)
fix p and X and c :: "'a chain"
assume "singular_chain p X c" (*‹singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*)
then show "singular_chain (Suc p) X (?h p c)"
by (simp add: h (*‹h ?p 0 = 0› ‹h ?p (?c1.0 - ?c2.0) = h ?p ?c1.0 - h ?p ?c2.0› ‹singular_chain ?p ?X ?c ⟹ singular_chain (Suc ?p) ?X (h ?p ?c)› ‹singular_chain ?p ?X ?c ⟹ chain_boundary (Suc ?p) (h ?p ?c) + h (?p - Suc 0) (chain_boundary ?p ?c) = singular_subdivision ?p ?c - ?c›*) k (*‹k ?p 0 = 0› ‹k ?p (?c1.0 - ?c2.0) = k ?p ?c1.0 - k ?p ?c2.0› ‹singular_chain ?p ?X ?c ⟹ singular_chain (Suc ?p) ?X (k ?p ?c)› ‹singular_chain ?p ?X ?c ⟹ chain_boundary (Suc ?p) (k ?p ?c) + k (?p - Suc 0) (chain_boundary ?p ?c) = (singular_subdivision ?p ^^ n) ?c - ?c›*) singular_chain_add (*‹⟦singular_chain ?p ?X ?a; singular_chain ?p ?X ?b⟧ ⟹ singular_chain ?p ?X (?a + ?b)›*) singular_chain_singular_subdivision (*‹singular_chain ?p ?X ?c ⟹ singular_chain ?p ?X (singular_subdivision ?p ?c)›*))
next
(*goals:
1. ‹⋀p::nat. singular_subdivision (Suc p) ((k::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int) p (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int)) + (h::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int) p (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int) = (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›
2. ‹⋀(p::nat) (c1::((nat ⇒ real) ⇒ 'a) ⇒₀ int) c2::((nat ⇒ real) ⇒ 'a) ⇒₀ int. singular_subdivision (Suc p) ((k::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int) p (c1 - c2)) + (h::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int) p (c1 - c2) = singular_subdivision (Suc p) (k p c1) + h p c1 - (singular_subdivision (Suc p) (k p c2) + h p c2)›
3. ‹⋀(p::nat) (X::'a topology) c::((nat ⇒ real) ⇒ 'a) ⇒₀ int. singular_chain p X c ⟹ chain_boundary (Suc p) (singular_subdivision (Suc p) ((k::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int) p c) + (h::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int) p c) + (singular_subdivision (Suc (p - Suc (0::nat))) (k (p - Suc (0::nat)) (chain_boundary p c)) + h (p - Suc (0::nat)) (chain_boundary p c)) = (singular_subdivision p ^^ Suc (n::nat)) c - c›*)
fix p :: nat and X :: "'a topology" and c :: "'a chain"
assume sc: "singular_chain p X c" (*‹singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*)
have f5: "chain_boundary (Suc p) (singular_subdivision (Suc p) (k p c)) = singular_subdivision p (chain_boundary (Suc p) (k p c))"
using chain_boundary_singular_subdivision (*‹singular_chain (?p::nat) (?X::?'a topology) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ⟹ chain_boundary ?p (singular_subdivision ?p ?c) = singular_subdivision (?p - Suc (0::nat)) (chain_boundary ?p ?c)›*) k(3) (*‹singular_chain ?p ?X ?c ⟹ singular_chain (Suc ?p) ?X (k ?p ?c)›*) sc (*‹singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*) by fastforce
have [simp]: "singular_subdivision (Suc (p - Suc 0)) (k (p - Suc 0) (chain_boundary p c)) =
singular_subdivision p (k (p - Suc 0) (chain_boundary p c))"
proof (cases p)
(*goals:
1. ‹p = 0 ⟹ singular_subdivision (Suc (p - Suc 0)) (k (p - Suc 0) (chain_boundary p c)) = singular_subdivision p (k (p - Suc 0) (chain_boundary p c))›
2. ‹⋀nat. p = Suc nat ⟹ singular_subdivision (Suc (p - Suc 0)) (k (p - Suc 0) (chain_boundary p c)) = singular_subdivision p (k (p - Suc 0) (chain_boundary p c))›*)
case 0 (*‹p = 0›*)
then show "?thesis"
(*goal: ‹singular_subdivision (Suc (p - Suc 0)) (k (p - Suc 0) (chain_boundary p c)) = singular_subdivision p (k (p - Suc 0) (chain_boundary p c))›*)
by (simp add: k (*‹(k::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int) (?p::nat) (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int) = (0::((nat ⇒ real) ⇒ 'a) ⇒₀ int)› ‹(k::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int) (?p::nat) ((?c1.0::((nat ⇒ real) ⇒ 'a) ⇒₀ int) - (?c2.0::((nat ⇒ real) ⇒ 'a) ⇒₀ int)) = k ?p ?c1.0 - k ?p ?c2.0› ‹singular_chain (?p::nat) (?X::'a topology) (?c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⟹ singular_chain (Suc ?p) ?X ((k::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int) ?p ?c)› ‹singular_chain (?p::nat) (?X::'a topology) (?c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⟹ chain_boundary (Suc ?p) ((k::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a) ⇒₀ int) ?p ?c) + k (?p - Suc (0::nat)) (chain_boundary ?p ?c) = (singular_subdivision ?p ^^ (n::nat)) ?c - ?c›*) chain_boundary_def (*‹chain_boundary (?p::nat) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ≡ if ?p = (0::nat) then 0::((nat ⇒ real) ⇒ ?'a) ⇒₀ int else frag_extend (λf::(nat ⇒ real) ⇒ ?'a. ∑k::nat≤?p. frag_cmul ((- (1::int)) ^ k) (frag_of (singular_face ?p k f))) ?c›*))
qed (auto)
(*solved the remaining goal: ‹⋀nat. p = Suc nat ⟹ singular_subdivision (Suc (p - Suc 0)) (k (p - Suc 0) (chain_boundary p c)) = singular_subdivision p (k (p - Suc 0) (chain_boundary p c))›*)
show "chain_boundary (Suc p) (?h p c) + ?h (p - Suc 0) (chain_boundary p c) = (singular_subdivision p ^^ Suc n) c - c"
using chain_boundary_singular_subdivision[of "Suc p" X] (*‹singular_chain (Suc p) X ?c ⟹ chain_boundary (Suc p) (singular_subdivision (Suc p) ?c) = singular_subdivision (Suc p - Suc 0) (chain_boundary (Suc p) ?c)›*) apply (simp add: chain_boundary_add (*‹chain_boundary ?p (?a + ?b) = chain_boundary ?p ?a + chain_boundary ?p ?b›*) f5 (*‹chain_boundary (Suc p) (singular_subdivision (Suc p) (k p c)) = singular_subdivision p (chain_boundary (Suc p) (k p c))›*) h (*‹h ?p 0 = 0› ‹h ?p (?c1.0 - ?c2.0) = h ?p ?c1.0 - h ?p ?c2.0› ‹singular_chain ?p ?X ?c ⟹ singular_chain (Suc ?p) ?X (h ?p ?c)› ‹singular_chain ?p ?X ?c ⟹ chain_boundary (Suc ?p) (h ?p ?c) + h (?p - Suc 0) (chain_boundary ?p ?c) = singular_subdivision ?p ?c - ?c›*) k (*‹k ?p 0 = 0› ‹k ?p (?c1.0 - ?c2.0) = k ?p ?c1.0 - k ?p ?c2.0› ‹singular_chain ?p ?X ?c ⟹ singular_chain (Suc ?p) ?X (k ?p ?c)› ‹singular_chain ?p ?X ?c ⟹ chain_boundary (Suc ?p) (k ?p ?c) + k (?p - Suc 0) (chain_boundary ?p ?c) = (singular_subdivision ?p ^^ n) ?c - ?c›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 33 facts*))
(*goal: ‹chain_boundary (Suc p) (singular_subdivision (Suc p) (k p c) + h p c) + (singular_subdivision (Suc (p - Suc 0)) (k (p - Suc 0) (chain_boundary p c)) + h (p - Suc 0) (chain_boundary p c)) = (singular_subdivision p ^^ Suc n) c - c›*)
by (smt (verit, del_insts) add.commute (*‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a›*) add.left_commute (*‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)›*) diff_add_cancel (*‹(?a::?'a::group_add) - (?b::?'a::group_add) + ?b = ?a›*) h( (*‹singular_chain (?p::nat) (?X::'a::type topology) (?c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⟹ chain_boundary (Suc ?p) ((h::nat ⇒ (((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ?p ?c) + h (?p - Suc (0::nat)) (chain_boundary ?p ?c) = singular_subdivision ?p ?c - ?c›*) 4) k( (*‹singular_chain (?p::nat) (?X::'a::type topology) (?c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⟹ chain_boundary (Suc ?p) ((k::nat ⇒ (((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ?p ?c) + k (?p - Suc (0::nat)) (chain_boundary ?p ?c) = (singular_subdivision ?p ^^ (n::nat)) ?c - ?c›*) 4) sc (*‹singular_chain (p::nat) (X::'a::type topology) (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)›*) singular_subdivision_add (*‹singular_subdivision (?p::nat) ((?a::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int) + (?b::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int)) = singular_subdivision ?p ?a + singular_subdivision ?p ?b›*))
qed (auto simp: k (*‹k ?p 0 = 0› ‹k ?p (?c1.0 - ?c2.0) = k ?p ?c1.0 - k ?p ?c2.0› ‹singular_chain ?p ?X ?c ⟹ singular_chain (Suc ?p) ?X (k ?p ?c)› ‹singular_chain ?p ?X ?c ⟹ chain_boundary (Suc ?p) (k ?p ?c) + k (?p - Suc 0) (chain_boundary ?p ?c) = (singular_subdivision ?p ^^ n) ?c - ?c›*) h (*‹h ?p 0 = 0› ‹h ?p (?c1.0 - ?c2.0) = h ?p ?c1.0 - h ?p ?c2.0› ‹singular_chain ?p ?X ?c ⟹ singular_chain (Suc ?p) ?X (h ?p ?c)› ‹singular_chain ?p ?X ?c ⟹ chain_boundary (Suc ?p) (h ?p ?c) + h (?p - Suc 0) (chain_boundary ?p ?c) = singular_subdivision ?p ?c - ?c›*) singular_subdivision_diff (*‹singular_subdivision ?p (?a - ?b) = singular_subdivision ?p ?a - singular_subdivision ?p ?b›*))
(*solves the remaining goals:
1. ‹⋀p. singular_subdivision (Suc p) (k p 0) + h p 0 = 0›
2. ‹⋀p c1 c2. singular_subdivision (Suc p) (k p (c1 - c2)) + h p (c1 - c2) = singular_subdivision (Suc p) (k p c1) + h p c1 - (singular_subdivision (Suc p) (k p c2) + h p c2)›*)
qed
lemma llemma:
assumes p: "standard_simplex p ⊆ ⋃𝒞"
and 𝒞: "⋀U. U ∈ 𝒞 ⟹ openin (powertop_real UNIV) U"
obtains d where "0 < d"
"⋀K. ⟦K ⊆ standard_simplex p;
⋀x y i. ⟦i ≤ p; x ∈ K; y ∈ K⟧ ⟹ ¦x i - y i¦ ≤ d⟧
⟹ ∃U. U ∈ 𝒞 ∧ K ⊆ U"
proof (-)
(*goal: ‹(⋀d::real. ⟦(0::real) < d; ⋀K::(nat ⇒ real) set. ⟦K ⊆ standard_simplex (p::nat); ⋀(x::nat ⇒ real) (y::nat ⇒ real) i::nat. ⟦i ≤ p; x ∈ K; y ∈ K⟧ ⟹ ¦x i - y i¦ ≤ d⟧ ⟹ ∃U::(nat ⇒ real) set. U ∈ (𝒞::(nat ⇒ real) set set) ∧ K ⊆ U⟧ ⟹ thesis::bool) ⟹ thesis›*)
have "∃e U. 0 < e ∧ U ∈ 𝒞 ∧ x ∈ U ∧
(∀y. (∀i≤p. ¦y i - x i¦ ≤ 2 * e) ∧ (∀i>p. y i = 0) ⟶ y ∈ U)" if x: "x ∈ standard_simplex p" for x
proof (-)
(*goal: ‹∃e U. 0 < e ∧ U ∈ 𝒞 ∧ x ∈ U ∧ (∀y. (∀i≤p. ¦y i - x i¦ ≤ 2 * e) ∧ (∀i>p. y i = 0) ⟶ y ∈ U)›*)
obtain U where U: "U ∈ 𝒞" "x ∈ U"
(*goal: ‹(⋀U::(nat ⇒ real) set. ⟦U ∈ (𝒞::(nat ⇒ real) set set); (x::nat ⇒ real) ∈ U⟧ ⟹ thesis::bool) ⟹ thesis›*)
using x (*‹x ∈ standard_simplex p›*) p (*‹standard_simplex (p::nat) ⊆ ⋃ (𝒞::(nat ⇒ real) set set)›*) by blast
then obtain V where finV: "finite {i. V i ≠ UNIV}" and openV: "⋀i. open (V i)" and xV: "x ∈ Pi⇩E UNIV V" and UV: "Pi⇩E UNIV V ⊆ U"
(*goal: ‹(⋀V. ⟦finite {i. V i ≠ UNIV}; ⋀i. open (V i); x ∈ Pi⇩E UNIV V; Pi⇩E UNIV V ⊆ U⟧ ⟹ thesis) ⟹ thesis›*)
using "𝒞" (*‹(?U::(nat ⇒ real) set) ∈ (𝒞::(nat ⇒ real) set set) ⟹ openin (powertop_real UNIV) ?U›*) unfolding openin_product_topology_alt
(*goal: ‹(⋀V. ⟦finite {i. V i ≠ UNIV}; ⋀i. open (V i); x ∈ Pi⇩E UNIV V; Pi⇩E UNIV V ⊆ U⟧ ⟹ thesis) ⟹ thesis›*)
by force
have xVi: "x i ∈ V i" for i
using PiE_mem[OF xV] (*‹?x ∈ UNIV ⟹ x ?x ∈ V ?x›*) by simp
have "⋀i. ∃e>0. ∀x'. ¦x' - x i¦ < e ⟶ x' ∈ V i"
by (rule openV [unfolded open_real, rule_format, OF xVi] (*‹∃e>0. ∀x'. ¦x' - x ?i¦ < e ⟶ x' ∈ V ?i›*))
then obtain d where d: "⋀i. d i > 0" and dV: "⋀i x'. ¦x' - x i¦ < d i ⟹ x' ∈ V i"
(*goal: ‹(⋀d::nat ⇒ real. ⟦⋀i::nat. (0::real) < d i; ⋀(i::nat) x'::real. ¦x' - (x::nat ⇒ real) i¦ < d i ⟹ x' ∈ (V::nat ⇒ real set) i⟧ ⟹ thesis::bool) ⟹ thesis›*)
by metis
define e where "e ≡ Inf (insert 1 (d ` {i. V i ≠ UNIV})) / 3"
have ed3: "e ≤ d i / 3" if "V i ≠ UNIV" for i
using that (*‹V i ≠ UNIV›*) finV (*‹finite {i::nat. (V::nat ⇒ real set) i ≠ UNIV}›*) by (auto simp: e_def (*‹e ≡ Inf (insert 1 (d ` {i. V i ≠ UNIV})) / 3›*) intro: cInf_le_finite (*‹⟦finite ?X; ?x ∈ ?X⟧ ⟹ Inf ?X ≤ ?x›*))
show "∃e U. 0 < e ∧ U ∈ 𝒞 ∧ x ∈ U ∧
(∀y. (∀i≤p. ¦y i - x i¦ ≤ 2 * e) ∧ (∀i>p. y i = 0) ⟶ y ∈ U)"
proof (intro exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goals:
1. ‹(0::real) < (?e::real)›
2. ‹(?U1::(nat ⇒ real) set) ∈ (𝒞::(nat ⇒ real) set set)›
3. ‹(x::nat ⇒ real) ∈ (?U1::(nat ⇒ real) set)›
4. ‹⋀y::nat ⇒ real. (∀i≤p::nat. ¦y i - (x::nat ⇒ real) i¦ ≤ (2::real) * (?e::real)) ∧ (∀i>p. y i = (0::real)) ⟹ y ∈ (?U1::(nat ⇒ real) set)›*)
show "e > 0"
using d (*‹0 < d ?i›*) finV (*‹finite {i. V i ≠ UNIV}›*) by (simp add: e_def (*‹e ≡ Inf (insert 1 (d ` {i. V i ≠ UNIV})) / 3›*) finite_less_Inf_iff (*‹⟦finite ?X; ?X ≠ {}⟧ ⟹ (?a < Inf ?X) = (∀x∈?X. ?a < x)›*))
fix y
assume y: "(∀i≤p. ¦y i - x i¦ ≤ 2 * e) ∧ (∀i>p. y i = 0)" (*‹(∀i≤p::nat. ¦(y::nat ⇒ real) i - (x::nat ⇒ real) i¦ ≤ (2::real) * (e::real)) ∧ (∀i>p. y i = (0::real))›*)
have "y ∈ Pi⇩E UNIV V"
proof (standard)
(*goals:
1. ‹⋀x::nat. x ∈ UNIV ⟹ (y::nat ⇒ real) x ∈ (V::nat ⇒ real set) x›
2. ‹⋀x::nat. x ∉ UNIV ⟹ (y::nat ⇒ real) x = undefined›*)
show "y i ∈ V i" for i
proof (cases "p < i")
(*goals:
1. ‹(p::nat) < (i::nat) ⟹ (y::nat ⇒ real) i ∈ (V::nat ⇒ real set) i›
2. ‹¬ (p::nat) < (i::nat) ⟹ (y::nat ⇒ real) i ∈ (V::nat ⇒ real set) i›*)
case True (*‹p < i›*)
then show "?thesis"
(*goal: ‹y i ∈ V i›*)
by (metis (mono_tags, lifting) y (*‹(∀i≤p. ¦y i - x i¦ ≤ 2 * e) ∧ (∀i>p. y i = 0)›*) x (*‹x ∈ standard_simplex p›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*) xVi (*‹x ?i ∈ V ?i›*))
next
(*goal: ‹¬ (p::nat) < (i::nat) ⟹ (y::nat ⇒ real) i ∈ (V::nat ⇒ real set) i›*)
case False (*‹¬ p < i›*)
show "?thesis"
(*goal: ‹y i ∈ V i›*)
proof (cases "V i = UNIV")
(*goals:
1. ‹V i = UNIV ⟹ y i ∈ V i›
2. ‹V i ≠ UNIV ⟹ y i ∈ V i›*)
case False (*‹V i ≠ UNIV›*)
show "?thesis"
(*goal: ‹y i ∈ V i›*)
proof (rule dV (*‹¦?x' - x ?i¦ < d ?i ⟹ ?x' ∈ V ?i›*))
(*goal: ‹¦y i - x i¦ < d i›*)
have "¦y i - x i¦ ≤ 2 * e"
using y (*‹(∀i≤p. ¦y i - x i¦ ≤ 2 * e) ∧ (∀i>p. y i = 0)›*) ‹¬ p < i› (*‹¬ p < i›*) by simp
also (*calculation: ‹¦y i - x i¦ ≤ 2 * e›*) have "… < d i"
using ed3[OF False] (*‹e ≤ d i / 3›*) ‹e > 0› (*‹0 < e›*) by simp
finally (*calculation: ‹¦y i - x i¦ < d i›*) show "¦y i - x i¦ < d i" .
qed
qed (auto)
(*solved the remaining goal: ‹V i = UNIV ⟹ y i ∈ V i›*)
qed
qed (auto)
(*solved the remaining goal: ‹⋀x. x ∉ UNIV ⟹ y x = undefined›*)
with UV (*‹Pi⇩E UNIV V ⊆ U›*) show "y ∈ U"
by blast
qed (use U in auto)
(*solves the remaining goals:
1. ‹U ∈ 𝒞›
2. ‹x ∈ U›*)
qed
then obtain e and U where eU: "⋀x. x ∈ standard_simplex p ⟹
0 < e x ∧ U x ∈ 𝒞 ∧ x ∈ U x" and UI: "⋀x y. ⟦x ∈ standard_simplex p; ⋀i. i ≤ p ⟹ ¦y i - x i¦ ≤ 2 * e x; ⋀i. i > p ⟹ y i = 0⟧
⟹ y ∈ U x"
(*goal: ‹(⋀e U. ⟦⋀x. x ∈ standard_simplex p ⟹ 0 < e x ∧ U x ∈ 𝒞 ∧ x ∈ U x; ⋀x y. ⟦x ∈ standard_simplex p; ⋀i. i ≤ p ⟹ ¦y i - x i¦ ≤ 2 * e x; ⋀i. p < i ⟹ y i = 0⟧ ⟹ y ∈ U x⟧ ⟹ thesis) ⟹ thesis›*)
by metis
define F where "F ≡ λx. Pi⇩E UNIV (λi. if i ≤ p then {x i - e x<..<x i + e x} else UNIV)"
have "∀S ∈ F ` standard_simplex p. openin (powertop_real UNIV) S"
by (simp add: F_def (*‹F ≡ λx. Π⇩E i∈UNIV. if i ≤ p then {x i - e x<..<x i + e x} else UNIV›*) openin_PiE_gen (*‹openin (product_topology ?X ?I) (Pi⇩E ?I ?S) = (Pi⇩E ?I ?S = {} ∨ finite {i ∈ ?I. ?S i ≠ topspace (?X i)} ∧ (∀i∈?I. openin (?X i) (?S i)))›*))
moreover have pF: "standard_simplex p ⊆ ⋃(F ` standard_simplex p)"
by (force simp: F_def (*‹F ≡ λx. Π⇩E i∈UNIV. if i ≤ p then {x i - e x<..<x i + e x} else UNIV›*) PiE_iff (*‹(?f ∈ Pi⇩E ?I ?X) = ((∀i∈?I. ?f i ∈ ?X i) ∧ ?f ∈ extensional ?I)›*) eU (*‹?x ∈ standard_simplex p ⟹ 0 < e ?x ∧ U ?x ∈ 𝒞 ∧ ?x ∈ U ?x›*))
ultimately have "∃ℱ. finite ℱ ∧ ℱ ⊆ F ` standard_simplex p ∧ standard_simplex p ⊆ ⋃ℱ"
using compactin_standard_simplex[of p] (*‹compactin (powertop_real UNIV) (standard_simplex p)›*) unfolding compactin_def
(*goal: ‹∃ℱ. finite ℱ ∧ ℱ ⊆ F ` standard_simplex p ∧ standard_simplex p ⊆ ⋃ ℱ›*)
by force
then obtain S where "finite S" and ssp: "S ⊆ standard_simplex p" "standard_simplex p ⊆ ⋃(F ` S)"
(*goal: ‹(⋀S. ⟦finite S; S ⊆ standard_simplex p; standard_simplex p ⊆ ⋃ (F ` S)⟧ ⟹ thesis) ⟹ thesis›*)
unfolding ex_finite_subset_image
(*goal: ‹(⋀S. ⟦finite S; S ⊆ standard_simplex p; standard_simplex p ⊆ ⋃ (F ` S)⟧ ⟹ thesis) ⟹ thesis›*)
by (auto simp: ex_finite_subset_image (*‹(∃B. finite B ∧ B ⊆ ?f ` ?A ∧ ?P B) = (∃B. finite B ∧ B ⊆ ?A ∧ ?P (?f ` B))›*))
then have "S ≠ {}"
by (auto simp: nonempty_standard_simplex (*‹standard_simplex ?p ≠ {}›*))
show "?thesis"
(*goal: ‹thesis›*)
proof (standard)
(*goals:
1. ‹(0::real) < (?d::real)›
2. ‹⋀K::(nat ⇒ real) set. ⟦K ⊆ standard_simplex (p::nat); ⋀(x::nat ⇒ real) (y::nat ⇒ real) i::nat. ⟦i ≤ p; x ∈ K; y ∈ K⟧ ⟹ ¦x i - y i¦ ≤ (?d::real)⟧ ⟹ ∃U::(nat ⇒ real) set. U ∈ (𝒞::(nat ⇒ real) set set) ∧ K ⊆ U›*)
show "Inf (e ` S) > 0"
using ‹finite S› (*‹finite S›*) ‹S ≠ {}› (*‹(S::(nat ⇒ real) set) ≠ {}›*) ssp (*‹S ⊆ standard_simplex p› ‹standard_simplex (p::nat) ⊆ ⋃ ((F::(nat ⇒ real) ⇒ (nat ⇒ real) set) ` (S::(nat ⇒ real) set))›*) eU (*‹?x ∈ standard_simplex p ⟹ 0 < e ?x ∧ U ?x ∈ 𝒞 ∧ ?x ∈ U ?x›*) by (auto simp: finite_less_Inf_iff (*‹⟦finite ?X; ?X ≠ {}⟧ ⟹ (?a < Inf ?X) = (∀x∈?X. ?a < x)›*))
fix k :: "(nat ⇒ real) set"
assume k: "k ⊆ standard_simplex p" and kle: "⋀x y i. ⟦i ≤ p; x ∈ k; y ∈ k⟧ ⟹ ¦x i - y i¦ ≤ Inf (e ` S)" (*‹(k::(nat ⇒ real) set) ⊆ standard_simplex (p::nat)› ‹⟦(?i::nat) ≤ (p::nat); (?x::nat ⇒ real) ∈ (k::(nat ⇒ real) set); (?y::nat ⇒ real) ∈ k⟧ ⟹ ¦?x ?i - ?y ?i¦ ≤ Inf ((e::(nat ⇒ real) ⇒ real) ` (S::(nat ⇒ real) set))›*)
show "∃U. U ∈ 𝒞 ∧ k ⊆ U"
proof (cases "k = {}")
(*goals:
1. ‹k = {} ⟹ ∃U. U ∈ 𝒞 ∧ k ⊆ U›
2. ‹k ≠ {} ⟹ ∃U. U ∈ 𝒞 ∧ k ⊆ U›*)
case True (*‹k = {}›*)
then show "?thesis"
(*goal: ‹∃U. U ∈ 𝒞 ∧ k ⊆ U›*)
using ‹S ≠ {}› (*‹S ≠ {}›*) eU (*‹?x ∈ standard_simplex p ⟹ 0 < e ?x ∧ U ?x ∈ 𝒞 ∧ ?x ∈ U ?x›*) equals0I (*‹(⋀y. y ∈ ?A ⟹ False) ⟹ ?A = {}›*) ssp(1) (*‹(S::(nat ⇒ real) set) ⊆ standard_simplex (p::nat)›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) p (*‹standard_simplex (p::nat) ⊆ ⋃ (𝒞::(nat ⇒ real) set set)›*) by auto
next
(*goal: ‹(k::(nat ⇒ real) set) ≠ {} ⟹ ∃U::(nat ⇒ real) set. U ∈ (𝒞::(nat ⇒ real) set set) ∧ k ⊆ U›*)
case False (*‹(k::(nat ⇒ real) set) ≠ {}›*)
with k (*‹(k::(nat ⇒ real) set) ⊆ standard_simplex (p::nat)›*) ssp (*‹(S::(nat ⇒ real) set) ⊆ standard_simplex (p::nat)› ‹standard_simplex p ⊆ ⋃ (F ` S)›*) obtain x and a where "x ∈ k" "x ∈ standard_simplex p" and a: "a ∈ S" and Fa: "x ∈ F a"
(*goal: ‹(⋀x a. ⟦x ∈ k; x ∈ standard_simplex p; a ∈ S; x ∈ F a⟧ ⟹ thesis) ⟹ thesis›*)
by blast
then have le_ea: "⋀i. i ≤ p ⟹ abs (x i - a i) < e a"
by (simp add: F_def (*‹F ≡ λx. Π⇩E i∈UNIV. if i ≤ p then {x i - e x<..<x i + e x} else UNIV›*) PiE_iff (*‹(?f ∈ Pi⇩E ?I ?X) = ((∀i∈?I. ?f i ∈ ?X i) ∧ ?f ∈ extensional ?I)›*) if_distrib (*‹?f (if ?c then ?x else ?y) = (if ?c then ?f ?x else ?f ?y)›*) abs_diff_less_iff (*‹(¦?x - ?a¦ < ?r) = (?a - ?r < ?x ∧ ?x < ?a + ?r)›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
show "?thesis"
(*goal: ‹∃U. U ∈ 𝒞 ∧ k ⊆ U›*)
proof (intro exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹?U ∈ 𝒞›
2. ‹k ⊆ ?U›*)
show "U a ∈ 𝒞"
using a (*‹a ∈ S›*) eU (*‹?x ∈ standard_simplex p ⟹ 0 < e ?x ∧ U ?x ∈ 𝒞 ∧ ?x ∈ U ?x›*) ssp(1) (*‹(S::(nat ⇒ real) set) ⊆ standard_simplex (p::nat)›*) by auto
show "k ⊆ U a"
proof (clarify)
(*goal: ‹⋀x. x ∈ k ⟹ x ∈ U a›*)
fix y
assume "y ∈ k" (*‹(y::nat ⇒ real) ∈ (k::(nat ⇒ real) set)›*)
with k (*‹k ⊆ standard_simplex p›*) have y: "y ∈ standard_simplex p"
by blast
show "y ∈ U a"
proof (rule UI (*‹⟦?x ∈ standard_simplex p; ⋀i. i ≤ p ⟹ ¦?y i - ?x i¦ ≤ 2 * e ?x; ⋀i. p < i ⟹ ?y i = 0⟧ ⟹ ?y ∈ U ?x›*))
(*goals:
1. ‹(a::nat ⇒ real) ∈ standard_simplex (p::nat)›
2. ‹⋀i::nat. i ≤ (p::nat) ⟹ ¦(y::nat ⇒ real) i - (a::nat ⇒ real) i¦ ≤ (2::real) * (e::(nat ⇒ real) ⇒ real) a›
3. ‹⋀i::nat. (p::nat) < i ⟹ (y::nat ⇒ real) i = (0::real)›*)
show "a ∈ standard_simplex p"
using a (*‹a ∈ S›*) ssp(1) (*‹S ⊆ standard_simplex p›*) by auto
fix i :: nat
assume "i ≤ p" (*‹(i::nat) ≤ (p::nat)›*)
then have "¦x i - y i¦ ≤ e a"
by (meson kle [OF ‹i ≤ p›] (*‹⟦?x ∈ k; ?y ∈ k⟧ ⟹ ¦?x i - ?y i¦ ≤ Inf (e ` S)›*) a (*‹a ∈ S›*) ‹finite S› ‹x ∈ k› ‹y ∈ k› cInf_le_finite (*‹⟦finite ?X; ?x ∈ ?X⟧ ⟹ Inf ?X ≤ ?x›*) finite_imageI (*‹finite ?F ⟹ finite (?h ` ?F)›*) imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*))
then show "¦y i - a i¦ ≤ 2 * e a"
using le_ea[OF ‹i ≤ p›] (*‹¦x i - a i¦ < e a›*) by linarith
next
(*goal: ‹⋀i. p < i ⟹ y i = 0›*)
fix i
assume "p < i" (*‹(p::nat) < (i::nat)›*)
then show "y i = 0"
using standard_simplex_def (*‹standard_simplex (?p::nat) ≡ {x::nat ⇒ real. (∀i::nat. (0::real) ≤ x i ∧ x i ≤ (1::real)) ∧ (∀i>?p. x i = (0::real)) ∧ sum x {..?p} = (1::real)}›*) y (*‹y ∈ standard_simplex p›*) by auto
qed
qed
qed
qed
qed
qed
proposition sufficient_iterated_singular_subdivision_exists:
assumes 𝒞: "⋀U. U ∈ 𝒞 ⟹ openin X U"
and X: "topspace X ⊆ ⋃𝒞"
and p: "singular_chain p X c"
obtains n where "⋀m f. ⟦n ≤ m; f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ m) c)⟧
⟹ ∃V ∈ 𝒞. f ` (standard_simplex p) ⊆ V"
proof (cases "c = 0")
(*goals:
1. ‹⟦⋀n. (⋀m f. ⟦n ≤ m; f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ m) c)⟧ ⟹ ∃V∈𝒞. f ` standard_simplex p ⊆ V) ⟹ thesis; c = 0⟧ ⟹ thesis›
2. ‹⟦⋀n. (⋀m f. ⟦n ≤ m; f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ m) c)⟧ ⟹ ∃V∈𝒞. f ` standard_simplex p ⊆ V) ⟹ thesis; c ≠ 0⟧ ⟹ thesis›*)
case False (*‹c ≠ 0›*)
then show "?thesis"
(*goal: ‹thesis›*)
proof (cases "topspace X = {}")
(*goals:
1. ‹⟦c ≠ 0; topspace X = {}⟧ ⟹ thesis›
2. ‹⟦c ≠ 0; topspace X ≠ {}⟧ ⟹ thesis›*)
case True (*‹topspace (X::'a topology) = {}›*)
show "?thesis"
(*goal: ‹thesis::bool›*)
using p (*‹singular_chain p X c›*) that (*‹(⋀m f. ⟦?n ≤ m; f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ m) c)⟧ ⟹ ∃V∈𝒞. f ` standard_simplex p ⊆ V) ⟹ thesis›*) by (force simp: singular_chain_empty (*‹topspace ?X = {} ⟹ singular_chain ?p ?X ?c = (?c = 0)›*) True (*‹topspace X = {}›*))
next
(*goal: ‹⟦c ≠ 0; topspace X ≠ {}⟧ ⟹ thesis›*)
case False (*‹topspace X ≠ {}›*)
show "?thesis"
(*goal: ‹thesis›*)
proof (cases "𝒞 = {}")
(*goals:
1. ‹(𝒞::'a set set) = {} ⟹ thesis::bool›
2. ‹(𝒞::'a set set) ≠ {} ⟹ thesis::bool›*)
case True (*‹𝒞 = {}›*)
then show "?thesis"
(*goal: ‹thesis::bool›*)
using False (*‹topspace X ≠ {}›*) X (*‹topspace X ⊆ ⋃ 𝒞›*) by blast
next
(*goal: ‹(𝒞::'a set set) ≠ {} ⟹ thesis::bool›*)
case False (*‹𝒞 ≠ {}›*)
have "∃e. 0 < e ∧
(∀K. K ⊆ standard_simplex p ⟶ (∀x y i. x ∈ K ∧ y ∈ K ∧ i ≤ p ⟶ ¦x i - y i¦ ≤ e)
⟶ (∃V. V ∈ 𝒞 ∧ f ` K ⊆ V))" if f: "f ∈ Poly_Mapping.keys c" for f
proof (-)
(*goal: ‹∃e>0::real. ∀K⊆standard_simplex (p::nat). (∀(x::nat ⇒ real) (y::nat ⇒ real) i::nat. x ∈ K ∧ y ∈ K ∧ i ≤ p ⟶ ¦x i - y i¦ ≤ e) ⟶ (∃V::'a set. V ∈ (𝒞::'a set set) ∧ (f::(nat ⇒ real) ⇒ 'a) ` K ⊆ V)›*)
have ssf: "singular_simplex p X f"
using f (*‹(f::(nat ⇒ real) ⇒ 'a) ∈ Poly_Mapping.keys (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*) p (*‹singular_chain (p::nat) (X::'a::type topology) (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)›*) by (auto simp: singular_chain_def (*‹singular_chain (?p::nat) (?X::?'a topology) (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ≡ Poly_Mapping.keys ?c ⊆ singular_simplex_set ?p ?X›*))
then have fp: "⋀x. x ∈ standard_simplex p ⟹ f x ∈ topspace X"
by (auto simp: singular_simplex_def (*‹singular_simplex (?p::nat) (?X::?'a topology) (?f::(nat ⇒ real) ⇒ ?'a) ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*) image_subset_iff (*‹((?f::?'b ⇒ ?'a) ` (?A::?'b set) ⊆ (?B::?'a set)) = (∀x::?'b∈?A. ?f x ∈ ?B)›*) dest: continuous_map_image_subset_topspace (*‹continuous_map (?X::?'a topology) (?Y::?'b topology) (?f::?'a ⇒ ?'b) ⟹ ?f ` topspace ?X ⊆ topspace ?Y›*))
have "∃T. openin (powertop_real UNIV) T ∧
standard_simplex p ∩ f -` V = T ∩ standard_simplex p" if V: "V ∈ 𝒞" for V
proof (-)
(*goal: ‹∃T. openin (powertop_real UNIV) T ∧ standard_simplex p ∩ f -` V = T ∩ standard_simplex p›*)
have "singular_simplex p X f"
using p (*‹singular_chain p X c›*) f (*‹f ∈ Poly_Mapping.keys c›*) unfolding singular_chain_def
(*goal: ‹singular_simplex p X f›*)
by blast
then have "openin (subtopology (powertop_real UNIV) (standard_simplex p))
{x ∈ standard_simplex p. f x ∈ V}"
using "𝒞"[OF ‹V ∈ 𝒞›] (*‹openin X V›*) by (simp add: singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*) continuous_map_def (*‹continuous_map ?X ?Y ?f ≡ ?f ∈ topspace ?X → topspace ?Y ∧ (∀U. openin ?Y U ⟶ openin ?X {x ∈ topspace ?X. ?f x ∈ U})›*))
moreover have "standard_simplex p ∩ f -` V = {x ∈ standard_simplex p. f x ∈ V}"
by blast
ultimately show "?thesis"
(*goal: ‹∃T. openin (powertop_real UNIV) T ∧ standard_simplex p ∩ f -` V = T ∩ standard_simplex p›*)
by (simp add: openin_subtopology (*‹openin (subtopology ?U ?V) ?S = (∃T. openin ?U T ∧ ?S = T ∩ ?V)›*))
qed
then obtain g where gope: "⋀V. V ∈ 𝒞 ⟹ openin (powertop_real UNIV) (g V)" and geq: "⋀V. V ∈ 𝒞 ⟹ standard_simplex p ∩ f -` V = g V ∩ standard_simplex p"
(*goal: ‹(⋀g. ⟦⋀V. V ∈ 𝒞 ⟹ openin (powertop_real UNIV) (g V); ⋀V. V ∈ 𝒞 ⟹ standard_simplex p ∩ f -` V = g V ∩ standard_simplex p⟧ ⟹ thesis) ⟹ thesis›*)
by metis
obtain d where "0 < d" and d: "⋀K. ⟦K ⊆ standard_simplex p; ⋀x y i. ⟦i ≤ p; x ∈ K; y ∈ K⟧ ⟹ ¦x i - y i¦ ≤ d⟧
⟹ ∃U. U ∈ g ` 𝒞 ∧ K ⊆ U"
(*goal: ‹(⋀d. ⟦0 < d; ⋀K. ⟦K ⊆ standard_simplex p; ⋀x y i. ⟦i ≤ p; x ∈ K; y ∈ K⟧ ⟹ ¦x i - y i¦ ≤ d⟧ ⟹ ∃U. U ∈ g ` 𝒞 ∧ K ⊆ U⟧ ⟹ thesis) ⟹ thesis›*)
proof (rule llemma [of p "g ` 𝒞"] (*‹⟦standard_simplex p ⊆ ⋃ (g ` 𝒞); ⋀U. U ∈ g ` 𝒞 ⟹ openin (powertop_real UNIV) U; ⋀d. ⟦0 < d; ⋀K. ⟦K ⊆ standard_simplex p; ⋀x y i. ⟦i ≤ p; x ∈ K; y ∈ K⟧ ⟹ ¦x i - y i¦ ≤ d⟧ ⟹ ∃U. U ∈ g ` 𝒞 ∧ K ⊆ U⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹(⋀d. ⟦0 < d; ⋀K. ⟦K ⊆ standard_simplex p; ⋀x y i. ⟦i ≤ p; x ∈ K; y ∈ K⟧ ⟹ ¦x i - y i¦ ≤ d⟧ ⟹ ∃U. U ∈ g ` 𝒞 ∧ K ⊆ U⟧ ⟹ thesis) ⟹ standard_simplex p ⊆ ⋃ (g ` 𝒞)›
2. ‹⋀U. ⟦⋀d. ⟦0 < d; ⋀K. ⟦K ⊆ standard_simplex p; ⋀x y i. ⟦i ≤ p; x ∈ K; y ∈ K⟧ ⟹ ¦x i - y i¦ ≤ d⟧ ⟹ ∃U. U ∈ g ` 𝒞 ∧ K ⊆ U⟧ ⟹ thesis; U ∈ g ` 𝒞⟧ ⟹ openin (powertop_real UNIV) U›
3. ‹⋀d. ⟦⋀d. ⟦0 < d; ⋀K. ⟦K ⊆ standard_simplex p; ⋀x y i. ⟦i ≤ p; x ∈ K; y ∈ K⟧ ⟹ ¦x i - y i¦ ≤ d⟧ ⟹ ∃U. U ∈ g ` 𝒞 ∧ K ⊆ U⟧ ⟹ thesis; 0 < d; ⋀K. ⟦K ⊆ standard_simplex p; ⋀x y i. ⟦i ≤ p; x ∈ K; y ∈ K⟧ ⟹ ¦x i - y i¦ ≤ d⟧ ⟹ ∃U. U ∈ g ` 𝒞 ∧ K ⊆ U⟧ ⟹ thesis›*)
show "standard_simplex p ⊆ ⋃(g ` 𝒞)"
using geq (*‹?V ∈ 𝒞 ⟹ standard_simplex p ∩ f -` ?V = g ?V ∩ standard_simplex p›*) X (*‹topspace X ⊆ ⋃ 𝒞›*) fp (*‹?x ∈ standard_simplex p ⟹ f ?x ∈ topspace X›*) by (fastforce simp add:)
show "openin (powertop_real UNIV) U" if "U ∈ g ` 𝒞" for U :: "(nat ⇒ real) set"
using gope (*‹?V ∈ 𝒞 ⟹ openin (powertop_real UNIV) (g ?V)›*) that (*‹U ∈ g ` 𝒞›*) by blast
qed (auto)
(*solved the remaining goal: ‹⋀d. ⟦⋀d. ⟦0 < d; ⋀K. ⟦K ⊆ standard_simplex p; ⋀x y i. ⟦i ≤ p; x ∈ K; y ∈ K⟧ ⟹ ¦x i - y i¦ ≤ d⟧ ⟹ ∃U. U ∈ g ` 𝒞 ∧ K ⊆ U⟧ ⟹ thesis; 0 < d; ⋀K. ⟦K ⊆ standard_simplex p; ⋀x y i. ⟦i ≤ p; x ∈ K; y ∈ K⟧ ⟹ ¦x i - y i¦ ≤ d⟧ ⟹ ∃U. U ∈ g ` 𝒞 ∧ K ⊆ U⟧ ⟹ thesis›*)
show "?thesis"
(*goal: ‹∃e>0. ∀K⊆standard_simplex p. (∀x y i. x ∈ K ∧ y ∈ K ∧ i ≤ p ⟶ ¦x i - y i¦ ≤ e) ⟶ (∃V. V ∈ 𝒞 ∧ f ` K ⊆ V)›*)
proof (rule exI (*‹?P ?x ⟹ ∃x. ?P x›*), intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goals:
1. ‹(0::real) < (?e::real)›
2. ‹⋀K::(nat ⇒ real) set. ⟦K ⊆ standard_simplex (p::nat); ∀(x::nat ⇒ real) (y::nat ⇒ real) i::nat. x ∈ K ∧ y ∈ K ∧ i ≤ p ⟶ ¦x i - y i¦ ≤ (?e::real)⟧ ⟹ ∃V::'a set. V ∈ (𝒞::'a set set) ∧ (f::(nat ⇒ real) ⇒ 'a) ` K ⊆ V›*)
fix K :: "(nat ⇒ real) set"
assume K: "K ⊆ standard_simplex p" and Kd: "∀x y i. x ∈ K ∧ y ∈ K ∧ i ≤ p ⟶ ¦x i - y i¦ ≤ d" (*‹(K::(nat ⇒ real) set) ⊆ standard_simplex (p::nat)› ‹∀(x::nat ⇒ real) (y::nat ⇒ real) i::nat. x ∈ (K::(nat ⇒ real) set) ∧ y ∈ K ∧ i ≤ (p::nat) ⟶ ¦x i - y i¦ ≤ (d::real)›*)
then have "∃U. U ∈ g ` 𝒞 ∧ K ⊆ U"
using d[OF K] (*‹(⋀x y i. ⟦i ≤ p; x ∈ K; y ∈ K⟧ ⟹ ¦x i - y i¦ ≤ d) ⟹ ∃U. U ∈ g ` 𝒞 ∧ K ⊆ U›*) by auto
then show "∃V. V ∈ 𝒞 ∧ f ` K ⊆ V"
using K (*‹K ⊆ standard_simplex p›*) geq (*‹?V ∈ 𝒞 ⟹ standard_simplex p ∩ f -` ?V = g ?V ∩ standard_simplex p›*) by fastforce
qed (rule ‹d > 0›)
(*solved the remaining goal: ‹0 < d›*)
qed
then obtain ψ where epos: "∀f ∈ Poly_Mapping.keys c. 0 < ψ f" and e: "⋀f K. ⟦f ∈ Poly_Mapping.keys c; K ⊆ standard_simplex p;
⋀x y i. x ∈ K ∧ y ∈ K ∧ i ≤ p ⟹ ¦x i - y i¦ ≤ ψ f⟧
⟹ ∃V. V ∈ 𝒞 ∧ f ` K ⊆ V"
(*goal: ‹(⋀ψ. ⟦∀f∈Poly_Mapping.keys c. 0 < ψ f; ⋀f K. ⟦f ∈ Poly_Mapping.keys c; K ⊆ standard_simplex p; ⋀x y i. x ∈ K ∧ y ∈ K ∧ i ≤ p ⟹ ¦x i - y i¦ ≤ ψ f⟧ ⟹ ∃V. V ∈ 𝒞 ∧ f ` K ⊆ V⟧ ⟹ thesis) ⟹ thesis›*)
by metis
obtain d where "0 < d" and d: "⋀f K. ⟦f ∈ Poly_Mapping.keys c; K ⊆ standard_simplex p;
⋀x y i. ⟦x ∈ K; y ∈ K; i ≤ p⟧ ⟹ ¦x i - y i¦ ≤ d⟧
⟹ ∃V. V ∈ 𝒞 ∧ f ` K ⊆ V"
(*goal: ‹(⋀d. ⟦0 < d; ⋀f K. ⟦f ∈ Poly_Mapping.keys c; K ⊆ standard_simplex p; ⋀x y i. ⟦x ∈ K; y ∈ K; i ≤ p⟧ ⟹ ¦x i - y i¦ ≤ d⟧ ⟹ ∃V. V ∈ 𝒞 ∧ f ` K ⊆ V⟧ ⟹ thesis) ⟹ thesis›*)
proof (standard)
(*goals:
1. ‹(⋀d. ⟦0 < d; ⋀f K. ⟦f ∈ Poly_Mapping.keys c; K ⊆ standard_simplex p; ⋀x y i. ⟦x ∈ K; y ∈ K; i ≤ p⟧ ⟹ ¦x i - y i¦ ≤ d⟧ ⟹ ∃V. V ∈ 𝒞 ∧ f ` K ⊆ V⟧ ⟹ thesis) ⟹ 0 < ?d2›
2. ‹⋀f K. ⟦⋀d. ⟦0 < d; ⋀f K. ⟦f ∈ Poly_Mapping.keys c; K ⊆ standard_simplex p; ⋀x y i. ⟦x ∈ K; y ∈ K; i ≤ p⟧ ⟹ ¦x i - y i¦ ≤ d⟧ ⟹ ∃V. V ∈ 𝒞 ∧ f ` K ⊆ V⟧ ⟹ thesis; f ∈ Poly_Mapping.keys c; K ⊆ standard_simplex p; ⋀x y i. ⟦x ∈ K; y ∈ K; i ≤ p⟧ ⟹ ¦x i - y i¦ ≤ ?d2⟧ ⟹ ∃V. V ∈ 𝒞 ∧ f ` K ⊆ V›*)
show "Inf (ψ ` Poly_Mapping.keys c) > 0"
by (simp add: finite_less_Inf_iff (*‹⟦finite ?X; ?X ≠ {}⟧ ⟹ (?a < Inf ?X) = (∀x∈?X. ?a < x)›*) ‹c ≠ 0› epos (*‹∀f∈Poly_Mapping.keys c. 0 < ψ f›*))
fix f and K
assume fK: "f ∈ Poly_Mapping.keys c" "K ⊆ standard_simplex p" and le: "⋀x y i. ⟦x ∈ K; y ∈ K; i ≤ p⟧ ⟹ ¦x i - y i¦ ≤ Inf (ψ ` Poly_Mapping.keys c)" (*‹(f::(nat ⇒ real) ⇒ 'a) ∈ Poly_Mapping.keys (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)› ‹(K::(nat ⇒ real) set) ⊆ standard_simplex (p::nat)› ‹⟦(?x::nat ⇒ real) ∈ (K::(nat ⇒ real) set); (?y::nat ⇒ real) ∈ K; (?i::nat) ≤ (p::nat)⟧ ⟹ ¦?x ?i - ?y ?i¦ ≤ Inf ((ψ::((nat ⇒ real) ⇒ 'a) ⇒ real) ` Poly_Mapping.keys (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int))›*)
then have lef: "Inf (ψ ` Poly_Mapping.keys c) ≤ ψ f"
by (auto intro: cInf_le_finite (*‹⟦finite ?X; ?x ∈ ?X⟧ ⟹ Inf ?X ≤ ?x›*))
show "∃V. V ∈ 𝒞 ∧ f ` K ⊆ V"
using le (*‹⟦?x ∈ K; ?y ∈ K; ?i ≤ p⟧ ⟹ ¦?x ?i - ?y ?i¦ ≤ Inf (ψ ` Poly_Mapping.keys c)›*) lef (*‹Inf ((ψ::((nat ⇒ real) ⇒ 'a::type) ⇒ real) ` Poly_Mapping.keys (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)) ≤ ψ (f::(nat ⇒ real) ⇒ 'a::type)›*) by (blast intro: dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) e [OF fK] (*‹(⋀x y i. x ∈ K ∧ y ∈ K ∧ i ≤ p ⟹ ¦x i - y i¦ ≤ ψ f) ⟹ ∃V. V ∈ 𝒞 ∧ f ` K ⊆ V›*))
qed
let ?d = "λm. (simplicial_subdivision p ^^ m) (frag_of (restrict id (standard_simplex p)))"
obtain n where n: "(p / (Suc p)) ^ n < d"
(*goal: ‹(⋀n. (real p / real (Suc p)) ^ n < d ⟹ thesis) ⟹ thesis›*)
using real_arch_pow_inv (*‹⟦0 < ?y; ?x < 1⟧ ⟹ ∃n. ?x ^ n < ?y›*) ‹0 < d› (*‹0 < d›*) by fastforce
show "?thesis"
(*goal: ‹thesis›*)
proof (standard)
(*goal: ‹⋀m f. ⟦?n ≤ m; f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ m) c)⟧ ⟹ ∃V∈𝒞. f ` standard_simplex p ⊆ V›*)
fix m and h
assume "n ≤ m" and "h ∈ Poly_Mapping.keys ((singular_subdivision p ^^ m) c)" (*‹(n::nat) ≤ (m::nat)› ‹(h::(nat ⇒ real) ⇒ 'a) ∈ Poly_Mapping.keys ((singular_subdivision (p::nat) ^^ (m::nat)) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int))›*)
then obtain f where "f ∈ Poly_Mapping.keys c" "h ∈ Poly_Mapping.keys (chain_map p f (?d m))"
(*goal: ‹(⋀f::(nat ⇒ real) ⇒ 'a::type. ⟦f ∈ Poly_Mapping.keys (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int); (h::(nat ⇒ real) ⇒ 'a::type) ∈ Poly_Mapping.keys (chain_map (p::nat) f ((simplicial_subdivision p ^^ (m::nat)) (frag_of (restrict id (standard_simplex p)))))⟧ ⟹ thesis::bool) ⟹ thesis›*)
using subsetD[OF keys_frag_extend] (*‹?c ∈ Poly_Mapping.keys (frag_extend ?f1 ?c1) ⟹ ?c ∈ (⋃x∈Poly_Mapping.keys ?c1. Poly_Mapping.keys (?f1 x))›*) iterated_singular_subdivision[OF p, of m] (*‹(singular_subdivision p ^^ m) c = frag_extend (λf. chain_map p f ((simplicial_subdivision p ^^ m) (frag_of (restrict id (standard_simplex p))))) c›*) by force
then obtain g where g: "g ∈ Poly_Mapping.keys (?d m)" and heq: "h = restrict (f ∘ g) (standard_simplex p)"
(*goal: ‹(⋀g. ⟦g ∈ Poly_Mapping.keys ((simplicial_subdivision p ^^ m) (frag_of (restrict id (standard_simplex p)))); h = restrict (f ∘ g) (standard_simplex p)⟧ ⟹ thesis) ⟹ thesis›*)
using keys_frag_extend (*‹Poly_Mapping.keys (frag_extend ?f ?c) ⊆ (⋃x∈Poly_Mapping.keys ?c. Poly_Mapping.keys (?f x))›*) by (force simp: chain_map_def (*‹chain_map ?p ?g ?c ≡ frag_extend (frag_of ∘ simplex_map ?p ?g) ?c›*) simplex_map_def (*‹simplex_map ?p ?g ?c ≡ restrict (?g ∘ ?c) (standard_simplex ?p)›*))
have xx: "simplicial_chain p (standard_simplex p) (?d n) ∧
(∀f ∈ Poly_Mapping.keys(?d n). ∀x ∈ standard_simplex p. ∀y ∈ standard_simplex p.
¦f x i - f y i¦ ≤ (p / (Suc p)) ^ n)" for n and i
proof (induction n)
(*goals:
1. ‹simplicial_chain (p::nat) (standard_simplex p) ((simplicial_subdivision p ^^ (0::nat)) (frag_of (restrict id (standard_simplex p)))) ∧ (∀f::(nat ⇒ real) ⇒ nat ⇒ real∈Poly_Mapping.keys ((simplicial_subdivision p ^^ (0::nat)) (frag_of (restrict id (standard_simplex p)))). ∀x::nat ⇒ real∈standard_simplex p. ∀y::nat ⇒ real∈standard_simplex p. ¦f x (i::nat) - f y i¦ ≤ (real p / real (Suc p)) ^ (0::nat))›
2. ‹⋀n::nat. simplicial_chain (p::nat) (standard_simplex p) ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p)))) ∧ (∀f::(nat ⇒ real) ⇒ nat ⇒ real∈Poly_Mapping.keys ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p)))). ∀x::nat ⇒ real∈standard_simplex p. ∀y::nat ⇒ real∈standard_simplex p. ¦f x (i::nat) - f y i¦ ≤ (real p / real (Suc p)) ^ n) ⟹ simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p)))) ∧ (∀f::(nat ⇒ real) ⇒ nat ⇒ real∈Poly_Mapping.keys ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p)))). ∀x::nat ⇒ real∈standard_simplex p. ∀y::nat ⇒ real∈standard_simplex p. ¦f x i - f y i¦ ≤ (real p / real (Suc p)) ^ Suc n)›*)
case 0 (*no hyothesis introduced yet*)
have "simplicial_simplex p (standard_simplex p) (λa∈standard_simplex p. a)"
by (metis eq_id_iff (*‹(∀x. ?f x = x) = (?f = id)›*) order_refl (*‹?x ≤ ?x›*) simplicial_simplex_id (*‹simplicial_simplex ?p ?S (restrict id (standard_simplex ?p)) = (standard_simplex ?p ⊆ ?S)›*))
moreover have "(∀x∈standard_simplex p. ∀y∈standard_simplex p. ¦x i - y i¦ ≤ 1)"
unfolding standard_simplex_def
(*goal: ‹∀x∈{x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>p. x i = 0) ∧ sum x {..p} = 1}. ∀y∈{x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>p. x i = 0) ∧ sum x {..p} = 1}. ¦x i - y i¦ ≤ 1›*)
by (auto simp: abs_if (*‹¦?a::?'a¦ = (if ?a < (0::?'a) then - ?a else ?a)›*) dest!: spec [where x=i] (*‹∀x::nat. (?P::nat ⇒ bool) x ⟹ ?P (i::nat)›*))
ultimately show "?case"
(*goal: ‹simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p)))) ∧ (∀f∈Poly_Mapping.keys ((simplicial_subdivision p ^^ 0) (frag_of (restrict id (standard_simplex p)))). ∀x∈standard_simplex p. ∀y∈standard_simplex p. ¦f x i - f y i¦ ≤ (real p / real (Suc p)) ^ 0)›*)
unfolding power_0 funpow_0
(*goal: ‹simplicial_chain p (standard_simplex p) (frag_of (restrict id (standard_simplex p))) ∧ (∀f∈Poly_Mapping.keys (frag_of (restrict id (standard_simplex p))). ∀x∈standard_simplex p. ∀y∈standard_simplex p. ¦f x i - f y i¦ ≤ 1)›*)
by simp
next
(*goal: ‹⋀n. simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p)))) ∧ (∀f∈Poly_Mapping.keys ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p)))). ∀x∈standard_simplex p. ∀y∈standard_simplex p. ¦f x i - f y i¦ ≤ (real p / real (Suc p)) ^ n) ⟹ simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p)))) ∧ (∀f∈Poly_Mapping.keys ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p)))). ∀x∈standard_simplex p. ∀y∈standard_simplex p. ¦f x i - f y i¦ ≤ (real p / real (Suc p)) ^ Suc n)›*)
case (Suc n) (*‹simplicial_chain (p::nat) (standard_simplex p) ((simplicial_subdivision p ^^ (n::nat)) (frag_of (restrict id (standard_simplex p)))) ∧ (∀f::(nat ⇒ real) ⇒ nat ⇒ real∈Poly_Mapping.keys ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p)))). ∀x::nat ⇒ real∈standard_simplex p. ∀y::nat ⇒ real∈standard_simplex p. ¦f x (i::nat) - f y i¦ ≤ (real p / real (Suc p)) ^ n)›*)
show "?case"
(*goal: ‹simplicial_chain p (standard_simplex p) ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p)))) ∧ (∀f∈Poly_Mapping.keys ((simplicial_subdivision p ^^ Suc n) (frag_of (restrict id (standard_simplex p)))). ∀x∈standard_simplex p. ∀y∈standard_simplex p. ¦f x i - f y i¦ ≤ (real p / real (Suc p)) ^ Suc n)›*)
unfolding power_Suc funpow.simps o_def
(*goal: ‹simplicial_chain p (standard_simplex p) (simplicial_subdivision p ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p))))) ∧ (∀f∈Poly_Mapping.keys (simplicial_subdivision p ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p))))). ∀x∈standard_simplex p. ∀y∈standard_simplex p. ¦f x i - f y i¦ ≤ real p / real (Suc p) * (real p / real (Suc p)) ^ n)›*)
proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*))
(*goals:
1. ‹simplicial_chain p (standard_simplex p) (simplicial_subdivision p ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p)))))›
2. ‹⋀f x y. ⟦f ∈ Poly_Mapping.keys (simplicial_subdivision p ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p))))); x ∈ standard_simplex p; y ∈ standard_simplex p⟧ ⟹ ¦f x i - f y i¦ ≤ real p / real (Suc p) * (real p / real (Suc p)) ^ n›*)
show "simplicial_chain p (standard_simplex p) (simplicial_subdivision p (?d n))"
by (simp add: Suc (*‹simplicial_chain (p::nat) (standard_simplex p) ((simplicial_subdivision p ^^ (n::nat)) (frag_of (restrict id (standard_simplex p)))) ∧ (∀f::(nat ⇒ real) ⇒ nat ⇒ real∈Poly_Mapping.keys ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p)))). ∀x::nat ⇒ real∈standard_simplex p. ∀y::nat ⇒ real∈standard_simplex p. ¦f x (i::nat) - f y i¦ ≤ (real p / real (Suc p)) ^ n)›*) simplicial_chain_simplicial_subdivision (*‹simplicial_chain (?p::nat) (?S::(nat ⇒ real) set) (?c::((nat ⇒ real) ⇒ nat ⇒ real) ⇒₀ int) ⟹ simplicial_chain ?p ?S (simplicial_subdivision ?p ?c)›*))
show "¦f x i - f y i¦ ≤ real p / real (Suc p) * (real p / real (Suc p)) ^ n" if "f ∈ Poly_Mapping.keys (simplicial_subdivision p (?d n))" and "x ∈ standard_simplex p" and "y ∈ standard_simplex p" for f and x and y
using Suc (*‹simplicial_chain (p::nat) (standard_simplex p) ((simplicial_subdivision p ^^ (n::nat)) (frag_of (restrict id (standard_simplex p)))) ∧ (∀f::(nat ⇒ real) ⇒ nat ⇒ real∈Poly_Mapping.keys ((simplicial_subdivision p ^^ n) (frag_of (restrict id (standard_simplex p)))). ∀x::nat ⇒ real∈standard_simplex p. ∀y::nat ⇒ real∈standard_simplex p. ¦f x (i::nat) - f y i¦ ≤ (real p / real (Suc p)) ^ n)›*) that (*‹(f::(nat ⇒ real) ⇒ nat ⇒ real) ∈ Poly_Mapping.keys (simplicial_subdivision (p::nat) ((simplicial_subdivision p ^^ (n::nat)) (frag_of (restrict id (standard_simplex p)))))› ‹x ∈ standard_simplex p› ‹y ∈ standard_simplex p›*) by (blast intro: simplicial_subdivision_shrinks (*‹⟦simplicial_chain ?p ?S ?c; ⋀f x y. ⟦f ∈ Poly_Mapping.keys ?c; x ∈ standard_simplex ?p; y ∈ standard_simplex ?p⟧ ⟹ ¦f x ?k - f y ?k¦ ≤ ?d; ?f ∈ Poly_Mapping.keys (simplicial_subdivision ?p ?c); ?x ∈ standard_simplex ?p; ?y ∈ standard_simplex ?p⟧ ⟹ ¦?f ?x ?k - ?f ?y ?k¦ ≤ real ?p / real (Suc ?p) * ?d›*))
qed
qed
have "g ` standard_simplex p ⊆ standard_simplex p"
using g (*‹(g::(nat ⇒ real) ⇒ nat ⇒ real) ∈ Poly_Mapping.keys ((simplicial_subdivision (p::nat) ^^ (m::nat)) (frag_of (restrict id (standard_simplex p))))›*) xx[of m] (*‹simplicial_chain (p::nat) (standard_simplex p) ((simplicial_subdivision p ^^ (m::nat)) (frag_of (restrict id (standard_simplex p)))) ∧ (∀f::(nat ⇒ real) ⇒ nat ⇒ real∈Poly_Mapping.keys ((simplicial_subdivision p ^^ m) (frag_of (restrict id (standard_simplex p)))). ∀x::nat ⇒ real∈standard_simplex p. ∀y::nat ⇒ real∈standard_simplex p. ¦f x (?i::nat) - f y ?i¦ ≤ (real p / real (Suc p)) ^ m)›*) unfolding simplicial_chain_def simplicial_simplex
(*goal: ‹g ` standard_simplex p ⊆ standard_simplex p›*)
by auto
moreover have "¦g x i - g y i¦ ≤ d" if "i ≤ p" "x ∈ standard_simplex p" "y ∈ standard_simplex p" for x and y and i
proof (-)
(*goal: ‹¦g x i - g y i¦ ≤ d›*)
have "¦g x i - g y i¦ ≤ (p / (Suc p)) ^ m"
using g (*‹g ∈ Poly_Mapping.keys ((simplicial_subdivision p ^^ m) (frag_of (restrict id (standard_simplex p))))›*) xx[of m] (*‹simplicial_chain (p::nat) (standard_simplex p) ((simplicial_subdivision p ^^ (m::nat)) (frag_of (restrict id (standard_simplex p)))) ∧ (∀f::(nat ⇒ real) ⇒ nat ⇒ real∈Poly_Mapping.keys ((simplicial_subdivision p ^^ m) (frag_of (restrict id (standard_simplex p)))). ∀x::nat ⇒ real∈standard_simplex p. ∀y::nat ⇒ real∈standard_simplex p. ¦f x (?i::nat) - f y ?i¦ ≤ (real p / real (Suc p)) ^ m)›*) that (*‹i ≤ p› ‹x ∈ standard_simplex p› ‹(y::nat ⇒ real) ∈ standard_simplex (p::nat)›*) by blast
also (*calculation: ‹¦g x i - g y i¦ ≤ (real p / real (Suc p)) ^ m›*) have "… ≤ (p / (Suc p)) ^ n"
by (auto intro: power_decreasing [OF ‹n ≤ m›] (*‹⟦0 ≤ ?a; ?a ≤ 1⟧ ⟹ ?a ^ m ≤ ?a ^ n›*))
finally (*calculation: ‹¦g x i - g y i¦ ≤ (real p / real (Suc p)) ^ n›*) show "?thesis"
(*goal: ‹¦g x i - g y i¦ ≤ d›*)
using n (*‹(real p / real (Suc p)) ^ n < d›*) by simp
qed
then have "¦x i - y i¦ ≤ d" if "x ∈ g ` (standard_simplex p)" "y ∈ g ` (standard_simplex p)" "i ≤ p" for i and x and y
using that (*‹x ∈ g ` standard_simplex p› ‹y ∈ g ` standard_simplex p› ‹(i::nat) ≤ (p::nat)›*) by blast
ultimately show "∃V∈𝒞. h ` standard_simplex p ⊆ V"
using ‹f ∈ Poly_Mapping.keys c› (*‹(f::(nat ⇒ real) ⇒ 'a) ∈ Poly_Mapping.keys (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*) d[of f "g ` standard_simplex p"] (*‹⟦f ∈ Poly_Mapping.keys c; g ` standard_simplex p ⊆ standard_simplex p; ⋀x y i. ⟦x ∈ g ` standard_simplex p; y ∈ g ` standard_simplex p; i ≤ p⟧ ⟹ ¦x i - y i¦ ≤ d⟧ ⟹ ∃V. V ∈ 𝒞 ∧ f ` g ` standard_simplex p ⊆ V›*) by (simp add: Bex_def (*‹Bex ?A ?P = (∃x. x ∈ ?A ∧ ?P x)›*) heq (*‹h = restrict (f ∘ g) (standard_simplex p)›*) image_image (*‹?f ` ?g ` ?A = (λx. ?f (?g x)) ` ?A›*))
qed
qed
qed
qed (force)
(*solved the remaining goal: ‹⟦⋀n. (⋀m f. ⟦n ≤ m; f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ m) c)⟧ ⟹ ∃V∈𝒞. f ` standard_simplex p ⊆ V) ⟹ thesis; c = 0⟧ ⟹ thesis›*)
lemma small_homologous_rel_relcycle_exists:
assumes 𝒞: "⋀U. U ∈ 𝒞 ⟹ openin X U"
and X: "topspace X ⊆ ⋃𝒞"
and p: "singular_relcycle p X S c"
obtains c' where "singular_relcycle p X S c'" "homologous_rel p X S c c'"
"⋀f. f ∈ Poly_Mapping.keys c' ⟹ ∃V ∈ 𝒞. f ` (standard_simplex p) ⊆ V"
proof (-)
(*goal: ‹(⋀c'. ⟦singular_relcycle p X S c'; homologous_rel p X S c c'; ⋀f. f ∈ Poly_Mapping.keys c' ⟹ ∃V∈𝒞. f ` standard_simplex p ⊆ V⟧ ⟹ thesis) ⟹ thesis›*)
have "singular_chain p X c" "(chain_boundary p c, 0) ∈ (mod_subset (p - Suc 0) (subtopology X S))"
using p (*‹singular_relcycle (p::nat) (X::'a::type topology) (S::'a::type set) (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)›*) unfolding singular_relcycle_def
(*goals:
1. ‹singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›
2. ‹(chain_boundary (p::nat) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int), 0::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ∈ mod_subset (p - Suc (0::nat)) (subtopology (X::'a topology) (S::'a set))›*)
apply -
(*goals:
1. ‹singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ∧ (chain_boundary p c, 0::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ∈ mod_subset (p - (1::nat)) (subtopology X (S::'a set)) ⟹ singular_chain p X c›
2. ‹singular_chain (p::nat) (X::'a topology) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ∧ (chain_boundary p c, 0::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ∈ mod_subset (p - (1::nat)) (subtopology X (S::'a set)) ⟹ (chain_boundary p c, 0::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ∈ mod_subset (p - Suc (0::nat)) (subtopology X S)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
then obtain n where n: "⋀m f. ⟦n ≤ m; f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ m) c)⟧
⟹ ∃V ∈ 𝒞. f ` (standard_simplex p) ⊆ V"
(*goal: ‹(⋀n. (⋀m f. ⟦n ≤ m; f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ m) c)⟧ ⟹ ∃V∈𝒞. f ` standard_simplex p ⊆ V) ⟹ thesis) ⟹ thesis›*)
by (blast intro: sufficient_iterated_singular_subdivision_exists [OF 𝒞 X] (*‹⟦⋀U. U ∈ 𝒞 ⟹ U ∈ 𝒞; singular_chain ?p X ?c; ⋀n. (⋀m f. ⟦n ≤ m; f ∈ Poly_Mapping.keys ((singular_subdivision ?p ^^ m) ?c)⟧ ⟹ ∃V∈𝒞. f ` standard_simplex ?p ⊆ V) ⟹ ?thesis⟧ ⟹ ?thesis›*))
let ?c' = "(singular_subdivision p ^^ n) c"
show "?thesis"
(*goal: ‹thesis›*)
proof (standard)
(*goals:
1. ‹singular_relcycle p X S ?c'›
2. ‹homologous_rel p X S c ?c'›
3. ‹⋀f. f ∈ Poly_Mapping.keys ?c' ⟹ ∃V∈𝒞. f ` standard_simplex p ⊆ V›*)
show "homologous_rel p X S c ?c'"
proof (induction n)
(*goals:
1. ‹homologous_rel p X S c ((singular_subdivision p ^^ 0) c)›
2. ‹⋀n. homologous_rel p X S c ((singular_subdivision p ^^ n) c) ⟹ homologous_rel p X S c ((singular_subdivision p ^^ Suc n) c)›*)
case 0 (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹homologous_rel p X S c ((singular_subdivision p ^^ 0) c)›*)
by auto
next
(*goal: ‹⋀n. homologous_rel p X S c ((singular_subdivision p ^^ n) c) ⟹ homologous_rel p X S c ((singular_subdivision p ^^ Suc n) c)›*)
case (Suc n) (*‹homologous_rel (p::nat) (X::'a topology) (S::'a set) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ((singular_subdivision p ^^ (n::nat)) c)›*)
then show "?case"
(*goal: ‹homologous_rel p X S c ((singular_subdivision p ^^ Suc n) c)›*)
apply simp
(*goal: ‹homologous_rel p X S c ((singular_subdivision p ^^ Suc n) c)›*)
by (metis homologous_rel_eq (*‹(homologous_rel ?p ?X ?S ?a = homologous_rel ?p ?X ?S ?b) = homologous_rel ?p ?X ?S ?a ?b›*) p (*‹singular_relcycle p X S c›*) homologous_rel_singular_subdivision (*‹singular_relcycle ?p ?X ?T ?c ⟹ homologous_rel ?p ?X ?T (singular_subdivision ?p ?c) ?c›*) homologous_rel_singular_relcycle (*‹homologous_rel ?p ?X ?S ?c1.0 ?c2.0 ⟹ singular_relcycle ?p ?X ?S ?c1.0 = singular_relcycle ?p ?X ?S ?c2.0›*))
qed
then show "singular_relcycle p X S ?c'"
by (metis homologous_rel_singular_relcycle (*‹homologous_rel ?p ?X ?S ?c1.0 ?c2.0 ⟹ singular_relcycle ?p ?X ?S ?c1.0 = singular_relcycle ?p ?X ?S ?c2.0›*) p (*‹singular_relcycle p X S c›*))
next
(*goal: ‹⋀f. f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ n) c) ⟹ ∃V∈𝒞. f ` standard_simplex p ⊆ V›*)
fix f :: "(nat ⇒ real) ⇒ 'a"
assume "f ∈ Poly_Mapping.keys ?c'" (*‹(f::(nat ⇒ real) ⇒ 'a) ∈ Poly_Mapping.keys ((singular_subdivision (p::nat) ^^ (n::nat)) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int))›*)
then show "∃V∈𝒞. f ` standard_simplex p ⊆ V"
by (rule n [OF order_refl] (*‹?f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ n) c) ⟹ ∃V∈𝒞. ?f ` standard_simplex p ⊆ V›*))
qed
qed
lemma excised_chain_exists:
fixes S :: "'a set"
assumes "X closure_of U ⊆ X interior_of T" "T ⊆ S" "singular_chain p (subtopology X S) c"
obtains n d e where "singular_chain p (subtopology X (S - U)) d"
"singular_chain p (subtopology X T) e"
"(singular_subdivision p ^^ n) c = d + e"
proof (-)
(*goal: ‹(⋀d e n. ⟦singular_chain p (subtopology X (S - U)) d; singular_chain p (subtopology X T) e; (singular_subdivision p ^^ n) c = d + e⟧ ⟹ thesis) ⟹ thesis›*)
have "*": "∃n d e. singular_chain p (subtopology X (S - U)) d ∧
singular_chain p (subtopology X T) e ∧
(singular_subdivision p ^^ n) c = d + e" if c: "singular_chain p (subtopology X S) c" and X: "X closure_of U ⊆ X interior_of T" "U ⊆ topspace X" and S: "T ⊆ S" "S ⊆ topspace X" for p and X and c and S and T :: "'a set" and U :: "'a set"
proof (-)
(*goal: ‹∃n d e. singular_chain p (subtopology X (S - U)) d ∧ singular_chain p (subtopology X T) e ∧ (singular_subdivision p ^^ n) c = d + e›*)
obtain n where n: "⋀m f. ⟦n ≤ m; f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ m) c)⟧
⟹ ∃V ∈ {S ∩ X interior_of T, S - X closure_of U}. f ` standard_simplex p ⊆ V"
(*goal: ‹(⋀n. (⋀m f. ⟦n ≤ m; f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ m) c)⟧ ⟹ ∃V∈{S ∩ X interior_of T, S - X closure_of U}. f ` standard_simplex p ⊆ V) ⟹ thesis) ⟹ thesis›*)
apply (rule sufficient_iterated_singular_subdivision_exists [of "{S ∩ X interior_of T, S - X closure_of U}"] (*‹⟦⋀U. U ∈ {S ∩ X interior_of T, S - X closure_of U} ⟹ openin ?X U; topspace ?X ⊆ ⋃ {S ∩ X interior_of T, S - X closure_of U}; singular_chain ?p ?X ?c; ⋀n. (⋀m f. ⟦n ≤ m; f ∈ Poly_Mapping.keys ((singular_subdivision ?p ^^ m) ?c)⟧ ⟹ ∃V∈{S ∩ X interior_of T, S - X closure_of U}. f ` standard_simplex ?p ⊆ V) ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goal: ‹(⋀n. (⋀m f. ⟦n ≤ m; f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ m) c)⟧ ⟹ ∃V∈{S ∩ X interior_of T, S - X closure_of U}. f ` standard_simplex p ⊆ V) ⟹ thesis) ⟹ thesis›*)
using X (*‹X closure_of U ⊆ X interior_of T› ‹U ⊆ topspace X›*) S (*‹T ⊆ S› ‹(S::'a set) ⊆ topspace (X::'a topology)›*) c (*‹singular_chain (p::nat) (subtopology (X::'a topology) (S::'a set)) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*) by (auto simp: topspace_subtopology (*‹topspace (subtopology ?U ?V) = topspace ?U ∩ ?V›*) openin_subtopology_Int2 (*‹openin ?X ?T ⟹ openin (subtopology ?X ?S) (?S ∩ ?T)›*) openin_subtopology_diff_closed (*‹⟦?S ⊆ topspace ?X; closedin ?X ?T⟧ ⟹ openin (subtopology ?X ?S) (?S - ?T)›*))
let ?c' = "λn. (singular_subdivision p ^^ n) c"
have "singular_chain p (subtopology X S) (?c' m)" for m
apply (induction m)
(*goals:
1. ‹singular_chain (p::nat) (subtopology (X::'a::type topology) (S::'a::type set)) ((singular_subdivision p ^^ (0::nat)) (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int))›
2. ‹⋀m::nat. singular_chain (p::nat) (subtopology (X::'a::type topology) (S::'a::type set)) ((singular_subdivision p ^^ m) (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)) ⟹ singular_chain p (subtopology X S) ((singular_subdivision p ^^ Suc m) c)›
discuss goal 1*)
apply ((auto simp: singular_chain_singular_subdivision (*‹singular_chain ?p ?X ?c ⟹ singular_chain ?p ?X (singular_subdivision ?p ?c)›*) c (*‹singular_chain p (subtopology X S) c›*))[1])
(*discuss goal 2*)
apply ((auto simp: singular_chain_singular_subdivision (*‹singular_chain ?p ?X ?c ⟹ singular_chain ?p ?X (singular_subdivision ?p ?c)›*) c (*‹singular_chain p (subtopology X S) c›*))[1])
(*proven 2 subgoals*) .
then have scp: "singular_chain p (subtopology X S) (?c' n)" .
have SS: "Poly_Mapping.keys (?c' n) ⊆ singular_simplex_set p (subtopology X (S - U))
∪ singular_simplex_set p (subtopology X T)"
proof (clarsimp)
(*goal: ‹⋀x. ⟦x ∈ Poly_Mapping.keys ((singular_subdivision p ^^ n) c); ¬ singular_simplex p (subtopology X T) x⟧ ⟹ singular_simplex p (subtopology X (S - U)) x›*)
fix f
assume f: "f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ n) c)" and non: "¬ singular_simplex p (subtopology X T) f" (*‹(f::(nat ⇒ real) ⇒ 'a) ∈ Poly_Mapping.keys ((singular_subdivision (p::nat) ^^ (n::nat)) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int))› ‹¬ singular_simplex (p::nat) (subtopology (X::'a topology) (T::'a set)) (f::(nat ⇒ real) ⇒ 'a)›*)
show "singular_simplex p (subtopology X (S - U)) f"
using n[OF order_refl f] (*‹∃V∈{S ∩ X interior_of T, S - X closure_of U}. f ` standard_simplex p ⊆ V›*) scp (*‹singular_chain (p::nat) (subtopology (X::'a topology) (S::'a set)) ((singular_subdivision p ^^ (n::nat)) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int))›*) f (*‹f ∈ Poly_Mapping.keys ((singular_subdivision p ^^ n) c)›*) non (*‹¬ singular_simplex p (subtopology X T) f›*) closure_of_subset[OF ‹U ⊆ topspace X›] (*‹U ⊆ X closure_of U›*) interior_of_subset[of X T] (*‹X interior_of T ⊆ T›*) by (fastforce simp: image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*) singular_simplex_subtopology (*‹singular_simplex ?p (subtopology ?X ?S) ?f = (singular_simplex ?p ?X ?f ∧ ?f ` standard_simplex ?p ⊆ ?S)›*) singular_chain_def (*‹singular_chain ?p ?X ?c ≡ Poly_Mapping.keys ?c ⊆ singular_simplex_set ?p ?X›*))
qed
show "?thesis"
(*goal: ‹∃n d e. singular_chain p (subtopology X (S - U)) d ∧ singular_chain p (subtopology X T) e ∧ (singular_subdivision p ^^ n) c = d + e›*)
unfolding singular_chain_def
(*goal: ‹∃n d e. Poly_Mapping.keys d ⊆ singular_simplex_set p (subtopology X (S - U)) ∧ Poly_Mapping.keys e ⊆ singular_simplex_set p (subtopology X T) ∧ (singular_subdivision p ^^ n) c = d + e›*)
using frag_split[OF SS] (*‹(⋀d e. ⟦Poly_Mapping.keys d ⊆ singular_simplex_set p (subtopology X (S - U)); Poly_Mapping.keys e ⊆ singular_simplex_set p (subtopology X T); d + e = (singular_subdivision p ^^ n) c⟧ ⟹ ?thesis) ⟹ ?thesis›*) by metis
qed
have "(subtopology X (topspace X ∩ S)) = (subtopology X S)"
by (metis subtopology_subtopology (*‹subtopology (subtopology ?X ?S) ?T = subtopology ?X (?S ∩ ?T)›*) subtopology_topspace (*‹subtopology ?U (topspace ?U) = ?U›*))
with assms (*‹(X::'a topology) closure_of (U::'a set) ⊆ X interior_of (T::'a set)› ‹(T::'a::type set) ⊆ (S::'a::type set)› ‹singular_chain (p::nat) (subtopology (X::'a topology) (S::'a set)) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*) have c: "singular_chain p (subtopology X (topspace X ∩ S)) c"
by simp
have Xsub: "X closure_of (topspace X ∩ U) ⊆ X interior_of (topspace X ∩ T)"
using assms (*‹X closure_of U ⊆ X interior_of T› ‹T ⊆ S› ‹singular_chain p (subtopology X S) c›*) closure_of_restrict (*‹?X closure_of ?S = ?X closure_of (topspace ?X ∩ ?S)›*) interior_of_restrict (*‹?X interior_of ?S = ?X interior_of (topspace ?X ∩ ?S)›*) by fastforce
obtain n and d and e where d: "singular_chain p (subtopology X (topspace X ∩ S - topspace X ∩ U)) d" and e: "singular_chain p (subtopology X (topspace X ∩ T)) e" and de: "(singular_subdivision p ^^ n) c = d + e"
(*goal: ‹(⋀d e n. ⟦singular_chain p (subtopology X (topspace X ∩ S - topspace X ∩ U)) d; singular_chain p (subtopology X (topspace X ∩ T)) e; (singular_subdivision p ^^ n) c = d + e⟧ ⟹ thesis) ⟹ thesis›*)
using "*"[OF c Xsub, simplified] (*‹topspace (X::'a::type topology) ∩ (T::'a::type set) ⊆ (S::'a::type set) ⟹ ∃(n::nat) d::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. singular_chain (p::nat) (subtopology X (topspace X ∩ S - topspace X ∩ (U::'a::type set))) d ∧ (∃e::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int. singular_chain p (subtopology X (topspace X ∩ T)) e ∧ (singular_subdivision p ^^ n) (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) = d + e)›*) assms (*‹X closure_of U ⊆ X interior_of T› ‹T ⊆ S› ‹singular_chain p (subtopology X S) c›*) by force
show thesis
proof (standard)
(*goals:
1. ‹singular_chain p (subtopology X (S - U)) ?d›
2. ‹singular_chain p (subtopology X T) ?e›
3. ‹(singular_subdivision p ^^ ?n) c = ?d + ?e›*)
show "singular_chain p (subtopology X (S - U)) d"
by (metis d (*‹singular_chain p (subtopology X (topspace X ∩ S - topspace X ∩ U)) d›*) Diff_Int_distrib (*‹?C ∩ (?A - ?B) = ?C ∩ ?A - ?C ∩ ?B›*) inf.cobounded2 (*‹inf ?a ?b ≤ ?b›*) singular_chain_mono (*‹⟦singular_chain ?p (subtopology ?X ?T) ?c; ?T ⊆ ?S⟧ ⟹ singular_chain ?p (subtopology ?X ?S) ?c›*))
show "singular_chain p (subtopology X T) e"
by (metis e (*‹singular_chain p (subtopology X (topspace X ∩ T)) e›*) inf.cobounded2 (*‹inf ?a ?b ≤ ?b›*) singular_chain_mono (*‹⟦singular_chain ?p (subtopology ?X ?T) ?c; ?T ⊆ ?S⟧ ⟹ singular_chain ?p (subtopology ?X ?S) ?c›*))
show "(singular_subdivision p ^^ n) c = d + e"
by (rule de (*‹(singular_subdivision p ^^ n) c = d + e›*))
qed
qed
lemma excised_relcycle_exists:
fixes S :: "'a set"
assumes X: "X closure_of U ⊆ X interior_of T" and "T ⊆ S"
and c: "singular_relcycle p (subtopology X S) T c"
obtains c' where "singular_relcycle p (subtopology X (S - U)) (T - U) c'"
"homologous_rel p (subtopology X S) T c c'"
proof (-)
(*goal: ‹(⋀c'. ⟦singular_relcycle p (subtopology X (S - U)) (T - U) c'; homologous_rel p (subtopology X S) T c c'⟧ ⟹ thesis) ⟹ thesis›*)
have [simp]: "(S - U) ∩ (T - U) = T - U" "S ∩ T = T"
using ‹T ⊆ S› (*‹T ⊆ S›*) apply -
(*goals:
1. ‹T ⊆ S ⟹ (S - U) ∩ (T - U) = T - U›
2. ‹T ⊆ S ⟹ S ∩ T = T›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
have scc: "singular_chain p (subtopology X S) c" and scp1: "singular_chain (p - Suc 0) (subtopology X T) (chain_boundary p c)"
using c (*‹singular_relcycle p (subtopology X S) T c›*) apply -
(*goals:
1. ‹singular_relcycle (p::nat) (subtopology (X::'a::type topology) (S::'a::type set)) (T::'a::type set) (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⟹ singular_chain p (subtopology X S) c›
2. ‹singular_relcycle (p::nat) (subtopology (X::'a::type topology) (S::'a::type set)) (T::'a::type set) (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int) ⟹ singular_chain (p - Suc (0::nat)) (subtopology X T) (chain_boundary p c)›
discuss goal 1*)
apply ((auto simp: singular_relcycle_def (*‹singular_relcycle ?p ?X ?S ≡ λc. singular_chain ?p ?X c ∧ (chain_boundary ?p c, 0) ∈ mod_subset (?p - 1) (subtopology ?X ?S)›*) mod_subset_def (*‹mod_subset ?p ?X ≡ {(a, b). singular_chain ?p ?X (a - b)}›*) subtopology_subtopology (*‹subtopology (subtopology ?X ?S) ?T = subtopology ?X (?S ∩ ?T)›*))[1])
(*discuss goal 2*)
apply ((auto simp: singular_relcycle_def (*‹singular_relcycle ?p ?X ?S ≡ λc. singular_chain ?p ?X c ∧ (chain_boundary ?p c, 0) ∈ mod_subset (?p - 1) (subtopology ?X ?S)›*) mod_subset_def (*‹mod_subset ?p ?X ≡ {(a, b). singular_chain ?p ?X (a - b)}›*) subtopology_subtopology (*‹subtopology (subtopology ?X ?S) ?T = subtopology ?X (?S ∩ ?T)›*))[1])
(*proven 2 subgoals*) .
obtain n and d and e where d: "singular_chain p (subtopology X (S - U)) d" and e: "singular_chain p (subtopology X T) e" and de: "(singular_subdivision p ^^ n) c = d + e"
(*goal: ‹(⋀d e n. ⟦singular_chain p (subtopology X (S - U)) d; singular_chain p (subtopology X T) e; (singular_subdivision p ^^ n) c = d + e⟧ ⟹ thesis) ⟹ thesis›*)
using excised_chain_exists[OF X ‹T ⊆ S› scc] (*‹(⋀n d e. ⟦singular_chain p (subtopology X (S - U)) d; singular_chain p (subtopology X T) e; (singular_subdivision p ^^ n) c = d + e⟧ ⟹ ?thesis) ⟹ ?thesis›*) .
have scSUd: "singular_chain (p - Suc 0) (subtopology X (S - U)) (chain_boundary p d)"
by (simp add: singular_chain_boundary (*‹singular_chain ?p ?X ?c ⟹ singular_chain (?p - Suc 0) ?X (chain_boundary ?p ?c)›*) d (*‹singular_chain p (subtopology X (S - U)) d›*))
have sccn: "singular_chain p (subtopology X S) ((singular_subdivision p ^^ n) c)" for n
apply (induction n)
(*goals:
1. ‹singular_chain p (subtopology X S) ((singular_subdivision p ^^ 0) c)›
2. ‹⋀n. singular_chain p (subtopology X S) ((singular_subdivision p ^^ n) c) ⟹ singular_chain p (subtopology X S) ((singular_subdivision p ^^ Suc n) c)›
discuss goal 1*)
apply ((auto simp: singular_chain_singular_subdivision (*‹singular_chain (?p::nat) (?X::?'a::type topology) (?c::((nat ⇒ real) ⇒ ?'a::type) ⇒₀ int) ⟹ singular_chain ?p ?X (singular_subdivision ?p ?c)›*) scc (*‹singular_chain (p::nat) (subtopology (X::'a::type topology) (S::'a::type set)) (c::((nat ⇒ real) ⇒ 'a::type) ⇒₀ int)›*))[1])
(*discuss goal 2*)
apply ((auto simp: singular_chain_singular_subdivision (*‹singular_chain ?p ?X ?c ⟹ singular_chain ?p ?X (singular_subdivision ?p ?c)›*) scc (*‹singular_chain p (subtopology X S) c›*))[1])
(*proven 2 subgoals*) .
have "singular_chain (p - Suc 0) (subtopology X T) (chain_boundary p ((singular_subdivision p ^^ n) c))"
proof (induction n)
(*goals:
1. ‹singular_chain ((p::nat) - Suc (0::nat)) (subtopology (X::'a topology) (T::'a set)) (chain_boundary p ((singular_subdivision p ^^ (0::nat)) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int)))›
2. ‹⋀n::nat. singular_chain ((p::nat) - Suc (0::nat)) (subtopology (X::'a topology) (T::'a set)) (chain_boundary p ((singular_subdivision p ^^ n) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int))) ⟹ singular_chain (p - Suc (0::nat)) (subtopology X T) (chain_boundary p ((singular_subdivision p ^^ Suc n) c))›*)
case (Suc n) (*‹singular_chain (p - Suc 0) (subtopology X T) (chain_boundary p ((singular_subdivision p ^^ n) c))›*)
then show "?case"
(*goal: ‹singular_chain (p - Suc 0) (subtopology X T) (chain_boundary p ((singular_subdivision p ^^ Suc n) c))›*)
by (simp add: singular_chain_singular_subdivision (*‹singular_chain ?p ?X ?c ⟹ singular_chain ?p ?X (singular_subdivision ?p ?c)›*) chain_boundary_singular_subdivision [OF sccn] (*‹chain_boundary p (singular_subdivision p ((singular_subdivision p ^^ ?n1) c)) = singular_subdivision (p - Suc 0) (chain_boundary p ((singular_subdivision p ^^ ?n1) c))›*))
qed (auto simp: scp1 (*‹singular_chain (p - Suc 0) (subtopology X T) (chain_boundary p c)›*))
(*solved the remaining goal: ‹singular_chain (p - Suc 0) (subtopology X T) (chain_boundary p ((singular_subdivision p ^^ 0) c))›*)
then have "singular_chain (p - Suc 0) (subtopology X T) (chain_boundary p ((singular_subdivision p ^^ n) c - e))"
by (simp add: chain_boundary_diff (*‹chain_boundary ?p (?a - ?b) = chain_boundary ?p ?a - chain_boundary ?p ?b›*) singular_chain_diff (*‹⟦singular_chain ?p ?X ?a; singular_chain ?p ?X ?b⟧ ⟹ singular_chain ?p ?X (?a - ?b)›*) singular_chain_boundary (*‹singular_chain ?p ?X ?c ⟹ singular_chain (?p - Suc 0) ?X (chain_boundary ?p ?c)›*) e (*‹singular_chain p (subtopology X T) e›*))
with de (*‹(singular_subdivision p ^^ n) c = d + e›*) have scTd: "singular_chain (p - Suc 0) (subtopology X T) (chain_boundary p d)"
by simp
show thesis
proof (standard)
(*goals:
1. ‹singular_relcycle p (subtopology X (S - U)) (T - U) ?c'›
2. ‹homologous_rel p (subtopology X S) T c ?c'›*)
have "singular_chain (p - Suc 0) X (chain_boundary p d)"
using scTd (*‹singular_chain (p - Suc 0) (subtopology X T) (chain_boundary p d)›*) singular_chain_subtopology (*‹singular_chain ?p (subtopology ?X ?S) ?c = (singular_chain ?p ?X ?c ∧ (∀f∈Poly_Mapping.keys ?c. f ` standard_simplex ?p ⊆ ?S))›*) by blast
with scSUd (*‹singular_chain ((p::nat) - Suc (0::nat)) (subtopology (X::'a topology) ((S::'a set) - (U::'a set))) (chain_boundary p (d::((nat ⇒ real) ⇒ 'a) ⇒₀ int))›*) scTd (*‹singular_chain (p - Suc 0) (subtopology X T) (chain_boundary p d)›*) have "singular_chain (p - Suc 0) (subtopology X (T - U)) (chain_boundary p d)"
by (fastforce simp add: singular_chain_subtopology (*‹singular_chain ?p (subtopology ?X ?S) ?c = (singular_chain ?p ?X ?c ∧ (∀f∈Poly_Mapping.keys ?c. f ` standard_simplex ?p ⊆ ?S))›*))
then show "singular_relcycle p (subtopology X (S - U)) (T - U) d"
by (auto simp: singular_relcycle_def (*‹singular_relcycle (?p::nat) (?X::?'a topology) (?S::?'a set) ≡ λc::((nat ⇒ real) ⇒ ?'a) ⇒₀ int. singular_chain ?p ?X c ∧ (chain_boundary ?p c, 0::((nat ⇒ real) ⇒ ?'a) ⇒₀ int) ∈ mod_subset (?p - (1::nat)) (subtopology ?X ?S)›*) mod_subset_def (*‹mod_subset (?p::nat) (?X::?'a topology) ≡ {(a::((nat ⇒ real) ⇒ ?'a) ⇒₀ int, b::((nat ⇒ real) ⇒ ?'a) ⇒₀ int). singular_chain ?p ?X (a - b)}›*) subtopology_subtopology (*‹subtopology (subtopology (?X::?'a topology) (?S::?'a set)) (?T::?'a set) = subtopology ?X (?S ∩ ?T)›*) d (*‹singular_chain (p::nat) (subtopology (X::'a topology) ((S::'a set) - (U::'a set))) (d::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*))
have "homologous_rel p (subtopology X S) T (c-0) ((singular_subdivision p ^^ n) c - e)"
proof (rule homologous_rel_diff (*‹⟦homologous_rel ?p ?X ?S ?a ?a'; homologous_rel ?p ?X ?S ?b ?b'⟧ ⟹ homologous_rel ?p ?X ?S (?a - ?b) (?a' - ?b')›*))
(*goals:
1. ‹homologous_rel p (subtopology X S) T c ((singular_subdivision p ^^ n) c)›
2. ‹homologous_rel p (subtopology X S) T 0 e›*)
show "homologous_rel p (subtopology X S) T c ((singular_subdivision p ^^ n) c)"
proof (induction n)
(*goals:
1. ‹homologous_rel p (subtopology X S) T c ((singular_subdivision p ^^ 0) c)›
2. ‹⋀n. homologous_rel p (subtopology X S) T c ((singular_subdivision p ^^ n) c) ⟹ homologous_rel p (subtopology X S) T c ((singular_subdivision p ^^ Suc n) c)›*)
case (Suc n) (*‹homologous_rel p (subtopology X S) T c ((singular_subdivision p ^^ n) c)›*)
then show "?case"
(*goal: ‹homologous_rel p (subtopology X S) T c ((singular_subdivision p ^^ Suc n) c)›*)
apply simp
(*goal: ‹homologous_rel p (subtopology X S) T c ((singular_subdivision p ^^ Suc n) c)›*)
by (metis c (*‹singular_relcycle p (subtopology X S) T c›*) homologous_rel_eq (*‹(homologous_rel ?p ?X ?S ?a = homologous_rel ?p ?X ?S ?b) = homologous_rel ?p ?X ?S ?a ?b›*) homologous_rel_singular_relcycle_1 (*‹⟦homologous_rel ?p ?X ?S ?c1.0 ?c2.0; singular_relcycle ?p ?X ?S ?c1.0⟧ ⟹ singular_relcycle ?p ?X ?S ?c2.0›*) homologous_rel_singular_subdivision (*‹singular_relcycle ?p ?X ?T ?c ⟹ homologous_rel ?p ?X ?T (singular_subdivision ?p ?c) ?c›*))
qed (auto)
(*solved the remaining goal: ‹homologous_rel p (subtopology X S) T c ((singular_subdivision p ^^ 0) c)›*)
show "homologous_rel p (subtopology X S) T 0 e"
unfolding homologous_rel_def
(*goal: ‹singular_relboundary p (subtopology X S) T (0 - e)›*)
using e (*‹singular_chain (p::nat) (subtopology (X::'a topology) (T::'a set)) (e::((nat ⇒ real) ⇒ 'a) ⇒₀ int)›*) apply (intro singular_relboundary_diff (*‹⟦singular_relboundary ?p ?X ?S ?a; singular_relboundary ?p ?X ?S ?b⟧ ⟹ singular_relboundary ?p ?X ?S (?a - ?b)›*) singular_chain_imp_relboundary (*‹singular_chain ?p (subtopology ?X ?S) ?c ⟹ singular_relboundary ?p ?X ?S ?c›*))
(*goals:
1. ‹singular_chain p (subtopology X T) e ⟹ singular_chain p (subtopology (subtopology X S) T) 0›
2. ‹singular_chain p (subtopology X T) e ⟹ singular_chain p (subtopology (subtopology X S) T) e›
discuss goal 1*)
apply (simp add: subtopology_subtopology (*‹subtopology (subtopology ?X ?S) ?T = subtopology ?X (?S ∩ ?T)›*))
(*discuss goal 2*)
apply (simp add: subtopology_subtopology (*‹subtopology (subtopology (?X::?'a topology) (?S::?'a set)) (?T::?'a set) = subtopology ?X (?S ∩ ?T)›*))
(*proven 2 subgoals*) .
qed
with de (*‹(singular_subdivision p ^^ n) c = d + e›*) show "homologous_rel p (subtopology X S) T c d"
by simp
qed
qed
subsection‹Homotopy invariance›
theorem homotopic_imp_homologous_rel_chain_maps:
assumes hom: "homotopic_with (λh. h ` T ⊆ V) S U f g" and c: "singular_relcycle p S T c"
shows "homologous_rel p U V (chain_map p f c) (chain_map p g c)"
proof (-)
(*goal: ‹homologous_rel p U V (chain_map p f c) (chain_map p g c)›*)
note sum.atMost_Suc[simp del] (*‹sum (?g::nat ⇒ ?'a) {..Suc (?n::nat)} = sum ?g {..?n} + ?g (Suc ?n)›*)
have contf: "continuous_map S U f" and contg: "continuous_map S U g"
using homotopic_with_imp_continuous_maps[OF hom] (*‹continuous_map S U f ∧ continuous_map S U g›*) apply -
(*goals:
1. ‹continuous_map S U f ∧ continuous_map S U g ⟹ continuous_map S U f›
2. ‹continuous_map S U f ∧ continuous_map S U g ⟹ continuous_map S U g›
discuss goal 1*)
apply metis
(*discuss goal 2*)
apply metis
(*proven 2 subgoals*) .
obtain h where conth: "continuous_map (prod_topology (top_of_set {0..1::real}) S) U h" and h0: "⋀x. h(0, x) = f x" and h1: "⋀x. h(1, x) = g x" and hV: "⋀t x. ⟦0 ≤ t; t ≤ 1; x ∈ T⟧ ⟹ h(t,x) ∈ V"
(*goal: ‹(⋀h. ⟦continuous_map (prod_topology (top_of_set {0..1}) S) U h; ⋀x. h (0, x) = f x; ⋀x. h (1, x) = g x; ⋀t x. ⟦0 ≤ t; t ≤ 1; x ∈ T⟧ ⟹ h (t, x) ∈ V⟧ ⟹ thesis) ⟹ thesis›*)
using hom (*‹homotopic_with (λh. h ` T ⊆ V) S U f g›*) by (fastforce simp: homotopic_with_def (*‹homotopic_with ?P ?X ?Y ?f ?g ≡ ∃h. continuous_map (prod_topology (top_of_set {0..1}) ?X) ?Y h ∧ (∀x. h (0, x) = ?f x) ∧ (∀x. h (1, x) = ?g x) ∧ (∀t∈{0..1}. ?P (λx. h (t, x)))›*))
define vv where "vv ≡ λj i. if i = Suc j then 1 else (0::real)"
define ww where "ww ≡ λj i. if i=0 ∨ i = Suc j then 1 else (0::real)"
define simp where "simp ≡ λq i. oriented_simplex (Suc q) (λj. if j ≤ i then vv j else ww(j -1))"
define pr where "pr ≡ λq c. ∑i≤q. frag_cmul ((-1) ^ i)
(frag_of (simplex_map (Suc q) (λz. h(z 0, c(z ∘ Suc))) (simp q i)))"
have ss_ss: "simplicial_simplex (Suc q) ({x. x 0 ∈ {0..1} ∧ (x ∘ Suc) ∈ standard_simplex q}) (simp q i)" if "i ≤ q" for q and i
proof (-)
(*goal: ‹simplicial_simplex (Suc q) {x. x 0 ∈ {0..1} ∧ x ∘ Suc ∈ standard_simplex q} (simp q i)›*)
have "(∑j≤Suc q. (if j ≤ i then vv j 0 else ww (j -1) 0) * x j) ∈ {0..1}" if "x ∈ standard_simplex (Suc q)" for x
proof (-)
(*goal: ‹(∑j≤Suc q. (if j ≤ i then vv j 0 else ww (j - 1) 0) * x j) ∈ {0..1}›*)
have "(∑j≤Suc q. if j ≤ i then 0 else x j) ≤ sum x {..Suc q}"
using that (*‹(x::nat ⇒ real) ∈ standard_simplex (Suc (q::nat))›*) unfolding standard_simplex_def
(*goal: ‹(∑j≤Suc q. if j ≤ i then 0 else x j) ≤ sum x {..Suc q}›*)
by (force intro!: sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*))
with ‹i ≤ q› (*‹i ≤ q›*) that (*‹x ∈ standard_simplex (Suc q)›*) show "?thesis"
(*goal: ‹(∑j≤Suc q. (if j ≤ i then vv j 0 else ww (j - 1) 0) * x j) ∈ {0..1}›*)
by (simp add: vv_def (*‹vv ≡ λj i. if i = Suc j then 1 else 0›*) ww_def (*‹ww ≡ λj i. if i = 0 ∨ i = Suc j then 1 else 0›*) standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*) if_distrib [of "λu. u * _"] (*‹(if ?c then ?x else ?y) * ?uu5 = (if ?c then ?x * ?uu5 else ?y * ?uu5)›*) sum_nonneg (*‹(⋀x. x ∈ ?A ⟹ 0 ≤ ?f x) ⟹ 0 ≤ sum ?f ?A›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
qed
moreover have "(λk. ∑j≤Suc q. (if j ≤ i then vv j k else ww (j -1) k) * x j) ∘ Suc ∈ standard_simplex q" if "x ∈ standard_simplex (Suc q)" for x
proof (-)
(*goal: ‹(λk. ∑j≤Suc q. (if j ≤ i then vv j k else ww (j - 1) k) * x j) ∘ Suc ∈ standard_simplex q›*)
have card: "({..q} ∩ {k. Suc k = j}) = {j-1}" if "0 < j" "j ≤ Suc q" for j
using that (*‹0 < j› ‹j ≤ Suc q›*) by auto
have eq: "(∑j≤Suc q. ∑k≤q. if j ≤ i then if k = j then x j else 0 else if Suc k = j then x j else 0)
= (∑j≤Suc q. x j)"
apply (rule sum.cong [OF refl] (*‹(⋀x. x ∈ ?A ⟹ ?g x = ?h x) ⟹ sum ?g ?A = sum ?h ?A›*))
(*goal: ‹(∑j≤Suc q. ∑k≤q. if j ≤ i then if k = j then x j else 0 else if Suc k = j then x j else 0) = sum x {..Suc q}›*)
by (use ‹i ≤ q› in ‹simp add: sum.If_cases card›)
have "(∑j≤Suc q. if j ≤ i then if k = j then x j else 0 else if Suc k = j then x j else 0)
≤ sum x {..Suc q}" for k
using that (*‹(x::nat ⇒ real) ∈ standard_simplex (Suc (q::nat))›*) unfolding standard_simplex_def
(*goal: ‹(∑j≤Suc q. if j ≤ i then if k = j then x j else 0 else if Suc k = j then x j else 0) ≤ sum x {..Suc q}›*)
by (force intro!: sum_mono (*‹(⋀i::?'b. i ∈ (?K::?'b set) ⟹ (?f::?'b ⇒ ?'a) i ≤ (?g::?'b ⇒ ?'a) i) ⟹ sum ?f ?K ≤ sum ?g ?K›*))
then show "?thesis"
(*goal: ‹(λk. ∑j≤Suc q. (if j ≤ i then vv j k else ww (j - 1) k) * x j) ∘ Suc ∈ standard_simplex q›*)
using ‹i ≤ q› (*‹(i::nat) ≤ (q::nat)›*) that (*‹x ∈ standard_simplex (Suc q)›*) by (simp add: vv_def (*‹vv::nat ⇒ nat ⇒ real ≡ λ(j::nat) i::nat. if i = Suc j then 1::real else (0::real)›*) ww_def (*‹ww::nat ⇒ nat ⇒ real ≡ λ(j::nat) i::nat. if i = (0::nat) ∨ i = Suc j then 1::real else (0::real)›*) standard_simplex_def (*‹standard_simplex (?p::nat) ≡ {x::nat ⇒ real. (∀i::nat. (0::real) ≤ x i ∧ x i ≤ (1::real)) ∧ (∀i>?p. x i = (0::real)) ∧ sum x {..?p} = (1::real)}›*) if_distrib [of "λu. u * _"] (*‹(if ?c::bool then ?x::?'c1 else (?y::?'c1)) * (?uu5::?'c1) = (if ?c then ?x * ?uu5 else ?y * ?uu5)›*) sum_nonneg (*‹(⋀x::?'b. x ∈ (?A::?'b set) ⟹ (0::?'a) ≤ (?f::?'b ⇒ ?'a) x) ⟹ (0::?'a) ≤ sum ?f ?A›*) sum.swap [where A = "atMost q"] (*‹(∑i::nat≤q::nat. sum ((?g::nat ⇒ ?'c ⇒ ?'a) i) (?B::?'c set)) = (∑j::?'c∈?B. ∑i::nat≤q. ?g i j)›*) eq (*‹(∑j::nat≤Suc q. ∑k::nat≤q::nat. if j ≤ (i::nat) then if k = j then (x::nat ⇒ real) j else (0::real) else if Suc k = j then x j else (0::real)) = sum x {..Suc q}›*) cong: if_cong (*‹⟦(?b::bool) = (?c::bool); ?c ⟹ (?x::?'a) = (?u::?'a); ¬ ?c ⟹ (?y::?'a) = (?v::?'a)⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
qed
ultimately show "?thesis"
(*goal: ‹simplicial_simplex (Suc q) {x. x 0 ∈ {0..1} ∧ x ∘ Suc ∈ standard_simplex q} (simp q i)›*)
by (simp add: that (*‹i ≤ q›*) simplicial_simplex_oriented_simplex (*‹simplicial_simplex ?p ?S (oriented_simplex ?p ?l) = ((λx i. ∑j≤?p. ?l j i * x j) ` standard_simplex ?p ⊆ ?S)›*) simp_def (*‹simp ≡ λq i. oriented_simplex (Suc q) (λj. if j ≤ i then vv j else ww (j - 1))›*) image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*) if_distribR (*‹(if ?b then ?f else ?g) ?x = (if ?b then ?f ?x else ?g ?x)›*))
qed
obtain prism where prism: "⋀q. prism q 0 = 0" "⋀q c. singular_chain q S c ⟹ singular_chain (Suc q) U (prism q c)" "⋀q c. singular_chain q (subtopology S T) c
⟹ singular_chain (Suc q) (subtopology U V) (prism q c)" "⋀q c. singular_chain q S c
⟹ chain_boundary (Suc q) (prism q c) =
chain_map q g c - chain_map q f c - prism (q -1) (chain_boundary q c)"
(*goal: ‹(⋀prism. ⟦⋀q. prism q 0 = 0; ⋀q c. singular_chain q S c ⟹ singular_chain (Suc q) U (prism q c); ⋀q c. singular_chain q (subtopology S T) c ⟹ singular_chain (Suc q) (subtopology U V) (prism q c); ⋀q c. singular_chain q S c ⟹ chain_boundary (Suc q) (prism q c) = chain_map q g c - chain_map q f c - prism (q - 1) (chain_boundary q c)⟧ ⟹ thesis) ⟹ thesis›*)
proof (standard)
(*goals:
1. ‹⋀q. (⋀prism. ⟦⋀q. prism q 0 = 0; ⋀q c. singular_chain q S c ⟹ singular_chain (Suc q) U (prism q c); ⋀q c. singular_chain q (subtopology S T) c ⟹ singular_chain (Suc q) (subtopology U V) (prism q c); ⋀q c. singular_chain q S c ⟹ chain_boundary (Suc q) (prism q c) = chain_map q g c - chain_map q f c - prism (q - 1) (chain_boundary q c)⟧ ⟹ thesis) ⟹ ?prism2 q 0 = 0›
2. ‹⋀q c. ⟦⋀prism. ⟦⋀q. prism q 0 = 0; ⋀q c. singular_chain q S c ⟹ singular_chain (Suc q) U (prism q c); ⋀q c. singular_chain q (subtopology S T) c ⟹ singular_chain (Suc q) (subtopology U V) (prism q c); ⋀q c. singular_chain q S c ⟹ chain_boundary (Suc q) (prism q c) = chain_map q g c - chain_map q f c - prism (q - 1) (chain_boundary q c)⟧ ⟹ thesis; singular_chain q S c⟧ ⟹ singular_chain (Suc q) U (?prism2 q c)›
3. ‹⋀q c. ⟦⋀prism. ⟦⋀q. prism q 0 = 0; ⋀q c. singular_chain q S c ⟹ singular_chain (Suc q) U (prism q c); ⋀q c. singular_chain q (subtopology S T) c ⟹ singular_chain (Suc q) (subtopology U V) (prism q c); ⋀q c. singular_chain q S c ⟹ chain_boundary (Suc q) (prism q c) = chain_map q g c - chain_map q f c - prism (q - 1) (chain_boundary q c)⟧ ⟹ thesis; singular_chain q (subtopology S T) c⟧ ⟹ singular_chain (Suc q) (subtopology U V) (?prism2 q c)›
4. ‹⋀q c. ⟦⋀prism. ⟦⋀q. prism q 0 = 0; ⋀q c. singular_chain q S c ⟹ singular_chain (Suc q) U (prism q c); ⋀q c. singular_chain q (subtopology S T) c ⟹ singular_chain (Suc q) (subtopology U V) (prism q c); ⋀q c. singular_chain q S c ⟹ chain_boundary (Suc q) (prism q c) = chain_map q g c - chain_map q f c - prism (q - 1) (chain_boundary q c)⟧ ⟹ thesis; singular_chain q S c⟧ ⟹ chain_boundary (Suc q) (?prism2 q c) = chain_map q g c - chain_map q f c - ?prism2 (q - 1) (chain_boundary q c)›*)
show "(frag_extend ∘ pr) q 0 = 0" for q
by (simp add: pr_def (*‹pr ≡ λq c. ∑i≤q. frag_cmul ((- 1) ^ i) (frag_of (simplex_map (Suc q) (λz. h (z 0, c (z ∘ Suc))) (simp q i)))›*))
next
(*goals:
1. ‹⋀q c. ⟦⋀prism. ⟦⋀q. prism q 0 = 0; ⋀q c. singular_chain q S c ⟹ singular_chain (Suc q) U (prism q c); ⋀q c. singular_chain q (subtopology S T) c ⟹ singular_chain (Suc q) (subtopology U V) (prism q c); ⋀q c. singular_chain q S c ⟹ chain_boundary (Suc q) (prism q c) = chain_map q g c - chain_map q f c - prism (q - 1) (chain_boundary q c)⟧ ⟹ thesis; singular_chain q S c⟧ ⟹ singular_chain (Suc q) U ((frag_extend ∘ pr) (?q11 q c) c)›
2. ‹⋀q c. ⟦⋀prism. ⟦⋀q. prism q 0 = 0; ⋀q c. singular_chain q S c ⟹ singular_chain (Suc q) U (prism q c); ⋀q c. singular_chain q (subtopology S T) c ⟹ singular_chain (Suc q) (subtopology U V) (prism q c); ⋀q c. singular_chain q S c ⟹ chain_boundary (Suc q) (prism q c) = chain_map q g c - chain_map q f c - prism (q - 1) (chain_boundary q c)⟧ ⟹ thesis; singular_chain q (subtopology S T) c⟧ ⟹ singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) (?q11 q c) c)›
3. ‹⋀q c. ⟦⋀prism. ⟦⋀q. prism q 0 = 0; ⋀q c. singular_chain q S c ⟹ singular_chain (Suc q) U (prism q c); ⋀q c. singular_chain q (subtopology S T) c ⟹ singular_chain (Suc q) (subtopology U V) (prism q c); ⋀q c. singular_chain q S c ⟹ chain_boundary (Suc q) (prism q c) = chain_map q g c - chain_map q f c - prism (q - 1) (chain_boundary q c)⟧ ⟹ thesis; singular_chain q S c⟧ ⟹ chain_boundary (Suc q) ((frag_extend ∘ pr) (?q11 q c) c) = chain_map q g c - chain_map q f c - (frag_extend ∘ pr) (?q11 (q - 1) (chain_boundary q c)) (chain_boundary q c)›*)
show "singular_chain (Suc q) U ((frag_extend ∘ pr) q c)" if "singular_chain q S c" for q and c
using that[unfolded singular_chain_def] (*‹Poly_Mapping.keys (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⊆ singular_simplex_set (q::nat) (S::'a topology)›*) proof (induction c rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹singular_chain (Suc q) U ((frag_extend ∘ pr) q 0)›
2. ‹⋀x. x ∈ singular_simplex_set q S ⟹ singular_chain (Suc q) U ((frag_extend ∘ pr) q (frag_of x))›
3. ‹⋀a b. ⟦singular_chain (Suc q) U ((frag_extend ∘ pr) q a); singular_chain (Suc q) U ((frag_extend ∘ pr) q b)⟧ ⟹ singular_chain (Suc q) U ((frag_extend ∘ pr) q (a - b))›*)
case (one m) (*‹(m::(nat ⇒ real) ⇒ 'a) ∈ singular_simplex_set (q::nat) (S::'a topology)›*)
show "?case"
(*goal: ‹singular_chain (Suc q) U ((frag_extend ∘ pr) q (frag_of m))›*)
apply (simp add: pr_def (*‹pr ≡ λq c. ∑i≤q. frag_cmul ((- 1) ^ i) (frag_of (simplex_map (Suc q) (λz. h (z 0, c (z ∘ Suc))) (simp q i)))›*))
(*goal: ‹singular_chain (Suc q) U ((frag_extend ∘ pr) q (frag_of m))›*)
proof (intro singular_chain_cmul (*‹singular_chain ?p ?X ?c ⟹ singular_chain ?p ?X (frag_cmul ?a ?c)›*) singular_chain_sum (*‹(⋀i. i ∈ ?I ⟹ singular_chain ?p ?X (?f i)) ⟹ singular_chain ?p ?X (sum ?f ?I)›*))
(*goal: ‹⋀i. i ∈ {..q} ⟹ singular_chain (Suc q) U (frag_of (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i)))›*)
fix i :: nat
assume "i ∈ {..q}" (*‹(i::nat) ∈ {..q::nat}›*)
define X where "X = subtopology (powertop_real UNIV) {x. x 0 ∈ {0..1} ∧ (x ∘ Suc) ∈ standard_simplex q}"
show "singular_chain (Suc q) U
(frag_of (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i)))"
unfolding singular_chain_of
(*goal: ‹singular_simplex (Suc q) U (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))›*)
proof (rule singular_simplex_simplex_map (*‹⟦singular_simplex ?p ?X ?f; continuous_map ?X ?X' ?g⟧ ⟹ singular_simplex ?p ?X' (simplex_map ?p ?g ?f)›*))
(*goals:
1. ‹singular_simplex (Suc (q::nat)) (?X::(nat ⇒ real) topology) ((simp::nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real) q (i::nat))›
2. ‹continuous_map (?X::(nat ⇒ real) topology) (U::'b topology) (λz::nat ⇒ real. (h::real × 'a ⇒ 'b) (z (0::nat), (m::(nat ⇒ real) ⇒ 'a) (z ∘ Suc)))›*)
show "singular_simplex (Suc q) X (simp q i)"
unfolding X_def
(*goal: ‹singular_simplex (Suc q) (subtopology (powertop_real UNIV) {x. x 0 ∈ {0..1} ∧ x ∘ Suc ∈ standard_simplex q}) (simp q i)›*)
using ‹i ∈ {..q}› (*‹i ∈ {..q}›*) simplicial_imp_singular_simplex (*‹simplicial_simplex (?p::nat) (?S::(?'a::type ⇒ real) set) (?f::(nat ⇒ real) ⇒ ?'a::type ⇒ real) ⟹ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f›*) ss_ss (*‹?i ≤ ?q ⟹ simplicial_simplex (Suc ?q) {x. x 0 ∈ {0..1} ∧ x ∘ Suc ∈ standard_simplex ?q} (simp ?q ?i)›*) by blast
have 0: "continuous_map X (top_of_set {0..1}) (λx. x 0)"
unfolding continuous_map_in_subtopology topspace_subtopology X_def
(*goal: ‹continuous_map (subtopology (powertop_real UNIV) {x::nat ⇒ real. x (0::nat) ∈ {0::real..1::real} ∧ x ∘ Suc ∈ standard_simplex (q::nat)}) euclideanreal (λx::nat ⇒ real. x (0::nat)) ∧ (λx::nat ⇒ real. x (0::nat)) ` (topspace (powertop_real UNIV) ∩ {x::nat ⇒ real. x (0::nat) ∈ {0::real..1::real} ∧ x ∘ Suc ∈ standard_simplex q}) ⊆ {0::real..1::real}›*)
by (auto intro: continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*) continuous_map_from_subtopology (*‹continuous_map ?X ?Y ?f ⟹ continuous_map (subtopology ?X ?S) ?Y ?f›*))
have 1: "continuous_map X S (m ∘ (λx j. x (Suc j)))"
proof (rule continuous_map_compose (*‹⟦continuous_map ?X ?X' ?f; continuous_map ?X' ?X'' ?g⟧ ⟹ continuous_map ?X ?X'' (?g ∘ ?f)›*))
(*goals:
1. ‹continuous_map X ?X' (λx j. x (Suc j))›
2. ‹continuous_map ?X' S m›*)
have "continuous_map (powertop_real UNIV) (powertop_real UNIV) (λx j. x (Suc j))"
by (auto intro: continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*))
then show "continuous_map X (subtopology (powertop_real UNIV) (standard_simplex q)) (λx j. x (Suc j))"
unfolding X_def o_def
(*goal: ‹continuous_map (subtopology (powertop_real UNIV) {x. x 0 ∈ {0..1} ∧ (λxa. x (Suc xa)) ∈ standard_simplex q}) (subtopology (powertop_real UNIV) (standard_simplex q)) (λx j. x (Suc j))›*)
by (auto simp: continuous_map_in_subtopology (*‹continuous_map ?X (subtopology ?X' ?S) ?f = (continuous_map ?X ?X' ?f ∧ ?f ` topspace ?X ⊆ ?S)›*) intro: continuous_map_from_subtopology (*‹continuous_map ?X ?Y ?f ⟹ continuous_map (subtopology ?X ?S) ?Y ?f›*) continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*))
qed (use one in ‹simp add: singular_simplex_def›)
(*solved the remaining goal: ‹continuous_map (subtopology (powertop_real UNIV) (standard_simplex q)) S m›*)
show "continuous_map X U (λz. h (z 0, m (z ∘ Suc)))"
apply (rule continuous_map_compose [unfolded o_def, OF _ conth] (*‹continuous_map ?X (prod_topology (top_of_set {0..1}) S) ?f ⟹ continuous_map ?X U (λx. h (?f x))›*))
(*goal: ‹continuous_map (X::(nat ⇒ real) topology) (U::'b topology) (λz::nat ⇒ real. (h::real × 'a ⇒ 'b) (z (0::nat), (m::(nat ⇒ real) ⇒ 'a) (z ∘ Suc)))›*)
using "0" (*‹continuous_map (X::(nat ⇒ real) topology) (top_of_set {0::real..1::real}) (λx::nat ⇒ real. x (0::nat))›*) "1" (*‹continuous_map X S (m ∘ (λx j. x (Suc j)))›*) by (simp add: continuous_map_pairwise (*‹continuous_map ?Z (prod_topology ?X ?Y) ?f = (continuous_map ?Z ?X (fst ∘ ?f) ∧ continuous_map ?Z ?Y (snd ∘ ?f))›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*))
qed
qed
next
(*goals:
1. ‹singular_chain (Suc q) U ((frag_extend ∘ pr) q 0)›
2. ‹⋀a b. ⟦singular_chain (Suc q) U ((frag_extend ∘ pr) q a); singular_chain (Suc q) U ((frag_extend ∘ pr) q b)⟧ ⟹ singular_chain (Suc q) U ((frag_extend ∘ pr) q (a - b))›*)
case (diff a b) (*‹singular_chain (Suc (q::nat)) (U::'b topology) ((frag_extend ∘ (pr::nat ⇒ ((nat ⇒ real) ⇒ 'a) ⇒ ((nat ⇒ real) ⇒ 'b) ⇒₀ int)) q (a::((nat ⇒ real) ⇒ 'a) ⇒₀ int))› ‹singular_chain (Suc q) U ((frag_extend ∘ pr) q b)›*)
then show "?case"
(*goal: ‹singular_chain (Suc q) U ((frag_extend ∘ pr) q (a - b))›*)
by (simp add: frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*) singular_chain_diff (*‹⟦singular_chain ?p ?X ?a; singular_chain ?p ?X ?b⟧ ⟹ singular_chain ?p ?X (?a - ?b)›*))
qed (auto)
(*solved the remaining goal: ‹singular_chain (Suc q) U ((frag_extend ∘ pr) q 0)›*)
next
(*goals:
1. ‹⋀q c. ⟦⋀prism. ⟦⋀q. prism q 0 = 0; ⋀q c. singular_chain q S c ⟹ singular_chain (Suc q) U (prism q c); ⋀q c. singular_chain q (subtopology S T) c ⟹ singular_chain (Suc q) (subtopology U V) (prism q c); ⋀q c. singular_chain q S c ⟹ chain_boundary (Suc q) (prism q c) = chain_map q g c - chain_map q f c - prism (q - 1) (chain_boundary q c)⟧ ⟹ thesis; singular_chain q (subtopology S T) c⟧ ⟹ singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q c)›
2. ‹⋀q c. ⟦⋀prism. ⟦⋀q. prism q 0 = 0; ⋀q c. singular_chain q S c ⟹ singular_chain (Suc q) U (prism q c); ⋀q c. singular_chain q (subtopology S T) c ⟹ singular_chain (Suc q) (subtopology U V) (prism q c); ⋀q c. singular_chain q S c ⟹ chain_boundary (Suc q) (prism q c) = chain_map q g c - chain_map q f c - prism (q - 1) (chain_boundary q c)⟧ ⟹ thesis; singular_chain q S c⟧ ⟹ chain_boundary (Suc q) ((frag_extend ∘ pr) q c) = chain_map q g c - chain_map q f c - (frag_extend ∘ pr) (q - 1) (chain_boundary q c)›*)
show "singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q c)" if "singular_chain q (subtopology S T) c" for q and c
using that[unfolded singular_chain_def] (*‹Poly_Mapping.keys c ⊆ singular_simplex_set q (subtopology S T)›*) proof (induction c rule: frag_induction (*‹⟦Poly_Mapping.keys ?c ⊆ ?S; ?P 0; ⋀x. x ∈ ?S ⟹ ?P (frag_of x); ⋀a b. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q 0)›
2. ‹⋀x. x ∈ singular_simplex_set q (subtopology S T) ⟹ singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q (frag_of x))›
3. ‹⋀a b. ⟦singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q a); singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q b)⟧ ⟹ singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q (a - b))›*)
case (one m) (*‹m ∈ singular_simplex_set q (subtopology S T)›*)
show "?case"
(*goal: ‹singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q (frag_of m))›*)
apply (simp add: pr_def (*‹pr ≡ λq c. ∑i≤q. frag_cmul ((- 1) ^ i) (frag_of (simplex_map (Suc q) (λz. h (z 0, c (z ∘ Suc))) (simp q i)))›*))
(*goal: ‹singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q (frag_of m))›*)
proof (intro singular_chain_cmul (*‹singular_chain ?p ?X ?c ⟹ singular_chain ?p ?X (frag_cmul ?a ?c)›*) singular_chain_sum (*‹(⋀i. i ∈ ?I ⟹ singular_chain ?p ?X (?f i)) ⟹ singular_chain ?p ?X (sum ?f ?I)›*))
(*goal: ‹⋀i. i ∈ {..q} ⟹ singular_chain (Suc q) (subtopology U V) (frag_of (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i)))›*)
fix i :: nat
assume "i ∈ {..q}" (*‹(i::nat) ∈ {..q::nat}›*)
define X where "X = subtopology (powertop_real UNIV) {x. x 0 ∈ {0..1} ∧ (x ∘ Suc) ∈ standard_simplex q}"
show "singular_chain (Suc q) (subtopology U V)
(frag_of (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i)))"
unfolding singular_chain_of
(*goal: ‹singular_simplex (Suc q) (subtopology U V) (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))›*)
proof (rule singular_simplex_simplex_map (*‹⟦singular_simplex ?p ?X ?f; continuous_map ?X ?X' ?g⟧ ⟹ singular_simplex ?p ?X' (simplex_map ?p ?g ?f)›*))
(*goals:
1. ‹singular_simplex (Suc (q::nat)) (?X::(nat ⇒ real) topology) ((simp::nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real) q (i::nat))›
2. ‹continuous_map (?X::(nat ⇒ real) topology) (subtopology (U::'b topology) (V::'b set)) (λz::nat ⇒ real. (h::real × 'a ⇒ 'b) (z (0::nat), (m::(nat ⇒ real) ⇒ 'a) (z ∘ Suc)))›*)
show "singular_simplex (Suc q) X (simp q i)"
unfolding X_def
(*goal: ‹singular_simplex (Suc q) (subtopology (powertop_real UNIV) {x. x 0 ∈ {0..1} ∧ x ∘ Suc ∈ standard_simplex q}) (simp q i)›*)
using ‹i ∈ {..q}› (*‹i ∈ {..q}›*) simplicial_imp_singular_simplex (*‹simplicial_simplex ?p ?S ?f ⟹ singular_simplex ?p (subtopology (powertop_real UNIV) ?S) ?f›*) ss_ss (*‹?i ≤ ?q ⟹ simplicial_simplex (Suc ?q) {x. x 0 ∈ {0..1} ∧ x ∘ Suc ∈ standard_simplex ?q} (simp ?q ?i)›*) by blast
have 0: "continuous_map X (top_of_set {0..1}) (λx. x 0)"
unfolding continuous_map_in_subtopology topspace_subtopology X_def
(*goal: ‹continuous_map (subtopology (powertop_real UNIV) {x::nat ⇒ real. x (0::nat) ∈ {0::real..1::real} ∧ x ∘ Suc ∈ standard_simplex (q::nat)}) euclideanreal (λx::nat ⇒ real. x (0::nat)) ∧ (λx::nat ⇒ real. x (0::nat)) ` (topspace (powertop_real UNIV) ∩ {x::nat ⇒ real. x (0::nat) ∈ {0::real..1::real} ∧ x ∘ Suc ∈ standard_simplex q}) ⊆ {0::real..1::real}›*)
by (auto intro: continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*) continuous_map_from_subtopology (*‹continuous_map ?X ?Y ?f ⟹ continuous_map (subtopology ?X ?S) ?Y ?f›*))
have 1: "continuous_map X (subtopology S T) (m ∘ (λx j. x (Suc j)))"
proof (rule continuous_map_compose (*‹⟦continuous_map ?X ?X' ?f; continuous_map ?X' ?X'' ?g⟧ ⟹ continuous_map ?X ?X'' (?g ∘ ?f)›*))
(*goals:
1. ‹continuous_map X ?X' (λx j. x (Suc j))›
2. ‹continuous_map ?X' (subtopology S T) m›*)
have "continuous_map (powertop_real UNIV) (powertop_real UNIV) (λx j. x (Suc j))"
by (auto intro: continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*))
then show "continuous_map X (subtopology (powertop_real UNIV) (standard_simplex q)) (λx j. x (Suc j))"
unfolding X_def o_def
(*goal: ‹continuous_map (subtopology (powertop_real UNIV) {x. x 0 ∈ {0..1} ∧ (λxa. x (Suc xa)) ∈ standard_simplex q}) (subtopology (powertop_real UNIV) (standard_simplex q)) (λx j. x (Suc j))›*)
by (auto simp: continuous_map_in_subtopology (*‹continuous_map ?X (subtopology ?X' ?S) ?f = (continuous_map ?X ?X' ?f ∧ ?f ` topspace ?X ⊆ ?S)›*) intro: continuous_map_from_subtopology (*‹continuous_map ?X ?Y ?f ⟹ continuous_map (subtopology ?X ?S) ?Y ?f›*) continuous_map_product_projection (*‹?k ∈ ?I ⟹ continuous_map (product_topology ?X ?I) (?X ?k) (λx. x ?k)›*))
show "continuous_map (subtopology (powertop_real UNIV) (standard_simplex q)) (subtopology S T) m"
using one (*‹m ∈ singular_simplex_set q (subtopology S T)›*) continuous_map_into_fulltopology (*‹continuous_map ?X (subtopology ?Y ?T) ?f ⟹ continuous_map ?X ?Y ?f›*) by (auto simp: singular_simplex_def (*‹singular_simplex ?p ?X ?f ≡ continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f ∧ ?f ∈ extensional (standard_simplex ?p)›*))
qed
have "continuous_map X (subtopology U V) (h ∘ (λz. (z 0, m (z ∘ Suc))))"
proof (rule continuous_map_compose (*‹⟦continuous_map ?X ?X' ?f; continuous_map ?X' ?X'' ?g⟧ ⟹ continuous_map ?X ?X'' (?g ∘ ?f)›*))
(*goals:
1. ‹continuous_map X ?X' (λz. (z 0, m (z ∘ Suc)))›
2. ‹continuous_map ?X' (subtopology U V) h›*)
show "continuous_map X (prod_topology (top_of_set {0..1::real}) (subtopology S T)) (λz. (z 0, m (z ∘ Suc)))"
using "0" (*‹continuous_map X (top_of_set {0..1}) (λx. x 0)›*) "1" (*‹continuous_map X (subtopology S T) (m ∘ (λx j. x (Suc j)))›*) by (simp add: continuous_map_pairwise (*‹continuous_map ?Z (prod_topology ?X ?Y) ?f = (continuous_map ?Z ?X (fst ∘ ?f) ∧ continuous_map ?Z ?Y (snd ∘ ?f))›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*))
have "continuous_map (subtopology (prod_topology euclideanreal S) ({0..1} × T)) U h"
by (metis conth (*‹continuous_map (prod_topology (top_of_set {0..1}) S) U h›*) continuous_map_from_subtopology (*‹continuous_map ?X ?Y ?f ⟹ continuous_map (subtopology ?X ?S) ?Y ?f›*) subtopology_Times (*‹subtopology (prod_topology ?X ?Y) (?S × ?T) = prod_topology (subtopology ?X ?S) (subtopology ?Y ?T)›*) subtopology_topspace (*‹subtopology ?U (topspace ?U) = ?U›*))
with hV (*‹⟦(0::real) ≤ (?t::real); ?t ≤ (1::real); (?x::'a::type) ∈ (T::'a::type set)⟧ ⟹ (h::real × 'a::type ⇒ 'b::type) (?t, ?x) ∈ (V::'b::type set)›*) show "continuous_map (prod_topology (top_of_set {0..1::real}) (subtopology S T)) (subtopology U V) h"
by (force simp: topspace_subtopology (*‹topspace (subtopology (?U::?'a::type topology) (?V::?'a::type set)) = topspace ?U ∩ ?V›*) continuous_map_in_subtopology (*‹continuous_map (?X::?'a::type topology) (subtopology (?X'::?'b::type topology) (?S::?'b::type set)) (?f::?'a::type ⇒ ?'b::type) = (continuous_map ?X ?X' ?f ∧ ?f ` topspace ?X ⊆ ?S)›*) subtopology_restrict (*‹subtopology (?X::?'a::type topology) (topspace ?X ∩ (?S::?'a::type set)) = subtopology ?X ?S›*) subtopology_Times (*‹subtopology (prod_topology (?X::?'a::type topology) (?Y::?'b::type topology)) ((?S::?'a::type set) × (?T::?'b::type set)) = prod_topology (subtopology ?X ?S) (subtopology ?Y ?T)›*))
qed
then show "continuous_map X (subtopology U V) (λz. h (z 0, m (z ∘ Suc)))"
by (simp add: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*))
qed
qed
next
(*goals:
1. ‹singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q 0)›
2. ‹⋀a b. ⟦singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q a); singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q b)⟧ ⟹ singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q (a - b))›*)
case (diff a b) (*‹singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q a)› ‹singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q b)›*)
then show "?case"
(*goal: ‹singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q (a - b))›*)
by (metis comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*) singular_chain_diff (*‹⟦singular_chain ?p ?X ?a; singular_chain ?p ?X ?b⟧ ⟹ singular_chain ?p ?X (?a - ?b)›*))
qed (auto)
(*solved the remaining goal: ‹singular_chain (Suc q) (subtopology U V) ((frag_extend ∘ pr) q 0)›*)
next
(*goal: ‹⋀q c. ⟦⋀prism. ⟦⋀q. prism q 0 = 0; ⋀q c. singular_chain q S c ⟹ singular_chain (Suc q) U (prism q c); ⋀q c. singular_chain q (subtopology S T) c ⟹ singular_chain (Suc q) (subtopology U V) (prism q c); ⋀q c. singular_chain q S c ⟹ chain_boundary (Suc q) (prism q c) = chain_map q g c - chain_map q f c - prism (q - 1) (chain_boundary q c)⟧ ⟹ thesis; singular_chain q S c⟧ ⟹ chain_boundary (Suc q) ((frag_extend ∘ pr) q c) = chain_map q g c - chain_map q f c - (frag_extend ∘ pr) (q - 1) (chain_boundary q c)›*)
show "chain_boundary (Suc q) ((frag_extend ∘ pr) q c) =
chain_map q g c - chain_map q f c - (frag_extend ∘ pr) (q -1) (chain_boundary q c)" if "singular_chain q S c" for q and c
using that[unfolded singular_chain_def] (*‹Poly_Mapping.keys c ⊆ singular_simplex_set q S›*) proof (induction c rule: frag_induction (*‹⟦Poly_Mapping.keys (?c::?'a ⇒₀ int) ⊆ (?S::?'a set); (?P::(?'a ⇒₀ int) ⇒ bool) (0::?'a ⇒₀ int); ⋀x::?'a. x ∈ ?S ⟹ ?P (frag_of x); ⋀(a::?'a ⇒₀ int) b::?'a ⇒₀ int. ⟦?P a; ?P b⟧ ⟹ ?P (a - b)⟧ ⟹ ?P ?c›*))
(*goals:
1. ‹chain_boundary (Suc q) ((frag_extend ∘ pr) q 0) = chain_map q g 0 - chain_map q f 0 - (frag_extend ∘ pr) (q - 1) (chain_boundary q 0)›
2. ‹⋀x. x ∈ singular_simplex_set q S ⟹ chain_boundary (Suc q) ((frag_extend ∘ pr) q (frag_of x)) = chain_map q g (frag_of x) - chain_map q f (frag_of x) - (frag_extend ∘ pr) (q - 1) (chain_boundary q (frag_of x))›
3. ‹⋀a b. ⟦chain_boundary (Suc q) ((frag_extend ∘ pr) q a) = chain_map q g a - chain_map q f a - (frag_extend ∘ pr) (q - 1) (chain_boundary q a); chain_boundary (Suc q) ((frag_extend ∘ pr) q b) = chain_map q g b - chain_map q f b - (frag_extend ∘ pr) (q - 1) (chain_boundary q b)⟧ ⟹ chain_boundary (Suc q) ((frag_extend ∘ pr) q (a - b)) = chain_map q g (a - b) - chain_map q f (a - b) - (frag_extend ∘ pr) (q - 1) (chain_boundary q (a - b))›*)
case (one m) (*‹m ∈ singular_simplex_set q S›*)
have eq2: "Sigma S T = (λi. (i,i)) ` {i ∈ S. i ∈ T i} ∪ (Sigma S (λi. T i - {i}))" for S :: "nat set" and T
by force
have 1: "(∑(i,j)∈(λi. (i, i)) ` {i. i ≤ q ∧ i ≤ Suc q}.
frag_cmul (((-1) ^ i) * (-1) ^ j)
(frag_of
(singular_face (Suc q) j
(simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i)))))
+ (∑(i,j)∈(λi. (i, i)) ` {i. i ≤ q}.
frag_cmul (- ((-1) ^ i * (-1) ^ j))
(frag_of
(singular_face (Suc q) (Suc j)
(simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i)))))
= frag_of (simplex_map q g m) - frag_of (simplex_map q f m)"
proof (-)
(*goal: ‹(∑(i, j)∈(λi. (i, i)) ` {i. i ≤ q ∧ i ≤ Suc q}. frag_cmul ((- 1) ^ i * (- 1) ^ j) (frag_of (singular_face (Suc q) j (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) + (∑(i, j)∈(λi. (i, i)) ` {i. i ≤ q}. frag_cmul (- ((- 1) ^ i * (- 1) ^ j)) (frag_of (singular_face (Suc q) (Suc j) (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) = frag_of (simplex_map q g m) - frag_of (simplex_map q f m)›*)
have "restrict ((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q 0 ∘ simplical_face 0)) (standard_simplex q)
= restrict (g ∘ m) (standard_simplex q)"
proof (rule restrict_ext (*‹(⋀x. x ∈ ?A ⟹ ?f x = ?g x) ⟹ restrict ?f ?A = restrict ?g ?A›*))
(*goal: ‹⋀x. x ∈ standard_simplex q ⟹ ((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q 0 ∘ simplical_face 0)) x = (g ∘ m) x›*)
fix x
assume x: "x ∈ standard_simplex q" (*‹(x::nat ⇒ real) ∈ standard_simplex (q::nat)›*)
have "(∑j≤Suc q. if j = 0 then 0 else x (j - Suc 0)) = (∑j≤q. x j)"
by (simp add: sum.atMost_Suc_shift (*‹sum ?g {..Suc ?n} = ?g 0 + (∑i≤?n. ?g (Suc i))›*))
with x (*‹x ∈ standard_simplex q›*) have "simp q 0 (simplical_face 0 x) 0 = 1"
apply (simp add: oriented_simplex_def (*‹oriented_simplex ?p ?l ≡ λx∈standard_simplex ?p. λi. ∑j≤?p. ?l j i * x j›*) simp_def (*‹simp ≡ λq i. oriented_simplex (Suc q) (λj. if j ≤ i then vv j else ww (j - 1))›*) simplical_face_in_standard_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p; ?x ∈ standard_simplex (?p - Suc 0)⟧ ⟹ simplical_face ?k ?x ∈ standard_simplex ?p›*))
(*goal: ‹(simp::nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real) (q::nat) (0::nat) (simplical_face (0::nat) (x::nat ⇒ real)) (0::nat) = (1::real)›*)
by (simp add: simplical_face_def (*‹simplical_face ?k ?x ≡ λi. if i < ?k then ?x i else if i = ?k then 0 else ?x (i - 1)›*) if_distrib (*‹?f (if ?c then ?x else ?y) = (if ?c then ?f ?x else ?f ?y)›*) ww_def (*‹ww ≡ λj i. if i = 0 ∨ i = Suc j then 1 else 0›*) standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
moreover have "(λn. if n ≤ q then x n else 0) = x"
using standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*) x (*‹x ∈ standard_simplex q›*) by auto
then have "(λn. simp q 0 (simplical_face 0 x) (Suc n)) = x"
unfolding oriented_simplex_def simp_def ww_def
(*goal: ‹(λn. (λx∈standard_simplex (Suc q). λi. ∑j≤Suc q. (if j ≤ 0 then vv j else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) i * x j) (simplical_face 0 x) (Suc n)) = x›*)
using x (*‹x ∈ standard_simplex q›*) apply (simp add: simplical_face_in_standard_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p; ?x ∈ standard_simplex (?p - Suc 0)⟧ ⟹ simplical_face ?k ?x ∈ standard_simplex ?p›*))
(*goal: ‹(λn. (λx∈standard_simplex (Suc q). λi. ∑j≤Suc q. (if j ≤ 0 then vv j else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) i * x j) (simplical_face 0 x) (Suc n)) = x›*)
apply (simp add: simplical_face_def (*‹simplical_face ?k ?x ≡ λi. if i < ?k then ?x i else if i = ?k then 0 else ?x (i - 1)›*) if_distrib (*‹?f (if ?c then ?x else ?y) = (if ?c then ?f ?x else ?f ?y)›*))
(*goal: ‹⟦(λn::nat. if n ≤ (q::nat) then (x::nat ⇒ real) n else (0::real)) = x; x ∈ standard_simplex q⟧ ⟹ (λn::nat. ∑j::nat≤Suc q. (if j = (0::nat) then (vv::nat ⇒ nat ⇒ real) j else (λi::nat. if i = (0::nat) ∨ i = Suc (j - (1::nat)) then 1::real else (0::real))) (Suc n) * simplical_face (0::nat) x j) = x›*)
by (simp add: if_distribR (*‹(if ?b::bool then ?f::?'b ⇒ ?'a else (?g::?'b ⇒ ?'a)) (?x::?'b) = (if ?b then ?f ?x else ?g ?x)›*) if_distrib (*‹(?f::?'b ⇒ ?'a) (if ?c::bool then ?x::?'b else (?y::?'b)) = (if ?c then ?f ?x else ?f ?y)›*) cong: if_cong (*‹⟦(?b::bool) = (?c::bool); ?c ⟹ (?x::?'a) = (?u::?'a); ¬ ?c ⟹ (?y::?'a) = (?v::?'a)⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
ultimately show "((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q 0 ∘ simplical_face 0)) x = (g ∘ m) x"
by (simp add: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) h1 (*‹h (1, ?x) = g ?x›*))
qed
then have a: "frag_of (singular_face (Suc q) 0 (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q 0)))
= frag_of (simplex_map q g m)"
apply (simp add: singular_face_simplex_map (*‹⟦(1::nat) ≤ (?p::nat); (?k::nat) ≤ ?p⟧ ⟹ singular_face ?p ?k (simplex_map ?p (?f::?'b::type ⇒ ?'a::type) (?c::(nat ⇒ real) ⇒ ?'b::type)) = simplex_map (?p - Suc (0::nat)) ?f (?c ∘ simplical_face ?k)›*))
(*goal: ‹frag_of (singular_face (Suc q) 0 (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q 0))) = frag_of (simplex_map q g m)›*)
by (simp add: simplex_map_def (*‹simplex_map ?p ?g ?c ≡ restrict (?g ∘ ?c) (standard_simplex ?p)›*))
have "restrict ((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q q ∘ simplical_face (Suc q))) (standard_simplex q)
= restrict (f ∘ m) (standard_simplex q)"
proof (rule restrict_ext (*‹(⋀x. x ∈ ?A ⟹ ?f x = ?g x) ⟹ restrict ?f ?A = restrict ?g ?A›*))
(*goal: ‹⋀x. x ∈ standard_simplex q ⟹ ((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q q ∘ simplical_face (Suc q))) x = (f ∘ m) x›*)
fix x
assume x: "x ∈ standard_simplex q" (*‹(x::nat ⇒ real) ∈ standard_simplex (q::nat)›*)
then have "simp q q (simplical_face (Suc q) x) 0 = 0"
unfolding oriented_simplex_def simp_def
(*goal: ‹(λx∈standard_simplex (Suc q). λi. ∑j≤Suc q. (if j ≤ q then vv j else ww (j - 1)) i * x j) (simplical_face (Suc q) x) 0 = 0›*)
apply (simp add: simplical_face_in_standard_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p; ?x ∈ standard_simplex (?p - Suc 0)⟧ ⟹ simplical_face ?k ?x ∈ standard_simplex ?p›*) sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*))
(*goal: ‹(λx::nat ⇒ real∈standard_simplex (Suc q). λi::nat. ∑j::nat≤Suc q. (if j ≤ (q::nat) then (vv::nat ⇒ nat ⇒ real) j else (ww::nat ⇒ nat ⇒ real) (j - (1::nat))) i * x j) (simplical_face (Suc q) (x::nat ⇒ real)) (0::nat) = (0::real)›*)
by (simp add: simplical_face_def (*‹simplical_face ?k ?x ≡ λi. if i < ?k then ?x i else if i = ?k then 0 else ?x (i - 1)›*) vv_def (*‹vv ≡ λj i. if i = Suc j then 1 else 0›*))
moreover have "(λn. simp q q (simplical_face (Suc q) x) (Suc n)) = x"
unfolding oriented_simplex_def simp_def vv_def
(*goal: ‹(λn. (λx∈standard_simplex (Suc q). λi. ∑j≤Suc q. (if j ≤ q then λi. if i = Suc j then 1 else 0 else ww (j - 1)) i * x j) (simplical_face (Suc q) x) (Suc n)) = x›*)
using x (*‹x ∈ standard_simplex q›*) apply (simp add: simplical_face_in_standard_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p; ?x ∈ standard_simplex (?p - Suc 0)⟧ ⟹ simplical_face ?k ?x ∈ standard_simplex ?p›*))
(*goal: ‹(λn. (λx∈standard_simplex (Suc q). λi. ∑j≤Suc q. (if j ≤ q then λi. if i = Suc j then 1 else 0 else ww (j - 1)) i * x j) (simplical_face (Suc q) x) (Suc n)) = x›*)
by (force simp: standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*) simplical_face_def (*‹simplical_face ?k ?x ≡ λi. if i < ?k then ?x i else if i = ?k then 0 else ?x (i - 1)›*) if_distribR (*‹(if ?b then ?f else ?g) ?x = (if ?b then ?f ?x else ?g ?x)›*) if_distrib [of "λx. x * _"] (*‹(if ?c then ?x else ?y) * ?uu5 = (if ?c then ?x * ?uu5 else ?y * ?uu5)›*) sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
ultimately show "((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q q ∘ simplical_face (Suc q))) x = (f ∘ m) x"
by (simp add: o_def (*‹(?f::?'b ⇒ ?'c) ∘ (?g::?'a ⇒ ?'b) = (λx::?'a. ?f (?g x))›*) h0 (*‹(h::real × 'a ⇒ 'b) (0::real, ?x::'a) = (f::'a ⇒ 'b) ?x›*))
qed
then have b: "frag_of (singular_face (Suc q) (Suc q)
(simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q q)))
= frag_of (simplex_map q f m)"
apply (simp add: singular_face_simplex_map (*‹⟦1 ≤ ?p; ?k ≤ ?p⟧ ⟹ singular_face ?p ?k (simplex_map ?p ?f ?c) = simplex_map (?p - Suc 0) ?f (?c ∘ simplical_face ?k)›*))
(*goal: ‹frag_of (singular_face (Suc q) (Suc q) (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q q))) = frag_of (simplex_map q f m)›*)
by (simp add: simplex_map_def (*‹simplex_map ?p ?g ?c ≡ restrict (?g ∘ ?c) (standard_simplex ?p)›*))
have sfeq: "simplex_map q (λz. h (z 0, m (z ∘ Suc))) (simp q (Suc i) ∘ simplical_face (Suc i))
= simplex_map q (λz. h (z 0, m (z ∘ Suc))) (simp q i ∘ simplical_face (Suc i))" if "i < q" for i
unfolding simplex_map_def
(*goal: ‹restrict ((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q (Suc i) ∘ simplical_face (Suc i))) (standard_simplex q) = restrict ((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q i ∘ simplical_face (Suc i))) (standard_simplex q)›*)
proof (rule restrict_ext (*‹(⋀x. x ∈ ?A ⟹ ?f x = ?g x) ⟹ restrict ?f ?A = restrict ?g ?A›*))
(*goal: ‹⋀x. x ∈ standard_simplex q ⟹ ((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q (Suc i) ∘ simplical_face (Suc i))) x = ((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q i ∘ simplical_face (Suc i))) x›*)
fix x
assume "x ∈ standard_simplex q" (*‹(x::nat ⇒ real) ∈ standard_simplex (q::nat)›*)
then have "(simp q (Suc i) ∘ simplical_face (Suc i)) x = (simp q i ∘ simplical_face (Suc i)) x"
unfolding oriented_simplex_def simp_def simplical_face_def
(*goal: ‹((λx∈standard_simplex (Suc q). λia. ∑j≤Suc q. (if j ≤ Suc i then vv j else ww (j - 1)) ia * x j) ∘ (λx ia. if ia < Suc i then x ia else if ia = Suc i then 0 else x (ia - 1))) x = ((λx∈standard_simplex (Suc q). λia. ∑j≤Suc q. (if j ≤ i then vv j else ww (j - 1)) ia * x j) ∘ (λx ia. if ia < Suc i then x ia else if ia = Suc i then 0 else x (ia - 1))) x›*)
by (force intro: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
then show "((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q (Suc i) ∘ simplical_face (Suc i))) x
= ((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q i ∘ simplical_face (Suc i))) x"
by simp
qed
have eqq: "{i. i ≤ q ∧ i ≤ Suc q} = {..q}"
by force
have qeq: "{..q} = insert 0 ((λi. Suc i) ` {i. i < q})" "{i. i ≤ q} = insert q {i. i < q}"
using le_imp_less_Suc (*‹?m ≤ ?n ⟹ ?m < Suc ?n›*) less_Suc_eq_0_disj (*‹(?m < Suc ?n) = (?m = 0 ∨ (∃j. ?m = Suc j ∧ j < ?n))›*) apply -
(*goals:
1. ‹⟦⋀(m::nat) n::nat. m ≤ n ⟹ m < Suc n; ⋀(m::nat) n::nat. (m < Suc n) = (m = (0::nat) ∨ (∃j::nat. m = Suc j ∧ j < n))⟧ ⟹ {..q::nat} = insert (0::nat) (Suc ` {i::nat. i < q})›
2. ‹⟦⋀(m::nat) n::nat. m ≤ n ⟹ m < Suc n; ⋀(m::nat) n::nat. (m < Suc n) = (m = (0::nat) ∨ (∃j::nat. m = Suc j ∧ j < n))⟧ ⟹ {i::nat. i ≤ (q::nat)} = insert q {i::nat. i < q}›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
show "?thesis"
(*goal: ‹(∑(i::nat, j::nat)∈(λi::nat. (i, i)) ` {i::nat. i ≤ q ∧ i ≤ Suc q}. frag_cmul ((- (1::int)) ^ i * (- (1::int)) ^ j) (frag_of (singular_face (Suc (q::nat)) j (simplex_map (Suc q) (λz::nat ⇒ real. (h::real × 'a ⇒ 'b) (z (0::nat), (m::(nat ⇒ real) ⇒ 'a) (z ∘ Suc))) ((simp::nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real) q i))))) + (∑(i::nat, j::nat)∈(λi::nat. (i, i)) ` {i::nat. i ≤ q}. frag_cmul (- ((- (1::int)) ^ i * (- (1::int)) ^ j)) (frag_of (singular_face (Suc q) (Suc j) (simplex_map (Suc q) (λz::nat ⇒ real. h (z (0::nat), m (z ∘ Suc))) (simp q i))))) = frag_of (simplex_map q (g::'a ⇒ 'b) m) - frag_of (simplex_map q (f::'a ⇒ 'b) m)›*)
using a (*‹frag_of (singular_face (Suc q) 0 (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q 0))) = frag_of (simplex_map q g m)›*) b (*‹frag_of (singular_face (Suc q) (Suc q) (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q q))) = frag_of (simplex_map q f m)›*) apply (simp add: sum.reindex (*‹inj_on (?h::?'b ⇒ ?'c) (?A::?'b set) ⟹ sum (?g::?'c ⇒ ?'a) (?h ` ?A) = sum (?g ∘ ?h) ?A›*) inj_on_def (*‹inj_on (?f::?'a ⇒ ?'b) (?A::?'a set) = (∀x::?'a∈?A. ∀y::?'a∈?A. ?f x = ?f y ⟶ x = y)›*) eqq (*‹{i::nat. i ≤ (q::nat) ∧ i ≤ Suc q} = {..q}›*))
(*goal: ‹(∑(i, j)∈(λi. (i, i)) ` {i. i ≤ q ∧ i ≤ Suc q}. frag_cmul ((- 1) ^ i * (- 1) ^ j) (frag_of (singular_face (Suc q) j (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) + (∑(i, j)∈(λi. (i, i)) ` {i. i ≤ q}. frag_cmul (- ((- 1) ^ i * (- 1) ^ j)) (frag_of (singular_face (Suc q) (Suc j) (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) = frag_of (simplex_map q g m) - frag_of (simplex_map q f m)›*)
by (simp add: qeq (*‹{..q} = insert 0 (Suc ` {i. i < q})› ‹{i. i ≤ q} = insert q {i. i < q}›*) sum.insert_if (*‹finite ?A ⟹ sum ?g (insert ?x ?A) = (if ?x ∈ ?A then sum ?g ?A else ?g ?x + sum ?g ?A)›*) sum.reindex (*‹inj_on ?h ?A ⟹ sum ?g (?h ` ?A) = sum (?g ∘ ?h) ?A›*) sum_negf (*‹(∑x∈?A. - ?f x) = - sum ?f ?A›*) singular_face_simplex_map (*‹⟦1 ≤ ?p; ?k ≤ ?p⟧ ⟹ singular_face ?p ?k (simplex_map ?p ?f ?c) = simplex_map (?p - Suc 0) ?f (?c ∘ simplical_face ?k)›*) sfeq (*‹?i < q ⟹ simplex_map q (λz. h (z 0, m (z ∘ Suc))) (simp q (Suc ?i) ∘ simplical_face (Suc ?i)) = simplex_map q (λz. h (z 0, m (z ∘ Suc))) (simp q ?i ∘ simplical_face (Suc ?i))›*))
qed
have 2: "(∑(i,j)∈(SIGMA i:{..q}. {0..min (Suc q) i} - {i}).
frag_cmul ((-1) ^ i * (-1) ^ j)
(frag_of
(singular_face (Suc q) j
(simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i)))))
+ (∑(i,j)∈(SIGMA i:{..q}. {i..q} - {i}).
frag_cmul (- ((-1) ^ i * (-1) ^ j))
(frag_of
(singular_face (Suc q) (Suc j)
(simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i)))))
= - frag_extend (pr (q - Suc 0)) (chain_boundary q (frag_of m))"
proof (cases "q=0")
(*goals:
1. ‹q = 0 ⟹ (∑(i, j)∈(SIGMA i:{..q}. {0..min (Suc q) i} - {i}). frag_cmul ((- 1) ^ i * (- 1) ^ j) (frag_of (singular_face (Suc q) j (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) + (∑(i, j)∈(SIGMA i:{..q}. {i..q} - {i}). frag_cmul (- ((- 1) ^ i * (- 1) ^ j)) (frag_of (singular_face (Suc q) (Suc j) (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) = - frag_extend (pr (q - Suc 0)) (chain_boundary q (frag_of m))›
2. ‹q ≠ 0 ⟹ (∑(i, j)∈(SIGMA i:{..q}. {0..min (Suc q) i} - {i}). frag_cmul ((- 1) ^ i * (- 1) ^ j) (frag_of (singular_face (Suc q) j (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) + (∑(i, j)∈(SIGMA i:{..q}. {i..q} - {i}). frag_cmul (- ((- 1) ^ i * (- 1) ^ j)) (frag_of (singular_face (Suc q) (Suc j) (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) = - frag_extend (pr (q - Suc 0)) (chain_boundary q (frag_of m))›*)
case True (*‹q = 0›*)
then show "?thesis"
(*goal: ‹(∑(i, j)∈(SIGMA i:{..q}. {0..min (Suc q) i} - {i}). frag_cmul ((- 1) ^ i * (- 1) ^ j) (frag_of (singular_face (Suc q) j (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) + (∑(i, j)∈(SIGMA i:{..q}. {i..q} - {i}). frag_cmul (- ((- 1) ^ i * (- 1) ^ j)) (frag_of (singular_face (Suc q) (Suc j) (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) = - frag_extend (pr (q - Suc 0)) (chain_boundary q (frag_of m))›*)
by (simp add: chain_boundary_def (*‹chain_boundary ?p ?c ≡ if ?p = 0 then 0 else frag_extend (λf. ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k f))) ?c›*) flip: sum.Sigma (*‹⟦finite ?A; ∀x∈?A. finite (?B x)⟧ ⟹ (∑x∈?A. sum (?g x) (?B x)) = (∑(x, y)∈Sigma ?A ?B. ?g x y)›*))
next
(*goal: ‹q ≠ 0 ⟹ (∑(i, j)∈(SIGMA i:{..q}. {0..min (Suc q) i} - {i}). frag_cmul ((- 1) ^ i * (- 1) ^ j) (frag_of (singular_face (Suc q) j (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) + (∑(i, j)∈(SIGMA i:{..q}. {i..q} - {i}). frag_cmul (- ((- 1) ^ i * (- 1) ^ j)) (frag_of (singular_face (Suc q) (Suc j) (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) = - frag_extend (pr (q - Suc 0)) (chain_boundary q (frag_of m))›*)
case False (*‹(q::nat) ≠ (0::nat)›*)
have eq: "{..q - Suc 0} × {..q} = Sigma {..q - Suc 0} (λi. {0..min q i}) ∪ Sigma {..q} (λi. {i<..q})"
by force
have I: "(∑(i,j)∈(SIGMA i:{..q}. {0..min (Suc q) i} - {i}).
frag_cmul ((-1) ^ (i + j))
(frag_of
(singular_face (Suc q) j
(simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i)))))
= (∑(i,j)∈(SIGMA i:{..q - Suc 0}. {0..min q i}).
frag_cmul (- ((-1) ^ (j + i)))
(frag_of
(simplex_map q (λz. h (z 0, singular_face q j m (z ∘ Suc)))
(simp (q - Suc 0) i))))"
proof (-)
(*goal: ‹(∑(i, j)∈(SIGMA i:{..q}. {0..min (Suc q) i} - {i}). frag_cmul ((- 1) ^ (i + j)) (frag_of (singular_face (Suc q) j (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) = (∑(i, j)∈(SIGMA i:{..q - Suc 0}. {0..min q i}). frag_cmul (- ((- 1) ^ (j + i))) (frag_of (simplex_map q (λz. h (z 0, singular_face q j m (z ∘ Suc))) (simp (q - Suc 0) i))))›*)
have seq: "simplex_map q (λz. h (z 0, singular_face q j m (z ∘ Suc)))
(simp (q - Suc 0) (i - Suc 0))
= simplex_map q (λz. h (z 0, m (z ∘ Suc))) (simp q i ∘ simplical_face j)" if ij: "i ≤ q" "j ≠ i" "j ≤ i" for i and j
unfolding simplex_map_def
(*goal: ‹restrict ((λz. h (z 0, singular_face q j m (z ∘ Suc))) ∘ simp (q - Suc 0) (i - Suc 0)) (standard_simplex q) = restrict ((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q i ∘ simplical_face j)) (standard_simplex q)›*)
proof (rule restrict_ext (*‹(⋀x. x ∈ ?A ⟹ ?f x = ?g x) ⟹ restrict ?f ?A = restrict ?g ?A›*))
(*goal: ‹⋀x. x ∈ standard_simplex q ⟹ ((λz. h (z 0, singular_face q j m (z ∘ Suc))) ∘ simp (q - Suc 0) (i - Suc 0)) x = ((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q i ∘ simplical_face j)) x›*)
fix x
assume x: "x ∈ standard_simplex q" (*‹(x::nat ⇒ real) ∈ standard_simplex (q::nat)›*)
have "i > 0"
using that (*‹i ≤ q› ‹j ≠ i› ‹j ≤ i›*) by force
then have iq: "i - Suc 0 ≤ q - Suc 0"
using ‹i ≤ q› (*‹i ≤ q›*) False (*‹q ≠ 0›*) by simp
have q0_eq: "{..Suc q} = insert 0 (Suc ` {..q})"
by (auto simp: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*) gr0_conv_Suc (*‹(0 < ?n) = (∃m. ?n = Suc m)›*))
have "α": "simp (q - Suc 0) (i - Suc 0) x 0 = simp q i (simplical_face j x) 0"
using False (*‹(q::nat) ≠ (0::nat)›*) x (*‹(x::nat ⇒ real) ∈ standard_simplex (q::nat)›*) ij (*‹i ≤ q› ‹j ≠ i› ‹j ≤ i›*) unfolding oriented_simplex_def simp_def vv_def ww_def
(*goal: ‹(λx∈standard_simplex (Suc (q - Suc 0)). λia. ∑j≤Suc (q - Suc 0). (if j ≤ i - Suc 0 then λi. if i = Suc j then 1 else 0 else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) ia * x j) x 0 = (λx∈standard_simplex (Suc q). λia. ∑j≤Suc q. (if j ≤ i then λi. if i = Suc j then 1 else 0 else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) ia * x j) (simplical_face j x) 0›*)
apply (simp add: simplical_face_in_standard_simplex (*‹⟦1 ≤ ?p; ?k ≤ ?p; ?x ∈ standard_simplex (?p - Suc 0)⟧ ⟹ simplical_face ?k ?x ∈ standard_simplex ?p›*))
(*goal: ‹(λx∈standard_simplex (Suc (q - Suc 0)). λia. ∑j≤Suc (q - Suc 0). (if j ≤ i - Suc 0 then λi. if i = Suc j then 1 else 0 else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) ia * x j) x 0 = (λx∈standard_simplex (Suc q). λia. ∑j≤Suc q. (if j ≤ i then λi. if i = Suc j then 1 else 0 else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) ia * x j) (simplical_face j x) 0›*)
by (force simp: simplical_face_def (*‹simplical_face ?k ?x ≡ λi. if i < ?k then ?x i else if i = ?k then 0 else ?x (i - 1)›*) q0_eq (*‹{..Suc q} = insert 0 (Suc ` {..q})›*) sum.reindex (*‹inj_on ?h ?A ⟹ sum ?g (?h ` ?A) = sum (?g ∘ ?h) ?A›*) intro!: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
have "β": "simplical_face j (simp (q - Suc 0) (i - Suc 0) x ∘ Suc) = simp q i (simplical_face j x) ∘ Suc"
proof (standard)
(*goal: ‹⋀xa. simplical_face j (simp (q - Suc 0) (i - Suc 0) x ∘ Suc) xa = (simp q i (simplical_face j x) ∘ Suc) xa›*)
fix k
show "simplical_face j (simp (q - Suc 0) (i - Suc 0) x ∘ Suc) k
= (simp q i (simplical_face j x) ∘ Suc) k"
using False (*‹q ≠ 0›*) x (*‹x ∈ standard_simplex q›*) ij (*‹i ≤ q› ‹j ≠ i› ‹j ≤ i›*) unfolding oriented_simplex_def simp_def o_def vv_def ww_def
(*goal: ‹simplical_face j (λxa. (λx∈standard_simplex (Suc (q - Suc 0)). λia. ∑j≤Suc (q - Suc 0). (if j ≤ i - Suc 0 then λi. if i = Suc j then 1 else 0 else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) ia * x j) x (Suc xa)) k = (λx∈standard_simplex (Suc q). λia. ∑j≤Suc q. (if j ≤ i then λi. if i = Suc j then 1 else 0 else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) ia * x j) (simplical_face j x) (Suc k)›*)
apply (simp add: simplical_face_in_standard_simplex (*‹⟦(1::nat) ≤ (?p::nat); (?k::nat) ≤ ?p; (?x::nat ⇒ real) ∈ standard_simplex (?p - Suc (0::nat))⟧ ⟹ simplical_face ?k ?x ∈ standard_simplex ?p›*) if_distribR (*‹(if ?b::bool then ?f::?'b ⇒ ?'a else (?g::?'b ⇒ ?'a)) (?x::?'b) = (if ?b then ?f ?x else ?g ?x)›*))
(*goal: ‹simplical_face j (λxa. (λx∈standard_simplex (Suc (q - Suc 0)). λia. ∑j≤Suc (q - Suc 0). (if j ≤ i - Suc 0 then λi. if i = Suc j then 1 else 0 else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) ia * x j) x (Suc xa)) k = (λx∈standard_simplex (Suc q). λia. ∑j≤Suc q. (if j ≤ i then λi. if i = Suc j then 1 else 0 else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) ia * x j) (simplical_face j x) (Suc k)›*)
apply (simp add: simplical_face_def (*‹simplical_face ?k ?x ≡ λi. if i < ?k then ?x i else if i = ?k then 0 else ?x (i - 1)›*) if_distrib [of "λu. u * _"] (*‹(if ?c then ?x else ?y) * ?uu5 = (if ?c then ?x * ?uu5 else ?y * ?uu5)›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
(*goal: ‹⟦x ∈ standard_simplex q; i ≤ q; j ≠ i; j ≤ i⟧ ⟹ simplical_face j (λxa. ∑j≤q. (if j ≤ i - Suc 0 then if Suc xa = Suc j then 1 else 0 else if Suc xa = 0 ∨ Suc xa = Suc (j - 1) then 1 else 0) * x j) k = (∑ja≤Suc q. (if ja ≤ i then if Suc k = Suc ja then 1 else 0 else if Suc k = 0 ∨ Suc k = Suc (ja - 1) then 1 else 0) * simplical_face j x ja)›*)
apply (intro impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⟦x ∈ standard_simplex q; i ≤ q; j ≠ i; j ≤ i; k ≠ j; k < j⟧ ⟹ (∑j≤q. if j ≤ i - Suc 0 then if k = j then x j else 0 else if Suc k = j then x j else 0) = (∑j≤Suc q. if j ≤ i then if k = j then x j else 0 else 0)›
2. ‹⟦x ∈ standard_simplex q; i ≤ q; j ≠ i; j ≤ i; k ≠ j; ¬ k < j⟧ ⟹ (∑j≤q. if j ≤ i - Suc 0 then if k - Suc 0 = j then x j else 0 else if k = j then x j else 0) = (∑j≤Suc q. if j ≤ i then if k = j then x (j - Suc 0) else 0 else if Suc k = j then x (j - Suc 0) else 0)›
discuss goal 1*)
apply (force simp: sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*) intro: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*discuss goal 2*)
apply (force simp: q0_eq (*‹{..Suc q} = insert 0 (Suc ` {..q})›*) sum.reindex (*‹inj_on ?h ?A ⟹ sum ?g (?h ` ?A) = sum (?g ∘ ?h) ?A›*) intro!: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*proven 2 subgoals*) .
qed
have "simp (q - Suc 0) (i - Suc 0) x ∘ Suc ∈ standard_simplex (q - Suc 0)"
using ss_ss[OF iq] (*‹simplicial_simplex (Suc (q - Suc 0)) {x. x 0 ∈ {0..1} ∧ x ∘ Suc ∈ standard_simplex (q - Suc 0)} (simp (q - Suc 0) (i - Suc 0))›*) ‹i ≤ q› (*‹(i::nat) ≤ (q::nat)›*) False (*‹q ≠ 0›*) ‹i > 0› (*‹(0::nat) < (i::nat)›*) by (simp add: image_subset_iff (*‹((?f::?'b ⇒ ?'a) ` (?A::?'b set) ⊆ (?B::?'a set)) = (∀x::?'b∈?A. ?f x ∈ ?B)›*) simplicial_simplex (*‹simplicial_simplex (?p::nat) (?S::(?'a ⇒ real) set) (?f::(nat ⇒ real) ⇒ ?'a ⇒ real) = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l::nat ⇒ ?'a ⇒ real. ?f = oriented_simplex ?p l))›*) x (*‹(x::nat ⇒ real) ∈ standard_simplex (q::nat)›*))
then show "((λz. h (z 0, singular_face q j m (z ∘ Suc))) ∘ simp (q - Suc 0) (i - Suc 0)) x
= ((λz. h (z 0, m (z ∘ Suc))) ∘ (simp q i ∘ simplical_face j)) x"
by (simp add: singular_face_def (*‹singular_face ?p ?k ?f ≡ restrict (?f ∘ simplical_face ?k) (standard_simplex (?p - Suc 0))›*) α (*‹simp (q - Suc 0) (i - Suc 0) x 0 = simp q i (simplical_face j x) 0›*) β (*‹simplical_face j (simp (q - Suc 0) (i - Suc 0) x ∘ Suc) = simp q i (simplical_face j x) ∘ Suc›*))
qed
have [simp]: "(-1::int) ^ (i + j - Suc 0) = - ((-1) ^ (i + j))" if "i ≠ j" for i :: nat and j :: nat
proof (-)
(*goal: ‹(- 1) ^ (i + j - Suc 0) = - ((- 1) ^ (i + j))›*)
have "i + j > 0"
using that (*‹(i::nat) ≠ (j::nat)›*) by blast
then show "?thesis"
(*goal: ‹(- 1) ^ (i + j - Suc 0) = - ((- 1) ^ (i + j))›*)
by (metis (no_types, opaque_lifting) One_nat_def (*‹1 = Suc 0›*) Suc_diff_1 (*‹0 < ?n ⟹ Suc (?n - 1) = ?n›*) add.inverse_inverse (*‹- (- ?a) = ?a›*) mult.left_neutral (*‹1 * ?a = ?a›*) mult_minus_left (*‹- ?a * ?b = - (?a * ?b)›*) power_Suc (*‹?a ^ Suc ?n = ?a * ?a ^ ?n›*))
qed
show "?thesis"
(*goal: ‹(∑(i, j)∈(SIGMA i:{..q}. {0..min (Suc q) i} - {i}). frag_cmul ((- 1) ^ (i + j)) (frag_of (singular_face (Suc q) j (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) = (∑(i, j)∈(SIGMA i:{..q - Suc 0}. {0..min q i}). frag_cmul (- ((- 1) ^ (j + i))) (frag_of (simplex_map q (λz. h (z 0, singular_face q j m (z ∘ Suc))) (simp (q - Suc 0) i))))›*)
apply (rule sum.eq_general_inverses [where h = "λ(a,b). (a-1,b)" and k = "λ(a,b). (Suc a,b)"] (*‹⟦⋀y. y ∈ ?B ⟹ (case y of (a, b) ⇒ (Suc a, b)) ∈ ?A ∧ (case case y of (a, b) ⇒ (Suc a, b) of (a, b) ⇒ (a - 1, b)) = y; ⋀x. x ∈ ?A ⟹ (case x of (a, b) ⇒ (a - 1, b)) ∈ ?B ∧ (case case x of (a, b) ⇒ (a - 1, b) of (a, b) ⇒ (Suc a, b)) = x ∧ ?γ (case x of (a, b) ⇒ (a - 1, b)) = ?φ x⟧ ⟹ sum ?φ ?A = sum ?γ ?B›*))
(*goal: ‹(∑(i, j)∈(SIGMA i:{..q}. {0..min (Suc q) i} - {i}). frag_cmul ((- 1) ^ (i + j)) (frag_of (singular_face (Suc q) j (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) = (∑(i, j)∈(SIGMA i:{..q - Suc 0}. {0..min q i}). frag_cmul (- ((- 1) ^ (j + i))) (frag_of (simplex_map q (λz. h (z 0, singular_face q j m (z ∘ Suc))) (simp (q - Suc 0) i))))›*)
using False (*‹q ≠ 0›*) apply -
(*goals:
1. ‹⋀y. ⟦y ∈ (SIGMA i:{..q - Suc 0}. {0..min q i}); q ≠ 0⟧ ⟹ (case y of (a, b) ⇒ (Suc a, b)) ∈ (SIGMA i:{..q}. {0..min (Suc q) i} - {i}) ∧ (case case y of (a, b) ⇒ (Suc a, b) of (a, b) ⇒ (a - 1, b)) = y›
2. ‹⋀x. ⟦x ∈ (SIGMA i:{..q}. {0..min (Suc q) i} - {i}); q ≠ 0⟧ ⟹ (case x of (a, b) ⇒ (a - 1, b)) ∈ (SIGMA i:{..q - Suc 0}. {0..min q i}) ∧ (case case x of (a, b) ⇒ (a - 1, b) of (a, b) ⇒ (Suc a, b)) = x ∧ (case case x of (a, b) ⇒ (a - 1, b) of (i, j) ⇒ frag_cmul (- ((- 1) ^ (j + i))) (frag_of (simplex_map q (λz. h (z 0, singular_face q j m (z ∘ Suc))) (simp (q - Suc 0) i)))) = (case x of (i, j) ⇒ frag_cmul ((- 1) ^ (i + j)) (frag_of (singular_face (Suc q) j (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i)))))›
discuss goal 1*)
apply ((auto simp: singular_face_simplex_map (*‹⟦(1::nat) ≤ (?p::nat); (?k::nat) ≤ ?p⟧ ⟹ singular_face ?p ?k (simplex_map ?p (?f::?'b ⇒ ?'a) (?c::(nat ⇒ real) ⇒ ?'b)) = simplex_map (?p - Suc (0::nat)) ?f (?c ∘ simplical_face ?k)›*) seq (*‹⟦(?i::nat) ≤ (q::nat); (?j::nat) ≠ ?i; ?j ≤ ?i⟧ ⟹ simplex_map q (λz::nat ⇒ real. (h::real × 'a ⇒ 'b) (z (0::nat), singular_face q ?j (m::(nat ⇒ real) ⇒ 'a) (z ∘ Suc))) ((simp::nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real) (q - Suc (0::nat)) (?i - Suc (0::nat))) = simplex_map q (λz::nat ⇒ real. h (z (0::nat), m (z ∘ Suc))) (simp q ?i ∘ simplical_face ?j)›*) add.commute (*‹(?a::?'a) + (?b::?'a) = ?b + ?a›*))[1])
(*discuss goal 2*)
apply ((auto simp: singular_face_simplex_map (*‹⟦(1::nat) ≤ (?p::nat); (?k::nat) ≤ ?p⟧ ⟹ singular_face ?p ?k (simplex_map ?p (?f::?'b::type ⇒ ?'a::type) (?c::(nat ⇒ real) ⇒ ?'b::type)) = simplex_map (?p - Suc (0::nat)) ?f (?c ∘ simplical_face ?k)›*) seq (*‹⟦(?i::nat) ≤ (q::nat); (?j::nat) ≠ ?i; ?j ≤ ?i⟧ ⟹ simplex_map q (λz::nat ⇒ real. (h::real × 'a::type ⇒ 'b::type) (z (0::nat), singular_face q ?j (m::(nat ⇒ real) ⇒ 'a::type) (z ∘ Suc))) ((simp::nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real) (q - Suc (0::nat)) (?i - Suc (0::nat))) = simplex_map q (λz::nat ⇒ real. h (z (0::nat), m (z ∘ Suc))) (simp q ?i ∘ simplical_face ?j)›*) add.commute (*‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a›*))[1])
(*proven 2 subgoals*) .
qed
have "*": "singular_face (Suc q) (Suc j) (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))
= simplex_map q (λz. h (z 0, singular_face q j m (z ∘ Suc))) (simp (q - Suc 0) i)" if ij: "i < j" "j ≤ q" for i and j
proof (-)
(*goal: ‹singular_face (Suc (q::nat)) (Suc (j::nat)) (simplex_map (Suc q) (λz::nat ⇒ real. (h::real × 'a ⇒ 'b) (z (0::nat), (m::(nat ⇒ real) ⇒ 'a) (z ∘ Suc))) ((simp::nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real) q (i::nat))) = simplex_map q (λz::nat ⇒ real. h (z (0::nat), singular_face q j m (z ∘ Suc))) (simp (q - Suc (0::nat)) i)›*)
have iq: "i ≤ q - Suc 0"
using that (*‹(i::nat) < (j::nat)› ‹j ≤ q›*) by auto
have sf_eqh: "singular_face (Suc q) (Suc j)
(λx. if x ∈ standard_simplex (Suc q)
then ((λz. h (z 0, m (z ∘ Suc))) ∘ simp q i) x else undefined) x
= h (simp (q - Suc 0) i x 0,
singular_face q j m (λxa. simp (q - Suc 0) i x (Suc xa)))" if x: "x ∈ standard_simplex q" for x
proof (-)
(*goal: ‹singular_face (Suc q) (Suc j) (λx. if x ∈ standard_simplex (Suc q) then ((λz. h (z 0, m (z ∘ Suc))) ∘ simp q i) x else undefined) x = h (simp (q - Suc 0) i x 0, singular_face q j m (λxa. simp (q - Suc 0) i x (Suc xa)))›*)
let ?f = "λk. ∑j≤q. if j ≤ i then if k = j then x j else 0
else if Suc k = j then x j else 0"
have fm: "simplical_face (Suc j) x ∈ standard_simplex (Suc q)"
using ss_ss[OF iq] (*‹simplicial_simplex (Suc (q - Suc 0)) {x. x 0 ∈ {0..1} ∧ x ∘ Suc ∈ standard_simplex (q - Suc 0)} (simp (q - Suc 0) i)›*) that (*‹x ∈ standard_simplex q›*) ij (*‹i < j› ‹j ≤ q›*) by (simp add: simplical_face_in_standard_simplex (*‹⟦(1::nat) ≤ (?p::nat); (?k::nat) ≤ ?p; (?x::nat ⇒ real) ∈ standard_simplex (?p - Suc (0::nat))⟧ ⟹ simplical_face ?k ?x ∈ standard_simplex ?p›*))
have ss: "?f ∈ standard_simplex (q - Suc 0)"
unfolding standard_simplex_def
(*goal: ‹(λk. ∑j≤q. if j ≤ i then if k = j then x j else 0 else if Suc k = j then x j else 0) ∈ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>q - Suc 0. x i = 0) ∧ sum x {..q - Suc 0} = 1}›*)
proof (intro CollectI (*‹(?P::?'a ⇒ bool) (?a::?'a) ⟹ ?a ∈ {x::?'a. ?P x}›*) conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P::bool ⟹ ?Q::bool) ⟹ ?P ⟶ ?Q›*) allI (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x) ⟹ ∀x::?'a. ?P x›*))
(*goals:
1. ‹⋀ia. 0 ≤ (∑j≤q. if j ≤ i then if ia = j then x j else 0 else if Suc ia = j then x j else 0)›
2. ‹⋀ia. (∑j≤q. if j ≤ i then if ia = j then x j else 0 else if Suc ia = j then x j else 0) ≤ 1›
3. ‹⋀ia. q - Suc 0 < ia ⟹ (∑j≤q. if j ≤ i then if ia = j then x j else 0 else if Suc ia = j then x j else 0) = 0›
4. ‹(∑ia≤q - Suc 0. ∑j≤q. if j ≤ i then if ia = j then x j else 0 else if Suc ia = j then x j else 0) = 1›*)
fix k
show "0 ≤ ?f k"
using that (*‹x ∈ standard_simplex q›*) by (simp add: sum_nonneg (*‹(⋀x. x ∈ ?A ⟹ 0 ≤ ?f x) ⟹ 0 ≤ sum ?f ?A›*) standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*))
show "?f k ≤ 1"
using x (*‹x ∈ standard_simplex q›*) sum_le_included[of "{..q}" "{..q}" x "id"] (*‹⟦finite {..q}; finite {..q}; ∀y∈{..q}. 0 ≤ x y; ∀xa∈{..q}. ∃y∈{..q}. id y = xa ∧ ?f xa ≤ x y⟧ ⟹ sum ?f {..q} ≤ sum x {..q}›*) by (simp add: standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*))
assume k: "q - Suc 0 < k" (*‹(q::nat) - Suc (0::nat) < (k::nat)›*)
show "?f k = 0"
apply (rule sum.neutral (*‹∀x∈?A. ?g x = 0 ⟹ sum ?g ?A = 0›*))
(*goal: ‹(∑j≤q. if j ≤ i then if k = j then x j else 0 else if Suc k = j then x j else 0) = 0›*)
by (use that x iq k standard_simplex_def in auto)
next
(*goal: ‹(∑ia≤q - Suc 0. ∑j≤q. if j ≤ i then if ia = j then x j else 0 else if Suc ia = j then x j else 0) = 1›*)
have "(∑k≤q - Suc 0. ?f k)
= (∑(k,j) ∈ ({..q - Suc 0} × {..q}) ∩ {(k,j). if j ≤ i then k = j else Suc k = j}. x j)"
apply (simp add: sum.Sigma (*‹⟦finite (?A::?'b set); ∀x::?'b∈?A. finite ((?B::?'b ⇒ ?'c set) x)⟧ ⟹ (∑x::?'b∈?A. sum ((?g::?'b ⇒ ?'c ⇒ ?'a) x) (?B x)) = (∑(x::?'b, y::?'c)∈Sigma ?A ?B. ?g x y)›*))
(*goal: ‹(∑k::nat≤q - Suc (0::nat). ∑j::nat≤q::nat. if j ≤ (i::nat) then if k = j then (x::nat ⇒ real) j else (0::real) else if Suc k = j then x j else (0::real)) = (∑(k::nat, j::nat)∈{..q - Suc (0::nat)} × {..q} ∩ {(k::nat, j::nat). if j ≤ i then k = j else Suc k = j}. x j)›*)
apply (rule sum.mono_neutral_cong (*‹⟦finite ?T; finite ?S; ⋀i. i ∈ ?T - ?S ⟹ ?h i = 0; ⋀i. i ∈ ?S - ?T ⟹ ?g i = 0; ⋀x. x ∈ ?S ∩ ?T ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?S = sum ?h ?T›*))
(*goals:
1. ‹finite ({..q - Suc 0} × {..q} ∩ {(k, j). (j ≤ i ⟶ k = j) ∧ (¬ j ≤ i ⟶ Suc k = j)})›
2. ‹finite ({..q - Suc 0} × {..q})›
3. ‹⋀ia. ia ∈ {..q - Suc 0} × {..q} ∩ {(k, j). (j ≤ i ⟶ k = j) ∧ (¬ j ≤ i ⟶ Suc k = j)} - {..q - Suc 0} × {..q} ⟹ (case ia of (k, j) ⇒ x j) = 0›
4. ‹⋀ia. ia ∈ {..q - Suc 0} × {..q} - {..q - Suc 0} × {..q} ∩ {(k, j). (j ≤ i ⟶ k = j) ∧ (¬ j ≤ i ⟶ Suc k = j)} ⟹ (case ia of (k, j) ⇒ if j ≤ i then if k = j then x j else 0 else if Suc k = j then x j else 0) = 0›
5. ‹⋀xa. xa ∈ {..q - Suc 0} × {..q} ∩ ({..q - Suc 0} × {..q} ∩ {(k, j). (j ≤ i ⟶ k = j) ∧ (¬ j ≤ i ⟶ Suc k = j)}) ⟹ (case xa of (k, j) ⇒ if j ≤ i then if k = j then x j else 0 else if Suc k = j then x j else 0) = (case xa of (k, j) ⇒ x j)›
discuss goal 1*)
apply ((auto simp: split: (*‹(case (?a, ?b) of (c, d) ⇒ ?f c d) = ?f ?a ?b›*) if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*discuss goal 2*)
apply ((auto simp: split: (*‹(case (?a::?'b, ?b::?'c) of (c::?'b, d::?'c) ⇒ (?f::?'b ⇒ ?'c ⇒ ?'a) c d) = ?f ?a ?b›*) if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*discuss goal 3*)
apply ((auto simp: split: (*‹(case (?a, ?b) of (c, d) ⇒ ?f c d) = ?f ?a ?b›*) if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*discuss goal 4*)
apply ((auto simp: split: (*‹(case (?a, ?b) of (c, d) ⇒ ?f c d) = ?f ?a ?b›*) if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*discuss goal 5*)
apply ((auto simp: split: (*‹(case (?a, ?b) of (c, d) ⇒ ?f c d) = ?f ?a ?b›*) if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*proven 5 subgoals*) .
also (*calculation: ‹(∑k≤q - Suc 0. ∑j≤q. if j ≤ i then if k = j then x j else 0 else if Suc k = j then x j else 0) = (∑(k, j)∈{..q - Suc 0} × {..q} ∩ {(k, j). if j ≤ i then k = j else Suc k = j}. x j)›*) have "… = sum x {..q}"
apply (rule sum.eq_general_inverses [where h = "λ(k,j). if j≤i ∧ k=j ∨ j>i ∧ Suc k = j then j else Suc q" and k = "λj. if j ≤ i then (j,j) else (j - Suc 0, j)"] (*‹⟦⋀y. y ∈ ?B ⟹ (if y ≤ i then (y, y) else (y - Suc 0, y)) ∈ ?A ∧ (case if y ≤ i then (y, y) else (y - Suc 0, y) of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q) = y; ⋀x. x ∈ ?A ⟹ (case x of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q) ∈ ?B ∧ (if (case x of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q) ≤ i then (case x of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q, case x of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q) else ((case x of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q) - Suc 0, case x of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q)) = x ∧ ?γ (case x of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q) = ?φ x⟧ ⟹ sum ?φ ?A = sum ?γ ?B›*))
(*goal: ‹(∑(k, j)∈{..q - Suc 0} × {..q} ∩ {(k, j). if j ≤ i then k = j else Suc k = j}. x j) = sum x {..q}›*)
using ij (*‹i < j› ‹j ≤ q›*) apply -
(*goals:
1. ‹⋀y. ⟦y ∈ {..q}; i < j; j ≤ q⟧ ⟹ (if y ≤ i then (y, y) else (y - Suc 0, y)) ∈ {..q - Suc 0} × {..q} ∩ {(k, j). if j ≤ i then k = j else Suc k = j} ∧ (case if y ≤ i then (y, y) else (y - Suc 0, y) of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q) = y›
2. ‹⋀xa. ⟦xa ∈ {..q - Suc 0} × {..q} ∩ {(k, j). if j ≤ i then k = j else Suc k = j}; i < j; j ≤ q⟧ ⟹ (case xa of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q) ∈ {..q} ∧ (if (case xa of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q) ≤ i then (case xa of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q, case xa of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q) else ((case xa of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q) - Suc 0, case xa of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q)) = xa ∧ x (case xa of (k, j) ⇒ if j ≤ i ∧ k = j ∨ i < j ∧ Suc k = j then j else Suc q) = (case xa of (k, j) ⇒ x j)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
also (*calculation: ‹(∑k≤q - Suc 0. ∑j≤q. if j ≤ i then if k = j then x j else 0 else if Suc k = j then x j else 0) = sum x {..q}›*) have "… = 1"
using x (*‹x ∈ standard_simplex q›*) by (simp add: standard_simplex_def (*‹standard_simplex ?p ≡ {x. (∀i. 0 ≤ x i ∧ x i ≤ 1) ∧ (∀i>?p. x i = 0) ∧ sum x {..?p} = 1}›*))
finally (*calculation: ‹(∑k≤q - Suc 0. ∑j≤q. if j ≤ i then if k = j then x j else 0 else if Suc k = j then x j else 0) = 1›*) show "(∑k≤q - Suc 0. ?f k) = 1"
by (simp add: standard_simplex_def (*‹standard_simplex (?p::nat) ≡ {x::nat ⇒ real. (∀i::nat. (0::real) ≤ x i ∧ x i ≤ (1::real)) ∧ (∀i>?p. x i = (0::real)) ∧ sum x {..?p} = (1::real)}›*))
qed
let ?g = "λk. if k ≤ i then 0
else if k < Suc j then x k
else if k = Suc j then 0 else x (k - Suc 0)"
have eq: "{..Suc q} = {..j} ∪ {Suc j} ∪ Suc`{j<..q}" "{..q} = {..j} ∪ {j<..q}"
using ij (*‹i < j› ‹j ≤ q›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) less_Suc_eq_0_disj (*‹((?m::nat) < Suc (?n::nat)) = (?m = (0::nat) ∨ (∃j::nat. ?m = Suc j ∧ j < ?n))›*) less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*) apply -
(*goals:
1. ‹⟦i < j; j ≤ q; ⋀z f A. (z ∈ f ` A) = (∃x∈A. z = f x); ⋀m n. (m < Suc n) = (m = 0 ∨ (∃j. m = Suc j ∧ j < n)); ⋀m n. (m < Suc n) = (m ≤ n)⟧ ⟹ {..Suc q} = {..j} ∪ {Suc j} ∪ Suc ` {j<..q}›
2. ‹⟦i < j; j ≤ q; ⋀z f A. (z ∈ f ` A) = (∃x∈A. z = f x); ⋀m n. (m < Suc n) = (m = 0 ∨ (∃j. m = Suc j ∧ j < n)); ⋀m n. (m < Suc n) = (m ≤ n)⟧ ⟹ {..q} = {..j} ∪ {j<..q}›
discuss goal 1*)
apply (force simp: image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*))
(*discuss goal 2*)
apply (force simp: image_iff (*‹((?z::?'a) ∈ (?f::?'b ⇒ ?'a) ` (?A::?'b set)) = (∃x::?'b∈?A. ?z = ?f x)›*))
(*proven 2 subgoals*) .
then have "(∑k≤Suc q. ?g k) = (∑k∈{..j} ∪ {Suc j} ∪ Suc`{j<..q}. ?g k)"
by simp
also (*calculation: ‹(∑k≤Suc q. if k ≤ i then 0 else if k < Suc j then x k else if k = Suc j then 0 else x (k - Suc 0)) = (∑k∈{..j} ∪ {Suc j} ∪ Suc ` {j<..q}. if k ≤ i then 0 else if k < Suc j then x k else if k = Suc j then 0 else x (k - Suc 0))›*) have "… = (∑k∈{..j} ∪ Suc`{j<..q}. ?g k)"
apply (rule sum.mono_neutral_right (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?g i = 0⟧ ⟹ sum ?g ?T = sum ?g ?S›*))
(*goals:
1. ‹finite ({..j} ∪ {Suc j} ∪ Suc ` {j<..q})›
2. ‹{..j} ∪ Suc ` {j<..q} ⊆ {..j} ∪ {Suc j} ∪ Suc ` {j<..q}›
3. ‹∀ia∈{..j} ∪ {Suc j} ∪ Suc ` {j<..q} - ({..j} ∪ Suc ` {j<..q}). (if ia ≤ i then 0 else if ia < Suc j then x ia else if ia = Suc j then 0 else x (ia - Suc 0)) = 0›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
also (*calculation: ‹(∑k::nat≤Suc (q::nat). if k ≤ (i::nat) then 0::real else if k < Suc (j::nat) then (x::nat ⇒ real) k else if k = Suc j then 0::real else x (k - Suc (0::nat))) = (∑k::nat∈{..j} ∪ Suc ` {j<..q}. if k ≤ i then 0::real else if k < Suc j then x k else if k = Suc j then 0::real else x (k - Suc (0::nat)))›*) have "… = (∑k∈{..j}. ?g k) + (∑k∈Suc`{j<..q}. ?g k)"
apply (rule sum.union_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ sum ?g (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*))
(*goals:
1. ‹finite {..j}›
2. ‹finite (Suc ` {j<..q})›
3. ‹{..j} ∩ Suc ` {j<..q} = {}›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
also (*calculation: ‹(∑k≤Suc q. if k ≤ i then 0 else if k < Suc j then x k else if k = Suc j then 0 else x (k - Suc 0)) = (∑k≤j. if k ≤ i then 0 else if k < Suc j then x k else if k = Suc j then 0 else x (k - Suc 0)) + (∑k∈Suc ` {j<..q}. if k ≤ i then 0 else if k < Suc j then x k else if k = Suc j then 0 else x (k - Suc 0))›*) have "… = (∑k∈{..j}. ?g k) + (∑k∈{j<..q}. ?g (Suc k))"
by (auto simp: sum.reindex (*‹inj_on ?h ?A ⟹ sum ?g (?h ` ?A) = sum (?g ∘ ?h) ?A›*))
also (*calculation: ‹(∑k::nat≤Suc (q::nat). if k ≤ (i::nat) then 0::real else if k < Suc (j::nat) then (x::nat ⇒ real) k else if k = Suc j then 0::real else x (k - Suc (0::nat))) = (∑k::nat≤j. if k ≤ i then 0::real else if k < Suc j then x k else if k = Suc j then 0::real else x (k - Suc (0::nat))) + (∑k::nat∈{j<..q}. if Suc k ≤ i then 0::real else if Suc k < Suc j then x (Suc k) else if Suc k = Suc j then 0::real else x (Suc k - Suc (0::nat)))›*) have "… = (∑k∈{..j}. if k ≤ i then 0 else x k)
+ (∑k∈{j<..q}. if k ≤ i then 0 else x k)"
apply (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) arg_cong2 [of concl: "(+)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a + ?c = ?b + ?d›*))
(*goals:
1. ‹{..j::nat} = {..j}›
2. ‹⋀xa::nat. xa ∈ {..j::nat} ⟹ (if xa ≤ (i::nat) then 0::real else if xa < Suc j then (x::nat ⇒ real) xa else if xa = Suc j then 0::real else x (xa - Suc (0::nat))) = (if xa ≤ i then 0::real else x xa)›
3. ‹{j::nat<..q::nat} = {j<..q}›
4. ‹⋀xa::nat. xa ∈ {j::nat<..q::nat} ⟹ (if Suc xa ≤ (i::nat) then 0::real else if Suc xa < Suc j then (x::nat ⇒ real) (Suc xa) else if Suc xa = Suc j then 0::real else x (Suc xa - Suc (0::nat))) = (if xa ≤ i then 0::real else x xa)›
discuss goal 1*)
apply ((use ij in auto)[1])
(*discuss goal 2*)
apply ((use ij in auto)[1])
(*discuss goal 3*)
apply ((use ij in auto)[1])
(*discuss goal 4*)
apply ((use ij in auto)[1])
(*proven 4 subgoals*) .
also (*calculation: ‹(∑k≤Suc q. if k ≤ i then 0 else if k < Suc j then x k else if k = Suc j then 0 else x (k - Suc 0)) = (∑k≤j. if k ≤ i then 0 else x k) + (∑k∈{j<..q}. if k ≤ i then 0 else x k)›*) have "… = (∑k≤q. if k ≤ i then 0 else x k)"
unfolding eq
(*goal: ‹(∑k≤j. if k ≤ i then 0 else x k) + (∑k∈{j<..q}. if k ≤ i then 0 else x k) = (∑k∈{..j} ∪ {j<..q}. if k ≤ i then 0 else x k)›*)
apply (subst sum.union_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ sum ?g (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*))
(*goals:
1. ‹finite {..j}›
2. ‹finite {j<..q}›
3. ‹{..j} ∩ {j<..q} = {}›
4. ‹(∑k≤j. if k ≤ i then 0 else x k) + (∑k∈{j<..q}. if k ≤ i then 0 else x k) = (∑k≤j. if k ≤ i then 0 else x k) + (∑k∈{j<..q}. if k ≤ i then 0 else x k)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*proven 4 subgoals*) .
finally (*calculation: ‹(∑k≤Suc q. if k ≤ i then 0 else if k < Suc j then x k else if k = Suc j then 0 else x (k - Suc 0)) = (∑k≤q. if k ≤ i then 0 else x k)›*) have "(∑k≤Suc q. ?g k) = (∑k≤q. if k ≤ i then 0 else x k)" .
then have QQ: "(∑l≤Suc q. if l ≤ i then 0 else simplical_face (Suc j) x l) = (∑j≤q. if j ≤ i then 0 else x j)"
by (simp add: simplical_face_def (*‹simplical_face ?k ?x ≡ λi. if i < ?k then ?x i else if i = ?k then 0 else ?x (i - 1)›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
have WW: "(λk. ∑l≤Suc q. if l ≤ i
then if k = l then simplical_face (Suc j) x l else 0
else if Suc k = l then simplical_face (Suc j) x l
else 0)
= simplical_face j
(λk. ∑j≤q. if j ≤ i then if k = j then x j else 0
else if Suc k = j then x j else 0)"
proof (-)
(*goal: ‹(λk::nat. ∑l::nat≤Suc (q::nat). if l ≤ (i::nat) then if k = l then simplical_face (Suc (j::nat)) (x::nat ⇒ real) l else (0::real) else if Suc k = l then simplical_face (Suc j) x l else (0::real)) = simplical_face j (λk::nat. ∑j::nat≤q. if j ≤ i then if k = j then x j else (0::real) else if Suc k = j then x j else (0::real))›*)
have "*": "(∑l≤q. if l ≤ i then 0 else if Suc k = l then x (l - Suc 0) else 0)
= (∑l≤q. if l ≤ i then if k - Suc 0 = l then x l else 0 else if k = l then x l else 0)" (is "?lhs = ?rhs") if "k ≠ q" "k > j" for k
proof (cases "k ≤ q")
(*goals:
1. ‹k ≤ q ⟹ (∑l≤q. if l ≤ i then 0 else if Suc k = l then x (l - Suc 0) else 0) = (∑l≤q. if l ≤ i then if k - Suc 0 = l then x l else 0 else if k = l then x l else 0)›
2. ‹¬ k ≤ q ⟹ (∑l≤q. if l ≤ i then 0 else if Suc k = l then x (l - Suc 0) else 0) = (∑l≤q. if l ≤ i then if k - Suc 0 = l then x l else 0 else if k = l then x l else 0)›*)
case True (*‹k ≤ q›*)
have "?lhs = sum (λl. x (l - Suc 0)) {Suc k}" "?rhs = sum x {k}"
(*goals:
1. ‹(∑l≤q. if l ≤ i then 0 else if Suc k = l then x (l - Suc 0) else 0) = (∑l∈{Suc k}. x (l - Suc 0))›
2. ‹(∑l≤q. if l ≤ i then if k - Suc 0 = l then x l else 0 else if k = l then x l else 0) = sum x {k}›
discuss goal 1*)
apply (rule sum.mono_neutral_cong_right (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?g i = 0; ⋀x. x ∈ ?S ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?T = sum ?h ?S›*))
(*goals:
1. ‹finite {..q::nat}›
2. ‹{Suc (k::nat)} ⊆ {..q::nat}›
3. ‹∀ia::nat∈{..q::nat} - {Suc (k::nat)}. (if ia ≤ (i::nat) then 0::real else if Suc k = ia then (x::nat ⇒ real) (ia - Suc (0::nat)) else (0::real)) = (0::real)›
4. ‹⋀xa::nat. xa ∈ {Suc (k::nat)} ⟹ (if xa ≤ (i::nat) then 0::real else if Suc k = xa then (x::nat ⇒ real) (xa - Suc (0::nat)) else (0::real)) = x (xa - Suc (0::nat))›
discuss goal 1*)
apply ((use True ij that in auto)[1])
(*discuss goal 2*)
apply ((use True ij that in auto)[1])
(*discuss goal 3*)
apply ((use True ij that in auto)[1])
(*discuss goal 4*)
apply ((use True ij that in auto)[1])
(*proven 4 subgoals*)
(*discuss goal 2*)
apply (rule sum.mono_neutral_cong_right (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?g i = 0; ⋀x. x ∈ ?S ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?T = sum ?h ?S›*))
(*goals:
1. ‹finite {..q::nat}›
2. ‹{k::nat} ⊆ {..q::nat}›
3. ‹∀ia::nat∈{..q::nat} - {k::nat}. (if ia ≤ (i::nat) then if k - Suc (0::nat) = ia then (x::nat ⇒ real) ia else (0::real) else if k = ia then x ia else (0::real)) = (0::real)›
4. ‹⋀xa::nat. xa ∈ {k::nat} ⟹ (if xa ≤ (i::nat) then if k - Suc (0::nat) = xa then (x::nat ⇒ real) xa else (0::real) else if k = xa then x xa else (0::real)) = x xa›
discuss goal 1*)
apply ((use True ij that in auto)[1])
(*discuss goal 2*)
apply ((use True ij that in auto)[1])
(*discuss goal 3*)
apply ((use True ij that in auto)[1])
(*discuss goal 4*)
apply ((use True ij that in auto)[1])
(*proven 4 subgoals*)
(*proven 2 subgoals*) .
then show "?thesis"
(*goal: ‹(∑l≤q. if l ≤ i then 0 else if Suc k = l then x (l - Suc 0) else 0) = (∑l≤q. if l ≤ i then if k - Suc 0 = l then x l else 0 else if k = l then x l else 0)›*)
by simp
next
(*goal: ‹¬ k ≤ q ⟹ (∑l≤q. if l ≤ i then 0 else if Suc k = l then x (l - Suc 0) else 0) = (∑l≤q. if l ≤ i then if k - Suc 0 = l then x l else 0 else if k = l then x l else 0)›*)
case False (*‹¬ k ≤ q›*)
have "?lhs = 0" "?rhs = 0"
(*goals:
1. ‹(∑l::nat≤q::nat. if l ≤ (i::nat) then 0::real else if Suc (k::nat) = l then (x::nat ⇒ real) (l - Suc (0::nat)) else (0::real)) = (0::real)›
2. ‹(∑l::nat≤q::nat. if l ≤ (i::nat) then if (k::nat) - Suc (0::nat) = l then (x::nat ⇒ real) l else (0::real) else if k = l then x l else (0::real)) = (0::real)›
discuss goal 1*)
apply (rule sum.neutral (*‹∀x∈?A. ?g x = 0 ⟹ sum ?g ?A = 0›*))
(*top goal: ‹(∑l≤q. if l ≤ i then 0 else if Suc k = l then x (l - Suc 0) else 0) = 0› and 1 goal remains*)
apply (use False ij in auto)
(*discuss goal 2*)
apply (rule sum.neutral (*‹∀x∈?A. ?g x = 0 ⟹ sum ?g ?A = 0›*))
(*goal: ‹⟦¬ (k::nat) ≤ (q::nat); (i::nat) < (j::nat); j ≤ q⟧ ⟹ (∑l::nat≤q. if l ≤ i then if k - Suc (0::nat) = l then (x::nat ⇒ real) l else (0::real) else if k = l then x l else (0::real)) = (0::real)›*)
apply (use False ij in auto)
(*proven 2 subgoals*) .
then show "?thesis"
(*goal: ‹(∑l≤q. if l ≤ i then 0 else if Suc k = l then x (l - Suc 0) else 0) = (∑l≤q. if l ≤ i then if k - Suc 0 = l then x l else 0 else if k = l then x l else 0)›*)
by simp
qed
have xq: "x q = (∑j≤q. if j ≤ i then if q - Suc 0 = j then x j else 0
else if q = j then x j else 0)" if "q≠j"
using ij (*‹i < j› ‹j ≤ q›*) that (*‹q ≠ j›*) by (force simp flip: ivl_disj_un( (*‹{..<?u} ∪ {?u} = {..?u}›*) 2) intro: sum.neutral (*‹∀x∈?A. ?g x = 0 ⟹ sum ?g ?A = 0›*))
show "?thesis"
(*goal: ‹(λk. ∑l≤Suc q. if l ≤ i then if k = l then simplical_face (Suc j) x l else 0 else if Suc k = l then simplical_face (Suc j) x l else 0) = simplical_face j (λk. ∑j≤q. if j ≤ i then if k = j then x j else 0 else if Suc k = j then x j else 0)›*)
using ij (*‹i < j› ‹j ≤ q›*) unfolding simplical_face_def
(*goal: ‹(λk. ∑l≤Suc q. if l ≤ i then if k = l then if l < Suc j then x l else if l = Suc j then 0 else x (l - 1) else 0 else if Suc k = l then if l < Suc j then x l else if l = Suc j then 0 else x (l - 1) else 0) = (λia. if ia < j then ∑j≤q. if j ≤ i then if ia = j then x j else 0 else if Suc ia = j then x j else 0 else if ia = j then 0 else ∑j≤q. if j ≤ i then if ia - 1 = j then x j else 0 else if Suc (ia - 1) = j then x j else 0)›*)
apply (intro ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*))
(*goal: ‹(λk::nat. ∑l::nat≤Suc (q::nat). if l ≤ (i::nat) then if k = l then if l < Suc (j::nat) then (x::nat ⇒ real) l else if l = Suc j then 0::real else x (l - (1::nat)) else (0::real) else if Suc k = l then if l < Suc j then x l else if l = Suc j then 0::real else x (l - (1::nat)) else (0::real)) = (λia::nat. if ia < j then ∑j::nat≤q. if j ≤ i then if ia = j then x j else (0::real) else if Suc ia = j then x j else (0::real) else if ia = j then 0::real else ∑j::nat≤q. if j ≤ i then if ia - (1::nat) = j then x j else (0::real) else if Suc (ia - (1::nat)) = j then x j else (0::real))›*)
by (auto simp: * (*‹⟦?k ≠ q; j < ?k⟧ ⟹ (∑l≤q. if l ≤ i then 0 else if Suc ?k = l then x (l - Suc 0) else 0) = (∑l≤q. if l ≤ i then if ?k - Suc 0 = l then x l else 0 else if ?k = l then x l else 0)›*) sum.atMost_Suc (*‹sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)›*) xq (*‹q ≠ j ⟹ x q = (∑j≤q. if j ≤ i then if q - Suc 0 = j then x j else 0 else if q = j then x j else 0)›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
qed
show "?thesis"
(*goal: ‹singular_face (Suc q) (Suc j) (λx. if x ∈ standard_simplex (Suc q) then ((λz. h (z 0, m (z ∘ Suc))) ∘ simp q i) x else undefined) x = h (simp (q - Suc 0) i x 0, singular_face q j m (λxa. simp (q - Suc 0) i x (Suc xa)))›*)
using False (*‹q ≠ 0›*) that (*‹x ∈ standard_simplex q›*) iq (*‹i ≤ q - Suc 0›*) unfolding oriented_simplex_def simp_def vv_def ww_def
(*goal: ‹singular_face (Suc q) (Suc j) (λx. if x ∈ standard_simplex (Suc q) then ((λz. h (z 0, m (z ∘ Suc))) ∘ (λx∈standard_simplex (Suc q). λia. ∑j≤Suc q. (if j ≤ i then λi. if i = Suc j then 1 else 0 else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) ia * x j)) x else undefined) x = h ((λx∈standard_simplex (Suc (q - Suc 0)). λia. ∑j≤Suc (q - Suc 0). (if j ≤ i then λi. if i = Suc j then 1 else 0 else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) ia * x j) x 0, singular_face q j m (λxa. (λx∈standard_simplex (Suc (q - Suc 0)). λia. ∑j≤Suc (q - Suc 0). (if j ≤ i then λi. if i = Suc j then 1 else 0 else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) ia * x j) x (Suc xa)))›*)
apply (simp add: if_distribR (*‹(if ?b then ?f else ?g) ?x = (if ?b then ?f ?x else ?g ?x)›*) simplical_face_def (*‹simplical_face ?k ?x ≡ λi. if i < ?k then ?x i else if i = ?k then 0 else ?x (i - 1)›*) if_distrib [of "λu. u * _"] (*‹(if ?c then ?x else ?y) * ?uu5 = (if ?c then ?x * ?uu5 else ?y * ?uu5)›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
(*goal: ‹singular_face (Suc q) (Suc j) (λx. if x ∈ standard_simplex (Suc q) then ((λz. h (z 0, m (z ∘ Suc))) ∘ (λx∈standard_simplex (Suc q). λia. ∑j≤Suc q. (if j ≤ i then λi. if i = Suc j then 1 else 0 else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) ia * x j)) x else undefined) x = h ((λx∈standard_simplex (Suc (q - Suc 0)). λia. ∑j≤Suc (q - Suc 0). (if j ≤ i then λi. if i = Suc j then 1 else 0 else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) ia * x j) x 0, singular_face q j m (λxa. (λx∈standard_simplex (Suc (q - Suc 0)). λia. ∑j≤Suc (q - Suc 0). (if j ≤ i then λi. if i = Suc j then 1 else 0 else (λi. if i = 0 ∨ i = Suc (j - 1) then 1 else 0)) ia * x j) x (Suc xa)))›*)
by (simp add: singular_face_def (*‹singular_face ?p ?k ?f ≡ restrict (?f ∘ simplical_face ?k) (standard_simplex (?p - Suc 0))›*) fm (*‹simplical_face (Suc j) x ∈ standard_simplex (Suc q)›*) ss (*‹(λk. ∑j≤q. if j ≤ i then if k = j then x j else 0 else if Suc k = j then x j else 0) ∈ standard_simplex (q - Suc 0)›*) QQ (*‹(∑l≤Suc q. if l ≤ i then 0 else simplical_face (Suc j) x l) = (∑j≤q. if j ≤ i then 0 else x j)›*) WW (*‹(λk. ∑l≤Suc q. if l ≤ i then if k = l then simplical_face (Suc j) x l else 0 else if Suc k = l then simplical_face (Suc j) x l else 0) = simplical_face j (λk. ∑j≤q. if j ≤ i then if k = j then x j else 0 else if Suc k = j then x j else 0)›*))
qed
show "?thesis"
(*goal: ‹singular_face (Suc q) (Suc j) (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i)) = simplex_map q (λz. h (z 0, singular_face q j m (z ∘ Suc))) (simp (q - Suc 0) i)›*)
unfolding simplex_map_def restrict_def
(*goal: ‹singular_face (Suc q) (Suc j) (λx. if x ∈ standard_simplex (Suc q) then ((λz. h (z 0, m (z ∘ Suc))) ∘ simp q i) x else undefined) = (λx. if x ∈ standard_simplex q then ((λz. h (z 0, singular_face q j m (z ∘ Suc))) ∘ simp (q - Suc 0) i) x else undefined)›*)
apply (simp add: simplicial_simplex (*‹simplicial_simplex ?p ?S ?f = (?f ` standard_simplex ?p ⊆ ?S ∧ (∃l. ?f = oriented_simplex ?p l))›*) image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) sf_eqh (*‹?x ∈ standard_simplex q ⟹ singular_face (Suc q) (Suc j) (λx. if x ∈ standard_simplex (Suc q) then ((λz. h (z 0, m (z ∘ Suc))) ∘ simp q i) x else undefined) ?x = h (simp (q - Suc 0) i ?x 0, singular_face q j m (λxa. simp (q - Suc 0) i ?x (Suc xa)))›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*))
(*goal: ‹singular_face (Suc (q::nat)) (Suc (j::nat)) (λx::nat ⇒ real. if x ∈ standard_simplex (Suc q) then ((λz::nat ⇒ real. (h::real × 'a ⇒ 'b) (z (0::nat), (m::(nat ⇒ real) ⇒ 'a) (z ∘ Suc))) ∘ (simp::nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real) q (i::nat)) x else undefined) = (λx::nat ⇒ real. if x ∈ standard_simplex q then ((λz::nat ⇒ real. h (z (0::nat), singular_face q j m (z ∘ Suc))) ∘ simp (q - Suc (0::nat)) i) x else undefined)›*)
by (simp add: singular_face_def (*‹singular_face ?p ?k ?f ≡ restrict (?f ∘ simplical_face ?k) (standard_simplex (?p - Suc 0))›*))
qed
have sgeq: "(SIGMA i:{..q}. {i..q} - {i}) = (SIGMA i:{..q}. {i<..q})"
by force
have II: "(∑(i,j)∈(SIGMA i:{..q}. {i..q} - {i}).
frag_cmul (- ((-1) ^ (i + j)))
(frag_of
(singular_face (Suc q) (Suc j)
(simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) =
(∑(i,j)∈(SIGMA i:{..q}. {i<..q}).
frag_cmul (- ((-1) ^ (j + i)))
(frag_of
(simplex_map q (λz. h (z 0, singular_face q j m (z ∘ Suc)))
(simp (q - Suc 0) i))))"
by (force simp: * (*‹⟦?i < ?j; ?j ≤ q⟧ ⟹ singular_face (Suc q) (Suc ?j) (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q ?i)) = simplex_map q (λz. h (z 0, singular_face q ?j m (z ∘ Suc))) (simp (q - Suc 0) ?i)›*) sgeq (*‹(SIGMA i:{..q}. {i..q} - {i}) = (SIGMA i:{..q}. {i<..q})›*) add.commute (*‹?a + ?b = ?b + ?a›*) intro: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
show "?thesis"
(*goal: ‹(∑(i, j)∈(SIGMA i:{..q}. {0..min (Suc q) i} - {i}). frag_cmul ((- 1) ^ i * (- 1) ^ j) (frag_of (singular_face (Suc q) j (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) + (∑(i, j)∈(SIGMA i:{..q}. {i..q} - {i}). frag_cmul (- ((- 1) ^ i * (- 1) ^ j)) (frag_of (singular_face (Suc q) (Suc j) (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) = - frag_extend (pr (q - Suc 0)) (chain_boundary q (frag_of m))›*)
using False (*‹(q::nat) ≠ (0::nat)›*) apply (simp add: chain_boundary_def (*‹chain_boundary ?p ?c ≡ if ?p = 0 then 0 else frag_extend (λf. ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k f))) ?c›*) frag_extend_sum (*‹finite ?I ⟹ frag_extend ?f (sum ?g ?I) = sum (frag_extend ?f ∘ ?g) ?I›*) frag_extend_cmul (*‹frag_extend ?f (frag_cmul ?c ?x) = frag_cmul ?c (frag_extend ?f ?x)›*) frag_cmul_sum (*‹frag_cmul ?a (sum ?b ?I) = (∑i∈?I. frag_cmul ?a (?b i))›*) pr_def (*‹pr ≡ λq c. ∑i≤q. frag_cmul ((- 1) ^ i) (frag_of (simplex_map (Suc q) (λz. h (z 0, c (z ∘ Suc))) (simp q i)))›*) flip: sum_negf (*‹(∑x∈?A. - ?f x) = - sum ?f ?A›*) power_add (*‹?a ^ (?m + ?n) = ?a ^ ?m * ?a ^ ?n›*))
(*goal: ‹(∑(i::nat, j::nat)∈(SIGMA i::nat:{..q}. {0::nat..min (Suc q) i} - {i}). frag_cmul ((- (1::int)) ^ i * (- (1::int)) ^ j) (frag_of (singular_face (Suc (q::nat)) j (simplex_map (Suc q) (λz::nat ⇒ real. (h::real × 'a ⇒ 'b) (z (0::nat), (m::(nat ⇒ real) ⇒ 'a) (z ∘ Suc))) ((simp::nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real) q i))))) + (∑(i::nat, j::nat)∈(SIGMA i::nat:{..q}. {i..q} - {i}). frag_cmul (- ((- (1::int)) ^ i * (- (1::int)) ^ j)) (frag_of (singular_face (Suc q) (Suc j) (simplex_map (Suc q) (λz::nat ⇒ real. h (z (0::nat), m (z ∘ Suc))) (simp q i))))) = - frag_extend ((pr::nat ⇒ ((nat ⇒ real) ⇒ 'a) ⇒ ((nat ⇒ real) ⇒ 'b) ⇒₀ int) (q - Suc (0::nat))) (chain_boundary q (frag_of m))›*)
apply (subst sum.swap [where A = "{..q}"] (*‹(∑i≤q. sum (?g i) ?B) = (∑j∈?B. ∑i≤q. ?g i j)›*))
(*goal: ‹0 < q ⟹ (∑x∈(SIGMA i:{..q}. {0..min (Suc q) i} - {i}). case x of (i, j) ⇒ frag_cmul ((- 1) ^ (i + j)) (frag_of (singular_face (Suc q) j (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) + (∑x∈(SIGMA i:{..q}. {i..q} - {i}). case x of (i, j) ⇒ frag_cmul (- ((- 1) ^ (i + j))) (frag_of (singular_face (Suc q) (Suc j) (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q i))))) = (∑x≤q. ∑i≤q - Suc 0. frag_cmul (- ((- 1) ^ (x + i))) (frag_of (simplex_map q (λz. h (z 0, singular_face q x m (z ∘ Suc))) (simp (q - Suc 0) i))))›*)
by (simp add: sum.cartesian_product (*‹(∑x::?'b∈(?A::?'b set). sum ((?g::?'b ⇒ ?'c ⇒ ?'a) x) (?B::?'c set)) = (∑(x::?'b, y::?'c)∈?A × ?B. ?g x y)›*) eq (*‹{..(q::nat) - Suc (0::nat)} × {..q} = (SIGMA i::nat:{..q - Suc (0::nat)}. {0::nat..min q i}) ∪ (SIGMA i::nat:{..q}. {i<..q})›*) sum.union_disjoint (*‹⟦finite (?A::?'b set); finite (?B::?'b set); ?A ∩ ?B = {}⟧ ⟹ sum (?g::?'b ⇒ ?'a) (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*) disjoint_iff_not_equal (*‹((?A::?'a set) ∩ (?B::?'a set) = {}) = (∀x::?'a∈?A. ∀y::?'a∈?B. x ≠ y)›*) I (*‹(∑(i::nat, j::nat)∈(SIGMA i::nat:{..q}. {0::nat..min (Suc q) i} - {i}). frag_cmul ((- (1::int)) ^ (i + j)) (frag_of (singular_face (Suc (q::nat)) j (simplex_map (Suc q) (λz::nat ⇒ real. (h::real × 'a ⇒ 'b) (z (0::nat), (m::(nat ⇒ real) ⇒ 'a) (z ∘ Suc))) ((simp::nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real) q i))))) = (∑(i::nat, j::nat)∈(SIGMA i::nat:{..q - Suc (0::nat)}. {0::nat..min q i}). frag_cmul (- ((- (1::int)) ^ (j + i))) (frag_of (simplex_map q (λz::nat ⇒ real. h (z (0::nat), singular_face q j m (z ∘ Suc))) (simp (q - Suc (0::nat)) i))))›*) II (*‹(∑(i::nat, j::nat)∈(SIGMA i::nat:{..q}. {i..q} - {i}). frag_cmul (- ((- (1::int)) ^ (i + j))) (frag_of (singular_face (Suc (q::nat)) (Suc j) (simplex_map (Suc q) (λz::nat ⇒ real. (h::real × 'a ⇒ 'b) (z (0::nat), (m::(nat ⇒ real) ⇒ 'a) (z ∘ Suc))) ((simp::nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real) q i))))) = (∑(i::nat, j::nat)∈(SIGMA i::nat:{..q}. {i<..q}). frag_cmul (- ((- (1::int)) ^ (j + i))) (frag_of (simplex_map q (λz::nat ⇒ real. h (z (0::nat), singular_face q j m (z ∘ Suc))) (simp (q - Suc (0::nat)) i))))›*))
qed
have "*": "⟦a+b = w; c+d = -z⟧ ⟹ (a + c) + (b+d) = w-z" for a :: "'c ⇒₀ int" and b :: "'c ⇒₀ int" and w :: "'c ⇒₀ int" and c :: "'c ⇒₀ int" and d :: "'c ⇒₀ int" and z :: "'c ⇒₀ int"
by (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 33 facts*))
have eq: "{..q} × {..Suc q} =
Sigma {..q} (λi. {0..min (Suc q) i})
∪ Sigma {..q} (λi. {Suc i..Suc q})"
by force
show "?case"
(*goal: ‹chain_boundary (Suc q) ((frag_extend ∘ pr) q (frag_of m)) = chain_map q g (frag_of m) - chain_map q f (frag_of m) - (frag_extend ∘ pr) (q - 1) (chain_boundary q (frag_of m))›*)
apply (subst pr_def (*‹pr::nat ⇒ ((nat ⇒ real) ⇒ 'a) ⇒ ((nat ⇒ real) ⇒ 'b) ⇒₀ int ≡ λ(q::nat) c::(nat ⇒ real) ⇒ 'a. ∑i::nat≤q. frag_cmul ((- (1::int)) ^ i) (frag_of (simplex_map (Suc q) (λz::nat ⇒ real. (h::real × 'a ⇒ 'b) (z (0::nat), c (z ∘ Suc))) ((simp::nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real) q i)))›*))
(*goal: ‹chain_boundary (Suc q) ((frag_extend ∘ pr) q (frag_of m)) = chain_map q g (frag_of m) - chain_map q f (frag_of m) - (frag_extend ∘ pr) (q - 1) (chain_boundary q (frag_of m))›*)
apply (simp add: chain_boundary_sum (*‹chain_boundary ?p (sum ?g ?I) = sum (chain_boundary ?p ∘ ?g) ?I›*) chain_boundary_cmul (*‹chain_boundary ?p (frag_cmul ?k ?c) = frag_cmul ?k (chain_boundary ?p ?c)›*))
(*goal: ‹chain_boundary (Suc q) ((frag_extend ∘ (λq c. ∑i≤q. frag_cmul ((- 1) ^ i) (frag_of (simplex_map (Suc q) (λz. h (z 0, c (z ∘ Suc))) (simp q i))))) q (frag_of m)) = chain_map q g (frag_of m) - chain_map q f (frag_of m) - (frag_extend ∘ pr) (q - 1) (chain_boundary q (frag_of m))›*)
apply (subst chain_boundary_def (*‹chain_boundary ?p ?c ≡ if ?p = 0 then 0 else frag_extend (λf. ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k f))) ?c›*))
(*goal: ‹(∑x≤q. frag_cmul ((- 1) ^ x) (chain_boundary (Suc q) (frag_of (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q x))))) = frag_of (simplex_map q g m) - frag_of (simplex_map q f m) - frag_extend (pr (q - Suc 0)) (chain_boundary q (frag_of m))›*)
apply simp
(*goal: ‹(∑x≤q. frag_cmul ((- 1) ^ x) (if Suc q = 0 then 0 else frag_extend (λf. ∑k≤Suc q. frag_cmul ((- 1) ^ k) (frag_of (singular_face (Suc q) k f))) (frag_of (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q x))))) = frag_of (simplex_map q g m) - frag_of (simplex_map q f m) - frag_extend (pr (q - Suc 0)) (chain_boundary q (frag_of m))›*)
apply (simp add: frag_cmul_sum (*‹frag_cmul ?a (sum ?b ?I) = (∑i∈?I. frag_cmul ?a (?b i))›*) sum.cartesian_product (*‹(∑x∈?A. sum (?g x) ?B) = (∑(x, y)∈?A × ?B. ?g x y)›*) eq (*‹{..q} × {..Suc q} = (SIGMA i:{..q}. {0..min (Suc q) i}) ∪ (SIGMA i:{..q}. {Suc i..Suc q})›*) sum.union_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ sum ?g (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*) disjoint_iff_not_equal (*‹(?A ∩ ?B = {}) = (∀x∈?A. ∀y∈?B. x ≠ y)›*) sum.atLeast_Suc_atMost_Suc_shift (*‹sum ?g {Suc ?m..Suc ?n} = sum (?g ∘ Suc) {?m..?n}›*) del: sum.cl_ivl_Suc (*‹sum ?g {?m..Suc ?n} = (if Suc ?n < ?m then 0 else sum ?g {?m..?n} + ?g (Suc ?n))›*) min.absorb2 (*‹?b ≤ ?a ⟹ min ?a ?b = ?b›*) min.absorb4 (*‹?b < ?a ⟹ min ?a ?b = ?b›*) flip: comm_monoid_add_class.sum.Sigma (*‹⟦finite ?A; ∀x∈?A. finite (?B x)⟧ ⟹ (∑x∈?A. sum (?g x) (?B x)) = (∑(x, y)∈Sigma ?A ?B. ?g x y)›*))
(*goal: ‹(∑x≤q. frag_cmul ((- 1) ^ x) (∑k≤Suc q. frag_cmul ((- 1) ^ k) (frag_of (singular_face (Suc q) k (simplex_map (Suc q) (λz. h (z 0, m (z ∘ Suc))) (simp q x)))))) = frag_of (simplex_map q g m) - frag_of (simplex_map q f m) - frag_extend (pr (q - Suc 0)) (chain_boundary q (frag_of m))›*)
apply (simp add: sum.Sigma (*‹⟦finite ?A; ∀x∈?A. finite (?B x)⟧ ⟹ (∑x∈?A. sum (?g x) (?B x)) = (∑(x, y)∈Sigma ?A ?B. ?g x y)›*) eq2 [of _ "λi. {_ i.._ i}"] (*‹(SIGMA i:?S. {?uu4 i..?uua4 i}) = (λi. (i, i)) ` {i ∈ ?S. i ∈ {?uu4 i..?uua4 i}} ∪ (SIGMA i:?S. {?uu4 i..?uua4 i} - {i})›*) del: min.absorb2 (*‹?b ≤ ?a ⟹ min ?a ?b = ?b›*) min.absorb4 (*‹?b < ?a ⟹ min ?a ?b = ?b›*))
(*goal: ‹(∑i::nat≤q. ∑ia::nat = 0::nat..min (Suc q) i. frag_cmul ((- (1::int)) ^ i * (- (1::int)) ^ ia) (frag_of (singular_face (Suc (q::nat)) ia (simplex_map (Suc q) (λz::nat ⇒ real. (h::real × 'a ⇒ 'b) (z (0::nat), (m::(nat ⇒ real) ⇒ 'a) (z ∘ Suc))) ((simp::nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real) q i))))) + (∑i::nat≤q. ∑x::nat = i..q. frag_cmul (- ((- (1::int)) ^ i * (- (1::int)) ^ x)) (frag_of (singular_face (Suc q) (Suc x) (simplex_map (Suc q) (λz::nat ⇒ real. h (z (0::nat), m (z ∘ Suc))) (simp q i))))) = frag_of (simplex_map q (g::'a ⇒ 'b) m) - frag_of (simplex_map q (f::'a ⇒ 'b) m) - frag_extend ((pr::nat ⇒ ((nat ⇒ real) ⇒ 'a) ⇒ ((nat ⇒ real) ⇒ 'b) ⇒₀ int) (q - Suc (0::nat))) (chain_boundary q (frag_of m))›*)
by (simp add: sum.union_disjoint (*‹⟦finite (?A::?'b set); finite (?B::?'b set); ?A ∩ ?B = {}⟧ ⟹ sum (?g::?'b ⇒ ?'a) (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*) disjoint_iff_not_equal (*‹((?A::?'a set) ∩ (?B::?'a set) = {}) = (∀x::?'a∈?A. ∀y::?'a∈?B. x ≠ y)›*) * [OF 1 2] (*‹(∑(i::nat, j::nat)∈(λi::nat. (i, i)) ` {i::nat. i ≤ q ∧ i ≤ Suc q}. frag_cmul ((- (1::int)) ^ i * (- (1::int)) ^ j) (frag_of (singular_face (Suc (q::nat)) j (simplex_map (Suc q) (λz::nat ⇒ real. (h::real × 'a ⇒ 'b) (z (0::nat), (m::(nat ⇒ real) ⇒ 'a) (z ∘ Suc))) ((simp::nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real) q i))))) + (∑(i::nat, j::nat)∈(SIGMA i::nat:{..q}. {0::nat..min (Suc q) i} - {i}). frag_cmul ((- (1::int)) ^ i * (- (1::int)) ^ j) (frag_of (singular_face (Suc q) j (simplex_map (Suc q) (λz::nat ⇒ real. h (z (0::nat), m (z ∘ Suc))) (simp q i))))) + ((∑(i::nat, j::nat)∈(λi::nat. (i, i)) ` {i::nat. i ≤ q}. frag_cmul (- ((- (1::int)) ^ i * (- (1::int)) ^ j)) (frag_of (singular_face (Suc q) (Suc j) (simplex_map (Suc q) (λz::nat ⇒ real. h (z (0::nat), m (z ∘ Suc))) (simp q i))))) + (∑(i::nat, j::nat)∈(SIGMA i::nat:{..q}. {i..q} - {i}). frag_cmul (- ((- (1::int)) ^ i * (- (1::int)) ^ j)) (frag_of (singular_face (Suc q) (Suc j) (simplex_map (Suc q) (λz::nat ⇒ real. h (z (0::nat), m (z ∘ Suc))) (simp q i)))))) = frag_of (simplex_map q (g::'a ⇒ 'b) m) - frag_of (simplex_map q (f::'a ⇒ 'b) m) - frag_extend ((pr::nat ⇒ ((nat ⇒ real) ⇒ 'a) ⇒ ((nat ⇒ real) ⇒ 'b) ⇒₀ int) (q - Suc (0::nat))) (chain_boundary q (frag_of m))›*))
next
(*goals:
1. ‹chain_boundary (Suc q) ((frag_extend ∘ pr) q 0) = chain_map q g 0 - chain_map q f 0 - (frag_extend ∘ pr) (q - 1) (chain_boundary q 0)›
2. ‹⋀a b. ⟦chain_boundary (Suc q) ((frag_extend ∘ pr) q a) = chain_map q g a - chain_map q f a - (frag_extend ∘ pr) (q - 1) (chain_boundary q a); chain_boundary (Suc q) ((frag_extend ∘ pr) q b) = chain_map q g b - chain_map q f b - (frag_extend ∘ pr) (q - 1) (chain_boundary q b)⟧ ⟹ chain_boundary (Suc q) ((frag_extend ∘ pr) q (a - b)) = chain_map q g (a - b) - chain_map q f (a - b) - (frag_extend ∘ pr) (q - 1) (chain_boundary q (a - b))›*)
case (diff a b) (*‹chain_boundary (Suc q) ((frag_extend ∘ pr) q a) = chain_map q g a - chain_map q f a - (frag_extend ∘ pr) (q - 1) (chain_boundary q a)› ‹chain_boundary (Suc q) ((frag_extend ∘ pr) q b) = chain_map q g b - chain_map q f b - (frag_extend ∘ pr) (q - 1) (chain_boundary q b)›*)
then show "?case"
(*goal: ‹chain_boundary (Suc q) ((frag_extend ∘ pr) q (a - b)) = chain_map q g (a - b) - chain_map q f (a - b) - (frag_extend ∘ pr) (q - 1) (chain_boundary q (a - b))›*)
by (simp add: chain_boundary_diff (*‹chain_boundary ?p (?a - ?b) = chain_boundary ?p ?a - chain_boundary ?p ?b›*) frag_extend_diff (*‹frag_extend ?f (?a - ?b) = frag_extend ?f ?a - frag_extend ?f ?b›*) chain_map_diff (*‹chain_map ?p ?g (?a - ?b) = chain_map ?p ?g ?a - chain_map ?p ?g ?b›*))
qed (auto)
(*solved the remaining goal: ‹chain_boundary (Suc q) ((frag_extend ∘ pr) q 0) = chain_map q g 0 - chain_map q f 0 - (frag_extend ∘ pr) (q - 1) (chain_boundary q 0)›*)
qed
have "*": "singular_chain p (subtopology U V) (prism (p - Suc 0) (chain_boundary p c))" if "singular_chain p S c" "singular_chain (p - Suc 0) (subtopology S T) (chain_boundary p c)"
proof (cases "p")
(*goals:
1. ‹p = 0 ⟹ singular_chain p (subtopology U V) (prism (p - Suc 0) (chain_boundary p c))›
2. ‹⋀nat. p = Suc nat ⟹ singular_chain p (subtopology U V) (prism (p - Suc 0) (chain_boundary p c))›*)
case 0 (*‹p = 0›*)
then show "?thesis"
(*goal: ‹singular_chain p (subtopology U V) (prism (p - Suc 0) (chain_boundary p c))›*)
by (simp add: chain_boundary_def (*‹chain_boundary ?p ?c ≡ if ?p = 0 then 0 else frag_extend (λf. ∑k≤?p. frag_cmul ((- 1) ^ k) (frag_of (singular_face ?p k f))) ?c›*) prism (*‹prism ?q 0 = 0› ‹singular_chain ?q S ?c ⟹ singular_chain (Suc ?q) U (prism ?q ?c)› ‹singular_chain ?q (subtopology S T) ?c ⟹ singular_chain (Suc ?q) (subtopology U V) (prism ?q ?c)› ‹singular_chain ?q S ?c ⟹ chain_boundary (Suc ?q) (prism ?q ?c) = chain_map ?q g ?c - chain_map ?q f ?c - prism (?q - 1) (chain_boundary ?q ?c)›*))
next
(*goal: ‹⋀nat. p = Suc nat ⟹ singular_chain p (subtopology U V) (prism (p - Suc 0) (chain_boundary p c))›*)
case (Suc p') (*‹p = Suc p'›*)
with prism (*‹prism ?q 0 = 0› ‹singular_chain ?q S ?c ⟹ singular_chain (Suc ?q) U (prism ?q ?c)› ‹singular_chain (?q::nat) (subtopology (S::'a topology) (T::'a set)) (?c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⟹ singular_chain (Suc ?q) (subtopology (U::'b topology) (V::'b set)) ((prism::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'b) ⇒₀ int) ?q ?c)› ‹singular_chain ?q S ?c ⟹ chain_boundary (Suc ?q) (prism ?q ?c) = chain_map ?q g ?c - chain_map ?q f ?c - prism (?q - 1) (chain_boundary ?q ?c)›*) that (*‹singular_chain p S c› ‹singular_chain (p - Suc 0) (subtopology S T) (chain_boundary p c)›*) show "?thesis"
(*goal: ‹singular_chain p (subtopology U V) (prism (p - Suc 0) (chain_boundary p c))›*)
by auto
qed
then show "?thesis"
(*goal: ‹homologous_rel p U V (chain_map p f c) (chain_map p g c)›*)
using c (*‹singular_relcycle p S T c›*) unfolding singular_relcycle_def homologous_rel_def singular_relboundary_def mod_subset_def
(*goal: ‹∃d::((nat ⇒ real) ⇒ 'b) ⇒₀ int. singular_chain (Suc (p::nat)) (U::'b topology) d ∧ (chain_boundary (Suc p) d, chain_map p (f::'a ⇒ 'b) (c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) - chain_map p (g::'a ⇒ 'b) c) ∈ {(a::((nat ⇒ real) ⇒ 'b) ⇒₀ int, b::((nat ⇒ real) ⇒ 'b) ⇒₀ int). singular_chain p (subtopology U (V::'b set)) (a - b)}›*)
apply (rule_tac x="- prism p c" in exI (*‹?P ?x ⟹ ∃x. ?P x›*))
(*goal: ‹∃d. singular_chain (Suc p) U d ∧ (chain_boundary (Suc p) d, chain_map p f c - chain_map p g c) ∈ {(a, b). singular_chain p (subtopology U V) (a - b)}›*)
by (simp add: chain_boundary_minus (*‹chain_boundary (?p::nat) (- (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int)) = - chain_boundary ?p ?c›*) prism( (*‹singular_chain (?q::nat) (S::'a topology) (?c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⟹ singular_chain (Suc ?q) (U::'b topology) ((prism::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'b) ⇒₀ int) ?q ?c)›*) 2) prism( (*‹singular_chain (?q::nat) (S::'a topology) (?c::((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⟹ chain_boundary (Suc ?q) ((prism::nat ⇒ (((nat ⇒ real) ⇒ 'a) ⇒₀ int) ⇒ ((nat ⇒ real) ⇒ 'b) ⇒₀ int) ?q ?c) = chain_map ?q (g::'a ⇒ 'b) ?c - chain_map ?q (f::'a ⇒ 'b) ?c - prism (?q - (1::nat)) (chain_boundary ?q ?c)›*) 4) singular_chain_minus (*‹singular_chain (?p::nat) (?X::?'a topology) (- (?c::((nat ⇒ real) ⇒ ?'a) ⇒₀ int)) = singular_chain ?p ?X ?c›*))
qed
end
| {
"path": "Isabelle2024/src/HOL/Homology/Simplices.thy",
"repo": "Isabelle2024",
"sha": "c85e6e253dac597180df293639c374c5f228e6198f57a9434927fd9f24ba84da"
} |
subsection‹ScottVariantHOMLAndersonQuant.thy (Figure 15 of \cite{J75})›
text‹Verification of Scottâs variant of Gödelâs argument with a mixed use of actualist and possibilist quantifiers
for entities; cf. Footnote 20 in \cite{J75}.›
theory ScottVariantHOMLAndersonQuant imports HOMLinHOL ModalFilter
begin
consts PositiveProperty::"(e⇒σ)⇒σ" ("P")
axiomatization where A1: "⌊❙¬P φ ❙↔ P ❙~φ⌋"
axiomatization where A2: "⌊P φ ❙∧ ❙□(❙∀y. φ y ❙⊃ ψ y) ❙⊃ P ψ⌋"
theorem T1: "⌊P φ ❙⊃ ❙◇(❙∃x. φ x)⌋" using A1 (*‹⌊λw. (❙¬?φ ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) A2 (*‹⌊?φ ❙∈ P ❙∧ ❙□(λv. ∀x. (?φ x ❙⊃ ?ψ x) v) ❙⊃ ?ψ ❙∈ P⌋›*) by smt
definition God ("G") where "G x ≡ ❙∀φ. P φ ❙⊃ φ x"
axiomatization where A3: "⌊P G⌋"
theorem Coro: "⌊❙◇(❙∃x. G x)⌋" using A3 (*‹⌊G ❙∈ P⌋›*) T1 (*‹⌊?φ ❙∈ P ❙⊃ ❙◇?φ ❙∈ Mexipossb⌋›*) by blast
axiomatization where A4: "⌊P φ ❙⊃ ❙□ P φ⌋"
definition Ess ("_Ess._") where "φ Ess. x ≡ φ x ❙∧ (❙∀ψ. ψ x ❙⊃ ❙□(❙∀y::e. φ y ❙⊃ ψ y))"
theorem T2: "⌊G x ❙⊃ G Ess. x⌋" using A1 (*‹⌊λw. (❙¬?φ ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) A4 (*‹⌊?φ ❙∈ P ❙⊃ ❙□?φ ❙∈ P⌋›*) Ess_def (*‹?φEss.?x ≡ λw. ?φ ?x w ∧ (∀x. (x ?x ❙⊃ ❙□(λv. ∀xa. (?φ xa ❙⊃ x xa) v)) w)›*) God_def (*‹G ?x ≡ λw. ∀x. (x ❙∈ P ❙⊃ x ?x) w›*) by smt
definition NecExist ("NE") where "NE x ≡ ❙∀φ. φ Ess. x ❙⊃ ❙□(❙∃⇧Ex. φ x)"
axiomatization where A5: "⌊P NE⌋"
lemma True nitpick[satisfy,card=1,eval="⌊P (λx.❙⊤)⌋"] oops ―‹One model found of cardinality one›
theorem T3: "⌊❙□(❙∃⇧Ex. G x)⌋"
―‹sledgehammer(A5 Coro God\_def NecExist\_def Rsymm T2)› ―‹Proof found›
proof (-)
(*goal: ‹⌊❙□G ❙∈ Mexiactb⌋›*)
have 1: "⌊(G x ❙⊃ NE x) ❙∧ (G Ess. x ❙⊃ ❙□(❙∃⇧Ex. G x))⌋"
using A5 (*‹⌊NE ❙∈ P⌋›*) Ess_def (*‹?φEss.?x ≡ λw. ?φ ?x w ∧ (∀x. (x ?x ❙⊃ ❙□(λv. ∀xa. (?φ xa ❙⊃ x xa) v)) w)›*) God_def (*‹G ?x ≡ λw. ∀x. (x ❙∈ P ❙⊃ x ?x) w›*) NecExist_def (*‹NE ?x ≡ λw. ∀x. (xEss.?x ❙⊃ ❙□x ❙∈ Mexiactb) w›*) by smt
hence 2: "⌊(❙∃x. G x) ❙⊃ ❙□(❙∃⇧Ex. G x)⌋"
using A5 (*‹⌊NE ❙∈ P⌋›*) God_def (*‹G ?x ≡ λw. ∀x. (x ❙∈ P ❙⊃ x ?x) w›*) NecExist_def (*‹NE ?x ≡ λw. ∀x. (xEss.?x ❙⊃ ❙□x ❙∈ Mexiactb) w›*) T2 (*‹⌊G (?x::e) ❙⊃ GEss.?x⌋›*) by smt
hence 3: "⌊❙◇(❙∃x. G x) ❙⊃ (❙◇(❙□(❙∃x. G x)) ❙⊃ ❙□(❙∃⇧Ex. G x))⌋"
using Rsymm (*‹⌊λx. (❙□(λy. y❙rx)) x⌋›*) by blast
thus "?thesis"
(*goal: ‹⌊❙□G ❙∈ Mexiactb⌋›*)
using "2" (*‹⌊G ❙∈ Mexipossb ❙⊃ ❙□G ❙∈ Mexiactb⌋›*) Coro (*‹⌊❙◇G ❙∈ Mexipossb⌋›*) by blast
qed
lemma MC: "⌊φ ❙⊃ ❙□φ⌋"
―‹sledgehammer(A1 A4 God\_def Rsymm T3)› ―‹Proof found›
proof (-)
(*goal: ‹⌊φ ❙⊃ ❙□φ⌋›*)
{
fix w
fix Q
have 1: "∀x.(G x w ⟶ (❙∀Z. Z x ❙⊃ ❙□(❙∀z.((G z) ❙⊃ (Z z)))) w)"
using A1 (*‹⌊λw::i. (❙¬(?φ::e ⇒ i ⇒ bool) ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) A4 (*‹⌊(?φ::e ⇒ i ⇒ bool) ❙∈ P ❙⊃ ❙□?φ ❙∈ P⌋›*) God_def (*‹G ?x ≡ λw. ∀x. (x ❙∈ P ❙⊃ x ?x) w›*) by smt
have 2: "(∃x. G x w)⟶((Q ❙⊃ ❙□(❙∀z.((G z) ❙⊃ Q))) w)"
using "1" (*‹∀x. G x w ⟶ (∀xa. (xa x ❙⊃ ❙□(λv. ∀x. (G x ❙⊃ xa x) v)) w)›*) by force
have 3: "(Q ❙⊃ ❙□Q) w"
using "2" (*‹(G ❙∈ Mexipossb ❙⊃ Q ❙⊃ ❙□(λv. ∀x. (G x ❙⊃ Q) v)) w›*) T3 (*‹⌊❙□G ❙∈ Mexiactb⌋›*) Rsymm (*‹⌊λx. (❙□(λy. y❙rx)) x⌋›*) by blast
}
thus "?thesis"
(*goal: ‹⌊φ ❙⊃ ❙□φ⌋›*)
by auto
qed
lemma PosProps: "⌊P (λx.❙⊤) ❙∧ P (λx. x ❙= x)⌋" using A1 (*‹⌊λw::i. (❙¬(?φ::e ⇒ i ⇒ bool) ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) A2 (*‹⌊?φ ❙∈ P ❙∧ ❙□(λv. ∀x. (?φ x ❙⊃ ?ψ x) v) ❙⊃ ?ψ ❙∈ P⌋›*) by blast
lemma NegProps: "⌊❙¬P(λx.❙⊥) ❙∧ ❙¬P(λx. x ❙≠ x)⌋" using A1 (*‹⌊λw. (❙¬?φ ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) A2 (*‹⌊?φ ❙∈ P ❙∧ ❙□(λv. ∀x. (?φ x ❙⊃ ?ψ x) v) ❙⊃ ?ψ ❙∈ P⌋›*) by blast
lemma UniqueEss1: "⌊φ Ess. x ❙∧ ψ Ess. x ❙⊃ ❙□(❙∀y. φ y ❙↔ ψ y)⌋" using Ess_def (*‹?φEss.?x ≡ λw. ?φ ?x w ∧ (∀x. (x ?x ❙⊃ ❙□(λv. ∀xa. (?φ xa ❙⊃ x xa) v)) w)›*) by smt
lemma UniqueEss2: "⌊φ Ess. x ❙∧ ψ Ess. x ❙⊃ ❙□(φ ❙= ψ)⌋" nitpick[card i=2] oops ―‹Countermodel found›
lemma UniqueEss3: "⌊φ Ess. x ❙⊃ ❙□(❙∀y. φ y ❙⊃ y ❙≡ x)⌋" using Ess_def (*‹?φEss.?x ≡ λw. ?φ ?x w ∧ (∀x. (x ?x ❙⊃ ❙□(λv. ∀xa. (?φ xa ❙⊃ x xa) v)) w)›*) MC (*‹⌊?φ ❙⊃ ❙□?φ⌋›*) by auto
lemma Monotheism: "⌊G x ❙∧ G y ❙⊃ x ❙≡ y⌋" using A1 (*‹⌊λw. (❙¬?φ ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) God_def (*‹G (?x::e) ≡ λw::i. ∀x::e ⇒ i ⇒ bool. (x ❙∈ P ❙⊃ x ?x) w›*) by smt
lemma Filter: "⌊Filter P⌋" using A1 (*‹⌊λw. (❙¬?φ ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) God_def (*‹G ?x ≡ λw. ∀x. (x ❙∈ P ❙⊃ x ?x) w›*) Rsymm (*‹⌊λx. (❙□(λy. y❙rx)) x⌋›*) T1 (*‹⌊?φ ❙∈ P ❙⊃ ❙◇?φ ❙∈ Mexipossb⌋›*) T3 (*‹⌊❙□G ❙∈ Mexiactb⌋›*) by (smt (verit, best))
lemma UltraFilter: "⌊UFilter P⌋" using Filter (*‹⌊λw. ((❙U ❙∈ P ❙∧ ❙¬❙∅ ❙∈ P) w ∧ (∀x xa. (x ❙∈ P) w ∧ (∀xb. (existsAt xb ❙⊃ x xb ❙⊃ xa xb) w) ⟶ (xa ❙∈ P) w)) ∧ (∀x xa. (x ❙∈ P ❙∧ xa ❙∈ P ❙⊃ (x ❙. xa) ❙∈ P) w)⌋›*) A1 (*‹⌊λw::i. (❙¬(?φ::e ⇒ i ⇒ bool) ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) by blast
lemma True nitpick[satisfy,card=1,eval="⌊P (λx.❙⊥)⌋"] oops ―‹One model found of cardinality one›
end
| {
"path": "afp-2025-02-12/thys/Notes_On_Goedels_Ontological_Argument/ScottVariantHOMLAndersonQuant.thy",
"repo": "afp-2025-02-12",
"sha": "6e5c34d3ea2d0f2177f576191731caf60995a406a3a9b42071841e01ed32457e"
} |
(* Author: Tobias Nipkow *)
section ‹Association List Update and Deletion›
theory AList_Upd_Del
imports Sorted_Less
begin
abbreviation "sorted1 ps ≡ sorted(map fst ps)"
text‹Define own ‹map_of› function to avoid pulling in an unknown
amount of lemmas implicitly (via the simpset).›
hide_const (open) map_of
fun map_of :: "('a*'b)list ⇒ 'a ⇒ 'b option" where
"map_of [] = (λx. None)" |
"map_of ((a,b)#ps) = (λx. if x=a then Some b else map_of ps x)"
text ‹Updating an association list:›
fun upd_list :: "'a::linorder ⇒ 'b ⇒ ('a*'b) list ⇒ ('a*'b) list" where
"upd_list x y [] = [(x,y)]" |
"upd_list x y ((a,b)#ps) =
(if x < a then (x,y)#(a,b)#ps else
if x = a then (x,y)#ps else (a,b) # upd_list x y ps)"
fun del_list :: "'a::linorder ⇒ ('a*'b)list ⇒ ('a*'b)list" where
"del_list x [] = []" |
"del_list x ((a,b)#ps) = (if x = a then ps else (a,b) # del_list x ps)"
subsection ‹Lemmas for \<^const>‹map_of››
lemma map_of_ins_list: "map_of (upd_list x y ps) = (map_of ps)(x := Some y)"
apply (induction ps)
(*goals:
1. ‹map_of (upd_list x y []) = (map_of [])(x ↦ y)›
2. ‹⋀a ps. map_of (upd_list x y ps) = (map_of ps)(x ↦ y) ⟹ map_of (upd_list x y (a # ps)) = (map_of (a # ps))(x ↦ y)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma map_of_append: "map_of (ps @ qs) x =
(case map_of ps x of None ⇒ map_of qs x | Some y ⇒ Some y)"
apply (induction ps)
(*goals:
1. ‹map_of ([] @ qs) x = (case map_of [] x of None ⇒ map_of qs x | Some y ⇒ Some y)›
2. ‹⋀a ps. map_of (ps @ qs) x = (case map_of ps x of None ⇒ map_of qs x | Some y ⇒ Some y) ⟹ map_of ((a # ps) @ qs) x = (case map_of (a # ps) x of None ⇒ map_of qs x | Some y ⇒ Some y)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma map_of_None: "sorted (x # map fst ps) ⟹ map_of ps x = None"
apply (induction ps)
(*goals:
1. ‹sorted (x # map fst []) ⟹ map_of [] x = None›
2. ‹⋀a ps. ⟦sorted (x # map fst ps) ⟹ map_of ps x = None; sorted (x # map fst (a # ps))⟧ ⟹ map_of (a # ps) x = None›
discuss goal 1*)
apply (fastforce simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ sorted (?xs @ ?y # ?ys) = (sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹ASSUMPTION (sorted (?x # ?xs)) ⟹ sorted ?xs› ‹ASSUMPTION (sorted (?xs @ [?y])) ⟹ sorted ?xs›*) sorted_wrt_Cons (*‹sorted_wrt ?P (?x # ?ys) = (Ball (set ?ys) (?P ?x) ∧ sorted_wrt ?P ?ys)›*))
(*discuss goal 2*)
apply (fastforce simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ sorted (?xs @ ?y # ?ys) = (sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹ASSUMPTION (sorted (?x # ?xs)) ⟹ sorted ?xs› ‹ASSUMPTION (sorted (?xs @ [?y])) ⟹ sorted ?xs›*) sorted_wrt_Cons (*‹sorted_wrt ?P (?x # ?ys) = (Ball (set ?ys) (?P ?x) ∧ sorted_wrt ?P ?ys)›*))
(*proven 2 subgoals*) .
lemma map_of_None2: "sorted (map fst ps @ [x]) ⟹ map_of ps x = None"
apply (induction ps)
(*goals:
1. ‹sorted (map fst [] @ [x::'a::linorder]) ⟹ map_of [] x = None›
2. ‹⋀(a::'a::linorder × 'b::type) ps::('a::linorder × 'b::type) list. ⟦sorted (map fst ps @ [x::'a::linorder]) ⟹ map_of ps x = None; sorted (map fst (a # ps) @ [x])⟧ ⟹ map_of (a # ps) x = None›
discuss goal 1*)
apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ sorted (?xs @ ?y # ?ys) = (sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹ASSUMPTION (sorted (?x # ?xs)) ⟹ sorted ?xs› ‹ASSUMPTION (sorted (?xs @ [?y])) ⟹ sorted ?xs›*))[1])
(*discuss goal 2*)
apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ sorted (?xs @ ?y # ?ys) = (sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹ASSUMPTION (sorted (?x # ?xs)) ⟹ sorted ?xs› ‹ASSUMPTION (sorted (?xs @ [?y])) ⟹ sorted ?xs›*))[1])
(*proven 2 subgoals*) .
lemma map_of_del_list: "sorted1 ps ⟹
map_of(del_list x ps) = (map_of ps)(x := None)"
apply (induction ps)
(*goals:
1. ‹sorted1 [] ⟹ map_of (del_list x []) = (map_of [])(x := None)›
2. ‹⋀a ps. ⟦sorted1 ps ⟹ map_of (del_list x ps) = (map_of ps)(x := None); sorted1 (a # ps)⟧ ⟹ map_of (del_list x (a # ps)) = (map_of (a # ps))(x := None)›
discuss goal 1*)
apply ((auto simp: map_of_None (*‹sorted (?x # map fst ?ps) ⟹ map_of ?ps ?x = None›*) sorted_lems (*‹NO_MATCH [] ?ys ⟹ sorted (?xs @ ?y # ?ys) = (sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹ASSUMPTION (sorted (?x # ?xs)) ⟹ sorted ?xs› ‹ASSUMPTION (sorted (?xs @ [?y])) ⟹ sorted ?xs›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*))[1])
(*discuss goal 2*)
apply ((auto simp: map_of_None (*‹sorted (?x # map fst ?ps) ⟹ map_of ?ps ?x = None›*) sorted_lems (*‹NO_MATCH [] ?ys ⟹ sorted (?xs @ ?y # ?ys) = (sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹ASSUMPTION (sorted (?x # ?xs)) ⟹ sorted ?xs› ‹ASSUMPTION (sorted (?xs @ [?y])) ⟹ sorted ?xs›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*))[1])
(*proven 2 subgoals*) .
lemma map_of_sorted_Cons: "sorted (a # map fst ps) ⟹ x < a ⟹
map_of ps x = None"
by (simp add: map_of_None (*‹sorted (?x # map fst ?ps) ⟹ map_of ?ps ?x = None›*) sorted_Cons_le (*‹⟦ASSUMPTION (sorted (?x # ?xs)); ?y ≤ ?x⟧ ⟹ sorted (?y # ?xs)›*))
lemma map_of_sorted_snoc: "sorted (map fst ps @ [a]) ⟹ a ≤ x ⟹
map_of ps x = None"
by (simp add: map_of_None2 (*‹sorted (map fst ?ps @ [?x]) ⟹ map_of ?ps ?x = None›*) sorted_snoc_le (*‹⟦ASSUMPTION (sorted (?xs @ [?x])); ?x ≤ ?y⟧ ⟹ sorted (?xs @ [?y])›*))
lemmas map_of_sorteds = map_of_sorted_Cons map_of_sorted_snoc
lemmas map_of_simps = sorted_lems map_of_append map_of_sorteds
subsection ‹Lemmas for \<^const>‹upd_list››
lemma sorted_upd_list: "sorted1 ps ⟹ sorted1 (upd_list x y ps)"
apply (induction ps)
(*goals:
1. ‹sorted1 [] ⟹ sorted1 (upd_list x y [])›
2. ‹⋀a ps. ⟦sorted1 ps ⟹ sorted1 (upd_list x y ps); sorted1 (a # ps)⟧ ⟹ sorted1 (upd_list x y (a # ps))›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (case_tac ps)
(*goals:
1. ‹⋀a ps. ⟦sorted1 ps ⟹ sorted1 (upd_list x y ps); sorted1 (a # ps); ps = []⟧ ⟹ sorted1 (upd_list x y (a # ps))›
2. ‹⋀a ps aa list. ⟦sorted1 ps ⟹ sorted1 (upd_list x y ps); sorted1 (a # ps); ps = aa # list⟧ ⟹ sorted1 (upd_list x y (a # ps))›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
lemma upd_list_sorted: "sorted1 (ps @ [(a,b)]) ⟹
upd_list x y (ps @ (a,b) # qs) =
(if x < a then upd_list x y ps @ (a,b) # qs
else ps @ upd_list x y ((a,b) # qs))"
apply (induction ps)
(*goals:
1. ‹sorted1 ([] @ [(a, b)]) ⟹ upd_list x y ([] @ (a, b) # qs) = (if x < a then upd_list x y [] @ (a, b) # qs else [] @ upd_list x y ((a, b) # qs))›
2. ‹⋀aa ps. ⟦sorted1 (ps @ [(a, b)]) ⟹ upd_list x y (ps @ (a, b) # qs) = (if x < a then upd_list x y ps @ (a, b) # qs else ps @ upd_list x y ((a, b) # qs)); sorted1 ((aa # ps) @ [(a, b)])⟧ ⟹ upd_list x y ((aa # ps) @ (a, b) # qs) = (if x < a then upd_list x y (aa # ps) @ (a, b) # qs else (aa # ps) @ upd_list x y ((a, b) # qs))›
discuss goal 1*)
apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ sorted (?xs @ ?y # ?ys) = (sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹ASSUMPTION (sorted (?x # ?xs)) ⟹ sorted ?xs› ‹ASSUMPTION (sorted (?xs @ [?y])) ⟹ sorted ?xs›*))[1])
(*discuss goal 2*)
apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ sorted (?xs @ ?y # ?ys) = (sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹ASSUMPTION (sorted (?x # ?xs)) ⟹ sorted ?xs› ‹ASSUMPTION (sorted (?xs @ [?y])) ⟹ sorted ?xs›*))[1])
(*proven 2 subgoals*) .
text‹In principle, @{thm upd_list_sorted} suffices, but the following two
corollaries speed up proofs.›
corollary upd_list_sorted1: "⟦ sorted (map fst ps @ [a]); x < a ⟧ ⟹
upd_list x y (ps @ (a,b) # qs) = upd_list x y ps @ (a,b) # qs"
by (auto simp: upd_list_sorted (*‹sorted1 (?ps @ [(?a, ?b)]) ⟹ upd_list ?x ?y (?ps @ (?a, ?b) # ?qs) = (if ?x < ?a then upd_list ?x ?y ?ps @ (?a, ?b) # ?qs else ?ps @ upd_list ?x ?y ((?a, ?b) # ?qs))›*))
corollary upd_list_sorted2: "⟦ sorted (map fst ps @ [a]); a ≤ x ⟧ ⟹
upd_list x y (ps @ (a,b) # qs) = ps @ upd_list x y ((a,b) # qs)"
by (auto simp: upd_list_sorted (*‹sorted1 (?ps @ [(?a, ?b)]) ⟹ upd_list ?x ?y (?ps @ (?a, ?b) # ?qs) = (if ?x < ?a then upd_list ?x ?y ?ps @ (?a, ?b) # ?qs else ?ps @ upd_list ?x ?y ((?a, ?b) # ?qs))›*))
lemmas upd_list_simps = sorted_lems upd_list_sorted1 upd_list_sorted2
text‹Splay trees need two additional \<^const>‹upd_list› lemmas:›
lemma upd_list_Cons:
"sorted1 ((x,y) # xs) ⟹ upd_list x y xs = (x,y) # xs"
apply (induction xs)
(*goals:
1. ‹sorted1 [(x, y)] ⟹ upd_list x y [] = [(x, y)]›
2. ‹⋀a xs. ⟦sorted1 ((x, y) # xs) ⟹ upd_list x y xs = (x, y) # xs; sorted1 ((x, y) # a # xs)⟧ ⟹ upd_list x y (a # xs) = (x, y) # a # xs›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma upd_list_snoc:
"sorted1 (xs @ [(x,y)]) ⟹ upd_list x y xs = xs @ [(x,y)]"
apply (induction xs)
(*goals:
1. ‹sorted1 ([] @ [(x::'a, y::'b)]) ⟹ upd_list x y [] = [] @ [(x, y)]›
2. ‹⋀(a::'a × 'b) xs::('a × 'b) list. ⟦sorted1 (xs @ [(x::'a, y::'b)]) ⟹ upd_list x y xs = xs @ [(x, y)]; sorted1 ((a # xs) @ [(x, y)])⟧ ⟹ upd_list x y (a # xs) = (a # xs) @ [(x, y)]›
discuss goal 1*)
apply ((auto simp add: sorted_mid_iff2 (*‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))›*))[1])
(*discuss goal 2*)
apply ((auto simp add: sorted_mid_iff2 (*‹sorted ((?x::?'a::linorder) # (?xs::?'a::linorder list) @ (?y::?'a::linorder) # (?ys::?'a::linorder list)) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))›*))[1])
(*proven 2 subgoals*) .
subsection ‹Lemmas for \<^const>‹del_list››
lemma sorted_del_list: "sorted1 ps ⟹ sorted1 (del_list x ps)"
apply (induction ps)
(*goals:
1. ‹sorted1 [] ⟹ sorted1 (del_list x [])›
2. ‹⋀a ps. ⟦sorted1 ps ⟹ sorted1 (del_list x ps); sorted1 (a # ps)⟧ ⟹ sorted1 (del_list x (a # ps))›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (case_tac ps)
(*goals:
1. ‹⋀a ps. ⟦sorted1 ps ⟹ sorted1 (del_list x ps); sorted1 (a # ps); ps = []⟧ ⟹ sorted1 (del_list x (a # ps))›
2. ‹⋀a ps aa list. ⟦sorted1 ps ⟹ sorted1 (del_list x ps); sorted1 (a # ps); ps = aa # list⟧ ⟹ sorted1 (del_list x (a # ps))›
discuss goal 1*)
apply ((auto simp: sorted_Cons_le (*‹⟦ASSUMPTION (sorted (?x # ?xs)); ?y ≤ ?x⟧ ⟹ sorted (?y # ?xs)›*))[1])
(*discuss goal 2*)
apply ((auto simp: sorted_Cons_le (*‹⟦ASSUMPTION (sorted (?x # ?xs)); ?y ≤ ?x⟧ ⟹ sorted (?y # ?xs)›*))[1])
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
lemma del_list_idem: "x ∉ set(map fst xs) ⟹ del_list x xs = xs"
apply (induct xs)
(*goals:
1. ‹x ∉ set (map fst []) ⟹ del_list x [] = []›
2. ‹⋀a xs. ⟦x ∉ set (map fst xs) ⟹ del_list x xs = xs; x ∉ set (map fst (a # xs))⟧ ⟹ del_list x (a # xs) = a # xs›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma del_list_sorted: "sorted1 (ps @ (a,b) # qs) ⟹
del_list x (ps @ (a,b) # qs) =
(if x < a then del_list x ps @ (a,b) # qs
else ps @ del_list x ((a,b) # qs))"
apply (induction ps)
(*goals:
1. ‹sorted1 ([] @ (a, b) # qs) ⟹ del_list x ([] @ (a, b) # qs) = (if x < a then del_list x [] @ (a, b) # qs else [] @ del_list x ((a, b) # qs))›
2. ‹⋀aa ps. ⟦sorted1 (ps @ (a, b) # qs) ⟹ del_list x (ps @ (a, b) # qs) = (if x < a then del_list x ps @ (a, b) # qs else ps @ del_list x ((a, b) # qs)); sorted1 ((aa # ps) @ (a, b) # qs)⟧ ⟹ del_list x ((aa # ps) @ (a, b) # qs) = (if x < a then del_list x (aa # ps) @ (a, b) # qs else (aa # ps) @ del_list x ((a, b) # qs))›
discuss goal 1*)
apply (fastforce simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ sorted (?xs @ ?y # ?ys) = (sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹ASSUMPTION (sorted (?x # ?xs)) ⟹ sorted ?xs› ‹ASSUMPTION (sorted (?xs @ [?y])) ⟹ sorted ?xs›*) sorted_wrt_Cons (*‹sorted_wrt ?P (?x # ?ys) = (Ball (set ?ys) (?P ?x) ∧ sorted_wrt ?P ?ys)›*) intro!: del_list_idem (*‹?x ∉ set (map fst ?xs) ⟹ del_list ?x ?xs = ?xs›*))
(*discuss goal 2*)
apply (fastforce simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ sorted (?xs @ ?y # ?ys) = (sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹ASSUMPTION (sorted (?x # ?xs)) ⟹ sorted ?xs› ‹ASSUMPTION (sorted (?xs @ [?y])) ⟹ sorted ?xs›*) sorted_wrt_Cons (*‹sorted_wrt ?P (?x # ?ys) = (Ball (set ?ys) (?P ?x) ∧ sorted_wrt ?P ?ys)›*) intro!: del_list_idem (*‹?x ∉ set (map fst ?xs) ⟹ del_list ?x ?xs = ?xs›*))
(*proven 2 subgoals*) .
text‹In principle, @{thm del_list_sorted} suffices, but the following
corollaries speed up proofs.›
corollary del_list_sorted1: "sorted1 (xs @ (a,b) # ys) ⟹ a ≤ x ⟹
del_list x (xs @ (a,b) # ys) = xs @ del_list x ((a,b) # ys)"
by (auto simp: del_list_sorted (*‹sorted1 (?ps @ (?a, ?b) # ?qs) ⟹ del_list ?x (?ps @ (?a, ?b) # ?qs) = (if ?x < ?a then del_list ?x ?ps @ (?a, ?b) # ?qs else ?ps @ del_list ?x ((?a, ?b) # ?qs))›*))
lemma del_list_sorted2: "sorted1 (xs @ (a,b) # ys) ⟹ x < a ⟹
del_list x (xs @ (a,b) # ys) = del_list x xs @ (a,b) # ys"
by (auto simp: del_list_sorted (*‹sorted1 (?ps @ (?a, ?b) # ?qs) ⟹ del_list ?x (?ps @ (?a, ?b) # ?qs) = (if ?x < ?a then del_list ?x ?ps @ (?a, ?b) # ?qs else ?ps @ del_list ?x ((?a, ?b) # ?qs))›*))
lemma del_list_sorted3:
"sorted1 (xs @ (a,a') # ys @ (b,b') # zs) ⟹ x < b ⟹
del_list x (xs @ (a,a') # ys @ (b,b') # zs) = del_list x (xs @ (a,a') # ys) @ (b,b') # zs"
by (auto simp: del_list_sorted (*‹sorted1 (?ps @ (?a, ?b) # ?qs) ⟹ del_list ?x (?ps @ (?a, ?b) # ?qs) = (if ?x < ?a then del_list ?x ?ps @ (?a, ?b) # ?qs else ?ps @ del_list ?x ((?a, ?b) # ?qs))›*) sorted_lems (*‹NO_MATCH [] ?ys ⟹ sorted (?xs @ ?y # ?ys) = (sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹ASSUMPTION (sorted (?x # ?xs)) ⟹ sorted ?xs› ‹ASSUMPTION (sorted (?xs @ [?y])) ⟹ sorted ?xs›*))
lemma del_list_sorted4:
"sorted1 (xs @ (a,a') # ys @ (b,b') # zs @ (c,c') # us) ⟹ x < c ⟹
del_list x (xs @ (a,a') # ys @ (b,b') # zs @ (c,c') # us) = del_list x (xs @ (a,a') # ys @ (b,b') # zs) @ (c,c') # us"
by (auto simp: del_list_sorted (*‹sorted1 ((?ps::(?'a::linorder × ?'b::type) list) @ (?a::?'a::linorder, ?b::?'b::type) # (?qs::(?'a::linorder × ?'b::type) list)) ⟹ del_list (?x::?'a::linorder) (?ps @ (?a, ?b) # ?qs) = (if ?x < ?a then del_list ?x ?ps @ (?a, ?b) # ?qs else ?ps @ del_list ?x ((?a, ?b) # ?qs))›*) sorted_lems (*‹NO_MATCH [] (?ys::?'b::linorder list) ⟹ sorted ((?xs::?'b::linorder list) @ (?y::?'b::linorder) # ?ys) = (sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹sorted ((?x::?'a::linorder) # (?xs::?'a::linorder list) @ (?y::?'a::linorder) # (?ys::?'a::linorder list)) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹ASSUMPTION (sorted ((?x::?'a::linorder) # (?xs::?'a::linorder list))) ⟹ sorted ?xs› ‹ASSUMPTION (sorted ((?xs::?'a::linorder list) @ [?y::?'a::linorder])) ⟹ sorted ?xs›*))
lemma del_list_sorted5:
"sorted1 (xs @ (a,a') # ys @ (b,b') # zs @ (c,c') # us @ (d,d') # vs) ⟹ x < d ⟹
del_list x (xs @ (a,a') # ys @ (b,b') # zs @ (c,c') # us @ (d,d') # vs) =
del_list x (xs @ (a,a') # ys @ (b,b') # zs @ (c,c') # us) @ (d,d') # vs"
by (auto simp: del_list_sorted (*‹sorted1 (?ps @ (?a, ?b) # ?qs) ⟹ del_list ?x (?ps @ (?a, ?b) # ?qs) = (if ?x < ?a then del_list ?x ?ps @ (?a, ?b) # ?qs else ?ps @ del_list ?x ((?a, ?b) # ?qs))›*) sorted_lems (*‹NO_MATCH [] ?ys ⟹ sorted (?xs @ ?y # ?ys) = (sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))› ‹ASSUMPTION (sorted (?x # ?xs)) ⟹ sorted ?xs› ‹ASSUMPTION (sorted (?xs @ [?y])) ⟹ sorted ?xs›*))
lemmas del_list_simps = sorted_lems
del_list_sorted1
del_list_sorted2
del_list_sorted3
del_list_sorted4
del_list_sorted5
text‹Splay trees need two additional \<^const>‹del_list› lemmas:›
lemma del_list_notin_Cons: "sorted (x # map fst xs) ⟹ del_list x xs = xs"
apply (induction xs)
(*goals:
1. ‹sorted (x # map fst []) ⟹ del_list x [] = []›
2. ‹⋀a xs. ⟦sorted (x # map fst xs) ⟹ del_list x xs = xs; sorted (x # map fst (a # xs))⟧ ⟹ del_list x (a # xs) = a # xs›
discuss goal 1*)
apply (fastforce simp: sorted_wrt_Cons (*‹sorted_wrt (?P::?'a ⇒ ?'a ⇒ bool) ((?x::?'a) # (?ys::?'a list)) = (Ball (set ?ys) (?P ?x) ∧ sorted_wrt ?P ?ys)›*))
(*discuss goal 2*)
apply (fastforce simp: sorted_wrt_Cons (*‹sorted_wrt ?P (?x # ?ys) = (Ball (set ?ys) (?P ?x) ∧ sorted_wrt ?P ?ys)›*))
(*proven 2 subgoals*) .
lemma del_list_sorted_app:
"sorted(map fst xs @ [x]) ⟹ del_list x (xs @ ys) = xs @ del_list x ys"
apply (induction xs)
(*goals:
1. ‹sorted (map fst [] @ [x]) ⟹ del_list x ([] @ ys) = [] @ del_list x ys›
2. ‹⋀a xs. ⟦sorted (map fst xs @ [x]) ⟹ del_list x (xs @ ys) = xs @ del_list x ys; sorted (map fst (a # xs) @ [x])⟧ ⟹ del_list x ((a # xs) @ ys) = (a # xs) @ del_list x ys›
discuss goal 1*)
apply ((auto simp: sorted_mid_iff2 (*‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))›*))[1])
(*discuss goal 2*)
apply ((auto simp: sorted_mid_iff2 (*‹sorted (?x # ?xs @ ?y # ?ys) = (sorted (?x # ?xs) ∧ ?x < ?y ∧ sorted (?xs @ [?y]) ∧ sorted (?y # ?ys))›*))[1])
(*proven 2 subgoals*) .
end
| {
"path": "Isabelle2024/src/HOL/Data_Structures/AList_Upd_Del.thy",
"repo": "Isabelle2024",
"sha": "980e53c817d0b020d3ad33516a358dd3a339ef6aa16ff47cd41bee42e5ba111e"
} |
theory Refine_Rigorous_Numerics_Aform
imports
Refine_Rigorous_Numerics
"HOL-Types_To_Sets.Types_To_Sets"
begin
lemma Joints_ne_empty[simp]: "Joints xs ≠ {}" "{} ≠ Joints xs"
(*goals:
1. ‹Joints xs ≠ {}›
2. ‹{} ≠ Joints xs›
discuss goal 1*)
apply ((auto simp: Joints_def (*‹Joints (?XS::(?'a × ?'a pdevs) list) = valuate (λe::nat ⇒ real. map (aform_val e) ?XS)›*) valuate_def (*‹valuate (?x::(nat ⇒ real) ⇒ ?'a) = ?x ` funcset UNIV {- (1::real)..1::real}›*))[1])
(*discuss goal 2*)
apply ((auto simp: Joints_def (*‹Joints (?XS::(?'a × ?'a pdevs) list) = valuate (λe::nat ⇒ real. map (aform_val e) ?XS)›*) valuate_def (*‹valuate (?x::(nat ⇒ real) ⇒ ?'a) = ?x ` funcset UNIV {- (1::real)..1::real}›*))[1])
(*proven 2 subgoals*) .
lemma Inf_aform_le_Affine: "x ∈ Affine X ⟹ Inf_aform X ≤ x"
by (auto simp: Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) intro!: Inf_aform (*‹?e ∈ funcset UNIV {- 1..1} ⟹ Inf_aform ?X ≤ aform_val ?e ?X›*))
lemma Sup_aform_ge_Affine: "x ∈ Affine X ⟹ x ≤ Sup_aform X"
by (auto simp: Affine_def (*‹Affine (?X::?'a × ?'a pdevs) = valuate (λe::nat ⇒ real. aform_val e ?X)›*) valuate_def (*‹valuate (?x::(nat ⇒ real) ⇒ ?'a) = ?x ` funcset UNIV {- (1::real)..1::real}›*) intro!: Sup_aform (*‹(?e::nat ⇒ real) ∈ funcset UNIV {- (1::real)..1::real} ⟹ aform_val ?e (?X::?'a × ?'a pdevs) ≤ Sup_aform ?X›*))
lemmas Inf_aform'_Affine_le = order_trans[OF Inf_aform' Inf_aform_le_Affine]
lemmas Sup_aform'_Affine_ge = order_trans[OF Sup_aform_ge_Affine Sup_aform']
fun approx_form_aform :: "nat ⇒ form ⇒ real aform list ⇒ bool" where
"approx_form_aform prec (Less a b) bs =
(case (approx_floatariths prec [a - b] bs)
of Some [r] ⇒ Sup_aform' prec r < 0
| _ ⇒ False)"
| "approx_form_aform prec (LessEqual a b) bs =
(case (approx_floatariths prec [a - b] bs)
of Some [r] ⇒ Sup_aform' prec r ≤ 0
| _ ⇒ False)"
| "approx_form_aform prec (AtLeastAtMost a b c) bs =
(case (approx_floatariths prec [a - b, a - c] bs)
of Some [r, s] ⇒ 0 ≤ Inf_aform' prec r ∧ Sup_aform' prec s ≤ 0
| _ ⇒ False)"
| "approx_form_aform prec (Bound a b c d) bs = False"
| "approx_form_aform prec (Assign a b c) bs = False"
| "approx_form_aform prec (Conj a b) bs ⟷
approx_form_aform prec a bs ∧ approx_form_aform prec b bs"
| "approx_form_aform prec (Disj a b) bs ⟷
approx_form_aform prec a bs ∨ approx_form_aform prec b bs"
lemma in_Joints_intervalD:
"x ∈ {Inf_aform' p X .. Sup_aform' p X} ∧ xs ∈ Joints XS"
if "x#xs ∈ Joints (X#XS)"
using that (*‹x # xs ∈ Joints (X # XS)›*) by (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) intro!: Inf_aform'_Affine_le (*‹?z ∈ Affine ?X ⟹ Inf_aform' ?p ?X ≤ ?z›*) Sup_aform'_Affine_ge (*‹?x ∈ Affine ?X ⟹ ?x ≤ Sup_aform' ?p ?X›*))
lemma approx_form_aform:
"interpret_form f vs"
if "approx_form_aform p f VS" "vs ∈ Joints VS"
using that (*‹approx_form_aform p f VS› ‹vs ∈ Joints VS›*) apply (induction f)
(*goals:
1. ‹⋀x1 x2 x3 f. ⟦⟦approx_form_aform p f VS; vs ∈ Joints VS⟧ ⟹ interpret_form f vs; approx_form_aform p (Bound x1 x2 x3 f) VS; vs ∈ Joints VS⟧ ⟹ interpret_form (Bound x1 x2 x3 f) vs›
2. ‹⋀x1 x2 f. ⟦⟦approx_form_aform p f VS; vs ∈ Joints VS⟧ ⟹ interpret_form f vs; approx_form_aform p (Assign x1 x2 f) VS; vs ∈ Joints VS⟧ ⟹ interpret_form (Assign x1 x2 f) vs›
3. ‹⋀x1 x2. ⟦approx_form_aform p (Less x1 x2) VS; vs ∈ Joints VS⟧ ⟹ interpret_form (Less x1 x2) vs›
4. ‹⋀x1 x2. ⟦approx_form_aform p (LessEqual x1 x2) VS; vs ∈ Joints VS⟧ ⟹ interpret_form (LessEqual x1 x2) vs›
5. ‹⋀x1 x2 x3. ⟦approx_form_aform p (AtLeastAtMost x1 x2 x3) VS; vs ∈ Joints VS⟧ ⟹ interpret_form (AtLeastAtMost x1 x2 x3) vs›
6. ‹⋀f1 f2. ⟦⟦approx_form_aform p f1 VS; vs ∈ Joints VS⟧ ⟹ interpret_form f1 vs; ⟦approx_form_aform p f2 VS; vs ∈ Joints VS⟧ ⟹ interpret_form f2 vs; approx_form_aform p (Conj f1 f2) VS; vs ∈ Joints VS⟧ ⟹ interpret_form (Conj f1 f2) vs›
7. ‹⋀f1 f2. ⟦⟦approx_form_aform p f1 VS; vs ∈ Joints VS⟧ ⟹ interpret_form f1 vs; ⟦approx_form_aform p f2 VS; vs ∈ Joints VS⟧ ⟹ interpret_form f2 vs; approx_form_aform p (Disj f1 f2) VS; vs ∈ Joints VS⟧ ⟹ interpret_form (Disj f1 f2) vs›
discuss goal 1*)
apply ((auto split: option.splits (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) list.splits (*‹(?P::?'b ⇒ bool) (case ?list::?'a list of [] ⇒ ?f1.0::?'b | (x::?'a) # (xa::?'a list) ⇒ (?f2.0::?'a ⇒ ?'a list ⇒ ?'b) x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀(x21::?'a) x22::?'a list. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))› ‹(?P::?'b ⇒ bool) (case ?list::?'a list of [] ⇒ ?f1.0::?'b | (x::?'a) # (xa::?'a list) ⇒ (?f2.0::?'a ⇒ ?'a list ⇒ ?'b) x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃(x21::?'a) x22::?'a list. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*) simp: algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 34 facts*) dest!: approx_floatariths_outer (*‹⟦approx_floatariths (?p::nat) (?ea::floatarith list) (?as::(real × real pdevs) list) = Some (?XS::(real × real pdevs) list); (?vs::real list) ∈ Joints ?as⟧ ⟹ interpret_floatariths ?ea ?vs @ ?vs ∈ Joints (?XS @ ?as)›*) dest!: in_Joints_intervalD[where p=p] (*‹(?x::?'a) # (?xs::?'a list) ∈ Joints ((?X::?'a × ?'a pdevs) # (?XS::(?'a × ?'a pdevs) list)) ⟹ ?x ∈ {Inf_aform' (p::nat) ?X..Sup_aform' p ?X} ∧ ?xs ∈ Joints ?XS›*))[1])
(*discuss goal 2*)
apply ((auto split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) list.splits (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))› ‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*) simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) dest!: approx_floatariths_outer (*‹⟦approx_floatariths ?p ?ea ?as = Some ?XS; ?vs ∈ Joints ?as⟧ ⟹ interpret_floatariths ?ea ?vs @ ?vs ∈ Joints (?XS @ ?as)›*) dest!: in_Joints_intervalD[where p=p] (*‹?x # ?xs ∈ Joints (?X # ?XS) ⟹ ?x ∈ {Inf_aform' p ?X..Sup_aform' p ?X} ∧ ?xs ∈ Joints ?XS›*))[1])
(*discuss goal 3*)
apply ((auto split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) list.splits (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))› ‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*) simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) dest!: approx_floatariths_outer (*‹⟦approx_floatariths ?p ?ea ?as = Some ?XS; ?vs ∈ Joints ?as⟧ ⟹ interpret_floatariths ?ea ?vs @ ?vs ∈ Joints (?XS @ ?as)›*) dest!: in_Joints_intervalD[where p=p] (*‹?x # ?xs ∈ Joints (?X # ?XS) ⟹ ?x ∈ {Inf_aform' p ?X..Sup_aform' p ?X} ∧ ?xs ∈ Joints ?XS›*))[1])
(*discuss goal 4*)
apply ((auto split: option.splits (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) list.splits (*‹(?P::?'b ⇒ bool) (case ?list::?'a list of [] ⇒ ?f1.0::?'b | (x::?'a) # (xa::?'a list) ⇒ (?f2.0::?'a ⇒ ?'a list ⇒ ?'b) x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀(x21::?'a) x22::?'a list. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))› ‹(?P::?'b ⇒ bool) (case ?list::?'a list of [] ⇒ ?f1.0::?'b | (x::?'a) # (xa::?'a list) ⇒ (?f2.0::?'a ⇒ ?'a list ⇒ ?'b) x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃(x21::?'a) x22::?'a list. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*) simp: algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 34 facts*) dest!: approx_floatariths_outer (*‹⟦approx_floatariths (?p::nat) (?ea::floatarith list) (?as::(real × real pdevs) list) = Some (?XS::(real × real pdevs) list); (?vs::real list) ∈ Joints ?as⟧ ⟹ interpret_floatariths ?ea ?vs @ ?vs ∈ Joints (?XS @ ?as)›*) dest!: in_Joints_intervalD[where p=p] (*‹(?x::?'a) # (?xs::?'a list) ∈ Joints ((?X::?'a × ?'a pdevs) # (?XS::(?'a × ?'a pdevs) list)) ⟹ ?x ∈ {Inf_aform' (p::nat) ?X..Sup_aform' p ?X} ∧ ?xs ∈ Joints ?XS›*))[1])
(*discuss goal 5*)
apply ((auto split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) list.splits (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))› ‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*) simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) dest!: approx_floatariths_outer (*‹⟦approx_floatariths ?p ?ea ?as = Some ?XS; ?vs ∈ Joints ?as⟧ ⟹ interpret_floatariths ?ea ?vs @ ?vs ∈ Joints (?XS @ ?as)›*) dest!: in_Joints_intervalD[where p=p] (*‹?x # ?xs ∈ Joints (?X # ?XS) ⟹ ?x ∈ {Inf_aform' p ?X..Sup_aform' p ?X} ∧ ?xs ∈ Joints ?XS›*))[1])
(*discuss goal 6*)
apply ((auto split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) list.splits (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))› ‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*) simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) dest!: approx_floatariths_outer (*‹⟦approx_floatariths ?p ?ea ?as = Some ?XS; ?vs ∈ Joints ?as⟧ ⟹ interpret_floatariths ?ea ?vs @ ?vs ∈ Joints (?XS @ ?as)›*) dest!: in_Joints_intervalD[where p=p] (*‹?x # ?xs ∈ Joints (?X # ?XS) ⟹ ?x ∈ {Inf_aform' p ?X..Sup_aform' p ?X} ∧ ?xs ∈ Joints ?XS›*))[1])
(*discuss goal 7*)
apply ((auto split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) list.splits (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))› ‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*) simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) dest!: approx_floatariths_outer (*‹⟦approx_floatariths ?p ?ea ?as = Some ?XS; ?vs ∈ Joints ?as⟧ ⟹ interpret_floatariths ?ea ?vs @ ?vs ∈ Joints (?XS @ ?as)›*) dest!: in_Joints_intervalD[where p=p] (*‹?x # ?xs ∈ Joints (?X # ?XS) ⟹ ?x ∈ {Inf_aform' p ?X..Sup_aform' p ?X} ∧ ?xs ∈ Joints ?XS›*))[1])
(*proven 7 subgoals*) .
fun msum_aforms::"nat ⇒ real aform list ⇒ real aform list ⇒ real aform list" where
"msum_aforms d (x#xs) (y#ys) = msum_aform d x y#msum_aforms d xs ys"
| "msum_aforms d _ _ = []"
definition [simp]: "degree_aforms_real = (degree_aforms::real aform list ⇒ nat)"
abbreviation "msum_aforms' ≡ λX Y. msum_aforms (degree_aforms_real (X @ Y)) X Y"
lemma aform_val_msum_aforms:
assumes "degree_aforms xs ≤ d"
shows "aform_vals e (msum_aforms d xs ys) = List.map2 (+) (aform_vals e xs) (aform_vals (λi. e (i + d)) ys)"
using assms (*‹degree_aforms xs ≤ d›*) proof (induction xs ys rule: msum_aforms.induct (*‹⟦⋀d x xs y ys. ?P d xs ys ⟹ ?P d (x # xs) (y # ys); ⋀d uv_. ?P d [] uv_; ⋀d uu_. ?P d uu_ []⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*))
(*goals:
1. ‹⋀d x xs y ys. ⟦degree_aforms xs ≤ d ⟹ aform_vals e (msum_aforms d xs ys) = map2 (+) (aform_vals e xs) (aform_vals (λi. e (i + d)) ys); degree_aforms (x # xs) ≤ d⟧ ⟹ aform_vals e (msum_aforms d (x # xs) (y # ys)) = map2 (+) (aform_vals e (x # xs)) (aform_vals (λi. e (i + d)) (y # ys))›
2. ‹⋀d uv_. degree_aforms [] ≤ d ⟹ aform_vals e (msum_aforms d [] uv_) = map2 (+) (aform_vals e []) (aform_vals (λi. e (i + d)) uv_)›
3. ‹⋀d uu_. degree_aforms uu_ ≤ d ⟹ aform_vals e (msum_aforms d uu_ []) = map2 (+) (aform_vals e uu_) (aform_vals (λi. e (i + d)) [])›*)
case (1 d x xs y ys) (*‹degree_aforms (xs::(real × real pdevs) list) ≤ (d::nat) ⟹ aform_vals (e::nat ⇒ real) (msum_aforms d xs (ys::(real × real pdevs) list)) = map2 (+) (aform_vals e xs) (aform_vals (λi::nat. e (i + d)) ys)› ‹degree_aforms (x # xs) ≤ d›*)
from "1" (*‹degree_aforms (xs::(real × real pdevs) list) ≤ (d::nat) ⟹ aform_vals (e::nat ⇒ real) (msum_aforms d xs (ys::(real × real pdevs) list)) = map2 (+) (aform_vals e xs) (aform_vals (λi::nat. e (i + d)) ys)› ‹degree_aforms ((x::real × real pdevs) # (xs::(real × real pdevs) list)) ≤ (d::nat)›*) have "degree_aforms xs ≤ d"
by (auto simp: degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*))
from "1"(1)[OF this] (*‹aform_vals e (msum_aforms d xs ys) = map2 (+) (aform_vals e xs) (aform_vals (λi. e (i + d)) ys)›*) "1" (*‹degree_aforms (xs::(real × real pdevs) list) ≤ (d::nat) ⟹ aform_vals (e::nat ⇒ real) (msum_aforms d xs (ys::(real × real pdevs) list)) = map2 (+) (aform_vals e xs) (aform_vals (λi::nat. e (i + d)) ys)› ‹degree_aforms (x # xs) ≤ d›*) have "aform_vals e (msum_aforms d xs ys) = List.map2 (+) (aform_vals e xs) (aform_vals (λi. e (i + d)) ys)"
by simp
then show "?case"
(*goal: ‹aform_vals (e::nat ⇒ real) (msum_aforms (d::nat) ((x::real × real pdevs) # (xs::(real × real pdevs) list)) ((y::real × real pdevs) # (ys::(real × real pdevs) list))) = map2 (+) (aform_vals e (x # xs)) (aform_vals (λi::nat. e (i + d)) (y # ys))›*)
using "1" (*‹degree_aforms xs ≤ d ⟹ aform_vals e (msum_aforms d xs ys) = map2 (+) (aform_vals e xs) (aform_vals (λi. e (i + d)) ys)› ‹degree_aforms (x # xs) ≤ d›*) by (simp add: aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*) aform_val_msum_aform (*‹degree_aform ?f ≤ ?n ⟹ aform_val ?e (msum_aform ?n ?f ?g) = aform_val ?e ?f + aform_val (λi. ?e (i + ?n)) ?g›*) degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*))
qed (auto simp: aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*))
(*solves the remaining goals:
1. ‹⋀d uv_. degree_aforms [] ≤ d ⟹ aform_vals e (msum_aforms d [] uv_) = map2 (+) (aform_vals e []) (aform_vals (λi. e (i + d)) uv_)›
2. ‹⋀d uu_. degree_aforms uu_ ≤ d ⟹ aform_vals e (msum_aforms d uu_ []) = map2 (+) (aform_vals e uu_) (aform_vals (λi. e (i + d)) [])›*)
lemma Joints_msum_aforms:
assumes "degree_aforms xs ≤ d"
assumes "degree_aforms ys ≤ d"
shows "Joints (msum_aforms d xs ys) = {List.map2 (+) a b |a b. a ∈ Joints xs ∧ b ∈ Joints ys}"
apply (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) aform_vals_def[symmetric] (*‹map (aform_val ?e) ?X = aform_vals ?e ?X›*) aform_val_msum_aforms (*‹degree_aforms ?xs ≤ ?d ⟹ aform_vals ?e (msum_aforms ?d ?xs ?ys) = map2 (+) (aform_vals ?e ?xs) (aform_vals (λi. ?e (i + ?d)) ?ys)›*) assms (*‹degree_aforms xs ≤ d› ‹degree_aforms ys ≤ d›*))
(*goal: ‹Joints (msum_aforms d xs ys) = {map2 (+) a b |a b. a ∈ Joints xs ∧ b ∈ Joints ys}›*)
apply force
(*top goal: ‹⋀e::nat ⇒ real. e ∈ funcset UNIV {- (1::real)..1::real} ⟹ ∃(a::real list) b::real list. map2 (+) (aform_vals e (xs::(real × real pdevs) list)) (aform_vals (λi::nat. e (i + (d::nat))) (ys::(real × real pdevs) list)) = map2 (+) a b ∧ a ∈ (λe::nat ⇒ real. aform_vals e xs) ` funcset UNIV {- (1::real)..1::real} ∧ b ∈ (λe::nat ⇒ real. aform_vals e ys) ` funcset UNIV {- (1::real)..1::real}› and 1 goal remains*)
subgoal for e and e'
apply (rule image_eqI[where x="λi. if i < d then e i else e' (i - d)"] (*‹⟦(?b::?'a) = (?f::(nat ⇒ real) ⇒ ?'a) (λi::nat. if i < (d::nat) then (e::nat ⇒ real) i else (e'::nat ⇒ real) (i - d)); (λi::nat. if i < d then e i else e' (i - d)) ∈ (?A::(nat ⇒ real) set)⟧ ⟹ ?b ∈ ?f ` ?A›*))
(*goal: ‹⟦e ∈ funcset UNIV {- 1..1}; e' ∈ funcset UNIV {- 1..1}⟧ ⟹ map2 (+) (aform_vals e xs) (aform_vals e' ys) ∈ (λe. map2 (+) (aform_vals e xs) (aform_vals (λi. e (i + d)) ys)) ` funcset UNIV {- 1..1}›*)
apply (auto simp: Pi_iff (*‹((?f::?'a ⇒ ?'b) ∈ Pi (?I::?'a set) (?X::?'a ⇒ ?'b set)) = (∀i::?'a∈?I. ?f i ∈ ?X i)›*))
(*top goal: ‹⟦e ∈ funcset UNIV {- 1..1}; e' ∈ funcset UNIV {- 1..1}⟧ ⟹ map2 (+) (aform_vals e xs) (aform_vals e' ys) = map2 (+) (aform_vals (λi. if i < d then e i else e' (i - d)) xs) (aform_vals (λi. if i + d < d then e (i + d) else e' (i + d - d)) ys)› and 1 goal remains*)
proof (goal_cases)
(*goal: ‹⟦∀i::nat. - (1::real) ≤ (e::nat ⇒ real) i ∧ e i ≤ (1::real); ∀i::nat. - (1::real) ≤ (e'::nat ⇒ real) i ∧ e' i ≤ (1::real)⟧ ⟹ map2 (+) (aform_vals e (xs::(real × real pdevs) list)) (aform_vals e' (ys::(real × real pdevs) list)) = map2 (+) (aform_vals (λi::nat. if i < (d::nat) then e i else e' (i - d)) xs) (aform_vals e' ys)›*)
case 1 (*‹∀i. - 1 ≤ e i ∧ e i ≤ 1› ‹∀i. - 1 ≤ e' i ∧ e' i ≤ 1›*)
have "(aform_vals e xs) = aform_vals (λi. if i < d then e i else e' (i - d)) xs"
using assms (*‹degree_aforms (xs::(real × real pdevs) list) ≤ (d::nat)› ‹degree_aforms ys ≤ d›*) by (auto intro!: simp: aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*) intro!: pdevs_val_degree_cong (*‹⟦?b = ?d; ⋀i. i < degree ?b ⟹ ?a i = ?c i⟧ ⟹ pdevs_val ?a ?b = pdevs_val ?c ?d›*))
then show "?case"
(*goal: ‹map2 (+) (aform_vals (e::nat ⇒ real) (xs::(real × real pdevs) list)) (aform_vals (e'::nat ⇒ real) (ys::(real × real pdevs) list)) = map2 (+) (aform_vals (λi::nat. if i < (d::nat) then e i else e' (i - d)) xs) (aform_vals e' ys)›*)
by simp
qed .
definition "split_aforms_largest_uncond_take n X =
(let (i, x) = max_pdev (abssum_of_pdevs_list (map snd (take n X))) in split_aforms X i)"
text ‹intersection with plane›
definition
"project_coord x b n = (∑i←Basis_list. (if i = b then n else if i = -b then -n else x ∙ i) *⇩R i)"
lemma inner_eq_abs_times_sgn:
"u ∙ b = abs u ∙ b * sgn (u ∙ b)" if "b ∈ Basis" for b::"'a::ordered_euclidean_space"
apply (subst sgn_mult_abs[symmetric] (*‹(?t::?'a::idom_abs_sgn) = sgn ?t * ¦?t¦›*))
(*goal: ‹u ∙ b = ¦u¦ ∙ b * sgn (u ∙ b)›*)
by (auto simp: that (*‹b ∈ Basis›*) abs_inner (*‹?i ∈ Basis ⟹ ¦?x¦ ∙ ?i = ¦?x ∙ ?i¦›*))
lemma inner_Basis_eq_zero_absI: "x ∈ Basis ⟹ abs u ∈ Basis ⟹ x ≠ ¦u¦ ⟹ x ≠ 0 ⟹ u ∙ x = 0"
for x::"'a::ordered_euclidean_space"
apply (subst euclidean_inner (*‹?x ∙ ?y = (∑b∈Basis. ?x ∙ b * (?y ∙ b))›*))
(*goal: ‹⟦x ∈ Basis; ¦u¦ ∈ Basis; x ≠ ¦u¦; x ≠ 0⟧ ⟹ u ∙ x = 0›*)
apply (auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) if_distribR (*‹(if ?b then ?f else ?g) ?x = (if ?b then ?f ?x else ?g ?x)›*) if_distrib (*‹?f (if ?c then ?x else ?y) = (if ?c then ?f ?x else ?f ?y)›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
(*goal: ‹⟦x ∈ Basis; ¦u¦ ∈ Basis; x ≠ ¦u¦; x ≠ 0⟧ ⟹ (∑b∈Basis. u ∙ b * (x ∙ b)) = 0›*)
apply (subst inner_eq_abs_times_sgn (*‹?b ∈ Basis ⟹ ?u ∙ ?b = ¦?u¦ ∙ ?b * sgn (?u ∙ ?b)›*))
(*goals:
1. ‹⟦x ∈ Basis; ¦u¦ ∈ Basis; x ≠ ¦u¦; x ≠ 0⟧ ⟹ x ∈ Basis›
2. ‹⟦x ∈ Basis; ¦u¦ ∈ Basis; x ≠ ¦u¦; x ≠ 0⟧ ⟹ ¦u¦ ∙ x * sgn (u ∙ x) = 0›
discuss goal 1*)
apply ((auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*))[1])
(*discuss goal 2*)
apply ((auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*))[1])
(*proven 2 subgoals*) .
lemma abs_in_BasisE:
fixes u::"'a::ordered_euclidean_space"
assumes "abs u ∈ Basis"
obtains "abs u = u" | "abs u = - u"
proof (cases "u ∙ abs u = 1")
(*goals:
1. ‹⟦¦u¦ = u ⟹ thesis; ¦u¦ = - u ⟹ thesis; u ∙ ¦u¦ = 1⟧ ⟹ thesis›
2. ‹⟦¦u¦ = u ⟹ thesis; ¦u¦ = - u ⟹ thesis; u ∙ ¦u¦ ≠ 1⟧ ⟹ thesis›*)
case True (*‹(u::'a::ordered_euclidean_space) ∙ ¦u¦ = (1::real)›*)
have "abs u = (∑i∈Basis. (if i = abs u then (abs u ∙ i) *⇩R i else 0))"
using assms (*‹¦u¦ ∈ Basis›*) by auto
also (*calculation: ‹¦u::'a¦ = (∑i::'a∈Basis. if i = ¦u¦ then (¦u¦ ∙ i) *⇩R i else (0::'a))›*) have "… = (∑i∈Basis. (if i = abs u then (u ∙ i) *⇩R i else 0))"
apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*goals:
1. ‹Basis = Basis›
2. ‹⋀x::'a. x ∈ Basis ⟹ (if x = ¦u::'a¦ then (¦u¦ ∙ x) *⇩R x else (0::'a)) = (if x = ¦u¦ then (u ∙ x) *⇩R x else (0::'a))›
discuss goal 1*)
apply ((auto simp: True (*‹u ∙ ¦u¦ = 1›*))[1])
(*discuss goal 2*)
apply ((auto simp: True (*‹u ∙ ¦u¦ = 1›*))[1])
(*proven 2 subgoals*) .
also (*calculation: ‹¦u::'a¦ = (∑i::'a∈Basis. if i = ¦u¦ then (u ∙ i) *⇩R i else (0::'a))›*) have "… = (∑i∈Basis. (u ∙ i) *⇩R i)"
apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*goals:
1. ‹Basis = Basis›
2. ‹⋀x::'a. x ∈ Basis ⟹ (if x = ¦u::'a¦ then (u ∙ x) *⇩R x else (0::'a)) = (u ∙ x) *⇩R x›
discuss goal 1*)
apply ((auto simp: inner_Basis_eq_zero_absI (*‹⟦(?x::?'a::ordered_euclidean_space) ∈ Basis; ¦?u::?'a::ordered_euclidean_space¦ ∈ Basis; ?x ≠ ¦?u¦; ?x ≠ (0::?'a::ordered_euclidean_space)⟧ ⟹ ?u ∙ ?x = (0::real)›*) assms (*‹¦u::'a::ordered_euclidean_space¦ ∈ Basis›*))[1])
(*discuss goal 2*)
apply ((auto simp: inner_Basis_eq_zero_absI (*‹⟦?x ∈ Basis; ¦?u¦ ∈ Basis; ?x ≠ ¦?u¦; ?x ≠ 0⟧ ⟹ ?u ∙ ?x = 0›*) assms (*‹¦u¦ ∈ Basis›*))[1])
(*proven 2 subgoals*) .
also (*calculation: ‹¦u¦ = (∑i∈Basis. (u ∙ i) *⇩R i)›*) have "… = u"
by (simp add: euclidean_representation (*‹(∑b::?'a∈Basis. ((?x::?'a) ∙ b) *⇩R b) = ?x›*))
finally (*calculation: ‹¦u¦ = u›*) show "?thesis"
(*goal: ‹thesis›*)
by standard
next
(*goal: ‹⟦¦u¦ = u ⟹ thesis; ¦u¦ = - u ⟹ thesis; u ∙ ¦u¦ ≠ 1⟧ ⟹ thesis›*)
case False (*‹u ∙ ¦u¦ ≠ 1›*)
then have F: "u ∙ ¦u¦ = -1"
apply (subst inner_eq_abs_times_sgn[OF assms] (*‹?u ∙ ¦u¦ = ¦?u¦ ∙ ¦u¦ * sgn (?u ∙ ¦u¦)›*))
(*goal: ‹u ∙ ¦u¦ = - 1›*)
apply (subst (asm) inner_eq_abs_times_sgn[OF assms] (*‹?u ∙ ¦u¦ = ¦?u¦ ∙ ¦u¦ * sgn (?u ∙ ¦u¦)›*))
(*goal: ‹u ∙ ¦u¦ ≠ 1 ⟹ ¦u¦ ∙ ¦u¦ * sgn (u ∙ ¦u¦) = - 1›*)
using assms (*‹¦u::'a¦ ∈ Basis›*) apply (auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) sgn_if (*‹sgn ?x = (if ?x = 0 then 0 else if 0 < ?x then 1 else - 1)›*))
(*goal: ‹¦u¦ ∙ ¦u¦ * sgn (u ∙ ¦u¦) ≠ 1 ⟹ ¦u¦ ∙ ¦u¦ * sgn (u ∙ ¦u¦) = - 1›*)
by (metis (full_types) abs_0_eq (*‹(0 = ¦?a¦) = (?a = 0)›*) euclidean_all_zero_iff (*‹(∀u∈Basis. ?x ∙ u = 0) = (?x = 0)›*) inner_Basis_eq_zero_absI (*‹⟦?x ∈ Basis; ¦?u¦ ∈ Basis; ?x ≠ ¦?u¦; ?x ≠ 0⟧ ⟹ ?u ∙ ?x = 0›*) nonzero_Basis (*‹?u ∈ Basis ⟹ ?u ≠ 0›*))
have "abs u = (∑i∈Basis. (if i = abs u then (abs u ∙ i) *⇩R i else 0))"
using assms (*‹¦u¦ ∈ Basis›*) by auto
also (*calculation: ‹¦u¦ = (∑i∈Basis. if i = ¦u¦ then (¦u¦ ∙ i) *⇩R i else 0)›*) have "… = (∑i∈Basis. (if i = abs u then (- u ∙ i) *⇩R i else 0))"
apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*goals:
1. ‹Basis = Basis›
2. ‹⋀x::'a. x ∈ Basis ⟹ (if x = ¦u::'a¦ then (¦u¦ ∙ x) *⇩R x else (0::'a)) = (if x = ¦u¦ then (- u ∙ x) *⇩R x else (0::'a))›
discuss goal 1*)
apply ((auto simp: F (*‹u ∙ ¦u¦ = - 1›*))[1])
(*discuss goal 2*)
apply ((auto simp: F (*‹u ∙ ¦u¦ = - 1›*))[1])
(*proven 2 subgoals*) .
also (*calculation: ‹¦u¦ = (∑i∈Basis. if i = ¦u¦ then (- u ∙ i) *⇩R i else 0)›*) have "… = (∑i∈Basis. (- u ∙ i) *⇩R i)"
apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*goals:
1. ‹Basis = Basis›
2. ‹⋀x. x ∈ Basis ⟹ (if x = ¦u¦ then (- u ∙ x) *⇩R x else 0) = (- u ∙ x) *⇩R x›
discuss goal 1*)
apply ((auto simp: inner_Basis_eq_zero_absI (*‹⟦?x ∈ Basis; ¦?u¦ ∈ Basis; ?x ≠ ¦?u¦; ?x ≠ 0⟧ ⟹ ?u ∙ ?x = 0›*) assms (*‹¦u¦ ∈ Basis›*))[1])
(*discuss goal 2*)
apply ((auto simp: inner_Basis_eq_zero_absI (*‹⟦?x ∈ Basis; ¦?u¦ ∈ Basis; ?x ≠ ¦?u¦; ?x ≠ 0⟧ ⟹ ?u ∙ ?x = 0›*) assms (*‹¦u¦ ∈ Basis›*))[1])
(*proven 2 subgoals*) .
also (*calculation: ‹¦u¦ = (∑i∈Basis. (- u ∙ i) *⇩R i)›*) have "… = - u"
apply (subst euclidean_representation (*‹(∑b∈Basis. (?x ∙ b) *⇩R b) = ?x›*))
(*goal: ‹(∑i∈Basis. (- u ∙ i) *⇩R i) = - u›*)
by simp
finally (*calculation: ‹¦u¦ = - u›*) show "?thesis"
(*goal: ‹thesis::bool›*)
by standard
qed
lemma abs_in_Basis_iff:
fixes u::"'a::ordered_euclidean_space"
shows "abs u ∈ Basis ⟷ u ∈ Basis ∨ - u ∈ Basis"
proof (-)
(*goal: ‹(¦u¦ ∈ Basis) = (u ∈ Basis ∨ - u ∈ Basis)›*)
have u: "u = (∑i∈Basis. (u ∙ i) *⇩R i)"
by (simp add: euclidean_representation (*‹(∑b∈Basis. (?x ∙ b) *⇩R b) = ?x›*))
have u': "- u = (∑i∈Basis. (- (u ∙ i)) *⇩R i)"
apply (subst u (*‹u = (∑i∈Basis. (u ∙ i) *⇩R i)›*))
(*goal: ‹- u = (∑i∈Basis. - (u ∙ i) *⇩R i)›*)
by (simp add: sum_negf (*‹(∑x∈?A. - ?f x) = - sum ?f ?A›*))
have au: "abs u = (∑i∈Basis. ¦u ∙ i¦ *⇩R i)"
by (simp add: eucl_abs[where 'a='a] (*‹¦?x¦ = (∑i∈Basis. ¦?x ∙ i¦ *⇩R i)›*))
have "(u ∈ Basis ∨ - u ∈ Basis)" if "(¦u¦ ∈ Basis)"
apply (rule abs_in_BasisE[OF that] (*‹⟦¦u::'a::ordered_euclidean_space¦ = u ⟹ ?thesis::bool; ¦u¦ = - u ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goal: ‹u ∈ Basis ∨ - u ∈ Basis›*)
using that (*‹¦u::'a::ordered_euclidean_space¦ ∈ Basis›*) apply -
(*goals:
1. ‹⟦¦u¦ = u; ¦u¦ ∈ Basis⟧ ⟹ u ∈ Basis ∨ - u ∈ Basis›
2. ‹⟦¦u¦ = - u; ¦u¦ ∈ Basis⟧ ⟹ u ∈ Basis ∨ - u ∈ Basis›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
show "?thesis"
(*goal: ‹(¦u¦ ∈ Basis) = (u ∈ Basis ∨ - u ∈ Basis)›*)
apply safe
(*goal: ‹(¦u¦ ∈ Basis) = (u ∈ Basis ∨ - u ∈ Basis)›*)
subgoalpremises prems for
using prems(1) (*‹¦u¦ ∈ Basis›*) apply (rule abs_in_BasisE (*‹⟦¦?u::?'a¦ ∈ Basis; ¦?u¦ = ?u ⟹ ?thesis::bool; ¦?u¦ = - ?u ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goal: ‹(u::'a::ordered_euclidean_space) ∈ Basis›*)
using prems (*‹¦u¦ ∈ Basis› ‹- u ∉ Basis›*) apply -
(*goals:
1. ‹⟦¦u¦ = u; ¦u¦ ∈ Basis; - u ∉ Basis⟧ ⟹ u ∈ Basis›
2. ‹⟦¦u¦ = - u; ¦u¦ ∈ Basis; - u ∉ Basis⟧ ⟹ u ∈ Basis›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
subgoal for
apply (subst au (*‹¦u¦ = (∑i∈Basis. ¦u ∙ i¦ *⇩R i)›*))
(*goal: ‹u ∈ Basis ⟹ ¦u¦ ∈ Basis›*)
apply (subst (asm) u (*‹u = (∑i∈Basis. (u ∙ i) *⇩R i)›*))
(*goal: ‹u ∈ Basis ⟹ (∑i∈Basis. ¦u ∙ i¦ *⇩R i) ∈ Basis›*)
apply (subst sum.cong[OF refl] (*‹(⋀x::?'b. x ∈ (?A::?'b set) ⟹ (?g::?'b ⇒ ?'a) x = (?h::?'b ⇒ ?'a) x) ⟹ sum ?g ?A = sum ?h ?A›*))
(*goal: ‹(∑i∈Basis. (u ∙ i) *⇩R i) ∈ Basis ⟹ (∑i∈Basis. ¦u ∙ i¦ *⇩R i) ∈ Basis›*)
apply (subst abs_inner[symmetric] (*‹?i ∈ Basis ⟹ ¦?x ∙ ?i¦ = ¦?x¦ ∙ ?i›*))
(*top goal: ‹⋀x::'a::ordered_euclidean_space. ⟦(∑i::'a::ordered_euclidean_space∈Basis. ((u::'a::ordered_euclidean_space) ∙ i) *⇩R i) ∈ Basis; x ∈ Basis⟧ ⟹ ¦u ∙ x¦ *⇩R x = (?h1::'a::ordered_euclidean_space ⇒ 'a::ordered_euclidean_space) x› and 1 goal remains*)
apply auto
(*top goal: ‹⋀x. ⟦(∑i∈Basis. (u ∙ i) *⇩R i) ∈ Basis; x ∈ Basis⟧ ⟹ x ∈ Basis› and 2 goals remain*)
using u (*‹u = (∑i∈Basis. (u ∙ i) *⇩R i)›*) by auto
subgoal for
apply (subst au (*‹¦u¦ = (∑i∈Basis. ¦u ∙ i¦ *⇩R i)›*))
(*goal: ‹- u ∈ Basis ⟹ ¦u¦ ∈ Basis›*)
apply (subst (asm) u' (*‹- u = (∑i∈Basis. - (u ∙ i) *⇩R i)›*))
(*goal: ‹- u ∈ Basis ⟹ (∑i∈Basis. ¦u ∙ i¦ *⇩R i) ∈ Basis›*)
apply (subst sum.cong[OF refl] (*‹(⋀x. x ∈ ?A ⟹ ?g x = ?h x) ⟹ sum ?g ?A = sum ?h ?A›*))
(*goal: ‹(∑i∈Basis. - (u ∙ i) *⇩R i) ∈ Basis ⟹ (∑i∈Basis. ¦u ∙ i¦ *⇩R i) ∈ Basis›*)
apply (subst abs_inner[symmetric] (*‹?i ∈ Basis ⟹ ¦?x ∙ ?i¦ = ¦?x¦ ∙ ?i›*))
(*top goal: ‹⋀x::'a::ordered_euclidean_space. ⟦(∑i::'a::ordered_euclidean_space∈Basis. - ((u::'a::ordered_euclidean_space) ∙ i) *⇩R i) ∈ Basis; x ∈ Basis⟧ ⟹ ¦u ∙ x¦ *⇩R x = (?h1::'a::ordered_euclidean_space ⇒ 'a::ordered_euclidean_space) x› and 1 goal remains*)
apply auto
(*top goal: ‹⋀x. ⟦(∑i∈Basis. - (u ∙ i) *⇩R i) ∈ Basis; x ∈ Basis⟧ ⟹ x ∈ Basis› and 2 goals remain*)
using u' (*‹- u = (∑i∈Basis. - (u ∙ i) *⇩R i)›*) apply auto
(*goal: ‹⋀x. ⟦(∑i∈Basis. - ((u ∙ i) *⇩R i)) ∈ Basis; x ∈ Basis⟧ ⟹ (¦u¦ ∙ x) *⇩R x = - ((u ∙ x) *⇩R x)›*)
by (metis Basis_nonneg (*‹(?i::?'a::ordered_euclidean_space) ∈ Basis ⟹ (0::?'a::ordered_euclidean_space) ≤ ?i›*) abs_of_nonpos (*‹(?a::?'a::ordered_ab_group_add_abs) ≤ (0::?'a::ordered_ab_group_add_abs) ⟹ ¦?a¦ = - ?a›*) inner_minus_left (*‹- (?x::?'a::real_inner) ∙ (?y::?'a::real_inner) = - (?x ∙ ?y)›*) neg_0_le_iff_le (*‹((0::?'a::ordered_ab_group_add) ≤ - (?a::?'a::ordered_ab_group_add)) = (?a ≤ (0::?'a::ordered_ab_group_add))›*) scaleR_left.minus (*‹- (?x::real) *⇩R (?xa::?'a::real_vector) = - (?x *⇩R ?xa)›*)) .
qed
lemma abs_inner_Basis:
fixes u v::"'a::ordered_euclidean_space"
assumes "abs u ∈ Basis" "abs v ∈ Basis"
shows "inner u v = (if u = v then 1 else if u = -v then -1 else 0)"
proof (-)
(*goal: ‹(u::'a) ∙ (v::'a) = (if u = v then 1::real else if u = - v then - (1::real) else (0::real))›*)
define i where "i ≡ if u ∈ Basis then u else -u"
define j where "j ≡ if v ∈ Basis then v else -v"
have u: "u = (if u ∈ Basis then i else - i)" and v: "v = (if v ∈ Basis then j else - j)"
(*goals:
1. ‹u = (if u ∈ Basis then i else - i)›
2. ‹v = (if v ∈ Basis then j else - j)›
discuss goal 1*)
apply ((auto simp: i_def (*‹i ≡ if u ∈ Basis then u else - u›*) j_def (*‹j ≡ if v ∈ Basis then v else - v›*))[1])
(*discuss goal 2*)
apply ((auto simp: i_def (*‹i ≡ if u ∈ Basis then u else - u›*) j_def (*‹j ≡ if v ∈ Basis then v else - v›*))[1])
(*proven 2 subgoals*) .
have "i ∈ Basis" "j ∈ Basis"
using assms (*‹¦u¦ ∈ Basis› ‹¦v::'a¦ ∈ Basis›*) apply -
(*goals:
1. ‹⟦¦u::'a¦ ∈ Basis; ¦v::'a¦ ∈ Basis⟧ ⟹ (i::'a) ∈ Basis›
2. ‹⟦¦u::'a¦ ∈ Basis; ¦v::'a¦ ∈ Basis⟧ ⟹ (j::'a) ∈ Basis›
discuss goal 1*)
apply ((auto simp: i_def (*‹i ≡ if u ∈ Basis then u else - u›*) j_def (*‹j ≡ if v ∈ Basis then v else - v›*) abs_in_Basis_iff (*‹(¦?u¦ ∈ Basis) = (?u ∈ Basis ∨ - ?u ∈ Basis)›*))[1])
(*discuss goal 2*)
apply ((auto simp: i_def (*‹i::'a ≡ if (u::'a) ∈ Basis then u else - u›*) j_def (*‹j::'a ≡ if (v::'a) ∈ Basis then v else - v›*) abs_in_Basis_iff (*‹(¦?u::?'a¦ ∈ Basis) = (?u ∈ Basis ∨ - ?u ∈ Basis)›*))[1])
(*proven 2 subgoals*) .
then show "?thesis"
(*goal: ‹u ∙ v = (if u = v then 1 else if u = - v then - 1 else 0)›*)
apply (subst u (*‹u = (if u ∈ Basis then i else - i)›*))
(*goal: ‹(u::'a) ∙ (v::'a) = (if u = v then 1::real else if u = - v then - (1::real) else (0::real))›*)
apply (subst v (*‹v = (if v ∈ Basis then j else - j)›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis⟧ ⟹ (if u ∈ Basis then i else - i) ∙ v = (if u = v then 1 else if u = - v then - 1 else 0)›*)
apply (auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis⟧ ⟹ (if u ∈ Basis then i else - i) ∙ (if v ∈ Basis then j else - j) = (if u = v then 1 else if u = - v then - 1 else 0)›*)
apply (auto simp: j_def (*‹j ≡ if v ∈ Basis then v else - v›*) i_def (*‹i ≡ if u ∈ Basis then u else - u›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
(*top goal: ‹⟦(j::'a) ∈ Basis; - (v::'a) ∈ Basis; (i::'a) = j; v ∈ Basis; (u::'a) = - v⟧ ⟹ - v = v› and 9 goals remain*)
using Basis_nonneg (*‹?i ∈ Basis ⟹ 0 ≤ ?i›*) abs_of_nonpos (*‹?a ≤ 0 ⟹ ¦?a¦ = - ?a›*) by fastforce
qed
lemma
project_coord_inner_Basis:
assumes "i ∈ Basis"
shows "(project_coord x b n) ∙ i = (if i = b then n else if i = -b then -n else x ∙ i)"
proof (-)
(*goal: ‹project_coord x b n ∙ i = (if i = b then n else if i = - b then - n else x ∙ i)›*)
have "project_coord x b n ∙ i =
(∑j∈Basis. (if j = b then n else if j = -b then -n else x ∙ j) * (if j = i then 1 else 0))"
using assms (*‹(i::'a::executable_euclidean_space) ∈ Basis›*) by (auto simp: project_coord_def (*‹project_coord ?x ?b ?n = (∑i←Basis_list. (if i = ?b then ?n else if i = - ?b then - ?n else ?x ∙ i) *⇩R i)›*) inner_sum_left (*‹sum ?f ?A ∙ ?y = (∑x∈?A. ?f x ∙ ?y)›*) inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*))
also (*calculation: ‹project_coord (x::'a) (b::'a) (n::real) ∙ (i::'a) = (∑j::'a∈Basis. (if j = b then n else if j = - b then - n else x ∙ j) * (if j = i then 1::real else (0::real)))›*) have "… = (∑j∈Basis. (if j = i then (if j = b then n else if j = -b then -n else x ∙ j) else 0))"
apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*goals:
1. ‹Basis = Basis›
2. ‹⋀xa. xa ∈ Basis ⟹ (if xa = b then n else if xa = - b then - n else x ∙ xa) * (if xa = i then 1 else 0) = (if xa = i then if xa = b then n else if xa = - b then - n else x ∙ xa else 0)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
also (*calculation: ‹project_coord x b n ∙ i = (∑j∈Basis. if j = i then if j = b then n else if j = - b then - n else x ∙ j else 0)›*) have "… = (if i = b then n else if i = -b then -n else x ∙ i)"
using assms (*‹i ∈ Basis›*) apply (subst sum.delta (*‹finite ?S ⟹ (∑k∈?S. if k = ?a then ?b k else 0) = (if ?a ∈ ?S then ?b ?a else 0)›*))
(*goals:
1. ‹i ∈ Basis ⟹ finite Basis›
2. ‹i ∈ Basis ⟹ (if i ∈ Basis then if i = b then n else if i = - b then - n else x ∙ i else 0) = (if i = b then n else if i = - b then - n else x ∙ i)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
finally (*calculation: ‹project_coord x b n ∙ i = (if i = b then n else if i = - b then - n else x ∙ i)›*) show "?thesis"
(*goal: ‹project_coord (x::'a) (b::'a) (n::real) ∙ (i::'a) = (if i = b then n else if i = - b then - n else x ∙ i)›*)
by simp
qed
lemma
project_coord_inner:
assumes "abs i ∈ Basis"
shows "(project_coord x b n) ∙ i = (if i = b then n else if i = -b then -n else x ∙ i)"
proof (-)
(*goal: ‹project_coord (x::'a::executable_euclidean_space) (b::'a::executable_euclidean_space) (n::real) ∙ (i::'a::executable_euclidean_space) = (if i = b then n else if i = - b then - n else x ∙ i)›*)
consider "i ∈ Basis" | "- i ∈ Basis"
(*goal: ‹⟦i ∈ Basis ⟹ thesis; - i ∈ Basis ⟹ thesis⟧ ⟹ thesis›*)
using assms (*‹¦i¦ ∈ Basis›*) by (auto simp: abs_in_Basis_iff (*‹(¦?u¦ ∈ Basis) = (?u ∈ Basis ∨ - ?u ∈ Basis)›*))
then show "?thesis"
(*goal: ‹project_coord x b n ∙ i = (if i = b then n else if i = - b then - n else x ∙ i)›*)
proof (cases)
(*goals:
1. ‹i ∈ Basis ⟹ project_coord x b n ∙ i = (if i = b then n else if i = - b then - n else x ∙ i)›
2. ‹- i ∈ Basis ⟹ project_coord x b n ∙ i = (if i = b then n else if i = - b then - n else x ∙ i)›*)
case 1 (*‹i ∈ Basis›*)
then show "?thesis"
(*goal: ‹project_coord (x::'a::executable_euclidean_space) (b::'a::executable_euclidean_space) (n::real) ∙ (i::'a::executable_euclidean_space) = (if i = b then n else if i = - b then - n else x ∙ i)›*)
by (simp add: project_coord_inner_Basis (*‹?i ∈ Basis ⟹ project_coord ?x ?b ?n ∙ ?i = (if ?i = ?b then ?n else if ?i = - ?b then - ?n else ?x ∙ ?i)›*))
next
(*goal: ‹- (i::'a) ∈ Basis ⟹ project_coord (x::'a) (b::'a) (n::real) ∙ i = (if i = b then n else if i = - b then - n else x ∙ i)›*)
case 2 (*‹- i ∈ Basis›*)
have "project_coord x b n ∙ i = - (project_coord x b n ∙ - i)"
by simp
also (*calculation: ‹project_coord x b n ∙ i = - (project_coord x b n ∙ - i)›*) have "… = - (if - i = b then n else if - i = -b then -n else x ∙ - i)"
using "2" (*‹- (i::'a) ∈ Basis›*) apply (subst project_coord_inner_Basis (*‹(?i::?'a) ∈ Basis ⟹ project_coord (?x::?'a) (?b::?'a) (?n::real) ∙ ?i = (if ?i = ?b then ?n else if ?i = - ?b then - ?n else ?x ∙ ?i)›*))
(*goals:
1. ‹- i ∈ Basis ⟹ - i ∈ Basis›
2. ‹- i ∈ Basis ⟹ - (if - i = b then n else if - i = - b then - n else x ∙ - i) = - (if - i = b then n else if - i = - b then - n else x ∙ - i)›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
also (*calculation: ‹project_coord (x::'a) (b::'a) (n::real) ∙ (i::'a) = - (if - i = b then n else if - i = - b then - n else x ∙ - i)›*) have "… = (if i = b then n else if i = -b then -n else x ∙ i)"
using "2" (*‹- i ∈ Basis›*) apply auto
(*goal: ‹- (if - i = b then n else if - i = - b then - n else x ∙ - i) = (if i = b then n else if i = - b then - n else x ∙ i)›*)
by (metis Basis_nonneg (*‹?i ∈ Basis ⟹ 0 ≤ ?i›*) abs_le_zero_iff (*‹(¦?a¦ ≤ 0) = (?a = 0)›*) abs_of_nonneg (*‹0 ≤ ?a ⟹ ¦?a¦ = ?a›*) neg_le_0_iff_le (*‹(- ?a ≤ 0) = (0 ≤ ?a)›*) nonzero_Basis (*‹?u ∈ Basis ⟹ ?u ≠ 0›*))
finally (*calculation: ‹project_coord x b n ∙ i = (if i = b then n else if i = - b then - n else x ∙ i)›*) show "?thesis"
(*goal: ‹project_coord (x::'a) (b::'a) (n::real) ∙ (i::'a) = (if i = b then n else if i = - b then - n else x ∙ i)›*) .
qed
qed
lift_definition project_coord_pdevs::"'a::executable_euclidean_space sctn ⇒ 'a pdevs ⇒ 'a pdevs" is
"λsctn xs i. project_coord (xs i) (normal sctn) 0"
by (rule finite_subset) (auto simp: project_coord_def cong: if_cong)
definition "project_coord_aform sctn cxs =
(project_coord (fst cxs) (normal sctn) (pstn sctn), project_coord_pdevs sctn (snd cxs))"
definition project_coord_aform_lv :: "real aform list ⇒ nat ⇒ real ⇒ real aform list"
where "project_coord_aform_lv xs b n = xs[b:=(n, zero_pdevs)]"
definition "project_ncoord_aform x b n = project_coord_aform (Sctn (Basis_list ! b) n) x"
lemma
finite_sum_subset_aux_lemma:
assumes "finite s"
shows " {i. (∑x∈s. f x i) ≠ 0} ⊆ {i. ∃x∈s. f x i ≠ 0}"
proof (-)
(*goal: ‹{i. (∑x∈s. f x i) ≠ 0} ⊆ {i. ∃x∈s. f x i ≠ 0}›*)
have "{i. (∑x∈s. f x i) ≠ 0} = - {i. (∑x∈s. f x i) = 0}"
by auto
also (*calculation: ‹{i::'b::type. (∑x::'a::type∈(s::'a::type set). (f::'a::type ⇒ 'b::type ⇒ 'c::comm_monoid_add) x i) ≠ (0::'c::comm_monoid_add)} = - {i::'b::type. (∑x::'a::type∈s. f x i) = (0::'c::comm_monoid_add)}›*) have "… ⊆ - {i. ∀x ∈ s. f x i = 0}"
by auto
also (*calculation: ‹{i. (∑x∈s. f x i) ≠ 0} ⊆ - {i. ∀x∈s. f x i = 0}›*) have "… = {i. ∃x ∈ s. f x i ≠ 0}"
by auto
finally (*calculation: ‹{i. (∑x∈s. f x i) ≠ 0} ⊆ {i. ∃x∈s. f x i ≠ 0}›*) show "?thesis"
(*goal: ‹{i. (∑x∈s. f x i) ≠ 0} ⊆ {i. ∃x∈s. f x i ≠ 0}›*)
by simp
qed
lift_definition sum_pdevs::"('i ⇒ 'a::comm_monoid_add pdevs) ⇒ 'i set ⇒ 'a pdevs"
is "λf X. if finite X then (λi. ∑x∈X. f x i) else (λ_. 0)"
apply auto
apply (rule finite_subset)
apply (rule finite_sum_subset_aux_lemma)
apply auto
done
lemma pdevs_apply_sum_pdevs[simp]:
"pdevs_apply (sum_pdevs f X) i = (∑x∈X. pdevs_apply (f x) i)"
apply transfer
(*goal: ‹pdevs_apply (sum_pdevs f X) i = (∑x∈X. pdevs_apply (f x) i)›*)
by auto
lemma sum_pdevs_empty[simp]: "sum_pdevs f {} = zero_pdevs"
apply transfer
(*goal: ‹sum_pdevs f {} = zero_pdevs›*)
by auto
lemma sum_pdevs_insert[simp]:
"finite xs ⟹ sum_pdevs f (insert a xs) =
(if a ∈ xs then sum_pdevs f xs else add_pdevs (f a) (sum_pdevs f xs))"
by (auto simp: insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*) intro!: pdevs_eqI (*‹(⋀i. pdevs_apply ?x i = pdevs_apply ?y i) ⟹ ?x = ?y›*))
lemma sum_pdevs_infinite[simp]: "infinite X ⟹ sum_pdevs f X = zero_pdevs"
apply transfer
(*goal: ‹infinite (X::'a set) ⟹ sum_pdevs (f::'a ⇒ 'b pdevs) X = zero_pdevs›*)
by auto
lemma compute_sum_pdevs[code]:
"sum_pdevs f (set XS) = foldr (λa b. add_pdevs (f a) b) (remdups XS) zero_pdevs"
apply (induction XS)
(*goals:
1. ‹sum_pdevs f (set []) = foldr (λa. add_pdevs (f a)) (remdups []) zero_pdevs›
2. ‹⋀a XS. sum_pdevs f (set XS) = foldr (λa. add_pdevs (f a)) (remdups XS) zero_pdevs ⟹ sum_pdevs f (set (a # XS)) = foldr (λa. add_pdevs (f a)) (remdups (a # XS)) zero_pdevs›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma degree_sum_pdevs_le:
"degree (sum_pdevs f X) ≤ Max (degree ` f ` X)"
apply (rule degree_le (*‹∀j≥?d. pdevs_apply ?x j = 0 ⟹ degree ?x ≤ ?d›*))
(*goal: ‹degree (sum_pdevs f X) ≤ Max (degree ` f ` X)›*)
apply auto
(*goal: ‹∀j≥Max (degree ` f ` X). pdevs_apply (sum_pdevs f X) j = 0›*)
apply (cases "X = {}")
(*goal: ‹⋀j. Max (degree ` f ` X) ≤ j ⟹ (∑x∈X. pdevs_apply (f x) j) = 0›*)
subgoal for
by simp
subgoal for
apply (cases "finite X")
(*goals:
1. ‹⟦Max (degree ` f ` X) ≤ j_; X ≠ {}; finite X⟧ ⟹ (∑x∈X. pdevs_apply (f x) j_) = 0›
2. ‹⟦Max (degree ` f ` X) ≤ j_; X ≠ {}; infinite X⟧ ⟹ (∑x∈X. pdevs_apply (f x) j_) = 0›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) . .
lemma pdevs_val_sum_pdevs:
"pdevs_val e (sum_pdevs f X) = (∑x∈X. pdevs_val e (f x))"
apply (cases "finite X")
(*goal: ‹pdevs_val e (sum_pdevs f X) = (∑x∈X. pdevs_val e (f x))›*)
subgoal for
apply (subst pdevs_val_sum_le (*‹degree ?X ≤ ?d ⟹ pdevs_val ?e ?X = (∑i<?d. ?e i *⇩R pdevs_apply ?X i)›*))
(*goals:
1. ‹finite (X::'b set) ⟹ degree (sum_pdevs (f::'b ⇒ 'a pdevs) X) ≤ (?d::nat)›
2. ‹finite (X::'b set) ⟹ (∑i::nat<?d::nat. (e::nat ⇒ real) i *⇩R pdevs_apply (sum_pdevs (f::'b ⇒ 'a pdevs) X) i) = (∑x::'b∈X. pdevs_val e (f x))›
discuss goal 1*)
apply (rule degree_sum_pdevs_le (*‹degree (sum_pdevs ?f ?X) ≤ Max (degree ` ?f ` ?X)›*))
(*discuss goal 2*)
apply (auto simp: scaleR_sum_right (*‹?a *⇩R sum ?f ?A = (∑x∈?A. ?a *⇩R ?f x)›*))
(*goal: ‹finite X ⟹ (∑i<Max (degree ` f ` X). e i *⇩R pdevs_apply (sum_pdevs f X) i) = (∑x∈X. pdevs_val e (f x))›*)
apply (subst sum.swap (*‹(∑i∈?A. sum (?g i) ?B) = (∑j∈?B. ∑i∈?A. ?g i j)›*))
(*goal: ‹finite (X::'b set) ⟹ (∑i::nat<Max (degree ` f ` X). ∑x::'b∈X. (e::nat ⇒ real) i *⇩R pdevs_apply ((f::'b ⇒ 'a pdevs) x) i) = (∑x::'b∈X. pdevs_val e (f x))›*)
apply (rule sum.cong[OF refl] (*‹(⋀x. x ∈ ?A ⟹ ?g x = ?h x) ⟹ sum ?g ?A = sum ?h ?A›*))
(*goal: ‹finite X ⟹ (∑j∈X. ∑i<Max (degree ` f ` X). e i *⇩R pdevs_apply (f j) i) = (∑x∈X. pdevs_val e (f x))›*)
apply (subst pdevs_val_sum_le[where d="Max (degree ` f ` X)"] (*‹degree ?X ≤ Max (degree ` f ` X) ⟹ pdevs_val ?e ?X = (∑i<Max (degree ` f ` X). ?e i *⇩R pdevs_apply ?X i)›*))
(*goals:
1. ‹⋀x. ⟦finite X; x ∈ X⟧ ⟹ degree (f x) ≤ Max (degree ` f ` X)›
2. ‹⋀x. ⟦finite X; x ∈ X⟧ ⟹ (∑i<Max (degree ` f ` X). e i *⇩R pdevs_apply (f x) i) = (∑i<Max (degree ` f ` X). e i *⇩R pdevs_apply (f x) i)›
discuss goal 1*)
apply ((auto simp: Max_ge_iff (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ (?x ≤ Max ?A) = (∃a∈?A. ?x ≤ a)›*))[1])
(*discuss goal 2*)
apply ((auto simp: Max_ge_iff (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ (?x ≤ Max ?A) = (∃a∈?A. ?x ≤ a)›*))[1])
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
subgoal for
by simp .
definition eucl_of_list_aform :: "(real × real pdevs) list ⇒ 'a::executable_euclidean_space aform"
where "eucl_of_list_aform xs =
(eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis)"
definition lv_aforms_rel::"(((real × real pdevs) list) × ('a::executable_euclidean_space aform)) set"
where "lv_aforms_rel = br eucl_of_list_aform (λxs. length xs = DIM('a))"
definition "inner_aforms' p X Y =
(let fas = [inner_floatariths (map floatarith.Var [0..<length X])
(map floatarith.Var[length X..<length X + length Y])]
in
approx_slp_outer p (length fas) fas (X@Y)
)"
lemma
affine_extension_AffineD:
assumes "affine_extension2 (λd x y. Some (F d x y)) f"
assumes "[x, y] ∈ Joints [X, Y]"
assumes "d ≥ degree_aform X"
assumes "d ≥ degree_aform Y"
shows "f x y ∈ Affine (F d X Y)"
proof (-)
(*goal: ‹f x y ∈ Affine (F d X Y)›*)
from assms(2) (*‹[x, y] ∈ Joints [X, Y]›*) obtain e where e: "e ∈ funcset UNIV {-1 .. 1}" "x = aform_val e X" "y = aform_val e Y"
(*goal: ‹(⋀e. ⟦e ∈ funcset UNIV {- 1..1}; x = aform_val e X; y = aform_val e Y⟧ ⟹ thesis) ⟹ thesis›*)
by (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*))
from affine_extension2E[OF assms ( 1 ) refl e ( 1 ) assms ( 3 ) assms ( 4 )] (*‹(⋀e'::nat ⇒ real. ⟦e' ∈ funcset UNIV {- (1::real)..1::real}; (f::'a ⇒ 'a ⇒ 'b) (aform_val (e::nat ⇒ real) (X::'a × 'a pdevs)) (aform_val e (Y::'a × 'a pdevs)) = aform_val e' ((F::nat ⇒ 'a × 'a pdevs ⇒ 'a × 'a pdevs ⇒ 'b × 'b pdevs) (d::nat) X Y); ⋀n::nat. n < d ⟹ e' n = e n; aform_val e X = aform_val e' X; aform_val e Y = aform_val e' Y⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) obtain e' where "e' ∈ funcset UNIV {- 1..1}" "f (aform_val e X) (aform_val e Y) = aform_val e' (F d X Y)" "⋀n. n < d ⟹ e' n = e n" "aform_val e X = aform_val e' X" "aform_val e Y = aform_val e' Y"
(*goal: ‹(⋀e'. ⟦e' ∈ funcset UNIV {- 1..1}; f (aform_val e X) (aform_val e Y) = aform_val e' (F d X Y); ⋀n. n < d ⟹ e' n = e n; aform_val e X = aform_val e' X; aform_val e Y = aform_val e' Y⟧ ⟹ thesis) ⟹ thesis›*)
by auto
then show "?thesis"
(*goal: ‹(f::'a::real_normed_vector ⇒ 'a::real_normed_vector ⇒ 'b::real_normed_vector) (x::'a::real_normed_vector) (y::'a::real_normed_vector) ∈ Affine ((F::nat ⇒ 'a::real_normed_vector × 'a::real_normed_vector pdevs ⇒ 'a::real_normed_vector × 'a::real_normed_vector pdevs ⇒ 'b::real_normed_vector × 'b::real_normed_vector pdevs) (d::nat) (X::'a::real_normed_vector × 'a::real_normed_vector pdevs) (Y::'a::real_normed_vector × 'a::real_normed_vector pdevs))›*)
by (auto simp: Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) e (*‹e ∈ funcset UNIV {- 1..1}› ‹x = aform_val e X› ‹y = aform_val e Y›*))
qed
lemma aform_val_zero_pdevs[simp]: "aform_val e (x, zero_pdevs) = x"
by (auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*))
lemma neg_equal_zero_eucl[simp]: "-a = a ⟷ a = 0" for a::"'a::euclidean_space"
by (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) euclidean_eq_iff[where 'a='a] (*‹(?x = ?y) = (∀b∈Basis. ?x ∙ b = ?y ∙ b)›*))
context includes autoref_syntax begin
lemma Option_bind_param[param, autoref_rules]:
"((⤜), (⤜)) ∈ ⟨S⟩option_rel → (S → ⟨R⟩option_rel) → ⟨R⟩option_rel"
unfolding Option.bind_def
(*goal: ‹(rec_option (λf. None) (λx f. f x), rec_option (λf. None) (λx f. f x)) ∈ ⟨S⟩option_rel → (S → ⟨R⟩option_rel) → ⟨R⟩option_rel›*)
by parametricity
lemma zip_Basis_list_pat[autoref_op_pat_def]: "∑(b, m)←zip Basis_list ms. m *⇩R b ≡ OP eucl_of_list $ ms"
proof (rule eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))
(*goal: ‹sum_list (map2 (λb m. m *⇩R b) Basis_list ms) = OP eucl_of_list $ ms›*)
have z: "zip ms (Basis_list::'a list) = map (λ(x, y). (y, x)) (zip Basis_list ms)"
apply (subst zip_commute (*‹zip ?xs ?ys = map2 (λx y. (y, x)) ?ys ?xs›*))
(*goal: ‹zip ms Basis_list = map2 (λx y. (y, x)) Basis_list ms›*)
by simp
show "(∑(b, m)←zip (Basis_list::'a list) ms. m *⇩R b) = OP eucl_of_list $ ms"
unfolding eucl_of_list_def autoref_tag_defs
(*goal: ‹sum_list (map2 (λb m. m *⇩R b) Basis_list ms) = sum_list (map2 (*⇩R) ms Basis_list)›*)
apply (subst z (*‹zip ms Basis_list = map2 (λx y. (y, x)) Basis_list ms›*))
(*goal: ‹sum_list (map2 (λb m. m *⇩R b) Basis_list ms) = sum_list (map2 (*⇩R) ms Basis_list)›*)
apply (subst map_map (*‹map ?f (map ?g ?xs) = map (?f ∘ ?g) ?xs›*))
(*goal: ‹sum_list (map2 (λb m. m *⇩R b) Basis_list ms) = (∑(x, y)←map2 (λx y. (y, x)) Basis_list ms. x *⇩R y)›*)
by (auto cong: map_cong (*‹⟦?xs = ?ys; ⋀x. x ∈ set ?ys ⟹ ?f x = ?g x⟧ ⟹ map ?f ?xs = map ?g ?ys›*) simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*))
qed
lemma length_aforms_of_ivls: "length (aforms_of_ivls a b) = min (length a) (length b)"
by (auto simp: aforms_of_ivls_def (*‹aforms_of_ivls ?ls ?us = map2 (λi (l, u). ((l + u) / 2, scaleR_pdevs ((u - l) / 2) (coord_pdevs i))) [0..<length ?ls] (zip ?ls ?us)›*))
lemma length_lv_rel:
"(ys, y::'a) ∈ lv_rel ⟹ length ys = DIM('a::executable_euclidean_space)"
by (auto simp: lv_rel_def (*‹lv_rel = br eucl_of_list (λxs::real list. length xs = DIM(?'a))›*) br_def (*‹br (?α::?'a ⇒ ?'b) (?I::?'a ⇒ bool) ≡ {(c::?'a, a::?'b). a = ?α c ∧ ?I c}›*))
lemma lv_rel_nth[simp]: "(xs, x::'a::executable_euclidean_space) ∈ lv_rel ⟹ b ∈ Basis ⟹
xs ! index (Basis_list) b = x ∙ b"
unfolding lv_rel_def
(*goal: ‹⟦(xs::real list, x::'a::executable_euclidean_space) ∈ br eucl_of_list (λxs::real list. length xs = DIM('a::executable_euclidean_space)); (b::'a::executable_euclidean_space) ∈ Basis⟧ ⟹ xs ! index Basis_list b = x ∙ b›*)
by (auto simp: br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) eucl_of_list_inner (*‹⟦?i ∈ Basis; length ?xs = DIM(?'a)⟧ ⟹ eucl_of_list ?xs ∙ ?i = ?xs ! index Basis_list ?i›*))
lemma aform_of_ivl_autoref[autoref_rules]:
"(aforms_of_ivls, aform_of_ivl) ∈ lv_rel → lv_rel → lv_aforms_rel"
apply (auto simp: lv_aforms_rel_def (*‹lv_aforms_rel = br eucl_of_list_aform (λxs. length xs = DIM(?'a))›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) eucl_of_list_aform_def (*‹eucl_of_list_aform ?xs = (eucl_of_list (map fst ?xs), sum_pdevs (λi. pdevs_scaleR (snd (?xs ! index Basis_list i)) i) Basis)›*) length_aforms_of_ivls (*‹length (aforms_of_ivls ?a ?b) = min (length ?a) (length ?b)›*) length_lv_rel (*‹(?ys, ?y) ∈ lv_rel ⟹ length ?ys = DIM(?'a)›*))
(*goal: ‹(aforms_of_ivls, aform_of_ivl) ∈ lv_rel → lv_rel → lv_aforms_rel›*)
subgoal for xs and x and ys and y
apply (auto simp: aform_of_ivl_def (*‹aform_of_ivl (?l::?'a) (?u::?'a) = ((?l + ?u) /⇩R (2::real), pdevs_of_ivl ?l ?u)›*) aforms_of_ivls_def (*‹aforms_of_ivls (?ls::real list) (?us::real list) = map2 (λ(i::nat) (l::real, u::real). ((l + u) / (2::real), scaleR_pdevs ((u - l) / (2::real)) (coord_pdevs i))) [0::nat..<length ?ls] (zip ?ls ?us)›*) o_def (*‹(?f::?'b ⇒ ?'c) ∘ (?g::?'a ⇒ ?'b) = (λx::?'a. ?f (?g x))›*) eucl_of_list_inner (*‹⟦(?i::?'a) ∈ Basis; length (?xs::real list) = DIM(?'a)⟧ ⟹ eucl_of_list ?xs ∙ ?i = ?xs ! index Basis_list ?i›*) inner_simps (*‹((?x::?'a) + (?y::?'a)) ∙ (?z::?'a) = ?x ∙ ?z + ?y ∙ ?z› ‹(?x::?'a) ∙ ((?y::?'a) + (?z::?'a)) = ?x ∙ ?y + ?x ∙ ?z› ‹(?x::?'a) ∙ ((?y::?'a) - (?z::?'a)) = ?x ∙ ?y - ?x ∙ ?z› ‹((?x::?'a) - (?y::?'a)) ∙ (?z::?'a) = ?x ∙ ?z - ?y ∙ ?z› ‹(?r::real) *⇩R (?x::?'a) ∙ (?y::?'a) = ?r * (?x ∙ ?y)› ‹(?x::?'a) ∙ (?r::real) *⇩R (?y::?'a) = ?r * (?x ∙ ?y)›*) pdevs_apply_pdevs_of_ivl (*‹pdevs_apply (pdevs_of_ivl (?l::?'a) (?u::?'a)) (?i::nat) = (if ?i < length Basis_list then ((?u - ?l) ∙ Basis_list ! ?i / (2::real)) *⇩R Basis_list ! ?i else (0::?'a))›*) length_lv_rel (*‹(?ys::real list, ?y::?'a) ∈ lv_rel ⟹ length ?ys = DIM(?'a)›*) intro!: euclidean_eqI[where 'a='a] (*‹(⋀b::'a. b ∈ Basis ⟹ (?x::'a) ∙ b = (?y::'a) ∙ b) ⟹ ?x = ?y›*) pdevs_eqI (*‹(⋀i::nat. pdevs_apply (?x::?'a pdevs) i = pdevs_apply (?y::?'a pdevs) i) ⟹ ?x = ?y›*))
(*goal: ‹⟦(xs, x) ∈ lv_rel; (ys, y) ∈ lv_rel⟧ ⟹ aform_of_ivl x y = (eucl_of_list (map fst (aforms_of_ivls xs ys)), sum_pdevs (λi. pdevs_scaleR (snd (aforms_of_ivls xs ys ! index Basis_list i)) i) Basis)›*)
by (metis index_Basis_list_nth (*‹?i < DIM(?'a) ⟹ index Basis_list (Basis_list ! ?i) = ?i›*) inner_not_same_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis; ?u ≠ ?v⟧ ⟹ ?u ∙ ?v = 0›*) length_Basis_list (*‹length Basis_list = DIM(?'a)›*) nth_Basis_list_in_Basis (*‹?n < length Basis_list ⟹ Basis_list ! ?n ∈ Basis›*)) .
lemma bound_intersect_2d_ud[autoref_rules]:
shows "(bound_intersect_2d_ud, bound_intersect_2d_ud) ∈ nat_rel → ((rnv_rel ×⇩r rnv_rel) ×⇩r Id) → rnv_rel → ⟨rnv_rel ×⇩r rnv_rel⟩option_rel"
by auto
lemma eucl_of_list_autoref[autoref_rules]:
includes autoref_syntax
assumes "SIDE_PRECOND (length xs = DIM('a::executable_euclidean_space))"
assumes "(xsi, xs) ∈ ⟨rnv_rel⟩list_rel"
shows "(xsi, eucl_of_list $ xs::'a) ∈ lv_rel"
using assms (*‹SIDE_PRECOND (length xs = DIM('a))› ‹(xsi, xs) ∈ rl_rel›*) unfolding lv_rel_def
(*goal: ‹(xsi, eucl_of_list $ xs) ∈ br eucl_of_list (λxs. length xs = DIM('a))›*)
by (auto simp: br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*))
definition "inner2s x b c = (inner_lv_rel x b, inner_lv_rel x c)"
lemma inner_lv_rel_autoref[autoref_rules]:
"(inner_lv_rel, (∙)) ∈ lv_rel → lv_rel → rnv_rel"
using lv_rel_inner[unfolded inner_lv_rel_def [ symmetric ]] (*‹(inner_lv_rel, (∙)) ∈ lv_rel → lv_rel → rnv_rel›*) by auto
lemma inner_lv_rel_eq:
"⟦length xs = DIM('a::executable_euclidean_space); (xa, x'a) ∈ lv_rel⟧ ⟹
inner_lv_rel xs xa = eucl_of_list xs ∙ (x'a::'a)"
using inner_lv_rel_autoref[param_fo, of "xs" "eucl_of_list xs" xa x'a] (*‹⟦(xs, eucl_of_list xs) ∈ lv_rel; (xa, x'a) ∈ lv_rel⟧ ⟹ (inner_lv_rel xs xa, eucl_of_list xs ∙ x'a) ∈ rnv_rel›*) unfolding lv_rel_def
(*goal: ‹⟦length xs = DIM('a); (xa, x'a) ∈ br eucl_of_list (λxs. length xs = DIM('a))⟧ ⟹ inner_lv_rel xs xa = eucl_of_list xs ∙ x'a›*)
by (auto simp: br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*))
definition "inner_pdevs xs ys = sum_pdevs (λi. scaleR_pdevs (ys ! i) (xs ! i)) {..<length xs}"
definition "pdevs_inner2s xs a b = prod_of_pdevs (inner_pdevs xs a) (inner_pdevs xs b)"
lemma inner2_aform_autoref[autoref_rules]:
shows "((λxs a b. (inner2s (map fst xs) a b, pdevs_inner2s (map snd xs) a b)), inner2_aform) ∈ lv_aforms_rel → lv_rel → lv_rel → ((rnv_rel ×⇩r rnv_rel)×⇩rId)"
unfolding inner2_aform_def
(*goal: ‹(λxs a b. (inner2s (map fst xs) a b, pdevs_inner2s (map snd xs) a b), λX a b. (inner2 (fst X) a b, pdevs_inner2 (snd X) a b)) ∈ lv_aforms_rel → lv_rel → lv_rel → (rnv_rel ×⇩r rnv_rel) ×⇩r Id›*)
apply (auto simp: lv_aforms_rel_def (*‹lv_aforms_rel = br eucl_of_list_aform (λxs::(real × real pdevs) list. length xs = DIM(?'a))›*) br_def (*‹br (?α::?'a ⇒ ?'b) (?I::?'a ⇒ bool) ≡ {(c::?'a, a::?'b). a = ?α c ∧ ?I c}›*) eucl_of_list_aform_def (*‹eucl_of_list_aform (?xs::(real × real pdevs) list) = (eucl_of_list (map fst ?xs), sum_pdevs (λi::?'a. pdevs_scaleR (snd (?xs ! index Basis_list i)) i) Basis)›*) inner2_aform_def (*‹inner2_aform (?X::?'a × ?'a pdevs) (?a::?'a) (?b::?'a) = (inner2 (fst ?X) ?a ?b, pdevs_inner2 (snd ?X) ?a ?b)›*))
(*goal: ‹(λxs a b. (inner2s (map fst xs) a b, pdevs_inner2s (map snd xs) a b), λX a b. (inner2 (fst X) a b, pdevs_inner2 (snd X) a b)) ∈ lv_aforms_rel → lv_rel → lv_rel → (rnv_rel ×⇩r rnv_rel) ×⇩r Id›*)
apply (auto simp: inner2s_def (*‹inner2s ?x ?b ?c = (inner_lv_rel ?x ?b, inner_lv_rel ?x ?c)›*) inner2_def (*‹inner2 ?x ?n ?l = (?x ∙ ?n, ?x ∙ ?l)›*) inner_lv_rel_eq (*‹⟦length ?xs = DIM(?'a); (?xa, ?x'a) ∈ lv_rel⟧ ⟹ inner_lv_rel ?xs ?xa = eucl_of_list ?xs ∙ ?x'a›*) pdevs_inner2s_def (*‹pdevs_inner2s ?xs ?a ?b = prod_of_pdevs (inner_pdevs ?xs ?a) (inner_pdevs ?xs ?b)›*) inner_pdevs_def (*‹inner_pdevs ?xs ?ys = sum_pdevs (λi. scaleR_pdevs (?ys ! i) (?xs ! i)) {..<length ?xs}›*) sum_Basis_sum_nth_Basis_list (*‹sum ?f Basis = (∑i<DIM(?'a). ?f (Basis_list ! i))›*) inner_sum_left (*‹sum ?f ?A ∙ ?y = (∑x∈?A. ?f x ∙ ?y)›*) inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) mult.commute (*‹?a * ?b = ?b * ?a›*) intro!: pdevs_eqI (*‹(⋀i. pdevs_apply ?x i = pdevs_apply ?y i) ⟹ ?x = ?y›*))
(*top goal: ‹⋀(a::(real × real pdevs) list) (ab::real list) (a'::'a::executable_euclidean_space) (ac::real list) a'a::'a::executable_euclidean_space. ⟦(ab, a') ∈ lv_rel; (ac, a'a) ∈ lv_rel; length a = DIM('a::executable_euclidean_space)⟧ ⟹ inner2s (map fst a) ab ac = inner2 (eucl_of_list (map fst a)) a' a'a› and 1 goal remains*)
subgoal for a and b and c and d and e and f
apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*goal: ‹⟦(b, c) ∈ lv_rel; (d, e) ∈ lv_rel; length a = DIM('a)⟧ ⟹ (∑x<DIM('a). b ! x * pdevs_apply (snd (a ! x)) f) = (∑x<DIM('a). Basis_list ! x ∙ c * pdevs_apply (snd (a ! x)) f)›*)
apply force
(*top goal: ‹⟦(b, c) ∈ lv_rel; (d, e) ∈ lv_rel; length a = DIM('a)⟧ ⟹ {..<DIM('a)} = {..<DIM('a)}› and 1 goal remains*)
subgoal for n
by (auto dest!: lv_rel_nth[where b="Basis_list ! n"] (*‹⟦(?xs, ?x) ∈ lv_rel; Basis_list ! n ∈ Basis⟧ ⟹ ?xs ! index Basis_list (Basis_list ! n) = ?x ∙ Basis_list ! n›*) simp: inner_commute (*‹?x ∙ ?y = ?y ∙ ?x›*)) .
subgoal for a and b and c and d and e and f
apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*goal: ‹⟦(b::real list, c::'a::executable_euclidean_space) ∈ lv_rel; (d::real list, e::'a::executable_euclidean_space) ∈ lv_rel; length (a::(real × real pdevs) list) = DIM('a::executable_euclidean_space)⟧ ⟹ (∑x::nat<DIM('a::executable_euclidean_space). d ! x * pdevs_apply (snd (a ! x)) (f::nat)) = (∑x::nat<DIM('a::executable_euclidean_space). Basis_list ! x ∙ e * pdevs_apply (snd (a ! x)) f)›*)
apply force
(*top goal: ‹⟦(b::real list, c::'a) ∈ lv_rel; (d::real list, e::'a) ∈ lv_rel; length (a::(real × real pdevs) list) = DIM('a)⟧ ⟹ {..<DIM('a)} = {..<DIM('a)}› and 1 goal remains*)
subgoal for n
by (auto dest!: lv_rel_nth[where b="Basis_list ! n"] (*‹⟦(?xs::real list, ?x::?'b1) ∈ lv_rel; Basis_list ! (n::nat) ∈ Basis⟧ ⟹ ?xs ! index Basis_list (Basis_list ! n) = ?x ∙ Basis_list ! n›*) simp: inner_commute (*‹(?x::?'a) ∙ (?y::?'a) = ?y ∙ ?x›*)) . .
lemma RETURN_inter_aform_plane_ortho_annot:
"RETURN (inter_aform_plane_ortho p (Z::'a aform) n g) =
(case those (map (λb. bound_intersect_2d_ud p (inner2_aform Z n b) g) Basis_list) of
Some mMs ⇒
do {
ASSERT (length mMs = DIM('a::executable_euclidean_space));
let l = (∑(b, m)←zip Basis_list (map fst mMs). m *⇩R b);
let u = (∑(b, M)←zip Basis_list (map snd mMs). M *⇩R b);
RETURN (Some (aform_of_ivl l u))
}
| None ⇒ RETURN None)"
apply (auto simp: inter_aform_plane_ortho_def (*‹inter_aform_plane_ortho ?p ?Z ?n ?g = those (map (λb. bound_intersect_2d_ud ?p (inner2_aform ?Z ?n b) ?g) Basis_list) ⤜ (λmMs. let l = sum_list (map2 (λb m. m *⇩R b) Basis_list (map fst mMs)); u = sum_list (map2 (λb M. M *⇩R b) Basis_list (map snd mMs)) in Some (aform_of_ivl l u))›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))
(*goal: ‹RETURN (inter_aform_plane_ortho p Z n g) = (case those (map (λb. bound_intersect_2d_ud p (inner2_aform Z n b) g) Basis_list) of None ⇒ RETURN None | Some mMs ⇒ ASSERT (length mMs = DIM('a)) ⤜ (λ_. let l = sum_list (map2 (λb m. m *⇩R b) Basis_list (map fst mMs)); u = sum_list (map2 (λb M. M *⇩R b) Basis_list (map snd mMs)) in RETURN (Some (aform_of_ivl l u))))›*)
subgoalpremises prems for x2
proof (-)
(*goal: ‹RETURN (Some (aform_of_ivl (sum_list (map2 (λb m. m *⇩R b) Basis_list (map fst x2))) (sum_list (map2 (λb M. M *⇩R b) Basis_list (map snd x2))))) = ASSERT (length x2 = DIM('a)) ⤜ (λ_. RETURN (Some (aform_of_ivl (sum_list (map2 (λb m. m *⇩R b) Basis_list (map fst x2))) (sum_list (map2 (λb M. M *⇩R b) Basis_list (map snd x2))))))›*)
have "length x2 = DIM('a)"
using prems (*‹those (map (λb. bound_intersect_2d_ud p (inner2_aform Z n b) g) Basis_list) = Some x2›*) using map_eq_imp_length_eq (*‹map (?f::?'b::type ⇒ ?'a::type) (?xs::?'b::type list) = map (?g::?'c::type ⇒ ?'a::type) (?ys::?'c::type list) ⟹ length ?xs = length ?ys›*) by (force simp: those_eq_Some_map_Some_iff (*‹(those (?xs::?'a option list) = Some (?ys::?'a list)) = (?xs = map Some ?ys)›*))
then show "?thesis"
(*goal: ‹RETURN (Some (aform_of_ivl (sum_list (map2 (λb m. m *⇩R b) Basis_list (map fst x2))) (sum_list (map2 (λb M. M *⇩R b) Basis_list (map snd x2))))) = ASSERT (length x2 = DIM('a)) ⤜ (λ_. RETURN (Some (aform_of_ivl (sum_list (map2 (λb m. m *⇩R b) Basis_list (map fst x2))) (sum_list (map2 (λb M. M *⇩R b) Basis_list (map snd x2))))))›*)
using prems (*‹those (map (λb. bound_intersect_2d_ud p (inner2_aform Z n b) g) Basis_list) = Some x2›*) by auto
qed .
definition "inter_aform_plane_ortho_nres p Z n g = RETURN (inter_aform_plane_ortho p Z n g)"
schematic_goal inter_aform_plane_ortho_lv:
fixes Z::"'a::executable_euclidean_space aform"
assumes [autoref_rules_raw]: "DIM_precond TYPE('a) D"
assumes [autoref_rules]: "(pp, p) ∈ nat_rel" "(Zi, Z) ∈ lv_aforms_rel"
"(ni, n) ∈ lv_rel" "(gi, g) ∈ rnv_rel"
notes [autoref_rules] = those_param param_map
shows "(nres_of (?f::?'a dres), inter_aform_plane_ortho_nres $ p $ Z $ n $ g) ∈ ?R"
unfolding autoref_tag_defs
(*goal: ‹(nres_of (?f::?'a::type dres), inter_aform_plane_ortho_nres (p::nat) (Z::'a::executable_euclidean_space × 'a::executable_euclidean_space pdevs) (n::'a::executable_euclidean_space) (g::real)) ∈ (?R::(?'a::type nres × ('a::executable_euclidean_space × 'a::executable_euclidean_space pdevs) option nres) set)›*)
unfolding RETURN_inter_aform_plane_ortho_annot inter_aform_plane_ortho_nres_def
(*goal: ‹(nres_of ?f, case those (map (λb. bound_intersect_2d_ud p (inner2_aform Z n b) g) Basis_list) of None ⇒ RETURN None | Some mMs ⇒ ASSERT (length mMs = DIM('a)) ⤜ (λ_. let l = sum_list (map2 (λb m. m *⇩R b) Basis_list (map fst mMs)); u = sum_list (map2 (λb M. M *⇩R b) Basis_list (map snd mMs)) in RETURN (Some (aform_of_ivl l u)))) ∈ ?R›*)
including art
by autoref_monadic
concrete_definition inter_aform_plane_ortho_lv for pp Zi ni gi uses inter_aform_plane_ortho_lv
lemmas [autoref_rules] = inter_aform_plane_ortho_lv.refine
lemma project_coord_lv[autoref_rules]:
assumes "(xs, x::'a::executable_euclidean_space aform) ∈ lv_aforms_rel" "(ni, n) ∈ nat_rel"
assumes "SIDE_PRECOND (n < DIM('a))"
shows "(project_coord_aform_lv xs ni, project_ncoord_aform $ x $ n) ∈ rnv_rel → lv_aforms_rel"
using assms (*‹(xs::(real × real pdevs) list, x::'a × 'a pdevs) ∈ lv_aforms_rel› ‹(ni, n) ∈ nat_rel› ‹SIDE_PRECOND (n < DIM('a))›*) apply (auto simp: project_coord_aform_lv_def (*‹project_coord_aform_lv (?xs::(real × real pdevs) list) (?b::nat) (?n::real) = ?xs[?b := (?n, zero_pdevs)]›*) project_ncoord_aform_def (*‹project_ncoord_aform (?x::?'a × ?'a pdevs) (?b::nat) (?n::real) = project_coord_aform (Sctn (Basis_list ! ?b) ?n) ?x›*) lv_rel_def (*‹lv_rel = br eucl_of_list (λxs::real list. length xs = DIM(?'a))›*) project_coord_aform_def (*‹project_coord_aform (?sctn::?'a sctn) (?cxs::?'a × ?'a pdevs) = (project_coord (fst ?cxs) (normal ?sctn) (pstn ?sctn), project_coord_pdevs ?sctn (snd ?cxs))›*) eucl_of_list_aform_def (*‹eucl_of_list_aform (?xs::(real × real pdevs) list) = (eucl_of_list (map fst ?xs), sum_pdevs (λi::?'a. pdevs_scaleR (snd (?xs ! index Basis_list i)) i) Basis)›*) lv_aforms_rel_def (*‹lv_aforms_rel = br eucl_of_list_aform (λxs::(real × real pdevs) list. length xs = DIM(?'a))›*) br_def (*‹br (?α::?'a ⇒ ?'b) (?I::?'a ⇒ bool) ≡ {(c::?'a, a::?'b). a = ?α c ∧ ?I c}›*))
(*goal: ‹(project_coord_aform_lv xs ni, project_ncoord_aform $ x $ n) ∈ rnv_rel → lv_aforms_rel›*)
subgoal for
apply (auto intro!: euclidean_eqI[where 'a='a] (*‹(⋀b::'a. b ∈ Basis ⟹ (?x::'a) ∙ b = (?y::'a) ∙ b) ⟹ ?x = ?y›*))
(*goal: ‹⟦ni = n; n < DIM('a); x = (eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a)⟧ ⟹ project_coord (eucl_of_list (map fst xs)) (Basis_list ! n) a'_ = eucl_of_list (map fst (xs[n := (a'_, zero_pdevs)]))›*)
apply (subst project_coord_inner_Basis (*‹?i ∈ Basis ⟹ project_coord ?x ?b ?n ∙ ?i = (if ?i = ?b then ?n else if ?i = - ?b then - ?n else ?x ∙ ?i)›*))
(*goal: ‹⋀b. ⟦ni = n; n < DIM('a); x = (eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a); b ∈ Basis⟧ ⟹ project_coord (eucl_of_list (map fst xs)) (Basis_list ! n) a'_ ∙ b = eucl_of_list (map fst (xs[n := (a'_, zero_pdevs)])) ∙ b›*)
apply (auto simp: eucl_of_list_inner (*‹⟦?i ∈ Basis; length ?xs = DIM(?'a)⟧ ⟹ eucl_of_list ?xs ∙ ?i = ?xs ! index Basis_list ?i›*))
(*top goal: ‹⋀b::'a. ⟦(ni::nat) = (n::nat); n < DIM('a); (x::'a × 'a pdevs) = (eucl_of_list (map fst (xs::(real × real pdevs) list)), sum_pdevs (λi::'a. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a); b ∈ Basis⟧ ⟹ b ∈ Basis› and 1 goal remains*)
apply (subst nth_list_update (*‹?i < length ?xs ⟹ ?xs[?i := ?x] ! ?j = (if ?i = ?j then ?x else ?xs ! ?j)›*))
(*top goal: ‹⟦ni = n; n < DIM('a); x = (eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a); - Basis_list ! n ∈ Basis; Basis_list ! n ≠ 0⟧ ⟹ - a'_ = fst (xs[n := (a'_, zero_pdevs)] ! index Basis_list (- Basis_list ! n))› and 1 goal remains*)
apply auto
(*top goal: ‹⟦ni = n; n < DIM('a); x = (eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a); - Basis_list ! n ∈ Basis; Basis_list ! n ≠ 0⟧ ⟹ n < length xs› and 2 goals remain*)
using in_Basis_index_Basis_list (*‹?i ∈ Basis ⟹ ?i = Basis_list ! index Basis_list ?i›*) apply force
(*top goal: ‹⟦ni = n; n < DIM('a); x = (eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a); - Basis_list ! n ∈ Basis; Basis_list ! n ≠ 0; n = index Basis_list (- Basis_list ! n)⟧ ⟹ a'_ = 0› and 2 goals remain*)
using inner_not_same_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis; ?u ≠ ?v⟧ ⟹ ?u ∙ ?v = 0›*) nth_Basis_list_in_Basis (*‹?n < length Basis_list ⟹ Basis_list ! ?n ∈ Basis›*)
(*goals:
1. ‹⟦ni = n; n < DIM('a); x = (eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a); - Basis_list ! n ∈ Basis; Basis_list ! n ≠ 0; n ≠ index Basis_list (- Basis_list ! n)⟧ ⟹ - a'_ = fst (xs ! index Basis_list (- Basis_list ! n))›
2. ‹⋀b. ⟦ni = n; n < DIM('a); x = (eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a); b ∈ Basis; b ≠ - Basis_list ! n; b ≠ Basis_list ! n⟧ ⟹ fst (xs ! index Basis_list b) = fst (xs[n := (a'_, zero_pdevs)] ! index Basis_list b)›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply (auto simp: nth_list_update (*‹?i < length ?xs ⟹ ?xs[?i := ?x] ! ?j = (if ?i = ?j then ?x else ?xs ! ?j)›*))
(*proven 2 subgoals*) .
subgoal for i
apply (auto intro!: pdevs_eqI (*‹(⋀i. pdevs_apply ?x i = pdevs_apply ?y i) ⟹ ?x = ?y›*) simp: project_coord_pdevs.rep_eq (*‹pdevs_apply (project_coord_pdevs ?x ?xa) = (λi. project_coord (pdevs_apply ?xa i) (normal ?x) 0)›*))
(*goal: ‹⟦ni = n; n < DIM('a); x = (eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a)⟧ ⟹ project_coord_pdevs (Sctn (Basis_list ! n) i) (sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis) = sum_pdevs (λia. pdevs_scaleR (snd (xs[n := (i, zero_pdevs)] ! index Basis_list ia)) ia) Basis›*)
apply (auto intro!: euclidean_eqI[where 'a='a] (*‹(⋀b. b ∈ Basis ⟹ ?x ∙ b = ?y ∙ b) ⟹ ?x = ?y›*))
(*goal: ‹⋀ia::nat. ⟦(ni::nat) = (n::nat); n < DIM('a::executable_euclidean_space); (x::'a::executable_euclidean_space × 'a::executable_euclidean_space pdevs) = (eucl_of_list (map fst (xs::(real × real pdevs) list)), sum_pdevs (λi::'a::executable_euclidean_space. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a::executable_euclidean_space)⟧ ⟹ project_coord (∑x::'a::executable_euclidean_space∈Basis. pdevs_apply (snd (xs ! index Basis_list x)) ia *⇩R x) (Basis_list ! n) (0::real) = (∑x::'a::executable_euclidean_space∈Basis. pdevs_apply (snd (xs[n := (i::real, zero_pdevs)] ! index Basis_list x)) ia *⇩R x)›*)
apply (subst project_coord_inner_Basis (*‹?i ∈ Basis ⟹ project_coord ?x ?b ?n ∙ ?i = (if ?i = ?b then ?n else if ?i = - ?b then - ?n else ?x ∙ ?i)›*))
(*goal: ‹⋀ia b. ⟦ni = n; n < DIM('a); x = (eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a); b ∈ Basis⟧ ⟹ project_coord (∑x∈Basis. pdevs_apply (snd (xs ! index Basis_list x)) ia *⇩R x) (Basis_list ! n) 0 ∙ b = pdevs_apply (snd (xs[n := (i, zero_pdevs)] ! index Basis_list b)) ia›*)
apply (auto simp: eucl_of_list_inner (*‹⟦?i ∈ Basis; length ?xs = DIM(?'a)⟧ ⟹ eucl_of_list ?xs ∙ ?i = ?xs ! index Basis_list ?i›*))
(*top goal: ‹⋀i b. ⟦ni = n; n < DIM('a); x = (eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a); b ∈ Basis⟧ ⟹ b ∈ Basis› and 1 goal remains*)
apply (subst nth_list_update (*‹?i < length ?xs ⟹ ?xs[?i := ?x] ! ?j = (if ?i = ?j then ?x else ?xs ! ?j)›*))
(*top goal: ‹⋀ia. ⟦ni = n; n < DIM('a); x = (eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a); - Basis_list ! n ∈ Basis; Basis_list ! n ≠ 0⟧ ⟹ pdevs_apply (snd (xs[n := (i, zero_pdevs)] ! index Basis_list (- Basis_list ! n))) ia = 0› and 1 goal remains*)
apply auto
(*top goal: ‹⋀i. ⟦ni = n; n < DIM('a); x = (eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a); - Basis_list ! n ∈ Basis; Basis_list ! n ≠ 0⟧ ⟹ n < length xs› and 2 goals remain*)
using inner_not_same_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis; ?u ≠ ?v⟧ ⟹ ?u ∙ ?v = 0›*) nth_Basis_list_in_Basis (*‹?n < length Basis_list ⟹ Basis_list ! ?n ∈ Basis›*)
(*goals:
1. ‹⋀i. ⟦ni = n; n < DIM('a); x = (eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a); - Basis_list ! n ∈ Basis; Basis_list ! n ≠ 0; n ≠ index Basis_list (- Basis_list ! n)⟧ ⟹ pdevs_apply (snd (xs ! index Basis_list (- Basis_list ! n))) i = 0›
2. ‹⋀ia b. ⟦ni = n; n < DIM('a); x = (eucl_of_list (map fst xs), sum_pdevs (λi. pdevs_scaleR (snd (xs ! index Basis_list i)) i) Basis); length xs = DIM('a); b ∈ Basis; b ≠ - Basis_list ! n; b ≠ Basis_list ! n⟧ ⟹ pdevs_apply (snd (xs ! index Basis_list b)) ia = pdevs_apply (snd (xs[n := (i, zero_pdevs)] ! index Basis_list b)) ia›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply (auto simp: nth_list_update (*‹?i < length ?xs ⟹ ?xs[?i := ?x] ! ?j = (if ?i = ?j then ?x else ?xs ! ?j)›*))
(*proven 2 subgoals*) . .
definition inter_aform_plane
where "inter_aform_plane prec Xs (sctn::'a sctn) =
do {
cxs ← inter_aform_plane_ortho_nres (prec) (Xs) (normal sctn) (pstn sctn);
case cxs of
Some cxs ⇒
(if normal sctn ∈ set Basis_list
then do {
ASSERT (index Basis_list (normal sctn) < DIM('a::executable_euclidean_space));
RETURN ((project_ncoord_aform cxs (index Basis_list (normal sctn)) (pstn sctn)))
}
else if - normal sctn ∈ set Basis_list
then do {
ASSERT (index Basis_list (-normal sctn) < DIM('a));
RETURN ((project_ncoord_aform cxs (index Basis_list (-normal sctn)) (- pstn sctn)))
}
else SUCCEED)
| None ⇒ SUCCEED
}"
lemma [autoref_rules]:
assumes [THEN GEN_OP_D, param]: "GEN_OP (=) (=) (A → A → bool_rel)"
shows "(index, index) ∈ ⟨A⟩list_rel → A → nat_rel"
unfolding index_def find_index_def
(*goal: ‹(λ(xs::'a list) a::'a. rec_list (λ_::'a ⇒ bool. 0::nat) (λ(x::'a) (xs::'a list) (xsa::('a ⇒ bool) ⇒ nat) P::'a ⇒ bool. if P x then 0::nat else xsa P + (1::nat)) xs (λx::'a. x = a), λ(xs::'b list) a::'b. rec_list (λ_::'b ⇒ bool. 0::nat) (λ(x::'b) (xs::'b list) (xsa::('b ⇒ bool) ⇒ nat) P::'b ⇒ bool. if P x then 0::nat else xsa P + (1::nat)) xs (λx::'b. x = a)) ∈ ⟨A::('a × 'b) set⟩list_rel → A → nat_rel›*)
by parametricity
schematic_goal inter_aform_plane_lv:
fixes Z::"'a::executable_euclidean_space aform"
assumes [autoref_rules_raw]: "DIM_precond TYPE('a) D"
assumes [autoref_rules]: "(preci, prec) ∈ nat_rel" "(Zi, Z) ∈ lv_aforms_rel"
"(sctni, sctn) ∈ ⟨lv_rel⟩sctn_rel"
notes [autoref_rules] = those_param param_map
shows "(nres_of (?f::?'a dres), inter_aform_plane prec Z sctn) ∈ ?R"
unfolding autoref_tag_defs
(*goal: ‹(nres_of ?f, inter_aform_plane prec Z sctn) ∈ ?R›*)
unfolding inter_aform_plane_def
(*goal: ‹(nres_of ?f, inter_aform_plane_ortho_nres prec Z (normal sctn) (pstn sctn) ⤜ case_option SUCCEED (λcxs. if normal sctn ∈ set Basis_list then ASSERT (index Basis_list (normal sctn) < DIM('a)) ⤜ (λ_. RETURN (project_ncoord_aform cxs (index Basis_list (normal sctn)) (pstn sctn))) else if - normal sctn ∈ set Basis_list then ASSERT (index Basis_list (- normal sctn) < DIM('a)) ⤜ (λ_. RETURN (project_ncoord_aform cxs (index Basis_list (- normal sctn)) (- pstn sctn))) else SUCCEED)) ∈ ?R›*)
including art
by autoref_monadic
concrete_definition inter_aform_plane_lv for preci Zi sctni uses inter_aform_plane_lv
lemmas [autoref_rules] = inter_aform_plane_lv.refine[autoref_higher_order_rule(1)]
end
lemma Basis_not_uminus:
fixes i::"'a::euclidean_space"
shows "i ∈ Basis ⟹ - i ∉ Basis"
by (metis inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) inner_minus_left (*‹- ?x ∙ ?y = - (?x ∙ ?y)›*) one_neq_neg_one (*‹1 ≠ - 1›*) zero_neq_neg_one (*‹0 ≠ - 1›*))
lemma
pdevs_apply_project_coord_pdevs:
assumes "normal sctn ∈ Basis ∨ - normal sctn ∈ Basis"
assumes "i ∈ Basis"
shows "pdevs_apply (project_coord_pdevs sctn cxs) x ∙ i =
(if i = abs (normal sctn) then 0 else pdevs_apply cxs x ∙ i)"
using assms[unfolded abs_in_Basis_iff [ symmetric ]] (*‹¦normal (sctn::'a sctn)¦ ∈ Basis› ‹i ∈ Basis›*) apply (transfer fixing: sctn)
(*goal: ‹pdevs_apply (project_coord_pdevs (sctn::'a::executable_euclidean_space sctn) (cxs::'a::executable_euclidean_space pdevs)) (x::nat) ∙ (i::'a::executable_euclidean_space) = (if i = ¦normal sctn¦ then 0::real else pdevs_apply cxs x ∙ i)›*)
apply (auto simp: project_coord_inner (*‹¦?i¦ ∈ Basis ⟹ project_coord ?x ?b ?n ∙ ?i = (if ?i = ?b then ?n else if ?i = - ?b then - ?n else ?x ∙ ?i)›*) Basis_not_uminus (*‹?i ∈ Basis ⟹ - ?i ∉ Basis›*))
(*goal: ‹⋀i cxs x. ⟦¦normal sctn¦ ∈ Basis; i ∈ Basis; finite {i. cxs i ≠ 0}⟧ ⟹ project_coord (cxs x) (normal sctn) 0 ∙ i = (if i = ¦normal sctn¦ then 0 else cxs x ∙ i)›*)
using Basis_nonneg (*‹?i ∈ Basis ⟹ 0 ≤ ?i›*) apply force
(*top goal: ‹⋀cxs x. ⟦¦normal sctn¦ ∈ Basis; - normal sctn ∈ Basis; finite {i. cxs i ≠ 0}; ¦normal sctn¦ ≠ normal sctn; normal sctn ≠ 0; - normal sctn ≠ ¦normal sctn¦⟧ ⟹ cxs x ∙ normal sctn = 0› and 1 goal remains*)
using Basis_nonneg (*‹?i ∈ Basis ⟹ 0 ≤ ?i›*) assms(1) (*‹normal (sctn::'a::executable_euclidean_space sctn) ∈ Basis ∨ - normal sctn ∈ Basis›*) by force
lemma pdevs_domain_project_coord_pdevs_subset:
"pdevs_domain (project_coord_pdevs sctn X) ⊆ pdevs_domain X"
apply auto
(*goal: ‹pdevs_domain (project_coord_pdevs sctn X) ⊆ pdevs_domain X›*)
apply (auto simp: euclidean_eq_iff[where 'a='a] (*‹(?x = ?y) = (∀b∈Basis. ?x ∙ b = ?y ∙ b)›*))
(*goal: ‹⋀x::nat. ⟦pdevs_apply (project_coord_pdevs (sctn::'a::executable_euclidean_space sctn) (X::'a::executable_euclidean_space pdevs)) x ≠ (0::'a::executable_euclidean_space); pdevs_apply X x = (0::'a::executable_euclidean_space)⟧ ⟹ False›*)
by (metis add.inverse_neutral (*‹- 0 = 0›*) project_coord_inner_Basis (*‹?i ∈ Basis ⟹ project_coord ?x ?b ?n ∙ ?i = (if ?i = ?b then ?n else if ?i = - ?b then - ?n else ?x ∙ ?i)›*) project_coord_pdevs.rep_eq (*‹pdevs_apply (project_coord_pdevs ?x ?xa) = (λi. project_coord (pdevs_apply ?xa i) (normal ?x) 0)›*))
lemma pdevs_val_project_coord_pdevs_inner_Basis:
assumes "b ∈ Basis"
shows "pdevs_val e (project_coord_pdevs sctn X) ∙ b =
(if b = abs (normal sctn) then 0 else pdevs_val e X ∙ b)"
using assms (*‹b ∈ Basis›*) apply auto
(*goal: ‹pdevs_val (e::nat ⇒ real) (project_coord_pdevs (sctn::'a sctn) (X::'a pdevs)) ∙ (b::'a) = (if b = ¦normal sctn¦ then 0::real else pdevs_val e X ∙ b)›*)
apply (simp add: pdevs_val_pdevs_domain (*‹pdevs_val ?e ?X = (∑i∈pdevs_domain ?X. ?e i *⇩R pdevs_apply ?X i)›*) inner_sum_left (*‹sum ?f ?A ∙ ?y = (∑x∈?A. ?f x ∙ ?y)›*))
(*top goal: ‹⟦¦normal sctn¦ ∈ Basis; b = ¦normal sctn¦⟧ ⟹ pdevs_val e (project_coord_pdevs sctn X) ∙ ¦normal sctn¦ = 0› and 1 goal remains*)
apply (subst sum.cong[OF refl] (*‹(⋀x::?'b::type. x ∈ (?A::?'b::type set) ⟹ (?g::?'b::type ⇒ ?'a::comm_monoid_add) x = (?h::?'b::type ⇒ ?'a::comm_monoid_add) x) ⟹ sum ?g ?A = sum ?h ?A›*))
(*top goal: ‹⟦¦normal sctn¦ ∈ Basis; b = ¦normal sctn¦⟧ ⟹ (∑i∈pdevs_domain (project_coord_pdevs sctn X). e i * (pdevs_apply (project_coord_pdevs sctn X) i ∙ ¦normal sctn¦)) = 0› and 1 goal remains*)
apply (subst pdevs_apply_project_coord_pdevs (*‹⟦normal ?sctn ∈ Basis ∨ - normal ?sctn ∈ Basis; ?i ∈ Basis⟧ ⟹ pdevs_apply (project_coord_pdevs ?sctn ?cxs) ?x ∙ ?i = (if ?i = ¦normal ?sctn¦ then 0 else pdevs_apply ?cxs ?x ∙ ?i)›*))
(*top goal: ‹⋀x. ⟦¦normal sctn¦ ∈ Basis; b = ¦normal sctn¦; x ∈ pdevs_domain (project_coord_pdevs sctn X)⟧ ⟹ e x * (pdevs_apply (project_coord_pdevs sctn X) x ∙ ¦normal sctn¦) = ?h11 x› and 2 goals remain*)
apply (simp add: abs_in_Basis_iff (*‹(¦?u¦ ∈ Basis) = (?u ∈ Basis ∨ - ?u ∈ Basis)›*))
(*top goal: ‹⋀x. ⟦¦normal sctn¦ ∈ Basis; b = ¦normal sctn¦; x ∈ pdevs_domain (project_coord_pdevs sctn X)⟧ ⟹ normal sctn ∈ Basis ∨ - normal sctn ∈ Basis› and 4 goals remain*)
apply simp
(*top goal: ‹⋀x. ⟦¦normal sctn¦ ∈ Basis; b = ¦normal sctn¦; x ∈ pdevs_domain (project_coord_pdevs sctn X)⟧ ⟹ ¦normal sctn¦ ∈ Basis› and 3 goals remain*)
apply (rule refl (*‹(?t::?'a) = ?t›*))
(*top goal: ‹⋀x. ⟦¦normal sctn¦ ∈ Basis; b = ¦normal sctn¦; x ∈ pdevs_domain (project_coord_pdevs sctn X)⟧ ⟹ e x * (if ¦normal sctn¦ = ¦normal sctn¦ then 0 else pdevs_apply X x ∙ ¦normal sctn¦) = ?h14 x x› and 2 goals remain*)
apply auto
(*top goal: ‹⟦¦normal sctn¦ ∈ Basis; b = ¦normal sctn¦⟧ ⟹ (∑x∈pdevs_domain (project_coord_pdevs sctn X). e x * (if ¦normal sctn¦ = ¦normal sctn¦ then 0 else pdevs_apply X x ∙ ¦normal sctn¦)) = 0› and 1 goal remains*)
unfolding pdevs_val_pdevs_domain inner_sum_left
(*goal: ‹⟦b ∈ Basis; b ≠ ¦normal sctn¦⟧ ⟹ (∑x∈pdevs_domain (project_coord_pdevs sctn X). e x *⇩R pdevs_apply (project_coord_pdevs sctn X) x ∙ b) = (∑x∈pdevs_domain X. e x *⇩R pdevs_apply X x ∙ b)›*)
apply (rule sum.mono_neutral_cong_left (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?h i = 0; ⋀x. x ∈ ?S ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?S = sum ?h ?T›*))
(*goals:
1. ‹⟦b ∈ Basis; b ≠ ¦normal sctn¦⟧ ⟹ finite (pdevs_domain X)›
2. ‹⟦b ∈ Basis; b ≠ ¦normal sctn¦⟧ ⟹ pdevs_domain (project_coord_pdevs sctn X) ⊆ pdevs_domain X›
3. ‹⟦b ∈ Basis; b ≠ ¦normal sctn¦⟧ ⟹ ∀i∈pdevs_domain X - pdevs_domain (project_coord_pdevs sctn X). e i *⇩R pdevs_apply X i ∙ b = 0›
4. ‹⋀x. ⟦b ∈ Basis; b ≠ ¦normal sctn¦; x ∈ pdevs_domain (project_coord_pdevs sctn X)⟧ ⟹ e x *⇩R pdevs_apply (project_coord_pdevs sctn X) x ∙ b = e x *⇩R pdevs_apply X x ∙ b›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (rule pdevs_domain_project_coord_pdevs_subset (*‹pdevs_domain (project_coord_pdevs ?sctn ?X) ⊆ pdevs_domain ?X›*))
(*discuss goal 3*)
apply ((auto)[1])
(*top goal: ‹⟦(b::'a) ∈ Basis; b ≠ ¦normal (sctn::'a sctn)¦⟧ ⟹ ∀i::nat∈pdevs_domain (X::'a pdevs) - pdevs_domain (project_coord_pdevs sctn X). (e::nat ⇒ real) i *⇩R pdevs_apply X i ∙ b = (0::real)› and 1 goal remains*)
apply (metis Basis_nonneg (*‹?i ∈ Basis ⟹ 0 ≤ ?i›*) abs_minus_cancel (*‹¦- ?a¦ = ¦?a¦›*) abs_of_nonneg (*‹0 ≤ ?a ⟹ ¦?a¦ = ?a›*) euclidean_all_zero_iff (*‹(∀u∈Basis. ?x ∙ u = 0) = (?x = 0)›*) project_coord_inner_Basis (*‹?i ∈ Basis ⟹ project_coord ?x ?b ?n ∙ ?i = (if ?i = ?b then ?n else if ?i = - ?b then - ?n else ?x ∙ ?i)›*) project_coord_pdevs.rep_eq (*‹pdevs_apply (project_coord_pdevs ?x ?xa) = (λi. project_coord (pdevs_apply ?xa i) (normal ?x) 0)›*))
(*discuss goal 4*)
apply ((auto)[1])
(*goal: ‹⋀x. ⟦b ∈ Basis; b ≠ ¦normal sctn¦; x ∈ pdevs_domain (project_coord_pdevs sctn X)⟧ ⟹ e x *⇩R pdevs_apply (project_coord_pdevs sctn X) x ∙ b = e x *⇩R pdevs_apply X x ∙ b›*)
apply (metis Basis_nonneg (*‹?i ∈ Basis ⟹ 0 ≤ ?i›*) abs_minus_cancel (*‹¦- ?a¦ = ¦?a¦›*) abs_of_nonneg (*‹0 ≤ ?a ⟹ ¦?a¦ = ?a›*) project_coord_inner_Basis (*‹?i ∈ Basis ⟹ project_coord ?x ?b ?n ∙ ?i = (if ?i = ?b then ?n else if ?i = - ?b then - ?n else ?x ∙ ?i)›*) project_coord_pdevs.rep_eq (*‹pdevs_apply (project_coord_pdevs ?x ?xa) = (λi. project_coord (pdevs_apply ?xa i) (normal ?x) 0)›*))
(*proven 4 subgoals*) .
lemma inner_in_Sum: "b ∈ Basis ⟹ x ∙ b = (∑i∈Basis. x ∙ i * (i ∙ b))"
apply (subst euclidean_representation[of x, symmetric] (*‹x = (∑b∈Basis. (x ∙ b) *⇩R b)›*))
(*goal: ‹(b::'a) ∈ Basis ⟹ (x::'a) ∙ b = (∑i::'a∈Basis. x ∙ i * (i ∙ b))›*)
unfolding inner_sum_left
(*goal: ‹b ∈ Basis ⟹ (∑xa∈Basis. (x ∙ xa) *⇩R xa ∙ b) = (∑i∈Basis. x ∙ i * (i ∙ b))›*)
by (auto simp: intro!:)
lemma aform_val_project_coord_aform:
"aform_val e (project_coord_aform sctn X) = project_coord (aform_val e X) (normal sctn) (pstn sctn)"
apply (auto simp: aform_val_def (*‹aform_val (?e::nat ⇒ real) (?X::?'a × ?'a pdevs) = fst ?X + pdevs_val ?e (snd ?X)›*) project_coord_def (*‹project_coord (?x::?'a) (?b::?'a) (?n::real) = (∑i::?'a←Basis_list. (if i = ?b then ?n else if i = - ?b then - ?n else ?x ∙ i) *⇩R i)›*) project_coord_aform_def (*‹project_coord_aform (?sctn::?'a sctn) (?cxs::?'a × ?'a pdevs) = (project_coord (fst ?cxs) (normal ?sctn) (pstn ?sctn), project_coord_pdevs ?sctn (snd ?cxs))›*))
(*goal: ‹aform_val e (project_coord_aform sctn X) = project_coord (aform_val e X) (normal sctn) (pstn sctn)›*)
apply (rule euclidean_eqI (*‹(⋀b::?'a. b ∈ Basis ⟹ (?x::?'a) ∙ b = (?y::?'a) ∙ b) ⟹ ?x = ?y›*))
(*goal: ‹(∑b∈Basis. (if b = normal sctn then pstn sctn else if b = - normal sctn then - pstn sctn else fst X ∙ b) *⇩R b) + pdevs_val e (project_coord_pdevs sctn (snd X)) = (∑b∈Basis. (if b = normal sctn then pstn sctn else if b = - normal sctn then - pstn sctn else (fst X + pdevs_val e (snd X)) ∙ b) *⇩R b)›*)
unfolding inner_add_left inner_sum_left
(*goal: ‹⋀b. b ∈ Basis ⟹ (∑x∈Basis. (if x = normal sctn then pstn sctn else if x = - normal sctn then - pstn sctn else fst X ∙ x) *⇩R x ∙ b) + pdevs_val e (project_coord_pdevs sctn (snd X)) ∙ b = (∑x∈Basis. (if x = normal sctn then pstn sctn else if x = - normal sctn then - pstn sctn else fst X ∙ x + pdevs_val e (snd X) ∙ x) *⇩R x ∙ b)›*)
apply (subst pdevs_val_project_coord_pdevs_inner_Basis (*‹?b ∈ Basis ⟹ pdevs_val ?e (project_coord_pdevs ?sctn ?X) ∙ ?b = (if ?b = ¦normal ?sctn¦ then 0 else pdevs_val ?e ?X ∙ ?b)›*))
(*goal: ‹⋀b. b ∈ Basis ⟹ (∑x∈Basis. (if x = normal sctn then pstn sctn else if x = - normal sctn then - pstn sctn else fst X ∙ x) *⇩R x ∙ b) + pdevs_val e (project_coord_pdevs sctn (snd X)) ∙ b = (∑x∈Basis. (if x = normal sctn then pstn sctn else if x = - normal sctn then - pstn sctn else fst X ∙ x + pdevs_val e (snd X) ∙ x) *⇩R x ∙ b)›*)
apply auto
(*top goal: ‹⋀b. b ∈ Basis ⟹ b ∈ Basis› and 1 goal remains*)
apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*top goal: ‹¦normal sctn¦ ∈ Basis ⟹ (∑x∈Basis. (if x = normal sctn then pstn sctn else if x = - normal sctn then - pstn sctn else fst X ∙ x) * (x ∙ ¦normal sctn¦)) = (∑x∈Basis. (if x = normal sctn then pstn sctn else if x = - normal sctn then - pstn sctn else fst X ∙ x + pdevs_val e (snd X) ∙ x) * (x ∙ ¦normal sctn¦))› and 1 goal remains*)
apply auto
(*top goal: ‹¦normal (sctn::'a sctn)¦ ∈ Basis ⟹ Basis = Basis› and 2 goals remain*)
apply (metis abs_in_Basis_iff (*‹(¦?u¦ ∈ Basis) = (?u ∈ Basis ∨ - ?u ∈ Basis)›*) abs_inner (*‹?i ∈ Basis ⟹ ¦?x¦ ∙ ?i = ¦?x ∙ ?i¦›*) abs_inner_Basis (*‹⟦¦?u¦ ∈ Basis; ¦?v¦ ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else if ?u = - ?v then - 1 else 0)›*) abs_zero (*‹¦0¦ = 0›*) inner_commute (*‹?x ∙ ?y = ?y ∙ ?x›*))
(*top goal: ‹⋀x. ⟦¦normal sctn¦ ∈ Basis; x ∈ Basis; x ≠ - normal sctn; x ≠ normal sctn; pdevs_val e (snd X) ∙ x ≠ 0⟧ ⟹ x ∙ ¦normal sctn¦ = 0› and 1 goal remains*)
apply (subst inner_in_Sum[where x="pdevs_val e (snd X)"] (*‹?b ∈ Basis ⟹ pdevs_val e (snd X) ∙ ?b = (∑i∈Basis. pdevs_val e (snd X) ∙ i * (i ∙ ?b))›*), force)
(*goal: ‹⋀b. ⟦b ∈ Basis; b ≠ ¦normal sctn¦⟧ ⟹ (∑x∈Basis. (if x = normal sctn then pstn sctn else if x = - normal sctn then - pstn sctn else fst X ∙ x) * (x ∙ b)) + pdevs_val e (snd X) ∙ b = (∑x∈Basis. (if x = normal sctn then pstn sctn else if x = - normal sctn then - pstn sctn else fst X ∙ x + pdevs_val e (snd X) ∙ x) * (x ∙ b))›*)
unfolding sum.distrib[symmetric]
(*goal: ‹⋀b::'a. ⟦b ∈ Basis; b ≠ ¦normal (sctn::'a sctn)¦⟧ ⟹ (∑x::'a∈Basis. (if x = normal sctn then pstn sctn else if x = - normal sctn then - pstn sctn else fst (X::'a × 'a pdevs) ∙ x) * (x ∙ b) + pdevs_val (e::nat ⇒ real) (snd X) ∙ x * (x ∙ b)) = (∑x::'a∈Basis. (if x = normal sctn then pstn sctn else if x = - normal sctn then - pstn sctn else fst X ∙ x + pdevs_val e (snd X) ∙ x) * (x ∙ b))›*)
apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*goals:
1. ‹⋀b. ⟦b ∈ Basis; b ≠ ¦normal sctn¦⟧ ⟹ Basis = Basis›
2. ‹⋀b x. ⟦b ∈ Basis; b ≠ ¦normal sctn¦; x ∈ Basis⟧ ⟹ (if x = normal sctn then pstn sctn else if x = - normal sctn then - pstn sctn else fst X ∙ x) * (x ∙ b) + pdevs_val e (snd X) ∙ x * (x ∙ b) = (if x = normal sctn then pstn sctn else if x = - normal sctn then - pstn sctn else fst X ∙ x + pdevs_val e (snd X) ∙ x) * (x ∙ b)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*goals:
1. ‹⋀b. ⟦b ∈ Basis; b ≠ ¦normal sctn¦; - normal sctn ∈ Basis; normal sctn ≠ 0; normal sctn ∙ b ≠ 0⟧ ⟹ pdevs_val e (snd X) ∙ normal sctn = 0›
2. ‹⋀b. ⟦b ∈ Basis; b ≠ normal sctn; normal sctn ∈ Basis; normal sctn ≠ - normal sctn; normal sctn ∙ b ≠ 0⟧ ⟹ pdevs_val e (snd X) ∙ normal sctn = 0›
3. ‹⋀b x. ⟦b ∈ Basis; b ≠ ¦normal sctn¦; x ∈ Basis; x ≠ - normal sctn; x ≠ normal sctn⟧ ⟹ fst X ∙ x * (x ∙ b) + pdevs_val e (snd X) ∙ x * (x ∙ b) = (fst X ∙ x + pdevs_val e (snd X) ∙ x) * (x ∙ b)›
discuss goal 1*)
apply (metis Basis_nonneg (*‹?i ∈ Basis ⟹ 0 ≤ ?i›*) abs_inner_Basis (*‹⟦¦?u¦ ∈ Basis; ¦?v¦ ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else if ?u = - ?v then - 1 else 0)›*) abs_of_nonneg (*‹0 ≤ ?a ⟹ ¦?a¦ = ?a›*) abs_of_nonpos (*‹?a ≤ 0 ⟹ ¦?a¦ = - ?a›*) inner_commute (*‹?x ∙ ?y = ?y ∙ ?x›*) neg_0_le_iff_le (*‹(0 ≤ - ?a) = (?a ≤ 0)›*))
(*discuss goal 2*)
apply (metis Basis_nonneg (*‹?i ∈ Basis ⟹ 0 ≤ ?i›*) abs_inner_Basis (*‹⟦¦?u¦ ∈ Basis; ¦?v¦ ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else if ?u = - ?v then - 1 else 0)›*) abs_of_nonneg (*‹0 ≤ ?a ⟹ ¦?a¦ = ?a›*) abs_of_nonpos (*‹?a ≤ 0 ⟹ ¦?a¦ = - ?a›*) neg_0_le_iff_le (*‹(0 ≤ - ?a) = (?a ≤ 0)›*))
(*discuss goal 3*)
apply (auto simp: inner_Basis (*‹⟦(?u::?'a::euclidean_space) ∈ Basis; (?v::?'a::euclidean_space) ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1::real else (0::real))›*))
(*proven 3 subgoals*)
(*proven 2 subgoals*) .
lemma project_coord_on_plane:
assumes "x ∈ plane_of (Sctn n c)"
shows "project_coord x n c = x"
using assms (*‹x ∈ plane_of (Sctn n c)›*) by (auto simp: project_coord_def (*‹project_coord ?x ?b ?n = (∑i←Basis_list. (if i = ?b then ?n else if i = - ?b then - ?n else ?x ∙ i) *⇩R i)›*) plane_of_def (*‹plane_of ?sctn = plane (normal ?sctn) (pstn ?sctn)›*) intro!: euclidean_eqI[where 'a='a] (*‹(⋀b. b ∈ Basis ⟹ ?x ∙ b = ?y ∙ b) ⟹ ?x = ?y›*))
lemma
mem_Affine_project_coord_aformI:
assumes "x ∈ Affine X"
assumes "x ∈ plane_of sctn"
shows "x ∈ Affine (project_coord_aform sctn X)"
proof (-)
(*goal: ‹x ∈ Affine (project_coord_aform sctn X)›*)
have "x = project_coord x (normal sctn) (pstn sctn)"
using assms (*‹x ∈ Affine X› ‹x ∈ plane_of sctn›*) apply (intro project_coord_on_plane[symmetric] (*‹(?t::?'a::executable_euclidean_space) ∈ plane_of (Sctn (?n::?'a::executable_euclidean_space) (?c::real)) ⟹ ?t = project_coord ?t ?n ?c›*))
(*goal: ‹x = project_coord x (normal sctn) (pstn sctn)›*)
by auto
also (*calculation: ‹x = project_coord x (normal sctn) (pstn sctn)›*) from assms (*‹x ∈ Affine X› ‹x ∈ plane_of sctn›*) obtain e where "e ∈ funcset UNIV {-1 .. 1}" "x = aform_val e X"
(*goal: ‹(⋀e. ⟦e ∈ funcset UNIV {- 1..1}; x = aform_val e X⟧ ⟹ thesis) ⟹ thesis›*)
by (auto simp: Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*))
note this(2) (*‹x = aform_val e X›*)
also (*calculation: ‹aform_val e X = project_coord (aform_val e X) (normal sctn) (pstn sctn)›*) have "project_coord (aform_val e X) (normal sctn) (pstn sctn) =
aform_val e (project_coord_aform sctn X)"
by (simp add: aform_val_project_coord_aform (*‹aform_val (?e::nat ⇒ real) (project_coord_aform (?sctn::?'a sctn) (?X::?'a × ?'a pdevs)) = project_coord (aform_val ?e ?X) (normal ?sctn) (pstn ?sctn)›*))
finally (*calculation: ‹aform_val (e::nat ⇒ real) (X::'a::executable_euclidean_space × 'a::executable_euclidean_space pdevs) = aform_val e (project_coord_aform (sctn::'a::executable_euclidean_space sctn) X)›*) have "x = aform_val e (project_coord_aform sctn X)"
unfolding ‹x = aform_val e X›
(*goal: ‹aform_val e X = aform_val e (project_coord_aform sctn X)›*) .
then show "?thesis"
(*goal: ‹x ∈ Affine (project_coord_aform sctn X)›*)
using ‹e ∈ _› (*‹e ∈ funcset UNIV {- 1..1}›*) by (auto simp: Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*))
qed
lemma
mem_Affine_project_coord_aformD:
assumes "x ∈ Affine (project_coord_aform sctn X)"
assumes "abs (normal sctn) ∈ Basis"
shows "x ∈ plane_of sctn"
using assms (*‹x ∈ Affine (project_coord_aform sctn X)› ‹¦normal sctn¦ ∈ Basis›*) by (auto simp: Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) aform_val_project_coord_aform (*‹aform_val ?e (project_coord_aform ?sctn ?X) = project_coord (aform_val ?e ?X) (normal ?sctn) (pstn ?sctn)›*) plane_of_def (*‹plane_of ?sctn = plane (normal ?sctn) (pstn ?sctn)›*) project_coord_inner (*‹¦?i¦ ∈ Basis ⟹ project_coord ?x ?b ?n ∙ ?i = (if ?i = ?b then ?n else if ?i = - ?b then - ?n else ?x ∙ ?i)›*))
definition "reduce_aform prec t X =
summarize_aforms (prec) (collect_threshold (prec) 0 t) (degree_aforms X) X"
definition "correct_girard p m N (X::real aform list) =
(let
Xs = map snd X;
M = pdevs_mapping Xs;
D = domain_pdevs Xs;
diff = m - card D
in if 0 < diff then (λ_ _. True) else
let
Ds = sorted_list_of_set D;
ortho_indices = map fst (take (diff + N) (sort_key (λ(i, r). r) (map (λi. let xs = M i in (i, sum_list' p (map abs xs) - fold max (map abs xs) 0)) Ds)));
_ = ()
in (λi (xs::real list). i ∉ set ortho_indices))"
definition "reduce_aforms prec C X = summarize_aforms (prec) C (degree_aforms X) X"
definition "pdevs_of_real x = (x, zero_pdevs)"
definition aform_inf_inner where "aform_inf_inner prec X n =
(case inner_aforms' (prec) X (map pdevs_of_real n) of
Some Xn ⇒ Inf_aform' (prec) (hd Xn))"
definition aform_sup_inner where "aform_sup_inner prec X n =
(case inner_aforms' (prec) X (map pdevs_of_real n) of
Some Xn ⇒ Sup_aform' (prec) (hd Xn))"
text ‹cannot fail›
lemma approx_un_ne_None: "approx_un p (λivl. Some (f ivl)) (Some r) ≠ None"
by (auto simp: approx_un_def (*‹approx_un ?p ?f ?a = ?a ⤜ (λrd. ?f (ivl_of_aform_err ?p rd) ⤜ (λivl. Some (ivl_err (real_interval ivl))))›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*))
lemma approx_un_eq_Some:
"approx_un p (λivl. Some (f ivl)) (Some r) = Some s ⟷
s = ivl_err (real_interval (f (ivl_of_aform_err p r)))"
using approx_un_ne_None (*‹approx_un ?p (λivl. Some (?f ivl)) (Some ?r) ≠ None›*) by (auto simp: approx_un_def (*‹approx_un (?p::nat) (?f::float interval ⇒ float interval option) (?a::((real × real pdevs) × real) option) = ?a ⤜ (λrd::(real × real pdevs) × real. ?f (ivl_of_aform_err ?p rd) ⤜ (λivl::float interval. Some (ivl_err (real_interval ivl))))›*) split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*))
lemma is_float_uminus:
"is_float aa ⟹ is_float (- aa)"
by (auto simp: is_float_def (*‹is_float ?r = (?r ∈ float)›*))
lemma is_float_uminus_iff[simp]:
"is_float (- aa) = is_float aa"
using is_float_uminus[of aa] (*‹is_float aa ⟹ is_float (- aa)›*) is_float_uminus[of "-aa"] (*‹is_float (- aa) ⟹ is_float (- (- aa))›*) by (auto simp: is_float_def (*‹is_float ?r = (?r ∈ float)›*))
lemma is_float_simps[simp]:
"is_float 0"
"is_float 1"
"is_float (real_of_float x)"
"is_float (truncate_down p X)"
"is_float (truncate_up p X)"
"is_float (eucl_truncate_down p X)"
"is_float (eucl_truncate_up p X)"
(*goals:
1. ‹is_float 0›
2. ‹is_float 1›
3. ‹is_float (real_of_float x)›
4. ‹is_float (truncate_down p X)›
5. ‹is_float (truncate_up p X)›
6. ‹is_float (eucl_truncate_down p X)›
7. ‹is_float (eucl_truncate_up p X)›
discuss goal 1*)
apply ((auto simp: is_float_def (*‹is_float ?r = (?r ∈ float)›*) eucl_truncate_down_def (*‹eucl_truncate_down ?q ?b = (∑i∈Basis. truncate_down ?q (?b ∙ i) *⇩R i)›*) eucl_truncate_up_def (*‹eucl_truncate_up ?q ?b = (∑i∈Basis. truncate_up ?q (?b ∙ i) *⇩R i)›*) truncate_down_def (*‹truncate_down ?prec ?x = round_down (int ?prec - ⌊log 2 ¦?x¦⌋) ?x›*) truncate_up_def (*‹truncate_up ?prec ?x = round_up (int ?prec - ⌊log 2 ¦?x¦⌋) ?x›*))[1])
(*discuss goal 2*)
apply ((auto simp: is_float_def (*‹is_float (?r::real) = (?r ∈ float)›*) eucl_truncate_down_def (*‹eucl_truncate_down (?q::nat) (?b::?'a) = (∑i::?'a∈Basis. truncate_down ?q (?b ∙ i) *⇩R i)›*) eucl_truncate_up_def (*‹eucl_truncate_up (?q::nat) (?b::?'a) = (∑i::?'a∈Basis. truncate_up ?q (?b ∙ i) *⇩R i)›*) truncate_down_def (*‹truncate_down (?prec::nat) (?x::real) = round_down (int ?prec - ⌊log (2::real) ¦?x¦⌋) ?x›*) truncate_up_def (*‹truncate_up (?prec::nat) (?x::real) = round_up (int ?prec - ⌊log (2::real) ¦?x¦⌋) ?x›*))[1])
(*discuss goal 3*)
apply ((auto simp: is_float_def (*‹is_float (?r::real) = (?r ∈ float)›*) eucl_truncate_down_def (*‹eucl_truncate_down (?q::nat) (?b::?'a) = (∑i::?'a∈Basis. truncate_down ?q (?b ∙ i) *⇩R i)›*) eucl_truncate_up_def (*‹eucl_truncate_up (?q::nat) (?b::?'a) = (∑i::?'a∈Basis. truncate_up ?q (?b ∙ i) *⇩R i)›*) truncate_down_def (*‹truncate_down (?prec::nat) (?x::real) = round_down (int ?prec - ⌊log (2::real) ¦?x¦⌋) ?x›*) truncate_up_def (*‹truncate_up (?prec::nat) (?x::real) = round_up (int ?prec - ⌊log (2::real) ¦?x¦⌋) ?x›*))[1])
(*discuss goal 4*)
apply ((auto simp: is_float_def (*‹is_float ?r = (?r ∈ float)›*) eucl_truncate_down_def (*‹eucl_truncate_down ?q ?b = (∑i∈Basis. truncate_down ?q (?b ∙ i) *⇩R i)›*) eucl_truncate_up_def (*‹eucl_truncate_up ?q ?b = (∑i∈Basis. truncate_up ?q (?b ∙ i) *⇩R i)›*) truncate_down_def (*‹truncate_down ?prec ?x = round_down (int ?prec - ⌊log 2 ¦?x¦⌋) ?x›*) truncate_up_def (*‹truncate_up ?prec ?x = round_up (int ?prec - ⌊log 2 ¦?x¦⌋) ?x›*))[1])
(*discuss goal 5*)
apply ((auto simp: is_float_def (*‹is_float ?r = (?r ∈ float)›*) eucl_truncate_down_def (*‹eucl_truncate_down ?q ?b = (∑i∈Basis. truncate_down ?q (?b ∙ i) *⇩R i)›*) eucl_truncate_up_def (*‹eucl_truncate_up ?q ?b = (∑i∈Basis. truncate_up ?q (?b ∙ i) *⇩R i)›*) truncate_down_def (*‹truncate_down ?prec ?x = round_down (int ?prec - ⌊log 2 ¦?x¦⌋) ?x›*) truncate_up_def (*‹truncate_up ?prec ?x = round_up (int ?prec - ⌊log 2 ¦?x¦⌋) ?x›*))[1])
(*discuss goal 6*)
apply ((auto simp: is_float_def (*‹is_float ?r = (?r ∈ float)›*) eucl_truncate_down_def (*‹eucl_truncate_down ?q ?b = (∑i∈Basis. truncate_down ?q (?b ∙ i) *⇩R i)›*) eucl_truncate_up_def (*‹eucl_truncate_up ?q ?b = (∑i∈Basis. truncate_up ?q (?b ∙ i) *⇩R i)›*) truncate_down_def (*‹truncate_down ?prec ?x = round_down (int ?prec - ⌊log 2 ¦?x¦⌋) ?x›*) truncate_up_def (*‹truncate_up ?prec ?x = round_up (int ?prec - ⌊log 2 ¦?x¦⌋) ?x›*))[1])
(*discuss goal 7*)
apply ((auto simp: is_float_def (*‹is_float ?r = (?r ∈ float)›*) eucl_truncate_down_def (*‹eucl_truncate_down ?q ?b = (∑i∈Basis. truncate_down ?q (?b ∙ i) *⇩R i)›*) eucl_truncate_up_def (*‹eucl_truncate_up ?q ?b = (∑i∈Basis. truncate_up ?q (?b ∙ i) *⇩R i)›*) truncate_down_def (*‹truncate_down ?prec ?x = round_down (int ?prec - ⌊log 2 ¦?x¦⌋) ?x›*) truncate_up_def (*‹truncate_up ?prec ?x = round_up (int ?prec - ⌊log 2 ¦?x¦⌋) ?x›*))[1])
(*proven 7 subgoals*) .
lemma is_float_sum_list'[simp]:
"is_float (sum_list' p xs)"
apply (induction xs)
(*goals:
1. ‹is_float (sum_list' p [])›
2. ‹⋀a xs. is_float (sum_list' p xs) ⟹ is_float (sum_list' p (a # xs))›
discuss goal 1*)
apply ((auto simp: is_float_def (*‹is_float ?r = (?r ∈ float)›*))[1])
(*discuss goal 2*)
apply ((auto simp: is_float_def (*‹is_float ?r = (?r ∈ float)›*))[1])
(*proven 2 subgoals*) .
lemma is_float_inverse_aform': "is_float (fst (fst (inverse_aform' p X)))"
unfolding inverse_aform'_def
(*goal: ‹is_float (fst (fst (let l = Inf_aform' p X; u = Sup_aform' p X; a = min ¦l¦ ¦u¦; b = max ¦l¦ ¦u¦; sq = truncate_up p (b * b); alpha = - real_divl p 1 sq; dmax = truncate_up p (real_divr p 1 a - alpha * a); dmin = truncate_down p (real_divl p 1 b - alpha * b); zeta' = truncate_up p ((dmin + dmax) / 2); zeta = if l < 0 then - zeta' else zeta'; delta = truncate_up p (zeta - dmin); res1 = trunc_bound_eucl p (alpha * fst X); res2 = trunc_bound_eucl p (fst res1 + zeta); zs = trunc_bound_pdevs p (scaleR_pdevs alpha (snd X)) in ((fst res2, fst zs), sum_list' p [delta, snd res1, snd res2, snd zs]))))›*)
by (msorry)
lemma is_float_min_range:
"min_range_antimono p F D E X Y = Some ((a, b), c) ⟹ is_float a"
"min_range_antimono p F D E X Y = Some ((a, b), c) ⟹ is_float c"
"min_range_mono p F D E X Y = Some ((a, b), c) ⟹ is_float a"
"min_range_mono p F D E X Y = Some ((a, b), c) ⟹ is_float c"
(*goals:
1. ‹min_range_antimono p F D E X Y = Some ((a, b), c) ⟹ is_float a›
2. ‹min_range_antimono p F D E X Y = Some ((a, b), c) ⟹ is_float c›
3. ‹min_range_mono p F D E X Y = Some ((a, b), c) ⟹ is_float a›
4. ‹min_range_mono p F D E X Y = Some ((a, b), c) ⟹ is_float c›
discuss goal 1*)
apply ((auto simp: min_range_antimono_def (*‹min_range_antimono ?p ?F ?DF ?l ?u ?X = (let L = floatarith.Num ?l; U = floatarith.Num ?u in approx ?p (floatarith.Max (?DF L) (?DF U)) [] ⤜ (λaivl. let a = upper aivl; A = floatarith.Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl. let (b, be) = mid_err bivl; (B, Be) = (floatarith.Num (float_of b), floatarith.Num (float_of be)) in approx ?p (floatarith.Add (Half (?F L - ?F U + A * (U - L))) Be) [] ⤜ (λdivl. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) min_range_mono_def (*‹min_range_mono ?p ?F ?DF ?l ?u ?X = (let L = floatarith.Num ?l; U = floatarith.Num ?u in approx ?p (floatarith.Min (?DF L) (?DF U)) [] ⤜ (λaivl. let a = lower aivl; A = floatarith.Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl. let (b, be) = mid_err bivl; (B, Be) = (floatarith.Num (float_of b), floatarith.Num (float_of be)) in approx ?p (Half (?F U - ?F L - A * (U - L)) + Be) [] ⤜ (λdivl. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) trunc_bound_eucl_def (*‹trunc_bound_eucl ?p ?s = (let d = eucl_truncate_down ?p ?s; ed = ¦d - ?s¦ in (d, eucl_truncate_up ?p ed))›*) mid_err_def (*‹mid_err ?ivl = (real_of_float (lower ?ivl + upper ?ivl) / 2, real_of_float (upper ?ivl - lower ?ivl) / 2)›*) affine_unop_def (*‹affine_unop ?p ?a ?b ?d ?X = (let ((x, xs), xe) = ?X; (ax, axe) = trunc_bound_eucl ?p (?a * x); (y, ye) = trunc_bound_eucl ?p (ax + ?b); (ys, yse) = trunc_bound_pdevs ?p (scaleR_pdevs ?a xs) in ((y, ys), sum_list' ?p [truncate_up ?p (¦?a¦ * xe), axe, ye, yse, ?d]))›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1])
(*discuss goal 2*)
apply ((auto simp: min_range_antimono_def (*‹min_range_antimono ?p ?F ?DF ?l ?u ?X = (let L = floatarith.Num ?l; U = floatarith.Num ?u in approx ?p (floatarith.Max (?DF L) (?DF U)) [] ⤜ (λaivl. let a = upper aivl; A = floatarith.Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl. let (b, be) = mid_err bivl; (B, Be) = (floatarith.Num (float_of b), floatarith.Num (float_of be)) in approx ?p (floatarith.Add (Half (?F L - ?F U + A * (U - L))) Be) [] ⤜ (λdivl. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) min_range_mono_def (*‹min_range_mono ?p ?F ?DF ?l ?u ?X = (let L = floatarith.Num ?l; U = floatarith.Num ?u in approx ?p (floatarith.Min (?DF L) (?DF U)) [] ⤜ (λaivl. let a = lower aivl; A = floatarith.Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl. let (b, be) = mid_err bivl; (B, Be) = (floatarith.Num (float_of b), floatarith.Num (float_of be)) in approx ?p (Half (?F U - ?F L - A * (U - L)) + Be) [] ⤜ (λdivl. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) trunc_bound_eucl_def (*‹trunc_bound_eucl ?p ?s = (let d = eucl_truncate_down ?p ?s; ed = ¦d - ?s¦ in (d, eucl_truncate_up ?p ed))›*) mid_err_def (*‹mid_err ?ivl = (real_of_float (lower ?ivl + upper ?ivl) / 2, real_of_float (upper ?ivl - lower ?ivl) / 2)›*) affine_unop_def (*‹affine_unop ?p ?a ?b ?d ?X = (let ((x, xs), xe) = ?X; (ax, axe) = trunc_bound_eucl ?p (?a * x); (y, ye) = trunc_bound_eucl ?p (ax + ?b); (ys, yse) = trunc_bound_pdevs ?p (scaleR_pdevs ?a xs) in ((y, ys), sum_list' ?p [truncate_up ?p (¦?a¦ * xe), axe, ye, yse, ?d]))›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1])
(*discuss goal 3*)
apply ((auto simp: min_range_antimono_def (*‹min_range_antimono ?p ?F ?DF ?l ?u ?X = (let L = floatarith.Num ?l; U = floatarith.Num ?u in approx ?p (floatarith.Max (?DF L) (?DF U)) [] ⤜ (λaivl. let a = upper aivl; A = floatarith.Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl. let (b, be) = mid_err bivl; (B, Be) = (floatarith.Num (float_of b), floatarith.Num (float_of be)) in approx ?p (floatarith.Add (Half (?F L - ?F U + A * (U - L))) Be) [] ⤜ (λdivl. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) min_range_mono_def (*‹min_range_mono ?p ?F ?DF ?l ?u ?X = (let L = floatarith.Num ?l; U = floatarith.Num ?u in approx ?p (floatarith.Min (?DF L) (?DF U)) [] ⤜ (λaivl. let a = lower aivl; A = floatarith.Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl. let (b, be) = mid_err bivl; (B, Be) = (floatarith.Num (float_of b), floatarith.Num (float_of be)) in approx ?p (Half (?F U - ?F L - A * (U - L)) + Be) [] ⤜ (λdivl. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) trunc_bound_eucl_def (*‹trunc_bound_eucl ?p ?s = (let d = eucl_truncate_down ?p ?s; ed = ¦d - ?s¦ in (d, eucl_truncate_up ?p ed))›*) mid_err_def (*‹mid_err ?ivl = (real_of_float (lower ?ivl + upper ?ivl) / 2, real_of_float (upper ?ivl - lower ?ivl) / 2)›*) affine_unop_def (*‹affine_unop ?p ?a ?b ?d ?X = (let ((x, xs), xe) = ?X; (ax, axe) = trunc_bound_eucl ?p (?a * x); (y, ye) = trunc_bound_eucl ?p (ax + ?b); (ys, yse) = trunc_bound_pdevs ?p (scaleR_pdevs ?a xs) in ((y, ys), sum_list' ?p [truncate_up ?p (¦?a¦ * xe), axe, ye, yse, ?d]))›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1])
(*discuss goal 4*)
apply ((auto simp: min_range_antimono_def (*‹min_range_antimono (?p::nat) (?F::floatarith ⇒ floatarith) (?DF::floatarith ⇒ floatarith) (?l::float) (?u::float) (?X::(real × real pdevs) × real) = (let L::floatarith = floatarith.Num ?l; U::floatarith = floatarith.Num ?u in approx ?p (floatarith.Max (?DF L) (?DF U)) [] ⤜ (λaivl::float interval. let a::float = upper aivl; A::floatarith = floatarith.Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl::float interval. let (b::real, be::real) = mid_err bivl; (B::floatarith, Be::floatarith) = (floatarith.Num (float_of b), floatarith.Num (float_of be)) in approx ?p (floatarith.Add (Half (?F L - ?F U + A * (U - L))) Be) [] ⤜ (λdivl::float interval. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) min_range_mono_def (*‹min_range_mono (?p::nat) (?F::floatarith ⇒ floatarith) (?DF::floatarith ⇒ floatarith) (?l::float) (?u::float) (?X::(real × real pdevs) × real) = (let L::floatarith = floatarith.Num ?l; U::floatarith = floatarith.Num ?u in approx ?p (floatarith.Min (?DF L) (?DF U)) [] ⤜ (λaivl::float interval. let a::float = lower aivl; A::floatarith = floatarith.Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl::float interval. let (b::real, be::real) = mid_err bivl; (B::floatarith, Be::floatarith) = (floatarith.Num (float_of b), floatarith.Num (float_of be)) in approx ?p (Half (?F U - ?F L - A * (U - L)) + Be) [] ⤜ (λdivl::float interval. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*) bind_eq_Some_conv (*‹((?f::?'b::type option) ⤜ (?g::?'b::type ⇒ ?'a::type option) = Some (?x::?'a::type)) = (∃y::?'b::type. ?f = Some y ∧ ?g y = Some ?x)›*) prod_eq_iff (*‹((?s::?'a::type × ?'b::type) = (?t::?'a::type × ?'b::type)) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) trunc_bound_eucl_def (*‹trunc_bound_eucl (?p::nat) (?s::?'a::executable_euclidean_space) = (let d::?'a::executable_euclidean_space = eucl_truncate_down ?p ?s; ed::?'a::executable_euclidean_space = ¦d - ?s¦ in (d, eucl_truncate_up ?p ed))›*) mid_err_def (*‹mid_err (?ivl::float interval) = (real_of_float (lower ?ivl + upper ?ivl) / (2::real), real_of_float (upper ?ivl - lower ?ivl) / (2::real))›*) affine_unop_def (*‹affine_unop (?p::nat) (?a::real) (?b::real) (?d::real) (?X::(real × real pdevs) × real) = (let ((x::real, xs::real pdevs), xe::real) = ?X; (ax::real, axe::real) = trunc_bound_eucl ?p (?a * x); (y::real, ye::real) = trunc_bound_eucl ?p (ax + ?b); (ys::real pdevs, yse::real) = trunc_bound_pdevs ?p (scaleR_pdevs ?a xs) in ((y, ys), sum_list' ?p [truncate_up ?p (¦?a¦ * xe), axe, ye, yse, ?d]))›*) split: prod.splits (*‹(?P::?'c::type ⇒ bool) (case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = (∀(x1::?'a::type) x2::?'b::type. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c::type ⇒ bool) (case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = (∄(x1::?'a::type) x2::?'b::type. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1])
(*proven 4 subgoals*) .
lemma is_float_ivl_err:
assumes "ivl_err x = ((a, b), c)" "is_float (lower x)" "is_float (upper x)"
shows "is_float a" "is_float c"
proof (-)
(*goals:
1. ‹is_float a›
2. ‹is_float c›*)
define x1 where "x1 = lower x"
define x2 where "x2 = upper x"
have "a = (x1 + x2) / 2" "c = (x2 - x1) / 2"
using assms (*‹ivl_err x = ((a, b), c)› ‹is_float (lower x)› ‹is_float (upper x)›*) apply -
(*goals:
1. ‹⟦ivl_err (x::real interval) = ((a::real, b::real pdevs), c::real); is_float (lower x); is_float (upper x)⟧ ⟹ a = ((x1::real) + (x2::real)) / (2::real)›
2. ‹⟦ivl_err (x::real interval) = ((a::real, b::real pdevs), c::real); is_float (lower x); is_float (upper x)⟧ ⟹ c = ((x2::real) - (x1::real)) / (2::real)›
discuss goal 1*)
apply ((auto simp: ivl_err_def (*‹ivl_err ?ivl ≡ (((upper ?ivl + lower ?ivl) / 2, zero_pdevs), (upper ?ivl - lower ?ivl) / 2)›*) x1_def (*‹x1 = lower x›*) x2_def (*‹x2 = upper x›*))[1])
(*discuss goal 2*)
apply ((auto simp: ivl_err_def (*‹ivl_err ?ivl ≡ (((upper ?ivl + lower ?ivl) / 2, zero_pdevs), (upper ?ivl - lower ?ivl) / 2)›*) x1_def (*‹x1 = lower x›*) x2_def (*‹x2 = upper x›*))[1])
(*proven 2 subgoals*) .
moreover have "(x1 + x2) / 2 ∈ float" "(x2 - x1) / 2 ∈ float"
using assms (*‹ivl_err x = ((a, b), c)› ‹is_float (lower x)› ‹is_float (upper x)›*) apply -
(*goals:
1. ‹⟦ivl_err x = ((a, b), c); is_float (lower x); is_float (upper x)⟧ ⟹ (x1 + x2) / 2 ∈ float›
2. ‹⟦ivl_err x = ((a, b), c); is_float (lower x); is_float (upper x)⟧ ⟹ (x2 - x1) / 2 ∈ float›
discuss goal 1*)
apply ((auto simp: is_float_def (*‹is_float ?r = (?r ∈ float)›*) x1_def (*‹x1 = lower x›*) x2_def (*‹x2 = upper x›*))[1])
(*discuss goal 2*)
apply ((auto simp: is_float_def (*‹is_float ?r = (?r ∈ float)›*) x1_def (*‹x1 = lower x›*) x2_def (*‹x2 = upper x›*))[1])
(*proven 2 subgoals*) .
ultimately show "is_float a" "is_float c"
unfolding is_float_def
(*goals:
1. ‹(a::real) ∈ float›
2. ‹(c::real) ∈ float›*)
apply -
(*goals:
1. ‹⟦a = (x1 + x2) / 2; c = (x2 - x1) / 2; (x1 + x2) / 2 ∈ float; (x2 - x1) / 2 ∈ float⟧ ⟹ a ∈ float›
2. ‹⟦a = (x1 + x2) / 2; c = (x2 - x1) / 2; (x1 + x2) / 2 ∈ float; (x2 - x1) / 2 ∈ float⟧ ⟹ c ∈ float›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
qed
lemma is_float_trunc_bound_eucl[simp]:
"is_float (fst (trunc_bound_eucl p X))"
by (auto simp: trunc_bound_eucl_def (*‹trunc_bound_eucl ?p ?s = (let d = eucl_truncate_down ?p ?s; ed = ¦d - ?s¦ in (d, eucl_truncate_up ?p ed))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*))
lemma add_eq_times_2_in_float: "a + b = c * 2 ⟹ is_float a ⟹ is_float b ⟹ is_float c"
proof (goal_cases)
(*goal: ‹⟦a + b = c * 2; is_float a; is_float b⟧ ⟹ is_float c›*)
case 1 (*‹a + b = c * 2› ‹is_float a› ‹is_float b›*)
then have "c = (a + b) / 2"
by simp
also (*calculation: ‹c = (a + b) / 2›*) have "… ∈ float"
using "1"(3,2) (*‹is_float (b::real)› ‹is_float a›*) by (simp add: is_float_def (*‹is_float ?r = (?r ∈ float)›*))
finally (*calculation: ‹c ∈ float›*) show "?case"
(*goal: ‹is_float c›*)
by (simp add: is_float_def (*‹is_float ?r = (?r ∈ float)›*))
qed
lemma approx_floatarith_Some_is_float:
"approx_floatarith p fa XS = Some ((a, b), ba) ⟹
list_all (λ((a, b), c). is_float a ∧ is_float c) XS ⟹
is_float a ∧ is_float ba"
apply (induction fa arbitrary: a b ba)
subgoal by (auto simp: bind_eq_Some_conv add_aform'_def Let_def )
subgoal by (auto simp: bind_eq_Some_conv uminus_aform_def Let_def)
subgoal by (auto simp: bind_eq_Some_conv mult_aform'_def Let_def )
subgoal by (auto simp: bind_eq_Some_conv inverse_aform_err_def map_aform_err_def
prod_eq_iff is_float_inverse_aform'
acc_err_def aform_to_aform_err_def aform_err_to_aform_def inverse_aform_def
Let_def split: if_splits)
subgoal by (auto simp: bind_eq_Some_conv cos_aform_err_def Let_def is_float_min_range
is_float_ivl_err
split: if_splits prod.splits)
subgoal by (auto simp: bind_eq_Some_conv arctan_aform_err_def Let_def is_float_min_range
is_float_ivl_err
split: if_splits prod.splits)
subgoal apply (auto simp: bind_eq_Some_conv uminus_aform_def Let_def is_float_min_range
is_float_ivl_err set_of_eq real_interval_abs
split: if_splits prod.splits)
apply (metis is_float_ivl_err(1) is_float_simps(3) lower_real_interval real_interval_abs upper_real_interval)
by (metis is_float_ivl_err(2) is_float_simps(3) lower_real_interval real_interval_abs upper_real_interval)
subgoal by (auto simp: bind_eq_Some_conv max_aform_err_def Let_def is_float_min_range
is_float_ivl_err max_def
split: if_splits prod.splits)
subgoal by (auto simp: bind_eq_Some_conv min_aform_err_def Let_def is_float_min_range
is_float_ivl_err min_def
split: if_splits prod.splits)
subgoal by (auto simp: bind_eq_Some_conv arctan_aform_err_def Let_def is_float_min_range
is_float_ivl_err
split: if_splits prod.splits)
subgoal by (auto simp: bind_eq_Some_conv sqrt_aform_err_def Let_def is_float_min_range
is_float_ivl_err
split: if_splits prod.splits)
subgoal by (auto simp: bind_eq_Some_conv exp_aform_err_def Let_def is_float_min_range
is_float_ivl_err
split: if_splits prod.splits)
subgoal by (auto simp: bind_eq_Some_conv powr_aform_err_def approx_bin_def
exp_aform_err_def Let_def is_float_min_range
is_float_ivl_err mult_aform'_def
split: if_splits prod.splits)
subgoal by (auto simp: bind_eq_Some_conv ln_aform_err_def Let_def is_float_min_range
is_float_ivl_err
split: if_splits prod.splits)
subgoal by (auto simp: bind_eq_Some_conv power_aform_err_def Let_def is_float_min_range
is_float_ivl_err mid_err_def dest!: add_eq_times_2_in_float
split: if_splits prod.splits)
subgoal by (auto simp: bind_eq_Some_conv cos_aform_err_def Let_def is_float_min_range
approx_un_def is_float_ivl_err
split: if_splits)
subgoal by (auto simp: bind_eq_Some_conv cos_aform_err_def Let_def is_float_min_range
list_all_length
split: if_splits)
subgoal by (auto simp: bind_eq_Some_conv num_aform_def Let_def)
done
lemma plain_floatarith_not_None:
assumes "plain_floatarith N fa" "N ≤ length XS"
"list_all (λ((a, b), c). is_float a ∧ is_float c) XS"
shows "approx_floatarith p fa XS ≠ None"
using assms (*‹plain_floatarith N fa› ‹N ≤ length XS› ‹list_all (λ((a, b), c). is_float a ∧ is_float c) XS›*) apply (induction fa)
(*goals:
1. ‹⋀(fa1::floatarith) fa2::floatarith. ⟦⟦plain_floatarith (N::nat) fa1; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa1 XS ≠ None; ⟦plain_floatarith N fa2; N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p fa2 XS ≠ None; plain_floatarith N (floatarith.Add fa1 fa2); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (floatarith.Add fa1 fa2) XS ≠ None›
2. ‹⋀fa::floatarith. ⟦⟦plain_floatarith (N::nat) fa; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa XS ≠ None; plain_floatarith N (floatarith.Minus fa); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (floatarith.Minus fa) XS ≠ None›
3. ‹⋀(fa1::floatarith) fa2::floatarith. ⟦⟦plain_floatarith (N::nat) fa1; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa1 XS ≠ None; ⟦plain_floatarith N fa2; N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p fa2 XS ≠ None; plain_floatarith N (floatarith.Mult fa1 fa2); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (floatarith.Mult fa1 fa2) XS ≠ None›
4. ‹⋀fa::floatarith. ⟦⟦plain_floatarith (N::nat) fa; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa XS ≠ None; plain_floatarith N (floatarith.Inverse fa); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (floatarith.Inverse fa) XS ≠ None›
5. ‹⋀fa::floatarith. ⟦⟦plain_floatarith (N::nat) fa; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa XS ≠ None; plain_floatarith N (floatarith.Cos fa); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (floatarith.Cos fa) XS ≠ None›
6. ‹⋀fa::floatarith. ⟦⟦plain_floatarith (N::nat) fa; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa XS ≠ None; plain_floatarith N (floatarith.Arctan fa); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (floatarith.Arctan fa) XS ≠ None›
7. ‹⋀fa::floatarith. ⟦⟦plain_floatarith (N::nat) fa; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa XS ≠ None; plain_floatarith N (floatarith.Abs fa); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (floatarith.Abs fa) XS ≠ None›
8. ‹⋀(fa1::floatarith) fa2::floatarith. ⟦⟦plain_floatarith (N::nat) fa1; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa1 XS ≠ None; ⟦plain_floatarith N fa2; N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p fa2 XS ≠ None; plain_floatarith N (floatarith.Max fa1 fa2); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (floatarith.Max fa1 fa2) XS ≠ None›
9. ‹⋀(fa1::floatarith) fa2::floatarith. ⟦⟦plain_floatarith (N::nat) fa1; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa1 XS ≠ None; ⟦plain_floatarith N fa2; N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p fa2 XS ≠ None; plain_floatarith N (floatarith.Min fa1 fa2); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (floatarith.Min fa1 fa2) XS ≠ None›
10. ‹⟦plain_floatarith (N::nat) floatarith.Pi; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) floatarith.Pi XS ≠ None›
11. ‹⋀fa::floatarith. ⟦⟦plain_floatarith (N::nat) fa; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa XS ≠ None; plain_floatarith N (floatarith.Sqrt fa); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (floatarith.Sqrt fa) XS ≠ None›
12. ‹⋀fa::floatarith. ⟦⟦plain_floatarith (N::nat) fa; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa XS ≠ None; plain_floatarith N (floatarith.Exp fa); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (floatarith.Exp fa) XS ≠ None›
13. ‹⋀(fa1::floatarith) fa2::floatarith. ⟦⟦plain_floatarith (N::nat) fa1; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa1 XS ≠ None; ⟦plain_floatarith N fa2; N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p fa2 XS ≠ None; plain_floatarith N (floatarith.Powr fa1 fa2); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (floatarith.Powr fa1 fa2) XS ≠ None›
14. ‹⋀fa::floatarith. ⟦⟦plain_floatarith (N::nat) fa; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa XS ≠ None; plain_floatarith N (floatarith.Ln fa); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (floatarith.Ln fa) XS ≠ None›
15. ‹⋀(fa::floatarith) x2a::nat. ⟦⟦plain_floatarith (N::nat) fa; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa XS ≠ None; plain_floatarith N (fa ^⇩e x2a); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (fa ^⇩e x2a) XS ≠ None›
16. ‹⋀fa::floatarith. ⟦⟦plain_floatarith (N::nat) fa; N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) fa XS ≠ None; plain_floatarith N (floatarith.Floor fa); N ≤ length XS; list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p (floatarith.Floor fa) XS ≠ None›
17. ‹⋀x::nat. ⟦plain_floatarith (N::nat) (floatarith.Var x); N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) (floatarith.Var x) XS ≠ None›
18. ‹⋀x::float. ⟦plain_floatarith (N::nat) (floatarith.Num x); N ≤ length (XS::((real × real pdevs) × real) list); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith (p::nat) (floatarith.Num x) XS ≠ None›
discuss goal 1*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 2*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 3*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 4*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 5*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 6*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 7*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 8*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 9*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 10*)
apply ((auto simp: Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un (?p::nat) (λivl::float interval. Some ((?f::float interval ⇒ float interval) ivl)) (Some (?r::(real × real pdevs) × real)) = Some (?s::(real × real pdevs) × real)) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹((?s::?'a × ?'b) = (?t::?'a × ?'b)) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith (?p::nat) (?fa::floatarith) (?XS::((real × real pdevs) × real) list) = Some ((?a::real, ?b::real pdevs), ?ba::real); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 11*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 12*)
apply ((auto simp: Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un (?p::nat) (λivl::float interval. Some ((?f::float interval ⇒ float interval) ivl)) (Some (?r::(real × real pdevs) × real)) = Some (?s::(real × real pdevs) × real)) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹((?s::?'a × ?'b) = (?t::?'a × ?'b)) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith (?p::nat) (?fa::floatarith) (?XS::((real × real pdevs) × real) list) = Some ((?a::real, ?b::real pdevs), ?ba::real); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 13*)
apply ((auto simp: Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un (?p::nat) (λivl::float interval. Some ((?f::float interval ⇒ float interval) ivl)) (Some (?r::(real × real pdevs) × real)) = Some (?s::(real × real pdevs) × real)) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹((?s::?'a × ?'b) = (?t::?'a × ?'b)) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith (?p::nat) (?fa::floatarith) (?XS::((real × real pdevs) × real) list) = Some ((?a::real, ?b::real pdevs), ?ba::real); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 14*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 15*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 16*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 17*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*discuss goal 18*)
apply ((auto simp: Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un (?p::nat) (λivl::float interval. Some ((?f::float interval ⇒ float interval) ivl)) (Some (?r::(real × real pdevs) × real)) = Some (?s::(real × real pdevs) × real)) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹((?s::?'a × ?'b) = (?t::?'a × ?'b)) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith (?p::nat) (?fa::floatarith) (?XS::((real × real pdevs) × real) list) = Some ((?a::real, ?b::real pdevs), ?ba::real); list_all (λ((a::real, b::real pdevs), c::real). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*))[1])
(*proven 18 subgoals*) .
lemma plain_floatarith_slp_not_None:
assumes "⋀fa. fa ∈ set fas ⟹ plain_floatarith N fa" "N ≤ length XS"
"list_all (λ((a, b), c). is_float a ∧ is_float c) XS"
shows "approx_slp p fas XS ≠ None"
using assms (*‹?fa ∈ set fas ⟹ plain_floatarith N ?fa› ‹N ≤ length XS› ‹list_all (λ((a, b), c). is_float a ∧ is_float c) XS›*) apply (induction fas arbitrary: XS)
(*goal: ‹approx_slp p fas XS ≠ None›*)
subgoal for
by simp
subgoal for fa and fas and XS
using plain_floatarith_not_None[of N fa XS p] (*‹⟦plain_floatarith N fa; N ≤ length XS; list_all (λ((a, b), c). is_float a ∧ is_float c) XS⟧ ⟹ approx_floatarith p fa XS ≠ None›*) by (auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) approx_un_eq_Some (*‹(approx_un ?p (λivl. Some (?f ivl)) (Some ?r) = Some ?s) = (?s = ivl_err (real_interval (?f (ivl_of_aform_err ?p ?r))))›*) prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) approx_floatarith_Some_is_float (*‹⟦approx_floatarith ?p ?fa ?XS = Some ((?a, ?b), ?ba); list_all (λ((a, b), c). is_float a ∧ is_float c) ?XS⟧ ⟹ is_float ?a ∧ is_float ?ba›*)) .
lemma plain_floatarithE:
assumes "plain_floatarith N fa" "N ≤ length XS"
"list_all (λ((a, b), c). is_float a ∧ is_float c) XS"
obtains R where "approx_floatarith p fa XS = Some R"
using plain_floatarith_not_None[OF assms] (*‹approx_floatarith ?p fa XS ≠ None›*) by force
lemma approx_slp_outer_eq_None_iff:
"approx_slp_outer p a b XS = None ⟷
approx_slp p b ((map (λx. (x, 0)) XS)) = None"
by (auto simp: approx_slp_outer_def (*‹approx_slp_outer ?p ?n ?slp ?XS = (let d = degree_aforms ?XS; XSe = map (λx. (x, 0)) ?XS in approx_slp ?p ?slp XSe ⤜ (λrs. let rs' = take ?n rs; d' = max d (degree_aforms_err rs') in Some (aforms_err_to_aforms d' rs')))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_None_conv (*‹(?a ⤜ ?f = None) = (?a = None ∨ ?f (the ?a) = None)›*))
lemma approx_slp_sing_eq_None_iff:
"approx_slp p [b] xs = None ⟷ approx_floatarith p b xs = None"
by (auto simp: approx_slp_outer_def (*‹approx_slp_outer ?p ?n ?slp ?XS = (let d = degree_aforms ?XS; XSe = map (λx. (x, 0)) ?XS in approx_slp ?p ?slp XSe ⤜ (λrs. let rs' = take ?n rs; d' = max d (degree_aforms_err rs') in Some (aforms_err_to_aforms d' rs')))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_None_conv (*‹(?a ⤜ ?f = None) = (?a = None ∨ ?f (the ?a) = None)›*))
lemma plain_inner_floatariths:
"plain_floatarith N (inner_floatariths xs ys)"
if "list_all (plain_floatarith N) xs" "list_all (plain_floatarith N) ys"
using that (*‹list_all (plain_floatarith N) xs› ‹list_all (plain_floatarith N) ys›*) apply (induction xs ys rule: inner_floatariths.induct (*‹⟦⋀uu_. ?P [] uu_; ⋀v va. ?P (v # va) []; ⋀x xs y ys. ?P xs ys ⟹ ?P (x # xs) (y # ys)⟧ ⟹ ?P ?a0.0 ?a1.0›*))
(*goals:
1. ‹⋀uu_. ⟦list_all (plain_floatarith N) []; list_all (plain_floatarith N) uu_⟧ ⟹ plain_floatarith N (inner_floatariths [] uu_)›
2. ‹⋀v va. ⟦list_all (plain_floatarith N) (v # va); list_all (plain_floatarith N) []⟧ ⟹ plain_floatarith N (inner_floatariths (v # va) [])›
3. ‹⋀x xs y ys. ⟦⟦list_all (plain_floatarith N) xs; list_all (plain_floatarith N) ys⟧ ⟹ plain_floatarith N (inner_floatariths xs ys); list_all (plain_floatarith N) (x # xs); list_all (plain_floatarith N) (y # ys)⟧ ⟹ plain_floatarith N (inner_floatariths (x # xs) (y # ys))›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
lemma aiN: "approx_floatarith p (inner_floatariths xs ys) zs ≠ None"
if "⋀x. x ∈ set xs ⟹ approx_floatarith p x zs ≠ None"
and "⋀x. x ∈ set ys ⟹ approx_floatarith p x zs ≠ None"
using that (*‹?x ∈ set xs ⟹ approx_floatarith p ?x zs ≠ None› ‹?x ∈ set ys ⟹ approx_floatarith p ?x zs ≠ None›*) apply (induction xs ys rule: inner_floatariths.induct (*‹⟦⋀uu_. ?P [] uu_; ⋀v va. ?P (v # va) []; ⋀x xs y ys. ?P xs ys ⟹ ?P (x # xs) (y # ys)⟧ ⟹ ?P ?a0.0 ?a1.0›*))
(*goals:
1. ‹⋀uu_. ⟦⋀x. x ∈ set [] ⟹ approx_floatarith p x zs ≠ None; ⋀x. x ∈ set uu_ ⟹ approx_floatarith p x zs ≠ None⟧ ⟹ approx_floatarith p (inner_floatariths [] uu_) zs ≠ None›
2. ‹⋀v va. ⟦⋀x. x ∈ set (v # va) ⟹ approx_floatarith p x zs ≠ None; ⋀x. x ∈ set [] ⟹ approx_floatarith p x zs ≠ None⟧ ⟹ approx_floatarith p (inner_floatariths (v # va) []) zs ≠ None›
3. ‹⋀x xs y ys. ⟦⟦⋀x. x ∈ set xs ⟹ approx_floatarith p x zs ≠ None; ⋀x. x ∈ set ys ⟹ approx_floatarith p x zs ≠ None⟧ ⟹ approx_floatarith p (inner_floatariths xs ys) zs ≠ None; ⋀xa. xa ∈ set (x # xs) ⟹ approx_floatarith p xa zs ≠ None; ⋀x. x ∈ set (y # ys) ⟹ approx_floatarith p x zs ≠ None⟧ ⟹ approx_floatarith p (inner_floatariths (x # xs) (y # ys)) zs ≠ None›
discuss goal 1*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*))[1])
(*discuss goal 2*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*))[1])
(*discuss goal 3*)
apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*))[1])
(*goal: ‹⋀x xs y ys. ⟦⟦⋀x. x ∈ set xs ⟹ approx_floatarith p x zs ≠ None; ⋀x. x ∈ set ys ⟹ approx_floatarith p x zs ≠ None⟧ ⟹ approx_floatarith p (inner_floatariths xs ys) zs ≠ None; ⋀xa. xa ∈ set (x # xs) ⟹ approx_floatarith p xa zs ≠ None; ⋀x. x ∈ set (y # ys) ⟹ approx_floatarith p x zs ≠ None⟧ ⟹ approx_floatarith p (inner_floatariths (x # xs) (y # ys)) zs ≠ None›*)
apply (metis old.prod.exhaust (*‹(⋀a b. ?y = (a, b) ⟹ ?P) ⟹ ?P›*))
(*proven 3 subgoals*) .
lemma aiVN: "approx_floatarith p
(inner_floatariths (map floatarith.Var [0..<length a])
(map floatarith.Var [length a..<length a + length b]))
(map (λx. (x, 0)) a @ map (λx. (x, 0)) b) ≠ None"
apply (rule aiN (*‹⟦⋀x. x ∈ set ?xs ⟹ approx_floatarith ?p x ?zs ≠ None; ⋀x. x ∈ set ?ys ⟹ approx_floatarith ?p x ?zs ≠ None⟧ ⟹ approx_floatarith ?p (inner_floatariths ?xs ?ys) ?zs ≠ None›*))
(*goals:
1. ‹⋀x. x ∈ set (map floatarith.Var [0..<length a]) ⟹ approx_floatarith p x (map (λx. (x, 0)) a @ map (λx. (x, 0)) b) ≠ None›
2. ‹⋀x. x ∈ set (map floatarith.Var [length a..<length a + length b]) ⟹ approx_floatarith p x (map (λx. (x, 0)) a @ map (λx. (x, 0)) b) ≠ None›
discuss goal 1*)
apply ((auto simp: nth_append (*‹((?xs::?'a::type list) @ (?ys::?'a::type list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*))[1])
(*discuss goal 2*)
apply ((auto simp: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*))[1])
(*proven 2 subgoals*) .
lemma iaN: "inner_aforms' p a b ≠ None"
unfolding inner_aforms'_def Let_def approx_slp_outer_def
(*goal: ‹approx_slp p [inner_floatariths (map floatarith.Var [0..<length a]) (map floatarith.Var [length a..<length a + length b])] (map (λx. (x, 0)) (a @ b)) ⤜ (λrs. Some (aforms_err_to_aforms (max (degree_aforms (a @ b)) (degree_aforms_err (take (length [inner_floatariths (map floatarith.Var [0..<length a]) (map floatarith.Var [length a..<length a + length b])]) rs))) (take (length [inner_floatariths (map floatarith.Var [0..<length a]) (map floatarith.Var [length a..<length a + length b])]) rs))) ≠ None›*)
using aiVN[of p a b] (*‹approx_floatarith p (inner_floatariths (map floatarith.Var [0..<length a]) (map floatarith.Var [length a..<length a + length b])) (map (λx. (x, 0)) a @ map (λx. (x, 0)) b) ≠ None›*) by (auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*))
definition "support_aform prec b X = (let ia = inner_aform X b in fst X ∙ b + tdev' (prec) (snd ia))"
definition "width_aforms prec X =
(let t = tdev' (prec) ((abssum_of_pdevs_list (map snd X))) in t)"
definition "inf_aforms prec xs = map (Inf_aform' (prec)) xs"
definition "sup_aforms prec xs = map (Sup_aform' (prec)) xs"
definition "fresh_index_aforms xs = Max (insert 0 (degree_aform ` set xs))"
definition "independent_aforms x env = (msum_aform (fresh_index_aforms env) (0, zero_pdevs) x#env)"
definition "aform_form_ivl prec form xs =
dRETURN (approx_form prec form (ivls_of_aforms prec xs) [])"
definition "aform_form prec form xs =
dRETURN (approx_form_aform prec form xs)"
definition "aform_slp prec n slp xs =
dRETURN (approx_slp_outer prec n slp xs)"
definition
"aform_isFDERIV prec n ns fas xs =
dRETURN (isFDERIV_approx prec n ns fas (ivls_of_aforms prec xs))"
definition aform_rel_internal: "aform_rel R = br Affine top O ⟨R⟩set_rel"
lemma aform_rel_def: "⟨rnv_rel⟩aform_rel = br Affine top"
unfolding relAPP_def
(*goal: ‹aform_rel rnv_rel = br Affine top›*)
by (auto simp: aform_rel_internal (*‹aform_rel ?R = br Affine top O ⟨?R⟩set_rel›*))
definition "aforms_rel = br Joints top"
definition aform_rell :: "((real × real pdevs) list × real list set) set"
where "aform_rell = aforms_rel"
definition aforms_relp_internal: "aforms_relp R = aforms_rel O ⟨R⟩set_rel"
lemma aforms_relp_def: "⟨R⟩aforms_relp = aforms_rel O ⟨R⟩set_rel"
by (auto simp: aforms_relp_internal (*‹aforms_relp ?R = aforms_rel O ⟨?R⟩set_rel›*) relAPP_def (*‹⟨?x⟩?f ≡ ?f ?x›*))
definition "product_aforms x y = x @ msum_aforms (degree_aforms (x)) (replicate (length y) (0, zero_pdevs)) y"
lemma
eucl_of_list_mem_eucl_of_list_aform:
assumes "x ∈ Joints a"
assumes "length a = DIM('a::executable_euclidean_space)"
shows "eucl_of_list x ∈ Affine (eucl_of_list_aform a::'a aform)"
using assms (*‹x ∈ Joints a› ‹length a = DIM('a)›*) by (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) eucl_of_list_aform_def (*‹eucl_of_list_aform ?xs = (eucl_of_list (map fst ?xs), sum_pdevs (λi. pdevs_scaleR (snd (?xs ! index Basis_list i)) i) Basis)›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) pdevs_val_sum_pdevs (*‹pdevs_val ?e (sum_pdevs ?f ?X) = (∑x∈?X. pdevs_val ?e (?f x))›*) inner_simps (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z› ‹?x ∙ (?y + ?z) = ?x ∙ ?y + ?x ∙ ?z› ‹?x ∙ (?y - ?z) = ?x ∙ ?y - ?x ∙ ?z› ‹(?x - ?y) ∙ ?z = ?x ∙ ?z - ?y ∙ ?z› ‹?r *⇩R ?x ∙ ?y = ?r * (?x ∙ ?y)› ‹?x ∙ ?r *⇩R ?y = ?r * (?x ∙ ?y)›*) eucl_of_list_inner (*‹⟦?i ∈ Basis; length ?xs = DIM(?'a)⟧ ⟹ eucl_of_list ?xs ∙ ?i = ?xs ! index Basis_list ?i›*) intro!: euclidean_eqI[where 'a='a] (*‹(⋀b. b ∈ Basis ⟹ ?x ∙ b = ?y ∙ b) ⟹ ?x = ?y›*))
lemma
in_image_eucl_of_list_eucl_of_list_aform:
assumes "length x = DIM('a::executable_euclidean_space)" "xa ∈ Affine (eucl_of_list_aform x::'a aform)"
shows "xa ∈ eucl_of_list ` Joints x"
using assms (*‹length (x::(real × real pdevs) list) = DIM('a)› ‹xa ∈ Affine (eucl_of_list_aform x)›*) by (auto intro!: nth_equalityI (*‹⟦length ?xs = length ?ys; ⋀i. i < length ?xs ⟹ ?xs ! i = ?ys ! i⟧ ⟹ ?xs = ?ys›*) image_eqI[where x="list_of_eucl xa"] (*‹⟦?b = ?f (list_of_eucl xa); list_of_eucl xa ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*) simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) eucl_of_list_aform_def (*‹eucl_of_list_aform ?xs = (eucl_of_list (map fst ?xs), sum_pdevs (λi. pdevs_scaleR (snd (?xs ! index Basis_list i)) i) Basis)›*) Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) inner_simps (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z› ‹?x ∙ (?y + ?z) = ?x ∙ ?y + ?x ∙ ?z› ‹?x ∙ (?y - ?z) = ?x ∙ ?y - ?x ∙ ?z› ‹(?x - ?y) ∙ ?z = ?x ∙ ?z - ?y ∙ ?z› ‹?r *⇩R ?x ∙ ?y = ?r * (?x ∙ ?y)› ‹?x ∙ ?r *⇩R ?y = ?r * (?x ∙ ?y)›*) pdevs_val_sum_pdevs (*‹pdevs_val ?e (sum_pdevs ?f ?X) = (∑x∈?X. pdevs_val ?e (?f x))›*) eucl_of_list_inner (*‹⟦?i ∈ Basis; length ?xs = DIM(?'a)⟧ ⟹ eucl_of_list ?xs ∙ ?i = ?xs ! index Basis_list ?i›*))
lemma
eucl_of_list_image_Joints:
assumes "length x = DIM('a::executable_euclidean_space)"
shows "eucl_of_list ` Joints x = Affine (eucl_of_list_aform x::'a aform)"
using assms (*‹length (x::(real × real pdevs) list) = DIM('a)›*) by (auto intro!: eucl_of_list_mem_eucl_of_list_aform (*‹⟦(?x::real list) ∈ Joints (?a::(real × real pdevs) list); length ?a = DIM(?'a)⟧ ⟹ eucl_of_list ?x ∈ Affine (eucl_of_list_aform ?a)›*) in_image_eucl_of_list_eucl_of_list_aform (*‹⟦length (?x::(real × real pdevs) list) = DIM(?'a); (?xa::?'a) ∈ Affine (eucl_of_list_aform ?x)⟧ ⟹ ?xa ∈ eucl_of_list ` Joints ?x›*))
definition "aform_ops =
⦇
appr_of_ivl = aforms_of_ivls,
product_appr = product_aforms,
msum_appr = msum_aforms',
inf_of_appr = λoptns. inf_aforms (precision optns),
sup_of_appr = λoptns. sup_aforms (precision optns),
split_appr = split_aforms_largest_uncond_take,
appr_inf_inner = λoptns. aform_inf_inner (precision optns),
appr_sup_inner = λoptns. aform_sup_inner (precision optns),
inter_appr_plane = λoptns xs sctn. inter_aform_plane_lv (length xs) (precision optns) xs sctn,
reduce_appr = λoptns. reduce_aforms (precision optns),
width_appr = λoptns. width_aforms (precision optns),
approx_slp_dres = λoptns. aform_slp (precision optns),
approx_euclarithform = λoptns. aform_form (precision optns),
approx_isFDERIV = λoptns. aform_isFDERIV (precision optns)
⦈"
lemma Affine_eq_permI:
assumes "fst X = fst Y"
assumes "map snd (list_of_pdevs (snd X)) <~~> map snd (list_of_pdevs (snd Y))" (is "?perm X Y")
shows "Affine X = Affine Y"
proof (-)
(*goal: ‹Affine X = Affine Y›*)
{
fix X and Y and e :: "nat ⇒ real"
assume perm: "?perm X Y" and e: "e ∈ funcset UNIV {- 1..1}" (*‹mset (map snd (list_of_pdevs (snd (X::'a × 'a pdevs)))) = mset (map snd (list_of_pdevs (snd (Y::'a × 'a pdevs))))› ‹(e::nat ⇒ real) ∈ funcset UNIV {- (1::real)..1::real}›*)
from pdevs_val_of_list_of_pdevs2[OF e, of "snd X"] (*‹(⋀e'. ⟦pdevs_val e (snd X) = pdevs_val e' (pdevs_of_list (map snd (list_of_pdevs (snd X)))); e' ∈ funcset UNIV {- 1..1}⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain e' where e': "pdevs_val e (snd X) = pdevs_val e' (pdevs_of_list (map snd (list_of_pdevs (snd X))))" "e' ∈ funcset UNIV {- 1..1}"
(*goal: ‹(⋀e'::nat ⇒ real. ⟦pdevs_val (e::nat ⇒ real) (snd (X::'a × 'a pdevs)) = pdevs_val e' (pdevs_of_list (map snd (list_of_pdevs (snd X)))); e' ∈ funcset UNIV {- (1::real)..1::real}⟧ ⟹ thesis::bool) ⟹ thesis›*)
by auto
note e'(1) (*‹pdevs_val (e::nat ⇒ real) (snd (X::'a × 'a pdevs)) = pdevs_val (e'::nat ⇒ real) (pdevs_of_list (map snd (list_of_pdevs (snd X))))›*)
also (*calculation: ‹pdevs_val (e::nat ⇒ real) (snd (X::'a × 'a pdevs)) = pdevs_val (e'::nat ⇒ real) (pdevs_of_list (map snd (list_of_pdevs (snd X))))›*) from pdevs_val_perm[OF perm e' ( 2 )] (*‹(⋀e'a. ⟦e'a ∈ funcset UNIV {- 1..1}; pdevs_val e' (pdevs_of_list (map snd (list_of_pdevs (snd X)))) = pdevs_val e'a (pdevs_of_list (map snd (list_of_pdevs (snd Y))))⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain e'' where e'': "e'' ∈ funcset UNIV {- 1..1}" "pdevs_val e' (pdevs_of_list (map snd (list_of_pdevs (snd X)))) =
pdevs_val e'' (pdevs_of_list (map snd (list_of_pdevs (snd Y))))"
(*goal: ‹(⋀e''. ⟦e'' ∈ funcset UNIV {- 1..1}; pdevs_val e' (pdevs_of_list (map snd (list_of_pdevs (snd X)))) = pdevs_val e'' (pdevs_of_list (map snd (list_of_pdevs (snd Y))))⟧ ⟹ thesis) ⟹ thesis›*)
by auto
note e''(2) (*‹pdevs_val e' (pdevs_of_list (map snd (list_of_pdevs (snd X)))) = pdevs_val e'' (pdevs_of_list (map snd (list_of_pdevs (snd Y))))›*)
also (*calculation: ‹pdevs_val e (snd X) = pdevs_val e'' (pdevs_of_list (map snd (list_of_pdevs (snd Y))))›*) from pdevs_val_of_list_of_pdevs[OF e'' ( 1 ), of "snd Y", simplified] (*‹(⋀e'. ⟦pdevs_val e'' (pdevs_of_list (map snd (list_of_pdevs (snd Y)))) = pdevs_val e' (snd Y); e' ∈ funcset UNIV {- 1..1}⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain e''' where e''': "pdevs_val e'' (pdevs_of_list (map snd (list_of_pdevs (snd Y)))) = pdevs_val e''' (snd Y)" "e''' ∈ funcset UNIV {- 1..1}"
(*goal: ‹(⋀e'''::nat ⇒ real. ⟦pdevs_val (e''::nat ⇒ real) (pdevs_of_list (map snd (list_of_pdevs (snd (Y::'a × 'a pdevs))))) = pdevs_val e''' (snd Y); e''' ∈ funcset UNIV {- (1::real)..1::real}⟧ ⟹ thesis::bool) ⟹ thesis›*)
by auto
note e'''(1) (*‹pdevs_val e'' (pdevs_of_list (map snd (list_of_pdevs (snd Y)))) = pdevs_val e''' (snd Y)›*)
finally (*calculation: ‹pdevs_val e (snd X) = pdevs_val e''' (snd Y)›*) have "∃e' ∈ funcset UNIV {-1 .. 1}. pdevs_val e (snd X) = pdevs_val e' (snd Y)"
using e'''(2) (*‹e''' ∈ funcset UNIV {- 1..1}›*) by auto
}
note E = this (*‹⟦mset (map snd (list_of_pdevs (snd ?Xa2))) = mset (map snd (list_of_pdevs (snd ?Ya2))); ?e2 ∈ funcset UNIV {- 1..1}⟧ ⟹ ∃e'∈funcset UNIV {- 1..1}. pdevs_val ?e2 (snd ?Xa2) = pdevs_val e' (snd ?Ya2)›*)
note e1 = E[OF assms ( 2 )] (*‹(?e2::nat ⇒ real) ∈ funcset UNIV {- (1::real)..1::real} ⟹ ∃e'::nat ⇒ real∈funcset UNIV {- (1::real)..1::real}. pdevs_val ?e2 (snd (X::'a × 'a pdevs)) = pdevs_val e' (snd (Y::'a × 'a pdevs))›*) and e2 = E[OF perm_sym [ OF assms ( 2 ) ]] (*‹(?e2::nat ⇒ real) ∈ funcset UNIV {- (1::real)..1::real} ⟹ ∃e'::nat ⇒ real∈funcset UNIV {- (1::real)..1::real}. pdevs_val ?e2 (snd (Y::'a::real_normed_vector × 'a::real_normed_vector pdevs)) = pdevs_val e' (snd (X::'a::real_normed_vector × 'a::real_normed_vector pdevs))›*)
show "?thesis"
(*goal: ‹Affine X = Affine Y›*)
by (auto simp: Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) assms (*‹fst X = fst Y› ‹mset (map snd (list_of_pdevs (snd X))) = mset (map snd (list_of_pdevs (snd Y)))›*) dest: e1 (*‹?e2 ∈ funcset UNIV {- 1..1} ⟹ ∃e'∈funcset UNIV {- 1..1}. pdevs_val ?e2 (snd X) = pdevs_val e' (snd Y)›*) e2 (*‹?e2 ∈ funcset UNIV {- 1..1} ⟹ ∃e'∈funcset UNIV {- 1..1}. pdevs_val ?e2 (snd Y) = pdevs_val e' (snd X)›*))
qed
context includes autoref_syntax begin
lemma aform_of_ivl_refine: "x ≤ y ⟹ (aform_of_ivl x y, atLeastAtMost x y) ∈ ⟨rnv_rel⟩aform_rel"
by (auto simp: aform_rel_def (*‹⟨rnv_rel⟩aform_rel = br Affine top›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) Affine_aform_of_ivl (*‹?a ≤ ?b ⟹ Affine (aform_of_ivl ?a ?b) = {?a..?b}›*))
lemma aforms_of_ivl_leI1:
fixes en::real
assumes "-1 ≤ en" "xsn ≤ ysn"
shows "xsn ≤ (xsn + ysn) / 2 + (ysn - xsn) * en / 2"
proof (-)
(*goal: ‹xsn ≤ (xsn + ysn) / 2 + (ysn - xsn) * en / 2›*)
have "xsn * (1 + en) ≤ ysn * (1 + en)"
using assms (*‹- 1 ≤ en› ‹(xsn::real) ≤ (ysn::real)›*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) by force
then show "?thesis"
(*goal: ‹xsn ≤ (xsn + ysn) / 2 + (ysn - xsn) * en / 2›*)
by (auto simp: algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 34 facts*) divide_simps (*‹inverse (?a::?'a) = (1::?'a) / ?a› ‹(?a::?'a) + (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z + ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (?a + ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (- ?a + ?b * ?z) / ?z)› ‹(?a::?'a) - (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z - ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (?a - ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (- ?a - ?b * ?z) / ?z)› ‹((?b::?'a) / (?c::?'a) = (?a::?'a)) = (if ?c ≠ (0::?'a) then ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = (?b::?'a) / (?c::?'a)) = (if ?c ≠ (0::?'a) then ?a * ?c = ?b else ?a = (0::?'a))› ‹(- ((?b::?'a) / (?c::?'a)) = (?a::?'a)) = (if ?c ≠ (0::?'a) then - ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = - ((?b::?'a) / (?c::?'a))) = (if ?c ≠ (0::?'a) then ?a * ?c = - ?b else ?a = (0::?'a))› ‹((?a::?'a) ≤ (?b::?'a) / (?c::?'a)) = (if (0::?'a) < ?c then ?a * ?c ≤ ?b else if ?c < (0::?'a) then ?b ≤ ?a * ?c else ?a ≤ (0::?'a))› and more 13 facts*))
qed
lemma aforms_of_ivl_leI2:
fixes en::real
assumes "1 ≥ en" "xsn ≤ ysn"
shows "(xsn + ysn) / 2 + (ysn - xsn) * en / 2 ≤ ysn"
proof (-)
(*goal: ‹(xsn + ysn) / 2 + (ysn - xsn) * en / 2 ≤ ysn›*)
have "xsn * (1 - en) ≤ ysn * (1 - en)"
using assms (*‹(en::real) ≤ (1::real)› ‹xsn ≤ ysn›*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) by force
then show "?thesis"
(*goal: ‹(xsn + ysn) / 2 + (ysn - xsn) * en / 2 ≤ ysn›*)
by (auto simp: algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 34 facts*) divide_simps (*‹inverse (?a::?'a) = (1::?'a) / ?a› ‹(?a::?'a) + (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z + ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (?a + ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (- ?a + ?b * ?z) / ?z)› ‹(?a::?'a) - (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z - ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (?a - ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (- ?a - ?b * ?z) / ?z)› ‹((?b::?'a) / (?c::?'a) = (?a::?'a)) = (if ?c ≠ (0::?'a) then ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = (?b::?'a) / (?c::?'a)) = (if ?c ≠ (0::?'a) then ?a * ?c = ?b else ?a = (0::?'a))› ‹(- ((?b::?'a) / (?c::?'a)) = (?a::?'a)) = (if ?c ≠ (0::?'a) then - ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = - ((?b::?'a) / (?c::?'a))) = (if ?c ≠ (0::?'a) then ?a * ?c = - ?b else ?a = (0::?'a))› ‹((?a::?'a) ≤ (?b::?'a) / (?c::?'a)) = (if (0::?'a) < ?c then ?a * ?c ≤ ?b else if ?c < (0::?'a) then ?b ≤ ?a * ?c else ?a ≤ (0::?'a))› and more 13 facts*))
qed
lemma Joints_aforms_of_ivlsD1:
"zs ∈ Joints (aforms_of_ivls xs ys) ⟹ list_all2 (≤) xs ys ⟹ list_all2 (≤) xs zs"
by (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) aforms_of_ivls_def (*‹aforms_of_ivls ?ls ?us = map2 (λi (l, u). ((l + u) / 2, scaleR_pdevs ((u - l) / 2) (coord_pdevs i))) [0..<length ?ls] (zip ?ls ?us)›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) Pi_iff (*‹(?f ∈ Pi ?I ?X) = (∀i∈?I. ?f i ∈ ?X i)›*) list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*) intro!: list_all2_all_nthI (*‹⟦length ?a = length ?b; ⋀n. n < length ?a ⟹ ?P (?a ! n) (?b ! n)⟧ ⟹ list_all2 ?P ?a ?b›*) aforms_of_ivl_leI1 (*‹⟦- 1 ≤ ?en; ?xsn ≤ ?ysn⟧ ⟹ ?xsn ≤ (?xsn + ?ysn) / 2 + (?ysn - ?xsn) * ?en / 2›*))
lemma Joints_aforms_of_ivlsD2:
"zs ∈ Joints (aforms_of_ivls xs ys) ⟹ list_all2 (≤) xs ys ⟹ list_all2 (≤) zs ys"
by (auto simp: Joints_def (*‹Joints (?XS::(?'a × ?'a pdevs) list) = valuate (λe::nat ⇒ real. map (aform_val e) ?XS)›*) valuate_def (*‹valuate (?x::(nat ⇒ real) ⇒ ?'a) = ?x ` funcset UNIV {- (1::real)..1::real}›*) aforms_of_ivls_def (*‹aforms_of_ivls (?ls::real list) (?us::real list) = map2 (λ(i::nat) (l::real, u::real). ((l + u) / (2::real), scaleR_pdevs ((u - l) / (2::real)) (coord_pdevs i))) [0::nat..<length ?ls] (zip ?ls ?us)›*) aform_val_def (*‹aform_val (?e::nat ⇒ real) (?X::?'a × ?'a pdevs) = fst ?X + pdevs_val ?e (snd ?X)›*) Pi_iff (*‹((?f::?'a ⇒ ?'b) ∈ Pi (?I::?'a set) (?X::?'a ⇒ ?'b set)) = (∀i::?'a∈?I. ?f i ∈ ?X i)›*) list_all2_conv_all_nth (*‹list_all2 (?P::?'a ⇒ ?'b ⇒ bool) (?xs::?'a list) (?ys::?'b list) = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*) intro!: list_all2_all_nthI (*‹⟦length (?a::?'a list) = length (?b::?'b list); ⋀n::nat. n < length ?a ⟹ (?P::?'a ⇒ ?'b ⇒ bool) (?a ! n) (?b ! n)⟧ ⟹ list_all2 ?P ?a ?b›*) aforms_of_ivl_leI2 (*‹⟦(?en::real) ≤ (1::real); (?xsn::real) ≤ (?ysn::real)⟧ ⟹ (?xsn + ?ysn) / (2::real) + (?ysn - ?xsn) * ?en / (2::real) ≤ ?ysn›*))
lemma aforms_of_ivls_refine:
"list_all2 (≤) xrs yrs ⟹
(xri, xrs) ∈ ⟨rnv_rel⟩list_rel ⟹
(yri, yrs) ∈ ⟨rnv_rel⟩list_rel ⟹ (aforms_of_ivls xri yri, lv_ivl xrs yrs) ∈ aforms_rel"
apply (auto simp: aforms_rel_def (*‹aforms_rel = br Joints top›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) list_all2_lengthD (*‹list_all2 ?P ?xs ?ys ⟹ length ?xs = length ?ys›*) lv_ivl_def (*‹lv_ivl ?xrs ?yrs = {zrs. list_all2 (≤) ?xrs zrs ∧ list_all2 (≤) zrs ?yrs}›*) Joints_aforms_of_ivlsD1 (*‹⟦?zs ∈ Joints (aforms_of_ivls ?xs ?ys); list_all2 (≤) ?xs ?ys⟧ ⟹ list_all2 (≤) ?xs ?zs›*) Joints_aforms_of_ivlsD2 (*‹⟦?zs ∈ Joints (aforms_of_ivls ?xs ?ys); list_all2 (≤) ?xs ?ys⟧ ⟹ list_all2 (≤) ?zs ?ys›*) intro!: aforms_of_ivls (*‹⟦length ?ls = length ?us; length ?xs = length ?ls; ⋀i. i < length ?xs ⟹ ?xs ! i ∈ {?ls ! i..?us ! i}⟧ ⟹ ?xs ∈ Joints (aforms_of_ivls ?ls ?us)›*))
(*goal: ‹⟦list_all2 (≤) xrs yrs; (xri, xrs) ∈ rl_rel; (yri, yrs) ∈ rl_rel⟧ ⟹ (aforms_of_ivls xri yri, lv_ivl xrs yrs) ∈ aforms_rel›*)
subgoal for
by (simp add: list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*))
subgoal for
by (simp add: list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*)) .
lemma degrees_zero_pdevs[simp]: "degrees (replicate n zero_pdevs) = 0"
by (auto simp: degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*) intro!: Max_eqI (*‹⟦finite ?A; ⋀y. y ∈ ?A ⟹ y ≤ ?x; ?x ∈ ?A⟧ ⟹ Max ?A = ?x›*))
lemma Joints_product_aforms:
"Joints (product_aforms a b) = product_listset (Joints a) (Joints b)"
apply (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) product_listset_def (*‹product_listset ?xs ?ys = (λ(x, y). x @ y) ` (?xs × ?ys)›*) product_aforms_def (*‹product_aforms ?x ?y = ?x @ msum_aforms (degree_aforms ?x) (replicate (length ?y) (0, zero_pdevs)) ?y›*) aform_vals_def[symmetric] (*‹map (aform_val ?e) ?X = aform_vals ?e ?X›*) aform_val_msum_aforms (*‹degree_aforms ?xs ≤ ?d ⟹ aform_vals ?e (msum_aforms ?d ?xs ?ys) = map2 (+) (aform_vals ?e ?xs) (aform_vals (λi. ?e (i + ?d)) ?ys)›*))
(*goal: ‹Joints (product_aforms a b) = product_listset (Joints a) (Joints b)›*)
subgoal for e
apply (rule image_eqI[where x="(aform_vals e a,
List.map2 (+) (aform_vals e (replicate (length b) (0, zero_pdevs))) (aform_vals (λi. e (i + degree_aforms a)) b))" ] (*‹⟦?b = ?f (aform_vals e a, map2 (+) (aform_vals e (replicate (length b) (0, zero_pdevs))) (aform_vals (λi. e (i + degree_aforms a)) b)); (aform_vals e a, map2 (+) (aform_vals e (replicate (length b) (0, zero_pdevs))) (aform_vals (λi. e (i + degree_aforms a)) b)) ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*))
(*goals:
1. ‹(e::nat ⇒ real) ∈ funcset UNIV {- (1::real)..1::real} ⟹ aform_vals e (a::(real × real pdevs) list) @ map2 (+) (aform_vals e (replicate (length (b::(real × real pdevs) list)) (0::real, zero_pdevs))) (aform_vals (λi::nat. e (i + degree_aforms a)) b) = (case (aform_vals e a, map2 (+) (aform_vals e (replicate (length b) (0::real, zero_pdevs))) (aform_vals (λi::nat. e (i + degree_aforms a)) b)) of (x::real list, xa::real list) ⇒ x @ xa)›
2. ‹(e::nat ⇒ real) ∈ funcset UNIV {- (1::real)..1::real} ⟹ (aform_vals e (a::(real × real pdevs) list), map2 (+) (aform_vals e (replicate (length (b::(real × real pdevs) list)) (0::real, zero_pdevs))) (aform_vals (λi::nat. e (i + degree_aforms a)) b)) ∈ (λe::nat ⇒ real. aform_vals e a) ` funcset UNIV {- (1::real)..1::real} × (λe::nat ⇒ real. aform_vals e b) ` funcset UNIV {- (1::real)..1::real}›
discuss goal 1*)
apply ((auto simp: split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*))[1])
(*discuss goal 2*)
apply ((auto simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*))[1])
(*goal: ‹e ∈ funcset UNIV {- 1..1} ⟹ (aform_vals e a, map2 (+) (aform_vals e (replicate (length b) (0, zero_pdevs))) (aform_vals (λi. e (i + degree_aforms a)) b)) ∈ (λe. aform_vals e a) ` funcset UNIV {- 1..1} × (λe. aform_vals e b) ` funcset UNIV {- 1..1}›*)
apply (auto simp: aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*) intro!: nth_equalityI (*‹⟦length ?xs = length ?ys; ⋀i. i < length ?xs ⟹ ?xs ! i = ?ys ! i⟧ ⟹ ?xs = ?ys›*) image_eqI[where x="λi. e (i + degree_aforms a)"] (*‹⟦?b = ?f (λi. e (i + degree_aforms a)); (λi. e (i + degree_aforms a)) ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*))
(*proven 2 subgoals*) .
subgoal for e1 and e2
apply (rule image_eqI[where x="λi. if i < degree_aforms a then e1 i else e2 (i - degree_aforms a)"] (*‹⟦?b = ?f (λi. if i < degree_aforms a then e1 i else e2 (i - degree_aforms a)); (λi. if i < degree_aforms a then e1 i else e2 (i - degree_aforms a)) ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*))
(*goal: ‹⟦e1 ∈ funcset UNIV {- 1..1}; e2 ∈ funcset UNIV {- 1..1}⟧ ⟹ aform_vals e1 a @ aform_vals e2 b ∈ (λe. aform_vals e a @ map2 (+) (aform_vals e (replicate (length b) (0, zero_pdevs))) (aform_vals (λi. e (i + degree_aforms a)) b)) ` funcset UNIV {- 1..1}›*)
apply (auto simp: aform_vals_def (*‹aform_vals (?e::nat ⇒ real) (?X::(?'a::real_normed_vector × ?'a::real_normed_vector pdevs) list) = map (aform_val ?e) ?X›*) aform_val_def (*‹aform_val (?e::nat ⇒ real) (?X::?'a::real_normed_vector × ?'a::real_normed_vector pdevs) = fst ?X + pdevs_val ?e (snd ?X)›*) Pi_iff (*‹((?f::?'a::type ⇒ ?'b::type) ∈ Pi (?I::?'a::type set) (?X::?'a::type ⇒ ?'b::type set)) = (∀i::?'a::type∈?I. ?f i ∈ ?X i)›*) intro!: nth_equalityI (*‹⟦length (?xs::?'a::type list) = length (?ys::?'a::type list); ⋀i::nat. i < length ?xs ⟹ ?xs ! i = ?ys ! i⟧ ⟹ ?xs = ?ys›*) pdevs_val_degree_cong (*‹⟦(?b::?'a::real_normed_vector pdevs) = (?d::?'a::real_normed_vector pdevs); ⋀i::nat. i < degree ?b ⟹ (?a::nat ⇒ real) i = (?c::nat ⇒ real) i⟧ ⟹ pdevs_val ?a ?b = pdevs_val ?c ?d›*))
(*top goal: ‹⟦e1 ∈ funcset UNIV {- 1..1}; e2 ∈ funcset UNIV {- 1..1}⟧ ⟹ aform_vals e1 a @ aform_vals e2 b = aform_vals (λi. if i < degree_aforms a then e1 i else e2 (i - degree_aforms a)) a @ map2 (+) (aform_vals (λi. if i < degree_aforms a then e1 i else e2 (i - degree_aforms a)) (replicate (length b) (0, zero_pdevs))) (aform_vals (λi. if i + degree_aforms a < degree_aforms a then e1 (i + degree_aforms a) else e2 (i + degree_aforms a - degree_aforms a)) b)› and 1 goal remains*)
subgoalpremises prems for x and xs and k
proof (-)
(*goal: ‹(e1::nat ⇒ real) (k::nat) = (e2::nat ⇒ real) (k - degree_aforms (a::(real × real pdevs) list))›*)
from prems (*‹∀i. - 1 ≤ e1 i ∧ e1 i ≤ 1› ‹∀i::nat. - (1::real) ≤ (e2::nat ⇒ real) i ∧ e2 i ≤ (1::real)› ‹(x, xs) ∈ set a› ‹k < degree xs› ‹¬ k < degree_aforms a›*) have "degree xs ≤ degree_aforms a"
by (auto simp: degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*) Max_gr_iff (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ (?x < Max ?A) = (∃a∈?A. ?x < a)›*))
then show "?thesis"
(*goal: ‹e1 k = e2 (k - degree_aforms a)›*)
using prems (*‹∀i. - 1 ≤ e1 i ∧ e1 i ≤ 1› ‹∀i. - 1 ≤ e2 i ∧ e2 i ≤ 1› ‹(x, xs) ∈ set a› ‹k < degree xs› ‹¬ (k::nat) < degree_aforms (a::(real × real pdevs) list)›*) by auto
qed . .
lemma product_aforms_refine:
"(product_aforms, product_listset) ∈ aforms_rel → aforms_rel → aforms_rel"
by (auto simp: aforms_rel_def (*‹aforms_rel = br Joints top›*) br_def (*‹br (?α::?'a ⇒ ?'b) (?I::?'a ⇒ bool) ≡ {(c::?'a, a::?'b). a = ?α c ∧ ?I c}›*) Joints_product_aforms (*‹Joints (product_aforms (?a::(real × real pdevs) list) (?b::(real × real pdevs) list)) = product_listset (Joints ?a) (Joints ?b)›*))
lemma mem_lv_rel_set_rel_iff:
fixes z::"'a::executable_euclidean_space set"
shows "(y, z) ∈ ⟨lv_rel⟩set_rel ⟷ (z = eucl_of_list ` y ∧ (∀x ∈ y. length x = DIM('a)))"
unfolding lv_rel_def
(*goal: ‹((y::real list set, z::'a::executable_euclidean_space set) ∈ ⟨br eucl_of_list (λxs::real list. length xs = DIM('a::executable_euclidean_space))⟩set_rel) = (z = eucl_of_list ` y ∧ (∀x::real list∈y. length x = DIM('a::executable_euclidean_space)))›*)
by (auto simp: set_rel_def (*‹⟨?R::(?'a::type × ?'b::type) set⟩set_rel ≡ {(A::?'a::type set, B::?'b::type set). (∀x::?'a::type∈A. ∃y::?'b::type∈B. (x, y) ∈ ?R) ∧ (∀y::?'b::type∈B. ∃x::?'a::type∈A. (x, y) ∈ ?R)}›*) br_def (*‹br (?α::?'a::type ⇒ ?'b::type) (?I::?'a::type ⇒ bool) ≡ {(c::?'a::type, a::?'b::type). a = ?α c ∧ ?I c}›*))
lemma eucl_of_list_mem_lv_rel: "length x = DIM('a::executable_euclidean_space) ⟹
(x, eucl_of_list x::'a) ∈ lv_rel"
unfolding lv_rel_def
(*goal: ‹length x = DIM('a) ⟹ (x, eucl_of_list x) ∈ br eucl_of_list (λxs. length xs = DIM('a))›*)
by (auto simp: br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*))
lemma
mem_Joints_msum_aforms'I:
"a ∈ Joints x ⟹ b ∈ Joints y ⟹ List.map2 (+) a b ∈ Joints (msum_aforms' x y)"
by (auto simp: Joints_msum_aforms (*‹⟦degree_aforms ?xs ≤ ?d; degree_aforms ?ys ≤ ?d⟧ ⟹ Joints (msum_aforms ?d ?xs ?ys) = {map2 (+) a b |a b. a ∈ Joints ?xs ∧ b ∈ Joints ?ys}›*) degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*))
lemma
mem_Joints_msum_aforms'E:
assumes "xa ∈ Joints (msum_aforms' x y)"
obtains a b where "xa = List.map2 (+) a b" "a ∈ Joints x" "b ∈ Joints y"
using assms (*‹xa ∈ Joints (msum_aforms' x y)›*) by (auto simp: Joints_msum_aforms (*‹⟦degree_aforms ?xs ≤ ?d; degree_aforms ?ys ≤ ?d⟧ ⟹ Joints (msum_aforms ?d ?xs ?ys) = {map2 (+) a b |a b. a ∈ Joints ?xs ∧ b ∈ Joints ?ys}›*) degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*))
lemma msum_aforms'_refine_raw:
shows "(msum_aforms' x y, {List.map2 (+) a b|a b. a ∈ Joints x ∧ b ∈ Joints y}) ∈ aforms_rel"
unfolding aforms_rel_def br_def
(*goal: ‹(msum_aforms' x y, {map2 (+) a b |a b. a ∈ Joints x ∧ b ∈ Joints y}) ∈ {(c, a). a = Joints c ∧ top c}›*)
apply (safe elim!: mem_Joints_msum_aforms'E (*‹⟦?xa ∈ Joints (msum_aforms' ?x ?y); ⋀a b. ⟦?xa = map2 (+) a b; a ∈ Joints ?x; b ∈ Joints ?y⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro!: mem_Joints_msum_aforms'I (*‹⟦?a ∈ Joints ?x; ?b ∈ Joints ?y⟧ ⟹ map2 (+) ?a ?b ∈ Joints (msum_aforms' ?x ?y)›*))
(*goal: ‹(msum_aforms' x y, {map2 (+) a b |a b. a ∈ Joints x ∧ b ∈ Joints y}) ∈ {(c, a). a = Joints c ∧ top c}›*)
by (auto simp: Joints_imp_length_eq (*‹(?xs::?'a list) ∈ Joints (?XS::(?'a × ?'a pdevs) list) ⟹ length ?xs = length ?XS›*))
lemma aforms_relD: "(a, b) ∈ aforms_rel ⟹ b = Joints a"
by (auto simp: aforms_rel_def (*‹aforms_rel = br Joints top›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*))
lemma msum_aforms'_refine:
"(msum_aforms', λxs ys. {List.map2 (+) x y |x y. x ∈ xs ∧ y ∈ ys}) ∈ aforms_rel → aforms_rel → aforms_rel"
by (safe dest!: aforms_relD (*‹(?a, ?b) ∈ aforms_rel ⟹ ?b = Joints ?a›*) intro!: msum_aforms'_refine_raw (*‹(msum_aforms' ?x ?y, {map2 (+) a b |a b. a ∈ Joints ?x ∧ b ∈ Joints ?y}) ∈ aforms_rel›*))
lemma length_inf_aforms[simp]: "length (inf_aforms optns x) = length x"
and length_sup_aforms[simp]: "length (sup_aforms optns x) = length x"
(*goals:
1. ‹length (inf_aforms optns x) = length x›
2. ‹length (sup_aforms optns x) = length x›
discuss goal 1*)
apply ((auto simp: inf_aforms_def (*‹inf_aforms ?prec ?xs = map (Inf_aform' ?prec) ?xs›*) sup_aforms_def (*‹sup_aforms ?prec ?xs = map (Sup_aform' ?prec) ?xs›*))[1])
(*discuss goal 2*)
apply ((auto simp: inf_aforms_def (*‹inf_aforms ?prec ?xs = map (Inf_aform' ?prec) ?xs›*) sup_aforms_def (*‹sup_aforms ?prec ?xs = map (Sup_aform' ?prec) ?xs›*))[1])
(*proven 2 subgoals*) .
lemma inf_aforms_refine:
"(xi, x) ∈ aforms_rel ⟹ length xi = d ⟹ (RETURN (inf_aforms optns xi), Inf_specs d x) ∈ ⟨rl_rel⟩nres_rel"
unfolding o_def
(*goal: ‹⟦(xi, x) ∈ aforms_rel; length xi = d⟧ ⟹ (RETURN (inf_aforms optns xi), Inf_specs d x) ∈ ⟨rl_rel⟩nres_rel›*)
apply (auto simp: br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) aforms_rel_def (*‹aforms_rel = br Joints top›*) mem_lv_rel_set_rel_iff (*‹((?y, ?z) ∈ ⟨lv_rel⟩set_rel) = (?z = eucl_of_list ` ?y ∧ (∀x∈?y. length x = DIM(?'a)))›*) nres_rel_def (*‹⟨?R⟩nres_rel ≡ {(c, a). c ≤ ⇓ ?R a}›*) Inf_specs_def (*‹Inf_specs ?d ?X = SPEC (λr. length r = ?d ∧ (∀x∈?X. list_all2 (≤) r x))›*) intro!: RETURN_SPEC_refine (*‹∃x'. (?x, x') ∈ ?R ∧ ?Φ x' ⟹ RETURN ?x ≤ ⇓ ?R (SPEC ?Φ)›*))
(*goal: ‹⟦(xi, x) ∈ aforms_rel; length xi = d⟧ ⟹ (RETURN (inf_aforms optns xi), Inf_specs d x) ∈ ⟨rl_rel⟩nres_rel›*)
unfolding lv_rel_def
(*goal: ‹⋀xa. ⟦x = Joints xi; d = length xi; xa ∈ Joints xi⟧ ⟹ list_all2 (≤) (inf_aforms optns xi) xa›*)
by (auto simp: aforms_rel_def (*‹aforms_rel = br Joints top›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*) eucl_of_list_inner (*‹⟦?i ∈ Basis; length ?xs = DIM(?'a)⟧ ⟹ eucl_of_list ?xs ∙ ?i = ?xs ! index Basis_list ?i›*) inf_aforms_def (*‹inf_aforms ?prec ?xs = map (Inf_aform' ?prec) ?xs›*) nth_in_AffineI (*‹⟦?xs ∈ Joints ?XS; ?i < length ?XS⟧ ⟹ ?xs ! ?i ∈ Affine (?XS ! ?i)›*) intro!: Inf_aform'_Affine_le (*‹?z ∈ Affine ?X ⟹ Inf_aform' ?p ?X ≤ ?z›*) list_all2_all_nthI (*‹⟦length ?a = length ?b; ⋀n. n < length ?a ⟹ ?P (?a ! n) (?b ! n)⟧ ⟹ list_all2 ?P ?a ?b›*))
lemma sup_aforms_refine:
"(xi, x) ∈ aforms_rel ⟹ length xi = d ⟹ (RETURN (sup_aforms optns xi), Sup_specs d x) ∈ ⟨rl_rel⟩nres_rel"
unfolding o_def
(*goal: ‹⟦(xi::(real × real pdevs) list, x::real list set) ∈ aforms_rel; length xi = (d::nat)⟧ ⟹ (RETURN (sup_aforms (optns::nat) xi), Sup_specs d x) ∈ ⟨rl_rel⟩nres_rel›*)
apply (auto simp: aforms_relp_def (*‹⟨?R⟩aforms_relp = aforms_rel O ⟨?R⟩set_rel›*) mem_lv_rel_set_rel_iff (*‹((?y, ?z) ∈ ⟨lv_rel⟩set_rel) = (?z = eucl_of_list ` ?y ∧ (∀x∈?y. length x = DIM(?'a)))›*) nres_rel_def (*‹⟨?R⟩nres_rel ≡ {(c, a). c ≤ ⇓ ?R a}›*) Sup_specs_def (*‹Sup_specs ?d ?X = SPEC (λr. length r = ?d ∧ (∀x∈?X. list_all2 (≤) x r))›*) intro!: RETURN_SPEC_refine (*‹∃x'. (?x, x') ∈ ?R ∧ ?Φ x' ⟹ RETURN ?x ≤ ⇓ ?R (SPEC ?Φ)›*))
(*goal: ‹⟦(xi::(real × real pdevs) list, x::real list set) ∈ aforms_rel; length xi = (d::nat)⟧ ⟹ (RETURN (sup_aforms (optns::nat) xi), Sup_specs d x) ∈ ⟨rl_rel⟩nres_rel›*)
unfolding lv_rel_def
(*goal: ‹⋀xa. ⟦(xi, x) ∈ aforms_rel; d = length xi; xa ∈ x⟧ ⟹ list_all2 (≤) xa (sup_aforms optns xi)›*)
by (auto simp: aforms_rel_def (*‹aforms_rel = br Joints top›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*) eucl_of_list_inner (*‹⟦?i ∈ Basis; length ?xs = DIM(?'a)⟧ ⟹ eucl_of_list ?xs ∙ ?i = ?xs ! index Basis_list ?i›*) sup_aforms_def (*‹sup_aforms ?prec ?xs = map (Sup_aform' ?prec) ?xs›*) nth_in_AffineI (*‹⟦?xs ∈ Joints ?XS; ?i < length ?XS⟧ ⟹ ?xs ! ?i ∈ Affine (?XS ! ?i)›*) intro!: Sup_aform'_Affine_ge (*‹?x ∈ Affine ?X ⟹ ?x ≤ Sup_aform' ?p ?X›*) list_all2_all_nthI (*‹⟦length ?a = length ?b; ⋀n. n < length ?a ⟹ ?P (?a ! n) (?b ! n)⟧ ⟹ list_all2 ?P ?a ?b›*))
lemma nres_of_THE_DRES_le:
assumes "⋀v. x = Some v ⟹ RETURN v ≤ y"
shows "nres_of (THE_DRES x) ≤ y"
using assms (*‹x = Some ?v ⟹ RETURN ?v ≤ y›*) by (auto simp: THE_DRES_def (*‹THE_DRES ?xi ≡ case ?xi of None ⇒ dSUCCEED | Some x ⇒ dRETURN x›*) split: option.split (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))›*))
lemma degree_le_fresh_index: "a ∈ set A ⟹ degree_aform a ≤ fresh_index_aforms A"
by (auto simp: fresh_index_aforms_def (*‹fresh_index_aforms ?xs = Max (insert 0 (degree_aform ` set ?xs))›*) intro!: Max_ge (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ ?x ≤ Max ?A›*))
lemma zero_in_JointsI: "xs ∈ Joints XS ⟹ z = (0, zero_pdevs) ⟹ 0 # xs ∈ Joints (z # XS)"
by (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*))
lemma cancel_nonneg_pos_add_multI: "0 ≤ c + c * x"
if "c ≥ 0" "1 + x ≥ 0"
for c x::real
proof (-)
(*goal: ‹(0::real) ≤ (c::real) + c * (x::real)›*)
have "0 ≤ c + c * x ⟷ 0 ≤ c * (1 + x)"
by (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*))
also (*calculation: ‹(0 ≤ c + c * x) = (0 ≤ c * (1 + x))›*) have "… ⟷ 0 ≤ 1 + x"
using that (*‹0 ≤ c› ‹(0::real) ≤ (1::real) + (x::real)›*) by (auto simp: zero_le_mult_iff (*‹(0 ≤ ?a * ?b) = (0 ≤ ?a ∧ 0 ≤ ?b ∨ ?a ≤ 0 ∧ ?b ≤ 0)›*))
finally (*calculation: ‹(0 ≤ c + c * x) = (0 ≤ 1 + x)›*) show "?thesis"
(*goal: ‹(0::real) ≤ (c::real) + c * (x::real)›*)
using that (*‹0 ≤ c› ‹0 ≤ 1 + x›*) by simp
qed
lemma Joints_map_split_aform:
fixes x::"real aform list"
shows "Joints x ⊆ Joints (map (λa. fst (split_aform a i)) x) ∪ Joints (map (λb. snd (split_aform b i)) x)"
unfolding subset_iff
(*goal: ‹∀t. t ∈ Joints x ⟶ t ∈ Joints (map (λa. fst (split_aform a i)) x) ∪ Joints (map (λb. snd (split_aform b i)) x)›*)
apply (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹∀t. t ∈ Joints x ⟶ t ∈ Joints (map (λa. fst (split_aform a i)) x) ∪ Joints (map (λb. snd (split_aform b i)) x)›*)
proof (goal_cases)
(*goal: ‹⋀t::real list. t ∈ Joints (x::(real × real pdevs) list) ⟹ t ∈ Joints (map (λa::real × real pdevs. fst (split_aform a (i::nat))) x) ∪ Joints (map (λb::real × real pdevs. snd (split_aform b i)) x)›*)
case (1 xs) (*‹xs ∈ Joints x›*)
then obtain e where e: "e ∈ funcset UNIV {-1 .. 1}" "xs = map (aform_val e) x"
(*goal: ‹(⋀e. ⟦e ∈ funcset UNIV {- 1..1}; xs = map (aform_val e) x⟧ ⟹ thesis) ⟹ thesis›*)
by (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*))
consider "e i ≥ 0" | "e i ≤ 0"
(*goal: ‹⟦0 ≤ e i ⟹ thesis; e i ≤ 0 ⟹ thesis⟧ ⟹ thesis›*)
by arith
then show "?case"
(*goal: ‹xs ∈ Joints (map (λa. fst (split_aform a i)) x) ∪ Joints (map (λb. snd (split_aform b i)) x)›*)
proof (cases)
(*goals:
1. ‹0 ≤ e i ⟹ xs ∈ Joints (map (λa. fst (split_aform a i)) x) ∪ Joints (map (λb. snd (split_aform b i)) x)›
2. ‹e i ≤ 0 ⟹ xs ∈ Joints (map (λa. fst (split_aform a i)) x) ∪ Joints (map (λb. snd (split_aform b i)) x)›*)
case 1 (*‹0 ≤ e i›*)
let ?e = "e(i:= 2 * e i - 1)"
note e(2) (*‹xs = map (aform_val e) x›*)
also (*calculation: ‹xs = map (aform_val e) x›*) have "map (aform_val e) x = map (aform_val ?e) (map (λb. snd (split_aform b i)) x)"
by (auto simp: aform_val_def (*‹aform_val (?e::nat ⇒ real) (?X::?'a × ?'a pdevs) = fst ?X + pdevs_val ?e (snd ?X)›*) split_aform_def (*‹split_aform (?X::?'a × ?'a pdevs) (?i::nat) = (let xi::?'a = pdevs_apply (snd ?X) ?i /⇩R (2::real) in ((fst ?X - xi, pdev_upd (snd ?X) ?i xi), fst ?X + xi, pdev_upd (snd ?X) ?i xi))›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) divide_simps (*‹inverse (?a::?'a) = (1::?'a) / ?a› ‹(?a::?'a) + (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z + ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (?a + ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (- ?a + ?b * ?z) / ?z)› ‹(?a::?'a) - (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z - ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (?a - ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (- ?a - ?b * ?z) / ?z)› ‹((?b::?'a) / (?c::?'a) = (?a::?'a)) = (if ?c ≠ (0::?'a) then ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = (?b::?'a) / (?c::?'a)) = (if ?c ≠ (0::?'a) then ?a * ?c = ?b else ?a = (0::?'a))› ‹(- ((?b::?'a) / (?c::?'a)) = (?a::?'a)) = (if ?c ≠ (0::?'a) then - ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = - ((?b::?'a) / (?c::?'a))) = (if ?c ≠ (0::?'a) then ?a * ?c = - ?b else ?a = (0::?'a))› ‹((?a::?'a) ≤ (?b::?'a) / (?c::?'a)) = (if (0::?'a) < ?c then ?a * ?c ≤ ?b else if ?c < (0::?'a) then ?b ≤ ?a * ?c else ?a ≤ (0::?'a))› and more 13 facts*) algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 34 facts*))
also (*calculation: ‹xs = map (aform_val (e(i := 2 * e i - 1))) (map (λb. snd (split_aform b i)) x)›*) have "… ∈ Joints (map (λb. snd (split_aform b i)) x)"
using e (*‹e ∈ funcset UNIV {- 1..1}› ‹xs = map (aform_val e) x›*) ‹0 ≤ e i› (*‹0 ≤ e i›*) by (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) Pi_iff (*‹(?f ∈ Pi ?I ?X) = (∀i∈?I. ?f i ∈ ?X i)›*) intro!: image_eqI[where x = ?e] (*‹⟦?b = ?f (e(i := 2 * e i - 1)); e(i := 2 * e i - 1) ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*))
finally (*calculation: ‹xs ∈ Joints (map (λb. snd (split_aform b i)) x)›*) show "?thesis"
(*goal: ‹xs ∈ Joints (map (λa. fst (split_aform a i)) x) ∪ Joints (map (λb. snd (split_aform b i)) x)›*)
by simp
next
(*goal: ‹e i ≤ 0 ⟹ xs ∈ Joints (map (λa. fst (split_aform a i)) x) ∪ Joints (map (λb. snd (split_aform b i)) x)›*)
case 2 (*‹e i ≤ 0›*)
let ?e = "e(i:= 2 * e i + 1)"
note e(2) (*‹xs = map (aform_val e) x›*)
also (*calculation: ‹xs = map (aform_val e) x›*) have "map (aform_val e) x = map (aform_val ?e) (map (λb. fst (split_aform b i)) x)"
by (auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) split_aform_def (*‹split_aform ?X ?i = (let xi = pdevs_apply (snd ?X) ?i /⇩R 2 in ((fst ?X - xi, pdev_upd (snd ?X) ?i xi), fst ?X + xi, pdev_upd (snd ?X) ?i xi))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*))
also (*calculation: ‹xs = map (aform_val (e(i := 2 * e i + 1))) (map (λb. fst (split_aform b i)) x)›*) have "… ∈ Joints (map (λb. fst (split_aform b i)) x)"
using e (*‹e ∈ funcset UNIV {- 1..1}› ‹xs = map (aform_val e) x›*) ‹0 ≥ e i› (*‹e i ≤ 0›*) by (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) Pi_iff (*‹(?f ∈ Pi ?I ?X) = (∀i∈?I. ?f i ∈ ?X i)›*) real_0_le_add_iff (*‹(0 ≤ ?x + ?y) = (- ?x ≤ ?y)›*) intro!: image_eqI[where x = ?e] (*‹⟦?b = ?f (e(i := 2 * e i + 1)); e(i := 2 * e i + 1) ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*) cancel_nonneg_pos_add_multI (*‹⟦0 ≤ ?c; 0 ≤ 1 + ?x⟧ ⟹ 0 ≤ ?c + ?c * ?x›*))
finally (*calculation: ‹xs ∈ Joints (map (λb. fst (split_aform b i)) x)›*) show "?thesis"
(*goal: ‹xs ∈ Joints (map (λa. fst (split_aform a i)) x) ∪ Joints (map (λb. snd (split_aform b i)) x)›*)
by simp
qed
qed
lemma split_aforms_lemma:
fixes x::"real aform list"
assumes "(x, y) ∈ aforms_rel"
assumes "z ⊆ y"
assumes "l = (length x)"
shows "∃a b. (split_aforms x i, a, b)
∈ aforms_rel ×⇩r aforms_rel ∧ env_len a l ∧ env_len b l ∧ z ⊆ a ∪ b"
using assms (*‹(x, y) ∈ aforms_rel› ‹z ⊆ y› ‹l = length x›*) apply (auto simp: split_aforms_def (*‹split_aforms ?xs ?i = (let splits = map (λx. split_aform x ?i) ?xs in (map fst splits, map snd splits))›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*))
(*goal: ‹∃(a::real list set) b::real list set. (split_aforms (x::(real × real pdevs) list) (i::nat), a, b) ∈ aforms_rel ×⇩r aforms_rel ∧ env_len a (l::nat) ∧ env_len b l ∧ (z::real list set) ⊆ a ∪ b›*)
apply (rule exI[where x="Joints (map (λx. fst (split_aform x i)) x)"] (*‹?P (Joints (map (λx. fst (split_aform x i)) x)) ⟹ ∃x. ?P x›*))
(*goal: ‹⟦(x, y) ∈ aforms_rel; z ⊆ y; l = length x⟧ ⟹ ∃a. (map (λx. fst (split_aform x i)) x, a) ∈ aforms_rel ∧ (∃b. (map (λx. snd (split_aform x i)) x, b) ∈ aforms_rel ∧ env_len a (length x) ∧ env_len b (length x) ∧ z ⊆ a ∪ b)›*)
apply auto
(*goal: ‹⟦(x, y) ∈ aforms_rel; z ⊆ y; l = length x⟧ ⟹ (map (λx. fst (split_aform x i)) x, Joints (map (λa. fst (split_aform a i)) x)) ∈ aforms_rel ∧ (∃b. (map (λx. snd (split_aform x i)) x, b) ∈ aforms_rel ∧ env_len (Joints (map (λa. fst (split_aform a i)) x)) (length x) ∧ env_len b (length x) ∧ z ⊆ Joints (map (λa. fst (split_aform a i)) x) ∪ b)›*)
subgoal for
by (auto intro!: brI (*‹⟦?a = ?α ?c; ?I ?c⟧ ⟹ (?c, ?a) ∈ br ?α ?I›*) simp: aforms_rel_def (*‹aforms_rel = br Joints top›*))
apply (rule exI[where x="Joints (map (λx. snd (split_aform x i)) x)"] (*‹(?P::real list set ⇒ bool) (Joints (map (λx::real × real pdevs. snd (split_aform x (i::nat))) (x::(real × real pdevs) list))) ⟹ ∃x::real list set. ?P x›*))
(*goal: ‹⟦(x, y) ∈ aforms_rel; z ⊆ y; l = length x⟧ ⟹ ∃b. (map (λx. snd (split_aform x i)) x, b) ∈ aforms_rel ∧ env_len (Joints (map (λa. fst (split_aform a i)) x)) (length x) ∧ env_len b (length x) ∧ z ⊆ Joints (map (λa. fst (split_aform a i)) x) ∪ b›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹⟦(x, y) ∈ aforms_rel; z ⊆ y; l = length x⟧ ⟹ (map (λx. snd (split_aform x i)) x, Joints (map (λb. snd (split_aform b i)) x)) ∈ aforms_rel ∧ env_len (Joints (map (λa. fst (split_aform a i)) x)) (length x) ∧ env_len (Joints (map (λb. snd (split_aform b i)) x)) (length x) ∧ z ⊆ Joints (map (λa. fst (split_aform a i)) x) ∪ Joints (map (λb. snd (split_aform b i)) x)›*)
subgoal for
by (auto intro!: brI (*‹⟦?a = ?α ?c; ?I ?c⟧ ⟹ (?c, ?a) ∈ br ?α ?I›*) simp: aforms_rel_def (*‹aforms_rel = br Joints top›*))
subgoal for
using Joints_map_split_aform[of x i] (*‹Joints x ⊆ Joints (map (λa. fst (split_aform a i)) x) ∪ Joints (map (λb. snd (split_aform b i)) x)›*) by (auto simp: br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) aforms_rel_def (*‹aforms_rel = br Joints top›*) env_len_def (*‹env_len ?env ?l = (∀xs∈?env. length xs = ?l)›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*)) .
lemma length_summarize_pdevs_list[simp]:
"length (summarize_pdevs_list a b c d) = length d"
by (auto simp: summarize_pdevs_list_def (*‹summarize_pdevs_list ?p ?I ?d ?xs = map2 (summarize_pdevs ?p (λi _. ?I i (pdevs_applys ?xs i))) [?d..<?d + length ?xs] ?xs›*))
lemma length_summarize_aforms[simp]:
"length (summarize_aforms a b e d) = length d"
by (auto simp: summarize_aforms_def (*‹summarize_aforms ?p ?C ?d ?X = zip (map fst ?X) (summarize_pdevs_list ?p (?C ?X) ?d (map snd ?X))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*))
lemma
split_aform_largest_take_refine:
"(ni, n) ∈ nat_rel ⟹
(xi::real aform list, x) ∈ aforms_rel ⟹
length xi = d ⟹ (RETURN (split_aforms_largest_uncond_take ni xi), split_spec_params d n x) ∈ ⟨aforms_rel ×⇩r aforms_rel⟩nres_rel"
apply (auto simp: split_spec_params_def (*‹split_spec_params (?d::nat) (?n::?'b::type) (?X::?'a::type list set) = SPEC (λ(A::?'a::type list set, B::?'a::type list set). env_len A ?d ∧ env_len B ?d ∧ ?X ⊆ A ∪ B)›*) nres_rel_def (*‹⟨?R::(?'a::type × ?'b::type) set⟩nres_rel ≡ {(c::?'a::type nres, a::?'b::type nres). c ≤ ⇓ ?R a}›*) aforms_relp_def (*‹⟨?R::(?'a::real_normed_vector list × ?'b::type) set⟩aforms_relp = aforms_rel O ⟨?R⟩set_rel›*) mem_lv_rel_set_rel_iff (*‹((?y::real list set, ?z::?'a::executable_euclidean_space set) ∈ ⟨lv_rel⟩set_rel) = (?z = eucl_of_list ` ?y ∧ (∀x::real list∈?y. length x = DIM(?'a::executable_euclidean_space)))›*) split_aforms_largest_uncond_take_def (*‹split_aforms_largest_uncond_take (?n::nat) (?X::(?'a::{euclidean_space,abs} × ?'a::{euclidean_space,abs} pdevs) list) = (let (i::nat, x::?'a::{euclidean_space,abs}) = max_pdev (abssum_of_pdevs_list (map snd (take ?n ?X))) in split_aforms ?X i)›*) Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*) comps (*‹(∘) ≡ λ(f::?'b::type ⇒ ?'c::type) (g::?'a::type ⇒ ?'b::type) x::?'a::type. f (g x)› ‹(o2) ≡ λ(f::?'b::type ⇒ ?'a::type) (g::?'c::type ⇒ ?'d::type ⇒ ?'b::type) (x::?'c::type) y::?'d::type. f (g x y)› ‹(o3) ≡ λ(f::?'b::type ⇒ ?'a::type) (g::?'c::type ⇒ ?'d::type ⇒ ?'e::type ⇒ ?'b::type) (x::?'c::type) (y::?'d::type) z::?'e::type. f (g x y z)› ‹(o4) ≡ λ(f::?'b::type ⇒ ?'a::type) (g::?'c::type ⇒ ?'d::type ⇒ ?'e::type ⇒ ?'f::type ⇒ ?'b::type) (w::?'c::type) (x::?'d::type) (y::?'e::type) z::?'f::type. f (g w x y z)› ‹(o5) ≡ λ(f::?'b::type ⇒ ?'a::type) (g::?'c::type ⇒ ?'d::type ⇒ ?'e::type ⇒ ?'f::type ⇒ ?'g::type ⇒ ?'b::type) (w::?'c::type) (x::?'d::type) (y::?'e::type) (z::?'f::type) a::?'g::type. f (g w x y z a)› ‹(o6) ≡ λ(f::?'b::type ⇒ ?'a::type) (g::?'c::type ⇒ ?'d::type ⇒ ?'e::type ⇒ ?'f::type ⇒ ?'g::type ⇒ ?'h::type ⇒ ?'b::type) (w::?'c::type) (x::?'d::type) (y::?'e::type) (z::?'f::type) (a::?'g::type) b::?'h::type. f (g w x y z a b)›*) split: prod.splits (*‹(?P::?'c::type ⇒ bool) (case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = (∀(x1::?'a::type) x2::?'b::type. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c::type ⇒ bool) (case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = (∄(x1::?'a::type) x2::?'b::type. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) intro!: RETURN_SPEC_refine (*‹∃x'::?'a::type. (?x::?'b::type, x') ∈ (?R::(?'b::type × ?'a::type) set) ∧ (?Φ::?'a::type ⇒ bool) x' ⟹ RETURN ?x ≤ ⇓ ?R (SPEC ?Φ)›*))
(*goal: ‹⟦(ni::nat, n::nat) ∈ nat_rel; (xi::(real × real pdevs) list, x::real list set) ∈ aforms_rel; length xi = (d::nat)⟧ ⟹ (RETURN (split_aforms_largest_uncond_take ni xi), split_spec_params d n x) ∈ ⟨aforms_rel ×⇩r aforms_rel⟩nres_rel›*)
apply (rule split_aforms_lemma (*‹⟦(?x::(real × real pdevs) list, ?y::real list set) ∈ aforms_rel; (?z::real list set) ⊆ ?y; (?l::nat) = length ?x⟧ ⟹ ∃(a::real list set) b::real list set. (split_aforms ?x (?i::nat), a, b) ∈ aforms_rel ×⇩r aforms_rel ∧ env_len a ?l ∧ env_len b ?l ∧ ?z ⊆ a ∪ b›*))
(*goals:
1. ‹⋀x1 x2. ⟦ni = n; (xi, x) ∈ aforms_rel; d = length xi; max_pdev (abssum_of_pdevs_list (map snd (take n xi))) = (x1, x2)⟧ ⟹ (xi, ?y12 x1 x2) ∈ aforms_rel›
2. ‹⋀x1 x2. ⟦ni = n; (xi, x) ∈ aforms_rel; d = length xi; max_pdev (abssum_of_pdevs_list (map snd (take n xi))) = (x1, x2)⟧ ⟹ x ⊆ ?y12 x1 x2›
3. ‹⋀x1 x2. ⟦ni = n; (xi, x) ∈ aforms_rel; d = length xi; max_pdev (abssum_of_pdevs_list (map snd (take n xi))) = (x1, x2)⟧ ⟹ length xi = length xi›
discuss goal 1*)
apply ((auto simp add: aforms_rel_def (*‹aforms_rel = br Joints top›*))[1])
(*discuss goal 2*)
apply ((auto simp add: aforms_rel_def (*‹aforms_rel = br Joints top›*))[1])
(*discuss goal 3*)
apply ((auto simp add: aforms_rel_def (*‹aforms_rel = br Joints top›*))[1])
(*proven 3 subgoals*) .
lemma aform_val_pdevs_of_real[simp]: "aform_val e (pdevs_of_real x) = x"
by (auto simp: pdevs_of_real_def (*‹pdevs_of_real (?x::?'a::type) = (?x, zero_pdevs)›*))
lemma degree_aform_pdevs_of_real[simp]: "degree_aform (pdevs_of_real x) = 0"
by (auto simp: pdevs_of_real_def (*‹pdevs_of_real ?x = (?x, zero_pdevs)›*))
lemma interpret_floatarith_inner_eq:
shows "interpret_floatarith (inner_floatariths xs ys) vs =
(∑(x, y) ← (zip xs ys). (interpret_floatarith x vs) * (interpret_floatarith y vs))"
apply (induction xs ys rule: inner_floatariths.induct (*‹⟦⋀uu_. ?P [] uu_; ⋀v va. ?P (v # va) []; ⋀x xs y ys. ?P xs ys ⟹ ?P (x # xs) (y # ys)⟧ ⟹ ?P ?a0.0 ?a1.0›*))
(*goals:
1. ‹⋀uu_. interpret_floatarith (inner_floatariths [] uu_) vs = sum_list (map2 (λx y. interpret_floatarith x vs * interpret_floatarith y vs) [] uu_)›
2. ‹⋀v va. interpret_floatarith (inner_floatariths (v # va) []) vs = sum_list (map2 (λx y. interpret_floatarith x vs * interpret_floatarith y vs) (v # va) [])›
3. ‹⋀x xs y ys. interpret_floatarith (inner_floatariths xs ys) vs = sum_list (map2 (λx y. interpret_floatarith x vs * interpret_floatarith y vs) xs ys) ⟹ interpret_floatarith (inner_floatariths (x # xs) (y # ys)) vs = sum_list (map2 (λx y. interpret_floatarith x vs * interpret_floatarith y vs) (x # xs) (y # ys))›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
lemma approx_slp_outer_sing:
"approx_slp_outer p (Suc 0) [fa] XS = Some R ⟷ (∃Y.
approx_floatarith p fa (map (λx. (x, 0)) XS) = Some Y ∧
[aform_err_to_aform Y (max (degree_aforms XS) (degree_aform_err Y))] = R)"
by (auto simp: approx_slp_outer_def (*‹approx_slp_outer ?p ?n ?slp ?XS = (let d = degree_aforms ?XS; XSe = map (λx. (x, 0)) ?XS in approx_slp ?p ?slp XSe ⤜ (λrs. let rs' = take ?n rs; d' = max d (degree_aforms_err rs') in Some (aforms_err_to_aforms d' rs')))›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*))
lemma aforms_err_aform_valsI:
assumes "vs = aform_vals e XS"
shows "vs ∈ aforms_err e (map (λx. (x, 0)) (XS))"
by (auto simp: assms (*‹vs = aform_vals e XS›*) aforms_err_def (*‹aforms_err ?e ?xs = listset (map (aform_err ?e) ?xs)›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*) aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*))
lemma aform_val_degree_cong:
"b = d ⟹ (⋀i. i < degree_aform d ⟹ a i = c i) ⟹ aform_val a b = aform_val c d"
by (auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) intro!: pdevs_val_degree_cong (*‹⟦?b = ?d; ⋀i. i < degree ?b ⟹ ?a i = ?c i⟧ ⟹ pdevs_val ?a ?b = pdevs_val ?c ?d›*))
lemma mem_degree_aformD: "x ∈ set XS ⟹ degree_aform x ≤ degree_aforms XS"
by (auto simp: degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*))
lemma degrees_append_leD1: "(degrees xs) ≤ degrees (xs @ ys)"
unfolding degrees_def
(*goal: ‹Max (insert 0 (degree ` set xs)) ≤ Max (insert 0 (degree ` set (xs @ ys)))›*)
apply (rule Max_mono (*‹⟦(?M::?'a set) ⊆ (?N::?'a set); ?M ≠ {}; finite ?N⟧ ⟹ Max ?M ≤ Max ?N›*))
(*goals:
1. ‹insert (0::nat) (degree ` set (xs::'a::real_vector pdevs list)) ⊆ insert (0::nat) (degree ` set (xs @ (ys::'a::real_vector pdevs list)))›
2. ‹insert (0::nat) (degree ` set (xs::'a::real_vector pdevs list)) ≠ {}›
3. ‹finite (insert (0::nat) (degree ` set ((xs::'a::real_vector pdevs list) @ (ys::'a::real_vector pdevs list))))›
discuss goal 1*)
apply ((auto simp: degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) Max_ge_iff (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ (?x ≤ Max ?A) = (∃a∈?A. ?x ≤ a)›*) image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) Max_gr_iff (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ (?x < Max ?A) = (∃a∈?A. ?x < a)›*))[1])
(*discuss goal 2*)
apply ((auto simp: degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) Max_ge_iff (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ (?x ≤ Max ?A) = (∃a∈?A. ?x ≤ a)›*) image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) Max_gr_iff (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ (?x < Max ?A) = (∃a∈?A. ?x < a)›*))[1])
(*discuss goal 3*)
apply ((auto simp: degrees_def (*‹degrees (?X::?'a pdevs list) = Max (insert (0::nat) (degree ` set ?X))›*) min_def (*‹min (?a::?'a) (?b::?'a) = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max (?a::?'a) (?b::?'a) = (if ?a ≤ ?b then ?b else ?a)›*) Max_ge_iff (*‹⟦finite (?A::?'a set); ?A ≠ {}⟧ ⟹ ((?x::?'a) ≤ Max ?A) = (∃a::?'a∈?A. ?x ≤ a)›*) image_Un (*‹(?f::?'b ⇒ ?'a) ` ((?A::?'b set) ∪ (?B::?'b set)) = ?f ` ?A ∪ ?f ` ?B›*) Max_gr_iff (*‹⟦finite (?A::?'a set); ?A ≠ {}⟧ ⟹ ((?x::?'a) < Max ?A) = (∃a::?'a∈?A. ?x < a)›*))[1])
(*proven 3 subgoals*) .
lemma inner_aforms':
assumes "xs ∈ Joints XS"
assumes "inner_aforms' p XS (map pdevs_of_real rs) = Some R"
shows "(∑(x, y) ← (zip xs rs). x * y) ∈ Affine (hd R)" (is ?th1) "length R = 1" (is ?th2)
proof (-)
(*goals:
1. ‹sum_list (map2 (*) xs rs) ∈ Affine (hd R)›
2. ‹length R = 1›*)
from assms (*‹xs ∈ Joints XS› ‹inner_aforms' (p::nat) (XS::(real × real pdevs) list) (map pdevs_of_real (rs::real list)) = Some (R::(real × real pdevs) list)›*) obtain e where "e ∈ funcset UNIV {-1 .. 1}" "xs = aform_vals e XS"
(*goal: ‹(⋀e. ⟦e ∈ funcset UNIV {- 1..1}; xs = aform_vals e XS⟧ ⟹ thesis) ⟹ thesis›*)
by (auto simp: Joints_def (*‹Joints (?XS::(?'a × ?'a pdevs) list) = valuate (λe::nat ⇒ real. map (aform_val e) ?XS)›*) valuate_def (*‹valuate (?x::(nat ⇒ real) ⇒ ?'a) = ?x ` funcset UNIV {- (1::real)..1::real}›*) aform_vals_def (*‹aform_vals (?e::nat ⇒ real) (?X::(?'a × ?'a pdevs) list) = map (aform_val ?e) ?X›*))
then have e: "xs @ rs = aform_vals e (XS @ map pdevs_of_real rs)" "xs @ rs ∈ Joints (XS @ map pdevs_of_real rs)" "length xs = length XS" "e ∈ funcset UNIV {- 1..1}"
apply -
(*goals:
1. ‹⟦e ∈ funcset UNIV {- 1..1}; xs = aform_vals e XS⟧ ⟹ xs @ rs = aform_vals e (XS @ map pdevs_of_real rs)›
2. ‹⟦e ∈ funcset UNIV {- 1..1}; xs = aform_vals e XS⟧ ⟹ xs @ rs ∈ Joints (XS @ map pdevs_of_real rs)›
3. ‹⟦e ∈ funcset UNIV {- 1..1}; xs = aform_vals e XS⟧ ⟹ length xs = length XS›
4. ‹⟦e ∈ funcset UNIV {- 1..1}; xs = aform_vals e XS⟧ ⟹ e ∈ funcset UNIV {- 1..1}›
discuss goal 1*)
apply ((auto simp: aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*) Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*))[1])
(*discuss goal 2*)
apply ((auto simp: aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*) Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*))[1])
(*discuss goal 3*)
apply ((auto simp: aform_vals_def (*‹aform_vals (?e::nat ⇒ real) (?X::(?'a × ?'a pdevs) list) = map (aform_val ?e) ?X›*) o_def (*‹(?f::?'b ⇒ ?'c) ∘ (?g::?'a ⇒ ?'b) = (λx::?'a. ?f (?g x))›*) degrees_def (*‹degrees (?X::?'a pdevs list) = Max (insert (0::nat) (degree ` set ?X))›*) Joints_def (*‹Joints (?XS::(?'a × ?'a pdevs) list) = valuate (λe::nat ⇒ real. map (aform_val e) ?XS)›*) valuate_def (*‹valuate (?x::(nat ⇒ real) ⇒ ?'a) = ?x ` funcset UNIV {- (1::real)..1::real}›*))[1])
(*discuss goal 4*)
apply ((auto simp: aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*) Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*))[1])
(*proven 4 subgoals*) .
have "approx_slp_outer p (Suc 0)
([inner_floatariths (map floatarith.Var [0..<length XS])
(map floatarith.Var [length XS..<length XS + length rs])])
(XS @ map pdevs_of_real rs) =
Some R"
using assms(2) (*‹inner_aforms' p XS (map pdevs_of_real rs) = Some R›*) by (auto simp: inner_aforms'_def (*‹inner_aforms' ?p ?X ?Y = (let fas = [inner_floatariths (map floatarith.Var [0..<length ?X]) (map floatarith.Var [length ?X..<length ?X + length ?Y])] in approx_slp_outer ?p (length fas) fas (?X @ ?Y))›*))
then obtain Y where Y: "approx_floatarith p
(inner_floatariths (map floatarith.Var [0..<length XS])
(map floatarith.Var [length XS..<length XS + length rs]))
(map (λx. (x, 0)) (XS @ map pdevs_of_real rs)) =
Some Y" "R = [aform_err_to_aform Y (max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y))]"
(*goal: ‹(⋀Y. ⟦approx_floatarith p (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (map (λx. (x, 0)) (XS @ map pdevs_of_real rs)) = Some Y; R = [aform_err_to_aform Y (max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y))]⟧ ⟹ thesis) ⟹ thesis›*)
unfolding approx_slp_outer_sing
(*goal: ‹(⋀Y. ⟦approx_floatarith p (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (map (λx. (x, 0)) (XS @ map pdevs_of_real rs)) = Some Y; R = [aform_err_to_aform Y (max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y))]⟧ ⟹ thesis) ⟹ thesis›*)
by auto
let ?m = "(max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y))"
from approx_floatarith_Elem[OF Y ( 1 ) e ( 4 ) aforms_err_aform_valsI [ OF e ( 1 ) ]] (*‹interpret_floatarith (inner_floatariths (map floatarith.Var [0::nat..<length (XS::(real × real pdevs) list)]) (map floatarith.Var [length XS..<length XS + length (rs::real list)])) ((xs::real list) @ rs) ∈ aform_err (e::nat ⇒ real) (Y::(real × real pdevs) × real)›*) have "interpret_floatarith
(inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs]))
(xs @ rs)
∈ aform_err e Y" "degree_aform_err Y ≤ max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y)"
apply -
(*goals:
1. ‹interpret_floatarith (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (xs @ rs) ∈ aform_err e Y ⟹ interpret_floatarith (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (xs @ rs) ∈ aform_err e Y›
2. ‹interpret_floatarith (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (xs @ rs) ∈ aform_err e Y ⟹ degree_aform_err Y ≤ max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
from aform_err_to_aformE[OF this] (*‹(⋀err. ⟦interpret_floatarith (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (xs @ rs) = aform_val (e(max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y) := err)) (aform_err_to_aform Y (max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y))); - 1 ≤ err; err ≤ 1⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain err where err: "interpret_floatarith
(inner_floatariths (map floatarith.Var [0..<length XS])
(map floatarith.Var [length XS..<length XS + length rs]))
(xs @ rs) =
aform_val (e(max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y) := err))
(aform_err_to_aform Y (max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y)))" "- 1 ≤ err" "err ≤ 1"
(*goal: ‹(⋀err. ⟦interpret_floatarith (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (xs @ rs) = aform_val (e(max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y) := err)) (aform_err_to_aform Y (max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y))); - 1 ≤ err; err ≤ 1⟧ ⟹ thesis) ⟹ thesis›*)
by auto
let ?e' = "(e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err))"
from e(1) (*‹xs @ rs = aform_vals e (XS @ map pdevs_of_real rs)›*) have e': "xs @ rs = aform_vals ?e' (XS @ map pdevs_of_real rs)"
apply (auto simp: aform_vals_def (*‹aform_vals (?e::nat ⇒ real) (?X::(?'a × ?'a pdevs) list) = map (aform_val ?e) ?X›*) intro!: aform_val_degree_cong (*‹⟦(?b::?'a × ?'a pdevs) = (?d::?'a × ?'a pdevs); ⋀i::nat. i < degree_aform ?d ⟹ (?a::nat ⇒ real) i = (?c::nat ⇒ real) i⟧ ⟹ aform_val ?a ?b = aform_val ?c ?d›*))
(*goals:
1. ‹⋀a b. ⟦xs = map (aform_val e) XS; rs = map (aform_val e ∘ pdevs_of_real) rs; (a, b) ∈ set XS; degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs) < degree b; degree_aform_err Y < degree b⟧ ⟹ e (max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y)) = err›
2. ‹⟦xs = map (aform_val e) XS; rs = map (aform_val e ∘ pdevs_of_real) rs⟧ ⟹ rs = map (aform_val (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err)) ∘ pdevs_of_real) rs›
discuss goal 1*)
apply (frule mem_degree_aformD (*‹?x ∈ set ?XS ⟹ degree_aform ?x ≤ degree_aforms ?XS›*))
(*top goal: ‹⋀a b. ⟦xs = map (aform_val e) XS; rs = map (aform_val e ∘ pdevs_of_real) rs; (a, b) ∈ set XS; degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs) < degree b; degree_aform_err Y < degree b⟧ ⟹ e (max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y)) = err› and 1 goal remains*)
apply (frule le_less_trans[OF degrees_append_leD1] (*‹degrees (?xs1 @ ?ys1) < ?z ⟹ degrees ?xs1 < ?z›*))
(*top goal: ‹⋀a b. ⟦xs = map (aform_val e) XS; rs = map (aform_val e ∘ pdevs_of_real) rs; (a, b) ∈ set XS; degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs) < degree b; degree_aform_err Y < degree b; degree_aform (a, b) ≤ degree_aforms XS⟧ ⟹ e (max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y)) = err› and 1 goal remains*)
apply ((auto simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*))[1])
(*discuss goal 2*)
apply ((auto simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*))[1])
(*proven 2 subgoals*) .
from err (*‹interpret_floatarith (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (xs @ rs) = aform_val (e(max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y) := err)) (aform_err_to_aform Y (max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y)))› ‹- 1 ≤ err› ‹err ≤ 1›*) have "interpret_floatarith
(inner_floatariths (map floatarith.Var [0..<length XS])
(map floatarith.Var [length XS..<length XS + length rs]))
(xs @ rs)#xs@rs ∈ Joints (R @ XS @ map pdevs_of_real rs)"
using e(1,3,4) (*‹xs @ rs = aform_vals e (XS @ map pdevs_of_real rs)› ‹length xs = length XS› ‹e ∈ funcset UNIV {- 1..1}›*) e' (*‹xs @ rs = aform_vals (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err)) (XS @ map pdevs_of_real rs)›*) apply (auto simp: valuate_def (*‹valuate (?x::(nat ⇒ real) ⇒ ?'a::type) = ?x ` funcset UNIV {- (1::real)..1::real}›*) Joints_def (*‹Joints (?XS::(?'a::real_normed_vector × ?'a::real_normed_vector pdevs) list) = valuate (λe::nat ⇒ real. map (aform_val e) ?XS)›*) intro!: nth_equalityI (*‹⟦length (?xs::?'a::type list) = length (?ys::?'a::type list); ⋀i::nat. i < length ?xs ⟹ ?xs ! i = ?ys ! i⟧ ⟹ ?xs = ?ys›*) image_eqI[where x="?e'"] (*‹⟦(?b::?'a::type) = (?f::(nat ⇒ real) ⇒ ?'a::type) ((e::nat ⇒ real)(max (degrees (map snd (XS::(real × real pdevs) list) @ map (snd ∘ pdevs_of_real) (rs::real list))) (degree_aform_err (Y::(real × real pdevs) × real)) := err::real)); e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err) ∈ (?A::(nat ⇒ real) set)⟧ ⟹ ?b ∈ ?f ` ?A›*))
(*goals:
1. ‹⟦interpret_floatarith (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (aform_vals e (XS @ map pdevs_of_real rs)) = aform_val (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err)) (aform_err_to_aform Y (max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y))); - 1 ≤ err; err ≤ 1; aform_vals (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err)) (XS @ map pdevs_of_real rs) = aform_vals e (XS @ map pdevs_of_real rs); length xs = length XS; e ∈ funcset UNIV {- 1..1}; xs @ rs = aform_vals e (XS @ map pdevs_of_real rs)⟧ ⟹ Suc (length (aform_vals e (XS @ map pdevs_of_real rs))) = length R + (length XS + length rs)›
2. ‹⋀i. ⟦interpret_floatarith (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (aform_vals e (XS @ map pdevs_of_real rs)) = aform_val (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err)) (aform_err_to_aform Y (max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y))); - 1 ≤ err; err ≤ 1; aform_vals (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err)) (XS @ map pdevs_of_real rs) = aform_vals e (XS @ map pdevs_of_real rs); length xs = length XS; e ∈ funcset UNIV {- 1..1}; xs @ rs = aform_vals e (XS @ map pdevs_of_real rs); i < Suc (length (aform_vals e (XS @ map pdevs_of_real rs)))⟧ ⟹ (aform_val (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err)) (aform_err_to_aform Y (max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y))) # aform_vals e (XS @ map pdevs_of_real rs)) ! i = (map (aform_val (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err))) R @ map (aform_val (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err))) XS @ map (aform_val (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err)) ∘ pdevs_of_real) rs) ! i›
discuss goal 1*)
apply (simp add: Y (*‹approx_floatarith p (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (map (λx. (x, 0)) (XS @ map pdevs_of_real rs)) = Some Y› ‹R = [aform_err_to_aform Y (max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y))]›*) aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*))
(*discuss goal 2*)
apply (simp add: Y (*‹approx_floatarith p (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (map (λx. (x, 0)) (XS @ map pdevs_of_real rs)) = Some Y› ‹R = [aform_err_to_aform Y (max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y))]›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*))
(*goal: ‹⋀i. ⟦interpret_floatarith (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (aform_vals e (XS @ map pdevs_of_real rs)) = aform_val (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err)) (aform_err_to_aform Y (max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y))); - 1 ≤ err; err ≤ 1; aform_vals (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err)) (XS @ map pdevs_of_real rs) = aform_vals e (XS @ map pdevs_of_real rs); length xs = length XS; e ∈ funcset UNIV {- 1..1}; xs @ rs = aform_vals e (XS @ map pdevs_of_real rs); i < Suc (length (aform_vals e (XS @ map pdevs_of_real rs)))⟧ ⟹ (aform_val (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err)) (aform_err_to_aform Y (max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y))) # aform_vals e (XS @ map pdevs_of_real rs)) ! i = (map (aform_val (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err))) R @ map (aform_val (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err))) XS @ map (aform_val (e(max (degrees (map snd XS @ map (snd ∘ pdevs_of_real) rs)) (degree_aform_err Y) := err)) ∘ pdevs_of_real) rs) ! i›*)
apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) nth_Cons (*‹(?x # ?xs) ! ?n = (case ?n of 0 ⇒ ?x | Suc k ⇒ ?xs ! k)›*))
(*goal: ‹⋀i. ⟦interpret_floatarith (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (aform_vals e (XS @ map pdevs_of_real rs)) = aform_val (e(max (degrees (map snd XS @ map (λx. snd (pdevs_of_real x)) rs)) (degree_aform_err Y) := err)) (aform_err_to_aform Y (max (degrees (map snd XS @ map (λx. snd (pdevs_of_real x)) rs)) (degree_aform_err Y))); - 1 ≤ err; err ≤ 1; aform_vals (e(max (degrees (map snd XS @ map (λx. snd (pdevs_of_real x)) rs)) (degree_aform_err Y) := err)) (XS @ map pdevs_of_real rs) = aform_vals e (XS @ map pdevs_of_real rs); length xs = length XS; e ∈ funcset UNIV {- 1..1}; xs @ rs = aform_vals e (XS @ map pdevs_of_real rs); i < Suc (length (aform_vals e (XS @ map pdevs_of_real rs)))⟧ ⟹ (aform_val (e(max (degrees (map snd XS @ map (λx. snd (pdevs_of_real x)) rs)) (degree_aform_err Y) := err)) (aform_err_to_aform Y (max (degrees (map snd XS @ map (λx. snd (pdevs_of_real x)) rs)) (degree_aform_err Y))) # aform_vals e (XS @ map pdevs_of_real rs)) ! i = (aform_val (e(max (degrees (map snd XS @ map (λx. snd (pdevs_of_real x)) rs)) (degree_aform_err Y) := err)) (aform_err_to_aform Y (max (degrees (map snd XS @ map (λx. snd (pdevs_of_real x)) rs)) (degree_aform_err Y))) # map (aform_val (e(max (degrees (map snd XS @ map (λx. snd (pdevs_of_real x)) rs)) (degree_aform_err Y) := err))) XS @ rs) ! i›*)
apply (auto split: nat.splits (*‹(?P::?'a ⇒ bool) (case ?nat::nat of 0::nat ⇒ ?f1.0::?'a | Suc (x::nat) ⇒ (?f2.0::nat ⇒ ?'a) x) = ((?nat = (0::nat) ⟶ ?P ?f1.0) ∧ (∀x2::nat. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'a ⇒ bool) (case ?nat::nat of 0::nat ⇒ ?f1.0::?'a | Suc (x::nat) ⇒ (?f2.0::nat ⇒ ?'a) x) = (¬ (?nat = (0::nat) ∧ ¬ ?P ?f1.0 ∨ (∃x2::nat. ?nat = Suc x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) nth_Cons (*‹((?x::?'a) # (?xs::?'a list)) ! (?n::nat) = (case ?n of 0::nat ⇒ ?x | Suc (k::nat) ⇒ ?xs ! k)›*) aform_vals_def (*‹aform_vals (?e::nat ⇒ real) (?X::(?'a × ?'a pdevs) list) = map (aform_val ?e) ?X›*))
(*proven 2 subgoals*) .
then have "(∑(x, y)←zip (map floatarith.Var [0..<length XS])
(map floatarith.Var
[length XS..<
length XS + length rs]). interpret_floatarith x (xs @ rs) * interpret_floatarith y (xs @ rs)) #
xs @ rs
∈ Joints (R @ XS @ map pdevs_of_real rs)"
apply (subst (asm)interpret_floatarith_inner_eq (*‹interpret_floatarith (inner_floatariths ?xs ?ys) ?vs = sum_list (map2 (λx y. interpret_floatarith x ?vs * interpret_floatarith y ?vs) ?xs ?ys)›*))
(*goal: ‹sum_list (map2 (λx y. interpret_floatarith x (xs @ rs) * interpret_floatarith y (xs @ rs)) (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) # xs @ rs ∈ Joints (R @ XS @ map pdevs_of_real rs)›*)
by (auto simp:)
also (*calculation: ‹sum_list (map2 (λx y. interpret_floatarith x (xs @ rs) * interpret_floatarith y (xs @ rs)) (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) # xs @ rs ∈ Joints (R @ XS @ map pdevs_of_real rs)›*) have "(∑(x, y)←zip (map floatarith.Var [0..<length XS])
(map floatarith.Var
[length XS..<
length XS + length rs]). interpret_floatarith x (xs @ rs) * interpret_floatarith y (xs @ rs)) =
(∑(x, y)←zip xs rs. x * y)"
by (auto simp: sum_list_sum_nth (*‹sum_list (?xs::?'b list) = sum ((!) ?xs) {0::nat..<length ?xs}›*) assms (*‹(xs::real list) ∈ Joints (XS::(real × real pdevs) list)› ‹inner_aforms' (p::nat) (XS::(real × real pdevs) list) (map pdevs_of_real (rs::real list)) = Some (R::(real × real pdevs) list)›*) e( (*‹length (xs::real list) = length (XS::(real × real pdevs) list)›*) 3) nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) intro!: sum.cong (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B ⟹ (?g::?'b ⇒ ?'a) x = (?h::?'b ⇒ ?'a) x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
finally (*calculation: ‹sum_list (map2 (*) xs rs) # xs @ rs ∈ Joints (R @ XS @ map pdevs_of_real rs)›*) show "?th1" "?th2"
apply -
(*goals:
1. ‹sum_list (map2 (*) xs rs) # xs @ rs ∈ Joints (R @ XS @ map pdevs_of_real rs) ⟹ sum_list (map2 (*) xs rs) ∈ Affine (hd R)›
2. ‹sum_list (map2 (*) xs rs) # xs @ rs ∈ Joints (R @ XS @ map pdevs_of_real rs) ⟹ length R = 1›
discuss goal 1*)
apply ((auto simp: Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) Y (*‹approx_floatarith p (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (map (λx. (x, 0)) (XS @ map pdevs_of_real rs)) = Some Y› ‹R = [aform_err_to_aform Y (max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y))]›*))[1])
(*discuss goal 2*)
apply ((auto simp: Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) Y (*‹approx_floatarith p (inner_floatariths (map floatarith.Var [0..<length XS]) (map floatarith.Var [length XS..<length XS + length rs])) (map (λx. (x, 0)) (XS @ map pdevs_of_real rs)) = Some Y› ‹R = [aform_err_to_aform Y (max (degree_aforms (XS @ map pdevs_of_real rs)) (degree_aform_err Y))]›*))[1])
(*proven 2 subgoals*) .
qed
lemma inner_aforms'_inner_lv_rel:
"(a, a') ∈ aforms_rel ⟹
inner_aforms' prec a (map pdevs_of_real a'a) = Some R ⟹
x ∈ a' ⟹ inner_lv_rel x a'a ∈ Affine (hd R)"
unfolding mem_lv_rel_set_rel_iff
(*goal: ‹⟦(a, a') ∈ aforms_rel; inner_aforms' prec a (map pdevs_of_real a'a) = Some R; x ∈ a'⟧ ⟹ inner_lv_rel x a'a ∈ Affine (hd R)›*)
unfolding lv_rel_def aforms_rel_def
(*goal: ‹⟦(a, a') ∈ br Joints top; inner_aforms' prec a (map pdevs_of_real a'a) = Some R; x ∈ a'⟧ ⟹ inner_lv_rel x a'a ∈ Affine (hd R)›*)
apply (auto simp: br_def (*‹br (?α::?'a::type ⇒ ?'b::type) (?I::?'a::type ⇒ bool) ≡ {(c::?'a::type, a::?'b::type). a = ?α c ∧ ?I c}›*))
(*goal: ‹⟦(a, a') ∈ br Joints top; inner_aforms' prec a (map pdevs_of_real a'a) = Some R; x ∈ a'⟧ ⟹ inner_lv_rel x a'a ∈ Affine (hd R)›*)
apply (subst arg_cong2[where f="(∈)", OF _ refl] (*‹?a = ?b ⟹ (?a ∈ ?c) = (?b ∈ ?c)›*))
(*goals:
1. ‹⟦a' = Joints a; inner_aforms' prec a (map pdevs_of_real a'a) = Some R; x ∈ Joints a⟧ ⟹ inner_lv_rel x a'a = ?b1›
2. ‹⟦a' = Joints a; inner_aforms' prec a (map pdevs_of_real a'a) = Some R; x ∈ Joints a⟧ ⟹ ?b1 ∈ Affine (hd R)›
discuss goal 1*)
apply ((auto simp: br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*) inner_lv_rel_def (*‹inner_lv_rel ?a ?b = sum_list (map2 (*) ?a ?b)›*))[1])
(*discuss goal 2*)
apply (rule inner_aforms' (*‹⟦?xs ∈ Joints ?XS; inner_aforms' ?p ?XS (map pdevs_of_real ?rs) = Some ?R⟧ ⟹ sum_list (map2 (*) ?xs ?rs) ∈ Affine (hd ?R)› ‹⟦?xs ∈ Joints ?XS; inner_aforms' ?p ?XS (map pdevs_of_real ?rs) = Some ?R⟧ ⟹ length ?R = 1›*))
(*goals:
1. ‹⟦a' = Joints a; inner_aforms' prec a (map pdevs_of_real a'a) = Some R; x ∈ Joints a⟧ ⟹ x ∈ Joints ?XS5›
2. ‹⟦a' = Joints a; inner_aforms' prec a (map pdevs_of_real a'a) = Some R; x ∈ Joints a⟧ ⟹ inner_aforms' ?p5 ?XS5 (map pdevs_of_real a'a) = Some R›
discuss goal 1*)
apply ((auto simp: br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*) inner_lv_rel_def (*‹inner_lv_rel ?a ?b = sum_list (map2 (*) ?a ?b)›*))[1])
(*discuss goal 2*)
apply ((auto simp: br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*) inner_lv_rel_def (*‹inner_lv_rel ?a ?b = sum_list (map2 (*) ?a ?b)›*))[1])
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
lemma aform_inf_inner_refine:
"(RETURN o2 aform_inf_inner optns, Inf_inners) ∈ aforms_rel → rl_rel → ⟨rnv_rel⟩nres_rel"
by (auto simp: aforms_relp_def (*‹⟨?R⟩aforms_relp = aforms_rel O ⟨?R⟩set_rel›*) nres_rel_def (*‹⟨?R⟩nres_rel ≡ {(c, a). c ≤ ⇓ ?R a}›*) Inf_inners_def (*‹Inf_inners ?X ?y = SPEC (λr. ∀x∈?X. r ≤ inner_lv_rel x ?y)›*) aform_inf_inner_def[abs_def] (*‹aform_inf_inner ≡ λprec X n. case inner_aforms' prec X (map pdevs_of_real n) of Some Xn ⇒ Inf_aform' prec (hd Xn)›*) comp2_def (*‹(?f o2 ?g) ?x ?y ≡ ?f (?g ?x ?y)›*) iaN (*‹inner_aforms' ?p ?a ?b ≠ None›*) intro!: Inf_aform'_Affine_le (*‹?z ∈ Affine ?X ⟹ Inf_aform' ?p ?X ≤ ?z›*) inner_aforms'_inner_lv_rel (*‹⟦(?a, ?a') ∈ aforms_rel; inner_aforms' ?prec ?a (map pdevs_of_real ?a'a) = Some ?R; ?x ∈ ?a'⟧ ⟹ inner_lv_rel ?x ?a'a ∈ Affine (hd ?R)›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) list.splits (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))› ‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*))
lemma aform_sup_inner_refine:
"(RETURN o2 aform_sup_inner optns, Sup_inners) ∈ aforms_rel → rl_rel → ⟨rnv_rel⟩nres_rel"
by (auto simp: aforms_relp_def (*‹⟨?R⟩aforms_relp = aforms_rel O ⟨?R⟩set_rel›*) nres_rel_def (*‹⟨?R⟩nres_rel ≡ {(c, a). c ≤ ⇓ ?R a}›*) Sup_inners_def (*‹Sup_inners ?X ?y = SPEC (λr. ∀x∈?X. inner_lv_rel x ?y ≤ r)›*) aform_sup_inner_def[abs_def] (*‹aform_sup_inner ≡ λprec X n. case inner_aforms' prec X (map pdevs_of_real n) of Some Xn ⇒ Sup_aform' prec (hd Xn)›*) comp2_def (*‹(?f o2 ?g) ?x ?y ≡ ?f (?g ?x ?y)›*) iaN (*‹inner_aforms' ?p ?a ?b ≠ None›*) intro!: Sup_aform'_Affine_ge (*‹?x ∈ Affine ?X ⟹ ?x ≤ Sup_aform' ?p ?X›*) inner_aforms'_inner_lv_rel (*‹⟦(?a, ?a') ∈ aforms_rel; inner_aforms' ?prec ?a (map pdevs_of_real ?a'a) = Some ?R; ?x ∈ ?a'⟧ ⟹ inner_lv_rel ?x ?a'a ∈ Affine (hd ?R)›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) list.splits (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))› ‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*))
lemma lv_aforms_rel_comp_br_Affine_le: "lv_aforms_rel O br Affine top ⊆ ⟨lv_rel⟩aforms_relp"
apply (auto simp: lv_aforms_rel_def (*‹lv_aforms_rel = br eucl_of_list_aform (λxs. length xs = DIM(?'a))›*) aforms_relp_def (*‹⟨?R⟩aforms_relp = aforms_rel O ⟨?R⟩set_rel›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*))
(*goal: ‹lv_aforms_rel O br Affine top ⊆ ⟨lv_rel⟩aforms_relp›*)
apply (rule relcompI (*‹⟦(?a::?'a, ?b::?'b) ∈ (?r::(?'a × ?'b) set); (?b, ?c::?'c) ∈ (?s::(?'b × ?'c) set)⟧ ⟹ (?a, ?c) ∈ ?r O ?s›*))
(*goals:
1. ‹⋀x aa ba. ⟦(aa, ba) = eucl_of_list_aform x; length x = DIM('a)⟧ ⟹ (x, ?b11 x aa ba) ∈ aforms_rel›
2. ‹⋀x aa ba. ⟦(aa, ba) = eucl_of_list_aform x; length x = DIM('a)⟧ ⟹ (?b11 x aa ba, Affine (eucl_of_list_aform x)) ∈ ⟨lv_rel⟩set_rel›
discuss goal 1*)
apply (auto simp: aforms_rel_def (*‹aforms_rel = br Joints top›*) intro!: brI (*‹⟦?a = ?α ?c; ?I ?c⟧ ⟹ (?c, ?a) ∈ br ?α ?I›*))
(*discuss goal 2*)
apply (auto simp: mem_lv_rel_set_rel_iff (*‹((?y, ?z) ∈ ⟨lv_rel⟩set_rel) = (?z = eucl_of_list ` ?y ∧ (∀x∈?y. length x = DIM(?'a)))›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*) intro!: eucl_of_list_mem_eucl_of_list_aform (*‹⟦?x ∈ Joints ?a; length ?a = DIM(?'a)⟧ ⟹ eucl_of_list ?x ∈ Affine (eucl_of_list_aform ?a)›*) intro!: in_image_eucl_of_list_eucl_of_list_aform (*‹⟦length ?x = DIM(?'a); ?xa ∈ Affine (eucl_of_list_aform ?x)⟧ ⟹ ?xa ∈ eucl_of_list ` Joints ?x›*))
(*proven 2 subgoals*) .
lemma bijective_lv_rel[relator_props]: "bijective lv_rel"
unfolding lv_rel_def bijective_def
(*goal: ‹(∀x y z. (x, y) ∈ br eucl_of_list (λxs. length xs = DIM('a)) ∧ (x, z) ∈ br eucl_of_list (λxs. length xs = DIM('a)) ⟶ y = z) ∧ (∀x y z. (x, z) ∈ br eucl_of_list (λxs. length xs = DIM('a)) ∧ (y, z) ∈ br eucl_of_list (λxs. length xs = DIM('a)) ⟶ x = y)›*)
apply (auto simp: br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*))
(*goal: ‹(∀x y z. (x, y) ∈ br eucl_of_list (λxs. length xs = DIM('a)) ∧ (x, z) ∈ br eucl_of_list (λxs. length xs = DIM('a)) ⟶ y = z) ∧ (∀x y z. (x, z) ∈ br eucl_of_list (λxs. length xs = DIM('a)) ∧ (y, z) ∈ br eucl_of_list (λxs. length xs = DIM('a)) ⟶ x = y)›*)
by (metis eucl_of_list_inj (*‹⟦length ?xs = DIM(?'a); length ?ys = DIM(?'a); eucl_of_list ?xs = eucl_of_list ?ys⟧ ⟹ ?xs = ?ys›*))
lemma sv_lv_rel_inverse[relator_props]: "single_valued (lv_rel¯)"
using bijective_lv_rel (*‹bijective lv_rel›*) by (rule bijective_imp_sv (*‹bijective (?R::(?'a × ?'b) set) ⟹ single_valued ?R› ‹bijective (?R::(?'a × ?'b) set) ⟹ single_valued (?R¯)›*))
lemma list_of_eucl_image_lv_rel_inverse:
"(x, list_of_eucl ` x) ∈ ⟨lv_rel¯⟩set_rel"
unfolding set_rel_sv[OF sv_lv_rel_inverse]
(*goal: ‹(x::'a::executable_euclidean_space set, list_of_eucl ` x) ∈ {(S::'a::executable_euclidean_space set, S'::real list set). S' = lv_rel¯ `` S ∧ S ⊆ Domain (lv_rel¯)}›*)
apply auto
(*goal: ‹(x::'a::executable_euclidean_space set, list_of_eucl ` x) ∈ {(S::'a::executable_euclidean_space set, S'::real list set). S' = lv_rel¯ `` S ∧ S ⊆ Domain (lv_rel¯)}›*)
apply (rule ImageI (*‹⟦(?a, ?b) ∈ ?r; ?a ∈ ?A⟧ ⟹ ?b ∈ ?r `` ?A›*))
(*top goal: ‹⋀xa::'a. xa ∈ (x::'a set) ⟹ list_of_eucl xa ∈ lv_rel¯ `` x› and 2 goals remain*)
apply (rule converseI (*‹(?a::?'a, ?b::?'b) ∈ (?r::(?'a × ?'b) set) ⟹ (?b, ?a) ∈ ?r¯›*))
(*top goal: ‹⋀xa. xa ∈ x ⟹ (?a16 xa, list_of_eucl xa) ∈ lv_rel¯› and 3 goals remain*)
apply (rule lv_relI (*‹length ?x = DIM(?'a) ⟹ (?x, eucl_of_list ?x) ∈ lv_rel›*))
(*top goal: ‹⋀xa. xa ∈ x ⟹ (list_of_eucl xa, ?a16 xa) ∈ lv_rel› and 3 goals remain*)
apply auto
(*top goal: ‹⋀xa. xa ∈ x ⟹ length (list_of_eucl xa) = DIM('a)› and 3 goals remain*)
apply (rule image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*))
(*top goal: ‹⋀xa xaa. ⟦xaa ∈ x; (xa, xaa) ∈ lv_rel⟧ ⟹ xa ∈ list_of_eucl ` x› and 1 goal remains*)
prefer 2
(*top goal: ‹⋀(xa::real list) xaa::'a. ⟦xaa ∈ (x::'a set); (xa, xaa) ∈ lv_rel⟧ ⟹ (?x23::real list ⇒ 'a ⇒ 'a) xa xaa ∈ x› and 2 goals remain*)
apply assumption
(*top goal: ‹⋀xa xaa. ⟦xaa ∈ x; (xa, xaa) ∈ lv_rel⟧ ⟹ ?x23 xa xaa ∈ x› and 2 goals remain*)
unfolding lv_rel_def
(*goals:
1. ‹⋀xa xaa. ⟦xaa ∈ x; (xa, xaa) ∈ br eucl_of_list (λxs. length xs = DIM('a))⟧ ⟹ xa = list_of_eucl xaa›
2. ‹⋀xa. xa ∈ x ⟹ xa ∈ Range (br eucl_of_list (λxs. length xs = DIM('a)))›*)
apply (auto simp: br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*))
(*top goal: ‹⋀(xa::real list) xaa::'a. ⟦xaa ∈ (x::'a set); (xa, xaa) ∈ br eucl_of_list (λxs::real list. length xs = DIM('a))⟧ ⟹ xa = list_of_eucl xaa› and 1 goal remains*)
subgoal for y
apply (rule exI[where x="list_of_eucl y"] (*‹?P (list_of_eucl y) ⟹ ∃x. ?P x›*))
(*goal: ‹y ∈ x ⟹ ∃c. y = eucl_of_list c ∧ length c = DIM('a)›*)
by auto .
lemma lv_rel_comp_lv_rel_inverse:
"((lv_rel::(_×'a::executable_euclidean_space) set) O lv_rel¯) = {(x, y). x = y ∧ length x = DIM('a)}"
apply (auto simp: intro!: lv_relI (*‹length ?x = DIM(?'a) ⟹ (?x, eucl_of_list ?x) ∈ lv_rel›*))
(*goal: ‹lv_rel O lv_rel¯ = {(x, y). x = y ∧ length x = DIM('a)}›*)
unfolding lv_rel_def
(*goals:
1. ‹⋀x y z. ⟦(x, y) ∈ br eucl_of_list (λxs. length xs = DIM('a)); (z, y) ∈ br eucl_of_list (λxs. length xs = DIM('a))⟧ ⟹ x = z›
2. ‹⋀x y z. ⟦(x, y) ∈ br eucl_of_list (λxs. length xs = DIM('a)); (z, y) ∈ br eucl_of_list (λxs. length xs = DIM('a))⟧ ⟹ length x = DIM('a)›*)
(*goals:
1. ‹⋀x y z. ⟦(x, y) ∈ br eucl_of_list (λxs. length xs = DIM('a)); (z, y) ∈ br eucl_of_list (λxs. length xs = DIM('a))⟧ ⟹ x = z›
2. ‹⋀x y z. ⟦(x, y) ∈ br eucl_of_list (λxs. length xs = DIM('a)); (z, y) ∈ br eucl_of_list (λxs. length xs = DIM('a))⟧ ⟹ length x = DIM('a)›
discuss goal 1*)
apply ((auto simp: br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) intro!: eucl_of_list_inj (*‹⟦length ?xs = DIM(?'a); length ?ys = DIM(?'a); eucl_of_list ?xs = eucl_of_list ?ys⟧ ⟹ ?xs = ?ys›*))[1])
(*discuss goal 2*)
apply ((auto simp: br_def (*‹br (?α::?'a ⇒ ?'b) (?I::?'a ⇒ bool) ≡ {(c::?'a, a::?'b). a = ?α c ∧ ?I c}›*) intro!: eucl_of_list_inj (*‹⟦length (?xs::real list) = DIM(?'a); length (?ys::real list) = DIM(?'a); eucl_of_list ?xs = eucl_of_list ?ys⟧ ⟹ ?xs = ?ys›*))[1])
(*proven 2 subgoals*) .
lemma inter_aform_plane_refine_aux:
"d = CARD('n::enum) ⟹
(xi, x) ∈ aforms_rel ⟹ (si, s) ∈ ⟨rl_rel⟩sctn_rel ⟹
length xi = d ⟹
length (normal si) = d ⟹
(nres_of (inter_aform_plane_lv (length xi) optns xi si), inter_sctn_specs d x s)
∈ ⟨aforms_rel⟩nres_rel"
proof (goal_cases)
(*goal: ‹⟦d = CARD('n); (xi, x) ∈ aforms_rel; (si, s) ∈ ⟨rl_rel⟩sctn_rel; length xi = d; length (normal si) = d⟧ ⟹ (nres_of (inter_aform_plane_lv (length xi) optns xi si), inter_sctn_specs d x s) ∈ ⟨aforms_rel⟩nres_rel›*)
case 1 (*‹(d::nat) = CARD('n::enum)› ‹(xi, x) ∈ aforms_rel› ‹(si, s) ∈ ⟨rl_rel⟩sctn_rel› ‹length xi = d› ‹length (normal (si::real list sctn)) = (d::nat)›*)
from "1" (*‹d = CARD('n)› ‹(xi, x) ∈ aforms_rel› ‹(si, s) ∈ ⟨rl_rel⟩sctn_rel› ‹length xi = d› ‹length (normal si) = d›*) have sis: "si = s"
apply (cases si)
(*goal: ‹(si::real list sctn) = (s::real list sctn)›*)
apply (cases s)
(*goal: ‹⋀(x1::real list) x2::real. ⟦(d::nat) = CARD('n); (xi::(real × real pdevs) list, x::real list set) ∈ aforms_rel; (si::real list sctn, s::real list sctn) ∈ ⟨rl_rel⟩sctn_rel; length xi = d; length (normal si) = d; si = Sctn x1 x2⟧ ⟹ si = s›*)
by (auto simp: sctn_rel_def (*‹⟨?A⟩sctn_rel = {(a, b). rel_sctn (in_rel ?A) a b}›*))
have Dp: "DIM_precond TYPE('n rvec) CARD('n)"
by auto
have a: "(xi, eucl_of_list_aform xi::'n rvec aform) ∈ lv_aforms_rel"
by (auto simp: lv_aforms_rel_def (*‹lv_aforms_rel = br eucl_of_list_aform (λxs. length xs = DIM(?'a))›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) aforms_relp_def (*‹⟨?R⟩aforms_relp = aforms_rel O ⟨?R⟩set_rel›*) aforms_rel_def (*‹aforms_rel = br Joints top›*) mem_lv_rel_set_rel_iff (*‹((?y, ?z) ∈ ⟨lv_rel⟩set_rel) = (?z = eucl_of_list ` ?y ∧ (∀x∈?y. length x = DIM(?'a)))›*) 1 (*‹d = CARD('n)› ‹(xi, x) ∈ aforms_rel› ‹(si, s) ∈ ⟨rl_rel⟩sctn_rel› ‹length xi = d› ‹length (normal si) = d›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*))
have b: "(si, (Sctn (eucl_of_list (normal si)) (pstn si))::'n rvec sctn) ∈ ⟨lv_rel⟩sctn_rel"
using "1" (*‹(d::nat) = CARD('n)› ‹(xi, x) ∈ aforms_rel› ‹(si, s) ∈ ⟨rl_rel⟩sctn_rel› ‹length (xi::(real × real pdevs) list) = (d::nat)› ‹length (normal si) = d›*) apply (cases si)
(*goal: ‹(si, Sctn (eucl_of_list (normal si)) (pstn si)) ∈ ⟨lv_rel⟩sctn_rel›*)
by (auto simp: lv_aforms_rel_def (*‹lv_aforms_rel = br eucl_of_list_aform (λxs. length xs = DIM(?'a))›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) aforms_relp_def (*‹⟨?R⟩aforms_relp = aforms_rel O ⟨?R⟩set_rel›*) aforms_rel_def (*‹aforms_rel = br Joints top›*) mem_lv_rel_set_rel_iff (*‹((?y, ?z) ∈ ⟨lv_rel⟩set_rel) = (?z = eucl_of_list ` ?y ∧ (∀x∈?y. length x = DIM(?'a)))›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*) sctn_rel_def (*‹⟨?A⟩sctn_rel = {(a, b). rel_sctn (in_rel ?A) a b}›*) intro!: lv_relI (*‹length ?x = DIM(?'a) ⟹ (?x, eucl_of_list ?x) ∈ lv_rel›*))
have a: "(nres_of (inter_aform_plane_lv CARD('n) optns xi si),
inter_aform_plane optns (eucl_of_list_aform xi::'n rvec aform) (Sctn (eucl_of_list (normal si)) (pstn si)))
∈ ⟨lv_aforms_rel⟩nres_rel" (is "(_, inter_aform_plane _ ?ea ?se) ∈ _")
using inter_aform_plane_lv.refine[OF Dp IdI a b, of optns] (*‹(nres_of (inter_aform_plane_lv CARD('n::enum) (optns::nat) (xi::(real × real pdevs) list) (si::real list sctn)), inter_aform_plane optns (eucl_of_list_aform xi) (Sctn (eucl_of_list (normal si)) (pstn si))) ∈ ⟨lv_aforms_rel⟩nres_rel›*) by simp
have b: "(inter_aform_plane optns ?ea ?se, inter_sctn_spec (Affine ?ea) ?se) ∈ ⟨br Affine top⟩nres_rel"
using "1" (*‹d = CARD('n)› ‹(xi, x) ∈ aforms_rel› ‹(si, s) ∈ ⟨rl_rel⟩sctn_rel› ‹length xi = d› ‹length (normal si) = d›*) apply (auto simp: inter_sctn_spec_def (*‹inter_sctn_spec ?X ?sctn = SPEC (λR. ?X ∩ plane_of ?sctn ⊆ R ∧ R ⊆ plane_of ?sctn)›*) nres_rel_def (*‹⟨?R⟩nres_rel ≡ {(c, a). c ≤ ⇓ ?R a}›*) inter_aform_plane_def (*‹inter_aform_plane ?prec ?Xs ?sctn = inter_aform_plane_ortho_nres ?prec ?Xs (normal ?sctn) (pstn ?sctn) ⤜ (λcxs. case cxs of None ⇒ SUCCEED | Some cxs ⇒ if normal ?sctn ∈ set Basis_list then ASSERT (index Basis_list (normal ?sctn) < DIM(?'a)) ⤜ (λ_. RETURN (project_ncoord_aform cxs (index Basis_list (normal ?sctn)) (pstn ?sctn))) else if - normal ?sctn ∈ set Basis_list then ASSERT (index Basis_list (- normal ?sctn) < DIM(?'a)) ⤜ (λ_. RETURN (project_ncoord_aform cxs (index Basis_list (- normal ?sctn)) (- pstn ?sctn))) else SUCCEED)›*) project_ncoord_aform_def (*‹project_ncoord_aform ?x ?b ?n = project_coord_aform (Sctn (Basis_list ! ?b) ?n) ?x›*) inter_aform_plane_ortho_nres_def (*‹inter_aform_plane_ortho_nres ?p ?Z ?n ?g = RETURN (inter_aform_plane_ortho ?p ?Z ?n ?g)›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) intro!: RETURN_SPEC_refine (*‹∃x'. (?x, x') ∈ ?R ∧ ?Φ x' ⟹ RETURN ?x ≤ ⇓ ?R (SPEC ?Φ)›*) dest!: inter_inter_aform_plane_ortho (*‹inter_aform_plane_ortho ?p ?Z ?n ?g = Some ?X ⟹ Affine ?Z ∩ plane ?n ?g ⊆ Affine ?X›*))
(*goals:
1. ‹⋀(a::(real, 'n::enum) vec) b::(real, 'n::enum) vec pdevs. ⟦(d::nat) = CARD('n::enum); (xi::(real × real pdevs) list, x::real list set) ∈ aforms_rel; (si::real list sctn, s::real list sctn) ∈ ⟨Id⟩sctn_rel; length xi = CARD('n::enum); length (normal si) = CARD('n::enum); - eucl_of_list (normal si) ∈ Basis; eucl_of_list (normal si) ∈ Basis; Affine (eucl_of_list_aform xi) ∩ plane (eucl_of_list (normal si)) (pstn si) ⊆ Affine (a, b)⟧ ⟹ ∃x'::(real, 'n::enum) vec set. (project_coord_aform (Sctn (eucl_of_list (normal si)) (pstn si)) (a, b), x') ∈ br Affine top ∧ Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x' ∧ x' ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si))›
2. ‹⋀(a::(real, 'n::enum) vec) b::(real, 'n::enum) vec pdevs. ⟦(d::nat) = CARD('n::enum); (xi::(real × real pdevs) list, x::real list set) ∈ aforms_rel; (si::real list sctn, s::real list sctn) ∈ ⟨Id⟩sctn_rel; length xi = CARD('n::enum); length (normal si) = CARD('n::enum); - eucl_of_list (normal si) ∈ Basis; eucl_of_list (normal si) ∉ Basis; Affine (eucl_of_list_aform xi) ∩ plane (eucl_of_list (normal si)) (pstn si) ⊆ Affine (a, b)⟧ ⟹ ∃x'::(real, 'n::enum) vec set. (project_coord_aform (Sctn (- eucl_of_list (normal si)) (- pstn si)) (a, b), x') ∈ br Affine top ∧ Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x' ∧ x' ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si))›
3. ‹⋀(a::(real, 'n::enum) vec) b::(real, 'n::enum) vec pdevs. ⟦(d::nat) = CARD('n::enum); (xi::(real × real pdevs) list, x::real list set) ∈ aforms_rel; (si::real list sctn, s::real list sctn) ∈ ⟨Id⟩sctn_rel; length xi = CARD('n::enum); length (normal si) = CARD('n::enum); - eucl_of_list (normal si) ∉ Basis; eucl_of_list (normal si) ∈ Basis; Affine (eucl_of_list_aform xi) ∩ plane (eucl_of_list (normal si)) (pstn si) ⊆ Affine (a, b)⟧ ⟹ ∃x'::(real, 'n::enum) vec set. (project_coord_aform (Sctn (eucl_of_list (normal si)) (pstn si)) (a, b), x') ∈ br Affine top ∧ Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x' ∧ x' ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si))›
discuss goal 1*)
apply ((auto simp: aform_rel_def (*‹⟨rnv_rel⟩aform_rel = br Affine top›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) nres_rel_def (*‹⟨?R⟩nres_rel ≡ {(c, a). c ≤ ⇓ ?R a}›*) comps (*‹(∘) ≡ λf g x. f (g x)› ‹(o2) ≡ λf g x y. f (g x y)› ‹(o3) ≡ λf g x y z. f (g x y z)› ‹(o4) ≡ λf g w x y z. f (g w x y z)› ‹(o5) ≡ λf g w x y z a. f (g w x y z a)› ‹(o6) ≡ λf g w x y z a b. f (g w x y z a b)›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) inter_sctn_spec_def (*‹inter_sctn_spec ?X ?sctn = SPEC (λR. ?X ∩ plane_of ?sctn ⊆ R ∧ R ⊆ plane_of ?sctn)›*) inter_aform_plane_def (*‹inter_aform_plane ?prec ?Xs ?sctn = inter_aform_plane_ortho_nres ?prec ?Xs (normal ?sctn) (pstn ?sctn) ⤜ (λcxs. case cxs of None ⇒ SUCCEED | Some cxs ⇒ if normal ?sctn ∈ set Basis_list then ASSERT (index Basis_list (normal ?sctn) < DIM(?'a)) ⤜ (λ_. RETURN (project_ncoord_aform cxs (index Basis_list (normal ?sctn)) (pstn ?sctn))) else if - normal ?sctn ∈ set Basis_list then ASSERT (index Basis_list (- normal ?sctn) < DIM(?'a)) ⤜ (λ_. RETURN (project_ncoord_aform cxs (index Basis_list (- normal ?sctn)) (- pstn ?sctn))) else SUCCEED)›*) plane_of_def (*‹plane_of ?sctn = plane (normal ?sctn) (pstn ?sctn)›*) aforms_relp_def (*‹⟨?R⟩aforms_relp = aforms_rel O ⟨?R⟩set_rel›*) aforms_rel_def (*‹aforms_rel = br Joints top›*) mem_lv_rel_set_rel_iff (*‹((?y, ?z) ∈ ⟨lv_rel⟩set_rel) = (?z = eucl_of_list ` ?y ∧ (∀x∈?y. length x = DIM(?'a)))›*) intro!: RETURN_SPEC_refine (*‹∃x'. (?x, x') ∈ ?R ∧ ?Φ x' ⟹ RETURN ?x ≤ ⇓ ?R (SPEC ?Φ)›*) nres_of_THE_DRES_le (*‹(⋀v. ?x = Some v ⟹ RETURN v ≤ ?y) ⟹ nres_of (THE_DRES ?x) ≤ ?y›*) mem_Affine_project_coord_aformI (*‹⟦?x ∈ Affine ?X; ?x ∈ plane_of ?sctn⟧ ⟹ ?x ∈ Affine (project_coord_aform ?sctn ?X)›*) dest!: inter_inter_aform_plane_ortho (*‹inter_aform_plane_ortho ?p ?Z ?n ?g = Some ?X ⟹ Affine ?Z ∩ plane ?n ?g ⊆ Affine ?X›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*top goal: ‹⋀a b. ⟦d = CARD('n); (xi, x) ∈ aforms_rel; (si, s) ∈ ⟨Id⟩sctn_rel; length xi = CARD('n); length (normal si) = CARD('n); - eucl_of_list (normal si) ∈ Basis; eucl_of_list (normal si) ∈ Basis; Affine (eucl_of_list_aform xi) ∩ plane (eucl_of_list (normal si)) (pstn si) ⊆ Affine (a, b)⟧ ⟹ ∃x'. (project_coord_aform (Sctn (eucl_of_list (normal si)) (pstn si)) (a, b), x') ∈ br Affine top ∧ Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x' ∧ x' ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si))› and 2 goals remain*)
apply ((auto dest!: mem_Affine_project_coord_aformD (*‹⟦?x ∈ Affine (project_coord_aform ?sctn ?X); ¦normal ?sctn¦ ∈ Basis⟧ ⟹ ?x ∈ plane_of ?sctn›*) simp: abs_in_Basis_iff (*‹(¦?u¦ ∈ Basis) = (?u ∈ Basis ∨ - ?u ∈ Basis)›*) plane_of_def (*‹plane_of ?sctn = plane (normal ?sctn) (pstn ?sctn)›*))[1])
(*discuss goal 2*)
apply ((auto simp: aform_rel_def (*‹⟨rnv_rel⟩aform_rel = br Affine top›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) nres_rel_def (*‹⟨?R⟩nres_rel ≡ {(c, a). c ≤ ⇓ ?R a}›*) comps (*‹(∘) ≡ λf g x. f (g x)› ‹(o2) ≡ λf g x y. f (g x y)› ‹(o3) ≡ λf g x y z. f (g x y z)› ‹(o4) ≡ λf g w x y z. f (g w x y z)› ‹(o5) ≡ λf g w x y z a. f (g w x y z a)› ‹(o6) ≡ λf g w x y z a b. f (g w x y z a b)›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) inter_sctn_spec_def (*‹inter_sctn_spec ?X ?sctn = SPEC (λR. ?X ∩ plane_of ?sctn ⊆ R ∧ R ⊆ plane_of ?sctn)›*) inter_aform_plane_def (*‹inter_aform_plane ?prec ?Xs ?sctn = inter_aform_plane_ortho_nres ?prec ?Xs (normal ?sctn) (pstn ?sctn) ⤜ (λcxs. case cxs of None ⇒ SUCCEED | Some cxs ⇒ if normal ?sctn ∈ set Basis_list then ASSERT (index Basis_list (normal ?sctn) < DIM(?'a)) ⤜ (λ_. RETURN (project_ncoord_aform cxs (index Basis_list (normal ?sctn)) (pstn ?sctn))) else if - normal ?sctn ∈ set Basis_list then ASSERT (index Basis_list (- normal ?sctn) < DIM(?'a)) ⤜ (λ_. RETURN (project_ncoord_aform cxs (index Basis_list (- normal ?sctn)) (- pstn ?sctn))) else SUCCEED)›*) plane_of_def (*‹plane_of ?sctn = plane (normal ?sctn) (pstn ?sctn)›*) aforms_relp_def (*‹⟨?R⟩aforms_relp = aforms_rel O ⟨?R⟩set_rel›*) aforms_rel_def (*‹aforms_rel = br Joints top›*) mem_lv_rel_set_rel_iff (*‹((?y, ?z) ∈ ⟨lv_rel⟩set_rel) = (?z = eucl_of_list ` ?y ∧ (∀x∈?y. length x = DIM(?'a)))›*) intro!: RETURN_SPEC_refine (*‹∃x'. (?x, x') ∈ ?R ∧ ?Φ x' ⟹ RETURN ?x ≤ ⇓ ?R (SPEC ?Φ)›*) nres_of_THE_DRES_le (*‹(⋀v. ?x = Some v ⟹ RETURN v ≤ ?y) ⟹ nres_of (THE_DRES ?x) ≤ ?y›*) mem_Affine_project_coord_aformI (*‹⟦?x ∈ Affine ?X; ?x ∈ plane_of ?sctn⟧ ⟹ ?x ∈ Affine (project_coord_aform ?sctn ?X)›*) dest!: inter_inter_aform_plane_ortho (*‹inter_aform_plane_ortho ?p ?Z ?n ?g = Some ?X ⟹ Affine ?Z ∩ plane ?n ?g ⊆ Affine ?X›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*top goal: ‹⋀(a::(real, 'n) vec) b::(real, 'n) vec pdevs. ⟦(d::nat) = CARD('n); (xi::(real × real pdevs) list, x::real list set) ∈ aforms_rel; (si::real list sctn, s::real list sctn) ∈ ⟨Id⟩sctn_rel; length xi = CARD('n); length (normal si) = CARD('n); - eucl_of_list (normal si) ∈ Basis; eucl_of_list (normal si) ∉ Basis; Affine (eucl_of_list_aform xi) ∩ plane (eucl_of_list (normal si)) (pstn si) ⊆ Affine (a, b)⟧ ⟹ ∃x'::(real, 'n) vec set. (project_coord_aform (Sctn (- eucl_of_list (normal si)) (- pstn si)) (a, b), x') ∈ br Affine top ∧ Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x' ∧ x' ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si))› and 1 goal remains*)
apply ((auto dest!: mem_Affine_project_coord_aformD (*‹⟦?x ∈ Affine (project_coord_aform ?sctn ?X); ¦normal ?sctn¦ ∈ Basis⟧ ⟹ ?x ∈ plane_of ?sctn›*) simp: abs_in_Basis_iff (*‹(¦?u¦ ∈ Basis) = (?u ∈ Basis ∨ - ?u ∈ Basis)›*) plane_of_def (*‹plane_of ?sctn = plane (normal ?sctn) (pstn ?sctn)›*))[1])
(*discuss goal 3*)
apply ((auto simp: aform_rel_def (*‹⟨rnv_rel⟩aform_rel = br Affine top›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) nres_rel_def (*‹⟨?R⟩nres_rel ≡ {(c, a). c ≤ ⇓ ?R a}›*) comps (*‹(∘) ≡ λf g x. f (g x)› ‹(o2) ≡ λf g x y. f (g x y)› ‹(o3) ≡ λf g x y z. f (g x y z)› ‹(o4) ≡ λf g w x y z. f (g w x y z)› ‹(o5) ≡ λf g w x y z a. f (g w x y z a)› ‹(o6) ≡ λf g w x y z a b. f (g w x y z a b)›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) inter_sctn_spec_def (*‹inter_sctn_spec ?X ?sctn = SPEC (λR. ?X ∩ plane_of ?sctn ⊆ R ∧ R ⊆ plane_of ?sctn)›*) inter_aform_plane_def (*‹inter_aform_plane ?prec ?Xs ?sctn = inter_aform_plane_ortho_nres ?prec ?Xs (normal ?sctn) (pstn ?sctn) ⤜ (λcxs. case cxs of None ⇒ SUCCEED | Some cxs ⇒ if normal ?sctn ∈ set Basis_list then ASSERT (index Basis_list (normal ?sctn) < DIM(?'a)) ⤜ (λ_. RETURN (project_ncoord_aform cxs (index Basis_list (normal ?sctn)) (pstn ?sctn))) else if - normal ?sctn ∈ set Basis_list then ASSERT (index Basis_list (- normal ?sctn) < DIM(?'a)) ⤜ (λ_. RETURN (project_ncoord_aform cxs (index Basis_list (- normal ?sctn)) (- pstn ?sctn))) else SUCCEED)›*) plane_of_def (*‹plane_of ?sctn = plane (normal ?sctn) (pstn ?sctn)›*) aforms_relp_def (*‹⟨?R⟩aforms_relp = aforms_rel O ⟨?R⟩set_rel›*) aforms_rel_def (*‹aforms_rel = br Joints top›*) mem_lv_rel_set_rel_iff (*‹((?y, ?z) ∈ ⟨lv_rel⟩set_rel) = (?z = eucl_of_list ` ?y ∧ (∀x∈?y. length x = DIM(?'a)))›*) intro!: RETURN_SPEC_refine (*‹∃x'. (?x, x') ∈ ?R ∧ ?Φ x' ⟹ RETURN ?x ≤ ⇓ ?R (SPEC ?Φ)›*) nres_of_THE_DRES_le (*‹(⋀v. ?x = Some v ⟹ RETURN v ≤ ?y) ⟹ nres_of (THE_DRES ?x) ≤ ?y›*) mem_Affine_project_coord_aformI (*‹⟦?x ∈ Affine ?X; ?x ∈ plane_of ?sctn⟧ ⟹ ?x ∈ Affine (project_coord_aform ?sctn ?X)›*) dest!: inter_inter_aform_plane_ortho (*‹inter_aform_plane_ortho ?p ?Z ?n ?g = Some ?X ⟹ Affine ?Z ∩ plane ?n ?g ⊆ Affine ?X›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*goal: ‹⋀(a::(real, 'n) vec) b::(real, 'n) vec pdevs. ⟦(d::nat) = CARD('n); (xi::(real × real pdevs) list, x::real list set) ∈ aforms_rel; (si::real list sctn, s::real list sctn) ∈ ⟨Id⟩sctn_rel; length xi = CARD('n); length (normal si) = CARD('n); - eucl_of_list (normal si) ∉ Basis; eucl_of_list (normal si) ∈ Basis; Affine (eucl_of_list_aform xi) ∩ plane (eucl_of_list (normal si)) (pstn si) ⊆ Affine (a, b)⟧ ⟹ ∃x'::(real, 'n) vec set. (project_coord_aform (Sctn (eucl_of_list (normal si)) (pstn si)) (a, b), x') ∈ br Affine top ∧ Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x' ∧ x' ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si))›*)
apply ((auto dest!: mem_Affine_project_coord_aformD (*‹⟦(?x::?'a::executable_euclidean_space) ∈ Affine (project_coord_aform (?sctn::?'a::executable_euclidean_space sctn) (?X::?'a::executable_euclidean_space × ?'a::executable_euclidean_space pdevs)); ¦normal ?sctn¦ ∈ Basis⟧ ⟹ ?x ∈ plane_of ?sctn›*) simp: abs_in_Basis_iff (*‹(¦?u::?'a::ordered_euclidean_space¦ ∈ Basis) = (?u ∈ Basis ∨ - ?u ∈ Basis)›*) plane_of_def (*‹plane_of (?sctn::?'a::real_inner sctn) = plane (normal ?sctn) (pstn ?sctn)›*))[1])
(*proven 3 subgoals*) .
from relcompI[OF a b] (*‹(nres_of (inter_aform_plane_lv CARD('n) optns xi si), inter_sctn_spec (Affine (eucl_of_list_aform xi)) (Sctn (eucl_of_list (normal si)) (pstn si))) ∈ ⟨lv_aforms_rel⟩nres_rel O ⟨br Affine top⟩nres_rel›*) have "(nres_of (inter_aform_plane_lv CARD('n) optns xi si), inter_sctn_spec (Affine ?ea) ?se) ∈
⟨lv_aforms_rel⟩nres_rel O ⟨br Affine top⟩nres_rel"
by auto
also (*calculation: ‹(nres_of (inter_aform_plane_lv CARD('n) optns xi si), inter_sctn_spec (Affine (eucl_of_list_aform xi)) (Sctn (eucl_of_list (normal si)) (pstn si))) ∈ ⟨lv_aforms_rel⟩nres_rel O ⟨br Affine top⟩nres_rel›*) have "⟨lv_aforms_rel⟩nres_rel O ⟨br Affine top⟩nres_rel ⊆ ⟨⟨lv_rel⟩aforms_relp⟩nres_rel"
unfolding nres_rel_comp
(*goal: ‹⟨lv_aforms_rel O br Affine top⟩nres_rel ⊆ ⟨⟨lv_rel⟩aforms_relp⟩nres_rel›*)
apply (rule nres_rel_mono (*‹?A ⊆ ?B ⟹ ⟨?A⟩nres_rel ⊆ ⟨?B⟩nres_rel›*))
(*goal: ‹⟨lv_aforms_rel O br Affine top⟩nres_rel ⊆ ⟨⟨lv_rel⟩aforms_relp⟩nres_rel›*)
by (rule lv_aforms_rel_comp_br_Affine_le (*‹lv_aforms_rel O br Affine top ⊆ ⟨lv_rel⟩aforms_relp›*))
finally (*calculation: ‹(nres_of (inter_aform_plane_lv CARD('n::enum) (optns::nat) (xi::(real × real pdevs) list) (si::real list sctn)), inter_sctn_spec (Affine (eucl_of_list_aform xi)) (Sctn (eucl_of_list (normal si)) (pstn si))) ∈ ⟨⟨lv_rel⟩aforms_relp⟩nres_rel›*) have step1: "(nres_of (inter_aform_plane_lv CARD('n) optns xi si),
inter_sctn_spec (Affine (eucl_of_list_aform xi)::'n rvec set) (Sctn (eucl_of_list (normal si)) (pstn si)))
∈ ⟨⟨lv_rel⟩aforms_relp⟩nres_rel"
by simp
have step2: "(inter_sctn_spec (Affine (eucl_of_list_aform xi)::'n rvec set) (Sctn (eucl_of_list (normal si)) (pstn si)),
inter_sctn_specs CARD('n) (Joints xi) si) ∈ ⟨⟨lv_rel¯⟩set_rel⟩nres_rel"
apply (auto simp: inter_sctn_specs_def (*‹inter_sctn_specs ?d ?X ?sctn = SPEC (λR. env_len R ?d ∧ ?X ∩ plane_ofs ?sctn ⊆ R ∧ R ⊆ plane_ofs ?sctn)›*) inter_sctn_spec_def (*‹inter_sctn_spec ?X ?sctn = SPEC (λR. ?X ∩ plane_of ?sctn ⊆ R ∧ R ⊆ plane_of ?sctn)›*) simp: nres_rel_def (*‹⟨?R⟩nres_rel ≡ {(c, a). c ≤ ⇓ ?R a}›*) intro!: SPEC_refine (*‹?S ≤ SPEC (λx. ∃x'. (x, x') ∈ ?R ∧ ?Φ x') ⟹ ?S ≤ ⇓ ?R (SPEC ?Φ)›*))
(*goal: ‹(inter_sctn_spec (Affine (eucl_of_list_aform xi)) (Sctn (eucl_of_list (normal si)) (pstn si)), inter_sctn_specs CARD('n) (Joints xi) si) ∈ ⟨⟨lv_rel¯⟩set_rel⟩nres_rel›*)
subgoal for x
apply (rule exI[where x="list_of_eucl ` x"] (*‹(?P::real list set ⇒ bool) (list_of_eucl ` (x::(real, 'n) vec set)) ⟹ ∃x::real list set. ?P x›*))
(*goal: ‹⟦Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x; x ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si))⟧ ⟹ ∃x'. (x, x') ∈ ⟨lv_rel¯⟩set_rel ∧ env_len x' CARD('n) ∧ Joints xi ∩ plane_ofs si ⊆ x' ∧ x' ⊆ plane_ofs si›*)
apply (auto simp: env_len_def (*‹env_len ?env ?l = (∀xs∈?env. length xs = ?l)›*) plane_ofs_def (*‹plane_ofs ?sctn = {x. inner_lv_rel x (normal ?sctn) = pstn ?sctn}›*) intro: list_of_eucl_image_lv_rel_inverse (*‹(?x, list_of_eucl ` ?x) ∈ ⟨lv_rel¯⟩set_rel›*))
(*goal: ‹⟦Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x; x ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si))⟧ ⟹ (x, list_of_eucl ` x) ∈ ⟨lv_rel¯⟩set_rel ∧ env_len (list_of_eucl ` x) CARD('n) ∧ Joints xi ∩ plane_ofs si ⊆ list_of_eucl ` x ∧ list_of_eucl ` x ⊆ plane_ofs si›*)
subgoal for y
apply (rule image_eqI[where x="eucl_of_list y"] (*‹⟦(?b::?'a) = (?f::?'a1 ⇒ ?'a) (eucl_of_list (y::real list)); eucl_of_list y ∈ (?A::?'a1 set)⟧ ⟹ ?b ∈ ?f ` ?A›*))
(*goal: ‹⟦Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x; x ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)); y ∈ Joints xi; inner_lv_rel y (normal si) = pstn si⟧ ⟹ y ∈ list_of_eucl ` x›*)
apply (subst list_of_eucl_eucl_of_list (*‹length ?xs = DIM(?'a) ⟹ list_of_eucl (eucl_of_list ?xs) = ?xs›*))
(*top goal: ‹⟦Affine (eucl_of_list_aform (xi::(real × real pdevs) list)) ∩ plane_of (Sctn (eucl_of_list (normal (si::real list sctn))) (pstn si)) ⊆ (x::(real, 'n) vec set); x ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)); (y::real list) ∈ Joints xi; inner_lv_rel y (normal si) = pstn si⟧ ⟹ y = list_of_eucl (eucl_of_list y)› and 1 goal remains*)
apply (auto simp: 1 (*‹d = CARD('n)› ‹(xi, x) ∈ aforms_rel› ‹(si, s) ∈ ⟨rl_rel⟩sctn_rel› ‹length xi = d› ‹length (normal si) = d›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*))
(*top goal: ‹⟦Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x; x ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)); y ∈ Joints xi; inner_lv_rel y (normal si) = pstn si⟧ ⟹ length y = DIM((real, 'n) vec)› and 2 goals remain*)
apply (rule subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*), assumption)
(*goal: ‹⟦Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x; x ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)); y ∈ Joints xi; inner_lv_rel y (normal si) = pstn si⟧ ⟹ eucl_of_list y ∈ x›*)
apply (auto simp: intro!: eucl_of_list_mem_eucl_of_list_aform (*‹⟦?x ∈ Joints ?a; length ?a = DIM(?'a)⟧ ⟹ eucl_of_list ?x ∈ Affine (eucl_of_list_aform ?a)›*) 1 (*‹d = CARD('n)› ‹(xi, x) ∈ aforms_rel› ‹(si, s) ∈ ⟨rl_rel⟩sctn_rel› ‹length xi = d› ‹length (normal si) = d›*))
(*goal: ‹⟦Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x; x ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)); y ∈ Joints xi; inner_lv_rel y (normal si) = pstn si⟧ ⟹ eucl_of_list y ∈ Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si))›*)
using inner_lv_rel_autoref[where 'a = "'n rvec", param_fo, OF lv_relI lv_relI, of y "normal si"] (*‹⟦length y = DIM((real, 'n) vec); length (normal si) = DIM((real, 'n) vec)⟧ ⟹ (inner_lv_rel y (normal si), eucl_of_list y ∙ eucl_of_list (normal si)) ∈ rnv_rel›*) apply -
(*goals:
1. ‹⟦Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x; x ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)); y ∈ Joints xi; inner_lv_rel y (normal si) = pstn si; ⟦length y = DIM((real, 'n) vec); length (normal si) = DIM((real, 'n) vec)⟧ ⟹ (inner_lv_rel y (normal si), eucl_of_list y ∙ eucl_of_list (normal si)) ∈ rnv_rel⟧ ⟹ length xi = CARD('n)›
2. ‹⟦Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x; x ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)); y ∈ Joints xi; inner_lv_rel y (normal si) = pstn si; ⟦length y = DIM((real, 'n) vec); length (normal si) = DIM((real, 'n) vec)⟧ ⟹ (inner_lv_rel y (normal si), eucl_of_list y ∙ eucl_of_list (normal si)) ∈ rnv_rel⟧ ⟹ eucl_of_list y ∈ plane_of (Sctn (eucl_of_list (normal si)) (pstn si))›
discuss goal 1*)
apply ((auto simp: plane_of_def (*‹plane_of ?sctn = plane (normal ?sctn) (pstn ?sctn)›*) 1 (*‹d = CARD('n)› ‹(xi, x) ∈ aforms_rel› ‹(si, s) ∈ ⟨rl_rel⟩sctn_rel› ‹length xi = d› ‹length (normal si) = d›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*))[1])
(*discuss goal 2*)
apply ((auto simp: plane_of_def (*‹plane_of ?sctn = plane (normal ?sctn) (pstn ?sctn)›*) 1 (*‹d = CARD('n)› ‹(xi, x) ∈ aforms_rel› ‹(si, s) ∈ ⟨rl_rel⟩sctn_rel› ‹length xi = d› ‹length (normal si) = d›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*))[1])
(*proven 2 subgoals*) .
subgoal for y
apply (drule subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*), assumption)
(*goal: ‹⟦Affine (eucl_of_list_aform xi) ∩ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)) ⊆ x; x ⊆ plane_of (Sctn (eucl_of_list (normal si)) (pstn si)); y ∈ x⟧ ⟹ inner_lv_rel (list_of_eucl y) (normal si) = pstn si›*)
using inner_lv_rel_autoref[where 'a = "'n rvec", param_fo, OF lv_relI lv_relI, of "list_of_eucl y" "normal si"] (*‹⟦length (list_of_eucl y) = DIM((real, 'n) vec); length (normal si) = DIM((real, 'n) vec)⟧ ⟹ (inner_lv_rel (list_of_eucl y) (normal si), eucl_of_list (list_of_eucl y) ∙ eucl_of_list (normal si)) ∈ rnv_rel›*) by (auto simp: plane_of_def (*‹plane_of ?sctn = plane (normal ?sctn) (pstn ?sctn)›*) 1 (*‹d = CARD('n)› ‹(xi, x) ∈ aforms_rel› ‹(si, s) ∈ ⟨rl_rel⟩sctn_rel› ‹length xi = d› ‹length (normal si) = d›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*)) . .
from relcompI[OF step1 step2] (*‹(nres_of (inter_aform_plane_lv CARD('n) optns xi si), inter_sctn_specs CARD('n) (Joints xi) si) ∈ ⟨⟨lv_rel⟩aforms_relp⟩nres_rel O ⟨⟨lv_rel¯⟩set_rel⟩nres_rel›*) have "(nres_of (inter_aform_plane_lv CARD('n) optns xi si), inter_sctn_specs CARD('n) (Joints xi) si)
∈ ⟨⟨lv_rel::(real list × 'n rvec)set⟩aforms_relp⟩nres_rel O ⟨⟨lv_rel¯⟩set_rel⟩nres_rel"
by simp
also (*calculation: ‹(nres_of (inter_aform_plane_lv CARD('n) optns xi si), inter_sctn_specs CARD('n) (Joints xi) si) ∈ ⟨⟨lv_rel⟩aforms_relp⟩nres_rel O ⟨⟨lv_rel¯⟩set_rel⟩nres_rel›*) have "⟨⟨lv_rel::(real list × 'n rvec)set⟩aforms_relp⟩nres_rel O ⟨⟨lv_rel¯⟩set_rel⟩nres_rel ⊆
⟨aforms_rel O Id⟩nres_rel"
unfolding nres_rel_comp O_assoc aforms_relp_def
(*goal: ‹⟨aforms_rel O ⟨lv_rel⟩set_rel O ⟨lv_rel¯⟩set_rel⟩nres_rel ⊆ ⟨aforms_rel O Id⟩nres_rel›*)
apply (rule nres_rel_mono (*‹?A ⊆ ?B ⟹ ⟨?A⟩nres_rel ⊆ ⟨?B⟩nres_rel›*))
(*goal: ‹⟨aforms_rel O ⟨lv_rel⟩set_rel O ⟨lv_rel¯⟩set_rel⟩nres_rel ⊆ ⟨aforms_rel O Id⟩nres_rel›*)
apply (rule relcomp_mono[OF order_refl] (*‹?s' ⊆ ?s ⟹ ?r O ?s' ⊆ ?r O ?s›*))
(*goal: ‹aforms_rel O ⟨lv_rel⟩set_rel O ⟨lv_rel¯⟩set_rel ⊆ aforms_rel O Id›*)
unfolding set_rel_sv[OF sv_lv_rel_inverse] set_rel_sv[OF lv_rel_sv]
(*goal: ‹{(S, S'). S' = lv_rel `` S ∧ S ⊆ Domain lv_rel} O {(S, S'). S' = lv_rel¯ `` S ∧ S ⊆ Domain (lv_rel¯)} ⊆ Id›*)
apply (auto simp: length_lv_rel (*‹(?ys, ?y) ∈ lv_rel ⟹ length ?ys = DIM(?'a)›*))
(*goal: ‹{(S, S'). S' = lv_rel `` S ∧ S ⊆ Domain lv_rel} O {(S, S'). S' = lv_rel¯ `` S ∧ S ⊆ Domain (lv_rel¯)} ⊆ Id›*)
unfolding relcomp_Image[symmetric] lv_rel_comp_lv_rel_inverse
(*goals:
1. ‹⋀x xa. ⟦x ⊆ Domain lv_rel; lv_rel `` x ⊆ Range lv_rel; xa ∈ x⟧ ⟹ xa ∈ {(x, y). x = y ∧ length x = DIM((real, 'n) vec)} `` x›
2. ‹⋀x xa xb xc. ⟦x ⊆ Domain lv_rel; lv_rel `` x ⊆ Range lv_rel; (xc, xb) ∈ lv_rel; xc ∈ x; (xa, xb) ∈ lv_rel⟧ ⟹ xa ∈ x›*)
apply (auto simp: Basis_not_uminus (*‹?i ∈ Basis ⟹ - ?i ∉ Basis›*) length_lv_rel (*‹(?ys, ?y) ∈ lv_rel ⟹ length ?ys = DIM(?'a)›*))
(*top goal: ‹⋀x xa. ⟦x ⊆ Domain lv_rel; lv_rel `` x ⊆ Range lv_rel; xa ∈ x⟧ ⟹ xa ∈ {(x, y). x = y ∧ length x = DIM((real, 'n) vec)} `` x› and 1 goal remains*)
unfolding lv_rel_def
(*goal: ‹⋀(x::real list set) (xa::real list) (xb::(real, 'n::enum) vec) xc::real list. ⟦x ⊆ Domain (br eucl_of_list (λxs::real list. length xs = DIM((real, 'n::enum) vec))); br eucl_of_list (λxs::real list. length xs = DIM((real, 'n::enum) vec)) `` x ⊆ Range (br eucl_of_list (λxs::real list. length xs = DIM((real, 'n::enum) vec))); (xc, xb) ∈ br eucl_of_list (λxs::real list. length xs = DIM((real, 'n::enum) vec)); xc ∈ x; (xa, xb) ∈ br eucl_of_list (λxs::real list. length xs = DIM((real, 'n::enum) vec))⟧ ⟹ xa ∈ x›*)
subgoal for a and b and c and d
apply (auto dest!: brD (*‹(?c, ?a) ∈ br ?α ?I ⟹ ?a = ?α ?c ∧ ?I ?c›*) simp: length_lv_rel (*‹(?ys, ?y) ∈ lv_rel ⟹ length ?ys = DIM(?'a)›*))
(*goal: ‹⟦a ⊆ Domain (br eucl_of_list (λxs. length xs = DIM((real, 'n) vec))); br eucl_of_list (λxs. length xs = DIM((real, 'n) vec)) `` a ⊆ Range (br eucl_of_list (λxs. length xs = DIM((real, 'n) vec))); (d, c) ∈ br eucl_of_list (λxs. length xs = DIM((real, 'n) vec)); d ∈ a; (b, c) ∈ br eucl_of_list (λxs. length xs = DIM((real, 'n) vec))⟧ ⟹ b ∈ a›*)
using eucl_of_list_inj[where 'a = "'n rvec", of d b] (*‹⟦length (d::real list) = DIM((real, 'n) vec); length (b::real list) = DIM((real, 'n) vec); eucl_of_list d = eucl_of_list b⟧ ⟹ d = b›*) by auto .
finally (*calculation: ‹(nres_of (inter_aform_plane_lv CARD('n) optns xi si), inter_sctn_specs CARD('n) (Joints xi) si) ∈ ⟨aforms_rel O Id⟩nres_rel›*) show "?case"
(*goal: ‹(nres_of (inter_aform_plane_lv (length xi) optns xi si), inter_sctn_specs d x s) ∈ ⟨aforms_rel⟩nres_rel›*)
using "1" (*‹d = CARD('n)› ‹(xi, x) ∈ aforms_rel› ‹(si, s) ∈ ⟨rl_rel⟩sctn_rel› ‹length xi = d› ‹length (normal si) = d›*) by (simp add: aforms_rel_def (*‹aforms_rel = br Joints top›*) br_def (*‹br (?α::?'a ⇒ ?'b) (?I::?'a ⇒ bool) ≡ {(c::?'a, a::?'b). a = ?α c ∧ ?I c}›*) sis (*‹(si::real list sctn) = (s::real list sctn)›*))
qed
end
setup ‹Sign.add_const_constraint (@{const_name "enum_class.enum"}, SOME @{typ "'a list"})›
setup ‹Sign.add_const_constraint (@{const_name "enum_class.enum_all"}, SOME @{typ "('a ⇒ bool) ⇒ bool"})›
setup ‹Sign.add_const_constraint (@{const_name "enum_class.enum_ex"}, SOME @{typ "('a ⇒ bool) ⇒ bool"})›
lemmas inter_aform_plane_refine_unoverloaded0 =
inter_aform_plane_refine_aux[internalize_sort "'n::enum",
unoverload enum_class.enum,
unoverload enum_class.enum_all,
unoverload enum_class.enum_ex]
theorem
inter_aform_plane_refine_unoverloaded:
"class.enum (enum::'a list) enum_all enum_ex ∧ d = CARD('a) ⟹
(xi, x) ∈ aforms_rel ⟹
(si, s) ∈ ⟨rl_rel⟩sctn_rel ⟹
length xi = d ⟹
length (normal si) = d ⟹
(nres_of (inter_aform_plane_lv (length xi) optns xi si), inter_sctn_specs d x s)
∈ ⟨aforms_rel⟩nres_rel"
apply (rule inter_aform_plane_refine_unoverloaded0 (*‹⟦class.enum ?enum ?enum_all ?enum_ex; ?d = CARD(?'a); (?xi, ?x) ∈ aforms_rel; (?si, ?s) ∈ ⟨rl_rel⟩sctn_rel; length ?xi = ?d; length (normal ?si) = ?d⟧ ⟹ (nres_of (inter_aform_plane_lv (length ?xi) ?optns ?xi ?si), inter_sctn_specs ?d ?x ?s) ∈ ⟨aforms_rel⟩nres_rel›*))
(*goals:
1. ‹⟦class.enum enum enum_all enum_ex ∧ d = CARD('a); (xi, x) ∈ aforms_rel; (si, s) ∈ ⟨rl_rel⟩sctn_rel; length xi = d; length (normal si) = d⟧ ⟹ class.enum ?enum ?enum_all ?enum_ex›
2. ‹⟦class.enum enum enum_all enum_ex ∧ d = CARD('a); (xi, x) ∈ aforms_rel; (si, s) ∈ ⟨rl_rel⟩sctn_rel; length xi = d; length (normal si) = d⟧ ⟹ d = CARD(?'a)›
3. ‹⟦class.enum enum enum_all enum_ex ∧ d = CARD('a); (xi, x) ∈ aforms_rel; (si, s) ∈ ⟨rl_rel⟩sctn_rel; length xi = d; length (normal si) = d⟧ ⟹ (xi, x) ∈ aforms_rel›
4. ‹⟦class.enum enum enum_all enum_ex ∧ d = CARD('a); (xi, x) ∈ aforms_rel; (si, s) ∈ ⟨rl_rel⟩sctn_rel; length xi = d; length (normal si) = d⟧ ⟹ (si, s) ∈ ⟨rl_rel⟩sctn_rel›
5. ‹⟦class.enum enum enum_all enum_ex ∧ d = CARD('a); (xi, x) ∈ aforms_rel; (si, s) ∈ ⟨rl_rel⟩sctn_rel; length xi = d; length (normal si) = d⟧ ⟹ length xi = d›
6. ‹⟦class.enum enum enum_all enum_ex ∧ d = CARD('a); (xi, x) ∈ aforms_rel; (si, s) ∈ ⟨rl_rel⟩sctn_rel; length xi = d; length (normal si) = d⟧ ⟹ length (normal si) = d›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*discuss goal 6*)
apply ((auto)[1])
(*proven 6 subgoals*) .
setup ‹Sign.add_const_constraint (@{const_name "enum_class.enum"}, SOME @{typ "'a::enum list"})›
setup ‹Sign.add_const_constraint (@{const_name "enum_class.enum_all"}, SOME @{typ "('a::enum ⇒ bool) ⇒ bool"})›
setup ‹Sign.add_const_constraint (@{const_name "enum_class.enum_ex"}, SOME @{typ "('a::enum ⇒ bool) ⇒ bool"})›
context includes autoref_syntax begin
text ‹TODO: this is a special case of ‹Cancel_Card_Constraint› from ‹AFP/Perron_Frobenius›!›
lemma type_impl_card_n_enum:
assumes "∃(Rep :: 'a ⇒ nat) Abs. type_definition Rep Abs {0 ..< n :: nat}"
obtains enum enum_all enum_ex
where "class.enum (enum::'a list) enum_all enum_ex ∧ n = CARD('a)"
proof (-)
(*goal: ‹(⋀enuma enum_all enum_ex. class.enum enuma enum_all enum_ex ∧ n = CARD('a) ⟹ thesis) ⟹ thesis›*)
from assms (*‹∃Rep Abs. type_definition Rep Abs {0..<n}›*) obtain rep :: "'a ⇒ nat" and abs :: "nat ⇒ 'a" where t: "type_definition rep abs {0 ..<n}"
(*goal: ‹(⋀rep abs. type_definition rep abs {0..<n} ⟹ thesis) ⟹ thesis›*)
by auto
then interpret type_definition rep abs "{0 ..<n}" .
have "card (UNIV :: 'a set) = card {0 ..< n}"
by (rule card (*‹CARD('a::type) = card {0::nat..<n::nat}›*))
also (*calculation: ‹CARD('a) = card {0..<n}›*) have "… = n"
by auto
finally (*calculation: ‹CARD('a) = n›*) have bn: "CARD ('a) = n" .
let ?enum = "(map abs [0..<n])"
have "class.enum ?enum (Ball (set ?enum)) (Bex (set ?enum))"
apply standard
(*goals:
1. ‹UNIV = set (map abs [0..<n])›
2. ‹distinct (map abs [0..<n])›
3. ‹⋀P. Ball (set (map abs [0..<n])) P = Ball UNIV P›
4. ‹⋀P. Bex (set (map abs [0..<n])) P = Bex UNIV P›
discuss goal 1*)
apply ((auto simp: distinct_map (*‹distinct (map ?f ?xs) = (distinct ?xs ∧ inj_on ?f (set ?xs))›*) univ (*‹UNIV = abs ` {0..<n}›*) Abs_inject (*‹⟦?x ∈ {0..<n}; ?y ∈ {0..<n}⟧ ⟹ (abs ?x = abs ?y) = (?x = ?y)›*) intro: inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*))[1])
(*discuss goal 2*)
apply ((auto simp: distinct_map (*‹distinct (map ?f ?xs) = (distinct ?xs ∧ inj_on ?f (set ?xs))›*) univ (*‹UNIV = abs ` {0..<n}›*) Abs_inject (*‹⟦?x ∈ {0..<n}; ?y ∈ {0..<n}⟧ ⟹ (abs ?x = abs ?y) = (?x = ?y)›*) intro: inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*))[1])
(*discuss goal 3*)
apply ((auto simp: distinct_map (*‹distinct (map ?f ?xs) = (distinct ?xs ∧ inj_on ?f (set ?xs))›*) univ (*‹UNIV = abs ` {0..<n}›*) Abs_inject (*‹⟦?x ∈ {0..<n}; ?y ∈ {0..<n}⟧ ⟹ (abs ?x = abs ?y) = (?x = ?y)›*) intro: inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*))[1])
(*discuss goal 4*)
apply ((auto simp: distinct_map (*‹distinct (map ?f ?xs) = (distinct ?xs ∧ inj_on ?f (set ?xs))›*) univ (*‹UNIV = abs ` {0..<n}›*) Abs_inject (*‹⟦?x ∈ {0..<n}; ?y ∈ {0..<n}⟧ ⟹ (abs ?x = abs ?y) = (?x = ?y)›*) intro: inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*))[1])
(*proven 4 subgoals*) .
with bn (*‹CARD('a) = (n::nat)›*) have "class.enum ?enum (Ball (set ?enum)) (Bex (set ?enum)) ∧ n = CARD('a)"
by simp
then show "?thesis"
(*goal: ‹thesis::bool›*)
apply -
(*goal: ‹thesis›*)
by standard
qed
lemma inter_aform_plane_refine_ex_typedef:
"(xi, x) ∈ aforms_rel ⟹
(si, s) ∈ ⟨rl_rel⟩sctn_rel ⟹
length xi = d ⟹
length (normal si) = d ⟹
(nres_of (inter_aform_plane_lv (length xi) optns xi si), inter_sctn_specs d x s)
∈ ⟨aforms_rel⟩nres_rel"
if "∃(Rep :: 'a ⇒ nat) Abs. type_definition Rep Abs {0 ..< d :: nat}"
apply (rule type_impl_card_n_enum[OF that] (*‹(⋀enuma enum_all enum_ex. class.enum enuma enum_all enum_ex ∧ d = CARD('a) ⟹ ?thesis) ⟹ ?thesis›*))
(*goal: ‹⟦(xi, x) ∈ aforms_rel; (si, s) ∈ ⟨rl_rel⟩sctn_rel; length xi = d; length (normal si) = d⟧ ⟹ (nres_of (inter_aform_plane_lv (length xi) optns xi si), inter_sctn_specs d x s) ∈ ⟨aforms_rel⟩nres_rel›*)
apply (rule inter_aform_plane_refine_unoverloaded (*‹⟦class.enum ?enum ?enum_all ?enum_ex ∧ ?d = CARD(?'a); (?xi, ?x) ∈ aforms_rel; (?si, ?s) ∈ ⟨rl_rel⟩sctn_rel; length ?xi = ?d; length (normal ?si) = ?d⟧ ⟹ (nres_of (inter_aform_plane_lv (length ?xi) ?optns ?xi ?si), inter_sctn_specs ?d ?x ?s) ∈ ⟨aforms_rel⟩nres_rel›*))
(*goals:
1. ‹⋀enuma enum_all enum_ex. ⟦(xi, x) ∈ aforms_rel; (si, s) ∈ ⟨rl_rel⟩sctn_rel; length xi = d; length (normal si) = d; class.enum enuma enum_all enum_ex ∧ d = CARD('a)⟧ ⟹ class.enum (?enum2 enuma enum_all enum_ex) (?enum_all2 enuma enum_all enum_ex) (?enum_ex2 enuma enum_all enum_ex) ∧ d = CARD(?'a2)›
2. ‹⋀enuma enum_all enum_ex. ⟦(xi, x) ∈ aforms_rel; (si, s) ∈ ⟨rl_rel⟩sctn_rel; length xi = d; length (normal si) = d; class.enum enuma enum_all enum_ex ∧ d = CARD('a)⟧ ⟹ (xi, x) ∈ aforms_rel›
3. ‹⋀enuma enum_all enum_ex. ⟦(xi, x) ∈ aforms_rel; (si, s) ∈ ⟨rl_rel⟩sctn_rel; length xi = d; length (normal si) = d; class.enum enuma enum_all enum_ex ∧ d = CARD('a)⟧ ⟹ (si, s) ∈ ⟨rl_rel⟩sctn_rel›
4. ‹⋀enuma enum_all enum_ex. ⟦(xi, x) ∈ aforms_rel; (si, s) ∈ ⟨rl_rel⟩sctn_rel; length xi = d; length (normal si) = d; class.enum enuma enum_all enum_ex ∧ d = CARD('a)⟧ ⟹ length xi = d›
5. ‹⋀enuma enum_all enum_ex. ⟦(xi, x) ∈ aforms_rel; (si, s) ∈ ⟨rl_rel⟩sctn_rel; length xi = d; length (normal si) = d; class.enum enuma enum_all enum_ex ∧ d = CARD('a)⟧ ⟹ length (normal si) = d›
discuss goal 1*)
apply assumption
(*discuss goal 2*)
apply assumption
(*discuss goal 3*)
apply assumption
(*discuss goal 4*)
apply assumption
(*discuss goal 5*)
apply assumption
(*proven 5 subgoals*) .
lemma inter_aform_plane_refine:
"0 < d ⟹
(xi, x) ∈ aforms_rel ⟹
(si, s) ∈ ⟨Id⟩sctn_rel ⟹
length xi = d ⟹
length (normal si) = d ⟹
(nres_of (inter_aform_plane_lv (length xi) optns xi si), inter_sctn_specs d x s)
∈ ⟨aforms_rel⟩nres_rel"
apply (rule inter_aform_plane_refine_ex_typedef[cancel_type_definition, simplified] (*‹⟦(0::nat) < (?d::nat); (?xi::(real × real pdevs) list, ?x::real list set) ∈ aforms_rel; (?si::real list sctn, ?s::real list sctn) ∈ ⟨Id⟩sctn_rel; length ?xi = ?d; length (normal ?si) = ?d⟧ ⟹ (nres_of (inter_aform_plane_lv (length ?xi) (?optns::nat) ?xi ?si), inter_sctn_specs ?d ?x ?s) ∈ ⟨aforms_rel⟩nres_rel›*))
(*goals:
1. ‹⟦0 < d; (xi, x) ∈ aforms_rel; (si, s) ∈ ⟨Id⟩sctn_rel; length xi = d; length (normal si) = d⟧ ⟹ 0 < d›
2. ‹⟦0 < d; (xi, x) ∈ aforms_rel; (si, s) ∈ ⟨Id⟩sctn_rel; length xi = d; length (normal si) = d⟧ ⟹ (xi, x) ∈ aforms_rel›
3. ‹⟦0 < d; (xi, x) ∈ aforms_rel; (si, s) ∈ ⟨Id⟩sctn_rel; length xi = d; length (normal si) = d⟧ ⟹ (si, s) ∈ ⟨Id⟩sctn_rel›
4. ‹⟦0 < d; (xi, x) ∈ aforms_rel; (si, s) ∈ ⟨Id⟩sctn_rel; length xi = d; length (normal si) = d⟧ ⟹ length xi = d›
5. ‹⟦0 < d; (xi, x) ∈ aforms_rel; (si, s) ∈ ⟨Id⟩sctn_rel; length xi = d; length (normal si) = d⟧ ⟹ length (normal si) = d›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*)
apply ((assumption)[1])
(*discuss goal 3*)
apply ((assumption)[1])
(*discuss goal 4*)
apply ((assumption)[1])
(*discuss goal 5*) .
(*proven 5 subgoals*)
lemma Joints_reduce_aforms: "x ∈ Joints X ⟹ x ∈ Joints (reduce_aforms prec t X)"
apply (auto simp: reduce_aforms_def (*‹reduce_aforms ?prec ?C ?X = summarize_aforms ?prec ?C (degree_aforms ?X) ?X›*) summarize_threshold_def[abs_def] (*‹summarize_threshold ≡ λp t x y. t * infnorm (eucl_truncate_up p (tdev' p x)) ≤ infnorm y›*) Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*))
(*goal: ‹x ∈ Joints X ⟹ x ∈ Joints (reduce_aforms prec t X)›*)
proof (goal_cases)
(*goal: ‹⋀e. ⟦e ∈ funcset UNIV {- 1..1}; x = map (aform_val e) X⟧ ⟹ map (aform_val e) X ∈ (λe. map (aform_val e) (summarize_aforms prec t (degree_aforms X) X)) ` funcset UNIV {- 1..1}›*)
case (1 e) (*‹e ∈ funcset UNIV {- 1..1}› ‹x = map (aform_val e) X›*)
from summarize_aformsE[OF ‹e ∈ _› order_refl] (*‹(⋀e'. ⟦aform_vals e ?X = aform_vals e' (summarize_aforms ?p ?C (degree_aforms ?X) ?X); ⋀i. i < degree_aforms ?X ⟹ e i = e' i; e' ∈ funcset UNIV {- 1..1}⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain e' where "aform_vals e X = aform_vals e' (summarize_aforms prec t (degree_aforms X) X)" "⋀i. i < degree_aforms X ⟹ e i = e' i" "e' ∈ funcset UNIV {- 1..1}"
(*goal: ‹(⋀e'. ⟦aform_vals e X = aform_vals e' (summarize_aforms prec t (degree_aforms X) X); ⋀i. i < degree_aforms X ⟹ e i = e' i; e' ∈ funcset UNIV {- 1..1}⟧ ⟹ thesis) ⟹ thesis›*)
by blast
thus "?case"
(*goal: ‹map (aform_val (e::nat ⇒ real)) (X::(real × real pdevs) list) ∈ (λe::nat ⇒ real. map (aform_val e) (summarize_aforms (prec::nat) (t::(real × real pdevs) list ⇒ nat ⇒ real list ⇒ bool) (degree_aforms X) X)) ` funcset UNIV {- (1::real)..1::real}›*)
by (auto intro!: image_eqI[where x=e'] (*‹⟦(?b::?'a::type) = (?f::(nat ⇒ real) ⇒ ?'a::type) (e'::nat ⇒ real); e' ∈ (?A::(nat ⇒ real) set)⟧ ⟹ ?b ∈ ?f ` ?A›*) simp: aform_vals_def (*‹aform_vals (?e::nat ⇒ real) (?X::(?'a::real_normed_vector × ?'a::real_normed_vector pdevs) list) = map (aform_val ?e) ?X›*))
qed
lemma length_reduce_aform[simp]: "length (reduce_aforms optns a x) = length x"
by (auto simp: reduce_aforms_def (*‹reduce_aforms ?prec ?C ?X = summarize_aforms ?prec ?C (degree_aforms ?X) ?X›*))
lemma reduce_aform_refine:
"(xi, x) ∈ aforms_rel ⟹ length xi = d ⟹
(RETURN (reduce_aforms prec C xi), reduce_specs d r x) ∈ ⟨aforms_rel⟩nres_rel"
apply (auto simp: reduce_specs_def (*‹reduce_specs ?d ?reach_options_o ?X = SPEC (λR. env_len R ?d ∧ ?X ⊆ R)›*) nres_rel_def (*‹⟨?R⟩nres_rel ≡ {(c, a). c ≤ ⇓ ?R a}›*) comps (*‹(∘) ≡ λf g x. f (g x)› ‹(o2) ≡ λf g x y. f (g x y)› ‹(o3) ≡ λf g x y z. f (g x y z)› ‹(o4) ≡ λf g w x y z. f (g w x y z)› ‹(o5) ≡ λf g w x y z a. f (g w x y z a)› ‹(o6) ≡ λf g w x y z a b. f (g w x y z a b)›*) aforms_relp_def (*‹⟨?R⟩aforms_relp = aforms_rel O ⟨?R⟩set_rel›*) mem_lv_rel_set_rel_iff (*‹((?y, ?z) ∈ ⟨lv_rel⟩set_rel) = (?z = eucl_of_list ` ?y ∧ (∀x∈?y. length x = DIM(?'a)))›*) aforms_rel_def (*‹aforms_rel = br Joints top›*) env_len_def (*‹env_len ?env ?l = (∀xs∈?env. length xs = ?l)›*) intro!: RETURN_SPEC_refine (*‹∃x'. (?x, x') ∈ ?R ∧ ?Φ x' ⟹ RETURN ?x ≤ ⇓ ?R (SPEC ?Φ)›*))
(*goal: ‹⟦(xi, x) ∈ aforms_rel; length xi = d⟧ ⟹ (RETURN (reduce_aforms prec C xi), reduce_specs d r x) ∈ ⟨aforms_rel⟩nres_rel›*)
apply (auto simp: br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) env_len_def (*‹env_len ?env ?l = (∀xs∈?env. length xs = ?l)›*))
(*goals:
1. ‹⋀xs. ⟦x = Joints xi; d = length xi; xs ∈ Joints (reduce_aforms prec C xi)⟧ ⟹ length xs = length xi›
2. ‹⋀xa. ⟦x = Joints xi; d = length xi; xa ∈ Joints xi⟧ ⟹ xa ∈ Joints (reduce_aforms prec C xi)›
discuss goal 1*)
apply ((auto simp: mem_lv_rel_set_rel_iff (*‹((?y::real list set, ?z::?'a::executable_euclidean_space set) ∈ ⟨lv_rel⟩set_rel) = (?z = eucl_of_list ` ?y ∧ (∀x::real list∈?y. length x = DIM(?'a::executable_euclidean_space)))›*) Joints_imp_length_eq (*‹(?xs::?'a::real_normed_vector list) ∈ Joints (?XS::(?'a::real_normed_vector × ?'a::real_normed_vector pdevs) list) ⟹ length ?xs = length ?XS›*) intro!: in_image_eucl_of_list_eucl_of_list_aform (*‹⟦length (?x::(real × real pdevs) list) = DIM(?'a::executable_euclidean_space); (?xa::?'a::executable_euclidean_space) ∈ Affine (eucl_of_list_aform ?x)⟧ ⟹ ?xa ∈ eucl_of_list ` Joints ?x›*) Joints_reduce_aforms (*‹(?x::real list) ∈ Joints (?X::(real × real pdevs) list) ⟹ ?x ∈ Joints (reduce_aforms (?prec::nat) (?t::(real × real pdevs) list ⇒ nat ⇒ real list ⇒ bool) ?X)›*) eucl_of_list_mem_eucl_of_list_aform (*‹⟦(?x::real list) ∈ Joints (?a::(real × real pdevs) list); length ?a = DIM(?'a::executable_euclidean_space)⟧ ⟹ eucl_of_list ?x ∈ Affine (eucl_of_list_aform ?a)›*))[1])
(*discuss goal 2*)
apply ((auto simp: mem_lv_rel_set_rel_iff (*‹((?y, ?z) ∈ ⟨lv_rel⟩set_rel) = (?z = eucl_of_list ` ?y ∧ (∀x∈?y. length x = DIM(?'a)))›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*) intro!: in_image_eucl_of_list_eucl_of_list_aform (*‹⟦length ?x = DIM(?'a); ?xa ∈ Affine (eucl_of_list_aform ?x)⟧ ⟹ ?xa ∈ eucl_of_list ` Joints ?x›*) Joints_reduce_aforms (*‹?x ∈ Joints ?X ⟹ ?x ∈ Joints (reduce_aforms ?prec ?t ?X)›*) eucl_of_list_mem_eucl_of_list_aform (*‹⟦?x ∈ Joints ?a; length ?a = DIM(?'a)⟧ ⟹ eucl_of_list ?x ∈ Affine (eucl_of_list_aform ?a)›*))[1])
(*proven 2 subgoals*) .
lemma aform_euclarithform_refine:
"(nres_of o2 aform_form optns, approx_form_spec) ∈ Id → aforms_rel → ⟨bool_rel⟩nres_rel"
by (auto simp: approx_form_spec_def (*‹approx_form_spec ?ea ?E = SPEC (λr. r ⟶ (∀e∈?E. interpret_form ?ea e))›*) nres_rel_def (*‹⟨?R⟩nres_rel ≡ {(c, a). c ≤ ⇓ ?R a}›*) comps (*‹(∘) ≡ λf g x. f (g x)› ‹(o2) ≡ λf g x y. f (g x y)› ‹(o3) ≡ λf g x y z. f (g x y z)› ‹(o4) ≡ λf g w x y z. f (g w x y z)› ‹(o5) ≡ λf g w x y z a. f (g w x y z a)› ‹(o6) ≡ λf g w x y z a b. f (g w x y z a b)›*) aform_form_def (*‹aform_form ?prec ?form ?xs = dRETURN (approx_form_aform ?prec ?form ?xs)›*) aforms_rel_def (*‹aforms_rel = br Joints top›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) approx_form_aform (*‹⟦approx_form_aform ?p ?f ?VS; ?vs ∈ Joints ?VS⟧ ⟹ interpret_form ?f ?vs›*) dest!: approx_form_aux (*‹⟦approx_form ?prec ?f ?vs ?ss; bounded_by ?xs ?vs⟧ ⟹ interpret_form ?f ?xs›*) intro!: ivls_of_aforms (*‹?xs ∈ Joints ?XS ⟹ bounded_by ?xs (ivls_of_aforms ?prec ?XS)›*))
lemma aform_isFDERIV:
"(λN xs fas vs. nres_of (aform_isFDERIV optns N xs fas vs), isFDERIV_spec)
∈ nat_rel → ⟨nat_rel⟩list_rel → ⟨Id⟩list_rel → aforms_rel → ⟨bool_rel⟩nres_rel"
by (auto simp: isFDERIV_spec_def (*‹isFDERIV_spec ?N ?xs ?fas ?VS = SPEC (λr. r ⟶ (∀vs∈?VS. isFDERIV ?N ?xs ?fas vs))›*) nres_rel_def (*‹⟨?R⟩nres_rel ≡ {(c, a). c ≤ ⇓ ?R a}›*) comps (*‹(∘) ≡ λf g x. f (g x)› ‹(o2) ≡ λf g x y. f (g x y)› ‹(o3) ≡ λf g x y z. f (g x y z)› ‹(o4) ≡ λf g w x y z. f (g w x y z)› ‹(o5) ≡ λf g w x y z a. f (g w x y z a)› ‹(o6) ≡ λf g w x y z a b. f (g w x y z a b)›*) aform_isFDERIV_def (*‹aform_isFDERIV ?prec ?n ?ns ?fas ?xs = dRETURN (isFDERIV_approx ?prec ?n ?ns ?fas (ivls_of_aforms ?prec ?xs))›*) aforms_rel_def (*‹aforms_rel = br Joints top›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) dest!: approx_form_aux (*‹⟦approx_form ?prec ?f ?vs ?ss; bounded_by ?xs ?vs⟧ ⟹ interpret_form ?f ?xs›*) intro!: ivls_of_aforms (*‹?xs ∈ Joints ?XS ⟹ bounded_by ?xs (ivls_of_aforms ?prec ?XS)›*) isFDERIV_approx (*‹⟦bounded_by ?vs ?VS; isFDERIV_approx ?prec ?n ?xs ?fas ?VS⟧ ⟹ isFDERIV ?n ?xs ?fas ?vs›*))
lemma approx_slp_lengthD: "approx_slp p slp a = Some xs ⟹
length xs = length slp + length a"
apply (induction slp arbitrary: xs a)
(*goals:
1. ‹⋀xs a. approx_slp p [] a = Some xs ⟹ length xs = length [] + length a›
2. ‹⋀a slp xs aa. ⟦⋀xs a. approx_slp p slp a = Some xs ⟹ length xs = length slp + length a; approx_slp p (a # slp) aa = Some xs⟧ ⟹ length xs = length (a # slp) + length aa›
discuss goal 1*)
apply ((auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*))[1])
(*discuss goal 2*)
apply ((auto simp: bind_eq_Some_conv (*‹((?f::?'b option) ⤜ (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*))[1])
(*proven 2 subgoals*) .
lemma approx_slp_outer_lengthD: "approx_slp_outer p d slp a = Some xs ⟹
length xs = min d (length slp + length a)"
by (auto simp: approx_slp_outer_def (*‹approx_slp_outer (?p::nat) (?n::nat) (?slp::floatarith list) (?XS::(real × real pdevs) list) = (let d::nat = degree_aforms ?XS; XSe::((real × real pdevs) × real) list = map (λx::real × real pdevs. (x, 0::real)) ?XS in approx_slp ?p ?slp XSe ⤜ (λrs::((real × real pdevs) × real) list. let rs'::((real × real pdevs) × real) list = take ?n rs; d'::nat = max d (degree_aforms_err rs') in Some (aforms_err_to_aforms d' rs')))›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) bind_eq_Some_conv (*‹((?f::?'b option) ⤜ (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*) o_def (*‹(?f::?'b ⇒ ?'c) ∘ (?g::?'a ⇒ ?'b) = (λx::?'a. ?f (?g x))›*) aforms_err_to_aforms_def (*‹aforms_err_to_aforms (?d::nat) (?xs::((real × real pdevs) × real) list) = map2 (λ(d::nat) x::(real × real pdevs) × real. aform_err_to_aform x d) [?d..<?d + length ?xs] ?xs›*) aform_err_to_aform_def (*‹aform_err_to_aform (?X::(real × real pdevs) × real) (?n::nat) = (fst (fst ?X), pdev_upd (snd (fst ?X)) ?n (snd ?X))›*) dest!: approx_slp_lengthD (*‹approx_slp (?p::nat) (?slp::floatarith list) (?a::((real × real pdevs) × real) list) = Some (?xs::((real × real pdevs) × real) list) ⟹ length ?xs = length ?slp + length ?a›*))
lemma approx_slp_refine:
"(nres_of o3 aform_slp prec, approx_slp_spec fas) ∈
nat_rel → fas_rel → aforms_rel → ⟨⟨aforms_rel⟩option_rel⟩nres_rel"
apply (auto simp: approx_slp_spec_def (*‹approx_slp_spec ?fas ?l ?slp ?env = ASSERT (slp_of_fas ?fas = ?slp ∧ length ?fas = ?l) ⤜ (λ_. SPEC (λR. case R of None ⇒ True | Some R ⇒ ∃e. env_len ?env e ∧ env_len R ?l ∧ (∀e∈?env. interpret_floatariths ?fas e ∈ R)))›*) comps (*‹(∘) ≡ λf g x. f (g x)› ‹(o2) ≡ λf g x y. f (g x y)› ‹(o3) ≡ λf g x y z. f (g x y z)› ‹(o4) ≡ λf g w x y z. f (g w x y z)› ‹(o5) ≡ λf g w x y z a. f (g w x y z a)› ‹(o6) ≡ λf g w x y z a b. f (g w x y z a b)›*) aform_slp_def (*‹aform_slp ?prec ?n ?slp ?xs = dRETURN (approx_slp_outer ?prec ?n ?slp ?xs)›*) nres_rel_def (*‹⟨?R⟩nres_rel ≡ {(c, a). c ≤ ⇓ ?R a}›*) intro!: RETURN_SPEC_refine (*‹∃x'. (?x, x') ∈ ?R ∧ ?Φ x' ⟹ RETURN ?x ≤ ⇓ ?R (SPEC ?Φ)›*) ASSERT_refine_right (*‹(?Φ ⟹ ?S ≤ ⇓ ?R ?S') ⟹ ?S ≤ ⇓ ?R (ASSERT ?Φ ⤜ (λ_. ?S'))›*))
(*goal: ‹(nres_of o3 aform_slp prec, approx_slp_spec fas) ∈ nat_rel → fas_rel → aforms_rel → ⟨⟨aforms_rel⟩option_rel⟩nres_rel›*)
subgoal for a and b
apply (rule exI[where x = "map_option Joints (approx_slp_outer prec (length fas) (slp_of_fas fas) a)"] (*‹?P (map_option Joints (approx_slp_outer prec (length fas) (slp_of_fas fas) a)) ⟹ ∃x. ?P x›*))
(*goal: ‹(a, b) ∈ aforms_rel ⟹ ∃x'. (approx_slp_outer prec (length fas) (slp_of_fas fas) a, x') ∈ ⟨aforms_rel⟩option_rel ∧ (case x' of None ⇒ True | Some R ⇒ ∃e. env_len b e ∧ env_len R (length fas) ∧ (∀e∈b. interpret_floatariths fas e ∈ R))›*)
apply (auto simp: option.splits (*‹(?P::?'b::type ⇒ bool) (case ?option::?'a::type option of None ⇒ ?f1.0::?'b::type | Some (x::?'a::type) ⇒ (?f2.0::?'a::type ⇒ ?'b::type) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a::type. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b::type ⇒ bool) (case ?option::?'a::type option of None ⇒ ?f1.0::?'b::type | Some (x::?'a::type) ⇒ (?f2.0::?'a::type ⇒ ?'b::type) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a::type. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) aforms_rel_def (*‹aforms_rel = br Joints top›*) br_def (*‹br (?α::?'a::type ⇒ ?'b::type) (?I::?'a::type ⇒ bool) ≡ {(c::?'a::type, a::?'b::type). a = ?α c ∧ ?I c}›*) env_len_def (*‹env_len (?env::?'a::type list set) (?l::nat) = (∀xs::?'a::type list∈?env. length xs = ?l)›*) Joints_imp_length_eq (*‹(?xs::?'a::real_normed_vector list) ∈ Joints (?XS::(?'a::real_normed_vector × ?'a::real_normed_vector pdevs) list) ⟹ length ?xs = length ?XS›*))
(*goal: ‹(a, b) ∈ aforms_rel ⟹ (approx_slp_outer prec (length fas) (slp_of_fas fas) a, map_option Joints (approx_slp_outer prec (length fas) (slp_of_fas fas) a)) ∈ ⟨aforms_rel⟩option_rel ∧ (case map_option Joints (approx_slp_outer prec (length fas) (slp_of_fas fas) a) of None ⇒ True | Some R ⇒ ∃e. env_len b e ∧ env_len R (length fas) ∧ (∀e∈b. interpret_floatariths fas e ∈ R))›*)
apply ((auto dest!: approx_slp_outer_lengthD (*‹approx_slp_outer ?p ?d ?slp ?a = Some ?xs ⟹ length ?xs = min ?d (length ?slp + length ?a)›*))[1])
(*top goal: ‹⋀x2 xs. ⟦b = Joints a; approx_slp_outer prec (length fas) (slp_of_fas fas) a = Some x2; xs ∈ Joints x2⟧ ⟹ length x2 = length fas› and 1 goal remains*)
using length_slp_of_fas_le (*‹length ?fas ≤ length (slp_of_fas ?fas)›*) trans_le_add1 (*‹?i ≤ ?j ⟹ ?i ≤ ?j + ?m›*) approx_slp_outer_lengthD (*‹approx_slp_outer ?p ?d ?slp ?a = Some ?xs ⟹ length ?xs = min ?d (length ?slp + length ?a)›*) apply blast
(*top goal: ‹⋀x2 xs. ⟦b = Joints a; xs ∈ Joints x2; length x2 = min (length fas) (length (slp_of_fas fas) + length a)⟧ ⟹ length fas ≤ length (slp_of_fas fas) + length a› and 1 goal remains*)
using approx_slp_outer_plain (*‹⟦approx_slp_outer ?p ?n ?slp ?XS = Some ?RS; ?slp = slp_of_fas ?fas; ?n = length ?fas; ?xs ∈ Joints ?XS⟧ ⟹ interpret_floatariths ?fas ?xs ∈ Joints ?RS›*) by blast .
lemma fresh_index_aforms_Nil[simp]: "fresh_index_aforms [] = 0"
by (auto simp: fresh_index_aforms_def (*‹fresh_index_aforms ?xs = Max (insert 0 (degree_aform ` set ?xs))›*))
lemma independent_aforms_Nil[simp]:
"independent_aforms x [] = [x]"
by (auto simp: independent_aforms_def (*‹independent_aforms ?x ?env = msum_aform (fresh_index_aforms ?env) (0, zero_pdevs) ?x # ?env›*))
lemma mem_Joints_zero_iff[simp]: "x # xs ∈ Joints ((0, zero_pdevs) # XS) ⟷ (x = 0 ∧ xs ∈ Joints XS)"
by (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*))
lemma Joints_independent_aforms_eq: "Joints (independent_aforms x xs) = set_Cons (Affine x) (Joints xs)"
by (simp add: independent_aforms_def (*‹independent_aforms ?x ?env = msum_aform (fresh_index_aforms ?env) (0, zero_pdevs) ?x # ?env›*) Joints_msum_aform (*‹⟦degree_aform ?X ≤ ?d; ⋀Y. Y ∈ set ?YS ⟹ degree_aform Y ≤ ?d⟧ ⟹ Joints (msum_aform ?d ?X ?Y # ?YS) = {(x + y) # ys |x y ys. y ∈ Affine ?Y ∧ x # ys ∈ Joints (?X # ?YS)}›*) degree_le_fresh_index (*‹?a ∈ set ?A ⟹ degree_aform ?a ≤ fresh_index_aforms ?A›*) set_Cons_def (*‹set_Cons ?A ?XS = {x # xs |x xs. x ∈ ?A ∧ xs ∈ ?XS}›*))
lemma independent_aforms_refine: "(independent_aforms, set_Cons) ∈ ⟨rnv_rel⟩aform_rel → aforms_rel → aforms_rel"
by (auto simp: aforms_rel_def (*‹aforms_rel = br Joints top›*) br_def (*‹br (?α::?'a::type ⇒ ?'b::type) (?I::?'a::type ⇒ bool) ≡ {(c::?'a::type, a::?'b::type). a = ?α c ∧ ?I c}›*) aform_rel_def (*‹⟨rnv_rel⟩aform_rel = br Affine top›*) Joints_independent_aforms_eq (*‹Joints (independent_aforms (?x::?'a::real_normed_vector × ?'a::real_normed_vector pdevs) (?xs::(?'a::real_normed_vector × ?'a::real_normed_vector pdevs) list)) = set_Cons (Affine ?x) (Joints ?xs)›*))
end
locale aform_approximate_sets = approximate_sets
aform_ops
Joints
aforms_rel
begin
lemma Joints_in_lv_rel_set_relD:
"(Joints xs, X) ∈ ⟨lv_rel⟩set_rel ⟹ X = Affine (eucl_of_list_aform xs)"
unfolding lv_rel_def set_rel_br
(*goal: ‹(Joints xs, X) ∈ br ((`) eucl_of_list) (λX. ∀xs∈X. length xs = DIM('a)) ⟹ X = Affine (eucl_of_list_aform xs)›*)
by (auto simp: br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*) eucl_of_list_image_Joints[symmetric] (*‹length ?x = DIM(?'a) ⟹ Affine (eucl_of_list_aform ?x) = eucl_of_list ` Joints ?x›*))
lemma ncc_precond: "ncc_precond TYPE('a::executable_euclidean_space)"
unfolding ncc_precond_def ncc_def appr_rel_def
(*goal: ‹∀(Xi, X)∈aforms_rel O ⟨lv_rel⟩set_rel. X ≠ {} ∧ compact X ∧ convex X›*)
by (auto simp: aforms_rel_def (*‹aforms_rel = br Joints top›*) compact_Affine (*‹compact (Affine (?X::?'a × ?'a pdevs))›*) convex_Affine (*‹convex (Affine (?X::?'a × ?'a pdevs))›*) dest!: Joints_in_lv_rel_set_relD (*‹(Joints (?xs::(real × real pdevs) list), ?X::?'a set) ∈ ⟨lv_rel⟩set_rel ⟹ ?X = Affine (eucl_of_list_aform ?xs)›*) brD (*‹(?c::?'a, ?a::?'b) ∈ br (?α::?'a ⇒ ?'b) (?I::?'a ⇒ bool) ⟹ ?a = ?α ?c ∧ ?I ?c›*))
lemma fst_eucl_of_list_aform_map: "fst (eucl_of_list_aform (map (λx. (fst x, asdf x)) x)) =
fst (eucl_of_list_aform x)"
by (auto simp: eucl_of_list_aform_def (*‹eucl_of_list_aform (?xs::(real × real pdevs) list) = (eucl_of_list (map fst ?xs), sum_pdevs (λi::?'a. pdevs_scaleR (snd (?xs ! index Basis_list i)) i) Basis)›*) o_def (*‹(?f::?'b ⇒ ?'c) ∘ (?g::?'a ⇒ ?'b) = (λx::?'a. ?f (?g x))›*))
lemma
Affine_pdevs_of_list:― ‹TODO: move!›
"Affine (fst x, pdevs_of_list (map snd (list_of_pdevs (snd x)))) = Affine x"
by (auto simp: Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) elim: pdevs_val_of_list_of_pdevs2[where X = "snd x"] (*‹⟦?e ∈ funcset UNIV ?I; ⋀e'. ⟦pdevs_val ?e (snd x) = pdevs_val e' (pdevs_of_list (map snd (list_of_pdevs (snd x)))); e' ∈ funcset UNIV ?I⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) pdevs_val_of_list_of_pdevs[where X = "snd x"] (*‹⟦?e ∈ funcset UNIV ?I; 0 ∈ ?I; ⋀e'. ⟦pdevs_val ?e (pdevs_of_list (map snd (list_of_pdevs (snd x)))) = pdevs_val e' (snd x); e' ∈ funcset UNIV ?I⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
end
lemma aform_approximate_sets: "aform_approximate_sets prec"
apply unfold_locales
(*goal: ‹aform_approximate_sets prec›*)
unfolding aform_ops_def approximate_set_ops.simps
(*goals:
1. ‹aforms_rel ≡ br Joints top›
2. ‹⋀xrs yrs xri yri. ⟦SIDE_PRECOND (list_all2 (≤) xrs yrs); (xri, xrs) ∈ rl_rel; (yri, yrs) ∈ rl_rel⟧ ⟹ (aforms_of_ivls xri yri, lv_ivl $ xrs $ yrs) ∈ aforms_rel›
3. ‹(product_aforms, product_listset) ∈ aforms_rel → aforms_rel → aforms_rel›
4. ‹(msum_aforms', λxs ys. {map2 (+) x y |x y. x ∈ xs ∧ y ∈ ys}) ∈ aforms_rel → aforms_rel → aforms_rel›
5. ‹⋀xi x d. ⟦(xi, x) ∈ aforms_rel; length xi = d⟧ ⟹ (RETURN (inf_aforms (precision prec) xi), Inf_specs d x) ∈ ⟨rl_rel⟩nres_rel›
6. ‹⋀xi x d. ⟦(xi, x) ∈ aforms_rel; length xi = d⟧ ⟹ (RETURN (sup_aforms (precision prec) xi), Sup_specs d x) ∈ ⟨rl_rel⟩nres_rel›
7. ‹⋀ni n xi x d. ⟦(ni, n) ∈ nat_rel; (xi, x) ∈ aforms_rel; length xi = d⟧ ⟹ (RETURN (split_aforms_largest_uncond_take ni xi), split_spec_params d n x) ∈ ⟨aforms_rel ×⇩r aforms_rel⟩nres_rel›
8. ‹(RETURN o2 aform_inf_inner (precision prec), Inf_inners) ∈ aforms_rel → rl_rel → ⟨rnv_rel⟩nres_rel›
9. ‹(RETURN o2 aform_sup_inner (precision prec), Sup_inners) ∈ aforms_rel → rl_rel → ⟨rnv_rel⟩nres_rel›
10. ‹⋀xi x d si s. ⟦(xi, x) ∈ aforms_rel; length xi = d; length (normal si) = d; 0 < d; (si, s) ∈ ⟨rl_rel⟩sctn_rel⟧ ⟹ (nres_of (inter_aform_plane_lv (length xi) (precision prec) xi si), inter_sctn_specs d x s) ∈ ⟨aforms_rel⟩nres_rel›
11. ‹⋀xi x d rai ra. ⟦(xi, x) ∈ aforms_rel; length xi = d; (rai, ra) ∈ reduce_argument_rel TYPE(real × real pdevs)⟧ ⟹ (RETURN (reduce_aforms (precision prec) rai xi), reduce_specs d ra x) ∈ ⟨aforms_rel⟩nres_rel›
12. ‹((RETURN ∘∘ width_aforms) (precision prec), width_spec) ∈ aforms_rel → ⟨rnv_rel⟩nres_rel›
13. ‹⋀fas. (nres_of o3 aform_slp (precision prec), approx_slp_spec fas) ∈ nat_rel → fas_rel → aforms_rel → ⟨⟨aforms_rel⟩option_rel⟩nres_rel›
14. ‹(nres_of o2 aform_form (precision prec), approx_form_spec) ∈ Id → aforms_rel → ⟨bool_rel⟩nres_rel›
15. ‹(λN xs fas vs. nres_of (aform_isFDERIV (precision prec) N xs fas vs), isFDERIV_spec) ∈ nat_rel → ⟨nat_rel⟩list_rel → fas_rel → aforms_rel → ⟨bool_rel⟩nres_rel›
16. ‹⋀X. Joints X ≠ {}›
17. ‹⋀xrs xs. xrs ∈ Joints xs ⟹ length xrs = length xs›
18. ‹⋀xrs xs is. ⟦xrs ∈ Joints xs; ⋀i. i ∈ set is ⟹ i < length xs⟧ ⟹ map ((!) xrs) is ∈ Joints (map ((!) xs) is)›
19. ‹⋀xrs xs b. xrs ∈ Joints xs ⟹ ∃r. r # xrs ∈ Joints (b # xs)›
20. ‹⋀xrs. (xrs ∈ Joints []) = (xrs = [])›*)
subgoal for
unfolding relAPP_def aforms_rel_def
(*goal: ‹br Joints top ≡ br Joints top›*) .
subgoal for
by (force simp: aforms_of_ivls_refine (*‹⟦list_all2 (≤) ?xrs ?yrs; (?xri, ?xrs) ∈ rl_rel; (?yri, ?yrs) ∈ rl_rel⟧ ⟹ (aforms_of_ivls ?xri ?yri, lv_ivl ?xrs ?yrs) ∈ aforms_rel›*))
subgoal for
by (rule product_aforms_refine (*‹(product_aforms, product_listset) ∈ aforms_rel → aforms_rel → aforms_rel›*))
subgoal for
by (rule msum_aforms'_refine (*‹(msum_aforms', λ(xs::real list set) ys::real list set. {map2 (+) x y |(x::real list) y::real list. x ∈ xs ∧ y ∈ ys}) ∈ aforms_rel → aforms_rel → aforms_rel›*))
subgoal for
apply (rule inf_aforms_refine (*‹⟦(?xi, ?x) ∈ aforms_rel; length ?xi = ?d⟧ ⟹ (RETURN (inf_aforms ?optns ?xi), Inf_specs ?d ?x) ∈ ⟨rl_rel⟩nres_rel›*))
(*goals:
1. ‹⟦(xi_, x_) ∈ aforms_rel; length xi_ = d_⟧ ⟹ (xi_, x_) ∈ aforms_rel›
2. ‹⟦(xi_, x_) ∈ aforms_rel; length xi_ = d_⟧ ⟹ length xi_ = d_›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
subgoal for
apply (rule sup_aforms_refine (*‹⟦(?xi, ?x) ∈ aforms_rel; length ?xi = ?d⟧ ⟹ (RETURN (sup_aforms ?optns ?xi), Sup_specs ?d ?x) ∈ ⟨rl_rel⟩nres_rel›*))
(*goals:
1. ‹⟦(xi_::(real × real pdevs) list, x_::real list set) ∈ aforms_rel; length xi_ = (d_::nat)⟧ ⟹ (xi_, x_) ∈ aforms_rel›
2. ‹⟦(xi_::(real × real pdevs) list, x_::real list set) ∈ aforms_rel; length xi_ = (d_::nat)⟧ ⟹ length xi_ = d_›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
subgoal for
apply (rule split_aform_largest_take_refine (*‹⟦(?ni, ?n) ∈ nat_rel; (?xi, ?x) ∈ aforms_rel; length ?xi = ?d⟧ ⟹ (RETURN (split_aforms_largest_uncond_take ?ni ?xi), split_spec_params ?d ?n ?x) ∈ ⟨aforms_rel ×⇩r aforms_rel⟩nres_rel›*))
(*goals:
1. ‹⟦(ni_, n_) ∈ nat_rel; (xi_, x_) ∈ aforms_rel; length xi_ = d_⟧ ⟹ (ni_, n_) ∈ nat_rel›
2. ‹⟦(ni_, n_) ∈ nat_rel; (xi_, x_) ∈ aforms_rel; length xi_ = d_⟧ ⟹ (xi_, x_) ∈ aforms_rel›
3. ‹⟦(ni_, n_) ∈ nat_rel; (xi_, x_) ∈ aforms_rel; length xi_ = d_⟧ ⟹ length xi_ = d_›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*)
apply ((assumption)[1])
(*discuss goal 3*) .
(*proven 3 subgoals*)
subgoal for
by (rule aform_inf_inner_refine (*‹(RETURN o2 aform_inf_inner ?optns, Inf_inners) ∈ aforms_rel → rl_rel → ⟨rnv_rel⟩nres_rel›*))
subgoal for
by (rule aform_sup_inner_refine (*‹(RETURN o2 aform_sup_inner (?optns::nat), Sup_inners) ∈ aforms_rel → rl_rel → ⟨rnv_rel⟩nres_rel›*))
subgoal for
apply (rule inter_aform_plane_refine (*‹⟦0 < ?d; (?xi, ?x) ∈ aforms_rel; (?si, ?s) ∈ ⟨Id⟩sctn_rel; length ?xi = ?d; length (normal ?si) = ?d⟧ ⟹ (nres_of (inter_aform_plane_lv (length ?xi) ?optns ?xi ?si), inter_sctn_specs ?d ?x ?s) ∈ ⟨aforms_rel⟩nres_rel›*))
(*goals:
1. ‹⟦(xi_, x_) ∈ aforms_rel; length xi_ = d_; length (normal si_) = d_; 0 < d_; (si_, s_) ∈ ⟨rl_rel⟩sctn_rel⟧ ⟹ 0 < d_›
2. ‹⟦(xi_, x_) ∈ aforms_rel; length xi_ = d_; length (normal si_) = d_; 0 < d_; (si_, s_) ∈ ⟨rl_rel⟩sctn_rel⟧ ⟹ (xi_, x_) ∈ aforms_rel›
3. ‹⟦(xi_, x_) ∈ aforms_rel; length xi_ = d_; length (normal si_) = d_; 0 < d_; (si_, s_) ∈ ⟨rl_rel⟩sctn_rel⟧ ⟹ (si_, s_) ∈ ⟨Id⟩sctn_rel›
4. ‹⟦(xi_, x_) ∈ aforms_rel; length xi_ = d_; length (normal si_) = d_; 0 < d_; (si_, s_) ∈ ⟨rl_rel⟩sctn_rel⟧ ⟹ length xi_ = d_›
5. ‹⟦(xi_, x_) ∈ aforms_rel; length xi_ = d_; length (normal si_) = d_; 0 < d_; (si_, s_) ∈ ⟨rl_rel⟩sctn_rel⟧ ⟹ length (normal si_) = d_›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*proven 5 subgoals*) .
subgoal for
by (auto split: option.splits (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) intro!: reduce_aform_refine (*‹⟦(?xi::(real × real pdevs) list, ?x::real list set) ∈ aforms_rel; length ?xi = (?d::nat)⟧ ⟹ (RETURN (reduce_aforms (?prec::nat) (?C::(real × real pdevs) list ⇒ nat ⇒ real list ⇒ bool) ?xi), reduce_specs ?d (?r::unit) ?x) ∈ ⟨aforms_rel⟩nres_rel›*))
subgoal for
by (force simp: width_spec_def (*‹width_spec ?X = SPEC top›*) nres_rel_def (*‹⟨?R⟩nres_rel ≡ {(c, a). c ≤ ⇓ ?R a}›*))
subgoal for
by (rule approx_slp_refine (*‹(nres_of o3 aform_slp ?prec, approx_slp_spec ?fas) ∈ nat_rel → fas_rel → aforms_rel → ⟨⟨aforms_rel⟩option_rel⟩nres_rel›*))
subgoal for
by (rule aform_euclarithform_refine (*‹(nres_of o2 aform_form ?optns, approx_form_spec) ∈ Id → aforms_rel → ⟨bool_rel⟩nres_rel›*))
subgoal for
by (rule aform_isFDERIV (*‹(λN xs fas vs. nres_of (aform_isFDERIV ?optns N xs fas vs), isFDERIV_spec) ∈ nat_rel → ⟨nat_rel⟩list_rel → fas_rel → aforms_rel → ⟨bool_rel⟩nres_rel›*))
subgoal for
by simp
subgoal for
by (auto simp: Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*))
subgoal for
by (force simp: Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) intro!:)
subgoal for
by (force simp: Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` funcset UNIV {- 1..1}›*) intro!:)
subgoal for
by (auto simp: Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*)) .
end
| {
"path": "afp-2025-02-12/thys/Ordinary_Differential_Equations/Numerics/Refine_Rigorous_Numerics_Aform.thy",
"repo": "afp-2025-02-12",
"sha": "67a8a0eb2c00086a29dcf83427be7b91bf3c1c32c862aa14c67963681e347ed3"
} |
(* Author: Alexander Maletzky *)
section ‹Ordered Associative Lists for Polynomials›
theory OAlist_Poly_Mapping
imports PP_Type MPoly_Type_Class_Ordered OAlist
begin
text ‹We introduce a dedicated type for ordered associative lists (oalists) representing polynomials.
To that end, we require the order relation the oalists are sorted wrt. to be admissible term orders,
and furthermore sort the lists @{emph ‹descending›} rather than @{emph ‹ascending›}, because this
allows to implement various operations more efficiently.
For technical reasons, we must restrict the type of terms to types embeddable into
@{typ "(nat, nat) pp × nat"}, though. All types we are interested in meet this requirement.›
lemma comparator_lexicographic:
fixes f::"'a ⇒ 'b" and g::"'a ⇒ 'c"
assumes "comparator c1" and "comparator c2" and "⋀x y. f x = f y ⟹ g x = g y ⟹ x = y"
shows "comparator (λx y. case c1 (f x) (f y) of Eq ⇒ c2 (g x) (g y) | val ⇒ val)"
(is "comparator ?c3")
proof (-)
(*goal: ‹comparator (λx y. case c1 (f x) (f y) of Eq ⇒ c2 (g x) (g y) | Lt ⇒ Lt | Gt ⇒ Gt)›*)
from assms(1) (*‹comparator (c1::'b ⇒ 'b ⇒ order)›*) interpret c1: comparator c1 .
from assms(2) (*‹comparator c2›*) interpret c2: comparator c2 .
show "?thesis"
(*goal: ‹comparator (λx y. case c1 (f x) (f y) of Eq ⇒ c2 (g x) (g y) | Lt ⇒ Lt | Gt ⇒ Gt)›*)
proof (standard)
(*goals:
1. ‹⋀x y. invert_order (case c1 (f x) (f y) of Eq ⇒ c2 (g x) (g y) | Lt ⇒ Lt | Gt ⇒ Gt) = (case c1 (f y) (f x) of Eq ⇒ c2 (g y) (g x) | Lt ⇒ Lt | Gt ⇒ Gt)›
2. ‹⋀x y. (case c1 (f x) (f y) of Eq ⇒ c2 (g x) (g y) | Lt ⇒ Lt | Gt ⇒ Gt) = Eq ⟹ x = y›
3. ‹⋀x y z. ⟦(case c1 (f x) (f y) of Eq ⇒ c2 (g x) (g y) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt; (case c1 (f y) (f z) of Eq ⇒ c2 (g y) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt⟧ ⟹ (case c1 (f x) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
fix x :: 'a and y :: 'a
show "invert_order (?c3 x y) = ?c3 y x"
apply (simp add: c1.eq (*‹(c1 ?x ?y = Eq) = (?x = ?y)›*) c2.eq (*‹(c2 ?x ?y = Eq) = (?x = ?y)›*) split: order.split (*‹?P (case ?order of Eq ⇒ ?f1.0 | Lt ⇒ ?f2.0 | Gt ⇒ ?f3.0) = ((?order = Eq ⟶ ?P ?f1.0) ∧ (?order = Lt ⟶ ?P ?f2.0) ∧ (?order = Gt ⟶ ?P ?f3.0))›*))
(*goal: ‹invert_order (case c1 (f x) (f y) of Eq ⇒ c2 (g x) (g y) | Lt ⇒ Lt | Gt ⇒ Gt) = (case c1 (f y) (f x) of Eq ⇒ c2 (g y) (g x) | Lt ⇒ Lt | Gt ⇒ Gt)›*)
by (metis invert_order.simps( (*‹invert_order Lt = Gt›*) 1) invert_order.simps( (*‹invert_order Gt = Lt›*) 2) c1.sym (*‹invert_order ((c1::'b ⇒ 'b ⇒ order) (?x::'b) (?y::'b)) = c1 ?y ?x›*) c2.sym (*‹invert_order ((c2::'c ⇒ 'c ⇒ order) (?x::'c) (?y::'c)) = c2 ?y ?x›*) order.distinct( (*‹Lt ≠ Gt›*) 5))
next
(*goals:
1. ‹⋀x y. (case c1 (f x) (f y) of Eq ⇒ c2 (g x) (g y) | Lt ⇒ Lt | Gt ⇒ Gt) = Eq ⟹ x = y›
2. ‹⋀x y z. ⟦(case c1 (f x) (f y) of Eq ⇒ c2 (g x) (g y) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt; (case c1 (f y) (f z) of Eq ⇒ c2 (g y) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt⟧ ⟹ (case c1 (f x) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
fix x :: 'a and y :: 'a
assume "?c3 x y = Eq" (*‹(case (c1::'b ⇒ 'b ⇒ order) ((f::'a ⇒ 'b) (x::'a)) (f (y::'a)) of Eq ⇒ (c2::'c ⇒ 'c ⇒ order) ((g::'a ⇒ 'c) x) (g y) | Lt ⇒ Lt | Gt ⇒ Gt) = Eq›*)
hence "f x = f y" and "g x = g y"
apply -
(*goals:
1. ‹(case c1 (f x) (f y) of Eq ⇒ c2 (g x) (g y) | Lt ⇒ Lt | Gt ⇒ Gt) = Eq ⟹ f x = f y›
2. ‹(case c1 (f x) (f y) of Eq ⇒ c2 (g x) (g y) | Lt ⇒ Lt | Gt ⇒ Gt) = Eq ⟹ g x = g y›
discuss goal 1*)
apply (simp add: c1.eq (*‹((c1::'b ⇒ 'b ⇒ order) (?x::'b) (?y::'b) = Eq) = (?x = ?y)›*) c2.eq (*‹((c2::'c ⇒ 'c ⇒ order) (?x::'c) (?y::'c) = Eq) = (?x = ?y)›*) split: order.splits (*‹(?P::?'a ⇒ bool) (case ?order::order of Eq ⇒ ?f1.0::?'a | Lt ⇒ ?f2.0::?'a | Gt ⇒ ?f3.0::?'a) = ((?order = Eq ⟶ ?P ?f1.0) ∧ (?order = Lt ⟶ ?P ?f2.0) ∧ (?order = Gt ⟶ ?P ?f3.0))› ‹(?P::?'a ⇒ bool) (case ?order::order of Eq ⇒ ?f1.0::?'a | Lt ⇒ ?f2.0::?'a | Gt ⇒ ?f3.0::?'a) = (¬ (?order = Eq ∧ ¬ ?P ?f1.0 ∨ ?order = Lt ∧ ¬ ?P ?f2.0 ∨ ?order = Gt ∧ ¬ ?P ?f3.0))›*) if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
(*discuss goal 2*)
apply (simp add: c1.eq (*‹(c1 ?x ?y = Eq) = (?x = ?y)›*) c2.eq (*‹(c2 ?x ?y = Eq) = (?x = ?y)›*) split: order.splits (*‹?P (case ?order of Eq ⇒ ?f1.0 | Lt ⇒ ?f2.0 | Gt ⇒ ?f3.0) = ((?order = Eq ⟶ ?P ?f1.0) ∧ (?order = Lt ⟶ ?P ?f2.0) ∧ (?order = Gt ⟶ ?P ?f3.0))› ‹?P (case ?order of Eq ⇒ ?f1.0 | Lt ⇒ ?f2.0 | Gt ⇒ ?f3.0) = (¬ (?order = Eq ∧ ¬ ?P ?f1.0 ∨ ?order = Lt ∧ ¬ ?P ?f2.0 ∨ ?order = Gt ∧ ¬ ?P ?f3.0))›*) if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
(*proven 2 subgoals*) .
thus "x = y"
by (rule assms( (*‹⟦f ?x = f ?y; g ?x = g ?y⟧ ⟹ ?x = ?y›*) 3))
next
(*goal: ‹⋀x y z. ⟦(case c1 (f x) (f y) of Eq ⇒ c2 (g x) (g y) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt; (case c1 (f y) (f z) of Eq ⇒ c2 (g y) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt⟧ ⟹ (case c1 (f x) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
fix x :: 'a and y :: 'a and z :: 'a
assume "?c3 x y = Lt" (*‹(case (c1::'b ⇒ 'b ⇒ order) ((f::'a ⇒ 'b) (x::'a)) (f (y::'a)) of Eq ⇒ (c2::'c ⇒ 'c ⇒ order) ((g::'a ⇒ 'c) x) (g y) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
hence d1: "c1 (f x) (f y) = Lt ∨ (c1 (f x) (f y) = Eq ∧ c2 (g x) (g y) = Lt)"
by (simp split: order.splits (*‹?P (case ?order of Eq ⇒ ?f1.0 | Lt ⇒ ?f2.0 | Gt ⇒ ?f3.0) = ((?order = Eq ⟶ ?P ?f1.0) ∧ (?order = Lt ⟶ ?P ?f2.0) ∧ (?order = Gt ⟶ ?P ?f3.0))› ‹?P (case ?order of Eq ⇒ ?f1.0 | Lt ⇒ ?f2.0 | Gt ⇒ ?f3.0) = (¬ (?order = Eq ∧ ¬ ?P ?f1.0 ∨ ?order = Lt ∧ ¬ ?P ?f2.0 ∨ ?order = Gt ∧ ¬ ?P ?f3.0))›*))
assume "?c3 y z = Lt" (*‹(case (c1::'b ⇒ 'b ⇒ order) ((f::'a ⇒ 'b) (y::'a)) (f (z::'a)) of Eq ⇒ (c2::'c ⇒ 'c ⇒ order) ((g::'a ⇒ 'c) y) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
hence d2: "c1 (f y) (f z) = Lt ∨ (c1 (f y) (f z) = Eq ∧ c2 (g y) (g z) = Lt)"
by (simp split: order.splits (*‹?P (case ?order of Eq ⇒ ?f1.0 | Lt ⇒ ?f2.0 | Gt ⇒ ?f3.0) = ((?order = Eq ⟶ ?P ?f1.0) ∧ (?order = Lt ⟶ ?P ?f2.0) ∧ (?order = Gt ⟶ ?P ?f3.0))› ‹?P (case ?order of Eq ⇒ ?f1.0 | Lt ⇒ ?f2.0 | Gt ⇒ ?f3.0) = (¬ (?order = Eq ∧ ¬ ?P ?f1.0 ∨ ?order = Lt ∧ ¬ ?P ?f2.0 ∨ ?order = Gt ∧ ¬ ?P ?f3.0))›*))
from d1 (*‹c1 (f x) (f y) = Lt ∨ c1 (f x) (f y) = Eq ∧ c2 (g x) (g y) = Lt›*) show "?c3 x z = Lt"
proof (standard)
(*goals:
1. ‹c1 (f x) (f y) = Lt ⟹ (case c1 (f x) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›
2. ‹c1 (f x) (f y) = Eq ∧ c2 (g x) (g y) = Lt ⟹ (case c1 (f x) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
assume 1: "c1 (f x) (f y) = Lt" (*‹(c1::'b ⇒ 'b ⇒ order) ((f::'a ⇒ 'b) (x::'a)) (f (y::'a)) = Lt›*)
from d2 (*‹c1 (f y) (f z) = Lt ∨ c1 (f y) (f z) = Eq ∧ c2 (g y) (g z) = Lt›*) show "?thesis"
(*goal: ‹(case c1 (f x) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
proof (standard)
(*goals:
1. ‹c1 (f y) (f z) = Lt ⟹ (case c1 (f x) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›
2. ‹c1 (f y) (f z) = Eq ∧ c2 (g y) (g z) = Lt ⟹ (case c1 (f x) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
assume "c1 (f y) (f z) = Lt" (*‹(c1::'b ⇒ 'b ⇒ order) ((f::'a ⇒ 'b) (y::'a)) (f (z::'a)) = Lt›*)
with "1" (*‹c1 (f x) (f y) = Lt›*) have "c1 (f x) (f z) = Lt"
by (rule c1.comp_trans (*‹⟦c1 ?x ?y = Lt; c1 ?y ?z = Lt⟧ ⟹ c1 ?x ?z = Lt›*))
thus "?thesis"
(*goal: ‹(case c1 (f x) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
by simp
next
(*goal: ‹c1 (f y) (f z) = Eq ∧ c2 (g y) (g z) = Lt ⟹ (case c1 (f x) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
assume "c1 (f y) (f z) = Eq ∧ c2 (g y) (g z) = Lt" (*‹(c1::'b ⇒ 'b ⇒ order) ((f::'a ⇒ 'b) (y::'a)) (f (z::'a)) = Eq ∧ (c2::'c ⇒ 'c ⇒ order) ((g::'a ⇒ 'c) y) (g z) = Lt›*)
hence "f z = f y" and "c2 (g y) (g z) = Lt"
apply -
(*goals:
1. ‹c1 (f y) (f z) = Eq ∧ c2 (g y) (g z) = Lt ⟹ f z = f y›
2. ‹c1 (f y) (f z) = Eq ∧ c2 (g y) (g z) = Lt ⟹ c2 (g y) (g z) = Lt›
discuss goal 1*)
apply (simp add: c1.eq (*‹(c1 ?x ?y = Eq) = (?x = ?y)›*))
(*discuss goal 2*)
apply (simp add: c1.eq (*‹(c1 ?x ?y = Eq) = (?x = ?y)›*))
(*proven 2 subgoals*) .
with "1" (*‹c1 (f x) (f y) = Lt›*) show "?thesis"
(*goal: ‹(case c1 (f x) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
by simp
qed
next
(*goal: ‹(c1::'b ⇒ 'b ⇒ order) ((f::'a ⇒ 'b) (x::'a)) (f (y::'a)) = Eq ∧ (c2::'c ⇒ 'c ⇒ order) ((g::'a ⇒ 'c) x) (g y) = Lt ⟹ (case c1 (f x) (f (z::'a)) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
assume "c1 (f x) (f y) = Eq ∧ c2 (g x) (g y) = Lt" (*‹(c1::'b ⇒ 'b ⇒ order) ((f::'a ⇒ 'b) (x::'a)) (f (y::'a)) = Eq ∧ (c2::'c ⇒ 'c ⇒ order) ((g::'a ⇒ 'c) x) (g y) = Lt›*)
hence 1: "f x = f y" and 2: "c2 (g x) (g y) = Lt"
apply -
(*goals:
1. ‹c1 (f x) (f y) = Eq ∧ c2 (g x) (g y) = Lt ⟹ f x = f y›
2. ‹c1 (f x) (f y) = Eq ∧ c2 (g x) (g y) = Lt ⟹ c2 (g x) (g y) = Lt›
discuss goal 1*)
apply (simp add: c1.eq (*‹((c1::'b::type ⇒ 'b::type ⇒ order) (?x::'b::type) (?y::'b::type) = Eq) = (?x = ?y)›*))
(*discuss goal 2*)
apply (simp add: c1.eq (*‹(c1 ?x ?y = Eq) = (?x = ?y)›*))
(*proven 2 subgoals*) .
from d2 (*‹c1 (f y) (f z) = Lt ∨ c1 (f y) (f z) = Eq ∧ c2 (g y) (g z) = Lt›*) show "?thesis"
(*goal: ‹(case c1 (f x) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
proof (standard)
(*goals:
1. ‹(c1::'b::type ⇒ 'b::type ⇒ order) ((f::'a::type ⇒ 'b::type) (y::'a::type)) (f (z::'a::type)) = Lt ⟹ (case c1 (f (x::'a::type)) (f z) of Eq ⇒ (c2::'c::type ⇒ 'c::type ⇒ order) ((g::'a::type ⇒ 'c::type) x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›
2. ‹(c1::'b::type ⇒ 'b::type ⇒ order) ((f::'a::type ⇒ 'b::type) (y::'a::type)) (f (z::'a::type)) = Eq ∧ (c2::'c::type ⇒ 'c::type ⇒ order) ((g::'a::type ⇒ 'c::type) y) (g z) = Lt ⟹ (case c1 (f (x::'a::type)) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
assume "c1 (f y) (f z) = Lt" (*‹(c1::'b ⇒ 'b ⇒ order) ((f::'a ⇒ 'b) (y::'a)) (f (z::'a)) = Lt›*)
thus "?thesis"
(*goal: ‹(case (c1::'b::type ⇒ 'b::type ⇒ order) ((f::'a::type ⇒ 'b::type) (x::'a::type)) (f (z::'a::type)) of Eq ⇒ (c2::'c::type ⇒ 'c::type ⇒ order) ((g::'a::type ⇒ 'c::type) x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
by (simp add: 1 (*‹(f::'a ⇒ 'b) (x::'a) = f (y::'a)›*))
next
(*goal: ‹c1 (f y) (f z) = Eq ∧ c2 (g y) (g z) = Lt ⟹ (case c1 (f x) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
assume "c1 (f y) (f z) = Eq ∧ c2 (g y) (g z) = Lt" (*‹(c1::'b ⇒ 'b ⇒ order) ((f::'a ⇒ 'b) (y::'a)) (f (z::'a)) = Eq ∧ (c2::'c ⇒ 'c ⇒ order) ((g::'a ⇒ 'c) y) (g z) = Lt›*)
hence 3: "f y = f z" and "c2 (g y) (g z) = Lt"
apply -
(*goals:
1. ‹(c1::'b ⇒ 'b ⇒ order) ((f::'a ⇒ 'b) (y::'a)) (f (z::'a)) = Eq ∧ (c2::'c ⇒ 'c ⇒ order) ((g::'a ⇒ 'c) y) (g z) = Lt ⟹ f y = f z›
2. ‹(c1::'b ⇒ 'b ⇒ order) ((f::'a ⇒ 'b) (y::'a)) (f (z::'a)) = Eq ∧ (c2::'c ⇒ 'c ⇒ order) ((g::'a ⇒ 'c) y) (g z) = Lt ⟹ c2 (g y) (g z) = Lt›
discuss goal 1*)
apply (simp add: c1.eq (*‹(c1 ?x ?y = Eq) = (?x = ?y)›*))
(*discuss goal 2*)
apply (simp add: c1.eq (*‹(c1 ?x ?y = Eq) = (?x = ?y)›*))
(*proven 2 subgoals*) .
from "2" (*‹c2 (g x) (g y) = Lt›*) this(2) (*‹c2 (g y) (g z) = Lt›*) have "c2 (g x) (g z) = Lt"
by (rule c2.comp_trans (*‹⟦c2 ?x ?y = Lt; c2 ?y ?z = Lt⟧ ⟹ c2 ?x ?z = Lt›*))
thus "?thesis"
(*goal: ‹(case c1 (f x) (f z) of Eq ⇒ c2 (g x) (g z) | Lt ⇒ Lt | Gt ⇒ Gt) = Lt›*)
by (simp add: 1 (*‹f x = f y›*) 3 (*‹f y = f z›*))
qed
qed
qed
qed
class nat_term =
fixes rep_nat_term :: "'a ⇒ ((nat, nat) pp × nat)"
and splus :: "'a ⇒ 'a ⇒ 'a"
assumes rep_nat_term_inj: "rep_nat_term x = rep_nat_term y ⟹ x = y"
and full_component: "snd (rep_nat_term x) = i ⟹ (∃y. rep_nat_term y = (t, i))"
and splus_term: "rep_nat_term (splus x y) = pprod.splus (fst (rep_nat_term x)) (rep_nat_term y)"
begin
definition "lex_comp_aux = (λx y. case comp_of_ord lex_pp (fst (rep_nat_term x)) (fst (rep_nat_term y)) of
Eq ⇒ comparator_of (snd (rep_nat_term x)) (snd (rep_nat_term y)) | val ⇒ val)"
lemma full_componentE:
assumes "snd (rep_nat_term x) = i"
obtains y where "rep_nat_term y = (t, i)"
proof (-)
(*goal: ‹(⋀y. rep_nat_term y = (t, i) ⟹ thesis) ⟹ thesis›*)
from assms (*‹snd (rep_nat_term x) = i›*) have "∃y. rep_nat_term y = (t, i)"
by (rule full_component (*‹snd (rep_nat_term (?x::'a)) = (?i::nat) ⟹ ∃y::'a. rep_nat_term y = (?t::(nat, nat) pp, ?i)›*))
then obtain y where "rep_nat_term y = (t, i)"
(*goal: ‹(⋀y. rep_nat_term y = (t, i) ⟹ thesis) ⟹ thesis›*)
by standard
thus "?thesis"
(*goal: ‹thesis›*)
by standard
qed
end
class nat_pp_term = nat_term + zero + plus +
assumes rep_nat_term_zero: "rep_nat_term 0 = (0, 0)"
and splus_pp_term: "splus = (+)"
definition nat_term_comp :: "'a::nat_term comparator ⇒ bool"
where "nat_term_comp cmp ⟷
(∀u v. snd (rep_nat_term u) = snd (rep_nat_term v) ⟶ fst (rep_nat_term u) = 0 ⟶ cmp u v ≠ Gt) ∧
(∀u v. fst (rep_nat_term u) = fst (rep_nat_term v) ⟶ snd (rep_nat_term u) < snd (rep_nat_term v) ⟶ cmp u v = Lt) ∧
(∀t u v. cmp u v = Lt ⟶ cmp (splus t u) (splus t v) = Lt) ∧
(∀u v a b. fst (rep_nat_term u) = fst (rep_nat_term a) ⟶ fst (rep_nat_term v) = fst (rep_nat_term b) ⟶
snd (rep_nat_term u) = snd (rep_nat_term v) ⟶ snd (rep_nat_term a) = snd (rep_nat_term b) ⟶
cmp a b = Lt ⟶ cmp u v = Lt)"
lemma nat_term_compI:
assumes "⋀u v. snd (rep_nat_term u) = snd (rep_nat_term v) ⟹ fst (rep_nat_term u) = 0 ⟹ cmp u v ≠ Gt"
and "⋀u v. fst (rep_nat_term u) = fst (rep_nat_term v) ⟹ snd (rep_nat_term u) < snd (rep_nat_term v) ⟹ cmp u v = Lt"
and "⋀t u v. cmp u v = Lt ⟹ cmp (splus t u) (splus t v) = Lt"
and "⋀u v a b. fst (rep_nat_term u) = fst (rep_nat_term a) ⟹ fst (rep_nat_term v) = fst (rep_nat_term b) ⟹
snd (rep_nat_term u) = snd (rep_nat_term v) ⟹ snd (rep_nat_term a) = snd (rep_nat_term b) ⟹
cmp a b = Lt ⟹ cmp u v = Lt"
shows "nat_term_comp cmp"
unfolding nat_term_comp_def fst_conv snd_conv
(*goal: ‹(∀u v. snd (rep_nat_term u) = snd (rep_nat_term v) ⟶ fst (rep_nat_term u) = 0 ⟶ cmp u v ≠ Gt) ∧ (∀u v. fst (rep_nat_term u) = fst (rep_nat_term v) ⟶ snd (rep_nat_term u) < snd (rep_nat_term v) ⟶ cmp u v = Lt) ∧ (∀t u v. cmp u v = Lt ⟶ cmp (splus t u) (splus t v) = Lt) ∧ (∀u v a b. fst (rep_nat_term u) = fst (rep_nat_term a) ⟶ fst (rep_nat_term v) = fst (rep_nat_term b) ⟶ snd (rep_nat_term u) = snd (rep_nat_term v) ⟶ snd (rep_nat_term a) = snd (rep_nat_term b) ⟶ cmp a b = Lt ⟶ cmp u v = Lt)›*)
using assms (*‹⟦snd (rep_nat_term ?u) = snd (rep_nat_term ?v); fst (rep_nat_term ?u) = 0⟧ ⟹ cmp ?u ?v ≠ Gt› ‹⟦fst (rep_nat_term ?u) = fst (rep_nat_term ?v); snd (rep_nat_term ?u) < snd (rep_nat_term ?v)⟧ ⟹ cmp ?u ?v = Lt› ‹cmp ?u ?v = Lt ⟹ cmp (splus ?t ?u) (splus ?t ?v) = Lt› ‹⟦fst (rep_nat_term ?u) = fst (rep_nat_term ?a); fst (rep_nat_term ?v) = fst (rep_nat_term ?b); snd (rep_nat_term ?u) = snd (rep_nat_term ?v); snd (rep_nat_term ?a) = snd (rep_nat_term ?b); cmp ?a ?b = Lt⟧ ⟹ cmp ?u ?v = Lt›*) by blast
lemma nat_term_compD1:
assumes "nat_term_comp cmp" and "snd (rep_nat_term u) = snd (rep_nat_term v)" and "fst (rep_nat_term u) = 0"
shows "cmp u v ≠ Gt"
using assms (*‹nat_term_comp (cmp::'a ⇒ 'a ⇒ order)› ‹snd (rep_nat_term u) = snd (rep_nat_term v)› ‹fst (rep_nat_term u) = 0›*) unfolding nat_term_comp_def fst_conv
(*goal: ‹cmp u v ≠ Gt›*)
by blast
lemma nat_term_compD2:
assumes "nat_term_comp cmp" and "fst (rep_nat_term u) = fst (rep_nat_term v)" and "snd (rep_nat_term u) < snd (rep_nat_term v)"
shows "cmp u v = Lt"
using assms (*‹nat_term_comp cmp› ‹fst (rep_nat_term u) = fst (rep_nat_term v)› ‹snd (rep_nat_term u) < snd (rep_nat_term v)›*) unfolding nat_term_comp_def fst_conv snd_conv
(*goal: ‹cmp u v = Lt›*)
by blast
lemma nat_term_compD3:
assumes "nat_term_comp cmp" and "cmp u v = Lt"
shows "cmp (splus t u) (splus t v) = Lt"
using assms (*‹nat_term_comp cmp› ‹(cmp::'a::nat_term ⇒ 'a::nat_term ⇒ order) (u::'a::nat_term) (v::'a::nat_term) = Lt›*) unfolding nat_term_comp_def snd_conv
(*goal: ‹(cmp::'a ⇒ 'a ⇒ order) (splus (t::'a) (u::'a)) (splus t (v::'a)) = Lt›*)
by blast
lemma nat_term_compD4:
assumes "nat_term_comp cmp" and "fst (rep_nat_term u) = fst (rep_nat_term a)"
and "fst (rep_nat_term v) = fst (rep_nat_term b)" and "snd (rep_nat_term u) = snd (rep_nat_term v)"
and "snd (rep_nat_term a) = snd (rep_nat_term b)" and "cmp a b = Lt"
shows "cmp u v = Lt"
using assms (*‹nat_term_comp cmp› ‹fst (rep_nat_term u) = fst (rep_nat_term a)› ‹fst (rep_nat_term v) = fst (rep_nat_term b)› ‹snd (rep_nat_term u) = snd (rep_nat_term v)› ‹snd (rep_nat_term a) = snd (rep_nat_term b)› ‹(cmp::'a::nat_term ⇒ 'a::nat_term ⇒ order) (a::'a::nat_term) (b::'a::nat_term) = Lt›*) unfolding nat_term_comp_def snd_conv
(*goal: ‹cmp u v = Lt›*)
by blast
lemma nat_term_compD1':
assumes "comparator cmp" and "nat_term_comp cmp" and "snd (rep_nat_term u) ≤ snd (rep_nat_term v)"
and "fst (rep_nat_term u) = 0"
shows "cmp u v ≠ Gt"
proof (cases "snd (rep_nat_term u) = snd (rep_nat_term v)")
(*goals:
1. ‹snd (rep_nat_term u) = snd (rep_nat_term v) ⟹ cmp u v ≠ Gt›
2. ‹snd (rep_nat_term u) ≠ snd (rep_nat_term v) ⟹ cmp u v ≠ Gt›*)
case True (*‹snd (rep_nat_term u) = snd (rep_nat_term v)›*)
with assms(2) (*‹nat_term_comp cmp›*) show "?thesis"
(*goal: ‹cmp u v ≠ Gt›*)
using assms(4) (*‹fst (rep_nat_term u) = 0›*) by (rule nat_term_compD1 (*‹⟦nat_term_comp ?cmp; snd (rep_nat_term ?u) = snd (rep_nat_term ?v); fst (rep_nat_term ?u) = 0⟧ ⟹ ?cmp ?u ?v ≠ Gt›*))
next
(*goal: ‹snd (rep_nat_term u) ≠ snd (rep_nat_term v) ⟹ cmp u v ≠ Gt›*)
from assms(1) (*‹comparator cmp›*) interpret cmp: comparator cmp .
case False (*‹snd (rep_nat_term u) ≠ snd (rep_nat_term v)›*)
with assms(3) (*‹snd (rep_nat_term (u::'a)) ≤ snd (rep_nat_term (v::'a))›*) have a: "snd (rep_nat_term u) < snd (rep_nat_term v)"
by simp
from refl (*‹(?t::?'a) = ?t›*) obtain w :: 'a where eq: "rep_nat_term w = (0, snd (rep_nat_term v))"
(*goal: ‹(⋀w::'a. rep_nat_term w = (0::(nat, nat) pp, snd (rep_nat_term (v::'a))) ⟹ thesis::bool) ⟹ thesis›*)
by (rule full_componentE (*‹⟦snd (rep_nat_term ?x) = ?i; ⋀y. rep_nat_term y = (?t, ?i) ⟹ ?thesis⟧ ⟹ ?thesis›*))
have "cmp u w = Lt"
apply (rule nat_term_compD2 (*‹⟦nat_term_comp ?cmp; fst (rep_nat_term ?u) = fst (rep_nat_term ?v); snd (rep_nat_term ?u) < snd (rep_nat_term ?v)⟧ ⟹ ?cmp ?u ?v = Lt›*))
(*goals:
1. ‹nat_term_comp cmp›
2. ‹fst (rep_nat_term u) = fst (rep_nat_term w)›
3. ‹snd (rep_nat_term u) < snd (rep_nat_term w)›
discuss goal 1*)
apply (fact assms( (*‹nat_term_comp cmp›*) 2))
(*discuss goal 2*)
apply (simp add: eq (*‹rep_nat_term w = (0, snd (rep_nat_term v))›*) assms( (*‹fst (rep_nat_term u) = 0›*) 4) a (*‹snd (rep_nat_term u) < snd (rep_nat_term v)›*))
(*discuss goal 3*)
apply (simp add: eq (*‹rep_nat_term w = (0, snd (rep_nat_term v))›*) assms( (*‹fst (rep_nat_term u) = 0›*) 4) a (*‹snd (rep_nat_term u) < snd (rep_nat_term v)›*))
(*proven 3 subgoals*) .
moreover have "cmp w v ≠ Gt"
apply (rule nat_term_compD1 (*‹⟦nat_term_comp ?cmp; snd (rep_nat_term ?u) = snd (rep_nat_term ?v); fst (rep_nat_term ?u) = 0⟧ ⟹ ?cmp ?u ?v ≠ Gt›*))
(*goals:
1. ‹nat_term_comp cmp›
2. ‹snd (rep_nat_term w) = snd (rep_nat_term v)›
3. ‹fst (rep_nat_term w) = 0›
discuss goal 1*)
apply (fact assms( (*‹nat_term_comp (cmp::'a::nat_term ⇒ 'a::nat_term ⇒ order)›*) 2))
(*discuss goal 2*)
apply (simp add: eq (*‹rep_nat_term w = (0, snd (rep_nat_term v))›*))
(*discuss goal 3*)
apply (simp add: eq (*‹rep_nat_term w = (0, snd (rep_nat_term v))›*))
(*proven 3 subgoals*) .
ultimately show "cmp u v ≠ Gt"
by (simp add: cmp.nGt_le_conv (*‹(cmp ?x ?y ≠ Gt) = cmp.le ?x ?y›*) cmp.Lt_lt_conv (*‹(cmp ?x ?y = Lt) = cmp.lt ?x ?y›*))
qed
lemma nat_term_compD4':
assumes "comparator cmp" and "nat_term_comp cmp" and "fst (rep_nat_term u) = fst (rep_nat_term a)"
and "fst (rep_nat_term v) = fst (rep_nat_term b)" and "snd (rep_nat_term u) = snd (rep_nat_term v)"
and "snd (rep_nat_term a) = snd (rep_nat_term b)"
shows "cmp u v = cmp a b"
proof (-)
(*goal: ‹cmp u v = cmp a b›*)
from assms(1) (*‹comparator (cmp::'a ⇒ 'a ⇒ order)›*) interpret cmp: comparator cmp .
show "?thesis"
(*goal: ‹(cmp::'a ⇒ 'a ⇒ order) (u::'a) (v::'a) = cmp (a::'a) (b::'a)›*)
proof (cases "cmp a b")
(*goals:
1. ‹(cmp::'a ⇒ 'a ⇒ order) (a::'a) (b::'a) = Eq ⟹ cmp (u::'a) (v::'a) = cmp a b›
2. ‹(cmp::'a ⇒ 'a ⇒ order) (a::'a) (b::'a) = Lt ⟹ cmp (u::'a) (v::'a) = cmp a b›
3. ‹(cmp::'a ⇒ 'a ⇒ order) (a::'a) (b::'a) = Gt ⟹ cmp (u::'a) (v::'a) = cmp a b›*)
case Eq (*‹cmp a b = Eq›*)
hence "fst (rep_nat_term u) = fst (rep_nat_term v)"
by (simp add: cmp.eq (*‹(cmp ?x ?y = Eq) = (?x = ?y)›*) assms( (*‹fst (rep_nat_term u) = fst (rep_nat_term a)› ‹fst (rep_nat_term v) = fst (rep_nat_term b)›*) 3, 4))
hence "rep_nat_term u = rep_nat_term v"
using assms(5) (*‹snd (rep_nat_term u) = snd (rep_nat_term v)›*) by (rule prod_eqI (*‹⟦fst ?p = fst ?q; snd ?p = snd ?q⟧ ⟹ ?p = ?q›*))
hence "u = v"
by (rule rep_nat_term_inj (*‹rep_nat_term ?x = rep_nat_term ?y ⟹ ?x = ?y›*))
thus "?thesis"
(*goal: ‹cmp u v = cmp a b›*)
by (simp add: Eq (*‹(cmp::'a ⇒ 'a ⇒ order) (a::'a) (b::'a) = Eq›*))
next
(*goals:
1. ‹cmp a b = Lt ⟹ cmp u v = cmp a b›
2. ‹cmp a b = Gt ⟹ cmp u v = cmp a b›*)
case Lt (*‹cmp a b = Lt›*)
with assms(2,3,4,5,6) (*‹nat_term_comp (cmp::'a::nat_term ⇒ 'a::nat_term ⇒ order)› ‹fst (rep_nat_term u) = fst (rep_nat_term a)› ‹fst (rep_nat_term v) = fst (rep_nat_term b)› ‹snd (rep_nat_term u) = snd (rep_nat_term v)› ‹snd (rep_nat_term a) = snd (rep_nat_term b)›*) have "cmp u v = Lt"
by (rule nat_term_compD4 (*‹⟦nat_term_comp (?cmp::?'a ⇒ ?'a ⇒ order); fst (rep_nat_term (?u::?'a)) = fst (rep_nat_term (?a::?'a)); fst (rep_nat_term (?v::?'a)) = fst (rep_nat_term (?b::?'a)); snd (rep_nat_term ?u) = snd (rep_nat_term ?v); snd (rep_nat_term ?a) = snd (rep_nat_term ?b); ?cmp ?a ?b = Lt⟧ ⟹ ?cmp ?u ?v = Lt›*))
thus "?thesis"
(*goal: ‹cmp u v = cmp a b›*)
by (simp add: Lt (*‹cmp a b = Lt›*))
next
(*goal: ‹cmp a b = Gt ⟹ cmp u v = cmp a b›*)
case Gt (*‹cmp a b = Gt›*)
hence "cmp b a = Lt"
by (simp only: cmp.Gt_lt_conv (*‹(cmp ?x ?y = Gt) = cmp.lt ?y ?x›*) cmp.Lt_lt_conv (*‹(cmp ?x ?y = Lt) = cmp.lt ?x ?y›*))
with assms(2,4,3) (*‹nat_term_comp (cmp::'a ⇒ 'a ⇒ order)› ‹fst (rep_nat_term v) = fst (rep_nat_term b)› ‹fst (rep_nat_term u) = fst (rep_nat_term a)›*) assms(5,6)[symmetric] (*‹snd (rep_nat_term (v::'a)) = snd (rep_nat_term (u::'a))› ‹snd (rep_nat_term b) = snd (rep_nat_term a)›*) have "cmp v u = Lt"
by (rule nat_term_compD4 (*‹⟦nat_term_comp (?cmp::?'a::nat_term ⇒ ?'a::nat_term ⇒ order); fst (rep_nat_term (?u::?'a::nat_term)) = fst (rep_nat_term (?a::?'a::nat_term)); fst (rep_nat_term (?v::?'a::nat_term)) = fst (rep_nat_term (?b::?'a::nat_term)); snd (rep_nat_term ?u) = snd (rep_nat_term ?v); snd (rep_nat_term ?a) = snd (rep_nat_term ?b); ?cmp ?a ?b = Lt⟧ ⟹ ?cmp ?u ?v = Lt›*))
hence "cmp u v = Gt"
by (simp only: cmp.Gt_lt_conv (*‹(cmp ?x ?y = Gt) = cmp.lt ?y ?x›*) cmp.Lt_lt_conv (*‹(cmp ?x ?y = Lt) = cmp.lt ?x ?y›*))
thus "?thesis"
(*goal: ‹cmp u v = cmp a b›*)
by (simp add: Gt (*‹cmp a b = Gt›*))
qed
qed
lemma nat_term_compD4'':
assumes "comparator cmp" and "nat_term_comp cmp" and "fst (rep_nat_term u) = fst (rep_nat_term a)"
and "fst (rep_nat_term v) = fst (rep_nat_term b)" and "snd (rep_nat_term u) ≤ snd (rep_nat_term v)"
and "snd (rep_nat_term a) = snd (rep_nat_term b)" and "cmp a b ≠ Gt"
shows "cmp u v ≠ Gt"
proof (cases "snd (rep_nat_term u) = snd (rep_nat_term v)")
(*goals:
1. ‹snd (rep_nat_term u) = snd (rep_nat_term v) ⟹ cmp u v ≠ Gt›
2. ‹snd (rep_nat_term u) ≠ snd (rep_nat_term v) ⟹ cmp u v ≠ Gt›*)
case True (*‹snd (rep_nat_term u) = snd (rep_nat_term v)›*)
with assms(1,2,3,4) (*‹comparator cmp› ‹nat_term_comp cmp› ‹fst (rep_nat_term u) = fst (rep_nat_term a)› ‹fst (rep_nat_term (v::'a)) = fst (rep_nat_term (b::'a))›*) have "cmp u v = cmp a b"
using assms(6) (*‹snd (rep_nat_term a) = snd (rep_nat_term b)›*) by (rule nat_term_compD4' (*‹⟦comparator ?cmp; nat_term_comp ?cmp; fst (rep_nat_term ?u) = fst (rep_nat_term ?a); fst (rep_nat_term ?v) = fst (rep_nat_term ?b); snd (rep_nat_term ?u) = snd (rep_nat_term ?v); snd (rep_nat_term ?a) = snd (rep_nat_term ?b)⟧ ⟹ ?cmp ?u ?v = ?cmp ?a ?b›*))
thus "?thesis"
(*goal: ‹(cmp::'a ⇒ 'a ⇒ order) (u::'a) (v::'a) ≠ Gt›*)
using assms(7) (*‹cmp a b ≠ Gt›*) by simp
next
(*goal: ‹snd (rep_nat_term u) ≠ snd (rep_nat_term v) ⟹ cmp u v ≠ Gt›*)
case False (*‹snd (rep_nat_term u) ≠ snd (rep_nat_term v)›*)
from assms(1) (*‹comparator cmp›*) interpret cmp: comparator cmp .
from refl (*‹?t = ?t›*) obtain w :: 'a where w: "rep_nat_term w = (fst (rep_nat_term u), snd (rep_nat_term v))"
(*goal: ‹(⋀w. rep_nat_term w = (fst (rep_nat_term u), snd (rep_nat_term v)) ⟹ thesis) ⟹ thesis›*)
by (rule full_componentE (*‹⟦snd (rep_nat_term ?x) = ?i; ⋀y. rep_nat_term y = (?t, ?i) ⟹ ?thesis⟧ ⟹ ?thesis›*))
have 1: "fst (rep_nat_term w) = fst (rep_nat_term a)" and 2: "snd (rep_nat_term w) = snd (rep_nat_term v)"
(*goals:
1. ‹fst (rep_nat_term w) = fst (rep_nat_term a)›
2. ‹snd (rep_nat_term w) = snd (rep_nat_term v)›
discuss goal 1*)
apply (simp add: w (*‹rep_nat_term (w::'a) = (fst (rep_nat_term (u::'a)), snd (rep_nat_term (v::'a)))›*) assms( (*‹fst (rep_nat_term (u::'a)) = fst (rep_nat_term (a::'a))›*) 3))
(*discuss goal 2*)
apply (simp add: w (*‹rep_nat_term w = (fst (rep_nat_term u), snd (rep_nat_term v))›*) assms( (*‹fst (rep_nat_term u) = fst (rep_nat_term a)›*) 3))
(*proven 2 subgoals*) .
from False (*‹snd (rep_nat_term u) ≠ snd (rep_nat_term v)›*) assms(5) (*‹snd (rep_nat_term u) ≤ snd (rep_nat_term v)›*) have "*": "snd (rep_nat_term u) < snd (rep_nat_term v)"
by simp
have "cmp u w = Lt"
apply (rule nat_term_compD2 (*‹⟦nat_term_comp (?cmp::?'a ⇒ ?'a ⇒ order); fst (rep_nat_term (?u::?'a)) = fst (rep_nat_term (?v::?'a)); snd (rep_nat_term ?u) < snd (rep_nat_term ?v)⟧ ⟹ ?cmp ?u ?v = Lt›*))
(*goals:
1. ‹nat_term_comp cmp›
2. ‹fst (rep_nat_term u) = fst (rep_nat_term w)›
3. ‹snd (rep_nat_term u) < snd (rep_nat_term w)›
discuss goal 1*)
apply (fact assms( (*‹nat_term_comp cmp›*) 2))
(*discuss goal 2*)
apply (simp add: * (*‹snd (rep_nat_term u) < snd (rep_nat_term v)›*) w (*‹rep_nat_term w = (fst (rep_nat_term u), snd (rep_nat_term v))›*))
(*discuss goal 3*)
apply (simp add: * (*‹snd (rep_nat_term u) < snd (rep_nat_term v)›*) w (*‹rep_nat_term w = (fst (rep_nat_term u), snd (rep_nat_term v))›*))
(*proven 3 subgoals*) .
moreover from assms(1,2) (*‹comparator cmp› ‹nat_term_comp cmp›*) "1" (*‹fst (rep_nat_term w) = fst (rep_nat_term a)›*) assms(4) (*‹fst (rep_nat_term v) = fst (rep_nat_term b)›*) "2" (*‹snd (rep_nat_term (w::'a::nat_term)) = snd (rep_nat_term (v::'a::nat_term))›*) assms(6) (*‹snd (rep_nat_term a) = snd (rep_nat_term b)›*) have "cmp w v = cmp a b"
by (rule nat_term_compD4' (*‹⟦comparator (?cmp::?'a ⇒ ?'a ⇒ order); nat_term_comp ?cmp; fst (rep_nat_term (?u::?'a)) = fst (rep_nat_term (?a::?'a)); fst (rep_nat_term (?v::?'a)) = fst (rep_nat_term (?b::?'a)); snd (rep_nat_term ?u) = snd (rep_nat_term ?v); snd (rep_nat_term ?a) = snd (rep_nat_term ?b)⟧ ⟹ ?cmp ?u ?v = ?cmp ?a ?b›*))
ultimately show "?thesis"
(*goal: ‹cmp u v ≠ Gt›*)
using assms(7) (*‹cmp a b ≠ Gt›*) by (metis cmp.nGt_le_conv (*‹(cmp ?x ?y ≠ Gt) = cmp.le ?x ?y›*) cmp.nLt_le_conv (*‹(cmp ?x ?y ≠ Lt) = cmp.le ?y ?x›*) cmp.comp_trans (*‹⟦cmp ?x ?y = Lt; cmp ?y ?z = Lt⟧ ⟹ cmp ?x ?z = Lt›*))
qed
lemma comparator_lex_comp_aux: "comparator (lex_comp_aux::'a::nat_term comparator)"
unfolding lex_comp_aux_def
(*goal: ‹comparator (λx y. case comp_of_ord lex_pp (fst (rep_nat_term x)) (fst (rep_nat_term y)) of Eq ⇒ comparator_of (snd (rep_nat_term x)) (snd (rep_nat_term y)) | Lt ⇒ Lt | Gt ⇒ Gt)›*)
proof (rule comparator_composition (*‹⟦comparator ?cmp; inj ?f⟧ ⟹ comparator (λx y. ?cmp (?f x) (?f y))›*))
(*goals:
1. ‹comparator (λa aa. case comp_of_ord lex_pp (fst a) (fst aa) of Eq ⇒ comparator_of (snd a) (snd aa) | Lt ⇒ Lt | Gt ⇒ Gt)›
2. ‹inj rep_nat_term›*)
from lex_pp_antisym (*‹⟦lex_pp (?s::(?'a, ?'b) pp) (?t::(?'a, ?'b) pp); lex_pp ?t ?s⟧ ⟹ ?s = ?t›*) have as: "antisymp lex_pp"
apply (rule antisympI (*‹(⋀x y. ⟦?R x y; ?R y x⟧ ⟹ x = y) ⟹ antisymp ?R›*))
(*goals:
1. ‹⋀x y. ⟦lex_pp x y; lex_pp y x⟧ ⟹ lex_pp x y›
2. ‹⋀x y. ⟦lex_pp x y; lex_pp y x⟧ ⟹ lex_pp y x›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
have "comparator (comp_of_ord (lex_pp::(nat, nat) pp ⇒ _))"
unfolding comp_of_ord_eq_comp_of_ords[OF as]
(*goal: ‹comparator (comp_of_ords lex_pp (strict lex_pp))›*)
apply (rule comp_of_ords (*‹class.linorder ?le ?lt ⟹ comparator (comp_of_ords ?le ?lt)›*))
(*goal: ‹comparator (comp_of_ords lex_pp (strict lex_pp))›*)
apply unfold_locales
(*goals:
1. ‹⋀x y. strict lex_pp x y = strict lex_pp x y›
2. ‹⋀x. lex_pp x x›
3. ‹⋀x y z. ⟦lex_pp x y; lex_pp y z⟧ ⟹ lex_pp x z›
4. ‹⋀x y. ⟦lex_pp x y; lex_pp y x⟧ ⟹ x = y›
5. ‹⋀x y. lex_pp x y ∨ lex_pp y x›
discuss goal 1*)
apply ((auto simp: lex_pp_refl (*‹lex_pp ?s ?s›*) intro: lex_pp_trans (*‹⟦lex_pp ?s ?t; lex_pp ?t ?u⟧ ⟹ lex_pp ?s ?u›*) lex_pp_lin' (*‹¬ lex_pp ?t ?s ⟹ lex_pp ?s ?t›*) elim!: lex_pp_antisym (*‹⟦lex_pp ?s ?t; lex_pp ?t ?s⟧ ⟹ ?s = ?t›*))[1])
(*discuss goal 2*)
apply ((auto simp: lex_pp_refl (*‹lex_pp (?s::(?'a, ?'b) pp) ?s›*) intro: lex_pp_trans (*‹⟦lex_pp (?s::(?'a, ?'b) pp) (?t::(?'a, ?'b) pp); lex_pp ?t (?u::(?'a, ?'b) pp)⟧ ⟹ lex_pp ?s ?u›*) lex_pp_lin' (*‹¬ lex_pp (?t::(?'a, ?'b) pp) (?s::(?'a, ?'b) pp) ⟹ lex_pp ?s ?t›*) elim!: lex_pp_antisym (*‹⟦lex_pp (?s::(?'a, ?'b) pp) (?t::(?'a, ?'b) pp); lex_pp ?t ?s⟧ ⟹ ?s = ?t›*))[1])
(*discuss goal 3*)
apply ((auto simp: lex_pp_refl (*‹lex_pp ?s ?s›*) intro: lex_pp_trans (*‹⟦lex_pp ?s ?t; lex_pp ?t ?u⟧ ⟹ lex_pp ?s ?u›*) lex_pp_lin' (*‹¬ lex_pp ?t ?s ⟹ lex_pp ?s ?t›*) elim!: lex_pp_antisym (*‹⟦lex_pp ?s ?t; lex_pp ?t ?s⟧ ⟹ ?s = ?t›*))[1])
(*discuss goal 4*)
apply ((auto simp: lex_pp_refl (*‹lex_pp ?s ?s›*) intro: lex_pp_trans (*‹⟦lex_pp ?s ?t; lex_pp ?t ?u⟧ ⟹ lex_pp ?s ?u›*) lex_pp_lin' (*‹¬ lex_pp ?t ?s ⟹ lex_pp ?s ?t›*) elim!: lex_pp_antisym (*‹⟦lex_pp ?s ?t; lex_pp ?t ?s⟧ ⟹ ?s = ?t›*))[1])
(*discuss goal 5*)
apply ((auto simp: lex_pp_refl (*‹lex_pp ?s ?s›*) intro: lex_pp_trans (*‹⟦lex_pp ?s ?t; lex_pp ?t ?u⟧ ⟹ lex_pp ?s ?u›*) lex_pp_lin' (*‹¬ lex_pp ?t ?s ⟹ lex_pp ?s ?t›*) elim!: lex_pp_antisym (*‹⟦lex_pp ?s ?t; lex_pp ?t ?s⟧ ⟹ ?s = ?t›*))[1])
(*proven 5 subgoals*) .
thus "comparator (λx y::((nat, nat) pp × nat). case comp_of_ord lex_pp (fst x) (fst y) of
Eq ⇒ comparator_of (snd x) (snd y) | val ⇒ val)"
using comparator_of (*‹comparator comparator_of›*) prod_eqI (*‹⟦fst ?p = fst ?q; snd ?p = snd ?q⟧ ⟹ ?p = ?q›*) apply (rule comparator_lexicographic (*‹⟦comparator ?c1.0; comparator ?c2.0; ⋀x y. ⟦?f x = ?f y; ?g x = ?g y⟧ ⟹ x = y⟧ ⟹ comparator (λx y. case ?c1.0 (?f x) (?f y) of Eq ⇒ ?c2.0 (?g x) (?g y) | Lt ⇒ Lt | Gt ⇒ Gt)›*))
(*goals:
1. ‹⋀x y. ⟦fst x = fst y; snd x = snd y⟧ ⟹ fst x = fst y›
2. ‹⋀x y. ⟦fst x = fst y; snd x = snd y⟧ ⟹ snd x = snd y›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
next
(*goal: ‹inj rep_nat_term›*)
from rep_nat_term_inj (*‹rep_nat_term ?x = rep_nat_term ?y ⟹ ?x = ?y›*) show "inj rep_nat_term"
by (rule injI (*‹(⋀x y. ?f x = ?f y ⟹ x = y) ⟹ inj ?f›*))
qed
lemma nat_term_comp_lex_comp_aux: "nat_term_comp (lex_comp_aux::'a::nat_term comparator)"
proof (-)
(*goal: ‹nat_term_comp lex_comp_aux›*)
from lex_pp_antisym (*‹⟦lex_pp ?s ?t; lex_pp ?t ?s⟧ ⟹ ?s = ?t›*) have as: "antisymp lex_pp"
apply (rule antisympI (*‹(⋀x y. ⟦?R x y; ?R y x⟧ ⟹ x = y) ⟹ antisymp ?R›*))
(*goals:
1. ‹⋀x y. ⟦lex_pp x y; lex_pp y x⟧ ⟹ lex_pp x y›
2. ‹⋀x y. ⟦lex_pp x y; lex_pp y x⟧ ⟹ lex_pp y x›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
interpret lex: comparator "comp_of_ord (lex_pp::(nat, nat) pp ⇒ _)"
unfolding comp_of_ord_eq_comp_of_ords[OF as]
(*goal: ‹comparator (comp_of_ords lex_pp (strict lex_pp))›*)
apply (rule comp_of_ords (*‹class.linorder (?le::?'a::type ⇒ ?'a::type ⇒ bool) (?lt::?'a::type ⇒ ?'a::type ⇒ bool) ⟹ comparator (comp_of_ords ?le ?lt)›*))
(*goal: ‹comparator (comp_of_ords lex_pp (strict lex_pp))›*)
apply unfold_locales
(*goals:
1. ‹⋀x y. strict lex_pp x y = strict lex_pp x y›
2. ‹⋀x. lex_pp x x›
3. ‹⋀x y z. ⟦lex_pp x y; lex_pp y z⟧ ⟹ lex_pp x z›
4. ‹⋀x y. ⟦lex_pp x y; lex_pp y x⟧ ⟹ x = y›
5. ‹⋀x y. lex_pp x y ∨ lex_pp y x›
discuss goal 1*)
apply ((auto simp: lex_pp_refl (*‹lex_pp ?s ?s›*) intro: lex_pp_trans (*‹⟦lex_pp ?s ?t; lex_pp ?t ?u⟧ ⟹ lex_pp ?s ?u›*) lex_pp_lin' (*‹¬ lex_pp ?t ?s ⟹ lex_pp ?s ?t›*) elim!: lex_pp_antisym (*‹⟦lex_pp ?s ?t; lex_pp ?t ?s⟧ ⟹ ?s = ?t›*))[1])
(*discuss goal 2*)
apply ((auto simp: lex_pp_refl (*‹lex_pp ?s ?s›*) intro: lex_pp_trans (*‹⟦lex_pp ?s ?t; lex_pp ?t ?u⟧ ⟹ lex_pp ?s ?u›*) lex_pp_lin' (*‹¬ lex_pp ?t ?s ⟹ lex_pp ?s ?t›*) elim!: lex_pp_antisym (*‹⟦lex_pp ?s ?t; lex_pp ?t ?s⟧ ⟹ ?s = ?t›*))[1])
(*discuss goal 3*)
apply ((auto simp: lex_pp_refl (*‹lex_pp ?s ?s›*) intro: lex_pp_trans (*‹⟦lex_pp ?s ?t; lex_pp ?t ?u⟧ ⟹ lex_pp ?s ?u›*) lex_pp_lin' (*‹¬ lex_pp ?t ?s ⟹ lex_pp ?s ?t›*) elim!: lex_pp_antisym (*‹⟦lex_pp ?s ?t; lex_pp ?t ?s⟧ ⟹ ?s = ?t›*))[1])
(*discuss goal 4*)
apply ((auto simp: lex_pp_refl (*‹lex_pp (?s::(?'a, ?'b) pp) ?s›*) intro: lex_pp_trans (*‹⟦lex_pp (?s::(?'a, ?'b) pp) (?t::(?'a, ?'b) pp); lex_pp ?t (?u::(?'a, ?'b) pp)⟧ ⟹ lex_pp ?s ?u›*) lex_pp_lin' (*‹¬ lex_pp (?t::(?'a, ?'b) pp) (?s::(?'a, ?'b) pp) ⟹ lex_pp ?s ?t›*) elim!: lex_pp_antisym (*‹⟦lex_pp (?s::(?'a, ?'b) pp) (?t::(?'a, ?'b) pp); lex_pp ?t ?s⟧ ⟹ ?s = ?t›*))[1])
(*discuss goal 5*)
apply ((auto simp: lex_pp_refl (*‹lex_pp ?s ?s›*) intro: lex_pp_trans (*‹⟦lex_pp ?s ?t; lex_pp ?t ?u⟧ ⟹ lex_pp ?s ?u›*) lex_pp_lin' (*‹¬ lex_pp ?t ?s ⟹ lex_pp ?s ?t›*) elim!: lex_pp_antisym (*‹⟦lex_pp ?s ?t; lex_pp ?t ?s⟧ ⟹ ?s = ?t›*))[1])
(*proven 5 subgoals*) .
show "?thesis"
(*goal: ‹nat_term_comp lex_comp_aux›*)
proof (rule nat_term_compI (*‹⟦⋀u v. ⟦snd (rep_nat_term u) = snd (rep_nat_term v); fst (rep_nat_term u) = 0⟧ ⟹ ?cmp u v ≠ Gt; ⋀u v. ⟦fst (rep_nat_term u) = fst (rep_nat_term v); snd (rep_nat_term u) < snd (rep_nat_term v)⟧ ⟹ ?cmp u v = Lt; ⋀t u v. ?cmp u v = Lt ⟹ ?cmp (splus t u) (splus t v) = Lt; ⋀u v a b. ⟦fst (rep_nat_term u) = fst (rep_nat_term a); fst (rep_nat_term v) = fst (rep_nat_term b); snd (rep_nat_term u) = snd (rep_nat_term v); snd (rep_nat_term a) = snd (rep_nat_term b); ?cmp a b = Lt⟧ ⟹ ?cmp u v = Lt⟧ ⟹ nat_term_comp ?cmp›*))
(*goals:
1. ‹⋀u v. ⟦snd (rep_nat_term u) = snd (rep_nat_term v); fst (rep_nat_term u) = 0⟧ ⟹ lex_comp_aux u v ≠ Gt›
2. ‹⋀u v. ⟦fst (rep_nat_term u) = fst (rep_nat_term v); snd (rep_nat_term u) < snd (rep_nat_term v)⟧ ⟹ lex_comp_aux u v = Lt›
3. ‹⋀t u v. lex_comp_aux u v = Lt ⟹ lex_comp_aux (splus t u) (splus t v) = Lt›
4. ‹⋀u v a b. ⟦fst (rep_nat_term u) = fst (rep_nat_term a); fst (rep_nat_term v) = fst (rep_nat_term b); snd (rep_nat_term u) = snd (rep_nat_term v); snd (rep_nat_term a) = snd (rep_nat_term b); lex_comp_aux a b = Lt⟧ ⟹ lex_comp_aux u v = Lt›*)
fix u :: 'a and v :: 'a
assume 1: "snd (rep_nat_term u) = snd (rep_nat_term v)" and 2: "fst (rep_nat_term u) = 0" (*‹snd (rep_nat_term (u::'a)) = snd (rep_nat_term (v::'a))› ‹fst (rep_nat_term (u::'a)) = (0::(nat, nat) pp)›*)
show "lex_comp_aux u v ≠ Gt"
apply (simp add: lex_comp_aux_def (*‹lex_comp_aux = (λx y. case comp_of_ord lex_pp (fst (rep_nat_term x)) (fst (rep_nat_term y)) of Eq ⇒ comparator_of (snd (rep_nat_term x)) (snd (rep_nat_term y)) | Lt ⇒ Lt | Gt ⇒ Gt)›*) 1 (*‹snd (rep_nat_term u) = snd (rep_nat_term v)›*) 2 (*‹fst (rep_nat_term u) = 0›*) split: order.split (*‹?P (case ?order of Eq ⇒ ?f1.0 | Lt ⇒ ?f2.0 | Gt ⇒ ?f3.0) = ((?order = Eq ⟶ ?P ?f1.0) ∧ (?order = Lt ⟶ ?P ?f2.0) ∧ (?order = Gt ⟶ ?P ?f3.0))›*))
(*goal: ‹lex_comp_aux u v ≠ Gt›*)
by (simp add: comp_of_ord_def (*‹comp_of_ord ?le ?x ?y = (if ?le ?x ?y then if ?x = ?y then Eq else Lt else Gt)›*) lex_pp_zero_min (*‹lex_pp 0 ?s›*))
next
(*goals:
1. ‹⋀u v. ⟦fst (rep_nat_term u) = fst (rep_nat_term v); snd (rep_nat_term u) < snd (rep_nat_term v)⟧ ⟹ lex_comp_aux u v = Lt›
2. ‹⋀t u v. lex_comp_aux u v = Lt ⟹ lex_comp_aux (splus t u) (splus t v) = Lt›
3. ‹⋀u v a b. ⟦fst (rep_nat_term u) = fst (rep_nat_term a); fst (rep_nat_term v) = fst (rep_nat_term b); snd (rep_nat_term u) = snd (rep_nat_term v); snd (rep_nat_term a) = snd (rep_nat_term b); lex_comp_aux a b = Lt⟧ ⟹ lex_comp_aux u v = Lt›*)
fix u :: 'a and v :: 'a
assume 1: "fst (rep_nat_term u) = fst (rep_nat_term v)" and 2: "snd (rep_nat_term u) < snd (rep_nat_term v)" (*‹fst (rep_nat_term (u::'a)) = fst (rep_nat_term (v::'a))› ‹snd (rep_nat_term (u::'a)) < snd (rep_nat_term (v::'a))›*)
show "lex_comp_aux u v = Lt"
apply (simp add: lex_comp_aux_def (*‹lex_comp_aux = (λ(x::?'a) y::?'a. case comp_of_ord lex_pp (fst (rep_nat_term x)) (fst (rep_nat_term y)) of Eq ⇒ comparator_of (snd (rep_nat_term x)) (snd (rep_nat_term y)) | Lt ⇒ Lt | Gt ⇒ Gt)›*) 1 (*‹fst (rep_nat_term (u::'a)) = fst (rep_nat_term (v::'a))›*) split: order.split (*‹(?P::?'a ⇒ bool) (case ?order::order of Eq ⇒ ?f1.0::?'a | Lt ⇒ ?f2.0::?'a | Gt ⇒ ?f3.0::?'a) = ((?order = Eq ⟶ ?P ?f1.0) ∧ (?order = Lt ⟶ ?P ?f2.0) ∧ (?order = Gt ⟶ ?P ?f3.0))›*))
(*goal: ‹lex_comp_aux (u::'a) (v::'a) = Lt›*)
by (simp add: comparator_of_def (*‹comparator_of ?x ?y = (if ?x < ?y then Lt else if ?x = ?y then Eq else Gt)›*) 2 (*‹snd (rep_nat_term u) < snd (rep_nat_term v)›*))
next
(*goals:
1. ‹⋀t u v. lex_comp_aux u v = Lt ⟹ lex_comp_aux (splus t u) (splus t v) = Lt›
2. ‹⋀u v a b. ⟦fst (rep_nat_term u) = fst (rep_nat_term a); fst (rep_nat_term v) = fst (rep_nat_term b); snd (rep_nat_term u) = snd (rep_nat_term v); snd (rep_nat_term a) = snd (rep_nat_term b); lex_comp_aux a b = Lt⟧ ⟹ lex_comp_aux u v = Lt›*)
fix t :: 'a and u :: 'a and v :: 'a
show "lex_comp_aux u v = Lt ⟹ lex_comp_aux (splus t u) (splus t v) = Lt"
by (auto simp: lex_comp_aux_def (*‹lex_comp_aux = (λx y. case comp_of_ord lex_pp (fst (rep_nat_term x)) (fst (rep_nat_term y)) of Eq ⇒ comparator_of (snd (rep_nat_term x)) (snd (rep_nat_term y)) | Lt ⇒ Lt | Gt ⇒ Gt)›*) splus_term (*‹rep_nat_term (splus ?x ?y) = pprod.splus (fst (rep_nat_term ?x)) (rep_nat_term ?y)›*) pprod.splus_def (*‹pprod.splus ?t ?v = (?t + pprod.pp_of_term ?v, pprod.component_of_term ?v)›*) comp_of_ord_def (*‹comp_of_ord ?le ?x ?y = (if ?le ?x ?y then if ?x = ?y then Eq else Lt else Gt)›*) lex_pp_refl (*‹lex_pp ?s ?s›*) split: order.splits (*‹?P (case ?order of Eq ⇒ ?f1.0 | Lt ⇒ ?f2.0 | Gt ⇒ ?f3.0) = ((?order = Eq ⟶ ?P ?f1.0) ∧ (?order = Lt ⟶ ?P ?f2.0) ∧ (?order = Gt ⟶ ?P ?f3.0))› ‹?P (case ?order of Eq ⇒ ?f1.0 | Lt ⇒ ?f2.0 | Gt ⇒ ?f3.0) = (¬ (?order = Eq ∧ ¬ ?P ?f1.0 ∨ ?order = Lt ∧ ¬ ?P ?f2.0 ∨ ?order = Gt ∧ ¬ ?P ?f3.0))›*) if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: lex_pp_plus_monotone' (*‹lex_pp ?s ?t ⟹ lex_pp (?u + ?s) (?u + ?t)›*))
next
(*goal: ‹⋀u v a b. ⟦fst (rep_nat_term u) = fst (rep_nat_term a); fst (rep_nat_term v) = fst (rep_nat_term b); snd (rep_nat_term u) = snd (rep_nat_term v); snd (rep_nat_term a) = snd (rep_nat_term b); lex_comp_aux a b = Lt⟧ ⟹ lex_comp_aux u v = Lt›*)
fix u :: 'a and v :: 'a and a :: 'a and b :: 'a
assume "fst (rep_nat_term u) = fst (rep_nat_term a)" and "fst (rep_nat_term v) = fst (rep_nat_term b)" and "snd (rep_nat_term a) = snd (rep_nat_term b)" and "lex_comp_aux a b = Lt" (*‹fst (rep_nat_term (u::'a)) = fst (rep_nat_term (a::'a))› ‹fst (rep_nat_term (v::'a)) = fst (rep_nat_term (b::'a))› ‹snd (rep_nat_term (a::'a)) = snd (rep_nat_term (b::'a))› ‹lex_comp_aux (a::'a) (b::'a) = Lt›*)
thus "lex_comp_aux u v = Lt"
by (simp add: lex_comp_aux_def (*‹lex_comp_aux = (λx y. case comp_of_ord lex_pp (fst (rep_nat_term x)) (fst (rep_nat_term y)) of Eq ⇒ comparator_of (snd (rep_nat_term x)) (snd (rep_nat_term y)) | Lt ⇒ Lt | Gt ⇒ Gt)›*) split: order.splits (*‹?P (case ?order of Eq ⇒ ?f1.0 | Lt ⇒ ?f2.0 | Gt ⇒ ?f3.0) = ((?order = Eq ⟶ ?P ?f1.0) ∧ (?order = Lt ⟶ ?P ?f2.0) ∧ (?order = Gt ⟶ ?P ?f3.0))› ‹?P (case ?order of Eq ⇒ ?f1.0 | Lt ⇒ ?f2.0 | Gt ⇒ ?f3.0) = (¬ (?order = Eq ∧ ¬ ?P ?f1.0 ∨ ?order = Lt ∧ ¬ ?P ?f2.0 ∨ ?order = Gt ∧ ¬ ?P ?f3.0))›*))
qed
qed
typedef (overloaded) 'a nat_term_order =
"{cmp::'a::nat_term comparator. comparator cmp ∧ nat_term_comp cmp}"
morphisms nat_term_compare Abs_nat_term_order
proof (rule, simp)
from comparator_lex_comp_aux nat_term_comp_lex_comp_aux
show "comparator lex_comp_aux ∧ nat_term_comp lex_comp_aux" ..
qed
lemma nat_term_compare_Abs_nat_term_order_id:
assumes "comparator cmp" and "nat_term_comp cmp"
shows "nat_term_compare (Abs_nat_term_order cmp) = cmp"
apply (rule Abs_nat_term_order_inverse (*‹?y ∈ {cmp. comparator cmp ∧ nat_term_comp cmp} ⟹ nat_term_compare (Abs_nat_term_order ?y) = ?y›*))
(*goal: ‹nat_term_compare (Abs_nat_term_order cmp) = cmp›*)
by (simp add: assms (*‹comparator (cmp::'a ⇒ 'a ⇒ order)› ‹nat_term_comp (cmp::'a ⇒ 'a ⇒ order)›*))
instantiation nat_term_order :: (type) equal
begin
definition equal_nat_term_order :: "'a nat_term_order ⇒ 'a nat_term_order ⇒ bool" where "equal_nat_term_order = (=)"
instance by (standard, simp add: equal_nat_term_order_def)
end
definition nat_term_compare_inv :: "'a nat_term_order ⇒ 'a::nat_term comparator"
where "nat_term_compare_inv to = (λx y. nat_term_compare to y x)"
definition key_order_of_nat_term_order :: "'a nat_term_order ⇒ 'a::nat_term key_order"
where key_order_of_nat_term_order_def [code del]:
"key_order_of_nat_term_order to = Abs_key_order (nat_term_compare to)"
definition key_order_of_nat_term_order_inv :: "'a nat_term_order ⇒ 'a::nat_term key_order"
where key_order_of_nat_term_order_inv_def [code del]:
"key_order_of_nat_term_order_inv to = Abs_key_order (nat_term_compare_inv to)"
definition le_of_nat_term_order :: "'a nat_term_order ⇒ 'a ⇒ 'a::nat_term ⇒ bool"
where "le_of_nat_term_order to = le_of_key_order (key_order_of_nat_term_order to)"
definition lt_of_nat_term_order :: "'a nat_term_order ⇒ 'a ⇒ 'a::nat_term ⇒ bool"
where "lt_of_nat_term_order to = lt_of_key_order (key_order_of_nat_term_order to)"
definition nat_term_order_of_le :: "'a::{linorder,nat_term} nat_term_order"
where "nat_term_order_of_le = Abs_nat_term_order (comparator_of)"
lemma comparator_nat_term_compare: "comparator (nat_term_compare to)"
using nat_term_compare (*‹nat_term_compare ?x ∈ {cmp. comparator cmp ∧ nat_term_comp cmp}›*) by blast
lemma nat_term_comp_nat_term_compare: "nat_term_comp (nat_term_compare to)"
using nat_term_compare (*‹nat_term_compare (?x::?'a nat_term_order) ∈ {cmp::?'a ⇒ ?'a ⇒ order. comparator cmp ∧ nat_term_comp cmp}›*) by blast
lemma nat_term_compare_splus: "nat_term_compare to (splus t u) (splus t v) = nat_term_compare to u v"
sorry
lemma nat_term_compare_conv: "nat_term_compare to = key_compare (key_order_of_nat_term_order to)"
unfolding key_order_of_nat_term_order_def
(*goal: ‹nat_term_compare (to::'a nat_term_order) = key_compare (Abs_key_order (nat_term_compare to))›*)
apply (rule sym (*‹(?s::?'a) = (?t::?'a) ⟹ ?t = ?s›*))
(*goal: ‹nat_term_compare to = key_compare (Abs_key_order (nat_term_compare to))›*)
apply (rule Abs_key_order_inverse (*‹?y ∈ {compare. comparator compare} ⟹ key_compare (Abs_key_order ?y) = ?y›*))
(*goal: ‹key_compare (Abs_key_order (nat_term_compare (to::'a::nat_term nat_term_order))) = nat_term_compare to›*)
by (simp add: comparator_nat_term_compare (*‹comparator (nat_term_compare ?to)›*))
lemma comparator_nat_term_compare_inv: "comparator (nat_term_compare_inv to)"
unfolding nat_term_compare_inv_def
(*goal: ‹comparator (λx y. nat_term_compare to y x)›*)
using comparator_nat_term_compare (*‹comparator (nat_term_compare ?to)›*) by (rule comparator_converse (*‹comparator ?cmp ⟹ comparator (λx y. ?cmp y x)›*))
lemma nat_term_compare_inv_conv: "nat_term_compare_inv to = key_compare (key_order_of_nat_term_order_inv to)"
unfolding key_order_of_nat_term_order_inv_def
(*goal: ‹nat_term_compare_inv (to::'a nat_term_order) = key_compare (Abs_key_order (nat_term_compare_inv to))›*)
apply (rule sym (*‹?s = ?t ⟹ ?t = ?s›*))
(*goal: ‹nat_term_compare_inv to = key_compare (Abs_key_order (nat_term_compare_inv to))›*)
apply (rule Abs_key_order_inverse (*‹?y ∈ {compare. comparator compare} ⟹ key_compare (Abs_key_order ?y) = ?y›*))
(*goal: ‹key_compare (Abs_key_order (nat_term_compare_inv to)) = nat_term_compare_inv to›*)
by (simp add: comparator_nat_term_compare_inv (*‹comparator (nat_term_compare_inv ?to)›*))
lemma nat_term_compare_inv_alt [code_unfold]: "nat_term_compare_inv to x y = nat_term_compare to y x"
by (simp only: nat_term_compare_inv_def (*‹nat_term_compare_inv ?to = (λx y. nat_term_compare ?to y x)›*))
lemma le_of_nat_term_order [code]: "le_of_nat_term_order to x y = (nat_term_compare to x y ≠ Gt)"
by (simp add: le_of_key_order_alt (*‹le_of_key_order ?ko ?x ?y = (key_compare ?ko ?x ?y ≠ Gt)›*) le_of_nat_term_order_def (*‹le_of_nat_term_order ?to = le_of_key_order (key_order_of_nat_term_order ?to)›*) nat_term_compare_conv (*‹nat_term_compare ?to = key_compare (key_order_of_nat_term_order ?to)›*))
lemma lt_of_nat_term_order [code]: "lt_of_nat_term_order to x y = (nat_term_compare to x y = Lt)"
by (simp add: lt_of_key_order_alt (*‹lt_of_key_order ?ko ?x ?y = (key_compare ?ko ?x ?y = Lt)›*) lt_of_nat_term_order_def (*‹lt_of_nat_term_order ?to = lt_of_key_order (key_order_of_nat_term_order ?to)›*) nat_term_compare_conv (*‹nat_term_compare ?to = key_compare (key_order_of_nat_term_order ?to)›*))
lemma le_of_nat_term_order_alt:
"le_of_nat_term_order to = (λu v. ko.le (key_order_of_nat_term_order_inv to) v u)"
apply (intro ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*))
(*goal: ‹le_of_nat_term_order to = (λu v. ko.le (key_order_of_nat_term_order_inv to) v u)›*)
by (simp add: le_of_comp_def (*‹le_of_comp (?acomp::?'a::type ⇒ ?'a::type ⇒ order) (?x::?'a::type) (?y::?'a::type) = (case ?acomp ?x ?y of Gt ⇒ False | _ ⇒ True)›*) nat_term_compare_inv_conv[symmetric] (*‹key_compare (key_order_of_nat_term_order_inv (?to::?'a::nat_term nat_term_order)) = nat_term_compare_inv ?to›*) le_of_nat_term_order_def (*‹le_of_nat_term_order (?to::?'a::nat_term nat_term_order) = le_of_key_order (key_order_of_nat_term_order ?to)›*) le_of_key_order_def (*‹le_of_key_order ≡ map_fun key_compare id le_of_comp›*) nat_term_compare_conv[symmetric] (*‹key_compare (key_order_of_nat_term_order (?to::?'a::nat_term nat_term_order)) = nat_term_compare ?to›*) nat_term_compare_inv_alt (*‹nat_term_compare_inv (?to::?'a::nat_term nat_term_order) (?x::?'a::nat_term) (?y::?'a::nat_term) = nat_term_compare ?to ?y ?x›*))
lemma lt_of_nat_term_order_alt:
"lt_of_nat_term_order to = (λu v. ko.lt (key_order_of_nat_term_order_inv to) v u)"
apply (intro ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*))
(*goal: ‹lt_of_nat_term_order to = (λu v. ko.lt (key_order_of_nat_term_order_inv to) v u)›*)
by (simp add: lt_of_comp_def (*‹lt_of_comp ?acomp ?x ?y = (case ?acomp ?x ?y of Lt ⇒ True | _ ⇒ False)›*) nat_term_compare_inv_conv[symmetric] (*‹key_compare (key_order_of_nat_term_order_inv ?to) = nat_term_compare_inv ?to›*) lt_of_nat_term_order_def (*‹lt_of_nat_term_order ?to = lt_of_key_order (key_order_of_nat_term_order ?to)›*) lt_of_key_order_def (*‹lt_of_key_order ≡ map_fun key_compare id lt_of_comp›*) nat_term_compare_conv[symmetric] (*‹key_compare (key_order_of_nat_term_order ?to) = nat_term_compare ?to›*) nat_term_compare_inv_alt (*‹nat_term_compare_inv ?to ?x ?y = nat_term_compare ?to ?y ?x›*))
lemma linorder_le_of_nat_term_order: "class.linorder (le_of_nat_term_order to) (lt_of_nat_term_order to)"
unfolding le_of_nat_term_order_alt lt_of_nat_term_order_alt
(*goal: ‹class.linorder (λ(u::'a) v::'a. ko.le (key_order_of_nat_term_order_inv (to::'a nat_term_order)) v u) (λ(u::'a) v::'a. ko.lt (key_order_of_nat_term_order_inv to) v u)›*)
using ko.linorder (*‹class.linorder (ko.le ?ko) (ko.lt ?ko)›*) by (rule linorder.dual_linorder (*‹class.linorder ?less_eq ?less ⟹ class.linorder (λx y. ?less_eq y x) (λx y. ?less y x)›*))
lemma le_of_nat_term_order_zero_min: "le_of_nat_term_order to 0 (t::'a::nat_pp_term)"
unfolding le_of_nat_term_order
(*goal: ‹nat_term_compare to 0 t ≠ Gt›*)
apply (rule nat_term_compD1' (*‹⟦comparator ?cmp; nat_term_comp ?cmp; snd (rep_nat_term ?u) ≤ snd (rep_nat_term ?v); fst (rep_nat_term ?u) = 0⟧ ⟹ ?cmp ?u ?v ≠ Gt›*))
(*goals:
1. ‹comparator (nat_term_compare (to::'a nat_term_order))›
2. ‹nat_term_comp (nat_term_compare (to::'a nat_term_order))›
3. ‹snd (rep_nat_term (0::'a)) ≤ snd (rep_nat_term (t::'a))›
4. ‹fst (rep_nat_term (0::'a)) = (0::(nat, nat) pp)›
discuss goal 1*)
apply (fact comparator_nat_term_compare (*‹comparator (nat_term_compare ?to)›*))
(*discuss goal 2*)
apply (fact nat_term_comp_nat_term_compare (*‹nat_term_comp (nat_term_compare ?to)›*))
(*discuss goal 3*)
apply (simp add: rep_nat_term_zero (*‹rep_nat_term (0::?'a) = (0::(nat, nat) pp, 0::nat)›*))
(*discuss goal 4*)
apply (simp add: rep_nat_term_zero (*‹rep_nat_term (0::?'a) = (0::(nat, nat) pp, 0::nat)›*))
(*proven 4 subgoals*) .
lemma le_of_nat_term_order_plus_monotone:
assumes "le_of_nat_term_order to s (t::'a::nat_pp_term)"
shows "le_of_nat_term_order to (u + s) (u + t)"
sorry
global_interpretation ko_ntm: comparator "nat_term_compare_inv ko"
defines lookup_pair_ko_ntm = ko_ntm.lookup_pair
and update_by_pair_ko_ntm = ko_ntm.update_by_pair
and update_by_fun_pair_ko_ntm = ko_ntm.update_by_fun_pair
and update_by_fun_gr_pair_ko_ntm = ko_ntm.update_by_fun_gr_pair
and map2_val_pair_ko_ntm = ko_ntm.map2_val_pair
and lex_ord_pair_ko_ntm = ko_ntm.lex_ord_pair
and prod_ord_pair_ko_ntm = ko_ntm.prod_ord_pair
and sort_oalist_ko_ntm' = ko_ntm.sort_oalist
by (fact comparator_nat_term_compare_inv (*‹comparator (nat_term_compare_inv ?to)›*))
lemma ko_ntm_le: "ko_ntm.le to = (λx y. le_of_nat_term_order to y x)"
apply (intro ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*))
(*goal: ‹ko_ntm.le (to::'a nat_term_order) = (λ(x::'a) y::'a. le_of_nat_term_order to y x)›*)
by (simp add: le_of_comp_def (*‹le_of_comp ?acomp ?x ?y = (case ?acomp ?x ?y of Gt ⇒ False | _ ⇒ True)›*) le_of_nat_term_order (*‹le_of_nat_term_order ?to ?x ?y = (nat_term_compare ?to ?x ?y ≠ Gt)›*) nat_term_compare_inv_def (*‹nat_term_compare_inv ?to = (λx y. nat_term_compare ?to y x)›*) split: order.split (*‹?P (case ?order of Eq ⇒ ?f1.0 | Lt ⇒ ?f2.0 | Gt ⇒ ?f3.0) = ((?order = Eq ⟶ ?P ?f1.0) ∧ (?order = Lt ⟶ ?P ?f2.0) ∧ (?order = Gt ⟶ ?P ?f3.0))›*))
global_interpretation ko_ntm: oalist_raw key_order_of_nat_term_order_inv
rewrites "comparator.lookup_pair (key_compare (key_order_of_nat_term_order_inv ko)) = lookup_pair_ko_ntm ko"
and "comparator.update_by_pair (key_compare (key_order_of_nat_term_order_inv ko)) = update_by_pair_ko_ntm ko"
and "comparator.update_by_fun_pair (key_compare (key_order_of_nat_term_order_inv ko)) = update_by_fun_pair_ko_ntm ko"
and "comparator.update_by_fun_gr_pair (key_compare (key_order_of_nat_term_order_inv ko)) = update_by_fun_gr_pair_ko_ntm ko"
and "comparator.map2_val_pair (key_compare (key_order_of_nat_term_order_inv ko)) = map2_val_pair_ko_ntm ko"
and "comparator.lex_ord_pair (key_compare (key_order_of_nat_term_order_inv ko)) = lex_ord_pair_ko_ntm ko"
and "comparator.prod_ord_pair (key_compare (key_order_of_nat_term_order_inv ko)) = prod_ord_pair_ko_ntm ko"
and "comparator.sort_oalist (key_compare (key_order_of_nat_term_order_inv ko)) = sort_oalist_ko_ntm' ko"
defines sort_oalist_aux_ko_ntm = ko_ntm.sort_oalist_aux
and lookup_ko_ntm = ko_ntm.lookup_raw
and sorted_domain_ko_ntm = ko_ntm.sorted_domain_raw
and tl_ko_ntm = ko_ntm.tl_raw
and min_key_val_ko_ntm = ko_ntm.min_key_val_raw
and update_by_ko_ntm = ko_ntm.update_by_raw
and update_by_fun_ko_ntm = ko_ntm.update_by_fun_raw
and update_by_fun_gr_ko_ntm = ko_ntm.update_by_fun_gr_raw
and map2_val_ko_ntm = ko_ntm.map2_val_raw
and lex_ord_ko_ntm = ko_ntm.lex_ord_raw
and prod_ord_ko_ntm = ko_ntm.prod_ord_raw
and oalist_eq_ko_ntm = ko_ntm.oalist_eq_raw
and sort_oalist_ko_ntm = ko_ntm.sort_oalist_raw
subgoal for
by (simp only: lookup_pair_ko_ntm_def (*‹lookup_pair_ko_ntm ?ko ≡ comparator.lookup_pair (nat_term_compare_inv ?ko)›*) nat_term_compare_inv_conv (*‹nat_term_compare_inv ?to = key_compare (key_order_of_nat_term_order_inv ?to)›*))
subgoal for
by (simp only: update_by_pair_ko_ntm_def (*‹update_by_pair_ko_ntm ?ko ≡ comparator.update_by_pair (nat_term_compare_inv ?ko)›*) nat_term_compare_inv_conv (*‹nat_term_compare_inv ?to = key_compare (key_order_of_nat_term_order_inv ?to)›*))
subgoal for
by (simp only: update_by_fun_pair_ko_ntm_def (*‹update_by_fun_pair_ko_ntm (?ko::?'a nat_term_order) ≡ comparator.update_by_fun_pair (nat_term_compare_inv ?ko)›*) nat_term_compare_inv_conv (*‹nat_term_compare_inv (?to::?'a nat_term_order) = key_compare (key_order_of_nat_term_order_inv ?to)›*))
subgoal for
by (simp only: update_by_fun_gr_pair_ko_ntm_def (*‹update_by_fun_gr_pair_ko_ntm ?ko ≡ comparator.update_by_fun_gr_pair (nat_term_compare_inv ?ko)›*) nat_term_compare_inv_conv (*‹nat_term_compare_inv ?to = key_compare (key_order_of_nat_term_order_inv ?to)›*))
subgoal for
by (simp only: map2_val_pair_ko_ntm_def (*‹map2_val_pair_ko_ntm ?ko ≡ comparator.map2_val_pair (nat_term_compare_inv ?ko)›*) nat_term_compare_inv_conv (*‹nat_term_compare_inv ?to = key_compare (key_order_of_nat_term_order_inv ?to)›*))
subgoal for
by (simp only: lex_ord_pair_ko_ntm_def (*‹lex_ord_pair_ko_ntm ?ko ≡ comparator.lex_ord_pair (nat_term_compare_inv ?ko)›*) nat_term_compare_inv_conv (*‹nat_term_compare_inv ?to = key_compare (key_order_of_nat_term_order_inv ?to)›*))
subgoal for
by (simp only: prod_ord_pair_ko_ntm_def (*‹prod_ord_pair_ko_ntm ?ko ≡ comparator.prod_ord_pair (nat_term_compare_inv ?ko)›*) nat_term_compare_inv_conv (*‹nat_term_compare_inv ?to = key_compare (key_order_of_nat_term_order_inv ?to)›*))
subgoal for
by (simp only: sort_oalist_ko_ntm'_def (*‹sort_oalist_ko_ntm' ?ko ≡ comparator.sort_oalist (nat_term_compare_inv ?ko)›*) nat_term_compare_inv_conv (*‹nat_term_compare_inv ?to = key_compare (key_order_of_nat_term_order_inv ?to)›*)) .
lemma compute_min_key_val_ko_ntm [code]:
"min_key_val_ko_ntm ko (xs, ox) =
(if ko = ox then hd else min_list_param (λx y. (le_of_nat_term_order ko) (fst y) (fst x))) xs"
sorry
typedef (overloaded) ('a, 'b) oalist_ntm =
"{xs::('a, 'b::zero, 'a::nat_term nat_term_order) oalist_raw. ko_ntm.oalist_inv xs}"
morphisms list_of_oalist_ntm Abs_oalist_ntm
by (auto simp: ko_ntm.oalist_inv_def intro: ko.oalist_inv_raw_Nil)
lemma oalist_ntm_eq_iff: "xs = ys ⟷ list_of_oalist_ntm xs = list_of_oalist_ntm ys"
by (simp add: list_of_oalist_ntm_inject (*‹(list_of_oalist_ntm ?x = list_of_oalist_ntm ?y) = (?x = ?y)›*))
lemma oalist_ntm_eqI: "list_of_oalist_ntm xs = list_of_oalist_ntm ys ⟹ xs = ys"
by (simp add: oalist_ntm_eq_iff (*‹(?xs = ?ys) = (list_of_oalist_ntm ?xs = list_of_oalist_ntm ?ys)›*))
text ‹Formal, totalized constructor for @{typ "('a, 'b) oalist_ntm"}:›
definition OAlist_ntm :: "('a × 'b) list × 'a nat_term_order ⇒ ('a::nat_term, 'b::zero) oalist_ntm"
where "OAlist_ntm xs = Abs_oalist_ntm (sort_oalist_ko_ntm xs)"
definition "oalist_of_list_ntm = OAlist_ntm"
lemma oalist_inv_list_of_oalist_ntm: "ko_ntm.oalist_inv (list_of_oalist_ntm xs)"
using list_of_oalist_ntm[of xs] (*‹list_of_oalist_ntm xs ∈ Collect ko_ntm.oalist_inv›*) by simp
lemma list_of_oalist_OAlist_ntm: "list_of_oalist_ntm (OAlist_ntm xs) = sort_oalist_ko_ntm xs"
proof (-)
(*goal: ‹list_of_oalist_ntm (OAlist_ntm xs) = sort_oalist_ko_ntm xs›*)
obtain xs' and ox where xs: "xs = (xs', ox)"
(*goal: ‹(⋀(xs'::('a × 'b) list) ox::'a nat_term_order. (xs::('a × 'b) list × 'a nat_term_order) = (xs', ox) ⟹ thesis::bool) ⟹ thesis›*)
by fastforce
have "ko_ntm.oalist_inv (sort_oalist_ko_ntm' ox xs', ox)"
using ko_ntm.oalist_inv_sort_oalist_raw (*‹ko_ntm.oalist_inv (sort_oalist_ko_ntm (?xs::(?'a × ?'b) list × ?'a nat_term_order))›*) by fastforce
thus "?thesis"
(*goal: ‹list_of_oalist_ntm (OAlist_ntm xs) = sort_oalist_ko_ntm xs›*)
by (simp add: xs (*‹xs = (xs', ox)›*) OAlist_ntm_def (*‹OAlist_ntm ?xs = Abs_oalist_ntm (sort_oalist_ko_ntm ?xs)›*) Abs_oalist_ntm_inverse (*‹?y ∈ Collect ko_ntm.oalist_inv ⟹ list_of_oalist_ntm (Abs_oalist_ntm ?y) = ?y›*))
qed
lemma OAlist_list_of_oalist_ntm [simp, code abstype]: "OAlist_ntm (list_of_oalist_ntm xs) = xs"
proof (-)
(*goal: ‹OAlist_ntm (list_of_oalist_ntm (xs::('a::nat_term, 'b::zero) oalist_ntm)) = xs›*)
obtain xs' and ox where xs: "list_of_oalist_ntm xs = (xs', ox)"
(*goal: ‹(⋀xs' ox. list_of_oalist_ntm xs = (xs', ox) ⟹ thesis) ⟹ thesis›*)
by fastforce
have "ko_ntm.oalist_inv_raw ox xs'"
by (simp add: xs[symmetric] (*‹(xs'::('a × 'b) list, ox::'a nat_term_order) = list_of_oalist_ntm (xs::('a, 'b) oalist_ntm)›*) ko_ntm.oalist_inv_alt[symmetric] (*‹ko.oalist_inv_raw (key_order_of_nat_term_order_inv (?ko::?'a nat_term_order)) (?xs::(?'a × ?'b) list) = ko_ntm.oalist_inv (?xs, ?ko)›*) nat_term_compare_inv_conv (*‹nat_term_compare_inv (?to::?'a nat_term_order) = key_compare (key_order_of_nat_term_order_inv ?to)›*) oalist_inv_list_of_oalist_ntm (*‹ko_ntm.oalist_inv (list_of_oalist_ntm (?xs::(?'a, ?'b) oalist_ntm))›*))
thus "?thesis"
(*goal: ‹OAlist_ntm (list_of_oalist_ntm (xs::('a, 'b) oalist_ntm)) = xs›*)
apply (simp add: xs (*‹list_of_oalist_ntm xs = (xs', ox)›*) OAlist_ntm_def (*‹OAlist_ntm ?xs = Abs_oalist_ntm (sort_oalist_ko_ntm ?xs)›*) ko_ntm.sort_oalist_id (*‹ko_ntm.oalist_inv_raw ?ko ?xs ⟹ sort_oalist_ko_ntm' ?ko ?xs = ?xs›*))
(*goal: ‹OAlist_ntm (list_of_oalist_ntm xs) = xs›*)
by (simp add: list_of_oalist_ntm_inverse (*‹Abs_oalist_ntm (list_of_oalist_ntm ?x) = ?x›*) xs[symmetric] (*‹(xs', ox) = list_of_oalist_ntm xs›*))
qed
lemma [code abstract]: "list_of_oalist_ntm (oalist_of_list_ntm xs) = sort_oalist_ko_ntm xs"
by (simp add: list_of_oalist_OAlist_ntm (*‹list_of_oalist_ntm (OAlist_ntm ?xs) = sort_oalist_ko_ntm ?xs›*) oalist_of_list_ntm_def (*‹oalist_of_list_ntm = OAlist_ntm›*))
global_interpretation oa_ntm: oalist_abstract key_order_of_nat_term_order_inv list_of_oalist_ntm OAlist_ntm
defines OAlist_lookup_ntm = oa_ntm.lookup
and OAlist_sorted_domain_ntm = oa_ntm.sorted_domain
and OAlist_empty_ntm = oa_ntm.empty
and OAlist_reorder_ntm = oa_ntm.reorder
and OAlist_tl_ntm = oa_ntm.tl
and OAlist_hd_ntm = oa_ntm.hd
and OAlist_except_min_ntm = oa_ntm.except_min
and OAlist_min_key_val_ntm = oa_ntm.min_key_val
and OAlist_insert_ntm = oa_ntm.insert
and OAlist_update_by_fun_ntm = oa_ntm.update_by_fun
and OAlist_update_by_fun_gr_ntm = oa_ntm.update_by_fun_gr
and OAlist_filter_ntm = oa_ntm.filter
and OAlist_map2_val_neutr_ntm = oa_ntm.map2_val_neutr
and OAlist_eq_ntm = oa_ntm.oalist_eq
apply unfold_locales
(*goal: ‹oalist_abstract key_order_of_nat_term_order_inv list_of_oalist_ntm OAlist_ntm›*)
subgoal for
by (fact oalist_inv_list_of_oalist_ntm (*‹ko_ntm.oalist_inv (list_of_oalist_ntm ?xs)›*))
subgoal for
by (simp only: list_of_oalist_OAlist_ntm (*‹list_of_oalist_ntm (OAlist_ntm ?xs) = sort_oalist_ko_ntm ?xs›*) sort_oalist_ko_ntm_def (*‹sort_oalist_ko_ntm ≡ oalist_raw.sort_oalist_raw key_order_of_nat_term_order_inv›*))
subgoal for
by (fact OAlist_list_of_oalist_ntm (*‹OAlist_ntm (list_of_oalist_ntm ?xs) = ?xs›*)) .
global_interpretation oa_ntm: oalist_abstract3 key_order_of_nat_term_order_inv
"list_of_oalist_ntm::('a, 'b) oalist_ntm ⇒ ('a, 'b::zero, 'a::nat_term nat_term_order) oalist_raw" OAlist_ntm
"list_of_oalist_ntm::('a, 'c) oalist_ntm ⇒ ('a, 'c::zero, 'a nat_term_order) oalist_raw" OAlist_ntm
"list_of_oalist_ntm::('a, 'd) oalist_ntm ⇒ ('a, 'd::zero, 'a nat_term_order) oalist_raw" OAlist_ntm
defines OAlist_map_val_ntm = oa_ntm.map_val
and OAlist_map2_val_ntm = oa_ntm.map2_val
and OAlist_map2_val_rneutr_ntm = oa_ntm.map2_val_rneutr
and OAlist_lex_ord_ntm = oa_ntm.lex_ord
and OAlist_prod_ord_ntm = oa_ntm.prod_ord by standard
lemmas OAlist_lookup_ntm_single = oa_ntm.lookup_oalist_of_list_single[folded oalist_of_list_ntm_def]
end (* theory *)
| {
"path": "afp-2025-02-12/thys/Polynomials/OAlist_Poly_Mapping.thy",
"repo": "afp-2025-02-12",
"sha": "1f1af69e612dfa6a1048c0d9b1d28882333cca63b7468fba7fb21e394148beed"
} |
(***********************************************************************************
* Copyright (c) 2016-2020 The University of Sheffield, UK
* 2019-2020 University of Exeter, UK
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* SPDX-License-Identifier: BSD-2-Clause
***********************************************************************************)
(* This file is automatically generated, please do not modify! *)
section‹Testing Node\_insertBefore›
text‹This theory contains the test cases for Node\_insertBefore.›
theory Shadow_DOM_Node_insertBefore
imports
"Shadow_DOM_BaseTest"
begin
definition Node_insertBefore_heap :: heap⇩f⇩i⇩n⇩a⇩l where
"Node_insertBefore_heap = create_heap [(cast (document_ptr.Ref 1), cast (create_document_obj html (Some (cast (element_ptr.Ref 1))) [])),
(cast (element_ptr.Ref 1), cast (create_element_obj ''html'' [cast (element_ptr.Ref 2), cast (element_ptr.Ref 6)] fmempty None)),
(cast (element_ptr.Ref 2), cast (create_element_obj ''head'' [cast (element_ptr.Ref 3), cast (element_ptr.Ref 4), cast (element_ptr.Ref 5)] fmempty None)),
(cast (element_ptr.Ref 3), cast (create_element_obj ''title'' [cast (character_data_ptr.Ref 1)] fmempty None)),
(cast (character_data_ptr.Ref 1), cast (create_character_data_obj ''Node.insertBefore'')),
(cast (element_ptr.Ref 4), cast (create_element_obj ''script'' [] (fmap_of_list [(''src'', ''/resources/testharness.js'')]) None)),
(cast (element_ptr.Ref 5), cast (create_element_obj ''script'' [] (fmap_of_list [(''src'', ''/resources/testharnessreport.js'')]) None)),
(cast (element_ptr.Ref 6), cast (create_element_obj ''body'' [cast (element_ptr.Ref 7), cast (element_ptr.Ref 8)] fmempty None)),
(cast (element_ptr.Ref 7), cast (create_element_obj ''div'' [] (fmap_of_list [(''id'', ''log'')]) None)),
(cast (element_ptr.Ref 8), cast (create_element_obj ''script'' [cast (character_data_ptr.Ref 2)] fmempty None)),
(cast (character_data_ptr.Ref 2), cast (create_character_data_obj ''%3C%3Cscript%3E%3E''))]"
definition Node_insertBefore_document :: "(unit, unit, unit, unit, unit, unit) object_ptr option" where "Node_insertBefore_document = Some (cast (document_ptr.Ref 1))"
text ‹"Calling insertBefore an a leaf node Text must throw HIERARCHY\_REQUEST\_ERR."›
lemma "test (do {
node ← Node_insertBefore_document . createTextNode(''Foo'');
tmp0 ← Node_insertBefore_document . createTextNode(''fail'');
assert_throws(HierarchyRequestError, node . insertBefore(tmp0, None))
}) Node_insertBefore_heap"
by eval
text ‹"Calling insertBefore with an inclusive ancestor of the context object must throw HIERARCHY\_REQUEST\_ERR."›
lemma "test (do {
tmp1 ← Node_insertBefore_document . body;
tmp2 ← Node_insertBefore_document . getElementById(''log'');
tmp0 ← Node_insertBefore_document . body;
assert_throws(HierarchyRequestError, tmp0 . insertBefore(tmp1, tmp2));
tmp4 ← Node_insertBefore_document . documentElement;
tmp5 ← Node_insertBefore_document . getElementById(''log'');
tmp3 ← Node_insertBefore_document . body;
assert_throws(HierarchyRequestError, tmp3 . insertBefore(tmp4, tmp5))
}) Node_insertBefore_heap"
by eval
text ‹"Calling insertBefore with a reference child whose parent is not the context node must throw a NotFoundError."›
lemma "test (do {
a ← Node_insertBefore_document . createElement(''div'');
b ← Node_insertBefore_document . createElement(''div'');
c ← Node_insertBefore_document . createElement(''div'');
assert_throws(NotFoundError, a . insertBefore(b, c))
}) Node_insertBefore_heap"
by eval
text ‹"If the context node is a document, inserting a document or text node should throw a HierarchyRequestError."›
lemma "test (do {
doc ← createDocument(''title'');
doc2 ← createDocument(''title2'');
tmp0 ← doc . documentElement;
assert_throws(HierarchyRequestError, doc . insertBefore(doc2, tmp0));
tmp1 ← doc . createTextNode(''text'');
tmp2 ← doc . documentElement;
assert_throws(HierarchyRequestError, doc . insertBefore(tmp1, tmp2))
}) Node_insertBefore_heap"
by eval
text ‹"Inserting a node before itself should not move the node"›
lemma "test (do {
a ← Node_insertBefore_document . createElement(''div'');
b ← Node_insertBefore_document . createElement(''div'');
c ← Node_insertBefore_document . createElement(''div'');
a . appendChild(b);
a . appendChild(c);
tmp0 ← a . childNodes;
assert_array_equals(tmp0, [b, c]);
tmp1 ← a . insertBefore(b, b);
assert_equals(tmp1, b);
tmp2 ← a . childNodes;
assert_array_equals(tmp2, [b, c]);
tmp3 ← a . insertBefore(c, c);
assert_equals(tmp3, c);
tmp4 ← a . childNodes;
assert_array_equals(tmp4, [b, c])
}) Node_insertBefore_heap"
by eval
end
| {
"path": "afp-2025-02-12/thys/Shadow_SC_DOM/tests/Shadow_DOM_Node_insertBefore.thy",
"repo": "afp-2025-02-12",
"sha": "00620014b4bf5191868181f80ad86f6d96935d45595bf448f5c8cd091dcc2773"
} |
(*
Title: Modal quantales
Author: Georg Struth
Maintainer: Georg Struth <g.struth at sheffield.ac.uk>
*)
section ‹Modal quantales›
theory Modal_Quantale
imports Quantales.Quantale_Star Modal_Kleene_Algebra_Var KAD.Modal_Kleene_Algebra
begin
subsection ‹Simplified modal semirings and Kleene algebras›
text ‹The previous formalisation of modal Kleene algebra in the AFP adds two compatibility axioms between domain and codomain
when combining an antidomain semiring with an antirange semiring. But these are unnecessary. They are derivable from the other
axioms. Thus I provide a simpler axiomatisation that should eventually replace the one in the AFP.›
class modal_semiring_simp = antidomain_semiring + antirange_semiring
lemma (in modal_semiring_simp) dr_compat [simp]: "d (r x) = r x"
proof (-)
(*goal: ‹d (r (x::'a)) = r x›*)
have a: "ar x ⋅ d (r x) = 0"
using local.ads_d_def (*‹d ?x = ad (ad ?x)›*) local.ars_r_def (*‹r ?x = ar ar ?x›*) local.dpdz.dom_weakly_local (*‹((?x::'a) ⋅ (?y::'a) = (zero_class.zero::'a)) = (?x ⋅ ad (ad ?y) = (zero_class.zero::'a))›*) by auto
have "r x ⋅ d (r x) ⋅ ar x ≤ r x ⋅ ar x"
by (simp add: local.a_subid_aux2 (*‹?x ⋅ ad ?y ≤ ?x›*) local.ads_d_def (*‹d ?x = ad (ad ?x)›*) local.mult_isor (*‹?x ≤ ?y ⟹ ?x ⋅ ?z ≤ ?y ⋅ ?z›*))
hence b: "r x ⋅ d (r x) ⋅ ar x = 0"
by (simp add: local.ardual.am2 (*‹ar ?y ⋅ ar ?x = ar ?x ⋅ ar ?y›*) local.ars_r_def (*‹r ?x = ar ar ?x›*) local.join.bot_unique (*‹(?a ≤ zero_class.zero) = (?a = zero_class.zero)›*))
have "d (r x) = (ar x + r x) ⋅ d (r x)"
using local.add_comm (*‹?x + ?y = ?y + ?x›*) local.ardual.ans3 (*‹ar ar (?x::'a::type) + ar ?x = (1::'a::type)›*) local.ars_r_def (*‹r ?x = ar ar ?x›*) local.mult_1_left (*‹(1::'a::type) ⋅ (?a::'a::type) = ?a›*) by presburger
also (*calculation: ‹d (r x) = (ar x + r x) ⋅ d (r x)›*) have "… = ar x ⋅ d (r x) + r x ⋅ d (r x)"
by simp
also (*calculation: ‹d (r (x::'a::type)) = ar x ⋅ d (r x) + r x ⋅ d (r x)›*) have "… = r x ⋅ d (r x)"
by (simp add: a (*‹ar x ⋅ d (r x) = zero_class.zero›*))
also (*calculation: ‹d (r x) = r x ⋅ d (r x)›*) have "… = r x ⋅ d (r x) ⋅ (ar x + r x)"
using local.add_comm (*‹?x + ?y = ?y + ?x›*) local.ardual.ans3 (*‹ar ar ?x + ar ?x = 1›*) local.ars_r_def (*‹r ?x = ar ar ?x›*) by auto
also (*calculation: ‹d (r x) = r x ⋅ d (r x) ⋅ (ar x + r x)›*) have "… = r x ⋅ d (r x) ⋅ ar x + r x ⋅ d (r x) ⋅ r x"
by simp
also (*calculation: ‹d (r (x::'a)) = r x ⋅ d (r x) ⋅ ar x + r x ⋅ d (r x) ⋅ r x›*) have "… = r x ⋅ d (r x) ⋅ r x"
using b (*‹r (x::'a::type) ⋅ d (r x) ⋅ ar x = (zero_class.zero::'a::type)›*) by auto
also (*calculation: ‹d (r x) = r x ⋅ d (r x) ⋅ r x›*) have "… = r x"
by (metis local.ads_d_def (*‹d ?x = ad (ad ?x)›*) local.am3 (*‹ad (ad ?x) ⋅ ?x = ?x›*) local.ardual.a_mult_idem (*‹ar ?x ⋅ ar ?x = ar ?x›*) local.ars_r_def (*‹r ?x = ar ar ?x›*) local.ds.ddual.mult_assoc (*‹?c ⋅ (?b ⋅ ?a) = ?c ⋅ ?b ⋅ ?a›*))
finally (*calculation: ‹d (r x) = r x›*) show "?thesis"
(*goal: ‹d (r x) = r x›*)
by simp
qed
lemma (in modal_semiring_simp) rd_compat [simp]: "r (d x) = d x"
by (smt (verit) local.a_mult_idem (*‹ad ?x ⋅ ad ?x = ad ?x›*) local.ads_d_def (*‹d ?x = ad (ad ?x)›*) local.am2 (*‹ad ?x ⋅ ad ?y = ad ?y ⋅ ad ?x›*) local.ardual.dpdz.dom_weakly_local (*‹(?y ⋅ ?x = zero_class.zero) = (ar ar ?y ⋅ ?x = zero_class.zero)›*) local.ars_r_def (*‹r ?x = ar ar ?x›*) local.dr_compat (*‹d (r ?x) = r ?x›*) local.kat_3_equiv' (*‹(d ?x ⋅ ?y ⋅ ad ?z = zero_class.zero) = (d ?x ⋅ ?y = d ?x ⋅ ?y ⋅ d ?z)›*))
subclass (in modal_semiring_simp) modal_semiring
apply unfold_locales by simp_all
class modal_kleene_algebra_simp = modal_semiring_simp + kleene_algebra
subclass (in modal_kleene_algebra_simp) modal_kleene_algebra..
subsection ‹Domain quantales›
class domain_quantale = unital_quantale + domain_op +
assumes dom_absorb: "x ≤ dom x ⋅ x"
and dom_local: "dom (x ⋅ dom y) = dom (x ⋅ y)"
and dom_add: "dom (x ⊔ y) = dom x ⊔ dom y"
and dom_subid: "dom x ≤ 1"
and dom_zero [simp]: "dom ⊥ = ⊥"
text ‹The definition is that of a domain semiring. I cannot extend the quantale class with respect to domain semirings
because of different operations are used for addition/sup. The following sublocale statement brings all those properties into scope.›
sublocale domain_quantale ⊆ dqmsr: domain_semiring "(⊔)" "(⋅)" 1 ⊥ dom "(≤)" "(<)"
apply unfold_locales
(*goals:
1. ‹⋀x. x ⊔ dom x ⋅ x = dom x ⋅ x›
2. ‹⋀x y. dom (x ⋅ dom y) = dom (x ⋅ y)›
3. ‹⋀x. dom x ⊔ 1 = 1›
4. ‹dom ⊥ = ⊥›
5. ‹⋀x y. dom (x ⊔ y) = dom x ⊔ dom y›
discuss goal 1*)
apply (simp add: dom_add (*‹dom (?x ⊔ ?y) = dom ?x ⊔ dom ?y›*) dom_local (*‹dom (?x ⋅ dom ?y) = dom (?x ⋅ ?y)›*) dom_absorb (*‹?x ≤ dom ?x ⋅ ?x›*) sup.absorb2 (*‹?a ≤ ?b ⟹ ?a ⊔ ?b = ?b›*) dom_subid (*‹dom ?x ≤ 1›*))
(*discuss goal 2*)
apply (simp add: dom_add (*‹dom (?x ⊔ ?y) = dom ?x ⊔ dom ?y›*) dom_local (*‹dom (?x ⋅ dom ?y) = dom (?x ⋅ ?y)›*) dom_absorb (*‹?x ≤ dom ?x ⋅ ?x›*) sup.absorb2 (*‹?a ≤ ?b ⟹ ?a ⊔ ?b = ?b›*) dom_subid (*‹dom ?x ≤ 1›*))
(*discuss goal 3*)
apply (simp add: dom_add (*‹dom (?x ⊔ ?y) = dom ?x ⊔ dom ?y›*) dom_local (*‹dom (?x ⋅ dom ?y) = dom (?x ⋅ ?y)›*) dom_absorb (*‹?x ≤ dom ?x ⋅ ?x›*) sup.absorb2 (*‹?a ≤ ?b ⟹ ?a ⊔ ?b = ?b›*) dom_subid (*‹dom ?x ≤ 1›*))
(*discuss goal 4*)
apply (simp add: dom_add (*‹dom (?x ⊔ ?y) = dom ?x ⊔ dom ?y›*) dom_local (*‹dom (?x ⋅ dom ?y) = dom (?x ⋅ ?y)›*) dom_absorb (*‹?x ≤ dom ?x ⋅ ?x›*) sup.absorb2 (*‹?a ≤ ?b ⟹ ?a ⊔ ?b = ?b›*) dom_subid (*‹dom ?x ≤ 1›*))
(*discuss goal 5*)
apply (simp add: dom_add (*‹dom (?x ⊔ ?y) = dom ?x ⊔ dom ?y›*) dom_local (*‹dom (?x ⋅ dom ?y) = dom (?x ⋅ ?y)›*) dom_absorb (*‹?x ≤ dom ?x ⋅ ?x›*) sup.absorb2 (*‹?a ≤ ?b ⟹ ?a ⊔ ?b = ?b›*) dom_subid (*‹dom ?x ≤ 1›*))
(*proven 5 subgoals*) .
sublocale domain_quantale ⊆ dqmka: domain_kleene_algebra "(⊔)" "(⋅)" 1 ⊥ dom "(≤)" "(<)" qstarby standard
typedef (overloaded) 'a d_element = "{x :: 'a :: domain_quantale. dom x = x}"
using dqmsr.dom_one by blast
setup_lifting type_definition_d_element
instantiation d_element :: (domain_quantale) bounded_lattice
begin
lift_definition less_eq_d_element :: "'a d_element ⇒ 'a d_element ⇒ bool" is "(≤)" .
lift_definition less_d_element :: "'a d_element ⇒ 'a d_element ⇒ bool" is "(<)" .
lift_definition bot_d_element :: "'a d_element" is ⊥
by simp
lift_definition top_d_element :: "'a d_element" is 1
by simp
lift_definition inf_d_element :: "'a d_element ⇒ 'a d_element ⇒ 'a d_element" is "(⋅)"
by (metis dqmsr.dom_mult_closed)
lift_definition sup_d_element :: "'a d_element ⇒ 'a d_element ⇒ 'a d_element" is "(⊔)"
by simp
instance
apply (standard; transfer)
apply (simp_all add: less_le_not_le)
apply (metis dqmsr.dom_subid_aux2'')
apply (metis dqmsr.dom_subid_aux1'')
apply (metis dqmsr.dom_glb_eq)
by (metis dqmsr.dom_subid)
end
instance d_element :: (domain_quantale) distrib_lattice
by (standard, transfer, metis dqmsr.dom_distrib)
context domain_quantale
begin
lemma dom_top [simp]: "dom ⊤ = 1"
proof (-)
(*goal: ‹dom ⊤ = 1›*)
have "1 ≤ ⊤"
by simp
hence "dom 1 ≤ dom ⊤"
using local.dqmsr.d_iso (*‹?x ≤ ?y ⟹ dom ?x ≤ dom ?y›*) by blast
thus "?thesis"
(*goal: ‹dom ⊤ = (1::'a::type)›*)
by (simp add: local.dual_order.antisym (*‹⟦?b ≤ ?a; ?a ≤ ?b⟧ ⟹ ?a = ?b›*))
qed
lemma dom_top2: "x ⋅ ⊤ ≤ dom x ⋅ ⊤"
proof (-)
(*goal: ‹x ⋅ ⊤ ≤ dom x ⋅ ⊤›*)
have "x ⋅ ⊤ = dom x ⋅ x ⋅ ⊤"
by simp
also (*calculation: ‹(x::'a) ⋅ ⊤ = dom x ⋅ x ⋅ ⊤›*) have "… ≤ dom x ⋅ ⊤ ⋅ ⊤"
using local.dqmsr.d_restrict_iff_1 (*‹(dom ?x ⋅ ?y ≤ ?z) = (dom ?x ⋅ ?y ≤ dom ?x ⋅ ?z)›*) local.top_greatest (*‹?a ≤ ⊤›*) local.top_times_top (*‹⊤ ⋅ ⊤ = ⊤›*) mult_assoc (*‹?a ⋅ ?b ⋅ ?c = ?a ⋅ (?b ⋅ ?c)›*) by presburger
finally (*calculation: ‹x ⋅ ⊤ ≤ dom x ⋅ ⊤ ⋅ ⊤›*) show "?thesis"
(*goal: ‹(x::'a) ⋅ ⊤ ≤ dom x ⋅ ⊤›*)
by (simp add: local.mult.semigroup_axioms (*‹semigroup (⋅)›*) semigroup.assoc (*‹semigroup (?f::?'a::type ⇒ ?'a::type ⇒ ?'a::type) ⟹ ?f (?f (?a::?'a::type) (?b::?'a::type)) (?c::?'a::type) = ?f ?a (?f ?b ?c)›*))
qed
lemma weak_twisted: "x ⋅ dom y ≤ dom (x ⋅ y) ⋅ x"
using local.dqmsr.fd_def (*‹domain_semiringl.fd (⋅) dom ?x ?y = dom (?x ⋅ ?y)›*) local.dqmsr.fdemodalisation2 (*‹(domain_semiringl.fd (⋅) dom ?x ?y ≤ dom ?z) = (?x ⋅ dom ?y ≤ dom ?z ⋅ ?x)›*) local.eq_refl (*‹?x = ?y ⟹ ?x ≤ ?y›*) by blast
lemma dom_meet: "dom x ⋅ dom y = dom x ⊓ dom y"
apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*))
(*goals:
1. ‹dom x ⋅ dom y ≤ dom x ⊓ dom y›
2. ‹dom x ⊓ dom y ≤ dom x ⋅ dom y›
discuss goal 1*)
apply (simp add: local.dqmsr.dom_subid_aux2 (*‹dom ?x ⋅ ?y ≤ ?y›*) local.dqmsr.dom_subid_aux2'' (*‹?x ⋅ dom ?y ≤ ?x›*))
(*discuss goal 2*)
apply (smt (z3) local.dom_absorb (*‹?x ≤ dom ?x ⋅ ?x›*) local.dqmsr.dom_iso (*‹?x ≤ ?y ⟹ dom ?x ≤ dom ?y›*) local.dqmsr.dom_subid_aux2 (*‹dom ?x ⋅ ?y ≤ ?y›*) local.dqmsr.dsg3 (*‹dom (dom ?x ⋅ ?y) = dom ?x ⋅ dom ?y›*) local.dqmsr.dsg4 (*‹dom ?x ⋅ dom ?y = dom ?y ⋅ dom ?x›*) local.dual_order.antisym (*‹⟦?b ≤ ?a; ?a ≤ ?b⟧ ⟹ ?a = ?b›*) local.inf.cobounded1 (*‹?a ⊓ ?b ≤ ?a›*) local.inf.cobounded2 (*‹?a ⊓ ?b ≤ ?b›*) local.psrpq.mult_isol_var (*‹⟦?u ≤ ?x; ?v ≤ ?y⟧ ⟹ ?u ⋅ ?v ≤ ?x ⋅ ?y›*))
(*proven 2 subgoals*) .
lemma dom_meet_pres: "dom (dom x ⊓ dom y) = dom x ⊓ dom y"
using dom_meet (*‹dom ?x ⋅ dom ?y = dom ?x ⊓ dom ?y›*) local.dqmsr.dom_mult_closed (*‹dom (dom ?x ⋅ dom ?y) = dom ?x ⋅ dom ?y›*) by presburger
lemma dom_meet_distl: "dom x ⋅ (y ⊓ z) = (dom x ⋅ y) ⊓ (dom x ⋅ z)"
proof (-)
(*goal: ‹dom x ⋅ (y ⊓ z) = dom x ⋅ y ⊓ (dom x ⋅ z)›*)
have a: "dom x ⋅ (y ⊓ z) ≤ (dom x ⋅ y) ⊓ (dom x ⋅ z)"
using local.mult_isol (*‹?x ≤ ?y ⟹ ?z ⋅ ?x ≤ ?z ⋅ ?y›*) by force
have "(dom x ⋅ y) ⊓ (dom x ⋅ z) = dom ((dom x ⋅ y) ⊓ (dom x ⋅ z)) ⋅ ((dom x ⋅ y) ⊓ (dom x ⋅ z))"
by simp
also (*calculation: ‹dom x ⋅ y ⊓ (dom x ⋅ z) = dom (dom x ⋅ y ⊓ (dom x ⋅ z)) ⋅ (dom x ⋅ y ⊓ (dom x ⋅ z))›*) have "… ≤ dom ((dom x ⋅ y)) ⋅ ((dom x ⋅ y) ⊓ (dom x ⋅ z))"
using calculation (*‹dom x ⋅ y ⊓ (dom x ⋅ z) = dom (dom x ⋅ y ⊓ (dom x ⋅ z)) ⋅ (dom x ⋅ y ⊓ (dom x ⋅ z))›*) local.dqmsr.dom_iso (*‹?x ≤ ?y ⟹ dom ?x ≤ dom ?y›*) local.dqmsr.dom_llp2 (*‹dom ?x ≤ dom ?y ⟹ ?x ≤ dom ?y ⋅ ?x›*) local.inf.cobounded1 (*‹?a ⊓ ?b ≤ ?a›*) by presburger
also (*calculation: ‹dom x ⋅ y ⊓ (dom x ⋅ z) ≤ dom (dom x ⋅ y) ⋅ (dom x ⋅ y ⊓ (dom x ⋅ z))›*) have "… ≤ dom x ⋅ ((dom x ⋅ y) ⊓ (dom x ⋅ z))"
by (metis local.dqmsr.domain_1'' (*‹dom (?x ⋅ ?y) ≤ dom ?x›*) local.dqmsr.domain_invol (*‹dom (dom ?x) = dom ?x›*) local.mult_isor (*‹?x ≤ ?y ⟹ ?x ⋅ ?z ≤ ?y ⋅ ?z›*))
also (*calculation: ‹dom (x::'a) ⋅ (y::'a) ⊓ (dom x ⋅ (z::'a)) ≤ dom x ⋅ (dom x ⋅ y ⊓ (dom x ⋅ z))›*) have "… ≤ dom x ⋅ (y ⊓ z)"
by (meson local.dqmsr.dom_subid_aux2 (*‹dom ?x ⋅ ?y ≤ ?y›*) local.inf_mono (*‹⟦?a ≤ ?c; ?b ≤ ?d⟧ ⟹ ?a ⊓ ?b ≤ ?c ⊓ ?d›*) local.order_refl (*‹?x ≤ ?x›*) local.psrpq.mult_isol_var (*‹⟦?u ≤ ?x; ?v ≤ ?y⟧ ⟹ ?u ⋅ ?v ≤ ?x ⋅ ?y›*))
finally (*calculation: ‹dom x ⋅ y ⊓ (dom x ⋅ z) ≤ dom x ⋅ (y ⊓ z)›*) show "?thesis"
(*goal: ‹dom x ⋅ (y ⊓ z) = dom x ⋅ y ⊓ (dom x ⋅ z)›*)
using a (*‹dom x ⋅ (y ⊓ z) ≤ dom x ⋅ y ⊓ (dom x ⋅ z)›*) local.dual_order.antisym (*‹⟦?b ≤ ?a; ?a ≤ ?b⟧ ⟹ ?a = ?b›*) by blast
qed
lemma dom_meet_approx: "dom ((dom x ⋅ y) ⊓ (dom x ⋅ z)) ≤ dom x"
by (metis dom_meet_distl (*‹dom ?x ⋅ (?y ⊓ ?z) = dom ?x ⋅ ?y ⊓ (dom ?x ⋅ ?z)›*) local.dqmsr.domain_1'' (*‹dom (?x ⋅ ?y) ≤ dom ?x›*) local.dqmsr.domain_invol (*‹dom (dom ?x) = dom ?x›*))
lemma dom_inf_pres_aux: "Y ≠ {} ⟹ dom (⨅y ∈ Y. dom x ⋅ y) ≤ dom x"
proof (-)
(*goal: ‹Y ≠ {} ⟹ dom (⨅ ((⋅) (dom x) ` Y)) ≤ dom x›*)
assume "Y ≠ {}" (*‹(Y::'a set) ≠ {}›*)
have "∀z∈Y. dom (⨅y ∈ Y. dom x ⋅ y) ≤ dom (dom x ⋅ z)"
by (meson local.INF_lower (*‹?i ∈ ?A ⟹ ⨅ (?f ` ?A) ≤ ?f ?i›*) local.dqmsr.dom_iso (*‹?x ≤ ?y ⟹ dom ?x ≤ dom ?y›*))
hence "∀z∈Y. dom (⨅y ∈ Y. dom x ⋅ y) ≤ dom x ⋅ dom z"
by fastforce
hence "∀z∈Y. dom (⨅y ∈ Y. dom x ⋅ y) ≤ dom x"
using dom_meet (*‹dom (?x::'a) ⋅ dom (?y::'a) = dom ?x ⊓ dom ?y›*) by fastforce
thus "dom (⨅y ∈ Y. dom x ⋅ y) ≤ dom x"
using ‹Y ≠ {}› (*‹Y ≠ {}›*) by blast
qed
lemma dom_inf_pres_aux2: "(⨅y ∈ Y. dom x ⋅ y) ≤ ⨅Y"
by (simp add: local.INF_lower2 (*‹⟦(?i::?'b::type) ∈ (?A::?'b::type set); (?f::?'b::type ⇒ 'a::type) ?i ≤ (?u::'a::type)⟧ ⟹ ⨅ (?f ` ?A) ≤ ?u›*) local.dqmsr.dom_subid_aux2 (*‹dom (?x::'a::type) ⋅ (?y::'a::type) ≤ ?y›*) local.le_Inf_iff (*‹((?b::'a::type) ≤ ⨅ (?A::'a::type set)) = (∀a::'a::type∈?A. ?b ≤ a)›*))
lemma dom_inf_pres: "Y ≠ {} ⟹ dom x ⋅ (⨅Y) = (⨅y ∈ Y. dom x ⋅ y)"
proof (-)
(*goal: ‹Y ≠ {} ⟹ dom x ⋅ ⨅ Y = ⨅ ((⋅) (dom x) ` Y)›*)
assume hyp: "Y ≠ {}" (*‹(Y::'a set) ≠ {}›*)
have a: "dom x ⋅ (⨅Y) ≤ (⨅y ∈ Y. dom x ⋅ y)"
by (simp add: Setcompr_eq_image (*‹{?f x |x. x ∈ ?A} = ?f ` ?A›*) local.Inf_subdistl (*‹?x ⋅ ⨅ ?Y ≤ ⨅ ((⋅) ?x ` ?Y)›*))
have "(⨅y ∈ Y. dom x ⋅ y) = dom (⨅y ∈ Y. dom x ⋅ y) ⋅ (⨅y ∈ Y. dom x ⋅ y)"
by simp
also (*calculation: ‹⨅ ((⋅) (dom x) ` Y) = dom (⨅ ((⋅) (dom x) ` Y)) ⋅ ⨅ ((⋅) (dom x) ` Y)›*) have "… ≤ dom x ⋅ (⨅y ∈ Y. dom x ⋅ y)"
using dom_inf_pres_aux (*‹?Y ≠ {} ⟹ dom (⨅ ((⋅) (dom ?x) ` ?Y)) ≤ dom ?x›*) hyp (*‹Y ≠ {}›*) local.mult_isor (*‹?x ≤ ?y ⟹ ?x ⋅ ?z ≤ ?y ⋅ ?z›*) by blast
also (*calculation: ‹⨅ ((⋅) (dom x) ` Y) ≤ dom x ⋅ ⨅ ((⋅) (dom x) ` Y)›*) have "… ≤ dom x ⋅ ⨅Y"
by (simp add: dom_inf_pres_aux2 (*‹⨅ ((⋅) (dom ?x) ` ?Y) ≤ ⨅ ?Y›*) local.psrpq.mult_isol_var (*‹⟦?u ≤ ?x; ?v ≤ ?y⟧ ⟹ ?u ⋅ ?v ≤ ?x ⋅ ?y›*))
finally (*calculation: ‹⨅ ((⋅) (dom x) ` Y) ≤ dom x ⋅ ⨅ Y›*) show "?thesis"
(*goal: ‹dom x ⋅ ⨅ Y = ⨅ ((⋅) (dom x) ` Y)›*)
using a (*‹dom x ⋅ ⨅ Y ≤ ⨅ ((⋅) (dom x) ` Y)›*) order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*) by blast
qed
lemma "dom (⨅X) ≤ ⨅ (dom ` X)"
by (simp add: local.INF_greatest (*‹(⋀i. i ∈ ?A ⟹ ?u ≤ ?f i) ⟹ ?u ≤ ⨅ (?f ` ?A)›*) local.Inf_lower (*‹?x ∈ ?A ⟹ ⨅ ?A ≤ ?x›*) local.dqmsr.dom_iso (*‹?x ≤ ?y ⟹ dom ?x ≤ dom ?y›*))
text ‹The domain operation need not preserve arbitrary sups, though this property holds, for instance,
in quantales of binary relations. I do not aim at a stronger axiomatisation in this theory.›
lemma dom_top_pres: "(x ≤ dom y ⋅ x) = (x ≤ dom y ⋅ ⊤)"
apply standard
(*goal: ‹(x ≤ dom y ⋅ x) = (x ≤ dom y ⋅ ⊤)›*)
apply (meson local.dqmsr.ddual.mult_isol_var (*‹⟦?u ≤ ?x; ?v ≤ ?y⟧ ⟹ ?v ⋅ ?u ≤ ?y ⋅ ?x›*) local.dual_order.eq_iff (*‹(?a = ?b) = (?b ≤ ?a ∧ ?a ≤ ?b)›*) local.dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) local.top_greatest (*‹?a ≤ ⊤›*))
(*top goal: ‹(x::'a) ≤ dom (y::'a) ⋅ x ⟹ x ≤ dom y ⋅ ⊤› and 1 goal remains*)
using local.dqmsr.dom_iso (*‹?x ≤ ?y ⟹ dom ?x ≤ dom ?y›*) local.dqmsr.dom_llp (*‹(?x ≤ dom ?y ⋅ ?x) = (dom ?x ≤ dom ?y)›*) by fastforce
lemma dom_lla_var: "(dom x ≤ dom y) = (x ≤ dom y ⋅ ⊤)"
using dom_top_pres (*‹(?x ≤ dom ?y ⋅ ?x) = (?x ≤ dom ?y ⋅ ⊤)›*) local.dqmsr.dom_llp (*‹((?x::'a) ≤ dom (?y::'a) ⋅ ?x) = (dom ?x ≤ dom ?y)›*) by force
lemma "dom (1 ⊓ x) = 1 ⊓ x ⟹ x ≤ 1 ⟹ dom x = x"
using local.inf_absorb2 (*‹?y ≤ ?x ⟹ ?x ⊓ ?y = ?y›*) by force
lemma dom_meet_sub: "dom (x ⊓ y) ≤ dom x ⊓ dom y"
by (simp add: local.dqmsr.d_iso (*‹?x ≤ ?y ⟹ dom ?x ≤ dom ?y›*))
lemma dom_dist1: "dom x ⊔ (dom y ⊓ dom z) = (dom x ⊔ dom y) ⊓ (dom x ⊔ dom z)"
by (metis dom_meet (*‹dom ?x ⋅ dom ?y = dom ?x ⊓ dom ?y›*) local.dom_add (*‹dom (?x ⊔ ?y) = dom ?x ⊔ dom ?y›*) local.dqmsr.dom_distrib (*‹dom ?x ⊔ dom ?y ⋅ dom ?z = (dom ?x ⊔ dom ?y) ⋅ (dom ?x ⊔ dom ?z)›*))
lemma dom_dist2: "dom x ⊓ (dom y ⊔ dom z) = (dom x ⊓ dom y) ⊔ (dom x ⊓ dom z)"
by (metis dom_meet (*‹dom (?x::'a) ⋅ dom (?y::'a) = dom ?x ⊓ dom ?y›*) local.dom_add (*‹dom ((?x::'a) ⊔ (?y::'a)) = dom ?x ⊔ dom ?y›*) local.sup_distl (*‹(?x::'a) ⋅ ((?y::'a) ⊔ (?z::'a)) = ?x ⋅ ?y ⊔ ?x ⋅ ?z›*))
abbreviation "fd' ≡ dqmsr.fd"
definition "bb x y = ⨆{dom z |z. fd' x z ≤ dom y}"
lemma fd'_bb_galois_aux: "fd' x (dom p) ≤ dom q ⟹ dom p ≤ bb x (dom q)"
by (simp add: bb_def (*‹bb ?x ?y = ⨆ {dom z |z. fd' ?x z ≤ dom ?y}›*) local.SUP_upper (*‹?i ∈ ?A ⟹ ?f ?i ≤ ⨆ (?f ` ?A)›*) setcompr_eq_image (*‹{?f x |x. ?P x} = ?f ` {x. ?P x}›*))
lemma dom_iso_var: "(⨆x ∈ X. dom x) ≤ dom (⨆x ∈ X. dom x)"
by (meson local.SUP_le_iff (*‹(⨆ (?f ` ?A) ≤ ?u) = (∀i∈?A. ?f i ≤ ?u)›*) local.dom_subid (*‹dom ?x ≤ 1›*) local.dqmsr.domain_subid (*‹?x ≤ 1 ⟹ ?x ≤ dom ?x›*))
lemma dom_iso_var2: "(⨆x ∈ X. dom x) ≤ dom (⨆x ∈ X. x)"
by (simp add: local.SUP_le_iff (*‹(⨆ ((?f::?'b ⇒ 'a) ` (?A::?'b set)) ≤ (?u::'a)) = (∀i::?'b∈?A. ?f i ≤ ?u)›*) local.Sup_upper (*‹(?x::'a) ∈ (?A::'a set) ⟹ ?x ≤ ⨆ ?A›*) local.dqmsr.dom_iso (*‹(?x::'a) ≤ (?y::'a) ⟹ dom ?x ≤ dom ?y›*))
end
subsection ‹Codomain quantales›
class codomain_quantale = unital_quantale + range_op +
assumes cod_absorb: "x ≤ x ⋅ cod x"
and cod_local: "cod (cod x ⋅ y) = cod (x ⋅ y)"
and cod_add: "cod (x ⊔ y) = cod x ⊔ cod y"
and cod_subid: "cod x ≤ 1"
and cod_zero: "cod ⊥ = ⊥"
sublocale codomain_quantale ⊆ coddual: domain_quantale range_op _ "λx y. y ⋅ x" _ _ _ _ _ _ _ _
apply unfold_locales
(*goals:
1. ‹⋀a b c. c ⋅ (b ⋅ a) = c ⋅ b ⋅ a›
2. ‹⋀a. a ⋅ 1 = a›
3. ‹⋀a. 1 ⋅ a = a›
4. ‹⋀X y. y ⋅ ⨆ X = ⨆ ((⋅) y ` X)›
5. ‹⋀x Y. ⨆ Y ⋅ x = (⨆y∈Y. y ⋅ x)›
6. ‹⋀x. x ≤ x ⋅ cod x›
7. ‹⋀x y. cod (cod y ⋅ x) = cod (y ⋅ x)›
8. ‹⋀x y. cod (x ⊔ y) = cod x ⊔ cod y›
9. ‹⋀x. cod x ≤ 1›
10. ‹cod ⊥ = ⊥›
discuss goal 1*)
apply ((auto simp: mult_assoc (*‹(?a::'a) ⋅ (?b::'a) ⋅ (?c::'a) = ?a ⋅ (?b ⋅ ?c)›*) cod_subid (*‹cod (?x::'a) ≤ (1::'a)›*) cod_zero (*‹cod ⊥ = ⊥›*) cod_add (*‹cod ((?x::'a) ⊔ (?y::'a)) = cod ?x ⊔ cod ?y›*) cod_local (*‹cod (cod (?x::'a) ⋅ (?y::'a)) = cod (?x ⋅ ?y)›*) cod_absorb (*‹(?x::'a) ≤ ?x ⋅ cod ?x›*) Sup_distr (*‹⨆ (?X::'a set) ⋅ (?y::'a) = (⨆x::'a∈?X. x ⋅ ?y)›*) Sup_distl (*‹(?x::'a) ⋅ ⨆ (?Y::'a set) = ⨆ ((⋅) ?x ` ?Y)›*))[1])
(*discuss goal 2*)
apply ((auto simp: mult_assoc (*‹(?a::'a) ⋅ (?b::'a) ⋅ (?c::'a) = ?a ⋅ (?b ⋅ ?c)›*) cod_subid (*‹cod (?x::'a) ≤ (1::'a)›*) cod_zero (*‹cod ⊥ = ⊥›*) cod_add (*‹cod ((?x::'a) ⊔ (?y::'a)) = cod ?x ⊔ cod ?y›*) cod_local (*‹cod (cod (?x::'a) ⋅ (?y::'a)) = cod (?x ⋅ ?y)›*) cod_absorb (*‹(?x::'a) ≤ ?x ⋅ cod ?x›*) Sup_distr (*‹⨆ (?X::'a set) ⋅ (?y::'a) = (⨆x::'a∈?X. x ⋅ ?y)›*) Sup_distl (*‹(?x::'a) ⋅ ⨆ (?Y::'a set) = ⨆ ((⋅) ?x ` ?Y)›*))[1])
(*discuss goal 3*)
apply ((auto simp: mult_assoc (*‹?a ⋅ ?b ⋅ ?c = ?a ⋅ (?b ⋅ ?c)›*) cod_subid (*‹cod ?x ≤ 1›*) cod_zero (*‹cod ⊥ = ⊥›*) cod_add (*‹cod (?x ⊔ ?y) = cod ?x ⊔ cod ?y›*) cod_local (*‹cod (cod ?x ⋅ ?y) = cod (?x ⋅ ?y)›*) cod_absorb (*‹?x ≤ ?x ⋅ cod ?x›*) Sup_distr (*‹⨆ ?X ⋅ ?y = (⨆x∈?X. x ⋅ ?y)›*) Sup_distl (*‹?x ⋅ ⨆ ?Y = ⨆ ((⋅) ?x ` ?Y)›*))[1])
(*discuss goal 4*)
apply ((auto simp: mult_assoc (*‹?a ⋅ ?b ⋅ ?c = ?a ⋅ (?b ⋅ ?c)›*) cod_subid (*‹cod ?x ≤ 1›*) cod_zero (*‹cod ⊥ = ⊥›*) cod_add (*‹cod (?x ⊔ ?y) = cod ?x ⊔ cod ?y›*) cod_local (*‹cod (cod ?x ⋅ ?y) = cod (?x ⋅ ?y)›*) cod_absorb (*‹?x ≤ ?x ⋅ cod ?x›*) Sup_distr (*‹⨆ ?X ⋅ ?y = (⨆x∈?X. x ⋅ ?y)›*) Sup_distl (*‹?x ⋅ ⨆ ?Y = ⨆ ((⋅) ?x ` ?Y)›*))[1])
(*discuss goal 5*)
apply ((auto simp: mult_assoc (*‹?a ⋅ ?b ⋅ ?c = ?a ⋅ (?b ⋅ ?c)›*) cod_subid (*‹cod ?x ≤ 1›*) cod_zero (*‹cod ⊥ = ⊥›*) cod_add (*‹cod (?x ⊔ ?y) = cod ?x ⊔ cod ?y›*) cod_local (*‹cod (cod ?x ⋅ ?y) = cod (?x ⋅ ?y)›*) cod_absorb (*‹?x ≤ ?x ⋅ cod ?x›*) Sup_distr (*‹⨆ ?X ⋅ ?y = (⨆x∈?X. x ⋅ ?y)›*) Sup_distl (*‹?x ⋅ ⨆ ?Y = ⨆ ((⋅) ?x ` ?Y)›*))[1])
(*discuss goal 6*)
apply ((auto simp: mult_assoc (*‹?a ⋅ ?b ⋅ ?c = ?a ⋅ (?b ⋅ ?c)›*) cod_subid (*‹cod ?x ≤ 1›*) cod_zero (*‹cod ⊥ = ⊥›*) cod_add (*‹cod (?x ⊔ ?y) = cod ?x ⊔ cod ?y›*) cod_local (*‹cod (cod ?x ⋅ ?y) = cod (?x ⋅ ?y)›*) cod_absorb (*‹?x ≤ ?x ⋅ cod ?x›*) Sup_distr (*‹⨆ ?X ⋅ ?y = (⨆x∈?X. x ⋅ ?y)›*) Sup_distl (*‹?x ⋅ ⨆ ?Y = ⨆ ((⋅) ?x ` ?Y)›*))[1])
(*discuss goal 7*)
apply ((auto simp: mult_assoc (*‹(?a::'a) ⋅ (?b::'a) ⋅ (?c::'a) = ?a ⋅ (?b ⋅ ?c)›*) cod_subid (*‹cod (?x::'a) ≤ (1::'a)›*) cod_zero (*‹cod ⊥ = ⊥›*) cod_add (*‹cod ((?x::'a) ⊔ (?y::'a)) = cod ?x ⊔ cod ?y›*) cod_local (*‹cod (cod (?x::'a) ⋅ (?y::'a)) = cod (?x ⋅ ?y)›*) cod_absorb (*‹(?x::'a) ≤ ?x ⋅ cod ?x›*) Sup_distr (*‹⨆ (?X::'a set) ⋅ (?y::'a) = (⨆x::'a∈?X. x ⋅ ?y)›*) Sup_distl (*‹(?x::'a) ⋅ ⨆ (?Y::'a set) = ⨆ ((⋅) ?x ` ?Y)›*))[1])
(*discuss goal 8*)
apply ((auto simp: mult_assoc (*‹?a ⋅ ?b ⋅ ?c = ?a ⋅ (?b ⋅ ?c)›*) cod_subid (*‹cod ?x ≤ 1›*) cod_zero (*‹cod ⊥ = ⊥›*) cod_add (*‹cod (?x ⊔ ?y) = cod ?x ⊔ cod ?y›*) cod_local (*‹cod (cod ?x ⋅ ?y) = cod (?x ⋅ ?y)›*) cod_absorb (*‹?x ≤ ?x ⋅ cod ?x›*) Sup_distr (*‹⨆ ?X ⋅ ?y = (⨆x∈?X. x ⋅ ?y)›*) Sup_distl (*‹?x ⋅ ⨆ ?Y = ⨆ ((⋅) ?x ` ?Y)›*))[1])
(*discuss goal 9*)
apply ((auto simp: mult_assoc (*‹?a ⋅ ?b ⋅ ?c = ?a ⋅ (?b ⋅ ?c)›*) cod_subid (*‹cod ?x ≤ 1›*) cod_zero (*‹cod ⊥ = ⊥›*) cod_add (*‹cod (?x ⊔ ?y) = cod ?x ⊔ cod ?y›*) cod_local (*‹cod (cod ?x ⋅ ?y) = cod (?x ⋅ ?y)›*) cod_absorb (*‹?x ≤ ?x ⋅ cod ?x›*) Sup_distr (*‹⨆ ?X ⋅ ?y = (⨆x∈?X. x ⋅ ?y)›*) Sup_distl (*‹?x ⋅ ⨆ ?Y = ⨆ ((⋅) ?x ` ?Y)›*))[1])
(*discuss goal 10*)
apply ((auto simp: mult_assoc (*‹?a ⋅ ?b ⋅ ?c = ?a ⋅ (?b ⋅ ?c)›*) cod_subid (*‹cod ?x ≤ 1›*) cod_zero (*‹cod ⊥ = ⊥›*) cod_add (*‹cod (?x ⊔ ?y) = cod ?x ⊔ cod ?y›*) cod_local (*‹cod (cod ?x ⋅ ?y) = cod (?x ⋅ ?y)›*) cod_absorb (*‹?x ≤ ?x ⋅ cod ?x›*) Sup_distr (*‹⨆ ?X ⋅ ?y = (⨆x∈?X. x ⋅ ?y)›*) Sup_distl (*‹?x ⋅ ⨆ ?Y = ⨆ ((⋅) ?x ` ?Y)›*))[1])
(*proven 10 subgoals*) .
abbreviation (in codomain_quantale) "bd' ≡ coddual.fd'"
definition (in codomain_quantale) "fb x y = ⨆{cod z |z. bd' x z ≤ cod y}"
lemma (in codomain_quantale) bd'_fb_galois_aux: "bd' x (cod p) ≤ cod q ⟹ cod p ≤ fb x (cod q)"
using local.coddual.bb_def (*‹domain_quantale.bb cod (λx y. y ⋅ x) Sup (≤) ?x ?y = ⨆ {cod z |z. bd' ?x z ≤ cod ?y}›*) local.coddual.fd'_bb_galois_aux (*‹bd' ?x (cod ?p) ≤ cod ?q ⟹ cod ?p ≤ domain_quantale.bb cod (λx y. y ⋅ x) Sup (≤) ?x (cod ?q)›*) local.fb_def (*‹fb (?x::'a::type) (?y::'a::type) = ⨆ {cod z |z::'a::type. bd' ?x z ≤ cod ?y}›*) by auto
subsection ‹Modal quantales›
class dc_modal_quantale = domain_quantale + codomain_quantale +
assumes dc_compat [simp]: "dom (cod x) = cod x"
and cd_compat [simp]: "cod (dom x) = dom x"
sublocale dc_modal_quantale ⊆ mqs: dr_modal_kleene_algebra "(⊔)" "(⋅)" 1 ⊥ "(≤)" "(<)" qstar dom cod
apply unfold_locales
(*goals:
1. ‹⋀x. dom (cod x) = cod x›
2. ‹⋀x. cod (dom x) = dom x›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
sublocale dc_modal_quantale ⊆ mqdual: dc_modal_quantale _ "λx y. y ⋅ x" _ _ _ _ _ _ _ _ dom cod
apply unfold_locales
(*goals:
1. ‹⋀x. x ≤ dom x ⋅ x›
2. ‹⋀x y. dom (y ⋅ dom x) = dom (y ⋅ x)›
3. ‹⋀x y. dom (x ⊔ y) = dom x ⊔ dom y›
4. ‹⋀x. dom x ≤ 1›
5. ‹dom ⊥ = ⊥›
6. ‹⋀x. cod (dom x) = dom x›
7. ‹⋀x. dom (cod x) = cod x›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*proven 7 subgoals*) .
lemma (in dc_modal_quantale) "x ⋅ ⊤ = dom x ⋅ ⊤"
(* nitpick[expect=genuine] *)
oops
lemma (in dc_modal_quantale) "⊤ ⋅ x = ⊤ ⋅ cod x"
(* nitpick[expect=genuine] *)
oops
subsection ‹Antidomain and anticodomain quantales›
notation antidomain_op ("adom")
class antidomain_quantale = unital_quantale + antidomain_op +
assumes as1 [simp]: "adom x ⋅ x = ⊥"
and as2 [simp]: "adom (x ⋅ y) ≤ adom (x ⋅ adom (adom y))"
and as3 [simp]: "adom (adom x) ⊔ adom x = 1"
definition (in antidomain_quantale) "ddom = adom ∘ adom"
sublocale antidomain_quantale ⊆ adqmsr: antidomain_semiring adom "(⊔)" "(⋅)" 1 ⊥ "(≤)" "(<)"
apply unfold_locales
(*goals:
1. ‹⋀x. adom x ⋅ x = ⊥›
2. ‹⋀x y. adom (x ⋅ y) ⊔ adom (x ⋅ adom (adom y)) = adom (x ⋅ adom (adom y))›
3. ‹⋀x. adom (adom x) ⊔ adom x = 1›
discuss goal 1*)
apply (simp add: local.sup.absorb2 (*‹?a ≤ ?b ⟹ ?a ⊔ ?b = ?b›*))
(*discuss goal 2*)
apply (simp add: local.sup.absorb2 (*‹?a ≤ ?b ⟹ ?a ⊔ ?b = ?b›*))
(*discuss goal 3*)
apply (simp add: local.sup.absorb2 (*‹?a ≤ ?b ⟹ ?a ⊔ ?b = ?b›*))
(*proven 3 subgoals*) .
sublocale antidomain_quantale ⊆ adqmka: antidomain_kleene_algebra adom "(⊔)" "(⋅)" 1 ⊥ "(≤)" "(<)" qstarby standard
sublocale antidomain_quantale ⊆ addq: domain_quantale ddom
apply unfold_locales
(*goals:
1. ‹⋀x. x ≤ ddom x ⋅ x›
2. ‹⋀x y. ddom (x ⋅ ddom y) = ddom (x ⋅ y)›
3. ‹⋀x y. ddom (x ⊔ y) = ddom x ⊔ ddom y›
4. ‹⋀x. ddom x ≤ 1›
5. ‹ddom ⊥ = ⊥›
discuss goal 1*)
apply (simp add: ddom_def (*‹ddom = adom ∘ adom›*) local.adqmsr.ans_d_def (*‹antidomain_near_semiring.ans_d adom ?x = adom (adom ?x)›*))
(*discuss goal 2*)
apply (simp add: ddom_def (*‹ddom = adom ∘ adom›*) local.adqmsr.ans_d_def (*‹antidomain_near_semiring.ans_d adom (?x::'a::type) = adom (adom ?x)›*))
(*discuss goal 3*)
apply (simp add: ddom_def (*‹ddom = adom ∘ adom›*) local.adqmsr.ans_d_def (*‹antidomain_near_semiring.ans_d adom ?x = adom (adom ?x)›*))
(*discuss goal 4*)
apply (simp add: ddom_def (*‹ddom = adom ∘ adom›*) local.adqmsr.ans_d_def (*‹antidomain_near_semiring.ans_d adom ?x = adom (adom ?x)›*))
(*discuss goal 5*)
apply (simp add: ddom_def (*‹ddom = adom ∘ adom›*) local.adqmsr.ans_d_def (*‹antidomain_near_semiring.ans_d adom ?x = adom (adom ?x)›*))
(*proven 5 subgoals*) .
notation antirange_op ("acod")
class anticodomain_quantale = unital_quantale + antirange_op +
assumes ars1 [simp]: "x ⋅ acod x = ⊥"
and ars2 [simp]: "acod (x ⋅ y) ≤ acod (acod (acod x) ⋅ y)"
and ars3 [simp]: "acod (acod x) ⊔ acod x = 1"
sublocale anticodomain_quantale ⊆ acoddual: antidomain_quantale acod _ "λx y. y ⋅ x" _ _ _ _ _ _ _ _
by (msorry)
definition (in anticodomain_quantale) "ccod = acod ∘ acod"
sublocale anticodomain_quantale ⊆ acdqmsr: antirange_semiring "(⊔)" "(⋅)" 1 ⊥ acod "(≤)" "(<)"by standard
sublocale anticodomain_quantale ⊆ acdqmka: antirange_kleene_algebra "(⊔)" "(⋅)" 1 ⊥ "(≤)" "(<)" qstar acodby standard
sublocale anticodomain_quantale ⊆ acddq: codomain_quantale _ _ _ _ _ _ _ _ _ _ "λ x. acod (acod x)"
apply unfold_locales
(*goals:
1. ‹⋀x. x ≤ x ⋅ acod (acod x)›
2. ‹⋀x y. acod (acod (acod (acod x) ⋅ y)) = acod (acod (x ⋅ y))›
3. ‹⋀x y. acod (acod (x ⊔ y)) = acod (acod x) ⊔ acod (acod y)›
4. ‹⋀x. acod (acod x) ≤ 1›
5. ‹acod (acod ⊥) = ⊥›
discuss goal 1*)
apply (simp add: local.acoddual.adqmsr.ans_d_def (*‹antidomain_near_semiring.ans_d acod ?x = acod (acod ?x)›*))
(*discuss goal 2*)
apply (simp add: local.acoddual.adqmsr.ans_d_def (*‹antidomain_near_semiring.ans_d acod ?x = acod (acod ?x)›*))
(*discuss goal 3*)
apply (simp add: local.acoddual.adqmsr.ans_d_def (*‹antidomain_near_semiring.ans_d acod ?x = acod (acod ?x)›*))
(*discuss goal 4*)
apply (simp add: local.acoddual.adqmsr.ans_d_def (*‹antidomain_near_semiring.ans_d acod ?x = acod (acod ?x)›*))
(*discuss goal 5*)
apply (simp add: local.acoddual.adqmsr.ans_d_def (*‹antidomain_near_semiring.ans_d acod ?x = acod (acod ?x)›*))
(*proven 5 subgoals*) .
class modal_quantale = antidomain_quantale + anticodomain_quantale
sublocale modal_quantale ⊆ mmqs: modal_kleene_algebra_simp "(⊔)" "(⋅)" 1 ⊥ "(≤)" "(<)" qstar adom acodby standard
sublocale modal_quantale ⊆ mmqdual: modal_quantale _ "λx y. y ⋅ x" _ _ _ _ _ _ _ _ adom acod
apply unfold_locales
(*goals:
1. ‹⋀x::'a. adom x ⋅ x = ⊥›
2. ‹⋀(x::'a) y::'a. adom (y ⋅ x) ≤ adom (y ⋅ adom (adom x))›
3. ‹⋀x::'a. adom (adom x) ⊔ adom x = (1::'a)›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*) .
end
| {
"path": "afp-2025-02-12/thys/Quantales_Converse/Modal_Quantale.thy",
"repo": "afp-2025-02-12",
"sha": "58420d5511b39a0cebe9091a666ecadebe5b90b0500fdfb304210db2dced1330"
} |
(* Title: HOL/HOLCF/IOA/CompoScheds.thy
Author: Olaf Müller
*)
section ‹Compositionality on Schedule level›
theory CompoScheds
imports CompoExecs
begin
definition mkex2 :: "('a, 's) ioa ⇒ ('a, 't) ioa ⇒ 'a Seq →
('a, 's) pairs → ('a, 't) pairs → ('s ⇒ 't ⇒ ('a, 's × 't) pairs)"
where "mkex2 A B =
(fix ⋅
(LAM h sch exA exB.
(λs t.
case sch of
nil ⇒ nil
| x ## xs ⇒
(case x of
UU ⇒ UU
| Def y ⇒
(if y ∈ act A then
(if y ∈ act B then
(case HD ⋅ exA of
UU ⇒ UU
| Def a ⇒
(case HD ⋅ exB of
UU ⇒ UU
| Def b ⇒
(y, (snd a, snd b)) ↝
(h ⋅ xs ⋅ (TL ⋅ exA) ⋅ (TL ⋅ exB)) (snd a) (snd b)))
else
(case HD ⋅ exA of
UU ⇒ UU
| Def a ⇒ (y, (snd a, t)) ↝ (h ⋅ xs ⋅ (TL ⋅ exA) ⋅ exB) (snd a) t))
else
(if y ∈ act B then
(case HD ⋅ exB of
UU ⇒ UU
| Def b ⇒ (y, (s, snd b)) ↝ (h ⋅ xs ⋅ exA ⋅ (TL ⋅ exB)) s (snd b))
else UU))))))"
definition mkex :: "('a, 's) ioa ⇒ ('a, 't) ioa ⇒ 'a Seq ⇒
('a, 's) execution ⇒ ('a, 't) execution ⇒ ('a, 's × 't) execution"
where "mkex A B sch exA exB =
((fst exA, fst exB), (mkex2 A B ⋅ sch ⋅ (snd exA) ⋅ (snd exB)) (fst exA) (fst exB))"
definition par_scheds :: "'a schedule_module ⇒ 'a schedule_module ⇒ 'a schedule_module"
where "par_scheds SchedsA SchedsB =
(let
schA = fst SchedsA; sigA = snd SchedsA;
schB = fst SchedsB; sigB = snd SchedsB
in
({sch. Filter (λa. a∈actions sigA)⋅sch ∈ schA} ∩
{sch. Filter (λa. a∈actions sigB)⋅sch ∈ schB} ∩
{sch. Forall (λx. x∈(actions sigA Un actions sigB)) sch},
asig_comp sigA sigB))"
subsection ‹‹mkex› rewrite rules›
lemma mkex2_unfold:
"mkex2 A B =
(LAM sch exA exB.
(λs t.
case sch of
nil ⇒ nil
| x ## xs ⇒
(case x of
UU ⇒ UU
| Def y ⇒
(if y ∈ act A then
(if y ∈ act B then
(case HD ⋅ exA of
UU ⇒ UU
| Def a ⇒
(case HD ⋅ exB of
UU ⇒ UU
| Def b ⇒
(y, (snd a, snd b)) ↝
(mkex2 A B ⋅ xs ⋅ (TL ⋅ exA) ⋅ (TL ⋅ exB)) (snd a) (snd b)))
else
(case HD ⋅ exA of
UU ⇒ UU
| Def a ⇒ (y, (snd a, t)) ↝ (mkex2 A B ⋅ xs ⋅ (TL ⋅ exA) ⋅ exB) (snd a) t))
else
(if y ∈ act B then
(case HD ⋅ exB of
UU ⇒ UU
| Def b ⇒ (y, (s, snd b)) ↝ (mkex2 A B ⋅ xs ⋅ exA ⋅ (TL ⋅ exB)) s (snd b))
else UU)))))"
apply (rule trans (*‹⟦?r = ?s; ?s = ?t⟧ ⟹ ?r = ?t›*))
(*goals:
1. ‹mkex2 A B = ?s›
2. ‹?s = (Λ sch exA exB. (λs t. case sch of nil ⇒ nil | x ## xs ⇒ case x of ⊥ ⇒ ⊥ | Def y ⇒ if y ∈ act A then if y ∈ act B then case HD⋅exA of ⊥ ⇒ ⊥ | Def a ⇒ case HD⋅exB of ⊥ ⇒ ⊥ | Def b ⇒ (y, snd a, snd b)↝(mkex2 A B⋅xs⋅(TL⋅exA)⋅(TL⋅exB)) (snd a) (snd b) else case HD⋅exA of ⊥ ⇒ ⊥ | Def a ⇒ (y, snd a, t)↝(mkex2 A B⋅xs⋅(TL⋅exA)⋅exB) (snd a) t else if y ∈ act B then case HD⋅exB of ⊥ ⇒ ⊥ | Def b ⇒ (y, s, snd b)↝(mkex2 A B⋅xs⋅exA⋅(TL⋅exB)) s (snd b) else ⊥))›
discuss goal 1*)
apply (rule fix_eq2 (*‹?f ≡ fix⋅?F ⟹ ?f = ?F⋅?f›*))
(*top goal: ‹mkex2 A B = ?s› and 1 goal remains*)
apply (simp only: mkex2_def (*‹mkex2 ?A ?B = (μ h. Λ sch exA exB. (λs t. case sch of nil ⇒ nil | x ## xs ⇒ case x of ⊥ ⇒ ⊥ | Def y ⇒ if y ∈ act ?A then if y ∈ act ?B then case HD⋅exA of ⊥ ⇒ ⊥ | Def a ⇒ case HD⋅exB of ⊥ ⇒ ⊥ | Def b ⇒ (y, snd a, snd b)↝(h⋅xs⋅(TL⋅exA)⋅(TL⋅exB)) (snd a) (snd b) else case HD⋅exA of ⊥ ⇒ ⊥ | Def a ⇒ (y, snd a, t)↝(h⋅xs⋅(TL⋅exA)⋅exB) (snd a) t else if y ∈ act ?B then case HD⋅exB of ⊥ ⇒ ⊥ | Def b ⇒ (y, s, snd b)↝(h⋅xs⋅exA⋅(TL⋅exB)) s (snd b) else ⊥))›*))
(*discuss goal 2*)
apply (rule beta_cfun (*‹cont ?f ⟹ (Λ x. ?f x)⋅?u = ?f ?u›*))
(*goal: ‹(Λ h sch exA exB. (λs t. case sch of nil ⇒ nil | x ## xs ⇒ case x of ⊥ ⇒ ⊥ | Def y ⇒ if y ∈ act A then if y ∈ act B then case HD⋅exA of ⊥ ⇒ ⊥ | Def a ⇒ case HD⋅exB of ⊥ ⇒ ⊥ | Def b ⇒ (y, snd a, snd b)↝(h⋅xs⋅(TL⋅exA)⋅(TL⋅exB)) (snd a) (snd b) else case HD⋅exA of ⊥ ⇒ ⊥ | Def a ⇒ (y, snd a, t)↝(h⋅xs⋅(TL⋅exA)⋅exB) (snd a) t else if y ∈ act B then case HD⋅exB of ⊥ ⇒ ⊥ | Def b ⇒ (y, s, snd b)↝(h⋅xs⋅exA⋅(TL⋅exB)) s (snd b) else ⊥))⋅(mkex2 A B) = (Λ sch exA exB. (λs t. case sch of nil ⇒ nil | x ## xs ⇒ case x of ⊥ ⇒ ⊥ | Def y ⇒ if y ∈ act A then if y ∈ act B then case HD⋅exA of ⊥ ⇒ ⊥ | Def a ⇒ case HD⋅exB of ⊥ ⇒ ⊥ | Def b ⇒ (y, snd a, snd b)↝(mkex2 A B⋅xs⋅(TL⋅exA)⋅(TL⋅exB)) (snd a) (snd b) else case HD⋅exA of ⊥ ⇒ ⊥ | Def a ⇒ (y, snd a, t)↝(mkex2 A B⋅xs⋅(TL⋅exA)⋅exB) (snd a) t else if y ∈ act B then case HD⋅exB of ⊥ ⇒ ⊥ | Def b ⇒ (y, s, snd b)↝(mkex2 A B⋅xs⋅exA⋅(TL⋅exB)) s (snd b) else ⊥))›*)
apply simp
(*proven 2 subgoals*) .
lemma mkex2_UU: "(mkex2 A B ⋅ UU ⋅ exA ⋅ exB) s t = UU"
apply (subst mkex2_unfold (*‹mkex2 ?A ?B = (Λ sch exA exB. (λs t. case sch of nil ⇒ nil | x ## xs ⇒ case x of ⊥ ⇒ ⊥ | Def y ⇒ if y ∈ act ?A then if y ∈ act ?B then case HD⋅exA of ⊥ ⇒ ⊥ | Def a ⇒ case HD⋅exB of ⊥ ⇒ ⊥ | Def b ⇒ (y, snd a, snd b)↝(mkex2 ?A ?B⋅xs⋅(TL⋅exA)⋅(TL⋅exB)) (snd a) (snd b) else case HD⋅exA of ⊥ ⇒ ⊥ | Def a ⇒ (y, snd a, t)↝(mkex2 ?A ?B⋅xs⋅(TL⋅exA)⋅exB) (snd a) t else if y ∈ act ?B then case HD⋅exB of ⊥ ⇒ ⊥ | Def b ⇒ (y, s, snd b)↝(mkex2 ?A ?B⋅xs⋅exA⋅(TL⋅exB)) s (snd b) else ⊥))›*))
(*goal: ‹(mkex2 A B⋅⊥⋅exA⋅exB) s t = ⊥›*)
by simp
lemma mkex2_nil: "(mkex2 A B ⋅ nil ⋅ exA ⋅ exB) s t = nil"
apply (subst mkex2_unfold (*‹mkex2 (?A::(?'a set × ?'a set × ?'a set) × ?'b set × (?'b × ?'a × ?'b) set × ?'a set set × ?'a set set) (?B::(?'a set × ?'a set × ?'a set) × ?'c set × (?'c × ?'a × ?'c) set × ?'a set set × ?'a set set) = (Λ (sch::?'a lift seq) (exA::(?'a × ?'b) lift seq) (exB::(?'a × ?'c) lift seq). (λ(s::?'b) t::?'c. case sch of nil ⇒ nil | (x::?'a lift) ## (xs::?'a lift seq) ⇒ case x of ⊥ ⇒ ⊥ | Def (y::?'a) ⇒ if y ∈ act ?A then if y ∈ act ?B then case HD⋅exA of ⊥ ⇒ ⊥ | Def (a::?'a × ?'b) ⇒ case HD⋅exB of ⊥ ⇒ ⊥ | Def (b::?'a × ?'c) ⇒ (y, snd a, snd b)↝(mkex2 ?A ?B⋅xs⋅(TL⋅exA)⋅(TL⋅exB)) (snd a) (snd b) else case HD⋅exA of ⊥ ⇒ ⊥ | Def (a::?'a × ?'b) ⇒ (y, snd a, t)↝(mkex2 ?A ?B⋅xs⋅(TL⋅exA)⋅exB) (snd a) t else if y ∈ act ?B then case HD⋅exB of ⊥ ⇒ ⊥ | Def (b::?'a × ?'c) ⇒ (y, s, snd b)↝(mkex2 ?A ?B⋅xs⋅exA⋅(TL⋅exB)) s (snd b) else ⊥))›*))
(*goal: ‹(mkex2 (A::('a set × 'a set × 'a set) × 'b set × ('b × 'a × 'b) set × 'a set set × 'a set set) (B::('a set × 'a set × 'a set) × 'c set × ('c × 'a × 'c) set × 'a set set × 'a set set)⋅nil⋅(exA::('a × 'b) lift seq)⋅(exB::('a × 'c) lift seq)) (s::'b) (t::'c) = nil›*)
by simp
lemma mkex2_cons_1:
"x ∈ act A ⟹ x ∉ act B ⟹ HD ⋅ exA = Def a ⟹
(mkex2 A B ⋅ (x ↝ sch) ⋅ exA ⋅ exB) s t =
(x, snd a,t) ↝ (mkex2 A B ⋅ sch ⋅ (TL ⋅ exA) ⋅ exB) (snd a) t"
apply (rule trans (*‹⟦(?r::?'a::type) = (?s::?'a::type); ?s = (?t::?'a::type)⟧ ⟹ ?r = ?t›*))
(*goals:
1. ‹⟦x ∈ act A; x ∉ act B; HD⋅exA = Def a⟧ ⟹ (mkex2 A B⋅(x↝sch)⋅exA⋅exB) s t = ?s›
2. ‹⟦x ∈ act A; x ∉ act B; HD⋅exA = Def a⟧ ⟹ ?s = (x, snd a, t)↝(mkex2 A B⋅sch⋅(TL⋅exA)⋅exB) (snd a) t›
discuss goal 1*)
apply (subst mkex2_unfold (*‹mkex2 ?A ?B = (Λ sch exA exB. (λs t. case sch of nil ⇒ nil | x ## xs ⇒ case x of ⊥ ⇒ ⊥ | Def y ⇒ if y ∈ act ?A then if y ∈ act ?B then case HD⋅exA of ⊥ ⇒ ⊥ | Def a ⇒ case HD⋅exB of ⊥ ⇒ ⊥ | Def b ⇒ (y, snd a, snd b)↝(mkex2 ?A ?B⋅xs⋅(TL⋅exA)⋅(TL⋅exB)) (snd a) (snd b) else case HD⋅exA of ⊥ ⇒ ⊥ | Def a ⇒ (y, snd a, t)↝(mkex2 ?A ?B⋅xs⋅(TL⋅exA)⋅exB) (snd a) t else if y ∈ act ?B then case HD⋅exB of ⊥ ⇒ ⊥ | Def b ⇒ (y, s, snd b)↝(mkex2 ?A ?B⋅xs⋅exA⋅(TL⋅exB)) s (snd b) else ⊥))›*))
(*top goal: ‹⟦(x::'a::type) ∈ act (A::('a::type set × 'a::type set × 'a::type set) × 'b::type set × ('b::type × 'a::type × 'b::type) set × 'a::type set set × 'a::type set set); x ∉ act (B::('a::type set × 'a::type set × 'a::type set) × 'c::type set × ('c::type × 'a::type × 'c::type) set × 'a::type set set × 'a::type set set); HD⋅(exA::('a::type × 'b::type) lift seq) = Def (a::'a::type × 'b::type)⟧ ⟹ (mkex2 A B⋅(x↝(sch::'a::type lift seq))⋅exA⋅(exB::('a::type × 'c::type) lift seq)) (s::'b::type) (t::'c::type) = (?s::('a::type × 'b::type × 'c::type) lift seq)› and 1 goal remains*)
apply (simp add: Consq_def (*‹Consq ?a = (Λ s. Def ?a ## s)›*) If_and_if (*‹If Def ?P then ?A else ?B = (if ?P then ?A else ?B)›*))
(*discuss goal 2*)
apply (simp add: Consq_def (*‹Consq ?a = (Λ s. Def ?a ## s)›*))
(*proven 2 subgoals*) .
lemma mkex2_cons_2:
"x ∉ act A ⟹ x ∈ act B ⟹ HD ⋅ exB = Def b ⟹
(mkex2 A B ⋅ (x ↝ sch) ⋅ exA ⋅ exB) s t =
(x, s, snd b) ↝ (mkex2 A B ⋅ sch ⋅ exA ⋅ (TL ⋅ exB)) s (snd b)"
apply (rule trans (*‹⟦(?r::?'a::type) = (?s::?'a::type); ?s = (?t::?'a::type)⟧ ⟹ ?r = ?t›*))
(*goals:
1. ‹⟦x ∉ act A; x ∈ act B; HD⋅exB = Def b⟧ ⟹ (mkex2 A B⋅(x↝sch)⋅exA⋅exB) s t = ?s›
2. ‹⟦x ∉ act A; x ∈ act B; HD⋅exB = Def b⟧ ⟹ ?s = (x, s, snd b)↝(mkex2 A B⋅sch⋅exA⋅(TL⋅exB)) s (snd b)›
discuss goal 1*)
apply (subst mkex2_unfold (*‹mkex2 ?A ?B = (Λ sch exA exB. (λs t. case sch of nil ⇒ nil | x ## xs ⇒ case x of ⊥ ⇒ ⊥ | Def y ⇒ if y ∈ act ?A then if y ∈ act ?B then case HD⋅exA of ⊥ ⇒ ⊥ | Def a ⇒ case HD⋅exB of ⊥ ⇒ ⊥ | Def b ⇒ (y, snd a, snd b)↝(mkex2 ?A ?B⋅xs⋅(TL⋅exA)⋅(TL⋅exB)) (snd a) (snd b) else case HD⋅exA of ⊥ ⇒ ⊥ | Def a ⇒ (y, snd a, t)↝(mkex2 ?A ?B⋅xs⋅(TL⋅exA)⋅exB) (snd a) t else if y ∈ act ?B then case HD⋅exB of ⊥ ⇒ ⊥ | Def b ⇒ (y, s, snd b)↝(mkex2 ?A ?B⋅xs⋅exA⋅(TL⋅exB)) s (snd b) else ⊥))›*))
(*top goal: ‹⟦x ∉ act A; x ∈ act B; HD⋅exB = Def b⟧ ⟹ (mkex2 A B⋅(x↝sch)⋅exA⋅exB) s t = ?s› and 1 goal remains*)
apply (simp add: Consq_def (*‹Consq ?a = (Λ s. Def ?a ## s)›*) If_and_if (*‹If Def ?P then ?A else ?B = (if ?P then ?A else ?B)›*))
(*discuss goal 2*)
apply (simp add: Consq_def (*‹Consq ?a = (Λ s. Def ?a ## s)›*))
(*proven 2 subgoals*) .
lemma mkex2_cons_3:
"x ∈ act A ⟹ x ∈ act B ⟹ HD ⋅ exA = Def a ⟹ HD ⋅ exB = Def b ⟹
(mkex2 A B ⋅ (x ↝ sch) ⋅ exA ⋅ exB) s t =
(x, snd a,snd b) ↝ (mkex2 A B ⋅ sch ⋅ (TL ⋅ exA) ⋅ (TL ⋅ exB)) (snd a) (snd b)"
apply (rule trans (*‹⟦?r = ?s; ?s = ?t⟧ ⟹ ?r = ?t›*))
(*goals:
1. ‹⟦x ∈ act A; x ∈ act B; HD⋅exA = Def a; HD⋅exB = Def b⟧ ⟹ (mkex2 A B⋅(x↝sch)⋅exA⋅exB) s t = ?s›
2. ‹⟦x ∈ act A; x ∈ act B; HD⋅exA = Def a; HD⋅exB = Def b⟧ ⟹ ?s = (x, snd a, snd b)↝(mkex2 A B⋅sch⋅(TL⋅exA)⋅(TL⋅exB)) (snd a) (snd b)›
discuss goal 1*)
apply (subst mkex2_unfold (*‹mkex2 (?A::(?'a::type set × ?'a::type set × ?'a::type set) × ?'b::type set × (?'b::type × ?'a::type × ?'b::type) set × ?'a::type set set × ?'a::type set set) (?B::(?'a::type set × ?'a::type set × ?'a::type set) × ?'c::type set × (?'c::type × ?'a::type × ?'c::type) set × ?'a::type set set × ?'a::type set set) = (Λ (sch::?'a::type lift seq) (exA::(?'a::type × ?'b::type) lift seq) (exB::(?'a::type × ?'c::type) lift seq). (λ(s::?'b::type) t::?'c::type. case sch of nil ⇒ nil | (x::?'a::type lift) ## (xs::?'a::type lift seq) ⇒ case x of ⊥ ⇒ ⊥ | Def (y::?'a::type) ⇒ if y ∈ act ?A then if y ∈ act ?B then case HD⋅exA of ⊥ ⇒ ⊥ | Def (a::?'a::type × ?'b::type) ⇒ case HD⋅exB of ⊥ ⇒ ⊥ | Def (b::?'a::type × ?'c::type) ⇒ (y, snd a, snd b)↝(mkex2 ?A ?B⋅xs⋅(TL⋅exA)⋅(TL⋅exB)) (snd a) (snd b) else case HD⋅exA of ⊥ ⇒ ⊥ | Def (a::?'a::type × ?'b::type) ⇒ (y, snd a, t)↝(mkex2 ?A ?B⋅xs⋅(TL⋅exA)⋅exB) (snd a) t else if y ∈ act ?B then case HD⋅exB of ⊥ ⇒ ⊥ | Def (b::?'a::type × ?'c::type) ⇒ (y, s, snd b)↝(mkex2 ?A ?B⋅xs⋅exA⋅(TL⋅exB)) s (snd b) else ⊥))›*))
(*top goal: ‹⟦x ∈ act A; x ∈ act B; HD⋅exA = Def a; HD⋅exB = Def b⟧ ⟹ (mkex2 A B⋅(x↝sch)⋅exA⋅exB) s t = ?s› and 1 goal remains*)
apply (simp add: Consq_def (*‹Consq ?a = (Λ s. Def ?a ## s)›*) If_and_if (*‹If Def ?P then ?A else ?B = (if ?P then ?A else ?B)›*))
(*discuss goal 2*)
apply (simp add: Consq_def (*‹Consq (?a::?'a) = (Λ (s::?'a lift seq). Def ?a ## s)›*))
(*proven 2 subgoals*) .
declare mkex2_UU [simp] mkex2_nil [simp] mkex2_cons_1 [simp]
mkex2_cons_2 [simp] mkex2_cons_3 [simp]
subsection ‹‹mkex››
lemma mkex_UU: "mkex A B UU (s,exA) (t,exB) = ((s,t),UU)"
by (simp add: mkex_def (*‹mkex ?A ?B ?sch ?exA ?exB = ((fst ?exA, fst ?exB), (mkex2 ?A ?B⋅?sch⋅(snd ?exA)⋅(snd ?exB)) (fst ?exA) (fst ?exB))›*))
lemma mkex_nil: "mkex A B nil (s,exA) (t,exB) = ((s,t),nil)"
by (simp add: mkex_def (*‹mkex ?A ?B ?sch ?exA ?exB = ((fst ?exA, fst ?exB), (mkex2 ?A ?B⋅?sch⋅(snd ?exA)⋅(snd ?exB)) (fst ?exA) (fst ?exB))›*))
lemma mkex_cons_1:
"x ∈ act A ⟹ x ∉ act B ⟹
mkex A B (x ↝ sch) (s, a ↝ exA) (t, exB) =
((s, t), (x, snd a, t) ↝ snd (mkex A B sch (snd a, exA) (t, exB)))"
apply (unfold mkex_def (*‹mkex ?A ?B ?sch ?exA ?exB = ((fst ?exA, fst ?exB), (mkex2 ?A ?B⋅?sch⋅(snd ?exA)⋅(snd ?exB)) (fst ?exA) (fst ?exB))›*))
(*goal: ‹⟦x ∈ act A; x ∉ act B⟧ ⟹ mkex A B (x↝sch) (s, a↝exA) (t, exB) = ((s, t), (x, snd a, t)↝snd (mkex A B sch (snd a, exA) (t, exB)))›*)
apply (cut_tac exA = "a ↝ exA" in mkex2_cons_1 (*‹⟦?x ∈ act ?A; ?x ∉ act ?B; HD⋅?exA = Def ?a⟧ ⟹ (mkex2 ?A ?B⋅(?x↝?sch)⋅?exA⋅?exB) ?s ?t = (?x, snd ?a, ?t)↝(mkex2 ?A ?B⋅?sch⋅(TL⋅?exA)⋅?exB) (snd ?a) ?t›*))
(*goals:
1. ‹⟦x ∈ act A; x ∉ act B⟧ ⟹ ?x ∈ act ?A›
2. ‹⟦x ∈ act A; x ∉ act B⟧ ⟹ ?x ∉ act ?B›
3. ‹⟦x ∈ act A; x ∉ act B⟧ ⟹ HD⋅(a↝exA) = Def ?a›
4. ‹⟦x ∈ act A; x ∉ act B; (mkex2 ?A ?B⋅(?x↝?sch)⋅(a↝exA)⋅?exB) ?s ?t = (?x, snd ?a, ?t)↝(mkex2 ?A ?B⋅?sch⋅(TL⋅(a↝exA))⋅?exB) (snd ?a) ?t⟧ ⟹ ((fst (s, a↝exA), fst (t, exB)), (mkex2 A B⋅(x↝sch)⋅(snd (s, a↝exA))⋅(snd (t, exB))) (fst (s, a↝exA)) (fst (t, exB))) = ((s, t), (x, snd a, t)↝snd ((fst (snd a, exA), fst (t, exB)), (mkex2 A B⋅sch⋅(snd (snd a, exA))⋅(snd (t, exB))) (fst (snd a, exA)) (fst (t, exB))))›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*proven 4 subgoals*) .
lemma mkex_cons_2:
"x ∉ act A ⟹ x ∈ act B ⟹
mkex A B (x ↝ sch) (s, exA) (t, b ↝ exB) =
((s, t), (x, s, snd b) ↝ snd (mkex A B sch (s, exA) (snd b, exB)))"
apply (unfold mkex_def (*‹mkex ?A ?B ?sch ?exA ?exB = ((fst ?exA, fst ?exB), (mkex2 ?A ?B⋅?sch⋅(snd ?exA)⋅(snd ?exB)) (fst ?exA) (fst ?exB))›*))
(*goal: ‹⟦x ∉ act A; x ∈ act B⟧ ⟹ mkex A B (x↝sch) (s, exA) (t, b↝exB) = ((s, t), (x, s, snd b)↝snd (mkex A B sch (s, exA) (snd b, exB)))›*)
apply (cut_tac exB = "b↝exB" in mkex2_cons_2 (*‹⟦?x ∉ act ?A; ?x ∈ act ?B; HD⋅?exB = Def ?b⟧ ⟹ (mkex2 ?A ?B⋅(?x↝?sch)⋅?exA⋅?exB) ?s ?t = (?x, ?s, snd ?b)↝(mkex2 ?A ?B⋅?sch⋅?exA⋅(TL⋅?exB)) ?s (snd ?b)›*))
(*goals:
1. ‹⟦x ∉ act A; x ∈ act B⟧ ⟹ ?x ∉ act ?A›
2. ‹⟦x ∉ act A; x ∈ act B⟧ ⟹ ?x ∈ act ?B›
3. ‹⟦x ∉ act A; x ∈ act B⟧ ⟹ HD⋅(b↝exB) = Def ?b›
4. ‹⟦x ∉ act A; x ∈ act B; (mkex2 ?A ?B⋅(?x↝?sch)⋅?exA⋅(b↝exB)) ?s ?t = (?x, ?s, snd ?b)↝(mkex2 ?A ?B⋅?sch⋅?exA⋅(TL⋅(b↝exB))) ?s (snd ?b)⟧ ⟹ ((fst (s, exA), fst (t, b↝exB)), (mkex2 A B⋅(x↝sch)⋅(snd (s, exA))⋅(snd (t, b↝exB))) (fst (s, exA)) (fst (t, b↝exB))) = ((s, t), (x, s, snd b)↝snd ((fst (s, exA), fst (snd b, exB)), (mkex2 A B⋅sch⋅(snd (s, exA))⋅(snd (snd b, exB))) (fst (s, exA)) (fst (snd b, exB))))›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*proven 4 subgoals*) .
lemma mkex_cons_3:
"x ∈ act A ⟹ x ∈ act B ⟹
mkex A B (x ↝ sch) (s, a ↝ exA) (t, b ↝ exB) =
((s, t), (x, snd a, snd b) ↝ snd (mkex A B sch (snd a, exA) (snd b, exB)))"
apply (unfold mkex_def (*‹mkex ?A ?B ?sch ?exA ?exB = ((fst ?exA, fst ?exB), (mkex2 ?A ?B⋅?sch⋅(snd ?exA)⋅(snd ?exB)) (fst ?exA) (fst ?exB))›*))
(*goal: ‹⟦x ∈ act A; x ∈ act B⟧ ⟹ mkex A B (x↝sch) (s, a↝exA) (t, b↝exB) = ((s, t), (x, snd a, snd b)↝snd (mkex A B sch (snd a, exA) (snd b, exB)))›*)
apply (cut_tac exB = "b↝exB" and exA = "a↝exA" in mkex2_cons_3 (*‹⟦?x ∈ act ?A; ?x ∈ act ?B; HD⋅?exA = Def ?a; HD⋅?exB = Def ?b⟧ ⟹ (mkex2 ?A ?B⋅(?x↝?sch)⋅?exA⋅?exB) ?s ?t = (?x, snd ?a, snd ?b)↝(mkex2 ?A ?B⋅?sch⋅(TL⋅?exA)⋅(TL⋅?exB)) (snd ?a) (snd ?b)›*))
(*goals:
1. ‹⟦x ∈ act A; x ∈ act B⟧ ⟹ ?x ∈ act ?A›
2. ‹⟦x ∈ act A; x ∈ act B⟧ ⟹ ?x ∈ act ?B›
3. ‹⟦x ∈ act A; x ∈ act B⟧ ⟹ HD⋅(a↝exA) = Def ?a›
4. ‹⟦x ∈ act A; x ∈ act B⟧ ⟹ HD⋅(b↝exB) = Def ?b›
5. ‹⟦x ∈ act A; x ∈ act B; (mkex2 ?A ?B⋅(?x↝?sch)⋅(a↝exA)⋅(b↝exB)) ?s ?t = (?x, snd ?a, snd ?b)↝(mkex2 ?A ?B⋅?sch⋅(TL⋅(a↝exA))⋅(TL⋅(b↝exB))) (snd ?a) (snd ?b)⟧ ⟹ ((fst (s, a↝exA), fst (t, b↝exB)), (mkex2 A B⋅(x↝sch)⋅(snd (s, a↝exA))⋅(snd (t, b↝exB))) (fst (s, a↝exA)) (fst (t, b↝exB))) = ((s, t), (x, snd a, snd b)↝snd ((fst (snd a, exA), fst (snd b, exB)), (mkex2 A B⋅sch⋅(snd (snd a, exA))⋅(snd (snd b, exB))) (fst (snd a, exA)) (fst (snd b, exB))))›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .
declare mkex2_UU [simp del] mkex2_nil [simp del]
mkex2_cons_1 [simp del] mkex2_cons_2 [simp del] mkex2_cons_3 [simp del]
lemmas composch_simps = mkex_UU mkex_nil mkex_cons_1 mkex_cons_2 mkex_cons_3
declare composch_simps [simp]
subsection ‹Compositionality on schedule level›
subsubsection ‹Lemmas for ‹⟹››
lemma lemma_2_1a:
― ‹‹tfilter ex› and ‹filter_act› are commutative›
"filter_act ⋅ (Filter_ex2 (asig_of A) ⋅ xs) =
Filter (λa. a ∈ act A) ⋅ (filter_act ⋅ xs)"
apply (unfold filter_act_def (*‹filter_act = Map fst›*) Filter_ex2_def (*‹Filter_ex2 (?sig::?'a set × ?'a set × ?'a set) = Filter (λx::?'a × ?'s. fst x ∈ actions ?sig)›*))
(*goal: ‹filter_act⋅(Filter_ex2 (asig_of (A::('a set × 'a set × 'a set) × 'c set × ('c × 'a × 'c) set × 'a set set × 'a set set))⋅(xs::('a × 'b) lift seq)) = Filter (λa::'a. a ∈ act A)⋅(filter_act⋅xs)›*)
by (simp add: MapFilter (*‹Filter ?P⋅(Map ?f⋅?x) = Map ?f⋅(Filter (?P ∘ ?f)⋅?x)›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*))
lemma lemma_2_1b:
― ‹State-projections do not affect ‹filter_act››
"filter_act ⋅ (ProjA2 ⋅ xs) = filter_act ⋅ xs ∧
filter_act ⋅ (ProjB2 ⋅ xs) = filter_act ⋅ xs"
by (pair_induct xs)
text ‹
Schedules of ‹A ∥ B› have only ‹A›- or ‹B›-actions.
Very similar to ‹lemma_1_1c›, but it is not checking if every action element
of an ‹ex› is in ‹A› or ‹B›, but after projecting it onto the action
schedule. Of course, this is the same proposition, but we cannot change this
one, when then rather ‹lemma_1_1c›.
›
lemma sch_actions_in_AorB:
"∀s. is_exec_frag (A ∥ B) (s, xs) ⟶ Forall (λx. x ∈ act (A ∥ B)) (filter_act ⋅ xs)"
apply (pair_induct xs simp: is_exec_frag_def Forall_def sforall_def)
(*goal: ‹∀s. is_exec_frag (A ∥ B) (s, xs) ⟶ Forall (λx. x ∈ act (A ∥ B)) (filter_act⋅xs)›*)
text ‹main case›
apply auto
(*goal: ‹⋀s x1 x2. ∀sa. is_exec_frag (A ∥ B) (sa, s) ⟶ Forall (λx. x ∈ act (A ∥ B)) (filter_act⋅s) ⟹ ∀sa. sa ─x1─(A ∥ B)→ x2 ∧ is_exec_frag (A ∥ B) (x2, s) ⟶ x1 ∈ act (A ∥ B) ∧ Forall (λx. x ∈ act (A ∥ B)) (filter_act⋅s)›*)
by (simp add: trans_of_defs2 (*‹⟦?s ─?a─(?A ∥ ?B)→ ?t; ?a ∈ act ?A⟧ ⟹ fst ?s ─?a─?A→ fst ?t› ‹⟦?s ─?a─(?A ∥ ?B)→ ?t; ?a ∈ act ?B⟧ ⟹ snd ?s ─?a─?B→ snd ?t› ‹⟦?s ─?a─(?A ∥ ?B)→ ?t; ?a ∉ act ?A⟧ ⟹ fst ?s = fst ?t› ‹⟦?s ─?a─(?A ∥ ?B)→ ?t; ?a ∉ act ?B⟧ ⟹ snd ?s = snd ?t› ‹?s ─?a─(?A ∥ ?B)→ ?t ⟹ ?a ∈ act ?A ∨ ?a ∈ act ?B›*) actions_asig_comp (*‹actions (asig_comp ?a ?b) = actions ?a ∪ actions ?b›*) asig_of_par (*‹asig_of (?A ∥ ?B) = asig_comp (asig_of ?A) (asig_of ?B)›*))
subsubsection ‹Lemmas for ‹⟸››
text ‹
Filtering actions out of ‹mkex (sch, exA, exB)› yields the oracle ‹sch›
structural induction.
›
lemma Mapfst_mkex_is_sch:
"∀exA exB s t.
Forall (λx. x ∈ act (A ∥ B)) sch ∧
Filter (λa. a ∈ act A) ⋅ sch ⊑ filter_act ⋅ exA ∧
Filter (λa. a ∈ act B) ⋅ sch ⊑ filter_act ⋅ exB ⟶
filter_act ⋅ (snd (mkex A B sch (s, exA) (t, exB))) = sch"
apply (Seq_induct sch simp: Filter_def Forall_def sforall_def mkex_def)
(*goal: ‹∀exA exB s t. Forall (λx. x ∈ act (A ∥ B)) sch ∧ Filter (λa. a ∈ act A)⋅sch ⊑ filter_act⋅exA ∧ Filter (λa. a ∈ act B)⋅sch ⊑ filter_act⋅exB ⟶ filter_act⋅(snd (mkex A B sch (s, exA) (t, exB))) = sch›*)
text ‹main case: splitting into 4 cases according to ‹a ∈ A›, ‹a ∈ B››
apply auto
(*goal: ‹⋀a s. ∀exA exB sa t. Forall (λx. x ∈ act (A ∥ B)) s ∧ Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅exA ∧ Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB ⟶ filter_act⋅(snd (mkex A B s (sa, exA) (t, exB))) = s ⟹ (a ∈ act A ⟶ (a ∈ act B ⟶ (∀exA exB sa t. a ∈ act (A ∥ B) ∧ Forall (λx. x ∈ act (A ∥ B)) s ∧ a↝Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅exA ∧ a↝Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB ⟶ filter_act⋅(snd (mkex A B (a↝s) (sa, exA) (t, exB))) = a↝s)) ∧ (a ∉ act B ⟶ (∀exA exB sa t. a ∈ act (A ∥ B) ∧ Forall (λx. x ∈ act (A ∥ B)) s ∧ a↝Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅exA ∧ Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB ⟶ filter_act⋅(snd (mkex A B (a↝s) (sa, exA) (t, exB))) = a↝s))) ∧ (a ∉ act A ⟶ (a ∈ act B ⟶ (∀exA exB sa t. a ∈ act (A ∥ B) ∧ Forall (λx. x ∈ act (A ∥ B)) s ∧ Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅exA ∧ a↝Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB ⟶ filter_act⋅(snd (mkex A B (a↝s) (sa, exA) (t, exB))) = a↝s)) ∧ (a ∉ act B ⟶ (∀exA exB sa t. a ∈ act (A ∥ B) ∧ Forall (λx. x ∈ act (A ∥ B)) s ∧ Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅exA ∧ Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB ⟶ filter_act⋅(snd (mkex A B (a↝s) (sa, exA) (t, exB))) = a↝s)))›*)
text ‹Case ‹y ∈ A›, ‹y ∈ B››
apply (Seq_case_simp exA)
(*top goal: ‹⋀a s exA exB sa t. ⟦∀exA exB sa t. Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅exA ∧ Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB ⟶ filter_act⋅(snd (mkex A B s (sa, exA) (t, exB))) = s; a ∈ act A; a ∈ act B; a ∈ act (A ∥ B); Forall (λx. x ∈ act (A ∥ B)) s; a↝Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅exA; a↝Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB⟧ ⟹ filter_act⋅(snd (mkex A B (a↝s) (sa, exA) (t, exB))) = a↝s› and 3 goals remain*)
text ‹Case ‹exA = UU›, Case ‹exA = nil››
text ‹
These ‹UU› and ‹nil› cases are the only places where the assumption
‹filter A sch ⊑ f_act exA› is used!
‹⟶› to generate a contradiction using ‹¬ a ↝ ss ⊑ UU nil›,
using theorems ‹Cons_not_less_UU› and ‹Cons_not_less_nil›.›
apply (Seq_case_simp exB)
(*top goal: ‹⋀a s exB sa t aa sb. ⟦∀exA exB sa t. Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅exA ∧ Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB ⟶ filter_act⋅(snd (mkex A B s (sa, exA) (t, exB))) = s; a ∈ act A; a ∈ act B; a ∈ act (A ∥ B); Forall (λx. x ∈ act (A ∥ B)) s; a↝Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅(aa↝sb); a↝Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB⟧ ⟹ filter_act⋅(snd (mkex A B (a↝s) (sa, aa↝sb) (t, exB))) = a↝s› and 3 goals remain*)
text ‹Case ‹exA = a ↝ x›, ‹exB = b ↝ y››
text ‹
Here it is important that @{method Seq_case_simp} uses no ‹!full!_simp_tac›
for the cons case, as otherwise ‹mkex_cons_3› would not be rewritten
without use of ‹rotate_tac›: then tactic would not be generally
applicable.›
apply simp
(*top goal: ‹⋀a s aa sb ab sc. ⟦∀exA exB sa t. Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅exA ∧ Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB ⟶ filter_act⋅(snd (mkex A B s (sa, exA) (t, exB))) = s; a ∈ act A; a ∈ act B; a ∈ act (A ∥ B); Forall (λx. x ∈ act (A ∥ B)) s; a↝Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅(aa↝sb); a↝Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅(ab↝sc)⟧ ⟹ filter_act⋅(snd (mkex A B s (snd aa, sb) (snd ab, sc))) = s› and 3 goals remain*)
text ‹Case ‹y ∈ A›, ‹y ∉ B››
apply (Seq_case_simp exA)
(*top goal: ‹⋀(a::'a) (s::'a lift seq) (exA::('a × 'b) lift seq) (exB::('a × 'c) lift seq) (sa::'b) t::'c. ⟦∀(exA::('a × 'b) lift seq) (exB::('a × 'c) lift seq) (sa::'b) t::'c. Filter (λa::'a. a ∈ act (A::('a set × 'a set × 'a set) × 'b set × ('b × 'a × 'b) set × 'a set set × 'a set set))⋅s ⊑ filter_act⋅exA ∧ Filter (λa::'a. a ∈ act (B::('a set × 'a set × 'a set) × 'c set × ('c × 'a × 'c) set × 'a set set × 'a set set))⋅s ⊑ filter_act⋅exB ⟶ filter_act⋅(snd (mkex A B s (sa, exA) (t, exB))) = s; a ∈ act A; a ∉ act B; a ∈ act (A ∥ B); Forall (λx::'a. x ∈ act (A ∥ B)) s; a↝Filter (λa::'a. a ∈ act A)⋅s ⊑ filter_act⋅exA; Filter (λa::'a. a ∈ act B)⋅s ⊑ filter_act⋅exB⟧ ⟹ filter_act⋅(snd (mkex A B (a↝s) (sa, exA) (t, exB))) = a↝s› and 2 goals remain*)
apply simp
(*top goal: ‹⋀a s exB t aa sb. ⟦∀exA exB sa t. Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅exA ∧ Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB ⟶ filter_act⋅(snd (mkex A B s (sa, exA) (t, exB))) = s; a ∈ act A; a ∉ act B; a ∈ act (A ∥ B); Forall (λx. x ∈ act (A ∥ B)) s; a↝Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅(aa↝sb); Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB⟧ ⟹ filter_act⋅(snd (mkex A B s (snd aa, sb) (t, exB))) = s› and 2 goals remain*)
text ‹Case ‹y ∉ A›, ‹y ∈ B››
apply (Seq_case_simp exB)
(*top goal: ‹⋀a s exA exB sa t. ⟦∀exA exB sa t. Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅exA ∧ Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB ⟶ filter_act⋅(snd (mkex A B s (sa, exA) (t, exB))) = s; a ∉ act A; a ∈ act B; a ∈ act (A ∥ B); Forall (λx. x ∈ act (A ∥ B)) s; Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅exA; a↝Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB⟧ ⟹ filter_act⋅(snd (mkex A B (a↝s) (sa, exA) (t, exB))) = a↝s› and 1 goal remains*)
apply simp
(*top goal: ‹⋀a s exA sa aa sb. ⟦∀exA exB sa t. Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅exA ∧ Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅exB ⟶ filter_act⋅(snd (mkex A B s (sa, exA) (t, exB))) = s; a ∉ act A; a ∈ act B; a ∈ act (A ∥ B); Forall (λx. x ∈ act (A ∥ B)) s; Filter (λa. a ∈ act A)⋅s ⊑ filter_act⋅exA; a↝Filter (λa. a ∈ act B)⋅s ⊑ filter_act⋅(aa↝sb)⟧ ⟹ filter_act⋅(snd (mkex A B s (sa, exA) (snd aa, sb))) = s› and 1 goal remains*)
text ‹Case ‹y ∉ A›, ‹y ∉ B››
by (simp add: asig_of_par (*‹asig_of (?A ∥ ?B) = asig_comp (asig_of ?A) (asig_of ?B)›*) actions_asig_comp (*‹actions (asig_comp ?a ?b) = actions ?a ∪ actions ?b›*))
text ‹Generalizing the proof above to a proof method:›
ML ‹
fun mkex_induct_tac ctxt sch exA exB =
EVERY' [
Seq_induct_tac ctxt sch
@{thms Filter_def Forall_def sforall_def mkex_def stutter_def},
asm_full_simp_tac ctxt,
SELECT_GOAL
(safe_tac (Context.raw_transfer (Proof_Context.theory_of ctxt) \<^theory_context>‹Fun›)),
Seq_case_simp_tac ctxt exA,
Seq_case_simp_tac ctxt exB,
asm_full_simp_tac ctxt,
Seq_case_simp_tac ctxt exA,
asm_full_simp_tac ctxt,
Seq_case_simp_tac ctxt exB,
asm_full_simp_tac ctxt,
asm_full_simp_tac (ctxt addsimps @{thms asig_of_par actions_asig_comp})]
›
method_setup mkex_induct = ‹
Scan.lift (Parse.embedded -- Parse.embedded -- Parse.embedded)
>> (fn ((sch, exA), exB) => fn ctxt =>
SIMPLE_METHOD' (mkex_induct_tac ctxt sch exA exB))
›
text ‹
Projection of ‹mkex (sch, exA, exB)› onto ‹A› stutters on ‹A›
structural induction.
›
lemma stutterA_mkex:
"∀exA exB s t.
Forall (λx. x ∈ act (A ∥ B)) sch ∧
Filter (λa. a ∈ act A) ⋅ sch ⊑ filter_act ⋅ exA ∧
Filter (λa. a ∈ act B) ⋅ sch ⊑ filter_act ⋅ exB ⟶
stutter (asig_of A) (s, ProjA2 ⋅ (snd (mkex A B sch (s, exA) (t, exB))))"
by (mkex_induct sch exA exB)
lemma stutter_mkex_on_A:
"Forall (λx. x ∈ act (A ∥ B)) sch ⟹
Filter (λa. a ∈ act A) ⋅ sch ⊑ filter_act ⋅ (snd exA) ⟹
Filter (λa. a ∈ act B) ⋅ sch ⊑ filter_act ⋅ (snd exB) ⟹
stutter (asig_of A) (ProjA (mkex A B sch exA exB))"
apply (cut_tac stutterA_mkex (*‹∀(exA::(?'a × ?'b) lift seq) (exB::(?'a × ?'c) lift seq) (s::?'b) t::?'c. Forall (λx::?'a. x ∈ act ((?A::(?'a set × ?'a set × ?'a set) × ?'b set × (?'b × ?'a × ?'b) set × ?'a set set × ?'a set set) ∥ (?B::(?'a set × ?'a set × ?'a set) × ?'c set × (?'c × ?'a × ?'c) set × ?'a set set × ?'a set set))) (?sch::?'a lift seq) ∧ Filter (λa::?'a. a ∈ act ?A)⋅?sch ⊑ filter_act⋅exA ∧ Filter (λa::?'a. a ∈ act ?B)⋅?sch ⊑ filter_act⋅exB ⟶ stutter (asig_of ?A) (s, ProjA2⋅(snd (mkex ?A ?B ?sch (s, exA) (t, exB))))›*))
(*goal: ‹⟦Forall (λx. x ∈ act (A ∥ B)) sch; Filter (λa. a ∈ act A)⋅sch ⊑ filter_act⋅(snd exA); Filter (λa. a ∈ act B)⋅sch ⊑ filter_act⋅(snd exB)⟧ ⟹ stutter (asig_of A) (ProjA (mkex A B sch exA exB))›*)
apply (simp add: stutter_def (*‹stutter ?sig ?ex = ((stutter2 ?sig⋅(snd ?ex)) (fst ?ex) ≠ FF)›*) ProjA_def (*‹ProjA ?ex = (fst (fst ?ex), ProjA2⋅(snd ?ex))›*) mkex_def (*‹mkex ?A ?B ?sch ?exA ?exB = ((fst ?exA, fst ?exB), (mkex2 ?A ?B⋅?sch⋅(snd ?exA)⋅(snd ?exB)) (fst ?exA) (fst ?exB))›*))
(*goal: ‹⟦Forall (λx. x ∈ act (A ∥ B)) sch; Filter (λa. a ∈ act A)⋅sch ⊑ filter_act⋅(snd exA); Filter (λa. a ∈ act B)⋅sch ⊑ filter_act⋅(snd exB); ∀exA exB s t. Forall (λx. x ∈ act (?A1 ∥ ?B1)) ?sch1 ∧ Filter (λa. a ∈ act ?A1)⋅?sch1 ⊑ filter_act⋅exA ∧ Filter (λa. a ∈ act ?B1)⋅?sch1 ⊑ filter_act⋅exB ⟶ stutter (asig_of ?A1) (s, ProjA2⋅(snd (mkex ?A1 ?B1 ?sch1 (s, exA) (t, exB))))⟧ ⟹ stutter (asig_of A) (ProjA (mkex A B sch exA exB))›*)
apply (erule allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⟦Forall (λx. x ∈ act (A ∥ B)) sch; Filter (λa. a ∈ act A)⋅sch ⊑ filter_act⋅(snd exA); Filter (λa. a ∈ act B)⋅sch ⊑ filter_act⋅(snd exB); ∀exA exB s t. Forall (λx. x ∈ act (?A1 ∥ ?B1)) ?sch1 ∧ Filter (λa. a ∈ act ?A1)⋅?sch1 ⊑ filter_act⋅exA ∧ Filter (λa. a ∈ act ?B1)⋅?sch1 ⊑ filter_act⋅exB ⟶ (stutter2 (asig_of ?A1)⋅(ProjA2⋅((mkex2 ?A1 ?B1⋅?sch1⋅exA⋅exB) s t))) s ≠ FF⟧ ⟹ (stutter2 (asig_of A)⋅(ProjA2⋅((mkex2 A B⋅sch⋅(snd exA)⋅(snd exB)) (fst exA) (fst exB)))) (fst exA) ≠ FF›*)
apply (erule allE (*‹⟦∀x::?'a::type. (?P::?'a::type ⇒ bool) x; ?P (?x::?'a::type) ⟹ ?R::bool⟧ ⟹ ?R›*))
(*goal: ‹⟦Forall (λx. x ∈ act (A ∥ B)) sch; Filter (λa. a ∈ act A)⋅sch ⊑ filter_act⋅(snd exA); Filter (λa. a ∈ act B)⋅sch ⊑ filter_act⋅(snd exB); ∀exB s t. Forall (λx. x ∈ act (?A1 ∥ ?B1)) ?sch1 ∧ Filter (λa. a ∈ act ?A1)⋅?sch1 ⊑ filter_act⋅?exA5 ∧ Filter (λa. a ∈ act ?B1)⋅?sch1 ⊑ filter_act⋅exB ⟶ (stutter2 (asig_of ?A1)⋅(ProjA2⋅((mkex2 ?A1 ?B1⋅?sch1⋅?exA5⋅exB) s t))) s ≠ FF⟧ ⟹ (stutter2 (asig_of A)⋅(ProjA2⋅((mkex2 A B⋅sch⋅(snd exA)⋅(snd exB)) (fst exA) (fst exB)))) (fst exA) ≠ FF›*)
apply (erule allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⟦Forall (λx::'a. x ∈ act ((A::('a set × 'a set × 'a set) × 'b set × ('b × 'a × 'b) set × 'a set set × 'a set set) ∥ (B::('a set × 'a set × 'a set) × 'c set × ('c × 'a × 'c) set × 'a set set × 'a set set))) (sch::'a lift seq); Filter (λa::'a. a ∈ act A)⋅sch ⊑ filter_act⋅(snd (exA::'b × ('a × 'b) lift seq)); Filter (λa::'a. a ∈ act B)⋅sch ⊑ filter_act⋅(snd (exB::'c × ('a × 'c) lift seq)); ∀(s::?'b1) t::?'c1. Forall (λx::?'a1. x ∈ act ((?A1::(?'a1 set × ?'a1 set × ?'a1 set) × ?'b1 set × (?'b1 × ?'a1 × ?'b1) set × ?'a1 set set × ?'a1 set set) ∥ (?B1::(?'a1 set × ?'a1 set × ?'a1 set) × ?'c1 set × (?'c1 × ?'a1 × ?'c1) set × ?'a1 set set × ?'a1 set set))) (?sch1::?'a1 lift seq) ∧ Filter (λa::?'a1. a ∈ act ?A1)⋅?sch1 ⊑ filter_act⋅(?exA5::(?'a1 × ?'b1) lift seq) ∧ Filter (λa::?'a1. a ∈ act ?B1)⋅?sch1 ⊑ filter_act⋅(?exB7::(?'a1 × ?'c1) lift seq) ⟶ (stutter2 (asig_of ?A1)⋅(ProjA2⋅((mkex2 ?A1 ?B1⋅?sch1⋅?exA5⋅?exB7) s t))) s ≠ FF⟧ ⟹ (stutter2 (asig_of A)⋅(ProjA2⋅((mkex2 A B⋅sch⋅(snd exA)⋅(snd exB)) (fst exA) (fst exB)))) (fst exA) ≠ FF›*)
apply (erule allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⟦Forall (λx. x ∈ act (A ∥ B)) sch; Filter (λa. a ∈ act A)⋅sch ⊑ filter_act⋅(snd exA); Filter (λa. a ∈ act B)⋅sch ⊑ filter_act⋅(snd exB); ∀t. Forall (λx. x ∈ act (?A1 ∥ ?B1)) ?sch1 ∧ Filter (λa. a ∈ act ?A1)⋅?sch1 ⊑ filter_act⋅?exA5 ∧ Filter (λa. a ∈ act ?B1)⋅?sch1 ⊑ filter_act⋅?exB7 ⟶ (stutter2 (asig_of ?A1)⋅(ProjA2⋅((mkex2 ?A1 ?B1⋅?sch1⋅?exA5⋅?exB7) ?s9 t))) ?s9 ≠ FF⟧ ⟹ (stutter2 (asig_of A)⋅(ProjA2⋅((mkex2 A B⋅sch⋅(snd exA)⋅(snd exB)) (fst exA) (fst exB)))) (fst exA) ≠ FF›*)
apply (drule mp (*‹⟦?P ⟶ ?Q; ?P⟧ ⟹ ?Q›*))
(*goals:
1. ‹⟦Forall (λx. x ∈ act (A ∥ B)) sch; Filter (λa. a ∈ act A)⋅sch ⊑ filter_act⋅(snd exA); Filter (λa. a ∈ act B)⋅sch ⊑ filter_act⋅(snd exB)⟧ ⟹ Forall (λx. x ∈ act (?A1 ∥ ?B1)) ?sch1 ∧ Filter (λa. a ∈ act ?A1)⋅?sch1 ⊑ filter_act⋅?exA5 ∧ Filter (λa. a ∈ act ?B1)⋅?sch1 ⊑ filter_act⋅?exB7›
2. ‹⟦Forall (λx. x ∈ act (A ∥ B)) sch; Filter (λa. a ∈ act A)⋅sch ⊑ filter_act⋅(snd exA); Filter (λa. a ∈ act B)⋅sch ⊑ filter_act⋅(snd exB); (stutter2 (asig_of ?A1)⋅(ProjA2⋅((mkex2 ?A1 ?B1⋅?sch1⋅?exA5⋅?exB7) ?s9 ?t11))) ?s9 ≠ FF⟧ ⟹ (stutter2 (asig_of A)⋅(ProjA2⋅((mkex2 A B⋅sch⋅(snd exA)⋅(snd exB)) (fst exA) (fst exB)))) (fst exA) ≠ FF›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply assumption
(*proven 2 subgoals*) .
text ‹
Projection of ‹mkex (sch, exA, exB)› onto ‹B› stutters on ‹B›
structural induction.
›
lemma stutterB_mkex:
"∀exA exB s t.
Forall (λx. x ∈ act (A ∥ B)) sch ∧
Filter (λa. a ∈ act A) ⋅ sch ⊑ filter_act ⋅ exA ∧
Filter (λa. a ∈ act B) ⋅ sch ⊑ filter_act ⋅ exB ⟶
stutter (asig_of B) (t, ProjB2 ⋅ (snd (mkex A B sch (s, exA) (t, exB))))"
by (mkex_induct sch exA exB)
lemma stutter_mkex_on_B:
"Forall (λx. x ∈ act (A ∥ B)) sch ⟹
Filter (λa. a ∈ act A) ⋅ sch ⊑ filter_act ⋅ (snd exA) ⟹
Filter (λa. a ∈ act B) ⋅ sch ⊑ filter_act ⋅ (snd exB) ⟹
stutter (asig_of B) (ProjB (mkex A B sch exA exB))"
apply (cut_tac stutterB_mkex (*‹∀(exA::(?'a × ?'b) lift seq) (exB::(?'a × ?'c) lift seq) (s::?'b) t::?'c. Forall (λx::?'a. x ∈ act ((?A::(?'a set × ?'a set × ?'a set) × ?'b set × (?'b × ?'a × ?'b) set × ?'a set set × ?'a set set) ∥ (?B::(?'a set × ?'a set × ?'a set) × ?'c set × (?'c × ?'a × ?'c) set × ?'a set set × ?'a set set))) (?sch::?'a lift seq) ∧ Filter (λa::?'a. a ∈ act ?A)⋅?sch ⊑ filter_act⋅exA ∧ Filter (λa::?'a. a ∈ act ?B)⋅?sch ⊑ filter_act⋅exB ⟶ stutter (asig_of ?B) (t, ProjB2⋅(snd (mkex ?A ?B ?sch (s, exA) (t, exB))))›*))
(*goal: ‹⟦Forall (λx::'a. x ∈ act ((A::('a set × 'a set × 'a set) × 'b set × ('b × 'a × 'b) set × 'a set set × 'a set set) ∥ (B::('a set × 'a set × 'a set) × 'c set × ('c × 'a × 'c) set × 'a set set × 'a set set))) (sch::'a lift seq); Filter (λa::'a. a ∈ act A)⋅sch ⊑ filter_act⋅(snd (exA::'b × ('a × 'b) lift seq)); Filter (λa::'a. a ∈ act B)⋅sch ⊑ filter_act⋅(snd (exB::'c × ('a × 'c) lift seq))⟧ ⟹ stutter (asig_of B) (ProjB (mkex A B sch exA exB))›*)
apply (simp add: stutter_def (*‹stutter ?sig ?ex = ((stutter2 ?sig⋅(snd ?ex)) (fst ?ex) ≠ FF)›*) ProjB_def (*‹ProjB ?ex = (snd (fst ?ex), ProjB2⋅(snd ?ex))›*) mkex_def (*‹mkex ?A ?B ?sch ?exA ?exB = ((fst ?exA, fst ?exB), (mkex2 ?A ?B⋅?sch⋅(snd ?exA)⋅(snd ?exB)) (fst ?exA) (fst ?exB))›*))
(*goal: ‹⟦Forall (λx::'a::type. x ∈ act ((A::('a::type set × 'a::type set × 'a::type set) × 'b::type set × ('b::type × 'a::type × 'b::type) set × 'a::type set set × 'a::type set set) ∥ (B::('a::type set × 'a::type set × 'a::type set) × 'c::type set × ('c::type × 'a::type × 'c::type) set × 'a::type set set × 'a::type set set))) (sch::'a::type lift seq); Filter (λa::'a::type. a ∈ act A)⋅sch ⊑ filter_act⋅(snd (exA::'b::type × ('a::type × 'b::type) lift seq)); Filter (λa::'a::type. a ∈ act B)⋅sch ⊑ filter_act⋅(snd (exB::'c::type × ('a::type × 'c::type) lift seq)); ∀(exA::(?'a1::type × ?'b1::type) lift seq) (exB::(?'a1::type × ?'c1::type) lift seq) (s::?'b1::type) t::?'c1::type. Forall (λx::?'a1::type. x ∈ act ((?A1::(?'a1::type set × ?'a1::type set × ?'a1::type set) × ?'b1::type set × (?'b1::type × ?'a1::type × ?'b1::type) set × ?'a1::type set set × ?'a1::type set set) ∥ (?B1::(?'a1::type set × ?'a1::type set × ?'a1::type set) × ?'c1::type set × (?'c1::type × ?'a1::type × ?'c1::type) set × ?'a1::type set set × ?'a1::type set set))) (?sch1::?'a1::type lift seq) ∧ Filter (λa::?'a1::type. a ∈ act ?A1)⋅?sch1 ⊑ filter_act⋅exA ∧ Filter (λa::?'a1::type. a ∈ act ?B1)⋅?sch1 ⊑ filter_act⋅exB ⟶ stutter (asig_of ?B1) (t, ProjB2⋅(snd (mkex ?A1 ?B1 ?sch1 (s, exA) (t, exB))))⟧ ⟹ stutter (asig_of B) (ProjB (mkex A B sch exA exB))›*)
apply (erule allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⟦Forall (λx. x ∈ act (A ∥ B)) sch; Filter (λa. a ∈ act A)⋅sch ⊑ filter_act⋅(snd exA); Filter (λa. a ∈ act B)⋅sch ⊑ filter_act⋅(snd exB); ∀exA exB s t. Forall (λx. x ∈ act (?A1 ∥ ?B1)) ?sch1 ∧ Filter (λa. a ∈ act ?A1)⋅?sch1 ⊑ filter_act⋅exA ∧ Filter (λa. a ∈ act ?B1)⋅?sch1 ⊑ filter_act⋅exB ⟶ (stutter2 (asig_of ?B1)⋅(ProjB2⋅((mkex2 ?A1 ?B1⋅?sch1⋅exA⋅exB) s t))) t ≠ FF⟧ ⟹ (stutter2 (asig_of B)⋅(ProjB2⋅((mkex2 A B⋅sch⋅(snd exA)⋅(snd exB)) (fst exA) (fst exB)))) (fst exB) ≠ FF›*)
apply (erule allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⟦Forall (λx. x ∈ act (A ∥ B)) sch; Filter (λa. a ∈ act A)⋅sch ⊑ filter_act⋅(snd exA); Filter (λa. a ∈ act B)⋅sch ⊑ filter_act⋅(snd exB); ∀exB s t. Forall (λx. x ∈ act (?A1 ∥ ?B1)) ?sch1 ∧ Filter (λa. a ∈ act ?A1)⋅?sch1 ⊑ filter_act⋅?exA5 ∧ Filter (λa. a ∈ act ?B1)⋅?sch1 ⊑ filter_act⋅exB ⟶ (stutter2 (asig_of ?B1)⋅(ProjB2⋅((mkex2 ?A1 ?B1⋅?sch1⋅?exA5⋅exB) s t))) t ≠ FF⟧ ⟹ (stutter2 (asig_of B)⋅(ProjB2⋅((mkex2 A B⋅sch⋅(snd exA)⋅(snd exB)) (fst exA) (fst exB)))) (fst exB) ≠ FF›*)
apply (erule allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⟦Forall (λx::'a. x ∈ act ((A::('a set × 'a set × 'a set) × 'b set × ('b × 'a × 'b) set × 'a set set × 'a set set) ∥ (B::('a set × 'a set × 'a set) × 'c set × ('c × 'a × 'c) set × 'a set set × 'a set set))) (sch::'a lift seq); Filter (λa::'a. a ∈ act A)⋅sch ⊑ filter_act⋅(snd (exA::'b × ('a × 'b) lift seq)); Filter (λa::'a. a ∈ act B)⋅sch ⊑ filter_act⋅(snd (exB::'c × ('a × 'c) lift seq)); ∀(s::?'b1) t::?'c1. Forall (λx::?'a1. x ∈ act ((?A1::(?'a1 set × ?'a1 set × ?'a1 set) × ?'b1 set × (?'b1 × ?'a1 × ?'b1) set × ?'a1 set set × ?'a1 set set) ∥ (?B1::(?'a1 set × ?'a1 set × ?'a1 set) × ?'c1 set × (?'c1 × ?'a1 × ?'c1) set × ?'a1 set set × ?'a1 set set))) (?sch1::?'a1 lift seq) ∧ Filter (λa::?'a1. a ∈ act ?A1)⋅?sch1 ⊑ filter_act⋅(?exA5::(?'a1 × ?'b1) lift seq) ∧ Filter (λa::?'a1. a ∈ act ?B1)⋅?sch1 ⊑ filter_act⋅(?exB7::(?'a1 × ?'c1) lift seq) ⟶ (stutter2 (asig_of ?B1)⋅(ProjB2⋅((mkex2 ?A1 ?B1⋅?sch1⋅?exA5⋅?exB7) s t))) t ≠ FF⟧ ⟹ (stutter2 (asig_of B)⋅(ProjB2⋅((mkex2 A B⋅sch⋅(snd exA)⋅(snd exB)) (fst exA) (fst exB)))) (fst exB) ≠ FF›*)
apply (erule allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⟦Forall (λx. x ∈ act (A ∥ B)) sch; Filter (λa. a ∈ act A)⋅sch ⊑ filter_act⋅(snd exA); Filter (λa. a ∈ act B)⋅sch ⊑ filter_act⋅(snd exB); ∀t. Forall (λx. x ∈ act (?A1 ∥ ?B1)) ?sch1 ∧ Filter (λa. a ∈ act ?A1)⋅?sch1 ⊑ filter_act⋅?exA5 ∧ Filter (λa. a ∈ act ?B1)⋅?sch1 ⊑ filter_act⋅?exB7 ⟶ (stutter2 (asig_of ?B1)⋅(ProjB2⋅((mkex2 ?A1 ?B1⋅?sch1⋅?exA5⋅?exB7) ?s9 t))) t ≠ FF⟧ ⟹ (stutter2 (asig_of B)⋅(ProjB2⋅((mkex2 A B⋅sch⋅(snd exA)⋅(snd exB)) (fst exA) (fst exB)))) (fst exB) ≠ FF›*)
apply (drule mp (*‹⟦?P ⟶ ?Q; ?P⟧ ⟹ ?Q›*))
(*goals:
1. ‹⟦Forall (λx. x ∈ act (A ∥ B)) sch; Filter (λa. a ∈ act A)⋅sch ⊑ filter_act⋅(snd exA); Filter (λa. a ∈ act B)⋅sch ⊑ filter_act⋅(snd exB)⟧ ⟹ Forall (λx. x ∈ act (?A1 ∥ ?B1)) ?sch1 ∧ Filter (λa. a ∈ act ?A1)⋅?sch1 ⊑ filter_act⋅?exA5 ∧ Filter (λa. a ∈ act ?B1)⋅?sch1 ⊑ filter_act⋅?exB7›
2. ‹⟦Forall (λx. x ∈ act (A ∥ B)) sch; Filter (λa. a ∈ act A)⋅sch ⊑ filter_act⋅(snd exA); Filter (λa. a ∈ act B)⋅sch ⊑ filter_act⋅(snd exB); (stutter2 (asig_of ?B1)⋅(ProjB2⋅((mkex2 ?A1 ?B1⋅?sch1⋅?exA5⋅?exB7) ?s9 ?t11))) ?t11 ≠ FF⟧ ⟹ (stutter2 (asig_of B)⋅(ProjB2⋅((mkex2 A B⋅sch⋅(snd exA)⋅(snd exB)) (fst exA) (fst exB)))) (fst exB) ≠ FF›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply assumption
(*proven 2 subgoals*) .
text ‹
Filter of ‹mkex (sch, exA, exB)› to ‹A› after projection onto ‹A› is ‹exA›,
using ‹zip ⋅ (proj1 ⋅ exA) ⋅ (proj2 ⋅ exA)› instead of ‹exA›,
because of admissibility problems structural induction.
›
lemma filter_mkex_is_exA_tmp:
"∀exA exB s t.
Forall (λx. x ∈ act (A ∥ B)) sch ∧
Filter (λa. a ∈ act A) ⋅ sch ⊑ filter_act ⋅ exA ∧
Filter (λa. a ∈ act B) ⋅ sch ⊑ filter_act ⋅ exB ⟶
Filter_ex2 (asig_of A) ⋅ (ProjA2 ⋅ (snd (mkex A B sch (s, exA) (t, exB)))) =
Zip ⋅ (Filter (λa. a ∈ act A) ⋅ sch) ⋅ (Map snd ⋅ exA)"
by (mkex_induct sch exB exA)
text ‹
‹zip ⋅ (proj1 ⋅ y) ⋅ (proj2 ⋅ y) = y› (using the lift operations)
lemma for admissibility problems
›
lemma Zip_Map_fst_snd: "Zip ⋅ (Map fst ⋅ y) ⋅ (Map snd ⋅ y) = y"
by (Seq_induct y)
text ‹
‹filter A ⋅ sch = proj1 ⋅ ex ⟶ zip ⋅ (filter A ⋅ sch) ⋅ (proj2 ⋅ ex) = ex›
lemma for eliminating non admissible equations in assumptions
›
lemma trick_against_eq_in_ass:
"Filter (λa. a ∈ act AB) ⋅ sch = filter_act ⋅ ex ⟹
ex = Zip ⋅ (Filter (λa. a ∈ act AB) ⋅ sch) ⋅ (Map snd ⋅ ex)"
apply (simp add: filter_act_def (*‹filter_act = Map fst›*))
(*goal: ‹Filter (λa::'a::type. a ∈ act (AB::('a::type set × 'a::type set × 'a::type set) × 'b::type set × ('b::type × 'a::type × 'b::type) set × 'a::type set set × 'a::type set set))⋅(sch::'a::type lift seq) = filter_act⋅(ex::('a::type × 'c::type) lift seq) ⟹ ex = Zip⋅(Filter (λa::'a::type. a ∈ act AB)⋅sch)⋅(Map snd⋅ex)›*)
by (rule Zip_Map_fst_snd [symmetric] (*‹?t = Zip⋅(Map fst⋅?t)⋅(Map snd⋅?t)›*))
text ‹
Filter of ‹mkex (sch, exA, exB)› to ‹A› after projection onto ‹A› is ‹exA›
using the above trick.
›
lemma filter_mkex_is_exA:
"Forall (λa. a ∈ act (A ∥ B)) sch ⟹
Filter (λa. a ∈ act A) ⋅ sch = filter_act ⋅ (snd exA) ⟹
Filter (λa. a ∈ act B) ⋅ sch = filter_act ⋅ (snd exB) ⟹
Filter_ex (asig_of A) (ProjA (mkex A B sch exA exB)) = exA"
apply (simp add: ProjA_def Filter_ex_def)
apply (pair exA)
apply (pair exB)
apply (rule conjI)
apply (simp (no_asm) add: mkex_def)
apply (simplesubst trick_against_eq_in_ass)
back
apply assumption
apply (simp add: filter_mkex_is_exA_tmp)
done
text ‹
Filter of ‹mkex (sch, exA, exB)› to ‹B› after projection onto ‹B› is ‹exB›
using ‹zip ⋅ (proj1 ⋅ exB) ⋅ (proj2 ⋅ exB)› instead of ‹exB›
because of admissibility problems structural induction.
›
lemma filter_mkex_is_exB_tmp:
"∀exA exB s t.
Forall (λx. x ∈ act (A ∥ B)) sch ∧
Filter (λa. a ∈ act A) ⋅ sch ⊑ filter_act ⋅ exA ∧
Filter (λa. a ∈ act B) ⋅ sch ⊑ filter_act ⋅ exB ⟶
Filter_ex2 (asig_of B) ⋅ (ProjB2 ⋅ (snd (mkex A B sch (s, exA) (t, exB)))) =
Zip ⋅ (Filter (λa. a ∈ act B) ⋅ sch) ⋅ (Map snd ⋅ exB)"
(*notice necessary change of arguments exA and exB*)
by (mkex_induct sch exA exB)
text ‹
Filter of ‹mkex (sch, exA, exB)› to ‹A› after projection onto ‹B› is ‹exB›
using the above trick.
›
lemma filter_mkex_is_exB:
"Forall (λa. a ∈ act (A ∥ B)) sch ⟹
Filter (λa. a ∈ act A) ⋅ sch = filter_act ⋅ (snd exA) ⟹
Filter (λa. a ∈ act B) ⋅ sch = filter_act ⋅ (snd exB) ⟹
Filter_ex (asig_of B) (ProjB (mkex A B sch exA exB)) = exB"
apply (simp add: ProjB_def Filter_ex_def)
apply (pair exA)
apply (pair exB)
apply (rule conjI)
apply (simp add: mkex_def)
apply (simplesubst trick_against_eq_in_ass)
back
apply assumption
apply (simp add: filter_mkex_is_exB_tmp)
done
lemma mkex_actions_in_AorB:
― ‹‹mkex› has only ‹A›- or ‹B›-actions›
"∀s t exA exB.
Forall (λx. x ∈ act (A ∥ B)) sch &
Filter (λa. a ∈ act A) ⋅ sch ⊑ filter_act ⋅ exA ∧
Filter (λa. a ∈ act B) ⋅ sch ⊑ filter_act ⋅ exB ⟶
Forall (λx. fst x ∈ act (A ∥ B)) (snd (mkex A B sch (s, exA) (t, exB)))"
by (mkex_induct sch exA exB)
theorem compositionality_sch:
"sch ∈ schedules (A ∥ B) ⟷
Filter (λa. a ∈ act A) ⋅ sch ∈ schedules A ∧
Filter (λa. a ∈ act B) ⋅ sch ∈ schedules B ∧
Forall (λx. x ∈ act (A ∥ B)) sch"
apply (simp add: schedules_def (*‹schedules ?ioa = {sch. has_schedule ?ioa sch}›*) has_schedule_def (*‹has_schedule ?ioa ?sch = (∃ex∈executions ?ioa. ?sch = filter_act⋅(snd ex))›*))
(*goal: ‹(sch ∈ schedules (A ∥ B)) = (Filter (λa. a ∈ act A)⋅sch ∈ schedules A ∧ Filter (λa. a ∈ act B)⋅sch ∈ schedules B ∧ Forall (λx. x ∈ act (A ∥ B)) sch)›*)
apply auto
(*goal: ‹(∃ex∈executions (A ∥ B). sch = filter_act⋅(snd ex)) = ((∃ex∈executions A. Filter (λa. a ∈ act A)⋅sch = filter_act⋅(snd ex)) ∧ (∃ex∈executions B. Filter (λa. a ∈ act B)⋅sch = filter_act⋅(snd ex)) ∧ Forall (λx. x ∈ act (A ∥ B)) sch)›*)
text ‹‹⟹››
apply (rule_tac x = "Filter_ex (asig_of A) (ProjA ex)" in bexI (*‹⟦?P ?x; ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*))
(*top goal: ‹⋀ex::('b × 'c) × ('a × 'b × 'c) lift seq. ⟦ex ∈ executions ((A::('a set × 'a set × 'a set) × 'b set × ('b × 'a × 'b) set × 'a set set × 'a set set) ∥ (B::('a set × 'a set × 'a set) × 'c set × ('c × 'a × 'c) set × 'a set set × 'a set set)); (sch::'a lift seq) = filter_act⋅(snd ex)⟧ ⟹ ∃exa::'b × ('a × 'b) lift seq∈executions A. Filter (λa::'a. a ∈ act A)⋅(filter_act⋅(snd ex)) = filter_act⋅(snd exa)› and 3 goals remain*)
prefer 2
(*top goal: ‹⋀ex. ⟦ex ∈ executions (A ∥ B); sch = filter_act⋅(snd ex)⟧ ⟹ Filter_ex (asig_of A) (ProjA ex) ∈ executions A› and 4 goals remain*)
apply (simp add: compositionality_ex (*‹(?ex ∈ executions (?A ∥ ?B)) = (Filter_ex (asig_of ?A) (ProjA ?ex) ∈ executions ?A ∧ Filter_ex (asig_of ?B) (ProjB ?ex) ∈ executions ?B ∧ stutter (asig_of ?A) (ProjA ?ex) ∧ stutter (asig_of ?B) (ProjB ?ex) ∧ Forall (λx. fst x ∈ act (?A ∥ ?B)) (snd ?ex))›*))
(*top goal: ‹⋀ex. ⟦ex ∈ executions (A ∥ B); sch = filter_act⋅(snd ex)⟧ ⟹ Filter_ex (asig_of A) (ProjA ex) ∈ executions A› and 4 goals remain*)
apply (simp (no_asm) add: Filter_ex_def (*‹Filter_ex ?sig ?ex = (fst ?ex, Filter_ex2 ?sig⋅(snd ?ex))›*) ProjA_def (*‹ProjA ?ex = (fst (fst ?ex), ProjA2⋅(snd ?ex))›*) lemma_2_1a (*‹filter_act⋅(Filter_ex2 (asig_of ?A)⋅?xs) = Filter (λa. a ∈ act ?A)⋅(filter_act⋅?xs)›*) lemma_2_1b (*‹filter_act⋅(ProjA2⋅?xs) = filter_act⋅?xs ∧ filter_act⋅(ProjB2⋅?xs) = filter_act⋅?xs›*))
(*top goal: ‹⋀ex. ⟦ex ∈ executions (A ∥ B); sch = filter_act⋅(snd ex)⟧ ⟹ Filter (λa. a ∈ act A)⋅(filter_act⋅(snd ex)) = filter_act⋅(snd (Filter_ex (asig_of A) (ProjA ex)))› and 3 goals remain*)
apply (rule_tac x = "Filter_ex (asig_of B) (ProjB ex)" in bexI (*‹⟦(?P::?'a ⇒ bool) (?x::?'a); ?x ∈ (?A::?'a set)⟧ ⟹ ∃x::?'a∈?A. ?P x›*))
(*top goal: ‹⋀ex. ⟦ex ∈ executions (A ∥ B); sch = filter_act⋅(snd ex)⟧ ⟹ ∃exa∈executions B. Filter (λa. a ∈ act B)⋅(filter_act⋅(snd ex)) = filter_act⋅(snd exa)› and 2 goals remain*)
prefer 2
(*top goal: ‹⋀ex. ⟦ex ∈ executions (A ∥ B); sch = filter_act⋅(snd ex)⟧ ⟹ Filter_ex (asig_of B) (ProjB ex) ∈ executions B› and 3 goals remain*)
apply (simp add: compositionality_ex (*‹(?ex ∈ executions (?A ∥ ?B)) = (Filter_ex (asig_of ?A) (ProjA ?ex) ∈ executions ?A ∧ Filter_ex (asig_of ?B) (ProjB ?ex) ∈ executions ?B ∧ stutter (asig_of ?A) (ProjA ?ex) ∧ stutter (asig_of ?B) (ProjB ?ex) ∧ Forall (λx. fst x ∈ act (?A ∥ ?B)) (snd ?ex))›*))
(*top goal: ‹⋀ex. ⟦ex ∈ executions (A ∥ B); sch = filter_act⋅(snd ex)⟧ ⟹ Filter_ex (asig_of B) (ProjB ex) ∈ executions B› and 3 goals remain*)
apply (simp add: Filter_ex_def (*‹Filter_ex ?sig ?ex = (fst ?ex, Filter_ex2 ?sig⋅(snd ?ex))›*) ProjB_def (*‹ProjB ?ex = (snd (fst ?ex), ProjB2⋅(snd ?ex))›*) lemma_2_1a (*‹filter_act⋅(Filter_ex2 (asig_of ?A)⋅?xs) = Filter (λa. a ∈ act ?A)⋅(filter_act⋅?xs)›*) lemma_2_1b (*‹filter_act⋅(ProjA2⋅?xs) = filter_act⋅?xs ∧ filter_act⋅(ProjB2⋅?xs) = filter_act⋅?xs›*))
(*top goal: ‹⋀ex::('b × 'c) × ('a × 'b × 'c) lift seq. ⟦ex ∈ executions ((A::('a set × 'a set × 'a set) × 'b set × ('b × 'a × 'b) set × 'a set set × 'a set set) ∥ (B::('a set × 'a set × 'a set) × 'c set × ('c × 'a × 'c) set × 'a set set × 'a set set)); (sch::'a lift seq) = filter_act⋅(snd ex)⟧ ⟹ Filter (λa::'a. a ∈ act B)⋅(filter_act⋅(snd ex)) = filter_act⋅(snd (Filter_ex (asig_of B) (ProjB ex)))› and 2 goals remain*)
apply (simp add: executions_def (*‹executions ?ioa = {e. fst e ∈ starts_of ?ioa ∧ is_exec_frag ?ioa e}›*))
(*top goal: ‹⋀ex. ⟦ex ∈ executions (A ∥ B); sch = filter_act⋅(snd ex)⟧ ⟹ Forall (λx. x ∈ act (A ∥ B)) (filter_act⋅(snd ex))› and 1 goal remains*)
apply (pair ex)
(*top goal: ‹⋀ex. ⟦fst ex ∈ starts_of (A ∥ B) ∧ is_exec_frag (A ∥ B) ex; sch = filter_act⋅(snd ex)⟧ ⟹ Forall (λx. x ∈ act (A ∥ B)) (filter_act⋅(snd ex))› and 1 goal remains*)
apply (erule conjE (*‹⟦(?P::bool) ∧ (?Q::bool); ⟦?P; ?Q⟧ ⟹ ?R::bool⟧ ⟹ ?R›*))
(*top goal: ‹⋀x1 x2. ⟦x1 ∈ starts_of (A ∥ B) ∧ is_exec_frag (A ∥ B) (x1, x2); sch = filter_act⋅x2⟧ ⟹ Forall (λx. x ∈ act (A ∥ B)) (filter_act⋅x2)› and 1 goal remains*)
apply (simp add: sch_actions_in_AorB (*‹∀s::?'a × ?'b. is_exec_frag ((?A::(?'c set × ?'c set × ?'c set) × ?'a set × (?'a × ?'c × ?'a) set × ?'c set set × ?'c set set) ∥ (?B::(?'c set × ?'c set × ?'c set) × ?'b set × (?'b × ?'c × ?'b) set × ?'c set set × ?'c set set)) (s, ?xs::(?'c × ?'a × ?'b) lift seq) ⟶ Forall (λx::?'c. x ∈ act (?A ∥ ?B)) (filter_act⋅?xs)›*))
(*top goal: ‹⋀x1 x2. ⟦sch = filter_act⋅x2; x1 ∈ starts_of (A ∥ B); is_exec_frag (A ∥ B) (x1, x2)⟧ ⟹ Forall (λx. x ∈ act (A ∥ B)) (filter_act⋅x2)› and 1 goal remains*)
text ‹‹⟸››
text ‹‹mkex› is exactly the construction of ‹exA∥B› out of ‹exA›, ‹exB›,
and the oracle ‹sch›, we need here›
apply (rename_tac exA exB)
(*goal: ‹⋀ex exa. ⟦ex ∈ executions A; Filter (λa. a ∈ act A)⋅sch = filter_act⋅(snd ex); Forall (λx. x ∈ act (A ∥ B)) sch; exa ∈ executions B; Filter (λa. a ∈ act B)⋅sch = filter_act⋅(snd exa)⟧ ⟹ ∃ex∈executions (A ∥ B). sch = filter_act⋅(snd ex)›*)
apply (rule_tac x = "mkex A B sch exA exB" in bexI (*‹⟦?P ?x; ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*))
(*goal: ‹⋀exA exB. ⟦exA ∈ executions A; Filter (λa. a ∈ act A)⋅sch = filter_act⋅(snd exA); Forall (λx. x ∈ act (A ∥ B)) sch; exB ∈ executions B; Filter (λa. a ∈ act B)⋅sch = filter_act⋅(snd exB)⟧ ⟹ ∃ex∈executions (A ∥ B). sch = filter_act⋅(snd ex)›*)
text ‹‹mkex› actions are just the oracle›
apply (pair exA)
(*top goal: ‹⋀exA exB. ⟦exA ∈ executions A; Filter (λa. a ∈ act A)⋅sch = filter_act⋅(snd exA); Forall (λx. x ∈ act (A ∥ B)) sch; exB ∈ executions B; Filter (λa. a ∈ act B)⋅sch = filter_act⋅(snd exB)⟧ ⟹ sch = filter_act⋅(snd (mkex A B sch exA exB))› and 1 goal remains*)
apply (pair exB)
(*top goal: ‹⋀exB x1 x2. ⟦(x1, x2) ∈ executions A; Filter (λa. a ∈ act A)⋅sch = filter_act⋅x2; Forall (λx. x ∈ act (A ∥ B)) sch; exB ∈ executions B; Filter (λa. a ∈ act B)⋅sch = filter_act⋅(snd exB)⟧ ⟹ sch = filter_act⋅(snd (mkex A B sch (x1, x2) exB))› and 1 goal remains*)
apply (simp add: Mapfst_mkex_is_sch (*‹∀exA exB s t. Forall (λx. x ∈ act (?A ∥ ?B)) ?sch ∧ Filter (λa. a ∈ act ?A)⋅?sch ⊑ filter_act⋅exA ∧ Filter (λa. a ∈ act ?B)⋅?sch ⊑ filter_act⋅exB ⟶ filter_act⋅(snd (mkex ?A ?B ?sch (s, exA) (t, exB))) = ?sch›*))
(*top goal: ‹⋀x1 x2 x1a x2a. ⟦(x1, x2) ∈ executions A; Filter (λa. a ∈ act A)⋅sch = filter_act⋅x2; Forall (λx. x ∈ act (A ∥ B)) sch; (x1a, x2a) ∈ executions B; Filter (λa. a ∈ act B)⋅sch = filter_act⋅x2a⟧ ⟹ sch = filter_act⋅(snd (mkex A B sch (x1, x2) (x1a, x2a)))› and 1 goal remains*)
text ‹‹mkex› is an execution -- use compositionality on ex-level›
apply (simp add: compositionality_ex (*‹(?ex ∈ executions (?A ∥ ?B)) = (Filter_ex (asig_of ?A) (ProjA ?ex) ∈ executions ?A ∧ Filter_ex (asig_of ?B) (ProjB ?ex) ∈ executions ?B ∧ stutter (asig_of ?A) (ProjA ?ex) ∧ stutter (asig_of ?B) (ProjB ?ex) ∧ Forall (λx. fst x ∈ act (?A ∥ ?B)) (snd ?ex))›*))
(*goal: ‹⋀exA exB. ⟦exA ∈ executions A; Filter (λa. a ∈ act A)⋅sch = filter_act⋅(snd exA); Forall (λx. x ∈ act (A ∥ B)) sch; exB ∈ executions B; Filter (λa. a ∈ act B)⋅sch = filter_act⋅(snd exB)⟧ ⟹ mkex A B sch exA exB ∈ executions (A ∥ B)›*)
apply (simp add: stutter_mkex_on_A (*‹⟦Forall (λx. x ∈ act (?A ∥ ?B)) ?sch; Filter (λa. a ∈ act ?A)⋅?sch ⊑ filter_act⋅(snd ?exA); Filter (λa. a ∈ act ?B)⋅?sch ⊑ filter_act⋅(snd ?exB)⟧ ⟹ stutter (asig_of ?A) (ProjA (mkex ?A ?B ?sch ?exA ?exB))›*) stutter_mkex_on_B (*‹⟦Forall (λx. x ∈ act (?A ∥ ?B)) ?sch; Filter (λa. a ∈ act ?A)⋅?sch ⊑ filter_act⋅(snd ?exA); Filter (λa. a ∈ act ?B)⋅?sch ⊑ filter_act⋅(snd ?exB)⟧ ⟹ stutter (asig_of ?B) (ProjB (mkex ?A ?B ?sch ?exA ?exB))›*) filter_mkex_is_exB (*‹⟦Forall (λa. a ∈ act (?A ∥ ?B)) ?sch; Filter (λa. a ∈ act ?A)⋅?sch = filter_act⋅(snd ?exA); Filter (λa. a ∈ act ?B)⋅?sch = filter_act⋅(snd ?exB)⟧ ⟹ Filter_ex (asig_of ?B) (ProjB (mkex ?A ?B ?sch ?exA ?exB)) = ?exB›*) filter_mkex_is_exA (*‹⟦Forall (λa. a ∈ act (?A ∥ ?B)) ?sch; Filter (λa. a ∈ act ?A)⋅?sch = filter_act⋅(snd ?exA); Filter (λa. a ∈ act ?B)⋅?sch = filter_act⋅(snd ?exB)⟧ ⟹ Filter_ex (asig_of ?A) (ProjA (mkex ?A ?B ?sch ?exA ?exB)) = ?exA›*))
(*goal: ‹⋀exA exB. ⟦exA ∈ executions A; Filter (λa. a ∈ act A)⋅sch = filter_act⋅(snd exA); Forall (λx. x ∈ act (A ∥ B)) sch; exB ∈ executions B; Filter (λa. a ∈ act B)⋅sch = filter_act⋅(snd exB)⟧ ⟹ Filter_ex (asig_of A) (ProjA (mkex A B sch exA exB)) ∈ executions A ∧ Filter_ex (asig_of B) (ProjB (mkex A B sch exA exB)) ∈ executions B ∧ stutter (asig_of A) (ProjA (mkex A B sch exA exB)) ∧ stutter (asig_of B) (ProjB (mkex A B sch exA exB)) ∧ Forall (λx. fst x ∈ act (A ∥ B)) (snd (mkex A B sch exA exB))›*)
apply (pair exA)
(*goal: ‹⋀exA exB. ⟦exA ∈ executions A; Filter (λa. a ∈ act A)⋅sch = filter_act⋅(snd exA); Forall (λx. x ∈ act (A ∥ B)) sch; exB ∈ executions B; Filter (λa. a ∈ act B)⋅sch = filter_act⋅(snd exB)⟧ ⟹ Forall (λx. fst x ∈ act (A ∥ B)) (snd (mkex A B sch exA exB))›*)
apply (pair exB)
(*goal: ‹⋀exB x1 x2. ⟦(x1, x2) ∈ executions A; Filter (λa. a ∈ act A)⋅sch = filter_act⋅x2; Forall (λx. x ∈ act (A ∥ B)) sch; exB ∈ executions B; Filter (λa. a ∈ act B)⋅sch = filter_act⋅(snd exB)⟧ ⟹ Forall (λx. fst x ∈ act (A ∥ B)) (snd (mkex A B sch (x1, x2) exB))›*)
by (simp add: mkex_actions_in_AorB (*‹∀(s::?'a) (t::?'b) (exA::(?'c × ?'a) lift seq) exB::(?'c × ?'b) lift seq. Forall (λx::?'c. x ∈ act ((?A::(?'c set × ?'c set × ?'c set) × ?'a set × (?'a × ?'c × ?'a) set × ?'c set set × ?'c set set) ∥ (?B::(?'c set × ?'c set × ?'c set) × ?'b set × (?'b × ?'c × ?'b) set × ?'c set set × ?'c set set))) (?sch::?'c lift seq) ∧ Filter (λa::?'c. a ∈ act ?A)⋅?sch ⊑ filter_act⋅exA ∧ Filter (λa::?'c. a ∈ act ?B)⋅?sch ⊑ filter_act⋅exB ⟶ Forall (λx::?'c × ?'a × ?'b. fst x ∈ act (?A ∥ ?B)) (snd (mkex ?A ?B ?sch (s, exA) (t, exB)))›*))
theorem compositionality_sch_modules:
"Scheds (A ∥ B) = par_scheds (Scheds A) (Scheds B)"
apply (unfold Scheds_def (*‹Scheds ?A = (schedules ?A, asig_of ?A)›*) par_scheds_def (*‹par_scheds ?SchedsA ?SchedsB = (let schA = fst ?SchedsA; sigA = snd ?SchedsA; schB = fst ?SchedsB; sigB = snd ?SchedsB in ({sch. Filter (λa. a ∈ actions sigA)⋅sch ∈ schA} ∩ {sch. Filter (λa. a ∈ actions sigB)⋅sch ∈ schB} ∩ {sch. Forall (λx. x ∈ actions sigA ∪ actions sigB) sch}, asig_comp sigA sigB))›*))
(*goal: ‹Scheds (A ∥ B) = par_scheds (Scheds A) (Scheds B)›*)
apply (simp add: asig_of_par (*‹asig_of (?A ∥ ?B) = asig_comp (asig_of ?A) (asig_of ?B)›*))
(*goal: ‹(schedules (A ∥ B), asig_of (A ∥ B)) = (let schA = fst (schedules A, asig_of A); sigA = snd (schedules A, asig_of A); schB = fst (schedules B, asig_of B); sigB = snd (schedules B, asig_of B) in ({sch. Filter (λa. a ∈ actions sigA)⋅sch ∈ schA} ∩ {sch. Filter (λa. a ∈ actions sigB)⋅sch ∈ schB} ∩ Collect (Forall (λx. x ∈ actions sigA ∪ actions sigB)), asig_comp sigA sigB))›*)
apply (rule set_eqI (*‹(⋀x. (x ∈ ?A) = (x ∈ ?B)) ⟹ ?A = ?B›*))
(*goal: ‹schedules (A ∥ B) = {sch. Filter (λa. a ∈ act A)⋅sch ∈ schedules A} ∩ {sch. Filter (λa. a ∈ act B)⋅sch ∈ schedules B} ∩ Collect (Forall (λx. x ∈ act A ∨ x ∈ act B))›*)
by (simp add: compositionality_sch (*‹(?sch ∈ schedules (?A ∥ ?B)) = (Filter (λa. a ∈ act ?A)⋅?sch ∈ schedules ?A ∧ Filter (λa. a ∈ act ?B)⋅?sch ∈ schedules ?B ∧ Forall (λx. x ∈ act (?A ∥ ?B)) ?sch)›*) actions_of_par (*‹act (?A1.0 ∥ ?A2.0) = act ?A1.0 ∪ act ?A2.0›*))
declare compoex_simps [simp del]
declare composch_simps [simp del]
end
| {
"path": "Isabelle2024/src/HOL/HOLCF/IOA/CompoScheds.thy",
"repo": "Isabelle2024",
"sha": "698deb08973b5e110e81b8da8f73d8584def88ae44484804a11e7db97d0468a1"
} |
(* Title: variants/a_norreqid/Seq_Invariants.thy
License: BSD 2-Clause. See LICENSE.
Author: Timothy Bourke, Inria
*)
section "Invariant proofs on individual processes"
theory A_Seq_Invariants
imports AWN.Invariants A_Aodv A_Aodv_Data A_Aodv_Predicates A_Fresher
begin
text ‹
The proposition numbers are taken from the December 2013 version of
the Fehnker et al technical report.
›
text ‹Proposition 7.2›
lemma sequence_number_increases:
"paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ, _), _, (ξ', _)). sn ξ ≤ sn ξ')"
by inv_cterms
lemma sequence_number_one_or_bigger:
"paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, _). 1 ≤ sn ξ)"
apply (rule onll_step_to_invariantI [OF sequence_number_increases] (*‹⟦wellformed Γ⇩A⇩O⇩D⇩V; ⋀ξ l p. ⟦(ξ, p) ∈ init (paodv ?i1); l ∈ labels Γ⇩A⇩O⇩D⇩V p⟧ ⟹ ?P (ξ, l); ⋀ξ p l ξ' l' a. ⟦(ξ, p) ∈ reachable (paodv ?i1) TT; l ∈ labels Γ⇩A⇩O⇩D⇩V p; ?P (ξ, l); case ((ξ, l), a, ξ', l') of (x, xa) ⇒ (case x of (ξ, uu_) ⇒ λ(uu_, ξ', uu_). sn ξ ≤ sn ξ') xa; TT a⟧ ⟹ ?P (ξ', l')⟧ ⟹ paodv ?i1 ⊫ onl Γ⇩A⇩O⇩D⇩V ?P›*))
(*goals:
1. ‹wellformed Γ⇩A⇩O⇩D⇩V›
2. ‹⋀ξ l p. ⟦(ξ, p) ∈ init (paodv i); l ∈ labels Γ⇩A⇩O⇩D⇩V p⟧ ⟹ case (ξ, l) of (ξ, uu_) ⇒ 1 ≤ sn ξ›
3. ‹⋀ξ p l ξ' l' a. ⟦(ξ, p) ∈ reachable (paodv i) TT; l ∈ labels Γ⇩A⇩O⇩D⇩V p; case (ξ, l) of (ξ, uu_) ⇒ 1 ≤ sn ξ; case ((ξ, l), a, ξ', l') of (x, xa) ⇒ (case x of (ξ, uu_) ⇒ λ(uu_, ξ', uu_). sn ξ ≤ sn ξ') xa; TT a⟧ ⟹ case (ξ', l') of (ξ, uu_) ⇒ 1 ≤ sn ξ›
discuss goal 1*)
apply ((auto simp: σ⇩A⇩O⇩D⇩V_def (*‹σ⇩A⇩O⇩D⇩V ?i ≡ {(⦇ip = ?i, sn = 1, rt = λx. None, rreqs = {}, store = λx. None, msg = SOME x. True, data = SOME x. True, dests = SOME x. True, pre = SOME x. True, dip = SOME x. True, oip = SOME x. True, hops = SOME x. True, dsn = SOME x. True, dsk = SOME x. True, osn = SOME x. True, sip = SOME x. x ≠ ?i⦈, Γ⇩A⇩O⇩D⇩V PAodv)}›*))[1])
(*discuss goal 2*)
apply ((auto simp: σ⇩A⇩O⇩D⇩V_def (*‹σ⇩A⇩O⇩D⇩V ?i ≡ {(⦇ip = ?i, sn = 1, rt = λx. None, rreqs = {}, store = λx. None, msg = SOME x. True, data = SOME x. True, dests = SOME x. True, pre = SOME x. True, dip = SOME x. True, oip = SOME x. True, hops = SOME x. True, dsn = SOME x. True, dsk = SOME x. True, osn = SOME x. True, sip = SOME x. x ≠ ?i⦈, Γ⇩A⇩O⇩D⇩V PAodv)}›*))[1])
(*discuss goal 3*)
apply ((auto simp: σ⇩A⇩O⇩D⇩V_def (*‹σ⇩A⇩O⇩D⇩V ?i ≡ {(⦇ip = ?i, sn = 1, rt = λx. None, rreqs = {}, store = λx. None, msg = SOME x. True, data = SOME x. True, dests = SOME x. True, pre = SOME x. True, dip = SOME x. True, oip = SOME x. True, hops = SOME x. True, dsn = SOME x. True, dsk = SOME x. True, osn = SOME x. True, sip = SOME x. x ≠ ?i⦈, Γ⇩A⇩O⇩D⇩V PAodv)}›*))[1])
(*proven 3 subgoals*) .
text ‹We can get rid of the onl/onll if desired...›
lemma sequence_number_increases':
"paodv i ⊫⇩A (λ((ξ, _), _, (ξ', _)). sn ξ ≤ sn ξ')"
apply (rule step_invariant_weakenE [OF sequence_number_increases] (*‹⟦⋀t. onll Γ⇩A⇩O⇩D⇩V (λ((ξ, uu_), uu_, ξ', uu_). sn ξ ≤ sn ξ') t ⟹ ?Q t; ⋀a. ?QI a ⟹ TT a⟧ ⟹ paodv ?i1 ⊫⇩A (?QI →) ?Q›*))
(*goals:
1. ‹⋀t. onll Γ⇩A⇩O⇩D⇩V (λ((ξ, uu_), uu_, ξ', uu_). sn ξ ≤ sn ξ') t ⟹ case t of (x, xa) ⇒ (case x of (ξ, uu_) ⇒ λ(uu_, ξ', uu_). sn ξ ≤ sn ξ') xa›
2. ‹⋀a. TT a ⟹ TT a›
discuss goal 1*)
apply ((auto dest!: onllD (*‹onll (?Γ::?'a ⇒ (?'b, ?'c, ?'a, ?'d) seqp) (?P::(?'e × ?'d) × ?'f × ?'e × ?'d ⇒ bool) ((?ξ::?'e, ?p::(?'b, ?'c, ?'a, ?'d) seqp), ?a::?'f, ?ξ'::?'e, ?p'::(?'b, ?'c, ?'a, ?'d) seqp) ⟹ ∀l::?'d∈labels ?Γ ?p. ∀l'::?'d∈labels ?Γ ?p'. ?P ((?ξ, l), ?a, ?ξ', l')›*))[1])
(*discuss goal 2*)
apply ((auto dest!: onllD (*‹onll ?Γ ?P ((?ξ, ?p), ?a, ?ξ', ?p') ⟹ ∀l∈labels ?Γ ?p. ∀l'∈labels ?Γ ?p'. ?P ((?ξ, l), ?a, ?ξ', l')›*))[1])
(*proven 2 subgoals*) .
lemma sequence_number_one_or_bigger':
"paodv i ⊫ (λ(ξ, _). 1 ≤ sn ξ)"
apply (rule invariant_weakenE [OF sequence_number_one_or_bigger] (*‹⟦⋀s::state × (state, msg, pseqp, pseqp label) seqp. onl Γ⇩A⇩O⇩D⇩V (λ(ξ::state, uu_::pseqp label). (1::nat) ≤ sn ξ) s ⟹ (?Q::state × (state, msg, pseqp, pseqp label) seqp ⇒ bool) s; ⋀a::msg seq_action. (?QI::msg seq_action ⇒ bool) a ⟹ TT a⟧ ⟹ paodv (?i1::nat) ⊫ (?QI →) ?Q›*))
(*goals:
1. ‹⋀s. onl Γ⇩A⇩O⇩D⇩V (λ(ξ, uu_). 1 ≤ sn ξ) s ⟹ case s of (ξ, uu_) ⇒ 1 ≤ sn ξ›
2. ‹⋀a. TT a ⟹ TT a›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma sip_in_kD:
"paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). l ∈ ({PAodv-:7} ∪ {PAodv-:5} ∪ {PRrep-:0..PRrep-:1}
∪ {PRreq-:0..PRreq-:3}) ⟶ sip ξ ∈ kD (rt ξ))"
by inv_cterms
lemma rrep_1_update_changes:
"paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l = PRrep-:1 ⟶
rt ξ ≠ update (rt ξ) (dip ξ) (dsn ξ, kno, val, hops ξ + 1, sip ξ, {})))"
by inv_cterms
lemma addpreRT_partly_welldefined:
"paodv i ⊫
onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l ∈ {PRreq-:16..PRreq-:18} ∪ {PRrep-:2..PRrep-:6} ⟶ dip ξ ∈ kD (rt ξ))
∧ (l ∈ {PRreq-:3..PRreq-:17} ⟶ oip ξ ∈ kD (rt ξ)))"
by inv_cterms
text ‹Proposition 7.38›
lemma includes_nhip:
"paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). ∀dip∈kD(rt ξ). the (nhop (rt ξ) dip)∈kD(rt ξ))"
proof (-)
(*goal: ‹paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). ∀dip∈kD (rt ξ). the (nhop (rt ξ) dip) ∈ kD (rt ξ))›*)
{
fix ip and ξ :: state and ξ' :: state
assume "∀dip∈kD (rt ξ). the (nhop (rt ξ) dip) ∈ kD (rt ξ)" and "ξ' = ξ⦇rt := update (rt ξ) ip (0, unk, val, Suc 0, ip, {})⦈" (*‹∀dip::nat∈kD (rt (ξ::state)). the (nhop (rt ξ) dip) ∈ kD (rt ξ)› ‹(ξ'::state) = ξ⦇rt := update (rt (ξ::state)) (ip::nat) (0::nat, unk, val, Suc (0::nat), ip, {})⦈›*)
hence "∀dip∈kD (rt ξ).
the (nhop (update (rt ξ) ip (0, unk, val, Suc 0, ip, {})) dip) = ip
∨ the (nhop (update (rt ξ) ip (0, unk, val, Suc 0, ip, {})) dip) ∈ kD (rt ξ)"
apply clarsimp
(*goal: ‹∀dip∈kD (rt ξ). the (nhop (update (rt ξ) ip (0, unk, val, Suc 0, ip, {})) dip) = ip ∨ the (nhop (update (rt ξ) ip (0, unk, val, Suc 0, ip, {})) dip) ∈ kD (rt ξ)›*)
by (metis nhop_update_unk_val (*‹the (nhop (update ?rt ?dip (?dsn, unk, val, ?hops, ?ip, ?npre)) ?dip) = ?ip›*) update_another (*‹?ip ≠ ?dip ⟹ update ?rt ?dip (?dsn, ?dsk, ?flag, ?hops, ?nhip, ?pre) ?ip = ?rt ?ip›*))
}
note one_hop = this (*‹⟦∀dip::nat∈kD (rt (?ξ2::state)). the (nhop (rt ?ξ2) dip) ∈ kD (rt ?ξ2); (?ξ'2::state) = ?ξ2⦇rt := update (rt ?ξ2) (?ip2::nat) (0::nat, unk, val, Suc (0::nat), ?ip2, {})⦈⟧ ⟹ ∀dip::nat∈kD (rt ?ξ2). the (nhop (update (rt ?ξ2) ?ip2 (0::nat, unk, val, Suc (0::nat), ?ip2, {})) dip) = ?ip2 ∨ the (nhop (update (rt ?ξ2) ?ip2 (0::nat, unk, val, Suc (0::nat), ?ip2, {})) dip) ∈ kD (rt ?ξ2)›*)
{
fix ip and sip and sn and hops and ξ :: state and ξ' :: state
assume "∀dip∈kD (rt ξ). the (nhop (rt ξ) dip) ∈ kD (rt ξ)" and "ξ' = ξ⦇rt := update (rt ξ) ip (sn, kno, val, Suc hops, sip, {})⦈" and "sip ∈ kD (rt ξ)" (*‹∀dip::nat∈kD (rt (ξ::state)). the (nhop (rt ξ) dip) ∈ kD (rt ξ)› ‹(ξ'::state) = ξ⦇rt := update (rt (ξ::state)) (ip::nat) (sn::nat, kno, val, Suc (hops::nat), sip::nat, {})⦈› ‹(sip::nat) ∈ kD (rt (ξ::state))›*)
hence "(the (nhop (update (rt ξ) ip (sn, kno, val, Suc hops, sip, {})) ip) = ip
∨ the (nhop (update (rt ξ) ip (sn, kno, val, Suc hops, sip, {})) ip) ∈ kD (rt ξ))
∧ (∀dip∈kD (rt ξ).
the (nhop (update (rt ξ) ip (sn, kno, val, Suc hops, sip, {})) dip) = ip
∨ the (nhop (update (rt ξ) ip (sn, kno, val, Suc hops, sip, {})) dip) ∈ kD (rt ξ))"
by (metis kD_update_unchanged (*‹?rt = update ?rt ?dip (?dsn, ?dsk, ?flag, ?hops, ?nhip, ?pre) ⟹ ?dip ∈ kD ?rt›*) nhop_update_changed (*‹update ?rt ?dip (?dsn, ?dsk, ?flg, ?hops, ?sip, {}) ≠ ?rt ⟹ the (nhop (update ?rt ?dip (?dsn, ?dsk, ?flg, ?hops, ?sip, {})) ?dip) = ?sip›*) update_another (*‹?ip ≠ ?dip ⟹ update ?rt ?dip (?dsn, ?dsk, ?flag, ?hops, ?nhip, ?pre) ?ip = ?rt ?ip›*))
}
note nhip_is_sip = this (*‹⟦∀dip∈kD (rt ?ξ2). the (nhop (rt ?ξ2) dip) ∈ kD (rt ?ξ2); ?ξ'2 = ?ξ2⦇rt := update (rt ?ξ2) ?ip2 (?sn2, kno, val, Suc ?hops2, ?sip2, {})⦈; ?sip2 ∈ kD (rt ?ξ2)⟧ ⟹ (the (nhop (update (rt ?ξ2) ?ip2 (?sn2, kno, val, Suc ?hops2, ?sip2, {})) ?ip2) = ?ip2 ∨ the (nhop (update (rt ?ξ2) ?ip2 (?sn2, kno, val, Suc ?hops2, ?sip2, {})) ?ip2) ∈ kD (rt ?ξ2)) ∧ (∀dip∈kD (rt ?ξ2). the (nhop (update (rt ?ξ2) ?ip2 (?sn2, kno, val, Suc ?hops2, ?sip2, {})) dip) = ?ip2 ∨ the (nhop (update (rt ?ξ2) ?ip2 (?sn2, kno, val, Suc ?hops2, ?sip2, {})) dip) ∈ kD (rt ?ξ2))›*)
show "?thesis"
(*goal: ‹paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). ∀dip∈kD (rt ξ). the (nhop (rt ξ) dip) ∈ kD (rt ξ))›*)
by (msorry)
qed
text ‹Proposition 7.22: needed in Proposition 7.4›
lemma addpreRT_welldefined:
"paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l ∈ {PRreq-:16..PRreq-:18} ⟶ dip ξ ∈ kD (rt ξ)) ∧
(l = PRreq-:17 ⟶ oip ξ ∈ kD (rt ξ)) ∧
(l = PRrep-:5 ⟶ dip ξ ∈ kD (rt ξ)) ∧
(l = PRrep-:6 ⟶ (the (nhop (rt ξ) (dip ξ))) ∈ kD (rt ξ)))"
(is "_ ⊫ onl Γ⇩A⇩O⇩D⇩V ?P")
unfolding invariant_def
(*goal: ‹Ball (reachable (paodv i) TT) (onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l ∈ {PRreq-:16..PRreq-:18} ⟶ dip ξ ∈ kD (rt ξ)) ∧ (l = PRreq-:17 ⟶ oip ξ ∈ kD (rt ξ)) ∧ (l = PRrep-:5 ⟶ dip ξ ∈ kD (rt ξ)) ∧ (l = PRrep-:6 ⟶ the (nhop (rt ξ) (dip ξ)) ∈ kD (rt ξ))))›*)
proof (standard)
(*goal: ‹⋀x. x ∈ reachable (paodv i) TT ⟹ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l ∈ {PRreq-:16..PRreq-:18} ⟶ dip ξ ∈ kD (rt ξ)) ∧ (l = PRreq-:17 ⟶ oip ξ ∈ kD (rt ξ)) ∧ (l = PRrep-:5 ⟶ dip ξ ∈ kD (rt ξ)) ∧ (l = PRrep-:6 ⟶ the (nhop (rt ξ) (dip ξ)) ∈ kD (rt ξ))) x›*)
fix s
assume "s ∈ reachable (paodv i) TT" (*‹(s::state × (state, msg, pseqp, pseqp label) seqp) ∈ reachable (paodv (i::nat)) TT›*)
then obtain ξ and p where "s = (ξ, p)" and "(ξ, p) ∈ reachable (paodv i) TT"
(*goal: ‹(⋀(ξ::state) p::(state, msg, pseqp, pseqp label) seqp. ⟦(s::state × (state, msg, pseqp, pseqp label) seqp) = (ξ, p); (ξ, p) ∈ reachable (paodv (i::nat)) TT⟧ ⟹ thesis::bool) ⟹ thesis›*)
by (metis prod.exhaust (*‹(⋀x1 x2. ?y = (x1, x2) ⟹ ?P) ⟹ ?P›*))
have "onl Γ⇩A⇩O⇩D⇩V ?P (ξ, p)"
proof (rule onlI (*‹(⋀l::?'a. l ∈ labels (?Γ::?'b ⇒ (?'c, ?'d, ?'b, ?'a) seqp) (?p::(?'c, ?'d, ?'b, ?'a) seqp) ⟹ (?P::?'e × ?'a ⇒ bool) (?ξ::?'e, l)) ⟹ onl ?Γ ?P (?ξ, ?p)›*))
(*goal: ‹⋀l. l ∈ labels Γ⇩A⇩O⇩D⇩V p ⟹ case (ξ, l) of (ξ, l) ⇒ (l ∈ {PRreq-:16..PRreq-:18} ⟶ dip ξ ∈ kD (rt ξ)) ∧ (l = PRreq-:17 ⟶ oip ξ ∈ kD (rt ξ)) ∧ (l = PRrep-:5 ⟶ dip ξ ∈ kD (rt ξ)) ∧ (l = PRrep-:6 ⟶ the (nhop (rt ξ) (dip ξ)) ∈ kD (rt ξ))›*)
fix l
assume "l ∈ labels Γ⇩A⇩O⇩D⇩V p" (*‹(l::pseqp label) ∈ labels Γ⇩A⇩O⇩D⇩V (p::(state, msg, pseqp, pseqp label) seqp)›*)
with ‹(ξ, p) ∈ reachable (paodv i) TT› (*‹(ξ, p) ∈ reachable (paodv i) TT›*) have I1: "l ∈ {PRreq-:16..PRreq-:18} ⟶ dip ξ ∈ kD(rt ξ)" and I2: "l = PRreq-:17 ⟶ oip ξ ∈ kD(rt ξ)" and I3: "l ∈ {PRrep-:2..PRrep-:6} ⟶ dip ξ ∈ kD(rt ξ)"
apply -
(*goals:
1. ‹⟦(ξ, p) ∈ reachable (paodv i) TT; l ∈ labels Γ⇩A⇩O⇩D⇩V p⟧ ⟹ l ∈ {PRreq-:16..PRreq-:18} ⟶ dip ξ ∈ kD (rt ξ)›
2. ‹⟦(ξ, p) ∈ reachable (paodv i) TT; l ∈ labels Γ⇩A⇩O⇩D⇩V p⟧ ⟹ l = PRreq-:17 ⟶ oip ξ ∈ kD (rt ξ)›
3. ‹⟦(ξ, p) ∈ reachable (paodv i) TT; l ∈ labels Γ⇩A⇩O⇩D⇩V p⟧ ⟹ l ∈ {PRrep-:2..PRrep-:6} ⟶ dip ξ ∈ kD (rt ξ)›
discuss goal 1*)
apply ((auto dest!: invariantD [OF addpreRT_partly_welldefined] (*‹?s ∈ reachable (paodv ?i1) TT ⟹ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l ∈ {PRreq-:16..PRreq-:18} ∪ {PRrep-:2..PRrep-:6} ⟶ dip ξ ∈ kD (rt ξ)) ∧ (l ∈ {PRreq-:3..PRreq-:17} ⟶ oip ξ ∈ kD (rt ξ))) ?s›*))[1])
(*discuss goal 2*)
apply ((auto dest!: invariantD [OF addpreRT_partly_welldefined] (*‹?s ∈ reachable (paodv ?i1) TT ⟹ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l ∈ {PRreq-:16..PRreq-:18} ∪ {PRrep-:2..PRrep-:6} ⟶ dip ξ ∈ kD (rt ξ)) ∧ (l ∈ {PRreq-:3..PRreq-:17} ⟶ oip ξ ∈ kD (rt ξ))) ?s›*))[1])
(*discuss goal 3*)
apply ((auto dest!: invariantD [OF addpreRT_partly_welldefined] (*‹?s ∈ reachable (paodv ?i1) TT ⟹ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l ∈ {PRreq-:16..PRreq-:18} ∪ {PRrep-:2..PRrep-:6} ⟶ dip ξ ∈ kD (rt ξ)) ∧ (l ∈ {PRreq-:3..PRreq-:17} ⟶ oip ξ ∈ kD (rt ξ))) ?s›*))[1])
(*proven 3 subgoals*) .
moreover from ‹(ξ, p) ∈ reachable (paodv i) TT› (*‹(ξ, p) ∈ reachable (paodv i) TT›*) ‹l ∈ labels Γ⇩A⇩O⇩D⇩V p› (*‹(l::pseqp label) ∈ labels Γ⇩A⇩O⇩D⇩V (p::(state, msg, pseqp, pseqp label) seqp)›*) I3 (*‹l ∈ {PRrep-:2..PRrep-:6} ⟶ dip ξ ∈ kD (rt ξ)›*) have "l = PRrep-:6 ⟶ (the (nhop (rt ξ) (dip ξ))) ∈ kD(rt ξ)"
by (auto dest!: invariantD [OF includes_nhip] (*‹(?s::state × (state, msg, pseqp, pseqp label) seqp) ∈ reachable (paodv (?i1::nat)) TT ⟹ onl Γ⇩A⇩O⇩D⇩V (λ(ξ::state, l::pseqp label). ∀dip::nat∈kD (rt ξ). the (nhop (rt ξ) dip) ∈ kD (rt ξ)) ?s›*))
ultimately show "?P (ξ, l)"
by simp
qed
with ‹s = (ξ, p)› (*‹(s::state × (state, msg, pseqp, pseqp label) seqp) = (ξ::state, p::(state, msg, pseqp, pseqp label) seqp)›*) show "onl Γ⇩A⇩O⇩D⇩V ?P s"
by simp
qed
text ‹Proposition 7.4›
lemma known_destinations_increase:
"paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ, _), _, (ξ', _)). kD (rt ξ) ⊆ kD (rt ξ'))"
by (inv_cterms inv add: onl_invariant_sterms [OF aodv_wf addpreRT_welldefined] simp add: subset_insertI)
text ‹Proposition 7.5›
lemma rreqs_increase:
"paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ, _), _, (ξ', _)). rreqs ξ ⊆ rreqs ξ')"
by (inv_cterms simp add: subset_insertI)
lemma dests_bigger_than_sqn:
"paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). l ∈ {PAodv-:15..PAodv-:19}
∪ {PPkt-:7..PPkt-:11}
∪ {PRreq-:9..PRreq-:13}
∪ {PRreq-:21..PRreq-:25}
∪ {PRrep-:10..PRrep-:14}
∪ {PRerr-:1..PRerr-:5}
⟶ (∀ip∈dom(dests ξ). ip∈kD(rt ξ) ∧ sqn (rt ξ) ip ≤ the (dests ξ ip)))"
proof (-)
(*goal: ‹paodv (i::nat) ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ::state, l::pseqp label). l ∈ {PAodv-:(15::int)..PAodv-:(19::int)} ∪ {PPkt-:(7::int)..PPkt-:(11::int)} ∪ {PRreq-:(9::int)..PRreq-:(13::int)} ∪ {PRreq-:(21::int)..PRreq-:(25::int)} ∪ {PRrep-:(10::int)..PRrep-:(14::int)} ∪ {PRerr-:(1::int)..PRerr-:(5::int)} ⟶ (∀ip::nat∈dom (dests ξ). ip ∈ kD (rt ξ) ∧ sqn (rt ξ) ip ≤ the (dests ξ ip)))›*)
have sqninv: "⋀dests rt rsn ip.
⟦ ∀ip∈dom(dests). ip∈kD(rt) ∧ sqn rt ip ≤ the (dests ip); dests ip = Some rsn ⟧
⟹ sqn (invalidate rt dests) ip ≤ rsn"
apply (rule sqn_invalidate_in_dests [THEN eq_imp_le] (*‹⟦?dests1 ?ipa1 = Some ?n; ?ipa1 ∈ kD ?rt1⟧ ⟹ sqn (invalidate ?rt1 ?dests1) ?ipa1 ≤ ?n›*))
(*goals:
1. ‹⋀dests rt rsn ip. ⟦∀ip∈dom dests. ip ∈ kD rt ∧ sqn rt ip ≤ the (dests ip); dests ip = Some rsn⟧ ⟹ dests ip = Some rsn›
2. ‹⋀dests rt rsn ip. ⟦∀ip∈dom dests. ip ∈ kD rt ∧ sqn rt ip ≤ the (dests ip); dests ip = Some rsn⟧ ⟹ ip ∈ kD rt›
discuss goal 1*)
apply assumption
(*discuss goal 2*)
apply auto
(*proven 2 subgoals*) .
have indests: "⋀dests rt rsn ip.
⟦ ∀ip∈dom(dests). ip∈kD(rt) ∧ sqn rt ip ≤ the (dests ip); dests ip = Some rsn ⟧
⟹ ip∈kD(rt) ∧ sqn rt ip ≤ rsn"
by (metis domI (*‹?m ?a = Some ?b ⟹ ?a ∈ dom ?m›*) option.sel (*‹the (Some ?x2.0) = ?x2.0›*))
show "?thesis"
(*goal: ‹paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). l ∈ {PAodv-:15..PAodv-:19} ∪ {PPkt-:7..PPkt-:11} ∪ {PRreq-:9..PRreq-:13} ∪ {PRreq-:21..PRreq-:25} ∪ {PRrep-:10..PRrep-:14} ∪ {PRerr-:1..PRerr-:5} ⟶ (∀ip∈dom (dests ξ). ip ∈ kD (rt ξ) ∧ sqn (rt ξ) ip ≤ the (dests ξ ip)))›*)
by (msorry)
qed
text ‹Proposition 7.6›
lemma sqns_increase:
"paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ, _), _, (ξ', _)). ∀ip. sqn (rt ξ) ip ≤ sqn (rt ξ') ip)"
proof (-)
(*goal: ‹paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ, uu_), uu_, ξ', uu_). ∀ip. sqn (rt ξ) ip ≤ sqn (rt ξ') ip)›*)
{
fix ξ :: state
assume "*": "∀ip∈dom(dests ξ). ip ∈ kD (rt ξ) ∧ sqn (rt ξ) ip ≤ the (dests ξ ip)" (*‹∀ip::nat∈dom (dests (ξ::state)). ip ∈ kD (rt ξ) ∧ sqn (rt ξ) ip ≤ the (dests ξ ip)›*)
have "∀ip. sqn (rt ξ) ip ≤ sqn (invalidate (rt ξ) (dests ξ)) ip"
proof (standard)
(*goal: ‹⋀ip::nat. sqn (rt (ξ::state)) ip ≤ sqn (invalidate (rt ξ) (dests ξ)) ip›*)
fix ip
from "*" (*‹∀ip∈dom (dests ξ). ip ∈ kD (rt ξ) ∧ sqn (rt ξ) ip ≤ the (dests ξ ip)›*) have "ip∉dom(dests ξ) ∨ sqn (rt ξ) ip ≤ the (dests ξ ip)"
by simp
thus "sqn (rt ξ) ip ≤ sqn (invalidate (rt ξ) (dests ξ)) ip"
by (metis domI (*‹?m ?a = Some ?b ⟹ ?a ∈ dom ?m›*) invalidate_sqn (*‹∀rsn. ?dests ?dip = Some rsn ⟶ sqn ?rt ?dip ≤ rsn ⟹ sqn ?rt ?dip ≤ sqn (invalidate ?rt ?dests) ?dip›*) option.sel (*‹the (Some ?x2.0) = ?x2.0›*))
qed
}
note solve_invalidate = this (*‹∀ip∈dom (dests ?ξ2). ip ∈ kD (rt ?ξ2) ∧ sqn (rt ?ξ2) ip ≤ the (dests ?ξ2 ip) ⟹ ∀ip. sqn (rt ?ξ2) ip ≤ sqn (invalidate (rt ?ξ2) (dests ?ξ2)) ip›*)
show "?thesis"
(*goal: ‹paodv (i::nat) ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ::state, uu_::pseqp label), uu_::msg seq_action, ξ'::state, uu_::pseqp label). ∀ip::nat. sqn (rt ξ) ip ≤ sqn (rt ξ') ip)›*)
by (inv_cterms inv add: onl_invariant_sterms [OF aodv_wf addpreRT_welldefined] onl_invariant_sterms [OF aodv_wf dests_bigger_than_sqn] simp add: solve_invalidate)
qed
text ‹Proposition 7.7›
lemma ip_constant:
"paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, _). ip ξ = i)"
by (msorry)
text ‹Proposition 7.8›
lemma sender_ip_valid':
"paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ, _), a, _). anycast (λm. not_Pkt m ⟶ msg_sender m = ip ξ) a)"
by inv_cterms
lemma sender_ip_valid:
"paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ, _), a, _). anycast (λm. not_Pkt m ⟶ msg_sender m = i) a)"
apply (rule step_invariant_weaken_with_invariantE [OF ip_constant sender_ip_valid'] (*‹(⋀s a s'. ⟦onl Γ⇩A⇩O⇩D⇩V (λ(ξ, uu_). ip ξ = ?i1) s; onl Γ⇩A⇩O⇩D⇩V (λ(ξ, uu_). ip ξ = ?i1) s'; onll Γ⇩A⇩O⇩D⇩V (λ((ξ, uu_), a, uu_). anycast (λm. not_Pkt m ⟶ msg_sender m = ip ξ) a) (s, a, s'); TT a⟧ ⟹ ?R (s, a, s')) ⟹ paodv ?i1 ⊫⇩A ?R›*))
(*goal: ‹paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ, uu_), a, uu_). anycast (λm. not_Pkt m ⟶ msg_sender m = i) a)›*)
by (auto dest!: onlD (*‹onl ?Γ ?P (?ξ, ?p) ⟹ ∀l∈labels ?Γ ?p. ?P (?ξ, l)›*) onllD (*‹onll ?Γ ?P ((?ξ, ?p), ?a, ?ξ', ?p') ⟹ ∀l∈labels ?Γ ?p. ∀l'∈labels ?Γ ?p'. ?P ((?ξ, l), ?a, ?ξ', l')›*))
lemma received_msg_inv:
"paodv i ⊫ (recvmsg P →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). l ∈ {PAodv-:1} ⟶ P (msg ξ))"
by inv_cterms
text ‹Proposition 7.9›
lemma sip_not_ip':
"paodv i ⊫ (recvmsg (λm. not_Pkt m ⟶ msg_sender m ≠ i) →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, _). sip ξ ≠ ip ξ)"
apply (inv_cterms inv add: onl_invariant_sterms [OF aodv_wf received_msg_inv] onl_invariant_sterms [OF aodv_wf ip_constant [THEN invariant_restrict_inD]] simp add: clear_locals_sip_not_ip')
(*goals:
1. ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PAodv-:1; sip ξ ≠ i; ((ξ, {PAodv-:1}⟨is_rerr⟩
p'), τ⇩s, ξ', p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PAodv-:8 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) (recvmsg (λm. not_Pkt m ⟶ msg_sender m ≠ i)); {PAodv-:1}⟨is_rerr⟩
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ', p') ∈ reachable (paodv i) (recvmsg (λm. not_Pkt m ⟶ msg_sender m ≠ i)); ip ξ = i; not_Pkt (msg ξ) ⟶ msg_sender (msg ξ) ≠ i; p = {PAodv-:1}⟨is_rerr⟩
p'; l' = PAodv-:8; a = τ⇩s; ξ' ∈ is_rerr ξ; q = p'⟧ ⟹ sip ξ' ≠ i›
2. ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PAodv-:1; sip ξ ≠ i; ((ξ, {PAodv-:1}⟨is_rrep⟩
p'), τ⇩s, ξ', p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PAodv-:6 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) (recvmsg (λm. not_Pkt m ⟶ msg_sender m ≠ i)); {PAodv-:1}⟨is_rrep⟩
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ', p') ∈ reachable (paodv i) (recvmsg (λm. not_Pkt m ⟶ msg_sender m ≠ i)); ip ξ = i; not_Pkt (msg ξ) ⟶ msg_sender (msg ξ) ≠ i; p = {PAodv-:1}⟨is_rrep⟩
p'; l' = PAodv-:6; a = τ⇩s; ξ' ∈ is_rrep ξ; q = p'⟧ ⟹ sip ξ' ≠ i›
3. ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PAodv-:1; sip ξ ≠ i; ((ξ, {PAodv-:1}⟨is_rreq⟩
p'), τ⇩s, ξ', p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PAodv-:4 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) (recvmsg (λm. not_Pkt m ⟶ msg_sender m ≠ i)); {PAodv-:1}⟨is_rreq⟩
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ', p') ∈ reachable (paodv i) (recvmsg (λm. not_Pkt m ⟶ msg_sender m ≠ i)); ip ξ = i; not_Pkt (msg ξ) ⟶ msg_sender (msg ξ) ≠ i; p = {PAodv-:1}⟨is_rreq⟩
p'; l' = PAodv-:4; a = τ⇩s; ξ' ∈ is_rreq ξ; q = p'⟧ ⟹ sip ξ' ≠ i›
discuss goal 1*)
apply clarsimp
(*discuss goal 2*)
apply clarsimp
(*discuss goal 3*)
apply clarsimp
(*proven 3 subgoals*) .
lemma sip_not_ip:
"paodv i ⊫ (recvmsg (λm. not_Pkt m ⟶ msg_sender m ≠ i) →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, _). sip ξ ≠ i)"
apply (inv_cterms inv add: onl_invariant_sterms [OF aodv_wf received_msg_inv] onl_invariant_sterms [OF aodv_wf ip_constant [THEN invariant_restrict_inD]] simp add: clear_locals_sip_not_ip')
(*goals:
1. ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PAodv-:1; sip ξ ≠ i; ((ξ, {PAodv-:1}⟨is_rerr⟩
p'), τ⇩s, ξ', p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PAodv-:8 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) (recvmsg (λm. not_Pkt m ⟶ msg_sender m ≠ i)); {PAodv-:1}⟨is_rerr⟩
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ', p') ∈ reachable (paodv i) (recvmsg (λm. not_Pkt m ⟶ msg_sender m ≠ i)); ip ξ = i; not_Pkt (msg ξ) ⟶ msg_sender (msg ξ) ≠ i; p = {PAodv-:1}⟨is_rerr⟩
p'; l' = PAodv-:8; a = τ⇩s; ξ' ∈ is_rerr ξ; q = p'⟧ ⟹ sip ξ' ≠ i›
2. ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PAodv-:1; sip ξ ≠ i; ((ξ, {PAodv-:1}⟨is_rrep⟩
p'), τ⇩s, ξ', p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PAodv-:6 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) (recvmsg (λm. not_Pkt m ⟶ msg_sender m ≠ i)); {PAodv-:1}⟨is_rrep⟩
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ', p') ∈ reachable (paodv i) (recvmsg (λm. not_Pkt m ⟶ msg_sender m ≠ i)); ip ξ = i; not_Pkt (msg ξ) ⟶ msg_sender (msg ξ) ≠ i; p = {PAodv-:1}⟨is_rrep⟩
p'; l' = PAodv-:6; a = τ⇩s; ξ' ∈ is_rrep ξ; q = p'⟧ ⟹ sip ξ' ≠ i›
3. ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PAodv-:1; sip ξ ≠ i; ((ξ, {PAodv-:1}⟨is_rreq⟩
p'), τ⇩s, ξ', p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PAodv-:4 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) (recvmsg (λm. not_Pkt m ⟶ msg_sender m ≠ i)); {PAodv-:1}⟨is_rreq⟩
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ', p') ∈ reachable (paodv i) (recvmsg (λm. not_Pkt m ⟶ msg_sender m ≠ i)); ip ξ = i; not_Pkt (msg ξ) ⟶ msg_sender (msg ξ) ≠ i; p = {PAodv-:1}⟨is_rreq⟩
p'; l' = PAodv-:4; a = τ⇩s; ξ' ∈ is_rreq ξ; q = p'⟧ ⟹ sip ξ' ≠ i›
discuss goal 1*)
apply clarsimp
(*discuss goal 2*)
apply clarsimp
(*discuss goal 3*)
apply clarsimp
(*proven 3 subgoals*) .
text ‹Neither ‹sip_not_ip'› nor ‹sip_not_ip› is needed to show loop freedom.›
text ‹Proposition 7.10›
lemma hop_count_positive:
"paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, _). ∀ip∈kD (rt ξ). the (dhops (rt ξ) ip) ≥ 1)"
by (msorry)
lemma rreq_dip_in_vD_dip_eq_ip:
"paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l ∈ {PRreq-:16..PRreq-:18} ⟶ dip ξ ∈ vD(rt ξ))
∧ (l ∈ {PRreq-:5, PRreq-:6} ⟶ dip ξ = ip ξ)
∧ (l ∈ {PRreq-:15..PRreq-:18} ⟶ dip ξ ≠ ip ξ))"
apply inv_cterms
(*goal: ‹paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l ∈ {PRreq-:16..PRreq-:18} ⟶ dip ξ ∈ vD (rt ξ)) ∧ (l ∈ {PRreq-:5, PRreq-:6} ⟶ dip ξ = ip ξ) ∧ (l ∈ {PRreq-:15..PRreq-:18} ⟶ dip ξ ≠ ip ξ))›*)
proof (elim conjE (*‹⟦(?P::bool) ∧ (?Q::bool); ⟦?P; ?Q⟧ ⟹ ?R::bool⟧ ⟹ ?R›*))
(*goal: ‹⋀(p::(state, msg, pseqp, pseqp label) seqp) (l::pseqp label) (ξ::state) (a::msg seq_action) (q::(state, msg, pseqp, pseqp label) seqp) (l'::pseqp label) (ξ'::state) (pp::(state, msg, pseqp, pseqp label) seqp) p'::(state, msg, pseqp, pseqp label) seqp. ⟦l = PRreq-:(17::int); ((ξ, {PRreq-:(17::int)}⟦λξ::state. ξ⦇rt := the (addpreRT (rt ξ) (oip ξ) {the (nhop (rt ξ) (dip ξ))})⦈⟧
p'), τ⇩s, ξ⦇rt := the (addpreRT (rt ξ) (oip ξ) {the (nhop (rt ξ) (dip ξ))})⦈, p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PRreq-:(18::int) ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv (i::nat)) TT; {PRreq-:(17::int)}⟦λξ::state. ξ⦇rt := the (addpreRT (rt ξ) (oip ξ) {the (nhop (rt ξ) (dip ξ))})⦈⟧
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ⦇rt := the (addpreRT (rt ξ) (oip ξ) {the (nhop (rt ξ) (dip ξ))})⦈, p') ∈ reachable (paodv i) TT; p = {PRreq-:(17::int)}⟦λξ::state. ξ⦇rt := the (addpreRT (rt ξ) (oip ξ) {the (nhop (rt ξ) (dip ξ))})⦈⟧
p'; l' = PRreq-:(18::int); a = τ⇩s; ξ' = ξ⦇rt := the (addpreRT (rt ξ) (oip ξ) {the (nhop (rt ξ) (dip ξ))})⦈; q = p'; dip ξ ∈ vD (rt ξ); dip ξ ≠ ip ξ⟧ ⟹ dip ξ ∈ vD (the (addpreRT (rt ξ) (oip ξ) {the (nhop (rt ξ) (dip ξ))}))›*)
fix l and ξ and pp and p'
assume "(ξ, pp) ∈ reachable (paodv i) TT" and "{PRreq-:17}⟦λξ. ξ⦇rt := the (addpreRT (rt ξ) (oip ξ) {the (nhop (rt ξ) (dip ξ))})⦈⟧ p'
∈ sterms Γ⇩A⇩O⇩D⇩V pp" and "l = PRreq-:17" and "dip ξ ∈ vD (rt ξ)" (*‹(ξ::state, pp::(state, msg, pseqp, pseqp label) seqp) ∈ reachable (paodv (i::nat)) TT› ‹{PRreq-:(17::int)}⟦λξ::state. ξ⦇rt := the (addpreRT (rt ξ) (oip ξ) {the (nhop (rt ξ) (dip ξ))})⦈⟧
(p'::(state, msg, pseqp, pseqp label) seqp) ∈ sterms Γ⇩A⇩O⇩D⇩V (pp::(state, msg, pseqp, pseqp label) seqp)› ‹(l::pseqp label) = PRreq-:(17::int)› ‹dip (ξ::state) ∈ vD (rt ξ)›*)
from this(1-3) (*‹(ξ, pp) ∈ reachable (paodv i) TT› ‹{PRreq-:(17::int)}⟦λξ::state. ξ⦇rt := the (addpreRT (rt ξ) (oip ξ) {the (nhop (rt ξ) (dip ξ))})⦈⟧
(p'::(state, msg, pseqp, pseqp label) seqp) ∈ sterms Γ⇩A⇩O⇩D⇩V (pp::(state, msg, pseqp, pseqp label) seqp)› ‹l = PRreq-:17›*) have "oip ξ ∈ kD (rt ξ)"
by (auto dest: onl_invariant_sterms [OF aodv_wf addpreRT_welldefined, where l="PRreq-:17"] (*‹⟦(?ξ, ?p) ∈ reachable (paodv ?i1) TT; ?p' ∈ sterms Γ⇩A⇩O⇩D⇩V ?p; PRreq-:17 ∈ labels Γ⇩A⇩O⇩D⇩V ?p'⟧ ⟹ case (?ξ, PRreq-:17) of (ξ, l) ⇒ (l ∈ {PRreq-:16..PRreq-:18} ⟶ dip ξ ∈ kD (rt ξ)) ∧ (l = PRreq-:17 ⟶ oip ξ ∈ kD (rt ξ)) ∧ (l = PRrep-:5 ⟶ dip ξ ∈ kD (rt ξ)) ∧ (l = PRrep-:6 ⟶ the (nhop (rt ξ) (dip ξ)) ∈ kD (rt ξ))›*))
with ‹dip ξ ∈ vD (rt ξ)› (*‹dip ξ ∈ vD (rt ξ)›*) show "dip ξ ∈ vD (the (addpreRT (rt ξ) (oip ξ) {the (nhop (rt ξ) (dip ξ))}))"
by simp
qed
text ‹Proposition 7.11›
lemma anycast_msg_zhops:
"⋀rreqid dip dsn dsk oip osn sip.
paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ(_, a, _). anycast msg_zhops a)"
apply (inv_cterms inv add: onl_invariant_sterms [OF aodv_wf rreq_dip_in_vD_dip_eq_ip [THEN invariant_restrict_inD]] onl_invariant_sterms [OF aodv_wf hop_count_positive [THEN invariant_restrict_inD]])
(*goal: ‹⋀rreqid dip dsn dsk oip osn sip. paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ(uu_, a, uu_). anycast msg_zhops a)›*)
proof (elim conjE (*‹⟦?P ∧ ?Q; ⟦?P; ?Q⟧ ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⋀p l ξ a q l' ξ' pp p' pp'. ⟦l = PRreq-:18; ((ξ, {PRreq-:18}unicast(λξ. the (nhop (rt ξ) (oip ξ)), λξ. Rrep (the (dhops (rt ξ) (dip ξ))) (dip ξ) (sqn (rt ξ) (dip ξ)) (oip ξ) (ip ξ)) .
p' ▹ pp'), unicast (the (nhop (rt ξ) (oip ξ))) (Rrep (the (dhops (rt ξ) (dip ξ))) (dip ξ) (sqn (rt ξ) (dip ξ)) (oip ξ) (ip ξ)), ξ, p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PRreq-:19 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) TT; {PRreq-:18}unicast(λξ. the (nhop (rt ξ) (oip ξ)), λξ. Rrep (the (dhops (rt ξ) (dip ξ))) (dip ξ) (sqn (rt ξ) (dip ξ)) (oip ξ) (ip ξ)) .
p' ▹ pp' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ, p') ∈ reachable (paodv i) TT; ∀ip∈kD (rt ξ). Suc 0 ≤ the (dhops (rt ξ) ip); p = {PRreq-:18}unicast(λξ. the (nhop (rt ξ) (oip ξ)), λξ. Rrep (the (dhops (rt ξ) (dip ξ))) (dip ξ) (sqn (rt ξ) (dip ξ)) (oip ξ) (ip ξ)) .
p' ▹ pp'; l' = PRreq-:19; a = unicast (the (nhop (rt ξ) (oip ξ))) (Rrep (the (dhops (rt ξ) (dip ξ))) (dip ξ) (sqn (rt ξ) (dip ξ)) (oip ξ) (ip ξ)); ξ' = ξ; q = p'; dip ξ ∈ vD (rt ξ); dip ξ ≠ ip ξ⟧ ⟹ 0 < the (dhops (rt ξ) (dip ξ))›*)
fix l and ξ and a and pp and p' and pp'
assume "(ξ, pp) ∈ reachable (paodv i) TT" and "{PRreq-:18}unicast(λξ. the (nhop (rt ξ) (oip ξ)),
λξ. Rrep (the (dhops (rt ξ) (dip ξ))) (dip ξ) (sqn (rt ξ) (dip ξ)) (oip ξ) (ip ξ)).
p' ▹ pp' ∈ sterms Γ⇩A⇩O⇩D⇩V pp" and "l = PRreq-:18" and "a = unicast (the (nhop (rt ξ) (oip ξ)))
(Rrep (the (dhops (rt ξ) (dip ξ))) (dip ξ) (sqn (rt ξ) (dip ξ)) (oip ξ) (ip ξ))" and "*": "∀ip∈kD (rt ξ). Suc 0 ≤ the (dhops (rt ξ) ip)" and "dip ξ ∈ vD (rt ξ)" (*‹(ξ::state, pp::(state, msg, pseqp, pseqp label) seqp) ∈ reachable (paodv (i::nat)) TT› ‹{PRreq-:(18::int)}unicast(λξ::state. the (nhop (rt ξ) (oip ξ)), λξ::state. Rrep (the (dhops (rt ξ) (dip ξ))) (dip ξ) (sqn (rt ξ) (dip ξ)) (oip ξ) (ip ξ)) .
(p'::(state, msg, pseqp, pseqp label) seqp) ▹ (pp'::(state, msg, pseqp, pseqp label) seqp) ∈ sterms Γ⇩A⇩O⇩D⇩V (pp::(state, msg, pseqp, pseqp label) seqp)› ‹(l::pseqp label) = PRreq-:(18::int)› ‹(a::msg seq_action) = unicast (the (nhop (rt (ξ::state)) (oip ξ))) (Rrep (the (dhops (rt ξ) (dip ξ))) (dip ξ) (sqn (rt ξ) (dip ξ)) (oip ξ) (ip ξ))› ‹∀ip::nat∈kD (rt (ξ::state)). Suc (0::nat) ≤ the (dhops (rt ξ) ip)› ‹dip (ξ::state) ∈ vD (rt ξ)›*)
from ‹dip ξ ∈ vD (rt ξ)› (*‹dip ξ ∈ vD (rt ξ)›*) have "dip ξ ∈ kD (rt ξ)"
by (rule vD_iD_gives_kD( (*‹?ip ∈ vD ?rt ⟹ ?ip ∈ kD ?rt›*) 1))
with "*" (*‹∀ip∈kD (rt ξ). Suc 0 ≤ the (dhops (rt ξ) ip)›*) have "Suc 0 ≤ the (dhops (rt ξ) (dip ξ))"
by standard
thus "0 < the (dhops (rt ξ) (dip ξ))"
by simp
qed
lemma hop_count_zero_oip_dip_sip:
"paodv i ⊫ (recvmsg msg_zhops →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l).
(l∈{PAodv-:4..PAodv-:5} ∪ {PRreq-:n|n. True} ⟶
(hops ξ = 0 ⟶ oip ξ = sip ξ))
∧
((l∈{PAodv-:6..PAodv-:7} ∪ {PRrep-:n|n. True} ⟶
(hops ξ = 0 ⟶ dip ξ = sip ξ))))"
apply (inv_cterms inv add: onl_invariant_sterms [OF aodv_wf received_msg_inv])
(*goals:
1. ‹⋀(p::(state, msg, pseqp, pseqp label) seqp) (l::pseqp label) (ξ::state) (a::msg seq_action) (q::(state, msg, pseqp, pseqp label) seqp) (l'::pseqp label) (ξ'::state) (pp::(state, msg, pseqp, pseqp label) seqp) p'::(state, msg, pseqp, pseqp label) seqp. ⟦l = PAodv-:(1::int); ((ξ, {PAodv-:(1::int)}⟨is_rrep⟩
p'), τ⇩s, ξ', p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PAodv-:(6::int) ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv (i::nat)) (recvmsg msg_zhops); {PAodv-:(1::int)}⟨is_rrep⟩
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ', p') ∈ reachable (paodv i) (recvmsg msg_zhops); msg_zhops (msg ξ); p = {PAodv-:(1::int)}⟨is_rrep⟩
p'; l' = PAodv-:(6::int); a = τ⇩s; ξ' ∈ is_rrep ξ; q = p'⟧ ⟹ hops ξ' = (0::nat) ⟶ dip ξ' = sip ξ'›
2. ‹⋀(p::(state, msg, pseqp, pseqp label) seqp) (l::pseqp label) (ξ::state) (a::msg seq_action) (q::(state, msg, pseqp, pseqp label) seqp) (l'::pseqp label) (ξ'::state) (pp::(state, msg, pseqp, pseqp label) seqp) p'::(state, msg, pseqp, pseqp label) seqp. ⟦l = PAodv-:(1::int); ((ξ, {PAodv-:(1::int)}⟨is_rreq⟩
p'), τ⇩s, ξ', p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PAodv-:(4::int) ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv (i::nat)) (recvmsg msg_zhops); {PAodv-:(1::int)}⟨is_rreq⟩
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ', p') ∈ reachable (paodv i) (recvmsg msg_zhops); msg_zhops (msg ξ); p = {PAodv-:(1::int)}⟨is_rreq⟩
p'; l' = PAodv-:(4::int); a = τ⇩s; ξ' ∈ is_rreq ξ; q = p'⟧ ⟹ hops ξ' = (0::nat) ⟶ oip ξ' = sip ξ'›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma osn_rreq:
"paodv i ⊫ (recvmsg rreq_rrep_sn →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l).
l ∈ {PAodv-:4, PAodv-:5} ∪ {PRreq-:n|n. True} ⟶ 1 ≤ osn ξ)"
apply (inv_cterms inv add: onl_invariant_sterms [OF aodv_wf received_msg_inv])
(*goal: ‹paodv i ⊫ (recvmsg rreq_rrep_sn →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). l ∈ {PAodv-:4, PAodv-:5} ∪ {PRreq-:n |n. True} ⟶ 1 ≤ osn ξ)›*)
by clarsimp
lemma osn_rreq':
"paodv i ⊫ (recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l).
l ∈ {PAodv-:4, PAodv-:5} ∪ {PRreq-:n|n. True} ⟶ 1 ≤ osn ξ)"
proof (rule invariant_weakenE [OF osn_rreq] (*‹⟦⋀s. onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). l ∈ {PAodv-:4, PAodv-:5} ∪ {PRreq-:n |n. True} ⟶ 1 ≤ osn ξ) s ⟹ ?Q s; ⋀a. ?QI a ⟹ recvmsg rreq_rrep_sn a⟧ ⟹ paodv ?i1 ⊫ (?QI →) ?Q›*))
(*goals:
1. ‹⋀s::state × (state, msg, pseqp, pseqp label) seqp. onl Γ⇩A⇩O⇩D⇩V (λ(ξ::state, l::pseqp label). l ∈ {PAodv-:(4::int), PAodv-:(5::int)} ∪ {PRreq-:n |n::int. True} ⟶ (1::nat) ≤ osn ξ) s ⟹ onl Γ⇩A⇩O⇩D⇩V (λ(ξ::state, l::pseqp label). l ∈ {PAodv-:(4::int), PAodv-:(5::int)} ∪ {PRreq-:n |n::int. True} ⟶ (1::nat) ≤ osn ξ) s›
2. ‹⋀a::msg seq_action. recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) a ⟹ recvmsg rreq_rrep_sn a›*)
fix a
assume "recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a" (*‹recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) (a::msg seq_action)›*)
thus "recvmsg rreq_rrep_sn a"
apply (cases a)
(*goals:
1. ‹⋀x1::msg. ⟦recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) (a::msg seq_action); a = broadcast x1⟧ ⟹ recvmsg rreq_rrep_sn a›
2. ‹⋀(x21::nat set) x22::msg. ⟦recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) (a::msg seq_action); a = groupcast x21 x22⟧ ⟹ recvmsg rreq_rrep_sn a›
3. ‹⋀(x31::nat) x32::msg. ⟦recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) (a::msg seq_action); a = unicast x31 x32⟧ ⟹ recvmsg rreq_rrep_sn a›
4. ‹⋀x4::nat. ⟦recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) (a::msg seq_action); a = ¬unicast x4⟧ ⟹ recvmsg rreq_rrep_sn a›
5. ‹⋀x5::msg. ⟦recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) (a::msg seq_action); a = send x5⟧ ⟹ recvmsg rreq_rrep_sn a›
6. ‹⋀x6::nat. ⟦recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) (a::msg seq_action); a = deliver x6⟧ ⟹ recvmsg rreq_rrep_sn a›
7. ‹⋀x7::msg. ⟦recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) (a::msg seq_action); a = receive x7⟧ ⟹ recvmsg rreq_rrep_sn a›
8. ‹⟦recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) (a::msg seq_action); a = τ⇩s⟧ ⟹ recvmsg rreq_rrep_sn a›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
qed
lemma dsn_rrep:
"paodv i ⊫ (recvmsg rreq_rrep_sn →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l).
l ∈ {PAodv-:6, PAodv-:7} ∪ {PRrep-:n|n. True} ⟶ 1 ≤ dsn ξ)"
apply (inv_cterms inv add: onl_invariant_sterms [OF aodv_wf received_msg_inv])
(*goal: ‹paodv i ⊫ (recvmsg rreq_rrep_sn →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). l ∈ {PAodv-:6, PAodv-:7} ∪ {PRrep-:n |n. True} ⟶ 1 ≤ dsn ξ)›*)
by clarsimp
lemma dsn_rrep':
"paodv i ⊫ (recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l).
l ∈ {PAodv-:6, PAodv-:7} ∪ {PRrep-:n|n. True} ⟶ 1 ≤ dsn ξ)"
proof (rule invariant_weakenE [OF dsn_rrep] (*‹⟦⋀s. onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). l ∈ {PAodv-:6, PAodv-:7} ∪ {PRrep-:n |n. True} ⟶ 1 ≤ dsn ξ) s ⟹ ?Q s; ⋀a. ?QI a ⟹ recvmsg rreq_rrep_sn a⟧ ⟹ paodv ?i1 ⊫ (?QI →) ?Q›*))
(*goals:
1. ‹⋀s. onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). l ∈ {PAodv-:6, PAodv-:7} ∪ {PRrep-:n |n. True} ⟶ 1 ≤ dsn ξ) s ⟹ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). l ∈ {PAodv-:6, PAodv-:7} ∪ {PRrep-:n |n. True} ⟶ 1 ≤ dsn ξ) s›
2. ‹⋀a. recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a ⟹ recvmsg rreq_rrep_sn a›*)
fix a
assume "recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a" (*‹recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) (a::msg seq_action)›*)
thus "recvmsg rreq_rrep_sn a"
apply (cases a)
(*goals:
1. ‹⋀x1. ⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = broadcast x1⟧ ⟹ recvmsg rreq_rrep_sn a›
2. ‹⋀x21 x22. ⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = groupcast x21 x22⟧ ⟹ recvmsg rreq_rrep_sn a›
3. ‹⋀x31 x32. ⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = unicast x31 x32⟧ ⟹ recvmsg rreq_rrep_sn a›
4. ‹⋀x4. ⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = ¬unicast x4⟧ ⟹ recvmsg rreq_rrep_sn a›
5. ‹⋀x5. ⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = send x5⟧ ⟹ recvmsg rreq_rrep_sn a›
6. ‹⋀x6. ⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = deliver x6⟧ ⟹ recvmsg rreq_rrep_sn a›
7. ‹⋀x7. ⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = receive x7⟧ ⟹ recvmsg rreq_rrep_sn a›
8. ‹⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = τ⇩s⟧ ⟹ recvmsg rreq_rrep_sn a›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
qed
lemma hop_count_zero_oip_dip_sip':
"paodv i ⊫ (recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l).
(l∈{PAodv-:4..PAodv-:5} ∪ {PRreq-:n|n. True} ⟶
(hops ξ = 0 ⟶ oip ξ = sip ξ))
∧
((l∈{PAodv-:6..PAodv-:7} ∪ {PRrep-:n|n. True} ⟶
(hops ξ = 0 ⟶ dip ξ = sip ξ))))"
proof (rule invariant_weakenE [OF hop_count_zero_oip_dip_sip] (*‹⟦⋀s. onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l ∈ {PAodv-:4..PAodv-:5} ∪ {PRreq-:n |n. True} ⟶ hops ξ = 0 ⟶ oip ξ = sip ξ) ∧ (l ∈ {PAodv-:6..PAodv-:7} ∪ {PRrep-:n |n. True} ⟶ hops ξ = 0 ⟶ dip ξ = sip ξ)) s ⟹ ?Q s; ⋀a. ?QI a ⟹ recvmsg msg_zhops a⟧ ⟹ paodv ?i1 ⊫ (?QI →) ?Q›*))
(*goals:
1. ‹⋀s. onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l ∈ {PAodv-:4..PAodv-:5} ∪ {PRreq-:n |n. True} ⟶ hops ξ = 0 ⟶ oip ξ = sip ξ) ∧ (l ∈ {PAodv-:6..PAodv-:7} ∪ {PRrep-:n |n. True} ⟶ hops ξ = 0 ⟶ dip ξ = sip ξ)) s ⟹ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l ∈ {PAodv-:4..PAodv-:5} ∪ {PRreq-:n |n. True} ⟶ hops ξ = 0 ⟶ oip ξ = sip ξ) ∧ (l ∈ {PAodv-:6..PAodv-:7} ∪ {PRrep-:n |n. True} ⟶ hops ξ = 0 ⟶ dip ξ = sip ξ)) s›
2. ‹⋀a. recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a ⟹ recvmsg msg_zhops a›*)
fix a
assume "recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a" (*‹recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) (a::msg seq_action)›*)
thus "recvmsg msg_zhops a"
apply (cases a)
(*goals:
1. ‹⋀x1. ⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = broadcast x1⟧ ⟹ recvmsg msg_zhops a›
2. ‹⋀x21 x22. ⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = groupcast x21 x22⟧ ⟹ recvmsg msg_zhops a›
3. ‹⋀x31 x32. ⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = unicast x31 x32⟧ ⟹ recvmsg msg_zhops a›
4. ‹⋀x4. ⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = ¬unicast x4⟧ ⟹ recvmsg msg_zhops a›
5. ‹⋀x5. ⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = send x5⟧ ⟹ recvmsg msg_zhops a›
6. ‹⋀x6. ⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = deliver x6⟧ ⟹ recvmsg msg_zhops a›
7. ‹⋀x7. ⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = receive x7⟧ ⟹ recvmsg msg_zhops a›
8. ‹⟦recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) a; a = τ⇩s⟧ ⟹ recvmsg msg_zhops a›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
qed
text ‹Proposition 7.12›
lemma zero_seq_unk_hops_one':
"paodv i ⊫ (recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, _).
∀dip∈kD(rt ξ). (sqn (rt ξ) dip = 0 ⟶ sqnf (rt ξ) dip = unk)
∧ (sqnf (rt ξ) dip = unk ⟶ the (dhops (rt ξ) dip) = 1)
∧ (the (dhops (rt ξ) dip) = 1 ⟶ the (nhop (rt ξ) dip) = dip))"
proof (-)
(*goal: ‹paodv (i::nat) ⊫ (recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ::state, uu_::pseqp label). ∀dip::nat∈kD (rt ξ). (sqn (rt ξ) dip = (0::nat) ⟶ sqnf (rt ξ) dip = unk) ∧ (sqnf (rt ξ) dip = unk ⟶ the (dhops (rt ξ) dip) = (1::nat)) ∧ (the (dhops (rt ξ) dip) = (1::nat) ⟶ the (nhop (rt ξ) dip) = dip))›*)
{
fix dip and ξ :: state and P
assume "sqn (invalidate (rt ξ) (dests ξ)) dip = 0" and all: "∀ip. sqn (rt ξ) ip ≤ sqn (invalidate (rt ξ) (dests ξ)) ip" and "*": "sqn (rt ξ) dip = 0 ⟹ P ξ dip" (*‹sqn (invalidate (rt (ξ::state)) (dests ξ)) (dip::nat) = (0::nat)› ‹∀ip::nat. sqn (rt (ξ::state)) ip ≤ sqn (invalidate (rt ξ) (dests ξ)) ip› ‹sqn (rt (ξ::state)) (dip::nat) = (0::nat) ⟹ (P::state ⇒ nat ⇒ bool) ξ dip›*)
have "P ξ dip"
proof (-)
(*goal: ‹P ξ dip›*)
from all (*‹∀ip. sqn (rt ξ) ip ≤ sqn (invalidate (rt ξ) (dests ξ)) ip›*) have "sqn (rt ξ) dip ≤ sqn (invalidate (rt ξ) (dests ξ)) dip"
by standard
with ‹sqn (invalidate (rt ξ) (dests ξ)) dip = 0› (*‹sqn (invalidate (rt ξ) (dests ξ)) dip = 0›*) have "sqn (rt ξ) dip = 0"
by simp
thus "P ξ dip"
by (rule * (*‹sqn (rt ξ) dip = 0 ⟹ P ξ dip›*))
qed
}
note sqn_invalidate_zero[elim !] = this (*‹⟦sqn (invalidate (rt (?ξ2::state)) (dests ?ξ2)) (?dip2::nat) = (0::nat); ∀ip::nat. sqn (rt ?ξ2) ip ≤ sqn (invalidate (rt ?ξ2) (dests ?ξ2)) ip; sqn (rt ?ξ2) ?dip2 = (0::nat) ⟹ (?P2::state ⇒ nat ⇒ bool) ?ξ2 ?dip2⟧ ⟹ ?P2 ?ξ2 ?dip2›*)
{
fix dsn :: nat and hops :: nat and sip and oip and rt and ip :: ip and dip :: ip
assume "∀dip∈kD(rt).
(sqn rt dip = 0 ⟶ π₃(the (rt dip)) = unk) ∧
(π₃(the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧
(the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip)" and "hops = 0 ⟶ sip = dip" and "Suc 0 ≤ dsn" and "ip ≠ dip ⟶ ip∈kD(rt)" (*‹∀dip::nat∈kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option). (sqn rt dip = (0::nat) ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc (0::nat)) ∧ (the (dhops rt dip) = Suc (0::nat) ⟶ the (nhop rt dip) = dip)› ‹(hops::nat) = (0::nat) ⟶ (sip::nat) = (dip::nat)› ‹Suc (0::nat) ≤ (dsn::nat)› ‹(ip::nat) ≠ (dip::nat) ⟶ ip ∈ kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option)›*)
hence "the (dhops (update rt dip (dsn, kno, val, Suc hops, sip, {})) ip) = Suc 0 ⟶
the (nhop (update rt dip (dsn, kno, val, Suc hops, sip, {})) ip) = ip"
apply -
(*goal: ‹the (dhops (update rt dip (dsn, kno, val, Suc hops, sip, {})) ip) = Suc 0 ⟶ the (nhop (update rt dip (dsn, kno, val, Suc hops, sip, {})) ip) = ip›*)
apply (rule update_cases (*‹⟦(π₂ ?r = 0) = (π₃ ?r = unk); ?ip ∉ kD ?rt ⟹ ?P (?rt(?ip ↦ ?r)); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip < π₂ ?r⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip = π₂ ?r; π₅ ?r < the (dhops ?rt ?ip)⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip = π₂ ?r; the (flag ?rt ?ip) = Aodv_Basic.inv⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; π₃ ?r = unk⟧ ⟹ ?P (?rt(?ip ↦ (π₂ (the (?rt ?ip)), π₃ ?r, π₄ ?r, π₅ ?r, π₆ ?r, π₇ (addpre ?r (π₇ (the (?rt ?ip))))))); ⟦?ip ∈ kD ?rt; π₂ ?r ≤ sqn ?rt ?ip; π₃ ?r = kno; sqn ?rt ?ip = π₂ ?r ⟹ the (dhops ?rt ?ip) ≤ π₅ ?r ∧ the (flag ?rt ?ip) = val⟧ ⟹ ?P (?rt(?ip ↦ addpre (the (?rt ?ip)) (π₇ ?r)))⟧ ⟹ ?P (update ?rt ?ip ?r)›*))
(*goals:
1. ‹⟦∀dip::nat∈kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option). (sqn rt dip = (0::nat) ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc (0::nat)) ∧ (the (dhops rt dip) = Suc (0::nat) ⟶ the (nhop rt dip) = dip); (hops::nat) = (0::nat) ⟶ (sip::nat) = (dip::nat); Suc (0::nat) ≤ (dsn::nat); (ip::nat) ≠ dip ⟶ ip ∈ kD rt⟧ ⟹ (π₂ (dsn, kno, val, Suc hops, sip, {}) = (0::nat)) = (π₃ (dsn, kno, val, Suc hops, sip, {}) = unk)›
2. ‹⟦∀dip::nat∈kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option). (sqn rt dip = (0::nat) ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc (0::nat)) ∧ (the (dhops rt dip) = Suc (0::nat) ⟶ the (nhop rt dip) = dip); (hops::nat) = (0::nat) ⟶ (sip::nat) = (dip::nat); Suc (0::nat) ≤ (dsn::nat); (ip::nat) ≠ dip ⟶ ip ∈ kD rt; dip ∉ kD rt⟧ ⟹ the (dhops (rt(dip ↦ (dsn, kno, val, Suc hops, sip, {}))) ip) = Suc (0::nat) ⟶ the (nhop (rt(dip ↦ (dsn, kno, val, Suc hops, sip, {}))) ip) = ip›
3. ‹⟦∀dip::nat∈kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option). (sqn rt dip = (0::nat) ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc (0::nat)) ∧ (the (dhops rt dip) = Suc (0::nat) ⟶ the (nhop rt dip) = dip); (hops::nat) = (0::nat) ⟶ (sip::nat) = (dip::nat); Suc (0::nat) ≤ (dsn::nat); (ip::nat) ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; sqn rt dip < π₂ (dsn, kno, val, Suc hops, sip, {})⟧ ⟹ the (dhops (rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip) = Suc (0::nat) ⟶ the (nhop (rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip) = ip›
4. ‹⟦∀dip::nat∈kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option). (sqn rt dip = (0::nat) ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc (0::nat)) ∧ (the (dhops rt dip) = Suc (0::nat) ⟶ the (nhop rt dip) = dip); (hops::nat) = (0::nat) ⟶ (sip::nat) = (dip::nat); Suc (0::nat) ≤ (dsn::nat); (ip::nat) ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; sqn rt dip = π₂ (dsn, kno, val, Suc hops, sip, {}); π₅ (dsn, kno, val, Suc hops, sip, {}) < the (dhops rt dip)⟧ ⟹ the (dhops (rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip) = Suc (0::nat) ⟶ the (nhop (rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip) = ip›
5. ‹⟦∀dip::nat∈kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option). (sqn rt dip = (0::nat) ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc (0::nat)) ∧ (the (dhops rt dip) = Suc (0::nat) ⟶ the (nhop rt dip) = dip); (hops::nat) = (0::nat) ⟶ (sip::nat) = (dip::nat); Suc (0::nat) ≤ (dsn::nat); (ip::nat) ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; sqn rt dip = π₂ (dsn, kno, val, Suc hops, sip, {}); the (flag rt dip) = Aodv_Basic.inv⟧ ⟹ the (dhops (rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip) = Suc (0::nat) ⟶ the (nhop (rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip) = ip›
6. ‹⟦∀dip::nat∈kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option). (sqn rt dip = (0::nat) ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc (0::nat)) ∧ (the (dhops rt dip) = Suc (0::nat) ⟶ the (nhop rt dip) = dip); (hops::nat) = (0::nat) ⟶ (sip::nat) = (dip::nat); Suc (0::nat) ≤ (dsn::nat); (ip::nat) ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; π₃ (dsn, kno, val, Suc hops, sip, {}) = unk⟧ ⟹ the (dhops (rt(dip ↦ (π₂ (the (rt dip)), π₃ (dsn, kno, val, Suc hops, sip, {}), π₄ (dsn, kno, val, Suc hops, sip, {}), π₅ (dsn, kno, val, Suc hops, sip, {}), π₆ (dsn, kno, val, Suc hops, sip, {}), π₇ (addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))))) ip) = Suc (0::nat) ⟶ the (nhop (rt(dip ↦ (π₂ (the (rt dip)), π₃ (dsn, kno, val, Suc hops, sip, {}), π₄ (dsn, kno, val, Suc hops, sip, {}), π₅ (dsn, kno, val, Suc hops, sip, {}), π₆ (dsn, kno, val, Suc hops, sip, {}), π₇ (addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))))) ip) = ip›
7. ‹⟦∀dip::nat∈kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option). (sqn rt dip = (0::nat) ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc (0::nat)) ∧ (the (dhops rt dip) = Suc (0::nat) ⟶ the (nhop rt dip) = dip); (hops::nat) = (0::nat) ⟶ (sip::nat) = (dip::nat); Suc (0::nat) ≤ (dsn::nat); (ip::nat) ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; π₂ (dsn, kno, val, Suc hops, sip, {}) ≤ sqn rt dip; π₃ (dsn, kno, val, Suc hops, sip, {}) = kno; sqn rt dip = π₂ (dsn, kno, val, Suc hops, sip, {}) ⟹ the (dhops rt dip) ≤ π₅ (dsn, kno, val, Suc hops, sip, {}) ∧ the (flag rt dip) = val⟧ ⟹ the (dhops (rt(dip ↦ addpre (the (rt dip)) (π₇ (dsn, kno, val, Suc hops, sip, {})))) ip) = Suc (0::nat) ⟶ the (nhop (rt(dip ↦ addpre (the (rt dip)) (π₇ (dsn, kno, val, Suc hops, sip, {})))) ip) = ip›
discuss goal 1*)
apply ((auto simp add: sqn_def (*‹sqn (?rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) (?dip::nat) ≡ case ?rt ?dip of None ⇒ 0::nat | Some (r::nat × k × f × nat × nat × nat set) ⇒ π₂ r›*) dest!: bspec (*‹⟦∀x::?'a∈?A::?'a set. (?P::?'a ⇒ bool) x; (?x::?'a) ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 2*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 3*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 4*)
apply ((auto simp add: sqn_def (*‹sqn (?rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) (?dip::nat) ≡ case ?rt ?dip of None ⇒ 0::nat | Some (r::nat × k × f × nat × nat × nat set) ⇒ π₂ r›*) dest!: bspec (*‹⟦∀x::?'a::type∈?A::?'a::type set. (?P::?'a::type ⇒ bool) x; (?x::?'a::type) ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 5*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 6*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 7*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*proven 7 subgoals*) .
}
note prreq_ok1[simp] = this (*‹⟦∀dip∈kD ?rt2. (sqn ?rt2 dip = 0 ⟶ π₃ (the (?rt2 dip)) = unk) ∧ (π₃ (the (?rt2 dip)) = unk ⟶ the (dhops ?rt2 dip) = Suc 0) ∧ (the (dhops ?rt2 dip) = Suc 0 ⟶ the (nhop ?rt2 dip) = dip); ?hops2 = 0 ⟶ ?sip2 = ?dip2; Suc 0 ≤ ?dsn2; ?ip2 ≠ ?dip2 ⟶ ?ip2 ∈ kD ?rt2⟧ ⟹ the (dhops (update ?rt2 ?dip2 (?dsn2, kno, val, Suc ?hops2, ?sip2, {})) ?ip2) = Suc 0 ⟶ the (nhop (update ?rt2 ?dip2 (?dsn2, kno, val, Suc ?hops2, ?sip2, {})) ?ip2) = ?ip2›*)
{
fix ip and dsn and hops and sip and oip and rt and dip
assume "∀dip∈kD(rt).
(sqn rt dip = 0 ⟶ π₃(the (rt dip)) = unk) ∧
(π₃(the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧
(the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip)" and "Suc 0 ≤ dsn" and "ip ≠ dip ⟶ ip∈kD(rt)" (*‹∀dip::nat∈kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option). (sqn rt dip = (0::nat) ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc (0::nat)) ∧ (the (dhops rt dip) = Suc (0::nat) ⟶ the (nhop rt dip) = dip)› ‹Suc (0::nat) ≤ (dsn::nat)› ‹(ip::nat) ≠ (dip::nat) ⟶ ip ∈ kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option)›*)
hence "π₃(the (update rt dip (dsn, kno, val, Suc hops, sip, {}) ip)) = unk ⟶
the (dhops (update rt dip (dsn, kno, val, Suc hops, sip, {})) ip) = Suc 0"
apply -
(*goal: ‹π₃ (the (update rt dip (dsn, kno, val, Suc hops, sip, {}) ip)) = unk ⟶ the (dhops (update rt dip (dsn, kno, val, Suc hops, sip, {})) ip) = Suc 0›*)
apply (rule update_cases (*‹⟦(π₂ ?r = 0) = (π₃ ?r = unk); ?ip ∉ kD ?rt ⟹ ?P (?rt(?ip ↦ ?r)); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip < π₂ ?r⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip = π₂ ?r; π₅ ?r < the (dhops ?rt ?ip)⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip = π₂ ?r; the (flag ?rt ?ip) = Aodv_Basic.inv⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; π₃ ?r = unk⟧ ⟹ ?P (?rt(?ip ↦ (π₂ (the (?rt ?ip)), π₃ ?r, π₄ ?r, π₅ ?r, π₆ ?r, π₇ (addpre ?r (π₇ (the (?rt ?ip))))))); ⟦?ip ∈ kD ?rt; π₂ ?r ≤ sqn ?rt ?ip; π₃ ?r = kno; sqn ?rt ?ip = π₂ ?r ⟹ the (dhops ?rt ?ip) ≤ π₅ ?r ∧ the (flag ?rt ?ip) = val⟧ ⟹ ?P (?rt(?ip ↦ addpre (the (?rt ?ip)) (π₇ ?r)))⟧ ⟹ ?P (update ?rt ?ip ?r)›*))
(*goals:
1. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); Suc 0 ≤ dsn; ip ≠ dip ⟶ ip ∈ kD rt⟧ ⟹ (π₂ (dsn, kno, val, Suc hops, sip, {}) = 0) = (π₃ (dsn, kno, val, Suc hops, sip, {}) = unk)›
2. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); Suc 0 ≤ dsn; ip ≠ dip ⟶ ip ∈ kD rt; dip ∉ kD rt⟧ ⟹ π₃ (the ((rt(dip ↦ (dsn, kno, val, Suc hops, sip, {}))) ip)) = unk ⟶ the (dhops (rt(dip ↦ (dsn, kno, val, Suc hops, sip, {}))) ip) = Suc 0›
3. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); Suc 0 ≤ dsn; ip ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; sqn rt dip < π₂ (dsn, kno, val, Suc hops, sip, {})⟧ ⟹ π₃ (the ((rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip)) = unk ⟶ the (dhops (rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip) = Suc 0›
4. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); Suc 0 ≤ dsn; ip ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; sqn rt dip = π₂ (dsn, kno, val, Suc hops, sip, {}); π₅ (dsn, kno, val, Suc hops, sip, {}) < the (dhops rt dip)⟧ ⟹ π₃ (the ((rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip)) = unk ⟶ the (dhops (rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip) = Suc 0›
5. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); Suc 0 ≤ dsn; ip ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; sqn rt dip = π₂ (dsn, kno, val, Suc hops, sip, {}); the (flag rt dip) = Aodv_Basic.inv⟧ ⟹ π₃ (the ((rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip)) = unk ⟶ the (dhops (rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip) = Suc 0›
6. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); Suc 0 ≤ dsn; ip ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; π₃ (dsn, kno, val, Suc hops, sip, {}) = unk⟧ ⟹ π₃ (the ((rt(dip ↦ (π₂ (the (rt dip)), π₃ (dsn, kno, val, Suc hops, sip, {}), π₄ (dsn, kno, val, Suc hops, sip, {}), π₅ (dsn, kno, val, Suc hops, sip, {}), π₆ (dsn, kno, val, Suc hops, sip, {}), π₇ (addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))))) ip)) = unk ⟶ the (dhops (rt(dip ↦ (π₂ (the (rt dip)), π₃ (dsn, kno, val, Suc hops, sip, {}), π₄ (dsn, kno, val, Suc hops, sip, {}), π₅ (dsn, kno, val, Suc hops, sip, {}), π₆ (dsn, kno, val, Suc hops, sip, {}), π₇ (addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))))) ip) = Suc 0›
7. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); Suc 0 ≤ dsn; ip ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; π₂ (dsn, kno, val, Suc hops, sip, {}) ≤ sqn rt dip; π₃ (dsn, kno, val, Suc hops, sip, {}) = kno; sqn rt dip = π₂ (dsn, kno, val, Suc hops, sip, {}) ⟹ the (dhops rt dip) ≤ π₅ (dsn, kno, val, Suc hops, sip, {}) ∧ the (flag rt dip) = val⟧ ⟹ π₃ (the ((rt(dip ↦ addpre (the (rt dip)) (π₇ (dsn, kno, val, Suc hops, sip, {})))) ip)) = unk ⟶ the (dhops (rt(dip ↦ addpre (the (rt dip)) (π₇ (dsn, kno, val, Suc hops, sip, {})))) ip) = Suc 0›
discuss goal 1*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) sqnf_def (*‹sqnf ?rt ?dip ≡ case ?rt ?dip of None ⇒ unk | Some r ⇒ π₃ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 2*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) sqnf_def (*‹sqnf ?rt ?dip ≡ case ?rt ?dip of None ⇒ unk | Some r ⇒ π₃ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 3*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) sqnf_def (*‹sqnf ?rt ?dip ≡ case ?rt ?dip of None ⇒ unk | Some r ⇒ π₃ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 4*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) sqnf_def (*‹sqnf ?rt ?dip ≡ case ?rt ?dip of None ⇒ unk | Some r ⇒ π₃ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 5*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) sqnf_def (*‹sqnf ?rt ?dip ≡ case ?rt ?dip of None ⇒ unk | Some r ⇒ π₃ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 6*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) sqnf_def (*‹sqnf ?rt ?dip ≡ case ?rt ?dip of None ⇒ unk | Some r ⇒ π₃ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 7*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) sqnf_def (*‹sqnf ?rt ?dip ≡ case ?rt ?dip of None ⇒ unk | Some r ⇒ π₃ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*proven 7 subgoals*) .
}
note prreq_ok2[simp] = this (*‹⟦∀dip∈kD ?rt2. (sqn ?rt2 dip = 0 ⟶ π₃ (the (?rt2 dip)) = unk) ∧ (π₃ (the (?rt2 dip)) = unk ⟶ the (dhops ?rt2 dip) = Suc 0) ∧ (the (dhops ?rt2 dip) = Suc 0 ⟶ the (nhop ?rt2 dip) = dip); Suc 0 ≤ ?dsn2; ?ip2 ≠ ?dip2 ⟶ ?ip2 ∈ kD ?rt2⟧ ⟹ π₃ (the (update ?rt2 ?dip2 (?dsn2, kno, val, Suc ?hops2, ?sip2, {}) ?ip2)) = unk ⟶ the (dhops (update ?rt2 ?dip2 (?dsn2, kno, val, Suc ?hops2, ?sip2, {})) ?ip2) = Suc 0›*)
{
fix ip and dsn and hops and sip and oip and rt and dip
assume "∀dip∈kD(rt).
(sqn rt dip = 0 ⟶ π₃(the (rt dip)) = unk) ∧
(π₃(the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧
(the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip)" and "Suc 0 ≤ dsn" and "ip ≠ dip ⟶ ip∈kD(rt)" (*‹∀dip::nat∈kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option). (sqn rt dip = (0::nat) ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc (0::nat)) ∧ (the (dhops rt dip) = Suc (0::nat) ⟶ the (nhop rt dip) = dip)› ‹Suc (0::nat) ≤ (dsn::nat)› ‹(ip::nat) ≠ (dip::nat) ⟶ ip ∈ kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option)›*)
hence "sqn (update rt dip (dsn, kno, val, Suc hops, sip, {})) ip = 0 ⟶
π₃ (the (update rt dip (dsn, kno, val, Suc hops, sip, {}) ip)) = unk"
apply -
(*goal: ‹sqn (update rt dip (dsn, kno, val, Suc hops, sip, {})) ip = 0 ⟶ π₃ (the (update rt dip (dsn, kno, val, Suc hops, sip, {}) ip)) = unk›*)
apply (rule update_cases (*‹⟦(π₂ (?r::nat × k × f × nat × nat × nat set) = (0::nat)) = (π₃ ?r = unk); (?ip::nat) ∉ kD (?rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) ⟹ (?P::(nat ⇒ (nat × k × f × nat × nat × nat set) option) ⇒ bool) (?rt(?ip ↦ ?r)); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip < π₂ ?r⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip = π₂ ?r; π₅ ?r < the (dhops ?rt ?ip)⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip = π₂ ?r; the (flag ?rt ?ip) = Aodv_Basic.inv⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; π₃ ?r = unk⟧ ⟹ ?P (?rt(?ip ↦ (π₂ (the (?rt ?ip)), π₃ ?r, π₄ ?r, π₅ ?r, π₆ ?r, π₇ (addpre ?r (π₇ (the (?rt ?ip))))))); ⟦?ip ∈ kD ?rt; π₂ ?r ≤ sqn ?rt ?ip; π₃ ?r = kno; sqn ?rt ?ip = π₂ ?r ⟹ the (dhops ?rt ?ip) ≤ π₅ ?r ∧ the (flag ?rt ?ip) = val⟧ ⟹ ?P (?rt(?ip ↦ addpre (the (?rt ?ip)) (π₇ ?r)))⟧ ⟹ ?P (update ?rt ?ip ?r)›*))
(*goals:
1. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); Suc 0 ≤ dsn; ip ≠ dip ⟶ ip ∈ kD rt⟧ ⟹ (π₂ (dsn, kno, val, Suc hops, sip, {}) = 0) = (π₃ (dsn, kno, val, Suc hops, sip, {}) = unk)›
2. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); Suc 0 ≤ dsn; ip ≠ dip ⟶ ip ∈ kD rt; dip ∉ kD rt⟧ ⟹ sqn (rt(dip ↦ (dsn, kno, val, Suc hops, sip, {}))) ip = 0 ⟶ π₃ (the ((rt(dip ↦ (dsn, kno, val, Suc hops, sip, {}))) ip)) = unk›
3. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); Suc 0 ≤ dsn; ip ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; sqn rt dip < π₂ (dsn, kno, val, Suc hops, sip, {})⟧ ⟹ sqn (rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip = 0 ⟶ π₃ (the ((rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip)) = unk›
4. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); Suc 0 ≤ dsn; ip ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; sqn rt dip = π₂ (dsn, kno, val, Suc hops, sip, {}); π₅ (dsn, kno, val, Suc hops, sip, {}) < the (dhops rt dip)⟧ ⟹ sqn (rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip = 0 ⟶ π₃ (the ((rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip)) = unk›
5. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); Suc 0 ≤ dsn; ip ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; sqn rt dip = π₂ (dsn, kno, val, Suc hops, sip, {}); the (flag rt dip) = Aodv_Basic.inv⟧ ⟹ sqn (rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip = 0 ⟶ π₃ (the ((rt(dip ↦ addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))) ip)) = unk›
6. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); Suc 0 ≤ dsn; ip ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; π₃ (dsn, kno, val, Suc hops, sip, {}) = unk⟧ ⟹ sqn (rt(dip ↦ (π₂ (the (rt dip)), π₃ (dsn, kno, val, Suc hops, sip, {}), π₄ (dsn, kno, val, Suc hops, sip, {}), π₅ (dsn, kno, val, Suc hops, sip, {}), π₆ (dsn, kno, val, Suc hops, sip, {}), π₇ (addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))))) ip = 0 ⟶ π₃ (the ((rt(dip ↦ (π₂ (the (rt dip)), π₃ (dsn, kno, val, Suc hops, sip, {}), π₄ (dsn, kno, val, Suc hops, sip, {}), π₅ (dsn, kno, val, Suc hops, sip, {}), π₆ (dsn, kno, val, Suc hops, sip, {}), π₇ (addpre (dsn, kno, val, Suc hops, sip, {}) (π₇ (the (rt dip))))))) ip)) = unk›
7. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); Suc 0 ≤ dsn; ip ≠ dip ⟶ ip ∈ kD rt; dip ∈ kD rt; π₂ (dsn, kno, val, Suc hops, sip, {}) ≤ sqn rt dip; π₃ (dsn, kno, val, Suc hops, sip, {}) = kno; sqn rt dip = π₂ (dsn, kno, val, Suc hops, sip, {}) ⟹ the (dhops rt dip) ≤ π₅ (dsn, kno, val, Suc hops, sip, {}) ∧ the (flag rt dip) = val⟧ ⟹ sqn (rt(dip ↦ addpre (the (rt dip)) (π₇ (dsn, kno, val, Suc hops, sip, {})))) ip = 0 ⟶ π₃ (the ((rt(dip ↦ addpre (the (rt dip)) (π₇ (dsn, kno, val, Suc hops, sip, {})))) ip)) = unk›
discuss goal 1*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 2*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 3*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 4*)
apply ((auto simp add: sqn_def (*‹sqn (?rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) (?dip::nat) ≡ case ?rt ?dip of None ⇒ 0::nat | Some (r::nat × k × f × nat × nat × nat set) ⇒ π₂ r›*) dest!: bspec (*‹⟦∀x::?'a∈?A::?'a set. (?P::?'a ⇒ bool) x; (?x::?'a) ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 5*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 6*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*discuss goal 7*)
apply ((auto simp add: sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*) dest!: bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))[1])
(*proven 7 subgoals*) .
}
note prreq_ok3[simp] = this (*‹⟦∀dip∈kD ?rt2. (sqn ?rt2 dip = 0 ⟶ π₃ (the (?rt2 dip)) = unk) ∧ (π₃ (the (?rt2 dip)) = unk ⟶ the (dhops ?rt2 dip) = Suc 0) ∧ (the (dhops ?rt2 dip) = Suc 0 ⟶ the (nhop ?rt2 dip) = dip); Suc 0 ≤ ?dsn2; ?ip2 ≠ ?dip2 ⟶ ?ip2 ∈ kD ?rt2⟧ ⟹ sqn (update ?rt2 ?dip2 (?dsn2, kno, val, Suc ?hops2, ?sip2, {})) ?ip2 = 0 ⟶ π₃ (the (update ?rt2 ?dip2 (?dsn2, kno, val, Suc ?hops2, ?sip2, {}) ?ip2)) = unk›*)
{
fix rt and sip
assume "∀dip∈kD rt.
(sqn rt dip = 0 ⟶ π₃(the (rt dip)) = unk) ∧
(π₃(the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧
(the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip)" (*‹∀dip::nat∈kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option). (sqn rt dip = (0::nat) ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc (0::nat)) ∧ (the (dhops rt dip) = Suc (0::nat) ⟶ the (nhop rt dip) = dip)›*)
hence "∀dip∈kD rt.
(sqn (update rt sip (0, unk, val, Suc 0, sip, {})) dip = 0 ⟶
π₃(the (update rt sip (0, unk, val, Suc 0, sip, {}) dip)) = unk)
∧ (π₃(the (update rt sip (0, unk, val, Suc 0, sip, {}) dip)) = unk ⟶
the (dhops (update rt sip (0, unk, val, Suc 0, sip, {})) dip) = Suc 0)
∧ (the (dhops (update rt sip (0, unk, val, Suc 0, sip, {})) dip) = Suc 0 ⟶
the (nhop (update rt sip (0, unk, val, Suc 0, sip, {})) dip) = dip)"
apply -
(*goal: ‹∀dip∈kD rt. (sqn (update rt sip (0, unk, val, Suc 0, sip, {})) dip = 0 ⟶ π₃ (the (update rt sip (0, unk, val, Suc 0, sip, {}) dip)) = unk) ∧ (π₃ (the (update rt sip (0, unk, val, Suc 0, sip, {}) dip)) = unk ⟶ the (dhops (update rt sip (0, unk, val, Suc 0, sip, {})) dip) = Suc 0) ∧ (the (dhops (update rt sip (0, unk, val, Suc 0, sip, {})) dip) = Suc 0 ⟶ the (nhop (update rt sip (0, unk, val, Suc 0, sip, {})) dip) = dip)›*)
apply (rule update_cases (*‹⟦(π₂ (?r::nat × k × f × nat × nat × nat set) = (0::nat)) = (π₃ ?r = unk); (?ip::nat) ∉ kD (?rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) ⟹ (?P::(nat ⇒ (nat × k × f × nat × nat × nat set) option) ⇒ bool) (?rt(?ip ↦ ?r)); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip < π₂ ?r⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip = π₂ ?r; π₅ ?r < the (dhops ?rt ?ip)⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip = π₂ ?r; the (flag ?rt ?ip) = Aodv_Basic.inv⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; π₃ ?r = unk⟧ ⟹ ?P (?rt(?ip ↦ (π₂ (the (?rt ?ip)), π₃ ?r, π₄ ?r, π₅ ?r, π₆ ?r, π₇ (addpre ?r (π₇ (the (?rt ?ip))))))); ⟦?ip ∈ kD ?rt; π₂ ?r ≤ sqn ?rt ?ip; π₃ ?r = kno; sqn ?rt ?ip = π₂ ?r ⟹ the (dhops ?rt ?ip) ≤ π₅ ?r ∧ the (flag ?rt ?ip) = val⟧ ⟹ ?P (?rt(?ip ↦ addpre (the (?rt ?ip)) (π₇ ?r)))⟧ ⟹ ?P (update ?rt ?ip ?r)›*))
(*goals:
1. ‹∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip) ⟹ (π₂ (0, unk, val, Suc 0, sip, {}) = 0) = (π₃ (0, unk, val, Suc 0, sip, {}) = unk)›
2. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); sip ∉ kD rt⟧ ⟹ ∀dip∈kD rt. (sqn (rt(sip ↦ (0, unk, val, Suc 0, sip, {}))) dip = 0 ⟶ π₃ (the ((rt(sip ↦ (0, unk, val, Suc 0, sip, {}))) dip)) = unk) ∧ (π₃ (the ((rt(sip ↦ (0, unk, val, Suc 0, sip, {}))) dip)) = unk ⟶ the (dhops (rt(sip ↦ (0, unk, val, Suc 0, sip, {}))) dip) = Suc 0) ∧ (the (dhops (rt(sip ↦ (0, unk, val, Suc 0, sip, {}))) dip) = Suc 0 ⟶ the (nhop (rt(sip ↦ (0, unk, val, Suc 0, sip, {}))) dip) = dip)›
3. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); sip ∈ kD rt; sqn rt sip < π₂ (0, unk, val, Suc 0, sip, {})⟧ ⟹ ∀dip∈kD rt. (sqn (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip = 0 ⟶ π₃ (the ((rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip)) = unk) ∧ (π₃ (the ((rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip)) = unk ⟶ the (dhops (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip) = Suc 0) ∧ (the (dhops (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip) = Suc 0 ⟶ the (nhop (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip) = dip)›
4. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); sip ∈ kD rt; sqn rt sip = π₂ (0, unk, val, Suc 0, sip, {}); π₅ (0, unk, val, Suc 0, sip, {}) < the (dhops rt sip)⟧ ⟹ ∀dip∈kD rt. (sqn (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip = 0 ⟶ π₃ (the ((rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip)) = unk) ∧ (π₃ (the ((rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip)) = unk ⟶ the (dhops (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip) = Suc 0) ∧ (the (dhops (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip) = Suc 0 ⟶ the (nhop (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip) = dip)›
5. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); sip ∈ kD rt; sqn rt sip = π₂ (0, unk, val, Suc 0, sip, {}); the (flag rt sip) = Aodv_Basic.inv⟧ ⟹ ∀dip∈kD rt. (sqn (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip = 0 ⟶ π₃ (the ((rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip)) = unk) ∧ (π₃ (the ((rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip)) = unk ⟶ the (dhops (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip) = Suc 0) ∧ (the (dhops (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip) = Suc 0 ⟶ the (nhop (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) dip) = dip)›
6. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); sip ∈ kD rt; π₃ (0, unk, val, Suc 0, sip, {}) = unk⟧ ⟹ ∀dip∈kD rt. (sqn (rt(sip ↦ (π₂ (the (rt sip)), π₃ (0, unk, val, Suc 0, sip, {}), π₄ (0, unk, val, Suc 0, sip, {}), π₅ (0, unk, val, Suc 0, sip, {}), π₆ (0, unk, val, Suc 0, sip, {}), π₇ (addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))))) dip = 0 ⟶ π₃ (the ((rt(sip ↦ (π₂ (the (rt sip)), π₃ (0, unk, val, Suc 0, sip, {}), π₄ (0, unk, val, Suc 0, sip, {}), π₅ (0, unk, val, Suc 0, sip, {}), π₆ (0, unk, val, Suc 0, sip, {}), π₇ (addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))))) dip)) = unk) ∧ (π₃ (the ((rt(sip ↦ (π₂ (the (rt sip)), π₃ (0, unk, val, Suc 0, sip, {}), π₄ (0, unk, val, Suc 0, sip, {}), π₅ (0, unk, val, Suc 0, sip, {}), π₆ (0, unk, val, Suc 0, sip, {}), π₇ (addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))))) dip)) = unk ⟶ the (dhops (rt(sip ↦ (π₂ (the (rt sip)), π₃ (0, unk, val, Suc 0, sip, {}), π₄ (0, unk, val, Suc 0, sip, {}), π₅ (0, unk, val, Suc 0, sip, {}), π₆ (0, unk, val, Suc 0, sip, {}), π₇ (addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))))) dip) = Suc 0) ∧ (the (dhops (rt(sip ↦ (π₂ (the (rt sip)), π₃ (0, unk, val, Suc 0, sip, {}), π₄ (0, unk, val, Suc 0, sip, {}), π₅ (0, unk, val, Suc 0, sip, {}), π₆ (0, unk, val, Suc 0, sip, {}), π₇ (addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))))) dip) = Suc 0 ⟶ the (nhop (rt(sip ↦ (π₂ (the (rt sip)), π₃ (0, unk, val, Suc 0, sip, {}), π₄ (0, unk, val, Suc 0, sip, {}), π₅ (0, unk, val, Suc 0, sip, {}), π₆ (0, unk, val, Suc 0, sip, {}), π₇ (addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))))) dip) = dip)›
7. ‹⟦∀dip∈kD rt. (sqn rt dip = 0 ⟶ π₃ (the (rt dip)) = unk) ∧ (π₃ (the (rt dip)) = unk ⟶ the (dhops rt dip) = Suc 0) ∧ (the (dhops rt dip) = Suc 0 ⟶ the (nhop rt dip) = dip); sip ∈ kD rt; π₂ (0, unk, val, Suc 0, sip, {}) ≤ sqn rt sip; π₃ (0, unk, val, Suc 0, sip, {}) = kno; sqn rt sip = π₂ (0, unk, val, Suc 0, sip, {}) ⟹ the (dhops rt sip) ≤ π₅ (0, unk, val, Suc 0, sip, {}) ∧ the (flag rt sip) = val⟧ ⟹ ∀dip∈kD rt. (sqn (rt(sip ↦ addpre (the (rt sip)) (π₇ (0, unk, val, Suc 0, sip, {})))) dip = 0 ⟶ π₃ (the ((rt(sip ↦ addpre (the (rt sip)) (π₇ (0, unk, val, Suc 0, sip, {})))) dip)) = unk) ∧ (π₃ (the ((rt(sip ↦ addpre (the (rt sip)) (π₇ (0, unk, val, Suc 0, sip, {})))) dip)) = unk ⟶ the (dhops (rt(sip ↦ addpre (the (rt sip)) (π₇ (0, unk, val, Suc 0, sip, {})))) dip) = Suc 0) ∧ (the (dhops (rt(sip ↦ addpre (the (rt sip)) (π₇ (0, unk, val, Suc 0, sip, {})))) dip) = Suc 0 ⟶ the (nhop (rt(sip ↦ addpre (the (rt sip)) (π₇ (0, unk, val, Suc 0, sip, {})))) dip) = dip)›
discuss goal 1*)
apply (simp add: sqnf_def (*‹sqnf ?rt ?dip ≡ case ?rt ?dip of None ⇒ unk | Some r ⇒ π₃ r›*) sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*))
(*discuss goal 2*)
apply (simp add: sqnf_def (*‹sqnf ?rt ?dip ≡ case ?rt ?dip of None ⇒ unk | Some r ⇒ π₃ r›*) sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*))
(*discuss goal 3*)
apply (simp add: sqnf_def (*‹sqnf ?rt ?dip ≡ case ?rt ?dip of None ⇒ unk | Some r ⇒ π₃ r›*) sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*))
(*discuss goal 4*)
apply (simp add: sqnf_def (*‹sqnf (?rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) (?dip::nat) ≡ case ?rt ?dip of None ⇒ unk | Some (r::nat × k × f × nat × nat × nat set) ⇒ π₃ r›*) sqn_def (*‹sqn (?rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) (?dip::nat) ≡ case ?rt ?dip of None ⇒ 0::nat | Some (r::nat × k × f × nat × nat × nat set) ⇒ π₂ r›*))
(*discuss goal 5*)
apply (simp add: sqnf_def (*‹sqnf ?rt ?dip ≡ case ?rt ?dip of None ⇒ unk | Some r ⇒ π₃ r›*) sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*))
(*discuss goal 6*)
apply (simp add: sqnf_def (*‹sqnf ?rt ?dip ≡ case ?rt ?dip of None ⇒ unk | Some r ⇒ π₃ r›*) sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*))
(*discuss goal 7*)
apply (simp add: sqnf_def (*‹sqnf ?rt ?dip ≡ case ?rt ?dip of None ⇒ unk | Some r ⇒ π₃ r›*) sqn_def (*‹sqn ?rt ?dip ≡ case ?rt ?dip of None ⇒ 0 | Some r ⇒ π₂ r›*))
(*proven 7 subgoals*) .
}
note prreq_ok4[simp] = this (*‹∀dip∈kD ?rt2. (sqn ?rt2 dip = 0 ⟶ π₃ (the (?rt2 dip)) = unk) ∧ (π₃ (the (?rt2 dip)) = unk ⟶ the (dhops ?rt2 dip) = Suc 0) ∧ (the (dhops ?rt2 dip) = Suc 0 ⟶ the (nhop ?rt2 dip) = dip) ⟹ ∀dip∈kD ?rt2. (sqn (update ?rt2 ?sip2 (0, unk, val, Suc 0, ?sip2, {})) dip = 0 ⟶ π₃ (the (update ?rt2 ?sip2 (0, unk, val, Suc 0, ?sip2, {}) dip)) = unk) ∧ (π₃ (the (update ?rt2 ?sip2 (0, unk, val, Suc 0, ?sip2, {}) dip)) = unk ⟶ the (dhops (update ?rt2 ?sip2 (0, unk, val, Suc 0, ?sip2, {})) dip) = Suc 0) ∧ (the (dhops (update ?rt2 ?sip2 (0, unk, val, Suc 0, ?sip2, {})) dip) = Suc 0 ⟶ the (nhop (update ?rt2 ?sip2 (0, unk, val, Suc 0, ?sip2, {})) dip) = dip)›*)
have prreq_ok5[simp]: "⋀sip rt.
π₃(the (update rt sip (0, unk, val, Suc 0, sip, {}) sip)) = unk ⟶
the (dhops (update rt sip (0, unk, val, Suc 0, sip, {})) sip) = Suc 0"
apply (rule update_cases (*‹⟦(π₂ ?r = 0) = (π₃ ?r = unk); ?ip ∉ kD ?rt ⟹ ?P (?rt(?ip ↦ ?r)); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip < π₂ ?r⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip = π₂ ?r; π₅ ?r < the (dhops ?rt ?ip)⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip = π₂ ?r; the (flag ?rt ?ip) = Aodv_Basic.inv⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; π₃ ?r = unk⟧ ⟹ ?P (?rt(?ip ↦ (π₂ (the (?rt ?ip)), π₃ ?r, π₄ ?r, π₅ ?r, π₆ ?r, π₇ (addpre ?r (π₇ (the (?rt ?ip))))))); ⟦?ip ∈ kD ?rt; π₂ ?r ≤ sqn ?rt ?ip; π₃ ?r = kno; sqn ?rt ?ip = π₂ ?r ⟹ the (dhops ?rt ?ip) ≤ π₅ ?r ∧ the (flag ?rt ?ip) = val⟧ ⟹ ?P (?rt(?ip ↦ addpre (the (?rt ?ip)) (π₇ ?r)))⟧ ⟹ ?P (update ?rt ?ip ?r)›*))
(*goals:
1. ‹⋀sip rt. (π₂ (0, unk, val, Suc 0, sip, {}) = 0) = (π₃ (0, unk, val, Suc 0, sip, {}) = unk)›
2. ‹⋀sip rt. sip ∉ kD rt ⟹ π₃ (the ((rt(sip ↦ (0, unk, val, Suc 0, sip, {}))) sip)) = unk ⟶ the (dhops (rt(sip ↦ (0, unk, val, Suc 0, sip, {}))) sip) = Suc 0›
3. ‹⋀sip rt. ⟦sip ∈ kD rt; sqn rt sip < π₂ (0, unk, val, Suc 0, sip, {})⟧ ⟹ π₃ (the ((rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) sip)) = unk ⟶ the (dhops (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) sip) = Suc 0›
4. ‹⋀sip rt. ⟦sip ∈ kD rt; sqn rt sip = π₂ (0, unk, val, Suc 0, sip, {}); π₅ (0, unk, val, Suc 0, sip, {}) < the (dhops rt sip)⟧ ⟹ π₃ (the ((rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) sip)) = unk ⟶ the (dhops (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) sip) = Suc 0›
5. ‹⋀sip rt. ⟦sip ∈ kD rt; sqn rt sip = π₂ (0, unk, val, Suc 0, sip, {}); the (flag rt sip) = Aodv_Basic.inv⟧ ⟹ π₃ (the ((rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) sip)) = unk ⟶ the (dhops (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) sip) = Suc 0›
6. ‹⋀sip rt. ⟦sip ∈ kD rt; π₃ (0, unk, val, Suc 0, sip, {}) = unk⟧ ⟹ π₃ (the ((rt(sip ↦ (π₂ (the (rt sip)), π₃ (0, unk, val, Suc 0, sip, {}), π₄ (0, unk, val, Suc 0, sip, {}), π₅ (0, unk, val, Suc 0, sip, {}), π₆ (0, unk, val, Suc 0, sip, {}), π₇ (addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))))) sip)) = unk ⟶ the (dhops (rt(sip ↦ (π₂ (the (rt sip)), π₃ (0, unk, val, Suc 0, sip, {}), π₄ (0, unk, val, Suc 0, sip, {}), π₅ (0, unk, val, Suc 0, sip, {}), π₆ (0, unk, val, Suc 0, sip, {}), π₇ (addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))))) sip) = Suc 0›
7. ‹⋀sip rt. ⟦sip ∈ kD rt; π₂ (0, unk, val, Suc 0, sip, {}) ≤ sqn rt sip; π₃ (0, unk, val, Suc 0, sip, {}) = kno; sqn rt sip = π₂ (0, unk, val, Suc 0, sip, {}) ⟹ the (dhops rt sip) ≤ π₅ (0, unk, val, Suc 0, sip, {}) ∧ the (flag rt sip) = val⟧ ⟹ π₃ (the ((rt(sip ↦ addpre (the (rt sip)) (π₇ (0, unk, val, Suc 0, sip, {})))) sip)) = unk ⟶ the (dhops (rt(sip ↦ addpre (the (rt sip)) (π₇ (0, unk, val, Suc 0, sip, {})))) sip) = Suc 0›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*proven 7 subgoals*) .
have prreq_ok6[simp]: "⋀sip rt.
sqn (update rt sip (0, unk, val, Suc 0, sip, {})) sip = 0 ⟶
π₃ (the (update rt sip (0, unk, val, Suc 0, sip, {}) sip)) = unk"
apply (rule update_cases (*‹⟦(π₂ (?r::nat × k × f × nat × nat × nat set) = (0::nat)) = (π₃ ?r = unk); (?ip::nat) ∉ kD (?rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) ⟹ (?P::(nat ⇒ (nat × k × f × nat × nat × nat set) option) ⇒ bool) (?rt(?ip ↦ ?r)); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip < π₂ ?r⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip = π₂ ?r; π₅ ?r < the (dhops ?rt ?ip)⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; sqn ?rt ?ip = π₂ ?r; the (flag ?rt ?ip) = Aodv_Basic.inv⟧ ⟹ ?P (?rt(?ip ↦ addpre ?r (π₇ (the (?rt ?ip))))); ⟦?ip ∈ kD ?rt; π₃ ?r = unk⟧ ⟹ ?P (?rt(?ip ↦ (π₂ (the (?rt ?ip)), π₃ ?r, π₄ ?r, π₅ ?r, π₆ ?r, π₇ (addpre ?r (π₇ (the (?rt ?ip))))))); ⟦?ip ∈ kD ?rt; π₂ ?r ≤ sqn ?rt ?ip; π₃ ?r = kno; sqn ?rt ?ip = π₂ ?r ⟹ the (dhops ?rt ?ip) ≤ π₅ ?r ∧ the (flag ?rt ?ip) = val⟧ ⟹ ?P (?rt(?ip ↦ addpre (the (?rt ?ip)) (π₇ ?r)))⟧ ⟹ ?P (update ?rt ?ip ?r)›*))
(*goals:
1. ‹⋀sip rt. (π₂ (0, unk, val, Suc 0, sip, {}) = 0) = (π₃ (0, unk, val, Suc 0, sip, {}) = unk)›
2. ‹⋀sip rt. sip ∉ kD rt ⟹ sqn (rt(sip ↦ (0, unk, val, Suc 0, sip, {}))) sip = 0 ⟶ π₃ (the ((rt(sip ↦ (0, unk, val, Suc 0, sip, {}))) sip)) = unk›
3. ‹⋀sip rt. ⟦sip ∈ kD rt; sqn rt sip < π₂ (0, unk, val, Suc 0, sip, {})⟧ ⟹ sqn (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) sip = 0 ⟶ π₃ (the ((rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) sip)) = unk›
4. ‹⋀sip rt. ⟦sip ∈ kD rt; sqn rt sip = π₂ (0, unk, val, Suc 0, sip, {}); π₅ (0, unk, val, Suc 0, sip, {}) < the (dhops rt sip)⟧ ⟹ sqn (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) sip = 0 ⟶ π₃ (the ((rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) sip)) = unk›
5. ‹⋀sip rt. ⟦sip ∈ kD rt; sqn rt sip = π₂ (0, unk, val, Suc 0, sip, {}); the (flag rt sip) = Aodv_Basic.inv⟧ ⟹ sqn (rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) sip = 0 ⟶ π₃ (the ((rt(sip ↦ addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))) sip)) = unk›
6. ‹⋀sip rt. ⟦sip ∈ kD rt; π₃ (0, unk, val, Suc 0, sip, {}) = unk⟧ ⟹ sqn (rt(sip ↦ (π₂ (the (rt sip)), π₃ (0, unk, val, Suc 0, sip, {}), π₄ (0, unk, val, Suc 0, sip, {}), π₅ (0, unk, val, Suc 0, sip, {}), π₆ (0, unk, val, Suc 0, sip, {}), π₇ (addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))))) sip = 0 ⟶ π₃ (the ((rt(sip ↦ (π₂ (the (rt sip)), π₃ (0, unk, val, Suc 0, sip, {}), π₄ (0, unk, val, Suc 0, sip, {}), π₅ (0, unk, val, Suc 0, sip, {}), π₆ (0, unk, val, Suc 0, sip, {}), π₇ (addpre (0, unk, val, Suc 0, sip, {}) (π₇ (the (rt sip))))))) sip)) = unk›
7. ‹⋀sip rt. ⟦sip ∈ kD rt; π₂ (0, unk, val, Suc 0, sip, {}) ≤ sqn rt sip; π₃ (0, unk, val, Suc 0, sip, {}) = kno; sqn rt sip = π₂ (0, unk, val, Suc 0, sip, {}) ⟹ the (dhops rt sip) ≤ π₅ (0, unk, val, Suc 0, sip, {}) ∧ the (flag rt sip) = val⟧ ⟹ sqn (rt(sip ↦ addpre (the (rt sip)) (π₇ (0, unk, val, Suc 0, sip, {})))) sip = 0 ⟶ π₃ (the ((rt(sip ↦ addpre (the (rt sip)) (π₇ (0, unk, val, Suc 0, sip, {})))) sip)) = unk›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*proven 7 subgoals*) .
show "?thesis"
(*goal: ‹paodv i ⊫ (recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, uu_). ∀dip∈kD (rt ξ). (sqn (rt ξ) dip = 0 ⟶ sqnf (rt ξ) dip = unk) ∧ (sqnf (rt ξ) dip = unk ⟶ the (dhops (rt ξ) dip) = 1) ∧ (the (dhops (rt ξ) dip) = 1 ⟶ the (nhop (rt ξ) dip) = dip))›*)
by (msorry)
qed
lemma zero_seq_unk_hops_one:
"paodv i ⊫ (recvmsg (λm. rreq_rrep_sn m ∧ msg_zhops m) →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, _).
∀dip∈kD(rt ξ). (sqn (rt ξ) dip = 0 ⟶ (sqnf (rt ξ) dip = unk
∧ the (dhops (rt ξ) dip) = 1
∧ the (nhop (rt ξ) dip) = dip)))"
apply (rule invariant_weakenE [OF zero_seq_unk_hops_one'] (*‹⟦⋀s::state × (state, msg, pseqp, pseqp label) seqp. onl Γ⇩A⇩O⇩D⇩V (λ(ξ::state, uu_::pseqp label). ∀dip::nat∈kD (rt ξ). (sqn (rt ξ) dip = (0::nat) ⟶ sqnf (rt ξ) dip = unk) ∧ (sqnf (rt ξ) dip = unk ⟶ the (dhops (rt ξ) dip) = (1::nat)) ∧ (the (dhops (rt ξ) dip) = (1::nat) ⟶ the (nhop (rt ξ) dip) = dip)) s ⟹ (?Q::state × (state, msg, pseqp, pseqp label) seqp ⇒ bool) s; ⋀a::msg seq_action. (?QI::msg seq_action ⇒ bool) a ⟹ recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) a⟧ ⟹ paodv (?i1::nat) ⊫ (?QI →) ?Q›*))
(*goals:
1. ‹⋀s::state × (state, msg, pseqp, pseqp label) seqp. onl Γ⇩A⇩O⇩D⇩V (λ(ξ::state, uu_::pseqp label). ∀dip::nat∈kD (rt ξ). (sqn (rt ξ) dip = (0::nat) ⟶ sqnf (rt ξ) dip = unk) ∧ (sqnf (rt ξ) dip = unk ⟶ the (dhops (rt ξ) dip) = (1::nat)) ∧ (the (dhops (rt ξ) dip) = (1::nat) ⟶ the (nhop (rt ξ) dip) = dip)) s ⟹ onl Γ⇩A⇩O⇩D⇩V (λ(ξ::state, uu_::pseqp label). ∀dip::nat∈kD (rt ξ). sqn (rt ξ) dip = (0::nat) ⟶ sqnf (rt ξ) dip = unk ∧ the (dhops (rt ξ) dip) = (1::nat) ∧ the (nhop (rt ξ) dip) = dip) s›
2. ‹⋀a::msg seq_action. recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) a ⟹ recvmsg (λm::msg. rreq_rrep_sn m ∧ msg_zhops m) a›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma kD_unk_or_atleast_one:
"paodv i ⊫ (recvmsg rreq_rrep_sn →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l).
∀dip∈kD(rt ξ). π₃(the (rt ξ dip)) = unk ∨ 1 ≤ π₂(the (rt ξ dip)))"
proof (-)
(*goal: ‹paodv i ⊫ (recvmsg rreq_rrep_sn →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). ∀dip∈kD (rt ξ). π₃ (the (rt ξ dip)) = unk ∨ 1 ≤ π₂ (the (rt ξ dip)))›*)
{
fix sip and rt and dsn1 and dsn2 and dsk1 and dsk2 and flag1 and flag2 and hops1 and hops2 and nhip1 and nhip2 and pre1 and pre2
assume "dsk1 = unk ∨ Suc 0 ≤ dsn2" (*‹(dsk1::k) = unk ∨ Suc (0::nat) ≤ (dsn2::nat)›*)
hence "π₃(the (update rt sip (dsn1, dsk1, flag1, hops1, nhip1, pre1) sip)) = unk
∨ Suc 0 ≤ sqn (update rt sip (dsn2, dsk2, flag2, hops2, nhip2, pre2)) sip"
unfolding update_def
(*goal: ‹π₃ (the ((case (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) (sip::nat) of None ⇒ rt(sip ↦ (dsn1::nat, dsk1::k, flag1::f, hops1::nat, nhip1::nat, pre1::nat set)) | Some (s::nat × k × f × nat × nat × nat set) ⇒ if π₂ s < π₂ (dsn1, dsk1, flag1, hops1, nhip1, pre1) then rt(sip ↦ addpre (dsn1, dsk1, flag1, hops1, nhip1, pre1) (π₇ s)) else if π₂ s = π₂ (dsn1, dsk1, flag1, hops1, nhip1, pre1) ∧ (π₅ (dsn1, dsk1, flag1, hops1, nhip1, pre1) < π₅ s ∨ π₄ s = Aodv_Basic.inv) then rt(sip ↦ addpre (dsn1, dsk1, flag1, hops1, nhip1, pre1) (π₇ s)) else if π₃ (dsn1, dsk1, flag1, hops1, nhip1, pre1) = unk then rt(sip ↦ (π₂ s, snd (addpre (dsn1, dsk1, flag1, hops1, nhip1, pre1) (π₇ s)))) else rt(sip ↦ addpre s (π₇ (dsn1, dsk1, flag1, hops1, nhip1, pre1)))) sip)) = unk ∨ Suc (0::nat) ≤ sqn (case rt sip of None ⇒ rt(sip ↦ (dsn2::nat, dsk2::k, flag2::f, hops2::nat, nhip2::nat, pre2::nat set)) | Some (s::nat × k × f × nat × nat × nat set) ⇒ if π₂ s < π₂ (dsn2, dsk2, flag2, hops2, nhip2, pre2) then rt(sip ↦ addpre (dsn2, dsk2, flag2, hops2, nhip2, pre2) (π₇ s)) else if π₂ s = π₂ (dsn2, dsk2, flag2, hops2, nhip2, pre2) ∧ (π₅ (dsn2, dsk2, flag2, hops2, nhip2, pre2) < π₅ s ∨ π₄ s = Aodv_Basic.inv) then rt(sip ↦ addpre (dsn2, dsk2, flag2, hops2, nhip2, pre2) (π₇ s)) else if π₃ (dsn2, dsk2, flag2, hops2, nhip2, pre2) = unk then rt(sip ↦ (π₂ s, snd (addpre (dsn2, dsk2, flag2, hops2, nhip2, pre2) (π₇ s)))) else rt(sip ↦ addpre s (π₇ (dsn2, dsk2, flag2, hops2, nhip2, pre2)))) sip›*)
apply (cases "dsk1 =unk")
(*goals:
1. ‹⟦dsk1 = unk ∨ Suc 0 ≤ dsn2; dsk1 = unk⟧ ⟹ π₃ (the ((case rt sip of None ⇒ rt(sip ↦ (dsn1, dsk1, flag1, hops1, nhip1, pre1)) | Some s ⇒ if π₂ s < π₂ (dsn1, dsk1, flag1, hops1, nhip1, pre1) then rt(sip ↦ addpre (dsn1, dsk1, flag1, hops1, nhip1, pre1) (π₇ s)) else if π₂ s = π₂ (dsn1, dsk1, flag1, hops1, nhip1, pre1) ∧ (π₅ (dsn1, dsk1, flag1, hops1, nhip1, pre1) < π₅ s ∨ π₄ s = Aodv_Basic.inv) then rt(sip ↦ addpre (dsn1, dsk1, flag1, hops1, nhip1, pre1) (π₇ s)) else if π₃ (dsn1, dsk1, flag1, hops1, nhip1, pre1) = unk then rt(sip ↦ (π₂ s, snd (addpre (dsn1, dsk1, flag1, hops1, nhip1, pre1) (π₇ s)))) else rt(sip ↦ addpre s (π₇ (dsn1, dsk1, flag1, hops1, nhip1, pre1)))) sip)) = unk ∨ Suc 0 ≤ sqn (case rt sip of None ⇒ rt(sip ↦ (dsn2, dsk2, flag2, hops2, nhip2, pre2)) | Some s ⇒ if π₂ s < π₂ (dsn2, dsk2, flag2, hops2, nhip2, pre2) then rt(sip ↦ addpre (dsn2, dsk2, flag2, hops2, nhip2, pre2) (π₇ s)) else if π₂ s = π₂ (dsn2, dsk2, flag2, hops2, nhip2, pre2) ∧ (π₅ (dsn2, dsk2, flag2, hops2, nhip2, pre2) < π₅ s ∨ π₄ s = Aodv_Basic.inv) then rt(sip ↦ addpre (dsn2, dsk2, flag2, hops2, nhip2, pre2) (π₇ s)) else if π₃ (dsn2, dsk2, flag2, hops2, nhip2, pre2) = unk then rt(sip ↦ (π₂ s, snd (addpre (dsn2, dsk2, flag2, hops2, nhip2, pre2) (π₇ s)))) else rt(sip ↦ addpre s (π₇ (dsn2, dsk2, flag2, hops2, nhip2, pre2)))) sip›
2. ‹⟦dsk1 = unk ∨ Suc 0 ≤ dsn2; dsk1 ≠ unk⟧ ⟹ π₃ (the ((case rt sip of None ⇒ rt(sip ↦ (dsn1, dsk1, flag1, hops1, nhip1, pre1)) | Some s ⇒ if π₂ s < π₂ (dsn1, dsk1, flag1, hops1, nhip1, pre1) then rt(sip ↦ addpre (dsn1, dsk1, flag1, hops1, nhip1, pre1) (π₇ s)) else if π₂ s = π₂ (dsn1, dsk1, flag1, hops1, nhip1, pre1) ∧ (π₅ (dsn1, dsk1, flag1, hops1, nhip1, pre1) < π₅ s ∨ π₄ s = Aodv_Basic.inv) then rt(sip ↦ addpre (dsn1, dsk1, flag1, hops1, nhip1, pre1) (π₇ s)) else if π₃ (dsn1, dsk1, flag1, hops1, nhip1, pre1) = unk then rt(sip ↦ (π₂ s, snd (addpre (dsn1, dsk1, flag1, hops1, nhip1, pre1) (π₇ s)))) else rt(sip ↦ addpre s (π₇ (dsn1, dsk1, flag1, hops1, nhip1, pre1)))) sip)) = unk ∨ Suc 0 ≤ sqn (case rt sip of None ⇒ rt(sip ↦ (dsn2, dsk2, flag2, hops2, nhip2, pre2)) | Some s ⇒ if π₂ s < π₂ (dsn2, dsk2, flag2, hops2, nhip2, pre2) then rt(sip ↦ addpre (dsn2, dsk2, flag2, hops2, nhip2, pre2) (π₇ s)) else if π₂ s = π₂ (dsn2, dsk2, flag2, hops2, nhip2, pre2) ∧ (π₅ (dsn2, dsk2, flag2, hops2, nhip2, pre2) < π₅ s ∨ π₄ s = Aodv_Basic.inv) then rt(sip ↦ addpre (dsn2, dsk2, flag2, hops2, nhip2, pre2) (π₇ s)) else if π₃ (dsn2, dsk2, flag2, hops2, nhip2, pre2) = unk then rt(sip ↦ (π₂ s, snd (addpre (dsn2, dsk2, flag2, hops2, nhip2, pre2) (π₇ s)))) else rt(sip ↦ addpre s (π₇ (dsn2, dsk2, flag2, hops2, nhip2, pre2)))) sip›
discuss goal 1*)
apply (clarsimp split: option.split (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))›*))
(*discuss goal 2*)
apply (clarsimp split: option.split (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))›*))
(*proven 2 subgoals*) .
}
note fromsip[simp] = this (*‹?dsk1.2 = unk ∨ Suc 0 ≤ ?dsn2.2 ⟹ π₃ (the (update ?rt2 ?sip2 (?dsn1.2, ?dsk1.2, ?flag1.2, ?hops1.2, ?nhip1.2, ?pre1.2) ?sip2)) = unk ∨ Suc 0 ≤ sqn (update ?rt2 ?sip2 (?dsn2.2, ?dsk2.2, ?flag2.2, ?hops2.2, ?nhip2.2, ?pre2.2)) ?sip2›*)
{
fix dip and sip and rt and dsn1 and dsn2 and dsk1 and dsk2 and flag1 and flag2 and hops1 and hops2 and nhip1 and nhip2 and pre1 and pre2
assume allkd: "∀dip∈kD(rt). π₃(the (rt dip)) = unk ∨ Suc 0 ≤ sqn rt dip" and "**": "dsk1 = unk ∨ Suc 0 ≤ dsn2" (*‹∀dip::nat∈kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option). π₃ (the (rt dip)) = unk ∨ Suc (0::nat) ≤ sqn rt dip› ‹(dsk1::k) = unk ∨ Suc (0::nat) ≤ (dsn2::nat)›*)
have "∀dip∈kD(rt). π₃(the (update rt sip (dsn1, dsk1, flag1, hops1, nhip1, pre1) dip)) = unk
∨ Suc 0 ≤ sqn (update rt sip (dsn2, dsk2, flag2, hops2, nhip2, pre2)) dip" (is "∀dip∈kD(rt). ?prop dip")
proof (standard)
(*goal: ‹⋀dip. dip ∈ kD rt ⟹ π₃ (the (update rt sip (dsn1, dsk1, flag1, hops1, nhip1, pre1) dip)) = unk ∨ Suc 0 ≤ sqn (update rt sip (dsn2, dsk2, flag2, hops2, nhip2, pre2)) dip›*)
fix dip
assume "dip∈kD(rt)" (*‹(dip::nat) ∈ kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option)›*)
thus "?prop dip"
proof (cases "dip = sip")
(*goals:
1. ‹⟦dip ∈ kD rt; dip = sip⟧ ⟹ π₃ (the (update rt sip (dsn1, dsk1, flag1, hops1, nhip1, pre1) dip)) = unk ∨ Suc 0 ≤ sqn (update rt sip (dsn2, dsk2, flag2, hops2, nhip2, pre2)) dip›
2. ‹⟦dip ∈ kD rt; dip ≠ sip⟧ ⟹ π₃ (the (update rt sip (dsn1, dsk1, flag1, hops1, nhip1, pre1) dip)) = unk ∨ Suc 0 ≤ sqn (update rt sip (dsn2, dsk2, flag2, hops2, nhip2, pre2)) dip›*)
assume "dip = sip" (*‹(dip::nat) = (sip::nat)›*)
with "**" (*‹dsk1 = unk ∨ Suc 0 ≤ dsn2›*) show "?thesis"
(*goal: ‹π₃ (the (update rt sip (dsn1, dsk1, flag1, hops1, nhip1, pre1) dip)) = unk ∨ Suc 0 ≤ sqn (update rt sip (dsn2, dsk2, flag2, hops2, nhip2, pre2)) dip›*)
by simp
next
(*goal: ‹⟦dip ∈ kD rt; dip ≠ sip⟧ ⟹ π₃ (the (update rt sip (dsn1, dsk1, flag1, hops1, nhip1, pre1) dip)) = unk ∨ Suc 0 ≤ sqn (update rt sip (dsn2, dsk2, flag2, hops2, nhip2, pre2)) dip›*)
assume "dip ≠ sip" (*‹(dip::nat) ≠ (sip::nat)›*)
with ‹dip∈kD(rt)› (*‹dip ∈ kD rt›*) allkd (*‹∀dip∈kD rt. π₃ (the (rt dip)) = unk ∨ Suc 0 ≤ sqn rt dip›*) show "?thesis"
(*goal: ‹π₃ (the (update rt sip (dsn1, dsk1, flag1, hops1, nhip1, pre1) dip)) = unk ∨ Suc 0 ≤ sqn (update rt sip (dsn2, dsk2, flag2, hops2, nhip2, pre2)) dip›*)
by simp
qed
qed
}
note solve_update[simp] = this (*‹⟦∀dip∈kD ?rt2. π₃ (the (?rt2 dip)) = unk ∨ Suc 0 ≤ sqn ?rt2 dip; ?dsk1.2 = unk ∨ Suc 0 ≤ ?dsn2.2⟧ ⟹ ∀dip∈kD ?rt2. π₃ (the (update ?rt2 ?sip2 (?dsn1.2, ?dsk1.2, ?flag1.2, ?hops1.2, ?nhip1.2, ?pre1.2) dip)) = unk ∨ Suc 0 ≤ sqn (update ?rt2 ?sip2 (?dsn2.2, ?dsk2.2, ?flag2.2, ?hops2.2, ?nhip2.2, ?pre2.2)) dip›*)
{
fix dip and rt and dests
assume "*": "∀ip∈dom(dests). ip∈kD(rt) ∧ sqn rt ip ≤ the (dests ip)" and "**": "∀ip∈kD(rt). π₃(the (rt ip)) = unk ∨ Suc 0 ≤ sqn rt ip" (*‹∀ip::nat∈dom (dests::nat ⇒ nat option). ip ∈ kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) ∧ sqn rt ip ≤ the (dests ip)› ‹∀ip::nat∈kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option). π₃ (the (rt ip)) = unk ∨ Suc (0::nat) ≤ sqn rt ip›*)
have "∀dip∈kD(rt). π₃(the (rt dip)) = unk ∨ Suc 0 ≤ sqn (invalidate rt dests) dip"
proof (standard)
(*goal: ‹⋀dip. dip ∈ kD rt ⟹ π₃ (the (rt dip)) = unk ∨ Suc 0 ≤ sqn (invalidate rt dests) dip›*)
fix dip
assume "dip∈kD(rt)" (*‹(dip::nat) ∈ kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option)›*)
with "**" (*‹∀ip::nat∈kD (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option). π₃ (the (rt ip)) = unk ∨ Suc (0::nat) ≤ sqn rt ip›*) have "π₃(the (rt dip)) = unk ∨ Suc 0 ≤ sqn rt dip"
by standard
thus "π₃ (the (rt dip)) = unk ∨ Suc 0 ≤ sqn (invalidate rt dests) dip"
proof (standard)
(*goals:
1. ‹π₃ (the (rt dip)) = unk ⟹ π₃ (the (rt dip)) = unk ∨ Suc 0 ≤ sqn (invalidate rt dests) dip›
2. ‹Suc 0 ≤ sqn rt dip ⟹ π₃ (the (rt dip)) = unk ∨ Suc 0 ≤ sqn (invalidate rt dests) dip›*)
assume "π₃(the (rt dip)) = unk" (*‹π₃ (the ((rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) (dip::nat))) = unk›*)
thus "?thesis"
(*goal: ‹π₃ (the ((rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) (dip::nat))) = unk ∨ Suc (0::nat) ≤ sqn (invalidate rt (dests::nat ⇒ nat option)) dip›*)
by standard
next
(*goal: ‹Suc (0::nat) ≤ sqn (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) (dip::nat) ⟹ π₃ (the (rt dip)) = unk ∨ Suc (0::nat) ≤ sqn (invalidate rt (dests::nat ⇒ nat option)) dip›*)
assume "Suc 0 ≤ sqn rt dip" (*‹Suc (0::nat) ≤ sqn (rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) (dip::nat)›*)
have "Suc 0 ≤ sqn (invalidate rt dests) dip"
proof (cases "dip∈dom(dests)")
(*goals:
1. ‹dip ∈ dom dests ⟹ Suc 0 ≤ sqn (invalidate rt dests) dip›
2. ‹dip ∉ dom dests ⟹ Suc 0 ≤ sqn (invalidate rt dests) dip›*)
assume "dip∈dom(dests)" (*‹(dip::nat) ∈ dom (dests::nat ⇒ nat option)›*)
with "*" (*‹∀ip∈dom dests. ip ∈ kD rt ∧ sqn rt ip ≤ the (dests ip)›*) have "sqn rt dip ≤ the (dests dip)"
by simp
with ‹Suc 0 ≤ sqn rt dip› (*‹Suc 0 ≤ sqn rt dip›*) have "Suc 0 ≤ the (dests dip)"
by simp
with ‹dip∈dom(dests)› (*‹dip ∈ dom dests›*) ‹dip∈kD(rt)›[THEN kD_Some] (*‹∃dsn dsk flag hops nhip pre. rt dip = Some (dsn, dsk, flag, hops, nhip, pre)›*) show "?thesis"
(*goal: ‹Suc 0 ≤ sqn (invalidate rt dests) dip›*)
unfolding invalidate_def sqn_def
(*goal: ‹Suc 0 ≤ (case case (rt dip, dests dip) of (None, x) ⇒ None | (Some (a, ab, ad, af, ah, ba), None) ⇒ Some (a, ab, ad, af, ah, ba) | (Some (a, ab, ad, af, ah, ba), Some rsn) ⇒ Some (rsn, ab, Aodv_Basic.inv, af, ah, ba) of None ⇒ 0 | Some r ⇒ π₂ r)›*)
by auto
next
(*goal: ‹dip ∉ dom dests ⟹ Suc 0 ≤ sqn (invalidate rt dests) dip›*)
assume "dip∉dom(dests)" (*‹(dip::nat) ∉ dom (dests::nat ⇒ nat option)›*)
with ‹Suc 0 ≤ sqn rt dip› (*‹Suc 0 ≤ sqn rt dip›*) ‹dip∈kD(rt)›[THEN kD_Some] (*‹∃dsn dsk flag hops nhip pre. rt dip = Some (dsn, dsk, flag, hops, nhip, pre)›*) show "?thesis"
(*goal: ‹Suc 0 ≤ sqn (invalidate rt dests) dip›*)
unfolding invalidate_def sqn_def
(*goal: ‹Suc 0 ≤ (case case (rt dip, dests dip) of (None, x) ⇒ None | (Some (a, ab, ad, af, ah, ba), None) ⇒ Some (a, ab, ad, af, ah, ba) | (Some (a, ab, ad, af, ah, ba), Some rsn) ⇒ Some (rsn, ab, Aodv_Basic.inv, af, ah, ba) of None ⇒ 0 | Some r ⇒ π₂ r)›*)
by auto
qed
thus "?thesis"
(*goal: ‹π₃ (the ((rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) (dip::nat))) = unk ∨ Suc (0::nat) ≤ sqn (invalidate rt (dests::nat ⇒ nat option)) dip›*)
by (rule disjI2 (*‹?Q ⟹ ?P ∨ ?Q›*))
qed
qed
}
note solve_invalidate[simp] = this (*‹⟦∀ip∈dom ?dests2. ip ∈ kD ?rt2 ∧ sqn ?rt2 ip ≤ the (?dests2 ip); ∀ip∈kD ?rt2. π₃ (the (?rt2 ip)) = unk ∨ Suc 0 ≤ sqn ?rt2 ip⟧ ⟹ ∀dip∈kD ?rt2. π₃ (the (?rt2 dip)) = unk ∨ Suc 0 ≤ sqn (invalidate ?rt2 ?dests2) dip›*)
show "?thesis"
(*goal: ‹paodv (i::nat) ⊫ (recvmsg rreq_rrep_sn →) onl Γ⇩A⇩O⇩D⇩V (λ(ξ::state, l::pseqp label). ∀dip::nat∈kD (rt ξ). π₃ (the (rt ξ dip)) = unk ∨ (1::nat) ≤ π₂ (the (rt ξ dip)))›*)
by (msorry)
qed
text ‹Proposition 7.13›
lemma rreq_rrep_sn_any_step_invariant:
"paodv i ⊫⇩A (recvmsg rreq_rrep_sn →) onll Γ⇩A⇩O⇩D⇩V (λ(_, a, _). anycast rreq_rrep_sn a)"
proof (-)
(*goal: ‹paodv i ⊫⇩A (recvmsg rreq_rrep_sn →) onll Γ⇩A⇩O⇩D⇩V (λ(uu_, a, uu_). anycast rreq_rrep_sn a)›*)
have sqnf_kno: "paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l).
(l ∈ {PRreq-:16..PRreq-:18} ⟶ sqnf (rt ξ) (dip ξ) = kno))"
by (inv_cterms inv add: onl_invariant_sterms_TT [OF aodv_wf addpreRT_welldefined])
show "?thesis"
(*goal: ‹paodv i ⊫⇩A (recvmsg rreq_rrep_sn →) onll Γ⇩A⇩O⇩D⇩V (λ(uu_, a, uu_). anycast rreq_rrep_sn a)›*)
apply (inv_cterms inv add: onl_invariant_sterms_TT [OF aodv_wf addpreRT_welldefined] onl_invariant_sterms [OF aodv_wf sequence_number_one_or_bigger [THEN invariant_restrict_inD]] onl_invariant_sterms [OF aodv_wf kD_unk_or_atleast_one] onl_invariant_sterms_TT [OF aodv_wf sqnf_kno] onl_invariant_sterms [OF aodv_wf osn_rreq] onl_invariant_sterms [OF aodv_wf dsn_rrep])
(*goal: ‹paodv i ⊫⇩A (recvmsg rreq_rrep_sn →) onll Γ⇩A⇩O⇩D⇩V (λ(uu_, a, uu_). anycast rreq_rrep_sn a)›*)
by (auto simp: proj2_eq_sqn (*‹(?dip::nat) ∈ kD (?rt::nat ⇒ (nat × k × f × nat × nat × nat set) option) ⟹ π₂ (the (?rt ?dip)) = sqn ?rt ?dip›*))
qed
text ‹Proposition 7.14›
lemma rreq_rrep_fresh_any_step_invariant:
"paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ, _), a, _). anycast (rreq_rrep_fresh (rt ξ)) a)"
proof (-)
(*goal: ‹paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ, uu_), a, uu_). anycast (rreq_rrep_fresh (rt ξ)) a)›*)
have rreq_oip: "paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l).
(l ∈ {PRreq-:3, PRreq-:4, PRreq-:15, PRreq-:27}
⟶ oip ξ ∈ kD(rt ξ)
∧ (sqn (rt ξ) (oip ξ) > (osn ξ)
∨ (sqn (rt ξ) (oip ξ) = (osn ξ)
∧ the (dhops (rt ξ) (oip ξ)) ≤ Suc (hops ξ)
∧ the (flag (rt ξ) (oip ξ)) = val))))"
proof (inv_cterms)
(*goal: ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PRreq-:2; ((ξ, {PRreq-:2}⟦λξ. ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
p'), τ⇩s, ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈, p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PRreq-:3 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) TT; {PRreq-:2}⟦λξ. ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈, p') ∈ reachable (paodv i) TT; p = {PRreq-:2}⟦λξ. ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
p'; l' = PRreq-:3; a = τ⇩s; ξ' = ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈; q = p'⟧ ⟹ osn ξ < sqn (update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) (oip ξ) ∨ sqn (update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) (oip ξ) = osn ξ ∧ the (dhops (update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) (oip ξ)) ≤ Suc (hops ξ) ∧ the (flag (update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) (oip ξ)) = val›*)
fix l and ξ and l' and pp and p'
assume "(ξ, pp) ∈ reachable (paodv i) TT" and "{PRreq-:2}⟦λξ. ξ⦇rt :=
update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧ p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp" and "l' = PRreq-:3" (*‹(ξ::state, pp::(state, msg, pseqp, pseqp label) seqp) ∈ reachable (paodv (i::nat)) TT› ‹{PRreq-:(2::int)}⟦λξ::state. ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
(p'::(state, msg, pseqp, pseqp label) seqp) ∈ sterms Γ⇩A⇩O⇩D⇩V (pp::(state, msg, pseqp, pseqp label) seqp)› ‹(l'::pseqp label) = PRreq-:(3::int)›*)
show "osn ξ < sqn (update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) (oip ξ)
∨ (sqn (update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) (oip ξ) = osn ξ
∧ the (dhops (update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) (oip ξ))
≤ Suc (hops ξ)
∧ the (flag (update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) (oip ξ))
= val)"
unfolding update_def
(*goal: ‹osn ξ < sqn (case rt ξ (oip ξ) of None ⇒ (rt ξ)(oip ξ ↦ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) | Some s ⇒ if π₂ s < π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₂ s = π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) ∧ (π₅ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) < π₅ s ∨ π₄ s = Aodv_Basic.inv) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₃ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) = unk then (rt ξ)(oip ξ ↦ (π₂ s, snd (addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)))) else (rt ξ)(oip ξ ↦ addpre s (π₇ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})))) (oip ξ) ∨ sqn (case rt ξ (oip ξ) of None ⇒ (rt ξ)(oip ξ ↦ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) | Some s ⇒ if π₂ s < π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₂ s = π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) ∧ (π₅ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) < π₅ s ∨ π₄ s = Aodv_Basic.inv) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₃ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) = unk then (rt ξ)(oip ξ ↦ (π₂ s, snd (addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)))) else (rt ξ)(oip ξ ↦ addpre s (π₇ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})))) (oip ξ) = osn ξ ∧ the (dhops (case rt ξ (oip ξ) of None ⇒ (rt ξ)(oip ξ ↦ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) | Some s ⇒ if π₂ s < π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₂ s = π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) ∧ (π₅ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) < π₅ s ∨ π₄ s = Aodv_Basic.inv) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₃ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) = unk then (rt ξ)(oip ξ ↦ (π₂ s, snd (addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)))) else (rt ξ)(oip ξ ↦ addpre s (π₇ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})))) (oip ξ)) ≤ Suc (hops ξ) ∧ the (flag (case rt ξ (oip ξ) of None ⇒ (rt ξ)(oip ξ ↦ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) | Some s ⇒ if π₂ s < π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₂ s = π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) ∧ (π₅ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) < π₅ s ∨ π₄ s = Aodv_Basic.inv) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₃ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) = unk then (rt ξ)(oip ξ ↦ (π₂ s, snd (addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)))) else (rt ξ)(oip ξ ↦ addpre s (π₇ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})))) (oip ξ)) = val›*)
apply (clarsimp split: option.split (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = Some x2 ⟶ ?P (?f2.0 x2)))›*))
(*goal: ‹osn ξ < sqn (case rt ξ (oip ξ) of None ⇒ (rt ξ)(oip ξ ↦ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) | Some s ⇒ if π₂ s < π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₂ s = π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) ∧ (π₅ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) < π₅ s ∨ π₄ s = Aodv_Basic.inv) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₃ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) = unk then (rt ξ)(oip ξ ↦ (π₂ s, snd (addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)))) else (rt ξ)(oip ξ ↦ addpre s (π₇ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})))) (oip ξ) ∨ sqn (case rt ξ (oip ξ) of None ⇒ (rt ξ)(oip ξ ↦ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) | Some s ⇒ if π₂ s < π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₂ s = π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) ∧ (π₅ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) < π₅ s ∨ π₄ s = Aodv_Basic.inv) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₃ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) = unk then (rt ξ)(oip ξ ↦ (π₂ s, snd (addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)))) else (rt ξ)(oip ξ ↦ addpre s (π₇ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})))) (oip ξ) = osn ξ ∧ the (dhops (case rt ξ (oip ξ) of None ⇒ (rt ξ)(oip ξ ↦ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) | Some s ⇒ if π₂ s < π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₂ s = π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) ∧ (π₅ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) < π₅ s ∨ π₄ s = Aodv_Basic.inv) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₃ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) = unk then (rt ξ)(oip ξ ↦ (π₂ s, snd (addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)))) else (rt ξ)(oip ξ ↦ addpre s (π₇ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})))) (oip ξ)) ≤ Suc (hops ξ) ∧ the (flag (case rt ξ (oip ξ) of None ⇒ (rt ξ)(oip ξ ↦ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})) | Some s ⇒ if π₂ s < π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₂ s = π₂ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) ∧ (π₅ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) < π₅ s ∨ π₄ s = Aodv_Basic.inv) then (rt ξ)(oip ξ ↦ addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)) else if π₃ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) = unk then (rt ξ)(oip ξ ↦ (π₂ s, snd (addpre (osn ξ, kno, val, Suc (hops ξ), sip ξ, {}) (π₇ s)))) else (rt ξ)(oip ξ ↦ addpre s (π₇ (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})))) (oip ξ)) = val›*)
by (metis linorder_neqE_nat (*‹⟦?x ≠ ?y; ?x < ?y ⟹ ?R; ?y < ?x ⟹ ?R⟧ ⟹ ?R›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*))
qed
have rrep_prrep: "paodv i ⊫ onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l).
(l ∈ {PRrep-:2..PRrep-:7} ⟶ (dip ξ ∈ kD(rt ξ)
∧ sqn (rt ξ) (dip ξ) = dsn ξ
∧ the (dhops (rt ξ) (dip ξ)) = Suc (hops ξ)
∧ the (flag (rt ξ) (dip ξ)) = val
∧ the (nhop (rt ξ) (dip ξ)) ∈ kD (rt ξ))))"
by (msorry)
show "?thesis"
(*goal: ‹paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ, uu_), a, uu_). anycast (rreq_rrep_fresh (rt ξ)) a)›*)
by (msorry)
qed
text ‹Proposition 7.15›
lemma rerr_invalid_any_step_invariant:
"paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ, _), a, _). anycast (rerr_invalid (rt ξ)) a)"
proof (-)
(*goal: ‹paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ, uu_), a, uu_). anycast (rerr_invalid (rt ξ)) a)›*)
have dests_inv: "paodv i ⊫
onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l ∈ {PAodv-:15, PPkt-:7, PRreq-:9,
PRreq-:21, PRrep-:10, PRerr-:1}
⟶ (∀ip∈dom(dests ξ). ip∈vD(rt ξ)))
∧ (l ∈ {PAodv-:16..PAodv-:19}
∪ {PPkt-:8..PPkt-:11}
∪ {PRreq-:10..PRreq-:13}
∪ {PRreq-:22..PRreq-:25}
∪ {PRrep-:11..PRrep-:14}
∪ {PRerr-:2..PRerr-:5} ⟶ (∀ip∈dom(dests ξ). ip∈iD(rt ξ)
∧ the (dests ξ ip) = sqn (rt ξ) ip))
∧ (l = PPkt-:14 ⟶ dip ξ∈iD(rt ξ)))"
by (msorry)
show "?thesis"
(*goal: ‹paodv i ⊫⇩A onll Γ⇩A⇩O⇩D⇩V (λ((ξ, uu_), a, uu_). anycast (rerr_invalid (rt ξ)) a)›*)
by (inv_cterms inv add: onl_invariant_sterms [OF aodv_wf dests_inv])
qed
text ‹Proposition 7.16›
text ‹
Some well-definedness obligations are irrelevant for the Isabelle development:
\begin{enumerate}
\item In each routing table there is at most one entry for each destination: guaranteed by type.
\item In each store of queued data packets there is at most one data queue for
each destination: guaranteed by structure.
\item Whenever a set of pairs @{term "(rip, rsn)"} is assigned to the variable
@{term "dests"} of type @{typ "ip ⇀ sqn"}, or to the first argument of
the function @{term "rerr"}, this set is a partial function, i.e., there
is at most one entry @{term "(rip, rsn)"} for each destination
@{term "rip"}: guaranteed by type.
\end{enumerate}
›
lemma dests_vD_inc_sqn:
"paodv i ⊫
onl Γ⇩A⇩O⇩D⇩V (λ(ξ, l). (l ∈ {PAodv-:15, PPkt-:7, PRreq-:9, PRreq-:21, PRrep-:10}
⟶ (∀ip∈dom(dests ξ). ip∈vD(rt ξ) ∧ the (dests ξ ip) = inc (sqn (rt ξ) ip)))
∧ (l = PRerr-:1
⟶ (∀ip∈dom(dests ξ). ip∈vD(rt ξ) ∧ the (dests ξ ip) > sqn (rt ξ) ip)))"
apply inv_cterms
(*goals:
1. ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PAodv-:14; ((ξ, {PAodv-:14}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p'), τ⇩s, ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈, p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PAodv-:15 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) TT; {PAodv-:14}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈, p') ∈ reachable (paodv i) TT; p = {PAodv-:14}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p'; l' = PAodv-:15; a = τ⇩s; ξ' = ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈; q = p'⟧ ⟹ ∀ip∈dom (λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None). (ip ∈ vD (rt ξ) ⟶ nhop (rt ξ) ip ≠ nhop (rt ξ) (dip ξ)) ⟶ ip ∈ vD (rt ξ) ∧ the None = inc (sqn (rt ξ) ip)›
2. ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PPkt-:6; ((ξ, {PPkt-:6}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p'), τ⇩s, ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈, p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PPkt-:7 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) TT; {PPkt-:6}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈, p') ∈ reachable (paodv i) TT; p = {PPkt-:6}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p'; l' = PPkt-:7; a = τ⇩s; ξ' = ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈; q = p'⟧ ⟹ ∀ip∈dom (λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None). (ip ∈ vD (rt ξ) ⟶ nhop (rt ξ) ip ≠ nhop (rt ξ) (dip ξ)) ⟶ ip ∈ vD (rt ξ) ∧ the None = inc (sqn (rt ξ) ip)›
3. ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PRreq-:20; ((ξ, {PRreq-:20}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p'), τ⇩s, ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈, p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PRreq-:21 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) TT; {PRreq-:20}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈, p') ∈ reachable (paodv i) TT; p = {PRreq-:20}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p'; l' = PRreq-:21; a = τ⇩s; ξ' = ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈; q = p'⟧ ⟹ ∀ip∈dom (λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None). (ip ∈ vD (rt ξ) ⟶ nhop (rt ξ) ip ≠ nhop (rt ξ) (oip ξ)) ⟶ ip ∈ vD (rt ξ) ∧ the None = inc (sqn (rt ξ) ip)›
4. ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PRreq-:8; ((ξ, {PRreq-:8}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p'), τ⇩s, ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈, p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PRreq-:9 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) TT; {PRreq-:8}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈, p') ∈ reachable (paodv i) TT; p = {PRreq-:8}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p'; l' = PRreq-:9; a = τ⇩s; ξ' = ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈; q = p'⟧ ⟹ ∀ip∈dom (λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None). (ip ∈ vD (rt ξ) ⟶ nhop (rt ξ) ip ≠ nhop (rt ξ) (oip ξ)) ⟶ ip ∈ vD (rt ξ) ∧ the None = inc (sqn (rt ξ) ip)›
5. ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PRrep-:9; ((ξ, {PRrep-:9}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p'), τ⇩s, ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈, p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PRrep-:10 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) TT; {PRrep-:9}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈, p') ∈ reachable (paodv i) TT; p = {PRrep-:9}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧
p'; l' = PRrep-:10; a = τ⇩s; ξ' = ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈; q = p'⟧ ⟹ ∀ip∈dom (λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None). (ip ∈ vD (rt ξ) ⟶ nhop (rt ξ) ip ≠ nhop (rt ξ) (oip ξ)) ⟶ ip ∈ vD (rt ξ) ∧ the None = inc (sqn (rt ξ) ip)›
6. ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PRerr-:0; ((ξ, {PRerr-:0}⟦λξ. ξ⦇dests := λrip. case dests ξ rip of None ⇒ None | Some rsn ⇒ if rip ∈ vD (rt ξ) ∧ the (nhop (rt ξ) rip) = sip ξ ∧ sqn (rt ξ) rip < rsn then Some rsn else None⦈⟧
p'), τ⇩s, ξ⦇dests := λrip. case dests ξ rip of None ⇒ None | Some rsn ⇒ if rip ∈ vD (rt ξ) ∧ the (nhop (rt ξ) rip) = sip ξ ∧ sqn (rt ξ) rip < rsn then Some rsn else None⦈, p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PRerr-:1 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) TT; {PRerr-:0}⟦λξ. ξ⦇dests := λrip. case dests ξ rip of None ⇒ None | Some rsn ⇒ if rip ∈ vD (rt ξ) ∧ the (nhop (rt ξ) rip) = sip ξ ∧ sqn (rt ξ) rip < rsn then Some rsn else None⦈⟧
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ⦇dests := λrip. case dests ξ rip of None ⇒ None | Some rsn ⇒ if rip ∈ vD (rt ξ) ∧ the (nhop (rt ξ) rip) = sip ξ ∧ sqn (rt ξ) rip < rsn then Some rsn else None⦈, p') ∈ reachable (paodv i) TT; p = {PRerr-:0}⟦λξ. ξ⦇dests := λrip. case dests ξ rip of None ⇒ None | Some rsn ⇒ if rip ∈ vD (rt ξ) ∧ the (nhop (rt ξ) rip) = sip ξ ∧ sqn (rt ξ) rip < rsn then Some rsn else None⦈⟧
p'; l' = PRerr-:1; a = τ⇩s; ξ' = ξ⦇dests := λrip. case dests ξ rip of None ⇒ None | Some rsn ⇒ if rip ∈ vD (rt ξ) ∧ the (nhop (rt ξ) rip) = sip ξ ∧ sqn (rt ξ) rip < rsn then Some rsn else None⦈; q = p'⟧ ⟹ ∀ip∈dom (λrip. case dests ξ rip of None ⇒ None | Some rsn ⇒ if rip ∈ vD (rt ξ) ∧ the (nhop (rt ξ) rip) = sip ξ ∧ sqn (rt ξ) rip < rsn then Some rsn else None). ip ∈ vD (rt ξ) ∧ sqn (rt ξ) ip < the (case dests ξ ip of None ⇒ None | Some rsn ⇒ if ip ∈ vD (rt ξ) ∧ the (nhop (rt ξ) ip) = sip ξ ∧ sqn (rt ξ) ip < rsn then Some rsn else None)›
discuss goal 1*)
apply (clarsimp split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) option.split_asm (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))
(*discuss goal 2*)
apply (clarsimp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) option.split_asm (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))
(*discuss goal 3*)
apply (clarsimp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) option.split_asm (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))
(*discuss goal 4*)
apply (clarsimp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) option.split_asm (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))
(*discuss goal 5*)
apply (clarsimp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) option.split_asm (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))
(*discuss goal 6*)
apply (clarsimp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) option.split_asm (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))
(*proven 6 subgoals*) .
text ‹Proposition 7.27›
lemma route_tables_fresher:
"paodv i ⊫⇩A (recvmsg rreq_rrep_sn →) onll Γ⇩A⇩O⇩D⇩V (λ((ξ, _), _, (ξ', _)).
∀dip∈kD(rt ξ). rt ξ ⊑⇘dip⇙ rt ξ')"
proof (inv_cterms inv add: onl_invariant_sterms [OF aodv_wf dests_vD_inc_sqn [THEN invariant_restrict_inD]] onl_invariant_sterms [OF aodv_wf hop_count_positive [THEN invariant_restrict_inD]] onl_invariant_sterms [OF aodv_wf osn_rreq] onl_invariant_sterms [OF aodv_wf dsn_rrep] onl_invariant_sterms [OF aodv_wf addpreRT_welldefined [THEN invariant_restrict_inD]])
(*goals:
1. ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PRreq-:2; ((ξ, {PRreq-:2}⟦λξ. ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
p'), τ⇩s, ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈, p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PRreq-:3 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) (recvmsg rreq_rrep_sn); {PRreq-:2}⟦λξ. ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈, p') ∈ reachable (paodv i) (recvmsg rreq_rrep_sn); Suc 0 ≤ osn ξ; ∀ip∈kD (rt ξ). Suc 0 ≤ the (dhops (rt ξ) ip); p = {PRreq-:2}⟦λξ. ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
p'; l' = PRreq-:3; a = τ⇩s; ξ' = ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈; q = p'⟧ ⟹ ∀dip∈kD (rt ξ). rt ξ ⊑⇘dip⇙ update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})›
2. ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PRrep-:1; ((ξ, {PRrep-:1}⟦λξ. ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
p'), τ⇩s, ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈, p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PRrep-:2 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) (recvmsg rreq_rrep_sn); {PRrep-:1}⟦λξ. ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈, p') ∈ reachable (paodv i) (recvmsg rreq_rrep_sn); Suc 0 ≤ dsn ξ; ∀ip∈kD (rt ξ). Suc 0 ≤ the (dhops (rt ξ) ip); p = {PRrep-:1}⟦λξ. ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
p'; l' = PRrep-:2; a = τ⇩s; ξ' = ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈; q = p'⟧ ⟹ ∀dipa∈kD (rt ξ). rt ξ ⊑⇘dipa⇙ update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})›*)
fix ξ and pp and p'
assume "(ξ, pp) ∈ reachable (paodv i) (recvmsg rreq_rrep_sn)" and "{PRreq-:2}⟦λξ. ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp" and "Suc 0 ≤ osn ξ" and "*": "∀ip∈kD (rt ξ). Suc 0 ≤ the (dhops (rt ξ) ip)" (*‹(ξ::state, pp::(state, msg, pseqp, pseqp label) seqp) ∈ reachable (paodv (i::nat)) (recvmsg rreq_rrep_sn)› ‹{PRreq-:(2::int)}⟦λξ::state. ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
(p'::(state, msg, pseqp, pseqp label) seqp) ∈ sterms Γ⇩A⇩O⇩D⇩V (pp::(state, msg, pseqp, pseqp label) seqp)› ‹Suc (0::nat) ≤ osn (ξ::state)› ‹∀ip::nat∈kD (rt (ξ::state)). Suc (0::nat) ≤ the (dhops (rt ξ) ip)›*)
show "∀ip∈kD (rt ξ). rt ξ ⊑⇘ip⇙ update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})"
proof (standard)
(*goal: ‹⋀ip. ip ∈ kD (rt ξ) ⟹ rt ξ ⊑⇘ip⇙ update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})›*)
fix ip
assume "ip∈kD (rt ξ)" (*‹(ip::nat) ∈ kD (rt (ξ::state))›*)
moreover with "*" (*‹∀ip∈kD (rt ξ). Suc 0 ≤ the (dhops (rt ξ) ip)›*) have "1 ≤ the (dhops (rt ξ) ip)"
by simp
moreover from ‹Suc 0 ≤ osn ξ› (*‹Suc 0 ≤ osn ξ›*) have "update_arg_wf (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})"
by standard
ultimately show "rt ξ ⊑⇘ip⇙ update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})"
by (rule rt_fresher_update (*‹⟦?dip ∈ kD ?rt; 1 ≤ the (dhops ?rt ?dip); update_arg_wf ?r⟧ ⟹ ?rt ⊑⇘?dip⇙ update ?rt ?ip ?r›*))
qed
next
(*goal: ‹⋀p l ξ a q l' ξ' pp p'. ⟦l = PRrep-:1; ((ξ, {PRrep-:1}⟦λξ. ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
p'), τ⇩s, ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈, p') ∈ seqp_sos Γ⇩A⇩O⇩D⇩V; PRrep-:2 ∈ labels Γ⇩A⇩O⇩D⇩V p'; (ξ, pp) ∈ reachable (paodv i) (recvmsg rreq_rrep_sn); {PRrep-:1}⟦λξ. ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp; (ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈, p') ∈ reachable (paodv i) (recvmsg rreq_rrep_sn); Suc 0 ≤ dsn ξ; ∀ip∈kD (rt ξ). Suc 0 ≤ the (dhops (rt ξ) ip); p = {PRrep-:1}⟦λξ. ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
p'; l' = PRrep-:2; a = τ⇩s; ξ' = ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈; q = p'⟧ ⟹ ∀dipa∈kD (rt ξ). rt ξ ⊑⇘dipa⇙ update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})›*)
fix ξ and pp and p'
assume "(ξ, pp) ∈ reachable (paodv i) (recvmsg rreq_rrep_sn)" and "{PRrep-:1}⟦λξ. ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
p' ∈ sterms Γ⇩A⇩O⇩D⇩V pp" and "Suc 0 ≤ dsn ξ" and "*": "∀ip∈kD (rt ξ). Suc 0 ≤ the (dhops (rt ξ) ip)" (*‹(ξ::state, pp::(state, msg, pseqp, pseqp label) seqp) ∈ reachable (paodv (i::nat)) (recvmsg rreq_rrep_sn)› ‹{PRrep-:(1::int)}⟦λξ::state. ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧
(p'::(state, msg, pseqp, pseqp label) seqp) ∈ sterms Γ⇩A⇩O⇩D⇩V (pp::(state, msg, pseqp, pseqp label) seqp)› ‹Suc (0::nat) ≤ dsn (ξ::state)› ‹∀ip::nat∈kD (rt (ξ::state)). Suc (0::nat) ≤ the (dhops (rt ξ) ip)›*)
show "∀ip∈kD (rt ξ). rt ξ ⊑⇘ip⇙ update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})"
proof (standard)
(*goal: ‹⋀ip. ip ∈ kD (rt ξ) ⟹ rt ξ ⊑⇘ip⇙ update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})›*)
fix ip
assume "ip∈kD (rt ξ)" (*‹(ip::nat) ∈ kD (rt (ξ::state))›*)
moreover with "*" (*‹∀ip∈kD (rt ξ). Suc 0 ≤ the (dhops (rt ξ) ip)›*) have "1 ≤ the (dhops (rt ξ) ip)"
by simp
moreover from ‹Suc 0 ≤ dsn ξ› (*‹Suc 0 ≤ dsn ξ›*) have "update_arg_wf (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})"
by standard
ultimately show "rt ξ ⊑⇘ip⇙ update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})"
by (rule rt_fresher_update (*‹⟦?dip ∈ kD ?rt; 1 ≤ the (dhops ?rt ?dip); update_arg_wf ?r⟧ ⟹ ?rt ⊑⇘?dip⇙ update ?rt ?ip ?r›*))
qed
qed
end
| {
"path": "afp-2025-02-12/thys/AODV/variants/a_norreqid/A_Seq_Invariants.thy",
"repo": "afp-2025-02-12",
"sha": "e22133f37891a231781ed44bd088b87eeb2bd21a3d2eea3dc47a332eb4ac26a3"
} |
section ‹General well-formedness of While CFG›
theory WellFormed imports
Interpretation
Labels
"../Basic/CFGExit_wf"
"../StaticIntra/CDepInstantiations"
begin
subsection ‹Definition of some functions›
fun lhs :: "cmd ⇒ vname set"
where
"lhs Skip = {}"
| "lhs (V:=e) = {V}"
| "lhs (c₁;;c₂) = lhs c₁"
| "lhs (if (b) c₁ else c₂) = {}"
| "lhs (while (b) c) = {}"
fun rhs_aux :: "expr ⇒ vname set"
where
"rhs_aux (Val v) = {}"
| "rhs_aux (Var V) = {V}"
| "rhs_aux (e1 «bop» e2) = (rhs_aux e1 ∪ rhs_aux e2)"
fun rhs :: "cmd ⇒ vname set"
where
"rhs Skip = {}"
| "rhs (V:=e) = rhs_aux e"
| "rhs (c₁;;c₂) = rhs c₁"
| "rhs (if (b) c₁ else c₂) = rhs_aux b"
| "rhs (while (b) c) = rhs_aux b"
lemma rhs_interpret_eq:
"⟦interpret b s = Some v'; ∀V ∈ rhs_aux b. s V = s' V⟧
⟹ interpret b s' = Some v'"
proof (induct b arbitrary:v')
(*goals:
1. ‹⋀(x::val) v'::val. ⟦interpret (Val x) (s::char list ⇒ val option) = Some v'; ∀V::char list∈rhs_aux (Val x). s V = (s'::char list ⇒ val option) V⟧ ⟹ interpret (Val x) s' = Some v'›
2. ‹⋀(x::char list) v'::val. ⟦interpret (Var x) (s::char list ⇒ val option) = Some v'; ∀V::char list∈rhs_aux (Var x). s V = (s'::char list ⇒ val option) V⟧ ⟹ interpret (Var x) s' = Some v'›
3. ‹⋀(b1::expr) (x2a::bop) (b2::expr) v'::val. ⟦⋀v'::val. ⟦interpret b1 (s::char list ⇒ val option) = Some v'; ∀V::char list∈rhs_aux b1. s V = (s'::char list ⇒ val option) V⟧ ⟹ interpret b1 s' = Some v'; ⋀v'::val. ⟦interpret b2 s = Some v'; ∀V::char list∈rhs_aux b2. s V = s' V⟧ ⟹ interpret b2 s' = Some v'; interpret (b1 «x2a» b2) s = Some v'; ∀V::char list∈rhs_aux (b1 «x2a» b2). s V = s' V⟧ ⟹ interpret (b1 «x2a» b2) s' = Some v'›*)
case (Val v) (*‹interpret (Val v) s = Some v'› ‹∀V::char list∈rhs_aux (Val (v::val)). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V›*)
from ‹interpret (Val v) s = Some v'› (*‹interpret (Val (v::val)) (s::char list ⇒ val option) = Some (v'::val)›*) have "v' = v"
by (fastforce elim:interpret.cases (*‹⟦⋀v s. ?x = (Val v, s) ⟹ ?P; ⋀V s. ?x = (Var V, s) ⟹ ?P; ⋀e₁ bop e₂ s. ?x = (e₁ «bop» e₂, s) ⟹ ?P⟧ ⟹ ?P›*))
thus "?case"
(*goal: ‹interpret (Val (v::val)) (s'::char list ⇒ val option) = Some (v'::val)›*)
by simp
next
(*goals:
1. ‹⋀x v'. ⟦interpret (Var x) s = Some v'; ∀V∈rhs_aux (Var x). s V = s' V⟧ ⟹ interpret (Var x) s' = Some v'›
2. ‹⋀b1 x2a b2 v'. ⟦⋀v'. ⟦interpret b1 s = Some v'; ∀V∈rhs_aux b1. s V = s' V⟧ ⟹ interpret b1 s' = Some v'; ⋀v'. ⟦interpret b2 s = Some v'; ∀V∈rhs_aux b2. s V = s' V⟧ ⟹ interpret b2 s' = Some v'; interpret (b1 «x2a» b2) s = Some v'; ∀V∈rhs_aux (b1 «x2a» b2). s V = s' V⟧ ⟹ interpret (b1 «x2a» b2) s' = Some v'›*)
case (Var V) (*‹interpret (Var V) s = Some v'› ‹∀V∈rhs_aux (Var V). s V = s' V›*)
hence "s' V = Some v'"
by (fastforce elim:interpret.cases (*‹⟦⋀v s. ?x = (Val v, s) ⟹ ?P; ⋀V s. ?x = (Var V, s) ⟹ ?P; ⋀e₁ bop e₂ s. ?x = (e₁ «bop» e₂, s) ⟹ ?P⟧ ⟹ ?P›*))
thus "?case"
(*goal: ‹interpret (Var V) s' = Some v'›*)
by simp
next
(*goal: ‹⋀b1 x2a b2 v'. ⟦⋀v'. ⟦interpret b1 s = Some v'; ∀V∈rhs_aux b1. s V = s' V⟧ ⟹ interpret b1 s' = Some v'; ⋀v'. ⟦interpret b2 s = Some v'; ∀V∈rhs_aux b2. s V = s' V⟧ ⟹ interpret b2 s' = Some v'; interpret (b1 «x2a» b2) s = Some v'; ∀V∈rhs_aux (b1 «x2a» b2). s V = s' V⟧ ⟹ interpret (b1 «x2a» b2) s' = Some v'›*)
case (BinOp b1 bop b2) (*‹⟦interpret b1 s = Some ?v'; ∀V∈rhs_aux b1. s V = s' V⟧ ⟹ interpret b1 s' = Some ?v'› ‹⟦interpret b2 s = Some ?v'; ∀V∈rhs_aux b2. s V = s' V⟧ ⟹ interpret b2 s' = Some ?v'› ‹interpret (b1 «bop» b2) s = Some v'› ‹∀V::char list∈rhs_aux ((b1::expr) «bop::bop» (b2::expr)). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V›*)
note IH1 = ‹⋀v'. ⟦interpret b1 s = Some v'; ∀V ∈ rhs_aux b1. s V = s' V⟧
⟹ interpret b1 s' = Some v'› (*‹⟦interpret b1 s = Some ?v'; ∀V∈rhs_aux b1. s V = s' V⟧ ⟹ interpret b1 s' = Some ?v'›*)
note IH2 = ‹⋀v'. ⟦interpret b2 s = Some v'; ∀V ∈ rhs_aux b2. s V = s' V⟧
⟹ interpret b2 s' = Some v'› (*‹⟦interpret (b2::expr) (s::char list ⇒ val option) = Some (?v'::val); ∀V::char list∈rhs_aux b2. s V = (s'::char list ⇒ val option) V⟧ ⟹ interpret b2 s' = Some ?v'›*)
from ‹interpret (b1 «bop» b2) s = Some v'› (*‹interpret (b1 «bop» b2) s = Some v'›*) have "∃v₁ v₂. interpret b1 s = Some v₁ ∧ interpret b2 s = Some v₂ ∧
binop bop v₁ v₂ = Some v'"
apply (cases "interpret b1 s")
(*goals:
1. ‹⟦interpret (b1 «bop» b2) s = Some v'; interpret b1 s = None⟧ ⟹ ∃v₁ v₂. interpret b1 s = Some v₁ ∧ interpret b2 s = Some v₂ ∧ binop bop v₁ v₂ = Some v'›
2. ‹⋀a. ⟦interpret (b1 «bop» b2) s = Some v'; interpret b1 s = Some a⟧ ⟹ ∃v₁ v₂. interpret b1 s = Some v₁ ∧ interpret b2 s = Some v₂ ∧ binop bop v₁ v₂ = Some v'›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (cases "interpret b2 s")
(*goals:
1. ‹⋀a. ⟦interpret (b1 «bop» b2) s = Some v'; interpret b1 s = Some a; interpret b2 s = None⟧ ⟹ ∃v₁ v₂. interpret b1 s = Some v₁ ∧ interpret b2 s = Some v₂ ∧ binop bop v₁ v₂ = Some v'›
2. ‹⋀a aa. ⟦interpret (b1 «bop» b2) s = Some v'; interpret b1 s = Some a; interpret b2 s = Some aa⟧ ⟹ ∃v₁ v₂. interpret b1 s = Some v₁ ∧ interpret b2 s = Some v₂ ∧ binop bop v₁ v₂ = Some v'›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (case_tac "binop bop a aa")
(*goals:
1. ‹⋀a aa. ⟦interpret (b1 «bop» b2) s = Some v'; interpret b1 s = Some a; interpret b2 s = Some aa; binop bop a aa = None⟧ ⟹ ∃v₁ v₂. interpret b1 s = Some v₁ ∧ interpret b2 s = Some v₂ ∧ binop bop v₁ v₂ = Some v'›
2. ‹⋀a aa ab. ⟦interpret (b1 «bop» b2) s = Some v'; interpret b1 s = Some a; interpret b2 s = Some aa; binop bop a aa = Some ab⟧ ⟹ ∃v₁ v₂. interpret b1 s = Some v₁ ∧ interpret b2 s = Some v₂ ∧ binop bop v₁ v₂ = Some v'›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*)
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
then obtain v₁ and v₂ where "interpret b1 s = Some v₁" and "interpret b2 s = Some v₂" and "binop bop v₁ v₂ = Some v'"
(*goal: ‹(⋀v₁ v₂. ⟦interpret b1 s = Some v₁; interpret b2 s = Some v₂; binop bop v₁ v₂ = Some v'⟧ ⟹ thesis) ⟹ thesis›*)
by blast
from ‹∀V ∈ rhs_aux (b1 «bop» b2). s V = s' V› (*‹∀V∈rhs_aux (b1 «bop» b2). s V = s' V›*) have "∀V ∈ rhs_aux b1. s V = s' V"
by simp
from IH1[OF ‹interpret b1 s = Some v₁› this] (*‹interpret (b1::expr) (s'::char list ⇒ val option) = Some (v₁::val)›*) have "interpret b1 s' = Some v₁" .
from ‹∀V ∈ rhs_aux (b1 «bop» b2). s V = s' V› (*‹∀V∈rhs_aux (b1 «bop» b2). s V = s' V›*) have "∀V ∈ rhs_aux b2. s V = s' V"
by simp
from IH2[OF ‹interpret b2 s = Some v₂› this] (*‹interpret b2 s' = Some v₂›*) have "interpret b2 s' = Some v₂" .
with ‹interpret b1 s' = Some v₁› (*‹interpret b1 s' = Some v₁›*) ‹binop bop v₁ v₂ = Some v'› (*‹binop bop v₁ v₂ = Some v'›*) show "?case"
(*goal: ‹interpret ((b1::expr) «bop::bop» (b2::expr)) (s'::char list ⇒ val option) = Some (v'::val)›*)
by simp
qed
fun Defs :: "cmd ⇒ w_node ⇒ vname set"
where "Defs prog n = {V. ∃l c. n = (_ l _) ∧ labels prog l c ∧ V ∈ lhs c}"
fun Uses :: "cmd ⇒ w_node ⇒ vname set"
where "Uses prog n = {V. ∃l c. n = (_ l _) ∧ labels prog l c ∧ V ∈ rhs c}"
subsection ‹Lemmas about @{term "prog ⊢ n -et→ n'"} to show well-formed
properties›
lemma WCFG_edge_no_Defs_equal:
"⟦prog ⊢ n -et→ n'; V ∉ Defs prog n⟧ ⟹ (transfer et s) V = s V"
proof (induct rule:WCFG_induct (*‹⟦?x1a ⊢ ?x2a -?x3a→ ?x4a; ⋀prog. ?P prog (_Entry_) (λs. False)⇩√ (_Exit_); ⋀prog. ?P prog (_Entry_) (λs. True)⇩√ (_ 0 _); ?P Skip (_ 0 _) ⇑id (_Exit_); ⋀V e. ?P (V:=e) (_ 0 _) ⇑λs. s(V := interpret e s) (_ 1 _); ⋀V e. ?P (V:=e) (_ 1 _) ⇑id (_Exit_); ⋀c₁ n et n' c₂. ⟦c₁ ⊢ n -et→ n'; ?P c₁ n et n'; n' ≠ (_Exit_)⟧ ⟹ ?P (c₁;; c₂) n et n'; ⋀c₁ n et c₂. ⟦c₁ ⊢ n -et→ (_Exit_); ?P c₁ n et (_Exit_); n ≠ (_Entry_)⟧ ⟹ ?P (c₁;; c₂) n et ((_ 0 _) ⊕ #:c₁); ⋀c₂ n et n' c₁. ⟦c₂ ⊢ n -et→ n'; ?P c₂ n et n'; n ≠ (_Entry_)⟧ ⟹ ?P (c₁;; c₂) (n ⊕ #:c₁) et (n' ⊕ #:c₁); ⋀b c₁ c₂. ?P (if (b) c₁ else c₂) (_ 0 _) (λs. interpret b s = Some true)⇩√ ((_ 0 _) ⊕ 1); ⋀b c₁ c₂. ?P (if (b) c₁ else c₂) (_ 0 _) (λs. interpret b s = Some false)⇩√ ((_ 0 _) ⊕ #:c₁ + 1); ⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; ?P c₁ n et n'; n ≠ (_Entry_)⟧ ⟹ ?P (if (b) c₁ else c₂) (n ⊕ 1) et (n' ⊕ 1); ⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; ?P c₂ n et n'; n ≠ (_Entry_)⟧ ⟹ ?P (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1) et (n' ⊕ #:c₁ + 1); ⋀b c'. ?P (while (b) c') (_ 0 _) (λs. interpret b s = Some true)⇩√ ((_ 0 _) ⊕ 2); ⋀b c'. ?P (while (b) c') (_ 0 _) (λs. interpret b s = Some false)⇩√ (_ 1 _); ⋀b c'. ?P (while (b) c') (_ 1 _) ⇑id (_Exit_); ⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ?P c' n et n'; n ≠ (_Entry_); n' ≠ (_Exit_)⟧ ⟹ ?P (while (b) c') (n ⊕ 2) et (n' ⊕ 2); ⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ?P c' n et (_Exit_); n ≠ (_Entry_)⟧ ⟹ ?P (while (b) c') (n ⊕ 2) et (_ 0 _)⟧ ⟹ ?P ?x1a ?x2a ?x3a ?x4a›*))
(*goals:
1. ‹⋀prog::cmd. (V::char list) ∉ Defs prog (_Entry_) ⟹ transfer (λs::char list ⇒ val option. False)⇩√ (s::char list ⇒ val option) V = s V›
2. ‹⋀prog::cmd. (V::char list) ∉ Defs prog (_Entry_) ⟹ transfer (λs::char list ⇒ val option. True)⇩√ (s::char list ⇒ val option) V = s V›
3. ‹(V::char list) ∉ Defs Skip (_ 0::nat _) ⟹ transfer ⇑id (s::char list ⇒ val option) V = s V›
4. ‹⋀(Va::char list) e::expr. (V::char list) ∉ Defs (Va:=e) (_ 0::nat _) ⟹ transfer ⇑λs::char list ⇒ val option. s(Va := interpret e s) (s::char list ⇒ val option) V = s V›
5. ‹⋀(Va::char list) e::expr. (V::char list) ∉ Defs (Va:=e) (_ 1::nat _) ⟹ transfer ⇑id (s::char list ⇒ val option) V = s V›
6. ‹⋀(c₁::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) c₂::cmd. ⟦c₁ ⊢ n -et→ n'; (V::char list) ∉ Defs c₁ n ⟹ transfer et (s::char list ⇒ val option) V = s V; n' ≠ (_Exit_); V ∉ Defs (c₁;; c₂) n⟧ ⟹ transfer et s V = s V›
7. ‹⋀(c₁::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) c₂::cmd. ⟦c₁ ⊢ n -et→ (_Exit_); (V::char list) ∉ Defs c₁ n ⟹ transfer et (s::char list ⇒ val option) V = s V; n ≠ (_Entry_); V ∉ Defs (c₁;; c₂) n⟧ ⟹ transfer et s V = s V›
8. ‹⋀(c₂::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) c₁::cmd. ⟦c₂ ⊢ n -et→ n'; (V::char list) ∉ Defs c₂ n ⟹ transfer et (s::char list ⇒ val option) V = s V; n ≠ (_Entry_); V ∉ Defs (c₁;; c₂) (n ⊕ #:c₁)⟧ ⟹ transfer et s V = s V›
9. ‹⋀(b::expr) (c₁::cmd) c₂::cmd. (V::char list) ∉ Defs (if (b) c₁ else c₂) (_ 0::nat _) ⟹ transfer (λs::char list ⇒ val option. interpret b s = Some true)⇩√ (s::char list ⇒ val option) V = s V›
10. ‹⋀(b::expr) (c₁::cmd) c₂::cmd. (V::char list) ∉ Defs (if (b) c₁ else c₂) (_ 0::nat _) ⟹ transfer (λs::char list ⇒ val option. interpret b s = Some false)⇩√ (s::char list ⇒ val option) V = s V›
11. ‹⋀(c₁::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) (b::expr) c₂::cmd. ⟦c₁ ⊢ n -et→ n'; (V::char list) ∉ Defs c₁ n ⟹ transfer et (s::char list ⇒ val option) V = s V; n ≠ (_Entry_); V ∉ Defs (if (b) c₁ else c₂) (n ⊕ 1::nat)⟧ ⟹ transfer et s V = s V›
12. ‹⋀(c₂::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) (b::expr) c₁::cmd. ⟦c₂ ⊢ n -et→ n'; (V::char list) ∉ Defs c₂ n ⟹ transfer et (s::char list ⇒ val option) V = s V; n ≠ (_Entry_); V ∉ Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + (1::nat))⟧ ⟹ transfer et s V = s V›
13. ‹⋀(b::expr) c'::cmd. (V::char list) ∉ Defs (while (b) c') (_ 0::nat _) ⟹ transfer (λs::char list ⇒ val option. interpret b s = Some true)⇩√ (s::char list ⇒ val option) V = s V›
14. ‹⋀(b::expr) c'::cmd. (V::char list) ∉ Defs (while (b) c') (_ 0::nat _) ⟹ transfer (λs::char list ⇒ val option. interpret b s = Some false)⇩√ (s::char list ⇒ val option) V = s V›
15. ‹⋀(b::expr) c'::cmd. (V::char list) ∉ Defs (while (b) c') (_ 1::nat _) ⟹ transfer ⇑id (s::char list ⇒ val option) V = s V›
16. ‹⋀(c'::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) b::expr. ⟦c' ⊢ n -et→ n'; (V::char list) ∉ Defs c' n ⟹ transfer et (s::char list ⇒ val option) V = s V; n ≠ (_Entry_); n' ≠ (_Exit_); V ∉ Defs (while (b) c') (n ⊕ 2::nat)⟧ ⟹ transfer et s V = s V›
17. ‹⋀(c'::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) b::expr. ⟦c' ⊢ n -et→ (_Exit_); (V::char list) ∉ Defs c' n ⟹ transfer et (s::char list ⇒ val option) V = s V; n ≠ (_Entry_); V ∉ Defs (while (b) c') (n ⊕ 2::nat)⟧ ⟹ transfer et s V = s V›*)
case (WCFG_LAss V' e) (*‹(V::char list) ∉ Defs ((V'::char list):=(e::expr)) (_ 0::nat _)›*)
have label: "labels (V':=e) 0 (V':=e)" and lhs: "V' ∈ lhs (V':=e)"
(*goals:
1. ‹labels (V':=e) 0 (V':=e)›
2. ‹V' ∈ lhs (V':=e)›
discuss goal 1*)
apply ((auto intro:Labels_Base (*‹labels (?c::cmd) (0::nat) ?c›*))[1])
(*discuss goal 2*)
apply ((auto intro:Labels_Base (*‹labels (?c::cmd) (0::nat) ?c›*))[1])
(*proven 2 subgoals*) .
hence "V' ∈ Defs (V':=e) (_0_)"
by fastforce
with ‹V ∉ Defs (V':=e) (_0_)› (*‹(V::char list) ∉ Defs ((V'::char list):=(e::expr)) (_ 0::nat _)›*) show "?case"
(*goal: ‹transfer ⇑λs. s(V' := interpret e s) s V = s V›*)
by auto
next
(*goals:
1. ‹⋀prog. V ∉ Defs prog (_Entry_) ⟹ transfer (λs. False)⇩√ s V = s V›
2. ‹⋀prog. V ∉ Defs prog (_Entry_) ⟹ transfer (λs. True)⇩√ s V = s V›
3. ‹V ∉ Defs Skip (_ 0 _) ⟹ transfer ⇑id s V = s V›
4. ‹⋀Va e. V ∉ Defs (Va:=e) (_ 1 _) ⟹ transfer ⇑id s V = s V›
5. ‹⋀c₁ n et n' c₂. ⟦c₁ ⊢ n -et→ n'; V ∉ Defs c₁ n ⟹ transfer et s V = s V; n' ≠ (_Exit_); V ∉ Defs (c₁;; c₂) n⟧ ⟹ transfer et s V = s V›
6. ‹⋀c₁ n et c₂. ⟦c₁ ⊢ n -et→ (_Exit_); V ∉ Defs c₁ n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (c₁;; c₂) n⟧ ⟹ transfer et s V = s V›
7. ‹⋀c₂ n et n' c₁. ⟦c₂ ⊢ n -et→ n'; V ∉ Defs c₂ n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (c₁;; c₂) (n ⊕ #:c₁)⟧ ⟹ transfer et s V = s V›
8. ‹⋀b c₁ c₂. V ∉ Defs (if (b) c₁ else c₂) (_ 0 _) ⟹ transfer (λs. interpret b s = Some true)⇩√ s V = s V›
9. ‹⋀b c₁ c₂. V ∉ Defs (if (b) c₁ else c₂) (_ 0 _) ⟹ transfer (λs. interpret b s = Some false)⇩√ s V = s V›
10. ‹⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; V ∉ Defs c₁ n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (if (b) c₁ else c₂) (n ⊕ 1)⟧ ⟹ transfer et s V = s V›
11. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; V ∉ Defs c₂ n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1)⟧ ⟹ transfer et s V = s V›
12. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 0 _) ⟹ transfer (λs. interpret b s = Some true)⇩√ s V = s V›
13. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 0 _) ⟹ transfer (λs. interpret b s = Some false)⇩√ s V = s V›
14. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 1 _) ⟹ transfer ⇑id s V = s V›
15. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; V ∉ Defs c' n ⟹ transfer et s V = s V; n ≠ (_Entry_); n' ≠ (_Exit_); V ∉ Defs (while (b) c') (n ⊕ 2)⟧ ⟹ transfer et s V = s V›
16. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); V ∉ Defs c' n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (while (b) c') (n ⊕ 2)⟧ ⟹ transfer et s V = s V›*)
case (WCFG_SeqFirst c₁ n et n' c₂) (*‹c₁ ⊢ n -et→ n'› ‹V ∉ Defs c₁ n ⟹ transfer et s V = s V› ‹(n'::w_node) ≠ (_Exit_)› ‹V ∉ Defs (c₁;; c₂) n›*)
note IH = ‹V ∉ Defs c₁ n ⟹ transfer et s V = s V› (*‹V ∉ Defs c₁ n ⟹ transfer et s V = s V›*)
have "V ∉ Defs c₁ n"
proof (standard)
(*goal: ‹V ∈ Defs c₁ n ⟹ False›*)
assume "V ∈ Defs c₁ n" (*‹(V::char list) ∈ Defs (c₁::cmd) (n::w_node)›*)
then obtain c and l where [simp]: "n = (_ l _)" and "labels c₁ l c" and "V ∈ lhs c"
(*goal: ‹(⋀(l::nat) c::cmd. ⟦(n::w_node) = (_ l _); labels (c₁::cmd) l c; (V::char list) ∈ lhs c⟧ ⟹ thesis::bool) ⟹ thesis›*)
by fastforce
from ‹labels c₁ l c› (*‹labels c₁ l c›*) have "labels (c₁;;c₂) l (c;;c₂)"
by (fastforce intro:Labels_Seq1 (*‹labels (?c₁::cmd) (?l::nat) (?c::cmd) ⟹ labels (?c₁;; (?c₂::cmd)) ?l (?c;; ?c₂)›*))
from ‹V ∈ lhs c› (*‹(V::char list) ∈ lhs (c::cmd)›*) have "V ∈ lhs (c;;c₂)"
by simp
with ‹labels (c₁;;c₂) l (c;;c₂)› (*‹labels (c₁;; c₂) l (c;; c₂)›*) have "V ∈ Defs (c₁;;c₂) n"
by fastforce
with ‹V ∉ Defs (c₁;;c₂) n› (*‹V ∉ Defs (c₁;; c₂) n›*) show False
by fastforce
qed
from IH[OF this] (*‹transfer et s V = s V›*) show "?case"
(*goal: ‹transfer et s V = s V›*) .
next
(*goals:
1. ‹⋀prog. V ∉ Defs prog (_Entry_) ⟹ transfer (λs. False)⇩√ s V = s V›
2. ‹⋀prog. V ∉ Defs prog (_Entry_) ⟹ transfer (λs. True)⇩√ s V = s V›
3. ‹V ∉ Defs Skip (_ 0 _) ⟹ transfer ⇑id s V = s V›
4. ‹⋀Va e. V ∉ Defs (Va:=e) (_ 1 _) ⟹ transfer ⇑id s V = s V›
5. ‹⋀c₁ n et c₂. ⟦c₁ ⊢ n -et→ (_Exit_); V ∉ Defs c₁ n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (c₁;; c₂) n⟧ ⟹ transfer et s V = s V›
6. ‹⋀c₂ n et n' c₁. ⟦c₂ ⊢ n -et→ n'; V ∉ Defs c₂ n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (c₁;; c₂) (n ⊕ #:c₁)⟧ ⟹ transfer et s V = s V›
7. ‹⋀b c₁ c₂. V ∉ Defs (if (b) c₁ else c₂) (_ 0 _) ⟹ transfer (λs. interpret b s = Some true)⇩√ s V = s V›
8. ‹⋀b c₁ c₂. V ∉ Defs (if (b) c₁ else c₂) (_ 0 _) ⟹ transfer (λs. interpret b s = Some false)⇩√ s V = s V›
9. ‹⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; V ∉ Defs c₁ n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (if (b) c₁ else c₂) (n ⊕ 1)⟧ ⟹ transfer et s V = s V›
10. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; V ∉ Defs c₂ n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1)⟧ ⟹ transfer et s V = s V›
11. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 0 _) ⟹ transfer (λs. interpret b s = Some true)⇩√ s V = s V›
12. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 0 _) ⟹ transfer (λs. interpret b s = Some false)⇩√ s V = s V›
13. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 1 _) ⟹ transfer ⇑id s V = s V›
14. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; V ∉ Defs c' n ⟹ transfer et s V = s V; n ≠ (_Entry_); n' ≠ (_Exit_); V ∉ Defs (while (b) c') (n ⊕ 2)⟧ ⟹ transfer et s V = s V›
15. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); V ∉ Defs c' n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (while (b) c') (n ⊕ 2)⟧ ⟹ transfer et s V = s V›*)
case (WCFG_SeqConnect c₁ n et c₂) (*‹c₁ ⊢ n -et→ (_Exit_)› ‹V ∉ Defs c₁ n ⟹ transfer et s V = s V› ‹(n::w_node) ≠ (_Entry_)› ‹V ∉ Defs (c₁;; c₂) n›*)
note IH = ‹V ∉ Defs c₁ n ⟹ transfer et s V = s V› (*‹(V::char list) ∉ Defs (c₁::cmd) (n::w_node) ⟹ transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) V = s V›*)
have "V ∉ Defs c₁ n"
proof (standard)
(*goal: ‹V ∈ Defs c₁ n ⟹ False›*)
assume "V ∈ Defs c₁ n" (*‹(V::char list) ∈ Defs (c₁::cmd) (n::w_node)›*)
then obtain c and l where [simp]: "n = (_ l _)" and "labels c₁ l c" and "V ∈ lhs c"
(*goal: ‹(⋀l c. ⟦n = (_ l _); labels c₁ l c; V ∈ lhs c⟧ ⟹ thesis) ⟹ thesis›*)
by fastforce
from ‹labels c₁ l c› (*‹labels c₁ l c›*) have "labels (c₁;;c₂) l (c;;c₂)"
by (fastforce intro:Labels_Seq1 (*‹labels ?c₁ ?l ?c ⟹ labels (?c₁;; ?c₂) ?l (?c;; ?c₂)›*))
from ‹V ∈ lhs c› (*‹V ∈ lhs c›*) have "V ∈ lhs (c;;c₂)"
by simp
with ‹labels (c₁;;c₂) l (c;;c₂)› (*‹labels (c₁;; c₂) l (c;; c₂)›*) have "V ∈ Defs (c₁;;c₂) n"
by fastforce
with ‹V ∉ Defs (c₁;;c₂) n› (*‹(V::char list) ∉ Defs ((c₁::cmd);; (c₂::cmd)) (n::w_node)›*) show False
by fastforce
qed
from IH[OF this] (*‹transfer et s V = s V›*) show "?case"
(*goal: ‹transfer et s V = s V›*) .
next
(*goals:
1. ‹⋀prog::cmd. (V::char list) ∉ Defs prog (_Entry_) ⟹ transfer (λs::char list ⇒ val option. False)⇩√ (s::char list ⇒ val option) V = s V›
2. ‹⋀prog::cmd. (V::char list) ∉ Defs prog (_Entry_) ⟹ transfer (λs::char list ⇒ val option. True)⇩√ (s::char list ⇒ val option) V = s V›
3. ‹(V::char list) ∉ Defs Skip (_ 0::nat _) ⟹ transfer ⇑id (s::char list ⇒ val option) V = s V›
4. ‹⋀(Va::char list) e::expr. (V::char list) ∉ Defs (Va:=e) (_ 1::nat _) ⟹ transfer ⇑id (s::char list ⇒ val option) V = s V›
5. ‹⋀(c₂::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) c₁::cmd. ⟦c₂ ⊢ n -et→ n'; (V::char list) ∉ Defs c₂ n ⟹ transfer et (s::char list ⇒ val option) V = s V; n ≠ (_Entry_); V ∉ Defs (c₁;; c₂) (n ⊕ #:c₁)⟧ ⟹ transfer et s V = s V›
6. ‹⋀(b::expr) (c₁::cmd) c₂::cmd. (V::char list) ∉ Defs (if (b) c₁ else c₂) (_ 0::nat _) ⟹ transfer (λs::char list ⇒ val option. interpret b s = Some true)⇩√ (s::char list ⇒ val option) V = s V›
7. ‹⋀(b::expr) (c₁::cmd) c₂::cmd. (V::char list) ∉ Defs (if (b) c₁ else c₂) (_ 0::nat _) ⟹ transfer (λs::char list ⇒ val option. interpret b s = Some false)⇩√ (s::char list ⇒ val option) V = s V›
8. ‹⋀(c₁::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) (b::expr) c₂::cmd. ⟦c₁ ⊢ n -et→ n'; (V::char list) ∉ Defs c₁ n ⟹ transfer et (s::char list ⇒ val option) V = s V; n ≠ (_Entry_); V ∉ Defs (if (b) c₁ else c₂) (n ⊕ 1::nat)⟧ ⟹ transfer et s V = s V›
9. ‹⋀(c₂::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) (b::expr) c₁::cmd. ⟦c₂ ⊢ n -et→ n'; (V::char list) ∉ Defs c₂ n ⟹ transfer et (s::char list ⇒ val option) V = s V; n ≠ (_Entry_); V ∉ Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + (1::nat))⟧ ⟹ transfer et s V = s V›
10. ‹⋀(b::expr) c'::cmd. (V::char list) ∉ Defs (while (b) c') (_ 0::nat _) ⟹ transfer (λs::char list ⇒ val option. interpret b s = Some true)⇩√ (s::char list ⇒ val option) V = s V›
11. ‹⋀(b::expr) c'::cmd. (V::char list) ∉ Defs (while (b) c') (_ 0::nat _) ⟹ transfer (λs::char list ⇒ val option. interpret b s = Some false)⇩√ (s::char list ⇒ val option) V = s V›
12. ‹⋀(b::expr) c'::cmd. (V::char list) ∉ Defs (while (b) c') (_ 1::nat _) ⟹ transfer ⇑id (s::char list ⇒ val option) V = s V›
13. ‹⋀(c'::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) b::expr. ⟦c' ⊢ n -et→ n'; (V::char list) ∉ Defs c' n ⟹ transfer et (s::char list ⇒ val option) V = s V; n ≠ (_Entry_); n' ≠ (_Exit_); V ∉ Defs (while (b) c') (n ⊕ 2::nat)⟧ ⟹ transfer et s V = s V›
14. ‹⋀(c'::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) b::expr. ⟦c' ⊢ n -et→ (_Exit_); (V::char list) ∉ Defs c' n ⟹ transfer et (s::char list ⇒ val option) V = s V; n ≠ (_Entry_); V ∉ Defs (while (b) c') (n ⊕ 2::nat)⟧ ⟹ transfer et s V = s V›*)
case (WCFG_SeqSecond c₂ n et n' c₁) (*‹c₂ ⊢ n -et→ n'› ‹V ∉ Defs c₂ n ⟹ transfer et s V = s V› ‹n ≠ (_Entry_)› ‹V ∉ Defs (c₁;; c₂) (n ⊕ #:c₁)›*)
note IH = ‹V ∉ Defs c₂ n ⟹ transfer et s V = s V› (*‹V ∉ Defs c₂ n ⟹ transfer et s V = s V›*)
have "V ∉ Defs c₂ n"
proof (standard)
(*goal: ‹V ∈ Defs c₂ n ⟹ False›*)
assume "V ∈ Defs c₂ n" (*‹(V::char list) ∈ Defs (c₂::cmd) (n::w_node)›*)
then obtain c and l where [simp]: "n = (_ l _)" and "labels c₂ l c" and "V ∈ lhs c"
(*goal: ‹(⋀l c. ⟦n = (_ l _); labels c₂ l c; V ∈ lhs c⟧ ⟹ thesis) ⟹ thesis›*)
by fastforce
from ‹labels c₂ l c› (*‹labels c₂ l c›*) have "labels (c₁;;c₂) (l + #:c₁) c"
by (fastforce intro:Labels_Seq2 (*‹labels ?c₂ ?l ?c ⟹ labels (?c₁;; ?c₂) (?l + #:?c₁) ?c›*))
with ‹V ∈ lhs c› (*‹V ∈ lhs c›*) have "V ∈ Defs (c₁;;c₂) (n ⊕ #:c₁)"
by fastforce
with ‹V ∉ Defs (c₁;;c₂) (n ⊕ #:c₁)› (*‹V ∉ Defs (c₁;; c₂) (n ⊕ #:c₁)›*) show False
by fastforce
qed
from IH[OF this] (*‹transfer et s V = s V›*) show "?case"
(*goal: ‹transfer et s V = s V›*) .
next
(*goals:
1. ‹⋀prog. V ∉ Defs prog (_Entry_) ⟹ transfer (λs. False)⇩√ s V = s V›
2. ‹⋀prog. V ∉ Defs prog (_Entry_) ⟹ transfer (λs. True)⇩√ s V = s V›
3. ‹V ∉ Defs Skip (_ 0 _) ⟹ transfer ⇑id s V = s V›
4. ‹⋀Va e. V ∉ Defs (Va:=e) (_ 1 _) ⟹ transfer ⇑id s V = s V›
5. ‹⋀b c₁ c₂. V ∉ Defs (if (b) c₁ else c₂) (_ 0 _) ⟹ transfer (λs. interpret b s = Some true)⇩√ s V = s V›
6. ‹⋀b c₁ c₂. V ∉ Defs (if (b) c₁ else c₂) (_ 0 _) ⟹ transfer (λs. interpret b s = Some false)⇩√ s V = s V›
7. ‹⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; V ∉ Defs c₁ n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (if (b) c₁ else c₂) (n ⊕ 1)⟧ ⟹ transfer et s V = s V›
8. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; V ∉ Defs c₂ n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1)⟧ ⟹ transfer et s V = s V›
9. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 0 _) ⟹ transfer (λs. interpret b s = Some true)⇩√ s V = s V›
10. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 0 _) ⟹ transfer (λs. interpret b s = Some false)⇩√ s V = s V›
11. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 1 _) ⟹ transfer ⇑id s V = s V›
12. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; V ∉ Defs c' n ⟹ transfer et s V = s V; n ≠ (_Entry_); n' ≠ (_Exit_); V ∉ Defs (while (b) c') (n ⊕ 2)⟧ ⟹ transfer et s V = s V›
13. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); V ∉ Defs c' n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (while (b) c') (n ⊕ 2)⟧ ⟹ transfer et s V = s V›*)
case (WCFG_CondThen c₁ n et n' b c₂) (*‹c₁::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node› ‹V ∉ Defs c₁ n ⟹ transfer et s V = s V› ‹n ≠ (_Entry_)› ‹V ∉ Defs (if (b) c₁ else c₂) (n ⊕ 1)›*)
note IH = ‹V ∉ Defs c₁ n ⟹ transfer et s V = s V› (*‹(V::char list) ∉ Defs (c₁::cmd) (n::w_node) ⟹ transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) V = s V›*)
have "V ∉ Defs c₁ n"
proof (standard)
(*goal: ‹V ∈ Defs c₁ n ⟹ False›*)
assume "V ∈ Defs c₁ n" (*‹(V::char list) ∈ Defs (c₁::cmd) (n::w_node)›*)
then obtain c and l where [simp]: "n = (_ l _)" and "labels c₁ l c" and "V ∈ lhs c"
(*goal: ‹(⋀l c. ⟦n = (_ l _); labels c₁ l c; V ∈ lhs c⟧ ⟹ thesis) ⟹ thesis›*)
by fastforce
from ‹labels c₁ l c› (*‹labels c₁ l c›*) have "labels (if (b) c₁ else c₂) (l + 1) c"
by (fastforce intro:Labels_CondTrue (*‹labels ?c₁ ?l ?c ⟹ labels (if (?b) ?c₁ else ?c₂) (?l + 1) ?c›*))
with ‹V ∈ lhs c› (*‹V ∈ lhs c›*) have "V ∈ Defs (if (b) c₁ else c₂) (n ⊕ 1)"
by fastforce
with ‹V ∉ Defs (if (b) c₁ else c₂) (n ⊕ 1)› (*‹V ∉ Defs (if (b) c₁ else c₂) (n ⊕ 1)›*) show False
by fastforce
qed
from IH[OF this] (*‹transfer et s V = s V›*) show "?case"
(*goal: ‹transfer et s V = s V›*) .
next
(*goals:
1. ‹⋀prog. V ∉ Defs prog (_Entry_) ⟹ transfer (λs. False)⇩√ s V = s V›
2. ‹⋀prog. V ∉ Defs prog (_Entry_) ⟹ transfer (λs. True)⇩√ s V = s V›
3. ‹V ∉ Defs Skip (_ 0 _) ⟹ transfer ⇑id s V = s V›
4. ‹⋀Va e. V ∉ Defs (Va:=e) (_ 1 _) ⟹ transfer ⇑id s V = s V›
5. ‹⋀b c₁ c₂. V ∉ Defs (if (b) c₁ else c₂) (_ 0 _) ⟹ transfer (λs. interpret b s = Some true)⇩√ s V = s V›
6. ‹⋀b c₁ c₂. V ∉ Defs (if (b) c₁ else c₂) (_ 0 _) ⟹ transfer (λs. interpret b s = Some false)⇩√ s V = s V›
7. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; V ∉ Defs c₂ n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1)⟧ ⟹ transfer et s V = s V›
8. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 0 _) ⟹ transfer (λs. interpret b s = Some true)⇩√ s V = s V›
9. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 0 _) ⟹ transfer (λs. interpret b s = Some false)⇩√ s V = s V›
10. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 1 _) ⟹ transfer ⇑id s V = s V›
11. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; V ∉ Defs c' n ⟹ transfer et s V = s V; n ≠ (_Entry_); n' ≠ (_Exit_); V ∉ Defs (while (b) c') (n ⊕ 2)⟧ ⟹ transfer et s V = s V›
12. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); V ∉ Defs c' n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (while (b) c') (n ⊕ 2)⟧ ⟹ transfer et s V = s V›*)
case (WCFG_CondElse c₂ n et n' b c₁) (*‹c₂ ⊢ n -et→ n'› ‹V ∉ Defs c₂ n ⟹ transfer et s V = s V› ‹n ≠ (_Entry_)› ‹V ∉ Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1)›*)
note IH = ‹V ∉ Defs c₂ n ⟹ transfer et s V = s V› (*‹V ∉ Defs c₂ n ⟹ transfer et s V = s V›*)
have "V ∉ Defs c₂ n"
proof (standard)
(*goal: ‹V ∈ Defs c₂ n ⟹ False›*)
assume "V ∈ Defs c₂ n" (*‹(V::char list) ∈ Defs (c₂::cmd) (n::w_node)›*)
then obtain c and l where [simp]: "n = (_ l _)" and "labels c₂ l c" and "V ∈ lhs c"
(*goal: ‹(⋀l c. ⟦n = (_ l _); labels c₂ l c; V ∈ lhs c⟧ ⟹ thesis) ⟹ thesis›*)
by fastforce
from ‹labels c₂ l c› (*‹labels (c₂::cmd) (l::nat) (c::cmd)›*) have "labels (if (b) c₁ else c₂) (l + #:c₁ + 1) c"
by (fastforce intro:Labels_CondFalse (*‹labels ?c₂ ?l ?c ⟹ labels (if (?b) ?c₁ else ?c₂) (?l + #:?c₁ + 1) ?c›*))
with ‹V ∈ lhs c› (*‹V ∈ lhs c›*) have "V ∈ Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1)"
by (fastforce simp:add.commute (*‹?a + ?b = ?b + ?a›*) add.left_commute (*‹?b + (?a + ?c) = ?a + (?b + ?c)›*))
with ‹V ∉ Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1)› (*‹V ∉ Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1)›*) show False
by fastforce
qed
from IH[OF this] (*‹transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) (V::char list) = s V›*) show "?case"
(*goal: ‹transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) (V::char list) = s V›*) .
next
(*goals:
1. ‹⋀prog. V ∉ Defs prog (_Entry_) ⟹ transfer (λs. False)⇩√ s V = s V›
2. ‹⋀prog. V ∉ Defs prog (_Entry_) ⟹ transfer (λs. True)⇩√ s V = s V›
3. ‹V ∉ Defs Skip (_ 0 _) ⟹ transfer ⇑id s V = s V›
4. ‹⋀Va e. V ∉ Defs (Va:=e) (_ 1 _) ⟹ transfer ⇑id s V = s V›
5. ‹⋀b c₁ c₂. V ∉ Defs (if (b) c₁ else c₂) (_ 0 _) ⟹ transfer (λs. interpret b s = Some true)⇩√ s V = s V›
6. ‹⋀b c₁ c₂. V ∉ Defs (if (b) c₁ else c₂) (_ 0 _) ⟹ transfer (λs. interpret b s = Some false)⇩√ s V = s V›
7. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 0 _) ⟹ transfer (λs. interpret b s = Some true)⇩√ s V = s V›
8. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 0 _) ⟹ transfer (λs. interpret b s = Some false)⇩√ s V = s V›
9. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 1 _) ⟹ transfer ⇑id s V = s V›
10. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; V ∉ Defs c' n ⟹ transfer et s V = s V; n ≠ (_Entry_); n' ≠ (_Exit_); V ∉ Defs (while (b) c') (n ⊕ 2)⟧ ⟹ transfer et s V = s V›
11. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); V ∉ Defs c' n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (while (b) c') (n ⊕ 2)⟧ ⟹ transfer et s V = s V›*)
case (WCFG_WhileBody c' n et n' b) (*‹c' ⊢ n -et→ n'› ‹(V::char list) ∉ Defs (c'::cmd) (n::w_node) ⟹ transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) V = s V› ‹n ≠ (_Entry_)› ‹n' ≠ (_Exit_)› ‹V ∉ Defs (while (b) c') (n ⊕ 2)›*)
note IH = ‹V ∉ Defs c' n ⟹ transfer et s V = s V› (*‹V ∉ Defs c' n ⟹ transfer et s V = s V›*)
have "V ∉ Defs c' n"
proof (standard)
(*goal: ‹(V::char list) ∈ Defs (c'::cmd) (n::w_node) ⟹ False›*)
assume "V ∈ Defs c' n" (*‹(V::char list) ∈ Defs (c'::cmd) (n::w_node)›*)
then obtain c and l where [simp]: "n = (_ l _)" and "labels c' l c" and "V ∈ lhs c"
(*goal: ‹(⋀(l::nat) c::cmd. ⟦(n::w_node) = (_ l _); labels (c'::cmd) l c; (V::char list) ∈ lhs c⟧ ⟹ thesis::bool) ⟹ thesis›*)
by fastforce
from ‹labels c' l c› (*‹labels c' l c›*) have "labels (while (b) c') (l + 2) (c;;while (b) c')"
by (fastforce intro:Labels_WhileBody (*‹labels (?c'::cmd) (?l::nat) (?c::cmd) ⟹ labels (while ((?b::expr)) ?c') (?l + (2::nat)) (?c;; while (?b) ?c')›*))
from ‹V ∈ lhs c› (*‹V ∈ lhs c›*) have "V ∈ lhs (c;;while (b) c')"
by fastforce
with ‹labels (while (b) c') (l + 2) (c;;while (b) c')› (*‹labels (while ((b::expr)) (c'::cmd)) ((l::nat) + (2::nat)) ((c::cmd);; while (b) c')›*) have "V ∈ Defs (while (b) c') (n ⊕ 2)"
by fastforce
with ‹V ∉ Defs (while (b) c') (n ⊕ 2)› (*‹(V::char list) ∉ Defs (while ((b::expr)) (c'::cmd)) (n::w_node ⊕ 2::nat)›*) show False
by fastforce
qed
from IH[OF this] (*‹transfer et s V = s V›*) show "?case"
(*goal: ‹transfer et s V = s V›*) .
next
(*goals:
1. ‹⋀prog. V ∉ Defs prog (_Entry_) ⟹ transfer (λs. False)⇩√ s V = s V›
2. ‹⋀prog. V ∉ Defs prog (_Entry_) ⟹ transfer (λs. True)⇩√ s V = s V›
3. ‹V ∉ Defs Skip (_ 0 _) ⟹ transfer ⇑id s V = s V›
4. ‹⋀Va e. V ∉ Defs (Va:=e) (_ 1 _) ⟹ transfer ⇑id s V = s V›
5. ‹⋀b c₁ c₂. V ∉ Defs (if (b) c₁ else c₂) (_ 0 _) ⟹ transfer (λs. interpret b s = Some true)⇩√ s V = s V›
6. ‹⋀b c₁ c₂. V ∉ Defs (if (b) c₁ else c₂) (_ 0 _) ⟹ transfer (λs. interpret b s = Some false)⇩√ s V = s V›
7. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 0 _) ⟹ transfer (λs. interpret b s = Some true)⇩√ s V = s V›
8. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 0 _) ⟹ transfer (λs. interpret b s = Some false)⇩√ s V = s V›
9. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 1 _) ⟹ transfer ⇑id s V = s V›
10. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); V ∉ Defs c' n ⟹ transfer et s V = s V; n ≠ (_Entry_); V ∉ Defs (while (b) c') (n ⊕ 2)⟧ ⟹ transfer et s V = s V›*)
case (WCFG_WhileBodyExit c' n et b) (*‹c' ⊢ n -et→ (_Exit_)› ‹V ∉ Defs c' n ⟹ transfer et s V = s V› ‹(n::w_node) ≠ (_Entry_)› ‹V ∉ Defs (while (b) c') (n ⊕ 2)›*)
note IH = ‹V ∉ Defs c' n ⟹ transfer et s V = s V› (*‹V ∉ Defs c' n ⟹ transfer et s V = s V›*)
have "V ∉ Defs c' n"
proof (standard)
(*goal: ‹(V::char list) ∈ Defs (c'::cmd) (n::w_node) ⟹ False›*)
assume "V ∈ Defs c' n" (*‹(V::char list) ∈ Defs (c'::cmd) (n::w_node)›*)
then obtain c and l where [simp]: "n = (_ l _)" and "labels c' l c" and "V ∈ lhs c"
(*goal: ‹(⋀l c. ⟦n = (_ l _); labels c' l c; V ∈ lhs c⟧ ⟹ thesis) ⟹ thesis›*)
by fastforce
from ‹labels c' l c› (*‹labels c' l c›*) have "labels (while (b) c') (l + 2) (c;;while (b) c')"
by (fastforce intro:Labels_WhileBody (*‹labels ?c' ?l ?c ⟹ labels (while (?b) ?c') (?l + 2) (?c;; while (?b) ?c')›*))
from ‹V ∈ lhs c› (*‹V ∈ lhs c›*) have "V ∈ lhs (c;;while (b) c')"
by fastforce
with ‹labels (while (b) c') (l + 2) (c;;while (b) c')› (*‹labels (while ((b::expr)) (c'::cmd)) ((l::nat) + (2::nat)) ((c::cmd);; while (b) c')›*) have "V ∈ Defs (while (b) c') (n ⊕ 2)"
by fastforce
with ‹V ∉ Defs (while (b) c') (n ⊕ 2)› (*‹(V::char list) ∉ Defs (while ((b::expr)) (c'::cmd)) (n::w_node ⊕ 2::nat)›*) show False
by fastforce
qed
from IH[OF this] (*‹transfer et s V = s V›*) show "?case"
(*goal: ‹transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) (V::char list) = s V›*) .
qed (auto)
(*solves the remaining goals:
1. ‹⋀prog. V ∉ Defs prog (_Entry_) ⟹ transfer (λs. False)⇩√ s V = s V›
2. ‹⋀prog. V ∉ Defs prog (_Entry_) ⟹ transfer (λs. True)⇩√ s V = s V›
3. ‹V ∉ Defs Skip (_ 0 _) ⟹ transfer ⇑id s V = s V›
4. ‹⋀Va e. V ∉ Defs (Va:=e) (_ 1 _) ⟹ transfer ⇑id s V = s V›
5. ‹⋀b c₁ c₂. V ∉ Defs (if (b) c₁ else c₂) (_ 0 _) ⟹ transfer (λs. interpret b s = Some true)⇩√ s V = s V›
6. ‹⋀b c₁ c₂. V ∉ Defs (if (b) c₁ else c₂) (_ 0 _) ⟹ transfer (λs. interpret b s = Some false)⇩√ s V = s V›
7. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 0 _) ⟹ transfer (λs. interpret b s = Some true)⇩√ s V = s V›
8. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 0 _) ⟹ transfer (λs. interpret b s = Some false)⇩√ s V = s V›
9. ‹⋀b c'. V ∉ Defs (while (b) c') (_ 1 _) ⟹ transfer ⇑id s V = s V›*)
(*<*)declare One_nat_def [simp del](*>*)
lemma WCFG_edge_transfer_uses_only_Uses:
"⟦prog ⊢ n -et→ n'; ∀V ∈ Uses prog n. s V = s' V⟧
⟹ ∀V ∈ Defs prog n. (transfer et s) V = (transfer et s') V"
proof (induct rule:WCFG_induct (*‹⟦?x1a ⊢ ?x2a -?x3a→ ?x4a; ⋀prog. ?P prog (_Entry_) (λs. False)⇩√ (_Exit_); ⋀prog. ?P prog (_Entry_) (λs. True)⇩√ (_ 0 _); ?P Skip (_ 0 _) ⇑id (_Exit_); ⋀V e. ?P (V:=e) (_ 0 _) ⇑λs. s(V := interpret e s) (_ 1 _); ⋀V e. ?P (V:=e) (_ 1 _) ⇑id (_Exit_); ⋀c₁ n et n' c₂. ⟦c₁ ⊢ n -et→ n'; ?P c₁ n et n'; n' ≠ (_Exit_)⟧ ⟹ ?P (c₁;; c₂) n et n'; ⋀c₁ n et c₂. ⟦c₁ ⊢ n -et→ (_Exit_); ?P c₁ n et (_Exit_); n ≠ (_Entry_)⟧ ⟹ ?P (c₁;; c₂) n et ((_ 0 _) ⊕ #:c₁); ⋀c₂ n et n' c₁. ⟦c₂ ⊢ n -et→ n'; ?P c₂ n et n'; n ≠ (_Entry_)⟧ ⟹ ?P (c₁;; c₂) (n ⊕ #:c₁) et (n' ⊕ #:c₁); ⋀b c₁ c₂. ?P (if (b) c₁ else c₂) (_ 0 _) (λs. interpret b s = Some true)⇩√ ((_ 0 _) ⊕ 1); ⋀b c₁ c₂. ?P (if (b) c₁ else c₂) (_ 0 _) (λs. interpret b s = Some false)⇩√ ((_ 0 _) ⊕ #:c₁ + 1); ⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; ?P c₁ n et n'; n ≠ (_Entry_)⟧ ⟹ ?P (if (b) c₁ else c₂) (n ⊕ 1) et (n' ⊕ 1); ⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; ?P c₂ n et n'; n ≠ (_Entry_)⟧ ⟹ ?P (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1) et (n' ⊕ #:c₁ + 1); ⋀b c'. ?P (while (b) c') (_ 0 _) (λs. interpret b s = Some true)⇩√ ((_ 0 _) ⊕ 2); ⋀b c'. ?P (while (b) c') (_ 0 _) (λs. interpret b s = Some false)⇩√ (_ 1 _); ⋀b c'. ?P (while (b) c') (_ 1 _) ⇑id (_Exit_); ⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ?P c' n et n'; n ≠ (_Entry_); n' ≠ (_Exit_)⟧ ⟹ ?P (while (b) c') (n ⊕ 2) et (n' ⊕ 2); ⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ?P c' n et (_Exit_); n ≠ (_Entry_)⟧ ⟹ ?P (while (b) c') (n ⊕ 2) et (_ 0 _)⟧ ⟹ ?P ?x1a ?x2a ?x3a ?x4a›*))
(*goals:
1. ‹⋀prog. ∀V∈Uses prog (_Entry_). s V = s' V ⟹ ∀V∈Defs prog (_Entry_). transfer (λs. False)⇩√ s V = transfer (λs. False)⇩√ s' V›
2. ‹⋀prog. ∀V∈Uses prog (_Entry_). s V = s' V ⟹ ∀V∈Defs prog (_Entry_). transfer (λs. True)⇩√ s V = transfer (λs. True)⇩√ s' V›
3. ‹∀V∈Uses Skip (_ 0 _). s V = s' V ⟹ ∀V∈Defs Skip (_ 0 _). transfer ⇑id s V = transfer ⇑id s' V›
4. ‹⋀V e. ∀V∈Uses (V:=e) (_ 0 _). s V = s' V ⟹ ∀Va∈Defs (V:=e) (_ 0 _). transfer ⇑λs. s(V := interpret e s) s Va = transfer ⇑λs. s(V := interpret e s) s' Va›
5. ‹⋀V e. ∀V∈Uses (V:=e) (_ 1 _). s V = s' V ⟹ ∀V∈Defs (V:=e) (_ 1 _). transfer ⇑id s V = transfer ⇑id s' V›
6. ‹⋀c₁ n et n' c₂. ⟦c₁ ⊢ n -et→ n'; ∀V∈Uses c₁ n. s V = s' V ⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V; n' ≠ (_Exit_); ∀V∈Uses (c₁;; c₂) n. s V = s' V⟧ ⟹ ∀V∈Defs (c₁;; c₂) n. transfer et s V = transfer et s' V›
7. ‹⋀c₁ n et c₂. ⟦c₁ ⊢ n -et→ (_Exit_); ∀V∈Uses c₁ n. s V = s' V ⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (c₁;; c₂) n. s V = s' V⟧ ⟹ ∀V∈Defs (c₁;; c₂) n. transfer et s V = transfer et s' V›
8. ‹⋀c₂ n et n' c₁. ⟦c₂ ⊢ n -et→ n'; ∀V∈Uses c₂ n. s V = s' V ⟹ ∀V∈Defs c₂ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (c₁;; c₂) (n ⊕ #:c₁). s V = s' V⟧ ⟹ ∀V∈Defs (c₁;; c₂) (n ⊕ #:c₁). transfer et s V = transfer et s' V›
9. ‹⋀b c₁ c₂. ∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V ⟹ ∀V∈Defs (if (b) c₁ else c₂) (_ 0 _). transfer (λs. interpret b s = Some true)⇩√ s V = transfer (λs. interpret b s = Some true)⇩√ s' V›
10. ‹⋀b c₁ c₂. ∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V ⟹ ∀V∈Defs (if (b) c₁ else c₂) (_ 0 _). transfer (λs. interpret b s = Some false)⇩√ s V = transfer (λs. interpret b s = Some false)⇩√ s' V›
11. ‹⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; ∀V∈Uses c₁ n. s V = s' V ⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V⟧ ⟹ ∀V∈Defs (if (b) c₁ else c₂) (n ⊕ 1). transfer et s V = transfer et s' V›
12. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; ∀V∈Uses c₂ n. s V = s' V ⟹ ∀V∈Defs c₂ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V⟧ ⟹ ∀V∈Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). transfer et s V = transfer et s' V›
13. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 0 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 0 _). transfer (λs. interpret b s = Some true)⇩√ s V = transfer (λs. interpret b s = Some true)⇩√ s' V›
14. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 0 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 0 _). transfer (λs. interpret b s = Some false)⇩√ s V = transfer (λs. interpret b s = Some false)⇩√ s' V›
15. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 1 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 1 _). transfer ⇑id s V = transfer ⇑id s' V›
16. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V⟧ ⟹ ∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›
17. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V⟧ ⟹ ∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›*)
case (WCFG_LAss V e) (*‹∀V∈Uses (V:=e) (_ 0 _). s V = s' V›*)
have "Uses (V:=e) (_0_) = {V. V ∈ rhs_aux e}"
by (fastforce elim:labels.cases (*‹⟦labels ?a1.0 ?a2.0 ?a3.0; ⋀c. ⟦?a1.0 = c; ?a2.0 = 0; ?a3.0 = c⟧ ⟹ ?P; ⋀V e. ⟦?a1.0 = V:=e; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P; ⋀c₁ l c c₂. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l; ?a3.0 = c;; c₂; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c c₁. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l + #:c₁; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c₁ l c b c₂. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + 1; ?a3.0 = c; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c b c₁. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + #:c₁ + 1; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c' l c b. ⟦?a1.0 = while (b) c'; ?a2.0 = l + 2; ?a3.0 = c;; while (b) c'; labels c' l c⟧ ⟹ ?P; ⋀b c'. ⟦?a1.0 = while (b) c'; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P⟧ ⟹ ?P›*) intro:Labels_Base (*‹labels ?c 0 ?c›*))
with ‹∀V'∈Uses (V:=e) (_0_). s V' = s' V'› (*‹∀V'∈Uses (V:=e) (_ 0 _). s V' = s' V'›*) have "∀V'∈rhs_aux e. s V' = s' V'"
by blast
have "Defs (V:=e) (_0_) = {V}"
by (fastforce elim:labels.cases (*‹⟦labels ?a1.0 ?a2.0 ?a3.0; ⋀c. ⟦?a1.0 = c; ?a2.0 = 0; ?a3.0 = c⟧ ⟹ ?P; ⋀V e. ⟦?a1.0 = V:=e; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P; ⋀c₁ l c c₂. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l; ?a3.0 = c;; c₂; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c c₁. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l + #:c₁; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c₁ l c b c₂. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + 1; ?a3.0 = c; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c b c₁. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + #:c₁ + 1; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c' l c b. ⟦?a1.0 = while (b) c'; ?a2.0 = l + 2; ?a3.0 = c;; while (b) c'; labels c' l c⟧ ⟹ ?P; ⋀b c'. ⟦?a1.0 = while (b) c'; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P⟧ ⟹ ?P›*) intro:Labels_Base (*‹labels ?c 0 ?c›*))
have "transfer ⇑λs. s(V := interpret e s) s V =
transfer ⇑λs. s(V := interpret e s) s' V"
proof (cases "interpret e s")
(*goals:
1. ‹interpret e s = None ⟹ transfer ⇑λs. s(V := interpret e s) s V = transfer ⇑λs. s(V := interpret e s) s' V›
2. ‹⋀a. interpret e s = Some a ⟹ transfer ⇑λs. s(V := interpret e s) s V = transfer ⇑λs. s(V := interpret e s) s' V›*)
case None (*‹interpret e s = None›*)
{
fix v
assume "interpret e s' = Some v" (*‹interpret (e::expr) (s'::char list ⇒ val option) = Some (v::val)›*)
with ‹∀V'∈rhs_aux e. s V' = s' V'› (*‹∀V'∈rhs_aux e. s V' = s' V'›*) have "interpret e s = Some v"
by (fastforce intro:rhs_interpret_eq (*‹⟦interpret (?b::expr) (?s::char list ⇒ val option) = Some (?v'::val); ∀V::char list∈rhs_aux ?b. ?s V = (?s'::char list ⇒ val option) V⟧ ⟹ interpret ?b ?s' = Some ?v'›*))
with None (*‹interpret e s = None›*) have False
by (fastforce split:if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
}
with None (*‹interpret e s = None›*) show "?thesis"
(*goal: ‹transfer ⇑λs. s(V := interpret e s) s V = transfer ⇑λs. s(V := interpret e s) s' V›*)
by fastforce
next
(*goal: ‹⋀a. interpret e s = Some a ⟹ transfer ⇑λs. s(V := interpret e s) s V = transfer ⇑λs. s(V := interpret e s) s' V›*)
case (Some v) (*‹interpret e s = Some v›*)
hence "interpret e s = Some v"
by (fastforce split:if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
with ‹∀V'∈rhs_aux e. s V' = s' V'› (*‹∀V'∈rhs_aux e. s V' = s' V'›*) have "interpret e s' = Some v"
by (fastforce intro:rhs_interpret_eq (*‹⟦interpret ?b ?s = Some ?v'; ∀V∈rhs_aux ?b. ?s V = ?s' V⟧ ⟹ interpret ?b ?s' = Some ?v'›*))
with Some (*‹interpret e s = Some v›*) show "?thesis"
(*goal: ‹transfer ⇑λs. s(V := interpret e s) s V = transfer ⇑λs. s(V := interpret e s) s' V›*)
by simp
qed
with ‹Defs (V:=e) (_0_) = {V}› (*‹Defs (V:=e) (_ 0 _) = {V}›*) show "?case"
(*goal: ‹∀Va∈Defs (V:=e) (_ 0 _). transfer ⇑λs. s(V := interpret e s) s Va = transfer ⇑λs. s(V := interpret e s) s' Va›*)
by simp
next
(*goals:
1. ‹⋀prog. ∀V∈Uses prog (_Entry_). s V = s' V ⟹ ∀V∈Defs prog (_Entry_). transfer (λs. False)⇩√ s V = transfer (λs. False)⇩√ s' V›
2. ‹⋀prog. ∀V∈Uses prog (_Entry_). s V = s' V ⟹ ∀V∈Defs prog (_Entry_). transfer (λs. True)⇩√ s V = transfer (λs. True)⇩√ s' V›
3. ‹∀V∈Uses Skip (_ 0 _). s V = s' V ⟹ ∀V∈Defs Skip (_ 0 _). transfer ⇑id s V = transfer ⇑id s' V›
4. ‹⋀V e. ∀V∈Uses (V:=e) (_ 1 _). s V = s' V ⟹ ∀V∈Defs (V:=e) (_ 1 _). transfer ⇑id s V = transfer ⇑id s' V›
5. ‹⋀c₁ n et n' c₂. ⟦c₁ ⊢ n -et→ n'; ∀V∈Uses c₁ n. s V = s' V ⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V; n' ≠ (_Exit_); ∀V∈Uses (c₁;; c₂) n. s V = s' V⟧ ⟹ ∀V∈Defs (c₁;; c₂) n. transfer et s V = transfer et s' V›
6. ‹⋀c₁ n et c₂. ⟦c₁ ⊢ n -et→ (_Exit_); ∀V∈Uses c₁ n. s V = s' V ⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (c₁;; c₂) n. s V = s' V⟧ ⟹ ∀V∈Defs (c₁;; c₂) n. transfer et s V = transfer et s' V›
7. ‹⋀c₂ n et n' c₁. ⟦c₂ ⊢ n -et→ n'; ∀V∈Uses c₂ n. s V = s' V ⟹ ∀V∈Defs c₂ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (c₁;; c₂) (n ⊕ #:c₁). s V = s' V⟧ ⟹ ∀V∈Defs (c₁;; c₂) (n ⊕ #:c₁). transfer et s V = transfer et s' V›
8. ‹⋀b c₁ c₂. ∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V ⟹ ∀V∈Defs (if (b) c₁ else c₂) (_ 0 _). transfer (λs. interpret b s = Some true)⇩√ s V = transfer (λs. interpret b s = Some true)⇩√ s' V›
9. ‹⋀b c₁ c₂. ∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V ⟹ ∀V∈Defs (if (b) c₁ else c₂) (_ 0 _). transfer (λs. interpret b s = Some false)⇩√ s V = transfer (λs. interpret b s = Some false)⇩√ s' V›
10. ‹⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; ∀V∈Uses c₁ n. s V = s' V ⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V⟧ ⟹ ∀V∈Defs (if (b) c₁ else c₂) (n ⊕ 1). transfer et s V = transfer et s' V›
11. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; ∀V∈Uses c₂ n. s V = s' V ⟹ ∀V∈Defs c₂ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V⟧ ⟹ ∀V∈Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). transfer et s V = transfer et s' V›
12. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 0 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 0 _). transfer (λs. interpret b s = Some true)⇩√ s V = transfer (λs. interpret b s = Some true)⇩√ s' V›
13. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 0 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 0 _). transfer (λs. interpret b s = Some false)⇩√ s V = transfer (λs. interpret b s = Some false)⇩√ s' V›
14. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 1 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 1 _). transfer ⇑id s V = transfer ⇑id s' V›
15. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V⟧ ⟹ ∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›
16. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V⟧ ⟹ ∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›*)
case (WCFG_SeqFirst c₁ n et n' c₂) (*‹c₁ ⊢ n -et→ n'› ‹∀V∈Uses c₁ n. s V = s' V ⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V› ‹n' ≠ (_Exit_)› ‹∀V∈Uses (c₁;; c₂) n. s V = s' V›*)
note IH = ‹∀V∈Uses c₁ n. s V = s' V
⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V› (*‹∀V∈Uses c₁ n. s V = s' V ⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V›*)
from ‹∀V∈Uses (c₁;;c₂) n. s V = s' V› (*‹∀V∈Uses (c₁;; c₂) n. s V = s' V›*) have "∀V∈Uses c₁ n. s V = s' V"
apply auto
(*goal: ‹∀V∈Uses c₁ n. s V = s' V›*)
apply (drule Labels_Seq1[of _ _ _ c₂] (*‹labels (?c₁::cmd) (?l::nat) (?c::cmd) ⟹ labels (?c₁;; (c₂::cmd)) ?l (?c;; c₂)›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (c₁;; c₂) l c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); labels c₁ l c; V ∈ rhs c⟧ ⟹ s V = s' V›*)
apply (erule_tac x="V" in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (c₁;; c₂) l c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); V ∈ rhs c; labels (c₁;; c₂) l (c;; c₂)⟧ ⟹ s V = s' V›*)
by auto
from IH[OF this] (*‹∀V∈Defs c₁ n. transfer et s V = transfer et s' V›*) have "∀V∈Defs c₁ n. transfer et s V = transfer et s' V" .
with ‹c₁ ⊢ n -et→ n'› (*‹c₁::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node›*) show "?case"
(*goal: ‹∀V∈Defs (c₁;; c₂) n. transfer et s V = transfer et s' V›*)
using Labels_Base (*‹labels (?c::cmd) (0::nat) ?c›*) apply clarsimp
(*goal: ‹∀V∈Defs (c₁;; c₂) n. transfer et s V = transfer et s' V›*)
apply (erule labels.cases (*‹⟦labels ?a1.0 ?a2.0 ?a3.0; ⋀c. ⟦?a1.0 = c; ?a2.0 = 0; ?a3.0 = c⟧ ⟹ ?P; ⋀V e. ⟦?a1.0 = V:=e; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P; ⋀c₁ l c c₂. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l; ?a3.0 = c;; c₂; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c c₁. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l + #:c₁; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c₁ l c b c₂. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + 1; ?a3.0 = c; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c b c₁. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + #:c₁ + 1; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c' l c b. ⟦?a1.0 = while (b) c'; ?a2.0 = l + 2; ?a3.0 = c;; while (b) c'; labels c' l c⟧ ⟹ ?P; ⋀b c'. ⟦?a1.0 = while (b) c'; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P⟧ ⟹ ?P›*))
(*goals:
1. ‹⋀V l c ca. ⟦c₁ ⊢ (_ l _) -et→ n'; ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = ca; l = 0; c = ca⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀V l c Va e. ⟦c₁ ⊢ (_ l _) -et→ n'; ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = Va:=e; l = 1; c = Skip⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀V l c c₁' la ca c₂'. ⟦c₁ ⊢ (_ l _) -et→ n'; ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = c₁';; c₂'; l = la; c = ca;; c₂'; labels c₁' la ca⟧ ⟹ transfer et s V = transfer et s' V›
4. ‹⋀V l c c₂' la ca c₁'. ⟦c₁ ⊢ (_ l _) -et→ n'; ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = c₁';; c₂'; l = la + #:c₁'; c = ca; labels c₂' la ca⟧ ⟹ transfer et s V = transfer et s' V›
5. ‹⋀V l c c₁' la ca b c₂'. ⟦c₁ ⊢ (_ l _) -et→ n'; ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = if (b) c₁' else c₂'; l = la + 1; c = ca; labels c₁' la ca⟧ ⟹ transfer et s V = transfer et s' V›
6. ‹⋀V l c c₂' la ca b c₁'. ⟦c₁ ⊢ (_ l _) -et→ n'; ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = if (b) c₁' else c₂'; l = la + #:c₁' + 1; c = ca; labels c₂' la ca⟧ ⟹ transfer et s V = transfer et s' V›
7. ‹⋀V l c c' la ca b. ⟦c₁ ⊢ (_ l _) -et→ n'; ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = while (b) c'; l = la + 2; c = ca;; while (b) c'; labels c' la ca⟧ ⟹ transfer et s V = transfer et s' V›
8. ‹⋀V l c b c'. ⟦c₁ ⊢ (_ l _) -et→ n'; ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = while (b) c'; l = 1; c = Skip⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*top goal: ‹⋀V l c ca. ⟦c₁ ⊢ (_ l _) -et→ n'; ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = ca; l = 0; c = ca⟧ ⟹ transfer et s V = transfer et s' V› and 7 goals remain*)
apply (erule_tac x="V" in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*top goal: ‹⋀V. ⟦c₁ ⊢ (_ 0 _) -et→ n'; ∀V. (∃c. labels c₁ 0 c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ 0 _); V ∈ lhs c₁⟧ ⟹ transfer et s V = transfer et s' V› and 7 goals remain*)
apply fastforce
(*discuss goal 2*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog::cmd ⊢ (_ ?l::nat _) -?et::(char list ⇒ val option) edge_kind→ ?n'::w_node ⟹ ?l < #:?prog›*))[1])
(*discuss goal 3*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog::cmd ⊢ (_ ?l::nat _) -?et::(char list ⇒ val option) edge_kind→ ?n'::w_node ⟹ ?l < #:?prog›*))[1])
(*discuss goal 4*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*discuss goal 5*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*discuss goal 6*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*discuss goal 7*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*discuss goal 8*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*proven 8 subgoals*) .
next
(*goals:
1. ‹⋀prog. ∀V∈Uses prog (_Entry_). s V = s' V ⟹ ∀V∈Defs prog (_Entry_). transfer (λs. False)⇩√ s V = transfer (λs. False)⇩√ s' V›
2. ‹⋀prog. ∀V∈Uses prog (_Entry_). s V = s' V ⟹ ∀V∈Defs prog (_Entry_). transfer (λs. True)⇩√ s V = transfer (λs. True)⇩√ s' V›
3. ‹∀V∈Uses Skip (_ 0 _). s V = s' V ⟹ ∀V∈Defs Skip (_ 0 _). transfer ⇑id s V = transfer ⇑id s' V›
4. ‹⋀V e. ∀V∈Uses (V:=e) (_ 1 _). s V = s' V ⟹ ∀V∈Defs (V:=e) (_ 1 _). transfer ⇑id s V = transfer ⇑id s' V›
5. ‹⋀c₁ n et c₂. ⟦c₁ ⊢ n -et→ (_Exit_); ∀V∈Uses c₁ n. s V = s' V ⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (c₁;; c₂) n. s V = s' V⟧ ⟹ ∀V∈Defs (c₁;; c₂) n. transfer et s V = transfer et s' V›
6. ‹⋀c₂ n et n' c₁. ⟦c₂ ⊢ n -et→ n'; ∀V∈Uses c₂ n. s V = s' V ⟹ ∀V∈Defs c₂ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (c₁;; c₂) (n ⊕ #:c₁). s V = s' V⟧ ⟹ ∀V∈Defs (c₁;; c₂) (n ⊕ #:c₁). transfer et s V = transfer et s' V›
7. ‹⋀b c₁ c₂. ∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V ⟹ ∀V∈Defs (if (b) c₁ else c₂) (_ 0 _). transfer (λs. interpret b s = Some true)⇩√ s V = transfer (λs. interpret b s = Some true)⇩√ s' V›
8. ‹⋀b c₁ c₂. ∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V ⟹ ∀V∈Defs (if (b) c₁ else c₂) (_ 0 _). transfer (λs. interpret b s = Some false)⇩√ s V = transfer (λs. interpret b s = Some false)⇩√ s' V›
9. ‹⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; ∀V∈Uses c₁ n. s V = s' V ⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V⟧ ⟹ ∀V∈Defs (if (b) c₁ else c₂) (n ⊕ 1). transfer et s V = transfer et s' V›
10. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; ∀V∈Uses c₂ n. s V = s' V ⟹ ∀V∈Defs c₂ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V⟧ ⟹ ∀V∈Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). transfer et s V = transfer et s' V›
11. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 0 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 0 _). transfer (λs. interpret b s = Some true)⇩√ s V = transfer (λs. interpret b s = Some true)⇩√ s' V›
12. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 0 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 0 _). transfer (λs. interpret b s = Some false)⇩√ s V = transfer (λs. interpret b s = Some false)⇩√ s' V›
13. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 1 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 1 _). transfer ⇑id s V = transfer ⇑id s' V›
14. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V⟧ ⟹ ∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›
15. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V⟧ ⟹ ∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›*)
case (WCFG_SeqConnect c₁ n et c₂) (*‹c₁ ⊢ n -et→ (_Exit_)› ‹∀V∈Uses c₁ n. s V = s' V ⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V› ‹n ≠ (_Entry_)› ‹∀V∈Uses (c₁;; c₂) n. s V = s' V›*)
note IH = ‹∀V∈Uses c₁ n. s V = s' V
⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V› (*‹∀V∈Uses c₁ n. s V = s' V ⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V›*)
from ‹∀V∈Uses (c₁;;c₂) n. s V = s' V› (*‹∀V∈Uses (c₁;; c₂) n. s V = s' V›*) have "∀V∈Uses c₁ n. s V = s' V"
apply auto
(*goal: ‹∀V∈Uses c₁ n. s V = s' V›*)
apply (drule Labels_Seq1[of _ _ _ c₂] (*‹labels ?c₁ ?l ?c ⟹ labels (?c₁;; c₂) ?l (?c;; c₂)›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (c₁;; c₂) l c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); labels c₁ l c; V ∈ rhs c⟧ ⟹ s V = s' V›*)
apply (erule_tac x="V" in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⋀(V::char list) (l::nat) c::cmd. ⟦∀V::char list. (∃c::cmd. labels ((c₁::cmd);; (c₂::cmd)) l c ∧ V ∈ rhs c) ⟶ (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; (n::w_node) = (_ l _); V ∈ rhs c; labels (c₁;; c₂) l (c;; c₂)⟧ ⟹ s V = s' V›*)
by auto
from IH[OF this] (*‹∀V∈Defs c₁ n. transfer et s V = transfer et s' V›*) have "∀V∈Defs c₁ n. transfer et s V = transfer et s' V" .
with ‹c₁ ⊢ n -et→ (_Exit_)› (*‹c₁::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ (_Exit_)›*) show "?case"
(*goal: ‹∀V∈Defs (c₁;; c₂) n. transfer et s V = transfer et s' V›*)
using Labels_Base (*‹labels (?c::cmd) (0::nat) ?c›*) apply clarsimp
(*goal: ‹∀V∈Defs (c₁;; c₂) n. transfer et s V = transfer et s' V›*)
apply (erule labels.cases (*‹⟦labels ?a1.0 ?a2.0 ?a3.0; ⋀c. ⟦?a1.0 = c; ?a2.0 = 0; ?a3.0 = c⟧ ⟹ ?P; ⋀V e. ⟦?a1.0 = V:=e; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P; ⋀c₁ l c c₂. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l; ?a3.0 = c;; c₂; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c c₁. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l + #:c₁; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c₁ l c b c₂. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + 1; ?a3.0 = c; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c b c₁. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + #:c₁ + 1; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c' l c b. ⟦?a1.0 = while (b) c'; ?a2.0 = l + 2; ?a3.0 = c;; while (b) c'; labels c' l c⟧ ⟹ ?P; ⋀b c'. ⟦?a1.0 = while (b) c'; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P⟧ ⟹ ?P›*))
(*goals:
1. ‹⋀V l c ca. ⟦c₁ ⊢ (_ l _) -et→ (_Exit_); ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = ca; l = 0; c = ca⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀V l c Va e. ⟦c₁ ⊢ (_ l _) -et→ (_Exit_); ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = Va:=e; l = 1; c = Skip⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀V l c c₁' la ca c₂'. ⟦c₁ ⊢ (_ l _) -et→ (_Exit_); ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = c₁';; c₂'; l = la; c = ca;; c₂'; labels c₁' la ca⟧ ⟹ transfer et s V = transfer et s' V›
4. ‹⋀V l c c₂' la ca c₁'. ⟦c₁ ⊢ (_ l _) -et→ (_Exit_); ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = c₁';; c₂'; l = la + #:c₁'; c = ca; labels c₂' la ca⟧ ⟹ transfer et s V = transfer et s' V›
5. ‹⋀V l c c₁' la ca b c₂'. ⟦c₁ ⊢ (_ l _) -et→ (_Exit_); ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = if (b) c₁' else c₂'; l = la + 1; c = ca; labels c₁' la ca⟧ ⟹ transfer et s V = transfer et s' V›
6. ‹⋀V l c c₂' la ca b c₁'. ⟦c₁ ⊢ (_ l _) -et→ (_Exit_); ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = if (b) c₁' else c₂'; l = la + #:c₁' + 1; c = ca; labels c₂' la ca⟧ ⟹ transfer et s V = transfer et s' V›
7. ‹⋀V l c c' la ca b. ⟦c₁ ⊢ (_ l _) -et→ (_Exit_); ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = while (b) c'; l = la + 2; c = ca;; while (b) c'; labels c' la ca⟧ ⟹ transfer et s V = transfer et s' V›
8. ‹⋀V l c b c'. ⟦c₁ ⊢ (_ l _) -et→ (_Exit_); ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = while (b) c'; l = 1; c = Skip⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog::cmd ⊢ (_ ?l::nat _) -?et::(char list ⇒ val option) edge_kind→ ?n'::w_node ⟹ ?l < #:?prog›*))[1])
(*top goal: ‹⋀V l c ca. ⟦c₁ ⊢ (_ l _) -et→ (_Exit_); ∀V. (∃c. labels c₁ l c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ l _); V ∈ lhs c; c₁;; c₂ = ca; l = 0; c = ca⟧ ⟹ transfer et s V = transfer et s' V› and 7 goals remain*)
apply (erule_tac x="V" in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*top goal: ‹⋀V. ⟦c₁ ⊢ (_ 0 _) -et→ (_Exit_); ∀V. (∃c. labels c₁ 0 c ∧ V ∈ lhs c) ⟶ transfer et s V = transfer et s' V; ⋀c. labels c 0 c; n = (_ 0 _); V ∈ lhs c₁⟧ ⟹ transfer et s V = transfer et s' V› and 7 goals remain*)
apply fastforce
(*discuss goal 2*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*discuss goal 3*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*discuss goal 4*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog::cmd ⊢ (_ ?l::nat _) -?et::(char list ⇒ val option) edge_kind→ ?n'::w_node ⟹ ?l < #:?prog›*))[1])
(*discuss goal 5*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*discuss goal 6*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*discuss goal 7*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*discuss goal 8*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*proven 8 subgoals*) .
next
(*goals:
1. ‹⋀prog::cmd. ∀V::char list∈Uses prog (_Entry_). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs prog (_Entry_). transfer (λs::char list ⇒ val option. False)⇩√ s V = transfer (λs::char list ⇒ val option. False)⇩√ s' V›
2. ‹⋀prog::cmd. ∀V::char list∈Uses prog (_Entry_). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs prog (_Entry_). transfer (λs::char list ⇒ val option. True)⇩√ s V = transfer (λs::char list ⇒ val option. True)⇩√ s' V›
3. ‹∀V::char list∈Uses Skip (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs Skip (_ 0::nat _). transfer ⇑id s V = transfer ⇑id s' V›
4. ‹⋀(V::char list) e::expr. ∀V::char list∈Uses (V:=e) (_ 1::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs (V:=e) (_ 1::nat _). transfer ⇑id s V = transfer ⇑id s' V›
5. ‹⋀(c₂::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) c₁::cmd. ⟦c₂ ⊢ n -et→ n'; ∀V::char list∈Uses c₂ n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs c₂ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V::char list∈Uses (c₁;; c₂) (n ⊕ #:c₁). s V = s' V⟧ ⟹ ∀V::char list∈Defs (c₁;; c₂) (n ⊕ #:c₁). transfer et s V = transfer et s' V›
6. ‹⋀(b::expr) (c₁::cmd) c₂::cmd. ∀V::char list∈Uses (if (b) c₁ else c₂) (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs (if (b) c₁ else c₂) (_ 0::nat _). transfer (λs::char list ⇒ val option. interpret b s = Some true)⇩√ s V = transfer (λs::char list ⇒ val option. interpret b s = Some true)⇩√ s' V›
7. ‹⋀(b::expr) (c₁::cmd) c₂::cmd. ∀V::char list∈Uses (if (b) c₁ else c₂) (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs (if (b) c₁ else c₂) (_ 0::nat _). transfer (λs::char list ⇒ val option. interpret b s = Some false)⇩√ s V = transfer (λs::char list ⇒ val option. interpret b s = Some false)⇩√ s' V›
8. ‹⋀(c₁::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) (b::expr) c₂::cmd. ⟦c₁ ⊢ n -et→ n'; ∀V::char list∈Uses c₁ n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs c₁ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V::char list∈Uses (if (b) c₁ else c₂) (n ⊕ 1::nat). s V = s' V⟧ ⟹ ∀V::char list∈Defs (if (b) c₁ else c₂) (n ⊕ 1::nat). transfer et s V = transfer et s' V›
9. ‹⋀(c₂::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) (b::expr) c₁::cmd. ⟦c₂ ⊢ n -et→ n'; ∀V::char list∈Uses c₂ n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs c₂ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V::char list∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + (1::nat)). s V = s' V⟧ ⟹ ∀V::char list∈Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + (1::nat)). transfer et s V = transfer et s' V›
10. ‹⋀(b::expr) c'::cmd. ∀V::char list∈Uses (while (b) c') (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs (while (b) c') (_ 0::nat _). transfer (λs::char list ⇒ val option. interpret b s = Some true)⇩√ s V = transfer (λs::char list ⇒ val option. interpret b s = Some true)⇩√ s' V›
11. ‹⋀(b::expr) c'::cmd. ∀V::char list∈Uses (while (b) c') (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs (while (b) c') (_ 0::nat _). transfer (λs::char list ⇒ val option. interpret b s = Some false)⇩√ s V = transfer (λs::char list ⇒ val option. interpret b s = Some false)⇩√ s' V›
12. ‹⋀(b::expr) c'::cmd. ∀V::char list∈Uses (while (b) c') (_ 1::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs (while (b) c') (_ 1::nat _). transfer ⇑id s V = transfer ⇑id s' V›
13. ‹⋀(c'::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) b::expr. ⟦c' ⊢ n -et→ n'; ∀V::char list∈Uses c' n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V::char list∈Uses (while (b) c') (n ⊕ 2::nat). s V = s' V⟧ ⟹ ∀V::char list∈Defs (while (b) c') (n ⊕ 2::nat). transfer et s V = transfer et s' V›
14. ‹⋀(c'::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) b::expr. ⟦c' ⊢ n -et→ (_Exit_); ∀V::char list∈Uses c' n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V::char list∈Uses (while (b) c') (n ⊕ 2::nat). s V = s' V⟧ ⟹ ∀V::char list∈Defs (while (b) c') (n ⊕ 2::nat). transfer et s V = transfer et s' V›*)
case (WCFG_SeqSecond c₂ n et n' c₁) (*‹c₂::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node› ‹∀V∈Uses c₂ n. s V = s' V ⟹ ∀V∈Defs c₂ n. transfer et s V = transfer et s' V› ‹(n::w_node) ≠ (_Entry_)› ‹∀V::char list∈Uses ((c₁::cmd);; (c₂::cmd)) (n::w_node ⊕ #:c₁). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V›*)
note IH = ‹∀V∈Uses c₂ n. s V = s' V
⟹ ∀V∈Defs c₂ n. transfer et s V = transfer et s' V› (*‹∀V∈Uses c₂ n. s V = s' V ⟹ ∀V∈Defs c₂ n. transfer et s V = transfer et s' V›*)
from ‹∀V∈Uses (c₁;;c₂) (n ⊕ #:c₁). s V = s' V› (*‹∀V∈Uses (c₁;; c₂) (n ⊕ #:c₁). s V = s' V›*) have "∀V∈Uses c₂ n. s V = s' V"
apply auto
(*goal: ‹∀V∈Uses c₂ n. s V = s' V›*)
by (blast dest:Labels_Seq2 (*‹labels ?c₂ ?l ?c ⟹ labels (?c₁;; ?c₂) (?l + #:?c₁) ?c›*))
from IH[OF this] (*‹∀V::char list∈Defs (c₂::cmd) (n::w_node). transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V›*) have "∀V∈Defs c₂ n. transfer et s V = transfer et s' V" .
with num_inner_nodes_gr_0[of "c₁"] (*‹(0::nat) < #:c₁::cmd›*) show "?case"
(*goal: ‹∀V∈Defs (c₁;; c₂) (n ⊕ #:c₁). transfer et s V = transfer et s' V›*)
apply clarsimp
(*goal: ‹∀V∈Defs (c₁;; c₂) (n ⊕ #:c₁). transfer et s V = transfer et s' V›*)
apply (erule labels.cases (*‹⟦labels ?a1.0 ?a2.0 ?a3.0; ⋀c. ⟦?a1.0 = c; ?a2.0 = 0; ?a3.0 = c⟧ ⟹ ?P; ⋀V e. ⟦?a1.0 = V:=e; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P; ⋀c₁ l c c₂. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l; ?a3.0 = c;; c₂; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c c₁. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l + #:c₁; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c₁ l c b c₂. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + 1; ?a3.0 = c; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c b c₁. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + #:c₁ + 1; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c' l c b. ⟦?a1.0 = while (b) c'; ?a2.0 = l + 2; ?a3.0 = c;; while (b) c'; labels c' l c⟧ ⟹ ?P; ⋀b c'. ⟦?a1.0 = while (b) c'; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P⟧ ⟹ ?P›*))
(*goals:
1. ‹⋀V l c ca. ⟦0 < #:c₁; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ = (_ l _); V ∈ lhs c; c₁;; c₂ = ca; l = 0; c = ca⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀V l c Va e. ⟦0 < #:c₁; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ = (_ l _); V ∈ lhs c; c₁;; c₂ = Va:=e; l = 1; c = Skip⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀V l c c₁' la ca c₂'. ⟦0 < #:c₁; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ = (_ l _); V ∈ lhs c; c₁;; c₂ = c₁';; c₂'; l = la; c = ca;; c₂'; labels c₁' la ca⟧ ⟹ transfer et s V = transfer et s' V›
4. ‹⋀V l c c₂' la ca c₁'. ⟦0 < #:c₁; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ = (_ l _); V ∈ lhs c; c₁;; c₂ = c₁';; c₂'; l = la + #:c₁'; c = ca; labels c₂' la ca⟧ ⟹ transfer et s V = transfer et s' V›
5. ‹⋀V l c c₁' la ca b c₂'. ⟦0 < #:c₁; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ = (_ l _); V ∈ lhs c; c₁;; c₂ = if (b) c₁' else c₂'; l = la + 1; c = ca; labels c₁' la ca⟧ ⟹ transfer et s V = transfer et s' V›
6. ‹⋀V l c c₂' la ca b c₁'. ⟦0 < #:c₁; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ = (_ l _); V ∈ lhs c; c₁;; c₂ = if (b) c₁' else c₂'; l = la + #:c₁' + 1; c = ca; labels c₂' la ca⟧ ⟹ transfer et s V = transfer et s' V›
7. ‹⋀V l c c' la ca b. ⟦0 < #:c₁; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ = (_ l _); V ∈ lhs c; c₁;; c₂ = while (b) c'; l = la + 2; c = ca;; while (b) c'; labels c' la ca⟧ ⟹ transfer et s V = transfer et s' V›
8. ‹⋀V l c b c'. ⟦0 < #:c₁; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ = (_ l _); V ∈ lhs c; c₁;; c₂ = while (b) c'; l = 1; c = Skip⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*top goal: ‹⋀V l c c₁' la ca c₂'. ⟦0 < #:c₁; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ = (_ l _); V ∈ lhs c; c₁;; c₂ = c₁';; c₂'; l = la; c = ca;; c₂'; labels c₁' la ca⟧ ⟹ transfer et s V = transfer et s' V› and 5 goals remain*)
apply (cases n)
(*goals:
1. ‹⋀V la ca x1. ⟦0 < #:c₁; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ = (_ la _); V ∈ lhs ca; labels c₁ la ca; n = (_ x1 _)⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀V la ca. ⟦0 < #:c₁; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ = (_ la _); V ∈ lhs ca; labels c₁ la ca; n = (_Entry_)⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀V la ca. ⟦0 < #:c₁; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ = (_ la _); V ∈ lhs ca; labels c₁ la ca; n = (_Exit_)⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*discuss goal 2*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*discuss goal 3*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*proven 3 subgoals*)
(*discuss goal 4*)
apply ((auto)[1])
(*top goal: ‹⋀V l c c₂' la ca c₁'. ⟦0 < #:c₁; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ = (_ l _); V ∈ lhs c; c₁;; c₂ = c₁';; c₂'; l = la + #:c₁'; c = ca; labels c₂' la ca⟧ ⟹ transfer et s V = transfer et s' V› and 4 goals remain*)
apply (cases n)
(*goals:
1. ‹⋀(V::char list) (la::nat) (ca::cmd) x1::nat. ⟦(0::nat) < #:c₁::cmd; ∀V::char list. (∃l::nat. (n::w_node) = (_ l _) ∧ (∃c::cmd. labels (c₂::cmd) l c ∧ V ∈ lhs c)) ⟶ transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ #:c₁ = (_ la + #:c₁ _); V ∈ lhs ca; labels c₂ la ca; n = (_ x1 _)⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀(V::char list) (la::nat) ca::cmd. ⟦(0::nat) < #:c₁::cmd; ∀V::char list. (∃l::nat. (n::w_node) = (_ l _) ∧ (∃c::cmd. labels (c₂::cmd) l c ∧ V ∈ lhs c)) ⟶ transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ #:c₁ = (_ la + #:c₁ _); V ∈ lhs ca; labels c₂ la ca; n = (_Entry_)⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀(V::char list) (la::nat) ca::cmd. ⟦(0::nat) < #:c₁::cmd; ∀V::char list. (∃l::nat. (n::w_node) = (_ l _) ∧ (∃c::cmd. labels (c₂::cmd) l c ∧ V ∈ lhs c)) ⟶ transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ #:c₁ = (_ la + #:c₁ _); V ∈ lhs ca; labels c₂ la ca; n = (_Exit_)⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*discuss goal 2*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*discuss goal 3*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*proven 3 subgoals*)
(*discuss goal 5*)
apply ((auto)[1])
(*discuss goal 6*)
apply ((auto)[1])
(*discuss goal 7*)
apply ((auto)[1])
(*discuss goal 8*)
apply ((auto)[1])
(*proven 8 subgoals*) .
next
(*goals:
1. ‹⋀prog. ∀V∈Uses prog (_Entry_). s V = s' V ⟹ ∀V∈Defs prog (_Entry_). transfer (λs. False)⇩√ s V = transfer (λs. False)⇩√ s' V›
2. ‹⋀prog. ∀V∈Uses prog (_Entry_). s V = s' V ⟹ ∀V∈Defs prog (_Entry_). transfer (λs. True)⇩√ s V = transfer (λs. True)⇩√ s' V›
3. ‹∀V∈Uses Skip (_ 0 _). s V = s' V ⟹ ∀V∈Defs Skip (_ 0 _). transfer ⇑id s V = transfer ⇑id s' V›
4. ‹⋀V e. ∀V∈Uses (V:=e) (_ 1 _). s V = s' V ⟹ ∀V∈Defs (V:=e) (_ 1 _). transfer ⇑id s V = transfer ⇑id s' V›
5. ‹⋀b c₁ c₂. ∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V ⟹ ∀V∈Defs (if (b) c₁ else c₂) (_ 0 _). transfer (λs. interpret b s = Some true)⇩√ s V = transfer (λs. interpret b s = Some true)⇩√ s' V›
6. ‹⋀b c₁ c₂. ∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V ⟹ ∀V∈Defs (if (b) c₁ else c₂) (_ 0 _). transfer (λs. interpret b s = Some false)⇩√ s V = transfer (λs. interpret b s = Some false)⇩√ s' V›
7. ‹⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; ∀V∈Uses c₁ n. s V = s' V ⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V⟧ ⟹ ∀V∈Defs (if (b) c₁ else c₂) (n ⊕ 1). transfer et s V = transfer et s' V›
8. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; ∀V∈Uses c₂ n. s V = s' V ⟹ ∀V∈Defs c₂ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V⟧ ⟹ ∀V∈Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). transfer et s V = transfer et s' V›
9. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 0 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 0 _). transfer (λs. interpret b s = Some true)⇩√ s V = transfer (λs. interpret b s = Some true)⇩√ s' V›
10. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 0 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 0 _). transfer (λs. interpret b s = Some false)⇩√ s V = transfer (λs. interpret b s = Some false)⇩√ s' V›
11. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 1 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 1 _). transfer ⇑id s V = transfer ⇑id s' V›
12. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V⟧ ⟹ ∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›
13. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V⟧ ⟹ ∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›*)
case (WCFG_CondThen c₁ n et n' b c₂) (*‹c₁::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node› ‹∀V::char list∈Uses (c₁::cmd) (n::w_node). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs c₁ n. transfer (et::(char list ⇒ val option) edge_kind) s V = transfer et s' V› ‹n ≠ (_Entry_)› ‹∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V›*)
note IH = ‹∀V∈Uses c₁ n. s V = s' V
⟹ ∀V∈Defs c₁ n. transfer et s V = transfer et s' V› (*‹∀V::char list∈Uses (c₁::cmd) (n::w_node). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs c₁ n. transfer (et::(char list ⇒ val option) edge_kind) s V = transfer et s' V›*)
from ‹∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V› (*‹∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V›*) have "∀V∈Uses c₁ n. s V = s' V"
apply auto
(*goal: ‹∀V::char list∈Uses (c₁::cmd) (n::w_node). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V›*)
by (blast dest:Labels_CondTrue (*‹labels (?c₁::cmd) (?l::nat) (?c::cmd) ⟹ labels (if ((?b::expr)) ?c₁ else (?c₂::cmd)) (?l + (1::nat)) ?c›*))
from IH[OF this] (*‹∀V∈Defs c₁ n. transfer et s V = transfer et s' V›*) have "∀V∈Defs c₁ n. transfer et s V = transfer et s' V" .
with ‹c₁ ⊢ n -et→ n'› (*‹c₁ ⊢ n -et→ n'›*) show "?case"
(*goal: ‹∀V∈Defs (if (b) c₁ else c₂) (n ⊕ 1). transfer et s V = transfer et s' V›*)
apply clarsimp
(*goal: ‹∀V∈Defs (if (b) c₁ else c₂) (n ⊕ 1). transfer et s V = transfer et s' V›*)
apply (erule labels.cases (*‹⟦labels (?a1.0::cmd) (?a2.0::nat) (?a3.0::cmd); ⋀c::cmd. ⟦?a1.0 = c; ?a2.0 = (0::nat); ?a3.0 = c⟧ ⟹ ?P::bool; ⋀(V::char list) e::expr. ⟦?a1.0 = V:=e; ?a2.0 = (1::nat); ?a3.0 = Skip⟧ ⟹ ?P; ⋀(c₁::cmd) (l::nat) (c::cmd) c₂::cmd. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l; ?a3.0 = c;; c₂; labels c₁ l c⟧ ⟹ ?P; ⋀(c₂::cmd) (l::nat) (c::cmd) c₁::cmd. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l + #:c₁; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀(c₁::cmd) (l::nat) (c::cmd) (b::expr) c₂::cmd. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + (1::nat); ?a3.0 = c; labels c₁ l c⟧ ⟹ ?P; ⋀(c₂::cmd) (l::nat) (c::cmd) (b::expr) c₁::cmd. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + #:c₁ + (1::nat); ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀(c'::cmd) (l::nat) (c::cmd) b::expr. ⟦?a1.0 = while (b) c'; ?a2.0 = l + (2::nat); ?a3.0 = c;; while (b) c'; labels c' l c⟧ ⟹ ?P; ⋀(b::expr) c'::cmd. ⟦?a1.0 = while (b) c'; ?a2.0 = (1::nat); ?a3.0 = Skip⟧ ⟹ ?P⟧ ⟹ ?P›*))
(*goals:
1. ‹⋀(V::char list) (l::nat) (c::cmd) ca::cmd. ⟦c₁::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node; ∀V::char list. (∃l::nat. n = (_ l _) ∧ (∃c::cmd. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ 1::nat = (_ l _); V ∈ lhs c; if ((b::expr)) c₁ else (c₂::cmd) = ca; l = (0::nat); c = ca⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀(V::char list) (l::nat) (c::cmd) (Va::char list) e::expr. ⟦c₁::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node; ∀V::char list. (∃l::nat. n = (_ l _) ∧ (∃c::cmd. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ 1::nat = (_ l _); V ∈ lhs c; if ((b::expr)) c₁ else (c₂::cmd) = Va:=e; l = (1::nat); c = Skip⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀(V::char list) (l::nat) (c::cmd) (c₁'::cmd) (la::nat) (ca::cmd) c₂'::cmd. ⟦c₁::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node; ∀V::char list. (∃l::nat. n = (_ l _) ∧ (∃c::cmd. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ 1::nat = (_ l _); V ∈ lhs c; if ((b::expr)) c₁ else (c₂::cmd) = c₁';; c₂'; l = la; c = ca;; c₂'; labels c₁' la ca⟧ ⟹ transfer et s V = transfer et s' V›
4. ‹⋀(V::char list) (l::nat) (c::cmd) (c₂'::cmd) (la::nat) (ca::cmd) c₁'::cmd. ⟦c₁::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node; ∀V::char list. (∃l::nat. n = (_ l _) ∧ (∃c::cmd. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ 1::nat = (_ l _); V ∈ lhs c; if ((b::expr)) c₁ else (c₂::cmd) = c₁';; c₂'; l = la + #:c₁'; c = ca; labels c₂' la ca⟧ ⟹ transfer et s V = transfer et s' V›
5. ‹⋀(V::char list) (l::nat) (c::cmd) (c₁'::cmd) (la::nat) (ca::cmd) (ba::expr) c₂'::cmd. ⟦c₁::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node; ∀V::char list. (∃l::nat. n = (_ l _) ∧ (∃c::cmd. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ 1::nat = (_ l _); V ∈ lhs c; if ((b::expr)) c₁ else (c₂::cmd) = if (ba) c₁' else c₂'; l = la + (1::nat); c = ca; labels c₁' la ca⟧ ⟹ transfer et s V = transfer et s' V›
6. ‹⋀(V::char list) (l::nat) (c::cmd) (c₂'::cmd) (la::nat) (ca::cmd) (ba::expr) c₁'::cmd. ⟦c₁::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node; ∀V::char list. (∃l::nat. n = (_ l _) ∧ (∃c::cmd. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ 1::nat = (_ l _); V ∈ lhs c; if ((b::expr)) c₁ else (c₂::cmd) = if (ba) c₁' else c₂'; l = la + #:c₁' + (1::nat); c = ca; labels c₂' la ca⟧ ⟹ transfer et s V = transfer et s' V›
7. ‹⋀(V::char list) (l::nat) (c::cmd) (c'::cmd) (la::nat) (ca::cmd) ba::expr. ⟦c₁::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node; ∀V::char list. (∃l::nat. n = (_ l _) ∧ (∃c::cmd. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ 1::nat = (_ l _); V ∈ lhs c; if ((b::expr)) c₁ else (c₂::cmd) = while (ba) c'; l = la + (2::nat); c = ca;; while (ba) c'; labels c' la ca⟧ ⟹ transfer et s V = transfer et s' V›
8. ‹⋀(V::char list) (l::nat) (c::cmd) (ba::expr) c'::cmd. ⟦c₁::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node; ∀V::char list. (∃l::nat. n = (_ l _) ∧ (∃c::cmd. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ 1::nat = (_ l _); V ∈ lhs c; if ((b::expr)) c₁ else (c₂::cmd) = while (ba) c'; l = (1::nat); c = Skip⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*top goal: ‹⋀V l c c₁' la ca ba c₂'. ⟦c₁ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 1 = (_ l _); V ∈ lhs c; if (b) c₁ else c₂ = if (ba) c₁' else c₂'; l = la + 1; c = ca; labels c₁' la ca⟧ ⟹ transfer et s V = transfer et s' V› and 3 goals remain*)
apply (cases n)
(*goals:
1. ‹⋀V la ca x1. ⟦c₁ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 1 = (_ la + 1 _); V ∈ lhs ca; labels c₁ la ca; n = (_ x1 _)⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀V la ca. ⟦c₁ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 1 = (_ la + 1 _); V ∈ lhs ca; labels c₁ la ca; n = (_Entry_)⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀V la ca. ⟦c₁ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 1 = (_ la + 1 _); V ∈ lhs ca; labels c₁ la ca; n = (_Exit_)⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*discuss goal 2*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*discuss goal 3*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels (?c::cmd) (?l::nat) (?c'::cmd) ⟹ ?l < #:?c›*))[1])
(*proven 3 subgoals*)
(*discuss goal 6*)
apply ((auto)[1])
(*top goal: ‹⋀V l c c₂' la ca ba c₁'. ⟦c₁ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 1 = (_ l _); V ∈ lhs c; if (b) c₁ else c₂ = if (ba) c₁' else c₂'; l = la + #:c₁' + 1; c = ca; labels c₂' la ca⟧ ⟹ transfer et s V = transfer et s' V› and 2 goals remain*)
apply (cases n)
(*goals:
1. ‹⋀V la ca x1. ⟦c₁ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 1 = (_ la + #:c₁ + 1 _); V ∈ lhs ca; labels c₂ la ca; n = (_ x1 _)⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀V la ca. ⟦c₁ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 1 = (_ la + #:c₁ + 1 _); V ∈ lhs ca; labels c₂ la ca; n = (_Entry_)⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀V la ca. ⟦c₁ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₁ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 1 = (_ la + #:c₁ + 1 _); V ∈ lhs ca; labels c₂ la ca; n = (_Exit_)⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*discuss goal 2*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*discuss goal 3*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*proven 3 subgoals*)
(*discuss goal 7*)
apply ((auto)[1])
(*discuss goal 8*)
apply ((auto)[1])
(*proven 8 subgoals*) .
next
(*goals:
1. ‹⋀prog. ∀V∈Uses prog (_Entry_). s V = s' V ⟹ ∀V∈Defs prog (_Entry_). transfer (λs. False)⇩√ s V = transfer (λs. False)⇩√ s' V›
2. ‹⋀prog. ∀V∈Uses prog (_Entry_). s V = s' V ⟹ ∀V∈Defs prog (_Entry_). transfer (λs. True)⇩√ s V = transfer (λs. True)⇩√ s' V›
3. ‹∀V∈Uses Skip (_ 0 _). s V = s' V ⟹ ∀V∈Defs Skip (_ 0 _). transfer ⇑id s V = transfer ⇑id s' V›
4. ‹⋀V e. ∀V∈Uses (V:=e) (_ 1 _). s V = s' V ⟹ ∀V∈Defs (V:=e) (_ 1 _). transfer ⇑id s V = transfer ⇑id s' V›
5. ‹⋀b c₁ c₂. ∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V ⟹ ∀V∈Defs (if (b) c₁ else c₂) (_ 0 _). transfer (λs. interpret b s = Some true)⇩√ s V = transfer (λs. interpret b s = Some true)⇩√ s' V›
6. ‹⋀b c₁ c₂. ∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V ⟹ ∀V∈Defs (if (b) c₁ else c₂) (_ 0 _). transfer (λs. interpret b s = Some false)⇩√ s V = transfer (λs. interpret b s = Some false)⇩√ s' V›
7. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; ∀V∈Uses c₂ n. s V = s' V ⟹ ∀V∈Defs c₂ n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V⟧ ⟹ ∀V∈Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). transfer et s V = transfer et s' V›
8. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 0 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 0 _). transfer (λs. interpret b s = Some true)⇩√ s V = transfer (λs. interpret b s = Some true)⇩√ s' V›
9. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 0 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 0 _). transfer (λs. interpret b s = Some false)⇩√ s V = transfer (λs. interpret b s = Some false)⇩√ s' V›
10. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 1 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 1 _). transfer ⇑id s V = transfer ⇑id s' V›
11. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V⟧ ⟹ ∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›
12. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V⟧ ⟹ ∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›*)
case (WCFG_CondElse c₂ n et n' b c₁) (*‹c₂ ⊢ n -et→ n'› ‹∀V∈Uses c₂ n. s V = s' V ⟹ ∀V∈Defs c₂ n. transfer et s V = transfer et s' V› ‹n ≠ (_Entry_)› ‹∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V›*)
note IH = ‹∀V∈Uses c₂ n. s V = s' V
⟹ ∀V∈Defs c₂ n. transfer et s V = transfer et s' V› (*‹∀V∈Uses c₂ n. s V = s' V ⟹ ∀V∈Defs c₂ n. transfer et s V = transfer et s' V›*)
from ‹∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V› (*‹∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V›*) have "∀V∈Uses c₂ n. s V = s' V"
apply auto
(*goal: ‹∀V∈Uses c₂ n. s V = s' V›*)
apply (drule Labels_CondFalse[of _ _ _ b c₁] (*‹labels (?c₂::cmd) (?l::nat) (?c::cmd) ⟹ labels (if ((b::expr)) (c₁::cmd) else ?c₂) (?l + #:c₁ + (1::nat)) ?c›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (if (b) c₁ else c₂) (l + (#:c₁ + 1)) c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); labels c₂ l c; V ∈ rhs c⟧ ⟹ s V = s' V›*)
apply (erule_tac x="V" in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⋀(V::char list) (l::nat) c::cmd. ⟦∀V::char list. (∃c::cmd. labels (if ((b::expr)) (c₁::cmd) else (c₂::cmd)) (l + (#:c₁ + (1::nat))) c ∧ V ∈ rhs c) ⟶ (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; (n::w_node) = (_ l _); V ∈ rhs c; labels (if (b) c₁ else c₂) (l + #:c₁ + (1::nat)) c⟧ ⟹ s V = s' V›*)
by (auto simp:add.assoc (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)›*))
from IH[OF this] (*‹∀V∈Defs c₂ n. transfer et s V = transfer et s' V›*) have "∀V∈Defs c₂ n. transfer et s V = transfer et s' V" .
with ‹c₂ ⊢ n -et→ n'› (*‹c₂ ⊢ n -et→ n'›*) show "?case"
(*goal: ‹∀V::char list∈Defs (if ((b::expr)) (c₁::cmd) else (c₂::cmd)) (n::w_node ⊕ #:c₁ + (1::nat)). transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V›*)
apply clarsimp
(*goal: ‹∀V∈Defs (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). transfer et s V = transfer et s' V›*)
apply (erule labels.cases (*‹⟦labels (?a1.0::cmd) (?a2.0::nat) (?a3.0::cmd); ⋀c::cmd. ⟦?a1.0 = c; ?a2.0 = (0::nat); ?a3.0 = c⟧ ⟹ ?P::bool; ⋀(V::char list) e::expr. ⟦?a1.0 = V:=e; ?a2.0 = (1::nat); ?a3.0 = Skip⟧ ⟹ ?P; ⋀(c₁::cmd) (l::nat) (c::cmd) c₂::cmd. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l; ?a3.0 = c;; c₂; labels c₁ l c⟧ ⟹ ?P; ⋀(c₂::cmd) (l::nat) (c::cmd) c₁::cmd. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l + #:c₁; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀(c₁::cmd) (l::nat) (c::cmd) (b::expr) c₂::cmd. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + (1::nat); ?a3.0 = c; labels c₁ l c⟧ ⟹ ?P; ⋀(c₂::cmd) (l::nat) (c::cmd) (b::expr) c₁::cmd. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + #:c₁ + (1::nat); ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀(c'::cmd) (l::nat) (c::cmd) b::expr. ⟦?a1.0 = while (b) c'; ?a2.0 = l + (2::nat); ?a3.0 = c;; while (b) c'; labels c' l c⟧ ⟹ ?P; ⋀(b::expr) c'::cmd. ⟦?a1.0 = while (b) c'; ?a2.0 = (1::nat); ?a3.0 = Skip⟧ ⟹ ?P⟧ ⟹ ?P›*))
(*goals:
1. ‹⋀V l c ca. ⟦c₂ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ + 1 = (_ l _); V ∈ lhs c; if (b) c₁ else c₂ = ca; l = 0; c = ca⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀V l c Va e. ⟦c₂ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ + 1 = (_ l _); V ∈ lhs c; if (b) c₁ else c₂ = Va:=e; l = 1; c = Skip⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀V l c c₁' la ca c₂'. ⟦c₂ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ + 1 = (_ l _); V ∈ lhs c; if (b) c₁ else c₂ = c₁';; c₂'; l = la; c = ca;; c₂'; labels c₁' la ca⟧ ⟹ transfer et s V = transfer et s' V›
4. ‹⋀V l c c₂' la ca c₁'. ⟦c₂ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ + 1 = (_ l _); V ∈ lhs c; if (b) c₁ else c₂ = c₁';; c₂'; l = la + #:c₁'; c = ca; labels c₂' la ca⟧ ⟹ transfer et s V = transfer et s' V›
5. ‹⋀V l c c₁' la ca ba c₂'. ⟦c₂ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ + 1 = (_ l _); V ∈ lhs c; if (b) c₁ else c₂ = if (ba) c₁' else c₂'; l = la + 1; c = ca; labels c₁' la ca⟧ ⟹ transfer et s V = transfer et s' V›
6. ‹⋀V l c c₂' la ca ba c₁'. ⟦c₂ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ + 1 = (_ l _); V ∈ lhs c; if (b) c₁ else c₂ = if (ba) c₁' else c₂'; l = la + #:c₁' + 1; c = ca; labels c₂' la ca⟧ ⟹ transfer et s V = transfer et s' V›
7. ‹⋀V l c c' la ca ba. ⟦c₂ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ + 1 = (_ l _); V ∈ lhs c; if (b) c₁ else c₂ = while (ba) c'; l = la + 2; c = ca;; while (ba) c'; labels c' la ca⟧ ⟹ transfer et s V = transfer et s' V›
8. ‹⋀V l c ba c'. ⟦c₂ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ + 1 = (_ l _); V ∈ lhs c; if (b) c₁ else c₂ = while (ba) c'; l = 1; c = Skip⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*top goal: ‹⋀(V::char list) (l::nat) (c::cmd) (c₁'::cmd) (la::nat) (ca::cmd) (ba::expr) c₂'::cmd. ⟦c₂::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node; ∀V::char list. (∃l::nat. n = (_ l _) ∧ (∃c::cmd. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ #:c₁::cmd + (1::nat) = (_ l _); V ∈ lhs c; if ((b::expr)) c₁ else c₂ = if (ba) c₁' else c₂'; l = la + (1::nat); c = ca; labels c₁' la ca⟧ ⟹ transfer et s V = transfer et s' V› and 3 goals remain*)
apply (cases n)
(*goals:
1. ‹⋀V la ca x1. ⟦c₂ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ + 1 = (_ la + 1 _); V ∈ lhs ca; labels c₁ la ca; n = (_ x1 _)⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀V la ca. ⟦c₂ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ + 1 = (_ la + 1 _); V ∈ lhs ca; labels c₁ la ca; n = (_Entry_)⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀V la ca. ⟦c₂ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ + 1 = (_ la + 1 _); V ∈ lhs ca; labels c₁ la ca; n = (_Exit_)⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*discuss goal 2*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*discuss goal 3*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*proven 3 subgoals*)
(*discuss goal 6*)
apply ((auto)[1])
(*top goal: ‹⋀V l c c₂' la ca ba c₁'. ⟦c₂ ⊢ n -et→ n'; ∀V. (∃l. n = (_ l _) ∧ (∃c. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ #:c₁ + 1 = (_ l _); V ∈ lhs c; if (b) c₁ else c₂ = if (ba) c₁' else c₂'; l = la + #:c₁' + 1; c = ca; labels c₂' la ca⟧ ⟹ transfer et s V = transfer et s' V› and 2 goals remain*)
apply (cases n)
(*goals:
1. ‹⋀(V::char list) (la::nat) (ca::cmd) x1::nat. ⟦c₂::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node; ∀V::char list. (∃l::nat. n = (_ l _) ∧ (∃c::cmd. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ #:c₁::cmd + (1::nat) = (_ la + #:c₁ + (1::nat) _); V ∈ lhs ca; labels c₂ la ca; n = (_ x1 _)⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀(V::char list) (la::nat) ca::cmd. ⟦c₂::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node; ∀V::char list. (∃l::nat. n = (_ l _) ∧ (∃c::cmd. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ #:c₁::cmd + (1::nat) = (_ la + #:c₁ + (1::nat) _); V ∈ lhs ca; labels c₂ la ca; n = (_Entry_)⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀(V::char list) (la::nat) ca::cmd. ⟦c₂::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node; ∀V::char list. (∃l::nat. n = (_ l _) ∧ (∃c::cmd. labels c₂ l c ∧ V ∈ lhs c)) ⟶ transfer et (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ #:c₁::cmd + (1::nat) = (_ la + #:c₁ + (1::nat) _); V ∈ lhs ca; labels c₂ la ca; n = (_Exit_)⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*discuss goal 2*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog ⊢ (_ ?l _) -?et→ ?n' ⟹ ?l < #:?prog›*))[1])
(*discuss goal 3*)
apply ((auto dest:WCFG_sourcelabel_less_num_nodes (*‹?prog::cmd ⊢ (_ ?l::nat _) -?et::(char list ⇒ val option) edge_kind→ ?n'::w_node ⟹ ?l < #:?prog›*))[1])
(*proven 3 subgoals*)
(*discuss goal 7*)
apply ((auto)[1])
(*discuss goal 8*)
apply ((auto)[1])
(*proven 8 subgoals*) .
next
(*goals:
1. ‹⋀prog::cmd. ∀V::char list∈Uses prog (_Entry_). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs prog (_Entry_). transfer (λs::char list ⇒ val option. False)⇩√ s V = transfer (λs::char list ⇒ val option. False)⇩√ s' V›
2. ‹⋀prog::cmd. ∀V::char list∈Uses prog (_Entry_). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs prog (_Entry_). transfer (λs::char list ⇒ val option. True)⇩√ s V = transfer (λs::char list ⇒ val option. True)⇩√ s' V›
3. ‹∀V::char list∈Uses Skip (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs Skip (_ 0::nat _). transfer ⇑id s V = transfer ⇑id s' V›
4. ‹⋀(V::char list) e::expr. ∀V::char list∈Uses (V:=e) (_ 1::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs (V:=e) (_ 1::nat _). transfer ⇑id s V = transfer ⇑id s' V›
5. ‹⋀(b::expr) (c₁::cmd) c₂::cmd. ∀V::char list∈Uses (if (b) c₁ else c₂) (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs (if (b) c₁ else c₂) (_ 0::nat _). transfer (λs::char list ⇒ val option. interpret b s = Some true)⇩√ s V = transfer (λs::char list ⇒ val option. interpret b s = Some true)⇩√ s' V›
6. ‹⋀(b::expr) (c₁::cmd) c₂::cmd. ∀V::char list∈Uses (if (b) c₁ else c₂) (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs (if (b) c₁ else c₂) (_ 0::nat _). transfer (λs::char list ⇒ val option. interpret b s = Some false)⇩√ s V = transfer (λs::char list ⇒ val option. interpret b s = Some false)⇩√ s' V›
7. ‹⋀(b::expr) c'::cmd. ∀V::char list∈Uses (while (b) c') (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs (while (b) c') (_ 0::nat _). transfer (λs::char list ⇒ val option. interpret b s = Some true)⇩√ s V = transfer (λs::char list ⇒ val option. interpret b s = Some true)⇩√ s' V›
8. ‹⋀(b::expr) c'::cmd. ∀V::char list∈Uses (while (b) c') (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs (while (b) c') (_ 0::nat _). transfer (λs::char list ⇒ val option. interpret b s = Some false)⇩√ s V = transfer (λs::char list ⇒ val option. interpret b s = Some false)⇩√ s' V›
9. ‹⋀(b::expr) c'::cmd. ∀V::char list∈Uses (while (b) c') (_ 1::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs (while (b) c') (_ 1::nat _). transfer ⇑id s V = transfer ⇑id s' V›
10. ‹⋀(c'::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) b::expr. ⟦c' ⊢ n -et→ n'; ∀V::char list∈Uses c' n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V::char list∈Uses (while (b) c') (n ⊕ 2::nat). s V = s' V⟧ ⟹ ∀V::char list∈Defs (while (b) c') (n ⊕ 2::nat). transfer et s V = transfer et s' V›
11. ‹⋀(c'::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) b::expr. ⟦c' ⊢ n -et→ (_Exit_); ∀V::char list∈Uses c' n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V::char list∈Uses (while (b) c') (n ⊕ 2::nat). s V = s' V⟧ ⟹ ∀V::char list∈Defs (while (b) c') (n ⊕ 2::nat). transfer et s V = transfer et s' V›*)
case (WCFG_WhileBody c' n et n' b) (*‹c' ⊢ n -et→ n'› ‹∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V› ‹n ≠ (_Entry_)› ‹n' ≠ (_Exit_)› ‹∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V›*)
note IH = ‹∀V∈Uses c' n. s V = s' V
⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V› (*‹∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V›*)
from ‹∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V› (*‹∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V›*) have "∀V∈Uses c' n. s V = s' V"
apply auto
(*goal: ‹∀V∈Uses c' n. s V = s' V›*)
apply (drule Labels_WhileBody[of _ _ _ b] (*‹labels ?c' ?l ?c ⟹ labels (while (b) ?c') (?l + 2) (?c;; while (b) ?c')›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (while (b) c') (Suc (Suc l)) c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); labels c' l c; V ∈ rhs c⟧ ⟹ s V = s' V›*)
apply (erule_tac x="V" in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (while (b) c') (Suc (Suc l)) c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); V ∈ rhs c; labels (while (b) c') (l + 2) (c;; while (b) c')⟧ ⟹ s V = s' V›*)
by auto
from IH[OF this] (*‹∀V::char list∈Defs (c'::cmd) (n::w_node). transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V›*) have "∀V∈Defs c' n. transfer et s V = transfer et s' V" .
thus "?case"
(*goal: ‹∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›*)
apply clarsimp
(*goal: ‹∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›*)
apply (erule labels.cases (*‹⟦labels ?a1.0 ?a2.0 ?a3.0; ⋀c. ⟦?a1.0 = c; ?a2.0 = 0; ?a3.0 = c⟧ ⟹ ?P; ⋀V e. ⟦?a1.0 = V:=e; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P; ⋀c₁ l c c₂. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l; ?a3.0 = c;; c₂; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c c₁. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l + #:c₁; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c₁ l c b c₂. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + 1; ?a3.0 = c; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c b c₁. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + #:c₁ + 1; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c' l c b. ⟦?a1.0 = while (b) c'; ?a2.0 = l + 2; ?a3.0 = c;; while (b) c'; labels c' l c⟧ ⟹ ?P; ⋀b c'. ⟦?a1.0 = while (b) c'; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P⟧ ⟹ ?P›*))
(*goals:
1. ‹⋀V l c ca. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = ca; l = 0; c = ca⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀V l c Va e. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = Va:=e; l = 1; c = Skip⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀V l c c₁ la ca c₂. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = c₁;; c₂; l = la; c = ca;; c₂; labels c₁ la ca⟧ ⟹ transfer et s V = transfer et s' V›
4. ‹⋀V l c c₂ la ca c₁. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = c₁;; c₂; l = la + #:c₁; c = ca; labels c₂ la ca⟧ ⟹ transfer et s V = transfer et s' V›
5. ‹⋀V l c c₁ la ca ba c₂. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = if (ba) c₁ else c₂; l = la + 1; c = ca; labels c₁ la ca⟧ ⟹ transfer et s V = transfer et s' V›
6. ‹⋀V l c c₂ la ca ba c₁. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = if (ba) c₁ else c₂; l = la + #:c₁ + 1; c = ca; labels c₂ la ca⟧ ⟹ transfer et s V = transfer et s' V›
7. ‹⋀V l c c'a la ca ba. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = while (ba) c'a; l = la + 2; c = ca;; while (ba) c'a; labels c'a la ca⟧ ⟹ transfer et s V = transfer et s' V›
8. ‹⋀V l c ba c'a. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = while (ba) c'a; l = 1; c = Skip⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*discuss goal 6*)
apply ((auto)[1])
(*discuss goal 7*)
apply ((auto)[1])
(*top goal: ‹⋀V l c c'a la ca ba. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = while (ba) c'a; l = la + 2; c = ca;; while (ba) c'a; labels c'a la ca⟧ ⟹ transfer et s V = transfer et s' V› and 1 goal remains*)
apply (cases n)
(*goals:
1. ‹⋀(V::char list) (la::nat) (ca::cmd) x1::nat. ⟦∀V::char list. (∃l::nat. (n::w_node) = (_ l _) ∧ (∃c::cmd. labels (c'::cmd) l c ∧ V ∈ lhs c)) ⟶ transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ 2::nat = (_ Suc (Suc la) _); V ∈ lhs ca; labels c' la ca; n = (_ x1 _)⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀(V::char list) (la::nat) ca::cmd. ⟦∀V::char list. (∃l::nat. (n::w_node) = (_ l _) ∧ (∃c::cmd. labels (c'::cmd) l c ∧ V ∈ lhs c)) ⟶ transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ 2::nat = (_ Suc (Suc la) _); V ∈ lhs ca; labels c' la ca; n = (_Entry_)⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀(V::char list) (la::nat) ca::cmd. ⟦∀V::char list. (∃l::nat. (n::w_node) = (_ l _) ∧ (∃c::cmd. labels (c'::cmd) l c ∧ V ∈ lhs c)) ⟶ transfer (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option) V = transfer et (s'::char list ⇒ val option) V; n ⊕ 2::nat = (_ Suc (Suc la) _); V ∈ lhs ca; labels c' la ca; n = (_Exit_)⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*discuss goal 2*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*discuss goal 3*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*proven 3 subgoals*)
(*discuss goal 8*)
apply ((auto)[1])
(*proven 8 subgoals*) .
next
(*goals:
1. ‹⋀prog. ∀V∈Uses prog (_Entry_). s V = s' V ⟹ ∀V∈Defs prog (_Entry_). transfer (λs. False)⇩√ s V = transfer (λs. False)⇩√ s' V›
2. ‹⋀prog. ∀V∈Uses prog (_Entry_). s V = s' V ⟹ ∀V∈Defs prog (_Entry_). transfer (λs. True)⇩√ s V = transfer (λs. True)⇩√ s' V›
3. ‹∀V∈Uses Skip (_ 0 _). s V = s' V ⟹ ∀V∈Defs Skip (_ 0 _). transfer ⇑id s V = transfer ⇑id s' V›
4. ‹⋀V e. ∀V∈Uses (V:=e) (_ 1 _). s V = s' V ⟹ ∀V∈Defs (V:=e) (_ 1 _). transfer ⇑id s V = transfer ⇑id s' V›
5. ‹⋀b c₁ c₂. ∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V ⟹ ∀V∈Defs (if (b) c₁ else c₂) (_ 0 _). transfer (λs. interpret b s = Some true)⇩√ s V = transfer (λs. interpret b s = Some true)⇩√ s' V›
6. ‹⋀b c₁ c₂. ∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V ⟹ ∀V∈Defs (if (b) c₁ else c₂) (_ 0 _). transfer (λs. interpret b s = Some false)⇩√ s V = transfer (λs. interpret b s = Some false)⇩√ s' V›
7. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 0 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 0 _). transfer (λs. interpret b s = Some true)⇩√ s V = transfer (λs. interpret b s = Some true)⇩√ s' V›
8. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 0 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 0 _). transfer (λs. interpret b s = Some false)⇩√ s V = transfer (λs. interpret b s = Some false)⇩√ s' V›
9. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 1 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 1 _). transfer ⇑id s V = transfer ⇑id s' V›
10. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V; n ≠ (_Entry_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V⟧ ⟹ ∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›*)
case (WCFG_WhileBodyExit c' n et b) (*‹c' ⊢ n -et→ (_Exit_)› ‹∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V› ‹n ≠ (_Entry_)› ‹∀V::char list∈Uses (while ((b::expr)) (c'::cmd)) (n::w_node ⊕ 2::nat). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V›*)
note IH = ‹∀V∈Uses c' n. s V = s' V
⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V› (*‹∀V∈Uses c' n. s V = s' V ⟹ ∀V∈Defs c' n. transfer et s V = transfer et s' V›*)
from ‹∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V› (*‹∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V›*) have "∀V∈Uses c' n. s V = s' V"
apply auto
(*goal: ‹∀V∈Uses c' n. s V = s' V›*)
apply (drule Labels_WhileBody[of _ _ _ b] (*‹labels ?c' ?l ?c ⟹ labels (while (b) ?c') (?l + 2) (?c;; while (b) ?c')›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (while (b) c') (Suc (Suc l)) c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); labels c' l c; V ∈ rhs c⟧ ⟹ s V = s' V›*)
apply (erule_tac x="V" in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (while (b) c') (Suc (Suc l)) c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); V ∈ rhs c; labels (while (b) c') (l + 2) (c;; while (b) c')⟧ ⟹ s V = s' V›*)
by auto
from IH[OF this] (*‹∀V∈Defs c' n. transfer et s V = transfer et s' V›*) have "∀V∈Defs c' n. transfer et s V = transfer et s' V" .
thus "?case"
(*goal: ‹∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›*)
apply clarsimp
(*goal: ‹∀V∈Defs (while (b) c') (n ⊕ 2). transfer et s V = transfer et s' V›*)
apply (erule labels.cases (*‹⟦labels ?a1.0 ?a2.0 ?a3.0; ⋀c. ⟦?a1.0 = c; ?a2.0 = 0; ?a3.0 = c⟧ ⟹ ?P; ⋀V e. ⟦?a1.0 = V:=e; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P; ⋀c₁ l c c₂. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l; ?a3.0 = c;; c₂; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c c₁. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l + #:c₁; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c₁ l c b c₂. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + 1; ?a3.0 = c; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c b c₁. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + #:c₁ + 1; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c' l c b. ⟦?a1.0 = while (b) c'; ?a2.0 = l + 2; ?a3.0 = c;; while (b) c'; labels c' l c⟧ ⟹ ?P; ⋀b c'. ⟦?a1.0 = while (b) c'; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P⟧ ⟹ ?P›*))
(*goals:
1. ‹⋀V l c ca. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = ca; l = 0; c = ca⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀V l c Va e. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = Va:=e; l = 1; c = Skip⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀V l c c₁ la ca c₂. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = c₁;; c₂; l = la; c = ca;; c₂; labels c₁ la ca⟧ ⟹ transfer et s V = transfer et s' V›
4. ‹⋀V l c c₂ la ca c₁. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = c₁;; c₂; l = la + #:c₁; c = ca; labels c₂ la ca⟧ ⟹ transfer et s V = transfer et s' V›
5. ‹⋀V l c c₁ la ca ba c₂. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = if (ba) c₁ else c₂; l = la + 1; c = ca; labels c₁ la ca⟧ ⟹ transfer et s V = transfer et s' V›
6. ‹⋀V l c c₂ la ca ba c₁. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = if (ba) c₁ else c₂; l = la + #:c₁ + 1; c = ca; labels c₂ la ca⟧ ⟹ transfer et s V = transfer et s' V›
7. ‹⋀V l c c'a la ca ba. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = while (ba) c'a; l = la + 2; c = ca;; while (ba) c'a; labels c'a la ca⟧ ⟹ transfer et s V = transfer et s' V›
8. ‹⋀V l c ba c'a. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = while (ba) c'a; l = 1; c = Skip⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*discuss goal 6*)
apply ((auto)[1])
(*discuss goal 7*)
apply ((auto)[1])
(*top goal: ‹⋀V l c c'a la ca ba. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ l _); V ∈ lhs c; while (b) c' = while (ba) c'a; l = la + 2; c = ca;; while (ba) c'a; labels c'a la ca⟧ ⟹ transfer et s V = transfer et s' V› and 1 goal remains*)
apply (cases n)
(*goals:
1. ‹⋀V la ca x1. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ Suc (Suc la) _); V ∈ lhs ca; labels c' la ca; n = (_ x1 _)⟧ ⟹ transfer et s V = transfer et s' V›
2. ‹⋀V la ca. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ Suc (Suc la) _); V ∈ lhs ca; labels c' la ca; n = (_Entry_)⟧ ⟹ transfer et s V = transfer et s' V›
3. ‹⋀V la ca. ⟦∀V. (∃l. n = (_ l _) ∧ (∃c. labels c' l c ∧ V ∈ lhs c)) ⟶ transfer et s V = transfer et s' V; n ⊕ 2 = (_ Suc (Suc la) _); V ∈ lhs ca; labels c' la ca; n = (_Exit_)⟧ ⟹ transfer et s V = transfer et s' V›
discuss goal 1*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*discuss goal 2*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels ?c ?l ?c' ⟹ ?l < #:?c›*))[1])
(*discuss goal 3*)
apply ((auto dest:label_less_num_inner_nodes (*‹labels (?c::cmd) (?l::nat) (?c'::cmd) ⟹ ?l < #:?c›*))[1])
(*proven 3 subgoals*)
(*discuss goal 8*)
apply ((auto)[1])
(*proven 8 subgoals*) .
qed ((fastforce elim:labels.cases (*‹⟦labels ?a1.0 ?a2.0 ?a3.0; ⋀c. ⟦?a1.0 = c; ?a2.0 = 0; ?a3.0 = c⟧ ⟹ ?P; ⋀V e. ⟦?a1.0 = V:=e; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P; ⋀c₁ l c c₂. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l; ?a3.0 = c;; c₂; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c c₁. ⟦?a1.0 = c₁;; c₂; ?a2.0 = l + #:c₁; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c₁ l c b c₂. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + 1; ?a3.0 = c; labels c₁ l c⟧ ⟹ ?P; ⋀c₂ l c b c₁. ⟦?a1.0 = if (b) c₁ else c₂; ?a2.0 = l + #:c₁ + 1; ?a3.0 = c; labels c₂ l c⟧ ⟹ ?P; ⋀c' l c b. ⟦?a1.0 = while (b) c'; ?a2.0 = l + 2; ?a3.0 = c;; while (b) c'; labels c' l c⟧ ⟹ ?P; ⋀b c'. ⟦?a1.0 = while (b) c'; ?a2.0 = 1; ?a3.0 = Skip⟧ ⟹ ?P⟧ ⟹ ?P›*))+)
(*solves the remaining goals:
1. ‹⋀prog. ∀V∈Uses prog (_Entry_). s V = s' V ⟹ ∀V∈Defs prog (_Entry_). transfer (λs. False)⇩√ s V = transfer (λs. False)⇩√ s' V›
2. ‹⋀prog. ∀V∈Uses prog (_Entry_). s V = s' V ⟹ ∀V∈Defs prog (_Entry_). transfer (λs. True)⇩√ s V = transfer (λs. True)⇩√ s' V›
3. ‹∀V∈Uses Skip (_ 0 _). s V = s' V ⟹ ∀V∈Defs Skip (_ 0 _). transfer ⇑id s V = transfer ⇑id s' V›
4. ‹⋀V e. ∀V∈Uses (V:=e) (_ 1 _). s V = s' V ⟹ ∀V∈Defs (V:=e) (_ 1 _). transfer ⇑id s V = transfer ⇑id s' V›
5. ‹⋀b c₁ c₂. ∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V ⟹ ∀V∈Defs (if (b) c₁ else c₂) (_ 0 _). transfer (λs. interpret b s = Some true)⇩√ s V = transfer (λs. interpret b s = Some true)⇩√ s' V›
6. ‹⋀b c₁ c₂. ∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V ⟹ ∀V∈Defs (if (b) c₁ else c₂) (_ 0 _). transfer (λs. interpret b s = Some false)⇩√ s V = transfer (λs. interpret b s = Some false)⇩√ s' V›
7. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 0 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 0 _). transfer (λs. interpret b s = Some true)⇩√ s V = transfer (λs. interpret b s = Some true)⇩√ s' V›
8. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 0 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 0 _). transfer (λs. interpret b s = Some false)⇩√ s V = transfer (λs. interpret b s = Some false)⇩√ s' V›
9. ‹⋀b c'. ∀V∈Uses (while (b) c') (_ 1 _). s V = s' V ⟹ ∀V∈Defs (while (b) c') (_ 1 _). transfer ⇑id s V = transfer ⇑id s' V›*)
lemma WCFG_edge_Uses_pred_eq:
"⟦prog ⊢ n -et→ n'; ∀V ∈ Uses prog n. s V = s' V; pred et s⟧
⟹ pred et s'"
proof (induct rule:WCFG_induct (*‹⟦?x1a ⊢ ?x2a -?x3a→ ?x4a; ⋀prog. ?P prog (_Entry_) (λs. False)⇩√ (_Exit_); ⋀prog. ?P prog (_Entry_) (λs. True)⇩√ (_ 0 _); ?P Skip (_ 0 _) ⇑id (_Exit_); ⋀V e. ?P (V:=e) (_ 0 _) ⇑λs. s(V := interpret e s) (_ 1 _); ⋀V e. ?P (V:=e) (_ 1 _) ⇑id (_Exit_); ⋀c₁ n et n' c₂. ⟦c₁ ⊢ n -et→ n'; ?P c₁ n et n'; n' ≠ (_Exit_)⟧ ⟹ ?P (c₁;; c₂) n et n'; ⋀c₁ n et c₂. ⟦c₁ ⊢ n -et→ (_Exit_); ?P c₁ n et (_Exit_); n ≠ (_Entry_)⟧ ⟹ ?P (c₁;; c₂) n et ((_ 0 _) ⊕ #:c₁); ⋀c₂ n et n' c₁. ⟦c₂ ⊢ n -et→ n'; ?P c₂ n et n'; n ≠ (_Entry_)⟧ ⟹ ?P (c₁;; c₂) (n ⊕ #:c₁) et (n' ⊕ #:c₁); ⋀b c₁ c₂. ?P (if (b) c₁ else c₂) (_ 0 _) (λs. interpret b s = Some true)⇩√ ((_ 0 _) ⊕ 1); ⋀b c₁ c₂. ?P (if (b) c₁ else c₂) (_ 0 _) (λs. interpret b s = Some false)⇩√ ((_ 0 _) ⊕ #:c₁ + 1); ⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; ?P c₁ n et n'; n ≠ (_Entry_)⟧ ⟹ ?P (if (b) c₁ else c₂) (n ⊕ 1) et (n' ⊕ 1); ⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; ?P c₂ n et n'; n ≠ (_Entry_)⟧ ⟹ ?P (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1) et (n' ⊕ #:c₁ + 1); ⋀b c'. ?P (while (b) c') (_ 0 _) (λs. interpret b s = Some true)⇩√ ((_ 0 _) ⊕ 2); ⋀b c'. ?P (while (b) c') (_ 0 _) (λs. interpret b s = Some false)⇩√ (_ 1 _); ⋀b c'. ?P (while (b) c') (_ 1 _) ⇑id (_Exit_); ⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ?P c' n et n'; n ≠ (_Entry_); n' ≠ (_Exit_)⟧ ⟹ ?P (while (b) c') (n ⊕ 2) et (n' ⊕ 2); ⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ?P c' n et (_Exit_); n ≠ (_Entry_)⟧ ⟹ ?P (while (b) c') (n ⊕ 2) et (_ 0 _)⟧ ⟹ ?P ?x1a ?x2a ?x3a ?x4a›*))
(*goals:
1. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. False)⇩√ s⟧ ⟹ pred (λs. False)⇩√ s'›
2. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. True)⇩√ s⟧ ⟹ pred (λs. True)⇩√ s'›
3. ‹⟦∀V∈Uses Skip (_ 0 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
4. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 0 _). s V = s' V; pred ⇑λs. s(V := interpret e s) s⟧ ⟹ pred ⇑λs. s(V := interpret e s) s'›
5. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
6. ‹⋀c₁ n et n' c₂. ⟦c₁ ⊢ n -et→ n'; ⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n' ≠ (_Exit_); ∀V∈Uses (c₁;; c₂) n. s V = s' V; pred et s⟧ ⟹ pred et s'›
7. ‹⋀c₁ n et c₂. ⟦c₁ ⊢ n -et→ (_Exit_); ⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (c₁;; c₂) n. s V = s' V; pred et s⟧ ⟹ pred et s'›
8. ‹⋀c₂ n et n' c₁. ⟦c₂ ⊢ n -et→ n'; ⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (c₁;; c₂) (n ⊕ #:c₁). s V = s' V; pred et s⟧ ⟹ pred et s'›
9. ‹⋀b c₁ c₂. ⟦∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V; pred (λs. interpret b s = Some true)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some true)⇩√ s'›
10. ‹⋀b c₁ c₂. ⟦∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V; pred (λs. interpret b s = Some false)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some false)⇩√ s'›
11. ‹⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; ⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V; pred et s⟧ ⟹ pred et s'›
12. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; ⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V; pred et s⟧ ⟹ pred et s'›
13. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 0 _). s V = s' V; pred (λs. interpret b s = Some true)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some true)⇩√ s'›
14. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 0 _). s V = s' V; pred (λs. interpret b s = Some false)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some false)⇩√ s'›
15. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
16. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›
17. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›*)
case (WCFG_SeqFirst c₁ n et n' c₂) (*‹c₁::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node› ‹⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'› ‹n' ≠ (_Exit_)› ‹∀V::char list∈Uses ((c₁::cmd);; (c₂::cmd)) (n::w_node). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V› ‹pred (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option)›*)
note IH = ‹⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'› (*‹⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'›*)
from ‹∀V∈Uses (c₁;; c₂) n. s V = s' V› (*‹∀V::char list∈Uses ((c₁::cmd);; (c₂::cmd)) (n::w_node). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V›*) have "∀V∈Uses c₁ n. s V = s' V"
apply auto
(*goal: ‹∀V∈Uses c₁ n. s V = s' V›*)
apply (drule Labels_Seq1[of _ _ _ c₂] (*‹labels ?c₁ ?l ?c ⟹ labels (?c₁;; c₂) ?l (?c;; c₂)›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (c₁;; c₂) l c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); labels c₁ l c; V ∈ rhs c⟧ ⟹ s V = s' V›*)
apply (erule_tac x="V" in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (c₁;; c₂) l c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); V ∈ rhs c; labels (c₁;; c₂) l (c;; c₂)⟧ ⟹ s V = s' V›*)
by auto
from IH[OF this ‹pred et s›] (*‹pred et s'›*) show "?case"
(*goal: ‹pred et s'›*) .
next
(*goals:
1. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. False)⇩√ s⟧ ⟹ pred (λs. False)⇩√ s'›
2. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. True)⇩√ s⟧ ⟹ pred (λs. True)⇩√ s'›
3. ‹⟦∀V∈Uses Skip (_ 0 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
4. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 0 _). s V = s' V; pred ⇑λs. s(V := interpret e s) s⟧ ⟹ pred ⇑λs. s(V := interpret e s) s'›
5. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
6. ‹⋀c₁ n et c₂. ⟦c₁ ⊢ n -et→ (_Exit_); ⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (c₁;; c₂) n. s V = s' V; pred et s⟧ ⟹ pred et s'›
7. ‹⋀c₂ n et n' c₁. ⟦c₂ ⊢ n -et→ n'; ⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (c₁;; c₂) (n ⊕ #:c₁). s V = s' V; pred et s⟧ ⟹ pred et s'›
8. ‹⋀b c₁ c₂. ⟦∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V; pred (λs. interpret b s = Some true)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some true)⇩√ s'›
9. ‹⋀b c₁ c₂. ⟦∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V; pred (λs. interpret b s = Some false)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some false)⇩√ s'›
10. ‹⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; ⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V; pred et s⟧ ⟹ pred et s'›
11. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; ⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V; pred et s⟧ ⟹ pred et s'›
12. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 0 _). s V = s' V; pred (λs. interpret b s = Some true)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some true)⇩√ s'›
13. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 0 _). s V = s' V; pred (λs. interpret b s = Some false)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some false)⇩√ s'›
14. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
15. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›
16. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›*)
case (WCFG_SeqConnect c₁ n et c₂) (*‹c₁ ⊢ n -et→ (_Exit_)› ‹⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'› ‹(n::w_node) ≠ (_Entry_)› ‹∀V::char list∈Uses ((c₁::cmd);; (c₂::cmd)) (n::w_node). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V› ‹pred et s›*)
note IH = ‹⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'› (*‹⟦∀V::char list∈Uses (c₁::cmd) (n::w_node). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred (et::(char list ⇒ val option) edge_kind) s⟧ ⟹ pred et s'›*)
from ‹∀V∈Uses (c₁;; c₂) n. s V = s' V› (*‹∀V∈Uses (c₁;; c₂) n. s V = s' V›*) have "∀V∈Uses c₁ n. s V = s' V"
apply auto
(*goal: ‹∀V∈Uses c₁ n. s V = s' V›*)
apply (drule Labels_Seq1[of _ _ _ c₂] (*‹labels (?c₁::cmd) (?l::nat) (?c::cmd) ⟹ labels (?c₁;; (c₂::cmd)) ?l (?c;; c₂)›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (c₁;; c₂) l c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); labels c₁ l c; V ∈ rhs c⟧ ⟹ s V = s' V›*)
apply (erule_tac x="V" in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⋀(V::char list) (l::nat) c::cmd. ⟦∀V::char list. (∃c::cmd. labels ((c₁::cmd);; (c₂::cmd)) l c ∧ V ∈ rhs c) ⟶ (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; (n::w_node) = (_ l _); V ∈ rhs c; labels (c₁;; c₂) l (c;; c₂)⟧ ⟹ s V = s' V›*)
by auto
from IH[OF this ‹pred et s›] (*‹pred et s'›*) show "?case"
(*goal: ‹pred et s'›*) .
next
(*goals:
1. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. False)⇩√ s⟧ ⟹ pred (λs. False)⇩√ s'›
2. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. True)⇩√ s⟧ ⟹ pred (λs. True)⇩√ s'›
3. ‹⟦∀V∈Uses Skip (_ 0 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
4. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 0 _). s V = s' V; pred ⇑λs. s(V := interpret e s) s⟧ ⟹ pred ⇑λs. s(V := interpret e s) s'›
5. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
6. ‹⋀c₂ n et n' c₁. ⟦c₂ ⊢ n -et→ n'; ⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (c₁;; c₂) (n ⊕ #:c₁). s V = s' V; pred et s⟧ ⟹ pred et s'›
7. ‹⋀b c₁ c₂. ⟦∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V; pred (λs. interpret b s = Some true)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some true)⇩√ s'›
8. ‹⋀b c₁ c₂. ⟦∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V; pred (λs. interpret b s = Some false)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some false)⇩√ s'›
9. ‹⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; ⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V; pred et s⟧ ⟹ pred et s'›
10. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; ⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V; pred et s⟧ ⟹ pred et s'›
11. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 0 _). s V = s' V; pred (λs. interpret b s = Some true)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some true)⇩√ s'›
12. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 0 _). s V = s' V; pred (λs. interpret b s = Some false)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some false)⇩√ s'›
13. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
14. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›
15. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›*)
case (WCFG_SeqSecond c₂ n et n' c₁) (*‹c₂::cmd ⊢ n::w_node -et::(char list ⇒ val option) edge_kind→ n'::w_node› ‹⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'› ‹(n::w_node) ≠ (_Entry_)› ‹∀V∈Uses (c₁;; c₂) (n ⊕ #:c₁). s V = s' V› ‹pred et s›*)
note IH = ‹⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'› (*‹⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'›*)
from ‹∀V∈Uses (c₁;; c₂) (n ⊕ #:c₁). s V = s' V› (*‹∀V∈Uses (c₁;; c₂) (n ⊕ #:c₁). s V = s' V›*) have "∀V∈Uses c₂ n. s V = s' V"
apply auto
(*goal: ‹∀V::char list∈Uses (c₂::cmd) (n::w_node). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V›*)
by (blast dest:Labels_Seq2 (*‹labels ?c₂ ?l ?c ⟹ labels (?c₁;; ?c₂) (?l + #:?c₁) ?c›*))
from IH[OF this ‹pred et s›] (*‹pred (et::(char list ⇒ val option) edge_kind) (s'::char list ⇒ val option)›*) show "?case"
(*goal: ‹pred et s'›*) .
next
(*goals:
1. ‹⋀prog::cmd. ⟦∀V::char list∈Uses prog (_Entry_). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred (λs::char list ⇒ val option. False)⇩√ s⟧ ⟹ pred (λs::char list ⇒ val option. False)⇩√ s'›
2. ‹⋀prog::cmd. ⟦∀V::char list∈Uses prog (_Entry_). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred (λs::char list ⇒ val option. True)⇩√ s⟧ ⟹ pred (λs::char list ⇒ val option. True)⇩√ s'›
3. ‹⟦∀V::char list∈Uses Skip (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
4. ‹⋀(V::char list) e::expr. ⟦∀V::char list∈Uses (V:=e) (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred ⇑λs::char list ⇒ val option. s(V := interpret e s) s⟧ ⟹ pred ⇑λs::char list ⇒ val option. s(V := interpret e s) s'›
5. ‹⋀(V::char list) e::expr. ⟦∀V::char list∈Uses (V:=e) (_ 1::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
6. ‹⋀(b::expr) (c₁::cmd) c₂::cmd. ⟦∀V::char list∈Uses (if (b) c₁ else c₂) (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred (λs::char list ⇒ val option. interpret b s = Some true)⇩√ s⟧ ⟹ pred (λs::char list ⇒ val option. interpret b s = Some true)⇩√ s'›
7. ‹⋀(b::expr) (c₁::cmd) c₂::cmd. ⟦∀V::char list∈Uses (if (b) c₁ else c₂) (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred (λs::char list ⇒ val option. interpret b s = Some false)⇩√ s⟧ ⟹ pred (λs::char list ⇒ val option. interpret b s = Some false)⇩√ s'›
8. ‹⋀(c₁::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) (b::expr) c₂::cmd. ⟦c₁ ⊢ n -et→ n'; ⟦∀V::char list∈Uses c₁ n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V::char list∈Uses (if (b) c₁ else c₂) (n ⊕ 1::nat). s V = s' V; pred et s⟧ ⟹ pred et s'›
9. ‹⋀(c₂::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) (b::expr) c₁::cmd. ⟦c₂ ⊢ n -et→ n'; ⟦∀V::char list∈Uses c₂ n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V::char list∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + (1::nat)). s V = s' V; pred et s⟧ ⟹ pred et s'›
10. ‹⋀(b::expr) c'::cmd. ⟦∀V::char list∈Uses (while (b) c') (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred (λs::char list ⇒ val option. interpret b s = Some true)⇩√ s⟧ ⟹ pred (λs::char list ⇒ val option. interpret b s = Some true)⇩√ s'›
11. ‹⋀(b::expr) c'::cmd. ⟦∀V::char list∈Uses (while (b) c') (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred (λs::char list ⇒ val option. interpret b s = Some false)⇩√ s⟧ ⟹ pred (λs::char list ⇒ val option. interpret b s = Some false)⇩√ s'›
12. ‹⋀(b::expr) c'::cmd. ⟦∀V::char list∈Uses (while (b) c') (_ 1::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
13. ‹⋀(c'::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) b::expr. ⟦c' ⊢ n -et→ n'; ⟦∀V::char list∈Uses c' n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V::char list∈Uses (while (b) c') (n ⊕ 2::nat). s V = s' V; pred et s⟧ ⟹ pred et s'›
14. ‹⋀(c'::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) b::expr. ⟦c' ⊢ n -et→ (_Exit_); ⟦∀V::char list∈Uses c' n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V::char list∈Uses (while (b) c') (n ⊕ 2::nat). s V = s' V; pred et s⟧ ⟹ pred et s'›*)
case (WCFG_CondTrue b c₁ c₂) (*‹∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V› ‹pred (λs. interpret b s = Some true)⇩√ s›*)
from ‹∀V∈Uses (if (b) c₁ else c₂) (_0_). s V = s' V› (*‹∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V›*) have all: "∀V. labels (if (b) c₁ else c₂) 0 (if (b) c₁ else c₂) ∧
V ∈ rhs (if (b) c₁ else c₂) ⟶ (s V = s' V)"
by fastforce
obtain v' where [simp]: "v' = true"
(*goal: ‹(⋀v'. v' = true ⟹ thesis) ⟹ thesis›*)
by simp
with ‹pred (λs. interpret b s = Some true)⇩√ s› (*‹pred (λs. interpret b s = Some true)⇩√ s›*) have "interpret b s = Some v'"
by simp
have "labels (if (b) c₁ else c₂) 0 (if (b) c₁ else c₂)"
by (rule Labels_Base (*‹labels ?c 0 ?c›*))
with all (*‹∀V. labels (if (b) c₁ else c₂) 0 (if (b) c₁ else c₂) ∧ V ∈ rhs (if (b) c₁ else c₂) ⟶ s V = s' V›*) have "∀V ∈ rhs_aux b. s V = s' V"
by simp
with ‹interpret b s = Some v'› (*‹interpret b s = Some v'›*) have "interpret b s' = Some v'"
by (rule rhs_interpret_eq (*‹⟦interpret (?b::expr) (?s::char list ⇒ val option) = Some (?v'::val); ∀V::char list∈rhs_aux ?b. ?s V = (?s'::char list ⇒ val option) V⟧ ⟹ interpret ?b ?s' = Some ?v'›*))
thus "?case"
(*goal: ‹pred (λs. interpret b s = Some true)⇩√ s'›*)
by simp
next
(*goals:
1. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. False)⇩√ s⟧ ⟹ pred (λs. False)⇩√ s'›
2. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. True)⇩√ s⟧ ⟹ pred (λs. True)⇩√ s'›
3. ‹⟦∀V∈Uses Skip (_ 0 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
4. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 0 _). s V = s' V; pred ⇑λs. s(V := interpret e s) s⟧ ⟹ pred ⇑λs. s(V := interpret e s) s'›
5. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
6. ‹⋀b c₁ c₂. ⟦∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V; pred (λs. interpret b s = Some false)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some false)⇩√ s'›
7. ‹⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; ⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V; pred et s⟧ ⟹ pred et s'›
8. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; ⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V; pred et s⟧ ⟹ pred et s'›
9. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 0 _). s V = s' V; pred (λs. interpret b s = Some true)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some true)⇩√ s'›
10. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 0 _). s V = s' V; pred (λs. interpret b s = Some false)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some false)⇩√ s'›
11. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
12. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›
13. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›*)
case (WCFG_CondFalse b c₁ c₂) (*‹∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V› ‹pred (λs. interpret b s = Some false)⇩√ s›*)
from ‹∀V∈Uses (if (b) c₁ else c₂) (_0_). s V = s' V› (*‹∀V∈Uses (if (b) c₁ else c₂) (_ 0 _). s V = s' V›*) have all: "∀V. labels (if (b) c₁ else c₂) 0 (if (b) c₁ else c₂) ∧
V ∈ rhs (if (b) c₁ else c₂) ⟶ (s V = s' V)"
by fastforce
obtain v' where [simp]: "v' = false"
(*goal: ‹(⋀v'. v' = false ⟹ thesis) ⟹ thesis›*)
by simp
with ‹pred (λs. interpret b s = Some false)⇩√ s› (*‹pred (λs. interpret b s = Some false)⇩√ s›*) have "interpret b s = Some v'"
by simp
have "labels (if (b) c₁ else c₂) 0 (if (b) c₁ else c₂)"
by (rule Labels_Base (*‹labels ?c 0 ?c›*))
with all (*‹∀V. labels (if (b) c₁ else c₂) 0 (if (b) c₁ else c₂) ∧ V ∈ rhs (if (b) c₁ else c₂) ⟶ s V = s' V›*) have "∀V ∈ rhs_aux b. s V = s' V"
by simp
with ‹interpret b s = Some v'› (*‹interpret b s = Some v'›*) have "interpret b s' = Some v'"
by (rule rhs_interpret_eq (*‹⟦interpret ?b ?s = Some ?v'; ∀V∈rhs_aux ?b. ?s V = ?s' V⟧ ⟹ interpret ?b ?s' = Some ?v'›*))
thus "?case"
(*goal: ‹pred (λs::char list ⇒ val option. interpret (b::expr) s = Some false)⇩√ (s'::char list ⇒ val option)›*)
by simp
next
(*goals:
1. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. False)⇩√ s⟧ ⟹ pred (λs. False)⇩√ s'›
2. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. True)⇩√ s⟧ ⟹ pred (λs. True)⇩√ s'›
3. ‹⟦∀V∈Uses Skip (_ 0 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
4. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 0 _). s V = s' V; pred ⇑λs. s(V := interpret e s) s⟧ ⟹ pred ⇑λs. s(V := interpret e s) s'›
5. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
6. ‹⋀c₁ n et n' b c₂. ⟦c₁ ⊢ n -et→ n'; ⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V; pred et s⟧ ⟹ pred et s'›
7. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; ⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V; pred et s⟧ ⟹ pred et s'›
8. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 0 _). s V = s' V; pred (λs. interpret b s = Some true)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some true)⇩√ s'›
9. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 0 _). s V = s' V; pred (λs. interpret b s = Some false)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some false)⇩√ s'›
10. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
11. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›
12. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›*)
case (WCFG_CondThen c₁ n et n' b c₂) (*‹c₁ ⊢ n -et→ n'› ‹⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'› ‹(n::w_node) ≠ (_Entry_)› ‹∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V› ‹pred (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option)›*)
note IH = ‹⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'› (*‹⟦∀V∈Uses c₁ n. s V = s' V; pred et s⟧ ⟹ pred et s'›*)
from ‹∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V› (*‹∀V∈Uses (if (b) c₁ else c₂) (n ⊕ 1). s V = s' V›*) have "∀V∈Uses c₁ n. s V = s' V"
apply auto
(*goal: ‹∀V∈Uses c₁ n. s V = s' V›*)
by (blast dest:Labels_CondTrue (*‹labels ?c₁ ?l ?c ⟹ labels (if (?b) ?c₁ else ?c₂) (?l + 1) ?c›*))
from IH[OF this ‹pred et s›] (*‹pred et s'›*) show "?case"
(*goal: ‹pred et s'›*) .
next
(*goals:
1. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. False)⇩√ s⟧ ⟹ pred (λs. False)⇩√ s'›
2. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. True)⇩√ s⟧ ⟹ pred (λs. True)⇩√ s'›
3. ‹⟦∀V∈Uses Skip (_ 0 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
4. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 0 _). s V = s' V; pred ⇑λs. s(V := interpret e s) s⟧ ⟹ pred ⇑λs. s(V := interpret e s) s'›
5. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
6. ‹⋀c₂ n et n' b c₁. ⟦c₂ ⊢ n -et→ n'; ⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V; pred et s⟧ ⟹ pred et s'›
7. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 0 _). s V = s' V; pred (λs. interpret b s = Some true)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some true)⇩√ s'›
8. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 0 _). s V = s' V; pred (λs. interpret b s = Some false)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some false)⇩√ s'›
9. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
10. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›
11. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›*)
case (WCFG_CondElse c₂ n et n' b c₁) (*‹c₂ ⊢ n -et→ n'› ‹⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'› ‹n ≠ (_Entry_)› ‹∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V› ‹pred (et::(char list ⇒ val option) edge_kind) (s::char list ⇒ val option)›*)
note IH = ‹⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'› (*‹⟦∀V∈Uses c₂ n. s V = s' V; pred et s⟧ ⟹ pred et s'›*)
from ‹∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V› (*‹∀V∈Uses (if (b) c₁ else c₂) (n ⊕ #:c₁ + 1). s V = s' V›*) have "∀V∈Uses c₂ n. s V = s' V"
apply auto
(*goal: ‹∀V∈Uses c₂ n. s V = s' V›*)
apply (drule Labels_CondFalse[of _ _ _ b c₁] (*‹labels (?c₂::cmd) (?l::nat) (?c::cmd) ⟹ labels (if ((b::expr)) (c₁::cmd) else ?c₂) (?l + #:c₁ + (1::nat)) ?c›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (if (b) c₁ else c₂) (l + (#:c₁ + 1)) c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); labels c₂ l c; V ∈ rhs c⟧ ⟹ s V = s' V›*)
apply (erule_tac x="V" in allE (*‹⟦∀x::?'a::type. (?P::?'a::type ⇒ bool) x; ?P (?x::?'a::type) ⟹ ?R::bool⟧ ⟹ ?R›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (if (b) c₁ else c₂) (l + (#:c₁ + 1)) c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); V ∈ rhs c; labels (if (b) c₁ else c₂) (l + #:c₁ + 1) c⟧ ⟹ s V = s' V›*)
by (auto simp:add.assoc (*‹?a + ?b + ?c = ?a + (?b + ?c)›*))
from IH[OF this ‹pred et s›] (*‹pred et s'›*) show "?case"
(*goal: ‹pred et s'›*) .
next
(*goals:
1. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. False)⇩√ s⟧ ⟹ pred (λs. False)⇩√ s'›
2. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. True)⇩√ s⟧ ⟹ pred (λs. True)⇩√ s'›
3. ‹⟦∀V∈Uses Skip (_ 0 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
4. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 0 _). s V = s' V; pred ⇑λs. s(V := interpret e s) s⟧ ⟹ pred ⇑λs. s(V := interpret e s) s'›
5. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
6. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 0 _). s V = s' V; pred (λs. interpret b s = Some true)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some true)⇩√ s'›
7. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 0 _). s V = s' V; pred (λs. interpret b s = Some false)⇩√ s⟧ ⟹ pred (λs. interpret b s = Some false)⇩√ s'›
8. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
9. ‹⋀c' n et n' b. ⟦c' ⊢ n -et→ n'; ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›
10. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›*)
case (WCFG_WhileTrue b c') (*‹∀V::char list∈Uses (while ((b::expr)) (c'::cmd)) (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V› ‹pred (λs. interpret b s = Some true)⇩√ s›*)
from ‹∀V∈Uses (while (b) c') (_0_). s V = s' V› (*‹∀V∈Uses (while (b) c') (_ 0 _). s V = s' V›*) have all: "∀V. labels (while (b) c') 0 (while (b) c') ∧
V ∈ rhs (while (b) c') ⟶ (s V = s' V)"
by fastforce
obtain v' where [simp]: "v' = true"
(*goal: ‹(⋀v'. v' = true ⟹ thesis) ⟹ thesis›*)
by simp
with ‹pred (λs. interpret b s = Some true)⇩√ s› (*‹pred (λs. interpret b s = Some true)⇩√ s›*) have "interpret b s = Some v'"
by simp
have "labels (while (b) c') 0 (while (b) c')"
by (rule Labels_Base (*‹labels ?c 0 ?c›*))
with all (*‹∀V. labels (while (b) c') 0 (while (b) c') ∧ V ∈ rhs (while (b) c') ⟶ s V = s' V›*) have "∀V ∈ rhs_aux b. s V = s' V"
by simp
with ‹interpret b s = Some v'› (*‹interpret b s = Some v'›*) have "interpret b s' = Some v'"
by (rule rhs_interpret_eq (*‹⟦interpret ?b ?s = Some ?v'; ∀V∈rhs_aux ?b. ?s V = ?s' V⟧ ⟹ interpret ?b ?s' = Some ?v'›*))
thus "?case"
(*goal: ‹pred (λs. interpret b s = Some true)⇩√ s'›*)
by simp
next
(*goals:
1. ‹⋀prog::cmd. ⟦∀V::char list∈Uses prog (_Entry_). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred (λs::char list ⇒ val option. False)⇩√ s⟧ ⟹ pred (λs::char list ⇒ val option. False)⇩√ s'›
2. ‹⋀prog::cmd. ⟦∀V::char list∈Uses prog (_Entry_). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred (λs::char list ⇒ val option. True)⇩√ s⟧ ⟹ pred (λs::char list ⇒ val option. True)⇩√ s'›
3. ‹⟦∀V::char list∈Uses Skip (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
4. ‹⋀(V::char list) e::expr. ⟦∀V::char list∈Uses (V:=e) (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred ⇑λs::char list ⇒ val option. s(V := interpret e s) s⟧ ⟹ pred ⇑λs::char list ⇒ val option. s(V := interpret e s) s'›
5. ‹⋀(V::char list) e::expr. ⟦∀V::char list∈Uses (V:=e) (_ 1::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
6. ‹⋀(b::expr) c'::cmd. ⟦∀V::char list∈Uses (while (b) c') (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred (λs::char list ⇒ val option. interpret b s = Some false)⇩√ s⟧ ⟹ pred (λs::char list ⇒ val option. interpret b s = Some false)⇩√ s'›
7. ‹⋀(b::expr) c'::cmd. ⟦∀V::char list∈Uses (while (b) c') (_ 1::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
8. ‹⋀(c'::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) b::expr. ⟦c' ⊢ n -et→ n'; ⟦∀V::char list∈Uses c' n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V::char list∈Uses (while (b) c') (n ⊕ 2::nat). s V = s' V; pred et s⟧ ⟹ pred et s'›
9. ‹⋀(c'::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) b::expr. ⟦c' ⊢ n -et→ (_Exit_); ⟦∀V::char list∈Uses c' n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V::char list∈Uses (while (b) c') (n ⊕ 2::nat). s V = s' V; pred et s⟧ ⟹ pred et s'›*)
case (WCFG_WhileFalse b c') (*‹∀V∈Uses (while (b) c') (_ 0 _). s V = s' V› ‹pred (λs::char list ⇒ val option. interpret (b::expr) s = Some false)⇩√ (s::char list ⇒ val option)›*)
from ‹∀V∈Uses (while (b) c') (_0_). s V = s' V› (*‹∀V∈Uses (while (b) c') (_ 0 _). s V = s' V›*) have all: "∀V. labels (while (b) c') 0 (while (b) c') ∧
V ∈ rhs (while (b) c') ⟶ (s V = s' V)"
by fastforce
obtain v' where [simp]: "v' = false"
(*goal: ‹(⋀v'. v' = false ⟹ thesis) ⟹ thesis›*)
by simp
with ‹pred (λs. interpret b s = Some false)⇩√ s› (*‹pred (λs. interpret b s = Some false)⇩√ s›*) have "interpret b s = Some v'"
by simp
have "labels (while (b) c') 0 (while (b) c')"
by (rule Labels_Base (*‹labels ?c 0 ?c›*))
with all (*‹∀V. labels (while (b) c') 0 (while (b) c') ∧ V ∈ rhs (while (b) c') ⟶ s V = s' V›*) have "∀V ∈ rhs_aux b. s V = s' V"
by simp
with ‹interpret b s = Some v'› (*‹interpret b s = Some v'›*) have "interpret b s' = Some v'"
by (rule rhs_interpret_eq (*‹⟦interpret ?b ?s = Some ?v'; ∀V∈rhs_aux ?b. ?s V = ?s' V⟧ ⟹ interpret ?b ?s' = Some ?v'›*))
thus "?case"
(*goal: ‹pred (λs::char list ⇒ val option. interpret (b::expr) s = Some false)⇩√ (s'::char list ⇒ val option)›*)
by simp
next
(*goals:
1. ‹⋀prog::cmd. ⟦∀V::char list∈Uses prog (_Entry_). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred (λs::char list ⇒ val option. False)⇩√ s⟧ ⟹ pred (λs::char list ⇒ val option. False)⇩√ s'›
2. ‹⋀prog::cmd. ⟦∀V::char list∈Uses prog (_Entry_). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred (λs::char list ⇒ val option. True)⇩√ s⟧ ⟹ pred (λs::char list ⇒ val option. True)⇩√ s'›
3. ‹⟦∀V::char list∈Uses Skip (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
4. ‹⋀(V::char list) e::expr. ⟦∀V::char list∈Uses (V:=e) (_ 0::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred ⇑λs::char list ⇒ val option. s(V := interpret e s) s⟧ ⟹ pred ⇑λs::char list ⇒ val option. s(V := interpret e s) s'›
5. ‹⋀(V::char list) e::expr. ⟦∀V::char list∈Uses (V:=e) (_ 1::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
6. ‹⋀(b::expr) c'::cmd. ⟦∀V::char list∈Uses (while (b) c') (_ 1::nat _). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
7. ‹⋀(c'::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) (n'::w_node) b::expr. ⟦c' ⊢ n -et→ n'; ⟦∀V::char list∈Uses c' n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); n' ≠ (_Exit_); ∀V::char list∈Uses (while (b) c') (n ⊕ 2::nat). s V = s' V; pred et s⟧ ⟹ pred et s'›
8. ‹⋀(c'::cmd) (n::w_node) (et::(char list ⇒ val option) edge_kind) b::expr. ⟦c' ⊢ n -et→ (_Exit_); ⟦∀V::char list∈Uses c' n. (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V::char list∈Uses (while (b) c') (n ⊕ 2::nat). s V = s' V; pred et s⟧ ⟹ pred et s'›*)
case (WCFG_WhileBody c' n et n' b) (*‹c' ⊢ n -et→ n'› ‹⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'› ‹(n::w_node) ≠ (_Entry_)› ‹(n'::w_node) ≠ (_Exit_)› ‹∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V› ‹pred et s›*)
note IH = ‹⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'› (*‹⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'›*)
from ‹∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V› (*‹∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V›*) have "∀V∈Uses c' n. s V = s' V"
apply auto
(*goal: ‹∀V∈Uses c' n. s V = s' V›*)
apply (drule Labels_WhileBody[of _ _ _ b] (*‹labels ?c' ?l ?c ⟹ labels (while (b) ?c') (?l + 2) (?c;; while (b) ?c')›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (while (b) c') (Suc (Suc l)) c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); labels c' l c; V ∈ rhs c⟧ ⟹ s V = s' V›*)
apply (erule_tac x="V" in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (while (b) c') (Suc (Suc l)) c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); V ∈ rhs c; labels (while (b) c') (l + 2) (c;; while (b) c')⟧ ⟹ s V = s' V›*)
by auto
from IH[OF this ‹pred et s›] (*‹pred (et::(char list ⇒ val option) edge_kind) (s'::char list ⇒ val option)›*) show "?case"
(*goal: ‹pred (et::(char list ⇒ val option) edge_kind) (s'::char list ⇒ val option)›*) .
next
(*goals:
1. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. False)⇩√ s⟧ ⟹ pred (λs. False)⇩√ s'›
2. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. True)⇩√ s⟧ ⟹ pred (λs. True)⇩√ s'›
3. ‹⟦∀V∈Uses Skip (_ 0 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
4. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 0 _). s V = s' V; pred ⇑λs. s(V := interpret e s) s⟧ ⟹ pred ⇑λs. s(V := interpret e s) s'›
5. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
6. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
7. ‹⋀c' n et b. ⟦c' ⊢ n -et→ (_Exit_); ⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'; n ≠ (_Entry_); ∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V; pred et s⟧ ⟹ pred et s'›*)
case (WCFG_WhileBodyExit c' n et b) (*‹c' ⊢ n -et→ (_Exit_)› ‹⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'› ‹n ≠ (_Entry_)› ‹∀V::char list∈Uses (while ((b::expr)) (c'::cmd)) (n::w_node ⊕ 2::nat). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V› ‹pred et s›*)
note IH = ‹⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'› (*‹⟦∀V∈Uses c' n. s V = s' V; pred et s⟧ ⟹ pred et s'›*)
from ‹∀V∈Uses (while (b) c') (n ⊕ 2). s V = s' V› (*‹∀V::char list∈Uses (while ((b::expr)) (c'::cmd)) (n::w_node ⊕ 2::nat). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V›*) have "∀V∈Uses c' n. s V = s' V"
apply auto
(*goal: ‹∀V::char list∈Uses (c'::cmd) (n::w_node). (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V›*)
apply (drule Labels_WhileBody[of _ _ _ b] (*‹labels ?c' ?l ?c ⟹ labels (while (b) ?c') (?l + 2) (?c;; while (b) ?c')›*))
(*goal: ‹⋀(V::char list) (l::nat) c::cmd. ⟦∀V::char list. (∃c::cmd. labels (while ((b::expr)) (c'::cmd)) (Suc (Suc l)) c ∧ V ∈ rhs c) ⟶ (s::char list ⇒ val option) V = (s'::char list ⇒ val option) V; (n::w_node) = (_ l _); labels c' l c; V ∈ rhs c⟧ ⟹ s V = s' V›*)
apply (erule_tac x="V" in allE (*‹⟦∀x::?'a::type. (?P::?'a::type ⇒ bool) x; ?P (?x::?'a::type) ⟹ ?R::bool⟧ ⟹ ?R›*))
(*goal: ‹⋀V l c. ⟦∀V. (∃c. labels (while (b) c') (Suc (Suc l)) c ∧ V ∈ rhs c) ⟶ s V = s' V; n = (_ l _); V ∈ rhs c; labels (while (b) c') (l + 2) (c;; while (b) c')⟧ ⟹ s V = s' V›*)
by auto
from IH[OF this ‹pred et s›] (*‹pred et s'›*) show "?case"
(*goal: ‹pred (et::(char list ⇒ val option) edge_kind) (s'::char list ⇒ val option)›*) .
qed (simp_all)
(*solves the remaining goals:
1. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. False)⇩√ s⟧ ⟹ pred (λs. False)⇩√ s'›
2. ‹⋀prog. ⟦∀V∈Uses prog (_Entry_). s V = s' V; pred (λs. True)⇩√ s⟧ ⟹ pred (λs. True)⇩√ s'›
3. ‹⟦∀V∈Uses Skip (_ 0 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
4. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 0 _). s V = s' V; pred ⇑λs. s(V := interpret e s) s⟧ ⟹ pred ⇑λs. s(V := interpret e s) s'›
5. ‹⋀V e. ⟦∀V∈Uses (V:=e) (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›
6. ‹⋀b c'. ⟦∀V∈Uses (while (b) c') (_ 1 _). s V = s' V; pred ⇑id s⟧ ⟹ pred ⇑id s'›*)
(*<*)declare One_nat_def [simp](*>*)
interpretation While_CFG_wf: CFG_wf sourcenode targetnode kind
"valid_edge prog" Entry "Defs prog" "Uses prog" id
for prog
proof (unfold_locales)
(*goals:
1. ‹Defs prog (_Entry_) = {} ∧ Uses prog (_Entry_) = {}›
2. ‹⋀a V s. ⟦valid_edge prog a; V ∉ Defs prog (sourcenode a); pred (kind a) s⟧ ⟹ id (transfer (kind a) s) V = id s V›
3. ‹⋀a s s'. ⟦valid_edge prog a; ∀V∈Uses prog (sourcenode a). id s V = id s' V; pred (kind a) s; pred (kind a) s'⟧ ⟹ ∀V∈Defs prog (sourcenode a). id (transfer (kind a) s) V = id (transfer (kind a) s') V›
4. ‹⋀a s s'. ⟦valid_edge prog a; pred (kind a) s; ∀V∈Uses prog (sourcenode a). id s V = id s' V⟧ ⟹ pred (kind a) s'›
5. ‹⋀a a'. ⟦valid_edge prog a; valid_edge prog a'; sourcenode a = sourcenode a'; targetnode a ≠ targetnode a'⟧ ⟹ ∃Q Q'. kind a = (Q)⇩√ ∧ kind a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*)
show "Defs prog (_Entry_) = {} ∧ Uses prog (_Entry_) = {}"
by (simp add:Defs.simps (*‹Defs ?prog ?n = {V. ∃l c. ?n = (_ l _) ∧ labels ?prog l c ∧ V ∈ lhs c}›*) Uses.simps (*‹Uses ?prog ?n = {V. ∃l c. ?n = (_ l _) ∧ labels ?prog l c ∧ V ∈ rhs c}›*))
next
(*goals:
1. ‹⋀a V s. ⟦valid_edge prog a; V ∉ Defs prog (sourcenode a); pred (kind a) s⟧ ⟹ id (transfer (kind a) s) V = id s V›
2. ‹⋀a s s'. ⟦valid_edge prog a; ∀V∈Uses prog (sourcenode a). id s V = id s' V; pred (kind a) s; pred (kind a) s'⟧ ⟹ ∀V∈Defs prog (sourcenode a). id (transfer (kind a) s) V = id (transfer (kind a) s') V›
3. ‹⋀a s s'. ⟦valid_edge prog a; pred (kind a) s; ∀V∈Uses prog (sourcenode a). id s V = id s' V⟧ ⟹ pred (kind a) s'›
4. ‹⋀a a'. ⟦valid_edge prog a; valid_edge prog a'; sourcenode a = sourcenode a'; targetnode a ≠ targetnode a'⟧ ⟹ ∃Q Q'. kind a = (Q)⇩√ ∧ kind a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*)
fix a and V and s
assume "valid_edge prog a" and "V ∉ Defs prog (sourcenode a)" (*‹valid_edge (prog::cmd) (a::w_node × (char list ⇒ val option) edge_kind × w_node)› ‹(V::char list) ∉ Defs (prog::cmd) (sourcenode (a::w_node × (char list ⇒ val option) edge_kind × w_node))›*)
obtain nx and et and nx' where [simp]: "a = (nx,et,nx')"
(*goal: ‹(⋀(nx::w_node) (et::(char list ⇒ val option) edge_kind) nx'::w_node. (a::w_node × (char list ⇒ val option) edge_kind × w_node) = (nx, et, nx') ⟹ thesis::bool) ⟹ thesis›*)
apply (cases a)
(*goal: ‹(⋀nx et nx'. a = (nx, et, nx') ⟹ thesis) ⟹ thesis›*)
by auto
with ‹valid_edge prog a› (*‹valid_edge prog a›*) have "prog ⊢ nx -et→ nx'"
by (simp add:valid_edge_def (*‹valid_edge ?prog ?a ≡ ?prog ⊢ sourcenode ?a -kind ?a→ targetnode ?a›*))
with ‹V ∉ Defs prog (sourcenode a)› (*‹V ∉ Defs prog (sourcenode a)›*) show "id (transfer (kind a) s) V = id s V"
by (fastforce intro:WCFG_edge_no_Defs_equal (*‹⟦?prog ⊢ ?n -?et→ ?n'; ?V ∉ Defs ?prog ?n⟧ ⟹ transfer ?et ?s ?V = ?s ?V›*))
next
(*goals:
1. ‹⋀a s s'. ⟦valid_edge prog a; ∀V∈Uses prog (sourcenode a). id s V = id s' V; pred (kind a) s; pred (kind a) s'⟧ ⟹ ∀V∈Defs prog (sourcenode a). id (transfer (kind a) s) V = id (transfer (kind a) s') V›
2. ‹⋀a s s'. ⟦valid_edge prog a; pred (kind a) s; ∀V∈Uses prog (sourcenode a). id s V = id s' V⟧ ⟹ pred (kind a) s'›
3. ‹⋀a a'. ⟦valid_edge prog a; valid_edge prog a'; sourcenode a = sourcenode a'; targetnode a ≠ targetnode a'⟧ ⟹ ∃Q Q'. kind a = (Q)⇩√ ∧ kind a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*)
fix a
fix s :: state and s' :: state
assume "valid_edge prog a" and "∀V∈Uses prog (sourcenode a). id s V = id s' V" (*‹valid_edge (prog::cmd) (a::w_node × (char list ⇒ val option) edge_kind × w_node)› ‹∀V::char list∈Uses (prog::cmd) (sourcenode (a::w_node × (char list ⇒ val option) edge_kind × w_node)). id (s::char list ⇒ val option) V = id (s'::char list ⇒ val option) V›*)
obtain nx and et and nx' where [simp]: "a = (nx,et,nx')"
(*goal: ‹(⋀nx et nx'. a = (nx, et, nx') ⟹ thesis) ⟹ thesis›*)
apply (cases a)
(*goal: ‹(⋀nx et nx'. a = (nx, et, nx') ⟹ thesis) ⟹ thesis›*)
by auto
with ‹valid_edge prog a› (*‹valid_edge prog a›*) have "prog ⊢ nx -et→ nx'"
by (simp add:valid_edge_def (*‹valid_edge ?prog ?a ≡ ?prog ⊢ sourcenode ?a -kind ?a→ targetnode ?a›*))
with ‹∀V∈Uses prog (sourcenode a). id s V = id s' V› (*‹∀V∈Uses prog (sourcenode a). id s V = id s' V›*) show "∀V∈Defs prog (sourcenode a).
id (transfer (kind a) s) V = id (transfer (kind a) s') V"
apply -
(*goal: ‹∀V∈Defs prog (sourcenode a). id (transfer (kind a) s) V = id (transfer (kind a) s') V›*)
apply (drule WCFG_edge_transfer_uses_only_Uses (*‹⟦?prog ⊢ ?n -?et→ ?n'; ∀V∈Uses ?prog ?n. ?s V = ?s' V⟧ ⟹ ∀V∈Defs ?prog ?n. transfer ?et ?s V = transfer ?et ?s' V›*))
(*goals:
1. ‹∀V::char list∈Uses (prog::cmd) (sourcenode (a::w_node × (char list ⇒ val option) edge_kind × w_node)). id (s::char list ⇒ val option) V = id (s'::char list ⇒ val option) V ⟹ ∀V::char list∈Uses prog (nx::w_node). (?s2::char list ⇒ val option) V = (?s'2::char list ⇒ val option) V›
2. ‹⟦∀V::char list∈Uses (prog::cmd) (sourcenode (a::w_node × (char list ⇒ val option) edge_kind × w_node)). id (s::char list ⇒ val option) V = id (s'::char list ⇒ val option) V; ∀V::char list∈Defs prog (nx::w_node). transfer (et::(char list ⇒ val option) edge_kind) (?s2::char list ⇒ val option) V = transfer et (?s'2::char list ⇒ val option) V⟧ ⟹ ∀V::char list∈Defs prog (sourcenode a). id (transfer (kind a) s) V = id (transfer (kind a) s') V›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
next
(*goals:
1. ‹⋀a s s'. ⟦valid_edge prog a; pred (kind a) s; ∀V∈Uses prog (sourcenode a). id s V = id s' V⟧ ⟹ pred (kind a) s'›
2. ‹⋀a a'. ⟦valid_edge prog a; valid_edge prog a'; sourcenode a = sourcenode a'; targetnode a ≠ targetnode a'⟧ ⟹ ∃Q Q'. kind a = (Q)⇩√ ∧ kind a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*)
fix a and s and s'
assume pred: "pred (kind a) s" and valid: "valid_edge prog a" and all: "∀V∈Uses prog (sourcenode a). id s V = id s' V" (*‹pred (kind (a::w_node × (char list ⇒ val option) edge_kind × w_node)) (s::char list ⇒ val option)› ‹valid_edge (prog::cmd) (a::w_node × (char list ⇒ val option) edge_kind × w_node)› ‹∀V::char list∈Uses (prog::cmd) (sourcenode (a::w_node × (char list ⇒ val option) edge_kind × w_node)). id (s::char list ⇒ val option) V = id (s'::char list ⇒ val option) V›*)
obtain nx and et and nx' where [simp]: "a = (nx,et,nx')"
(*goal: ‹(⋀(nx::w_node) (et::(char list ⇒ val option) edge_kind) nx'::w_node. (a::w_node × (char list ⇒ val option) edge_kind × w_node) = (nx, et, nx') ⟹ thesis::bool) ⟹ thesis›*)
apply (cases a)
(*goal: ‹(⋀nx et nx'. a = (nx, et, nx') ⟹ thesis) ⟹ thesis›*)
by auto
with ‹valid_edge prog a› (*‹valid_edge prog a›*) have "prog ⊢ nx -et→ nx'"
by (simp add:valid_edge_def (*‹valid_edge ?prog ?a ≡ ?prog ⊢ sourcenode ?a -kind ?a→ targetnode ?a›*))
with ‹pred (kind a) s› (*‹pred (kind a) s›*) ‹∀V∈Uses prog (sourcenode a). id s V = id s' V› (*‹∀V∈Uses prog (sourcenode a). id s V = id s' V›*) show "pred (kind a) s'"
apply -
(*goal: ‹pred (kind (a::w_node × (char list ⇒ val option) edge_kind × w_node)) (s'::char list ⇒ val option)›*)
apply (drule WCFG_edge_Uses_pred_eq (*‹⟦?prog::cmd ⊢ ?n::w_node -?et::(char list ⇒ val option) edge_kind→ ?n'::w_node; ∀V::char list∈Uses ?prog ?n. (?s::char list ⇒ val option) V = (?s'::char list ⇒ val option) V; pred ?et ?s⟧ ⟹ pred ?et ?s'›*))
(*goals:
1. ‹⟦pred (kind a) s; ∀V∈Uses prog (sourcenode a). id s V = id s' V⟧ ⟹ ∀V∈Uses prog nx. ?s3 V = ?s'3 V›
2. ‹⟦pred (kind a) s; ∀V∈Uses prog (sourcenode a). id s V = id s' V⟧ ⟹ pred et ?s3›
3. ‹⟦pred (kind a) s; ∀V∈Uses prog (sourcenode a). id s V = id s' V; pred et ?s'3⟧ ⟹ pred (kind a) s'›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*) .
next
(*goal: ‹⋀(a::w_node × (char list ⇒ val option) edge_kind × w_node) a'::w_node × (char list ⇒ val option) edge_kind × w_node. ⟦valid_edge (prog::cmd) a; valid_edge prog a'; sourcenode a = sourcenode a'; targetnode a ≠ targetnode a'⟧ ⟹ ∃(Q::(char list ⇒ val option) ⇒ bool) Q'::(char list ⇒ val option) ⇒ bool. kind a = (Q)⇩√ ∧ kind a' = (Q')⇩√ ∧ (∀s::char list ⇒ val option. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*)
fix a and a'
assume "valid_edge prog a" and "valid_edge prog a'" and "sourcenode a = sourcenode a'" and "targetnode a ≠ targetnode a'" (*‹valid_edge (prog::cmd) (a::w_node × (char list ⇒ val option) edge_kind × w_node)› ‹valid_edge (prog::cmd) (a'::w_node × (char list ⇒ val option) edge_kind × w_node)› ‹sourcenode (a::w_node × (char list ⇒ val option) edge_kind × w_node) = sourcenode (a'::w_node × (char list ⇒ val option) edge_kind × w_node)› ‹targetnode (a::w_node × (char list ⇒ val option) edge_kind × w_node) ≠ targetnode (a'::w_node × (char list ⇒ val option) edge_kind × w_node)›*)
thus "∃Q Q'. kind a = (Q)⇩√ ∧ kind a' = (Q')⇩√ ∧
(∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))"
by (fastforce intro!:WCFG_deterministic (*‹⟦?prog::cmd ⊢ ?n₁::w_node -?et₁::(char list ⇒ val option) edge_kind→ ?n₁'::w_node; ?prog ⊢ ?n₂::w_node -?et₂::(char list ⇒ val option) edge_kind→ ?n₂'::w_node; ?n₁ = ?n₂; ?n₁' ≠ ?n₂'⟧ ⟹ ∃(Q::(char list ⇒ val option) ⇒ bool) Q'::(char list ⇒ val option) ⇒ bool. ?et₁ = (Q)⇩√ ∧ ?et₂ = (Q')⇩√ ∧ (∀s::char list ⇒ val option. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) simp:valid_edge_def (*‹valid_edge (?prog::cmd) (?a::w_node × (char list ⇒ val option) edge_kind × w_node) ≡ ?prog ⊢ sourcenode ?a -kind ?a→ targetnode ?a›*))
qed
lemma While_CFGExit_wf_aux:"CFGExit_wf sourcenode targetnode kind
(valid_edge prog) Entry (Defs prog) (Uses prog) id Exit"
proof (unfold_locales)
(*goal: ‹Defs prog (_Exit_) = {} ∧ Uses prog (_Exit_) = {}›*)
show "Defs prog (_Exit_) = {} ∧ Uses prog (_Exit_) = {}"
by (simp add:Defs.simps (*‹Defs ?prog ?n = {V. ∃l c. ?n = (_ l _) ∧ labels ?prog l c ∧ V ∈ lhs c}›*) Uses.simps (*‹Uses ?prog ?n = {V. ∃l c. ?n = (_ l _) ∧ labels ?prog l c ∧ V ∈ rhs c}›*))
qed
interpretation While_CFGExit_wf: CFGExit_wf sourcenode targetnode kind
"valid_edge prog" Entry "Defs prog" "Uses prog" id Exit
for prog
by (rule While_CFGExit_wf_aux (*‹CFGExit_wf sourcenode targetnode kind (valid_edge ?prog) (_Entry_) (Defs ?prog) (Uses ?prog) id (_Exit_)›*))
end
| {
"path": "afp-2025-02-12/thys/Slicing/While/WellFormed.thy",
"repo": "afp-2025-02-12",
"sha": "4812130096493c57c694171eeacc9cfc7ab49e82815b6b46d7561d1448d8fada"
} |
(* Author: Tobias Nipkow *)
section "Deterministic List Update"
theory Move_to_Front
imports
Swaps
On_Off
Competitive_Analysis
begin
declare Let_def[simp]
subsection "Function ‹mtf›"
definition mtf :: "'a ⇒ 'a list ⇒ 'a list" where
"mtf x xs =
(if x ∈ set xs then x # (take (index xs x) xs) @ drop (index xs x + 1) xs
else xs)"
lemma mtf_id[simp]: "x ∉ set xs ⟹ mtf x xs = xs"
by (simp add: mtf_def (*‹mtf ?x ?xs = (if ?x ∈ set ?xs then ?x # take (index ?xs ?x) ?xs @ drop (index ?xs ?x + 1) ?xs else ?xs)›*))
lemma mtf0[simp]: "x ∈ set xs ⟹ mtf x xs ! 0 = x"
by (auto simp: mtf_def (*‹mtf ?x ?xs = (if ?x ∈ set ?xs then ?x # take (index ?xs ?x) ?xs @ drop (index ?xs ?x + 1) ?xs else ?xs)›*))
lemma before_in_mtf: assumes "z ∈ set xs"
shows "x < y in mtf z xs ⟷
(y ≠ z ∧ (if x=z then y ∈ set xs else x < y in xs))"
sorry
lemma Inv_mtf: "set xs = set ys ⟹ z : set ys ⟹ Inv xs (mtf z ys) =
Inv xs ys ∪ {(x,z)|x. x < z in xs ∧ x < z in ys}
- {(z,x)|x. z < x in xs ∧ x < z in ys}"
by (auto simp add: Inv_def (*‹Inv ?xs ?ys = {(x, y). x < y in ?xs ∧ y < x in ?ys}›*) before_in_mtf (*‹?z ∈ set ?xs ⟹ ?x < ?y in mtf ?z ?xs = (?y ≠ ?z ∧ (if ?x = ?z then ?y ∈ set ?xs else ?x < ?y in ?xs))›*) not_before_in (*‹⟦?x ∈ set ?xs; ?y ∈ set ?xs⟧ ⟹ (¬ ?x < ?y in ?xs) = (?y < ?x in ?xs ∨ ?x = ?y)›*) dest: before_in_setD1 (*‹?x < ?y in ?xs ⟹ ?x ∈ set ?xs›*))
lemma set_mtf[simp]: "set(mtf x xs) = set xs"
apply (simp add: mtf_def (*‹mtf ?x ?xs = (if ?x ∈ set ?xs then ?x # take (index ?xs ?x) ?xs @ drop (index ?xs ?x + 1) ?xs else ?xs)›*))
(*goal: ‹set (mtf x xs) = set xs›*)
by (metis append_take_drop_id (*‹take ?n ?xs @ drop ?n ?xs = ?xs›*) Cons_nth_drop_Suc (*‹?i < length ?xs ⟹ ?xs ! ?i # drop (Suc ?i) ?xs = drop ?i ?xs›*) index_less (*‹⟦?x ∈ set ?xs; length ?xs ≤ ?n⟧ ⟹ index ?xs ?x < ?n›*) le_refl (*‹?n ≤ ?n›*) Un_insert_right (*‹?A ∪ insert ?a ?B = insert ?a (?A ∪ ?B)›*) nth_index (*‹?x ∈ set ?xs ⟹ ?xs ! index ?xs ?x = ?x›*) set_append (*‹set (?xs @ ?ys) = set ?xs ∪ set ?ys›*) set_simps( (*‹set (?x21.0 # ?x22.0) = insert ?x21.0 (set ?x22.0)›*) 2))
lemma length_mtf[simp]: "size (mtf x xs) = size xs"
apply (auto simp add: mtf_def (*‹mtf ?x ?xs = (if ?x ∈ set ?xs then ?x # take (index ?xs ?x) ?xs @ drop (index ?xs ?x + 1) ?xs else ?xs)›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*))
(*goal: ‹length (mtf x xs) = length xs›*)
by (metis index_less_size_conv (*‹(index ?xs ?x < length ?xs) = (?x ∈ set ?xs)›*) leD (*‹?y ≤ ?x ⟹ ¬ ?x < ?y›*))
lemma distinct_mtf[simp]: "distinct (mtf x xs) = distinct xs"
by (metis length_mtf (*‹length (mtf ?x ?xs) = length ?xs›*) set_mtf (*‹set (mtf ?x ?xs) = set ?xs›*) card_distinct (*‹card (set ?xs) = length ?xs ⟹ distinct ?xs›*) distinct_card (*‹distinct ?xs ⟹ card (set ?xs) = length ?xs›*))
subsection "Function ‹mtf2›"
definition mtf2 :: "nat ⇒ 'a ⇒ 'a list ⇒ 'a list" where
"mtf2 n x xs =
(if x : set xs then swaps [index xs x - n..<index xs x] xs else xs)"
lemma mtf_eq_mtf2: "mtf x xs = mtf2 (length xs - 1) x xs"
proof (-)
(*goal: ‹mtf x xs = mtf2 (length xs - 1) x xs›*)
have "x : set xs ⟹ index xs x - (size xs - Suc 0) = 0"
by (auto simp: less_Suc_eq_le[symmetric] (*‹(?m ≤ ?n) = (?m < Suc ?n)›*))
thus "?thesis"
(*goal: ‹mtf x xs = mtf2 (length xs - 1) x xs›*)
by (auto simp: mtf_def (*‹mtf ?x ?xs = (if ?x ∈ set ?xs then ?x # take (index ?xs ?x) ?xs @ drop (index ?xs ?x + 1) ?xs else ?xs)›*) mtf2_def (*‹mtf2 ?n ?x ?xs = (if ?x ∈ set ?xs then swaps [index ?xs ?x - ?n..<index ?xs ?x] ?xs else ?xs)›*) swaps_eq_nth_take_drop (*‹?i < length ?xs ⟹ swaps [0..<?i] ?xs = ?xs ! ?i # take ?i ?xs @ drop (Suc ?i) ?xs›*))
qed
lemma mtf20[simp]: "mtf2 0 x xs = xs"
sorry
lemma length_mtf2[simp]: "length (mtf2 n x xs) = length xs"
by (auto simp: mtf2_def (*‹mtf2 ?n ?x ?xs = (if ?x ∈ set ?xs then swaps [index ?xs ?x - ?n..<index ?xs ?x] ?xs else ?xs)›*) index_less_size_conv[symmetric] (*‹(?x ∈ set ?xs) = (index ?xs ?x < length ?xs)›*) simp del:index_conv_size_if_notin (*‹?x ∉ set ?xs ⟹ index ?xs ?x = length ?xs›*))
lemma set_mtf2[simp]: "set(mtf2 n x xs) = set xs"
by (auto simp: mtf2_def (*‹mtf2 (?n::nat) (?x::?'a) (?xs::?'a list) = (if ?x ∈ set ?xs then swaps [index ?xs ?x - ?n..<index ?xs ?x] ?xs else ?xs)›*) index_less_size_conv[symmetric] (*‹((?x::?'a) ∈ set (?xs::?'a list)) = (index ?xs ?x < length ?xs)›*) simp del:index_conv_size_if_notin (*‹(?x::?'a) ∉ set (?xs::?'a list) ⟹ index ?xs ?x = length ?xs›*))
lemma distinct_mtf2[simp]: "distinct (mtf2 n x xs) = distinct xs"
by (metis length_mtf2 (*‹length (mtf2 (?n::nat) (?x::?'a) (?xs::?'a list)) = length ?xs›*) set_mtf2 (*‹set (mtf2 (?n::nat) (?x::?'a) (?xs::?'a list)) = set ?xs›*) card_distinct (*‹card (set (?xs::?'a list)) = length ?xs ⟹ distinct ?xs›*) distinct_card (*‹distinct (?xs::?'a list) ⟹ card (set ?xs) = length ?xs›*))
lemma card_Inv_mtf2: "xs!j = ys!0 ⟹ j < length xs ⟹ dist_perm xs ys ⟹
card (Inv (swaps [i..<j] xs) ys) = card (Inv xs ys) - int(j-i)"
proof (induction j arbitrary: xs)
(*goals:
1. ‹⋀xs::'a list. ⟦xs ! (0::nat) = (ys::'a list) ! (0::nat); (0::nat) < length xs; dist_perm xs ys⟧ ⟹ int (card (Inv (swaps [i::nat..<0::nat] xs) ys)) = int (card (Inv xs ys)) - int ((0::nat) - i)›
2. ‹⋀(j::nat) xs::'a list. ⟦⋀xs::'a list. ⟦xs ! j = (ys::'a list) ! (0::nat); j < length xs; dist_perm xs ys⟧ ⟹ int (card (Inv (swaps [i::nat..<j] xs) ys)) = int (card (Inv xs ys)) - int (j - i); xs ! Suc j = ys ! (0::nat); Suc j < length xs; dist_perm xs ys⟧ ⟹ int (card (Inv (swaps [i..<Suc j] xs) ys)) = int (card (Inv xs ys)) - int (Suc j - i)›*)
case (Suc j) (*‹⟦(?xs::'a::type list) ! (j::nat) = (ys::'a::type list) ! (0::nat); j < length ?xs; dist_perm ?xs ys⟧ ⟹ int (card (Inv (swaps [i::nat..<j] ?xs) ys)) = int (card (Inv ?xs ys)) - int (j - i)› ‹xs ! Suc j = ys ! 0› ‹Suc j < length xs› ‹dist_perm xs ys›*)
show "?case"
(*goal: ‹int (card (Inv (swaps [i..<Suc j] xs) ys)) = int (card (Inv xs ys)) - int (Suc j - i)›*)
proof (cases)
(*goals:
1. ‹?P::bool ⟹ int (card (Inv (swaps [i::nat..<Suc (j::nat)] (xs::'a::type list)) (ys::'a::type list))) = int (card (Inv xs ys)) - int (Suc j - i)›
2. ‹¬ (?P::bool) ⟹ int (card (Inv (swaps [i::nat..<Suc (j::nat)] (xs::'a::type list)) (ys::'a::type list))) = int (card (Inv xs ys)) - int (Suc j - i)›*)
assume "i > j" (*‹(j::nat) < (i::nat)›*)
thus "?thesis"
(*goal: ‹int (card (Inv (swaps [i::nat..<Suc (j::nat)] (xs::'a list)) (ys::'a list))) = int (card (Inv xs ys)) - int (Suc j - i)›*)
by simp
next
(*goal: ‹¬ j < i ⟹ int (card (Inv (swaps [i..<Suc j] xs) ys)) = int (card (Inv xs ys)) - int (Suc j - i)›*)
assume [arith]: "¬ i > j" (*‹¬ (j::nat) < (i::nat)›*)
have 0: "Suc j < length ys"
by (metis Suc.prems( (*‹Suc j < length xs› ‹dist_perm xs ys›*) 2,3) distinct_card (*‹distinct ?xs ⟹ card (set ?xs) = length ?xs›*))
have 1: "(ys ! 0, xs ! j) : Inv ys xs"
proof (auto simp: Inv_def (*‹Inv ?xs ?ys = {(x, y). x < y in ?xs ∧ y < x in ?ys}›*))
(*goals:
1. ‹(ys::'a list) ! (0::nat) < (xs::'a list) ! (j::nat) in ys›
2. ‹(xs::'a list) ! (j::nat) < (ys::'a list) ! (0::nat) in xs›*)
show "ys ! 0 < xs ! j in ys"
using Suc.prems (*‹xs ! Suc j = ys ! 0› ‹Suc j < length xs› ‹dist_perm xs ys›*) by (metis Suc_lessD (*‹Suc ?m < ?n ⟹ ?m < ?n›*) n_not_Suc_n (*‹?n ≠ Suc ?n›*) not_before0 (*‹¬ ?x < ?xs ! 0 in ?xs›*) not_before_in (*‹⟦?x ∈ set ?xs; ?y ∈ set ?xs⟧ ⟹ (¬ ?x < ?y in ?xs) = (?y < ?x in ?xs ∨ ?x = ?y)›*) nth_eq_iff_index_eq (*‹⟦distinct ?xs; ?i < length ?xs; ?j < length ?xs⟧ ⟹ (?xs ! ?i = ?xs ! ?j) = (?i = ?j)›*) nth_mem (*‹?n < length ?xs ⟹ ?xs ! ?n ∈ set ?xs›*))
show "xs ! j < ys ! 0 in xs"
using Suc.prems (*‹xs ! Suc j = ys ! 0› ‹Suc j < length xs› ‹dist_perm xs ys›*) by (metis Suc_lessD (*‹Suc (?m::nat) < (?n::nat) ⟹ ?m < ?n›*) before_id (*‹⟦distinct (?xs::?'a list); (?i::nat) < length ?xs; (?j::nat) < length ?xs⟧ ⟹ ?xs ! ?i < ?xs ! ?j in ?xs = (?i < ?j)›*) lessI (*‹(?n::nat) < Suc ?n›*))
qed
have 2: "card(Inv ys xs) ≠ 0"
using "1" (*‹(ys ! 0, xs ! j) ∈ Inv ys xs›*) by auto
have "int(card (Inv (swaps [i..<Suc j] xs) ys)) =
card (Inv (swap j xs) ys) - int (j-i)"
using Suc (*‹⟦?xs ! j = ys ! 0; j < length ?xs; dist_perm ?xs ys⟧ ⟹ int (card (Inv (swaps [i..<j] ?xs) ys)) = int (card (Inv ?xs ys)) - int (j - i)› ‹xs ! Suc j = ys ! 0› ‹Suc j < length xs› ‹dist_perm xs ys›*) by simp
also (*calculation: ‹int (card (Inv (swaps [i..<Suc j] xs) ys)) = int (card (Inv (swap j xs) ys)) - int (j - i)›*) have "… = card (Inv ys (swap j xs)) - int (j-i)"
by (simp add: card_Inv_sym (*‹card (Inv (?xs::?'a list) (?ys::?'a list)) = card (Inv ?ys ?xs)›*))
also (*calculation: ‹int (card (Inv (swaps [i::nat..<Suc (j::nat)] (xs::'a list)) (ys::'a list))) = int (card (Inv ys (swap j xs))) - int (j - i)›*) have "… = card (Inv ys xs - {(ys ! 0, xs ! j)}) - int (j - i)"
using Suc.prems (*‹(xs::'a list) ! Suc (j::nat) = (ys::'a list) ! (0::nat)› ‹Suc j < length xs› ‹dist_perm xs ys›*) "0" (*‹Suc j < length ys›*) by (simp add: Inv_swap (*‹dist_perm (?xs::?'a list) (?ys::?'a list) ⟹ Inv ?xs (swap (?n::nat) ?ys) = (if Suc ?n < length ?xs then if ?ys ! ?n < ?ys ! Suc ?n in ?xs then Inv ?xs ?ys ∪ {(?ys ! ?n, ?ys ! Suc ?n)} else Inv ?xs ?ys - {(?ys ! Suc ?n, ?ys ! ?n)} else Inv ?xs ?ys)›*))
also (*calculation: ‹int (card (Inv (swaps [i::nat..<Suc (j::nat)] (xs::'a list)) (ys::'a list))) = int (card (Inv ys xs - {(ys ! (0::nat), xs ! j)})) - int (j - i)›*) have "… = int(card (Inv ys xs) - 1) - (j - i)"
using "1" (*‹(ys ! 0, xs ! j) ∈ Inv ys xs›*) by (simp add: card_Diff_singleton (*‹?x ∈ ?A ⟹ card (?A - {?x}) = card ?A - 1›*))
also (*calculation: ‹int (card (Inv (swaps [i..<Suc j] xs) ys)) = int (card (Inv ys xs) - 1) - int (j - i)›*) have "… = card (Inv ys xs) - int (Suc j - i)"
using "2" (*‹card (Inv (ys::'a list) (xs::'a list)) ≠ (0::nat)›*) by arith
also (*calculation: ‹int (card (Inv (swaps [i..<Suc j] xs) ys)) = int (card (Inv ys xs)) - int (Suc j - i)›*) have "… = card (Inv xs ys) - int (Suc j - i)"
by (simp add: card_Inv_sym (*‹card (Inv ?xs ?ys) = card (Inv ?ys ?xs)›*))
finally (*calculation: ‹int (card (Inv (swaps [i..<Suc j] xs) ys)) = int (card (Inv xs ys)) - int (Suc j - i)›*) show "?thesis"
(*goal: ‹int (card (Inv (swaps [i..<Suc j] xs) ys)) = int (card (Inv xs ys)) - int (Suc j - i)›*) .
qed
qed (simp)
(*solved the remaining goal: ‹⋀xs. ⟦xs ! 0 = ys ! 0; 0 < length xs; dist_perm xs ys⟧ ⟹ int (card (Inv (swaps [i..<0] xs) ys)) = int (card (Inv xs ys)) - int (0 - i)›*)
subsection "Function Lxy"
definition Lxy :: "'a list ⇒ 'a set ⇒ 'a list" where
"Lxy xs S = filter (λz. z∈S) xs"
thm inter_set_filter
lemma Lxy_length_cons: "length (Lxy xs S) ≤ length (Lxy (x#xs) S)"
unfolding Lxy_def
(*goal: ‹length (filter (λz::'a::type. z ∈ (S::'a::type set)) (xs::'a::type list)) ≤ length (filter (λz::'a::type. z ∈ S) ((x::'a::type) # xs))›*)
by simp
lemma Lxy_empty[simp]: "Lxy [] S = []"
unfolding Lxy_def
(*goal: ‹filter (λz. z ∈ S) [] = []›*)
by simp
lemma Lxy_set_filter: "set (Lxy xs S) = S ∩ set xs"
by (simp add: Lxy_def (*‹Lxy (?xs::?'a list) (?S::?'a set) = filter (λz::?'a. z ∈ ?S) ?xs›*) inter_set_filter (*‹(?A::?'a set) ∩ set (?xs::?'a list) = set (filter (λx::?'a. x ∈ ?A) ?xs)›*))
lemma Lxy_distinct: "distinct xs ⟹ distinct (Lxy xs S)"
by (simp add: Lxy_def (*‹Lxy ?xs ?S = filter (λz. z ∈ ?S) ?xs›*))
lemma Lxy_append: "Lxy (xs@ys) S = Lxy xs S @ Lxy ys S"
by (simp add: Lxy_def (*‹Lxy ?xs ?S = filter (λz. z ∈ ?S) ?xs›*))
lemma Lxy_snoc: "Lxy (xs@[x]) S = (if x∈S then Lxy xs S @ [x] else Lxy xs S)"
by (simp add: Lxy_def (*‹Lxy ?xs ?S = filter (λz. z ∈ ?S) ?xs›*))
lemma Lxy_not: "S ∩ set xs = {} ⟹ Lxy xs S = []"
unfolding Lxy_def
(*goal: ‹S ∩ set xs = {} ⟹ filter (λz. z ∈ S) xs = []›*)
apply (induct xs)
(*goals:
1. ‹S ∩ set [] = {} ⟹ filter (λz. z ∈ S) [] = []›
2. ‹⋀a xs. ⟦S ∩ set xs = {} ⟹ filter (λz. z ∈ S) xs = []; S ∩ set (a # xs) = {}⟧ ⟹ filter (λz. z ∈ S) (a # xs) = []›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
lemma Lxy_notin: "set xs ∩ S = {} ⟹ Lxy xs S = []"
apply (induct xs)
(*goals:
1. ‹set [] ∩ S = {} ⟹ Lxy [] S = []›
2. ‹⋀a xs. ⟦set xs ∩ S = {} ⟹ Lxy xs S = []; set (a # xs) ∩ S = {}⟧ ⟹ Lxy (a # xs) S = []›
discuss goal 1*)
apply (simp add: Lxy_def (*‹Lxy ?xs ?S = filter (λz. z ∈ ?S) ?xs›*))
(*discuss goal 2*)
apply (simp add: Lxy_def (*‹Lxy ?xs ?S = filter (λz. z ∈ ?S) ?xs›*))
(*proven 2 subgoals*) .
lemma Lxy_in: "x∈S ⟹ Lxy [x] S = [x]"
by (simp add: Lxy_def (*‹Lxy ?xs ?S = filter (λz. z ∈ ?S) ?xs›*))
lemma Lxy_project:
assumes "x≠y" "x ∈ set xs" "y∈set xs" "distinct xs"
and "x < y in xs"
shows "Lxy xs {x,y} = [x,y]"
proof (-)
(*goal: ‹Lxy xs {x, y} = [x, y]›*)
from assms (*‹x ≠ y› ‹x ∈ set xs› ‹y ∈ set xs› ‹distinct (xs::'a list)› ‹x < y in xs›*) have ij: "index xs x < index xs y" and xinxs: "index xs x < length xs" and yinxs: "index xs y < length xs"
unfolding before_in_def
(*goals:
1. ‹index xs x < index xs y›
2. ‹index xs x < length xs›
3. ‹index xs y < length xs›*)
apply -
(*goals:
1. ‹⟦(x::'a::type) ≠ (y::'a::type); x ∈ set (xs::'a::type list); y ∈ set xs; distinct xs; index xs x < index xs y ∧ y ∈ set xs⟧ ⟹ index xs x < index xs y›
2. ‹⟦(x::'a::type) ≠ (y::'a::type); x ∈ set (xs::'a::type list); y ∈ set xs; distinct xs; index xs x < index xs y ∧ y ∈ set xs⟧ ⟹ index xs x < length xs›
3. ‹⟦(x::'a::type) ≠ (y::'a::type); x ∈ set (xs::'a::type list); y ∈ set xs; distinct xs; index xs x < index xs y ∧ y ∈ set xs⟧ ⟹ index xs y < length xs›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
from xinxs (*‹index xs x < length xs›*) obtain a and as where dec1: "a @ [xs!index xs x] @ as = xs" and "a = take (index xs x) xs" and "as = drop (Suc (index xs x)) xs" and length_a: "length a = index xs x" and length_as: "length as = length xs - index xs x- 1"
(*goal: ‹(⋀a as. ⟦a @ [xs ! index xs x] @ as = xs; a = take (index xs x) xs; as = drop (Suc (index xs x)) xs; length a = index xs x; length as = length xs - index xs x - 1⟧ ⟹ thesis) ⟹ thesis›*)
using id_take_nth_drop (*‹(?i::nat) < length (?xs::?'a list) ⟹ ?xs = take ?i ?xs @ ?xs ! ?i # drop (Suc ?i) ?xs›*) by fastforce
have "index xs y≥length (a @ [xs!index xs x])"
using length_a (*‹length (a::'a::type list) = index (xs::'a::type list) (x::'a::type)›*) ij (*‹index xs x < index xs y›*) by auto
then have "((a @ [xs!index xs x]) @ as) ! index xs y = as ! (index xs y-length (a @ [xs ! index xs x]))"
using nth_append[where xs = "a @ [xs!index xs x]" and ys = "as"] (*‹((a @ [xs ! index xs x]) @ as) ! ?n = (if ?n < length (a @ [xs ! index xs x]) then (a @ [xs ! index xs x]) ! ?n else as ! (?n - length (a @ [xs ! index xs x])))›*) by simp
then have xsj: "xs ! index xs y = as ! (index xs y-index xs x-1)"
using dec1 (*‹a @ [xs ! index xs x] @ as = xs›*) length_a (*‹length a = index xs x›*) by auto
have las: "(index xs y-index xs x-1) < length as"
using length_as (*‹length as = length xs - index xs x - 1›*) yinxs (*‹index (xs::'a list) (y::'a) < length xs›*) ij (*‹index (xs::'a list) (x::'a) < index xs (y::'a)›*) by simp
obtain b and c where dec2: "b @ [xs!index xs y] @ c = as" and "b = take (index xs y-index xs x-1) as" "c=drop (Suc (index xs y-index xs x-1)) as" and length_b: "length b = index xs y-index xs x-1"
(*goal: ‹(⋀b c. ⟦b @ [xs ! index xs y] @ c = as; b = take (index xs y - index xs x - 1) as; c = drop (Suc (index xs y - index xs x - 1)) as; length b = index xs y - index xs x - 1⟧ ⟹ thesis) ⟹ thesis›*)
using id_take_nth_drop[OF las] (*‹as = take (index xs y - index xs x - 1) as @ as ! (index xs y - index xs x - 1) # drop (Suc (index xs y - index xs x - 1)) as›*) xsj (*‹xs ! index xs y = as ! (index xs y - index xs x - 1)›*) by force
have xs_dec: "a @ [xs!index xs x] @ b @ [xs!index xs y] @ c = xs"
using dec1 (*‹a @ [xs ! index xs x] @ as = xs›*) dec2 (*‹b @ [xs ! index xs y] @ c = as›*) by auto
from xs_dec (*‹a @ [xs ! index xs x] @ b @ [xs ! index xs y] @ c = xs›*) assms(4) (*‹distinct (xs::'a::type list)›*) have "distinct ((a @ [xs!index xs x] @ b @ [xs!index xs y]) @ c)"
by simp
then have c_empty: "set c ∩ {x,y} = {}" and b_empty: "set b ∩ {x,y} = {}" and a_empty: "set a ∩ {x,y} = {}"
apply -
(*goals:
1. ‹distinct ((a @ [xs ! index xs x] @ b @ [xs ! index xs y]) @ c) ⟹ set c ∩ {x, y} = {}›
2. ‹distinct ((a @ [xs ! index xs x] @ b @ [xs ! index xs y]) @ c) ⟹ set b ∩ {x, y} = {}›
3. ‹distinct ((a @ [xs ! index xs x] @ b @ [xs ! index xs y]) @ c) ⟹ set a ∩ {x, y} = {}›
discuss goal 1*)
apply ((auto simp add: assms( (*‹(x::'a) ∈ set (xs::'a list)› ‹(y::'a) ∈ set (xs::'a list)›*) 2,3))[1])
(*discuss goal 2*)
apply ((auto simp add: assms( (*‹(x::'a) ∈ set (xs::'a list)› ‹(y::'a) ∈ set (xs::'a list)›*) 2,3))[1])
(*discuss goal 3*)
apply ((auto simp add: assms( (*‹x ∈ set xs› ‹y ∈ set xs›*) 2,3))[1])
(*proven 3 subgoals*) .
have "Lxy (a @ [xs!index xs x] @ b @ [xs!index xs y] @ c) {x,y} = [x,y]"
apply (simp only: Lxy_append (*‹Lxy (?xs @ ?ys) ?S = Lxy ?xs ?S @ Lxy ?ys ?S›*))
(*goal: ‹Lxy (a @ [xs ! index xs x] @ b @ [xs ! index xs y] @ c) {x, y} = [x, y]›*)
apply (simp add: assms( (*‹x ∈ set xs› ‹y ∈ set xs›*) 2,3))
(*goal: ‹Lxy (a::'a list) {x::'a, y::'a} @ Lxy [(xs::'a list) ! index xs x] {x, y} @ Lxy (b::'a list) {x, y} @ Lxy [xs ! index xs y] {x, y} @ Lxy (c::'a list) {x, y} = [x, y]›*)
using a_empty (*‹set (a::'a list) ∩ {x::'a, y::'a} = {}›*) b_empty (*‹set b ∩ {x, y} = {}›*) c_empty (*‹set (c::'a list) ∩ {x::'a, y::'a} = {}›*) by (simp add: Lxy_notin (*‹set ?xs ∩ ?S = {} ⟹ Lxy ?xs ?S = []›*) Lxy_in (*‹?x ∈ ?S ⟹ Lxy [?x] ?S = [?x]›*))
with xs_dec (*‹a @ [xs ! index xs x] @ b @ [xs ! index xs y] @ c = xs›*) show "?thesis"
(*goal: ‹Lxy (xs::'a list) {x::'a, y::'a} = [x, y]›*)
by auto
qed
lemma Lxy_mono: "{x,y} ⊆ set xs ⟹ distinct xs ⟹ x < y in xs = x < y in Lxy xs {x,y}"
apply (cases "x=y")
(*goal: ‹⟦{x, y} ⊆ set xs; distinct xs⟧ ⟹ x < y in xs = x < y in Lxy xs {x, y}›*)
proof (simp add: before_in_irefl (*‹(?x::?'a) < ?x in (?xs::?'a list) = False›*))
(*goal: ‹⟦{x::'a, y::'a} ⊆ set (xs::'a list); distinct xs; x ≠ y⟧ ⟹ x < y in xs = x < y in Lxy xs {x, y}›*)
assume xyset: "{x,y} ⊆ set xs" (*‹{x::'a, y::'a} ⊆ set (xs::'a list)›*)
assume dxs: "distinct xs" (*‹distinct (xs::'a list)›*)
assume xy: "x≠y" (*‹(x::'a) ≠ (y::'a)›*)
{
fix x and y
assume 1: "{x,y} ⊆ set xs" (*‹{x::'a, y::'a} ⊆ set (xs::'a list)›*)
assume xny: "x≠y" (*‹(x::'a) ≠ (y::'a)›*)
assume 3: "x < y in xs" (*‹(x::'a) < (y::'a) in (xs::'a list)›*)
have "Lxy xs {x,y} = [x,y]"
apply (rule Lxy_project (*‹⟦?x ≠ ?y; ?x ∈ set ?xs; ?y ∈ set ?xs; distinct ?xs; ?x < ?y in ?xs⟧ ⟹ Lxy ?xs {?x, ?y} = [?x, ?y]›*))
(*goal: ‹Lxy xs {x, y} = [x, y]›*)
using xny (*‹x ≠ y›*) "1" (*‹{x, y} ⊆ set xs›*) "3" (*‹x < y in xs›*) dxs (*‹distinct xs›*) apply -
(*goals:
1. ‹⟦x ≠ y; {x, y} ⊆ set xs; x < y in xs; distinct xs⟧ ⟹ x ≠ y›
2. ‹⟦x ≠ y; {x, y} ⊆ set xs; x < y in xs; distinct xs⟧ ⟹ x ∈ set xs›
3. ‹⟦x ≠ y; {x, y} ⊆ set xs; x < y in xs; distinct xs⟧ ⟹ y ∈ set xs›
4. ‹⟦x ≠ y; {x, y} ⊆ set xs; x < y in xs; distinct xs⟧ ⟹ distinct xs›
5. ‹⟦x ≠ y; {x, y} ⊆ set xs; x < y in xs; distinct xs⟧ ⟹ x < y in xs›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .
then have "x < y in Lxy xs {x,y}"
using xny (*‹x ≠ y›*) by (simp add: before_in_def (*‹?x < ?y in ?xs = (index ?xs ?x < index ?xs ?y ∧ ?y ∈ set ?xs)›*))
}
note aha = this (*‹⟦{?xa2, ?ya2} ⊆ set xs; ?xa2 ≠ ?ya2; ?xa2 < ?ya2 in xs⟧ ⟹ ?xa2 < ?ya2 in Lxy xs {?xa2, ?ya2}›*)
have a: "x < y in xs ⟹ x < y in Lxy xs {x,y}"
apply (subst Lxy_project (*‹⟦(?x::?'a) ≠ (?y::?'a); ?x ∈ set (?xs::?'a list); ?y ∈ set ?xs; distinct ?xs; ?x < ?y in ?xs⟧ ⟹ Lxy ?xs {?x, ?y} = [?x, ?y]›*))
(*goal: ‹x < y in xs ⟹ x < y in Lxy xs {x, y}›*)
using xy (*‹x ≠ y›*) xyset (*‹{x, y} ⊆ set xs›*) dxs (*‹distinct (xs::'a::type list)›*) apply -
(*goals:
1. ‹⟦x < y in xs; x ≠ y; {x, y} ⊆ set xs; distinct xs⟧ ⟹ x ≠ y›
2. ‹⟦x < y in xs; x ≠ y; {x, y} ⊆ set xs; distinct xs⟧ ⟹ x ∈ set xs›
3. ‹⟦x < y in xs; x ≠ y; {x, y} ⊆ set xs; distinct xs⟧ ⟹ y ∈ set xs›
4. ‹⟦x < y in xs; x ≠ y; {x, y} ⊆ set xs; distinct xs⟧ ⟹ distinct xs›
5. ‹⟦x < y in xs; x ≠ y; {x, y} ⊆ set xs; distinct xs⟧ ⟹ x < y in xs›
6. ‹⟦x < y in xs; x ≠ y; {x, y} ⊆ set xs; distinct xs⟧ ⟹ x < y in [x, y]›
discuss goal 1*)
apply (simp add: before_in_def (*‹?x < ?y in ?xs = (index ?xs ?x < index ?xs ?y ∧ ?y ∈ set ?xs)›*))
(*discuss goal 2*)
apply (simp add: before_in_def (*‹?x < ?y in ?xs = (index ?xs ?x < index ?xs ?y ∧ ?y ∈ set ?xs)›*))
(*discuss goal 3*)
apply (simp add: before_in_def (*‹?x < ?y in ?xs = (index ?xs ?x < index ?xs ?y ∧ ?y ∈ set ?xs)›*))
(*discuss goal 4*)
apply (simp add: before_in_def (*‹(?x::?'a::type) < (?y::?'a::type) in (?xs::?'a::type list) = (index ?xs ?x < index ?xs ?y ∧ ?y ∈ set ?xs)›*))
(*discuss goal 5*)
apply (simp add: before_in_def (*‹?x < ?y in ?xs = (index ?xs ?x < index ?xs ?y ∧ ?y ∈ set ?xs)›*))
(*discuss goal 6*)
apply (simp add: before_in_def (*‹(?x::?'a) < (?y::?'a) in (?xs::?'a list) = (index ?xs ?x < index ?xs ?y ∧ ?y ∈ set ?xs)›*))
(*proven 6 subgoals*) .
have t: "{x,y}={y,x}"
by auto
have f: "~ x < y in xs ⟹ y < x in Lxy xs {x,y}"
unfolding t
(*goal: ‹¬ x < y in xs ⟹ y < x in Lxy xs {y, x}›*)
apply (rule aha (*‹⟦{?xa2, ?ya2} ⊆ set xs; ?xa2 ≠ ?ya2; ?xa2 < ?ya2 in xs⟧ ⟹ ?xa2 < ?ya2 in Lxy xs {?xa2, ?ya2}›*))
(*goal: ‹¬ x < y in xs ⟹ y < x in Lxy xs {y, x}›*)
using xyset (*‹{x, y} ⊆ set xs›*) apply simp
(*top goal: ‹¬ x < y in xs ⟹ {y, x} ⊆ set xs› and 2 goals remain*)
using xy (*‹x ≠ y›*) apply simp
(*top goal: ‹¬ x < y in xs ⟹ y ≠ x› and 1 goal remains*)
using xy (*‹x ≠ y›*) xyset (*‹{x, y} ⊆ set xs›*) by (simp add: not_before_in (*‹⟦(?x::?'a) ∈ set (?xs::?'a list); (?y::?'a) ∈ set ?xs⟧ ⟹ (¬ ?x < ?y in ?xs) = (?y < ?x in ?xs ∨ ?x = ?y)›*))
have b: "~ x < y in xs ⟹ ~ x < y in Lxy xs {x,y}"
proof (-)
(*goal: ‹¬ x < y in xs ⟹ ¬ x < y in Lxy xs {x, y}›*)
assume "~ x < y in xs" (*‹¬ (x::'a) < (y::'a) in (xs::'a list)›*)
then have "y < x in Lxy xs {x,y}"
using f (*‹¬ (x::'a) < (y::'a) in (xs::'a list) ⟹ y < x in Lxy xs {x, y}›*) by auto
then have "~ x < y in Lxy xs {x,y}"
using xy (*‹x ≠ y›*) by (simp add: not_before_in (*‹⟦?x ∈ set ?xs; ?y ∈ set ?xs⟧ ⟹ (¬ ?x < ?y in ?xs) = (?y < ?x in ?xs ∨ ?x = ?y)›*))
then show "?thesis"
(*goal: ‹¬ x < y in Lxy xs {x, y}›*) .
qed
from a (*‹(x::'a) < (y::'a) in (xs::'a list) ⟹ x < y in Lxy xs {x, y}›*) b (*‹¬ (x::'a) < (y::'a) in (xs::'a list) ⟹ ¬ x < y in Lxy xs {x, y}›*) show "?thesis"
(*goal: ‹x < y in xs = x < y in Lxy xs {x, y}›*)
by metis
qed
subsection "List Update as Online/Offline Algorithm"
type_synonym 'a state = "'a list"
type_synonym answer = "nat * nat list"
definition step :: "'a state ⇒ 'a ⇒ answer ⇒ 'a state" where
"step s r a =
(let (k,sws) = a in mtf2 k r (swaps sws s))"
definition t :: "'a state ⇒ 'a ⇒ answer ⇒ nat" where
"t s r a = (let (mf,sws) = a in index (swaps sws s) r + 1 + size sws)"
definition static where "static s rs = (set rs ⊆ set s)"
interpretation On_Off step t static .
type_synonym 'a alg_off = "'a state ⇒ 'a list ⇒ answer list"
type_synonym ('a,'is) alg_on = "('a state,'is,'a,answer) alg_on"
lemma T_ge_len: "length as = length rs ⟹ T s rs as ≥ length rs"
apply (induction arbitrary: s rule: list_induct2)
(*goals:
1. ‹⋀s. length [] ≤ T s [] []›
2. ‹⋀x xs y ys s. ⟦length xs = length ys; ⋀s. length ys ≤ T s ys xs⟧ ⟹ length (y # ys) ≤ T s (y # ys) (x # xs)›
discuss goal 1*)
apply ((auto simp: t_def (*‹t ?s ?r ?a = (let (mf, sws) = ?a in index (swaps sws ?s) ?r + 1 + length sws)›*) trans_le_add2 (*‹?i ≤ ?j ⟹ ?i ≤ ?m + ?j›*))[1])
(*discuss goal 2*)
apply ((auto simp: t_def (*‹t ?s ?r ?a = (let (mf, sws) = ?a in index (swaps sws ?s) ?r + 1 + length sws)›*) trans_le_add2 (*‹?i ≤ ?j ⟹ ?i ≤ ?m + ?j›*))[1])
(*proven 2 subgoals*) .
lemma T_off_neq0: "(⋀rs s0. size(alg s0 rs) = length rs) ⟹
rs ≠ [] ⟹ T_off alg s0 rs ≠ 0"
apply (erule_tac x=rs in meta_allE (*‹⟦⋀x. PROP ?P x; PROP ?P ?x ⟹ PROP ?W⟧ ⟹ PROP ?W›*))
(*goal: ‹⟦⋀rs s0. length (alg s0 rs) = length rs; rs ≠ []⟧ ⟹ T_off alg s0 rs ≠ 0›*)
apply (erule_tac x=s0 in meta_allE (*‹⟦⋀x. PROP ?P x; PROP ?P ?x ⟹ PROP ?W⟧ ⟹ PROP ?W›*))
(*goal: ‹⟦rs ≠ []; ⋀s0. length (alg s0 rs) = length rs⟧ ⟹ T_off alg s0 rs ≠ 0›*)
by (auto simp: neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) length_Suc_conv (*‹(length ?xs = Suc ?n) = (∃y ys. ?xs = y # ys ∧ length ys = ?n)›*) t_def (*‹t ?s ?r ?a = (let (mf, sws) = ?a in index (swaps sws ?s) ?r + 1 + length sws)›*))
lemma length_step[simp]: "length (step s r as) = length s"
by (simp add: step_def (*‹step ?s ?r ?a = (let (k, sws) = ?a in mtf2 k ?r (swaps sws ?s))›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*))
lemma step_Nil_iff[simp]: "step xs r act = [] ⟷ xs = []"
by (auto simp add: step_def (*‹step ?s ?r ?a = (let (k, sws) = ?a in mtf2 k ?r (swaps sws ?s))›*) mtf2_def (*‹mtf2 ?n ?x ?xs = (if ?x ∈ set ?xs then swaps [index ?xs ?x - ?n..<index ?xs ?x] ?xs else ?xs)›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))
lemma set_step2: "set(step s r (mf,sws)) = set s"
sorry
lemma set_step: "set(step s r act) = set s"
apply (cases act)
(*goal: ‹set (step s r act) = set s›*)
by (simp add: set_step2 (*‹set (step ?s ?r (?mf, ?sws)) = set ?s›*))
lemma distinct_step: "distinct(step s r as) = distinct s"
by (auto simp: step_def (*‹step ?s ?r ?a = (let (k, sws) = ?a in mtf2 k ?r (swaps sws ?s))›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*))
subsection "Online Algorithm Move-to-Front is 2-Competitive"
definition MTF :: "('a,unit) alg_on" where
"MTF = (λ_. (), λs r. ((size (fst s) - 1,[]), ()))"
text‹It was first proved by Sleator and Tarjan~\<^cite>‹"SleatorT-CACM85"› that
the Move-to-Front algorithm is 2-competitive.›
(* The core idea with upper bounds: *)
lemma potential:
fixes t :: "nat ⇒ 'a::linordered_ab_group_add" and p :: "nat ⇒ 'a"
assumes p0: "p 0 = 0" and ppos: "⋀n. p n ≥ 0"
and ub: "⋀n. t n + p(n+1) - p n ≤ u n"
shows "(∑i<n. t i) ≤ (∑i<n. u i)"
proof (-)
(*goal: ‹sum t {..<n} ≤ sum u {..<n}›*)
let ?a = "λn. t n + p(n+1) - p n"
have 1: "(∑i<n. t i) = (∑i<n. ?a i) - p(n)"
apply (induction n)
(*goals:
1. ‹sum t {..<0} = (∑i<0. t i + p (i + 1) - p i) - p 0›
2. ‹⋀n. sum t {..<n} = (∑i<n. t i + p (i + 1) - p i) - p n ⟹ sum t {..<Suc n} = (∑i<Suc n. t i + p (i + 1) - p i) - p (Suc n)›
discuss goal 1*)
apply (simp add: p0 (*‹(p::nat ⇒ 'a) (0::nat) = (0::'a)›*))
(*discuss goal 2*)
apply (simp add: p0 (*‹(p::nat ⇒ 'a) (0::nat) = (0::'a)›*))
(*proven 2 subgoals*) .
thus "?thesis"
(*goal: ‹sum t {..<n} ≤ sum u {..<n}›*)
by (metis (erased, lifting) add.commute (*‹?a + ?b = ?b + ?a›*) diff_add_cancel (*‹?a - ?b + ?b = ?a›*) le_add_same_cancel2 (*‹(?a ≤ ?b + ?a) = (0 ≤ ?b)›*) order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*) ppos (*‹0 ≤ p ?n›*) sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*) ub (*‹t ?n + p (?n + 1) - p ?n ≤ u ?n›*))
qed
lemma potential2:
fixes t :: "nat ⇒ 'a::linordered_ab_group_add" and p :: "nat ⇒ 'a"
assumes p0: "p 0 = 0" and ppos: "⋀n. p n ≥ 0"
and ub: "⋀m. m<n ⟹ t m + p(m+1) - p m ≤ u m"
shows "(∑i<n. t i) ≤ (∑i<n. u i)"
proof (-)
(*goal: ‹sum t {..<n} ≤ sum u {..<n}›*)
let ?a = "λn. t n + p(n+1) - p n"
have "(∑i<n. t i) = (∑i<n. ?a i) - p(n)"
apply (induction n)
(*goals:
1. ‹sum t {..<0} = (∑i<0. t i + p (i + 1) - p i) - p 0›
2. ‹⋀n. sum t {..<n} = (∑i<n. t i + p (i + 1) - p i) - p n ⟹ sum t {..<Suc n} = (∑i<Suc n. t i + p (i + 1) - p i) - p (Suc n)›
discuss goal 1*)
apply (simp add: p0 (*‹p 0 = 0›*))
(*discuss goal 2*)
apply (simp add: p0 (*‹p 0 = 0›*))
(*proven 2 subgoals*) .
also (*calculation: ‹sum t {..<n} = (∑i<n. t i + p (i + 1) - p i) - p n›*) have "… ≤ (∑i<n. ?a i)"
using ppos (*‹0 ≤ p ?n›*) by auto
also (*calculation: ‹sum t {..<n} ≤ (∑i<n. t i + p (i + 1) - p i)›*) have "… ≤ (∑i<n. u i)"
apply (rule sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*))
(*goal: ‹(∑i<n. t i + p (i + 1) - p i) ≤ sum u {..<n}›*)
apply (rule ub (*‹?m < n ⟹ t ?m + p (?m + 1) - p ?m ≤ u ?m›*))
(*goal: ‹⋀i::nat. i ∈ {..<n::nat} ⟹ (t::nat ⇒ 'a::linordered_ab_group_add) i + (p::nat ⇒ 'a::linordered_ab_group_add) (i + (1::nat)) - p i ≤ (u::nat ⇒ 'a::linordered_ab_group_add) i›*)
by auto
finally (*calculation: ‹sum (t::nat ⇒ 'a) {..<n::nat} ≤ sum (u::nat ⇒ 'a) {..<n}›*) show "?thesis"
(*goal: ‹sum (t::nat ⇒ 'a::linordered_ab_group_add) {..<n::nat} ≤ sum (u::nat ⇒ 'a::linordered_ab_group_add) {..<n}›*) .
qed
abbreviation "before x xs ≡ {y. y < x in xs}"
abbreviation "after x xs ≡ {y. x < y in xs}"
lemma finite_before[simp]: "finite (before x xs)"
apply (rule finite_subset[where B = "set xs"] (*‹⟦?A ⊆ set xs; finite (set xs)⟧ ⟹ finite ?A›*))
(*goals:
1. ‹before x xs ⊆ set xs›
2. ‹finite (set xs)›
discuss goal 1*)
apply ((auto dest: before_in_setD1 (*‹?x < ?y in ?xs ⟹ ?x ∈ set ?xs›*))[1])
(*discuss goal 2*)
apply ((auto dest: before_in_setD1 (*‹(?x::?'a) < (?y::?'a) in (?xs::?'a list) ⟹ ?x ∈ set ?xs›*))[1])
(*proven 2 subgoals*) .
lemma finite_after[simp]: "finite (after x xs)"
apply (rule finite_subset[where B = "set xs"] (*‹⟦(?A::'a::type set) ⊆ set (xs::'a::type list); finite (set xs)⟧ ⟹ finite ?A›*))
(*goals:
1. ‹after x xs ⊆ set xs›
2. ‹finite (set xs)›
discuss goal 1*)
apply ((auto dest: before_in_setD2 (*‹(?x::?'a) < (?y::?'a) in (?xs::?'a list) ⟹ ?y ∈ set ?xs›*))[1])
(*discuss goal 2*)
apply ((auto dest: before_in_setD2 (*‹?x < ?y in ?xs ⟹ ?y ∈ set ?xs›*))[1])
(*proven 2 subgoals*) .
lemma before_conv_take:
"x : set xs ⟹ before x xs = set(take (index xs x) xs)"
apply (auto simp add: before_in_def (*‹?x < ?y in ?xs = (index ?xs ?x < index ?xs ?y ∧ ?y ∈ set ?xs)›*) set_take_if_index (*‹⟦index ?xs ?x < ?i; ?i ≤ length ?xs⟧ ⟹ ?x ∈ set (take ?i ?xs)›*) index_le_size (*‹index ?xs ?x ≤ length ?xs›*))
(*goal: ‹x ∈ set xs ⟹ before x xs = set (take (index xs x) xs)›*)
by (metis index_take (*‹?i ≤ index ?xs ?x ⟹ ?x ∉ set (take ?i ?xs)›*) leI (*‹¬ ?x < ?y ⟹ ?y ≤ ?x›*))
lemma card_before: "distinct xs ⟹ x : set xs ⟹ card (before x xs) = index xs x"
using index_le_size[of xs x] (*‹index xs x ≤ length xs›*) by (simp add: before_conv_take (*‹?x ∈ set ?xs ⟹ before ?x ?xs = set (take (index ?xs ?x) ?xs)›*) distinct_card[OF distinct_take] (*‹distinct ?xs1 ⟹ card (set (take ?i1 ?xs1)) = length (take ?i1 ?xs1)›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*))
lemma before_Un: "set xs = set ys ⟹ x : set xs ⟹
before x ys = before x xs ∩ before x ys Un after x xs ∩ before x ys"
apply auto
(*goal: ‹⟦set xs = set ys; x ∈ set xs⟧ ⟹ before x ys = before x xs ∩ before x ys ∪ after x xs ∩ before x ys›*)
by (metis before_in_setD1 (*‹?x < ?y in ?xs ⟹ ?x ∈ set ?xs›*) not_before_in (*‹⟦?x ∈ set ?xs; ?y ∈ set ?xs⟧ ⟹ (¬ ?x < ?y in ?xs) = (?y < ?x in ?xs ∨ ?x = ?y)›*))
lemma phi_diff_aux:
"card (Inv xs ys ∪
{(y, x) |y. y < x in xs ∧ y < x in ys} -
{(x, y) |y. x < y in xs ∧ y < x in ys}) =
card(Inv xs ys) + card(before x xs ∩ before x ys)
- int(card(after x xs ∩ before x ys))"
(is "card(?I ∪ ?B - ?A) = card ?I + card ?b - int(card ?a)")
proof (-)
(*goal: ‹int (card (Inv xs ys ∪ {(y, x) |y. y < x in xs ∧ y < x in ys} - {(x, y) |y. x < y in xs ∧ y < x in ys})) = int (card (Inv xs ys) + card (before x xs ∩ before x ys)) - int (card (after x xs ∩ before x ys))›*)
have 1: "?I ∩ ?B = {}"
apply (auto simp: Inv_def (*‹Inv ?xs ?ys = {(x, y). x < y in ?xs ∧ y < x in ?ys}›*))
(*goal: ‹Inv xs ys ∩ {(y, x) |y. y < x in xs ∧ y < x in ys} = {}›*)
by (metis no_before_inI (*‹?x < ?y in ?xs ⟹ (¬ ?y < ?x in ?xs) = True›*))
have 2: "?A ⊆ ?I ∪ ?B"
by (auto simp: Inv_def (*‹Inv ?xs ?ys = {(x, y). x < y in ?xs ∧ y < x in ?ys}›*))
have 3: "?A ⊆ ?I"
by (auto simp: Inv_def (*‹Inv (?xs::?'a list) (?ys::?'a list) = {(x::?'a, y::?'a). x < y in ?xs ∧ y < x in ?ys}›*))
have "int(card(?I ∪ ?B - ?A)) = int(card ?I + card ?B) - int(card ?A)"
using card_mono[OF _ 3] (*‹finite (Inv xs ys) ⟹ card {(x, y) |y. x < y in xs ∧ y < x in ys} ≤ card (Inv xs ys)›*) by (simp add: card_Un_disjoint[OF _ _ 1] (*‹⟦finite (Inv xs ys); finite {(y, x) |y. y < x in xs ∧ y < x in ys}⟧ ⟹ card (Inv xs ys ∪ {(y, x) |y. y < x in xs ∧ y < x in ys}) = card (Inv xs ys) + card {(y, x) |y. y < x in xs ∧ y < x in ys}›*) card_Diff_subset[OF _ 2] (*‹finite {(x, y) |y. x < y in xs ∧ y < x in ys} ⟹ card (Inv xs ys ∪ {(y, x) |y. y < x in xs ∧ y < x in ys} - {(x, y) |y. x < y in xs ∧ y < x in ys}) = card (Inv xs ys ∪ {(y, x) |y. y < x in xs ∧ y < x in ys}) - card {(x, y) |y. x < y in xs ∧ y < x in ys}›*))
also (*calculation: ‹int (card (Inv xs ys ∪ {(y, x) |y. y < x in xs ∧ y < x in ys} - {(x, y) |y. x < y in xs ∧ y < x in ys})) = int (card (Inv xs ys) + card {(y, x) |y. y < x in xs ∧ y < x in ys}) - int (card {(x, y) |y. x < y in xs ∧ y < x in ys})›*) have "card ?B = card (fst ` ?B)"
by (auto simp: card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*) inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))
also (*calculation: ‹int (card (Inv xs ys ∪ {(y, x) |y. y < x in xs ∧ y < x in ys} - {(x, y) |y. x < y in xs ∧ y < x in ys})) = int (card (Inv xs ys) + card (fst ` {(y, x) |y. y < x in xs ∧ y < x in ys})) - int (card {(x, y) |y. x < y in xs ∧ y < x in ys})›*) have "fst ` ?B = ?b"
by force
also (*calculation: ‹int (card (Inv xs ys ∪ {(y, x) |y. y < x in xs ∧ y < x in ys} - {(x, y) |y. x < y in xs ∧ y < x in ys})) = int (card (Inv xs ys) + card (before x xs ∩ before x ys)) - int (card {(x, y) |y. x < y in xs ∧ y < x in ys})›*) have "card ?A = card (snd ` ?A)"
by (auto simp: card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*) inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))
also (*calculation: ‹int (card (Inv xs ys ∪ {(y, x) |y. y < x in xs ∧ y < x in ys} - {(x, y) |y. x < y in xs ∧ y < x in ys})) = int (card (Inv xs ys) + card (before x xs ∩ before x ys)) - int (card (snd ` {(x, y) |y. x < y in xs ∧ y < x in ys}))›*) have "snd ` ?A = ?a"
by force
finally (*calculation: ‹int (card (Inv xs ys ∪ {(y, x) |y. y < x in xs ∧ y < x in ys} - {(x, y) |y. x < y in xs ∧ y < x in ys})) = int (card (Inv xs ys) + card (before x xs ∩ before x ys)) - int (card (after x xs ∩ before x ys))›*) show "?thesis"
(*goal: ‹int (card (Inv xs ys ∪ {(y, x) |y. y < x in xs ∧ y < x in ys} - {(x, y) |y. x < y in xs ∧ y < x in ys})) = int (card (Inv xs ys) + card (before x xs ∩ before x ys)) - int (card (after x xs ∩ before x ys))›*) .
qed
lemma not_before_Cons[simp]: "¬ x < y in y # xs"
by (simp add: before_in_def (*‹?x < ?y in ?xs = (index ?xs ?x < index ?xs ?y ∧ ?y ∈ set ?xs)›*))
lemma before_Cons[simp]:
"y ∈ set xs ⟹ y ≠ x ⟹ before y (x#xs) = insert x (before y xs)"
by (auto simp: before_in_def (*‹(?x::?'a::type) < (?y::?'a::type) in (?xs::?'a::type list) = (index ?xs ?x < index ?xs ?y ∧ ?y ∈ set ?xs)›*))
lemma card_before_le_index: "card (before x xs) ≤ index xs x"
apply (cases "x ∈ set xs")
(*goals:
1. ‹x ∈ set xs ⟹ card (before x xs) ≤ index xs x›
2. ‹x ∉ set xs ⟹ card (before x xs) ≤ index xs x›
discuss goal 1*)
apply (induction xs)
(*goals:
1. ‹x ∈ set [] ⟹ card (before x []) ≤ index [] x›
2. ‹⋀a xs. ⟦x ∈ set xs ⟹ card (before x xs) ≤ index xs x; x ∈ set (a # xs)⟧ ⟹ card (before x (a # xs)) ≤ index (a # xs) x›
discuss goal 1*)
apply (simp add: before_in_def (*‹?x < ?y in ?xs = (index ?xs ?x < index ?xs ?y ∧ ?y ∈ set ?xs)›*))
(*discuss goal 2*)
apply (auto simp: card_insert_if (*‹finite ?A ⟹ card (insert ?x ?A) = (if ?x ∈ ?A then card ?A else Suc (card ?A))›*))
(*proven 2 subgoals*)
(*discuss goal 2*)
apply (simp add: before_in_def (*‹?x < ?y in ?xs = (index ?xs ?x < index ?xs ?y ∧ ?y ∈ set ?xs)›*))
(*proven 2 subgoals*) .
lemma config_config_length: "length (fst (config A init qs)) = length init"
apply (induct rule: config_induct (*‹⟦(?P::?'aa list ⇒ bool) (?s0.0::?'aa list); ⋀(s::?'aa list) (q::?'aa) a::nat × nat list. ?P s ⟹ ?P (step s q a)⟧ ⟹ ?P (fst (config (?A::(?'aa list ⇒ ?'a) × (?'aa list × ?'a ⇒ ?'aa ⇒ (nat × nat list) × ?'a)) ?s0.0 (?qs::?'aa list)))›*))
(*goals:
1. ‹length init = length init›
2. ‹⋀s q a. length s = length init ⟹ length (step s q a) = length init›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
lemma config_config_distinct:
shows " distinct (fst (config A init qs)) = distinct init"
apply (induct rule: config_induct (*‹⟦(?P::?'aa list ⇒ bool) (?s0.0::?'aa list); ⋀(s::?'aa list) (q::?'aa) a::nat × nat list. ?P s ⟹ ?P (step s q a)⟧ ⟹ ?P (fst (config (?A::(?'aa list ⇒ ?'a) × (?'aa list × ?'a ⇒ ?'aa ⇒ (nat × nat list) × ?'a)) ?s0.0 (?qs::?'aa list)))›*))
(*goals:
1. ‹distinct (init::'a list) = distinct init›
2. ‹⋀(s::'a list) (q::'a) a::nat × nat list. distinct s = distinct (init::'a list) ⟹ distinct (step s q a) = distinct init›
discuss goal 1*)
apply (simp add: distinct_step (*‹distinct (step ?s ?r ?as) = distinct ?s›*))
(*discuss goal 2*)
apply (simp add: distinct_step (*‹distinct (step ?s ?r ?as) = distinct ?s›*))
(*proven 2 subgoals*) .
lemma config_config_set:
shows "set (fst (config A init qs)) = set init"
apply (induct rule: config_induct (*‹⟦?P ?s0.0; ⋀s q a. ?P s ⟹ ?P (step s q a)⟧ ⟹ ?P (fst (config ?A ?s0.0 ?qs))›*))
(*goals:
1. ‹set init = set init›
2. ‹⋀s q a. set s = set init ⟹ set (step s q a) = set init›
discuss goal 1*)
apply (simp add: set_step (*‹set (step ?s ?r ?act) = set ?s›*))
(*discuss goal 2*)
apply (simp add: set_step (*‹set (step ?s ?r ?act) = set ?s›*))
(*proven 2 subgoals*) .
lemma config_config:
"set (fst (config A init qs)) = set init
∧ distinct (fst (config A init qs)) = distinct init
∧ length (fst (config A init qs)) = length init"
using config_config_distinct (*‹distinct (fst (config (?A::(?'a list ⇒ ?'b) × (?'a list × ?'b ⇒ ?'a ⇒ (nat × nat list) × ?'b)) (?init::?'a list) (?qs::?'a list))) = distinct ?init›*) config_config_set (*‹set (fst (config ?A ?init ?qs)) = set ?init›*) config_config_length (*‹length (fst (config ?A ?init ?qs)) = length ?init›*) by metis
lemma config_dist_perm:
"distinct init ⟹ dist_perm (fst (config A init qs)) init"
using config_config_distinct (*‹distinct (fst (config ?A ?init ?qs)) = distinct ?init›*) config_config_set (*‹set (fst (config ?A ?init ?qs)) = set ?init›*) by metis
lemma config_rand_length: "∀x∈set_pmf (config_rand A init qs). length (fst x) = length init"
apply (induct rule: config_rand_induct (*‹⟦?P ?s0.0; ⋀s q a. ?P s ⟹ ?P (step s q a)⟧ ⟹ ∀x∈set_pmf (config'_rand ?A (fst ?A ?s0.0 ⤜ (λis. return_pmf (?s0.0, is))) ?qs). ?P (fst x)›*))
(*goals:
1. ‹length init = length init›
2. ‹⋀s q a. length s = length init ⟹ length (step s q a) = length init›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
lemma config_rand_distinct:
shows "∀x ∈ (config_rand A init qs). distinct (fst x) = distinct init"
apply (induct rule: config_rand_induct (*‹⟦?P ?s0.0; ⋀s q a. ?P s ⟹ ?P (step s q a)⟧ ⟹ ∀x∈set_pmf (config'_rand ?A (fst ?A ?s0.0 ⤜ (λis. return_pmf (?s0.0, is))) ?qs). ?P (fst x)›*))
(*goals:
1. ‹distinct (init::'a::type list) = distinct init›
2. ‹⋀(s::'a::type list) (q::'a::type) a::nat × nat list. distinct s = distinct (init::'a::type list) ⟹ distinct (step s q a) = distinct init›
discuss goal 1*)
apply (simp add: distinct_step (*‹distinct (step (?s::?'a list) (?r::?'a) (?as::nat × nat list)) = distinct ?s›*))
(*discuss goal 2*)
apply (simp add: distinct_step (*‹distinct (step ?s ?r ?as) = distinct ?s›*))
(*proven 2 subgoals*) .
lemma config_rand_set:
shows " ∀x ∈ (config_rand A init qs). set (fst x) = set init"
apply (induct rule: config_rand_induct (*‹⟦?P ?s0.0; ⋀s q a. ?P s ⟹ ?P (step s q a)⟧ ⟹ ∀x∈set_pmf (config'_rand ?A (fst ?A ?s0.0 ⤜ (λis. return_pmf (?s0.0, is))) ?qs). ?P (fst x)›*))
(*goals:
1. ‹set init = set init›
2. ‹⋀s q a. set s = set init ⟹ set (step s q a) = set init›
discuss goal 1*)
apply (simp add: set_step (*‹set (step ?s ?r ?act) = set ?s›*))
(*discuss goal 2*)
apply (simp add: set_step (*‹set (step ?s ?r ?act) = set ?s›*))
(*proven 2 subgoals*) .
lemma config_rand:
"∀x ∈ (config_rand A init qs). set (fst x) = set init
∧ distinct (fst x) = distinct init ∧ length (fst x) = length init"
using config_rand_distinct (*‹∀x∈set_pmf (config'_rand ?A (fst ?A ?init ⤜ (λis. return_pmf (?init, is))) ?qs). distinct (fst x) = distinct ?init›*) config_rand_set (*‹∀x∈set_pmf (config'_rand ?A (fst ?A ?init ⤜ (λis. return_pmf (?init, is))) ?qs). set (fst x) = set ?init›*) config_rand_length (*‹∀x∈set_pmf (config'_rand ?A (fst ?A ?init ⤜ (λis. return_pmf (?init, is))) ?qs). length (fst x) = length ?init›*) by metis
lemma config_rand_dist_perm:
"distinct init ⟹ ∀x ∈ (config_rand A init qs). dist_perm (fst x) init"
using config_rand_distinct (*‹∀x∈set_pmf (config'_rand ?A (fst ?A ?init ⤜ (λis. return_pmf (?init, is))) ?qs). distinct (fst x) = distinct ?init›*) config_rand_set (*‹∀x∈set_pmf (config'_rand ?A (fst ?A ?init ⤜ (λis. return_pmf (?init, is))) ?qs). set (fst x) = set ?init›*) by metis
(*fixme start from Inv*)
lemma amor_mtf_ub: assumes "x : set ys" "set xs = set ys"
shows "int(card(before x xs Int before x ys)) - card(after x xs Int before x ys)
≤ 2 * int(index xs x) - card (before x ys)" (is "?m - ?n ≤ 2 * ?j - ?k")
proof (-)
(*goal: ‹int (card (before x xs ∩ before x ys)) - int (card (after x xs ∩ before x ys)) ≤ 2 * int (index xs x) - int (card (before x ys))›*)
have xxs: "x ∈ set xs"
using assms(1,2) (*‹x ∈ set ys› ‹set xs = set ys›*) by simp
let ?bxxs = "before x xs"
let ?bxys = "before x ys"
let ?axxs = "after x xs"
have 0: "?bxxs ∩ ?axxs = {}"
by (auto simp: before_in_def (*‹(?x::?'a) < (?y::?'a) in (?xs::?'a list) = (index ?xs ?x < index ?xs ?y ∧ ?y ∈ set ?xs)›*))
hence 1: "(?bxxs ∩ ?bxys) ∩ (?axxs ∩ ?bxys) = {}"
by blast
have "(?bxxs ∩ ?bxys) ∪ (?axxs ∩ ?bxys) = ?bxys"
using assms(2) (*‹set (xs::'a list) = set (ys::'a list)›*) before_Un (*‹⟦set ?xs = set ?ys; ?x ∈ set ?xs⟧ ⟹ before ?x ?ys = before ?x ?xs ∩ before ?x ?ys ∪ after ?x ?xs ∩ before ?x ?ys›*) xxs (*‹x ∈ set xs›*) by fastforce
hence "?m + ?n = ?k"
using card_Un_disjoint[OF _ _ 1] (*‹⟦finite (before x xs ∩ before x ys); finite (after x xs ∩ before x ys)⟧ ⟹ card (before x xs ∩ before x ys ∪ after x xs ∩ before x ys) = card (before x xs ∩ before x ys) + card (after x xs ∩ before x ys)›*) by simp
hence "?m - ?n = 2 * ?m - ?k"
by arith
also (*calculation: ‹int (card (before x xs ∩ before x ys)) - int (card (after x xs ∩ before x ys)) = 2 * int (card (before x xs ∩ before x ys)) - int (card (before x ys))›*) have "?m ≤ ?j"
using card_before_le_index[of x xs] (*‹card (before x xs) ≤ index xs x›*) card_mono[of ?bxxs, OF _ Int_lower1] (*‹finite (before x xs) ⟹ card (before x xs ∩ ?B1) ≤ card (before x xs)›*) by (auto intro: order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*))
finally (*calculation: ‹(⋀xa y. xa ≤ y ⟹ 2 * xa - int (card (before x ys)) ≤ 2 * y - int (card (before x ys))) ⟹ int (card (before x xs ∩ before x ys)) - int (card (after x xs ∩ before x ys)) ≤ 2 * int (index xs x) - int (card (before x ys))›*) show "?thesis"
(*goal: ‹int (card (before (x::'a) (xs::'a list) ∩ before x (ys::'a list))) - int (card (after x xs ∩ before x ys)) ≤ (2::int) * int (index xs x) - int (card (before x ys))›*)
by auto
qed
locale MTF_Off =
fixes as :: "answer list"
fixes rs :: "'a list"
fixes s0 :: "'a list"
assumes dist_s0[simp]: "distinct s0"
assumes len_as: "length as = length rs"
begin
definition mtf_A :: "nat list" where
"mtf_A = map fst as"
definition sw_A :: "nat list list" where
"sw_A = map snd as"
fun s_A :: "nat ⇒ 'a list" where
"s_A 0 = s0" |
"s_A(Suc n) = step (s_A n) (rs!n) (mtf_A!n, sw_A!n)"
lemma length_s_A[simp]: "length(s_A n) = length s0"
apply (induction n)
(*goals:
1. ‹length (s_A 0) = length s0›
2. ‹⋀n. length (s_A n) = length s0 ⟹ length (s_A (Suc n)) = length s0›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
lemma dist_s_A[simp]: "distinct(s_A n)"
apply (induction n)
(*goals:
1. ‹distinct (s_A (0::nat))›
2. ‹⋀n::nat. distinct (s_A n) ⟹ distinct (s_A (Suc n))›
discuss goal 1*)
apply (simp add: step_def (*‹step ?s ?r ?a = (let (k, sws) = ?a in mtf2 k ?r (swaps sws ?s))›*))
(*discuss goal 2*)
apply (simp add: step_def (*‹step ?s ?r ?a = (let (k, sws) = ?a in mtf2 k ?r (swaps sws ?s))›*))
(*proven 2 subgoals*) .
lemma set_s_A[simp]: "set(s_A n) = set s0"
apply (induction n)
(*goals:
1. ‹set (s_A 0) = set s0›
2. ‹⋀n. set (s_A n) = set s0 ⟹ set (s_A (Suc n)) = set s0›
discuss goal 1*)
apply (simp add: step_def (*‹step ?s ?r ?a = (let (k, sws) = ?a in mtf2 k ?r (swaps sws ?s))›*))
(*discuss goal 2*)
apply (simp add: step_def (*‹step ?s ?r ?a = (let (k, sws) = ?a in mtf2 k ?r (swaps sws ?s))›*))
(*proven 2 subgoals*) .
fun s_mtf :: "nat ⇒ 'a list" where
"s_mtf 0 = s0" |
"s_mtf (Suc n) = mtf (rs!n) (s_mtf n)"
definition t_mtf :: "nat ⇒ int" where
"t_mtf n = index (s_mtf n) (rs!n) + 1"
definition T_mtf :: "nat ⇒ int" where
"T_mtf n = (∑i<n. t_mtf i)"
definition c_A :: "nat ⇒ int" where
"c_A n = index (swaps (sw_A!n) (s_A n)) (rs!n) + 1"
definition f_A :: "nat ⇒ int" where
"f_A n = min (mtf_A!n) (index (swaps (sw_A!n) (s_A n)) (rs!n))"
definition p_A :: "nat ⇒ int" where
"p_A n = size(sw_A!n)"
definition t_A :: "nat ⇒ int" where
"t_A n = c_A n + p_A n"
definition T_A :: "nat ⇒ int" where
"T_A n = (∑i<n. t_A i)"
lemma length_s_mtf[simp]: "length(s_mtf n) = length s0"
apply (induction n)
(*goals:
1. ‹length (s_mtf 0) = length s0›
2. ‹⋀n. length (s_mtf n) = length s0 ⟹ length (s_mtf (Suc n)) = length s0›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
lemma dist_s_mtf[simp]: "distinct(s_mtf n)"
apply (induction n)
(*goals:
1. ‹distinct (s_mtf (0::nat))›
2. ‹⋀n::nat. distinct (s_mtf n) ⟹ distinct (s_mtf (Suc n))›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (auto simp: mtf_def (*‹mtf ?x ?xs = (if ?x ∈ set ?xs then ?x # take (index ?xs ?x) ?xs @ drop (index ?xs ?x + 1) ?xs else ?xs)›*) index_take (*‹?i ≤ index ?xs ?x ⟹ ?x ∉ set (take ?i ?xs)›*) set_drop_if_index (*‹⟦distinct ?xs; index ?xs ?x < ?i⟧ ⟹ ?x ∉ set (drop ?i ?xs)›*))
(*goal: ‹⋀n. distinct (s_mtf n) ⟹ distinct (s_mtf (Suc n))›*)
apply (metis set_drop_if_index (*‹⟦distinct ?xs; index ?xs ?x < ?i⟧ ⟹ ?x ∉ set (drop ?i ?xs)›*) index_take (*‹?i ≤ index ?xs ?x ⟹ ?x ∉ set (take ?i ?xs)›*) less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*) linear (*‹?x ≤ ?y ∨ ?y ≤ ?x›*))
(*proven 2 subgoals*) .
lemma set_s_mtf[simp]: "set (s_mtf n) = set s0"
apply (induction n)
(*goals:
1. ‹set (s_mtf 0) = set s0›
2. ‹⋀n. set (s_mtf n) = set s0 ⟹ set (s_mtf (Suc n)) = set s0›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
lemma dperm_inv: "dist_perm (s_A n) (s_mtf n)"
by (metis dist_s_mtf (*‹distinct (s_mtf ?n)›*) dist_s_A (*‹distinct (s_A ?n)›*) set_s_mtf (*‹set (s_mtf ?n) = set s0›*) set_s_A (*‹set (s_A ?n) = set s0›*))
definition Phi :: "nat ⇒ int" ("Φ") where
"Phi n = card(Inv (s_A n) (s_mtf n))"
lemma phi0: "Phi 0 = 0"
by (simp add: Phi_def (*‹Φ ?n = int (card (Inv (s_A ?n) (s_mtf ?n)))›*))
lemma phi_pos: "Phi n ≥ 0"
by (simp add: Phi_def (*‹Φ ?n = int (card (Inv (s_A ?n) (s_mtf ?n)))›*))
lemma mtf_ub: "t_mtf n + Phi (n+1) - Phi n ≤ 2 * c_A n - 1 + p_A n - f_A n"
proof (-)
(*goal: ‹t_mtf (n::nat) + Φ (n + (1::nat)) - Φ n ≤ (2::int) * c_A n - (1::int) + p_A n - f_A n›*)
let ?xs = "s_A n"
let ?ys = "s_mtf n"
let ?x = "rs!n"
let ?xs' = "swaps (sw_A!n) ?xs"
let ?ys' = "mtf ?x ?ys"
show "?thesis"
(*goal: ‹t_mtf (n::nat) + Φ (n + (1::nat)) - Φ n ≤ (2::int) * c_A n - (1::int) + p_A n - f_A n›*)
proof (cases)
(*goals:
1. ‹?P ⟹ t_mtf n + Φ (n + 1) - Φ n ≤ 2 * c_A n - 1 + p_A n - f_A n›
2. ‹¬ ?P ⟹ t_mtf n + Φ (n + 1) - Φ n ≤ 2 * c_A n - 1 + p_A n - f_A n›*)
assume xin: "?x ∈ set ?ys" (*‹(rs::'a list) ! (n::nat) ∈ set (s_mtf n)›*)
let ?bb = "before ?x ?xs ∩ before ?x ?ys"
let ?ab = "after ?x ?xs ∩ before ?x ?ys"
have phi_mtf: "card(Inv ?xs' ?ys') - int(card (Inv ?xs' ?ys))
≤ 2 * int(index ?xs' ?x) - int(card (before ?x ?ys))"
using xin (*‹(rs::'a list) ! (n::nat) ∈ set (s_mtf n)›*) by (simp add: Inv_mtf (*‹⟦set ?xs = set ?ys; ?z ∈ set ?ys⟧ ⟹ Inv ?xs (mtf ?z ?ys) = Inv ?xs ?ys ∪ {(x, ?z) |x. x < ?z in ?xs ∧ x < ?z in ?ys} - {(?z, x) |x. ?z < x in ?xs ∧ x < ?z in ?ys}›*) phi_diff_aux (*‹int (card (Inv ?xs ?ys ∪ {(y, ?x) |y. y < ?x in ?xs ∧ y < ?x in ?ys} - {(?x, y) |y. ?x < y in ?xs ∧ y < ?x in ?ys})) = int (card (Inv ?xs ?ys) + card (before ?x ?xs ∩ before ?x ?ys)) - int (card (after ?x ?xs ∩ before ?x ?ys))›*) amor_mtf_ub (*‹⟦?x ∈ set ?ys; set ?xs = set ?ys⟧ ⟹ int (card (before ?x ?xs ∩ before ?x ?ys)) - int (card (after ?x ?xs ∩ before ?x ?ys)) ≤ 2 * int (index ?xs ?x) - int (card (before ?x ?ys))›*))
have phi_sw: "card(Inv ?xs' ?ys) ≤ Phi n + length(sw_A!n)"
proof (-)
(*goal: ‹int (card (Inv (swaps (sw_A ! n) (s_A n)) (s_mtf n))) ≤ Φ n + int (length (sw_A ! n))›*)
have "int(card (Inv ?xs' ?ys)) ≤ card(Inv ?xs' ?xs) + int(card(Inv ?xs ?ys))"
using card_Inv_tri_ineq[of ?xs' ?xs ?ys] (*‹⟦dist_perm (swaps (sw_A ! n) (s_A n)) (s_A n); dist_perm (s_A n) (s_mtf n)⟧ ⟹ card (Inv (swaps (sw_A ! n) (s_A n)) (s_mtf n)) ≤ card (Inv (swaps (sw_A ! n) (s_A n)) (s_A n)) + card (Inv (s_A n) (s_mtf n))›*) xin (*‹rs ! n ∈ set (s_mtf n)›*) by simp
also (*calculation: ‹int (card (Inv (swaps (sw_A ! n) (s_A n)) (s_mtf n))) ≤ int (card (Inv (swaps (sw_A ! n) (s_A n)) (s_A n))) + int (card (Inv (s_A n) (s_mtf n)))›*) have "card(Inv ?xs' ?xs) = card(Inv ?xs ?xs')"
by (rule card_Inv_sym (*‹card (Inv ?xs ?ys) = card (Inv ?ys ?xs)›*))
also (*calculation: ‹int (card (Inv (swaps (sw_A ! n) (s_A n)) (s_mtf n))) ≤ int (card (Inv (s_A n) (swaps (sw_A ! n) (s_A n)))) + int (card (Inv (s_A n) (s_mtf n)))›*) have "card(Inv ?xs ?xs') ≤ size(sw_A!n)"
by (metis card_Inv_swaps_le (*‹distinct ?xs ⟹ card (Inv ?xs (swaps ?sws ?xs)) ≤ length ?sws›*) dist_s_A (*‹distinct (s_A ?n)›*))
finally (*calculation: ‹(⋀x y. x ≤ y ⟹ int x + int (card (Inv (s_A n) (s_mtf n))) ≤ int y + int (card (Inv (s_A n) (s_mtf n)))) ⟹ int (card (Inv (swaps (sw_A ! n) (s_A n)) (s_mtf n))) ≤ int (length (sw_A ! n)) + int (card (Inv (s_A n) (s_mtf n)))›*) show "?thesis"
(*goal: ‹int (card (Inv (swaps (sw_A ! n) (s_A n)) (s_mtf n))) ≤ Φ n + int (length (sw_A ! n))›*)
by (fastforce simp: Phi_def (*‹Φ ?n = int (card (Inv (s_A ?n) (s_mtf ?n)))›*))
qed
have phi_free: "card(Inv ?xs' ?ys') - Phi (Suc n) = f_A n"
using xin (*‹rs ! n ∈ set (s_mtf n)›*) by (simp add: Phi_def (*‹Φ ?n = int (card (Inv (s_A ?n) (s_mtf ?n)))›*) mtf2_def (*‹mtf2 ?n ?x ?xs = (if ?x ∈ set ?xs then swaps [index ?xs ?x - ?n..<index ?xs ?x] ?xs else ?xs)›*) step_def (*‹step ?s ?r ?a = (let (k, sws) = ?a in mtf2 k ?r (swaps sws ?s))›*) card_Inv_mtf2 (*‹⟦?xs ! ?j = ?ys ! 0; ?j < length ?xs; dist_perm ?xs ?ys⟧ ⟹ int (card (Inv (swaps [?i..<?j] ?xs) ?ys)) = int (card (Inv ?xs ?ys)) - int (?j - ?i)›*) index_less_size_conv (*‹(index ?xs ?x < length ?xs) = (?x ∈ set ?xs)›*) f_A_def (*‹f_A ?n = int (min (mtf_A ! ?n) (index (swaps (sw_A ! ?n) (s_A ?n)) (rs ! ?n)))›*))
show "?thesis"
(*goal: ‹t_mtf n + Φ (n + 1) - Φ n ≤ 2 * c_A n - 1 + p_A n - f_A n›*)
using xin (*‹rs ! n ∈ set (s_mtf n)›*) phi_sw (*‹int (card (Inv (swaps (sw_A ! n) (s_A n)) (s_mtf n))) ≤ Φ n + int (length (sw_A ! n))›*) phi_mtf (*‹int (card (Inv (swaps (sw_A ! n) (s_A n)) (mtf (rs ! n) (s_mtf n)))) - int (card (Inv (swaps (sw_A ! n) (s_A n)) (s_mtf n))) ≤ 2 * int (index (swaps (sw_A ! n) (s_A n)) (rs ! n)) - int (card (before (rs ! n) (s_mtf n)))›*) phi_free (*‹int (card (Inv (swaps (sw_A ! n) (s_A n)) (mtf (rs ! n) (s_mtf n)))) - Φ (Suc n) = f_A n›*) card_before[of "s_mtf n"] (*‹⟦distinct (s_mtf (n::nat)); (?x::'a) ∈ set (s_mtf n)⟧ ⟹ card (before ?x (s_mtf n)) = index (s_mtf n) ?x›*) by (simp add: t_mtf_def (*‹t_mtf ?n = int (index (s_mtf ?n) (rs ! ?n) + 1)›*) c_A_def (*‹c_A ?n = int (index (swaps (sw_A ! ?n) (s_A ?n)) (rs ! ?n) + 1)›*) p_A_def (*‹p_A ?n = int (length (sw_A ! ?n))›*))
next
(*goal: ‹(rs::'a list) ! (n::nat) ∉ set (s_mtf n) ⟹ t_mtf n + Φ (n + (1::nat)) - Φ n ≤ (2::int) * c_A n - (1::int) + p_A n - f_A n›*)
assume notin: "?x ∉ set ?ys" (*‹(rs::'a list) ! (n::nat) ∉ set (s_mtf n)›*)
have "int (card (Inv ?xs' ?ys)) - card (Inv ?xs ?ys) ≤ card(Inv ?xs ?xs')"
using card_Inv_tri_ineq[OF _ dperm_inv, of ?xs' n] (*‹dist_perm (swaps (sw_A ! n) (s_A n)) (s_A n) ⟹ card (Inv (swaps (sw_A ! n) (s_A n)) (s_mtf n)) ≤ card (Inv (swaps (sw_A ! n) (s_A n)) (s_A n)) + card (Inv (s_A n) (s_mtf n))›*) swaps_inv[of "sw_A!n" "s_A n"] (*‹set (swaps (sw_A ! n) (s_A n)) = set (s_A n) ∧ length (swaps (sw_A ! n) (s_A n)) = length (s_A n) ∧ distinct (swaps (sw_A ! n) (s_A n)) = distinct (s_A n)›*) by (simp add: card_Inv_sym (*‹card (Inv (?xs::?'a list) (?ys::?'a list)) = card (Inv ?ys ?xs)›*))
also (*calculation: ‹int (card (Inv (swaps (sw_A ! n) (s_A n)) (s_mtf n))) - int (card (Inv (s_A n) (s_mtf n))) ≤ int (card (Inv (s_A n) (swaps (sw_A ! n) (s_A n))))›*) have "… ≤ size(sw_A!n)"
by (simp add: card_Inv_swaps_le (*‹distinct ?xs ⟹ card (Inv ?xs (swaps ?sws ?xs)) ≤ length ?sws›*) dperm_inv (*‹dist_perm (s_A ?n) (s_mtf ?n)›*))
finally (*calculation: ‹int (card (Inv (swaps (sw_A ! (n::nat)) (s_A n)) (s_mtf n))) - int (card (Inv (s_A n) (s_mtf n))) ≤ int (length (sw_A ! n))›*) show "?thesis"
(*goal: ‹t_mtf (n::nat) + Φ (n + (1::nat)) - Φ n ≤ (2::int) * c_A n - (1::int) + p_A n - f_A n›*)
using notin (*‹rs ! n ∉ set (s_mtf n)›*) by (simp add: t_mtf_def (*‹t_mtf ?n = int (index (s_mtf ?n) (rs ! ?n) + 1)›*) step_def (*‹step ?s ?r ?a = (let (k, sws) = ?a in mtf2 k ?r (swaps sws ?s))›*) c_A_def (*‹c_A ?n = int (index (swaps (sw_A ! ?n) (s_A ?n)) (rs ! ?n) + 1)›*) p_A_def (*‹p_A ?n = int (length (sw_A ! ?n))›*) f_A_def (*‹f_A ?n = int (min (mtf_A ! ?n) (index (swaps (sw_A ! ?n) (s_A ?n)) (rs ! ?n)))›*) Phi_def (*‹Φ ?n = int (card (Inv (s_A ?n) (s_mtf ?n)))›*) mtf2_def (*‹mtf2 ?n ?x ?xs = (if ?x ∈ set ?xs then swaps [index ?xs ?x - ?n..<index ?xs ?x] ?xs else ?xs)›*))
qed
qed
theorem Sleator_Tarjan: "T_mtf n ≤ (∑i<n. 2*c_A i + p_A i - f_A i) - n"
proof (-)
(*goal: ‹T_mtf n ≤ (∑i<n. 2 * c_A i + p_A i - f_A i) - int n›*)
have "(∑i<n. t_mtf i) ≤ (∑i<n. 2*c_A i - 1 + p_A i - f_A i)"
by (rule potential[where p=Phi,OF phi0 phi_pos mtf_ub] (*‹sum t_mtf {..<?n} ≤ (∑i<?n. 2 * c_A i - 1 + p_A i - f_A i)›*))
also (*calculation: ‹sum t_mtf {..<n} ≤ (∑i<n. 2 * c_A i - 1 + p_A i - f_A i)›*) have "… = (∑i<n. (2*c_A i + p_A i - f_A i) - 1)"
by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*))
also (*calculation: ‹sum t_mtf {..<n} ≤ (∑i<n. 2 * c_A i + p_A i - f_A i - 1)›*) have "… = (∑i<n. 2*c_A i + p_A i - f_A i) - n"
by (simp add: sumr_diff_mult_const2[symmetric] (*‹(∑i::nat<?n::nat. (?f::nat ⇒ ?'a) i - (?r::?'a)) = sum ?f {..<?n} - of_nat ?n * ?r›*))
finally (*calculation: ‹sum t_mtf {..<n} ≤ (∑i<n. 2 * c_A i + p_A i - f_A i) - int n›*) show "?thesis"
(*goal: ‹T_mtf (n::nat) ≤ (∑i::nat<n. (2::int) * c_A i + p_A i - f_A i) - int n›*)
by (simp add: T_mtf_def (*‹T_mtf ?n = sum t_mtf {..<?n}›*))
qed
corollary Sleator_Tarjan': "T_mtf n ≤ 2*T_A n - n"
proof (-)
(*goal: ‹T_mtf n ≤ 2 * T_A n - int n›*)
have "T_mtf n ≤ (∑i<n. 2*c_A i + p_A i - f_A i) - n"
by (fact Sleator_Tarjan (*‹T_mtf ?n ≤ (∑i<?n. 2 * c_A i + p_A i - f_A i) - int ?n›*))
also (*calculation: ‹T_mtf n ≤ (∑i<n. 2 * c_A i + p_A i - f_A i) - int n›*) have "(∑i<n. 2*c_A i + p_A i - f_A i) ≤ (∑i<n. 2*(c_A i + p_A i))"
apply (intro sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*))
(*goal: ‹(∑i::nat<n::nat. (2::int) * c_A i + p_A i - f_A i) ≤ (∑i::nat<n. (2::int) * (c_A i + p_A i))›*)
by (simp add: p_A_def (*‹p_A ?n = int (length (sw_A ! ?n))›*) f_A_def (*‹f_A ?n = int (min (mtf_A ! ?n) (index (swaps (sw_A ! ?n) (s_A ?n)) (rs ! ?n)))›*))
also (*calculation: ‹(⋀x y. x ≤ y ⟹ x - int n ≤ y - int n) ⟹ T_mtf n ≤ (∑i<n. 2 * (c_A i + p_A i)) - int n›*) have "… ≤ 2* T_A n"
by (simp add: sum_distrib_left (*‹(?r::?'a::semiring_0) * sum (?f::?'b::type ⇒ ?'a::semiring_0) (?A::?'b::type set) = (∑n::?'b::type∈?A. ?r * ?f n)›*) T_A_def (*‹T_A (?n::nat) = sum t_A {..<?n}›*) t_A_def (*‹t_A (?n::nat) = c_A ?n + p_A ?n›*))
finally (*calculation: ‹⟦⋀x y. x ≤ y ⟹ x - int n ≤ y - int n; ⋀x y. x ≤ y ⟹ x - int n ≤ y - int n⟧ ⟹ T_mtf n ≤ 2 * T_A n - int n›*) show "T_mtf n ≤ 2* T_A n - n"
by auto
qed
lemma T_A_nneg: "0 ≤ T_A n"
by (auto simp add: sum_nonneg (*‹(⋀x::?'b::type. x ∈ (?A::?'b::type set) ⟹ (0::?'a::ordered_comm_monoid_add) ≤ (?f::?'b::type ⇒ ?'a::ordered_comm_monoid_add) x) ⟹ (0::?'a::ordered_comm_monoid_add) ≤ sum ?f ?A›*) T_A_def (*‹T_A (?n::nat) = sum t_A {..<?n}›*) t_A_def (*‹t_A (?n::nat) = c_A ?n + p_A ?n›*) c_A_def (*‹c_A (?n::nat) = int (index (swaps (sw_A ! ?n) (s_A ?n)) ((rs::'a::type list) ! ?n) + (1::nat))›*) p_A_def (*‹p_A (?n::nat) = int (length (sw_A ! ?n))›*))
lemma T_mtf_ub: "∀i<n. rs!i ∈ set s0 ⟹ T_mtf n ≤ n * size s0"
proof (induction n)
(*goals:
1. ‹∀i<0::nat. (rs::'a::type list) ! i ∈ set (s0::'a::type list) ⟹ T_mtf (0::nat) ≤ int ((0::nat) * length s0)›
2. ‹⋀n::nat. ⟦∀i<n. (rs::'a::type list) ! i ∈ set (s0::'a::type list) ⟹ T_mtf n ≤ int (n * length s0); ∀i<Suc n. rs ! i ∈ set s0⟧ ⟹ T_mtf (Suc n) ≤ int (Suc n * length s0)›*)
case 0 (*‹∀i<0. rs ! i ∈ set s0›*)
show "?case"
(*goal: ‹T_mtf 0 ≤ int (0 * length s0)›*)
by (simp add: T_mtf_def (*‹T_mtf (?n::nat) = sum t_mtf {..<?n}›*))
next
(*goal: ‹⋀n. ⟦∀i<n. rs ! i ∈ set s0 ⟹ T_mtf n ≤ int (n * length s0); ∀i<Suc n. rs ! i ∈ set s0⟧ ⟹ T_mtf (Suc n) ≤ int (Suc n * length s0)›*)
case (Suc n) (*‹∀i<n. rs ! i ∈ set s0 ⟹ T_mtf n ≤ int (n * length s0)› ‹∀i<Suc n. rs ! i ∈ set s0›*)
thus "?case"
(*goal: ‹T_mtf (Suc n) ≤ int (Suc n * length s0)›*)
using index_less_size_conv[of "s_mtf n" "rs!n"] (*‹(index (s_mtf n) (rs ! n) < length (s_mtf n)) = (rs ! n ∈ set (s_mtf n))›*) by (simp add: T_mtf_def (*‹T_mtf ?n = sum t_mtf {..<?n}›*) t_mtf_def (*‹t_mtf ?n = int (index (s_mtf ?n) (rs ! ?n) + 1)›*) less_Suc_eq (*‹(?m < Suc ?n) = (?m < ?n ∨ ?m = ?n)›*) del: index_less (*‹⟦?x ∈ set ?xs; length ?xs ≤ ?n⟧ ⟹ index ?xs ?x < ?n›*))
qed
corollary T_mtf_competitive: assumes "s0 ≠ []" and "∀i<n. rs!i ∈ set s0"
shows "T_mtf n ≤ (2 - 1/(size s0)) * T_A n"
proof (cases)
(*goals:
1. ‹?P::bool ⟹ real_of_int (T_mtf (n::nat)) ≤ ((2::real) - (1::real) / real (length (s0::'a::type list))) * real_of_int (T_A n)›
2. ‹¬ (?P::bool) ⟹ real_of_int (T_mtf (n::nat)) ≤ ((2::real) - (1::real) / real (length (s0::'a::type list))) * real_of_int (T_A n)›*)
assume 0: "real_of_int(T_A n) ≤ n * (size s0)" (*‹real_of_int (T_A (n::nat)) ≤ real (n * length (s0::'a list))›*)
have "T_mtf n ≤ 2 * T_A n - n"
proof (-)
(*goal: ‹T_mtf n ≤ 2 * T_A n - int n›*)
have "T_mtf n ≤ (∑i<n. 2*c_A i + p_A i - f_A i) - n"
by (rule Sleator_Tarjan (*‹T_mtf (?n::nat) ≤ (∑i::nat<?n. (2::int) * c_A i + p_A i - f_A i) - int ?n›*))
also (*calculation: ‹T_mtf n ≤ (∑i<n. 2 * c_A i + p_A i - f_A i) - int n›*) have "(∑i<n. 2*c_A i + p_A i - f_A i) ≤ (∑i<n. 2*(c_A i + p_A i))"
apply (intro sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*))
(*goal: ‹(∑i<n. 2 * c_A i + p_A i - f_A i) ≤ (∑i<n. 2 * (c_A i + p_A i))›*)
by (simp add: p_A_def (*‹p_A ?n = int (length (sw_A ! ?n))›*) f_A_def (*‹f_A ?n = int (min (mtf_A ! ?n) (index (swaps (sw_A ! ?n) (s_A ?n)) (rs ! ?n)))›*))
also (*calculation: ‹(⋀x y. x ≤ y ⟹ x - int n ≤ y - int n) ⟹ T_mtf n ≤ (∑i<n. 2 * (c_A i + p_A i)) - int n›*) have "… ≤ 2 * T_A n"
by (simp add: sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*) T_A_def (*‹T_A ?n = sum t_A {..<?n}›*) t_A_def (*‹t_A ?n = c_A ?n + p_A ?n›*))
finally (*calculation: ‹⟦⋀x y. x ≤ y ⟹ x - int n ≤ y - int n; ⋀x y. x ≤ y ⟹ x - int n ≤ y - int n⟧ ⟹ T_mtf n ≤ 2 * T_A n - int n›*) show "?thesis"
(*goal: ‹T_mtf n ≤ 2 * T_A n - int n›*)
by simp
qed
hence "real_of_int(T_mtf n) ≤ 2 * of_int(T_A n) - n"
by simp
also (*calculation: ‹real_of_int (T_mtf n) ≤ real_of_int (2 * of_int (T_A n) - int n)›*) have "… = 2 * of_int(T_A n) - (n * size s0) / size s0"
using assms(1) (*‹s0 ≠ []›*) by simp
also (*calculation: ‹real_of_int (T_mtf (n::nat)) ≤ (2::real) * real_of_int (T_A n) - real (n * length (s0::'a list)) / real (length s0)›*) have "… ≤ 2 * real_of_int(T_A n) - T_A n / size s0"
apply (rule diff_left_mono[OF divide_right_mono[OF 0]] (*‹0 ≤ ?c1 ⟹ ?c - real (n * length s0) / ?c1 ≤ ?c - real_of_int (T_A n) / ?c1›*))
(*goal: ‹2 * real_of_int (T_A n) - real (n * length s0) / real (length s0) ≤ 2 * real_of_int (T_A n) - real_of_int (T_A n) / real (length s0)›*)
by simp
also (*calculation: ‹real_of_int (T_mtf n) ≤ 2 * real_of_int (T_A n) - real_of_int (T_A n) / real (length s0)›*) have "… = (2 - 1 / size s0) * T_A n"
by algebra
finally (*calculation: ‹real_of_int (T_mtf n) ≤ (2 - 1 / real (length s0)) * real_of_int (T_A n)›*) show "?thesis"
(*goal: ‹real_of_int (T_mtf n) ≤ (2 - 1 / real (length s0)) * real_of_int (T_A n)›*) .
next
(*goal: ‹¬ real_of_int (T_A n) ≤ real (n * length s0) ⟹ real_of_int (T_mtf n) ≤ (2 - 1 / real (length s0)) * real_of_int (T_A n)›*)
assume 0: "¬ real_of_int(T_A n) ≤ n * (size s0)" (*‹¬ real_of_int (T_A (n::nat)) ≤ real (n * length (s0::'a list))›*)
have "2 - 1 / size s0 ≥ 1"
using assms(1) (*‹s0 ≠ []›*) by (auto simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*))
have "real_of_int (T_mtf n) ≤ n * size s0"
using T_mtf_ub[OF assms ( 2 )] (*‹T_mtf n ≤ int (n * length s0)›*) by linarith
also (*calculation: ‹real_of_int (T_mtf n) ≤ real (n * length s0)›*) have "… < of_int(T_A n)"
using "0" (*‹¬ real_of_int (T_A (n::nat)) ≤ real (n * length (s0::'a list))›*) by simp
also (*calculation: ‹real_of_int (T_mtf n) < real_of_int (T_A n)›*) have "… ≤ (2 - 1 / size s0) * T_A n"
using assms(1) (*‹s0 ≠ []›*) T_A_nneg[of n] (*‹0 ≤ T_A n›*) by (auto simp add: mult_le_cancel_right1 (*‹(?c ≤ ?b * ?c) = ((0 < ?c ⟶ 1 ≤ ?b) ∧ (?c < 0 ⟶ ?b ≤ 1))›*) field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*))
finally (*calculation: ‹real_of_int (T_mtf n) < (2 - 1 / real (length s0)) * real_of_int (T_A n)›*) show "?thesis"
(*goal: ‹real_of_int (T_mtf n) ≤ (2 - 1 / real (length s0)) * real_of_int (T_A n)›*)
by linarith
qed
lemma t_A_t: "n < length rs ⟹ t_A n = int (t (s_A n) (rs ! n) (as ! n))"
by (simp add: t_A_def (*‹t_A ?n = c_A ?n + p_A ?n›*) t_def (*‹t ?s ?r ?a = (let (mf, sws) = ?a in index (swaps sws ?s) ?r + 1 + length sws)›*) c_A_def (*‹c_A ?n = int (index (swaps (sw_A ! ?n) (s_A ?n)) (rs ! ?n) + 1)›*) p_A_def (*‹p_A ?n = int (length (sw_A ! ?n))›*) sw_A_def (*‹sw_A = map snd as›*) len_as (*‹length as = length rs›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))
lemma T_A_eq_lem: "(∑i=0..<length rs. t_A i) =
T (s_A 0) (drop 0 rs) (drop 0 as)"
proof (induction rule: zero_induct[of _ "size rs"] (*‹⟦?P (length rs); ⋀n. ?P (Suc n) ⟹ ?P n⟧ ⟹ ?P 0›*))
(*goals:
1. ‹sum t_A {length rs..<length rs} = int (T (s_A (length rs)) (drop (length rs) rs) (drop (length rs) as))›
2. ‹⋀n. sum t_A {Suc n..<length rs} = int (T (s_A (Suc n)) (drop (Suc n) rs) (drop (Suc n) as)) ⟹ sum t_A {n..<length rs} = int (T (s_A n) (drop n rs) (drop n as))›*)
case 1 (*no hyothesis introduced yet*)
thus "?case"
(*goal: ‹sum t_A {length rs..<length rs} = int (T (s_A (length rs)) (drop (length rs) rs) (drop (length rs) as))›*)
by (simp add: len_as (*‹length as = length rs›*))
next
(*goal: ‹⋀n. sum t_A {Suc n..<length rs} = int (T (s_A (Suc n)) (drop (Suc n) rs) (drop (Suc n) as)) ⟹ sum t_A {n..<length rs} = int (T (s_A n) (drop n rs) (drop n as))›*)
case (2 n) (*‹sum t_A {Suc n..<length rs} = int (T (s_A (Suc n)) (drop (Suc n) rs) (drop (Suc n) as))›*)
show "?case"
(*goal: ‹sum t_A {n..<length rs} = int (T (s_A n) (drop n rs) (drop n as))›*)
proof (cases)
(*goals:
1. ‹?P ⟹ sum t_A {n..<length rs} = int (T (s_A n) (drop n rs) (drop n as))›
2. ‹¬ ?P ⟹ sum t_A {n..<length rs} = int (T (s_A n) (drop n rs) (drop n as))›*)
assume "n < length rs" (*‹(n::nat) < length (rs::'a list)›*)
thus "?case"
(*goal: ‹sum t_A {n..<length rs} = int (T (s_A n) (drop n rs) (drop n as))›*)
using "2" (*‹sum t_A {Suc (n::nat)..<length (rs::'a::type list)} = int (T (s_A (Suc n)) (drop (Suc n) rs) (drop (Suc n) (as::(nat × nat list) list)))›*) by (simp add: Cons_nth_drop_Suc[symmetric,where i=n] (*‹(n::nat) < length (?xs::?'a list) ⟹ drop n ?xs = ?xs ! n # drop (Suc n) ?xs›*) len_as (*‹length (as::(nat × nat list) list) = length (rs::'a list)›*) sum.atLeast_Suc_lessThan (*‹(?m::nat) < (?n::nat) ⟹ sum (?g::nat ⇒ ?'a) {?m..<?n} = ?g ?m + sum ?g {Suc ?m..<?n}›*) t_A_t (*‹(?n::nat) < length (rs::'a list) ⟹ t_A ?n = int (t (s_A ?n) (rs ! ?n) ((as::(nat × nat list) list) ! ?n))›*) mtf_A_def (*‹mtf_A = map fst (as::(nat × nat list) list)›*) sw_A_def (*‹sw_A = map snd (as::(nat × nat list) list)›*))
next
(*goal: ‹¬ n < length rs ⟹ sum t_A {n..<length rs} = int (T (s_A n) (drop n rs) (drop n as))›*)
assume "¬ n < length rs" (*‹¬ (n::nat) < length (rs::'a list)›*)
thus "?case"
(*goal: ‹sum t_A {n..<length rs} = int (T (s_A n) (drop n rs) (drop n as))›*)
by (simp add: len_as (*‹length (as::(nat × nat list) list) = length (rs::'a list)›*))
qed
qed
lemma T_A_eq: "T_A (length rs) = T s0 rs as"
using T_A_eq_lem (*‹sum t_A {0::nat..<length (rs::'a list)} = int (T (s_A (0::nat)) (drop (0::nat) rs) (drop (0::nat) (as::(nat × nat list) list)))›*) by (simp add: T_A_def (*‹T_A ?n = sum t_A {..<?n}›*) atLeast0LessThan (*‹{0..<?n} = {..<?n}›*))
lemma nth_off_MTF: "n < length rs ⟹ off2 MTF s rs ! n = (size(fst s) - 1,[])"
apply (induction rs arbitrary: s n)
(*goals:
1. ‹⋀s n. n < length [] ⟹ off2 MTF s [] ! n = (length (fst s) - 1, [])›
2. ‹⋀a rs s n. ⟦⋀s n. n < length rs ⟹ off2 MTF s rs ! n = (length (fst s) - 1, []); n < length (a # rs)⟧ ⟹ off2 MTF s (a # rs) ! n = (length (fst s) - 1, [])›
discuss goal 1*)
apply ((auto simp add: MTF_def (*‹MTF = (λ_. (), λs r. ((length (fst s) - 1, []), ()))›*) nth_Cons' (*‹(?x # ?xs) ! ?n = (if ?n = 0 then ?x else ?xs ! (?n - 1))›*) Step_def (*‹Step ?A ?s ?r = (let (a, is') = snd ?A ?s ?r in (step (fst ?s) ?r a, is'))›*))[1])
(*discuss goal 2*)
apply ((auto simp add: MTF_def (*‹MTF = (λ_::?'a::type list. (), λ(s::?'a::type list × unit) r::?'a::type. ((length (fst s) - (1::nat), []), ()))›*) nth_Cons' (*‹((?x::?'a::type) # (?xs::?'a::type list)) ! (?n::nat) = (if ?n = (0::nat) then ?x else ?xs ! (?n - (1::nat)))›*) Step_def (*‹Step (?A::(?'a::type list ⇒ ?'istate::type) × (?'a::type list × ?'istate::type ⇒ ?'a::type ⇒ (nat × nat list) × ?'istate::type)) (?s::?'a::type list × ?'istate::type) (?r::?'a::type) = (let (a::nat × nat list, is'::?'istate::type) = snd ?A ?s ?r in (step (fst ?s) ?r a, is'))›*))[1])
(*proven 2 subgoals*) .
lemma t_mtf_MTF: "n < length rs ⟹
t_mtf n = int (t (s_mtf n) (rs ! n) (off MTF s rs ! n))"
by (simp add: t_mtf_def (*‹t_mtf ?n = int (index (s_mtf ?n) (rs ! ?n) + 1)›*) t_def (*‹t ?s ?r ?a = (let (mf, sws) = ?a in index (swaps sws ?s) ?r + 1 + length sws)›*) nth_off_MTF (*‹?n < length rs ⟹ off2 MTF ?s rs ! ?n = (length (fst ?s) - 1, [])›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))
lemma mtf_MTF: "n < length rs ⟹ length s = length s0 ⟹ mtf (rs ! n) s =
step s (rs ! n) (off MTF s0 rs ! n)"
by (auto simp add: nth_off_MTF (*‹?n < length rs ⟹ off2 MTF ?s rs ! ?n = (length (fst ?s) - 1, [])›*) step_def (*‹step ?s ?r ?a = (let (k, sws) = ?a in mtf2 k ?r (swaps sws ?s))›*) mtf_eq_mtf2 (*‹mtf ?x ?xs = mtf2 (length ?xs - 1) ?x ?xs›*))
lemma T_mtf_eq_lem: "(∑i=0..<length rs. t_mtf i) =
T (s_mtf 0) (drop 0 rs) (drop 0 (off MTF s0 rs))"
proof (induction rule: zero_induct[of _ "size rs"] (*‹⟦?P (length rs); ⋀n. ?P (Suc n) ⟹ ?P n⟧ ⟹ ?P 0›*))
(*goals:
1. ‹sum t_mtf {length rs..<length rs} = int (T (s_mtf (length rs)) (drop (length rs) rs) (drop (length rs) (off MTF s0 rs)))›
2. ‹⋀n. sum t_mtf {Suc n..<length rs} = int (T (s_mtf (Suc n)) (drop (Suc n) rs) (drop (Suc n) (off MTF s0 rs))) ⟹ sum t_mtf {n..<length rs} = int (T (s_mtf n) (drop n rs) (drop n (off MTF s0 rs)))›*)
case 1 (*no hyothesis introduced yet*)
thus "?case"
(*goal: ‹sum t_mtf {length rs..<length rs} = int (T (s_mtf (length rs)) (drop (length rs) rs) (drop (length rs) (off MTF s0 rs)))›*)
by (simp add: len_as (*‹length as = length rs›*))
next
(*goal: ‹⋀n. sum t_mtf {Suc n..<length rs} = int (T (s_mtf (Suc n)) (drop (Suc n) rs) (drop (Suc n) (off MTF s0 rs))) ⟹ sum t_mtf {n..<length rs} = int (T (s_mtf n) (drop n rs) (drop n (off MTF s0 rs)))›*)
case (2 n) (*‹sum t_mtf {Suc n..<length rs} = int (T (s_mtf (Suc n)) (drop (Suc n) rs) (drop (Suc n) (off MTF s0 rs)))›*)
show "?case"
(*goal: ‹sum t_mtf {n..<length rs} = int (T (s_mtf n) (drop n rs) (drop n (off MTF s0 rs)))›*)
proof (cases)
(*goals:
1. ‹?P ⟹ sum t_mtf {n..<length rs} = int (T (s_mtf n) (drop n rs) (drop n (off MTF s0 rs)))›
2. ‹¬ ?P ⟹ sum t_mtf {n..<length rs} = int (T (s_mtf n) (drop n rs) (drop n (off MTF s0 rs)))›*)
assume "n < length rs" (*‹(n::nat) < length (rs::'a list)›*)
thus "?case"
(*goal: ‹sum t_mtf {n..<length rs} = int (T (s_mtf n) (drop n rs) (drop n (off MTF s0 rs)))›*)
using "2" (*‹sum t_mtf {Suc n..<length rs} = int (T (s_mtf (Suc n)) (drop (Suc n) rs) (drop (Suc n) (off MTF s0 rs)))›*) by (simp add: Cons_nth_drop_Suc[symmetric,where i=n] (*‹n < length ?xs ⟹ drop n ?xs = ?xs ! n # drop (Suc n) ?xs›*) len_as (*‹length as = length rs›*) sum.atLeast_Suc_lessThan (*‹?m < ?n ⟹ sum ?g {?m..<?n} = ?g ?m + sum ?g {Suc ?m..<?n}›*) t_mtf_MTF[where s=s0] (*‹?n < length rs ⟹ t_mtf ?n = int (t (s_mtf ?n) (rs ! ?n) (off MTF s0 rs ! ?n))›*) mtf_A_def (*‹mtf_A = map fst as›*) sw_A_def (*‹sw_A = map snd as›*) mtf_MTF (*‹⟦?n < length rs; length ?s = length s0⟧ ⟹ mtf (rs ! ?n) ?s = step ?s (rs ! ?n) (off MTF s0 rs ! ?n)›*))
next
(*goal: ‹¬ n < length rs ⟹ sum t_mtf {n..<length rs} = int (T (s_mtf n) (drop n rs) (drop n (off MTF s0 rs)))›*)
assume "¬ n < length rs" (*‹¬ (n::nat) < length (rs::'a list)›*)
thus "?case"
(*goal: ‹sum t_mtf {n..<length rs} = int (T (s_mtf n) (drop n rs) (drop n (off MTF s0 rs)))›*)
by (simp add: len_as (*‹length as = length rs›*))
qed
qed
lemma T_mtf_eq: "T_mtf (length rs) = T_on MTF s0 rs"
using T_mtf_eq_lem (*‹sum t_mtf {0::nat..<length (rs::'a list)} = int (T (s_mtf (0::nat)) (drop (0::nat) rs) (drop (0::nat) (off MTF (s0::'a list) rs)))›*) by (simp add: T_mtf_def (*‹T_mtf ?n = sum t_mtf {..<?n}›*) atLeast0LessThan (*‹{0..<?n} = {..<?n}›*))
corollary MTF_competitive2: "s0 ≠ [] ⟹ ∀i<length rs. rs!i ∈ set s0 ⟹
T_on MTF s0 rs ≤ (2 - 1/(size s0)) * T s0 rs as"
by (metis T_mtf_competitive (*‹⟦s0 ≠ []; ∀i<?n. rs ! i ∈ set s0⟧ ⟹ real_of_int (T_mtf ?n) ≤ (2 - 1 / real (length s0)) * real_of_int (T_A ?n)›*) T_A_eq (*‹T_A (length rs) = int (T s0 rs as)›*) T_mtf_eq (*‹T_mtf (length rs) = int (T_on MTF s0 rs)›*) of_int_of_nat_eq (*‹of_int (int ?n) = of_nat ?n›*))
corollary MTF_competitive': "T_on MTF s0 rs ≤ 2 * T s0 rs as"
using Sleator_Tarjan'[of "length rs"] (*‹T_mtf (length rs) ≤ 2 * T_A (length rs) - int (length rs)›*) T_A_eq (*‹T_A (length rs) = int (T s0 rs as)›*) T_mtf_eq (*‹T_mtf (length rs) = int (T_on MTF s0 rs)›*) by auto
end
theorem compet_MTF: assumes "s0 ≠ []" "distinct s0" "set rs ⊆ set s0"
shows "T_on MTF s0 rs ≤ (2 - 1/(size s0)) * T_opt s0 rs"
proof (-)
(*goal: ‹real (T_on MTF s0 rs) ≤ (2 - 1 / real (length s0)) * real (T_opt s0 rs)›*)
from assms(3) (*‹set (rs::'a list) ⊆ set (s0::'a list)›*) have 1: "∀i < length rs. rs!i ∈ set s0"
by auto
{
fix as :: "answer list"
assume len: "length as = length rs" (*‹length (as::(nat × nat list) list) = length (rs::'a list)›*)
interpret MTF_Off as rs s0
proof (standard)
(*goals:
1. ‹distinct s0›
2. ‹length as = length rs›*)
qed (auto simp: assms( (*‹distinct s0›*) 2) len (*‹length as = length rs›*))
(*solves the remaining goals:
1. ‹distinct s0›
2. ‹length as = length rs›*)
from MTF_competitive2[OF assms ( 1 ) 1] (*‹real (T_on MTF (s0::'a::type list) (rs::'a::type list)) ≤ ((2::real) - (1::real) / real (length s0)) * real (T s0 rs (as::(nat × nat list) list))›*) assms(1) (*‹s0 ≠ []›*) have "T_on MTF s0 rs / (2 - 1 / (length s0)) ≤ of_int(T s0 rs as)"
by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) length_greater_0_conv[symmetric] (*‹(?xs ≠ []) = (0 < length ?xs)›*) del: length_greater_0_conv (*‹(0 < length ?xs) = (?xs ≠ [])›*))
}
hence "T_on MTF s0 rs / (2 - 1/(size s0)) ≤ T_opt s0 rs"
apply (simp add: T_opt_def (*‹T_opt ?s ?rs = ⨅ {T ?s ?rs as |as. length as = length ?rs}›*) Inf_nat_def (*‹⨅ ?X = (LEAST n. n ∈ ?X)›*))
(*goal: ‹real (T_on MTF s0 rs) / (2 - 1 / real (length s0)) ≤ real (T_opt s0 rs)›*)
apply (rule LeastI2_wellorder (*‹⟦(?P::?'a::wellorder ⇒ bool) (?a::?'a::wellorder); ⋀a::?'a::wellorder. ⟦?P a; ∀b::?'a::wellorder. ?P b ⟶ a ≤ b⟧ ⟹ (?Q::?'a::wellorder ⇒ bool) a⟧ ⟹ ?Q (Least ?P)›*))
(*goal: ‹(⋀as. length as = length rs ⟹ real (T s0 rs (off2 MTF (s0, ()) rs)) / (2 - 1 / real (length s0)) ≤ real (T s0 rs as)) ⟹ real (T s0 rs (off2 MTF (s0, ()) rs)) / (2 - 1 / real (length s0)) ≤ real (LEAST n. ∃as. n = T s0 rs as ∧ length as = length rs)›*)
using length_replicate[of "length rs" undefined] (*‹length (replicate (length rs) undefined) = length rs›*)
(*goals:
1. ‹(⋀as. length as = length rs ⟹ real (T s0 rs (off2 MTF (s0, ()) rs)) / (2 - 1 / real (length s0)) ≤ real (T s0 rs as)) ⟹ ∃as. ?a4 = T s0 rs as ∧ length as = length rs›
2. ‹⋀a. ⟦⋀as. length as = length rs ⟹ real (T s0 rs (off2 MTF (s0, ()) rs)) / (2 - 1 / real (length s0)) ≤ real (T s0 rs as); ∃as. a = T s0 rs as ∧ length as = length rs; ∀b. (∃as. b = T s0 rs as ∧ length as = length rs) ⟶ a ≤ b⟧ ⟹ real (T s0 rs (off2 MTF (s0, ()) rs)) / (2 - 1 / real (length s0)) ≤ real a›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply auto
(*proven 2 subgoals*) .
thus "?thesis"
(*goal: ‹real (T_on MTF (s0::'a list) (rs::'a list)) ≤ ((2::real) - (1::real) / real (length s0)) * real (T_opt s0 rs)›*)
using assms (*‹s0 ≠ []› ‹distinct s0› ‹set (rs::'a list) ⊆ set (s0::'a list)›*) by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) length_greater_0_conv[symmetric] (*‹(?xs ≠ []) = (0 < length ?xs)›*) del: length_greater_0_conv (*‹(0 < length ?xs) = (?xs ≠ [])›*))
qed
theorem compet_MTF': assumes "distinct s0"
shows "T_on MTF s0 rs ≤ (2::real) * T_opt s0 rs"
proof (-)
(*goal: ‹real (T_on MTF s0 rs) ≤ 2 * real (T_opt s0 rs)›*)
{
fix as :: "answer list"
assume len: "length as = length rs" (*‹length (as::(nat × nat list) list) = length (rs::'a list)›*)
interpret MTF_Off as rs s0
proof (standard)
(*goals:
1. ‹distinct s0›
2. ‹length as = length rs›*)
qed (auto simp: assms( (*‹distinct s0›*) 1) len (*‹length as = length rs›*))
(*solves the remaining goals:
1. ‹distinct s0›
2. ‹length as = length rs›*)
from MTF_competitive' (*‹T_on MTF s0 rs ≤ 2 * T s0 rs as›*) have "T_on MTF s0 rs / 2 ≤ of_int(T s0 rs as)"
by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) length_greater_0_conv[symmetric] (*‹(?xs ≠ []) = (0 < length ?xs)›*) del: length_greater_0_conv (*‹(0 < length ?xs) = (?xs ≠ [])›*))
}
hence "T_on MTF s0 rs / 2 ≤ T_opt s0 rs"
apply (simp add: T_opt_def (*‹T_opt ?s ?rs = ⨅ {T ?s ?rs as |as. length as = length ?rs}›*) Inf_nat_def (*‹⨅ ?X = (LEAST n. n ∈ ?X)›*))
(*goal: ‹real (T_on MTF s0 rs) / 2 ≤ real (T_opt s0 rs)›*)
apply (rule LeastI2_wellorder (*‹⟦?P ?a; ⋀a. ⟦?P a; ∀b. ?P b ⟶ a ≤ b⟧ ⟹ ?Q a⟧ ⟹ ?Q (Least ?P)›*))
(*goal: ‹(⋀as. length as = length rs ⟹ real (T s0 rs (off2 MTF (s0, ()) rs)) ≤ real (T s0 rs as) * 2) ⟹ real (T s0 rs (off2 MTF (s0, ()) rs)) ≤ real (LEAST n. ∃as. n = T s0 rs as ∧ length as = length rs) * 2›*)
using length_replicate[of "length rs" undefined] (*‹length (replicate (length rs) undefined) = length rs›*)
(*goals:
1. ‹(⋀as. length as = length rs ⟹ real (T s0 rs (off2 MTF (s0, ()) rs)) ≤ real (T s0 rs as) * 2) ⟹ ∃as. ?a4 = T s0 rs as ∧ length as = length rs›
2. ‹⋀a. ⟦⋀as. length as = length rs ⟹ real (T s0 rs (off2 MTF (s0, ()) rs)) ≤ real (T s0 rs as) * 2; ∃as. a = T s0 rs as ∧ length as = length rs; ∀b. (∃as. b = T s0 rs as ∧ length as = length rs) ⟶ a ≤ b⟧ ⟹ real (T s0 rs (off2 MTF (s0, ()) rs)) ≤ real a * 2›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply auto
(*proven 2 subgoals*) .
thus "?thesis"
(*goal: ‹real (T_on MTF s0 rs) ≤ 2 * real (T_opt s0 rs)›*)
using assms (*‹distinct s0›*) by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) length_greater_0_conv[symmetric] (*‹(?xs ≠ []) = (0 < length ?xs)›*) del: length_greater_0_conv (*‹(0 < length ?xs) = (?xs ≠ [])›*))
qed
theorem MTF_is_2_competitive: "compet MTF 2 {s . distinct s}"
unfolding compet_def
(*goal: ‹∀s::'a list∈Collect distinct. ∃b≥0::real. ∀rs::'a list. static s rs ⟶ real (T_on MTF s rs) ≤ (2::real) * real (T_opt s rs) + b›*)
using compet_MTF' (*‹distinct ?s0.0 ⟹ real (T_on MTF ?s0.0 ?rs) ≤ 2 * real (T_opt ?s0.0 ?rs)›*) by fastforce
subsection "Lower Bound for Competitiveness"
text‹This result is independent of MTF
but is based on the list update problem defined in this theory.›
lemma rat_fun_lem:
fixes l c :: real
assumes [simp]: "F ≠ bot"
assumes "0 < l"
assumes ev:
"eventually (λn. l ≤ f n / g n) F"
"eventually (λn. (f n + c) / (g n + d) ≤ u) F"
and
g: "LIM n F. g n :> at_top"
shows "l ≤ u"
proof (rule dense_le_bounded[OF ‹0 < l›] (*‹(⋀w::real. ⟦(0::real) < w; w < (l::real)⟧ ⟹ w ≤ (?z::real)) ⟹ l ≤ ?z›*))
(*goal: ‹⋀w::real. ⟦(0::real) < w; w < (l::real)⟧ ⟹ w ≤ (u::real)›*)
fix x
assume x: "0 < x" "x < l" (*‹(0::real) < (x::real)› ‹(x::real) < (l::real)›*)
define m where "m = (x - l) / 2"
define k where "k = l / (x - m)"
have "x = l / k + m" "1 < k" "m < 0"
unfolding k_def m_def
(*goals:
1. ‹(x::real) = (l::real) / (l / (x - (x - l) / (2::real))) + (x - l) / (2::real)›
2. ‹(1::real) < (l::real) / ((x::real) - (x - l) / (2::real))›
3. ‹((x::real) - (l::real)) / (2::real) < (0::real)›*)
using x (*‹(0::real) < (x::real)› ‹x < l›*) apply -
(*goals:
1. ‹⟦0 < x; x < l⟧ ⟹ x = l / (l / (x - (x - l) / 2)) + (x - l) / 2›
2. ‹⟦0 < x; x < l⟧ ⟹ 1 < l / (x - (x - l) / 2)›
3. ‹⟦0 < x; x < l⟧ ⟹ (x - l) / 2 < 0›
discuss goal 1*)
apply ((auto simp: divide_simps (*‹inverse (?a::?'a) = (1::?'a) / ?a› ‹(?a::?'a) + (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z + ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (?a + ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (- ?a + ?b * ?z) / ?z)› ‹(?a::?'a) - (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z - ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (?a - ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (- ?a - ?b * ?z) / ?z)› ‹((?b::?'a) / (?c::?'a) = (?a::?'a)) = (if ?c ≠ (0::?'a) then ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = (?b::?'a) / (?c::?'a)) = (if ?c ≠ (0::?'a) then ?a * ?c = ?b else ?a = (0::?'a))› ‹(- ((?b::?'a) / (?c::?'a)) = (?a::?'a)) = (if ?c ≠ (0::?'a) then - ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = - ((?b::?'a) / (?c::?'a))) = (if ?c ≠ (0::?'a) then ?a * ?c = - ?b else ?a = (0::?'a))› ‹((?a::?'a) ≤ (?b::?'a) / (?c::?'a)) = (if (0::?'a) < ?c then ?a * ?c ≤ ?b else if ?c < (0::?'a) then ?b ≤ ?a * ?c else ?a ≤ (0::?'a))› and more 13 facts*))[1])
(*discuss goal 2*)
apply ((auto simp: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*))[1])
(*discuss goal 3*)
apply ((auto simp: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*))[1])
(*proven 3 subgoals*) .
from ‹1 < k› (*‹1 < k›*) have "LIM n F. (k - 1) * g n :> at_top"
apply (intro filterlim_tendsto_pos_mult_at_top[OF tendsto_const _ g] (*‹0 < ?c ⟹ LIM x F. ?c * g x :> at_top›*))
(*goal: ‹LIM n F. (k - 1) * g n :> at_top›*)
by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))
then have "eventually (λn. d ≤ (k - 1) * g n) F"
by (simp add: filterlim_at_top (*‹filterlim ?f at_top ?F = (∀Z. ∀⇩F x in ?F. Z ≤ ?f x)›*))
moreover have "eventually (λn. 1 ≤ g n) F" "eventually (λn. 1 - d ≤ g n) F" "eventually (λn. c / m - d ≤ g n) F"
using g (*‹filterlim g at_top F›*) apply -
(*goals:
1. ‹filterlim (g::'a ⇒ real) at_top (F::'a filter) ⟹ ∀⇩F n::'a in F. (1::real) ≤ g n›
2. ‹filterlim (g::'a ⇒ real) at_top (F::'a filter) ⟹ ∀⇩F n::'a in F. (1::real) - (d::real) ≤ g n›
3. ‹filterlim (g::'a ⇒ real) at_top (F::'a filter) ⟹ ∀⇩F n::'a in F. (c::real) / (m::real) - (d::real) ≤ g n›
discuss goal 1*)
apply ((auto simp add: filterlim_at_top (*‹filterlim ?f at_top ?F = (∀Z. ∀⇩F x in ?F. Z ≤ ?f x)›*))[1])
(*discuss goal 2*)
apply ((auto simp add: filterlim_at_top (*‹filterlim ?f at_top ?F = (∀Z. ∀⇩F x in ?F. Z ≤ ?f x)›*))[1])
(*discuss goal 3*)
apply ((auto simp add: filterlim_at_top (*‹filterlim ?f at_top ?F = (∀Z. ∀⇩F x in ?F. Z ≤ ?f x)›*))[1])
(*proven 3 subgoals*) .
ultimately have "eventually (λn. x ≤ u) F"
using ev (*‹∀⇩F n in F. l ≤ f n / g n› ‹∀⇩F n in F. (f n + c) / (g n + d) ≤ u›*) proof (eventually_elim)
(*goal: ‹⋀n. ⟦d ≤ (k - 1) * g n; 1 ≤ g n; 1 - d ≤ g n; c / m - d ≤ g n; l ≤ f n / g n; (f n + c) / (g n + d) ≤ u⟧ ⟹ x ≤ u›*)
fix n
assume d: "d ≤ (k - 1) * g n" "1 ≤ g n" "1 - d ≤ g n" "c / m - d ≤ g n" and l: "l ≤ f n / g n" and u: "(f n + c) / (g n + d) ≤ u" (*‹(d::real) ≤ ((k::real) - (1::real)) * (g::'a ⇒ real) (n::'a)› ‹(1::real) ≤ (g::'a ⇒ real) (n::'a)› ‹(1::real) - (d::real) ≤ (g::'a ⇒ real) (n::'a)› ‹(c::real) / (m::real) - (d::real) ≤ (g::'a ⇒ real) (n::'a)› ‹(l::real) ≤ (f::'a ⇒ real) (n::'a) / (g::'a ⇒ real) n› ‹((f::'a ⇒ real) (n::'a) + (c::real)) / ((g::'a ⇒ real) n + (d::real)) ≤ (u::real)›*)
from d (*‹d ≤ (k - 1) * g n› ‹1 ≤ g n› ‹1 - d ≤ g n› ‹c / m - d ≤ g n›*) have "g n + d ≤ k * g n"
by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))
from d (*‹d ≤ (k - 1) * g n› ‹1 ≤ g n› ‹1 - d ≤ g n› ‹c / m - d ≤ g n›*) have g: "0 < g n" "0 < g n + d"
apply -
(*goals:
1. ‹⟦d ≤ (k - 1) * g n; 1 ≤ g n; 1 - d ≤ g n; c / m - d ≤ g n⟧ ⟹ 0 < g n›
2. ‹⟦d ≤ (k - 1) * g n; 1 ≤ g n; 1 - d ≤ g n; c / m - d ≤ g n⟧ ⟹ 0 < g n + d›
discuss goal 1*)
apply ((auto simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))[1])
(*discuss goal 2*)
apply ((auto simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))[1])
(*proven 2 subgoals*) .
with ‹0 < l› (*‹0 < l›*) l (*‹l ≤ f n / g n›*) have "0 < f n"
by (auto simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) intro: mult_pos_pos (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a * ?b›*) less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*))
note ‹x = l / k + m› (*‹x = l / k + m›*)
also (*calculation: ‹x = l / k + m›*) have "l / k ≤ f n / (k * g n)"
using l (*‹l ≤ f n / g n›*) ‹1 < k› (*‹1 < k›*) by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))
also (*calculation: ‹(⋀x y. x ≤ y ⟹ x + m ≤ y + m) ⟹ x ≤ f n / (k * g n) + m›*) have "… ≤ f n / (g n + d)"
using d (*‹(d::real) ≤ ((k::real) - (1::real)) * (g::'a ⇒ real) (n::'a)› ‹1 ≤ g n› ‹1 - d ≤ g n› ‹c / m - d ≤ g n›*) ‹1 < k› (*‹(1::real) < (k::real)›*) ‹0 < f n› (*‹0 < f n›*) apply (intro divide_left_mono (*‹⟦?b ≤ ?a; 0 ≤ ?c; 0 < ?a * ?b⟧ ⟹ ?c / ?a ≤ ?c / ?b›*) mult_pos_pos (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a * ?b›*))
(*goals:
1. ‹⟦d ≤ (k - 1) * g n; 1 ≤ g n; 1 - d ≤ g n; c / m - d ≤ g n; 1 < k; 0 < f n⟧ ⟹ g n + d ≤ k * g n›
2. ‹⟦d ≤ (k - 1) * g n; 1 ≤ g n; 1 - d ≤ g n; c / m - d ≤ g n; 1 < k; 0 < f n⟧ ⟹ 0 ≤ f n›
3. ‹⟦d ≤ (k - 1) * g n; 1 ≤ g n; 1 - d ≤ g n; c / m - d ≤ g n; 1 < k; 0 < f n⟧ ⟹ 0 < k›
4. ‹⟦d ≤ (k - 1) * g n; 1 ≤ g n; 1 - d ≤ g n; c / m - d ≤ g n; 1 < k; 0 < f n⟧ ⟹ 0 < g n›
5. ‹⟦d ≤ (k - 1) * g n; 1 ≤ g n; 1 - d ≤ g n; c / m - d ≤ g n; 1 < k; 0 < f n⟧ ⟹ 0 < g n + d›
discuss goal 1*)
apply ((auto simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))[1])
(*discuss goal 2*)
apply ((auto simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))[1])
(*discuss goal 3*)
apply ((auto simp: field_simps (*‹(?a::?'a::semigroup_add) + (?b::?'a::semigroup_add) + (?c::?'a::semigroup_add) = ?a + (?b + ?c)› ‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a› ‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)› ‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)› ‹(?a::?'a::ab_semigroup_mult) * (?b::?'a::ab_semigroup_mult) = ?b * ?a› ‹(?b::?'a::ab_semigroup_mult) * ((?a::?'a::ab_semigroup_mult) * (?c::?'a::ab_semigroup_mult)) = ?a * (?b * ?c)› ‹(?a::?'a::cancel_ab_semigroup_add) - (?b::?'a::cancel_ab_semigroup_add) - (?c::?'a::cancel_ab_semigroup_add) = ?a - (?b + ?c)› ‹(?a::?'a::group_add) + ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?b - ?c› ‹((?a::?'a::group_add) - (?b::?'a::group_add) = (?c::?'a::group_add)) = (?a = ?c + ?b)› ‹((?a::?'a::group_add) = (?c::?'a::group_add) - (?b::?'a::group_add)) = (?a + ?b = ?c)› ‹(?a::?'a::group_add) - ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?c - ?b› ‹(?a::?'a::ab_group_add) - (?b::?'a::ab_group_add) + (?c::?'a::ab_group_add) = ?a + ?c - ?b› and more 77 facts*))[1])
(*discuss goal 4*)
apply ((auto simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))[1])
(*discuss goal 5*)
apply ((auto simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))[1])
(*proven 5 subgoals*) .
also (*calculation: ‹⟦⋀x y. x ≤ y ⟹ x + m ≤ y + m; ⋀x y. x ≤ y ⟹ x + m ≤ y + m⟧ ⟹ x ≤ f n / (g n + d) + m›*) have "m ≤ c / (g n + d)"
using ‹c / m - d ≤ g n› (*‹c / m - d ≤ g n›*) ‹0 < g n› (*‹0 < g n›*) ‹0 < g n + d› (*‹(0::real) < (g::'a::type ⇒ real) (n::'a::type) + (d::real)›*) ‹m < 0› (*‹m < 0›*) by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))
also (*calculation: ‹⟦⋀x y. x ≤ y ⟹ x + m ≤ y + m; ⋀x y. x ≤ y ⟹ x + m ≤ y + m; ⋀x y. x ≤ y ⟹ f n / (g n + d) + x ≤ f n / (g n + d) + y⟧ ⟹ x ≤ f n / (g n + d) + c / (g n + d)›*) have "f n / (g n + d) + c / (g n + d) = (f n + c) / (g n + d)"
using ‹0 < g n + d› (*‹0 < g n + d›*) by (auto simp: add_divide_distrib (*‹(?a + ?b) / ?c = ?a / ?c + ?b / ?c›*))
also (*calculation: ‹⟦⋀x y. x ≤ y ⟹ x + m ≤ y + m; ⋀x y. x ≤ y ⟹ x + m ≤ y + m; ⋀x y. x ≤ y ⟹ f n / (g n + d) + x ≤ f n / (g n + d) + y⟧ ⟹ x ≤ (f n + c) / (g n + d)›*) note u (*‹(f n + c) / (g n + d) ≤ u›*)
finally (*calculation: ‹⟦⋀x y. x ≤ y ⟹ x + m ≤ y + m; ⋀x y. x ≤ y ⟹ x + m ≤ y + m; ⋀x y. x ≤ y ⟹ f n / (g n + d) + x ≤ f n / (g n + d) + y⟧ ⟹ x ≤ u›*) show "x ≤ u"
by simp
qed
then show "x ≤ u"
by auto
qed
lemma compet_lb0:
fixes a Aon Aoff cruel
defines "f s0 rs == real(T_on Aon s0 rs)"
defines "g s0 rs == real(T_off Aoff s0 rs)"
assumes "⋀rs s0. size(Aoff s0 rs) = length rs" and "⋀n. cruel n ≠ []"
assumes "compet Aon c S0" and "c≥0" and "s0 ∈ S0"
and l: "eventually (λn. f s0 (cruel n) / (g s0 (cruel n) + a) ≥ l) sequentially"
and g: "LIM n sequentially. g s0 (cruel n) :> at_top"
and "l > 0" and "⋀n. static s0 (cruel n)"
shows "l ≤ c"
proof (-)
(*goal: ‹l ≤ c›*)
let ?h = "λb s0 rs. (f s0 rs - b) / g s0 rs"
have g': "LIM n sequentially. g s0 (cruel n) + a :> at_top"
using filterlim_tendsto_add_at_top[OF tendsto_const g] (*‹LIM x sequentially. ?c + g s0 (cruel x) :> at_top›*) by (simp add: ac_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 37 facts*))
from competE[OF assms ( 5 ) ‹c≥0› _ ‹s0 ∈ S0›] (*‹∀s0 rs. length (?aoff s0 rs) = length rs ⟹ ∃b≥0. ∀rs. static s0 rs ⟶ real (T_on Aon s0 rs) ≤ c * real (T_off ?aoff s0 rs) + b›*) assms(3) (*‹length ((Aoff::'a list ⇒ 'a list ⇒ (nat × nat list) list) (?s0.0::'a list) (?rs::'a list)) = length ?rs›*) obtain b where "∀rs. static s0 rs ∧ rs ≠ [] ⟶ ?h b s0 rs ≤ c "
(*goal: ‹(⋀b. ∀rs. static s0 rs ∧ rs ≠ [] ⟶ (f s0 rs - b) / g s0 rs ≤ c ⟹ thesis) ⟹ thesis›*)
by (fastforce simp del: neq0_conv (*‹(?n ≠ 0) = (0 < ?n)›*) simp: neq0_conv[symmetric] (*‹(0 < ?n) = (?n ≠ 0)›*) field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) f_def (*‹f ?s0.0 ?rs ≡ real (T_on Aon ?s0.0 ?rs)›*) g_def (*‹g ?s0.0 ?rs ≡ real (T_off Aoff ?s0.0 ?rs)›*) T_off_neq0[of Aoff, OF assms(3)] (*‹?rs ≠ [] ⟹ T_off Aoff ?s0.0 ?rs ≠ 0›*))
hence "∀n. (?h b s0 o cruel) n ≤ c"
using assms(4,11) (*‹cruel ?n ≠ []› ‹static s0 (cruel ?n)›*) by simp
with rat_fun_lem[OF sequentially_bot ‹l>0› _ _ g', of "f s0 o cruel" "-b" "- a" c] (*‹⟦∀⇩F n in sequentially. l ≤ (f s0 ∘ cruel) n / (g s0 (cruel n) + a); ∀⇩F n in sequentially. ((f s0 ∘ cruel) n + - b) / (g s0 (cruel n) + a + - a) ≤ c⟧ ⟹ l ≤ c›*) assms(7) (*‹s0 ∈ S0›*) l (*‹∀⇩F n in sequentially. l ≤ f s0 (cruel n) / (g s0 (cruel n) + a)›*) show "l ≤ c"
by auto
qed
text ‹Sorting›
fun ins_sws where
"ins_sws k x [] = []" |
"ins_sws k x (y#ys) = (if k x ≤ k y then [] else map Suc (ins_sws k x ys) @ [0])"
fun sort_sws where
"sort_sws k [] = []" |
"sort_sws k (x#xs) =
ins_sws k x (sort_key k xs) @ map Suc (sort_sws k xs)"
lemma length_ins_sws: "length(ins_sws k x xs) ≤ length xs"
apply (induction xs)
(*goals:
1. ‹length (ins_sws k x []) ≤ length []›
2. ‹⋀a xs. length (ins_sws k x xs) ≤ length xs ⟹ length (ins_sws k x (a # xs)) ≤ length (a # xs)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma length_sort_sws_le: "length(sort_sws k xs) ≤ length xs ^ 2"
proof (induction xs)
(*goals:
1. ‹length (sort_sws k []) ≤ (length [])²›
2. ‹⋀a xs. length (sort_sws k xs) ≤ (length xs)² ⟹ length (sort_sws k (a # xs)) ≤ (length (a # xs))²›*)
case (Cons x xs) (*‹length (sort_sws k xs) ≤ (length xs)²›*)
thus "?case"
(*goal: ‹length (sort_sws k (x # xs)) ≤ (length (x # xs))²›*)
using length_ins_sws[of k x "sort_key k xs"] (*‹length (ins_sws (k::'a::type ⇒ 'b::linorder) (x::'a::type) (sort_key k (xs::'a::type list))) ≤ length (sort_key k xs)›*) by (simp add: numeral_eq_Suc (*‹numeral ?k = Suc (pred_numeral ?k)›*))
qed (simp)
(*solved the remaining goal: ‹length (sort_sws k []) ≤ (length [])²›*)
lemma swaps_ins_sws:
"swaps (ins_sws k x xs) (x#xs) = insort_key k x xs"
apply (induction xs)
(*goals:
1. ‹swaps (ins_sws k x []) [x] = insort_key k x []›
2. ‹⋀a xs. swaps (ins_sws k x xs) (x # xs) = insort_key k x xs ⟹ swaps (ins_sws k x (a # xs)) (x # a # xs) = insort_key k x (a # xs)›
discuss goal 1*)
apply ((auto simp: swap_def[of 0] (*‹swap 0 ?xs = (if Suc 0 < length ?xs then ?xs[0 := ?xs ! Suc 0, Suc 0 := ?xs ! 0] else ?xs)›*))[1])
(*discuss goal 2*)
apply ((auto simp: swap_def[of 0] (*‹swap 0 ?xs = (if Suc 0 < length ?xs then ?xs[0 := ?xs ! Suc 0, Suc 0 := ?xs ! 0] else ?xs)›*))[1])
(*proven 2 subgoals*) .
lemma swaps_sort_sws[simp]:
"swaps (sort_sws k xs) xs = sort_key k xs"
apply (induction xs)
(*goals:
1. ‹swaps (sort_sws (k::'a::type ⇒ 'b::linorder) []) [] = sort_key k []›
2. ‹⋀(a::'a::type) xs::'a::type list. swaps (sort_sws (k::'a::type ⇒ 'b::linorder) xs) xs = sort_key k xs ⟹ swaps (sort_sws k (a # xs)) (a # xs) = sort_key k (a # xs)›
discuss goal 1*)
apply ((auto simp: swaps_ins_sws (*‹swaps (ins_sws ?k ?x ?xs) (?x # ?xs) = insort_key ?k ?x ?xs›*))[1])
(*discuss goal 2*)
apply ((auto simp: swaps_ins_sws (*‹swaps (ins_sws (?k::?'a::type ⇒ ?'b::linorder) (?x::?'a::type) (?xs::?'a::type list)) (?x # ?xs) = insort_key ?k ?x ?xs›*))[1])
(*proven 2 subgoals*) .
text‹The cruel adversary:›
fun cruel :: "('a,'is) alg_on ⇒ 'a state * 'is ⇒ nat ⇒ 'a list" where
"cruel A s 0 = []" |
"cruel A s (Suc n) = last (fst s) # cruel A (Step A s (last (fst s))) n"
definition adv :: "('a,'is) alg_on ⇒ ('a::linorder) alg_off" where
"adv A s rs = (if rs=[] then [] else
let crs = cruel A (Step A (s, fst A s) (last s)) (size rs - 1)
in (0,sort_sws (λx. size rs - 1 - count_list crs x) s) # replicate (size rs - 1) (0,[]))"
lemma set_cruel: "s ≠ [] ⟹ set(cruel A (s,is) n) ⊆ set s"
apply (induction n arbitrary: s "is")
(*goals:
1. ‹⋀s is. s ≠ [] ⟹ set (cruel A (s, is) 0) ⊆ set s›
2. ‹⋀n s is. ⟦⋀s is. s ≠ [] ⟹ set (cruel A (s, is) n) ⊆ set s; s ≠ []⟧ ⟹ set (cruel A (s, is) (Suc n)) ⊆ set s›
discuss goal 1*)
apply ((auto simp: step_def (*‹step ?s ?r ?a = (let (k, sws) = ?a in mtf2 k ?r (swaps sws ?s))›*) Step_def (*‹Step ?A ?s ?r = (let (a, is') = snd ?A ?s ?r in (step (fst ?s) ?r a, is'))›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))[1])
(*discuss goal 2*)
apply ((auto simp: step_def (*‹step (?s::?'a list) (?r::?'a) (?a::nat × nat list) = (let (k::nat, sws::nat list) = ?a in mtf2 k ?r (swaps sws ?s))›*) Step_def (*‹Step (?A::(?'a list ⇒ ?'istate) × (?'a list × ?'istate ⇒ ?'a ⇒ (nat × nat list) × ?'istate)) (?s::?'a list × ?'istate) (?r::?'a) = (let (a::nat × nat list, is'::?'istate) = snd ?A ?s ?r in (step (fst ?s) ?r a, is'))›*) split: prod.split (*‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∀(x1::?'a) x2::?'b. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))[1])
(*goal: ‹⋀(n::nat) (s::'a::type list) is::'b::type. ⟦⋀(s::'a::type list) is::'b::type. s ≠ [] ⟹ set (cruel (A::('a::type list ⇒ 'b::type) × ('a::type list × 'b::type ⇒ 'a::type ⇒ (nat × nat list) × 'b::type)) (s, is) n) ⊆ set s; s ≠ []⟧ ⟹ set (cruel A (s, is) (Suc n)) ⊆ set s›*)
apply (metis empty_iff (*‹((?c::?'a) ∈ {}) = False›*) swaps_inv (*‹set (swaps (?sws::nat list) (?xs::?'a list)) = set ?xs ∧ length (swaps ?sws ?xs) = length ?xs ∧ distinct (swaps ?sws ?xs) = distinct ?xs›*) last_in_set (*‹(?as::?'a list) ≠ [] ⟹ last ?as ∈ set ?as›*) list.set( (*‹set [] = {}›*) 1) rev_subsetD (*‹⟦(?c::?'a) ∈ (?A::?'a set); ?A ⊆ (?B::?'a set)⟧ ⟹ ?c ∈ ?B›*) set_mtf2 (*‹set (mtf2 (?n::nat) (?x::?'a) (?xs::?'a list)) = set ?xs›*))
(*proven 2 subgoals*) .
lemma static_cruel: "s ≠ [] ⟹ static s (cruel A (s,is) n)"
by (simp add: set_cruel (*‹(?s::?'a list) ≠ [] ⟹ set (cruel (?A::(?'a list ⇒ ?'b) × (?'a list × ?'b ⇒ ?'a ⇒ (nat × nat list) × ?'b)) (?s, ?is::?'b) (?n::nat)) ⊆ set ?s›*) static_def (*‹static (?s::?'a list) (?rs::?'a list) = (set ?rs ⊆ set ?s)›*))
(* Do not convert into structured proof - eta conversion screws it up! *)
lemma T_cruel:
"s ≠ [] ⟹ distinct s ⟹
T s (cruel A (s,is) n) (off2 A (s,is) (cruel A (s,is) n)) ≥ n*(length s)"
apply (induction n arbitrary: s "is")
(*goals:
1. ‹⋀s is. ⟦s ≠ []; distinct s⟧ ⟹ 0 * length s ≤ T s (cruel A (s, is) 0) (off2 A (s, is) (cruel A (s, is) 0))›
2. ‹⋀n s is. ⟦⋀s is. ⟦s ≠ []; distinct s⟧ ⟹ n * length s ≤ T s (cruel A (s, is) n) (off2 A (s, is) (cruel A (s, is) n)); s ≠ []; distinct s⟧ ⟹ Suc n * length s ≤ T s (cruel A (s, is) (Suc n)) (off2 A (s, is) (cruel A (s, is) (Suc n)))›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (erule_tac x = "fst(Step A (s, is) (last s))" in meta_allE (*‹⟦⋀x. PROP ?P x; PROP ?P ?x ⟹ PROP ?W⟧ ⟹ PROP ?W›*))
(*goal: ‹⋀n s is. ⟦⋀s is. ⟦s ≠ []; distinct s⟧ ⟹ n * length s ≤ T s (cruel A (s, is) n) (off2 A (s, is) (cruel A (s, is) n)); s ≠ []; distinct s⟧ ⟹ Suc n * length s ≤ T s (cruel A (s, is) (Suc n)) (off2 A (s, is) (cruel A (s, is) (Suc n)))›*)
apply (erule_tac x = "snd(Step A (s, is) (last s))" in meta_allE (*‹⟦⋀x. PROP ?P x; PROP ?P ?x ⟹ PROP ?W⟧ ⟹ PROP ?W›*))
(*goal: ‹⋀(n::nat) (s::'a list) is::'b. ⟦s ≠ []; distinct s; ⋀isa::'b. ⟦fst (Step (A::('a list ⇒ 'b) × ('a list × 'b ⇒ 'a ⇒ (nat × nat list) × 'b)) (s, is) (last s)) ≠ []; distinct (fst (Step A (s, is) (last s)))⟧ ⟹ n * length (fst (Step A (s, is) (last s))) ≤ T (fst (Step A (s, is) (last s))) (cruel A (fst (Step A (s, is) (last s)), isa) n) (off2 A (fst (Step A (s, is) (last s)), isa) (cruel A (fst (Step A (s, is) (last s)), isa) n))⟧ ⟹ Suc n * length s ≤ T s (cruel A (s, is) (Suc n)) (off2 A (s, is) (cruel A (s, is) (Suc n)))›*)
apply (frule_tac sws = "snd(fst(snd A (s,is) (last s)))" in index_swaps_last_size (*‹distinct ?s ⟹ length ?s ≤ index (swaps ?sws ?s) (last ?s) + length ?sws + 1›*))
(*goal: ‹⋀n s is. ⟦s ≠ []; distinct s; ⟦fst (Step A (s, is) (last s)) ≠ []; distinct (fst (Step A (s, is) (last s)))⟧ ⟹ n * length (fst (Step A (s, is) (last s))) ≤ T (fst (Step A (s, is) (last s))) (cruel A (fst (Step A (s, is) (last s)), snd (Step A (s, is) (last s))) n) (off2 A (fst (Step A (s, is) (last s)), snd (Step A (s, is) (last s))) (cruel A (fst (Step A (s, is) (last s)), snd (Step A (s, is) (last s))) n))⟧ ⟹ Suc n * length s ≤ T s (cruel A (s, is) (Suc n)) (off2 A (s, is) (cruel A (s, is) (Suc n)))›*)
apply (simp add: distinct_step (*‹distinct (step ?s ?r ?as) = distinct ?s›*) t_def (*‹t ?s ?r ?a = (let (mf, sws) = ?a in index (swaps sws ?s) ?r + 1 + length sws)›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*) Step_def (*‹Step ?A ?s ?r = (let (a, is') = snd ?A ?s ?r in (step (fst ?s) ?r a, is'))›*) length_greater_0_conv[symmetric] (*‹(?xs ≠ []) = (0 < length ?xs)›*) del: length_greater_0_conv (*‹(0 < length ?xs) = (?xs ≠ [])›*))
(*proven 2 subgoals*) .
lemma length_cruel[simp]: "length (cruel A s n) = n"
apply (induction n arbitrary: s)
(*goals:
1. ‹⋀s. length (cruel A s 0) = 0›
2. ‹⋀n s. (⋀s. length (cruel A s n) = n) ⟹ length (cruel A s (Suc n)) = Suc n›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma t_sort_sws: "t s r (mf, sort_sws k s) ≤ size s ^ 2 + size s + 1"
using length_sort_sws_le[of k s] (*‹length (sort_sws k s) ≤ (length s)²›*) index_le_size[of "sort_key k s" r] (*‹index (sort_key (k::'a::type ⇒ 'b::linorder) (s::'a::type list)) (r::'a::type) ≤ length (sort_key k s)›*) by (simp add: t_def (*‹t ?s ?r ?a = (let (mf, sws) = ?a in index (swaps sws ?s) ?r + 1 + length sws)›*) add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) index_le_size (*‹index ?xs ?x ≤ length ?xs›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*))
lemma T_noop:
"n = length rs ⟹ T s rs (replicate n (0, [])) = (∑r←rs. index s r + 1)"
apply (induction rs arbitrary: s n)
(*goals:
1. ‹⋀s n. n = length [] ⟹ T s [] (replicate n (0, [])) = (∑r←[]. index s r + 1)›
2. ‹⋀a rs s n. ⟦⋀s n. n = length rs ⟹ T s rs (replicate n (0, [])) = (∑r←rs. index s r + 1); n = length (a # rs)⟧ ⟹ T s (a # rs) (replicate n (0, [])) = (∑r←a # rs. index s r + 1)›
discuss goal 1*)
apply ((auto simp: t_def (*‹t ?s ?r ?a = (let (mf, sws) = ?a in index (swaps sws ?s) ?r + 1 + length sws)›*) step_def (*‹step ?s ?r ?a = (let (k, sws) = ?a in mtf2 k ?r (swaps sws ?s))›*))[1])
(*discuss goal 2*)
apply ((auto simp: t_def (*‹t ?s ?r ?a = (let (mf, sws) = ?a in index (swaps sws ?s) ?r + 1 + length sws)›*) step_def (*‹step ?s ?r ?a = (let (k, sws) = ?a in mtf2 k ?r (swaps sws ?s))›*))[1])
(*proven 2 subgoals*) .
lemma sorted_asc: "j≤i ⟹ i<size ss ⟹ ∀x ∈ set ss. ∀y ∈ set ss. k(x) ≤ k(y) ⟶ f y ≤ f x
⟹ sorted (map k ss) ⟹ f (ss ! i) ≤ f (ss ! j)"
by (auto simp: sorted_iff_nth_mono (*‹sorted ?xs = (∀i j. i ≤ j ⟶ j < length ?xs ⟶ ?xs ! i ≤ ?xs ! j)›*))
lemma sorted_weighted_gauss_Ico_div2:
fixes f :: "nat ⇒ nat"
assumes "⋀i j. i ≤ j ⟹ j < n ⟹ f i ≥ f j"
shows "(∑i=0..<n. (i + 1) * f i) ≤ (n + 1) * sum f {0..<n} div 2"
proof (cases n)
(*goals:
1. ‹n = 0 ⟹ (∑i = 0..<n. (i + 1) * f i) ≤ (n + 1) * sum f {0..<n} div 2›
2. ‹⋀nat. n = Suc nat ⟹ (∑i = 0..<n. (i + 1) * f i) ≤ (n + 1) * sum f {0..<n} div 2›*)
case 0 (*‹(n::nat) = (0::nat)›*)
then show "?thesis"
(*goal: ‹(∑i = 0..<n. (i + 1) * f i) ≤ (n + 1) * sum f {0..<n} div 2›*)
by simp
next
(*goal: ‹⋀nat::nat. (n::nat) = Suc nat ⟹ (∑i::nat = 0::nat..<n. (i + (1::nat)) * (f::nat ⇒ nat) i) ≤ (n + (1::nat)) * sum f {0::nat..<n} div (2::nat)›*)
case (Suc n) (*‹n = Suc n›*)
with assms (*‹⟦(?i::nat) ≤ (?j::nat); ?j < (n::nat)⟧ ⟹ (f::nat ⇒ nat) ?j ≤ f ?i›*) have "Suc n * (∑i=0..<Suc n. Suc i * f i) ≤ (∑i=0..<Suc n. Suc i) * sum f {0..<Suc n}"
apply (intro Chebyshev_sum_upper_nat [of "Suc n" Suc f] (*‹⟦⋀i j. ⟦i ≤ j; j < Suc n⟧ ⟹ Suc i ≤ Suc j; ⋀i j. ⟦i ≤ j; j < Suc n⟧ ⟹ f j ≤ f i⟧ ⟹ Suc n * (∑i = 0..<Suc n. Suc i * f i) ≤ sum Suc {0..<Suc n} * sum f {0..<Suc n}›*))
(*goals:
1. ‹⋀i j. ⟦⋀i j. ⟦i ≤ j; j < n⟧ ⟹ f j ≤ f i; n = Suc n; i ≤ j; j < Suc n⟧ ⟹ Suc i ≤ Suc j›
2. ‹⋀i j. ⟦⋀i j. ⟦i ≤ j; j < n⟧ ⟹ f j ≤ f i; n = Suc n; i ≤ j; j < Suc n⟧ ⟹ f j ≤ f i›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
then have "Suc n * (2 * (∑i=0..n. Suc i * f i)) ≤ 2 * (∑i=0..n. Suc i) * sum f {0..n}"
by (simp add: atLeastLessThanSuc_atLeastAtMost (*‹{?l..<Suc ?u} = {?l..?u}›*))
also (*calculation: ‹Suc (n::nat) * ((2::nat) * (∑i::nat = 0::nat..n. Suc i * (f::nat ⇒ nat) i)) ≤ (2::nat) * sum Suc {0::nat..n} * sum f {0::nat..n}›*) have "2 * (∑i=0..n. Suc i) = Suc n * (n + 2)"
using arith_series_nat[of 1 1 n] (*‹(∑i = 0..n. 1 + i * 1) = Suc n * (2 * 1 + n * 1) div 2›*) by simp
finally (*calculation: ‹Suc n * (2 * (∑i = 0..n. Suc i * f i)) ≤ Suc n * (n + 2) * sum f {0..n}›*) have "2 * (∑i=0..n. Suc i * f i) ≤ (n + 2) * sum f {0..n}"
by (simp only: ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 37 facts*) Suc_mult_le_cancel1 (*‹(Suc ?k * ?m ≤ Suc ?k * ?n) = (?m ≤ ?n)›*))
with Suc (*‹n = Suc n›*) show "?thesis"
(*goal: ‹(∑i = 0..<n. (i + 1) * f i) ≤ (n + 1) * sum f {0..<n} div 2›*)
apply (simp only: atLeastLessThanSuc_atLeastAtMost (*‹{?l..<Suc ?u} = {?l..?u}›*))
(*goal: ‹(∑i = 0..<n. (i + 1) * f i) ≤ (n + 1) * sum f {0..<n} div 2›*)
by simp
qed
lemma T_adv: assumes "l ≠ 0"
shows "T_off (adv A) [0..<l] (cruel A ([0..<l],fst A [0..<l]) (Suc n))
≤ l² + l + 1 + (l + 1) * n div 2" (is "?l ≤ ?r")
proof-
let ?s = "[0..<l]"
let ?r = "last ?s"
let ?S' = "Step A (?s,fst A ?s) ?r"
let ?s' = "fst ?S'"
let ?cr = "cruel A ?S' n"
let ?c = "count_list ?cr"
let ?k = "λx. n - ?c x"
let ?sort = "sort_key ?k ?s"
have 1: "set ?s' = {0..<l}"
by(simp add: set_step Step_def split: prod.split)
have 3: "⋀x. x < l ⟹ ?c x ≤ n"
by(simp) (metis count_le_length length_cruel)
have "?l = t ?s (last ?s) (0, sort_sws ?k ?s) + (∑x∈set ?s'. ?c x * (index ?sort x + 1))"
using assms
apply(simp add: adv_def T_noop sum_list_map_eq_sum_count2[OF set_cruel] Step_def
split: prod.split)
apply(subst (3) step_def)
apply(simp)
done
also have "(∑x∈set ?s'. ?c x * (index ?sort x + 1)) = (∑x∈{0..<l}. ?c x * (index ?sort x + 1))"
by (simp add: 1)
also have "… = (∑x∈{0..<l}. ?c (?sort ! x) * (index ?sort (?sort ! x) + 1))"
by(rule sum.reindex_bij_betw[where ?h = "nth ?sort", symmetric])
(simp add: bij_betw_imageI inj_on_nth nth_image)
also have "… = (∑x∈{0..<l}. ?c (?sort ! x) * (x+1))"
by(simp add: index_nth_id)
also have "… ≤ (∑x∈{0..<l}. (x+1) * ?c (?sort ! x))"
by (simp add: algebra_simps)
also(ord_eq_le_subst) have "… ≤ (l+1) * (∑x∈{0..<l}. ?c (?sort ! x)) div 2"
apply(rule sorted_weighted_gauss_Ico_div2)
apply(erule sorted_asc[where k = "λx. n - count_list (cruel A ?S' n) x"])
apply(auto simp add: index_nth_id dest!: 3)
using assms [[linarith_split_limit = 20]] by simp
also have "(∑x∈{0..<l}. ?c (?sort ! x)) = (∑x∈{0..<l}. ?c (?sort ! (index ?sort x)))"
by(rule sum.reindex_bij_betw[where ?h = "index ?sort", symmetric])
(simp add: bij_betw_imageI inj_on_index2 index_image)
also have "… = (∑x∈{0..<l}. ?c x)" by(simp)
also have "… = length ?cr"
using set_cruel[of ?s' A _ n] assms 1
by(auto simp add: sum_count_set Step_def split: prod.split)
also have "… = n" by simp
also have "t ?s (last ?s) (0, sort_sws ?k ?s) ≤ (length ?s)^2 + length ?s + 1"
by(rule t_sort_sws)
also have "… = l^2 + l + 1" by simp
finally show "?l ≤ l² + l + 1 + (l + 1) * n div 2" by auto
qed
text ‹The main theorem:›
theorem compet_lb2:
assumes "compet A c {xs::nat list. size xs = l}" and "l ≠ 0" and "c ≥ 0"
shows "c ≥ 2*l/(l+1)"
proof (rule compet_lb0[OF _ _ assms(1) ‹c≥0›] (*‹⟦⋀(rs::nat list) s0::nat list. length ((?Aoff::nat list ⇒ nat list ⇒ (nat × nat list) list) s0 rs) = length rs; ⋀n::nat. (?cruel::nat ⇒ nat list) n ≠ []; (?s0.0::nat list) ∈ {xs::nat list. length xs = (l::nat)}; ∀⇩F n::nat in sequentially. (?l::real) ≤ real (T_on (A::(nat list ⇒ 'a) × (nat list × 'a ⇒ nat ⇒ (nat × nat list) × 'a)) ?s0.0 (?cruel n)) / (real (T_off ?Aoff ?s0.0 (?cruel n)) + (?a::real)); LIM (n::nat) sequentially. real (T_off ?Aoff ?s0.0 (?cruel n)) :> at_top; (0::real) < ?l; ⋀n::nat. static ?s0.0 (?cruel n)⟧ ⟹ ?l ≤ (c::real)›*))
(*goals:
1. ‹⋀rs s0. length (?Aoff s0 rs) = length rs›
2. ‹⋀n. ?cruel n ≠ []›
3. ‹?s0.0 ∈ {xs. length xs = l}›
4. ‹∀⇩F n in sequentially. real (2 * l) / real (l + 1) ≤ real (T_on A ?s0.0 (?cruel n)) / (real (T_off ?Aoff ?s0.0 (?cruel n)) + ?a)›
5. ‹LIM n sequentially. real (T_off ?Aoff ?s0.0 (?cruel n)) :> at_top›
6. ‹0 < real (2 * l) / real (l + 1)›
7. ‹⋀n. static ?s0.0 (?cruel n)›*)
let ?S0 = "{xs::nat list. size xs = l}"
let ?s0 = "[0..<l]"
let ?cruel = "cruel A (?s0,fst A ?s0) o Suc"
let ?on = "λn. T_on A ?s0 (?cruel n)"
let ?off = "λn. T_off (adv A) ?s0 (?cruel n)"
show "⋀s0 rs. length (adv A s0 rs) = length rs"
by (simp add: adv_def (*‹adv (?A::(?'a::linorder list ⇒ ?'is::type) × (?'a::linorder list × ?'is::type ⇒ ?'a::linorder ⇒ (nat × nat list) × ?'is::type)) (?s::?'a::linorder list) (?rs::?'a::linorder list) = (if ?rs = [] then [] else let crs::?'a::linorder list = cruel ?A (Step ?A (?s, fst ?A ?s) (last ?s)) (length ?rs - (1::nat)) in (0::nat, sort_sws (λx::?'a::linorder. length ?rs - (1::nat) - count_list crs x) ?s) # replicate (length ?rs - (1::nat)) (0::nat, []))›*))
show "⋀n. ?cruel n ≠ []"
by auto
show "?s0 ∈ ?S0"
by simp
{
fix Z :: real and n :: nat
assume "n ≥ nat(ceiling Z)" (*‹nat ⌈Z::real⌉ ≤ (n::nat)›*)
have "?off n ≥ length(?cruel n)"
apply (rule T_ge_len (*‹length (?as::(nat × nat list) list) = length (?rs::?'a list) ⟹ length ?rs ≤ T (?s::?'a list) ?rs ?as›*))
(*goal: ‹length ((cruel (A::(nat list ⇒ 'a) × (nat list × 'a ⇒ nat ⇒ (nat × nat list) × 'a)) ([0::nat..<l::nat], fst A [0::nat..<l]) ∘ Suc) (n::nat)) ≤ T_off (adv A) [0::nat..<l] ((cruel A ([0::nat..<l], fst A [0::nat..<l]) ∘ Suc) n)›*)
by (simp add: adv_def (*‹adv ?A ?s ?rs = (if ?rs = [] then [] else let crs = cruel ?A (Step ?A (?s, fst ?A ?s) (last ?s)) (length ?rs - 1) in (0, sort_sws (λx. length ?rs - 1 - count_list crs x) ?s) # replicate (length ?rs - 1) (0, []))›*))
hence "?off n > n"
by simp
hence "Z ≤ ?off n"
using ‹n ≥ nat(ceiling Z)› (*‹nat ⌈Z::real⌉ ≤ (n::nat)›*) by linarith
}
thus "LIM n sequentially. real (?off n) :> at_top"
by (auto simp only: filterlim_at_top (*‹filterlim ?f at_top ?F = (∀Z. ∀⇩F x in ?F. Z ≤ ?f x)›*) eventually_sequentially (*‹eventually ?P sequentially = (∃N. ∀n≥N. ?P n)›*))
let ?a = "- (l^2 + l + 1)"
{
fix n
assume "n ≥ l^2 + l + 1" (*‹(l::nat)² + l + (1::nat) ≤ (n::nat)›*)
have "2*l/(l+1) = 2*l*(n+1) / ((l+1)*(n+1))"
by (simp del: One_nat_def (*‹1 = Suc 0›*))
also (*calculation: ‹real (2 * l) / real (l + 1) = real (2 * l * (n + 1)) / real ((l + 1) * (n + 1))›*) have "… = 2*real(l*(n+1)) / ((l+1)*(n+1))"
by simp
also (*calculation: ‹real ((2::nat) * (l::nat)) / real (l + (1::nat)) = (2::real) * real (l * ((n::nat) + (1::nat))) / real ((l + (1::nat)) * (n + (1::nat)))›*) have "l * (n+1) ≤ ?on n"
using T_cruel[of ?s0 "Suc n"] (*‹⟦[0..<l] ≠ []; distinct [0..<l]⟧ ⟹ Suc n * length [0..<l] ≤ T [0..<l] (cruel ?A ([0..<l], ?is) (Suc n)) (off2 ?A ([0..<l], ?is) (cruel ?A ([0..<l], ?is) (Suc n)))›*) ‹l ≠ 0› (*‹l ≠ 0›*) by (simp add: ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 37 facts*))
also (*calculation: ‹(⋀(x::nat) y::nat. x ≤ y ⟹ (2::real) * real x / real (((l::nat) + (1::nat)) * ((n::nat) + (1::nat))) ≤ (2::real) * real y / real ((l + (1::nat)) * (n + (1::nat)))) ⟹ real ((2::nat) * l) / real (l + (1::nat)) ≤ (2::real) * real (T_on (A::(nat list ⇒ 'a) × (nat list × 'a ⇒ nat ⇒ (nat × nat list) × 'a)) [0::nat..<l] ((cruel A ([0::nat..<l], fst A [0::nat..<l]) ∘ Suc) n)) / real ((l + (1::nat)) * (n + (1::nat)))›*) have "2*real(?on n) / ((l+1)*(n+1)) ≤ 2*real(?on n)/(2*(?off n + ?a))"
proof (-)
(*goal: ‹2 * real (T_on A [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)) / real ((l + 1) * (n + 1)) ≤ 2 * real (T_on A [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)) / real_of_int (2 * (int (T_off (adv A) [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)) + - int (l² + l + 1)))›*)
have 0: "2*real(?on n) ≥ 0"
by simp
have 1: "0 < real ((l + 1) * (n + 1))"
by (simp del: of_nat_Suc (*‹of_nat (Suc ?m) = 1 + of_nat ?m›*))
have "?off n ≥ length(?cruel n)"
apply (rule T_ge_len (*‹length ?as = length ?rs ⟹ length ?rs ≤ T ?s ?rs ?as›*))
(*goal: ‹length ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n) ≤ T_off (adv A) [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)›*)
by (simp add: adv_def (*‹adv (?A::(?'a list ⇒ ?'is) × (?'a list × ?'is ⇒ ?'a ⇒ (nat × nat list) × ?'is)) (?s::?'a list) (?rs::?'a list) = (if ?rs = [] then [] else let crs::?'a list = cruel ?A (Step ?A (?s, fst ?A ?s) (last ?s)) (length ?rs - (1::nat)) in (0::nat, sort_sws (λx::?'a. length ?rs - (1::nat) - count_list crs x) ?s) # replicate (length ?rs - (1::nat)) (0::nat, []))›*))
hence "?off n > n"
by simp
hence "?off n + ?a > 0"
using ‹n ≥ l^2 + l + 1› (*‹(l::nat)² + l + (1::nat) ≤ (n::nat)›*) by linarith
hence 2: "real_of_int(2*(?off n + ?a)) > 0"
by (simp only: of_int_0_less_iff (*‹(0 < of_int ?z) = (0 < ?z)›*) zero_less_mult_iff (*‹(0 < ?a * ?b) = (0 < ?a ∧ 0 < ?b ∨ ?a < 0 ∧ ?b < 0)›*) zero_less_numeral (*‹0 < numeral ?n›*) simp_thms (*‹(¬ ¬ ?P) = ?P› ‹((¬ ?P) = (¬ ?Q)) = (?P = ?Q)› ‹(?P ≠ ?Q) = (?P = (¬ ?Q))› ‹(?P ∨ ¬ ?P) = True› ‹(¬ ?P ∨ ?P) = True› ‹(?x = ?x) = True› ‹(¬ True) = False› ‹(¬ False) = True› ‹(¬ ?P) ≠ ?P› ‹?P ≠ (¬ ?P)› ‹(True = ?P) = ?P› ‹(?P = True) = ?P› and more 32 facts*))
have "?off n + ?a ≤ (l+1)*(n) div 2"
using T_adv[OF ‹l≠0›, of A n] (*‹T_off (adv (A::(nat list ⇒ 'a) × (nat list × 'a ⇒ nat ⇒ (nat × nat list) × 'a))) [0::nat..<l::nat] (cruel A ([0::nat..<l], fst A [0::nat..<l]) (Suc (n::nat))) ≤ l² + l + (1::nat) + (l + (1::nat)) * n div (2::nat)›*) by (simp only: o_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) of_nat_add (*‹of_nat (?m + ?n) = of_nat ?m + of_nat ?n›*) of_nat_le_iff (*‹(of_nat ?m ≤ of_nat ?n) = (?m ≤ ?n)›*))
also (*calculation: ‹int (T_off (adv (A::(nat list ⇒ 'a) × (nat list × 'a ⇒ nat ⇒ (nat × nat list) × 'a))) [0::nat..<l::nat] ((cruel A ([0::nat..<l], fst A [0::nat..<l]) ∘ Suc) (n::nat))) + - int (l² + l + (1::nat)) ≤ int ((l + (1::nat)) * n div (2::nat))›*) have "… ≤ (l+1)*(n+1) div 2"
by simp
finally (*calculation: ‹int (T_off (adv A) [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)) + - int (l² + l + 1) ≤ int ((l + 1) * (n + 1) div 2)›*) have "2*(?off n + ?a) ≤ (l+1)*(n+1)"
by (simp add: zdiv_int (*‹int (?m div ?n) = int ?m div int ?n›*))
hence "of_int(2*(?off n + ?a)) ≤ real((l+1)*(n+1))"
by (simp only: of_int_le_iff (*‹(of_int (?w::int) ≤ of_int (?z::int)) = (?w ≤ ?z)›*))
from divide_left_mono[OF this 0 mult_pos_pos [ OF 1 2 ]] (*‹2 * real (T_on A [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)) / real ((l + 1) * (n + 1)) ≤ 2 * real (T_on A [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)) / real_of_int (2 * (int (T_off (adv A) [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)) + - int (l² + l + 1)))›*) show "?thesis"
(*goal: ‹2 * real (T_on A [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)) / real ((l + 1) * (n + 1)) ≤ 2 * real (T_on A [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)) / real_of_int (2 * (int (T_off (adv A) [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)) + - int (l² + l + 1)))›*) .
qed
also (*calculation: ‹(⋀x y. x ≤ y ⟹ 2 * real x / real ((l + 1) * (n + 1)) ≤ 2 * real y / real ((l + 1) * (n + 1))) ⟹ real (2 * l) / real (l + 1) ≤ 2 * real (T_on A [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)) / real_of_int (2 * (int (T_off (adv A) [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)) + - int (l² + l + 1)))›*) have "… = ?on n / (?off n + ?a)"
by (simp del: distrib_left_numeral (*‹numeral (?v::num) * ((?b::?'a) + (?c::?'a)) = numeral ?v * ?b + numeral ?v * ?c›*) One_nat_def (*‹(1::nat) = Suc (0::nat)›*) cruel.simps (*‹cruel (?A::(?'a list ⇒ ?'is) × (?'a list × ?'is ⇒ ?'a ⇒ (nat × nat list) × ?'is)) (?s::?'a list × ?'is) (0::nat) = []› ‹cruel (?A::(?'a list ⇒ ?'is) × (?'a list × ?'is ⇒ ?'a ⇒ (nat × nat list) × ?'is)) (?s::?'a list × ?'is) (Suc (?n::nat)) = last (fst ?s) # cruel ?A (Step ?A ?s (last (fst ?s))) ?n›*))
finally (*calculation: ‹(⋀x y. x ≤ y ⟹ 2 * real x / real ((l + 1) * (n + 1)) ≤ 2 * real y / real ((l + 1) * (n + 1))) ⟹ real (2 * l) / real (l + 1) ≤ real (T_on A [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)) / real_of_int (int (T_off (adv A) [0..<l] ((cruel A ([0..<l], fst A [0..<l]) ∘ Suc) n)) + - int (l² + l + 1))›*) have "2*l/(l+1) ≤ ?on n / (real (?off n) + ?a)"
by (auto simp: divide_right_mono (*‹⟦(?a::?'a) ≤ (?b::?'a); (0::?'a) ≤ (?c::?'a)⟧ ⟹ ?a / ?c ≤ ?b / ?c›*))
}
thus "eventually (λn. (2 * l) / (l + 1) ≤ ?on n / (real(?off n) + ?a)) sequentially"
by (auto simp add: filterlim_at_top (*‹filterlim ?f at_top ?F = (∀Z. ∀⇩F x in ?F. Z ≤ ?f x)›*) eventually_sequentially (*‹eventually ?P sequentially = (∃N. ∀n≥N. ?P n)›*))
show "0 < 2*l / (l+1)"
using ‹l ≠ 0› (*‹(l::nat) ≠ (0::nat)›*) by simp
show "⋀n. static ?s0 (?cruel n)"
using ‹l ≠ 0› (*‹l ≠ 0›*) by (simp add: static_cruel (*‹?s ≠ [] ⟹ static ?s (cruel ?A (?s, ?is) ?n)›*) del: cruel.simps (*‹cruel ?A ?s 0 = []› ‹cruel ?A ?s (Suc ?n) = last (fst ?s) # cruel ?A (Step ?A ?s (last (fst ?s))) ?n›*))
qed
end
| {
"path": "afp-2025-02-12/thys/List_Update/Move_to_Front.thy",
"repo": "afp-2025-02-12",
"sha": "9058fb0f58d1ae7f722986a4b4e3c45d00c3106270fa903caf3c9dcbea564df7"
} |
(* Title: HOL/MicroJava/J/State.thy
Author: David von Oheimb
Copyright 1999 Technische Universitaet Muenchen
*)
section ‹Objects and the Heap›
theory Objects imports TypeRel Value begin
subsection‹Objects›
type_synonym
fields = "vname × cname ⇀ val" ― ‹field name, defining class, value›
type_synonym
obj = "cname × fields" ― ‹class instance with class name and fields›
definition obj_ty :: "obj ⇒ ty"
where
"obj_ty obj ≡ Class (fst obj)"
definition init_fields :: "((vname × cname) × ty) list ⇒ fields"
where
"init_fields ≡ map_of ∘ map (λ(F,T). (F,default_val T))"
― ‹a new, blank object with default values in all fields:›
definition blank :: "'m prog ⇒ cname ⇒ obj"
where
"blank P C ≡ (C,init_fields (fields P C))"
lemma [simp]: "obj_ty (C,fs) = Class C"
(*<*)by (simp add: obj_ty_def (*‹obj_ty (?obj::char list × (char list × char list ⇒ val option)) ≡ Class (fst ?obj)›*))(*>*)
subsection‹Heap›
type_synonym heap = "addr ⇀ obj"
abbreviation
cname_of :: "heap ⇒ addr ⇒ cname" where
"cname_of hp a == fst (the (hp a))"
definition new_Addr :: "heap ⇒ addr option"
where
"new_Addr h ≡ if ∃a. h a = None then Some(LEAST a. h a = None) else None"
definition cast_ok :: "'m prog ⇒ cname ⇒ heap ⇒ val ⇒ bool"
where
"cast_ok P C h v ≡ v = Null ∨ P ⊢ cname_of h (the_Addr v) ≼⇧* C"
definition hext :: "heap ⇒ heap ⇒ bool" ("_ ⊴ _" [51,51] 50)
where
"h ⊴ h' ≡ ∀a C fs. h a = Some(C,fs) ⟶ (∃fs'. h' a = Some(C,fs'))"
primrec typeof_h :: "heap ⇒ val ⇒ ty option" ("typeof⇘_⇙")
where
"typeof⇘h⇙ Unit = Some Void"
| "typeof⇘h⇙ Null = Some NT"
| "typeof⇘h⇙ (Bool b) = Some Boolean"
| "typeof⇘h⇙ (Intg i) = Some Integer"
| "typeof⇘h⇙ (Addr a) = (case h a of None ⇒ None | Some(C,fs) ⇒ Some(Class C))"
lemma new_Addr_SomeD:
"new_Addr h = Some a ⟹ h a = None"
(*<*) by (fastforce simp add:new_Addr_def (*‹new_Addr ?h ≡ if ∃a. ?h a = None then ⌊LEAST a. ?h a = None⌋ else None›*) split:if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro:LeastI (*‹?P ?k ⟹ ?P (LEAST x. ?P x)›*))(*>*)
lemma [simp]: "(typeof⇘h⇙ v = Some Boolean) = (∃b. v = Bool b)"
(*<*) apply (induct v)
(*goals:
1. ‹(typeof⇘h⇙ Unit = ⌊Boolean⌋) = (∃b. Unit = Bool b)›
2. ‹(typeof⇘h⇙ Null = ⌊Boolean⌋) = (∃b. Null = Bool b)›
3. ‹⋀x. (typeof⇘h⇙ (Bool x) = ⌊Boolean⌋) = (∃b. Bool x = Bool b)›
4. ‹⋀x. (typeof⇘h⇙ (Intg x) = ⌊Boolean⌋) = (∃b. Intg x = Bool b)›
5. ‹⋀x. (typeof⇘h⇙ (Addr x) = ⌊Boolean⌋) = (∃b. Addr x = Bool b)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .(*>*)
lemma [simp]: "(typeof⇘h⇙ v = Some Integer) = (∃i. v = Intg i)"
(*<*)apply (cases v)
(*goals:
1. ‹v = Unit ⟹ (typeof⇘h⇙ v = ⌊Integer⌋) = (∃i. v = Intg i)›
2. ‹v = Null ⟹ (typeof⇘h⇙ v = ⌊Integer⌋) = (∃i. v = Intg i)›
3. ‹⋀x3. v = Bool x3 ⟹ (typeof⇘h⇙ v = ⌊Integer⌋) = (∃i. v = Intg i)›
4. ‹⋀x4. v = Intg x4 ⟹ (typeof⇘h⇙ v = ⌊Integer⌋) = (∃i. v = Intg i)›
5. ‹⋀x5. v = Addr x5 ⟹ (typeof⇘h⇙ v = ⌊Integer⌋) = (∃i. v = Intg i)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .(*>*)
lemma [simp]: "(typeof⇘h⇙ v = Some NT) = (v = Null)"
(*<*) apply (cases v)
(*goals:
1. ‹v = Unit ⟹ (typeof⇘h⇙ v = ⌊NT⌋) = (v = Null)›
2. ‹v = Null ⟹ (typeof⇘h⇙ v = ⌊NT⌋) = (v = Null)›
3. ‹⋀x3. v = Bool x3 ⟹ (typeof⇘h⇙ v = ⌊NT⌋) = (v = Null)›
4. ‹⋀x4. v = Intg x4 ⟹ (typeof⇘h⇙ v = ⌊NT⌋) = (v = Null)›
5. ‹⋀x5. v = Addr x5 ⟹ (typeof⇘h⇙ v = ⌊NT⌋) = (v = Null)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .(*>*)
lemma [simp]: "(typeof⇘h⇙ v = Some(Class C)) = (∃a fs. v = Addr a ∧ h a = Some(C,fs))"
(*<*) apply (cases v)
(*goals:
1. ‹v = Unit ⟹ (typeof⇘h⇙ v = ⌊Class C⌋) = (∃a fs. v = Addr a ∧ h a = ⌊(C, fs)⌋)›
2. ‹v = Null ⟹ (typeof⇘h⇙ v = ⌊Class C⌋) = (∃a fs. v = Addr a ∧ h a = ⌊(C, fs)⌋)›
3. ‹⋀x3. v = Bool x3 ⟹ (typeof⇘h⇙ v = ⌊Class C⌋) = (∃a fs. v = Addr a ∧ h a = ⌊(C, fs)⌋)›
4. ‹⋀x4. v = Intg x4 ⟹ (typeof⇘h⇙ v = ⌊Class C⌋) = (∃a fs. v = Addr a ∧ h a = ⌊(C, fs)⌋)›
5. ‹⋀x5. v = Addr x5 ⟹ (typeof⇘h⇙ v = ⌊Class C⌋) = (∃a fs. v = Addr a ∧ h a = ⌊(C, fs)⌋)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .(*>*)
lemma [simp]: "h a = Some(C,fs) ⟹ typeof⇘(h(a↦(C,fs')))⇙ v = typeof⇘h⇙ v"
(*<*) apply (induct v)
(*goals:
1. ‹h a = ⌊(C, fs)⌋ ⟹ typeof⇘h(a ↦ (C, fs'))⇙ Unit = typeof⇘h⇙ Unit›
2. ‹h a = ⌊(C, fs)⌋ ⟹ typeof⇘h(a ↦ (C, fs'))⇙ Null = typeof⇘h⇙ Null›
3. ‹⋀x. h a = ⌊(C, fs)⌋ ⟹ typeof⇘h(a ↦ (C, fs'))⇙ (Bool x) = typeof⇘h⇙ (Bool x)›
4. ‹⋀x. h a = ⌊(C, fs)⌋ ⟹ typeof⇘h(a ↦ (C, fs'))⇙ (Intg x) = typeof⇘h⇙ (Intg x)›
5. ‹⋀x. h a = ⌊(C, fs)⌋ ⟹ typeof⇘h(a ↦ (C, fs'))⇙ (Addr x) = typeof⇘h⇙ (Addr x)›
discuss goal 1*)
apply ((auto simp:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1])
(*discuss goal 2*)
apply ((auto simp:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1])
(*discuss goal 3*)
apply ((auto simp:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))[1])
(*discuss goal 4*)
apply ((auto simp:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1])
(*discuss goal 5*)
apply ((auto simp:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1])
(*proven 5 subgoals*) .(*>*)
text‹For literal values the first parameter of @{term typeof} can be
set to @{term Map.empty} because they do not contain addresses:›
abbreviation
typeof :: "val ⇒ ty option" where
"typeof v == typeof_h Map.empty v"
lemma typeof_lit_typeof:
"typeof v = Some T ⟹ typeof⇘h⇙ v = Some T"
(*<*) apply (cases v)
(*goals:
1. ‹⟦typeof⇘λx. None⇙ v = ⌊T⌋; v = Unit⟧ ⟹ typeof⇘h⇙ v = ⌊T⌋›
2. ‹⟦typeof⇘λx. None⇙ v = ⌊T⌋; v = Null⟧ ⟹ typeof⇘h⇙ v = ⌊T⌋›
3. ‹⋀x3. ⟦typeof⇘λx. None⇙ v = ⌊T⌋; v = Bool x3⟧ ⟹ typeof⇘h⇙ v = ⌊T⌋›
4. ‹⋀x4. ⟦typeof⇘λx. None⇙ v = ⌊T⌋; v = Intg x4⟧ ⟹ typeof⇘h⇙ v = ⌊T⌋›
5. ‹⋀x5. ⟦typeof⇘λx. None⇙ v = ⌊T⌋; v = Addr x5⟧ ⟹ typeof⇘h⇙ v = ⌊T⌋›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .(*>*)
lemma typeof_lit_is_type:
"typeof v = Some T ⟹ is_type P T"
(*<*) apply (induct v)
(*goals:
1. ‹typeof⇘λx. None⇙ Unit = ⌊T⌋ ⟹ is_type P T›
2. ‹typeof⇘λx. None⇙ Null = ⌊T⌋ ⟹ is_type P T›
3. ‹⋀x. typeof⇘λx. None⇙ (Bool x) = ⌊T⌋ ⟹ is_type P T›
4. ‹⋀x. typeof⇘λx. None⇙ (Intg x) = ⌊T⌋ ⟹ is_type P T›
5. ‹⋀x. typeof⇘λx. None⇙ (Addr x) = ⌊T⌋ ⟹ is_type P T›
discuss goal 1*)
apply ((auto simp:is_type_def (*‹is_type ?P ?T ≡ case ?T of Class C ⇒ is_class ?P C | _ ⇒ True›*))[1])
(*discuss goal 2*)
apply ((auto simp:is_type_def (*‹is_type (?P::(char list × char list × (char list × ty) list × (char list × ty list × ty × ?'m) list) list) (?T::ty) ≡ case ?T of Class (C::char list) ⇒ is_class ?P C | _ ⇒ True›*))[1])
(*discuss goal 3*)
apply ((auto simp:is_type_def (*‹is_type ?P ?T ≡ case ?T of Class C ⇒ is_class ?P C | _ ⇒ True›*))[1])
(*discuss goal 4*)
apply ((auto simp:is_type_def (*‹is_type ?P ?T ≡ case ?T of Class C ⇒ is_class ?P C | _ ⇒ True›*))[1])
(*discuss goal 5*)
apply ((auto simp:is_type_def (*‹is_type ?P ?T ≡ case ?T of Class C ⇒ is_class ?P C | _ ⇒ True›*))[1])
(*proven 5 subgoals*) .(*>*)
subsection ‹Heap extension ‹⊴››
lemma hextI: "∀a C fs. h a = Some(C,fs) ⟶ (∃fs'. h' a = Some(C,fs')) ⟹ h ⊴ h'"
(*<*)by (auto simp: hext_def (*‹(?h::nat ⇒ (char list × (char list × char list ⇒ val option)) option) ⊴ (?h'::nat ⇒ (char list × (char list × char list ⇒ val option)) option) ≡ ∀(a::nat) (C::char list) fs::char list × char list ⇒ val option. ?h a = ⌊(C, fs)⌋ ⟶ (∃fs'::char list × char list ⇒ val option. ?h' a = ⌊(C, fs')⌋)›*))(*>*)
lemma hext_objD: "⟦ h ⊴ h'; h a = Some(C,fs) ⟧ ⟹ ∃fs'. h' a = Some(C,fs')"
(*<*)by (auto simp: hext_def (*‹?h ⊴ ?h' ≡ ∀a C fs. ?h a = ⌊(C, fs)⌋ ⟶ (∃fs'. ?h' a = ⌊(C, fs')⌋)›*))(*>*)
lemma hext_refl [iff]: "h ⊴ h"
(*<*)apply (rule hextI (*‹∀a C fs. ?h a = ⌊(C, fs)⌋ ⟶ (∃fs'. ?h' a = ⌊(C, fs')⌋) ⟹ ?h ⊴ ?h'›*))
(*goal: ‹h ⊴ h›*)
by fast(*>*)
lemma hext_new [simp]: "h a = None ⟹ h ⊴ h(a↦x)"
(*<*)apply (rule hextI (*‹∀a C fs. ?h a = ⌊(C, fs)⌋ ⟶ (∃fs'. ?h' a = ⌊(C, fs')⌋) ⟹ ?h ⊴ ?h'›*))
(*goal: ‹h a = None ⟹ h ⊴ h(a ↦ x)›*)
by (auto simp:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))(*>*)
lemma hext_trans: "⟦ h ⊴ h'; h' ⊴ h'' ⟧ ⟹ h ⊴ h''"
(*<*)apply (rule hextI (*‹∀a C fs. ?h a = ⌊(C, fs)⌋ ⟶ (∃fs'. ?h' a = ⌊(C, fs')⌋) ⟹ ?h ⊴ ?h'›*))
(*goal: ‹⟦(h::nat ⇒ (char list × (char list × char list ⇒ val option)) option) ⊴ (h'::nat ⇒ (char list × (char list × char list ⇒ val option)) option); h' ⊴ (h''::nat ⇒ (char list × (char list × char list ⇒ val option)) option)⟧ ⟹ h ⊴ h''›*)
by (fast dest: hext_objD (*‹⟦(?h::nat ⇒ (char list × (char list × char list ⇒ val option)) option) ⊴ (?h'::nat ⇒ (char list × (char list × char list ⇒ val option)) option); ?h (?a::nat) = ⌊(?C::char list, ?fs::char list × char list ⇒ val option)⌋⟧ ⟹ ∃fs'::char list × char list ⇒ val option. ?h' ?a = ⌊(?C, fs')⌋›*))(*>*)
lemma hext_upd_obj: "h a = Some (C,fs) ⟹ h ⊴ h(a↦(C,fs'))"
(*<*)apply (rule hextI (*‹∀a C fs. ?h a = ⌊(C, fs)⌋ ⟶ (∃fs'. ?h' a = ⌊(C, fs')⌋) ⟹ ?h ⊴ ?h'›*))
(*goal: ‹(h::nat ⇒ (char list × (char list × char list ⇒ val option)) option) (a::nat) = ⌊(C::char list, fs::char list × char list ⇒ val option)⌋ ⟹ h ⊴ h(a ↦ (C, fs'::char list × char list ⇒ val option))›*)
by (auto simp:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))(*>*)
lemma hext_typeof_mono: "⟦ h ⊴ h'; typeof⇘h⇙ v = Some T ⟧ ⟹ typeof⇘h'⇙ v = Some T"
(*<*)
proof (cases v)
(*goals:
1. ‹⟦h ⊴ h'; typeof⇘h⇙ v = ⌊T⌋; v = Unit⟧ ⟹ typeof⇘h'⇙ v = ⌊T⌋›
2. ‹⟦h ⊴ h'; typeof⇘h⇙ v = ⌊T⌋; v = Null⟧ ⟹ typeof⇘h'⇙ v = ⌊T⌋›
3. ‹⋀x3. ⟦h ⊴ h'; typeof⇘h⇙ v = ⌊T⌋; v = Bool x3⟧ ⟹ typeof⇘h'⇙ v = ⌊T⌋›
4. ‹⋀x4. ⟦h ⊴ h'; typeof⇘h⇙ v = ⌊T⌋; v = Intg x4⟧ ⟹ typeof⇘h'⇙ v = ⌊T⌋›
5. ‹⋀x5. ⟦h ⊴ h'; typeof⇘h⇙ v = ⌊T⌋; v = Addr x5⟧ ⟹ typeof⇘h'⇙ v = ⌊T⌋›*)
case Addr (*‹v = Addr x5_›*)
assume "h ⊴ h'" and "typeof⇘h⇙ v = ⌊T⌋" (*‹(h::nat ⇒ (char list × (char list × char list ⇒ val option)) option) ⊴ (h'::nat ⇒ (char list × (char list × char list ⇒ val option)) option)› ‹typeof⇘h::nat ⇒ (char list × (char list × char list ⇒ val option)) option⇙ (v::val) = ⌊T::ty⌋›*)
then show "?thesis"
(*goal: ‹typeof⇘h'::nat ⇒ (char list × (char list × char list ⇒ val option)) option⇙ (v::val) = ⌊T::ty⌋›*)
using Addr (*‹v = Addr x5_›*) by (fastforce simp:hext_def (*‹?h ⊴ ?h' ≡ ∀a C fs. ?h a = ⌊(C, fs)⌋ ⟶ (∃fs'. ?h' a = ⌊(C, fs')⌋)›*))
qed (simp_all)
(*solves the remaining goals:
1. ‹⟦h ⊴ h'; typeof⇘h⇙ v = ⌊T⌋; v = Unit⟧ ⟹ typeof⇘h'⇙ v = ⌊T⌋›
2. ‹⟦h ⊴ h'; typeof⇘h⇙ v = ⌊T⌋; v = Null⟧ ⟹ typeof⇘h'⇙ v = ⌊T⌋›
3. ‹⋀x3. ⟦h ⊴ h'; typeof⇘h⇙ v = ⌊T⌋; v = Bool x3⟧ ⟹ typeof⇘h'⇙ v = ⌊T⌋›
4. ‹⋀x4. ⟦h ⊴ h'; typeof⇘h⇙ v = ⌊T⌋; v = Intg x4⟧ ⟹ typeof⇘h'⇙ v = ⌊T⌋›*)
(*>*)
text ‹Code generator setup for @{term "new_Addr"}›
definition gen_new_Addr :: "heap ⇒ addr ⇒ addr option"
where "gen_new_Addr h n ≡ if ∃a. a ≥ n ∧ h a = None then Some(LEAST a. a ≥ n ∧ h a = None) else None"
lemma new_Addr_code_code [code]:
"new_Addr h = gen_new_Addr h 0"
by (simp add: new_Addr_def (*‹new_Addr ?h ≡ if ∃a. ?h a = None then ⌊LEAST a. ?h a = None⌋ else None›*) gen_new_Addr_def (*‹gen_new_Addr ?h ?n ≡ if ∃a≥?n. ?h a = None then ⌊LEAST a. ?n ≤ a ∧ ?h a = None⌋ else None›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*))
lemma gen_new_Addr_code [code]:
"gen_new_Addr h n = (if h n = None then Some n else gen_new_Addr h (Suc n))"
apply (simp add: gen_new_Addr_def (*‹gen_new_Addr ?h ?n ≡ if ∃a≥?n. ?h a = None then ⌊LEAST a. ?n ≤ a ∧ ?h a = None⌋ else None›*))
(*goal: ‹gen_new_Addr h n = (if h n = None then ⌊n⌋ else gen_new_Addr h (Suc n))›*)
apply (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹(∃a≥n. h a = None) ⟶ ((∃a≥Suc n. h a = None) ⟶ (h n = None ⟶ (LEAST a. n ≤ a ∧ h a = None) = n) ∧ ((∃a b. h n = ⌊(a, b)⌋) ⟶ (LEAST a. n ≤ a ∧ h a = None) = (LEAST a. Suc n ≤ a ∧ h a = None))) ∧ ((∀a≥Suc n. ∃aa b. h a = ⌊(aa, b)⌋) ⟶ (h n = None ⟶ (LEAST a. n ≤ a ∧ h a = None) = n) ∧ (∀a b. h n ≠ ⌊(a, b)⌋))›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹∃a≥n. h a = None ⟹ (∃a≥Suc n. h a = None) ⟶ (h n = None ⟶ (LEAST a. n ≤ a ∧ h a = None) = n) ∧ ((∃a b. h n = ⌊(a, b)⌋) ⟶ (LEAST a. n ≤ a ∧ h a = None) = (LEAST a. Suc n ≤ a ∧ h a = None))›
2. ‹∃a≥n. h a = None ⟹ (∀a≥Suc n. ∃aa b. h a = ⌊(aa, b)⌋) ⟶ (h n = None ⟶ (LEAST a. n ≤ a ∧ h a = None) = n) ∧ (∀a b. h n ≠ ⌊(a, b)⌋)›
discuss goal 1*)
apply ((safe)[1])
(*goals:
1. ‹⋀(a::nat) aa::nat. ⟦(n::nat) ≤ a; (h::nat ⇒ (char list × (char list × char list ⇒ val option)) option) a = None; Suc n ≤ aa; h aa = None; h n = None⟧ ⟹ (LEAST a::nat. n ≤ a ∧ h a = None) = n›
2. ‹⋀(a::nat) (aa::nat) (ab::char list) b::char list × char list ⇒ val option. ⟦(n::nat) ≤ a; (h::nat ⇒ (char list × (char list × char list ⇒ val option)) option) a = None; Suc n ≤ aa; h aa = None; h n = ⌊(ab, b)⌋⟧ ⟹ (LEAST a::nat. n ≤ a ∧ h a = None) = (LEAST a::nat. Suc n ≤ a ∧ h a = None)›
discuss goal 1*)
apply ((fastforce intro: Least_equality (*‹⟦?P ?x; ⋀y. ?P y ⟹ ?x ≤ y⟧ ⟹ Least ?P = ?x›*))[1])
(*discuss goal 2*)
apply (rule arg_cong[where f=Least] (*‹?x = ?y ⟹ Least ?x = Least ?y›*))
(*top goal: ‹⋀a aa ab b. ⟦n ≤ a; h a = None; Suc n ≤ aa; h aa = None; h n = ⌊(ab, b)⌋⟧ ⟹ (LEAST a. n ≤ a ∧ h a = None) = (LEAST a. Suc n ≤ a ∧ h a = None)› and 1 goal remains*)
apply (rule ext (*‹(⋀x::?'a::type. (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x) ⟹ ?f = ?g›*))
(*top goal: ‹⋀a aa ab b. ⟦n ≤ a; h a = None; Suc n ≤ aa; h aa = None; h n = ⌊(ab, b)⌋⟧ ⟹ (λa. n ≤ a ∧ h a = None) = (λa. Suc n ≤ a ∧ h a = None)› and 1 goal remains*)
apply ((case_tac "n = ac")[1])
(*goals:
1. ‹⋀(a::nat) (aa::nat) (ab::char list) (b::char list × char list ⇒ val option) ac::nat. ⟦(n::nat) ≤ a; (h::nat ⇒ (char list × (char list × char list ⇒ val option)) option) a = None; Suc n ≤ aa; h aa = None; h n = ⌊(ab, b)⌋; n = ac⟧ ⟹ (n ≤ ac ∧ h ac = None) = (Suc n ≤ ac ∧ h ac = None)›
2. ‹⋀(a::nat) (aa::nat) (ab::char list) (b::char list × char list ⇒ val option) ac::nat. ⟦(n::nat) ≤ a; (h::nat ⇒ (char list × (char list × char list ⇒ val option)) option) a = None; Suc n ≤ aa; h aa = None; h n = ⌊(ab, b)⌋; n ≠ ac⟧ ⟹ (n ≤ ac ∧ h ac = None) = (Suc n ≤ ac ∧ h ac = None)›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*)
(*proven 2 subgoals*)
(*discuss goal 2*)
apply ((clarify)[1])
(*goal: ‹∃a≥n. h a = None ⟹ (∀a≥Suc n. ∃aa b. h a = ⌊(aa, b)⌋) ⟶ (h n = None ⟶ (LEAST a. n ≤ a ∧ h a = None) = n) ∧ (∀a b. h n ≠ ⌊(a, b)⌋)›*)
apply ((subgoal_tac "a = n")[1])
(*goals:
1. ‹⋀a. ⟦n ≤ a; h a = None; ∀a≥Suc n. ∃aa b. h a = ⌊(aa, b)⌋; a = n⟧ ⟹ (h n = None ⟶ (LEAST a. n ≤ a ∧ h a = None) = n) ∧ (∀a b. h n ≠ ⌊(a, b)⌋)›
2. ‹⋀a. ⟦n ≤ a; h a = None; ∀a≥Suc n. ∃aa b. h a = ⌊(aa, b)⌋⟧ ⟹ a = n›
discuss goal 1*)
apply simp
(*top goal: ‹⋀a. ⟦n ≤ a; h a = None; ∀a≥Suc n. ∃aa b. h a = ⌊(aa, b)⌋; a = n⟧ ⟹ (h n = None ⟶ (LEAST a. n ≤ a ∧ h a = None) = n) ∧ (∀a b. h n ≠ ⌊(a, b)⌋)› and 1 goal remains*)
apply (rule Least_equality (*‹⟦(?P::?'a ⇒ bool) (?x::?'a); ⋀y::?'a. ?P y ⟹ ?x ≤ y⟧ ⟹ Least ?P = ?x›*))
(*goals:
1. ‹⋀a. ⟦h n = None; ∀a≥Suc n. ∃aa b. h a = ⌊(aa, b)⌋; a = n⟧ ⟹ n ≤ n ∧ h n = None›
2. ‹⋀a y. ⟦h n = None; ∀a≥Suc n. ∃aa b. h a = ⌊(aa, b)⌋; a = n; n ≤ y ∧ h y = None⟧ ⟹ n ≤ y›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*)
(*discuss goal 2*)
apply (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*))
(*goal: ‹⋀a. ⟦n ≤ a; h a = None; ∀a≥Suc n. ∃aa b. h a = ⌊(aa, b)⌋⟧ ⟹ a = n›*)
apply ((erule_tac x="a" in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*))[1])
(*goal: ‹⋀a::nat. ⟦(n::nat) ≤ a; (h::nat ⇒ (char list × (char list × char list ⇒ val option)) option) a = None; ∀a≥Suc n. ∃(aa::char list) b::char list × char list ⇒ val option. h a = ⌊(aa, b)⌋; a ≠ n⟧ ⟹ False›*)
apply simp
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
end
| {
"path": "afp-2025-02-12/thys/Jinja/Common/Objects.thy",
"repo": "afp-2025-02-12",
"sha": "fb4509bd266f6604c2c7519bb7d5029d678de8d3c13dbb79610f988e6c5ebf8f"
} |
(*
Auction Theory Toolbox (http://formare.github.io/auctions/)
Authors:
* Marco B. Caminati http://caminati.co.nr
* Manfred Kerber <mnfrd.krbr@gmail.com>
* Christoph Lange <math.semantic.web@gmail.com>
* Colin Rowat <c.rowat@bham.ac.uk>
Dually licenced under
* Creative Commons Attribution (CC-BY) 3.0
* ISC License (1-clause BSD License)
See LICENSE file for details
(Rationale for this dual licence: http://arxiv.org/abs/1107.3212)
*)
section ‹Additional material that we would have expected in Set.thy›
theory SetUtils
imports
Main
begin
subsection ‹Equality›
text ‹An inference (introduction) rule that combines @{thm equalityI} and @{thm subsetI} to a single step›
lemma equalitySubsetI: "(⋀x . x ∈ A ⟹ x ∈ B) ⟹ (⋀x . x ∈ B ⟹ x ∈ A) ⟹ A = B"
by blast
subsection ‹Trivial sets›
text ‹A trivial set (i.e. singleton or empty), as in Mizar›
definition trivial where "trivial x = (x ⊆ {the_elem x})"
text ‹The empty set is trivial.›
lemma trivial_empty: "trivial {}"
unfolding trivial_def
(*goal: ‹{} ⊆ {the_elem {}}›*)
by (rule empty_subsetI (*‹{} ⊆ ?A›*))
text ‹A singleton set is trivial.›
lemma trivial_singleton: "trivial {x}"
unfolding trivial_def
(*goal: ‹{x} ⊆ {the_elem {x}}›*)
by simp
text ‹If a trivial set has a singleton subset, the latter is unique.›
lemma singleton_sub_trivial_uniq:
fixes x X
assumes "{x} ⊆ X" and "trivial X"
shows "x = the_elem X"
(* CL: The following takes 16 ms in Isabelle2013-1-RC1:
by (metis assms(1) assms(2) insert_not_empty insert_subset subset_empty subset_insert trivial_def trivial_imp_no_distinct) *)
using assms (*‹{x} ⊆ X› ‹trivial X›*) unfolding trivial_def
(*goal: ‹x = the_elem X›*)
by fast
text ‹Any subset of a trivial set is trivial.›
lemma trivial_subset: fixes X Y assumes "trivial Y" assumes "X ⊆ Y"
shows "trivial X"
(* CL: The following takes 36 ms in Isabelle2013-1-RC1:
by (metis assms(1) assms(2) equals0D no_distinct_imp_trivial subsetI subset_antisym subset_singletonD trivial_cases) *)
using assms (*‹trivial (Y::'a::type set)› ‹X ⊆ Y›*) unfolding trivial_def
(*goal: ‹X ⊆ {the_elem X}›*)
by (metis (full_types) subset_empty (*‹(?A ⊆ {}) = (?A = {})›*) subset_insertI2 (*‹?A ⊆ ?B ⟹ ?A ⊆ insert ?b ?B›*) subset_singletonD (*‹?A ⊆ {?x} ⟹ ?A = {} ∨ ?A = {?x}›*))
text ‹There are no two different elements in a trivial set.›
lemma trivial_imp_no_distinct:
assumes triv: "trivial X" and x: "x ∈ X" and y: "y ∈ X"
shows "x = y"
(* CL: The following takes 17 ms in Isabelle2013-1-RC1: *)
using assms (*‹trivial (X::'a set)› ‹x ∈ X› ‹(y::'a::type) ∈ (X::'a::type set)›*) by (metis empty_subsetI (*‹{} ⊆ ?A›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) singleton_sub_trivial_uniq (*‹⟦{?x} ⊆ ?X; trivial ?X⟧ ⟹ ?x = the_elem ?X›*))
subsection ‹The image of a set under a function›
text ‹an equivalent notation for the image of a set, using set comprehension›
lemma image_Collect_mem: "{ f x | x . x ∈ S } = f ` S"
by auto
subsection ‹Big Union›
text ‹An element is in the union of a family of sets if it is in one of the family's member sets.›
lemma Union_member: "(∃ S ∈ F . x ∈ S) ⟷ x ∈ ⋃ F"
by blast
subsection ‹Miscellaneous›
lemma trivial_subset_non_empty: assumes "trivial t" "t ∩ X ≠ {}"
shows "t ⊆ X"
using trivial_def (*‹trivial ?x = (?x ⊆ {the_elem ?x})›*) assms (*‹trivial (t::'a set)› ‹t ∩ X ≠ {}›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*) by fast
lemma trivial_implies_finite: assumes "trivial X"
shows "finite X"
using assms (*‹trivial X›*) by (metis finite.simps (*‹finite (?a::?'a set) = (?a = {} ∨ (∃(A::?'a set) a::?'a. ?a = insert a A ∧ finite A))›*) subset_singletonD (*‹(?A::?'a set) ⊆ {?x::?'a} ⟹ ?A = {} ∨ ?A = {?x}›*) trivial_def (*‹trivial (?x::?'a set) = (?x ⊆ {the_elem ?x})›*))
(* finite.simps trivial_cases by metis *)
lemma lm01: assumes "trivial (A × B)"
shows "(finite (A×B) & card A * (card B) ≤ 1)"
using trivial_def (*‹trivial ?x = (?x ⊆ {the_elem ?x})›*) assms (*‹trivial ((A::'a set) × (B::'b set))›*) One_nat_def (*‹1 = Suc 0›*) card_cartesian_product (*‹card (?A × ?B) = card ?A * card ?B›*) card.empty (*‹card {} = 0›*) card_insert_disjoint (*‹⟦finite ?A; ?x ∉ ?A⟧ ⟹ card (insert ?x ?A) = Suc (card ?A)›*) empty_iff (*‹(?c ∈ {}) = False›*) finite.emptyI (*‹finite {}›*) le0 (*‹0 ≤ ?n›*) trivial_implies_finite (*‹trivial ?X ⟹ finite ?X›*) order_refl (*‹(?x::?'a) ≤ ?x›*) subset_singletonD (*‹?A ⊆ {?x} ⟹ ?A = {} ∨ ?A = {?x}›*) by (metis(no_types))
lemma lm02: assumes "finite X"
shows "trivial X=(card X ≤ 1)"
using assms (*‹finite X›*) One_nat_def (*‹1 = Suc 0›*) card.empty (*‹card {} = 0›*) card_insert_if (*‹finite (?A::?'a set) ⟹ card (insert (?x::?'a) ?A) = (if ?x ∈ ?A then card ?A else Suc (card ?A))›*) card_mono (*‹⟦finite (?B::?'a::type set); (?A::?'a::type set) ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*) card_seteq (*‹⟦finite ?B; ?A ⊆ ?B; card ?B ≤ card ?A⟧ ⟹ ?A = ?B›*) empty_iff (*‹(?c ∈ {}) = False›*) empty_subsetI (*‹{} ⊆ (?A::?'a set)›*) finite.cases (*‹⟦finite ?a; ?a = {} ⟹ ?P; ⋀A a. ⟦?a = insert a A; finite A⟧ ⟹ ?P⟧ ⟹ ?P›*) finite.emptyI (*‹finite {}›*) finite_insert (*‹finite (insert ?a ?A) = finite ?A›*) insert_mono (*‹?C ⊆ ?D ⟹ insert ?a ?C ⊆ insert ?a ?D›*) trivial_def (*‹trivial ?x = (?x ⊆ {the_elem ?x})›*) trivial_singleton (*‹trivial {?x}›*) by (metis(no_types))
lemma lm03: shows "trivial {x}"
by (metis order_refl (*‹?x ≤ ?x›*) the_elem_eq (*‹the_elem {?x} = ?x›*) trivial_def (*‹trivial ?x = (?x ⊆ {the_elem ?x})›*))
lemma lm04: assumes "trivial X" "{x} ⊆ X"
shows "{x} = X"
using singleton_sub_trivial_uniq (*‹⟦{?x::?'a} ⊆ (?X::?'a set); trivial ?X⟧ ⟹ ?x = the_elem ?X›*) assms (*‹trivial X› ‹{x} ⊆ X›*) by (metis subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) trivial_def (*‹trivial ?x = (?x ⊆ {the_elem ?x})›*))
lemma lm05: assumes "¬ trivial X" "trivial T"
shows "X - T ≠ {}"
using assms (*‹¬ trivial X› ‹trivial T›*) by (metis Diff_iff (*‹(?c ∈ ?A - ?B) = (?c ∈ ?A ∧ ?c ∉ ?B)›*) empty_iff (*‹(?c ∈ {}) = False›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) trivial_subset (*‹⟦trivial ?Y; ?X ⊆ ?Y⟧ ⟹ trivial ?X›*))
lemma lm06: assumes "(finite (A × B) & card A * (card B) ≤ 1)"
shows "trivial (A × B)"
unfolding trivial_def
(*goal: ‹A × B ⊆ {the_elem (A × B)}›*)
using trivial_def (*‹trivial ?x = (?x ⊆ {the_elem ?x})›*) assms (*‹finite (A × B) ∧ card A * card B ≤ 1›*) by (metis card_cartesian_product (*‹card ((?A::?'a set) × (?B::?'b set)) = card ?A * card ?B›*) lm02 (*‹finite (?X::?'a set) ⟹ trivial ?X = (card ?X ≤ (1::nat))›*))
lemma lm07: "trivial (A × B) = (finite (A × B) & card A * (card B) ≤ 1)"
using lm01 (*‹trivial ((?A::?'a set) × (?B::?'b set)) ⟹ finite (?A × ?B) ∧ card ?A * card ?B ≤ (1::nat)›*) lm06 (*‹finite (?A × ?B) ∧ card ?A * card ?B ≤ 1 ⟹ trivial (?A × ?B)›*) by blast
lemma trivial_empty_or_singleton: "trivial X = (X = {} ∨ X = {the_elem X})"
by (metis subset_singletonD (*‹?A ⊆ {?x} ⟹ ?A = {} ∨ ?A = {?x}›*) trivial_def (*‹trivial ?x = (?x ⊆ {the_elem ?x})›*) trivial_empty (*‹trivial {}›*) trivial_singleton (*‹trivial {?x}›*))
lemma trivial_cartesian: assumes "trivial X" "trivial Y"
shows "trivial (X × Y)"
using assms (*‹trivial X› ‹trivial Y›*) lm07 (*‹trivial (?A × ?B) = (finite (?A × ?B) ∧ card ?A * card ?B ≤ 1)›*) One_nat_def (*‹1 = Suc 0›*) Sigma_empty1 (*‹Sigma {} ?B = {}›*) Sigma_empty2 (*‹?A × {} = {}›*) card.empty (*‹card {} = (0::nat)›*) card_insert_if (*‹finite ?A ⟹ card (insert ?x ?A) = (if ?x ∈ ?A then card ?A else Suc (card ?A))›*) finite_SigmaI (*‹⟦finite ?A; ⋀a. a ∈ ?A ⟹ finite (?B a)⟧ ⟹ finite (Sigma ?A ?B)›*) trivial_implies_finite (*‹trivial (?X::?'a::type set) ⟹ finite ?X›*) nat_1_eq_mult_iff (*‹(1 = ?m * ?n) = (?m = 1 ∧ ?n = 1)›*) order_refl (*‹(?x::?'a) ≤ ?x›*) subset_singletonD (*‹?A ⊆ {?x} ⟹ ?A = {} ∨ ?A = {?x}›*) trivial_def (*‹trivial ?x = (?x ⊆ {the_elem ?x})›*) trivial_empty (*‹trivial {}›*) by (metis (full_types))
lemma trivial_same: "trivial X = (∀x1 ∈ X. ∀x2 ∈ X. x1 = x2)"
sorry
lemma lm08: assumes "(Pow X ⊆ {{},X})"
shows "trivial X"
unfolding trivial_same
(*goal: ‹∀x1∈X. Ball X ((=) x1)›*)
using assms (*‹Pow X ⊆ {{}, X}›*) by auto
lemma lm09: assumes "trivial X"
shows "(Pow X ⊆ {{},X})"
using assms (*‹trivial X›*) trivial_same (*‹trivial (?X::?'a set) = (∀x1::?'a∈?X. ∀x2::?'a∈?X. x1 = x2)›*) by fast
lemma lm10: "trivial X = (Pow X ⊆ {{},X})"
using lm08 (*‹Pow ?X ⊆ {{}, ?X} ⟹ trivial ?X›*) lm09 (*‹trivial ?X ⟹ Pow ?X ⊆ {{}, ?X}›*) by metis
lemma lm11: "({x} × UNIV) ∩ P = {x} × (P `` {x})"
by fast
lemma lm12: "(x,y) ∈ P = (y ∈ P``{x})"
by simp
lemma lm13: assumes "inj_on f A" "inj_on f B"
shows "inj_on f (A ∪ B) = (f`(A-B) ∩ (f`(B-A)) = {})"
using assms (*‹inj_on f A› ‹inj_on (f::'a ⇒ 'b) (B::'a set)›*) inj_on_Un (*‹inj_on (?f::?'a ⇒ ?'b) ((?A::?'a set) ∪ (?B::?'a set)) = (inj_on ?f ?A ∧ inj_on ?f ?B ∧ ?f ` (?A - ?B) ∩ ?f ` (?B - ?A) = {})›*) by metis
lemma injection_union: assumes "inj_on f A" "inj_on f B" "(f`A) ∩ (f`B) = {}"
shows "inj_on f (A ∪ B)"
using assms (*‹inj_on (f::'a ⇒ 'b) (A::'a set)› ‹inj_on f B› ‹(f::'a ⇒ 'b) ` (A::'a set) ∩ f ` (B::'a set) = {}›*) lm13 (*‹⟦inj_on ?f ?A; inj_on ?f ?B⟧ ⟹ inj_on ?f (?A ∪ ?B) = (?f ` (?A - ?B) ∩ ?f ` (?B - ?A) = {})›*) by fast
lemma lm14: "(Pow X = {X}) = (X={})"
by auto
end
| {
"path": "afp-2025-02-12/thys/Vickrey_Clarke_Groves/SetUtils.thy",
"repo": "afp-2025-02-12",
"sha": "b41bc7d210e1bb7e6c38c0acebbc1072deb33e704f3df7eabe93f1a6da600249"
} |
subsection "Proof"
theory Fun4_secure
imports Fun4
begin
(* THE PROOF OF SECURITY *)
definition "PC ≡ {0..6}"
(*For the counterparts, we chose i=0 to ensure going down the then branch*)
definition "same_xx_cp cfg1 cfg2 ≡
vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx
∧ vstore (getVstore (stateOf cfg1)) xx = 0"
definition "common_memory cfg cfg' cfgs' ≡
array_base aa1 (getAvstore (stateOf cfg)) = array_base aa1 (getAvstore (stateOf cfg')) ∧
(∀cfg''∈set cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg))) ∧
array_base aa2 (getAvstore (stateOf cfg)) = array_base aa2 (getAvstore (stateOf cfg')) ∧
(∀cfg''∈set cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg))) ∧
(getHheap (stateOf cfg)) = (getHheap (stateOf cfg')) ∧
(∀cfg''∈set cfgs'. getHheap (stateOf cfg) = (getHheap (stateOf cfg''))) ∧
(getAvstore (stateOf cfg)) = (getAvstore (stateOf cfg'))"
(* we read "before" as "before or at" *)
definition "beforeInput = {0,1}"
definition "afterInput = {2..6}"
definition "elseBranch = 6"
definition "startOfThenBranch = 4"
definition "inThenBranch = {4..6}"
definition "afterInputNotInElse = {2,3,4,5,6,8}"
definition "inThenBranchBeforeOutput = {3,4,5}"
definition "atCond = 3"
definition "atThenOutput = 5"
definition "atJump = 6"
(* Common to all the unwinding relations in this proof: *)
definition common_strat1 :: "stateO ⇒ stateO ⇒ status ⇒ stateV ⇒ stateV ⇒ status ⇒ bool"
where
"common_strat1 =
(λ (pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO.
(pstate3 = pstate4 ∧
cfg1 = cfg3 ∧ cfg2 = cfg4 ∧
pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧
pcOf cfg3 ∈ PC ∧ pcOf ` (set cfgs3) ⊆ PC ∧
⌦‹tr1 and tr3 have common memory ›
common_memory cfg1 cfg3 cfgs3 ∧
⌦‹likewise tr2 and tr4 ›
common_memory cfg2 cfg4 cfgs4 ∧
(∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧
array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧
⌦‹ ›
array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧
(∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧
(∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧
array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧
(∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧
(∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧
⌦‹ ›
(statA = Diff ⟶ statO = Diff)))"
lemmas common_strat1_defs = common_strat1_def common_memory_def
(* Common to all the unwinding relations in this proof: *)
definition common :: "enat ⇒ stateO ⇒ stateO ⇒ status ⇒ stateV ⇒ stateV ⇒ status ⇒ bool"
where
"common = (λ(num::enat)
(pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO.
(pstate3 = pstate4 ∧
(num = (endPC - pcOf cfg1) ∨ num = ∞) ∧
⌦‹tr1 and tr2 stay on the same path ›
pcOf cfg1 = pcOf cfg2 ∧
⌦‹likewise tr3 and tr4 ›
pcOf cfg3 = pcOf cfg4 ∧
map pcOf cfgs3 = map pcOf cfgs4 ∧
pcOf cfg3 ∈ PC ∧ pcOf ` (set cfgs3) ⊆ PC ∧
pcOf cfg1 ∈ PC ∧
⌦‹tr1 and tr3 have common memory ›
common_memory cfg1 cfg3 cfgs3 ∧
⌦‹likewise tr2 and tr4 ›
common_memory cfg2 cfg4 cfgs4 ∧
(∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧
array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧
⌦‹All traces have same base addresses
AtoJ: Maybe this is also worth being extracted as a predicate. ›
array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧
(∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧
(∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧
array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧
(∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧
(∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧
(statA = Diff ⟶ statO = Diff)
))"
lemmas common_defs = common_def common_memory_def
lemma common_implies: "common num
(pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO ⟹
pcOf cfg1 < 9 ∧ pcOf cfg3 < 9 ∧
(n≥0 ⟶ array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧
array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1)))"
unfolding common_defs PC_def
(*goal: ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg1 < 9 ∧ pcOf cfg3 < 9 ∧ (0 ≤ n ⟶ array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1)))›*)
by force
(* Before input is inserted *)
definition Δ0 :: "enat ⇒ stateO ⇒ stateO ⇒ status ⇒ stateV ⇒ stateV ⇒ status ⇒ bool" where
"Δ0 = (λnum (pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO.
(common num (pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO ∧
⌦‹head of the buffers are equal counterpartwise ›
(llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧
llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧
(lhd ibUT3 ≥ NN ∧ (lhd ibUT1 = 0) ∧ ibUT1 = ibUT2
∨lhd ibUT3 < NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧
pcOf cfg3 ∈ beforeInput ∧
⌦‹since memory is equal, cfg1=cfg3 and cfg2=cfg4 in 'loading' state›
cfg1 = cfg3 ∧ cfg2 = cfg4 ∧
ls1 = ls3 ∧ ls2 = ls4 ∧
ls1 ={} ∧ ls2={} ∧
noMisSpec cfgs3
))"
lemmas Δ0_defs' = Δ0_def common_defs PC_def beforeInput_def noMisSpec_def
lemma Δ0_def2:
"Δ0 num (pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO
=
(common num (pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO ∧
⌦‹head of the buffers are equal counterpartwise ›
(llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧
llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧
(ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧
(lhd ibUT3 ≥ NN ∧ (lhd ibUT1 = 0) ∧ ibUT1 = ibUT2
∨lhd ibUT3 < NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧
pcOf cfg3 ∈ beforeInput ∧
⌦‹since memory is equal, cfg1=cfg3 and cfg2=cfg4 in 'loading' state›
cfg1 = cfg3 ∧ cfg2 = cfg4 ∧
ls1 = ls3 ∧ ls2 = ls4 ∧
ls1 ={} ∧ ls2={} ∧
noMisSpec cfgs3
)"
unfolding "Δ0_defs'"
(*goal: ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO = ((case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = [])›*)
apply (clarsimp, standard)
(*goal: ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO = ((case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = [])›*)
subgoal for
by (smt (verit) infinity_ne_i0 (*‹∞ ≠ (0::enat)›*) llength_LNil (*‹llength [[]] = (0::enat)›*))
subgoal for
by (smt (verit)) .
lemmas Δ0_defs = Δ0_def2 common_defs PC_def beforeInput_def noMisSpec_def
lemma Δ0_implies: "Δ0 num (pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO ⟹
(pcOf cfg3 = 1 ⟶ ibUT3 ≠ LNil) ∧
(pcOf cfg4 = 1 ⟶ ibUT4 ≠ LNil) ∧
pcOf cfg1 < 7 ∧ pcOf cfg2 = pcOf cfg1 ∧
cfgs3 = [] ∧ pcOf cfg3 < 7 ∧
cfgs4 = [] ∧ pcOf cfg4 < 7"
unfolding "Δ0_defs"
(*goal: ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = [] ⟹ (pcOf cfg3 = 1 ⟶ ibUT3 ≠ [[]]) ∧ (pcOf cfg4 = 1 ⟶ ibUT4 ≠ [[]]) ∧ pcOf cfg1 < 7 ∧ pcOf cfg2 = pcOf cfg1 ∧ cfgs3 = [] ∧ pcOf cfg3 < 7 ∧ cfgs4 = [] ∧ pcOf cfg4 < 7›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = [] ⟹ pcOf cfg3 = 1 ⟶ ibUT3 ≠ [[]]›
2. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = [] ⟹ pcOf cfg4 = 1 ⟶ ibUT4 ≠ [[]]›
3. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = [] ⟹ pcOf cfg1 < 7›
4. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = [] ⟹ pcOf cfg2 = pcOf cfg1›
5. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = [] ⟹ cfgs3 = []›
6. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = [] ⟹ pcOf cfg3 < 7›
7. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = [] ⟹ cfgs4 = []›
8. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = [] ⟹ pcOf cfg4 < 7›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*top goal: ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = [] ⟹ cfgs4 = []› and 1 goal remains*)
apply (metis Nil_is_map_conv (*‹([] = map ?f ?xs) = (?xs = [])›*))
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
(* After input is inserted, no mis-speculation *)
definition Δ1 :: "enat ⇒ stateO ⇒ stateO ⇒ status ⇒ stateV ⇒ stateV ⇒ status ⇒ bool" where
"Δ1 = (λnum
(pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO.
(common_strat1 (pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO ∧
pcOf cfg3 ∈ afterInput ∧
same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧
vstore (getVstore (stateOf cfg3)) xx < NN ∧
ls1 = ls3 ∧ ls2 = ls4 ∧
noMisSpec cfgs3
))"
lemmas Δ1_defs = Δ1_def common_strat1_defs PC_def afterInput_def same_var_o_def noMisSpec_def
lemma Δ1_implies: "Δ1 num
(pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO ⟹
pcOf cfg1 < 7 ∧
cfgs3 = [] ∧ pcOf cfg3 ≠ 1 ∧ pcOf cfg3 < 7 ∧
cfgs4 = [] ∧ pcOf cfg4 ≠ 1 ∧ pcOf cfg4 < 7"
unfolding "Δ1_defs"
(*goal: ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ {2..6} ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg1 < 7 ∧ cfgs3 = [] ∧ pcOf cfg3 ≠ 1 ∧ pcOf cfg3 < 7 ∧ cfgs4 = [] ∧ pcOf cfg4 ≠ 1 ∧ pcOf cfg4 < 7›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ {2..6} ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg1 < 7›
2. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ {2..6} ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ cfgs3 = []›
3. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ {2..6} ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg3 ≠ 1›
4. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ {2..6} ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg3 < 7›
5. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ {2..6} ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ cfgs4 = []›
6. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ {2..6} ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg4 ≠ 1›
7. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ {2..6} ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg4 < 7›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*top goal: ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ {2..6} ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ cfgs4 = []› and 2 goals remain*)
apply (metis map_is_Nil_conv (*‹(map ?f ?xs = []) = (?xs = [])›*))
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*proven 7 subgoals*) .
(* Left mis-speculation: *)
definition Δ2 :: "enat ⇒ stateO ⇒ stateO ⇒ status ⇒ stateV ⇒ stateV ⇒ status ⇒ bool" where
"Δ2 = (λnum
(pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO.
(common_strat1
(pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO ∧
pcOf cfg3 = startOfThenBranch ∧
pcOf cfg1 = pcOf cfg3 ∧
pcOf (last cfgs3) = elseBranch ∧
same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧
vstore (getVstore (stateOf cfg3)) xx < NN ∧
ls1 = ls3 ∧ ls2 = ls4 ∧
misSpecL1 cfgs3
))"
lemmas Δ2_defs = Δ2_def common_strat1_defs PC_def same_var_def startOfThenBranch_def
misSpecL1_def elseBranch_def
lemma Δ2_implies: "Δ2 num
(pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO ⟹
pcOf (last cfgs3) = 6 ∧ pcOf cfg3 = 4 ∧
pcOf (last cfgs4) = pcOf (last cfgs3) ∧
pcOf cfg3 = pcOf cfg4 ∧
length cfgs3 = Suc 0 ∧
length cfgs3 = length cfgs4"
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹Δ2 num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf (last cfgs3) = 6 ∧ pcOf cfg3 = 4 ∧ pcOf (last cfgs4) = pcOf (last cfgs3) ∧ pcOf cfg3 = pcOf cfg4 ∧ length cfgs3 = Suc 0 ∧ length cfgs3 = length cfgs4›*)
unfolding "Δ2_defs"
(*goals:
1. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = 4 ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = 6 ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc 0) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf (last cfgs3) = 6›
2. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = 4 ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = 6 ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc 0) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg3 = 4›
3. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = 4 ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = 6 ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc 0) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf (last cfgs4) = pcOf (last cfgs3)›
4. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = 4 ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = 6 ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc 0) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg3 = pcOf cfg4›
5. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = 4 ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = 6 ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc 0) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ length cfgs3 = Suc 0›
6. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = 4 ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = 6 ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc 0) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ length cfgs3 = length cfgs4›*)
(*goals:
1. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = 4 ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = 6 ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc 0) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf (last cfgs3) = 6›
2. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = 4 ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = 6 ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc 0) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg3 = 4›
3. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = 4 ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = 6 ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc 0) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf (last cfgs4) = pcOf (last cfgs3)›
4. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = 4 ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = 6 ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc 0) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg3 = pcOf cfg4›
5. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = 4 ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = 6 ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc 0) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ length cfgs3 = Suc 0›
6. ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = 4 ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = 6 ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc 0) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ length cfgs3 = length cfgs4›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*top goal: ‹(case (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0::nat..6::nat} ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = (4::nat) ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = (6::nat) ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc (0::nat)) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status) ⟹ pcOf (last cfgs4) = pcOf (last cfgs3)› and 3 goals remain*)
apply (metis last_map (*‹?xs ≠ [] ⟹ last (map ?f ?xs) = ?f (last ?xs)›*) map_is_Nil_conv (*‹(map ?f ?xs = []) = (?xs = [])›*))
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*goal: ‹(case (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0::nat..6::nat} ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = (4::nat) ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = (6::nat) ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc (0::nat)) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status) ⟹ length cfgs3 = length cfgs4›*)
apply (metis length_map (*‹length (map ?f ?xs) = length ?xs›*))
(*proven 6 subgoals*) .
(**********************************************)
(**********************************************)
(* After input is inserted and xx ≥ NN in tr3 *)
definition Δ1' :: "enat ⇒ stateO ⇒ stateO ⇒ status ⇒ stateV ⇒ stateV ⇒ status ⇒ bool" where
"Δ1' = (λnum (pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO.
(common num (pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO ∧
⌦‹ ›
pcOf cfg3 ∈ afterInput ∧
same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧
(pcOf cfg1 > 2 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧
vstore (getVstore (stateOf cfg3)) xx ≥ NN ∧
(pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧
ls1 = {} ∧ ls2 = {} ∧
ls1 = ls3 ∧ ls2 = ls4) ∧
(pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))}
∧ ls1 = ls2 ∧ ls3 = ls4) ∧
(Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2) ∧
(pcOf cfg1 ≥ 4 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧
same_xx_cp cfg1 cfg2 ∧
vstore (getVstore (stateOf cfg1)) xx = 0 ∧
ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧
noMisSpec cfgs3
))"
lemmas Δ1'_defs = Δ1'_def common_defs PC_def afterInput_def
same_var_o_def same_xx_cp_def noMisSpec_def inThenBranch_def elseBranch_def
lemma Δ1'_implies: "Δ1' num (pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO ⟹
pcOf cfg1 < 7 ∧ pcOf cfg1 ≠ Suc 0 ∧
pcOf cfg2 = pcOf cfg1 ∧
cfgs3 = [] ∧ pcOf cfg3 < 7 ∧
cfgs4 = [] ∧ pcOf cfg4 < 7"
unfolding "Δ1'_defs"
(*goal: ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ {2..6} ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ {4..6} ∧ pcOf cfg3 = 6) ∧ (vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = 0) ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg1 < 7 ∧ pcOf cfg1 ≠ Suc 0 ∧ pcOf cfg2 = pcOf cfg1 ∧ cfgs3 = [] ∧ pcOf cfg3 < 7 ∧ cfgs4 = [] ∧ pcOf cfg4 < 7›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ {2..6} ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ {4..6} ∧ pcOf cfg3 = 6) ∧ (vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = 0) ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg1 < 7 ∧ pcOf cfg1 ≠ Suc 0 ∧ pcOf cfg2 = pcOf cfg1 ∧ cfgs3 = [] ∧ pcOf cfg3 < 7 ∧ cfgs4 = [] ∧ pcOf cfg4 < 7›*)
apply simp_all
(*top goal: ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ {2..6} ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ {4..6} ∧ pcOf cfg3 = 6) ∧ (vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = 0) ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg1 < 7› and 6 goals remain*)
using Suc_lessI (*‹⟦?m < ?n; Suc ?m ≠ ?n⟧ ⟹ Suc ?m < ?n›*) startOfThenBranch_def (*‹startOfThenBranch = (4::?'a)›*) verit_eq_simplify(10) (*‹num.One ≠ num.Bit0 (?x2.0::num)›*) zero_neq_numeral (*‹(0::?'a) ≠ numeral (?n::num)›*)
(*goals:
1. ‹pstate3 = pstate4 ∧ (num = enat (7 - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ≤ 6 ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3) ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4) ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pcOf cfg3 ∧ pcOf cfg3 ≤ 6 ∧ vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx) ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ≤ 6 ∧ pcOf cfg3 = 6) ∧ vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = [] ⟹ pcOf cfg2 ≠ Suc 0›
2. ‹pstate3 = pstate4 ∧ (num = enat (7 - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ≤ 6 ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3) ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4) ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pcOf cfg3 ∧ pcOf cfg3 ≤ 6 ∧ vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx) ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ≤ 6 ∧ pcOf cfg3 = 6) ∧ vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = [] ⟹ cfgs4 = []›
discuss goal 1*)
apply linarith
(*discuss goal 2*)
apply (metis list.map_disc_iff (*‹(map ?f ?a = []) = (?a = [])›*))
(*proven 2 subgoals*) .
definition Δ3' :: "enat ⇒ stateO ⇒ stateO ⇒ status ⇒ stateV ⇒ stateV ⇒ status ⇒ bool" where
"Δ3' = (λ num (pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO.
(common num (pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO ∧
⌦‹ ›
pcOf cfg3 = elseBranch ∧ cfgs3 ≠ [] ∧
pcOf (last cfgs3) ∈ inThenBranch ∧
pcOf (last cfgs4) = pcOf(last cfgs3) ∧
⌦‹we sync the cp traces with the speculation cfgs3/cfgs4›
pcOf cfg1 = pcOf(last cfgs3) ∧
same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧
(getAvstore (stateOf cfg3)) = (getAvstore (stateOf (last cfgs3))) ∧
(getAvstore (stateOf cfg4)) = (getAvstore (stateOf (last cfgs4))) ∧
same_xx_cp cfg1 cfg2 ∧
ls1 = ls3 ∧ ls2 = ls4 ∧
vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt ∧
vstore (getVstore (stateOf cfg3)) xx ≥ NN ∧
(pcOf cfg1 = 4 ⟶ ls1 = {} ∧ ls2 = {}) ∧
(pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))}
∧ ls2 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg2))}
∧ ls3 = ls4) ∧
(pcOf cfg1 > 4 ⟶same_var vv cfg1 (last cfgs3) ∧ same_var vv cfg2 (last cfgs4)) ∧
misSpecL1 cfgs3
))"
lemmas Δ3'_defs = Δ3'_def common_defs PC_def elseBranch_def
inThenBranch_def startOfThenBranch_def
same_var_o_def same_xx_cp_def misSpecL1_def same_var_def
lemma Δ3'_implies: "Δ3' num (pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO ⟹
pcOf cfg1 < 7 ∧ pcOf cfg1 ≠ Suc 0 ∧
pcOf cfg2 = pcOf cfg1 ∧
pcOf cfg3 < 7 ∧ pcOf cfg4 < 7 ∧
(pcOf (last cfgs3) = 4 ∨ pcOf (last cfgs3) = 5 ∨ pcOf (last cfgs3) = 6) ∧ pcOf cfg3 = 6"
unfolding "Δ3'_defs"
(*goal: ‹(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = 6 ∧ cfgs3 ≠ [] ∧ pcOf (last cfgs3) ∈ {4..6} ∧ pcOf (last cfgs4) = pcOf (last cfgs3) ∧ pcOf cfg1 = pcOf (last cfgs3) ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ getAvstore (stateOf cfg3) = getAvstore (stateOf (last cfgs3)) ∧ getAvstore (stateOf cfg4) = getAvstore (stateOf (last cfgs4)) ∧ (vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = 0) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 = 4 ⟶ ls1 = {} ∧ ls2 = {}) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls2 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg2))} ∧ ls3 = ls4) ∧ (4 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg1)) vv = vstore (getVstore (stateOf (last cfgs3))) vv ∧ vstore (getVstore (stateOf cfg2)) vv = vstore (getVstore (stateOf (last cfgs4))) vv) ∧ length cfgs3 = Suc 0) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ pcOf cfg1 < 7 ∧ pcOf cfg1 ≠ Suc 0 ∧ pcOf cfg2 = pcOf cfg1 ∧ pcOf cfg3 < 7 ∧ pcOf cfg4 < 7 ∧ (pcOf (last cfgs3) = 4 ∨ pcOf (last cfgs3) = 5 ∨ pcOf (last cfgs3) = 6) ∧ pcOf cfg3 = 6›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹(case (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ ((num::enat) = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0::nat..6::nat} ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ pcOf cfg1 ∈ {0::nat..6::nat} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = (6::nat) ∧ cfgs3 ≠ [] ∧ pcOf (last cfgs3) ∈ {4::nat..6::nat} ∧ pcOf (last cfgs4) = pcOf (last cfgs3) ∧ pcOf cfg1 = pcOf (last cfgs3) ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ getAvstore (stateOf cfg3) = getAvstore (stateOf (last cfgs3)) ∧ getAvstore (stateOf cfg4) = getAvstore (stateOf (last cfgs4)) ∧ (vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int)) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 = (4::nat) ⟶ ls1 = {} ∧ ls2 = {}) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls2 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg2))} ∧ ls3 = ls4) ∧ ((4::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg1)) vv = vstore (getVstore (stateOf (last cfgs3))) vv ∧ vstore (getVstore (stateOf cfg2)) vv = vstore (getVstore (stateOf (last cfgs4))) vv) ∧ length cfgs3 = Suc (0::nat)) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status) ⟹ pcOf cfg1 < (7::nat)›
2. ‹(case (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ ((num::enat) = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0::nat..6::nat} ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ pcOf cfg1 ∈ {0::nat..6::nat} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = (6::nat) ∧ cfgs3 ≠ [] ∧ pcOf (last cfgs3) ∈ {4::nat..6::nat} ∧ pcOf (last cfgs4) = pcOf (last cfgs3) ∧ pcOf cfg1 = pcOf (last cfgs3) ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ getAvstore (stateOf cfg3) = getAvstore (stateOf (last cfgs3)) ∧ getAvstore (stateOf cfg4) = getAvstore (stateOf (last cfgs4)) ∧ (vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int)) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 = (4::nat) ⟶ ls1 = {} ∧ ls2 = {}) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls2 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg2))} ∧ ls3 = ls4) ∧ ((4::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg1)) vv = vstore (getVstore (stateOf (last cfgs3))) vv ∧ vstore (getVstore (stateOf cfg2)) vv = vstore (getVstore (stateOf (last cfgs4))) vv) ∧ length cfgs3 = Suc (0::nat)) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status) ⟹ pcOf cfg1 ≠ Suc (0::nat)›
3. ‹(case (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ ((num::enat) = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0::nat..6::nat} ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ pcOf cfg1 ∈ {0::nat..6::nat} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = (6::nat) ∧ cfgs3 ≠ [] ∧ pcOf (last cfgs3) ∈ {4::nat..6::nat} ∧ pcOf (last cfgs4) = pcOf (last cfgs3) ∧ pcOf cfg1 = pcOf (last cfgs3) ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ getAvstore (stateOf cfg3) = getAvstore (stateOf (last cfgs3)) ∧ getAvstore (stateOf cfg4) = getAvstore (stateOf (last cfgs4)) ∧ (vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int)) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 = (4::nat) ⟶ ls1 = {} ∧ ls2 = {}) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls2 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg2))} ∧ ls3 = ls4) ∧ ((4::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg1)) vv = vstore (getVstore (stateOf (last cfgs3))) vv ∧ vstore (getVstore (stateOf cfg2)) vv = vstore (getVstore (stateOf (last cfgs4))) vv) ∧ length cfgs3 = Suc (0::nat)) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status) ⟹ pcOf cfg2 = pcOf cfg1›
4. ‹(case (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ ((num::enat) = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0::nat..6::nat} ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ pcOf cfg1 ∈ {0::nat..6::nat} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = (6::nat) ∧ cfgs3 ≠ [] ∧ pcOf (last cfgs3) ∈ {4::nat..6::nat} ∧ pcOf (last cfgs4) = pcOf (last cfgs3) ∧ pcOf cfg1 = pcOf (last cfgs3) ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ getAvstore (stateOf cfg3) = getAvstore (stateOf (last cfgs3)) ∧ getAvstore (stateOf cfg4) = getAvstore (stateOf (last cfgs4)) ∧ (vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int)) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 = (4::nat) ⟶ ls1 = {} ∧ ls2 = {}) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls2 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg2))} ∧ ls3 = ls4) ∧ ((4::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg1)) vv = vstore (getVstore (stateOf (last cfgs3))) vv ∧ vstore (getVstore (stateOf cfg2)) vv = vstore (getVstore (stateOf (last cfgs4))) vv) ∧ length cfgs3 = Suc (0::nat)) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status) ⟹ pcOf cfg3 < (7::nat)›
5. ‹(case (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ ((num::enat) = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0::nat..6::nat} ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ pcOf cfg1 ∈ {0::nat..6::nat} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = (6::nat) ∧ cfgs3 ≠ [] ∧ pcOf (last cfgs3) ∈ {4::nat..6::nat} ∧ pcOf (last cfgs4) = pcOf (last cfgs3) ∧ pcOf cfg1 = pcOf (last cfgs3) ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ getAvstore (stateOf cfg3) = getAvstore (stateOf (last cfgs3)) ∧ getAvstore (stateOf cfg4) = getAvstore (stateOf (last cfgs4)) ∧ (vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int)) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 = (4::nat) ⟶ ls1 = {} ∧ ls2 = {}) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls2 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg2))} ∧ ls3 = ls4) ∧ ((4::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg1)) vv = vstore (getVstore (stateOf (last cfgs3))) vv ∧ vstore (getVstore (stateOf cfg2)) vv = vstore (getVstore (stateOf (last cfgs4))) vv) ∧ length cfgs3 = Suc (0::nat)) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status) ⟹ pcOf cfg4 < (7::nat)›
6. ‹(case (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ ((num::enat) = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0::nat..6::nat} ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ pcOf cfg1 ∈ {0::nat..6::nat} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = (6::nat) ∧ cfgs3 ≠ [] ∧ pcOf (last cfgs3) ∈ {4::nat..6::nat} ∧ pcOf (last cfgs4) = pcOf (last cfgs3) ∧ pcOf cfg1 = pcOf (last cfgs3) ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ getAvstore (stateOf cfg3) = getAvstore (stateOf (last cfgs3)) ∧ getAvstore (stateOf cfg4) = getAvstore (stateOf (last cfgs4)) ∧ (vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int)) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 = (4::nat) ⟶ ls1 = {} ∧ ls2 = {}) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls2 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg2))} ∧ ls3 = ls4) ∧ ((4::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg1)) vv = vstore (getVstore (stateOf (last cfgs3))) vv ∧ vstore (getVstore (stateOf cfg2)) vv = vstore (getVstore (stateOf (last cfgs4))) vv) ∧ length cfgs3 = Suc (0::nat)) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status) ⟹ pcOf (last cfgs3) = (4::nat) ∨ pcOf (last cfgs3) = (5::nat) ∨ pcOf (last cfgs3) = (6::nat)›
7. ‹(case (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ ((num::enat) = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0::nat..6::nat} ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ pcOf cfg1 ∈ {0::nat..6::nat} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = (6::nat) ∧ cfgs3 ≠ [] ∧ pcOf (last cfgs3) ∈ {4::nat..6::nat} ∧ pcOf (last cfgs4) = pcOf (last cfgs3) ∧ pcOf cfg1 = pcOf (last cfgs3) ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ getAvstore (stateOf cfg3) = getAvstore (stateOf (last cfgs3)) ∧ getAvstore (stateOf cfg4) = getAvstore (stateOf (last cfgs4)) ∧ (vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int)) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 = (4::nat) ⟶ ls1 = {} ∧ ls2 = {}) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls2 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg2))} ∧ ls3 = ls4) ∧ ((4::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg1)) vv = vstore (getVstore (stateOf (last cfgs3))) vv ∧ vstore (getVstore (stateOf cfg2)) vv = vstore (getVstore (stateOf (last cfgs4))) vv) ∧ length cfgs3 = Suc (0::nat)) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status) ⟹ pcOf cfg3 = (6::nat)›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*top goal: ‹(case (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ ((num::enat) = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0::nat..6::nat} ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ pcOf cfg1 ∈ {0::nat..6::nat} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = (6::nat) ∧ cfgs3 ≠ [] ∧ pcOf (last cfgs3) ∈ {4::nat..6::nat} ∧ pcOf (last cfgs4) = pcOf (last cfgs3) ∧ pcOf cfg1 = pcOf (last cfgs3) ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ getAvstore (stateOf cfg3) = getAvstore (stateOf (last cfgs3)) ∧ getAvstore (stateOf cfg4) = getAvstore (stateOf (last cfgs4)) ∧ (vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int)) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 = (4::nat) ⟶ ls1 = {} ∧ ls2 = {}) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls2 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg2))} ∧ ls3 = ls4) ∧ ((4::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg1)) vv = vstore (getVstore (stateOf (last cfgs3))) vv ∧ vstore (getVstore (stateOf cfg2)) vv = vstore (getVstore (stateOf (last cfgs4))) vv) ∧ length cfgs3 = Suc (0::nat)) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status) ⟹ pcOf (last cfgs3) = (4::nat) ∨ pcOf (last cfgs3) = (5::nat) ∨ pcOf (last cfgs3) = (6::nat)› and 1 goal remains*)
apply (metis cases_thenBranch (*‹?i < 4 ∨ ?i = 4 ∨ ?i = 5 ∨ ?i = 6 ∨ 6 < ?i›*) le_neq_implies_less (*‹⟦?m ≤ ?n; ?m ≠ ?n⟧ ⟹ ?m < ?n›*) less_SucI (*‹?m < ?n ⟹ ?m < Suc ?n›*) not_less_eq (*‹(¬ ?m < ?n) = (?n < Suc ?m)›*))
(*discuss goal 7*)
apply simp
(*proven 7 subgoals*) .
(************************************************)
(* End: *)
definition Δe :: "enat ⇒ stateO ⇒ stateO ⇒ status ⇒ stateV ⇒ stateV ⇒ status ⇒ bool" where
"Δe = (λ(num::enat) (pstate3,cfg3,cfgs3,ibT3,ibUT3,ls3)
(pstate4,cfg4,cfgs4,ibT4,ibUT4,ls4)
statA
(cfg1,ibT1,ibUT1,ls1)
(cfg2,ibT2,ibUT2,ls2)
statO.
((num = (endPC - pcOf cfg1) ∨ num = ∞) ∧
pcOf cfg3 = endPC ∧ pcOf cfg4 = endPC ∧ cfgs3 = [] ∧ cfgs4 = [] ∧
pcOf cfg1 = endPC ∧ pcOf cfg2 = endPC))"
lemmas Δe_defs = Δe_def common_def endPC
(* *)
context array_nempty
begin
lemma init: "initCond Δ0"
unfolding initCond_def
(*goal: ‹∀(s1::predState × config × config list × int llist × int llist × nat set) s2::predState × config × config list × int llist × int llist × nat set. istateO s1 ∧ istateO s2 ⟶ (∃(sv1::config × int llist × int llist × nat set) sv2::config × int llist × int llist × nat set. istateV sv1 ∧ istateV sv2 ∧ corrState sv1 s1 ∧ corrState sv2 s2 ∧ Δ0 ∞ s1 s2 status.Eq sv1 sv2 status.Eq)›*)
apply (intro allI (*‹(⋀x::?'a::type. (?P::?'a::type ⇒ bool) x) ⟹ ∀x::?'a::type. ?P x›*))
(*goal: ‹∀s1 s2. istateO s1 ∧ istateO s2 ⟶ (∃sv1 sv2. istateV sv1 ∧ istateV sv2 ∧ corrState sv1 s1 ∧ corrState sv2 s2 ∧ Δ0 ∞ s1 s2 status.Eq sv1 sv2 status.Eq)›*)
subgoal for s3 and s4
apply (cases s3, cases s4)
(*goal: ‹istateO s3 ∧ istateO s4 ⟶ (∃sv1 sv2. istateV sv1 ∧ istateV sv2 ∧ corrState sv1 s3 ∧ corrState sv2 s4 ∧ Δ0 ∞ s3 s4 status.Eq sv1 sv2 status.Eq)›*)
subgoal for pstate3 and cfg3 and cfgs3 and ibT3 and ibUT3 and ls3 and pstate4 and cfg4 and cfgs4 and ibT4 and ibUT4 and ls4
apply safe
(*goal: ‹⟦(s3::predState × config × config list × int llist × int llist × nat set) = (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set); (s4::predState × config × config list × int llist × int llist × nat set) = (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set)⟧ ⟹ istateO s3 ∧ istateO s4 ⟶ (∃(sv1::config × int llist × int llist × nat set) sv2::config × int llist × int llist × nat set. istateV sv1 ∧ istateV sv2 ∧ corrState sv1 s3 ∧ corrState sv2 s4 ∧ Δ0 ∞ s3 s4 status.Eq sv1 sv2 status.Eq)›*)
apply clarsimp
(*goal: ‹⟦s4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4); s3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3); istateO (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3); istateO (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)⟧ ⟹ ∃sv1 sv2. istateV sv1 ∧ istateV sv2 ∧ corrState sv1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ∧ corrState sv2 (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) ∧ Δ0 ∞ (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) status.Eq sv1 sv2 status.Eq›*)
apply (cases "lhd ibUT3 < NN")
(*goal: ‹⟦s4 = (initPstate, cfg4, [], ibT4, ibUT4, {}); s3 = (initPstate, cfg3, [], ibT3, ibUT3, {}); pstate3 = initPstate; pstate4 = initPstate; pcOf cfg3 = 0; pcOf cfg4 = 0; ls3 = {}; ls4 = {}; initAvstore (getAvstore (stateOf cfg3)); initAvstore (getAvstore (stateOf cfg4)); cfgs3 = []; cfgs4 = []; llength ibT3 = ∞; llength ibUT3 = ∞; llength ibT4 = ∞; llength ibUT4 = ∞⟧ ⟹ ∃a. pcOf a = 0 ∧ initAvstore (getAvstore (stateOf a)) ∧ (∃aa. llength aa = ∞ ∧ (∃ab. llength ab = ∞ ∧ (∃ac. pcOf ac = 0 ∧ initAvstore (getAvstore (stateOf ac)) ∧ (∃ad. llength ad = ∞ ∧ (∃ae. llength ae = ∞ ∧ Δ0 ∞ (initPstate, cfg3, [], ibT3, ibUT3, {}) (initPstate, cfg4, [], ibT4, ibUT4, {}) status.Eq (a, aa, ab, {}) (ac, ad, ae, {}) status.Eq)))))›*)
subgoal for
apply (cases "getAvstore (stateOf cfg3)", cases "getAvstore (stateOf cfg4)")
(*goal: ‹⟦s4 = (initPstate, cfg4, [], ibT4, ibUT4, {}); s3 = (initPstate, cfg3, [], ibT3, ibUT3, {}); pstate3 = initPstate; pstate4 = initPstate; pcOf cfg3 = 0; pcOf cfg4 = 0; ls3 = {}; ls4 = {}; initAvstore (getAvstore (stateOf cfg3)); initAvstore (getAvstore (stateOf cfg4)); cfgs3 = []; cfgs4 = []; llength ibT3 = ∞; llength ibUT3 = ∞; llength ibT4 = ∞; llength ibUT4 = ∞; lhd ibUT3 < int NN⟧ ⟹ ∃a. pcOf a = 0 ∧ initAvstore (getAvstore (stateOf a)) ∧ (∃aa. llength aa = ∞ ∧ (∃ab. llength ab = ∞ ∧ (∃ac. pcOf ac = 0 ∧ initAvstore (getAvstore (stateOf ac)) ∧ (∃ad. llength ad = ∞ ∧ (∃ae. llength ae = ∞ ∧ Δ0 ∞ (initPstate, cfg3, [], ibT3, ibUT3, {}) (initPstate, cfg4, [], ibT4, ibUT4, {}) status.Eq (a, aa, ab, {}) (ac, ad, ae, {}) status.Eq)))))›*)
unfolding "Δ0_defs"
(*goal: ‹⋀(x::char list ⇒ nat × nat) xa::char list ⇒ nat × nat. ⟦(s4::predState × config × config list × int llist × int llist × nat set) = (initPstate, cfg4::config, [], ibT4::int llist, ibUT4::int llist, {}); (s3::predState × config × config list × int llist × int llist × nat set) = (initPstate, cfg3::config, [], ibT3::int llist, ibUT3::int llist, {}); (pstate3::predState) = initPstate; (pstate4::predState) = initPstate; pcOf cfg3 = (0::nat); pcOf cfg4 = (0::nat); (ls3::nat set) = {}; (ls4::nat set) = {}; initAvstore (getAvstore (stateOf cfg3)); initAvstore (getAvstore (stateOf cfg4)); (cfgs3::config list) = []; (cfgs4::config list) = []; llength ibT3 = ∞; llength ibUT3 = ∞; llength ibT4 = ∞; llength ibUT4 = ∞; lhd ibUT3 < int NN; getAvstore (stateOf cfg3) = Avstore x; getAvstore (stateOf cfg4) = Avstore xa⟧ ⟹ ∃a::config. pcOf a = (0::nat) ∧ initAvstore (getAvstore (stateOf a)) ∧ (∃aa::int llist. llength aa = ∞ ∧ (∃ab::int llist. llength ab = ∞ ∧ (∃ac::config. pcOf ac = (0::nat) ∧ initAvstore (getAvstore (stateOf ac)) ∧ (∃ad::int llist. llength ad = ∞ ∧ (∃ae::int llist. llength ae = ∞ ∧ (case (initPstate, cfg3, [], ibT3, ibUT3, {}) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (∞ = enat (endPC - pcOf cfg1) ∨ ∞ = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0::nat..6::nat} ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ pcOf cfg1 ∈ {0::nat..6::nat} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (initPstate, cfg4, [], ibT4, ibUT4, {}) status.Eq (a, aa, ab, {}) (ac, ad, ae, {}) status.Eq ∧ (llength ab = ∞ ∧ llength ae = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (ab ≠ [[]] ∧ ae ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ab = (0::int) ∧ ab = ae ∨ lhd ibUT3 < int NN ∧ ab = ibUT3 ∧ ae = ibUT4) ∧ pcOf cfg3 ∈ {0::nat, 1::nat} ∧ a = cfg3 ∧ ac = cfg4 ∧ {} = {} ∧ {} = {} ∧ {} = {} ∧ {} = {} ∧ [] = [])))))›*)
unfolding array_base_def array_loc_def
(*goal: ‹⋀x xa. ⟦s4 = (initPstate, cfg4, [], ibT4, ibUT4, {}); s3 = (initPstate, cfg3, [], ibT3, ibUT3, {}); pstate3 = initPstate; pstate4 = initPstate; pcOf cfg3 = 0; pcOf cfg4 = 0; ls3 = {}; ls4 = {}; initAvstore (getAvstore (stateOf cfg3)); initAvstore (getAvstore (stateOf cfg4)); cfgs3 = []; cfgs4 = []; llength ibT3 = ∞; llength ibUT3 = ∞; llength ibT4 = ∞; llength ibUT4 = ∞; lhd ibUT3 < int NN; getAvstore (stateOf cfg3) = Avstore x; getAvstore (stateOf cfg4) = Avstore xa⟧ ⟹ ∃a. pcOf a = 0 ∧ initAvstore (getAvstore (stateOf a)) ∧ (∃aa. llength aa = ∞ ∧ (∃ab. llength ab = ∞ ∧ (∃ac. pcOf ac = 0 ∧ initAvstore (getAvstore (stateOf ac)) ∧ (∃ad. llength ad = ∞ ∧ (∃ae. llength ae = ∞ ∧ (case (initPstate, cfg3, [], ibT3, ibUT3, {}) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (∞ = enat (endPC - pcOf cfg1) ∨ ∞ = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ ((case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa1)) ∧ (∀cfg''∈set cfgs3. (case getAvstore (stateOf cfg'') of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa1))) ∧ (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa2)) ∧ (∀cfg''∈set cfgs3. (case getAvstore (stateOf cfg'') of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa2))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ ((case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa1)) ∧ (∀cfg''∈set cfgs4. (case getAvstore (stateOf cfg'') of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa1))) ∧ (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa2)) ∧ (∀cfg''∈set cfgs4. (case getAvstore (stateOf cfg'') of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa1)) + 0 ≠ (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa2)) + n ∧ (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa1)) + 0 ≠ (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa2)) + n) ∧ (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa1)) ∧ (∀cfg3'∈set cfgs3. (case getAvstore (stateOf cfg3') of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa1))) ∧ (∀cfg4'∈set cfgs4. (case getAvstore (stateOf cfg4') of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa1))) ∧ (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa2)) ∧ (∀cfg3'∈set cfgs3. (case getAvstore (stateOf cfg3') of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa2))) ∧ (∀cfg4'∈set cfgs4. (case getAvstore (stateOf cfg4') of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa2))) ∧ (statA = Diff ⟶ statO = Diff)) (initPstate, cfg4, [], ibT4, ibUT4, {}) status.Eq (a, aa, ab, {}) (ac, ad, ae, {}) status.Eq ∧ (llength ab = ∞ ∧ llength ae = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (ab ≠ [[]] ∧ ae ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]]) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ab = 0 ∧ ab = ae ∨ lhd ibUT3 < int NN ∧ ab = ibUT3 ∧ ae = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ a = cfg3 ∧ ac = cfg4 ∧ {} = {} ∧ {} = {} ∧ {} = {} ∧ {} = {} ∧ [] = [])))))›*)
using aa1 (*‹0 < size_aa1›*) by auto
subgoal for
apply (cases "getAvstore (stateOf cfg3)", cases "getAvstore (stateOf cfg4)")
(*goal: ‹⟦s4 = (initPstate, cfg4, [], ibT4, ibUT4, {}); s3 = (initPstate, cfg3, [], ibT3, ibUT3, {}); pstate3 = initPstate; pstate4 = initPstate; pcOf cfg3 = 0; pcOf cfg4 = 0; ls3 = {}; ls4 = {}; initAvstore (getAvstore (stateOf cfg3)); initAvstore (getAvstore (stateOf cfg4)); cfgs3 = []; cfgs4 = []; llength ibT3 = ∞; llength ibUT3 = ∞; llength ibT4 = ∞; llength ibUT4 = ∞; ¬ lhd ibUT3 < int NN⟧ ⟹ ∃a. pcOf a = 0 ∧ initAvstore (getAvstore (stateOf a)) ∧ (∃aa. llength aa = ∞ ∧ (∃ab. llength ab = ∞ ∧ (∃ac. pcOf ac = 0 ∧ initAvstore (getAvstore (stateOf ac)) ∧ (∃ad. llength ad = ∞ ∧ (∃ae. llength ae = ∞ ∧ Δ0 ∞ (initPstate, cfg3, [], ibT3, ibUT3, {}) (initPstate, cfg4, [], ibT4, ibUT4, {}) status.Eq (a, aa, ab, {}) (ac, ad, ae, {}) status.Eq)))))›*)
unfolding "Δ0_defs'"
(*goal: ‹⋀x xa. ⟦s4 = (initPstate, cfg4, [], ibT4, ibUT4, {}); s3 = (initPstate, cfg3, [], ibT3, ibUT3, {}); pstate3 = initPstate; pstate4 = initPstate; pcOf cfg3 = 0; pcOf cfg4 = 0; ls3 = {}; ls4 = {}; initAvstore (getAvstore (stateOf cfg3)); initAvstore (getAvstore (stateOf cfg4)); cfgs3 = []; cfgs4 = []; llength ibT3 = ∞; llength ibUT3 = ∞; llength ibT4 = ∞; llength ibUT4 = ∞; ¬ lhd ibUT3 < int NN; getAvstore (stateOf cfg3) = Avstore x; getAvstore (stateOf cfg4) = Avstore xa⟧ ⟹ ∃a. pcOf a = 0 ∧ initAvstore (getAvstore (stateOf a)) ∧ (∃aa. llength aa = ∞ ∧ (∃ab. llength ab = ∞ ∧ (∃ac. pcOf ac = 0 ∧ initAvstore (getAvstore (stateOf ac)) ∧ (∃ad. llength ad = ∞ ∧ (∃ae. llength ae = ∞ ∧ (case (initPstate, cfg3, [], ibT3, ibUT3, {}) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (∞ = enat (endPC - pcOf cfg1) ∨ ∞ = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = []) (initPstate, cfg4, [], ibT4, ibUT4, {}) status.Eq (a, aa, ab, {}) (ac, ad, ae, {}) status.Eq)))))›*)
unfolding array_base_def array_loc_def
(*goal: ‹⋀x xa. ⟦s4 = (initPstate, cfg4, [], ibT4, ibUT4, {}); s3 = (initPstate, cfg3, [], ibT3, ibUT3, {}); pstate3 = initPstate; pstate4 = initPstate; pcOf cfg3 = 0; pcOf cfg4 = 0; ls3 = {}; ls4 = {}; initAvstore (getAvstore (stateOf cfg3)); initAvstore (getAvstore (stateOf cfg4)); cfgs3 = []; cfgs4 = []; llength ibT3 = ∞; llength ibUT3 = ∞; llength ibT4 = ∞; llength ibUT4 = ∞; ¬ lhd ibUT3 < int NN; getAvstore (stateOf cfg3) = Avstore x; getAvstore (stateOf cfg4) = Avstore xa⟧ ⟹ ∃a. pcOf a = 0 ∧ initAvstore (getAvstore (stateOf a)) ∧ (∃aa. llength aa = ∞ ∧ (∃ab. llength ab = ∞ ∧ (∃ac. pcOf ac = 0 ∧ initAvstore (getAvstore (stateOf ac)) ∧ (∃ad. llength ad = ∞ ∧ (∃ae. llength ae = ∞ ∧ (case (initPstate, cfg3, [], ibT3, ibUT3, {}) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (∞ = enat (endPC - pcOf cfg1) ∨ ∞ = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ ((case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa1)) ∧ (∀cfg''∈set cfgs3. (case getAvstore (stateOf cfg'') of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa1))) ∧ (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa2)) ∧ (∀cfg''∈set cfgs3. (case getAvstore (stateOf cfg'') of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa2))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ ((case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa1)) ∧ (∀cfg''∈set cfgs4. (case getAvstore (stateOf cfg'') of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa1))) ∧ (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa2)) ∧ (∀cfg''∈set cfgs4. (case getAvstore (stateOf cfg'') of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa1)) + 0 ≠ (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa2)) + n ∧ (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa1)) + 0 ≠ (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa2)) + n) ∧ (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa1)) ∧ (∀cfg3'∈set cfgs3. (case getAvstore (stateOf cfg3') of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa1))) ∧ (∀cfg4'∈set cfgs4. (case getAvstore (stateOf cfg4') of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa1))) ∧ (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa2)) ∧ (∀cfg3'∈set cfgs3. (case getAvstore (stateOf cfg3') of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa2))) ∧ (∀cfg4'∈set cfgs4. (case getAvstore (stateOf cfg4') of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa2))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = []) (initPstate, cfg4, [], ibT4, ibUT4, {}) status.Eq (a, aa, ab, {}) (ac, ad, ae, {}) status.Eq)))))›*)
using aa1 (*‹(0::nat) < size_aa1›*) apply (simp split: avstore.splits (*‹(?P::?'a ⇒ bool) (case ?avstorea::avstore of Avstore (x::char list ⇒ nat × nat) ⇒ (?f::(char list ⇒ nat × nat) ⇒ ?'a) x) = (∀x::char list ⇒ nat × nat. ?avstorea = Avstore x ⟶ ?P (?f x))› ‹(?P::?'a ⇒ bool) (case ?avstorea::avstore of Avstore (x::char list ⇒ nat × nat) ⇒ (?f::(char list ⇒ nat × nat) ⇒ ?'a) x) = (∄x::char list ⇒ nat × nat. ?avstorea = Avstore x ∧ ¬ ?P (?f x))›*))
(*goal: ‹⋀x xa. ⟦s4 = (initPstate, cfg4, [], ibT4, ibUT4, {}); s3 = (initPstate, cfg3, [], ibT3, ibUT3, {}); pstate3 = initPstate; pstate4 = initPstate; pcOf cfg3 = 0; pcOf cfg4 = 0; ls3 = {}; ls4 = {}; initAvstore (getAvstore (stateOf cfg3)); initAvstore (getAvstore (stateOf cfg4)); cfgs3 = []; cfgs4 = []; llength ibT3 = ∞; llength ibUT3 = ∞; llength ibT4 = ∞; llength ibUT4 = ∞; ¬ lhd ibUT3 < int NN; getAvstore (stateOf cfg3) = Avstore x; getAvstore (stateOf cfg4) = Avstore xa⟧ ⟹ ∃a. pcOf a = 0 ∧ initAvstore (getAvstore (stateOf a)) ∧ (∃aa. llength aa = ∞ ∧ (∃ab. llength ab = ∞ ∧ (∃ac. pcOf ac = 0 ∧ initAvstore (getAvstore (stateOf ac)) ∧ (∃ad. llength ad = ∞ ∧ (∃ae. llength ae = ∞ ∧ (case (initPstate, cfg3, [], ibT3, ibUT3, {}) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (∞ = enat (endPC - pcOf cfg1) ∨ ∞ = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ ((case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa1)) ∧ (∀cfg''∈set cfgs3. (case getAvstore (stateOf cfg'') of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa1))) ∧ (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa2)) ∧ (∀cfg''∈set cfgs3. (case getAvstore (stateOf cfg'') of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa2))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ ((case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa1)) ∧ (∀cfg''∈set cfgs4. (case getAvstore (stateOf cfg'') of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa1))) ∧ (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa2)) ∧ (∀cfg''∈set cfgs4. (case getAvstore (stateOf cfg'') of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa1)) + 0 ≠ (case getAvstore (stateOf cfg2) of Avstore as ⇒ fst (as aa2)) + n ∧ (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa1)) + 0 ≠ (case getAvstore (stateOf cfg1) of Avstore as ⇒ fst (as aa2)) + n) ∧ (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa1)) ∧ (∀cfg3'∈set cfgs3. (case getAvstore (stateOf cfg3') of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa1))) ∧ (∀cfg4'∈set cfgs4. (case getAvstore (stateOf cfg4') of Avstore as ⇒ fst (as aa1)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa1))) ∧ (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa2)) ∧ (∀cfg3'∈set cfgs3. (case getAvstore (stateOf cfg3') of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg3) of Avstore as ⇒ fst (as aa2))) ∧ (∀cfg4'∈set cfgs4. (case getAvstore (stateOf cfg4') of Avstore as ⇒ fst (as aa2)) = (case getAvstore (stateOf cfg4) of Avstore as ⇒ fst (as aa2))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ (llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞) ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ pcOf cfg3 ∈ {0, 1} ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = []) (initPstate, cfg4, [], ibT4, ibUT4, {}) status.Eq (a, aa, ab, {}) (ac, ad, ae, {}) status.Eq)))))›*)
apply (rule exI[of _ "cfg3"] (*‹(?P::config ⇒ bool) (cfg3::config) ⟹ ∃x::config. ?P x›*))
(*goal: ‹⋀x xa. ⟦s4 = (initPstate, cfg4, [], ibT4, ibUT4, {}); s3 = (initPstate, cfg3, [], ibT3, ibUT3, {}); pstate3 = initPstate; pstate4 = initPstate; pcOf cfg3 = 0; pcOf cfg4 = 0; ls3 = {}; ls4 = {}; x aa1 = (0, size_aa1) ∧ x aa2 = (size_aa1, size_aa2); xa aa1 = (0, size_aa1) ∧ xa aa2 = (size_aa1, size_aa2); cfgs3 = []; cfgs4 = []; llength ibT3 = ∞; llength ibUT3 = ∞; llength ibT4 = ∞; llength ibUT4 = ∞; ¬ lhd ibUT3 < int NN; getAvstore (stateOf cfg3) = Avstore x; getAvstore (stateOf cfg4) = Avstore xa; 0 < size_aa1⟧ ⟹ ∃a. ∀xa. getAvstore (stateOf a) = Avstore xa ⟶ pcOf a = 0 ∧ xa aa1 = (0, size_aa1) ∧ xa aa2 = (size_aa1, size_aa2) ∧ (∃a. llength a = ∞) ∧ (∃aa. llength aa = ∞ ∧ (∃a. llength a = ∞) ∧ llength aa = ∞ ∧ pcOf a = 0 ∧ pcOf a ≤ 6 ∧ fst (xa aa1) = 0 ∧ fst (xa aa2) = size_aa1 ∧ getHheap (stateOf a) = getHheap (stateOf cfg3) ∧ xa = x ∧ (∀n. fst (xa aa1) ≠ fst (xa aa2) + n) ∧ llength aa = ∞ ∧ lhd aa = 0 ∧ a = cfg3)›*)
using ex_llength_infty (*‹∃a. llength a = ∞ ∧ lhd a = 0›*) by auto . . .
(* *)
(*Playing the first strategy*)
lemma step0: "unwindIntoCond Δ0 (oor3 Δ0 Δ1 Δ1')"
proof (rule unwindIntoCond_simpleI (*‹⟦⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; ?Δ w s1 s2 statA sv1 sv2 statO⟧ ⟹ finalS s1 = finalS s2 ∧ finalN sv1 = finalS s1 ∧ finalN sv2 = finalS s2; ⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; ?Δ w s1 s2 statA sv1 sv2 statO; statA = status.Eq⟧ ⟹ isIntO s1 = isIntO s2; ⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; ?Δ w s1 s2 statA sv1 sv2 statO⟧ ⟹ match ?Δ' s1 s2 statA sv1 sv2 statO⟧ ⟹ unwindIntoCond ?Δ ?Δ'›*))
(*goals:
1. ‹⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δ0 w s1 s2 statA sv1 sv2 statO⟧ ⟹ finalS s1 = finalS s2 ∧ finalN sv1 = finalS s1 ∧ finalN sv2 = finalS s2›
2. ‹⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δ0 w s1 s2 statA sv1 sv2 statO; statA = status.Eq⟧ ⟹ isIntO s1 = isIntO s2›
3. ‹⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δ0 w s1 s2 statA sv1 sv2 statO⟧ ⟹ match (oor3 Δ0 Δ1 Δ1') s1 s2 statA sv1 sv2 statO›*)
fix n and ss3 and ss4 and statA and ss1 and ss2 and statO
assume r: "reachO ss3" "reachO ss4" "reachV ss1" "reachV ss2" and "Δ0": "Δ0 n ss3 ss4 statA ss1 ss2 statO" (*‹reachO (ss3::predState × config × config list × int llist × int llist × nat set)› ‹reachO (ss4::predState × config × config list × int llist × int llist × nat set)› ‹reachV (ss1::config × int llist × int llist × nat set)› ‹reachV (ss2::config × int llist × int llist × nat set)› ‹Δ0 (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
obtain pstate3 and cfg3 and cfgs3 and ibT3 and ibUT3 and ls3 where ss3: "ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)"
(*goal: ‹(⋀pstate3 cfg3 cfgs3 ibT3 ibUT3 ls3. ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⟹ thesis) ⟹ thesis›*)
apply (cases ss3)
(*goal: ‹(⋀(pstate3::predState) (cfg3::config) (cfgs3::config list) (ibT3::int llist) (ibUT3::int llist) ls3::nat set. (ss3::predState × config × config list × int llist × int llist × nat set) = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⟹ thesis::bool) ⟹ thesis›*)
by auto
obtain pstate4 and cfg4 and cfgs4 and ibT4 and ibUT4 and ls4 where ss4: "ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)"
(*goal: ‹(⋀pstate4 cfg4 cfgs4 ibT4 ibUT4 ls4. ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) ⟹ thesis) ⟹ thesis›*)
apply (cases ss4)
(*goal: ‹(⋀pstate4 cfg4 cfgs4 ibT4 ibUT4 ls4. ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) ⟹ thesis) ⟹ thesis›*)
by auto
obtain cfg1 and ibT1 and ibUT1 and ls1 where ss1: "ss1 = (cfg1, ibT1, ibUT1, ls1)"
(*goal: ‹(⋀cfg1 ibT1 ibUT1 ls1. ss1 = (cfg1, ibT1, ibUT1, ls1) ⟹ thesis) ⟹ thesis›*)
apply (cases ss1)
(*goal: ‹(⋀cfg1 ibT1 ibUT1 ls1. ss1 = (cfg1, ibT1, ibUT1, ls1) ⟹ thesis) ⟹ thesis›*)
by auto
obtain cfg2 and ibT2 and ibUT2 and ls2 where ss2: "ss2 = (cfg2, ibT2, ibUT2, ls2)"
(*goal: ‹(⋀(cfg2::config) (ibT2::int llist) (ibUT2::int llist) ls2::nat set. (ss2::config × int llist × int llist × nat set) = (cfg2, ibT2, ibUT2, ls2) ⟹ thesis::bool) ⟹ thesis›*)
apply (cases ss2)
(*goal: ‹(⋀cfg2 ibT2 ibUT2 ls2. ss2 = (cfg2, ibT2, ibUT2, ls2) ⟹ thesis) ⟹ thesis›*)
by auto
note ss = ss3 (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*) ss4 (*‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*) ss1 (*‹ss1 = (cfg1, ibT1, ibUT1, ls1)›*) ss2 (*‹ss2 = (cfg2, ibT2, ibUT2, ls2)›*)
obtain pc3 and vs3 and avst3 and h3 and p3 where cfg3: "cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)"
(*goal: ‹(⋀(pc3::nat) (vs3::char list ⇒ int) (avst3::avstore) (h3::heap) p3::nat. (cfg3::config) = Config pc3 (State (Vstore vs3) avst3 h3 p3) ⟹ thesis::bool) ⟹ thesis›*)
apply (cases cfg3)
(*goal: ‹(⋀pc3 vs3 avst3 h3 p3. cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ⟹ thesis) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore ?state) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore ?vstorea) = ?vstorea›*))
obtain pc4 and vs4 and avst4 and h4 and p4 where cfg4: "cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)"
(*goal: ‹(⋀pc4 vs4 avst4 h4 p4. cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ⟹ thesis) ⟹ thesis›*)
apply (cases cfg4)
(*goal: ‹(⋀pc4 vs4 avst4 h4 p4. cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ⟹ thesis) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore ?state) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore ?vstorea) = ?vstorea›*))
note cfg = cfg3 (*‹cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)›*) cfg4 (*‹cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)›*)
obtain hh3 where h3: "h3 = Heap hh3"
(*goal: ‹(⋀hh3. h3 = Heap hh3 ⟹ thesis) ⟹ thesis›*)
apply (cases h3)
(*goal: ‹(⋀hh3. h3 = Heap hh3 ⟹ thesis) ⟹ thesis›*)
by auto
obtain hh4 where h4: "h4 = Heap hh4"
(*goal: ‹(⋀hh4. h4 = Heap hh4 ⟹ thesis) ⟹ thesis›*)
apply (cases h4)
(*goal: ‹(⋀hh4. h4 = Heap hh4 ⟹ thesis) ⟹ thesis›*)
by auto
note hh = h3 (*‹h3 = Heap hh3›*) h4 (*‹(h4::heap) = Heap (hh4::nat ⇒ int)›*)
have f1: "¬finalN ss1"
using "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) finalB_pc_iff' (*‹?pc < 7 ⟹ finalB (Config ?pc ?s, ?ibT, ?ibUT) = (?pc = 1 ∧ ?ibUT = [[]])›*) unfolding ss finalN_iff_finalB "Δ0_defs"
(*goal: ‹¬ finalB (cfg1, ibT1, ibUT1)›*)
by simp
have f2: "¬finalN ss2"
using "Δ0" (*‹Δ0 (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) finalB_pc_iff' (*‹?pc < 7 ⟹ finalB (Config ?pc ?s, ?ibT, ?ibUT) = (?pc = 1 ∧ ?ibUT = [[]])›*) unfolding ss finalN_iff_finalB "Δ0_defs"
(*goal: ‹¬ finalB (cfg2, ibT2, ibUT2)›*)
by simp
have f3: "¬finalS ss3"
using "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹¬ finalS (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set)›*)
apply -
(*goal: ‹¬ finalS (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
apply (frule Δ0_implies (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ (pcOf ?cfg3.0 = 1 ⟶ ?ibUT3.0 ≠ [[]]) ∧ (pcOf ?cfg4.0 = 1 ⟶ ?ibUT4.0 ≠ [[]]) ∧ pcOf ?cfg1.0 < 7 ∧ pcOf ?cfg2.0 = pcOf ?cfg1.0 ∧ ?cfgs3.0 = [] ∧ pcOf ?cfg3.0 < 7 ∧ ?cfgs4.0 = [] ∧ pcOf ?cfg4.0 < 7›*))
(*goal: ‹Δ0 n (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ ¬ finalS (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
using finalS_cond (*‹⟦pcOf ?cfg < 7; ?cfgs = []; pcOf ?cfg = 1 ⟶ ?ibUT ≠ [[]]⟧ ⟹ ¬ finalS (?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls)›*) by simp
have f4: "¬finalS ss4"
using "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹¬ finalS (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply -
(*goal: ‹¬ finalS (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply (frule Δ0_implies (*‹Δ0 (?num::enat) (?pstate3.0::predState, ?cfg3.0::config, ?cfgs3.0::config list, ?ibT3.0::int llist, ?ibUT3.0::int llist, ?ls3.0::nat set) (?pstate4.0::predState, ?cfg4.0::config, ?cfgs4.0::config list, ?ibT4.0::int llist, ?ibUT4.0::int llist, ?ls4.0::nat set) (?statA::status) (?cfg1.0::config, ?ibT1.0::int llist, ?ibUT1.0::int llist, ?ls1.0::nat set) (?cfg2.0::config, ?ibT2.0::int llist, ?ibUT2.0::int llist, ?ls2.0::nat set) (?statO::status) ⟹ (pcOf ?cfg3.0 = (1::nat) ⟶ ?ibUT3.0 ≠ [[]]) ∧ (pcOf ?cfg4.0 = (1::nat) ⟶ ?ibUT4.0 ≠ [[]]) ∧ pcOf ?cfg1.0 < (7::nat) ∧ pcOf ?cfg2.0 = pcOf ?cfg1.0 ∧ ?cfgs3.0 = [] ∧ pcOf ?cfg3.0 < (7::nat) ∧ ?cfgs4.0 = [] ∧ pcOf ?cfg4.0 < (7::nat)›*))
(*goal: ‹Δ0 n (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ ¬ finalS (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
using finalS_cond (*‹⟦pcOf ?cfg < 7; ?cfgs = []; pcOf ?cfg = 1 ⟶ ?ibUT ≠ [[]]⟧ ⟹ ¬ finalS (?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls)›*) by simp
note finals = f1 (*‹¬ finalN ss1›*) f2 (*‹¬ finalN ss2›*) f3 (*‹¬ finalS ss3›*) f4 (*‹¬ finalS ss4›*)
show "finalS ss3 = finalS ss4 ∧ finalN ss1 = finalS ss3 ∧ finalN ss2 = finalS ss4"
using finals (*‹¬ finalN ss1› ‹¬ finalN ss2› ‹¬ finalS ss3› ‹¬ finalS ss4›*) by auto
then show "isIntO ss3 = isIntO ss4"
by simp
show "match (oor3 Δ0 Δ1 Δ1') ss3 ss4 statA ss1 ss2 statO"
unfolding match_def
(*goal: ‹match1 (oor3 Δ0 Δ1 Δ1') ss3 ss4 statA ss1 ss2 statO ∧ match2 (oor3 Δ0 Δ1 Δ1') ss3 ss4 statA ss1 ss2 statO ∧ match12 (oor3 Δ0 Δ1 Δ1') ss3 ss4 statA ss1 ss2 statO›*)
proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹match1 (oor3 Δ0 Δ1 Δ1') ss3 ss4 statA ss1 ss2 statO›
2. ‹match2 (oor3 Δ0 Δ1 Δ1') ss3 ss4 statA ss1 ss2 statO›
3. ‹match12 (oor3 Δ0 Δ1 Δ1') ss3 ss4 statA ss1 ss2 statO›*)
show "match1 (oor3 Δ0 Δ1 Δ1') ss3 ss4 statA ss1 ss2 statO"
unfolding match1_def
(*goal: ‹¬ isIntO ss3 ⟶ (∀s1'. validTransO (ss3, s1') ⟶ ¬ isSecO ss3 ∧ oor3 Δ0 Δ1 Δ1' ∞ s1' ss4 statA ss1 ss2 statO ∨ eqSec ss1 ss3 ∧ ¬ isIntV ss1 ∧ match1_1 (oor3 Δ0 Δ1 Δ1') ss3 s1' ss4 statA ss1 ss2 statO ∨ eqSec ss1 ss3 ∧ ¬ isSecV ss2 ∧ Van.eqAct ss1 ss2 ∧ match1_12 (oor3 Δ0 Δ1 Δ1') ss3 s1' ss4 statA ss1 ss2 statO)›*)
by (simp add: finalS_def (*‹finalS = final (→S)›*) final_def (*‹final ?r ?x ≡ ∀y. ¬ ?r ?x y›*))
show "match2 (oor3 Δ0 Δ1 Δ1') ss3 ss4 statA ss1 ss2 statO"
unfolding match2_def
(*goal: ‹¬ isIntO ss4 ⟶ (∀s2'. validTransO (ss4, s2') ⟶ ¬ isSecO ss4 ∧ oor3 Δ0 Δ1 Δ1' ∞ ss3 s2' statA ss1 ss2 statO ∨ eqSec ss2 ss4 ∧ ¬ isIntV ss2 ∧ match2_1 (oor3 Δ0 Δ1 Δ1') ss3 ss4 s2' statA ss1 ss2 statO ∨ ¬ isSecV ss1 ∧ eqSec ss2 ss4 ∧ Van.eqAct ss1 ss2 ∧ match2_12 (oor3 Δ0 Δ1 Δ1') ss3 ss4 s2' statA ss1 ss2 statO)›*)
by (simp add: finalS_def (*‹finalS = final (→S)›*) final_def (*‹final ?r ?x ≡ ∀y. ¬ ?r ?x y›*))
show "match12 (oor3 Δ0 Δ1 Δ1') ss3 ss4 statA ss1 ss2 statO"
proof (rule match12_simpleI (*‹(⋀s1' s2' statA'. ⟦statA' = sstatA' ?statA ?s1.0 ?s2.0; validTransO (?s1.0, s1'); validTransO (?s2.0, s2'); Opt.eqAct ?s1.0 ?s2.0⟧ ⟹ ¬ isSecO ?s1.0 ∧ ¬ isSecO ?s2.0 ∧ (?statA = statA' ∨ ?statO = Diff) ∧ ?Δ ∞ s1' s2' statA' ?sv1.0 ?sv2.0 ?statO ∨ eqSec ?sv1.0 ?s1.0 ∧ eqSec ?sv2.0 ?s2.0 ∧ Van.eqAct ?sv1.0 ?sv2.0 ∧ match12_12 ?Δ s1' s2' statA' ?sv1.0 ?sv2.0 ?statO) ⟹ match12 ?Δ ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*), rule disjI2 (*‹?Q ⟹ ?P ∨ ?Q›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⋀s1' s2' statA'. ⟦statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ eqSec ss1 ss3›
2. ‹⋀s1' s2' statA'. ⟦statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ eqSec ss2 ss4›
3. ‹⋀s1' s2' statA'. ⟦statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ Van.eqAct ss1 ss2›
4. ‹⋀s1' s2' statA'. ⟦statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ match12_12 (oor3 Δ0 Δ1 Δ1') s1' s2' statA' ss1 ss2 statO›*)
fix ss3' and ss4' and statA'
assume statA': "statA' = sstatA' statA ss3 ss4" and v: "validTransO (ss3, ss3')" "validTransO (ss4, ss4')" and sa: "Opt.eqAct ss3 ss4" (*‹(statA'::status) = sstatA' (statA::status) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss3::predState × config × config list × int llist × int llist × nat set, ss3'::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)› ‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*)
note v3 = v(1) (*‹validTransO (ss3, ss3')›*)
note v4 = v(2) (*‹validTransO (ss4, ss4')›*)
obtain pstate3' and cfg3' and cfgs3' and ibT3' and ibUT3' and ls3' where ss3': "ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')"
(*goal: ‹(⋀pstate3' cfg3' cfgs3' ibT3' ibUT3' ls3'. ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') ⟹ thesis) ⟹ thesis›*)
apply (cases ss3')
(*goal: ‹(⋀pstate3' cfg3' cfgs3' ibT3' ibUT3' ls3'. ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') ⟹ thesis) ⟹ thesis›*)
by auto
obtain pstate4' and cfg4' and cfgs4' and ibT4' and ibUT4' and ls4' where ss4': "ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')"
(*goal: ‹(⋀pstate4' cfg4' cfgs4' ibT4' ibUT4' ls4'. ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') ⟹ thesis) ⟹ thesis›*)
apply (cases ss4')
(*goal: ‹(⋀pstate4' cfg4' cfgs4' ibT4' ibUT4' ls4'. ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') ⟹ thesis) ⟹ thesis›*)
by auto
note ss = ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)› ‹ss1 = (cfg1, ibT1, ibUT1, ls1)› ‹ss2 = (cfg2, ibT2, ibUT2, ls2)›*) ss3' (*‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')›*) ss4' (*‹(ss4'::predState × config × config list × int llist × int llist × nat set) = (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set)›*)
obtain pc3 and vs3 and avst3 and h3 and p3 where cfg3: "cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)"
(*goal: ‹(⋀pc3 vs3 avst3 h3 p3. cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ⟹ thesis) ⟹ thesis›*)
apply (cases cfg3)
(*goal: ‹(⋀pc3 vs3 avst3 h3 p3. cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ⟹ thesis) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore ?state) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore ?vstorea) = ?vstorea›*))
obtain pc4 and vs4 and avst4 and h4 and p4 where cfg4: "cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)"
(*goal: ‹(⋀pc4 vs4 avst4 h4 p4. cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ⟹ thesis) ⟹ thesis›*)
apply (cases cfg4)
(*goal: ‹(⋀pc4 vs4 avst4 h4 p4. cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ⟹ thesis) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore ?state) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore ?vstorea) = ?vstorea›*))
note cfg = cfg3 (*‹cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)›*) cfg4 (*‹cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)›*)
show "eqSec ss1 ss3"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4, ss4')›*) "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹eqSec (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set)›*)
by (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
show "eqSec ss2 ss4"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4, ss4')›*) "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹eqSec (cfg2, ibT2, ibUT2, ls2) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply (simp add: Δ0_defs (*‹Δ0 (?num::enat) (?pstate3.0::predState, ?cfg3.0::config, ?cfgs3.0::config list, ?ibT3.0::int llist, ?ibUT3.0::int llist, ?ls3.0::nat set) (?pstate4.0::predState, ?cfg4.0::config, ?cfgs4.0::config list, ?ibT4.0::int llist, ?ibUT4.0::int llist, ?ls4.0::nat set) (?statA::status) (?cfg1.0::config, ?ibT1.0::int llist, ?ibUT1.0::int llist, ?ls1.0::nat set) (?cfg2.0::config, ?ibT2.0::int llist, ?ibUT2.0::int llist, ?ls2.0::nat set) (?statO::status) = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = (0::int) ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹beforeInput = {0::?'a, 1::?'a}› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []›*))
(*goal: ‹eqSec (cfg2, ibT2, ibUT2, ls2) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
by (metis length_0_conv (*‹(length ?xs = 0) = (?xs = [])›*) length_map (*‹length (map ?f ?xs) = length ?xs›*))
show saO: "Van.eqAct ss1 ss2"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)›*) sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹Van.eqAct (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2)›*)
unfolding Opt.eqAct_def Van.eqAct_def
(*goal: ‹isIntV (cfg1, ibT1, ibUT1, ls1) = isIntV (cfg2, ibT2, ibUT2, ls2) ∧ (isIntV (cfg1, ibT1, ibUT1, ls1) ⟶ getActV (cfg1, ibT1, ibUT1, ls1) = getActV (cfg2, ibT2, ibUT2, ls2))›*)
apply (simp add: Δ0_defs (*‹Δ0 (?num::enat) (?pstate3.0::predState, ?cfg3.0::config, ?cfgs3.0::config list, ?ibT3.0::int llist, ?ibUT3.0::int llist, ?ls3.0::nat set) (?pstate4.0::predState, ?cfg4.0::config, ?cfgs4.0::config list, ?ibT4.0::int llist, ?ibUT4.0::int llist, ?ls4.0::nat set) (?statA::status) (?cfg1.0::config, ?ibT1.0::int llist, ?ibUT1.0::int llist, ?ls1.0::nat set) (?cfg2.0::config, ?ibT2.0::int llist, ?ibUT2.0::int llist, ?ls2.0::nat set) (?statO::status) = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = (0::int) ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹beforeInput = {0::?'a, 1::?'a}› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []›*))
(*goal: ‹isIntV (cfg1, ibT1, ibUT1, ls1) = isIntV (cfg2, ibT2, ibUT2, ls2) ∧ (isIntV (cfg1, ibT1, ibUT1, ls1) ⟶ getActV (cfg1, ibT1, ibUT1, ls1) = getActV (cfg2, ibT2, ibUT2, ls2))›*)
by (metis enat.distinct( (*‹∞ ≠ enat ?nat1›*) 2) f3 (*‹¬ finalS ss3›*) list.map_disc_iff (*‹(map ?f ?a = []) = (?a = [])›*) llength_LNil (*‹llength [[]] = 0›*) ss3 (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*) zero_enat_def (*‹0 = enat 0›*))
show "match12_12 (oor3 Δ0 Δ1 Δ1') ss3' ss4' statA' ss1 ss2 statO"
unfolding match12_12_def
(*goal: ‹∃(sv1'::config × int llist × int llist × nat set) sv2'::config × int llist × int llist × nat set. let statO'::status = sstatO' (statO::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) in validTransV (ss1, sv1') ∧ validTransV (ss2, sv2') ∧ ((statA'::status) = Diff ⟶ statO' = Diff) ∧ oor3 Δ0 Δ1 Δ1' ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) statA' sv1' sv2' statO'›*)
proof (rule exI[of _ "nextN ss1"] (*‹?P (nextN ss1) ⟹ ∃x. ?P x›*), rule exI[of _ "nextN ss2"] (*‹?P (nextN ss2) ⟹ ∃x. ?P x›*), unfold Let_def (*‹Let ?s ?f ≡ ?f ?s›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goals:
1. ‹validTransV (ss1, nextN ss1)›
2. ‹validTransV (ss2, nextN ss2)›
3. ‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›
4. ‹oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
show "validTransV (ss1, nextN ss1)"
by (simp add: f1 (*‹¬ finalN ss1›*) nextN_stepN (*‹¬ finalN ?cfg_ib_ls ⟹ ?cfg_ib_ls →N nextN ?cfg_ib_ls›*))
show "validTransV (ss2, nextN ss2)"
by (simp add: f2 (*‹¬ finalN ss2›*) nextN_stepN (*‹¬ finalN ?cfg_ib_ls ⟹ ?cfg_ib_ls →N nextN ?cfg_ib_ls›*))
{
assume sstat: "statA' = Diff" (*‹(statA'::status) = Diff›*)
show "sstatO' statO ss1 ss2 = Diff"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)›*) sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) sstat (*‹(statA'::status) = Diff›*) unfolding ss cfg statA'
(*goal: ‹sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff›*)
apply simp
(*goal: ‹sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff›*)
apply (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*) sstatO'_def (*‹sstatO' ?statO ?sv1.0 ?sv2.0 = updStat ?statO (isIntV ?sv1.0, getObsV ?sv1.0) (isIntV ?sv2.0, getObsV ?sv2.0)›*) sstatA'_def (*‹sstatA' ?statA ?s1.0 ?s2.0 = updStat ?statA (isIntO ?s1.0, getObsO ?s1.0) (isIntO ?s2.0, getObsO ?s2.0)›*) finalS_def (*‹finalS = final (→S)›*) final_def (*‹final ?r ?x ≡ ∀y. ¬ ?r ?x y›*))
(*goal: ‹⟦(pstate3::predState, Config (pc3::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)), cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) →S (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set); (pstate4::predState, Config (pc4::nat) (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), cfgs3, ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); Δ0 (n::enat) (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), cfgs3, ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status); sstatA' statA (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), cfgs3, ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) = Diff⟧ ⟹ sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff›*)
using cases_6[of pc3] (*‹pc3 = 0 ∨ pc3 = 1 ∨ pc3 = 2 ∨ pc3 = 3 ∨ pc3 = 4 ∨ pc3 = 5 ∨ pc3 = 6 ∨ 6 < pc3›*) apply (elim disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⟦(pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ (n = enat (7 - pcOf cfg1) ∨ n = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ≤ 6 ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = hheap h3 ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞ ∧ ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]] ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ (pc3 = 0 ∨ pc3 = Suc 0) ∧ cfg1 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ∧ cfg2 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = []; updStat statA (∃a aa ab ac ad b. (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) →S (a, aa, ab, ac, ad, b), if pc4 = 6 then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))) (stateOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))), ls3) else ⊥) (∃a aa ab ac ad b. (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (a, aa, ab, ac, ad, b), if pc4 = 6 ∧ cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff⟧ ⟹ (pc4 = 6 ⟶ updStat statO (True, ⊥, ls3) (True, ⊥, ls4) = Diff) ∧ (pc4 ≠ 6 ⟶ updStat statO (True, ⊥) (True, ⊥) = Diff)›*)
apply simp_all
(*top goal: ‹⟦(pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ (n = enat (7 - pcOf cfg1) ∨ n = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ≤ 6 ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = hheap h3 ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞ ∧ ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]] ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ (pc3 = 0 ∨ pc3 = Suc 0) ∧ cfg1 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ∧ cfg2 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = []; updStat statA (∃a aa ab ac ad b. (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) →S (a, aa, ab, ac, ad, b), if pc4 = 6 then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))) (stateOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))), ls3) else ⊥) (∃a aa ab ac ad b. (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (a, aa, ab, ac, ad, b), if pc4 = 6 ∧ cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; pc3 = 0⟧ ⟹ (pc4 = 6 ⟶ updStat statO (True, ⊥, ls3) (True, ⊥, ls4) = Diff) ∧ (pc4 ≠ 6 ⟶ updStat statO (True, ⊥) (True, ⊥) = Diff)› and 7 goals remain*)
apply (cases statO, simp_all)
(*top goal: ‹⟦pstate3' = pstate4 ∧ cfg3' = Config (Suc 0) (State (Vstore vs3) avst3 h3 p3) ∧ ibT3' = ibT3 ∧ ibUT3' = ibUT3 ∧ cfgs3' = [] ∧ ls3' = ls3; (pstate4, Config 0 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config 0 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config 0 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ (n = enat (7 - pcOf cfg1) ∨ n = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pc4 = 0 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ≤ 6 ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = hheap h3 ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞ ∧ ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]] ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ cfg1 = Config 0 (State (Vstore vs3) avst3 h3 p3) ∧ cfg2 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = []; updStat statA (True, ⊥) (∃a aa ab ac ad b. (pstate4, Config 0 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (a, aa, ab, ac, ad, b), ⊥) = Diff; pc3 = 0⟧ ⟹ updStat statO (True, ⊥) (True, ⊥) = Diff› and 1 goal remains*)
apply (cases statA, simp_all)
(*top goal: ‹⟦pstate3' = pstate4 ∧ cfg3' = Config (Suc 0) (State (Vstore vs3) avst3 h3 p3) ∧ ibT3' = ibT3 ∧ ibUT3' = ibUT3 ∧ cfgs3' = [] ∧ ls3' = ls3; (pstate4, Config 0 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config 0 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config 0 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ (n = enat (7 - pcOf cfg1) ∨ n = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pc4 = 0 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ≤ 6 ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = hheap h3 ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ statA ≠ Diff ∧ llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞ ∧ ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]] ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ cfg1 = Config 0 (State (Vstore vs3) avst3 h3 p3) ∧ cfg2 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = []; updStat statA (True, ⊥) (∃a aa ab ac ad b. (pstate4, Config 0 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (a, aa, ab, ac, ad, b), ⊥) = Diff; pc3 = 0; statO = status.Eq⟧ ⟹ False› and 1 goal remains*)
apply (cases statO, simp_all)
(*top goal: ‹⟦pstate3' = pstate4 ∧ cfg3' = Config (Suc 0) (State (Vstore vs3) avst3 h3 p3) ∧ ibT3' = ibT3 ∧ ibUT3' = ibUT3 ∧ cfgs3' = [] ∧ ls3' = ls3; (pstate4, Config 0 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config 0 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config 0 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ (n = enat (7 - pcOf cfg1) ∨ n = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pc4 = 0 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ≤ 6 ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = hheap h3 ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞ ∧ ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]] ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ cfg1 = Config 0 (State (Vstore vs3) avst3 h3 p3) ∧ cfg2 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = []; updStat status.Eq (True, ⊥) (∃a aa ab ac ad b. (pstate4, Config 0 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (a, aa, ab, ac, ad, b), ⊥) = Diff; pc3 = 0; statO = status.Eq; statA = status.Eq⟧ ⟹ False› and 1 goal remains*)
apply (cases statA, simp_all)
(*top goal: ‹⟦pstate3' = pstate4 ∧ cfg3' = Config (Suc 0) (State (Vstore vs3) avst3 h3 p3) ∧ ibT3' = ibT3 ∧ ibUT3' = ibUT3 ∧ cfgs3' = [] ∧ ls3' = ls3; (pstate4, Config 0 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config 0 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config 0 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ (n = enat (7 - pcOf cfg1) ∨ n = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pc4 = 0 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ≤ 6 ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = hheap h3 ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞ ∧ ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]] ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ cfg1 = Config 0 (State (Vstore vs3) avst3 h3 p3) ∧ cfg2 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = []; updStat status.Eq (True, ⊥) (∃a aa ab ac ad b. (pstate4, Config 0 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (a, aa, ab, ac, ad, b), ⊥) = Diff; pc3 = 0; statA = status.Eq; statO = status.Eq⟧ ⟹ False› and 1 goal remains*)
apply (smt (z3) status.distinct (*‹status.Eq ≠ Diff› ‹Diff ≠ status.Eq›*) updStat.simps (*‹updStat status.Eq (True, ?a) (True, ?a') = (if ?a = ?a' then status.Eq else Diff)› ‹updStat Diff ?uu ?uv = Diff› ‹updStat ?stat (False, ?va) ?uv = ?stat› ‹updStat ?stat ?uu (False, ?va) = ?stat›*))
(*top goal: ‹⟦(pstate3'::predState) = (pstate4::predState) ∧ (cfg3'::config) = Config (Suc (0::nat)) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)) ∧ (ibT3'::int llist) = (ibT3::int llist) ∧ (ibUT3'::int llist) = (ibUT3::int llist) ∧ (cfgs3'::config list) = [] ∧ (ls3'::nat set) = (ls3::nat set); (pstate4, Config (0::nat) (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); Opt.eqAct (pstate4, Config (0::nat) (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config (0::nat) (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); (pstate3::predState) = pstate4 ∧ ((n::enat) = enat ((7::nat) - pcOf (cfg1::config)) ∨ n = ∞) ∧ pcOf cfg1 = pcOf (cfg2::config) ∧ (pc4::nat) = (0::nat) ∧ map pcOf (cfgs3::config list) = map pcOf cfgs4 ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ pcOf cfg1 ≤ (6::nat) ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = hheap h3 ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ llength (ibUT1::int llist) = ∞ ∧ llength (ibUT2::int llist) = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞ ∧ ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]] ∧ (int NN ≤ lhd ibUT3 ∧ lhd ibUT1 = (0::int) ∧ ibUT1 = ibUT2 ∨ lhd ibUT3 < int NN ∧ ibUT1 = ibUT3 ∧ ibUT2 = ibUT4) ∧ cfg1 = Config (0::nat) (State (Vstore vs3) avst3 h3 p3) ∧ cfg2 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ∧ (ls1::nat set) = ls3 ∧ (ls2::nat set) = ls4 ∧ ls1 = {} ∧ ls2 = {} ∧ cfgs3 = []; updStat status.Eq (True, ⊥) (∃(a::predState) (aa::config) (ab::config list) (ac::int llist) (ad::int llist) b::nat set. (pstate4, Config (0::nat) (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (a, aa, ab, ac, ad, b), ⊥) = Diff; (pc3::nat) = (0::nat); (statO::status) = status.Eq; (statA::status) = status.Eq⟧ ⟹ False› and 1 goal remains*)
using updStat.simps (*‹updStat status.Eq (True, ?a) (True, ?a') = (if ?a = ?a' then status.Eq else Diff)› ‹updStat Diff ?uu ?uv = Diff› ‹updStat ?stat (False, ?va) ?uv = ?stat› ‹updStat ?stat ?uu (False, ?va) = ?stat›*) by (smt (z3) status.exhaust (*‹⟦?y = status.Eq ⟹ ?P; ?y = Diff ⟹ ?P⟧ ⟹ ?P›*))
}
note stat = this (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*)
show "oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)"
using v3[unfolded ss, simplified] (*‹(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')›*) proof (cases rule: stepS_cases (*‹⟦(?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls) →S (?pstate', ?cfg', ?cfgs', ?ibT', ?ibUT', ?ls'); ⟦?cfgs = []; ¬ is_IfJump (prog ! pcOf ?cfg) ∨ ¬ mispred ?pstate [pcOf ?cfg]; ?pstate' = ?pstate; ¬ finalB (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ?cfgs' = []; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs = []; is_IfJump (prog ! pcOf ?cfg); mispred ?pstate [pcOf ?cfg]; ?pstate' = update ?pstate [pcOf ?cfg]; ¬ finalM (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (?cfg, ?ibT, ?ibUT) ∧ ?cfgs' = [cfg1']; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ is_IfJump (prog ! pcOf (last ?cfgs)) ∨ ¬ mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) ≠ Fence; ?pstate' = ?pstate; ¬ is_getInput (prog ! pcOf (last ?cfgs)); ¬ is_Output (prog ! pcOf (last ?cfgs)); ?cfg' = ?cfg; ?ls' = ?ls ∪ readLocs (last ?cfgs); ∃cfg1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (cfg1', ?ibT', ?ibUT') ∧ ?cfgs' = butlast ?cfgs ## cfg1'⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); is_IfJump (prog ! pcOf (last ?cfgs)); mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ finalM (last ?cfgs, ?ibT, ?ibUT); ?cfg' = ?cfg; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (lcfg', ?ibT', ?ibUT') ∧ (cfg1', ibT1', ibUT1') = nextM (last ?cfgs, ?ibT, ?ibUT) ∧ ?cfgs' = butlast ?cfgs @ [lcfg'] ## cfg1'; ?ls' = ?ls ∪ readLocs (last ?cfgs)⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) = Fence; ?pstate' = ?pstate; ?cfg' = ?cfg; ?cfgs' = []; ?ibT' = ?ibT; ?ibUT' = ?ibUT; ?ls' = ?ls⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?cfg' = ?cfg; ?cfgs' = butlast ?cfgs; ?ls' = ?ls; ?ibT' = ?ibT; ?ibUT' = ?ibUT⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) ≠ Fence; pstate3' = pstate3; ¬ is_getInput (prog ! pcOf (last cfgs3)); ¬ is_Output (prog ! pcOf (last cfgs3)); cfg3' = cfg3; ls3' = ls3 ∪ readLocs (last cfgs3); ∃cfg1'. nextB (last cfgs3, ibT3, ibUT3) = (cfg1', ibT3', ibUT3') ∧ cfgs3' = butlast cfgs3 ## cfg1'⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3, ibUT3); cfg3' = cfg3; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'; ls3' = ls3 ∪ readLocs (last cfgs3)⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
6. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_mispred (*‹(cfgs3::config list) = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹(pstate3'::predState) = update (pstate3::predState) [pcOf (cfg3::config)]› ‹¬ finalM (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg3::config, ibT3::int llist, ibUT3::int llist) ∧ (cfgs3'::config list) = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*)
then show "?thesis"
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (nextN (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)) (nextN (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)) (sstatO' (statO::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
apply -
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (nextN (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)) (nextN (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)) (sstatO' (statO::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
apply (frule Δ0_implies (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ (pcOf ?cfg3.0 = 1 ⟶ ?ibUT3.0 ≠ [[]]) ∧ (pcOf ?cfg4.0 = 1 ⟶ ?ibUT4.0 ≠ [[]]) ∧ pcOf ?cfg1.0 < 7 ∧ pcOf ?cfg2.0 = pcOf ?cfg1.0 ∧ ?cfgs3.0 = [] ∧ pcOf ?cfg3.0 < 7 ∧ ?cfgs4.0 = [] ∧ pcOf ?cfg4.0 < 7›*))
(*goal: ‹⟦(cfgs3::config list) = []; is_IfJump (prog ! pcOf (cfg3::config)); mispred (pstate3::predState) [pcOf cfg3]; (pstate3'::predState) = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3::int llist, ibUT3::int llist); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3, ibT3, ibUT3); ∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ (cfgs3'::config list) = [cfg1']; (ls3'::nat set) = (ls3::nat set) ∪ readLocs cfg3; Opt.eqAct (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set); Δ0 (n::enat) (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status); (statA'::status) = Diff ⟹ sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) ≠ Fence; pstate3' = pstate3; ¬ is_getInput (prog ! pcOf (last cfgs3)); ¬ is_Output (prog ! pcOf (last cfgs3)); cfg3' = cfg3; ls3' = ls3 ∪ readLocs (last cfgs3); ∃cfg1'. nextB (last cfgs3, ibT3, ibUT3) = (cfg1', ibT3', ibUT3') ∧ cfgs3' = butlast cfgs3 ## cfg1'⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3, ibUT3); cfg3' = cfg3; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'; ls3' = ls3 ∪ readLocs (last cfgs3)⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_normal (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹prog ! pcOf (last cfgs3) ≠ Fence› ‹pstate3' = pstate3› ‹¬ is_getInput (prog ! pcOf (last cfgs3))› ‹¬ is_Output (prog ! pcOf (last cfgs3))› ‹cfg3' = cfg3› ‹ls3' = ls3 ∪ readLocs (last cfgs3)› ‹∃cfg1'::config. nextB (last (cfgs3::config list), ibT3::int llist, ibUT3::int llist) = (cfg1', ibT3'::int llist, ibUT3'::int llist) ∧ (cfgs3'::config list) = butlast cfgs3 ## cfg1'›*)
then show "?thesis"
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ0" (*‹Δ0 (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3, ibUT3); cfg3' = cfg3; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'; ls3' = ls3 ∪ readLocs (last cfgs3)⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_mispred (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹is_IfJump (prog ! pcOf (last cfgs3))› ‹mispred pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹¬ finalM (last cfgs3, ibT3, ibUT3)› ‹cfg3' = cfg3› ‹∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'› ‹ls3' = ls3 ∪ readLocs (last cfgs3)›*)
then show "?thesis"
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_Fence (*‹cfgs3 ≠ []› ‹¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf (cfgs3::config list))› ‹prog ! pcOf (last (cfgs3::config list)) = Fence› ‹pstate3' = pstate3› ‹cfg3' = cfg3› ‹cfgs3' = []› ‹(ibT3'::int llist) = (ibT3::int llist)› ‹ibUT3' = ibUT3› ‹(ls3'::nat set) = (ls3::nat set)›*)
then show "?thesis"
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹(statA'::status) = Diff ⟹ sstatO' (statO::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) = Diff›*) unfolding ss
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (nextN (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)) (nextN (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)) (sstatO' (statO::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_resolve (*‹cfgs3 ≠ []› ‹resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹cfg3' = cfg3› ‹cfgs3' = butlast cfgs3› ‹ls3' = ls3› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3›*)
then show "?thesis"
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ0_defs (*‹Δ0 (?num::enat) (?pstate3.0::predState, ?cfg3.0::config, ?cfgs3.0::config list, ?ibT3.0::int llist, ?ibUT3.0::int llist, ?ls3.0::nat set) (?pstate4.0::predState, ?cfg4.0::config, ?cfgs4.0::config list, ?ibT4.0::int llist, ?ibUT4.0::int llist, ?ls4.0::nat set) (?statA::status) (?cfg1.0::config, ?ibT1.0::int llist, ?ibUT1.0::int llist, ?ls1.0::nat set) (?cfg2.0::config, ?ibT2.0::int llist, ?ibUT2.0::int llist, ?ls2.0::nat set) (?statO::status) = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = (0::int) ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a::{zero,numeral,ord}..6::?'a::{zero,numeral,ord}}› ‹beforeInput = {0::?'a::{one,zero}, 1::?'a::{one,zero}}› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []›*))
next
(*goal: ‹⟦(cfgs3::config list) = []; ¬ is_IfJump (prog ! pcOf (cfg3::config)) ∨ ¬ mispred (pstate3::predState) [pcOf cfg3]; (pstate3'::predState) = pstate3; ¬ finalB (cfg3, ibT3::int llist, ibUT3::int llist); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3, ibT3, ibUT3); (cfgs3'::config list) = []; (ls3'::nat set) = (ls3::nat set) ∪ readLocs cfg3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
case nonspec_normal (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*)
note nn3 = nonspec_normal (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*)
show "?thesis"
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using v3[unfolded ss, simplified] (*‹(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')›*) proof (cases rule: stepS_cases (*‹⟦(?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls) →S (?pstate', ?cfg', ?cfgs', ?ibT', ?ibUT', ?ls'); ⟦?cfgs = []; ¬ is_IfJump (prog ! pcOf ?cfg) ∨ ¬ mispred ?pstate [pcOf ?cfg]; ?pstate' = ?pstate; ¬ finalB (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ?cfgs' = []; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs = []; is_IfJump (prog ! pcOf ?cfg); mispred ?pstate [pcOf ?cfg]; ?pstate' = update ?pstate [pcOf ?cfg]; ¬ finalM (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (?cfg, ?ibT, ?ibUT) ∧ ?cfgs' = [cfg1']; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ is_IfJump (prog ! pcOf (last ?cfgs)) ∨ ¬ mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) ≠ Fence; ?pstate' = ?pstate; ¬ is_getInput (prog ! pcOf (last ?cfgs)); ¬ is_Output (prog ! pcOf (last ?cfgs)); ?cfg' = ?cfg; ?ls' = ?ls ∪ readLocs (last ?cfgs); ∃cfg1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (cfg1', ?ibT', ?ibUT') ∧ ?cfgs' = butlast ?cfgs ## cfg1'⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); is_IfJump (prog ! pcOf (last ?cfgs)); mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ finalM (last ?cfgs, ?ibT, ?ibUT); ?cfg' = ?cfg; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (lcfg', ?ibT', ?ibUT') ∧ (cfg1', ibT1', ibUT1') = nextM (last ?cfgs, ?ibT, ?ibUT) ∧ ?cfgs' = butlast ?cfgs @ [lcfg'] ## cfg1'; ?ls' = ?ls ∪ readLocs (last ?cfgs)⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) = Fence; ?pstate' = ?pstate; ?cfg' = ?cfg; ?cfgs' = []; ?ibT' = ?ibT; ?ibUT' = ?ibUT; ?ls' = ?ls⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?cfg' = ?cfg; ?cfgs' = butlast ?cfgs; ?ls' = ?ls; ?ibT' = ?ibT; ?ibUT' = ?ibUT⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) ≠ Fence; pstate3' = pstate3; ¬ is_getInput (prog ! pcOf (last cfgs3)); ¬ is_Output (prog ! pcOf (last cfgs3)); cfg3' = cfg3; ls3' = ls3 ∪ readLocs (last cfgs3); ∃cfg1'. nextB (last cfgs3, ibT3, ibUT3) = (cfg1', ibT3', ibUT3') ∧ cfgs3' = butlast cfgs3 ## cfg1'⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3, ibUT3); cfg3' = cfg3; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'; ls3' = ls3 ∪ readLocs (last cfgs3)⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
6. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_mispred (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf (cfg3::config))› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (cfg3::config)›*)
then show "?thesis"
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹(cfgs3::config list) = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹cfgs3' = []› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (cfg3::config)›*) unfolding ss
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) ≠ Fence; pstate3' = pstate3; ¬ is_getInput (prog ! pcOf (last cfgs3)); ¬ is_Output (prog ! pcOf (last cfgs3)); cfg3' = cfg3; ls3' = ls3 ∪ readLocs (last cfgs3); ∃cfg1'. nextB (last cfgs3, ibT3, ibUT3) = (cfg1', ibT3', ibUT3') ∧ cfgs3' = butlast cfgs3 ## cfg1'⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3, ibUT3); cfg3' = cfg3; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'; ls3' = ls3 ∪ readLocs (last cfgs3)⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_normal (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹prog ! pcOf (last cfgs3) ≠ Fence› ‹(pstate3'::predState) = (pstate3::predState)› ‹¬ is_getInput (prog ! pcOf (last cfgs3))› ‹¬ is_Output (prog ! pcOf (last cfgs3))› ‹cfg3' = cfg3› ‹ls3' = ls3 ∪ readLocs (last cfgs3)› ‹∃cfg1'. nextB (last cfgs3, ibT3, ibUT3) = (cfg1', ibT3', ibUT3') ∧ cfgs3' = butlast cfgs3 ## cfg1'›*)
then show "?thesis"
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ0" (*‹Δ0 (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦(cfgs3::config list) = []; ¬ is_IfJump (prog ! pcOf (cfg3::config)) ∨ ¬ mispred (pstate3::predState) [pcOf cfg3]; (pstate3'::predState) = pstate3; ¬ finalB (cfg3, ibT3::int llist, ibUT3::int llist); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3, ibT3, ibUT3); (cfgs3'::config list) = []; (ls3'::nat set) = (ls3::nat set) ∪ readLocs cfg3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
2. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); (pstate3'::predState) = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3::int llist, ibUT3::int llist); (cfg3'::config) = cfg3; ∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3'::int llist, ibUT3'::int llist) ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ (cfgs3'::config list) = butlast cfgs3 @ [lcfg'] ## cfg1'; (ls3'::nat set) = (ls3::nat set) ∪ readLocs (last cfgs3)⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
3. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; (pstate3'::predState) = pstate3; (cfg3'::config) = cfg3; (cfgs3'::config list) = []; (ibT3'::int llist) = (ibT3::int llist); (ibUT3'::int llist) = (ibUT3::int llist); (ls3'::nat set) = (ls3::nat set)⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
4. ‹⟦(cfgs3::config list) ≠ []; resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); (pstate3'::predState) = update pstate3 (pcOf cfg3 # map pcOf cfgs3); (cfg3'::config) = cfg3; (cfgs3'::config list) = butlast cfgs3; (ls3'::nat set) = (ls3::nat set); (ibT3'::int llist) = (ibT3::int llist); (ibUT3'::int llist) = (ibUT3::int llist)⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
case spec_mispred (*‹(cfgs3::config list) ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹is_IfJump (prog ! pcOf (last cfgs3))› ‹mispred pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹(pstate3'::predState) = update (pstate3::predState) (pcOf (cfg3::config) # map pcOf (cfgs3::config list))› ‹¬ finalM (last cfgs3, ibT3, ibUT3)› ‹cfg3' = cfg3› ‹∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'› ‹ls3' = ls3 ∪ readLocs (last cfgs3)›*)
then show "?thesis"
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_Fence (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹prog ! pcOf (last (cfgs3::config list)) = Fence› ‹pstate3' = pstate3› ‹cfg3' = cfg3› ‹(cfgs3'::config list) = []› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3› ‹ls3' = ls3›*)
then show "?thesis"
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹(cfgs3::config list) = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_resolve (*‹cfgs3 ≠ []› ‹resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf (cfgs3::config list))› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹cfg3' = cfg3› ‹cfgs3' = butlast cfgs3› ‹ls3' = ls3› ‹(ibT3'::int llist) = (ibT3::int llist)› ‹ibUT3' = ibUT3›*)
then show "?thesis"
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹(pstate3'::predState) = (pstate3::predState)› ‹¬ finalB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (cfg3::config)›*) unfolding ss
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goal: ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_normal (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*)
note nn4 = nonspec_normal (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*)
show "?thesis"
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) saO (*‹Van.eqAct ss1 ss2›*) "Δ0" (*‹Δ0 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) v3 (*‹validTransO (ss3, ss3')›*) v4 (*‹validTransO (ss4, ss4')›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) nn4 (*‹(cfgs3::config list) = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) f4 (*‹¬ finalS ss4›*) unfolding ss cfg Opt.eqAct_def
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
apply clarsimp
(*goal: ‹oor3 Δ0 Δ1 Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
apply (cases "pc3 = 0")
(*goal: ‹⟦Van.eqAct (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2); Δ0 n (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff; (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; cfgs3 = []; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3)); ¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); ¬ finalS (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); getActO (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) = getActO (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4)⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3))) (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (case nextB (cfg1, ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs cfg1)) (case nextB (cfg2, ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs cfg2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
subgoal for
apply (rule oor3I1 (*‹?Δ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO ⟹ oor3 ?Δ ?Δ₂ ?Δ₃ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*goal: ‹⟦Van.eqAct (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2); Δ0 n (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff; (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; cfgs3 = []; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3)); ¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); ¬ finalS (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); getActO (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) = getActO (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pc3 = 0⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3))) (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (case nextB (cfg1, ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs cfg1)) (case nextB (cfg2, ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs cfg2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
apply (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
(*goal: ‹⟦Van.eqAct (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set); Δ0 (n::enat) (pstate3::predState, Config (pc3::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)), [], ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, Config (pc4::nat) (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) (statO::status); (statA'::status) = Diff ⟹ sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff; (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; (cfgs3::config list) = []; (pstate3'::predState) = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfgs3'::config list) = []; (ls3'::nat set) = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3)); ¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); ¬ finalS (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); getActO (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) = getActO (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pc3 = (0::nat)⟧ ⟹ Δ0 ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3))) (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (case nextB (cfg1, ibT1, ibUT1) of (cfg'::config, ibT'::int llist, ibUT'::int llist) ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs cfg1)) (case nextB (cfg2, ibT2, ibUT2) of (cfg'::config, ibT'::int llist, ibUT'::int llist) ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs cfg2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (metis config.sel( (*‹stateOf (Config ?x1.0 ?x2.0) = ?x2.0›*) 2) state.sel( (*‹getAvstore (State ?x1.0 ?x2.0 ?x3.0 ?x4.0) = ?x2.0›*) 2))
subgoal for
apply (subgoal_tac "pc4 = 1")
(*goal: ‹⟦Van.eqAct (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set); Δ0 (n::enat) (pstate3::predState, Config (pc3::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)), [], ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, Config (pc4::nat) (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) (statO::status); (statA'::status) = Diff ⟹ sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff; (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; (cfgs3::config list) = []; (pstate3'::predState) = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfgs3'::config list) = []; (ls3'::nat set) = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3)); ¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); ¬ finalS (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); getActO (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) = getActO (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pc3 ≠ (0::nat)⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3))) (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (case nextB (cfg1, ibT1, ibUT1) of (cfg'::config, ibT'::int llist, ibUT'::int llist) ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs cfg1)) (case nextB (cfg2, ibT2, ibUT2) of (cfg'::config, ibT'::int llist, ibUT'::int llist) ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs cfg2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
defer 1
(*top goal: ‹⟦Van.eqAct (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2); Δ0 n (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff; (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; cfgs3 = []; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3)); ¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); ¬ finalS (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); getActO (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) = getActO (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pc3 ≠ 0⟧ ⟹ pc4 = 1› and 1 goal remains*)
subgoal for
by (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
subgoal for
using xx_NN_cases[of "vstore (getVstore (stateOf cfg3'))"] (*‹vstore (getVstore (stateOf cfg3')) xx < int NN ∨ int NN ≤ vstore (getVstore (stateOf cfg3')) xx›*) apply (elim disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⟦Van.eqAct (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set); Δ0 (n::enat) (pstate3::predState, Config (pc3::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)), [], ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, Config (pc4::nat) (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) (statO::status); (statA'::status) = Diff ⟹ sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff; (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; (cfgs3::config list) = []; (pstate3'::predState) = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfgs3'::config list) = []; (ls3'::nat set) = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3)); ¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); ¬ finalS (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); getActO (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) = getActO (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pc3 ≠ (0::nat); pc4 = (1::nat)⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3))) (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (case nextB (cfg1, ibT1, ibUT1) of (cfg'::config, ibT'::int llist, ibUT'::int llist) ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs cfg1)) (case nextB (cfg2, ibT2, ibUT2) of (cfg'::config, ibT'::int llist, ibUT'::int llist) ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs cfg2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
subgoal for
apply (rule oor3I2 (*‹(?Δ₂::?'a ⇒ ?'b ⇒ ?'c ⇒ ?'d ⇒ ?'e ⇒ ?'f ⇒ ?'g ⇒ bool) (?w::?'a) (?s1.0::?'b) (?s2.0::?'c) (?statA::?'d) (?sv1.0::?'e) (?sv2.0::?'f) (?statO::?'g) ⟹ oor3 (?Δ::?'a ⇒ ?'b ⇒ ?'c ⇒ ?'d ⇒ ?'e ⇒ ?'f ⇒ ?'g ⇒ bool) ?Δ₂ (?Δ₃::?'a ⇒ ?'b ⇒ ?'c ⇒ ?'d ⇒ ?'e ⇒ ?'f ⇒ ?'g ⇒ bool) ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*goal: ‹⟦Van.eqAct (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set); Δ0 (n::enat) (pstate3::predState, Config (pc3::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)), [], ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, Config (pc4::nat) (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) (statO::status); (statA'::status) = Diff ⟹ sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff; (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; (cfgs3::config list) = []; (pstate3'::predState) = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfgs3'::config list) = []; (ls3'::nat set) = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3)); ¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); ¬ finalS (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); getActO (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) = getActO (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pc3 ≠ (0::nat); pc4 = (1::nat); vstore (getVstore (stateOf cfg3')) xx < int NN⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3))) (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (case nextB (cfg1, ibT1, ibUT1) of (cfg'::config, ibT'::int llist, ibUT'::int llist) ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs cfg1)) (case nextB (cfg2, ibT2, ibUT2) of (cfg'::config, ibT'::int llist, ibUT'::int llist) ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs cfg2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
apply (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*) Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
(*goal: ‹⟦Van.eqAct (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set); Δ0 (n::enat) (pstate3::predState, Config (pc3::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)), [], ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, Config (pc4::nat) (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) (statO::status); (statA'::status) = Diff ⟹ sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff; (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; (cfgs3::config list) = []; (pstate3'::predState) = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfgs3'::config list) = []; (ls3'::nat set) = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3)); ¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); ¬ finalS (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); getActO (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) = getActO (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pc3 ≠ (0::nat); pc4 = (1::nat); vstore (getVstore (stateOf cfg3')) xx < int NN⟧ ⟹ Δ1 ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3))) (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (case nextB (cfg1, ibT1, ibUT1) of (cfg'::config, ibT'::int llist, ibUT'::int llist) ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs cfg1)) (case nextB (cfg2, ibT2, ibUT2) of (cfg'::config, ibT'::int llist, ibUT'::int llist) ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs cfg2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by metis
subgoal for
apply (rule oor3I3 (*‹(?Δ₃::?'a ⇒ ?'b ⇒ ?'c ⇒ ?'d ⇒ ?'e ⇒ ?'f ⇒ ?'g ⇒ bool) (?w::?'a) (?s1.0::?'b) (?s2.0::?'c) (?statA::?'d) (?sv1.0::?'e) (?sv2.0::?'f) (?statO::?'g) ⟹ oor3 (?Δ::?'a ⇒ ?'b ⇒ ?'c ⇒ ?'d ⇒ ?'e ⇒ ?'f ⇒ ?'g ⇒ bool) (?Δ₂::?'a ⇒ ?'b ⇒ ?'c ⇒ ?'d ⇒ ?'e ⇒ ?'f ⇒ ?'g ⇒ bool) ?Δ₃ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*goal: ‹⟦Van.eqAct (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set); Δ0 (n::enat) (pstate3::predState, Config (pc3::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)), [], ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, Config (pc4::nat) (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) (statO::status); (statA'::status) = Diff ⟹ sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff; (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; (cfgs3::config list) = []; (pstate3'::predState) = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfgs3'::config list) = []; (ls3'::nat set) = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3)); ¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); ¬ finalS (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); getActO (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) = getActO (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pc3 ≠ (0::nat); pc4 = (1::nat); int NN ≤ vstore (getVstore (stateOf cfg3')) xx⟧ ⟹ oor3 Δ0 Δ1 Δ1' ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3))) (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (case nextB (cfg1, ibT1, ibUT1) of (cfg'::config, ibT'::int llist, ibUT'::int llist) ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs cfg1)) (case nextB (cfg2, ibT2, ibUT2) of (cfg'::config, ibT'::int llist, ibUT'::int llist) ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs cfg2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
apply (simp add: Δ0_defs (*‹Δ0 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO = (common ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ∧ (llength ?ibUT1.0 = ∞ ∧ llength ?ibUT2.0 = ∞ ∧ llength ?ibUT3.0 = ∞ ∧ llength ?ibUT4.0 = ∞) ∧ (?ibUT1.0 ≠ [[]] ∧ ?ibUT2.0 ≠ [[]] ∧ ?ibUT3.0 ≠ [[]] ∧ ?ibUT4.0 ≠ [[]]) ∧ (int NN ≤ lhd ?ibUT3.0 ∧ lhd ?ibUT1.0 = 0 ∧ ?ibUT1.0 = ?ibUT2.0 ∨ lhd ?ibUT3.0 < int NN ∧ ?ibUT1.0 = ?ibUT3.0 ∧ ?ibUT2.0 = ?ibUT4.0) ∧ pcOf ?cfg3.0 ∈ beforeInput ∧ ?cfg1.0 = ?cfg3.0 ∧ ?cfg2.0 = ?cfg4.0 ∧ ?ls1.0 = ?ls3.0 ∧ ?ls2.0 = ?ls4.0 ∧ ?ls1.0 = {} ∧ ?ls2.0 = {} ∧ noMisSpec ?cfgs3.0)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹beforeInput = {0, 1}› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*) Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
(*goal: ‹⟦Van.eqAct (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2); Δ0 n (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff; (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; cfgs3 = []; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3)); ¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); ¬ finalS (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); getActO (pstate3, Config pc3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) = getActO (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pc3 ≠ 0; pc4 = 1; int NN ≤ vstore (getVstore (stateOf cfg3')) xx⟧ ⟹ Δ1' ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 h3 p3))) (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (case nextB (cfg1, ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs cfg1)) (case nextB (cfg2, ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs cfg2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⟦Van.eqAct (Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), ibT1, ibUT2, ls3) (Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), ibT2, ibUT2, ls4); pstate3 = pstate4 ∧ (n = enat (7 - pcOf cfg1) ∨ n = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pc3 = Suc 0 ∧ cfgs4 = [] ∧ pc3 ≤ 6 ∧ pcOf cfg1 ≤ 6 ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ getHheap (stateOf cfg1) = hheap h3 ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞ ∧ ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]] ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∧ pc3 = Suc 0 ∧ cfg1 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ∧ cfg2 = Config (Suc 0) (State (Vstore vs4) avst4 h4 p4) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {}; statA' = Diff ⟹ sstatO' statO (Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), ibT1, ibUT2, ls3) (Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), ibT2, ibUT2, ls4) = Diff; pstate4' = pstate4 ∧ cfg4' = Config 2 (State (Vstore (vs4(xx := lhd ibUT4))) avst4 h4 p4) ∧ ibT4' = ibT4 ∧ ibUT4' = ltl ibUT4 ∧ cfgs4' = [] ∧ ls4' = ls4; cfgs3 = []; pstate3' = pstate4; cfg3' = Config 2 (State (Vstore (vs3(xx := lhd ibUT4))) avst3 h3 p3) ∧ ibT3' = ibT3 ∧ ibUT3' = ltl ibUT3; cfgs3' = []; ls3' = ls3; ¬ finalS (pstate4, Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), [], ibT4, ibUT4, ls4); ¬ finalS (pstate4, Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); lhd ibUT3 = lhd ibUT4; pc4 = Suc 0; int NN ≤ lhd ibUT4⟧ ⟹ ∀n. array_loc aa1 0 avst4 ≠ array_loc aa2 n avst4 ∧ array_loc aa1 0 avst3 ≠ array_loc aa2 n avst3›
2. ‹⟦Van.eqAct (Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), ibT1, ibUT2, ls3) (Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), ibT2, ibUT2, ls4); pstate3 = pstate4 ∧ (n = enat (7 - pcOf cfg1) ∨ n = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pc3 = Suc 0 ∧ cfgs4 = [] ∧ pc3 ≤ 6 ∧ pcOf cfg1 ≤ 6 ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ getHheap (stateOf cfg1) = hheap h3 ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞ ∧ ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]] ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∧ pc3 = Suc 0 ∧ cfg1 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ∧ cfg2 = Config (Suc 0) (State (Vstore vs4) avst4 h4 p4) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {}; statA' = Diff ⟹ sstatO' statO (Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), ibT1, ibUT2, ls3) (Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), ibT2, ibUT2, ls4) = Diff; pstate4' = pstate4 ∧ cfg4' = Config 2 (State (Vstore (vs4(xx := lhd ibUT4))) avst4 h4 p4) ∧ ibT4' = ibT4 ∧ ibUT4' = ltl ibUT4 ∧ cfgs4' = [] ∧ ls4' = ls4; cfgs3 = []; pstate3' = pstate4; cfg3' = Config 2 (State (Vstore (vs3(xx := lhd ibUT4))) avst3 h3 p3) ∧ ibT3' = ibT3 ∧ ibUT3' = ltl ibUT3; cfgs3' = []; ls3' = ls3; ¬ finalS (pstate4, Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), [], ibT4, ibUT4, ls4); ¬ finalS (pstate4, Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); lhd ibUT3 = lhd ibUT4; pc4 = Suc 0; int NN ≤ lhd ibUT4⟧ ⟹ ls3 = {}›
3. ‹⟦Van.eqAct (Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), ibT1, ibUT2, ls3) (Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), ibT2, ibUT2, ls4); pstate3 = pstate4 ∧ (n = enat (7 - pcOf cfg1) ∨ n = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pc3 = Suc 0 ∧ cfgs4 = [] ∧ pc3 ≤ 6 ∧ pcOf cfg1 ≤ 6 ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ getHheap (stateOf cfg1) = hheap h3 ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞ ∧ ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]] ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∧ pc3 = Suc 0 ∧ cfg1 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ∧ cfg2 = Config (Suc 0) (State (Vstore vs4) avst4 h4 p4) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {}; statA' = Diff ⟹ sstatO' statO (Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), ibT1, ibUT2, ls3) (Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), ibT2, ibUT2, ls4) = Diff; pstate4' = pstate4 ∧ cfg4' = Config 2 (State (Vstore (vs4(xx := lhd ibUT4))) avst4 h4 p4) ∧ ibT4' = ibT4 ∧ ibUT4' = ltl ibUT4 ∧ cfgs4' = [] ∧ ls4' = ls4; cfgs3 = []; pstate3' = pstate4; cfg3' = Config 2 (State (Vstore (vs3(xx := lhd ibUT4))) avst3 h3 p3) ∧ ibT3' = ibT3 ∧ ibUT3' = ltl ibUT3; cfgs3' = []; ls3' = ls3; ¬ finalS (pstate4, Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), [], ibT4, ibUT4, ls4); ¬ finalS (pstate4, Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); lhd ibUT3 = lhd ibUT4; pc4 = Suc 0; int NN ≤ lhd ibUT4⟧ ⟹ ls4 = {}›
4. ‹⟦Van.eqAct (Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), ibT1, ibUT2, ls3) (Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), ibT2, ibUT2, ls4); pstate3 = pstate4 ∧ (n = enat (7 - pcOf cfg1) ∨ n = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pc3 = Suc 0 ∧ cfgs4 = [] ∧ pc3 ≤ 6 ∧ pcOf cfg1 ≤ 6 ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ getHheap (stateOf cfg1) = hheap h3 ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞ ∧ ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]] ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∧ pc3 = Suc 0 ∧ cfg1 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ∧ cfg2 = Config (Suc 0) (State (Vstore vs4) avst4 h4 p4) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {}; statA' = Diff ⟹ sstatO' statO (Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), ibT1, ibUT2, ls3) (Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), ibT2, ibUT2, ls4) = Diff; pstate4' = pstate4 ∧ cfg4' = Config 2 (State (Vstore (vs4(xx := lhd ibUT4))) avst4 h4 p4) ∧ ibT4' = ibT4 ∧ ibUT4' = ltl ibUT4 ∧ cfgs4' = [] ∧ ls4' = ls4; cfgs3 = []; pstate3' = pstate4; cfg3' = Config 2 (State (Vstore (vs3(xx := lhd ibUT4))) avst3 h3 p3) ∧ ibT3' = ibT3 ∧ ibUT3' = ltl ibUT3; cfgs3' = []; ls3' = ls3; ¬ finalS (pstate4, Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), [], ibT4, ibUT4, ls4); ¬ finalS (pstate4, Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); lhd ibUT3 = lhd ibUT4; pc4 = Suc 0; int NN ≤ lhd ibUT4⟧ ⟹ ls3 ⊆ {array_loc aa1 0 avst3}›
5. ‹⟦Van.eqAct (Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), ibT1, ibUT2, ls3) (Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), ibT2, ibUT2, ls4); pstate3 = pstate4 ∧ (n = enat (7 - pcOf cfg1) ∨ n = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pc3 = Suc 0 ∧ cfgs4 = [] ∧ pc3 ≤ 6 ∧ pcOf cfg1 ≤ 6 ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ getHheap (stateOf cfg1) = hheap h3 ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞ ∧ ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]] ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∧ pc3 = Suc 0 ∧ cfg1 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ∧ cfg2 = Config (Suc 0) (State (Vstore vs4) avst4 h4 p4) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {}; statA' = Diff ⟹ sstatO' statO (Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), ibT1, ibUT2, ls3) (Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), ibT2, ibUT2, ls4) = Diff; pstate4' = pstate4 ∧ cfg4' = Config 2 (State (Vstore (vs4(xx := lhd ibUT4))) avst4 h4 p4) ∧ ibT4' = ibT4 ∧ ibUT4' = ltl ibUT4 ∧ cfgs4' = [] ∧ ls4' = ls4; cfgs3 = []; pstate3' = pstate4; cfg3' = Config 2 (State (Vstore (vs3(xx := lhd ibUT4))) avst3 h3 p3) ∧ ibT3' = ibT3 ∧ ibUT3' = ltl ibUT3; cfgs3' = []; ls3' = ls3; ¬ finalS (pstate4, Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), [], ibT4, ibUT4, ls4); ¬ finalS (pstate4, Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); lhd ibUT3 = lhd ibUT4; pc4 = Suc 0; int NN ≤ lhd ibUT4⟧ ⟹ ls3 = ls4›
6. ‹⟦Van.eqAct (Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), ibT1, ibUT2, ls3) (Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), ibT2, ibUT2, ls4); pstate3 = pstate4 ∧ (n = enat (7 - pcOf cfg1) ∨ n = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pc3 = Suc 0 ∧ cfgs4 = [] ∧ pc3 ≤ 6 ∧ pcOf cfg1 ≤ 6 ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ getHheap (stateOf cfg1) = hheap h3 ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ llength ibUT1 = ∞ ∧ llength ibUT2 = ∞ ∧ llength ibUT3 = ∞ ∧ llength ibUT4 = ∞ ∧ ibUT1 ≠ [[]] ∧ ibUT2 ≠ [[]] ∧ ibUT3 ≠ [[]] ∧ ibUT4 ≠ [[]] ∧ lhd ibUT1 = 0 ∧ ibUT1 = ibUT2 ∧ pc3 = Suc 0 ∧ cfg1 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ∧ cfg2 = Config (Suc 0) (State (Vstore vs4) avst4 h4 p4) ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 = {} ∧ ls2 = {}; statA' = Diff ⟹ sstatO' statO (Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), ibT1, ibUT2, ls3) (Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), ibT2, ibUT2, ls4) = Diff; pstate4' = pstate4 ∧ cfg4' = Config 2 (State (Vstore (vs4(xx := lhd ibUT4))) avst4 h4 p4) ∧ ibT4' = ibT4 ∧ ibUT4' = ltl ibUT4 ∧ cfgs4' = [] ∧ ls4' = ls4; cfgs3 = []; pstate3' = pstate4; cfg3' = Config 2 (State (Vstore (vs3(xx := lhd ibUT4))) avst3 h3 p3) ∧ ibT3' = ibT3 ∧ ibUT3' = ltl ibUT3; cfgs3' = []; ls3' = ls3; ¬ finalS (pstate4, Config (Suc 0) (State (Vstore vs4) avst4 h4 p4), [], ibT4, ibUT4, ls4); ¬ finalS (pstate4, Config (Suc 0) (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); lhd ibUT3 = lhd ibUT4; pc4 = Suc 0; int NN ≤ lhd ibUT4⟧ ⟹ lhd ibUT2 = 0›
discuss goal 1*)
apply metis
(*discuss goal 2*)
apply metis
(*discuss goal 3*)
apply metis
(*discuss goal 4*)
apply blast
(*discuss goal 5*)
apply fastforce
(*discuss goal 6*)
apply fastforce
(*proven 6 subgoals*) . . . .
qed
qed
qed
qed
qed
qed
(**)
lemma step1: "unwindIntoCond Δ1 (oor3 Δ1 Δ2 Δe)"
proof (rule unwindIntoCond_simpleI (*‹⟦⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; ?Δ w s1 s2 statA sv1 sv2 statO⟧ ⟹ finalS s1 = finalS s2 ∧ finalN sv1 = finalS s1 ∧ finalN sv2 = finalS s2; ⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; ?Δ w s1 s2 statA sv1 sv2 statO; statA = status.Eq⟧ ⟹ isIntO s1 = isIntO s2; ⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; ?Δ w s1 s2 statA sv1 sv2 statO⟧ ⟹ match ?Δ' s1 s2 statA sv1 sv2 statO⟧ ⟹ unwindIntoCond ?Δ ?Δ'›*))
(*goals:
1. ‹⋀(w::enat) (s1::predState × config × config list × int llist × int llist × nat set) (s2::predState × config × config list × int llist × int llist × nat set) (statA::status) (sv1::config × int llist × int llist × nat set) (sv2::config × int llist × int llist × nat set) statO::status. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δ1 w s1 s2 statA sv1 sv2 statO⟧ ⟹ finalS s1 = finalS s2 ∧ finalN sv1 = finalS s1 ∧ finalN sv2 = finalS s2›
2. ‹⋀(w::enat) (s1::predState × config × config list × int llist × int llist × nat set) (s2::predState × config × config list × int llist × int llist × nat set) (statA::status) (sv1::config × int llist × int llist × nat set) (sv2::config × int llist × int llist × nat set) statO::status. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δ1 w s1 s2 statA sv1 sv2 statO; statA = status.Eq⟧ ⟹ isIntO s1 = isIntO s2›
3. ‹⋀(w::enat) (s1::predState × config × config list × int llist × int llist × nat set) (s2::predState × config × config list × int llist × int llist × nat set) (statA::status) (sv1::config × int llist × int llist × nat set) (sv2::config × int llist × int llist × nat set) statO::status. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δ1 w s1 s2 statA sv1 sv2 statO⟧ ⟹ match (oor3 Δ1 Δ2 Δe) s1 s2 statA sv1 sv2 statO›*)
fix n and ss3 and ss4 and statA and ss1 and ss2 and statO
assume r: "reachO ss3" "reachO ss4" "reachV ss1" "reachV ss2" and "Δ1": "Δ1 n ss3 ss4 statA ss1 ss2 statO" (*‹reachO (ss3::predState × config × config list × int llist × int llist × nat set)› ‹reachO (ss4::predState × config × config list × int llist × int llist × nat set)› ‹reachV (ss1::config × int llist × int llist × nat set)› ‹reachV (ss2::config × int llist × int llist × nat set)› ‹Δ1 (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
obtain pstate3 and cfg3 and cfgs3 and ibT3 and ibUT3 and ls3 where ss3: "ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)"
(*goal: ‹(⋀pstate3 cfg3 cfgs3 ibT3 ibUT3 ls3. ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⟹ thesis) ⟹ thesis›*)
apply (cases ss3)
(*goal: ‹(⋀pstate3 cfg3 cfgs3 ibT3 ibUT3 ls3. ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⟹ thesis) ⟹ thesis›*)
by auto
obtain pstate4 and cfg4 and cfgs4 and ibT4 and ibUT4 and ls4 where ss4: "ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)"
(*goal: ‹(⋀pstate4 cfg4 cfgs4 ibT4 ibUT4 ls4. ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) ⟹ thesis) ⟹ thesis›*)
apply (cases ss4)
(*goal: ‹(⋀pstate4 cfg4 cfgs4 ibT4 ibUT4 ls4. ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) ⟹ thesis) ⟹ thesis›*)
by auto
obtain cfg1 and ibT1 and ibUT1 and ls1 where ss1: "ss1 = (cfg1, ibT1, ibUT1, ls1)"
(*goal: ‹(⋀cfg1 ibT1 ibUT1 ls1. ss1 = (cfg1, ibT1, ibUT1, ls1) ⟹ thesis) ⟹ thesis›*)
apply (cases ss1)
(*goal: ‹(⋀cfg1 ibT1 ibUT1 ls1. ss1 = (cfg1, ibT1, ibUT1, ls1) ⟹ thesis) ⟹ thesis›*)
by auto
obtain cfg2 and ibT2 and ibUT2 and ls2 where ss2: "ss2 = (cfg2, ibT2, ibUT2, ls2)"
(*goal: ‹(⋀(cfg2::config) (ibT2::int llist) (ibUT2::int llist) ls2::nat set. (ss2::config × int llist × int llist × nat set) = (cfg2, ibT2, ibUT2, ls2) ⟹ thesis::bool) ⟹ thesis›*)
apply (cases ss2)
(*goal: ‹(⋀(cfg2::config) (ibT2::int llist) (ibUT2::int llist) ls2::nat set. (ss2::config × int llist × int llist × nat set) = (cfg2, ibT2, ibUT2, ls2) ⟹ thesis::bool) ⟹ thesis›*)
by auto
note ss = ss3 (*‹(ss3::predState × config × config list × int llist × int llist × nat set) = (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set)›*) ss4 (*‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*) ss1 (*‹ss1 = (cfg1, ibT1, ibUT1, ls1)›*) ss2 (*‹ss2 = (cfg2, ibT2, ibUT2, ls2)›*)
obtain pc1 and vs1 and avst1 and h1 and p1 where cfg1: "cfg1 = Config pc1 (State (Vstore vs1) avst1 h1 p1)"
(*goal: ‹(⋀pc1 vs1 avst1 h1 p1. cfg1 = Config pc1 (State (Vstore vs1) avst1 h1 p1) ⟹ thesis) ⟹ thesis›*)
apply (cases cfg1)
(*goal: ‹(⋀pc1 vs1 avst1 h1 p1. cfg1 = Config pc1 (State (Vstore vs1) avst1 h1 p1) ⟹ thesis) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore ?state) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore ?vstorea) = ?vstorea›*))
obtain pc2 and vs2 and avst2 and h2 and p2 where cfg2: "cfg2 = Config pc2 (State (Vstore vs2) avst2 h2 p2)"
(*goal: ‹(⋀pc2 vs2 avst2 h2 p2. cfg2 = Config pc2 (State (Vstore vs2) avst2 h2 p2) ⟹ thesis) ⟹ thesis›*)
apply (cases cfg2)
(*goal: ‹(⋀(pc2::nat) (vs2::char list ⇒ int) (avst2::avstore) (h2::heap) p2::nat. (cfg2::config) = Config pc2 (State (Vstore vs2) avst2 h2 p2) ⟹ thesis::bool) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore ?state) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore ?vstorea) = ?vstorea›*))
obtain pc3 and vs3 and avst3 and h3 and p3 where cfg3: "cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)"
(*goal: ‹(⋀pc3 vs3 avst3 h3 p3. cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ⟹ thesis) ⟹ thesis›*)
apply (cases cfg3)
(*goal: ‹(⋀pc3 vs3 avst3 h3 p3. cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ⟹ thesis) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore (?state::state)) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore (?vstorea::vstore)) = ?vstorea›*))
obtain pc4 and vs4 and avst4 and h4 and p4 where cfg4: "cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)"
(*goal: ‹(⋀(pc4::nat) (vs4::char list ⇒ int) (avst4::avstore) (h4::heap) p4::nat. (cfg4::config) = Config pc4 (State (Vstore vs4) avst4 h4 p4) ⟹ thesis::bool) ⟹ thesis›*)
apply (cases cfg4)
(*goal: ‹(⋀pc4 vs4 avst4 h4 p4. cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ⟹ thesis) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore ?state) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore ?vstorea) = ?vstorea›*))
note cfg = cfg1 (*‹cfg1 = Config pc1 (State (Vstore vs1) avst1 h1 p1)›*) cfg2 (*‹cfg2 = Config pc2 (State (Vstore vs2) avst2 h2 p2)›*) cfg3 (*‹cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)›*) cfg4 (*‹cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)›*)
obtain hh3 where h3: "h3 = Heap hh3"
(*goal: ‹(⋀hh3. h3 = Heap hh3 ⟹ thesis) ⟹ thesis›*)
apply (cases h3)
(*goal: ‹(⋀hh3. h3 = Heap hh3 ⟹ thesis) ⟹ thesis›*)
by auto
obtain hh4 where h4: "h4 = Heap hh4"
(*goal: ‹(⋀hh4::nat ⇒ int. (h4::heap) = Heap hh4 ⟹ thesis::bool) ⟹ thesis›*)
apply (cases h4)
(*goal: ‹(⋀hh4::nat ⇒ int. (h4::heap) = Heap hh4 ⟹ thesis::bool) ⟹ thesis›*)
by auto
note hh = h3 (*‹h3 = Heap hh3›*) h4 (*‹(h4::heap) = Heap (hh4::nat ⇒ int)›*)
have f1: "¬finalN ss1"
using "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) finalB_pc_iff' (*‹?pc < 7 ⟹ finalB (Config ?pc ?s, ?ibT, ?ibUT) = (?pc = 1 ∧ ?ibUT = [[]])›*) unfolding ss cfg finalN_iff_finalB "Δ1_defs"
(*goal: ‹¬ finalB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1)›*)
by simp
have f2: "¬finalN ss2"
using "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) finalB_pc_iff' (*‹(?pc::nat) < (7::nat) ⟹ finalB (Config ?pc (?s::state), ?ibT::int llist, ?ibUT::int llist) = (?pc = (1::nat) ∧ ?ibUT = [[]])›*) unfolding ss cfg finalN_iff_finalB "Δ1_defs"
(*goal: ‹¬ finalB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2)›*)
by simp
have f3: "¬finalS ss3"
using "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹¬ finalS (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
apply -
(*goal: ‹¬ finalS (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
apply (frule Δ1_implies (*‹Δ1 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ pcOf ?cfg1.0 < 7 ∧ ?cfgs3.0 = [] ∧ pcOf ?cfg3.0 ≠ 1 ∧ pcOf ?cfg3.0 < 7 ∧ ?cfgs4.0 = [] ∧ pcOf ?cfg4.0 ≠ 1 ∧ pcOf ?cfg4.0 < 7›*))
(*goal: ‹Δ1 n (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ ¬ finalS (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
using finalS_cond (*‹⟦pcOf ?cfg < 7; ?cfgs = []; pcOf ?cfg = 1 ⟶ ?ibUT ≠ [[]]⟧ ⟹ ¬ finalS (?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls)›*) by simp
have f4: "¬finalS ss4"
using "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹¬ finalS (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply -
(*goal: ‹¬ finalS (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set)›*)
apply (frule Δ1_implies (*‹Δ1 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ pcOf ?cfg1.0 < 7 ∧ ?cfgs3.0 = [] ∧ pcOf ?cfg3.0 ≠ 1 ∧ pcOf ?cfg3.0 < 7 ∧ ?cfgs4.0 = [] ∧ pcOf ?cfg4.0 ≠ 1 ∧ pcOf ?cfg4.0 < 7›*))
(*goal: ‹Δ1 n (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ ¬ finalS (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
using finalS_cond (*‹⟦pcOf ?cfg < 7; ?cfgs = []; pcOf ?cfg = 1 ⟶ ?ibUT ≠ [[]]⟧ ⟹ ¬ finalS (?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls)›*) by simp
note finals = f1 (*‹¬ finalN ss1›*) f2 (*‹¬ finalN (ss2::config × int llist × int llist × nat set)›*) f3 (*‹¬ finalS ss3›*) f4 (*‹¬ finalS ss4›*)
show "finalS ss3 = finalS ss4 ∧ finalN ss1 = finalS ss3 ∧ finalN ss2 = finalS ss4"
using finals (*‹¬ finalN ss1› ‹¬ finalN (ss2::config × int llist × int llist × nat set)› ‹¬ finalS ss3› ‹¬ finalS (ss4::predState × config × config list × int llist × int llist × nat set)›*) by auto
then show "isIntO ss3 = isIntO ss4"
by simp
show "match (oor3 Δ1 Δ2 Δe) ss3 ss4 statA ss1 ss2 statO"
unfolding match_def
(*goal: ‹match1 (oor3 Δ1 Δ2 Δe) ss3 ss4 statA ss1 ss2 statO ∧ match2 (oor3 Δ1 Δ2 Δe) ss3 ss4 statA ss1 ss2 statO ∧ match12 (oor3 Δ1 Δ2 Δe) ss3 ss4 statA ss1 ss2 statO›*)
proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹match1 (oor3 Δ1 Δ2 Δe) ss3 ss4 statA ss1 ss2 statO›
2. ‹match2 (oor3 Δ1 Δ2 Δe) ss3 ss4 statA ss1 ss2 statO›
3. ‹match12 (oor3 Δ1 Δ2 Δe) ss3 ss4 statA ss1 ss2 statO›*)
show "match1 (oor3 Δ1 Δ2 Δe) ss3 ss4 statA ss1 ss2 statO"
unfolding match1_def
(*goal: ‹¬ isIntO ss3 ⟶ (∀s1'. validTransO (ss3, s1') ⟶ ¬ isSecO ss3 ∧ oor3 Δ1 Δ2 Δe ∞ s1' ss4 statA ss1 ss2 statO ∨ eqSec ss1 ss3 ∧ ¬ isIntV ss1 ∧ match1_1 (oor3 Δ1 Δ2 Δe) ss3 s1' ss4 statA ss1 ss2 statO ∨ eqSec ss1 ss3 ∧ ¬ isSecV ss2 ∧ Van.eqAct ss1 ss2 ∧ match1_12 (oor3 Δ1 Δ2 Δe) ss3 s1' ss4 statA ss1 ss2 statO)›*)
by (simp add: finalS_def (*‹finalS = final (→S)›*) final_def (*‹final ?r ?x ≡ ∀y. ¬ ?r ?x y›*))
show "match2 (oor3 Δ1 Δ2 Δe) ss3 ss4 statA ss1 ss2 statO"
unfolding match2_def
(*goal: ‹¬ isIntO (ss4::predState × config × config list × int llist × int llist × nat set) ⟶ (∀s2'::predState × config × config list × int llist × int llist × nat set. validTransO (ss4, s2') ⟶ ¬ isSecO ss4 ∧ oor3 Δ1 Δ2 Δe ∞ (ss3::predState × config × config list × int llist × int llist × nat set) s2' (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status) ∨ eqSec ss2 ss4 ∧ ¬ isIntV ss2 ∧ match2_1 (oor3 Δ1 Δ2 Δe) ss3 ss4 s2' statA ss1 ss2 statO ∨ ¬ isSecV ss1 ∧ eqSec ss2 ss4 ∧ Van.eqAct ss1 ss2 ∧ match2_12 (oor3 Δ1 Δ2 Δe) ss3 ss4 s2' statA ss1 ss2 statO)›*)
by (simp add: finalS_def (*‹finalS = final (→S)›*) final_def (*‹final (?r::?'a ⇒ ?'b ⇒ bool) (?x::?'a) ≡ ∀y::?'b. ¬ ?r ?x y›*))
show "match12 (oor3 Δ1 Δ2 Δe) ss3 ss4 statA ss1 ss2 statO"
proof (rule match12_simpleI (*‹(⋀s1' s2' statA'. ⟦statA' = sstatA' ?statA ?s1.0 ?s2.0; validTransO (?s1.0, s1'); validTransO (?s2.0, s2'); Opt.eqAct ?s1.0 ?s2.0⟧ ⟹ ¬ isSecO ?s1.0 ∧ ¬ isSecO ?s2.0 ∧ (?statA = statA' ∨ ?statO = Diff) ∧ ?Δ ∞ s1' s2' statA' ?sv1.0 ?sv2.0 ?statO ∨ eqSec ?sv1.0 ?s1.0 ∧ eqSec ?sv2.0 ?s2.0 ∧ Van.eqAct ?sv1.0 ?sv2.0 ∧ match12_12 ?Δ s1' s2' statA' ?sv1.0 ?sv2.0 ?statO) ⟹ match12 ?Δ ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*), rule disjI2 (*‹?Q ⟹ ?P ∨ ?Q›*), intro conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⋀s1' s2' statA'. ⟦statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ eqSec ss1 ss3›
2. ‹⋀s1' s2' statA'. ⟦statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ eqSec ss2 ss4›
3. ‹⋀s1' s2' statA'. ⟦statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ Van.eqAct ss1 ss2›
4. ‹⋀s1' s2' statA'. ⟦statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ match12_12 (oor3 Δ1 Δ2 Δe) s1' s2' statA' ss1 ss2 statO›*)
fix ss3' and ss4' and statA'
assume statA': "statA' = sstatA' statA ss3 ss4" and v: "validTransO (ss3, ss3')" "validTransO (ss4, ss4')" and sa: "Opt.eqAct ss3 ss4" (*‹(statA'::status) = sstatA' (statA::status) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss3::predState × config × config list × int llist × int llist × nat set, ss3'::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)› ‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*)
note v3 = v(1) (*‹validTransO (ss3, ss3')›*)
note v4 = v(2) (*‹validTransO (ss4, ss4')›*)
obtain pstate3' and cfg3' and cfgs3' and ibT3' and ibUT3' and ls3' where ss3': "ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')"
(*goal: ‹(⋀(pstate3'::predState) (cfg3'::config) (cfgs3'::config list) (ibT3'::int llist) (ibUT3'::int llist) ls3'::nat set. (ss3'::predState × config × config list × int llist × int llist × nat set) = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') ⟹ thesis::bool) ⟹ thesis›*)
apply (cases ss3')
(*goal: ‹(⋀pstate3' cfg3' cfgs3' ibT3' ibUT3' ls3'. ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') ⟹ thesis) ⟹ thesis›*)
by auto
obtain pstate4' and cfg4' and cfgs4' and ibT4' and ibUT4' and ls4' where ss4': "ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')"
(*goal: ‹(⋀pstate4' cfg4' cfgs4' ibT4' ibUT4' ls4'. ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') ⟹ thesis) ⟹ thesis›*)
apply (cases ss4')
(*goal: ‹(⋀pstate4' cfg4' cfgs4' ibT4' ibUT4' ls4'. ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') ⟹ thesis) ⟹ thesis›*)
by auto
note ss = ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)› ‹ss1 = (cfg1, ibT1, ibUT1, ls1)› ‹(ss2::config × int llist × int llist × nat set) = (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)›*) ss3' (*‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')›*) ss4' (*‹(ss4'::predState × config × config list × int llist × int llist × nat set) = (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set)›*)
show "eqSec ss1 ss3"
using v (*‹validTransO (ss3::predState × config × config list × int llist × int llist × nat set, ss3'::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹eqSec (cfg1, ibT1, ibUT1, ls1) (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
by (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*) eqSec_def (*‹eqSec ?trnO ?trnA ≡ isSecV ?trnO = isSecO ?trnA ∧ (isSecV ?trnO ⟶ getSecV ?trnO = getSecO ?trnA)›*))
show "eqSec ss2 ss4"
using v (*‹validTransO (ss3::predState × config × config list × int llist × int llist × nat set, ss3'::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) unfolding ss
(*goal: ‹eqSec (cfg2, ibT2, ibUT2, ls2) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
by (simp add: Δ1_defs (*‹Δ1 = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []›*) eqSec_def (*‹eqSec (?trnO::config × int llist × int llist × nat set) (?trnA::predState × config × config list × int llist × int llist × nat set) ≡ isSecV ?trnO = isSecO ?trnA ∧ (isSecV ?trnO ⟶ getSecV ?trnO = getSecO ?trnA)›*))
show "Van.eqAct ss1 ss2"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss Van.eqAct_def
(*goal: ‹isIntV (cfg1, ibT1, ibUT1, ls1) = isIntV (cfg2, ibT2, ibUT2, ls2) ∧ (isIntV (cfg1, ibT1, ibUT1, ls1) ⟶ getActV (cfg1, ibT1, ibUT1, ls1) = getActV (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
show "match12_12 (oor3 Δ1 Δ2 Δe) ss3' ss4' statA' ss1 ss2 statO"
unfolding match12_12_def
(*goal: ‹∃(sv1'::config × int llist × int llist × nat set) sv2'::config × int llist × int llist × nat set. let statO'::status = sstatO' (statO::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) in validTransV (ss1, sv1') ∧ validTransV (ss2, sv2') ∧ ((statA'::status) = Diff ⟶ statO' = Diff) ∧ oor3 Δ1 Δ2 Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) statA' sv1' sv2' statO'›*)
proof (rule exI[of _ "nextN ss1"] (*‹?P (nextN ss1) ⟹ ∃x. ?P x›*), rule exI[of _ "nextN ss2"] (*‹?P (nextN ss2) ⟹ ∃x. ?P x›*), unfold Let_def (*‹Let ?s ?f ≡ ?f ?s›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goals:
1. ‹validTransV (ss1, nextN ss1)›
2. ‹validTransV (ss2, nextN ss2)›
3. ‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›
4. ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
show "validTransV (ss1, nextN ss1)"
by (simp add: f1 (*‹¬ finalN ss1›*) nextN_stepN (*‹¬ finalN ?cfg_ib_ls ⟹ ?cfg_ib_ls →N nextN ?cfg_ib_ls›*))
show "validTransV (ss2, nextN ss2)"
by (simp add: f2 (*‹¬ finalN ss2›*) nextN_stepN (*‹¬ finalN ?cfg_ib_ls ⟹ ?cfg_ib_ls →N nextN ?cfg_ib_ls›*))
{
assume sstat: "statA' = Diff" (*‹(statA'::status) = Diff›*)
show "sstatO' statO ss1 ss2 = Diff"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) sstat (*‹statA' = Diff›*) unfolding ss cfg statA'
(*goal: ‹sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff›*)
apply (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*) sstatO'_def (*‹sstatO' ?statO ?sv1.0 ?sv2.0 = updStat ?statO (isIntV ?sv1.0, getObsV ?sv1.0) (isIntV ?sv2.0, getObsV ?sv2.0)›*) sstatA'_def (*‹sstatA' ?statA ?s1.0 ?s2.0 = updStat ?statA (isIntO ?s1.0, getObsO ?s1.0) (isIntO ?s2.0, getObsO ?s2.0)›*))
(*goal: ‹sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff›*)
using cases_6[of pc3] (*‹pc3 = 0 ∨ pc3 = 1 ∨ pc3 = 2 ∨ pc3 = 3 ∨ pc3 = 4 ∨ pc3 = 5 ∨ pc3 = 6 ∨ 6 < pc3›*) apply (elim disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⟦(pstate4::predState, Config (pc4::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)), [], ibT3::int llist, ibUT3::int llist, ls3::nat set) →S (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set); (pstate4, Config pc4 (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); (pstate3::predState) = pstate4 ∧ (pc1::nat) = (pc3::nat) ∧ (vs1::char list ⇒ int) = vs3 ∧ (avst1::avstore) = avst3 ∧ (h1::heap) = h3 ∧ (p1::nat) = p3 ∧ (pc2::nat) = pc4 ∧ (vs2::char list ⇒ int) = vs4 ∧ (avst2::avstore) = avst4 ∧ (h2::heap) = h4 ∧ (p2::nat) = p4 ∧ pc3 = pc4 ∧ map pcOf (cfgs3::config list) = map pcOf cfgs4 ∧ pc3 ≤ (6::nat) ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''::config∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''::config∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n::nat. array_loc aa1 (0::nat) avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 (0::nat) avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ ((statA::status) = Diff ⟶ (statO::status) = Diff) ∧ (2::nat) ≤ pc3 ∧ pc3 ≤ (6::nat) ∧ vs3 xx = vs4 xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ (ls1::nat set) = ls3 ∧ (ls2::nat set) = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), if pc4 = (6::nat) then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))) (stateOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))), ls3) else ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if pc4 = (6::nat) ∧ cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff⟧ ⟹ (pc4 = (6::nat) ⟶ updStat statO (True, ⊥, ls3) (True, ⊥, ls4) = Diff) ∧ (pc4 ≠ (6::nat) ⟶ updStat statO (True, ⊥) (True, ⊥) = Diff)›*)
defer 1
(*top goal: ‹⟦(pstate4::predState, Config (pc4::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)), [], ibT3::int llist, ibUT3::int llist, ls3::nat set) →S (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set); (pstate4, Config pc4 (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); (pstate3::predState) = pstate4 ∧ (pc1::nat) = (pc3::nat) ∧ (vs1::char list ⇒ int) = vs3 ∧ (avst1::avstore) = avst3 ∧ (h1::heap) = h3 ∧ (p1::nat) = p3 ∧ (pc2::nat) = pc4 ∧ (vs2::char list ⇒ int) = vs4 ∧ (avst2::avstore) = avst4 ∧ (h2::heap) = h4 ∧ (p2::nat) = p4 ∧ pc3 = pc4 ∧ map pcOf (cfgs3::config list) = map pcOf cfgs4 ∧ pc3 ≤ (6::nat) ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''::config∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''::config∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n::nat. array_loc aa1 (0::nat) avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 (0::nat) avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ ((statA::status) = Diff ⟶ (statO::status) = Diff) ∧ (2::nat) ≤ pc3 ∧ pc3 ≤ (6::nat) ∧ vs3 xx = vs4 xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ (ls1::nat set) = ls3 ∧ (ls2::nat set) = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), if pc4 = (6::nat) then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))) (stateOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))), ls3) else ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if pc4 = (6::nat) ∧ cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; pc3 = (1::nat)⟧ ⟹ (pc4 = (6::nat) ⟶ updStat statO (True, ⊥, ls3) (True, ⊥, ls4) = Diff) ∧ (pc4 ≠ (6::nat) ⟶ updStat statO (True, ⊥) (True, ⊥) = Diff)› and 7 goals remain*)
defer 1
(*top goal: ‹⟦(pstate4::predState, Config (pc4::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)), [], ibT3::int llist, ibUT3::int llist, ls3::nat set) →S (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set); (pstate4, Config pc4 (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); (pstate3::predState) = pstate4 ∧ (pc1::nat) = (pc3::nat) ∧ (vs1::char list ⇒ int) = vs3 ∧ (avst1::avstore) = avst3 ∧ (h1::heap) = h3 ∧ (p1::nat) = p3 ∧ (pc2::nat) = pc4 ∧ (vs2::char list ⇒ int) = vs4 ∧ (avst2::avstore) = avst4 ∧ (h2::heap) = h4 ∧ (p2::nat) = p4 ∧ pc3 = pc4 ∧ map pcOf (cfgs3::config list) = map pcOf cfgs4 ∧ pc3 ≤ (6::nat) ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''::config∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''::config∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n::nat. array_loc aa1 (0::nat) avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 (0::nat) avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ ((statA::status) = Diff ⟶ (statO::status) = Diff) ∧ (2::nat) ≤ pc3 ∧ pc3 ≤ (6::nat) ∧ vs3 xx = vs4 xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ (ls1::nat set) = ls3 ∧ (ls2::nat set) = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), if pc4 = (6::nat) then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))) (stateOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))), ls3) else ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if pc4 = (6::nat) ∧ cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; pc3 = (2::nat)⟧ ⟹ (pc4 = (6::nat) ⟶ updStat statO (True, ⊥, ls3) (True, ⊥, ls4) = Diff) ∧ (pc4 ≠ (6::nat) ⟶ updStat statO (True, ⊥) (True, ⊥) = Diff)› and 7 goals remain*)
subgoal for
apply (cases statO, simp_all)
(*goal: ‹⟦(pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ pc1 = pc3 ∧ vs1 = vs3 ∧ avst1 = avst3 ∧ h1 = h3 ∧ p1 = p3 ∧ pc2 = pc4 ∧ vs2 = vs4 ∧ avst2 = avst4 ∧ h2 = h4 ∧ p2 = p4 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), if pc4 = 6 then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))) (stateOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))), ls3) else ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if pc4 = 6 ∧ cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; pc3 = 2⟧ ⟹ (pc4 = 6 ⟶ updStat statO (True, ⊥, ls3) (True, ⊥, ls4) = Diff) ∧ (pc4 ≠ 6 ⟶ updStat statO (True, ⊥) (True, ⊥) = Diff)›*)
apply (cases statA, simp_all)
(*goal: ‹⟦pstate3' = pstate4 ∧ cfg3' = Config 3 (State (Vstore (vs3(tt := 0))) avst3 h3 p3) ∧ ibT3' = ibT3 ∧ ibUT3' = ibUT3 ∧ cfgs3' = [] ∧ ls3' = ls3; (pstate4, Config 2 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config 2 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config 2 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ pc1 = 2 ∧ vs1 = vs3 ∧ avst1 = avst3 ∧ h1 = h3 ∧ p1 = p3 ∧ pc2 = pc4 ∧ vs2 = vs4 ∧ avst2 = avst4 ∧ h2 = h4 ∧ p2 = p4 ∧ pc4 = 2 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ statA ≠ Diff ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config 2 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), ⊥) (¬ finalS (pstate4, Config 2 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), ⊥) = Diff; pc3 = 2; statO = status.Eq⟧ ⟹ False›*)
using cfg (*‹cfg1 = Config pc1 (State (Vstore vs1) avst1 h1 p1)› ‹cfg2 = Config pc2 (State (Vstore vs2) avst2 h2 p2)› ‹(cfg3::config) = Config (pc3::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat))› ‹(cfg4::config) = Config (pc4::nat) (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat))›*) finals (*‹¬ finalN ss1› ‹¬ finalN ss2› ‹¬ finalS ss3› ‹¬ finalS ss4›*) ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)› ‹ss1 = (cfg1, ibT1, ibUT1, ls1)› ‹ss2 = (cfg2, ibT2, ibUT2, ls2)› ‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')› ‹(ss4'::predState × config × config list × int llist × int llist × nat set) = (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set)›*) status.distinct(1) (*‹status.Eq ≠ Diff›*) updStat.simps (*‹updStat status.Eq (True, ?a::?'a) (True, ?a'::?'a) = (if ?a = ?a' then status.Eq else Diff)› ‹updStat Diff ?uu ?uv = Diff› ‹updStat ?stat (False, ?va) ?uv = ?stat› ‹updStat ?stat ?uu (False, ?va) = ?stat›*) by auto
subgoal for
apply (cases statO, simp_all)
(*goal: ‹⟦(pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ pc1 = pc3 ∧ vs1 = vs3 ∧ avst1 = avst3 ∧ h1 = h3 ∧ p1 = p3 ∧ pc2 = pc4 ∧ vs2 = vs4 ∧ avst2 = avst4 ∧ h2 = h4 ∧ p2 = p4 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), if pc4 = 6 then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))) (stateOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))), ls3) else ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if pc4 = 6 ∧ cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; pc3 = 3⟧ ⟹ (pc4 = 6 ⟶ updStat statO (True, ⊥, ls3) (True, ⊥, ls4) = Diff) ∧ (pc4 ≠ 6 ⟶ updStat statO (True, ⊥) (True, ⊥) = Diff)›*)
apply (cases statA, simp_all)
(*goal: ‹⟦(pstate4, Config 3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); (pstate4, Config 3 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config 3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config 3 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ pc1 = 3 ∧ vs1 = vs3 ∧ avst1 = avst3 ∧ h1 = h3 ∧ p1 = p3 ∧ pc2 = pc4 ∧ vs2 = vs4 ∧ avst2 = avst4 ∧ h2 = h4 ∧ p2 = p4 ∧ pc4 = 3 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ statA ≠ Diff ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config 3 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), ⊥) (¬ finalS (pstate4, Config 3 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), ⊥) = Diff; pc3 = 3; statO = status.Eq⟧ ⟹ False›*)
using cfg (*‹cfg1 = Config pc1 (State (Vstore vs1) avst1 h1 p1)› ‹cfg2 = Config pc2 (State (Vstore vs2) avst2 h2 p2)› ‹(cfg3::config) = Config (pc3::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat))› ‹cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)›*) finals (*‹¬ finalN ss1› ‹¬ finalN ss2› ‹¬ finalS ss3› ‹¬ finalS ss4›*) ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)› ‹ss1 = (cfg1, ibT1, ibUT1, ls1)› ‹ss2 = (cfg2, ibT2, ibUT2, ls2)› ‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')› ‹(ss4'::predState × config × config list × int llist × int llist × nat set) = (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set)›*) status.distinct(1) (*‹status.Eq ≠ Diff›*) updStat.simps (*‹updStat status.Eq (True, ?a) (True, ?a') = (if ?a = ?a' then status.Eq else Diff)› ‹updStat Diff ?uu ?uv = Diff› ‹updStat ?stat (False, ?va) ?uv = ?stat› ‹updStat ?stat ?uu (False, ?va) = ?stat›*) by auto
subgoal for
apply (cases statO, simp_all)
(*goal: ‹⟦(pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ pc1 = pc3 ∧ vs1 = vs3 ∧ avst1 = avst3 ∧ h1 = h3 ∧ p1 = p3 ∧ pc2 = pc4 ∧ vs2 = vs4 ∧ avst2 = avst4 ∧ h2 = h4 ∧ p2 = p4 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), if pc4 = 6 then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))) (stateOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))), ls3) else ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if pc4 = 6 ∧ cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; pc3 = 4⟧ ⟹ (pc4 = 6 ⟶ updStat statO (True, ⊥, ls3) (True, ⊥, ls4) = Diff) ∧ (pc4 ≠ 6 ⟶ updStat statO (True, ⊥) (True, ⊥) = Diff)›*)
apply (cases statA, simp_all)
(*goal: ‹⟦(pstate3'::predState) = (pstate4::predState) ∧ (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (Config (4::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)), ibT3::int llist, ibUT3::int llist) ∧ (cfgs3'::config list) = [] ∧ (ls3'::nat set) = insert (array_loc aa1 (0::nat) avst3) (ls3::nat set); (pstate4, Config (4::nat) (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); Opt.eqAct (pstate4, Config (4::nat) (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config (4::nat) (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); (pstate3::predState) = pstate4 ∧ (pc1::nat) = (4::nat) ∧ (vs1::char list ⇒ int) = vs3 ∧ (avst1::avstore) = avst3 ∧ (h1::heap) = h3 ∧ (p1::nat) = p3 ∧ (pc2::nat) = (pc4::nat) ∧ (vs2::char list ⇒ int) = vs4 ∧ (avst2::avstore) = avst4 ∧ (h2::heap) = h4 ∧ (p2::nat) = p4 ∧ pc4 = (4::nat) ∧ map pcOf (cfgs3::config list) = map pcOf cfgs4 ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''::config∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''::config∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n::nat. array_loc aa1 (0::nat) avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 (0::nat) avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA::status) ≠ Diff ∧ vs3 xx = vs4 xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ (ls1::nat set) = ls3 ∧ (ls2::nat set) = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config (4::nat) (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), ⊥) (¬ finalS (pstate4, Config (4::nat) (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), ⊥) = Diff; (pc3::nat) = (4::nat); (statO::status) = status.Eq⟧ ⟹ False›*)
using cfg (*‹cfg1 = Config pc1 (State (Vstore vs1) avst1 h1 p1)› ‹cfg2 = Config pc2 (State (Vstore vs2) avst2 h2 p2)› ‹cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)› ‹cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)›*) finals (*‹¬ finalN ss1› ‹¬ finalN ss2› ‹¬ finalS ss3› ‹¬ finalS ss4›*) ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)› ‹ss1 = (cfg1, ibT1, ibUT1, ls1)› ‹(ss2::config × int llist × int llist × nat set) = (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)› ‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')› ‹(ss4'::predState × config × config list × int llist × int llist × nat set) = (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set)›*) status.distinct(1) (*‹status.Eq ≠ Diff›*) updStat.simps (*‹updStat status.Eq (True, ?a::?'a::type) (True, ?a'::?'a::type) = (if ?a = ?a' then status.Eq else Diff)› ‹updStat Diff ?uu ?uv = Diff› ‹updStat ?stat (False, ?va) ?uv = ?stat› ‹updStat ?stat ?uu (False, ?va) = ?stat›*) by auto
subgoal for
apply (cases statO, simp_all)
(*goal: ‹⟦(pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ pc1 = pc3 ∧ vs1 = vs3 ∧ avst1 = avst3 ∧ h1 = h3 ∧ p1 = p3 ∧ pc2 = pc4 ∧ vs2 = vs4 ∧ avst2 = avst4 ∧ h2 = h4 ∧ p2 = p4 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), if pc4 = 6 then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))) (stateOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))), ls3) else ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if pc4 = 6 ∧ cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; pc3 = 5⟧ ⟹ (pc4 = 6 ⟶ updStat statO (True, ⊥, ls3) (True, ⊥, ls4) = Diff) ∧ (pc4 ≠ 6 ⟶ updStat statO (True, ⊥) (True, ⊥) = Diff)›*)
apply (cases statA, simp_all)
(*goal: ‹⟦pstate3' = pstate4 ∧ (cfg3', ibT3', ibUT3') = nextB (Config 5 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3) ∧ cfgs3' = [] ∧ ls3' = insert (array_loc aa2 (nat (vs3 vv * 512)) avst3) ls3; (pstate4, Config 5 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config 5 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config 5 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ pc1 = 5 ∧ vs1 = vs3 ∧ avst1 = avst3 ∧ h1 = h3 ∧ p1 = p3 ∧ pc2 = pc4 ∧ vs2 = vs4 ∧ avst2 = avst4 ∧ h2 = h4 ∧ p2 = p4 ∧ pc4 = 5 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ statA ≠ Diff ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config 5 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), ⊥) (¬ finalS (pstate4, Config 5 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), ⊥) = Diff; pc3 = 5; statO = status.Eq⟧ ⟹ False›*)
using cfg (*‹cfg1 = Config pc1 (State (Vstore vs1) avst1 h1 p1)› ‹cfg2 = Config pc2 (State (Vstore vs2) avst2 h2 p2)› ‹cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)› ‹cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)›*) finals (*‹¬ finalN ss1› ‹¬ finalN ss2› ‹¬ finalS ss3› ‹¬ finalS ss4›*) ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹(ss4::predState × config × config list × int llist × int llist × nat set) = (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set)› ‹ss1 = (cfg1, ibT1, ibUT1, ls1)› ‹(ss2::config × int llist × int llist × nat set) = (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)› ‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')› ‹ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*) status.distinct(1) (*‹status.Eq ≠ Diff›*) updStat.simps (*‹updStat status.Eq (True, ?a) (True, ?a') = (if ?a = ?a' then status.Eq else Diff)› ‹updStat Diff ?uu ?uv = Diff› ‹updStat ?stat (False, ?va) ?uv = ?stat› ‹updStat ?stat ?uu (False, ?va) = ?stat›*) by auto
subgoal for
apply (cases statO, simp_all)
(*goal: ‹⟦(pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ pc1 = pc3 ∧ vs1 = vs3 ∧ avst1 = avst3 ∧ h1 = h3 ∧ p1 = p3 ∧ pc2 = pc4 ∧ vs2 = vs4 ∧ avst2 = avst4 ∧ h2 = h4 ∧ p2 = p4 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), if pc4 = 6 then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))) (stateOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))), ls3) else ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if pc4 = 6 ∧ cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; pc3 = 6⟧ ⟹ (pc4 = 6 ⟶ updStat statO (True, ⊥, ls3) (True, ⊥, ls4) = Diff) ∧ (pc4 ≠ 6 ⟶ updStat statO (True, ⊥) (True, ⊥) = Diff)›*)
apply (cases statA, simp_all)
(*goal: ‹⟦(pstate3'::predState) = (pstate4::predState) ∧ (cfg3'::config) = Config (7::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)) ∧ (ibT3'::int llist) = (ibT3::int llist) ∧ (ibUT3'::int llist) = (ibUT3::int llist) ∧ (cfgs3'::config list) = [] ∧ (ls3'::nat set) = (ls3::nat set); (pstate4, Config (6::nat) (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); Opt.eqAct (pstate4, Config (6::nat) (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config (6::nat) (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); (pstate3::predState) = pstate4 ∧ (pc1::nat) = (6::nat) ∧ (vs1::char list ⇒ int) = vs3 ∧ (avst1::avstore) = avst3 ∧ (h1::heap) = h3 ∧ (p1::nat) = p3 ∧ (pc2::nat) = (pc4::nat) ∧ (vs2::char list ⇒ int) = vs4 ∧ (avst2::avstore) = avst4 ∧ (h2::heap) = h4 ∧ (p2::nat) = p4 ∧ pc4 = (6::nat) ∧ map pcOf (cfgs3::config list) = map pcOf cfgs4 ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''::config∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''::config∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n::nat. array_loc aa1 (0::nat) avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 (0::nat) avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA::status) ≠ Diff ∧ vs3 xx = vs4 xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ (ls1::nat set) = ls3 ∧ (ls2::nat set) = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config (6::nat) (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), ⊥, ls3) (¬ finalS (pstate4, Config (6::nat) (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; (pc3::nat) = (6::nat); (statO::status) = status.Eq⟧ ⟹ ls3 ≠ ls4›*)
using cfg (*‹cfg1 = Config pc1 (State (Vstore vs1) avst1 h1 p1)› ‹(cfg2::config) = Config (pc2::nat) (State (Vstore (vs2::char list ⇒ int)) (avst2::avstore) (h2::heap) (p2::nat))› ‹cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)› ‹cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)›*) finals (*‹¬ finalN ss1› ‹¬ finalN ss2› ‹¬ finalS ss3› ‹¬ finalS ss4›*) ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)› ‹ss1 = (cfg1, ibT1, ibUT1, ls1)› ‹ss2 = (cfg2, ibT2, ibUT2, ls2)› ‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')› ‹ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*) status.distinct(1) (*‹status.Eq ≠ Diff›*) updStat.simps (*‹updStat status.Eq (True, ?a) (True, ?a') = (if ?a = ?a' then status.Eq else Diff)› ‹updStat Diff ?uu ?uv = Diff› ‹updStat ?stat (False, ?va) ?uv = ?stat› ‹updStat ?stat ?uu (False, ?va) = ?stat›*) by auto
(*goals:
1. ‹⟦(pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ pc1 = pc3 ∧ vs1 = vs3 ∧ avst1 = avst3 ∧ h1 = h3 ∧ p1 = p3 ∧ pc2 = pc4 ∧ vs2 = vs4 ∧ avst2 = avst4 ∧ h2 = h4 ∧ p2 = p4 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), if pc4 = 6 then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))) (stateOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))), ls3) else ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if pc4 = 6 ∧ cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; 6 < pc3⟧ ⟹ (pc4 = 6 ⟶ updStat statO (True, ⊥, ls3) (True, ⊥, ls4) = Diff) ∧ (pc4 ≠ 6 ⟶ updStat statO (True, ⊥) (True, ⊥) = Diff)›
2. ‹⟦(pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ pc1 = pc3 ∧ vs1 = vs3 ∧ avst1 = avst3 ∧ h1 = h3 ∧ p1 = p3 ∧ pc2 = pc4 ∧ vs2 = vs4 ∧ avst2 = avst4 ∧ h2 = h4 ∧ p2 = p4 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), if pc4 = 6 then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))) (stateOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))), ls3) else ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if pc4 = 6 ∧ cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; pc3 = 0⟧ ⟹ (pc4 = 6 ⟶ updStat statO (True, ⊥, ls3) (True, ⊥, ls4) = Diff) ∧ (pc4 ≠ 6 ⟶ updStat statO (True, ⊥) (True, ⊥) = Diff)›
3. ‹⟦(pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ pc1 = pc3 ∧ vs1 = vs3 ∧ avst1 = avst3 ∧ h1 = h3 ∧ p1 = p3 ∧ pc2 = pc4 ∧ vs2 = vs4 ∧ avst2 = avst4 ∧ h2 = h4 ∧ p2 = p4 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hheap h1 = hheap h3 ∧ (∀cfg''∈set cfgs3. hheap h1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hheap h2 = hheap h4 ∧ (∀cfg''∈set cfgs4. hheap h2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), if pc4 = 6 then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))) (stateOf (Config pc4 (State (Vstore vs3) avst3 h3 p3))), ls3) else ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if pc4 = 6 ∧ cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; pc3 = 1⟧ ⟹ (pc4 = 6 ⟶ updStat statO (True, ⊥, ls3) (True, ⊥, ls4) = Diff) ∧ (pc4 ≠ 6 ⟶ updStat statO (True, ⊥) (True, ⊥) = Diff)›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*) .
}
note stat = this (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*)
show "(oor3 Δ1 Δ2 Δe) ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)"
using v3[unfolded ss, simplified] (*‹(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) →S (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set)›*) proof (cases rule: stepS_cases (*‹⟦(?pstate::predState, ?cfg::config, ?cfgs::config list, ?ibT::int llist, ?ibUT::int llist, ?ls::nat set) →S (?pstate'::predState, ?cfg'::config, ?cfgs'::config list, ?ibT'::int llist, ?ibUT'::int llist, ?ls'::nat set); ⟦?cfgs = []; ¬ is_IfJump (prog ! pcOf ?cfg) ∨ ¬ mispred ?pstate [pcOf ?cfg]; ?pstate' = ?pstate; ¬ finalB (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ?cfgs' = []; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis::bool; ⟦?cfgs = []; is_IfJump (prog ! pcOf ?cfg); mispred ?pstate [pcOf ?cfg]; ?pstate' = update ?pstate [pcOf ?cfg]; ¬ finalM (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (?cfg, ?ibT, ?ibUT) ∧ ?cfgs' = [cfg1']; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ is_IfJump (prog ! pcOf (last ?cfgs)) ∨ ¬ mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) ≠ Fence; ?pstate' = ?pstate; ¬ is_getInput (prog ! pcOf (last ?cfgs)); ¬ is_Output (prog ! pcOf (last ?cfgs)); ?cfg' = ?cfg; ?ls' = ?ls ∪ readLocs (last ?cfgs); ∃cfg1'::config. nextB (last ?cfgs, ?ibT, ?ibUT) = (cfg1', ?ibT', ?ibUT') ∧ ?cfgs' = butlast ?cfgs ## cfg1'⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); is_IfJump (prog ! pcOf (last ?cfgs)); mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ finalM (last ?cfgs, ?ibT, ?ibUT); ?cfg' = ?cfg; ∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last ?cfgs, ?ibT, ?ibUT) = (lcfg', ?ibT', ?ibUT') ∧ (cfg1', ibT1', ibUT1') = nextM (last ?cfgs, ?ibT, ?ibUT) ∧ ?cfgs' = butlast ?cfgs @ [lcfg'] ## cfg1'; ?ls' = ?ls ∪ readLocs (last ?cfgs)⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) = Fence; ?pstate' = ?pstate; ?cfg' = ?cfg; ?cfgs' = []; ?ibT' = ?ibT; ?ibUT' = ?ibUT; ?ls' = ?ls⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?cfg' = ?cfg; ?cfgs' = butlast ?cfgs; ?ls' = ?ls; ?ibT' = ?ibT; ?ibUT' = ?ibUT⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) ≠ Fence; pstate3' = pstate3; ¬ is_getInput (prog ! pcOf (last cfgs3)); ¬ is_Output (prog ! pcOf (last cfgs3)); cfg3' = cfg3; ls3' = ls3 ∪ readLocs (last cfgs3); ∃cfg1'. nextB (last cfgs3, ibT3, ibUT3) = (cfg1', ibT3', ibUT3') ∧ cfgs3' = butlast cfgs3 ## cfg1'⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3, ibUT3); cfg3' = cfg3; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'; ls3' = ls3 ∪ readLocs (last cfgs3)⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
6. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_normal (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹prog ! pcOf (last cfgs3) ≠ Fence› ‹pstate3' = pstate3› ‹¬ is_getInput (prog ! pcOf (last cfgs3))› ‹¬ is_Output (prog ! pcOf (last cfgs3))› ‹cfg3' = cfg3› ‹ls3' = ls3 ∪ readLocs (last cfgs3)› ‹∃cfg1'::config. nextB (last (cfgs3::config list), ibT3::int llist, ibUT3::int llist) = (cfg1', ibT3'::int llist, ibUT3'::int llist) ∧ (cfgs3'::config list) = butlast cfgs3 ## cfg1'›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3, ibUT3); cfg3' = cfg3; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'; ls3' = ls3 ∪ readLocs (last cfgs3)⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_mispred (*‹cfgs3 ≠ []› ‹¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf (cfgs3::config list))› ‹is_IfJump (prog ! pcOf (last cfgs3))› ‹mispred pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹¬ finalM (last cfgs3, ibT3, ibUT3)› ‹(cfg3'::config) = (cfg3::config)› ‹∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last (cfgs3::config list), ibT3::int llist, ibUT3::int llist) = (lcfg', ibT3'::int llist, ibUT3'::int llist) ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ (cfgs3'::config list) = butlast cfgs3 @ [lcfg'] ## cfg1'› ‹ls3' = ls3 ∪ readLocs (last cfgs3)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_Fence (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹prog ! pcOf (last cfgs3) = Fence› ‹pstate3' = pstate3› ‹cfg3' = cfg3› ‹cfgs3' = []› ‹(ibT3'::int llist) = (ibT3::int llist)› ‹ibUT3' = ibUT3› ‹(ls3'::nat set) = (ls3::nat set)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹(statA'::status) = Diff ⟹ sstatO' (statO::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a::{zero,numeral,ord}..6::?'a::{zero,numeral,ord}}› ‹afterInput = {2::?'a::{numeral,ord}..6::?'a::{numeral,ord}}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_resolve (*‹cfgs3 ≠ []› ‹resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹cfg3' = cfg3› ‹cfgs3' = butlast cfgs3› ‹ls3' = ls3› ‹(ibT3'::int llist) = (ibT3::int llist)› ‹ibUT3' = ibUT3›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_mispred (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*)
note nm3 = nonspec_mispred (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*)
show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
using v4[unfolded ss, simplified] (*‹(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*) proof (cases rule: stepS_cases (*‹⟦(?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls) →S (?pstate', ?cfg', ?cfgs', ?ibT', ?ibUT', ?ls'); ⟦?cfgs = []; ¬ is_IfJump (prog ! pcOf ?cfg) ∨ ¬ mispred ?pstate [pcOf ?cfg]; ?pstate' = ?pstate; ¬ finalB (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ?cfgs' = []; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs = []; is_IfJump (prog ! pcOf ?cfg); mispred ?pstate [pcOf ?cfg]; ?pstate' = update ?pstate [pcOf ?cfg]; ¬ finalM (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (?cfg, ?ibT, ?ibUT) ∧ ?cfgs' = [cfg1']; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ is_IfJump (prog ! pcOf (last ?cfgs)) ∨ ¬ mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) ≠ Fence; ?pstate' = ?pstate; ¬ is_getInput (prog ! pcOf (last ?cfgs)); ¬ is_Output (prog ! pcOf (last ?cfgs)); ?cfg' = ?cfg; ?ls' = ?ls ∪ readLocs (last ?cfgs); ∃cfg1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (cfg1', ?ibT', ?ibUT') ∧ ?cfgs' = butlast ?cfgs ## cfg1'⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); is_IfJump (prog ! pcOf (last ?cfgs)); mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ finalM (last ?cfgs, ?ibT, ?ibUT); ?cfg' = ?cfg; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (lcfg', ?ibT', ?ibUT') ∧ (cfg1', ibT1', ibUT1') = nextM (last ?cfgs, ?ibT, ?ibUT) ∧ ?cfgs' = butlast ?cfgs @ [lcfg'] ## cfg1'; ?ls' = ?ls ∪ readLocs (last ?cfgs)⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) = Fence; ?pstate' = ?pstate; ?cfg' = ?cfg; ?cfgs' = []; ?ibT' = ?ibT; ?ibUT' = ?ibUT; ?ls' = ?ls⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?cfg' = ?cfg; ?cfgs' = butlast ?cfgs; ?ls' = ?ls; ?ibT' = ?ibT; ?ibUT' = ?ibUT⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⟦(cfgs4::config list) = []; ¬ is_IfJump (prog ! pcOf (cfg4::config)) ∨ ¬ mispred (pstate4::predState) [pcOf cfg4]; (pstate4'::predState) = pstate4; ¬ finalB (cfg4, ibT4::int llist, ibUT4::int llist); (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4, ibT4, ibUT4); (cfgs4'::config list) = []; (ls4'::nat set) = (ls4::nat set) ∪ readLocs cfg4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
2. ‹⟦(cfgs4::config list) = []; is_IfJump (prog ! pcOf (cfg4::config)); mispred (pstate4::predState) [pcOf cfg4]; (pstate4'::predState) = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4::int llist, ibUT4::int llist); (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4, ibT4, ibUT4); ∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ (cfgs4'::config list) = [cfg1']; (ls4'::nat set) = (ls4::nat set) ∪ readLocs cfg4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
3. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); ¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) ≠ Fence; (pstate4'::predState) = pstate4; ¬ is_getInput (prog ! pcOf (last cfgs4)); ¬ is_Output (prog ! pcOf (last cfgs4)); (cfg4'::config) = cfg4; (ls4'::nat set) = (ls4::nat set) ∪ readLocs (last cfgs4); ∃cfg1'::config. nextB (last cfgs4, ibT4::int llist, ibUT4::int llist) = (cfg1', ibT4'::int llist, ibUT4'::int llist) ∧ (cfgs4'::config list) = butlast cfgs4 ## cfg1'⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
4. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); (pstate4'::predState) = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4::int llist, ibUT4::int llist); (cfg4'::config) = cfg4; ∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4'::int llist, ibUT4'::int llist) ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ (cfgs4'::config list) = butlast cfgs4 @ [lcfg'] ## cfg1'; (ls4'::nat set) = (ls4::nat set) ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
5. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; (pstate4'::predState) = pstate4; (cfg4'::config) = cfg4; (cfgs4'::config list) = []; (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist); (ls4'::nat set) = (ls4::nat set)⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
6. ‹⟦(cfgs4::config list) ≠ []; resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); (pstate4'::predState) = update pstate4 (pcOf cfg4 # map pcOf cfgs4); (cfg4'::config) = cfg4; (cfgs4'::config list) = butlast cfgs4; (ls4'::nat set) = (ls4::nat set); (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist)⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
case nonspec_normal (*‹cfgs4 = []› ‹¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]› ‹pstate4' = pstate4› ‹¬ finalB (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹cfgs4' = []› ‹ls4' = ls4 ∪ readLocs cfg4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹(statA'::status) = Diff ⟹ sstatO' (statO::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) = Diff›*) nm3 (*‹(cfgs3::config list) = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a::{zero,numeral,ord}..6::?'a::{zero,numeral,ord}}› ‹afterInput = {2::?'a::{numeral,ord}..6::?'a::{numeral,ord}}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs4 = []; is_IfJump (prog ! pcOf cfg4); mispred pstate4 [pcOf cfg4]; pstate4' = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) ≠ Fence; pstate4' = pstate4; ¬ is_getInput (prog ! pcOf (last cfgs4)); ¬ is_Output (prog ! pcOf (last cfgs4)); cfg4' = cfg4; ls4' = ls4 ∪ readLocs (last cfgs4); ∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_normal (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹prog ! pcOf (last cfgs4) ≠ Fence› ‹pstate4' = pstate4› ‹¬ is_getInput (prog ! pcOf (last cfgs4))› ‹¬ is_Output (prog ! pcOf (last (cfgs4::config list)))› ‹(cfg4'::config) = (cfg4::config)› ‹ls4' = ls4 ∪ readLocs (last cfgs4)› ‹∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nm3 (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹(pstate3'::predState) = update (pstate3::predState) [pcOf (cfg3::config)]› ‹¬ finalM (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg3::config, ibT3::int llist, ibUT3::int llist) ∧ (cfgs3'::config list) = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs4 = []; is_IfJump (prog ! pcOf cfg4); mispred pstate4 [pcOf cfg4]; pstate4' = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_mispred (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹is_IfJump (prog ! pcOf (last cfgs4))› ‹mispred pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹¬ finalM (last cfgs4, ibT4, ibUT4)› ‹cfg4' = cfg4› ‹∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'› ‹ls4' = ls4 ∪ readLocs (last cfgs4)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1" (*‹Δ1 (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nm3 (*‹(cfgs3::config list) = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹(pstate3'::predState) = update (pstate3::predState) [pcOf (cfg3::config)]› ‹¬ finalM (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg3::config, ibT3::int llist, ibUT3::int llist) ∧ (cfgs3'::config list) = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs4 = []; is_IfJump (prog ! pcOf cfg4); mispred pstate4 [pcOf cfg4]; pstate4' = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_Fence (*‹(cfgs4::config list) ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹prog ! pcOf (last cfgs4) = Fence› ‹pstate4' = pstate4› ‹cfg4' = cfg4› ‹cfgs4' = []› ‹ibT4' = ibT4› ‹ibUT4' = ibUT4› ‹ls4' = ls4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nm3 (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3, ibT3, ibUT3)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs4 = []; is_IfJump (prog ! pcOf cfg4); mispred pstate4 [pcOf cfg4]; pstate4' = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_resolve (*‹cfgs4 ≠ []› ‹resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹(pstate4'::predState) = update (pstate4::predState) (pcOf (cfg4::config) # map pcOf (cfgs4::config list))› ‹cfg4' = cfg4› ‹(cfgs4'::config list) = butlast (cfgs4::config list)› ‹ls4' = ls4› ‹ibT4' = ibT4› ‹ibUT4' = ibUT4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nm3 (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []›*))
next
(*goal: ‹⟦cfgs4 = []; is_IfJump (prog ! pcOf cfg4); mispred pstate4 [pcOf cfg4]; pstate4' = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_mispred (*‹cfgs4 = []› ‹is_IfJump (prog ! pcOf cfg4)› ‹mispred pstate4 [pcOf cfg4]› ‹pstate4' = update pstate4 [pcOf cfg4]› ‹¬ finalM (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']› ‹ls4' = ls4 ∪ readLocs cfg4›*)
note nm4 = nonspec_mispred (*‹cfgs4 = []› ‹is_IfJump (prog ! pcOf cfg4)› ‹mispred pstate4 [pcOf cfg4]› ‹pstate4' = update pstate4 [pcOf cfg4]› ‹¬ finalM (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg4::config, ibT4::int llist, ibUT4::int llist) ∧ (cfgs4'::config list) = [cfg1']› ‹(ls4'::nat set) = (ls4::nat set) ∪ readLocs (cfg4::config)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) v3 (*‹validTransO (ss3, ss3')›*) v4 (*‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)›*) nm3 (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*) nm4 (*‹cfgs4 = []› ‹is_IfJump (prog ! pcOf (cfg4::config))› ‹mispred pstate4 [pcOf cfg4]› ‹pstate4' = update pstate4 [pcOf cfg4]› ‹¬ finalM (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']› ‹ls4' = ls4 ∪ readLocs cfg4›*) unfolding ss cfg hh
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (nextN (Config (pc1::nat) (State (Vstore (vs1::char list ⇒ int)) (avst1::avstore) (h1::heap) (p1::nat)), ibT1::int llist, ibUT1::int llist, ls1::nat set)) (nextN (Config (pc2::nat) (State (Vstore (vs2::char list ⇒ int)) (avst2::avstore) (h2::heap) (p2::nat)), ibT2::int llist, ibUT2::int llist, ls2::nat set)) (sstatO' (statO::status) (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
apply clarsimp
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1)) (nextN (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2)) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
using cases_6[of pc3] (*‹(pc3::nat) = (0::nat) ∨ pc3 = (1::nat) ∨ pc3 = (2::nat) ∨ pc3 = (3::nat) ∨ pc3 = (4::nat) ∨ pc3 = (5::nat) ∨ pc3 = (6::nat) ∨ (6::nat) < pc3›*) apply (elim disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹⋀cfg1' cfg1'a ibT1' ibUT1' ibT1'a ibUT1'a. ⟦is_IfJump (prog ! pc4); mispred pstate4 [pc4]; Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3); mispred pstate3 [pc3]; pstate3' = update pstate3 [pc3]; ¬ finalM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); cfgs4 = []; pstate4' = update pstate4 [pc4]; ¬ finalM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); cfgs4' = [cfg1']; (cfg1', ibT1', ibUT1') = nextM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs3' = [cfg1'a]; (cfg1'a, ibT1'a, ibUT1'a) = nextM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); pc3 = 0⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (update pstate3 [pc3], cfg3', [cfg1'a], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (update pstate4 [pc4], cfg4', [cfg1'], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›
2. ‹⋀cfg1' cfg1'a ibT1' ibUT1' ibT1'a ibUT1'a. ⟦is_IfJump (prog ! pc4); mispred pstate4 [pc4]; Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3); mispred pstate3 [pc3]; pstate3' = update pstate3 [pc3]; ¬ finalM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); cfgs4 = []; pstate4' = update pstate4 [pc4]; ¬ finalM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); cfgs4' = [cfg1']; (cfg1', ibT1', ibUT1') = nextM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs3' = [cfg1'a]; (cfg1'a, ibT1'a, ibUT1'a) = nextM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); pc3 = 1⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (update pstate3 [pc3], cfg3', [cfg1'a], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (update pstate4 [pc4], cfg4', [cfg1'], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›
3. ‹⋀cfg1' cfg1'a ibT1' ibUT1' ibT1'a ibUT1'a. ⟦is_IfJump (prog ! pc4); mispred pstate4 [pc4]; Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3); mispred pstate3 [pc3]; pstate3' = update pstate3 [pc3]; ¬ finalM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); cfgs4 = []; pstate4' = update pstate4 [pc4]; ¬ finalM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); cfgs4' = [cfg1']; (cfg1', ibT1', ibUT1') = nextM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs3' = [cfg1'a]; (cfg1'a, ibT1'a, ibUT1'a) = nextM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); pc3 = 2⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (update pstate3 [pc3], cfg3', [cfg1'a], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (update pstate4 [pc4], cfg4', [cfg1'], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›
4. ‹⋀cfg1' cfg1'a ibT1' ibUT1' ibT1'a ibUT1'a. ⟦is_IfJump (prog ! pc4); mispred pstate4 [pc4]; Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3); mispred pstate3 [pc3]; pstate3' = update pstate3 [pc3]; ¬ finalM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); cfgs4 = []; pstate4' = update pstate4 [pc4]; ¬ finalM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); cfgs4' = [cfg1']; (cfg1', ibT1', ibUT1') = nextM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs3' = [cfg1'a]; (cfg1'a, ibT1'a, ibUT1'a) = nextM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); pc3 = 3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (update pstate3 [pc3], cfg3', [cfg1'a], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (update pstate4 [pc4], cfg4', [cfg1'], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›
5. ‹⋀cfg1' cfg1'a ibT1' ibUT1' ibT1'a ibUT1'a. ⟦is_IfJump (prog ! pc4); mispred pstate4 [pc4]; Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3); mispred pstate3 [pc3]; pstate3' = update pstate3 [pc3]; ¬ finalM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); cfgs4 = []; pstate4' = update pstate4 [pc4]; ¬ finalM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); cfgs4' = [cfg1']; (cfg1', ibT1', ibUT1') = nextM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs3' = [cfg1'a]; (cfg1'a, ibT1'a, ibUT1'a) = nextM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); pc3 = 4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (update pstate3 [pc3], cfg3', [cfg1'a], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (update pstate4 [pc4], cfg4', [cfg1'], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›
6. ‹⋀cfg1' cfg1'a ibT1' ibUT1' ibT1'a ibUT1'a. ⟦is_IfJump (prog ! pc4); mispred pstate4 [pc4]; Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3); mispred pstate3 [pc3]; pstate3' = update pstate3 [pc3]; ¬ finalM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); cfgs4 = []; pstate4' = update pstate4 [pc4]; ¬ finalM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); cfgs4' = [cfg1']; (cfg1', ibT1', ibUT1') = nextM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs3' = [cfg1'a]; (cfg1'a, ibT1'a, ibUT1'a) = nextM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); pc3 = 5⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (update pstate3 [pc3], cfg3', [cfg1'a], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (update pstate4 [pc4], cfg4', [cfg1'], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›
7. ‹⋀cfg1' cfg1'a ibT1' ibUT1' ibT1'a ibUT1'a. ⟦is_IfJump (prog ! pc4); mispred pstate4 [pc4]; Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3); mispred pstate3 [pc3]; pstate3' = update pstate3 [pc3]; ¬ finalM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); cfgs4 = []; pstate4' = update pstate4 [pc4]; ¬ finalM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); cfgs4' = [cfg1']; (cfg1', ibT1', ibUT1') = nextM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs3' = [cfg1'a]; (cfg1'a, ibT1'a, ibUT1'a) = nextM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); pc3 = 6⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (update pstate3 [pc3], cfg3', [cfg1'a], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (update pstate4 [pc4], cfg4', [cfg1'], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›
8. ‹⋀cfg1' cfg1'a ibT1' ibUT1' ibT1'a ibUT1'a. ⟦is_IfJump (prog ! pc4); mispred pstate4 [pc4]; Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3); mispred pstate3 [pc3]; pstate3' = update pstate3 [pc3]; ¬ finalM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); cfgs4 = []; pstate4' = update pstate4 [pc4]; ¬ finalM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); cfgs4' = [cfg1']; (cfg1', ibT1', ibUT1') = nextM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs3' = [cfg1'a]; (cfg1'a, ibT1'a, ibUT1'a) = nextM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); 6 < pc3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (update pstate3 [pc3], cfg3', [cfg1'a], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (update pstate4 [pc4], cfg4', [cfg1'], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›
discuss goal 1*)
apply (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
(*discuss goal 2*)
apply (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
(*discuss goal 3*)
apply (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
(*discuss goal 4*)
apply (simp add: Δ1_defs (*‹Δ1 = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a::{zero,numeral,ord}..6::?'a::{zero,numeral,ord}}› ‹afterInput = {2::?'a::{numeral,ord}..6::?'a::{numeral,ord}}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []›*))
(*top goal: ‹⋀cfg1' cfg1'a ibT1' ibUT1' ibT1'a ibUT1'a. ⟦is_IfJump (prog ! pc4); mispred pstate4 [pc4]; Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3); mispred pstate3 [pc3]; pstate3' = update pstate3 [pc3]; ¬ finalM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); cfgs4 = []; pstate4' = update pstate4 [pc4]; ¬ finalM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); cfgs4' = [cfg1']; (cfg1', ibT1', ibUT1') = nextM (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs3' = [cfg1'a]; (cfg1'a, ibT1'a, ibUT1'a) = nextM (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); pc3 = 3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (update pstate3 [pc3], cfg3', [cfg1'a], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (update pstate4 [pc4], cfg4', [cfg1'], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))› and 4 goals remain*)
apply (rule oor3I2 (*‹(?Δ₂::?'a ⇒ ?'b ⇒ ?'c ⇒ ?'d ⇒ ?'e ⇒ ?'f ⇒ ?'g ⇒ bool) (?w::?'a) (?s1.0::?'b) (?s2.0::?'c) (?statA::?'d) (?sv1.0::?'e) (?sv2.0::?'f) (?statO::?'g) ⟹ oor3 (?Δ::?'a ⇒ ?'b ⇒ ?'c ⇒ ?'d ⇒ ?'e ⇒ ?'f ⇒ ?'g ⇒ bool) ?Δ₂ (?Δ₃::?'a ⇒ ?'b ⇒ ?'c ⇒ ?'d ⇒ ?'e ⇒ ?'f ⇒ ?'g ⇒ bool) ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*top goal: ‹⋀cfg1' cfg1'a. ⟦Opt.eqAct (pstate4, Config 3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config 3 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ pc1 = 3 ∧ vs1 = vs3 ∧ avst1 = avst3 ∧ h1 = Heap hh3 ∧ p1 = p3 ∧ pc2 = pc4 ∧ vs2 = vs4 ∧ avst2 = avst4 ∧ h2 = Heap hh4 ∧ p2 = p4 ∧ pc4 = 3 ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ hheap h1 = hh3 ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ hheap h2 = hh4 ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (statA = Diff ⟶ statO = Diff) ∧ vs3 xx = vs4 xx ∧ vs3 xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4; statA' = Diff ⟹ sstatO' statO (Config 3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT1, ibUT1, ls3) (Config 3 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT2, ibUT2, ls4) = Diff; cfgs3 = []; mispred pstate4 [3]; pstate3' = update pstate4 [3]; ¬ finalM (Config 3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); cfg3' = Config 4 (State (Vstore vs3) avst3 (Heap hh3) p3) ∧ ibT3' = ibT3 ∧ ibUT3' = ibUT3; ls3' = ls3; cfgs4 = []; pstate4' = update pstate4 [3]; ¬ finalM (Config 3 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfg4' = Config 4 (State (Vstore vs4) avst4 (Heap hh4) p4) ∧ ibT4' = ibT4 ∧ ibUT4' = ibUT4; ls4' = ls4; cfgs4' = [Config 6 (State (Vstore vs4) avst4 (Heap hh4) p4)]; cfg1' = Config 6 (State (Vstore vs4) avst4 (Heap hh4) p4); cfgs3' = [Config 6 (State (Vstore vs3) avst3 (Heap hh3) p3)]; cfg1'a = Config 6 (State (Vstore vs3) avst3 (Heap hh3) p3); pc3 = 3⟧ ⟹ oor3 (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3) ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4) ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pcOf cfg3 ∧ pcOf cfg3 ≤ 6 ∧ vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx) ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ cfgs3 = []) Δ2 Δe ∞ (update pstate4 [3], Config 4 (State (Vstore vs3) avst3 (Heap hh3) p3), [Config 6 (State (Vstore vs3) avst3 (Heap hh3) p3)], ibT3, ibUT3, ls3) (update pstate4 [3], Config 4 (State (Vstore vs4) avst4 (Heap hh4) p4), [Config 6 (State (Vstore vs4) avst4 (Heap hh4) p4)], ibT4, ibUT4, ls4) statA' (Config 4 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT1, ibUT1, ls3) (Config 4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT2, ibUT2, ls4) (sstatO' statO (Config 3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT1, ibUT1, ls3) (Config 3 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT2, ibUT2, ls4))› and 4 goals remain*)
apply (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*) Δ2_defs (*‹Δ2 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = startOfThenBranch ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = elseBranch ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ misSpecL1 cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹same_var ?x ?cfg ?cfg' ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x› ‹startOfThenBranch = 4› ‹misSpecL1 ?cfgs ≡ length ?cfgs = Suc 0› ‹elseBranch = 6›*))
(*top goal: ‹⋀cfg1' cfg1'a. ⟦Opt.eqAct (pstate4, Config 3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config 3 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ pc1 = 3 ∧ vs1 = vs3 ∧ avst1 = avst3 ∧ h1 = Heap hh3 ∧ p1 = p3 ∧ pc2 = pc4 ∧ vs2 = vs4 ∧ avst2 = avst4 ∧ h2 = Heap hh4 ∧ p2 = p4 ∧ pc4 = 3 ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ hheap h1 = hh3 ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ hheap h2 = hh4 ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (statA = Diff ⟶ statO = Diff) ∧ vs3 xx = vs4 xx ∧ vs3 xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4; statA' = Diff ⟹ sstatO' statO (Config 3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT1, ibUT1, ls3) (Config 3 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT2, ibUT2, ls4) = Diff; cfgs3 = []; mispred pstate4 [3]; pstate3' = update pstate4 [3]; ¬ finalM (Config 3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); cfg3' = Config 4 (State (Vstore vs3) avst3 (Heap hh3) p3) ∧ ibT3' = ibT3 ∧ ibUT3' = ibUT3; ls3' = ls3; cfgs4 = []; pstate4' = update pstate4 [3]; ¬ finalM (Config 3 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfg4' = Config 4 (State (Vstore vs4) avst4 (Heap hh4) p4) ∧ ibT4' = ibT4 ∧ ibUT4' = ibUT4; ls4' = ls4; cfgs4' = [Config 6 (State (Vstore vs4) avst4 (Heap hh4) p4)]; cfg1' = Config 6 (State (Vstore vs4) avst4 (Heap hh4) p4); cfgs3' = [Config 6 (State (Vstore vs3) avst3 (Heap hh3) p3)]; cfg1'a = Config 6 (State (Vstore vs3) avst3 (Heap hh3) p3); pc3 = 3⟧ ⟹ Δ2 ∞ (update pstate4 [3], Config 4 (State (Vstore vs3) avst3 (Heap hh3) p3), [Config 6 (State (Vstore vs3) avst3 (Heap hh3) p3)], ibT3, ibUT3, ls3) (update pstate4 [3], Config 4 (State (Vstore vs4) avst4 (Heap hh4) p4), [Config 6 (State (Vstore vs4) avst4 (Heap hh4) p4)], ibT4, ibUT4, ls4) statA' (Config 4 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT1, ibUT1, ls3) (Config 4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT2, ibUT2, ls4) (sstatO' statO (Config 3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT1, ibUT1, ls3) (Config 3 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT2, ibUT2, ls4))› and 4 goals remain*)
apply metis
(*discuss goal 5*)
apply (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
(*discuss goal 6*)
apply (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
(*discuss goal 7*)
apply (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
(*discuss goal 8*)
apply (simp add: Δ1_defs (*‹Δ1 = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a::{zero,numeral,ord}..6::?'a::{zero,numeral,ord}}› ‹afterInput = {2::?'a::{numeral,ord}..6::?'a::{numeral,ord}}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []›*))
(*proven 8 subgoals*) .
qed
next
(*goal: ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_normal (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*)
note nn3 = nonspec_normal (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (cfg3::config)›*)
show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using v4[unfolded ss, simplified] (*‹(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*) proof (cases rule: stepS_cases (*‹⟦(?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls) →S (?pstate', ?cfg', ?cfgs', ?ibT', ?ibUT', ?ls'); ⟦?cfgs = []; ¬ is_IfJump (prog ! pcOf ?cfg) ∨ ¬ mispred ?pstate [pcOf ?cfg]; ?pstate' = ?pstate; ¬ finalB (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ?cfgs' = []; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs = []; is_IfJump (prog ! pcOf ?cfg); mispred ?pstate [pcOf ?cfg]; ?pstate' = update ?pstate [pcOf ?cfg]; ¬ finalM (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (?cfg, ?ibT, ?ibUT) ∧ ?cfgs' = [cfg1']; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ is_IfJump (prog ! pcOf (last ?cfgs)) ∨ ¬ mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) ≠ Fence; ?pstate' = ?pstate; ¬ is_getInput (prog ! pcOf (last ?cfgs)); ¬ is_Output (prog ! pcOf (last ?cfgs)); ?cfg' = ?cfg; ?ls' = ?ls ∪ readLocs (last ?cfgs); ∃cfg1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (cfg1', ?ibT', ?ibUT') ∧ ?cfgs' = butlast ?cfgs ## cfg1'⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); is_IfJump (prog ! pcOf (last ?cfgs)); mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ finalM (last ?cfgs, ?ibT, ?ibUT); ?cfg' = ?cfg; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (lcfg', ?ibT', ?ibUT') ∧ (cfg1', ibT1', ibUT1') = nextM (last ?cfgs, ?ibT, ?ibUT) ∧ ?cfgs' = butlast ?cfgs @ [lcfg'] ## cfg1'; ?ls' = ?ls ∪ readLocs (last ?cfgs)⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) = Fence; ?pstate' = ?pstate; ?cfg' = ?cfg; ?cfgs' = []; ?ibT' = ?ibT; ?ibUT' = ?ibUT; ?ls' = ?ls⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?cfg' = ?cfg; ?cfgs' = butlast ?cfgs; ?ls' = ?ls; ?ibT' = ?ibT; ?ibUT' = ?ibUT⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 = []; is_IfJump (prog ! pcOf cfg4); mispred pstate4 [pcOf cfg4]; pstate4' = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) ≠ Fence; pstate4' = pstate4; ¬ is_getInput (prog ! pcOf (last cfgs4)); ¬ is_Output (prog ! pcOf (last cfgs4)); cfg4' = cfg4; ls4' = ls4 ∪ readLocs (last cfgs4); ∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
6. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_mispred (*‹cfgs4 = []› ‹is_IfJump (prog ! pcOf cfg4)› ‹mispred pstate4 [pcOf cfg4]› ‹(pstate4'::predState) = update (pstate4::predState) [pcOf (cfg4::config)]› ‹¬ finalM (cfg4::config, ibT4::int llist, ibUT4::int llist)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']› ‹ls4' = ls4 ∪ readLocs cfg4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹cfgs3' = []› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (cfg3::config)›*) unfolding ss
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) ≠ Fence; pstate4' = pstate4; ¬ is_getInput (prog ! pcOf (last cfgs4)); ¬ is_Output (prog ! pcOf (last cfgs4)); cfg4' = cfg4; ls4' = ls4 ∪ readLocs (last cfgs4); ∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_normal (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹prog ! pcOf (last cfgs4) ≠ Fence› ‹pstate4' = pstate4› ‹¬ is_getInput (prog ! pcOf (last cfgs4))› ‹¬ is_Output (prog ! pcOf (last cfgs4))› ‹cfg4' = cfg4› ‹(ls4'::nat set) = (ls4::nat set) ∪ readLocs (last (cfgs4::config list))› ‹∃cfg1'::config. nextB (last (cfgs4::config list), ibT4::int llist, ibUT4::int llist) = (cfg1', ibT4'::int llist, ibUT4'::int llist) ∧ (cfgs4'::config list) = butlast cfgs4 ## cfg1'›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹(statA'::status) = Diff ⟹ sstatO' (statO::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹(pstate3'::predState) = (pstate3::predState)› ‹¬ finalB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹(cfgs3'::config list) = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (nextN (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)) (nextN (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)) (sstatO' (statO::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_mispred (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹is_IfJump (prog ! pcOf (last cfgs4))› ‹mispred pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹¬ finalM (last cfgs4, ibT4, ibUT4)› ‹cfg4' = cfg4› ‹∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'› ‹ls4' = ls4 ∪ readLocs (last cfgs4)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹(statA'::status) = Diff ⟹ sstatO' (statO::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹(cfgs3'::config list) = []› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (cfg3::config)›*) unfolding ss
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦(cfgs4::config list) = []; ¬ is_IfJump (prog ! pcOf (cfg4::config)) ∨ ¬ mispred (pstate4::predState) [pcOf cfg4]; (pstate4'::predState) = pstate4; ¬ finalB (cfg4, ibT4::int llist, ibUT4::int llist); (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4, ibT4, ibUT4); (cfgs4'::config list) = []; (ls4'::nat set) = (ls4::nat set) ∪ readLocs cfg4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
2. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; (pstate4'::predState) = pstate4; (cfg4'::config) = cfg4; (cfgs4'::config list) = []; (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist); (ls4'::nat set) = (ls4::nat set)⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
3. ‹⟦(cfgs4::config list) ≠ []; resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); (pstate4'::predState) = update pstate4 (pcOf cfg4 # map pcOf cfgs4); (cfg4'::config) = cfg4; (cfgs4'::config list) = butlast cfgs4; (ls4'::nat set) = (ls4::nat set); (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist)⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
case spec_Fence (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹prog ! pcOf (last cfgs4) = Fence› ‹pstate4' = pstate4› ‹cfg4' = cfg4› ‹cfgs4' = []› ‹ibT4' = ibT4› ‹ibUT4' = ibUT4› ‹ls4' = ls4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (nextN (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)) (nextN (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)) (sstatO' (statO::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_resolve (*‹cfgs4 ≠ []› ‹resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf (cfgs4::config list))› ‹pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹cfg4' = cfg4› ‹cfgs4' = butlast cfgs4› ‹ls4' = ls4› ‹ibT4' = ibT4› ‹ibUT4' = ibUT4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹(pstate3'::predState) = (pstate3::predState)› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
next
(*goal: ‹⟦(cfgs4::config list) = []; ¬ is_IfJump (prog ! pcOf (cfg4::config)) ∨ ¬ mispred (pstate4::predState) [pcOf cfg4]; (pstate4'::predState) = pstate4; ¬ finalB (cfg4, ibT4::int llist, ibUT4::int llist); (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4, ibT4, ibUT4); (cfgs4'::config list) = []; (ls4'::nat set) = (ls4::nat set) ∪ readLocs cfg4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
case nonspec_normal (*‹cfgs4 = []› ‹¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]› ‹pstate4' = pstate4› ‹¬ finalB (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹cfgs4' = []› ‹ls4' = ls4 ∪ readLocs cfg4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1" (*‹Δ1 n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹(statA'::status) = Diff ⟹ sstatO' (statO::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) = Diff›*) v3 (*‹validTransO (ss3, ss3')›*) v4 (*‹validTransO (ss4, ss4')›*) nn3 (*‹(cfgs3::config list) = []› ‹¬ is_IfJump (prog ! pcOf (cfg3::config)) ∨ ¬ mispred (pstate3::predState) [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfgs3'::config list) = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss cfg hh
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1)) (nextN (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2)) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
apply clarsimp
(*goal: ‹oor3 Δ1 Δ2 Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1)) (nextN (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2)) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
using cases_6[of pc3] (*‹pc3 = 0 ∨ pc3 = 1 ∨ pc3 = 2 ∨ pc3 = 3 ∨ pc3 = 4 ∨ pc3 = 5 ∨ pc3 = 6 ∨ 6 < pc3›*) apply (elim disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⟦(cfgs4::config list) = []; is_IfJump (prog ! (pc4::nat)) ⟶ ¬ mispred (pstate4::predState) [pc4]; (pstate4'::predState) = pstate4; ¬ finalB (Config pc4 (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (Heap (hh4::nat ⇒ int)) (p4::nat)), ibT4::int llist, ibUT4::int llist); (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfgs4'::config list) = []; (ls4'::nat set) = (ls4::nat set) ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); Opt.eqAct (pstate3::predState, Config (pc3::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (Heap (hh3::nat ⇒ int)) (p3::nat)), [], ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 (n::enat) (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) (statA::status) (Config (pc1::nat) (State (Vstore (vs1::char list ⇒ int)) (avst1::avstore) (h1::heap) (p1::nat)), ibT1::int llist, ibUT1::int llist, ls1::nat set) (Config (pc2::nat) (State (Vstore (vs2::char list ⇒ int)) (avst2::avstore) (h2::heap) (p2::nat)), ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status); (statA'::status) = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; (cfgs3::config list) = []; is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; (pstate3'::predState) = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfgs3'::config list) = []; (ls3'::nat set) = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (pstate4, cfg4', [], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg'::config, ibT'::int llist, ibUT'::int llist) ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg'::config, ibT'::int llist, ibUT'::int llist) ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
subgoal for
by (simp add: Δ1_defs (*‹Δ1 = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a::{zero,numeral,ord}..6::?'a::{zero,numeral,ord}}› ‹afterInput = {2::?'a::{numeral,ord}..6::?'a::{numeral,ord}}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []›*))
subgoal for
by (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
subgoal for
apply (rule oor3I1 (*‹?Δ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO ⟹ oor3 ?Δ ?Δ₂ ?Δ₃ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*goal: ‹⟦cfgs4 = []; is_IfJump (prog ! pc4) ⟶ ¬ mispred pstate4 [pc4]; pstate4' = pstate4; ¬ finalB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); pc3 = 2⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (pstate4, cfg4', [], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
apply (simp add:Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
(*goal: ‹⟦cfgs4 = []; is_IfJump (prog ! pc4) ⟶ ¬ mispred pstate4 [pc4]; pstate4' = pstate4; ¬ finalB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); pc3 = 2⟧ ⟹ Δ1 ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (pstate4, cfg4', [], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
by metis
subgoal for
apply (rule oor3I1 (*‹?Δ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO ⟹ oor3 ?Δ ?Δ₂ ?Δ₃ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*goal: ‹⟦cfgs4 = []; is_IfJump (prog ! pc4) ⟶ ¬ mispred pstate4 [pc4]; pstate4' = pstate4; ¬ finalB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); pc3 = 3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (pstate4, cfg4', [], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
apply (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
(*goal: ‹⟦cfgs4 = []; is_IfJump (prog ! pc4) ⟶ ¬ mispred pstate4 [pc4]; pstate4' = pstate4; ¬ finalB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); pc3 = 3⟧ ⟹ Δ1 ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (pstate4, cfg4', [], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
by metis
subgoal for
apply (rule oor3I1 (*‹(?Δ::?'a ⇒ ?'b ⇒ ?'c ⇒ ?'d ⇒ ?'e ⇒ ?'f ⇒ ?'g ⇒ bool) (?w::?'a) (?s1.0::?'b) (?s2.0::?'c) (?statA::?'d) (?sv1.0::?'e) (?sv2.0::?'f) (?statO::?'g) ⟹ oor3 ?Δ (?Δ₂::?'a ⇒ ?'b ⇒ ?'c ⇒ ?'d ⇒ ?'e ⇒ ?'f ⇒ ?'g ⇒ bool) (?Δ₃::?'a ⇒ ?'b ⇒ ?'c ⇒ ?'d ⇒ ?'e ⇒ ?'f ⇒ ?'g ⇒ bool) ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*goal: ‹⟦cfgs4 = []; is_IfJump (prog ! pc4) ⟶ ¬ mispred pstate4 [pc4]; pstate4' = pstate4; ¬ finalB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); pc3 = 4⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (pstate4, cfg4', [], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
apply (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
(*goal: ‹⟦cfgs4 = []; is_IfJump (prog ! pc4) ⟶ ¬ mispred pstate4 [pc4]; pstate4' = pstate4; ¬ finalB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); pc3 = 4⟧ ⟹ Δ1 ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (pstate4, cfg4', [], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
by metis
subgoal for
apply (rule oor3I1 (*‹?Δ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO ⟹ oor3 ?Δ ?Δ₂ ?Δ₃ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*goal: ‹⟦cfgs4 = []; is_IfJump (prog ! pc4) ⟶ ¬ mispred pstate4 [pc4]; pstate4' = pstate4; ¬ finalB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); pc3 = 5⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (pstate4, cfg4', [], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
apply (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
(*goal: ‹⟦cfgs4 = []; is_IfJump (prog ! pc4) ⟶ ¬ mispred pstate4 [pc4]; pstate4' = pstate4; ¬ finalB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); pc3 = 5⟧ ⟹ Δ1 ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (pstate4, cfg4', [], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
by metis
(*goals:
1. ‹⟦cfgs4 = []; is_IfJump (prog ! pc4) ⟶ ¬ mispred pstate4 [pc4]; pstate4' = pstate4; ¬ finalB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); pc3 = 6⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (pstate4, cfg4', [], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›
2. ‹⟦cfgs4 = []; is_IfJump (prog ! pc4) ⟶ ¬ mispred pstate4 [pc4]; pstate4' = pstate4; ¬ finalB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); 6 < pc3⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (pstate4, cfg4', [], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›
discuss goal 1*)
apply (rule oor3I3 (*‹?Δ₃ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO ⟹ oor3 ?Δ ?Δ₂ ?Δ₃ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*top goal: ‹⟦cfgs4 = []; is_IfJump (prog ! pc4) ⟶ ¬ mispred pstate4 [pc4]; pstate4' = pstate4; ¬ finalB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4)); Opt.eqAct (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4); Δ1 n (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), [], ibT4, ibUT4, ls4) statA (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) statO; statA' = Diff ⟹ sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2) = Diff; cfgs3 = []; is_IfJump (prog ! pc3) ⟶ ¬ mispred pstate3 [pc3]; pstate3' = pstate3; ¬ finalB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3)); pc3 = 6⟧ ⟹ oor3 Δ1 Δ2 Δe ∞ (pstate3, cfg3', [], ibT3', ibUT3', ls3 ∪ readLocs (Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3))) (pstate4, cfg4', [], ibT4', ibUT4', ls4 ∪ readLocs (Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4))) statA' (case nextB (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls1 ∪ readLocs (Config pc1 (State (Vstore vs1) avst1 h1 p1)))) (case nextB (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2) of (cfg', ibT', ibUT') ⇒ (cfg', ibT', ibUT', ls2 ∪ readLocs (Config pc2 (State (Vstore vs2) avst2 h2 p2)))) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))› and 1 goal remains*)
apply (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*) Δe_defs (*‹Δe = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg3 = endPC ∧ pcOf cfg4 = endPC ∧ cfgs3 = [] ∧ cfgs4 = [] ∧ pcOf cfg1 = endPC ∧ pcOf cfg2 = endPC)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹endPC = 7›*))
(*discuss goal 2*)
apply (simp add: Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*) Δe_defs (*‹Δe = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg3 = endPC ∧ pcOf cfg4 = endPC ∧ cfgs3 = [] ∧ cfgs4 = [] ∧ pcOf cfg1 = endPC ∧ pcOf cfg2 = endPC)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹endPC = 7›*))
(*proven 2 subgoals*) .
qed
qed
qed
qed
qed
qed
(* *)
lemma step2: "unwindIntoCond Δ2 Δ1"
proof (rule unwindIntoCond_simpleI (*‹⟦⋀(w::enat) (s1::predState × config × config list × int llist × int llist × nat set) (s2::predState × config × config list × int llist × int llist × nat set) (statA::status) (sv1::config × int llist × int llist × nat set) (sv2::config × int llist × int llist × nat set) statO::status. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; (?Δ::enat ⇒ predState × config × config list × int llist × int llist × nat set ⇒ predState × config × config list × int llist × int llist × nat set ⇒ status ⇒ config × int llist × int llist × nat set ⇒ config × int llist × int llist × nat set ⇒ status ⇒ bool) w s1 s2 statA sv1 sv2 statO⟧ ⟹ finalS s1 = finalS s2 ∧ finalN sv1 = finalS s1 ∧ finalN sv2 = finalS s2; ⋀(w::enat) (s1::predState × config × config list × int llist × int llist × nat set) (s2::predState × config × config list × int llist × int llist × nat set) (statA::status) (sv1::config × int llist × int llist × nat set) (sv2::config × int llist × int llist × nat set) statO::status. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; ?Δ w s1 s2 statA sv1 sv2 statO; statA = status.Eq⟧ ⟹ isIntO s1 = isIntO s2; ⋀(w::enat) (s1::predState × config × config list × int llist × int llist × nat set) (s2::predState × config × config list × int llist × int llist × nat set) (statA::status) (sv1::config × int llist × int llist × nat set) (sv2::config × int llist × int llist × nat set) statO::status. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; ?Δ w s1 s2 statA sv1 sv2 statO⟧ ⟹ match (?Δ'::enat ⇒ predState × config × config list × int llist × int llist × nat set ⇒ predState × config × config list × int llist × int llist × nat set ⇒ status ⇒ config × int llist × int llist × nat set ⇒ config × int llist × int llist × nat set ⇒ status ⇒ bool) s1 s2 statA sv1 sv2 statO⟧ ⟹ unwindIntoCond ?Δ ?Δ'›*))
(*goals:
1. ‹⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δ2 w s1 s2 statA sv1 sv2 statO⟧ ⟹ finalS s1 = finalS s2 ∧ finalN sv1 = finalS s1 ∧ finalN sv2 = finalS s2›
2. ‹⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δ2 w s1 s2 statA sv1 sv2 statO; statA = status.Eq⟧ ⟹ isIntO s1 = isIntO s2›
3. ‹⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δ2 w s1 s2 statA sv1 sv2 statO⟧ ⟹ match Δ1 s1 s2 statA sv1 sv2 statO›*)
fix n and ss3 and ss4 and statA and ss1 and ss2 and statO
assume r: "reachO ss3" "reachO ss4" "reachV ss1" "reachV ss2" and "Δ2": "Δ2 n ss3 ss4 statA ss1 ss2 statO" (*‹reachO (ss3::predState × config × config list × int llist × int llist × nat set)› ‹reachO (ss4::predState × config × config list × int llist × int llist × nat set)› ‹reachV (ss1::config × int llist × int llist × nat set)› ‹reachV (ss2::config × int llist × int llist × nat set)› ‹Δ2 (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
obtain pstate3 and cfg3 and cfgs3 and ibT3 and ibUT3 and ls3 where ss3: "ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)"
(*goal: ‹(⋀pstate3 cfg3 cfgs3 ibT3 ibUT3 ls3. ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⟹ thesis) ⟹ thesis›*)
apply (cases ss3)
(*goal: ‹(⋀pstate3 cfg3 cfgs3 ibT3 ibUT3 ls3. ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⟹ thesis) ⟹ thesis›*)
by auto
obtain pstate4 and cfg4 and cfgs4 and ibT4 and ibUT4 and ls4 where ss4: "ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)"
(*goal: ‹(⋀pstate4 cfg4 cfgs4 ibT4 ibUT4 ls4. ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) ⟹ thesis) ⟹ thesis›*)
apply (cases ss4)
(*goal: ‹(⋀pstate4 cfg4 cfgs4 ibT4 ibUT4 ls4. ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) ⟹ thesis) ⟹ thesis›*)
by auto
obtain cfg1 and ibT1 and ibUT1 and ls1 where ss1: "ss1 = (cfg1, ibT1, ibUT1, ls1)"
(*goal: ‹(⋀cfg1 ibT1 ibUT1 ls1. ss1 = (cfg1, ibT1, ibUT1, ls1) ⟹ thesis) ⟹ thesis›*)
apply (cases ss1)
(*goal: ‹(⋀cfg1 ibT1 ibUT1 ls1. ss1 = (cfg1, ibT1, ibUT1, ls1) ⟹ thesis) ⟹ thesis›*)
by auto
obtain cfg2 and ibT2 and ibUT2 and ls2 where ss2: "ss2 = (cfg2, ibT2, ibUT2, ls2)"
(*goal: ‹(⋀cfg2 ibT2 ibUT2 ls2. ss2 = (cfg2, ibT2, ibUT2, ls2) ⟹ thesis) ⟹ thesis›*)
apply (cases ss2)
(*goal: ‹(⋀cfg2 ibT2 ibUT2 ls2. ss2 = (cfg2, ibT2, ibUT2, ls2) ⟹ thesis) ⟹ thesis›*)
by auto
note ss = ss3 (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*) ss4 (*‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*) ss1 (*‹(ss1::config × int llist × int llist × nat set) = (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)›*) ss2 (*‹ss2 = (cfg2, ibT2, ibUT2, ls2)›*)
obtain pc3 and vs3 and avst3 and h3 and p3 where lcfgs3: "last cfgs3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)"
(*goal: ‹(⋀pc3 vs3 avst3 h3 p3. last cfgs3 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ⟹ thesis) ⟹ thesis›*)
apply (cases "last cfgs3")
(*goal: ‹(⋀pc3 vs3 avst3 h3 p3. last cfgs3 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ⟹ thesis) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore ?state) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore ?vstorea) = ?vstorea›*))
obtain pc4 and vs4 and avst4 and h4 and p4 where lcfgs4: "last cfgs4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)"
(*goal: ‹(⋀pc4 vs4 avst4 h4 p4. last cfgs4 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ⟹ thesis) ⟹ thesis›*)
apply (cases "last cfgs4")
(*goal: ‹(⋀pc4 vs4 avst4 h4 p4. last cfgs4 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ⟹ thesis) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore ?state) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore ?vstorea) = ?vstorea›*))
note lcfgs = lcfgs3 (*‹last cfgs3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)›*) lcfgs4 (*‹last cfgs4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)›*)
have f1: "¬finalN ss1"
using "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) finalB_pc_iff' (*‹(?pc::nat) < (7::nat) ⟹ finalB (Config ?pc (?s::state), ?ibT::int llist, ?ibUT::int llist) = (?pc = (1::nat) ∧ ?ibUT = [[]])›*) unfolding ss finalN_iff_finalB "Δ2_defs"
(*goal: ‹¬ finalB (cfg1, ibT1, ibUT1)›*)
by simp
have f2: "¬finalN ss2"
using "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) finalB_pc_iff' (*‹?pc < 7 ⟹ finalB (Config ?pc ?s, ?ibT, ?ibUT) = (?pc = 1 ∧ ?ibUT = [[]])›*) unfolding ss finalN_iff_finalB "Δ2_defs"
(*goal: ‹¬ finalB (cfg2, ibT2, ibUT2)›*)
by auto
have f3: "¬finalS ss3"
using "Δ2" (*‹Δ2 (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) unfolding ss
(*goal: ‹¬ finalS (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
apply -
(*goal: ‹¬ finalS (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
apply (frule Δ2_implies (*‹Δ2 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ pcOf (last ?cfgs3.0) = 6 ∧ pcOf ?cfg3.0 = 4 ∧ pcOf (last ?cfgs4.0) = pcOf (last ?cfgs3.0) ∧ pcOf ?cfg3.0 = pcOf ?cfg4.0 ∧ length ?cfgs3.0 = Suc 0 ∧ length ?cfgs3.0 = length ?cfgs4.0›*))
(*goal: ‹Δ2 n (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ ¬ finalS (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
using finalS_cond_spec (*‹⟦pcOf ?cfg < 7; (pcOf (last ?cfgs) = 4 ∨ pcOf (last ?cfgs) = 5 ∨ pcOf (last ?cfgs) = 6) ∧ pcOf ?cfg = 6 ∨ pcOf (last ?cfgs) = 6 ∧ pcOf ?cfg = 4; length ?cfgs = Suc 0⟧ ⟹ ¬ finalS (?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls)›*) by simp
have f4: "¬finalS ss4"
using "Δ2" (*‹Δ2 (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) unfolding ss
(*goal: ‹¬ finalS (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply -
(*goal: ‹¬ finalS (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply (frule Δ2_implies (*‹Δ2 (?num::enat) (?pstate3.0::predState, ?cfg3.0::config, ?cfgs3.0::config list, ?ibT3.0::int llist, ?ibUT3.0::int llist, ?ls3.0::nat set) (?pstate4.0::predState, ?cfg4.0::config, ?cfgs4.0::config list, ?ibT4.0::int llist, ?ibUT4.0::int llist, ?ls4.0::nat set) (?statA::status) (?cfg1.0::config, ?ibT1.0::int llist, ?ibUT1.0::int llist, ?ls1.0::nat set) (?cfg2.0::config, ?ibT2.0::int llist, ?ibUT2.0::int llist, ?ls2.0::nat set) (?statO::status) ⟹ pcOf (last ?cfgs3.0) = (6::nat) ∧ pcOf ?cfg3.0 = (4::nat) ∧ pcOf (last ?cfgs4.0) = pcOf (last ?cfgs3.0) ∧ pcOf ?cfg3.0 = pcOf ?cfg4.0 ∧ length ?cfgs3.0 = Suc (0::nat) ∧ length ?cfgs3.0 = length ?cfgs4.0›*))
(*goal: ‹Δ2 n (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ ¬ finalS (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
using finalS_cond_spec (*‹⟦pcOf ?cfg < 7; (pcOf (last ?cfgs) = 4 ∨ pcOf (last ?cfgs) = 5 ∨ pcOf (last ?cfgs) = 6) ∧ pcOf ?cfg = 6 ∨ pcOf (last ?cfgs) = 6 ∧ pcOf ?cfg = 4; length ?cfgs = Suc 0⟧ ⟹ ¬ finalS (?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls)›*) by simp
note finals = f1 (*‹¬ finalN ss1›*) f2 (*‹¬ finalN (ss2::config × int llist × int llist × nat set)›*) f3 (*‹¬ finalS ss3›*) f4 (*‹¬ finalS ss4›*)
show "finalS ss3 = finalS ss4 ∧ finalN ss1 = finalS ss3 ∧ finalN ss2 = finalS ss4"
using finals (*‹¬ finalN ss1› ‹¬ finalN ss2› ‹¬ finalS ss3› ‹¬ finalS ss4›*) by auto
then show "isIntO ss3 = isIntO ss4"
by simp
show "match Δ1 ss3 ss4 statA ss1 ss2 statO"
unfolding match_def
(*goal: ‹match1 Δ1 ss3 ss4 statA ss1 ss2 statO ∧ match2 Δ1 ss3 ss4 statA ss1 ss2 statO ∧ match12 Δ1 ss3 ss4 statA ss1 ss2 statO›*)
proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹match1 Δ1 (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
2. ‹match2 Δ1 (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
3. ‹match12 Δ1 (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
show "match1 Δ1 ss3 ss4 statA ss1 ss2 statO"
unfolding match1_def
(*goal: ‹¬ isIntO ss3 ⟶ (∀s1'. validTransO (ss3, s1') ⟶ ¬ isSecO ss3 ∧ Δ1 ∞ s1' ss4 statA ss1 ss2 statO ∨ eqSec ss1 ss3 ∧ ¬ isIntV ss1 ∧ match1_1 Δ1 ss3 s1' ss4 statA ss1 ss2 statO ∨ eqSec ss1 ss3 ∧ ¬ isSecV ss2 ∧ Van.eqAct ss1 ss2 ∧ match1_12 Δ1 ss3 s1' ss4 statA ss1 ss2 statO)›*)
by (simp add: finalS_def (*‹finalS = final (→S)›*) final_def (*‹final (?r::?'a ⇒ ?'b ⇒ bool) (?x::?'a) ≡ ∀y::?'b. ¬ ?r ?x y›*))
show "match2 Δ1 ss3 ss4 statA ss1 ss2 statO"
unfolding match2_def
(*goal: ‹¬ isIntO ss4 ⟶ (∀s2'. validTransO (ss4, s2') ⟶ ¬ isSecO ss4 ∧ Δ1 ∞ ss3 s2' statA ss1 ss2 statO ∨ eqSec ss2 ss4 ∧ ¬ isIntV ss2 ∧ match2_1 Δ1 ss3 ss4 s2' statA ss1 ss2 statO ∨ ¬ isSecV ss1 ∧ eqSec ss2 ss4 ∧ Van.eqAct ss1 ss2 ∧ match2_12 Δ1 ss3 ss4 s2' statA ss1 ss2 statO)›*)
by (simp add: finalS_def (*‹finalS = final (→S)›*) final_def (*‹final (?r::?'a ⇒ ?'b ⇒ bool) (?x::?'a) ≡ ∀y::?'b. ¬ ?r ?x y›*))
show "match12 Δ1 ss3 ss4 statA ss1 ss2 statO"
proof (rule match12_simpleI (*‹(⋀(s1'::predState × config × config list × int llist × int llist × nat set) (s2'::predState × config × config list × int llist × int llist × nat set) statA'::status. ⟦statA' = sstatA' (?statA::status) (?s1.0::predState × config × config list × int llist × int llist × nat set) (?s2.0::predState × config × config list × int llist × int llist × nat set); validTransO (?s1.0, s1'); validTransO (?s2.0, s2'); Opt.eqAct ?s1.0 ?s2.0⟧ ⟹ ¬ isSecO ?s1.0 ∧ ¬ isSecO ?s2.0 ∧ (?statA = statA' ∨ (?statO::status) = Diff) ∧ (?Δ::?'a::infinity ⇒ predState × config × config list × int llist × int llist × nat set ⇒ predState × config × config list × int llist × int llist × nat set ⇒ status ⇒ config × int llist × int llist × nat set ⇒ config × int llist × int llist × nat set ⇒ status ⇒ bool) ∞ s1' s2' statA' (?sv1.0::config × int llist × int llist × nat set) (?sv2.0::config × int llist × int llist × nat set) ?statO ∨ eqSec ?sv1.0 ?s1.0 ∧ eqSec ?sv2.0 ?s2.0 ∧ Van.eqAct ?sv1.0 ?sv2.0 ∧ match12_12 ?Δ s1' s2' statA' ?sv1.0 ?sv2.0 ?statO) ⟹ match12 ?Δ ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*), rule disjI1 (*‹?P ⟹ ?P ∨ ?Q›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⋀s1' s2' statA'. ⟦statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ ¬ isSecO ss3›
2. ‹⋀s1' s2' statA'. ⟦statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ ¬ isSecO ss4›
3. ‹⋀s1' s2' statA'. ⟦statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ statA = statA' ∨ statO = Diff›
4. ‹⋀s1' s2' statA'. ⟦statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ Δ1 ∞ s1' s2' statA' ss1 ss2 statO›*)
fix ss3' and ss4' and statA'
assume statA': "statA' = sstatA' statA ss3 ss4" and v: "validTransO (ss3, ss3')" "validTransO (ss4, ss4')" and sa: "Opt.eqAct ss3 ss4" (*‹(statA'::status) = sstatA' (statA::status) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss3::predState × config × config list × int llist × int llist × nat set, ss3'::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)› ‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*)
note v3 = v(1) (*‹validTransO (ss3, ss3')›*)
note v4 = v(2) (*‹validTransO (ss4, ss4')›*)
obtain pstate3' and cfg3' and cfgs3' and ibT3' and ibUT3' and ls3' where ss3': "ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')"
(*goal: ‹(⋀(pstate3'::predState) (cfg3'::config) (cfgs3'::config list) (ibT3'::int llist) (ibUT3'::int llist) ls3'::nat set. (ss3'::predState × config × config list × int llist × int llist × nat set) = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') ⟹ thesis::bool) ⟹ thesis›*)
apply (cases ss3')
(*goal: ‹(⋀pstate3' cfg3' cfgs3' ibT3' ibUT3' ls3'. ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') ⟹ thesis) ⟹ thesis›*)
by auto
obtain pstate4' and cfg4' and cfgs4' and ibT4' and ibUT4' and ls4' where ss4': "ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')"
(*goal: ‹(⋀pstate4' cfg4' cfgs4' ibT4' ibUT4' ls4'. ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') ⟹ thesis) ⟹ thesis›*)
apply (cases ss4')
(*goal: ‹(⋀pstate4' cfg4' cfgs4' ibT4' ibUT4' ls4'. ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') ⟹ thesis) ⟹ thesis›*)
by auto
note ss = ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)› ‹(ss1::config × int llist × int llist × nat set) = (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)› ‹ss2 = (cfg2, ibT2, ibUT2, ls2)›*) ss3' (*‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')›*) ss4' (*‹ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*)
obtain hh3 where h3: "h3 = Heap hh3"
(*goal: ‹(⋀hh3::nat ⇒ int. (h3::heap) = Heap hh3 ⟹ thesis::bool) ⟹ thesis›*)
apply (cases h3)
(*goal: ‹(⋀hh3. h3 = Heap hh3 ⟹ thesis) ⟹ thesis›*)
by auto
obtain hh4 where h4: "h4 = Heap hh4"
(*goal: ‹(⋀hh4. h4 = Heap hh4 ⟹ thesis) ⟹ thesis›*)
apply (cases h4)
(*goal: ‹(⋀hh4::nat ⇒ int. (h4::heap) = Heap hh4 ⟹ thesis::bool) ⟹ thesis›*)
by auto
note hh = h3 (*‹h3 = Heap hh3›*) h4 (*‹h4 = Heap hh4›*)
show "¬ isSecO ss3"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹¬ isSecO (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
by (simp add: Δ2_defs (*‹Δ2 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = startOfThenBranch ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = elseBranch ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ misSpecL1 cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹same_var ?x ?cfg ?cfg' ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x› ‹startOfThenBranch = 4› ‹misSpecL1 ?cfgs ≡ length ?cfgs = Suc 0› ‹elseBranch = 6›*))
show "¬ isSecO ss4"
using v (*‹validTransO (ss3::predState × config × config list × int llist × int llist × nat set, ss3'::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹¬ isSecO (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply clarsimp
(*goal: ‹¬ isSecO (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply (simp add: Δ2_defs (*‹Δ2 = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = startOfThenBranch ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = elseBranch ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ misSpecL1 cfgs3)› ‹common_strat1 = (λ(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹same_var (?x::char list) (?cfg::config) (?cfg'::config) ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x› ‹startOfThenBranch = (4::?'a)› ‹misSpecL1 (?cfgs::config list) ≡ length ?cfgs = Suc (0::nat)› ‹elseBranch = (6::?'a)›*))
(*goal: ‹⟦(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) →S (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set); Opt.eqAct (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4::predState, cfg4::config, [], ibT4::int llist, ibUT4::int llist, ls4::nat set); Δ2 (n::enat) (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, [], ibT4, ibUT4, ls4) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status); (cfgs4::config list) = []; pcOf cfg4 = (0::nat); (pstate4'::predState) = pstate4; (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4, ibT4, ibUT4); (cfgs4'::config list) = []; (ls4'::nat set) = ls4 ∪ readLocs cfg4⟧ ⟹ False›*)
by linarith
show stat: "statA = statA' ∨ statO = Diff"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) apply (cases ss3, cases ss4, cases ss1, cases ss2)
(*goal: ‹statA = statA' ∨ statO = Diff›*)
apply (cases ss3', cases ss4', clarsimp)
(*goal: ‹⋀a b c d e f aa ba ca da ea fa ab bb cb db ac bc cc dc. ⟦validTransO (ss3, ss3'); validTransO (ss4, ss4'); Opt.eqAct ss3 ss4; Δ2 n ss3 ss4 statA ss1 ss2 statO; ss3 = (a, b, c, d, e, f); validTransO (ss3, ss3'); validTransO (ss4, ss4'); Opt.eqAct ss3 ss4; Δ2 n ss3 ss4 statA ss1 ss2 statO; ss4 = (aa, ba, ca, da, ea, fa); validTransO (ss3, ss3'); validTransO (ss4, ss4'); Opt.eqAct ss3 ss4; Δ2 n ss3 ss4 statA ss1 ss2 statO; ss1 = (ab, bb, cb, db); validTransO (ss3, ss3'); validTransO (ss4, ss4'); Opt.eqAct ss3 ss4; Δ2 n ss3 ss4 statA ss1 ss2 statO; ss2 = (ac, bc, cc, dc)⟧ ⟹ statA = statA' ∨ statO = Diff›*)
unfolding ss statA'
(*goal: ‹⋀a b c d e f aa ba ca da ea fa ab bb cb db ac bc cc dc ad bd cd dd eb fb ae be ce de ec fc. ⟦(a, b, c, d, e, f) →S (ad, bd, cd, dd, eb, fb); (aa, ba, ca, da, ea, fa) →S (ae, be, ce, de, ec, fc); Opt.eqAct (a, b, c, d, e, f) (aa, ba, ca, da, ea, fa); Δ2 n (a, b, c, d, e, f) (aa, ba, ca, da, ea, fa) statA (ab, bb, cb, db) (ac, bc, cc, dc) statO; (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) = (a, b, c, d, e, f); (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) = (aa, ba, ca, da, ea, fa); (cfg1, ibT1, ibUT1, ls1) = (ab, bb, cb, db); (cfg2, ibT2, ibUT2, ls2) = (ac, bc, cc, dc); (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') = (ad, bd, cd, dd, eb, fb); (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') = (ae, be, ce, de, ec, fc); statO ≠ Diff⟧ ⟹ statA = sstatA' statA (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply clarsimp
(*goal: ‹⋀(a::predState) (b::config) (c::config list) (d::int llist) (e::int llist) (f::nat set) (aa::predState) (ba::config) (ca::config list) (da::int llist) (ea::int llist) (fa::nat set) (ab::config) (bb::int llist) (cb::int llist) (db::nat set) (ac::config) (bc::int llist) (cc::int llist) (dc::nat set) (ad::predState) (bd::config) (cd::config list) (dd::int llist) (eb::int llist) (fb::nat set) (ae::predState) (be::config) (ce::config list) (de::int llist) (ec::int llist) fc::nat set. ⟦(a, b, c, d, e, f) →S (ad, bd, cd, dd, eb, fb); (aa, ba, ca, da, ea, fa) →S (ae, be, ce, de, ec, fc); Opt.eqAct (a, b, c, d, e, f) (aa, ba, ca, da, ea, fa); Δ2 (n::enat) (a, b, c, d, e, f) (aa, ba, ca, da, ea, fa) (statA::status) (ab, bb, cb, db) (ac, bc, cc, dc) (statO::status); (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) = (a, b, c, d, e, f); (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) = (aa, ba, ca, da, ea, fa); (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) = (ab, bb, cb, db); (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) = (ac, bc, cc, dc); (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) = (ad, bd, cd, dd, eb, fb); (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) = (ae, be, ce, de, ec, fc); statO ≠ Diff⟧ ⟹ statA = sstatA' statA (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply (simp_all add: Δ2_defs sstatA'_def)
(*goal: ‹⟦(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4); Δ2 n (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO; statO ≠ Diff⟧ ⟹ statA = sstatA' statA (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply (cases statO, simp_all)
(*goal: ‹⟦(pstate4, cfg3, cfgs3, ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3) ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4) ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ statA ≠ Diff ∧ pcOf cfg3 = 4 ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = 6 ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ length cfgs3 = Suc 0; statO ≠ Diff⟧ ⟹ statA = updStat statA (¬ finalS (pstate4, cfg3, cfgs3, ibT3, ibUT3, ls3), ⊥) (¬ finalS (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4), ⊥)›*)
apply (cases statA, simp_all)
(*goal: ‹⟦(pstate4::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) →S (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set); (pstate4, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); Opt.eqAct (pstate4, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4); (pstate3::predState) = pstate4 ∧ (cfg1::config) = cfg3 ∧ (cfg2::config) = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ≤ (6::nat) ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3) ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4) ∧ (∀n::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA::status) ≠ Diff ∧ pcOf cfg3 = (4::nat) ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = (6::nat) ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ (ls1::nat set) = ls3 ∧ (ls2::nat set) = ls4 ∧ length cfgs3 = Suc (0::nat); (statO::status) = status.Eq⟧ ⟹ statA = updStat statA (¬ finalS (pstate4, cfg3, cfgs3, ibT3, ibUT3, ls3), ⊥) (¬ finalS (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4), ⊥)›*)
unfolding finalS_defs
(*goal: ‹⟦(pstate4::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) →S (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set); (pstate4, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); Opt.eqAct (pstate4, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4); (pstate3::predState) = pstate4 ∧ (cfg1::config) = cfg3 ∧ (cfg2::config) = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ≤ (6::nat) ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3) ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4) ∧ (∀n::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ pcOf cfg3 = (4::nat) ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = (6::nat) ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ (ls1::nat set) = ls3 ∧ (ls2::nat set) = ls4 ∧ length cfgs3 = Suc (0::nat); (statO::status) = status.Eq; (statA::status) = status.Eq⟧ ⟹ status.Eq = updStat status.Eq (¬ (∀y::predState × config × config list × int llist × int llist × nat set. ¬ (pstate4, cfg3, cfgs3, ibT3, ibUT3, ls3) →S y), ⊥) (¬ (∀y::predState × config × config list × int llist × int llist × nat set. ¬ (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) →S y), ⊥)›*)
by (smt (verit, ccfv_SIG) updStat.simps( (*‹updStat status.Eq (True, ?a) (True, ?a') = (if ?a = ?a' then status.Eq else Diff)›*) 1))
show "Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO"
using v3[unfolded ss, simplified] (*‹(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')›*) proof (cases rule: stepS_cases (*‹⟦(?pstate::predState, ?cfg::config, ?cfgs::config list, ?ibT::int llist, ?ibUT::int llist, ?ls::nat set) →S (?pstate'::predState, ?cfg'::config, ?cfgs'::config list, ?ibT'::int llist, ?ibUT'::int llist, ?ls'::nat set); ⟦?cfgs = []; ¬ is_IfJump (prog ! pcOf ?cfg) ∨ ¬ mispred ?pstate [pcOf ?cfg]; ?pstate' = ?pstate; ¬ finalB (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ?cfgs' = []; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis::bool; ⟦?cfgs = []; is_IfJump (prog ! pcOf ?cfg); mispred ?pstate [pcOf ?cfg]; ?pstate' = update ?pstate [pcOf ?cfg]; ¬ finalM (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (?cfg, ?ibT, ?ibUT) ∧ ?cfgs' = [cfg1']; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ is_IfJump (prog ! pcOf (last ?cfgs)) ∨ ¬ mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) ≠ Fence; ?pstate' = ?pstate; ¬ is_getInput (prog ! pcOf (last ?cfgs)); ¬ is_Output (prog ! pcOf (last ?cfgs)); ?cfg' = ?cfg; ?ls' = ?ls ∪ readLocs (last ?cfgs); ∃cfg1'::config. nextB (last ?cfgs, ?ibT, ?ibUT) = (cfg1', ?ibT', ?ibUT') ∧ ?cfgs' = butlast ?cfgs ## cfg1'⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); is_IfJump (prog ! pcOf (last ?cfgs)); mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ finalM (last ?cfgs, ?ibT, ?ibUT); ?cfg' = ?cfg; ∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last ?cfgs, ?ibT, ?ibUT) = (lcfg', ?ibT', ?ibUT') ∧ (cfg1', ibT1', ibUT1') = nextM (last ?cfgs, ?ibT, ?ibUT) ∧ ?cfgs' = butlast ?cfgs @ [lcfg'] ## cfg1'; ?ls' = ?ls ∪ readLocs (last ?cfgs)⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) = Fence; ?pstate' = ?pstate; ?cfg' = ?cfg; ?cfgs' = []; ?ibT' = ?ibT; ?ibUT' = ?ibUT; ?ls' = ?ls⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?cfg' = ?cfg; ?cfgs' = butlast ?cfgs; ?ls' = ?ls; ?ibT' = ?ibT; ?ibUT' = ?ibUT⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⟦(cfgs3::config list) = []; ¬ is_IfJump (prog ! pcOf (cfg3::config)) ∨ ¬ mispred (pstate3::predState) [pcOf cfg3]; (pstate3'::predState) = pstate3; ¬ finalB (cfg3, ibT3::int llist, ibUT3::int llist); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3, ibT3, ibUT3); (cfgs3'::config list) = []; (ls3'::nat set) = (ls3::nat set) ∪ readLocs cfg3⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
2. ‹⟦(cfgs3::config list) = []; is_IfJump (prog ! pcOf (cfg3::config)); mispred (pstate3::predState) [pcOf cfg3]; (pstate3'::predState) = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3::int llist, ibUT3::int llist); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3, ibT3, ibUT3); ∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ (cfgs3'::config list) = [cfg1']; (ls3'::nat set) = (ls3::nat set) ∪ readLocs cfg3⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
3. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); ¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) ≠ Fence; (pstate3'::predState) = pstate3; ¬ is_getInput (prog ! pcOf (last cfgs3)); ¬ is_Output (prog ! pcOf (last cfgs3)); (cfg3'::config) = cfg3; (ls3'::nat set) = (ls3::nat set) ∪ readLocs (last cfgs3); ∃cfg1'::config. nextB (last cfgs3, ibT3::int llist, ibUT3::int llist) = (cfg1', ibT3'::int llist, ibUT3'::int llist) ∧ (cfgs3'::config list) = butlast cfgs3 ## cfg1'⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
4. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); (pstate3'::predState) = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3::int llist, ibUT3::int llist); (cfg3'::config) = cfg3; ∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3'::int llist, ibUT3'::int llist) ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ (cfgs3'::config list) = butlast cfgs3 @ [lcfg'] ## cfg1'; (ls3'::nat set) = (ls3::nat set) ∪ readLocs (last cfgs3)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
5. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; (pstate3'::predState) = pstate3; (cfg3'::config) = cfg3; (cfgs3'::config list) = []; (ibT3'::int llist) = (ibT3::int llist); (ibUT3'::int llist) = (ibUT3::int llist); (ls3'::nat set) = (ls3::nat set)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
6. ‹⟦(cfgs3::config list) ≠ []; resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); (pstate3'::predState) = update pstate3 (pcOf cfg3 # map pcOf cfgs3); (cfg3'::config) = cfg3; (cfgs3'::config list) = butlast cfgs3; (ls3'::nat set) = (ls3::nat set); (ibT3'::int llist) = (ibT3::int llist); (ibUT3'::int llist) = (ibUT3::int llist)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
case nonspec_normal (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*)
then show "?thesis"
(*goal: ‹Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›*)
using sa (*‹Opt.eqAct ss3 ss4›*) stat (*‹statA = statA' ∨ statO = Diff›*) "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
by (simp add: Δ2_defs (*‹Δ2 = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = startOfThenBranch ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = elseBranch ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ misSpecL1 cfgs3)› ‹common_strat1 = (λ(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹same_var (?x::char list) (?cfg::config) (?cfg'::config) ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x› ‹startOfThenBranch = (4::?'a)› ‹misSpecL1 (?cfgs::config list) ≡ length ?cfgs = Suc (0::nat)› ‹elseBranch = (6::?'a)›*))
next
(*goals:
1. ‹⟦(cfgs3::config list) = []; is_IfJump (prog ! pcOf (cfg3::config)); mispred (pstate3::predState) [pcOf cfg3]; (pstate3'::predState) = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3::int llist, ibUT3::int llist); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3, ibT3, ibUT3); ∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ (cfgs3'::config list) = [cfg1']; (ls3'::nat set) = (ls3::nat set) ∪ readLocs cfg3⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
2. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); ¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) ≠ Fence; (pstate3'::predState) = pstate3; ¬ is_getInput (prog ! pcOf (last cfgs3)); ¬ is_Output (prog ! pcOf (last cfgs3)); (cfg3'::config) = cfg3; (ls3'::nat set) = (ls3::nat set) ∪ readLocs (last cfgs3); ∃cfg1'::config. nextB (last cfgs3, ibT3::int llist, ibUT3::int llist) = (cfg1', ibT3'::int llist, ibUT3'::int llist) ∧ (cfgs3'::config list) = butlast cfgs3 ## cfg1'⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
3. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); (pstate3'::predState) = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3::int llist, ibUT3::int llist); (cfg3'::config) = cfg3; ∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3'::int llist, ibUT3'::int llist) ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ (cfgs3'::config list) = butlast cfgs3 @ [lcfg'] ## cfg1'; (ls3'::nat set) = (ls3::nat set) ∪ readLocs (last cfgs3)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
4. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; (pstate3'::predState) = pstate3; (cfg3'::config) = cfg3; (cfgs3'::config list) = []; (ibT3'::int llist) = (ibT3::int llist); (ibUT3'::int llist) = (ibUT3::int llist); (ls3'::nat set) = (ls3::nat set)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
5. ‹⟦(cfgs3::config list) ≠ []; resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); (pstate3'::predState) = update pstate3 (pcOf cfg3 # map pcOf cfgs3); (cfg3'::config) = cfg3; (cfgs3'::config list) = butlast cfgs3; (ls3'::nat set) = (ls3::nat set); (ibT3'::int llist) = (ibT3::int llist); (ibUT3'::int llist) = (ibUT3::int llist)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
case nonspec_mispred (*‹(cfgs3::config list) = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred (pstate3::predState) [pcOf (cfg3::config)]› ‹(pstate3'::predState) = update (pstate3::predState) [pcOf (cfg3::config)]› ‹¬ finalM (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg3::config, ibT3::int llist, ibUT3::int llist) ∧ (cfgs3'::config list) = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*)
then show "?thesis"
(*goal: ‹Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) stat (*‹statA = statA' ∨ statO = Diff›*) "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
by (simp add: Δ2_defs (*‹Δ2 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = startOfThenBranch ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = elseBranch ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ misSpecL1 cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹same_var ?x ?cfg ?cfg' ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x› ‹startOfThenBranch = 4› ‹misSpecL1 ?cfgs ≡ length ?cfgs = Suc 0› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); ¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) ≠ Fence; (pstate3'::predState) = pstate3; ¬ is_getInput (prog ! pcOf (last cfgs3)); ¬ is_Output (prog ! pcOf (last cfgs3)); (cfg3'::config) = cfg3; (ls3'::nat set) = (ls3::nat set) ∪ readLocs (last cfgs3); ∃cfg1'::config. nextB (last cfgs3, ibT3::int llist, ibUT3::int llist) = (cfg1', ibT3'::int llist, ibUT3'::int llist) ∧ (cfgs3'::config list) = butlast cfgs3 ## cfg1'⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
2. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); (pstate3'::predState) = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3::int llist, ibUT3::int llist); (cfg3'::config) = cfg3; ∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3'::int llist, ibUT3'::int llist) ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ (cfgs3'::config list) = butlast cfgs3 @ [lcfg'] ## cfg1'; (ls3'::nat set) = (ls3::nat set) ∪ readLocs (last cfgs3)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
3. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; (pstate3'::predState) = pstate3; (cfg3'::config) = cfg3; (cfgs3'::config list) = []; (ibT3'::int llist) = (ibT3::int llist); (ibUT3'::int llist) = (ibUT3::int llist); (ls3'::nat set) = (ls3::nat set)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
4. ‹⟦(cfgs3::config list) ≠ []; resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); (pstate3'::predState) = update pstate3 (pcOf cfg3 # map pcOf cfgs3); (cfg3'::config) = cfg3; (cfgs3'::config list) = butlast cfgs3; (ls3'::nat set) = (ls3::nat set); (ibT3'::int llist) = (ibT3::int llist); (ibUT3'::int llist) = (ibUT3::int llist)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
case spec_normal (*‹(cfgs3::config list) ≠ []› ‹¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf (cfgs3::config list))› ‹¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹prog ! pcOf (last cfgs3) ≠ Fence› ‹pstate3' = pstate3› ‹¬ is_getInput (prog ! pcOf (last (cfgs3::config list)))› ‹¬ is_Output (prog ! pcOf (last cfgs3))› ‹cfg3' = cfg3› ‹ls3' = ls3 ∪ readLocs (last cfgs3)› ‹∃cfg1'. nextB (last cfgs3, ibT3, ibUT3) = (cfg1', ibT3', ibUT3') ∧ cfgs3' = butlast cfgs3 ## cfg1'›*)
then show "?thesis"
(*goal: ‹Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) stat (*‹(statA::status) = (statA'::status) ∨ (statO::status) = Diff›*) "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) v3 (*‹validTransO (ss3, ss3')›*) unfolding ss
(*goal: ‹Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
apply -
(*goal: ‹Δ1 ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status)›*)
apply (frule Δ2_implies (*‹Δ2 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ pcOf (last ?cfgs3.0) = 6 ∧ pcOf ?cfg3.0 = 4 ∧ pcOf (last ?cfgs4.0) = pcOf (last ?cfgs3.0) ∧ pcOf ?cfg3.0 = pcOf ?cfg4.0 ∧ length ?cfgs3.0 = Suc 0 ∧ length ?cfgs3.0 = length ?cfgs4.0›*))
(*goal: ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) ≠ Fence; pstate3' = pstate3; ¬ is_getInput (prog ! pcOf (last cfgs3)); ¬ is_Output (prog ! pcOf (last cfgs3)); cfg3' = cfg3; ls3' = ls3 ∪ readLocs (last cfgs3); ∃cfg1'. nextB (last cfgs3, ibT3, ibUT3) = (cfg1', ibT3', ibUT3') ∧ cfgs3' = butlast cfgs3 ## cfg1'; Opt.eqAct (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4); statA = statA' ∨ statO = Diff; Δ2 n (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO; validTransO ((pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3), pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')⟧ ⟹ Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
by (simp add: Δ2_defs (*‹Δ2 = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = startOfThenBranch ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = elseBranch ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ misSpecL1 cfgs3)› ‹common_strat1 = (λ(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a::{zero,numeral,ord}..6::?'a::{zero,numeral,ord}}› ‹same_var (?x::char list) (?cfg::config) (?cfg'::config) ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x› ‹startOfThenBranch = (4::?'a::numeral)› ‹misSpecL1 (?cfgs::config list) ≡ length ?cfgs = Suc (0::nat)› ‹elseBranch = (6::?'a::numeral)›*))
next
(*goals:
1. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); (pstate3'::predState) = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3::int llist, ibUT3::int llist); (cfg3'::config) = cfg3; ∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3'::int llist, ibUT3'::int llist) ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ (cfgs3'::config list) = butlast cfgs3 @ [lcfg'] ## cfg1'; (ls3'::nat set) = (ls3::nat set) ∪ readLocs (last cfgs3)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
2. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; (pstate3'::predState) = pstate3; (cfg3'::config) = cfg3; (cfgs3'::config list) = []; (ibT3'::int llist) = (ibT3::int llist); (ibUT3'::int llist) = (ibUT3::int llist); (ls3'::nat set) = (ls3::nat set)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
3. ‹⟦(cfgs3::config list) ≠ []; resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); (pstate3'::predState) = update pstate3 (pcOf cfg3 # map pcOf cfgs3); (cfg3'::config) = cfg3; (cfgs3'::config list) = butlast cfgs3; (ls3'::nat set) = (ls3::nat set); (ibT3'::int llist) = (ibT3::int llist); (ibUT3'::int llist) = (ibUT3::int llist)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
case spec_mispred (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹is_IfJump (prog ! pcOf (last cfgs3))› ‹mispred pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹¬ finalM (last cfgs3, ibT3, ibUT3)› ‹cfg3' = cfg3› ‹∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (last (cfgs3::config list))›*)
then show "?thesis"
(*goal: ‹Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›*)
using sa (*‹Opt.eqAct ss3 ss4›*) stat (*‹(statA::status) = (statA'::status) ∨ (statO::status) = Diff›*) "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
apply -
(*goal: ‹Δ1 ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status)›*)
apply (frule Δ2_implies (*‹Δ2 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ pcOf (last ?cfgs3.0) = 6 ∧ pcOf ?cfg3.0 = 4 ∧ pcOf (last ?cfgs4.0) = pcOf (last ?cfgs3.0) ∧ pcOf ?cfg3.0 = pcOf ?cfg4.0 ∧ length ?cfgs3.0 = Suc 0 ∧ length ?cfgs3.0 = length ?cfgs4.0›*))
(*goal: ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3, ibUT3); cfg3' = cfg3; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'; ls3' = ls3 ∪ readLocs (last cfgs3); Opt.eqAct (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4); statA = statA' ∨ statO = Diff; Δ2 n (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO⟧ ⟹ Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
by (simp add: Δ2_defs (*‹Δ2 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = startOfThenBranch ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = elseBranch ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ misSpecL1 cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹same_var ?x ?cfg ?cfg' ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x› ‹startOfThenBranch = 4› ‹misSpecL1 ?cfgs ≡ length ?cfgs = Suc 0› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›
2. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›*)
case spec_Fence (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹prog ! pcOf (last (cfgs3::config list)) = Fence› ‹pstate3' = pstate3› ‹cfg3' = cfg3› ‹cfgs3' = []› ‹ibT3' = ibT3› ‹(ibUT3'::int llist) = (ibUT3::int llist)› ‹ls3' = ls3›*)
then show "?thesis"
(*goal: ‹Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›*)
using sa (*‹Opt.eqAct ss3 ss4›*) stat (*‹(statA::status) = (statA'::status) ∨ (statO::status) = Diff›*) "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
apply -
(*goal: ‹Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
apply (frule Δ2_implies (*‹Δ2 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ pcOf (last ?cfgs3.0) = 6 ∧ pcOf ?cfg3.0 = 4 ∧ pcOf (last ?cfgs4.0) = pcOf (last ?cfgs3.0) ∧ pcOf ?cfg3.0 = pcOf ?cfg4.0 ∧ length ?cfgs3.0 = Suc 0 ∧ length ?cfgs3.0 = length ?cfgs4.0›*))
(*goal: ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3; Opt.eqAct (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4); statA = statA' ∨ statO = Diff; Δ2 n (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO⟧ ⟹ Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
by (simp add: Δ2_defs (*‹Δ2 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = startOfThenBranch ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = elseBranch ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ misSpecL1 cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹same_var ?x ?cfg ?cfg' ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x› ‹startOfThenBranch = 4› ‹misSpecL1 ?cfgs ≡ length ?cfgs = Suc 0› ‹elseBranch = 6›*))
next
(*goal: ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›*)
case spec_resolve (*‹cfgs3 ≠ []› ‹resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹(pstate3'::predState) = update (pstate3::predState) (pcOf (cfg3::config) # map pcOf (cfgs3::config list))› ‹(cfg3'::config) = (cfg3::config)› ‹cfgs3' = butlast cfgs3› ‹ls3' = ls3› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3›*)
note sr3 = spec_resolve (*‹cfgs3 ≠ []› ‹resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf (cfgs3::config list))› ‹(pstate3'::predState) = update (pstate3::predState) (pcOf (cfg3::config) # map pcOf (cfgs3::config list))› ‹cfg3' = cfg3› ‹cfgs3' = butlast cfgs3› ‹ls3' = ls3› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3›*)
show "?thesis"
(*goal: ‹Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›*)
using v4[unfolded ss, simplified] (*‹(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*) proof (cases rule: stepS_cases (*‹⟦(?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls) →S (?pstate', ?cfg', ?cfgs', ?ibT', ?ibUT', ?ls'); ⟦?cfgs = []; ¬ is_IfJump (prog ! pcOf ?cfg) ∨ ¬ mispred ?pstate [pcOf ?cfg]; ?pstate' = ?pstate; ¬ finalB (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ?cfgs' = []; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs = []; is_IfJump (prog ! pcOf ?cfg); mispred ?pstate [pcOf ?cfg]; ?pstate' = update ?pstate [pcOf ?cfg]; ¬ finalM (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (?cfg, ?ibT, ?ibUT) ∧ ?cfgs' = [cfg1']; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ is_IfJump (prog ! pcOf (last ?cfgs)) ∨ ¬ mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) ≠ Fence; ?pstate' = ?pstate; ¬ is_getInput (prog ! pcOf (last ?cfgs)); ¬ is_Output (prog ! pcOf (last ?cfgs)); ?cfg' = ?cfg; ?ls' = ?ls ∪ readLocs (last ?cfgs); ∃cfg1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (cfg1', ?ibT', ?ibUT') ∧ ?cfgs' = butlast ?cfgs ## cfg1'⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); is_IfJump (prog ! pcOf (last ?cfgs)); mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ finalM (last ?cfgs, ?ibT, ?ibUT); ?cfg' = ?cfg; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (lcfg', ?ibT', ?ibUT') ∧ (cfg1', ibT1', ibUT1') = nextM (last ?cfgs, ?ibT, ?ibUT) ∧ ?cfgs' = butlast ?cfgs @ [lcfg'] ## cfg1'; ?ls' = ?ls ∪ readLocs (last ?cfgs)⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) = Fence; ?pstate' = ?pstate; ?cfg' = ?cfg; ?cfgs' = []; ?ibT' = ?ibT; ?ibUT' = ?ibUT; ?ls' = ?ls⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?cfg' = ?cfg; ?cfgs' = butlast ?cfgs; ?ls' = ?ls; ?ibT' = ?ibT; ?ibUT' = ?ibUT⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›
2. ‹⟦cfgs4 = []; is_IfJump (prog ! pcOf cfg4); mispred pstate4 [pcOf cfg4]; pstate4' = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) ≠ Fence; pstate4' = pstate4; ¬ is_getInput (prog ! pcOf (last cfgs4)); ¬ is_Output (prog ! pcOf (last cfgs4)); cfg4' = cfg4; ls4' = ls4 ∪ readLocs (last cfgs4); ∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›
4. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›
5. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›
6. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›*)
case nonspec_normal (*‹cfgs4 = []› ‹¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]› ‹pstate4' = pstate4› ‹¬ finalB (cfg4::config, ibT4::int llist, ibUT4::int llist)› ‹(cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4::config, ibT4::int llist, ibUT4::int llist)› ‹(cfgs4'::config list) = []› ‹ls4' = ls4 ∪ readLocs cfg4›*)
then show "?thesis"
(*goal: ‹Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›*)
using sa (*‹Opt.eqAct ss3 ss4›*) stat (*‹(statA::status) = (statA'::status) ∨ (statO::status) = Diff›*) "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) sr3 (*‹cfgs3 ≠ []› ‹resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹cfg3' = cfg3› ‹cfgs3' = butlast cfgs3› ‹ls3' = ls3› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3›*) unfolding ss
(*goal: ‹Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
by (simp add: Δ2_defs (*‹Δ2 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = startOfThenBranch ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = elseBranch ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ misSpecL1 cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹same_var ?x ?cfg ?cfg' ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x› ‹startOfThenBranch = 4› ‹misSpecL1 ?cfgs ≡ length ?cfgs = Suc 0› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs4 = []; is_IfJump (prog ! pcOf cfg4); mispred pstate4 [pcOf cfg4]; pstate4' = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›
2. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) ≠ Fence; pstate4' = pstate4; ¬ is_getInput (prog ! pcOf (last cfgs4)); ¬ is_Output (prog ! pcOf (last cfgs4)); cfg4' = cfg4; ls4' = ls4 ∪ readLocs (last cfgs4); ∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›
4. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›
5. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›*)
case nonspec_mispred (*‹cfgs4 = []› ‹is_IfJump (prog ! pcOf cfg4)› ‹mispred pstate4 [pcOf cfg4]› ‹pstate4' = update pstate4 [pcOf cfg4]› ‹¬ finalM (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']› ‹ls4' = ls4 ∪ readLocs cfg4›*)
then show "?thesis"
(*goal: ‹Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) stat (*‹statA = statA' ∨ statO = Diff›*) "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) sr3 (*‹cfgs3 ≠ []› ‹resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹cfg3' = cfg3› ‹cfgs3' = butlast cfgs3› ‹ls3' = ls3› ‹(ibT3'::int llist) = (ibT3::int llist)› ‹ibUT3' = ibUT3›*) unfolding ss
(*goal: ‹Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
by (simp add: Δ2_defs (*‹Δ2 = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = startOfThenBranch ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = elseBranch ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ misSpecL1 cfgs3)› ‹common_strat1 = (λ(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹same_var (?x::char list) (?cfg::config) (?cfg'::config) ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x› ‹startOfThenBranch = (4::?'a)› ‹misSpecL1 (?cfgs::config list) ≡ length ?cfgs = Suc (0::nat)› ‹elseBranch = (6::?'a)›*))
next
(*goals:
1. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); ¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) ≠ Fence; (pstate4'::predState) = pstate4; ¬ is_getInput (prog ! pcOf (last cfgs4)); ¬ is_Output (prog ! pcOf (last cfgs4)); (cfg4'::config) = cfg4; (ls4'::nat set) = (ls4::nat set) ∪ readLocs (last cfgs4); ∃cfg1'::config. nextB (last cfgs4, ibT4::int llist, ibUT4::int llist) = (cfg1', ibT4'::int llist, ibUT4'::int llist) ∧ (cfgs4'::config list) = butlast cfgs4 ## cfg1'⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
2. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); (pstate4'::predState) = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4::int llist, ibUT4::int llist); (cfg4'::config) = cfg4; ∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4'::int llist, ibUT4'::int llist) ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ (cfgs4'::config list) = butlast cfgs4 @ [lcfg'] ## cfg1'; (ls4'::nat set) = (ls4::nat set) ∪ readLocs (last cfgs4)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
3. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; (pstate4'::predState) = pstate4; (cfg4'::config) = cfg4; (cfgs4'::config list) = []; (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist); (ls4'::nat set) = (ls4::nat set)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
4. ‹⟦(cfgs4::config list) ≠ []; resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); (pstate4'::predState) = update pstate4 (pcOf cfg4 # map pcOf cfgs4); (cfg4'::config) = cfg4; (cfgs4'::config list) = butlast cfgs4; (ls4'::nat set) = (ls4::nat set); (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
case spec_normal (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹prog ! pcOf (last cfgs4) ≠ Fence› ‹pstate4' = pstate4› ‹¬ is_getInput (prog ! pcOf (last cfgs4))› ‹¬ is_Output (prog ! pcOf (last cfgs4))› ‹(cfg4'::config) = (cfg4::config)› ‹ls4' = ls4 ∪ readLocs (last cfgs4)› ‹∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'›*)
then show "?thesis"
(*goal: ‹Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) stat (*‹statA = statA' ∨ statO = Diff›*) "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) sr3 (*‹cfgs3 ≠ []› ‹resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹(cfg3'::config) = (cfg3::config)› ‹(cfgs3'::config list) = butlast (cfgs3::config list)› ‹(ls3'::nat set) = (ls3::nat set)› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3›*) unfolding ss
(*goal: ‹Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
by (simp add: Δ2_defs (*‹Δ2 = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = startOfThenBranch ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = elseBranch ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ misSpecL1 cfgs3)› ‹common_strat1 = (λ(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a::{zero,numeral,ord}..6::?'a::{zero,numeral,ord}}› ‹same_var (?x::char list) (?cfg::config) (?cfg'::config) ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x› ‹startOfThenBranch = (4::?'a::numeral)› ‹misSpecL1 (?cfgs::config list) ≡ length ?cfgs = Suc (0::nat)› ‹elseBranch = (6::?'a::numeral)›*))
next
(*goals:
1. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›
2. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›
3. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›*)
case spec_mispred (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹is_IfJump (prog ! pcOf (last cfgs4))› ‹mispred pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹¬ finalM (last cfgs4, ibT4, ibUT4)› ‹(cfg4'::config) = (cfg4::config)› ‹∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'› ‹ls4' = ls4 ∪ readLocs (last cfgs4)›*)
then show "?thesis"
(*goal: ‹Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) stat (*‹statA = statA' ∨ statO = Diff›*) "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) sr3 (*‹cfgs3 ≠ []› ‹resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹(cfg3'::config) = (cfg3::config)› ‹cfgs3' = butlast cfgs3› ‹(ls3'::nat set) = (ls3::nat set)› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3›*) unfolding ss
(*goal: ‹Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
by (simp add: Δ2_defs (*‹Δ2 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = startOfThenBranch ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = elseBranch ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ misSpecL1 cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹same_var ?x ?cfg ?cfg' ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x› ‹startOfThenBranch = 4› ‹misSpecL1 ?cfgs ≡ length ?cfgs = Suc 0› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; (pstate4'::predState) = pstate4; (cfg4'::config) = cfg4; (cfgs4'::config list) = []; (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist); (ls4'::nat set) = (ls4::nat set)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
2. ‹⟦(cfgs4::config list) ≠ []; resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); (pstate4'::predState) = update pstate4 (pcOf cfg4 # map pcOf cfgs4); (cfg4'::config) = cfg4; (cfgs4'::config list) = butlast cfgs4; (ls4'::nat set) = (ls4::nat set); (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist)⟧ ⟹ Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
case spec_Fence (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹prog ! pcOf (last cfgs4) = Fence› ‹(pstate4'::predState) = (pstate4::predState)› ‹(cfg4'::config) = (cfg4::config)› ‹cfgs4' = []› ‹ibT4' = ibT4› ‹(ibUT4'::int llist) = (ibUT4::int llist)› ‹ls4' = ls4›*)
then show "?thesis"
(*goal: ‹Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) stat (*‹statA = statA' ∨ statO = Diff›*) "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) sr3 (*‹(cfgs3::config list) ≠ []› ‹resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹cfg3' = cfg3› ‹(cfgs3'::config list) = butlast (cfgs3::config list)› ‹ls3' = ls3› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3›*) unfolding ss
(*goal: ‹Δ1 ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status)›*)
by (simp add: Δ2_defs (*‹Δ2 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = startOfThenBranch ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = elseBranch ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ misSpecL1 cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹same_var ?x ?cfg ?cfg' ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x› ‹startOfThenBranch = 4› ‹misSpecL1 ?cfgs ≡ length ?cfgs = Suc 0› ‹elseBranch = 6›*))
next
(*goal: ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ Δ1 ∞ ss3' ss4' statA' ss1 ss2 statO›*)
case spec_resolve (*‹(cfgs4::config list) ≠ []› ‹resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹(cfg4'::config) = (cfg4::config)› ‹cfgs4' = butlast cfgs4› ‹ls4' = ls4› ‹(ibT4'::int llist) = (ibT4::int llist)› ‹ibUT4' = ibUT4›*)
note sr4 = spec_resolve (*‹(cfgs4::config list) ≠ []› ‹resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹(pstate4'::predState) = update (pstate4::predState) (pcOf (cfg4::config) # map pcOf (cfgs4::config list))› ‹(cfg4'::config) = (cfg4::config)› ‹cfgs4' = butlast cfgs4› ‹ls4' = ls4› ‹ibT4' = ibT4› ‹(ibUT4'::int llist) = (ibUT4::int llist)›*)
show "?thesis"
(*goal: ‹Δ1 ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) stat (*‹(statA::status) = (statA'::status) ∨ (statO::status) = Diff›*) "Δ2" (*‹Δ2 n ss3 ss4 statA ss1 ss2 statO›*) v3 (*‹validTransO (ss3, ss3')›*) v4 (*‹validTransO (ss4, ss4')›*) sr3 (*‹(cfgs3::config list) ≠ []› ‹resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹(pstate3'::predState) = update (pstate3::predState) (pcOf (cfg3::config) # map pcOf (cfgs3::config list))› ‹cfg3' = cfg3› ‹cfgs3' = butlast cfgs3› ‹ls3' = ls3› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3›*) sr4 (*‹cfgs4 ≠ []› ‹resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹cfg4' = cfg4› ‹cfgs4' = butlast cfgs4› ‹ls4' = ls4› ‹ibT4' = ibT4› ‹ibUT4' = ibUT4›*) unfolding ss lcfgs hh
(*goal: ‹Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
apply -
(*goal: ‹Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
apply (frule Δ2_implies (*‹Δ2 ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ pcOf (last ?cfgs3.0) = 6 ∧ pcOf ?cfg3.0 = 4 ∧ pcOf (last ?cfgs4.0) = pcOf (last ?cfgs3.0) ∧ pcOf ?cfg3.0 = pcOf ?cfg4.0 ∧ length ?cfgs3.0 = Suc 0 ∧ length ?cfgs3.0 = length ?cfgs4.0›*))
(*goal: ‹⟦Opt.eqAct (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4); statA = statA' ∨ statO = Diff; Δ2 n (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO; validTransO ((pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3), pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); validTransO ((pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4), pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3; cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
apply (simp add: Δ2_defs (*‹Δ2 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = startOfThenBranch ∧ pcOf cfg1 = pcOf cfg3 ∧ pcOf (last cfgs3) = elseBranch ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ misSpecL1 cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹same_var ?x ?cfg ?cfg' ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x› ‹startOfThenBranch = 4› ‹misSpecL1 ?cfgs ≡ length ?cfgs = Suc 0› ‹elseBranch = 6›*) Δ1_defs (*‹Δ1 = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common_strat1 (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ vstore (getVstore (stateOf cfg3)) xx < int NN ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ noMisSpec cfgs3)› ‹common_strat1 = (λ(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ cfg1 = cfg3 ∧ cfg2 = cfg4 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹noMisSpec ?cfgs ≡ ?cfgs = []›*))
(*goal: ‹⟦Opt.eqAct (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4); statA = statA' ∨ statO = Diff; Δ2 n (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO; validTransO ((pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3), pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); validTransO ((pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4), pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3; cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4; pcOf (last cfgs3) = 6 ∧ pcOf cfg3 = 4 ∧ pcOf (last cfgs4) = pcOf (last cfgs3) ∧ pcOf cfg3 = pcOf cfg4 ∧ length cfgs3 = Suc 0 ∧ length cfgs3 = length cfgs4⟧ ⟹ Δ1 ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
by metis
qed
qed
qed
qed
qed
(*Playing the first strategy*)
lemma xx_le_NN[simp]:"cfg = Config pc (State (Vstore vs) avst h p) ⟹ vs xx = 0 ⟹ vs xx < int NN"
using NN (*‹0 < int NN›*) by auto
(*auxillary lemma to help delint*)
lemma match12I:"match12 (oor3 Δ1' Δ3' Δe) ss3 ss4 statA ss1 ss2 statO ⟹
(∃v<n. proact (oor3 Δ1' Δ3' Δe) v ss3 ss4 statA ss1 ss2 statO) ∨
match (oor3 Δ1' Δ3' Δe) ss3 ss4 statA ss1 ss2 statO"
apply (rule disjI2 (*‹?Q ⟹ ?P ∨ ?Q›*))
(*goal: ‹match12 (oor3 Δ1' Δ3' Δe) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status) ⟹ (∃v<n::enat. proact (oor3 Δ1' Δ3' Δe) v ss3 ss4 statA ss1 ss2 statO) ∨ match (oor3 Δ1' Δ3' Δe) ss3 ss4 statA ss1 ss2 statO›*)
unfolding match_def match1_def match2_def
(*goal: ‹match12 (oor3 Δ1' Δ3' Δe) ss3 ss4 statA ss1 ss2 statO ⟹ (¬ isIntO ss3 ⟶ (∀s1'. validTransO (ss3, s1') ⟶ ¬ isSecO ss3 ∧ oor3 Δ1' Δ3' Δe ∞ s1' ss4 statA ss1 ss2 statO ∨ eqSec ss1 ss3 ∧ ¬ isIntV ss1 ∧ match1_1 (oor3 Δ1' Δ3' Δe) ss3 s1' ss4 statA ss1 ss2 statO ∨ eqSec ss1 ss3 ∧ ¬ isSecV ss2 ∧ Van.eqAct ss1 ss2 ∧ match1_12 (oor3 Δ1' Δ3' Δe) ss3 s1' ss4 statA ss1 ss2 statO)) ∧ (¬ isIntO ss4 ⟶ (∀s2'. validTransO (ss4, s2') ⟶ ¬ isSecO ss4 ∧ oor3 Δ1' Δ3' Δe ∞ ss3 s2' statA ss1 ss2 statO ∨ eqSec ss2 ss4 ∧ ¬ isIntV ss2 ∧ match2_1 (oor3 Δ1' Δ3' Δe) ss3 ss4 s2' statA ss1 ss2 statO ∨ ¬ isSecV ss1 ∧ eqSec ss2 ss4 ∧ Van.eqAct ss1 ss2 ∧ match2_12 (oor3 Δ1' Δ3' Δe) ss3 ss4 s2' statA ss1 ss2 statO)) ∧ match12 (oor3 Δ1' Δ3' Δe) ss3 ss4 statA ss1 ss2 statO›*)
by (simp add: finalS_def (*‹finalS = final (→S)›*) final_def (*‹final (?r::?'a::type ⇒ ?'b::type ⇒ bool) (?x::?'a::type) ≡ ∀y::?'b::type. ¬ ?r ?x y›*))
(*Playing the first strategy*)
lemma step1': "unwindIntoCond Δ1' (oor3 Δ1' Δ3' Δe)"
proof (rule unwindIntoCond_simpleIB (*‹⟦⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; ?Δ w s1 s2 statA sv1 sv2 statO⟧ ⟹ finalS s1 = finalS s2 ∧ finalN sv1 = finalS s1 ∧ finalN sv2 = finalS s2; ⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; ?Δ w s1 s2 statA sv1 sv2 statO; statA = status.Eq⟧ ⟹ isIntO s1 = isIntO s2; ⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; ?Δ w s1 s2 statA sv1 sv2 statO⟧ ⟹ (∃v<w. proact ?Δ' v s1 s2 statA sv1 sv2 statO) ∨ match ?Δ' s1 s2 statA sv1 sv2 statO⟧ ⟹ unwindIntoCond ?Δ ?Δ'›*))
(*goals:
1. ‹⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δ1' w s1 s2 statA sv1 sv2 statO⟧ ⟹ finalS s1 = finalS s2 ∧ finalN sv1 = finalS s1 ∧ finalN sv2 = finalS s2›
2. ‹⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δ1' w s1 s2 statA sv1 sv2 statO; statA = status.Eq⟧ ⟹ isIntO s1 = isIntO s2›
3. ‹⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δ1' w s1 s2 statA sv1 sv2 statO⟧ ⟹ (∃v<w. proact (oor3 Δ1' Δ3' Δe) v s1 s2 statA sv1 sv2 statO) ∨ match (oor3 Δ1' Δ3' Δe) s1 s2 statA sv1 sv2 statO›*)
fix n and ss3 and ss4 and statA and ss1 and ss2 and statO
assume r: "reachO ss3" "reachO ss4" "reachV ss1" "reachV ss2" and "Δ1'": "Δ1' n ss3 ss4 statA ss1 ss2 statO" (*‹reachO (ss3::predState × config × config list × int llist × int llist × nat set)› ‹reachO (ss4::predState × config × config list × int llist × int llist × nat set)› ‹reachV (ss1::config × int llist × int llist × nat set)› ‹reachV (ss2::config × int llist × int llist × nat set)› ‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
obtain pstate3 and cfg3 and cfgs3 and ibT3 and ibUT3 and ls3 where ss3: "ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)"
(*goal: ‹(⋀(pstate3::predState) (cfg3::config) (cfgs3::config list) (ibT3::int llist) (ibUT3::int llist) ls3::nat set. (ss3::predState × config × config list × int llist × int llist × nat set) = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⟹ thesis::bool) ⟹ thesis›*)
apply (cases ss3)
(*goal: ‹(⋀pstate3 cfg3 cfgs3 ibT3 ibUT3 ls3. ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⟹ thesis) ⟹ thesis›*)
by auto
obtain pstate4 and cfg4 and cfgs4 and ibT4 and ibUT4 and ls4 where ss4: "ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)"
(*goal: ‹(⋀pstate4 cfg4 cfgs4 ibT4 ibUT4 ls4. ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) ⟹ thesis) ⟹ thesis›*)
apply (cases ss4)
(*goal: ‹(⋀pstate4 cfg4 cfgs4 ibT4 ibUT4 ls4. ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) ⟹ thesis) ⟹ thesis›*)
by auto
obtain cfg1 and ibT1 and ibUT1 and ls1 where ss1: "ss1 = (cfg1, ibT1, ibUT1, ls1)"
(*goal: ‹(⋀(cfg1::config) (ibT1::int llist) (ibUT1::int llist) ls1::nat set. (ss1::config × int llist × int llist × nat set) = (cfg1, ibT1, ibUT1, ls1) ⟹ thesis::bool) ⟹ thesis›*)
apply (cases ss1)
(*goal: ‹(⋀cfg1 ibT1 ibUT1 ls1. ss1 = (cfg1, ibT1, ibUT1, ls1) ⟹ thesis) ⟹ thesis›*)
by auto
obtain cfg2 and ibT2 and ibUT2 and ls2 where ss2: "ss2 = (cfg2, ibT2, ibUT2, ls2)"
(*goal: ‹(⋀cfg2 ibT2 ibUT2 ls2. ss2 = (cfg2, ibT2, ibUT2, ls2) ⟹ thesis) ⟹ thesis›*)
apply (cases ss2)
(*goal: ‹(⋀cfg2 ibT2 ibUT2 ls2. ss2 = (cfg2, ibT2, ibUT2, ls2) ⟹ thesis) ⟹ thesis›*)
by auto
note ss = ss3 (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*) ss4 (*‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*) ss1 (*‹ss1 = (cfg1, ibT1, ibUT1, ls1)›*) ss2 (*‹ss2 = (cfg2, ibT2, ibUT2, ls2)›*)
obtain pc1 and vs1 and avst1 and h1 and p1 where cfg1: "cfg1 = Config pc1 (State (Vstore vs1) avst1 h1 p1)"
(*goal: ‹(⋀pc1 vs1 avst1 h1 p1. cfg1 = Config pc1 (State (Vstore vs1) avst1 h1 p1) ⟹ thesis) ⟹ thesis›*)
apply (cases cfg1)
(*goal: ‹(⋀pc1 vs1 avst1 h1 p1. cfg1 = Config pc1 (State (Vstore vs1) avst1 h1 p1) ⟹ thesis) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore ?state) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore ?vstorea) = ?vstorea›*))
obtain pc2 and vs2 and avst2 and h2 and p2 where cfg2: "cfg2 = Config pc2 (State (Vstore vs2) avst2 h2 p2)"
(*goal: ‹(⋀(pc2::nat) (vs2::char list ⇒ int) (avst2::avstore) (h2::heap) p2::nat. (cfg2::config) = Config pc2 (State (Vstore vs2) avst2 h2 p2) ⟹ thesis::bool) ⟹ thesis›*)
apply (cases cfg2)
(*goal: ‹(⋀(pc2::nat) (vs2::char list ⇒ int) (avst2::avstore) (h2::heap) p2::nat. (cfg2::config) = Config pc2 (State (Vstore vs2) avst2 h2 p2) ⟹ thesis::bool) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore ?state) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore ?vstorea) = ?vstorea›*))
obtain pc3 and vs3 and avst3 and h3 and p3 where cfg3: "cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)"
(*goal: ‹(⋀pc3 vs3 avst3 h3 p3. cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ⟹ thesis) ⟹ thesis›*)
apply (cases cfg3)
(*goal: ‹(⋀pc3 vs3 avst3 h3 p3. cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ⟹ thesis) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore ?state) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore ?vstorea) = ?vstorea›*))
obtain pc4 and vs4 and avst4 and h4 and p4 where cfg4: "cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)"
(*goal: ‹(⋀pc4 vs4 avst4 h4 p4. cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ⟹ thesis) ⟹ thesis›*)
apply (cases cfg4)
(*goal: ‹(⋀pc4 vs4 avst4 h4 p4. cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ⟹ thesis) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore (?state::state)) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore (?vstorea::vstore)) = ?vstorea›*))
note cfg = cfg3 (*‹cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)›*) cfg4 (*‹(cfg4::config) = Config (pc4::nat) (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat))›*)
obtain hh1 where h1: "h1 = Heap hh1"
(*goal: ‹(⋀hh1::nat ⇒ int. (h1::heap) = Heap hh1 ⟹ thesis::bool) ⟹ thesis›*)
apply (cases h1)
(*goal: ‹(⋀hh1. h1 = Heap hh1 ⟹ thesis) ⟹ thesis›*)
by auto
obtain hh2 where h2: "h2 = Heap hh2"
(*goal: ‹(⋀hh2. h2 = Heap hh2 ⟹ thesis) ⟹ thesis›*)
apply (cases h2)
(*goal: ‹(⋀hh2::nat ⇒ int. (h2::heap) = Heap hh2 ⟹ thesis::bool) ⟹ thesis›*)
by auto
obtain hh3 where h3: "h3 = Heap hh3"
(*goal: ‹(⋀hh3. h3 = Heap hh3 ⟹ thesis) ⟹ thesis›*)
apply (cases h3)
(*goal: ‹(⋀hh3. h3 = Heap hh3 ⟹ thesis) ⟹ thesis›*)
by auto
obtain hh4 where h4: "h4 = Heap hh4"
(*goal: ‹(⋀hh4. h4 = Heap hh4 ⟹ thesis) ⟹ thesis›*)
apply (cases h4)
(*goal: ‹(⋀hh4. h4 = Heap hh4 ⟹ thesis) ⟹ thesis›*)
by auto
note hh = h3 (*‹h3 = Heap hh3›*) h4 (*‹(h4::heap) = Heap (hh4::nat ⇒ int)›*)
have f1: "¬finalN ss1"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹¬ finalN (cfg1, ibT1, ibUT1, ls1)›*)
apply -
(*goal: ‹¬ finalN (cfg1, ibT1, ibUT1, ls1)›*)
apply (frule Δ1'_implies (*‹Δ1' ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ pcOf ?cfg1.0 < 7 ∧ pcOf ?cfg1.0 ≠ Suc 0 ∧ pcOf ?cfg2.0 = pcOf ?cfg1.0 ∧ ?cfgs3.0 = [] ∧ pcOf ?cfg3.0 < 7 ∧ ?cfgs4.0 = [] ∧ pcOf ?cfg4.0 < 7›*))
(*goal: ‹Δ1' (n::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status) ⟹ ¬ finalN (cfg1, ibT1, ibUT1, ls1)›*)
unfolding finalN_iff_finalB "Δ1'_defs"
(*goal: ‹⟦(case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⇒ λ(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (n = enat (endPC - pcOf cfg1) ∨ n = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0..6} ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pcOf cfg1 ∈ {0..6} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ {2..6} ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ {4..6} ∧ pcOf cfg3 = 6) ∧ (vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = 0) ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO; pcOf cfg1 < 7 ∧ pcOf cfg1 ≠ Suc 0 ∧ pcOf cfg2 = pcOf cfg1 ∧ cfgs3 = [] ∧ pcOf cfg3 < 7 ∧ cfgs4 = [] ∧ pcOf cfg4 < 7⟧ ⟹ ¬ finalB (cfg1, ibT1, ibUT1)›*)
using finalB_pcOf_iff (*‹pcOf ?cfg ≤ 7 ⟹ finalB (?cfg, ?ibT, ?ibUT) = (pcOf ?cfg = 1 ∧ ?ibUT = [[]] ∨ pcOf ?cfg = 7)›*) by simp
have f2: "¬finalN ss2"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹¬ finalN (cfg2, ibT2, ibUT2, ls2)›*)
apply -
(*goal: ‹¬ finalN (cfg2, ibT2, ibUT2, ls2)›*)
apply (frule Δ1'_implies (*‹Δ1' (?num::enat) (?pstate3.0::predState, ?cfg3.0::config, ?cfgs3.0::config list, ?ibT3.0::int llist, ?ibUT3.0::int llist, ?ls3.0::nat set) (?pstate4.0::predState, ?cfg4.0::config, ?cfgs4.0::config list, ?ibT4.0::int llist, ?ibUT4.0::int llist, ?ls4.0::nat set) (?statA::status) (?cfg1.0::config, ?ibT1.0::int llist, ?ibUT1.0::int llist, ?ls1.0::nat set) (?cfg2.0::config, ?ibT2.0::int llist, ?ibUT2.0::int llist, ?ls2.0::nat set) (?statO::status) ⟹ pcOf ?cfg1.0 < (7::nat) ∧ pcOf ?cfg1.0 ≠ Suc (0::nat) ∧ pcOf ?cfg2.0 = pcOf ?cfg1.0 ∧ ?cfgs3.0 = [] ∧ pcOf ?cfg3.0 < (7::nat) ∧ ?cfgs4.0 = [] ∧ pcOf ?cfg4.0 < (7::nat)›*))
(*goal: ‹Δ1' n (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ ¬ finalN (cfg2, ibT2, ibUT2, ls2)›*)
unfolding finalN_iff_finalB "Δ1'_defs"
(*goal: ‹⟦(case (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. (case (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) of (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) ⇒ λ(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ ((n::enat) = enat (endPC - pcOf cfg1) ∨ n = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ {0::nat..6::nat} ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ pcOf cfg1 ∈ {0::nat..6::nat} ∧ (array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)) ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = getHheap (stateOf cfg3) ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3)) ∧ (array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = getHheap (stateOf cfg4) ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4)) ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff)) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ {2::nat..6::nat} ∧ (vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx)) ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ {4::nat..6::nat} ∧ pcOf cfg3 = (6::nat)) ∧ (vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int)) ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status); pcOf cfg1 < (7::nat) ∧ pcOf cfg1 ≠ Suc (0::nat) ∧ pcOf cfg2 = pcOf cfg1 ∧ cfgs3 = [] ∧ pcOf cfg3 < (7::nat) ∧ cfgs4 = [] ∧ pcOf cfg4 < (7::nat)⟧ ⟹ ¬ finalB (cfg2, ibT2, ibUT2)›*)
using finalB_pcOf_iff (*‹pcOf (?cfg::config) ≤ (7::nat) ⟹ finalB (?cfg, ?ibT::int llist, ?ibUT::int llist) = (pcOf ?cfg = (1::nat) ∧ ?ibUT = [[]] ∨ pcOf ?cfg = (7::nat))›*) by simp
have f3: "¬finalS ss3"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹¬ finalS (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
apply -
(*goal: ‹¬ finalS (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
apply (frule Δ1'_implies (*‹Δ1' ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ pcOf ?cfg1.0 < 7 ∧ pcOf ?cfg1.0 ≠ Suc 0 ∧ pcOf ?cfg2.0 = pcOf ?cfg1.0 ∧ ?cfgs3.0 = [] ∧ pcOf ?cfg3.0 < 7 ∧ ?cfgs4.0 = [] ∧ pcOf ?cfg4.0 < 7›*))
(*goal: ‹Δ1' n (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ⟹ ¬ finalS (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
using finalS_cond (*‹⟦pcOf ?cfg < 7; ?cfgs = []; pcOf ?cfg = 1 ⟶ ?ibUT ≠ [[]]⟧ ⟹ ¬ finalS (?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls)›*) by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
have f4: "¬finalS ss4"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹¬ finalS (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply -
(*goal: ‹¬ finalS (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set)›*)
apply (frule Δ1'_implies (*‹Δ1' ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ pcOf ?cfg1.0 < 7 ∧ pcOf ?cfg1.0 ≠ Suc 0 ∧ pcOf ?cfg2.0 = pcOf ?cfg1.0 ∧ ?cfgs3.0 = [] ∧ pcOf ?cfg3.0 < 7 ∧ ?cfgs4.0 = [] ∧ pcOf ?cfg4.0 < 7›*))
(*goal: ‹Δ1' (n::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) (statO::status) ⟹ ¬ finalS (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
using finalS_cond (*‹⟦pcOf (?cfg::config) < (7::nat); (?cfgs::config list) = []; pcOf ?cfg = (1::nat) ⟶ (?ibUT::int llist) ≠ [[]]⟧ ⟹ ¬ finalS (?pstate::predState, ?cfg, ?cfgs, ?ibT::int llist, ?ibUT, ?ls::nat set)›*) by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
note finals = f1 (*‹¬ finalN ss1›*) f2 (*‹¬ finalN ss2›*) f3 (*‹¬ finalS ss3›*) f4 (*‹¬ finalS ss4›*)
show "finalS ss3 = finalS ss4 ∧ finalN ss1 = finalS ss3 ∧ finalN ss2 = finalS ss4"
using finals (*‹¬ finalN ss1› ‹¬ finalN ss2› ‹¬ finalS ss3› ‹¬ finalS ss4›*) by auto
then show "isIntO ss3 = isIntO ss4"
by simp
show "(∃v<n. proact (oor3 Δ1' Δ3' Δe) v ss3 ss4 statA ss1 ss2 statO) ∨
match (oor3 Δ1' Δ3' Δe) ss3 ss4 statA ss1 ss2 statO"
using cases_6[of "pcOf cfg1"] (*‹pcOf cfg1 = 0 ∨ pcOf cfg1 = 1 ∨ pcOf cfg1 = 2 ∨ pcOf cfg1 = 3 ∨ pcOf cfg1 = 4 ∨ pcOf cfg1 = 5 ∨ pcOf cfg1 = 6 ∨ 6 < pcOf cfg1›*) apply (elim disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹(∃v<n. proact (oor3 Δ1' Δ3' Δe) v ss3 ss4 statA ss1 ss2 statO) ∨ match (oor3 Δ1' Δ3' Δe) ss3 ss4 statA ss1 ss2 statO›*)
subgoal for
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹pcOf cfg1 = 0 ⟹ (∃v<n. proact (oor3 Δ1' Δ3' Δe) v (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO) ∨ match (oor3 Δ1' Δ3' Δe) (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
(*goal: ‹pcOf cfg1 = 0 ⟹ (∃v<n. proact (oor3 Δ1' Δ3' Δe) v (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO) ∨ match (oor3 Δ1' Δ3' Δe) (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
by linarith
subgoal for
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹pcOf cfg1 = 1 ⟹ (∃v<n. proact (oor3 Δ1' Δ3' Δe) v (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO) ∨ match (oor3 Δ1' Δ3' Δe) (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
(*goal: ‹pcOf cfg1 = 1 ⟹ (∃v<n. proact (oor3 Δ1' Δ3' Δe) v (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO) ∨ match (oor3 Δ1' Δ3' Δe) (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
by linarith
subgoal for
proof (rule match12I (*‹match12 (oor3 Δ1' Δ3' Δe) ?ss3.0 ?ss4.0 ?statA ?ss1.0 ?ss2.0 ?statO ⟹ (∃v<?n. proact (oor3 Δ1' Δ3' Δe) v ?ss3.0 ?ss4.0 ?statA ?ss1.0 ?ss2.0 ?statO) ∨ match (oor3 Δ1' Δ3' Δe) ?ss3.0 ?ss4.0 ?statA ?ss1.0 ?ss2.0 ?statO›*), rule match12_simpleI (*‹(⋀(s1'::predState × config × config list × int llist × int llist × nat set) (s2'::predState × config × config list × int llist × int llist × nat set) statA'::status. ⟦statA' = sstatA' (?statA::status) (?s1.0::predState × config × config list × int llist × int llist × nat set) (?s2.0::predState × config × config list × int llist × int llist × nat set); validTransO (?s1.0, s1'); validTransO (?s2.0, s2'); Opt.eqAct ?s1.0 ?s2.0⟧ ⟹ ¬ isSecO ?s1.0 ∧ ¬ isSecO ?s2.0 ∧ (?statA = statA' ∨ (?statO::status) = Diff) ∧ (?Δ::?'a ⇒ predState × config × config list × int llist × int llist × nat set ⇒ predState × config × config list × int llist × int llist × nat set ⇒ status ⇒ config × int llist × int llist × nat set ⇒ config × int llist × int llist × nat set ⇒ status ⇒ bool) ∞ s1' s2' statA' (?sv1.0::config × int llist × int llist × nat set) (?sv2.0::config × int llist × int llist × nat set) ?statO ∨ eqSec ?sv1.0 ?s1.0 ∧ eqSec ?sv2.0 ?s2.0 ∧ Van.eqAct ?sv1.0 ?sv2.0 ∧ match12_12 ?Δ s1' s2' statA' ?sv1.0 ?sv2.0 ?statO) ⟹ match12 ?Δ ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*), rule disjI2 (*‹?Q ⟹ ?P ∨ ?Q›*), intro conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⋀s1' s2' statA'. ⟦pcOf cfg1 = 2; statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ eqSec ss1 ss3›
2. ‹⋀s1' s2' statA'. ⟦pcOf cfg1 = 2; statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ eqSec ss2 ss4›
3. ‹⋀s1' s2' statA'. ⟦pcOf cfg1 = 2; statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ Van.eqAct ss1 ss2›
4. ‹⋀s1' s2' statA'. ⟦pcOf cfg1 = 2; statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ match12_12 (oor3 Δ1' Δ3' Δe) s1' s2' statA' ss1 ss2 statO›*)
fix ss3' and ss4' and statA'
assume statA': "statA' = sstatA' statA ss3 ss4" and v: "validTransO (ss3, ss3')" "validTransO (ss4, ss4')" and sa: "Opt.eqAct ss3 ss4" and pc: "pcOf cfg1 = 2" (*‹(statA'::status) = sstatA' (statA::status) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss3::predState × config × config list × int llist × int llist × nat set, ss3'::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)› ‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)› ‹pcOf (cfg1::config) = (2::nat)›*)
note v3 = v(1) (*‹validTransO (ss3::predState × config × config list × int llist × int llist × nat set, ss3'::predState × config × config list × int llist × int llist × nat set)›*)
note v4 = v(2) (*‹validTransO (ss4, ss4')›*)
obtain pstate3' and cfg3' and cfgs3' and ibT3' and ibUT3' and ls3' where ss3': "ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')"
(*goal: ‹(⋀(pstate3'::predState) (cfg3'::config) (cfgs3'::config list) (ibT3'::int llist) (ibUT3'::int llist) ls3'::nat set. (ss3'::predState × config × config list × int llist × int llist × nat set) = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') ⟹ thesis::bool) ⟹ thesis›*)
apply (cases ss3')
(*goal: ‹(⋀pstate3' cfg3' cfgs3' ibT3' ibUT3' ls3'. ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') ⟹ thesis) ⟹ thesis›*)
by auto
obtain pstate4' and cfg4' and cfgs4' and ibT4' and ibUT4' and ls4' where ss4': "ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')"
(*goal: ‹(⋀pstate4' cfg4' cfgs4' ibT4' ibUT4' ls4'. ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') ⟹ thesis) ⟹ thesis›*)
apply (cases ss4')
(*goal: ‹(⋀pstate4' cfg4' cfgs4' ibT4' ibUT4' ls4'. ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') ⟹ thesis) ⟹ thesis›*)
by auto
note ss = ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹(ss4::predState × config × config list × int llist × int llist × nat set) = (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set)› ‹ss1 = (cfg1, ibT1, ibUT1, ls1)› ‹ss2 = (cfg2, ibT2, ibUT2, ls2)›*) ss3' (*‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')›*) ss4' (*‹ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*)
show "eqSec ss1 ss3"
using v (*‹validTransO (ss3::predState × config × config list × int llist × int llist × nat set, ss3'::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹eqSec (cfg1, ibT1, ibUT1, ls1) (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
(*goal: ‹eqSec (cfg1, ibT1, ibUT1, ls1) (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
by (metis not_gr_zero (*‹(¬ 0 < ?n) = (?n = 0)›*) not_numeral_le_zero (*‹¬ numeral ?n ≤ 0›*) zero_less_numeral (*‹0 < numeral ?n›*))
show "eqSec ss2 ss4"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)›*) sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹eqSec (cfg2, ibT2, ibUT2, ls2) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
(*goal: ‹eqSec (cfg2, ibT2, ibUT2, ls2) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
by (metis not_gr_zero (*‹(¬ 0 < ?n) = (?n = 0)›*) not_numeral_le_zero (*‹¬ numeral ?n ≤ 0›*) zero_neq_numeral (*‹0 ≠ numeral ?n›*))
show "Van.eqAct ss1 ss2"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss Van.eqAct_def
(*goal: ‹isIntV (cfg1, ibT1, ibUT1, ls1) = isIntV (cfg2, ibT2, ibUT2, ls2) ∧ (isIntV (cfg1, ibT1, ibUT1, ls1) ⟶ getActV (cfg1, ibT1, ibUT1, ls1) = getActV (cfg2, ibT2, ibUT2, ls2))›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
(*goal: ‹isIntV (cfg1, ibT1, ibUT1, ls1) = isIntV (cfg2, ibT2, ibUT2, ls2) ∧ (isIntV (cfg1, ibT1, ibUT1, ls1) ⟶ getActV (cfg1, ibT1, ibUT1, ls1) = getActV (cfg2, ibT2, ibUT2, ls2))›*)
by (metis Δ1' (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) Δ1'_implies (*‹Δ1' ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ pcOf ?cfg1.0 < 7 ∧ pcOf ?cfg1.0 ≠ Suc 0 ∧ pcOf ?cfg2.0 = pcOf ?cfg1.0 ∧ ?cfgs3.0 = [] ∧ pcOf ?cfg3.0 < 7 ∧ ?cfgs4.0 = [] ∧ pcOf ?cfg4.0 < 7›*) ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)› ‹ss1 = (cfg1, ibT1, ibUT1, ls1)› ‹ss2 = (cfg2, ibT2, ibUT2, ls2)› ‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')› ‹ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*))
show "match12_12 (oor3 Δ1' Δ3' Δe) ss3' ss4' statA' ss1 ss2 statO"
unfolding match12_12_def
(*goal: ‹∃sv1' sv2'. let statO' = sstatO' statO ss1 ss2 in validTransV (ss1, sv1') ∧ validTransV (ss2, sv2') ∧ (statA' = Diff ⟶ statO' = Diff) ∧ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' sv1' sv2' statO'›*)
proof (rule exI[of _ "nextN ss1"] (*‹?P (nextN ss1) ⟹ ∃x. ?P x›*), rule exI[of _ "nextN ss2"] (*‹?P (nextN ss2) ⟹ ∃x. ?P x›*), unfold Let_def (*‹Let ?s ?f ≡ ?f ?s›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goals:
1. ‹validTransV (ss1, nextN ss1)›
2. ‹validTransV (ss2, nextN ss2)›
3. ‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›
4. ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
show "validTransV (ss1, nextN ss1)"
by (simp add: f1 (*‹¬ finalN ss1›*) nextN_stepN (*‹¬ finalN ?cfg_ib_ls ⟹ ?cfg_ib_ls →N nextN ?cfg_ib_ls›*))
show "validTransV (ss2, nextN ss2)"
by (simp add: f2 (*‹¬ finalN (ss2::config × int llist × int llist × nat set)›*) nextN_stepN (*‹¬ finalN (?cfg_ib_ls::config × int llist × int llist × nat set) ⟹ ?cfg_ib_ls →N nextN ?cfg_ib_ls›*))
have cfgs4: "cfgs4 = []"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss "Δ1'_defs"
(*goal: ‹(cfgs4::config list) = []›*)
apply clarify
(*goal: ‹cfgs4 = []›*)
by (metis list.map_disc_iff (*‹(map ?f ?a = []) = (?a = [])›*))
have notJump: "¬is_IfJump (prog ! pcOf cfg3)"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf cfg1 = 2›*) unfolding ss "Δ1'_defs"
(*goal: ‹¬ is_IfJump (prog ! pcOf cfg3)›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*) sstatO'_def (*‹sstatO' ?statO ?sv1.0 ?sv2.0 = updStat ?statO (isIntV ?sv1.0, getObsV ?sv1.0) (isIntV ?sv2.0, getObsV ?sv2.0)›*) sstatA'_def (*‹sstatA' ?statA ?s1.0 ?s2.0 = updStat ?statA (isIntO ?s1.0, getObsO ?s1.0) (isIntO ?s2.0, getObsO ?s2.0)›*))
{
assume sstat: "statA' = Diff" (*‹(statA'::status) = Diff›*)
show "sstatO' statO ss1 ss2 = Diff"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)›*) sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) sstat (*‹statA' = Diff›*) pc (*‹pcOf (cfg1::config) = (2::nat)›*) unfolding ss cfg statA'
(*goal: ‹sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*) sstatO'_def (*‹sstatO' (?statO::status) (?sv1.0::config × int llist × int llist × nat set) (?sv2.0::config × int llist × int llist × nat set) = updStat ?statO (isIntV ?sv1.0, getObsV ?sv1.0) (isIntV ?sv2.0, getObsV ?sv2.0)›*) sstatA'_def (*‹sstatA' (?statA::status) (?s1.0::predState × config × config list × int llist × int llist × nat set) (?s2.0::predState × config × config list × int llist × int llist × nat set) = updStat ?statA (isIntO ?s1.0, getObsO ?s1.0) (isIntO ?s2.0, getObsO ?s2.0)›*))
(*goal: ‹sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff›*)
apply (cases statO, simp_all)
(*goal: ‹⟦(pstate3'::predState) = (pstate4::predState) ∧ (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (Config (pc4::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)), ibT3::int llist, ibUT3::int llist) ∧ (cfgs3'::config list) = [] ∧ (ls3'::nat set) = (ls4::nat set) ∪ readLocs (Config pc4 (State (Vstore vs3) avst3 h3 p3)); (pstate4, Config pc4 (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls4) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); (pstate3::predState) = pstate4 ∧ ((n::enat) = enat (5::nat) ∨ n = ∞) ∧ pcOf (cfg2::config) = (2::nat) ∧ (pc3::nat) = pc4 ∧ map pcOf (cfgs3::config list) = map pcOf cfgs4 ∧ pc3 ≤ (6::nat) ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ array_base aa1 (getAvstore (stateOf (cfg1::config))) = array_base aa1 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = hheap h3 ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ ((statA::status) = Diff ⟶ (statO::status) = Diff) ∧ (2::nat) ≤ pc3 ∧ pc3 ≤ (6::nat) ∧ vs3 xx = vs4 xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ int NN ≤ vs3 xx ∧ pc3 = (2::nat) ∧ (ls1::nat set) = {} ∧ (ls2::nat set) = {} ∧ ls1 = (ls3::nat set) ∧ ls2 = ls4 ∧ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4 ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls4), ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), ⊥) = Diff; pcOf cfg1 = (2::nat)⟧ ⟹ updStat statO (True, ⊥) (True, ⊥) = Diff›*)
apply (cases statA, simp_all)
(*goal: ‹⟦pstate3' = pstate4 ∧ (cfg3', ibT3', ibUT3') = nextB (Config pc4 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3) ∧ cfgs3' = [] ∧ ls3' = ls4 ∪ readLocs (Config pc4 (State (Vstore vs3) avst3 h3 p3)); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls4) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ (n = enat 5 ∨ n = ∞) ∧ pcOf cfg2 = 2 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = hheap h3 ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ statA ≠ Diff ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ int NN ≤ vs3 xx ∧ pc3 = 2 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4 ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls4), ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), ⊥) = Diff; pcOf cfg1 = 2; statO = status.Eq⟧ ⟹ False›*)
using cfg (*‹cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)› ‹(cfg4::config) = Config (pc4::nat) (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat))›*) finals (*‹¬ finalN ss1› ‹¬ finalN ss2› ‹¬ finalS ss3› ‹¬ finalS ss4›*) ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)› ‹ss1 = (cfg1, ibT1, ibUT1, ls1)› ‹ss2 = (cfg2, ibT2, ibUT2, ls2)› ‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')› ‹(ss4'::predState × config × config list × int llist × int llist × nat set) = (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set)›*) by simp
}
note stat = this (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*)
have pc4: "pc4 = 2"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf (cfg1::config) = (2::nat)›*) unfolding ss cfg
(*goal: ‹pc4 = 2›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*))
show "(oor3 Δ1' Δ3' Δe) ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)"
using v3[unfolded ss, simplified] (*‹(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) →S (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set)›*) proof (cases rule: stepS_cases (*‹⟦(?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls) →S (?pstate', ?cfg', ?cfgs', ?ibT', ?ibUT', ?ls'); ⟦?cfgs = []; ¬ is_IfJump (prog ! pcOf ?cfg) ∨ ¬ mispred ?pstate [pcOf ?cfg]; ?pstate' = ?pstate; ¬ finalB (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ?cfgs' = []; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs = []; is_IfJump (prog ! pcOf ?cfg); mispred ?pstate [pcOf ?cfg]; ?pstate' = update ?pstate [pcOf ?cfg]; ¬ finalM (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (?cfg, ?ibT, ?ibUT) ∧ ?cfgs' = [cfg1']; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ is_IfJump (prog ! pcOf (last ?cfgs)) ∨ ¬ mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) ≠ Fence; ?pstate' = ?pstate; ¬ is_getInput (prog ! pcOf (last ?cfgs)); ¬ is_Output (prog ! pcOf (last ?cfgs)); ?cfg' = ?cfg; ?ls' = ?ls ∪ readLocs (last ?cfgs); ∃cfg1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (cfg1', ?ibT', ?ibUT') ∧ ?cfgs' = butlast ?cfgs ## cfg1'⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); is_IfJump (prog ! pcOf (last ?cfgs)); mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ finalM (last ?cfgs, ?ibT, ?ibUT); ?cfg' = ?cfg; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (lcfg', ?ibT', ?ibUT') ∧ (cfg1', ibT1', ibUT1') = nextM (last ?cfgs, ?ibT, ?ibUT) ∧ ?cfgs' = butlast ?cfgs @ [lcfg'] ## cfg1'; ?ls' = ?ls ∪ readLocs (last ?cfgs)⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) = Fence; ?pstate' = ?pstate; ?cfg' = ?cfg; ?cfgs' = []; ?ibT' = ?ibT; ?ibUT' = ?ibUT; ?ls' = ?ls⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?cfg' = ?cfg; ?cfgs' = butlast ?cfgs; ?ls' = ?ls; ?ibT' = ?ibT; ?ibUT' = ?ibUT⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) ≠ Fence; pstate3' = pstate3; ¬ is_getInput (prog ! pcOf (last cfgs3)); ¬ is_Output (prog ! pcOf (last cfgs3)); cfg3' = cfg3; ls3' = ls3 ∪ readLocs (last cfgs3); ∃cfg1'. nextB (last cfgs3, ibT3, ibUT3) = (cfg1', ibT3', ibUT3') ∧ cfgs3' = butlast cfgs3 ## cfg1'⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3, ibUT3); cfg3' = cfg3; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'; ls3' = ls3 ∪ readLocs (last cfgs3)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
6. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_normal (*‹(cfgs3::config list) ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹prog ! pcOf (last cfgs3) ≠ Fence› ‹pstate3' = pstate3› ‹¬ is_getInput (prog ! pcOf (last cfgs3))› ‹¬ is_Output (prog ! pcOf (last cfgs3))› ‹cfg3' = cfg3› ‹ls3' = ls3 ∪ readLocs (last cfgs3)› ‹∃cfg1'. nextB (last cfgs3, ibT3, ibUT3) = (cfg1', ibT3', ibUT3') ∧ cfgs3' = butlast cfgs3 ## cfg1'›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3, ibUT3); cfg3' = cfg3; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'; ls3' = ls3 ∪ readLocs (last cfgs3)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_mispred (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹is_IfJump (prog ! pcOf (last (cfgs3::config list)))› ‹mispred pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹¬ finalM (last cfgs3, ibT3, ibUT3)› ‹cfg3' = cfg3› ‹∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'› ‹ls3' = ls3 ∪ readLocs (last cfgs3)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_Fence (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹prog ! pcOf (last cfgs3) = Fence› ‹pstate3' = pstate3› ‹cfg3' = cfg3› ‹(cfgs3'::config list) = []› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3› ‹(ls3'::nat set) = (ls3::nat set)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_resolve (*‹cfgs3 ≠ []› ‹resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹cfg3' = cfg3› ‹cfgs3' = butlast cfgs3› ‹ls3' = ls3› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹(statA'::status) = Diff ⟹ sstatO' (statO::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a::{zero,numeral,ord}..6::?'a::{zero,numeral,ord}}› ‹afterInput = {2::?'a::{numeral,ord}..6::?'a::{numeral,ord}}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a::{numeral,ord}..6::?'a::{numeral,ord}}› ‹elseBranch = (6::?'a::numeral)›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_mispred (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred (pstate3::predState) [pcOf (cfg3::config)]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using notJump (*‹¬ is_IfJump (prog ! pcOf (cfg3::config))›*) by auto
next
(*goal: ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_normal (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*)
note nn3 = nonspec_normal (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*)
show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
using v4[unfolded ss, simplified] (*‹(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set)›*) proof (cases rule: stepS_cases (*‹⟦(?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls) →S (?pstate', ?cfg', ?cfgs', ?ibT', ?ibUT', ?ls'); ⟦?cfgs = []; ¬ is_IfJump (prog ! pcOf ?cfg) ∨ ¬ mispred ?pstate [pcOf ?cfg]; ?pstate' = ?pstate; ¬ finalB (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ?cfgs' = []; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs = []; is_IfJump (prog ! pcOf ?cfg); mispred ?pstate [pcOf ?cfg]; ?pstate' = update ?pstate [pcOf ?cfg]; ¬ finalM (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (?cfg, ?ibT, ?ibUT) ∧ ?cfgs' = [cfg1']; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ is_IfJump (prog ! pcOf (last ?cfgs)) ∨ ¬ mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) ≠ Fence; ?pstate' = ?pstate; ¬ is_getInput (prog ! pcOf (last ?cfgs)); ¬ is_Output (prog ! pcOf (last ?cfgs)); ?cfg' = ?cfg; ?ls' = ?ls ∪ readLocs (last ?cfgs); ∃cfg1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (cfg1', ?ibT', ?ibUT') ∧ ?cfgs' = butlast ?cfgs ## cfg1'⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); is_IfJump (prog ! pcOf (last ?cfgs)); mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ finalM (last ?cfgs, ?ibT, ?ibUT); ?cfg' = ?cfg; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (lcfg', ?ibT', ?ibUT') ∧ (cfg1', ibT1', ibUT1') = nextM (last ?cfgs, ?ibT, ?ibUT) ∧ ?cfgs' = butlast ?cfgs @ [lcfg'] ## cfg1'; ?ls' = ?ls ∪ readLocs (last ?cfgs)⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) = Fence; ?pstate' = ?pstate; ?cfg' = ?cfg; ?cfgs' = []; ?ibT' = ?ibT; ?ibUT' = ?ibUT; ?ls' = ?ls⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?cfg' = ?cfg; ?cfgs' = butlast ?cfgs; ?ls' = ?ls; ?ibT' = ?ibT; ?ibUT' = ?ibUT⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 = []; is_IfJump (prog ! pcOf cfg4); mispred pstate4 [pcOf cfg4]; pstate4' = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) ≠ Fence; pstate4' = pstate4; ¬ is_getInput (prog ! pcOf (last cfgs4)); ¬ is_Output (prog ! pcOf (last cfgs4)); cfg4' = cfg4; ls4' = ls4 ∪ readLocs (last cfgs4); ∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
6. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_mispred (*‹cfgs4 = []› ‹is_IfJump (prog ! pcOf cfg4)› ‹mispred pstate4 [pcOf cfg4]› ‹pstate4' = update pstate4 [pcOf cfg4]› ‹¬ finalM (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']› ‹ls4' = ls4 ∪ readLocs cfg4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) ≠ Fence; pstate4' = pstate4; ¬ is_getInput (prog ! pcOf (last cfgs4)); ¬ is_Output (prog ! pcOf (last cfgs4)); cfg4' = cfg4; ls4' = ls4 ∪ readLocs (last cfgs4); ∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_normal (*‹cfgs4 ≠ []› ‹¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf (cfgs4::config list))› ‹¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹prog ! pcOf (last (cfgs4::config list)) ≠ Fence› ‹pstate4' = pstate4› ‹¬ is_getInput (prog ! pcOf (last cfgs4))› ‹¬ is_Output (prog ! pcOf (last cfgs4))› ‹cfg4' = cfg4› ‹ls4' = ls4 ∪ readLocs (last cfgs4)› ‹∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹(pstate3'::predState) = (pstate3::predState)› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦(cfgs4::config list) = []; ¬ is_IfJump (prog ! pcOf (cfg4::config)) ∨ ¬ mispred (pstate4::predState) [pcOf cfg4]; (pstate4'::predState) = pstate4; ¬ finalB (cfg4, ibT4::int llist, ibUT4::int llist); (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4, ibT4, ibUT4); (cfgs4'::config list) = []; (ls4'::nat set) = (ls4::nat set) ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
2. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); (pstate4'::predState) = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4::int llist, ibUT4::int llist); (cfg4'::config) = cfg4; ∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4'::int llist, ibUT4'::int llist) ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ (cfgs4'::config list) = butlast cfgs4 @ [lcfg'] ## cfg1'; (ls4'::nat set) = (ls4::nat set) ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
3. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; (pstate4'::predState) = pstate4; (cfg4'::config) = cfg4; (cfgs4'::config list) = []; (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist); (ls4'::nat set) = (ls4::nat set)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
4. ‹⟦(cfgs4::config list) ≠ []; resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); (pstate4'::predState) = update pstate4 (pcOf cfg4 # map pcOf cfgs4); (cfg4'::config) = cfg4; (cfgs4'::config list) = butlast cfgs4; (ls4'::nat set) = (ls4::nat set); (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
case spec_mispred (*‹(cfgs4::config list) ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹is_IfJump (prog ! pcOf (last cfgs4))› ‹mispred (pstate4::predState) (pcOf (cfg4::config) # map pcOf (cfgs4::config list))› ‹pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹¬ finalM (last (cfgs4::config list), ibT4::int llist, ibUT4::int llist)› ‹cfg4' = cfg4› ‹∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'› ‹ls4' = ls4 ∪ readLocs (last cfgs4)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_Fence (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹prog ! pcOf (last cfgs4) = Fence› ‹pstate4' = pstate4› ‹cfg4' = cfg4› ‹cfgs4' = []› ‹(ibT4'::int llist) = (ibT4::int llist)› ‹ibUT4' = ibUT4› ‹(ls4'::nat set) = (ls4::nat set)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹(pstate3'::predState) = (pstate3::predState)› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹cfgs3' = []› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (cfg3::config)›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_resolve (*‹cfgs4 ≠ []› ‹resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf (cfgs4::config list))› ‹pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹cfg4' = cfg4› ‹(cfgs4'::config list) = butlast (cfgs4::config list)› ‹ls4' = ls4› ‹ibT4' = ibT4› ‹(ibUT4'::int llist) = (ibUT4::int llist)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹(statA'::status) = Diff ⟹ sstatO' (statO::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (nextN (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)) (nextN (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)) (sstatO' (statO::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*))
next
(*goal: ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_normal (*‹cfgs4 = []› ‹¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]› ‹pstate4' = pstate4› ‹¬ finalB (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹cfgs4' = []› ‹(ls4'::nat set) = (ls4::nat set) ∪ readLocs (cfg4::config)›*)
note nn4 = nonspec_normal (*‹cfgs4 = []› ‹¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]› ‹pstate4' = pstate4› ‹¬ finalB (cfg4, ibT4, ibUT4)› ‹(cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4::config, ibT4::int llist, ibUT4::int llist)› ‹cfgs4' = []› ‹ls4' = ls4 ∪ readLocs cfg4›*)
show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
apply (rule oor3I1 (*‹?Δ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO ⟹ oor3 ?Δ ?Δ₂ ?Δ₃ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) pc (*‹pcOf cfg1 = 2›*) pc4 (*‹pc4 = 2›*) v3 (*‹validTransO (ss3::predState × config × config list × int llist × int llist × nat set, ss3'::predState × config × config list × int llist × int llist × nat set)›*) v4 (*‹validTransO (ss4, ss4')›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹(cfgs3'::config list) = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) config.sel(2) (*‹stateOf (Config ?x1.0 ?x2.0) = ?x2.0›*) state.sel(2) (*‹getAvstore (State (?x1.0::vstore) (?x2.0::avstore) (?x3.0::heap) (?x4.0::nat)) = ?x2.0›*) unfolding ss cfg cfg1 cfg2 hh
(*goal: ‹Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1)) (nextN (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2)) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
apply (simp add:Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
(*goal: ‹Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1)) (nextN (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2)) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
using numeral_le_iff (*‹(numeral ?m ≤ numeral ?n) = (?m ≤ ?n)›*) semiring_norm(69,72) (*‹(num.Bit0 ?m ≤ num.One) = False› ‹(num.Bit0 ?m ≤ num.Bit1 ?n) = (?m ≤ ?n)›*) by force
qed
qed
qed
qed
subgoal for
proof (rule match12I (*‹match12 (oor3 Δ1' Δ3' Δe) ?ss3.0 ?ss4.0 ?statA ?ss1.0 ?ss2.0 ?statO ⟹ (∃v<?n. proact (oor3 Δ1' Δ3' Δe) v ?ss3.0 ?ss4.0 ?statA ?ss1.0 ?ss2.0 ?statO) ∨ match (oor3 Δ1' Δ3' Δe) ?ss3.0 ?ss4.0 ?statA ?ss1.0 ?ss2.0 ?statO›*), rule match12_simpleI (*‹(⋀s1' s2' statA'. ⟦statA' = sstatA' ?statA ?s1.0 ?s2.0; validTransO (?s1.0, s1'); validTransO (?s2.0, s2'); Opt.eqAct ?s1.0 ?s2.0⟧ ⟹ ¬ isSecO ?s1.0 ∧ ¬ isSecO ?s2.0 ∧ (?statA = statA' ∨ ?statO = Diff) ∧ ?Δ ∞ s1' s2' statA' ?sv1.0 ?sv2.0 ?statO ∨ eqSec ?sv1.0 ?s1.0 ∧ eqSec ?sv2.0 ?s2.0 ∧ Van.eqAct ?sv1.0 ?sv2.0 ∧ match12_12 ?Δ s1' s2' statA' ?sv1.0 ?sv2.0 ?statO) ⟹ match12 ?Δ ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*), rule disjI2 (*‹?Q ⟹ ?P ∨ ?Q›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⋀s1' s2' statA'. ⟦pcOf cfg1 = 3; statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ eqSec ss1 ss3›
2. ‹⋀s1' s2' statA'. ⟦pcOf cfg1 = 3; statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ eqSec ss2 ss4›
3. ‹⋀s1' s2' statA'. ⟦pcOf cfg1 = 3; statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ Van.eqAct ss1 ss2›
4. ‹⋀s1' s2' statA'. ⟦pcOf cfg1 = 3; statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ match12_12 (oor3 Δ1' Δ3' Δe) s1' s2' statA' ss1 ss2 statO›*)
fix ss3' and ss4' and statA'
assume statA': "statA' = sstatA' statA ss3 ss4" and v: "validTransO (ss3, ss3')" "validTransO (ss4, ss4')" and sa: "Opt.eqAct ss3 ss4" and pc: "pcOf cfg1 = 3" (*‹(statA'::status) = sstatA' (statA::status) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss3::predState × config × config list × int llist × int llist × nat set, ss3'::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)› ‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)› ‹pcOf (cfg1::config) = (3::nat)›*)
note v3 = v(1) (*‹validTransO (ss3, ss3')›*)
note v4 = v(2) (*‹validTransO (ss4, ss4')›*)
obtain pstate3' and cfg3' and cfgs3' and ibT3' and ibUT3' and ls3' where ss3': "ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')"
(*goal: ‹(⋀pstate3' cfg3' cfgs3' ibT3' ibUT3' ls3'. ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') ⟹ thesis) ⟹ thesis›*)
apply (cases ss3')
(*goal: ‹(⋀pstate3' cfg3' cfgs3' ibT3' ibUT3' ls3'. ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') ⟹ thesis) ⟹ thesis›*)
by auto
obtain pstate4' and cfg4' and cfgs4' and ibT4' and ibUT4' and ls4' where ss4': "ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')"
(*goal: ‹(⋀(pstate4'::predState) (cfg4'::config) (cfgs4'::config list) (ibT4'::int llist) (ibUT4'::int llist) ls4'::nat set. (ss4'::predState × config × config list × int llist × int llist × nat set) = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') ⟹ thesis::bool) ⟹ thesis›*)
apply (cases ss4')
(*goal: ‹(⋀(pstate4'::predState) (cfg4'::config) (cfgs4'::config list) (ibT4'::int llist) (ibUT4'::int llist) ls4'::nat set. (ss4'::predState × config × config list × int llist × int llist × nat set) = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') ⟹ thesis::bool) ⟹ thesis›*)
by auto
note ss = ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)› ‹ss1 = (cfg1, ibT1, ibUT1, ls1)› ‹ss2 = (cfg2, ibT2, ibUT2, ls2)›*) ss3' (*‹(ss3'::predState × config × config list × int llist × int llist × nat set) = (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set)›*) ss4' (*‹ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*)
show "eqSec ss1 ss3"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹eqSec (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set)›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
(*goal: ‹eqSec (cfg1, ibT1, ibUT1, ls1) (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
by (metis not_gr_zero (*‹(¬ 0 < ?n) = (?n = 0)›*) not_numeral_le_zero (*‹¬ numeral ?n ≤ 0›*) zero_less_numeral (*‹0 < numeral ?n›*))
show "eqSec ss2 ss4"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹eqSec (cfg2, ibT2, ibUT2, ls2) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
(*goal: ‹eqSec (cfg2, ibT2, ibUT2, ls2) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
by (metis not_gr_zero (*‹(¬ 0 < ?n) = (?n = 0)›*) not_numeral_le_zero (*‹¬ numeral ?n ≤ 0›*) zero_neq_numeral (*‹0 ≠ numeral ?n›*))
show "Van.eqAct ss1 ss2"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss Van.eqAct_def
(*goal: ‹isIntV (cfg1, ibT1, ibUT1, ls1) = isIntV (cfg2, ibT2, ibUT2, ls2) ∧ (isIntV (cfg1, ibT1, ibUT1, ls1) ⟶ getActV (cfg1, ibT1, ibUT1, ls1) = getActV (cfg2, ibT2, ibUT2, ls2))›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
(*goal: ‹isIntV (cfg1, ibT1, ibUT1, ls1) = isIntV (cfg2, ibT2, ibUT2, ls2) ∧ (isIntV (cfg1, ibT1, ibUT1, ls1) ⟶ getActV (cfg1, ibT1, ibUT1, ls1) = getActV (cfg2, ibT2, ibUT2, ls2))›*)
by (metis Δ1' (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) Δ1'_implies (*‹Δ1' ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ pcOf ?cfg1.0 < 7 ∧ pcOf ?cfg1.0 ≠ Suc 0 ∧ pcOf ?cfg2.0 = pcOf ?cfg1.0 ∧ ?cfgs3.0 = [] ∧ pcOf ?cfg3.0 < 7 ∧ ?cfgs4.0 = [] ∧ pcOf ?cfg4.0 < 7›*) ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)› ‹ss1 = (cfg1, ibT1, ibUT1, ls1)› ‹ss2 = (cfg2, ibT2, ibUT2, ls2)› ‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')› ‹ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*))
show "match12_12 (oor3 Δ1' Δ3' Δe) ss3' ss4' statA' ss1 ss2 statO"
unfolding match12_12_def
(*goal: ‹∃sv1' sv2'. let statO' = sstatO' statO ss1 ss2 in validTransV (ss1, sv1') ∧ validTransV (ss2, sv2') ∧ (statA' = Diff ⟶ statO' = Diff) ∧ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' sv1' sv2' statO'›*)
proof (rule exI[of _ "nextN ss1"] (*‹(?P::config × int llist × int llist × nat set ⇒ bool) (nextN (ss1::config × int llist × int llist × nat set)) ⟹ ∃x::config × int llist × int llist × nat set. ?P x›*), rule exI[of _ "nextN ss2"] (*‹?P (nextN ss2) ⟹ ∃x. ?P x›*), unfold Let_def (*‹Let ?s ?f ≡ ?f ?s›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goals:
1. ‹validTransV (ss1::config × int llist × int llist × nat set, nextN ss1)›
2. ‹validTransV (ss2::config × int llist × int llist × nat set, nextN ss2)›
3. ‹(statA'::status) = Diff ⟹ sstatO' (statO::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) = Diff›
4. ‹oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
show "validTransV (ss1, nextN ss1)"
by (simp add: f1 (*‹¬ finalN ss1›*) nextN_stepN (*‹¬ finalN ?cfg_ib_ls ⟹ ?cfg_ib_ls →N nextN ?cfg_ib_ls›*))
show "validTransV (ss2, nextN ss2)"
by (simp add: f2 (*‹¬ finalN ss2›*) nextN_stepN (*‹¬ finalN ?cfg_ib_ls ⟹ ?cfg_ib_ls →N nextN ?cfg_ib_ls›*))
have cfgs4: "cfgs4 = []"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss "Δ1'_defs"
(*goal: ‹(cfgs4::config list) = []›*)
apply clarify
(*goal: ‹cfgs4 = []›*)
by (metis map_is_Nil_conv (*‹(map (?f::?'b ⇒ ?'a) (?xs::?'b list) = []) = (?xs = [])›*))
{
assume sstat: "statA' = Diff" (*‹(statA'::status) = Diff›*)
show "sstatO' statO ss1 ss2 = Diff"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) sstat (*‹statA' = Diff›*) pc (*‹pcOf cfg1 = 3›*) unfolding ss cfg statA'
(*goal: ‹sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*) sstatO'_def (*‹sstatO' ?statO ?sv1.0 ?sv2.0 = updStat ?statO (isIntV ?sv1.0, getObsV ?sv1.0) (isIntV ?sv2.0, getObsV ?sv2.0)›*) sstatA'_def (*‹sstatA' ?statA ?s1.0 ?s2.0 = updStat ?statA (isIntO ?s1.0, getObsO ?s1.0) (isIntO ?s2.0, getObsO ?s2.0)›*))
(*goal: ‹sstatO' (statO::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) = Diff›*)
apply (cases statO, simp_all)
(*goal: ‹⟦(pstate4::predState, Config (pc4::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (h3::heap) (p3::nat)), [], ibT3::int llist, ibUT3::int llist, ls4::nat set) →S (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set); (pstate4, Config pc4 (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (h4::heap) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls4) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); (pstate3::predState) = pstate4 ∧ ((n::enat) = enat (4::nat) ∨ n = ∞) ∧ pcOf (cfg2::config) = (3::nat) ∧ (pc3::nat) = pc4 ∧ map pcOf (cfgs3::config list) = map pcOf cfgs4 ∧ pc3 ≤ (6::nat) ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ array_base aa1 (getAvstore (stateOf (cfg1::config))) = array_base aa1 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = hheap h3 ∧ (∀cfg''::config∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''::config∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ ((statA::status) = Diff ⟶ (statO::status) = Diff) ∧ (2::nat) ≤ pc3 ∧ pc3 ≤ (6::nat) ∧ vs3 xx = vs4 xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 tt = vs4 tt ∧ int NN ≤ vs3 xx ∧ pc3 = (3::nat) ∧ (ls1::nat set) = {} ∧ (ls2::nat set) = {} ∧ ls1 = (ls3::nat set) ∧ ls2 = ls4 ∧ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4 ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls4), ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), ⊥) = Diff; pcOf cfg1 = (3::nat)⟧ ⟹ updStat statO (True, ⊥) (True, ⊥) = Diff›*)
apply (cases statA, simp_all)
(*goal: ‹⟦(pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls4) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3'); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls4) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ (n = enat 4 ∨ n = ∞) ∧ pcOf cfg2 = 3 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = hheap h3 ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ statA ≠ Diff ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 tt = vs4 tt ∧ int NN ≤ vs3 xx ∧ pc3 = 3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4 ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls4), ⊥) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), ⊥) = Diff; pcOf cfg1 = 3; statO = status.Eq⟧ ⟹ False›*)
using cfg (*‹cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)› ‹cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)›*) finals (*‹¬ finalN (ss1::config × int llist × int llist × nat set)› ‹¬ finalN ss2› ‹¬ finalS ss3› ‹¬ finalS ss4›*) ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹(ss4::predState × config × config list × int llist × int llist × nat set) = (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set)› ‹(ss1::config × int llist × int llist × nat set) = (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)› ‹ss2 = (cfg2, ibT2, ibUT2, ls2)› ‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')› ‹ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*) by simp
}
note stat = this (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*)
have pc4: "pc4 = 3"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf (cfg1::config) = (3::nat)›*) unfolding ss cfg
(*goal: ‹pc4 = 3›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*))
show "(oor3 Δ1' Δ3' Δe) ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)"
using v3[unfolded ss, simplified] (*‹(pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) →S (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')›*) proof (cases rule: stepS_cases (*‹⟦(?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls) →S (?pstate', ?cfg', ?cfgs', ?ibT', ?ibUT', ?ls'); ⟦?cfgs = []; ¬ is_IfJump (prog ! pcOf ?cfg) ∨ ¬ mispred ?pstate [pcOf ?cfg]; ?pstate' = ?pstate; ¬ finalB (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ?cfgs' = []; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs = []; is_IfJump (prog ! pcOf ?cfg); mispred ?pstate [pcOf ?cfg]; ?pstate' = update ?pstate [pcOf ?cfg]; ¬ finalM (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (?cfg, ?ibT, ?ibUT) ∧ ?cfgs' = [cfg1']; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ is_IfJump (prog ! pcOf (last ?cfgs)) ∨ ¬ mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) ≠ Fence; ?pstate' = ?pstate; ¬ is_getInput (prog ! pcOf (last ?cfgs)); ¬ is_Output (prog ! pcOf (last ?cfgs)); ?cfg' = ?cfg; ?ls' = ?ls ∪ readLocs (last ?cfgs); ∃cfg1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (cfg1', ?ibT', ?ibUT') ∧ ?cfgs' = butlast ?cfgs ## cfg1'⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); is_IfJump (prog ! pcOf (last ?cfgs)); mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ finalM (last ?cfgs, ?ibT, ?ibUT); ?cfg' = ?cfg; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (lcfg', ?ibT', ?ibUT') ∧ (cfg1', ibT1', ibUT1') = nextM (last ?cfgs, ?ibT, ?ibUT) ∧ ?cfgs' = butlast ?cfgs @ [lcfg'] ## cfg1'; ?ls' = ?ls ∪ readLocs (last ?cfgs)⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) = Fence; ?pstate' = ?pstate; ?cfg' = ?cfg; ?cfgs' = []; ?ibT' = ?ibT; ?ibUT' = ?ibUT; ?ls' = ?ls⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?cfg' = ?cfg; ?cfgs' = butlast ?cfgs; ?ls' = ?ls; ?ibT' = ?ibT; ?ibUT' = ?ibUT⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⟦(cfgs3::config list) = []; ¬ is_IfJump (prog ! pcOf (cfg3::config)) ∨ ¬ mispred (pstate3::predState) [pcOf cfg3]; (pstate3'::predState) = pstate3; ¬ finalB (cfg3, ibT3::int llist, ibUT3::int llist); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3, ibT3, ibUT3); (cfgs3'::config list) = []; (ls3'::nat set) = (ls3::nat set) ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
2. ‹⟦(cfgs3::config list) = []; is_IfJump (prog ! pcOf (cfg3::config)); mispred (pstate3::predState) [pcOf cfg3]; (pstate3'::predState) = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3::int llist, ibUT3::int llist); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3, ibT3, ibUT3); ∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ (cfgs3'::config list) = [cfg1']; (ls3'::nat set) = (ls3::nat set) ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
3. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); ¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) ≠ Fence; (pstate3'::predState) = pstate3; ¬ is_getInput (prog ! pcOf (last cfgs3)); ¬ is_Output (prog ! pcOf (last cfgs3)); (cfg3'::config) = cfg3; (ls3'::nat set) = (ls3::nat set) ∪ readLocs (last cfgs3); ∃cfg1'::config. nextB (last cfgs3, ibT3::int llist, ibUT3::int llist) = (cfg1', ibT3'::int llist, ibUT3'::int llist) ∧ (cfgs3'::config list) = butlast cfgs3 ## cfg1'⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
4. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); (pstate3'::predState) = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3::int llist, ibUT3::int llist); (cfg3'::config) = cfg3; ∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3'::int llist, ibUT3'::int llist) ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ (cfgs3'::config list) = butlast cfgs3 @ [lcfg'] ## cfg1'; (ls3'::nat set) = (ls3::nat set) ∪ readLocs (last cfgs3)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
5. ‹⟦(cfgs3::config list) ≠ []; ¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; (pstate3'::predState) = pstate3; (cfg3'::config) = cfg3; (cfgs3'::config list) = []; (ibT3'::int llist) = (ibT3::int llist); (ibUT3'::int llist) = (ibUT3::int llist); (ls3'::nat set) = (ls3::nat set)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
6. ‹⟦(cfgs3::config list) ≠ []; resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf cfgs3); (pstate3'::predState) = update pstate3 (pcOf cfg3 # map pcOf cfgs3); (cfg3'::config) = cfg3; (cfgs3'::config list) = butlast cfgs3; (ls3'::nat set) = (ls3::nat set); (ibT3'::int llist) = (ibT3::int llist); (ibUT3'::int llist) = (ibUT3::int llist)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
case spec_normal (*‹cfgs3 ≠ []› ‹¬ resolve (pstate3::predState) (pcOf (cfg3::config) # map pcOf (cfgs3::config list))› ‹¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹prog ! pcOf (last cfgs3) ≠ Fence› ‹pstate3' = pstate3› ‹¬ is_getInput (prog ! pcOf (last cfgs3))› ‹¬ is_Output (prog ! pcOf (last cfgs3))› ‹cfg3' = cfg3› ‹ls3' = ls3 ∪ readLocs (last cfgs3)› ‹∃cfg1'::config. nextB (last (cfgs3::config list), ibT3::int llist, ibUT3::int llist) = (cfg1', ibT3'::int llist, ibUT3'::int llist) ∧ (cfgs3'::config list) = butlast cfgs3 ## cfg1'›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3, ibUT3); cfg3' = cfg3; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'; ls3' = ls3 ∪ readLocs (last cfgs3)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_mispred (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹is_IfJump (prog ! pcOf (last cfgs3))› ‹mispred pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹¬ finalM (last (cfgs3::config list), ibT3::int llist, ibUT3::int llist)› ‹cfg3' = cfg3› ‹∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'› ‹ls3' = ls3 ∪ readLocs (last cfgs3)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (nextN (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)) (nextN (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)) (sstatO' (statO::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_Fence (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹prog ! pcOf (last cfgs3) = Fence› ‹(pstate3'::predState) = (pstate3::predState)› ‹cfg3' = cfg3› ‹cfgs3' = []› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3› ‹(ls3'::nat set) = (ls3::nat set)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_resolve (*‹cfgs3 ≠ []› ‹resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹cfg3' = cfg3› ‹(cfgs3'::config list) = butlast (cfgs3::config list)› ‹ls3' = ls3› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_mispred (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3, ibT3, ibUT3)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*)
note nm3 = nonspec_mispred (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (cfg3::config)›*)
show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
using v4[unfolded ss, simplified] (*‹(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*) proof (cases rule: stepS_cases (*‹⟦(?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls) →S (?pstate', ?cfg', ?cfgs', ?ibT', ?ibUT', ?ls'); ⟦?cfgs = []; ¬ is_IfJump (prog ! pcOf ?cfg) ∨ ¬ mispred ?pstate [pcOf ?cfg]; ?pstate' = ?pstate; ¬ finalB (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ?cfgs' = []; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs = []; is_IfJump (prog ! pcOf ?cfg); mispred ?pstate [pcOf ?cfg]; ?pstate' = update ?pstate [pcOf ?cfg]; ¬ finalM (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (?cfg, ?ibT, ?ibUT) ∧ ?cfgs' = [cfg1']; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ is_IfJump (prog ! pcOf (last ?cfgs)) ∨ ¬ mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) ≠ Fence; ?pstate' = ?pstate; ¬ is_getInput (prog ! pcOf (last ?cfgs)); ¬ is_Output (prog ! pcOf (last ?cfgs)); ?cfg' = ?cfg; ?ls' = ?ls ∪ readLocs (last ?cfgs); ∃cfg1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (cfg1', ?ibT', ?ibUT') ∧ ?cfgs' = butlast ?cfgs ## cfg1'⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); is_IfJump (prog ! pcOf (last ?cfgs)); mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ finalM (last ?cfgs, ?ibT, ?ibUT); ?cfg' = ?cfg; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (lcfg', ?ibT', ?ibUT') ∧ (cfg1', ibT1', ibUT1') = nextM (last ?cfgs, ?ibT, ?ibUT) ∧ ?cfgs' = butlast ?cfgs @ [lcfg'] ## cfg1'; ?ls' = ?ls ∪ readLocs (last ?cfgs)⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) = Fence; ?pstate' = ?pstate; ?cfg' = ?cfg; ?cfgs' = []; ?ibT' = ?ibT; ?ibUT' = ?ibUT; ?ls' = ?ls⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?cfg' = ?cfg; ?cfgs' = butlast ?cfgs; ?ls' = ?ls; ?ibT' = ?ibT; ?ibUT' = ?ibUT⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⟦(cfgs4::config list) = []; ¬ is_IfJump (prog ! pcOf (cfg4::config)) ∨ ¬ mispred (pstate4::predState) [pcOf cfg4]; (pstate4'::predState) = pstate4; ¬ finalB (cfg4, ibT4::int llist, ibUT4::int llist); (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4, ibT4, ibUT4); (cfgs4'::config list) = []; (ls4'::nat set) = (ls4::nat set) ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
2. ‹⟦(cfgs4::config list) = []; is_IfJump (prog ! pcOf (cfg4::config)); mispred (pstate4::predState) [pcOf cfg4]; (pstate4'::predState) = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4::int llist, ibUT4::int llist); (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4, ibT4, ibUT4); ∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ (cfgs4'::config list) = [cfg1']; (ls4'::nat set) = (ls4::nat set) ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
3. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); ¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) ≠ Fence; (pstate4'::predState) = pstate4; ¬ is_getInput (prog ! pcOf (last cfgs4)); ¬ is_Output (prog ! pcOf (last cfgs4)); (cfg4'::config) = cfg4; (ls4'::nat set) = (ls4::nat set) ∪ readLocs (last cfgs4); ∃cfg1'::config. nextB (last cfgs4, ibT4::int llist, ibUT4::int llist) = (cfg1', ibT4'::int llist, ibUT4'::int llist) ∧ (cfgs4'::config list) = butlast cfgs4 ## cfg1'⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
4. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); (pstate4'::predState) = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4::int llist, ibUT4::int llist); (cfg4'::config) = cfg4; ∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4'::int llist, ibUT4'::int llist) ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ (cfgs4'::config list) = butlast cfgs4 @ [lcfg'] ## cfg1'; (ls4'::nat set) = (ls4::nat set) ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
5. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; (pstate4'::predState) = pstate4; (cfg4'::config) = cfg4; (cfgs4'::config list) = []; (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist); (ls4'::nat set) = (ls4::nat set)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
6. ‹⟦(cfgs4::config list) ≠ []; resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); (pstate4'::predState) = update pstate4 (pcOf cfg4 # map pcOf cfgs4); (cfg4'::config) = cfg4; (cfgs4'::config list) = butlast cfgs4; (ls4'::nat set) = (ls4::nat set); (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
case spec_normal (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹prog ! pcOf (last (cfgs4::config list)) ≠ Fence› ‹pstate4' = pstate4› ‹¬ is_getInput (prog ! pcOf (last cfgs4))› ‹¬ is_Output (prog ! pcOf (last cfgs4))› ‹cfg4' = cfg4› ‹ls4' = ls4 ∪ readLocs (last cfgs4)› ‹∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹(statA'::status) = Diff ⟹ sstatO' (statO::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) = Diff›*) nm3 (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (cfg3::config)›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*) cfgs4 (*‹(cfgs4::config list) = []›*))
next
(*goals:
1. ‹⟦(cfgs4::config list) = []; ¬ is_IfJump (prog ! pcOf (cfg4::config)) ∨ ¬ mispred (pstate4::predState) [pcOf cfg4]; (pstate4'::predState) = pstate4; ¬ finalB (cfg4, ibT4::int llist, ibUT4::int llist); (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4, ibT4, ibUT4); (cfgs4'::config list) = []; (ls4'::nat set) = (ls4::nat set) ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
2. ‹⟦(cfgs4::config list) = []; is_IfJump (prog ! pcOf (cfg4::config)); mispred (pstate4::predState) [pcOf cfg4]; (pstate4'::predState) = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4::int llist, ibUT4::int llist); (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4, ibT4, ibUT4); ∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ (cfgs4'::config list) = [cfg1']; (ls4'::nat set) = (ls4::nat set) ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
3. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); (pstate4'::predState) = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4::int llist, ibUT4::int llist); (cfg4'::config) = cfg4; ∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4'::int llist, ibUT4'::int llist) ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ (cfgs4'::config list) = butlast cfgs4 @ [lcfg'] ## cfg1'; (ls4'::nat set) = (ls4::nat set) ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
4. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; (pstate4'::predState) = pstate4; (cfg4'::config) = cfg4; (cfgs4'::config list) = []; (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist); (ls4'::nat set) = (ls4::nat set)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
5. ‹⟦(cfgs4::config list) ≠ []; resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); (pstate4'::predState) = update pstate4 (pcOf cfg4 # map pcOf cfgs4); (cfg4'::config) = cfg4; (cfgs4'::config list) = butlast cfgs4; (ls4'::nat set) = (ls4::nat set); (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
case spec_mispred (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹is_IfJump (prog ! pcOf (last (cfgs4::config list)))› ‹mispred pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹¬ finalM (last cfgs4, ibT4, ibUT4)› ‹cfg4' = cfg4› ‹∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'› ‹ls4' = ls4 ∪ readLocs (last cfgs4)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nm3 (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf (cfg3::config))› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*) cfgs4 (*‹cfgs4 = []›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 = []; is_IfJump (prog ! pcOf cfg4); mispred pstate4 [pcOf cfg4]; pstate4' = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_Fence (*‹(cfgs4::config list) ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹prog ! pcOf (last cfgs4) = Fence› ‹(pstate4'::predState) = (pstate4::predState)› ‹cfg4' = cfg4› ‹cfgs4' = []› ‹ibT4' = ibT4› ‹ibUT4' = ibUT4› ‹ls4' = ls4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nm3 (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf (cfg3::config))› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (cfg3::config)›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (nextN (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)) (nextN (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)) (sstatO' (statO::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*) cfgs4 (*‹cfgs4 = []›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 = []; is_IfJump (prog ! pcOf cfg4); mispred pstate4 [pcOf cfg4]; pstate4' = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_resolve (*‹cfgs4 ≠ []› ‹resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹(pstate4'::predState) = update (pstate4::predState) (pcOf (cfg4::config) # map pcOf (cfgs4::config list))› ‹cfg4' = cfg4› ‹cfgs4' = butlast cfgs4› ‹ls4' = ls4› ‹(ibT4'::int llist) = (ibT4::int llist)› ‹(ibUT4'::int llist) = (ibUT4::int llist)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nm3 (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg3::config, ibT3::int llist, ibUT3::int llist) ∧ (cfgs3'::config list) = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*) cfgs4 (*‹cfgs4 = []›*))
next
(*goals:
1. ‹⟦(cfgs4::config list) = []; ¬ is_IfJump (prog ! pcOf (cfg4::config)) ∨ ¬ mispred (pstate4::predState) [pcOf cfg4]; (pstate4'::predState) = pstate4; ¬ finalB (cfg4, ibT4::int llist, ibUT4::int llist); (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4, ibT4, ibUT4); (cfgs4'::config list) = []; (ls4'::nat set) = (ls4::nat set) ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
2. ‹⟦(cfgs4::config list) = []; is_IfJump (prog ! pcOf (cfg4::config)); mispred (pstate4::predState) [pcOf cfg4]; (pstate4'::predState) = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4::int llist, ibUT4::int llist); (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4, ibT4, ibUT4); ∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ (cfgs4'::config list) = [cfg1']; (ls4'::nat set) = (ls4::nat set) ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
case nonspec_normal (*‹cfgs4 = []› ‹¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]› ‹(pstate4'::predState) = (pstate4::predState)› ‹¬ finalB (cfg4, ibT4, ibUT4)› ‹(cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4::config, ibT4::int llist, ibUT4::int llist)› ‹cfgs4' = []› ‹ls4' = ls4 ∪ readLocs cfg4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nm3 (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹(pstate3'::predState) = update (pstate3::predState) [pcOf (cfg3::config)]› ‹¬ finalM (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*) cfgs4 (*‹cfgs4 = []›*))
next
(*goal: ‹⟦(cfgs4::config list) = []; is_IfJump (prog ! pcOf (cfg4::config)); mispred (pstate4::predState) [pcOf cfg4]; (pstate4'::predState) = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4::int llist, ibUT4::int llist); (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4, ibT4, ibUT4); ∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ (cfgs4'::config list) = [cfg1']; (ls4'::nat set) = (ls4::nat set) ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
case nonspec_mispred (*‹cfgs4 = []› ‹is_IfJump (prog ! pcOf cfg4)› ‹mispred pstate4 [pcOf cfg4]› ‹pstate4' = update pstate4 [pcOf cfg4]› ‹¬ finalM (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']› ‹ls4' = ls4 ∪ readLocs cfg4›*)
note nm4 = nonspec_mispred (*‹(cfgs4::config list) = []› ‹is_IfJump (prog ! pcOf cfg4)› ‹mispred (pstate4::predState) [pcOf (cfg4::config)]› ‹pstate4' = update pstate4 [pcOf cfg4]› ‹¬ finalM (cfg4, ibT4, ibUT4)› ‹(cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4::config, ibT4::int llist, ibUT4::int llist)› ‹∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg4::config, ibT4::int llist, ibUT4::int llist) ∧ (cfgs4'::config list) = [cfg1']› ‹ls4' = ls4 ∪ readLocs cfg4›*)
show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
apply (rule oor3I2 (*‹?Δ₂ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO ⟹ oor3 ?Δ ?Δ₂ ?Δ₃ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) pc4 (*‹pc4 = 3›*) "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) pc (*‹pcOf cfg1 = 3›*) v3 (*‹validTransO (ss3, ss3')›*) v4 (*‹validTransO (ss4, ss4')›*) nm3 (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf (cfg3::config))› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (cfg3::config)›*) nm4 (*‹cfgs4 = []› ‹is_IfJump (prog ! pcOf cfg4)› ‹mispred pstate4 [pcOf cfg4]› ‹pstate4' = update pstate4 [pcOf cfg4]› ‹¬ finalM (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']› ‹(ls4'::nat set) = (ls4::nat set) ∪ readLocs (cfg4::config)›*) config.sel(2) (*‹stateOf (Config ?x1.0 ?x2.0) = ?x2.0›*) state.sel(2) (*‹getAvstore (State ?x1.0 ?x2.0 ?x3.0 ?x4.0) = ?x2.0›*) unfolding ss cfg cfg1 cfg2 hh
(*goal: ‹Δ3' ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (nextN (Config (pc1::nat) (State (Vstore (vs1::char list ⇒ int)) (avst1::avstore) (h1::heap) (p1::nat)), ibT1::int llist, ibUT1::int llist, ls1::nat set)) (nextN (Config (pc2::nat) (State (Vstore (vs2::char list ⇒ int)) (avst2::avstore) (h2::heap) (p2::nat)), ibT2::int llist, ibUT2::int llist, ls2::nat set)) (sstatO' (statO::status) (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
apply (simp add:Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*) Δ3'_defs (*‹Δ3' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 = elseBranch ∧ cfgs3 ≠ [] ∧ pcOf (last cfgs3) ∈ inThenBranch ∧ pcOf (last cfgs4) = pcOf (last cfgs3) ∧ pcOf cfg1 = pcOf (last cfgs3) ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ getAvstore (stateOf cfg3) = getAvstore (stateOf (last cfgs3)) ∧ getAvstore (stateOf cfg4) = getAvstore (stateOf (last cfgs4)) ∧ same_xx_cp cfg1 cfg2 ∧ ls1 = ls3 ∧ ls2 = ls4 ∧ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 = (4::nat) ⟶ ls1 = {} ∧ ls2 = {}) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls2 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg2))} ∧ ls3 = ls4) ∧ ((4::nat) < pcOf cfg1 ⟶ same_var vv cfg1 (last cfgs3) ∧ same_var vv cfg2 (last cfgs4)) ∧ misSpecL1 cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹elseBranch = (6::?'a)› ‹inThenBranch = {4::?'a..6::?'a}› ‹startOfThenBranch = (4::?'a)› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹misSpecL1 (?cfgs::config list) ≡ length ?cfgs = Suc (0::nat)› ‹same_var (?x::char list) (?cfg::config) (?cfg'::config) ≡ vstore (getVstore (stateOf ?cfg)) ?x = vstore (getVstore (stateOf ?cfg')) ?x›*))
(*goal: ‹Δ3' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1)) (nextN (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2)) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
by (metis empty_subsetI (*‹{} ⊆ ?A›*) nat_less_le (*‹(?m < ?n) = (?m ≤ ?n ∧ ?m ≠ ?n)›*) nat_neq_iff (*‹(?m ≠ ?n) = (?m < ?n ∨ ?n < ?m)›*) numeral_eq_iff (*‹(numeral ?m = numeral ?n) = (?m = ?n)›*) semiring_norm( (*‹(num.Bit1 ?m = num.Bit0 ?n) = False›*) 89) set_eq_subset (*‹(?A = ?B) = (?A ⊆ ?B ∧ ?B ⊆ ?A)›*))
qed
next
(*goal: ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_normal (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*)
note nn3 = nonspec_normal (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹cfgs3' = []› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (cfg3::config)›*)
show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
using v4[unfolded ss, simplified] (*‹(pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*) proof (cases rule: stepS_cases (*‹⟦(?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls) →S (?pstate', ?cfg', ?cfgs', ?ibT', ?ibUT', ?ls'); ⟦?cfgs = []; ¬ is_IfJump (prog ! pcOf ?cfg) ∨ ¬ mispred ?pstate [pcOf ?cfg]; ?pstate' = ?pstate; ¬ finalB (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ?cfgs' = []; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs = []; is_IfJump (prog ! pcOf ?cfg); mispred ?pstate [pcOf ?cfg]; ?pstate' = update ?pstate [pcOf ?cfg]; ¬ finalM (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (?cfg, ?ibT, ?ibUT) ∧ ?cfgs' = [cfg1']; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ is_IfJump (prog ! pcOf (last ?cfgs)) ∨ ¬ mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) ≠ Fence; ?pstate' = ?pstate; ¬ is_getInput (prog ! pcOf (last ?cfgs)); ¬ is_Output (prog ! pcOf (last ?cfgs)); ?cfg' = ?cfg; ?ls' = ?ls ∪ readLocs (last ?cfgs); ∃cfg1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (cfg1', ?ibT', ?ibUT') ∧ ?cfgs' = butlast ?cfgs ## cfg1'⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); is_IfJump (prog ! pcOf (last ?cfgs)); mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ finalM (last ?cfgs, ?ibT, ?ibUT); ?cfg' = ?cfg; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (lcfg', ?ibT', ?ibUT') ∧ (cfg1', ibT1', ibUT1') = nextM (last ?cfgs, ?ibT, ?ibUT) ∧ ?cfgs' = butlast ?cfgs @ [lcfg'] ## cfg1'; ?ls' = ?ls ∪ readLocs (last ?cfgs)⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) = Fence; ?pstate' = ?pstate; ?cfg' = ?cfg; ?cfgs' = []; ?ibT' = ?ibT; ?ibUT' = ?ibUT; ?ls' = ?ls⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?cfg' = ?cfg; ?cfgs' = butlast ?cfgs; ?ls' = ?ls; ?ibT' = ?ibT; ?ibUT' = ?ibUT⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 = []; is_IfJump (prog ! pcOf cfg4); mispred pstate4 [pcOf cfg4]; pstate4' = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) ≠ Fence; pstate4' = pstate4; ¬ is_getInput (prog ! pcOf (last cfgs4)); ¬ is_Output (prog ! pcOf (last cfgs4)); cfg4' = cfg4; ls4' = ls4 ∪ readLocs (last cfgs4); ∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
6. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_mispred (*‹cfgs4 = []› ‹is_IfJump (prog ! pcOf cfg4)› ‹mispred pstate4 [pcOf cfg4]› ‹pstate4' = update pstate4 [pcOf cfg4]› ‹¬ finalM (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']› ‹ls4' = ls4 ∪ readLocs cfg4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (cfg3::config)›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) ≠ Fence; pstate4' = pstate4; ¬ is_getInput (prog ! pcOf (last cfgs4)); ¬ is_Output (prog ! pcOf (last cfgs4)); cfg4' = cfg4; ls4' = ls4 ∪ readLocs (last cfgs4); ∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_normal (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹prog ! pcOf (last cfgs4) ≠ Fence› ‹pstate4' = pstate4› ‹¬ is_getInput (prog ! pcOf (last cfgs4))› ‹¬ is_Output (prog ! pcOf (last cfgs4))› ‹cfg4' = cfg4› ‹ls4' = ls4 ∪ readLocs (last cfgs4)› ‹∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹(pstate3'::predState) = (pstate3::predState)› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_mispred (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹is_IfJump (prog ! pcOf (last (cfgs4::config list)))› ‹mispred (pstate4::predState) (pcOf (cfg4::config) # map pcOf (cfgs4::config list))› ‹pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹¬ finalM (last (cfgs4::config list), ibT4::int llist, ibUT4::int llist)› ‹cfg4' = cfg4› ‹∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'› ‹ls4' = ls4 ∪ readLocs (last cfgs4)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹(statA'::status) = Diff ⟹ sstatO' (statO::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹(cfgs3'::config list) = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (nextN (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)) (nextN (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)) (sstatO' (statO::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_Fence (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹prog ! pcOf (last cfgs4) = Fence› ‹(pstate4'::predState) = (pstate4::predState)› ‹(cfg4'::config) = (cfg4::config)› ‹(cfgs4'::config list) = []› ‹ibT4' = ibT4› ‹ibUT4' = ibUT4› ‹(ls4'::nat set) = (ls4::nat set)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹(cfgs3::config list) = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (cfg3::config)›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_resolve (*‹cfgs4 ≠ []› ‹resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹(pstate4'::predState) = update (pstate4::predState) (pcOf (cfg4::config) # map pcOf (cfgs4::config list))› ‹cfg4' = cfg4› ‹cfgs4' = butlast cfgs4› ‹ls4' = ls4› ‹ibT4' = ibT4› ‹ibUT4' = ibUT4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹(cfgs3::config list) = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goal: ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_normal (*‹cfgs4 = []› ‹¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]› ‹pstate4' = pstate4› ‹¬ finalB (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹cfgs4' = []› ‹ls4' = ls4 ∪ readLocs cfg4›*)
note nn4 = nonspec_normal (*‹cfgs4 = []› ‹¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]› ‹pstate4' = pstate4› ‹¬ finalB (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹cfgs4' = []› ‹(ls4'::nat set) = (ls4::nat set) ∪ readLocs (cfg4::config)›*)
show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
apply (rule oor3I1 (*‹?Δ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO ⟹ oor3 ?Δ ?Δ₂ ?Δ₃ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) pc4 (*‹(pc4::nat) = (3::nat)›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) pc (*‹pcOf cfg1 = 3›*) v3 (*‹validTransO (ss3, ss3')›*) v4 (*‹validTransO (ss4, ss4')›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) config.sel(2) (*‹stateOf (Config (?x1.0::nat) (?x2.0::state)) = ?x2.0›*) state.sel(2) (*‹getAvstore (State (?x1.0::vstore) (?x2.0::avstore) (?x3.0::heap) (?x4.0::nat)) = ?x2.0›*) unfolding ss cfg cfg1 cfg2 hh
(*goal: ‹Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1)) (nextN (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2)) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
apply (simp add:Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
(*goal: ‹Δ1' ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1)) (nextN (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2)) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
by (metis nat_le_linear (*‹?m ≤ ?n ∨ ?n ≤ ?m›*) nat_less_le (*‹(?m < ?n) = (?m ≤ ?n ∧ ?m ≠ ?n)›*) numeral_eq_iff (*‹(numeral ?m = numeral ?n) = (?m = ?n)›*) semiring_norm( (*‹(num.Bit0 ?m = num.Bit1 ?n) = False›*) 88))
qed
qed
qed
qed
subgoal for
apply (rule disjI1 (*‹?P ⟹ ?P ∨ ?Q›*), rule exI[of _ 2] (*‹?P 2 ⟹ ∃x. ?P x›*), rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹pcOf cfg1 = 4 ⟹ (∃v<n. proact (oor3 Δ1' Δ3' Δe) v ss3 ss4 statA ss1 ss2 statO) ∨ match (oor3 Δ1' Δ3' Δe) ss3 ss4 statA ss1 ss2 statO›*)
subgoal for
using "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) unfolding ss "Δ1'_defs"
(*goal: ‹pcOf cfg1 = 4 ⟹ 2 < n›*)
apply clarify
(*goal: ‹pcOf cfg1 = 4 ⟹ 2 < n›*)
apply (erule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⟦pcOf cfg1 = 4; pstate3 = pstate4; pcOf cfg3 ∈ {2..6}; n = enat (endPC - pcOf cfg1) ∨ n = ∞; pcOf cfg1 = pcOf cfg2; vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx; 2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt; pcOf cfg3 = pcOf cfg4; ∀cfg3'∈set []. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx; ∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx; int NN ≤ vstore (getVstore (stateOf cfg3)) xx; map pcOf [] = map pcOf cfgs4; pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4; pcOf cfg3 ∈ {0..6}; pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4; pcOf ` set [] ⊆ {0..6}; Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2; pcOf cfg1 ∈ {0..6}; 4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ {4..6} ∧ pcOf cfg3 = 6; array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)); vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx; vstore (getVstore (stateOf cfg1)) xx = 0; vstore (getVstore (stateOf cfg1)) xx = 0; ∀cfg''∈set []. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1)); array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)); ∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1)); ls3 ⊆ ls1; array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)); ∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2)); array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)); ls4 ⊆ ls2; cfgs3 = []; ∀cfg''∈set []. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1)); array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)); ∀cfg3'∈set []. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3)); getHheap (stateOf cfg1) = getHheap (stateOf cfg3); ∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2)); ∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4)); ∀cfg''∈set []. getHheap (stateOf cfg1) = getHheap (stateOf cfg''); getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3); getHheap (stateOf cfg2) = getHheap (stateOf cfg4); array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)); ∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg''); getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4); ∀cfg3'∈set []. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3)); ∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4)); statA = Diff ⟶ statO = Diff⟧ ⟹ 2 < n›*)
subgoalpremises p for
using p(1,47) (*‹pcOf cfg1 = 4› ‹n = enat (endPC - pcOf cfg1)›*) unfolding endPC
(*goal: ‹2 < n›*)
by simp
subgoal for
using enat_ord_simps(4) (*‹(?q < ∞) = (?q ≠ ∞)›*) numeral_ne_infinity (*‹numeral (?k::num) ≠ ∞›*) by presburger .
unfolding proact_def
(*goal: ‹pcOf cfg1 = 4 ⟹ ¬ isSecV ss1 ∧ ¬ isIntV ss1 ∧ move_1 (oor3 Δ1' Δ3' Δe) 2 ss3 ss4 statA ss1 ss2 statO ∨ ¬ isSecV ss2 ∧ ¬ isIntV ss2 ∧ move_2 (oor3 Δ1' Δ3' Δe) 2 ss3 ss4 statA ss1 ss2 statO ∨ ¬ isSecV ss1 ∧ ¬ isSecV ss2 ∧ Van.eqAct ss1 ss2 ∧ move_12 (oor3 Δ1' Δ3' Δe) 2 ss3 ss4 statA ss1 ss2 statO›*)
proof (intro disjI2 (*‹?Q ⟹ ?P ∨ ?Q›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹pcOf cfg1 = 4 ⟹ ¬ isSecV ss1›
2. ‹pcOf cfg1 = 4 ⟹ ¬ isSecV ss2›
3. ‹pcOf cfg1 = 4 ⟹ Van.eqAct ss1 ss2›
4. ‹pcOf cfg1 = 4 ⟹ move_12 (oor3 Δ1' Δ3' Δe) 2 ss3 ss4 statA ss1 ss2 statO›*)
assume pc: "pcOf cfg1 = 4" (*‹pcOf (cfg1::config) = (4::nat)›*)
show "¬ isSecV ss1"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf cfg1 = 4›*) unfolding "Δ1'_defs" ss cfg
(*goal: ‹¬ isSecV (cfg1, ibT1, ibUT1, ls1)›*)
by auto
show "¬ isSecV ss2"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf cfg1 = 4›*) unfolding "Δ1'_defs" ss cfg
(*goal: ‹¬ isSecV (cfg2, ibT2, ibUT2, ls2)›*)
by auto
show "Van.eqAct ss1 ss2"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf cfg1 = 4›*) unfolding "Δ1'_defs" ss cfg Van.eqAct_def
(*goal: ‹isIntV (cfg1, ibT1, ibUT1, ls1) = isIntV (cfg2, ibT2, ibUT2, ls2) ∧ (isIntV (cfg1, ibT1, ibUT1, ls1) ⟶ getActV (cfg1, ibT1, ibUT1, ls1) = getActV (cfg2, ibT2, ibUT2, ls2))›*)
by auto
show "move_12 (oor3 Δ1' Δ3' Δe) 2 ss3 ss4 statA ss1 ss2 statO"
unfolding move_12_def Let_def
(*goal: ‹∃(sv1'::config × int llist × int llist × nat set) sv2'::config × int llist × int llist × nat set. validTransV (ss1::config × int llist × int llist × nat set, sv1') ∧ validTransV (ss2::config × int llist × int llist × nat set, sv2') ∧ oor3 Δ1' Δ3' Δe (2::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) sv1' sv2' (sstatO' (statO::status) ss1 ss2)›*)
proof (rule exI[of _ "nextN ss1"] (*‹?P (nextN ss1) ⟹ ∃x. ?P x›*), rule exI[of _ "nextN ss2"] (*‹?P (nextN ss2) ⟹ ∃x. ?P x›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹validTransV (ss1::config × int llist × int llist × nat set, nextN ss1)›
2. ‹validTransV (ss2::config × int llist × int llist × nat set, nextN ss2)›
3. ‹oor3 Δ1' Δ3' Δe (2::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
show "validTransV (ss1, nextN ss1)"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf cfg1 = 4›*) unfolding validTransV_iff_nextN ss "Δ1'_defs"
(*goal: ‹¬ finalN (cfg1, ibT1, ibUT1, ls1) ∧ nextN (cfg1, ibT1, ibUT1, ls1) = nextN (cfg1, ibT1, ibUT1, ls1)›*)
by simp
show "validTransV (ss2, nextN ss2)"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf cfg1 = 4›*) unfolding validTransV_iff_nextN ss "Δ1'_defs"
(*goal: ‹¬ finalN (cfg2, ibT2, ibUT2, ls2) ∧ nextN (cfg2, ibT2, ibUT2, ls2) = nextN (cfg2, ibT2, ibUT2, ls2)›*)
by simp
have a1_0: "array_loc aa1 0 avst3 = array_loc aa1 0 avst4"
using "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) pc (*‹pcOf cfg1 = 4›*) unfolding cfg cfg1 ss "Δ1'_defs" array_loc_def
(*goal: ‹array_base aa1 avst3 + 0 = array_base aa1 avst4 + 0›*)
by simp
have pc1: "pc1 = 4"
using "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) pc (*‹pcOf cfg1 = 4›*) unfolding cfg cfg1 ss "Δ1'_defs"
(*goal: ‹pc1 = 4›*)
by simp
show "oor3 Δ1' Δ3' Δe 2 ss3 ss4 statA (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)"
apply (rule oor3I1 (*‹?Δ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO ⟹ oor3 ?Δ ?Δ₂ ?Δ₃ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*goal: ‹oor3 Δ1' Δ3' Δe 2 ss3 ss4 statA (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf (cfg1::config) = (4::nat)›*) unfolding ss cfg cfg1 cfg2 hh h1 h2 endPC
(*goal: ‹Δ1' 2 (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), cfgs3, ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), cfgs4, ibT4, ibUT4, ls4) statA (nextN (Config pc1 (State (Vstore vs1) avst1 (Heap hh1) p1), ibT1, ibUT1, ls1)) (nextN (Config pc2 (State (Vstore vs2) avst2 (Heap hh2) p2), ibT2, ibUT2, ls2)) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 (Heap hh1) p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 (Heap hh2) p2), ibT2, ibUT2, ls2))›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
(*goal: ‹Δ1' 2 (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), cfgs3, ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), cfgs4, ibT4, ibUT4, ls4) statA (nextN (Config pc1 (State (Vstore vs1) avst1 (Heap hh1) p1), ibT1, ibUT1, ls1)) (nextN (Config pc2 (State (Vstore vs2) avst2 (Heap hh2) p2), ibT2, ibUT2, ls2)) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 (Heap hh1) p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 (Heap hh2) p2), ibT2, ibUT2, ls2))›*)
apply -
(*goal: ‹⟦pstate3 = pstate4 ∧ (n = enat (7 - pc1) ∨ n = ∞) ∧ pc1 = 4 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pc1 ≤ 6 ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hh1 = hh3 ∧ (∀cfg''∈set cfgs3. hh1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hh2 = hh4 ∧ (∀cfg''∈set cfgs4. hh2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ (2 < pc1 ⟶ vs3 tt = vs4 tt) ∧ int NN ≤ vs3 xx ∧ (pc1 < 4 ⟶ pc1 = pc3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pc1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 avst1} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pc1 ⟶ pc1 ≤ 6 ∧ pc3 = 6) ∧ vs1 xx = vs2 xx ∧ vs1 xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []; pc2 = 4⟧ ⟹ enat 2 = 2 ∧ cfgs4 = [] ∧ (∀cfg''∈set cfgs4. hh4 = getHheap (stateOf cfg'')) ∧ (∀n. array_loc aa1 0 avst4 ≠ array_loc aa2 n avst4 ∧ array_loc aa1 0 avst3 ≠ array_loc aa2 n avst3) ∧ (statA = Diff ⟶ sstatO' Diff (Config 4 (State (Vstore vs1) avst3 (Heap hh3) p1), ibT1, ibUT1, ls2) (Config 4 (State (Vstore vs2) avst4 (Heap hh4) p2), ibT2, ibUT2, ls2) = Diff) ∧ ls2 ⊆ {array_loc aa1 0 avst3} ∧ insert (array_loc aa1 0 avst3) ls2 = insert (array_loc aa1 0 avst4) ls2 ∧ pc4 = 6 ∧ ls4 ⊆ insert (array_loc aa1 0 avst3) ls2 ∧ ls4 ⊆ insert (array_loc aa1 0 avst4) ls2›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹⟦pstate3 = pstate4 ∧ (n = enat (7 - pc1) ∨ n = ∞) ∧ pc1 = 4 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pc1 ≤ 6 ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hh1 = hh3 ∧ (∀cfg''∈set cfgs3. hh1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hh2 = hh4 ∧ (∀cfg''∈set cfgs4. hh2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ (2 < pc1 ⟶ vs3 tt = vs4 tt) ∧ int NN ≤ vs3 xx ∧ (pc1 < 4 ⟶ pc1 = pc3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pc1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 avst1} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pc1 ⟶ pc1 ≤ 6 ∧ pc3 = 6) ∧ vs1 xx = vs2 xx ∧ vs1 xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []; pc2 = 4⟧ ⟹ enat 2 = 2 ∧ cfgs4 = [] ∧ (∀cfg''∈set cfgs4. hh4 = getHheap (stateOf cfg'')) ∧ (∀n. array_loc aa1 0 avst4 ≠ array_loc aa2 n avst4 ∧ array_loc aa1 0 avst3 ≠ array_loc aa2 n avst3) ∧ (statA = Diff ⟶ sstatO' Diff (Config 4 (State (Vstore vs1) avst3 (Heap hh3) p1), ibT1, ibUT1, ls2) (Config 4 (State (Vstore vs2) avst4 (Heap hh4) p2), ibT2, ibUT2, ls2) = Diff) ∧ ls2 ⊆ {array_loc aa1 0 avst3} ∧ insert (array_loc aa1 0 avst3) ls2 = insert (array_loc aa1 0 avst4) ls2 ∧ pc4 = 6 ∧ ls4 ⊆ insert (array_loc aa1 0 avst3) ls2 ∧ ls4 ⊆ insert (array_loc aa1 0 avst4) ls2›*)
subgoal for
by (metis numeral_eq_enat (*‹numeral ?k = enat (numeral ?k)›*))
subgoal for
by (metis Nil_is_map_conv (*‹([] = map ?f ?xs) = (?xs = [])›*))
subgoal for
by metis
subgoal for
by metis
subgoal for
unfolding sstatO'_def
(*goal: ‹⟦(pstate3::predState) = (pstate4::predState) ∧ ((n::enat) = enat ((7::nat) - (pc1::nat)) ∨ n = ∞) ∧ pc1 = (4::nat) ∧ (pc3::nat) = (pc4::nat) ∧ map pcOf (cfgs3::config list) = map pcOf (cfgs4::config list) ∧ pc3 ≤ (6::nat) ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ pc1 ≤ (6::nat) ∧ array_base aa1 (avst1::avstore) = array_base aa1 (avst3::avstore) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ (hh1::nat ⇒ int) = (hh3::nat ⇒ int) ∧ (∀cfg''::config∈set cfgs3. hh1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 (avst2::avstore) = array_base aa1 (avst4::avstore) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ (hh2::nat ⇒ int) = (hh4::nat ⇒ int) ∧ (∀cfg''::config∈set cfgs4. hh2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n::nat. array_loc aa1 (0::nat) avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 (0::nat) avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ ((statA::status) = Diff ⟶ (statO::status) = Diff) ∧ (2::nat) ≤ pc3 ∧ pc3 ≤ (6::nat) ∧ (vs3::char list ⇒ int) xx = (vs4::char list ⇒ int) xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ ((2::nat) < pc1 ⟶ vs3 tt = vs4 tt) ∧ int NN ≤ vs3 xx ∧ (pc1 < (4::nat) ⟶ pc1 = pc3 ∧ (ls1::nat set) = {} ∧ (ls2::nat set) = {} ∧ ls1 = (ls3::nat set) ∧ ls2 = (ls4::nat set)) ∧ (pc1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) avst1} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pc1 ⟶ pc1 ≤ (6::nat) ∧ pc3 = (6::nat)) ∧ (vs1::char list ⇒ int) xx = (vs2::char list ⇒ int) xx ∧ vs1 xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []; (pc2::nat) = (4::nat)⟧ ⟹ statA = Diff ⟶ updStat Diff (isIntV (Config (4::nat) (State (Vstore vs1) avst3 (Heap hh3) (p1::nat)), ibT1::int llist, ibUT1::int llist, ls2), getObsV (Config (4::nat) (State (Vstore vs1) avst3 (Heap hh3) p1), ibT1, ibUT1, ls2)) (isIntV (Config (4::nat) (State (Vstore vs2) avst4 (Heap hh4) (p2::nat)), ibT2::int llist, ibUT2::int llist, ls2), getObsV (Config (4::nat) (State (Vstore vs2) avst4 (Heap hh4) p2), ibT2, ibUT2, ls2)) = Diff›*)
by simp
subgoal for
using a1_0 (*‹array_loc aa1 (0::nat) (avst3::avstore) = array_loc aa1 (0::nat) (avst4::avstore)›*) by force
subgoal for
unfolding a1_0 dist_def pc1 array_loc_def
(*goal: ‹⟦(pstate3::predState) = (pstate4::predState) ∧ ((n::enat) = enat ((7::nat) - (4::nat)) ∨ n = ∞) ∧ (4::nat) = (4::nat) ∧ (pc3::nat) = (pc4::nat) ∧ map pcOf (cfgs3::config list) = map pcOf (cfgs4::config list) ∧ pc3 ≤ (6::nat) ∧ pcOf ` set cfgs3 ⊆ {0::nat..6::nat} ∧ (4::nat) ≤ (6::nat) ∧ array_base aa1 (avst1::avstore) = array_base aa1 (avst3::avstore) ∧ (∀cfg''::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ (hh1::nat ⇒ int) = (hh3::nat ⇒ int) ∧ (∀cfg''::config∈set cfgs3. hh1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 (avst2::avstore) = array_base aa1 (avst4::avstore) ∧ (∀cfg''::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ (hh2::nat ⇒ int) = (hh4::nat ⇒ int) ∧ (∀cfg''::config∈set cfgs4. hh2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n::nat. array_base aa1 avst2 + (0::nat) ≠ array_base aa2 avst2 + n ∧ array_base aa1 avst1 + (0::nat) ≠ array_base aa2 avst1 + n) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ ((statA::status) = Diff ⟶ (statO::status) = Diff) ∧ (2::nat) ≤ pc3 ∧ pc3 ≤ (6::nat) ∧ (vs3::char list ⇒ int) xx = (vs4::char list ⇒ int) xx ∧ (∀cfg3'::config∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'::config∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ ((2::nat) < (4::nat) ⟶ vs3 tt = vs4 tt) ∧ int NN ≤ vs3 xx ∧ ((4::nat) < (4::nat) ⟶ (4::nat) = pc3 ∧ (ls1::nat set) = {} ∧ (ls2::nat set) = {} ∧ ls1 = (ls3::nat set) ∧ ls2 = (ls4::nat set)) ∧ ((4::nat) ≤ (5::nat) ⟶ ls1 ⊆ {array_base aa1 avst1 + (0::nat)} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ sym_diff ls3 ls4 ⊆ sym_diff ls1 ls2 ∧ ((4::nat) ≤ (4::nat) ⟶ (4::nat) ≤ (6::nat) ∧ pc3 = (6::nat)) ∧ (vs1::char list ⇒ int) xx = (vs2::char list ⇒ int) xx ∧ vs1 xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []; (pc2::nat) = (4::nat)⟧ ⟹ insert (array_base aa1 avst3 + (0::nat)) ls2 = insert (array_base aa1 avst4 + (0::nat)) ls2›*)
by simp
subgoal for
by blast
subgoal for
by (simp add: subset_insertI2 (*‹?A ⊆ ?B ⟹ ?A ⊆ insert ?b ?B›*))
subgoal for
by (simp add: subset_insertI2 (*‹?A ⊆ ?B ⟹ ?A ⊆ insert ?b ?B›*)) .
qed
qed
subgoal for
apply (rule disjI1 (*‹?P ⟹ ?P ∨ ?Q›*), rule exI[of _ 1] (*‹?P 1 ⟹ ∃x. ?P x›*), rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹pcOf cfg1 = 5 ⟹ (∃v<n. proact (oor3 Δ1' Δ3' Δe) v ss3 ss4 statA ss1 ss2 statO) ∨ match (oor3 Δ1' Δ3' Δe) ss3 ss4 statA ss1 ss2 statO›*)
subgoal for
using "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) unfolding ss "Δ1'_defs"
(*goal: ‹pcOf cfg1 = 5 ⟹ 1 < n›*)
apply clarify
(*goal: ‹pcOf (cfg1::config) = (5::nat) ⟹ (1::enat) < (n::enat)›*)
apply (erule disjE (*‹⟦(?P::bool) ∨ (?Q::bool); ?P ⟹ ?R::bool; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⟦pcOf cfg1 = 5; pstate3 = pstate4; pcOf cfg3 ∈ {2..6}; n = enat (endPC - pcOf cfg1) ∨ n = ∞; pcOf cfg1 = pcOf cfg2; vstore (getVstore (stateOf cfg3)) xx = vstore (getVstore (stateOf cfg4)) xx; 2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt; pcOf cfg3 = pcOf cfg4; ∀cfg3'∈set []. vstore (getVstore (stateOf cfg3')) xx = vstore (getVstore (stateOf cfg3)) xx; ∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vstore (getVstore (stateOf cfg4)) xx; int NN ≤ vstore (getVstore (stateOf cfg3)) xx; map pcOf [] = map pcOf cfgs4; pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4; pcOf cfg3 ∈ {0..6}; pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4; pcOf ` set [] ⊆ {0..6}; Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2; pcOf cfg1 ∈ {0..6}; 4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ {4..6} ∧ pcOf cfg3 = 6; array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 (getAvstore (stateOf cfg3)); vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx; vstore (getVstore (stateOf cfg1)) xx = 0; vstore (getVstore (stateOf cfg1)) xx = 0; ∀cfg''∈set []. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1)); array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 (getAvstore (stateOf cfg4)); ∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1)); ls3 ⊆ ls1; array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 (getAvstore (stateOf cfg3)); ∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2)); array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)); ls4 ⊆ ls2; cfgs3 = []; ∀cfg''∈set []. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1)); array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 (getAvstore (stateOf cfg4)); ∀cfg3'∈set []. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3)); getHheap (stateOf cfg1) = getHheap (stateOf cfg3); ∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2)); ∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4)); ∀cfg''∈set []. getHheap (stateOf cfg1) = getHheap (stateOf cfg''); getAvstore (stateOf cfg1) = getAvstore (stateOf cfg3); getHheap (stateOf cfg2) = getHheap (stateOf cfg4); array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)); ∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg''); getAvstore (stateOf cfg2) = getAvstore (stateOf cfg4); ∀cfg3'∈set []. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3)); ∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4)); statA = Diff ⟶ statO = Diff⟧ ⟹ 1 < n›*)
subgoalpremises p for
using p(1,47) (*‹pcOf cfg1 = 5› ‹n = enat (endPC - pcOf cfg1)›*) unfolding endPC
(*goal: ‹1 < n›*)
by (simp add: one_enat_def (*‹1 = enat 1›*))
subgoal for
by (metis enat_ord_code( (*‹(enat ?m < ∞) = True›*) 4) one_enat_def (*‹1 = enat 1›*)) .
unfolding proact_def
(*goal: ‹pcOf cfg1 = 5 ⟹ ¬ isSecV ss1 ∧ ¬ isIntV ss1 ∧ move_1 (oor3 Δ1' Δ3' Δe) 1 ss3 ss4 statA ss1 ss2 statO ∨ ¬ isSecV ss2 ∧ ¬ isIntV ss2 ∧ move_2 (oor3 Δ1' Δ3' Δe) 1 ss3 ss4 statA ss1 ss2 statO ∨ ¬ isSecV ss1 ∧ ¬ isSecV ss2 ∧ Van.eqAct ss1 ss2 ∧ move_12 (oor3 Δ1' Δ3' Δe) 1 ss3 ss4 statA ss1 ss2 statO›*)
proof (intro disjI2 (*‹?Q::bool ⟹ (?P::bool) ∨ ?Q›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹pcOf cfg1 = 5 ⟹ ¬ isSecV ss1›
2. ‹pcOf cfg1 = 5 ⟹ ¬ isSecV ss2›
3. ‹pcOf cfg1 = 5 ⟹ Van.eqAct ss1 ss2›
4. ‹pcOf cfg1 = 5 ⟹ move_12 (oor3 Δ1' Δ3' Δe) 1 ss3 ss4 statA ss1 ss2 statO›*)
assume pc: "pcOf cfg1 = 5" (*‹pcOf (cfg1::config) = (5::nat)›*)
show "¬ isSecV ss1"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf cfg1 = 5›*) unfolding "Δ1'_defs" ss cfg
(*goal: ‹¬ isSecV (cfg1, ibT1, ibUT1, ls1)›*)
by auto
show "¬ isSecV ss2"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf (cfg1::config) = (5::nat)›*) unfolding "Δ1'_defs" ss cfg
(*goal: ‹¬ isSecV (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)›*)
by auto
show "Van.eqAct ss1 ss2"
using "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) pc (*‹pcOf cfg1 = 5›*) unfolding "Δ1'_defs" ss cfg Van.eqAct_def
(*goal: ‹isIntV (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) = isIntV (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) ∧ (isIntV (cfg1, ibT1, ibUT1, ls1) ⟶ getActV (cfg1, ibT1, ibUT1, ls1) = getActV (cfg2, ibT2, ibUT2, ls2))›*)
by auto
show "move_12 (oor3 Δ1' Δ3' Δe) 1 ss3 ss4 statA ss1 ss2 statO"
unfolding move_12_def Let_def
(*goal: ‹∃sv1' sv2'. validTransV (ss1, sv1') ∧ validTransV (ss2, sv2') ∧ oor3 Δ1' Δ3' Δe 1 ss3 ss4 statA sv1' sv2' (sstatO' statO ss1 ss2)›*)
proof (rule exI[of _ "nextN ss1"] (*‹?P (nextN ss1) ⟹ ∃x. ?P x›*), rule exI[of _ "nextN ss2"] (*‹(?P::config × int llist × int llist × nat set ⇒ bool) (nextN (ss2::config × int llist × int llist × nat set)) ⟹ ∃x::config × int llist × int llist × nat set. ?P x›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹validTransV (ss1, nextN ss1)›
2. ‹validTransV (ss2, nextN ss2)›
3. ‹oor3 Δ1' Δ3' Δe 1 ss3 ss4 statA (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
show "validTransV (ss1, nextN ss1)"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf cfg1 = 5›*) unfolding validTransV_iff_nextN ss "Δ1'_defs"
(*goal: ‹¬ finalN (cfg1, ibT1, ibUT1, ls1) ∧ nextN (cfg1, ibT1, ibUT1, ls1) = nextN (cfg1, ibT1, ibUT1, ls1)›*)
by simp
show "validTransV (ss2, nextN ss2)"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf cfg1 = 5›*) unfolding validTransV_iff_nextN ss "Δ1'_defs"
(*goal: ‹¬ finalN (cfg2, ibT2, ibUT2, ls2) ∧ nextN (cfg2, ibT2, ibUT2, ls2) = nextN (cfg2, ibT2, ibUT2, ls2)›*)
by simp
show "oor3 Δ1' Δ3' Δe 1 ss3 ss4 statA (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)"
apply (rule oor3I1 (*‹?Δ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO ⟹ oor3 ?Δ ?Δ₂ ?Δ₃ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*goal: ‹oor3 Δ1' Δ3' Δe (1::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf cfg1 = 5›*) unfolding ss cfg cfg1 cfg2 hh h1 h2 endPC
(*goal: ‹Δ1' (1::enat) (pstate3::predState, Config (pc3::nat) (State (Vstore (vs3::char list ⇒ int)) (avst3::avstore) (Heap (hh3::nat ⇒ int)) (p3::nat)), cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, Config (pc4::nat) (State (Vstore (vs4::char list ⇒ int)) (avst4::avstore) (Heap (hh4::nat ⇒ int)) (p4::nat)), cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (nextN (Config (pc1::nat) (State (Vstore (vs1::char list ⇒ int)) (avst1::avstore) (Heap (hh1::nat ⇒ int)) (p1::nat)), ibT1::int llist, ibUT1::int llist, ls1::nat set)) (nextN (Config (pc2::nat) (State (Vstore (vs2::char list ⇒ int)) (avst2::avstore) (Heap (hh2::nat ⇒ int)) (p2::nat)), ibT2::int llist, ibUT2::int llist, ls2::nat set)) (sstatO' (statO::status) (Config pc1 (State (Vstore vs1) avst1 (Heap hh1) p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 (Heap hh2) p2), ibT2, ibUT2, ls2))›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*))
(*goal: ‹Δ1' 1 (pstate3, Config pc3 (State (Vstore vs3) avst3 (Heap hh3) p3), cfgs3, ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 (Heap hh4) p4), cfgs4, ibT4, ibUT4, ls4) statA (nextN (Config pc1 (State (Vstore vs1) avst1 (Heap hh1) p1), ibT1, ibUT1, ls1)) (nextN (Config pc2 (State (Vstore vs2) avst2 (Heap hh2) p2), ibT2, ibUT2, ls2)) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 (Heap hh1) p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 (Heap hh2) p2), ibT2, ibUT2, ls2))›*)
apply -
(*goal: ‹⟦pstate3 = pstate4 ∧ (n = enat (7 - pc1) ∨ n = ∞) ∧ pc1 = 5 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pc1 ≤ 6 ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hh1 = hh3 ∧ (∀cfg''∈set cfgs3. hh1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hh2 = hh4 ∧ (∀cfg''∈set cfgs4. hh2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ (2 < pc1 ⟶ vs3 tt = vs4 tt) ∧ int NN ≤ vs3 xx ∧ (pc1 < 4 ⟶ pc1 = pc3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pc1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 avst1} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pc1 ⟶ pc1 ≤ 6 ∧ pc3 = 6) ∧ vs1 xx = vs2 xx ∧ vs1 xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []; pc2 = 5⟧ ⟹ enat (Suc 0) = 1 ∧ cfgs4 = [] ∧ (∀cfg''∈set cfgs4. hh4 = getHheap (stateOf cfg'')) ∧ (∀n. array_loc aa1 0 avst4 ≠ array_loc aa2 n avst4 ∧ array_loc aa1 0 avst3 ≠ array_loc aa2 n avst3) ∧ (statA = Diff ⟶ sstatO' Diff (Config 5 (State (Vstore vs1) avst3 (Heap hh3) p1), ibT1, ibUT1, ls2) (Config 5 (State (Vstore vs2) avst4 (Heap hh4) p2), ibT2, ibUT2, ls2) = Diff) ∧ pc4 = 6 ∧ ls4 ⊆ insert (array_loc aa2 (nat (vs1 vv * 512)) avst3) ls2 ∧ ls4 ⊆ insert (array_loc aa2 (nat (vs2 vv * 512)) avst4) ls2›*)
apply (intro conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹⟦pstate3 = pstate4 ∧ (n = enat (7 - pc1) ∨ n = ∞) ∧ pc1 = 5 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pc1 ≤ 6 ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hh1 = hh3 ∧ (∀cfg''∈set cfgs3. hh1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hh2 = hh4 ∧ (∀cfg''∈set cfgs4. hh2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ (2 < pc1 ⟶ vs3 tt = vs4 tt) ∧ int NN ≤ vs3 xx ∧ (pc1 < 4 ⟶ pc1 = pc3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pc1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 avst1} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pc1 ⟶ pc1 ≤ 6 ∧ pc3 = 6) ∧ vs1 xx = vs2 xx ∧ vs1 xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []; pc2 = 5⟧ ⟹ enat (Suc 0) = 1 ∧ cfgs4 = [] ∧ (∀cfg''∈set cfgs4. hh4 = getHheap (stateOf cfg'')) ∧ (∀n. array_loc aa1 0 avst4 ≠ array_loc aa2 n avst4 ∧ array_loc aa1 0 avst3 ≠ array_loc aa2 n avst3) ∧ (statA = Diff ⟶ sstatO' Diff (Config 5 (State (Vstore vs1) avst3 (Heap hh3) p1), ibT1, ibUT1, ls2) (Config 5 (State (Vstore vs2) avst4 (Heap hh4) p2), ibT2, ibUT2, ls2) = Diff) ∧ pc4 = 6 ∧ ls4 ⊆ insert (array_loc aa2 (nat (vs1 vv * 512)) avst3) ls2 ∧ ls4 ⊆ insert (array_loc aa2 (nat (vs2 vv * 512)) avst4) ls2›*)
subgoal for
by (metis One_nat_def (*‹1 = Suc 0›*) one_enat_def (*‹1 = enat 1›*))
subgoal for
by (metis Nil_is_map_conv (*‹([] = map ?f ?xs) = (?xs = [])›*))
subgoal for
by metis
subgoal for
by metis
subgoal for
unfolding sstatO'_def
(*goal: ‹⟦pstate3 = pstate4 ∧ (n = enat (7 - pc1) ∨ n = ∞) ∧ pc1 = 5 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ pc1 ≤ 6 ∧ array_base aa1 avst1 = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst1) ∧ array_base aa2 avst1 = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst1) ∧ hh1 = hh3 ∧ (∀cfg''∈set cfgs3. hh1 = getHheap (stateOf cfg'')) ∧ avst1 = avst3 ∧ array_base aa1 avst2 = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 avst2) ∧ array_base aa2 avst2 = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 avst2) ∧ hh2 = hh4 ∧ (∀cfg''∈set cfgs4. hh2 = getHheap (stateOf cfg'')) ∧ avst2 = avst4 ∧ (∀n. array_loc aa1 0 avst2 ≠ array_loc aa2 n avst2 ∧ array_loc aa1 0 avst1 ≠ array_loc aa2 n avst1) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ (2 < pc1 ⟶ vs3 tt = vs4 tt) ∧ int NN ≤ vs3 xx ∧ (pc1 < 4 ⟶ pc1 = pc3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pc1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 avst1} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pc1 ⟶ pc1 ≤ 6 ∧ pc3 = 6) ∧ vs1 xx = vs2 xx ∧ vs1 xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []; pc2 = 5⟧ ⟹ statA = Diff ⟶ updStat Diff (isIntV (Config 5 (State (Vstore vs1) avst3 (Heap hh3) p1), ibT1, ibUT1, ls2), getObsV (Config 5 (State (Vstore vs1) avst3 (Heap hh3) p1), ibT1, ibUT1, ls2)) (isIntV (Config 5 (State (Vstore vs2) avst4 (Heap hh4) p2), ibT2, ibUT2, ls2), getObsV (Config 5 (State (Vstore vs2) avst4 (Heap hh4) p2), ibT2, ibUT2, ls2)) = Diff›*)
by simp
subgoal for
by (metis Suc_n_not_le_n (*‹¬ Suc ?n ≤ ?n›*) eval_nat_numeral( (*‹numeral (num.Bit1 ?n) = Suc (numeral (num.Bit0 ?n))›*) 3) nat_le_linear (*‹?m ≤ ?n ∨ ?n ≤ ?m›*))
subgoal for
by (metis atThenOutput_def (*‹atThenOutput = 5›*) insert_compr (*‹insert ?a ?B = {x. x = ?a ∨ x ∈ ?B}›*) less_or_eq_imp_le (*‹?m < ?n ∨ ?m = ?n ⟹ ?m ≤ ?n›*) mult.commute (*‹?a * ?b = ?b * ?a›*) nat_numeral (*‹nat (numeral ?k) = numeral ?k›*) pc (*‹pcOf cfg1 = 5›*) subset_insertI2 (*‹?A ⊆ ?B ⟹ ?A ⊆ insert ?b ?B›*))
subgoal for
by (simp add: subset_insertI2 (*‹?A ⊆ ?B ⟹ ?A ⊆ insert ?b ?B›*)) .
qed
qed
subgoal for
proof (rule match12I (*‹match12 (oor3 Δ1' Δ3' Δe) ?ss3.0 ?ss4.0 ?statA ?ss1.0 ?ss2.0 ?statO ⟹ (∃v<?n. proact (oor3 Δ1' Δ3' Δe) v ?ss3.0 ?ss4.0 ?statA ?ss1.0 ?ss2.0 ?statO) ∨ match (oor3 Δ1' Δ3' Δe) ?ss3.0 ?ss4.0 ?statA ?ss1.0 ?ss2.0 ?statO›*), rule match12_simpleI (*‹(⋀s1' s2' statA'. ⟦statA' = sstatA' ?statA ?s1.0 ?s2.0; validTransO (?s1.0, s1'); validTransO (?s2.0, s2'); Opt.eqAct ?s1.0 ?s2.0⟧ ⟹ ¬ isSecO ?s1.0 ∧ ¬ isSecO ?s2.0 ∧ (?statA = statA' ∨ ?statO = Diff) ∧ ?Δ ∞ s1' s2' statA' ?sv1.0 ?sv2.0 ?statO ∨ eqSec ?sv1.0 ?s1.0 ∧ eqSec ?sv2.0 ?s2.0 ∧ Van.eqAct ?sv1.0 ?sv2.0 ∧ match12_12 ?Δ s1' s2' statA' ?sv1.0 ?sv2.0 ?statO) ⟹ match12 ?Δ ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*), rule disjI2 (*‹?Q ⟹ ?P ∨ ?Q›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⋀s1' s2' statA'. ⟦pcOf cfg1 = 6; statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ eqSec ss1 ss3›
2. ‹⋀s1' s2' statA'. ⟦pcOf cfg1 = 6; statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ eqSec ss2 ss4›
3. ‹⋀s1' s2' statA'. ⟦pcOf cfg1 = 6; statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ Van.eqAct ss1 ss2›
4. ‹⋀s1' s2' statA'. ⟦pcOf cfg1 = 6; statA' = sstatA' statA ss3 ss4; validTransO (ss3, s1'); validTransO (ss4, s2'); Opt.eqAct ss3 ss4⟧ ⟹ match12_12 (oor3 Δ1' Δ3' Δe) s1' s2' statA' ss1 ss2 statO›*)
fix ss3' and ss4' and statA'
assume statA': "statA' = sstatA' statA ss3 ss4" and v: "validTransO (ss3, ss3')" "validTransO (ss4, ss4')" and sa: "Opt.eqAct ss3 ss4" and pc: "pcOf cfg1 = 6" (*‹(statA'::status) = sstatA' (statA::status) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss3::predState × config × config list × int llist × int llist × nat set, ss3'::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss4::predState × config × config list × int llist × int llist × nat set, ss4'::predState × config × config list × int llist × int llist × nat set)› ‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)› ‹pcOf (cfg1::config) = (6::nat)›*)
note v3 = v(1) (*‹validTransO (ss3, ss3')›*)
note v4 = v(2) (*‹validTransO (ss4, ss4')›*)
obtain pstate3' and cfg3' and cfgs3' and ibT3' and ibUT3' and ls3' where ss3': "ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')"
(*goal: ‹(⋀pstate3' cfg3' cfgs3' ibT3' ibUT3' ls3'. ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') ⟹ thesis) ⟹ thesis›*)
apply (cases ss3')
(*goal: ‹(⋀(pstate3'::predState) (cfg3'::config) (cfgs3'::config list) (ibT3'::int llist) (ibUT3'::int llist) ls3'::nat set. (ss3'::predState × config × config list × int llist × int llist × nat set) = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') ⟹ thesis::bool) ⟹ thesis›*)
by auto
obtain pstate4' and cfg4' and cfgs4' and ibT4' and ibUT4' and ls4' where ss4': "ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')"
(*goal: ‹(⋀pstate4' cfg4' cfgs4' ibT4' ibUT4' ls4'. ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') ⟹ thesis) ⟹ thesis›*)
apply (cases ss4')
(*goal: ‹(⋀pstate4' cfg4' cfgs4' ibT4' ibUT4' ls4'. ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') ⟹ thesis) ⟹ thesis›*)
by auto
note ss = ss (*‹(ss3::predState × config × config list × int llist × int llist × nat set) = (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set)› ‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)› ‹(ss1::config × int llist × int llist × nat set) = (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)› ‹ss2 = (cfg2, ibT2, ibUT2, ls2)›*) ss3' (*‹(ss3'::predState × config × config list × int llist × int llist × nat set) = (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set)›*) ss4' (*‹ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*)
show "eqSec ss1 ss3"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹eqSec (cfg1, ibT1, ibUT1, ls1) (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*))
(*goal: ‹eqSec (cfg1, ibT1, ibUT1, ls1) (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)›*)
by (metis not_gr_zero (*‹(¬ 0 < ?n) = (?n = 0)›*) not_numeral_le_zero (*‹¬ numeral ?n ≤ 0›*) zero_less_numeral (*‹0 < numeral ?n›*))
show "eqSec ss2 ss4"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹eqSec (cfg2, ibT2, ibUT2, ls2) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
(*goal: ‹eqSec (cfg2, ibT2, ibUT2, ls2) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
by (metis not_gr_zero (*‹(¬ 0 < ?n) = (?n = 0)›*) not_numeral_le_zero (*‹¬ numeral ?n ≤ 0›*) zero_neq_numeral (*‹0 ≠ numeral ?n›*))
show "Van.eqAct ss1 ss2"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss Van.eqAct_def
(*goal: ‹isIntV (cfg1, ibT1, ibUT1, ls1) = isIntV (cfg2, ibT2, ibUT2, ls2) ∧ (isIntV (cfg1, ibT1, ibUT1, ls1) ⟶ getActV (cfg1, ibT1, ibUT1, ls1) = getActV (cfg2, ibT2, ibUT2, ls2))›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
(*goal: ‹isIntV (cfg1, ibT1, ibUT1, ls1) = isIntV (cfg2, ibT2, ibUT2, ls2) ∧ (isIntV (cfg1, ibT1, ibUT1, ls1) ⟶ getActV (cfg1, ibT1, ibUT1, ls1) = getActV (cfg2, ibT2, ibUT2, ls2))›*)
by (metis Δ1' (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) Δ1'_implies (*‹Δ1' ?num (?pstate3.0, ?cfg3.0, ?cfgs3.0, ?ibT3.0, ?ibUT3.0, ?ls3.0) (?pstate4.0, ?cfg4.0, ?cfgs4.0, ?ibT4.0, ?ibUT4.0, ?ls4.0) ?statA (?cfg1.0, ?ibT1.0, ?ibUT1.0, ?ls1.0) (?cfg2.0, ?ibT2.0, ?ibUT2.0, ?ls2.0) ?statO ⟹ pcOf ?cfg1.0 < 7 ∧ pcOf ?cfg1.0 ≠ Suc 0 ∧ pcOf ?cfg2.0 = pcOf ?cfg1.0 ∧ ?cfgs3.0 = [] ∧ pcOf ?cfg3.0 < 7 ∧ ?cfgs4.0 = [] ∧ pcOf ?cfg4.0 < 7›*) ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)› ‹ss1 = (cfg1, ibT1, ibUT1, ls1)› ‹ss2 = (cfg2, ibT2, ibUT2, ls2)› ‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')› ‹ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*))
show "match12_12 (oor3 Δ1' Δ3' Δe) ss3' ss4' statA' ss1 ss2 statO"
unfolding match12_12_def
(*goal: ‹∃sv1' sv2'. let statO' = sstatO' statO ss1 ss2 in validTransV (ss1, sv1') ∧ validTransV (ss2, sv2') ∧ (statA' = Diff ⟶ statO' = Diff) ∧ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' sv1' sv2' statO'›*)
proof (rule exI[of _ "nextN ss1"] (*‹?P (nextN ss1) ⟹ ∃x. ?P x›*), rule exI[of _ "nextN ss2"] (*‹?P (nextN ss2) ⟹ ∃x. ?P x›*), unfold Let_def (*‹Let ?s ?f ≡ ?f ?s›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goals:
1. ‹validTransV (ss1, nextN ss1)›
2. ‹validTransV (ss2, nextN ss2)›
3. ‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›
4. ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
show "validTransV (ss1, nextN ss1)"
by (simp add: f1 (*‹¬ finalN ss1›*) nextN_stepN (*‹¬ finalN ?cfg_ib_ls ⟹ ?cfg_ib_ls →N nextN ?cfg_ib_ls›*))
show "validTransV (ss2, nextN ss2)"
by (simp add: f2 (*‹¬ finalN ss2›*) nextN_stepN (*‹¬ finalN ?cfg_ib_ls ⟹ ?cfg_ib_ls →N nextN ?cfg_ib_ls›*))
have cfgs4: "cfgs4 = []"
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss "Δ1'_defs"
(*goal: ‹(cfgs4::config list) = []›*)
apply clarify
(*goal: ‹cfgs4 = []›*)
by (metis map_is_Nil_conv (*‹(map ?f ?xs = []) = (?xs = [])›*))
{
assume sstat: "statA' = Diff" (*‹(statA'::status) = Diff›*)
show "sstatO' statO ss1 ss2 = Diff"
using v (*‹validTransO (ss3::predState × config × config list × int llist × int llist × nat set, ss3'::predState × config × config list × int llist × int llist × nat set)› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) sstat (*‹(statA'::status) = Diff›*) pc (*‹pcOf (cfg1::config) = (6::nat)›*) unfolding ss cfg statA'
(*goal: ‹sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff›*)
apply (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*) sstatO'_def (*‹sstatO' ?statO ?sv1.0 ?sv2.0 = updStat ?statO (isIntV ?sv1.0, getObsV ?sv1.0) (isIntV ?sv2.0, getObsV ?sv2.0)›*) sstatA'_def (*‹sstatA' ?statA ?s1.0 ?s2.0 = updStat ?statA (isIntO ?s1.0, getObsO ?s1.0) (isIntO ?s2.0, getObsO ?s2.0)›*))
(*goal: ‹sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) = Diff›*)
apply (cases statO, simp_all)
(*goal: ‹⟦pstate3' = pstate4 ∧ (cfg3', ibT3', ibUT3') = nextB (Config pc4 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3) ∧ cfgs3' = [] ∧ ls3' = ls3 ∪ readLocs (Config pc4 (State (Vstore vs3) avst3 h3 p3)); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ (n = enat (Suc 0) ∨ n = ∞) ∧ pcOf cfg2 = 6 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = hheap h3 ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ (statA = Diff ⟶ statO = Diff) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 tt = vs4 tt ∧ int NN ≤ vs3 xx ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ pc3 = 6 ∧ vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), case prog ! pc4 of Output T aexp ⇒ aval aexp (State (Vstore vs3) avst3 h3 p3) | Output U aexp ⇒ ⊥ | _ ⇒ ⊥, ls3) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; pcOf cfg1 = 6⟧ ⟹ updStat statO (True, ⊥, ls1) (True, ⊥, ls2) = Diff›*)
apply (cases statA, simp_all)
(*goal: ‹⟦pstate3' = pstate4 ∧ (cfg3', ibT3', ibUT3') = nextB (Config pc4 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3) ∧ cfgs3' = [] ∧ ls3' = ls3 ∪ readLocs (Config pc4 (State (Vstore vs3) avst3 h3 p3)); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ (n = enat (Suc 0) ∨ n = ∞) ∧ pcOf cfg2 = 6 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = hheap h3 ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ statA ≠ Diff ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 tt = vs4 tt ∧ int NN ≤ vs3 xx ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ pc3 = 6 ∧ vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []; updStat statA (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), case prog ! pc4 of Output T aexp ⇒ aval aexp (State (Vstore vs3) avst3 h3 p3) | Output U aexp ⇒ ⊥ | _ ⇒ ⊥, ls3) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; pcOf cfg1 = 6; statO = status.Eq⟧ ⟹ ls1 ≠ ls2›*)
using cfg (*‹cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)› ‹cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)›*) finals (*‹¬ finalN (ss1::config × int llist × int llist × nat set)› ‹¬ finalN ss2› ‹¬ finalS (ss3::predState × config × config list × int llist × int llist × nat set)› ‹¬ finalS ss4›*) ss (*‹ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)› ‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)› ‹ss1 = (cfg1, ibT1, ibUT1, ls1)› ‹ss2 = (cfg2, ibT2, ibUT2, ls2)› ‹ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')› ‹ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')›*) apply (simp split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
(*goal: ‹⟦pstate3' = pstate4 ∧ (cfg3', ibT3', ibUT3') = nextB (Config pc4 (State (Vstore vs3) avst3 h3 p3), ibT3, ibUT3) ∧ cfgs3' = [] ∧ ls3' = ls3 ∪ readLocs (Config pc4 (State (Vstore vs3) avst3 h3 p3)); (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4) →S (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4'); Opt.eqAct (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4); pstate3 = pstate4 ∧ (n = enat (Suc 0) ∨ n = ∞) ∧ pcOf cfg2 = 6 ∧ pc3 = pc4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pc3 ≤ 6 ∧ pcOf ` set cfgs3 ⊆ {0..6} ∧ array_base aa1 (getAvstore (stateOf cfg1)) = array_base aa1 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg1))) ∧ array_base aa2 (getAvstore (stateOf cfg1)) = array_base aa2 avst3 ∧ (∀cfg''∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg1))) ∧ getHheap (stateOf cfg1) = hheap h3 ∧ (∀cfg''∈set cfgs3. getHheap (stateOf cfg1) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg1) = avst3 ∧ array_base aa1 (getAvstore (stateOf cfg2)) = array_base aa1 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf cfg2))) ∧ array_base aa2 (getAvstore (stateOf cfg2)) = array_base aa2 avst4 ∧ (∀cfg''∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf cfg2))) ∧ getHheap (stateOf cfg2) = hheap h4 ∧ (∀cfg''∈set cfgs4. getHheap (stateOf cfg2) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf cfg2) = avst4 ∧ (∀n. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 avst3 = array_base aa1 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 avst4) ∧ array_base aa2 avst3 = array_base aa2 avst4 ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 avst3) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 avst4) ∧ 2 ≤ pc3 ∧ pc3 ≤ 6 ∧ vs3 xx = vs4 xx ∧ (∀cfg3'∈set cfgs3. vstore (getVstore (stateOf cfg3')) xx = vs3 xx) ∧ (∀cfg4'∈set cfgs4. vstore (getVstore (stateOf cfg4')) xx = vs4 xx) ∧ vs3 tt = vs4 tt ∧ int NN ≤ vs3 xx ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ pc3 = 6 ∧ vstore (getVstore (stateOf cfg1)) xx = vstore (getVstore (stateOf cfg2)) xx ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ cfgs3 = []; updStat status.Eq (¬ finalS (pstate4, Config pc4 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3), case prog ! pc4 of Output T aexp ⇒ aval aexp (State (Vstore vs3) avst3 h3 p3) | Output U aexp ⇒ ⊥ | _ ⇒ ⊥, ls3) (¬ finalS (pstate4, Config pc4 (State (Vstore vs4) avst4 h4 p4), cfgs4, ibT4, ibUT4, ls4), if cfgs4 = [] then (outOf (prog ! pcOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))) (stateOf (Config pc4 (State (Vstore vs4) avst4 h4 p4))), ls4) else ⊥) = Diff; pcOf cfg1 = 6; statO = status.Eq; statA = status.Eq⟧ ⟹ ls1 ≠ ls2›*)
unfolding dist_def
(*goal: ‹⟦pcOf cfg1 = 6; statO = status.Eq; statA = status.Eq; cfg3 = Config 6 (State (Vstore vs3) avst3 h3 p3); cfg4 = Config 6 (State (Vstore vs4) avst4 h4 p4); ¬ finalS (pstate4, Config 6 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); ¬ finalS (pstate4, Config 6 (State (Vstore vs4) avst4 h4 p4), [], ibT4, ibUT4, ls4); ss3 = (pstate4, Config 6 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); ss4 = (pstate4, Config 6 (State (Vstore vs4) avst4 h4 p4), [], ibT4, ibUT4, ls4); ss1 = (cfg1, ibT1, ibUT1, ls1); ss2 = (cfg2, ibT2, ibUT2, ls2); ss3' = (pstate4, Config 7 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3); ss4' = (pstate4, Config 7 (State (Vstore vs4) avst4 h4 p4), [], ibT4, ibUT4, ls4); pstate4' = pstate4 ∧ cfg4' = Config 7 (State (Vstore vs4) avst4 h4 p4) ∧ ibT4' = ibT4 ∧ ibUT4' = ibUT4 ∧ cfgs4' = [] ∧ ls4' = ls4; Opt.eqAct (pstate4, Config 6 (State (Vstore vs3) avst3 h3 p3), [], ibT3, ibUT3, ls3) (pstate4, Config 6 (State (Vstore vs4) avst4 h4 p4), [], ibT4, ibUT4, ls4); ls3 ≠ ls4; pstate3' = pstate4; pstate3 = pstate4; cfg3' = Config 7 (State (Vstore vs3) avst3 h3 p3) ∧ ibT3' = ibT3 ∧ ibUT3' = ibUT3; n = enat (Suc 0) ∨ n = ∞; cfgs3' = []; ls3' = ls3; pcOf cfg2 = 6; pc4 = 6; cfgs4 = []; getHheap (stateOf cfg1) = hheap h3; getAvstore (stateOf cfg1) = avst3; getHheap (stateOf cfg2) = hheap h4; getAvstore (stateOf cfg2) = avst4; ∀n. array_loc aa1 0 avst4 ≠ array_loc aa2 n avst4 ∧ array_loc aa1 0 avst3 ≠ array_loc aa2 n avst3; array_base aa1 avst3 = array_base aa1 avst4; array_base aa2 avst3 = array_base aa2 avst4; vs3 xx = vs4 xx; vs3 tt = vs4 tt; int NN ≤ vs4 xx; sym_diff ls3 ls4 ⊆ sym_diff ls1 ls2; pc3 = 6; vstore (getVstore (stateOf cfg2)) xx = 0; vstore (getVstore (stateOf cfg1)) xx = 0; ls3 ⊆ ls1; ls4 ⊆ ls2; cfgs3 = []⟧ ⟹ ls1 ≠ ls2›*)
by blast
}
note stat = this (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*)
have pc4: "pc4 = 6"
using v (*‹validTransO (ss3, ss3')› ‹validTransO (ss4, ss4')›*) sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) pc (*‹pcOf cfg1 = 6›*) unfolding ss cfg
(*goal: ‹(pc4::nat) = (6::nat)›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
have notJump: "¬is_IfJump (prog ! pcOf cfg3)"
using "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) pc (*‹pcOf cfg1 = 6›*) unfolding ss "Δ1'_defs"
(*goal: ‹¬ is_IfJump (prog ! pcOf cfg3)›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*) sstatO'_def (*‹sstatO' ?statO ?sv1.0 ?sv2.0 = updStat ?statO (isIntV ?sv1.0, getObsV ?sv1.0) (isIntV ?sv2.0, getObsV ?sv2.0)›*) sstatA'_def (*‹sstatA' ?statA ?s1.0 ?s2.0 = updStat ?statA (isIntO ?s1.0, getObsO ?s1.0) (isIntO ?s2.0, getObsO ?s2.0)›*))
show "(oor3 Δ1' Δ3' Δe) ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)"
using v3[unfolded ss, simplified] (*‹(pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) →S (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set)›*) proof (cases rule: stepS_cases (*‹⟦(?pstate, ?cfg, ?cfgs, ?ibT, ?ibUT, ?ls) →S (?pstate', ?cfg', ?cfgs', ?ibT', ?ibUT', ?ls'); ⟦?cfgs = []; ¬ is_IfJump (prog ! pcOf ?cfg) ∨ ¬ mispred ?pstate [pcOf ?cfg]; ?pstate' = ?pstate; ¬ finalB (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ?cfgs' = []; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs = []; is_IfJump (prog ! pcOf ?cfg); mispred ?pstate [pcOf ?cfg]; ?pstate' = update ?pstate [pcOf ?cfg]; ¬ finalM (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (?cfg, ?ibT, ?ibUT) ∧ ?cfgs' = [cfg1']; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ is_IfJump (prog ! pcOf (last ?cfgs)) ∨ ¬ mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) ≠ Fence; ?pstate' = ?pstate; ¬ is_getInput (prog ! pcOf (last ?cfgs)); ¬ is_Output (prog ! pcOf (last ?cfgs)); ?cfg' = ?cfg; ?ls' = ?ls ∪ readLocs (last ?cfgs); ∃cfg1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (cfg1', ?ibT', ?ibUT') ∧ ?cfgs' = butlast ?cfgs ## cfg1'⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); is_IfJump (prog ! pcOf (last ?cfgs)); mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ finalM (last ?cfgs, ?ibT, ?ibUT); ?cfg' = ?cfg; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last ?cfgs, ?ibT, ?ibUT) = (lcfg', ?ibT', ?ibUT') ∧ (cfg1', ibT1', ibUT1') = nextM (last ?cfgs, ?ibT, ?ibUT) ∧ ?cfgs' = butlast ?cfgs @ [lcfg'] ## cfg1'; ?ls' = ?ls ∪ readLocs (last ?cfgs)⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) = Fence; ?pstate' = ?pstate; ?cfg' = ?cfg; ?cfgs' = []; ?ibT' = ?ibT; ?ibUT' = ?ibUT; ?ls' = ?ls⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?cfg' = ?cfg; ?cfgs' = butlast ?cfgs; ?ls' = ?ls; ?ibT' = ?ibT; ?ibUT' = ?ibUT⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) ≠ Fence; pstate3' = pstate3; ¬ is_getInput (prog ! pcOf (last cfgs3)); ¬ is_Output (prog ! pcOf (last cfgs3)); cfg3' = cfg3; ls3' = ls3 ∪ readLocs (last cfgs3); ∃cfg1'. nextB (last cfgs3, ibT3, ibUT3) = (cfg1', ibT3', ibUT3') ∧ cfgs3' = butlast cfgs3 ## cfg1'⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3, ibUT3); cfg3' = cfg3; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'; ls3' = ls3 ∪ readLocs (last cfgs3)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
6. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_normal (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹¬ is_IfJump (prog ! pcOf (last cfgs3)) ∨ ¬ mispred pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹prog ! pcOf (last cfgs3) ≠ Fence› ‹pstate3' = pstate3› ‹¬ is_getInput (prog ! pcOf (last (cfgs3::config list)))› ‹¬ is_Output (prog ! pcOf (last cfgs3))› ‹cfg3' = cfg3› ‹(ls3'::nat set) = (ls3::nat set) ∪ readLocs (last (cfgs3::config list))› ‹∃cfg1'. nextB (last cfgs3, ibT3, ibUT3) = (cfg1', ibT3', ibUT3') ∧ cfgs3' = butlast cfgs3 ## cfg1'›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (nextN (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)) (nextN (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)) (sstatO' (statO::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); is_IfJump (prog ! pcOf (last cfgs3)); mispred pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); ¬ finalM (last cfgs3, ibT3, ibUT3); cfg3' = cfg3; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'; ls3' = ls3 ∪ readLocs (last cfgs3)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_mispred (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹is_IfJump (prog ! pcOf (last cfgs3))› ‹mispred pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹¬ finalM (last cfgs3, ibT3, ibUT3)› ‹(cfg3'::config) = (cfg3::config)› ‹∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs3, ibT3, ibUT3) = (lcfg', ibT3', ibUT3') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs3, ibT3, ibUT3) ∧ cfgs3' = butlast cfgs3 @ [lcfg'] ## cfg1'› ‹ls3' = ls3 ∪ readLocs (last cfgs3)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; ¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); prog ! pcOf (last cfgs3) = Fence; pstate3' = pstate3; cfg3' = cfg3; cfgs3' = []; ibT3' = ibT3; ibUT3' = ibUT3; ls3' = ls3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_Fence (*‹cfgs3 ≠ []› ‹¬ resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹prog ! pcOf (last cfgs3) = Fence› ‹pstate3' = pstate3› ‹(cfg3'::config) = (cfg3::config)› ‹cfgs3' = []› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3› ‹ls3' = ls3›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs3 = []; is_IfJump (prog ! pcOf cfg3); mispred pstate3 [pcOf cfg3]; pstate3' = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs3 ≠ []; resolve pstate3 (pcOf cfg3 # map pcOf cfgs3); pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3); cfg3' = cfg3; cfgs3' = butlast cfgs3; ls3' = ls3; ibT3' = ibT3; ibUT3' = ibUT3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_resolve (*‹cfgs3 ≠ []› ‹resolve pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹pstate3' = update pstate3 (pcOf cfg3 # map pcOf cfgs3)› ‹cfg3' = cfg3› ‹(cfgs3'::config list) = butlast (cfgs3::config list)› ‹(ls3'::nat set) = (ls3::nat set)› ‹ibT3' = ibT3› ‹ibUT3' = ibUT3›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*))
next
(*goals:
1. ‹⟦(cfgs3::config list) = []; ¬ is_IfJump (prog ! pcOf (cfg3::config)) ∨ ¬ mispred (pstate3::predState) [pcOf cfg3]; (pstate3'::predState) = pstate3; ¬ finalB (cfg3, ibT3::int llist, ibUT3::int llist); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3, ibT3, ibUT3); (cfgs3'::config list) = []; (ls3'::nat set) = (ls3::nat set) ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
2. ‹⟦(cfgs3::config list) = []; is_IfJump (prog ! pcOf (cfg3::config)); mispred (pstate3::predState) [pcOf cfg3]; (pstate3'::predState) = update pstate3 [pcOf cfg3]; ¬ finalM (cfg3, ibT3::int llist, ibUT3::int llist); (cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3, ibT3, ibUT3); ∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ (cfgs3'::config list) = [cfg1']; (ls3'::nat set) = (ls3::nat set) ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
case nonspec_mispred (*‹cfgs3 = []› ‹is_IfJump (prog ! pcOf cfg3)› ‹mispred pstate3 [pcOf cfg3]› ‹pstate3' = update pstate3 [pcOf cfg3]› ‹¬ finalM (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg3, ibT3, ibUT3) ∧ cfgs3' = [cfg1']› ‹ls3' = ls3 ∪ readLocs cfg3›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using notJump (*‹¬ is_IfJump (prog ! pcOf cfg3)›*) by auto
next
(*goal: ‹⟦cfgs3 = []; ¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]; pstate3' = pstate3; ¬ finalB (cfg3, ibT3, ibUT3); (cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3); cfgs3' = []; ls3' = ls3 ∪ readLocs cfg3⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_normal (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf (cfg3::config)) ∨ ¬ mispred (pstate3::predState) [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*)
note nn3 = nonspec_normal (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*)
show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using v4[unfolded ss, simplified] (*‹(pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) →S (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set)›*) proof (cases rule: stepS_cases (*‹⟦(?pstate::predState, ?cfg::config, ?cfgs::config list, ?ibT::int llist, ?ibUT::int llist, ?ls::nat set) →S (?pstate'::predState, ?cfg'::config, ?cfgs'::config list, ?ibT'::int llist, ?ibUT'::int llist, ?ls'::nat set); ⟦?cfgs = []; ¬ is_IfJump (prog ! pcOf ?cfg) ∨ ¬ mispred ?pstate [pcOf ?cfg]; ?pstate' = ?pstate; ¬ finalB (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ?cfgs' = []; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis::bool; ⟦?cfgs = []; is_IfJump (prog ! pcOf ?cfg); mispred ?pstate [pcOf ?cfg]; ?pstate' = update ?pstate [pcOf ?cfg]; ¬ finalM (?cfg, ?ibT, ?ibUT); (?cfg', ?ibT', ?ibUT') = nextB (?cfg, ?ibT, ?ibUT); ∃(cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. (cfg1', ibT1', ibUT1') = nextM (?cfg, ?ibT, ?ibUT) ∧ ?cfgs' = [cfg1']; ?ls' = ?ls ∪ readLocs ?cfg⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ is_IfJump (prog ! pcOf (last ?cfgs)) ∨ ¬ mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) ≠ Fence; ?pstate' = ?pstate; ¬ is_getInput (prog ! pcOf (last ?cfgs)); ¬ is_Output (prog ! pcOf (last ?cfgs)); ?cfg' = ?cfg; ?ls' = ?ls ∪ readLocs (last ?cfgs); ∃cfg1'::config. nextB (last ?cfgs, ?ibT, ?ibUT) = (cfg1', ?ibT', ?ibUT') ∧ ?cfgs' = butlast ?cfgs ## cfg1'⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); is_IfJump (prog ! pcOf (last ?cfgs)); mispred ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ¬ finalM (last ?cfgs, ?ibT, ?ibUT); ?cfg' = ?cfg; ∃(lcfg'::config) (cfg1'::config) (ibT1'::int llist) ibUT1'::int llist. nextB (last ?cfgs, ?ibT, ?ibUT) = (lcfg', ?ibT', ?ibUT') ∧ (cfg1', ibT1', ibUT1') = nextM (last ?cfgs, ?ibT, ?ibUT) ∧ ?cfgs' = butlast ?cfgs @ [lcfg'] ## cfg1'; ?ls' = ?ls ∪ readLocs (last ?cfgs)⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; ¬ resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); prog ! pcOf (last ?cfgs) = Fence; ?pstate' = ?pstate; ?cfg' = ?cfg; ?cfgs' = []; ?ibT' = ?ibT; ?ibUT' = ?ibUT; ?ls' = ?ls⟧ ⟹ ?thesis; ⟦?cfgs ≠ []; resolve ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?pstate' = update ?pstate (pcOf ?cfg # map pcOf ?cfgs); ?cfg' = ?cfg; ?cfgs' = butlast ?cfgs; ?ls' = ?ls; ?ibT' = ?ibT; ?ibUT' = ?ibUT⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 = []; is_IfJump (prog ! pcOf cfg4); mispred pstate4 [pcOf cfg4]; pstate4' = update pstate4 [pcOf cfg4]; ¬ finalM (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); ∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) ≠ Fence; pstate4' = pstate4; ¬ is_getInput (prog ! pcOf (last cfgs4)); ¬ is_Output (prog ! pcOf (last cfgs4)); cfg4' = cfg4; ls4' = ls4 ∪ readLocs (last cfgs4); ∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
6. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_mispred (*‹cfgs4 = []› ‹is_IfJump (prog ! pcOf cfg4)› ‹mispred pstate4 [pcOf cfg4]› ‹pstate4' = update pstate4 [pcOf cfg4]› ‹¬ finalM (cfg4::config, ibT4::int llist, ibUT4::int llist)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹∃cfg1' ibT1' ibUT1'. (cfg1', ibT1', ibUT1') = nextM (cfg4, ibT4, ibUT4) ∧ cfgs4' = [cfg1']› ‹ls4' = ls4 ∪ readLocs cfg4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3'::predState, cfg3'::config, cfgs3'::config list, ibT3'::int llist, ibUT3'::int llist, ls3'::nat set) (pstate4'::predState, cfg4'::config, cfgs4'::config list, ibT4'::int llist, ibUT4'::int llist, ls4'::nat set) (statA'::status) (nextN (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set)) (nextN (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set)) (sstatO' (statO::status) (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ is_IfJump (prog ! pcOf (last cfgs4)) ∨ ¬ mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) ≠ Fence; pstate4' = pstate4; ¬ is_getInput (prog ! pcOf (last cfgs4)); ¬ is_Output (prog ! pcOf (last cfgs4)); cfg4' = cfg4; ls4' = ls4 ∪ readLocs (last cfgs4); ∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
5. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_normal (*‹cfgs4 ≠ []› ‹¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf (cfgs4::config list))› ‹¬ is_IfJump (prog ! pcOf (last (cfgs4::config list))) ∨ ¬ mispred (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4)› ‹prog ! pcOf (last cfgs4) ≠ Fence› ‹pstate4' = pstate4› ‹¬ is_getInput (prog ! pcOf (last cfgs4))› ‹¬ is_Output (prog ! pcOf (last cfgs4))› ‹cfg4' = cfg4› ‹ls4' = ls4 ∪ readLocs (last cfgs4)› ‹∃cfg1'. nextB (last cfgs4, ibT4, ibUT4) = (cfg1', ibT4', ibUT4') ∧ cfgs4' = butlast cfgs4 ## cfg1'›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹(cfgs3::config list) = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); is_IfJump (prog ! pcOf (last cfgs4)); mispred pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); ¬ finalM (last cfgs4, ibT4, ibUT4); cfg4' = cfg4; ∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'; ls4' = ls4 ∪ readLocs (last cfgs4)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
3. ‹⟦cfgs4 ≠ []; ¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; pstate4' = pstate4; cfg4' = cfg4; cfgs4' = []; ibT4' = ibT4; ibUT4' = ibUT4; ls4' = ls4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
4. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_mispred (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹is_IfJump (prog ! pcOf (last cfgs4))› ‹mispred pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹¬ finalM (last cfgs4, ibT4, ibUT4)› ‹cfg4' = cfg4› ‹∃lcfg' cfg1' ibT1' ibUT1'. nextB (last cfgs4, ibT4, ibUT4) = (lcfg', ibT4', ibUT4') ∧ (cfg1', ibT1', ibUT1') = nextM (last cfgs4, ibT4, ibUT4) ∧ cfgs4' = butlast cfgs4 @ [lcfg'] ## cfg1'› ‹ls4' = ls4 ∪ readLocs (last cfgs4)›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹(cfgs3::config list) = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦(cfgs4::config list) = []; ¬ is_IfJump (prog ! pcOf (cfg4::config)) ∨ ¬ mispred (pstate4::predState) [pcOf cfg4]; (pstate4'::predState) = pstate4; ¬ finalB (cfg4, ibT4::int llist, ibUT4::int llist); (cfg4'::config, ibT4'::int llist, ibUT4'::int llist) = nextB (cfg4, ibT4, ibUT4); (cfgs4'::config list) = []; (ls4'::nat set) = (ls4::nat set) ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
2. ‹⟦(cfgs4::config list) ≠ []; ¬ resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); prog ! pcOf (last cfgs4) = Fence; (pstate4'::predState) = pstate4; (cfg4'::config) = cfg4; (cfgs4'::config list) = []; (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist); (ls4'::nat set) = (ls4::nat set)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›
3. ‹⟦(cfgs4::config list) ≠ []; resolve (pstate4::predState) (pcOf (cfg4::config) # map pcOf cfgs4); (pstate4'::predState) = update pstate4 (pcOf cfg4 # map pcOf cfgs4); (cfg4'::config) = cfg4; (cfgs4'::config list) = butlast cfgs4; (ls4'::nat set) = (ls4::nat set); (ibT4'::int llist) = (ibT4::int llist); (ibUT4'::int llist) = (ibUT4::int llist)⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ (ss3'::predState × config × config list × int llist × int llist × nat set) (ss4'::predState × config × config list × int llist × int llist × nat set) (statA'::status) (nextN (ss1::config × int llist × int llist × nat set)) (nextN (ss2::config × int llist × int llist × nat set)) (sstatO' (statO::status) ss1 ss2)›*)
case spec_Fence (*‹cfgs4 ≠ []› ‹¬ resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹prog ! pcOf (last (cfgs4::config list)) = Fence› ‹pstate4' = pstate4› ‹(cfg4'::config) = (cfg4::config)› ‹cfgs4' = []› ‹ibT4' = ibT4› ‹ibUT4' = ibUT4› ‹ls4' = ls4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set)›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goals:
1. ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›
2. ‹⟦cfgs4 ≠ []; resolve pstate4 (pcOf cfg4 # map pcOf cfgs4); pstate4' = update pstate4 (pcOf cfg4 # map pcOf cfgs4); cfg4' = cfg4; cfgs4' = butlast cfgs4; ls4' = ls4; ibT4' = ibT4; ibUT4' = ibUT4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case spec_resolve (*‹(cfgs4::config list) ≠ []› ‹resolve pstate4 (pcOf cfg4 # map pcOf cfgs4)› ‹(pstate4'::predState) = update (pstate4::predState) (pcOf (cfg4::config) # map pcOf (cfgs4::config list))› ‹(cfg4'::config) = (cfg4::config)› ‹cfgs4' = butlast cfgs4› ‹ls4' = ls4› ‹ibT4' = ibT4› ‹ibUT4' = ibUT4›*)
then show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3, ibT3, ibUT3)› ‹(cfg3'::config, ibT3'::int llist, ibUT3'::int llist) = nextB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) unfolding ss
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (cfg1, ibT1, ibUT1, ls1)) (nextN (cfg2, ibT2, ibUT2, ls2)) (sstatO' statO (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2))›*)
by (simp add: Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*))
next
(*goal: ‹⟦cfgs4 = []; ¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]; pstate4' = pstate4; ¬ finalB (cfg4, ibT4, ibUT4); (cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4); cfgs4' = []; ls4' = ls4 ∪ readLocs cfg4⟧ ⟹ oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
case nonspec_normal (*‹(cfgs4::config list) = []› ‹¬ is_IfJump (prog ! pcOf cfg4) ∨ ¬ mispred pstate4 [pcOf cfg4]› ‹(pstate4'::predState) = (pstate4::predState)› ‹¬ finalB (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹(cfgs4'::config list) = []› ‹ls4' = ls4 ∪ readLocs cfg4›*)
note nn4 = nonspec_normal (*‹cfgs4 = []› ‹¬ is_IfJump (prog ! pcOf (cfg4::config)) ∨ ¬ mispred (pstate4::predState) [pcOf cfg4]› ‹(pstate4'::predState) = (pstate4::predState)› ‹¬ finalB (cfg4, ibT4, ibUT4)› ‹(cfg4', ibT4', ibUT4') = nextB (cfg4, ibT4, ibUT4)› ‹cfgs4' = []› ‹ls4' = ls4 ∪ readLocs cfg4›*)
show "?thesis"
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
apply (rule oor3I3 (*‹?Δ₃ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO ⟹ oor3 ?Δ ?Δ₂ ?Δ₃ ?w ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*goal: ‹oor3 Δ1' Δ3' Δe ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)›*)
using sa (*‹Opt.eqAct ss3 ss4›*) "Δ1'" (*‹Δ1' (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*) stat (*‹statA' = Diff ⟹ sstatO' statO ss1 ss2 = Diff›*) pc (*‹pcOf cfg1 = 6›*) pc4 (*‹(pc4::nat) = (6::nat)›*) v3 (*‹validTransO (ss3, ss3')›*) v4 (*‹validTransO (ss4, ss4')›*) nn3 (*‹cfgs3 = []› ‹¬ is_IfJump (prog ! pcOf cfg3) ∨ ¬ mispred pstate3 [pcOf cfg3]› ‹pstate3' = pstate3› ‹¬ finalB (cfg3::config, ibT3::int llist, ibUT3::int llist)› ‹(cfg3', ibT3', ibUT3') = nextB (cfg3, ibT3, ibUT3)› ‹cfgs3' = []› ‹ls3' = ls3 ∪ readLocs cfg3›*) config.sel(2) (*‹stateOf (Config ?x1.0 ?x2.0) = ?x2.0›*) state.sel(2) (*‹getAvstore (State ?x1.0 ?x2.0 ?x3.0 ?x4.0) = ?x2.0›*) unfolding ss cfg cfg1 cfg2 hh
(*goal: ‹Δe ∞ (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3') (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4') statA' (nextN (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1)) (nextN (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2)) (sstatO' statO (Config pc1 (State (Vstore vs1) avst1 h1 p1), ibT1, ibUT1, ls1) (Config pc2 (State (Vstore vs2) avst2 h2 p2), ibT2, ibUT2, ls2))›*)
by (simp add:Δ1'_defs (*‹Δ1' = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ (2 < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < 4 ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ 5 ⟶ ls1 ⊆ {array_loc aa1 0 (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ (4 ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = 0 ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory ?cfg ?cfg' ?cfgs' ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0..6}› ‹afterInput = {2..6}› ‹same_var_o ?ii ?cfg3.0 ?cfgs3.0 ?cfg4.0 ?cfgs4.0 ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp ?cfg1.0 ?cfg2.0 ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = 0› ‹noMisSpec ?cfgs ≡ ?cfgs = []› ‹inThenBranch = {4..6}› ‹elseBranch = 6›*) Δe_defs (*‹Δe = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg3 = endPC ∧ pcOf cfg4 = endPC ∧ cfgs3 = [] ∧ cfgs4 = [] ∧ pcOf cfg1 = endPC ∧ pcOf cfg2 = endPC)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹endPC = 7›*))
qed
qed
qed
qed
using "Δ1'" (*‹Δ1' n ss3 ss4 statA ss1 ss2 statO›*) unfolding ss
(*goal: ‹6 < pcOf cfg1 ⟹ (∃v<n. proact (oor3 Δ1' Δ3' Δe) v (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO) ∨ match (oor3 Δ1' Δ3' Δe) (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
by (simp add:Δ1'_defs (*‹Δ1' = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. common num (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∧ pcOf cfg3 ∈ afterInput ∧ same_var_o xx cfg3 cfgs3 cfg4 cfgs4 ∧ ((2::nat) < pcOf cfg1 ⟶ vstore (getVstore (stateOf cfg3)) tt = vstore (getVstore (stateOf cfg4)) tt) ∧ int NN ≤ vstore (getVstore (stateOf cfg3)) xx ∧ (pcOf cfg1 < (4::nat) ⟶ pcOf cfg1 = pcOf cfg3 ∧ ls1 = {} ∧ ls2 = {} ∧ ls1 = ls3 ∧ ls2 = ls4) ∧ (pcOf cfg1 ≤ (5::nat) ⟶ ls1 ⊆ {array_loc aa1 (0::nat) (getAvstore (stateOf cfg1))} ∧ ls1 = ls2 ∧ ls3 = ls4) ∧ Language_Prelims.dist ls3 ls4 ⊆ Language_Prelims.dist ls1 ls2 ∧ ((4::nat) ≤ pcOf cfg1 ⟶ pcOf cfg1 ∈ inThenBranch ∧ pcOf cfg3 = elseBranch) ∧ same_xx_cp cfg1 cfg2 ∧ vstore (getVstore (stateOf cfg1)) xx = (0::int) ∧ ls3 ⊆ ls1 ∧ ls4 ⊆ ls2 ∧ noMisSpec cfgs3)› ‹common = (λ(num::enat) (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set) (pstate4::predState, cfg4::config, cfgs4::config list, ibT4::int llist, ibUT4::int llist, ls4::nat set) (statA::status) (cfg1::config, ibT1::int llist, ibUT1::int llist, ls1::nat set) (cfg2::config, ibT2::int llist, ibUT2::int llist, ls2::nat set) statO::status. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0::nat. array_loc aa1 (0::nat) (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 (0::nat) (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'::config∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'::config∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹common_memory (?cfg::config) (?cfg'::config) (?cfgs'::config list) ≡ array_base aa1 (getAvstore (stateOf ?cfg)) = array_base aa1 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa1 (getAvstore (stateOf cfg'')) = array_base aa1 (getAvstore (stateOf ?cfg))) ∧ array_base aa2 (getAvstore (stateOf ?cfg)) = array_base aa2 (getAvstore (stateOf ?cfg')) ∧ (∀cfg''::config∈set ?cfgs'. array_base aa2 (getAvstore (stateOf cfg'')) = array_base aa2 (getAvstore (stateOf ?cfg))) ∧ getHheap (stateOf ?cfg) = getHheap (stateOf ?cfg') ∧ (∀cfg''::config∈set ?cfgs'. getHheap (stateOf ?cfg) = getHheap (stateOf cfg'')) ∧ getAvstore (stateOf ?cfg) = getAvstore (stateOf ?cfg')› ‹PC ≡ {0::?'a..6::?'a}› ‹afterInput = {2::?'a..6::?'a}› ‹same_var_o (?ii::char list) (?cfg3.0::config) (?cfgs3.0::config list) (?cfg4.0::config) (?cfgs4.0::config list) ≡ vstore (getVstore (stateOf ?cfg3.0)) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii ∧ (∀cfg3'::config∈set ?cfgs3.0. vstore (getVstore (stateOf cfg3')) ?ii = vstore (getVstore (stateOf ?cfg3.0)) ?ii) ∧ (∀cfg4'::config∈set ?cfgs4.0. vstore (getVstore (stateOf cfg4')) ?ii = vstore (getVstore (stateOf ?cfg4.0)) ?ii)› ‹same_xx_cp (?cfg1.0::config) (?cfg2.0::config) ≡ vstore (getVstore (stateOf ?cfg1.0)) xx = vstore (getVstore (stateOf ?cfg2.0)) xx ∧ vstore (getVstore (stateOf ?cfg1.0)) xx = (0::int)› ‹noMisSpec (?cfgs::config list) ≡ ?cfgs = []› ‹inThenBranch = {4::?'a..6::?'a}› ‹elseBranch = (6::?'a)›*))
qed
lemma step3': "unwindIntoCond Δ3' (oor Δ3' Δ1')"
proof(rule unwindIntoCond_simpleI)
fix n ss3 ss4 statA ss1 ss2 statO
assume r: "reachO ss3" "reachO ss4" "reachV ss1" "reachV ss2"
and Δ3': "Δ3' n ss3 ss4 statA ss1 ss2 statO"
obtain pstate3 cfg3 cfgs3 ibT3 ibUT3 ls3 where ss3: "ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)"
by (cases ss3, auto)
obtain pstate4 cfg4 cfgs4 ibT4 ibUT4 ls4 where ss4: "ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)"
by (cases ss4, auto)
obtain cfg1 ibT1 ibUT1 ls1 where ss1: "ss1 = (cfg1, ibT1, ibUT1, ls1)"
by (cases ss1, auto)
obtain cfg2 ibT2 ibUT2 ls2 where ss2: "ss2 = (cfg2, ibT2, ibUT2, ls2)"
by (cases ss2, auto)
note ss = ss3 ss4 ss1 ss2
obtain pc1 vs1 avst1 h1 p1 where
cfg1: "cfg1 = Config pc1 (State (Vstore vs1) avst1 h1 p1)"
by (cases "cfg1") (metis state.collapse vstore.collapse)
obtain pc2 vs2 avst2 h2 p2 where
cfg2: "cfg2 = Config pc2 (State (Vstore vs2) avst2 h2 p2)"
by (cases "cfg2") (metis state.collapse vstore.collapse)
obtain pc3 vs3 avst3 h3 p3 where
cfg3: "cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)"
by (cases "cfg3") (metis state.collapse vstore.collapse)
obtain pc4 vs4 avst4 h4 p4 where
cfg4: "cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)"
by (cases "cfg4") (metis state.collapse vstore.collapse)
note cfg = cfg1 cfg2 cfg3 cfg4
obtain lpc3 lvs3 lavst3 lh3 lp3 where
lcfgs3: "last cfgs3 = Config lpc3 (State (Vstore lvs3) lavst3 lh3 lp3)"
by (cases "last cfgs3") (metis state.collapse vstore.collapse)
obtain lpc4 lvs4 lavst4 lh4 lp4 where
lcfgs4: "last cfgs4 = Config lpc4 (State (Vstore lvs4) lavst4 lh4 lp4)"
by (cases "last cfgs4") (metis state.collapse vstore.collapse)
note lcfgs = lcfgs3 lcfgs4
obtain hh1 where h1: "h1 = Heap hh1" by(cases h1, auto)
obtain hh2 where h2: "h2 = Heap hh2" by(cases h2, auto)
obtain hh3 where h3: "h3 = Heap hh3" by(cases h3, auto)
obtain hh4 where h4: "h4 = Heap hh4" by(cases h4, auto)
obtain lhh3 where lh3: "lh3 = Heap lhh3" by(cases lh3, auto)
obtain lhh4 where lh4: "lh4 = Heap lhh4" by(cases lh4, auto)
note hh = h3 h4 lh3 lh4 h1 h2
define a1_3 where a1_3:"a1_3 = array_loc aa1 0 avst3"
define a1_4 where a1_4:"a1_4 = array_loc aa1 0 avst4"
define a2_3 where a2_3:"a2_3 = array_loc aa2 (nat (lvs3 vv * 512)) avst3"
define a2_4 where a2_4:"a2_4 = array_loc aa2 (nat (lvs4 vv * 512)) avst4"
have butlast:"butlast cfgs4 = []"
using Δ3' unfolding ss apply (simp add: Δ3'_defs)
by (metis length_1_butlast length_map)
have h3_eq:"hh3 = lhh3"
using cfg lcfgs hh Δ3' unfolding Δ3'_defs ss apply clarify
using config.sel(2) getHheap.simps heap.sel last_in_set
by metis
have h4_eq:"hh4 = lhh4"
using cfg lcfgs hh Δ3' unfolding Δ3'_defs ss apply clarify
using config.sel(2) getHheap.simps heap.sel last_in_set
by (metis map_is_Nil_conv)
have f1:"¬finalN ss1"
using Δ3' finalB_pc_iff' unfolding ss finalN_iff_finalB Δ3'_defs
by simp
have f2:"¬finalN ss2"
using Δ3' finalB_pc_iff' unfolding ss cfg finalN_iff_finalB Δ3'_defs
by simp
have f3:"¬finalS ss3"
using Δ3' unfolding ss apply-apply(frule Δ3'_implies)
using finalS_cond_spec by (simp add: Δ3'_defs)
have f4:"¬finalS ss4"
using Δ3' unfolding ss apply-apply(frule Δ3'_implies)
using finalS_cond_spec apply (simp add: Δ3'_defs)
by (metis length_map)
note finals = f1 f2 f3 f4
show "finalS ss3 = finalS ss4 ∧ finalN ss1 = finalS ss3 ∧ finalN ss2 = finalS ss4"
using finals by auto
then show "isIntO ss3 = isIntO ss4" by simp
show "match (oor Δ3' Δ1') ss3 ss4 statA ss1 ss2 statO"
unfolding match_def proof(intro conjI)
(* match1 and match2 are impossible case since isIntO always holds *)
show "match1 (oor Δ3' Δ1') ss3 ss4 statA ss1 ss2 statO"
unfolding match1_def by (simp add: finalS_def final_def)
show "match2 (oor Δ3' Δ1') ss3 ss4 statA ss1 ss2 statO"
unfolding match2_def by (simp add: finalS_def final_def)
show "match12 (oor Δ3' Δ1') ss3 ss4 statA ss1 ss2 statO"
using cases_thenBranch[of "pcOf (last cfgs3)"]
apply(elim disjE)
subgoal using Δ3' unfolding ss lcfgs Δ3'_defs
by (clarify, metis atLeastAtMost_iff inThenBranch_def lcfgs3 le_antisym less_irrefl_nat less_or_eq_imp_le startOfThenBranch_def)
subgoal
proof(rule match12_simpleI, rule disjI2, intro conjI)
fix ss3' ss4' statA'
assume statA': "statA' = sstatA' statA ss3 ss4"
and v: "validTransO (ss3, ss3')" "validTransO (ss4, ss4')"
and sa: "Opt.eqAct ss3 ss4"
and pc:"pcOf (last cfgs3) = 4"
note v3 = v(1) note v4 = v(2)
have pc2:"pc2 = 4"
using Δ3' pc unfolding ss cfg unfolding Δ3'_defs
apply clarify
by (metis config.sel(1))
obtain pstate3' cfg3' cfgs3' ibT3' ibUT3' ls3' where ss3': "ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')"
by (cases ss3', auto)
obtain pstate4' cfg4' cfgs4' ibT4' ibUT4' ls4' where ss4': "ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')"
by (cases ss4', auto)
note ss = ss ss3' ss4'
show "eqSec ss1 ss3"
using v sa Δ3' unfolding ss by (simp add: Δ3'_defs)
show "eqSec ss2 ss4"
using v sa Δ3' unfolding ss by (simp add: Δ3'_defs)
show "Van.eqAct ss1 ss2"
using v sa Δ3' unfolding ss Van.eqAct_def
by (simp add: Δ3'_defs lessI less_or_eq_imp_le numeral_3_eq_3 pc)
show "match12_12 (oor Δ3' Δ1') ss3' ss4' statA' ss1 ss2 statO"
unfolding match12_12_def
proof(rule exI[of _ "nextN ss1"], rule exI[of _ "nextN ss2"], unfold Let_def, intro conjI impI)
show "validTransV (ss1, nextN ss1)"
by (simp add: f1 nextN_stepN)
show "validTransV (ss2, nextN ss2)"
by (simp add: f2 nextN_stepN)
{assume sstat: "statA' = Diff"
show "sstatO' statO ss1 ss2 = Diff"
using v sa Δ3' sstat unfolding ss cfg statA'
apply(simp add: Δ3'_defs sstatO'_def sstatA'_def)
apply(cases statO, simp_all) apply(cases statA, simp_all)
by (smt (z3) Nil_is_map_conv cfg finals ss status.distinct(1) updStat.simps(1))
} note stat = this
show "oor Δ3' Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)"
using v3[unfolded ss, simplified] proof(cases rule: stepS_cases)
case nonspec_mispred
then show ?thesis using sa Δ3' stat unfolding ss by (simp add: Δ3'_defs)
next
case spec_mispred
then show ?thesis using sa Δ3' stat unfolding ss by (simp add: Δ3'_defs)
next
case spec_Fence
then show ?thesis using sa Δ3' stat unfolding ss by (simp add: Δ3'_defs)
next
case nonspec_normal
then show ?thesis using sa Δ3' stat unfolding ss by (simp add: Δ3'_defs)
next
case spec_resolve
then show ?thesis using sa Δ3' stat pc unfolding ss apply (simp add: Δ3'_defs)
by (metis last_ConsL last_map n_not_Suc_n numeral_2_eq_2 numeral_3_eq_3 numeral_eq_iff semiring_norm(87))
(*spec normal is non trivial*)
next
case spec_normal note sn3 = spec_normal
show ?thesis
using v4[unfolded ss, simplified] proof(cases rule: stepS_cases)
case nonspec_mispred
then show ?thesis using sa Δ3' stat sn3 unfolding ss by (simp add: Δ3'_defs)
next
case spec_mispred
then show ?thesis using sa Δ3' stat sn3 unfolding ss by (simp add: Δ3'_defs)
next
case spec_Fence
then show ?thesis using sa Δ3' stat sn3 unfolding ss by (simp add: Δ3'_defs)
next
case spec_resolve
then show ?thesis using sa Δ3' stat sn3 unfolding ss by (simp add: Δ3'_defs)
next
case nonspec_normal note nn4 = nonspec_normal
then show ?thesis using sa Δ3' stat sn3 unfolding ss by (simp add: Δ3'_defs)
next
case spec_normal note sn4 = spec_normal
then show ?thesis
using Δ3' sn3 sn4 pc2 lcfgs h3_eq h4_eq hh stat a1_3 a1_4
unfolding ss cfg
apply simp
apply(rule oorI1)
apply (simp add: Δ3'_defs butlast )
apply clarsimp apply(intro conjI)
subgoal by (smt (z3) config.sel(2) last_in_set state.sel(1) vstore.sel)
subgoal by (smt (z3) config.sel(2) last_in_set state.sel(1) vstore.sel)
subgoal unfolding array_loc_def by simp .
qed
qed
qed
qed
subgoal proof(rule match12_simpleI, rule disjI2, intro conjI)
fix ss3' ss4' statA'
assume statA': "statA' = sstatA' statA ss3 ss4"
and v: "validTransO (ss3, ss3')" "validTransO (ss4, ss4')"
and sa: "Opt.eqAct ss3 ss4"
and pc:"pcOf (last cfgs3) = 5"
note v3 = v(1) note v4 = v(2)
have pc2:"pc2 = 5"
using Δ3' Δ3'_implies pc unfolding ss cfg Δ3'_defs
apply clarify by (smt (z3) config.sel(1))
obtain pstate3' cfg3' cfgs3' ibT3' ibUT3' ls3' where ss3': "ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')"
by (cases ss3', auto)
obtain pstate4' cfg4' cfgs4' ibT4' ibUT4' ls4' where ss4': "ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')"
by (cases ss4', auto)
note ss = ss ss3' ss4'
show "eqSec ss1 ss3"
using v sa Δ3' unfolding ss by (simp add: Δ3'_defs pc)
show "eqSec ss2 ss4"
using v sa Δ3' unfolding ss by (simp add: Δ3'_defs pc)
show "Van.eqAct ss1 ss2"
using v sa Δ3' unfolding ss Van.eqAct_def
by (simp add: Δ3'_defs pc)
show "match12_12 (oor Δ3' Δ1') ss3' ss4' statA' ss1 ss2 statO"
unfolding match12_12_def
proof(rule exI[of _ "nextN ss1"], rule exI[of _ "nextN ss2"], unfold Let_def, intro conjI impI)
show "validTransV (ss1, nextN ss1)"
by (simp add: f1 nextN_stepN)
show "validTransV (ss2, nextN ss2)"
by (simp add: f2 nextN_stepN)
{assume sstat: "statA' = Diff"
show "sstatO' statO ss1 ss2 = Diff"
using v sa Δ3' sstat unfolding ss cfg statA'
apply(simp add: Δ3'_defs sstatO'_def sstatA'_def)
apply(cases statO, simp_all) apply(cases statA, simp_all)
by (smt (z3) Nil_is_map_conv cfg f3 f4 ss status.distinct(1) updStat.simps(1))
} note stat = this
show "oor Δ3' Δ1' ∞ ss3' ss4' statA' (nextN ss1) (nextN ss2) (sstatO' statO ss1 ss2)"
using v3[unfolded ss, simplified] proof(cases rule: stepS_cases)
case nonspec_mispred
then show ?thesis using sa Δ3' stat unfolding ss by (simp add: Δ3'_defs)
next
case spec_mispred
then show ?thesis using sa Δ3' stat unfolding ss by (simp add: Δ3'_defs)
next
case spec_Fence
then show ?thesis using sa Δ3' stat unfolding ss by (simp add: Δ3'_defs)
next
case nonspec_normal
then show ?thesis using sa Δ3' stat unfolding ss by (simp add: Δ3'_defs)
next
case spec_resolve
then show ?thesis using sa Δ3' stat pc unfolding ss apply (simp add: Δ3'_defs)
by (metis last_ConsL last_map numeral_eq_iff semiring_norm(89))
(*spec normal and spec resolve are non trivial*)
next
case spec_normal note sn3 = spec_normal
show ?thesis
using v4[unfolded ss, simplified] proof(cases rule: stepS_cases)
case nonspec_mispred
then show ?thesis using sa Δ3' stat sn3 unfolding ss by (simp add: Δ3'_defs)
next
case spec_mispred
then show ?thesis using sa Δ3' stat sn3 unfolding ss by (simp add: Δ3'_defs)
next
case spec_Fence
then show ?thesis using sa Δ3' stat sn3 unfolding ss by (simp add: Δ3'_defs)
next
case spec_resolve
then show ?thesis using sa Δ3' stat sn3 unfolding ss by (simp add: Δ3'_defs)
next
case nonspec_normal note nn4 = nonspec_normal
then show ?thesis using sa Δ3' stat sn3 unfolding ss by (simp add: Δ3'_defs)
next
case spec_normal note sn4 = spec_normal
then show ?thesis
using Δ3' sn3 sn4 pc2 lcfgs h3_eq h4_eq hh stat
unfolding ss cfg a1_3 a1_4
apply simp apply(rule oorI1)
apply (simp add: Δ3'_defs butlast)
apply clarsimp
by (smt (z3) config.sel(2) last_in_set state.sel(1) vstore.sel)
qed
qed
qed
qed
subgoal proof(rule match12_simpleI, rule disjI1, intro conjI)
fix ss3' ss4' statA'
assume statA': "statA' = sstatA' statA ss3 ss4"
and v: "validTransO (ss3, ss3')" "validTransO (ss4, ss4')"
and sa: "Opt.eqAct ss3 ss4"
and pc:"pcOf (last cfgs3) = 6"
note v3 = v(1) note v4 = v(2)
obtain pstate3' cfg3' cfgs3' ibT3' ibUT3' ls3' where ss3': "ss3' = (pstate3', cfg3', cfgs3', ibT3', ibUT3', ls3')"
by (cases ss3', auto)
obtain pstate4' cfg4' cfgs4' ibT4' ibUT4' ls4' where ss4': "ss4' = (pstate4', cfg4', cfgs4', ibT4', ibUT4', ls4')"
by (cases ss4', auto)
note ss = ss ss3' ss4'
show "¬ isSecO ss3"
using v sa Δ3' unfolding ss by (simp add: Δ3'_defs)
show "¬ isSecO ss4"
using v sa Δ3' unfolding ss by (simp add: Δ3'_defs)
show stat: "statA = statA' ∨ statO = Diff"
using v sa Δ3'
unfolding ss statA' sstatA'_def
apply(simp_all add: Δ3'_defs)
apply (cases statA, simp_all)
by (smt (verit, best) Nil_is_map_conv f3 f4 ss updStat.simps(1))
show "oor Δ3' Δ1' ∞ ss3' ss4' statA' ss1 ss2 statO"
using v3[unfolded ss, simplified] proof(cases rule: stepS_cases)
case nonspec_mispred
then show ?thesis using sa Δ3' stat unfolding ss by (simp add: Δ3'_defs)
next
case spec_mispred
then show ?thesis using sa Δ3' stat unfolding ss by (simp add: Δ3'_defs)
next
case spec_Fence
then show ?thesis using sa Δ3' stat unfolding ss by (simp add: Δ3'_defs)
next
case nonspec_normal
then show ?thesis using sa Δ3' stat unfolding ss by (simp add: Δ3'_defs)
next
case spec_normal note sn3 = spec_normal
show ?thesis using sa Δ3' stat sn3 pc v3 unfolding ss by (simp add: Δ3'_defs)
next
(*resolution is the only possibT,ibUTility*)
case spec_resolve note sr3 = spec_resolve
show ?thesis using v4[unfolded ss, simplified] proof(cases rule: stepS_cases)
case nonspec_mispred
then show ?thesis using sa Δ3' stat sr3 unfolding ss by (simp add: Δ3'_defs)
next
case spec_mispred
then show ?thesis using sa Δ3' stat sr3 unfolding ss by (simp add: Δ3'_defs)
next
case spec_Fence
then show ?thesis using sa Δ3' stat sr3 unfolding ss by (simp add: Δ3'_defs)
next
case nonspec_normal
then show ?thesis using sa Δ3' stat sr3 unfolding ss by (simp add: Δ3'_defs)
next
case spec_normal
then show ?thesis using sa Δ3' stat sr3 unfolding ss by (simp add: Δ3'_defs)
next
case spec_resolve note sr4 = spec_resolve
then show ?thesis
using Δ3' sr3 sr4 lcfgs hh stat a2_3 a2_4
butlast array_locBase le_refl
unfolding ss cfg
apply simp
apply(rule oorI2)
apply (simp add: Δ3'_defs Δ1'_defs, intro conjI, metis)
apply meson apply meson apply blast by meson
qed
qed
qed
subgoal using Δ3' unfolding ss lcfgs Δ3'_defs
by (simp add: avstoreOf.cases elseBranch_def lcfgs3) .
qed
qed
lemma stepe: "unwindIntoCond Δe Δe"
proof (rule unwindIntoCond_simpleI (*‹⟦⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; ?Δ w s1 s2 statA sv1 sv2 statO⟧ ⟹ finalS s1 = finalS s2 ∧ finalN sv1 = finalS s1 ∧ finalN sv2 = finalS s2; ⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; ?Δ w s1 s2 statA sv1 sv2 statO; statA = status.Eq⟧ ⟹ isIntO s1 = isIntO s2; ⋀w s1 s2 statA sv1 sv2 statO. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; ?Δ w s1 s2 statA sv1 sv2 statO⟧ ⟹ match ?Δ' s1 s2 statA sv1 sv2 statO⟧ ⟹ unwindIntoCond ?Δ ?Δ'›*))
(*goals:
1. ‹⋀(w::enat) (s1::predState × config × config list × int llist × int llist × nat set) (s2::predState × config × config list × int llist × int llist × nat set) (statA::status) (sv1::config × int llist × int llist × nat set) (sv2::config × int llist × int llist × nat set) statO::status. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δe w s1 s2 statA sv1 sv2 statO⟧ ⟹ finalS s1 = finalS s2 ∧ finalN sv1 = finalS s1 ∧ finalN sv2 = finalS s2›
2. ‹⋀(w::enat) (s1::predState × config × config list × int llist × int llist × nat set) (s2::predState × config × config list × int llist × int llist × nat set) (statA::status) (sv1::config × int llist × int llist × nat set) (sv2::config × int llist × int llist × nat set) statO::status. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δe w s1 s2 statA sv1 sv2 statO; statA = status.Eq⟧ ⟹ isIntO s1 = isIntO s2›
3. ‹⋀(w::enat) (s1::predState × config × config list × int llist × int llist × nat set) (s2::predState × config × config list × int llist × int llist × nat set) (statA::status) (sv1::config × int llist × int llist × nat set) (sv2::config × int llist × int llist × nat set) statO::status. ⟦reachO s1; reachO s2; reachV sv1; reachV sv2; Δe w s1 s2 statA sv1 sv2 statO⟧ ⟹ match Δe s1 s2 statA sv1 sv2 statO›*)
fix n and ss3 and ss4 and statA and ss1 and ss2 and statO
assume r: "reachO ss3" "reachO ss4" "reachV ss1" "reachV ss2" and "Δe": "Δe n ss3 ss4 statA ss1 ss2 statO" (*‹reachO (ss3::predState × config × config list × int llist × int llist × nat set)› ‹reachO (ss4::predState × config × config list × int llist × int llist × nat set)› ‹reachV (ss1::config × int llist × int llist × nat set)› ‹reachV (ss2::config × int llist × int llist × nat set)› ‹Δe (n::enat) (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
obtain pstate3 and cfg3 and cfgs3 and ibT3 and ibUT3 and ls3 where ss3: "ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3)"
(*goal: ‹(⋀pstate3 cfg3 cfgs3 ibT3 ibUT3 ls3. ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⟹ thesis) ⟹ thesis›*)
apply (cases ss3)
(*goal: ‹(⋀pstate3 cfg3 cfgs3 ibT3 ibUT3 ls3. ss3 = (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ⟹ thesis) ⟹ thesis›*)
by auto
obtain pstate4 and cfg4 and cfgs4 and ibT4 and ibUT4 and ls4 where ss4: "ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)"
(*goal: ‹(⋀(pstate4::predState) (cfg4::config) (cfgs4::config list) (ibT4::int llist) (ibUT4::int llist) ls4::nat set. (ss4::predState × config × config list × int llist × int llist × nat set) = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) ⟹ thesis::bool) ⟹ thesis›*)
apply (cases ss4)
(*goal: ‹(⋀(pstate4::predState) (cfg4::config) (cfgs4::config list) (ibT4::int llist) (ibUT4::int llist) ls4::nat set. (ss4::predState × config × config list × int llist × int llist × nat set) = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) ⟹ thesis::bool) ⟹ thesis›*)
by auto
obtain cfg1 and ibT1 and ibUT1 and ls1 where ss1: "ss1 = (cfg1, ibT1, ibUT1, ls1)"
(*goal: ‹(⋀cfg1 ibT1 ibUT1 ls1. ss1 = (cfg1, ibT1, ibUT1, ls1) ⟹ thesis) ⟹ thesis›*)
apply (cases ss1)
(*goal: ‹(⋀cfg1 ibT1 ibUT1 ls1. ss1 = (cfg1, ibT1, ibUT1, ls1) ⟹ thesis) ⟹ thesis›*)
by auto
obtain cfg2 and ibT2 and ibUT2 and ls2 where ss2: "ss2 = (cfg2, ibT2, ibUT2, ls2)"
(*goal: ‹(⋀cfg2 ibT2 ibUT2 ls2. ss2 = (cfg2, ibT2, ibUT2, ls2) ⟹ thesis) ⟹ thesis›*)
apply (cases ss2)
(*goal: ‹(⋀cfg2 ibT2 ibUT2 ls2. ss2 = (cfg2, ibT2, ibUT2, ls2) ⟹ thesis) ⟹ thesis›*)
by auto
note ss = ss3 (*‹(ss3::predState × config × config list × int llist × int llist × nat set) = (pstate3::predState, cfg3::config, cfgs3::config list, ibT3::int llist, ibUT3::int llist, ls3::nat set)›*) ss4 (*‹ss4 = (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*) ss1 (*‹ss1 = (cfg1, ibT1, ibUT1, ls1)›*) ss2 (*‹ss2 = (cfg2, ibT2, ibUT2, ls2)›*)
obtain pc3 and vs3 and avst3 and h3 and p3 where cfg3: "cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)"
(*goal: ‹(⋀(pc3::nat) (vs3::char list ⇒ int) (avst3::avstore) (h3::heap) p3::nat. (cfg3::config) = Config pc3 (State (Vstore vs3) avst3 h3 p3) ⟹ thesis::bool) ⟹ thesis›*)
apply (cases cfg3)
(*goal: ‹(⋀pc3 vs3 avst3 h3 p3. cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3) ⟹ thesis) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore ?state) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore ?vstorea) = ?vstorea›*))
obtain pc4 and vs4 and avst4 and h4 and p4 where cfg4: "cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)"
(*goal: ‹(⋀(pc4::nat) (vs4::char list ⇒ int) (avst4::avstore) (h4::heap) p4::nat. (cfg4::config) = Config pc4 (State (Vstore vs4) avst4 h4 p4) ⟹ thesis::bool) ⟹ thesis›*)
apply (cases cfg4)
(*goal: ‹(⋀pc4 vs4 avst4 h4 p4. cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4) ⟹ thesis) ⟹ thesis›*)
by (metis state.collapse (*‹State (getVstore ?state) (getAvstore ?state) (getHeap ?state) (getFree ?state) = ?state›*) vstore.collapse (*‹Vstore (vstore ?vstorea) = ?vstorea›*))
note cfg = cfg3 (*‹cfg3 = Config pc3 (State (Vstore vs3) avst3 h3 p3)›*) cfg4 (*‹cfg4 = Config pc4 (State (Vstore vs4) avst4 h4 p4)›*)
obtain hh3 where h3: "h3 = Heap hh3"
(*goal: ‹(⋀hh3. h3 = Heap hh3 ⟹ thesis) ⟹ thesis›*)
apply (cases h3)
(*goal: ‹(⋀hh3. h3 = Heap hh3 ⟹ thesis) ⟹ thesis›*)
by auto
obtain hh4 where h4: "h4 = Heap hh4"
(*goal: ‹(⋀hh4. h4 = Heap hh4 ⟹ thesis) ⟹ thesis›*)
apply (cases h4)
(*goal: ‹(⋀hh4. h4 = Heap hh4 ⟹ thesis) ⟹ thesis›*)
by auto
note hh = h3 (*‹h3 = Heap hh3›*) h4 (*‹h4 = Heap hh4›*)
show "finalS ss3 = finalS ss4 ∧ finalN ss1 = finalS ss3 ∧ finalN ss2 = finalS ss4"
using "Δe" (*‹Δe n ss3 ss4 statA ss1 ss2 statO›*) Opt.final_def (*‹finalS ?s1.0 = (∀s2. ¬ validTransO (?s1.0, s2))›*) Prog.endPC_def (*‹Prog ?prog ⟹ Prog.endPC ?prog ≡ length ?prog›*) finalS_def (*‹finalS = final (→S)›*) stepS_endPC (*‹pcOf ?cfg = endPC ⟹ ¬ (?pstate, ?cfg, [], ?ibT, ?ibUT, ?ls) →S ?ss'›*) unfolding "Δe_defs" ss
(*goal: ‹finalS (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) = finalS (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) ∧ finalN (cfg1, ibT1, ibUT1, ls1) = finalS (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ∧ finalN (cfg2, ibT2, ibUT2, ls2) = finalS (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)›*)
by clarsimp
then show "isIntO ss3 = isIntO ss4"
by simp
show "match Δe ss3 ss4 statA ss1 ss2 statO"
unfolding match_def
(*goal: ‹match1 Δe (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status) ∧ match2 Δe ss3 ss4 statA ss1 ss2 statO ∧ match12 Δe ss3 ss4 statA ss1 ss2 statO›*)
proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹match1 Δe (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
2. ‹match2 Δe (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›
3. ‹match12 Δe (ss3::predState × config × config list × int llist × int llist × nat set) (ss4::predState × config × config list × int llist × int llist × nat set) (statA::status) (ss1::config × int llist × int llist × nat set) (ss2::config × int llist × int llist × nat set) (statO::status)›*)
show "match1 Δe ss3 ss4 statA ss1 ss2 statO"
unfolding match1_def
(*goal: ‹¬ isIntO ss3 ⟶ (∀s1'. validTransO (ss3, s1') ⟶ ¬ isSecO ss3 ∧ Δe ∞ s1' ss4 statA ss1 ss2 statO ∨ eqSec ss1 ss3 ∧ ¬ isIntV ss1 ∧ match1_1 Δe ss3 s1' ss4 statA ss1 ss2 statO ∨ eqSec ss1 ss3 ∧ ¬ isSecV ss2 ∧ Van.eqAct ss1 ss2 ∧ match1_12 Δe ss3 s1' ss4 statA ss1 ss2 statO)›*)
by (simp add: finalS_def (*‹finalS = final (→S)›*) final_def (*‹final ?r ?x ≡ ∀y. ¬ ?r ?x y›*))
show "match2 Δe ss3 ss4 statA ss1 ss2 statO"
unfolding match2_def
(*goal: ‹¬ isIntO ss4 ⟶ (∀s2'. validTransO (ss4, s2') ⟶ ¬ isSecO ss4 ∧ Δe ∞ ss3 s2' statA ss1 ss2 statO ∨ eqSec ss2 ss4 ∧ ¬ isIntV ss2 ∧ match2_1 Δe ss3 ss4 s2' statA ss1 ss2 statO ∨ ¬ isSecV ss1 ∧ eqSec ss2 ss4 ∧ Van.eqAct ss1 ss2 ∧ match2_12 Δe ss3 ss4 s2' statA ss1 ss2 statO)›*)
by (simp add: finalS_def (*‹finalS = final (→S)›*) final_def (*‹final ?r ?x ≡ ∀y. ¬ ?r ?x y›*))
show "match12 Δe ss3 ss4 statA ss1 ss2 statO"
apply (rule match12_simpleI (*‹(⋀(s1'::predState × config × config list × int llist × int llist × nat set) (s2'::predState × config × config list × int llist × int llist × nat set) statA'::status. ⟦statA' = sstatA' (?statA::status) (?s1.0::predState × config × config list × int llist × int llist × nat set) (?s2.0::predState × config × config list × int llist × int llist × nat set); validTransO (?s1.0, s1'); validTransO (?s2.0, s2'); Opt.eqAct ?s1.0 ?s2.0⟧ ⟹ ¬ isSecO ?s1.0 ∧ ¬ isSecO ?s2.0 ∧ (?statA = statA' ∨ (?statO::status) = Diff) ∧ (?Δ::?'a ⇒ predState × config × config list × int llist × int llist × nat set ⇒ predState × config × config list × int llist × int llist × nat set ⇒ status ⇒ config × int llist × int llist × nat set ⇒ config × int llist × int llist × nat set ⇒ status ⇒ bool) ∞ s1' s2' statA' (?sv1.0::config × int llist × int llist × nat set) (?sv2.0::config × int llist × int llist × nat set) ?statO ∨ eqSec ?sv1.0 ?s1.0 ∧ eqSec ?sv2.0 ?s2.0 ∧ Van.eqAct ?sv1.0 ?sv2.0 ∧ match12_12 ?Δ s1' s2' statA' ?sv1.0 ?sv2.0 ?statO) ⟹ match12 ?Δ ?s1.0 ?s2.0 ?statA ?sv1.0 ?sv2.0 ?statO›*))
(*goal: ‹match12 Δe ss3 ss4 statA ss1 ss2 statO›*)
using "Δe" (*‹Δe n ss3 ss4 statA ss1 ss2 statO›*) stepS_endPC (*‹pcOf ?cfg = endPC ⟹ ¬ (?pstate, ?cfg, [], ?ibT, ?ibUT, ?ls) →S ?ss'›*) unfolding ss
(*goal: ‹⋀s1' s2' statA'. ⟦statA' = sstatA' statA (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4); validTransO ((pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3), s1'); validTransO ((pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4), s2'); Opt.eqAct (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4)⟧ ⟹ ¬ isSecO (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ∧ ¬ isSecO (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) ∧ (statA = statA' ∨ statO = Diff) ∧ Δe ∞ s1' s2' statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO ∨ eqSec (cfg1, ibT1, ibUT1, ls1) (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) ∧ eqSec (cfg2, ibT2, ibUT2, ls2) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) ∧ Van.eqAct (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) ∧ match12_12 Δe s1' s2' statA' (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO›*)
by (simp add: Δe_defs (*‹Δe = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg3 = endPC ∧ pcOf cfg4 = endPC ∧ cfgs3 = [] ∧ cfgs4 = [] ∧ pcOf cfg1 = endPC ∧ pcOf cfg2 = endPC)› ‹common = (λnum (pstate3, cfg3, cfgs3, ibT3, ibUT3, ls3) (pstate4, cfg4, cfgs4, ibT4, ibUT4, ls4) statA (cfg1, ibT1, ibUT1, ls1) (cfg2, ibT2, ibUT2, ls2) statO. pstate3 = pstate4 ∧ (num = enat (endPC - pcOf cfg1) ∨ num = ∞) ∧ pcOf cfg1 = pcOf cfg2 ∧ pcOf cfg3 = pcOf cfg4 ∧ map pcOf cfgs3 = map pcOf cfgs4 ∧ pcOf cfg3 ∈ PC ∧ pcOf ` set cfgs3 ⊆ PC ∧ pcOf cfg1 ∈ PC ∧ common_memory cfg1 cfg3 cfgs3 ∧ common_memory cfg2 cfg4 cfgs4 ∧ (∀n≥0. array_loc aa1 0 (getAvstore (stateOf cfg2)) ≠ array_loc aa2 n (getAvstore (stateOf cfg2)) ∧ array_loc aa1 0 (getAvstore (stateOf cfg1)) ≠ array_loc aa2 n (getAvstore (stateOf cfg1))) ∧ array_base aa1 (getAvstore (stateOf cfg3)) = array_base aa1 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa1 (getAvstore (stateOf cfg3')) = array_base aa1 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa1 (getAvstore (stateOf cfg4')) = array_base aa1 (getAvstore (stateOf cfg4))) ∧ array_base aa2 (getAvstore (stateOf cfg3)) = array_base aa2 (getAvstore (stateOf cfg4)) ∧ (∀cfg3'∈set cfgs3. array_base aa2 (getAvstore (stateOf cfg3')) = array_base aa2 (getAvstore (stateOf cfg3))) ∧ (∀cfg4'∈set cfgs4. array_base aa2 (getAvstore (stateOf cfg4')) = array_base aa2 (getAvstore (stateOf cfg4))) ∧ (statA = Diff ⟶ statO = Diff))› ‹endPC = 7›*))
qed
qed
lemmas theConds = step0 step1 step2
step1' step3' stepe
proposition "rsecure"
proof (-)
(*goal: ‹rsecure›*)
define m where m: "m ≡ (6::nat)"
define Δs where "Δs": "Δs ≡ λi::nat.
if i = 0 then Δ0
else if i = 1 then Δ1
else if i = 2 then Δ2
else if i = 3 then Δ1'
else if i = 4 then Δ3'
else Δe"
define nxt where nxt: "nxt ≡ λi::nat.
if i = 0 then {0,1,3::nat}
else if i = 1 then {1,2,5}
else if i = 2 then {1}
else if i = 3 then {3,4,5}
else if i = 4 then {4,3}
else {5}"
show "?thesis"
(*goal: ‹rsecure›*)
apply (rule distrib_unwind_rsecure[of m nxt Δs] (*‹⟦0 < m; ⋀i. i < m ⟹ nxt i ⊆ {0..<m}; initCond (Δs 0); ⋀i. i < m ⟹ unwindIntoCond (Δs i) (λw s1 s2 statA sv1 sv2 statO. ∃j∈nxt i. Δs j w s1 s2 statA sv1 sv2 statO)⟧ ⟹ rsecure›*))
(*goal: ‹rsecure›*)
subgoal for
unfolding m
(*goal: ‹0 < 6›*)
by auto
subgoal for
unfolding nxt m
(*goal: ‹i_ < 6 ⟹ (if i_ = 0 then {0, 1, 3} else if i_ = 1 then {1, 2, 5} else if i_ = 2 then {1} else if i_ = 3 then {3, 4, 5} else if i_ = 4 then {4, 3} else {5}) ⊆ {0..<6}›*)
by auto
subgoal for
using init (*‹initCond Δ0›*) unfolding "Δs"
(*goal: ‹initCond (if 0 = 0 then Δ0 else if 0 = 1 then Δ1 else if 0 = 2 then Δ2 else if 0 = 3 then Δ1' else if 0 = 4 then Δ3' else Δe)›*)
by auto
subgoal for
unfolding m nxt "Δs"
(*goal: ‹i_ < 6 ⟹ unwindIntoCond (if i_ = 0 then Δ0 else if i_ = 1 then Δ1 else if i_ = 2 then Δ2 else if i_ = 3 then Δ1' else if i_ = 4 then Δ3' else Δe) (λw s1 s2 statA sv1 sv2 statO. ∃j∈if i_ = 0 then {0, 1, 3} else if i_ = 1 then {1, 2, 5} else if i_ = 2 then {1} else if i_ = 3 then {3, 4, 5} else if i_ = 4 then {4, 3} else {5}. (if j = 0 then Δ0 else if j = 1 then Δ1 else if j = 2 then Δ2 else if j = 3 then Δ1' else if j = 4 then Δ3' else Δe) w s1 s2 statA sv1 sv2 statO)›*)
apply (simp split: if_splits (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
(*goal: ‹i_ < 6 ⟹ unwindIntoCond (if i_ = 0 then Δ0 else if i_ = 1 then Δ1 else if i_ = 2 then Δ2 else if i_ = 3 then Δ1' else if i_ = 4 then Δ3' else Δe) (λw s1 s2 statA sv1 sv2 statO. ∃j∈if i_ = 0 then {0, 1, 3} else if i_ = 1 then {1, 2, 5} else if i_ = 2 then {1} else if i_ = 3 then {3, 4, 5} else if i_ = 4 then {4, 3} else {5}. (if j = 0 then Δ0 else if j = 1 then Δ1 else if j = 2 then Δ2 else if j = 3 then Δ1' else if j = 4 then Δ3' else Δe) w s1 s2 statA sv1 sv2 statO)›*)
using theConds (*‹unwindIntoCond Δ0 (oor3 Δ0 Δ1 Δ1')› ‹unwindIntoCond Δ1 (oor3 Δ1 Δ2 Δe)› ‹unwindIntoCond Δ2 Δ1› ‹unwindIntoCond Δ1' (oor3 Δ1' Δ3' Δe)› ‹unwindIntoCond Δ3' (oor Δ3' Δ1')› ‹unwindIntoCond Δe Δe›*) unfolding oor_def oor3_def oor4_def
(*goal: ‹i_ < 6 ⟹ (i_ = 4 ⟶ unwindIntoCond Δ3' (λw s1 s2 statA sv1 sv2 statO. Δ3' w s1 s2 statA sv1 sv2 statO ∨ Δ1' w s1 s2 statA sv1 sv2 statO)) ∧ (i_ ≠ 4 ⟶ (i_ = 3 ⟶ unwindIntoCond Δ1' (λw s1 s2 statA sv1 sv2 statO. Δ1' w s1 s2 statA sv1 sv2 statO ∨ Δ3' w s1 s2 statA sv1 sv2 statO ∨ Δe w s1 s2 statA sv1 sv2 statO)) ∧ (i_ ≠ 3 ⟶ (i_ = 2 ⟶ unwindIntoCond Δ2 Δ1) ∧ (i_ ≠ 2 ⟶ (i_ = Suc 0 ⟶ unwindIntoCond Δ1 (λw s1 s2 statA sv1 sv2 statO. Δ1 w s1 s2 statA sv1 sv2 statO ∨ Δ2 w s1 s2 statA sv1 sv2 statO ∨ Δe w s1 s2 statA sv1 sv2 statO)) ∧ (i_ ≠ Suc 0 ⟶ (i_ = 0 ⟶ unwindIntoCond Δ0 (λw s1 s2 statA sv1 sv2 statO. Δ0 w s1 s2 statA sv1 sv2 statO ∨ Δ1 w s1 s2 statA sv1 sv2 statO ∨ Δ1' w s1 s2 statA sv1 sv2 statO)) ∧ (0 < i_ ⟶ unwindIntoCond Δe Δe)))))›*)
by auto .
qed
end
end | {
"path": "afp-2025-02-12/thys/IMP_With_Speculation/Examples/Fun4_secure.thy",
"repo": "afp-2025-02-12",
"sha": "f048fe9c8fd3e0c870ae3e9bf8aee8248a8cffe28e647a3e5dc0f200a56bf51a"
} |
theory PNT_Subsummable
imports
"PNT_Remainder_Library"
begin
unbundle pnt_notation
definition has_subsum where "has_subsum f S x ≡ (λn. if n ∈ S then f n else 0) sums x"
definition subsum where "subsum f S ≡ ∑n. if n ∈ S then f n else 0"
definition subsummable (infix "subsummable" 50)
where "f subsummable S ≡ summable (λn. if n ∈ S then f n else 0)"
syntax "_subsum" :: "pttrn ⇒ nat set ⇒ 'a ⇒ 'a"
("(2∑`_ ∈ (_)./ _)" [0, 0, 10] 10)
translations
"∑` x∈S. t" => "CONST subsum (λx. t) S"
syntax "_subsum_prop" :: "pttrn ⇒ bool ⇒ 'a ⇒ 'a"
("(2∑`_ | (_)./ _)" [0, 0, 10] 10)
translations
"∑` x|P. t" => "CONST subsum (λx. t) {x. P}"
syntax "_subsum_ge" :: "pttrn ⇒ nat ⇒ 'a ⇒ 'a"
("(2∑`_ ≥ _./ _)" [0, 0, 10] 10)
translations
"∑` x≥n. t" => "CONST subsum (λx. t) {n..}"
lemma has_subsum_finite:
"finite F ⟹ has_subsum f F (sum f F)"
unfolding has_subsum_def
(*goal: ‹finite F ⟹ (λn. if n ∈ F then f n else 0) sums sum f F›*)
by (rule sums_If_finite_set (*‹finite ?A ⟹ (λr. if r ∈ ?A then ?f r else 0) sums sum ?f ?A›*))
lemma has_subsum_If_finite_set:
assumes "finite F"
shows "has_subsum (λn. if n ∈ F then f n else 0) A (sum f (F ∩ A))"
proof (-)
(*goal: ‹has_subsum (λn. if n ∈ F then f n else 0) A (sum f (F ∩ A))›*)
have "F ∩ A = {x. x ∈ A ∧ x ∈ F}"
by auto
thus "?thesis"
(*goal: ‹has_subsum (λn. if n ∈ F then f n else 0) A (sum f (F ∩ A))›*)
unfolding has_subsum_def
(*goal: ‹(λn. if n ∈ A then if n ∈ F then f n else 0 else 0) sums sum f (F ∩ A)›*)
using assms (*‹finite F›*) by (auto simp add: if_if_eq_conj (*‹(if ?P then if ?Q then ?x else ?y else ?y) = (if ?P ∧ ?Q then ?x else ?y)›*) intro!: sums_If_finite (*‹finite {r. ?P r} ⟹ (λr. if ?P r then ?f r else 0) sums (∑r | ?P r. ?f r)›*))
qed
lemma has_subsum_If_finite:
assumes "finite {n ∈ A. p n}"
shows "has_subsum (λn. if p n then f n else 0) A (sum f {n ∈ A. p n})"
unfolding has_subsum_def
(*goal: ‹(λn. if n ∈ A then if p n then f n else 0 else 0) sums sum f {n ∈ A. p n}›*)
using assms (*‹finite {n ∈ A. p n}›*) by (auto simp add: if_if_eq_conj (*‹(if ?P then if ?Q then ?x else ?y else ?y) = (if ?P ∧ ?Q then ?x else ?y)›*) intro!: sums_If_finite (*‹finite {r. ?P r} ⟹ (λr. if ?P r then ?f r else 0) sums (∑r | ?P r. ?f r)›*))
lemma has_subsum_univ:
"f sums v ⟹ has_subsum f UNIV v"
unfolding has_subsum_def
(*goal: ‹(f::nat ⇒ 'a) sums (v::'a) ⟹ (λn::nat. if n ∈ UNIV then f n else (0::'a)) sums v›*)
by auto
lemma subsumI:
fixes f :: "nat ⇒ 'a :: {t2_space, comm_monoid_add}"
shows "has_subsum f A x ⟹ x = subsum f A"
unfolding has_subsum_def subsum_def
(*goal: ‹(λn. if n ∈ A then f n else 0) sums x ⟹ x = (∑n. if n ∈ A then f n else 0)›*)
by (intro sums_unique (*‹?f sums ?s ⟹ ?s = suminf ?f›*))
lemma has_subsum_summable:
"has_subsum f A x ⟹ f subsummable A"
unfolding has_subsum_def subsummable_def
(*goal: ‹(λn. if n ∈ A then f n else 0) sums x ⟹ summable (λn. if n ∈ A then f n else 0)›*)
by (rule sums_summable (*‹?f sums ?l ⟹ summable ?f›*))
lemma subsummable_sums:
fixes f :: "nat ⇒ 'a :: {comm_monoid_add, t2_space}"
shows "f subsummable S ⟹ has_subsum f S (subsum f S)"
unfolding subsummable_def has_subsum_def subsum_def
(*goal: ‹summable (λn::nat. if n ∈ (S::nat set) then (f::nat ⇒ 'a) n else (0::'a)) ⟹ (λn::nat. if n ∈ S then f n else (0::'a)) sums (∑n::nat. if n ∈ S then f n else (0::'a))›*)
by (intro summable_sums (*‹summable ?f ⟹ ?f sums suminf ?f›*))
lemma has_subsum_diff_finite:
fixes S :: "'a :: {topological_ab_group_add, t2_space}"
assumes "finite F" "has_subsum f A S" "F ⊆ A"
shows "has_subsum f (A - F) (S - sum f F)"
proof (-)
(*goal: ‹has_subsum f (A - F) (S - sum f F)›*)
define p where "p n ≡ if n ∈ F then 0 else (if n ∈ A then f n else 0)" for n
define q where "q n ≡ if n ∈ A - F then f n else 0" for n
have "F ∩ A = F"
using assms(3) (*‹F ⊆ A›*) by auto
hence "p sums (S - sum f F)"
using assms (*‹finite F› ‹has_subsum f A S› ‹F ⊆ A›*) unfolding p_def has_subsum_def
(*goal: ‹(λn. if n ∈ F then 0 else if n ∈ A then f n else 0) sums (S - sum f F)›*)
by (auto intro: sums_If_finite_set' [where ?S = S] (*‹⟦(?g::nat ⇒ 'a::{topological_ab_group_add,t2_space}) sums (S::'a::{topological_ab_group_add,t2_space}); finite (?A::nat set); (?S'::'a::{topological_ab_group_add,t2_space}) = S + (∑n::nat∈?A. (?f::nat ⇒ 'a::{topological_ab_group_add,t2_space}) n - ?g n)⟧ ⟹ (λn::nat. if n ∈ ?A then ?f n else ?g n) sums ?S'›*) simp: sum_negf (*‹(∑x::?'b::type∈(?A::?'b::type set). - (?f::?'b::type ⇒ ?'a::ab_group_add) x) = - sum ?f ?A›*) sum.inter_restrict [symmetric] (*‹finite (?A::?'b::type set) ⟹ (∑x::?'b::type∈?A. if x ∈ (?B::?'b::type set) then (?g::?'b::type ⇒ ?'a::comm_monoid_add) x else (0::?'a::comm_monoid_add)) = sum ?g (?A ∩ ?B)›*))
moreover have "p = q"
unfolding p_def q_def
(*goal: ‹(λn. if n ∈ F then 0 else if n ∈ A then f n else 0) = (λn. if n ∈ A - F then f n else 0)›*)
by auto
finally (*calculation: ‹q sums (S - sum f F)›*) show "?thesis"
(*goal: ‹has_subsum f (A - F) (S - sum f F)›*)
unfolding q_def has_subsum_def
(*goal: ‹(λn. if n ∈ A - F then f n else 0) sums (S - sum f F)›*)
by auto
qed
lemma subsum_split:
fixes f :: "nat ⇒ 'a :: {topological_ab_group_add, t2_space}"
assumes "f subsummable A" "finite F" "F ⊆ A"
shows "subsum f A = sum f F + subsum f (A - F)"
proof (-)
(*goal: ‹subsum f A = sum f F + subsum f (A - F)›*)
from assms(1) (*‹f subsummable A›*) have "has_subsum f A (subsum f A)"
by (intro subsummable_sums (*‹?f subsummable ?S ⟹ has_subsum ?f ?S (subsum ?f ?S)›*))
hence "has_subsum f (A - F) (subsum f A - sum f F)"
using assms (*‹f subsummable A› ‹finite F› ‹F ⊆ A›*) apply (intro has_subsum_diff_finite (*‹⟦finite ?F; has_subsum ?f ?A ?S; ?F ⊆ ?A⟧ ⟹ has_subsum ?f (?A - ?F) (?S - sum ?f ?F)›*))
(*goals:
1. ‹⟦has_subsum f A (subsum f A); f subsummable A; finite F; F ⊆ A⟧ ⟹ finite F›
2. ‹⟦has_subsum f A (subsum f A); f subsummable A; finite F; F ⊆ A⟧ ⟹ has_subsum f A (subsum f A)›
3. ‹⟦has_subsum f A (subsum f A); f subsummable A; finite F; F ⊆ A⟧ ⟹ F ⊆ A›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*)
apply ((assumption)[1])
(*discuss goal 3*) .
(*proven 3 subgoals*)
hence "subsum f A - sum f F = subsum f (A - F)"
by (rule subsumI (*‹has_subsum ?f ?A ?x ⟹ ?x = subsum ?f ?A›*))
thus "?thesis"
(*goal: ‹subsum (f::nat ⇒ 'a::{topological_ab_group_add,t2_space}) (A::nat set) = sum f (F::nat set) + subsum f (A - F)›*)
by (auto simp add: algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 34 facts*))
qed
lemma has_subsum_zero [simp]: "has_subsum (λn. 0) A 0" unfolding has_subsum_def
(*goal: ‹(λn. if n ∈ A then 0 else 0) sums 0›*)
by auto
lemma zero_subsummable [simp]: "(λn. 0) subsummable A" unfolding subsummable_def
(*goal: ‹summable (λn. if n ∈ A then 0 else 0)›*)
by auto
lemma zero_subsum [simp]: "(∑`n∈A. 0 :: 'a :: {comm_monoid_add, t2_space}) = 0" unfolding subsum_def
(*goal: ‹(∑n. if n ∈ A then 0 else 0) = 0›*)
by auto
lemma has_subsum_minus:
fixes f :: "nat ⇒ 'a :: real_normed_vector"
assumes "has_subsum f A a" "has_subsum g A b"
shows "has_subsum (λn. f n - g n) A (a - b)"
proof (-)
(*goal: ‹has_subsum (λn. f n - g n) A (a - b)›*)
define p where "p n = (if n ∈ A then f n else 0)" for n
define q where "q n = (if n ∈ A then g n else 0)" for n
have "(λn. p n - q n) sums (a - b)"
using assms (*‹has_subsum (f::nat ⇒ 'a) (A::nat set) (a::'a)› ‹has_subsum g A b›*) unfolding p_def q_def has_subsum_def
(*goal: ‹(λn. (if n ∈ A then f n else 0) - (if n ∈ A then g n else 0)) sums (a - b)›*)
apply (intro sums_diff (*‹⟦?f sums ?a; ?g sums ?b⟧ ⟹ (λn. ?f n - ?g n) sums (?a - ?b)›*))
(*goals:
1. ‹⟦(λn. if n ∈ A then f n else 0) sums a; (λn. if n ∈ A then g n else 0) sums b⟧ ⟹ (λn. if n ∈ A then f n else 0) sums a›
2. ‹⟦(λn. if n ∈ A then f n else 0) sums a; (λn. if n ∈ A then g n else 0) sums b⟧ ⟹ (λn. if n ∈ A then g n else 0) sums b›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
moreover have "(if n ∈ A then f n - g n else 0) = p n - q n" for n
unfolding p_def q_def
(*goal: ‹(if n ∈ A then f n - g n else 0) = (if n ∈ A then f n else 0) - (if n ∈ A then g n else 0)›*)
by auto
ultimately show "?thesis"
(*goal: ‹has_subsum (λn::nat. (f::nat ⇒ 'a) n - (g::nat ⇒ 'a) n) (A::nat set) ((a::'a) - (b::'a))›*)
unfolding has_subsum_def
(*goal: ‹(λn::nat. if n ∈ (A::nat set) then (f::nat ⇒ 'a) n - (g::nat ⇒ 'a) n else (0::'a)) sums ((a::'a) - (b::'a))›*)
by auto
qed
lemma subsum_minus:
assumes "f subsummable A" "g subsummable A"
shows "subsum f A - subsum g A = (∑`n∈A. f n - g n :: 'a :: real_normed_vector)"
by (intro subsumI (*‹has_subsum ?f ?A ?x ⟹ ?x = subsum ?f ?A›*) has_subsum_minus (*‹⟦has_subsum ?f ?A ?a; has_subsum ?g ?A ?b⟧ ⟹ has_subsum (λn. ?f n - ?g n) ?A (?a - ?b)›*) subsummable_sums (*‹?f subsummable ?S ⟹ has_subsum ?f ?S (subsum ?f ?S)›*) assms (*‹f subsummable A› ‹g subsummable A›*))
lemma subsummable_minus:
assumes "f subsummable A" "g subsummable A"
shows "(λn. f n - g n :: 'a :: real_normed_vector) subsummable A"
by (auto intro: has_subsum_summable (*‹has_subsum ?f ?A ?x ⟹ ?f subsummable ?A›*) has_subsum_minus (*‹⟦has_subsum ?f ?A ?a; has_subsum ?g ?A ?b⟧ ⟹ has_subsum (λn. ?f n - ?g n) ?A (?a - ?b)›*) subsummable_sums (*‹?f subsummable ?S ⟹ has_subsum ?f ?S (subsum ?f ?S)›*) assms (*‹f subsummable A› ‹g subsummable A›*))
lemma has_subsum_uminus:
assumes "has_subsum f A a"
shows "has_subsum (λn. - f n :: 'a :: real_normed_vector) A (- a)"
proof (-)
(*goal: ‹has_subsum (λn::nat. - (f::nat ⇒ 'a) n) (A::nat set) (- (a::'a))›*)
have "has_subsum (λn. 0 - f n) A (0 - a)"
apply (intro has_subsum_minus (*‹⟦has_subsum ?f ?A ?a; has_subsum ?g ?A ?b⟧ ⟹ has_subsum (λn. ?f n - ?g n) ?A (?a - ?b)›*))
(*goals:
1. ‹has_subsum (λn. 0) A 0›
2. ‹has_subsum f A a›
discuss goal 1*)
apply ((use assms in auto)[1])
(*discuss goal 2*)
apply ((use assms in auto)[1])
(*proven 2 subgoals*) .
thus "?thesis"
(*goal: ‹has_subsum (λn::nat. - (f::nat ⇒ 'a::real_normed_vector) n) (A::nat set) (- (a::'a::real_normed_vector))›*)
by auto
qed
lemma subsum_uminus:
"f subsummable A ⟹ - subsum f A = (∑`n∈A. - f n :: 'a :: real_normed_vector)"
by (intro subsumI (*‹has_subsum ?f ?A ?x ⟹ ?x = subsum ?f ?A›*) has_subsum_uminus (*‹has_subsum ?f ?A ?a ⟹ has_subsum (λn. - ?f n) ?A (- ?a)›*) subsummable_sums (*‹?f subsummable ?S ⟹ has_subsum ?f ?S (subsum ?f ?S)›*))
lemma subsummable_uminus:
"f subsummable A ⟹ (λn. - f n :: 'a :: real_normed_vector) subsummable A"
by (auto intro: has_subsum_summable (*‹has_subsum ?f ?A ?x ⟹ ?f subsummable ?A›*) has_subsum_uminus (*‹has_subsum ?f ?A ?a ⟹ has_subsum (λn. - ?f n) ?A (- ?a)›*) subsummable_sums (*‹?f subsummable ?S ⟹ has_subsum ?f ?S (subsum ?f ?S)›*))
lemma has_subsum_add:
fixes f :: "nat ⇒ 'a :: real_normed_vector"
assumes "has_subsum f A a" "has_subsum g A b"
shows "has_subsum (λn. f n + g n) A (a + b)"
proof (-)
(*goal: ‹has_subsum (λn. f n + g n) A (a + b)›*)
have "has_subsum (λn. f n - - g n) A (a - - b)"
by (intro has_subsum_minus (*‹⟦has_subsum (?f::nat ⇒ ?'a::real_normed_vector) (?A::nat set) (?a::?'a::real_normed_vector); has_subsum (?g::nat ⇒ ?'a::real_normed_vector) ?A (?b::?'a::real_normed_vector)⟧ ⟹ has_subsum (λn::nat. ?f n - ?g n) ?A (?a - ?b)›*) has_subsum_uminus (*‹has_subsum (?f::nat ⇒ ?'a::real_normed_vector) (?A::nat set) (?a::?'a::real_normed_vector) ⟹ has_subsum (λn::nat. - ?f n) ?A (- ?a)›*) assms (*‹has_subsum (f::nat ⇒ 'a::real_normed_vector) (A::nat set) (a::'a::real_normed_vector)› ‹has_subsum (g::nat ⇒ 'a::real_normed_vector) (A::nat set) (b::'a::real_normed_vector)›*))
thus "?thesis"
(*goal: ‹has_subsum (λn. f n + g n) A (a + b)›*)
by auto
qed
lemma subsum_add:
assumes "f subsummable A" "g subsummable A"
shows "subsum f A + subsum g A = (∑`n∈A. f n + g n :: 'a :: real_normed_vector)"
by (intro subsumI (*‹has_subsum (?f::nat ⇒ ?'a) (?A::nat set) (?x::?'a) ⟹ ?x = subsum ?f ?A›*) has_subsum_add (*‹⟦has_subsum (?f::nat ⇒ ?'a) (?A::nat set) (?a::?'a); has_subsum (?g::nat ⇒ ?'a) ?A (?b::?'a)⟧ ⟹ has_subsum (λn::nat. ?f n + ?g n) ?A (?a + ?b)›*) subsummable_sums (*‹(?f::nat ⇒ ?'a) subsummable (?S::nat set) ⟹ has_subsum ?f ?S (subsum ?f ?S)›*) assms (*‹(f::nat ⇒ 'a) subsummable (A::nat set)› ‹(g::nat ⇒ 'a) subsummable (A::nat set)›*))
lemma subsummable_add:
assumes "f subsummable A" "g subsummable A"
shows "(λn. f n + g n :: 'a :: real_normed_vector) subsummable A"
by (auto intro: has_subsum_summable (*‹has_subsum ?f ?A ?x ⟹ ?f subsummable ?A›*) has_subsum_add (*‹⟦has_subsum ?f ?A ?a; has_subsum ?g ?A ?b⟧ ⟹ has_subsum (λn. ?f n + ?g n) ?A (?a + ?b)›*) subsummable_sums (*‹?f subsummable ?S ⟹ has_subsum ?f ?S (subsum ?f ?S)›*) assms (*‹f subsummable A› ‹g subsummable A›*))
lemma subsum_cong:
"(⋀x. x ∈ A ⟹ f x = g x) ⟹ subsum f A = subsum g A"
unfolding subsum_def
(*goal: ‹(⋀x. x ∈ A ⟹ f x = g x) ⟹ (∑n. if n ∈ A then f n else 0) = (∑n. if n ∈ A then g n else 0)›*)
apply (intro suminf_cong (*‹(⋀n. ?f n = ?g n) ⟹ suminf ?f = suminf ?g›*))
(*goal: ‹(⋀x. x ∈ A ⟹ f x = g x) ⟹ (∑n. if n ∈ A then f n else 0) = (∑n. if n ∈ A then g n else 0)›*)
by auto
lemma subsummable_cong:
fixes f :: "nat ⇒ 'a :: real_normed_vector"
shows "(⋀x. x ∈ A ⟹ f x = g x) ⟹ (f subsummable A) = (g subsummable A)"
unfolding subsummable_def
(*goal: ‹(⋀x::nat. x ∈ (A::nat set) ⟹ (f::nat ⇒ 'a::real_normed_vector) x = (g::nat ⇒ 'a::real_normed_vector) x) ⟹ summable (λn::nat. if n ∈ A then f n else (0::'a::real_normed_vector)) = summable (λn::nat. if n ∈ A then g n else (0::'a::real_normed_vector))›*)
apply (intro summable_cong (*‹∀⇩F x::nat in sequentially. (?f::nat ⇒ ?'a) x = (?g::nat ⇒ ?'a) x ⟹ summable ?f = summable ?g›*))
(*goal: ‹(⋀x. x ∈ A ⟹ f x = g x) ⟹ summable (λn. if n ∈ A then f n else 0) = summable (λn. if n ∈ A then g n else 0)›*)
by auto
lemma subsum_norm_bound:
fixes f :: "nat ⇒ 'a :: banach"
assumes "g subsummable A" "⋀n. n ∈ A ⟹ ∥f n∥ ≤ g n"
shows "∥subsum f A∥ ≤ subsum g A"
using assms (*‹g subsummable A› ‹?n ∈ A ⟹ ∥f ?n∥ ≤ g ?n›*) unfolding subsummable_def subsum_def
(*goal: ‹∥∑n. if n ∈ A then f n else 0∥ ≤ (∑n. if n ∈ A then g n else 0)›*)
apply (intro suminf_norm_bound (*‹⟦summable (?g::nat ⇒ real); ⋀n::nat. ∥(?f::nat ⇒ ?'a) n∥ ≤ ?g n⟧ ⟹ ∥suminf ?f∥ ≤ (∑n::nat. ?g n)›*))
(*goals:
1. ‹⟦summable (λn. if n ∈ A then g n else 0); ⋀n. n ∈ A ⟹ ∥f n∥ ≤ g n⟧ ⟹ summable (λn. if n ∈ A then g n else 0)›
2. ‹⋀n. ⟦summable (λn. if n ∈ A then g n else 0); ⋀n. n ∈ A ⟹ ∥f n∥ ≤ g n⟧ ⟹ ∥if n ∈ A then f n else 0∥ ≤ (if n ∈ A then g n else 0)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma eval_fds_subsum:
fixes f :: "'a :: {nat_power, banach, real_normed_field} fds"
assumes "fds_converges f s"
shows "has_subsum (λn. fds_nth f n / nat_power n s) {1..} (eval_fds f s)"
proof (-)
(*goal: ‹has_subsum (λn. fds_nth f n / nat_power n s) {1..} (eval_fds f s)›*)
let ?f = "λn. fds_nth f n / nat_power n s"
let ?v = "eval_fds f s"
have "has_subsum (λn. ?f n) UNIV ?v"
by (intro has_subsum_univ (*‹?f sums ?v ⟹ has_subsum ?f UNIV ?v›*) fds_converges_iff [THEN iffD1] (*‹fds_converges ?f1 ?s1 ⟹ (λn. fds_nth ?f1 n / nat_power n ?s1) sums eval_fds ?f1 ?s1›*) assms (*‹fds_converges f s›*))
hence "has_subsum ?f (UNIV - {0}) (?v - sum ?f {0})"
apply (intro has_subsum_diff_finite (*‹⟦finite ?F; has_subsum ?f ?A ?S; ?F ⊆ ?A⟧ ⟹ has_subsum ?f (?A - ?F) (?S - sum ?f ?F)›*))
(*goals:
1. ‹has_subsum (λn. fds_nth f n / nat_power n s) UNIV (eval_fds f s) ⟹ finite {0}›
2. ‹has_subsum (λn. fds_nth f n / nat_power n s) UNIV (eval_fds f s) ⟹ has_subsum (λn. fds_nth f n / nat_power n s) UNIV (eval_fds f s)›
3. ‹has_subsum (λn. fds_nth f n / nat_power n s) UNIV (eval_fds f s) ⟹ {0} ⊆ UNIV›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
moreover have "UNIV - {0 :: nat} = {1..}"
by auto
ultimately show "?thesis"
(*goal: ‹has_subsum (λn. fds_nth f n / nat_power n s) {1..} (eval_fds f s)›*)
by auto
qed
lemma fds_abs_subsummable:
fixes f :: "'a :: {nat_power, banach, real_normed_field} fds"
assumes "fds_abs_converges f s"
shows "(λn. ∥fds_nth f n / nat_power n s∥) subsummable {1..}"
proof (-)
(*goal: ‹(λn. ∥fds_nth f n / nat_power n s∥) subsummable {1..}›*)
have "summable (λn. ∥fds_nth f n / nat_power n s∥)"
apply (subst fds_abs_converges_def [symmetric] (*‹summable (λn. ∥fds_nth ?f n / nat_power n ?s∥) = fds_abs_converges ?f ?s›*))
(*goal: ‹summable (λn::nat. ∥fds_nth (f::'a::{nat_power,banach,real_normed_field} fds) n / nat_power n (s::'a::{nat_power,banach,real_normed_field})∥)›*)
by (rule assms (*‹fds_abs_converges f s›*))
moreover have "∥fds_nth f n / nat_power n s∥ = 0" if "¬ 1 ≤ n" for n
proof (-)
(*goal: ‹∥fds_nth f n / nat_power n s∥ = 0›*)
have "n = 0"
using that (*‹¬ 1 ≤ n›*) by auto
thus "?thesis"
(*goal: ‹∥fds_nth f n / nat_power n s∥ = 0›*)
by auto
qed
hence "(λn. if 1 ≤ n then ∥fds_nth f n / nat_power n s∥ else 0)
= (λn. ∥fds_nth f n / nat_power n s∥)"
by auto
ultimately show "?thesis"
(*goal: ‹(λn. ∥fds_nth f n / nat_power n s∥) subsummable {1..}›*)
unfolding subsummable_def
(*goal: ‹summable (λn. if n ∈ {1..} then ∥fds_nth f n / nat_power n s∥ else 0)›*)
by auto
qed
lemma subsum_mult2:
fixes f :: "nat ⇒ 'a :: real_normed_algebra"
shows "f subsummable A ⟹ (∑`x∈A. f x * c) = subsum f A * c"
unfolding subsum_def subsummable_def
(*goal: ‹summable (λn::nat. if n ∈ (A::nat set) then (f::nat ⇒ 'a) n else (0::'a)) ⟹ (∑n::nat. if n ∈ A then f n * (c::'a) else (0::'a)) = (∑n::nat. if n ∈ A then f n else (0::'a)) * c›*)
apply (subst suminf_mult2 (*‹summable ?f ⟹ suminf ?f * ?c = (∑n. ?f n * ?c)›*))
(*goals:
1. ‹summable (λn::nat. if n ∈ (A::nat set) then (f::nat ⇒ 'a) n else (0::'a)) ⟹ summable (λn::nat. if n ∈ A then f n else (0::'a))›
2. ‹summable (λn::nat. if n ∈ (A::nat set) then (f::nat ⇒ 'a) n else (0::'a)) ⟹ (∑n::nat. if n ∈ A then f n * (c::'a) else (0::'a)) = (∑n::nat. (if n ∈ A then f n else (0::'a)) * c)›
discuss goal 1*)
apply ((auto intro: suminf_cong (*‹(⋀n::nat. (?f::nat ⇒ ?'a) n = (?g::nat ⇒ ?'a) n) ⟹ suminf ?f = suminf ?g›*))[1])
(*discuss goal 2*)
apply ((auto intro: suminf_cong (*‹(⋀n. ?f n = ?g n) ⟹ suminf ?f = suminf ?g›*))[1])
(*proven 2 subgoals*) .
lemma subsummable_mult2:
fixes f :: "nat ⇒ 'a :: real_normed_algebra"
assumes "f subsummable A"
shows "(λx. f x * c) subsummable A"
proof (-)
(*goal: ‹(λx. f x * c) subsummable A›*)
have "summable (λn. (if n ∈ A then f n else 0) * c)" (is "?P")
using assms (*‹f subsummable A›*) unfolding subsummable_def
(*goal: ‹summable (λn. (if n ∈ A then f n else 0) * c)›*)
by (intro summable_mult2 (*‹summable (?f::nat ⇒ ?'a) ⟹ summable (λn::nat. ?f n * (?c::?'a))›*))
moreover have "?P = ?thesis"
unfolding subsummable_def
(*goal: ‹summable (λn. (if n ∈ A then f n else 0) * c) = summable (λn. if n ∈ A then f n * c else 0)›*)
apply (rule summable_cong (*‹∀⇩F x in sequentially. ?f x = ?g x ⟹ summable ?f = summable ?g›*))
(*goal: ‹summable (λn. (if n ∈ A then f n else 0) * c) = summable (λn. if n ∈ A then f n * c else 0)›*)
by auto
ultimately show "?thesis"
(*goal: ‹(λx::nat. (f::nat ⇒ 'a) x * (c::'a)) subsummable (A::nat set)›*)
by auto
qed
lemma subsum_ge_limit:
"lim (λN. ∑n = m..N. f n) = (∑`n ≥ m. f n)"
proof (-)
(*goal: ‹lim (λN. sum f {m..N}) = subsum f {m..}›*)
define g where "g n ≡ if n ∈ {m..} then f n else 0" for n
have "(∑n. g n) = lim (λN. ∑n<N. g n)"
by (rule suminf_eq_lim (*‹suminf (?f::nat ⇒ ?'a::{comm_monoid_add,t2_space}) = lim (λn::nat. sum ?f {..<n})›*))
also (*calculation: ‹(∑n. g n) = lim (λN. sum g {..<N})›*) have "… = lim (λN. ∑n<N + 1. g n)"
unfolding lim_def
(*goal: ‹(THE L. (λN. sum g {..<N}) ⇢ L) = (THE L. (λN. sum g {..<N + 1}) ⇢ L)›*)
using LIMSEQ_ignore_initial_segment (*‹(?f::nat ⇒ ?'a::topological_space) ⇢ (?a::?'a::topological_space) ⟹ (λn::nat. ?f (n + (?k::nat))) ⇢ ?a›*) LIMSEQ_offset (*‹(λn. ?f (n + ?k)) ⇢ ?a ⟹ ?f ⇢ ?a›*) apply (intro The_cong (*‹(⋀x. ?P x = ?Q x) ⟹ The ?P = The ?Q›*) iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))
(*goals:
1. ‹⋀x. ⟦⋀f a k. f ⇢ a ⟹ (λn. f (n + k)) ⇢ a; ⋀f k a. (λn. f (n + k)) ⇢ a ⟹ f ⇢ a; (λN. sum g {..<N}) ⇢ x⟧ ⟹ (λN. sum g {..<N + 1}) ⇢ x›
2. ‹⋀x. ⟦⋀f a k. f ⇢ a ⟹ (λn. f (n + k)) ⇢ a; ⋀f k a. (λn. f (n + k)) ⇢ a ⟹ f ⇢ a; (λN. sum g {..<N + 1}) ⇢ x⟧ ⟹ (λN. sum g {..<N}) ⇢ x›
discuss goal 1*)
apply blast
(*discuss goal 2*) .
(*proven 2 subgoals*)
also (*calculation: ‹(∑n::nat. (g::nat ⇒ 'a::{comm_monoid_add,t2_space}) n) = lim (λN::nat. sum g {..<N + (1::nat)})›*) have "… = lim (λN. ∑n = m..N. f n)"
proof (-)
(*goal: ‹lim (λN. sum g {..<N + 1}) = lim (λN. sum f {m..N})›*)
have "{x. x < N + 1 ∧ m ≤ x} = {m..N}" for N
by auto
thus "?thesis"
(*goal: ‹lim (λN. sum g {..<N + 1}) = lim (λN. sum f {m..N})›*)
unfolding g_def
(*goal: ‹lim (λN. ∑n<N + 1. if n ∈ {m..} then f n else 0) = lim (λN. sum f {m..N})›*)
apply (subst sum.inter_filter [symmetric] (*‹finite ?A ⟹ (∑x∈?A. if ?P x then ?g x else 0) = sum ?g {x ∈ ?A. ?P x}›*))
(*goals:
1. ‹⋀N. (⋀N. {x. x < N + 1 ∧ m ≤ x} = {m..N}) ⟹ finite {..<N + 1}›
2. ‹(⋀N. {x. x < N + 1 ∧ m ≤ x} = {m..N}) ⟹ lim (λN. sum f {x ∈ {..<N + 1}. x ∈ {m..}}) = lim (λN. sum f {m..N})›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
qed
finally (*calculation: ‹(∑n. g n) = lim (λN. sum f {m..N})›*) show "?thesis"
(*goal: ‹lim (λN::nat. sum (f::nat ⇒ 'a) {m::nat..N}) = subsum f {m..}›*)
unfolding subsum_def g_def
(*goal: ‹lim (λN. sum f {m..N}) = (∑n. if n ∈ {m..} then f n else 0)›*)
by auto
qed
lemma has_subsum_ge_limit:
fixes f :: "nat ⇒ 'a :: {t2_space, comm_monoid_add, topological_space}"
assumes "((λN. ∑n = m..N. f n) ⤏ l) at_top"
shows "has_subsum f {m..} l"
proof (-)
(*goal: ‹has_subsum f {m..} l›*)
define g where "g n ≡ if n ∈ {m..} then f n else 0" for n
have "((λN. ∑n<N + 1. g n) ⤏ l) at_top"
proof (-)
(*goal: ‹(λN::nat. sum (g::nat ⇒ 'a) {..<N + (1::nat)}) ⇢ (l::'a)›*)
have "{x. x < N + 1 ∧ m ≤ x} = {m..N}" for N
by auto
with assms (*‹(λN. sum f {m..N}) ⇢ l›*) show "?thesis"
(*goal: ‹(λN. sum g {..<N + 1}) ⇢ l›*)
unfolding g_def
(*goal: ‹(λN. ∑n<N + 1. if n ∈ {m..} then f n else 0) ⇢ l›*)
apply (subst sum.inter_filter [symmetric] (*‹finite ?A ⟹ (∑x∈?A. if ?P x then ?g x else 0) = sum ?g {x ∈ ?A. ?P x}›*))
(*goals:
1. ‹⋀N. ⟦(λN. sum f {m..N}) ⇢ l; ⋀N. {x. x < N + 1 ∧ m ≤ x} = {m..N}⟧ ⟹ finite {..<N + 1}›
2. ‹⟦(λN. sum f {m..N}) ⇢ l; ⋀N. {x. x < N + 1 ∧ m ≤ x} = {m..N}⟧ ⟹ (λN. sum f {x ∈ {..<N + 1}. x ∈ {m..}}) ⇢ l›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
qed
hence "((λN. ∑n<N. g n) ⤏ l) at_top"
by (rule LIMSEQ_offset (*‹(λn. ?f (n + ?k)) ⇢ ?a ⟹ ?f ⇢ ?a›*))
thus "?thesis"
(*goal: ‹has_subsum f {m..} l›*)
unfolding has_subsum_def sums_def g_def
(*goal: ‹(λn. ∑n<n. if n ∈ {m..} then f n else 0) ⇢ l›*)
by auto
qed
lemma eval_fds_complex:
fixes f :: "complex fds"
assumes "fds_converges f s"
shows "has_subsum (λn. fds_nth f n / n nat_powr s) {1..} (eval_fds f s)"
proof (-)
(*goal: ‹has_subsum (λn::nat. fds_nth (f::complex fds) n / n nat_powr (s::complex)) {1::nat..} (eval_fds f s)›*)
have "has_subsum (λn. fds_nth f n / nat_power n s) {1..} (eval_fds f s)"
by (intro eval_fds_subsum (*‹fds_converges ?f ?s ⟹ has_subsum (λn. fds_nth ?f n / nat_power n ?s) {1..} (eval_fds ?f ?s)›*) assms (*‹fds_converges f s›*))
thus "?thesis"
(*goal: ‹has_subsum (λn. fds_nth f n / n nat_powr s) {1..} (eval_fds f s)›*)
unfolding nat_power_complex_def
(*goal: ‹has_subsum (λn::nat. fds_nth (f::complex fds) n / n nat_powr (s::complex)) {1::nat..} (eval_fds f s)›*) .
qed
lemma eval_fds_complex_subsum:
fixes f :: "complex fds"
assumes "fds_converges f s"
shows "eval_fds f s = (∑`n ≥ 1. fds_nth f n / n nat_powr s)"
"(λn. fds_nth f n / n nat_powr s) subsummable {1..}"
proof (goal_cases)
(*goals:
1. ‹eval_fds (f::complex fds) (s::complex) = subsum (λn::nat. fds_nth f n / n nat_powr s) {1::nat..}›
2. ‹(λn::nat. fds_nth (f::complex fds) n / n nat_powr (s::complex)) subsummable {1::nat..}›*)
case 1 (*no hyothesis introduced yet*)
show "?case"
(*goal: ‹eval_fds f s = subsum (λn. fds_nth f n / n nat_powr s) {1..}›*)
by (intro subsumI (*‹has_subsum ?f ?A ?x ⟹ ?x = subsum ?f ?A›*) eval_fds_complex (*‹fds_converges ?f ?s ⟹ has_subsum (λn. fds_nth ?f n / n nat_powr ?s) {1..} (eval_fds ?f ?s)›*) assms (*‹fds_converges f s›*))
case 2 (*no hyothesis introduced yet*)
show "?case"
(*goal: ‹(λn. fds_nth f n / n nat_powr s) subsummable {1..}›*)
apply (intro has_subsum_summable (*‹has_subsum ?f ?A ?x ⟹ ?f subsummable ?A›*))
(*goal: ‹(λn. fds_nth f n / n nat_powr s) subsummable {1..}›*)
apply (rule eval_fds_complex (*‹fds_converges ?f ?s ⟹ has_subsum (λn. fds_nth ?f n / n nat_powr ?s) {1..} (eval_fds ?f ?s)›*) assms (*‹fds_converges f s›*))
(*goal: ‹has_subsum (λn. fds_nth f n / n nat_powr s) {1..} ?x›*)
by (rule eval_fds_complex (*‹fds_converges (?f::complex fds) (?s::complex) ⟹ has_subsum (λn::nat. fds_nth ?f n / n nat_powr ?s) {1::nat..} (eval_fds ?f ?s)›*) assms (*‹fds_converges (f::complex fds) (s::complex)›*))
qed
lemma has_sum_imp_has_subsum:
fixes x :: "'a :: {comm_monoid_add, t2_space}"
assumes "(f has_sum x) A"
shows "has_subsum f A x"
proof (-)
(*goal: ‹has_subsum f A x›*)
have "(∀⇩F x in at_top. sum f ({..<x} ∩ A) ∈ S)" if "open S" "x ∈ S" for S
proof (-)
(*goal: ‹∀⇩F x::nat in sequentially. sum (f::nat ⇒ 'a) ({..<x} ∩ (A::nat set)) ∈ (S::'a set)›*)
have "∀S. open S ⟶ x ∈ S ⟶ (∀⇩F x in finite_subsets_at_top A. sum f x ∈ S)"
using assms (*‹(f has_sum x) A›*) unfolding has_sum_def tendsto_def
(*goal: ‹∀S. open S ⟶ x ∈ S ⟶ (∀⇩F x in finite_subsets_at_top A. sum f x ∈ S)›*) .
hence "∀⇩F x in finite_subsets_at_top A. sum f x ∈ S"
using that (*‹open S› ‹x ∈ S›*) by auto
then obtain X where hX: "finite X" "X ⊆ A" and hY: "⋀Y. finite Y ⟹ X ⊆ Y ⟹ Y ⊆ A ⟹ sum f Y ∈ S"
(*goal: ‹(⋀X. ⟦finite X; X ⊆ A; ⋀Y. ⟦finite Y; X ⊆ Y; Y ⊆ A⟧ ⟹ sum f Y ∈ S⟧ ⟹ thesis) ⟹ thesis›*)
unfolding eventually_finite_subsets_at_top
(*goal: ‹(⋀X. ⟦finite X; X ⊆ A; ⋀Y. ⟦finite Y; X ⊆ Y; Y ⊆ A⟧ ⟹ sum f Y ∈ S⟧ ⟹ thesis) ⟹ thesis›*)
by metis
define n where "n ≡ Max X + 1"
show "?thesis"
(*goal: ‹∀⇩F x in sequentially. sum f ({..<x} ∩ A) ∈ S›*)
apply (subst eventually_sequentially (*‹eventually ?P sequentially = (∃N. ∀n≥N. ?P n)›*))
(*goal: ‹∀⇩F x in sequentially. sum f ({..<x} ∩ A) ∈ S›*)
apply standard
(*goal: ‹∃N. ∀n≥N. sum f ({..<n} ∩ A) ∈ S›*)
proof (safe)
(*goal: ‹⋀n. ?N ≤ n ⟹ sum f ({..<n} ∩ A) ∈ S›*)
fix m
assume Hm: "n ≤ m" (*‹(n::nat) ≤ (m::nat)›*)
moreover have "x ∈ X ⟹ x < n" for x
unfolding n_def
(*goal: ‹(x::nat) ∈ (X::nat set) ⟹ x < Max X + (1::nat)›*)
using Max_ge[OF hX ( 1 ), of x] (*‹x ∈ X ⟹ x ≤ Max X›*) by auto
ultimately show "sum f ({..<m} ∩ A) ∈ S"
using hX(2) (*‹X ⊆ A›*) apply (intro hY (*‹⟦finite (?Y::nat set); (X::nat set) ⊆ ?Y; ?Y ⊆ (A::nat set)⟧ ⟹ sum (f::nat ⇒ 'a) ?Y ∈ (S::'a set)›*))
(*goals:
1. ‹⟦n ≤ m; ⋀x. x ∈ X ⟹ x < n; X ⊆ A⟧ ⟹ finite ({..<m} ∩ A)›
2. ‹⟦n ≤ m; ⋀x. x ∈ X ⟹ x < n; X ⊆ A⟧ ⟹ X ⊆ {..<m} ∩ A›
3. ‹⟦n ≤ m; ⋀x. x ∈ X ⟹ x < n; X ⊆ A⟧ ⟹ {..<m} ∩ A ⊆ A›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*top goal: ‹⟦n ≤ m; ⋀x. x ∈ X ⟹ x < n; X ⊆ A⟧ ⟹ X ⊆ {..<m} ∩ A› and 1 goal remains*)
apply (metis order.strict_trans2 (*‹⟦?a < ?b; ?b ≤ ?c⟧ ⟹ ?a < ?c›*))
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
qed
qed
thus "?thesis"
(*goal: ‹has_subsum (f::nat ⇒ 'a::{comm_monoid_add,t2_space}) (A::nat set) (x::'a::{comm_monoid_add,t2_space})›*)
unfolding has_subsum_def sums_def tendsto_def
(*goal: ‹∀S. open S ⟶ x ∈ S ⟶ (∀⇩F x in sequentially. (∑n<x. if n ∈ A then f n else 0) ∈ S)›*)
by (simp add: sum.inter_restrict [symmetric] (*‹finite ?A ⟹ (∑x∈?A. if x ∈ ?B then ?g x else 0) = sum ?g (?A ∩ ?B)›*))
qed
unbundle no_pnt_notation
end
| {
"path": "afp-2025-02-12/thys/PNT_with_Remainder/PNT_Subsummable.thy",
"repo": "afp-2025-02-12",
"sha": "8bb38532db8de0f002dbdb9c8bb619b5a0350fc4474d0837e0da85c406a4944d"
} |
(*************************************************************************
* Copyright (C)
* 2019 The University of Exeter
* 2018-2019 The University of Paris-Saclay
* 2018 The University of Sheffield
*
* License:
* This program can be redistributed and/or modified under the terms
* of the 2-clause BSD-style license.
*
* SPDX-License-Identifier: BSD-2-Clause
*************************************************************************)
chapter‹The High-Level Interface to the Automata-Library›
theory RegExpInterface
imports "Functional-Automata.Execute"
keywords
"reflect_ML_exports" :: thy_decl
begin
text‹ The implementation of the monitoring concept follows the following design decisions:
▸ We re-use generated code from the AFP submissions @{theory "Regular-Sets.Regular_Set"} and
@{theory "Functional-Automata.Automata"}, converted by the code-generator into executable SML code
(ports to future Isabelle versions should just reuse future versions of these)
▸ Monitor-Expressions are regular expressions (in some adapted syntax)
over Document Class identifiers; they denote the language of all possible document object
instances belonging to these classes
▸ Instead of expanding the sub-class relation (and building the product automaton of all
monitor expressions), we convert the monitor expressions into automata over class-id's
executed in parallel, in order to avoid blowup.
▸ For efficiency reasons, the class-ids were internally abstracted to integers; the
encoding table is called environment ▩‹env›.
▸ For reusability reasons, we did NOT abstract the internal state representation in the
deterministic automata construction (lists of lists of bits - sic !) by replacing them
by unique keys via a suitable coding-table; rather, we opted for keeping the automatas small
(no products, no subclass-expansion).
›
section‹Monitor Syntax over RegExp - constructs›
notation Star ("⦃(_)⦄⇧*" [0]100)
notation Plus (infixr "||" 55)
notation Times (infixr "~~" 60)
notation Atom ("⌊_⌋" 65)
definition rep1 :: "'a rexp ⇒ 'a rexp" ("⦃(_)⦄⁺")
where "⦃A⦄⁺ ≡ A ~~ ⦃A⦄⇧*"
definition opt :: "'a rexp ⇒ 'a rexp" ("⟦(_)⟧")
where "⟦A⟧ ≡ A || One"
value "Star (Conc(Alt (Atom(CHR ''a'')) (Atom(CHR ''b''))) (Atom(CHR ''c'')))"
text‹or better equivalently:›
value "⦃(⌊CHR ''a''⌋ || ⌊CHR ''b''⌋) ~~ ⌊CHR ''c''⌋⦄⇧*"
section‹Some Standard and Derived Semantics›
text‹ This is just a reminder - already defined in @{theory "Regular-Sets.Regular_Exp"}
as @{term lang}.›
text‹In the following, we give a semantics for our regular expressions, which so far have
just been a term language (i.e. abstract syntax). The semantics is a ``denotational semantics'',
i.e. we give a direct meaning for regular expressions in some universe of ``denotations''.
This universe of denotations is in our concrete case:›
text‹Now the denotational semantics for regular expression can be defined on a post-card:›
fun Lang :: "'a rexp => 'a lang"
where L_Emp : "Lang Zero = {}"
|L_One: "Lang One = {[]}"
|L_Atom: "Lang (⌊a⌋) = {[a]}"
|L_Un: "Lang (el || er) = (Lang el) ∪ (Lang er)"
|L_Conc: "Lang (el ~~ er) = {xs@ys | xs ys. xs ∈ Lang el ∧ ys ∈ Lang er}"
|L_Star: "Lang (Star e) = Regular_Set.star(Lang e)"
text‹A more useful definition is the sub-language - definition›
fun L⇩s⇩u⇩b :: "'a::order rexp => 'a lang"
where L⇩s⇩u⇩b_Emp: "L⇩s⇩u⇩b Zero = {}"
|L⇩s⇩u⇩b_One: "L⇩s⇩u⇩b One = {[]}"
|L⇩s⇩u⇩b_Atom: "L⇩s⇩u⇩b (⌊a⌋) = {z . ∀x. x ≤ a ∧ z=[x]}"
|L⇩s⇩u⇩b_Un: "L⇩s⇩u⇩b (el || er) = (L⇩s⇩u⇩b el) ∪ (L⇩s⇩u⇩b er)"
|L⇩s⇩u⇩b_Conc: "L⇩s⇩u⇩b (el ~~ er) = {xs@ys | xs ys. xs ∈ L⇩s⇩u⇩b el ∧ ys ∈ L⇩s⇩u⇩b er}"
|L⇩s⇩u⇩b_Star: "L⇩s⇩u⇩b (Star e) = Regular_Set.star(L⇩s⇩u⇩b e)"
definition XX where "XX = (rexp2na example_expression)"
definition YY where "YY = na2da(rexp2na example_expression)"
(* reminder from execute *)
value "NA.accepts (rexp2na example_expression) [0,1,1,0,0,1]"
value "DA.accepts (na2da (rexp2na example_expression)) [0,1,1,0,0,1]"
section‹HOL - Adaptions and Export to SML›
definition enabled :: "('a,'σ set)da ⇒ 'σ set ⇒ 'a list ⇒ 'a list"
where "enabled A σ = filter (λx. next A x σ ≠ {}) "
definition zero where "zero = (0::nat)"
definition one where "one = (1::nat)"
export_code zero one Suc Int.nat nat_of_integer int_of_integer (* for debugging *)
example_expression (* for debugging *)
Zero One Atom Plus Times Star (* regexp abstract syntax *)
rexp2na na2da enabled (* low-level automata interface *)
NA.accepts DA.accepts
in SML module_name RegExpChecker
subsection‹Infrastructure for Reflecting exported SML code›
ML‹
fun reflect_local_ML_exports args trans = let
fun eval_ML_context ctxt = let
fun is_sml_file f = String.isSuffix ".ML" (Path.implode (#path f))
val files = (map (Generated_Files.check_files_in (Context.proof_of ctxt)) args)
val ml_files = filter is_sml_file (map #1 (maps Generated_Files.get_files_in files))
val ml_content = map (fn f => Syntax.read_input (Bytes.content (#content f))) ml_files
fun eval ml_content = fold (fn sml => (ML_Context.exec
(fn () => ML_Context.eval_source ML_Compiler.flags sml)))
ml_content
in
(eval ml_content #> Local_Theory.propagate_ml_env) ctxt
end
in
Toplevel.generic_theory eval_ML_context trans
end
val files_in_theory =
(Parse.underscore >> K [] || Scan.repeat1 Parse.path_binding) --
Scan.option (\<^keyword>‹(› |-- Parse.!!! (\<^keyword>‹in›
|-- Parse.theory_name --| \<^keyword>‹)›));
val _ =
Outer_Syntax.command \<^command_keyword>‹reflect_ML_exports›
"evaluate generated Standard ML files"
(Parse.and_list1 files_in_theory >> (fn args => reflect_local_ML_exports args));
›
reflect_ML_exports _
section‹The Abstract Interface For Monitor Expressions›
text‹Here comes the hic : The reflection of the HOL-Automata module into an SML module
with an abstract interface hiding some generation artefacts like the internal states
of the deterministic automata ...›
ML‹
structure RegExpInterface : sig
type automaton
type env
type cid
val alphabet : term list -> env
val ext_alphabet: env -> term list -> env
val conv : theory -> term -> env -> int RegExpChecker.rexp (* for debugging *)
val rexp_term2da: theory -> env -> term -> automaton
val enabled : automaton -> env -> cid list
val next : automaton -> env -> cid -> automaton
val final : automaton -> bool
val accepts : automaton -> env -> cid list -> bool
end
=
struct
local open RegExpChecker in
type state = bool list RegExpChecker.set
type env = string list
type cid = string
type automaton = state * ((Int.int -> state -> state) * (state -> bool))
val add_atom = fold_aterms (fn Const (c as (_, \<^Type>‹rexp _›)) => insert (op=) c | _=> I);
fun alphabet termS = rev(map fst (fold add_atom termS []));
fun ext_alphabet env termS =
let val res = rev(map fst (fold add_atom termS [])) @ env;
val _ = if has_duplicates (op=) res
then error("reject and accept alphabets must be disjoint!")
else ()
in res end;
fun conv _ \<^Const_>‹Regular_Exp.rexp.Zero _› _ = Zero
|conv _ \<^Const_>‹Regular_Exp.rexp.One _› _ = Onea
|conv thy \<^Const_>‹Regular_Exp.rexp.Times _ for X Y› env = Times(conv thy X env, conv thy Y env)
|conv thy \<^Const_>‹Regular_Exp.rexp.Plus _ for X Y› env = Plus(conv thy X env, conv thy Y env)
|conv thy \<^Const_>‹Regular_Exp.rexp.Star _ for X› env = Star(conv thy X env)
|conv thy \<^Const_>‹RegExpInterface.opt _ for X› env = Plus(conv thy X env, Onea)
|conv thy \<^Const_>‹RegExpInterface.rep1 _ for X› env = Times(conv thy X env, Star(conv thy X env))
|conv _ (Const (s, \<^Type>‹rexp _›)) env =
let val n = find_index (fn x => x = s) env
val _ = if n<0 then error"conversion error of regexp." else ()
in Atom(n) end
|conv thy S _ = error("conversion error of regexp:" ^ (Syntax.string_of_term_global thy S))
val eq_int = {equal = curry(op =) : Int.int -> Int.int -> bool};
val eq_bool_list = {equal = curry(op =) : bool list -> bool list -> bool};
fun rexp_term2da thy env term = let val rexp = conv thy term env;
val nda = RegExpChecker.rexp2na eq_int rexp;
val da = RegExpChecker.na2da eq_bool_list nda;
in da end;
(* here comes the main interface of the module:
- "enabled" gives the part of the alphabet "env" for which the automatan does not
go into a final state
- next provides an automata transformation that produces an automaton that
recognizes the rest of a word after a *)
fun enabled (da as (state,(_,_))) env =
let val inds = RegExpChecker.enabled da state (0 upto (length env - 1))
in map (fn i => nth env i) inds end
fun next (current_state, (step,fin)) env a =
let val index = find_index (fn x => x = a) env
in if index < 0 then error"undefined id for monitor"
else (step index current_state,(step,fin))
end
fun final (current_state, (_,fin)) = fin current_state
fun accepts da env word = let fun index a = find_index (fn x => x = a) env
val indexL = map index word
val _ = if forall (fn x => x >= 0) indexL then ()
else error"undefined id for monitor"
in RegExpChecker.accepts da indexL end
end; (* local *)
end (* struct *)
›
lemma regexp_sub : "a ≤ b ⟹ L⇩s⇩u⇩b (⌊a⌋) ⊆ L⇩s⇩u⇩b (⌊b⌋)"
using dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) by auto
lemma regexp_seq_mono:
"Lang(a) ⊆ Lang (a') ⟹ Lang(b) ⊆ Lang (b') ⟹ Lang(a ~~ b) ⊆ Lang(a' ~~ b')" by auto
lemma regexp_seq_mono':
"L⇩s⇩u⇩b(a) ⊆ L⇩s⇩u⇩b (a') ⟹ L⇩s⇩u⇩b(b) ⊆ L⇩s⇩u⇩b (b') ⟹ L⇩s⇩u⇩b(a ~~ b) ⊆ L⇩s⇩u⇩b(a' ~~ b')" by auto
lemma regexp_alt_mono :"Lang(a) ⊆ Lang (a') ⟹ Lang(a || b) ⊆ Lang(a' || b)" by auto
lemma regexp_alt_mono' :"L⇩s⇩u⇩b(a) ⊆ L⇩s⇩u⇩b (a') ⟹ L⇩s⇩u⇩b(a || b) ⊆ L⇩s⇩u⇩b(a' || b)" by auto
lemma regexp_alt_commute : "Lang(a || b) = Lang(b || a)" by auto
lemma regexp_alt_commute' : "L⇩s⇩u⇩b(a || b) = L⇩s⇩u⇩b(b || a)" by auto
lemma regexp_unit_right : "Lang (a) = Lang (a ~~ One) " by simp
lemma regexp_unit_right' : "L⇩s⇩u⇩b (a) = L⇩s⇩u⇩b (a ~~ One) " by simp
lemma regexp_unit_left : "Lang (a) = Lang (One ~~ a) " by simp
lemma regexp_unit_left' : "L⇩s⇩u⇩b (a) = L⇩s⇩u⇩b (One ~~ a) " by simp
lemma opt_star_incl :"Lang (opt a) ⊆ Lang (Star a)" by (simp add: opt_def (*‹⟦?A⟧ ≡ ?A || One›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*))
lemma opt_star_incl':"L⇩s⇩u⇩b (opt a) ⊆ L⇩s⇩u⇩b (Star a)" by (simp add: opt_def (*‹⟦?A⟧ ≡ ?A || One›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*))
lemma rep1_star_incl:"Lang (rep1 a) ⊆ Lang (Star a)"
unfolding rep1_def
(*goal: ‹Lang ((a::'a rexp) ~~ ⦃a⦄⇧*) ⊆ Lang (⦃a⦄⇧*)›*)
apply (subst L_Star (*‹Lang (⦃?e⦄⇧*) = Regular_Set.star ( Lang ?e ) › * ))
(*goal: ‹Lang (a ~~ ⦃a⦄⇧*) ⊆ Lang (⦃a⦄⇧*)›*)
apply (subst L_Conc (*‹Lang (?el ~~ ?er) = {xs @ ys |xs ys. xs ∈ Lang ?el ∧ ys ∈ Lang ?er}›*))
(*goal: ‹Lang ((a::'a rexp) ~~ ⦃a⦄⇧*) ⊆ Regular_Set.star (Lang a)›*)
by force
lemma rep1_star_incl':"L⇩s⇩u⇩b (rep1 a) ⊆ L⇩s⇩u⇩b (Star a)"
unfolding rep1_def
(*goal: ‹L⇩s⇩u⇩b (a ~~ ⦃a⦄⇧*) ⊆ L⇩s⇩u⇩b (⦃a⦄⇧*)›*)
apply (subst L⇩s⇩u⇩b_Star (*‹L⇩s⇩u⇩b (⦃?e⦄⇧*) = Regular_Set.star ( L⇩s⇩u⇩b ?e ) › * ))
(*goal: ‹L⇩s⇩u⇩b (a ~~ ⦃a⦄⇧*) ⊆ L⇩s⇩u⇩b (⦃a⦄⇧*)›*)
apply (subst L⇩s⇩u⇩b_Conc (*‹L⇩s⇩u⇩b (?el ~~ ?er) = {xs @ ys |xs ys. xs ∈ L⇩s⇩u⇩b ?el ∧ ys ∈ L⇩s⇩u⇩b ?er}›*))
(*goal: ‹L⇩s⇩u⇩b ((a::'a::order rexp) ~~ ⦃a⦄⇧*) ⊆ Regular_Set.star (L⇩s⇩u⇩b a)›*)
by force
lemma cancel_rep1 : "Lang (a) ⊆ Lang (rep1 a)"
unfolding rep1_def
(*goal: ‹Lang a ⊆ Lang (a ~~ ⦃a⦄⇧*)›*)
by auto
lemma cancel_rep1' : "L⇩s⇩u⇩b (a) ⊆ L⇩s⇩u⇩b (rep1 a)"
unfolding rep1_def
(*goal: ‹L⇩s⇩u⇩b a ⊆ L⇩s⇩u⇩b (a ~~ ⦃a⦄⇧*)›*)
by auto
lemma seq_cancel_opt : "Lang (a) ⊆ Lang (c) ⟹ Lang (a) ⊆ Lang (opt b ~~ c)"
apply (subst regexp_unit_left (*‹Lang ?a = Lang (One ~~ ?a)›*))
(*goal: ‹Lang a ⊆ Lang c ⟹ Lang a ⊆ Lang (⟦b⟧ ~~ c)›*)
apply (rule regexp_seq_mono (*‹⟦Lang ?a ⊆ Lang ?a'; Lang ?b ⊆ Lang ?b'⟧ ⟹ Lang (?a ~~ ?b) ⊆ Lang (?a' ~~ ?b')›*))
(*goals:
1. ‹Lang a ⊆ Lang c ⟹ Lang One ⊆ Lang ⟦b⟧›
2. ‹Lang a ⊆ Lang c ⟹ Lang a ⊆ Lang c›
discuss goal 1*)
apply (simp add: opt_def (*‹⟦?A⟧ ≡ ?A || One›*))
(*discuss goal 2*)
apply (simp add: opt_def (*‹⟦?A⟧ ≡ ?A || One›*))
(*proven 2 subgoals*) .
lemma seq_cancel_opt' : "L⇩s⇩u⇩b (a) ⊆ L⇩s⇩u⇩b (c) ⟹ L⇩s⇩u⇩b (a) ⊆ L⇩s⇩u⇩b (opt b ~~ c)"
apply (subst regexp_unit_left' (*‹L⇩s⇩u⇩b ?a = L⇩s⇩u⇩b (One ~~ ?a)›*))
(*goal: ‹L⇩s⇩u⇩b a ⊆ L⇩s⇩u⇩b c ⟹ L⇩s⇩u⇩b a ⊆ L⇩s⇩u⇩b (⟦b⟧ ~~ c)›*)
apply (rule regexp_seq_mono' (*‹⟦L⇩s⇩u⇩b ?a ⊆ L⇩s⇩u⇩b ?a'; L⇩s⇩u⇩b ?b ⊆ L⇩s⇩u⇩b ?b'⟧ ⟹ L⇩s⇩u⇩b (?a ~~ ?b) ⊆ L⇩s⇩u⇩b (?a' ~~ ?b')›*))
(*goals:
1. ‹L⇩s⇩u⇩b a ⊆ L⇩s⇩u⇩b c ⟹ L⇩s⇩u⇩b One ⊆ L⇩s⇩u⇩b ⟦b⟧›
2. ‹L⇩s⇩u⇩b a ⊆ L⇩s⇩u⇩b c ⟹ L⇩s⇩u⇩b a ⊆ L⇩s⇩u⇩b c›
discuss goal 1*)
apply (simp add: opt_def (*‹⟦?A::?'a::type rexp⟧ ≡ ?A || One›*))
(*discuss goal 2*)
apply (simp add: opt_def (*‹⟦?A⟧ ≡ ?A || One›*))
(*proven 2 subgoals*) .
lemma seq_cancel_Star : "Lang (a) ⊆ Lang (c) ⟹ Lang (a) ⊆ Lang (Star b ~~ c)"
by auto
lemma seq_cancel_Star' : "L⇩s⇩u⇩b (a) ⊆ L⇩s⇩u⇩b (c) ⟹ L⇩s⇩u⇩b (a) ⊆ L⇩s⇩u⇩b (Star b ~~ c)"
by auto
lemma mono_Star : "Lang (a) ⊆ Lang (b) ⟹ Lang (Star a) ⊆ Lang (Star b)"
apply auto
(*goal: ‹Lang a ⊆ Lang b ⟹ Lang (⦃a⦄⇧*) ⊆ Lang (⦃b⦄⇧*)›*)
by (metis in_star_iff_concat (*‹(?w ∈ Regular_Set.star ?A) = (∃ws. set ws ⊆ ?A ∧ ?w = concat ws)›*) order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*))
lemma mono_Star' : "L⇩s⇩u⇩b (a) ⊆ L⇩s⇩u⇩b (b) ⟹ L⇩s⇩u⇩b (Star a) ⊆ L⇩s⇩u⇩b (Star b)"
apply auto
(*goal: ‹L⇩s⇩u⇩b a ⊆ L⇩s⇩u⇩b b ⟹ L⇩s⇩u⇩b (⦃a⦄⇧*) ⊆ L⇩s⇩u⇩b (⦃b⦄⇧*)›*)
by (metis in_star_iff_concat (*‹(?w ∈ Regular_Set.star ?A) = (∃ws. set ws ⊆ ?A ∧ ?w = concat ws)›*) order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*))
lemma mono_rep1_star:"Lang (a) ⊆ Lang (b) ⟹ Lang (rep1 a) ⊆ Lang (Star b)"
using mono_Star (*‹Lang ?a ⊆ Lang ?b ⟹ Lang (⦃?a⦄⇧*) ⊆ Lang (⦃?b⦄⇧*)›*) rep1_star_incl (*‹Lang ⦃?a::?'a rexp⦄⁺ ⊆ Lang (⦃?a⦄⇧*)›*) by blast
lemma mono_rep1_star':"L⇩s⇩u⇩b (a) ⊆ L⇩s⇩u⇩b (b) ⟹ L⇩s⇩u⇩b (rep1 a) ⊆ L⇩s⇩u⇩b (Star b)"
using mono_Star' (*‹L⇩s⇩u⇩b ?a ⊆ L⇩s⇩u⇩b ?b ⟹ L⇩s⇩u⇩b (⦃?a⦄⇧*) ⊆ L⇩s⇩u⇩b (⦃?b⦄⇧*)›*) rep1_star_incl' (*‹L⇩s⇩u⇩b ⦃?a⦄⁺ ⊆ L⇩s⇩u⇩b (⦃?a⦄⇧*)›*) by blast
no_notation Star ("⦃(_)⦄⇧*" [0]100)
no_notation Plus (infixr "||" 55)
no_notation Times (infixr "~~" 60)
no_notation Atom ("⌊_⌋" 65)
no_notation rep1 ("⦃(_)⦄⁺")
no_notation opt ("⟦(_)⟧")
ML‹
structure RegExpInterface_Notations =
struct
val Star = (\<^term>‹Regular_Exp.Star›, Mixfix (Syntax.read_input "⦃(_)⦄⇧*", [0], 100, Position.no_range))
val Plus = (\<^term>‹Regular_Exp.Plus›, Infixr (Syntax.read_input "||", 55, Position.no_range))
val Times = (\<^term>‹Regular_Exp.Times›, Infixr (Syntax.read_input "~~", 60, Position.no_range))
val Atom = (\<^term>‹Regular_Exp.Atom›, Mixfix (Syntax.read_input "⌊_⌋", [], 65, Position.no_range))
val opt = (\<^term>‹RegExpInterface.opt›, Mixfix (Syntax.read_input "⟦(_)⟧", [], 1000, Position.no_range))
val rep1 = (\<^term>‹RegExpInterface.rep1›, Mixfix (Syntax.read_input "⦃(_)⦄⁺", [], 1000, Position.no_range))
val notations = [Star, Plus, Times, Atom, rep1, opt]
end
›
end
| {
"path": "afp-2025-02-12/thys/Isabelle_DOF/thys/RegExpInterface.thy",
"repo": "afp-2025-02-12",
"sha": "d670ae8f014aa415c781a41671b67cec074ac2ddb773c11a0b0f60276531cc2d"
} |
(* Title: Pre-Post Specifications and Modal Operators
Author: Walter Guttmann
Maintainer: Walter Guttmann <walter.guttmann at canterbury.ac.nz>
*)
section ‹Pre-Post Specifications and Modal Operators›
theory Pre_Post_Modal
imports Pre_Post Hoare_Modal
begin
class pre_post_spec_whiledo = pre_post_spec_greatest + whiledo
begin
lemma nat_test_pre_post:
"nat_test t s ⟹ -q ≤ s ⟹ (∀n . x ≤ t n*-p*-q⊣(pSum t n*-q)) ⟹ -p⋆x ≤ -q⊣--p*-q"
by (smt (verit, ccfv_threshold) nat_test_def (*‹nat_test ?t ?s ≡ (∀n. ?t n = - - ?t n) ∧ ?s = - - ?s ∧ (∀n. ?t n ≤ ?s) ∧ (∀x y. (∀n. ?t n * - x ≤ - y) ⟶ ?s * - x ≤ - y)›*) nat_test_pre (*‹⟦nat_test ?t ?s; - ?q ≤ ?s; ∀n. ?t n * - ?p * - ?q ≤ ?x « pSum ?t n * - ?q⟧ ⟹ - ?q ≤ - ?p ⋆ ?x « - - ?p * - ?q›*) pSum_test_nat (*‹nat_test ?t ?s ⟹ pSum ?t ?m = - - pSum ?t ?m›*) pre_post_galois (*‹(- ?p ≤ ?x « - ?q) = (?x ≤ - ?p ⊣ - ?q)›*) tests_dual.sub_sup_closed (*‹- ?x * - ?y = - - (- ?x * - ?y)›*))
lemma nat_test_pre_post_2:
"nat_test t s ⟹ -r ≤ s ⟹ (∀n . x ≤ t n*-p⊣(pSum t n)) ⟹ -p⋆x ≤ -r⊣1"
by (smt (verit, ccfv_threshold) nat_test_def (*‹nat_test ?t ?s ≡ (∀n. ?t n = - - ?t n) ∧ ?s = - - ?s ∧ (∀n. ?t n ≤ ?s) ∧ (∀x y. (∀n. ?t n * - x ≤ - y) ⟶ ?s * - x ≤ - y)›*) nat_test_pre_2 (*‹⟦nat_test ?t ?s; - ?r ≤ ?s; ∀n. ?t n * - ?p ≤ ?x « pSum ?t n⟧ ⟹ - ?r ≤ - ?p ⋆ ?x « 1›*) one_def (*‹1 = - bot›*) pSum_test_nat (*‹nat_test ?t ?s ⟹ pSum ?t ?m = - - pSum ?t ?m›*) pre_post_galois (*‹(- ?p ≤ ?x « - ?q) = (?x ≤ - ?p ⊣ - ?q)›*) tests_dual.sub_sup_closed (*‹- ?x * - ?y = - - (- ?x * - ?y)›*))
end
class pre_post_spec_hoare = pre_post_spec_whiledo + hoare_calculus_sound
begin
lemma pre_post_while:
"x ≤ -p*-q⊣-q ⟶ -p⋆x ≤ aL*-q⊣-q"
by (smt aL_test (*‹aL = - - aL›*) pre_post_galois (*‹(- ?p ≤ ?x « - ?q) = (?x ≤ - ?p ⊣ - ?q)›*) sub_mult_closed (*‹- ?x * - ?y = - - (- ?x * - ?y)›*) while_soundness (*‹- ?p * - ?q ≤ ?x « - ?q ⟶ aL * - ?q ≤ - ?p ⋆ ?x « - ?q›*))
text ‹Theorem 43.1›
lemma while_soundness_3:
"test_seq t ⟹ -q ≤ Sum t ⟹ x ≤ t 0*-p*-q⊣aL*-q ⟹ (∀n>0 . x ≤ t n*-p*-q⊣pSum t n*-q) ⟹ -p⋆x ≤ -q⊣--p*-q"
by (smt (verit, del_insts) aL_test (*‹aL = - - aL›*) pSum_test (*‹test_seq ?t ⟹ pSum ?t ?m = - - pSum ?t ?m›*) tests_dual.inf_closed (*‹- ?x ⊔ - ?y = - - (- ?x ⊔ - ?y)›*) pre_post_galois (*‹(- ?p ≤ ?x « - ?q) = (?x ≤ - ?p ⊣ - ?q)›*) sub_mult_closed (*‹- ?x * - ?y = - - (- ?x * - ?y)›*) test_seq_def (*‹test_seq ?t ≡ ∀n. ?t n = - - ?t n›*) while_soundness_1 (*‹⟦test_seq ?t; - ?q ≤ complete_tests_class.Sum ?t; ?t 0 * - ?p * - ?q ≤ ?x « aL * - ?q; ∀n>0. ?t n * - ?p * - ?q ≤ ?x « pSum ?t n * - ?q⟧ ⟹ - ?q ≤ - ?p ⋆ ?x « - - ?p * - ?q›*))
text ‹Theorem 43.2›
lemma while_soundness_4:
"test_seq t ⟹ -r ≤ Sum t ⟹ (∀n . x ≤ t n*-p⊣pSum t n) ⟹ -p⋆x ≤ -r⊣1"
by (smt one_def (*‹1 = - bot›*) pSum_test (*‹test_seq ?t ⟹ pSum ?t ?m = - - pSum ?t ?m›*) pre_post_galois (*‹(- ?p ≤ ?x « - ?q) = (?x ≤ - ?p ⊣ - ?q)›*) sub_mult_closed (*‹- ?x * - ?y = - - (- ?x * - ?y)›*) test_seq_def (*‹test_seq ?t ≡ ∀n. ?t n = - - ?t n›*) while_soundness_2 (*‹⟦test_seq ?t; - ?r ≤ complete_tests_class.Sum ?t; ∀n. ?t n * - ?p ≤ ?x « pSum ?t n⟧ ⟹ - ?r ≤ - ?p ⋆ ?x « 1›*))
end
class pre_post_spec_hoare_pc_2 = pre_post_spec_hoare + hoare_calculus_pc_2
begin
text ‹Theorem 43.3›
lemma pre_post_while_pc:
"x ≤ -p*-q⊣-q ⟶ -p⋆x ≤ -q⊣--p*-q"
by (metis pre_post_galois (*‹(- ?p ≤ ?x « - ?q) = (?x ≤ - ?p ⊣ - ?q)›*) sub_mult_closed (*‹- ?x * - ?y = - - (- ?x * - ?y)›*) while_soundness_pc (*‹- ?p * - ?q ≤ ?x « - ?q ⟹ - ?q ≤ - ?p ⋆ ?x « - - ?p * - ?q›*))
end
class pre_post_spec_hoare_pc = pre_post_spec_hoare + hoare_calculus_pc
begin
subclass pre_post_spec_hoare_pc_2 ..
lemma pre_post_one_one_top:
"1⊣1 = top"
using order.eq_iff (*‹(?a = ?b) = (?a ≤ ?b ∧ ?b ≤ ?a)›*) pre_one_one (*‹?x « 1 = 1›*) pre_post_one_one (*‹(?x « 1 = 1) = (?x ≤ 1 ⊣ 1)›*) by auto
end
class pre_post_spec_H = pre_post_spec_greatest + box_precondition + havoc +
assumes H_zero_2: "H * bot = bot"
assumes H_split_2: "x ≤ x * -q * top ⊔ H * --q"
begin
subclass idempotent_left_semiring_H
apply unfold_locales
apply (rule H_zero_2)
by (smt H_split_2 tests_dual.complement_bot mult_assoc mult_left_zero mult_1_right one_def)
lemma pre_post_def_iff:
"-p * x * --q ≤ Z ⟷ x ≤ Z ⊔ --p * top ⊔ H * -q"
proof (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))
(*goals:
1. ‹a p * x * a (a q) ≤ Z ⟹ x ≤ Z ⊔ a (a p) * top ⊔ H * a q›
2. ‹x ≤ Z ⊔ a (a p) * top ⊔ H * a q ⟹ a p * x * a (a q) ≤ Z›*)
assume "-p * x * --q ≤ Z" (*‹a (p::'a) * (x::'a) * a (a (q::'a)) ≤ Z›*)
hence "x * --q * top ≤ Z ⊔ --p * top"
by (smt (verit, ccfv_threshold) Z_left_zero_above_one (*‹reflexive ?x ⟹ Z * ?x = Z›*) case_split_left_sup (*‹a ?p * ?x ≤ ?y ∧ a (a ?p) * ?x ≤ ?z ⟹ ?x ≤ ?y ⊔ ?z›*) mult_assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*) mult_left_isotone (*‹?x ≤ ?y ⟹ ?x * ?z ≤ ?y * ?z›*) mult_right_dist_sup (*‹(?x ⊔ ?y) * ?z = ?x * ?z ⊔ ?y * ?z›*) mult_right_isotone (*‹?x ≤ ?y ⟹ ?z * ?x ≤ ?z * ?y›*) top_greatest (*‹?x ≤ top›*) top_mult_top (*‹surjective top›*))
thus "x ≤ Z ⊔ --p * top ⊔ H * -q"
by (metis sup_left_isotone (*‹?x ≤ ?y ⟹ ?x ⊔ ?z ≤ ?y ⊔ ?z›*) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) H_split_2 (*‹?x ≤ ?x * a ?q * top ⊔ H * a (a ?q)›*) tests_dual.double_negation (*‹a (a (a ?x)) = a ?x›*))
next
(*goal: ‹x ≤ Z ⊔ a (a p) * top ⊔ H * a q ⟹ a p * x * a (a q) ≤ Z›*)
assume "x ≤ Z ⊔ --p * top ⊔ H * -q" (*‹(x::'a) ≤ Z ⊔ a (a (p::'a)) * top ⊔ H * a (q::'a)›*)
hence "-p * x * --q ≤ -p * (Z * --q ⊔ --p * top * --q ⊔ H * -q * --q)"
by (metis mult_left_isotone (*‹?x ≤ ?y ⟹ ?x * ?z ≤ ?y * ?z›*) mult_right_dist_sup (*‹(?x ⊔ ?y) * ?z = ?x * ?z ⊔ ?y * ?z›*) mult_right_isotone (*‹?x ≤ ?y ⟹ ?z * ?x ≤ ?z * ?y›*) mult_assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*))
thus "-p * x * --q ≤ Z"
by (metis H_zero_2 (*‹H * bot = bot›*) Z_mult_decreasing (*‹Z * (?x::'a) ≤ Z›*) sup_commute (*‹(?x::'a) ⊔ (?y::'a) = ?y ⊔ ?x›*) sup_bot_left (*‹bot ⊔ (?x::'a) = ?x›*) mult_assoc (*‹(?a::'a) * (?b::'a) * (?c::'a) = ?a * (?b * ?c)›*) mult_right_dist_sup (*‹((?x::'a) ⊔ (?y::'a)) * (?z::'a) = ?x * ?z ⊔ ?y * ?z›*) mult_right_isotone (*‹(?x::'a) ≤ (?y::'a) ⟹ (?z::'a) * ?x ≤ ?z * ?y›*) order_trans (*‹⟦(?x::'a) ≤ (?y::'a); ?y ≤ (?z::'a)⟧ ⟹ ?x ≤ ?z›*) test_mult_left_dist_shunt (*‹a (?p::'a) * (a (a ?p) * (?x::'a) ⊔ Z) = a ?p * Z›*) test_mult_left_sub_dist_shunt (*‹a (?p::'a) * (a (a ?p) * (?x::'a) ⊔ Z) ≤ Z›*) tests_dual.top_def (*‹bot = a (?x::'a) * a (a ?x)›*))
qed
lemma pre_post_def:
"-p⊣-q = Z ⊔ --p*top ⊔ H*-q"
by (meson order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*) order_refl (*‹?x ≤ ?x›*) pre_Z (*‹(a ?p ≤ ?x « a ?q) = (a ?p * ?x * a (a ?q) ≤ Z)›*) pre_post_galois (*‹(a ?p ≤ ?x « a ?q) = (?x ≤ a ?p ⊣ a ?q)›*) pre_post_def_iff (*‹(a ?p * ?x * a (a ?q) ≤ Z) = (?x ≤ Z ⊔ a (a ?p) * top ⊔ H * a ?q)›*))
end
class pre_post_L = pre_post_spec_greatest + box_while + left_conway_semiring_L + left_kleene_conway_semiring +
assumes circ_below_L_add_star: "x⇧∘ ≤ L ⊔ x⇧⋆"
begin
text ‹a loop does not abort if its body does not abort›
text ‹this avoids abortion from all states* alternatively from states in -r if -r is an invariant›
lemma body_abort_loop:
assumes "Z = L"
and "x ≤ -p⊣1"
shows "-p⋆x ≤ 1⊣1"
proof (-)
(*goal: ‹a p ⋆ x ≤ 1 ⊣ 1›*)
have "-p * x * bot ≤ L"
by (metis assms (*‹Z = L› ‹x ≤ a p ⊣ 1›*) pre_Z (*‹(a ?p ≤ ?x « a ?q) = (a ?p * ?x * a (a ?q) ≤ Z)›*) pre_post_galois (*‹(a ?p ≤ ?x « a ?q) = (?x ≤ a ?p ⊣ a ?q)›*) tests_dual.sba_dual.one_def (*‹1 = a bot›*) tests_dual.top_double_complement (*‹a (a bot) = bot›*))
hence "(-p * x)⇧⋆ * bot ≤ L"
by (metis L_split (*‹?x * L ≤ ?x * bot ⊔ L›*) le_iff_sup (*‹(?x ≤ ?y) = (?x ⊔ ?y = ?y)›*) star_left_induct (*‹?z ⊔ ?y * ?x ≤ ?x ⟶ ?y⇧⋆ * ?z ≤ ?x›*) sup_bot_left (*‹bot ⊔ ?x = ?x›*))
hence "(-p * x)⇧∘ * bot ≤ L"
by (smt L_left_zero (*‹L * (?x::'a::type) = L›*) L_split (*‹(?x::'a::type) * L ≤ ?x * bot ⊔ L›*) sup_commute (*‹(?x::'a::type) ⊔ (?y::'a::type) = ?y ⊔ ?x›*) circ_below_L_add_star (*‹(?x::'a::type)⇧∘ ≤ L ⊔ ?x⇧⋆›*) le_iff_sup (*‹((?x::'a::type) ≤ (?y::'a::type)) = (?x ⊔ ?y = ?y)›*) mult_right_dist_sup (*‹((?x::'a::type) ⊔ (?y::'a::type)) * (?z::'a::type) = ?x * ?z ⊔ ?y * ?z›*))
thus "?thesis"
(*goal: ‹a (p::'a) ⋆ (x::'a) ≤ (1::'a) ⊣ (1::'a)›*)
by (metis assms( (*‹Z = L›*) 1) a_restrict (*‹a (?x::'a) * ?x ≤ Z›*) mult_isotone (*‹⟦(?w::'a) ≤ (?y::'a); (?x::'a) ≤ (?z::'a)⟧ ⟹ ?w * ?x ≤ ?y * ?z›*) pre_pc_Z (*‹((?x::'a) « (1::'a) = (1::'a)) = (?x * bot ≤ Z)›*) pre_post_compose_2 (*‹(a (?p::'a) ⊣ a ?p) * (a ?p ⊣ a (?q::'a)) = a ?p ⊣ a ?q›*) pre_post_one_one (*‹((?x::'a) « (1::'a) = (1::'a)) = (?x ≤ (1::'a) ⊣ (1::'a))›*) tests_dual.sba_dual.one_def (*‹(1::'a) = a bot›*) while_def (*‹(?p::'a) ⋆ (?x::'a) = (?p * ?x)⇧∘ * a ?p›*) tests_dual.sup_right_zero (*‹a (?x::'a) * bot = bot›*))
qed
end
class pre_post_spec_Hd = pre_post_spec_least + diamond_precondition + idempotent_left_semiring_Hd +
assumes d_mult_top: "d(x) * top = x * top"
begin
subclass pre_post_spec_least_Hd
apply unfold_locales
by (simp add: d_mult_top diamond_x_1 pre_def)
end
end
| {
"path": "afp-2025-02-12/thys/Correctness_Algebras/Pre_Post_Modal.thy",
"repo": "afp-2025-02-12",
"sha": "a5046cf6a17f2921756d12a9f23dbf1a120642b1451dc12eb955b907315b45e4"
} |
theory SASP_Checker
imports SASP_Semantics
"HOL-Library.Code_Target_Nat"
begin
section ‹An Executable Checker for Multi-Valued Planning Problem Solutions›
subsection ‹Auxiliary Lemmas›
lemma map_of_leI:
assumes "distinct (map fst l)"
assumes "⋀k v. (k,v)∈set l ⟹ m k = Some v"
shows "map_of l ⊆⇩m m"
using assms (*‹distinct (map fst l)› ‹(?k, ?v) ∈ set l ⟹ m ?k = Some ?v›*) by (metis (no_types, opaque_lifting) domIff (*‹(?a ∈ dom ?m) = (?m ?a ≠ None)›*) map_le_def (*‹(?m₁ ⊆⇩m ?m₂) = (∀a∈dom ?m₁. ?m₁ a = ?m₂ a)›*) map_of_SomeD (*‹map_of ?xs ?k = Some ?y ⟹ (?k, ?y) ∈ set ?xs›*) not_Some_eq (*‹(∀y. ?x ≠ Some y) = (?x = None)›*))
lemma [simp]: "fst ∘ (λ(a, b, c, d). (f a b c d, g a b c d)) = (λ(a,b,c,d). f a b c d)"
by auto
lemma map_mp: "m⊆⇩mm' ⟹ m k = Some v ⟹ m' k = Some v"
by (auto simp: map_le_def (*‹(?m₁ ⊆⇩m ?m₂) = (∀a∈dom ?m₁. ?m₁ a = ?m₂ a)›*) dom_def (*‹dom ?m = {a. ?m a ≠ None}›*))
lemma map_add_map_of_fold:
fixes ps and m :: "'a ⇀ 'b"
assumes "distinct (map fst ps)"
shows "m ++ map_of ps = fold (λ(k, v) m. m(k ↦ v)) ps m"
proof (-)
(*goal: ‹m ++ map_of ps = fold (λ(k, v) m. m(k ↦ v)) ps m›*)
have X1: "(fold (λ(k, v) m. m(k ↦ v)) ps m)(a ↦ b)
= fold (λ(k, v) m. m(k ↦ v)) ps (m(a ↦ b))" if "a ∉ fst ` set ps" for a and b and ps and m :: "'a ⇀ 'b"
using that (*‹a ∉ fst ` set ps›*) apply (induction ps arbitrary: m)
(*goals:
1. ‹⋀m. a ∉ fst ` set [] ⟹ (fold (λ(k, v) m. m(k ↦ v)) [] m)(a ↦ b) = fold (λ(k, v) m. m(k ↦ v)) [] (m(a ↦ b))›
2. ‹⋀aa ps m. ⟦⋀m. a ∉ fst ` set ps ⟹ (fold (λ(k, v) m. m(k ↦ v)) ps m)(a ↦ b) = fold (λ(k, v) m. m(k ↦ v)) ps (m(a ↦ b)); a ∉ fst ` set (aa # ps)⟧ ⟹ (fold (λ(k, v) m. m(k ↦ v)) (aa # ps) m)(a ↦ b) = fold (λ(k, v) m. m(k ↦ v)) (aa # ps) (m(a ↦ b))›
discuss goal 1*)
apply ((auto simp: fun_upd_twist (*‹?a ≠ ?c ⟹ ?m(?a := ?b, ?c := ?d) = ?m(?c := ?d, ?a := ?b)›*))[1])
(*discuss goal 2*)
apply ((auto simp: fun_upd_twist (*‹?a ≠ ?c ⟹ ?m(?a := ?b, ?c := ?d) = ?m(?c := ?d, ?a := ?b)›*))[1])
(*proven 2 subgoals*) .
show "?thesis"
(*goal: ‹m ++ map_of ps = fold (λ(k, v) m. m(k ↦ v)) ps m›*)
using assms (*‹distinct (map fst ps)›*) apply (induction ps arbitrary: m)
(*goals:
1. ‹⋀m. distinct (map fst []) ⟹ m ++ map_of [] = fold (λ(k, v) m. m(k ↦ v)) [] m›
2. ‹⋀a ps m. ⟦⋀m. distinct (map fst ps) ⟹ m ++ map_of ps = fold (λ(k, v) m. m(k ↦ v)) ps m; distinct (map fst (a # ps))⟧ ⟹ m ++ map_of (a # ps) = fold (λ(k, v) m. m(k ↦ v)) (a # ps) m›
discuss goal 1*)
apply ((auto simp: X1 (*‹(?a::'a) ∉ fst ` set (?ps::('a × 'b) list) ⟹ (fold (λ(k::'a, v::'b) m::'a ⇒ 'b option. m(k ↦ v)) ?ps (?m::'a ⇒ 'b option))(?a ↦ ?b::'b) = fold (λ(k::'a, v::'b) m::'a ⇒ 'b option. m(k ↦ v)) ?ps (?m(?a ↦ ?b))›*))[1])
(*discuss goal 2*)
apply ((auto simp: X1 (*‹?a ∉ fst ` set ?ps ⟹ (fold (λ(k, v) m. m(k ↦ v)) ?ps ?m)(?a ↦ ?b) = fold (λ(k, v) m. m(k ↦ v)) ?ps (?m(?a ↦ ?b))›*))[1])
(*proven 2 subgoals*) .
qed
subsection ‹Well-formedness Check›
lemmas wf_code_thms =
ast_problem.astDom_def ast_problem.astI_def ast_problem.astG_def ast_problem.astδ_def
ast_problem.numVars_def ast_problem.numVals_def
ast_problem.wf_partial_state_def ast_problem.wf_operator_def ast_problem.well_formed_def
declare wf_code_thms[code]
export_code ast_problem.well_formed in SML
subsection ‹Execution›
definition match_pre :: "ast_precond ⇒ state ⇒ bool" where
"match_pre ≡ λ(x,v) s. s x = Some v"
definition match_pres :: "ast_precond list ⇒ state ⇒ bool" where
"match_pres pres s ≡ ∀pre∈set pres. match_pre pre s"
definition match_implicit_pres :: "ast_effect list ⇒ state ⇒ bool" where
"match_implicit_pres effs s ≡ ∀(_,x,vp,_)∈set effs.
(case vp of None ⇒ True | Some v ⇒ s x = Some v)"
definition enabled_opr' :: "ast_operator ⇒ state ⇒ bool" where
"enabled_opr' ≡ λ(name,pres,effs,cost) s. match_pres pres s ∧ match_implicit_pres effs s"
definition eff_enabled' :: "state ⇒ ast_effect ⇒ bool" where
"eff_enabled' s ≡ λ(pres,_,_,_). match_pres pres s"
definition "execute_opr' ≡ λ(name,_,effs,_) s.
let effs = filter (eff_enabled' s) effs
in fold (λ(_,x,_,v) s. s(x↦v)) effs s
"
definition lookup_operator' :: "ast_problem ⇒ name ⇀ ast_operator"
where "lookup_operator' ≡ λ(D,I,G,δ) name. find (λ(n,_,_,_). n=name) δ"
definition enabled' :: "ast_problem ⇒ name ⇒ state ⇒ bool" where
"enabled' problem name s ≡
case lookup_operator' problem name of
Some π ⇒ enabled_opr' π s
| None ⇒ False"
definition execute' :: "ast_problem ⇒ name ⇒ state ⇒ state" where
"execute' problem name s ≡
case lookup_operator' problem name of
Some π ⇒ execute_opr' π s
| None ⇒ undefined"
context wf_ast_problem begin
lemma match_pres_correct:
assumes D: "distinct (map fst pres)"
assumes "s∈valid_states"
shows "match_pres pres s ⟷ s∈subsuming_states (map_of pres)"
proof (-)
(*goal: ‹match_pres pres s = (s ∈ subsuming_states (map_of pres))›*)
have "match_pres pres s ⟷ map_of pres ⊆⇩m s"
unfolding match_pres_def match_pre_def
(*goal: ‹(∀pre∈set pres. (case pre of (x, v) ⇒ λs. s x = Some v) s) = (map_of pres ⊆⇩m s)›*)
apply (auto split: prod.splits (*‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∀(x1::?'a) x2::?'b. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∄(x1::?'a) x2::?'b. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))
(*goal: ‹(∀pre∈set pres. (case pre of (x, v) ⇒ λs. s x = Some v) s) = (map_of pres ⊆⇩m s)›*)
using map_le_def (*‹(?m₁ ⊆⇩m ?m₂) = (∀a∈dom ?m₁. ?m₁ a = ?m₂ a)›*) map_of_SomeD (*‹map_of ?xs ?k = Some ?y ⟹ (?k, ?y) ∈ set ?xs›*)
(*goals:
1. ‹∀pre∈set pres. ∀x1 x2. pre = (x1, x2) ⟶ s x1 = Some x2 ⟹ map_of pres ⊆⇩m s›
2. ‹⋀x1 x2. ⟦map_of pres ⊆⇩m s; (x1, x2) ∈ set pres⟧ ⟹ s x1 = Some x2›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply (metis (full_types) D (*‹distinct (map fst (pres::(nat × nat) list))›*) domIff (*‹((?a::?'a) ∈ dom (?m::?'a ⇒ ?'b option)) = (?m ?a ≠ None)›*) map_le_def (*‹((?m₁::?'a ⇒ ?'b option) ⊆⇩m (?m₂::?'a ⇒ ?'b option)) = (∀a::?'a∈dom ?m₁. ?m₁ a = ?m₂ a)›*) map_of_eq_Some_iff (*‹distinct (map fst (?xys::(?'a × ?'b) list)) ⟹ (map_of ?xys (?x::?'a) = Some (?y::?'b)) = ((?x, ?y) ∈ set ?xys)›*) option.simps( (*‹Some (?x2.0::?'a) ≠ None›*) 3))
(*proven 2 subgoals*) .
with assms (*‹distinct (map fst pres)› ‹s ∈ valid_states›*) show "?thesis"
(*goal: ‹match_pres pres s = (s ∈ subsuming_states (map_of pres))›*)
unfolding subsuming_states_def
(*goal: ‹match_pres pres s = (s ∈ {s ∈ valid_states. map_of pres ⊆⇩m s})›*)
by auto
qed
lemma match_implicit_pres_correct:
assumes D: "distinct (map (λ(_, v, _, _). v) effs)"
assumes "s∈valid_states"
shows "match_implicit_pres effs s ⟷ s∈subsuming_states (map_of (implicit_pres effs))"
proof (-)
(*goal: ‹match_implicit_pres effs s = (s ∈ subsuming_states (map_of (implicit_pres effs)))›*)
from assms (*‹distinct (map (λ(uu_::(nat × nat) list, v::nat, uu_::nat option, uu_::nat). v) (effs::((nat × nat) list × nat × nat option × nat) list))› ‹s ∈ valid_states›*) show "?thesis"
(*goal: ‹match_implicit_pres effs s = (s ∈ subsuming_states (map_of (implicit_pres effs)))›*)
unfolding subsuming_states_def
(*goal: ‹match_implicit_pres effs s = (s ∈ {s ∈ valid_states. map_of (implicit_pres effs) ⊆⇩m s})›*)
unfolding match_implicit_pres_def implicit_pres_def
(*goal: ‹(∀(uu_, x, vp, uu_)∈set effs. case vp of None ⇒ True | Some v ⇒ s x = Some v) = (s ∈ {s ∈ valid_states. map_of (map (λ(uu_, v, vpre, uu_). (v, the vpre)) (filter (λ(uu_, uu_, vpre, uu_). vpre ≠ None) effs)) ⊆⇩m s})›*)
apply (auto split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp: distinct_map_filter (*‹distinct (map ?f ?xs) ⟹ distinct (map ?f (filter ?P ?xs))›*) intro!: map_of_leI (*‹⟦distinct (map fst ?l); ⋀k v. (k, v) ∈ set ?l ⟹ ?m k = Some v⟧ ⟹ map_of ?l ⊆⇩m ?m›*))
(*goal: ‹(∀(uu_, x, vp, uu_)∈set effs. case vp of None ⇒ True | Some v ⇒ s x = Some v) = (s ∈ {s ∈ valid_states. map_of (map (λ(uu_, v, vpre, uu_). (v, the vpre)) (filter (λ(uu_, uu_, vpre, uu_). vpre ≠ None) effs)) ⊆⇩m s})›*)
by (force simp: distinct_map_filter (*‹distinct (map (?f::?'b ⇒ ?'a) (?xs::?'b list)) ⟹ distinct (map ?f (filter (?P::?'b ⇒ bool) ?xs))›*) split: prod.split (*‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∀(x1::?'a) x2::?'b. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*) elim: map_mp (*‹⟦(?m::?'a ⇒ ?'b option) ⊆⇩m (?m'::?'a ⇒ ?'b option); ?m (?k::?'a) = Some (?v::?'b)⟧ ⟹ ?m' ?k = Some ?v›*))
qed
lemma enabled_opr'_correct:
assumes V: "s∈valid_states"
assumes "lookup_operator name = Some π"
shows "enabled_opr' π s ⟷ enabled name s"
using lookup_operator_wf[OF assms ( 2 )] (*‹wf_operator π› ‹fst π = name›*) assms (*‹s ∈ valid_states› ‹lookup_operator name = Some π›*) unfolding enabled_opr'_def enabled_def wf_operator_def
(*goal: ‹(case π of (name, pres, effs, cost) ⇒ λs. match_pres pres s ∧ match_implicit_pres effs s) s = (case lookup_operator name of None ⇒ False | Some (x, pres, effs, xa) ⇒ s ∈ subsuming_states (map_of pres) ∧ s ∈ subsuming_states (map_of (implicit_pres effs)))›*)
by (auto simp: match_pres_correct[OF _ V] (*‹distinct (map fst ?pres) ⟹ match_pres ?pres s = (s ∈ subsuming_states (map_of ?pres))›*) match_implicit_pres_correct[OF _ V] (*‹distinct (map (λ(uu_, v, uu_, uu_). v) ?effs) ⟹ match_implicit_pres ?effs s = (s ∈ subsuming_states (map_of (implicit_pres ?effs)))›*) simp: wf_partial_state_def (*‹wf_partial_state ?ps ≡ distinct (map fst ?ps) ∧ (∀(x, v)∈set ?ps. x < numVars ∧ v < numVals x)›*) split: option.split (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))›*))
lemma eff_enabled'_correct:
assumes V: "s∈valid_states"
assumes "case eff of (pres,_,_,_) ⇒ wf_partial_state pres"
shows "eff_enabled' s eff ⟷ eff_enabled s eff"
using assms (*‹(s::nat ⇒ nat option) ∈ valid_states› ‹case eff of (pres, x, xa, xb) ⇒ wf_partial_state pres›*) unfolding eff_enabled'_def eff_enabled_def wf_partial_state_def
(*goal: ‹(case eff of (pres, uu_, uua_, uub_) ⇒ match_pres pres s) = (case eff of (pres, uu_, uua_, uub_) ⇒ s ∈ subsuming_states (map_of pres))›*)
by (auto simp: match_pres_correct (*‹⟦distinct (map fst ?pres); ?s ∈ valid_states⟧ ⟹ match_pres ?pres ?s = (?s ∈ subsuming_states (map_of ?pres))›*))
lemma execute_opr'_correct:
assumes V: "s∈valid_states"
assumes LO: "lookup_operator name = Some π"
shows "execute_opr' π s = execute name s"
proof (cases π)
(*goal: ‹⋀a b c d. π = (a, b, c, d) ⟹ execute_opr' π s = execute name s›*)
case [simp]: (fields name pres effs) (*‹(π::char list × (nat × nat) list × ((nat × nat) list × nat × nat option × nat) list × nat) = (name::char list, pres::(nat × nat) list, effs::((nat × nat) list × nat × nat option × nat) list, d_::nat)›*)
have [simp]: "filter (eff_enabled' s) effs = filter (eff_enabled s) effs"
apply (rule filter_cong[OF refl] (*‹(⋀x. x ∈ set ?xs ⟹ ?P x = ?Q x) ⟹ filter ?P ?xs = filter ?Q ?xs›*))
(*goal: ‹filter (eff_enabled' s) effs = filter (eff_enabled s) effs›*)
apply (rule eff_enabled'_correct[OF V] (*‹case ?eff of (pres, x, xa, xb) ⇒ wf_partial_state pres ⟹ eff_enabled' s ?eff = eff_enabled s ?eff›*))
(*goal: ‹⋀x. x ∈ set effs ⟹ eff_enabled' s x = eff_enabled s x›*)
using lookup_operator_wf[OF LO] (*‹wf_operator (π::char list × (nat × nat) list × ((nat × nat) list × nat × nat option × nat) list × nat)› ‹fst π = name›*) unfolding wf_operator_def
(*goal: ‹⋀x. x ∈ set effs ⟹ case x of (pres, x, xa, xb) ⇒ wf_partial_state pres›*)
by auto
have X1: "distinct (map fst (map (λ(_, x, _, y). (x, y)) (filter (eff_enabled s) effs)))"
using lookup_operator_wf[OF LO] (*‹wf_operator (π::char list × (nat × nat) list × ((nat × nat) list × nat × nat option × nat) list × nat)› ‹fst π = name›*) unfolding wf_operator_def
(*goal: ‹distinct (map fst (map (λ(uu_::(nat × nat) list, x::nat, uu_::nat option, y::nat). (x, y)) (filter (eff_enabled (s::nat ⇒ nat option)) (effs::((nat × nat) list × nat × nat option × nat) list))))›*)
by (auto simp: distinct_map_filter (*‹distinct (map ?f ?xs) ⟹ distinct (map ?f (filter ?P ?xs))›*))
term "filter (eff_enabled s) effs"
have [simp]: "fold (λ(_, x, _, v) s. s(x ↦ v)) l s =
fold (λ(k, v) m. m(k ↦ v)) (map (λ(_, x, _, y). (x, y)) l) s" for l :: "ast_effect list"
apply (induction l arbitrary: s)
(*goals:
1. ‹⋀s. fold (λ(uu_, x, uu_, v) s. s(x ↦ v)) [] s = fold (λ(k, v) m. m(k ↦ v)) (map (λ(_, x, uu_, y). (x, y)) []) s›
2. ‹⋀a l s. (⋀s. fold (λ(uu_, x, uu_, v) s. s(x ↦ v)) l s = fold (λ(k, v) m. m(k ↦ v)) (map (λ(_, x, uu_, y). (x, y)) l) s) ⟹ fold (λ(uu_, x, uu_, v) s. s(x ↦ v)) (a # l) s = fold (λ(k, v) m. m(k ↦ v)) (map (λ(_, x, uu_, y). (x, y)) (a # l)) s›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
show "?thesis"
(*goal: ‹execute_opr' π s = execute name s›*)
unfolding execute_opr'_def execute_def
(*goal: ‹(case π of (name, uu_, effs, uua_) ⇒ λs. let effs = filter (eff_enabled' s) effs in fold (λ(uu_, x, uu_, v) s. s(x ↦ v)) effs s) s = (case lookup_operator name of Some (x, xa, effs, xb) ⇒ s ++ map_of (map (λ(uu_, x, uu_, v). (x, v)) (filter (eff_enabled s) effs)))›*)
using LO (*‹lookup_operator name = Some π›*) by (auto simp: map_add_map_of_fold[OF X1] (*‹?m ++ map_of (map (λ(uu_, x, uu_, y). (x, y)) (filter (eff_enabled s) effs)) = fold (λ(k, v) m. m(k ↦ v)) (map (λ(uu_, x, uu_, y). (x, y)) (filter (eff_enabled s) effs)) ?m›*))
qed
lemma lookup_operator'_correct:
"lookup_operator' problem name = lookup_operator name"
unfolding lookup_operator'_def lookup_operator_def
(*goal: ‹(case problem of (D, I, G, δ) ⇒ λname. find (λ(n, uu_, uu_, uu_). n = name) δ) name = find (λ(n, uu_, uu_, uu_). n = name) astδ›*)
unfolding "astδ_def"
(*goal: ‹(case problem of (D, I, G, δ) ⇒ λname. find (λ(n, uu_, uu_, uu_). n = name) δ) name = find (λ(n, uu_, uu_, uu_). n = name) (case problem of (D, I, G, δ) ⇒ δ)›*)
by (auto split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))
lemma enabled'_correct:
assumes V: "s∈valid_states"
shows "enabled' problem name s = enabled name s"
unfolding enabled'_def
(*goal: ‹(case lookup_operator' (problem::(char list × nat option × char list list) list × nat list × (nat × nat) list × (char list × (nat × nat) list × ((nat × nat) list × nat × nat option × nat) list × nat) list) (name::char list) of None ⇒ False | Some (π::char list × (nat × nat) list × ((nat × nat) list × nat × nat option × nat) list × nat) ⇒ enabled_opr' π (s::nat ⇒ nat option)) = enabled name s›*)
using enabled_opr'_correct[OF V] (*‹lookup_operator (?name::char list) = Some (?π::char list × (nat × nat) list × ((nat × nat) list × nat × nat option × nat) list × nat) ⟹ enabled_opr' ?π (s::nat ⇒ nat option) = enabled ?name s›*) by (auto split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp: enabled_def (*‹enabled ?name ?s ≡ case lookup_operator ?name of None ⇒ False | Some (x, pres, effs, xa) ⇒ ?s ∈ subsuming_states (map_of pres) ∧ ?s ∈ subsuming_states (map_of (implicit_pres effs))›*) lookup_operator'_correct (*‹lookup_operator' problem ?name = lookup_operator ?name›*))
lemma execute'_correct:
assumes V: "s∈valid_states"
assumes "enabled name s" (* Intentionally put this here, also we could resolve non-enabled case by reflexivity (undefined=undefined) *)
shows "execute' problem name s = execute name s"
unfolding execute'_def
(*goal: ‹(case lookup_operator' problem name of Some π ⇒ execute_opr' π s) = execute name s›*)
using execute_opr'_correct[OF V] (*‹lookup_operator ?name = Some ?π ⟹ execute_opr' ?π s = execute ?name s›*) ‹enabled name s› (*‹enabled name s›*) by (auto split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp: enabled_def (*‹enabled ?name ?s ≡ case lookup_operator ?name of None ⇒ False | Some (x, pres, effs, xa) ⇒ ?s ∈ subsuming_states (map_of pres) ∧ ?s ∈ subsuming_states (map_of (implicit_pres effs))›*) lookup_operator'_correct (*‹lookup_operator' problem ?name = lookup_operator ?name›*))
end
context ast_problem
begin
fun simulate_plan :: "plan ⇒ state ⇀ state" where
"simulate_plan [] s = Some s"
| "simulate_plan (π#πs) s = (
if enabled π s then
let s' = execute π s in
simulate_plan πs s'
else
None
)"
lemma simulate_plan_correct: "simulate_plan πs s = Some s' ⟷ path_to s πs s'"
apply (induction s πs s' rule: path_to.induct (*‹⟦⋀s s'. ?P s [] s'; ⋀s π πs s'. ?P (execute π s) πs s' ⟹ ?P s (π # πs) s'⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*))
(*goals:
1. ‹⋀s s'. (simulate_plan [] s = Some s') = path_to s [] s'›
2. ‹⋀s π πs s'. (simulate_plan πs (execute π s) = Some s') = path_to (execute π s) πs s' ⟹ (simulate_plan (π # πs) s = Some s') = path_to s (π # πs) s'›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
definition check_plan :: "plan ⇒ bool" where
"check_plan πs = (
case simulate_plan πs I of
None ⇒ False
| Some s' ⇒ s' ∈ G)"
lemma check_plan_correct: "check_plan πs ⟷ valid_plan πs"
unfolding check_plan_def valid_plan_def
(*goal: ‹(case simulate_plan πs I of None ⇒ False | Some s' ⇒ s' ∈ G) = (∃s'∈G. path_to I πs s')›*)
by (auto split: option.split (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))›*) simp: simulate_plan_correct[symmetric] (*‹path_to ?s ?πs ?s' = (simulate_plan ?πs ?s = Some ?s')›*))
end
fun simulate_plan' :: "ast_problem ⇒ plan ⇒ state ⇀ state" where
"simulate_plan' problem [] s = Some s"
| "simulate_plan' problem (π#πs) s = (
if enabled' problem π s then
let s = execute' problem π s in
simulate_plan' problem πs s
else
None
)"
text ‹Avoiding duplicate lookup.›
(*[code] *)
lemma simulate_plan'_code[code]:
"simulate_plan' problem [] s = Some s"
"simulate_plan' problem (π#πs) s = (
case lookup_operator' problem π of
None ⇒ None
| Some π ⇒
if enabled_opr' π s then
simulate_plan' problem πs (execute_opr' π s)
else None
)"
(*goals:
1. ‹simulate_plan' problem [] s = Some s›
2. ‹simulate_plan' problem (π # πs) s = (case lookup_operator' problem π of None ⇒ None | Some π ⇒ if enabled_opr' π s then simulate_plan' problem πs (execute_opr' π s) else None)›
discuss goal 1*)
apply ((auto simp: enabled'_def (*‹enabled' ?problem ?name ?s ≡ case lookup_operator' ?problem ?name of None ⇒ False | Some π ⇒ enabled_opr' π ?s›*) execute'_def (*‹execute' ?problem ?name ?s ≡ case lookup_operator' ?problem ?name of Some π ⇒ execute_opr' π ?s›*) split: option.split (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))›*))[1])
(*discuss goal 2*)
apply ((auto simp: enabled'_def (*‹enabled' ?problem ?name ?s ≡ case lookup_operator' ?problem ?name of None ⇒ False | Some π ⇒ enabled_opr' π ?s›*) execute'_def (*‹execute' ?problem ?name ?s ≡ case lookup_operator' ?problem ?name of Some π ⇒ execute_opr' π ?s›*) split: option.split (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))›*))[1])
(*proven 2 subgoals*) .
definition initial_state' :: "ast_problem ⇒ state" where
"initial_state' problem ≡ let astI = ast_problem.astI problem in (
λv. if v<length astI then Some (astI!v) else None
)"
definition check_plan' :: "ast_problem ⇒ plan ⇒ bool" where
"check_plan' problem πs = (
case simulate_plan' problem πs (initial_state' problem) of
None ⇒ False
| Some s' ⇒ match_pres (ast_problem.astG problem) s')"
context wf_ast_problem
begin
lemma simulate_plan'_correct:
assumes "s∈valid_states"
shows "simulate_plan' problem πs s = simulate_plan πs s"
using assms (*‹s ∈ valid_states›*) apply (induction πs s rule: simulate_plan.induct (*‹⟦⋀s. ?P [] s; ⋀π πs s. (⋀x. ⟦enabled π s; x = execute π s⟧ ⟹ ?P πs x) ⟹ ?P (π # πs) s⟧ ⟹ ?P ?a0.0 ?a1.0›*))
(*goals:
1. ‹⋀s. s ∈ valid_states ⟹ simulate_plan' problem [] s = simulate_plan [] s›
2. ‹⋀π πs s. ⟦⋀x. ⟦enabled π s; x = execute π s; x ∈ valid_states⟧ ⟹ simulate_plan' problem πs x = simulate_plan πs x; s ∈ valid_states⟧ ⟹ simulate_plan' problem (π # πs) s = simulate_plan (π # πs) s›
discuss goal 1*)
apply ((auto simp: enabled'_correct (*‹?s ∈ valid_states ⟹ enabled' problem ?name ?s = enabled ?name ?s›*) execute'_correct (*‹⟦?s ∈ valid_states; enabled ?name ?s⟧ ⟹ execute' problem ?name ?s = execute ?name ?s›*) execute_preserves_valid (*‹⟦?s ∈ valid_states; enabled ?name ?s⟧ ⟹ execute ?name ?s ∈ valid_states›*))[1])
(*discuss goal 2*)
apply ((auto simp: enabled'_correct (*‹?s ∈ valid_states ⟹ enabled' problem ?name ?s = enabled ?name ?s›*) execute'_correct (*‹⟦?s ∈ valid_states; enabled ?name ?s⟧ ⟹ execute' problem ?name ?s = execute ?name ?s›*) execute_preserves_valid (*‹⟦?s ∈ valid_states; enabled ?name ?s⟧ ⟹ execute ?name ?s ∈ valid_states›*))[1])
(*proven 2 subgoals*) .
lemma simulate_plan'_correct_paper: (* For presentation in paper.
Summarizing intermediate refinement step. *)
assumes "s∈valid_states"
shows "simulate_plan' problem πs s = Some s'
⟷ path_to s πs s'"
using simulate_plan'_correct[OF assms] (*‹simulate_plan' problem ?πs s = simulate_plan ?πs s›*) simulate_plan_correct (*‹(simulate_plan ?πs ?s = Some ?s') = path_to ?s ?πs ?s'›*) by simp
lemma initial_state'_correct:
"initial_state' problem = I"
unfolding initial_state'_def I_def
(*goal: ‹(let astI = astI in (λv. if v < length astI then Some (astI ! v) else None)) = (λv. if v < length astI then Some (astI ! v) else None)›*)
by (auto simp: Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*))
lemma check_plan'_correct:
"check_plan' problem πs = check_plan πs"
proof (-)
(*goal: ‹check_plan' problem πs = check_plan πs›*)
have D: "distinct (map fst astG)"
using wf_goal (*‹wf_partial_state astG›*) unfolding wf_partial_state_def
(*goal: ‹distinct (map fst astG)›*)
by auto
have S'V: "s'∈valid_states" if "simulate_plan πs I = Some s'" for s'
using that (*‹simulate_plan πs I = Some s'›*) by (auto simp: simulate_plan_correct (*‹(simulate_plan ?πs ?s = Some ?s') = path_to ?s ?πs ?s'›*) path_to_pres_valid[OF I_valid] (*‹path_to I ?πs ?s' ⟹ ?s' ∈ valid_states›*))
show "?thesis"
(*goal: ‹check_plan' problem πs = check_plan πs›*)
unfolding check_plan'_def check_plan_def
(*goal: ‹(case simulate_plan' (problem::(char list × nat option × char list list) list × nat list × (nat × nat) list × (char list × (nat × nat) list × ((nat × nat) list × nat × nat option × nat) list × nat) list) (πs::char list list) (initial_state' problem) of None ⇒ False | Some (x::nat ⇒ nat option) ⇒ match_pres astG x) = (case simulate_plan πs I of None ⇒ False | Some (s'::nat ⇒ nat option) ⇒ s' ∈ G)›*)
by (auto split: option.splits (*‹(?P::?'b::type ⇒ bool) (case ?option::?'a::type option of None ⇒ ?f1.0::?'b::type | Some (x::?'a::type) ⇒ (?f2.0::?'a::type ⇒ ?'b::type) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a::type. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b::type ⇒ bool) (case ?option::?'a::type option of None ⇒ ?f1.0::?'b::type | Some (x::?'a::type) ⇒ (?f2.0::?'a::type ⇒ ?'b::type) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a::type. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp: initial_state'_correct (*‹initial_state' (problem::(char list × nat option × char list list) list × nat list × (nat × nat) list × (char list × (nat × nat) list × ((nat × nat) list × nat × nat option × nat) list × nat) list) = I›*) simulate_plan'_correct[OF I_valid] (*‹simulate_plan' (problem::(char list × nat option × char list list) list × nat list × (nat × nat) list × (char list × (nat × nat) list × ((nat × nat) list × nat × nat option × nat) list × nat) list) (?πs::char list list) I = simulate_plan ?πs I›*) simp: match_pres_correct[OF D S'V] (*‹simulate_plan (πs::char list list) I = Some (?s::nat ⇒ nat option) ⟹ match_pres astG ?s = (?s ∈ subsuming_states (map_of astG))›*) G_def (*‹G ≡ subsuming_states (map_of astG)›*))
qed
end
(* Overall checker *)
definition verify_plan :: "ast_problem ⇒ plan ⇒ String.literal + unit" where
"verify_plan problem πs = (
if ast_problem.well_formed problem then
if check_plan' problem πs then Inr () else Inl (STR ''Invalid plan'')
else Inl (STR ''Problem not well formed'')
)"
lemma verify_plan_correct:
"verify_plan problem πs = Inr ()
⟷ ast_problem.well_formed problem ∧ ast_problem.valid_plan problem πs"
proof (-)
(*goal: ‹(verify_plan problem πs = Inr ()) = (ast_problem.well_formed problem ∧ ast_problem.valid_plan problem πs)›*)
{
assume "ast_problem.well_formed problem" (*‹ast_problem.well_formed (problem::(char list × nat option × char list list) list × nat list × (nat × nat) list × (char list × (nat × nat) list × ((nat × nat) list × nat × nat option × nat) list × nat) list)›*)
then interpret wf_ast_problem where
by unfold_locales
from check_plan'_correct (*‹check_plan' problem ?πs = check_plan ?πs›*) check_plan_correct (*‹check_plan ?πs = valid_plan ?πs›*) have "check_plan' problem πs = valid_plan πs"
by simp
}
then show "?thesis"
(*goal: ‹(verify_plan problem πs = Inr ()) = (ast_problem.well_formed problem ∧ ast_problem.valid_plan problem πs)›*)
unfolding verify_plan_def
(*goal: ‹((if ast_problem.well_formed problem then if check_plan' problem πs then Inr () else Inl STR ''Invalid plan'' else Inl STR ''Problem not well formed'') = Inr ()) = (ast_problem.well_formed problem ∧ ast_problem.valid_plan problem πs)›*)
by auto
qed
definition nat_opt_of_integer :: "integer ⇒ nat option" where
"nat_opt_of_integer i = (if (i ≥ 0) then Some (nat_of_integer i) else None)"
(*Export functions, which includes constructors*)
export_code verify_plan nat_of_integer integer_of_nat nat_opt_of_integer Inl Inr String.explode String.implode
in SML
module_name SASP_Checker_Exported
end
| {
"path": "afp-2025-02-12/thys/AI_Planning_Languages_Semantics/SASP_Checker.thy",
"repo": "afp-2025-02-12",
"sha": "c69da1afa368cc68c21cffdec6422b1e7a4e404d6442a39e8ce9b3d205657aee"
} |
(*
Author: Mohammad Abdulaziz, Fred Kurz
*)
theory STRIPS_Semantics
imports "STRIPS_Representation"
"List_Supplement"
"Map_Supplement"
begin
section "STRIPS Semantics"
text ‹ Having provided a concrete implementation of STRIPS and a corresponding locale ‹strips›, we
can now continue to define the semantics of serial and parallel STRIPS plan execution (see
\autoref{sub:serial-sas-plus-and-parallel-strips} and
\autoref{sub:parallel-sas-plus-and-parallel-strips}). ›
subsection "Serial Plan Execution Semantics"
text ‹ Serial plan execution is defined by primitive recursion on the plan.
Definition \autoref{isadef:execute_serial_plan} returns the given state if the state argument does
note satisfy the precondition of the next operator in the plan.
Otherwise it executes the rest of the plan on the successor state \<^term>‹execute_operator s op› of
the given state and operator. ›
primrec execute_serial_plan
where "execute_serial_plan s [] = s"
| "execute_serial_plan s (op # ops)
= (if is_operator_applicable_in s op
then execute_serial_plan (execute_operator s op) ops
else s
)"
text ‹ Analogously, a STRIPS trace either returns the singleton list containing only the given
state in case the precondition of the next operator in the plan is not satisfied. Otherwise, the
given state is prepended to trace of the rest of the plan for the successor state of executing the
next operator on the given state. ›
fun trace_serial_plan_strips
:: "'variable strips_state ⇒ 'variable strips_plan ⇒ 'variable strips_state list"
where "trace_serial_plan_strips s [] = [s]"
| "trace_serial_plan_strips s (op # ops)
= s # (if is_operator_applicable_in s op
then trace_serial_plan_strips (execute_operator s op) ops
else [])"
text ‹ Finally, a serial solution is a plan which transforms a given problems initial state into
its goal state and for which all operators are elements of the problem's operator list. ›
definition is_serial_solution_for_problem
where "is_serial_solution_for_problem Π π
≡ (goal_of Π) ⊆⇩m execute_serial_plan (initial_of Π) π
∧ list_all (λop. ListMem op (operators_of Π)) π"
lemma is_valid_problem_strips_initial_of_dom:
fixes Π:: "'a strips_problem"
assumes "is_valid_problem_strips Π"
shows "dom ((Π)⇩I) = set ((Π)⇩𝒱)"
proof (-)
(*goal: ‹dom (Π⇩I) = set (Π⇩𝒱)›*)
{
let ?I = "strips_problem.initial_of Π"
let ?vs = "strips_problem.variables_of Π"
fix v
have "?I v ≠ None ⟷ ListMem v ?vs"
using assms(1) (*‹is_valid_problem_strips Π›*) unfolding is_valid_problem_strips_def
(*goal: ‹((Π⇩I) v ≠ None) = ListMem v (Π⇩𝒱)›*)
by meson
hence "v ∈ dom ?I ⟷ v ∈ set ?vs"
using ListMem_iff (*‹ListMem (?x::?'a) (?xs::?'a list) = (?x ∈ set ?xs)›*) by fast
}
thus "?thesis"
(*goal: ‹dom (Π⇩I) = set (Π⇩𝒱)›*)
by auto
qed
lemma is_valid_problem_dom_of_goal_state_is:
fixes Π:: "'a strips_problem"
assumes "is_valid_problem_strips Π"
shows "dom ((Π)⇩G) ⊆ set ((Π)⇩𝒱)"
proof (-)
(*goal: ‹dom (Π⇩G) ⊆ set (Π⇩𝒱)›*)
let ?vs = "strips_problem.variables_of Π"
let ?G = "strips_problem.goal_of Π"
have nb: "∀v. ?G v ≠ None ⟶ ListMem v ?vs"
using assms(1) (*‹is_valid_problem_strips Π›*) unfolding is_valid_problem_strips_def
(*goal: ‹∀v. (Π⇩G) v ≠ None ⟶ ListMem v (Π⇩𝒱)›*)
by meson
{
fix v
assume "v ∈ dom ?G" (*‹(v::'a) ∈ dom ((Π::'a strips_problem)⇩G)›*)
then have "?G v ≠ None"
by blast
hence "v ∈ set ?vs"
using nb (*‹∀v. (Π⇩G) v ≠ None ⟶ ListMem v (Π⇩𝒱)›*) unfolding ListMem_iff
(*goal: ‹v ∈ set (Π⇩𝒱)›*)
by blast
}
thus "?thesis"
(*goal: ‹dom (Π⇩G) ⊆ set (Π⇩𝒱)›*)
by auto
qed
lemma is_valid_problem_strips_operator_variable_sets:
fixes Π:: "'a strips_problem"
assumes "is_valid_problem_strips Π"
and "op ∈ set ((Π)⇩𝒪)"
shows "set (precondition_of op) ⊆ set ((Π)⇩𝒱)"
and "set (add_effects_of op) ⊆ set ((Π)⇩𝒱)"
and "set (delete_effects_of op) ⊆ set ((Π)⇩𝒱)"
and "disjnt (set (add_effects_of op)) (set (delete_effects_of op))"
proof (-)
(*goals:
1. ‹set (precondition_of op) ⊆ set (Π⇩𝒱)›
2. ‹set (add_effects_of op) ⊆ set (Π⇩𝒱)›
3. ‹set (delete_effects_of op) ⊆ set (Π⇩𝒱)›
4. ‹disjnt (set (add_effects_of op)) (set (delete_effects_of op))›*)
let ?ops = "strips_problem.operators_of Π" and ?vs = "strips_problem.variables_of Π"
have "list_all (is_valid_operator_strips Π) ?ops"
using assms(1) (*‹is_valid_problem_strips Π›*) unfolding is_valid_problem_strips_def
(*goal: ‹list_all (is_valid_operator_strips Π) (Π⇩𝒪)›*)
by meson
moreover have "∀v ∈ set (precondition_of op). v ∈ set ((Π)⇩𝒱)" and "∀v ∈ set (add_effects_of op). v ∈ set ((Π)⇩𝒱)" and "∀v ∈ set (delete_effects_of op). v ∈ set ((Π)⇩𝒱)" and "∀v ∈ set (add_effects_of op). v ∉ set (delete_effects_of op)" and "∀v ∈ set (delete_effects_of op). v ∉ set (add_effects_of op)"
using assms(2) (*‹op ∈ set (Π⇩𝒪)›*) calculation (*‹list_all (is_valid_operator_strips Π) (Π⇩𝒪)›*) unfolding is_valid_operator_strips_def list_all_iff Let_def ListMem_iff
(*goals:
1. ‹∀v∈set (precondition_of op). v ∈ set (Π⇩𝒱)›
2. ‹∀v∈set (add_effects_of op). v ∈ set (Π⇩𝒱)›
3. ‹∀v∈set (delete_effects_of op). v ∈ set (Π⇩𝒱)›
4. ‹∀v∈set (add_effects_of op). v ∉ set (delete_effects_of op)›
5. ‹∀v∈set (delete_effects_of op). v ∉ set (add_effects_of op)›*)
using variables_of_def (*‹variables_of ≡ id ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_fst strips_problem_ext_Tuple_Iso›*) apply -
(*goals:
1. ‹⟦op ∈ set (Π⇩𝒪); ∀op∈set (Π⇩𝒪). (∀v∈set (precondition_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (add_effects_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (delete_effects_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (add_effects_of op). v ∉ set (delete_effects_of op)) ∧ (∀v∈set (delete_effects_of op). v ∉ set (add_effects_of op)); variables_of ≡ id ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_fst strips_problem_ext_Tuple_Iso⟧ ⟹ ∀v∈set (precondition_of op). v ∈ set (Π⇩𝒱)›
2. ‹⟦op ∈ set (Π⇩𝒪); ∀op∈set (Π⇩𝒪). (∀v∈set (precondition_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (add_effects_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (delete_effects_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (add_effects_of op). v ∉ set (delete_effects_of op)) ∧ (∀v∈set (delete_effects_of op). v ∉ set (add_effects_of op)); variables_of ≡ id ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_fst strips_problem_ext_Tuple_Iso⟧ ⟹ ∀v∈set (add_effects_of op). v ∈ set (Π⇩𝒱)›
3. ‹⟦op ∈ set (Π⇩𝒪); ∀op∈set (Π⇩𝒪). (∀v∈set (precondition_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (add_effects_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (delete_effects_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (add_effects_of op). v ∉ set (delete_effects_of op)) ∧ (∀v∈set (delete_effects_of op). v ∉ set (add_effects_of op)); variables_of ≡ id ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_fst strips_problem_ext_Tuple_Iso⟧ ⟹ ∀v∈set (delete_effects_of op). v ∈ set (Π⇩𝒱)›
4. ‹⟦op ∈ set (Π⇩𝒪); ∀op∈set (Π⇩𝒪). (∀v∈set (precondition_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (add_effects_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (delete_effects_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (add_effects_of op). v ∉ set (delete_effects_of op)) ∧ (∀v∈set (delete_effects_of op). v ∉ set (add_effects_of op)); variables_of ≡ id ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_fst strips_problem_ext_Tuple_Iso⟧ ⟹ ∀v∈set (add_effects_of op). v ∉ set (delete_effects_of op)›
5. ‹⟦op ∈ set (Π⇩𝒪); ∀op∈set (Π⇩𝒪). (∀v∈set (precondition_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (add_effects_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (delete_effects_of op). v ∈ set (Π⇩𝒱)) ∧ (∀v∈set (add_effects_of op). v ∉ set (delete_effects_of op)) ∧ (∀v∈set (delete_effects_of op). v ∉ set (add_effects_of op)); variables_of ≡ id ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_fst strips_problem_ext_Tuple_Iso⟧ ⟹ ∀v∈set (delete_effects_of op). v ∉ set (add_effects_of op)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .
ultimately show "set (precondition_of op) ⊆ set ((Π)⇩𝒱)" and "set (add_effects_of op) ⊆ set ((Π)⇩𝒱)" and "set (delete_effects_of op) ⊆ set ((Π)⇩𝒱)" and "disjnt (set (add_effects_of op)) (set (delete_effects_of op))"
unfolding disjnt_def
(*goals:
1. ‹set (precondition_of op) ⊆ set (Π⇩𝒱)›
2. ‹set (add_effects_of op) ⊆ set (Π⇩𝒱)›
3. ‹set (delete_effects_of op) ⊆ set (Π⇩𝒱)›
4. ‹set (add_effects_of op) ∩ set (delete_effects_of op) = {}›*)
apply -
(*goals:
1. ‹⟦list_all (is_valid_operator_strips Π) (Π⇩𝒪); ∀v∈set (precondition_of op). v ∈ set (Π⇩𝒱); ∀v∈set (add_effects_of op). v ∈ set (Π⇩𝒱); ∀v∈set (delete_effects_of op). v ∈ set (Π⇩𝒱); ∀v∈set (add_effects_of op). v ∉ set (delete_effects_of op); ∀v∈set (delete_effects_of op). v ∉ set (add_effects_of op)⟧ ⟹ set (precondition_of op) ⊆ set (Π⇩𝒱)›
2. ‹⟦list_all (is_valid_operator_strips Π) (Π⇩𝒪); ∀v∈set (precondition_of op). v ∈ set (Π⇩𝒱); ∀v∈set (add_effects_of op). v ∈ set (Π⇩𝒱); ∀v∈set (delete_effects_of op). v ∈ set (Π⇩𝒱); ∀v∈set (add_effects_of op). v ∉ set (delete_effects_of op); ∀v∈set (delete_effects_of op). v ∉ set (add_effects_of op)⟧ ⟹ set (add_effects_of op) ⊆ set (Π⇩𝒱)›
3. ‹⟦list_all (is_valid_operator_strips Π) (Π⇩𝒪); ∀v∈set (precondition_of op). v ∈ set (Π⇩𝒱); ∀v∈set (add_effects_of op). v ∈ set (Π⇩𝒱); ∀v∈set (delete_effects_of op). v ∈ set (Π⇩𝒱); ∀v∈set (add_effects_of op). v ∉ set (delete_effects_of op); ∀v∈set (delete_effects_of op). v ∉ set (add_effects_of op)⟧ ⟹ set (delete_effects_of op) ⊆ set (Π⇩𝒱)›
4. ‹⟦list_all (is_valid_operator_strips Π) (Π⇩𝒪); ∀v∈set (precondition_of op). v ∈ set (Π⇩𝒱); ∀v∈set (add_effects_of op). v ∈ set (Π⇩𝒱); ∀v∈set (delete_effects_of op). v ∈ set (Π⇩𝒱); ∀v∈set (add_effects_of op). v ∉ set (delete_effects_of op); ∀v∈set (delete_effects_of op). v ∉ set (add_effects_of op)⟧ ⟹ set (add_effects_of op) ∩ set (delete_effects_of op) = {}›
discuss goal 1*)
apply fast
(*discuss goal 2*)
apply fast
(*discuss goal 3*)
apply fast
(*discuss goal 4*)
apply fast
(*proven 4 subgoals*) .
qed
lemma effect_to_assignments_i:
assumes "as = effect_to_assignments op"
shows "as = (map (λv. (v, True)) (add_effects_of op)
@ map (λv. (v, False)) (delete_effects_of op))"
sorry
lemma effect_to_assignments_ii:
― ‹ NOTE ‹effect_to_assignments› can be simplified drastically given that only atomic effects
and the add-effects as well as delete-effects lists only consist of variables.›
assumes "as = effect_to_assignments op"
obtains as₁ as₂
where "as = as₁ @ as₂"
and "as₁ = map (λv. (v, True)) (add_effects_of op)"
and "as₂ = map (λv. (v, False)) (delete_effects_of op)"
by (simp add: assms (*‹as = effect_to_assignments op›*) effect__strips_def (*‹effect__strips ?op = map (λv. (v, True)) (add_effects_of ?op) @ map (λv. (v, False)) (delete_effects_of ?op)›*) effect_to_assignments_def (*‹effect_to_assignments ?op ≡ effect__strips ?op›*))<close>
lemma effect_to_assignments_iii_a:
fixes v
assumes "v ∈ set (add_effects_of op)"
and "as = effect_to_assignments op"
obtains a where "a ∈ set as" "a = (v, True)"
proof (-)
(*goal: ‹(⋀a. ⟦a ∈ set as; a = (v, True)⟧ ⟹ thesis) ⟹ thesis›*)
let ?add_assignments = "(λv. (v, True)) ` set (add_effects_of op)"
let ?delete_assignments = "(λv. (v, False)) ` set (delete_effects_of op)"
obtain as₁ and as₂ where a1: "as = as₁ @ as₂" and a2: "as₁ = map (λv. (v, True)) (add_effects_of op)" and a3: "as₂ = map (λv. (v, False)) (delete_effects_of op)"
(*goal: ‹(⋀(as₁::('a × bool) list) as₂::('a × bool) list. ⟦(as::('a × bool) list) = as₁ @ as₂; as₁ = map (λv::'a. (v, True)) (add_effects_of (op::'a strips_operator)); as₂ = map (λv::'a. (v, False)) (delete_effects_of op)⟧ ⟹ thesis::bool) ⟹ thesis›*)
using assms(2) (*‹as = effect_to_assignments op›*) effect_to_assignments_ii (*‹⟦(?as::(?'a × bool) list) = effect_to_assignments (?op::?'a strips_operator); ⋀(as₁::(?'a × bool) list) as₂::(?'a × bool) list. ⟦?as = as₁ @ as₂; as₁ = map (λv::?'a. (v, True)) (add_effects_of ?op); as₂ = map (λv::?'a. (v, False)) (delete_effects_of ?op)⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) by blast
then have b: "set as
= ?add_assignments ∪ ?delete_assignments"
by auto
{
from b (*‹set (as::('a × bool) list) = (λv::'a. (v, True)) ` set (add_effects_of (op::'a strips_operator)) ∪ (λv::'a. (v, False)) ` set (delete_effects_of op)›*) have "?add_assignments ⊆ set as"
by blast
moreover have "{(v, True)} ⊆ ?add_assignments"
using assms(1) (*‹v ∈ set (add_effects_of op)›*) a2 (*‹as₁ = map (λv. (v, True)) (add_effects_of op)›*) by blast
ultimately have "∃a. a ∈ set as ∧ a = (v, True)"
by blast
}
then show "?thesis"
(*goal: ‹thesis::bool›*)
using that (*‹⟦(?a::'a × bool) ∈ set (as::('a × bool) list); ?a = (v::'a, True)⟧ ⟹ thesis::bool›*) by blast
qed
lemma effect_to_assignments_iii_b:
― ‹ NOTE This proof is symmetrical to the one above. ›
fixes v
assumes "v ∈ set (delete_effects_of op)"
and "as = effect_to_assignments op"
obtains a where "a ∈ set as" "a = (v, False)"
proof (-)
(*goal: ‹(⋀a::'a × bool. ⟦a ∈ set (as::('a × bool) list); a = (v::'a, False)⟧ ⟹ thesis::bool) ⟹ thesis›*)
let ?add_assignments = "(λv. (v, True)) ` set (add_effects_of op)"
let ?delete_assignments = "(λv. (v, False)) ` set (delete_effects_of op)"
obtain as₁ and as₂ where a1: "as = as₁ @ as₂" and a2: "as₁ = map (λv. (v, True)) (add_effects_of op)" and a3: "as₂ = map (λv. (v, False)) (delete_effects_of op)"
(*goal: ‹(⋀as₁ as₂. ⟦as = as₁ @ as₂; as₁ = map (λv. (v, True)) (add_effects_of op); as₂ = map (λv. (v, False)) (delete_effects_of op)⟧ ⟹ thesis) ⟹ thesis›*)
using assms(2) (*‹as = effect_to_assignments op›*) effect_to_assignments_ii (*‹⟦?as = effect_to_assignments ?op; ⋀as₁ as₂. ⟦?as = as₁ @ as₂; as₁ = map (λv. (v, True)) (add_effects_of ?op); as₂ = map (λv. (v, False)) (delete_effects_of ?op)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by blast
then have b: "set as
= ?add_assignments ∪ ?delete_assignments"
by auto
{
from b (*‹set as = (λv. (v, True)) ` set (add_effects_of op) ∪ (λv. (v, False)) ` set (delete_effects_of op)›*) have "?delete_assignments ⊆ set as"
by blast
moreover have "{(v, False)} ⊆ ?delete_assignments"
using assms(1) (*‹v ∈ set (delete_effects_of op)›*) a2 (*‹as₁ = map (λv. (v, True)) (add_effects_of op)›*) by blast
ultimately have "∃a. a ∈ set as ∧ a = (v, False)"
by blast
}
then show "?thesis"
(*goal: ‹thesis›*)
using that (*‹⟦?a ∈ set as; ?a = (v, False)⟧ ⟹ thesis›*) by blast
qed
lemma effect__strips_i:
fixes op
assumes "e = effect__strips op"
obtains es₁ es₂
where "e = (es₁ @ es₂)"
and "es₁ = map (λv. (v, True)) (add_effects_of op)"
and "es₂ = map (λv. (v, False)) (delete_effects_of op)"
proof (-)
(*goal: ‹(⋀es₁ es₂. ⟦e = es₁ @ es₂; es₁ = map (λv. (v, True)) (add_effects_of op); es₂ = map (λv. (v, False)) (delete_effects_of op)⟧ ⟹ thesis) ⟹ thesis›*)
obtain es₁ and es₂ where a: "e = (es₁ @ es₂)" and b: "es₁ = map (λv. (v, True)) (add_effects_of op)" and c: "es₂ = map (λv. (v, False)) (delete_effects_of op)"
(*goal: ‹(⋀es₁ es₂. ⟦e = es₁ @ es₂; es₁ = map (λv. (v, True)) (add_effects_of op); es₂ = map (λv. (v, False)) (delete_effects_of op)⟧ ⟹ thesis) ⟹ thesis›*)
using assms(1) (*‹e = effect__strips op›*) unfolding effect__strips_def
(*goal: ‹(⋀es₁ es₂. ⟦e = es₁ @ es₂; es₁ = map (λv. (v, True)) (add_effects_of op); es₂ = map (λv. (v, False)) (delete_effects_of op)⟧ ⟹ thesis) ⟹ thesis›*)
by blast
then show "?thesis"
(*goal: ‹thesis›*)
using that (*‹⟦e = ?es₁ @ ?es₂; ?es₁ = map (λv. (v, True)) (add_effects_of op); ?es₂ = map (λv. (v, False)) (delete_effects_of op)⟧ ⟹ thesis›*) by force
qed
lemma effect__strips_ii:
fixes op
assumes "e = ConjunctiveEffect (es₁ @ es₂)"
and "es₁ = map (λv. (v, True)) (add_effects_of op)"
and "es₂ = map (λv. (v, False)) (delete_effects_of op)"
shows "∀v ∈ set (add_effects_of op). (∃e' ∈ set es₁. e' = (v, True))"
and "∀v ∈ set (delete_effects_of op). (∃e' ∈ set es₂. e' = (v, False))"
proof (standard)
(*goals:
1. ‹⋀v::'b::type. v ∈ set (add_effects_of (op::('b, 'c) strips_operator_scheme)) ⟹ ∃e'::'b::type × bool∈set (es₁::('b::type × bool) list). e' = (v, True)›
2. ‹∀v::'b::type∈set (delete_effects_of (op::('b, 'c) strips_operator_scheme)). ∃e'::'b::type × bool∈set (es₂::('b::type × bool) list). e' = (v, False)›*)
fix v
{
assume a: "v ∈ set (add_effects_of op)" (*‹(v::'b) ∈ set (add_effects_of (op::('b, 'c) strips_operator_scheme))›*)
have "set es₁ = (λv. (v, True)) ` set (add_effects_of op)"
using assms(2) (*‹(es₁::('b × bool) list) = map (λv::'b. (v, True)) (add_effects_of (op::('b, 'c) strips_operator_scheme))›*) List.set_map (*‹set (map (?f::?'b ⇒ ?'a) (?xs::?'b list)) = ?f ` set ?xs›*) by auto
then obtain e' where "e' ∈ set es₁" and "e' = (λv. (v, True)) v"
(*goal: ‹(⋀e'::'b::type × bool. ⟦e' ∈ set (es₁::('b::type × bool) list); e' = (v::'b::type, True)⟧ ⟹ thesis::bool) ⟹ thesis›*)
using a (*‹v ∈ set (add_effects_of op)›*) by blast
then have "∃e' ∈ set es₁. e' = (v, True)"
by blast
}
thus "v ∈ set (add_effects_of op) ⟹ ∃e' ∈ set es₁. e' = (v, True)"
by fast
next
(*goal: ‹∀v∈set (delete_effects_of op). ∃e'∈set es₂. e' = (v, False)›*)
{
fix v
assume a: "v ∈ set (delete_effects_of op)" (*‹(v::'b) ∈ set (delete_effects_of (op::('b, 'c) strips_operator_scheme))›*)
have "set es₂ = (λv. (v, False)) ` set (delete_effects_of op)"
using assms(3) (*‹es₂ = map (λv. (v, False)) (delete_effects_of op)›*) List.set_map (*‹set (map (?f::?'b::type ⇒ ?'a::type) (?xs::?'b::type list)) = ?f ` set ?xs›*) by force
then obtain e'' where "e'' ∈ set es₂" and "e'' = (λv. (v, False)) v"
(*goal: ‹(⋀e''. ⟦e'' ∈ set es₂; e'' = (v, False)⟧ ⟹ thesis) ⟹ thesis›*)
using a (*‹v ∈ set (delete_effects_of op)›*) by blast
then have "∃e'' ∈ set es₂. e'' = (v, False)"
by blast
}
thus "∀v∈set (delete_effects_of op). ∃e'∈set es₂. e' = (v, False)"
by fast
qed
(* TODO refactor theory Appendix AND make visible? *)
lemma map_of_constant_assignments_dom:
― ‹ NOTE ancillary lemma used in the proof below. ›
assumes "m = map_of (map (λv. (v, d)) vs)"
shows "dom m = set vs"
proof (-)
(*goal: ‹dom m = set vs›*)
let ?vs' = "map (λv. (v, d)) vs"
have "dom m = fst ` set ?vs'"
using assms(1) (*‹m = map_of (map (λv. (v, d)) vs)›*) dom_map_of_conv_image_fst (*‹dom (map_of ?xys) = fst ` set ?xys›*) by metis
moreover have "fst ` set ?vs' = set vs"
by force
ultimately show "?thesis"
(*goal: ‹dom m = set vs›*)
by argo
qed
lemma effect__strips_iii_a:
assumes "s' = (s ⪢ op)"
shows "⋀v. v ∈ set (add_effects_of op) ⟹ s' v = Some True"
proof (-)
(*goal: ‹⋀v::'a::type. v ∈ set (add_effects_of (op::'a strips_operator)) ⟹ (s'::'a::type ⇒ bool option) v = Some True›*)
fix v
assume a: "v ∈ set (add_effects_of op)" (*‹(v::'a) ∈ set (add_effects_of (op::'a strips_operator))›*)
let ?as = "effect_to_assignments op"
obtain as₁ and as₂ where b: "?as = as₁ @ as₂" and c: "as₁ = map (λv. (v, True)) (add_effects_of op)" and "as₂ = map (λv. (v, False)) (delete_effects_of op)"
(*goal: ‹(⋀as₁ as₂. ⟦effect_to_assignments op = as₁ @ as₂; as₁ = map (λv. (v, True)) (add_effects_of op); as₂ = map (λv. (v, False)) (delete_effects_of op)⟧ ⟹ thesis) ⟹ thesis›*)
using effect_to_assignments_ii (*‹⟦?as = effect_to_assignments ?op; ⋀as₁ as₂. ⟦?as = as₁ @ as₂; as₁ = map (λv. (v, True)) (add_effects_of ?op); as₂ = map (λv. (v, False)) (delete_effects_of ?op)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by blast
have d: "map_of ?as = map_of as₂ ++ map_of as₁"
using b (*‹effect_to_assignments op = as₁ @ as₂›*) Map.map_of_append (*‹map_of (?xs @ ?ys) = map_of ?ys ++ map_of ?xs›*) by auto
{
let ?vs = "add_effects_of op"
have "?vs ≠ []"
using a (*‹v ∈ set (add_effects_of op)›*) by force
then have "dom (map_of as₁) = set (add_effects_of op)"
using c (*‹as₁ = map (λv. (v, True)) (add_effects_of op)›*) map_of_constant_assignments_dom (*‹(?m::?'a::type ⇒ ?'b::type option) = map_of (map (λv::?'a::type. (v, ?d::?'b::type)) (?vs::?'a::type list)) ⟹ dom ?m = set ?vs›*) by metis
then have "v ∈ dom (map_of as₁)"
using a (*‹v ∈ set (add_effects_of op)›*) by blast
then have "map_of ?as v = map_of as₁ v"
using d (*‹map_of (effect_to_assignments op) = map_of as₂ ++ map_of as₁›*) by force
}
moreover {
let ?f = "λ_. True"
from c (*‹(as₁::('a × bool) list) = map (λv::'a. (v, True)) (add_effects_of (op::'a strips_operator))›*) have "map_of as₁ = (Some ∘ ?f) |` (set (add_effects_of op))"
using map_of_map_restrict (*‹map_of (map (λk. (k, ?f k)) ?ks) = (Some ∘ ?f) |` set ?ks›*) by fast
then have "map_of as₁ v = Some True"
using a (*‹v ∈ set (add_effects_of op)›*) by auto
}
moreover have "s' = s ++ map_of as₂ ++ map_of as₁"
using assms(1) (*‹(s'::'a ⇒ bool option) = (s::'a ⇒ bool option) ⪢ (op::'a strips_operator)›*) unfolding execute_operator_def
(*goal: ‹s' = s ++ map_of as₂ ++ map_of as₁›*)
using b (*‹effect_to_assignments op = as₁ @ as₂›*) by simp
ultimately show "s' v = Some True"
by simp
qed
(* TODO In contrast to the proof above we need proof preparation with auto. Why? *)
lemma effect__strips_iii_b:
assumes "s' = (s ⪢ op)"
shows "⋀v. v ∈ set (delete_effects_of op) ∧ v ∉ set (add_effects_of op) ⟹ s' v = Some False"
proof (auto)
(*goal: ‹⋀v. ⟦v ∈ set (delete_effects_of op); v ∉ set (add_effects_of op)⟧ ⟹ s' v = Some False›*)
fix v
assume a1: "v ∉ set (add_effects_of op)" and a2: "v ∈ set (delete_effects_of op)" (*‹(v::'a) ∉ set (add_effects_of (op::'a strips_operator))› ‹(v::'a) ∈ set (delete_effects_of (op::'a strips_operator))›*)
let ?as = "effect_to_assignments op"
obtain as₁ and as₂ where b: "?as = as₁ @ as₂" and c: "as₁ = map (λv. (v, True)) (add_effects_of op)" and d: "as₂ = map (λv. (v, False)) (delete_effects_of op)"
(*goal: ‹(⋀as₁ as₂. ⟦effect_to_assignments op = as₁ @ as₂; as₁ = map (λv. (v, True)) (add_effects_of op); as₂ = map (λv. (v, False)) (delete_effects_of op)⟧ ⟹ thesis) ⟹ thesis›*)
using effect_to_assignments_ii (*‹⟦(?as::(?'a::type × bool) list) = effect_to_assignments (?op::?'a strips_operator); ⋀(as₁::(?'a::type × bool) list) as₂::(?'a::type × bool) list. ⟦?as = as₁ @ as₂; as₁ = map (λv::?'a::type. (v, True)) (add_effects_of ?op); as₂ = map (λv::?'a::type. (v, False)) (delete_effects_of ?op)⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) by blast
have e: "map_of ?as = map_of as₂ ++ map_of as₁"
using b (*‹effect_to_assignments op = as₁ @ as₂›*) Map.map_of_append (*‹map_of ((?xs::(?'a × ?'b) list) @ (?ys::(?'a × ?'b) list)) = map_of ?ys ++ map_of ?xs›*) by auto
{
have "dom (map_of as₁) = set (add_effects_of op)"
using c (*‹as₁ = map (λv. (v, True)) (add_effects_of op)›*) map_of_constant_assignments_dom (*‹?m = map_of (map (λv. (v, ?d)) ?vs) ⟹ dom ?m = set ?vs›*) by metis
then have "v ∉ dom (map_of as₁)"
using a1 (*‹v ∉ set (add_effects_of op)›*) by blast
}
note f = this (*‹(v::'a::type) ∉ dom (map_of (as₁::('a::type × bool) list))›*)
{
let ?vs = "delete_effects_of op"
have "?vs ≠ []"
using a2 (*‹v ∈ set (delete_effects_of op)›*) by force
then have "dom (map_of as₂) = set ?vs"
using d (*‹as₂ = map (λv. (v, False)) (delete_effects_of op)›*) map_of_constant_assignments_dom (*‹?m = map_of (map (λv. (v, ?d)) ?vs) ⟹ dom ?m = set ?vs›*) by metis
}
note g = this (*‹dom (map_of as₂) = set (delete_effects_of op)›*)
{
have "s' = s ++ map_of as₂ ++ map_of as₁"
using assms(1) (*‹(s'::'a ⇒ bool option) = (s::'a ⇒ bool option) ⪢ (op::'a strips_operator)›*) unfolding execute_operator_def
(*goal: ‹s' = s ++ map_of as₂ ++ map_of as₁›*)
using b (*‹effect_to_assignments op = as₁ @ as₂›*) by simp
thm f map_add_dom_app_simps(3)[OF f, of "s ++ map_of as₂"]
moreover have "s' v = (s ++ map_of as₂) v"
using calculation (*‹s' = s ++ map_of as₂ ++ map_of as₁›*) map_add_dom_app_simps(3)[OF f, of "s ++ map_of as₂"] (*‹(s ++ map_of as₂ ++ map_of as₁) v = (s ++ map_of as₂) v›*) by blast
moreover have "v ∈ dom (map_of as₂)"
using a2 (*‹v ∈ set (delete_effects_of op)›*) g (*‹dom (map_of as₂) = set (delete_effects_of op)›*) by argo
ultimately have "s' v = map_of as₂ v"
by fastforce
}
moreover {
let ?f = "λ_. False"
from d (*‹as₂ = map (λv. (v, False)) (delete_effects_of op)›*) have "map_of as₂ = (Some ∘ ?f) |` (set (delete_effects_of op))"
using map_of_map_restrict (*‹map_of (map (λk. (k, ?f k)) ?ks) = (Some ∘ ?f) |` set ?ks›*) by fast
then have "map_of as₂ v = Some False"
using a2 (*‹v ∈ set (delete_effects_of op)›*) by force
}
ultimately show " s' v = Some False"
by argo
qed
(* TODO We need proof preparation with auto. Why? *)
lemma effect__strips_iii_c:
assumes "s' = (s ⪢ op)"
shows "⋀v. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op) ⟹ s' v = s v"
proof (auto)
(*goal: ‹⋀v. ⟦v ∉ set (add_effects_of op); v ∉ set (delete_effects_of op)⟧ ⟹ s' v = s v›*)
fix v
assume a1: "v ∉ set (add_effects_of op)" and a2: "v ∉ set (delete_effects_of op)" (*‹(v::'a) ∉ set (add_effects_of (op::'a strips_operator))› ‹(v::'a) ∉ set (delete_effects_of (op::'a strips_operator))›*)
let ?as = "effect_to_assignments op"
obtain as₁ and as₂ where b: "?as = as₁ @ as₂" and c: "as₁ = map (λv. (v, True)) (add_effects_of op)" and d: "as₂ = map (λv. (v, False)) (delete_effects_of op)"
(*goal: ‹(⋀(as₁::('a::type × bool) list) as₂::('a::type × bool) list. ⟦effect_to_assignments (op::'a strips_operator) = as₁ @ as₂; as₁ = map (λv::'a::type. (v, True)) (add_effects_of op); as₂ = map (λv::'a::type. (v, False)) (delete_effects_of op)⟧ ⟹ thesis::bool) ⟹ thesis›*)
using effect_to_assignments_ii (*‹⟦?as = effect_to_assignments ?op; ⋀as₁ as₂. ⟦?as = as₁ @ as₂; as₁ = map (λv. (v, True)) (add_effects_of ?op); as₂ = map (λv. (v, False)) (delete_effects_of ?op)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by blast
have e: "map_of ?as = map_of as₂ ++ map_of as₁"
using b (*‹effect_to_assignments op = as₁ @ as₂›*) Map.map_of_append (*‹map_of (?xs @ ?ys) = map_of ?ys ++ map_of ?xs›*) by auto
{
have "dom (map_of as₁) = set (add_effects_of op)"
using c (*‹(as₁::('a × bool) list) = map (λv::'a. (v, True)) (add_effects_of (op::'a strips_operator))›*) map_of_constant_assignments_dom (*‹?m = map_of (map (λv. (v, ?d)) ?vs) ⟹ dom ?m = set ?vs›*) by metis
then have "v ∉ dom (map_of as₁)"
using a1 (*‹v ∉ set (add_effects_of op)›*) by blast
}
moreover {
have "dom (map_of as₂) = set (delete_effects_of op)"
using d (*‹as₂ = map (λv. (v, False)) (delete_effects_of op)›*) map_of_constant_assignments_dom (*‹?m = map_of (map (λv. (v, ?d)) ?vs) ⟹ dom ?m = set ?vs›*) by metis
then have "v ∉ dom (map_of as₂)"
using a2 (*‹(v::'a::type) ∉ set (delete_effects_of (op::'a strips_operator))›*) by blast
}
ultimately show "s' v = s v"
using assms(1) (*‹s' = s ⪢ op›*) unfolding execute_operator_def
(*goal: ‹s' v = s v›*)
by (simp add: b (*‹effect_to_assignments op = as₁ @ as₂›*) map_add_dom_app_simps( (*‹?m ∉ dom ?l2.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l1.0 ?m›*) 3))
qed
text ‹The following theorem combines three preceding sublemmas which show
that the following properties hold for the successor state ‹s' ≡ execute_operator op s›
obtained by executing an operator ‹op› in a state ‹s›:
\footnote{Lemmas \path{effect__strips_iii_a}, \path{effect__strips_iii_b}, and
\path{effect__strips_iii_c} (not shown).}
\begin{itemize}
\item every add effect is satisfied in ‹s'› (sublemma \isaname{effect__strips_iii_a}); and,
\item every delete effect that is not also an add effect is not satisfied in ‹s'› (sublemma
\isaname{effect__strips_iii_b}); and finally
\item the state remains unchanged---i.e. ‹s' v = s v›---for all variables which are neither an
add effect nor a delete effect.
\end{itemize} ›
(* TODO? Rewrite theorem ‹operator_effect__strips› to match ‹s ++ map_of (
effect_to_assignments op)› rather than ‹execute_operator Π op s› since we need this
form later on for the parallel execution theorem? *)
theorem operator_effect__strips:
assumes "s' = (s ⪢ op)"
shows
"⋀v.
v ∈ set (add_effects_of op)
⟹ s' v = Some True"
and "⋀v.
v ∉ set (add_effects_of op) ∧ v ∈ set (delete_effects_of op)
⟹ s' v = Some False"
and "⋀v.
v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op)
⟹ s' v = s v"
proof (auto)
(*goals:
1. ‹⋀v. v ∈ set (add_effects_of op) ⟹ s' v = Some True›
2. ‹⋀v. ⟦v ∉ set (add_effects_of op); v ∈ set (delete_effects_of op)⟧ ⟹ s' v = Some False›
3. ‹⋀v. ⟦v ∉ set (add_effects_of op); v ∉ set (delete_effects_of op)⟧ ⟹ s' v = s v›*)
show "⋀v.
v ∈ set (add_effects_of op)
⟹ s' v = Some True"
using assms (*‹s' = s ⪢ op›*) effect__strips_iii_a (*‹⟦?s' = ?s ⪢ ?op; ?v ∈ set (add_effects_of ?op)⟧ ⟹ ?s' ?v = Some True›*) by fast
next
(*goals:
1. ‹⋀v. ⟦v ∉ set (add_effects_of op); v ∈ set (delete_effects_of op)⟧ ⟹ s' v = Some False›
2. ‹⋀v. ⟦v ∉ set (add_effects_of op); v ∉ set (delete_effects_of op)⟧ ⟹ s' v = s v›*)
show "⋀v.
v ∉ set (add_effects_of op)
⟹ v ∈ set (delete_effects_of op)
⟹ s' v = Some False"
using assms (*‹s' = s ⪢ op›*) effect__strips_iii_b (*‹⟦?s' = ?s ⪢ ?op; ?v ∈ set (delete_effects_of ?op) ∧ ?v ∉ set (add_effects_of ?op)⟧ ⟹ ?s' ?v = Some False›*) by fast
next
(*goal: ‹⋀v. ⟦v ∉ set (add_effects_of op); v ∉ set (delete_effects_of op)⟧ ⟹ s' v = s v›*)
show "⋀v.
v ∉ set (add_effects_of op)
⟹ v ∉ set (delete_effects_of op)
⟹ s' v = s v"
using assms (*‹s' = s ⪢ op›*) effect__strips_iii_c (*‹⟦?s' = ?s ⪢ ?op; ?v ∉ set (add_effects_of ?op) ∧ ?v ∉ set (delete_effects_of ?op)⟧ ⟹ ?s' ?v = ?s ?v›*) by metis
qed
subsection "Parallel Plan Semantics"
definition "are_all_operators_applicable s ops
≡ list_all (λop. is_operator_applicable_in s op) ops"
definition "are_operator_effects_consistent op₁ op₂ ≡ let
add₁ = add_effects_of op₁
; add₂ = add_effects_of op₂
; del₁ = delete_effects_of op₁
; del₂ = delete_effects_of op₂
in ¬list_ex (λv. list_ex ((=) v) del₂) add₁ ∧ ¬list_ex (λv. list_ex ((=) v) add₂) del₁"
definition "are_all_operator_effects_consistent ops ≡
list_all (λop. list_all (are_operator_effects_consistent op) ops) ops"
definition execute_parallel_operator
:: "'variable strips_state
⇒ 'variable strips_operator list
⇒ 'variable strips_state"
where "execute_parallel_operator s ops
≡ foldl (++) s (map (map_of ∘ effect_to_assignments) ops)"
text ‹ The parallel STRIPS execution semantics is defined in similar way as the serial STRIPS
execution semantics. However, the applicability test is lifted to parallel operators and we
additionally test for operator consistency (which was unecessary in the serial case). ›
fun execute_parallel_plan
:: "'variable strips_state
⇒ 'variable strips_parallel_plan
⇒ 'variable strips_state"
where "execute_parallel_plan s [] = s"
| "execute_parallel_plan s (ops # opss) = (if
are_all_operators_applicable s ops
∧ are_all_operator_effects_consistent ops
then execute_parallel_plan (execute_parallel_operator s ops) opss
else s)"
definition "are_operators_interfering op₁ op₂
≡ list_ex (λv. list_ex ((=) v) (delete_effects_of op₁)) (precondition_of op₂)
∨ list_ex (λv. list_ex ((=) v) (precondition_of op₁)) (delete_effects_of op₂)"
(* TODO rewrite as inductive predicate *)
primrec are_all_operators_non_interfering
:: "'variable strips_operator list ⇒ bool"
where "are_all_operators_non_interfering [] = True"
| "are_all_operators_non_interfering (op # ops)
= (list_all (λop'. ¬are_operators_interfering op op') ops
∧ are_all_operators_non_interfering ops)"
text ‹ Since traces mirror the execution semantics, the same is true for the definition of
parallel STRIPS plan traces. ›
fun trace_parallel_plan_strips
:: "'variable strips_state ⇒ 'variable strips_parallel_plan ⇒ 'variable strips_state list"
where "trace_parallel_plan_strips s [] = [s]"
| "trace_parallel_plan_strips s (ops # opss) = s # (if
are_all_operators_applicable s ops
∧ are_all_operator_effects_consistent ops
then trace_parallel_plan_strips (execute_parallel_operator s ops) opss
else [])"
text ‹ Similarly, the definition of parallel solutions requires that the parallel execution
semantics transforms the initial problem into the goal state of the problem and that every
operator of every parallel operator in the parallel plan is an operator that is defined in the
problem description. ›
definition is_parallel_solution_for_problem
where "is_parallel_solution_for_problem Π π
≡ (strips_problem.goal_of Π) ⊆⇩m execute_parallel_plan
(strips_problem.initial_of Π) π
∧ list_all (λops. list_all (λop.
ListMem op (strips_problem.operators_of Π)) ops) π"
(* TODO rename are_all_operators_applicable_in_set *)
lemma are_all_operators_applicable_set:
"are_all_operators_applicable s ops
⟷ (∀op ∈ set ops. ∀v ∈ set (precondition_of op). s v = Some True)"
unfolding are_all_operators_applicable_def STRIPS_Representation.is_operator_applicable_in_def list_all_iff
(*goal: ‹(∀op∈set ops. let p = precondition_of op in ∀v∈set p. s v = Some True) = (∀op∈set ops. ∀v∈set (precondition_of op). s v = Some True)›*)
by presburger
(* TODO rename are_all_operators_applicable_in_cons *)
lemma are_all_operators_applicable_cons:
assumes "are_all_operators_applicable s (op # ops)"
shows "is_operator_applicable_in s op"
and "are_all_operators_applicable s ops"
proof (-)
(*goals:
1. ‹is_operator_applicable_in s op›
2. ‹are_all_operators_applicable s ops›*)
from assms (*‹are_all_operators_applicable (s::'a ⇒ bool option) ((op::'a strips_operator) # (ops::'a strips_operator list))›*) have a: "list_all (λop. is_operator_applicable_in s op) (op # ops)"
unfolding are_all_operators_applicable_def is_operator_applicable_in_def STRIPS_Representation.is_operator_applicable_in_def
(*goal: ‹list_all (λop. Let (precondition_of op) (list_all (λv. s v = Some True))) (op # ops)›*)
by blast
then have "is_operator_applicable_in s op"
by fastforce
moreover {
from a (*‹list_all (is_operator_applicable_in s) (op # ops)›*) have "list_all (λop. is_operator_applicable_in s op) ops"
by simp
then have "are_all_operators_applicable s ops"
using are_all_operators_applicable_def (*‹are_all_operators_applicable ?s ?ops ≡ list_all (is_operator_applicable_in ?s) ?ops›*) is_operator_applicable_in_def (*‹is_operator_applicable_in ?s ?op ≡ Let (precondition_of ?op) (list_all (λv. ?s v = Some True))›*) STRIPS_Representation.is_operator_applicable_in_def (*‹is_operator_applicable_in (?s::?'variable ⇒ bool option) (?op::?'variable strips_operator) ≡ Let (precondition_of ?op) (list_all (λv::?'variable. ?s v = Some True))›*) by blast
}
ultimately show "is_operator_applicable_in s op" and "are_all_operators_applicable s ops"
apply -
(*goals:
1. ‹⟦is_operator_applicable_in s op; are_all_operators_applicable s ops⟧ ⟹ is_operator_applicable_in s op›
2. ‹⟦is_operator_applicable_in s op; are_all_operators_applicable s ops⟧ ⟹ are_all_operators_applicable s ops›
discuss goal 1*)
apply fast
(*discuss goal 2*)
apply fast
(*proven 2 subgoals*) .
qed
lemma are_operator_effects_consistent_set:
assumes "op₁ ∈ set ops"
and "op₂ ∈ set ops"
shows "are_operator_effects_consistent op₁ op₂
= (set (add_effects_of op₁) ∩ set (delete_effects_of op₂) = {}
∧ set (delete_effects_of op₁) ∩ set (add_effects_of op₂) = {})"
proof (-)
(*goal: ‹are_operator_effects_consistent op₁ op₂ = (set (add_effects_of op₁) ∩ set (delete_effects_of op₂) = {} ∧ set (delete_effects_of op₁) ∩ set (add_effects_of op₂) = {})›*)
have "(¬list_ex (λv. list_ex ((=) v) (delete_effects_of op₂)) (add_effects_of op₁))
= (set (add_effects_of op₁) ∩ set (delete_effects_of op₂) = {})"
using list_ex_intersection[of "delete_effects_of op₂" "add_effects_of op₁"] (*‹list_ex (λv. list_ex ((=) v) (delete_effects_of op₂)) (add_effects_of op₁) = (set (add_effects_of op₁) ∩ set (delete_effects_of op₂) ≠ {})›*) by meson
moreover have "(¬list_ex (λv. list_ex ((=) v) (add_effects_of op₂)) (delete_effects_of op₁))
= (set (delete_effects_of op₁) ∩ set (add_effects_of op₂) = {})"
using list_ex_intersection[of "add_effects_of op₂" "delete_effects_of op₁"] (*‹list_ex (λv::'a. list_ex ((=) v) (add_effects_of (op₂::('a, 'b) strips_operator_scheme))) (delete_effects_of (op₁::('a, 'b) strips_operator_scheme)) = (set (delete_effects_of op₁) ∩ set (add_effects_of op₂) ≠ {})›*) by meson
ultimately show "are_operator_effects_consistent op₁ op₂
= (set (add_effects_of op₁) ∩ set (delete_effects_of op₂) = {}
∧ set (delete_effects_of op₁) ∩ set (add_effects_of op₂) = {})"
unfolding are_operator_effects_consistent_def
(*goal: ‹(let add₁ = add_effects_of op₁; add₂ = add_effects_of op₂; del₁ = delete_effects_of op₁; del₂ = delete_effects_of op₂ in ¬ list_ex (λv. list_ex ((=) v) del₂) add₁ ∧ ¬ list_ex (λv. list_ex ((=) v) add₂) del₁) = (set (add_effects_of op₁) ∩ set (delete_effects_of op₂) = {} ∧ set (delete_effects_of op₁) ∩ set (add_effects_of op₂) = {})›*)
by presburger
qed
lemma are_all_operator_effects_consistent_set:
"are_all_operator_effects_consistent ops
⟷ (∀op₁ ∈ set ops. ∀op₂ ∈ set ops.
(set (add_effects_of op₁) ∩ set (delete_effects_of op₂) = {})
∧ (set (delete_effects_of op₁) ∩ set (add_effects_of op₂) = {}))"
proof (-)
(*goal: ‹are_all_operator_effects_consistent ops = (∀op₁∈set ops. ∀op₂∈set ops. set (add_effects_of op₁) ∩ set (delete_effects_of op₂) = {} ∧ set (delete_effects_of op₁) ∩ set (add_effects_of op₂) = {})›*)
{
fix op₁ and op₂
assume "op₁ ∈ set ops" and "op₂ ∈ set ops" (*‹(op₁::('a, 'b) strips_operator_scheme) ∈ set (ops::('a, 'b) strips_operator_scheme list)› ‹(op₂::('a, 'b) strips_operator_scheme) ∈ set (ops::('a, 'b) strips_operator_scheme list)›*)
hence "are_operator_effects_consistent op₁ op₂
= (set (add_effects_of op₁) ∩ set (delete_effects_of op₂) = {}
∧ set (delete_effects_of op₁) ∩ set (add_effects_of op₂) = {})"
using are_operator_effects_consistent_set[of op₁ ops op₂] (*‹⟦op₁ ∈ set ops; op₂ ∈ set ops⟧ ⟹ are_operator_effects_consistent op₁ op₂ = (set (add_effects_of op₁) ∩ set (delete_effects_of op₂) = {} ∧ set (delete_effects_of op₁) ∩ set (add_effects_of op₂) = {})›*) by fast
}
thus "?thesis"
(*goal: ‹are_all_operator_effects_consistent ops = (∀op₁∈set ops. ∀op₂∈set ops. set (add_effects_of op₁) ∩ set (delete_effects_of op₂) = {} ∧ set (delete_effects_of op₁) ∩ set (add_effects_of op₂) = {})›*)
unfolding are_all_operator_effects_consistent_def list_all_iff
(*goal: ‹(∀op∈set ops. Ball (set ops) (are_operator_effects_consistent op)) = (∀op₁∈set ops. ∀op₂∈set ops. set (add_effects_of op₁) ∩ set (delete_effects_of op₂) = {} ∧ set (delete_effects_of op₁) ∩ set (add_effects_of op₂) = {})›*)
by force
qed
lemma are_all_effects_consistent_tail:
assumes "are_all_operator_effects_consistent (op # ops)"
shows "are_all_operator_effects_consistent ops"
proof (-)
(*goal: ‹are_all_operator_effects_consistent ops›*)
from assms (*‹are_all_operator_effects_consistent (op # ops)›*) have a: "list_all (λop'. list_all (are_operator_effects_consistent op')
(Cons op ops)) (Cons op ops)"
unfolding are_all_operator_effects_consistent_def
(*goal: ‹list_all (λop'. list_all (are_operator_effects_consistent op') (op # ops)) (op # ops)›*)
by blast
then have b_1: "list_all (are_operator_effects_consistent op) (op # ops)" and b_2: "list_all (λop'. list_all (are_operator_effects_consistent op') (op # ops)) ops"
apply -
(*goals:
1. ‹list_all (λop'. list_all (are_operator_effects_consistent op') (op # ops)) (op # ops) ⟹ list_all (are_operator_effects_consistent op) (op # ops)›
2. ‹list_all (λop'. list_all (are_operator_effects_consistent op') (op # ops)) (op # ops) ⟹ list_all (λop'. list_all (are_operator_effects_consistent op') (op # ops)) ops›
discuss goal 1*)
apply force
(*discuss goal 2*)
apply force
(*proven 2 subgoals*) .
then have "list_all (are_operator_effects_consistent op) ops"
by simp
moreover {
{
fix z
assume "z ∈ set (Cons op ops)" and "list_all (are_operator_effects_consistent z) (op # ops)" (*‹(z::('a, 'b) strips_operator_scheme) ∈ set ((op::('a, 'b) strips_operator_scheme) # (ops::('a, 'b) strips_operator_scheme list))› ‹list_all (are_operator_effects_consistent (z::('a, 'b) strips_operator_scheme)) ((op::('a, 'b) strips_operator_scheme) # (ops::('a, 'b) strips_operator_scheme list))›*)
then have "list_all (are_operator_effects_consistent z) ops"
by auto
}
then have "list_all (λop'. list_all (are_operator_effects_consistent op') ops) ops"
using list.pred_mono_strong[of "(λop'. list_all (are_operator_effects_consistent op') (op # ops))" "Cons op ops" "(λop'. list_all (are_operator_effects_consistent op') ops)"] (*‹⟦list_all (λop'. list_all (are_operator_effects_consistent op') (op # ops)) (op # ops); ⋀z. ⟦z ∈ set (op # ops); list_all (are_operator_effects_consistent z) (op # ops)⟧ ⟹ list_all (are_operator_effects_consistent z) ops⟧ ⟹ list_all (λop'. list_all (are_operator_effects_consistent op') ops) (op # ops)›*) a (*‹list_all (λop'. list_all (are_operator_effects_consistent op') (op # ops)) (op # ops)›*) by fastforce
}
ultimately have "list_all (are_operator_effects_consistent op) ops
∧ list_all (λop'. list_all (are_operator_effects_consistent op') ops) ops"
by blast
then show "?thesis"
(*goal: ‹are_all_operator_effects_consistent ops›*)
using are_all_operator_effects_consistent_def (*‹are_all_operator_effects_consistent ?ops ≡ list_all (λop. list_all (are_operator_effects_consistent op) ?ops) ?ops›*) by fast
qed
lemma are_all_operators_non_interfering_tail:
assumes "are_all_operators_non_interfering (op # ops)"
shows "are_all_operators_non_interfering ops"
using assms (*‹are_all_operators_non_interfering (op # ops)›*) unfolding are_all_operators_non_interfering_def
(*goal: ‹rec_list True (λop ops. (∧) (list_all (λop'. ¬ are_operators_interfering op op') ops)) ops›*)
by simp
lemma are_operators_interfering_symmetric:
assumes "are_operators_interfering op₁ op₂"
shows "are_operators_interfering op₂ op₁"
using assms (*‹are_operators_interfering op₁ op₂›*) unfolding are_operators_interfering_def list_ex_iff
(*goal: ‹(∃v∈set (precondition_of op₁). Bex (set (delete_effects_of op₂)) ((=) v)) ∨ (∃v∈set (delete_effects_of op₁). Bex (set (precondition_of op₂)) ((=) v))›*)
by fast<close>
lemma are_all_operators_non_interfering_set_contains_no_distinct_interfering_operator_pairs:
assumes "are_all_operators_non_interfering ops"
and "are_operators_interfering op₁ op₂"
and "op₁ ≠ op₂"
shows "op₁ ∉ set ops ∨ op₂ ∉ set ops"
using assms
proof (induction ops)
case (Cons op ops)
thm Cons.IH[OF _ Cons.prems(2, 3)]
have nb₁: "∀op' ∈ set ops. ¬are_operators_interfering op op'"
and nb₂: "are_all_operators_non_interfering ops"
using Cons.prems(1)
unfolding are_all_operators_non_interfering.simps(2) list_all_iff
by blast+
then consider (A) "op = op₁"
| (B) "op = op₂"
| (C) "op ≠ op₁ ∧ op ≠ op₂"
by blast
thus ?case
proof (cases)
case A
{
assume "op₂ ∈ set (op # ops)"
then have "op₂ ∈ set ops"
using Cons.prems(3) A
by force
then have "¬are_operators_interfering op₁ op₂"
using nb₁ A
by fastforce
hence False
using Cons.prems(2)..
}
thus ?thesis
by blast
next
case B
{
assume "op₁ ∈ set (op # ops)"
then have "op₁ ∈ set ops"
using Cons.prems(3) B
by force
then have "¬are_operators_interfering op₁ op₂"
using nb₁ B are_operators_interfering_symmetric
by blast
hence False
using Cons.prems(2)..
}
thus ?thesis
by blast
next
case C
thus ?thesis
using Cons.IH[OF nb₂ Cons.prems(2, 3)]
by force
qed
qed simp
(* TODO The recurring ‹list_all ↝ ∀› transformations could be refactored into a general
lemma.
TODO refactor (also used in lemma ‹execute_serial_plan_split_i›). *)
lemma execute_parallel_plan_precondition_cons_i:
fixes s :: "('variable, bool) state"
assumes "¬are_operators_interfering op op'"
and "is_operator_applicable_in s op"
and "is_operator_applicable_in s op'"
shows "is_operator_applicable_in (s ++ map_of (effect_to_assignments op)) op'"
proof (-)
(*goal: ‹is_operator_applicable_in (s ++ map_of (effect_to_assignments op)) op'›*)
let ?s' = "s ++ map_of (effect_to_assignments op)"
{
have a: "?s' = s ⪢ op"
by (simp add: execute_operator_def (*‹?s ⪢ ?op ≡ ?s ++ map_of (effect_to_assignments ?op)›*))
then have "⋀v. v ∈ set (add_effects_of op) ⟹ ?s' v = Some True" and "⋀v. v ∉ set (add_effects_of op) ∧ v ∈ set (delete_effects_of op) ⟹ ?s' v = Some False" and "⋀v. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op) ⟹ ?s' v = s v"
using operator_effect__strips (*‹⟦?s' = ?s ⪢ ?op; ?v ∈ set (add_effects_of ?op)⟧ ⟹ ?s' ?v = Some True› ‹⟦?s' = ?s ⪢ ?op; ?v ∉ set (add_effects_of ?op) ∧ ?v ∈ set (delete_effects_of ?op)⟧ ⟹ ?s' ?v = Some False› ‹⟦(?s'::?'a ⇒ bool option) = (?s::?'a ⇒ bool option) ⪢ (?op::?'a strips_operator); (?v::?'a) ∉ set (add_effects_of ?op) ∧ ?v ∉ set (delete_effects_of ?op)⟧ ⟹ ?s' ?v = ?s ?v›*) by ((metis)+)
}
note a = this (*‹?v ∈ set (add_effects_of op) ⟹ (s ++ map_of (effect_to_assignments op)) ?v = Some True› ‹?v ∉ set (add_effects_of op) ∧ ?v ∈ set (delete_effects_of op) ⟹ (s ++ map_of (effect_to_assignments op)) ?v = Some False› ‹?v ∉ set (add_effects_of op) ∧ ?v ∉ set (delete_effects_of op) ⟹ (s ++ map_of (effect_to_assignments op)) ?v = s ?v›*)
{
fix v
assume "α": "v ∈ set (precondition_of op')" (*‹(v::'variable) ∈ set (precondition_of (op'::'variable strips_operator))›*)
{
fix v
have "¬list_ex ((=) v) (delete_effects_of op)
= list_all (λv'. ¬v = v') (delete_effects_of op)"
using not_list_ex_equals_list_all_not[where P = "(=) v" and xs = "delete_effects_of op"] (*‹(¬ list_ex ((=) (v::'variable)) (delete_effects_of (op::'variable strips_operator))) = list_all ((≠) v) (delete_effects_of op)›*) by blast
}
moreover {
from assms(1) (*‹¬ are_operators_interfering op op'›*) have "¬list_ex (λv. list_ex ((=) v) (delete_effects_of op)) (precondition_of op')"
unfolding are_operators_interfering_def
(*goal: ‹¬ list_ex (λv. list_ex ((=) v) (delete_effects_of op)) (precondition_of op')›*)
by blast
then have "list_all (λv. ¬list_ex ((=) v) (delete_effects_of op)) (precondition_of op')"
using not_list_ex_equals_list_all_not[where P = "λv. list_ex ((=) v) (delete_effects_of op)" and xs = "precondition_of op'"] (*‹(¬ list_ex (λv. list_ex ((=) v) (delete_effects_of op)) (precondition_of op')) = list_all (λx. ¬ list_ex ((=) x) (delete_effects_of op)) (precondition_of op')›*) by blast
}
ultimately have "β": "list_all (λv. list_all (λv'. ¬v = v') (delete_effects_of op)) (precondition_of op')"
by presburger
moreover {
fix v
have "list_all (λv'. ¬v = v') (delete_effects_of op)
= (∀v' ∈ set (delete_effects_of op). ¬v = v')"
using list_all_iff[where P = "λv'. ¬v = v'" and x = "delete_effects_of op"] (*‹list_all ((≠) (v::'variable)) (delete_effects_of (op::'variable strips_operator)) = (∀v'::'variable∈set (delete_effects_of op). v ≠ v')›*) .
}
ultimately have "∀v ∈ set (precondition_of op'). ∀v' ∈ set (delete_effects_of op). ¬v = v'"
using "β" (*‹list_all (λv. list_all ((≠) v) (delete_effects_of op)) (precondition_of op')›*) list_all_iff[where P = "λv. list_all (λv'. ¬v = v') (delete_effects_of op)" and x = "precondition_of op'"] (*‹list_all (λv. list_all ((≠) v) (delete_effects_of op)) (precondition_of op') = (∀v∈set (precondition_of op'). list_all ((≠) v) (delete_effects_of op))›*) by presburger
then have "v ∉ set (delete_effects_of op)"
using "α" (*‹v ∈ set (precondition_of op')›*) by fast
}
note b = this (*‹?v2 ∈ set (precondition_of op') ⟹ ?v2 ∉ set (delete_effects_of op)›*)
{
fix v
assume a: "v ∈ set (precondition_of op')" (*‹(v::'variable) ∈ set (precondition_of (op'::'variable strips_operator))›*)
have "list_all (λv. s v = Some True) (precondition_of op')"
using assms(3) (*‹is_operator_applicable_in s op'›*) unfolding is_operator_applicable_in_def STRIPS_Representation.is_operator_applicable_in_def
(*goal: ‹list_all (λv. s v = Some True) (precondition_of op')›*)
by presburger
then have "∀v ∈ set (precondition_of op'). s v = Some True"
using list_all_iff[where P = "λv. s v = Some True" and x = "precondition_of op'"] (*‹list_all (λv::'variable. (s::'variable ⇒ bool option) v = Some True) (precondition_of (op'::'variable strips_operator)) = (∀v::'variable∈set (precondition_of op'). s v = Some True)›*) by blast
then have "s v = Some True"
using a (*‹(v::'variable) ∈ set (precondition_of (op'::'variable strips_operator))›*) by blast
}
note c = this (*‹?v2 ∈ set (precondition_of op') ⟹ s ?v2 = Some True›*)
{
fix v
assume d: "v ∈ set (precondition_of op')" (*‹(v::'variable) ∈ set (precondition_of (op'::'variable strips_operator))›*)
then have "?s' v = Some True"
proof (cases "v ∈ set (add_effects_of op)")
(*goals:
1. ‹⟦v ∈ set (precondition_of op'); v ∈ set (add_effects_of op)⟧ ⟹ (s ++ map_of (effect_to_assignments op)) v = Some True›
2. ‹⟦v ∈ set (precondition_of op'); v ∉ set (add_effects_of op)⟧ ⟹ (s ++ map_of (effect_to_assignments op)) v = Some True›*)
case True (*‹(v::'variable) ∈ set (add_effects_of (op::'variable strips_operator))›*)
then show "?thesis"
(*goal: ‹(s ++ map_of (effect_to_assignments op)) v = Some True›*)
using a (*‹?v ∈ set (add_effects_of op) ⟹ (s ++ map_of (effect_to_assignments op)) ?v = Some True› ‹?v ∉ set (add_effects_of op) ∧ ?v ∈ set (delete_effects_of op) ⟹ (s ++ map_of (effect_to_assignments op)) ?v = Some False› ‹?v ∉ set (add_effects_of op) ∧ ?v ∉ set (delete_effects_of op) ⟹ (s ++ map_of (effect_to_assignments op)) ?v = s ?v›*) by blast
next
(*goal: ‹⟦v ∈ set (precondition_of op'); v ∉ set (add_effects_of op)⟧ ⟹ (s ++ map_of (effect_to_assignments op)) v = Some True›*)
case e: False (*‹v ∉ set (add_effects_of op)›*)
then show "?thesis"
(*goal: ‹(s ++ map_of (effect_to_assignments op)) v = Some True›*)
proof (cases "v ∈ set (delete_effects_of op)")
(*goals:
1. ‹⟦v ∉ set (add_effects_of op); v ∈ set (delete_effects_of op)⟧ ⟹ (s ++ map_of (effect_to_assignments op)) v = Some True›
2. ‹⟦v ∉ set (add_effects_of op); v ∉ set (delete_effects_of op)⟧ ⟹ (s ++ map_of (effect_to_assignments op)) v = Some True›*)
case True (*‹(v::'variable) ∈ set (delete_effects_of (op::'variable strips_operator))›*)
then show "?thesis"
(*goal: ‹(s ++ map_of (effect_to_assignments op)) v = Some True›*)
using assms(1) (*‹¬ are_operators_interfering op op'›*) b (*‹?v2 ∈ set (precondition_of op') ⟹ ?v2 ∉ set (delete_effects_of op)›*) d (*‹v ∈ set (precondition_of op')›*) by fast
next
(*goal: ‹⟦v ∉ set (add_effects_of op); v ∉ set (delete_effects_of op)⟧ ⟹ (s ++ map_of (effect_to_assignments op)) v = Some True›*)
case False (*‹v ∉ set (delete_effects_of op)›*)
then have "?s' v = s v"
using a (*‹?v ∈ set (add_effects_of op) ⟹ (s ++ map_of (effect_to_assignments op)) ?v = Some True› ‹?v ∉ set (add_effects_of op) ∧ ?v ∈ set (delete_effects_of op) ⟹ (s ++ map_of (effect_to_assignments op)) ?v = Some False› ‹?v ∉ set (add_effects_of op) ∧ ?v ∉ set (delete_effects_of op) ⟹ (s ++ map_of (effect_to_assignments op)) ?v = s ?v›*) e (*‹v ∉ set (add_effects_of op)›*) by blast
then show "?thesis"
(*goal: ‹((s::'variable ⇒ bool option) ++ map_of (effect_to_assignments (op::'variable strips_operator))) (v::'variable) = Some True›*)
using c (*‹?v2 ∈ set (precondition_of op') ⟹ s ?v2 = Some True›*) d (*‹v ∈ set (precondition_of op')›*) by presburger
qed
qed
}
then have "list_all (λv. ?s' v = Some True) (precondition_of op')"
using list_all_iff[where P = "λv. ?s' v = Some True" and x = "precondition_of op'"] (*‹list_all (λv. (s ++ map_of (effect_to_assignments op)) v = Some True) (precondition_of op') = (∀v∈set (precondition_of op'). (s ++ map_of (effect_to_assignments op)) v = Some True)›*) by blast
then show "?thesis"
(*goal: ‹is_operator_applicable_in (s ++ map_of (effect_to_assignments op)) op'›*)
unfolding is_operator_applicable_in_def STRIPS_Representation.is_operator_applicable_in_def
(*goal: ‹Let (precondition_of op') (list_all (λv. (s ++ map_of (effect_to_assignments op)) v = Some True))›*)
by auto
qed<close>
lemma execute_parallel_plan_precondition_cons:
fixes a :: "'variable strips_operator"
assumes "are_all_operators_applicable s (a # ops)"
and "are_all_operator_effects_consistent (a # ops)"
and "are_all_operators_non_interfering (a # ops)"
shows "are_all_operators_applicable (s ++ map_of (effect_to_assignments a)) ops"
and "are_all_operator_effects_consistent ops"
and "are_all_operators_non_interfering ops"
using are_all_effects_consistent_tail[OF assms ( 2 )] (*‹are_all_operator_effects_consistent (ops::'variable strips_operator list)›*) are_all_operators_non_interfering_tail[OF assms ( 3 )] (*‹are_all_operators_non_interfering (ops::'variable strips_operator list)›*) proof (-)
(*goals:
1. ‹⟦are_all_operator_effects_consistent ops; are_all_operators_non_interfering ops⟧ ⟹ are_all_operators_applicable (s ++ map_of (effect_to_assignments a)) ops›
2. ‹⟦are_all_operator_effects_consistent ops; are_all_operators_non_interfering ops⟧ ⟹ are_all_operator_effects_consistent ops›
3. ‹⟦are_all_operator_effects_consistent ops; are_all_operators_non_interfering ops⟧ ⟹ are_all_operators_non_interfering ops›*)
let ?s' = "s ++ map_of (effect_to_assignments a)"
have "nb₁": "∀op ∈ set (a # ops). is_operator_applicable_in s op"
using assms(1) (*‹are_all_operators_applicable s (a # ops)›*) are_all_operators_applicable_set (*‹are_all_operators_applicable (?s::?'a::type ⇒ bool option) (?ops::?'a strips_operator list) = (∀op::?'a strips_operator∈set ?ops. ∀v::?'a::type∈set (precondition_of op). ?s v = Some True)›*) unfolding are_all_operators_applicable_def is_operator_applicable_in_def STRIPS_Representation.is_operator_applicable_in_def list_all_iff
(*goal: ‹∀op∈set (a # ops). let p = precondition_of op in ∀v∈set p. s v = Some True›*)
by blast
have "nb₂": "∀op ∈ set ops. ¬are_operators_interfering a op"
using assms(3) (*‹are_all_operators_non_interfering (a # ops)›*) unfolding are_all_operators_non_interfering_def list_all_iff
(*goal: ‹∀op∈set ops. ¬ are_operators_interfering a op›*)
by simp
have "nb₃": "is_operator_applicable_in s a"
using assms(1) (*‹are_all_operators_applicable (s::'variable ⇒ bool option) ((a::'variable strips_operator) # (ops::'variable strips_operator list))›*) are_all_operators_applicable_set (*‹are_all_operators_applicable (?s::?'a ⇒ bool option) (?ops::?'a strips_operator list) = (∀op::?'a strips_operator∈set ?ops. ∀v::?'a∈set (precondition_of op). ?s v = Some True)›*) unfolding are_all_operators_applicable_def is_operator_applicable_in_def STRIPS_Representation.is_operator_applicable_in_def list_all_iff
(*goal: ‹let p = precondition_of a in ∀v∈set p. s v = Some True›*)
by force
{
fix op
assume op_in_ops: "op ∈ set ops" (*‹(op::'variable strips_operator) ∈ set (ops::'variable strips_operator list)›*)
hence "is_operator_applicable_in ?s' op"
using execute_parallel_plan_precondition_cons_i[of a op] (*‹⟦¬ are_operators_interfering (a::'variable strips_operator) (op::'variable strips_operator); is_operator_applicable_in (?s::'variable ⇒ bool option) a; is_operator_applicable_in ?s op⟧ ⟹ is_operator_applicable_in (?s ++ map_of (effect_to_assignments a)) op›*) "nb₁" (*‹∀op::'variable strips_operator∈set ((a::'variable strips_operator) # (ops::'variable strips_operator list)). is_operator_applicable_in (s::'variable ⇒ bool option) op›*) "nb₂" (*‹∀op::'variable strips_operator∈set (ops::'variable strips_operator list). ¬ are_operators_interfering (a::'variable strips_operator) op›*) "nb₃" (*‹is_operator_applicable_in s a›*) by force
}
then show "are_all_operators_applicable ?s' ops"
unfolding are_all_operators_applicable_def list_all_iff is_operator_applicable_in_def
(*goal: ‹∀op::'variable strips_operator∈set (ops::'variable strips_operator list). let p::'variable::type list = precondition_of op in ∀v::'variable::type∈set p. ((s::'variable::type ⇒ bool option) ++ map_of (effect_to_assignments (a::'variable strips_operator))) v = Some True›*)
by blast
qed
lemma execute_parallel_operator_cons[simp]:
"execute_parallel_operator s (op # ops)
= execute_parallel_operator (s ++ map_of (effect_to_assignments op)) ops"
unfolding execute_parallel_operator_def
(*goal: ‹foldl (++) s (map (map_of ∘ effect_to_assignments) (op # ops)) = foldl (++) (s ++ map_of (effect_to_assignments op)) (map (map_of ∘ effect_to_assignments) ops)›*)
by simp
lemma execute_parallel_operator_cons_equals:
assumes "are_all_operators_applicable s (a # ops)"
and "are_all_operator_effects_consistent (a # ops)"
and "are_all_operators_non_interfering (a # ops)"
shows "execute_parallel_operator s (a # ops)
= execute_parallel_operator (s ++ map_of (effect_to_assignments a)) ops"
proof (-)
(*goal: ‹execute_parallel_operator s (a # ops) = execute_parallel_operator (s ++ map_of (effect_to_assignments a)) ops›*)
let ?s' = "s ++ map_of (effect_to_assignments a)"
{
from assms(1,2) (*‹are_all_operators_applicable s (a # ops)› ‹are_all_operator_effects_consistent (a # ops)›*) have "execute_parallel_operator s (Cons a ops)
= foldl (++) s (map (map_of ∘ effect_to_assignments) (Cons a ops))"
unfolding execute_parallel_operator_def
(*goal: ‹foldl (++) s (map (map_of ∘ effect_to_assignments) (a # ops)) = foldl (++) s (map (map_of ∘ effect_to_assignments) (a # ops))›*)
by presburger
also (*calculation: ‹execute_parallel_operator (s::'a ⇒ bool option) ((a::'a strips_operator) # (ops::'a strips_operator list)) = foldl (++) s (map (map_of ∘ effect_to_assignments) (a # ops))›*) have "… = foldl (++) (?s')
(map (map_of ∘ effect_to_assignments) ops)"
by auto
finally (*calculation: ‹execute_parallel_operator s (a # ops) = foldl (++) (s ++ map_of (effect_to_assignments a)) (map (map_of ∘ effect_to_assignments) ops)›*) have "execute_parallel_operator s (Cons a ops)
= foldl (++) (?s')
(map (map_of ∘ effect_to_assignments) ops)"
using execute_parallel_operator_def (*‹execute_parallel_operator ?s ?ops ≡ foldl (++) ?s (map (map_of ∘ effect_to_assignments) ?ops)›*) by blast
}
moreover have "execute_parallel_operator ?s' ops
= foldl (++) (s ++ (map_of ∘ effect_to_assignments) a)
(map (map_of ∘ effect_to_assignments) ops)"
by (simp add: execute_parallel_operator_def (*‹execute_parallel_operator ?s ?ops ≡ foldl (++) ?s (map (map_of ∘ effect_to_assignments) ?ops)›*))
ultimately show "?thesis"
(*goal: ‹execute_parallel_operator s (a # ops) = execute_parallel_operator (s ++ map_of (effect_to_assignments a)) ops›*)
by force
qed<close>
corollary execute_parallel_operator_cons_equals_corollary:
assumes "are_all_operators_applicable s (a # ops)"
shows "execute_parallel_operator s (a # ops)
= execute_parallel_operator (s ⪢ a) ops"
proof (-)
(*goal: ‹execute_parallel_operator (s::'a ⇒ bool option) ((a::'a strips_operator) # (ops::'a strips_operator list)) = execute_parallel_operator (s ⪢ a) ops›*)
let ?s' = "s ++ map_of (effect_to_assignments a)"
from assms (*‹are_all_operators_applicable s (a # ops)›*) have "execute_parallel_operator s (a # ops)
= execute_parallel_operator (s ++ map_of (effect_to_assignments a)) ops"
using execute_parallel_operator_cons_equals (*‹⟦are_all_operators_applicable ?s (?a # ?ops); are_all_operator_effects_consistent (?a # ?ops); are_all_operators_non_interfering (?a # ?ops)⟧ ⟹ execute_parallel_operator ?s (?a # ?ops) = execute_parallel_operator (?s ++ map_of (effect_to_assignments ?a)) ?ops›*) by simp
moreover have "?s' = s ⪢ a"
unfolding execute_operator_def
(*goal: ‹s ++ map_of (effect_to_assignments a) = s ++ map_of (effect_to_assignments a)›*)
by simp
ultimately show "?thesis"
(*goal: ‹execute_parallel_operator s (a # ops) = execute_parallel_operator (s ⪢ a) ops›*)
by argo
qed
(* TODO duplicate? *)
lemma effect_to_assignments_simp[simp]: "effect_to_assignments op
= map (λv. (v, True)) (add_effects_of op) @ map (λv. (v, False)) (delete_effects_of op)"
by (simp add: effect_to_assignments_i (*‹?as = effect_to_assignments ?op ⟹ ?as = map (λv. (v, True)) (add_effects_of ?op) @ map (λv. (v, False)) (delete_effects_of ?op)›*))
lemma effect_to_assignments_set_is[simp]:
"set (effect_to_assignments op) = { ((v, a), True) | v a. (v, a) ∈ set (add_effects_of op) }
∪ { ((v, a), False) | v a. (v, a) ∈ set (delete_effects_of op) }"
proof (-)
(*goal: ‹set (effect_to_assignments op) = {((v, a), True) |v a. (v, a) ∈ set (add_effects_of op)} ∪ {((v, a), False) |v a. (v, a) ∈ set (delete_effects_of op)}›*)
obtain as where "effect__strips op = as" and "as = map (λv. (v, True)) (add_effects_of op)
@ map (λv. (v, False)) (delete_effects_of op)"
(*goal: ‹(⋀as. ⟦effect__strips op = as; as = map (λv. (v, True)) (add_effects_of op) @ map (λv. (v, False)) (delete_effects_of op)⟧ ⟹ thesis) ⟹ thesis›*)
unfolding effect__strips_def
(*goal: ‹(⋀as. ⟦map (λv. (v, True)) (add_effects_of op) @ map (λv. (v, False)) (delete_effects_of op) = as; as = map (λv. (v, True)) (add_effects_of op) @ map (λv. (v, False)) (delete_effects_of op)⟧ ⟹ thesis) ⟹ thesis›*)
by blast
moreover have "as
= map (λv. (v, True)) (add_effects_of op) @ map (λv. (v, False)) (delete_effects_of op)"
using calculation(2) (*‹as = map (λv. (v, True)) (add_effects_of op) @ map (λv. (v, False)) (delete_effects_of op)›*) unfolding map_append map_map comp_apply
(*goal: ‹as = map (λv. (v, True)) (add_effects_of op) @ map (λv. (v, False)) (delete_effects_of op)›*)
by auto
moreover have "effect_to_assignments op = as"
unfolding effect_to_assignments_def calculation(1,2)
(*goal: ‹map (λv::'a::type × 'b::type. (v, True)) (add_effects_of (op::('a × 'b) strips_operator)) @ map (λv::'a::type × 'b::type. (v, False)) (delete_effects_of op) = map (λv::'a::type × 'b::type. (v, True)) (add_effects_of op) @ map (λv::'a::type × 'b::type. (v, False)) (delete_effects_of op)›*)
by auto
ultimately show "?thesis"
(*goal: ‹set (effect_to_assignments op) = {((v, a), True) |v a. (v, a) ∈ set (add_effects_of op)} ∪ {((v, a), False) |v a. (v, a) ∈ set (delete_effects_of op)}›*)
unfolding set_map
(*goal: ‹set (effect_to_assignments (op::('a × 'b) strips_operator)) = {((v, a), True) |(v::'a::type) a::'b::type. (v, a) ∈ set (add_effects_of op)} ∪ {((v, a), False) |(v::'a::type) a::'b::type. (v, a) ∈ set (delete_effects_of op)}›*)
by auto
qed
corollary effect_to_assignments_construction_from_function_graph:
assumes "set (add_effects_of op) ∩ set (delete_effects_of op) = {}"
shows "effect_to_assignments op = map
(λv. (v, if ListMem v (add_effects_of op) then True else False))
(add_effects_of op @ delete_effects_of op)"
and "effect_to_assignments op = map
(λv. (v, if ListMem v (delete_effects_of op) then False else True))
(add_effects_of op @ delete_effects_of op)"
proof (-)
(*goals:
1. ‹effect_to_assignments op = map (λv. (v, if ListMem v (add_effects_of op) then True else False)) (add_effects_of op @ delete_effects_of op)›
2. ‹effect_to_assignments op = map (λv. (v, if ListMem v (delete_effects_of op) then False else True)) (add_effects_of op @ delete_effects_of op)›*)
let ?f = "λv. (v, if ListMem v (add_effects_of op) then True else False)" and ?g = "λv. (v, if ListMem v (delete_effects_of op) then False else True)"
{
have "map ?f (add_effects_of op @ delete_effects_of op)
= map ?f (add_effects_of op) @ map ?f (delete_effects_of op)"
using map_append (*‹map ?f (?xs @ ?ys) = map ?f ?xs @ map ?f ?ys›*) by fast
hence "effect_to_assignments op = map ?f (add_effects_of op @ delete_effects_of op)"
using ListMem_iff (*‹ListMem ?x ?xs = (?x ∈ set ?xs)›*) assms (*‹set (add_effects_of (op::'a strips_operator)) ∩ set (delete_effects_of op) = {}›*) by fastforce
}
moreover {
have "map ?g (add_effects_of op @ delete_effects_of op)
= map ?g (add_effects_of op) @ map ?g (delete_effects_of op)"
using map_append (*‹map (?f::?'b::type ⇒ ?'a::type) ((?xs::?'b::type list) @ (?ys::?'b::type list)) = map ?f ?xs @ map ?f ?ys›*) by fast
hence "effect_to_assignments op = map ?g (add_effects_of op @ delete_effects_of op)"
using ListMem_iff (*‹ListMem ?x ?xs = (?x ∈ set ?xs)›*) assms (*‹set (add_effects_of op) ∩ set (delete_effects_of op) = {}›*) by fastforce
}
ultimately show "effect_to_assignments op = map
(λv. (v, if ListMem v (add_effects_of op) then True else False))
(add_effects_of op @ delete_effects_of op)" and "effect_to_assignments op = map
(λv. (v, if ListMem v (delete_effects_of op) then False else True))
(add_effects_of op @ delete_effects_of op)"
apply -
(*goals:
1. ‹⟦effect_to_assignments op = map (λv. (v, if ListMem v (add_effects_of op) then True else False)) (add_effects_of op @ delete_effects_of op); effect_to_assignments op = map (λv. (v, if ListMem v (delete_effects_of op) then False else True)) (add_effects_of op @ delete_effects_of op)⟧ ⟹ effect_to_assignments op = map (λv. (v, if ListMem v (add_effects_of op) then True else False)) (add_effects_of op @ delete_effects_of op)›
2. ‹⟦effect_to_assignments op = map (λv. (v, if ListMem v (add_effects_of op) then True else False)) (add_effects_of op @ delete_effects_of op); effect_to_assignments op = map (λv. (v, if ListMem v (delete_effects_of op) then False else True)) (add_effects_of op @ delete_effects_of op)⟧ ⟹ effect_to_assignments op = map (λv. (v, if ListMem v (delete_effects_of op) then False else True)) (add_effects_of op @ delete_effects_of op)›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
qed
corollary map_of_effect_to_assignments_is_none_if:
assumes "¬v ∈ set (add_effects_of op)"
and "¬v ∈ set (delete_effects_of op)"
shows "map_of (effect_to_assignments op) v = None"
proof (-)
(*goal: ‹map_of (effect_to_assignments op) v = None›*)
let ?l = "effect_to_assignments op"
{
have "set ?l = { (v, True) | v. v ∈ set (add_effects_of op) }
∪ { (v, False) | v. v ∈ set (delete_effects_of op)}"
by auto
then have "fst ` set ?l
= (fst ` {(v, True) | v. v ∈ set (add_effects_of op)})
∪ (fst ` {(v, False) | v. v ∈ set (delete_effects_of op)})"
using image_Un[of fst "{(v, True) | v. v ∈ set (add_effects_of op)}" "{(v, False) | v. v ∈ set (delete_effects_of op)}"] (*‹fst ` ({(v, True) |v. v ∈ set (add_effects_of op)} ∪ {(v, False) |v. v ∈ set (delete_effects_of op)}) = fst ` {(v, True) |v. v ∈ set (add_effects_of op)} ∪ fst ` {(v, False) |v. v ∈ set (delete_effects_of op)}›*) by presburger
also (*calculation: ‹fst ` set (effect_to_assignments (op::'a strips_operator)) = fst ` {(v, True) |v::'a. v ∈ set (add_effects_of op)} ∪ fst ` {(v, False) |v::'a. v ∈ set (delete_effects_of op)}›*) have "… = (fst ` (λv. (v, True)) ` set (add_effects_of op))
∪ (fst ` (λv. (v, False)) ` set (delete_effects_of op))"
using setcompr_eq_image[of "λv. (v, True)" "λv. v ∈ set (add_effects_of op)"] (*‹{(x, True) |x. x ∈ set (add_effects_of op)} = (λv. (v, True)) ` {x. x ∈ set (add_effects_of op)}›*) setcompr_eq_image[of "λv. (v, False)" "λv. v ∈ set (delete_effects_of op)"] (*‹{(x, False) |x. x ∈ set (delete_effects_of op)} = (λv. (v, False)) ` {x. x ∈ set (delete_effects_of op)}›*) by simp
also (*calculation: ‹fst ` set (effect_to_assignments (op::'a strips_operator)) = fst ` (λv::'a::type. (v, True)) ` set (add_effects_of op) ∪ fst ` (λv::'a::type. (v, False)) ` set (delete_effects_of op)›*) have "… = id ` set (add_effects_of op) ∪ id ` set (delete_effects_of op)"
by force
finally (*calculation: ‹fst ` set (effect_to_assignments op) = id ` set (add_effects_of op) ∪ id ` set (delete_effects_of op)›*) have "fst ` set ?l = set (add_effects_of op) ∪ set (delete_effects_of op)"
by auto
hence "v ∉ fst ` set ?l"
using assms(1,2) (*‹v ∉ set (add_effects_of op)› ‹v ∉ set (delete_effects_of op)›*) by blast
}
thus "?thesis"
(*goal: ‹map_of (effect_to_assignments (op::'a strips_operator)) (v::'a) = None›*)
using map_of_eq_None_iff[of ?l v] (*‹(map_of (effect_to_assignments op) v = None) = (v ∉ fst ` set (effect_to_assignments op))›*) by blast
qed
lemma execute_parallel_operator_positive_effect_if_i:
assumes "are_all_operators_applicable s ops"
and "are_all_operator_effects_consistent ops"
and "op ∈ set ops"
and "v ∈ set (add_effects_of op)"
shows "map_of (effect_to_assignments op) v = Some True"
proof (-)
(*goal: ‹map_of (effect_to_assignments op) v = Some True›*)
let ?f = "λx. if ListMem x (add_effects_of op) then True else False" and ?l' = " map (λv. (v, if ListMem v (add_effects_of op) then True else False))
(add_effects_of op @ delete_effects_of op)"
have "set (add_effects_of op) ≠ {}"
using assms(4) (*‹(v::'a::type) ∈ set (add_effects_of (op::'a strips_operator))›*) by fastforce
moreover {
have "set (add_effects_of op) ∩ set (delete_effects_of op) = {}"
using are_all_operator_effects_consistent_set (*‹are_all_operator_effects_consistent ?ops = (∀op₁∈set ?ops. ∀op₂∈set ?ops. set (add_effects_of op₁) ∩ set (delete_effects_of op₂) = {} ∧ set (delete_effects_of op₁) ∩ set (add_effects_of op₂) = {})›*) assms(2,3) (*‹are_all_operator_effects_consistent ops› ‹op ∈ set ops›*) by fast
moreover have "effect_to_assignments op = ?l'"
using effect_to_assignments_construction_from_function_graph(1) (*‹set (add_effects_of ?op) ∩ set (delete_effects_of ?op) = {} ⟹ effect_to_assignments ?op = map (λv. (v, if ListMem v (add_effects_of ?op) then True else False)) (add_effects_of ?op @ delete_effects_of ?op)›*) calculation (*‹set (add_effects_of op) ∩ set (delete_effects_of op) = {}›*) by fast
ultimately have "map_of (effect_to_assignments op) = map_of ?l'"
by argo
}
ultimately have "map_of (effect_to_assignments op) v = Some (?f v)"
using Map_Supplement.map_of_from_function_graph_is_some_if[of _ _ "?f", OF _ assms ( 4 )] (*‹set (add_effects_of op) ≠ {} ⟹ map_of (map (λx. (x, if ListMem x (add_effects_of op) then True else False)) (add_effects_of op)) v = Some (if ListMem v (add_effects_of op) then True else False)›*) by simp
thus "?thesis"
(*goal: ‹map_of (effect_to_assignments op) v = Some True›*)
using ListMem_iff (*‹ListMem ?x ?xs = (?x ∈ set ?xs)›*) assms(4) (*‹v ∈ set (add_effects_of op)›*) by metis
qed
lemma execute_parallel_operator_positive_effect_if:
fixes ops
assumes "are_all_operators_applicable s ops"
and "are_all_operator_effects_consistent ops"
and "op ∈ set ops"
and "v ∈ set (add_effects_of op)"
shows "execute_parallel_operator s ops v = Some True"
proof -
let ?l = "map (map_of ∘ effect_to_assignments) ops"
have set_l_is: "set ?l = (map_of ∘ effect_to_assignments) ` set ops"
using set_map
by fastforce
{
let ?m = "(map_of ∘ effect_to_assignments) op"
have "?m ∈ set ?l"
using assms(3) set_l_is
by blast
moreover have "?m v = Some True"
using execute_parallel_operator_positive_effect_if_i[OF assms]
by fastforce
ultimately have "∃m ∈ set ?l. m v = Some True"
by blast
}
moreover {
fix m'
assume "m' ∈ set ?l"
then obtain op'
where op'_in_set_ops: "op' ∈ set ops"
and m'_is: "m' = (map_of ∘ effect_to_assignments) op'"
by auto
then have "set (add_effects_of op) ∩ set (delete_effects_of op') = {}"
using assms(2, 3) are_all_operator_effects_consistent_set[of ops]
by blast
then have "v ∉ set (delete_effects_of op')"
using assms(4)
by blast
then consider (v_in_set_add_effects) "v ∈ set (add_effects_of op')"
| (otherwise) "¬v ∈ set (add_effects_of op') ∧ ¬v ∈ set (delete_effects_of op')"
by blast
hence "m' v = Some True ∨ m' v = None"
proof (cases)
case v_in_set_add_effects
― ‹ TODO slow. ›
thus ?thesis
using execute_parallel_operator_positive_effect_if_i[
OF assms(1, 2) op'_in_set_ops, of v] m'_is
by simp
next
case otherwise
then have "¬v ∈ set (add_effects_of op')"
and "¬v ∈ set (delete_effects_of op')"
by blast+
thus ?thesis
using map_of_effect_to_assignments_is_none_if[of v op'] m'_is
by fastforce
qed
}
― ‹ TODO slow. ›
ultimately show ?thesis
unfolding execute_parallel_operator_def
using foldl_map_append_is_some_if[of s v True ?l]
by meson
qed
lemma execute_parallel_operator_negative_effect_if_i:
assumes "are_all_operators_applicable s ops"
and "are_all_operator_effects_consistent ops"
and "op ∈ set ops"
and "v ∈ set (delete_effects_of op)"
shows "map_of (effect_to_assignments op) v = Some False"
proof (-)
(*goal: ‹map_of (effect_to_assignments op) v = Some False›*)
let ?f = "λx. if ListMem x (delete_effects_of op) then False else True" and ?l' = " map (λv. (v, if ListMem v (delete_effects_of op) then False else True))
(add_effects_of op @ delete_effects_of op)"
have "set (delete_effects_of op @ add_effects_of op) ≠ {}"
using assms(4) (*‹v ∈ set (delete_effects_of op)›*) by fastforce
moreover have "v ∈ set (delete_effects_of op @ add_effects_of op)"
using assms(4) (*‹v ∈ set (delete_effects_of op)›*) by simp
moreover {
have "set (add_effects_of op) ∩ set (delete_effects_of op) = {}"
using are_all_operator_effects_consistent_set (*‹are_all_operator_effects_consistent ?ops = (∀op₁∈set ?ops. ∀op₂∈set ?ops. set (add_effects_of op₁) ∩ set (delete_effects_of op₂) = {} ∧ set (delete_effects_of op₁) ∩ set (add_effects_of op₂) = {})›*) assms(2,3) (*‹are_all_operator_effects_consistent (ops::'a strips_operator list)› ‹op ∈ set ops›*) by fast
moreover have "effect_to_assignments op = ?l'"
using effect_to_assignments_construction_from_function_graph(2) (*‹set (add_effects_of ?op) ∩ set (delete_effects_of ?op) = {} ⟹ effect_to_assignments ?op = map (λv. (v, if ListMem v (delete_effects_of ?op) then False else True)) (add_effects_of ?op @ delete_effects_of ?op)›*) calculation (*‹set (add_effects_of op) ∩ set (delete_effects_of op) = {}›*) by blast
ultimately have "map_of (effect_to_assignments op) = map_of ?l'"
by argo
}
ultimately have "map_of (effect_to_assignments op) v = Some (?f v)"
using Map_Supplement.map_of_from_function_graph_is_some_if[of "add_effects_of op @ delete_effects_of op" v "?f"] (*‹⟦set (add_effects_of op @ delete_effects_of op) ≠ {}; v ∈ set (add_effects_of op @ delete_effects_of op)⟧ ⟹ map_of (map (λx. (x, if ListMem x (delete_effects_of op) then False else True)) (add_effects_of op @ delete_effects_of op)) v = Some (if ListMem v (delete_effects_of op) then False else True)›*) by force
thus "?thesis"
(*goal: ‹map_of (effect_to_assignments op) v = Some False›*)
using assms(4) (*‹v ∈ set (delete_effects_of op)›*) unfolding ListMem_iff
(*goal: ‹map_of (effect_to_assignments op) v = Some False›*)
by presburger
qed
lemma execute_parallel_operator_negative_effect_if:
assumes "are_all_operators_applicable s ops"
and "are_all_operator_effects_consistent ops"
and "op ∈ set ops"
and "v ∈ set (delete_effects_of op)"
shows "execute_parallel_operator s ops v = Some False"
proof -
let ?l = "map (map_of ∘ effect_to_assignments) ops"
have set_l_is: "set ?l = (map_of ∘ effect_to_assignments) ` set ops"
using set_map
by fastforce
{
let ?m = "(map_of ∘ effect_to_assignments) op"
have "?m ∈ set ?l"
using assms(3) set_l_is
by blast
moreover have "?m v = Some False"
using execute_parallel_operator_negative_effect_if_i[OF assms]
by fastforce
ultimately have "∃m ∈ set ?l. m v = Some False"
by blast
}
moreover {
fix m'
assume "m' ∈ set ?l"
then obtain op'
where op'_in_set_ops: "op' ∈ set ops"
and m'_is: "m' = (map_of ∘ effect_to_assignments) op'"
by auto
then have "set (delete_effects_of op) ∩ set (add_effects_of op') = {}"
using assms(2, 3) are_all_operator_effects_consistent_set[of ops]
by blast
then have "v ∉ set (add_effects_of op')"
using assms(4)
by blast
then consider (v_in_set_delete_effects) "v ∈ set (delete_effects_of op')"
| (otherwise) "¬v ∈ set (add_effects_of op') ∧ ¬v ∈ set (delete_effects_of op')"
by blast
hence "m' v = Some False ∨ m' v = None"
proof (cases)
case v_in_set_delete_effects
― ‹ TODO slow. ›
thus ?thesis
using execute_parallel_operator_negative_effect_if_i[
OF assms(1, 2) op'_in_set_ops, of v] m'_is
by simp
next
case otherwise
then have "¬v ∈ set (add_effects_of op')"
and "¬v ∈ set (delete_effects_of op')"
by blast+
thus ?thesis
using map_of_effect_to_assignments_is_none_if[of v op'] m'_is
by fastforce
qed
}
― ‹ TODO slow. ›
ultimately show ?thesis
unfolding execute_parallel_operator_def
using foldl_map_append_is_some_if[of s v False ?l]
by meson
qed
lemma execute_parallel_operator_no_effect_if:
assumes "∀op ∈ set ops. ¬v ∈ set (add_effects_of op) ∧ ¬v ∈ set (delete_effects_of op)"
shows "execute_parallel_operator s ops v = s v"
using assms (*‹∀op∈set ops. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op)›*) unfolding execute_parallel_operator_def
(*goal: ‹foldl (++) s (map (map_of ∘ effect_to_assignments) ops) v = s v›*)
proof (induction ops arbitrary: s)
(*goals:
1. ‹⋀s. ∀op∈set []. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op) ⟹ foldl (++) s (map (map_of ∘ effect_to_assignments) []) v = s v›
2. ‹⋀a ops s. ⟦⋀s. ∀op∈set ops. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op) ⟹ foldl (++) s (map (map_of ∘ effect_to_assignments) ops) v = s v; ∀op∈set (a # ops). v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op)⟧ ⟹ foldl (++) s (map (map_of ∘ effect_to_assignments) (a # ops)) v = s v›*)
case (Cons a ops) (*‹∀op∈set ops. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op) ⟹ foldl (++) ?s (map (map_of ∘ effect_to_assignments) ops) v = ?s v› ‹∀op∈set (a # ops). v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op)›*)
let ?f = "map_of ∘ effect_to_assignments"
{
have "v ∉ set (add_effects_of a) ∧ v ∉ set (delete_effects_of a)"
using Cons.prems(1) (*‹∀op::'a strips_operator∈set ((a::'a strips_operator) # (ops::'a strips_operator list)). (v::'a::type) ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op)›*) by force
then have "?f a v = None"
using map_of_effect_to_assignments_is_none_if[of v a] (*‹⟦v ∉ set (add_effects_of a); v ∉ set (delete_effects_of a)⟧ ⟹ map_of (effect_to_assignments a) v = None›*) by fastforce
then have "v ∉ dom (?f a)"
by blast
hence "(s ++ ?f a) v = s v"
using map_add_dom_app_simps(3)[of v "?f a" s] (*‹v ∉ dom ((map_of ∘ effect_to_assignments) a) ⟹ (s ++ (map_of ∘ effect_to_assignments) a) v = s v›*) by blast
}
moreover {
have "∀op∈set ops. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op)"
using Cons.prems(1) (*‹∀op∈set (a # ops). v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op)›*) by simp
hence "foldl (++) (s ++ ?f a) (map ?f ops) v = (s ++ ?f a) v"
using Cons.IH[of "s ++ ?f a"] (*‹∀op∈set ops. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op) ⟹ foldl (++) (s ++ (map_of ∘ effect_to_assignments) a) (map (map_of ∘ effect_to_assignments) ops) v = (s ++ (map_of ∘ effect_to_assignments) a) v›*) by blast
}
moreover {
have "map ?f (a # ops) = ?f a # map ?f ops"
by force
then have "foldl (++) s (map ?f (a # ops))
= foldl (++) (s ++ ?f a) (map ?f ops)"
using foldl_Cons (*‹foldl ?f ?a (?x # ?xs) = foldl ?f (?f ?a ?x) ?xs›*) by force
}
ultimately show "?case"
(*goal: ‹foldl (++) s (map (map_of ∘ effect_to_assignments) (a # ops)) v = s v›*)
by argo
qed (fastforce)
(*solved the remaining goal: ‹⋀s. ∀op∈set []. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op) ⟹ foldl (++) s (map (map_of ∘ effect_to_assignments) []) v = s v›*)
corollary execute_parallel_operators_strips_none_if:
assumes "∀op ∈ set ops. ¬v ∈ set (add_effects_of op) ∧ ¬v ∈ set (delete_effects_of op)"
and "s v = None"
shows "execute_parallel_operator s ops v = None"
using execute_parallel_operator_no_effect_if[OF assms ( 1 )] (*‹execute_parallel_operator ?s ops v = ?s v›*) assms(2) (*‹s v = None›*) by simp
corollary execute_parallel_operators_strips_none_if_contraposition:
assumes "¬execute_parallel_operator s ops v = None"
shows "(∃op ∈ set ops. v ∈ set (add_effects_of op) ∨ v ∈ set (delete_effects_of op))
∨ s v ≠ None"
proof (-)
(*goal: ‹(∃op::'a strips_operator∈set (ops::'a strips_operator list). (v::'a::type) ∈ set (add_effects_of op) ∨ v ∈ set (delete_effects_of op)) ∨ (s::'a::type ⇒ bool option) v ≠ None›*)
let ?P = "(∀op ∈ set ops. ¬v ∈ set (add_effects_of op) ∧ ¬v ∈ set (delete_effects_of op))
∧ s v = None" and ?Q = "execute_parallel_operator s ops v = None"
have "?P ⟹ ?Q"
using execute_parallel_operators_strips_none_if[of ops v s] (*‹⟦∀op∈set ops. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op); s v = None⟧ ⟹ execute_parallel_operator s ops v = None›*) by blast
then have "¬?P"
using contrapos_nn[of ?Q ?P] (*‹⟦execute_parallel_operator s ops v ≠ None; (∀op∈set ops. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op)) ∧ s v = None ⟹ execute_parallel_operator s ops v = None⟧ ⟹ ¬ ((∀op∈set ops. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op)) ∧ s v = None)›*) using assms (*‹execute_parallel_operator s ops v ≠ None›*) by argo
thus "?thesis"
(*goal: ‹(∃op∈set ops. v ∈ set (add_effects_of op) ∨ v ∈ set (delete_effects_of op)) ∨ s v ≠ None›*)
by meson
qed
text ‹ We will now move on to showing the equivalent to theorem \isaname{operator_effect__strips}
in \isaname{execute_parallel_operator_effect}.
Under the condition that for a list of operators \<^term>‹ops› all
operators in the corresponding set are applicable in a given state \<^term>‹s› and all operator effects
are consistent, if an operator \<^term>‹op› exists with \<^term>‹op ∈ set ops› and with \<^term>‹v› being
an add effect of \<^term>‹op›, then the successor state
@{text[display, indent=4] "s' ≡ execute_parallel_operator s ops"}
will evaluate \<^term>‹v› to true, that is
@{text[display, indent=4] "execute_parallel_operator s ops v = Some True"}
Symmetrically, if \<^term>‹v› is a delete effect, we have
@{text[display, indent=4] "execute_parallel_operator s ops v = Some False"}
under the same condition as for the positive effect.
Lastly, if \<^term>‹v› is neither an add effect nor a delete effect for any operator in the
operator set corresponding to $ops$, then the state after parallel operator execution remains
unchanged, i.e.
@{text[display, indent=4] "execute_parallel_operator s ops v = s v"}
›
theorem execute_parallel_operator_effect:
assumes "are_all_operators_applicable s ops"
and "are_all_operator_effects_consistent ops"
shows "op ∈ set ops ∧ v ∈ set (add_effects_of op)
⟶ execute_parallel_operator s ops v = Some True"
and "op ∈ set ops ∧ v ∈ set (delete_effects_of op)
⟶ execute_parallel_operator s ops v = Some False"
and "(∀op ∈ set ops.
v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op))
⟶ execute_parallel_operator s ops v = s v"
using execute_parallel_operator_positive_effect_if[OF assms] (*‹⟦?op ∈ set ops; ?v ∈ set (add_effects_of ?op)⟧ ⟹ execute_parallel_operator s ops ?v = Some True›*) execute_parallel_operator_negative_effect_if[OF assms] (*‹⟦?op ∈ set ops; ?v ∈ set (delete_effects_of ?op)⟧ ⟹ execute_parallel_operator s ops ?v = Some False›*) execute_parallel_operator_no_effect_if[of ops v s] (*‹∀op::'a strips_operator∈set (ops::'a strips_operator list). (v::'a) ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op) ⟹ execute_parallel_operator (s::'a ⇒ bool option) ops v = s v›*) apply -
(*goals:
1. ‹⟦⋀op v. ⟦op ∈ set ops; v ∈ set (add_effects_of op)⟧ ⟹ execute_parallel_operator s ops v = Some True; ⋀op v. ⟦op ∈ set ops; v ∈ set (delete_effects_of op)⟧ ⟹ execute_parallel_operator s ops v = Some False; ∀op∈set ops. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op) ⟹ execute_parallel_operator s ops v = s v⟧ ⟹ op ∈ set ops ∧ v ∈ set (add_effects_of op) ⟶ execute_parallel_operator s ops v = Some True›
2. ‹⟦⋀op v. ⟦op ∈ set ops; v ∈ set (add_effects_of op)⟧ ⟹ execute_parallel_operator s ops v = Some True; ⋀op v. ⟦op ∈ set ops; v ∈ set (delete_effects_of op)⟧ ⟹ execute_parallel_operator s ops v = Some False; ∀op∈set ops. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op) ⟹ execute_parallel_operator s ops v = s v⟧ ⟹ op ∈ set ops ∧ v ∈ set (delete_effects_of op) ⟶ execute_parallel_operator s ops v = Some False›
3. ‹⟦⋀op v. ⟦op ∈ set ops; v ∈ set (add_effects_of op)⟧ ⟹ execute_parallel_operator s ops v = Some True; ⋀op v. ⟦op ∈ set ops; v ∈ set (delete_effects_of op)⟧ ⟹ execute_parallel_operator s ops v = Some False; ∀op∈set ops. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op) ⟹ execute_parallel_operator s ops v = s v⟧ ⟹ (∀op∈set ops. v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op)) ⟶ execute_parallel_operator s ops v = s v›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*discuss goal 3*)
apply blast
(*proven 3 subgoals*) .
lemma is_parallel_solution_for_problem_operator_set:
fixes Π:: "'a strips_problem"
assumes "is_parallel_solution_for_problem Π π"
and "ops ∈ set π"
and "op ∈ set ops"
shows "op ∈ set ((Π)⇩𝒪)"
proof (-)
(*goal: ‹(op::'a strips_operator) ∈ set ((Π::'a strips_problem)⇩𝒪)›*)
have "∀ops ∈ set π. ∀op ∈ set ops. op ∈ set (strips_problem.operators_of Π)"
using assms(1) (*‹is_parallel_solution_for_problem Π π›*) unfolding is_parallel_solution_for_problem_def list_all_iff ListMem_iff
(*goal: ‹∀ops∈set π. ∀op∈set ops. op ∈ set (Π⇩𝒪)›*)
by standard
thus "?thesis"
(*goal: ‹op ∈ set (Π⇩𝒪)›*)
using assms(2,3) (*‹ops ∈ set π› ‹op ∈ set ops›*) by fastforce
qed
lemma trace_parallel_plan_strips_not_nil: "trace_parallel_plan_strips I π ≠ []"
proof (cases π)
(*goals:
1. ‹π = [] ⟹ trace_parallel_plan_strips I π ≠ []›
2. ‹⋀a list. π = a # list ⟹ trace_parallel_plan_strips I π ≠ []›*)
case (Cons a list) (*‹π = a # list›*)
then show "?thesis"
(*goal: ‹trace_parallel_plan_strips I π ≠ []›*)
apply (cases "are_all_operators_applicable I (hd π) ∧ are_all_operator_effects_consistent (hd π)")
(*goals:
1. ‹⟦π = a # list; are_all_operators_applicable I (hd π) ∧ are_all_operator_effects_consistent (hd π)⟧ ⟹ trace_parallel_plan_strips I π ≠ []›
2. ‹⟦π = a # list; ¬ (are_all_operators_applicable I (hd π) ∧ are_all_operator_effects_consistent (hd π))⟧ ⟹ trace_parallel_plan_strips I π ≠ []›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
qed (simp)
(*solved the remaining goal: ‹π = [] ⟹ trace_parallel_plan_strips I π ≠ []›*)
corollary length_trace_parallel_plan_gt_0[simp]: "0 < length (trace_parallel_plan_strips I π)"
using trace_parallel_plan_strips_not_nil (*‹trace_parallel_plan_strips ?I ?π ≠ []›*) apply -
(*goal: ‹(0::nat) < length (trace_parallel_plan_strips (I::'a::type ⇒ bool option) (π::'a strips_operator list list))›*)
by standard
corollary length_trace_minus_one_lt_length_trace[simp]:
"length (trace_parallel_plan_strips I π) - 1 < length (trace_parallel_plan_strips I π)"
using diff_less[OF _ length_trace_parallel_plan_gt_0] (*‹(0::nat) < (?n::nat) ⟹ length (trace_parallel_plan_strips (?I1::?'a1 ⇒ bool option) (?π1::?'a1 strips_operator list list)) - ?n < length (trace_parallel_plan_strips ?I1 ?π1)›*) by auto
lemma trace_parallel_plan_strips_head_is_initial_state:
"trace_parallel_plan_strips I π ! 0 = I"
proof (cases π)
(*goals:
1. ‹π = [] ⟹ trace_parallel_plan_strips I π ! 0 = I›
2. ‹⋀a list. π = a # list ⟹ trace_parallel_plan_strips I π ! 0 = I›*)
case (Cons a list) (*‹π = a # list›*)
then show "?thesis"
(*goal: ‹trace_parallel_plan_strips I π ! 0 = I›*)
apply (cases "are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a")
(*goals:
1. ‹⟦π = a # list; are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a⟧ ⟹ trace_parallel_plan_strips I π ! 0 = I›
2. ‹⟦π = a # list; ¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a)⟧ ⟹ trace_parallel_plan_strips I π ! 0 = I›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
qed (simp)
(*solved the remaining goal: ‹π = [] ⟹ trace_parallel_plan_strips I π ! 0 = I›*)
lemma trace_parallel_plan_strips_length_gt_one_if:
assumes "k < length (trace_parallel_plan_strips I π) - 1"
shows "1 < length (trace_parallel_plan_strips I π)"
using assms (*‹k < length (trace_parallel_plan_strips I π) - 1›*) by linarith<close>
lemma trace_parallel_plan_strips_last_cons_then:
"last (s # trace_parallel_plan_strips s' π) = last (trace_parallel_plan_strips s' π)"
apply (cases π)
(*goals:
1. ‹π = [] ⟹ last (s # trace_parallel_plan_strips s' π) = last (trace_parallel_plan_strips s' π)›
2. ‹⋀a list. π = a # list ⟹ last (s # trace_parallel_plan_strips s' π) = last (trace_parallel_plan_strips s' π)›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply force
(*proven 2 subgoals*) .
text ‹ Parallel plan traces have some important properties that we want to confirm before
proceeding. Let \<^term>‹τ ≡ trace_parallel_plan_strips I π› be a trace for a parallel plan \<^term>‹π›
with initial state \<^term>‹I›.
First, all parallel operators \<^term>‹ops = π ! k› for any index \<^term>‹k› with \<^term>‹k < length τ - 1›
(meaning that \<^term>‹k› is not the index of the last element).
must be applicable and their effects must be consistent. Otherwise, the trace would have terminated
and \<^term>‹ops› would have been the last element. This would violate the assumption that \<^term>‹k < length τ - 1›
is not the last index since the index of the last element is \<^term>‹length τ - 1›.
\footnote{More precisely, the index of the last element is \<^term>‹length τ - 1› if \<^term>‹τ› is not
empty which is however always true since the trace contains at least the initial state.} ›
(* TODO? hide? *)
lemma trace_parallel_plan_strips_operator_preconditions:
assumes "k < length (trace_parallel_plan_strips I π) - 1"
shows "are_all_operators_applicable (trace_parallel_plan_strips I π ! k) (π ! k)
∧ are_all_operator_effects_consistent (π ! k)"
using assms (*‹k < length (trace_parallel_plan_strips I π) - 1›*) proof (induction "π" arbitrary: I k)
(*goals:
1. ‹⋀I k. k < length (trace_parallel_plan_strips I []) - 1 ⟹ are_all_operators_applicable (trace_parallel_plan_strips I [] ! k) ([] ! k) ∧ are_all_operator_effects_consistent ([] ! k)›
2. ‹⋀a π I k. ⟦⋀I k. k < length (trace_parallel_plan_strips I π) - 1 ⟹ are_all_operators_applicable (trace_parallel_plan_strips I π ! k) (π ! k) ∧ are_all_operator_effects_consistent (π ! k); k < length (trace_parallel_plan_strips I (a # π)) - 1⟧ ⟹ are_all_operators_applicable (trace_parallel_plan_strips I (a # π) ! k) ((a # π) ! k) ∧ are_all_operator_effects_consistent ((a # π) ! k)›*)
case (Cons a π) (*‹?k < length (trace_parallel_plan_strips ?I π) - 1 ⟹ are_all_operators_applicable (trace_parallel_plan_strips ?I π ! ?k) (π ! ?k) ∧ are_all_operator_effects_consistent (π ! ?k)› ‹(k::nat) < length (trace_parallel_plan_strips (I::'a ⇒ bool option) ((a::'a strips_operator list) # (π::'a strips_operator list list))) - (1::nat)›*)
then show "?case"
(*goal: ‹are_all_operators_applicable (trace_parallel_plan_strips I (a # π) ! k) ((a # π) ! k) ∧ are_all_operator_effects_consistent ((a # π) ! k)›*)
proof (cases "are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a")
(*goals:
1. ‹⟦⋀k I. k < length (trace_parallel_plan_strips I π) - 1 ⟹ are_all_operators_applicable (trace_parallel_plan_strips I π ! k) (π ! k) ∧ are_all_operator_effects_consistent (π ! k); k < length (trace_parallel_plan_strips I (a # π)) - 1; are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a⟧ ⟹ are_all_operators_applicable (trace_parallel_plan_strips I (a # π) ! k) ((a # π) ! k) ∧ are_all_operator_effects_consistent ((a # π) ! k)›
2. ‹⟦⋀k I. k < length (trace_parallel_plan_strips I π) - 1 ⟹ are_all_operators_applicable (trace_parallel_plan_strips I π ! k) (π ! k) ∧ are_all_operator_effects_consistent (π ! k); k < length (trace_parallel_plan_strips I (a # π)) - 1; ¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a)⟧ ⟹ are_all_operators_applicable (trace_parallel_plan_strips I (a # π) ! k) ((a # π) ! k) ∧ are_all_operator_effects_consistent ((a # π) ! k)›*)
case True (*‹are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a›*)
have trace_parallel_plan_strips_cons: "trace_parallel_plan_strips I (a # π)
= I # trace_parallel_plan_strips (execute_parallel_operator I a) π"
using True (*‹are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a›*) by simp
then show "?thesis"
(*goal: ‹are_all_operators_applicable (trace_parallel_plan_strips I (a # π) ! k) ((a # π) ! k) ∧ are_all_operator_effects_consistent ((a # π) ! k)›*)
proof (cases "k")
(*goals:
1. ‹⟦trace_parallel_plan_strips I (a # π) = I # trace_parallel_plan_strips (execute_parallel_operator I a) π; k = 0⟧ ⟹ are_all_operators_applicable (trace_parallel_plan_strips I (a # π) ! k) ((a # π) ! k) ∧ are_all_operator_effects_consistent ((a # π) ! k)›
2. ‹⋀nat. ⟦trace_parallel_plan_strips I (a # π) = I # trace_parallel_plan_strips (execute_parallel_operator I a) π; k = Suc nat⟧ ⟹ are_all_operators_applicable (trace_parallel_plan_strips I (a # π) ! k) ((a # π) ! k) ∧ are_all_operator_effects_consistent ((a # π) ! k)›*)
case 0 (*‹(k::nat) = (0::nat)›*)
have "trace_parallel_plan_strips I (a # π) ! 0 = I"
using trace_parallel_plan_strips_cons (*‹trace_parallel_plan_strips I (a # π) = I # trace_parallel_plan_strips (execute_parallel_operator I a) π›*) by simp
moreover have "(a # π) ! 0 = a"
by simp
ultimately show "?thesis"
(*goal: ‹are_all_operators_applicable (trace_parallel_plan_strips I (a # π) ! k) ((a # π) ! k) ∧ are_all_operator_effects_consistent ((a # π) ! k)›*)
using True (*‹are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a›*) "0" (*‹k = 0›*) by presburger
next
(*goal: ‹⋀nat. ⟦trace_parallel_plan_strips I (a # π) = I # trace_parallel_plan_strips (execute_parallel_operator I a) π; k = Suc nat⟧ ⟹ are_all_operators_applicable (trace_parallel_plan_strips I (a # π) ! k) ((a # π) ! k) ∧ are_all_operator_effects_consistent ((a # π) ! k)›*)
case (Suc k') (*‹k = Suc k'›*)
let ?I' = "execute_parallel_operator I a"
have "trace_parallel_plan_strips I (a # π) ! Suc k' = trace_parallel_plan_strips ?I' π ! k'"
using trace_parallel_plan_strips_cons (*‹trace_parallel_plan_strips I (a # π) = I # trace_parallel_plan_strips (execute_parallel_operator I a) π›*) by simp
moreover have "(a # π) ! Suc k' = π ! k'"
by simp
moreover {
have "length (trace_parallel_plan_strips I (a # π))
= 1 + length (trace_parallel_plan_strips ?I' π)"
unfolding trace_parallel_plan_strips_cons
(*goal: ‹length (I # trace_parallel_plan_strips (execute_parallel_operator I a) π) = 1 + length (trace_parallel_plan_strips (execute_parallel_operator I a) π)›*)
by simp
then have "k' < length (trace_parallel_plan_strips ?I' π) - 1"
using Suc (*‹k = Suc k'›*) Cons.prems (*‹k < length (trace_parallel_plan_strips I (a # π)) - 1›*) by fastforce
hence "are_all_operators_applicable (trace_parallel_plan_strips ?I' π ! k') (π ! k')
∧ are_all_operator_effects_consistent (π ! k')"
using Cons.IH[of k'] (*‹k' < length (trace_parallel_plan_strips ?I π) - 1 ⟹ are_all_operators_applicable (trace_parallel_plan_strips ?I π ! k') (π ! k') ∧ are_all_operator_effects_consistent (π ! k')›*) by blast
}
ultimately show "?thesis"
(*goal: ‹are_all_operators_applicable (trace_parallel_plan_strips I (a # π) ! k) ((a # π) ! k) ∧ are_all_operator_effects_consistent ((a # π) ! k)›*)
using Suc (*‹k = Suc k'›*) by argo
qed
next
(*goal: ‹⟦⋀k I. k < length (trace_parallel_plan_strips I π) - 1 ⟹ are_all_operators_applicable (trace_parallel_plan_strips I π ! k) (π ! k) ∧ are_all_operator_effects_consistent (π ! k); k < length (trace_parallel_plan_strips I (a # π)) - 1; ¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a)⟧ ⟹ are_all_operators_applicable (trace_parallel_plan_strips I (a # π) ! k) ((a # π) ! k) ∧ are_all_operator_effects_consistent ((a # π) ! k)›*)
case False (*‹¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a)›*)
then have "trace_parallel_plan_strips I (a # π) = [I]"
by force
then have "length (trace_parallel_plan_strips I (a # π)) - 1 = 0"
by simp
then show "?thesis"
(*goal: ‹are_all_operators_applicable (trace_parallel_plan_strips I (a # π) ! k) ((a # π) ! k) ∧ are_all_operator_effects_consistent ((a # π) ! k)›*)
using Cons.prems (*‹k < length (trace_parallel_plan_strips I (a # π)) - 1›*) by force
qed
qed (auto)
(*solved the remaining goal: ‹⋀I k. k < length (trace_parallel_plan_strips I []) - 1 ⟹ are_all_operators_applicable (trace_parallel_plan_strips I [] ! k) ([] ! k) ∧ are_all_operator_effects_consistent ([] ! k)›*)
text ‹ Another interesting property that we verify below is that elements of the trace
store the result of plan prefix execution. This means that for an index \<^term>‹k› with\newline
\<^term>‹k < length (trace_parallel_plan_strips I π)›, the \<^term>‹k›-th element of the trace is state
reached by executing the plan prefix \<^term>‹take k π› consisting of the first \<^term>‹k› parallel
operators of \<^term>‹π›. ›
lemma trace_parallel_plan_plan_prefix:
assumes "k < length (trace_parallel_plan_strips I π)"
shows "trace_parallel_plan_strips I π ! k = execute_parallel_plan I (take k π)"
using assms (*‹k < length (trace_parallel_plan_strips I π)›*) proof (induction π arbitrary: I k)
(*goals:
1. ‹⋀I k. k < length (trace_parallel_plan_strips I []) ⟹ trace_parallel_plan_strips I [] ! k = execute_parallel_plan I (take k [])›
2. ‹⋀a π I k. ⟦⋀I k. k < length (trace_parallel_plan_strips I π) ⟹ trace_parallel_plan_strips I π ! k = execute_parallel_plan I (take k π); k < length (trace_parallel_plan_strips I (a # π))⟧ ⟹ trace_parallel_plan_strips I (a # π) ! k = execute_parallel_plan I (take k (a # π))›*)
case (Cons a π) (*‹?k < length (trace_parallel_plan_strips ?I π) ⟹ trace_parallel_plan_strips ?I π ! ?k = execute_parallel_plan ?I (take ?k π)› ‹k < length (trace_parallel_plan_strips I (a # π))›*)
then show "?case"
(*goal: ‹trace_parallel_plan_strips I (a # π) ! k = execute_parallel_plan I (take k (a # π))›*)
proof (cases "are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a")
(*goals:
1. ‹⟦⋀k I. k < length (trace_parallel_plan_strips I π) ⟹ trace_parallel_plan_strips I π ! k = execute_parallel_plan I (take k π); k < length (trace_parallel_plan_strips I (a # π)); are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a⟧ ⟹ trace_parallel_plan_strips I (a # π) ! k = execute_parallel_plan I (take k (a # π))›
2. ‹⟦⋀k I. k < length (trace_parallel_plan_strips I π) ⟹ trace_parallel_plan_strips I π ! k = execute_parallel_plan I (take k π); k < length (trace_parallel_plan_strips I (a # π)); ¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a)⟧ ⟹ trace_parallel_plan_strips I (a # π) ! k = execute_parallel_plan I (take k (a # π))›*)
case True (*‹are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a›*)
let ?σ = "trace_parallel_plan_strips I (a # π)" and ?I' = "execute_parallel_operator I a"
have "σ_equals": "?σ = I # trace_parallel_plan_strips ?I' π"
using True (*‹are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a›*) by auto
then show "?thesis"
(*goal: ‹trace_parallel_plan_strips I (a # π) ! k = execute_parallel_plan I (take k (a # π))›*)
proof (cases "k = 0")
(*goals:
1. ‹⟦trace_parallel_plan_strips I (a # π) = I # trace_parallel_plan_strips (execute_parallel_operator I a) π; k = 0⟧ ⟹ trace_parallel_plan_strips I (a # π) ! k = execute_parallel_plan I (take k (a # π))›
2. ‹⟦trace_parallel_plan_strips I (a # π) = I # trace_parallel_plan_strips (execute_parallel_operator I a) π; k ≠ 0⟧ ⟹ trace_parallel_plan_strips I (a # π) ! k = execute_parallel_plan I (take k (a # π))›*)
case False (*‹k ≠ 0›*)
obtain k' where k_is_suc_of_k': "k = Suc k'"
(*goal: ‹(⋀k'. k = Suc k' ⟹ thesis) ⟹ thesis›*)
using not0_implies_Suc[OF False] (*‹∃m::nat. (k::nat) = Suc m›*) by blast
then have "execute_parallel_plan I (take k (a # π))
= execute_parallel_plan ?I' (take k' π)"
using True (*‹are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a›*) by simp
moreover have "trace_parallel_plan_strips I (a # π) ! k
= trace_parallel_plan_strips ?I' π ! k'"
using "σ_equals" (*‹trace_parallel_plan_strips I (a # π) = I # trace_parallel_plan_strips (execute_parallel_operator I a) π›*) k_is_suc_of_k' (*‹k = Suc k'›*) by simp
moreover {
have "k' < length (trace_parallel_plan_strips (execute_parallel_operator I a) π)"
using Cons.prems (*‹k < length (trace_parallel_plan_strips I (a # π))›*) "σ_equals" (*‹trace_parallel_plan_strips (I::'a::type ⇒ bool option) ((a::'a strips_operator list) # (π::'a strips_operator list list)) = I # trace_parallel_plan_strips (execute_parallel_operator I a) π›*) k_is_suc_of_k' (*‹k = Suc k'›*) by force
hence "trace_parallel_plan_strips ?I' π ! k'
= execute_parallel_plan ?I' (take k' π)"
using Cons.IH[of k' ?I'] (*‹(k'::nat) < length (trace_parallel_plan_strips (execute_parallel_operator (I::'a ⇒ bool option) (a::'a strips_operator list)) (π::'a strips_operator list list)) ⟹ trace_parallel_plan_strips (execute_parallel_operator I a) π ! k' = execute_parallel_plan (execute_parallel_operator I a) (take k' π)›*) by blast
}
ultimately show "?thesis"
(*goal: ‹trace_parallel_plan_strips I (a # π) ! k = execute_parallel_plan I (take k (a # π))›*)
by presburger
qed (simp)
(*solved the remaining goal: ‹⟦trace_parallel_plan_strips I (a # π) = I # trace_parallel_plan_strips (execute_parallel_operator I a) π; k = 0⟧ ⟹ trace_parallel_plan_strips I (a # π) ! k = execute_parallel_plan I (take k (a # π))›*)
next
(*goal: ‹⟦⋀(k::nat) I::'a ⇒ bool option. k < length (trace_parallel_plan_strips I (π::'a strips_operator list list)) ⟹ trace_parallel_plan_strips I π ! k = execute_parallel_plan I (take k π); (k::nat) < length (trace_parallel_plan_strips (I::'a ⇒ bool option) ((a::'a strips_operator list) # π)); ¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a)⟧ ⟹ trace_parallel_plan_strips I (a # π) ! k = execute_parallel_plan I (take k (a # π))›*)
case operator_precondition_violated: False (*‹¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a)›*)
then show "?thesis"
(*goal: ‹trace_parallel_plan_strips (I::'a ⇒ bool option) ((a::'a strips_operator list) # (π::'a strips_operator list list)) ! (k::nat) = execute_parallel_plan I (take k (a # π))›*)
proof (cases "k = 0")
(*goals:
1. ‹⟦¬ (are_all_operators_applicable (I::'a ⇒ bool option) (a::'a strips_operator list) ∧ are_all_operator_effects_consistent a); (k::nat) = (0::nat)⟧ ⟹ trace_parallel_plan_strips I (a # (π::'a strips_operator list list)) ! k = execute_parallel_plan I (take k (a # π))›
2. ‹⟦¬ (are_all_operators_applicable (I::'a ⇒ bool option) (a::'a strips_operator list) ∧ are_all_operator_effects_consistent a); (k::nat) ≠ (0::nat)⟧ ⟹ trace_parallel_plan_strips I (a # (π::'a strips_operator list list)) ! k = execute_parallel_plan I (take k (a # π))›*)
case False (*‹(k::nat) ≠ (0::nat)›*)
then have "trace_parallel_plan_strips I (a # π) = [I]"
using operator_precondition_violated (*‹¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a)›*) by force
moreover have "execute_parallel_plan I (take k (a # π)) = I"
using Cons.prems (*‹k < length (trace_parallel_plan_strips I (a # π))›*) operator_precondition_violated (*‹¬ (are_all_operators_applicable (I::'a::type ⇒ bool option) (a::'a strips_operator list) ∧ are_all_operator_effects_consistent a)›*) by force
ultimately show "?thesis"
(*goal: ‹trace_parallel_plan_strips I (a # π) ! k = execute_parallel_plan I (take k (a # π))›*)
using Cons.prems (*‹k < length (trace_parallel_plan_strips I (a # π))›*) nth_Cons_0 (*‹(?x # ?xs) ! 0 = ?x›*) by auto
qed (simp)
(*solved the remaining goal: ‹⟦¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a); k = 0⟧ ⟹ trace_parallel_plan_strips I (a # π) ! k = execute_parallel_plan I (take k (a # π))›*)
qed
qed (simp)
(*solved the remaining goal: ‹⋀I k. k < length (trace_parallel_plan_strips I []) ⟹ trace_parallel_plan_strips I [] ! k = execute_parallel_plan I (take k [])›*)
lemma length_trace_parallel_plan_strips_lte_length_plan_plus_one:
shows "length (trace_parallel_plan_strips I π) ≤ length π + 1"
proof (induction π arbitrary: I)
(*goals:
1. ‹⋀I. length (trace_parallel_plan_strips I []) ≤ length [] + 1›
2. ‹⋀a π I. (⋀I. length (trace_parallel_plan_strips I π) ≤ length π + 1) ⟹ length (trace_parallel_plan_strips I (a # π)) ≤ length (a # π) + 1›*)
case (Cons a π) (*‹length (trace_parallel_plan_strips ?I π) ≤ length π + 1›*)
then show "?case"
(*goal: ‹length (trace_parallel_plan_strips I (a # π)) ≤ length (a # π) + 1›*)
proof (cases "are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a")
(*goals:
1. ‹⟦⋀I::'a ⇒ bool option. length (trace_parallel_plan_strips I (π::'a strips_operator list list)) ≤ length π + (1::nat); are_all_operators_applicable (I::'a ⇒ bool option) (a::'a strips_operator list) ∧ are_all_operator_effects_consistent a⟧ ⟹ length (trace_parallel_plan_strips I (a # π)) ≤ length (a # π) + (1::nat)›
2. ‹⟦⋀I::'a ⇒ bool option. length (trace_parallel_plan_strips I (π::'a strips_operator list list)) ≤ length π + (1::nat); ¬ (are_all_operators_applicable (I::'a ⇒ bool option) (a::'a strips_operator list) ∧ are_all_operator_effects_consistent a)⟧ ⟹ length (trace_parallel_plan_strips I (a # π)) ≤ length (a # π) + (1::nat)›*)
case True (*‹are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a›*)
let ?I' = "execute_parallel_operator I a"
{
have "trace_parallel_plan_strips I (a # π) = I # trace_parallel_plan_strips ?I' π"
using True (*‹are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a›*) by auto
then have "length (trace_parallel_plan_strips I (a # π))
= length (trace_parallel_plan_strips ?I' π) + 1"
by simp
moreover have "length (trace_parallel_plan_strips ?I' π) ≤ length π + 1"
using Cons.IH[of ?I'] (*‹length (trace_parallel_plan_strips (execute_parallel_operator I a) π) ≤ length π + 1›*) by blast
ultimately have "length (trace_parallel_plan_strips I (a # π)) ≤ length (a # π) + 1"
by simp
}
thus "?thesis"
(*goal: ‹length (trace_parallel_plan_strips I (a # π)) ≤ length (a # π) + 1›*)
by blast
qed (auto)
(*solved the remaining goal: ‹⟦⋀I. length (trace_parallel_plan_strips I π) ≤ length π + 1; ¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a)⟧ ⟹ length (trace_parallel_plan_strips I (a # π)) ≤ length (a # π) + 1›*)
qed (simp)
(*solved the remaining goal: ‹⋀I::'a ⇒ bool option. length (trace_parallel_plan_strips I []) ≤ length [] + (1::nat)›*)<close>
lemma plan_is_at_least_singleton_plan_if_trace_has_at_least_two_elements:
assumes "k < length (trace_parallel_plan_strips I π) - 1"
obtains ops π' where "π = ops # π'"
proof (-)
(*goal: ‹(⋀ops π'. π = ops # π' ⟹ thesis) ⟹ thesis›*)
let ?τ = "trace_parallel_plan_strips I π"
have "length ?τ ≤ length π + 1"
using length_trace_parallel_plan_strips_lte_length_plan_plus_one (*‹length (trace_parallel_plan_strips (?I::?'a::type ⇒ bool option) (?π::?'a strips_operator list list)) ≤ length ?π + (1::nat)›*) by fast
then have "0 < length π"
using trace_parallel_plan_strips_length_gt_one_if (*‹?k < length (trace_parallel_plan_strips ?I ?π) - 1 ⟹ 1 < length (trace_parallel_plan_strips ?I ?π)›*) assms (*‹k < length (trace_parallel_plan_strips I π) - 1›*) by force
then obtain k' where "length π = Suc k'"
(*goal: ‹(⋀k'. length π = Suc k' ⟹ thesis) ⟹ thesis›*)
using gr0_implies_Suc (*‹0 < ?n ⟹ ∃m. ?n = Suc m›*) by meson
thus "?thesis"
(*goal: ‹thesis›*)
using that (*‹(π::'a strips_operator list list) = (?ops::'a strips_operator list) # (?π'::'a strips_operator list list) ⟹ thesis::bool›*) using length_Suc_conv[of π k'] (*‹(length π = Suc k') = (∃y ys. π = y # ys ∧ length ys = k')›*) by blast
qed<close>
corollary length_trace_parallel_plan_strips_lt_length_plan_plus_one_then:
assumes "length (trace_parallel_plan_strips I π) < length π + 1"
shows "¬are_all_operators_applicable
(execute_parallel_plan I (take (length (trace_parallel_plan_strips I π) - 1) π))
(π ! (length (trace_parallel_plan_strips I π) - 1))
∨ ¬are_all_operator_effects_consistent (π ! (length (trace_parallel_plan_strips I π) - 1))"
using assms (*‹length (trace_parallel_plan_strips I π) < length π + 1›*) proof (induction π arbitrary: I)
(*goals:
1. ‹⋀I. length (trace_parallel_plan_strips I []) < length [] + 1 ⟹ ¬ are_all_operators_applicable (execute_parallel_plan I (take (length (trace_parallel_plan_strips I []) - 1) [])) ([] ! (length (trace_parallel_plan_strips I []) - 1)) ∨ ¬ are_all_operator_effects_consistent ([] ! (length (trace_parallel_plan_strips I []) - 1))›
2. ‹⋀a π I. ⟦⋀I. length (trace_parallel_plan_strips I π) < length π + 1 ⟹ ¬ are_all_operators_applicable (execute_parallel_plan I (take (length (trace_parallel_plan_strips I π) - 1) π)) (π ! (length (trace_parallel_plan_strips I π) - 1)) ∨ ¬ are_all_operator_effects_consistent (π ! (length (trace_parallel_plan_strips I π) - 1)); length (trace_parallel_plan_strips I (a # π)) < length (a # π) + 1⟧ ⟹ ¬ are_all_operators_applicable (execute_parallel_plan I (take (length (trace_parallel_plan_strips I (a # π)) - 1) (a # π))) ((a # π) ! (length (trace_parallel_plan_strips I (a # π)) - 1)) ∨ ¬ are_all_operator_effects_consistent ((a # π) ! (length (trace_parallel_plan_strips I (a # π)) - 1))›*)
case (Cons ops π) (*‹length (trace_parallel_plan_strips ?I π) < length π + 1 ⟹ ¬ are_all_operators_applicable (execute_parallel_plan ?I (take (length (trace_parallel_plan_strips ?I π) - 1) π)) (π ! (length (trace_parallel_plan_strips ?I π) - 1)) ∨ ¬ are_all_operator_effects_consistent (π ! (length (trace_parallel_plan_strips ?I π) - 1))› ‹length (trace_parallel_plan_strips I (ops # π)) < length (ops # π) + 1›*)
let ?τ = "trace_parallel_plan_strips I (ops # π)" and ?I' = "execute_parallel_operator I ops"
show "?case"
(*goal: ‹¬ are_all_operators_applicable (execute_parallel_plan I (take (length (trace_parallel_plan_strips I (ops # π)) - 1) (ops # π))) ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1)) ∨ ¬ are_all_operator_effects_consistent ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1))›*)
proof (cases "are_all_operators_applicable I ops ∧ are_all_operator_effects_consistent ops")
(*goals:
1. ‹are_all_operators_applicable I ops ∧ are_all_operator_effects_consistent ops ⟹ ¬ are_all_operators_applicable (execute_parallel_plan I (take (length (trace_parallel_plan_strips I (ops # π)) - 1) (ops # π))) ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1)) ∨ ¬ are_all_operator_effects_consistent ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1))›
2. ‹¬ (are_all_operators_applicable I ops ∧ are_all_operator_effects_consistent ops) ⟹ ¬ are_all_operators_applicable (execute_parallel_plan I (take (length (trace_parallel_plan_strips I (ops # π)) - 1) (ops # π))) ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1)) ∨ ¬ are_all_operator_effects_consistent ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1))›*)
case True (*‹are_all_operators_applicable I ops ∧ are_all_operator_effects_consistent ops›*)
then have "τ_is": "?τ = I # trace_parallel_plan_strips ?I' π"
by fastforce
show "?thesis"
(*goal: ‹¬ are_all_operators_applicable (execute_parallel_plan I (take (length (trace_parallel_plan_strips I (ops # π)) - 1) (ops # π))) ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1)) ∨ ¬ are_all_operator_effects_consistent ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1))›*)
proof (cases "length (trace_parallel_plan_strips ?I' π) < length π + 1")
(*goals:
1. ‹length (trace_parallel_plan_strips (execute_parallel_operator I ops) π) < length π + 1 ⟹ ¬ are_all_operators_applicable (execute_parallel_plan I (take (length (trace_parallel_plan_strips I (ops # π)) - 1) (ops # π))) ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1)) ∨ ¬ are_all_operator_effects_consistent ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1))›
2. ‹¬ length (trace_parallel_plan_strips (execute_parallel_operator I ops) π) < length π + 1 ⟹ ¬ are_all_operators_applicable (execute_parallel_plan I (take (length (trace_parallel_plan_strips I (ops # π)) - 1) (ops # π))) ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1)) ∨ ¬ are_all_operator_effects_consistent ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1))›*)
case True (*‹length (trace_parallel_plan_strips (execute_parallel_operator I ops) π) < length π + 1›*)
then have "¬ are_all_operators_applicable
(execute_parallel_plan ?I'
(take (length (trace_parallel_plan_strips ?I' π) - 1) π))
(π ! (length (trace_parallel_plan_strips ?I' π) - 1))
∨ ¬ are_all_operator_effects_consistent
(π ! (length (trace_parallel_plan_strips ?I' π) - 1))"
using Cons.IH[of ?I'] (*‹length (trace_parallel_plan_strips (execute_parallel_operator I ops) π) < length π + 1 ⟹ ¬ are_all_operators_applicable (execute_parallel_plan (execute_parallel_operator I ops) (take (length (trace_parallel_plan_strips (execute_parallel_operator I ops) π) - 1) π)) (π ! (length (trace_parallel_plan_strips (execute_parallel_operator I ops) π) - 1)) ∨ ¬ are_all_operator_effects_consistent (π ! (length (trace_parallel_plan_strips (execute_parallel_operator I ops) π) - 1))›*) by blast
moreover have "trace_parallel_plan_strips ?I' π ≠ []"
using trace_parallel_plan_strips_not_nil (*‹trace_parallel_plan_strips (?I::?'a ⇒ bool option) (?π::?'a strips_operator list list) ≠ []›*) by blast
ultimately show "?thesis"
(*goal: ‹¬ are_all_operators_applicable (execute_parallel_plan I (take (length (trace_parallel_plan_strips I (ops # π)) - 1) (ops # π))) ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1)) ∨ ¬ are_all_operator_effects_consistent ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1))›*)
unfolding take_Cons'
(*goal: ‹¬ are_all_operators_applicable (execute_parallel_plan I (if length (trace_parallel_plan_strips I (ops # π)) - 1 = 0 then [] else ops # take (length (trace_parallel_plan_strips I (ops # π)) - 1 - 1) π)) ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1)) ∨ ¬ are_all_operator_effects_consistent ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1))›*)
by simp
next
(*goal: ‹¬ length (trace_parallel_plan_strips (execute_parallel_operator I ops) π) < length π + 1 ⟹ ¬ are_all_operators_applicable (execute_parallel_plan I (take (length (trace_parallel_plan_strips I (ops # π)) - 1) (ops # π))) ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1)) ∨ ¬ are_all_operator_effects_consistent ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1))›*)
case False (*‹¬ length (trace_parallel_plan_strips (execute_parallel_operator I ops) π) < length π + 1›*)
then have "length (trace_parallel_plan_strips ?I' π) ≥ length π + 1"
by fastforce
thm Cons.prems
moreover have "length (trace_parallel_plan_strips I (ops # π))
= 1 + length (trace_parallel_plan_strips ?I' π)"
using True (*‹are_all_operators_applicable I ops ∧ are_all_operator_effects_consistent ops›*) by force
moreover have "length (trace_parallel_plan_strips ?I' π)
< length (ops # π)"
using Cons.prems (*‹length (trace_parallel_plan_strips I (ops # π)) < length (ops # π) + 1›*) calculation(2) (*‹length (trace_parallel_plan_strips I (ops # π)) = 1 + length (trace_parallel_plan_strips (execute_parallel_operator I ops) π)›*) by force
ultimately have False
by fastforce
thus "?thesis"
(*goal: ‹¬ are_all_operators_applicable (execute_parallel_plan I (take (length (trace_parallel_plan_strips I (ops # π)) - 1) (ops # π))) ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1)) ∨ ¬ are_all_operator_effects_consistent ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1))›*)
by standard
qed
next
(*goal: ‹¬ (are_all_operators_applicable I ops ∧ are_all_operator_effects_consistent ops) ⟹ ¬ are_all_operators_applicable (execute_parallel_plan I (take (length (trace_parallel_plan_strips I (ops # π)) - 1) (ops # π))) ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1)) ∨ ¬ are_all_operator_effects_consistent ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - 1))›*)
case False (*‹¬ (are_all_operators_applicable I ops ∧ are_all_operator_effects_consistent ops)›*)
then have "τ_is_singleton": "?τ = [I]"
using False (*‹¬ (are_all_operators_applicable (I::'a::type ⇒ bool option) (ops::'a strips_operator list) ∧ are_all_operator_effects_consistent ops)›*) by auto
then have "ops = (ops # π) ! (length ?τ - 1)"
by fastforce
moreover have "execute_parallel_plan I (take (length ?τ - 1) π) = I"
using "τ_is_singleton" (*‹trace_parallel_plan_strips (I::'a ⇒ bool option) ((ops::'a strips_operator list) # (π::'a strips_operator list list)) = [I]›*) by auto
ultimately show "?thesis"
(*goal: ‹¬ are_all_operators_applicable (execute_parallel_plan (I::'a ⇒ bool option) (take (length (trace_parallel_plan_strips I ((ops::'a strips_operator list) # (π::'a strips_operator list list))) - (1::nat)) (ops # π))) ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - (1::nat))) ∨ ¬ are_all_operator_effects_consistent ((ops # π) ! (length (trace_parallel_plan_strips I (ops # π)) - (1::nat)))›*)
using False (*‹¬ (are_all_operators_applicable I ops ∧ are_all_operator_effects_consistent ops)›*) by auto
qed
qed (simp)
(*solved the remaining goal: ‹⋀I. length (trace_parallel_plan_strips I []) < length [] + 1 ⟹ ¬ are_all_operators_applicable (execute_parallel_plan I (take (length (trace_parallel_plan_strips I []) - 1) [])) ([] ! (length (trace_parallel_plan_strips I []) - 1)) ∨ ¬ are_all_operator_effects_consistent ([] ! (length (trace_parallel_plan_strips I []) - 1))›*)
lemma trace_parallel_plan_step_effect_is:
assumes "k < length (trace_parallel_plan_strips I π) - 1"
shows "trace_parallel_plan_strips I π ! Suc k
= execute_parallel_operator (trace_parallel_plan_strips I π ! k) (π ! k)"
proof (-)
(*goal: ‹trace_parallel_plan_strips I π ! Suc k = execute_parallel_operator (trace_parallel_plan_strips I π ! k) (π ! k)›*)
{
let ?τ = "trace_parallel_plan_strips I π"
have "Suc k < length ?τ"
using assms (*‹k < length (trace_parallel_plan_strips I π) - 1›*) by linarith
hence "trace_parallel_plan_strips I π ! Suc k
= execute_parallel_plan I (take (Suc k) π)"
using trace_parallel_plan_plan_prefix[of "Suc k" I π] (*‹Suc (k::nat) < length (trace_parallel_plan_strips (I::'a::type ⇒ bool option) (π::'a strips_operator list list)) ⟹ trace_parallel_plan_strips I π ! Suc k = execute_parallel_plan I (take (Suc k) π)›*) by blast
}
moreover have "execute_parallel_plan I (take (Suc k) π)
= execute_parallel_operator (trace_parallel_plan_strips I π ! k) (π ! k)"
using assms (*‹k < length (trace_parallel_plan_strips I π) - 1›*) proof (induction k arbitrary: I π)
(*goals:
1. ‹⋀I π. 0 < length (trace_parallel_plan_strips I π) - 1 ⟹ execute_parallel_plan I (take (Suc 0) π) = execute_parallel_operator (trace_parallel_plan_strips I π ! 0) (π ! 0)›
2. ‹⋀k I π. ⟦⋀I π. k < length (trace_parallel_plan_strips I π) - 1 ⟹ execute_parallel_plan I (take (Suc k) π) = execute_parallel_operator (trace_parallel_plan_strips I π ! k) (π ! k); Suc k < length (trace_parallel_plan_strips I π) - 1⟧ ⟹ execute_parallel_plan I (take (Suc (Suc k)) π) = execute_parallel_operator (trace_parallel_plan_strips I π ! Suc k) (π ! Suc k)›*)
case 0 (*‹0 < length (trace_parallel_plan_strips I π) - 1›*)
then have "execute_parallel_operator (trace_parallel_plan_strips I π ! 0) (π ! 0)
= execute_parallel_operator I (π ! 0)"
using trace_parallel_plan_strips_head_is_initial_state[of I π] (*‹trace_parallel_plan_strips I π ! 0 = I›*) by argo
moreover {
obtain ops and π' where "π = ops # π'"
(*goal: ‹(⋀ops π''. π = ops # π'' ⟹ thesis) ⟹ thesis›*)
using plan_is_at_least_singleton_plan_if_trace_has_at_least_two_elements[OF "0.prems"] (*‹(⋀ops π''. π = ops # π'' ⟹ ?thesis) ⟹ ?thesis›*) by blast
then have "take (Suc 0) π = [π ! 0]"
by simp
hence "execute_parallel_plan I (take (Suc 0) π)
= execute_parallel_plan I [π ! 0]"
by argo
}
moreover {
have "0 < length (trace_parallel_plan_strips I π) - 1"
using trace_parallel_plan_strips_length_gt_one_if (*‹(?k::nat) < length (trace_parallel_plan_strips (?I::?'a ⇒ bool option) (?π::?'a strips_operator list list)) - (1::nat) ⟹ (1::nat) < length (trace_parallel_plan_strips ?I ?π)›*) "0.prems" (*‹0 < length (trace_parallel_plan_strips I π) - 1›*) by fastforce
hence "are_all_operators_applicable I (π ! 0)
∧ are_all_operator_effects_consistent (π ! 0)"
using trace_parallel_plan_strips_operator_preconditions[of 0 I π] (*‹0 < length (trace_parallel_plan_strips I π) - 1 ⟹ are_all_operators_applicable (trace_parallel_plan_strips I π ! 0) (π ! 0) ∧ are_all_operator_effects_consistent (π ! 0)›*) trace_parallel_plan_strips_head_is_initial_state[of I π] (*‹trace_parallel_plan_strips (I::'a ⇒ bool option) (π::'a strips_operator list list) ! (0::nat) = I›*) by argo
}
ultimately show "?case"
(*goal: ‹execute_parallel_plan I (take (Suc 0) π) = execute_parallel_operator (trace_parallel_plan_strips I π ! 0) (π ! 0)›*)
by auto
next
(*goal: ‹⋀k I π. ⟦⋀I π. k < length (trace_parallel_plan_strips I π) - 1 ⟹ execute_parallel_plan I (take (Suc k) π) = execute_parallel_operator (trace_parallel_plan_strips I π ! k) (π ! k); Suc k < length (trace_parallel_plan_strips I π) - 1⟧ ⟹ execute_parallel_plan I (take (Suc (Suc k)) π) = execute_parallel_operator (trace_parallel_plan_strips I π ! Suc k) (π ! Suc k)›*)
case (Suc k) (*‹k < length (trace_parallel_plan_strips ?I ?π) - 1 ⟹ execute_parallel_plan ?I (take (Suc k) ?π) = execute_parallel_operator (trace_parallel_plan_strips ?I ?π ! k) (?π ! k)› ‹Suc k < length (trace_parallel_plan_strips I π) - 1›*)
obtain ops and π' where "π_split": "π = ops # π'"
(*goal: ‹(⋀ops π''. π = ops # π'' ⟹ thesis) ⟹ thesis›*)
using plan_is_at_least_singleton_plan_if_trace_has_at_least_two_elements[OF Suc.prems] (*‹(⋀ops π''. π = ops # π'' ⟹ ?thesis) ⟹ ?thesis›*) by blast
let ?I' = "execute_parallel_operator I ops"
{
have "length (trace_parallel_plan_strips I π) =
1 + length (trace_parallel_plan_strips ?I' π')"
using Suc.prems (*‹Suc k < length (trace_parallel_plan_strips I π) - 1›*) "π_split" (*‹(π::'a strips_operator list list) = (ops::'a strips_operator list) # (π'::'a strips_operator list list)›*) by fastforce
then have "k < length (trace_parallel_plan_strips ?I' π')"
using Suc.prems (*‹Suc k < length (trace_parallel_plan_strips I π) - 1›*) by fastforce
moreover have "trace_parallel_plan_strips I π ! Suc k
= trace_parallel_plan_strips ?I' π' ! k"
using Suc.prems (*‹Suc k < length (trace_parallel_plan_strips I π) - 1›*) "π_split" (*‹π = ops # π'›*) by force
ultimately have "trace_parallel_plan_strips I π ! Suc k
= execute_parallel_plan ?I' (take k π')"
using trace_parallel_plan_plan_prefix[of k ?I' π'] (*‹k < length (trace_parallel_plan_strips (execute_parallel_operator I ops) π') ⟹ trace_parallel_plan_strips (execute_parallel_operator I ops) π' ! k = execute_parallel_plan (execute_parallel_operator I ops) (take k π')›*) by argo
}
moreover have "execute_parallel_plan I (take (Suc (Suc k)) π)
= execute_parallel_plan ?I' (take (Suc k) π')"
using Suc.prems (*‹Suc k < length (trace_parallel_plan_strips I π) - 1›*) "π_split" (*‹π = ops # π'›*) by fastforce
moreover {
have "0 < length (trace_parallel_plan_strips I π) - 1"
using Suc.prems (*‹Suc k < length (trace_parallel_plan_strips I π) - 1›*) by linarith
hence "are_all_operators_applicable I (π ! 0)
∧ are_all_operator_effects_consistent (π ! 0)"
using trace_parallel_plan_strips_operator_preconditions[of 0 I π] (*‹0 < length (trace_parallel_plan_strips I π) - 1 ⟹ are_all_operators_applicable (trace_parallel_plan_strips I π ! 0) (π ! 0) ∧ are_all_operator_effects_consistent (π ! 0)›*) trace_parallel_plan_strips_head_is_initial_state[of I π] (*‹trace_parallel_plan_strips I π ! 0 = I›*) by argo
}
ultimately show "?case"
(*goal: ‹execute_parallel_plan I (take (Suc (Suc k)) π) = execute_parallel_operator (trace_parallel_plan_strips I π ! Suc k) (π ! Suc k)›*)
using Suc.IH (*‹k < length (trace_parallel_plan_strips ?I ?π) - 1 ⟹ execute_parallel_plan ?I (take (Suc k) ?π) = execute_parallel_operator (trace_parallel_plan_strips ?I ?π ! k) (?π ! k)›*) Suc.prems (*‹Suc k < length (trace_parallel_plan_strips I π) - 1›*) "π_split" (*‹π = ops # π'›*) by auto
qed
ultimately show "?thesis"
(*goal: ‹trace_parallel_plan_strips I π ! Suc k = execute_parallel_operator (trace_parallel_plan_strips I π ! k) (π ! k)›*)
using assms (*‹k < length (trace_parallel_plan_strips I π) - 1›*) by argo
qed<close>
(* TODO refactor ‹STRIPS_Semantics› + abstract/concretize first two assumptions (e.g. second one
only needs all operators are problem operators)? *)
lemma trace_parallel_plan_strips_none_if:
fixes Π:: "'a strips_problem"
assumes "is_valid_problem_strips Π"
and "is_parallel_solution_for_problem Π π"
and "k < length (trace_parallel_plan_strips ((Π)⇩I) π)"
shows "(trace_parallel_plan_strips ((Π)⇩I) π ! k) v = None ⟷ v ∉ set ((Π)⇩𝒱)"
proof (-)
(*goal: ‹((trace_parallel_plan_strips (Π⇩I) π ! k) v = None) = (v ∉ set (Π⇩𝒱))›*)
let ?vs = "strips_problem.variables_of Π" and ?ops = "strips_problem.operators_of Π" and ?τ = "trace_parallel_plan_strips ((Π)⇩I) π" and ?I = "strips_problem.initial_of Π"
show "?thesis"
(*goal: ‹((trace_parallel_plan_strips ((Π::'a strips_problem)⇩I) (π::'a strips_operator list list) ! (k::nat)) (v::'a::type) = None) = (v ∉ set (Π⇩𝒱))›*)
using assms (*‹is_valid_problem_strips Π› ‹is_parallel_solution_for_problem Π π› ‹(k::nat) < length (trace_parallel_plan_strips ((Π::'a strips_problem)⇩I) (π::'a strips_operator list list))›*) proof (induction k)
(*goals:
1. ‹⟦is_valid_problem_strips Π; is_parallel_solution_for_problem Π π; 0 < length (trace_parallel_plan_strips (Π⇩I) π)⟧ ⟹ ((trace_parallel_plan_strips (Π⇩I) π ! 0) v = None) = (v ∉ set (Π⇩𝒱))›
2. ‹⋀k. ⟦⟦is_valid_problem_strips Π; is_parallel_solution_for_problem Π π; k < length (trace_parallel_plan_strips (Π⇩I) π)⟧ ⟹ ((trace_parallel_plan_strips (Π⇩I) π ! k) v = None) = (v ∉ set (Π⇩𝒱)); is_valid_problem_strips Π; is_parallel_solution_for_problem Π π; Suc k < length (trace_parallel_plan_strips (Π⇩I) π)⟧ ⟹ ((trace_parallel_plan_strips (Π⇩I) π ! Suc k) v = None) = (v ∉ set (Π⇩𝒱))›*)
case 0 (*‹is_valid_problem_strips Π› ‹is_parallel_solution_for_problem (Π::'a strips_problem) (π::'a strips_operator list list)› ‹0 < length (trace_parallel_plan_strips (Π⇩I) π)›*)
have "?τ ! 0 = ?I"
using trace_parallel_plan_strips_head_is_initial_state (*‹trace_parallel_plan_strips ?I ?π ! 0 = ?I›*) by auto
then show "?case"
(*goal: ‹((trace_parallel_plan_strips (Π⇩I) π ! 0) v = None) = (v ∉ set (Π⇩𝒱))›*)
using is_valid_problem_strips_initial_of_dom[OF assms ( 1 )] (*‹dom (Π⇩I) = set (Π⇩𝒱)›*) by auto
next
(*goal: ‹⋀k::nat. ⟦⟦is_valid_problem_strips (Π::'a strips_problem); is_parallel_solution_for_problem Π (π::'a strips_operator list list); k < length (trace_parallel_plan_strips (Π⇩I) π)⟧ ⟹ ((trace_parallel_plan_strips (Π⇩I) π ! k) (v::'a) = None) = (v ∉ set (Π⇩𝒱)); is_valid_problem_strips Π; is_parallel_solution_for_problem Π π; Suc k < length (trace_parallel_plan_strips (Π⇩I) π)⟧ ⟹ ((trace_parallel_plan_strips (Π⇩I) π ! Suc k) v = None) = (v ∉ set (Π⇩𝒱))›*)
case (Suc k) (*‹⟦is_valid_problem_strips Π; is_parallel_solution_for_problem Π π; k < length (trace_parallel_plan_strips (Π⇩I) π)⟧ ⟹ ((trace_parallel_plan_strips (Π⇩I) π ! k) v = None) = (v ∉ set (Π⇩𝒱))› ‹is_valid_problem_strips Π› ‹is_parallel_solution_for_problem Π π› ‹Suc k < length (trace_parallel_plan_strips (Π⇩I) π)›*)
have "k_lt_length_τ_minus_one": "k < length ?τ - 1"
using Suc.prems(3) (*‹Suc (k::nat) < length (trace_parallel_plan_strips ((Π::'a strips_problem)⇩I) (π::'a strips_operator list list))›*) by linarith
then have IH: "(trace_parallel_plan_strips ?I π ! k) v = None ⟷ v ∉set ((Π)⇩𝒱)"
using Suc.IH[OF Suc.prems ( 1 , 2 )] (*‹(k::nat) < length (trace_parallel_plan_strips ((Π::'a strips_problem)⇩I) (π::'a strips_operator list list)) ⟹ ((trace_parallel_plan_strips (Π⇩I) π ! k) (v::'a) = None) = (v ∉ set (Π⇩𝒱))›*) by force
have "τ_Suc_k_is": "(?τ ! Suc k) = execute_parallel_operator (?τ ! k) (π ! k)"
using trace_parallel_plan_step_effect_is[OF k_lt_length_τ_minus_one] (*‹trace_parallel_plan_strips (Π⇩I) π ! Suc k = execute_parallel_operator (trace_parallel_plan_strips (Π⇩I) π ! k) (π ! k)›*) .
have all_operators_applicable: "are_all_operators_applicable (?τ ! k) (π ! k)" and all_effects_consistent: "are_all_operator_effects_consistent (π ! k)"
using trace_parallel_plan_strips_operator_preconditions[OF k_lt_length_τ_minus_one] (*‹are_all_operators_applicable (trace_parallel_plan_strips (Π⇩I) π ! k) (π ! k) ∧ are_all_operator_effects_consistent (π ! k)›*) apply -
(*goals:
1. ‹are_all_operators_applicable (trace_parallel_plan_strips (Π⇩I) π ! k) (π ! k) ∧ are_all_operator_effects_consistent (π ! k) ⟹ are_all_operators_applicable (trace_parallel_plan_strips (Π⇩I) π ! k) (π ! k)›
2. ‹are_all_operators_applicable (trace_parallel_plan_strips (Π⇩I) π ! k) (π ! k) ∧ are_all_operator_effects_consistent (π ! k) ⟹ are_all_operator_effects_consistent (π ! k)›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
show "?case"
(*goal: ‹((trace_parallel_plan_strips (Π⇩I) π ! Suc k) v = None) = (v ∉ set (Π⇩𝒱))›*)
proof (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))
(*goals:
1. ‹(trace_parallel_plan_strips (Π⇩I) π ! Suc k) v = None ⟹ v ∉ set (Π⇩𝒱)›
2. ‹v ∉ set (Π⇩𝒱) ⟹ (trace_parallel_plan_strips (Π⇩I) π ! Suc k) v = None›*)
assume "τ_Suc_k_of_v_is_None": "(?τ ! Suc k) v = None" (*‹(trace_parallel_plan_strips ((Π::'a strips_problem)⇩I) (π::'a strips_operator list list) ! Suc (k::nat)) (v::'a) = None›*)
show "v ∉ set ((Π)⇩𝒱)"
proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*))
(*goal: ‹¬ v ∉ set (Π⇩𝒱) ⟹ False›*)
assume "¬v ∉ set ((Π)⇩𝒱)" (*‹¬ (v::'a) ∉ set ((Π::'a strips_problem)⇩𝒱)›*)
then have v_in_set_vs: "v ∈ set((Π)⇩𝒱)"
by blast
show False
proof (cases "∃op ∈ set (π ! k).
v ∈ set (add_effects_of op) ∨ v ∈ set (delete_effects_of op)")
(*goals:
1. ‹∃op∈set (π ! k). v ∈ set (add_effects_of op) ∨ v ∈ set (delete_effects_of op) ⟹ False›
2. ‹¬ (∃op∈set (π ! k). v ∈ set (add_effects_of op) ∨ v ∈ set (delete_effects_of op)) ⟹ False›*)
case True (*‹∃op∈set (π ! k). v ∈ set (add_effects_of op) ∨ v ∈ set (delete_effects_of op)›*)
then obtain op where "op_in_π⇩k": "op ∈ set (π ! k)" and "v ∈ set (add_effects_of op) ∨ v ∈ set (delete_effects_of op)"
(*goal: ‹(⋀op. ⟦op ∈ set (π ! k); v ∈ set (add_effects_of op) ∨ v ∈ set (delete_effects_of op)⟧ ⟹ thesis) ⟹ thesis›*)
by standard
then consider (A)"v ∈ set (add_effects_of op)" | (B)"v ∈ set (delete_effects_of op)"
(*goal: ‹⟦v ∈ set (add_effects_of op) ⟹ thesis; v ∈ set (delete_effects_of op) ⟹ thesis⟧ ⟹ thesis›*)
by blast
thus False
using execute_parallel_operator_positive_effect_if[OF all_operators_applicable all_effects_consistent op_in_π⇩k] (*‹?v ∈ set (add_effects_of op) ⟹ execute_parallel_operator (trace_parallel_plan_strips (Π⇩I) π ! k) (π ! k) ?v = Some True›*) execute_parallel_operator_negative_effect_if[OF all_operators_applicable all_effects_consistent op_in_π⇩k] (*‹(?v::'a) ∈ set (delete_effects_of (op::'a strips_operator)) ⟹ execute_parallel_operator (trace_parallel_plan_strips ((Π::'a strips_problem)⇩I) (π::'a strips_operator list list) ! (k::nat)) (π ! k) ?v = Some False›*) "τ_Suc_k_of_v_is_None" (*‹(trace_parallel_plan_strips (Π⇩I) π ! Suc k) v = None›*) "τ_Suc_k_is" (*‹trace_parallel_plan_strips (Π⇩I) π ! Suc k = execute_parallel_operator (trace_parallel_plan_strips (Π⇩I) π ! k) (π ! k)›*) apply cases
(*goals:
1. ‹⟦⋀v::'a. v ∈ set (add_effects_of (op::'a strips_operator)) ⟹ execute_parallel_operator (trace_parallel_plan_strips ((Π::'a strips_problem)⇩I) (π::'a strips_operator list list) ! (k::nat)) (π ! k) v = Some True; ⋀v::'a. v ∈ set (delete_effects_of op) ⟹ execute_parallel_operator (trace_parallel_plan_strips (Π⇩I) π ! k) (π ! k) v = Some False; (trace_parallel_plan_strips (Π⇩I) π ! Suc k) (v::'a) = None; trace_parallel_plan_strips (Π⇩I) π ! Suc k = execute_parallel_operator (trace_parallel_plan_strips (Π⇩I) π ! k) (π ! k); v ∈ set (add_effects_of op)⟧ ⟹ False›
2. ‹⟦⋀v::'a. v ∈ set (add_effects_of (op::'a strips_operator)) ⟹ execute_parallel_operator (trace_parallel_plan_strips ((Π::'a strips_problem)⇩I) (π::'a strips_operator list list) ! (k::nat)) (π ! k) v = Some True; ⋀v::'a. v ∈ set (delete_effects_of op) ⟹ execute_parallel_operator (trace_parallel_plan_strips (Π⇩I) π ! k) (π ! k) v = Some False; (trace_parallel_plan_strips (Π⇩I) π ! Suc k) (v::'a) = None; trace_parallel_plan_strips (Π⇩I) π ! Suc k = execute_parallel_operator (trace_parallel_plan_strips (Π⇩I) π ! k) (π ! k); v ∈ set (delete_effects_of op)⟧ ⟹ False›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply fastforce
(*proven 2 subgoals*) .
next
(*goal: ‹¬ (∃op::'a strips_operator∈set ((π::'a strips_operator list list) ! (k::nat)). (v::'a) ∈ set (add_effects_of op) ∨ v ∈ set (delete_effects_of op)) ⟹ False›*)
case False (*‹¬ (∃op∈set (π ! k). v ∈ set (add_effects_of op) ∨ v ∈ set (delete_effects_of op))›*)
then have "∀op ∈ set (π ! k).
v ∉ set (add_effects_of op) ∧ v ∉ set (delete_effects_of op)"
by blast
then have "(?τ ! Suc k) v = (?τ ! k) v"
using execute_parallel_operator_no_effect_if (*‹∀op::?'a strips_operator∈set (?ops::?'a strips_operator list). (?v::?'a) ∉ set (add_effects_of op) ∧ ?v ∉ set (delete_effects_of op) ⟹ execute_parallel_operator (?s::?'a ⇒ bool option) ?ops ?v = ?s ?v›*) "τ_Suc_k_is" (*‹trace_parallel_plan_strips (Π⇩I) π ! Suc k = execute_parallel_operator (trace_parallel_plan_strips (Π⇩I) π ! k) (π ! k)›*) by fastforce
then have "v ∉ set ((Π)⇩𝒱)"
using IH (*‹((trace_parallel_plan_strips (Π⇩I) π ! k) v = None) = (v ∉ set (Π⇩𝒱))›*) "τ_Suc_k_of_v_is_None" (*‹(trace_parallel_plan_strips (Π⇩I) π ! Suc k) v = None›*) by simp
thus False
using v_in_set_vs (*‹v ∈ set (Π⇩𝒱)›*) by blast
qed
qed
next
(*goal: ‹v ∉ set (Π⇩𝒱) ⟹ (trace_parallel_plan_strips (Π⇩I) π ! Suc k) v = None›*)
assume v_notin_vs: "v ∉ set ((Π)⇩𝒱)" (*‹(v::'a) ∉ set ((Π::'a strips_problem)⇩𝒱)›*)
{
fix op
assume "op_in_π⇩k": "op ∈ set (π ! k)" (*‹(op::'a strips_operator) ∈ set ((π::'a strips_operator list list) ! (k::nat))›*)
{
have "1 < length ?τ"
using trace_parallel_plan_strips_length_gt_one_if[OF k_lt_length_τ_minus_one] (*‹1 < length (trace_parallel_plan_strips (Π⇩I) π)›*) .
then have "0 < length ?τ - 1"
using "k_lt_length_τ_minus_one" (*‹k < length (trace_parallel_plan_strips (Π⇩I) π) - 1›*) by linarith
moreover have "length ?τ - 1 ≤ length π"
using length_trace_parallel_plan_strips_lte_length_plan_plus_one (*‹length (trace_parallel_plan_strips (?I::?'a ⇒ bool option) (?π::?'a strips_operator list list)) ≤ length ?π + (1::nat)›*) le_diff_conv (*‹(?j - ?k ≤ ?i) = (?j ≤ ?i + ?k)›*) by blast
then have "k < length π"
using "k_lt_length_τ_minus_one" (*‹(k::nat) < length (trace_parallel_plan_strips ((Π::'a strips_problem)⇩I) (π::'a strips_operator list list)) - (1::nat)›*) by force
hence "π ! k ∈ set π"
by simp
}
then have op_in_ops: "op ∈ set ?ops"
using is_parallel_solution_for_problem_operator_set[OF assms ( 2 ) _ op_in_π⇩k] (*‹π ! k ∈ set π ⟹ op ∈ set (Π⇩𝒪)›*) by force
hence "v ∉ set (add_effects_of op)" and "v ∉ set (delete_effects_of op)"
subgoal for
using is_valid_problem_strips_operator_variable_sets(2) (*‹⟦is_valid_problem_strips ?Π; ?op ∈ set (?Π⇩𝒪)⟧ ⟹ set (add_effects_of ?op) ⊆ set (?Π⇩𝒱)›*) assms(1) (*‹is_valid_problem_strips Π›*) op_in_ops (*‹op ∈ set (Π⇩𝒪)›*) v_notin_vs (*‹(v::'a) ∉ set ((Π::'a strips_problem)⇩𝒱)›*) by auto
subgoal for
using is_valid_problem_strips_operator_variable_sets(3) (*‹⟦is_valid_problem_strips ?Π; ?op ∈ set (?Π⇩𝒪)⟧ ⟹ set (delete_effects_of ?op) ⊆ set (?Π⇩𝒱)›*) assms(1) (*‹is_valid_problem_strips Π›*) op_in_ops (*‹op ∈ set (Π⇩𝒪)›*) v_notin_vs (*‹v ∉ set (Π⇩𝒱)›*) by auto .
}
then have "(?τ ! Suc k) v = (?τ ! k) v"
using execute_parallel_operator_no_effect_if (*‹∀op∈set ?ops. ?v ∉ set (add_effects_of op) ∧ ?v ∉ set (delete_effects_of op) ⟹ execute_parallel_operator ?s ?ops ?v = ?s ?v›*) "τ_Suc_k_is" (*‹trace_parallel_plan_strips (Π⇩I) π ! Suc k = execute_parallel_operator (trace_parallel_plan_strips (Π⇩I) π ! k) (π ! k)›*) by metis
thus "(?τ ! Suc k) v = None"
using IH (*‹((trace_parallel_plan_strips (Π⇩I) π ! k) v = None) = (v ∉ set (Π⇩𝒱))›*) v_notin_vs (*‹v ∉ set (Π⇩𝒱)›*) by fastforce
qed
qed
qed
text ‹ Finally, given initial and goal states \<^term>‹I› and \<^term>‹G›, we can show that it's
equivalent to say that \<^term>‹π› is a solution for \<^term>‹I› and \<^term>‹G›---i.e.
\<^term>‹G ⊆⇩m execute_parallel_plan I π›---and
that the goal state is subsumed by the last element of the trace of \<^term>‹π› with initial state
\<^term>‹I›. ›
lemma execute_parallel_plan_reaches_goal_iff_goal_is_last_element_of_trace:
"G ⊆⇩m execute_parallel_plan I π
⟷ G ⊆⇩m last (trace_parallel_plan_strips I π)"
proof (-)
(*goal: ‹(G ⊆⇩m execute_parallel_plan I π) = (G ⊆⇩m last (trace_parallel_plan_strips I π))›*)
let ?LHS = "G ⊆⇩m execute_parallel_plan I π" and ?RHS = "G ⊆⇩m last (trace_parallel_plan_strips I π)"
show "?thesis"
(*goal: ‹(G ⊆⇩m execute_parallel_plan I π) = (G ⊆⇩m last (trace_parallel_plan_strips I π))›*)
proof (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))
(*goals:
1. ‹G ⊆⇩m execute_parallel_plan I π ⟹ G ⊆⇩m last (trace_parallel_plan_strips I π)›
2. ‹G ⊆⇩m last (trace_parallel_plan_strips I π) ⟹ G ⊆⇩m execute_parallel_plan I π›*)
assume "?LHS" (*‹(G::'a ⇒ bool option) ⊆⇩m execute_parallel_plan (I::'a ⇒ bool option) (π::'a strips_operator list list)›*)
thus "?RHS"
proof (induction π arbitrary: I)
(*goals:
1. ‹⋀I. G ⊆⇩m execute_parallel_plan I [] ⟹ G ⊆⇩m last (trace_parallel_plan_strips I [])›
2. ‹⋀a π I. ⟦⋀I. G ⊆⇩m execute_parallel_plan I π ⟹ G ⊆⇩m last (trace_parallel_plan_strips I π); G ⊆⇩m execute_parallel_plan I (a # π)⟧ ⟹ G ⊆⇩m last (trace_parallel_plan_strips I (a # π))›*)
case (Cons a π) (*‹G ⊆⇩m execute_parallel_plan ?I π ⟹ G ⊆⇩m last (trace_parallel_plan_strips ?I π)› ‹G ⊆⇩m execute_parallel_plan I (a # π)›*)
thus "?case"
(*goal: ‹G ⊆⇩m last (trace_parallel_plan_strips I (a # π))›*)
using Cons.prems (*‹G ⊆⇩m execute_parallel_plan I (a # π)›*) proof (cases "are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a")
(*goals:
1. ‹⟦⋀I. G ⊆⇩m execute_parallel_plan I π ⟹ G ⊆⇩m last (trace_parallel_plan_strips I π); G ⊆⇩m execute_parallel_plan I (a # π); G ⊆⇩m execute_parallel_plan I (a # π); are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a⟧ ⟹ G ⊆⇩m last (trace_parallel_plan_strips I (a # π))›
2. ‹⟦⋀I. G ⊆⇩m execute_parallel_plan I π ⟹ G ⊆⇩m last (trace_parallel_plan_strips I π); G ⊆⇩m execute_parallel_plan I (a # π); G ⊆⇩m execute_parallel_plan I (a # π); ¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a)⟧ ⟹ G ⊆⇩m last (trace_parallel_plan_strips I (a # π))›*)
case True (*‹are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a›*)
let ?I' = "execute_parallel_operator I a"
{
have "execute_parallel_plan I (a # π) = execute_parallel_plan ?I' π"
using True (*‹are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a›*) by auto
then have "G ⊆⇩m execute_parallel_plan ?I' π"
using Cons.prems (*‹G ⊆⇩m execute_parallel_plan I (a # π)›*) by presburger
hence "G ⊆⇩m last (trace_parallel_plan_strips ?I' π)"
using Cons.IH[of ?I'] (*‹G ⊆⇩m execute_parallel_plan (execute_parallel_operator I a) π ⟹ G ⊆⇩m last (trace_parallel_plan_strips (execute_parallel_operator I a) π)›*) by blast
}
moreover {
have "trace_parallel_plan_strips I (a # π)
= I # trace_parallel_plan_strips ?I' π"
using True (*‹are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a›*) by simp
then have "last (trace_parallel_plan_strips I (a # π))
= last (I # trace_parallel_plan_strips ?I' π)"
by argo
hence "last (trace_parallel_plan_strips I (a # π))
= last (trace_parallel_plan_strips ?I' π)"
using trace_parallel_plan_strips_last_cons_then[of I ?I' π] (*‹last ((I::'a::type ⇒ bool option) # trace_parallel_plan_strips (execute_parallel_operator I (a::'a strips_operator list)) (π::'a strips_operator list list)) = last (trace_parallel_plan_strips (execute_parallel_operator I a) π)›*) by argo
}
ultimately show "?thesis"
(*goal: ‹G ⊆⇩m last (trace_parallel_plan_strips I (a # π))›*)
by argo
qed (force)
(*solved the remaining goal: ‹⟦⋀I. G ⊆⇩m execute_parallel_plan I π ⟹ G ⊆⇩m last (trace_parallel_plan_strips I π); G ⊆⇩m execute_parallel_plan I (a # π); G ⊆⇩m execute_parallel_plan I (a # π); ¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a)⟧ ⟹ G ⊆⇩m last (trace_parallel_plan_strips I (a # π))›*)
qed (simp)
(*solved the remaining goal: ‹⋀I. G ⊆⇩m execute_parallel_plan I [] ⟹ G ⊆⇩m last (trace_parallel_plan_strips I [])›*)
next
(*goal: ‹G ⊆⇩m last (trace_parallel_plan_strips I π) ⟹ G ⊆⇩m execute_parallel_plan I π›*)
assume "?RHS" (*‹(G::'a ⇒ bool option) ⊆⇩m last (trace_parallel_plan_strips (I::'a ⇒ bool option) (π::'a strips_operator list list))›*)
thus "?LHS"
proof (induction π arbitrary: I)
(*goals:
1. ‹⋀I::'a ⇒ bool option. (G::'a ⇒ bool option) ⊆⇩m last (trace_parallel_plan_strips I []) ⟹ G ⊆⇩m execute_parallel_plan I []›
2. ‹⋀(a::'a strips_operator list) (π::'a strips_operator list list) I::'a ⇒ bool option. ⟦⋀I::'a ⇒ bool option. (G::'a ⇒ bool option) ⊆⇩m last (trace_parallel_plan_strips I π) ⟹ G ⊆⇩m execute_parallel_plan I π; G ⊆⇩m last (trace_parallel_plan_strips I (a # π))⟧ ⟹ G ⊆⇩m execute_parallel_plan I (a # π)›*)
case (Cons a π) (*‹G ⊆⇩m last (trace_parallel_plan_strips ?I π) ⟹ G ⊆⇩m execute_parallel_plan ?I π› ‹G ⊆⇩m last (trace_parallel_plan_strips I (a # π))›*)
thus "?case"
(*goal: ‹G ⊆⇩m execute_parallel_plan I (a # π)›*)
proof (cases "are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a")
(*goals:
1. ‹⟦⋀I::'a ⇒ bool option. (G::'a ⇒ bool option) ⊆⇩m last (trace_parallel_plan_strips I (π::'a strips_operator list list)) ⟹ G ⊆⇩m execute_parallel_plan I π; G ⊆⇩m last (trace_parallel_plan_strips (I::'a ⇒ bool option) ((a::'a strips_operator list) # π)); are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a⟧ ⟹ G ⊆⇩m execute_parallel_plan I (a # π)›
2. ‹⟦⋀I::'a ⇒ bool option. (G::'a ⇒ bool option) ⊆⇩m last (trace_parallel_plan_strips I (π::'a strips_operator list list)) ⟹ G ⊆⇩m execute_parallel_plan I π; G ⊆⇩m last (trace_parallel_plan_strips (I::'a ⇒ bool option) ((a::'a strips_operator list) # π)); ¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a)⟧ ⟹ G ⊆⇩m execute_parallel_plan I (a # π)›*)
case True (*‹are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a›*)
let ?I' = "execute_parallel_operator I a"
{
have "trace_parallel_plan_strips I (a # π) = I # (trace_parallel_plan_strips ?I' π)"
using True (*‹are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a›*) by simp
then have "last (trace_parallel_plan_strips I (a # π))
= last (trace_parallel_plan_strips ?I' π)"
using trace_parallel_plan_strips_last_cons_then[of I ?I' π] (*‹last (I # trace_parallel_plan_strips (execute_parallel_operator I a) π) = last (trace_parallel_plan_strips (execute_parallel_operator I a) π)›*) by argo
hence "G ⊆⇩m last (trace_parallel_plan_strips ?I' π)"
using Cons.prems (*‹G ⊆⇩m last (trace_parallel_plan_strips I (a # π))›*) by argo
}
thus "?thesis"
(*goal: ‹(G::'a ⇒ bool option) ⊆⇩m execute_parallel_plan (I::'a ⇒ bool option) ((a::'a strips_operator list) # (π::'a strips_operator list list))›*)
using True (*‹are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a›*) Cons (*‹G ⊆⇩m last (trace_parallel_plan_strips ?I π) ⟹ G ⊆⇩m execute_parallel_plan ?I π› ‹G ⊆⇩m last (trace_parallel_plan_strips I (a # π))›*) by simp
next
(*goal: ‹⟦⋀I. G ⊆⇩m last (trace_parallel_plan_strips I π) ⟹ G ⊆⇩m execute_parallel_plan I π; G ⊆⇩m last (trace_parallel_plan_strips I (a # π)); ¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a)⟧ ⟹ G ⊆⇩m execute_parallel_plan I (a # π)›*)
case False (*‹¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a)›*)
then have "last (trace_parallel_plan_strips I (a # π)) = I" and "execute_parallel_plan I (a # π) = I"
apply -
(*goals:
1. ‹¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a) ⟹ last (trace_parallel_plan_strips I (a # π)) = I›
2. ‹¬ (are_all_operators_applicable I a ∧ are_all_operator_effects_consistent a) ⟹ execute_parallel_plan I (a # π) = I›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply force
(*proven 2 subgoals*) .
thus "?thesis"
(*goal: ‹G ⊆⇩m execute_parallel_plan I (a # π)›*)
using Cons.prems (*‹(G::'a ⇒ bool option) ⊆⇩m last (trace_parallel_plan_strips (I::'a ⇒ bool option) ((a::'a strips_operator list) # (π::'a strips_operator list list)))›*) by argo
qed
qed (fastforce)
(*solved the remaining goal: ‹⋀I. G ⊆⇩m last (trace_parallel_plan_strips I []) ⟹ G ⊆⇩m execute_parallel_plan I []›*)
qed
qed
subsection "Serializable Parallel Plans"
text ‹ With the groundwork on parallel and serial execution of STRIPS in place we can now address
the question under which conditions a parallel solution to a problem corresponds to a serial
solution and vice versa.
As we will see (in theorem \ref{isathm:embedding-serial-strips-plan}), while a serial plan can
be trivially rewritten as a parallel plan consisting of singleton operator list for each operator
in the plan, the condition for parallel plan solutions also involves non interference. ›
― ‹ Given that non interference implies that operator execution order can be switched
arbitrarily, it stands to reason that parallel operator execution can be serialized if non
interference is mandated in addition to the regular parallel execution condition (applicability and
effect consistency). This is in fact true as we show in the lemma below
\footnote{In the source literatur it is required that $\mathrm{app}_S(s)$ is defined which requires that
$\mathrm{app}_o(s)$ is defined for every $o \in S$. This again means that the preconditions
hold in $s$ and the set of effects is consistent which translates to the execution condition
in ‹execute_parallel_operator›.
\cite[Lemma 2.11., p.1037]{DBLP:journals/ai/RintanenHN06}
Also, the proposition \cite[Lemma 2.11., p.1037]{DBLP:journals/ai/RintanenHN06} is in fact
proposed to be true for any total ordering of the operator set but we only proof it for the
implicit total ordering induced by the specific order in the operator list of the problem
statement.} ›
(* TODO rename execute_parallel_operator_equals_execute_serial_if *)
lemma execute_parallel_operator_equals_execute_sequential_strips_if:
fixes s :: "('variable, bool) state"
assumes "are_all_operators_applicable s ops"
and "are_all_operator_effects_consistent ops"
and "are_all_operators_non_interfering ops"
shows "execute_parallel_operator s ops = execute_serial_plan s ops"
using assms (*‹are_all_operators_applicable s ops› ‹are_all_operator_effects_consistent ops› ‹are_all_operators_non_interfering ops›*) proof (induction ops arbitrary: s)
(*goals:
1. ‹⋀s. ⟦are_all_operators_applicable s []; are_all_operator_effects_consistent []; are_all_operators_non_interfering []⟧ ⟹ execute_parallel_operator s [] = execute_serial_plan s []›
2. ‹⋀a ops s. ⟦⋀s. ⟦are_all_operators_applicable s ops; are_all_operator_effects_consistent ops; are_all_operators_non_interfering ops⟧ ⟹ execute_parallel_operator s ops = execute_serial_plan s ops; are_all_operators_applicable s (a # ops); are_all_operator_effects_consistent (a # ops); are_all_operators_non_interfering (a # ops)⟧ ⟹ execute_parallel_operator s (a # ops) = execute_serial_plan s (a # ops)›*)
case Nil (*‹are_all_operators_applicable s []› ‹are_all_operator_effects_consistent []› ‹are_all_operators_non_interfering []›*)
have "execute_parallel_operator s Nil
= foldl (++) s (map (map_of ∘ effect_to_assignments) Nil)"
using Nil.prems(1,2) (*‹are_all_operators_applicable s []› ‹are_all_operator_effects_consistent []›*) unfolding execute_parallel_operator_def
(*goal: ‹foldl (++) s (map (map_of ∘ effect_to_assignments) []) = foldl (++) s (map (map_of ∘ effect_to_assignments) [])›*)
by presburger
also (*calculation: ‹execute_parallel_operator s [] = foldl (++) s (map (map_of ∘ effect_to_assignments) [])›*) have "… = s"
by simp
finally (*calculation: ‹execute_parallel_operator s [] = s›*) have "execute_parallel_operator s Nil = s"
by blast
moreover have "execute_serial_plan s Nil = s"
by auto
ultimately show "?case"
(*goal: ‹execute_parallel_operator s [] = execute_serial_plan s []›*)
by simp
next
(*goal: ‹⋀a ops s. ⟦⋀s. ⟦are_all_operators_applicable s ops; are_all_operator_effects_consistent ops; are_all_operators_non_interfering ops⟧ ⟹ execute_parallel_operator s ops = execute_serial_plan s ops; are_all_operators_applicable s (a # ops); are_all_operator_effects_consistent (a # ops); are_all_operators_non_interfering (a # ops)⟧ ⟹ execute_parallel_operator s (a # ops) = execute_serial_plan s (a # ops)›*)
case (Cons a ops) (*‹⟦are_all_operators_applicable (?s::'variable ⇒ bool option) (ops::'variable strips_operator list); are_all_operator_effects_consistent ops; are_all_operators_non_interfering ops⟧ ⟹ execute_parallel_operator ?s ops = execute_serial_plan ?s ops› ‹are_all_operators_applicable s (a # ops)› ‹are_all_operator_effects_consistent (a # ops)› ‹are_all_operators_non_interfering (a # ops)›*)
have a: "is_operator_applicable_in s a"
using are_all_operators_applicable_cons (*‹are_all_operators_applicable (?s::?'a::type ⇒ bool option) ((?op::?'a strips_operator) # (?ops::?'a strips_operator list)) ⟹ is_operator_applicable_in ?s ?op› ‹are_all_operators_applicable ?s (?op # ?ops) ⟹ are_all_operators_applicable ?s ?ops›*) Cons.prems(1) (*‹are_all_operators_applicable s (a # ops)›*) by blast
let ?s' = "s ++ map_of (effect_to_assignments a)"
{
from Cons.prems (*‹are_all_operators_applicable s (a # ops)› ‹are_all_operator_effects_consistent (a # ops)› ‹are_all_operators_non_interfering (a # ops)›*) have "are_all_operators_applicable ?s' ops" and "are_all_operator_effects_consistent ops" and "are_all_operators_non_interfering ops"
using execute_parallel_plan_precondition_cons (*‹⟦are_all_operators_applicable ?s (?a # ?ops); are_all_operator_effects_consistent (?a # ?ops); are_all_operators_non_interfering (?a # ?ops)⟧ ⟹ are_all_operators_applicable (?s ++ map_of (effect_to_assignments ?a)) ?ops› ‹⟦are_all_operators_applicable ?s (?a # ?ops); are_all_operator_effects_consistent (?a # ?ops); are_all_operators_non_interfering (?a # ?ops)⟧ ⟹ are_all_operator_effects_consistent ?ops› ‹⟦are_all_operators_applicable ?s (?a # ?ops); are_all_operator_effects_consistent (?a # ?ops); are_all_operators_non_interfering (?a # ?ops)⟧ ⟹ are_all_operators_non_interfering ?ops›*) apply -
(*goals:
1. ‹⟦are_all_operators_applicable s (a # ops); are_all_operator_effects_consistent (a # ops); are_all_operators_non_interfering (a # ops); ⋀s a ops. ⟦are_all_operators_applicable s (a # ops); are_all_operator_effects_consistent (a # ops); are_all_operators_non_interfering (a # ops)⟧ ⟹ are_all_operators_applicable (s ++ map_of (effect_to_assignments a)) ops; ⋀s a ops. ⟦are_all_operators_applicable s (a # ops); are_all_operator_effects_consistent (a # ops); are_all_operators_non_interfering (a # ops)⟧ ⟹ are_all_operator_effects_consistent ops; ⋀s a ops. ⟦are_all_operators_applicable s (a # ops); are_all_operator_effects_consistent (a # ops); are_all_operators_non_interfering (a # ops)⟧ ⟹ are_all_operators_non_interfering ops⟧ ⟹ are_all_operators_applicable (s ++ map_of (effect_to_assignments a)) ops›
2. ‹⟦are_all_operators_applicable s (a # ops); are_all_operator_effects_consistent (a # ops); are_all_operators_non_interfering (a # ops); ⋀s a ops. ⟦are_all_operators_applicable s (a # ops); are_all_operator_effects_consistent (a # ops); are_all_operators_non_interfering (a # ops)⟧ ⟹ are_all_operators_applicable (s ++ map_of (effect_to_assignments a)) ops; ⋀s a ops. ⟦are_all_operators_applicable s (a # ops); are_all_operator_effects_consistent (a # ops); are_all_operators_non_interfering (a # ops)⟧ ⟹ are_all_operator_effects_consistent ops; ⋀s a ops. ⟦are_all_operators_applicable s (a # ops); are_all_operator_effects_consistent (a # ops); are_all_operators_non_interfering (a # ops)⟧ ⟹ are_all_operators_non_interfering ops⟧ ⟹ are_all_operator_effects_consistent ops›
3. ‹⟦are_all_operators_applicable s (a # ops); are_all_operator_effects_consistent (a # ops); are_all_operators_non_interfering (a # ops); ⋀s a ops. ⟦are_all_operators_applicable s (a # ops); are_all_operator_effects_consistent (a # ops); are_all_operators_non_interfering (a # ops)⟧ ⟹ are_all_operators_applicable (s ++ map_of (effect_to_assignments a)) ops; ⋀s a ops. ⟦are_all_operators_applicable s (a # ops); are_all_operator_effects_consistent (a # ops); are_all_operators_non_interfering (a # ops)⟧ ⟹ are_all_operator_effects_consistent ops; ⋀s a ops. ⟦are_all_operators_applicable s (a # ops); are_all_operator_effects_consistent (a # ops); are_all_operators_non_interfering (a # ops)⟧ ⟹ are_all_operators_non_interfering ops⟧ ⟹ are_all_operators_non_interfering ops›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*discuss goal 3*)
apply blast
(*proven 3 subgoals*) .
then have "execute_serial_plan ?s' ops
= execute_parallel_operator ?s' ops"
using Cons.IH (*‹⟦are_all_operators_applicable ?s ops; are_all_operator_effects_consistent ops; are_all_operators_non_interfering ops⟧ ⟹ execute_parallel_operator ?s ops = execute_serial_plan ?s ops›*) by presburger
}
moreover from Cons.prems (*‹are_all_operators_applicable s (a # ops)› ‹are_all_operator_effects_consistent ((a::'variable strips_operator) # (ops::'variable strips_operator list))› ‹are_all_operators_non_interfering ((a::'variable strips_operator) # (ops::'variable strips_operator list))›*) have "execute_parallel_operator s (Cons a ops)
= execute_parallel_operator ?s' ops"
using execute_parallel_operator_cons_equals_corollary (*‹are_all_operators_applicable ?s (?a # ?ops) ⟹ execute_parallel_operator ?s (?a # ?ops) = execute_parallel_operator (?s ⪢ ?a) ?ops›*) unfolding execute_operator_def
(*goal: ‹execute_parallel_operator (s::'variable::type ⇒ bool option) ((a::'variable strips_operator) # (ops::'variable strips_operator list)) = execute_parallel_operator (s ++ map_of (effect_to_assignments a)) ops›*)
by simp
moreover from a (*‹is_operator_applicable_in s a›*) have "execute_serial_plan s (Cons a ops)
= execute_serial_plan ?s' ops"
unfolding execute_serial_plan_def execute_operator_def is_operator_applicable_in_def
(*goal: ‹rec_list (λs::'variable::type ⇒ bool option. s) (λ(op::'variable strips_operator) (ops::'variable strips_operator list) (opsa::('variable::type ⇒ bool option) ⇒ 'variable::type ⇒ bool option) s::'variable::type ⇒ bool option. if Let (precondition_of op) (list_all (λv::'variable::type. s v = Some True)) then opsa (s ++ map_of (effect_to_assignments op)) else s) ((a::'variable strips_operator) # (ops::'variable strips_operator list)) (s::'variable::type ⇒ bool option) = rec_list (λs::'variable::type ⇒ bool option. s) (λ(op::'variable strips_operator) (ops::'variable strips_operator list) (opsa::('variable::type ⇒ bool option) ⇒ 'variable::type ⇒ bool option) s::'variable::type ⇒ bool option. if Let (precondition_of op) (list_all (λv::'variable::type. s v = Some True)) then opsa (s ++ map_of (effect_to_assignments op)) else s) ops (s ++ map_of (effect_to_assignments a))›*)
by fastforce
ultimately show "?case"
(*goal: ‹execute_parallel_operator s (a # ops) = execute_serial_plan s (a # ops)›*)
by argo
qed
lemma execute_serial_plan_split_i:
assumes "are_all_operators_applicable s (op # π)"
and "are_all_operators_non_interfering (op # π)"
shows "are_all_operators_applicable (s ⪢ op) π"
using assms (*‹are_all_operators_applicable s (op # π)› ‹are_all_operators_non_interfering (op # π)›*) proof (induction π arbitrary: s)
(*goals:
1. ‹⋀s. ⟦are_all_operators_applicable s [op]; are_all_operators_non_interfering [op]⟧ ⟹ are_all_operators_applicable (s ⪢ op) []›
2. ‹⋀a π s. ⟦⋀s. ⟦are_all_operators_applicable s (op # π); are_all_operators_non_interfering (op # π)⟧ ⟹ are_all_operators_applicable (s ⪢ op) π; are_all_operators_applicable s (op # a # π); are_all_operators_non_interfering (op # a # π)⟧ ⟹ are_all_operators_applicable (s ⪢ op) (a # π)›*)
case Nil (*‹are_all_operators_applicable s [op]› ‹are_all_operators_non_interfering [op]›*)
then show "?case"
(*goal: ‹are_all_operators_applicable (s ⪢ op) []›*)
unfolding are_all_operators_applicable_def
(*goal: ‹list_all (is_operator_applicable_in ((s::'a::type ⇒ bool option) ⪢ (op::'a strips_operator))) []›*)
by simp
next
(*goal: ‹⋀a π s. ⟦⋀s. ⟦are_all_operators_applicable s (op # π); are_all_operators_non_interfering (op # π)⟧ ⟹ are_all_operators_applicable (s ⪢ op) π; are_all_operators_applicable s (op # a # π); are_all_operators_non_interfering (op # a # π)⟧ ⟹ are_all_operators_applicable (s ⪢ op) (a # π)›*)
case (Cons op' π) (*‹⟦are_all_operators_applicable ?s (op # π); are_all_operators_non_interfering (op # π)⟧ ⟹ are_all_operators_applicable (?s ⪢ op) π› ‹are_all_operators_applicable s (op # op' # π)› ‹are_all_operators_non_interfering (op # op' # π)›*)
let ?t = "s ⪢ op"
{
fix x
assume "x ∈ set (op' # π)" (*‹(x::'a strips_operator) ∈ set ((op'::'a strips_operator) # (π::'a strips_operator list))›*)
moreover have "op ∈ set (op # op' # π)"
by simp
moreover have "¬are_operators_interfering op x"
using Cons.prems(2) (*‹are_all_operators_non_interfering (op # op' # π)›*) calculation(1) (*‹x ∈ set (op' # π)›*) unfolding are_all_operators_non_interfering_def list_all_iff
(*goal: ‹¬ are_operators_interfering op x›*)
by fastforce
moreover have "is_operator_applicable_in s op"
using Cons.prems(1) (*‹are_all_operators_applicable s (op # op' # π)›*) unfolding are_all_operators_applicable_def list_all_iff is_operator_applicable_in_def
(*goal: ‹let p = precondition_of op in ∀v∈set p. s v = Some True›*)
by force
moreover have "is_operator_applicable_in s x"
using are_all_operators_applicable_cons(2)[OF Cons.prems ( 1 )] (*‹are_all_operators_applicable s (op' # π)›*) calculation(1) (*‹x ∈ set (op' # π)›*) unfolding are_all_operators_applicable_def list_all_iff is_operator_applicable_in_def
(*goal: ‹let p = precondition_of x in ∀v∈set p. s v = Some True›*)
by fast
ultimately have "is_operator_applicable_in ?t x"
using execute_parallel_plan_precondition_cons_i[of op x s] (*‹⟦¬ are_operators_interfering op x; is_operator_applicable_in s op; is_operator_applicable_in s x⟧ ⟹ is_operator_applicable_in (s ++ map_of (effect_to_assignments op)) x›*) by (auto simp: execute_operator_def (*‹?s ⪢ ?op ≡ ?s ++ map_of (effect_to_assignments ?op)›*))
}
thus "?case"
(*goal: ‹are_all_operators_applicable (s ⪢ op) (op' # π)›*)
using are_all_operators_applicable_cons(2) (*‹are_all_operators_applicable ?s (?op # ?ops) ⟹ are_all_operators_applicable ?s ?ops›*) unfolding is_operator_applicable_in_def STRIPS_Representation.is_operator_applicable_in_def are_all_operators_applicable_def list_all_iff
(*goal: ‹∀opa∈set (op' # π). let p = precondition_of opa in ∀v∈set p. (s ⪢ op) v = Some True›*)
by simp
qed<close>
lemma execute_serial_plan_split:
fixes s :: "('variable, bool) state"
assumes "are_all_operators_applicable s π₁"
and "are_all_operators_non_interfering π₁"
shows "execute_serial_plan s (π₁ @ π₂)
= execute_serial_plan (execute_serial_plan s π₁) π₂"
using assms (*‹are_all_operators_applicable (s::'variable::type ⇒ bool option) (π₁::'variable strips_operator list)› ‹are_all_operators_non_interfering π₁›*) proof (induction π₁ arbitrary: s)
(*goals:
1. ‹⋀s. ⟦are_all_operators_applicable s []; are_all_operators_non_interfering []⟧ ⟹ execute_serial_plan s ([] @ π₂) = execute_serial_plan (execute_serial_plan s []) π₂›
2. ‹⋀a π₁ s. ⟦⋀s. ⟦are_all_operators_applicable s π₁; are_all_operators_non_interfering π₁⟧ ⟹ execute_serial_plan s (π₁ @ π₂) = execute_serial_plan (execute_serial_plan s π₁) π₂; are_all_operators_applicable s (a # π₁); are_all_operators_non_interfering (a # π₁)⟧ ⟹ execute_serial_plan s ((a # π₁) @ π₂) = execute_serial_plan (execute_serial_plan s (a # π₁)) π₂›*)
case (Cons op π₁) (*‹⟦are_all_operators_applicable ?s π₁; are_all_operators_non_interfering π₁⟧ ⟹ execute_serial_plan ?s (π₁ @ π₂) = execute_serial_plan (execute_serial_plan ?s π₁) π₂› ‹are_all_operators_applicable s (op # π₁)› ‹are_all_operators_non_interfering (op # π₁)›*)
let ?t = "s ⪢ op"
{
have "are_all_operators_applicable (s ⪢ op) π₁"
using execute_serial_plan_split_i[OF Cons.prems ( 1 , 2 )] (*‹are_all_operators_applicable ((s::'variable::type ⇒ bool option) ⪢ (op::'variable strips_operator)) (π₁::'variable strips_operator list)›*) .
moreover have "are_all_operators_non_interfering π₁"
using are_all_operators_non_interfering_tail[OF Cons.prems ( 2 )] (*‹are_all_operators_non_interfering π₁›*) .
ultimately have "execute_serial_plan ?t (π₁ @ π₂) =
execute_serial_plan (execute_serial_plan ?t π₁) π₂"
using Cons.IH[of ?t] (*‹⟦are_all_operators_applicable ((s::'variable ⇒ bool option) ⪢ (op::'variable strips_operator)) (π₁::'variable strips_operator list); are_all_operators_non_interfering π₁⟧ ⟹ execute_serial_plan (s ⪢ op) (π₁ @ (π₂::'variable strips_operator list)) = execute_serial_plan (execute_serial_plan (s ⪢ op) π₁) π₂›*) by blast
}
moreover have "STRIPS_Representation.is_operator_applicable_in s op"
using Cons.prems(1) (*‹are_all_operators_applicable (s::'variable ⇒ bool option) ((op::'variable strips_operator) # (π₁::'variable strips_operator list))›*) unfolding are_all_operators_applicable_def list_all_iff
(*goal: ‹is_operator_applicable_in s op›*)
by fastforce
ultimately show "?case"
(*goal: ‹execute_serial_plan s ((op # π₁) @ π₂) = execute_serial_plan (execute_serial_plan s (op # π₁)) π₂›*)
unfolding execute_serial_plan_def
(*goal: ‹rec_list (λs. s) (λop ops opsa s. if is_operator_applicable_in s op then opsa (s ⪢ op) else s) ((op # π₁) @ π₂) s = rec_list (λs. s) (λop ops opsa s. if is_operator_applicable_in s op then opsa (s ⪢ op) else s) π₂ (rec_list (λs. s) (λop ops opsa s. if is_operator_applicable_in s op then opsa (s ⪢ op) else s) (op # π₁) s)›*)
by simp
qed (simp)
(*solved the remaining goal: ‹⋀s::'variable ⇒ bool option. ⟦are_all_operators_applicable s []; are_all_operators_non_interfering []⟧ ⟹ execute_serial_plan s ([] @ (π₂::'variable strips_operator list)) = execute_serial_plan (execute_serial_plan s []) π₂›*)
(* TODO refactor *)
lemma embedding_lemma_i:
fixes I :: "('variable, bool) state"
assumes "is_operator_applicable_in I op"
and "are_operator_effects_consistent op op"
shows "I ⪢ op = execute_parallel_operator I [op]"
proof (-)
(*goal: ‹I ⪢ op = execute_parallel_operator I [op]›*)
have "are_all_operators_applicable I [op]"
using assms(1) (*‹is_operator_applicable_in I op›*) unfolding are_all_operators_applicable_def list_all_iff is_operator_applicable_in_def
(*goal: ‹∀op::'variable strips_operator∈set [op::'variable strips_operator]. let p::'variable list = precondition_of op in ∀v::'variable∈set p. (I::'variable ⇒ bool option) v = Some True›*)
by fastforce
moreover have "are_all_operator_effects_consistent [op]"
unfolding are_all_operator_effects_consistent_def list_all_iff
(*goal: ‹∀opa∈set [op]. Ball (set [op]) (are_operator_effects_consistent opa)›*)
using assms(2) (*‹are_operator_effects_consistent op op›*) by fastforce
moreover have "are_all_operators_non_interfering [op]"
by simp
moreover have "I ⪢ op = execute_serial_plan I [op]"
using assms(1) (*‹is_operator_applicable_in I op›*) unfolding is_operator_applicable_in_def
(*goal: ‹I ⪢ op = execute_serial_plan I [op]›*)
by (simp add: assms( (*‹is_operator_applicable_in I op›*) 1) execute_operator_def (*‹?s ⪢ ?op ≡ ?s ++ map_of (effect_to_assignments ?op)›*))
ultimately show "?thesis"
(*goal: ‹I ⪢ op = execute_parallel_operator I [op]›*)
using execute_parallel_operator_equals_execute_sequential_strips_if (*‹⟦are_all_operators_applicable ?s ?ops; are_all_operator_effects_consistent ?ops; are_all_operators_non_interfering ?ops⟧ ⟹ execute_parallel_operator ?s ?ops = execute_serial_plan ?s ?ops›*) by force
qed
lemma execute_serial_plan_is_execute_parallel_plan_ii:
fixes I :: "'variable strips_state"
assumes "∀op ∈ set π. are_operator_effects_consistent op op"
and "G ⊆⇩m execute_serial_plan I π"
shows "G ⊆⇩m execute_parallel_plan I (embed π)"
proof (-)
(*goal: ‹G ⊆⇩m execute_parallel_plan I (List_Supplement.embed π)›*)
show "?thesis"
(*goal: ‹G ⊆⇩m execute_parallel_plan I (List_Supplement.embed π)›*)
using assms (*‹∀op::'variable strips_operator∈set (π::'variable strips_operator list). are_operator_effects_consistent op op› ‹G ⊆⇩m execute_serial_plan I π›*) proof (induction π arbitrary: I)
(*goals:
1. ‹⋀I. ⟦∀op∈set []. are_operator_effects_consistent op op; G ⊆⇩m execute_serial_plan I []⟧ ⟹ G ⊆⇩m execute_parallel_plan I (List_Supplement.embed [])›
2. ‹⋀a π I. ⟦⋀I. ⟦∀op∈set π. are_operator_effects_consistent op op; G ⊆⇩m execute_serial_plan I π⟧ ⟹ G ⊆⇩m execute_parallel_plan I (List_Supplement.embed π); ∀op∈set (a # π). are_operator_effects_consistent op op; G ⊆⇩m execute_serial_plan I (a # π)⟧ ⟹ G ⊆⇩m execute_parallel_plan I (List_Supplement.embed (a # π))›*)
case (Cons op π) (*‹⟦∀op∈set π. are_operator_effects_consistent op op; G ⊆⇩m execute_serial_plan ?I π⟧ ⟹ G ⊆⇩m execute_parallel_plan ?I (List_Supplement.embed π)› ‹∀op∈set (op # π). are_operator_effects_consistent op op› ‹G ⊆⇩m execute_serial_plan I (op # π)›*)
then show "?case"
(*goal: ‹G ⊆⇩m execute_parallel_plan I (List_Supplement.embed (op # π))›*)
proof (cases "is_operator_applicable_in I op")
(*goals:
1. ‹⟦⋀I::'variable::type ⇒ bool option. ⟦∀op::'variable strips_operator∈set (π::'variable strips_operator list). are_operator_effects_consistent op op; (G::'variable::type ⇒ bool option) ⊆⇩m execute_serial_plan I π⟧ ⟹ G ⊆⇩m execute_parallel_plan I (List_Supplement.embed π); ∀op::'variable strips_operator∈set ((op::'variable strips_operator) # π). are_operator_effects_consistent op op; G ⊆⇩m execute_serial_plan (I::'variable::type ⇒ bool option) (op # π); is_operator_applicable_in I op⟧ ⟹ G ⊆⇩m execute_parallel_plan I (List_Supplement.embed (op # π))›
2. ‹⟦⋀I::'variable::type ⇒ bool option. ⟦∀op::'variable strips_operator∈set (π::'variable strips_operator list). are_operator_effects_consistent op op; (G::'variable::type ⇒ bool option) ⊆⇩m execute_serial_plan I π⟧ ⟹ G ⊆⇩m execute_parallel_plan I (List_Supplement.embed π); ∀op::'variable strips_operator∈set ((op::'variable strips_operator) # π). are_operator_effects_consistent op op; G ⊆⇩m execute_serial_plan (I::'variable::type ⇒ bool option) (op # π); ¬ is_operator_applicable_in I op⟧ ⟹ G ⊆⇩m execute_parallel_plan I (List_Supplement.embed (op # π))›*)
case True (*‹is_operator_applicable_in I op›*)
let ?J = "I ⪢ op" and ?J' = "execute_parallel_operator I [op]"
{
have "G ⊆⇩m execute_serial_plan ?J π"
using Cons.prems(2) (*‹G ⊆⇩m execute_serial_plan I (op # π)›*) True (*‹is_operator_applicable_in I op›*) unfolding is_operator_applicable_in_def
(*goal: ‹G ⊆⇩m execute_serial_plan (I ⪢ op) π›*)
by (simp add: True (*‹is_operator_applicable_in I op›*))
hence "G ⊆⇩m execute_parallel_plan ?J (embed π)"
using Cons.IH[of ?J] (*‹⟦∀op∈set π. are_operator_effects_consistent op op; G ⊆⇩m execute_serial_plan (I ⪢ op) π⟧ ⟹ G ⊆⇩m execute_parallel_plan (I ⪢ op) (List_Supplement.embed π)›*) Cons.prems(1) (*‹∀op∈set (op # π). are_operator_effects_consistent op op›*) by fastforce
}
moreover {
have "are_all_operators_applicable I [op]"
using True (*‹is_operator_applicable_in I op›*) unfolding are_all_operators_applicable_def list_all_iff is_operator_applicable_in_def
(*goal: ‹∀op::'variable strips_operator∈set [op::'variable strips_operator]. let p::'variable list = precondition_of op in ∀v::'variable∈set p. (I::'variable ⇒ bool option) v = Some True›*)
by fastforce
moreover have "are_all_operator_effects_consistent [op]"
unfolding are_all_operator_effects_consistent_def list_all_iff
(*goal: ‹∀opa∈set [op]. Ball (set [op]) (are_operator_effects_consistent opa)›*)
using Cons.prems(1) (*‹∀op∈set (op # π). are_operator_effects_consistent op op›*) by fastforce
moreover have "?J = ?J'"
using execute_parallel_operator_equals_execute_sequential_strips_if[OF calculation ( 1 , 2 )] (*‹are_all_operators_non_interfering [op] ⟹ execute_parallel_operator I [op] = execute_serial_plan I [op]›*) Cons.prems(1) (*‹∀op∈set (op # π). are_operator_effects_consistent op op›*) True (*‹is_operator_applicable_in I op›*) unfolding is_operator_applicable_in_def
(*goal: ‹(I::'variable ⇒ bool option) ⪢ (op::'variable strips_operator) = execute_parallel_operator I [op]›*)
by (simp add: True (*‹is_operator_applicable_in I op›*))
ultimately have "execute_parallel_plan I (embed (op # π))
= execute_parallel_plan ?J (embed π)"
by fastforce
}
ultimately show "?thesis"
(*goal: ‹G ⊆⇩m execute_parallel_plan I (List_Supplement.embed (op # π))›*)
by presburger
next
(*goal: ‹⟦⋀I. ⟦∀op∈set π. are_operator_effects_consistent op op; G ⊆⇩m execute_serial_plan I π⟧ ⟹ G ⊆⇩m execute_parallel_plan I (List_Supplement.embed π); ∀op∈set (op # π). are_operator_effects_consistent op op; G ⊆⇩m execute_serial_plan I (op # π); ¬ is_operator_applicable_in I op⟧ ⟹ G ⊆⇩m execute_parallel_plan I (List_Supplement.embed (op # π))›*)
case False (*‹¬ is_operator_applicable_in I op›*)
then have "G ⊆⇩m I"
using Cons.prems (*‹∀op∈set (op # π). are_operator_effects_consistent op op› ‹G ⊆⇩m execute_serial_plan I (op # π)›*) is_operator_applicable_in_def (*‹is_operator_applicable_in (?s::?'variable ⇒ bool option) (?op::?'variable strips_operator) ≡ Let (precondition_of ?op) (list_all (λv::?'variable. ?s v = Some True))›*) by simp
moreover {
have "¬are_all_operators_applicable I [op]"
using False (*‹¬ is_operator_applicable_in I op›*) unfolding are_all_operators_applicable_def list_all_iff is_operator_applicable_in_def
(*goal: ‹¬ (∀op::'variable strips_operator∈set [op::'variable strips_operator]. let p::'variable::type list = precondition_of op in ∀v::'variable::type∈set p. (I::'variable::type ⇒ bool option) v = Some True)›*)
by force
hence "execute_parallel_plan I (embed (op # π)) = I"
by simp
}
ultimately show "?thesis"
(*goal: ‹G ⊆⇩m execute_parallel_plan I (List_Supplement.embed (op # π))›*)
by presburger
qed
qed (simp)
(*solved the remaining goal: ‹⋀I. ⟦∀op∈set []. are_operator_effects_consistent op op; G ⊆⇩m execute_serial_plan I []⟧ ⟹ G ⊆⇩m execute_parallel_plan I (List_Supplement.embed [])›*)
qed
lemma embedding_lemma_iii:
fixes Π:: "'a strips_problem"
assumes "∀op ∈ set π. op ∈ set ((Π)⇩𝒪)"
shows "∀ops ∈ set (embed π). ∀op ∈ set ops. op ∈ set ((Π)⇩𝒪)"
proof (-)
(*goal: ‹∀ops∈set (List_Supplement.embed π). ∀op∈set ops. op ∈ set (Π⇩𝒪)›*)
have nb: "set (embed π) = { [op] | op. op ∈ set π }"
apply (induction π)
(*goals:
1. ‹set (List_Supplement.embed []) = {[op] |op::'a strips_operator. op ∈ set []}›
2. ‹⋀(a::'a strips_operator) π::'a strips_operator list. set (List_Supplement.embed π) = {[op] |op::'a strips_operator. op ∈ set π} ⟹ set (List_Supplement.embed (a # π)) = {[op] |op::'a strips_operator. op ∈ set (a # π)}›
discuss goal 1*)
apply force
(*discuss goal 2*)
apply force
(*proven 2 subgoals*) .
{
fix ops
assume "ops ∈ set (embed π)" (*‹(ops::'a strips_operator list) ∈ set (List_Supplement.embed (π::'a strips_operator list))›*)
moreover obtain op where "op ∈ set π" and "ops = [op]"
(*goal: ‹(⋀op. ⟦op ∈ set π; ops = [op]⟧ ⟹ thesis) ⟹ thesis›*)
using nb (*‹set (List_Supplement.embed π) = {[op] |op. op ∈ set π}›*) calculation (*‹ops ∈ set (List_Supplement.embed π)›*) by blast
ultimately have "∀op ∈ set ops. op ∈ set ((Π)⇩𝒪)"
using assms(1) (*‹∀op::'a strips_operator∈set (π::'a strips_operator list). op ∈ set ((Π::'a strips_problem)⇩𝒪)›*) by simp
}
thus "?thesis"
(*goal: ‹∀ops::'a strips_operator list∈set (List_Supplement.embed (π::'a strips_operator list)). ∀op::'a strips_operator∈set ops. op ∈ set ((Π::'a strips_problem)⇩𝒪)›*)
apply -
(*goal: ‹∀ops∈set (List_Supplement.embed π). ∀op∈set ops. op ∈ set (Π⇩𝒪)›*)
by standard
qed
text ‹ We show in the following theorem that---as mentioned---a serial solution \<^term>‹π› to a
STRIPS problem \<^term>‹Π› corresponds directly to a parallel solution obtained by embedding each operator
in \<^term>‹π› in a list (by use of function \<^term>‹embed›). The proof shows this by first
confirming that
@{text[display, indent=4] "G ⊆⇩m execute_serial_plan ((Π)⇩I) π
⟹ G ⊆⇩m execute_serial_plan ((Π)⇩I) (embed π)"}
using lemma \isaname{execute_serial_plan_is_execute_parallel_plan_strip_ii}; and
moreover by showing that
@{text[display, indent=4] "∀ops ∈ set (embed π). ∀op ∈ set ops. op ∈ (Π)⇩𝒪"}
meaning that under the given assumptions, all parallel operators of the embedded serial plan are
again operators in the operator set of the problem. ›
theorem embedding_lemma:
assumes "is_valid_problem_strips Π"
and "is_serial_solution_for_problem Π π"
shows "is_parallel_solution_for_problem Π (embed π)"
proof (-)
(*goal: ‹is_parallel_solution_for_problem (Π::'a strips_problem) (List_Supplement.embed (π::'a strips_operator list))›*)
have "nb₁": "∀op ∈ set π. op ∈ set ((Π)⇩𝒪)"
using assms(2) (*‹is_serial_solution_for_problem (Π::'a strips_problem) (π::'a strips_operator list)›*) unfolding is_serial_solution_for_problem_def list_all_iff ListMem_iff operators_of_def
(*goal: ‹∀op::'a strips_operator∈set (π::'a strips_operator list). op ∈ set ((id ∘ Record.iso_tuple_snd Record.tuple_iso_tuple ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_fst strips_problem_ext_Tuple_Iso) (Π::'a strips_problem))›*)
by blast
{
fix op
assume "op ∈ set π" (*‹(op::'a strips_operator) ∈ set (π::'a strips_operator list)›*)
moreover have "op ∈ set ((Π)⇩𝒪)"
using "nb₁" (*‹∀op∈set π. op ∈ set (Π⇩𝒪)›*) calculation (*‹op ∈ set π›*) by fast
moreover have "is_valid_operator_strips Π op"
using assms(1) (*‹is_valid_problem_strips (Π::'a strips_problem)›*) calculation(2) (*‹op ∈ set (Π⇩𝒪)›*) unfolding is_valid_problem_strips_def is_valid_problem_strips_def list_all_iff operators_of_def
(*goal: ‹is_valid_operator_strips Π op›*)
by meson
moreover have "list_all (λv. ¬ListMem v (delete_effects_of op)) (add_effects_of op)" and "list_all (λv. ¬ListMem v (add_effects_of op)) (delete_effects_of op)"
using calculation(3) (*‹is_valid_operator_strips (Π::'a strips_problem) (op::'a strips_operator)›*) unfolding is_valid_operator_strips_def
(*goals:
1. ‹list_all (λv. ¬ ListMem v (delete_effects_of op)) (add_effects_of op)›
2. ‹list_all (λv. ¬ ListMem v (add_effects_of op)) (delete_effects_of op)›*)
apply -
(*goals:
1. ‹let vs = Π⇩𝒱; pre = precondition_of op; add = add_effects_of op; del = delete_effects_of op in list_all (λv. ListMem v vs) pre ∧ list_all (λv. ListMem v vs) add ∧ list_all (λv. ListMem v vs) del ∧ list_all (λv. ¬ ListMem v del) add ∧ list_all (λv. ¬ ListMem v add) del ⟹ list_all (λv. ¬ ListMem v (delete_effects_of op)) (add_effects_of op)›
2. ‹let vs = Π⇩𝒱; pre = precondition_of op; add = add_effects_of op; del = delete_effects_of op in list_all (λv. ListMem v vs) pre ∧ list_all (λv. ListMem v vs) add ∧ list_all (λv. ListMem v vs) del ∧ list_all (λv. ¬ ListMem v del) add ∧ list_all (λv. ¬ ListMem v add) del ⟹ list_all (λv. ¬ ListMem v (add_effects_of op)) (delete_effects_of op)›
discuss goal 1*)
apply meson
(*discuss goal 2*)
apply meson
(*proven 2 subgoals*) .
moreover have "¬list_ex (λv. ListMem v (delete_effects_of op)) (add_effects_of op)" and "¬list_ex (λv. ListMem v (add_effects_of op)) (delete_effects_of op)"
using calculation(4,5) (*‹list_all (λv. ¬ ListMem v (delete_effects_of op)) (add_effects_of op)› ‹list_all (λv::'a. ¬ ListMem v (add_effects_of (op::'a strips_operator))) (delete_effects_of op)›*) not_list_ex_equals_list_all_not (*‹(¬ list_ex ?P ?xs) = list_all (λx. ¬ ?P x) ?xs›*) apply -
(*goals:
1. ‹⟦list_all (λv. ¬ ListMem v (delete_effects_of op)) (add_effects_of op); list_all (λv. ¬ ListMem v (add_effects_of op)) (delete_effects_of op); ⋀P xs. (¬ list_ex P xs) = list_all (λx. ¬ P x) xs⟧ ⟹ ¬ list_ex (λv. ListMem v (delete_effects_of op)) (add_effects_of op)›
2. ‹⟦list_all (λv. ¬ ListMem v (delete_effects_of op)) (add_effects_of op); list_all (λv. ¬ ListMem v (add_effects_of op)) (delete_effects_of op); ⋀P xs. (¬ list_ex P xs) = list_all (λx. ¬ P x) xs⟧ ⟹ ¬ list_ex (λv. ListMem v (add_effects_of op)) (delete_effects_of op)›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
moreover have "¬list_ex (λv. list_ex ((=) v) (delete_effects_of op)) (add_effects_of op)" and "¬list_ex (λv. list_ex ((=) v) (add_effects_of op)) (delete_effects_of op)"
using calculation(6,7) (*‹¬ list_ex (λv. ListMem v (delete_effects_of op)) (add_effects_of op)› ‹¬ list_ex (λv. ListMem v (add_effects_of op)) (delete_effects_of op)›*) unfolding list_ex_iff ListMem_iff
(*goals:
1. ‹¬ (∃v∈set (add_effects_of op). Bex (set (delete_effects_of op)) ((=) v))›
2. ‹¬ (∃v∈set (delete_effects_of op). Bex (set (add_effects_of op)) ((=) v))›*)
apply -
(*goals:
1. ‹⟦¬ (∃v∈set (add_effects_of op). v ∈ set (delete_effects_of op)); ¬ (∃v∈set (delete_effects_of op). v ∈ set (add_effects_of op))⟧ ⟹ ¬ (∃v∈set (add_effects_of op). Bex (set (delete_effects_of op)) ((=) v))›
2. ‹⟦¬ (∃v∈set (add_effects_of op). v ∈ set (delete_effects_of op)); ¬ (∃v∈set (delete_effects_of op). v ∈ set (add_effects_of op))⟧ ⟹ ¬ (∃v∈set (delete_effects_of op). Bex (set (add_effects_of op)) ((=) v))›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
ultimately have "are_operator_effects_consistent op op"
unfolding are_operator_effects_consistent_def Let_def
(*goal: ‹¬ list_ex (λv. list_ex ((=) v) (delete_effects_of op)) (add_effects_of op) ∧ ¬ list_ex (λv. list_ex ((=) v) (add_effects_of op)) (delete_effects_of op)›*)
by blast
}
note "nb₂" = this (*‹?op2 ∈ set π ⟹ are_operator_effects_consistent ?op2 ?op2›*)
moreover {
have "(Π)⇩G ⊆⇩m execute_serial_plan ((Π)⇩I) π"
using assms(2) (*‹is_serial_solution_for_problem Π π›*) unfolding is_serial_solution_for_problem_def
(*goal: ‹Π⇩G ⊆⇩m execute_serial_plan (Π⇩I) π›*)
by simp
hence "(Π)⇩G ⊆⇩m execute_parallel_plan ((Π)⇩I) (embed π)"
using execute_serial_plan_is_execute_parallel_plan_ii (*‹⟦∀op∈set ?π. are_operator_effects_consistent op op; ?G ⊆⇩m execute_serial_plan ?I ?π⟧ ⟹ ?G ⊆⇩m execute_parallel_plan ?I (List_Supplement.embed ?π)›*) "nb₂" (*‹?op2 ∈ set π ⟹ are_operator_effects_consistent ?op2 ?op2›*) by blast
}
moreover have "∀ops ∈ set (embed π). ∀op ∈ set ops. op ∈ set ((Π)⇩𝒪)"
using embedding_lemma_iii[OF nb₁] (*‹∀ops∈set (List_Supplement.embed π). ∀op∈set ops. op ∈ set (Π⇩𝒪)›*) .
ultimately show "?thesis"
(*goal: ‹is_parallel_solution_for_problem Π (List_Supplement.embed π)›*)
unfolding is_parallel_solution_for_problem_def goal_of_def initial_of_def operators_of_def list_all_iff ListMem_iff
(*goal: ‹(id ∘ Record.iso_tuple_snd Record.tuple_iso_tuple ∘ Record.iso_tuple_snd Record.tuple_iso_tuple ∘ Record.iso_tuple_fst strips_problem_ext_Tuple_Iso) Π ⊆⇩m execute_parallel_plan ((id ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_snd Record.tuple_iso_tuple ∘ Record.iso_tuple_fst strips_problem_ext_Tuple_Iso) Π) (List_Supplement.embed π) ∧ (∀ops∈set (List_Supplement.embed π). ∀op∈set ops. op ∈ set ((id ∘ Record.iso_tuple_snd Record.tuple_iso_tuple ∘ Record.iso_tuple_fst Record.tuple_iso_tuple ∘ Record.iso_tuple_fst strips_problem_ext_Tuple_Iso) Π))›*)
by blast
qed
lemma flattening_lemma_i:
fixes Π:: "'a strips_problem"
assumes "∀ops ∈ set π. ∀op ∈ set ops. op ∈ set ((Π)⇩𝒪)"
shows "∀op ∈ set (concat π). op ∈ set ((Π)⇩𝒪)"
proof (-)
(*goal: ‹∀op∈set (concat π). op ∈ set (Π⇩𝒪)›*)
{
fix op
assume "op ∈ set (concat π)" (*‹(op::'a strips_operator) ∈ set (concat (π::'a strips_operator list list))›*)
moreover have "op ∈ (⋃ops ∈ set π. set ops)"
using calculation (*‹(op::'a strips_operator) ∈ set (concat (π::'a strips_operator list list))›*) unfolding set_concat
(*goal: ‹op ∈ ⋃ (set ` set π)›*) .
then obtain ops where "ops ∈ set π" and "op ∈ set ops"
(*goal: ‹(⋀ops. ⟦ops ∈ set π; op ∈ set ops⟧ ⟹ thesis) ⟹ thesis›*)
using UN_iff (*‹(?b ∈ ⋃ (?B ` ?A)) = (∃x∈?A. ?b ∈ ?B x)›*) by blast
ultimately have "op ∈ set ((Π)⇩𝒪)"
using assms (*‹∀ops∈set π. ∀op∈set ops. op ∈ set (Π⇩𝒪)›*) by blast
}
thus "?thesis"
(*goal: ‹∀op::'a strips_operator∈set (concat (π::'a strips_operator list list)). op ∈ set ((Π::'a strips_problem)⇩𝒪)›*)
by standard
qed
lemma flattening_lemma_ii:
fixes I :: "'variable strips_state"
assumes "∀ops ∈ set π. ∃op. ops = [op] ∧ is_valid_operator_strips Π op "
and "G ⊆⇩m execute_parallel_plan I π"
shows "G ⊆⇩m execute_serial_plan I (concat π)"
proof (-)
(*goal: ‹(G::'variable ⇒ bool option) ⊆⇩m execute_serial_plan (I::'variable ⇒ bool option) (concat (π::'variable strips_operator list list))›*)
let ?π' = "concat π"
{
fix op
assume "is_valid_operator_strips Π op" (*‹is_valid_operator_strips (Π::'variable strips_problem) (op::'variable strips_operator)›*)
moreover have "list_all (λv. ¬ListMem v (delete_effects_of op)) (add_effects_of op)" and "list_all (λv. ¬ListMem v (add_effects_of op)) (delete_effects_of op)"
using calculation(1) (*‹is_valid_operator_strips Π op›*) unfolding is_valid_operator_strips_def
(*goals:
1. ‹list_all (λv. ¬ ListMem v (delete_effects_of op)) (add_effects_of op)›
2. ‹list_all (λv. ¬ ListMem v (add_effects_of op)) (delete_effects_of op)›*)
apply -
(*goals:
1. ‹let vs = Π⇩𝒱; pre = precondition_of op; add = add_effects_of op; del = delete_effects_of op in list_all (λv. ListMem v vs) pre ∧ list_all (λv. ListMem v vs) add ∧ list_all (λv. ListMem v vs) del ∧ list_all (λv. ¬ ListMem v del) add ∧ list_all (λv. ¬ ListMem v add) del ⟹ list_all (λv. ¬ ListMem v (delete_effects_of op)) (add_effects_of op)›
2. ‹let vs = Π⇩𝒱; pre = precondition_of op; add = add_effects_of op; del = delete_effects_of op in list_all (λv. ListMem v vs) pre ∧ list_all (λv. ListMem v vs) add ∧ list_all (λv. ListMem v vs) del ∧ list_all (λv. ¬ ListMem v del) add ∧ list_all (λv. ¬ ListMem v add) del ⟹ list_all (λv. ¬ ListMem v (add_effects_of op)) (delete_effects_of op)›
discuss goal 1*)
apply meson
(*discuss goal 2*)
apply meson
(*proven 2 subgoals*) .
moreover have "¬list_ex (λv. ListMem v (delete_effects_of op)) (add_effects_of op)" and "¬list_ex (λv. ListMem v (add_effects_of op)) (delete_effects_of op)"
using calculation(2,3) (*‹list_all (λv. ¬ ListMem v (delete_effects_of op)) (add_effects_of op)› ‹list_all (λv. ¬ ListMem v (add_effects_of op)) (delete_effects_of op)›*) not_list_ex_equals_list_all_not (*‹(¬ list_ex (?P::?'a ⇒ bool) (?xs::?'a list)) = list_all (λx::?'a. ¬ ?P x) ?xs›*) apply -
(*goals:
1. ‹⟦list_all (λv::'variable. ¬ ListMem v (delete_effects_of (op::'variable strips_operator))) (add_effects_of op); list_all (λv::'variable. ¬ ListMem v (add_effects_of op)) (delete_effects_of op); ⋀(P::?'a6 ⇒ bool) xs::?'a6 list. (¬ list_ex P xs) = list_all (λx::?'a6. ¬ P x) xs⟧ ⟹ ¬ list_ex (λv::'variable. ListMem v (delete_effects_of op)) (add_effects_of op)›
2. ‹⟦list_all (λv::'variable. ¬ ListMem v (delete_effects_of (op::'variable strips_operator))) (add_effects_of op); list_all (λv::'variable. ¬ ListMem v (add_effects_of op)) (delete_effects_of op); ⋀(P::?'a2 ⇒ bool) xs::?'a2 list. (¬ list_ex P xs) = list_all (λx::?'a2. ¬ P x) xs⟧ ⟹ ¬ list_ex (λv::'variable. ListMem v (add_effects_of op)) (delete_effects_of op)›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
moreover have "¬list_ex (λv. list_ex ((=) v) (delete_effects_of op)) (add_effects_of op)" and "¬list_ex (λv. list_ex ((=) v) (add_effects_of op)) (delete_effects_of op)"
using calculation(4,5) (*‹¬ list_ex (λv. ListMem v (delete_effects_of op)) (add_effects_of op)› ‹¬ list_ex (λv. ListMem v (add_effects_of op)) (delete_effects_of op)›*) unfolding list_ex_iff ListMem_iff
(*goals:
1. ‹¬ (∃v∈set (add_effects_of op). Bex (set (delete_effects_of op)) ((=) v))›
2. ‹¬ (∃v∈set (delete_effects_of op). Bex (set (add_effects_of op)) ((=) v))›*)
apply -
(*goals:
1. ‹⟦¬ (∃v∈set (add_effects_of op). v ∈ set (delete_effects_of op)); ¬ (∃v∈set (delete_effects_of op). v ∈ set (add_effects_of op))⟧ ⟹ ¬ (∃v∈set (add_effects_of op). Bex (set (delete_effects_of op)) ((=) v))›
2. ‹⟦¬ (∃v∈set (add_effects_of op). v ∈ set (delete_effects_of op)); ¬ (∃v∈set (delete_effects_of op). v ∈ set (add_effects_of op))⟧ ⟹ ¬ (∃v∈set (delete_effects_of op). Bex (set (add_effects_of op)) ((=) v))›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
ultimately have "are_operator_effects_consistent op op"
unfolding are_operator_effects_consistent_def Let_def
(*goal: ‹¬ list_ex (λv. list_ex ((=) v) (delete_effects_of op)) (add_effects_of op) ∧ ¬ list_ex (λv. list_ex ((=) v) (add_effects_of op)) (delete_effects_of op)›*)
by blast
}
note "nb₁" = this (*‹is_valid_operator_strips Π ?op2 ⟹ are_operator_effects_consistent ?op2 ?op2›*)
show "?thesis"
(*goal: ‹G ⊆⇩m execute_serial_plan I (concat π)›*)
using assms (*‹∀ops∈set π. ∃op. ops = [op] ∧ is_valid_operator_strips Π op› ‹(G::'variable::type ⇒ bool option) ⊆⇩m execute_parallel_plan (I::'variable::type ⇒ bool option) (π::'variable strips_operator list list)›*) proof (induction π arbitrary: I)
(*goals:
1. ‹⋀I. ⟦∀ops∈set []. ∃op. ops = [op] ∧ is_valid_operator_strips Π op; G ⊆⇩m execute_parallel_plan I []⟧ ⟹ G ⊆⇩m execute_serial_plan I (concat [])›
2. ‹⋀a π I. ⟦⋀I. ⟦∀ops∈set π. ∃op. ops = [op] ∧ is_valid_operator_strips Π op; G ⊆⇩m execute_parallel_plan I π⟧ ⟹ G ⊆⇩m execute_serial_plan I (concat π); ∀ops∈set (a # π). ∃op. ops = [op] ∧ is_valid_operator_strips Π op; G ⊆⇩m execute_parallel_plan I (a # π)⟧ ⟹ G ⊆⇩m execute_serial_plan I (concat (a # π))›*)
case (Cons ops π) (*‹⟦∀ops∈set π. ∃op. ops = [op] ∧ is_valid_operator_strips Π op; G ⊆⇩m execute_parallel_plan ?I π⟧ ⟹ G ⊆⇩m execute_serial_plan ?I (concat π)› ‹∀ops∈set (ops # π). ∃op. ops = [op] ∧ is_valid_operator_strips Π op› ‹G ⊆⇩m execute_parallel_plan I (ops # π)›*)
obtain op where ops_is: "ops = [op]" and is_valid_op: "is_valid_operator_strips Π op"
(*goal: ‹(⋀op::'variable strips_operator. ⟦(ops::'variable strips_operator list) = [op]; is_valid_operator_strips (Π::'variable strips_problem) op⟧ ⟹ thesis::bool) ⟹ thesis›*)
using Cons.prems(1) (*‹∀ops∈set (ops # π). ∃op. ops = [op] ∧ is_valid_operator_strips Π op›*) by fastforce
show "?case"
(*goal: ‹G ⊆⇩m execute_serial_plan I (concat (ops # π))›*)
proof (cases "are_all_operators_applicable I ops")
(*goals:
1. ‹are_all_operators_applicable I ops ⟹ G ⊆⇩m execute_serial_plan I (concat (ops # π))›
2. ‹¬ are_all_operators_applicable I ops ⟹ G ⊆⇩m execute_serial_plan I (concat (ops # π))›*)
case True (*‹are_all_operators_applicable I ops›*)
let ?J = "execute_parallel_operator I [op]" and ?J' = "I ⪢ op"
have "nb₂": "is_operator_applicable_in I op"
using True (*‹are_all_operators_applicable I ops›*) ops_is (*‹ops = [op]›*) unfolding are_all_operators_applicable_def list_all_iff is_operator_applicable_in_def
(*goal: ‹let p = precondition_of op in ∀v∈set p. I v = Some True›*)
by simp
have "nb₃": "are_operator_effects_consistent op op"
using "nb₁"[OF is_valid_op] (*‹are_operator_effects_consistent op op›*) .
{
then have "are_all_operator_effects_consistent ops"
unfolding are_all_operator_effects_consistent_def list_all_iff
(*goal: ‹∀op∈set ops. Ball (set ops) (are_operator_effects_consistent op)›*)
using ops_is (*‹(ops::'variable strips_operator list) = [op::'variable strips_operator]›*) by fastforce
hence "G ⊆⇩m execute_parallel_plan ?J π"
using Cons.prems(2) (*‹G ⊆⇩m execute_parallel_plan I (ops # π)›*) ops_is (*‹ops = [op]›*) True (*‹are_all_operators_applicable (I::'variable ⇒ bool option) (ops::'variable strips_operator list)›*) by fastforce
}
moreover have "execute_serial_plan I (concat (ops # π))
= execute_serial_plan ?J' (concat π)"
using ops_is (*‹(ops::'variable strips_operator list) = [op::'variable strips_operator]›*) "nb₂" (*‹is_operator_applicable_in I op›*) unfolding is_operator_applicable_in_def
(*goal: ‹execute_serial_plan I (concat (ops # π)) = execute_serial_plan (I ⪢ op) (concat π)›*)
by (simp add: execute_operator_def (*‹?s ⪢ ?op ≡ ?s ++ map_of (effect_to_assignments ?op)›*) nb₂ (*‹is_operator_applicable_in I op›*))
moreover have "?J = ?J'"
unfolding execute_parallel_operator_def execute_operator_def comp_apply
(*goal: ‹foldl (++) I (map (λx. map_of (effect_to_assignments x)) [op]) = I ++ map_of (effect_to_assignments op)›*)
by fastforce
ultimately show "?thesis"
(*goal: ‹G ⊆⇩m execute_serial_plan I (concat (ops # π))›*)
using Cons.IH (*‹⟦∀ops∈set π. ∃op. ops = [op] ∧ is_valid_operator_strips Π op; G ⊆⇩m execute_parallel_plan ?I π⟧ ⟹ G ⊆⇩m execute_serial_plan ?I (concat π)›*) Cons.prems (*‹∀ops::'variable strips_operator list∈set ((ops::'variable strips_operator list) # (π::'variable strips_operator list list)). ∃op::'variable strips_operator. ops = [op] ∧ is_valid_operator_strips (Π::'variable strips_problem) op› ‹G ⊆⇩m execute_parallel_plan I (ops # π)›*) by force
next
(*goal: ‹¬ are_all_operators_applicable (I::'variable::type ⇒ bool option) (ops::'variable strips_operator list) ⟹ (G::'variable::type ⇒ bool option) ⊆⇩m execute_serial_plan I (concat (ops # (π::'variable strips_operator list list)))›*)
case False (*‹¬ are_all_operators_applicable (I::'variable ⇒ bool option) (ops::'variable strips_operator list)›*)
moreover have "G ⊆⇩m I"
using Cons.prems(2) (*‹G ⊆⇩m execute_parallel_plan I (ops # π)›*) calculation (*‹¬ are_all_operators_applicable I ops›*) by force
moreover {
have "¬is_operator_applicable_in I op"
using ops_is (*‹ops = [op]›*) False (*‹¬ are_all_operators_applicable I ops›*) unfolding are_all_operators_applicable_def list_all_iff is_operator_applicable_in_def
(*goal: ‹¬ (let p = precondition_of op in ∀v∈set p. I v = Some True)›*)
by fastforce
hence "execute_serial_plan I (concat (ops # π)) = I"
using ops_is (*‹ops = [op]›*) is_operator_applicable_in_def (*‹is_operator_applicable_in ?s ?op ≡ Let (precondition_of ?op) (list_all (λv. ?s v = Some True))›*) by simp
}
ultimately show "?thesis"
(*goal: ‹G ⊆⇩m execute_serial_plan I (concat (ops # π))›*)
by argo
qed
qed (force)
(*solved the remaining goal: ‹⋀I. ⟦∀ops∈set []. ∃op. ops = [op] ∧ is_valid_operator_strips Π op; G ⊆⇩m execute_parallel_plan I []⟧ ⟹ G ⊆⇩m execute_serial_plan I (concat [])›*)
qed
text ‹ The opposite direction is also easy to show if we can normalize the parallel plan to the
form of an embedded serial plan as shown below. ›
lemma flattening_lemma:
assumes "is_valid_problem_strips Π"
and "∀ops ∈ set π. ∃op. ops = [op]"
and "is_parallel_solution_for_problem Π π"
shows "is_serial_solution_for_problem Π (concat π)"
proof (-)
(*goal: ‹is_serial_solution_for_problem Π (concat π)›*)
let ?π' = "concat π"
{
have "∀ops ∈ set π. ∀op ∈ set ops. op ∈ set ((Π)⇩𝒪)"
using assms(3) (*‹is_parallel_solution_for_problem (Π::'a strips_problem) (π::'a strips_operator list list)›*) unfolding is_parallel_solution_for_problem_def list_all_iff ListMem_iff
(*goal: ‹∀ops∈set π. ∀op∈set ops. op ∈ set (Π⇩𝒪)›*)
by force
hence "∀op ∈ set ?π'. op ∈ set ((Π)⇩𝒪)"
using flattening_lemma_i (*‹∀ops∈set ?π. ∀op∈set ops. op ∈ set (?Π⇩𝒪) ⟹ ∀op∈set (concat ?π). op ∈ set (?Π⇩𝒪)›*) by blast
}
moreover {
{
fix ops
assume "ops ∈ set π" (*‹(ops::'a strips_operator list) ∈ set (π::'a strips_operator list list)›*)
moreover obtain op where "ops = [op]"
(*goal: ‹(⋀op. ops = [op] ⟹ thesis) ⟹ thesis›*)
using assms(2) (*‹∀ops∈set π. ∃op. ops = [op]›*) calculation (*‹ops ∈ set π›*) by blast
moreover have "op ∈ set ((Π)⇩𝒪)"
using assms(3) (*‹is_parallel_solution_for_problem Π π›*) calculation (*‹ops ∈ set π› ‹(ops::'a strips_operator list) = [op::'a strips_operator]›*) unfolding is_parallel_solution_for_problem_def list_all_iff ListMem_iff
(*goal: ‹op ∈ set (Π⇩𝒪)›*)
by force
moreover have "is_valid_operator_strips Π op"
using assms(1) (*‹is_valid_problem_strips Π›*) calculation(3) (*‹op ∈ set (Π⇩𝒪)›*) unfolding is_valid_problem_strips_def Let_def list_all_iff ListMem_iff
(*goal: ‹is_valid_operator_strips Π op›*)
by simp
ultimately have "∃op. ops = [op] ∧ is_valid_operator_strips Π op"
by blast
}
moreover have "(Π)⇩G ⊆⇩m execute_parallel_plan ((Π)⇩I) π"
using assms(3) (*‹is_parallel_solution_for_problem Π π›*) unfolding is_parallel_solution_for_problem_def
(*goal: ‹Π⇩G ⊆⇩m execute_parallel_plan (Π⇩I) π›*)
by simp
ultimately have "(Π)⇩G ⊆⇩m execute_serial_plan ((Π)⇩I) ?π'"
using flattening_lemma_ii (*‹⟦∀ops∈set ?π. ∃op. ops = [op] ∧ is_valid_operator_strips ?Π op; ?G ⊆⇩m execute_parallel_plan ?I ?π⟧ ⟹ ?G ⊆⇩m execute_serial_plan ?I (concat ?π)›*) by blast
}
ultimately show "is_serial_solution_for_problem Π ?π'"
unfolding is_serial_solution_for_problem_def list_all_iff ListMem_iff
(*goal: ‹Π⇩G ⊆⇩m execute_serial_plan (Π⇩I) (concat π) ∧ (∀op∈set (concat π). op ∈ set (Π⇩𝒪))›*)
by simp
qed
text ‹ Finally, we can obtain the important result that a parallel plan with a trace that
reaches the goal state of a given problem \<^term>‹Π›, and for which both the parallel operator execution
condition as well as non interference is assured at every point \<^term>‹k < length π›, the flattening of
the parallel plan \<^term>‹concat π› is a serial solution for the initial and goal state of the problem.
To wit, by lemma \ref{isathm:parallel-solution-trace-strips} we have
@{text[display, indent=4] "(G ⊆⇩m execute_parallel_plan I π)
= (G ⊆⇩m last (trace_parallel_plan_strips I π))"}
so the second assumption entails that \<^term>‹π› is a solution for the initial state and the goal state
of the problem. (which implicitely means that \<^term>‹π› is a solution
for the inital state and goal state of the problem). The trace formulation is used in this case
because it allows us to write the---state dependent---applicability condition more succinctly. The
proof (shown below) is by structural induction on \<^term>‹π› with arbitrary initial state.›
(* TODO Demote to lemma; add theorem about problem solutions. Move text to theorem. *)
theorem execute_parallel_plan_is_execute_sequential_plan_if:
fixes I :: "('variable, bool) state"
assumes "is_valid_problem Π"
and "G ⊆⇩m last (trace_parallel_plan_strips I π)"
and "∀k < length π.
are_all_operators_applicable (trace_parallel_plan_strips I π ! k) (π ! k)
∧ are_all_operator_effects_consistent (π ! k)
∧ are_all_operators_non_interfering (π ! k)"
shows "G ⊆⇩m execute_serial_plan I (concat π)"
using assms (*‹is_valid_problem Π› ‹G ⊆⇩m last (trace_parallel_plan_strips I π)› ‹∀k<length π. are_all_operators_applicable (trace_parallel_plan_strips I π ! k) (π ! k) ∧ are_all_operator_effects_consistent (π ! k) ∧ are_all_operators_non_interfering (π ! k)›*) proof (induction π arbitrary: I)
(*goals:
1. ‹⋀I. ⟦is_valid_problem Π; G ⊆⇩m last (trace_parallel_plan_strips I []); ∀k<length []. are_all_operators_applicable (trace_parallel_plan_strips I [] ! k) ([] ! k) ∧ are_all_operator_effects_consistent ([] ! k) ∧ are_all_operators_non_interfering ([] ! k)⟧ ⟹ G ⊆⇩m execute_serial_plan I (concat [])›
2. ‹⋀a π I. ⟦⋀I. ⟦is_valid_problem Π; G ⊆⇩m last (trace_parallel_plan_strips I π); ∀k<length π. are_all_operators_applicable (trace_parallel_plan_strips I π ! k) (π ! k) ∧ are_all_operator_effects_consistent (π ! k) ∧ are_all_operators_non_interfering (π ! k)⟧ ⟹ G ⊆⇩m execute_serial_plan I (concat π); is_valid_problem Π; G ⊆⇩m last (trace_parallel_plan_strips I (a # π)); ∀k<length (a # π). are_all_operators_applicable (trace_parallel_plan_strips I (a # π) ! k) ((a # π) ! k) ∧ are_all_operator_effects_consistent ((a # π) ! k) ∧ are_all_operators_non_interfering ((a # π) ! k)⟧ ⟹ G ⊆⇩m execute_serial_plan I (concat (a # π))›*)
case (Cons ops π) (*‹⟦is_valid_problem Π; G ⊆⇩m last (trace_parallel_plan_strips ?I π); ∀k<length π. are_all_operators_applicable (trace_parallel_plan_strips ?I π ! k) (π ! k) ∧ are_all_operator_effects_consistent (π ! k) ∧ are_all_operators_non_interfering (π ! k)⟧ ⟹ G ⊆⇩m execute_serial_plan ?I (concat π)› ‹is_valid_problem Π› ‹G ⊆⇩m last (trace_parallel_plan_strips I (ops # π))› ‹∀k<length (ops # π). are_all_operators_applicable (trace_parallel_plan_strips I (ops # π) ! k) ((ops # π) ! k) ∧ are_all_operator_effects_consistent ((ops # π) ! k) ∧ are_all_operators_non_interfering ((ops # π) ! k)›*)
let ?ops' = "take (length ops) (concat (ops # π))"
let ?J = "execute_parallel_operator I ops" and ?J' = "execute_serial_plan I ?ops'"
{
have "trace_parallel_plan_strips I π ! 0 = I" and "(ops # π) ! 0 = ops"
unfolding trace_parallel_plan_strips_head_is_initial_state
(*goals:
1. ‹I = I›
2. ‹(ops # π) ! 0 = ops›*)
(*goals:
1. ‹I = I›
2. ‹(ops # π) ! 0 = ops›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
then have "are_all_operators_applicable I ops" and "are_all_operator_effects_consistent ops" and "are_all_operators_non_interfering ops"
using Cons.prems(3) (*‹∀k<length (ops # π). are_all_operators_applicable (trace_parallel_plan_strips I (ops # π) ! k) ((ops # π) ! k) ∧ are_all_operator_effects_consistent ((ops # π) ! k) ∧ are_all_operators_non_interfering ((ops # π) ! k)›*) apply -
(*goals:
1. ‹⟦trace_parallel_plan_strips I π ! 0 = I; (ops # π) ! 0 = ops; ∀k<length (ops # π). are_all_operators_applicable (trace_parallel_plan_strips I (ops # π) ! k) ((ops # π) ! k) ∧ are_all_operator_effects_consistent ((ops # π) ! k) ∧ are_all_operators_non_interfering ((ops # π) ! k)⟧ ⟹ are_all_operators_applicable I ops›
2. ‹⟦trace_parallel_plan_strips I π ! 0 = I; (ops # π) ! 0 = ops; ∀k<length (ops # π). are_all_operators_applicable (trace_parallel_plan_strips I (ops # π) ! k) ((ops # π) ! k) ∧ are_all_operator_effects_consistent ((ops # π) ! k) ∧ are_all_operators_non_interfering ((ops # π) ! k)⟧ ⟹ are_all_operator_effects_consistent ops›
3. ‹⟦trace_parallel_plan_strips I π ! 0 = I; (ops # π) ! 0 = ops; ∀k<length (ops # π). are_all_operators_applicable (trace_parallel_plan_strips I (ops # π) ! k) ((ops # π) ! k) ∧ are_all_operator_effects_consistent ((ops # π) ! k) ∧ are_all_operators_non_interfering ((ops # π) ! k)⟧ ⟹ are_all_operators_non_interfering ops›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
then have "trace_parallel_plan_strips I (ops # π)
= I # trace_parallel_plan_strips ?J π"
by fastforce
}
note nb = this (*‹trace_parallel_plan_strips I (ops # π) = I # trace_parallel_plan_strips (execute_parallel_operator I ops) π›*)
{
have "last (trace_parallel_plan_strips I (ops # π))
= last (trace_parallel_plan_strips ?J π)"
using trace_parallel_plan_strips_last_cons_then (*‹last (?s # trace_parallel_plan_strips ?s' ?π) = last (trace_parallel_plan_strips ?s' ?π)›*) nb (*‹trace_parallel_plan_strips I (ops # π) = I # trace_parallel_plan_strips (execute_parallel_operator I ops) π›*) by metis
hence "G ⊆⇩m last (trace_parallel_plan_strips ?J π)"
using Cons.prems(2) (*‹G ⊆⇩m last (trace_parallel_plan_strips I (ops # π))›*) by force
}
moreover {
fix k
assume "k < length π" (*‹(k::nat) < length (π::'variable strips_operator list list)›*)
moreover have "k + 1 < length (ops # π)"
using calculation (*‹k < length π›*) by force
moreover have "π ! k = (ops # π) ! (k + 1)"
by simp
ultimately have "are_all_operators_applicable
(trace_parallel_plan_strips ?J π ! k) (π ! k)" and "are_all_operator_effects_consistent (π ! k)" and "are_all_operators_non_interfering (π ! k)"
using Cons.prems(3) (*‹∀k<length (ops # π). are_all_operators_applicable (trace_parallel_plan_strips I (ops # π) ! k) ((ops # π) ! k) ∧ are_all_operator_effects_consistent ((ops # π) ! k) ∧ are_all_operators_non_interfering ((ops # π) ! k)›*) nb (*‹trace_parallel_plan_strips I (ops # π) = I # trace_parallel_plan_strips (execute_parallel_operator I ops) π›*) apply -
(*goals:
1. ‹⟦k < length π; k + 1 < length (ops # π); π ! k = (ops # π) ! (k + 1); ∀k<length (ops # π). are_all_operators_applicable (trace_parallel_plan_strips I (ops # π) ! k) ((ops # π) ! k) ∧ are_all_operator_effects_consistent ((ops # π) ! k) ∧ are_all_operators_non_interfering ((ops # π) ! k); trace_parallel_plan_strips I (ops # π) = I # trace_parallel_plan_strips (execute_parallel_operator I ops) π⟧ ⟹ are_all_operators_applicable (trace_parallel_plan_strips (execute_parallel_operator I ops) π ! k) (π ! k)›
2. ‹⟦k < length π; k + 1 < length (ops # π); π ! k = (ops # π) ! (k + 1); ∀k<length (ops # π). are_all_operators_applicable (trace_parallel_plan_strips I (ops # π) ! k) ((ops # π) ! k) ∧ are_all_operator_effects_consistent ((ops # π) ! k) ∧ are_all_operators_non_interfering ((ops # π) ! k); trace_parallel_plan_strips I (ops # π) = I # trace_parallel_plan_strips (execute_parallel_operator I ops) π⟧ ⟹ are_all_operator_effects_consistent (π ! k)›
3. ‹⟦k < length π; k + 1 < length (ops # π); π ! k = (ops # π) ! (k + 1); ∀k<length (ops # π). are_all_operators_applicable (trace_parallel_plan_strips I (ops # π) ! k) ((ops # π) ! k) ∧ are_all_operator_effects_consistent ((ops # π) ! k) ∧ are_all_operators_non_interfering ((ops # π) ! k); trace_parallel_plan_strips I (ops # π) = I # trace_parallel_plan_strips (execute_parallel_operator I ops) π⟧ ⟹ are_all_operators_non_interfering (π ! k)›
discuss goal 1*)
apply force
(*discuss goal 2*)
apply force
(*discuss goal 3*)
apply force
(*proven 3 subgoals*) .
}
ultimately have "G ⊆⇩m execute_serial_plan ?J (concat π)"
using Cons.IH[OF Cons.prems ( 1 ), of ?J] (*‹⟦G ⊆⇩m last (trace_parallel_plan_strips (execute_parallel_operator I ops) π); ∀k<length π. are_all_operators_applicable (trace_parallel_plan_strips (execute_parallel_operator I ops) π ! k) (π ! k) ∧ are_all_operator_effects_consistent (π ! k) ∧ are_all_operators_non_interfering (π ! k)⟧ ⟹ G ⊆⇩m execute_serial_plan (execute_parallel_operator I ops) (concat π)›*) by blast
moreover {
have "execute_serial_plan I (concat (ops # π))
= execute_serial_plan ?J' (concat π)"
using execute_serial_plan_split[of I ops] (*‹⟦are_all_operators_applicable (I::'variable ⇒ bool option) (ops::'variable strips_operator list); are_all_operators_non_interfering ops⟧ ⟹ execute_serial_plan I (ops @ (?π₂::'variable strips_operator list)) = execute_serial_plan (execute_serial_plan I ops) ?π₂›*) Cons.prems(3) (*‹∀k<length (ops # π). are_all_operators_applicable (trace_parallel_plan_strips I (ops # π) ! k) ((ops # π) ! k) ∧ are_all_operator_effects_consistent ((ops # π) ! k) ∧ are_all_operators_non_interfering ((ops # π) ! k)›*) by auto
thm execute_parallel_operator_equals_execute_sequential_strips_if[of I]
moreover have "?J = ?J'"
using execute_parallel_operator_equals_execute_sequential_strips_if (*‹⟦are_all_operators_applicable ?s ?ops; are_all_operator_effects_consistent ?ops; are_all_operators_non_interfering ?ops⟧ ⟹ execute_parallel_operator ?s ?ops = execute_serial_plan ?s ?ops›*) Cons.prems(3) (*‹∀k<length (ops # π). are_all_operators_applicable (trace_parallel_plan_strips I (ops # π) ! k) ((ops # π) ! k) ∧ are_all_operator_effects_consistent ((ops # π) ! k) ∧ are_all_operators_non_interfering ((ops # π) ! k)›*) by fastforce
ultimately have "execute_serial_plan I (concat (ops # π))
= execute_serial_plan ?J (concat π)"
using execute_serial_plan_split[of I ops] (*‹⟦are_all_operators_applicable I ops; are_all_operators_non_interfering ops⟧ ⟹ execute_serial_plan I (ops @ ?π₂) = execute_serial_plan (execute_serial_plan I ops) ?π₂›*) Cons.prems(3) (*‹∀k<length (ops # π). are_all_operators_applicable (trace_parallel_plan_strips I (ops # π) ! k) ((ops # π) ! k) ∧ are_all_operator_effects_consistent ((ops # π) ! k) ∧ are_all_operators_non_interfering ((ops # π) ! k)›*) by argo
}
ultimately show "?case"
(*goal: ‹G ⊆⇩m execute_serial_plan I (concat (ops # π))›*)
by argo
qed (force)
(*solved the remaining goal: ‹⋀I. ⟦is_valid_problem Π; G ⊆⇩m last (trace_parallel_plan_strips I []); ∀k<length []. are_all_operators_applicable (trace_parallel_plan_strips I [] ! k) ([] ! k) ∧ are_all_operator_effects_consistent ([] ! k) ∧ are_all_operators_non_interfering ([] ! k)⟧ ⟹ G ⊆⇩m execute_serial_plan I (concat [])›*)
subsection "Auxiliary lemmas about STRIPS"
lemma set_to_precondition_of_op_is[simp]: "set (to_precondition op)
= { (v, True) | v. v ∈ set (precondition_of op) }"
unfolding to_precondition_def STRIPS_Representation.to_precondition_def set_map
(*goal: ‹(λv. (v, True)) ` set (precondition_of op) = {(v, True) |v. v ∈ set (precondition_of op)}›*)
by blast
end
| {
"path": "afp-2025-02-12/thys/Verified_SAT_Based_AI_Planning/STRIPS_Semantics.thy",
"repo": "afp-2025-02-12",
"sha": "79dd3a05437f321f013673c4f393151fd5314e68a3ac1c9e580f74463a10c360"
} |
(* Title: Schutz_Spacetime/TemporalOrderOnPath.thy
Authors: Richard Schmoetten, Jake Palmer and Jacques D. Fleuriot
University of Edinburgh, 2021
*)
theory TemporalOrderOnPath
imports Minkowski "HOL-Library.Disjoint_Sets"
begin
text ‹
In Schutz \<^cite>‹‹pp.~18-30› in "schutz1997"›, this is ``Chapter 3: Temporal order on a path''.
All theorems are from Schutz, all lemmas are either parts of the Schutz proofs extracted, or
additional lemmas which needed to be added, with the exception of the three transitivity lemmas
leading to Theorem 9, which are given by Schutz as well.
Much of what we'd like to prove about chains with respect to injectivity, surjectivity,
bijectivity, is proved in ‹TernaryOrdering.thy›.
Some more things are proved in interlude sections.
›
section "Preliminary Results for Primitives"
text ‹
First some proofs that belong in this section but aren't proved in the book or are covered but
in a different form or off-handed remark.
›
context MinkowskiPrimitive begin
lemma cross_once_notin:
assumes "Q ∈ 𝒫"
and "R ∈ 𝒫"
and "a ∈ Q"
and "b ∈ Q"
and "b ∈ R"
and "a ≠ b"
and "Q ≠ R"
shows "a ∉ R"
using assms (*‹Q ∈ 𝒫› ‹R ∈ 𝒫› ‹(a::'a) ∈ (Q::'a set)› ‹(b::'a) ∈ (Q::'a set)› ‹b ∈ R› ‹a ≠ b› ‹(Q::'a::type set) ≠ (R::'a::type set)›*) paths_cross_once (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?Q ≠ ?R; ?Q ∩ ?R ≠ {}⟧ ⟹ ∃!a. a ∈ ℰ ∧ ?Q ∩ ?R = {a}›*) eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) by meson
lemma paths_cross_at:
assumes path_Q: "Q ∈ 𝒫" and path_R: "R ∈ 𝒫"
and Q_neq_R: "Q ≠ R"
and QR_nonempty: "Q ∩ R ≠ {}"
and x_inQ: "x ∈ Q" and x_inR: "x ∈ R"
shows "Q ∩ R = {x}"
proof (rule equalityI (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*))
(*goals:
1. ‹Q ∩ R ⊆ {x}›
2. ‹{x} ⊆ Q ∩ R›*)
show "Q ∩ R ⊆ {x}"
apply (rule subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*))
(*goal: ‹Q ∩ R ⊆ {x}›*)
proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*))
(*goal: ‹⋀xa. ⟦xa ∈ Q ∩ R; xa ∉ {x}⟧ ⟹ False›*)
fix y
assume y_in_QR: "y ∈ Q ∩ R" and y_not_in_just_x: "y ∉ {x}" (*‹(y::'a) ∈ (Q::'a set) ∩ (R::'a set)› ‹(y::'a) ∉ {x::'a}›*)
then have y_neq_x: "y ≠ x"
by simp
then have "¬ (∃z. Q ∩ R = {z})"
by (meson Q_neq_R (*‹Q ≠ R›*) path_Q (*‹Q ∈ 𝒫›*) path_R (*‹R ∈ 𝒫›*) x_inQ (*‹x ∈ Q›*) x_inR (*‹x ∈ R›*) y_in_QR (*‹y ∈ Q ∩ R›*) cross_once_notin (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*) IntD1 (*‹?c ∈ ?A ∩ ?B ⟹ ?c ∈ ?A›*) IntD2 (*‹?c ∈ ?A ∩ ?B ⟹ ?c ∈ ?B›*))
thus False
using paths_cross_once (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?Q ≠ ?R; ?Q ∩ ?R ≠ {}⟧ ⟹ ∃!a. a ∈ ℰ ∧ ?Q ∩ ?R = {a}›*) by (meson QR_nonempty (*‹(Q::'a set) ∩ (R::'a set) ≠ {}›*) Q_neq_R (*‹(Q::'a set) ≠ (R::'a set)›*) path_Q (*‹(Q::'a set) ∈ (𝒫::'a set set)›*) path_R (*‹(R::'a set) ∈ (𝒫::'a set set)›*))
qed
show "{x} ⊆ Q ∩ R"
using x_inQ (*‹x ∈ Q›*) x_inR (*‹(x::'a::type) ∈ (R::'a::type set)›*) by simp
qed
lemma events_distinct_paths:
assumes a_event: "a ∈ ℰ"
and b_event: "b ∈ ℰ"
and a_neq_b: "a ≠ b"
shows "∃R∈𝒫. ∃S∈𝒫. a ∈ R ∧ b ∈ S ∧ (R ≠ S ⟶ (∃!c∈ℰ. R ∩ S = {c}))"
by (metis events_paths (*‹⟦?a ∈ ℰ; ?b ∈ ℰ; ?a ≠ ?b⟧ ⟹ ∃R∈𝒫. ∃S∈𝒫. ?a ∈ R ∧ ?b ∈ S ∧ R ∩ S ≠ {}›*) assms (*‹a ∈ ℰ› ‹b ∈ ℰ› ‹a ≠ b›*) paths_cross_once (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?Q ≠ ?R; ?Q ∩ ?R ≠ {}⟧ ⟹ ∃!a. a ∈ ℰ ∧ ?Q ∩ ?R = {a}›*))
end (* context MinkowskiPrimitive *)
context MinkowskiBetweenness begin
lemma assumes "[a;b;c]" shows "∃f. local_long_ch_by_ord f {a,b,c}"
using abc_abc_neq[OF assms] (*‹a ≠ b ∧ a ≠ c ∧ b ≠ c›*) unfolding chain_defs
(*goal: ‹∃f. (infinite {a, b, c} ∨ 3 ≤ card {a, b, c}) ∧ local_ordering f betw {a, b, c}›*)
by (simp add: assms (*‹[a;b;c]›*) ord_ordered_loc (*‹⟦?ord ?a ?b ?c; ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c⟧ ⟹ ∃f. local_ordering f ?ord {?a, ?b, ?c}›*))
lemma between_chain: "[a;b;c] ⟹ ch {a,b,c}"
proof (-)
(*goal: ‹[a;b;c] ⟹ ch {a, b, c}›*)
assume "[a;b;c]" (*‹[a::'a;b::'a;c::'a]›*)
hence "∃f. local_ordering f betw {a,b,c}"
by (simp add: abc_abc_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) ord_ordered_loc (*‹⟦(?ord::?'a ⇒ ?'a ⇒ ?'a ⇒ bool) (?a::?'a) (?b::?'a) (?c::?'a); ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c⟧ ⟹ ∃f::nat ⇒ ?'a. local_ordering f ?ord {?a, ?b, ?c}›*))
hence "∃f. local_long_ch_by_ord f {a,b,c}"
using ‹[a;b;c]› (*‹[a::'a;b::'a;c::'a]›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) local_long_ch_by_ord_def (*‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X›*) by auto
thus "?thesis"
(*goal: ‹ch {a, b, c}›*)
by (simp add: chain_defs (*‹short_ch (?X::'a::type set) ≡ card ?X = (2::nat) ∧ (∃P::'a::type set∈𝒫::'a::type set set. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a::type) (?X::'a::type set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f::nat ⇒ 'a::type↝?X::'a::type set] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a::type set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch (?X::'a::type set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a::type. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type .. ?y::'a::type] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type..?y::'a::type..?z::'a::type] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*))
qed
end (* context MinkowskiBetweenness *)
section "3.1 Order on a finite chain"
context MinkowskiBetweenness begin
subsection ‹Theorem 1›
text ‹
See ‹Minkowski.abc_only_cba›.
Proving it again here to show it can be done following the prose in Schutz.
›
theorem theorem1 [no_atp]:
assumes abc: "[a;b;c]"
shows "[c;b;a] ∧ ¬ [b;c;a] ∧ ¬ [c;a;b]"
proof (-)
(*goal: ‹[c;b;a] ∧ ¬ [b;c;a] ∧ ¬ [c;a;b]›*)
have part_i: "[c;b;a]"
using abc (*‹[a;b;c]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by simp
have part_ii: "¬ [b;c;a]"
proof (rule notI (*‹(?P::bool ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹[b;c;a] ⟹ False›*)
assume "[b;c;a]" (*‹[b::'a;c::'a;a::'a]›*)
then have "[a;b;a]"
using abc (*‹[a;b;c]›*) abc_bcd_abd (*‹⟦[?a::'a;?b::'a;?c::'a]; [?b;?c;?d::'a]⟧ ⟹ [?a;?b;?d]›*) by blast
thus False
using abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) by blast
qed
have part_iii: "¬ [c;a;b]"
proof (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹[c;a;b] ⟹ False›*)
assume "[c;a;b]" (*‹[c::'a;a::'a;b::'a]›*)
then have "[c;a;c]"
using abc (*‹[a;b;c]›*) abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) by blast
thus False
using abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) by blast
qed
thus "?thesis"
(*goal: ‹[c;b;a] ∧ ¬ [b;c;a] ∧ ¬ [c;a;b]›*)
using part_i (*‹[c;b;a]›*) part_ii (*‹¬ [b;c;a]›*) part_iii (*‹¬ [c;a;b]›*) by auto
qed
subsection ‹Theorem 2›
text ‹
The lemma ‹abc_bcd_acd›, equal to the start of Schutz's proof, is given in ‹Minkowski› in order
to prove some equivalences.
We're splitting up Theorem 2 into two named results:
\begin{itemize}
\item[‹order_finite_chain›] there is a betweenness relation for each triple of adjacent events, and
\item[‹index_injective›] all events of a chain are distinct.
\end{itemize}
We will be following Schutz' proof for both.
Distinctness of chain events is interpreted as injectivity of the indexing function
(see ‹index_injective›): we assume that this corresponds to what Schutz means by distinctness
of elements in a sequence.
›
text ‹
For the case of two-element chains: the elements are distinct by definition,
and the statement on \<^term>‹local_ordering› is void (respectively, \<^term>‹False ⟹ P› for any \<^term>‹P›).
We exclude this case from our proof of ‹order_finite_chain›. Two helper lemmas are provided,
each capturing one of the proofs by induction in Schutz' writing.
›
lemma thm2_ind1:
assumes chX: "local_long_ch_by_ord f X"
and finiteX: "finite X"
shows "∀j i. ((i::nat) < j ∧ j < card X - 1) ⟶ [f i; f j; f (j + 1)]"
apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*))
(*goal: ‹∀j i. i < j ∧ j < card X - 1 ⟶ [f i;f j;f (j + 1)]›*)
proof (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*))
(*goal: ‹⋀j i. i < j ∧ j < card X - 1 ⟶ [f i;f j;f (j + 1)]›*)
let ?P = "λ i j. [f i; f j; f (j+1)]"
fix i and j
show "(i<j ∧ j<card X -1) ⟶ ?P i j"
proof (induct j)
(*goals:
1. ‹i < 0 ∧ 0 < card X - 1 ⟶ [f i;f 0;f (0 + 1)]›
2. ‹⋀j. i < j ∧ j < card X - 1 ⟶ [f i;f j;f (j + 1)] ⟹ i < Suc j ∧ Suc j < card X - 1 ⟶ [f i;f (Suc j);f (Suc j + 1)]›*)
case 0 (*no hyothesis introduced yet*)
show "?case"
(*goal: ‹i < 0 ∧ 0 < card X - 1 ⟶ [f i;f 0;f (0 + 1)]›*)
by blast
next
(*goal: ‹⋀j::nat. (i::nat) < j ∧ j < card (X::'a set) - (1::nat) ⟶ [(f::nat ⇒ 'a) i;f j;f (j + (1::nat))] ⟹ i < Suc j ∧ Suc j < card X - (1::nat) ⟶ [f i;f (Suc j);f (Suc j + (1::nat))]›*)
case (Suc j) (*‹i < j ∧ j < card X - 1 ⟶ [f i;f j;f (j + 1)]›*)
show "?case"
(*goal: ‹i < Suc j ∧ Suc j < card X - 1 ⟶ [f i;f (Suc j);f (Suc j + 1)]›*)
proof (clarify)
(*goal: ‹⟦i < Suc j; Suc j < card X - 1⟧ ⟹ [f i;f (Suc j);f (Suc j + 1)]›*)
assume asm: "i<Suc j" "Suc j<card X -1" (*‹(i::nat) < Suc (j::nat)› ‹Suc (j::nat) < card (X::'a set) - (1::nat)›*)
have pj: "?P j (Suc j)"
using asm(2) (*‹Suc j < card X - 1›*) chX (*‹local_long_ch_by_ord f X›*) less_diff_conv (*‹(?i < ?j - ?k) = (?i + ?k < ?j)›*) local_long_ch_by_ord_def (*‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X›*) local_ordering_def (*‹local_ordering (?f::nat ⇒ ?'a) (?ord::?'a ⇒ ?'a ⇒ ?'a ⇒ bool) (?X::?'a set) ≡ (∀n::nat. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x::?'a∈?X. ∃n::nat. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n::nat. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) by (metis Suc_eq_plus1 (*‹Suc ?n = ?n + 1›*))
have "i<j ∨ i=j"
using asm(1) (*‹i < Suc j›*) by linarith
thus "?P i (Suc j)"
proof (standard)
(*goals:
1. ‹i < j ⟹ [f i;f (Suc j);f (Suc j + 1)]›
2. ‹i = j ⟹ [f i;f (Suc j);f (Suc j + 1)]›*)
assume "i=j" (*‹(i::nat) = (j::nat)›*)
hence "Suc i = Suc j ∧ Suc (Suc j) = Suc (Suc j)"
by simp
thus "?P i (Suc j)"
using pj (*‹[f j;f (Suc j);f (Suc j + 1)]›*) by auto
next
(*goal: ‹i < j ⟹ [f i;f (Suc j);f (Suc j + 1)]›*)
assume "i<j" (*‹(i::nat) < (j::nat)›*)
have "j < card X - 1"
using asm(2) (*‹Suc j < card X - 1›*) by linarith
thus "?P i (Suc j)"
using ‹i<j› (*‹(i::nat) < (j::nat)›*) Suc.hyps (*‹i < j ∧ j < card X - 1 ⟶ [f i;f j;f (j + 1)]›*) asm(1) (*‹i < Suc j›*) asm(2) (*‹Suc j < card X - 1›*) chX (*‹local_long_ch_by_ord f X›*) finiteX (*‹finite X›*) Suc_eq_plus1 (*‹Suc (?n::nat) = ?n + (1::nat)›*) abc_bcd_acd (*‹⟦[?a::'a;?b::'a;?c::'a]; [?b;?c;?d::'a]⟧ ⟹ [?a;?c;?d]›*) pj (*‹[f j;f (Suc j);f (Suc j + 1)]›*) by presburger
qed
qed
qed
qed
lemma thm2_ind2:
assumes chX: "local_long_ch_by_ord f X"
and finiteX: "finite X"
shows "∀m l. (0<(l-m) ∧ (l-m) < l ∧ l < card X) ⟶ [f (l-m-1); f (l-m); (f l)]"
apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*))
(*goal: ‹∀m l. 0 < l - m ∧ l - m < l ∧ l < card X ⟶ [f (l - m - 1);f (l - m);f l]›*)
proof (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*))
(*goal: ‹⋀m l. 0 < l - m ∧ l - m < l ∧ l < card X ⟶ [f (l - m - 1);f (l - m);f l]›*)
fix l and m
let ?P = "λ k l. [f (k-1); f k; f l]"
let ?n = "card X"
let ?k = "(l::nat)-m"
show "0 < ?k ∧ ?k < l ∧ l < ?n ⟶ ?P ?k l"
proof (induct m)
(*goals:
1. ‹0 < l - 0 ∧ l - 0 < l ∧ l < card X ⟶ [f (l - 0 - 1);f (l - 0);f l]›
2. ‹⋀m. 0 < l - m ∧ l - m < l ∧ l < card X ⟶ [f (l - m - 1);f (l - m);f l] ⟹ 0 < l - Suc m ∧ l - Suc m < l ∧ l < card X ⟶ [f (l - Suc m - 1);f (l - Suc m);f l]›*)
case 0 (*no hyothesis introduced yet*)
show "?case"
(*goal: ‹0 < l - 0 ∧ l - 0 < l ∧ l < card X ⟶ [f (l - 0 - 1);f (l - 0);f l]›*)
by simp
next
(*goal: ‹⋀m. 0 < l - m ∧ l - m < l ∧ l < card X ⟶ [f (l - m - 1);f (l - m);f l] ⟹ 0 < l - Suc m ∧ l - Suc m < l ∧ l < card X ⟶ [f (l - Suc m - 1);f (l - Suc m);f l]›*)
case (Suc m) (*‹(0::nat) < (l::nat) - (m::nat) ∧ l - m < l ∧ l < card (X::'a::type set) ⟶ [(f::nat ⇒ 'a::type) (l - m - (1::nat));f (l - m);f l]›*)
show "?case"
(*goal: ‹0 < l - Suc m ∧ l - Suc m < l ∧ l < card X ⟶ [f (l - Suc m - 1);f (l - Suc m);f l]›*)
proof (clarify)
(*goal: ‹⟦(0::nat) < (l::nat) - Suc (m::nat); l - Suc m < l; l < card (X::'a set)⟧ ⟹ [(f::nat ⇒ 'a) (l - Suc m - (1::nat));f (l - Suc m);f l]›*)
assume asm: "0 < l - Suc m" "l - Suc m < l" "l < ?n" (*‹(0::nat) < (l::nat) - Suc (m::nat)› ‹(l::nat) - Suc (m::nat) < l› ‹(l::nat) < card (X::'a set)›*)
have "Suc m = 1 ∨ Suc m > 1"
by linarith
thus "[f (l - Suc m - 1); f (l - Suc m); f l]" (is "?goal")
proof (standard)
(*goals:
1. ‹Suc m = 1 ⟹ [f (l - Suc m - 1);f (l - Suc m);f l]›
2. ‹1 < Suc m ⟹ [f (l - Suc m - 1);f (l - Suc m);f l]›*)
assume "Suc m = 1" (*‹Suc (m::nat) = (1::nat)›*)
show "?goal"
proof (-)
(*goal: ‹[f (l - Suc m - 1);f (l - Suc m);f l]›*)
have "l - Suc m < card X"
using asm(2) (*‹(l::nat) - Suc (m::nat) < l›*) asm(3) (*‹(l::nat) < card (X::'a::type set)›*) less_trans (*‹⟦?x < ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) by blast
then show "?thesis"
(*goal: ‹[f (l - Suc m - 1);f (l - Suc m);f l]›*)
using ‹Suc m = 1› (*‹Suc m = 1›*) asm (*‹0 < l - Suc m› ‹l - Suc m < l› ‹(l::nat) < card (X::'a set)›*) finiteX (*‹finite X›*) thm2_ind1 (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X⟧ ⟹ ∀j i. i < j ∧ j < card ?X - 1 ⟶ [?f i;?f j;?f (j + 1)]›*) chX (*‹local_long_ch_by_ord f X›*) using Suc_eq_plus1 (*‹Suc ?n = ?n + 1›*) add_diff_inverse_nat (*‹¬ ?m < ?n ⟹ ?n + (?m - ?n) = ?m›*) diff_Suc_less (*‹(0::nat) < (?n::nat) ⟹ ?n - Suc (?i::nat) < ?n›*) gr_implies_not_zero (*‹?m < ?n ⟹ ?n ≠ 0›*) less_one (*‹((?n::nat) < (1::nat)) = (?n = (0::nat))›*) plus_1_eq_Suc (*‹(+) 1 = Suc›*) by (smt local_long_ch_by_ord_def (*‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X›*) ordering_ord_ijk_loc (*‹⟦local_ordering ?f ?ord ?X; finite ?X ⟶ Suc (Suc ?i) < card ?X⟧ ⟹ ?ord (?f ?i) (?f (Suc ?i)) (?f (Suc (Suc ?i)))›*))
qed
next
(*goal: ‹1 < Suc m ⟹ [f (l - Suc m - 1);f (l - Suc m);f l]›*)
assume "Suc m > 1" (*‹(1::nat) < Suc (m::nat)›*)
show "?goal"
apply (rule_tac a="f l" and c="f(l - Suc m - 1)" in abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*))
(*goal: ‹[(f::nat ⇒ 'a) ((l::nat) - Suc (m::nat) - (1::nat));f (l - Suc m);f l]›*)
proof (rule_tac a="f l" and c="f(l-Suc m)" and d="f(l-Suc m-1)" and b="f(l-m)" in abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*))
(*goals:
1. ‹[(f::nat ⇒ 'a::type) (l::nat);f (l - (m::nat));f (l - Suc m)]›
2. ‹[(f::nat ⇒ 'a::type) ((l::nat) - (m::nat));f (l - Suc m);f (l - Suc m - (1::nat))]›*)
have "[f(l-m-1); f(l-m); f l]"
using Suc.hyps (*‹(0::nat) < (l::nat) - (m::nat) ∧ l - m < l ∧ l < card (X::'a::type set) ⟶ [(f::nat ⇒ 'a::type) (l - m - (1::nat));f (l - m);f l]›*) ‹1 < Suc m› (*‹1 < Suc m›*) asm(1,3) (*‹(0::nat) < (l::nat) - Suc (m::nat)› ‹l < card X›*) by force
thus "[f l; f(l - m); f(l - Suc m)]"
using abc_sym (*‹[?a::'a;?b::'a;?c::'a] ⟹ [?c;?b;?a]›*) One_nat_def (*‹1 = Suc 0›*) diff_zero (*‹?a - 0 = ?a›*) minus_nat.simps(2) (*‹?m - Suc ?n = (case ?m - ?n of 0 ⇒ 0 | Suc k ⇒ k)›*) by metis
have "Suc(l - Suc m - 1) = l - Suc m" "Suc(l - Suc m) = l-m"
using Suc_pred (*‹0 < ?n ⟹ Suc (?n - Suc 0) = ?n›*) asm(1) (*‹(0::nat) < (l::nat) - Suc (m::nat)›*) apply -
(*goals:
1. ‹⟦⋀n. 0 < n ⟹ Suc (n - Suc 0) = n; 0 < l - Suc m⟧ ⟹ Suc (l - Suc m - 1) = l - Suc m›
2. ‹⟦⋀n. 0 < n ⟹ Suc (n - Suc 0) = n; 0 < l - Suc m⟧ ⟹ Suc (l - Suc m) = l - m›
discuss goal 1*)
apply presburger
(*discuss goal 2*)
apply presburger
(*proven 2 subgoals*) .
hence "[f(l - Suc m - 1); f(l - Suc m); f(l - m)]"
using chX (*‹local_long_ch_by_ord f X›*) unfolding local_long_ch_by_ord_def local_ordering_def
(*goal: ‹[(f::nat ⇒ 'a) ((l::nat) - Suc (m::nat) - (1::nat));f (l - Suc m);f (l - m)]›*)
by (metis asm( (*‹(l::nat) - Suc (m::nat) < l› ‹(l::nat) < card (X::'a set)›*) 2,3) less_trans_Suc (*‹⟦(?i::nat) < (?j::nat); ?j < (?k::nat)⟧ ⟹ Suc ?i < ?k›*))
thus "[f(l - m); f(l - Suc m); f(l - Suc m - 1)]"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by blast
qed
qed
qed
qed
qed
lemma thm2_ind2b:
assumes chX: "local_long_ch_by_ord f X"
and finiteX: "finite X"
and ordered_nats: "0<k ∧ k<l ∧ l < card X"
shows "[f (k-1); f k; f l]"
using thm2_ind2 (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X⟧ ⟹ ∀m l. 0 < l - m ∧ l - m < l ∧ l < card ?X ⟶ [?f (l - m - 1);?f (l - m);?f l]›*) finiteX (*‹finite X›*) chX (*‹local_long_ch_by_ord f X›*) ordered_nats (*‹0 < k ∧ k < l ∧ l < card X›*) by (metis diff_diff_cancel (*‹?i ≤ ?n ⟹ ?n - (?n - ?i) = ?i›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))
text ‹
This is Theorem 2 properly speaking, except for the "chain elements are distinct" part
(which is proved as injectivity of the index later). Follows Schutz fairly well!
The statement Schutz proves under (i) is given in ‹MinkowskiBetweenness.abc_bcd_acd› instead.
›
theorem (*2*) order_finite_chain:
assumes chX: "local_long_ch_by_ord f X"
and finiteX: "finite X"
and ordered_nats: "0 ≤ (i::nat) ∧ i < j ∧ j < l ∧ l < card X"
shows "[f i; f j; f l]"
proof (-)
(*goal: ‹[f i;f j;f l]›*)
let ?n = "card X - 1"
have ord1: "0≤i ∧ i<j ∧ j<?n"
using ordered_nats (*‹0 ≤ i ∧ i < j ∧ j < l ∧ l < card X›*) by linarith
have e2: "[f i; f j; f (j+1)]"
using thm2_ind1 (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X⟧ ⟹ ∀j i. i < j ∧ j < card ?X - 1 ⟶ [?f i;?f j;?f (j + 1)]›*) using Suc_eq_plus1 (*‹Suc ?n = ?n + 1›*) chX (*‹local_long_ch_by_ord (f::nat ⇒ 'a) (X::'a set)›*) finiteX (*‹finite X›*) ord1 (*‹0 ≤ i ∧ i < j ∧ j < card X - 1›*) by presburger
have e3: "∀k. 0<k ∧ k<l ⟶ [f (k-1); f k; f l]"
using thm2_ind2b (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 < ?k ∧ ?k < ?l ∧ ?l < card ?X⟧ ⟹ [?f (?k - 1);?f ?k;?f ?l]›*) chX (*‹local_long_ch_by_ord f X›*) finiteX (*‹finite X›*) ordered_nats (*‹0 ≤ i ∧ i < j ∧ j < l ∧ l < card X›*) by blast
have "j<l-1 ∨ j=l-1"
using ordered_nats (*‹(0::nat) ≤ (i::nat) ∧ i < (j::nat) ∧ j < (l::nat) ∧ l < card (X::'a::type set)›*) by linarith
thus "?thesis"
(*goal: ‹[f i;f j;f l]›*)
proof (standard)
(*goals:
1. ‹j < l - 1 ⟹ [f i;f j;f l]›
2. ‹j = l - 1 ⟹ [f i;f j;f l]›*)
assume "j<l-1" (*‹(j::nat) < (l::nat) - (1::nat)›*)
have "[f j; f (j+1); f l]"
using e3 (*‹∀k. 0 < k ∧ k < l ⟶ [f (k - 1);f k;f l]›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) ordered_nats (*‹0 ≤ i ∧ i < j ∧ j < l ∧ l < card X›*) using ‹j < l - 1› (*‹j < l - 1›*) less_diff_conv (*‹(?i < ?j - ?k) = (?i + ?k < ?j)›*) by auto
thus "?thesis"
(*goal: ‹[f i;f j;f l]›*)
using e2 (*‹[f i;f j;f (j + 1)]›*) abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) by blast
next
(*goal: ‹j = l - 1 ⟹ [f i;f j;f l]›*)
assume "j=l-1" (*‹(j::nat) = (l::nat) - (1::nat)›*)
thus "?thesis"
(*goal: ‹[f i;f j;f l]›*)
using e2 (*‹[(f::nat ⇒ 'a) (i::nat);f (j::nat);f (j + (1::nat))]›*) using ordered_nats (*‹0 ≤ i ∧ i < j ∧ j < l ∧ l < card X›*) by auto
qed
qed
corollary (*2*) order_finite_chain2:
assumes chX: "[f↝X]"
and finiteX: "finite X"
and ordered_nats: "0 ≤ (i::nat) ∧ i < j ∧ j < l ∧ l < card X"
shows "[f i; f j; f l]"
proof (-)
(*goal: ‹[f i;f j;f l]›*)
have "card X > 2"
using ordered_nats (*‹0 ≤ i ∧ i < j ∧ j < l ∧ l < card X›*) by (simp add: eval_nat_numeral (*‹Numeral1 = Suc 0› ‹numeral (num.Bit0 ?n) = Suc (numeral (Num.BitM ?n))› ‹numeral (num.Bit1 ?n) = Suc (numeral (num.Bit0 ?n))›*))
thus "?thesis"
(*goal: ‹[f i;f j;f l]›*)
using order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a .. ?y::'a] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) short_ch_card(1) (*‹short_ch_by_ord ?f ?Q ⟹ card ?Q = 2›*) by (metis assms (*‹[f↝X]› ‹finite X› ‹0 ≤ i ∧ i < j ∧ j < l ∧ l < card X›*) nat_neq_iff (*‹(?m ≠ ?n) = (?m < ?n ∨ ?n < ?m)›*))
qed
theorem (*2ii*) index_injective:
fixes i::nat and j::nat
assumes chX: "local_long_ch_by_ord f X"
and finiteX: "finite X"
and indices: "i<j" "j<card X"
shows "f i ≠ f j"
proof (cases)
(*goals:
1. ‹?P::bool ⟹ (f::nat ⇒ 'a::type) (i::nat) ≠ f (j::nat)›
2. ‹¬ (?P::bool) ⟹ (f::nat ⇒ 'a::type) (i::nat) ≠ f (j::nat)›*)
assume "Suc i < j" (*‹Suc (i::nat) < (j::nat)›*)
then have "[f i; f (Suc(i)); f j]"
using order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) chX (*‹local_long_ch_by_ord (f::nat ⇒ 'a::type) (X::'a::type set)›*) finiteX (*‹finite X›*) indices(2) (*‹(j::nat) < card (X::'a set)›*) by blast
then show "?thesis"
(*goal: ‹(f::nat ⇒ 'a::type) (i::nat) ≠ f (j::nat)›*)
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) by blast
next
(*goal: ‹¬ Suc i < j ⟹ f i ≠ f j›*)
assume "¬Suc i < j" (*‹¬ Suc (i::nat) < (j::nat)›*)
hence "Suc i = j"
using Suc_lessI (*‹⟦?m < ?n; Suc ?m ≠ ?n⟧ ⟹ Suc ?m < ?n›*) indices(1) (*‹i < j›*) by blast
show "?thesis"
(*goal: ‹(f::nat ⇒ 'a) (i::nat) ≠ f (j::nat)›*)
proof (cases)
(*goals:
1. ‹?P::bool ⟹ (f::nat ⇒ 'a::type) (i::nat) ≠ f (j::nat)›
2. ‹¬ (?P::bool) ⟹ (f::nat ⇒ 'a::type) (i::nat) ≠ f (j::nat)›*)
assume "Suc j = card X" (*‹Suc (j::nat) = card (X::'a set)›*)
then have "0<i"
proof (-)
(*goal: ‹Suc j = card X ⟹ 0 < i›*)
have "card X ≥ 3"
using assms(1) (*‹local_long_ch_by_ord f X›*) finiteX (*‹finite X›*) long_chain_card_geq (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X⟧ ⟹ 3 ≤ card ?X›*) by blast
thus "?thesis"
(*goal: ‹0 < i›*)
using ‹Suc i = j› (*‹Suc i = j›*) ‹Suc j = card X› (*‹Suc j = card X›*) by linarith
qed
then have "[f 0; f i; f j]"
using assms (*‹local_long_ch_by_ord f X› ‹finite X› ‹i < j› ‹j < card X›*) order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) by blast
thus "?thesis"
(*goal: ‹f i ≠ f j›*)
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) by blast
next
(*goal: ‹Suc j ≠ card X ⟹ f i ≠ f j›*)
assume "¬Suc j = card X" (*‹Suc (j::nat) ≠ card (X::'a set)›*)
then have "Suc j < card X"
using Suc_lessI (*‹⟦?m < ?n; Suc ?m ≠ ?n⟧ ⟹ Suc ?m < ?n›*) indices(2) (*‹(j::nat) < card (X::'a::type set)›*) by blast
then have "[f i; f j; f(Suc j)]"
using chX (*‹local_long_ch_by_ord (f::nat ⇒ 'a) (X::'a set)›*) finiteX (*‹finite X›*) indices(1) (*‹(i::nat) < (j::nat)›*) order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) by blast
thus "?thesis"
(*goal: ‹f i ≠ f j›*)
using abc_abc_neq (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) by blast
qed
qed
theorem (*2ii*) index_injective2:
fixes i::nat and j::nat
assumes chX: "[f↝X]"
and finiteX: "finite X"
and indices: "i<j" "j<card X"
shows "f i ≠ f j"
using assms(1) (*‹[f↝X]›*) unfolding ch_by_ord_def
(*goal: ‹f i ≠ f j›*)
proof (rule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹short_ch_by_ord f X ⟹ f i ≠ f j›
2. ‹local_long_ch_by_ord f X ⟹ f i ≠ f j›*)
assume asm: "short_ch_by_ord f X" (*‹short_ch_by_ord (f::nat ⇒ 'a) (X::'a set)›*)
hence "card X = 2"
using short_ch_card(1) (*‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ⟹ card ?Q = (2::nat)›*) by simp
hence "j=1" "i=0"
using indices (*‹i < j› ‹(j::nat) < card (X::'a set)›*) plus_1_eq_Suc (*‹(+) 1 = Suc›*) apply -
(*goals:
1. ‹⟦card X = 2; i < j; j < card X; (+) 1 = Suc⟧ ⟹ j = 1›
2. ‹⟦card X = 2; i < j; j < card X; (+) 1 = Suc⟧ ⟹ i = 0›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
thus "?thesis"
(*goal: ‹f i ≠ f j›*)
using asm (*‹short_ch_by_ord f X›*) unfolding chain_defs
(*goal: ‹(f::nat ⇒ 'a) (i::nat) ≠ f (j::nat)›*)
by force
next
(*goal: ‹local_long_ch_by_ord (f::nat ⇒ 'a::type) (X::'a::type set) ⟹ f (i::nat) ≠ f (j::nat)›*)
assume "local_long_ch_by_ord f X" (*‹local_long_ch_by_ord (f::nat ⇒ 'a) (X::'a set)›*)
thus "?thesis"
(*goal: ‹f i ≠ f j›*)
using index_injective (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; ?i < ?j; ?j < card ?X⟧ ⟹ ?f ?i ≠ ?f ?j›*) assms (*‹[f↝X]› ‹finite X› ‹i < j› ‹j < card X›*) by presburger
qed
text ‹
Surjectivity of the index function is easily derived from the definition of ‹local_ordering›,
so we obtain bijectivity as an easy corollary to the second part of Theorem 2.
›
corollary index_bij_betw:
assumes chX: "local_long_ch_by_ord f X"
and finiteX: "finite X"
shows "bij_betw f {0..<card X} X"
proof (unfold bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*), rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹inj_on (f::nat ⇒ 'a::type) {0::nat..<card (X::'a::type set)}›
2. ‹(f::nat ⇒ 'a::type) ` {0::nat..<card (X::'a::type set)} = X›*)
show "inj_on f {0..<card X}"
using index_injective[OF assms] (*‹⟦?i < ?j; ?j < card X⟧ ⟹ f ?i ≠ f ?j›*) by (metis (mono_tags) atLeastLessThan_iff (*‹(?i ∈ {?l..<?u}) = (?l ≤ ?i ∧ ?i < ?u)›*) inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*) nat_neq_iff (*‹(?m ≠ ?n) = (?m < ?n ∨ ?n < ?m)›*))
{
fix n
assume "n ∈ {0..<card X}" (*‹(n::nat) ∈ {0::nat..<card (X::'a set)}›*)
then have "f n ∈ X"
using assms (*‹local_long_ch_by_ord f X› ‹finite X›*) unfolding chain_defs local_ordering_def
(*goal: ‹(f::nat ⇒ 'a) (n::nat) ∈ (X::'a set)›*)
by auto
}
moreover {
fix x
assume "x ∈ X" (*‹(x::'a) ∈ (X::'a set)›*)
then have "∃n ∈ {0..<card X}. f n = x"
using assms (*‹local_long_ch_by_ord f X› ‹finite X›*) unfolding chain_defs local_ordering_def
(*goal: ‹∃n∈{0..<card X}. f n = x›*)
using atLeastLessThan_iff (*‹(?i ∈ {?l..<?u}) = (?l ≤ ?i ∧ ?i < ?u)›*) bot_nat_0.extremum (*‹0 ≤ ?a›*) by blast
}
ultimately show "f ` {0..<card X} = X"
by blast
qed
corollary index_bij_betw2:
assumes chX: "[f↝X]"
and finiteX: "finite X"
shows "bij_betw f {0..<card X} X"
using assms(1) (*‹[f↝X]›*) unfolding ch_by_ord_def
(*goal: ‹bij_betw f {0..<card X} X›*)
proof (rule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹short_ch_by_ord f X ⟹ bij_betw f {0..<card X} X›
2. ‹local_long_ch_by_ord f X ⟹ bij_betw f {0..<card X} X›*)
assume "local_long_ch_by_ord f X" (*‹local_long_ch_by_ord (f::nat ⇒ 'a) (X::'a set)›*)
thus "bij_betw f {0..<card X} X"
using index_bij_betw (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X⟧ ⟹ bij_betw ?f {0..<card ?X} ?X›*) assms (*‹[f::nat ⇒ 'a↝X::'a set]› ‹finite X›*) by presburger
next
(*goal: ‹short_ch_by_ord f X ⟹ bij_betw f {0..<card X} X›*)
assume asm: "short_ch_by_ord f X" (*‹short_ch_by_ord (f::nat ⇒ 'a) (X::'a set)›*)
show "bij_betw f {0..<card X} X"
proof (unfold bij_betw_def (*‹bij_betw (?f::?'a ⇒ ?'b) (?A::?'a set) (?B::?'b set) = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*), rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹inj_on f {0..<card X}›
2. ‹f ` {0..<card X} = X›*)
show "inj_on f {0..<card X}"
using index_injective2[OF assms] (*‹⟦?i < ?j; ?j < card X⟧ ⟹ f ?i ≠ f ?j›*) by (metis (mono_tags) atLeastLessThan_iff (*‹(?i ∈ {?l..<?u}) = (?l ≤ ?i ∧ ?i < ?u)›*) inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*) nat_neq_iff (*‹(?m ≠ ?n) = (?m < ?n ∨ ?n < ?m)›*))
{
fix n
assume asm2: "n ∈ {0..<card X}" (*‹(n::nat) ∈ {0::nat..<card (X::'a set)}›*)
have "f n ∈ X"
using asm (*‹short_ch_by_ord f X›*) asm2 (*‹(n::nat) ∈ {0::nat..<card (X::'a set)}›*) short_ch_card(1) (*‹short_ch_by_ord ?f ?Q ⟹ card ?Q = 2›*) apply (simp add: eval_nat_numeral (*‹Numeral1 = Suc (0::nat)› ‹numeral (num.Bit0 (?n::num)) = Suc (numeral (Num.BitM ?n))› ‹numeral (num.Bit1 (?n::num)) = Suc (numeral (num.Bit0 ?n))›*))
(*goal: ‹f n ∈ X›*)
by (metis One_nat_def (*‹1 = Suc 0›*) less_Suc0 (*‹(?n < Suc 0) = (?n = 0)›*) less_antisym (*‹⟦¬ ?n < ?m; ?n < Suc ?m⟧ ⟹ ?m = ?n›*) short_ch_ord_in (*‹short_ch_by_ord ?f ?Q ⟹ ?f 0 ∈ ?Q› ‹short_ch_by_ord ?f ?Q ⟹ ?f 1 ∈ ?Q›*))
}
moreover {
fix x
assume asm2: "x ∈ X" (*‹(x::'a) ∈ (X::'a set)›*)
have "∃n ∈ {0..<card X}. f n = x"
using short_ch_card(1) (*‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ⟹ card ?Q = (2::nat)›*) short_ch_by_ord_def (*‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))›*) asm (*‹short_ch_by_ord f X›*) asm2 (*‹(x::'a::type) ∈ (X::'a::type set)›*) atLeast0_lessThan_Suc (*‹{0..<Suc ?n} = insert ?n {0..<?n}›*) by (auto simp: eval_nat_numeral (*‹Numeral1 = Suc 0› ‹numeral (num.Bit0 ?n) = Suc (numeral (Num.BitM ?n))› ‹numeral (num.Bit1 ?n) = Suc (numeral (num.Bit0 ?n))›*))
}
ultimately show "f ` {0..<card X} = X"
by blast
qed
qed
subsection "Additional lemmas about chains"
lemma first_neq_last:
assumes "[f↝Q|x..z]"
shows "x≠z"
apply (cases rule: finite_chain_with_cases[OF assms] (*‹⟦⟦x = f 0; z = f (card Q - 1); short_ch_by_ord f Q⟧ ⟹ ?thesis; ⟦x = f 0; z = f (card Q - 1); 3 ≤ card Q; local_long_ch_by_ord f Q⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goal: ‹x ≠ z›*)
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) apply (metis Suc_1 (*‹Suc (1::nat) = (2::nat)›*) card_2_iff (*‹(card (?S::?'a set) = (2::nat)) = (∃(x::?'a) y::?'a. ?S = {x, y} ∧ x ≠ y)›*) diff_Suc_1 (*‹Suc (?n::nat) - (1::nat) = ?n›*))
(*top goal: ‹⟦x = f 0; z = f (card Q - 1); short_ch_by_ord f Q⟧ ⟹ x ≠ z› and 1 goal remains*)
using index_injective[of f Q 0 "card Q - 1"] (*‹⟦local_long_ch_by_ord f Q; finite Q; 0 < card Q - 1; card Q - 1 < card Q⟧ ⟹ f 0 ≠ f (card Q - 1)›*) by (metis card.infinite (*‹infinite ?A ⟹ card ?A = 0›*) diff_is_0_eq (*‹(?m - ?n = 0) = (?m ≤ ?n)›*) diff_less (*‹⟦0 < ?n; 0 < ?m⟧ ⟹ ?m - ?n < ?m›*) gr0I (*‹(?n = 0 ⟹ False) ⟹ 0 < ?n›*) le_trans (*‹⟦?i ≤ ?j; ?j ≤ ?k⟧ ⟹ ?i ≤ ?k›*) less_imp_le_nat (*‹?m < ?n ⟹ ?m ≤ ?n›*) less_numeral_extra( (*‹0 < 1›*) 1) numeral_le_one_iff (*‹(numeral ?n ≤ 1) = (?n ≤ num.One)›*) semiring_norm( (*‹(num.Bit1 ?m ≤ num.One) = False›*) 70))
lemma index_middle_element:
assumes "[f↝X|a..b..c]"
shows "∃n. 0<n ∧ n<(card X - 1) ∧ f n = b"
proof (-)
(*goal: ‹∃n>0. n < card X - 1 ∧ f n = b›*)
obtain n where n_def: "n < card X" "f n = b"
(*goal: ‹(⋀n. ⟦n < card X; f n = b⟧ ⟹ thesis) ⟹ thesis›*)
using local_ordering_def (*‹local_ordering ?f ?ord ?X ≡ (∀n. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x∈?X. ∃n. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) assms (*‹[f↝X|a..b..c]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis two_ordered_loc (*‹⟦?a = ?f 0; ?b = ?f 1⟧ ⟹ local_ordering ?f ?ord {?a, ?b}›*))
have "0<n ∧ n<(card X - 1) ∧ f n = b"
using assms (*‹[f↝X|a..b..c]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) n_def (*‹n < card X› ‹f n = b›*) by (metis (no_types, lifting) Suc_pred' (*‹0 < ?n ⟹ ?n = Suc (?n - 1)›*) gr_implies_not0 (*‹?m < ?n ⟹ ?n ≠ 0›*) less_SucE (*‹⟦?m < Suc ?n; ?m < ?n ⟹ ?P; ?m = ?n ⟹ ?P⟧ ⟹ ?P›*) not_gr_zero (*‹(¬ 0 < ?n) = (?n = 0)›*))
thus "?thesis"
(*goal: ‹∃n>0. n < card X - 1 ∧ f n = b›*)
by blast
qed
text ‹
Another corollary to Theorem 2, without mentioning indices.
›
corollary fin_ch_betw: "[f↝X|a..b..c] ⟹ [a;b;c]"
using order_finite_chain2 (*‹⟦[?f↝?X]; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) index_middle_element (*‹[?f↝?X|?a..?b..?c] ⟹ ∃n>0. n < card ?X - 1 ∧ ?f n = ?b›*) using finite_chain_def (*‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]›*) finite_chain_with_def (*‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis (no_types, lifting) card_gt_0_iff (*‹(0 < card ?A) = (?A ≠ {} ∧ finite ?A)›*) diff_less (*‹⟦0 < ?n; 0 < ?m⟧ ⟹ ?m - ?n < ?m›*) empty_iff (*‹(?c ∈ {}) = False›*) le_eq_less_or_eq (*‹(?m ≤ ?n) = (?m < ?n ∨ ?m = ?n)›*) less_one (*‹(?n < 1) = (?n = 0)›*))
lemma long_chain_2_imp_3: "⟦[f↝X|a..c]; card X > 2⟧ ⟹ ∃b. [f↝X|a..b..c]"
using points_in_chain (*‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a .. ?z::'a] ⟹ ?x ∈ ?Q ∧ ?z ∈ ?Q›*) first_neq_last (*‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a .. ?z::'a] ⟹ ?x ≠ ?z›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis card_2_iff' (*‹(card ?S = 2) = (∃x∈?S. ∃y∈?S. x ≠ y ∧ (∀z∈?S. z = x ∨ z = y))›*) numeral_less_iff (*‹(numeral ?m < numeral ?n) = (?m < ?n)›*) semiring_norm( (*‹(?m < num.One) = False› ‹(num.Bit0 ?m < num.Bit0 ?n) = (?m < ?n)›*) 75,78))
lemma finite_chain2_betw: "⟦[f↝X|a..c]; card X > 2⟧ ⟹ ∃b. [a;b;c]"
using fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*) long_chain_2_imp_3 (*‹⟦[?f↝?X|?a .. ?c]; 2 < card ?X⟧ ⟹ ∃b. [?f↝?X|?a..b..?c]›*) by metis
lemma finite_long_chain_with_alt [chain_alts]: "[f↝Q|x..y..z] ⟷ [f↝Q|x..z] ∧ [x;y;z] ∧ y∈Q"
proof (standard)
(*goals:
1. ‹[f↝Q|x..y..z] ⟹ [f↝Q|x .. z] ∧ [x;y;z] ∧ y ∈ Q›
2. ‹[f↝Q|x .. z] ∧ [x;y;z] ∧ y ∈ Q ⟹ [f↝Q|x..y..z]›*)
{
assume "[f↝Q|x .. z] ∧ [x;y;z] ∧ y∈Q" (*‹[f::nat ⇒ 'a↝Q::'a set|x::'a .. z::'a] ∧ [x;y::'a;z] ∧ y ∈ Q›*)
thus "[f↝Q|x..y..z]"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by blast
}
{
assume asm: "[f↝Q|x..y..z]" (*‹[f::nat ⇒ 'a↝Q::'a set|x::'a..y::'a..z::'a]›*)
show "[f↝Q|x .. z] ∧ [x;y;z] ∧ y∈Q"
using asm (*‹[f↝Q|x..y..z]›*) fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*) finite_long_chain_with_def (*‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by blast
}
qed
lemma finite_long_chain_with_card: "[f↝Q|x..y..z] ⟹ card Q ≥ 3"
unfolding chain_defs numeral_3_eq_3
(*goal: ‹((finite Q ∧ (Q = {f 0, f 1} ∧ (∃Q. path Q (f 0) (f 1)) ∨ (infinite Q ∨ Suc (Suc (Suc 0)) ≤ card Q) ∧ local_ordering f betw Q)) ∧ f 0 = x ∧ f (card Q - 1) = z) ∧ x ≠ y ∧ y ≠ z ∧ y ∈ Q ⟹ Suc (Suc (Suc 0)) ≤ card Q›*)
by fastforce
lemma finite_long_chain_with_alt2:
assumes "finite Q" "local_long_ch_by_ord f Q" "f 0 = x" "f (card Q - 1) = z" "[x;y;z] ∧ y∈Q"
shows "[f↝Q|x..y..z]"
using assms (*‹finite Q› ‹local_long_ch_by_ord f Q› ‹f 0 = x› ‹f (card Q - 1) = z› ‹[x::'a;y::'a;z::'a] ∧ y ∈ (Q::'a set)›*) finite_chain_alt (*‹finite_chain ?f ?Q = (short_ch_by_ord ?f ?Q ∨ finite ?Q ∧ local_long_ch_by_ord ?f ?Q)›*) finite_chain_with_def (*‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y›*) finite_long_chain_with_alt (*‹[?f↝?Q|?x..?y..?z] = ([?f↝?Q|?x .. ?z] ∧ [?x;?y;?z] ∧ ?y ∈ ?Q)›*) by blast
lemma finite_long_chain_with_alt3:
assumes "finite Q" "local_long_ch_by_ord f Q" "f 0 = x" "f (card Q - 1) = z" "y≠x ∧ y≠z ∧ y∈Q"
shows "[f↝Q|x..y..z]"
using assms (*‹finite Q› ‹local_long_ch_by_ord f Q› ‹f 0 = x› ‹f (card Q - 1) = z› ‹y ≠ x ∧ y ≠ z ∧ y ∈ Q›*) finite_chain_alt (*‹finite_chain ?f ?Q = (short_ch_by_ord ?f ?Q ∨ finite ?Q ∧ local_long_ch_by_ord ?f ?Q)›*) finite_chain_with_def (*‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by auto
lemma chain_sym_obtain:
assumes "[f↝X|a..b..c]"
obtains g where "[g↝X|c..b..a]" and "g=(λn. f (card X - 1 - n))"
using ordering_sym_loc[of betw X f] (*‹⟦⋀a b c. [a;b;c] ⟹ [c;b;a]; finite X; local_ordering f betw X⟧ ⟹ local_ordering (λn. f (card X - 1 - n)) betw X›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) assms (*‹[f↝X|a..b..c]›*) unfolding chain_defs
(*goal: ‹(⋀g. ⟦((finite X ∧ (X = {g 0, g 1} ∧ (∃Q. path Q (g 0) (g 1)) ∨ (infinite X ∨ 3 ≤ card X) ∧ local_ordering g betw X)) ∧ g 0 = c ∧ g (card X - 1) = a) ∧ c ≠ b ∧ b ≠ a ∧ b ∈ X; g = (λn. f (card X - 1 - n))⟧ ⟹ thesis) ⟹ thesis›*)
using first_neq_last (*‹[?f↝?Q|?x .. ?z] ⟹ ?x ≠ ?z›*) points_in_long_chain(3) (*‹[?f↝?Q|?x..?y..?z] ⟹ ?z ∈ ?Q›*) by (metis assms (*‹[f↝X|a..b..c]›*) diff_self_eq_0 (*‹?m - ?m = 0›*) empty_iff (*‹(?c ∈ {}) = False›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) minus_nat.diff_0 (*‹?m - 0 = ?m›*))
lemma chain_sym:
assumes "[f↝X|a..b..c]"
shows "[λn. f (card X - 1 - n)↝X|c..b..a]"
using chain_sym_obtain[where f = f and a = a and b = b and c = c and X = X] (*‹⟦[f↝X|a..b..c]; ⋀g. ⟦[g↝X|c..b..a]; g = (λn. f (card X - 1 - n))⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) using assms(1) (*‹[f↝X|a..b..c]›*) by blast
lemma chain_sym2:
assumes "[f↝X|a..c]"
shows "[λn. f (card X - 1 - n)↝X|c..a]"
proof (-)
(*goal: ‹[λn. f (card X - 1 - n)↝X|c .. a]›*)
{
assume asm: "a = f 0" "c = f (card X - 1)" and asm_short: "short_ch_by_ord f X" (*‹(a::'a) = (f::nat ⇒ 'a) (0::nat)› ‹(c::'a) = (f::nat ⇒ 'a) (card (X::'a set) - (1::nat))› ‹short_ch_by_ord (f::nat ⇒ 'a) (X::'a set)›*)
hence cardX: "card X = 2"
using short_ch_card(1) (*‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ⟹ card ?Q = (2::nat)›*) by auto
hence ac: "f 0 = a" "f 1 = c"
apply -
(*goals:
1. ‹card X = 2 ⟹ f 0 = a›
2. ‹card X = 2 ⟹ f 1 = c›
discuss goal 1*)
apply (simp add: asm (*‹a = f 0› ‹c = f (card X - 1)›*))
(*discuss goal 2*)
apply (simp add: asm (*‹(a::'a) = (f::nat ⇒ 'a) (0::nat)› ‹(c::'a) = (f::nat ⇒ 'a) (card (X::'a set) - (1::nat))›*))
(*proven 2 subgoals*) .
have "n=1 ∨ n=0" if "n<card X" for n
using cardX (*‹card (X::'a set) = (2::nat)›*) that (*‹n < card X›*) by linarith
hence fn_eq: "(λn. if n = 0 then f 1 else f 0) = (λn. f (card X - Suc n))" if "n<card X" for n
by (metis One_nat_def (*‹1 = Suc 0›*) Zero_not_Suc (*‹0 ≠ Suc ?m›*) ac( (*‹f 1 = c›*) 2) asm( (*‹c = f (card X - 1)›*) 2) not_gr_zero (*‹(¬ 0 < ?n) = (?n = 0)›*) old.nat.inject (*‹(Suc ?nat = Suc ?nat') = (?nat = ?nat')›*) zero_less_diff (*‹(0 < ?n - ?m) = (?m < ?n)›*))
have "c = f (card X - 1 - 0)" and "a = f (card X - 1 - (card X - 1))" and "short_ch_by_ord (λn. f (card X - 1 - n)) X"
apply ((simp add: asm (*‹a = f 0› ‹c = f (card X - 1)›*))+)
(*top goal: ‹c = f (card X - 1 - 0)› and 2 goals remain*)
using short_ch_sym[OF asm_short] (*‹short_ch_by_ord (λn. if n = 0 then f 1 else f 0) X›*) fn_eq (*‹?n < card X ⟹ (λn. if n = 0 then f 1 else f 0) = (λn. f (card X - Suc n))›*) ‹f 1 = c› (*‹f 1 = c›*) asm(2) (*‹c = f (card X - 1)›*) short_ch_by_ord_def (*‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))›*) by fastforce
}
consider "short_ch_by_ord f X" | "∃b. [f↝X|a..b..c]"
(*goal: ‹⟦short_ch_by_ord f X ⟹ thesis; ∃b. [f↝X|a..b..c] ⟹ thesis⟧ ⟹ thesis›*)
using assms (*‹[f↝X|a .. c]›*) long_chain_2_imp_3 (*‹⟦[?f::nat ⇒ 'a↝?X::'a set|?a::'a .. ?c::'a]; (2::nat) < card ?X⟧ ⟹ ∃b::'a. [?f↝?X|?a..b..?c]›*) finite_chain_with_alt (*‹[?f↝?Q|?x .. ?z] = ((short_ch_by_ord ?f ?Q ∨ 3 ≤ card ?Q ∧ local_ordering ?f betw ?Q) ∧ ?x = ?f 0 ∧ ?z = ?f (card ?Q - 1))›*) by fastforce
thus "?thesis"
(*goal: ‹[λn. f (card X - 1 - n)↝X|c .. a]›*)
apply cases
(*goal: ‹[λn. f (card X - 1 - n)↝X|c .. a]›*)
using ‹⟦a=f 0; c=f (card X-1); short_ch_by_ord f X⟧ ⟹ short_ch_by_ord (λn. f (card X -1-n)) X› (*‹⟦a = f 0; c = f (card X - 1); short_ch_by_ord f X⟧ ⟹ short_ch_by_ord (λn. f (card X - 1 - n)) X›*) assms (*‹[f↝X|a .. c]›*) finite_chain_alt (*‹finite_chain ?f ?Q = (short_ch_by_ord ?f ?Q ∨ finite ?Q ∧ local_long_ch_by_ord ?f ?Q)›*) finite_chain_with_def (*‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type .. ?y::'a::type] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y›*) apply ((auto)[1])
(*top goal: ‹short_ch_by_ord f X ⟹ [λn. f (card X - 1 - n)↝X|c .. a]› and 1 goal remains*)
using chain_sym (*‹[?f↝?X|?a..?b..?c] ⟹ [λn. ?f (card ?X - 1 - n)↝?X|?c..?b..?a]›*) finite_long_chain_with_alt (*‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] = ([?f↝?Q|?x .. ?z] ∧ [?x;?y;?z] ∧ ?y ∈ ?Q)›*) by blast
qed
lemma chain_sym_obtain2:
assumes "[f↝X|a..c]"
obtains g where "[g↝X|c..a]" and "g=(λn. f (card X - 1 - n))"
using assms (*‹[f↝X|a .. c]›*) chain_sym2 (*‹[?f::nat ⇒ 'a↝?X::'a set|?a::'a .. ?c::'a] ⟹ [λn::nat. ?f (card ?X - (1::nat) - n)↝?X|?c .. ?a]›*) by auto
end (* context MinkowskiBetweenness *)
section "Preliminary Results for Kinematic Triangles and Paths/Betweenness"
text ‹
Theorem 3 (collinearity)
First we prove some lemmas that will be very helpful.
›
context MinkowskiPrimitive begin
lemma triangle_permutes [no_atp]:
assumes "△ a b c"
shows "△ a c b" "△ b a c" "△ b c a" "△ c a b" "△ c b a"
using assms (*‹△ a b c›*) apply -
(*goals:
1. ‹△ (a::'a) (b::'a) (c::'a) ⟹ △ a c b›
2. ‹△ (a::'a) (b::'a) (c::'a) ⟹ △ b a c›
3. ‹△ (a::'a) (b::'a) (c::'a) ⟹ △ b c a›
4. ‹△ (a::'a) (b::'a) (c::'a) ⟹ △ c a b›
5. ‹△ (a::'a) (b::'a) (c::'a) ⟹ △ c b a›
discuss goal 1*)
apply ((auto simp add: kinematic_triangle_def (*‹△ (?a::'a) (?b::'a) (?c::'a) ≡ ?a ∈ (ℰ::'a set) ∧ ?b ∈ ℰ ∧ ?c ∈ ℰ ∧ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c ∧ (∃Q::'a set∈𝒫::'a set set. ∃R::'a set∈𝒫. Q ≠ R ∧ (∃S::'a set∈𝒫. Q ≠ S ∧ R ≠ S ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?a ∈ R ∧ ?c ∈ R ∧ ?b ∈ S ∧ ?c ∈ S))›*))[1])
(*discuss goal 2*)
apply ((auto simp add: kinematic_triangle_def (*‹△ ?a ?b ?c ≡ ?a ∈ ℰ ∧ ?b ∈ ℰ ∧ ?c ∈ ℰ ∧ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c ∧ (∃Q∈𝒫. ∃R∈𝒫. Q ≠ R ∧ (∃S∈𝒫. Q ≠ S ∧ R ≠ S ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?a ∈ R ∧ ?c ∈ R ∧ ?b ∈ S ∧ ?c ∈ S))›*))[1])
(*discuss goal 3*)
apply ((auto simp add: kinematic_triangle_def (*‹△ ?a ?b ?c ≡ ?a ∈ ℰ ∧ ?b ∈ ℰ ∧ ?c ∈ ℰ ∧ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c ∧ (∃Q∈𝒫. ∃R∈𝒫. Q ≠ R ∧ (∃S∈𝒫. Q ≠ S ∧ R ≠ S ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?a ∈ R ∧ ?c ∈ R ∧ ?b ∈ S ∧ ?c ∈ S))›*))[1])
(*discuss goal 4*)
apply ((auto simp add: kinematic_triangle_def (*‹△ ?a ?b ?c ≡ ?a ∈ ℰ ∧ ?b ∈ ℰ ∧ ?c ∈ ℰ ∧ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c ∧ (∃Q∈𝒫. ∃R∈𝒫. Q ≠ R ∧ (∃S∈𝒫. Q ≠ S ∧ R ≠ S ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?a ∈ R ∧ ?c ∈ R ∧ ?b ∈ S ∧ ?c ∈ S))›*))[1])
(*discuss goal 5*)
apply ((auto simp add: kinematic_triangle_def (*‹△ ?a ?b ?c ≡ ?a ∈ ℰ ∧ ?b ∈ ℰ ∧ ?c ∈ ℰ ∧ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c ∧ (∃Q∈𝒫. ∃R∈𝒫. Q ≠ R ∧ (∃S∈𝒫. Q ≠ S ∧ R ≠ S ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?a ∈ R ∧ ?c ∈ R ∧ ?b ∈ S ∧ ?c ∈ S))›*))[1])
(*proven 5 subgoals*) .
lemma triangle_paths [no_atp]:
assumes tri_abc: "△ a b c"
shows "path_ex a b" "path_ex a c" "path_ex b c"
using tri_abc (*‹△ a b c›*) apply -
(*goals:
1. ‹△ a b c ⟹ ∃Q. path Q a b›
2. ‹△ a b c ⟹ ∃Q. path Q a c›
3. ‹△ a b c ⟹ ∃Q. path Q b c›
discuss goal 1*)
apply ((auto simp add: kinematic_triangle_def (*‹△ ?a ?b ?c ≡ ?a ∈ ℰ ∧ ?b ∈ ℰ ∧ ?c ∈ ℰ ∧ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c ∧ (∃Q∈𝒫. ∃R∈𝒫. Q ≠ R ∧ (∃S∈𝒫. Q ≠ S ∧ R ≠ S ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?a ∈ R ∧ ?c ∈ R ∧ ?b ∈ S ∧ ?c ∈ S))›*))[1])
(*discuss goal 2*)
apply ((auto simp add: kinematic_triangle_def (*‹△ (?a::'a::type) (?b::'a::type) (?c::'a::type) ≡ ?a ∈ (ℰ::'a::type set) ∧ ?b ∈ ℰ ∧ ?c ∈ ℰ ∧ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c ∧ (∃Q::'a::type set∈𝒫::'a::type set set. ∃R::'a::type set∈𝒫. Q ≠ R ∧ (∃S::'a::type set∈𝒫. Q ≠ S ∧ R ≠ S ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?a ∈ R ∧ ?c ∈ R ∧ ?b ∈ S ∧ ?c ∈ S))›*))[1])
(*discuss goal 3*)
apply ((auto simp add: kinematic_triangle_def (*‹△ ?a ?b ?c ≡ ?a ∈ ℰ ∧ ?b ∈ ℰ ∧ ?c ∈ ℰ ∧ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c ∧ (∃Q∈𝒫. ∃R∈𝒫. Q ≠ R ∧ (∃S∈𝒫. Q ≠ S ∧ R ≠ S ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?a ∈ R ∧ ?c ∈ R ∧ ?b ∈ S ∧ ?c ∈ S))›*))[1])
(*proven 3 subgoals*) .
lemma triangle_paths_unique:
assumes tri_abc: "△ a b c"
shows "∃!ab. path ab a b"
using path_unique (*‹⟦path ?ab ?a ?b; path ?ab' ?a ?b⟧ ⟹ ?ab = ?ab'›*) tri_abc (*‹△ a b c›*) triangle_paths(1) (*‹△ (?a::'a) (?b::'a) (?c::'a) ⟹ ∃Q::'a set. path Q ?a ?b›*) by auto
text ‹
The definition of the kinematic triangle says that there exist paths that $a$ and $b$ pass through,
and $a$ and $c$ pass through etc that are not equal. But we can show there is a \emph{unique} $ab$ that $a$
and $b$ pass through, and assuming there is a path $abc$ that $a, b, c$ pass through, it must be
unique. Therefore ‹ab = abc› and ‹ac = abc›, but ‹ab ≠ ac›, therefore ‹False›.
Lemma ‹tri_three_paths› is not in the books but might simplify some path obtaining.
›
lemma triangle_diff_paths:
assumes tri_abc: "△ a b c"
shows "¬ (∃Q∈𝒫. a ∈ Q ∧ b ∈ Q ∧ c ∈ Q)"
proof (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹∃Q∈𝒫. a ∈ Q ∧ b ∈ Q ∧ c ∈ Q ⟹ False›*)
assume not_thesis: "∃Q∈𝒫. a ∈ Q ∧ b ∈ Q ∧ c ∈ Q" (*‹∃Q::'a set∈𝒫::'a set set. (a::'a) ∈ Q ∧ (b::'a) ∈ Q ∧ (c::'a) ∈ Q›*)
then obtain abc where path_abc: "abc ∈ 𝒫 ∧ a ∈ abc ∧ b ∈ abc ∧ c ∈ abc"
(*goal: ‹(⋀abc. abc ∈ 𝒫 ∧ a ∈ abc ∧ b ∈ abc ∧ c ∈ abc ⟹ thesis) ⟹ thesis›*)
by auto
have abc_neq: "a ≠ b ∧ a ≠ c ∧ b ≠ c"
using tri_abc (*‹△ a b c›*) kinematic_triangle_def (*‹△ ?a ?b ?c ≡ ?a ∈ ℰ ∧ ?b ∈ ℰ ∧ ?c ∈ ℰ ∧ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c ∧ (∃Q∈𝒫. ∃R∈𝒫. Q ≠ R ∧ (∃S∈𝒫. Q ≠ S ∧ R ≠ S ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?a ∈ R ∧ ?c ∈ R ∧ ?b ∈ S ∧ ?c ∈ S))›*) by simp
have "∃ab∈𝒫. ∃ac∈𝒫. ab ≠ ac ∧ a ∈ ab ∧ b ∈ ab ∧ a ∈ ac ∧ c ∈ ac"
using tri_abc (*‹△ a b c›*) kinematic_triangle_def (*‹△ ?a ?b ?c ≡ ?a ∈ ℰ ∧ ?b ∈ ℰ ∧ ?c ∈ ℰ ∧ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c ∧ (∃Q∈𝒫. ∃R∈𝒫. Q ≠ R ∧ (∃S∈𝒫. Q ≠ S ∧ R ≠ S ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?a ∈ R ∧ ?c ∈ R ∧ ?b ∈ S ∧ ?c ∈ S))›*) by metis
then obtain ab and ac where ab_ac_relate: "ab ∈ 𝒫 ∧ ac ∈ 𝒫 ∧ ab ≠ ac ∧ {a,b} ⊆ ab ∧ {a,c} ⊆ ac"
(*goal: ‹(⋀ab ac. ab ∈ 𝒫 ∧ ac ∈ 𝒫 ∧ ab ≠ ac ∧ {a, b} ⊆ ab ∧ {a, c} ⊆ ac ⟹ thesis) ⟹ thesis›*)
by blast
have "∃!ab∈𝒫. a ∈ ab ∧ b ∈ ab"
using tri_abc (*‹△ a b c›*) triangle_paths_unique (*‹△ ?a ?b ?c ⟹ ∃!ab. path ab ?a ?b›*) by blast
then have ab_eq_abc: "ab = abc"
using path_abc (*‹abc ∈ 𝒫 ∧ a ∈ abc ∧ b ∈ abc ∧ c ∈ abc›*) ab_ac_relate (*‹ab ∈ 𝒫 ∧ ac ∈ 𝒫 ∧ ab ≠ ac ∧ {a, b} ⊆ ab ∧ {a, c} ⊆ ac›*) by auto
have "∃!ac∈𝒫. a ∈ ac ∧ b ∈ ac"
using tri_abc (*‹△ a b c›*) triangle_paths_unique (*‹△ ?a ?b ?c ⟹ ∃!ab. path ab ?a ?b›*) by blast
then have ac_eq_abc: "ac = abc"
using path_abc (*‹(abc::'a::type set) ∈ (𝒫::'a::type set set) ∧ (a::'a::type) ∈ abc ∧ (b::'a::type) ∈ abc ∧ (c::'a::type) ∈ abc›*) ab_ac_relate (*‹ab ∈ 𝒫 ∧ ac ∈ 𝒫 ∧ ab ≠ ac ∧ {a, b} ⊆ ab ∧ {a, c} ⊆ ac›*) eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) abc_neq (*‹a ≠ b ∧ a ≠ c ∧ b ≠ c›*) by auto
have "ab = ac"
using ab_eq_abc (*‹ab = abc›*) ac_eq_abc (*‹(ac::'a set) = (abc::'a set)›*) by simp
thus False
using ab_ac_relate (*‹ab ∈ 𝒫 ∧ ac ∈ 𝒫 ∧ ab ≠ ac ∧ {a, b} ⊆ ab ∧ {a, c} ⊆ ac›*) by simp
qed
lemma tri_three_paths [elim]:
assumes tri_abc: "△ a b c"
shows "∃ab bc ca. path ab a b ∧ path bc b c ∧ path ca c a ∧ ab ≠ bc ∧ ab ≠ ca ∧ bc ≠ ca"
using tri_abc (*‹△ a b c›*) triangle_diff_paths (*‹△ ?a ?b ?c ⟹ ¬ (∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q)›*) triangle_paths(2,3) (*‹△ ?a ?b ?c ⟹ ∃Q. path Q ?a ?c› ‹△ ?a ?b ?c ⟹ ∃Q. path Q ?b ?c›*) triangle_paths_unique (*‹△ ?a ?b ?c ⟹ ∃!ab. path ab ?a ?b›*) by fastforce
lemma triangle_paths_neq:
assumes tri_abc: "△ a b c"
and path_ab: "path ab a b"
and path_ac: "path ac a c"
shows "ab ≠ ac"
using assms (*‹△ a b c› ‹path ab a b› ‹path (ac::'a::type set) (a::'a::type) (c::'a::type)›*) triangle_diff_paths (*‹△ ?a ?b ?c ⟹ ¬ (∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q)›*) by blast
end (*context MinkowskiPrimitive*)
context MinkowskiBetweenness begin
lemma abc_ex_path_unique:
assumes abc: "[a;b;c]"
shows "∃!Q∈𝒫. a ∈ Q ∧ b ∈ Q ∧ c ∈ Q"
proof (-)
(*goal: ‹∃!Q::'a set. Q ∈ (𝒫::'a set set) ∧ (a::'a) ∈ Q ∧ (b::'a) ∈ Q ∧ (c::'a) ∈ Q›*)
have a_neq_c: "a ≠ c"
using abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) abc (*‹[a::'a::type;b::'a::type;c::'a::type]›*) by simp
have "∃Q∈𝒫. a ∈ Q ∧ b ∈ Q ∧ c ∈ Q"
using abc_ex_path (*‹[?a::'a;?b::'a;?c::'a] ⟹ ∃Q::'a set∈𝒫::'a set set. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) abc (*‹[a;b;c]›*) by simp
then obtain P and Q where path_P: "P ∈ 𝒫" and abc_inP: "a ∈ P ∧ b ∈ P ∧ c ∈ P" and path_Q: "Q ∈ 𝒫" and abc_in_Q: "a ∈ Q ∧ b ∈ Q ∧ c ∈ Q"
(*goal: ‹(⋀P Q. ⟦P ∈ 𝒫; a ∈ P ∧ b ∈ P ∧ c ∈ P; Q ∈ 𝒫; a ∈ Q ∧ b ∈ Q ∧ c ∈ Q⟧ ⟹ thesis) ⟹ thesis›*)
by auto
then have "P = Q"
using a_neq_c (*‹a ≠ c›*) eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) by blast
thus "?thesis"
(*goal: ‹∃!Q::'a::type set. Q ∈ (𝒫::'a::type set set) ∧ (a::'a::type) ∈ Q ∧ (b::'a::type) ∈ Q ∧ (c::'a::type) ∈ Q›*)
using eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) a_neq_c (*‹a ≠ c›*) using abc_inP (*‹a ∈ P ∧ b ∈ P ∧ c ∈ P›*) path_P (*‹P ∈ 𝒫›*) by auto
qed
lemma betw_c_in_path:
assumes abc: "[a;b;c]"
and path_ab: "path ab a b"
shows "c ∈ ab"
(* By abc_ex_path, there is a path through a b c. By eq_paths there can be only one, which must be ab. *)
using eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) assms (*‹[a;b;c]› ‹path ab a b›*) by blast
lemma betw_b_in_path:
assumes abc: "[a;b;c]"
and path_ab: "path ac a c"
shows "b ∈ ac"
using assms (*‹[a::'a;b::'a;c::'a]› ‹path ac a c›*) abc_ex_path_unique (*‹[?a;?b;?c] ⟹ ∃!Q. Q ∈ 𝒫 ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) path_unique (*‹⟦path ?ab ?a ?b; path ?ab' ?a ?b⟧ ⟹ ?ab = ?ab'›*) by blast
lemma betw_a_in_path:
assumes abc: "[a;b;c]"
and path_ab: "path bc b c"
shows "a ∈ bc"
using assms (*‹[a;b;c]› ‹path (bc::'a set) (b::'a) (c::'a)›*) abc_ex_path_unique (*‹[?a;?b;?c] ⟹ ∃!Q. Q ∈ 𝒫 ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) path_unique (*‹⟦path ?ab ?a ?b; path ?ab' ?a ?b⟧ ⟹ ?ab = ?ab'›*) by blast
lemma triangle_not_betw_abc:
assumes tri_abc: "△ a b c"
shows "¬ [a;b;c]"
using tri_abc (*‹△ a b c›*) abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) triangle_diff_paths (*‹△ ?a ?b ?c ⟹ ¬ (∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q)›*) by blast
lemma triangle_not_betw_acb:
assumes tri_abc: "△ a b c"
shows "¬ [a;c;b]"
by (simp add: tri_abc (*‹△ (a::'a) (b::'a) (c::'a)›*) triangle_not_betw_abc (*‹△ (?a::'a) (?b::'a) (?c::'a) ⟹ ¬ [?a;?b;?c]›*) triangle_permutes( (*‹△ (?a::'a) (?b::'a) (?c::'a) ⟹ △ ?a ?c ?b›*) 1))
lemma triangle_not_betw_bac:
assumes tri_abc: "△ a b c"
shows "¬ [b;a;c]"
by (simp add: tri_abc (*‹△ a b c›*) triangle_not_betw_abc (*‹△ ?a ?b ?c ⟹ ¬ [?a;?b;?c]›*) triangle_permutes( (*‹△ ?a ?b ?c ⟹ △ ?b ?a ?c›*) 2))
lemma triangle_not_betw_any:
assumes tri_abc: "△ a b c"
shows "¬ (∃d∈{a,b,c}. ∃e∈{a,b,c}. ∃f∈{a,b,c}. [d;e;f])"
by (metis abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) empty_iff (*‹(?c ∈ {}) = False›*) insertE (*‹⟦?a ∈ insert ?b ?A; ?a = ?b ⟹ ?P; ?a ∈ ?A ⟹ ?P⟧ ⟹ ?P›*) tri_abc (*‹△ a b c›*) triangle_diff_paths (*‹△ ?a ?b ?c ⟹ ¬ (∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q)›*))
end (*context MinkowskiBetweenness*)
section "3.2 First collinearity theorem"
theorem (*3*) (in MinkowskiChain) collinearity_alt2:
assumes tri_abc: "△ a b c"
and path_de: "path de d e"
(* This follows immediately from tri_abc without it as an assumption, but we need ab in scope
to refer to it in the conclusion. *)
and path_ab: "path ab a b"
and bcd: "[b;c;d]"
and cea: "[c;e;a]"
shows "∃f∈de∩ab. [a;f;b]"
proof (-)
(*goal: ‹∃f∈de ∩ ab. [a;f;b]›*)
have "∃f∈ab ∩ de. ∃X ord. [ord↝X|a..f..b]"
proof (-)
(*goal: ‹∃f∈ab ∩ de. ∃X ord. [ord↝X|a..f..b]›*)
have "path_ex a c"
using tri_abc (*‹△ a b c›*) triangle_paths(2) (*‹△ (?a::'a) (?b::'a) (?c::'a) ⟹ ∃Q::'a set. path Q ?a ?c›*) by auto
then obtain ac where path_ac: "path ac a c"
(*goal: ‹(⋀ac. path ac a c ⟹ thesis) ⟹ thesis›*)
by auto
have "path_ex b c"
using tri_abc (*‹△ (a::'a) (b::'a) (c::'a)›*) triangle_paths(3) (*‹△ ?a ?b ?c ⟹ ∃Q. path Q ?b ?c›*) by auto
then obtain bc where path_bc: "path bc b c"
(*goal: ‹(⋀bc::'a set. path bc (b::'a) (c::'a) ⟹ thesis::bool) ⟹ thesis›*)
by auto
have ab_neq_ac: "ab ≠ ac"
using triangle_paths_neq (*‹⟦△ ?a ?b ?c; path ?ab ?a ?b; path ?ac ?a ?c⟧ ⟹ ?ab ≠ ?ac›*) path_ab (*‹path ab a b›*) path_ac (*‹path ac a c›*) tri_abc (*‹△ a b c›*) by fastforce
have ab_neq_bc: "ab ≠ bc"
using eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) ab_neq_ac (*‹ab ≠ ac›*) path_ab (*‹path ab a b›*) path_ac (*‹path (ac::'a set) (a::'a) (c::'a)›*) path_bc (*‹path bc b c›*) by blast
have ac_neq_bc: "ac ≠ bc"
using eq_paths (*‹⟦(?P::'a set) ∈ (𝒫::'a set set); (?Q::'a set) ∈ 𝒫; (?a::'a) ∈ ?P; (?b::'a) ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) ab_neq_bc (*‹ab ≠ bc›*) path_ab (*‹path ab a b›*) path_ac (*‹path ac a c›*) path_bc (*‹path bc b c›*) by blast
have d_in_bc: "d ∈ bc"
using bcd (*‹[b;c;d]›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) path_bc (*‹path bc b c›*) by blast
have e_in_ac: "e ∈ ac"
using betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) cea (*‹[c;e;a]›*) path_ac (*‹path ac a c›*) by blast
show "?thesis"
(*goal: ‹∃f∈ab ∩ de. ∃X ord. [ord↝X|a..f..b]›*)
using O6_old[where Q = ab and R = ac and S = bc and T = de and a = a and b = b and c = c] (*‹⟦ab ∈ 𝒫; ac ∈ 𝒫; bc ∈ 𝒫; de ∈ 𝒫; ab ≠ ac; ab ≠ bc; ac ≠ bc; a ∈ ab ∩ ac ∧ b ∈ ab ∩ bc ∧ c ∈ ac ∩ bc; ∃d∈bc. [b;c;d] ∧ (∃e∈ac. d ∈ de ∧ e ∈ de ∧ [c;e;a])⟧ ⟹ ∃f∈de ∩ ab. ∃g X. [g↝X|a..f..b]›*) ab_neq_ac (*‹ab ≠ ac›*) ab_neq_bc (*‹ab ≠ bc›*) ac_neq_bc (*‹(ac::'a set) ≠ (bc::'a set)›*) path_ab (*‹path ab a b›*) path_bc (*‹path bc b c›*) path_ac (*‹path ac a c›*) path_de (*‹path de d e›*) bcd (*‹[b;c;d]›*) cea (*‹[c;e;a]›*) d_in_bc (*‹d ∈ bc›*) e_in_ac (*‹e ∈ ac›*) by auto
qed
thus "?thesis"
(*goal: ‹∃f∈de ∩ ab. [a;f;b]›*)
using fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*) by blast
qed
theorem (*3*) (in MinkowskiChain) collinearity_alt:
assumes tri_abc: "△ a b c"
and path_de: "path de d e"
and bcd: "[b;c;d]"
and cea: "[c;e;a]"
shows "∃ab. path ab a b ∧ (∃f∈de∩ab. [a;f;b])"
proof (-)
(*goal: ‹∃ab. path ab a b ∧ (∃f∈de ∩ ab. [a;f;b])›*)
have ex_path_ab: "path_ex a b"
using tri_abc (*‹△ a b c›*) triangle_paths_unique (*‹△ ?a ?b ?c ⟹ ∃!ab. path ab ?a ?b›*) by blast
then obtain ab where path_ab: "path ab a b"
(*goal: ‹(⋀ab. path ab a b ⟹ thesis) ⟹ thesis›*)
by blast
have "∃f∈ab ∩ de. ∃X g. [g↝X|a..f..b]"
proof (-)
(*goal: ‹∃f∈ab ∩ de. ∃X g. [g↝X|a..f..b]›*)
have "path_ex a c"
using tri_abc (*‹△ a b c›*) triangle_paths(2) (*‹△ ?a ?b ?c ⟹ ∃Q. path Q ?a ?c›*) by auto
then obtain ac where path_ac: "path ac a c"
(*goal: ‹(⋀ac::'a set. path ac (a::'a) (c::'a) ⟹ thesis::bool) ⟹ thesis›*)
by auto
have "path_ex b c"
using tri_abc (*‹△ a b c›*) triangle_paths(3) (*‹△ ?a ?b ?c ⟹ ∃Q. path Q ?b ?c›*) by auto
then obtain bc where path_bc: "path bc b c"
(*goal: ‹(⋀bc::'a set. path bc (b::'a) (c::'a) ⟹ thesis::bool) ⟹ thesis›*)
by auto
have ab_neq_ac: "ab ≠ ac"
using triangle_paths_neq (*‹⟦△ ?a ?b ?c; path ?ab ?a ?b; path ?ac ?a ?c⟧ ⟹ ?ab ≠ ?ac›*) path_ab (*‹path ab a b›*) path_ac (*‹path ac a c›*) tri_abc (*‹△ a b c›*) by fastforce
have ab_neq_bc: "ab ≠ bc"
using eq_paths (*‹⟦(?P::'a::type set) ∈ (𝒫::'a::type set set); (?Q::'a::type set) ∈ 𝒫; (?a::'a::type) ∈ ?P; (?b::'a::type) ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) ab_neq_ac (*‹ab ≠ ac›*) path_ab (*‹path ab a b›*) path_ac (*‹path ac a c›*) path_bc (*‹path (bc::'a set) (b::'a) (c::'a)›*) by blast
have ac_neq_bc: "ac ≠ bc"
using eq_paths (*‹⟦(?P::'a set) ∈ (𝒫::'a set set); (?Q::'a set) ∈ 𝒫; (?a::'a) ∈ ?P; (?b::'a) ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) ab_neq_bc (*‹ab ≠ bc›*) path_ab (*‹path (ab::'a::type set) (a::'a::type) (b::'a::type)›*) path_ac (*‹path ac a c›*) path_bc (*‹path bc b c›*) by blast
have d_in_bc: "d ∈ bc"
using bcd (*‹[b;c;d]›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) path_bc (*‹path bc b c›*) by blast
have e_in_ac: "e ∈ ac"
using betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) cea (*‹[c;e;a]›*) path_ac (*‹path (ac::'a set) (a::'a) (c::'a)›*) by blast
show "?thesis"
(*goal: ‹∃f∈ab ∩ de. ∃X g. [g↝X|a..f..b]›*)
using O6_old[where Q = ab and R = ac and S = bc and T = de and a = a and b = b and c = c] (*‹⟦ab ∈ 𝒫; ac ∈ 𝒫; bc ∈ 𝒫; de ∈ 𝒫; ab ≠ ac; ab ≠ bc; ac ≠ bc; a ∈ ab ∩ ac ∧ b ∈ ab ∩ bc ∧ c ∈ ac ∩ bc; ∃d∈bc. [b;c;d] ∧ (∃e∈ac. d ∈ de ∧ e ∈ de ∧ [c;e;a])⟧ ⟹ ∃f∈de ∩ ab. ∃g X. [g↝X|a..f..b]›*) ab_neq_ac (*‹ab ≠ ac›*) ab_neq_bc (*‹ab ≠ bc›*) ac_neq_bc (*‹ac ≠ bc›*) path_ab (*‹path ab a b›*) path_bc (*‹path (bc::'a set) (b::'a) (c::'a)›*) path_ac (*‹path ac a c›*) path_de (*‹path de d e›*) bcd (*‹[b;c;d]›*) cea (*‹[c::'a::type;e::'a::type;a::'a::type]›*) d_in_bc (*‹d ∈ bc›*) e_in_ac (*‹e ∈ ac›*) by auto
qed
thus "?thesis"
(*goal: ‹∃ab::'a set. path ab (a::'a) (b::'a) ∧ (∃f::'a∈(de::'a set) ∩ ab. [a;f;b])›*)
using fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*) path_ab (*‹path ab a b›*) by fastforce
qed
theorem (*3*) (in MinkowskiChain) collinearity:
assumes tri_abc: "△ a b c"
and path_de: "path de d e"
and bcd: "[b;c;d]"
and cea: "[c;e;a]"
shows "(∃f∈de∩(path_of a b). [a;f;b])"
proof (-)
(*goal: ‹∃f∈de ∩ (THE ab. path ab a b). [a;f;b]›*)
let ?ab = "path_of a b"
have path_ab: "path ?ab a b"
using tri_abc (*‹△ a b c›*) theI'[OF triangle_paths_unique] (*‹△ ?a1 ?b1 ?c1 ⟹ path (THE x. path x ?a1 ?b1) ?a1 ?b1›*) by blast
have "∃f∈?ab ∩ de. ∃X ord. [ord↝X|a..f..b]"
proof (-)
(*goal: ‹∃f∈(THE ab. path ab a b) ∩ de. ∃X ord. [ord↝X|a..f..b]›*)
have "path_ex a c"
using tri_abc (*‹△ a b c›*) triangle_paths(2) (*‹△ ?a ?b ?c ⟹ ∃Q. path Q ?a ?c›*) by auto
then obtain ac where path_ac: "path ac a c"
(*goal: ‹(⋀ac::'a::type set. path ac (a::'a::type) (c::'a::type) ⟹ thesis::bool) ⟹ thesis›*)
by auto
have "path_ex b c"
using tri_abc (*‹△ a b c›*) triangle_paths(3) (*‹△ (?a::'a) (?b::'a) (?c::'a) ⟹ ∃Q::'a set. path Q ?b ?c›*) by auto
then obtain bc where path_bc: "path bc b c"
(*goal: ‹(⋀bc. path bc b c ⟹ thesis) ⟹ thesis›*)
by auto
have ab_neq_ac: "?ab ≠ ac"
using triangle_paths_neq (*‹⟦△ ?a ?b ?c; path ?ab ?a ?b; path ?ac ?a ?c⟧ ⟹ ?ab ≠ ?ac›*) path_ab (*‹path (THE ab. path ab a b) a b›*) path_ac (*‹path ac a c›*) tri_abc (*‹△ a b c›*) by fastforce
have ab_neq_bc: "?ab ≠ bc"
using eq_paths (*‹⟦(?P::'a set) ∈ (𝒫::'a set set); (?Q::'a set) ∈ 𝒫; (?a::'a) ∈ ?P; (?b::'a) ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) ab_neq_ac (*‹(THE ab::'a set. path ab (a::'a) (b::'a)) ≠ (ac::'a set)›*) path_ab (*‹path (THE ab. path ab a b) a b›*) path_ac (*‹path (ac::'a set) (a::'a) (c::'a)›*) path_bc (*‹path bc b c›*) by blast
have ac_neq_bc: "ac ≠ bc"
using eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) ab_neq_bc (*‹(THE ab. path ab a b) ≠ bc›*) path_ab (*‹path (THE ab. path ab a b) a b›*) path_ac (*‹path ac a c›*) path_bc (*‹path bc b c›*) by blast
have d_in_bc: "d ∈ bc"
using bcd (*‹[b;c;d]›*) betw_c_in_path (*‹⟦[?a::'a::type;?b::'a::type;?c::'a::type]; path (?ab::'a::type set) ?a ?b⟧ ⟹ ?c ∈ ?ab›*) path_bc (*‹path (bc::'a::type set) (b::'a::type) (c::'a::type)›*) by blast
have e_in_ac: "e ∈ ac"
using betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) cea (*‹[c;e;a]›*) path_ac (*‹path ac a c›*) by blast
show "?thesis"
(*goal: ‹∃f∈(THE ab. path ab a b) ∩ de. ∃X ord. [ord↝X|a..f..b]›*)
using O6_old[where Q = ?ab and R = ac and S = bc and T = de and a = a and b = b and c = c] (*‹⟦(THE ab. path ab a b) ∈ 𝒫; ac ∈ 𝒫; bc ∈ 𝒫; de ∈ 𝒫; (THE ab. path ab a b) ≠ ac; (THE ab. path ab a b) ≠ bc; ac ≠ bc; a ∈ (THE ab. path ab a b) ∩ ac ∧ b ∈ (THE ab. path ab a b) ∩ bc ∧ c ∈ ac ∩ bc; ∃d∈bc. [b;c;d] ∧ (∃e∈ac. d ∈ de ∧ e ∈ de ∧ [c;e;a])⟧ ⟹ ∃f∈de ∩ (THE ab. path ab a b). ∃g X. [g↝X|a..f..b]›*) ab_neq_ac (*‹(THE ab::'a set. path ab (a::'a) (b::'a)) ≠ (ac::'a set)›*) ab_neq_bc (*‹(THE ab. path ab a b) ≠ bc›*) ac_neq_bc (*‹(ac::'a set) ≠ (bc::'a set)›*) path_ab (*‹path (THE ab. path ab a b) a b›*) path_bc (*‹path (bc::'a set) (b::'a) (c::'a)›*) path_ac (*‹path ac a c›*) path_de (*‹path de d e›*) bcd (*‹[b;c;d]›*) cea (*‹[c;e;a]›*) d_in_bc (*‹(d::'a) ∈ (bc::'a set)›*) e_in_ac (*‹(e::'a) ∈ (ac::'a set)›*) IntI (*‹⟦(?c::?'a::type) ∈ (?A::?'a::type set); ?c ∈ (?B::?'a::type set)⟧ ⟹ ?c ∈ ?A ∩ ?B›*) Int_commute (*‹?A ∩ ?B = ?B ∩ ?A›*) by (metis (no_types, lifting))
qed
thus "?thesis"
(*goal: ‹∃f∈de ∩ (THE ab. path ab a b). [a;f;b]›*)
using fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*) by blast
qed
section "Additional results for Paths and Unreachables"
context MinkowskiPrimitive begin
text ‹The degenerate case.›
lemma big_bang:
assumes no_paths: "𝒫 = {}"
shows "∃a. ℰ = {a}"
proof (-)
(*goal: ‹∃a::'a::type. (ℰ::'a::type set) = {a}›*)
have "∃a. a ∈ ℰ"
using nonempty_events (*‹ℰ ≠ {}›*) by blast
then obtain a where a_event: "a ∈ ℰ"
(*goal: ‹(⋀a. a ∈ ℰ ⟹ thesis) ⟹ thesis›*)
by auto
have "¬ (∃b∈ℰ. b ≠ a)"
proof (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹∃b∈ℰ. b ≠ a ⟹ False›*)
assume "∃b∈ℰ. b ≠ a" (*‹∃b::'a∈ℰ::'a set. b ≠ (a::'a)›*)
then have "∃Q. Q ∈ 𝒫"
using events_paths (*‹⟦?a ∈ ℰ; ?b ∈ ℰ; ?a ≠ ?b⟧ ⟹ ∃R∈𝒫. ∃S∈𝒫. ?a ∈ R ∧ ?b ∈ S ∧ R ∩ S ≠ {}›*) a_event (*‹a ∈ ℰ›*) by auto
thus False
using no_paths (*‹𝒫 = {}›*) by simp
qed
then have "∀b∈ℰ. b = a"
by simp
thus "?thesis"
(*goal: ‹∃a. ℰ = {a}›*)
using a_event (*‹a ∈ ℰ›*) by auto
qed
lemma two_events_then_path:
assumes two_events: "∃a∈ℰ. ∃b∈ℰ. a ≠ b"
shows "∃Q. Q ∈ 𝒫"
proof (-)
(*goal: ‹∃Q. Q ∈ 𝒫›*)
have "(∀a. ℰ ≠ {a}) ⟶ 𝒫 ≠ {}"
using big_bang (*‹𝒫 = {} ⟹ ∃a. ℰ = {a}›*) by blast
then have "𝒫 ≠ {}"
using two_events (*‹∃a::'a∈ℰ::'a set. ∃b::'a∈ℰ. a ≠ b›*) by blast
thus "?thesis"
(*goal: ‹∃Q::'a set. Q ∈ (𝒫::'a set set)›*)
by blast
qed
lemma paths_are_events: "∀Q∈𝒫. ∀a∈Q. a ∈ ℰ"
by simp
lemma same_empty_unreach:
"⟦Q ∈ 𝒫; a ∈ Q⟧ ⟹ unreach-on Q from a = {}"
apply (unfold unreachable_subset_def (*‹unreach-on ?Q from ?b ≡ {x ∈ ?Q. ?Q ∈ 𝒫 ∧ ?b ∈ ℰ ∧ ?b ∉ ?Q ∧ (∄Q. path Q ?b x)}›*))
(*goal: ‹⟦Q ∈ 𝒫; a ∈ Q⟧ ⟹ unreach-on Q from a = {}›*)
by simp
lemma same_path_reachable:
"⟦Q ∈ 𝒫; a ∈ Q; b ∈ Q⟧ ⟹ a ∈ Q - unreach-on Q from b"
by (simp add: same_empty_unreach (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ unreach-on ?Q from ?a = {}›*))
text ‹
If we have two paths crossing and $a$ is on the crossing point, and $b$ is on one of the paths,
then $a$ is in the reachable part of the path $b$ is on.
›
lemma same_path_reachable2:
"⟦Q ∈ 𝒫; R ∈ 𝒫; a ∈ Q; a ∈ R; b ∈ Q⟧ ⟹ a ∈ R - unreach-on R from b"
unfolding unreachable_subset_def
(*goal: ‹⟦(Q::'a set) ∈ (𝒫::'a set set); (R::'a set) ∈ 𝒫; (a::'a) ∈ Q; a ∈ R; (b::'a) ∈ Q⟧ ⟹ a ∈ R - {x::'a ∈ R. R ∈ 𝒫 ∧ b ∈ (ℰ::'a set) ∧ b ∉ R ∧ (∄Q::'a set. path Q b x)}›*)
by blast
(* This will never be used without R ∈ 𝒫 but we might as well leave it off as the proof doesn't
need it. *)
lemma cross_in_reachable:
assumes path_Q: "Q ∈ 𝒫"
and a_inQ: "a ∈ Q"
and b_inQ: "b ∈ Q"
and b_inR: "b ∈ R"
shows "b ∈ R - unreach-on R from a"
unfolding unreachable_subset_def
(*goal: ‹b ∈ R - {x ∈ R. R ∈ 𝒫 ∧ a ∈ ℰ ∧ a ∉ R ∧ (∄Q. path Q a x)}›*)
using a_inQ (*‹a ∈ Q›*) b_inQ (*‹b ∈ Q›*) b_inR (*‹b ∈ R›*) path_Q (*‹Q ∈ 𝒫›*) by auto
lemma reachable_path:
assumes path_Q: "Q ∈ 𝒫"
and b_event: "b ∈ ℰ"
and a_reachable: "a ∈ Q - unreach-on Q from b"
shows "∃R∈𝒫. a ∈ R ∧ b ∈ R"
proof (-)
(*goal: ‹∃R::'a set∈𝒫::'a set set. (a::'a) ∈ R ∧ (b::'a) ∈ R›*)
have a_inQ: "a ∈ Q"
using a_reachable (*‹a ∈ Q - unreach-on Q from b›*) by simp
have "Q ∉ 𝒫 ∨ b ∉ ℰ ∨ b ∈ Q ∨ (∃R∈𝒫. b ∈ R ∧ a ∈ R)"
using a_reachable (*‹a ∈ Q - unreach-on Q from b›*) unreachable_subset_def (*‹unreach-on (?Q::'a set) from (?b::'a) ≡ {x::'a ∈ ?Q. ?Q ∈ (𝒫::'a set set) ∧ ?b ∈ (ℰ::'a set) ∧ ?b ∉ ?Q ∧ (∄Q::'a set. path Q ?b x)}›*) by auto
then have "b ∈ Q ∨ (∃R∈𝒫. b ∈ R ∧ a ∈ R)"
using path_Q (*‹Q ∈ 𝒫›*) b_event (*‹(b::'a) ∈ (ℰ::'a set)›*) by simp
thus "?thesis"
(*goal: ‹∃R∈𝒫. a ∈ R ∧ b ∈ R›*)
proof (rule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹b ∈ Q ⟹ ∃R∈𝒫. a ∈ R ∧ b ∈ R›
2. ‹∃R∈𝒫. b ∈ R ∧ a ∈ R ⟹ ∃R∈𝒫. a ∈ R ∧ b ∈ R›*)
assume "b ∈ Q" (*‹(b::'a) ∈ (Q::'a set)›*)
thus "?thesis"
(*goal: ‹∃R∈𝒫. a ∈ R ∧ b ∈ R›*)
using a_inQ (*‹a ∈ Q›*) path_Q (*‹Q ∈ 𝒫›*) by auto
next
(*goal: ‹∃R∈𝒫. b ∈ R ∧ a ∈ R ⟹ ∃R∈𝒫. a ∈ R ∧ b ∈ R›*)
assume "∃R∈𝒫. b ∈ R ∧ a ∈ R" (*‹∃R::'a set∈𝒫::'a set set. (b::'a) ∈ R ∧ (a::'a) ∈ R›*)
thus "?thesis"
(*goal: ‹∃R∈𝒫. a ∈ R ∧ b ∈ R›*)
using conj_commute (*‹((?P::bool) ∧ (?Q::bool)) = (?Q ∧ ?P)›*) by simp
qed
qed
end (* context MinkowskiPrimitive *)
context MinkowskiBetweenness begin
lemma ord_path_of:
assumes "[a;b;c]"
shows "a ∈ path_of b c" "b ∈ path_of a c" "c ∈ path_of a b"
and "path_of a b = path_of a c" "path_of a b = path_of b c"
proof (-)
(*goals:
1. ‹a ∈ (THE ab. path ab b c)›
2. ‹b ∈ (THE ab. path ab a c)›
3. ‹c ∈ (THE ab. path ab a b)›
4. ‹(THE ab. path ab a b) = (THE ab. path ab a c)›
5. ‹(THE ab. path ab a b) = (THE ab. path ab b c)›*)
show "a ∈ path_of b c"
using betw_a_in_path[of a b c "path_of b c"] (*‹⟦[a;b;c]; path (THE ab. path ab b c) b c⟧ ⟹ a ∈ (THE ab. path ab b c)›*) path_of_ex (*‹path (THE ab. path ab ?a ?b) ?a ?b = (∃Q. path Q ?a ?b)›*) abc_ex_path_unique (*‹[?a;?b;?c] ⟹ ∃!Q. Q ∈ 𝒫 ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) assms (*‹[a;b;c]›*) by (smt (z3) betw_a_in_path (*‹⟦[?a;?b;?c]; path ?bc ?b ?c⟧ ⟹ ?a ∈ ?bc›*) the1_equality (*‹⟦∃!x. ?P x; ?P ?a⟧ ⟹ (THE x. ?P x) = ?a›*))
show "b ∈ path_of a c"
using betw_b_in_path[of a b c "path_of a c"] (*‹⟦[a::'a::type;b::'a::type;c::'a::type]; path (THE ab::'a::type set. path ab a c) a c⟧ ⟹ b ∈ (THE ab::'a::type set. path ab a c)›*) path_of_ex (*‹path (THE ab. path ab ?a ?b) ?a ?b = (∃Q. path Q ?a ?b)›*) abc_ex_path_unique (*‹[?a::'a;?b::'a;?c::'a] ⟹ ∃!Q::'a set. Q ∈ (𝒫::'a set set) ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) abc_abc_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) assms (*‹[a;b;c]›*) by (smt (z3) betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) the1_equality (*‹⟦∃!x. ?P x; ?P ?a⟧ ⟹ (THE x. ?P x) = ?a›*))
show "c ∈ path_of a b"
using betw_c_in_path[of a b c "path_of a b"] (*‹⟦[a;b;c]; path (THE ab. path ab a b) a b⟧ ⟹ c ∈ (THE ab. path ab a b)›*) path_of_ex (*‹path (THE ab. path ab ?a ?b) ?a ?b = (∃Q. path Q ?a ?b)›*) abc_ex_path_unique (*‹[?a;?b;?c] ⟹ ∃!Q. Q ∈ 𝒫 ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) assms (*‹[a;b;c]›*) by (smt (z3) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) the1_equality (*‹⟦∃!x. ?P x; ?P ?a⟧ ⟹ (THE x. ?P x) = ?a›*))
show "path_of a b = path_of a c"
by (metis (mono_tags) abc_ac_neq (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ?a ≠ ?c›*) assms (*‹[a::'a::type;b::'a::type;c::'a::type]›*) betw_b_in_path (*‹⟦[?a::'a::type;?b::'a::type;?c::'a::type]; path (?ac::'a::type set) ?a ?c⟧ ⟹ ?b ∈ ?ac›*) betw_c_in_path (*‹⟦[?a::'a::type;?b::'a::type;?c::'a::type]; path (?ab::'a::type set) ?a ?b⟧ ⟹ ?c ∈ ?ab›*) ends_notin_segment (*‹(?a::'a::type) ∉ segment ?a (?b::'a::type) ∧ ?b ∉ segment ?a ?b›*) seg_betw (*‹((?x::'a::type) ∈ segment (?a::'a::type) (?b::'a::type)) = [?a;?x;?b]›*))
show "path_of a b = path_of b c"
by (metis (mono_tags) assms (*‹[a;b;c]›*) betw_a_in_path (*‹⟦[?a;?b;?c]; path ?bc ?b ?c⟧ ⟹ ?a ∈ ?bc›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) ends_notin_segment (*‹?a ∉ segment ?a ?b ∧ ?b ∉ segment ?a ?b›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*))
qed
text ‹
Schutz defines chains as subsets of paths. The result below proves that even though we do not
include this fact in our definition, it still holds, at least for finite chains.
›
text ‹
Notice that this whole proof would be unnecessary if including path-belongingness in the
definition, as Schutz does. This would also keep path-belongingness independent of axiom O1 and O4,
thus enabling an independent statement of axiom O6, which perhaps we now lose. In exchange,
our definition is slightly weaker (for ‹card X ≥ 3› and ‹infinite X›).
›
lemma obtain_index_fin_chain:
assumes "[f↝X]" "x∈X" "finite X"
obtains i where "f i = x" "i<card X"
proof (-)
(*goal: ‹(⋀i. ⟦f i = x; i < card X⟧ ⟹ thesis) ⟹ thesis›*)
have "∃i<card X. f i = x"
using assms(1) (*‹[f↝X]›*) unfolding ch_by_ord_def
(*goal: ‹∃i<card X. f i = x›*)
proof (rule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹short_ch_by_ord f X ⟹ ∃i<card X. f i = x›
2. ‹local_long_ch_by_ord f X ⟹ ∃i<card X. f i = x›*)
assume asm: "short_ch_by_ord f X" (*‹short_ch_by_ord (f::nat ⇒ 'a) (X::'a set)›*)
hence "card X = 2"
using short_ch_card(1) (*‹short_ch_by_ord ?f ?Q ⟹ card ?Q = 2›*) by auto
thus "∃i<card X. f i = x"
using asm (*‹short_ch_by_ord f X›*) assms(2) (*‹x ∈ X›*) unfolding chain_defs
(*goal: ‹∃i<card X. f i = x›*)
by force
next
(*goal: ‹local_long_ch_by_ord (f::nat ⇒ 'a::type) (X::'a::type set) ⟹ ∃i<card X. f i = (x::'a::type)›*)
assume asm: "local_long_ch_by_ord f X" (*‹local_long_ch_by_ord (f::nat ⇒ 'a) (X::'a set)›*)
thus "∃i<card X. f i = x"
using asm (*‹local_long_ch_by_ord (f::nat ⇒ 'a) (X::'a set)›*) assms(2,3) (*‹x ∈ X› ‹finite X›*) unfolding chain_defs local_ordering_def
(*goal: ‹∃i<card X. f i = x›*)
by blast
qed
thus "?thesis"
(*goal: ‹thesis›*)
using that (*‹⟦f ?i = x; ?i < card X⟧ ⟹ thesis›*) by blast
qed
lemma obtain_index_inf_chain:
assumes "[f↝X]" "x∈X" "infinite X"
obtains i where "f i = x"
using assms (*‹[f↝X]› ‹(x::'a) ∈ (X::'a set)› ‹infinite (X::'a set)›*) unfolding chain_defs local_ordering_def
(*goal: ‹(⋀i. f i = x ⟹ thesis) ⟹ thesis›*)
by blast
lemma fin_chain_on_path2:
assumes "[f↝X]" "finite X"
shows "∃P∈𝒫. X⊆P"
using assms(1) (*‹[f↝X]›*) unfolding ch_by_ord_def
(*goal: ‹∃P::'a::type set∈𝒫::'a::type set set. (X::'a::type set) ⊆ P›*)
proof (rule disjE (*‹⟦(?P::bool) ∨ (?Q::bool); ?P ⟹ ?R::bool; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹short_ch_by_ord f X ⟹ ∃P∈𝒫. X ⊆ P›
2. ‹local_long_ch_by_ord f X ⟹ ∃P∈𝒫. X ⊆ P›*)
assume "short_ch_by_ord f X" (*‹short_ch_by_ord (f::nat ⇒ 'a) (X::'a set)›*)
thus "?thesis"
(*goal: ‹∃P∈𝒫. X ⊆ P›*)
using short_ch_by_ord_def (*‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))›*) by auto
next
(*goal: ‹local_long_ch_by_ord f X ⟹ ∃P∈𝒫. X ⊆ P›*)
assume asm: "local_long_ch_by_ord f X" (*‹local_long_ch_by_ord (f::nat ⇒ 'a) (X::'a set)›*)
have "[f 0;f 1;f 2]"
using order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) asm (*‹local_long_ch_by_ord f X›*) assms(2) (*‹finite X›*) local_long_ch_by_ord_def (*‹local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X›*) by auto
then obtain P where "P∈𝒫" "{f 0,f 1,f 2} ⊆ P"
(*goal: ‹(⋀P. ⟦P ∈ 𝒫; {f 0, f 1, f 2} ⊆ P⟧ ⟹ thesis) ⟹ thesis›*)
by (meson abc_ex_path (*‹[?a::'a;?b::'a;?c::'a] ⟹ ∃Q::'a set∈𝒫::'a set set. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) empty_subsetI (*‹{} ⊆ (?A::?'a set)›*) insert_subset (*‹(insert (?x::?'a) (?A::?'a set) ⊆ (?B::?'a set)) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*))
then have "path P (f 0) (f 1)"
using ‹[f 0;f 1;f 2]› (*‹[f 0;f 1;f 2]›*) by (simp add: abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*))
{
fix x
assume "x∈X" (*‹(x::'a) ∈ (X::'a set)›*)
then obtain i where i: "f i = x" "i<card X"
(*goal: ‹(⋀i. ⟦f i = x; i < card X⟧ ⟹ thesis) ⟹ thesis›*)
using obtain_index_fin_chain (*‹⟦[?f↝?X]; ?x ∈ ?X; finite ?X; ⋀i. ⟦?f i = ?x; i < card ?X⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) assms (*‹[f↝X]› ‹finite X›*) by blast
consider "i=0∨i=1" | "i>1"
(*goal: ‹⟦i = 0 ∨ i = 1 ⟹ thesis; 1 < i ⟹ thesis⟧ ⟹ thesis›*)
by linarith
hence "x∈P"
proof (cases)
(*goals:
1. ‹(i::nat) = (0::nat) ∨ i = (1::nat) ⟹ (x::'a) ∈ (P::'a set)›
2. ‹(1::nat) < (i::nat) ⟹ (x::'a) ∈ (P::'a set)›*)
case 1 (*‹i = 0 ∨ i = 1›*)
thus "?thesis"
(*goal: ‹x ∈ P›*)
using i(1) (*‹f i = x›*) ‹{f 0, f 1, f 2} ⊆ P› (*‹{f 0, f 1, f 2} ⊆ P›*) by auto
next
(*goal: ‹1 < i ⟹ x ∈ P›*)
case 2 (*‹1 < i›*)
hence "[f 0;f 1;f i]"
using assms (*‹[f::nat ⇒ 'a↝X::'a set]› ‹finite X›*) i(2) (*‹i < card X›*) order_finite_chain2 (*‹⟦[?f↝?X]; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) by auto
hence "{f 0,f 1,f i}⊆P"
using ‹path P (f 0) (f 1)› (*‹path P (f 0) (f 1)›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) by blast
thus "?thesis"
(*goal: ‹x ∈ P›*)
by (simp add: i( (*‹(f::nat ⇒ 'a) (i::nat) = (x::'a)›*) 1))
qed
}
thus "?thesis"
(*goal: ‹∃P∈𝒫. X ⊆ P›*)
using ‹P∈𝒫› (*‹P ∈ 𝒫›*) by auto
qed
lemma fin_chain_on_path:
assumes "[f↝X]" "finite X"
shows "∃!P∈𝒫. X⊆P"
proof (-)
(*goal: ‹∃!P. P ∈ 𝒫 ∧ X ⊆ P›*)
obtain P where P: "P∈𝒫" "X⊆P"
(*goal: ‹(⋀P. ⟦P ∈ 𝒫; X ⊆ P⟧ ⟹ thesis) ⟹ thesis›*)
using fin_chain_on_path2[OF assms] (*‹∃P∈𝒫. X ⊆ P›*) by auto
obtain a and b where ab: "a∈X" "b∈X" "a≠b"
(*goal: ‹(⋀a b. ⟦a ∈ X; b ∈ X; a ≠ b⟧ ⟹ thesis) ⟹ thesis›*)
using assms(1) (*‹[f::nat ⇒ 'a↝X::'a set]›*) unfolding chain_defs
(*goal: ‹(⋀(a::'a) b::'a. ⟦a ∈ (X::'a set); b ∈ X; a ≠ b⟧ ⟹ thesis::bool) ⟹ thesis›*)
by (metis assms( (*‹finite (X::'a set)›*) 2) insertCI (*‹((?a::?'a) ∉ (?B::?'a set) ⟹ ?a = (?b::?'a)) ⟹ ?a ∈ insert ?b ?B›*) three_in_set3 (*‹⟦(3::nat) ≤ card (?X::?'a set); ⋀(x::?'a) (y::?'a) z::?'a. ⟦x ∈ ?X; y ∈ ?X; z ∈ ?X; x ≠ y; x ≠ z; y ≠ z⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*))
thus "?thesis"
(*goal: ‹∃!P::'a set. P ∈ (𝒫::'a set set) ∧ (X::'a set) ⊆ P›*)
using P (*‹P ∈ 𝒫› ‹X ⊆ P›*) ab (*‹(a::'a) ∈ (X::'a set)› ‹b ∈ X› ‹a ≠ b›*) by (meson eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*))
qed
lemma fin_chain_on_path3:
assumes "[f↝X]" "finite X" "a∈X" "b∈X" "a≠b"
shows "X ⊆ path_of a b"
proof (-)
(*goal: ‹X ⊆ (THE ab. path ab a b)›*)
let ?ab = "path_of a b"
obtain P where P: "P∈𝒫" "X⊆P"
(*goal: ‹(⋀P::'a::type set. ⟦P ∈ (𝒫::'a::type set set); (X::'a::type set) ⊆ P⟧ ⟹ thesis::bool) ⟹ thesis›*)
using fin_chain_on_path2[OF assms ( 1 , 2 )] (*‹∃P::'a set∈𝒫::'a set set. (X::'a set) ⊆ P›*) by auto
have "path P a b"
using P (*‹(P::'a set) ∈ (𝒫::'a set set)› ‹(X::'a::type set) ⊆ (P::'a::type set)›*) assms(3-5) (*‹(a::'a) ∈ (X::'a set)› ‹b ∈ X› ‹a ≠ b›*) by auto
then have "path ?ab a b"
using path_of_ex (*‹path (THE ab. path ab ?a ?b) ?a ?b = (∃Q. path Q ?a ?b)›*) by blast
hence "?ab = P"
using eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) ‹path P a b› (*‹path (P::'a set) (a::'a) (b::'a)›*) by auto
thus "X ⊆ path_of a b"
using P (*‹P ∈ 𝒫› ‹X ⊆ P›*) by simp
qed
end (* context MinkowskiBetweenness *)
context MinkowskiUnreachable begin
text ‹
First some basic facts about the primitive notions, which seem to belong here.
I don't think any/all of these are explicitly proved in Schutz.
›
lemma no_empty_paths [simp]:
assumes "Q∈𝒫"
shows "Q≠{}"
(*using assms nonempty_events two_in_unreach unreachable_subset_def by blast*)
proof (-)
(*goal: ‹Q ≠ {}›*)
obtain a where "a∈ℰ"
(*goal: ‹(⋀a. a ∈ ℰ ⟹ thesis) ⟹ thesis›*)
using nonempty_events (*‹(ℰ::'a set) ≠ {}›*) by blast
have "a∈Q ∨ a∉Q"
by auto
thus "?thesis"
(*goal: ‹Q ≠ {}›*)
proof (standard)
(*goals:
1. ‹a ∈ Q ⟹ Q ≠ {}›
2. ‹a ∉ Q ⟹ Q ≠ {}›*)
assume "a∈Q" (*‹(a::'a) ∈ (Q::'a set)›*)
thus "?thesis"
(*goal: ‹Q ≠ {}›*)
by blast
next
(*goal: ‹a ∉ Q ⟹ Q ≠ {}›*)
assume "a∉Q" (*‹(a::'a) ∉ (Q::'a set)›*)
then obtain b where "b∈unreach-on Q from a"
(*goal: ‹(⋀b::'a. b ∈ unreach-on (Q::'a set) from (a::'a) ⟹ thesis::bool) ⟹ thesis›*)
using two_in_unreach (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?b::'a) ∈ (ℰ::'a set); ?b ∉ ?Q⟧ ⟹ ∃x::'a∈unreach-on ?Q from ?b. ∃y::'a∈unreach-on ?Q from ?b. x ≠ y›*) ‹a ∈ ℰ› (*‹a ∈ ℰ›*) assms (*‹Q ∈ 𝒫›*) by blast
thus "?thesis"
(*goal: ‹Q ≠ {}›*)
using unreachable_subset_def (*‹unreach-on ?Q from ?b ≡ {x ∈ ?Q. ?Q ∈ 𝒫 ∧ ?b ∈ ℰ ∧ ?b ∉ ?Q ∧ (∄Q. path Q ?b x)}›*) by auto
qed
qed
lemma events_ex_path:
assumes ge1_path: "𝒫 ≠ {}"
shows "∀x∈ℰ. ∃Q∈𝒫. x ∈ Q"
(*using ex_in_conv no_empty_paths in_path_event assms events_paths
by metis*)
proof (standard)
(*goal: ‹⋀x. x ∈ ℰ ⟹ ∃Q∈𝒫. x ∈ Q›*)
fix x
assume x_event: "x ∈ ℰ" (*‹(x::'a) ∈ (ℰ::'a set)›*)
have "∃Q. Q ∈ 𝒫"
using ge1_path (*‹𝒫 ≠ {}›*) using ex_in_conv (*‹(∃x::?'a::type. x ∈ (?A::?'a::type set)) = (?A ≠ {})›*) by blast
then obtain Q where path_Q: "Q ∈ 𝒫"
(*goal: ‹(⋀Q. Q ∈ 𝒫 ⟹ thesis) ⟹ thesis›*)
by auto
then have "∃y. y ∈ Q"
using no_empty_paths (*‹?Q ∈ 𝒫 ⟹ ?Q ≠ {}›*) by blast
then obtain y where y_inQ: "y ∈ Q"
(*goal: ‹(⋀y. y ∈ Q ⟹ thesis) ⟹ thesis›*)
by auto
then have y_event: "y ∈ ℰ"
using in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_Q (*‹Q ∈ 𝒫›*) by simp
have "∃P∈𝒫. x ∈ P"
proof (cases)
(*goals:
1. ‹?P ⟹ ∃P∈𝒫. x ∈ P›
2. ‹¬ ?P ⟹ ∃P∈𝒫. x ∈ P›*)
assume "x = y" (*‹(x::'a) = (y::'a)›*)
thus "?thesis"
(*goal: ‹∃P∈𝒫. x ∈ P›*)
using y_inQ (*‹y ∈ Q›*) path_Q (*‹Q ∈ 𝒫›*) by auto
next
(*goal: ‹x ≠ y ⟹ ∃P∈𝒫. x ∈ P›*)
assume "x ≠ y" (*‹(x::'a) ≠ (y::'a)›*)
thus "?thesis"
(*goal: ‹∃P∈𝒫. x ∈ P›*)
using events_paths (*‹⟦?a ∈ ℰ; ?b ∈ ℰ; ?a ≠ ?b⟧ ⟹ ∃R∈𝒫. ∃S∈𝒫. ?a ∈ R ∧ ?b ∈ S ∧ R ∩ S ≠ {}›*) x_event (*‹x ∈ ℰ›*) y_event (*‹y ∈ ℰ›*) by auto
qed
thus "∃Q∈𝒫. x ∈ Q"
by simp
qed
lemma unreach_ge2_then_ge2:
assumes "∃x∈unreach-on Q from b. ∃y∈unreach-on Q from b. x ≠ y"
shows "∃x∈Q. ∃y∈Q. x ≠ y"
using assms (*‹∃x∈unreach-on Q from b. ∃y∈unreach-on Q from b. x ≠ y›*) unreachable_subset_def (*‹unreach-on ?Q from ?b ≡ {x ∈ ?Q. ?Q ∈ 𝒫 ∧ ?b ∈ ℰ ∧ ?b ∉ ?Q ∧ (∄Q. path Q ?b x)}›*) by auto
text ‹
This lemma just proves that the chain obtained to bound the unreachable set of a path
is indeed on that path. Extends I6; requires Theorem 2; used in Theorem 13.
Seems to be assumed in Schutz' chain notation in I6.
›
lemma chain_on_path_I6:
assumes path_Q: "Q∈𝒫"
and event_b: "b∉Q" "b∈ℰ"
and unreach: "Q⇩x ∈ unreach-on Q from b" "Q⇩z ∈ unreach-on Q from b" "Q⇩x ≠ Q⇩z"
and X_def: "[f↝X|Q⇩x..Q⇩z]"
"(∀i∈{1 .. card X - 1}. (f i) ∈ unreach-on Q from b ∧ (∀Q⇩y∈ℰ. [(f(i-1)); Q⇩y; f i] ⟶ Q⇩y ∈ unreach-on Q from b))"
shows "X⊆Q"
proof (-)
(*goal: ‹X ⊆ Q›*)
have 1: "path Q Q⇩x Q⇩z"
using unreachable_subset_def (*‹unreach-on ?Q from ?b ≡ {x ∈ ?Q. ?Q ∈ 𝒫 ∧ ?b ∈ ℰ ∧ ?b ∉ ?Q ∧ (∄Q. path Q ?b x)}›*) unreach (*‹(Q⇩x::'a) ∈ unreach-on (Q::'a set) from (b::'a)› ‹Q⇩z ∈ unreach-on Q from b› ‹(Q⇩x::'a) ≠ (Q⇩z::'a)›*) path_Q (*‹Q ∈ 𝒫›*) by simp
then have 2: "Q = path_of Q⇩x Q⇩z"
using path_of_ex[of Q⇩x Q⇩z] (*‹path (THE ab. path ab Q⇩x Q⇩z) Q⇩x Q⇩z = (∃Q. path Q Q⇩x Q⇩z)›*) by (meson eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*))
have "X⊆path_of Q⇩x Q⇩z"
proof (rule fin_chain_on_path3[of f] (*‹⟦[f↝?X]; finite ?X; ?a ∈ ?X; ?b ∈ ?X; ?a ≠ ?b⟧ ⟹ ?X ⊆ (THE ab. path ab ?a ?b)›*))
(*goals:
1. ‹[f↝X]›
2. ‹finite X›
3. ‹Q⇩x ∈ X›
4. ‹Q⇩z ∈ X›
5. ‹Q⇩x ≠ Q⇩z›*)
from unreach(3) (*‹Q⇩x ≠ Q⇩z›*) show "Q⇩x ≠ Q⇩z"
by simp
from X_def (*‹[f↝X|Q⇩x .. Q⇩z]› ‹∀i∈{1..card X - 1}. f i ∈ unreach-on Q from b ∧ (∀Q⇩y∈ℰ. [f (i - 1);Q⇩y;f i] ⟶ Q⇩y ∈ unreach-on Q from b)›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) show "[f↝X]" "finite X"
apply -
(*goals:
1. ‹⟦[f::nat ⇒ 'a::type↝X::'a::type set|Q⇩x::'a::type .. Q⇩z::'a::type]; ∀i::nat∈{1::nat..card X - (1::nat)}. f i ∈ unreach-on (Q::'a::type set) from (b::'a::type) ∧ (∀Q⇩y::'a::type∈ℰ::'a::type set. [f (i - (1::nat));Q⇩y;f i] ⟶ Q⇩y ∈ unreach-on Q from b); ⋀X::'a::type set. short_ch X ≡ card X = (2::nat) ∧ (∃P::'a::type set∈𝒫::'a::type set set. X ⊆ P); ⋀(f::nat ⇒ 'a::type) X::'a::type set. local_long_ch_by_ord f X ≡ (infinite X ∨ (3::nat) ≤ card X) ∧ local_ordering f betw X; ⋀(f::nat ⇒ 'a::type) X::'a::type set. [f↝X] ≡ short_ch_by_ord f X ∨ local_long_ch_by_ord f X; ⋀(f::nat ⇒ 'a::type) Q::'a::type set. short_ch_by_ord f Q ≡ Q = {f (0::nat), f (1::nat)} ∧ (∃Q::'a::type set. path Q (f (0::nat)) (f (1::nat))); ⋀X::'a::type set. ch X ≡ short_ch X ∨ (∃f::nat ⇒ 'a::type. local_long_ch_by_ord f X); ⋀(f::nat ⇒ 'a::type) Q::'a::type set. infinite_chain f Q ≡ infinite Q ∧ [f↝Q]; ⋀(f::nat ⇒ 'a::type) (Q::'a::type set) x::'a::type. [f↝Q|x ..] ≡ infinite_chain f Q ∧ f (0::nat) = x; ⋀(f::nat ⇒ 'a::type) Q::'a::type set. finite_chain f Q ≡ finite Q ∧ [f↝Q]; ⋀(f::nat ⇒ 'a::type) (Q::'a::type set) (x::'a::type) y::'a::type. [f↝Q|x .. y] ≡ finite_chain f Q ∧ f (0::nat) = x ∧ f (card Q - (1::nat)) = y; ⋀(f::nat ⇒ 'a::type) (Q::'a::type set) (x::'a::type) (y::'a::type) z::'a::type. [f↝Q|x..y..z] ≡ [f↝Q|x .. z] ∧ x ≠ y ∧ y ≠ z ∧ y ∈ Q⟧ ⟹ [f↝X]›
2. ‹⟦[f::nat ⇒ 'a::type↝X::'a::type set|Q⇩x::'a::type .. Q⇩z::'a::type]; ∀i::nat∈{1::nat..card X - (1::nat)}. f i ∈ unreach-on (Q::'a::type set) from (b::'a::type) ∧ (∀Q⇩y::'a::type∈ℰ::'a::type set. [f (i - (1::nat));Q⇩y;f i] ⟶ Q⇩y ∈ unreach-on Q from b); ⋀X::'a::type set. short_ch X ≡ card X = (2::nat) ∧ (∃P::'a::type set∈𝒫::'a::type set set. X ⊆ P); ⋀(f::nat ⇒ 'a::type) X::'a::type set. local_long_ch_by_ord f X ≡ (infinite X ∨ (3::nat) ≤ card X) ∧ local_ordering f betw X; ⋀(f::nat ⇒ 'a::type) X::'a::type set. [f↝X] ≡ short_ch_by_ord f X ∨ local_long_ch_by_ord f X; ⋀(f::nat ⇒ 'a::type) Q::'a::type set. short_ch_by_ord f Q ≡ Q = {f (0::nat), f (1::nat)} ∧ (∃Q::'a::type set. path Q (f (0::nat)) (f (1::nat))); ⋀X::'a::type set. ch X ≡ short_ch X ∨ (∃f::nat ⇒ 'a::type. local_long_ch_by_ord f X); ⋀(f::nat ⇒ 'a::type) Q::'a::type set. infinite_chain f Q ≡ infinite Q ∧ [f↝Q]; ⋀(f::nat ⇒ 'a::type) (Q::'a::type set) x::'a::type. [f↝Q|x ..] ≡ infinite_chain f Q ∧ f (0::nat) = x; ⋀(f::nat ⇒ 'a::type) Q::'a::type set. finite_chain f Q ≡ finite Q ∧ [f↝Q]; ⋀(f::nat ⇒ 'a::type) (Q::'a::type set) (x::'a::type) y::'a::type. [f↝Q|x .. y] ≡ finite_chain f Q ∧ f (0::nat) = x ∧ f (card Q - (1::nat)) = y; ⋀(f::nat ⇒ 'a::type) (Q::'a::type set) (x::'a::type) (y::'a::type) z::'a::type. [f↝Q|x..y..z] ≡ [f↝Q|x .. z] ∧ x ≠ y ∧ y ≠ z ∧ y ∈ Q⟧ ⟹ finite X›
discuss goal 1*)
apply metis
(*discuss goal 2*)
apply metis
(*proven 2 subgoals*) .
from assms(7) (*‹[f↝X|Q⇩x .. Q⇩z]›*) points_in_chain (*‹[?f↝?Q|?x .. ?z] ⟹ ?x ∈ ?Q ∧ ?z ∈ ?Q›*) show "Q⇩x ∈ X" "Q⇩z ∈ X"
apply -
(*goals:
1. ‹⟦[f::nat ⇒ 'a::type↝X::'a::type set|Q⇩x::'a::type .. Q⇩z::'a::type]; ⋀(f::nat ⇒ 'a::type) (Q::'a::type set) (x::'a::type) z::'a::type. [f↝Q|x .. z] ⟹ x ∈ Q ∧ z ∈ Q⟧ ⟹ Q⇩x ∈ X›
2. ‹⟦[f::nat ⇒ 'a::type↝X::'a::type set|Q⇩x::'a::type .. Q⇩z::'a::type]; ⋀(f::nat ⇒ 'a::type) (Q::'a::type set) (x::'a::type) z::'a::type. [f↝Q|x .. z] ⟹ x ∈ Q ∧ z ∈ Q⟧ ⟹ Q⇩z ∈ X›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
qed
thus "?thesis"
(*goal: ‹X ⊆ Q›*)
using "2" (*‹Q = (THE ab. path ab Q⇩x Q⇩z)›*) by simp
qed
end (* context MinkowskiUnreachable *)
section "Results about Paths as Sets"
text ‹
Note several of the following don't need MinkowskiPrimitive, they are just Set lemmas;
nevertheless I'm naming them and writing them this way for clarity.
›
context MinkowskiPrimitive begin
lemma distinct_paths:
assumes "Q ∈ 𝒫"
and "R ∈ 𝒫"
and "d ∉ Q"
and "d ∈ R"
shows "R ≠ Q"
using assms (*‹Q ∈ 𝒫› ‹(R::'a set) ∈ (𝒫::'a set set)› ‹(d::'a::type) ∉ (Q::'a::type set)› ‹(d::'a) ∈ (R::'a set)›*) by auto
lemma distinct_paths2:
assumes "Q ∈ 𝒫"
and "R ∈ 𝒫"
and "∃d. d ∉ Q ∧ d ∈ R"
shows "R ≠ Q"
using assms (*‹(Q::'a set) ∈ (𝒫::'a set set)› ‹R ∈ 𝒫› ‹∃d. d ∉ Q ∧ d ∈ R›*) by auto
lemma external_events_neq:
"⟦Q ∈ 𝒫; a ∈ Q; b ∈ ℰ; b ∉ Q⟧ ⟹ a ≠ b"
by auto
lemma notin_cross_events_neq:
"⟦Q ∈ 𝒫; R ∈ 𝒫; Q ≠ R; a ∈ Q; b ∈ R; a ∉ R∩Q⟧ ⟹ a ≠ b"
by blast
lemma nocross_events_neq:
"⟦Q ∈ 𝒫; R ∈ 𝒫; a ∈ Q; b ∈ R; R∩Q = {}⟧ ⟹ a ≠ b"
by auto
text ‹
Given a nonempty path $Q$, and an external point $d$, we can find another path
$R$ passing through $d$ (by I2 aka ‹events_paths›). This path is distinct
from $Q$, as it passes through a point external to it.
›
lemma external_path:
assumes path_Q: "Q ∈ 𝒫"
and a_inQ: "a ∈ Q"
and d_notinQ: "d ∉ Q"
and d_event: "d ∈ ℰ"
shows "∃R∈𝒫. d ∈ R"
proof (-)
(*goal: ‹∃R∈𝒫. d ∈ R›*)
have a_neq_d: "a ≠ d"
using a_inQ (*‹a ∈ Q›*) d_notinQ (*‹d ∉ Q›*) by auto
thus "∃R∈𝒫. d ∈ R"
using events_paths (*‹⟦?a ∈ ℰ; ?b ∈ ℰ; ?a ≠ ?b⟧ ⟹ ∃R∈𝒫. ∃S∈𝒫. ?a ∈ R ∧ ?b ∈ S ∧ R ∩ S ≠ {}›*) by (meson a_inQ (*‹(a::'a) ∈ (Q::'a set)›*) d_event (*‹(d::'a) ∈ (ℰ::'a set)›*) in_path_event (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q⟧ ⟹ ?a ∈ (ℰ::'a set)›*) path_Q (*‹(Q::'a set) ∈ (𝒫::'a set set)›*))
qed
lemma distinct_path:
assumes "Q ∈ 𝒫"
and "a ∈ Q"
and "d ∉ Q"
and "d ∈ ℰ"
shows "∃R∈𝒫. R ≠ Q"
using assms (*‹(Q::'a set) ∈ (𝒫::'a set set)› ‹a ∈ Q› ‹(d::'a) ∉ (Q::'a set)› ‹d ∈ ℰ›*) external_path (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q; (?d::'a) ∉ ?Q; ?d ∈ (ℰ::'a set)⟧ ⟹ ∃R::'a set∈𝒫. ?d ∈ R›*) by metis
lemma external_distinct_path:
assumes "Q ∈ 𝒫"
and "a ∈ Q"
and "d ∉ Q"
and "d ∈ ℰ"
shows "∃R∈𝒫. R ≠ Q ∧ d ∈ R"
using assms (*‹(Q::'a set) ∈ (𝒫::'a set set)› ‹a ∈ Q› ‹d ∉ Q› ‹d ∈ ℰ›*) external_path (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?d ∉ ?Q; ?d ∈ ℰ⟧ ⟹ ∃R∈𝒫. ?d ∈ R›*) by fastforce
end (* context MinkowskiPrimitive *)
section "3.3 Boundedness of the unreachable set"
subsection ‹Theorem 4 (boundedness of the unreachable set)›
text ‹
The same assumptions as I7, different conclusion.
This doesn't just give us boundedness, it gives us another event outside of the unreachable
set, as long as we have one already.
I7 conclusion: ‹∃g X Qn. [g↝X|Qx..Qy..Qn] ∧ Qn ∈ Q - unreach-on Q from b›
›
theorem (*4*) (in MinkowskiUnreachable) unreachable_set_bounded:
assumes path_Q: "Q ∈ 𝒫"
and b_nin_Q: "b ∉ Q"
and b_event: "b ∈ ℰ"
and Qx_reachable: "Qx ∈ Q - unreach-on Q from b"
and Qy_unreachable: "Qy ∈ unreach-on Q from b"
shows "∃Qz∈Q - unreach-on Q from b. [Qx;Qy;Qz] ∧ Qx ≠ Qz"
using assms (*‹Q ∈ 𝒫› ‹b ∉ Q› ‹b ∈ ℰ› ‹(Qx::'a::type) ∈ (Q::'a::type set) - unreach-on Q from (b::'a::type)› ‹Qy ∈ unreach-on Q from b›*) I7_old (*‹⟦?Q ∈ 𝒫; ?b ∉ ?Q; ?b ∈ ℰ; ?Qx ∈ ?Q - unreach-on ?Q from ?b; ?Qy ∈ unreach-on ?Q from ?b⟧ ⟹ ∃g X Qn. [g↝X|?Qx..?Qy..Qn] ∧ Qn ∈ ?Q - unreach-on ?Q from ?b›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*) by (metis first_neq_last (*‹[?f↝?Q|?x .. ?z] ⟹ ?x ≠ ?z›*))
subsection ‹Theorem 5 (first existence theorem)›
text ‹
The lemma below is used in the contradiction in ‹external_event›,
which is the essential part to Theorem 5(i).
›
lemma (in MinkowskiUnreachable) only_one_path:
assumes path_Q: "Q ∈ 𝒫"
and all_inQ: "∀a∈ℰ. a ∈ Q"
and path_R: "R ∈ 𝒫"
shows "R = Q"
proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*))
(*goal: ‹R ≠ Q ⟹ False›*)
assume "¬ R = Q" (*‹(R::'a set) ≠ (Q::'a set)›*)
then have R_neq_Q: "R ≠ Q"
by simp
have "ℰ = Q"
by (simp add: all_inQ (*‹∀a∈ℰ. a ∈ Q›*) antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*) path_Q (*‹Q ∈ 𝒫›*) path_sub_events (*‹?Q ∈ 𝒫 ⟹ ?Q ⊆ ℰ›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*))
hence "R⊂Q"
using R_neq_Q (*‹R ≠ Q›*) path_R (*‹(R::'a set) ∈ (𝒫::'a set set)›*) path_sub_events (*‹?Q ∈ 𝒫 ⟹ ?Q ⊆ ℰ›*) by auto
obtain c where "c∉R" "c∈Q"
(*goal: ‹(⋀c. ⟦c ∉ R; c ∈ Q⟧ ⟹ thesis) ⟹ thesis›*)
using ‹R ⊂ Q› (*‹R ⊂ Q›*) by blast
then obtain a and b where "path R a b"
(*goal: ‹(⋀a b. path R a b ⟹ thesis) ⟹ thesis›*)
using ‹ℰ = Q› (*‹ℰ = Q›*) path_R (*‹(R::'a set) ∈ (𝒫::'a set set)›*) two_in_unreach (*‹⟦?Q ∈ 𝒫; ?b ∈ ℰ; ?b ∉ ?Q⟧ ⟹ ∃x∈unreach-on ?Q from ?b. ∃y∈unreach-on ?Q from ?b. x ≠ y›*) unreach_ge2_then_ge2 (*‹∃x∈unreach-on ?Q from ?b. ∃y∈unreach-on ?Q from ?b. x ≠ y ⟹ ∃x∈?Q. ∃y∈?Q. x ≠ y›*) by blast
have "a∈Q" "b∈Q"
using ‹ℰ = Q› (*‹(ℰ::'a set) = (Q::'a set)›*) ‹path R a b› (*‹path R a b›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) apply -
(*goals:
1. ‹⟦ℰ = Q; path R a b; ⋀Q a. ⟦Q ∈ 𝒫; a ∈ Q⟧ ⟹ a ∈ ℰ⟧ ⟹ a ∈ Q›
2. ‹⟦ℰ = Q; path R a b; ⋀Q a. ⟦Q ∈ 𝒫; a ∈ Q⟧ ⟹ a ∈ ℰ⟧ ⟹ b ∈ Q›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
thus False
using eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) using R_neq_Q (*‹(R::'a set) ≠ (Q::'a set)›*) ‹path R a b› (*‹path R a b›*) path_Q (*‹(Q::'a::type set) ∈ (𝒫::'a::type set set)›*) by blast
qed
context MinkowskiSpacetime begin
text ‹Unfortunately, we cannot assume that a path exists without the axiom of dimension.›
lemma external_event:
assumes path_Q: "Q ∈ 𝒫"
shows "∃d∈ℰ. d ∉ Q"
proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*))
(*goal: ‹¬ (∃d∈ℰ. d ∉ Q) ⟹ False›*)
assume "¬ (∃d∈ℰ. d ∉ Q)" (*‹¬ (∃d::'a∈ℰ::'a set. d ∉ (Q::'a set))›*)
then have all_inQ: "∀d∈ℰ. d ∈ Q"
by simp
then have only_one_path: "∀P∈𝒫. P = Q"
by (simp add: only_one_path (*‹⟦?Q ∈ 𝒫; ∀a∈ℰ. a ∈ ?Q; ?R ∈ 𝒫⟧ ⟹ ?R = ?Q›*) path_Q (*‹Q ∈ 𝒫›*))
thus False
using ex_3SPRAY (*‹ℰ ≠ {} ⟹ Bex ℰ three_SPRAY›*) three_SPRAY_ge4 (*‹three_SPRAY ?x ⟹ ∃Q1∈𝒫. ∃Q2∈𝒫. ∃Q3∈𝒫. ∃Q4∈𝒫. Q1 ≠ Q2 ∧ Q1 ≠ Q3 ∧ Q1 ≠ Q4 ∧ Q2 ≠ Q3 ∧ Q2 ≠ Q4 ∧ Q3 ≠ Q4›*) four_paths (*‹∃Q1::'a set∈𝒫::'a set set. ∃Q2::'a set∈𝒫. ∃Q3::'a set∈𝒫. ∃Q4::'a set∈𝒫. Q1 ≠ Q2 ∧ Q1 ≠ Q3 ∧ Q1 ≠ Q4 ∧ Q2 ≠ Q3 ∧ Q2 ≠ Q4 ∧ Q3 ≠ Q4›*) by auto
qed
text ‹
Now we can prove the first part of the theorem's conjunction.
This follows pretty much exactly the same pattern as the book, except it relies on more
intermediate lemmas.
›
theorem (*5i*) ge2_events:
assumes path_Q: "Q ∈ 𝒫"
and a_inQ: "a ∈ Q"
shows "∃b∈Q. b ≠ a"
proof (-)
(*goal: ‹∃b∈Q. b ≠ a›*)
have d_notinQ: "∃d∈ℰ. d ∉ Q"
using path_Q (*‹Q ∈ 𝒫›*) external_event (*‹?Q ∈ 𝒫 ⟹ ∃d∈ℰ. d ∉ ?Q›*) by blast
then obtain d where "d ∈ ℰ" and "d ∉ Q"
(*goal: ‹(⋀d. ⟦d ∈ ℰ; d ∉ Q⟧ ⟹ thesis) ⟹ thesis›*)
by auto
thus "?thesis"
(*goal: ‹∃b::'a∈Q::'a set. b ≠ (a::'a)›*)
using two_in_unreach[where Q = Q and b = d] (*‹⟦Q ∈ 𝒫; d ∈ ℰ; d ∉ Q⟧ ⟹ ∃x∈unreach-on Q from d. ∃y∈unreach-on Q from d. x ≠ y›*) path_Q (*‹(Q::'a::type set) ∈ (𝒫::'a::type set set)›*) unreach_ge2_then_ge2 (*‹∃x::'a∈unreach-on (?Q::'a set) from (?b::'a). ∃y::'a∈unreach-on ?Q from ?b. x ≠ y ⟹ ∃x::'a∈?Q. ∃y::'a∈?Q. x ≠ y›*) by metis
qed
text ‹
Simple corollary which is easier to use when we don't have one event on a path yet.
Anything which uses this implicitly used ‹no_empty_paths› on top of ‹ge2_events›.
›
lemma ge2_events_lax:
assumes path_Q: "Q ∈ 𝒫"
shows "∃a∈Q. ∃b∈Q. a ≠ b"
proof (-)
(*goal: ‹∃a∈Q. ∃b∈Q. a ≠ b›*)
have "∃a∈ℰ. a ∈ Q"
using path_Q (*‹Q ∈ 𝒫›*) no_empty_paths (*‹?Q ∈ 𝒫 ⟹ ?Q ≠ {}›*) by (meson ex_in_conv (*‹(∃x::?'a. x ∈ (?A::?'a set)) = (?A ≠ {})›*) in_path_event (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q⟧ ⟹ ?a ∈ (ℰ::'a set)›*))
thus "?thesis"
(*goal: ‹∃a::'a::type∈Q::'a::type set. ∃b::'a::type∈Q. a ≠ b›*)
using path_Q (*‹Q ∈ 𝒫›*) ge2_events (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ∃b∈?Q. b ≠ ?a›*) by blast
qed
lemma ex_crossing_path:
assumes path_Q: "Q ∈ 𝒫"
shows "∃R∈𝒫. R ≠ Q ∧ (∃c. c ∈ R ∧ c ∈ Q)"
proof (-)
(*goal: ‹∃R∈𝒫. R ≠ Q ∧ (∃c. c ∈ R ∧ c ∈ Q)›*)
obtain a where a_inQ: "a ∈ Q"
(*goal: ‹(⋀a. a ∈ Q ⟹ thesis) ⟹ thesis›*)
using ge2_events_lax (*‹?Q ∈ 𝒫 ⟹ ∃a∈?Q. ∃b∈?Q. a ≠ b›*) path_Q (*‹Q ∈ 𝒫›*) by blast
obtain d where d_event: "d ∈ ℰ" and d_notinQ: "d ∉ Q"
(*goal: ‹(⋀d. ⟦d ∈ ℰ; d ∉ Q⟧ ⟹ thesis) ⟹ thesis›*)
using external_event (*‹?Q ∈ 𝒫 ⟹ ∃d∈ℰ. d ∉ ?Q›*) path_Q (*‹Q ∈ 𝒫›*) by auto
then have "a ≠ d"
using a_inQ (*‹(a::'a::type) ∈ (Q::'a::type set)›*) by auto
then have ex_through_d: "∃R∈𝒫. ∃S∈𝒫. a ∈ R ∧ d ∈ S ∧ R ∩ S ≠ {}"
using events_paths[where a = a and b = d] (*‹⟦(a::'a) ∈ (ℰ::'a set); (d::'a) ∈ ℰ; a ≠ d⟧ ⟹ ∃R::'a set∈𝒫::'a set set. ∃S::'a set∈𝒫. a ∈ R ∧ d ∈ S ∧ R ∩ S ≠ {}›*) path_Q (*‹Q ∈ 𝒫›*) a_inQ (*‹(a::'a) ∈ (Q::'a set)›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) d_event (*‹(d::'a) ∈ (ℰ::'a set)›*) by simp
then obtain R and S where path_R: "R ∈ 𝒫" and path_S: "S ∈ 𝒫" and a_inR: "a ∈ R" and d_inS: "d ∈ S" and R_crosses_S: "R ∩ S ≠ {}"
(*goal: ‹(⋀R S. ⟦R ∈ 𝒫; S ∈ 𝒫; a ∈ R; d ∈ S; R ∩ S ≠ {}⟧ ⟹ thesis) ⟹ thesis›*)
by auto
have S_neq_Q: "S ≠ Q"
using d_notinQ (*‹(d::'a::type) ∉ (Q::'a::type set)›*) d_inS (*‹d ∈ S›*) by auto
show "?thesis"
(*goal: ‹∃R::'a::type set∈𝒫::'a::type set set. R ≠ (Q::'a::type set) ∧ (∃c::'a::type. c ∈ R ∧ c ∈ Q)›*)
proof (cases)
(*goals:
1. ‹?P ⟹ ∃R∈𝒫. R ≠ Q ∧ (∃c. c ∈ R ∧ c ∈ Q)›
2. ‹¬ ?P ⟹ ∃R∈𝒫. R ≠ Q ∧ (∃c. c ∈ R ∧ c ∈ Q)›*)
assume "R = Q" (*‹(R::'a set) = (Q::'a set)›*)
then have "Q ∩ S ≠ {}"
using R_crosses_S (*‹R ∩ S ≠ {}›*) by simp
thus "?thesis"
(*goal: ‹∃R∈𝒫. R ≠ Q ∧ (∃c. c ∈ R ∧ c ∈ Q)›*)
using S_neq_Q (*‹S ≠ Q›*) path_S (*‹S ∈ 𝒫›*) by blast
next
(*goal: ‹R ≠ Q ⟹ ∃R∈𝒫. R ≠ Q ∧ (∃c. c ∈ R ∧ c ∈ Q)›*)
assume "R ≠ Q" (*‹(R::'a set) ≠ (Q::'a set)›*)
thus "?thesis"
(*goal: ‹∃R::'a set∈𝒫::'a set set. R ≠ (Q::'a set) ∧ (∃c::'a. c ∈ R ∧ c ∈ Q)›*)
using a_inQ (*‹a ∈ Q›*) a_inR (*‹a ∈ R›*) path_R (*‹R ∈ 𝒫›*) by blast
qed
qed
text ‹
If we have two paths $Q$ and $R$ with $a$ on $Q$ and $b$ at the intersection of $Q$ and $R$, then by
‹two_in_unreach› (I5) and Theorem 4 (boundedness of the unreachable set), there is an unreachable
set from $a$ on one side of $b$ on $R$, and on the other side of that there is an event which is
reachable from $a$ by some path, which is the path we want.
›
lemma path_past_unreach:
assumes path_Q: "Q ∈ 𝒫"
and path_R: "R ∈ 𝒫"
and a_inQ: "a ∈ Q"
and b_inQ: "b ∈ Q"
and b_inR: "b ∈ R"
and Q_neq_R: "Q ≠ R"
and a_neq_b: "a ≠ b"
shows "∃S∈𝒫. S ≠ Q ∧ a ∈ S ∧ (∃c. c ∈ S ∧ c ∈ R)"
proof (-)
(*goal: ‹∃S::'a::type set∈𝒫::'a::type set set. S ≠ (Q::'a::type set) ∧ (a::'a::type) ∈ S ∧ (∃c::'a::type. c ∈ S ∧ c ∈ (R::'a::type set))›*)
obtain d where d_event: "d ∈ ℰ" and d_notinR: "d ∉ R"
(*goal: ‹(⋀d. ⟦d ∈ ℰ; d ∉ R⟧ ⟹ thesis) ⟹ thesis›*)
using external_event (*‹(?Q::'a set) ∈ (𝒫::'a set set) ⟹ ∃d::'a∈ℰ::'a set. d ∉ ?Q›*) path_R (*‹R ∈ 𝒫›*) by blast
have b_reachable: "b ∈ R - unreach-on R from a"
using cross_in_reachable (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R⟧ ⟹ ?b ∈ ?R - unreach-on ?R from ?a›*) path_R (*‹(R::'a set) ∈ (𝒫::'a set set)›*) a_inQ (*‹a ∈ Q›*) b_inQ (*‹(b::'a::type) ∈ (Q::'a::type set)›*) b_inR (*‹(b::'a) ∈ (R::'a set)›*) path_Q (*‹(Q::'a set) ∈ (𝒫::'a set set)›*) by simp
have a_notinR: "a ∉ R"
using cross_once_notin (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*) Q_neq_R (*‹Q ≠ R›*) a_inQ (*‹a ∈ Q›*) a_neq_b (*‹a ≠ b›*) b_inQ (*‹(b::'a) ∈ (Q::'a set)›*) b_inR (*‹b ∈ R›*) path_Q (*‹Q ∈ 𝒫›*) path_R (*‹R ∈ 𝒫›*) by blast
then obtain u where "u ∈ unreach-on R from a"
(*goal: ‹(⋀u. u ∈ unreach-on R from a ⟹ thesis) ⟹ thesis›*)
using two_in_unreach (*‹⟦?Q ∈ 𝒫; ?b ∈ ℰ; ?b ∉ ?Q⟧ ⟹ ∃x∈unreach-on ?Q from ?b. ∃y∈unreach-on ?Q from ?b. x ≠ y›*) a_inQ (*‹a ∈ Q›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_Q (*‹Q ∈ 𝒫›*) path_R (*‹(R::'a::type set) ∈ (𝒫::'a::type set set)›*) by blast
then obtain c where c_reachable: "c ∈ R - unreach-on R from a" and c_neq_b: "b ≠ c"
(*goal: ‹(⋀c. ⟦c ∈ R - unreach-on R from a; b ≠ c⟧ ⟹ thesis) ⟹ thesis›*)
using unreachable_set_bounded[where Q = R and Qx = b and b = a and Qy = u] (*‹⟦R ∈ 𝒫; a ∉ R; a ∈ ℰ; b ∈ R - unreach-on R from a; u ∈ unreach-on R from a⟧ ⟹ ∃Qz∈R - unreach-on R from a. [b;u;Qz] ∧ b ≠ Qz›*) path_R (*‹R ∈ 𝒫›*) d_event (*‹d ∈ ℰ›*) d_notinR (*‹d ∉ R›*) using a_inQ (*‹a ∈ Q›*) a_notinR (*‹a ∉ R›*) b_reachable (*‹b ∈ R - unreach-on R from a›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_Q (*‹Q ∈ 𝒫›*) by blast
then obtain S where S_facts: "S ∈ 𝒫 ∧ a ∈ S ∧ (c ∈ S ∧ c ∈ R)"
(*goal: ‹(⋀S. S ∈ 𝒫 ∧ a ∈ S ∧ c ∈ S ∧ c ∈ R ⟹ thesis) ⟹ thesis›*)
using reachable_path (*‹⟦?Q ∈ 𝒫; ?b ∈ ℰ; ?a ∈ ?Q - unreach-on ?Q from ?b⟧ ⟹ ∃R∈𝒫. ?a ∈ R ∧ ?b ∈ R›*) by (metis Diff_iff (*‹(?c ∈ ?A - ?B) = (?c ∈ ?A ∧ ?c ∉ ?B)›*) a_inQ (*‹a ∈ Q›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_Q (*‹Q ∈ 𝒫›*) path_R (*‹R ∈ 𝒫›*))
then have "S ≠ Q"
using Q_neq_R (*‹Q ≠ R›*) b_inQ (*‹b ∈ Q›*) b_inR (*‹b ∈ R›*) c_neq_b (*‹b ≠ c›*) eq_paths (*‹⟦(?P::'a set) ∈ (𝒫::'a set set); (?Q::'a set) ∈ 𝒫; (?a::'a) ∈ ?P; (?b::'a) ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) path_R (*‹R ∈ 𝒫›*) by blast
thus "?thesis"
(*goal: ‹∃S∈𝒫. S ≠ Q ∧ a ∈ S ∧ (∃c. c ∈ S ∧ c ∈ R)›*)
using S_facts (*‹S ∈ 𝒫 ∧ a ∈ S ∧ c ∈ S ∧ c ∈ R›*) by auto
qed
theorem (*5ii*) ex_crossing_at:
assumes path_Q: "Q ∈ 𝒫"
and a_inQ: "a ∈ Q"
shows "∃ac∈𝒫. ac ≠ Q ∧ (∃c. c ∉ Q ∧ a ∈ ac ∧ c ∈ ac)"
proof (-)
(*goal: ‹∃ac∈𝒫. ac ≠ Q ∧ (∃c. c ∉ Q ∧ a ∈ ac ∧ c ∈ ac)›*)
obtain b where b_inQ: "b ∈ Q" and a_neq_b: "a ≠ b"
(*goal: ‹(⋀b. ⟦b ∈ Q; a ≠ b⟧ ⟹ thesis) ⟹ thesis›*)
using a_inQ (*‹(a::'a) ∈ (Q::'a set)›*) ge2_events (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q⟧ ⟹ ∃b::'a∈?Q. b ≠ ?a›*) path_Q (*‹Q ∈ 𝒫›*) by blast
have "∃R∈𝒫. R ≠ Q ∧ (∃e. e ∈ R ∧ e ∈ Q)"
by (simp add: ex_crossing_path (*‹(?Q::'a set) ∈ (𝒫::'a set set) ⟹ ∃R::'a set∈𝒫. R ≠ ?Q ∧ (∃c::'a. c ∈ R ∧ c ∈ ?Q)›*) path_Q (*‹(Q::'a set) ∈ (𝒫::'a set set)›*))
then obtain R and e where path_R: "R ∈ 𝒫" and R_neq_Q: "R ≠ Q" and e_inR: "e ∈ R" and e_inQ: "e ∈ Q"
(*goal: ‹(⋀R e. ⟦R ∈ 𝒫; R ≠ Q; e ∈ R; e ∈ Q⟧ ⟹ thesis) ⟹ thesis›*)
by auto
thus "?thesis"
(*goal: ‹∃ac∈𝒫. ac ≠ Q ∧ (∃c. c ∉ Q ∧ a ∈ ac ∧ c ∈ ac)›*)
proof (cases)
(*goals:
1. ‹⟦R ∈ 𝒫; R ≠ Q; e ∈ R; e ∈ Q; ?P4⟧ ⟹ ∃ac∈𝒫. ac ≠ Q ∧ (∃c. c ∉ Q ∧ a ∈ ac ∧ c ∈ ac)›
2. ‹⟦R ∈ 𝒫; R ≠ Q; e ∈ R; e ∈ Q; ¬ ?P4⟧ ⟹ ∃ac∈𝒫. ac ≠ Q ∧ (∃c. c ∉ Q ∧ a ∈ ac ∧ c ∈ ac)›*)
assume e_eq_a: "e = a" (*‹(e::'a) = (a::'a)›*)
then have "∃c. c ∈ unreach-on R from b"
using R_neq_Q (*‹R ≠ Q›*) a_inQ (*‹(a::'a) ∈ (Q::'a set)›*) a_neq_b (*‹a ≠ b›*) b_inQ (*‹b ∈ Q›*) e_inR (*‹e ∈ R›*) path_Q (*‹Q ∈ 𝒫›*) path_R (*‹R ∈ 𝒫›*) two_in_unreach (*‹⟦?Q ∈ 𝒫; ?b ∈ ℰ; ?b ∉ ?Q⟧ ⟹ ∃x∈unreach-on ?Q from ?b. ∃y∈unreach-on ?Q from ?b. x ≠ y›*) path_unique (*‹⟦path ?ab ?a ?b; path ?ab' ?a ?b⟧ ⟹ ?ab = ?ab'›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) by metis
thus "?thesis"
(*goal: ‹∃ac::'a set∈𝒫::'a set set. ac ≠ (Q::'a set) ∧ (∃c::'a. c ∉ Q ∧ (a::'a) ∈ ac ∧ c ∈ ac)›*)
using R_neq_Q (*‹(R::'a set) ≠ (Q::'a set)›*) e_eq_a (*‹e = a›*) e_inR (*‹e ∈ R›*) path_Q (*‹Q ∈ 𝒫›*) path_R (*‹R ∈ 𝒫›*) eq_paths (*‹⟦(?P::'a::type set) ∈ (𝒫::'a::type set set); (?Q::'a::type set) ∈ 𝒫; (?a::'a::type) ∈ ?P; (?b::'a::type) ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) ge2_events_lax (*‹?Q ∈ 𝒫 ⟹ ∃a∈?Q. ∃b∈?Q. a ≠ b›*) by metis
next
(*goal: ‹⟦(R::'a set) ∈ (𝒫::'a set set); R ≠ (Q::'a set); (e::'a) ∈ R; e ∈ Q; e ≠ (a::'a)⟧ ⟹ ∃ac::'a set∈𝒫. ac ≠ Q ∧ (∃c::'a. c ∉ Q ∧ a ∈ ac ∧ c ∈ ac)›*)
assume e_neq_a: "e ≠ a" (*‹(e::'a) ≠ (a::'a)›*)
then have "∃S∈𝒫. S ≠ Q ∧ a ∈ S ∧ (∃c. c ∈ S ∧ c ∈ R)"
using path_past_unreach (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R; ?Q ≠ ?R; ?a ≠ ?b⟧ ⟹ ∃S∈𝒫. S ≠ ?Q ∧ ?a ∈ S ∧ (∃c. c ∈ S ∧ c ∈ ?R)›*) R_neq_Q (*‹R ≠ Q›*) a_inQ (*‹a ∈ Q›*) e_inQ (*‹e ∈ Q›*) e_inR (*‹e ∈ R›*) path_Q (*‹(Q::'a set) ∈ (𝒫::'a set set)›*) path_R (*‹R ∈ 𝒫›*) by auto
thus "?thesis"
(*goal: ‹∃ac∈𝒫. ac ≠ Q ∧ (∃c. c ∉ Q ∧ a ∈ ac ∧ c ∈ ac)›*)
by (metis R_neq_Q (*‹R ≠ Q›*) e_inR (*‹e ∈ R›*) e_neq_a (*‹e ≠ a›*) eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) path_Q (*‹Q ∈ 𝒫›*) path_R (*‹R ∈ 𝒫›*))
qed
qed
(* Alternative formulation using the path function *)
lemma (*5ii_alt*) ex_crossing_at_alt:
assumes path_Q: "Q ∈ 𝒫"
and a_inQ: "a ∈ Q"
shows "∃ac. ∃c. path ac a c ∧ ac ≠ Q ∧ c ∉ Q"
using ex_crossing_at (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ∃ac∈𝒫. ac ≠ ?Q ∧ (∃c. c ∉ ?Q ∧ ?a ∈ ac ∧ c ∈ ac)›*) assms (*‹Q ∈ 𝒫› ‹a ∈ Q›*) by fastforce
end (* context MinkowskiSpacetime *)
section "3.4 Prolongation"
context MinkowskiSpacetime begin
lemma (in MinkowskiPrimitive) unreach_on_path:
"a ∈ unreach-on Q from b ⟹ a ∈ Q"
using unreachable_subset_def (*‹unreach-on ?Q from ?b ≡ {x ∈ ?Q. ?Q ∈ 𝒫 ∧ ?b ∈ ℰ ∧ ?b ∉ ?Q ∧ (∄Q. path Q ?b x)}›*) by simp
lemma (in MinkowskiUnreachable) unreach_equiv:
"⟦Q ∈ 𝒫; R ∈ 𝒫; a ∈ Q; b ∈ R; a ∈ unreach-on Q from b⟧ ⟹ b ∈ unreach-on R from a"
unfolding unreachable_subset_def
(*goal: ‹⟦(Q::'a set) ∈ (𝒫::'a set set); (R::'a set) ∈ 𝒫; (a::'a) ∈ Q; (b::'a) ∈ R; a ∈ {x::'a ∈ Q. Q ∈ 𝒫 ∧ b ∈ (ℰ::'a set) ∧ b ∉ Q ∧ (∄Q::'a set. path Q b x)}⟧ ⟹ b ∈ {x::'a ∈ R. R ∈ 𝒫 ∧ a ∈ ℰ ∧ a ∉ R ∧ (∄Q::'a set. path Q a x)}›*)
by auto
theorem (*6i*) prolong_betw:
assumes path_Q: "Q ∈ 𝒫"
and a_inQ: "a ∈ Q"
and b_inQ: "b ∈ Q"
and ab_neq: "a ≠ b"
shows "∃c∈ℰ. [a;b;c]"
proof (-)
(*goal: ‹∃c∈ℰ. [a;b;c]›*)
obtain e and ae where e_event: "e ∈ ℰ" and e_notinQ: "e ∉ Q" and path_ae: "path ae a e"
(*goal: ‹(⋀e ae. ⟦e ∈ ℰ; e ∉ Q; path ae a e⟧ ⟹ thesis) ⟹ thesis›*)
using ex_crossing_at (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ∃ac∈𝒫. ac ≠ ?Q ∧ (∃c. c ∉ ?Q ∧ ?a ∈ ac ∧ c ∈ ac)›*) a_inQ (*‹(a::'a::type) ∈ (Q::'a::type set)›*) path_Q (*‹(Q::'a::type set) ∈ (𝒫::'a::type set set)›*) in_path_event (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q⟧ ⟹ ?a ∈ (ℰ::'a set)›*) by blast
have "b ∉ ae"
using a_inQ (*‹a ∈ Q›*) ab_neq (*‹a ≠ b›*) b_inQ (*‹b ∈ Q›*) e_notinQ (*‹e ∉ Q›*) eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) path_Q (*‹Q ∈ 𝒫›*) path_ae (*‹path ae a e›*) by blast
then obtain f where f_unreachable: "f ∈ unreach-on ae from b"
(*goal: ‹(⋀f::'a. f ∈ unreach-on (ae::'a set) from (b::'a) ⟹ thesis::bool) ⟹ thesis›*)
using two_in_unreach (*‹⟦?Q ∈ 𝒫; ?b ∈ ℰ; ?b ∉ ?Q⟧ ⟹ ∃x∈unreach-on ?Q from ?b. ∃y∈unreach-on ?Q from ?b. x ≠ y›*) b_inQ (*‹b ∈ Q›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_Q (*‹Q ∈ 𝒫›*) path_ae (*‹path ae a e›*) by blast
then have b_unreachable: "b ∈ unreach-on Q from f"
using unreach_equiv (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?R; ?a ∈ unreach-on ?Q from ?b⟧ ⟹ ?b ∈ unreach-on ?R from ?a›*) by (metis (mono_tags, lifting) CollectD (*‹?a ∈ {x. ?P x} ⟹ ?P ?a›*) b_inQ (*‹b ∈ Q›*) path_Q (*‹Q ∈ 𝒫›*) unreachable_subset_def (*‹unreach-on ?Q from ?b ≡ {x ∈ ?Q. ?Q ∈ 𝒫 ∧ ?b ∈ ℰ ∧ ?b ∉ ?Q ∧ (∄Q. path Q ?b x)}›*))
have a_reachable: "a ∈ Q - unreach-on Q from f"
using same_path_reachable2[where Q = ae and R = Q and a = a and b = f] (*‹⟦ae ∈ 𝒫; Q ∈ 𝒫; a ∈ ae; a ∈ Q; f ∈ ae⟧ ⟹ a ∈ Q - unreach-on Q from f›*) path_ae (*‹path ae a e›*) a_inQ (*‹a ∈ Q›*) path_Q (*‹Q ∈ 𝒫›*) f_unreachable (*‹f ∈ unreach-on ae from b›*) unreach_on_path (*‹?a ∈ unreach-on ?Q from ?b ⟹ ?a ∈ ?Q›*) by blast
thus "?thesis"
(*goal: ‹∃c∈ℰ. [a;b;c]›*)
using unreachable_set_bounded[where Qy = b and Q = Q and b = f and Qx = a] (*‹⟦Q ∈ 𝒫; f ∉ Q; f ∈ ℰ; a ∈ Q - unreach-on Q from f; b ∈ unreach-on Q from f⟧ ⟹ ∃Qz∈Q - unreach-on Q from f. [a;b;Qz] ∧ a ≠ Qz›*) b_unreachable (*‹b ∈ unreach-on Q from f›*) unreachable_subset_def (*‹unreach-on ?Q from ?b ≡ {x ∈ ?Q. ?Q ∈ 𝒫 ∧ ?b ∈ ℰ ∧ ?b ∉ ?Q ∧ (∄Q. path Q ?b x)}›*) by auto
qed
lemma (in MinkowskiSpacetime) prolong_betw2:
assumes path_Q: "Q ∈ 𝒫"
and a_inQ: "a ∈ Q"
and b_inQ: "b ∈ Q"
and ab_neq: "a ≠ b"
shows "∃c∈Q. [a;b;c]"
by (metis assms (*‹Q ∈ 𝒫› ‹a ∈ Q› ‹b ∈ Q› ‹a ≠ b›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) prolong_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ∃c∈ℰ. [?a;?b;c]›*))
lemma (in MinkowskiSpacetime) prolong_betw3:
assumes path_Q: "Q ∈ 𝒫"
and a_inQ: "a ∈ Q"
and b_inQ: "b ∈ Q"
and ab_neq: "a ≠ b"
shows "∃c∈Q. ∃d∈Q. [a;b;c] ∧ [a;b;d] ∧ c≠d"
by (metis (full_types) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) a_inQ (*‹a ∈ Q›*) ab_neq (*‹a ≠ b›*) b_inQ (*‹b ∈ Q›*) path_Q (*‹Q ∈ 𝒫›*) prolong_betw2 (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ∃c∈?Q. [?a;?b;c]›*))
lemma finite_path_has_ends:
assumes "Q ∈ 𝒫"
and "X ⊆ Q"
and "finite X"
and "card X ≥ 3"
shows "∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])"
using assms (*‹Q ∈ 𝒫› ‹X ⊆ Q› ‹finite X› ‹(3::nat) ≤ card (X::'a set)›*) proof (induct "card X - 3" arbitrary: X)
(*goals:
1. ‹⋀X. ⟦0 = card X - 3; Q ∈ 𝒫; X ⊆ Q; finite X; 3 ≤ card X⟧ ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›
2. ‹⋀x X. ⟦⋀X. ⟦x = card X - 3; Q ∈ 𝒫; X ⊆ Q; finite X; 3 ≤ card X⟧ ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b]); Suc x = card X - 3; Q ∈ 𝒫; X ⊆ Q; finite X; 3 ≤ card X⟧ ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
case 0 (*‹0 = card X - 3› ‹Q ∈ 𝒫› ‹(X::'a set) ⊆ (Q::'a set)› ‹finite (X::'a::type set)› ‹3 ≤ card X›*)
then have "card X = 3"
by linarith
then obtain a and b and c where X_eq: "X = {a, b, c}"
(*goal: ‹(⋀a b c. X = {a, b, c} ⟹ thesis) ⟹ thesis›*)
by (metis card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*) numeral_3_eq_3 (*‹3 = Suc (Suc (Suc 0))›*))
then have abc_neq: "a ≠ b" "a ≠ c" "b ≠ c"
apply -
(*goals:
1. ‹X = {a, b, c} ⟹ a ≠ b›
2. ‹X = {a, b, c} ⟹ a ≠ c›
3. ‹X = {a, b, c} ⟹ b ≠ c›
discuss goal 1*)
apply (metis ‹card X = 3› empty_iff (*‹(?c ∈ {}) = False›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) order_refl (*‹?x ≤ ?x›*) three_in_set3 (*‹⟦3 ≤ card ?X; ⋀x y z. ⟦x ∈ ?X; y ∈ ?X; z ∈ ?X; x ≠ y; x ≠ z; y ≠ z⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*discuss goal 2*)
apply (metis ‹card X = 3› empty_iff (*‹(?c ∈ {}) = False›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) order_refl (*‹?x ≤ ?x›*) three_in_set3 (*‹⟦3 ≤ card ?X; ⋀x y z. ⟦x ∈ ?X; y ∈ ?X; z ∈ ?X; x ≠ y; x ≠ z; y ≠ z⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*discuss goal 3*)
apply (metis ‹card X = 3› empty_iff (*‹(?c ∈ {}) = False›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) order_refl (*‹?x ≤ ?x›*) three_in_set3 (*‹⟦3 ≤ card ?X; ⋀x y z. ⟦x ∈ ?X; y ∈ ?X; z ∈ ?X; x ≠ y; x ≠ z; y ≠ z⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*proven 3 subgoals*) .
then consider "[a;b;c]" | "[b;c;a]" | "[c;a;b]"
(*goal: ‹⟦[a;b;c] ⟹ thesis; [b;c;a] ⟹ thesis; [c;a;b] ⟹ thesis⟧ ⟹ thesis›*)
using some_betw[of Q a b c] (*‹⟦Q ∈ 𝒫; a ∈ Q; b ∈ Q; c ∈ Q; a ≠ b; a ≠ c; b ≠ c⟧ ⟹ [a;b;c] ∨ [b;c;a] ∨ [c;a;b]›*) "0.prems"(1) (*‹Q ∈ 𝒫›*) "0.prems"(2) (*‹X ⊆ Q›*) X_eq (*‹X = {a, b, c}›*) by auto
thus "?case"
(*goal: ‹∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
proof (cases)
(*goals:
1. ‹[a;b;c] ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›
2. ‹[b;c;a] ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›
3. ‹[c;a;b] ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
assume "[a;b;c]" (*‹[a::'a;b::'a;c::'a]›*)
thus "?thesis"
(*goal: ‹∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
using X_eq (*‹X = {a, b, c}›*) abc_neq(2) (*‹a ≠ c›*) by blast
next
(*goals:
1. ‹[b;c;a] ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›
2. ‹[c;a;b] ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
assume "[b;c;a]" (*‹[b::'a;c::'a;a::'a]›*)
thus "?thesis"
(*goal: ‹∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
by (simp add: X_eq (*‹X = {a, b, c}›*) abc_neq( (*‹a ≠ b›*) 1))
next
(*goal: ‹[c;a;b] ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
assume "[c;a;b]" (*‹[c::'a;a::'a;b::'a]›*)
thus "?thesis"
(*goal: ‹∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
using X_eq (*‹X = {a, b, c}›*) abc_neq(3) (*‹b ≠ c›*) by blast
qed
next
(*goal: ‹⋀x X. ⟦⋀X. ⟦x = card X - 3; Q ∈ 𝒫; X ⊆ Q; finite X; 3 ≤ card X⟧ ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b]); Suc x = card X - 3; Q ∈ 𝒫; X ⊆ Q; finite X; 3 ≤ card X⟧ ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
case IH: (Suc n) (*‹⟦n = card ?X - 3; Q ∈ 𝒫; ?X ⊆ Q; finite ?X; 3 ≤ card ?X⟧ ⟹ ∃a∈?X. ∃b∈?X. a ≠ b ∧ (∀c∈?X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])› ‹Suc n = card X - 3› ‹Q ∈ 𝒫› ‹(X::'a set) ⊆ (Q::'a set)› ‹finite X› ‹3 ≤ card X›*)
obtain Y and x where X_eq: "X = insert x Y" and "x ∉ Y"
(*goal: ‹(⋀(x::'a) Y::'a set. ⟦(X::'a set) = insert x Y; x ∉ Y⟧ ⟹ thesis::bool) ⟹ thesis›*)
by (meson IH.prems( (*‹(3::nat) ≤ card (X::'a::type set)›*) 4) Set.set_insert (*‹⟦(?x::?'a::type) ∈ (?A::?'a::type set); ⋀B::?'a::type set. ⟦?A = insert ?x B; ?x ∉ B⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) three_in_set3 (*‹⟦(3::nat) ≤ card (?X::?'a::type set); ⋀(x::?'a::type) (y::?'a::type) z::?'a::type. ⟦x ∈ ?X; y ∈ ?X; z ∈ ?X; x ≠ y; x ≠ z; y ≠ z⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*))
then have "card Y - 3 = n" "card Y ≥ 3"
using IH.hyps(2) (*‹Suc n = card X - 3›*) IH.prems(3) (*‹finite X›*) X_eq (*‹X = insert x Y›*) ‹x ∉ Y› (*‹x ∉ Y›*) apply -
(*goals:
1. ‹⟦X = insert x Y; x ∉ Y; Suc n = card X - 3; finite X; X = insert x Y; x ∉ Y⟧ ⟹ card Y - 3 = n›
2. ‹⟦X = insert x Y; x ∉ Y; Suc n = card X - 3; finite X; X = insert x Y; x ∉ Y⟧ ⟹ 3 ≤ card Y›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
then obtain a and b where ab_Y: "a ∈ Y" "b ∈ Y" "a ≠ b" and Y_ends: "∀c∈Y. (a ≠ c ∧ b ≠ c) ⟶ [a;c;b]"
(*goal: ‹(⋀a b. ⟦a ∈ Y; b ∈ Y; a ≠ b; ∀c∈Y. a ≠ c ∧ b ≠ c ⟶ [a;c;b]⟧ ⟹ thesis) ⟹ thesis›*)
using IH(1)[of Y] (*‹⟦n = card Y - 3; Q ∈ 𝒫; Y ⊆ Q; finite Y; 3 ≤ card Y⟧ ⟹ ∃a∈Y. ∃b∈Y. a ≠ b ∧ (∀c∈Y. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*) IH.prems(1-3) (*‹Q ∈ 𝒫› ‹X ⊆ Q› ‹finite X›*) X_eq (*‹X = insert x Y›*) by auto
consider "[a;x;b]" | "[x;b;a]" | "[b;a;x]"
(*goal: ‹⟦[a;x;b] ⟹ thesis; [x;b;a] ⟹ thesis; [b;a;x] ⟹ thesis⟧ ⟹ thesis›*)
using some_betw[of Q a x b] (*‹⟦(Q::'a::type set) ∈ (𝒫::'a::type set set); (a::'a::type) ∈ Q; (x::'a::type) ∈ Q; (b::'a::type) ∈ Q; a ≠ x; a ≠ b; x ≠ b⟧ ⟹ [a;x;b] ∨ [x;b;a] ∨ [b;a;x]›*) ab_Y (*‹(a::'a) ∈ (Y::'a set)› ‹b ∈ Y› ‹a ≠ b›*) IH.prems(1,2) (*‹Q ∈ 𝒫› ‹(X::'a set) ⊆ (Q::'a set)›*) X_eq (*‹X = insert x Y›*) ‹x ∉ Y› (*‹x ∉ Y›*) by auto
thus "?case"
(*goal: ‹∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
proof (cases)
(*goals:
1. ‹[a;x;b] ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›
2. ‹[x;b;a] ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›
3. ‹[b;a;x] ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
assume "[a;x;b]" (*‹[a::'a;x::'a;b::'a]›*)
thus "?thesis"
(*goal: ‹∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
using Y_ends (*‹∀c∈Y. a ≠ c ∧ b ≠ c ⟶ [a;c;b]›*) X_eq (*‹X = insert x Y›*) ab_Y (*‹a ∈ Y› ‹b ∈ Y› ‹a ≠ b›*) by auto
next
(*goals:
1. ‹[x;b;a] ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›
2. ‹[b;a;x] ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
assume "[x;b;a]" (*‹[x::'a;b::'a;a::'a]›*)
{
fix c
assume "c ∈ X" "x ≠ c" "a ≠ c" (*‹(c::'a) ∈ (X::'a set)› ‹(x::'a) ≠ (c::'a)› ‹(a::'a) ≠ (c::'a)›*)
then have "[x;c;a]"
by (smt IH.prems( (*‹X ⊆ Q›*) 2) X_eq (*‹X = insert x Y›*) Y_ends (*‹∀c∈Y. a ≠ c ∧ b ≠ c ⟶ [a;c;b]›*) ‹[x;b;a]› ab_Y( (*‹a ∈ Y›*) 1) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]›*) 3) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) ‹Q ∈ 𝒫› betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*))
}
thus "?thesis"
(*goal: ‹∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
using X_eq (*‹X = insert x Y›*) ‹[x;b;a]› (*‹[x;b;a]›*) ab_Y(1) (*‹a ∈ Y›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) by force
next
(*goal: ‹[b;a;x] ⟹ ∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
assume "[b;a;x]" (*‹[b::'a;a::'a;x::'a]›*)
{
fix c
assume "c ∈ X" "b ≠ c" "x ≠ c" (*‹(c::'a) ∈ (X::'a set)› ‹(b::'a) ≠ (c::'a)› ‹(x::'a) ≠ (c::'a)›*)
then have "[b;c;x]"
by (smt IH.prems( (*‹X ⊆ Q›*) 2) X_eq (*‹X = insert x Y›*) Y_ends (*‹∀c∈Y. a ≠ c ∧ b ≠ c ⟶ [a;c;b]›*) ‹[b;a;x]› ab_Y( (*‹a ∈ Y›*) 1) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]›*) 1) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) ‹Q ∈ 𝒫› betw_a_in_path (*‹⟦[?a;?b;?c]; path ?bc ?b ?c⟧ ⟹ ?a ∈ ?bc›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*))
}
thus "?thesis"
(*goal: ‹∃a∈X. ∃b∈X. a ≠ b ∧ (∀c∈X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*)
using X_eq (*‹X = insert x Y›*) ‹x ∉ Y› (*‹x ∉ Y›*) ab_Y(2) (*‹b ∈ Y›*) by fastforce
qed
qed
lemma obtain_fin_path_ends:
assumes path_X: "X∈𝒫"
and fin_Q: "finite Q"
and card_Q: "card Q ≥ 3"
and events_Q: "Q⊆X"
obtains a b where "a≠b" and "a∈Q" and "b∈Q" and "∀c∈Q. (a≠c ∧ b≠c) ⟶ [a;c;b]"
proof (-)
(*goal: ‹(⋀a b. ⟦a ≠ b; a ∈ Q; b ∈ Q; ∀c∈Q. a ≠ c ∧ b ≠ c ⟶ [a;c;b]⟧ ⟹ thesis) ⟹ thesis›*)
obtain n where "n≥0" and "card Q = n+3"
(*goal: ‹(⋀n. ⟦0 ≤ n; card Q = n + 3⟧ ⟹ thesis) ⟹ thesis›*)
using card_Q (*‹3 ≤ card Q›*) nat_le_iff_add (*‹(?m ≤ ?n) = (∃k. ?n = ?m + k)›*) by auto
then obtain a and b where "a≠b" and "a∈Q" and "b∈Q" and "∀c∈Q. (a≠c ∧ b≠c) ⟶ [a;c;b]"
(*goal: ‹(⋀a b. ⟦a ≠ b; a ∈ Q; b ∈ Q; ∀c∈Q. a ≠ c ∧ b ≠ c ⟶ [a;c;b]⟧ ⟹ thesis) ⟹ thesis›*)
using finite_path_has_ends (*‹⟦?Q ∈ 𝒫; ?X ⊆ ?Q; finite ?X; 3 ≤ card ?X⟧ ⟹ ∃a∈?X. ∃b∈?X. a ≠ b ∧ (∀c∈?X. a ≠ c ∧ b ≠ c ⟶ [a;c;b])›*) assms (*‹X ∈ 𝒫› ‹finite Q› ‹(3::nat) ≤ card (Q::'a::type set)› ‹Q ⊆ X›*) ‹n≥0› (*‹0 ≤ n›*) by metis
thus "?thesis"
(*goal: ‹thesis›*)
using that (*‹⟦?a ≠ ?b; ?a ∈ Q; ?b ∈ Q; ∀c∈Q. ?a ≠ c ∧ ?b ≠ c ⟶ [?a;c;?b]⟧ ⟹ thesis›*) by auto
qed
lemma path_card_nil:
assumes "Q∈𝒫"
shows "card Q = 0"
proof (rule ccontr)
assume "card Q ≠ 0"
obtain n where "n = card Q"
by auto
hence "n≥1"
using ‹card Q ≠ 0› by linarith
then consider (n1) "n=1" | (n2) "n=2" | (n3) "n≥3"
by linarith
thus False
proof (cases)
case n1
thus ?thesis
using One_nat_def card_Suc_eq ge2_events_lax singletonD assms(1)
by (metis ‹n = card Q›)
next
case n2
then obtain a b where "a≠b" and "a∈Q" and "b∈Q"
using ge2_events_lax assms(1) by blast
then obtain c where "c∈Q" and "c≠a" and "c≠b"
using prolong_betw2 by (metis abc_abc_neq assms(1))
hence "card Q ≠ 2"
by (metis ‹a ∈ Q› ‹a ≠ b› ‹b ∈ Q› card_2_iff')
thus False
using ‹n = card Q› ‹n = 2› by blast
next
case n3
have fin_Q: "finite Q"
proof -
have "(0::nat) ≠ 1"
by simp
then show ?thesis
by (meson ‹card Q ≠ 0› card.infinite)
qed
have card_Q: "card Q ≥ 3"
using ‹n = card Q› n3 by blast
have "Q⊆Q" by simp
then obtain a b where "a∈Q" and "b∈Q" and "a≠b"
and acb: "∀c∈Q. (c≠a ∧ c≠b) ⟶ [a;c;b]"
using obtain_fin_path_ends card_Q fin_Q assms(1)
by metis
then obtain x where "[a;b;x]" and "x∈Q"
using prolong_betw2 assms(1) by blast
thus False
by (metis acb abc_abc_neq abc_only_cba(2))
qed
qed
theorem (*6ii*) infinite_paths:
assumes "P∈𝒫"
shows "infinite P"
proof (standard)
(*goal: ‹finite P ⟹ False›*)
assume fin_P: "finite P" (*‹finite (P::'a set)›*)
have "P≠{}"
by (simp add: assms (*‹P ∈ 𝒫›*))
hence "card P ≠ 0"
by (simp add: fin_P (*‹finite P›*))
moreover have "¬(card P ≥ 1)"
using path_card_nil (*‹?Q ∈ 𝒫 ⟹ card ?Q = 0›*) by (simp add: assms (*‹P ∈ 𝒫›*))
ultimately show False
by simp
qed
end (* contex MinkowskiSpacetime *)
section "3.5 Second collinearity theorem"
text ‹We start with a useful betweenness lemma.›
lemma (in MinkowskiBetweenness) some_betw2:
assumes path_Q: "Q ∈ 𝒫"
and a_inQ: "a ∈ Q"
and b_inQ: "b ∈ Q"
and c_inQ: "c ∈ Q"
shows "a = b ∨ a = c ∨ b = c ∨ [a;b;c] ∨ [b;c;a] ∨ [c;a;b]"
using a_inQ (*‹a ∈ Q›*) b_inQ (*‹b ∈ Q›*) c_inQ (*‹c ∈ Q›*) path_Q (*‹Q ∈ 𝒫›*) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) by blast
lemma (in MinkowskiPrimitive) paths_tri:
assumes path_ab: "path ab a b"
and path_bc: "path bc b c"
and path_ca: "path ca c a"
and a_notin_bc: "a ∉ bc"
shows "△ a b c"
proof (-)
(*goal: ‹△ a b c›*)
have abc_events: "a ∈ ℰ ∧ b ∈ ℰ ∧ c ∈ ℰ"
using path_ab (*‹path ab a b›*) path_bc (*‹path bc b c›*) path_ca (*‹path (ca::'a set) (c::'a) (a::'a)›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) by auto
have abc_neq: "a ≠ b ∧ a ≠ c ∧ b ≠ c"
using path_ab (*‹path (ab::'a set) (a::'a) (b::'a)›*) path_bc (*‹path (bc::'a set) (b::'a) (c::'a)›*) path_ca (*‹path (ca::'a::type set) (c::'a::type) (a::'a::type)›*) by auto
have paths_neq: "ab ≠ bc ∧ ab ≠ ca ∧ bc ≠ ca"
using a_notin_bc (*‹a ∉ bc›*) cross_once_notin (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*) path_ab (*‹path (ab::'a::type set) (a::'a::type) (b::'a::type)›*) path_bc (*‹path (bc::'a::type set) (b::'a::type) (c::'a::type)›*) path_ca (*‹path ca c a›*) by blast
show "?thesis"
(*goal: ‹△ (a::'a) (b::'a) (c::'a)›*)
unfolding kinematic_triangle_def
(*goal: ‹a ∈ ℰ ∧ b ∈ ℰ ∧ c ∈ ℰ ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c ∧ (∃Q∈𝒫. ∃R∈𝒫. Q ≠ R ∧ (∃S∈𝒫. Q ≠ S ∧ R ≠ S ∧ a ∈ Q ∧ b ∈ Q ∧ a ∈ R ∧ c ∈ R ∧ b ∈ S ∧ c ∈ S))›*)
using abc_events (*‹a ∈ ℰ ∧ b ∈ ℰ ∧ c ∈ ℰ›*) abc_neq (*‹a ≠ b ∧ a ≠ c ∧ b ≠ c›*) paths_neq (*‹ab ≠ bc ∧ ab ≠ ca ∧ bc ≠ ca›*) path_ab (*‹path ab a b›*) path_bc (*‹path bc b c›*) path_ca (*‹path ca c a›*) by auto
qed
lemma (in MinkowskiPrimitive) paths_tri2:
assumes path_ab: "path ab a b"
and path_bc: "path bc b c"
and path_ca: "path ca c a"
and ab_neq_bc: "ab ≠ bc"
shows "△ a b c"
by (meson ab_neq_bc (*‹(ab::'a set) ≠ (bc::'a set)›*) cross_once_notin (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?R::'a set) ∈ 𝒫; (?a::'a) ∈ ?Q; (?b::'a) ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*) path_ab (*‹path (ab::'a set) (a::'a) (b::'a)›*) path_bc (*‹path (bc::'a set) (b::'a) (c::'a)›*) path_ca (*‹path (ca::'a set) (c::'a) (a::'a)›*) paths_tri (*‹⟦path (?ab::'a set) (?a::'a) (?b::'a); path (?bc::'a set) ?b (?c::'a); path (?ca::'a set) ?c ?a; ?a ∉ ?bc⟧ ⟹ △ ?a ?b ?c›*))
text ‹
Schutz states it more like
‹⟦tri_abc; bcd; cea⟧ ⟹ (path de d e ⟶ ∃f∈de. [a;f;b]∧[d;e;f])›.
Equivalent up to usage of ‹impI›.
›
theorem (*7*) (in MinkowskiChain) collinearity2:
assumes tri_abc: "△ a b c"
and bcd: "[b;c;d]"
and cea: "[c;e;a]"
and path_de: "path de d e"
shows "∃f. [a;f;b] ∧ [d;e;f]"
proof (-)
(*goal: ‹∃f. [a;f;b] ∧ [d;e;f]›*)
obtain ab where path_ab: "path ab a b"
(*goal: ‹(⋀ab::'a::type set. path ab (a::'a::type) (b::'a::type) ⟹ thesis::bool) ⟹ thesis›*)
using tri_abc (*‹△ a b c›*) triangle_paths_unique (*‹△ ?a ?b ?c ⟹ ∃!ab. path ab ?a ?b›*) by blast
then obtain f where afb: "[a;f;b]" and f_in_de: "f ∈ de"
(*goal: ‹(⋀f. ⟦[a;f;b]; f ∈ de⟧ ⟹ thesis) ⟹ thesis›*)
using collinearity (*‹⟦△ ?a ?b ?c; path ?de ?d ?e; [?b;?c;?d]; [?c;?e;?a]⟧ ⟹ ∃f∈?de ∩ (THE ab. path ab ?a ?b). [?a;f;?b]›*) tri_abc (*‹△ a b c›*) path_de (*‹path de d e›*) path_ab (*‹path ab a b›*) bcd (*‹[b;c;d]›*) cea (*‹[c;e;a]›*) by blast
obtain af where path_af: "path af a f"
(*goal: ‹(⋀af. path af a f ⟹ thesis) ⟹ thesis›*)
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) afb (*‹[a;f;b]›*) betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) path_ab (*‹path (ab::'a set) (a::'a) (b::'a)›*) by blast
have "[d;e;f]"
proof (-)
(*goal: ‹[d::'a;e::'a;f::'a]›*)
have def_in_de: "d ∈ de ∧ e ∈ de ∧ f ∈ de"
using path_de (*‹path de d e›*) f_in_de (*‹(f::'a::type) ∈ (de::'a::type set)›*) by simp
then have five_poss: "f = d ∨ f = e ∨ [e;f;d] ∨ [f;d;e] ∨ [d;e;f]"
using path_de (*‹path de d e›*) some_betw2 (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q⟧ ⟹ ?a = ?b ∨ ?a = ?c ∨ ?b = ?c ∨ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) by blast
have "f = d ∨ f = e ⟶ (∃Q∈𝒫. a ∈ Q ∧ b ∈ Q ∧ c ∈ Q)"
by (metis abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) afb (*‹[a;f;b]›*) bcd (*‹[b;c;d]›*) betw_a_in_path (*‹⟦[?a;?b;?c]; path ?bc ?b ?c⟧ ⟹ ?a ∈ ?bc›*) betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) cea (*‹[c;e;a]›*) path_ab (*‹path ab a b›*))
then have f_neq_d_e: "f ≠ d ∧ f ≠ e"
using tri_abc (*‹△ (a::'a::type) (b::'a::type) (c::'a::type)›*) using triangle_diff_paths (*‹△ ?a ?b ?c ⟹ ¬ (∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q)›*) by simp
then consider "[e;f;d]" | "[f;d;e]" | "[d;e;f]"
(*goal: ‹⟦[e;f;d] ⟹ thesis; [f;d;e] ⟹ thesis; [d;e;f] ⟹ thesis⟧ ⟹ thesis›*)
using five_poss (*‹(f::'a::type) = (d::'a::type) ∨ f = (e::'a::type) ∨ [e;f;d] ∨ [f;d;e] ∨ [d;e;f]›*) by linarith
thus "?thesis"
(*goal: ‹[d;e;f]›*)
proof (cases)
(*goals:
1. ‹[e;f;d] ⟹ [d;e;f]›
2. ‹[f;d;e] ⟹ [d;e;f]›
3. ‹[d;e;f] ⟹ [d;e;f]›*)
assume efd: "[e;f;d]" (*‹[e::'a;f::'a;d::'a]›*)
obtain dc where path_dc: "path dc d c"
(*goal: ‹(⋀dc. path dc d c ⟹ thesis) ⟹ thesis›*)
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) bcd (*‹[b::'a::type;c::'a::type;d::'a::type]›*) by blast
obtain ce where path_ce: "path ce c e"
(*goal: ‹(⋀ce::'a set. path ce (c::'a) (e::'a) ⟹ thesis::bool) ⟹ thesis›*)
using abc_abc_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) cea (*‹[c::'a;e::'a;a::'a]›*) by blast
have "dc≠ce"
using bcd (*‹[b;c;d]›*) betw_a_in_path (*‹⟦[?a::'a;?b::'a;?c::'a]; path (?bc::'a set) ?b ?c⟧ ⟹ ?a ∈ ?bc›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) cea (*‹[c;e;a]›*) path_ce (*‹path ce c e›*) path_dc (*‹path dc d c›*) tri_abc (*‹△ a b c›*) triangle_diff_paths (*‹△ ?a ?b ?c ⟹ ¬ (∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q)›*) by blast
hence "△ d c e"
using paths_tri2 (*‹⟦path (?ab::'a set) (?a::'a) (?b::'a); path (?bc::'a set) ?b (?c::'a); path (?ca::'a set) ?c ?a; ?ab ≠ ?bc⟧ ⟹ △ ?a ?b ?c›*) path_ce (*‹path ce c e›*) path_dc (*‹path dc d c›*) path_de (*‹path de d e›*) by blast
then obtain x where x_in_af: "x ∈ af" and dxc: "[d;x;c]"
(*goal: ‹(⋀x::'a. ⟦x ∈ (af::'a set); [d::'a;x;c::'a]⟧ ⟹ thesis::bool) ⟹ thesis›*)
using collinearity[where a = d and b = c and c = e and d = a and e = f and de = af] (*‹⟦△ d c e; path af a f; [c;e;a]; [e;f;d]⟧ ⟹ ∃f∈af ∩ (THE ab. path ab d c). [d;f;c]›*) cea (*‹[c;e;a]›*) efd (*‹[e;f;d]›*) path_dc (*‹path dc d c›*) path_af (*‹path af a f›*) by blast
then have x_in_dc: "x ∈ dc"
using betw_b_in_path (*‹⟦[?a::'a;?b::'a;?c::'a]; path (?ac::'a set) ?a ?c⟧ ⟹ ?b ∈ ?ac›*) path_dc (*‹path dc d c›*) by blast
then have "x = b"
using eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) by (metis path_af (*‹path af a f›*) path_dc (*‹path dc d c›*) afb (*‹[a;f;b]›*) bcd (*‹[b;c;d]›*) tri_abc (*‹△ a b c›*) x_in_af (*‹x ∈ af›*) betw_a_in_path (*‹⟦[?a;?b;?c]; path ?bc ?b ?c⟧ ⟹ ?a ∈ ?bc›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) triangle_diff_paths (*‹△ ?a ?b ?c ⟹ ¬ (∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q)›*))
then have "[d;b;c]"
using dxc (*‹[d::'a;x::'a;c::'a]›*) by simp
then have False
using bcd (*‹[b;c;d]›*) abc_only_cba[where a = b and b = c and c = d] (*‹[b;c;d] ⟹ ¬ [c;b;d]› ‹[b;c;d] ⟹ ¬ [b;d;c]› ‹[b;c;d] ⟹ ¬ [c;d;b]› ‹[b;c;d] ⟹ ¬ [d;b;c]›*) by simp
thus "?thesis"
(*goal: ‹[d;e;f]›*)
by simp
next
(*goals:
1. ‹[f;d;e] ⟹ [d;e;f]›
2. ‹[d;e;f] ⟹ [d;e;f]›*)
assume fde: "[f;d;e]" (*‹[f::'a;d::'a;e::'a]›*)
obtain bd where path_bd: "path bd b d"
(*goal: ‹(⋀bd::'a set. path bd (b::'a) (d::'a) ⟹ thesis::bool) ⟹ thesis›*)
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) bcd (*‹[b;c;d]›*) by blast
obtain ea where path_ea: "path ea e a"
(*goal: ‹(⋀ea. path ea e a ⟹ thesis) ⟹ thesis›*)
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_ex_path_unique (*‹[?a::'a;?b::'a;?c::'a] ⟹ ∃!Q::'a set. Q ∈ (𝒫::'a set set) ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) cea (*‹[c;e;a]›*) by blast
obtain fe where path_fe: "path fe f e"
(*goal: ‹(⋀fe. path fe f e ⟹ thesis) ⟹ thesis›*)
using f_in_de (*‹f ∈ de›*) f_neq_d_e (*‹f ≠ d ∧ f ≠ e›*) path_de (*‹path de d e›*) by blast
have "fe≠ea"
using tri_abc (*‹△ a b c›*) afb (*‹[a;f;b]›*) cea (*‹[c::'a::type;e::'a::type;a::'a::type]›*) path_ea (*‹path ea e a›*) path_fe (*‹path fe f e›*) by (metis abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) betw_a_in_path (*‹⟦[?a;?b;?c]; path ?bc ?b ?c⟧ ⟹ ?a ∈ ?bc›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) triangle_paths_neq (*‹⟦△ ?a ?b ?c; path ?ab ?a ?b; path ?ac ?a ?c⟧ ⟹ ?ab ≠ ?ac›*))
hence "△ e a f"
by (metis path_unique (*‹⟦path ?ab ?a ?b; path ?ab' ?a ?b⟧ ⟹ ?ab = ?ab'›*) path_af (*‹path af a f›*) path_ea (*‹path ea e a›*) path_fe (*‹path fe f e›*) paths_tri2 (*‹⟦path ?ab ?a ?b; path ?bc ?b ?c; path ?ca ?c ?a; ?ab ≠ ?bc⟧ ⟹ △ ?a ?b ?c›*))
then obtain y where y_in_bd: "y ∈ bd" and eya: "[e;y;a]"
(*goal: ‹(⋀y. ⟦y ∈ bd; [e;y;a]⟧ ⟹ thesis) ⟹ thesis›*)
thm collinearity
using collinearity[where a = e and b = a and c = f and d = b and e = d and de = bd] (*‹⟦△ e a f; path bd b d; [a;f;b]; [f;d;e]⟧ ⟹ ∃f∈bd ∩ (THE ab. path ab e a). [e;f;a]›*) afb (*‹[a;f;b]›*) fde (*‹[f::'a;d::'a;e::'a]›*) path_bd (*‹path bd b d›*) path_ea (*‹path ea e a›*) by blast
then have "y = c"
by (metis (mono_tags, lifting) afb (*‹[a;f;b]›*) bcd (*‹[b;c;d]›*) cea (*‹[c;e;a]›*) path_bd (*‹path bd b d›*) tri_abc (*‹△ a b c›*) abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) path_unique (*‹⟦path ?ab ?a ?b; path ?ab' ?a ?b⟧ ⟹ ?ab = ?ab'›*) triangle_paths( (*‹△ ?a ?b ?c ⟹ ∃Q. path Q ?a ?c›*) 2) triangle_paths_neq (*‹⟦△ ?a ?b ?c; path ?ab ?a ?b; path ?ac ?a ?c⟧ ⟹ ?ab ≠ ?ac›*))
then have "[e;c;a]"
using eya (*‹[e::'a;y::'a;a::'a]›*) by simp
then have False
using cea (*‹[c;e;a]›*) abc_only_cba[where a = c and b = e and c = a] (*‹[c;e;a] ⟹ ¬ [e;c;a]› ‹[c;e;a] ⟹ ¬ [c;a;e]› ‹[c;e;a] ⟹ ¬ [e;a;c]› ‹[c;e;a] ⟹ ¬ [a;c;e]›*) by simp
thus "?thesis"
(*goal: ‹[d;e;f]›*)
by simp
next
(*goal: ‹[d;e;f] ⟹ [d;e;f]›*)
assume "[d;e;f]" (*‹[d::'a;e::'a;f::'a]›*)
thus "?thesis"
(*goal: ‹[d;e;f]›*)
by assumption
qed
qed
thus "?thesis"
(*goal: ‹∃f::'a. [a::'a;f;b::'a] ∧ [d::'a;e::'a;f]›*)
using afb (*‹[a;f;b]›*) f_in_de (*‹f ∈ de›*) by blast
qed
section "3.6 Order on a path - Theorems 8 and 9"
context MinkowskiSpacetime begin
subsection ‹Theorem 8 (as in Veblen (1911) Theorem 6)›
text ‹
Note ‹a'b'c'› don't necessarily form a triangle, as there still needs to be paths between them.
›
theorem (*8*) (in MinkowskiChain) tri_betw_no_path:
assumes tri_abc: "△ a b c"
and ab'c: "[a; b'; c]"
and bc'a: "[b; c'; a]"
and ca'b: "[c; a'; b]"
shows "¬ (∃Q∈𝒫. a' ∈ Q ∧ b' ∈ Q ∧ c' ∈ Q)"
proof (-)
(*goal: ‹¬ (∃Q::'a set∈𝒫::'a set set. (a'::'a) ∈ Q ∧ (b'::'a) ∈ Q ∧ (c'::'a) ∈ Q)›*)
have abc_a'b'c'_neq: "a ≠ a' ∧ a ≠ b' ∧ a ≠ c'
∧ b ≠ a' ∧ b ≠ b' ∧ b ≠ c'
∧ c ≠ a' ∧ c ≠ b' ∧ c ≠ c'"
using abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) by (metis ab'c (*‹[a;b';c]›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) bc'a (*‹[b;c';a]›*) ca'b (*‹[c;a';b]›*) tri_abc (*‹△ a b c›*) triangle_not_betw_abc (*‹△ ?a ?b ?c ⟹ ¬ [?a;?b;?c]›*) triangle_permutes( (*‹△ ?a ?b ?c ⟹ △ ?c ?a ?b›*) 4))
have tri_betw_no_path_single_case: False if a'b'c': "[a'; b'; c']" and tri_abc: "△ a b c" and ab'c: "[a; b'; c]" and bc'a: "[b; c'; a]" and ca'b: "[c; a'; b]" for a and b and c and a' and b' and c'
proof (-)
(*goal: ‹False›*)
have abc_a'b'c'_neq: "a ≠ a' ∧ a ≠ b' ∧ a ≠ c'
∧ b ≠ a' ∧ b ≠ b' ∧ b ≠ c'
∧ c ≠ a' ∧ c ≠ b' ∧ c ≠ c'"
using abc_abc_neq (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) that (*‹[a';b';c']› ‹△ a b c› ‹[a;b';c]› ‹[b::'a;c'::'a;a::'a]› ‹[c::'a;a'::'a;b::'a]›*) by (metis triangle_not_betw_abc (*‹△ ?a ?b ?c ⟹ ¬ [?a;?b;?c]›*) triangle_permutes( (*‹△ ?a ?b ?c ⟹ △ ?c ?a ?b›*) 4))
have c'b'a': "[c'; b'; a']"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) a'b'c' (*‹[a';b';c']›*) by simp
have nopath_a'c'b: "¬ (∃Q∈𝒫. a' ∈ Q ∧ c' ∈ Q ∧ b ∈ Q)"
proof (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹∃Q∈𝒫. a' ∈ Q ∧ c' ∈ Q ∧ b ∈ Q ⟹ False›*)
assume "∃Q∈𝒫. a' ∈ Q ∧ c' ∈ Q ∧ b ∈ Q" (*‹∃Q::'a set∈𝒫::'a set set. (a'::'a) ∈ Q ∧ (c'::'a) ∈ Q ∧ (b::'a) ∈ Q›*)
then obtain Q where path_Q: "Q ∈ 𝒫" and a'_inQ: "a' ∈ Q" and c'_inQ: "c' ∈ Q" and b_inQ: "b ∈ Q"
(*goal: ‹(⋀Q. ⟦Q ∈ 𝒫; a' ∈ Q; c' ∈ Q; b ∈ Q⟧ ⟹ thesis) ⟹ thesis›*)
by blast
then have ac_inQ: "a ∈ Q ∧ c ∈ Q"
using eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) by (metis abc_a'b'c'_neq (*‹a ≠ a' ∧ a ≠ b' ∧ a ≠ c' ∧ b ≠ a' ∧ b ≠ b' ∧ b ≠ c' ∧ c ≠ a' ∧ c ≠ b' ∧ c ≠ c'›*) ca'b (*‹[c;a';b]›*) bc'a (*‹[b;c';a]›*) betw_a_in_path (*‹⟦[?a;?b;?c]; path ?bc ?b ?c⟧ ⟹ ?a ∈ ?bc›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*))
thus False
using b_inQ (*‹(b::'a) ∈ (Q::'a set)›*) path_Q (*‹(Q::'a::type set) ∈ (𝒫::'a::type set set)›*) tri_abc (*‹△ a b c›*) triangle_diff_paths (*‹△ ?a ?b ?c ⟹ ¬ (∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q)›*) by blast
qed
then have tri_a'bc': "△ a' b c'"
by (smt bc'a (*‹[b;c';a]›*) ca'b (*‹[c;a';b]›*) a'b'c' (*‹[a';b';c']›*) paths_tri (*‹⟦path ?ab ?a ?b; path ?bc ?b ?c; path ?ca ?c ?a; ?a ∉ ?bc⟧ ⟹ △ ?a ?b ?c›*) abc_ex_path_unique (*‹[?a;?b;?c] ⟹ ∃!Q. Q ∈ 𝒫 ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*))
obtain ab' where path_ab': "path ab' a b'"
(*goal: ‹(⋀ab'. path ab' a b' ⟹ thesis) ⟹ thesis›*)
using ab'c (*‹[a;b';c]›*) abc_a'b'c'_neq (*‹a ≠ a' ∧ a ≠ b' ∧ a ≠ c' ∧ b ≠ a' ∧ b ≠ b' ∧ b ≠ c' ∧ c ≠ a' ∧ c ≠ b' ∧ c ≠ c'›*) abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) by blast
obtain a'b where path_a'b: "path a'b a' b"
(*goal: ‹(⋀a'b. path a'b a' b ⟹ thesis) ⟹ thesis›*)
using tri_a'bc' (*‹△ a' b c'›*) triangle_paths(1) (*‹△ ?a ?b ?c ⟹ ∃Q. path Q ?a ?b›*) by blast
then have "∃x∈a'b. [a'; x; b] ∧ [a; b'; x]"
using collinearity2[where a = a' and b = b and c = c' and e = b' and d = a and de = ab'] (*‹⟦△ a' b c'; [b;c';a]; [c';b';a']; path ab' a b'⟧ ⟹ ∃f. [a';f;b] ∧ [a;b';f]›*) bc'a (*‹[b::'a;c'::'a;a::'a]›*) betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) c'b'a' (*‹[c'::'a;b'::'a;a'::'a]›*) path_ab' (*‹path ab' a b'›*) tri_a'bc' (*‹△ a' b c'›*) by blast
then obtain x where x_in_a'b: "x ∈ a'b" and a'xb: "[a'; x; b]" and ab'x: "[a; b'; x]"
(*goal: ‹(⋀x. ⟦x ∈ a'b; [a';x;b]; [a;b';x]⟧ ⟹ thesis) ⟹ thesis›*)
by blast
have c_in_ab': "c ∈ ab'"
using ab'c (*‹[a::'a;b'::'a;c::'a]›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) path_ab' (*‹path ab' a b'›*) by auto
have c_in_a'b: "c ∈ a'b"
using ca'b (*‹[c;a';b]›*) betw_a_in_path (*‹⟦[?a;?b;?c]; path ?bc ?b ?c⟧ ⟹ ?a ∈ ?bc›*) path_a'b (*‹path a'b a' b›*) by auto
have ab'_a'b_distinct: "ab' ≠ a'b"
using c_in_a'b (*‹c ∈ a'b›*) path_a'b (*‹path (a'b::'a set) (a'::'a) (b::'a)›*) path_ab' (*‹path ab' a b'›*) tri_abc (*‹△ a b c›*) triangle_diff_paths (*‹△ ?a ?b ?c ⟹ ¬ (∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q)›*) by blast
have "ab' ∩ a'b = {c}"
using paths_cross_at (*‹⟦(?Q::'a::type set) ∈ (𝒫::'a::type set set); (?R::'a::type set) ∈ 𝒫; ?Q ≠ ?R; ?Q ∩ ?R ≠ {}; (?x::'a::type) ∈ ?Q; ?x ∈ ?R⟧ ⟹ ?Q ∩ ?R = {?x}›*) ab'_a'b_distinct (*‹ab' ≠ a'b›*) c_in_a'b (*‹c ∈ a'b›*) c_in_ab' (*‹c ∈ ab'›*) path_a'b (*‹path a'b a' b›*) path_ab' (*‹path ab' a b'›*) by auto
then have "x = c"
using ab'x (*‹[a;b';x]›*) path_ab' (*‹path ab' a b'›*) x_in_a'b (*‹x ∈ a'b›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) by auto
then have "[a'; c; b]"
using a'xb (*‹[a';x;b]›*) by auto
thus "?thesis"
(*goal: ‹False›*)
using ca'b (*‹[c;a';b]›*) abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?c;?a;?b]›*) by blast
qed
show "?thesis"
(*goal: ‹¬ (∃Q∈𝒫. a' ∈ Q ∧ b' ∈ Q ∧ c' ∈ Q)›*)
proof (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹∃Q∈𝒫. a' ∈ Q ∧ b' ∈ Q ∧ c' ∈ Q ⟹ False›*)
assume path_a'b'c': "∃Q∈𝒫. a' ∈ Q ∧ b' ∈ Q ∧ c' ∈ Q" (*‹∃Q::'a set∈𝒫::'a set set. (a'::'a) ∈ Q ∧ (b'::'a) ∈ Q ∧ (c'::'a) ∈ Q›*)
consider "[a'; b'; c']" | "[b'; c'; a']" | "[c'; a'; b']"
(*goal: ‹⟦[a';b';c'] ⟹ thesis; [b';c';a'] ⟹ thesis; [c';a';b'] ⟹ thesis⟧ ⟹ thesis›*)
using some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) by (smt abc_a'b'c'_neq (*‹a ≠ a' ∧ a ≠ b' ∧ a ≠ c' ∧ b ≠ a' ∧ b ≠ b' ∧ b ≠ c' ∧ c ≠ a' ∧ c ≠ b' ∧ c ≠ c'›*) path_a'b'c' (*‹∃Q∈𝒫. a' ∈ Q ∧ b' ∈ Q ∧ c' ∈ Q›*) bc'a (*‹[b;c';a]›*) ca'b (*‹[c;a';b]›*) ab'c (*‹[a;b';c]›*) tri_abc (*‹△ a b c›*) abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) cross_once_notin (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*) triangle_diff_paths (*‹△ ?a ?b ?c ⟹ ¬ (∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q)›*))
thus False
apply cases
(*goal: ‹False›*)
using tri_betw_no_path_single_case[of a' b' c'] (*‹⟦[a';b';c']; △ ?a ?b ?c; [?a;b';?c]; [?b;c';?a]; [?c;a';?b]⟧ ⟹ False›*) ab'c (*‹[a;b';c]›*) bc'a (*‹[b::'a;c'::'a;a::'a]›*) ca'b (*‹[c;a';b]›*) tri_abc (*‹△ a b c›*) apply blast
(*top goal: ‹[a'::'a::type;b'::'a::type;c'::'a::type] ⟹ False› and 2 goals remain*)
using tri_betw_no_path_single_case (*‹⟦[?a'::'a;?b'::'a;?c'::'a]; △ (?a::'a) (?b::'a) (?c::'a); [?a;?b';?c]; [?b;?c';?a]; [?c;?a';?b]⟧ ⟹ False›*) ab'c (*‹[a;b';c]›*) bc'a (*‹[b::'a;c'::'a;a::'a]›*) ca'b (*‹[c;a';b]›*) tri_abc (*‹△ a b c›*) triangle_permutes (*‹△ ?a ?b ?c ⟹ △ ?a ?c ?b› ‹△ ?a ?b ?c ⟹ △ ?b ?a ?c› ‹△ (?a::'a::type) (?b::'a::type) (?c::'a::type) ⟹ △ ?b ?c ?a› ‹△ ?a ?b ?c ⟹ △ ?c ?a ?b› ‹△ ?a ?b ?c ⟹ △ ?c ?b ?a›*) abc_sym (*‹[?a::'a;?b::'a;?c::'a] ⟹ [?c;?b;?a]›*) apply -
(*goals:
1. ‹⟦[b';c';a']; ⋀a' b' c' a b c. ⟦[a';b';c']; △ a b c; [a;b';c]; [b;c';a]; [c;a';b]⟧ ⟹ False; [a;b';c]; [b;c';a]; [c;a';b]; △ a b c; ⋀a b c. △ a b c ⟹ △ a c b; ⋀a b c. △ a b c ⟹ △ b a c; ⋀a b c. △ a b c ⟹ △ b c a; ⋀a b c. △ a b c ⟹ △ c a b; ⋀a b c. △ a b c ⟹ △ c b a; ⋀a b c. [a;b;c] ⟹ [c;b;a]⟧ ⟹ False›
2. ‹⟦[c';a';b']; ⋀a' b' c' a b c. ⟦[a';b';c']; △ a b c; [a;b';c]; [b;c';a]; [c;a';b]⟧ ⟹ False; [a;b';c]; [b;c';a]; [c;a';b]; △ a b c; ⋀a b c. △ a b c ⟹ △ a c b; ⋀a b c. △ a b c ⟹ △ b a c; ⋀a b c. △ a b c ⟹ △ b c a; ⋀a b c. △ a b c ⟹ △ c a b; ⋀a b c. △ a b c ⟹ △ c b a; ⋀a b c. [a;b;c] ⟹ [c;b;a]⟧ ⟹ False›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
qed
qed
subsection ‹Theorem 9›
text ‹
We now begin working on the transitivity lemmas needed to prove Theorem 9.
Multiple lemmas below obtain primed variables (e.g. ‹d'›). These are starred in Schutz (e.g. ‹d*›),
but that notation is already reserved in Isabelle.
›
lemma unreachable_bounded_path_only:
assumes d'_def: "d'∉ unreach-on ab from e" "d'∈ab" "d'≠e"
and e_event: "e ∈ ℰ"
and path_ab: "ab ∈ 𝒫"
and e_notin_S: "e ∉ ab"
shows "∃d'e. path d'e d' e"
proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*))
(*goal: ‹∄d'e. path d'e d' e ⟹ False›*)
assume "¬(∃d'e. path d'e d' e)" (*‹∄d'e::'a set. path d'e (d'::'a) (e::'a)›*)
hence "¬(∃R∈𝒫. d'∈R ∧ e∈R ∧ d'≠e)"
by blast
hence "¬(∃R∈𝒫. e∈R ∧ d'∈R)"
using d'_def(3) (*‹(d'::'a::type) ≠ (e::'a::type)›*) by blast
moreover have "ab∈𝒫 ∧ e∈ℰ ∧ e∉ab"
by (simp add: e_event (*‹e ∈ ℰ›*) e_notin_S (*‹e ∉ ab›*) path_ab (*‹ab ∈ 𝒫›*))
ultimately have "d'∈ unreach-on ab from e"
unfolding unreachable_subset_def
(*goal: ‹d' ∈ {x ∈ ab. ab ∈ 𝒫 ∧ e ∈ ℰ ∧ e ∉ ab ∧ (∄Q. path Q e x)}›*)
using d'_def(2) (*‹d' ∈ ab›*) by blast
thus False
using d'_def(1) (*‹d' ∉ unreach-on ab from e›*) by auto
qed
lemma unreachable_bounded_path:
assumes S_neq_ab: "S ≠ ab"
and a_inS: "a ∈ S"
and e_inS: "e ∈ S"
and e_neq_a: "e ≠ a"
and path_S: "S ∈ 𝒫"
and path_ab: "path ab a b"
and path_be: "path be b e"
and no_de: "¬(∃de. path de d e)"
and abd:"[a;b;d]"
obtains d' d'e where "d'∈ab ∧ path d'e d' e ∧ [b; d; d']"
proof (-)
(*goal: ‹(⋀d' d'e. d' ∈ ab ∧ path d'e d' e ∧ [b;d;d'] ⟹ thesis) ⟹ thesis›*)
have e_event: "e∈ℰ"
using e_inS (*‹(e::'a::type) ∈ (S::'a::type set)›*) path_S (*‹(S::'a set) ∈ (𝒫::'a set set)›*) by auto
have "e∉ab"
using S_neq_ab (*‹S ≠ ab›*) a_inS (*‹(a::'a) ∈ (S::'a set)›*) e_inS (*‹e ∈ S›*) e_neq_a (*‹e ≠ a›*) eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) path_S (*‹S ∈ 𝒫›*) path_ab (*‹path ab a b›*) by auto
have "ab∈𝒫 ∧ e∉ab"
using S_neq_ab (*‹S ≠ ab›*) a_inS (*‹a ∈ S›*) e_inS (*‹e ∈ S›*) e_neq_a (*‹e ≠ a›*) eq_paths (*‹⟦(?P::'a set) ∈ (𝒫::'a set set); (?Q::'a set) ∈ 𝒫; (?a::'a) ∈ ?P; (?b::'a) ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) path_S (*‹S ∈ 𝒫›*) path_ab (*‹path ab a b›*) by auto
have "b ∈ ab - unreach-on ab from e"
using cross_in_reachable (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R⟧ ⟹ ?b ∈ ?R - unreach-on ?R from ?a›*) path_ab (*‹path ab a b›*) path_be (*‹path (be::'a set) (b::'a) (e::'a)›*) by blast
have "d ∈ unreach-on ab from e"
using no_de (*‹∄de. path de d e›*) abd (*‹[a;b;d]›*) path_ab (*‹path ab a b›*) e_event (*‹e ∈ ℰ›*) ‹e∉ab› (*‹e ∉ ab›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) unreachable_bounded_path_only (*‹⟦?d' ∉ unreach-on ?ab from ?e; ?d' ∈ ?ab; ?d' ≠ ?e; ?e ∈ ℰ; ?ab ∈ 𝒫; ?e ∉ ?ab⟧ ⟹ ∃d'e. path d'e ?d' ?e›*) by blast
have "∃d' d'e. d'∈ab ∧ path d'e d' e ∧ [b; d; d']"
proof (-)
(*goal: ‹∃d' d'e. d' ∈ ab ∧ path d'e d' e ∧ [b;d;d']›*)
obtain d' where "[b; d; d']" "d'∈ab" "d'∉ unreach-on ab from e" "b≠d'" "e≠d'"
(*goal: ‹(⋀d'::'a::type. ⟦[b::'a::type;d::'a::type;d']; d' ∈ (ab::'a::type set); d' ∉ unreach-on ab from (e::'a::type); b ≠ d'; e ≠ d'⟧ ⟹ thesis::bool) ⟹ thesis›*)
using unreachable_set_bounded (*‹⟦?Q ∈ 𝒫; ?b ∉ ?Q; ?b ∈ ℰ; ?Qx ∈ ?Q - unreach-on ?Q from ?b; ?Qy ∈ unreach-on ?Q from ?b⟧ ⟹ ∃Qz∈?Q - unreach-on ?Q from ?b. [?Qx;?Qy;Qz] ∧ ?Qx ≠ Qz›*) ‹b ∈ ab - unreach-on ab from e› (*‹(b::'a) ∈ (ab::'a set) - unreach-on ab from (e::'a)›*) ‹d ∈ unreach-on ab from e› (*‹d ∈ unreach-on ab from e›*) e_event (*‹e ∈ ℰ›*) ‹e∉ab› (*‹e ∉ ab›*) path_ab (*‹path ab a b›*) by (metis DiffE (*‹⟦?c ∈ ?A - ?B; ⟦?c ∈ ?A; ?c ∉ ?B⟧ ⟹ ?P⟧ ⟹ ?P›*))
then obtain d'e where "path d'e d' e"
(*goal: ‹(⋀d'e. path d'e d' e ⟹ thesis) ⟹ thesis›*)
using unreachable_bounded_path_only (*‹⟦?d' ∉ unreach-on ?ab from ?e; ?d' ∈ ?ab; ?d' ≠ ?e; ?e ∈ ℰ; ?ab ∈ 𝒫; ?e ∉ ?ab⟧ ⟹ ∃d'e. path d'e ?d' ?e›*) e_event (*‹e ∈ ℰ›*) ‹e∉ab› (*‹e ∉ ab›*) path_ab (*‹path ab a b›*) by blast
thus "?thesis"
(*goal: ‹∃d' d'e. d' ∈ ab ∧ path d'e d' e ∧ [b;d;d']›*)
using ‹[b; d; d']› (*‹[b;d;d']›*) ‹d' ∈ ab› (*‹d' ∈ ab›*) by blast
qed
thus "?thesis"
(*goal: ‹thesis›*)
using that (*‹?d' ∈ ab ∧ path ?d'e ?d' e ∧ [b;d;?d'] ⟹ thesis›*) by blast
qed
text ‹
This lemma collects the first three paragraphs of Schutz' proof of Theorem 9 - Lemma 1.
Several case splits need to be considered, but have no further importance outside of this lemma:
thus we parcel them away from the main proof.›
lemma exist_c'd'_alt:
assumes abc: "[a;b;c]"
and abd: "[a;b;d]"
and dbc: "[d;b;c]" (* the assumption that makes this False for ccontr! *)
and c_neq_d: "c ≠ d"
and path_ab: "path ab a b"
and path_S: "S ∈ 𝒫"
and a_inS: "a ∈ S"
and e_inS: "e ∈ S"
and e_neq_a: "e ≠ a"
and S_neq_ab: "S ≠ ab"
and path_be: "path be b e"
shows "∃c' d'. ∃d'e c'e. c'∈ab ∧ d'∈ab
∧ [a; b; d'] ∧ [c'; b; a] ∧ [c'; b; d']
∧ path d'e d' e ∧ path c'e c' e"
proof (cases)
(*goals:
1. ‹?P ⟹ ∃c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›
2. ‹¬ ?P ⟹ ∃c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*)
assume "∃de. path de d e" (*‹∃de::'a set. path de (d::'a) (e::'a)›*)
then obtain de where "path de d e"
(*goal: ‹(⋀de. path de d e ⟹ thesis) ⟹ thesis›*)
by blast
hence "[a;b;d] ∧ d∈ab"
using abd (*‹[a::'a::type;b::'a::type;d::'a::type]›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) path_ab (*‹path ab a b›*) by blast
thus "?thesis"
(*goal: ‹∃c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*)
proof (cases)
(*goals:
1. ‹⟦[a;b;d] ∧ d ∈ ab; ?P1⟧ ⟹ ∃c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›
2. ‹⟦[a;b;d] ∧ d ∈ ab; ¬ ?P1⟧ ⟹ ∃c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*)
assume "∃ce. path ce c e" (*‹∃ce::'a set. path ce (c::'a) (e::'a)›*)
then obtain ce where "path ce c e"
(*goal: ‹(⋀ce. path ce c e ⟹ thesis) ⟹ thesis›*)
by blast
have "c ∈ ab"
using abc (*‹[a;b;c]›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) path_ab (*‹path ab a b›*) by blast
thus "?thesis"
(*goal: ‹∃(c'::'a) (d'::'a) (d'e::'a set) c'e::'a set. c' ∈ (ab::'a set) ∧ d' ∈ ab ∧ [a::'a;b::'a;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' (e::'a) ∧ path c'e c' e›*)
using ‹[a;b;d] ∧ d ∈ ab› (*‹[a::'a;b::'a;d::'a] ∧ d ∈ (ab::'a set)›*) ‹∃ce. path ce c e› (*‹∃ce::'a set. path ce (c::'a) (e::'a)›*) ‹c ∈ ab› (*‹c ∈ ab›*) ‹path de d e› (*‹path (de::'a set) (d::'a) (e::'a)›*) abc (*‹[a::'a::type;b::'a::type;c::'a::type]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) dbc (*‹[d::'a;b::'a;c::'a]›*) by blast
next
(*goal: ‹⟦[a;b;d] ∧ d ∈ ab; ∄ce. path ce c e⟧ ⟹ ∃c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*)
assume "¬(∃ce. path ce c e)" (*‹∄ce::'a set. path ce (c::'a) (e::'a)›*)
obtain c' and c'e where "c'∈ab ∧ path c'e c' e ∧ [b; c; c']"
(*goal: ‹(⋀c' c'e. c' ∈ ab ∧ path c'e c' e ∧ [b;c;c'] ⟹ thesis) ⟹ thesis›*)
using unreachable_bounded_path[where ab = ab and e = e and b = b and d = c and a = a and S = S and be = be] (*‹⟦(S::'a set) ≠ (ab::'a set); (a::'a) ∈ S; (e::'a) ∈ S; e ≠ a; S ∈ (𝒫::'a set set); path ab a (b::'a); path (be::'a set) b e; ∄de::'a set. path de (c::'a) e; [a;b;c]; ⋀(d'::'a) d'e::'a set. d' ∈ ab ∧ path d'e d' e ∧ [b;c;d'] ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) S_neq_ab (*‹(S::'a set) ≠ (ab::'a set)›*) ‹¬(∃ce. path ce c e)› (*‹∄ce::'a::type set. path ce (c::'a::type) (e::'a::type)›*) a_inS (*‹a ∈ S›*) abc (*‹[a;b;c]›*) e_inS (*‹e ∈ S›*) e_neq_a (*‹e ≠ a›*) path_S (*‹(S::'a set) ∈ (𝒫::'a set set)›*) path_ab (*‹path ab a b›*) path_be (*‹path be b e›*) by (metis (mono_tags, lifting))
hence "[a; b; c'] ∧ [d; b; c']"
using abc (*‹[a::'a;b::'a;c::'a]›*) dbc (*‹[d;b;c]›*) by blast
hence "[c'; b; a] ∧ [c'; b; d]"
using theorem1 (*‹[?a;?b;?c] ⟹ [?c;?b;?a] ∧ ¬ [?b;?c;?a] ∧ ¬ [?c;?a;?b]›*) by blast
thus "?thesis"
(*goal: ‹∃c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*)
using ‹[a;b;d] ∧ d ∈ ab› (*‹[a::'a;b::'a;d::'a] ∧ d ∈ (ab::'a set)›*) ‹c' ∈ ab ∧ path c'e c' e ∧ [b; c; c']› (*‹(c'::'a) ∈ (ab::'a set) ∧ path (c'e::'a set) c' (e::'a) ∧ [b::'a;c::'a;c']›*) ‹path de d e› (*‹path de d e›*) by blast
qed
next
(*goal: ‹∄de. path de d e ⟹ ∃c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*)
assume "¬ (∃de. path de d e)" (*‹∄de::'a set. path de (d::'a) (e::'a)›*)
obtain d' and d'e where d'_in_ab: "d' ∈ ab" and bdd': "[b; d; d']" and "path d'e d' e"
(*goal: ‹(⋀d' d'e. ⟦d' ∈ ab; [b;d;d']; path d'e d' e⟧ ⟹ thesis) ⟹ thesis›*)
using unreachable_bounded_path[where ab = ab and e = e and b = b and d = d and a = a and S = S and be = be] (*‹⟦S ≠ ab; a ∈ S; e ∈ S; e ≠ a; S ∈ 𝒫; path ab a b; path be b e; ∄de. path de d e; [a;b;d]; ⋀d' d'e. d' ∈ ab ∧ path d'e d' e ∧ [b;d;d'] ⟹ ?thesis⟧ ⟹ ?thesis›*) S_neq_ab (*‹S ≠ ab›*) ‹∄de. path de d e› (*‹∄de. path de d e›*) a_inS (*‹a ∈ S›*) abd (*‹[a;b;d]›*) e_inS (*‹e ∈ S›*) e_neq_a (*‹e ≠ a›*) path_S (*‹(S::'a set) ∈ (𝒫::'a set set)›*) path_ab (*‹path ab a b›*) path_be (*‹path be b e›*) by (metis (mono_tags, lifting))
hence "[a; b; d']"
using abd (*‹[a;b;d]›*) by blast
thus "?thesis"
(*goal: ‹∃c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*)
proof (cases)
(*goals:
1. ‹⟦[a;b;d']; ?P1⟧ ⟹ ∃c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›
2. ‹⟦[a;b;d']; ¬ ?P1⟧ ⟹ ∃c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*)
assume "∃ce. path ce c e" (*‹∃ce::'a set. path ce (c::'a) (e::'a)›*)
then obtain ce where "path ce c e"
(*goal: ‹(⋀ce. path ce c e ⟹ thesis) ⟹ thesis›*)
by blast
have "c ∈ ab"
using abc (*‹[a::'a;b::'a;c::'a]›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) path_ab (*‹path ab a b›*) by blast
thus "?thesis"
(*goal: ‹∃c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*)
using ‹[a; b; d']› (*‹[a;b;d']›*) ‹d' ∈ ab› (*‹d' ∈ ab›*) ‹path ce c e› (*‹path ce c e›*) ‹c ∈ ab› (*‹(c::'a::type) ∈ (ab::'a::type set)›*) ‹path d'e d' e› (*‹path d'e d' e›*) abc (*‹[a::'a;b::'a;c::'a]›*) abc_sym (*‹[?a::'a;?b::'a;?c::'a] ⟹ [?c;?b;?a]›*) dbc (*‹[d;b;c]›*) by (meson abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) bdd' (*‹[b;d;d']›*))
next
(*goal: ‹⟦[a;b;d']; ∄ce. path ce c e⟧ ⟹ ∃c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*)
assume "¬(∃ce. path ce c e)" (*‹∄ce::'a set. path ce (c::'a) (e::'a)›*)
obtain c' and c'e where "c'∈ab ∧ path c'e c' e ∧ [b; c; c']"
(*goal: ‹(⋀c' c'e. c' ∈ ab ∧ path c'e c' e ∧ [b;c;c'] ⟹ thesis) ⟹ thesis›*)
using unreachable_bounded_path[where ab = ab and e = e and b = b and d = c and a = a and S = S and be = be] (*‹⟦S ≠ ab; a ∈ S; e ∈ S; e ≠ a; S ∈ 𝒫; path ab a b; path be b e; ∄de. path de c e; [a;b;c]; ⋀d' d'e. d' ∈ ab ∧ path d'e d' e ∧ [b;c;d'] ⟹ ?thesis⟧ ⟹ ?thesis›*) S_neq_ab (*‹S ≠ ab›*) ‹¬(∃ce. path ce c e)› (*‹∄ce. path ce c e›*) a_inS (*‹a ∈ S›*) abc (*‹[a;b;c]›*) e_inS (*‹e ∈ S›*) e_neq_a (*‹e ≠ a›*) path_S (*‹S ∈ 𝒫›*) path_ab (*‹path (ab::'a::type set) (a::'a::type) (b::'a::type)›*) path_be (*‹path be b e›*) by (metis (mono_tags, lifting))
hence "[a; b; c'] ∧ [d; b; c']"
using abc (*‹[a;b;c]›*) dbc (*‹[d::'a;b::'a;c::'a]›*) by blast
hence "[c'; b; a] ∧ [c'; b; d]"
using theorem1 (*‹[?a;?b;?c] ⟹ [?c;?b;?a] ∧ ¬ [?b;?c;?a] ∧ ¬ [?c;?a;?b]›*) by blast
thus "?thesis"
(*goal: ‹∃c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*)
using ‹[a; b; d']› (*‹[a;b;d']›*) ‹c' ∈ ab ∧ path c'e c' e ∧ [b; c; c']› (*‹c' ∈ ab ∧ path c'e c' e ∧ [b;c;c']›*) ‹path d'e d' e› (*‹path d'e d' e›*) bdd' (*‹[b::'a;d::'a;d'::'a]›*) d'_in_ab (*‹d' ∈ ab›*) by blast
qed
qed
lemma exist_c'd':
assumes abc: "[a;b;c]"
and abd: "[a;b;d]"
and dbc: "[d;b;c]" (* the assumption that makes this False for ccontr! *)
and path_S: "path S a e"
and path_be: "path be b e"
and S_neq_ab: "S ≠ path_of a b"
shows "∃c' d'. [a; b; d'] ∧ [c'; b; a] ∧ [c'; b; d'] ∧
path_ex d' e ∧ path_ex c' e"
proof (cases "path_ex d e")
(*goals:
1. ‹∃Q. path Q d e ⟹ ∃c' d'. [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q. path Q d' e) ∧ (∃Q. path Q c' e)›
2. ‹∄Q. path Q d e ⟹ ∃c' d'. [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q. path Q d' e) ∧ (∃Q. path Q c' e)›*)
let ?ab = "path_of a b"
have "path_ex a b"
using abc (*‹[a;b;c]›*) abc_abc_neq (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) by blast
hence path_ab: "path ?ab a b"
using path_of_ex (*‹path (THE ab. path ab ?a ?b) ?a ?b = (∃Q. path Q ?a ?b)›*) by simp
have "c≠d"
using abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) dbc (*‹[d::'a::type;b::'a::type;c::'a::type]›*) by blast
{
case True (*‹∃Q. path Q d e›*)
then obtain de where "path de d e"
(*goal: ‹(⋀de. path de d e ⟹ thesis) ⟹ thesis›*)
by blast
hence "[a;b;d] ∧ d∈?ab"
using abd (*‹[a;b;d]›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) path_ab (*‹path (THE ab::'a set. path ab (a::'a) (b::'a)) a b›*) by blast
thus "?thesis"
(*goal: ‹∃c' d'. [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q. path Q d' e) ∧ (∃Q. path Q c' e)›*)
proof (cases "path_ex c e")
(*goals:
1. ‹⟦[a;b;d] ∧ d ∈ (THE ab. path ab a b); ∃Q. path Q c e⟧ ⟹ ∃c' d'. [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q. path Q d' e) ∧ (∃Q. path Q c' e)›
2. ‹⟦[a;b;d] ∧ d ∈ (THE ab. path ab a b); ∄Q. path Q c e⟧ ⟹ ∃c' d'. [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q. path Q d' e) ∧ (∃Q. path Q c' e)›*)
case True (*‹∃Q::'a set. path Q (c::'a) (e::'a)›*)
then obtain ce where "path ce c e"
(*goal: ‹(⋀ce. path ce c e ⟹ thesis) ⟹ thesis›*)
by blast
have "c ∈ ?ab"
using abc (*‹[a;b;c]›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) path_ab (*‹path (THE ab. path ab a b) a b›*) by blast
thus "?thesis"
(*goal: ‹∃c' d'. [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q. path Q d' e) ∧ (∃Q. path Q c' e)›*)
using ‹[a;b;d] ∧ d ∈ ?ab› (*‹[a::'a;b::'a;d::'a] ∧ d ∈ (THE ab::'a set. path ab a b)›*) ‹∃ce. path ce c e› (*‹∃ce. path ce c e›*) ‹c ∈ ?ab› (*‹c ∈ (THE ab. path ab a b)›*) ‹path de d e› (*‹path de d e›*) abc (*‹[a;b;c]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) dbc (*‹[d;b;c]›*) by blast
next
(*goal: ‹⟦[a::'a;b::'a;d::'a] ∧ d ∈ (THE ab::'a set. path ab a b); ∄Q::'a set. path Q (c::'a) (e::'a)⟧ ⟹ ∃(c'::'a) d'::'a. [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q::'a set. path Q d' e) ∧ (∃Q::'a set. path Q c' e)›*)
case False (*‹∄Q::'a::type set. path Q (c::'a::type) (e::'a::type)›*)
obtain c' and c'e where "c'∈?ab ∧ path c'e c' e ∧ [b; c; c']"
(*goal: ‹(⋀c' c'e. c' ∈ (THE ab. path ab a b) ∧ path c'e c' e ∧ [b;c;c'] ⟹ thesis) ⟹ thesis›*)
using unreachable_bounded_path[where ab = "?ab" and e = e and b = b and d = c and a = a and S = S and be = be] (*‹⟦S ≠ (THE ab. path ab a b); a ∈ S; e ∈ S; e ≠ a; S ∈ 𝒫; path (THE ab. path ab a b) a b; path be b e; ∄de. path de c e; [a;b;c]; ⋀d' d'e. d' ∈ (THE ab. path ab a b) ∧ path d'e d' e ∧ [b;c;d'] ⟹ ?thesis⟧ ⟹ ?thesis›*) S_neq_ab (*‹S ≠ (THE ab. path ab a b)›*) ‹¬(∃ce. path ce c e)› (*‹∄ce. path ce c e›*) abc (*‹[a;b;c]›*) path_S (*‹path S a e›*) path_ab (*‹path (THE ab. path ab a b) a b›*) path_be (*‹path be b e›*) by (metis (mono_tags, lifting))
hence "[a; b; c'] ∧ [d; b; c']"
using abc (*‹[a;b;c]›*) dbc (*‹[d;b;c]›*) by blast
hence "[c'; b; a] ∧ [c'; b; d]"
using theorem1 (*‹[?a;?b;?c] ⟹ [?c;?b;?a] ∧ ¬ [?b;?c;?a] ∧ ¬ [?c;?a;?b]›*) by blast
thus "?thesis"
(*goal: ‹∃c' d'. [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q. path Q d' e) ∧ (∃Q. path Q c' e)›*)
using ‹[a;b;d] ∧ d ∈ ?ab› (*‹[a::'a;b::'a;d::'a] ∧ d ∈ (THE ab::'a set. path ab a b)›*) ‹c' ∈ ?ab ∧ path c'e c' e ∧ [b; c; c']› (*‹c' ∈ (THE ab. path ab a b) ∧ path c'e c' e ∧ [b;c;c']›*) ‹path de d e› (*‹path de d e›*) by blast
qed
}
{
case False (*‹∄Q::'a set. path Q (d::'a) (e::'a)›*)
obtain d' and d'e where d'_in_ab: "d' ∈ ?ab" and bdd': "[b; d; d']" and "path d'e d' e"
(*goal: ‹(⋀(d'::'a) d'e::'a set. ⟦d' ∈ (THE ab::'a set. path ab (a::'a) (b::'a)); [b;d::'a;d']; path d'e d' (e::'a)⟧ ⟹ thesis::bool) ⟹ thesis›*)
using unreachable_bounded_path[where ab = "?ab" and e = e and b = b and d = d and a = a and S = S and be = be] (*‹⟦S ≠ (THE ab. path ab a b); a ∈ S; e ∈ S; e ≠ a; S ∈ 𝒫; path (THE ab. path ab a b) a b; path be b e; ∄de. path de d e; [a;b;d]; ⋀d' d'e. d' ∈ (THE ab. path ab a b) ∧ path d'e d' e ∧ [b;d;d'] ⟹ ?thesis⟧ ⟹ ?thesis›*) S_neq_ab (*‹S ≠ (THE ab. path ab a b)›*) ‹¬path_ex d e› (*‹∄Q::'a set. path Q (d::'a) (e::'a)›*) abd (*‹[a;b;d]›*) path_S (*‹path (S::'a set) (a::'a) (e::'a)›*) path_ab (*‹path (THE ab. path ab a b) a b›*) path_be (*‹path be b e›*) by (metis (mono_tags, lifting))
hence "[a; b; d']"
using abd (*‹[a;b;d]›*) by blast
thus "?thesis"
(*goal: ‹∃(c'::'a) d'::'a. [a::'a;b::'a;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q::'a set. path Q d' (e::'a)) ∧ (∃Q::'a set. path Q c' e)›*)
proof (cases "path_ex c e")
(*goals:
1. ‹⟦[a::'a::type;b::'a::type;d'::'a::type]; ∃Q::'a::type set. path Q (c::'a::type) (e::'a::type)⟧ ⟹ ∃(c'::'a::type) d'::'a::type. [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q::'a::type set. path Q d' e) ∧ (∃Q::'a::type set. path Q c' e)›
2. ‹⟦[a::'a::type;b::'a::type;d'::'a::type]; ∄Q::'a::type set. path Q (c::'a::type) (e::'a::type)⟧ ⟹ ∃(c'::'a::type) d'::'a::type. [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q::'a::type set. path Q d' e) ∧ (∃Q::'a::type set. path Q c' e)›*)
case True (*‹∃Q. path Q c e›*)
then obtain ce where "path ce c e"
(*goal: ‹(⋀ce. path ce c e ⟹ thesis) ⟹ thesis›*)
by blast
have "c ∈ ?ab"
using abc (*‹[a;b;c]›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) path_ab (*‹path (THE ab. path ab a b) a b›*) by blast
thus "?thesis"
(*goal: ‹∃(c'::'a) d'::'a. [a::'a;b::'a;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q::'a set. path Q d' (e::'a)) ∧ (∃Q::'a set. path Q c' e)›*)
using ‹[a; b; d']› (*‹[a;b;d']›*) ‹d' ∈ ?ab› (*‹(d'::'a::type) ∈ (THE ab::'a::type set. path ab (a::'a::type) (b::'a::type))›*) ‹path ce c e› (*‹path ce c e›*) ‹c ∈ ?ab› (*‹c ∈ (THE ab. path ab a b)›*) ‹path d'e d' e› (*‹path (d'e::'a set) (d'::'a) (e::'a)›*) abc (*‹[a::'a;b::'a;c::'a]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) dbc (*‹[d::'a;b::'a;c::'a]›*) by (meson abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) bdd' (*‹[b;d;d']›*))
next
(*goal: ‹⟦[a::'a::type;b::'a::type;d'::'a::type]; ∄Q::'a::type set. path Q (c::'a::type) (e::'a::type)⟧ ⟹ ∃(c'::'a::type) d'::'a::type. [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q::'a::type set. path Q d' e) ∧ (∃Q::'a::type set. path Q c' e)›*)
case False (*‹∄Q::'a set. path Q (c::'a) (e::'a)›*)
obtain c' and c'e where "c'∈?ab ∧ path c'e c' e ∧ [b; c; c']"
(*goal: ‹(⋀c' c'e. c' ∈ (THE ab. path ab a b) ∧ path c'e c' e ∧ [b;c;c'] ⟹ thesis) ⟹ thesis›*)
using unreachable_bounded_path[where ab = "?ab" and e = e and b = b and d = c and a = a and S = S and be = be] (*‹⟦S ≠ (THE ab. path ab a b); a ∈ S; e ∈ S; e ≠ a; S ∈ 𝒫; path (THE ab. path ab a b) a b; path be b e; ∄de. path de c e; [a;b;c]; ⋀d' d'e. d' ∈ (THE ab. path ab a b) ∧ path d'e d' e ∧ [b;c;d'] ⟹ ?thesis⟧ ⟹ ?thesis›*) S_neq_ab (*‹S ≠ (THE ab. path ab a b)›*) ‹¬(path_ex c e)› (*‹∄Q::'a::type set. path Q (c::'a::type) (e::'a::type)›*) abc (*‹[a;b;c]›*) path_S (*‹path S a e›*) path_ab (*‹path (THE ab. path ab a b) a b›*) path_be (*‹path be b e›*) by (metis (mono_tags, lifting))
hence "[a; b; c'] ∧ [d; b; c']"
using abc (*‹[a;b;c]›*) dbc (*‹[d;b;c]›*) by blast
hence "[c'; b; a] ∧ [c'; b; d]"
using theorem1 (*‹[?a;?b;?c] ⟹ [?c;?b;?a] ∧ ¬ [?b;?c;?a] ∧ ¬ [?c;?a;?b]›*) by blast
thus "?thesis"
(*goal: ‹∃c' d'. [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q. path Q d' e) ∧ (∃Q. path Q c' e)›*)
using ‹[a; b; d']› (*‹[a;b;d']›*) ‹c' ∈ ?ab ∧ path c'e c' e ∧ [b; c; c']› (*‹c' ∈ (THE ab. path ab a b) ∧ path c'e c' e ∧ [b;c;c']›*) ‹path d'e d' e› (*‹path d'e d' e›*) bdd' (*‹[b;d;d']›*) d'_in_ab (*‹d' ∈ (THE ab. path ab a b)›*) by blast
qed
}
qed
lemma exist_f'_alt:
assumes path_ab: "path ab a b"
and path_S: "S ∈ 𝒫"
and a_inS: "a ∈ S"
and e_inS: "e ∈ S"
and e_neq_a: "e ≠ a"
and f_def: "[e; c'; f]" "f∈c'e"
and S_neq_ab: "S ≠ ab"
and c'd'_def: "c'∈ab ∧ d'∈ab
∧ [a; b; d'] ∧ [c'; b; a] ∧ [c'; b; d']
∧ path d'e d' e ∧ path c'e c' e"
shows "∃f'. ∃f'b. [e; c'; f'] ∧ path f'b f' b"
proof (cases)
(*goals:
1. ‹?P ⟹ ∃f' f'b. [e;c';f'] ∧ path f'b f' b›
2. ‹¬ ?P ⟹ ∃f' f'b. [e;c';f'] ∧ path f'b f' b›*)
assume "∃bf. path bf b f" (*‹∃bf::'a set. path bf (b::'a) (f::'a)›*)
thus "?thesis"
(*goal: ‹∃f' f'b. [e;c';f'] ∧ path f'b f' b›*)
using ‹[e; c'; f]› (*‹[e;c';f]›*) by blast
next
(*goal: ‹∄bf::'a set. path bf (b::'a) (f::'a) ⟹ ∃(f'::'a) f'b::'a set. [e::'a;c'::'a;f'] ∧ path f'b f' b›*)
assume "¬(∃bf. path bf b f)" (*‹∄bf::'a set. path bf (b::'a) (f::'a)›*)
hence "f ∈ unreach-on c'e from b"
using assms(1-5,7-9) (*‹path (ab::'a::type set) (a::'a::type) (b::'a::type)› ‹S ∈ 𝒫› ‹(a::'a) ∈ (S::'a set)› ‹(e::'a) ∈ (S::'a set)› ‹e ≠ a› ‹f ∈ c'e› ‹S ≠ ab› ‹c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*) abc_abc_neq (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) betw_events (*‹[?a;?b;?c] ⟹ ?a ∈ ℰ ∧ ?b ∈ ℰ ∧ ?c ∈ ℰ›*) eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) unreachable_bounded_path_only (*‹⟦(?d'::'a) ∉ unreach-on (?ab::'a set) from (?e::'a); ?d' ∈ ?ab; ?d' ≠ ?e; ?e ∈ (ℰ::'a set); ?ab ∈ (𝒫::'a set set); ?e ∉ ?ab⟧ ⟹ ∃d'e::'a set. path d'e ?d' ?e›*) by metis
moreover have "c' ∈ c'e - unreach-on c'e from b"
using c'd'_def (*‹c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*) cross_in_reachable (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R⟧ ⟹ ?b ∈ ?R - unreach-on ?R from ?a›*) path_ab (*‹path ab a b›*) by blast
moreover have "b∈ℰ ∧ b∉c'e"
using ‹f ∈ unreach-on c'e from b› (*‹f ∈ unreach-on c'e from b›*) betw_events (*‹[?a;?b;?c] ⟹ ?a ∈ ℰ ∧ ?b ∈ ℰ ∧ ?c ∈ ℰ›*) c'd'_def (*‹(c'::'a) ∈ (ab::'a set) ∧ (d'::'a) ∈ ab ∧ [a::'a;b::'a;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path (d'e::'a set) d' (e::'a) ∧ path (c'e::'a set) c' e›*) same_empty_unreach (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ unreach-on ?Q from ?a = {}›*) by auto
ultimately obtain f' where f'_def: "[c'; f; f']" "f'∈c'e" "f'∉ unreach-on c'e from b" "c'≠f'" "b≠f'"
(*goal: ‹(⋀f'. ⟦[c';f;f']; f' ∈ c'e; f' ∉ unreach-on c'e from b; c' ≠ f'; b ≠ f'⟧ ⟹ thesis) ⟹ thesis›*)
using unreachable_set_bounded (*‹⟦?Q ∈ 𝒫; ?b ∉ ?Q; ?b ∈ ℰ; ?Qx ∈ ?Q - unreach-on ?Q from ?b; ?Qy ∈ unreach-on ?Q from ?b⟧ ⟹ ∃Qz∈?Q - unreach-on ?Q from ?b. [?Qx;?Qy;Qz] ∧ ?Qx ≠ Qz›*) c'd'_def (*‹(c'::'a) ∈ (ab::'a set) ∧ (d'::'a) ∈ ab ∧ [a::'a;b::'a;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path (d'e::'a set) d' (e::'a) ∧ path (c'e::'a set) c' e›*) by (metis DiffE (*‹⟦?c ∈ ?A - ?B; ⟦?c ∈ ?A; ?c ∉ ?B⟧ ⟹ ?P⟧ ⟹ ?P›*))
hence "[e; c'; f']"
using ‹[e; c'; f]› (*‹[e::'a::type;c'::'a::type;f::'a::type]›*) by blast
moreover obtain f'b where "path f'b f' b"
(*goal: ‹(⋀f'b. path f'b f' b ⟹ thesis) ⟹ thesis›*)
using ‹b ∈ ℰ ∧ b ∉ c'e› (*‹b ∈ ℰ ∧ b ∉ c'e›*) c'd'_def (*‹c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*) f'_def(2,3) (*‹f' ∈ c'e› ‹f' ∉ unreach-on c'e from b›*) unreachable_bounded_path_only (*‹⟦?d' ∉ unreach-on ?ab from ?e; ?d' ∈ ?ab; ?d' ≠ ?e; ?e ∈ ℰ; ?ab ∈ 𝒫; ?e ∉ ?ab⟧ ⟹ ∃d'e. path d'e ?d' ?e›*) by blast
ultimately show "?thesis"
(*goal: ‹∃f' f'b. [e;c';f'] ∧ path f'b f' b›*)
by blast
qed
lemma exist_f':
assumes path_ab: "path ab a b"
and path_S: "path S a e"
and f_def: "[e; c'; f]"
and S_neq_ab: "S ≠ ab"
and c'd'_def: "[a; b; d']" "[c'; b; a]" "[c'; b; d']"
"path d'e d' e" "path c'e c' e"
shows "∃f'. [e; c'; f'] ∧ path_ex f' b"
proof (cases)
(*goals:
1. ‹?P ⟹ ∃f'. [e;c';f'] ∧ (∃Q. path Q f' b)›
2. ‹¬ ?P ⟹ ∃f'. [e;c';f'] ∧ (∃Q. path Q f' b)›*)
assume "path_ex b f" (*‹∃Q::'a set. path Q (b::'a) (f::'a)›*)
thus "?thesis"
(*goal: ‹∃f'. [e;c';f'] ∧ (∃Q. path Q f' b)›*)
using f_def (*‹[e;c';f]›*) by blast
next
(*goal: ‹∄Q. path Q b f ⟹ ∃f'. [e;c';f'] ∧ (∃Q. path Q f' b)›*)
assume no_path: "¬(path_ex b f)" (*‹∄Q::'a set. path Q (b::'a) (f::'a)›*)
have path_S_2: "S ∈ 𝒫" "a ∈ S" "e ∈ S" "e ≠ a"
using path_S (*‹path S a e›*) apply -
(*goals:
1. ‹path S a e ⟹ S ∈ 𝒫›
2. ‹path S a e ⟹ a ∈ S›
3. ‹path S a e ⟹ e ∈ S›
4. ‹path S a e ⟹ e ≠ a›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*proven 4 subgoals*) .
have "f∈c'e"
using betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) f_def (*‹[e::'a::type;c'::'a::type;f::'a::type]›*) c'd'_def(5) (*‹path (c'e::'a::type set) (c'::'a::type) (e::'a::type)›*) by blast
have "c'∈ ab" "d'∈ ab"
using betw_a_in_path (*‹⟦[?a;?b;?c]; path ?bc ?b ?c⟧ ⟹ ?a ∈ ?bc›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) c'd'_def(1,2) (*‹[a;b;d']› ‹[c';b;a]›*) path_ab (*‹path ab a b›*) apply -
(*goals:
1. ‹⟦⋀a b c bc. ⟦[a;b;c]; path bc b c⟧ ⟹ a ∈ bc; ⋀a b c ab. ⟦[a;b;c]; path ab a b⟧ ⟹ c ∈ ab; [a;b;d']; [c';b;a]; path ab a b⟧ ⟹ c' ∈ ab›
2. ‹⟦⋀a b c bc. ⟦[a;b;c]; path bc b c⟧ ⟹ a ∈ bc; ⋀a b c ab. ⟦[a;b;c]; path ab a b⟧ ⟹ c ∈ ab; [a;b;d']; [c';b;a]; path ab a b⟧ ⟹ d' ∈ ab›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
have "f ∈ unreach-on c'e from b"
using no_path (*‹∄Q. path Q b f›*) assms(1,4-9) (*‹path (ab::'a set) (a::'a) (b::'a)› ‹S ≠ ab› ‹[a;b;d']› ‹[c';b;a]› ‹[c';b;d']› ‹path d'e d' e› ‹path c'e c' e›*) path_S_2 (*‹S ∈ 𝒫› ‹a ∈ S› ‹e ∈ S› ‹e ≠ a›*) ‹f∈c'e› (*‹f ∈ c'e›*) ‹c'∈ab› (*‹c' ∈ ab›*) ‹d'∈ab› (*‹d' ∈ ab›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) betw_events (*‹[?a;?b;?c] ⟹ ?a ∈ ℰ ∧ ?b ∈ ℰ ∧ ?c ∈ ℰ›*) eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) unreachable_bounded_path_only (*‹⟦?d' ∉ unreach-on ?ab from ?e; ?d' ∈ ?ab; ?d' ≠ ?e; ?e ∈ ℰ; ?ab ∈ 𝒫; ?e ∉ ?ab⟧ ⟹ ∃d'e. path d'e ?d' ?e›*) by metis
moreover have "c' ∈ c'e - unreach-on c'e from b"
using c'd'_def (*‹[a;b;d']› ‹[c'::'a;b::'a;a::'a]› ‹[c';b;d']› ‹path d'e d' e› ‹path c'e c' e›*) cross_in_reachable (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R⟧ ⟹ ?b ∈ ?R - unreach-on ?R from ?a›*) path_ab (*‹path ab a b›*) ‹c' ∈ ab› (*‹(c'::'a) ∈ (ab::'a set)›*) by blast
moreover have "b∈ℰ ∧ b∉c'e"
using ‹f ∈ unreach-on c'e from b› (*‹f ∈ unreach-on c'e from b›*) betw_events (*‹[?a;?b;?c] ⟹ ?a ∈ ℰ ∧ ?b ∈ ℰ ∧ ?c ∈ ℰ›*) c'd'_def (*‹[a;b;d']› ‹[c';b;a]› ‹[c';b;d']› ‹path (d'e::'a set) (d'::'a) (e::'a)› ‹path c'e c' e›*) same_empty_unreach (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ unreach-on ?Q from ?a = {}›*) by auto
ultimately obtain f' where f'_def: "[c'; f; f']" "f'∈c'e" "f'∉ unreach-on c'e from b" "c'≠f'" "b≠f'"
(*goal: ‹(⋀f'. ⟦[c';f;f']; f' ∈ c'e; f' ∉ unreach-on c'e from b; c' ≠ f'; b ≠ f'⟧ ⟹ thesis) ⟹ thesis›*)
using unreachable_set_bounded (*‹⟦?Q ∈ 𝒫; ?b ∉ ?Q; ?b ∈ ℰ; ?Qx ∈ ?Q - unreach-on ?Q from ?b; ?Qy ∈ unreach-on ?Q from ?b⟧ ⟹ ∃Qz∈?Q - unreach-on ?Q from ?b. [?Qx;?Qy;Qz] ∧ ?Qx ≠ Qz›*) c'd'_def (*‹[a::'a;b::'a;d'::'a]› ‹[c';b;a]› ‹[c';b;d']› ‹path (d'e::'a set) (d'::'a) (e::'a)› ‹path c'e c' e›*) by (metis DiffE (*‹⟦?c ∈ ?A - ?B; ⟦?c ∈ ?A; ?c ∉ ?B⟧ ⟹ ?P⟧ ⟹ ?P›*))
hence "[e; c'; f']"
using ‹[e; c'; f]› (*‹[e;c';f]›*) by blast
moreover obtain f'b where "path f'b f' b"
(*goal: ‹(⋀f'b. path f'b f' b ⟹ thesis) ⟹ thesis›*)
using ‹b ∈ ℰ ∧ b ∉ c'e› (*‹b ∈ ℰ ∧ b ∉ c'e›*) c'd'_def (*‹[a::'a;b::'a;d'::'a]› ‹[c';b;a]› ‹[c';b;d']› ‹path (d'e::'a set) (d'::'a) (e::'a)› ‹path c'e c' e›*) f'_def(2,3) (*‹(f'::'a) ∈ (c'e::'a set)› ‹f' ∉ unreach-on c'e from b›*) unreachable_bounded_path_only (*‹⟦?d' ∉ unreach-on ?ab from ?e; ?d' ∈ ?ab; ?d' ≠ ?e; ?e ∈ ℰ; ?ab ∈ 𝒫; ?e ∉ ?ab⟧ ⟹ ∃d'e. path d'e ?d' ?e›*) by blast
ultimately show "?thesis"
(*goal: ‹∃f'. [e;c';f'] ∧ (∃Q. path Q f' b)›*)
by blast
qed
lemma abc_abd_bcdbdc:
assumes abc: "[a;b;c]"
and abd: "[a;b;d]"
and c_neq_d: "c ≠ d"
shows "[b;c;d] ∨ [b;d;c]"
proof (-)
(*goal: ‹[b;c;d] ∨ [b;d;c]›*)
have "¬ [d;b;c]"
proof (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹[d;b;c] ⟹ False›*)
assume dbc: "[d;b;c]" (*‹[d::'a;b::'a;c::'a]›*)
obtain ab where path_ab: "path ab a b"
(*goal: ‹(⋀ab. path ab a b ⟹ thesis) ⟹ thesis›*)
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_ex_path_unique (*‹[?a;?b;?c] ⟹ ∃!Q. Q ∈ 𝒫 ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) abc (*‹[a::'a;b::'a;c::'a]›*) by blast
obtain S where path_S: "S ∈ 𝒫" and S_neq_ab: "S ≠ ab" and a_inS: "a ∈ S"
(*goal: ‹(⋀S. ⟦S ∈ 𝒫; S ≠ ab; a ∈ S⟧ ⟹ thesis) ⟹ thesis›*)
using ex_crossing_at (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ∃ac∈𝒫. ac ≠ ?Q ∧ (∃c. c ∉ ?Q ∧ ?a ∈ ac ∧ c ∈ ac)›*) path_ab (*‹path ab a b›*) by auto
have "∃e∈S. e ≠ a ∧ (∃be∈𝒫. path be b e)"
proof (-)
(*goal: ‹∃e∈S. e ≠ a ∧ (∃be∈𝒫. path be b e)›*)
have b_notinS: "b ∉ S"
using S_neq_ab (*‹S ≠ ab›*) a_inS (*‹(a::'a::type) ∈ (S::'a::type set)›*) path_S (*‹S ∈ 𝒫›*) path_ab (*‹path ab a b›*) path_unique (*‹⟦path ?ab ?a ?b; path ?ab' ?a ?b⟧ ⟹ ?ab = ?ab'›*) by blast
then obtain x and y and z where x_in_unreach: "x ∈ unreach-on S from b" and y_in_unreach: "y ∈ unreach-on S from b" and x_neq_y: "x ≠ y" and z_in_reach: "z ∈ S - unreach-on S from b"
(*goal: ‹(⋀x y z. ⟦x ∈ unreach-on S from b; y ∈ unreach-on S from b; x ≠ y; z ∈ S - unreach-on S from b⟧ ⟹ thesis) ⟹ thesis›*)
using two_in_unreach[where Q = S and b = b] (*‹⟦S ∈ 𝒫; b ∈ ℰ; b ∉ S⟧ ⟹ ∃x∈unreach-on S from b. ∃y∈unreach-on S from b. x ≠ y›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_S (*‹S ∈ 𝒫›*) path_ab (*‹path ab a b›*) a_inS (*‹a ∈ S›*) cross_in_reachable (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R⟧ ⟹ ?b ∈ ?R - unreach-on ?R from ?a›*) by blast
then obtain w where w_in_reach: "w ∈ S - unreach-on S from b" and w_neq_z: "w ≠ z"
(*goal: ‹(⋀w::'a. ⟦w ∈ (S::'a set) - unreach-on S from (b::'a); w ≠ (z::'a)⟧ ⟹ thesis::bool) ⟹ thesis›*)
using unreachable_set_bounded[where Q = S and b = b and Qx = z and Qy = x] (*‹⟦S ∈ 𝒫; b ∉ S; b ∈ ℰ; z ∈ S - unreach-on S from b; x ∈ unreach-on S from b⟧ ⟹ ∃Qz∈S - unreach-on S from b. [z;x;Qz] ∧ z ≠ Qz›*) b_notinS (*‹b ∉ S›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_S (*‹S ∈ 𝒫›*) path_ab (*‹path ab a b›*) by blast
thus "?thesis"
(*goal: ‹∃e::'a∈S::'a set. e ≠ (a::'a) ∧ (∃be::'a set∈𝒫::'a set set. path be (b::'a) e)›*)
by (metis DiffD1 (*‹?c ∈ ?A - ?B ⟹ ?c ∈ ?A›*) b_notinS (*‹b ∉ S›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_S (*‹S ∈ 𝒫›*) path_ab (*‹path ab a b›*) reachable_path (*‹⟦?Q ∈ 𝒫; ?b ∈ ℰ; ?a ∈ ?Q - unreach-on ?Q from ?b⟧ ⟹ ∃R∈𝒫. ?a ∈ R ∧ ?b ∈ R›*) z_in_reach (*‹z ∈ S - unreach-on S from b›*))
qed
then obtain e and be where e_inS: "e ∈ S" and e_neq_a: "e ≠ a" and path_be: "path be b e"
(*goal: ‹(⋀e be. ⟦e ∈ S; e ≠ a; path be b e⟧ ⟹ thesis) ⟹ thesis›*)
by blast
have path_ae: "path S a e"
using a_inS (*‹a ∈ S›*) e_inS (*‹e ∈ S›*) e_neq_a (*‹e ≠ a›*) path_S (*‹(S::'a set) ∈ (𝒫::'a set set)›*) by auto
have S_neq_ab_2: "S ≠ path_of a b"
using S_neq_ab (*‹S ≠ ab›*) cross_once_notin (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*) path_ab (*‹path ab a b›*) path_of_ex (*‹path (THE ab. path ab ?a ?b) ?a ?b = (∃Q. path Q ?a ?b)›*) by blast
have "∃c' d'.
c'∈ab ∧ d'∈ab
∧ [a; b; d'] ∧ [c'; b; a] ∧ [c'; b; d']
∧ path_ex d' e ∧ path_ex c' e"
using exist_c'd'[where a = a and b = b and c = c and d = d and e = e and be = be and S = S] (*‹⟦[a;b;c]; [a;b;d]; [d;b;c]; path S a e; path be b e; S ≠ (THE ab. path ab a b)⟧ ⟹ ∃c' d'. [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ (∃Q. path Q d' e) ∧ (∃Q. path Q c' e)›*) using assms(1-2) (*‹[a;b;c]› ‹[a;b;d]›*) dbc (*‹[d;b;c]›*) e_neq_a (*‹e ≠ a›*) path_ae (*‹path S a e›*) path_be (*‹path be b e›*) S_neq_ab_2 (*‹S ≠ (THE ab. path ab a b)›*) using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) betw_a_in_path (*‹⟦[?a::'a;?b::'a;?c::'a]; path (?bc::'a set) ?b ?c⟧ ⟹ ?a ∈ ?bc›*) path_ab (*‹path ab a b›*) by blast
then obtain c' and d' and d'e and c'e where c'd'_def: "c'∈ab ∧ d'∈ab
∧ [a; b; d'] ∧ [c'; b; a] ∧ [c'; b; d']
∧ path d'e d' e ∧ path c'e c' e"
(*goal: ‹(⋀c' d' d'e c'e. c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e ⟹ thesis) ⟹ thesis›*)
by blast
obtain f where f_def: "f∈c'e" "[e; c'; f]"
(*goal: ‹(⋀f. ⟦f ∈ c'e; [e;c';f]⟧ ⟹ thesis) ⟹ thesis›*)
using c'd'_def (*‹c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*) prolong_betw2 (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ∃c∈?Q. [?a;?b;c]›*) by blast
then obtain f' and f'b where f'_def: "[e; c'; f'] ∧ path f'b f' b"
(*goal: ‹(⋀f' f'b. [e;c';f'] ∧ path f'b f' b ⟹ thesis) ⟹ thesis›*)
using exist_f'[where e = e and c' = c' and b = b and f = f and S = S and ab = ab and d' = d' and a = a and c'e = c'e] (*‹⟦path (ab::'a set) (a::'a) (b::'a); path (S::'a set) a (e::'a); [e;c'::'a;f::'a]; S ≠ ab; [a;b;d'::'a]; [c';b;a]; [c';b;d']; path (?d'e::'a set) d' e; path (c'e::'a set) c' e⟧ ⟹ ∃f'::'a. [e;c';f'] ∧ (∃Q::'a set. path Q f' b)›*) using path_ab (*‹path ab a b›*) path_S (*‹S ∈ 𝒫›*) a_inS (*‹a ∈ S›*) e_inS (*‹e ∈ S›*) e_neq_a (*‹e ≠ a›*) f_def (*‹f ∈ c'e› ‹[e::'a;c'::'a;f::'a]›*) S_neq_ab (*‹S ≠ ab›*) c'd'_def (*‹c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*) by blast
obtain ae where path_ae: "path ae a e"
(*goal: ‹(⋀ae. path ae a e ⟹ thesis) ⟹ thesis›*)
using a_inS (*‹a ∈ S›*) e_inS (*‹e ∈ S›*) e_neq_a (*‹e ≠ a›*) path_S (*‹S ∈ 𝒫›*) by blast
have tri_aec: "△ a e c'"
by (smt cross_once_notin (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*) S_neq_ab (*‹S ≠ ab›*) a_inS (*‹a ∈ S›*) abc (*‹[a;b;c]›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) e_inS (*‹e ∈ S›*) e_neq_a (*‹e ≠ a›*) path_S (*‹S ∈ 𝒫›*) path_ab (*‹path ab a b›*) c'd'_def (*‹c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*) paths_tri (*‹⟦path ?ab ?a ?b; path ?bc ?b ?c; path ?ca ?c ?a; ?a ∉ ?bc⟧ ⟹ △ ?a ?b ?c›*))
then obtain h where h_in_f'b: "h ∈ f'b" and ahe: "[a;h;e]" and f'bh: "[f'; b; h]"
(*goal: ‹(⋀h. ⟦h ∈ f'b; [a;h;e]; [f';b;h]⟧ ⟹ thesis) ⟹ thesis›*)
using collinearity2[where a = a and b = e and c = c' and d = f' and e = b and de = f'b] (*‹⟦△ a e c'; [e;c';f']; [c';b;a]; path f'b f' b⟧ ⟹ ∃f. [a;f;e] ∧ [f';b;f]›*) f'_def (*‹[e::'a;c'::'a;f'::'a] ∧ path (f'b::'a set) f' (b::'a)›*) c'd'_def (*‹c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*) f'_def (*‹[e::'a;c'::'a;f'::'a] ∧ path (f'b::'a set) f' (b::'a)›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) by blast
have tri_dec: "△ d' e c'"
using cross_once_notin (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*) S_neq_ab (*‹S ≠ ab›*) a_inS (*‹a ∈ S›*) abc (*‹[a;b;c]›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) e_inS (*‹e ∈ S›*) e_neq_a (*‹e ≠ a›*) path_S (*‹S ∈ 𝒫›*) path_ab (*‹path ab a b›*) c'd'_def (*‹c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*) paths_tri (*‹⟦path ?ab ?a ?b; path ?bc ?b ?c; path ?ca ?c ?a; ?a ∉ ?bc⟧ ⟹ △ ?a ?b ?c›*) by smt
then obtain g where g_in_f'b: "g ∈ f'b" and d'ge: "[d'; g; e]" and f'bg: "[f'; b; g]"
(*goal: ‹(⋀g. ⟦g ∈ f'b; [d';g;e]; [f';b;g]⟧ ⟹ thesis) ⟹ thesis›*)
using collinearity2[where a = d' and b = e and c = c' and d = f' and e = b and de = f'b] (*‹⟦△ (d'::'a::type) (e::'a::type) (c'::'a::type); [e;c';f'::'a::type]; [c';b::'a::type;d']; path (f'b::'a::type set) f' b⟧ ⟹ ∃f::'a::type. [d';f;e] ∧ [f';b;f]›*) f'_def (*‹[e;c';f'] ∧ path f'b f' b›*) c'd'_def (*‹c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) by blast
have "△ e a d'"
by (smt betw_c_in_path (*‹⟦[?a::'a;?b::'a;?c::'a]; path (?ab::'a set) ?a ?b⟧ ⟹ ?c ∈ ?ab›*) paths_tri2 (*‹⟦path (?ab::'a set) (?a::'a) (?b::'a); path (?bc::'a set) ?b (?c::'a); path (?ca::'a set) ?c ?a; ?ab ≠ ?bc⟧ ⟹ △ ?a ?b ?c›*) S_neq_ab (*‹(S::'a set) ≠ (ab::'a set)›*) a_inS (*‹(a::'a) ∈ (S::'a set)›*) abc_ac_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?c›*) abd (*‹[a::'a;b::'a;d::'a]›*) e_inS (*‹(e::'a) ∈ (S::'a set)›*) e_neq_a (*‹(e::'a) ≠ (a::'a)›*) c'd'_def (*‹(c'::'a) ∈ (ab::'a set) ∧ (d'::'a) ∈ ab ∧ [a::'a;b::'a;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path (d'e::'a set) d' (e::'a) ∧ path (c'e::'a set) c' e›*) path_S (*‹(S::'a set) ∈ (𝒫::'a set set)›*) path_ab (*‹path (ab::'a set) (a::'a) (b::'a)›*))
thus False
using tri_betw_no_path[where a = e and b = a and c = d' and b' = g and a' = b and c' = h] (*‹⟦△ e a d'; [e;g;d']; [a;h;e]; [d';b;a]⟧ ⟹ ¬ (∃Q∈𝒫. b ∈ Q ∧ g ∈ Q ∧ h ∈ Q)›*) f'_def (*‹[e::'a;c'::'a;f'::'a] ∧ path (f'b::'a set) f' (b::'a)›*) c'd'_def (*‹c' ∈ ab ∧ d' ∈ ab ∧ [a;b;d'] ∧ [c';b;a] ∧ [c';b;d'] ∧ path d'e d' e ∧ path c'e c' e›*) h_in_f'b (*‹h ∈ f'b›*) g_in_f'b (*‹(g::'a) ∈ (f'b::'a set)›*) abd (*‹[a;b;d]›*) d'ge (*‹[d';g;e]›*) ahe (*‹[a;h;e]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by blast
qed
thus "?thesis"
(*goal: ‹[b;c;d] ∨ [b;d;c]›*)
by (smt abc (*‹[a::'a::type;b::'a::type;c::'a::type]›*) abc_abc_neq (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_ex_path (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ∃Q::'a::type set∈𝒫::'a::type set set. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) abc_sym (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ [?c;?b;?a]›*) abd (*‹[a::'a::type;b::'a::type;d::'a::type]›*) c_neq_d (*‹(c::'a::type) ≠ (d::'a::type)›*) cross_once_notin (*‹⟦(?Q::'a::type set) ∈ (𝒫::'a::type set set); (?R::'a::type set) ∈ 𝒫; (?a::'a::type) ∈ ?Q; (?b::'a::type) ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*) some_betw (*‹⟦(?Q::'a::type set) ∈ (𝒫::'a::type set set); (?a::'a::type) ∈ ?Q; (?b::'a::type) ∈ ?Q; (?c::'a::type) ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*))
qed
(* Lemma 2-3.6. *)
lemma abc_abd_acdadc:
assumes abc: "[a;b;c]"
and abd: "[a;b;d]"
and c_neq_d: "c ≠ d"
shows "[a;c;d] ∨ [a;d;c]"
proof (-)
(*goal: ‹[a;c;d] ∨ [a;d;c]›*)
have cba: "[c;b;a]"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) abc (*‹[a;b;c]›*) by simp
have dba: "[d;b;a]"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) abd (*‹[a;b;d]›*) by simp
have dcb_over_cba: "[d;c;b] ∧ [c;b;a] ⟹ [d;c;a]"
by auto
have cdb_over_dba: "[c;d;b] ∧ [d;b;a] ⟹ [c;d;a]"
by auto
have bcdbdc: "[b;c;d] ∨ [b;d;c]"
using abc (*‹[a;b;c]›*) abc_abd_bcdbdc (*‹⟦[?a::'a;?b::'a;?c::'a]; [?a;?b;?d::'a]; ?c ≠ ?d⟧ ⟹ [?b;?c;?d] ∨ [?b;?d;?c]›*) abd (*‹[a;b;d]›*) c_neq_d (*‹c ≠ d›*) by auto
then have dcb_or_cdb: "[d;c;b] ∨ [c;d;b]"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by blast
then have "[d;c;a] ∨ [c;d;a]"
using abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ¬ [?a;?c;?b]› ‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) dcb_over_cba (*‹[d::'a::type;c::'a::type;b::'a::type] ∧ [c;b;a::'a::type] ⟹ [d;c;a]›*) cdb_over_dba (*‹[c;d;b] ∧ [d;b;a] ⟹ [c;d;a]›*) cba (*‹[c;b;a]›*) dba (*‹[d;b;a]›*) by blast
thus "?thesis"
(*goal: ‹[a;c;d] ∨ [a;d;c]›*)
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by auto
qed
(* Lemma 3-3.6. *)
lemma abc_acd_bcd:
assumes abc: "[a;b;c]"
and acd: "[a;c;d]"
shows "[b;c;d]"
proof (-)
(*goal: ‹[b;c;d]›*)
have path_abc: "∃Q∈𝒫. a ∈ Q ∧ b ∈ Q ∧ c ∈ Q"
using abc (*‹[a;b;c]›*) by (simp add: abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*))
have path_acd: "∃Q∈𝒫. a ∈ Q ∧ c ∈ Q ∧ d ∈ Q"
using acd (*‹[a;c;d]›*) by (simp add: abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*))
then have "∃Q∈𝒫. b ∈ Q ∧ c ∈ Q ∧ d ∈ Q"
using path_abc (*‹∃Q∈𝒫. a ∈ Q ∧ b ∈ Q ∧ c ∈ Q›*) abc_abc_neq (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) acd (*‹[a;c;d]›*) cross_once_notin (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*) by metis
then have bcd3: "[b;c;d] ∨ [b;d;c] ∨ [c;b;d]"
by (metis abc (*‹[a;b;c]›*) abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) 1,2) acd (*‹[a;c;d]›*) some_betw2 (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q⟧ ⟹ ?a = ?b ∨ ?a = ?c ∨ ?b = ?c ∨ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*))
show "?thesis"
(*goal: ‹[b;c;d]›*)
proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*))
(*goal: ‹¬ [b;c;d] ⟹ False›*)
assume "¬ [b;c;d]" (*‹¬ [b::'a;c::'a;d::'a]›*)
then have "[b;d;c] ∨ [c;b;d]"
using bcd3 (*‹[b::'a::type;c::'a::type;d::'a::type] ∨ [b;d;c] ∨ [c;b;d]›*) by simp
thus False
proof (rule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹[b;d;c] ⟹ False›
2. ‹[c;b;d] ⟹ False›*)
assume "[b;d;c]" (*‹[b::'a;d::'a;c::'a]›*)
then have "[c;d;b]"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by simp
then have "[a;c;b]"
using acd (*‹[a;c;d]›*) abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) by blast
thus False
using abc (*‹[a;b;c]›*) abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) by blast
next
(*goal: ‹[c;b;d] ⟹ False›*)
assume cbd: "[c;b;d]" (*‹[c::'a;b::'a;d::'a]›*)
have cba: "[c;b;a]"
using abc (*‹[a;b;c]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by blast
have a_neq_d: "a ≠ d"
using abc_ac_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?c›*) acd (*‹[a;c;d]›*) by auto
then have "[c;a;d] ∨ [c;d;a]"
using abc_abd_acdadc (*‹⟦[?a::'a;?b::'a;?c::'a]; [?a;?b;?d::'a]; ?c ≠ ?d⟧ ⟹ [?a;?c;?d] ∨ [?a;?d;?c]›*) cbd (*‹[c::'a;b::'a;d::'a]›*) cba (*‹[c;b;a]›*) by simp
thus False
using abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) acd (*‹[a;c;d]›*) by blast
qed
qed
qed
text ‹
A few lemmas that don't seem to be proved by Schutz, but can be proven now, after Lemma 3.
These sometimes avoid us having to construct a chain explicitly.
›
lemma abd_bcd_abc:
assumes abd: "[a;b;d]"
and bcd: "[b;c;d]"
shows "[a;b;c]"
proof (-)
(*goal: ‹[a;b;c]›*)
have dcb: "[d;c;b]"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) bcd (*‹[b;c;d]›*) by simp
have dba: "[d;b;a]"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) abd (*‹[a;b;d]›*) by simp
have "[c;b;a]"
using abc_acd_bcd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?b;?c;?d]›*) dcb (*‹[d;c;b]›*) dba (*‹[d;b;a]›*) by blast
thus "?thesis"
(*goal: ‹[a::'a::type;b::'a::type;c::'a::type]›*)
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by simp
qed
lemma abc_acd_abd:
assumes abc: "[a;b;c]"
and acd: "[a;c;d]"
shows "[a;b;d]"
using abc (*‹[a;b;c]›*) abc_acd_bcd (*‹⟦[?a::'a;?b::'a;?c::'a]; [?a;?c;?d::'a]⟧ ⟹ [?b;?c;?d]›*) acd (*‹[a;c;d]›*) by blast
lemma abd_acd_abcacb:
assumes abd: "[a;b;d]"
and acd: "[a;c;d]"
and bc: "b≠c"
shows "[a;b;c] ∨ [a;c;b]"
proof (-)
(*goal: ‹[a;b;c] ∨ [a;c;b]›*)
obtain P where P_def: "P∈𝒫" "a∈P" "b∈P" "d∈P"
(*goal: ‹(⋀P. ⟦P ∈ 𝒫; a ∈ P; b ∈ P; d ∈ P⟧ ⟹ thesis) ⟹ thesis›*)
using abd (*‹[a;b;d]›*) abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) by blast
hence "c∈P"
using acd (*‹[a;c;d]›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) by blast
have "¬[b;a;c]"
using abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) abd (*‹[a;b;d]›*) acd (*‹[a;c;d]›*) by blast
thus "?thesis"
(*goal: ‹[a::'a;b::'a;c::'a] ∨ [a;c;b]›*)
by (metis P_def( (*‹(P::'a set) ∈ (𝒫::'a set set)› ‹(a::'a) ∈ (P::'a set)› ‹(b::'a) ∈ (P::'a set)›*) 1-3) ‹c ∈ P› abc_abc_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_sym (*‹[?a::'a;?b::'a;?c::'a] ⟹ [?c;?b;?a]›*) abd (*‹[a::'a;b::'a;d::'a]›*) acd (*‹[a::'a;c::'a;d::'a]›*) bc (*‹(b::'a) ≠ (c::'a)›*) some_betw (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q; (?b::'a) ∈ ?Q; (?c::'a) ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*))
qed
lemma abe_ade_bcd_ace:
assumes abe: "[a;b;e]"
and ade: "[a;d;e]"
and bcd: "[b;c;d]"
shows "[a;c;e]"
proof (-)
(*goal: ‹[a;c;e]›*)
have abdadb: "[a;b;d] ∨ [a;d;b]"
using abc_ac_neq (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ?a ≠ ?c›*) abd_acd_abcacb (*‹⟦[?a;?b;?d]; [?a;?c;?d]; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?a;?c;?b]›*) abe (*‹[a;b;e]›*) ade (*‹[a;d;e]›*) bcd (*‹[b::'a::type;c::'a::type;d::'a::type]›*) by auto
thus "?thesis"
(*goal: ‹[a;c;e]›*)
proof (standard)
(*goals:
1. ‹[a::'a;b::'a;d::'a] ⟹ [a;c::'a;e::'a]›
2. ‹[a::'a;d::'a;b::'a] ⟹ [a;c::'a;e::'a]›*)
assume "[a;b;d]" (*‹[a::'a;b::'a;d::'a]›*)
thus "?thesis"
(*goal: ‹[a::'a::type;c::'a::type;e::'a::type]›*)
by (meson abc_acd_abd (*‹⟦[?a::'a::type;?b::'a::type;?c::'a::type]; [?a;?c;?d::'a::type]⟧ ⟹ [?a;?b;?d]›*) abc_sym (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ [?c;?b;?a]›*) ade (*‹[a::'a::type;d::'a::type;e::'a::type]›*) bcd (*‹[b::'a::type;c::'a::type;d::'a::type]›*))
next
(*goal: ‹[a::'a::type;d::'a::type;b::'a::type] ⟹ [a;c::'a::type;e::'a::type]›*)
assume "[a;d;b]" (*‹[a::'a;d::'a;b::'a]›*)
thus "?thesis"
(*goal: ‹[a::'a;c::'a;e::'a]›*)
by (meson abc_acd_abd (*‹⟦[?a::'a;?b::'a;?c::'a]; [?a;?c;?d::'a]⟧ ⟹ [?a;?b;?d]›*) abc_sym (*‹[?a::'a;?b::'a;?c::'a] ⟹ [?c;?b;?a]›*) abe (*‹[a::'a;b::'a;e::'a]›*) bcd (*‹[b::'a;c::'a;d::'a]›*))
qed
qed
text ‹Now we start on Theorem 9. Based on Veblen (1904) Lemma 2 p357.›
lemma (in MinkowskiBetweenness) chain3:
assumes path_Q: "Q ∈ 𝒫"
and a_inQ: "a ∈ Q"
and b_inQ: "b ∈ Q"
and c_inQ: "c ∈ Q"
and abc_neq: "a ≠ b ∧ a ≠ c ∧ b ≠ c"
shows "ch {a,b,c}"
proof (-)
(*goal: ‹ch {a, b, c}›*)
have abc_betw: "[a;b;c] ∨ [a;c;b] ∨ [b;a;c]"
using assms (*‹Q ∈ 𝒫› ‹a ∈ Q› ‹(b::'a) ∈ (Q::'a set)› ‹c ∈ Q› ‹a ≠ b ∧ a ≠ c ∧ b ≠ c›*) by (meson in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*))
have ch1: "[a;b;c] ⟶ ch {a,b,c}"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) ch_by_ord_def (*‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X›*) ch_def (*‹ch ?X ≡ ∃f. [f↝?X]›*) ord_ordered_loc (*‹⟦(?ord::?'a ⇒ ?'a ⇒ ?'a ⇒ bool) (?a::?'a) (?b::?'a) (?c::?'a); ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c⟧ ⟹ ∃f::nat ⇒ ?'a. local_ordering f ?ord {?a, ?b, ?c}›*) between_chain (*‹[?a;?b;?c] ⟹ ch {?a, ?b, ?c}›*) by auto
have ch2: "[a;c;b] ⟶ ch {a,c,b}"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) ch_by_ord_def (*‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X›*) ch_def (*‹ch (?X::'a set) ≡ ∃f::nat ⇒ 'a. [f↝?X]›*) ord_ordered_loc (*‹⟦(?ord::?'a::type ⇒ ?'a::type ⇒ ?'a::type ⇒ bool) (?a::?'a::type) (?b::?'a::type) (?c::?'a::type); ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c⟧ ⟹ ∃f::nat ⇒ ?'a::type. local_ordering f ?ord {?a, ?b, ?c}›*) between_chain (*‹[?a;?b;?c] ⟹ ch {?a, ?b, ?c}›*) by auto
have ch3: "[b;a;c] ⟶ ch {b,a,c}"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) ch_by_ord_def (*‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X›*) ch_def (*‹ch ?X ≡ ∃f. [f↝?X]›*) ord_ordered_loc (*‹⟦?ord ?a ?b ?c; ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c⟧ ⟹ ∃f. local_ordering f ?ord {?a, ?b, ?c}›*) between_chain (*‹[?a::'a;?b::'a;?c::'a] ⟹ ch {?a, ?b, ?c}›*) by auto
show "?thesis"
(*goal: ‹ch {a, b, c}›*)
using abc_betw (*‹[a;b;c] ∨ [a;c;b] ∨ [b;a;c]›*) ch1 (*‹[a;b;c] ⟶ ch {a, b, c}›*) ch2 (*‹[a;c;b] ⟶ ch {a, c, b}›*) ch3 (*‹[b;a;c] ⟶ ch {b, a, c}›*) by (metis insert_commute (*‹insert ?x (insert ?y ?A) = insert ?y (insert ?x ?A)›*))
qed
lemma overlap_chain: "⟦[a;b;c]; [b;c;d]⟧ ⟹ ch {a,b,c,d}"
proof (-)
(*goal: ‹⟦[a;b;c]; [b;c;d]⟧ ⟹ ch {a, b, c, d}›*)
assume "[a;b;c]" and "[b;c;d]" (*‹[a::'a;b::'a;c::'a]› ‹[b::'a;c::'a;d::'a]›*)
have "∃f. local_ordering f betw {a,b,c,d}"
proof (-)
(*goal: ‹∃f. local_ordering f betw {a, b, c, d}›*)
have f1: "[a;b;d]"
using ‹[a;b;c]› (*‹[a::'a;b::'a;c::'a]›*) ‹[b;c;d]› (*‹[b;c;d]›*) by blast
have "[a;c;d]"
using ‹[a;b;c]› (*‹[a;b;c]›*) ‹[b;c;d]› (*‹[b;c;d]›*) abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) by blast
then show "?thesis"
(*goal: ‹∃f::nat ⇒ 'a. local_ordering f betw {a::'a, b::'a, c::'a, d::'a}›*)
using f1 (*‹[a::'a;b::'a;d::'a]›*) by (metis (no_types) ‹[a;b;c]› ‹[b;c;d]› abc_abc_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) overlap_ordering_loc (*‹⟦(?ord::?'a ⇒ ?'a ⇒ ?'a ⇒ bool) (?a::?'a) (?b::?'a) (?c::?'a); ?ord ?b ?c (?d::?'a); ?ord ?a ?b ?d; ?ord ?a ?c ?d; ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?a ≠ ?d ∧ ?b ≠ ?c ∧ ?b ≠ ?d ∧ ?c ≠ ?d⟧ ⟹ ∃f::nat ⇒ ?'a. local_ordering f ?ord {?a, ?b, ?c, ?d}›*))
qed
hence "∃f. local_long_ch_by_ord f {a,b,c,d}"
apply (simp add: chain_defs (*‹short_ch (?X::'a set) ≡ card ?X = (2::nat) ∧ (∃P::'a set∈𝒫::'a set set. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f::nat ⇒ 'a↝?X::'a set] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a .. ?y::'a] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) eval_nat_numeral (*‹Numeral1 = Suc (0::nat)› ‹numeral (num.Bit0 (?n::num)) = Suc (numeral (Num.BitM ?n))› ‹numeral (num.Bit1 (?n::num)) = Suc (numeral (num.Bit0 ?n))›*))
(*goal: ‹∃f. local_long_ch_by_ord f {a, b, c, d}›*)
using ‹[a;b;c]› (*‹[a::'a;b::'a;c::'a]›*) abc_abc_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) by (smt (z3) ‹[b;c;d]› card.empty (*‹card {} = 0›*) card_insert_disjoint (*‹⟦finite ?A; ?x ∉ ?A⟧ ⟹ card (insert ?x ?A) = Suc (card ?A)›*) card_insert_le (*‹card ?A ≤ card (insert ?x ?A)›*) finite.emptyI (*‹finite {}›*) finite.insertI (*‹finite ?A ⟹ finite (insert ?a ?A)›*) insertE (*‹⟦?a ∈ insert ?b ?A; ?a = ?b ⟹ ?P; ?a ∈ ?A ⟹ ?P⟧ ⟹ ?P›*) insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*) insert_not_empty (*‹insert ?a ?A ≠ {}›*))
thus "?thesis"
(*goal: ‹ch {a, b, c, d}›*)
by (simp add: chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*))
qed
text ‹
The book introduces Theorem 9 before the above three lemmas but can only complete the proof
once they are proven.
This doesn't exactly say it the same way as the book, as the book gives the
\<^term>‹local_ordering› (abcd) explicitly (for arbitrarly named events), but is equivalent.
›
theorem (*9*) chain4:
assumes path_Q: "Q ∈ 𝒫"
and inQ: "a ∈ Q" "b ∈ Q" "c ∈ Q" "d ∈ Q"
and abcd_neq: "a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d"
shows "ch {a,b,c,d}"
proof (-)
(*goal: ‹ch {a, b, c, d}›*)
obtain a' and b' and c' where a'_pick: "a' ∈ {a,b,c,d}" and b'_pick: "b' ∈ {a,b,c,d}" and c'_pick: "c' ∈ {a,b,c,d}" and a'b'c': "[a'; b'; c']"
(*goal: ‹(⋀a' b' c'. ⟦a' ∈ {a, b, c, d}; b' ∈ {a, b, c, d}; c' ∈ {a, b, c, d}; [a';b';c']⟧ ⟹ thesis) ⟹ thesis›*)
using some_betw (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q; (?b::'a) ∈ ?Q; (?c::'a) ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) by (metis inQ( (*‹a ∈ Q› ‹b ∈ Q› ‹d ∈ Q›*) 1,2,4) abcd_neq (*‹a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) path_Q (*‹Q ∈ 𝒫›*))
then obtain d' where d'_neq: "d' ≠ a' ∧ d' ≠ b' ∧ d' ≠ c'" and d'_pick: "d' ∈ {a,b,c,d}"
(*goal: ‹(⋀d'. ⟦d' ≠ a' ∧ d' ≠ b' ∧ d' ≠ c'; d' ∈ {a, b, c, d}⟧ ⟹ thesis) ⟹ thesis›*)
using insert_iff (*‹((?a::?'a::type) ∈ insert (?b::?'a::type) (?A::?'a::type set)) = (?a = ?b ∨ ?a ∈ ?A)›*) abcd_neq (*‹a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d›*) by metis
have all_picked_on_path: "a'∈Q" "b'∈Q" "c'∈Q" "d'∈Q"
using a'_pick (*‹a' ∈ {a, b, c, d}›*) b'_pick (*‹b' ∈ {a, b, c, d}›*) c'_pick (*‹c' ∈ {a, b, c, d}›*) d'_pick (*‹(d'::'a) ∈ {a::'a, b::'a, c::'a, d::'a}›*) inQ (*‹a ∈ Q› ‹b ∈ Q› ‹c ∈ Q› ‹d ∈ Q›*) apply -
(*goals:
1. ‹⟦a' ∈ {a, b, c, d}; b' ∈ {a, b, c, d}; c' ∈ {a, b, c, d}; d' ∈ {a, b, c, d}; a ∈ Q; b ∈ Q; c ∈ Q; d ∈ Q⟧ ⟹ a' ∈ Q›
2. ‹⟦a' ∈ {a, b, c, d}; b' ∈ {a, b, c, d}; c' ∈ {a, b, c, d}; d' ∈ {a, b, c, d}; a ∈ Q; b ∈ Q; c ∈ Q; d ∈ Q⟧ ⟹ b' ∈ Q›
3. ‹⟦a' ∈ {a, b, c, d}; b' ∈ {a, b, c, d}; c' ∈ {a, b, c, d}; d' ∈ {a, b, c, d}; a ∈ Q; b ∈ Q; c ∈ Q; d ∈ Q⟧ ⟹ c' ∈ Q›
4. ‹⟦a' ∈ {a, b, c, d}; b' ∈ {a, b, c, d}; c' ∈ {a, b, c, d}; d' ∈ {a, b, c, d}; a ∈ Q; b ∈ Q; c ∈ Q; d ∈ Q⟧ ⟹ d' ∈ Q›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*discuss goal 3*)
apply blast
(*discuss goal 4*)
apply blast
(*proven 4 subgoals*) .
consider "[d'; a'; b']" | "[a'; d'; b']" | "[a'; b'; d']"
(*goal: ‹⟦[d';a';b'] ⟹ thesis; [a';d';b'] ⟹ thesis; [a';b';d'] ⟹ thesis⟧ ⟹ thesis›*)
using some_betw (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q; (?b::'a) ∈ ?Q; (?c::'a) ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) all_picked_on_path(1,2,4) (*‹a' ∈ Q› ‹b' ∈ Q› ‹d' ∈ Q›*) by (metis a'b'c' (*‹[a'::'a::type;b'::'a::type;c'::'a::type]›*) d'_neq (*‹(d'::'a::type) ≠ (a'::'a::type) ∧ d' ≠ (b'::'a::type) ∧ d' ≠ (c'::'a::type)›*) path_Q (*‹(Q::'a::type set) ∈ (𝒫::'a::type set set)›*))
then have picked_chain: "ch {a',b',c',d'}"
proof (cases)
(*goals:
1. ‹[d';a';b'] ⟹ ch {a', b', c', d'}›
2. ‹[a';d';b'] ⟹ ch {a', b', c', d'}›
3. ‹[a';b';d'] ⟹ ch {a', b', c', d'}›*)
assume "[d'; a'; b']" (*‹[d'::'a;a'::'a;b'::'a]›*)
thus "?thesis"
(*goal: ‹ch {a'::'a, b'::'a, c'::'a, d'::'a}›*)
using a'b'c' (*‹[a';b';c']›*) overlap_chain (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ ch {?a, ?b, ?c, ?d}›*) by (metis (full_types) insert_commute (*‹insert ?x (insert ?y ?A) = insert ?y (insert ?x ?A)›*))
next
(*goals:
1. ‹[a'::'a;d'::'a;b'::'a] ⟹ ch {a', b', c'::'a, d'}›
2. ‹[a'::'a;b'::'a;d'::'a] ⟹ ch {a', b', c'::'a, d'}›*)
assume a'd'b': "[a'; d'; b']" (*‹[a'::'a;d'::'a;b'::'a]›*)
then have "[d'; b'; c']"
using abc_acd_bcd (*‹⟦[?a::'a;?b::'a;?c::'a]; [?a;?c;?d::'a]⟧ ⟹ [?b;?c;?d]›*) a'b'c' (*‹[a';b';c']›*) by blast
thus "?thesis"
(*goal: ‹ch {a', b', c', d'}›*)
using a'd'b' (*‹[a';d';b']›*) overlap_chain (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ ch {?a, ?b, ?c, ?d}›*) by (metis (full_types) insert_commute (*‹insert ?x (insert ?y ?A) = insert ?y (insert ?x ?A)›*))
next
(*goal: ‹[a';b';d'] ⟹ ch {a', b', c', d'}›*)
assume a'b'd': "[a'; b'; d']" (*‹[a'::'a;b'::'a;d'::'a]›*)
then have two_cases: "[b'; c'; d'] ∨ [b'; d'; c']"
using abc_abd_bcdbdc (*‹⟦[?a;?b;?c]; [?a;?b;?d]; ?c ≠ ?d⟧ ⟹ [?b;?c;?d] ∨ [?b;?d;?c]›*) a'b'c' (*‹[a';b';c']›*) d'_neq (*‹d' ≠ a' ∧ d' ≠ b' ∧ d' ≠ c'›*) by blast
have case1: "[b'; c'; d'] ⟹ ?thesis"
using a'b'c' (*‹[a';b';c']›*) overlap_chain (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ ch {?a, ?b, ?c, ?d}›*) by blast
have case2: "[b'; d'; c'] ⟹ ?thesis"
using abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) abc_acd_bcd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?b;?c;?d]›*) a'b'd' (*‹[a';b';d']›*) overlap_chain (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ ch {?a, ?b, ?c, ?d}›*) by (metis (full_types) insert_commute (*‹insert ?x (insert ?y ?A) = insert ?y (insert ?x ?A)›*))
show "?thesis"
(*goal: ‹ch {a', b', c', d'}›*)
using two_cases (*‹[b';c';d'] ∨ [b';d';c']›*) case1 (*‹[b';c';d'] ⟹ ch {a', b', c', d'}›*) case2 (*‹[b';d';c'] ⟹ ch {a', b', c', d'}›*) by blast
qed
have "{a',b',c',d'} = {a,b,c,d}"
proof (rule Set.set_eqI (*‹(⋀x::?'a::type. (x ∈ (?A::?'a::type set)) = (x ∈ (?B::?'a::type set))) ⟹ ?A = ?B›*), rule iffI (*‹⟦?P::bool ⟹ ?Q::bool; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))
(*goals:
1. ‹⋀x. x ∈ {a', b', c', d'} ⟹ x ∈ {a, b, c, d}›
2. ‹⋀x. x ∈ {a, b, c, d} ⟹ x ∈ {a', b', c', d'}›*)
fix x
assume "x ∈ {a',b',c',d'}" (*‹(x::'a) ∈ {a'::'a, b'::'a, c'::'a, d'::'a}›*)
thus "x ∈ {a,b,c,d}"
using a'_pick (*‹(a'::'a::type) ∈ {a::'a::type, b::'a::type, c::'a::type, d::'a::type}›*) b'_pick (*‹b' ∈ {a, b, c, d}›*) c'_pick (*‹c' ∈ {a, b, c, d}›*) d'_pick (*‹d' ∈ {a, b, c, d}›*) by auto
next
(*goal: ‹⋀x. x ∈ {a, b, c, d} ⟹ x ∈ {a', b', c', d'}›*)
fix x
assume x_pick: "x ∈ {a,b,c,d}" (*‹(x::'a) ∈ {a::'a, b::'a, c::'a, d::'a}›*)
have "a' ≠ b' ∧ a' ≠ c' ∧ a' ≠ d' ∧ b' ≠ c' ∧ c' ≠ d'"
using a'b'c' (*‹[a';b';c']›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) d'_neq (*‹(d'::'a) ≠ (a'::'a) ∧ d' ≠ (b'::'a) ∧ d' ≠ (c'::'a)›*) by blast
thus "x ∈ {a',b',c',d'}"
using a'_pick (*‹a' ∈ {a, b, c, d}›*) b'_pick (*‹b' ∈ {a, b, c, d}›*) c'_pick (*‹c' ∈ {a, b, c, d}›*) d'_pick (*‹(d'::'a) ∈ {a::'a, b::'a, c::'a, d::'a}›*) x_pick (*‹(x::'a::type) ∈ {a::'a::type, b::'a::type, c::'a::type, d::'a::type}›*) d'_neq (*‹(d'::'a) ≠ (a'::'a) ∧ d' ≠ (b'::'a) ∧ d' ≠ (c'::'a)›*) by auto
qed
thus "?thesis"
(*goal: ‹ch {a::'a, b::'a, c::'a, d::'a}›*)
using picked_chain (*‹ch {a', b', c', d'}›*) by simp
qed
theorem (*9*) chain4_alt:
assumes path_Q: "Q ∈ 𝒫"
and abcd_inQ: "{a,b,c,d} ⊆ Q"
and abcd_distinct: "card {a,b,c,d} = 4"
shows "ch {a,b,c,d}"
proof (-)
(*goal: ‹ch {a::'a, b::'a, c::'a, d::'a}›*)
have abcd_neq: "a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d"
using abcd_distinct (*‹card {a, b, c, d} = 4›*) numeral_3_eq_3 (*‹(3::nat) = Suc (Suc (Suc (0::nat)))›*) by (smt (z3) card_1_singleton_iff (*‹(card ?A = Suc 0) = (∃x. ?A = {x})›*) card_2_iff (*‹(card ?S = 2) = (∃x y. ?S = {x, y} ∧ x ≠ y)›*) card_3_dist (*‹(card {?x, ?y, ?z} = 3) = (?x ≠ ?y ∧ ?x ≠ ?z ∧ ?y ≠ ?z)›*) insert_absorb2 (*‹insert ?x (insert ?x ?A) = insert ?x ?A›*) insert_commute (*‹insert ?x (insert ?y ?A) = insert ?y (insert ?x ?A)›*) numeral_1_eq_Suc_0 (*‹Numeral1 = Suc 0›*) numeral_eq_iff (*‹(numeral ?m = numeral ?n) = (?m = ?n)›*) semiring_norm( (*‹(num.Bit0 ?m = num.One) = False›*) 85) semiring_norm( (*‹(num.Bit0 ?m = num.Bit1 ?n) = False›*) 88) verit_eq_simplify( (*‹(num.Bit0 ?x2.0 = num.Bit0 ?y2.0) = (?x2.0 = ?y2.0)›*) 8))
have inQ: "a ∈ Q" "b ∈ Q" "c ∈ Q" "d ∈ Q"
using abcd_inQ (*‹{a, b, c, d} ⊆ Q›*) apply -
(*goals:
1. ‹{a, b, c, d} ⊆ Q ⟹ a ∈ Q›
2. ‹{a, b, c, d} ⊆ Q ⟹ b ∈ Q›
3. ‹{a, b, c, d} ⊆ Q ⟹ c ∈ Q›
4. ‹{a, b, c, d} ⊆ Q ⟹ d ∈ Q›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*proven 4 subgoals*) .
show "?thesis"
(*goal: ‹ch {a, b, c, d}›*)
using chain4[OF assms ( 1 ) inQ] (*‹a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d ⟹ ch {a, b, c, d}›*) abcd_neq (*‹a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d›*) by simp
qed
end (* context MinkowskiSpacetime *)
section "Interlude - Chains, segments, rays"
context MinkowskiBetweenness begin
subsection "General results for chains"
lemma inf_chain_is_long:
assumes "[f↝X|x..]"
shows "local_long_ch_by_ord f X ∧ f 0 = x ∧ infinite X"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis assms (*‹[f::nat ⇒ 'a↝X::'a set|x::'a ..]›*) infinite_chain_alt (*‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) = (infinite ?Q ∧ local_ordering ?f betw ?Q)›*))
text ‹A reassurance that the starting point $x$ is implied.›
lemma long_inf_chain_is_semifin:
assumes "local_long_ch_by_ord f X ∧ infinite X"
shows "∃ x. [f↝X|x..]"
using assms (*‹local_long_ch_by_ord f X ∧ infinite X›*) infinite_chain_with_def (*‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x›*) chain_alts (*‹short_ch ?X = (∃x∈?X. ∃y∈?X. (∃Q. path Q x y) ∧ ¬ (∃z∈?X. z ≠ x ∧ z ≠ y))› ‹short_ch ?X = (∃x y. ?X = {x, y} ∧ (∃Q. path Q x y))› ‹local_long_ch_by_ord ?f ?X = (∃x∈?X. ∃y∈?X. ∃z∈?X. x ≠ y ∧ y ≠ z ∧ x ≠ z ∧ local_ordering ?f betw ?X)› ‹∃f. short_ch_by_ord f ?Q = short_ch ?Q› ‹infinite_chain ?f ?Q = (infinite ?Q ∧ local_ordering ?f betw ?Q)› ‹finite_chain ?f ?Q = (short_ch_by_ord ?f ?Q ∨ finite ?Q ∧ local_long_ch_by_ord ?f ?Q)› ‹[?f↝?Q|?x .. ?z] = ((short_ch_by_ord ?f ?Q ∨ 3 ≤ card ?Q ∧ local_ordering ?f betw ?Q) ∧ ?x = ?f 0 ∧ ?z = ?f (card ?Q - 1))› ‹[?f↝?Q|?x..?y..?z] = ([?f↝?Q|?x .. ?z] ∧ [?x;?y;?z] ∧ ?y ∈ ?Q)›*) by auto
lemma endpoint_in_semifin:
assumes "[f↝X|x..]"
shows "x∈X"
using zero_into_ordering_loc (*‹⟦local_ordering ?f ?betw ?X; ?X ≠ {}⟧ ⟹ ?f 0 ∈ ?X›*) by (metis assms (*‹[f↝X|x ..]›*) empty_iff (*‹(?c ∈ {}) = False›*) inf_chain_is_long (*‹[?f↝?X|?x ..] ⟹ local_long_ch_by_ord ?f ?X ∧ ?f 0 = ?x ∧ infinite ?X›*) local_long_ch_by_ord_alt (*‹local_long_ch_by_ord ?f ?X = (∃x∈?X. ∃y∈?X. ∃z∈?X. x ≠ y ∧ y ≠ z ∧ x ≠ z ∧ local_ordering ?f betw ?X)›*))
text ‹
Yet another corollary to Theorem 2, without indices, for arbitrary events on the chain.
›
corollary all_aligned_on_fin_chain:
assumes "[f↝X]" "finite X"
and x: "x∈X" and y: "y∈X" and z:"z∈X" and xy: "x≠y" and xz: "x≠z" and yz: "y≠z"
shows "[x;y;z] ∨ [x;z;y] ∨ [y;x;z]"
proof (-)
(*goal: ‹[x;y;z] ∨ [x;z;y] ∨ [y;x;z]›*)
have "card X ≥ 3"
using assms(2-5) (*‹finite X› ‹x ∈ X› ‹y ∈ X› ‹z ∈ X›*) three_subset[OF xy xz yz] (*‹{x, y, z} ⊆ ?X ⟹ 3 ≤ card ?X ∨ infinite ?X›*) by blast
hence 1: "local_long_ch_by_ord f X"
using assms(1,3-) (*‹[f↝X]› ‹x ∈ X› ‹y ∈ X› ‹z ∈ X› ‹x ≠ y› ‹x ≠ z› ‹y ≠ z›*) chain_defs (*‹short_ch (?X::'a::type set) ≡ card ?X = (2::nat) ∧ (∃P::'a::type set∈𝒫::'a::type set set. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis short_ch_alt( (*‹short_ch ?X = (∃x∈?X. ∃y∈?X. (∃Q. path Q x y) ∧ ¬ (∃z∈?X. z ≠ x ∧ z ≠ y))›*) 1) short_ch_card( (*‹short_ch_by_ord ?f ?Q ⟹ card ?Q = 2›*) 1) short_ch_card_2 (*‹[?f↝?X] ⟹ short_ch ?X = (card ?X = 2)›*))
obtain i and j and k where ijk: "x=f i" "i<card X" "y=f j" "j<card X" "z=f k" "k<card X"
(*goal: ‹(⋀i j k. ⟦x = f i; i < card X; y = f j; j < card X; z = f k; k < card X⟧ ⟹ thesis) ⟹ thesis›*)
using obtain_index_fin_chain (*‹⟦[?f::nat ⇒ 'a::type↝?X::'a::type set]; (?x::'a::type) ∈ ?X; finite ?X; ⋀i::nat. ⟦?f i = ?x; i < card ?X⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) assms(1-5) (*‹[f↝X]› ‹finite X› ‹x ∈ X› ‹y ∈ X› ‹z ∈ X›*) by metis
have 2: "[f i;f j;f k]" if "i<j ∧ j<k" "k<card X" for i and j and k
using assms (*‹[f↝X]› ‹finite X› ‹x ∈ X› ‹y ∈ X› ‹z ∈ X› ‹x ≠ y› ‹x ≠ z› ‹(y::'a) ≠ (z::'a)›*) order_finite_chain2 (*‹⟦[?f↝?X]; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) that(1,2) (*‹(i::nat) < (j::nat) ∧ j < (k::nat)› ‹(k::nat) < card (X::'a set)›*) by auto
consider "i<j ∧ j<k" | "i<k ∧ k<j" | "j<i ∧ i<k" | "i>j ∧ j>k" | "i>k ∧ k>j" | "j>i ∧ i>k"
(*goal: ‹⟦i < j ∧ j < k ⟹ thesis; i < k ∧ k < j ⟹ thesis; j < i ∧ i < k ⟹ thesis; j < i ∧ k < j ⟹ thesis; k < i ∧ j < k ⟹ thesis; i < j ∧ k < i ⟹ thesis⟧ ⟹ thesis›*)
using xy (*‹x ≠ y›*) xz (*‹x ≠ z›*) yz (*‹y ≠ z›*) ijk(1,3,5) (*‹x = f i› ‹y = f j› ‹z = f k›*) by (metis linorder_neqE_nat (*‹⟦?x ≠ ?y; ?x < ?y ⟹ ?R; ?y < ?x ⟹ ?R⟧ ⟹ ?R›*))
thus "?thesis"
(*goal: ‹[x;y;z] ∨ [x;z;y] ∨ [y;x;z]›*)
apply cases
(*goal: ‹[x;y;z] ∨ [x;z;y] ∨ [y;x;z]›*)
using "2" (*‹⟦?i < ?j ∧ ?j < ?k; ?k < card X⟧ ⟹ [f ?i;f ?j;f ?k]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) ijk (*‹x = f i› ‹(i::nat) < card (X::'a set)› ‹y = f j› ‹(j::nat) < card (X::'a set)› ‹z = f k› ‹k < card X›*) apply -
(*goals:
1. ‹⟦i < j ∧ j < k; ⋀i j k. ⟦i < j ∧ j < k; k < card X⟧ ⟹ [f i;f j;f k]; ⋀a b c. [a;b;c] ⟹ [c;b;a]; x = f i; i < card X; y = f j; j < card X; z = f k; k < card X⟧ ⟹ [x;y;z] ∨ [x;z;y] ∨ [y;x;z]›
2. ‹⟦i < k ∧ k < j; ⋀i j k. ⟦i < j ∧ j < k; k < card X⟧ ⟹ [f i;f j;f k]; ⋀a b c. [a;b;c] ⟹ [c;b;a]; x = f i; i < card X; y = f j; j < card X; z = f k; k < card X⟧ ⟹ [x;y;z] ∨ [x;z;y] ∨ [y;x;z]›
3. ‹⟦j < i ∧ i < k; ⋀i j k. ⟦i < j ∧ j < k; k < card X⟧ ⟹ [f i;f j;f k]; ⋀a b c. [a;b;c] ⟹ [c;b;a]; x = f i; i < card X; y = f j; j < card X; z = f k; k < card X⟧ ⟹ [x;y;z] ∨ [x;z;y] ∨ [y;x;z]›
4. ‹⟦j < i ∧ k < j; ⋀i j k. ⟦i < j ∧ j < k; k < card X⟧ ⟹ [f i;f j;f k]; ⋀a b c. [a;b;c] ⟹ [c;b;a]; x = f i; i < card X; y = f j; j < card X; z = f k; k < card X⟧ ⟹ [x;y;z] ∨ [x;z;y] ∨ [y;x;z]›
5. ‹⟦k < i ∧ j < k; ⋀i j k. ⟦i < j ∧ j < k; k < card X⟧ ⟹ [f i;f j;f k]; ⋀a b c. [a;b;c] ⟹ [c;b;a]; x = f i; i < card X; y = f j; j < card X; z = f k; k < card X⟧ ⟹ [x;y;z] ∨ [x;z;y] ∨ [y;x;z]›
6. ‹⟦i < j ∧ k < i; ⋀i j k. ⟦i < j ∧ j < k; k < card X⟧ ⟹ [f i;f j;f k]; ⋀a b c. [a;b;c] ⟹ [c;b;a]; x = f i; i < card X; y = f j; j < card X; z = f k; k < card X⟧ ⟹ [x;y;z] ∨ [x;z;y] ∨ [y;x;z]›
discuss goal 1*)
apply presburger
(*discuss goal 2*)
apply presburger
(*discuss goal 3*)
apply presburger
(*discuss goal 4*)
apply presburger
(*discuss goal 5*)
apply presburger
(*discuss goal 6*)
apply presburger
(*proven 6 subgoals*) .
qed
lemma (in MinkowskiPrimitive) card2_either_elt1_or_elt2:
assumes "card X = 2" and "x∈X" and "y∈X" and "x≠y"
and "z∈X" and "z≠x"
shows "z=y"
by (metis assms (*‹card X = 2› ‹x ∈ X› ‹y ∈ X› ‹x ≠ y› ‹z ∈ X› ‹z ≠ x›*) card_2_iff' (*‹(card ?S = 2) = (∃x∈?S. ∃y∈?S. x ≠ y ∧ (∀z∈?S. z = x ∨ z = y))›*))
(* potential misnomer: Schutz defines bounds only for infinite chains. *)
lemma get_fin_long_ch_bounds:
assumes "local_long_ch_by_ord f X"
and "finite X"
shows "∃x∈X. ∃y∈X. ∃z∈X. [f↝X|x..y..z]"
proof ((rule bexI (*‹⟦?P ?x; ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*))+)
(*goals:
1. ‹[f↝X|?x..?y3..?z6]›
2. ‹?z6 ∈ X›
3. ‹?y3 ∈ X›
4. ‹?x ∈ X›*)
show 1: "[f↝X|f 0..f 1..f (card X - 1)]"
using assms (*‹local_long_ch_by_ord f X› ‹finite X›*) unfolding finite_long_chain_with_def
(*goal: ‹[f↝X|f 0 .. f (card X - 1)] ∧ f 0 ≠ f 1 ∧ f 1 ≠ f (card X - 1) ∧ f 1 ∈ X›*)
using index_injective (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; ?i < ?j; ?j < card ?X⟧ ⟹ ?f ?i ≠ ?f ?j›*) by (auto simp: finite_chain_with_alt (*‹[?f↝?Q|?x .. ?z] = ((short_ch_by_ord ?f ?Q ∨ 3 ≤ card ?Q ∧ local_ordering ?f betw ?Q) ∧ ?x = ?f 0 ∧ ?z = ?f (card ?Q - 1))›*) local_long_ch_by_ord_def (*‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X›*) local_ordering_def (*‹local_ordering ?f ?ord ?X ≡ (∀n. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x∈?X. ∃n. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*))
show "f (card X - 1) ∈ X"
using "1" (*‹[f↝X|f 0..f 1..f (card X - 1)]›*) points_in_long_chain(3) (*‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type..?y::'a::type..?z::'a::type] ⟹ ?z ∈ ?Q›*) by auto
show "f 0 ∈ X" "f 1 ∈ X"
using "1" (*‹[f↝X|f 0..f 1..f (card X - 1)]›*) points_in_long_chain (*‹[?f↝?Q|?x..?y..?z] ⟹ ?x ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?y ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?z ∈ ?Q›*) apply -
(*goals:
1. ‹⟦[f↝X|f 0..f 1..f (card X - 1)]; ⋀f Q x y z. [f↝Q|x..y..z] ⟹ x ∈ Q; ⋀f Q x y z. [f↝Q|x..y..z] ⟹ y ∈ Q; ⋀f Q x y z. [f↝Q|x..y..z] ⟹ z ∈ Q⟧ ⟹ f 0 ∈ X›
2. ‹⟦[f↝X|f 0..f 1..f (card X - 1)]; ⋀f Q x y z. [f↝Q|x..y..z] ⟹ x ∈ Q; ⋀f Q x y z. [f↝Q|x..y..z] ⟹ y ∈ Q; ⋀f Q x y z. [f↝Q|x..y..z] ⟹ z ∈ Q⟧ ⟹ f 1 ∈ X›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
qed
lemma get_fin_long_ch_bounds2:
assumes "local_long_ch_by_ord f X"
and "finite X"
obtains x y z n⇩x n⇩y n⇩z
where "x∈X" "y∈X" "z∈X" "[f↝X|x..y..z]" "f n⇩x = x" "f n⇩y = y" "f n⇩z = z"
using get_fin_long_ch_bounds (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X⟧ ⟹ ∃x∈?X. ∃y∈?X. ∃z∈?X. [?f↝?X|x..y..z]›*) assms (*‹local_long_ch_by_ord f X› ‹finite X›*) by (meson finite_chain_with_def (*‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y›*) finite_long_chain_with_alt (*‹[?f↝?Q|?x..?y..?z] = ([?f↝?Q|?x .. ?z] ∧ [?x;?y;?z] ∧ ?y ∈ ?Q)›*) index_middle_element (*‹[?f↝?X|?a..?b..?c] ⟹ ∃n>0. n < card ?X - 1 ∧ ?f n = ?b›*))
lemma long_ch_card_ge3:
assumes "ch_by_ord f X" "finite X"
shows "local_long_ch_by_ord f X ⟷ card X ≥ 3"
using assms (*‹[f::nat ⇒ 'a↝X::'a set]› ‹finite X›*) ch_by_ord_def (*‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X›*) local_long_ch_by_ord_def (*‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X›*) short_ch_card(1) (*‹short_ch_by_ord ?f ?Q ⟹ card ?Q = 2›*) by auto
lemma fin_ch_betw2:
assumes "[f↝X|a..c]" and "b∈X"
obtains "b=a"|"b=c"|"[a;b;c]"
by (metis assms (*‹[f↝X|a .. c]› ‹b ∈ X›*) finite_long_chain_with_alt (*‹[?f↝?Q|?x..?y..?z] = ([?f↝?Q|?x .. ?z] ∧ [?x;?y;?z] ∧ ?y ∈ ?Q)›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*))
lemma chain_bounds_unique:
assumes "[f↝X|a..c]" "[g↝X|x..z]"
shows "(a=x ∧ c=z) ∨ (a=z ∧ c=x)"
using assms (*‹[f↝X|a .. c]› ‹[g↝X|x .. z]›*) points_in_chain (*‹[?f↝?Q|?x .. ?z] ⟹ ?x ∈ ?Q ∧ ?z ∈ ?Q›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by (metis (full_types) fin_ch_betw2 (*‹⟦[?f::nat ⇒ 'a↝?X::'a set|?a::'a .. ?c::'a]; (?b::'a) ∈ ?X; ?b = ?a ⟹ ?thesis::bool; ?b = ?c ⟹ ?thesis; [?a;?b;?c] ⟹ ?thesis⟧ ⟹ ?thesis›*))
end (* context MinkowskiBetweenness *)
subsection "Results for segments, rays and (sub)chains"
context MinkowskiBetweenness begin
lemma inside_not_bound:
assumes "[f↝X|a..c]"
and "j<card X"
shows "j>0 ⟹ f j ≠ a" "j<card X - 1 ⟹ f j ≠ c"
using index_injective2 (*‹⟦[?f↝?X]; finite ?X; ?i < ?j; ?j < card ?X⟧ ⟹ ?f ?i ≠ ?f ?j›*) assms (*‹[f↝X|a .. c]› ‹j < card X›*) finite_chain_def (*‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]›*) finite_chain_with_def (*‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y›*) apply metis
(*top goal: ‹0 < j ⟹ f j ≠ a› and 1 goal remains*)
using index_injective2 (*‹⟦[?f↝?X]; finite ?X; ?i < ?j; ?j < card ?X⟧ ⟹ ?f ?i ≠ ?f ?j›*) assms (*‹[f↝X|a .. c]› ‹j < card X›*) finite_chain_def (*‹finite_chain (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ finite ?Q ∧ [?f↝?Q]›*) finite_chain_with_def (*‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y›*) by auto
text ‹Converse to Theorem 2(i).›
lemma (in MinkowskiBetweenness) order_finite_chain_indices:
assumes chX: "local_long_ch_by_ord f X" "finite X"
and abc: "[a;b;c]"
and ijk: "f i = a" "f j = b" "f k = c" "i<card X" "j<card X" "k<card X"
shows "i<j ∧ j<k ∨ k<j ∧ j<i"
by (metis abc_abc_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_only_cba( (*‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?b;?a;?c]› ‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?a;?c;?b]› ‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?b;?c;?a]›*) 1,2,3) assms (*‹local_long_ch_by_ord (f::nat ⇒ 'a) (X::'a set)› ‹finite (X::'a set)› ‹[a::'a;b::'a;c::'a]› ‹(f::nat ⇒ 'a) (i::nat) = (a::'a)› ‹(f::nat ⇒ 'a) (j::nat) = (b::'a)› ‹(f::nat ⇒ 'a) (k::nat) = (c::'a)› ‹(i::nat) < card (X::'a set)› ‹(j::nat) < card (X::'a set)› ‹(k::nat) < card (X::'a set)›*) bot_nat_0.extremum (*‹(0::nat) ≤ (?a::nat)›*) linorder_neqE_nat (*‹⟦(?x::nat) ≠ (?y::nat); ?x < ?y ⟹ ?R::bool; ?y < ?x ⟹ ?R⟧ ⟹ ?R›*) order_finite_chain (*‹⟦local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set); finite ?X; (0::nat) ≤ (?i::nat) ∧ ?i < (?j::nat) ∧ ?j < (?l::nat) ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*))
lemma order_finite_chain_indices2:
assumes "[f↝X|a..c]"
and "f j = b" "j<card X"
obtains "0<j ∧ j<(card X - 1)"|"j=(card X - 1) ∧ b=c"|"j=0 ∧ b=a"
proof (-)
(*goal: ‹⟦0 < j ∧ j < card X - 1 ⟹ thesis; j = card X - 1 ∧ b = c ⟹ thesis; j = 0 ∧ b = a ⟹ thesis⟧ ⟹ thesis›*)
have finX: "finite X"
using assms(3) (*‹j < card X›*) card.infinite (*‹infinite ?A ⟹ card ?A = 0›*) gr_implies_not0 (*‹?m < ?n ⟹ ?n ≠ 0›*) by blast
have "b∈X"
using assms (*‹[f::nat ⇒ 'a↝X::'a set|a::'a .. c::'a]› ‹f j = b› ‹(j::nat) < card (X::'a set)›*) unfolding chain_defs local_ordering_def
(*goal: ‹b ∈ X›*)
by (metis One_nat_def (*‹1 = Suc 0›*) card_2_iff (*‹(card ?S = 2) = (∃x y. ?S = {x, y} ∧ x ≠ y)›*) insertI1 (*‹?a ∈ insert ?a ?B›*) insert_commute (*‹insert ?x (insert ?y ?A) = insert ?y (insert ?x ?A)›*) less_2_cases (*‹?n < 2 ⟹ ?n = 0 ∨ ?n = Suc 0›*))
have a: "f 0 = a" and c: "f (card X - 1) = c"
using assms(1) (*‹[f::nat ⇒ 'a↝X::'a set|a::'a .. c::'a]›*) finite_chain_with_def (*‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y›*) apply -
(*goals:
1. ‹⟦[f::nat ⇒ 'a↝X::'a set|a::'a .. c::'a]; ⋀(f::nat ⇒ 'a) (Q::'a set) (x::'a) y::'a. [f↝Q|x .. y] ≡ finite_chain f Q ∧ f (0::nat) = x ∧ f (card Q - (1::nat)) = y⟧ ⟹ f (0::nat) = a›
2. ‹⟦[f::nat ⇒ 'a↝X::'a set|a::'a .. c::'a]; ⋀(f::nat ⇒ 'a) (Q::'a set) (x::'a) y::'a. [f↝Q|x .. y] ≡ finite_chain f Q ∧ f (0::nat) = x ∧ f (card Q - (1::nat)) = y⟧ ⟹ f (card X - (1::nat)) = c›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
have "0<j ∧ j<(card X - 1) ∨ j=(card X - 1) ∧ b=c ∨ j=0 ∧ b=a"
proof (cases "short_ch_by_ord f X")
(*goals:
1. ‹short_ch_by_ord (f::nat ⇒ 'a) (X::'a set) ⟹ (0::nat) < (j::nat) ∧ j < card X - (1::nat) ∨ j = card X - (1::nat) ∧ (b::'a) = (c::'a) ∨ j = (0::nat) ∧ b = (a::'a)›
2. ‹¬ short_ch_by_ord (f::nat ⇒ 'a) (X::'a set) ⟹ (0::nat) < (j::nat) ∧ j < card X - (1::nat) ∨ j = card X - (1::nat) ∧ (b::'a) = (c::'a) ∨ j = (0::nat) ∧ b = (a::'a)›*)
case True (*‹short_ch_by_ord f X›*)
hence "X={a,c}"
using a (*‹(f::nat ⇒ 'a) (0::nat) = (a::'a)›*) assms(1) (*‹[f↝X|a .. c]›*) first_neq_last (*‹[?f↝?Q|?x .. ?z] ⟹ ?x ≠ ?z›*) points_in_chain (*‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a .. ?z::'a] ⟹ ?x ∈ ?Q ∧ ?z ∈ ?Q›*) short_ch_by_ord_def (*‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))›*) by fastforce
then consider "b=a" | "b=c"
(*goal: ‹⟦b = a ⟹ thesis; b = c ⟹ thesis⟧ ⟹ thesis›*)
using ‹b∈X› (*‹b ∈ X›*) by fastforce
thus "?thesis"
(*goal: ‹0 < j ∧ j < card X - 1 ∨ j = card X - 1 ∧ b = c ∨ j = 0 ∧ b = a›*)
apply cases
(*goal: ‹0 < j ∧ j < card X - 1 ∨ j = card X - 1 ∧ b = c ∨ j = 0 ∧ b = a›*)
using assms(2,3) (*‹(f::nat ⇒ 'a) (j::nat) = (b::'a)› ‹j < card X›*) a (*‹(f::nat ⇒ 'a) (0::nat) = (a::'a)›*) c (*‹f (card X - 1) = c›*) le_less (*‹((?x::?'a) ≤ (?y::?'a)) = (?x < ?y ∨ ?x = ?y)›*) apply -
(*goals:
1. ‹⟦b = a; f j = b; j < card X; f 0 = a; f (card X - 1) = c; ⋀x y. (x ≤ y) = (x < y ∨ x = y)⟧ ⟹ 0 < j ∧ j < card X - 1 ∨ j = card X - 1 ∧ b = c ∨ j = 0 ∧ b = a›
2. ‹⟦b = c; f j = b; j < card X; f 0 = a; f (card X - 1) = c; ⋀x y. (x ≤ y) = (x < y ∨ x = y)⟧ ⟹ 0 < j ∧ j < card X - 1 ∨ j = card X - 1 ∧ b = c ∨ j = 0 ∧ b = a›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply fastforce
(*proven 2 subgoals*) .
next
(*goal: ‹¬ short_ch_by_ord f X ⟹ 0 < j ∧ j < card X - 1 ∨ j = card X - 1 ∧ b = c ∨ j = 0 ∧ b = a›*)
case False (*‹¬ short_ch_by_ord f X›*)
hence chX: "local_long_ch_by_ord f X"
using assms(1) (*‹[f::nat ⇒ 'a↝X::'a set|a::'a .. c::'a]›*) unfolding finite_chain_with_alt
(*goal: ‹local_long_ch_by_ord (f::nat ⇒ 'a) (X::'a set)›*)
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by meson
consider "[a;b;c]" | "b=a" | "b=c"
(*goal: ‹⟦[a;b;c] ⟹ thesis; b = a ⟹ thesis; b = c ⟹ thesis⟧ ⟹ thesis›*)
using ‹b∈X› (*‹b ∈ X›*) assms(1) (*‹[f↝X|a .. c]›*) fin_ch_betw2 (*‹⟦[?f::nat ⇒ 'a::type↝?X::'a::type set|?a::'a::type .. ?c::'a::type]; (?b::'a::type) ∈ ?X; ?b = ?a ⟹ ?thesis::bool; ?b = ?c ⟹ ?thesis; [?a;?b;?c] ⟹ ?thesis⟧ ⟹ ?thesis›*) by blast
thus "?thesis"
(*goal: ‹0 < j ∧ j < card X - 1 ∨ j = card X - 1 ∧ b = c ∨ j = 0 ∧ b = a›*)
apply cases
(*goal: ‹(0::nat) < (j::nat) ∧ j < card (X::'a set) - (1::nat) ∨ j = card X - (1::nat) ∧ (b::'a) = (c::'a) ∨ j = (0::nat) ∧ b = (a::'a)›*)
using ‹f 0 = a› (*‹f 0 = a›*) chX (*‹local_long_ch_by_ord f X›*) finX (*‹finite X›*) assms(2,3) (*‹f j = b› ‹j < card X›*) a (*‹f 0 = a›*) c (*‹f (card X - 1) = c›*) order_finite_chain_indices (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; [?a;?b;?c]; ?f ?i = ?a; ?f ?j = ?b; ?f ?k = ?c; ?i < card ?X; ?j < card ?X; ?k < card ?X⟧ ⟹ ?i < ?j ∧ ?j < ?k ∨ ?k < ?j ∧ ?j < ?i›*) apply fastforce
(*top goal: ‹[a;b;c] ⟹ 0 < j ∧ j < card X - 1 ∨ j = card X - 1 ∧ b = c ∨ j = 0 ∧ b = a› and 2 goals remain*)
using ‹f 0 = a› (*‹(f::nat ⇒ 'a) (0::nat) = (a::'a)›*) chX (*‹local_long_ch_by_ord f X›*) finX (*‹finite X›*) assms(2,3) (*‹f j = b› ‹j < card X›*) index_injective (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; ?i < ?j; ?j < card ?X⟧ ⟹ ?f ?i ≠ ?f ?j›*) apply blast
(*top goal: ‹(b::'a) = (a::'a) ⟹ (0::nat) < (j::nat) ∧ j < card (X::'a set) - (1::nat) ∨ j = card X - (1::nat) ∧ b = (c::'a) ∨ j = (0::nat) ∧ b = a› and 1 goal remains*)
using a (*‹f 0 = a›*) c (*‹f (card X - 1) = c›*) assms (*‹[f↝X|a .. c]› ‹f j = b› ‹j < card X›*) chX (*‹local_long_ch_by_ord f X›*) finX (*‹finite X›*) index_injective (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; ?i < ?j; ?j < card ?X⟧ ⟹ ?f ?i ≠ ?f ?j›*) linorder_neqE_nat (*‹⟦(?x::nat) ≠ (?y::nat); ?x < ?y ⟹ ?R::bool; ?y < ?x ⟹ ?R⟧ ⟹ ?R›*) inside_not_bound(2) (*‹⟦[?f↝?X|?a .. ?c]; ?j < card ?X; ?j < card ?X - 1⟧ ⟹ ?f ?j ≠ ?c›*) by metis
qed
thus "?thesis"
(*goal: ‹thesis::bool›*)
using that (*‹0 < j ∧ j < card X - 1 ⟹ thesis› ‹j = card X - 1 ∧ b = c ⟹ thesis› ‹j = 0 ∧ b = a ⟹ thesis›*) by blast
qed
lemma index_bij_betw_subset:
assumes chX: "[f↝X|a..b..c]" "f i = b" "card X > i"
shows "bij_betw f {0<..<i} {e∈X. [a;e;b]}"
proof (unfold bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹inj_on f {0<..<i}›
2. ‹f ` {0<..<i} = {e ∈ X. [a;e;b]}›*)
have chX2: "local_long_ch_by_ord f X" "finite X"
using assms (*‹[f::nat ⇒ 'a↝X::'a set|a::'a..b::'a..c::'a]› ‹(f::nat ⇒ 'a::type) (i::nat) = (b::'a::type)› ‹i < card X›*) unfolding chain_defs
(*goals:
1. ‹(infinite X ∨ 3 ≤ card X) ∧ local_ordering f betw X›
2. ‹finite X›*)
apply (metis chX( (*‹[f↝X|a..b..c]›*) 1) abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*) points_in_long_chain( (*‹[?f↝?Q|?x..?y..?z] ⟹ ?x ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?z ∈ ?Q›*) 1,3) short_ch_alt( (*‹short_ch ?X = (∃x∈?X. ∃y∈?X. (∃Q. path Q x y) ∧ ¬ (∃z∈?X. z ≠ x ∧ z ≠ y))›*) 1) short_ch_path (*‹short_ch {?x, ?y} = (∃Q. path Q ?x ?y)›*))
(*top goal: ‹(infinite (X::'a set) ∨ (3::nat) ≤ card X) ∧ local_ordering (f::nat ⇒ 'a) betw X› and 1 goal remains*)
using assms (*‹[f↝X|a..b..c]› ‹f i = b› ‹i < card X›*) unfolding chain_defs
(*goal: ‹finite X›*)
by simp
from index_bij_betw[OF this] (*‹bij_betw f {0..<card X} X›*) have 1: "bij_betw f {0..<card X} X" .
have "{0<..<i} ⊂ {0..<card X}"
using assms(1,3) (*‹[f↝X|a..b..c]› ‹i < card X›*) unfolding chain_defs
(*goal: ‹{0<..<i} ⊂ {0..<card X}›*)
by fastforce
show "inj_on f {0<..<i}"
using "1" (*‹bij_betw f {0..<card X} X›*) assms(3) (*‹i < card X›*) unfolding bij_betw_def
(*goal: ‹inj_on (f::nat ⇒ 'a::type) {0::nat<..<i::nat}›*)
by (smt (z3) atLeastLessThan_empty_iff2 (*‹({} = {?a..<?b}) = (¬ ?a < ?b)›*) atLeastLessThan_iff (*‹(?i ∈ {?l..<?u}) = (?l ≤ ?i ∧ ?i < ?u)›*) empty_iff (*‹(?c ∈ {}) = False›*) greaterThanLessThan_iff (*‹(?i ∈ {?l<..<?u}) = (?l < ?i ∧ ?i < ?u)›*) inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) less_or_eq_imp_le (*‹?m < ?n ∨ ?m = ?n ⟹ ?m ≤ ?n›*))
show "f ` {0<..<i} = {e ∈ X. [a;e;b]}"
proof (standard)
(*goals:
1. ‹f ` {0<..<i} ⊆ {e ∈ X. [a;e;b]}›
2. ‹{e ∈ X. [a;e;b]} ⊆ f ` {0<..<i}›*)
show "f ` {0<..<i} ⊆ {e ∈ X. [a;e;b]}"
proof (auto simp add: image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⋀x. ⟦0 < x; x < i⟧ ⟹ f x ∈ X›
2. ‹⋀x. ⟦0 < x; x < i⟧ ⟹ [a;f x;b]›*)
fix j
assume asm: "j>0" "j<i" (*‹(0::nat) < (j::nat)› ‹(j::nat) < (i::nat)›*)
hence "j < card X"
using chX(3) (*‹i < card X›*) less_trans (*‹⟦?x < ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) by blast
thus "f j ∈ X" "[a;f j;b]"
using chX(1) (*‹[f↝X|a..b..c]›*) asm(1) (*‹0 < j›*) unfolding chain_defs local_ordering_def
(*goals:
1. ‹f j ∈ X›
2. ‹[a;f j;b]›*)
apply (metis chX2( (*‹local_long_ch_by_ord f X›*) 1) chX( (*‹[f↝X|a..b..c]›*) 1) fin_chain_card_geq_2 (*‹[?f↝?X|?a .. ?b] ⟹ 2 ≤ card ?X›*) short_ch_card_2 (*‹[?f↝?X] ⟹ short_ch ?X = (card ?X = 2)›*) short_xor_long( (*‹local_long_ch_by_ord ?f ?Q ⟹ ¬ short_ch ?Q›*) 2) le_antisym (*‹⟦?m ≤ ?n; ?n ≤ ?m⟧ ⟹ ?m = ?n›*) set_le_two (*‹card {?a, ?b} ≤ 2›*) finite_chain_def (*‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]›*) finite_chain_with_def (*‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y›*) finite_long_chain_with_alt (*‹[?f↝?Q|?x..?y..?z] = ([?f↝?Q|?x .. ?z] ∧ [?x;?y;?z] ∧ ?y ∈ ?Q)›*))
(*top goal: ‹f j ∈ X› and 1 goal remains*)
using chX (*‹[f↝X|a..b..c]› ‹f i = b› ‹i < card X›*) asm (*‹0 < j› ‹j < i›*) chX2(1) (*‹local_long_ch_by_ord f X›*) order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) unfolding chain_defs local_ordering_def
(*goal: ‹[a;f j;b]›*)
by force
qed
show "{e ∈ X. [a;e;b]} ⊆ f ` {0<..<i}"
proof (auto)
(*goal: ‹⋀x. ⟦x ∈ X; [a;x;b]⟧ ⟹ x ∈ f ` {0<..<i}›*)
fix e
assume e: "e ∈ X" "[a;e;b]" (*‹(e::'a) ∈ (X::'a set)› ‹[a::'a;e::'a;b::'a]›*)
obtain j where "f j = e" "j<card X"
(*goal: ‹(⋀j. ⟦f j = e; j < card X⟧ ⟹ thesis) ⟹ thesis›*)
using e (*‹e ∈ X› ‹[a;e;b]›*) chX2 (*‹local_long_ch_by_ord f X› ‹finite X›*) unfolding chain_defs local_ordering_def
(*goal: ‹(⋀j. ⟦f j = e; j < card X⟧ ⟹ thesis) ⟹ thesis›*)
by blast
show "e ∈ f ` {0<..<i}"
proof (standard)
(*goals:
1. ‹e = f ?x›
2. ‹?x ∈ {0<..<i}›*)
have "0<j∧j<i ∨ i<j∧j<0"
using order_finite_chain_indices (*‹⟦local_long_ch_by_ord (?f::nat ⇒ 'a::type) (?X::'a::type set); finite ?X; [?a::'a::type;?b::'a::type;?c::'a::type]; ?f (?i::nat) = ?a; ?f (?j::nat) = ?b; ?f (?k::nat) = ?c; ?i < card ?X; ?j < card ?X; ?k < card ?X⟧ ⟹ ?i < ?j ∧ ?j < ?k ∨ ?k < ?j ∧ ?j < ?i›*) chX (*‹[f::nat ⇒ 'a↝X::'a set|a::'a..b::'a..c::'a]› ‹f i = b› ‹i < card X›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (smt (z3) ‹f j = e› ‹j < card X› chX2( (*‹local_long_ch_by_ord (f::nat ⇒ 'a) (X::'a set)›*) 1) e( (*‹[a::'a;e::'a;b::'a]›*) 2) gr_implies_not_zero (*‹(?m::?'a) < (?n::?'a) ⟹ ?n ≠ (0::?'a)›*) linorder_neqE_nat (*‹⟦(?x::nat) ≠ (?y::nat); ?x < ?y ⟹ ?R::bool; ?y < ?x ⟹ ?R⟧ ⟹ ?R›*))
hence "j<i"
by simp
thus "j∈{0<..<i}" "e = f j"
using ‹0 < j ∧ j < i ∨ i < j ∧ j < 0› (*‹0 < j ∧ j < i ∨ i < j ∧ j < 0›*) greaterThanLessThan_iff (*‹((?i::?'a) ∈ {?l::?'a<..<?u::?'a}) = (?l < ?i ∧ ?i < ?u)›*)
(*goals:
1. ‹j ∈ {0<..<i}›
2. ‹e = f j›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply (simp add: ‹f j = e›)
(*proven 2 subgoals*) .
qed
qed
qed
qed
lemma bij_betw_extend:
assumes "bij_betw f A B"
and "f a = b" "a∉A" "b∉B"
shows "bij_betw f (insert a A) (insert b B)"
by (smt (verit, ccfv_SIG) assms( (*‹bij_betw f A B›*) 1) assms( (*‹f a = b›*) 2) assms( (*‹b ∉ B›*) 4) bij_betwI' (*‹⟦⋀x y. ⟦x ∈ ?X; y ∈ ?X⟧ ⟹ (?f x = ?f y) = (x = y); ⋀x. x ∈ ?X ⟹ ?f x ∈ ?Y; ⋀y. y ∈ ?Y ⟹ ∃x∈?X. y = ?f x⟧ ⟹ bij_betw ?f ?X ?Y›*) bij_betw_iff_bijections (*‹bij_betw ?f ?A ?B = (∃g. (∀x∈?A. ?f x ∈ ?B ∧ g (?f x) = x) ∧ (∀y∈?B. g y ∈ ?A ∧ ?f (g y) = y))›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*))
lemma insert_iff2:
assumes "a∈X" shows "insert a {x∈X. P x} = {x∈X. P x ∨ x=a}"
using insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) assms (*‹a ∈ X›*) by blast
lemma index_bij_betw_subset2:
assumes chX: "[f↝X|a..b..c]" "f i = b" "card X > i"
shows "bij_betw f {0..i} {e∈X. [a;e;b]∨a=e∨b=e}"
proof (-)
(*goal: ‹bij_betw (f::nat ⇒ 'a) {0::nat..i::nat} {e::'a ∈ X::'a set. [a::'a;e;b::'a] ∨ a = e ∨ b = e}›*)
have "bij_betw f {0<..<i} {e∈X. [a;e;b]}"
using index_bij_betw_subset[OF assms] (*‹bij_betw f {0<..<i} {e ∈ X. [a;e;b]}›*) .
moreover have "0∉{0<..<i}" "i∉{0<..<i}"
(*goals:
1. ‹0 ∉ {0<..<i}›
2. ‹i ∉ {0<..<i}›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
moreover have "a∉{e∈X. [a;e;b]}" "b∉{e∈X. [a;e;b]}"
using abc_abc_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) apply -
(*goals:
1. ‹(⋀a b c. [a;b;c] ⟹ a ≠ b ∧ a ≠ c ∧ b ≠ c) ⟹ a ∉ {e ∈ X. [a;e;b]}›
2. ‹(⋀a b c. [a;b;c] ⟹ a ≠ b ∧ a ≠ c ∧ b ≠ c) ⟹ b ∉ {e ∈ X. [a;e;b]}›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
moreover have "f 0 = a" "f i = b"
using assms (*‹[f↝X|a..b..c]› ‹f i = b› ‹i < card X›*) unfolding chain_defs
(*goals:
1. ‹f 0 = a›
2. ‹f i = b›*)
apply -
(*goals:
1. ‹⟦((finite X ∧ (X = {f 0, f 1} ∧ (∃Q. path Q (f 0) (f 1)) ∨ (infinite X ∨ 3 ≤ card X) ∧ local_ordering f betw X)) ∧ f 0 = a ∧ f (card X - 1) = c) ∧ a ≠ b ∧ b ≠ c ∧ b ∈ X; f i = b; i < card X⟧ ⟹ f 0 = a›
2. ‹⟦((finite X ∧ (X = {f 0, f 1} ∧ (∃Q. path Q (f 0) (f 1)) ∨ (infinite X ∨ 3 ≤ card X) ∧ local_ordering f betw X)) ∧ f 0 = a ∧ f (card X - 1) = c) ∧ a ≠ b ∧ b ≠ c ∧ b ∈ X; f i = b; i < card X⟧ ⟹ f i = b›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
moreover have "(insert b (insert a {e∈X. [a;e;b]})) = {e∈X. [a;e;b]∨a=e∨b=e}"
proof (-)
(*goal: ‹insert b (insert a {e ∈ X. [a;e;b]}) = {e ∈ X. [a;e;b] ∨ a = e ∨ b = e}›*)
have 1: "(insert a {e∈X. [a;e;b]}) = {e∈X. [a;e;b]∨a=e}"
using insert_iff2[OF points_in_long_chain ( 1 ) [ OF chX ( 1 ) ]] (*‹insert a {x ∈ X. ?P x} = {x ∈ X. ?P x ∨ x = a}›*) by auto
have "b∉{e∈X. [a;e;b]∨a=e}"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) chX(1) (*‹[f↝X|a..b..c]›*) fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*) by fastforce
thus "(insert b (insert a {e∈X. [a;e;b]})) = {e∈X. [a;e;b]∨a=e∨b=e}"
using "1" (*‹insert (a::'a) {e::'a ∈ X::'a set. [a;e;b::'a]} = {e::'a ∈ X. [a;e;b] ∨ a = e}›*) insert_iff2 (*‹?a ∈ ?X ⟹ insert ?a {x ∈ ?X. ?P x} = {x ∈ ?X. ?P x ∨ x = ?a}›*) points_in_long_chain(2)[OF chX ( 1 )] (*‹b ∈ X›*) by auto
qed
moreover have "(insert i (insert 0 {0<..<i})) = {0..i}"
using image_Suc_lessThan (*‹Suc ` {..<?n} = {1..?n}›*) by auto
ultimately show "?thesis"
(*goal: ‹bij_betw f {0..i} {e ∈ X. [a;e;b] ∨ a = e ∨ b = e}›*)
using bij_betw_extend[of f] (*‹⟦bij_betw f ?A ?B; f ?a = ?b; ?a ∉ ?A; ?b ∉ ?B⟧ ⟹ bij_betw f (insert ?a ?A) (insert ?b ?B)›*) by (metis (no_types, lifting) chX( (*‹[f↝X|a..b..c]›*) 1) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*))
qed
lemma chain_shortening:
assumes "[f↝X|a..b..c]"
shows "[f ↝ {e∈X. [a;e;b] ∨ e=a ∨ e=b} |a..b]"
proof (unfold finite_chain_with_def finite_chain_def, (intro conjI))
text ‹Different forms of assumptions for compatibility with needed antecedents later.›
show "f 0 = a" using assms unfolding chain_defs by simp
have chX: "local_long_ch_by_ord f X"
using assms first_neq_last points_in_long_chain(1,3) short_ch_card(1) chain_defs
by (metis card2_either_elt1_or_elt2)
have finX: "finite X"
by (meson assms chain_defs)
text ‹General facts about the shortened set, which we will call Y.›
let ?Y = "{e∈X. [a;e;b] ∨ e=a ∨ e=b}"
show finY: "finite ?Y"
using assms finite_chain_def finite_chain_with_def finite_long_chain_with_alt by auto
have "a≠b" "a∈?Y" "b∈?Y" "c∉?Y"
using assms finite_long_chain_with_def apply simp
using assms points_in_long_chain(1,2) apply auto[1]
using assms points_in_long_chain(2) apply auto[1]
using abc_ac_neq abc_only_cba(2) assms fin_ch_betw by fastforce
from this(1-3) finY have cardY: "card ?Y ≥ 2"
by (metis (no_types, lifting) card_le_Suc0_iff_eq not_less_eq_eq numeral_2_eq_2)
text ‹Obtain index for ‹b› (‹a› is at index ‹0›): this index ‹i› is ‹card ?Y - 1›.›
obtain i where i: "i<card X" "f i=b"
using assms unfolding chain_defs local_ordering_def using Suc_leI diff_le_self by force
hence "i<card X - 1"
using assms unfolding chain_defs
by (metis Suc_lessI diff_Suc_Suc diff_Suc_eq_diff_pred minus_nat.diff_0 zero_less_diff)
have card01: "i+1 = card {0..i}" by simp
have bb: "bij_betw f {0..i} ?Y" using index_bij_betw_subset2[OF assms i(2,1)] Collect_cong by smt
hence i_eq: "i = card ?Y - 1" using bij_betw_same_card by force
thus "f (card ?Y - 1) = b" using i(2) by simp
text ‹The path ‹P› on which ‹X› lies. If ‹?Y› has two arguments, ‹P› makes it a short chain.›
obtain P where P_def: "P∈𝒫" "X⊆P" "⋀Q. Q∈𝒫 ∧ X⊆Q ⟹ Q=P"
using fin_chain_on_path[of f X] assms unfolding chain_defs by force
have "a∈P" "b∈P" using P_def by (meson assms in_mono points_in_long_chain)+
consider (eq_1)"i=1"|(gt_1)"i>1" using ‹a ≠ b› ‹f 0 = a› i(2) less_linear by blast
thus "[f↝?Y]"
proof (cases)
case eq_1
hence "{0..i}={0,1}" by auto
hence "bij_betw f {0,1} ?Y" using bb by auto
from bij_betw_imp_surj_on[OF this] show ?thesis
unfolding chain_defs using P_def eq_1 ‹a ≠ b› ‹f 0 = a› i(2) by blast
next
case gt_1
have 1: "3≤card ?Y" using gt_1 cardY i_eq by linarith
{
fix n assume "n < card ?Y"
hence "n<card X"
using ‹i<card X - 1› add_diff_inverse_nat i_eq nat_diff_split_asm by linarith
have "f n ∈ ?Y"
proof (simp, intro conjI)
show "f n ∈ X"
using ‹n<card X› assms chX chain_defs local_ordering_def by metis
consider "0<n ∧ n<card ?Y - 1"|"n=card ?Y - 1"|"n=0"
using ‹n<card ?Y› nat_less_le zero_less_diff by linarith
thus "[a;f n;b] ∨ f n = a ∨ f n = b"
using i i_eq ‹f 0 = a› chX finX le_numeral_extra(3) order_finite_chain by fastforce
qed
} moreover {
fix x assume "x∈?Y" hence "x∈X" by simp
obtain i⇩x where i⇩x: "i⇩x < card X" "f i⇩x = x"
using assms obtain_index_fin_chain chain_defs ‹x∈X› by metis
have "i⇩x < card ?Y"
proof -
consider "[a;x;b]"|"x=a"|"x=b" using ‹x∈?Y› by auto
hence "(i⇩x<i ∨ i⇩x<0) ∨ i⇩x=0 ∨ i⇩x=i"
apply cases
apply (metis ‹f 0=a› chX finX i i⇩x less_nat_zero_code neq0_conv order_finite_chain_indices)
using ‹f 0 = a› chX finX i⇩x index_injective apply blast
by (metis chX finX i(2) i⇩x index_injective linorder_neqE_nat)
thus ?thesis using gt_1 i_eq by linarith
qed
hence "∃n. n < card ?Y ∧ f n = x" using i⇩x(2) by blast
} moreover {
fix n assume "Suc (Suc n) < card ?Y"
hence "Suc (Suc n) < card X"
using i(1) i_eq by linarith
hence "[f n; f (Suc n); f (Suc (Suc n))]"
using assms unfolding chain_defs local_ordering_def by auto
}
ultimately have 2: "local_ordering f betw ?Y"
by (simp add: local_ordering_def finY)
show ?thesis using 1 2 chain_defs by blast
qed
qed
corollary ord_fin_ch_right:
assumes "[f↝X|a..f i..c]" "j≥i" "j<card X"
shows "[f i;f j;c] ∨ j = card X - 1 ∨ j = i"
proof (-)
(*goal: ‹[f i;f j;c] ∨ j = card X - 1 ∨ j = i›*)
consider (inter)"j>i ∧ j<card X - 1" | (left)"j=i" | (right)"j=card X - 1"
(*goal: ‹⟦i < j ∧ j < card X - 1 ⟹ thesis; j = i ⟹ thesis; j = card X - 1 ⟹ thesis⟧ ⟹ thesis›*)
using assms(3,2) (*‹j < card X› ‹i ≤ j›*) by linarith
thus "?thesis"
(*goal: ‹[f i;f j;c] ∨ j = card X - 1 ∨ j = i›*)
apply cases
(*goal: ‹[(f::nat ⇒ 'a) (i::nat);f (j::nat);c::'a] ∨ j = card (X::'a set) - (1::nat) ∨ j = i›*)
using assms(1) (*‹[f↝X|a..f i..c]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) order_finite_chain2 (*‹⟦[?f↝?X]; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*)
(*goals:
1. ‹i < j ∧ j < card X - 1 ⟹ [f i;f j;c] ∨ j = card X - 1 ∨ j = i›
2. ‹j = i ⟹ [f i;f j;c] ∨ j = card X - 1 ∨ j = i›
3. ‹j = card X - 1 ⟹ [f i;f j;c] ∨ j = card X - 1 ∨ j = i›
discuss goal 1*)
apply force
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*) .
qed
lemma f_img_is_subset:
assumes "[f↝X|(f 0) ..]" "i≥0" "j>i" "Y=f`{i..j}"
shows "Y⊆X"
proof (standard)
(*goal: ‹⋀x. x ∈ Y ⟹ x ∈ X›*)
fix x
assume "x∈Y" (*‹(x::'a) ∈ (Y::'a set)›*)
then obtain n where "n∈{i..j}" "f n = x"
(*goal: ‹(⋀n. ⟦n ∈ {i..j}; f n = x⟧ ⟹ thesis) ⟹ thesis›*)
using assms(4) (*‹Y = f ` {i..j}›*) by blast
hence "f n ∈ X"
by (metis local_ordering_def (*‹local_ordering ?f ?ord ?X ≡ (∀n. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x∈?X. ∃n. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) assms( (*‹[f↝X|f 0 ..]›*) 1) inf_chain_is_long (*‹[?f↝?X|?x ..] ⟹ local_long_ch_by_ord ?f ?X ∧ ?f 0 = ?x ∧ infinite ?X›*) local_long_ch_by_ord_def (*‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X›*))
thus "x∈X"
using ‹f n = x› (*‹f n = x›*) by blast
qed
lemma i_le_j_events_neq:
assumes "[f↝X|a..b..c]"
and "i<j" "j<card X"
shows "f i ≠ f j"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f::nat ⇒ 'a↝?X::'a set] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (meson assms (*‹[f↝X|a..b..c]› ‹i < j› ‹j < card X›*) index_injective2 (*‹⟦[?f↝?X]; finite ?X; ?i < ?j; ?j < card ?X⟧ ⟹ ?f ?i ≠ ?f ?j›*))
lemma indices_neq_imp_events_neq:
assumes "[f↝X|a..b..c]"
and "i≠j" "j<card X" "i<card X"
shows "f i ≠ f j"
by (metis assms (*‹[f↝X|a..b..c]› ‹i ≠ j› ‹j < card X› ‹i < card X›*) i_le_j_events_neq (*‹⟦[?f↝?X|?a..?b..?c]; ?i < ?j; ?j < card ?X⟧ ⟹ ?f ?i ≠ ?f ?j›*) less_linear (*‹?x < ?y ∨ ?x = ?y ∨ ?y < ?x›*))
end (* context MinkowskiChain *)
context MinkowskiSpacetime begin
lemma bound_on_path:
assumes "Q∈𝒫" "[f↝X|(f 0)..]" "X⊆Q" "is_bound_f b X f"
shows "b∈Q"
proof (-)
(*goal: ‹b ∈ Q›*)
obtain a and c where "a∈X" "c∈X" "[a;c;b]"
(*goal: ‹(⋀(a::'a::type) c::'a::type. ⟦a ∈ (X::'a::type set); c ∈ X; [a;c;b::'a::type]⟧ ⟹ thesis::bool) ⟹ thesis›*)
using assms(4) (*‹is_bound_f b X f›*) by (metis local_ordering_def (*‹local_ordering (?f::nat ⇒ ?'a::type) (?ord::?'a::type ⇒ ?'a::type ⇒ ?'a::type ⇒ bool) (?X::?'a::type set) ≡ (∀n::nat. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x::?'a::type∈?X. ∃n::nat. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n::nat. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) inf_chain_is_long (*‹[?f::nat ⇒ 'a::type↝?X::'a::type set|?x::'a::type ..] ⟹ local_long_ch_by_ord ?f ?X ∧ ?f (0::nat) = ?x ∧ infinite ?X›*) is_bound_f_def (*‹is_bound_f (?Q⇩b::'a::type) (?Q::'a::type set) (?f::nat ⇒ 'a::type) ≡ ∀(i::nat) j::nat. [?f↝?Q|?f (0::nat) ..] ∧ (i < j ⟶ [?f i;?f j;?Q⇩b])›*) local_long_ch_by_ord_def (*‹local_long_ch_by_ord (?f::nat ⇒ 'a::type) (?X::'a::type set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X›*) zero_less_one (*‹(0::?'a::zero_less_one) < (1::?'a::zero_less_one)›*))
thus "?thesis"
(*goal: ‹(b::'a) ∈ (Q::'a set)›*)
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) assms(1) (*‹Q ∈ 𝒫›*) assms(3) (*‹X ⊆ Q›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) by blast
qed
lemma pro_basis_change:
assumes "[a;b;c]"
shows "prolongation a c = prolongation b c" (is "?ac=?bc")
proof (standard)
(*goals:
1. ‹prolongation a c ⊆ prolongation b c›
2. ‹prolongation b c ⊆ prolongation a c›*)
show "?ac ⊆ ?bc"
proof (standard)
(*goal: ‹⋀x. x ∈ prolongation a c ⟹ x ∈ prolongation b c›*)
fix x
assume "x∈?ac" (*‹(x::'a) ∈ prolongation (a::'a) (c::'a)›*)
hence "[a;c;x]"
by (simp add: pro_betw (*‹((?x::'a) ∈ prolongation (?a::'a) (?b::'a)) = [?a;?b;?x]›*))
hence "[b;c;x]"
using assms (*‹[a;b;c]›*) abc_acd_bcd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?b;?c;?d]›*) by blast
thus "x∈?bc"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*) by blast
qed
show "?bc ⊆ ?ac"
proof (standard)
(*goal: ‹⋀x. x ∈ prolongation b c ⟹ x ∈ prolongation a c›*)
fix x
assume "x∈?bc" (*‹(x::'a) ∈ prolongation (b::'a) (c::'a)›*)
hence "[b;c;x]"
by (simp add: pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*))
hence "[a;c;x]"
using assms (*‹[a;b;c]›*) abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) by blast
thus "x∈?ac"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) pro_betw (*‹((?x::'a) ∈ prolongation (?a::'a) (?b::'a)) = [?a;?b;?x]›*) by blast
qed
qed
lemma adjoining_segs_exclusive:
assumes "[a;b;c]"
shows "segment a b ∩ segment b c = {}"
proof (cases)
(*goals:
1. ‹?P ⟹ segment a b ∩ segment b c = {}›
2. ‹¬ ?P ⟹ segment a b ∩ segment b c = {}›*)
assume "segment a b = {}" (*‹segment (a::'a) (b::'a) = {}›*)
thus "?thesis"
(*goal: ‹segment a b ∩ segment b c = {}›*)
by blast
next
(*goal: ‹segment a b ≠ {} ⟹ segment a b ∩ segment b c = {}›*)
assume "segment a b ≠ {}" (*‹segment (a::'a) (b::'a) ≠ {}›*)
have "x∈segment a b ⟶ x∉segment b c" for x
proof (standard)
(*goal: ‹x ∈ segment a b ⟹ x ∉ segment b c›*)
fix x
assume "x∈segment a b" (*‹(x::'a) ∈ segment (a::'a) (b::'a)›*)
hence "[a;x;b]"
by (simp add: seg_betw (*‹((?x::'a) ∈ segment (?a::'a) (?b::'a)) = [?a;?x;?b]›*))
have "¬[a;b;x]"
by (meson ‹[a;x;b]› abc_only_cba (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ¬ [?b;?a;?c]› ‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ¬ [?a;?c;?b]› ‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ¬ [?b;?c;?a]› ‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ¬ [?c;?a;?b]›*))
have "¬[b;x;c]"
using ‹¬ [a;b;x]› (*‹¬ [a;b;x]›*) abd_bcd_abc (*‹⟦[?a::'a;?b::'a;?d::'a]; [?b;?c::'a;?d]⟧ ⟹ [?a;?b;?c]›*) assms (*‹[a;b;c]›*) by blast
thus "x∉segment b c"
by (simp add: seg_betw (*‹((?x::'a::type) ∈ segment (?a::'a::type) (?b::'a::type)) = [?a;?x;?b]›*))
qed
thus "?thesis"
(*goal: ‹segment a b ∩ segment b c = {}›*)
by blast
qed
end (* context MinkowskiSpacetime *)
section "3.6 Order on a path - Theorems 10 and 11"
context MinkowskiSpacetime begin
subsection ‹Theorem 10 (based on Veblen (1904) theorem 10).›
lemma (in MinkowskiBetweenness) two_event_chain:
assumes finiteX: "finite X"
and path_Q: "Q ∈ 𝒫"
and events_X: "X ⊆ Q"
and card_X: "card X = 2"
shows "ch X"
proof (-)
(*goal: ‹ch X›*)
obtain a and b where X_is: "X={a,b}"
(*goal: ‹(⋀a b. X = {a, b} ⟹ thesis) ⟹ thesis›*)
using card_le_Suc_iff (*‹(Suc ?n ≤ card ?A) = (∃a B. ?A = insert a B ∧ a ∉ B ∧ ?n ≤ card B ∧ finite B)›*) numeral_2_eq_2 (*‹(2::nat) = Suc (Suc (0::nat))›*) by (meson card_2_iff (*‹(card (?S::?'a set) = (2::nat)) = (∃(x::?'a) y::?'a. ?S = {x, y} ∧ x ≠ y)›*) card_X (*‹card (X::'a set) = (2::nat)›*))
have no_c: "¬(∃c∈{a,b}. c≠a ∧ c≠b)"
by blast
have "a≠b ∧ a∈Q & b∈Q"
using X_is (*‹X = {a, b}›*) card_X (*‹card (X::'a::type set) = (2::nat)›*) events_X (*‹(X::'a set) ⊆ (Q::'a set)›*) by force
hence "short_ch {a,b}"
using path_Q (*‹Q ∈ 𝒫›*) no_c (*‹¬ (∃c∈{a, b}. c ≠ a ∧ c ≠ b)›*) by (meson short_ch_intros( (*‹⟦?X = {?x, ?y}; ∃Q. path Q ?x ?y⟧ ⟹ short_ch ?X›*) 2))
thus "?thesis"
(*goal: ‹ch X›*)
by (simp add: X_is (*‹X = {a, b}›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*))
qed
lemma (in MinkowskiBetweenness) three_event_chain:
assumes finiteX: "finite X"
and path_Q: "Q ∈ 𝒫"
and events_X: "X ⊆ Q"
and card_X: "card X = 3"
shows "ch X"
proof (-)
(*goal: ‹ch X›*)
obtain a and b and c where X_is: "X={a,b,c}"
(*goal: ‹(⋀a b c. X = {a, b, c} ⟹ thesis) ⟹ thesis›*)
using numeral_3_eq_3 (*‹(3::nat) = Suc (Suc (Suc (0::nat)))›*) card_X (*‹card (X::'a::type set) = (3::nat)›*) by (metis card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*))
then have all_neq: "a≠b ∧ a≠c ∧ b≠c"
using card_X (*‹card X = 3›*) numeral_2_eq_2 (*‹2 = Suc (Suc 0)›*) numeral_3_eq_3 (*‹3 = Suc (Suc (Suc 0))›*) by (metis Suc_n_not_le_n (*‹¬ Suc ?n ≤ ?n›*) insert_absorb2 (*‹insert ?x (insert ?x ?A) = insert ?x ?A›*) insert_commute (*‹insert ?x (insert ?y ?A) = insert ?y (insert ?x ?A)›*) set_le_two (*‹card {?a, ?b} ≤ 2›*))
have in_path: "a∈Q ∧ b∈Q ∧ c∈Q"
using X_is (*‹X = {a, b, c}›*) events_X (*‹X ⊆ Q›*) by blast
hence "[a;b;c] ∨ [b;c;a] ∨ [c;a;b]"
using some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) all_neq (*‹a ≠ b ∧ a ≠ c ∧ b ≠ c›*) path_Q (*‹(Q::'a set) ∈ (𝒫::'a set set)›*) by auto
thus "ch X"
using between_chain (*‹[?a;?b;?c] ⟹ ch {?a, ?b, ?c}›*) X_is (*‹X = {a, b, c}›*) all_neq (*‹a ≠ b ∧ a ≠ c ∧ b ≠ c›*) chain3 (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c⟧ ⟹ ch {?a, ?b, ?c}›*) in_path (*‹a ∈ Q ∧ b ∈ Q ∧ c ∈ Q›*) path_Q (*‹(Q::'a set) ∈ (𝒫::'a set set)›*) by auto
qed
text ‹This is case (i) of the induction in Theorem 10.›
lemma (*for 10*) chain_append_at_left_edge:
assumes long_ch_Y: "[f↝Y|a₁..a..a⇩n]"
and bY: "[b; a₁; a⇩n]"
fixes g defines g_def: "g ≡ (λj::nat. if j≥1 then f (j-1) else b)"
shows "[g↝(insert b Y)|b .. a₁ .. a⇩n]"
proof -
let ?X = "insert b Y"
have ord_fY: "local_ordering f betw Y" using long_ch_Y finite_long_chain_with_card chain_defs
by (meson long_ch_card_ge3)
have "b∉Y"
using abc_ac_neq abc_only_cba(1) assms by (metis fin_ch_betw2 finite_long_chain_with_alt)
have bound_indices: "f 0 = a₁ ∧ f (card Y - 1) = a⇩n"
using long_ch_Y by (simp add: chain_defs)
have fin_Y: "card Y ≥ 3"
using finite_long_chain_with_def long_ch_Y numeral_2_eq_2 points_in_long_chain
by (metis abc_abc_neq bY card2_either_elt1_or_elt2 fin_chain_card_geq_2 leI le_less_Suc_eq numeral_3_eq_3)
hence num_ord: "0 ≤ (0::nat) ∧ 0<(1::nat) ∧ 1 < card Y - 1 ∧ card Y - 1 < card Y"
by linarith
hence "[a₁; f 1; a⇩n]"
using order_finite_chain chain_defs long_ch_Y
by auto
text ‹Schutz has a step here that says $[b a_1 a_2 a_n]$ is a chain (using Theorem 9).
We have no easy way (yet) of denoting an ordered 4-element chain, so we skip this step
using a \<^term>‹local_ordering› lemma from our script for 3.6, which Schutz doesn't list.›
hence "[b; a₁; f 1]"
using bY abd_bcd_abc by blast
have "local_ordering g betw ?X"
proof -
{
fix n assume "finite ?X ⟶ n<card ?X"
have "g n ∈ ?X"
apply (cases "n≥1")
prefer 2 apply (simp add: g_def)
proof
assume "1≤n" "g n ∉ Y"
hence "g n = f(n-1)" unfolding g_def by auto
hence "g n ∈ Y"
proof (cases "n = card ?X - 1")
case True
thus ?thesis
using ‹b∉Y› card.insert diff_Suc_1 long_ch_Y points_in_long_chain chain_defs
by (metis ‹g n = f (n - 1)›)
next
case False
hence "n < card Y"
using points_in_long_chain ‹finite ?X ⟶ n < card ?X› ‹g n = f (n - 1)› ‹g n ∉ Y› ‹b∉Y› chain_defs
by (metis card.insert finite_insert long_ch_Y not_less_simps(1))
hence "n-1 < card Y - 1"
using ‹1 ≤ n› diff_less_mono by blast
hence "f(n-1)∈Y"
using long_ch_Y fin_Y unfolding chain_defs local_ordering_def
by (metis Suc_le_D card_3_dist diff_Suc_1 insert_absorb2 le_antisym less_SucI numeral_3_eq_3 set_le_three)
thus ?thesis
using ‹g n = f (n - 1)› by presburger
qed
hence False using ‹g n ∉ Y› by auto
thus "g n = b" by simp
qed
} moreover {
fix n assume "(finite ?X ⟶ Suc(Suc n) < card ?X)"
hence "[g n; g (Suc n); g (Suc(Suc n))]"
apply (cases "n≥1")
using ‹b∉Y› ‹[b; a₁; f 1]› g_def ordering_ord_ijk_loc[OF ord_fY] fin_Y
apply (metis Suc_diff_le card_insert_disjoint diff_Suc_1 finite_insert le_Suc_eq not_less_eq)
by (metis One_nat_def Suc_leI ‹[b;a₁;f 1]› bound_indices diff_Suc_1 g_def
not_less_less_Suc_eq zero_less_Suc)
} moreover {
fix x assume "x∈?X" "x=b"
have "(finite ?X ⟶ 0 < card ?X) ∧ g 0 = x"
by (simp add: ‹b∉Y› ‹x = b› g_def)
} moreover {
fix x assume "x∈?X" "x≠b"
hence "∃n. (finite ?X ⟶ n < card ?X) ∧ g n = x"
proof -
obtain n where "f n = x" "n < card Y"
using ‹x∈?X› ‹x≠b› local_ordering_def insert_iff long_ch_Y chain_defs by (metis ord_fY)
have "(finite ?X ⟶ n+1 < card ?X)" "g(n+1) = x"
apply (simp add: ‹b∉Y› ‹n < card Y›)
by (simp add: ‹f n = x› g_def)
thus ?thesis by auto
qed
}
ultimately show ?thesis
unfolding local_ordering_def
by smt
qed
hence "local_long_ch_by_ord g ?X"
unfolding local_long_ch_by_ord_def
using fin_Y ‹b∉Y›
by (meson card_insert_le finite_insert le_trans)
show ?thesis
proof (intro finite_long_chain_with_alt2)
show "local_long_ch_by_ord g ?X" using ‹local_long_ch_by_ord g ?X› by simp
show "[b;a₁;a⇩n] ∧ a₁ ∈ ?X" using bY long_ch_Y points_in_long_chain(1) by auto
show "g 0 = b" using g_def by simp
show "finite ?X"
using fin_Y ‹b∉Y› eval_nat_numeral by (metis card.infinite finite.insertI not_numeral_le_zero)
show "g (card ?X - 1) = a⇩n"
using g_def ‹b∉Y› bound_indices eval_nat_numeral
by (metis One_nat_def card.infinite card_insert_disjoint diff_Suc_Suc
diff_is_0_eq' less_nat_zero_code minus_nat.diff_0 nat_le_linear num_ord)
qed
qed
text ‹
This is case (iii) of the induction in Theorem 10.
Schutz says merely ``The proof for this case is similar to that for Case (i).''
Thus I feel free to use a result on symmetry, rather than going through
the pain of Case (i) (‹chain_append_at_left_edge›) again.
›
lemma (*for 10*) chain_append_at_right_edge:
assumes long_ch_Y: "[f↝Y|a₁..a..a⇩n]"
and Yb: "[a₁; a⇩n; b]"
fixes g defines g_def: "g ≡ (λj::nat. if j ≤ (card Y - 1) then f j else b)"
shows "[g↝(insert b Y)|a₁ .. a⇩n .. b]"
proof (-)
(*goal: ‹[g::nat ⇒ 'a↝insert (b::'a) (Y::'a set)|a₁::'a..a⇩n::'a..b]›*)
let ?X = "insert b Y"
have "b∉Y"
using Yb (*‹[a₁;a⇩n;b]›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_only_cba(2) (*‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) by (metis fin_ch_betw2 (*‹⟦[?f::nat ⇒ 'a::type↝?X::'a::type set|?a::'a::type .. ?c::'a::type]; (?b::'a::type) ∈ ?X; ?b = ?a ⟹ ?thesis::bool; ?b = ?c ⟹ ?thesis; [?a;?b;?c] ⟹ ?thesis⟧ ⟹ ?thesis›*) finite_long_chain_with_def (*‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type..?y::'a::type..?z::'a::type] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*))
have fin_Y: "card Y ≥ 3"
using finite_long_chain_with_card (*‹[?f↝?Q|?x..?y..?z] ⟹ 3 ≤ card ?Q›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) by auto
hence fin_X: "finite ?X"
by (metis card.infinite (*‹infinite ?A ⟹ card ?A = 0›*) finite.insertI (*‹finite ?A ⟹ finite (insert ?a ?A)›*) not_numeral_le_zero (*‹¬ numeral ?n ≤ 0›*))
have "a₁∈Y ∧ a⇩n∈Y ∧ a∈Y"
using long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) points_in_long_chain (*‹[?f↝?Q|?x..?y..?z] ⟹ ?x ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?y ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?z ∈ ?Q›*) by meson
have "a₁≠a ∧ a≠ a⇩n ∧ a₁≠a⇩n"
using Yb (*‹[a₁;a⇩n;b]›*) abc_abc_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_Y (*‹[f::nat ⇒ 'a::type↝Y::'a::type set|a₁::'a::type..a::'a::type..a⇩n::'a::type]›*) by auto
have "Suc (card Y) = card ?X"
using ‹b∉Y› (*‹b ∉ Y›*) fin_X (*‹finite (insert b Y)›*) finite_long_chain_with_def (*‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) by auto
obtain f2 where f2_def: "[f2↝Y|a⇩n..a..a₁]" "f2=(λn. f (card Y - 1 - n))"
(*goal: ‹(⋀f2. ⟦[f2↝Y|a⇩n..a..a₁]; f2 = (λn. f (card Y - 1 - n))⟧ ⟹ thesis) ⟹ thesis›*)
using chain_sym (*‹[?f↝?X|?a..?b..?c] ⟹ [λn. ?f (card ?X - 1 - n)↝?X|?c..?b..?a]›*) long_ch_Y (*‹[f::nat ⇒ 'a↝Y::'a set|a₁::'a..a::'a..a⇩n::'a]›*) by blast
obtain g2 where g2_def: "g2 = (λj::nat. if j≥1 then f2 (j-1) else b)"
(*goal: ‹(⋀g2::nat ⇒ 'a::type. g2 = (λj::nat. if (1::nat) ≤ j then (f2::nat ⇒ 'a::type) (j - (1::nat)) else (b::'a::type)) ⟹ thesis::bool) ⟹ thesis›*)
by simp
have "[b; a⇩n; a₁]"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) Yb (*‹[a₁;a⇩n;b]›*) by blast
hence g2_ord_X: "[g2↝?X|b .. a⇩n .. a₁]"
using chain_append_at_left_edge[where a₁ = "a⇩n" and a⇩n = "a₁" and f = "f2"] (*‹⟦[f2↝?Y|a⇩n..?a..a₁]; [?b;a⇩n;a₁]⟧ ⟹ [λj. if 1 ≤ j then f2 (j - 1) else ?b↝insert ?b ?Y|?b..a⇩n..a₁]›*) fin_X (*‹finite (insert (b::'a::type) (Y::'a::type set))›*) ‹b∉Y› (*‹(b::'a) ∉ (Y::'a set)›*) f2_def (*‹[f2::nat ⇒ 'a↝Y::'a set|a⇩n::'a..a::'a..a₁::'a]› ‹f2 = (λn. f (card Y - 1 - n))›*) g2_def (*‹g2 = (λj. if 1 ≤ j then f2 (j - 1) else b)›*) by blast
then obtain g1 where g1_def: "[g1↝?X|a₁..a⇩n..b]" "g1=(λn. g2 (card ?X - 1 - n))"
(*goal: ‹(⋀g1::nat ⇒ 'a. ⟦[g1↝insert (b::'a) (Y::'a set)|a₁::'a..a⇩n::'a..b]; g1 = (λn::nat. (g2::nat ⇒ 'a) (card (insert b Y) - (1::nat) - n))⟧ ⟹ thesis::bool) ⟹ thesis›*)
using chain_sym (*‹[?f↝?X|?a..?b..?c] ⟹ [λn. ?f (card ?X - 1 - n)↝?X|?c..?b..?a]›*) by blast
have sYX: "(card Y) = (card ?X) - 1"
using assms(2,3) (*‹[a₁;a⇩n;b]› ‹g ≡ λj. if j ≤ card Y - 1 then f j else b›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) ‹Suc (card Y) = card ?X› (*‹Suc (card (Y::'a set)) = card (insert (b::'a) Y)›*) by linarith
have "g1=g"
unfolding g1_def g2_def f2_def g_def
(*goal: ‹(λn. if 1 ≤ card (insert b Y) - 1 - n then f (card Y - 1 - (card (insert b Y) - 1 - n - 1)) else b) = (λj. if j ≤ card Y - 1 then f j else b)›*)
proof (standard)
(*goal: ‹⋀n. (if 1 ≤ card (insert b Y) - 1 - n then f (card Y - 1 - (card (insert b Y) - 1 - n - 1)) else b) = (if n ≤ card Y - 1 then f n else b)›*)
fix n
show "(
if 1 ≤ card ?X - 1 - n then
f (card Y - 1 - (card ?X - 1 - n - 1))
else b
) = (
if n ≤ card Y - 1 then
f n
else b
)" (is "?lhs=?rhs")
proof (cases)
(*goals:
1. ‹?P::bool ⟹ (if (1::nat) ≤ card (insert (b::'a::type) (Y::'a::type set)) - (1::nat) - (n::nat) then (f::nat ⇒ 'a::type) (card Y - (1::nat) - (card (insert b Y) - (1::nat) - n - (1::nat))) else b) = (if n ≤ card Y - (1::nat) then f n else b)›
2. ‹¬ (?P::bool) ⟹ (if (1::nat) ≤ card (insert (b::'a::type) (Y::'a::type set)) - (1::nat) - (n::nat) then (f::nat ⇒ 'a::type) (card Y - (1::nat) - (card (insert b Y) - (1::nat) - n - (1::nat))) else b) = (if n ≤ card Y - (1::nat) then f n else b)›*)
assume "n ≤ card ?X - 2" (*‹(n::nat) ≤ card (insert (b::'a) (Y::'a set)) - (2::nat)›*)
show "?lhs=?rhs"
using ‹n ≤ card ?X - 2› (*‹n ≤ card (insert b Y) - 2›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_Y (*‹[f::nat ⇒ 'a↝Y::'a set|a₁::'a..a::'a..a⇩n::'a]›*) sYX (*‹card (Y::'a::type set) = card (insert (b::'a::type) Y) - (1::nat)›*) ‹Suc (card Y) = card ?X› (*‹Suc (card Y) = card (insert b Y)›*) by (metis (mono_tags, opaque_lifting) Suc_1 (*‹Suc 1 = 2›*) Suc_leD (*‹Suc ?m ≤ ?n ⟹ ?m ≤ ?n›*) diff_Suc_Suc (*‹Suc ?m - Suc ?n = ?m - ?n›*) diff_commute (*‹?i - ?j - ?k = ?i - ?k - ?j›*) diff_diff_cancel (*‹?i ≤ ?n ⟹ ?n - (?n - ?i) = ?i›*) diff_le_mono2 (*‹?m ≤ ?n ⟹ ?l - ?n ≤ ?l - ?m›*) fin_chain_card_geq_2 (*‹[?f↝?X|?a .. ?b] ⟹ 2 ≤ card ?X›*))
next
(*goal: ‹¬ n ≤ card (insert b Y) - 2 ⟹ (if 1 ≤ card (insert b Y) - 1 - n then f (card Y - 1 - (card (insert b Y) - 1 - n - 1)) else b) = (if n ≤ card Y - 1 then f n else b)›*)
assume "¬ n ≤ card ?X - 2" (*‹¬ (n::nat) ≤ card (insert (b::'a) (Y::'a set)) - (2::nat)›*)
thus "?lhs=?rhs"
by (metis ‹Suc (card Y) = card ?X› Suc_1 (*‹Suc (1::nat) = (2::nat)›*) diff_Suc_1 (*‹Suc (?n::nat) - (1::nat) = ?n›*) diff_Suc_eq_diff_pred (*‹(?m::nat) - Suc (?n::nat) = ?m - (1::nat) - ?n›*) diff_diff_cancel (*‹(?i::nat) ≤ (?n::nat) ⟹ ?n - (?n - ?i) = ?i›*) diff_is_0_eq' (*‹(?m::nat) ≤ (?n::nat) ⟹ ?m - ?n = (0::nat)›*) nat_le_linear (*‹(?m::nat) ≤ (?n::nat) ∨ ?n ≤ ?m›*) not_less_eq_eq (*‹(¬ (?m::nat) ≤ (?n::nat)) = (Suc ?n ≤ ?m)›*))
qed
qed
thus "?thesis"
(*goal: ‹[g↝insert b Y|a₁..a⇩n..b]›*)
using g1_def(1) (*‹[g1↝insert b Y|a₁..a⇩n..b]›*) by blast
qed
lemma S_is_dense:
assumes long_ch_Y: "[f↝Y|a₁..a..a⇩n]"
and S_def: "S = {k::nat. [a₁; f k; b] ∧ k < card Y}"
and k_def: "S≠{}" "k = Max S"
and k'_def: "k'>0" "k'<k"
shows "k' ∈ S"
proof (-)
(*goal: ‹k' ∈ S›*)
text ‹
We will prove this by contradiction. We can obtain the path that ‹Y› lies on, and show ‹b› is
on it too. Then since ‹f`S› must be on this path, there must be an ordering involving ‹b›, ‹f k›
and ‹f k'› that leads to contradiction with the definition of ‹S› and ‹k∉S›.
Notice we need no knowledge about ‹b› except how it relates to ‹S›.
›
have "[f↝Y]"
using long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by meson
have "card Y ≥ 3"
using finite_long_chain_with_card (*‹[?f↝?Q|?x..?y..?z] ⟹ 3 ≤ card ?Q›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) by blast
hence "finite Y"
by (metis card.infinite (*‹infinite ?A ⟹ card ?A = 0›*) not_numeral_le_zero (*‹¬ numeral ?n ≤ 0›*))
have "k∈S"
using k_def (*‹(S::nat set) ≠ {}› ‹k = Max S›*) Max_in (*‹⟦finite (?A::?'a set); ?A ≠ {}⟧ ⟹ Max ?A ∈ ?A›*) S_def (*‹S = {k. [a₁;f k;b] ∧ k < card Y}›*) by (metis finite_Collect_conjI (*‹finite {x::?'a. (?P::?'a ⇒ bool) x} ∨ finite {x::?'a. (?Q::?'a ⇒ bool) x} ⟹ finite {x::?'a. ?P x ∧ ?Q x}›*) finite_Collect_less_nat (*‹finite {n::nat. n < (?k::nat)}›*))
hence "k<card Y"
using S_def (*‹S = {k. [a₁;f k;b] ∧ k < card Y}›*) by auto
have "k'<card Y"
using S_def (*‹S = {k. [a₁;f k;b] ∧ k < card Y}›*) k'_def (*‹0 < k'› ‹k' < k›*) ‹k∈S› (*‹k ∈ S›*) by auto
show "k' ∈ S"
proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*))
(*goal: ‹k' ∉ S ⟹ False›*)
assume asm: "¬k'∈S" (*‹(k'::nat) ∉ (S::nat set)›*)
have 1: "[f 0;f k;f k']"
proof (-)
(*goal: ‹[f 0;f k;f k']›*)
have "[a₁; b; f k']"
using order_finite_chain2 (*‹⟦[?f::nat ⇒ 'a↝?X::'a set]; finite ?X; (0::nat) ≤ (?i::nat) ∧ ?i < (?j::nat) ∧ ?j < (?l::nat) ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) long_ch_Y (*‹[f::nat ⇒ 'a::type↝Y::'a::type set|a₁::'a::type..a::'a::type..a⇩n::'a::type]›*) ‹k ∈ S› (*‹k ∈ S›*) ‹k' < card Y› (*‹k' < card Y›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (smt (z3) abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) asm (*‹k' ∉ S›*) le_numeral_extra( (*‹0 ≤ 0›*) 3) assms (*‹[f↝Y|a₁..a..a⇩n]› ‹S = {k. [a₁;f k;b] ∧ k < card Y}› ‹S ≠ {}› ‹k = Max S› ‹0 < k'› ‹k' < k›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*))
have "[a₁; f k; b]"
using S_def (*‹S = {k. [a₁;f k;b] ∧ k < card Y}›*) ‹k ∈ S› (*‹k ∈ S›*) by blast
have "[f k; b; f k']"
using abc_acd_bcd (*‹⟦[?a::'a::type;?b::'a::type;?c::'a::type]; [?a;?c;?d::'a::type]⟧ ⟹ [?b;?c;?d]›*) ‹[a₁; b; f k']› (*‹[a₁;b;f k']›*) ‹[a₁; f k; b]› (*‹[a₁;f k;b]›*) by blast
thus "?thesis"
(*goal: ‹[f 0;f k;f k']›*)
using ‹[a₁;f k;b]› (*‹[a₁;f k;b]›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) unfolding finite_long_chain_with_def finite_chain_with_def
(*goal: ‹[(f::nat ⇒ 'a::type) (0::nat);f (k::nat);f (k'::nat)]›*)
by blast
qed
have 2: "[f 0;f k';f k]"
apply (intro order_finite_chain2[OF ‹[f↝Y]› ‹finite Y›] (*‹0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card Y ⟹ [f ?i;f ?j;f ?l]›*))
(*goal: ‹[f 0;f k';f k]›*)
by (simp add: ‹k < card Y› k'_def (*‹0 < k'› ‹k' < k›*))
show False
using "1" (*‹[f 0;f k;f k']›*) "2" (*‹[f 0;f k';f k]›*) abc_only_cba(2) (*‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) by blast
qed
qed
lemma (*for 10*) smallest_k_ex:
assumes long_ch_Y: "[f↝Y|a₁..a..a⇩n]"
and Y_def: "b∉Y"
and Yb: "[a₁; b; a⇩n]"
shows "∃k>0. [a₁; b; f k] ∧ k < card Y ∧ ¬(∃k'<k. [a₁; b; f k'])"
proof (-)
(*goal: ‹∃k>0. [a₁;b;f k] ∧ k < card Y ∧ ¬ (∃k'<k. [a₁;b;f k'])›*)
have bound_indices: "f 0 = a₁ ∧ f (card Y - 1) = a⇩n"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) by auto
have fin_Y: "finite Y"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f::nat ⇒ 'a↝?X::'a set] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_Y (*‹[f::nat ⇒ 'a::type↝Y::'a::type set|a₁::'a::type..a::'a::type..a⇩n::'a::type]›*) by presburger
have card_Y: "card Y ≥ 3"
using long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) points_in_long_chain (*‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ⟹ ?x ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?y ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?z ∈ ?Q›*) finite_long_chain_with_card (*‹[?f↝?Q|?x..?y..?z] ⟹ 3 ≤ card ?Q›*) by blast
text ‹We consider all indices of chain elements between ‹a₁› and ‹b›, and find the maximal one.›
let ?S = "{k::nat. [a₁; f k; b] ∧ k < card Y}"
obtain S where S_def: "S=?S"
(*goal: ‹(⋀S::nat set. S = {k::nat. [a₁::'a;(f::nat ⇒ 'a) k;b::'a] ∧ k < card (Y::'a set)} ⟹ thesis::bool) ⟹ thesis›*)
by simp
have "S⊆{0..card Y}"
using S_def (*‹S = {k. [a₁;f k;b] ∧ k < card Y}›*) by auto
hence "finite S"
using finite_subset (*‹⟦(?A::?'a::type set) ⊆ (?B::?'a::type set); finite ?B⟧ ⟹ finite ?A›*) by blast
show "?thesis"
(*goal: ‹∃k>0. [a₁;b;f k] ∧ k < card Y ∧ ¬ (∃k'<k. [a₁;b;f k'])›*)
proof (cases)
(*goals:
1. ‹?P ⟹ ∃k>0. [a₁;b;f k] ∧ k < card Y ∧ ¬ (∃k'<k. [a₁;b;f k'])›
2. ‹¬ ?P ⟹ ∃k>0. [a₁;b;f k] ∧ k < card Y ∧ ¬ (∃k'<k. [a₁;b;f k'])›*)
assume "S={}" (*‹(S::nat set) = {}›*)
show "?thesis"
(*goal: ‹∃k>0::nat. [a₁::'a::type;b::'a::type;(f::nat ⇒ 'a::type) k] ∧ k < card (Y::'a::type set) ∧ ¬ (∃k'<k. [a₁;b;f k'])›*)
proof (standard)
(*goal: ‹0 < ?k ∧ [a₁;b;f ?k] ∧ ?k < card Y ∧ ¬ (∃k'<?k. [a₁;b;f k'])›*)
show "(0::nat)<1 ∧ [a₁; b; f 1] ∧ 1 < card Y ∧ ¬ (∃k'::nat. k' < 1 ∧ [a₁; b; f k'])"
proof (intro conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹(0::nat) < (1::nat)›
2. ‹[a₁::'a;b::'a;(f::nat ⇒ 'a) (1::nat)]›
3. ‹(1::nat) < card (Y::'a set)›
4. ‹¬ (∃k'<1::nat. [a₁::'a;b::'a;(f::nat ⇒ 'a) k'])›*)
show "(0::nat)<1"
by simp
show "1 < card Y"
using Yb (*‹[a₁;b;a⇩n]›*) abc_ac_neq (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ?a ≠ ?c›*) bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) by fastforce
show "¬ (∃k'::nat. k' < 1 ∧ [a₁; b; f k'])"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) by blast
show "[a₁; b; f 1]"
proof (-)
(*goal: ‹[a₁;b;f 1]›*)
have "f 1 ∈ Y"
using long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) chain_defs (*‹short_ch (?X::'a::type set) ≡ card ?X = (2::nat) ∧ (∃P::'a::type set∈𝒫::'a::type set set. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) local_ordering_def (*‹local_ordering (?f::nat ⇒ ?'a) (?ord::?'a ⇒ ?'a ⇒ ?'a ⇒ bool) (?X::?'a set) ≡ (∀n::nat. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x::?'a∈?X. ∃n::nat. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n::nat. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) by (metis ‹1 < card Y› short_ch_ord_in( (*‹short_ch_by_ord ?f ?Q ⟹ ?f 1 ∈ ?Q›*) 2))
hence "[a₁; f 1; a⇩n]"
using bound_indices (*‹(f::nat ⇒ 'a) (0::nat) = (a₁::'a) ∧ f (card (Y::'a set) - (1::nat)) = (a⇩n::'a)›*) long_ch_Y (*‹[f::nat ⇒ 'a↝Y::'a set|a₁::'a..a::'a..a⇩n::'a]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) local_ordering_def (*‹local_ordering (?f::nat ⇒ ?'a) (?ord::?'a ⇒ ?'a ⇒ ?'a ⇒ bool) (?X::?'a set) ≡ (∀n::nat. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x::?'a∈?X. ∃n::nat. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n::nat. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) card_Y (*‹3 ≤ card Y›*) by (smt (z3) Nat.lessE (*‹⟦?i < ?k; ?k = Suc ?i ⟹ ?P; ⋀j. ⟦?i < j; ?k = Suc j⟧ ⟹ ?P⟧ ⟹ ?P›*) One_nat_def (*‹1 = Suc 0›*) Suc_le_lessD (*‹Suc ?m ≤ ?n ⟹ ?m < ?n›*) Suc_lessD (*‹Suc ?m < ?n ⟹ ?m < ?n›*) diff_Suc_1 (*‹Suc ?n - 1 = ?n›*) diff_Suc_less (*‹0 < ?n ⟹ ?n - Suc ?i < ?n›*) fin_ch_betw2 (*‹⟦[?f↝?X|?a .. ?c]; ?b ∈ ?X; ?b = ?a ⟹ ?thesis; ?b = ?c ⟹ ?thesis; [?a;?b;?c] ⟹ ?thesis⟧ ⟹ ?thesis›*) i_le_j_events_neq (*‹⟦[?f↝?X|?a..?b..?c]; ?i < ?j; ?j < card ?X⟧ ⟹ ?f ?i ≠ ?f ?j›*) less_numeral_extra( (*‹0 < 1›*) 1) numeral_3_eq_3 (*‹3 = Suc (Suc (Suc 0))›*))
hence "[a₁; b; f 1] ∨ [a₁; f 1; b] ∨ [b; a₁; f 1]"
using abc_ex_path_unique (*‹[?a::'a;?b::'a;?c::'a] ⟹ ∃!Q::'a set. Q ∈ (𝒫::'a set set) ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by (smt Y_def (*‹b ∉ Y›*) Yb (*‹[a₁;b;a⇩n]›*) ‹f 1 ∈ Y› abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) cross_once_notin (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*))
thus "[a₁; b; f 1]"
proof (-)
(*goal: ‹[a₁;b;f 1] ∨ [a₁;f 1;b] ∨ [b;a₁;f 1] ⟹ [a₁;b;f 1]›*)
have "∀n. ¬ ([a₁; f n; b] ∧ n < card Y)"
using S_def (*‹(S::nat set) = {k::nat. [a₁::'a::type;(f::nat ⇒ 'a::type) k;b::'a::type] ∧ k < card (Y::'a::type set)}›*) ‹S = {}› (*‹S = {}›*) by blast
then have "[a₁; b; f 1] ∨ ¬ [a⇩n; f 1; b] ∧ ¬ [a₁; f 1; b]"
using bound_indices (*‹(f::nat ⇒ 'a::type) (0::nat) = (a₁::'a::type) ∧ f (card (Y::'a::type set) - (1::nat)) = (a⇩n::'a::type)›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) abd_bcd_abc (*‹⟦[?a::'a;?b::'a;?d::'a]; [?b;?c::'a;?d]⟧ ⟹ [?a;?b;?c]›*) Yb (*‹[a₁;b;a⇩n]›*) by (metis (no_types) diff_is_0_eq' (*‹?m ≤ ?n ⟹ ?m - ?n = 0›*) nat_le_linear (*‹?m ≤ ?n ∨ ?n ≤ ?m›*) nat_less_le (*‹(?m < ?n) = (?m ≤ ?n ∧ ?m ≠ ?n)›*))
then show "?thesis"
(*goal: ‹[a₁;b;f 1]›*)
using abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by (meson ‹[a₁; b; f 1] ∨ [a₁; f 1; b] ∨ [b; a₁; f 1]› ‹[a₁; f 1; a⇩n]›)
qed
qed
qed
qed
next
(*goal: ‹S ≠ {} ⟹ ∃k>0. [a₁;b;f k] ∧ k < card Y ∧ ¬ (∃k'<k. [a₁;b;f k'])›*)
assume "¬S={}" (*‹(S::nat set) ≠ {}›*)
obtain k where "k = Max S"
(*goal: ‹(⋀k. k = Max S ⟹ thesis) ⟹ thesis›*)
by simp
hence "k ∈ S"
using Max_in (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ Max ?A ∈ ?A›*) by (simp add: ‹S ≠ {}› ‹finite S›)
have "k≥1"
proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*))
(*goal: ‹¬ 1 ≤ k ⟹ False›*)
assume "¬ 1 ≤ k" (*‹¬ (1::nat) ≤ (k::nat)›*)
hence "k=0"
by simp
have "[a₁; f k; b]"
using ‹k∈S› (*‹k ∈ S›*) S_def (*‹S = {k. [a₁;f k;b] ∧ k < card Y}›*) by blast
thus False
using bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) ‹k = 0› (*‹(k::nat) = (0::nat)›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) by blast
qed
show "?thesis"
(*goal: ‹∃k>0. [a₁;b;f k] ∧ k < card Y ∧ ¬ (∃k'<k. [a₁;b;f k'])›*)
proof (standard)
(*goal: ‹0 < ?k ∧ [a₁;b;f ?k] ∧ ?k < card Y ∧ ¬ (∃k'<?k. [a₁;b;f k'])›*)
let ?k = "k+1"
show "0<?k ∧ [a₁; b; f ?k] ∧ ?k < card Y ∧ ¬ (∃k'::nat. k' < ?k ∧ [a₁; b; f k'])"
proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹0 < k + 1›
2. ‹[a₁;b;f (k + 1)]›
3. ‹k + 1 < card Y›
4. ‹¬ (∃k'<k + 1. [a₁;b;f k'])›*)
show "(0::nat)<?k"
by simp
show "?k < card Y"
by (metis (no_types, lifting) S_def (*‹S = {k. [a₁;f k;b] ∧ k < card Y}›*) Yb (*‹[a₁;b;a⇩n]›*) ‹k ∈ S› abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) 2) add.commute (*‹?a + ?b = ?b + ?a›*) add_diff_cancel_right' (*‹?a + ?b - ?b = ?a›*) bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) less_SucE (*‹⟦?m < Suc ?n; ?m < ?n ⟹ ?P; ?m = ?n ⟹ ?P⟧ ⟹ ?P›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) nat_add_left_cancel_less (*‹(?k + ?m < ?k + ?n) = (?m < ?n)›*) plus_1_eq_Suc (*‹(+) 1 = Suc›*))
show "[a₁; b; f ?k]"
proof (-)
(*goal: ‹[a₁::'a;b::'a;(f::nat ⇒ 'a) ((k::nat) + (1::nat))]›*)
have "f ?k ∈ Y"
using ‹k + 1 < card Y› (*‹(k::nat) + (1::nat) < card (Y::'a set)›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) card_Y (*‹3 ≤ card Y›*) unfolding local_ordering_def chain_defs
(*goal: ‹(f::nat ⇒ 'a) ((k::nat) + (1::nat)) ∈ (Y::'a set)›*)
by (metis One_nat_def (*‹1 = Suc 0›*) Suc_numeral (*‹Suc (numeral ?n) = numeral (?n + num.One)›*) not_less_eq_eq (*‹(¬ ?m ≤ ?n) = (Suc ?n ≤ ?m)›*) numeral_3_eq_3 (*‹3 = Suc (Suc (Suc 0))›*) numerals( (*‹Numeral1 = 1›*) 1) semiring_norm( (*‹num.One + num.One = num.Bit0 num.One›*) 2) set_le_two (*‹card {?a, ?b} ≤ 2›*))
have "[a₁; f ?k; a⇩n] ∨ f ?k = a⇩n"
using fin_ch_betw2 (*‹⟦[?f↝?X|?a .. ?c]; ?b ∈ ?X; ?b = ?a ⟹ ?thesis; ?b = ?c ⟹ ?thesis; [?a;?b;?c] ⟹ ?thesis⟧ ⟹ ?thesis›*) inside_not_bound(1) (*‹⟦[?f::nat ⇒ 'a↝?X::'a set|?a::'a .. ?c::'a]; (?j::nat) < card ?X; (0::nat) < ?j⟧ ⟹ ?f ?j ≠ ?a›*) long_ch_Y (*‹[f::nat ⇒ 'a::type↝Y::'a::type set|a₁::'a::type..a::'a::type..a⇩n::'a::type]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis ‹0 < k + 1› ‹k + 1 < card Y› ‹f (k + 1) ∈ Y›)
thus "[a₁; b; f ?k]"
proof (rule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹[a₁;f (k + 1);a⇩n] ⟹ [a₁;b;f (k + 1)]›
2. ‹f (k + 1) = a⇩n ⟹ [a₁;b;f (k + 1)]›*)
assume "[a₁; f ?k; a⇩n]" (*‹[a₁::'a;(f::nat ⇒ 'a) ((k::nat) + (1::nat));a⇩n::'a]›*)
hence "f ?k ≠ a⇩n"
by (simp add: abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*))
hence "[a₁; b; f ?k] ∨ [a₁; f ?k; b] ∨ [b; a₁; f ?k]"
using abc_ex_path_unique (*‹[?a;?b;?c] ⟹ ∃!Q. Q ∈ 𝒫 ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) ‹[a₁; f ?k; a⇩n]› (*‹[a₁;f (k + 1);a⇩n]›*) ‹f ?k ∈ Y› (*‹f (k + 1) ∈ Y›*) Yb (*‹[a₁::'a;b::'a;a⇩n::'a]›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) assms(3) (*‹[a₁;b;a⇩n]›*) cross_once_notin (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*) by (smt Y_def (*‹(b::'a) ∉ (Y::'a set)›*))
moreover have "¬ [a₁; f ?k; b]"
proof (standard)
(*goal: ‹[a₁;f (k + 1);b] ⟹ False›*)
assume "[a₁; f ?k; b]" (*‹[a₁::'a;(f::nat ⇒ 'a) ((k::nat) + (1::nat));b::'a]›*)
hence "?k ∈ S"
using S_def (*‹S = {k. [a₁;f k;b] ∧ k < card Y}›*) ‹[a₁; f ?k; b]› (*‹[a₁;f (k + 1);b]›*) ‹k + 1 < card Y› (*‹(k::nat) + (1::nat) < card (Y::'a set)›*) by blast
hence "?k ≤ k"
by (simp add: ‹finite S› ‹k = Max S›)
thus False
by linarith
qed
moreover have "¬ [b; a₁; f ?k]"
using Yb (*‹[a₁::'a;b::'a;a⇩n::'a]›*) ‹[a₁; f ?k; a⇩n]› (*‹[a₁;f (k + 1);a⇩n]›*) abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) by blast
ultimately show "[a₁; b; f ?k]"
by blast
next
(*goal: ‹f (k + 1) = a⇩n ⟹ [a₁;b;f (k + 1)]›*)
assume "f ?k = a⇩n" (*‹(f::nat ⇒ 'a) ((k::nat) + (1::nat)) = (a⇩n::'a)›*)
show "?thesis"
(*goal: ‹[a₁;b;f (k + 1)]›*)
using Yb (*‹[a₁;b;a⇩n]›*) ‹f (k + 1) = a⇩n› (*‹f (k + 1) = a⇩n›*) by blast
qed
qed
show "¬(∃k'::nat. k' < k + 1 ∧ [a₁; b; f k'])"
proof (standard)
(*goal: ‹∃k'<k + 1. [a₁;b;f k'] ⟹ False›*)
assume "∃k'::nat. k' < k + 1 ∧ [a₁; b; f k']" (*‹∃k'<(k::nat) + (1::nat). [a₁::'a;b::'a;(f::nat ⇒ 'a) k']›*)
then obtain k' where k'_def: "k'>0" "k' < k + 1" "[a₁; b; f k']"
(*goal: ‹(⋀k'::nat. ⟦(0::nat) < k'; k' < (k::nat) + (1::nat); [a₁::'a;b::'a;(f::nat ⇒ 'a) k']⟧ ⟹ thesis::bool) ⟹ thesis›*)
using abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) neq0_conv (*‹(?n ≠ 0) = (0 < ?n)›*) by blast
hence "k'<k"
using S_def (*‹S = {k. [a₁;f k;b] ∧ k < card Y}›*) ‹k ∈ S› (*‹k ∈ S›*) abc_only_cba(2) (*‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) less_SucE (*‹⟦?m < Suc ?n; ?m < ?n ⟹ ?P; ?m = ?n ⟹ ?P⟧ ⟹ ?P›*) by fastforce
hence "k'∈S"
using S_is_dense (*‹⟦[?f↝?Y|?a₁..?a..?a⇩n]; ?S = {k. [?a₁;?f k;?b] ∧ k < card ?Y}; ?S ≠ {}; ?k = Max ?S; 0 < ?k'; ?k' < ?k⟧ ⟹ ?k' ∈ ?S›*) long_ch_Y (*‹[f::nat ⇒ 'a::type↝Y::'a::type set|a₁::'a::type..a::'a::type..a⇩n::'a::type]›*) S_def (*‹S = {k. [a₁;f k;b] ∧ k < card Y}›*) ‹¬S={}› (*‹S ≠ {}›*) ‹k = Max S› (*‹k = Max S›*) ‹k'>0› (*‹0 < k'›*) by blast
thus False
using S_def (*‹S = {k. [a₁;f k;b] ∧ k < card Y}›*) abc_only_cba(2) (*‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) k'_def(3) (*‹[a₁;b;f k']›*) by blast
qed
qed
qed
qed
qed
(* TODO: there's definitely a way of doing this using chain_sym and smallest_k_ex. *)
lemma greatest_k_ex:
assumes long_ch_Y: "[f↝Y|a₁..a..a⇩n]"
and Y_def: "b∉Y"
and Yb: "[a₁; b; a⇩n]"
shows "∃k. [f k; b; a⇩n] ∧ k < card Y - 1 ∧ ¬(∃k'<card Y. k'>k ∧ [f k'; b; a⇩n])"
proof (-)
(*goal: ‹∃k. [f k;b;a⇩n] ∧ k < card Y - 1 ∧ ¬ (∃k'<card Y. k < k' ∧ [f k';b;a⇩n])›*)
have bound_indices: "f 0 = a₁ ∧ f (card Y - 1) = a⇩n"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a::type set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) by simp
have fin_Y: "finite Y"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type .. ?y::'a::type] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) by presburger
have card_Y: "card Y ≥ 3"
using long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) points_in_long_chain (*‹[?f↝?Q|?x..?y..?z] ⟹ ?x ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?y ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?z ∈ ?Q›*) finite_long_chain_with_card (*‹[?f↝?Q|?x..?y..?z] ⟹ 3 ≤ card ?Q›*) by blast
have chY2: "local_long_ch_by_ord f Y"
using long_ch_Y (*‹[f::nat ⇒ 'a::type↝Y::'a::type set|a₁::'a::type..a::'a::type..a⇩n::'a::type]›*) chain_defs (*‹short_ch (?X::'a::type set) ≡ card ?X = (2::nat) ∧ (∃P::'a::type set∈𝒫::'a::type set set. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (meson card_Y (*‹3 ≤ card Y›*) long_ch_card_ge3 (*‹⟦[?f↝?X]; finite ?X⟧ ⟹ local_long_ch_by_ord ?f ?X = (3 ≤ card ?X)›*))
text ‹Again we consider all indices of chain elements between ‹a₁› and ‹b›.›
let ?S = "{k::nat. [a⇩n; f k; b] ∧ k < card Y}"
obtain S where S_def: "S=?S"
(*goal: ‹(⋀S. S = {k. [a⇩n;f k;b] ∧ k < card Y} ⟹ thesis) ⟹ thesis›*)
by simp
have "S⊆{0..card Y}"
using S_def (*‹S = {k. [a⇩n;f k;b] ∧ k < card Y}›*) by auto
hence "finite S"
using finite_subset (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); finite ?B⟧ ⟹ finite ?A›*) by blast
show "?thesis"
(*goal: ‹∃k. [f k;b;a⇩n] ∧ k < card Y - 1 ∧ ¬ (∃k'<card Y. k < k' ∧ [f k';b;a⇩n])›*)
proof (cases)
(*goals:
1. ‹?P ⟹ ∃k. [f k;b;a⇩n] ∧ k < card Y - 1 ∧ ¬ (∃k'<card Y. k < k' ∧ [f k';b;a⇩n])›
2. ‹¬ ?P ⟹ ∃k. [f k;b;a⇩n] ∧ k < card Y - 1 ∧ ¬ (∃k'<card Y. k < k' ∧ [f k';b;a⇩n])›*)
assume "S={}" (*‹(S::nat set) = {}›*)
show "?thesis"
(*goal: ‹∃k. [f k;b;a⇩n] ∧ k < card Y - 1 ∧ ¬ (∃k'<card Y. k < k' ∧ [f k';b;a⇩n])›*)
proof (standard)
(*goal: ‹[f ?k;b;a⇩n] ∧ ?k < card Y - 1 ∧ ¬ (∃k'<card Y. ?k < k' ∧ [f k';b;a⇩n])›*)
let ?n = "card Y - 2"
show "[f ?n; b; a⇩n] ∧ ?n < card Y - 1 ∧ ¬(∃k'<card Y. k'>?n ∧ [f k'; b; a⇩n])"
proof (intro conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹[f (card Y - 2);b;a⇩n]›
2. ‹card Y - 2 < card Y - 1›
3. ‹¬ (∃k'<card Y. card Y - 2 < k' ∧ [f k';b;a⇩n])›*)
show "?n < card Y - 1"
using Yb (*‹[a₁;b;a⇩n]›*) abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) by fastforce
next
(*goals:
1. ‹[f (card Y - 2);b;a⇩n]›
2. ‹¬ (∃k'<card Y. card Y - 2 < k' ∧ [f k';b;a⇩n])›*)
show "¬(∃k'<card Y. k'>?n ∧ [f k'; b; a⇩n])"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) by (metis One_nat_def (*‹1 = Suc 0›*) Suc_diff_le (*‹?n ≤ ?m ⟹ Suc ?m - ?n = Suc (?m - ?n)›*) Suc_leD (*‹Suc ?m ≤ ?n ⟹ ?m ≤ ?n›*) Suc_lessI (*‹⟦?m < ?n; Suc ?m ≠ ?n⟧ ⟹ Suc ?m < ?n›*) card_Y (*‹3 ≤ card Y›*) diff_Suc_1 (*‹Suc ?n - 1 = ?n›*) diff_Suc_Suc (*‹Suc ?m - Suc ?n = ?m - ?n›*) not_less_eq (*‹(¬ ?m < ?n) = (?n < Suc ?m)›*) numeral_2_eq_2 (*‹2 = Suc (Suc 0)›*) numeral_3_eq_3 (*‹3 = Suc (Suc (Suc 0))›*))
next
(*goal: ‹[f (card Y - 2);b;a⇩n]›*)
show "[f ?n; b; a⇩n]"
proof (-)
(*goal: ‹[(f::nat ⇒ 'a) (card (Y::'a set) - (2::nat));b::'a;a⇩n::'a]›*)
have "[f 0;f ?n; f (card Y - 1)]"
apply (intro order_finite_chain[of f Y] (*‹⟦local_long_ch_by_ord f Y; finite Y; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card Y⟧ ⟹ [f ?i;f ?j;f ?l]›*), simp_all add: chY2 fin_Y)
(*goal: ‹[f 0;f (card Y - 2);f (card Y - 1)]›*)
using card_Y (*‹3 ≤ card Y›*) by linarith
hence "[a₁; f ?n; a⇩n]"
using long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) unfolding chain_defs
(*goal: ‹[a₁;f (card Y - 2);a⇩n]›*)
by simp
have "f ?n ∈ Y"
using long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) eval_nat_numeral (*‹Numeral1 = Suc 0› ‹numeral (num.Bit0 ?n) = Suc (numeral (Num.BitM ?n))› ‹numeral (num.Bit1 ?n) = Suc (numeral (num.Bit0 ?n))›*) unfolding local_ordering_def chain_defs
(*goal: ‹(f::nat ⇒ 'a) (card (Y::'a set) - (2::nat)) ∈ Y›*)
by (metis card_1_singleton_iff (*‹(card ?A = Suc 0) = (∃x. ?A = {x})›*) card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*) card_gt_0_iff (*‹(0 < card ?A) = (?A ≠ {} ∧ finite ?A)›*) diff_Suc_less (*‹0 < ?n ⟹ ?n - Suc ?i < ?n›*) diff_self_eq_0 (*‹?m - ?m = 0›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) numeral_2_eq_2 (*‹2 = Suc (Suc 0)›*))
hence "[a⇩n; b; f ?n] ∨ [a⇩n; f ?n; b] ∨ [b; a⇩n; f ?n]"
using abc_ex_path_unique (*‹[?a;?b;?c] ⟹ ∃!Q. Q ∈ 𝒫 ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) ‹[a₁; f ?n; a⇩n]› (*‹[a₁;f (card Y - 2);a⇩n]›*) by (smt Y_def (*‹(b::'a) ∉ (Y::'a set)›*) Yb (*‹[a₁::'a;b::'a;a⇩n::'a]›*) ‹f ?n ∈ Y› abc_abc_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) cross_once_notin (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?R::'a set) ∈ 𝒫; (?a::'a) ∈ ?Q; (?b::'a) ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*))
thus "[f ?n; b; a⇩n]"
proof (-)
(*goal: ‹[a⇩n;b;f (card Y - 2)] ∨ [a⇩n;f (card Y - 2);b] ∨ [b;a⇩n;f (card Y - 2)] ⟹ [f (card Y - 2);b;a⇩n]›*)
have "∀n. ¬ ([a⇩n; f n; b] ∧ n < card Y)"
using S_def (*‹S = {k. [a⇩n;f k;b] ∧ k < card Y}›*) ‹S = {}› (*‹S = {}›*) by blast
then have "[a⇩n; b; f ?n] ∨ ¬ [a₁; f ?n; b] ∧ ¬ [a⇩n; f ?n; b]"
using bound_indices (*‹(f::nat ⇒ 'a) (0::nat) = (a₁::'a) ∧ f (card (Y::'a set) - (1::nat)) = (a⇩n::'a)›*) abc_sym (*‹[?a::'a;?b::'a;?c::'a] ⟹ [?c;?b;?a]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) Yb (*‹[a₁::'a;b::'a;a⇩n::'a]›*) by (metis (no_types, lifting) ‹f (card Y - 2) ∈ Y› card_gt_0_iff (*‹(0 < card ?A) = (?A ≠ {} ∧ finite ?A)›*) diff_less (*‹⟦0 < ?n; 0 < ?m⟧ ⟹ ?m - ?n < ?m›*) empty_iff (*‹(?c ∈ {}) = False›*) fin_Y (*‹finite Y›*) zero_less_numeral (*‹0 < numeral ?n›*))
then show "?thesis"
(*goal: ‹[f (card Y - 2);b;a⇩n]›*)
using abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by (meson ‹[a⇩n; b; f ?n] ∨ [a⇩n; f ?n; b] ∨ [b; a⇩n; f ?n]› ‹[a₁; f ?n; a⇩n]›)
qed
qed
qed
qed
next
(*goal: ‹S ≠ {} ⟹ ∃k. [f k;b;a⇩n] ∧ k < card Y - 1 ∧ ¬ (∃k'<card Y. k < k' ∧ [f k';b;a⇩n])›*)
assume "¬S={}" (*‹(S::nat set) ≠ {}›*)
obtain k where "k = Min S"
(*goal: ‹(⋀k::nat. k = Min (S::nat set) ⟹ thesis::bool) ⟹ thesis›*)
by simp
hence "k ∈ S"
by (simp add: ‹S ≠ {}› ‹finite S›)
show "?thesis"
(*goal: ‹∃k. [f k;b;a⇩n] ∧ k < card Y - 1 ∧ ¬ (∃k'<card Y. k < k' ∧ [f k';b;a⇩n])›*)
proof (standard)
(*goal: ‹[f ?k;b;a⇩n] ∧ ?k < card Y - 1 ∧ ¬ (∃k'<card Y. ?k < k' ∧ [f k';b;a⇩n])›*)
let ?k = "k-1"
show "[f ?k; b; a⇩n] ∧ ?k < card Y - 1 ∧ ¬ (∃k'<card Y. ?k < k' ∧ [f k'; b; a⇩n])"
proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹[(f::nat ⇒ 'a) ((k::nat) - (1::nat));b::'a;a⇩n::'a]›
2. ‹(k::nat) - (1::nat) < card (Y::'a set) - (1::nat)›
3. ‹¬ (∃k'<card (Y::'a set). (k::nat) - (1::nat) < k' ∧ [(f::nat ⇒ 'a) k';b::'a;a⇩n::'a])›*)
show "?k < card Y - 1"
using S_def (*‹S = {k. [a⇩n;f k;b] ∧ k < card Y}›*) ‹k ∈ S› (*‹k ∈ S›*) less_imp_diff_less (*‹?j < ?k ⟹ ?j - ?n < ?k›*) card_Y (*‹3 ≤ card Y›*) by (metis (no_types, lifting) One_nat_def (*‹1 = Suc 0›*) diff_is_0_eq' (*‹?m ≤ ?n ⟹ ?m - ?n = 0›*) diff_less_mono (*‹⟦?a < ?b; ?c ≤ ?a⟧ ⟹ ?a - ?c < ?b - ?c›*) lessI (*‹?n < Suc ?n›*) less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) nat_le_linear (*‹?m ≤ ?n ∨ ?n ≤ ?m›*) numeral_3_eq_3 (*‹3 = Suc (Suc (Suc 0))›*) zero_less_diff (*‹(0 < ?n - ?m) = (?m < ?n)›*))
show "[f ?k; b; a⇩n]"
proof (-)
(*goal: ‹[f (k - 1);b;a⇩n]›*)
have "f ?k ∈ Y"
using ‹k - 1 < card Y - 1› (*‹k - 1 < card Y - 1›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) card_Y (*‹3 ≤ card Y›*) eval_nat_numeral (*‹Numeral1 = Suc 0› ‹numeral (num.Bit0 ?n) = Suc (numeral (Num.BitM ?n))› ‹numeral (num.Bit1 ?n) = Suc (numeral (num.Bit0 ?n))›*) unfolding local_ordering_def chain_defs
(*goal: ‹f (k - 1) ∈ Y›*)
by (metis Suc_pred' (*‹(0::nat) < (?n::nat) ⟹ ?n = Suc (?n - (1::nat))›*) less_Suc_eq (*‹((?m::nat) < Suc (?n::nat)) = (?m < ?n ∨ ?m = ?n)›*) less_nat_zero_code (*‹((?n::nat) < (0::nat)) = False›*) not_less_eq (*‹(¬ (?m::nat) < (?n::nat)) = (?n < Suc ?m)›*) not_less_eq_eq (*‹(¬ (?m::nat) ≤ (?n::nat)) = (Suc ?n ≤ ?m)›*) set_le_two (*‹card {?a::?'a, ?b::?'a} ≤ (2::nat)›*))
have "[a₁; f ?k; a⇩n] ∨ f ?k = a₁"
using bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) ‹k - 1 < card Y - 1› (*‹k - 1 < card Y - 1›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) unfolding finite_long_chain_with_alt
(*goal: ‹[a₁;f (k - 1);a⇩n] ∨ f (k - 1) = a₁›*)
by (metis ‹f (k - 1) ∈ Y› card_Diff1_less (*‹⟦finite (?A::?'a set); (?x::?'a) ∈ ?A⟧ ⟹ card (?A - {?x}) < card ?A›*) card_Diff_singleton_if (*‹card ((?A::?'a set) - {?x::?'a}) = (if ?x ∈ ?A then card ?A - (1::nat) else card ?A)›*) chY2 (*‹local_long_ch_by_ord (f::nat ⇒ 'a) (Y::'a set)›*) index_injective (*‹⟦local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set); finite ?X; (?i::nat) < (?j::nat); ?j < card ?X⟧ ⟹ ?f ?i ≠ ?f ?j›*))
thus "[f ?k; b; a⇩n]"
proof (rule disjE (*‹⟦(?P::bool) ∨ (?Q::bool); ?P ⟹ ?R::bool; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹[a₁::'a::type;(f::nat ⇒ 'a::type) ((k::nat) - (1::nat));a⇩n::'a::type] ⟹ [f (k - (1::nat));b::'a::type;a⇩n]›
2. ‹(f::nat ⇒ 'a::type) ((k::nat) - (1::nat)) = (a₁::'a::type) ⟹ [f (k - (1::nat));b::'a::type;a⇩n::'a::type]›*)
assume "[a₁; f ?k; a⇩n]" (*‹[a₁::'a;(f::nat ⇒ 'a) ((k::nat) - (1::nat));a⇩n::'a]›*)
hence "f ?k ≠ a₁"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) by blast
hence "[a⇩n; b; f ?k] ∨ [a⇩n; f ?k; b] ∨ [b; a⇩n; f ?k]"
using abc_ex_path_unique (*‹[?a;?b;?c] ⟹ ∃!Q. Q ∈ 𝒫 ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) ‹[a₁; f ?k; a⇩n]› (*‹[a₁;f (k - 1);a⇩n]›*) ‹f ?k ∈ Y› (*‹(f::nat ⇒ 'a::type) ((k::nat) - (1::nat)) ∈ (Y::'a::type set)›*) Yb (*‹[a₁;b;a⇩n]›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) assms(3) (*‹[a₁;b;a⇩n]›*) cross_once_notin (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?R::'a set) ∈ 𝒫; (?a::'a) ∈ ?Q; (?b::'a) ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*) by (smt Y_def (*‹(b::'a::type) ∉ (Y::'a::type set)›*))
moreover have "¬ [a⇩n; f ?k; b]"
proof (standard)
(*goal: ‹[a⇩n;f (k - 1);b] ⟹ False›*)
assume "[a⇩n; f ?k; b]" (*‹[a⇩n::'a;(f::nat ⇒ 'a) ((k::nat) - (1::nat));b::'a]›*)
hence "?k ∈ S"
using S_def (*‹(S::nat set) = {k::nat. [a⇩n::'a;(f::nat ⇒ 'a) k;b::'a] ∧ k < card (Y::'a set)}›*) ‹[a⇩n; f ?k; b]› (*‹[a⇩n;f (k - 1);b]›*) ‹k - 1 < card Y - 1› (*‹(k::nat) - (1::nat) < card (Y::'a set) - (1::nat)›*) by simp
hence "?k ≥ k"
by (simp add: ‹finite S› ‹k = Min S›)
thus False
using ‹f (k - 1) ≠ a₁› (*‹f (k - 1) ≠ a₁›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a::type) (?X::'a::type set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) by auto
qed
moreover have "¬ [b; a⇩n; f ?k]"
using Yb (*‹[a₁;b;a⇩n]›*) ‹[a₁; f ?k; a⇩n]› (*‹[a₁;f (k - 1);a⇩n]›*) abc_only_cba(2) (*‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) abc_bcd_acd (*‹⟦[?a::'a;?b::'a;?c::'a]; [?b;?c;?d::'a]⟧ ⟹ [?a;?c;?d]›*) by blast
ultimately show "[f ?k; b; a⇩n]"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by auto
next
(*goal: ‹f (k - 1) = a₁ ⟹ [f (k - 1);b;a⇩n]›*)
assume "f ?k = a₁" (*‹(f::nat ⇒ 'a) ((k::nat) - (1::nat)) = (a₁::'a)›*)
show "?thesis"
(*goal: ‹[f (k - 1);b;a⇩n]›*)
using Yb (*‹[a₁;b;a⇩n]›*) ‹f (k - 1) = a₁› (*‹f (k - 1) = a₁›*) by blast
qed
qed
show "¬(∃k'<card Y. k-1 < k' ∧ [f k'; b; a⇩n])"
proof (standard)
(*goal: ‹∃k'<card Y. k - 1 < k' ∧ [f k';b;a⇩n] ⟹ False›*)
assume "∃k'<card Y. k-1 < k' ∧ [f k'; b; a⇩n]" (*‹∃k'<card (Y::'a set). (k::nat) - (1::nat) < k' ∧ [(f::nat ⇒ 'a) k';b::'a;a⇩n::'a]›*)
then obtain k' where k'_def: "k'<card Y -1" "k' > k - 1" "[a⇩n; b; f k']"
(*goal: ‹(⋀k'. ⟦k' < card Y - 1; k - 1 < k'; [a⇩n;b;f k']⟧ ⟹ thesis) ⟹ thesis›*)
using abc_ac_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?c›*) bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) neq0_conv (*‹(?n ≠ 0) = (0 < ?n)›*) by (metis Suc_diff_1 (*‹(0::nat) < (?n::nat) ⟹ Suc (?n - (1::nat)) = ?n›*) abc_sym (*‹[?a::'a;?b::'a;?c::'a] ⟹ [?c;?b;?a]›*) gr_implies_not0 (*‹(?m::nat) < (?n::nat) ⟹ ?n ≠ (0::nat)›*) less_SucE (*‹⟦(?m::nat) < Suc (?n::nat); ?m < ?n ⟹ ?P::bool; ?m = ?n ⟹ ?P⟧ ⟹ ?P›*))
hence "k'>k"
using S_def (*‹S = {k. [a⇩n;f k;b] ∧ k < card Y}›*) ‹k ∈ S› (*‹k ∈ S›*) abc_only_cba(2) (*‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) less_SucE (*‹⟦?m < Suc ?n; ?m < ?n ⟹ ?P; ?m = ?n ⟹ ?P⟧ ⟹ ?P›*) by (metis (no_types, lifting) add_diff_inverse_nat (*‹¬ ?m < ?n ⟹ ?n + (?m - ?n) = ?m›*) less_one (*‹(?n < 1) = (?n = 0)›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) not_less_eq (*‹(¬ ?m < ?n) = (?n < Suc ?m)›*) plus_1_eq_Suc (*‹(+) 1 = Suc›*))
thm S_is_dense
hence "k'∈S"
apply (intro S_is_dense[of f Y a₁ a a⇩n _ b "Max S"] (*‹⟦[f↝Y|a₁..a..a⇩n]; ?S = {k. [a₁;f k;b] ∧ k < card Y}; ?S ≠ {}; Max S = Max ?S; 0 < ?k'; ?k' < Max S⟧ ⟹ ?k' ∈ ?S›*))
(*goal: ‹(k'::nat) ∈ (S::nat set)›*)
apply (simp add: long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*))
(*top goal: ‹(k::nat) < (k'::nat) ⟹ [f::nat ⇒ 'a↝Y::'a set|a₁::'a..a::'a..a⇩n::'a]› and 5 goals remain*)
apply (smt (verit, ccfv_SIG) S_def (*‹S = {k. [a⇩n;f k;b] ∧ k < card Y}›*) ‹k ∈ S› abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) 4) add_diff_inverse_nat (*‹¬ ?m < ?n ⟹ ?n + (?m - ?n) = ?m›*) bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) chY2 (*‹local_long_ch_by_ord f Y›*) diff_add_zero (*‹?a - (?a + ?b) = 0›*) diff_is_0_eq (*‹(?m - ?n = 0) = (?m ≤ ?n)›*) fin_Y (*‹finite Y›*) k'_def( (*‹k' < card Y - 1› ‹[a⇩n;b;f k']›*) 1,3) less_add_one (*‹?a < ?a + 1›*) less_diff_conv2 (*‹?k ≤ ?j ⟹ (?j - ?k < ?i) = (?j < ?i + ?k)›*) less_nat_zero_code (*‹(?n < 0) = False›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*))
(*top goal: ‹k < k' ⟹ S = {k. [a₁;f k;b] ∧ k < card Y}› and 4 goals remain*)
apply (simp add: ‹S ≠ {}›, simp, simp)
(*top goal: ‹(k::nat) < (k'::nat) ⟹ (S::nat set) ≠ {}› and 3 goals remain*)
using k'_def (*‹k' < card Y - 1› ‹k - 1 < k'› ‹[a⇩n;b;f k']›*) S_def (*‹S = {k. [a⇩n;f k;b] ∧ k < card Y}›*) by (smt (verit, ccfv_SIG) ‹k ∈ S› abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) 4) add_diff_cancel_right' (*‹?a + ?b - ?b = ?a›*) add_diff_inverse_nat (*‹¬ ?m < ?n ⟹ ?n + (?m - ?n) = ?m›*) bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) chY2 (*‹local_long_ch_by_ord f Y›*) fin_Y (*‹finite Y›*) le_eq_less_or_eq (*‹(?m ≤ ?n) = (?m < ?n ∨ ?m = ?n)›*) less_nat_zero_code (*‹(?n < 0) = False›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) nat_neq_iff (*‹(?m ≠ ?n) = (?m < ?n ∨ ?n < ?m)›*) order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) zero_less_diff (*‹(0 < ?n - ?m) = (?m < ?n)›*) zero_less_one (*‹0 < 1›*))
thus False
using S_def (*‹S = {k. [a⇩n;f k;b] ∧ k < card Y}›*) abc_only_cba(2) (*‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?a;?c;?b]›*) k'_def(3) (*‹[a⇩n;b;f k']›*) by blast
qed
qed
qed
qed
qed
lemma get_closest_chain_events:
assumes long_ch_Y: "[f↝Y|a₀..a..a⇩n]"
and x_def: "x∉Y" "[a₀; x; a⇩n]"
obtains n⇩b n⇩c b c
where "b=f n⇩b" "c=f n⇩c" "[b;x;c]" "b∈Y" "c∈Y" "n⇩b = n⇩c - 1" "n⇩c<card Y" "n⇩c>0"
"¬(∃k < card Y. [f k; x; a⇩n] ∧ k>n⇩b)" "¬(∃k<n⇩c. [a₀; x; f k])"
proof (-)
(*goal: ‹(⋀b n⇩b c n⇩c. ⟦b = f n⇩b; c = f n⇩c; [b;x;c]; b ∈ Y; c ∈ Y; n⇩b = n⇩c - 1; n⇩c < card Y; 0 < n⇩c; ¬ (∃k<card Y. [f k;x;a⇩n] ∧ n⇩b < k); ¬ (∃k<n⇩c. [a₀;x;f k])⟧ ⟹ thesis) ⟹ thesis›*)
have "∃ n⇩b n⇩c b c. b=f n⇩b ∧ c=f n⇩c ∧ [b;x;c] ∧ b∈Y ∧ c∈Y ∧ n⇩b = n⇩c - 1 ∧ n⇩c<card Y ∧ n⇩c>0
∧ ¬(∃k < card Y. [f k; x; a⇩n] ∧ k>n⇩b) ∧ ¬(∃k < n⇩c. [a₀; x; f k])"
proof (-)
(*goal: ‹∃(n⇩b::nat) (n⇩c::nat) (b::'a) c::'a. b = (f::nat ⇒ 'a) n⇩b ∧ c = f n⇩c ∧ [b;x::'a;c] ∧ b ∈ (Y::'a set) ∧ c ∈ Y ∧ n⇩b = n⇩c - (1::nat) ∧ n⇩c < card Y ∧ (0::nat) < n⇩c ∧ ¬ (∃k<card Y. [f k;x;a⇩n::'a] ∧ n⇩b < k) ∧ ¬ (∃k<n⇩c. [a₀::'a;x;f k])›*)
have bound_indices: "f 0 = a₀ ∧ f (card Y - 1) = a⇩n"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_Y (*‹[f↝Y|a₀..a..a⇩n]›*) by simp
have fin_Y: "finite Y"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a::type) (?X::'a::type set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_Y (*‹[f↝Y|a₀..a..a⇩n]›*) by presburger
have card_Y: "card Y ≥ 3"
using long_ch_Y (*‹[f↝Y|a₀..a..a⇩n]›*) points_in_long_chain (*‹[?f↝?Q|?x..?y..?z] ⟹ ?x ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?y ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?z ∈ ?Q›*) finite_long_chain_with_card (*‹[?f↝?Q|?x..?y..?z] ⟹ 3 ≤ card ?Q›*) by blast
have chY2: "local_long_ch_by_ord f Y"
using long_ch_Y (*‹[f↝Y|a₀..a..a⇩n]›*) chain_defs (*‹short_ch (?X::'a::type set) ≡ card ?X = (2::nat) ∧ (∃P::'a::type set∈𝒫::'a::type set set. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (meson card_Y (*‹3 ≤ card Y›*) long_ch_card_ge3 (*‹⟦[?f↝?X]; finite ?X⟧ ⟹ local_long_ch_by_ord ?f ?X = (3 ≤ card ?X)›*))
obtain P where P_def: "P∈𝒫" "Y⊆P"
(*goal: ‹(⋀P. ⟦P ∈ 𝒫; Y ⊆ P⟧ ⟹ thesis) ⟹ thesis›*)
using fin_chain_on_path (*‹⟦[?f↝?X]; finite ?X⟧ ⟹ ∃!P. P ∈ 𝒫 ∧ ?X ⊆ P›*) long_ch_Y (*‹[f::nat ⇒ 'a::type↝Y::'a::type set|a₀::'a::type..a::'a::type..a⇩n::'a::type]›*) fin_Y (*‹finite Y›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a .. ?y::'a] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by meson
hence "x∈P"
using betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) x_def(2) (*‹[a₀;x;a⇩n]›*) long_ch_Y (*‹[f↝Y|a₀..a..a⇩n]›*) points_in_long_chain (*‹[?f↝?Q|?x..?y..?z] ⟹ ?x ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?y ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?z ∈ ?Q›*) by (metis abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*))
obtain n⇩c where nc_def: "¬(∃k. [a₀; x; f k] ∧ k<n⇩c)" "[a₀; x; f n⇩c]" "n⇩c<card Y" "n⇩c>0"
(*goal: ‹(⋀n⇩c::nat. ⟦∄k::nat. [a₀::'a::type;x::'a::type;(f::nat ⇒ 'a::type) k] ∧ k < n⇩c; [a₀;x;f n⇩c]; n⇩c < card (Y::'a::type set); (0::nat) < n⇩c⟧ ⟹ thesis::bool) ⟹ thesis›*)
using smallest_k_ex[where a₁ = a₀ and a = a and a⇩n = a⇩n and b = x and f = f and Y = Y] (*‹⟦[f↝Y|a₀..a..a⇩n]; x ∉ Y; [a₀;x;a⇩n]⟧ ⟹ ∃k>0. [a₀;x;f k] ∧ k < card Y ∧ ¬ (∃k'<k. [a₀;x;f k'])›*) long_ch_Y (*‹[f↝Y|a₀..a..a⇩n]›*) x_def (*‹x ∉ Y› ‹[a₀;x;a⇩n]›*) by blast
then obtain c where c_def: "c=f n⇩c" "c∈Y"
(*goal: ‹(⋀c::'a::type. ⟦c = (f::nat ⇒ 'a::type) (n⇩c::nat); c ∈ (Y::'a::type set)⟧ ⟹ thesis::bool) ⟹ thesis›*)
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a::type set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a::type. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type .. ?y::'a::type] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) local_ordering_def (*‹local_ordering (?f::nat ⇒ ?'a) (?ord::?'a ⇒ ?'a ⇒ ?'a ⇒ bool) (?X::?'a set) ≡ (∀n::nat. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x::?'a∈?X. ∃n::nat. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n::nat. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) by (metis chY2 (*‹local_long_ch_by_ord (f::nat ⇒ 'a::type) (Y::'a::type set)›*))
have c_goal: "c=f n⇩c ∧ c∈Y ∧ n⇩c<card Y ∧ n⇩c>0 ∧ ¬(∃k < card Y. [a₀; x; f k] ∧ k<n⇩c)"
using c_def (*‹c = f n⇩c› ‹c ∈ Y›*) nc_def(1,3,4) (*‹∄k. [a₀;x;f k] ∧ k < n⇩c› ‹n⇩c < card Y› ‹0 < n⇩c›*) by blast
obtain n⇩b where nb_def: "¬(∃k < card Y. [f k; x; a⇩n] ∧ k>n⇩b)" "[f n⇩b; x; a⇩n]" "n⇩b<card Y-1"
(*goal: ‹(⋀n⇩b. ⟦¬ (∃k<card Y. [f k;x;a⇩n] ∧ n⇩b < k); [f n⇩b;x;a⇩n]; n⇩b < card Y - 1⟧ ⟹ thesis) ⟹ thesis›*)
using greatest_k_ex[where a₁ = a₀ and a = a and a⇩n = a⇩n and b = x and f = f and Y = Y] (*‹⟦[f↝Y|a₀..a..a⇩n]; x ∉ Y; [a₀;x;a⇩n]⟧ ⟹ ∃k. [f k;x;a⇩n] ∧ k < card Y - 1 ∧ ¬ (∃k'<card Y. k < k' ∧ [f k';x;a⇩n])›*) long_ch_Y (*‹[f↝Y|a₀..a..a⇩n]›*) x_def (*‹(x::'a::type) ∉ (Y::'a::type set)› ‹[a₀;x;a⇩n]›*) by blast
hence "n⇩b<card Y"
by linarith
then obtain b where b_def: "b=f n⇩b" "b∈Y"
(*goal: ‹(⋀b. ⟦b = f n⇩b; b ∈ Y⟧ ⟹ thesis) ⟹ thesis›*)
using nb_def (*‹¬ (∃k<card (Y::'a set). [(f::nat ⇒ 'a) k;x::'a;a⇩n::'a] ∧ (n⇩b::nat) < k)› ‹[f n⇩b;x;a⇩n]› ‹n⇩b < card Y - 1›*) chY2 (*‹local_long_ch_by_ord f Y›*) local_ordering_def (*‹local_ordering (?f::nat ⇒ ?'a) (?ord::?'a ⇒ ?'a ⇒ ?'a ⇒ bool) (?X::?'a set) ≡ (∀n::nat. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x::?'a∈?X. ∃n::nat. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n::nat. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) by (metis local_long_ch_by_ord_alt (*‹local_long_ch_by_ord ?f ?X = (∃x∈?X. ∃y∈?X. ∃z∈?X. x ≠ y ∧ y ≠ z ∧ x ≠ z ∧ local_ordering ?f betw ?X)›*))
have "[b;x;c]"
proof (-)
(*goal: ‹[b;x;c]›*)
have "[b; x; a⇩n]"
using b_def(1) (*‹b = f n⇩b›*) nb_def(2) (*‹[f n⇩b;x;a⇩n]›*) by blast
have "[a₀; x; c]"
using c_def(1) (*‹(c::'a) = (f::nat ⇒ 'a) (n⇩c::nat)›*) nc_def(2) (*‹[a₀;x;f n⇩c]›*) by blast
moreover have "∀a. [a;x;b] ∨ ¬ [a; a⇩n; x]"
using ‹[b; x; a⇩n]› (*‹[b::'a;x::'a;a⇩n::'a]›*) abc_bcd_acd (*‹⟦[?a::'a;?b::'a;?c::'a]; [?b;?c;?d::'a]⟧ ⟹ [?a;?c;?d]›*) by (metis (full_types) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*))
moreover have "∀a. [a;x;b] ∨ ¬ [a⇩n; a; x]"
using ‹[b; x; a⇩n]› (*‹[b;x;a⇩n]›*) by (meson abc_acd_bcd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?b;?c;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*))
moreover have "a⇩n = c ⟶ [b;x;c]"
using ‹[b; x; a⇩n]› (*‹[b;x;a⇩n]›*) by meson
ultimately show "?thesis"
(*goal: ‹[b;x;c]›*)
using abc_abd_bcdbdc (*‹⟦[?a;?b;?c]; [?a;?b;?d]; ?c ≠ ?d⟧ ⟹ [?b;?c;?d] ∨ [?b;?d;?c]›*) abc_sym (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ [?c;?b;?a]›*) x_def(2) (*‹[a₀::'a::type;x::'a::type;a⇩n::'a::type]›*) by meson
qed
have "n⇩b<n⇩c"
using ‹[b;x;c]› (*‹[b;x;c]›*) ‹n⇩c<card Y› (*‹n⇩c < card Y›*) ‹n⇩b<card Y› (*‹(n⇩b::nat) < card (Y::'a::type set)›*) ‹c = f n⇩c› (*‹(c::'a) = (f::nat ⇒ 'a) (n⇩c::nat)›*) ‹b = f n⇩b› (*‹(b::'a) = (f::nat ⇒ 'a) (n⇩b::nat)›*) by (smt (z3) abc_abd_bcdbdc (*‹⟦[?a;?b;?c]; [?a;?b;?d]; ?c ≠ ?d⟧ ⟹ [?b;?c;?d] ∨ [?b;?d;?c]›*) abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) 4) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) bot_nat_0.extremum (*‹0 ≤ ?a›*) bound_indices (*‹f 0 = a₀ ∧ f (card Y - 1) = a⇩n›*) chY2 (*‹local_long_ch_by_ord f Y›*) fin_Y (*‹finite Y›*) nat_neq_iff (*‹(?m ≠ ?n) = (?m < ?n ∨ ?n < ?m)›*) nc_def( (*‹[a₀;x;f n⇩c]›*) 2) nc_def( (*‹0 < n⇩c›*) 4) order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*))
have "n⇩b = n⇩c - 1"
proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*))
(*goal: ‹n⇩b ≠ n⇩c - 1 ⟹ False›*)
assume "n⇩b ≠ n⇩c - 1" (*‹(n⇩b::nat) ≠ (n⇩c::nat) - (1::nat)›*)
have "n⇩b<n⇩c-1"
using ‹n⇩b ≠ n⇩c - 1› (*‹n⇩b ≠ n⇩c - 1›*) ‹n⇩b<n⇩c› (*‹n⇩b < n⇩c›*) by linarith
hence "[f n⇩b; (f(n⇩c-1)); f n⇩c]"
using ‹n⇩b ≠ n⇩c - 1› (*‹n⇩b ≠ n⇩c - 1›*) long_ch_Y (*‹[f↝Y|a₀..a..a⇩n]›*) nc_def(3) (*‹n⇩c < card Y›*) order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by auto
have "¬[a₀; x; (f(n⇩c-1))]"
using nc_def(1,4) (*‹∄k. [a₀;x;f k] ∧ k < n⇩c› ‹0 < n⇩c›*) diff_less (*‹⟦0 < ?n; 0 < ?m⟧ ⟹ ?m - ?n < ?m›*) less_numeral_extra(1) (*‹0 < 1›*) by blast
have "n⇩c-1≠0"
using ‹n⇩b < n⇩c› (*‹n⇩b < n⇩c›*) ‹n⇩b ≠ n⇩c - 1› (*‹n⇩b ≠ n⇩c - 1›*) by linarith
hence "f(n⇩c-1)≠a₀ ∧ a₀≠x"
using bound_indices (*‹f 0 = a₀ ∧ f (card Y - 1) = a⇩n›*) ‹n⇩b < n⇩c - 1› (*‹n⇩b < n⇩c - 1›*) abc_abc_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) less_imp_diff_less (*‹(?j::nat) < (?k::nat) ⟹ ?j - (?n::nat) < ?k›*) nb_def(1) (*‹¬ (∃k<card Y. [f k;x;a⇩n] ∧ n⇩b < k)›*) nc_def(3) (*‹n⇩c < card Y›*) x_def(2) (*‹[a₀;x;a⇩n]›*) by blast
have "x≠f(n⇩c-1)"
using x_def(1) (*‹x ∉ Y›*) nc_def(3) (*‹n⇩c < card Y›*) chY2 (*‹local_long_ch_by_ord f Y›*) unfolding chain_defs local_ordering_def
(*goal: ‹(x::'a) ≠ (f::nat ⇒ 'a) ((n⇩c::nat) - (1::nat))›*)
by (metis One_nat_def (*‹1 = Suc 0›*) Suc_pred (*‹0 < ?n ⟹ Suc (?n - Suc 0) = ?n›*) less_Suc_eq (*‹(?m < Suc ?n) = (?m < ?n ∨ ?m = ?n)›*) nc_def( (*‹0 < n⇩c›*) 4) not_less_eq (*‹(¬ ?m < ?n) = (?n < Suc ?m)›*))
hence "[a₀; f (n⇩c-1); x]"
using long_ch_Y (*‹[f↝Y|a₀..a..a⇩n]›*) nc_def (*‹∄k::nat. [a₀::'a::type;x::'a::type;(f::nat ⇒ 'a::type) k] ∧ k < (n⇩c::nat)› ‹[a₀;x;f n⇩c]› ‹n⇩c < card Y› ‹(0::nat) < (n⇩c::nat)›*) c_def (*‹c = f n⇩c› ‹c ∈ Y›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis ‹[f n⇩b;f (n⇩c - 1);f n⇩c]› ‹¬ [a₀;x;f (n⇩c - 1)]› abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) abd_acd_abcacb (*‹⟦[?a;?b;?d]; [?a;?c;?d]; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?a;?c;?b]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) b_def( (*‹b = f n⇩b›*) 1) b_def( (*‹b ∈ Y›*) 2) fin_ch_betw2 (*‹⟦[?f↝?X|?a .. ?c]; ?b ∈ ?X; ?b = ?a ⟹ ?thesis; ?b = ?c ⟹ ?thesis; [?a;?b;?c] ⟹ ?thesis⟧ ⟹ ?thesis›*) nb_def( (*‹[f n⇩b;x;a⇩n]›*) 2))
hence "[(f(n⇩c-1)); x; a⇩n]"
using abc_acd_bcd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?b;?c;?d]›*) x_def(2) (*‹[a₀;x;a⇩n]›*) by blast
thus False
using nb_def(1) (*‹¬ (∃k<card Y. [f k;x;a⇩n] ∧ n⇩b < k)›*) using ‹n⇩b < n⇩c - 1› (*‹(n⇩b::nat) < (n⇩c::nat) - (1::nat)›*) less_imp_diff_less (*‹?j < ?k ⟹ ?j - ?n < ?k›*) nc_def(3) (*‹n⇩c < card Y›*) by blast
qed
have b_goal: "b=f n⇩b ∧ b∈Y ∧ n⇩b=n⇩c-1 ∧ ¬(∃k < card Y. [f k; x; a⇩n] ∧ k>n⇩b)"
using b_def (*‹b = f n⇩b› ‹(b::'a) ∈ (Y::'a set)›*) nb_def(1) (*‹¬ (∃k<card Y. [f k;x;a⇩n] ∧ n⇩b < k)›*) nb_def(3) (*‹n⇩b < card Y - 1›*) ‹n⇩b=n⇩c-1› (*‹n⇩b = n⇩c - 1›*) by blast
thus "?thesis"
(*goal: ‹∃(n⇩b::nat) (n⇩c::nat) (b::'a) c::'a. b = (f::nat ⇒ 'a) n⇩b ∧ c = f n⇩c ∧ [b;x::'a;c] ∧ b ∈ (Y::'a set) ∧ c ∈ Y ∧ n⇩b = n⇩c - (1::nat) ∧ n⇩c < card Y ∧ (0::nat) < n⇩c ∧ ¬ (∃k<card Y. [f k;x;a⇩n::'a] ∧ n⇩b < k) ∧ ¬ (∃k<n⇩c. [a₀::'a;x;f k])›*)
using ‹[b;x;c]› (*‹[b;x;c]›*) c_goal (*‹(c::'a::type) = (f::nat ⇒ 'a::type) (n⇩c::nat) ∧ c ∈ (Y::'a::type set) ∧ n⇩c < card Y ∧ (0::nat) < n⇩c ∧ ¬ (∃k<card Y. [a₀::'a::type;x::'a::type;f k] ∧ k < n⇩c)›*) using ‹n⇩b < card Y› (*‹n⇩b < card Y›*) nc_def(1) (*‹∄k. [a₀;x;f k] ∧ k < n⇩c›*) by auto
qed
thus "?thesis"
(*goal: ‹thesis›*)
using that (*‹⟦?b = f ?n⇩b; ?c = f ?n⇩c; [?b;x;?c]; ?b ∈ Y; ?c ∈ Y; ?n⇩b = ?n⇩c - 1; ?n⇩c < card Y; 0 < ?n⇩c; ¬ (∃k<card Y. [f k;x;a⇩n] ∧ ?n⇩b < k); ¬ (∃k<?n⇩c. [a₀;x;f k])⟧ ⟹ thesis›*) by auto
qed
text ‹This is case (ii) of the induction in Theorem 10.›
lemma (*for 10*) chain_append_inside:
assumes long_ch_Y: "[f↝Y|a₁..a..a⇩n]"
and Y_def: "b∉Y"
and Yb: "[a₁; b; a⇩n]"
and k_def: "[a₁; b; f k]" "k < card Y" "¬(∃k'. (0::nat)<k' ∧ k'<k ∧ [a₁; b; f k'])"
fixes g
defines g_def: "g ≡ (λj::nat. if (j≤k-1) then f j else (if (j=k) then b else f (j-1)))"
shows "[g↝insert b Y|a₁ .. b .. a⇩n]"
proof (-)
(*goal: ‹[g↝insert b Y|a₁..b..a⇩n]›*)
let ?X = "insert b Y"
have fin_X: "finite ?X"
by (meson chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) finite.insertI (*‹finite ?A ⟹ finite (insert ?a ?A)›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*))
have bound_indices: "f 0 = a₁ ∧ f (card Y - 1) = a⇩n"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f::nat ⇒ 'a↝?X::'a set] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type .. ?y::'a::type] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) by auto
have fin_Y: "finite Y"
using chain_defs (*‹short_ch (?X::'a set) ≡ card ?X = (2::nat) ∧ (∃P::'a set∈𝒫::'a set set. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) by presburger
have f_def: "local_long_ch_by_ord f Y"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f::nat ⇒ 'a::type↝?X::'a::type set] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) by (meson finite_long_chain_with_card (*‹[?f↝?Q|?x..?y..?z] ⟹ 3 ≤ card ?Q›*) long_ch_card_ge3 (*‹⟦[?f↝?X]; finite ?X⟧ ⟹ local_long_ch_by_ord ?f ?X = (3 ≤ card ?X)›*))
have "a₁ ≠ a⇩n ∧ a₁ ≠ b ∧ b ≠ a⇩n"
using Yb (*‹[a₁;b;a⇩n]›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) by blast
have "k ≠ 0"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) k_def (*‹[a₁;b;f k]› ‹k < card Y› ‹¬ (∃k'>0. k' < k ∧ [a₁;b;f k'])›*) by metis
have b_middle: "[f(k-1); b; f k]"
proof (cases)
(*goals:
1. ‹?P ⟹ [f (k - 1);b;f k]›
2. ‹¬ ?P ⟹ [f (k - 1);b;f k]›*)
assume "k=1" (*‹(k::nat) = (1::nat)›*)
show "[f(k-1); b; f k]"
using ‹[a₁; b; f k]› (*‹[a₁;b;f k]›*) ‹k = 1› (*‹k = 1›*) bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) by auto
next
(*goal: ‹k ≠ 1 ⟹ [f (k - 1);b;f k]›*)
assume "k≠1" (*‹(k::nat) ≠ (1::nat)›*)
show "[f(k-1); b; f k]"
proof (-)
(*goal: ‹[f (k - 1);b;f k]›*)
have a1k: "[a₁; f (k-1); f k]"
using bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) using ‹k < card Y› (*‹k < card Y›*) ‹k ≠ 0› (*‹k ≠ 0›*) ‹k ≠ 1› (*‹k ≠ 1›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) fin_Y (*‹finite Y›*) order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) unfolding chain_defs
(*goal: ‹[a₁::'a;(f::nat ⇒ 'a) ((k::nat) - (1::nat));f k]›*)
by auto
text ‹In fact, the comprehension below gives the order of elements too.
Our notation and Theorem 9 are too weak to say that just now.›
have ch_with_b: "ch {a₁, (f (k-1)), b, (f k)}"
using chain4 (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?d ∈ ?Q; ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?a ≠ ?d ∧ ?b ≠ ?c ∧ ?b ≠ ?d ∧ ?c ≠ ?d⟧ ⟹ ch {?a, ?b, ?c, ?d}›*) using k_def(1) (*‹[a₁;b;f k]›*) abc_ex_path_unique (*‹[?a;?b;?c] ⟹ ∃!Q. Q ∈ 𝒫 ∧ ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) between_chain (*‹[?a;?b;?c] ⟹ ch {?a, ?b, ?c}›*) cross_once_notin (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R; ?a ≠ ?b; ?Q ≠ ?R⟧ ⟹ ?a ∉ ?R›*) by (smt ‹[a₁; f (k-1); f k]› abc_abc_neq (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) insert_absorb2 (*‹insert (?x::?'a::type) (insert ?x (?A::?'a::type set)) = insert ?x ?A›*))
have "f (k-1) ≠ b ∧ (f k) ≠ (f (k-1)) ∧ b ≠ (f k)"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) f_def (*‹local_long_ch_by_ord f Y›*) k_def(2) (*‹k < card Y›*) Y_def (*‹(b::'a) ∉ (Y::'a set)›*) by (metis local_ordering_def (*‹local_ordering ?f ?ord ?X ≡ (∀n. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x∈?X. ∃n. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) ‹[a₁; f (k-1); f k]› less_imp_diff_less (*‹?j < ?k ⟹ ?j - ?n < ?k›*) local_long_ch_by_ord_def (*‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X›*))
hence some_ord_bk: "[f(k-1); b; f k] ∨ [b; f (k-1); f k] ∨ [f (k-1); f k; b]"
using fin_chain_on_path (*‹⟦[?f::nat ⇒ 'a↝?X::'a set]; finite ?X⟧ ⟹ ∃!P::'a set. P ∈ (𝒫::'a set set) ∧ ?X ⊆ P›*) ch_with_b (*‹ch {a₁, f (k - 1), b, f k}›*) some_betw (*‹⟦(?Q::'a::type set) ∈ (𝒫::'a::type set set); (?a::'a::type) ∈ ?Q; (?b::'a::type) ∈ ?Q; (?c::'a::type) ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) Y_def (*‹b ∉ Y›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis a1k (*‹[a₁;f (k - 1);f k]›*) abc_acd_bcd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?b;?c;?d]›*) abd_acd_abcacb (*‹⟦[?a;?b;?d]; [?a;?c;?d]; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?a;?c;?b]›*) k_def( (*‹[a₁;b;f k]›*) 1))
thus "[f(k-1); b; f k]"
proof (-)
(*goal: ‹[f (k - 1);b;f k] ∨ [b;f (k - 1);f k] ∨ [f (k - 1);f k;b] ⟹ [f (k - 1);b;f k]›*)
have "¬ [a₁; f k; b]"
by (simp add: ‹[a₁; b; f k]› abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) 2))
thus "?thesis"
(*goal: ‹[f (k - 1);b;f k]›*)
using some_ord_bk (*‹[(f::nat ⇒ 'a::type) ((k::nat) - (1::nat));b::'a::type;f k] ∨ [b;f (k - (1::nat));f k] ∨ [f (k - (1::nat));f k;b]›*) k_def (*‹[a₁;b;f k]› ‹(k::nat) < card (Y::'a set)› ‹¬ (∃k'>0. k' < k ∧ [a₁;b;f k'])›*) abc_bcd_acd (*‹⟦[?a::'a::type;?b::'a::type;?c::'a::type]; [?b;?c;?d::'a::type]⟧ ⟹ [?a;?c;?d]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) bound_indices (*‹(f::nat ⇒ 'a) (0::nat) = (a₁::'a) ∧ f (card (Y::'a set) - (1::nat)) = (a⇩n::'a)›*) by (metis diff_is_0_eq' (*‹?m ≤ ?n ⟹ ?m - ?n = 0›*) diff_less (*‹⟦0 < ?n; 0 < ?m⟧ ⟹ ?m - ?n < ?m›*) less_imp_diff_less (*‹?j < ?k ⟹ ?j - ?n < ?k›*) less_irrefl_nat (*‹?n < ?n ⟹ ?R›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) zero_less_diff (*‹(0 < ?n - ?m) = (?m < ?n)›*) zero_less_one (*‹0 < 1›*) ‹[a₁; b; f k]› a1k (*‹[a₁;f (k - 1);f k]›*))
qed
qed
qed
let ?case1 ∨ ?case2 = "k-2 ≥ 0 ∨ k+1 ≤ card Y -1"
have b_right: "[f (k-2); f (k-1); b]" if "k ≥ 2"
proof (-)
(*goal: ‹[f (k - 2);f (k - 1);b]›*)
have "k-1 < (k::nat)"
using ‹k ≠ 0› (*‹k ≠ 0›*) diff_less (*‹⟦(0::nat) < (?n::nat); (0::nat) < (?m::nat)⟧ ⟹ ?m - ?n < ?m›*) zero_less_one (*‹0 < 1›*) by blast
hence "k-2 < k-1"
using ‹2 ≤ k› (*‹2 ≤ k›*) by linarith
have "[f (k-2); f (k-1); b]"
using abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) b_middle (*‹[f (k - 1);b;f k]›*) f_def (*‹local_long_ch_by_ord f Y›*) k_def(2) (*‹k < card Y›*) fin_Y (*‹finite (Y::'a set)›*) ‹k-2 < k-1› (*‹(k::nat) - (2::nat) < k - (1::nat)›*) ‹k-1 < k› (*‹k - 1 < k›*) thm2_ind2 (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X⟧ ⟹ ∀m l. 0 < l - m ∧ l - m < l ∧ l < card ?X ⟶ [?f (l - m - 1);?f (l - m);?f l]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis Suc_1 (*‹Suc (1::nat) = (2::nat)›*) Suc_le_lessD (*‹Suc (?m::nat) ≤ (?n::nat) ⟹ ?m < ?n›*) diff_Suc_eq_diff_pred (*‹(?m::nat) - Suc (?n::nat) = ?m - (1::nat) - ?n›*) that (*‹(2::nat) ≤ (k::nat)›*) zero_less_diff (*‹((0::nat) < (?n::nat) - (?m::nat)) = (?m < ?n)›*))
thus "[f (k-2); f (k-1); b]"
using ‹[f(k - 1); b; f k]› (*‹[f (k - 1);b;f k]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) by blast
qed
have b_left: "[b; f k; f (k+1)]" if "k+1 ≤ card Y -1"
proof (-)
(*goal: ‹[b;f k;f (k + 1)]›*)
have "[f (k-1); f k; f (k+1)]"
using ‹k ≠ 0› (*‹k ≠ 0›*) f_def (*‹local_long_ch_by_ord f Y›*) fin_Y (*‹finite Y›*) order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) that (*‹k + 1 ≤ card Y - 1›*) by auto
thus "[b; f k; f (k+1)]"
using ‹[f (k - 1); b; f k]› (*‹[f (k - 1);b;f k]›*) abc_acd_bcd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?b;?c;?d]›*) by blast
qed
have "local_ordering g betw ?X"
proof (-)
(*goal: ‹local_ordering g betw (insert b Y)›*)
have "∀n. (finite ?X ⟶ n < card ?X) ⟶ g n ∈ ?X"
proof (clarify)
(*goal: ‹⋀n. ⟦finite (insert b Y) ⟶ n < card (insert b Y); g n ∉ Y⟧ ⟹ g n = b›*)
fix n
assume "finite ?X ⟶ n < card ?X" "g n ∉ Y" (*‹finite (insert (b::'a) (Y::'a set)) ⟶ (n::nat) < card (insert b Y)› ‹(g::nat ⇒ 'a) (n::nat) ∉ (Y::'a set)›*)
consider "n≤k-1" | "n≥k+1" | "n=k"
(*goal: ‹⟦n ≤ k - 1 ⟹ thesis; k + 1 ≤ n ⟹ thesis; n = k ⟹ thesis⟧ ⟹ thesis›*)
by linarith
thus "g n = b"
proof (cases)
(*goals:
1. ‹n ≤ k - 1 ⟹ g n = b›
2. ‹k + 1 ≤ n ⟹ g n = b›
3. ‹n = k ⟹ g n = b›*)
assume "n ≤ k - 1" (*‹(n::nat) ≤ (k::nat) - (1::nat)›*)
thus "g n = b"
using f_def (*‹local_long_ch_by_ord f Y›*) k_def(2) (*‹k < card Y›*) Y_def(1) (*‹b ∉ Y›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f::nat ⇒ 'a↝?X::'a set] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) local_ordering_def (*‹local_ordering ?f ?ord ?X ≡ (∀n. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x∈?X. ∃n. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) g_def (*‹g::nat ⇒ 'a::type ≡ λj::nat. if j ≤ (k::nat) - (1::nat) then (f::nat ⇒ 'a::type) j else if j = k then b::'a::type else f (j - (1::nat))›*) by (metis ‹g n ∉ Y› ‹k ≠ 0› diff_less (*‹⟦0 < ?n; 0 < ?m⟧ ⟹ ?m - ?n < ?m›*) le_less (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*) less_one (*‹(?n < 1) = (?n = 0)›*) less_trans (*‹⟦?x < ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*))
next
(*goals:
1. ‹k + 1 ≤ n ⟹ g n = b›
2. ‹n = k ⟹ g n = b›*)
assume "k + 1 ≤ n" (*‹(k::nat) + (1::nat) ≤ (n::nat)›*)
show "g n = b"
proof (-)
(*goal: ‹(g::nat ⇒ 'a) (n::nat) = (b::'a)›*)
have "f n ∈ Y ∨ ¬(n < card Y)" for n
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a::type set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a::type. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis local_ordering_def (*‹local_ordering ?f ?ord ?X ≡ (∀n. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x∈?X. ∃n. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) f_def (*‹local_long_ch_by_ord f Y›*))
then show "g n = b"
using ‹finite ?X ⟶ n < card ?X› (*‹finite (insert b Y) ⟶ n < card (insert b Y)›*) fin_Y (*‹finite (Y::'a::type set)›*) g_def (*‹g ≡ λj. if j ≤ k - 1 then f j else if j = k then b else f (j - 1)›*) Y_def (*‹b ∉ Y›*) ‹g n ∉ Y› (*‹g n ∉ Y›*) ‹k + 1 ≤ n› (*‹k + 1 ≤ n›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) not_less_simps(1) (*‹¬ ?n < ?m ⟹ (?n < Suc ?m) = (?n = ?m)›*) not_one_le_zero (*‹¬ 1 ≤ 0›*) by fastforce
qed
next
(*goal: ‹n = k ⟹ g n = b›*)
assume "n=k" (*‹(n::nat) = (k::nat)›*)
thus "g n = b"
using Y_def (*‹b ∉ Y›*) ‹k ≠ 0› (*‹(k::nat) ≠ (0::nat)›*) g_def (*‹g ≡ λj. if j ≤ k - 1 then f j else if j = k then b else f (j - 1)›*) by auto
qed
qed
moreover have "∀x∈?X. ∃n. (finite ?X ⟶ n < card ?X) ∧ g n = x"
proof (standard)
(*goal: ‹⋀x. x ∈ insert b Y ⟹ ∃n. (finite (insert b Y) ⟶ n < card (insert b Y)) ∧ g n = x›*)
fix x
assume "x∈?X" (*‹(x::'a) ∈ insert (b::'a) (Y::'a set)›*)
show "∃n. (finite ?X ⟶ n < card ?X) ∧ g n = x"
proof (cases)
(*goals:
1. ‹?P ⟹ ∃n. (finite (insert b Y) ⟶ n < card (insert b Y)) ∧ g n = x›
2. ‹¬ ?P ⟹ ∃n. (finite (insert b Y) ⟶ n < card (insert b Y)) ∧ g n = x›*)
assume "x∈Y" (*‹(x::'a) ∈ (Y::'a set)›*)
show "?thesis"
(*goal: ‹∃n::nat. (finite (insert (b::'a) (Y::'a set)) ⟶ n < card (insert b Y)) ∧ (g::nat ⇒ 'a) n = (x::'a)›*)
proof (-)
(*goal: ‹∃n. (finite (insert b Y) ⟶ n < card (insert b Y)) ∧ g n = x›*)
obtain ix where "f ix = x" "ix < card Y"
(*goal: ‹(⋀ix::nat. ⟦(f::nat ⇒ 'a) ix = (x::'a); ix < card (Y::'a set)⟧ ⟹ thesis::bool) ⟹ thesis›*)
using ‹x ∈ Y› (*‹x ∈ Y›*) f_def (*‹local_long_ch_by_ord (f::nat ⇒ 'a) (Y::'a set)›*) fin_Y (*‹finite Y›*) unfolding chain_defs local_ordering_def
(*goal: ‹(⋀ix. ⟦f ix = x; ix < card Y⟧ ⟹ thesis) ⟹ thesis›*)
by auto
have "ix≤k-1 ∨ ix≥k"
by linarith
thus "?thesis"
(*goal: ‹∃n::nat. (finite (insert (b::'a) (Y::'a set)) ⟶ n < card (insert b Y)) ∧ (g::nat ⇒ 'a) n = (x::'a)›*)
proof (standard)
(*goals:
1. ‹ix ≤ k - 1 ⟹ ∃n. (finite (insert b Y) ⟶ n < card (insert b Y)) ∧ g n = x›
2. ‹k ≤ ix ⟹ ∃n. (finite (insert b Y) ⟶ n < card (insert b Y)) ∧ g n = x›*)
assume "ix≤k-1" (*‹(ix::nat) ≤ (k::nat) - (1::nat)›*)
hence "g ix = x"
using ‹f ix = x› (*‹f ix = x›*) g_def (*‹g ≡ λj. if j ≤ k - 1 then f j else if j = k then b else f (j - 1)›*) by auto
moreover have "finite ?X ⟶ ix < card ?X"
using Y_def (*‹(b::'a) ∉ (Y::'a set)›*) ‹ix < card Y› (*‹ix < card Y›*) by auto
ultimately show "?thesis"
(*goal: ‹∃n. (finite (insert b Y) ⟶ n < card (insert b Y)) ∧ g n = x›*)
by metis
next
(*goal: ‹(k::nat) ≤ (ix::nat) ⟹ ∃n::nat. (finite (insert (b::'a) (Y::'a set)) ⟶ n < card (insert b Y)) ∧ (g::nat ⇒ 'a) n = (x::'a)›*)
assume "ix≥k" (*‹(k::nat) ≤ (ix::nat)›*)
hence "g (ix+1) = x"
using ‹f ix = x› (*‹f ix = x›*) g_def (*‹g ≡ λj. if j ≤ k - 1 then f j else if j = k then b else f (j - 1)›*) by auto
moreover have "finite ?X ⟶ ix+1 < card ?X"
using Y_def (*‹b ∉ Y›*) ‹ix < card Y› (*‹ix < card Y›*) by auto
ultimately show "?thesis"
(*goal: ‹∃n. (finite (insert b Y) ⟶ n < card (insert b Y)) ∧ g n = x›*)
by metis
qed
qed
next
(*goal: ‹x ∉ Y ⟹ ∃n. (finite (insert b Y) ⟶ n < card (insert b Y)) ∧ g n = x›*)
assume "x∉Y" (*‹(x::'a) ∉ (Y::'a set)›*)
hence "x=b"
using Y_def (*‹b ∉ Y›*) ‹x ∈ ?X› (*‹x ∈ insert b Y›*) by blast
thus "?thesis"
(*goal: ‹∃n::nat. (finite (insert (b::'a::type) (Y::'a::type set)) ⟶ n < card (insert b Y)) ∧ (g::nat ⇒ 'a::type) n = (x::'a::type)›*)
using Y_def (*‹b ∉ Y›*) ‹k ≠ 0› (*‹k ≠ 0›*) k_def(2) (*‹(k::nat) < card (Y::'a::type set)›*) ordered_cancel_comm_monoid_diff_class.le_diff_conv2 (*‹?a ≤ ?b ⟹ (?c ≤ ?b - ?a) = (?c + ?a ≤ ?b)›*) g_def (*‹g ≡ λj. if j ≤ k - 1 then f j else if j = k then b else f (j - 1)›*) by auto
qed
qed
moreover have "∀n n' n''. (finite ?X ⟶ n'' < card ?X) ∧ Suc n = n' ∧ Suc n' = n''
⟶ [g n; g (Suc n); g (Suc (Suc n))]"
proof (clarify)
(*goal: ‹⋀(n::nat) (n'::nat) n''::nat. finite (insert (b::'a) (Y::'a set)) ⟶ Suc (Suc n) < card (insert b Y) ⟹ [(g::nat ⇒ 'a) n;g (Suc n);g (Suc (Suc n))]›*)
fix n and n' and n''
assume a: "(finite ?X ⟶ (Suc (Suc n)) < card ?X)" (*‹finite (insert (b::'a) (Y::'a set)) ⟶ Suc (Suc (n::nat)) < card (insert b Y)›*)
text ‹Introduce the two-case splits used later.›
have cases_sn: "Suc n≤k-1 ∨ Suc n=k" if "n≤k-1"
using ‹k ≠ 0› (*‹(k::nat) ≠ (0::nat)›*) that (*‹n ≤ k - 1›*) by linarith
have cases_ssn: "Suc(Suc n)≤k-1 ∨ Suc(Suc n)=k" if "n≤k-1" "Suc n≤k-1"
using that(2) (*‹Suc (n::nat) ≤ (k::nat) - (1::nat)›*) by linarith
consider "n≤k-1" | "n≥k+1" | "n=k"
(*goal: ‹⟦n ≤ k - 1 ⟹ thesis; k + 1 ≤ n ⟹ thesis; n = k ⟹ thesis⟧ ⟹ thesis›*)
by linarith
then show "[g n; g (Suc n); g (Suc (Suc n))]"
proof (cases)
(*goals:
1. ‹(n::nat) ≤ (k::nat) - (1::nat) ⟹ [(g::nat ⇒ 'a) n;g (Suc n);g (Suc (Suc n))]›
2. ‹(k::nat) + (1::nat) ≤ (n::nat) ⟹ [(g::nat ⇒ 'a) n;g (Suc n);g (Suc (Suc n))]›
3. ‹(n::nat) = (k::nat) ⟹ [(g::nat ⇒ 'a) n;g (Suc n);g (Suc (Suc n))]›*)
assume "n≤k-1" (*‹(n::nat) ≤ (k::nat) - (1::nat)›*)
show "?thesis"
(*goal: ‹[g n;g (Suc n);g (Suc (Suc n))]›*)
using cases_sn (*‹n ≤ k - 1 ⟹ Suc n ≤ k - 1 ∨ Suc n = k›*) proof (rule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹n ≤ k - 1›
2. ‹Suc n ≤ k - 1 ⟹ [g n;g (Suc n);g (Suc (Suc n))]›
3. ‹Suc n = k ⟹ [g n;g (Suc n);g (Suc (Suc n))]›*)
assume "Suc n ≤ k - 1" (*‹Suc (n::nat) ≤ (k::nat) - (1::nat)›*)
show "?thesis"
(*goal: ‹[g n;g (Suc n);g (Suc (Suc n))]›*)
using cases_ssn (*‹⟦n ≤ k - 1; Suc n ≤ k - 1⟧ ⟹ Suc (Suc n) ≤ k - 1 ∨ Suc (Suc n) = k›*) proof (rule disjE (*‹⟦(?P::bool) ∨ (?Q::bool); ?P ⟹ ?R::bool; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹(n::nat) ≤ (k::nat) - (1::nat)›
2. ‹Suc (n::nat) ≤ (k::nat) - (1::nat)›
3. ‹Suc (Suc (n::nat)) ≤ (k::nat) - (1::nat) ⟹ [(g::nat ⇒ 'a) n;g (Suc n);g (Suc (Suc n))]›
4. ‹Suc (Suc (n::nat)) = (k::nat) ⟹ [(g::nat ⇒ 'a) n;g (Suc n);g (Suc (Suc n))]›*)
show "n ≤ k - 1"
using ‹n ≤ k - 1› (*‹n ≤ k - 1›*) by blast
show "Suc n ≤ k - 1"
using ‹Suc n ≤ k - 1› (*‹Suc (n::nat) ≤ (k::nat) - (1::nat)›*) by blast
next
(*goals:
1. ‹Suc (Suc n) ≤ k - 1 ⟹ [g n;g (Suc n);g (Suc (Suc n))]›
2. ‹Suc (Suc n) = k ⟹ [g n;g (Suc n);g (Suc (Suc n))]›*)
assume "Suc (Suc n) ≤ k - 1" (*‹Suc (Suc (n::nat)) ≤ (k::nat) - (1::nat)›*)
thus "?thesis"
(*goal: ‹[g n;g (Suc n);g (Suc (Suc n))]›*)
using ‹Suc n ≤ k - 1› (*‹Suc n ≤ k - 1›*) ‹k ≠ 0› (*‹k ≠ 0›*) ‹n ≤ k - 1› (*‹n ≤ k - 1›*) ordering_ord_ijk_loc (*‹⟦local_ordering ?f ?ord ?X; finite ?X ⟶ Suc (Suc ?i) < card ?X⟧ ⟹ ?ord (?f ?i) (?f (Suc ?i)) (?f (Suc (Suc ?i)))›*) f_def (*‹local_long_ch_by_ord f Y›*) g_def (*‹g ≡ λj. if j ≤ k - 1 then f j else if j = k then b else f (j - 1)›*) k_def(2) (*‹k < card Y›*) by (metis (no_types, lifting) add_diff_inverse_nat (*‹¬ ?m < ?n ⟹ ?n + (?m - ?n) = ?m›*) less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*) less_imp_le_nat (*‹?m < ?n ⟹ ?m ≤ ?n›*) less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*) less_one (*‹(?n < 1) = (?n = 0)›*) local_long_ch_by_ord_def (*‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X›*) plus_1_eq_Suc (*‹(+) 1 = Suc›*))
next
(*goal: ‹Suc (Suc n) = k ⟹ [g n;g (Suc n);g (Suc (Suc n))]›*)
assume "Suc (Suc n) = k" (*‹Suc (Suc (n::nat)) = (k::nat)›*)
thus "?thesis"
(*goal: ‹[g n;g (Suc n);g (Suc (Suc n))]›*)
using b_right (*‹2 ≤ k ⟹ [f (k - 2);f (k - 1);b]›*) g_def (*‹g::nat ⇒ 'a ≡ λj::nat. if j ≤ (k::nat) - (1::nat) then (f::nat ⇒ 'a) j else if j = k then b::'a else f (j - (1::nat))›*) by force
qed
next
(*goals:
1. ‹n ≤ k - 1›
2. ‹Suc n = k ⟹ [g n;g (Suc n);g (Suc (Suc n))]›*)
assume "Suc n = k" (*‹Suc (n::nat) = (k::nat)›*)
show "?thesis"
(*goal: ‹[g n;g (Suc n);g (Suc (Suc n))]›*)
using b_middle (*‹[(f::nat ⇒ 'a) ((k::nat) - (1::nat));b::'a;f k]›*) ‹Suc n = k› (*‹Suc (n::nat) = (k::nat)›*) ‹n ≤ k - 1› (*‹n ≤ k - 1›*) g_def (*‹g ≡ λj. if j ≤ k - 1 then f j else if j = k then b else f (j - 1)›*) by auto
next
(*goal: ‹n ≤ k - 1›*)
show "n ≤ k-1"
using ‹n ≤ k - 1› (*‹n ≤ k - 1›*) by blast
qed
next
(*goals:
1. ‹(k::nat) + (1::nat) ≤ (n::nat) ⟹ [(g::nat ⇒ 'a) n;g (Suc n);g (Suc (Suc n))]›
2. ‹(n::nat) = (k::nat) ⟹ [(g::nat ⇒ 'a) n;g (Suc n);g (Suc (Suc n))]›*)
assume "n≥k+1" (*‹(k::nat) + (1::nat) ≤ (n::nat)›*)
show "?thesis"
(*goal: ‹[g n;g (Suc n);g (Suc (Suc n))]›*)
proof (-)
(*goal: ‹[g n;g (Suc n);g (Suc (Suc n))]›*)
have "g n = f (n-1)"
using ‹k + 1 ≤ n› (*‹k + 1 ≤ n›*) less_imp_diff_less (*‹?j < ?k ⟹ ?j - ?n < ?k›*) g_def (*‹g ≡ λj. if j ≤ k - 1 then f j else if j = k then b else f (j - 1)›*) by auto
moreover have "g (Suc n) = f (n)"
using ‹k + 1 ≤ n› (*‹k + 1 ≤ n›*) g_def (*‹g::nat ⇒ 'a ≡ λj::nat. if j ≤ (k::nat) - (1::nat) then (f::nat ⇒ 'a) j else if j = k then b::'a else f (j - (1::nat))›*) by auto
moreover have "g (Suc (Suc n)) = f (Suc n)"
using ‹k + 1 ≤ n› (*‹k + 1 ≤ n›*) g_def (*‹g ≡ λj. if j ≤ k - 1 then f j else if j = k then b else f (j - 1)›*) by auto
moreover have "n-1<n ∧ n<Suc n"
using ‹k + 1 ≤ n› (*‹k + 1 ≤ n›*) by auto
moreover have "finite Y ⟶ Suc n < card Y"
using Y_def (*‹b ∉ Y›*) a (*‹finite (insert b Y) ⟶ Suc (Suc n) < card (insert b Y)›*) by auto
ultimately show "?thesis"
(*goal: ‹[g n;g (Suc n);g (Suc (Suc n))]›*)
using f_def (*‹local_long_ch_by_ord f Y›*) unfolding chain_defs local_ordering_def
(*goal: ‹[g n;g (Suc n);g (Suc (Suc n))]›*)
by (metis ‹k + 1 ≤ n› add_leD2 (*‹?m + ?k ≤ ?n ⟹ ?k ≤ ?n›*) le_add_diff_inverse (*‹?b ≤ ?a ⟹ ?b + (?a - ?b) = ?a›*) plus_1_eq_Suc (*‹(+) 1 = Suc›*))
qed
next
(*goal: ‹(n::nat) = (k::nat) ⟹ [(g::nat ⇒ 'a) n;g (Suc n);g (Suc (Suc n))]›*)
assume "n=k" (*‹(n::nat) = (k::nat)›*)
show "?thesis"
(*goal: ‹[g n;g (Suc n);g (Suc (Suc n))]›*)
using ‹k ≠ 0› (*‹k ≠ 0›*) ‹n = k› (*‹n = k›*) b_left (*‹k + 1 ≤ card Y - 1 ⟹ [b;f k;f (k + 1)]›*) g_def (*‹g::nat ⇒ 'a ≡ λj::nat. if j ≤ (k::nat) - (1::nat) then (f::nat ⇒ 'a) j else if j = k then b::'a else f (j - (1::nat))›*) Y_def(1) (*‹b ∉ Y›*) a (*‹finite (insert b Y) ⟶ Suc (Suc n) < card (insert b Y)›*) assms(3) (*‹[a₁;b;a⇩n]›*) fin_Y (*‹finite Y›*) by auto
qed
qed
ultimately show "local_ordering g betw ?X"
unfolding local_ordering_def
(*goal: ‹(∀n. (finite (insert b Y) ⟶ n < card (insert b Y)) ⟶ g n ∈ insert b Y) ∧ (∀x∈insert b Y. ∃n. (finite (insert b Y) ⟶ n < card (insert b Y)) ∧ g n = x) ∧ (∀n. (finite (insert b Y) ⟶ Suc (Suc n) < card (insert b Y)) ⟶ [g n;g (Suc n);g (Suc (Suc n))])›*)
by presburger
qed
hence "local_long_ch_by_ord g ?X"
using Y_def (*‹b ∉ Y›*) f_def (*‹local_long_ch_by_ord f Y›*) local_long_ch_by_ord_def (*‹local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X›*) local_long_ch_by_ord_def (*‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X›*) by auto
thus "[g↝?X|a₁..b..a⇩n]"
using fin_X (*‹finite (insert b Y)›*) ‹a₁ ≠ a⇩n ∧ a₁ ≠ b ∧ b ≠ a⇩n› (*‹a₁ ≠ a⇩n ∧ a₁ ≠ b ∧ b ≠ a⇩n›*) bound_indices (*‹f 0 = a₁ ∧ f (card Y - 1) = a⇩n›*) k_def(2) (*‹k < card Y›*) Y_def (*‹b ∉ Y›*) g_def (*‹g ≡ λj. if j ≤ k - 1 then f j else if j = k then b else f (j - 1)›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type .. ?y::'a::type] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by simp
qed
lemma card4_eq:
assumes "card X = 4"
shows "∃a b c d. a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d ∧ X = {a, b, c, d}"
proof (-)
(*goal: ‹∃a b c d. a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d ∧ X = {a, b, c, d}›*)
obtain a and X' where "X = insert a X'" and "a ∉ X'"
(*goal: ‹(⋀a X'. ⟦X = insert a X'; a ∉ X'⟧ ⟹ thesis) ⟹ thesis›*)
by (metis Suc_eq_numeral (*‹(Suc ?n = numeral ?k) = (?n = pred_numeral ?k)›*) assms (*‹card X = 4›*) card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*))
then have "card X' = 3"
by (metis add_2_eq_Suc' (*‹?n + 2 = Suc (Suc ?n)›*) assms (*‹card X = 4›*) card_eq_0_iff (*‹(card ?A = 0) = (?A = {} ∨ infinite ?A)›*) card_insert_if (*‹finite ?A ⟹ card (insert ?x ?A) = (if ?x ∈ ?A then card ?A else Suc (card ?A))›*) diff_Suc_1 (*‹Suc ?n - 1 = ?n›*) finite_insert (*‹finite (insert ?a ?A) = finite ?A›*) numeral_3_eq_3 (*‹3 = Suc (Suc (Suc 0))›*) numeral_Bit0 (*‹numeral (num.Bit0 ?n) = numeral ?n + numeral ?n›*) plus_nat.add_0 (*‹0 + ?n = ?n›*) zero_neq_numeral (*‹0 ≠ numeral ?n›*))
then obtain b and X'' where "X' = insert b X''" and "b ∉ X''"
(*goal: ‹(⋀b X''. ⟦X' = insert b X''; b ∉ X''⟧ ⟹ thesis) ⟹ thesis›*)
by (metis card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*) numeral_3_eq_3 (*‹3 = Suc (Suc (Suc 0))›*))
then have "card X'' = 2"
by (metis Suc_eq_numeral (*‹(Suc ?n = numeral ?k) = (?n = pred_numeral ?k)›*) ‹card X' = 3› card.infinite (*‹infinite ?A ⟹ card ?A = 0›*) card_insert_if (*‹finite ?A ⟹ card (insert ?x ?A) = (if ?x ∈ ?A then card ?A else Suc (card ?A))›*) finite_insert (*‹finite (insert ?a ?A) = finite ?A›*) pred_numeral_simps( (*‹pred_numeral (num.Bit1 ?k) = numeral (num.Bit0 ?k)›*) 3) zero_neq_numeral (*‹0 ≠ numeral ?n›*))
then have "∃c d. c ≠ d ∧ X'' = {c, d}"
by (meson card_2_iff (*‹(card ?S = 2) = (∃x y. ?S = {x, y} ∧ x ≠ y)›*))
thus "?thesis"
(*goal: ‹∃a b c d. a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d ∧ X = {a, b, c, d}›*)
using ‹X = insert a X'› (*‹X = insert a X'›*) ‹X' = insert b X''› (*‹X' = insert b X''›*) ‹a ∉ X'› (*‹a ∉ X'›*) ‹b ∉ X''› (*‹b ∉ X''›*) by blast
qed
theorem (*10*) path_finsubset_chain:
assumes "Q ∈ 𝒫"
and "X ⊆ Q"
and "card X ≥ 2"
shows "ch X"
proof (-)
(*goal: ‹ch X›*)
have "finite X"
using assms(3) (*‹2 ≤ card X›*) not_numeral_le_zero (*‹¬ numeral (?n::num) ≤ (0::?'a)›*) by fastforce
consider "card X = 2" | "card X = 3" | "card X ≥ 4"
(*goal: ‹⟦card X = 2 ⟹ thesis; card X = 3 ⟹ thesis; 4 ≤ card X ⟹ thesis⟧ ⟹ thesis›*)
using ‹card X ≥ 2› (*‹2 ≤ card X›*) by linarith
thus "?thesis"
(*goal: ‹ch X›*)
proof (cases)
(*goals:
1. ‹card X = 2 ⟹ ch X›
2. ‹card X = 3 ⟹ ch X›
3. ‹4 ≤ card X ⟹ ch X›*)
assume "card X = 2" (*‹card (X::'a set) = (2::nat)›*)
thus "?thesis"
(*goal: ‹ch X›*)
using ‹finite X› (*‹finite X›*) assms (*‹Q ∈ 𝒫› ‹X ⊆ Q› ‹2 ≤ card X›*) two_event_chain (*‹⟦finite ?X; ?Q ∈ 𝒫; ?X ⊆ ?Q; card ?X = 2⟧ ⟹ ch ?X›*) by blast
next
(*goals:
1. ‹card X = 3 ⟹ ch X›
2. ‹4 ≤ card X ⟹ ch X›*)
assume "card X = 3" (*‹card (X::'a set) = (3::nat)›*)
thus "?thesis"
(*goal: ‹ch X›*)
using ‹finite X› (*‹finite X›*) assms (*‹Q ∈ 𝒫› ‹(X::'a set) ⊆ (Q::'a set)› ‹2 ≤ card X›*) three_event_chain (*‹⟦finite ?X; ?Q ∈ 𝒫; ?X ⊆ ?Q; card ?X = 3⟧ ⟹ ch ?X›*) by blast
next
(*goal: ‹4 ≤ card X ⟹ ch X›*)
assume "card X ≥ 4" (*‹(4::nat) ≤ card (X::'a set)›*)
thus "?thesis"
(*goal: ‹ch (X::'a::type set)›*)
using assms(1,2) (*‹Q ∈ 𝒫› ‹(X::'a::type set) ⊆ (Q::'a::type set)›*) ‹finite X› (*‹finite (X::'a set)›*) proof (induct "card X - 4" arbitrary: X)
(*goals:
1. ‹⋀X. ⟦0 = card X - 4; 4 ≤ card X; Q ∈ 𝒫; X ⊆ Q; finite X⟧ ⟹ ch X›
2. ‹⋀x X. ⟦⋀X. ⟦x = card X - 4; 4 ≤ card X; Q ∈ 𝒫; X ⊆ Q; finite X⟧ ⟹ ch X; Suc x = card X - 4; 4 ≤ card X; Q ∈ 𝒫; X ⊆ Q; finite X⟧ ⟹ ch X›*)
case 0 (*‹0 = card X - 4› ‹4 ≤ card X› ‹(Q::'a set) ∈ (𝒫::'a set set)› ‹X ⊆ Q› ‹finite X›*)
then have "card X = 4"
by auto
then have "∃a b c d. a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d ∧ X = {a, b, c, d}"
using card4_eq (*‹card ?X = 4 ⟹ ∃a b c d. a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d ∧ ?X = {a, b, c, d}›*) by fastforce
thus "?case"
(*goal: ‹ch X›*)
using "0.prems"(3) (*‹X ⊆ Q›*) assms(1) (*‹Q ∈ 𝒫›*) chain4 (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q; (?b::'a) ∈ ?Q; (?c::'a) ∈ ?Q; (?d::'a) ∈ ?Q; ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?a ≠ ?d ∧ ?b ≠ ?c ∧ ?b ≠ ?d ∧ ?c ≠ ?d⟧ ⟹ ch {?a, ?b, ?c, ?d}›*) by auto
next
(*goal: ‹⋀x X. ⟦⋀X. ⟦x = card X - 4; 4 ≤ card X; Q ∈ 𝒫; X ⊆ Q; finite X⟧ ⟹ ch X; Suc x = card X - 4; 4 ≤ card X; Q ∈ 𝒫; X ⊆ Q; finite X⟧ ⟹ ch X›*)
case IH: (Suc n) (*‹⟦n = card ?X - 4; 4 ≤ card ?X; Q ∈ 𝒫; ?X ⊆ Q; finite ?X⟧ ⟹ ch ?X› ‹Suc n = card X - 4› ‹(4::nat) ≤ card (X::'a::type set)› ‹Q ∈ 𝒫› ‹X ⊆ Q› ‹finite (X::'a set)›*)
then obtain Y and b where X_eq: "X = insert b Y" and "b ∉ Y"
(*goal: ‹(⋀b Y. ⟦X = insert b Y; b ∉ Y⟧ ⟹ thesis) ⟹ thesis›*)
by (metis Diff_iff (*‹(?c ∈ ?A - ?B) = (?c ∈ ?A ∧ ?c ∉ ?B)›*) card_eq_0_iff (*‹(card ?A = 0) = (?A = {} ∨ infinite ?A)›*) finite.cases (*‹⟦finite ?a; ?a = {} ⟹ ?P; ⋀A a. ⟦?a = insert a A; finite A⟧ ⟹ ?P⟧ ⟹ ?P›*) insertI1 (*‹?a ∈ insert ?a ?B›*) insert_Diff_single (*‹insert ?a (?A - {?a}) = insert ?a ?A›*) not_numeral_le_zero (*‹¬ numeral ?n ≤ 0›*))
have "card Y ≥ 4" "n = card Y - 4"
using IH.hyps(2) (*‹Suc n = card X - 4›*) IH.prems(4) (*‹finite X›*) X_eq (*‹X = insert b Y›*) ‹b ∉ Y› (*‹b ∉ Y›*) apply -
(*goals:
1. ‹⟦Suc n = card X - 4; finite X; X = insert b Y; b ∉ Y⟧ ⟹ 4 ≤ card Y›
2. ‹⟦Suc n = card X - 4; finite X; X = insert b Y; b ∉ Y⟧ ⟹ n = card Y - 4›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
then have "ch Y"
using IH(1)[of Y] (*‹⟦(n::nat) = card (Y::'a set) - (4::nat); (4::nat) ≤ card Y; (Q::'a set) ∈ (𝒫::'a set set); Y ⊆ Q; finite Y⟧ ⟹ ch Y›*) IH.prems(3,4) (*‹X ⊆ Q› ‹finite X›*) X_eq (*‹X = insert b Y›*) assms(1) (*‹Q ∈ 𝒫›*) by auto
then obtain f where f_ords: "local_long_ch_by_ord f Y"
(*goal: ‹(⋀f. local_long_ch_by_ord f Y ⟹ thesis) ⟹ thesis›*)
using ‹4 ≤ card Y› (*‹(4::nat) ≤ card (Y::'a set)›*) ch_alt (*‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)›*) short_ch_card(2) (*‹short_ch ?Q ⟹ card ?Q = 2›*) by auto
then obtain a₁ and a and a⇩n where long_ch_Y: "[f↝Y|a₁..a..a⇩n]"
(*goal: ‹(⋀a₁ a a⇩n. [f↝Y|a₁..a..a⇩n] ⟹ thesis) ⟹ thesis›*)
using ‹4 ≤ card Y› (*‹4 ≤ card Y›*) get_fin_long_ch_bounds (*‹⟦local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set); finite ?X⟧ ⟹ ∃x::'a∈?X. ∃y::'a∈?X. ∃z::'a∈?X. [?f↝?X|x..y..z]›*) by fastforce
hence bound_indices: "f 0 = a₁ ∧ f (card Y - 1) = a⇩n"
by (simp add: chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*))
have "a₁ ≠ a⇩n ∧ a₁ ≠ b ∧ b ≠ a⇩n"
using ‹b ∉ Y› (*‹b ∉ Y›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) fin_ch_betw (*‹[?f::nat ⇒ 'a::type↝?X::'a::type set|?a::'a::type..?b::'a::type..?c::'a::type] ⟹ [?a;?b;?c]›*) long_ch_Y (*‹[f::nat ⇒ 'a::type↝Y::'a::type set|a₁::'a::type..a::'a::type..a⇩n::'a::type]›*) points_in_long_chain (*‹[?f↝?Q|?x..?y..?z] ⟹ ?x ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?y ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?z ∈ ?Q›*) by metis
moreover have "a₁ ∈ Q ∧ a⇩n ∈ Q ∧ b ∈ Q"
using IH.prems(3) (*‹(X::'a set) ⊆ (Q::'a set)›*) X_eq (*‹X = insert b Y›*) long_ch_Y (*‹[f::nat ⇒ 'a::type↝Y::'a::type set|a₁::'a::type..a::'a::type..a⇩n::'a::type]›*) points_in_long_chain (*‹[?f↝?Q|?x..?y..?z] ⟹ ?x ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?y ∈ ?Q› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ⟹ ?z ∈ ?Q›*) by auto
ultimately consider "[b; a₁; a⇩n]" | "[a₁; a⇩n; b]" | "[a⇩n; b; a₁]"
(*goal: ‹⟦[b;a₁;a⇩n] ⟹ thesis; [a₁;a⇩n;b] ⟹ thesis; [a⇩n;b;a₁] ⟹ thesis⟧ ⟹ thesis›*)
using some_betw[of Q b a₁ a⇩n] (*‹⟦Q ∈ 𝒫; b ∈ Q; a₁ ∈ Q; a⇩n ∈ Q; b ≠ a₁; b ≠ a⇩n; a₁ ≠ a⇩n⟧ ⟹ [b;a₁;a⇩n] ∨ [a₁;a⇩n;b] ∨ [a⇩n;b;a₁]›*) ‹Q ∈ 𝒫› (*‹Q ∈ 𝒫›*) by blast
thus "ch X"
proof (cases)
(*goals:
1. ‹[b;a₁;a⇩n] ⟹ ch X›
2. ‹[a₁;a⇩n;b] ⟹ ch X›
3. ‹[a⇩n;b;a₁] ⟹ ch X›*)
assume "[b; a₁; a⇩n]" (*‹[b::'a;a₁::'a;a⇩n::'a]›*)
have X_eq': "X = Y ∪ {b}"
using X_eq (*‹X = insert b Y›*) by auto
let ?g = "λj. if j ≥ 1 then f (j - 1) else b"
have "[?g↝X|b..a₁..a⇩n]"
using chain_append_at_left_edge (*‹⟦[?f::nat ⇒ 'a↝?Y::'a set|?a₁::'a..?a::'a..?a⇩n::'a]; [?b::'a;?a₁;?a⇩n]⟧ ⟹ [λj::nat. if (1::nat) ≤ j then ?f (j - (1::nat)) else ?b↝insert ?b ?Y|?b..?a₁..?a⇩n]›*) IH.prems(4) (*‹finite X›*) X_eq' (*‹X = Y ∪ {b}›*) ‹[b; a₁; a⇩n]› (*‹[b;a₁;a⇩n]›*) ‹b ∉ Y› (*‹b ∉ Y›*) long_ch_Y (*‹[f::nat ⇒ 'a::type↝Y::'a::type set|a₁::'a::type..a::'a::type..a⇩n::'a::type]›*) X_eq (*‹X = insert b Y›*) by presburger
thus "ch X"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by auto
next
(*goals:
1. ‹[a₁;a⇩n;b] ⟹ ch X›
2. ‹[a⇩n;b;a₁] ⟹ ch X›*)
assume "[a₁; a⇩n; b]" (*‹[a₁::'a;a⇩n::'a;b::'a]›*)
let ?g = "λj. if j ≤ (card X - 2) then f j else b"
have "[?g↝X|a₁..a⇩n..b]"
using chain_append_at_right_edge (*‹⟦[?f↝?Y|?a₁..?a..?a⇩n]; [?a₁;?a⇩n;?b]⟧ ⟹ [λj. if j ≤ card ?Y - 1 then ?f j else ?b↝insert ?b ?Y|?a₁..?a⇩n..?b]›*) IH.prems(4) (*‹finite (X::'a set)›*) X_eq (*‹X = insert b Y›*) ‹[a₁; a⇩n; b]› (*‹[a₁;a⇩n;b]›*) ‹b ∉ Y› (*‹b ∉ Y›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) by auto
thus "ch X"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (meson ch_def (*‹ch (?X::'a::type set) ≡ ∃f::nat ⇒ 'a::type. [f↝?X]›*))
next
(*goal: ‹[a⇩n;b;a₁] ⟹ ch X›*)
assume "[a⇩n; b; a₁]" (*‹[a⇩n::'a;b::'a;a₁::'a]›*)
then have "[a₁; b; a⇩n]"
by (simp add: abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*))
obtain k where k_def: "[a₁; b; f k]" "k < card Y" "¬ (∃k'. 0 < k' ∧ k' < k ∧ [a₁; b; f k'])"
(*goal: ‹(⋀k. ⟦[a₁;b;f k]; k < card Y; ¬ (∃k'>0. k' < k ∧ [a₁;b;f k'])⟧ ⟹ thesis) ⟹ thesis›*)
using ‹[a₁; b; a⇩n]› (*‹[a₁;b;a⇩n]›*) ‹b ∉ Y› (*‹b ∉ Y›*) long_ch_Y (*‹[f↝Y|a₁..a..a⇩n]›*) smallest_k_ex (*‹⟦[?f↝?Y|?a₁..?a..?a⇩n]; ?b ∉ ?Y; [?a₁;?b;?a⇩n]⟧ ⟹ ∃k>0. [?a₁;?b;?f k] ∧ k < card ?Y ∧ ¬ (∃k'<k. [?a₁;?b;?f k'])›*) by blast
obtain g where "g = (λj::nat. if j ≤ k - 1
then f j
else if j = k
then b else f (j - 1))"
(*goal: ‹(⋀g. g = (λj. if j ≤ k - 1 then f j else if j = k then b else f (j - 1)) ⟹ thesis) ⟹ thesis›*)
by simp
hence "[g↝X|a₁..b..a⇩n]"
using chain_append_inside[of f Y a₁ a a⇩n b k] (*‹⟦[f::nat ⇒ 'a↝Y::'a set|a₁::'a..a::'a..a⇩n::'a]; (b::'a) ∉ Y; [a₁;b;a⇩n]; [a₁;b;f (k::nat)]; k < card Y; ¬ (∃k'>0::nat. k' < k ∧ [a₁;b;f k'])⟧ ⟹ [λj::nat. if j ≤ k - (1::nat) then f j else if j = k then b else f (j - (1::nat))↝insert b Y|a₁..b..a⇩n]›*) IH.prems(4) (*‹finite X›*) X_eq (*‹X = insert b Y›*) ‹[a₁; b; a⇩n]› (*‹[a₁;b;a⇩n]›*) ‹b ∉ Y› (*‹b ∉ Y›*) k_def (*‹[a₁;b;f k]› ‹(k::nat) < card (Y::'a set)› ‹¬ (∃k'>0. k' < k ∧ [a₁;b;f k'])›*) long_ch_Y (*‹[f::nat ⇒ 'a↝Y::'a set|a₁::'a..a::'a..a⇩n::'a]›*) by auto
thus "ch X"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type..?y::'a::type..?z::'a::type] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) ch_def (*‹ch ?X ≡ ∃f. [f↝?X]›*) by auto
qed
qed
qed
qed
lemma path_finsubset_chain2:
assumes "Q ∈ 𝒫" and "X ⊆ Q" and "card X ≥ 2"
obtains f a b where "[f↝X|a..b]"
proof (-)
(*goal: ‹(⋀f a b. [f↝X|a .. b] ⟹ thesis) ⟹ thesis›*)
have finX: "finite X"
by (metis assms( (*‹2 ≤ card X›*) 3) card.infinite (*‹infinite ?A ⟹ card ?A = 0›*) rel_simps( (*‹¬ numeral ?n ≤ 0›*) 28))
have ch_X: "ch X"
using path_finsubset_chain[OF assms] (*‹ch X›*) by blast
obtain f and a and b where f_def: "[f↝X|a..b]" "a∈X ∧ b∈X"
(*goal: ‹(⋀f a b. ⟦[f↝X|a .. b]; a ∈ X ∧ b ∈ X⟧ ⟹ thesis) ⟹ thesis›*)
using assms (*‹(Q::'a::type set) ∈ (𝒫::'a::type set set)› ‹X ⊆ Q› ‹2 ≤ card X›*) finX (*‹finite X›*) ch_X (*‹ch X›*) get_fin_long_ch_bounds (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X⟧ ⟹ ∃x∈?X. ∃y∈?X. ∃z∈?X. [?f↝?X|x..y..z]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type..?y::'a::type..?z::'a::type] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis ch_def (*‹ch ?X ≡ ∃f. [f↝?X]›*) points_in_chain (*‹[?f↝?Q|?x .. ?z] ⟹ ?x ∈ ?Q ∧ ?z ∈ ?Q›*))
thus "?thesis"
(*goal: ‹thesis›*)
using that (*‹[?f↝X|?a .. ?b] ⟹ thesis›*) by auto
qed
subsection ‹Theorem 11›
text ‹
Notice this case is so simple, it doesn't even require the path density larger sets of segments
rely on for fixing their cardinality.
›
lemma (*for 11*) segmentation_ex_N2:
assumes path_P: "P∈𝒫"
and Q_def: "finite (Q::'a set)" "card Q = N" "Q⊆P" "N=2"
and f_def: "[f↝Q|a..b]"
and S_def: "S = {segment a b}"
and P1_def: "P1 = prolongation b a"
and P2_def: "P2 = prolongation a b"
shows "P = ((⋃S) ∪ P1 ∪ P2 ∪ Q) ∧
card S = (N-1) ∧ (∀x∈S. is_segment x) ∧
P1∩P2={} ∧ (∀x∈S. (x∩P1={} ∧ x∩P2={} ∧ (∀y∈S. x≠y ⟶ x∩y={})))"
proof (-)
(*goal: ‹P = ⋃ S ∪ P1 ∪ P2 ∪ Q ∧ card S = N - 1 ∧ (∀x∈S. is_segment x) ∧ P1 ∩ P2 = {} ∧ (∀x∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y∈S. x ≠ y ⟶ x ∩ y = {}))›*)
have "a∈Q ∧ b∈Q ∧ a≠b"
using chain_defs (*‹short_ch (?X::'a set) ≡ card ?X = (2::nat) ∧ (∃P::'a set∈𝒫::'a set set. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) f_def (*‹[f↝Q|a .. b]›*) points_in_chain (*‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a .. ?z::'a] ⟹ ?x ∈ ?Q ∧ ?z ∈ ?Q›*) first_neq_last (*‹[?f↝?Q|?x .. ?z] ⟹ ?x ≠ ?z›*) by metis
hence "Q={a,b}"
using assms(3,5) (*‹card Q = N› ‹(N::nat) = (2::nat)›*) by (smt card_2_iff (*‹(card ?S = 2) = (∃x y. ?S = {x, y} ∧ x ≠ y)›*) insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*) insert_commute (*‹insert ?x (insert ?y ?A) = insert ?y (insert ?x ?A)›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) singleton_insert_inj_eq (*‹({?b} = insert ?a ?A) = (?a = ?b ∧ ?A ⊆ {?b})›*))
have "a∈P ∧ b∈P"
using ‹Q={a,b}› (*‹(Q::'a set) = {a::'a, b::'a}›*) assms(4) (*‹Q ⊆ P›*) by auto
have "a≠b"
using ‹Q={a,b}› (*‹Q = {a, b}›*) using ‹N = 2› (*‹N = 2›*) assms(3) (*‹card Q = N›*) by force
obtain s where s_def: "s = segment a b"
(*goal: ‹(⋀s. s = segment a b ⟹ thesis) ⟹ thesis›*)
by simp
let ?S = "{s}"
have "P = ((⋃{s}) ∪ P1 ∪ P2 ∪ Q) ∧
card {s} = (N-1) ∧ (∀x∈{s}. is_segment x) ∧
P1∩P2={} ∧ (∀x∈{s}. (x∩P1={} ∧ x∩P2={} ∧ (∀y∈{s}. x≠y ⟶ x∩y={})))"
proof (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹P = ⋃ {s} ∪ P1 ∪ P2 ∪ Q›
2. ‹card {s} = N - 1 ∧ (∀x∈{s}. is_segment x) ∧ P1 ∩ P2 = {} ∧ (∀x∈{s}. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y∈{s}. x ≠ y ⟶ x ∩ y = {}))›*)
{
fix x
assume "x∈P" (*‹(x::'a) ∈ (P::'a set)›*)
have "[a;x;b] ∨ [b;a;x] ∨ [a;b;x] ∨ x=a ∨ x=b"
using ‹a∈P ∧ b∈P› (*‹a ∈ P ∧ b ∈ P›*) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) path_P (*‹P ∈ 𝒫›*) ‹a≠b› (*‹a ≠ b›*) by (meson ‹x ∈ P› abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*))
then have "x∈s ∨ x∈P1 ∨ x∈P2 ∨ x=a ∨ x=b"
using pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*) seg_betw (*‹((?x::'a::type) ∈ segment (?a::'a::type) (?b::'a::type)) = [?a;?x;?b]›*) P1_def (*‹P1 = prolongation b a›*) P2_def (*‹P2 = prolongation a b›*) s_def (*‹s = segment a b›*) ‹Q = {a, b}› (*‹Q = {a, b}›*) by auto
hence "x ∈ (⋃{s}) ∪ P1 ∪ P2 ∪ Q"
using ‹Q = {a, b}› (*‹Q = {a, b}›*) by auto
}
moreover {
fix x
assume "x ∈ (⋃{s}) ∪ P1 ∪ P2 ∪ Q" (*‹(x::'a) ∈ ⋃ {s::'a set} ∪ (P1::'a set) ∪ (P2::'a set) ∪ (Q::'a set)›*)
hence "x∈s ∨ x∈P1 ∨ x∈P2 ∨ x=a ∨ x=b"
using ‹Q = {a, b}› (*‹Q = {a, b}›*) by blast
hence "[a;x;b] ∨ [b;a;x] ∨ [a;b;x] ∨ x=a ∨ x=b"
using s_def (*‹s = segment a b›*) P1_def (*‹P1 = prolongation b a›*) P2_def (*‹P2 = prolongation a b›*) unfolding segment_def prolongation_def
(*goal: ‹[a;x;b] ∨ [b;a;x] ∨ [a;b;x] ∨ x = a ∨ x = b›*)
by auto
hence "x∈P"
using ‹a ∈ P ∧ b ∈ P› (*‹a ∈ P ∧ b ∈ P›*) ‹a ≠ b› (*‹(a::'a) ≠ (b::'a)›*) betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) path_P (*‹(P::'a set) ∈ (𝒫::'a set set)›*) by blast
}
ultimately show union_P: "P = ((⋃{s}) ∪ P1 ∪ P2 ∪ Q)"
by blast
show "card {s} = (N-1) ∧ (∀x∈{s}. is_segment x) ∧ P1∩P2={} ∧
(∀x∈{s}. (x∩P1={} ∧ x∩P2={} ∧ (∀y∈{s}. x≠y ⟶ x∩y={})))"
proof (safe)
(*goals:
1. ‹card {s} = N - 1›
2. ‹⋀x. is_segment s›
3. ‹⋀x. ⟦x ∈ P1; x ∈ P2⟧ ⟹ x ∈ {}›
4. ‹⋀x xa. ⟦xa ∈ s; xa ∈ P1⟧ ⟹ xa ∈ {}›
5. ‹⋀x xa. ⟦xa ∈ s; xa ∈ P2⟧ ⟹ xa ∈ {}›*)
show "card {s} = N - 1"
using ‹Q = {a, b}› (*‹Q = {a, b}›*) ‹a ≠ b› (*‹a ≠ b›*) assms(3) (*‹card Q = N›*) by auto
show "is_segment s"
using s_def (*‹s = segment a b›*) by blast
show "⋀x. x ∈ P1 ⟹ x ∈ P2 ⟹ x ∈ {}"
proof (-)
(*goal: ‹⋀x. ⟦x ∈ P1; x ∈ P2⟧ ⟹ x ∈ {}›*)
fix x
assume "x∈P1" "x∈P2" (*‹(x::'a) ∈ (P1::'a set)› ‹(x::'a) ∈ (P2::'a set)›*)
show "x∈{}"
using P1_def (*‹P1 = prolongation b a›*) P2_def (*‹P2 = prolongation a b›*) ‹x ∈ P1› (*‹x ∈ P1›*) ‹x ∈ P2› (*‹(x::'a) ∈ (P2::'a set)›*) abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*) by metis
qed
show "⋀x xa. xa ∈ s ⟹ xa ∈ P1 ⟹ xa ∈ {}"
proof (-)
(*goal: ‹⋀x xa. ⟦xa ∈ s; xa ∈ P1⟧ ⟹ xa ∈ {}›*)
fix x and xa
assume "xa∈s" "xa∈P1" (*‹(xa::'a) ∈ (s::'a set)› ‹(xa::'a) ∈ (P1::'a set)›*)
show "xa∈{}"
using abc_only_cba (*‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*) P1_def (*‹P1 = prolongation b a›*) ‹xa ∈ P1› (*‹xa ∈ P1›*) ‹xa ∈ s› (*‹xa ∈ s›*) s_def (*‹s = segment a b›*) by metis
qed
show "⋀x xa. xa ∈ s ⟹ xa ∈ P2 ⟹ xa ∈ {}"
proof (-)
(*goal: ‹⋀x xa. ⟦xa ∈ s; xa ∈ P2⟧ ⟹ xa ∈ {}›*)
fix x and xa
assume "xa∈s" "xa∈P2" (*‹(xa::'a) ∈ (s::'a set)› ‹(xa::'a) ∈ (P2::'a set)›*)
show "xa∈{}"
using abc_only_cba (*‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) seg_betw (*‹((?x::'a) ∈ segment (?a::'a) (?b::'a)) = [?a;?x;?b]›*) pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*) by (metis P2_def (*‹P2 = prolongation a b›*) ‹xa ∈ P2› ‹xa ∈ s› s_def (*‹s = segment a b›*))
qed
qed
qed
thus "?thesis"
(*goal: ‹P = ⋃ S ∪ P1 ∪ P2 ∪ Q ∧ card S = N - 1 ∧ (∀x∈S. is_segment x) ∧ P1 ∩ P2 = {} ∧ (∀x∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y∈S. x ≠ y ⟶ x ∩ y = {}))›*)
by (simp add: S_def (*‹(S::'a set set) = {segment (a::'a) (b::'a)}›*) s_def (*‹(s::'a set) = segment (a::'a) (b::'a)›*))
qed
lemma int_split_to_segs:
assumes f_def: "[f↝Q|a..b..c]"
fixes S defines S_def: "S ≡ {segment (f i) (f(i+1)) | i. i<card Q-1}"
shows "interval a c = (⋃S) ∪ Q"
proof (standard)
(*goals:
1. ‹interval a c ⊆ ⋃ S ∪ Q›
2. ‹⋃ S ∪ Q ⊆ interval a c›*)
let ?N = "card Q"
have f_def_2: "a∈Q ∧ b∈Q ∧ c∈Q"
using f_def (*‹[f↝Q|a..b..c]›*) points_in_long_chain (*‹[?f↝?Q|?x..?y..?z] ⟹ ?x ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?y ∈ ?Q› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ⟹ ?z ∈ ?Q›*) by blast
hence "?N ≥ 3"
using f_def (*‹[f↝Q|a..b..c]›*) long_ch_card_ge3 (*‹⟦[?f↝?X]; finite ?X⟧ ⟹ local_long_ch_by_ord ?f ?X = (3 ≤ card ?X)›*) chain_defs (*‹short_ch (?X::'a::type set) ≡ card ?X = (2::nat) ∧ (∃P::'a::type set∈𝒫::'a::type set set. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f::nat ⇒ 'a::type↝?X::'a::type set] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a .. ?y::'a] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (meson finite_long_chain_with_card (*‹[?f↝?Q|?x..?y..?z] ⟹ 3 ≤ card ?Q›*))
have bound_indices: "f 0 = a ∧ f (card Q - 1) = c"
using f_def (*‹[f::nat ⇒ 'a::type↝Q::'a::type set|a::'a::type..b::'a::type..c::'a::type]›*) chain_defs (*‹short_ch (?X::'a set) ≡ card ?X = (2::nat) ∧ (∃P::'a set∈𝒫::'a set set. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by auto
let ?i = ?u = "interval a c = (⋃S) ∪ Q"
show "?i⊆?u"
proof (standard)
(*goal: ‹⋀x. x ∈ interval a c ⟹ x ∈ ⋃ S ∪ Q›*)
fix p
assume "p ∈ ?i" (*‹(p::'a) ∈ interval (a::'a) (c::'a)›*)
show "p∈?u"
proof (cases)
(*goals:
1. ‹?P ⟹ p ∈ ⋃ S ∪ Q›
2. ‹¬ ?P ⟹ p ∈ ⋃ S ∪ Q›*)
assume "p∈Q" (*‹(p::'a) ∈ (Q::'a set)›*)
thus "?thesis"
(*goal: ‹p ∈ ⋃ S ∪ Q›*)
by blast
next
(*goal: ‹p ∉ Q ⟹ p ∈ ⋃ S ∪ Q›*)
assume "p∉Q" (*‹(p::'a) ∉ (Q::'a set)›*)
hence "p≠a ∧ p≠c"
using f_def (*‹[f↝Q|a..b..c]›*) f_def_2 (*‹a ∈ Q ∧ b ∈ Q ∧ c ∈ Q›*) by blast
hence "[a;p;c]"
using seg_betw (*‹((?x::'a::type) ∈ segment (?a::'a::type) (?b::'a::type)) = [?a;?x;?b]›*) ‹p ∈ interval a c› (*‹p ∈ interval a c›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) by auto
then obtain n⇩y and n⇩z and y and z where yz_def: "y=f n⇩y" "z=f n⇩z" "[y;p;z]" "y∈Q" "z∈Q" "n⇩y=n⇩z-1" "n⇩z<card Q" "¬(∃k < card Q. [f k; p; c] ∧ k>n⇩y)" "¬(∃k<n⇩z. [a; p; f k])"
(*goal: ‹(⋀y n⇩y z n⇩z. ⟦y = f n⇩y; z = f n⇩z; [y;p;z]; y ∈ Q; z ∈ Q; n⇩y = n⇩z - 1; n⇩z < card Q; ¬ (∃k<card Q. [f k;p;c] ∧ n⇩y < k); ¬ (∃k<n⇩z. [a;p;f k])⟧ ⟹ thesis) ⟹ thesis›*)
using get_closest_chain_events[where f = f and x = p and Y = Q and a⇩n = c and a₀ = a and a = b] (*‹⟦[f↝Q|a..b..c]; p ∉ Q; [a;p;c]; ⋀n⇩b n⇩c b ca. ⟦b = f n⇩b; ca = f n⇩c; [b;p;ca]; b ∈ Q; ca ∈ Q; n⇩b = n⇩c - 1; n⇩c < card Q; 0 < n⇩c; ¬ (∃k<card Q. [f k;p;c] ∧ n⇩b < k); ¬ (∃k<n⇩c. [a;p;f k])⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) f_def (*‹[f↝Q|a..b..c]›*) ‹p∉Q› (*‹p ∉ Q›*) by metis
have "n⇩y<card Q-1"
using yz_def(6,7) (*‹n⇩y = n⇩z - 1› ‹(n⇩z::nat) < card (Q::'a::type set)›*) f_def (*‹[f↝Q|a..b..c]›*) index_middle_element (*‹[?f↝?X|?a..?b..?c] ⟹ ∃n>0. n < card ?X - 1 ∧ ?f n = ?b›*) by fastforce
let ?s = "segment (f n⇩y) (f n⇩z)"
have "p∈?s"
using ‹[y;p;z]› (*‹[y::'a;p::'a;z::'a]›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) yz_def(1,2) (*‹y = f n⇩y› ‹(z::'a) = (f::nat ⇒ 'a) (n⇩z::nat)›*) by blast
have "n⇩z = n⇩y + 1"
using yz_def(6) (*‹(n⇩y::nat) = (n⇩z::nat) - (1::nat)›*) by (metis abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) add.commute (*‹?a + ?b = ?b + ?a›*) add_diff_inverse_nat (*‹¬ ?m < ?n ⟹ ?n + (?m - ?n) = ?m›*) less_one (*‹(?n < 1) = (?n = 0)›*) yz_def( (*‹y = f n⇩y› ‹z = f n⇩z› ‹[y;p;z]›*) 1,2,3) zero_diff (*‹0 - ?a = 0›*))
hence "?s∈S"
using S_def (*‹S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}›*) ‹n⇩y<card Q-1› (*‹n⇩y < card Q - 1›*) assms(2) (*‹S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}›*) by blast
hence "p∈⋃S"
using ‹p ∈ ?s› (*‹p ∈ segment (f n⇩y) (f n⇩z)›*) by blast
thus "?thesis"
(*goal: ‹p ∈ ⋃ S ∪ Q›*)
by blast
qed
qed
show "?u⊆?i"
proof (standard)
(*goal: ‹⋀x. x ∈ ⋃ S ∪ Q ⟹ x ∈ interval a c›*)
fix p
assume "p ∈ ?u" (*‹(p::'a) ∈ ⋃ (S::'a set set) ∪ (Q::'a set)›*)
hence "p∈⋃S ∨ p∈Q"
by blast
thus "p∈?i"
proof (standard)
(*goals:
1. ‹p ∈ ⋃ S ⟹ p ∈ interval a c›
2. ‹p ∈ Q ⟹ p ∈ interval a c›*)
assume "p∈Q" (*‹(p::'a) ∈ (Q::'a set)›*)
then consider "p=a" | "p=c" | "[a;p;c]"
(*goal: ‹⟦(p::'a) = (a::'a) ⟹ thesis::bool; p = (c::'a) ⟹ thesis; [a;p;c] ⟹ thesis⟧ ⟹ thesis›*)
using f_def (*‹[f↝Q|a..b..c]›*) by (meson fin_ch_betw2 (*‹⟦[?f↝?X|?a .. ?c]; ?b ∈ ?X; ?b = ?a ⟹ ?thesis; ?b = ?c ⟹ ?thesis; [?a;?b;?c] ⟹ ?thesis⟧ ⟹ ?thesis›*) finite_long_chain_with_alt (*‹[?f↝?Q|?x..?y..?z] = ([?f↝?Q|?x .. ?z] ∧ [?x;?y;?z] ∧ ?y ∈ ?Q)›*))
thus "?thesis"
(*goal: ‹p ∈ interval a c›*)
proof (cases)
(*goals:
1. ‹p = a ⟹ p ∈ interval a c›
2. ‹p = c ⟹ p ∈ interval a c›
3. ‹[a;p;c] ⟹ p ∈ interval a c›*)
assume "p=a" (*‹(p::'a) = (a::'a)›*)
thus "?thesis"
(*goal: ‹(p::'a) ∈ interval (a::'a) (c::'a)›*)
by (simp add: interval_def (*‹interval (?a::'a) (?b::'a) ≡ insert ?b (insert ?a (segment ?a ?b))›*))
next
(*goals:
1. ‹(p::'a) = (c::'a) ⟹ p ∈ interval (a::'a) c›
2. ‹[a::'a;p::'a;c::'a] ⟹ p ∈ interval a c›*)
assume "p=c" (*‹(p::'a) = (c::'a)›*)
thus "?thesis"
(*goal: ‹p ∈ interval a c›*)
by (simp add: interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*))
next
(*goal: ‹[a;p;c] ⟹ p ∈ interval a c›*)
assume "[a;p;c]" (*‹[a::'a;p::'a;c::'a]›*)
thus "?thesis"
(*goal: ‹p ∈ interval a c›*)
using interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by auto
qed
next
(*goal: ‹(p::'a) ∈ ⋃ (S::'a set set) ⟹ p ∈ interval (a::'a) (c::'a)›*)
assume "p∈⋃S" (*‹(p::'a) ∈ ⋃ (S::'a set set)›*)
then obtain s where "p∈s" "s∈S"
(*goal: ‹(⋀s. ⟦p ∈ s; s ∈ S⟧ ⟹ thesis) ⟹ thesis›*)
by blast
then obtain y where "s = segment (f y) (f (y+1))" "y<?N-1"
(*goal: ‹(⋀y. ⟦s = segment (f y) (f (y + 1)); y < card Q - 1⟧ ⟹ thesis) ⟹ thesis›*)
using S_def (*‹S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}›*) by blast
hence "y+1<?N"
by (simp add: assms( (*‹S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}›*) 2))
hence fy_in_Q: "(f y)∈Q ∧ f (y+1) ∈ Q"
using f_def (*‹[f↝Q|a..b..c]›*) add_lessD1 (*‹(?i::nat) + (?j::nat) < (?k::nat) ⟹ ?i < ?k›*) unfolding chain_defs local_ordering_def
(*goal: ‹f y ∈ Q ∧ f (y + 1) ∈ Q›*)
by (metis One_nat_def (*‹1 = Suc 0›*) Suc_eq_plus1 (*‹Suc ?n = ?n + 1›*) Zero_not_Suc (*‹0 ≠ Suc ?m›*) ‹3≤card Q› card_1_singleton_iff (*‹(card ?A = Suc 0) = (∃x. ?A = {x})›*) card_gt_0_iff (*‹(0 < card ?A) = (?A ≠ {} ∧ finite ?A)›*) card_insert_if (*‹finite ?A ⟹ card (insert ?x ?A) = (if ?x ∈ ?A then card ?A else Suc (card ?A))›*) diff_add_inverse2 (*‹?m + ?n - ?n = ?m›*) diff_is_0_eq' (*‹?m ≤ ?n ⟹ ?m - ?n = 0›*) less_numeral_extra( (*‹0 < 1›*) 1) numeral_3_eq_3 (*‹3 = Suc (Suc (Suc 0))›*) plus_1_eq_Suc (*‹(+) 1 = Suc›*))
have "[a; f y; c] ∨ y=0"
using ‹y <?N - 1› (*‹y < card Q - 1›*) assms(2) (*‹S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}›*) f_def (*‹[f::nat ⇒ 'a::type↝Q::'a::type set|a::'a::type..b::'a::type..c::'a::type]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a::type set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) by auto
moreover have "[a; f (y+1); c] ∨ y = ?N-2"
using ‹y+1 < card Q› (*‹y + 1 < card Q›*) assms(2) (*‹S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}›*) f_def (*‹[f↝Q|a..b..c]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a::type) (?X::'a::type set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type..?y::'a::type..?z::'a::type] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) order_finite_chain (*‹⟦local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set); finite ?X; (0::nat) ≤ (?i::nat) ∧ ?i < (?j::nat) ∧ ?j < (?l::nat) ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) i_le_j_events_neq (*‹⟦[?f↝?X|?a..?b..?c]; ?i < ?j; ?j < card ?X⟧ ⟹ ?f ?i ≠ ?f ?j›*) using indices_neq_imp_events_neq (*‹⟦[?f↝?X|?a..?b..?c]; ?i ≠ ?j; ?j < card ?X; ?i < card ?X⟧ ⟹ ?f ?i ≠ ?f ?j›*) fin_ch_betw2 (*‹⟦[?f↝?X|?a .. ?c]; ?b ∈ ?X; ?b = ?a ⟹ ?thesis; ?b = ?c ⟹ ?thesis; [?a;?b;?c] ⟹ ?thesis⟧ ⟹ ?thesis›*) fy_in_Q (*‹f y ∈ Q ∧ f (y + 1) ∈ Q›*) by (smt (z3) Nat.add_0_right (*‹?m + 0 = ?m›*) Nat.add_diff_assoc (*‹?k ≤ ?j ⟹ ?i + (?j - ?k) = ?i + ?j - ?k›*) add_gr_0 (*‹(0 < ?m + ?n) = (0 < ?m ∨ 0 < ?n)›*) card_Diff1_less (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ card (?A - {?x}) < card ?A›*) card_Diff_singleton_if (*‹card (?A - {?x}) = (if ?x ∈ ?A then card ?A - 1 else card ?A)›*) diff_diff_left (*‹?i - ?j - ?k = ?i - (?j + ?k)›*) diff_is_0_eq' (*‹?m ≤ ?n ⟹ ?m - ?n = 0›*) le_numeral_extra( (*‹1 ≤ 1›*) 4) less_numeral_extra( (*‹0 < 1›*) 1) nat_1_add_1 (*‹1 + 1 = 2›*))
ultimately consider "y=0" | "y=?N-2" | "([a; f y; c] ∧ [a; f (y+1); c])"
(*goal: ‹⟦y = 0 ⟹ thesis; y = card Q - 2 ⟹ thesis; [a;f y;c] ∧ [a;f (y + 1);c] ⟹ thesis⟧ ⟹ thesis›*)
by linarith
hence "[a;p;c]"
proof (cases)
(*goals:
1. ‹y = 0 ⟹ [a;p;c]›
2. ‹y = card Q - 2 ⟹ [a;p;c]›
3. ‹[a;f y;c] ∧ [a;f (y + 1);c] ⟹ [a;p;c]›*)
assume "y=0" (*‹(y::nat) = (0::nat)›*)
hence "f y = a"
by (simp add: bound_indices (*‹f 0 = a ∧ f (card Q - 1) = c›*))
hence "[a; p; (f(y+1))]"
using ‹p ∈ s› (*‹p ∈ s›*) ‹s = segment (f y) (f (y + 1))› (*‹s = segment (f y) (f (y + 1))›*) seg_betw (*‹((?x::'a::type) ∈ segment (?a::'a::type) (?b::'a::type)) = [?a;?x;?b]›*) by auto
moreover have "[a; (f(y+1)); c]"
using ‹[a; (f(y+1)); c] ∨ y = ?N - 2› (*‹[a;f (y + 1);c] ∨ y = card Q - 2›*) ‹y = 0› (*‹y = 0›*) ‹?N≥3› (*‹3 ≤ card Q›*) by linarith
ultimately show "[a;p;c]"
using abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) by blast
next
(*goals:
1. ‹y = card Q - 2 ⟹ [a;p;c]›
2. ‹[a;f y;c] ∧ [a;f (y + 1);c] ⟹ [a;p;c]›*)
assume "y=?N-2" (*‹(y::nat) = card (Q::'a set) - (2::nat)›*)
hence "f (y+1) = c"
using bound_indices (*‹(f::nat ⇒ 'a::type) (0::nat) = (a::'a::type) ∧ f (card (Q::'a::type set) - (1::nat)) = (c::'a::type)›*) ‹?N≥3› (*‹3 ≤ card Q›*) numeral_2_eq_2 (*‹2 = Suc (Suc 0)›*) numeral_3_eq_3 (*‹(3::nat) = Suc (Suc (Suc (0::nat)))›*) by (metis One_nat_def (*‹1 = Suc 0›*) Suc_diff_le (*‹?n ≤ ?m ⟹ Suc ?m - ?n = Suc (?m - ?n)›*) add.commute (*‹?a + ?b = ?b + ?a›*) add_leD2 (*‹?m + ?k ≤ ?n ⟹ ?k ≤ ?n›*) diff_Suc_Suc (*‹Suc ?m - Suc ?n = ?m - ?n›*) plus_1_eq_Suc (*‹(+) 1 = Suc›*))
hence "[f y; p; c]"
using ‹p ∈ s› (*‹(p::'a) ∈ (s::'a set)›*) ‹s = segment (f y) (f (y + 1))› (*‹s = segment (f y) (f (y + 1))›*) seg_betw (*‹((?x::'a) ∈ segment (?a::'a) (?b::'a)) = [?a;?x;?b]›*) by auto
moreover have "[a; f y; c]"
using ‹[a; f y; c] ∨ y = 0› (*‹[a;f y;c] ∨ y = 0›*) ‹y = ?N - 2› (*‹y = card Q - 2›*) ‹?N≥3› (*‹3 ≤ card Q›*) by linarith
ultimately show "[a;p;c]"
by (meson abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*))
next
(*goal: ‹[a;f y;c] ∧ [a;f (y + 1);c] ⟹ [a;p;c]›*)
assume "[a; f y; c] ∧ [a; (f(y+1)); c]" (*‹[a::'a;(f::nat ⇒ 'a) (y::nat);c::'a] ∧ [a;f (y + (1::nat));c]›*)
thus "[a;p;c]"
using abe_ade_bcd_ace[where a = a and b = "f y" and d = "f (y+1)" and e = c and c = p] (*‹⟦[a::'a::type;(f::nat ⇒ 'a::type) (y::nat);c::'a::type]; [a;f (y + (1::nat));c]; [f y;p::'a::type;f (y + (1::nat))]⟧ ⟹ [a;p;c]›*) using ‹p ∈ s› (*‹(p::'a::type) ∈ (s::'a::type set)›*) ‹s = segment (f y) (f(y+1))› (*‹s = segment (f y) (f (y + 1))›*) seg_betw (*‹((?x::'a) ∈ segment (?a::'a) (?b::'a)) = [?a;?x;?b]›*) by auto
qed
thus "?thesis"
(*goal: ‹p ∈ interval a c›*)
using interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹((?x::'a) ∈ segment (?a::'a) (?b::'a)) = [?a;?x;?b]›*) by auto
qed
qed
qed
lemma (*for 11*) path_is_union:
assumes path_P: "P∈𝒫"
and Q_def: "finite (Q::'a set)" "card Q = N" "Q⊆P" "N≥3"
and f_def: "a∈Q ∧ b∈Q ∧ c∈Q" "[f↝Q|a..b..c]"
and S_def: "S = {s. ∃i<(N-1). s = segment (f i) (f (i+1))}"
and P1_def: "P1 = prolongation b a"
and P2_def: "P2 = prolongation b c"
shows "P = ((⋃S) ∪ P1 ∪ P2 ∪ Q)"
proof (-)
(*goal: ‹P = ⋃ S ∪ P1 ∪ P2 ∪ Q›*)
have in_P: "a∈P ∧ b∈P ∧ c∈P"
using assms(4) (*‹Q ⊆ P›*) f_def (*‹a ∈ Q ∧ b ∈ Q ∧ c ∈ Q› ‹[f↝Q|a..b..c]›*) by blast
have bound_indices: "f 0 = a ∧ f (card Q - 1) = c"
using f_def (*‹a ∈ Q ∧ b ∈ Q ∧ c ∈ Q› ‹[f↝Q|a..b..c]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f::nat ⇒ 'a↝?X::'a set] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by auto
have points_neq: "a≠b ∧ b≠c ∧ a≠c"
using f_def (*‹a ∈ Q ∧ b ∈ Q ∧ c ∈ Q› ‹[f↝Q|a..b..c]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a::type) (?X::'a::type set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis first_neq_last (*‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a .. ?z::'a] ⟹ ?x ≠ ?z›*))
text ‹The proof in two parts: subset inclusion one way, then the other.›
{
fix x
assume "x∈P" (*‹(x::'a) ∈ (P::'a set)›*)
have "[a;x;c] ∨ [b;a;x] ∨ [b;c;x] ∨ x=a ∨ x=c"
using in_P (*‹a ∈ P ∧ b ∈ P ∧ c ∈ P›*) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) path_P (*‹P ∈ 𝒫›*) points_neq (*‹(a::'a) ≠ (b::'a) ∧ b ≠ (c::'a) ∧ a ≠ c›*) ‹x ∈ P› (*‹x ∈ P›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by (metis (full_types) abc_acd_bcd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?b;?c;?d]›*) fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*) f_def( (*‹[f↝Q|a..b..c]›*) 2))
then have "(∃s∈S. x∈s) ∨ x∈P1 ∨ x∈P2 ∨ x∈Q"
proof (cases)
(*goals:
1. ‹⟦[a;x;c] ∨ [b;a;x] ∨ [b;c;x] ∨ x = a ∨ x = c; ?P1⟧ ⟹ (∃s∈S. x ∈ s) ∨ x ∈ P1 ∨ x ∈ P2 ∨ x ∈ Q›
2. ‹⟦[a;x;c] ∨ [b;a;x] ∨ [b;c;x] ∨ x = a ∨ x = c; ¬ ?P1⟧ ⟹ (∃s∈S. x ∈ s) ∨ x ∈ P1 ∨ x ∈ P2 ∨ x ∈ Q›*)
assume "[a;x;c]" (*‹[a::'a;x::'a;c::'a]›*)
hence only_axc: "¬([b;a;x] ∨ [b;c;x] ∨ x=a ∨ x=c)"
using abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) by (meson abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) f_def (*‹a ∈ Q ∧ b ∈ Q ∧ c ∈ Q› ‹[f↝Q|a..b..c]›*) fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*))
have "x ∈ interval a c"
using ‹[a;x;c]› (*‹[a;x;c]›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by auto
hence "x∈Q ∨ x∈⋃S"
using int_split_to_segs (*‹[?f↝?Q|?a..?b..?c] ⟹ interval ?a ?c = ⋃ {segment (?f i) (?f (i + 1)) |i. i < card ?Q - 1} ∪ ?Q›*) S_def (*‹S = {s. ∃i<N - 1. s = segment (f i) (f (i + 1))}›*) assms(2,3,5) (*‹finite Q› ‹card Q = N› ‹3 ≤ N›*) f_def (*‹a ∈ Q ∧ b ∈ Q ∧ c ∈ Q› ‹[f↝Q|a..b..c]›*) by blast
thus "?thesis"
(*goal: ‹(∃s∈S. x ∈ s) ∨ x ∈ P1 ∨ x ∈ P2 ∨ x ∈ Q›*)
by blast
next
(*goal: ‹⟦[a;x;c] ∨ [b;a;x] ∨ [b;c;x] ∨ x = a ∨ x = c; ¬ [a;x;c]⟧ ⟹ (∃s∈S. x ∈ s) ∨ x ∈ P1 ∨ x ∈ P2 ∨ x ∈ Q›*)
assume "¬[a;x;c]" (*‹¬ [a::'a;x::'a;c::'a]›*)
hence "[b;a;x] ∨ [b;c;x] ∨ x=a ∨ x=c"
using ‹[a;x;c] ∨ [b;a;x] ∨ [b;c;x] ∨ x = a ∨ x = c› (*‹[a;x;c] ∨ [b;a;x] ∨ [b;c;x] ∨ x = a ∨ x = c›*) by blast
hence " x∈P1 ∨ x∈P2 ∨ x∈Q"
using P1_def (*‹P1 = prolongation b a›*) P2_def (*‹P2 = prolongation b c›*) f_def (*‹a ∈ Q ∧ b ∈ Q ∧ c ∈ Q› ‹[f↝Q|a..b..c]›*) pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*) by auto
thus "?thesis"
(*goal: ‹(∃s::'a set∈S::'a set set. (x::'a) ∈ s) ∨ x ∈ (P1::'a set) ∨ x ∈ (P2::'a set) ∨ x ∈ (Q::'a set)›*)
by blast
qed
hence "x ∈ (⋃S) ∪ P1 ∪ P2 ∪ Q"
by blast
}
moreover {
fix x
assume "x ∈ (⋃S) ∪ P1 ∪ P2 ∪ Q" (*‹(x::'a) ∈ ⋃ (S::'a set set) ∪ (P1::'a set) ∪ (P2::'a set) ∪ (Q::'a set)›*)
hence "(∃s∈S. x∈s) ∨ x∈P1 ∨ x∈P2 ∨ x∈Q"
by blast
hence "x∈⋃S ∨ [b;a;x] ∨ [b;c;x] ∨ x∈Q"
using S_def (*‹S = {s. ∃i<N - 1. s = segment (f i) (f (i + 1))}›*) P1_def (*‹P1 = prolongation b a›*) P2_def (*‹P2 = prolongation b c›*) unfolding segment_def prolongation_def
(*goal: ‹x ∈ ⋃ S ∨ [b;a;x] ∨ [b;c;x] ∨ x ∈ Q›*)
by auto
hence "x∈P"
proof (cases)
(*goals:
1. ‹⟦(x::'a::type) ∈ ⋃ (S::'a::type set set) ∨ [b::'a::type;a::'a::type;x] ∨ [b;c::'a::type;x] ∨ x ∈ (Q::'a::type set); ?P1::bool⟧ ⟹ x ∈ (P::'a::type set)›
2. ‹⟦(x::'a::type) ∈ ⋃ (S::'a::type set set) ∨ [b::'a::type;a::'a::type;x] ∨ [b;c::'a::type;x] ∨ x ∈ (Q::'a::type set); ¬ (?P1::bool)⟧ ⟹ x ∈ (P::'a::type set)›*)
assume "x∈⋃S" (*‹(x::'a) ∈ ⋃ (S::'a set set)›*)
have "S = {segment (f i) (f(i+1)) | i. i<N-1}"
using S_def (*‹(S::'a set set) = {s::'a set. ∃i<(N::nat) - (1::nat). s = segment ((f::nat ⇒ 'a) i) (f (i + (1::nat)))}›*) by blast
hence "x∈interval a c"
using int_split_to_segs[OF f_def ( 2 )] (*‹interval a c = ⋃ {segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ Q›*) assms (*‹P ∈ 𝒫› ‹finite Q› ‹card Q = N› ‹Q ⊆ P› ‹(3::nat) ≤ (N::nat)› ‹a ∈ Q ∧ b ∈ Q ∧ c ∈ Q› ‹[f↝Q|a..b..c]› ‹S = {s. ∃i<N - 1. s = segment (f i) (f (i + 1))}› ‹P1 = prolongation b a› ‹(P2::'a::type set) = prolongation (b::'a::type) (c::'a::type)›*) ‹x∈⋃S› (*‹x ∈ ⋃ S›*) by (simp add: UnCI (*‹(?c ∉ ?B ⟹ ?c ∈ ?A) ⟹ ?c ∈ ?A ∪ ?B›*))
hence "[a;x;c] ∨ x=a ∨ x=c"
using interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹((?x::'a) ∈ segment (?a::'a) (?b::'a)) = [?a;?x;?b]›*) by auto
thus "?thesis"
(*goal: ‹x ∈ P›*)
proof (rule disjE (*‹⟦(?P::bool) ∨ (?Q::bool); ?P ⟹ ?R::bool; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹[a;x;c] ⟹ x ∈ P›
2. ‹x = a ∨ x = c ⟹ x ∈ P›*)
assume "x=a ∨ x=c" (*‹(x::'a) = (a::'a) ∨ x = (c::'a)›*)
thus "?thesis"
(*goal: ‹(x::'a) ∈ (P::'a set)›*)
using in_P (*‹a ∈ P ∧ b ∈ P ∧ c ∈ P›*) by blast
next
(*goal: ‹[a;x;c] ⟹ x ∈ P›*)
assume "[a;x;c]" (*‹[a::'a;x::'a;c::'a]›*)
thus "?thesis"
(*goal: ‹x ∈ P›*)
using betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) in_P (*‹(a::'a) ∈ (P::'a set) ∧ (b::'a) ∈ P ∧ (c::'a) ∈ P›*) path_P (*‹P ∈ 𝒫›*) points_neq (*‹(a::'a::type) ≠ (b::'a::type) ∧ b ≠ (c::'a::type) ∧ a ≠ c›*) by blast
qed
next
(*goal: ‹⟦x ∈ ⋃ S ∨ [b;a;x] ∨ [b;c;x] ∨ x ∈ Q; x ∉ ⋃ S⟧ ⟹ x ∈ P›*)
assume "x∉⋃S" (*‹(x::'a) ∉ ⋃ (S::'a set set)›*)
hence "[b;a;x] ∨ [b;c;x] ∨ x∈Q"
using ‹x ∈ ⋃ S ∨ [b;a;x] ∨ [b;c;x] ∨ x ∈ Q› (*‹x ∈ ⋃ S ∨ [b;a;x] ∨ [b;c;x] ∨ x ∈ Q›*) by blast
thus "?thesis"
(*goal: ‹x ∈ P›*)
using assms(4) (*‹Q ⊆ P›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) in_P (*‹a ∈ P ∧ b ∈ P ∧ c ∈ P›*) path_P (*‹P ∈ 𝒫›*) points_neq (*‹a ≠ b ∧ b ≠ c ∧ a ≠ c›*) by blast
qed
}
ultimately show "P = ((⋃S) ∪ P1 ∪ P2 ∪ Q)"
by blast
qed
lemma (*for 11*) inseg_axc:
assumes path_P: "P∈𝒫"
and Q_def: "finite (Q::'a set)" "card Q = N" "Q⊆P" "N≥3"
and f_def: "a∈Q ∧ b∈Q ∧ c∈Q" "[f↝Q|a..b..c]"
and S_def: "S = {s. ∃i<(N-1). s = segment (f i) (f (i+1))}"
and x_def: "x∈s" "s∈S"
shows "[a;x;c]"
proof (-)
(*goal: ‹[a;x;c]›*)
have fQ: "local_long_ch_by_ord f Q"
using f_def (*‹(a::'a::type) ∈ (Q::'a::type set) ∧ (b::'a::type) ∈ Q ∧ (c::'a::type) ∈ Q› ‹[f::nat ⇒ 'a↝Q::'a set|a::'a..b::'a..c::'a]›*) Q_def (*‹finite Q› ‹card Q = N› ‹Q ⊆ P› ‹3 ≤ N›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis ch_long_if_card_geq3 (*‹⟦ch ?X; 3 ≤ card ?X⟧ ⟹ ∃f. local_long_ch_by_ord f ?X›*) path_P (*‹P ∈ 𝒫›*) short_ch_card( (*‹short_ch_by_ord ?f ?Q ⟹ card ?Q = 2›*) 1) short_xor_long( (*‹local_long_ch_by_ord ?f ?Q ⟹ ¬ short_ch ?Q›*) 2))
have inseg_neq_ac: "x≠a ∧ x≠c" if "x∈s" "s∈S" for x and s
proof (standard)
(*goals:
1. ‹x ≠ a›
2. ‹x ≠ c›*)
show "x≠a"
proof (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹x = a ⟹ False›*)
assume "x=a" (*‹(x::'a) = (a::'a)›*)
obtain n where s_def: "s = segment (f n) (f (n+1))" "n<N-1"
(*goal: ‹(⋀n. ⟦s = segment (f n) (f (n + 1)); n < N - 1⟧ ⟹ thesis) ⟹ thesis›*)
using S_def (*‹S = {s. ∃i<N - 1. s = segment (f i) (f (i + 1))}›*) ‹s ∈ S› (*‹s ∈ S›*) by blast
hence "n<card Q"
using assms(3) (*‹card Q = N›*) by linarith
hence "f n ∈ Q"
using fQ (*‹local_long_ch_by_ord (f::nat ⇒ 'a::type) (Q::'a::type set)›*) unfolding chain_defs local_ordering_def
(*goal: ‹f n ∈ Q›*)
by blast
hence "[a; f n; c]"
using f_def (*‹a ∈ Q ∧ b ∈ Q ∧ c ∈ Q› ‹[f↝Q|a..b..c]›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) assms(3) (*‹card Q = N›*) order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) that(1) (*‹x ∈ s›*) using ‹n < N - 1› (*‹n < N - 1›*) ‹s = segment (f n) (f (n + 1))› (*‹s = segment (f n) (f (n + 1))›*) ‹x = a› (*‹x = a›*) by (metis abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) add_lessD1 (*‹?i + ?j < ?k ⟹ ?i < ?k›*) fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*) inside_not_bound( (*‹⟦[?f↝?X|?a .. ?c]; ?j < card ?X; ?j < card ?X - 1⟧ ⟹ ?f ?j ≠ ?c›*) 2) less_diff_conv (*‹(?i < ?j - ?k) = (?i + ?k < ?j)›*))
moreover have "[(f(n)); x; (f(n+1))]"
using ‹x∈s› (*‹(x::'a) ∈ (s::'a set)›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) s_def(1) (*‹s = segment (f n) (f (n + 1))›*) by simp
ultimately show False
using ‹x=a› (*‹(x::'a) = (a::'a)›*) abc_only_cba(1) (*‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?b;?a;?c]›*) assms(3) (*‹card Q = N›*) fQ (*‹local_long_ch_by_ord f Q›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) s_def(2) (*‹(n::nat) < (N::nat) - (1::nat)›*) by (smt (z3) ‹n < card Q› f_def( (*‹[f↝Q|a..b..c]›*) 2) order_finite_chain_indices2 (*‹⟦[?f↝?X|?a .. ?c]; ?f ?j = ?b; ?j < card ?X; 0 < ?j ∧ ?j < card ?X - 1 ⟹ ?thesis; ?j = card ?X - 1 ∧ ?b = ?c ⟹ ?thesis; ?j = 0 ∧ ?b = ?a ⟹ ?thesis⟧ ⟹ ?thesis›*) thm2_ind1 (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X⟧ ⟹ ∀j i. i < j ∧ j < card ?X - 1 ⟶ [?f i;?f j;?f (j + 1)]›*))
qed
show "x≠c"
proof (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹x = c ⟹ False›*)
assume "x=c" (*‹(x::'a) = (c::'a)›*)
obtain n where s_def: "s = segment (f n) (f (n+1))" "n<N-1"
(*goal: ‹(⋀n::nat. ⟦(s::'a::type set) = segment ((f::nat ⇒ 'a::type) n) (f (n + (1::nat))); n < (N::nat) - (1::nat)⟧ ⟹ thesis::bool) ⟹ thesis›*)
using S_def (*‹S = {s. ∃i<N - 1. s = segment (f i) (f (i + 1))}›*) ‹s ∈ S› (*‹s ∈ S›*) by blast
hence "n+1<N"
by simp
have "[(f(n)); x; (f(n+1))]"
using ‹x∈s› (*‹x ∈ s›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) s_def(1) (*‹s = segment (f n) (f (n + 1))›*) by simp
have "f (n) ∈ Q"
using fQ (*‹local_long_ch_by_ord f Q›*) ‹n+1 < N› (*‹n + 1 < N›*) chain_defs (*‹short_ch (?X::'a set) ≡ card ?X = (2::nat) ∧ (∃P::'a set∈𝒫::'a set set. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) local_ordering_def (*‹local_ordering ?f ?ord ?X ≡ (∀n. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x∈?X. ∃n. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) by (metis add_lessD1 (*‹?i + ?j < ?k ⟹ ?i < ?k›*) assms( (*‹card Q = N›*) 3))
have "f (n+1) ∈ Q"
using ‹n+1 < N› (*‹n + 1 < N›*) fQ (*‹local_long_ch_by_ord f Q›*) chain_defs (*‹short_ch (?X::'a set) ≡ card ?X = (2::nat) ∧ (∃P::'a set∈𝒫::'a set set. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f::nat ⇒ 'a↝?X::'a set] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) local_ordering_def (*‹local_ordering (?f::nat ⇒ ?'a::type) (?ord::?'a::type ⇒ ?'a::type ⇒ ?'a::type ⇒ bool) (?X::?'a::type set) ≡ (∀n::nat. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x::?'a::type∈?X. ∃n::nat. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n::nat. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) by (metis assms( (*‹card Q = N›*) 3))
have "f(n+1) ≠ c"
using ‹x=c› (*‹x = c›*) ‹[(f(n)); x; (f(n+1))]› (*‹[f n;x;f (n + 1)]›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) by blast
hence "[a; (f(n+1)); c]"
using f_def (*‹a ∈ Q ∧ b ∈ Q ∧ c ∈ Q› ‹[f::nat ⇒ 'a::type↝Q::'a::type set|a::'a::type..b::'a::type..c::'a::type]›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) assms(3) (*‹card Q = N›*) order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) that(1) (*‹x ∈ s›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?c;?a;?b]›*) fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*) by (metis ‹[f n; x; f (n + 1)]› ‹f (n + 1) ∈ Q› ‹f n ∈ Q› ‹x = c›)
thus False
using ‹x=c› (*‹x = c›*) ‹[(f(n)); x; (f(n+1))]› (*‹[f n;x;f (n + 1)]›*) assms(3) (*‹card (Q::'a::type set) = (N::nat)›*) f_def (*‹(a::'a) ∈ (Q::'a set) ∧ (b::'a) ∈ Q ∧ (c::'a) ∈ Q› ‹[f↝Q|a..b..c]›*) s_def(2) (*‹n < N - 1›*) abc_only_cba(1) (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) by (metis ‹f n ∈ Q› abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) 1,2) fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*))
qed
qed
show "[a;x;c]"
proof (-)
(*goal: ‹[a;x;c]›*)
have "x∈interval a c"
using int_split_to_segs[OF f_def ( 2 )] (*‹interval a c = ⋃ {segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ Q›*) S_def (*‹S = {s. ∃i<N - 1. s = segment (f i) (f (i + 1))}›*) assms(2,3,5) (*‹finite Q› ‹card Q = N› ‹3 ≤ N›*) x_def (*‹x ∈ s› ‹s ∈ S›*) by blast
have "x≠a ∧ x≠c"
using inseg_neq_ac (*‹⟦(?x::'a) ∈ (?s::'a set); ?s ∈ (S::'a set set)⟧ ⟹ ?x ≠ (a::'a) ∧ ?x ≠ (c::'a)›*) using x_def (*‹(x::'a) ∈ (s::'a set)› ‹(s::'a set) ∈ (S::'a set set)›*) by auto
thus "?thesis"
(*goal: ‹[a;x;c]›*)
using seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) ‹x ∈ interval a c› (*‹x ∈ interval a c›*) interval_def (*‹interval (?a::'a::type) (?b::'a::type) ≡ insert ?b (insert ?a (segment ?a ?b))›*) by auto
qed
qed
lemma disjoint_segmentation:
assumes path_P: "P∈𝒫"
and Q_def: "finite (Q::'a set)" "card Q = N" "Q⊆P" "N≥3"
and f_def: "a∈Q ∧ b∈Q ∧ c∈Q" "[f↝Q|a..b..c]"
and S_def: "S = {s. ∃i<(N-1). s = segment (f i) (f (i+1))}"
and P1_def: "P1 = prolongation b a"
and P2_def: "P2 = prolongation b c"
shows "P1∩P2={} ∧ (∀x∈S. (x∩P1={} ∧ x∩P2={} ∧ (∀y∈S. x≠y ⟶ x∩y={})))"
proof (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹P1 ∩ P2 = {}›
2. ‹∀x∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y∈S. x ≠ y ⟶ x ∩ y = {})›*)
have fQ: "local_long_ch_by_ord f Q"
using f_def (*‹a ∈ Q ∧ b ∈ Q ∧ c ∈ Q› ‹[f::nat ⇒ 'a↝Q::'a set|a::'a..b::'a..c::'a]›*) Q_def (*‹finite Q› ‹card (Q::'a::type set) = (N::nat)› ‹(Q::'a set) ⊆ (P::'a set)› ‹(3::nat) ≤ (N::nat)›*) chain_defs (*‹short_ch (?X::'a set) ≡ card ?X = (2::nat) ∧ (∃P::'a set∈𝒫::'a set set. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis ch_long_if_card_geq3 (*‹⟦ch ?X; 3 ≤ card ?X⟧ ⟹ ∃f. local_long_ch_by_ord f ?X›*) path_P (*‹P ∈ 𝒫›*) short_ch_card( (*‹short_ch_by_ord ?f ?Q ⟹ card ?Q = 2›*) 1) short_xor_long( (*‹local_long_ch_by_ord ?f ?Q ⟹ ¬ short_ch ?Q›*) 2))
show "P1 ∩ P2 = {}"
proof (safe)
(*goal: ‹⋀x. ⟦x ∈ P1; x ∈ P2⟧ ⟹ x ∈ {}›*)
fix x
assume "x∈P1" "x∈P2" (*‹(x::'a) ∈ (P1::'a set)› ‹(x::'a) ∈ (P2::'a set)›*)
show "x∈{}"
using abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*) P1_def (*‹P1 = prolongation b a›*) P2_def (*‹(P2::'a set) = prolongation (b::'a) (c::'a)›*) by (metis ‹x ∈ P1› ‹x ∈ P2› abc_bcd_abd (*‹⟦[?a::'a::type;?b::'a::type;?c::'a::type]; [?b;?c;?d::'a::type]⟧ ⟹ [?a;?b;?d]›*) f_def( (*‹[f::nat ⇒ 'a::type↝Q::'a::type set|a::'a::type..b::'a::type..c::'a::type]›*) 2) fin_ch_betw (*‹[?f::nat ⇒ 'a::type↝?X::'a::type set|?a::'a::type..?b::'a::type..?c::'a::type] ⟹ [?a;?b;?c]›*))
qed
show "∀x∈S. (x∩P1={} ∧ x∩P2={} ∧ (∀y∈S. x≠y ⟶ x∩y={}))"
proof (rule ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*))
(*goal: ‹⋀x::'a set. x ∈ (S::'a set set) ⟹ x ∩ (P1::'a set) = {} ∧ x ∩ (P2::'a set) = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {})›*)
fix s
assume "s∈S" (*‹(s::'a set) ∈ (S::'a set set)›*)
show "s ∩ P1 = {} ∧ s ∩ P2 = {} ∧ (∀y∈S. s ≠ y ⟶ s ∩ y = {})"
proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goals:
1. ‹s ∩ P1 = {}›
2. ‹s ∩ P2 = {}›
3. ‹⋀y. ⟦y ∈ S; s ≠ y⟧ ⟹ s ∩ y = {}›*)
show "s∩P1={}"
proof (safe)
(*goal: ‹⋀x::'a::type. ⟦x ∈ (s::'a::type set); x ∈ (P1::'a::type set)⟧ ⟹ x ∈ {}›*)
fix x
assume "x∈s" "x∈P1" (*‹(x::'a) ∈ (s::'a set)› ‹(x::'a) ∈ (P1::'a set)›*)
hence "[a;x;c]"
using inseg_axc (*‹⟦?P ∈ 𝒫; finite ?Q; card ?Q = ?N; ?Q ⊆ ?P; 3 ≤ ?N; ?a ∈ ?Q ∧ ?b ∈ ?Q ∧ ?c ∈ ?Q; [?f↝?Q|?a..?b..?c]; ?S = {s. ∃i<?N - 1. s = segment (?f i) (?f (i + 1))}; ?x ∈ ?s; ?s ∈ ?S⟧ ⟹ [?a;?x;?c]›*) ‹s ∈ S› (*‹s ∈ S›*) assms (*‹P ∈ 𝒫› ‹finite Q› ‹card (Q::'a::type set) = (N::nat)› ‹Q ⊆ P› ‹3 ≤ N› ‹(a::'a) ∈ (Q::'a set) ∧ (b::'a) ∈ Q ∧ (c::'a) ∈ Q› ‹[f::nat ⇒ 'a::type↝Q::'a::type set|a::'a::type..b::'a::type..c::'a::type]› ‹S = {s. ∃i<N - 1. s = segment (f i) (f (i + 1))}› ‹P1 = prolongation b a› ‹(P2::'a set) = prolongation (b::'a) (c::'a)›*) by blast
thus "x∈{}"
by (metis P1_def (*‹P1 = prolongation b a›*) ‹x ∈ P1› abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]›*) 1) f_def( (*‹[f↝Q|a..b..c]›*) 2) fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*) pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*))
qed
show "s∩P2={}"
proof (safe)
(*goal: ‹⋀x. ⟦x ∈ s; x ∈ P2⟧ ⟹ x ∈ {}›*)
fix x
assume "x∈s" "x∈P2" (*‹(x::'a) ∈ (s::'a set)› ‹(x::'a) ∈ (P2::'a set)›*)
hence "[a;x;c]"
using inseg_axc (*‹⟦(?P::'a set) ∈ (𝒫::'a set set); finite (?Q::'a set); card ?Q = (?N::nat); ?Q ⊆ ?P; (3::nat) ≤ ?N; (?a::'a) ∈ ?Q ∧ (?b::'a) ∈ ?Q ∧ (?c::'a) ∈ ?Q; [?f::nat ⇒ 'a↝?Q|?a..?b..?c]; (?S::'a set set) = {s::'a set. ∃i<?N - (1::nat). s = segment (?f i) (?f (i + (1::nat)))}; (?x::'a) ∈ (?s::'a set); ?s ∈ ?S⟧ ⟹ [?a;?x;?c]›*) ‹s ∈ S› (*‹s ∈ S›*) assms (*‹P ∈ 𝒫› ‹finite Q› ‹card Q = N› ‹Q ⊆ P› ‹3 ≤ N› ‹a ∈ Q ∧ b ∈ Q ∧ c ∈ Q› ‹[f↝Q|a..b..c]› ‹S = {s. ∃i<N - 1. s = segment (f i) (f (i + 1))}› ‹P1 = prolongation b a› ‹P2 = prolongation b c›*) by blast
thus "x∈{}"
by (metis P2_def (*‹P2 = prolongation b c›*) ‹x ∈ P2› abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) 2) f_def( (*‹[f↝Q|a..b..c]›*) 2) fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*) pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*))
qed
fix r
assume "r∈S" "s≠r" (*‹(r::'a set) ∈ (S::'a set set)› ‹(s::'a set) ≠ (r::'a set)›*)
show "s∩r={}"
proof (safe)
(*goal: ‹⋀x. ⟦x ∈ s; x ∈ r⟧ ⟹ x ∈ {}›*)
fix y
assume "y ∈ r" "y ∈ s" (*‹(y::'a) ∈ (r::'a set)› ‹(y::'a) ∈ (s::'a set)›*)
obtain n and m where rs_def: "r = segment (f n) (f(n+1))" "s = segment (f m) (f(m+1))" "n≠m" "n<N-1" "m<N-1"
(*goal: ‹(⋀n m. ⟦r = segment (f n) (f (n + 1)); s = segment (f m) (f (m + 1)); n ≠ m; n < N - 1; m < N - 1⟧ ⟹ thesis) ⟹ thesis›*)
using S_def (*‹S = {s. ∃i<N - 1. s = segment (f i) (f (i + 1))}›*) ‹r ∈ S› (*‹r ∈ S›*) ‹s ≠ r› (*‹s ≠ r›*) ‹s ∈ S› (*‹s ∈ S›*) by blast
have y_betw: "[f n; y; (f(n+1))] ∧ [f m; y; (f(m+1))]"
using seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) ‹y∈r› (*‹y ∈ r›*) ‹y∈s› (*‹y ∈ s›*) rs_def(1,2) (*‹(r::'a::type set) = segment ((f::nat ⇒ 'a::type) (n::nat)) (f (n + (1::nat)))› ‹s = segment (f m) (f (m + 1))›*) by simp
have False
proof (cases)
(*goals:
1. ‹?P ⟹ False›
2. ‹¬ ?P ⟹ False›*)
assume "n<m" (*‹(n::nat) < (m::nat)›*)
have "[f n; f m; (f(m+1))]"
using ‹n < m› (*‹n < m›*) assms(3) (*‹card (Q::'a set) = (N::nat)›*) fQ (*‹local_long_ch_by_ord (f::nat ⇒ 'a) (Q::'a set)›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a::type) (?X::'a::type set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a .. ?y::'a] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) order_finite_chain (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X; 0 ≤ ?i ∧ ?i < ?j ∧ ?j < ?l ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) rs_def(5) (*‹m < N - 1›*) by (metis assms( (*‹finite Q›*) 2) thm2_ind1 (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X⟧ ⟹ ∀j i. i < j ∧ j < card ?X - 1 ⟶ [?f i;?f j;?f (j + 1)]›*))
have "n+1<m"
using ‹[f n; f m; f(m + 1)]› (*‹[f n;f m;f (m + 1)]›*) ‹n < m› (*‹n < m›*) abc_only_cba(2) (*‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) y_betw (*‹[f n;y;f (n + 1)] ∧ [f m;y;f (m + 1)]›*) by (metis Suc_eq_plus1 (*‹Suc ?n = ?n + 1›*) Suc_leI (*‹?m < ?n ⟹ Suc ?m ≤ ?n›*) le_eq_less_or_eq (*‹(?m ≤ ?n) = (?m < ?n ∨ ?m = ?n)›*))
hence "[f n; (f(n+1)); f m]"
using fQ (*‹local_long_ch_by_ord f Q›*) assms(3) (*‹card Q = N›*) rs_def(5) (*‹m < N - 1›*) unfolding chain_defs local_ordering_def
(*goal: ‹[f n;f (n + 1);f m]›*)
by (metis (full_types) ‹[f n;f m;f (m + 1)]› abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]›*) 1) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) assms( (*‹finite Q›*) 2) fQ (*‹local_long_ch_by_ord f Q›*) thm2_ind1 (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X⟧ ⟹ ∀j i. i < j ∧ j < card ?X - 1 ⟶ [?f i;?f j;?f (j + 1)]›*) y_betw (*‹[f n;y;f (n + 1)] ∧ [f m;y;f (m + 1)]›*))
hence "[f n; (f(n+1)); y]"
using ‹[f n; f m; f(m + 1)]› (*‹[f n;f m;f (m + 1)]›*) abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) y_betw (*‹[f n;y;f (n + 1)] ∧ [f m;y;f (m + 1)]›*) by blast
thus "?thesis"
(*goal: ‹False›*)
using abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) y_betw (*‹[f n;y;f (n + 1)] ∧ [f m;y;f (m + 1)]›*) by blast
next
(*goal: ‹¬ (n::nat) < (m::nat) ⟹ False›*)
assume "¬n<m" (*‹¬ (n::nat) < (m::nat)›*)
hence "n>m"
using nat_neq_iff (*‹(?m ≠ ?n) = (?m < ?n ∨ ?n < ?m)›*) rs_def(3) (*‹n ≠ m›*) by blast
have "[f m; f n; (f(n+1))]"
using ‹n > m› (*‹(m::nat) < (n::nat)›*) assms(3) (*‹card Q = N›*) fQ (*‹local_long_ch_by_ord (f::nat ⇒ 'a) (Q::'a set)›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a::type set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a::type. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) rs_def(4) (*‹n < N - 1›*) by (metis assms( (*‹finite Q›*) 2) thm2_ind1 (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X⟧ ⟹ ∀j i. i < j ∧ j < card ?X - 1 ⟶ [?f i;?f j;?f (j + 1)]›*))
hence "m+1<n"
using ‹n > m› (*‹m < n›*) abc_only_cba(2) (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ¬ [?a;?c;?b]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) y_betw (*‹[f n;y;f (n + 1)] ∧ [f m;y;f (m + 1)]›*) by (metis Suc_eq_plus1 (*‹Suc ?n = ?n + 1›*) Suc_leI (*‹?m < ?n ⟹ Suc ?m ≤ ?n›*) le_eq_less_or_eq (*‹(?m ≤ ?n) = (?m < ?n ∨ ?m = ?n)›*))
hence "[f m; (f(m+1)); f n]"
using fQ (*‹local_long_ch_by_ord f Q›*) assms(2,3) (*‹finite Q› ‹card Q = N›*) rs_def(4) (*‹n < N - 1›*) unfolding chain_defs local_ordering_def
(*goal: ‹[f m;f (m + 1);f n]›*)
by (metis (no_types, lifting) ‹[f m;f n;f (n + 1)]› abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]›*) 1) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) fQ (*‹local_long_ch_by_ord f Q›*) thm2_ind1 (*‹⟦local_long_ch_by_ord ?f ?X; finite ?X⟧ ⟹ ∀j i. i < j ∧ j < card ?X - 1 ⟶ [?f i;?f j;?f (j + 1)]›*) y_betw (*‹[f n;y;f (n + 1)] ∧ [f m;y;f (m + 1)]›*))
hence "[f m; (f(m+1)); y]"
using ‹[f m; f n; f(n + 1)]› (*‹[(f::nat ⇒ 'a::type) (m::nat);f (n::nat);f (n + (1::nat))]›*) abc_acd_abd (*‹⟦[?a::'a;?b::'a;?c::'a]; [?a;?c;?d::'a]⟧ ⟹ [?a;?b;?d]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) y_betw (*‹[f n;y;f (n + 1)] ∧ [f m;y;f (m + 1)]›*) by blast
thus "?thesis"
(*goal: ‹False›*)
using abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) y_betw (*‹[(f::nat ⇒ 'a) (n::nat);y::'a;f (n + (1::nat))] ∧ [f (m::nat);y;f (m + (1::nat))]›*) by blast
qed
thus "y∈{}"
by blast
qed
qed
qed
qed
lemma (*for 11*) segmentation_ex_Nge3:
assumes path_P: "P∈𝒫"
and Q_def: "finite (Q::'a set)" "card Q = N" "Q⊆P" "N≥3"
and f_def: "a∈Q ∧ b∈Q ∧ c∈Q" "[f↝Q|a..b..c]"
and S_def: "S = {s. ∃i<(N-1). s = segment (f i) (f (i+1))}"
and P1_def: "P1 = prolongation b a"
and P2_def: "P2 = prolongation b c"
shows "P = ((⋃S) ∪ P1 ∪ P2 ∪ Q) ∧
(∀x∈S. is_segment x) ∧
P1∩P2={} ∧ (∀x∈S. (x∩P1={} ∧ x∩P2={} ∧ (∀y∈S. x≠y ⟶ x∩y={})))"
proof (intro disjoint_segmentation (*‹⟦?P ∈ 𝒫; finite ?Q; card ?Q = ?N; ?Q ⊆ ?P; 3 ≤ ?N; ?a ∈ ?Q ∧ ?b ∈ ?Q ∧ ?c ∈ ?Q; [?f↝?Q|?a..?b..?c]; ?S = {s. ∃i<?N - 1. s = segment (?f i) (?f (i + 1))}; ?P1.0 = prolongation ?b ?a; ?P2.0 = prolongation ?b ?c⟧ ⟹ ?P1.0 ∩ ?P2.0 = {} ∧ (∀x∈?S. x ∩ ?P1.0 = {} ∧ x ∩ ?P2.0 = {} ∧ (∀y∈?S. x ≠ y ⟶ x ∩ y = {}))›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹P = ⋃ S ∪ P1 ∪ P2 ∪ Q›
2. ‹∀x∈S. is_segment x›
3. ‹?P2 ∈ 𝒫›
4. ‹finite ?Q2›
5. ‹card ?Q2 = ?N2›
6. ‹?Q2 ⊆ ?P2›
7. ‹3 ≤ ?N2›
8. ‹?a2 ∈ ?Q2›
9. ‹?b2 ∈ ?Q2›
10. ‹?c2 ∈ ?Q2›
11. ‹[?f2↝?Q2|?a2..?b2..?c2]›
12. ‹S = {s. ∃i<?N2 - 1. s = segment (?f2 i) (?f2 (i + 1))}›
13. ‹P1 = prolongation ?b2 ?a2›
14. ‹P2 = prolongation ?b2 ?c2›*)
show "P = ((⋃S) ∪ P1 ∪ P2 ∪ Q)"
using path_is_union (*‹⟦?P ∈ 𝒫; finite ?Q; card ?Q = ?N; ?Q ⊆ ?P; 3 ≤ ?N; ?a ∈ ?Q ∧ ?b ∈ ?Q ∧ ?c ∈ ?Q; [?f↝?Q|?a..?b..?c]; ?S = {s. ∃i<?N - 1. s = segment (?f i) (?f (i + 1))}; ?P1.0 = prolongation ?b ?a; ?P2.0 = prolongation ?b ?c⟧ ⟹ ?P = ⋃ ?S ∪ ?P1.0 ∪ ?P2.0 ∪ ?Q›*) assms (*‹P ∈ 𝒫› ‹finite Q› ‹card Q = N› ‹(Q::'a set) ⊆ (P::'a set)› ‹3 ≤ N› ‹a ∈ Q ∧ b ∈ Q ∧ c ∈ Q› ‹[f↝Q|a..b..c]› ‹S = {s. ∃i<N - 1. s = segment (f i) (f (i + 1))}› ‹P1 = prolongation b a› ‹P2 = prolongation b c›*) by blast
show "∀x∈S. is_segment x"
proof (standard)
(*goal: ‹⋀x. x ∈ S ⟹ is_segment x›*)
fix s
assume "s∈S" (*‹(s::'a set) ∈ (S::'a set set)›*)
thus "is_segment s"
using S_def (*‹S = {s. ∃i<N - 1. s = segment (f i) (f (i + 1))}›*) by auto
qed
qed (use assms disjoint_segmentation in auto)
(*solves the remaining goals:
1. ‹?P2 ∈ 𝒫›
2. ‹finite ?Q2›
3. ‹card ?Q2 = ?N2›
4. ‹?Q2 ⊆ ?P2›
5. ‹3 ≤ ?N2›
6. ‹?a2 ∈ ?Q2›
7. ‹?b2 ∈ ?Q2›
8. ‹?c2 ∈ ?Q2›
9. ‹[?f2↝?Q2|?a2..?b2..?c2]›
10. ‹S = {s. ∃i<?N2 - 1. s = segment (?f2 i) (?f2 (i + 1))}›
11. ‹P1 = prolongation ?b2 ?a2›
12. ‹P2 = prolongation ?b2 ?c2›*)
text ‹Some unfolding of the definition for a finite chain that happens to be short.›
lemma finite_chain_with_card_2:
assumes f_def: "[f↝Q|a..b]"
and card_Q: "card Q = 2"
shows "finite Q" "f 0 = a" "f (card Q - 1) = b" "Q = {f 0, f 1}" "∃Q. path Q (f 0) (f 1)"
using assms (*‹[f↝Q|a .. b]› ‹card Q = 2›*) unfolding chain_defs
(*goals:
1. ‹finite Q›
2. ‹f 0 = a›
3. ‹f (card Q - 1) = b›
4. ‹Q = {f 0, f 1}›
5. ‹∃Q. path Q (f 0) (f 1)›*)
apply -
(*goals:
1. ‹⟦(finite Q ∧ (Q = {f 0, f 1} ∧ (∃Q. path Q (f 0) (f 1)) ∨ (infinite Q ∨ 3 ≤ card Q) ∧ local_ordering f betw Q)) ∧ f 0 = a ∧ f (card Q - 1) = b; card Q = 2⟧ ⟹ finite Q›
2. ‹⟦(finite Q ∧ (Q = {f 0, f 1} ∧ (∃Q. path Q (f 0) (f 1)) ∨ (infinite Q ∨ 3 ≤ card Q) ∧ local_ordering f betw Q)) ∧ f 0 = a ∧ f (card Q - 1) = b; card Q = 2⟧ ⟹ f 0 = a›
3. ‹⟦(finite Q ∧ (Q = {f 0, f 1} ∧ (∃Q. path Q (f 0) (f 1)) ∨ (infinite Q ∨ 3 ≤ card Q) ∧ local_ordering f betw Q)) ∧ f 0 = a ∧ f (card Q - 1) = b; card Q = 2⟧ ⟹ f (card Q - 1) = b›
4. ‹⟦(finite Q ∧ (Q = {f 0, f 1} ∧ (∃Q. path Q (f 0) (f 1)) ∨ (infinite Q ∨ 3 ≤ card Q) ∧ local_ordering f betw Q)) ∧ f 0 = a ∧ f (card Q - 1) = b; card Q = 2⟧ ⟹ Q = {f 0, f 1}›
5. ‹⟦(finite Q ∧ (Q = {f 0, f 1} ∧ (∃Q. path Q (f 0) (f 1)) ∨ (infinite Q ∨ 3 ≤ card Q) ∧ local_ordering f betw Q)) ∧ f 0 = a ∧ f (card Q - 1) = b; card Q = 2⟧ ⟹ ∃Q. path Q (f 0) (f 1)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .
text ‹
Schutz says "As in the proof of the previous theorem [...]" - does he mean to imply that this
should really be proved as induction? I can see that quite easily, induct on $N$, and add a segment
by either splitting up a segment or taking a piece out of a prolongation.
But I think that might be too much trouble.
›
theorem (*11*) show_segmentation:
assumes path_P: "P∈𝒫"
and Q_def: "Q⊆P"
and f_def: "[f↝Q|a..b]"
fixes P1 defines P1_def: "P1 ≡ prolongation b a"
fixes P2 defines P2_def: "P2 ≡ prolongation a b"
fixes S defines S_def: "S ≡ {segment (f i) (f (i+1)) | i. i<card Q-1}"
shows "P = ((⋃S) ∪ P1 ∪ P2 ∪ Q)" "(∀x∈S. is_segment x)"
"disjoint (S∪{P1,P2})" "P1≠P2" "P1∉S" "P2∉S"
proof (-)
(*goals:
1. ‹P = ⋃ S ∪ P1 ∪ P2 ∪ Q›
2. ‹∀x∈S. is_segment x›
3. ‹disjoint (S ∪ {P1, P2})›
4. ‹P1 ≠ P2›
5. ‹P1 ∉ S›
6. ‹P2 ∉ S›*)
have card_Q: "card Q ≥ 2"
using fin_chain_card_geq_2 (*‹[?f::nat ⇒ 'a↝?X::'a set|?a::'a .. ?b::'a] ⟹ (2::nat) ≤ card ?X›*) f_def (*‹[f↝Q|a .. b]›*) by blast
have "finite Q"
by (metis card.infinite (*‹infinite ?A ⟹ card ?A = 0›*) card_Q (*‹2 ≤ card Q›*) rel_simps( (*‹¬ numeral ?n ≤ 0›*) 28))
have f_def_2: "a∈Q ∧ b∈Q"
using f_def (*‹[f↝Q|a .. b]›*) points_in_chain (*‹[?f↝?Q|?x .. ?z] ⟹ ?x ∈ ?Q ∧ ?z ∈ ?Q›*) finite_chain_with_def (*‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type .. ?y::'a::type] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y›*) by auto
have "a≠b"
using f_def (*‹[f↝Q|a .. b]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a .. ?y::'a] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis first_neq_last (*‹[?f↝?Q|?x .. ?z] ⟹ ?x ≠ ?z›*))
{
assume "card Q = 2" (*‹card (Q::'a set) = (2::nat)›*)
hence "card Q - 1 = Suc 0"
by simp
have "Q = {f 0, f 1}" "∃Q. path Q (f 0) (f 1)" "f 0 = a" "f (card Q - 1) = b"
using ‹card Q = 2› (*‹card Q = 2›*) finite_chain_with_card_2 (*‹⟦[?f↝?Q|?a .. ?b]; card ?Q = 2⟧ ⟹ finite ?Q› ‹⟦[?f↝?Q|?a .. ?b]; card ?Q = 2⟧ ⟹ ?f 0 = ?a› ‹⟦[?f↝?Q|?a .. ?b]; card ?Q = 2⟧ ⟹ ?f (card ?Q - 1) = ?b› ‹⟦[?f↝?Q|?a .. ?b]; card ?Q = 2⟧ ⟹ ?Q = {?f 0, ?f 1}› ‹⟦[?f::nat ⇒ 'a::type↝?Q::'a::type set|?a::'a::type .. ?b::'a::type]; card ?Q = (2::nat)⟧ ⟹ ∃Q::'a::type set. path Q (?f (0::nat)) (?f (1::nat))›*) f_def (*‹[f↝Q|a .. b]›*) apply -
(*goals:
1. ‹⟦card Q = 2; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ finite Q; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ f 0 = a; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ f (card Q - 1) = b; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ Q = {f 0, f 1}; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ ∃Q. path Q (f 0) (f 1); [f↝Q|a .. b]⟧ ⟹ Q = {f 0, f 1}›
2. ‹⟦card Q = 2; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ finite Q; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ f 0 = a; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ f (card Q - 1) = b; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ Q = {f 0, f 1}; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ ∃Q. path Q (f 0) (f 1); [f↝Q|a .. b]⟧ ⟹ ∃Q. path Q (f 0) (f 1)›
3. ‹⟦card Q = 2; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ finite Q; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ f 0 = a; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ f (card Q - 1) = b; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ Q = {f 0, f 1}; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ ∃Q. path Q (f 0) (f 1); [f↝Q|a .. b]⟧ ⟹ f 0 = a›
4. ‹⟦card Q = 2; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ finite Q; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ f 0 = a; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ f (card Q - 1) = b; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ Q = {f 0, f 1}; ⋀f Q a b. ⟦[f↝Q|a .. b]; card Q = 2⟧ ⟹ ∃Q. path Q (f 0) (f 1); [f↝Q|a .. b]⟧ ⟹ f (card Q - 1) = b›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*proven 4 subgoals*) .
hence "S={segment a b}"
unfolding S_def
(*goal: ‹{segment (f i) (f (i + 1)) |i. i < card Q - 1} = {segment a b}›*)
using ‹card Q - 1 = Suc 0› (*‹card Q - 1 = Suc 0›*) by (simp add: eval_nat_numeral (*‹Numeral1 = Suc 0› ‹numeral (num.Bit0 ?n) = Suc (numeral (Num.BitM ?n))› ‹numeral (num.Bit1 ?n) = Suc (numeral (num.Bit0 ?n))›*))
hence "P = ((⋃S) ∪ P1 ∪ P2 ∪ Q)" "(∀x∈S. is_segment x)" "P1∩P2={}" "(∀x∈S. (x∩P1={} ∧ x∩P2={} ∧ (∀y∈S. x≠y ⟶ x∩y={})))"
using assms (*‹P ∈ 𝒫› ‹Q ⊆ P› ‹[f↝Q|a .. b]› ‹P1::'a set ≡ prolongation (b::'a) (a::'a)› ‹P2 ≡ prolongation a b› ‹S::'a set set ≡ {segment ((f::nat ⇒ 'a) i) (f (i + (1::nat))) |i::nat. i < card (Q::'a set) - (1::nat)}›*) f_def (*‹[f↝Q|a .. b]›*) ‹finite Q› (*‹finite Q›*) segmentation_ex_N2[where P = P and Q = Q and N = "card Q"] (*‹⟦P ∈ 𝒫; finite Q; card Q = card Q; Q ⊆ P; card Q = 2; [?f↝Q|?a .. ?b]; ?S = {segment ?a ?b}; ?P1.0 = prolongation ?b ?a; ?P2.0 = prolongation ?a ?b⟧ ⟹ P = ⋃ ?S ∪ ?P1.0 ∪ ?P2.0 ∪ Q ∧ card ?S = card Q - 1 ∧ (∀x∈?S. is_segment x) ∧ ?P1.0 ∩ ?P2.0 = {} ∧ (∀x∈?S. x ∩ ?P1.0 = {} ∧ x ∩ ?P2.0 = {} ∧ (∀y∈?S. x ≠ y ⟶ x ∩ y = {}))›*) apply -
(*goals:
1. ‹⟦(S::'a set set) = {segment (a::'a) (b::'a)}; (P::'a set) ∈ (𝒫::'a set set); (Q::'a set) ⊆ P; [f::nat ⇒ 'a↝Q|a .. b]; P1::'a set ≡ prolongation b a; P2::'a set ≡ prolongation a b; S ≡ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}; [f↝Q|a .. b]; finite Q; ⋀(f::nat ⇒ 'a) (a::'a) (b::'a) (S::'a set set) (P1::'a set) P2::'a set. ⟦P ∈ 𝒫; finite Q; card Q = card Q; Q ⊆ P; card Q = (2::nat); [f↝Q|a .. b]; S = {segment a b}; P1 = prolongation b a; P2 = prolongation a b⟧ ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q ∧ card S = card Q - (1::nat) ∧ (∀x::'a set∈S. is_segment x) ∧ P1 ∩ P2 = {} ∧ (∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {}))⟧ ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q›
2. ‹⟦(S::'a set set) = {segment (a::'a) (b::'a)}; (P::'a set) ∈ (𝒫::'a set set); (Q::'a set) ⊆ P; [f::nat ⇒ 'a↝Q|a .. b]; P1::'a set ≡ prolongation b a; P2::'a set ≡ prolongation a b; S ≡ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}; [f↝Q|a .. b]; finite Q; ⋀(f::nat ⇒ 'a) (a::'a) (b::'a) (S::'a set set) (P1::'a set) P2::'a set. ⟦P ∈ 𝒫; finite Q; card Q = card Q; Q ⊆ P; card Q = (2::nat); [f↝Q|a .. b]; S = {segment a b}; P1 = prolongation b a; P2 = prolongation a b⟧ ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q ∧ card S = card Q - (1::nat) ∧ (∀x::'a set∈S. is_segment x) ∧ P1 ∩ P2 = {} ∧ (∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {}))⟧ ⟹ ∀x::'a set∈S. is_segment x›
3. ‹⟦(S::'a set set) = {segment (a::'a) (b::'a)}; (P::'a set) ∈ (𝒫::'a set set); (Q::'a set) ⊆ P; [f::nat ⇒ 'a↝Q|a .. b]; P1::'a set ≡ prolongation b a; P2::'a set ≡ prolongation a b; S ≡ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}; [f↝Q|a .. b]; finite Q; ⋀(f::nat ⇒ 'a) (a::'a) (b::'a) (S::'a set set) (P1::'a set) P2::'a set. ⟦P ∈ 𝒫; finite Q; card Q = card Q; Q ⊆ P; card Q = (2::nat); [f↝Q|a .. b]; S = {segment a b}; P1 = prolongation b a; P2 = prolongation a b⟧ ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q ∧ card S = card Q - (1::nat) ∧ (∀x::'a set∈S. is_segment x) ∧ P1 ∩ P2 = {} ∧ (∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {}))⟧ ⟹ P1 ∩ P2 = {}›
4. ‹⟦(S::'a set set) = {segment (a::'a) (b::'a)}; (P::'a set) ∈ (𝒫::'a set set); (Q::'a set) ⊆ P; [f::nat ⇒ 'a↝Q|a .. b]; P1::'a set ≡ prolongation b a; P2::'a set ≡ prolongation a b; S ≡ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}; [f↝Q|a .. b]; finite Q; ⋀(f::nat ⇒ 'a) (a::'a) (b::'a) (S::'a set set) (P1::'a set) P2::'a set. ⟦P ∈ 𝒫; finite Q; card Q = card Q; Q ⊆ P; card Q = (2::nat); [f↝Q|a .. b]; S = {segment a b}; P1 = prolongation b a; P2 = prolongation a b⟧ ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q ∧ card S = card Q - (1::nat) ∧ (∀x::'a set∈S. is_segment x) ∧ P1 ∩ P2 = {} ∧ (∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {}))⟧ ⟹ ∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {})›
discuss goal 1*)
apply (metis (no_types, lifting) ‹card Q = 2›)
(*discuss goal 2*)
apply (metis (no_types, lifting) ‹card Q = 2›)
(*discuss goal 3*)
apply (metis (no_types, lifting) ‹card Q = 2›)
(*discuss goal 4*)
apply (metis (no_types, lifting) ‹card Q = 2›)
(*proven 4 subgoals*) .
}
moreover {
assume "card Q ≠ 2" (*‹card (Q::'a set) ≠ (2::nat)›*)
hence "card Q ≥ 3"
using card_Q (*‹2 ≤ card Q›*) by auto
then obtain c where c_def: "[f↝Q|a..c..b]"
(*goal: ‹(⋀c. [f↝Q|a..c..b] ⟹ thesis) ⟹ thesis›*)
using assms(3,5) (*‹[f↝Q|a .. b]› ‹P2 ≡ prolongation a b›*) ‹a≠b› (*‹(a::'a) ≠ (b::'a)›*) chain_defs (*‹short_ch (?X::'a set) ≡ card ?X = (2::nat) ∧ (∃P::'a set∈𝒫::'a set set. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis f_def (*‹[f::nat ⇒ 'a↝Q::'a set|a::'a .. b::'a]›*) three_in_set3 (*‹⟦(3::nat) ≤ card (?X::?'a set); ⋀(x::?'a) (y::?'a) z::?'a. ⟦x ∈ ?X; y ∈ ?X; z ∈ ?X; x ≠ y; x ≠ z; y ≠ z⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*))
have pro_equiv: "P1 = prolongation c a ∧ P2 = prolongation c b"
using pro_basis_change (*‹[?a;?b;?c] ⟹ prolongation ?a ?c = prolongation ?b ?c›*) using P1_def (*‹P1 ≡ prolongation b a›*) P2_def (*‹P2 ≡ prolongation a b›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) c_def (*‹[f↝Q|a..c..b]›*) fin_ch_betw (*‹[?f↝?X|?a..?b..?c] ⟹ [?a;?b;?c]›*) by auto
have S_def2: "S = {s. ∃i<(card Q-1). s = segment (f i) (f (i+1))}"
using S_def (*‹S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}›*) ‹card Q ≥ 3› (*‹(3::nat) ≤ card (Q::'a set)›*) by auto
have "P = ((⋃S) ∪ P1 ∪ P2 ∪ Q)" "(∀x∈S. is_segment x)" "P1∩P2={}" "(∀x∈S. (x∩P1={} ∧ x∩P2={} ∧ (∀y∈S. x≠y ⟶ x∩y={})))"
using f_def_2 (*‹a ∈ Q ∧ b ∈ Q›*) assms (*‹P ∈ 𝒫› ‹Q ⊆ P› ‹[f↝Q|a .. b]› ‹P1 ≡ prolongation b a› ‹P2::'a set ≡ prolongation (a::'a) (b::'a)› ‹S::'a set set ≡ {segment ((f::nat ⇒ 'a) i) (f (i + (1::nat))) |i::nat. i < card (Q::'a set) - (1::nat)}›*) f_def (*‹[f↝Q|a .. b]›*) ‹card Q ≥ 3› (*‹3 ≤ card Q›*) c_def (*‹[f::nat ⇒ 'a↝Q::'a set|a::'a..c::'a..b::'a]›*) pro_equiv (*‹P1 = prolongation c a ∧ P2 = prolongation c b›*) segmentation_ex_Nge3[where P = P and Q = Q and N = "card Q" and S = S and a = a and b = c and c = b and f = f] (*‹⟦P ∈ 𝒫; finite Q; card Q = card Q; Q ⊆ P; 3 ≤ card Q; a ∈ Q ∧ c ∈ Q ∧ b ∈ Q; [f↝Q|a..c..b]; S = {s. ∃i<card Q - 1. s = segment (f i) (f (i + 1))}; ?P1.0 = prolongation c a; ?P2.0 = prolongation c b⟧ ⟹ P = ⋃ S ∪ ?P1.0 ∪ ?P2.0 ∪ Q ∧ (∀x∈S. is_segment x) ∧ ?P1.0 ∩ ?P2.0 = {} ∧ (∀x∈S. x ∩ ?P1.0 = {} ∧ x ∩ ?P2.0 = {} ∧ (∀y∈S. x ≠ y ⟶ x ∩ y = {}))›*) using points_in_long_chain (*‹[?f↝?Q|?x..?y..?z] ⟹ ?x ∈ ?Q› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type..?y::'a::type..?z::'a::type] ⟹ ?y ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?z ∈ ?Q›*) ‹finite Q› (*‹finite Q›*) S_def2 (*‹S = {s. ∃i<card Q - 1. s = segment (f i) (f (i + 1))}›*) apply -
(*goals:
1. ‹⟦(a::'a) ∈ (Q::'a set) ∧ (b::'a) ∈ Q; (P::'a set) ∈ (𝒫::'a set set); Q ⊆ P; [f::nat ⇒ 'a↝Q|a .. b]; P1::'a set ≡ prolongation b a; P2::'a set ≡ prolongation a b; S::'a set set ≡ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}; [f↝Q|a .. b]; (3::nat) ≤ card Q; [f↝Q|a..c::'a..b]; P1 = prolongation c a ∧ P2 = prolongation c b; ⋀(P1::'a set) P2::'a set. ⟦P ∈ 𝒫; finite Q; card Q = card Q; Q ⊆ P; (3::nat) ≤ card Q; a ∈ Q ∧ c ∈ Q ∧ b ∈ Q; [f↝Q|a..c..b]; S = {s::'a set. ∃i<card Q - (1::nat). s = segment (f i) (f (i + (1::nat)))}; P1 = prolongation c a; P2 = prolongation c b⟧ ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q ∧ (∀x::'a set∈S. is_segment x) ∧ P1 ∩ P2 = {} ∧ (∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {})); ⋀(f::nat ⇒ 'a) (Q::'a set) (x::'a) (y::'a) z::'a. [f↝Q|x..y..z] ⟹ x ∈ Q; ⋀(f::nat ⇒ 'a) (Q::'a set) (x::'a) (y::'a) z::'a. [f↝Q|x..y..z] ⟹ y ∈ Q; ⋀(f::nat ⇒ 'a) (Q::'a set) (x::'a) (y::'a) z::'a. [f↝Q|x..y..z] ⟹ z ∈ Q; finite Q; S = {s::'a set. ∃i<card Q - (1::nat). s = segment (f i) (f (i + (1::nat)))}⟧ ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q›
2. ‹⟦(a::'a) ∈ (Q::'a set) ∧ (b::'a) ∈ Q; (P::'a set) ∈ (𝒫::'a set set); Q ⊆ P; [f::nat ⇒ 'a↝Q|a .. b]; P1::'a set ≡ prolongation b a; P2::'a set ≡ prolongation a b; S::'a set set ≡ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}; [f↝Q|a .. b]; (3::nat) ≤ card Q; [f↝Q|a..c::'a..b]; P1 = prolongation c a ∧ P2 = prolongation c b; ⋀(P1::'a set) P2::'a set. ⟦P ∈ 𝒫; finite Q; card Q = card Q; Q ⊆ P; (3::nat) ≤ card Q; a ∈ Q ∧ c ∈ Q ∧ b ∈ Q; [f↝Q|a..c..b]; S = {s::'a set. ∃i<card Q - (1::nat). s = segment (f i) (f (i + (1::nat)))}; P1 = prolongation c a; P2 = prolongation c b⟧ ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q ∧ (∀x::'a set∈S. is_segment x) ∧ P1 ∩ P2 = {} ∧ (∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {})); ⋀(f::nat ⇒ 'a) (Q::'a set) (x::'a) (y::'a) z::'a. [f↝Q|x..y..z] ⟹ x ∈ Q; ⋀(f::nat ⇒ 'a) (Q::'a set) (x::'a) (y::'a) z::'a. [f↝Q|x..y..z] ⟹ y ∈ Q; ⋀(f::nat ⇒ 'a) (Q::'a set) (x::'a) (y::'a) z::'a. [f↝Q|x..y..z] ⟹ z ∈ Q; finite Q; S = {s::'a set. ∃i<card Q - (1::nat). s = segment (f i) (f (i + (1::nat)))}⟧ ⟹ ∀x::'a set∈S. is_segment x›
3. ‹⟦(a::'a) ∈ (Q::'a set) ∧ (b::'a) ∈ Q; (P::'a set) ∈ (𝒫::'a set set); Q ⊆ P; [f::nat ⇒ 'a↝Q|a .. b]; P1::'a set ≡ prolongation b a; P2::'a set ≡ prolongation a b; S::'a set set ≡ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}; [f↝Q|a .. b]; (3::nat) ≤ card Q; [f↝Q|a..c::'a..b]; P1 = prolongation c a ∧ P2 = prolongation c b; ⋀(P1::'a set) P2::'a set. ⟦P ∈ 𝒫; finite Q; card Q = card Q; Q ⊆ P; (3::nat) ≤ card Q; a ∈ Q ∧ c ∈ Q ∧ b ∈ Q; [f↝Q|a..c..b]; S = {s::'a set. ∃i<card Q - (1::nat). s = segment (f i) (f (i + (1::nat)))}; P1 = prolongation c a; P2 = prolongation c b⟧ ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q ∧ (∀x::'a set∈S. is_segment x) ∧ P1 ∩ P2 = {} ∧ (∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {})); ⋀(f::nat ⇒ 'a) (Q::'a set) (x::'a) (y::'a) z::'a. [f↝Q|x..y..z] ⟹ x ∈ Q; ⋀(f::nat ⇒ 'a) (Q::'a set) (x::'a) (y::'a) z::'a. [f↝Q|x..y..z] ⟹ y ∈ Q; ⋀(f::nat ⇒ 'a) (Q::'a set) (x::'a) (y::'a) z::'a. [f↝Q|x..y..z] ⟹ z ∈ Q; finite Q; S = {s::'a set. ∃i<card Q - (1::nat). s = segment (f i) (f (i + (1::nat)))}⟧ ⟹ P1 ∩ P2 = {}›
4. ‹⟦(a::'a) ∈ (Q::'a set) ∧ (b::'a) ∈ Q; (P::'a set) ∈ (𝒫::'a set set); Q ⊆ P; [f::nat ⇒ 'a↝Q|a .. b]; P1::'a set ≡ prolongation b a; P2::'a set ≡ prolongation a b; S::'a set set ≡ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}; [f↝Q|a .. b]; (3::nat) ≤ card Q; [f↝Q|a..c::'a..b]; P1 = prolongation c a ∧ P2 = prolongation c b; ⋀(P1::'a set) P2::'a set. ⟦P ∈ 𝒫; finite Q; card Q = card Q; Q ⊆ P; (3::nat) ≤ card Q; a ∈ Q ∧ c ∈ Q ∧ b ∈ Q; [f↝Q|a..c..b]; S = {s::'a set. ∃i<card Q - (1::nat). s = segment (f i) (f (i + (1::nat)))}; P1 = prolongation c a; P2 = prolongation c b⟧ ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q ∧ (∀x::'a set∈S. is_segment x) ∧ P1 ∩ P2 = {} ∧ (∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {})); ⋀(f::nat ⇒ 'a) (Q::'a set) (x::'a) (y::'a) z::'a. [f↝Q|x..y..z] ⟹ x ∈ Q; ⋀(f::nat ⇒ 'a) (Q::'a set) (x::'a) (y::'a) z::'a. [f↝Q|x..y..z] ⟹ y ∈ Q; ⋀(f::nat ⇒ 'a) (Q::'a set) (x::'a) (y::'a) z::'a. [f↝Q|x..y..z] ⟹ z ∈ Q; finite Q; S = {s::'a set. ∃i<card Q - (1::nat). s = segment (f i) (f (i + (1::nat)))}⟧ ⟹ ∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {})›
discuss goal 1*)
apply metis
(*discuss goal 2*)
apply metis
(*discuss goal 3*)
apply metis
(*discuss goal 4*)
apply metis
(*proven 4 subgoals*) .
}
ultimately have old_thesis: "P = ((⋃S) ∪ P1 ∪ P2 ∪ Q)" "(∀x∈S. is_segment x)" "P1∩P2={}" "(∀x∈S. (x∩P1={} ∧ x∩P2={} ∧ (∀y∈S. x≠y ⟶ x∩y={})))"
apply -
(*goals:
1. ‹⟦card (Q::'a set) = (2::nat) ⟹ (P::'a set) = ⋃ (S::'a set set) ∪ (P1::'a set) ∪ (P2::'a set) ∪ Q; card Q = (2::nat) ⟹ ∀x::'a set∈S. is_segment x; card Q = (2::nat) ⟹ P1 ∩ P2 = {}; card Q = (2::nat) ⟹ ∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {}); card Q ≠ (2::nat) ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q; card Q ≠ (2::nat) ⟹ ∀x::'a set∈S. is_segment x; card Q ≠ (2::nat) ⟹ P1 ∩ P2 = {}; card Q ≠ (2::nat) ⟹ ∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {})⟧ ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q›
2. ‹⟦card (Q::'a set) = (2::nat) ⟹ (P::'a set) = ⋃ (S::'a set set) ∪ (P1::'a set) ∪ (P2::'a set) ∪ Q; card Q = (2::nat) ⟹ ∀x::'a set∈S. is_segment x; card Q = (2::nat) ⟹ P1 ∩ P2 = {}; card Q = (2::nat) ⟹ ∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {}); card Q ≠ (2::nat) ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q; card Q ≠ (2::nat) ⟹ ∀x::'a set∈S. is_segment x; card Q ≠ (2::nat) ⟹ P1 ∩ P2 = {}; card Q ≠ (2::nat) ⟹ ∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {})⟧ ⟹ ∀x::'a set∈S. is_segment x›
3. ‹⟦card (Q::'a set) = (2::nat) ⟹ (P::'a set) = ⋃ (S::'a set set) ∪ (P1::'a set) ∪ (P2::'a set) ∪ Q; card Q = (2::nat) ⟹ ∀x::'a set∈S. is_segment x; card Q = (2::nat) ⟹ P1 ∩ P2 = {}; card Q = (2::nat) ⟹ ∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {}); card Q ≠ (2::nat) ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q; card Q ≠ (2::nat) ⟹ ∀x::'a set∈S. is_segment x; card Q ≠ (2::nat) ⟹ P1 ∩ P2 = {}; card Q ≠ (2::nat) ⟹ ∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {})⟧ ⟹ P1 ∩ P2 = {}›
4. ‹⟦card (Q::'a set) = (2::nat) ⟹ (P::'a set) = ⋃ (S::'a set set) ∪ (P1::'a set) ∪ (P2::'a set) ∪ Q; card Q = (2::nat) ⟹ ∀x::'a set∈S. is_segment x; card Q = (2::nat) ⟹ P1 ∩ P2 = {}; card Q = (2::nat) ⟹ ∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {}); card Q ≠ (2::nat) ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q; card Q ≠ (2::nat) ⟹ ∀x::'a set∈S. is_segment x; card Q ≠ (2::nat) ⟹ P1 ∩ P2 = {}; card Q ≠ (2::nat) ⟹ ∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {})⟧ ⟹ ∀x::'a set∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y::'a set∈S. x ≠ y ⟶ x ∩ y = {})›
discuss goal 1*)
apply meson
(*discuss goal 2*)
apply meson
(*discuss goal 3*)
apply meson
(*discuss goal 4*)
apply meson
(*proven 4 subgoals*) .
thus "disjoint (S∪{P1,P2})" "P1≠P2" "P1∉S" "P2∉S" "P = ((⋃S) ∪ P1 ∪ P2 ∪ Q)" "(∀x∈S. is_segment x)"
unfolding disjoint_def
(*goals:
1. ‹∀a::'a::type set∈(S::'a::type set set) ∪ {P1::'a::type set, P2::'a::type set}. ∀b::'a::type set∈S ∪ {P1, P2}. a ≠ b ⟶ a ∩ b = {}›
2. ‹(P1::'a::type set) ≠ (P2::'a::type set)›
3. ‹(P1::'a::type set) ∉ (S::'a::type set set)›
4. ‹(P2::'a::type set) ∉ (S::'a::type set set)›
5. ‹(P::'a::type set) = ⋃ (S::'a::type set set) ∪ (P1::'a::type set) ∪ (P2::'a::type set) ∪ (Q::'a::type set)›
6. ‹∀x::'a::type set∈S::'a::type set set. is_segment x›*)
apply (simp add: Int_commute (*‹?A ∩ ?B = ?B ∩ ?A›*))
(*top goal: ‹∀a::'a set∈(S::'a set set) ∪ {P1::'a set, P2::'a set}. ∀b::'a set∈S ∪ {P1, P2}. a ≠ b ⟶ a ∩ b = {}› and 5 goals remain*)
apply (metis P2_def (*‹P2 ≡ prolongation a b›*) Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) old_thesis( (*‹P = ⋃ S ∪ P1 ∪ P2 ∪ Q› ‹P1 ∩ P2 = {}›*) 1,3) ‹a ≠ b› disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) f_def_2 (*‹a ∈ Q ∧ b ∈ Q›*) path_P (*‹P ∈ 𝒫›*) pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*) prolong_betw2 (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ∃c∈?Q. [?a;?b;c]›*))
(*top goal: ‹P1 ≠ P2› and 4 goals remain*)
apply (metis P1_def (*‹P1 ≡ prolongation b a›*) Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) old_thesis( (*‹P = ⋃ S ∪ P1 ∪ P2 ∪ Q› ‹∀x∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y∈S. x ≠ y ⟶ x ∩ y = {})›*) 1,4) ‹a ≠ b› disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) f_def_2 (*‹a ∈ Q ∧ b ∈ Q›*) path_P (*‹P ∈ 𝒫›*) pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*) prolong_betw3 (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ∃c∈?Q. ∃d∈?Q. [?a;?b;c] ∧ [?a;?b;d] ∧ c ≠ d›*))
(*top goal: ‹P1 ∉ S› and 3 goals remain*)
apply (metis P2_def (*‹P2 ≡ prolongation a b›*) Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) old_thesis( (*‹P = ⋃ S ∪ P1 ∪ P2 ∪ Q› ‹∀x∈S. x ∩ P1 = {} ∧ x ∩ P2 = {} ∧ (∀y∈S. x ≠ y ⟶ x ∩ y = {})›*) 1,4) ‹a ≠ b› disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) f_def_2 (*‹a ∈ Q ∧ b ∈ Q›*) path_P (*‹P ∈ 𝒫›*) pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*) prolong_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ∃c∈ℰ. [?a;?b;c]›*))
(*top goal: ‹(P2::'a set) ∉ (S::'a set set)› and 2 goals remain*)
using old_thesis(1,2) (*‹P = ⋃ S ∪ P1 ∪ P2 ∪ Q› ‹∀x∈S. is_segment x›*) apply -
(*goals:
1. ‹⟦P = ⋃ S ∪ P1 ∪ P2 ∪ Q; ∀x∈S. is_segment x⟧ ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q›
2. ‹⟦P = ⋃ S ∪ P1 ∪ P2 ∪ Q; ∀x∈S. is_segment x⟧ ⟹ ∀x∈S. is_segment x›
discuss goal 1*)
apply linarith
(*discuss goal 2*)
apply linarith
(*proven 2 subgoals*) .
qed
theorem (*11*) segmentation:
assumes path_P: "P∈𝒫"
and Q_def: "card Q≥2" "Q⊆P"
shows "∃S P1 P2. P = ((⋃S) ∪ P1 ∪ P2 ∪ Q) ∧
disjoint (S∪{P1,P2}) ∧ P1≠P2 ∧ P1∉S ∧ P2∉S ∧
(∀x∈S. is_segment x) ∧ is_prolongation P1 ∧ is_prolongation P2"
proof (-)
(*goal: ‹∃S P1 P2. P = ⋃ S ∪ P1 ∪ P2 ∪ Q ∧ disjoint (S ∪ {P1, P2}) ∧ P1 ≠ P2 ∧ P1 ∉ S ∧ P2 ∉ S ∧ (∀x∈S. is_segment x) ∧ is_prolongation P1 ∧ is_prolongation P2›*)
let ?N = "card Q"
obtain f and a and b where f_def: "[f↝Q|a..b]"
(*goal: ‹(⋀f a b. [f↝Q|a .. b] ⟹ thesis) ⟹ thesis›*)
using path_finsubset_chain2[OF path_P Q_def ( 2 , 1 )] (*‹(⋀f a b. [f↝Q|a .. b] ⟹ ?thesis) ⟹ ?thesis›*) by metis
let ?S = "{segment (f i) (f (i+1)) | i. i<card Q-1}"
let ?P1 = "prolongation b a"
let ?P2 = "prolongation a b"
have from_seg: "P = ((⋃?S) ∪ ?P1 ∪ ?P2 ∪ Q)" "(∀x∈?S. is_segment x)" "disjoint (?S∪{?P1,?P2})" "?P1≠?P2" "?P1∉?S" "?P2∉?S"
using show_segmentation[OF path_P Q_def ( 2 ) ‹[f↝Q|a..b]›] (*‹P = ⋃ {segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ prolongation b a ∪ prolongation a b ∪ Q› ‹∀x∈{segment (f i) (f (i + 1)) |i. i < card Q - 1}. is_segment x› ‹disjoint ({segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ {prolongation b a, prolongation a b})› ‹prolongation b a ≠ prolongation a b› ‹prolongation (b::'a::type) (a::'a::type) ∉ {segment ((f::nat ⇒ 'a::type) i) (f (i + (1::nat))) |i::nat. i < card (Q::'a::type set) - (1::nat)}› ‹prolongation a b ∉ {segment (f i) (f (i + 1)) |i. i < card Q - 1}›*) apply -
(*goals:
1. ‹⟦(P::'a set) = ⋃ {segment ((f::nat ⇒ 'a) i) (f (i + (1::nat))) |i::nat. i < card (Q::'a set) - (1::nat)} ∪ prolongation (b::'a) (a::'a) ∪ prolongation a b ∪ Q; ∀x::'a set∈{segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}. is_segment x; disjoint ({segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)} ∪ {prolongation b a, prolongation a b}); prolongation b a ≠ prolongation a b; prolongation b a ∉ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}; prolongation a b ∉ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}⟧ ⟹ P = ⋃ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)} ∪ prolongation b a ∪ prolongation a b ∪ Q›
2. ‹⟦(P::'a set) = ⋃ {segment ((f::nat ⇒ 'a) i) (f (i + (1::nat))) |i::nat. i < card (Q::'a set) - (1::nat)} ∪ prolongation (b::'a) (a::'a) ∪ prolongation a b ∪ Q; ∀x::'a set∈{segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}. is_segment x; disjoint ({segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)} ∪ {prolongation b a, prolongation a b}); prolongation b a ≠ prolongation a b; prolongation b a ∉ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}; prolongation a b ∉ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}⟧ ⟹ ∀x::'a set∈{segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}. is_segment x›
3. ‹⟦(P::'a set) = ⋃ {segment ((f::nat ⇒ 'a) i) (f (i + (1::nat))) |i::nat. i < card (Q::'a set) - (1::nat)} ∪ prolongation (b::'a) (a::'a) ∪ prolongation a b ∪ Q; ∀x::'a set∈{segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}. is_segment x; disjoint ({segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)} ∪ {prolongation b a, prolongation a b}); prolongation b a ≠ prolongation a b; prolongation b a ∉ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}; prolongation a b ∉ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}⟧ ⟹ disjoint ({segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)} ∪ {prolongation b a, prolongation a b})›
4. ‹⟦(P::'a set) = ⋃ {segment ((f::nat ⇒ 'a) i) (f (i + (1::nat))) |i::nat. i < card (Q::'a set) - (1::nat)} ∪ prolongation (b::'a) (a::'a) ∪ prolongation a b ∪ Q; ∀x::'a set∈{segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}. is_segment x; disjoint ({segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)} ∪ {prolongation b a, prolongation a b}); prolongation b a ≠ prolongation a b; prolongation b a ∉ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}; prolongation a b ∉ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}⟧ ⟹ prolongation b a ≠ prolongation a b›
5. ‹⟦(P::'a set) = ⋃ {segment ((f::nat ⇒ 'a) i) (f (i + (1::nat))) |i::nat. i < card (Q::'a set) - (1::nat)} ∪ prolongation (b::'a) (a::'a) ∪ prolongation a b ∪ Q; ∀x::'a set∈{segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}. is_segment x; disjoint ({segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)} ∪ {prolongation b a, prolongation a b}); prolongation b a ≠ prolongation a b; prolongation b a ∉ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}; prolongation a b ∉ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}⟧ ⟹ prolongation b a ∉ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}›
6. ‹⟦(P::'a set) = ⋃ {segment ((f::nat ⇒ 'a) i) (f (i + (1::nat))) |i::nat. i < card (Q::'a set) - (1::nat)} ∪ prolongation (b::'a) (a::'a) ∪ prolongation a b ∪ Q; ∀x::'a set∈{segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}. is_segment x; disjoint ({segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)} ∪ {prolongation b a, prolongation a b}); prolongation b a ≠ prolongation a b; prolongation b a ∉ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}; prolongation a b ∉ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}⟧ ⟹ prolongation a b ∉ {segment (f i) (f (i + (1::nat))) |i::nat. i < card Q - (1::nat)}›
discuss goal 1*)
apply force
(*discuss goal 2*)
apply force
(*discuss goal 3*)
apply force
(*discuss goal 4*)
apply force
(*discuss goal 5*)
apply force
(*discuss goal 6*)
apply force
(*proven 6 subgoals*) .
thus "?thesis"
(*goal: ‹∃S P1 P2. P = ⋃ S ∪ P1 ∪ P2 ∪ Q ∧ disjoint (S ∪ {P1, P2}) ∧ P1 ≠ P2 ∧ P1 ∉ S ∧ P2 ∉ S ∧ (∀x∈S. is_segment x) ∧ is_prolongation P1 ∧ is_prolongation P2›*)
by blast
qed
end (* context MinkowskiSpacetime *)
section "Chains are unique up to reversal"
context MinkowskiSpacetime begin
lemma chain_remove_at_right_edge:
assumes "[f↝X|a..c]" "f (card X - 2) = p" "3 ≤ card X" "X = insert c Y" "c∉Y"
shows "[f↝Y|a..p]"
proof (-)
(*goal: ‹[f↝Y|a .. p]›*)
have lch_X: "local_long_ch_by_ord f X"
using assms(1,3) (*‹[f↝X|a .. c]› ‹3 ≤ card X›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type..?y::'a::type..?z::'a::type] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) short_ch_card_2 (*‹[?f::nat ⇒ 'a↝?X::'a set] ⟹ short_ch ?X = (card ?X = (2::nat))›*) by fastforce
have "p∈X"
by (metis local_ordering_def (*‹local_ordering ?f ?ord ?X ≡ (∀n. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x∈?X. ∃n. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) assms( (*‹f (card X - 2) = p›*) 2) card.empty (*‹card {} = 0›*) card_gt_0_iff (*‹(0 < card ?A) = (?A ≠ {} ∧ finite ?A)›*) diff_less (*‹⟦0 < ?n; 0 < ?m⟧ ⟹ ?m - ?n < ?m›*) lch_X (*‹local_long_ch_by_ord f X›*) local_long_ch_by_ord_def (*‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X›*) not_numeral_le_zero (*‹¬ numeral ?n ≤ 0›*) zero_less_numeral (*‹0 < numeral ?n›*))
have bound_ind: "f 0 = a ∧ f (card X - 1) = c"
using lch_X (*‹local_long_ch_by_ord f X›*) assms(1,3) (*‹[f↝X|a .. c]› ‹3 ≤ card X›*) unfolding finite_chain_with_def finite_long_chain_with_def
(*goal: ‹f 0 = a ∧ f (card X - 1) = c›*)
by metis
have "[a;p;c]"
proof (-)
(*goal: ‹[a;p;c]›*)
have "card X - 2 < card X - 1"
using ‹3 ≤ card X› (*‹3 ≤ card X›*) by auto
moreover have "card X - 2 > 0"
using ‹3 ≤ card X› (*‹(3::nat) ≤ card (X::'a set)›*) by linarith
ultimately show "?thesis"
(*goal: ‹[a::'a::type;p::'a::type;c::'a::type]›*)
using order_finite_chain[OF lch_X] (*‹⟦finite (X::'a::type set); (0::nat) ≤ (?i::nat) ∧ ?i < (?j::nat) ∧ ?j < (?l::nat) ∧ ?l < card X⟧ ⟹ [(f::nat ⇒ 'a::type) ?i;f ?j;f ?l]›*) ‹3 ≤ card X› (*‹3 ≤ card X›*) assms(2) (*‹f (card X - 2) = p›*) bound_ind (*‹f 0 = a ∧ f (card X - 1) = c›*) by (metis card.infinite (*‹infinite ?A ⟹ card ?A = 0›*) diff_less (*‹⟦0 < ?n; 0 < ?m⟧ ⟹ ?m - ?n < ?m›*) le_numeral_extra( (*‹0 ≤ 0›*) 3) less_numeral_extra( (*‹0 < 1›*) 1) not_gr_zero (*‹(¬ 0 < ?n) = (?n = 0)›*) not_numeral_le_zero (*‹¬ numeral ?n ≤ 0›*))
qed
have "[f↝X|a..p..c]"
unfolding finite_long_chain_with_alt
(*goal: ‹[f::nat ⇒ 'a::type↝X::'a::type set|a::'a::type .. c::'a::type] ∧ [a;p::'a::type;c] ∧ p ∈ X›*)
by (simp add: assms( (*‹[f↝X|a .. c]›*) 1) ‹[a;p;c]› ‹p∈X›)
have 1: "x = a" if "x ∈ Y" "¬ [a;x;p]" "x ≠ p" for x
proof (-)
(*goal: ‹(x::'a::type) = (a::'a::type)›*)
have "x∈X"
using that(1) (*‹x ∈ Y›*) assms(4) (*‹(X::'a::type set) = insert (c::'a::type) (Y::'a::type set)›*) by simp
hence 01: "x=a ∨ [a;p;x]"
by (metis that( (*‹¬ [a;x;p]› ‹x ≠ p›*) 2,3) ‹[a;p;c]› abd_acd_abcacb (*‹⟦[?a;?b;?d]; [?a;?c;?d]; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?a;?c;?b]›*) assms( (*‹[f↝X|a .. c]›*) 1) fin_ch_betw2 (*‹⟦[?f↝?X|?a .. ?c]; ?b ∈ ?X; ?b = ?a ⟹ ?thesis; ?b = ?c ⟹ ?thesis; [?a;?b;?c] ⟹ ?thesis⟧ ⟹ ?thesis›*))
have 02: "x=c" if "[a;p;x]"
proof (-)
(*goal: ‹x = c›*)
obtain i where i_def: "f i = x" "i<card X"
(*goal: ‹(⋀i::nat. ⟦(f::nat ⇒ 'a) i = (x::'a); i < card (X::'a set)⟧ ⟹ thesis::bool) ⟹ thesis›*)
using ‹x∈X› (*‹x ∈ X›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (meson assms( (*‹[f↝X|a .. c]›*) 1) obtain_index_fin_chain (*‹⟦[?f↝?X]; ?x ∈ ?X; finite ?X; ⋀i. ⟦?f i = ?x; i < card ?X⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
have "f 0 = a"
by (simp add: bound_ind (*‹f 0 = a ∧ f (card X - 1) = c›*))
have "card X - 2 < i"
using order_finite_chain_indices[OF lch_X _ that ‹f 0 = a› assms ( 2 ) i_def ( 1 ) _ _ i_def ( 2 )] (*‹⟦finite X; 0 < card X; card X - 2 < card X⟧ ⟹ 0 < card X - 2 ∧ card X - 2 < i ∨ i < card X - 2 ∧ card X - 2 < 0›*) by (metis card_eq_0_iff (*‹(card (?A::?'a set) = (0::nat)) = (?A = {} ∨ infinite ?A)›*) card_gt_0_iff (*‹((0::nat) < card (?A::?'a set)) = (?A ≠ {} ∧ finite ?A)›*) diff_less (*‹⟦(0::nat) < (?n::nat); (0::nat) < (?m::nat)⟧ ⟹ ?m - ?n < ?m›*) i_def( (*‹(i::nat) < card (X::'a set)›*) 2) less_nat_zero_code (*‹((?n::nat) < (0::nat)) = False›*) zero_less_numeral (*‹(0::?'a) < numeral (?n::num)›*))
hence "i = card X - 1"
using i_def(2) (*‹i < card X›*) by linarith
thus "?thesis"
(*goal: ‹(x::'a) = (c::'a)›*)
using bound_ind (*‹f 0 = a ∧ f (card X - 1) = c›*) i_def(1) (*‹f i = x›*) by blast
qed
show "?thesis"
(*goal: ‹x = a›*)
using "01" (*‹x = a ∨ [a;p;x]›*) "02" (*‹[a;p;x] ⟹ x = c›*) assms(5) (*‹c ∉ Y›*) that(1) (*‹x ∈ Y›*) by auto
qed
have "Y = {e ∈ X. [a;e;p] ∨ e = a ∨ e = p}"
apply (safe, simp_all add: assms(4) 1)
(*goal: ‹Y = {e ∈ X. [a;e;p] ∨ e = a ∨ e = p}›*)
using ‹[a;p;c]› (*‹[a::'a;p::'a;c::'a]›*) abc_only_cba(2) (*‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) abc_abc_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) assms(4) (*‹X = insert c Y›*) apply -
(*goals:
1. ‹⋀x. ⟦x = c ∨ x ∈ Y; [a;x;p]; [a;p;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ a ≠ b ∧ a ≠ c ∧ b ≠ c; X = insert c Y⟧ ⟹ x ∈ Y›
2. ‹⟦a = c ∨ a ∈ Y; [a;p;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ a ≠ b ∧ a ≠ c ∧ b ≠ c; X = insert c Y⟧ ⟹ a ∈ Y›
3. ‹⟦p = c ∨ p ∈ Y; [a;p;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ a ≠ b ∧ a ≠ c ∧ b ≠ c; X = insert c Y⟧ ⟹ p ∈ Y›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*discuss goal 3*)
apply blast
(*proven 3 subgoals*) .
thus "?thesis"
(*goal: ‹[f::nat ⇒ 'a↝Y::'a set|a::'a .. p::'a]›*)
using chain_shortening[OF ‹[f↝X|a..p..c]›] (*‹[f↝{e ∈ X. [a;e;p] ∨ e = a ∨ e = p}|a .. p]›*) by simp
qed
lemma (in MinkowskiChain) fin_long_ch_imp_fin_ch:
assumes "[f↝X|a..b..c]"
shows "[f↝X|a..c]"
using assms (*‹[f↝X|a..b..c]›*) by (simp add: finite_long_chain_with_alt (*‹[?f↝?Q|?x..?y..?z] = ([?f↝?Q|?x .. ?z] ∧ [?x;?y;?z] ∧ ?y ∈ ?Q)›*))
text ‹
If we ever want to have chains less strongly identified by endpoints,
this result should generalise - $a,c,x,z$ are only used to identify reversal/no-reversal cases.
›
lemma chain_unique_induction_ax:
assumes "card X ≥ 3"
and "i < card X"
and "[f↝X|a..c]"
and "[g↝X|x..z]"
and "a = x ∨ c = z"
shows "f i = g i"
using assms (*‹(3::nat) ≤ card (X::'a set)› ‹i < card X› ‹[f↝X|a .. c]› ‹[g↝X|x .. z]› ‹(a::'a::type) = (x::'a::type) ∨ (c::'a::type) = (z::'a::type)›*) proof (induct "card X - 3" arbitrary: X a c x z)
(*goals:
1. ‹⋀(X::'a::type set) (a::'a::type) (c::'a::type) (x::'a::type) z::'a::type. ⟦(0::nat) = card X - (3::nat); (3::nat) ≤ card X; (i::nat) < card X; [f::nat ⇒ 'a::type↝X|a .. c]; [g::nat ⇒ 'a::type↝X|x .. z]; a = x ∨ c = z⟧ ⟹ f i = g i›
2. ‹⋀(xa::nat) (X::'a::type set) (a::'a::type) (c::'a::type) (x::'a::type) z::'a::type. ⟦⋀(X::'a::type set) (a::'a::type) (c::'a::type) (x::'a::type) z::'a::type. ⟦xa = card X - (3::nat); (3::nat) ≤ card X; (i::nat) < card X; [f::nat ⇒ 'a::type↝X|a .. c]; [g::nat ⇒ 'a::type↝X|x .. z]; a = x ∨ c = z⟧ ⟹ f i = g i; Suc xa = card X - (3::nat); (3::nat) ≤ card X; i < card X; [f↝X|a .. c]; [g↝X|x .. z]; a = x ∨ c = z⟧ ⟹ f i = g i›*)
case Nil: 0 (*‹0 = card X - 3› ‹3 ≤ card X› ‹(i::nat) < card (X::'a set)› ‹[f↝X|a .. c]› ‹[g↝X|x .. z]› ‹(a::'a) = (x::'a) ∨ (c::'a) = (z::'a)›*)
have "card X = 3"
using Nil.hyps (*‹0 = card X - 3›*) Nil.prems(1) (*‹3 ≤ card X›*) by auto
obtain b where f_ch: "[f↝X|a..b..c]"
(*goal: ‹(⋀b. [f↝X|a..b..c] ⟹ thesis) ⟹ thesis›*)
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis Nil.prems( (*‹3 ≤ card X› ‹[f↝X|a .. c]›*) 1,3) three_in_set3 (*‹⟦3 ≤ card ?X; ⋀x y z. ⟦x ∈ ?X; y ∈ ?X; z ∈ ?X; x ≠ y; x ≠ z; y ≠ z⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
obtain y where g_ch: "[g↝X|x..y..z]"
(*goal: ‹(⋀y. [g↝X|x..y..z] ⟹ thesis) ⟹ thesis›*)
using Nil.prems (*‹3 ≤ card X› ‹i < card X› ‹[f↝X|a .. c]› ‹[g↝X|x .. z]› ‹(a::'a) = (x::'a) ∨ (c::'a) = (z::'a)›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis three_in_set3 (*‹⟦3 ≤ card ?X; ⋀x y z. ⟦x ∈ ?X; y ∈ ?X; z ∈ ?X; x ≠ y; x ≠ z; y ≠ z⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
have "i=1 ∨ i=0 ∨ i=2"
using ‹card X = 3› (*‹card X = 3›*) Nil.prems(2) (*‹i < card X›*) by linarith
thus "?case"
(*goal: ‹f i = g i›*)
proof (rule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹i = 1 ⟹ f i = g i›
2. ‹i = 0 ∨ i = 2 ⟹ f i = g i›*)
assume "i=1" (*‹(i::nat) = (1::nat)›*)
hence "f i = b ∧ g i = y"
using index_middle_element (*‹[?f::nat ⇒ 'a↝?X::'a set|?a::'a..?b::'a..?c::'a] ⟹ ∃n>0::nat. n < card ?X - (1::nat) ∧ ?f n = ?b›*) f_ch (*‹[f↝X|a..b..c]›*) g_ch (*‹[g↝X|x..y..z]›*) ‹card X = 3› (*‹card X = 3›*) numeral_3_eq_3 (*‹3 = Suc (Suc (Suc 0))›*) by (metis One_nat_def (*‹1 = Suc 0›*) add_diff_cancel_left' (*‹?a + ?b - ?a = ?b›*) less_SucE (*‹⟦?m < Suc ?n; ?m < ?n ⟹ ?P; ?m = ?n ⟹ ?P⟧ ⟹ ?P›*) not_less_eq (*‹(¬ ?m < ?n) = (?n < Suc ?m)›*) plus_1_eq_Suc (*‹(+) 1 = Suc›*))
have "f i = g i"
proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*))
(*goal: ‹f i ≠ g i ⟹ False›*)
assume "f i ≠ g i" (*‹(f::nat ⇒ 'a) (i::nat) ≠ (g::nat ⇒ 'a) i›*)
hence "g i ≠ b"
by (simp add: ‹f i = b ∧ g i = y›)
have "g i ∈ X"
using ‹f i = b ∧ g i = y› (*‹f i = b ∧ g i = y›*) g_ch (*‹[g↝X|x..y..z]›*) points_in_long_chain (*‹[?f↝?Q|?x..?y..?z] ⟹ ?x ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?y ∈ ?Q› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ⟹ ?z ∈ ?Q›*) by blast
have "X = {a,b,c}"
using f_ch (*‹[f↝X|a..b..c]›*) unfolding finite_long_chain_with_alt
(*goal: ‹X = {a, b, c}›*)
using ‹card X = 3› (*‹card (X::'a set) = (3::nat)›*) points_in_long_chain[OF f_ch] (*‹a ∈ X› ‹b ∈ X› ‹c ∈ X›*) abc_abc_neq[of a b c] (*‹[a;b;c] ⟹ a ≠ b ∧ a ≠ c ∧ b ≠ c›*) by (simp add: card_3_eq'( (*‹⟦card (?X::?'a::type set) = (3::nat); (?a::?'a::type) ∈ ?X; (?b::?'a::type) ∈ ?X; (?c::?'a::type) ∈ ?X; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ ?X = {?a, ?b, ?c}›*) 2))
hence "(g i = a ∨ g i = c)"
using ‹g i ≠ b› (*‹g i ≠ b›*) ‹g i ∈ X› (*‹g i ∈ X›*) by blast
hence "¬ [a; g i; c]"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) by blast
hence "g i ∉ X"
using ‹f i=b ∧ g i=y› (*‹f i = b ∧ g i = y›*) ‹g i=a ∨ g i=c› (*‹g i = a ∨ g i = c›*) f_ch (*‹[f↝X|a..b..c]›*) g_ch (*‹[g↝X|x..y..z]›*) chain_bounds_unique (*‹⟦[?f↝?X|?a .. ?c]; [?g↝?X|?x .. ?z]⟧ ⟹ ?a = ?x ∧ ?c = ?z ∨ ?a = ?z ∧ ?c = ?x›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by blast
thus False
by (simp add: ‹g i ∈ X›)
qed
thus "?thesis"
(*goal: ‹f i = g i›*)
by (simp add: ‹card X = 3› ‹i = 1›)
next
(*goal: ‹i = 0 ∨ i = 2 ⟹ f i = g i›*)
assume "i = 0 ∨ i = 2" (*‹(i::nat) = (0::nat) ∨ i = (2::nat)›*)
show "?thesis"
(*goal: ‹f i = g i›*)
using Nil.prems(5) (*‹a = x ∨ c = z›*) ‹card X = 3› (*‹card X = 3›*) ‹i = 0 ∨ i = 2› (*‹i = 0 ∨ i = 2›*) chain_bounds_unique (*‹⟦[?f↝?X|?a .. ?c]; [?g↝?X|?x .. ?z]⟧ ⟹ ?a = ?x ∧ ?c = ?z ∨ ?a = ?z ∧ ?c = ?x›*) f_ch (*‹[f↝X|a..b..c]›*) g_ch (*‹[g::nat ⇒ 'a↝X::'a set|x::'a..y::'a..z::'a]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis diff_Suc_1 (*‹Suc (?n::nat) - (1::nat) = ?n›*) numeral_2_eq_2 (*‹(2::nat) = Suc (Suc (0::nat))›*) numeral_3_eq_3 (*‹(3::nat) = Suc (Suc (Suc (0::nat)))›*))
qed
next
(*goal: ‹⋀xa X a c x z. ⟦⋀X a c x z. ⟦xa = card X - 3; 3 ≤ card X; i < card X; [f↝X|a .. c]; [g↝X|x .. z]; a = x ∨ c = z⟧ ⟹ f i = g i; Suc xa = card X - 3; 3 ≤ card X; i < card X; [f↝X|a .. c]; [g↝X|x .. z]; a = x ∨ c = z⟧ ⟹ f i = g i›*)
case IH: (Suc n) (*‹⟦(n::nat) = card (?X::'a::type set) - (3::nat); (3::nat) ≤ card ?X; (i::nat) < card ?X; [f::nat ⇒ 'a::type↝?X|?a::'a::type .. ?c::'a::type]; [g::nat ⇒ 'a::type↝?X|?x::'a::type .. ?z::'a::type]; ?a = ?x ∨ ?c = ?z⟧ ⟹ f i = g i› ‹Suc n = card X - 3› ‹3 ≤ card X› ‹i < card X› ‹[f::nat ⇒ 'a↝X::'a set|a::'a .. c::'a]› ‹[g↝X|x .. z]› ‹a = x ∨ c = z›*)
have lch_fX: "local_long_ch_by_ord f X"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_card_ge3 (*‹⟦[?f↝?X]; finite ?X⟧ ⟹ local_long_ch_by_ord ?f ?X = (3 ≤ card ?X)›*) IH(3,5) (*‹3 ≤ card X› ‹[f↝X|a .. c]›*) by fastforce
have lch_gX: "local_long_ch_by_ord g X"
using IH(3,6) (*‹3 ≤ card X› ‹[g↝X|x .. z]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f::nat ⇒ 'a::type↝?X::'a::type set] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_card_ge3 (*‹⟦[?f::nat ⇒ 'a↝?X::'a set]; finite ?X⟧ ⟹ local_long_ch_by_ord ?f ?X = ((3::nat) ≤ card ?X)›*) by fastforce
have fin_X: "finite X"
using IH(4) (*‹i < card X›*) le_0_eq (*‹(?n ≤ 0) = (?n = 0)›*) by fastforce
have "ch_by_ord f X"
using lch_fX (*‹local_long_ch_by_ord f X›*) unfolding ch_by_ord_def
(*goal: ‹short_ch_by_ord (f::nat ⇒ 'a::type) (X::'a::type set) ∨ local_long_ch_by_ord f X›*)
by blast
have "card X ≥ 4"
using IH.hyps(2) (*‹Suc n = card X - 3›*) by linarith
obtain b where f_ch: "[f↝X|a..b..c]"
(*goal: ‹(⋀b::'a::type. [f::nat ⇒ 'a::type↝X::'a::type set|a::'a::type..b..c::'a::type] ⟹ thesis::bool) ⟹ thesis›*)
using IH(3,5) (*‹(3::nat) ≤ card (X::'a set)› ‹[f::nat ⇒ 'a↝X::'a set|a::'a .. c::'a]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a::type set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a::type. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis three_in_set3 (*‹⟦3 ≤ card ?X; ⋀x y z. ⟦x ∈ ?X; y ∈ ?X; z ∈ ?X; x ≠ y; x ≠ z; y ≠ z⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
obtain y where g_ch: "[g↝X|x..y..z]"
(*goal: ‹(⋀y. [g↝X|x..y..z] ⟹ thesis) ⟹ thesis›*)
using IH.prems(1,4) (*‹(3::nat) ≤ card (X::'a set)› ‹[g↝X|x .. z]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a::type set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a::type. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type .. ?y::'a::type] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis three_in_set3 (*‹⟦3 ≤ card ?X; ⋀x y z. ⟦x ∈ ?X; y ∈ ?X; z ∈ ?X; x ≠ y; x ≠ z; y ≠ z⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
obtain p where p_def: "p = f (card X - 2)"
(*goal: ‹(⋀p. p = f (card X - 2) ⟹ thesis) ⟹ thesis›*)
by simp
have "[a;p;c]"
proof (-)
(*goal: ‹[a;p;c]›*)
have "card X - 2 < card X - 1"
using ‹4 ≤ card X› (*‹4 ≤ card X›*) by auto
moreover have "card X - 2 > 0"
using ‹3 ≤ card X› (*‹3 ≤ card X›*) by linarith
ultimately show "?thesis"
(*goal: ‹[a;p;c]›*)
using f_ch (*‹[f↝X|a..b..c]›*) p_def (*‹(p::'a) = (f::nat ⇒ 'a) (card (X::'a set) - (2::nat))›*) chain_defs (*‹short_ch (?X::'a::type set) ≡ card ?X = (2::nat) ∧ (∃P::'a::type set∈𝒫::'a::type set set. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a::type set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) ‹[f↝X]› (*‹[f↝X]›*) order_finite_chain2 (*‹⟦[?f::nat ⇒ 'a::type↝?X::'a::type set]; finite ?X; (0::nat) ≤ (?i::nat) ∧ ?i < (?j::nat) ∧ ?j < (?l::nat) ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) by force
qed
hence "p≠c ∧ p≠a"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) by blast
obtain Y where Y_def: "X = insert c Y" "c∉Y"
(*goal: ‹(⋀Y. ⟦X = insert c Y; c ∉ Y⟧ ⟹ thesis) ⟹ thesis›*)
using f_ch (*‹[f↝X|a..b..c]›*) points_in_long_chain (*‹[?f↝?Q|?x..?y..?z] ⟹ ?x ∈ ?Q› ‹[?f↝?Q|?x..?y..?z] ⟹ ?y ∈ ?Q› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type..?y::'a::type..?z::'a::type] ⟹ ?z ∈ ?Q›*) by (meson mk_disjoint_insert (*‹?a ∈ ?A ⟹ ∃B. ?A = insert ?a B ∧ ?a ∉ B›*))
hence fin_Y: "finite Y"
using f_ch (*‹[f::nat ⇒ 'a↝X::'a set|a::'a..b::'a..c::'a]›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a::type set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a::type. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by auto
hence "n = card Y - 3"
using ‹Suc n = card X - 3› (*‹Suc n = card X - 3›*) ‹X = insert c Y› (*‹X = insert c Y›*) ‹c∉Y› (*‹(c::'a) ∉ (Y::'a set)›*) card_insert_if (*‹finite ?A ⟹ card (insert ?x ?A) = (if ?x ∈ ?A then card ?A else Suc (card ?A))›*) by auto
hence card_Y: "card Y = n + 3"
using Y_def(1) (*‹X = insert c Y›*) Y_def(2) (*‹c ∉ Y›*) fin_Y (*‹finite Y›*) IH.hyps(2) (*‹Suc n = card X - 3›*) by fastforce
have "card Y = card X - 1"
using Y_def(1,2) (*‹X = insert c Y› ‹c ∉ Y›*) fin_X (*‹finite X›*) by auto
have "p∈Y"
using ‹X = insert c Y› (*‹X = insert c Y›*) ‹[a;p;c]› (*‹[a;p;c]›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) lch_fX (*‹local_long_ch_by_ord f X›*) p_def (*‹p = f (card X - 2)›*) IH.prems(1,3) (*‹3 ≤ card X› ‹[f↝X|a .. c]›*) Y_def(2) (*‹(c::'a) ∉ (Y::'a set)›*) by (metis chain_remove_at_right_edge (*‹⟦[?f↝?X|?a .. ?c]; ?f (card ?X - 2) = ?p; 3 ≤ card ?X; ?X = insert ?c ?Y; ?c ∉ ?Y⟧ ⟹ [?f↝?Y|?a .. ?p]›*) points_in_chain (*‹[?f↝?Q|?x .. ?z] ⟹ ?x ∈ ?Q ∧ ?z ∈ ?Q›*))
have "[f↝Y|a..p]"
using chain_remove_at_right_edge[where f = f and a = a and c = c and X = X and p = p and Y = Y] (*‹⟦[f↝X|a .. c]; f (card X - 2) = p; 3 ≤ card X; X = insert c Y; c ∉ Y⟧ ⟹ [f↝Y|a .. p]›*) using fin_long_ch_imp_fin_ch[where f = f and a = a and c = c and b = b and X = X] (*‹[f↝X|a..b..c] ⟹ [f↝X|a .. c]›*) using f_ch (*‹[f↝X|a..b..c]›*) p_def (*‹p = f (card X - 2)›*) ‹card X ≥ 3› (*‹3 ≤ card X›*) Y_def (*‹X = insert c Y› ‹c ∉ Y›*) by blast
hence ch_fY: "local_long_ch_by_ord f Y"
using card_Y (*‹card Y = n + 3›*) fin_Y (*‹finite Y›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a::type) (?Q::'a::type set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) long_ch_card_ge3 (*‹⟦[?f::nat ⇒ 'a↝?X::'a set]; finite ?X⟧ ⟹ local_long_ch_by_ord ?f ?X = ((3::nat) ≤ card ?X)›*) by force
have p_closest: "¬ (∃q∈X. [p;q;c])"
proof (standard)
(*goal: ‹∃q∈X. [p;q;c] ⟹ False›*)
assume "(∃q∈X. [p;q;c])" (*‹∃q::'a∈X::'a set. [p::'a;q;c::'a]›*)
then obtain q where "q∈X" "[p;q;c]"
(*goal: ‹(⋀q. ⟦q ∈ X; [p;q;c]⟧ ⟹ thesis) ⟹ thesis›*)
by blast
then obtain j where "j < card X" "f j = q"
(*goal: ‹(⋀j::nat. ⟦j < card (X::'a set); (f::nat ⇒ 'a) j = (q::'a)⟧ ⟹ thesis::bool) ⟹ thesis›*)
using lch_fX (*‹local_long_ch_by_ord f X›*) lch_gX (*‹local_long_ch_by_ord g X›*) fin_X (*‹finite (X::'a set)›*) points_in_chain (*‹[?f↝?Q|?x .. ?z] ⟹ ?x ∈ ?Q ∧ ?z ∈ ?Q›*) ‹p≠c ∧ p≠a› (*‹(p::'a) ≠ (c::'a) ∧ p ≠ (a::'a)›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type .. ?y::'a::type] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis local_ordering_def (*‹local_ordering (?f::nat ⇒ ?'a::type) (?ord::?'a::type ⇒ ?'a::type ⇒ ?'a::type ⇒ bool) (?X::?'a::type set) ≡ (∀n::nat. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x::?'a::type∈?X. ∃n::nat. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n::nat. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*))
have "j > card X - 2 ∧ j < card X - 1"
proof (-)
(*goal: ‹card X - 2 < j ∧ j < card X - 1›*)
have "j > card X - 2 ∧ j < card X - 1 ∨ j > card X - 1 ∧ j < card X - 2"
apply (intro order_finite_chain_indices[OF lch_fX ‹finite X› ‹[p;q;c]›] (*‹⟦(f::nat ⇒ 'a::type) (?i::nat) = (p::'a::type); f (?j::nat) = (q::'a::type); f (?k::nat) = (c::'a::type); ?i < card (X::'a::type set); ?j < card X; ?k < card X⟧ ⟹ ?i < ?j ∧ ?j < ?k ∨ ?k < ?j ∧ ?j < ?i›*))
(*goal: ‹card X - 2 < j ∧ j < card X - 1 ∨ card X - 1 < j ∧ j < card X - 2›*)
using p_def (*‹p = f (card X - 2)›*) ‹f j = q› (*‹f j = q›*) IH.prems(3) (*‹[f↝X|a .. c]›*) finite_chain_with_def (*‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y›*) ‹j < card X› (*‹j < card X›*) apply -
(*goals:
1. ‹⟦p = f (card X - 2); f j = q; [f↝X|a .. c]; ⋀f Q x y. [f↝Q|x .. y] ≡ finite_chain f Q ∧ f 0 = x ∧ f (card Q - 1) = y; j < card X⟧ ⟹ f (card X - 2) = p›
2. ‹⟦p = f (card X - 2); f j = q; [f↝X|a .. c]; ⋀f Q x y. [f↝Q|x .. y] ≡ finite_chain f Q ∧ f 0 = x ∧ f (card Q - 1) = y; j < card X⟧ ⟹ f j = q›
3. ‹⟦p = f (card X - 2); f j = q; [f↝X|a .. c]; ⋀f Q x y. [f↝Q|x .. y] ≡ finite_chain f Q ∧ f 0 = x ∧ f (card Q - 1) = y; j < card X⟧ ⟹ f (card X - 1) = c›
4. ‹⟦p = f (card X - 2); f j = q; [f↝X|a .. c]; ⋀f Q x y. [f↝Q|x .. y] ≡ finite_chain f Q ∧ f 0 = x ∧ f (card Q - 1) = y; j < card X⟧ ⟹ card X - 2 < card X›
5. ‹⟦p = f (card X - 2); f j = q; [f↝X|a .. c]; ⋀f Q x y. [f↝Q|x .. y] ≡ finite_chain f Q ∧ f 0 = x ∧ f (card Q - 1) = y; j < card X⟧ ⟹ j < card X›
6. ‹⟦p = f (card X - 2); f j = q; [f↝X|a .. c]; ⋀f Q x y. [f↝Q|x .. y] ≡ finite_chain f Q ∧ f 0 = x ∧ f (card Q - 1) = y; j < card X⟧ ⟹ card X - 1 < card X›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*discuss goal 6*)
apply ((auto)[1])
(*proven 6 subgoals*) .
thus "?thesis"
(*goal: ‹card X - 2 < j ∧ j < card X - 1›*)
by linarith
qed
thus False
by linarith
qed
have "g (card X - 2) = p"
proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*))
(*goal: ‹g (card X - 2) ≠ p ⟹ False›*)
assume asm_false: "g (card X - 2) ≠ p" (*‹(g::nat ⇒ 'a) (card (X::'a set) - (2::nat)) ≠ (p::'a)›*)
obtain j where "g j = p" "j < card X - 1" "j>0"
(*goal: ‹(⋀j::nat. ⟦(g::nat ⇒ 'a) j = (p::'a); j < card (X::'a set) - (1::nat); (0::nat) < j⟧ ⟹ thesis::bool) ⟹ thesis›*)
using ‹X = insert c Y› (*‹X = insert c Y›*) ‹p∈Y› (*‹p ∈ Y›*) points_in_chain (*‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type .. ?z::'a::type] ⟹ ?x ∈ ?Q ∧ ?z ∈ ?Q›*) ‹p≠c ∧ p≠a› (*‹(p::'a) ≠ (c::'a) ∧ p ≠ (a::'a)›*) by (metis (no_types) chain_bounds_unique (*‹⟦[?f↝?X|?a .. ?c]; [?g↝?X|?x .. ?z]⟧ ⟹ ?a = ?x ∧ ?c = ?z ∨ ?a = ?z ∧ ?c = ?x›*) f_ch (*‹[f↝X|a..b..c]›*) finite_long_chain_with_def (*‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) g_ch (*‹[g↝X|x..y..z]›*) index_middle_element (*‹[?f↝?X|?a..?b..?c] ⟹ ∃n>0. n < card ?X - 1 ∧ ?f n = ?b›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*))
hence "j < card X - 2"
using asm_false (*‹g (card X - 2) ≠ p›*) le_eq_less_or_eq (*‹((?m::nat) ≤ (?n::nat)) = (?m < ?n ∨ ?m = ?n)›*) by fastforce
hence "j < card Y - 1"
by (simp add: Y_def( (*‹(X::'a::type set) = insert (c::'a::type) (Y::'a::type set)› ‹(c::'a::type) ∉ (Y::'a::type set)›*) 1,2) fin_Y (*‹finite (Y::'a::type set)›*))
obtain d where "d = g (card X - 2)"
(*goal: ‹(⋀d. d = g (card X - 2) ⟹ thesis) ⟹ thesis›*)
by simp
have "[p;d;z]"
proof (-)
(*goal: ‹[p::'a;d::'a;z::'a]›*)
have "card X - 1 > card X - 2"
using ‹j < card X - 1› (*‹j < card X - 1›*) by linarith
thus "?thesis"
(*goal: ‹[p;d;z]›*)
using lch_gX (*‹local_long_ch_by_ord g X›*) ‹j < card Y - 1› (*‹(j::nat) < card (Y::'a set) - (1::nat)›*) ‹card Y = card X - 1› (*‹card Y = card X - 1›*) ‹d = g (card X - 2)› (*‹d = g (card X - 2)›*) ‹g j = p› (*‹g j = p›*) order_finite_chain[OF lch_gX] (*‹⟦finite (X::'a::type set); (0::nat) ≤ (?i::nat) ∧ ?i < (?j::nat) ∧ ?j < (?l::nat) ∧ ?l < card X⟧ ⟹ [(g::nat ⇒ 'a::type) ?i;g ?j;g ?l]›*) chain_defs (*‹short_ch (?X::'a set) ≡ card ?X = (2::nat) ∧ (∃P::'a set∈𝒫::'a set set. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) local_ordering_def (*‹local_ordering ?f ?ord ?X ≡ (∀n. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x∈?X. ∃n. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) by (smt (z3) IH.prems( (*‹[f↝X|a .. c]› ‹[g↝X|x .. z]› ‹a = x ∨ c = z›*) 3-5) asm_false (*‹g (card X - 2) ≠ p›*) chain_bounds_unique (*‹⟦[?f↝?X|?a .. ?c]; [?g↝?X|?x .. ?z]⟧ ⟹ ?a = ?x ∧ ?c = ?z ∨ ?a = ?z ∧ ?c = ?x›*) chain_remove_at_right_edge (*‹⟦[?f↝?X|?a .. ?c]; ?f (card ?X - 2) = ?p; 3 ≤ card ?X; ?X = insert ?c ?Y; ?c ∉ ?Y⟧ ⟹ [?f↝?Y|?a .. ?p]›*) p_def (*‹p = f (card X - 2)›*) ‹⋀thesis. (⋀Y. ⟦X = insert c Y; c ∉ Y⟧ ⟹ thesis) ⟹ thesis›)
qed
moreover have "d∈X"
using lch_gX (*‹local_long_ch_by_ord g X›*) ‹d = g (card X - 2)› (*‹d = g (card X - 2)›*) unfolding local_long_ch_by_ord_def local_ordering_def
(*goal: ‹d ∈ X›*)
by auto
ultimately show False
using p_closest (*‹¬ (∃q∈X. [p;q;c])›*) abc_sym (*‹[?a::'a;?b::'a;?c::'a] ⟹ [?c;?b;?a]›*) IH.prems(3-5) (*‹[f↝X|a .. c]› ‹[g::nat ⇒ 'a↝X::'a set|x::'a .. z::'a]› ‹a = x ∨ c = z›*) chain_bounds_unique (*‹⟦[?f↝?X|?a .. ?c]; [?g↝?X|?x .. ?z]⟧ ⟹ ?a = ?x ∧ ?c = ?z ∨ ?a = ?z ∧ ?c = ?x›*) f_ch (*‹[f↝X|a..b..c]›*) g_ch (*‹[g↝X|x..y..z]›*) by blast
qed
hence ch_gY: "local_long_ch_by_ord g Y"
using IH.prems(1,4,5) (*‹(3::nat) ≤ card (X::'a::type set)› ‹[g↝X|x .. z]› ‹a = x ∨ c = z›*) g_ch (*‹[g↝X|x..y..z]›*) f_ch (*‹[f↝X|a..b..c]›*) ch_fY (*‹local_long_ch_by_ord f Y›*) card_Y (*‹card (Y::'a::type set) = (n::nat) + (3::nat)›*) chain_remove_at_right_edge (*‹⟦[?f↝?X|?a .. ?c]; ?f (card ?X - 2) = ?p; 3 ≤ card ?X; ?X = insert ?c ?Y; ?c ∉ ?Y⟧ ⟹ [?f↝?Y|?a .. ?p]›*) fin_Y (*‹finite (Y::'a set)›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis Y_def (*‹(X::'a set) = insert (c::'a) (Y::'a set)› ‹(c::'a) ∉ (Y::'a set)›*) chain_bounds_unique (*‹⟦[?f::nat ⇒ 'a↝?X::'a set|?a::'a .. ?c::'a]; [?g::nat ⇒ 'a↝?X|?x::'a .. ?z::'a]⟧ ⟹ ?a = ?x ∧ ?c = ?z ∨ ?a = ?z ∧ ?c = ?x›*) long_ch_card_ge3 (*‹⟦[?f::nat ⇒ 'a↝?X::'a set]; finite ?X⟧ ⟹ local_long_ch_by_ord ?f ?X = ((3::nat) ≤ card ?X)›*))
have "f i ∈ Y ∨ f i = c"
by (metis local_ordering_def (*‹local_ordering ?f ?ord ?X ≡ (∀n. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x∈?X. ∃n. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) ‹X = insert c Y› ‹i < card X› lch_fX (*‹local_long_ch_by_ord f X›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) local_long_ch_by_ord_def (*‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X›*))
thus "f i = g i"
proof (rule disjE (*‹⟦(?P::bool) ∨ (?Q::bool); ?P ⟹ ?R::bool; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹f i ∈ Y ⟹ f i = g i›
2. ‹f i = c ⟹ f i = g i›*)
assume "f i ∈ Y" (*‹(f::nat ⇒ 'a) (i::nat) ∈ (Y::'a set)›*)
hence "f i ≠ c"
using ‹c ∉ Y› (*‹(c::'a) ∉ (Y::'a set)›*) by blast
hence "i < card Y"
using ‹X = insert c Y› (*‹X = insert c Y›*) ‹c∉Y› (*‹c ∉ Y›*) IH(3,4) (*‹3 ≤ card X› ‹(i::nat) < card (X::'a::type set)›*) f_ch (*‹[f↝X|a..b..c]›*) fin_Y (*‹finite Y›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f::nat ⇒ 'a↝?X::'a set] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord (?f::nat ⇒ 'a) (?Q::'a set) ≡ ?Q = {?f (0::nat), ?f (1::nat)} ∧ (∃Q::'a set. path Q (?f (0::nat)) (?f (1::nat)))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a .. ?y::'a] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) not_less_less_Suc_eq (*‹¬ ?n < ?m ⟹ (?n < Suc ?m) = (?n = ?m)›*) by (metis ‹card Y = card X - 1› card_insert_disjoint (*‹⟦finite ?A; ?x ∉ ?A⟧ ⟹ card (insert ?x ?A) = Suc (card ?A)›*))
hence "3 ≤ card Y"
using card_Y (*‹card Y = n + 3›*) le_add2 (*‹?n ≤ ?m + ?n›*) by presburger
show "f i = g i"
using IH(1)[of Y] (*‹⟦n = card Y - 3; 3 ≤ card Y; i < card Y; [f↝Y|?a .. ?c]; [g↝Y|?x .. ?z]; ?a = ?x ∨ ?c = ?z⟧ ⟹ f i = g i›*) using ‹n = card Y - 3› (*‹n = card Y - 3›*) ‹3 ≤ card Y› (*‹3 ≤ card Y›*) ‹i < card Y› (*‹i < card Y›*) using Y_def (*‹X = insert c Y› ‹c ∉ Y›*) card_Y (*‹card Y = n + 3›*) chain_remove_at_right_edge (*‹⟦[?f::nat ⇒ 'a::type↝?X::'a::type set|?a::'a::type .. ?c::'a::type]; ?f (card ?X - (2::nat)) = (?p::'a::type); (3::nat) ≤ card ?X; ?X = insert ?c (?Y::'a::type set); ?c ∉ ?Y⟧ ⟹ [?f↝?Y|?a .. ?p]›*) le_add2 (*‹?n ≤ ?m + ?n›*) by (metis IH.prems( (*‹3 ≤ card X› ‹[f↝X|a .. c]› ‹[g↝X|x .. z]› ‹a = x ∨ c = z›*) 1,3,4,5) chain_bounds_unique (*‹⟦[?f↝?X|?a .. ?c]; [?g↝?X|?x .. ?z]⟧ ⟹ ?a = ?x ∧ ?c = ?z ∨ ?a = ?z ∧ ?c = ?x›*))
next
(*goal: ‹f i = c ⟹ f i = g i›*)
assume "f i = c" (*‹(f::nat ⇒ 'a) (i::nat) = (c::'a)›*)
show "?thesis"
(*goal: ‹f i = g i›*)
using IH.prems(2,5) (*‹i < card X› ‹a = x ∨ c = z›*) ‹f i = c› (*‹f i = c›*) chain_bounds_unique (*‹⟦[?f↝?X|?a .. ?c]; [?g↝?X|?x .. ?z]⟧ ⟹ ?a = ?x ∧ ?c = ?z ∨ ?a = ?z ∧ ?c = ?x›*) f_ch (*‹[f↝X|a..b..c]›*) g_ch (*‹[g↝X|x..y..z]›*) indices_neq_imp_events_neq (*‹⟦[?f↝?X|?a..?b..?c]; ?i ≠ ?j; ?j < card ?X; ?i < card ?X⟧ ⟹ ?f ?i ≠ ?f ?j›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis ‹card Y = card X - 1› Y_def (*‹(X::'a set) = insert (c::'a) (Y::'a set)› ‹(c::'a) ∉ (Y::'a set)›*) card_insert_disjoint (*‹⟦finite (?A::?'a set); (?x::?'a) ∉ ?A⟧ ⟹ card (insert ?x ?A) = Suc (card ?A)›*) fin_Y (*‹finite (Y::'a set)›*) lessI (*‹(?n::nat) < Suc ?n›*))
qed
qed
text ‹I'm really impressed ‹sledgehammer›/‹smt› can solve this if I just tell them "Use symmetry!".›
lemma chain_unique_induction_cx:
assumes "card X ≥ 3"
and "i < card X"
and "[f↝X|a..c]"
and "[g↝X|x..z]"
and "c = x ∨ a = z"
shows "f i = g (card X - i - 1)"
using chain_sym_obtain2 (*‹⟦[?f↝?X|?a .. ?c]; ⋀g. ⟦[g↝?X|?c .. ?a]; g = (λn. ?f (card ?X - 1 - n))⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) chain_unique_induction_ax (*‹⟦3 ≤ card ?X; ?i < card ?X; [?f↝?X|?a .. ?c]; [?g↝?X|?x .. ?z]; ?a = ?x ∨ ?c = ?z⟧ ⟹ ?f ?i = ?g ?i›*) assms (*‹3 ≤ card X› ‹i < card X› ‹[f↝X|a .. c]› ‹[g↝X|x .. z]› ‹c = x ∨ a = z›*) diff_right_commute (*‹?a - ?c - ?b = ?a - ?b - ?c›*) by smt
text ‹
This lemma has to exclude two-element chains again, because no order exists within them.
Alternatively, the result is trivial: any function that assigns one element to index 0 and
the other to 1 can be replaced with the (unique) other assignment, without destroying any
(trivial, since ternary) \<^term>‹local_ordering› of the chain.
This could be made generic over the \<^term>‹local_ordering›
similar to @{thm chain_sym} relying on @{thm ordering_sym_loc}.
›
lemma chain_unique_upto_rev_cases:
assumes ch_f: "[f↝X|a..c]"
and ch_g: "[g↝X|x..z]"
and card_X: "card X ≥ 3"
and valid_index: "i < card X"
shows "((a=x ∨ c=z) ⟶ (f i = g i))" "((a=z ∨ c=x) ⟶ (f i = g (card X - i - 1)))"
proof (-)
(*goals:
1. ‹a = x ∨ c = z ⟶ f i = g i›
2. ‹a = z ∨ c = x ⟶ f i = g (card X - i - 1)›*)
obtain n where n_def: "n = card X - 3"
(*goal: ‹(⋀n::nat. n = card (X::'a::type set) - (3::nat) ⟹ thesis::bool) ⟹ thesis›*)
by blast
hence valid_index_2: "i < n + 3"
by (simp add: card_X (*‹(3::nat) ≤ card (X::'a set)›*) valid_index (*‹(i::nat) < card (X::'a set)›*))
show "((a=x ∨ c=z) ⟶ (f i = g i))"
using card_X (*‹3 ≤ card X›*) ch_f (*‹[f↝X|a .. c]›*) ch_g (*‹[g↝X|x .. z]›*) chain_unique_induction_ax (*‹⟦3 ≤ card ?X; ?i < card ?X; [?f↝?X|?a .. ?c]; [?g↝?X|?x .. ?z]; ?a = ?x ∨ ?c = ?z⟧ ⟹ ?f ?i = ?g ?i›*) valid_index (*‹i < card X›*) by blast
show "((a=z ∨ c=x) ⟶ (f i = g (card X - i - 1)))"
using assms(3) (*‹3 ≤ card X›*) ch_f (*‹[f↝X|a .. c]›*) ch_g (*‹[g↝X|x .. z]›*) chain_unique_induction_cx (*‹⟦3 ≤ card ?X; ?i < card ?X; [?f↝?X|?a .. ?c]; [?g↝?X|?x .. ?z]; ?c = ?x ∨ ?a = ?z⟧ ⟹ ?f ?i = ?g (card ?X - ?i - 1)›*) valid_index (*‹i < card X›*) by blast
qed
lemma chain_unique_upto_rev:
assumes "[f↝X|a..c]" "[g↝X|x..z]" "card X ≥ 3" "i < card X"
shows "f i = g i ∨ f i = g (card X - i - 1)" "a=x∧c=z ∨ c=x∧a=z"
proof (-)
(*goals:
1. ‹f i = g i ∨ f i = g (card X - i - 1)›
2. ‹a = x ∧ c = z ∨ c = x ∧ a = z›*)
have "(a=x ∨ c=z) ∨ (a=z ∨ c=x)"
using chain_bounds_unique (*‹⟦[?f↝?X|?a .. ?c]; [?g↝?X|?x .. ?z]⟧ ⟹ ?a = ?x ∧ ?c = ?z ∨ ?a = ?z ∧ ?c = ?x›*) by (metis assms( (*‹[f↝X|a .. c]› ‹[g↝X|x .. z]›*) 1,2))
thus "f i = g i ∨ f i = g (card X - i - 1)"
using assms(3) (*‹3 ≤ card X›*) ‹i < card X› (*‹i < card X›*) assms (*‹[f↝X|a .. c]› ‹[g↝X|x .. z]› ‹3 ≤ card X› ‹i < card X›*) chain_unique_upto_rev_cases (*‹⟦[?f↝?X|?a .. ?c]; [?g↝?X|?x .. ?z]; 3 ≤ card ?X; ?i < card ?X⟧ ⟹ ?a = ?x ∨ ?c = ?z ⟶ ?f ?i = ?g ?i› ‹⟦[?f↝?X|?a .. ?c]; [?g↝?X|?x .. ?z]; 3 ≤ card ?X; ?i < card ?X⟧ ⟹ ?a = ?z ∨ ?c = ?x ⟶ ?f ?i = ?g (card ?X - ?i - 1)›*) by blast
thus "(a=x∧c=z) ∨ (c=x∧a=z)"
by (meson assms( (*‹[f↝X|a .. c]› ‹[g↝X|x .. z]› ‹3 ≤ card X›*) 1-3) chain_bounds_unique (*‹⟦[?f↝?X|?a .. ?c]; [?g↝?X|?x .. ?z]⟧ ⟹ ?a = ?x ∧ ?c = ?z ∨ ?a = ?z ∧ ?c = ?x›*))
qed
end (* context MinkowskiSpacetime *)
section "Interlude: betw4 and WLOG"
subsection "betw4 - strict and non-strict, basic lemmas"
context MinkowskiBetweenness begin
text ‹Define additional notation for non-strict \<^term>‹local_ordering› -
cf Schutz' monograph \<^cite>‹‹ p.~27› in "schutz1997"›.›
abbreviation nonstrict_betw_right :: "'a ⇒ 'a ⇒ 'a ⇒ bool" ("[_;_;_⟧") where
"nonstrict_betw_right a b c ≡ [a;b;c] ∨ b = c"
abbreviation nonstrict_betw_left :: "'a ⇒ 'a ⇒ 'a ⇒ bool" ("⟦_;_;_]") where
"nonstrict_betw_left a b c ≡ [a;b;c] ∨ b = a"
abbreviation nonstrict_betw_both :: "'a ⇒ 'a ⇒ 'a ⇒ bool" (* ("[(_ _ _)]") *) where
"nonstrict_betw_both a b c ≡ nonstrict_betw_left a b c ∨ nonstrict_betw_right a b c"
abbreviation betw4 :: "'a ⇒ 'a ⇒ 'a ⇒ 'a ⇒ bool" ("[_;_;_;_]") where
"betw4 a b c d ≡ [a;b;c] ∧ [b;c;d]"
abbreviation nonstrict_betw_right4 :: "'a ⇒ 'a ⇒ 'a ⇒ 'a ⇒ bool" ("[_;_;_;_⟧") where
"nonstrict_betw_right4 a b c d ≡ betw4 a b c d ∨ c = d"
abbreviation nonstrict_betw_left4 :: "'a ⇒ 'a ⇒ 'a ⇒ 'a ⇒ bool" ("⟦_;_;_;_]") where
"nonstrict_betw_left4 a b c d ≡ betw4 a b c d ∨ a = b"
abbreviation nonstrict_betw_both4 :: "'a ⇒ 'a ⇒ 'a ⇒ 'a ⇒ bool" (* ("[(_ _ _ _)]") *) where
"nonstrict_betw_both4 a b c d ≡ nonstrict_betw_left4 a b c d ∨ nonstrict_betw_right4 a b c d"
lemma betw4_strong:
assumes "betw4 a b c d"
shows "[a;b;d] ∧ [a;c;d]"
using abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) assms (*‹[a::'a;b::'a;c::'a;d::'a]›*) by blast
lemma betw4_imp_neq:
assumes "betw4 a b c d"
shows "a≠b ∧ a≠c ∧ a≠d ∧ b≠c ∧ b≠d ∧ c≠d"
using abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) assms (*‹[a;b;c;d]›*) by blast
end (* context MinkowskiBetweenness *)
context MinkowskiSpacetime begin
lemma betw4_weak:
fixes a b c d :: 'a
assumes "[a;b;c] ∧ [a;c;d]
∨ [a;b;c] ∧ [b;c;d]
∨ [a;b;d] ∧ [b;c;d]
∨ [a;b;d] ∧ [b;c;d]"
shows "betw4 a b c d"
using abc_acd_bcd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?b;?c;?d]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) assms (*‹[a;b;c] ∧ [a;c;d] ∨ [a;b;c;d] ∨ [a;b;d] ∧ [b;c;d] ∨ [a;b;d] ∧ [b;c;d]›*) by blast
lemma betw4_sym:
fixes a::'a and b::'a and c::'a and d::'a
shows "betw4 a b c d ⟷ betw4 d c b a"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by blast
lemma abcd_dcba_only:
fixes a::'a and b::'a and c::'a and d::'a
assumes "[a;b;c;d]"
shows "¬[a;b;d;c]" "¬[a;c;b;d]" "¬[a;c;d;b]" "¬[a;d;b;c]" "¬[a;d;c;b]"
"¬[b;a;c;d]" "¬[b;a;d;c]" "¬[b;c;a;d]" "¬[b;c;d;a]" "¬[b;d;c;a]" "¬[b;d;a;c]"
"¬[c;a;b;d]" "¬[c;a;d;b]" "¬[c;b;a;d]" "¬[c;b;d;a]" "¬[c;d;a;b]" "¬[c;d;b;a]"
"¬[d;a;b;c]" "¬[d;a;c;b]" "¬[d;b;a;c]" "¬[d;b;c;a]" "¬[d;c;a;b]"
using abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) assms (*‹[a;b;c;d]›*) apply -
(*goals:
1. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [a;b;d;c]›
2. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [a;c;b;d]›
3. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [a;c;d;b]›
4. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [a;d;b;c]›
5. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [a;d;c;b]›
6. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [b;a;c;d]›
7. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [b;a;d;c]›
8. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [b;c;a;d]›
9. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [b;c;d;a]›
10. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [b;d;c;a]›
11. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [b;d;a;c]›
12. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [c;a;b;d]›
13. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [c;a;d;b]›
14. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [c;b;a;d]›
15. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [c;b;d;a]›
16. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [c;d;a;b]›
17. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [c;d;b;a]›
18. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [d;a;b;c]›
19. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [d;a;c;b]›
20. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [d;b;a;c]›
21. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [d;b;c;a]›
22. ‹⟦⋀a b c. [a;b;c] ⟹ ¬ [b;a;c]; ⋀a b c. [a;b;c] ⟹ ¬ [a;c;b]; ⋀a b c. [a;b;c] ⟹ ¬ [b;c;a]; ⋀a b c. [a;b;c] ⟹ ¬ [c;a;b]; [a;b;c;d]⟧ ⟹ ¬ [d;c;a;b]›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*discuss goal 3*)
apply blast
(*discuss goal 4*)
apply blast
(*discuss goal 5*)
apply blast
(*discuss goal 6*)
apply blast
(*discuss goal 7*)
apply blast
(*discuss goal 8*)
apply blast
(*discuss goal 9*)
apply blast
(*discuss goal 10*)
apply blast
(*discuss goal 11*)
apply blast
(*discuss goal 12*)
apply blast
(*discuss goal 13*)
apply blast
(*discuss goal 14*)
apply blast
(*discuss goal 15*)
apply blast
(*discuss goal 16*)
apply blast
(*discuss goal 17*)
apply blast
(*discuss goal 18*)
apply blast
(*discuss goal 19*)
apply blast
(*discuss goal 20*)
apply blast
(*discuss goal 21*)
apply blast
(*discuss goal 22*)
apply blast
(*proven 22 subgoals*) .
lemma some_betw4a:
fixes a::'a and b::'a and c::'a and d::'a and P
assumes "P∈𝒫" "a∈P" "b∈P" "c∈P" "d∈P" "a≠b ∧ a≠c ∧ a≠d ∧ b≠c ∧ b≠d ∧ c≠d"
and "¬([a;b;c;d] ∨ [a;b;d;c] ∨ [a;c;b;d] ∨ [a;c;d;b] ∨ [a;d;b;c] ∨ [a;d;c;b])"
shows "[b;a;c;d] ∨ [b;a;d;c] ∨ [b;c;a;d] ∨ [b;d;a;c] ∨ [c;a;b;d] ∨ [c;b;a;d]"
by (smt abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) assms (*‹P ∈ 𝒫› ‹a ∈ P› ‹b ∈ P› ‹c ∈ P› ‹d ∈ P› ‹a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d› ‹¬ ([a;b;c;d] ∨ [a;b;d;c] ∨ [a;c;b;d] ∨ [a;c;d;b] ∨ [a;d;b;c] ∨ [a;d;c;b])›*) some_betw_xor (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∧ ¬ [?b;?c;?a] ∧ ¬ [?c;?a;?b] ∨ [?b;?c;?a] ∧ ¬ [?a;?b;?c] ∧ ¬ [?c;?a;?b] ∨ [?c;?a;?b] ∧ ¬ [?a;?b;?c] ∧ ¬ [?b;?c;?a]›*))
lemma some_betw4b:
fixes a::'a and b::'a and c::'a and d::'a and P
assumes "P∈𝒫" "a∈P" "b∈P" "c∈P" "d∈P" "a≠b ∧ a≠c ∧ a≠d ∧ b≠c ∧ b≠d ∧ c≠d"
and "¬([b;a;c;d] ∨ [b;a;d;c] ∨ [b;c;a;d] ∨ [b;d;a;c] ∨ [c;a;b;d] ∨ [c;b;a;d])"
shows "[a;b;c;d] ∨ [a;b;d;c] ∨ [a;c;b;d] ∨ [a;c;d;b] ∨ [a;d;b;c] ∨ [a;d;c;b]"
by (smt abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) assms (*‹P ∈ 𝒫› ‹a ∈ P› ‹b ∈ P› ‹c ∈ P› ‹d ∈ P› ‹a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d› ‹¬ ([b;a;c;d] ∨ [b;a;d;c] ∨ [b;c;a;d] ∨ [b;d;a;c] ∨ [c;a;b;d] ∨ [c;b;a;d])›*) some_betw_xor (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∧ ¬ [?b;?c;?a] ∧ ¬ [?c;?a;?b] ∨ [?b;?c;?a] ∧ ¬ [?a;?b;?c] ∧ ¬ [?c;?a;?b] ∨ [?c;?a;?b] ∧ ¬ [?a;?b;?c] ∧ ¬ [?b;?c;?a]›*))
lemma abd_acd_abcdacbd:
fixes a::'a and b::'a and c::'a and d::'a
assumes abd: "[a;b;d]" and acd: "[a;c;d]" and "b≠c"
shows "[a;b;c;d] ∨ [a;c;b;d]"
proof (-)
(*goal: ‹[a;b;c;d] ∨ [a;c;b;d]›*)
obtain P where "P∈𝒫" "a∈P" "b∈P" "d∈P"
(*goal: ‹(⋀P. ⟦P ∈ 𝒫; a ∈ P; b ∈ P; d ∈ P⟧ ⟹ thesis) ⟹ thesis›*)
using abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) abd (*‹[a;b;d]›*) by blast
have "c∈P"
using ‹P ∈ 𝒫› (*‹P ∈ 𝒫›*) ‹a ∈ P› (*‹a ∈ P›*) ‹d ∈ P› (*‹(d::'a::type) ∈ (P::'a::type set)›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) acd (*‹[a::'a;c::'a;d::'a]›*) betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) by blast
have "¬[b;d;c]"
using abc_sym (*‹[?a::'a;?b::'a;?c::'a] ⟹ [?c;?b;?a]›*) abcd_dcba_only(5) (*‹[?a::'a::type;?b::'a::type;?c::'a::type;?d::'a::type] ⟹ ¬ [?a;?d;?c;?b]›*) abd (*‹[a;b;d]›*) acd (*‹[a;c;d]›*) by blast
hence "[b;c;d] ∨ [c;b;d]"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_sym (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ [?c;?b;?a]›*) abd (*‹[a;b;d]›*) acd (*‹[a;c;d]›*) assms(3) (*‹b ≠ c›*) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) by (metis ‹P ∈ 𝒫› ‹b ∈ P› ‹c ∈ P› ‹d ∈ P›)
thus "?thesis"
(*goal: ‹[a::'a;b::'a;c::'a;d::'a] ∨ [a;c;b;d]›*)
using abd (*‹[a;b;d]›*) acd (*‹[a::'a;c::'a;d::'a]›*) betw4_weak (*‹[?a;?b;?c] ∧ [?a;?c;?d] ∨ [?a;?b;?c;?d] ∨ [?a;?b;?d] ∧ [?b;?c;?d] ∨ [?a;?b;?d] ∧ [?b;?c;?d] ⟹ [?a;?b;?c;?d]›*) by blast
qed
end (*context MinkowskiSpacetime*)
subsection "WLOG for two general symmetric relations of two elements on a single path"
context MinkowskiBetweenness begin
text ‹
This first one is really just trying to get a hang of how to write these things.
If you have a relation that does not care which way round the ``endpoints'' (if $Q$ is the
interval-relation) go, then anything you want to prove about both undistinguished endpoints,
follows from a proof involving a single endpoint.
›
lemma wlog_sym_element:
assumes symmetric_rel: "⋀a b I. Q I a b ⟹ Q I b a"
and one_endpoint: "⋀a b x I. ⟦Q I a b; x=a⟧ ⟹ P x I"
shows other_endpoint: "⋀a b x I. ⟦Q I a b; x=b⟧ ⟹ P x I"
using assms (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a› ‹⟦Q ?I ?a ?b; ?x = ?a⟧ ⟹ P ?x ?I›*) by fastforce
text ‹
This one gives the most pertinent case split: a proof involving e.g. an element of an interval
must consider the edge case and the inside case.
›
lemma wlog_element:
assumes symmetric_rel: "⋀a b I. Q I a b ⟹ Q I b a"
and one_endpoint: "⋀a b x I. ⟦Q I a b; x=a⟧ ⟹ P x I"
and neither_endpoint: "⋀a b x I. ⟦Q I a b; x∈I; (x≠a ∧ x≠b)⟧ ⟹ P x I"
shows any_element: "⋀x I. ⟦x∈I; (∃a b. Q I a b)⟧ ⟹ P x I"
by (metis assms (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a› ‹⟦Q ?I ?a ?b; ?x = ?a⟧ ⟹ P ?x ?I› ‹⟦Q ?I ?a ?b; ?x ∈ ?I; ?x ≠ ?a ∧ ?x ≠ ?b⟧ ⟹ P ?x ?I›*))
text ‹
Summary of the two above. Use for early case splitting in proofs.
Doesn't need $P$ to be symmetric - the context in the conclusion is explicitly symmetric.
›
lemma wlog_two_sets_element:
assumes symmetric_Q: "⋀a b I. Q I a b ⟹ Q I b a"
and case_split: "⋀a b c d x I J. ⟦Q I a b; Q J c d⟧ ⟹
(x=a ∨ x=c ⟶ P x I J) ∧ (¬(x=a ∨ x=b ∨ x=c ∨ x=d) ⟶ P x I J)"
shows "⋀x I J. ⟦∃a b. Q I a b; ∃a b. Q J a b⟧ ⟹ P x I J"
by (smt case_split (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d⟧ ⟹ (?x = ?a ∨ ?x = ?c ⟶ P ?x ?I ?J) ∧ (¬ (?x = ?a ∨ ?x = ?b ∨ ?x = ?c ∨ ?x = ?d) ⟶ P ?x ?I ?J)›*) symmetric_Q (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a›*))
text ‹
Now we start on the actual result of interest. First we assume the events are all distinct,
and we deal with the degenerate possibilities after.
›
lemma wlog_endpoints_distinct1:
assumes symmetric_Q: "⋀a b I. Q I a b ⟹ Q I b a"
and "⋀I J a b c d. ⟦Q I a b; Q J c d; [a;b;c;d]⟧ ⟹ P I J"
shows "⋀I J a b c d. ⟦Q I a b; Q J c d;
[b;a;c;d] ∨ [a;b;d;c] ∨ [b;a;d;c] ∨ [d;c;b;a]⟧ ⟹ P I J"
by (meson abc_sym (*‹[?a::'a;?b::'a;?c::'a] ⟹ [?c;?b;?a]›*) assms( (*‹⟦(Q::'b ⇒ 'a ⇒ 'a ⇒ bool) (?I::'b) (?a::'a) (?b::'a); Q (?J::'b) (?c::'a) (?d::'a); [?a;?b;?c;?d]⟧ ⟹ (P::'b ⇒ 'b ⇒ bool) ?I ?J›*) 2) symmetric_Q (*‹(Q::'b ⇒ 'a ⇒ 'a ⇒ bool) (?I::'b) (?a::'a) (?b::'a) ⟹ Q ?I ?b ?a›*))
lemma wlog_endpoints_distinct2:
assumes symmetric_Q: "⋀a b I. Q I a b ⟹ Q I b a"
and "⋀I J a b c d. ⟦Q I a b; Q J c d; [a;c;b;d]⟧ ⟹ P I J"
shows "⋀I J a b c d. ⟦Q I a b; Q J c d;
[b;c;a;d] ∨ [a;d;b;c] ∨ [b;d;a;c] ∨ [d;b;c;a]⟧ ⟹ P I J"
by (meson abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) assms( (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; [?a;?c;?b;?d]⟧ ⟹ P ?I ?J›*) 2) symmetric_Q (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a›*))
lemma wlog_endpoints_distinct3:
assumes symmetric_Q: "⋀a b I. Q I a b ⟹ Q I b a"
and symmetric_P: "⋀I J. ⟦∃a b. Q I a b; ∃a b. Q J a b; P I J⟧ ⟹ P J I"
and "⋀I J a b c d. ⟦Q I a b; Q J c d; [a;c;d;b]⟧ ⟹ P I J"
shows "⋀I J a b c d. ⟦Q I a b; Q J c d;
[a;d;c;b] ∨ [b;c;d;a] ∨ [b;d;c;a] ∨ [c;a;b;d]⟧ ⟹ P I J"
by (meson assms (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a› ‹⟦∃a b. Q ?I a b; ∃a b. Q ?J a b; P ?I ?J⟧ ⟹ P ?J ?I› ‹⟦Q ?I ?a ?b; Q ?J ?c ?d; [?a;?c;?d;?b]⟧ ⟹ P ?I ?J›*))
lemma (in MinkowskiSpacetime) wlog_endpoints_distinct4:
fixes Q:: "('a set) ⇒ 'a ⇒ 'a ⇒ bool" (* cf ‹I = interval a b› *)
and P:: "('a set) ⇒ ('a set) ⇒ bool"
and A:: "('a set)" (* the path that takes the role of the real line *)
assumes path_A: "A∈𝒫"
and symmetric_Q: "⋀a b I. Q I a b ⟹ Q I b a"
and Q_implies_path: "⋀a b I. ⟦I⊆A; Q I a b⟧ ⟹ b∈A ∧ a∈A"
and symmetric_P: "⋀I J. ⟦∃a b. Q I a b; ∃a b. Q J a b; P I J⟧ ⟹ P J I"
and "⋀I J a b c d.
⟦Q I a b; Q J c d; I⊆A; J⊆A; [a;b;c;d] ∨ [a;c;b;d] ∨ [a;c;d;b]⟧ ⟹ P I J"
shows "⋀I J a b c d. ⟦Q I a b; Q J c d; I⊆A; J⊆A;
a≠b ∧ a≠c ∧ a≠d ∧ b≠c ∧ b≠d ∧ c≠d⟧ ⟹ P I J"
proof (-)
(*goal: ‹⋀I J a b c d. ⟦Q I a b; Q J c d; I ⊆ A; J ⊆ A; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d⟧ ⟹ P I J›*)
fix I and J and a and b and c and d
assume asm: "Q I a b" "Q J c d" "I ⊆ A" "J ⊆ A" "a≠b ∧ a≠c ∧ a≠d ∧ b≠c ∧ b≠d ∧ c≠d" (*‹(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (I::'a set) (a::'a) (b::'a)› ‹(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (J::'a set) (c::'a) (d::'a)› ‹(I::'a set) ⊆ (A::'a set)› ‹(J::'a set) ⊆ (A::'a set)› ‹(a::'a) ≠ (b::'a) ∧ a ≠ (c::'a) ∧ a ≠ (d::'a) ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d›*)
have endpoints_on_path: "a∈A" "b∈A" "c∈A" "d∈A"
using Q_implies_path (*‹⟦?I ⊆ A; Q ?I ?a ?b⟧ ⟹ ?b ∈ A ∧ ?a ∈ A›*) asm (*‹(Q::'a::type set ⇒ 'a::type ⇒ 'a::type ⇒ bool) (I::'a::type set) (a::'a::type) (b::'a::type)› ‹Q J c d› ‹I ⊆ A› ‹J ⊆ A› ‹a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d›*) apply -
(*goals:
1. ‹⟦⋀I a b. ⟦I ⊆ A; Q I a b⟧ ⟹ b ∈ A ∧ a ∈ A; Q I a b; Q J c d; I ⊆ A; J ⊆ A; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d⟧ ⟹ a ∈ A›
2. ‹⟦⋀I a b. ⟦I ⊆ A; Q I a b⟧ ⟹ b ∈ A ∧ a ∈ A; Q I a b; Q J c d; I ⊆ A; J ⊆ A; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d⟧ ⟹ b ∈ A›
3. ‹⟦⋀I a b. ⟦I ⊆ A; Q I a b⟧ ⟹ b ∈ A ∧ a ∈ A; Q I a b; Q J c d; I ⊆ A; J ⊆ A; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d⟧ ⟹ c ∈ A›
4. ‹⟦⋀I a b. ⟦I ⊆ A; Q I a b⟧ ⟹ b ∈ A ∧ a ∈ A; Q I a b; Q J c d; I ⊆ A; J ⊆ A; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d⟧ ⟹ d ∈ A›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*discuss goal 3*)
apply blast
(*discuss goal 4*)
apply blast
(*proven 4 subgoals*) .
show "P I J"
proof (cases)
(*goals:
1. ‹?P ⟹ P I J›
2. ‹¬ ?P ⟹ P I J›*)
assume "[b;a;c;d] ∨ [b;a;d;c] ∨ [b;c;a;d] ∨
[b;d;a;c] ∨ [c;a;b;d] ∨ [c;b;a;d]" (*‹[b::'a;a::'a;c::'a;d::'a] ∨ [b;a;d;c] ∨ [b;c;a;d] ∨ [b;d;a;c] ∨ [c;a;b;d] ∨ [c;b;a;d]›*)
then consider "[b;a;c;d]" | "[b;a;d;c]" | "[b;c;a;d]" | "[b;d;a;c]" | "[c;a;b;d]" | "[c;b;a;d]"
(*goal: ‹⟦[b;a;c;d] ⟹ thesis; [b;a;d;c] ⟹ thesis; [b;c;a;d] ⟹ thesis; [b;d;a;c] ⟹ thesis; [c;a;b;d] ⟹ thesis; [c;b;a;d] ⟹ thesis⟧ ⟹ thesis›*)
by linarith
thus "P I J"
apply cases
(*goals:
1. ‹[b::'a;a::'a;c::'a;d::'a] ⟹ (P::'a set ⇒ 'a set ⇒ bool) (I::'a set) (J::'a set)›
2. ‹[b::'a;a::'a;d::'a;c::'a] ⟹ (P::'a set ⇒ 'a set ⇒ bool) (I::'a set) (J::'a set)›
3. ‹[b::'a;c::'a;a::'a;d::'a] ⟹ (P::'a set ⇒ 'a set ⇒ bool) (I::'a set) (J::'a set)›
4. ‹[b::'a;d::'a;a::'a;c::'a] ⟹ (P::'a set ⇒ 'a set ⇒ bool) (I::'a set) (J::'a set)›
5. ‹[c::'a;a::'a;b::'a;d::'a] ⟹ (P::'a set ⇒ 'a set ⇒ bool) (I::'a set) (J::'a set)›
6. ‹[c::'a;b::'a;a::'a;d::'a] ⟹ (P::'a set ⇒ 'a set ⇒ bool) (I::'a set) (J::'a set)›
discuss goal 1*)
apply (metis(mono_tags) asm( (*‹Q I a b› ‹Q J c d› ‹I ⊆ A› ‹J ⊆ A›*) 1-4) assms( (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A; [?a;?b;?c;?d] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b]⟧ ⟹ P ?I ?J›*) 5) symmetric_Q (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a›*))
(*discuss goal 2*)
apply (metis(mono_tags) asm( (*‹Q I a b› ‹Q J c d› ‹I ⊆ A› ‹J ⊆ A›*) 1-4) assms( (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A; [?a;?b;?c;?d] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b]⟧ ⟹ P ?I ?J›*) 5) symmetric_Q (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a›*))
(*discuss goal 3*)
apply (metis(mono_tags) asm( (*‹Q I a b› ‹Q J c d› ‹I ⊆ A› ‹J ⊆ A›*) 1-4) assms( (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A; [?a;?b;?c;?d] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b]⟧ ⟹ P ?I ?J›*) 5) symmetric_Q (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a›*))
(*discuss goal 4*)
apply (metis(mono_tags) asm( (*‹Q I a b› ‹Q J c d› ‹I ⊆ A› ‹J ⊆ A›*) 1-4) assms( (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A; [?a;?b;?c;?d] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b]⟧ ⟹ P ?I ?J›*) 5) symmetric_Q (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a›*))
(*discuss goal 5*)
apply (metis asm( (*‹(Q::'a::type set ⇒ 'a::type ⇒ 'a::type ⇒ bool) (I::'a::type set) (a::'a::type) (b::'a::type)› ‹(Q::'a::type set ⇒ 'a::type ⇒ 'a::type ⇒ bool) (J::'a::type set) (c::'a::type) (d::'a::type)› ‹(I::'a::type set) ⊆ (A::'a::type set)› ‹(J::'a::type set) ⊆ (A::'a::type set)›*) 1-4) assms( (*‹⟦∃(a::'a::type) b::'a::type. (Q::'a::type set ⇒ 'a::type ⇒ 'a::type ⇒ bool) (?I::'a::type set) a b; ∃(a::'a::type) b::'a::type. Q (?J::'a::type set) a b; (P::'a::type set ⇒ 'a::type set ⇒ bool) ?I ?J⟧ ⟹ P ?J ?I› ‹⟦(Q::'a::type set ⇒ 'a::type ⇒ 'a::type ⇒ bool) (?I::'a::type set) (?a::'a::type) (?b::'a::type); Q (?J::'a::type set) (?c::'a::type) (?d::'a::type); ?I ⊆ (A::'a::type set); ?J ⊆ A; [?a;?b;?c;?d] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b]⟧ ⟹ (P::'a::type set ⇒ 'a::type set ⇒ bool) ?I ?J›*) 4,5))
(*discuss goal 6*)
apply (metis asm( (*‹Q I a b› ‹Q J c d› ‹I ⊆ A› ‹J ⊆ A›*) 1-4) assms( (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a› ‹⟦∃a b. Q ?I a b; ∃a b. Q ?J a b; P ?I ?J⟧ ⟹ P ?J ?I› ‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A; [?a;?b;?c;?d] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b]⟧ ⟹ P ?I ?J›*) 2,4,5) symmetric_Q (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a›*))
(*proven 6 subgoals*) .
next
(*goal: ‹¬ ([b;a;c;d] ∨ [b;a;d;c] ∨ [b;c;a;d] ∨ [b;d;a;c] ∨ [c;a;b;d] ∨ [c;b;a;d]) ⟹ P I J›*)
assume "¬([b;a;c;d] ∨ [b;a;d;c] ∨ [b;c;a;d] ∨
[b;d;a;c] ∨ [c;a;b;d] ∨ [c;b;a;d])" (*‹¬ ([b::'a;a::'a;c::'a;d::'a] ∨ [b;a;d;c] ∨ [b;c;a;d] ∨ [b;d;a;c] ∨ [c;a;b;d] ∨ [c;b;a;d])›*)
hence "[a;b;c;d] ∨ [a;b;d;c] ∨ [a;c;b;d] ∨
[a;c;d;b] ∨ [a;d;b;c] ∨ [a;d;c;b]"
using some_betw4b[where P = A and a = a and b = b and c = c and d = d] (*‹⟦A ∈ 𝒫; a ∈ A; b ∈ A; c ∈ A; d ∈ A; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d; ¬ ([b;a;c;d] ∨ [b;a;d;c] ∨ [b;c;a;d] ∨ [b;d;a;c] ∨ [c;a;b;d] ∨ [c;b;a;d])⟧ ⟹ [a;b;c;d] ∨ [a;b;d;c] ∨ [a;c;b;d] ∨ [a;c;d;b] ∨ [a;d;b;c] ∨ [a;d;c;b]›*) using endpoints_on_path (*‹a ∈ A› ‹b ∈ A› ‹(c::'a) ∈ (A::'a set)› ‹(d::'a) ∈ (A::'a set)›*) asm (*‹Q I a b› ‹Q J c d› ‹I ⊆ A› ‹(J::'a set) ⊆ (A::'a set)› ‹(a::'a::type) ≠ (b::'a::type) ∧ a ≠ (c::'a::type) ∧ a ≠ (d::'a::type) ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d›*) path_A (*‹(A::'a set) ∈ (𝒫::'a set set)›*) by simp
then consider "[a;b;c;d]" | "[a;b;d;c]" | "[a;c;b;d]" | "[a;c;d;b]" | "[a;d;b;c]" | "[a;d;c;b]"
(*goal: ‹⟦[a;b;c;d] ⟹ thesis; [a;b;d;c] ⟹ thesis; [a;c;b;d] ⟹ thesis; [a;c;d;b] ⟹ thesis; [a;d;b;c] ⟹ thesis; [a;d;c;b] ⟹ thesis⟧ ⟹ thesis›*)
by linarith
thus "P I J"
apply cases
(*goals:
1. ‹[a;b;c;d] ⟹ P I J›
2. ‹[a;b;d;c] ⟹ P I J›
3. ‹[a;c;b;d] ⟹ P I J›
4. ‹[a;c;d;b] ⟹ P I J›
5. ‹[a;d;b;c] ⟹ P I J›
6. ‹[a;d;c;b] ⟹ P I J›
discuss goal 1*)
apply (metis asm( (*‹Q I a b› ‹Q J c d› ‹I ⊆ A› ‹J ⊆ A›*) 1-4) assms( (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A; [?a;?b;?c;?d] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b]⟧ ⟹ P ?I ?J›*) 5) symmetric_Q (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a›*))
(*discuss goal 2*)
apply (metis asm( (*‹Q I a b› ‹Q J c d› ‹I ⊆ A› ‹J ⊆ A›*) 1-4) assms( (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A; [?a;?b;?c;?d] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b]⟧ ⟹ P ?I ?J›*) 5) symmetric_Q (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a›*))
(*discuss goal 3*)
apply (metis asm( (*‹(Q::'a::type set ⇒ 'a::type ⇒ 'a::type ⇒ bool) (I::'a::type set) (a::'a::type) (b::'a::type)› ‹(Q::'a::type set ⇒ 'a::type ⇒ 'a::type ⇒ bool) (J::'a::type set) (c::'a::type) (d::'a::type)› ‹(I::'a::type set) ⊆ (A::'a::type set)› ‹(J::'a::type set) ⊆ (A::'a::type set)›*) 1-4) assms( (*‹⟦(Q::'a::type set ⇒ 'a::type ⇒ 'a::type ⇒ bool) (?I::'a::type set) (?a::'a::type) (?b::'a::type); Q (?J::'a::type set) (?c::'a::type) (?d::'a::type); ?I ⊆ (A::'a::type set); ?J ⊆ A; [?a;?b;?c;?d] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b]⟧ ⟹ (P::'a::type set ⇒ 'a::type set ⇒ bool) ?I ?J›*) 5) symmetric_Q (*‹(Q::'a::type set ⇒ 'a::type ⇒ 'a::type ⇒ bool) (?I::'a::type set) (?a::'a::type) (?b::'a::type) ⟹ Q ?I ?b ?a›*))
(*discuss goal 4*)
apply (metis asm( (*‹Q I a b› ‹Q J c d› ‹I ⊆ A› ‹J ⊆ A›*) 1-4) assms( (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A; [?a;?b;?c;?d] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b]⟧ ⟹ P ?I ?J›*) 5) symmetric_Q (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a›*))
(*discuss goal 5*)
apply (metis asm( (*‹Q I a b› ‹Q J c d› ‹I ⊆ A› ‹J ⊆ A›*) 1-4) assms( (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A; [?a;?b;?c;?d] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b]⟧ ⟹ P ?I ?J›*) 5) symmetric_Q (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a›*))
(*discuss goal 6*)
apply (metis asm( (*‹(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (I::'a set) (a::'a) (b::'a)› ‹(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (J::'a set) (c::'a) (d::'a)› ‹(I::'a set) ⊆ (A::'a set)› ‹(J::'a set) ⊆ (A::'a set)›*) 1-4) assms( (*‹⟦(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (?I::'a set) (?a::'a) (?b::'a); Q (?J::'a set) (?c::'a) (?d::'a); ?I ⊆ (A::'a set); ?J ⊆ A; [?a;?b;?c;?d] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b]⟧ ⟹ (P::'a set ⇒ 'a set ⇒ bool) ?I ?J›*) 5) symmetric_Q (*‹(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (?I::'a set) (?a::'a) (?b::'a) ⟹ Q ?I ?b ?a›*))
(*proven 6 subgoals*) .
qed
qed
lemma (in MinkowskiSpacetime) wlog_endpoints_distinct':
assumes "A ∈ 𝒫"
and "⋀a b I. Q I a b ⟹ Q I b a"
and "⋀a b I. ⟦I ⊆ A; Q I a b⟧ ⟹ a ∈ A"
and "⋀I J. ⟦∃a b. Q I a b; ∃a b. Q J a b; P I J⟧ ⟹ P J I"
and "⋀I J a b c d.
⟦Q I a b; Q J c d; I⊆A; J⊆A; betw4 a b c d ∨ betw4 a c b d ∨ betw4 a c d b⟧ ⟹ P I J"
and "Q I a b"
and "Q J c d"
and "I ⊆ A"
and "J ⊆ A"
and "a ≠ b" "a ≠ c" "a ≠ d" "b ≠ c" "b ≠ d" "c ≠ d"
shows "P I J"
proof (-)
(*goal: ‹P I J›*)
{
let ?R = "(λI. (∃a b. Q I a b))"
have "⋀I J. ⟦?R I; ?R J; P I J⟧ ⟹ P J I"
using assms(4) (*‹⟦∃a b. Q ?I a b; ∃a b. Q ?J a b; P ?I ?J⟧ ⟹ P ?J ?I›*) by blast
}
thus "?thesis"
(*goal: ‹P I J›*)
using wlog_endpoints_distinct4[where P = P and Q = Q and A = A and I = I and J = J and a = a and b = b and c = c and d = d] (*‹⟦A ∈ 𝒫; ⋀a b I. Q I a b ⟹ Q I b a; ⋀a b I. ⟦I ⊆ A; Q I a b⟧ ⟹ b ∈ A ∧ a ∈ A; ⋀I J. ⟦∃a b. Q I a b; ∃a b. Q J a b; P I J⟧ ⟹ P J I; ⋀I J a b c d. ⟦Q I a b; Q J c d; I ⊆ A; J ⊆ A; [a;b;c;d] ∨ [a;c;b;d] ∨ [a;c;d;b]⟧ ⟹ P I J; Q I a b; Q J c d; I ⊆ A; J ⊆ A; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d⟧ ⟹ P I J›*) by (smt assms( (*‹(A::'a set) ∈ (𝒫::'a set set)› ‹(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (?I::'a set) (?a::'a) (?b::'a) ⟹ Q ?I ?b ?a› ‹⟦(?I::'a set) ⊆ (A::'a set); (Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) ?I (?a::'a) (?b::'a)⟧ ⟹ ?a ∈ A› ‹⟦(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (?I::'a set) (?a::'a) (?b::'a); Q (?J::'a set) (?c::'a) (?d::'a); ?I ⊆ (A::'a set); ?J ⊆ A; [?a;?b;?c;?d] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b]⟧ ⟹ (P::'a set ⇒ 'a set ⇒ bool) ?I ?J› ‹(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (I::'a set) (a::'a) (b::'a)› ‹(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (J::'a set) (c::'a) (d::'a)› ‹(I::'a set) ⊆ (A::'a set)› ‹(J::'a set) ⊆ (A::'a set)› ‹(a::'a) ≠ (b::'a)› ‹(a::'a) ≠ (c::'a)› ‹(a::'a) ≠ (d::'a)› ‹(b::'a) ≠ (c::'a)› and more 2 facts*) 1-3,5-))
qed
lemma (in MinkowskiSpacetime) wlog_endpoints_distinct:
assumes path_A: "A∈𝒫"
and symmetric_Q: "⋀a b I. Q I a b ⟹ Q I b a"
and Q_implies_path: "⋀a b I. ⟦I⊆A; Q I a b⟧ ⟹ b∈A ∧ a∈A"
and symmetric_P: "⋀I J. ⟦∃a b. Q I a b; ∃a b. Q J a b; P I J⟧ ⟹ P J I"
and "⋀I J a b c d.
⟦Q I a b; Q J c d; I⊆A; J⊆A; [a;b;c;d] ∨ [a;c;b;d] ∨ [a;c;d;b]⟧ ⟹ P I J"
shows "⋀I J a b c d. ⟦Q I a b; Q J c d; I⊆A; J⊆A;
a≠b ∧ a≠c ∧ a≠d ∧ b≠c ∧ b≠d ∧ c≠d⟧ ⟹ P I J"
by (smt (verit, ccfv_SIG) assms (*‹A ∈ 𝒫› ‹Q ?I ?a ?b ⟹ Q ?I ?b ?a› ‹⟦?I ⊆ A; Q ?I ?a ?b⟧ ⟹ ?b ∈ A ∧ ?a ∈ A› ‹⟦∃a b. Q ?I a b; ∃a b. Q ?J a b; P ?I ?J⟧ ⟹ P ?J ?I› ‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A; [?a;?b;?c;?d] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b]⟧ ⟹ P ?I ?J›*) some_betw4b (*‹⟦?P ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?c ∈ ?P; ?d ∈ ?P; ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?a ≠ ?d ∧ ?b ≠ ?c ∧ ?b ≠ ?d ∧ ?c ≠ ?d; ¬ ([?b;?a;?c;?d] ∨ [?b;?a;?d;?c] ∨ [?b;?c;?a;?d] ∨ [?b;?d;?a;?c] ∨ [?c;?a;?b;?d] ∨ [?c;?b;?a;?d])⟧ ⟹ [?a;?b;?c;?d] ∨ [?a;?b;?d;?c] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b] ∨ [?a;?d;?b;?c] ∨ [?a;?d;?c;?b]›*))
lemma wlog_endpoints_degenerate1:
assumes symmetric_Q: "⋀a b I. Q I a b ⟹ Q I b a"
and symmetric_P: "⋀I J. ⟦∃a b. Q I a b; ∃a b. Q I a b; P I J⟧ ⟹ P J I"
(* two singleton intervals *)
and two: "⋀I J a b c d. ⟦Q I a b; Q J c d;
(a=b ∧ b=c ∧ c=d) ∨ (a=b ∧ b≠c ∧ c=d)⟧ ⟹ P I J"
(* one singleton interval *)
and one: "⋀I J a b c d. ⟦Q I a b; Q J c d;
(a=b ∧ b=c ∧ c≠d) ∨ (a=b ∧ b≠c ∧ c≠d ∧ a≠d)⟧ ⟹ P I J"
(* no singleton interval - the all-distinct case is a separate theorem *)
and no: "⋀I J a b c d. ⟦Q I a b; Q J c d;
(a≠b ∧ b≠c ∧ c≠d ∧ a=d) ∨ (a≠b ∧ b=c ∧ c≠d ∧ a=d)⟧ ⟹ P I J"
shows "⋀I J a b c d. ⟦Q I a b; Q J c d; ¬(a≠b ∧ b≠c ∧ c≠d ∧ a≠d ∧ a≠c ∧ b≠d)⟧ ⟹ P I J"
by (metis assms (*‹(Q::'c ⇒ 'b ⇒ 'b ⇒ bool) (?I::'c) (?a::'b) (?b::'b) ⟹ Q ?I ?b ?a› ‹⟦∃(a::'b) b::'b. (Q::'c ⇒ 'b ⇒ 'b ⇒ bool) (?I::'c) a b; ∃(a::'b) b::'b. Q ?I a b; (P::'c ⇒ 'c ⇒ bool) ?I (?J::'c)⟧ ⟹ P ?J ?I› ‹⟦(Q::'c ⇒ 'b ⇒ 'b ⇒ bool) (?I::'c) (?a::'b) (?b::'b); Q (?J::'c) (?c::'b) (?d::'b); ?a = ?b ∧ ?b = ?c ∧ ?c = ?d ∨ ?a = ?b ∧ ?b ≠ ?c ∧ ?c = ?d⟧ ⟹ (P::'c ⇒ 'c ⇒ bool) ?I ?J› ‹⟦(Q::'c ⇒ 'b ⇒ 'b ⇒ bool) (?I::'c) (?a::'b) (?b::'b); Q (?J::'c) (?c::'b) (?d::'b); ?a = ?b ∧ ?b = ?c ∧ ?c ≠ ?d ∨ ?a = ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d⟧ ⟹ (P::'c ⇒ 'c ⇒ bool) ?I ?J› ‹⟦(Q::'c ⇒ 'b ⇒ 'b ⇒ bool) (?I::'c) (?a::'b) (?b::'b); Q (?J::'c) (?c::'b) (?d::'b); ?a ≠ ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a = ?d ∨ ?a ≠ ?b ∧ ?b = ?c ∧ ?c ≠ ?d ∧ ?a = ?d⟧ ⟹ (P::'c ⇒ 'c ⇒ bool) ?I ?J›*))
lemma wlog_endpoints_degenerate2:
assumes symmetric_Q: "⋀a b I. Q I a b ⟹ Q I b a"
and Q_implies_path: "⋀a b I A. ⟦I⊆A; A∈𝒫; Q I a b⟧ ⟹ b∈A ∧ a∈A"
and symmetric_P: "⋀I J. ⟦∃a b. Q I a b; ∃a b. Q J a b; P I J⟧ ⟹ P J I"
and "⋀I J a b c d A. ⟦Q I a b; Q J c d; I⊆A; J⊆A; A∈𝒫;
[a;b;c] ∧ a=d⟧ ⟹ P I J"
and "⋀I J a b c d A. ⟦Q I a b; Q J c d; I⊆A; J⊆A; A∈𝒫;
[b;a;c] ∧ a=d⟧ ⟹ P I J"
shows "⋀I J a b c d A. ⟦Q I a b; Q J c d; I⊆A; J⊆A; A∈𝒫;
a≠b ∧ b≠c ∧ c≠d ∧ a=d⟧ ⟹ P I J"
proof (-)
(*goal: ‹⋀I J a b c d A. ⟦Q I a b; Q J c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a = d⟧ ⟹ P I J›*)
have last_case: "⋀I J a b c d A. ⟦Q I a b; Q J c d; I⊆A; J⊆A; A∈𝒫;
[b;c;a] ∧ a=d⟧ ⟹ P I J"
using assms(1,3-5) (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a› ‹⟦∃(a::'a) b::'a. (Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (?I::'a set) a b; ∃(a::'a) b::'a. Q (?J::'a set) a b; (P::'a set ⇒ 'a set ⇒ bool) ?I ?J⟧ ⟹ P ?J ?I› ‹⟦(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (?I::'a set) (?a::'a) (?b::'a); Q (?J::'a set) (?c::'a) (?d::'a); ?I ⊆ (?A::'a set); ?J ⊆ ?A; ?A ∈ (𝒫::'a set set); [?a;?b;?c] ∧ ?a = ?d⟧ ⟹ (P::'a set ⇒ 'a set ⇒ bool) ?I ?J› ‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ ?A; ?J ⊆ ?A; ?A ∈ 𝒫; [?b;?a;?c] ∧ ?a = ?d⟧ ⟹ P ?I ?J›*) by (metis abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*))
thus "⋀I J a b c d A. ⟦Q I a b; Q J c d; I⊆A; J⊆A; A∈𝒫;
a≠b ∧ b≠c ∧ c≠d ∧ a=d⟧ ⟹ P I J"
by (smt (z3) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) assms( (*‹⟦?I ⊆ ?A; ?A ∈ 𝒫; Q ?I ?a ?b⟧ ⟹ ?b ∈ ?A ∧ ?a ∈ ?A› ‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ ?A; ?J ⊆ ?A; ?A ∈ 𝒫; [?a;?b;?c] ∧ ?a = ?d⟧ ⟹ P ?I ?J› ‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ ?A; ?J ⊆ ?A; ?A ∈ 𝒫; [?b;?a;?c] ∧ ?a = ?d⟧ ⟹ P ?I ?J›*) 2,4,5) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*))
qed
lemma wlog_endpoints_degenerate:
assumes path_A: "A∈𝒫"
and symmetric_Q: "⋀a b I. Q I a b ⟹ Q I b a"
and Q_implies_path: "⋀a b I. ⟦I⊆A; Q I a b⟧ ⟹ b∈A ∧ a∈A"
and symmetric_P: "⋀I J. ⟦∃a b. Q I a b; ∃a b. Q J a b; P I J⟧ ⟹ P J I"
and "⋀I J a b c d. ⟦Q I a b; Q J c d; I⊆A; J⊆A⟧
⟹ ((a=b ∧ b=c ∧ c=d) ⟶ P I J) ∧ ((a=b ∧ b≠c ∧ c=d) ⟶ P I J)
∧ ((a=b ∧ b=c ∧ c≠d) ⟶ P I J) ∧ ((a=b ∧ b≠c ∧ c≠d ∧ a≠d) ⟶ P I J)
∧ ((a≠b ∧ b=c ∧ c≠d ∧ a=d) ⟶ P I J)
∧ (([a;b;c] ∧ a=d) ⟶ P I J) ∧ (([b;a;c] ∧ a=d) ⟶ P I J)"
shows "⋀I J a b c d. ⟦Q I a b; Q J c d; I⊆A; J⊆A;
¬(a≠b ∧ b≠c ∧ c≠d ∧ a≠d ∧ a≠c ∧ b≠d)⟧ ⟹ P I J"
proof (-)
(*goal: ‹⋀I J a b c d. ⟦Q I a b; Q J c d; I ⊆ A; J ⊆ A; ¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)⟧ ⟹ P I J›*)
text ‹We first extract some of the assumptions of this lemma into the form
of other WLOG lemmas' assumptions.›
have ord1: "⋀I J a b c d. ⟦Q I a b; Q J c d; I⊆A; J⊆A;
[a;b;c] ∧ a=d⟧ ⟹ P I J"
using assms(5) (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A⟧ ⟹ (?a = ?b ∧ ?b = ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b = ?c ∧ ?c ≠ ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ⟶ P ?I ?J) ∧ (?a ≠ ?b ∧ ?b = ?c ∧ ?c ≠ ?d ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?a;?b;?c] ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?b;?a;?c] ∧ ?a = ?d ⟶ P ?I ?J)›*) by auto
have ord2: "⋀I J a b c d. ⟦Q I a b; Q J c d; I⊆A; J⊆A;
[b;a;c] ∧ a=d⟧ ⟹ P I J"
using assms(5) (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A⟧ ⟹ (?a = ?b ∧ ?b = ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b = ?c ∧ ?c ≠ ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ⟶ P ?I ?J) ∧ (?a ≠ ?b ∧ ?b = ?c ∧ ?c ≠ ?d ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?a;?b;?c] ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?b;?a;?c] ∧ ?a = ?d ⟶ P ?I ?J)›*) by auto
have last_case: "⋀I J a b c d. ⟦Q I a b; Q J c d; I⊆A; J⊆A;
a≠b ∧ b≠c ∧ c≠d ∧ a=d⟧ ⟹ P I J"
using ord1 (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A; [?a;?b;?c] ∧ ?a = ?d⟧ ⟹ P ?I ?J›*) ord2 (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A; [?b;?a;?c] ∧ ?a = ?d⟧ ⟹ P ?I ?J›*) wlog_endpoints_degenerate2 (*‹⟦⋀a b I. ?Q I a b ⟹ ?Q I b a; ⋀a b I A. ⟦I ⊆ A; A ∈ 𝒫; ?Q I a b⟧ ⟹ b ∈ A ∧ a ∈ A; ⋀I J. ⟦∃a b. ?Q I a b; ∃a b. ?Q J a b; ?P I J⟧ ⟹ ?P J I; ⋀I J a b c d A. ⟦?Q I a b; ?Q J c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; [a;b;c] ∧ a = d⟧ ⟹ ?P I J; ⋀I J a b c d A. ⟦?Q I a b; ?Q J c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; [b;a;c] ∧ a = d⟧ ⟹ ?P I J; ?Q ?I ?a ?b; ?Q ?J ?c ?d; ?I ⊆ ?A; ?J ⊆ ?A; ?A ∈ 𝒫; ?a ≠ ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a = ?d⟧ ⟹ ?P ?I ?J›*) symmetric_P (*‹⟦∃a b. Q ?I a b; ∃a b. Q ?J a b; P ?I ?J⟧ ⟹ P ?J ?I›*) symmetric_Q (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a›*) Q_implies_path (*‹⟦?I ⊆ A; Q ?I ?a ?b⟧ ⟹ ?b ∈ A ∧ ?a ∈ A›*) path_A (*‹A ∈ 𝒫›*) by (metis abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*))
show "⋀I J a b c d. ⟦Q I a b; Q J c d; I⊆A; J⊆A;
¬(a≠b ∧ b≠c ∧ c≠d ∧ a≠d ∧ a≠c ∧ b≠d)⟧ ⟹ P I J"
proof (-)
(*goal: ‹⋀I J a b c d. ⟦Q I a b; Q J c d; I ⊆ A; J ⊆ A; ¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)⟧ ⟹ P I J›*)
text ‹Fix the sets on the path, and obtain the assumptions of ‹wlog_endpoints_degenerate1›.›
fix I and J
assume asm1: "I⊆A" "J⊆A" (*‹(I::'a set) ⊆ (A::'a set)› ‹(J::'a set) ⊆ (A::'a set)›*)
have two: "⋀a b c d. ⟦Q I a b; Q J c d; a=b ∧ b=c ∧ c=d⟧ ⟹ P I J" "⋀a b c d. ⟦Q I a b; Q J c d; a=b ∧ b≠c ∧ c=d⟧ ⟹ P I J"
using ‹J ⊆ A› (*‹J ⊆ A›*) ‹I ⊆ A› (*‹(I::'a set) ⊆ (A::'a set)›*) path_A (*‹(A::'a::type set) ∈ (𝒫::'a::type set set)›*) assms(5) (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A⟧ ⟹ (?a = ?b ∧ ?b = ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b = ?c ∧ ?c ≠ ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ⟶ P ?I ?J) ∧ (?a ≠ ?b ∧ ?b = ?c ∧ ?c ≠ ?d ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?a;?b;?c] ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?b;?a;?c] ∧ ?a = ?d ⟶ P ?I ?J)›*) apply -
(*goals:
1. ‹⋀a b c d. ⟦Q I a b; Q J c d; a = b ∧ b = c ∧ c = d; J ⊆ A; I ⊆ A; A ∈ 𝒫; ⋀I a b J c d. ⟦Q I a b; Q J c d; I ⊆ A; J ⊆ A⟧ ⟹ (a = b ∧ b = c ∧ c = d ⟶ P I J) ∧ (a = b ∧ b ≠ c ∧ c = d ⟶ P I J) ∧ (a = b ∧ b = c ∧ c ≠ d ⟶ P I J) ∧ (a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟶ P I J) ∧ (a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟶ P I J) ∧ ([a;b;c] ∧ a = d ⟶ P I J) ∧ ([b;a;c] ∧ a = d ⟶ P I J)⟧ ⟹ P I J›
2. ‹⋀a b c d. ⟦Q I a b; Q J c d; a = b ∧ b ≠ c ∧ c = d; J ⊆ A; I ⊆ A; A ∈ 𝒫; ⋀I a b J c d. ⟦Q I a b; Q J c d; I ⊆ A; J ⊆ A⟧ ⟹ (a = b ∧ b = c ∧ c = d ⟶ P I J) ∧ (a = b ∧ b ≠ c ∧ c = d ⟶ P I J) ∧ (a = b ∧ b = c ∧ c ≠ d ⟶ P I J) ∧ (a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟶ P I J) ∧ (a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟶ P I J) ∧ ([a;b;c] ∧ a = d ⟶ P I J) ∧ ([b;a;c] ∧ a = d ⟶ P I J)⟧ ⟹ P I J›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
have one: "⋀ a b c d. ⟦Q I a b; Q J c d; a=b ∧ b=c ∧ c≠d⟧ ⟹ P I J" "⋀ a b c d. ⟦Q I a b; Q J c d; a=b ∧ b≠c ∧ c≠d ∧ a≠d⟧ ⟹ P I J"
using ‹I ⊆ A› (*‹I ⊆ A›*) ‹J ⊆ A› (*‹J ⊆ A›*) path_A (*‹A ∈ 𝒫›*) assms(5) (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A⟧ ⟹ (?a = ?b ∧ ?b = ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b = ?c ∧ ?c ≠ ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ⟶ P ?I ?J) ∧ (?a ≠ ?b ∧ ?b = ?c ∧ ?c ≠ ?d ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?a;?b;?c] ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?b;?a;?c] ∧ ?a = ?d ⟶ P ?I ?J)›*) apply -
(*goals:
1. ‹⋀a b c d. ⟦Q I a b; Q J c d; a = b ∧ b = c ∧ c ≠ d; I ⊆ A; J ⊆ A; A ∈ 𝒫; ⋀I a b J c d. ⟦Q I a b; Q J c d; I ⊆ A; J ⊆ A⟧ ⟹ (a = b ∧ b = c ∧ c = d ⟶ P I J) ∧ (a = b ∧ b ≠ c ∧ c = d ⟶ P I J) ∧ (a = b ∧ b = c ∧ c ≠ d ⟶ P I J) ∧ (a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟶ P I J) ∧ (a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟶ P I J) ∧ ([a;b;c] ∧ a = d ⟶ P I J) ∧ ([b;a;c] ∧ a = d ⟶ P I J)⟧ ⟹ P I J›
2. ‹⋀a b c d. ⟦Q I a b; Q J c d; a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d; I ⊆ A; J ⊆ A; A ∈ 𝒫; ⋀I a b J c d. ⟦Q I a b; Q J c d; I ⊆ A; J ⊆ A⟧ ⟹ (a = b ∧ b = c ∧ c = d ⟶ P I J) ∧ (a = b ∧ b ≠ c ∧ c = d ⟶ P I J) ∧ (a = b ∧ b = c ∧ c ≠ d ⟶ P I J) ∧ (a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟶ P I J) ∧ (a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟶ P I J) ∧ ([a;b;c] ∧ a = d ⟶ P I J) ∧ ([b;a;c] ∧ a = d ⟶ P I J)⟧ ⟹ P I J›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
have no: "⋀ a b c d. ⟦Q I a b; Q J c d; a≠b ∧ b≠c ∧ c≠d ∧ a=d⟧ ⟹ P I J" "⋀ a b c d. ⟦Q I a b; Q J c d; a≠b ∧ b=c ∧ c≠d ∧ a=d⟧ ⟹ P I J"
using ‹I ⊆ A› (*‹(I::'a set) ⊆ (A::'a set)›*) ‹J ⊆ A› (*‹J ⊆ A›*) path_A (*‹A ∈ 𝒫›*) last_case (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A; ?a ≠ ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a = ?d⟧ ⟹ P ?I ?J›*) apply blast
(*top goal: ‹⋀a b c d. ⟦Q I a b; Q J c d; a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a = d⟧ ⟹ P I J› and 1 goal remains*)
using ‹I ⊆ A› (*‹I ⊆ A›*) ‹J ⊆ A› (*‹J ⊆ A›*) path_A (*‹(A::'a set) ∈ (𝒫::'a set set)›*) assms(5) (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A⟧ ⟹ (?a = ?b ∧ ?b = ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b = ?c ∧ ?c ≠ ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ⟶ P ?I ?J) ∧ (?a ≠ ?b ∧ ?b = ?c ∧ ?c ≠ ?d ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?a;?b;?c] ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?b;?a;?c] ∧ ?a = ?d ⟶ P ?I ?J)›*) by auto
text ‹Now unwrap the remaining object logic and finish the proof.›
fix a and b and c and d
assume asm2: "Q I a b" "Q J c d" "¬(a≠b ∧ b≠c ∧ c≠d ∧ a≠d ∧ a≠c ∧ b≠d)" (*‹(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (I::'a set) (a::'a) (b::'a)› ‹(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (J::'a set) (c::'a) (d::'a)› ‹¬ ((a::'a) ≠ (b::'a) ∧ b ≠ (c::'a) ∧ c ≠ (d::'a) ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)›*)
show "P I J"
using two[where a = a and b = b and c = c and d = d] (*‹⟦Q I a b; Q J c d; a = b ∧ b = c ∧ c = d⟧ ⟹ P I J› ‹⟦(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (I::'a set) (a::'a) (b::'a); Q (J::'a set) (c::'a) (d::'a); a = b ∧ b ≠ c ∧ c = d⟧ ⟹ (P::'a set ⇒ 'a set ⇒ bool) I J›*) using one[where a = a and b = b and c = c and d = d] (*‹⟦Q I a b; Q J c d; a = b ∧ b = c ∧ c ≠ d⟧ ⟹ P I J› ‹⟦Q I a b; Q J c d; a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d⟧ ⟹ P I J›*) using no[where a = a and b = b and c = c and d = d] (*‹⟦Q I a b; Q J c d; a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a = d⟧ ⟹ P I J› ‹⟦Q I a b; Q J c d; a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d⟧ ⟹ P I J›*) using wlog_endpoints_degenerate1[where I = I and J = J and a = a and b = b and c = c and d = d and P = P and Q = Q] (*‹⟦⋀a b I. Q I a b ⟹ Q I b a; ⋀I J. ⟦∃a b. Q I a b; ∃a b. Q I a b; P I J⟧ ⟹ P J I; ⋀I J a b c d. ⟦Q I a b; Q J c d; a = b ∧ b = c ∧ c = d ∨ a = b ∧ b ≠ c ∧ c = d⟧ ⟹ P I J; ⋀I J a b c d. ⟦Q I a b; Q J c d; a = b ∧ b = c ∧ c ≠ d ∨ a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d⟧ ⟹ P I J; ⋀I J a b c d. ⟦Q I a b; Q J c d; a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a = d ∨ a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d⟧ ⟹ P I J; Q I a b; Q J c d; ¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)⟧ ⟹ P I J›*) using asm1 (*‹I ⊆ A› ‹J ⊆ A›*) asm2 (*‹Q I a b› ‹Q J c d› ‹¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)›*) symmetric_P (*‹⟦∃a b. Q ?I a b; ∃a b. Q ?J a b; P ?I ?J⟧ ⟹ P ?J ?I›*) last_case (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A; ?a ≠ ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a = ?d⟧ ⟹ P ?I ?J›*) assms(5) (*‹⟦(Q::'a::type set ⇒ 'a::type ⇒ 'a::type ⇒ bool) (?I::'a::type set) (?a::'a::type) (?b::'a::type); Q (?J::'a::type set) (?c::'a::type) (?d::'a::type); ?I ⊆ (A::'a::type set); ?J ⊆ A⟧ ⟹ (?a = ?b ∧ ?b = ?c ∧ ?c = ?d ⟶ (P::'a::type set ⇒ 'a::type set ⇒ bool) ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b = ?c ∧ ?c ≠ ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ⟶ P ?I ?J) ∧ (?a ≠ ?b ∧ ?b = ?c ∧ ?c ≠ ?d ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?a;?b;?c] ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?b;?a;?c] ∧ ?a = ?d ⟶ P ?I ?J)›*) symmetric_Q (*‹Q ?I ?a ?b ⟹ Q ?I ?b ?a›*) by smt
qed
qed
lemma (in MinkowskiSpacetime) wlog_intro:
assumes path_A: "A∈𝒫"
and symmetric_Q: "⋀a b I. Q I a b ⟹ Q I b a"
and Q_implies_path: "⋀a b I. ⟦I⊆A; Q I a b⟧ ⟹ b∈A ∧ a∈A"
and symmetric_P: "⋀I J. ⟦∃a b. Q I a b; ∃c d. Q J c d; P I J⟧ ⟹ P J I"
and essential_cases: "⋀I J a b c d. ⟦Q I a b; Q J c d; I⊆A; J⊆A⟧
⟹ ((a=b ∧ b=c ∧ c=d) ⟶ P I J)
∧ ((a=b ∧ b≠c ∧ c=d) ⟶ P I J)
∧ ((a=b ∧ b=c ∧ c≠d) ⟶ P I J)
∧ ((a=b ∧ b≠c ∧ c≠d ∧ a≠d) ⟶ P I J)
∧ ((a≠b ∧ b=c ∧ c≠d ∧ a=d) ⟶ P I J)
∧ (([a;b;c] ∧ a=d) ⟶ P I J)
∧ (([b;a;c] ∧ a=d) ⟶ P I J)
∧ ([a;b;c;d] ⟶ P I J)
∧ ([a;c;b;d] ⟶ P I J)
∧ ([a;c;d;b] ⟶ P I J)"
and antecedants: "Q I a b" "Q J c d" "I⊆A" "J⊆A"
shows "P I J"
using essential_cases (*‹⟦Q ?I ?a ?b; Q ?J ?c ?d; ?I ⊆ A; ?J ⊆ A⟧ ⟹ (?a = ?b ∧ ?b = ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b = ?c ∧ ?c ≠ ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ⟶ P ?I ?J) ∧ (?a ≠ ?b ∧ ?b = ?c ∧ ?c ≠ ?d ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?a;?b;?c] ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?b;?a;?c] ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?a;?b;?c;?d] ⟶ P ?I ?J) ∧ ([?a;?c;?b;?d] ⟶ P ?I ?J) ∧ ([?a;?c;?d;?b] ⟶ P ?I ?J)›*) antecedants (*‹(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (I::'a set) (a::'a) (b::'a)› ‹Q J c d› ‹I ⊆ A› ‹J ⊆ A›*) wlog_endpoints_degenerate[OF path_A symmetric_Q Q_implies_path symmetric_P] (*‹⟦⋀(a::'a) (b::'a) I::'a set. (Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) ((?I6::'a ⇒ 'a ⇒ 'a set ⇒ 'a set) b a I) ((?b7::'a ⇒ 'a ⇒ 'a set ⇒ 'a) b a I) ((?a8::'a ⇒ 'a ⇒ 'a set ⇒ 'a) b a I) ⟹ Q (?I6 a b I) (?a8 a b I) (?b7 a b I); ⋀(a::'a) (b::'a) I::'a set. ⟦I ⊆ (A::'a set); Q (?I6 b a I) (?b7 b a I) (?a8 b a I)⟧ ⟹ (?I4::'a ⇒ 'a ⇒ 'a set ⇒ 'a set) a b I ⊆ A; ⋀(a::'a) (b::'a) I::'a set. ⟦I ⊆ A; Q (?I6 b a I) (?b7 b a I) (?a8 b a I)⟧ ⟹ Q (?I4 a b I) a b; ⋀(I::'a set) J::'a set. ⟦∃(a::'a) b::'a. Q (?I6 b a I) (?b7 b a I) (?a8 b a I); ∃(a::'a) b::'a. Q (?I6 b a J) (?b7 b a J) (?a8 b a J); (P::'a set ⇒ 'a set ⇒ bool) ((?J2::'a set ⇒ 'a set ⇒ 'a set) J I) ((?I3::'a set ⇒ 'a set ⇒ 'a set) J I)⟧ ⟹ ∃(a::'a) b::'a. Q (?I3 I J) a b; ⋀(I::'a set) J::'a set. ⟦∃(a::'a) b::'a. Q (?I6 b a I) (?b7 b a I) (?a8 b a I); ∃(a::'a) b::'a. Q (?I6 b a J) (?b7 b a J) (?a8 b a J); P (?J2 J I) (?I3 J I)⟧ ⟹ ∃(c::'a) d::'a. Q (?J2 I J) c d; ⋀(I::'a set) J::'a set. ⟦∃(a::'a) b::'a. Q (?I6 b a I) (?b7 b a I) (?a8 b a I); ∃(a::'a) b::'a. Q (?I6 b a J) (?b7 b a J) (?a8 b a J); P (?J2 J I) (?I3 J I)⟧ ⟹ P (?I3 I J) (?J2 I J); ⋀(I::'a set) (J::'a set) (a::'a) (b::'a) (c::'a) d::'a. ⟦Q (?I6 b a I) (?b7 b a I) (?a8 b a I); Q (?I6 d c J) (?b7 d c J) (?a8 d c J); I ⊆ A; J ⊆ A⟧ ⟹ (a = b ∧ b = c ∧ c = d ⟶ P (?J2 J I) (?I3 J I)) ∧ (a = b ∧ b ≠ c ∧ c = d ⟶ P (?J2 J I) (?I3 J I)) ∧ (a = b ∧ b = c ∧ c ≠ d ⟶ P (?J2 J I) (?I3 J I)) ∧ (a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟶ P (?J2 J I) (?I3 J I)) ∧ (a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟶ P (?J2 J I) (?I3 J I)) ∧ ([a;b;c] ∧ a = d ⟶ P (?J2 J I) (?I3 J I)) ∧ ([b;a;c] ∧ a = d ⟶ P (?J2 J I) (?I3 J I)); Q (?I6 (?b::'a) (?a::'a) (?I::'a set)) (?b7 ?b ?a ?I) (?a8 ?b ?a ?I); Q (?I6 (?d::'a) (?c::'a) (?J::'a set)) (?b7 ?d ?c ?J) (?a8 ?d ?c ?J); ?I ⊆ A; ?J ⊆ A; ¬ (?a ≠ ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ∧ ?a ≠ ?c ∧ ?b ≠ ?d)⟧ ⟹ P (?J2 ?J ?I) (?I3 ?J ?I)›*) wlog_endpoints_distinct[OF path_A symmetric_Q Q_implies_path symmetric_P] (*‹⟦⋀a b I. Q (?I6 b a I) (?b7 b a I) (?a8 b a I) ⟹ Q (?I6 a b I) (?a8 a b I) (?b7 a b I); ⋀a b I. ⟦I ⊆ A; Q (?I6 b a I) (?b7 b a I) (?a8 b a I)⟧ ⟹ ?I4 a b I ⊆ A; ⋀a b I. ⟦I ⊆ A; Q (?I6 b a I) (?b7 b a I) (?a8 b a I)⟧ ⟹ Q (?I4 a b I) a b; ⋀I J. ⟦∃a b. Q (?I6 b a I) (?b7 b a I) (?a8 b a I); ∃a b. Q (?I6 b a J) (?b7 b a J) (?a8 b a J); P (?J2 J I) (?I3 J I)⟧ ⟹ ∃a b. Q (?I3 I J) a b; ⋀I J. ⟦∃a b. Q (?I6 b a I) (?b7 b a I) (?a8 b a I); ∃a b. Q (?I6 b a J) (?b7 b a J) (?a8 b a J); P (?J2 J I) (?I3 J I)⟧ ⟹ ∃c d. Q (?J2 I J) c d; ⋀I J. ⟦∃a b. Q (?I6 b a I) (?b7 b a I) (?a8 b a I); ∃a b. Q (?I6 b a J) (?b7 b a J) (?a8 b a J); P (?J2 J I) (?I3 J I)⟧ ⟹ P (?I3 I J) (?J2 I J); ⋀I J a b c d. ⟦Q (?I6 b a I) (?b7 b a I) (?a8 b a I); Q (?I6 d c J) (?b7 d c J) (?a8 d c J); I ⊆ A; J ⊆ A; [a;b;c;d] ∨ [a;c;b;d] ∨ [a;c;d;b]⟧ ⟹ P (?J2 J I) (?I3 J I); Q (?I6 ?b ?a ?I) (?b7 ?b ?a ?I) (?a8 ?b ?a ?I); Q (?I6 ?d ?c ?J) (?b7 ?d ?c ?J) (?a8 ?d ?c ?J); ?I ⊆ A; ?J ⊆ A; ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?a ≠ ?d ∧ ?b ≠ ?c ∧ ?b ≠ ?d ∧ ?c ≠ ?d⟧ ⟹ P (?J2 ?J ?I) (?I3 ?J ?I)›*) by (smt (z3) Q_implies_path (*‹⟦(?I::'a set) ⊆ (A::'a set); (Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) ?I (?a::'a) (?b::'a)⟧ ⟹ ?b ∈ A ∧ ?a ∈ A›*) path_A (*‹(A::'a set) ∈ (𝒫::'a set set)›*) symmetric_P (*‹⟦∃(a::'a) b::'a. (Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (?I::'a set) a b; ∃(c::'a) d::'a. Q (?J::'a set) c d; (P::'a set ⇒ 'a set ⇒ bool) ?I ?J⟧ ⟹ P ?J ?I›*) symmetric_Q (*‹(Q::'a set ⇒ 'a ⇒ 'a ⇒ bool) (?I::'a set) (?a::'a) (?b::'a) ⟹ Q ?I ?b ?a›*) some_betw2 (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q; (?b::'a) ∈ ?Q; (?c::'a) ∈ ?Q⟧ ⟹ ?a = ?b ∨ ?a = ?c ∨ ?b = ?c ∨ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) some_betw4b (*‹⟦(?P::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?P; (?b::'a) ∈ ?P; (?c::'a) ∈ ?P; (?d::'a) ∈ ?P; ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?a ≠ ?d ∧ ?b ≠ ?c ∧ ?b ≠ ?d ∧ ?c ≠ ?d; ¬ ([?b;?a;?c;?d] ∨ [?b;?a;?d;?c] ∨ [?b;?c;?a;?d] ∨ [?b;?d;?a;?c] ∨ [?c;?a;?b;?d] ∨ [?c;?b;?a;?d])⟧ ⟹ [?a;?b;?c;?d] ∨ [?a;?b;?d;?c] ∨ [?a;?c;?b;?d] ∨ [?a;?c;?d;?b] ∨ [?a;?d;?b;?c] ∨ [?a;?d;?c;?b]›*) abc_only_cba( (*‹[?a::'a;?b::'a;?c::'a] ⟹ ¬ [?b;?a;?c]›*) 1))
end (*context MinkowskiSpacetime*)
subsection "WLOG for two intervals"
context MinkowskiBetweenness begin
text ‹
This section just specifies the results for a generic relation $Q$
in the previous section to the interval relation.
›
lemma wlog_two_interval_element:
assumes "⋀x I J. ⟦is_interval I; is_interval J; P x J I⟧ ⟹ P x I J"
and "⋀a b c d x I J. ⟦I = interval a b; J = interval c d⟧ ⟹
(x=a ∨ x=c ⟶ P x I J) ∧ (¬(x=a ∨ x=b ∨ x=c ∨ x=d) ⟶ P x I J)"
shows "⋀x I J. ⟦is_interval I; is_interval J⟧ ⟹ P x I J"
by (metis assms( (*‹⟦?I = interval ?a ?b; ?J = interval ?c ?d⟧ ⟹ (?x = ?a ∨ ?x = ?c ⟶ P ?x ?I ?J) ∧ (¬ (?x = ?a ∨ ?x = ?b ∨ ?x = ?c ∨ ?x = ?d) ⟶ P ?x ?I ?J)›*) 2) int_sym (*‹interval ?a ?b = interval ?b ?a›*))
lemma (in MinkowskiSpacetime) wlog_interval_endpoints_distinct:
assumes "⋀I J. ⟦is_interval I; is_interval J; P I J⟧ ⟹ P J I" (*P does not distinguish between intervals*)
"⋀I J a b c d. ⟦I = interval a b; J = interval c d⟧
⟹ ([a;b;c;d] ⟶ P I J) ∧ ([a;c;b;d] ⟶ P I J) ∧ ([a;c;d;b] ⟶ P I J)"
shows "⋀I J Q a b c d. ⟦I = interval a b; J = interval c d; I⊆Q; J⊆Q; Q∈𝒫;
a≠b ∧ a≠c ∧ a≠d ∧ b≠c ∧ b≠d ∧ c≠d⟧ ⟹ P I J"
proof (-)
(*goal: ‹⋀I J Q a b c d. ⟦I = interval a b; J = interval c d; I ⊆ Q; J ⊆ Q; Q ∈ 𝒫; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d⟧ ⟹ P I J›*)
let ?Q = "λ I a b. I = interval a b"
fix I and J and A and a and b and c and d
assume asm: "?Q I a b" "?Q J c d" "I⊆A" "J⊆A" "A∈𝒫" "a≠b ∧ a≠c ∧ a≠d ∧ b≠c ∧ b≠d ∧ c≠d" (*‹(I::'a set) = interval (a::'a) (b::'a)› ‹(J::'a set) = interval (c::'a) (d::'a)› ‹(I::'a set) ⊆ (A::'a set)› ‹(J::'a set) ⊆ (A::'a set)› ‹(A::'a set) ∈ (𝒫::'a set set)› ‹(a::'a) ≠ (b::'a) ∧ a ≠ (c::'a) ∧ a ≠ (d::'a) ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d›*)
show "P I J"
proof (rule wlog_endpoints_distinct (*‹⟦?A ∈ 𝒫; ⋀a b I. ?Q I a b ⟹ ?Q I b a; ⋀a b I. ⟦I ⊆ ?A; ?Q I a b⟧ ⟹ b ∈ ?A ∧ a ∈ ?A; ⋀I J. ⟦∃a b. ?Q I a b; ∃a b. ?Q J a b; ?P I J⟧ ⟹ ?P J I; ⋀I J a b c d. ⟦?Q I a b; ?Q J c d; I ⊆ ?A; J ⊆ ?A; [a;b;c;d] ∨ [a;c;b;d] ∨ [a;c;d;b]⟧ ⟹ ?P I J; ?Q ?I ?a ?b; ?Q ?J ?c ?d; ?I ⊆ ?A; ?J ⊆ ?A; ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?a ≠ ?d ∧ ?b ≠ ?c ∧ ?b ≠ ?d ∧ ?c ≠ ?d⟧ ⟹ ?P ?I ?J›*))
(*goals:
1. ‹?A ∈ 𝒫›
2. ‹⋀a b I. ?Q I a b ⟹ ?Q I b a›
3. ‹⋀a b I. ⟦I ⊆ ?A; ?Q I a b⟧ ⟹ b ∈ ?A ∧ a ∈ ?A›
4. ‹⋀I J. ⟦∃a b. ?Q I a b; ∃a b. ?Q J a b; P I J⟧ ⟹ P J I›
5. ‹⋀I J a b c d. ⟦?Q I a b; ?Q J c d; I ⊆ ?A; J ⊆ ?A; [a;b;c;d] ∨ [a;c;b;d] ∨ [a;c;d;b]⟧ ⟹ P I J›
6. ‹?Q I ?a ?b›
7. ‹?Q J ?c ?d›
8. ‹I ⊆ ?A›
9. ‹J ⊆ ?A›
10. ‹?a ≠ ?b ∧ ?a ≠ ?c ∧ ?a ≠ ?d ∧ ?b ≠ ?c ∧ ?b ≠ ?d ∧ ?c ≠ ?d›*)
show "⋀a b I. ?Q I a b ⟹ ?Q I b a"
by (simp add: int_sym (*‹interval (?a::'a::type) (?b::'a::type) = interval ?b ?a›*))
show "⋀a b I. I ⊆ A ⟹ ?Q I a b ⟹ b ∈ A ∧ a ∈ A"
by (simp add: ends_in_int (*‹?a ∈ interval ?a ?b ∧ ?b ∈ interval ?a ?b›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*))
show "⋀I J. is_interval I ⟹ is_interval J ⟹ P I J ⟹ P J I"
using assms(1) (*‹⟦is_interval ?I; is_interval ?J; P ?I ?J⟧ ⟹ P ?J ?I›*) by blast
show "⋀I J a b c d. ⟦?Q I a b; ?Q J c d; [a;b;c;d] ∨ [a;c;b;d] ∨ [a;c;d;b]⟧
⟹ P I J"
by (meson assms( (*‹⟦?I = interval ?a ?b; ?J = interval ?c ?d⟧ ⟹ ([?a;?b;?c;?d] ⟶ P ?I ?J) ∧ ([?a;?c;?b;?d] ⟶ P ?I ?J) ∧ ([?a;?c;?d;?b] ⟶ P ?I ?J)›*) 2))
show "I = interval a b" "J = interval c d" "I⊆A" "J⊆A" "A∈𝒫" "a≠b ∧ a≠c ∧ a≠d ∧ b≠c ∧ b≠d ∧ c≠d"
using asm (*‹I = interval a b› ‹(J::'a set) = interval (c::'a) (d::'a)› ‹I ⊆ A› ‹J ⊆ A› ‹(A::'a set) ∈ (𝒫::'a set set)› ‹a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d›*) apply -
(*goals:
1. ‹⟦I = interval a b; J = interval c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d⟧ ⟹ I = interval a b›
2. ‹⟦I = interval a b; J = interval c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d⟧ ⟹ J = interval c d›
3. ‹⟦I = interval a b; J = interval c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d⟧ ⟹ I ⊆ A›
4. ‹⟦I = interval a b; J = interval c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d⟧ ⟹ J ⊆ A›
5. ‹⟦I = interval a b; J = interval c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d⟧ ⟹ A ∈ 𝒫›
6. ‹⟦I = interval a b; J = interval c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d⟧ ⟹ a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*proven 6 subgoals*) .
qed
qed
lemma wlog_interval_endpoints_degenerate:
assumes symmetry: "⋀I J. ⟦is_interval I; is_interval J; P I J⟧ ⟹ P J I"
and "⋀I J a b c d Q. ⟦I = interval a b; J = interval c d; I⊆Q; J⊆Q; Q∈𝒫⟧
⟹ ((a=b ∧ b=c ∧ c=d) ⟶ P I J) ∧ ((a=b ∧ b≠c ∧ c=d) ⟶ P I J)
∧ ((a=b ∧ b=c ∧ c≠d) ⟶ P I J) ∧ ((a=b ∧ b≠c ∧ c≠d ∧ a≠d) ⟶ P I J)
∧ ((a≠b ∧ b=c ∧ c≠d ∧ a=d) ⟶ P I J)
∧ (([a;b;c] ∧ a=d) ⟶ P I J) ∧ (([b;a;c] ∧ a=d) ⟶ P I J)"
shows "⋀I J a b c d Q. ⟦I = interval a b; J = interval c d; I⊆Q; J⊆Q; Q∈𝒫;
¬(a≠b ∧ b≠c ∧ c≠d ∧ a≠d ∧ a≠c ∧ b≠d)⟧ ⟹ P I J"
proof (-)
(*goal: ‹⋀I J a b c d Q. ⟦I = interval a b; J = interval c d; I ⊆ Q; J ⊆ Q; Q ∈ 𝒫; ¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)⟧ ⟹ P I J›*)
let ?Q = "λ I a b. I = interval a b"
fix I and J and a and b and c and d and A
assume asm: "?Q I a b" "?Q J c d" "I⊆A" "J⊆A" "A∈𝒫" "¬(a≠b ∧ b≠c ∧ c≠d ∧ a≠d ∧ a≠c ∧ b≠d)" (*‹(I::'a set) = interval (a::'a) (b::'a)› ‹(J::'a set) = interval (c::'a) (d::'a)› ‹(I::'a set) ⊆ (A::'a set)› ‹(J::'a set) ⊆ (A::'a set)› ‹(A::'a set) ∈ (𝒫::'a set set)› ‹¬ ((a::'a) ≠ (b::'a) ∧ b ≠ (c::'a) ∧ c ≠ (d::'a) ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)›*)
show "P I J"
proof (rule wlog_endpoints_degenerate (*‹⟦?A ∈ 𝒫; ⋀a b I. ?Q I a b ⟹ ?Q I b a; ⋀a b I. ⟦I ⊆ ?A; ?Q I a b⟧ ⟹ b ∈ ?A ∧ a ∈ ?A; ⋀I J. ⟦∃a b. ?Q I a b; ∃a b. ?Q J a b; ?P I J⟧ ⟹ ?P J I; ⋀I J a b c d. ⟦?Q I a b; ?Q J c d; I ⊆ ?A; J ⊆ ?A⟧ ⟹ (a = b ∧ b = c ∧ c = d ⟶ ?P I J) ∧ (a = b ∧ b ≠ c ∧ c = d ⟶ ?P I J) ∧ (a = b ∧ b = c ∧ c ≠ d ⟶ ?P I J) ∧ (a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟶ ?P I J) ∧ (a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟶ ?P I J) ∧ ([a;b;c] ∧ a = d ⟶ ?P I J) ∧ ([b;a;c] ∧ a = d ⟶ ?P I J); ?Q ?I ?a ?b; ?Q ?J ?c ?d; ?I ⊆ ?A; ?J ⊆ ?A; ¬ (?a ≠ ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ∧ ?a ≠ ?c ∧ ?b ≠ ?d)⟧ ⟹ ?P ?I ?J›*))
(*goals:
1. ‹?A ∈ 𝒫›
2. ‹⋀a b I. ?Q I a b ⟹ ?Q I b a›
3. ‹⋀a b I. ⟦I ⊆ ?A; ?Q I a b⟧ ⟹ b ∈ ?A ∧ a ∈ ?A›
4. ‹⋀I J. ⟦∃a b. ?Q I a b; ∃a b. ?Q J a b; P I J⟧ ⟹ P J I›
5. ‹⋀I J a b c d. ⟦?Q I a b; ?Q J c d; I ⊆ ?A; J ⊆ ?A⟧ ⟹ (a = b ∧ b = c ∧ c = d ⟶ P I J) ∧ (a = b ∧ b ≠ c ∧ c = d ⟶ P I J) ∧ (a = b ∧ b = c ∧ c ≠ d ⟶ P I J) ∧ (a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟶ P I J) ∧ (a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟶ P I J) ∧ ([a;b;c] ∧ a = d ⟶ P I J) ∧ ([b;a;c] ∧ a = d ⟶ P I J)›
6. ‹?Q I ?a ?b›
7. ‹?Q J ?c ?d›
8. ‹I ⊆ ?A›
9. ‹J ⊆ ?A›
10. ‹¬ (?a ≠ ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ∧ ?a ≠ ?c ∧ ?b ≠ ?d)›*)
show "⋀a b I. ?Q I a b ⟹ ?Q I b a"
by (simp add: int_sym (*‹interval ?a ?b = interval ?b ?a›*))
show "⋀a b I. I ⊆ A ⟹ ?Q I a b ⟹ b ∈ A ∧ a ∈ A"
by (simp add: ends_in_int (*‹?a ∈ interval ?a ?b ∧ ?b ∈ interval ?a ?b›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*))
show "⋀I J. is_interval I ⟹ is_interval J ⟹ P I J ⟹ P J I"
using symmetry (*‹⟦is_interval ?I; is_interval ?J; P ?I ?J⟧ ⟹ P ?J ?I›*) by blast
show "I = interval a b" "J = interval c d" "I⊆A" "J⊆A" "A∈𝒫" "¬ (a≠b ∧ b≠c ∧ c≠d ∧ a≠d ∧ a≠c ∧ b≠d)"
using asm (*‹I = interval a b› ‹J = interval c d› ‹I ⊆ A› ‹J ⊆ A› ‹A ∈ 𝒫› ‹¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)›*) apply -
(*goals:
1. ‹⟦I = interval a b; J = interval c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; ¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)⟧ ⟹ I = interval a b›
2. ‹⟦I = interval a b; J = interval c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; ¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)⟧ ⟹ J = interval c d›
3. ‹⟦I = interval a b; J = interval c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; ¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)⟧ ⟹ I ⊆ A›
4. ‹⟦I = interval a b; J = interval c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; ¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)⟧ ⟹ J ⊆ A›
5. ‹⟦I = interval a b; J = interval c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; ¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)⟧ ⟹ A ∈ 𝒫›
6. ‹⟦I = interval a b; J = interval c d; I ⊆ A; J ⊆ A; A ∈ 𝒫; ¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)⟧ ⟹ ¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*discuss goal 6*)
apply ((auto)[1])
(*proven 6 subgoals*) .
show "⋀I J a b c d. ⟦?Q I a b; ?Q J c d; I ⊆ A; J ⊆ A⟧ ⟹
(a = b ∧ b = c ∧ c = d ⟶ P I J) ∧
(a = b ∧ b ≠ c ∧ c = d ⟶ P I J) ∧
(a = b ∧ b = c ∧ c ≠ d ⟶ P I J) ∧
(a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟶ P I J) ∧
(a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟶ P I J) ∧
([a;b;c] ∧ a = d ⟶ P I J) ∧ ([b;a;c] ∧ a = d ⟶ P I J)"
using assms(2) (*‹⟦?I = interval ?a ?b; ?J = interval ?c ?d; ?I ⊆ ?Q; ?J ⊆ ?Q; ?Q ∈ 𝒫⟧ ⟹ (?a = ?b ∧ ?b = ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c = ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b = ?c ∧ ?c ≠ ?d ⟶ P ?I ?J) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ⟶ P ?I ?J) ∧ (?a ≠ ?b ∧ ?b = ?c ∧ ?c ≠ ?d ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?a;?b;?c] ∧ ?a = ?d ⟶ P ?I ?J) ∧ ([?b;?a;?c] ∧ ?a = ?d ⟶ P ?I ?J)›*) ‹A∈𝒫› (*‹A ∈ 𝒫›*) by auto
qed
qed
end (* context MinkowskiBetweenness *)
section "Interlude: Intervals, Segments, Connectedness"
context MinkowskiSpacetime begin
text ‹
In this secion, we apply the WLOG lemmas from the previous section in order to reduce the
number of cases we need to consider when thinking about two arbitrary intervals on a path.
This is used to prove that the (countable) intersection of intervals is an interval.
These results cannot be found in Schutz, but he does use them (without justification)
in his proof of Theorem 12 (even for uncountable intersections).
›
lemma int_of_ints_is_interval_neq: (* Proof using WLOG *)
assumes "I1 = interval a b" "I2 = interval c d" "I1⊆P" "I2⊆P" "P∈𝒫" "I1∩I2 ≠ {}"
and events_neq: "a≠b" "a≠c" "a≠d" "b≠c" "b≠d" "c≠d"
shows "is_interval (I1 ∩ I2)"
proof (-)
(*goal: ‹is_interval (I1 ∩ I2)›*)
have on_path: "a∈P ∧ b∈P ∧ c∈P ∧ d∈P"
using assms(1-4) (*‹I1 = interval a b› ‹I2 = interval c d› ‹I1 ⊆ P› ‹I2 ⊆ P›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) by auto
let ?prop = "λ I J. is_interval (I∩J) ∨ (I∩J) = {}"
have symmetry: "(⋀I J. is_interval I ⟹ is_interval J ⟹ ?prop I J ⟹ ?prop J I)"
by (simp add: Int_commute (*‹?A ∩ ?B = ?B ∩ ?A›*))
{
fix I and J and a and b and c and d
assume "I = interval a b" "J = interval c d" (*‹(I::'a set) = interval (a::'a) (b::'a)› ‹(J::'a set) = interval (c::'a) (d::'a)›*)
have "([a;b;c;d] ⟶ ?prop I J)" "([a;c;b;d] ⟶ ?prop I J)" "([a;c;d;b] ⟶ ?prop I J)"
proof (rule_tac [!] impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goals:
1. ‹[a;b;c;d] ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
2. ‹[a;c;b;d] ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
3. ‹[a;c;d;b] ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*)
assume "betw4 a b c d" (*‹[a::'a;b::'a;c::'a;d::'a]›*)
have "I∩J = {}"
proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*))
(*goal: ‹(I::'a set) ∩ (J::'a set) ≠ {} ⟹ False›*)
assume "I∩J≠{}" (*‹(I::'a set) ∩ (J::'a set) ≠ {}›*)
then obtain x where "x∈I∩J"
(*goal: ‹(⋀x. x ∈ I ∩ J ⟹ thesis) ⟹ thesis›*)
by blast
show False
proof (cases)
(*goals:
1. ‹?P::bool ⟹ False›
2. ‹¬ (?P::bool) ⟹ False›*)
assume "x≠a ∧ x≠b ∧ x≠c ∧ x≠d" (*‹(x::'a) ≠ (a::'a) ∧ x ≠ (b::'a) ∧ x ≠ (c::'a) ∧ x ≠ (d::'a)›*)
hence "[a;x;b]" "[c;x;d]"
using ‹I=interval a b› (*‹I = interval a b›*) ‹x∈I∩J› (*‹x ∈ I ∩ J›*) ‹J=interval c d› (*‹J = interval c d›*) ‹x∈I∩J› (*‹x ∈ I ∩ J›*) apply -
(*goals:
1. ‹⟦x ≠ a ∧ x ≠ b ∧ x ≠ c ∧ x ≠ d; I = interval a b; x ∈ I ∩ J; J = interval c d; x ∈ I ∩ J⟧ ⟹ [a;x;b]›
2. ‹⟦x ≠ a ∧ x ≠ b ∧ x ≠ c ∧ x ≠ d; I = interval a b; x ∈ I ∩ J; J = interval c d; x ∈ I ∩ J⟧ ⟹ [c;x;d]›
discuss goal 1*)
apply (simp add: interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*))
(*discuss goal 2*)
apply (simp add: interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*))
(*proven 2 subgoals*) .
thus False
by (meson ‹betw4 a b c d› abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]›*) 3) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*))
next
(*goal: ‹¬ (x ≠ a ∧ x ≠ b ∧ x ≠ c ∧ x ≠ d) ⟹ False›*)
assume "¬(x≠a ∧ x≠b ∧ x≠c ∧ x≠d)" (*‹¬ ((x::'a) ≠ (a::'a) ∧ x ≠ (b::'a) ∧ x ≠ (c::'a) ∧ x ≠ (d::'a))›*)
thus False
using interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) ‹I = interval a b› (*‹I = interval a b›*) ‹J = interval c d› (*‹J = interval c d›*) abcd_dcba_only(21) (*‹[?a::'a::type;?b::'a::type;?c::'a::type;?d::'a::type] ⟹ ¬ [?d;?b;?c;?a]›*) ‹x ∈ I ∩ J› (*‹x ∈ I ∩ J›*) ‹betw4 a b c d› (*‹[a;b;c;d]›*) abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) abc_only_cba(1,2) (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) by (metis (full_types) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) Int_iff (*‹(?c ∈ ?A ∩ ?B) = (?c ∈ ?A ∧ ?c ∈ ?B)›*))
qed
qed
thus "?prop I J"
by simp
next
(*goals:
1. ‹[a;c;b;d] ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
2. ‹[a;c;d;b] ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*)
assume "[a;c;b;d]" (*‹[a::'a;c::'a;b::'a;d::'a]›*)
then have "a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d"
using betw4_imp_neq (*‹[?a;?b;?c;?d] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?a ≠ ?d ∧ ?b ≠ ?c ∧ ?b ≠ ?d ∧ ?c ≠ ?d›*) by blast
have "I∩J = interval c b"
proof (safe)
(*goals:
1. ‹⋀x. ⟦x ∈ I; x ∈ J⟧ ⟹ x ∈ interval c b›
2. ‹⋀x. x ∈ interval c b ⟹ x ∈ I›
3. ‹⋀x. x ∈ interval c b ⟹ x ∈ J›*)
fix x
assume "x ∈ interval c b" (*‹(x::'a) ∈ interval (c::'a) (b::'a)›*)
{
assume "x=b ∨ x=c" (*‹(x::'a) = (b::'a) ∨ x = (c::'a)›*)
hence "x∈I"
using ‹[a;c;b;d]› (*‹[a::'a::type;c::'a::type;b::'a::type;d::'a::type]›*) ‹I = interval a b› (*‹(I::'a set) = interval (a::'a) (b::'a)›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by auto
have "x∈J"
using ‹x=b ∨ x=c› (*‹x = b ∨ x = c›*) using ‹[a;c;b;d]› (*‹[a;c;b;d]›*) ‹J = interval c d› (*‹(J::'a set) = interval (c::'a) (d::'a)›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by auto
hence "x∈I ∧ x∈J"
using ‹x ∈ I› (*‹x ∈ I›*) by blast
}
moreover {
assume "¬(x=b ∨ x=c)" (*‹¬ ((x::'a) = (b::'a) ∨ x = (c::'a))›*)
hence "[c;x;b]"
using ‹x∈interval c b› (*‹x ∈ interval c b›*) unfolding interval_def segment_def
(*goal: ‹[c;x;b]›*)
by simp
hence "[a;x;b]"
by (meson ‹[a;c;b;d]› abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*))
have "[c;x;d]"
using ‹[a;c;b;d]› (*‹[a;c;b;d]›*) ‹[c;x;b]› (*‹[c;x;b]›*) abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) by blast
have "x∈I" "x∈J"
using ‹I = interval a b› (*‹(I::'a set) = interval (a::'a) (b::'a)›*) ‹[a;x;b]› (*‹[a;x;b]›*) ‹J = interval c d› (*‹J = interval c d›*) ‹[c;x;d]› (*‹[c;x;d]›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) apply -
(*goals:
1. ‹⟦I = interval a b; [a;x;b]; J = interval c d; [c;x;d]; ⋀a b. interval a b ≡ insert b (insert a (segment a b)); ⋀x a b. (x ∈ segment a b) = [a;x;b]⟧ ⟹ x ∈ I›
2. ‹⟦I = interval a b; [a;x;b]; J = interval c d; [c;x;d]; ⋀a b. interval a b ≡ insert b (insert a (segment a b)); ⋀x a b. (x ∈ segment a b) = [a;x;b]⟧ ⟹ x ∈ J›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
}
ultimately show "x∈I" "x∈J"
apply -
(*goals:
1. ‹⟦x = b ∨ x = c ⟹ x ∈ I ∧ x ∈ J; ¬ (x = b ∨ x = c) ⟹ x ∈ I; ¬ (x = b ∨ x = c) ⟹ x ∈ J⟧ ⟹ x ∈ I›
2. ‹⟦x = b ∨ x = c ⟹ x ∈ I ∧ x ∈ J; ¬ (x = b ∨ x = c) ⟹ x ∈ I; ¬ (x = b ∨ x = c) ⟹ x ∈ J⟧ ⟹ x ∈ J›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
next
(*goal: ‹⋀x. ⟦x ∈ I; x ∈ J⟧ ⟹ x ∈ interval c b›*)
fix x
assume "x∈I" "x∈J" (*‹(x::'a) ∈ (I::'a set)› ‹(x::'a) ∈ (J::'a set)›*)
show "x ∈ interval c b"
proof (cases)
(*goals:
1. ‹?P ⟹ x ∈ interval c b›
2. ‹¬ ?P ⟹ x ∈ interval c b›*)
assume not_eq: "x≠a ∧ x≠b ∧ x≠c ∧ x≠d" (*‹(x::'a) ≠ (a::'a) ∧ x ≠ (b::'a) ∧ x ≠ (c::'a) ∧ x ≠ (d::'a)›*)
have "[a;x;b]" "[c;x;d]"
using ‹x∈I› (*‹x ∈ I›*) ‹I = interval a b› (*‹I = interval a b›*) ‹x∈J› (*‹x ∈ J›*) ‹J = interval c d› (*‹(J::'a set) = interval (c::'a) (d::'a)›*) not_eq (*‹x ≠ a ∧ x ≠ b ∧ x ≠ c ∧ x ≠ d›*) unfolding interval_def segment_def
(*goals:
1. ‹[a;x;b]›
2. ‹[c;x;d]›*)
apply -
(*goals:
1. ‹⟦x ∈ I; I = insert b (insert a {x. ∃ab. [a;x;b] ∧ x ∈ ab ∧ path ab a b}); x ∈ J; J = insert d (insert c {x. ∃ab. [c;x;d] ∧ x ∈ ab ∧ path ab c d}); x ≠ a ∧ x ≠ b ∧ x ≠ c ∧ x ≠ d⟧ ⟹ [a;x;b]›
2. ‹⟦x ∈ I; I = insert b (insert a {x. ∃ab. [a;x;b] ∧ x ∈ ab ∧ path ab a b}); x ∈ J; J = insert d (insert c {x. ∃ab. [c;x;d] ∧ x ∈ ab ∧ path ab c d}); x ≠ a ∧ x ≠ b ∧ x ≠ c ∧ x ≠ d⟧ ⟹ [c;x;d]›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
hence "[c;x;b]"
by (meson ‹[a;c;b;d]› abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) betw4_weak (*‹[?a;?b;?c] ∧ [?a;?c;?d] ∨ [?a;?b;?c;?d] ∨ [?a;?b;?d] ∧ [?b;?c;?d] ∨ [?a;?b;?d] ∧ [?b;?c;?d] ⟹ [?a;?b;?c;?d]›*))
thus "?thesis"
(*goal: ‹x ∈ interval c b›*)
unfolding interval_def segment_def
(*goal: ‹(x::'a) ∈ insert (b::'a) (insert (c::'a) {x::'a. ∃ab::'a set. [c;x;b] ∧ x ∈ ab ∧ path ab c b})›*)
using seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) segment_def (*‹segment ?a ?b ≡ {x. ∃ab. [?a;x;?b] ∧ x ∈ ab ∧ path ab ?a ?b}›*) by auto
next
(*goal: ‹¬ ((x::'a) ≠ (a::'a) ∧ x ≠ (b::'a) ∧ x ≠ (c::'a) ∧ x ≠ (d::'a)) ⟹ x ∈ interval c b›*)
assume not_not_eq: "¬(x≠a ∧ x≠b ∧ x≠c ∧ x≠d)" (*‹¬ ((x::'a) ≠ (a::'a) ∧ x ≠ (b::'a) ∧ x ≠ (c::'a) ∧ x ≠ (d::'a))›*)
{
assume "x=a" (*‹(x::'a) = (a::'a)›*)
have "¬[d;a;c]"
using ‹[a;c;b;d]› (*‹[a;c;b;d]›*) abcd_dcba_only(9) (*‹[?a;?b;?c;?d] ⟹ ¬ [?b;?c;?d;?a]›*) by blast
hence "a ∉ interval c d"
unfolding interval_def segment_def
(*goal: ‹a ∉ insert d (insert c {x. ∃ab. [c;x;d] ∧ x ∈ ab ∧ path ab c d})›*)
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) ‹a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d› (*‹a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d›*) by blast
hence False
using ‹x∈J› (*‹x ∈ J›*) ‹J = interval c d› (*‹(J::'a::type set) = interval (c::'a::type) (d::'a::type)›*) ‹x=a› (*‹(x::'a) = (a::'a)›*) by blast
}
moreover {
assume "x=d" (*‹(x::'a) = (d::'a)›*)
have "¬[a;d;b]"
using ‹betw4 a c b d› (*‹[a;c;b;d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) abcd_dcba_only(9) (*‹[?a;?b;?c;?d] ⟹ ¬ [?b;?c;?d;?a]›*) by blast
hence "d∉interval a b"
unfolding interval_def segment_def
(*goal: ‹(d::'a::type) ∉ insert (b::'a::type) (insert (a::'a::type) {x::'a::type. ∃ab::'a::type set. [a;x;b] ∧ x ∈ ab ∧ path ab a b})›*)
using ‹a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d› (*‹a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d›*) by blast
hence False
using ‹x∈I› (*‹x ∈ I›*) ‹x=d› (*‹x = d›*) ‹I = interval a b› (*‹I = interval a b›*) by blast
}
ultimately show "?thesis"
(*goal: ‹x ∈ interval c b›*)
using interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) not_not_eq (*‹¬ (x ≠ a ∧ x ≠ b ∧ x ≠ c ∧ x ≠ d)›*) by auto
qed
qed
thus "?prop I J"
by auto
next
(*goal: ‹[a;c;d;b] ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*)
assume "[a;c;d;b]" (*‹[a::'a;c::'a;d::'a;b::'a]›*)
have "I∩J = interval c d"
proof (safe)
(*goals:
1. ‹⋀x. ⟦x ∈ I; x ∈ J⟧ ⟹ x ∈ interval c d›
2. ‹⋀x. x ∈ interval c d ⟹ x ∈ I›
3. ‹⋀x. x ∈ interval c d ⟹ x ∈ J›*)
fix x
assume "x ∈ interval c d" (*‹(x::'a) ∈ interval (c::'a) (d::'a)›*)
{
assume "x≠c ∧ x≠d" (*‹(x::'a) ≠ (c::'a) ∧ x ≠ (d::'a)›*)
have "x ∈ J"
by (simp add: ‹J = interval c d› ‹x ∈ interval c d›)
have "[c;x;d]"
using ‹x ∈ interval c d› (*‹x ∈ interval c d›*) ‹x ≠ c ∧ x ≠ d› (*‹x ≠ c ∧ x ≠ d›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹((?x::'a::type) ∈ segment (?a::'a::type) (?b::'a::type)) = [?a;?x;?b]›*) by auto
have "[a;x;b]"
by (meson ‹betw4 a c d b› ‹[c;x;d]› abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) abe_ade_bcd_ace (*‹⟦[?a;?b;?e]; [?a;?d;?e]; [?b;?c;?d]⟧ ⟹ [?a;?c;?e]›*))
have "x ∈ I"
using ‹I = interval a b› (*‹I = interval a b›*) ‹[a;x;b]› (*‹[a;x;b]›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by auto
hence "x∈I ∧ x∈J"
by (simp add: ‹x ∈ J›)
}
moreover {
assume "¬ (x≠c ∧ x≠d)" (*‹¬ ((x::'a) ≠ (c::'a) ∧ x ≠ (d::'a))›*)
hence "x∈I ∧ x∈J"
by (metis ‹I = interval a b› ‹J = interval c d› ‹[a;c;d;b]› ‹x ∈ interval c d› abc_bcd_abd (*‹⟦[?a::'a::type;?b::'a::type;?c::'a::type]; [?b;?c;?d::'a::type]⟧ ⟹ [?a;?b;?d]›*) abc_bcd_acd (*‹⟦[?a::'a::type;?b::'a::type;?c::'a::type]; [?b;?c;?d::'a::type]⟧ ⟹ [?a;?c;?d]›*) insertI2 (*‹(?a::?'a::type) ∈ (?B::?'a::type set) ⟹ ?a ∈ insert (?b::?'a::type) ?B›*) interval_def (*‹interval (?a::'a::type) (?b::'a::type) ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹((?x::'a::type) ∈ segment (?a::'a::type) (?b::'a::type)) = [?a;?x;?b]›*))
}
ultimately show "x∈I" "x∈J"
apply -
(*goals:
1. ‹⟦x ≠ c ∧ x ≠ d ⟹ x ∈ I ∧ x ∈ J; ¬ (x ≠ c ∧ x ≠ d) ⟹ x ∈ I ∧ x ∈ J⟧ ⟹ x ∈ I›
2. ‹⟦x ≠ c ∧ x ≠ d ⟹ x ∈ I ∧ x ∈ J; ¬ (x ≠ c ∧ x ≠ d) ⟹ x ∈ I ∧ x ∈ J⟧ ⟹ x ∈ J›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
next
(*goal: ‹⋀x. ⟦x ∈ I; x ∈ J⟧ ⟹ x ∈ interval c d›*)
fix x
assume "x∈I" "x∈J" (*‹(x::'a) ∈ (I::'a set)› ‹(x::'a) ∈ (J::'a set)›*)
show "x ∈ interval c d"
using ‹J = interval c d› (*‹J = interval c d›*) ‹x ∈ J› (*‹x ∈ J›*) by auto
qed
thus "?prop I J"
by auto
qed
}
then show "is_interval (I1∩I2)"
using wlog_interval_endpoints_distinct[where P = "?prop" and I = I1 and J = I2 and Q = P and a = a and b = b and c = c and d = d] (*‹⟦⋀I J. ⟦is_interval I; is_interval J; is_interval (I ∩ J) ∨ I ∩ J = {}⟧ ⟹ is_interval (J ∩ I) ∨ J ∩ I = {}; ⋀I J a b c d. ⟦I = interval a b; J = interval c d⟧ ⟹ ([a;b;c;d] ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}) ∧ ([a;c;b;d] ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}) ∧ ([a;c;d;b] ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}); I1 = interval a b; I2 = interval c d; I1 ⊆ P; I2 ⊆ P; P ∈ 𝒫; a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d⟧ ⟹ is_interval (I1 ∩ I2) ∨ I1 ∩ I2 = {}›*) using symmetry (*‹⟦is_interval ?I; is_interval ?J; is_interval (?I ∩ ?J) ∨ ?I ∩ ?J = {}⟧ ⟹ is_interval (?J ∩ ?I) ∨ ?J ∩ ?I = {}›*) assms (*‹I1 = interval a b› ‹I2 = interval c d› ‹I1 ⊆ P› ‹I2 ⊆ P› ‹(P::'a set) ∈ (𝒫::'a set set)› ‹I1 ∩ I2 ≠ {}› ‹(a::'a::type) ≠ (b::'a::type)› ‹a ≠ c› ‹a ≠ d› ‹b ≠ c› ‹(b::'a::type) ≠ (d::'a::type)› ‹c ≠ d›*) by simp
qed
lemma int_of_ints_is_interval_deg: (* Proof using WLOG *)
assumes "I = interval a b" "J = interval c d" "I∩J ≠ {}" "I⊆P" "J⊆P" "P∈𝒫"
and events_deg: "¬(a≠b ∧ b≠c ∧ c≠d ∧ a≠d ∧ a≠c ∧ b≠d)"
shows "is_interval (I ∩ J)"
proof (-)
(*goal: ‹is_interval (I ∩ J)›*)
let ?p = "λ I J. (is_interval (I ∩ J) ∨ I∩J = {})"
have symmetry: "⋀I J. ⟦is_interval I; is_interval J; ?p I J⟧ ⟹ ?p J I"
by (simp add: inf_commute (*‹inf ?x ?y = inf ?y ?x›*))
have degen_cases: "⋀I J a b c d Q. ⟦I = interval a b; J = interval c d; I⊆Q; J⊆Q; Q∈𝒫⟧
⟹ ((a=b ∧ b=c ∧ c=d) ⟶ ?p I J) ∧ ((a=b ∧ b≠c ∧ c=d) ⟶ ?p I J)
∧ ((a=b ∧ b=c ∧ c≠d) ⟶ ?p I J) ∧ ((a=b ∧ b≠c ∧ c≠d ∧ a≠d) ⟶ ?p I J)
∧ ((a≠b ∧ b=c ∧ c≠d ∧ a=d) ⟶ ?p I J)
∧ (([a;b;c] ∧ a=d) ⟶ ?p I J) ∧ (([b;a;c] ∧ a=d) ⟶ ?p I J)"
proof (-)
(*goal: ‹⋀I J a b c d Q. ⟦I = interval a b; J = interval c d; I ⊆ Q; J ⊆ Q; Q ∈ 𝒫⟧ ⟹ (a = b ∧ b = c ∧ c = d ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}) ∧ (a = b ∧ b ≠ c ∧ c = d ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}) ∧ (a = b ∧ b = c ∧ c ≠ d ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}) ∧ (a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}) ∧ (a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}) ∧ ([a;b;c] ∧ a = d ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}) ∧ ([b;a;c] ∧ a = d ⟶ is_interval (I ∩ J) ∨ I ∩ J = {})›*)
fix I and J and a and b and c and d and Q
assume "I = interval a b" "J = interval c d" "I⊆Q" "J⊆Q" "Q∈𝒫" (*‹(I::'a set) = interval (a::'a) (b::'a)› ‹(J::'a set) = interval (c::'a) (d::'a)› ‹(I::'a set) ⊆ (Q::'a set)› ‹(J::'a set) ⊆ (Q::'a set)› ‹(Q::'a set) ∈ (𝒫::'a set set)›*)
show "((a=b ∧ b=c ∧ c=d) ⟶ ?p I J) ∧ ((a=b ∧ b≠c ∧ c=d) ⟶ ?p I J)
∧ ((a=b ∧ b=c ∧ c≠d) ⟶ ?p I J) ∧ ((a=b ∧ b≠c ∧ c≠d ∧ a≠d) ⟶ ?p I J)
∧ ((a≠b ∧ b=c ∧ c≠d ∧ a=d) ⟶ ?p I J)
∧ (([a;b;c] ∧ a=d) ⟶ ?p I J) ∧ (([b;a;c] ∧ a=d) ⟶ ?p I J)"
proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goals:
1. ‹a = b ∧ b = c ∧ c = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
2. ‹a = b ∧ b ≠ c ∧ c = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
3. ‹a = b ∧ b = c ∧ c ≠ d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
4. ‹a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
5. ‹a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
6. ‹[a;b;c] ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
7. ‹[b;a;c] ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*)
assume "a = b ∧ b = c ∧ c = d" (*‹(a::'a) = (b::'a) ∧ b = (c::'a) ∧ c = (d::'a)›*)
thus "?p I J"
using ‹I = interval a b› (*‹I = interval a b›*) ‹J = interval c d› (*‹J = interval c d›*) by auto
next
(*goals:
1. ‹a = b ∧ b ≠ c ∧ c = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
2. ‹a = b ∧ b = c ∧ c ≠ d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
3. ‹a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
4. ‹a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
5. ‹[a;b;c] ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
6. ‹[b;a;c] ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*)
assume "a = b ∧ b ≠ c ∧ c = d" (*‹(a::'a) = (b::'a) ∧ b ≠ (c::'a) ∧ c = (d::'a)›*)
thus "?p I J"
using ‹J = interval c d› (*‹(J::'a set) = interval (c::'a) (d::'a)›*) empty_segment (*‹segment ?a ?a = {}›*) interval_def (*‹interval (?a::'a) (?b::'a) ≡ insert ?b (insert ?a (segment ?a ?b))›*) by auto
next
(*goals:
1. ‹a = b ∧ b = c ∧ c ≠ d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
2. ‹a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
3. ‹a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
4. ‹[a;b;c] ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
5. ‹[b;a;c] ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*)
assume "a = b ∧ b = c ∧ c ≠ d" (*‹(a::'a) = (b::'a) ∧ b = (c::'a) ∧ c ≠ (d::'a)›*)
thus "?p I J"
using ‹I = interval a b› (*‹I = interval a b›*) empty_segment (*‹segment ?a ?a = {}›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) by auto
next
(*goals:
1. ‹a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
2. ‹a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
3. ‹[a;b;c] ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
4. ‹[b;a;c] ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*)
assume "a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d" (*‹(a::'a) = (b::'a) ∧ b ≠ (c::'a) ∧ c ≠ (d::'a) ∧ a ≠ d›*)
thus "?p I J"
using ‹I = interval a b› (*‹I = interval a b›*) empty_segment (*‹segment ?a ?a = {}›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) by auto
next
(*goals:
1. ‹a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
2. ‹[a;b;c] ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
3. ‹[b;a;c] ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*)
assume "a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d" (*‹(a::'a) ≠ (b::'a) ∧ b = (c::'a) ∧ c ≠ (d::'a) ∧ a = d›*)
thus "?p I J"
using ‹I = interval a b› (*‹I = interval a b›*) ‹J = interval c d› (*‹J = interval c d›*) int_sym (*‹interval ?a ?b = interval ?b ?a›*) by auto
next
(*goals:
1. ‹[a;b;c] ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
2. ‹[b;a;c] ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*)
assume "[a;b;c] ∧ a = d" (*‹[a::'a;b::'a;c::'a] ∧ a = (d::'a)›*)
show "?p I J"
proof (cases)
(*goals:
1. ‹?P ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
2. ‹¬ ?P ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*)
assume "I∩J = {}" (*‹(I::'a set) ∩ (J::'a set) = {}›*)
thus "?thesis"
(*goal: ‹is_interval (I ∩ J) ∨ I ∩ J = {}›*)
by simp
next
(*goal: ‹(I::'a set) ∩ (J::'a set) ≠ {} ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*)
assume "I∩J ≠ {}" (*‹(I::'a set) ∩ (J::'a set) ≠ {}›*)
have "I∩J = interval a b"
proof (safe)
(*goals:
1. ‹⋀x. ⟦x ∈ I; x ∈ J⟧ ⟹ x ∈ interval a b›
2. ‹⋀x. x ∈ interval a b ⟹ x ∈ I›
3. ‹⋀x. x ∈ interval a b ⟹ x ∈ J›*)
fix x
assume "x∈I" "x∈J" (*‹(x::'a) ∈ (I::'a set)› ‹(x::'a) ∈ (J::'a set)›*)
thus "x∈interval a b"
using ‹I = interval a b› (*‹I = interval a b›*) by blast
next
(*goals:
1. ‹⋀x. x ∈ interval a b ⟹ x ∈ I›
2. ‹⋀x. x ∈ interval a b ⟹ x ∈ J›*)
fix x
assume "x∈interval a b" (*‹(x::'a) ∈ interval (a::'a) (b::'a)›*)
show "x∈I"
by (simp add: ‹I = interval a b› ‹x ∈ interval a b›)
have "[d;b;c]"
using ‹[a;b;c] ∧ a = d› (*‹[a;b;c] ∧ a = d›*) by blast
have "[a;x;b] ∨ x=a ∨ x=b"
using ‹I = interval a b› (*‹I = interval a b›*) ‹x ∈ I› (*‹(x::'a) ∈ (I::'a set)›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹((?x::'a::type) ∈ segment (?a::'a::type) (?b::'a::type)) = [?a;?x;?b]›*) by auto
consider "[d;x;c]" | "x=a ∨ x=b"
(*goal: ‹⟦[d;x;c] ⟹ thesis; x = a ∨ x = b ⟹ thesis⟧ ⟹ thesis›*)
using ‹[a;b;c] ∧ a = d› (*‹[a;b;c] ∧ a = d›*) ‹[a;x;b] ∨ x = a ∨ x = b› (*‹[a;x;b] ∨ x = a ∨ x = b›*) abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) by blast
thus "x∈J"
proof (cases)
(*goals:
1. ‹[d;x;c] ⟹ x ∈ J›
2. ‹x = a ∨ x = b ⟹ x ∈ J›*)
case 1 (*‹[d;x;c]›*)
then show "?thesis"
(*goal: ‹x ∈ J›*)
by (simp add: ‹J = interval c d› abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*))
next
(*goal: ‹(x::'a) = (a::'a) ∨ x = (b::'a) ⟹ x ∈ (J::'a set)›*)
case 2 (*‹x = a ∨ x = b›*)
then have "x ∈ interval c d"
using ‹[a;b;c] ∧ a = d› (*‹[a::'a;b::'a;c::'a] ∧ a = (d::'a)›*) int_sym (*‹interval (?a::'a::type) (?b::'a::type) = interval ?b ?a›*) interval_def (*‹interval (?a::'a::type) (?b::'a::type) ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by force
then show "?thesis"
(*goal: ‹(x::'a) ∈ (J::'a set)›*)
using ‹J = interval c d› (*‹J = interval c d›*) by blast
qed
qed
thus "?p I J"
by blast
qed
next
(*goal: ‹[b;a;c] ∧ a = d ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*)
assume "[b;a;c] ∧ a = d" (*‹[b::'a;a::'a;c::'a] ∧ a = (d::'a)›*)
show "?p I J"
proof (cases)
(*goals:
1. ‹?P ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›
2. ‹¬ ?P ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*)
assume "I∩J = {}" (*‹(I::'a set) ∩ (J::'a set) = {}›*)
thus "?thesis"
(*goal: ‹is_interval (I ∩ J) ∨ I ∩ J = {}›*)
by simp
next
(*goal: ‹I ∩ J ≠ {} ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*)
assume "I∩J ≠ {}" (*‹(I::'a set) ∩ (J::'a set) ≠ {}›*)
have "I∩J = {a}"
proof (safe)
(*goals:
1. ‹⋀x. ⟦x ∉ {}; x ∈ I; x ∈ J⟧ ⟹ x = a›
2. ‹⋀x. a ∈ I›
3. ‹⋀x. a ∈ J›*)
fix x
assume "x∈I" "x∈J" "x∉{}" (*‹(x::'a) ∈ (I::'a set)› ‹(x::'a) ∈ (J::'a set)› ‹(x::'a) ∉ {}›*)
have cxd: "[c;x;d] ∨ x=c ∨ x=d"
using ‹J = interval c d› (*‹J = interval c d›*) ‹x ∈ J› (*‹x ∈ J›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by auto
consider "[a;x;b]" | "x=a" | "x=b"
(*goal: ‹⟦[a;x;b] ⟹ thesis; x = a ⟹ thesis; x = b ⟹ thesis⟧ ⟹ thesis›*)
using ‹I = interval a b› (*‹I = interval a b›*) ‹x ∈ I› (*‹x ∈ I›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by auto
then show "x=a"
proof (cases)
(*goals:
1. ‹[a;x;b] ⟹ x = a›
2. ‹x = a ⟹ x = a›
3. ‹x = b ⟹ x = a›*)
assume "[a;x;b]" (*‹[a::'a;x::'a;b::'a]›*)
hence "[b;x;d;c]"
using ‹[b;a;c] ∧ a = d› (*‹[b;a;c] ∧ a = d›*) abc_acd_bcd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?b;?c;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by meson
hence False
using cxd (*‹[c;x;d] ∨ x = c ∨ x = d›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) by blast
thus "?thesis"
(*goal: ‹x = a›*)
by simp
next
(*goals:
1. ‹x = a ⟹ x = a›
2. ‹x = b ⟹ x = a›*)
assume "x=b" (*‹(x::'a) = (b::'a)›*)
hence "[b;d;c]"
using ‹[b;a;c] ∧ a = d› (*‹[b;a;c] ∧ a = d›*) by blast
hence False
using cxd (*‹[c;x;d] ∨ x = c ∨ x = d›*) ‹x = b› (*‹x = b›*) abc_abc_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) by blast
thus "?thesis"
(*goal: ‹x = a›*)
by simp
next
(*goal: ‹x = a ⟹ x = a›*)
assume "x=a" (*‹(x::'a) = (a::'a)›*)
thus "x=a"
by simp
qed
next
(*goals:
1. ‹⋀x. a ∈ I›
2. ‹⋀x. a ∈ J›*)
show "a∈I"
by (simp add: ‹I = interval a b› ends_in_int (*‹?a ∈ interval ?a ?b ∧ ?b ∈ interval ?a ?b›*))
show "a∈J"
by (simp add: ‹J = interval c d› ‹[b;a;c] ∧ a = d› ends_in_int (*‹?a ∈ interval ?a ?b ∧ ?b ∈ interval ?a ?b›*))
qed
thus "?p I J"
by (simp add: empty_segment (*‹segment ?a ?a = {}›*) interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*))
qed
qed
qed
have "?p I J"
using wlog_interval_endpoints_degenerate[where P = "?p" and I = I and J = J and a = a and b = b and c = c and d = d and Q = P] (*‹⟦⋀I J. ⟦is_interval I; is_interval J; is_interval (I ∩ J) ∨ I ∩ J = {}⟧ ⟹ is_interval (J ∩ I) ∨ J ∩ I = {}; ⋀I J a b c d Q. ⟦I = interval a b; J = interval c d; I ⊆ Q; J ⊆ Q; Q ∈ 𝒫⟧ ⟹ (a = b ∧ b = c ∧ c = d ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}) ∧ (a = b ∧ b ≠ c ∧ c = d ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}) ∧ (a = b ∧ b = c ∧ c ≠ d ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}) ∧ (a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}) ∧ (a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}) ∧ ([a;b;c] ∧ a = d ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}) ∧ ([b;a;c] ∧ a = d ⟶ is_interval (I ∩ J) ∨ I ∩ J = {}); I = interval a b; J = interval c d; I ⊆ P; J ⊆ P; P ∈ 𝒫; ¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)⟧ ⟹ is_interval (I ∩ J) ∨ I ∩ J = {}›*) using degen_cases (*‹⟦?I = interval ?a ?b; ?J = interval ?c ?d; ?I ⊆ ?Q; ?J ⊆ ?Q; ?Q ∈ 𝒫⟧ ⟹ (?a = ?b ∧ ?b = ?c ∧ ?c = ?d ⟶ is_interval (?I ∩ ?J) ∨ ?I ∩ ?J = {}) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c = ?d ⟶ is_interval (?I ∩ ?J) ∨ ?I ∩ ?J = {}) ∧ (?a = ?b ∧ ?b = ?c ∧ ?c ≠ ?d ⟶ is_interval (?I ∩ ?J) ∨ ?I ∩ ?J = {}) ∧ (?a = ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ⟶ is_interval (?I ∩ ?J) ∨ ?I ∩ ?J = {}) ∧ (?a ≠ ?b ∧ ?b = ?c ∧ ?c ≠ ?d ∧ ?a = ?d ⟶ is_interval (?I ∩ ?J) ∨ ?I ∩ ?J = {}) ∧ ([?a;?b;?c] ∧ ?a = ?d ⟶ is_interval (?I ∩ ?J) ∨ ?I ∩ ?J = {}) ∧ ([?b;?a;?c] ∧ ?a = ?d ⟶ is_interval (?I ∩ ?J) ∨ ?I ∩ ?J = {})›*) using symmetry (*‹⟦is_interval ?I; is_interval ?J; is_interval (?I ∩ ?J) ∨ ?I ∩ ?J = {}⟧ ⟹ is_interval (?J ∩ ?I) ∨ ?J ∩ ?I = {}›*) assms (*‹I = interval a b› ‹J = interval c d› ‹I ∩ J ≠ {}› ‹I ⊆ P› ‹J ⊆ P› ‹P ∈ 𝒫› ‹¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)›*) by smt
thus "?thesis"
(*goal: ‹is_interval (I ∩ J)›*)
using assms(3) (*‹(I::'a set) ∩ (J::'a set) ≠ {}›*) by blast
qed
lemma int_of_ints_is_interval:
assumes "is_interval I" "is_interval J" "I⊆P" "J⊆P" "P∈𝒫" "I∩J ≠ {}"
shows "is_interval (I ∩ J)"
using int_of_ints_is_interval_neq (*‹⟦?I1.0 = interval ?a ?b; ?I2.0 = interval ?c ?d; ?I1.0 ⊆ ?P; ?I2.0 ⊆ ?P; ?P ∈ 𝒫; ?I1.0 ∩ ?I2.0 ≠ {}; ?a ≠ ?b; ?a ≠ ?c; ?a ≠ ?d; ?b ≠ ?c; ?b ≠ ?d; ?c ≠ ?d⟧ ⟹ is_interval (?I1.0 ∩ ?I2.0)›*) int_of_ints_is_interval_deg (*‹⟦?I = interval ?a ?b; ?J = interval ?c ?d; ?I ∩ ?J ≠ {}; ?I ⊆ ?P; ?J ⊆ ?P; ?P ∈ 𝒫; ¬ (?a ≠ ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ∧ ?a ≠ ?c ∧ ?b ≠ ?d)⟧ ⟹ is_interval (?I ∩ ?J)›*) by (meson assms (*‹is_interval I› ‹is_interval J› ‹I ⊆ P› ‹J ⊆ P› ‹P ∈ 𝒫› ‹I ∩ J ≠ {}›*))
lemma int_of_ints_is_interval2:
assumes "∀x∈S. (is_interval x ∧ x⊆P)" "P∈𝒫" "⋂S ≠ {}" "finite S" "S≠{}"
shows "is_interval (⋂S)"
proof (-)
(*goal: ‹is_interval (⋂ S)›*)
obtain n where "n = card S"
(*goal: ‹(⋀n. n = card S ⟹ thesis) ⟹ thesis›*)
by simp
consider "n=0" | "n=1" | "n≥2"
(*goal: ‹⟦n = 0 ⟹ thesis; n = 1 ⟹ thesis; 2 ≤ n ⟹ thesis⟧ ⟹ thesis›*)
by linarith
thus "?thesis"
(*goal: ‹is_interval (⋂ S)›*)
proof (cases)
(*goals:
1. ‹(n::nat) = (0::nat) ⟹ is_interval (⋂ (S::'a::type set set))›
2. ‹(n::nat) = (1::nat) ⟹ is_interval (⋂ (S::'a::type set set))›
3. ‹(2::nat) ≤ (n::nat) ⟹ is_interval (⋂ (S::'a::type set set))›*)
assume "n=0" (*‹(n::nat) = (0::nat)›*)
then have False
using ‹n = card S› (*‹(n::nat) = card (S::'a set set)›*) assms(4,5) (*‹finite S› ‹S ≠ {}›*) by simp
thus "?thesis"
(*goal: ‹is_interval (⋂ S)›*)
by simp
next
(*goals:
1. ‹n = 1 ⟹ is_interval (⋂ S)›
2. ‹2 ≤ n ⟹ is_interval (⋂ S)›*)
assume "n=1" (*‹(n::nat) = (1::nat)›*)
then obtain I where "S = {I}"
(*goal: ‹(⋀I. S = {I} ⟹ thesis) ⟹ thesis›*)
using ‹n = card S› (*‹n = card S›*) card_1_singletonE (*‹⟦card ?A = 1; ⋀x. ?A = {x} ⟹ ?thesis⟧ ⟹ ?thesis›*) by auto
then have "⋂S = I"
by simp
moreover have "is_interval I"
by (simp add: ‹S = {I}› assms( (*‹∀x∈S. is_interval x ∧ x ⊆ P›*) 1))
ultimately show "?thesis"
(*goal: ‹is_interval (⋂ (S::'a set set))›*)
by blast
next
(*goal: ‹2 ≤ n ⟹ is_interval (⋂ S)›*)
assume "2≤n" (*‹(2::nat) ≤ (n::nat)›*)
obtain m where "m+2=n"
(*goal: ‹(⋀m. m + 2 = n ⟹ thesis) ⟹ thesis›*)
using ‹2 ≤ n› (*‹(2::nat) ≤ (n::nat)›*) le_add_diff_inverse2 (*‹?b ≤ ?a ⟹ ?a - ?b + ?b = ?a›*) by blast
have ind: "⋀S. ⟦∀x∈S. (is_interval x ∧ x⊆P); P∈𝒫; ⋂S ≠ {}; finite S; S≠{}; m+2=card S⟧
⟹ is_interval (⋂S)"
proof (induct m)
(*goals:
1. ‹⋀S. ⟦∀x∈S. is_interval x ∧ x ⊆ P; P ∈ 𝒫; ⋂ S ≠ {}; finite S; S ≠ {}; 0 + 2 = card S⟧ ⟹ is_interval (⋂ S)›
2. ‹⋀m S. ⟦⋀S. ⟦∀x∈S. is_interval x ∧ x ⊆ P; P ∈ 𝒫; ⋂ S ≠ {}; finite S; S ≠ {}; m + 2 = card S⟧ ⟹ is_interval (⋂ S); ∀x∈S. is_interval x ∧ x ⊆ P; P ∈ 𝒫; ⋂ S ≠ {}; finite S; S ≠ {}; Suc m + 2 = card S⟧ ⟹ is_interval (⋂ S)›*)
case 0 (*‹∀x::'a set∈S::'a set set. is_interval x ∧ x ⊆ (P::'a set)› ‹P ∈ 𝒫› ‹⋂ S ≠ {}› ‹finite S› ‹(S::'a set set) ≠ {}› ‹0 + 2 = card S›*)
then have "card S = 2"
by auto
then obtain I and J where "S={I,J}" "I≠J"
(*goal: ‹(⋀I J. ⟦S = {I, J}; I ≠ J⟧ ⟹ thesis) ⟹ thesis›*)
by (meson card_2_iff (*‹(card (?S::?'a::type set) = (2::nat)) = (∃(x::?'a::type) y::?'a::type. ?S = {x, y} ∧ x ≠ y)›*))
then have "I∈S" "J∈S"
apply -
(*goals:
1. ‹⟦(S::'a set set) = {I::'a set, J::'a set}; I ≠ J⟧ ⟹ I ∈ S›
2. ‹⟦(S::'a set set) = {I::'a set, J::'a set}; I ≠ J⟧ ⟹ J ∈ S›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
then have "is_interval I" "is_interval J" "I⊆P" "J⊆P"
apply -
(*goals:
1. ‹⟦I ∈ S; J ∈ S⟧ ⟹ is_interval I›
2. ‹⟦I ∈ S; J ∈ S⟧ ⟹ is_interval J›
3. ‹⟦I ∈ S; J ∈ S⟧ ⟹ I ⊆ P›
4. ‹⟦I ∈ S; J ∈ S⟧ ⟹ J ⊆ P›
discuss goal 1*)
apply (simp add: "0.prems" (*‹∀x::'a::type set∈S::'a::type set set. is_interval x ∧ x ⊆ (P::'a::type set)›*) (1))
(*discuss goal 2*)
apply (simp add: "0.prems" (*‹∀x::'a::type set∈S::'a::type set set. is_interval x ∧ x ⊆ (P::'a::type set)›*) (1))
(*discuss goal 3*)
apply (simp add: "0.prems" (*‹∀x∈S. is_interval x ∧ x ⊆ P›*) (1))
(*discuss goal 4*)
apply (simp add: "0.prems" (*‹∀x∈S. is_interval x ∧ x ⊆ P›*) (1))
(*proven 4 subgoals*) .
also (*calculation:
‹is_interval I›
‹is_interval J›
‹I ⊆ P›
‹J ⊆ P›*) have "I∩J ≠ {}"
using ‹S={I,J}› (*‹S = {I, J}›*) "0.prems"(3) (*‹⋂ S ≠ {}›*) by force
then have "is_interval(I∩J)"
using assms(2) (*‹P ∈ 𝒫›*) calculation (*‹is_interval I› ‹is_interval J› ‹I ⊆ P› ‹(J::'a set) ⊆ (P::'a set)›*) int_of_ints_is_interval[where I = I and J = J and P = P] (*‹⟦is_interval I; is_interval J; I ⊆ P; J ⊆ P; P ∈ 𝒫; I ∩ J ≠ {}⟧ ⟹ is_interval (I ∩ J)›*) by fastforce
then show "?case"
(*goal: ‹is_interval (⋂ S)›*)
by (simp add: ‹S = {I, J}›)
next
(*goal: ‹⋀m S. ⟦⋀S. ⟦∀x∈S. is_interval x ∧ x ⊆ P; P ∈ 𝒫; ⋂ S ≠ {}; finite S; S ≠ {}; m + 2 = card S⟧ ⟹ is_interval (⋂ S); ∀x∈S. is_interval x ∧ x ⊆ P; P ∈ 𝒫; ⋂ S ≠ {}; finite S; S ≠ {}; Suc m + 2 = card S⟧ ⟹ is_interval (⋂ S)›*)
case (Suc m) (*‹⟦∀x∈?S. is_interval x ∧ x ⊆ P; P ∈ 𝒫; ⋂ ?S ≠ {}; finite ?S; ?S ≠ {}; m + 2 = card ?S⟧ ⟹ is_interval (⋂ ?S)› ‹∀x::'a set∈S::'a set set. is_interval x ∧ x ⊆ (P::'a set)› ‹P ∈ 𝒫› ‹⋂ (S::'a set set) ≠ {}› ‹finite S› ‹(S::'a set set) ≠ {}› ‹Suc (m::nat) + (2::nat) = card (S::'a::type set set)›*)
obtain S' and I where "I∈S" "S = insert I S'" "I∉S'"
(*goal: ‹(⋀I S'. ⟦I ∈ S; S = insert I S'; I ∉ S'⟧ ⟹ thesis) ⟹ thesis›*)
using Suc.prems(4,5) (*‹finite S› ‹S ≠ {}›*) by (metis Set.set_insert (*‹⟦?x ∈ ?A; ⋀B. ⟦?A = insert ?x B; ?x ∉ B⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) finite.simps (*‹finite ?a = (?a = {} ∨ (∃A a. ?a = insert a A ∧ finite A))›*) insertI1 (*‹?a ∈ insert ?a ?B›*))
then have "is_interval (⋂S')"
proof (-)
(*goal: ‹⟦I ∈ S; S = insert I S'; I ∉ S'⟧ ⟹ is_interval (⋂ S')›*)
have "m+2 = card S'"
using Suc.prems(4,6) (*‹finite S› ‹Suc (m::nat) + (2::nat) = card (S::'a set set)›*) ‹S = insert I S'› (*‹(S::'a::type set set) = insert (I::'a::type set) (S'::'a::type set set)›*) ‹I∉S'› (*‹I ∉ S'›*) by auto
moreover have "∀x∈S'. is_interval x ∧ x ⊆ P"
by (simp add: Suc.prems( (*‹∀x∈S. is_interval x ∧ x ⊆ P›*) 1) ‹S = insert I S'›)
moreover have "⋂ S' ≠ {}"
using Suc.prems(3) (*‹⋂ S ≠ {}›*) ‹S = insert I S'› (*‹(S::'a set set) = insert (I::'a set) (S'::'a set set)›*) by auto
moreover have "finite S'"
using Suc.prems(4) (*‹finite S›*) ‹S = insert I S'› (*‹S = insert I S'›*) by auto
ultimately show "?thesis"
(*goal: ‹is_interval (⋂ S')›*)
using assms(2) (*‹(P::'a set) ∈ (𝒫::'a set set)›*) Suc(1)[where S = S'] (*‹⟦∀x∈S'. is_interval x ∧ x ⊆ P; P ∈ 𝒫; ⋂ S' ≠ {}; finite S'; S' ≠ {}; m + 2 = card S'⟧ ⟹ is_interval (⋂ S')›*) by fastforce
qed
then have "is_interval ((⋂S')∩I)"
proof (rule int_of_ints_is_interval (*‹⟦is_interval (?I::'a set); is_interval (?J::'a set); ?I ⊆ (?P::'a set); ?J ⊆ ?P; ?P ∈ (𝒫::'a set set); ?I ∩ ?J ≠ {}⟧ ⟹ is_interval (?I ∩ ?J)›*))
(*goals:
1. ‹is_interval I›
2. ‹⋂ S' ⊆ ?P›
3. ‹I ⊆ ?P›
4. ‹?P ∈ 𝒫›
5. ‹⋂ S' ∩ I ≠ {}›*)
show "is_interval I"
by (simp add: Suc.prems( (*‹∀x∈S. is_interval x ∧ x ⊆ P›*) 1) ‹I ∈ S›)
show "⋂S' ⊆ P"
using ‹I ∉ S'› (*‹I ∉ S'›*) ‹S = insert I S'› (*‹S = insert I S'›*) Suc.prems(1,4,6) (*‹∀x::'a set∈S::'a set set. is_interval x ∧ x ⊆ (P::'a set)› ‹finite (S::'a set set)› ‹Suc m + 2 = card S›*) Inter_subset (*‹⟦⋀X. X ∈ ?A ⟹ X ⊆ ?B; ?A ≠ {}⟧ ⟹ ⋂ ?A ⊆ ?B›*) by (metis Suc_n_not_le_n (*‹¬ Suc ?n ≤ ?n›*) card.empty (*‹card {} = 0›*) card_insert_disjoint (*‹⟦finite ?A; ?x ∉ ?A⟧ ⟹ card (insert ?x ?A) = Suc (card ?A)›*) finite_insert (*‹finite (insert ?a ?A) = finite ?A›*) le_add2 (*‹?n ≤ ?m + ?n›*) numeral_2_eq_2 (*‹2 = Suc (Suc 0)›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) subset_insertI (*‹?B ⊆ insert ?a ?B›*))
show "I ⊆ P"
by (simp add: Suc.prems( (*‹∀x∈S. is_interval x ∧ x ⊆ P›*) 1) ‹I ∈ S›)
show "P ∈ 𝒫"
using assms(2) (*‹P ∈ 𝒫›*) by auto
show "⋂S' ∩ I ≠ {}"
using Suc.prems(3) (*‹⋂ S ≠ {}›*) ‹S = insert I S'› (*‹S = insert I S'›*) by auto
qed
thus "?case"
(*goal: ‹is_interval (⋂ S)›*)
using ‹S = insert I S'› (*‹S = insert I S'›*) by (simp add: inf.commute (*‹inf ?a ?b = inf ?b ?a›*))
qed
then show "?thesis"
(*goal: ‹is_interval (⋂ S)›*)
using ‹m + 2 = n› (*‹m + 2 = n›*) ‹n = card S› (*‹n = card S›*) assms (*‹∀x∈S. is_interval x ∧ x ⊆ P› ‹(P::'a set) ∈ (𝒫::'a set set)› ‹⋂ S ≠ {}› ‹finite (S::'a set set)› ‹S ≠ {}›*) by blast
qed
qed
end (*context MinkowskiSpacetime*)
section "3.7 Continuity and the monotonic sequence property"
context MinkowskiSpacetime begin
text ‹
This section only includes a proof of the first part of Theorem 12, as well as some results
that would be useful in proving part (ii).
›
theorem (*12(i)*) two_rays:
assumes path_Q: "Q∈𝒫"
and event_a: "a∈Q"
shows "∃R L. (is_ray_on R Q ∧ is_ray_on L Q
∧ Q-{a} ⊆ (R ∪ L) ⌦‹events of Q excl. a belong to two rays›
∧ (∀r∈R. ∀l∈L. [l;a;r]) ⌦‹a is betw any 'a of one ray and any 'a of the other›
∧ (∀x∈R. ∀y∈R. ¬ [x;a;y]) ⌦‹but a is not betw any two events …›
∧ (∀x∈L. ∀y∈L. ¬ [x;a;y]))" ⌦‹… of the same ray›
proof (-)
(*goal: ‹∃R L. is_ray_on R Q ∧ is_ray_on L Q ∧ Q - {a} ⊆ R ∪ L ∧ (∀r∈R. ∀l∈L. [l;a;r]) ∧ (∀x∈R. ∀y∈R. ¬ [x;a;y]) ∧ (∀x∈L. ∀y∈L. ¬ [x;a;y])›*)
text ‹Schutz here uses Theorem 6, but we don't need it.›
obtain b where "b∈ℰ" and "b∈Q" and "b≠a"
(*goal: ‹(⋀b. ⟦b ∈ ℰ; b ∈ Q; b ≠ a⟧ ⟹ thesis) ⟹ thesis›*)
using event_a (*‹(a::'a) ∈ (Q::'a set)›*) ge2_events (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ∃b∈?Q. b ≠ ?a›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_Q (*‹Q ∈ 𝒫›*) by blast
let ?L = "{x. [x;a;b]}"
let ?R = "{y. [a;y;b] ∨ [a;b;y⟧}"
have "Q = ?L ∪ {a} ∪ ?R"
proof (-)
(*goal: ‹Q = {x. [x;a;b]} ∪ {a} ∪ {y. [a;y;b] ∨ [a;b;y⟧}›*)
have inQ: "∀x∈Q. [x;a;b] ∨ x=a ∨ [a;x;b] ∨ [a;b;x⟧"
by (meson ‹b ∈ Q› ‹b ≠ a› abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) event_a (*‹a ∈ Q›*) path_Q (*‹Q ∈ 𝒫›*) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*))
show "?thesis"
(*goal: ‹Q = {x. [x;a;b]} ∪ {a} ∪ {y. [a;y;b] ∨ [a;b;y⟧}›*)
proof (safe)
(*goals:
1. ‹⋀x. ⟦x ∈ Q; x ∉ {}; x ≠ a; ¬ [x;a;b]; ¬ [a;x;b]; b ≠ x⟧ ⟹ [a;b;x]›
2. ‹⋀x. [x;a;b] ⟹ x ∈ Q›
3. ‹⋀x. a ∈ Q›
4. ‹⋀x. [a;x;b] ⟹ x ∈ Q›
5. ‹⋀x. [a;b;x] ⟹ x ∈ Q›
6. ‹⋀x. b ∈ Q›*)
fix x
assume "x ∈ Q" "x ≠ a" "¬ [x;a;b]" "¬ [a;x;b]" "b ≠ x" (*‹(x::'a) ∈ (Q::'a set)› ‹(x::'a) ≠ (a::'a)› ‹¬ [x::'a;a::'a;b::'a]› ‹¬ [a::'a;x::'a;b::'a]› ‹(b::'a) ≠ (x::'a)›*)
then show "[a;b;x]"
using inQ (*‹∀x∈Q. [x;a;b] ∨ x = a ∨ [a;x;b] ∨ [a;b;x⟧›*) by blast
next
(*goals:
1. ‹⋀x::'a. [x;a::'a;b::'a] ⟹ x ∈ (Q::'a set)›
2. ‹⋀x::'a. (a::'a) ∈ (Q::'a set)›
3. ‹⋀x::'a. [a::'a;x;b::'a] ⟹ x ∈ (Q::'a set)›
4. ‹⋀x::'a. [a::'a;b::'a;x] ⟹ x ∈ (Q::'a set)›
5. ‹⋀x::'a. (b::'a) ∈ (Q::'a set)›*)
fix x
assume "[x;a;b]" (*‹[x::'a;a::'a;b::'a]›*)
then show "x ∈ Q"
by (simp add: ‹b ∈ Q› abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) betw_a_in_path (*‹⟦[?a;?b;?c]; path ?bc ?b ?c⟧ ⟹ ?a ∈ ?bc›*) event_a (*‹a ∈ Q›*) path_Q (*‹Q ∈ 𝒫›*))
next
(*goals:
1. ‹⋀x. a ∈ Q›
2. ‹⋀x. [a;x;b] ⟹ x ∈ Q›
3. ‹⋀x. [a;b;x] ⟹ x ∈ Q›
4. ‹⋀x. b ∈ Q›*)
show "a ∈ Q"
by (simp add: event_a (*‹a ∈ Q›*))
next
(*goals:
1. ‹⋀x. [a;x;b] ⟹ x ∈ Q›
2. ‹⋀x. [a;b;x] ⟹ x ∈ Q›
3. ‹⋀x. b ∈ Q›*)
fix x
assume "[a;x;b]" (*‹[a::'a;x::'a;b::'a]›*)
then show "x ∈ Q"
by (simp add: ‹b ∈ Q› abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) event_a (*‹a ∈ Q›*) path_Q (*‹Q ∈ 𝒫›*))
next
(*goals:
1. ‹⋀x. [a;b;x] ⟹ x ∈ Q›
2. ‹⋀x. b ∈ Q›*)
fix x
assume "[a;b;x]" (*‹[a::'a;b::'a;x::'a]›*)
then show "x ∈ Q"
by (simp add: ‹b ∈ Q› abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) event_a (*‹a ∈ Q›*) path_Q (*‹Q ∈ 𝒫›*))
next
(*goal: ‹⋀x. b ∈ Q›*)
show "b ∈ Q"
using ‹b ∈ Q› (*‹(b::'a::type) ∈ (Q::'a::type set)›*) .
qed
qed
have disjointLR: "?L ∩ ?R = {}"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) by blast
have wxyz_ord: "[x;a;y;b⟧ ∨ [x;a;b;y⟧
∧ (([w;x;a] ∧ [x;a;y]) ∨ ([x;w;a] ∧ [w;a;y]))
∧ (([x;a;y] ∧ [a;y;z]) ∨ ([x;a;z] ∧ [a;z;y]))" if "x∈?L" "w∈?L" "y∈?R" "z∈?R" "w≠x" "y≠z" for x and w and y and z
using path_finsubset_chain (*‹⟦?Q ∈ 𝒫; ?X ⊆ ?Q; 2 ≤ card ?X⟧ ⟹ ch ?X›*) order_finite_chain (*‹⟦local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set); finite ?X; (0::nat) ≤ (?i::nat) ∧ ?i < (?j::nat) ∧ ?j < (?l::nat) ∧ ?l < card ?X⟧ ⟹ [?f ?i;?f ?j;?f ?l]›*) by (smt abc_abd_bcdbdc (*‹⟦[?a;?b;?c]; [?a;?b;?d]; ?c ≠ ?d⟧ ⟹ [?b;?c;?d] ∨ [?b;?d;?c]›*) abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) that (*‹x ∈ {x. [x;a;b]}› ‹w ∈ {x. [x;a;b]}› ‹y ∈ {y. [a;y;b] ∨ [a;b;y⟧}› ‹z ∈ {y. [a;y;b] ∨ [a;b;y⟧}› ‹w ≠ x› ‹y ≠ z›*))
obtain x and y where "x∈?L" "y∈?R"
(*goal: ‹(⋀(x::'a) y::'a. ⟦x ∈ {x::'a. [x;a::'a;b::'a]}; y ∈ {y::'a. [a;y;b] ∨ [a;b;y⟧}⟧ ⟹ thesis::bool) ⟹ thesis›*)
by (metis (mono_tags) ‹b ∈ Q› ‹b ≠ a› abc_sym (*‹[?a::'a;?b::'a;?c::'a] ⟹ [?c;?b;?a]›*) event_a (*‹(a::'a) ∈ (Q::'a set)›*) mem_Collect_eq (*‹((?a::?'a) ∈ Collect (?P::?'a ⇒ bool)) = ?P ?a›*) path_Q (*‹(Q::'a set) ∈ (𝒫::'a set set)›*) prolong_betw2 (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q; (?b::'a) ∈ ?Q; ?a ≠ ?b⟧ ⟹ ∃c::'a∈?Q. [?a;?b;c]›*))
obtain w where "w∈?L" "w≠x"
(*goal: ‹(⋀w. ⟦w ∈ {x. [x;a;b]}; w ≠ x⟧ ⟹ thesis) ⟹ thesis›*)
by (metis ‹b ∈ Q› ‹b ≠ a› abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) event_a (*‹a ∈ Q›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) path_Q (*‹Q ∈ 𝒫›*) prolong_betw3 (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ∃c∈?Q. ∃d∈?Q. [?a;?b;c] ∧ [?a;?b;d] ∧ c ≠ d›*))
obtain z where "z∈?R" "y≠z"
(*goal: ‹(⋀z. ⟦z ∈ {y. [a;y;b] ∨ [a;b;y⟧}; y ≠ z⟧ ⟹ thesis) ⟹ thesis›*)
by (metis (mono_tags) ‹b ∈ Q› ‹b ≠ a› event_a (*‹a ∈ Q›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) path_Q (*‹Q ∈ 𝒫›*) prolong_betw3 (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ∃c∈?Q. ∃d∈?Q. [?a;?b;c] ∧ [?a;?b;d] ∧ c ≠ d›*))
have "is_ray_on ?R Q ∧
is_ray_on ?L Q ∧
Q - {a} ⊆ ?R ∪ ?L ∧
(∀r∈?R. ∀l∈?L. [l;a;r]) ∧
(∀x∈?R. ∀y∈?R. ¬ [x;a;y]) ∧
(∀x∈?L. ∀y∈?L. ¬ [x;a;y])"
proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹is_ray_on {y::'a::type. [a::'a::type;y;b::'a::type] ∨ [a;b;y⟧} (Q::'a::type set)›
2. ‹is_ray_on {x::'a::type. [x;a::'a::type;b::'a::type]} (Q::'a::type set)›
3. ‹(Q::'a::type set) - {a::'a::type} ⊆ {y::'a::type. [a;y;b::'a::type] ∨ [a;b;y⟧} ∪ {x::'a::type. [x;a;b]}›
4. ‹∀r::'a::type∈{y::'a::type. [a::'a::type;y;b::'a::type] ∨ [a;b;y⟧}. ∀l::'a::type∈{x::'a::type. [x;a;b]}. [l;a;r]›
5. ‹∀x::'a::type∈{y::'a::type. [a::'a::type;y;b::'a::type] ∨ [a;b;y⟧}. ∀y::'a::type∈{y::'a::type. [a;y;b] ∨ [a;b;y⟧}. ¬ [x;a;y]›
6. ‹∀x::'a::type∈{x::'a::type. [x;a::'a::type;b::'a::type]}. ∀y::'a::type∈{x::'a::type. [x;a;b]}. ¬ [x;a;y]›*)
show "is_ray_on ?L Q"
proof (unfold is_ray_on_def (*‹is_ray_on ?R ?P ≡ ?P ∈ 𝒫 ∧ ?R ⊆ ?P ∧ is_ray ?R›*), safe)
(*goals:
1. ‹Q ∈ 𝒫›
2. ‹⋀x. [x;a;b] ⟹ x ∈ Q›
3. ‹is_ray {x. [x;a;b]}›*)
show "Q ∈ 𝒫"
by (simp add: path_Q (*‹Q ∈ 𝒫›*))
next
(*goals:
1. ‹⋀x. [x;a;b] ⟹ x ∈ Q›
2. ‹is_ray {x. [x;a;b]}›*)
fix x
assume "[x;a;b]" (*‹[x::'a;a::'a;b::'a]›*)
then show "x ∈ Q"
using ‹b ∈ Q› (*‹b ∈ Q›*) ‹b ≠ a› (*‹b ≠ a›*) betw_a_in_path (*‹⟦[?a;?b;?c]; path ?bc ?b ?c⟧ ⟹ ?a ∈ ?bc›*) event_a (*‹(a::'a::type) ∈ (Q::'a::type set)›*) path_Q (*‹Q ∈ 𝒫›*) by blast
next
(*goal: ‹is_ray {x. [x;a;b]}›*)
show "is_ray {x. [x;a;b]}"
proof (-)
(*goal: ‹is_ray {x. [x;a;b]}›*)
have "[x;a;b]"
using ‹x∈?L› (*‹x ∈ {x. [x;a;b]}›*) by simp
have "?L = ray a x"
proof (standard)
(*goals:
1. ‹{x::'a::type. [x;a::'a::type;b::'a::type]} ⊆ ray a (x::'a::type)›
2. ‹ray (a::'a::type) (x::'a::type) ⊆ {x::'a::type. [x;a;b::'a::type]}›*)
show "ray a x ⊆ ?L"
proof (standard)
(*goal: ‹⋀xa::'a. xa ∈ ray (a::'a) (x::'a) ⟹ xa ∈ {x::'a. [x;a;b::'a]}›*)
fix e
assume "e∈ray a x" (*‹(e::'a) ∈ ray (a::'a) (x::'a)›*)
show "e∈?L"
using wxyz_ord (*‹⟦(?x::'a) ∈ {x::'a. [x;a::'a;b::'a]}; (?w::'a) ∈ {x::'a. [x;a;b]}; (?y::'a) ∈ {y::'a. [a;y;b] ∨ [a;b;y⟧}; (?z::'a) ∈ {y::'a. [a;y;b] ∨ [a;b;y⟧}; ?w ≠ ?x; ?y ≠ ?z⟧ ⟹ [?x;a;?y;b⟧ ∨ [?x;a;b;?y⟧ ∧ ([?w;?x;a;?y] ∨ [?x;?w;a;?y]) ∧ ([?x;a;?y;?z] ∨ [?x;a;?z;?y])›*) ray_cases (*‹?x ∈ ray ?a ?b ⟹ [?a;?x;?b] ∨ [?a;?b;?x] ∨ ?x = ?b›*) abc_bcd_abd (*‹⟦[?a::'a;?b::'a;?c::'a]; [?b;?c;?d::'a]⟧ ⟹ [?a;?b;?d]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) abc_sym (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ [?c;?b;?a]›*) by (metis ‹[x;a;b]› ‹e ∈ ray a x› mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*))
qed
show "?L ⊆ ray a x"
proof (standard)
(*goal: ‹⋀xa. xa ∈ {x. [x;a;b]} ⟹ xa ∈ ray a x›*)
fix e
assume "e∈?L" (*‹(e::'a) ∈ {x::'a. [x;a::'a;b::'a]}›*)
hence "[e;a;b]"
by simp
show "e∈ray a x"
proof (cases)
(*goals:
1. ‹?P::bool ⟹ (e::'a) ∈ ray (a::'a) (x::'a)›
2. ‹¬ (?P::bool) ⟹ (e::'a) ∈ ray (a::'a) (x::'a)›*)
assume "e=x" (*‹(e::'a) = (x::'a)›*)
thus "?thesis"
(*goal: ‹e ∈ ray a x›*)
by (simp add: ray_def (*‹ray (?a::'a) (?b::'a) ≡ insert ?b (segment ?a ?b ∪ prolongation ?a ?b)›*))
next
(*goal: ‹(e::'a) ≠ (x::'a) ⟹ e ∈ ray (a::'a) x›*)
assume "e≠x" (*‹(e::'a) ≠ (x::'a)›*)
hence "[e;x;a] ∨ [x;e;a]"
using wxyz_ord (*‹⟦?x ∈ {x. [x;a;b]}; ?w ∈ {x. [x;a;b]}; ?y ∈ {y. [a;y;b] ∨ [a;b;y⟧}; ?z ∈ {y. [a;y;b] ∨ [a;b;y⟧}; ?w ≠ ?x; ?y ≠ ?z⟧ ⟹ [?x;a;?y;b⟧ ∨ [?x;a;b;?y⟧ ∧ ([?w;?x;a;?y] ∨ [?x;?w;a;?y]) ∧ ([?x;a;?y;?z] ∨ [?x;a;?z;?y])›*) by (meson ‹[e;a;b]› ‹[x;a;b]› abc_abd_bcdbdc (*‹⟦[?a;?b;?c]; [?a;?b;?d]; ?c ≠ ?d⟧ ⟹ [?b;?c;?d] ∨ [?b;?d;?c]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*))
thus "e∈ray a x"
by (metis Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) insertCI (*‹(?a ∉ ?B ⟹ ?a = ?b) ⟹ ?a ∈ insert ?b ?B›*) pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*) ray_def (*‹ray ?a ?b ≡ insert ?b (segment ?a ?b ∪ prolongation ?a ?b)›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*))
qed
qed
qed
thus "is_ray ?L"
by auto
qed
qed
show "is_ray_on ?R Q"
proof (unfold is_ray_on_def (*‹is_ray_on ?R ?P ≡ ?P ∈ 𝒫 ∧ ?R ⊆ ?P ∧ is_ray ?R›*), safe)
(*goals:
1. ‹(Q::'a set) ∈ (𝒫::'a set set)›
2. ‹⋀x::'a. [a::'a;x;b::'a] ⟹ x ∈ (Q::'a set)›
3. ‹⋀x::'a. [a::'a;b::'a;x] ⟹ x ∈ (Q::'a set)›
4. ‹⋀x::'a. (b::'a) ∈ (Q::'a set)›
5. ‹is_ray {y::'a. [a::'a;y;b::'a] ∨ [a;b;y⟧}›*)
show "Q ∈ 𝒫"
by (simp add: path_Q (*‹Q ∈ 𝒫›*))
next
(*goals:
1. ‹⋀x::'a. [a::'a;x;b::'a] ⟹ x ∈ (Q::'a set)›
2. ‹⋀x::'a. [a::'a;b::'a;x] ⟹ x ∈ (Q::'a set)›
3. ‹⋀x::'a. (b::'a) ∈ (Q::'a set)›
4. ‹is_ray {y::'a. [a::'a;y;b::'a] ∨ [a;b;y⟧}›*)
fix x
assume "[a;x;b]" (*‹[a::'a;x::'a;b::'a]›*)
then show "x ∈ Q"
by (simp add: ‹b ∈ Q› abc_abc_neq (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) betw_b_in_path (*‹⟦[?a::'a::type;?b::'a::type;?c::'a::type]; path (?ac::'a::type set) ?a ?c⟧ ⟹ ?b ∈ ?ac›*) event_a (*‹(a::'a::type) ∈ (Q::'a::type set)›*) path_Q (*‹(Q::'a::type set) ∈ (𝒫::'a::type set set)›*))
next
(*goals:
1. ‹⋀x. [a;b;x] ⟹ x ∈ Q›
2. ‹⋀x. b ∈ Q›
3. ‹is_ray {y. [a;y;b] ∨ [a;b;y⟧}›*)
fix x
assume "[a;b;x]" (*‹[a::'a;b::'a;x::'a]›*)
then show "x ∈ Q"
by (simp add: ‹b ∈ Q› abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) event_a (*‹a ∈ Q›*) path_Q (*‹Q ∈ 𝒫›*))
next
(*goals:
1. ‹⋀x. b ∈ Q›
2. ‹is_ray {y. [a;y;b] ∨ [a;b;y⟧}›*)
show "b ∈ Q"
using ‹b ∈ Q› (*‹b ∈ Q›*) .
next
(*goal: ‹is_ray {y. [a;y;b] ∨ [a;b;y⟧}›*)
show "is_ray {y. [a;y;b] ∨ [a;b;y⟧}"
proof (-)
(*goal: ‹is_ray {y. [a;y;b] ∨ [a;b;y⟧}›*)
have "[a;y;b] ∨ [a;b;y] ∨ y=b"
using ‹y∈?R› (*‹y ∈ {y. [a;y;b] ∨ [a;b;y⟧}›*) by blast
have "?R = ray a y"
proof (standard)
(*goals:
1. ‹{y. [a;y;b] ∨ [a;b;y⟧} ⊆ ray a y›
2. ‹ray a y ⊆ {y. [a;y;b] ∨ [a;b;y⟧}›*)
show "ray a y ⊆ ?R"
proof (standard)
(*goal: ‹⋀x. x ∈ ray a y ⟹ x ∈ {y. [a;y;b] ∨ [a;b;y⟧}›*)
fix e
assume "e∈ray a y" (*‹(e::'a) ∈ ray (a::'a) (y::'a)›*)
hence "[a;e;y] ∨ [a;y;e] ∨ y=e"
using ray_cases (*‹?x ∈ ray ?a ?b ⟹ [?a;?x;?b] ∨ [?a;?b;?x] ∨ ?x = ?b›*) by auto
show "e∈?R"
proof (-)
(*goal: ‹e ∈ {y. [a;y;b] ∨ [a;b;y⟧}›*)
{
assume "e ≠ b" (*‹(e::'a) ≠ (b::'a)›*)
have "(e ≠ y ∧ e ≠ b) ∧ [w;a;y] ∨ [a;e;b] ∨ [a;b;e⟧"
using ‹[a;y;b] ∨ [a;b;y] ∨ y = b› (*‹[a;y;b] ∨ [a;b;y] ∨ y = b›*) ‹w ∈ {x. [x;a;b]}› (*‹w ∈ {x. [x;a;b]}›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) by blast
hence "[a;e;b] ∨ [a;b;e⟧"
using abc_abd_bcdbdc (*‹⟦[?a;?b;?c]; [?a;?b;?d]; ?c ≠ ?d⟧ ⟹ [?b;?c;?d] ∨ [?b;?d;?c]›*) abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) by (metis ‹[a;e;y] ∨ [a;y;e⟧› ‹w ∈ ?L› mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*))
}
thus "?thesis"
(*goal: ‹e ∈ {y. [a;y;b] ∨ [a;b;y⟧}›*)
by blast
qed
qed
show "?R ⊆ ray a y"
proof (standard)
(*goal: ‹⋀x. x ∈ {y. [a;y;b] ∨ [a;b;y⟧} ⟹ x ∈ ray a y›*)
fix e
assume "e∈?R" (*‹(e::'a) ∈ {y::'a. [a::'a;y;b::'a] ∨ [a;b;y⟧}›*)
hence aeb_cases: "[a;e;b] ∨ [a;b;e] ∨ e=b"
by blast
hence aey_cases: "[a;e;y] ∨ [a;y;e] ∨ e=y"
using abc_abd_bcdbdc (*‹⟦[?a;?b;?c]; [?a;?b;?d]; ?c ≠ ?d⟧ ⟹ [?b;?c;?d] ∨ [?b;?d;?c]›*) abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abd_bcd_abc (*‹⟦[?a::'a;?b::'a;?d::'a]; [?b;?c::'a;?d]⟧ ⟹ [?a;?b;?c]›*) by (metis ‹[a;y;b] ∨ [a;b;y] ∨ y = b› ‹x ∈ {x. [x;a;b]}› mem_Collect_eq (*‹((?a::?'a) ∈ Collect (?P::?'a ⇒ bool)) = ?P ?a›*))
show "e∈ray a y"
proof (-)
(*goal: ‹e ∈ ray a y›*)
{
assume "e=b" (*‹(e::'a) = (b::'a)›*)
hence "?thesis"
using ‹[a;y;b] ∨ [a;b;y] ∨ y = b› (*‹[a;y;b] ∨ [a;b;y] ∨ y = b›*) ‹b ≠ a› (*‹(b::'a) ≠ (a::'a)›*) pro_betw (*‹((?x::'a) ∈ prolongation (?a::'a) (?b::'a)) = [?a;?b;?x]›*) ray_def (*‹ray ?a ?b ≡ insert ?b (segment ?a ?b ∪ prolongation ?a ?b)›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by auto
}
moreover {
assume "[a;e;b] ∨ [a;b;e]" (*‹[a::'a;e::'a;b::'a] ∨ [a;b;e]›*)
assume "y≠e" (*‹(y::'a) ≠ (e::'a)›*)
hence "[a;e;y] ∨ [a;y;e]"
using aey_cases (*‹[a;e;y] ∨ [a;y;e] ∨ e = y›*) by auto
hence "e∈ray a y"
unfolding ray_def
(*goal: ‹e ∈ insert y (segment a y ∪ prolongation a y)›*)
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by auto
}
moreover {
assume "[a;e;b] ∨ [a;b;e]" (*‹[a::'a;e::'a;b::'a] ∨ [a;b;e]›*)
assume "y=e" (*‹(y::'a) = (e::'a)›*)
have "e∈ray a y"
unfolding ray_def
(*goal: ‹e ∈ insert y (segment a y ∪ prolongation a y)›*)
by (simp add: ‹y = e›)
}
ultimately show "?thesis"
(*goal: ‹e ∈ ray a y›*)
using aeb_cases (*‹[a;e;b] ∨ [a;b;e] ∨ e = b›*) by blast
qed
qed
qed
thus "is_ray ?R"
by auto
qed
qed
show "(∀r∈?R. ∀l∈?L. [l;a;r])"
using abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) by blast
show "∀x∈?R. ∀y∈?R. ¬ [x;a;y]"
by (smt abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) abc_bcd_abd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*))
show "∀x∈?L. ∀y∈?L. ¬ [x;a;y]"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_abd_bcdbdc (*‹⟦[?a;?b;?c]; [?a;?b;?d]; ?c ≠ ?d⟧ ⟹ [?b;?c;?d] ∨ [?b;?d;?c]›*) abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) by blast
show "Q-{a} ⊆ ?R ∪ ?L"
using ‹Q = {x. [x;a;b]} ∪ {a} ∪ {y. [a;y;b] ∨ [a;b;y⟧}› (*‹Q = {x. [x;a;b]} ∪ {a} ∪ {y. [a;y;b] ∨ [a;b;y⟧}›*) by blast
qed
thus "?thesis"
(*goal: ‹∃R L. is_ray_on R Q ∧ is_ray_on L Q ∧ Q - {a} ⊆ R ∪ L ∧ (∀r∈R. ∀l∈L. [l;a;r]) ∧ (∀x∈R. ∀y∈R. ¬ [x;a;y]) ∧ (∀x∈L. ∀y∈L. ¬ [x;a;y])›*)
by (metis (mono_tags, lifting))
qed
text ‹
The definition ‹closest_to› in prose:
Pick any $r \in R$. The closest event $c$ is such that there is no closer event in $L$,
i.e. all other events of $L$ are further away from $r$.
Thus in $L$, $c$ is the element closest to $R$.
›
definition closest_to :: "('a set) ⇒ 'a ⇒ ('a set) ⇒ bool"
where "closest_to L c R ≡ c∈L ∧ (∀r∈R. ∀l∈L-{c}. [l;c;r])"
lemma int_on_path:
assumes "l∈L" "r∈R" "Q∈𝒫"
and partition: "L⊆Q" "L≠{}" "R⊆Q" "R≠{}" "L∪R=Q"
shows "interval l r ⊆ Q"
proof (standard)
(*goal: ‹⋀x. x ∈ interval l r ⟹ x ∈ Q›*)
fix x
assume "x∈interval l r" (*‹(x::'a) ∈ interval (l::'a) (r::'a)›*)
thus "x∈Q"
unfolding interval_def segment_def
(*goal: ‹x ∈ Q›*)
using betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) partition(5) (*‹L ∪ R = Q›*) ‹Q∈𝒫› (*‹Q ∈ 𝒫›*) seg_betw (*‹((?x::'a) ∈ segment (?a::'a) (?b::'a)) = [?a;?x;?b]›*) ‹l ∈ L› (*‹l ∈ L›*) ‹r ∈ R› (*‹r ∈ R›*) by blast
qed
lemma ray_of_bounds1:
assumes "Q∈𝒫" "[f↝X|(f 0)..]" "X⊆Q" "closest_bound c X" "is_bound_f b X f" "b≠c"
assumes "is_bound_f x X f"
shows "x=b ∨ x=c ∨ [c;x;b] ∨ [c;b;x]"
proof (-)
(*goal: ‹x = b ∨ x = c ∨ [c;x;b] ∨ [c;b;x]›*)
have "x∈Q"
using bound_on_path (*‹⟦?Q ∈ 𝒫; [?f↝?X|?f 0 ..]; ?X ⊆ ?Q; is_bound_f ?b ?X ?f⟧ ⟹ ?b ∈ ?Q›*) assms(1,3,7) (*‹Q ∈ 𝒫› ‹X ⊆ Q› ‹is_bound_f x X f›*) unfolding all_bounds_def is_bound_def is_bound_f_def
(*goal: ‹x ∈ Q›*)
by auto
{
assume "x=b" (*‹(x::'a) = (b::'a)›*)
hence "?thesis"
by blast
}
moreover {
assume "x=c" (*‹(x::'a) = (c::'a)›*)
hence "?thesis"
by blast
}
moreover {
assume "x≠b" "x≠c" (*‹(x::'a) ≠ (b::'a)› ‹(x::'a) ≠ (c::'a)›*)
hence "?thesis"
by (meson abc_abd_bcdbdc (*‹⟦[?a;?b;?c]; [?a;?b;?d]; ?c ≠ ?d⟧ ⟹ [?b;?c;?d] ∨ [?b;?d;?c]›*) assms( (*‹closest_bound c X› ‹is_bound_f b X f› ‹b ≠ c› ‹is_bound_f x X f›*) 4,5,6,7) closest_bound_def (*‹closest_bound ?Q⇩b ?Q ≡ ∃f. is_bound_f ?Q⇩b ?Q f ∧ (∀Q⇩b'. is_bound Q⇩b' ?Q ∧ Q⇩b' ≠ ?Q⇩b ⟶ [f 0;?Q⇩b;Q⇩b'])›*) is_bound_def (*‹is_bound ?Q⇩b ?Q ≡ ∃f. is_bound_f ?Q⇩b ?Q f›*))
}
ultimately show "?thesis"
(*goal: ‹x = b ∨ x = c ∨ [c;x;b] ∨ [c;b;x]›*)
by blast
qed
lemma ray_of_bounds2:
assumes "Q∈𝒫" "[f↝X|(f 0)..]" "X⊆Q" "closest_bound_f c X f" "is_bound_f b X f" "b≠c"
assumes "x=b ∨ x=c ∨ [c;x;b] ∨ [c;b;x]"
shows "is_bound_f x X f"
proof (-)
(*goal: ‹is_bound_f x X f›*)
have "x∈Q"
using assms(1,3,4,5,6,7) (*‹Q ∈ 𝒫› ‹X ⊆ Q› ‹closest_bound_f c X f› ‹is_bound_f b X f› ‹b ≠ c› ‹x = b ∨ x = c ∨ [c;x;b] ∨ [c;b;x]›*) betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) betw_c_in_path (*‹⟦[?a::'a::type;?b::'a::type;?c::'a::type]; path (?ab::'a::type set) ?a ?b⟧ ⟹ ?c ∈ ?ab›*) bound_on_path (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); [?f::nat ⇒ 'a↝?X::'a set|?f (0::nat) ..]; ?X ⊆ ?Q; is_bound_f (?b::'a) ?X ?f⟧ ⟹ ?b ∈ ?Q›*) using closest_bound_f_def (*‹closest_bound_f (?Q⇩b::'a) (?Q::'a set) (?f::nat ⇒ 'a) ≡ is_bound_f ?Q⇩b ?Q ?f ∧ (∀Q⇩b'::'a. is_bound Q⇩b' ?Q ∧ Q⇩b' ≠ ?Q⇩b ⟶ [?f (0::nat);?Q⇩b;Q⇩b'])›*) is_bound_f_def (*‹is_bound_f ?Q⇩b ?Q ?f ≡ ∀i j. [?f↝?Q|?f 0 ..] ∧ (i < j ⟶ [?f i;?f j;?Q⇩b])›*) by metis
{
assume "x=b" (*‹(x::'a) = (b::'a)›*)
hence "?thesis"
by (simp add: assms( (*‹is_bound_f b X f›*) 5))
}
moreover {
assume "x=c" (*‹(x::'a) = (c::'a)›*)
hence "?thesis"
using assms(4) (*‹closest_bound_f c X f›*) by (simp add: closest_bound_f_def (*‹closest_bound_f ?Q⇩b ?Q ?f ≡ is_bound_f ?Q⇩b ?Q ?f ∧ (∀Q⇩b'. is_bound Q⇩b' ?Q ∧ Q⇩b' ≠ ?Q⇩b ⟶ [?f 0;?Q⇩b;Q⇩b'])›*))
}
moreover {
assume "[c;x;b]" (*‹[c::'a;x::'a;b::'a]›*)
hence "?thesis"
unfolding is_bound_f_def
(*goal: ‹∀(i::nat) j::nat. [f::nat ⇒ 'a↝X::'a set|f (0::nat) ..] ∧ (i < j ⟶ [f i;f j;x::'a])›*)
proof (safe)
(*goals:
1. ‹⋀i j. [c;x;b] ⟹ [f↝X|f 0 ..]›
2. ‹⋀i j. ⟦[c;x;b]; i < j⟧ ⟹ [f i;f j;x]›*)
fix i :: nat and j :: nat
show "[f↝X|f 0..]"
by (simp add: assms( (*‹[f↝X|f 0 ..]›*) 2))
assume "i<j" (*‹(i::nat) < (j::nat)›*)
hence "[f i; f j; b]"
using assms(5) (*‹is_bound_f b X f›*) is_bound_f_def (*‹is_bound_f ?Q⇩b ?Q ?f ≡ ∀i j. [?f↝?Q|?f 0 ..] ∧ (i < j ⟶ [?f i;?f j;?Q⇩b])›*) by blast
hence "[f j; b; c] ∨ [f j; c; b]"
using ‹i < j› (*‹i < j›*) abc_abd_bcdbdc (*‹⟦[?a::'a::type;?b::'a::type;?c::'a::type]; [?a;?b;?d::'a::type]; ?c ≠ ?d⟧ ⟹ [?b;?c;?d] ∨ [?b;?d;?c]›*) assms(4,6) (*‹closest_bound_f c X f› ‹b ≠ c›*) closest_bound_f_def (*‹closest_bound_f (?Q⇩b::'a) (?Q::'a set) (?f::nat ⇒ 'a) ≡ is_bound_f ?Q⇩b ?Q ?f ∧ (∀Q⇩b'::'a. is_bound Q⇩b' ?Q ∧ Q⇩b' ≠ ?Q⇩b ⟶ [?f (0::nat);?Q⇩b;Q⇩b'])›*) is_bound_f_def (*‹is_bound_f (?Q⇩b::'a) (?Q::'a set) (?f::nat ⇒ 'a) ≡ ∀(i::nat) j::nat. [?f↝?Q|?f (0::nat) ..] ∧ (i < j ⟶ [?f i;?f j;?Q⇩b])›*) by auto
thus "[f i; f j; x]"
by (meson ‹[c;x;b]› ‹[f i; f j; b]› abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*))
qed
}
moreover {
assume "[c;b;x]" (*‹[c::'a;b::'a;x::'a]›*)
hence "?thesis"
unfolding is_bound_f_def
(*goal: ‹∀i j. [f↝X|f 0 ..] ∧ (i < j ⟶ [f i;f j;x])›*)
proof (safe)
(*goals:
1. ‹⋀(i::nat) j::nat. [c::'a;b::'a;x::'a] ⟹ [f::nat ⇒ 'a↝X::'a set|f (0::nat) ..]›
2. ‹⋀(i::nat) j::nat. ⟦[c::'a;b::'a;x::'a]; i < j⟧ ⟹ [(f::nat ⇒ 'a) i;f j;x]›*)
fix i :: nat and j :: nat
show "[f↝X|f 0..]"
by (simp add: assms( (*‹[f↝X|f 0 ..]›*) 2))
assume "i<j" (*‹(i::nat) < (j::nat)›*)
hence "[f i; f j; b]"
using assms(5) (*‹is_bound_f b X f›*) is_bound_f_def (*‹is_bound_f ?Q⇩b ?Q ?f ≡ ∀i j. [?f↝?Q|?f 0 ..] ∧ (i < j ⟶ [?f i;?f j;?Q⇩b])›*) by blast
hence "[f j; b; c] ∨ [f j; c; b]"
using ‹i < j› (*‹i < j›*) abc_abd_bcdbdc (*‹⟦[?a::'a;?b::'a;?c::'a]; [?a;?b;?d::'a]; ?c ≠ ?d⟧ ⟹ [?b;?c;?d] ∨ [?b;?d;?c]›*) assms(4,6) (*‹closest_bound_f c X f› ‹b ≠ c›*) closest_bound_f_def (*‹closest_bound_f ?Q⇩b ?Q ?f ≡ is_bound_f ?Q⇩b ?Q ?f ∧ (∀Q⇩b'. is_bound Q⇩b' ?Q ∧ Q⇩b' ≠ ?Q⇩b ⟶ [?f 0;?Q⇩b;Q⇩b'])›*) is_bound_f_def (*‹is_bound_f ?Q⇩b ?Q ?f ≡ ∀i j. [?f↝?Q|?f 0 ..] ∧ (i < j ⟶ [?f i;?f j;?Q⇩b])›*) by auto
thus "[f i; f j; x]"
proof (-)
(*goal: ‹[f j;b;c] ∨ [f j;c;b] ⟹ [f i;f j;x]›*)
have "(c = b) ∨ [f 0; c; b]"
using assms(4,5) (*‹closest_bound_f c X f› ‹is_bound_f b X f›*) closest_bound_f_def (*‹closest_bound_f ?Q⇩b ?Q ?f ≡ is_bound_f ?Q⇩b ?Q ?f ∧ (∀Q⇩b'. is_bound Q⇩b' ?Q ∧ Q⇩b' ≠ ?Q⇩b ⟶ [?f 0;?Q⇩b;Q⇩b'])›*) is_bound_def (*‹is_bound ?Q⇩b ?Q ≡ ∃f. is_bound_f ?Q⇩b ?Q f›*) by auto
hence "[f j; b; c] ⟶ [x; f j; f i]"
by (metis abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) 2) assms( (*‹is_bound_f b X f›*) 5) is_bound_f_def (*‹is_bound_f ?Q⇩b ?Q ?f ≡ ∀i j. [?f↝?Q|?f 0 ..] ∧ (i < j ⟶ [?f i;?f j;?Q⇩b])›*) neq0_conv (*‹(?n ≠ 0) = (0 < ?n)›*))
thus "?thesis"
(*goal: ‹[f i;f j;x]›*)
using ‹[c;b;x]› (*‹[c;b;x]›*) ‹[f i; f j; b]› (*‹[f i;f j;b]›*) ‹[f j; b; c] ∨ [f j; c; b]› (*‹[f j;b;c] ∨ [f j;c;b]›*) abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by blast
qed
qed
}
ultimately show "?thesis"
(*goal: ‹is_bound_f x X f›*)
using assms(7) (*‹x = b ∨ x = c ∨ [c;x;b] ∨ [c;b;x]›*) by blast
qed
lemma ray_of_bounds3:
assumes "Q∈𝒫" "[f↝X|(f 0)..]" "X⊆Q" "closest_bound_f c X f" "is_bound_f b X f" "b≠c"
shows "all_bounds X = insert c (ray c b)"
proof (standard)
(*goals:
1. ‹all_bounds X ⊆ insert c (ray c b)›
2. ‹insert c (ray c b) ⊆ all_bounds X›*)
let ?B = "all_bounds X"
let ?C = "insert c (ray c b)"
show "?B ⊆ ?C"
proof (standard)
(*goal: ‹⋀x. x ∈ all_bounds X ⟹ x ∈ insert c (ray c b)›*)
fix x
assume "x∈?B" (*‹(x::'a) ∈ all_bounds (X::'a set)›*)
hence "is_bound x X"
by (simp add: all_bounds_def (*‹all_bounds ?Q = {Q⇩b. is_bound Q⇩b ?Q}›*))
hence "x=b ∨ x=c ∨ [c;x;b] ∨ [c;b;x]"
using ray_of_bounds1 (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); [?f::nat ⇒ 'a↝?X::'a set|?f (0::nat) ..]; ?X ⊆ ?Q; closest_bound (?c::'a) ?X; is_bound_f (?b::'a) ?X ?f; ?b ≠ ?c; is_bound_f (?x::'a) ?X ?f⟧ ⟹ ?x = ?b ∨ ?x = ?c ∨ [?c;?x;?b] ∨ [?c;?b;?x]›*) abc_abd_bcdbdc (*‹⟦[?a;?b;?c]; [?a;?b;?d]; ?c ≠ ?d⟧ ⟹ [?b;?c;?d] ∨ [?b;?d;?c]›*) assms(4,5,6) (*‹closest_bound_f c X f› ‹is_bound_f (b::'a) (X::'a set) (f::nat ⇒ 'a)› ‹b ≠ c›*) by (meson closest_bound_f_def (*‹closest_bound_f ?Q⇩b ?Q ?f ≡ is_bound_f ?Q⇩b ?Q ?f ∧ (∀Q⇩b'. is_bound Q⇩b' ?Q ∧ Q⇩b' ≠ ?Q⇩b ⟶ [?f 0;?Q⇩b;Q⇩b'])›*) is_bound_def (*‹is_bound ?Q⇩b ?Q ≡ ∃f. is_bound_f ?Q⇩b ?Q f›*))
thus "x∈?C"
using pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*) ray_def (*‹ray ?a ?b ≡ insert ?b (segment ?a ?b ∪ prolongation ?a ?b)›*) seg_betw (*‹((?x::'a::type) ∈ segment (?a::'a::type) (?b::'a::type)) = [?a;?x;?b]›*) by auto
qed
show "?C ⊆ ?B"
proof (standard)
(*goal: ‹⋀x. x ∈ insert c (ray c b) ⟹ x ∈ all_bounds X›*)
fix x
assume "x∈?C" (*‹(x::'a) ∈ insert (c::'a) (ray c (b::'a))›*)
hence "x=b ∨ x=c ∨ [c;x;b] ∨ [c;b;x]"
using pro_betw (*‹(?x ∈ prolongation ?a ?b) = [?a;?b;?x]›*) ray_def (*‹ray (?a::'a) (?b::'a) ≡ insert ?b (segment ?a ?b ∪ prolongation ?a ?b)›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by auto
hence "is_bound x X"
unfolding is_bound_def
(*goal: ‹∃f. is_bound_f x X f›*)
using ray_of_bounds2 (*‹⟦?Q ∈ 𝒫; [?f↝?X|?f 0 ..]; ?X ⊆ ?Q; closest_bound_f ?c ?X ?f; is_bound_f ?b ?X ?f; ?b ≠ ?c; ?x = ?b ∨ ?x = ?c ∨ [?c;?x;?b] ∨ [?c;?b;?x]⟧ ⟹ is_bound_f ?x ?X ?f›*) assms (*‹Q ∈ 𝒫› ‹[f↝X|f 0 ..]› ‹(X::'a set) ⊆ (Q::'a set)› ‹closest_bound_f c X f› ‹is_bound_f b X f› ‹b ≠ c›*) by blast
thus "x∈?B"
by (simp add: all_bounds_def (*‹all_bounds ?Q = {Q⇩b. is_bound Q⇩b ?Q}›*))
qed
qed
lemma int_in_closed_ray:
assumes "path ab a b"
shows "interval a b ⊂ insert a (ray a b)"
proof (standard)
(*goals:
1. ‹interval a b ⊆ insert a (ray a b)›
2. ‹interval a b ≠ insert a (ray a b)›*)
let ?i = "interval a b"
show "interval a b ≠ insert a (ray a b)"
proof (-)
(*goal: ‹interval a b ≠ insert a (ray a b)›*)
obtain c where "[a;b;c]"
(*goal: ‹(⋀c. [a;b;c] ⟹ thesis) ⟹ thesis›*)
using prolong_betw2 (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ∃c∈?Q. [?a;?b;c]›*) using assms (*‹path ab a b›*) by blast
hence "c∈ray a b"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) pro_betw (*‹((?x::'a) ∈ prolongation (?a::'a) (?b::'a)) = [?a;?b;?x]›*) ray_def (*‹ray ?a ?b ≡ insert ?b (segment ?a ?b ∪ prolongation ?a ?b)›*) by auto
have "c∉interval a b"
using ‹[a;b;c]› (*‹[a;b;c]›*) abc_abc_neq (*‹[?a::'a::type;?b::'a::type;?c::'a::type] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_only_cba(2) (*‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) interval_def (*‹interval (?a::'a) (?b::'a) ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by auto
thus "?thesis"
(*goal: ‹interval a b ≠ insert a (ray a b)›*)
using ‹c ∈ ray a b› (*‹(c::'a) ∈ ray (a::'a) (b::'a)›*) by blast
qed
show "interval a b ⊆ insert a (ray a b)"
using interval_def (*‹interval ?a ?b ≡ insert ?b (insert ?a (segment ?a ?b))›*) ray_def (*‹ray ?a ?b ≡ insert ?b (segment ?a ?b ∪ prolongation ?a ?b)›*) by auto
qed
end (* context MinkowskiSpacetime *)
section "3.8 Connectedness of the unreachable set"
context MinkowskiSpacetime begin
subsection ‹Theorem 13 (Connectedness of the Unreachable Set)›
theorem (*13*) unreach_connected:
assumes path_Q: "Q∈𝒫"
and event_b: "b∉Q" "b∈ℰ"
and unreach: "Q⇩x ∈ unreach-on Q from b" "Q⇩z ∈ unreach-on Q from b"
and xyz: "[Q⇩x; Q⇩y; Q⇩z]"
shows "Q⇩y ∈ unreach-on Q from b"
proof (-)
(*goal: ‹Q⇩y ∈ unreach-on Q from b›*)
have xz: "Q⇩x ≠ Q⇩z"
using abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) xyz (*‹[Q⇩x;Q⇩y;Q⇩z]›*) by blast
text ‹First we obtain the chain from @{thm I6}.›
have in_Q: "Q⇩x∈Q ∧ Q⇩y∈Q ∧ Q⇩z∈Q"
using betw_b_in_path (*‹⟦[?a;?b;?c]; path ?ac ?a ?c⟧ ⟹ ?b ∈ ?ac›*) path_Q (*‹Q ∈ 𝒫›*) unreach(1,2) (*‹Q⇩x ∈ unreach-on Q from b› ‹Q⇩z ∈ unreach-on Q from b›*) xz (*‹Q⇩x ≠ Q⇩z›*) unreach_on_path (*‹?a ∈ unreach-on ?Q from ?b ⟹ ?a ∈ ?Q›*) xyz (*‹[Q⇩x;Q⇩y;Q⇩z]›*) by blast
hence event_y: "Q⇩y∈ℰ"
using in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_Q (*‹Q ∈ 𝒫›*) by blast
text‹legacy: @{thm I6_old} instead of @{thm I6}›
obtain X and f where X_def: "ch_by_ord f X" "f 0 = Q⇩x" "f (card X - 1) = Q⇩z" "(∀i∈{1 .. card X - 1}. (f i) ∈ unreach-on Q from b ∧ (∀Qy∈ℰ. [f (i - 1); Qy; f i] ⟶ Qy ∈ unreach-on Q from b))" "short_ch X ⟶ Q⇩x ∈ X ∧ Q⇩z ∈ X ∧ (∀Q⇩y∈ℰ. [Q⇩x; Q⇩y; Q⇩z] ⟶ Q⇩y ∈ unreach-on Q from b)"
(*goal: ‹(⋀f X. ⟦[f↝X]; f 0 = Q⇩x; f (card X - 1) = Q⇩z; ∀i∈{1..card X - 1}. f i ∈ unreach-on Q from b ∧ (∀Qy∈ℰ. [f (i - 1);Qy;f i] ⟶ Qy ∈ unreach-on Q from b); short_ch X ⟶ Q⇩x ∈ X ∧ Q⇩z ∈ X ∧ (∀Q⇩y∈ℰ. [Q⇩x;Q⇩y;Q⇩z] ⟶ Q⇩y ∈ unreach-on Q from b)⟧ ⟹ thesis) ⟹ thesis›*)
using I6_old[OF assms ( 1 - 5 ) xz] (*‹∃(X::'a set) f::nat ⇒ 'a. [f↝X] ∧ f (0::nat) = (Q⇩x::'a) ∧ f (card X - (1::nat)) = (Q⇩z::'a) ∧ (∀i::nat∈{1::nat..card X - (1::nat)}. f i ∈ unreach-on (Q::'a set) from (b::'a) ∧ (∀Qy::'a∈ℰ::'a set. [f (i - (1::nat));Qy;f i] ⟶ Qy ∈ unreach-on Q from b)) ∧ (short_ch X ⟶ Q⇩x ∈ X ∧ Q⇩z ∈ X ∧ (∀Qy::'a∈ℰ. [Q⇩x;Qy;Q⇩z] ⟶ Qy ∈ unreach-on Q from b))›*) by blast
hence fin_X: "finite X"
using xz (*‹Q⇩x ≠ Q⇩z›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) by fastforce
obtain N where "N=card X" "N≥2"
(*goal: ‹(⋀N. ⟦N = card X; 2 ≤ N⟧ ⟹ thesis) ⟹ thesis›*)
using X_def(2,3) (*‹f 0 = Q⇩x› ‹f (card X - 1) = Q⇩z›*) xz (*‹Q⇩x ≠ Q⇩z›*) by fastforce
text ‹
Then we have to manually show the bounds, defined via indices only, are in the obtained chain.
›
let ?a = "f 0"
let ?d = "f (card X - 1)"
{
assume "card X = 2" (*‹card (X::'a set) = (2::nat)›*)
hence "short_ch X" "?a ∈ X ∧ ?d ∈ X" "?a ≠ ?d"
using X_def (*‹[f↝X]› ‹f 0 = Q⇩x› ‹(f::nat ⇒ 'a) (card (X::'a set) - (1::nat)) = (Q⇩z::'a)› ‹∀i∈{1..card X - 1}. f i ∈ unreach-on Q from b ∧ (∀Qy∈ℰ. [f (i - 1);Qy;f i] ⟶ Qy ∈ unreach-on Q from b)› ‹short_ch (X::'a set) ⟶ (Q⇩x::'a) ∈ X ∧ (Q⇩z::'a) ∈ X ∧ (∀Q⇩y::'a∈ℰ::'a set. [Q⇩x;Q⇩y;Q⇩z] ⟶ Q⇩y ∈ unreach-on (Q::'a set) from (b::'a))›*) ‹card X = 2› (*‹card X = 2›*) short_ch_card_2 (*‹[?f↝?X] ⟹ short_ch ?X = (card ?X = 2)›*) xz (*‹Q⇩x ≠ Q⇩z›*) apply -
(*goals:
1. ‹⟦card X = 2; [f↝X]; f 0 = Q⇩x; f (card X - 1) = Q⇩z; ∀i∈{1..card X - 1}. f i ∈ unreach-on Q from b ∧ (∀Qy∈ℰ. [f (i - 1);Qy;f i] ⟶ Qy ∈ unreach-on Q from b); short_ch X ⟶ Q⇩x ∈ X ∧ Q⇩z ∈ X ∧ (∀Q⇩y∈ℰ. [Q⇩x;Q⇩y;Q⇩z] ⟶ Q⇩y ∈ unreach-on Q from b); card X = 2; ⋀f X. [f↝X] ⟹ short_ch X = (card X = 2); Q⇩x ≠ Q⇩z⟧ ⟹ short_ch X›
2. ‹⟦card X = 2; [f↝X]; f 0 = Q⇩x; f (card X - 1) = Q⇩z; ∀i∈{1..card X - 1}. f i ∈ unreach-on Q from b ∧ (∀Qy∈ℰ. [f (i - 1);Qy;f i] ⟶ Qy ∈ unreach-on Q from b); short_ch X ⟶ Q⇩x ∈ X ∧ Q⇩z ∈ X ∧ (∀Q⇩y∈ℰ. [Q⇩x;Q⇩y;Q⇩z] ⟶ Q⇩y ∈ unreach-on Q from b); card X = 2; ⋀f X. [f↝X] ⟹ short_ch X = (card X = 2); Q⇩x ≠ Q⇩z⟧ ⟹ f 0 ∈ X ∧ f (card X - 1) ∈ X›
3. ‹⟦card X = 2; [f↝X]; f 0 = Q⇩x; f (card X - 1) = Q⇩z; ∀i∈{1..card X - 1}. f i ∈ unreach-on Q from b ∧ (∀Qy∈ℰ. [f (i - 1);Qy;f i] ⟶ Qy ∈ unreach-on Q from b); short_ch X ⟶ Q⇩x ∈ X ∧ Q⇩z ∈ X ∧ (∀Q⇩y∈ℰ. [Q⇩x;Q⇩y;Q⇩z] ⟶ Q⇩y ∈ unreach-on Q from b); card X = 2; ⋀f X. [f↝X] ⟹ short_ch X = (card X = 2); Q⇩x ≠ Q⇩z⟧ ⟹ f 0 ≠ f (card X - 1)›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*discuss goal 3*)
apply blast
(*proven 3 subgoals*) .
}
hence "[f↝X|Q⇩x..Q⇩z]"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord ?f ?X ≡ (infinite ?X ∨ 3 ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f::nat ⇒ 'a↝?Q::'a set|?x::'a..?y::'a..?z::'a] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) by (metis X_def( (*‹[f::nat ⇒ 'a↝X::'a set]› ‹(f::nat ⇒ 'a) (0::nat) = (Q⇩x::'a)› ‹(f::nat ⇒ 'a) (card (X::'a set) - (1::nat)) = (Q⇩z::'a)›*) 1-3) fin_X (*‹finite (X::'a set)›*))
text ‹
Further on, we split the proof into two cases, namely the split Schutz absorbs into his
non-strict \<^term>‹local_ordering›. Just below is the statement we use @{thm disjE} with.›
have y_cases: "Q⇩y∈X ∨ Q⇩y∉X"
by blast
have y_int: "Q⇩y∈interval Q⇩x Q⇩z"
using interval_def (*‹interval (?a::'a) (?b::'a) ≡ insert ?b (insert ?a (segment ?a ?b))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) xyz (*‹[Q⇩x::'a::type;Q⇩y::'a::type;Q⇩z::'a::type]›*) by auto
have X_in_Q: "X⊆Q"
using chain_on_path_I6[where Q = Q and X = X] (*‹⟦Q ∈ 𝒫; ?b ∉ Q; ?b ∈ ℰ; ?Q⇩x ∈ unreach-on Q from ?b; ?Q⇩z ∈ unreach-on Q from ?b; ?Q⇩x ≠ ?Q⇩z; [?f↝X|?Q⇩x .. ?Q⇩z]; ∀i∈{1..card X - 1}. ?f i ∈ unreach-on Q from ?b ∧ (∀Q⇩y∈ℰ. [?f (i - 1);Q⇩y;?f i] ⟶ Q⇩y ∈ unreach-on Q from ?b)⟧ ⟹ X ⊆ Q›*) X_def (*‹[f↝X]› ‹f 0 = Q⇩x› ‹f (card X - 1) = Q⇩z› ‹∀i∈{1..card X - 1}. f i ∈ unreach-on Q from b ∧ (∀Qy∈ℰ. [f (i - 1);Qy;f i] ⟶ Qy ∈ unreach-on Q from b)› ‹short_ch X ⟶ Q⇩x ∈ X ∧ Q⇩z ∈ X ∧ (∀Q⇩y∈ℰ. [Q⇩x;Q⇩y;Q⇩z] ⟶ Q⇩y ∈ unreach-on Q from b)›*) event_b (*‹b ∉ Q› ‹b ∈ ℰ›*) path_Q (*‹(Q::'a set) ∈ (𝒫::'a set set)›*) unreach (*‹Q⇩x ∈ unreach-on Q from b› ‹Q⇩z ∈ unreach-on Q from b›*) xz (*‹(Q⇩x::'a) ≠ (Q⇩z::'a)›*) ‹[f↝X|Q⇩x .. Q⇩z]› (*‹[f::nat ⇒ 'a::type↝X::'a::type set|Q⇩x::'a::type .. Q⇩z::'a::type]›*) by blast
show "?thesis"
(*goal: ‹Q⇩y ∈ unreach-on Q from b›*)
proof (cases)
(*goals:
1. ‹?P ⟹ Q⇩y ∈ unreach-on Q from b›
2. ‹¬ ?P ⟹ Q⇩y ∈ unreach-on Q from b›*)
text ‹We treat short chains separately.
(Legacy: they used to have a separate clause in @{thm I6}, now @{thm I6_old})›
assume "N=2" (*‹(N::nat) = (2::nat)›*)
thus "?thesis"
(*goal: ‹Q⇩y ∈ unreach-on Q from b›*)
using X_def(1,5) (*‹[f↝X]› ‹short_ch X ⟶ Q⇩x ∈ X ∧ Q⇩z ∈ X ∧ (∀Q⇩y∈ℰ. [Q⇩x;Q⇩y;Q⇩z] ⟶ Q⇩y ∈ unreach-on Q from b)›*) xyz (*‹[Q⇩x;Q⇩y;Q⇩z]›*) ‹N = card X› (*‹N = card X›*) event_y (*‹(Q⇩y::'a::type) ∈ (ℰ::'a::type set)›*) short_ch_card_2 (*‹[?f↝?X] ⟹ short_ch ?X = (card ?X = 2)›*) by auto
next
(*goal: ‹N ≠ 2 ⟹ Q⇩y ∈ unreach-on Q from b›*)
text ‹
This is where Schutz obtains the chain from Theorem 11. We instead use the chain we already have
with only a part of Theorem 11, namely @{thm int_split_to_segs}.
‹?S› is defined like in @{thm segmentation}.›
assume "N≠2" (*‹(N::nat) ≠ (2::nat)›*)
hence "N≥3"
using ‹2 ≤ N› (*‹(2::nat) ≤ (N::nat)›*) by auto
have "2≤card X"
using ‹2 ≤ N› (*‹2 ≤ N›*) ‹N = card X› (*‹N = card X›*) by blast
show "?thesis"
(*goal: ‹(Q⇩y::'a) ∈ unreach-on (Q::'a set) from (b::'a)›*)
using y_cases (*‹(Q⇩y::'a) ∈ (X::'a set) ∨ Q⇩y ∉ X›*) proof (rule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹Q⇩y ∈ X ⟹ Q⇩y ∈ unreach-on Q from b›
2. ‹Q⇩y ∉ X ⟹ Q⇩y ∈ unreach-on Q from b›*)
assume "Q⇩y∈X" (*‹(Q⇩y::'a) ∈ (X::'a set)›*)
then obtain i where i_def: "i<card X" "Q⇩y = f i"
(*goal: ‹(⋀i. ⟦i < card X; Q⇩y = f i⟧ ⟹ thesis) ⟹ thesis›*)
using X_def(1) (*‹[f↝X]›*) by (metis fin_X (*‹finite X›*) obtain_index_fin_chain (*‹⟦[?f↝?X]; ?x ∈ ?X; finite ?X; ⋀i. ⟦?f i = ?x; i < card ?X⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
have "i≠0 ∧ i≠card X - 1"
using X_def(2,3) (*‹f 0 = Q⇩x› ‹f (card X - 1) = Q⇩z›*) by (metis abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) i_def( (*‹Q⇩y = f i›*) 2) xyz (*‹[Q⇩x;Q⇩y;Q⇩z]›*))
hence "i∈{1..card X -1}"
using i_def(1) (*‹i < card X›*) by fastforce
thus "?thesis"
(*goal: ‹Q⇩y ∈ unreach-on Q from b›*)
using X_def(4) (*‹∀i∈{1..card X - 1}. f i ∈ unreach-on Q from b ∧ (∀Qy∈ℰ. [f (i - 1);Qy;f i] ⟶ Qy ∈ unreach-on Q from b)›*) i_def(2) (*‹Q⇩y = f i›*) by metis
next
(*goal: ‹Q⇩y ∉ X ⟹ Q⇩y ∈ unreach-on Q from b›*)
assume "Q⇩y∉X" (*‹(Q⇩y::'a) ∉ (X::'a set)›*)
let ?S = "if card X = 2 then {segment ?a ?d} else {segment (f i) (f(i+1)) | i. i<card X - 1}"
have "Q⇩y∈⋃?S"
proof (-)
(*goal: ‹Q⇩y ∈ ⋃ (if card X = 2 then {segment (f 0) (f (card X - 1))} else {segment (f i) (f (i + 1)) |i. i < card X - 1})›*)
obtain c where "[f↝X|Q⇩x..c..Q⇩z]"
(*goal: ‹(⋀c::'a. [f::nat ⇒ 'a↝X::'a set|Q⇩x::'a..c..Q⇩z::'a] ⟹ thesis::bool) ⟹ thesis›*)
using X_def(1) (*‹[f↝X]›*) ‹N = card X› (*‹N = card X›*) ‹N≠2› (*‹N ≠ 2›*) ‹[f↝X|Q⇩x..Q⇩z]› (*‹[f::nat ⇒ 'a↝X::'a set|Q⇩x::'a .. Q⇩z::'a]›*) short_ch_card_2 (*‹[?f↝?X] ⟹ short_ch ?X = (card ?X = 2)›*) by (metis ‹2 ≤ N› le_neq_implies_less (*‹⟦?m ≤ ?n; ?m ≠ ?n⟧ ⟹ ?m < ?n›*) long_chain_2_imp_3 (*‹⟦[?f↝?X|?a .. ?c]; 2 < card ?X⟧ ⟹ ∃b. [?f↝?X|?a..b..?c]›*))
have "interval Q⇩x Q⇩z = ⋃?S ∪ X"
using int_split_to_segs[OF ‹[f↝X|Q⇩x..c..Q⇩z]›] (*‹interval Q⇩x Q⇩z = ⋃ {segment (f i) (f (i + 1)) |i. i < card X - 1} ∪ X›*) by auto
thus "?thesis"
(*goal: ‹(Q⇩y::'a) ∈ ⋃ (if card (X::'a set) = (2::nat) then {segment ((f::nat ⇒ 'a) (0::nat)) (f (card X - (1::nat)))} else {segment (f i) (f (i + (1::nat))) |i::nat. i < card X - (1::nat)})›*)
using ‹Q⇩y∉X› (*‹Q⇩y ∉ X›*) y_int (*‹Q⇩y ∈ interval Q⇩x Q⇩z›*) by blast
qed
then obtain s where "s∈?S" "Q⇩y∈s"
(*goal: ‹(⋀s. ⟦s ∈ (if card X = 2 then {segment (f 0) (f (card X - 1))} else {segment (f i) (f (i + 1)) |i. i < card X - 1}); Q⇩y ∈ s⟧ ⟹ thesis) ⟹ thesis›*)
by blast
have "∃i. i∈{1..(card X)-1} ∧ [(f(i-1)); Q⇩y; f i]"
proof (-)
(*goal: ‹∃i. i ∈ {1..card X - 1} ∧ [f (i - 1);Q⇩y;f i]›*)
obtain i' where i'_def: "i' < N-1" "s = segment (f i') (f (i' + 1))"
(*goal: ‹(⋀i'::nat. ⟦i' < (N::nat) - (1::nat); (s::'a set) = segment ((f::nat ⇒ 'a) i') (f (i' + (1::nat)))⟧ ⟹ thesis::bool) ⟹ thesis›*)
using ‹Q⇩y∈s› (*‹Q⇩y ∈ s›*) ‹s∈?S› (*‹(s::'a set) ∈ (if card (X::'a set) = (2::nat) then {segment ((f::nat ⇒ 'a) (0::nat)) (f (card X - (1::nat)))} else {segment (f i) (f (i + (1::nat))) |i::nat. i < card X - (1::nat)})›*) ‹N=card X› (*‹N = card X›*) by (smt ‹2 ≤ N› ‹N ≠ 2› le_antisym (*‹⟦?m ≤ ?n; ?n ≤ ?m⟧ ⟹ ?m = ?n›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*))
show "?thesis"
(*goal: ‹∃i. i ∈ {1..card X - 1} ∧ [f (i - 1);Q⇩y;f i]›*)
proof (rule exI (*‹?P ?x ⟹ ∃x. ?P x›*), rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹?i ∈ {1..card X - 1}›
2. ‹[f (?i - 1);Q⇩y;f ?i]›*)
show "(i'+1) ∈ {1..card X - 1}"
using i'_def(1) (*‹i' < N - 1›*) by (simp add: ‹N = card X›)
show "[f((i'+1) - 1); Q⇩y; f(i'+1)]"
using i'_def(2) (*‹s = segment (f i') (f (i' + 1))›*) ‹Q⇩y∈s› (*‹Q⇩y ∈ s›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by simp
qed
qed
then obtain i where i_def: "i∈{1..(card X)-1}" "[(f(i-1)); Q⇩y; f i]"
(*goal: ‹(⋀i. ⟦i ∈ {1..card X - 1}; [f (i - 1);Q⇩y;f i]⟧ ⟹ thesis) ⟹ thesis›*)
by blast
show "?thesis"
(*goal: ‹Q⇩y ∈ unreach-on Q from b›*)
by (meson X_def( (*‹∀i::nat∈{1::nat..card (X::'a set) - (1::nat)}. (f::nat ⇒ 'a) i ∈ unreach-on (Q::'a set) from (b::'a) ∧ (∀Qy::'a∈ℰ::'a set. [f (i - (1::nat));Qy;f i] ⟶ Qy ∈ unreach-on Q from b)›*) 4) i_def (*‹(i::nat) ∈ {1::nat..card (X::'a set) - (1::nat)}› ‹[(f::nat ⇒ 'a) ((i::nat) - (1::nat));Q⇩y::'a;f i]›*) event_y (*‹(Q⇩y::'a) ∈ (ℰ::'a set)›*))
qed
qed
qed
subsection ‹Theorem 14 (Second Existence Theorem)›
lemma (*for 14i*) union_of_bounded_sets_is_bounded:
assumes "∀x∈A. [a;x;b]" "∀x∈B. [c;x;d]" "A⊆Q" "B⊆Q" "Q∈𝒫"
"card A > 1 ∨ infinite A" "card B > 1 ∨ infinite B"
shows "∃l∈Q. ∃u∈Q. ∀x∈A∪B. [l;x;u]"
proof (-)
(*goal: ‹∃l∈Q. ∃u∈Q. ∀x∈A ∪ B. [l;x;u]›*)
let ?P = "λ A B. ∃l∈Q. ∃u∈Q. ∀x∈A∪B. [l;x;u]"
let ?I = "λ A a b. (card A > 1 ∨ infinite A) ∧ (∀x∈A. [a;x;b])"
let ?R = "λA. ∃a b. ?I A a b"
have on_path: "⋀a b A. A ⊆ Q ⟹ ?I A a b ⟹ b ∈ Q ∧ a ∈ Q"
proof (-)
(*goal: ‹⋀a b A. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q›*)
fix a and b and A
assume "A⊆Q" "?I A a b" (*‹(A::'a set) ⊆ (Q::'a set)› ‹((1::nat) < card (A::'a set) ∨ infinite A) ∧ (∀x::'a∈A. [a::'a;x;b::'a])›*)
show "b∈Q∧a∈Q"
proof (cases)
(*goals:
1. ‹?P ⟹ b ∈ Q ∧ a ∈ Q›
2. ‹¬ ?P ⟹ b ∈ Q ∧ a ∈ Q›*)
assume "card A ≤ 1 ∧ finite A" (*‹card (A::'a set) ≤ (1::nat) ∧ finite A›*)
thus "?thesis"
(*goal: ‹(b::'a::type) ∈ (Q::'a::type set) ∧ (a::'a::type) ∈ Q›*)
using ‹?I A a b› (*‹(1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])›*) by auto
next
(*goal: ‹¬ (card (A::'a::type set) ≤ (1::nat) ∧ finite A) ⟹ (b::'a::type) ∈ (Q::'a::type set) ∧ (a::'a::type) ∈ Q›*)
assume "¬ (card A ≤ 1 ∧ finite A)" (*‹¬ (card (A::'a set) ≤ (1::nat) ∧ finite A)›*)
hence asmA: "card A > 1 ∨ infinite A"
by linarith
then obtain x and y where "x∈A" "y∈A" "x≠y"
(*goal: ‹(⋀x y. ⟦x ∈ A; y ∈ A; x ≠ y⟧ ⟹ thesis) ⟹ thesis›*)
proof (standard)
(*goals:
1. ‹⟦⋀x y. ⟦x ∈ A; y ∈ A; x ≠ y⟧ ⟹ thesis; 1 < card A⟧ ⟹ thesis›
2. ‹⟦⋀x y. ⟦x ∈ A; y ∈ A; x ≠ y⟧ ⟹ thesis; infinite A⟧ ⟹ thesis›*)
assume "1 < card A" "⋀x y. ⟦x ∈ A; y ∈ A; x ≠ y⟧ ⟹ thesis" (*‹(1::nat) < card (A::'a set)› ‹⟦(?x::'a) ∈ (A::'a set); (?y::'a) ∈ A; ?x ≠ ?y⟧ ⟹ thesis::bool›*)
then show "?thesis"
(*goal: ‹thesis›*)
by (metis One_nat_def (*‹1 = Suc 0›*) Suc_le_eq (*‹(Suc ?m ≤ ?n) = (?m < ?n)›*) card_le_Suc_iff (*‹(Suc ?n ≤ card ?A) = (∃a B. ?A = insert a B ∧ a ∉ B ∧ ?n ≤ card B ∧ finite B)›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*))
next
(*goal: ‹⟦⋀x y. ⟦x ∈ A; y ∈ A; x ≠ y⟧ ⟹ thesis; infinite A⟧ ⟹ thesis›*)
assume "infinite A" "⋀x y. ⟦x ∈ A; y ∈ A; x ≠ y⟧ ⟹ thesis" (*‹infinite (A::'a set)› ‹⟦(?x::'a) ∈ (A::'a set); (?y::'a) ∈ A; ?x ≠ ?y⟧ ⟹ thesis::bool›*)
then show "?thesis"
(*goal: ‹thesis›*)
using infinite_imp_nonempty (*‹infinite ?S ⟹ ?S ≠ {}›*) by (metis finite_insert (*‹finite (insert (?a::?'a) (?A::?'a set)) = finite ?A›*) finite_subset (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); finite ?B⟧ ⟹ finite ?A›*) singletonI (*‹(?a::?'a) ∈ {?a}›*) subsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ∈ (?B::?'a set)) ⟹ ?A ⊆ ?B›*))
qed
have "x∈Q" "y∈Q"
using ‹A ⊆ Q› (*‹A ⊆ Q›*) ‹x ∈ A› (*‹x ∈ A›*) ‹y ∈ A› (*‹y ∈ A›*) apply -
(*goals:
1. ‹⟦A ⊆ Q; x ∈ A; y ∈ A⟧ ⟹ x ∈ Q›
2. ‹⟦A ⊆ Q; x ∈ A; y ∈ A⟧ ⟹ y ∈ Q›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
have "[a;x;b]" "[a;y;b]"
(*goals:
1. ‹[a::'a;x::'a;b::'a]›
2. ‹[a::'a;y::'a;b::'a]›
discuss goal 1*)
apply (simp add: ‹(1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])› ‹x ∈ A› ‹y ∈ A›)
(*discuss goal 2*)
apply (simp add: ‹(1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])› ‹x ∈ A› ‹y ∈ A›)
(*proven 2 subgoals*) .
hence "betw4 a x y b ∨ betw4 a y x b"
using ‹x ≠ y› (*‹x ≠ y›*) abd_acd_abcdacbd (*‹⟦[?a::'a;?b::'a;?d::'a]; [?a;?c::'a;?d]; ?b ≠ ?c⟧ ⟹ [?a;?b;?c;?d] ∨ [?a;?c;?b;?d]›*) by blast
hence "a∈Q ∧ b∈Q"
using ‹Q∈𝒫› (*‹Q ∈ 𝒫›*) ‹x∈Q› (*‹x ∈ Q›*) ‹x≠y› (*‹x ≠ y›*) ‹x∈Q› (*‹x ∈ Q›*) ‹y∈Q› (*‹y ∈ Q›*) betw_a_in_path (*‹⟦[?a;?b;?c]; path ?bc ?b ?c⟧ ⟹ ?a ∈ ?bc›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) by blast
thus "?thesis"
(*goal: ‹b ∈ Q ∧ a ∈ Q›*)
by simp
qed
qed
show "?thesis"
(*goal: ‹∃l∈Q. ∃u∈Q. ∀x∈A ∪ B. [l;x;u]›*)
proof (cases)
(*goals:
1. ‹?P::bool ⟹ ∃l::'a::type∈Q::'a::type set. ∃u::'a::type∈Q. ∀x::'a::type∈(A::'a::type set) ∪ (B::'a::type set). [l;x;u]›
2. ‹¬ (?P::bool) ⟹ ∃l::'a::type∈Q::'a::type set. ∃u::'a::type∈Q. ∀x::'a::type∈(A::'a::type set) ∪ (B::'a::type set). [l;x;u]›*)
assume "a≠b ∧ a≠c ∧ a≠d ∧ b≠c ∧ b≠d ∧ c≠d" (*‹(a::'a) ≠ (b::'a) ∧ a ≠ (c::'a) ∧ a ≠ (d::'a) ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d›*)
show "?P A B"
proof (rule_tac P="?P" and A=Q in wlog_endpoints_distinct (*‹⟦?A ∈ 𝒫; ⋀a b I. ?Q I a b ⟹ ?Q I b a; ⋀a b I. ⟦I ⊆ ?A; ?Q I a b⟧ ⟹ b ∈ ?A ∧ a ∈ ?A; ⋀I J. ⟦∃a b. ?Q I a b; ∃a b. ?Q J a b; ?P I J⟧ ⟹ ?P J I; ⋀I J a b c d. ⟦?Q I a b; ?Q J c d; I ⊆ ?A; J ⊆ ?A; [a;b;c;d] ∨ [a;c;b;d] ∨ [a;c;d;b]⟧ ⟹ ?P I J; ?Q ?I ?a ?b; ?Q ?J ?c ?d; ?I ⊆ ?A; ?J ⊆ ?A; ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?a ≠ ?d ∧ ?b ≠ ?c ∧ ?b ≠ ?d ∧ ?c ≠ ?d⟧ ⟹ ?P ?I ?J›*))
(*goals:
1. ‹Q ∈ 𝒫›
2. ‹⋀a b I. ?Q I a b ⟹ ?Q I b a›
3. ‹⋀a b I. ⟦I ⊆ Q; ?Q I a b⟧ ⟹ b ∈ Q ∧ a ∈ Q›
4. ‹⋀I J. ⟦∃a b. ?Q I a b; ∃a b. ?Q J a b; ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]⟧ ⟹ ∃l∈Q. ∃u∈Q. ∀x∈J ∪ I. [l;x;u]›
5. ‹⋀I J a b c d. ⟦?Q I a b; ?Q J c d; I ⊆ Q; J ⊆ Q; [a;b;c;d] ∨ [a;c;b;d] ∨ [a;c;d;b]⟧ ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
6. ‹?Q A ?a ?b›
7. ‹?Q B ?c ?d›
8. ‹A ⊆ Q›
9. ‹B ⊆ Q›
10. ‹?a ≠ ?b ∧ ?a ≠ ?c ∧ ?a ≠ ?d ∧ ?b ≠ ?c ∧ ?b ≠ ?d ∧ ?c ≠ ?d›*)
text ‹First, some technicalities: the relations $P, I, R$ have the symmetry required.›
show "⋀a b I. ?I I a b ⟹ ?I I b a"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by blast
show "⋀a b A. A ⊆ Q ⟹ ?I A a b ⟹ b ∈ Q ∧ a ∈ Q"
using on_path (*‹⟦?A ⊆ Q; (1 < card ?A ∨ infinite ?A) ∧ (∀x∈?A. [?a;x;?b])⟧ ⟹ ?b ∈ Q ∧ ?a ∈ Q›*) assms(5) (*‹Q ∈ 𝒫›*) by blast
show "⋀I J. ?R I ⟹ ?R J ⟹ ?P I J ⟹ ?P J I"
by (simp add: Un_commute (*‹?A ∪ ?B = ?B ∪ ?A›*))
text ‹Next, the lemma/case assumptions have to be repeated for Isabelle.›
show "?I A a b" "?I B c d" "A⊆Q" "B⊆Q" "Q∈𝒫"
using assms (*‹∀x∈A. [a;x;b]› ‹∀x∈B. [c;x;d]› ‹A ⊆ Q› ‹B ⊆ Q› ‹Q ∈ 𝒫› ‹1 < card A ∨ infinite A› ‹(1::nat) < card (B::'a set) ∨ infinite B›*) apply -
(*goals:
1. ‹⟦∀x∈A. [a;x;b]; ∀x∈B. [c;x;d]; A ⊆ Q; B ⊆ Q; Q ∈ 𝒫; 1 < card A ∨ infinite A; 1 < card B ∨ infinite B⟧ ⟹ (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])›
2. ‹⟦∀x∈A. [a;x;b]; ∀x∈B. [c;x;d]; A ⊆ Q; B ⊆ Q; Q ∈ 𝒫; 1 < card A ∨ infinite A; 1 < card B ∨ infinite B⟧ ⟹ (1 < card B ∨ infinite B) ∧ (∀x∈B. [c;x;d])›
3. ‹⟦∀x∈A. [a;x;b]; ∀x∈B. [c;x;d]; A ⊆ Q; B ⊆ Q; Q ∈ 𝒫; 1 < card A ∨ infinite A; 1 < card B ∨ infinite B⟧ ⟹ A ⊆ Q›
4. ‹⟦∀x∈A. [a;x;b]; ∀x∈B. [c;x;d]; A ⊆ Q; B ⊆ Q; Q ∈ 𝒫; 1 < card A ∨ infinite A; 1 < card B ∨ infinite B⟧ ⟹ B ⊆ Q›
5. ‹⟦∀x∈A. [a;x;b]; ∀x∈B. [c;x;d]; A ⊆ Q; B ⊆ Q; Q ∈ 𝒫; 1 < card A ∨ infinite A; 1 < card B ∨ infinite B⟧ ⟹ Q ∈ 𝒫›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*proven 5 subgoals*) .
show "a≠b ∧ a≠c ∧ a≠d ∧ b≠c ∧ b≠d ∧ c≠d"
using ‹a≠b ∧ a≠c ∧ a≠d ∧ b≠c ∧ b≠d ∧ c≠d› (*‹a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d›*) by simp
text ‹Finally, the important bit: proofs for the necessary cases of betweenness.›
show "?P I J" if "?I I a b" "?I J c d" "I⊆Q" "J⊆Q" and "[a;b;c;d] ∨ [a;c;b;d] ∨ [a;c;d;b]" for I and J and a and b and c and d
proof (-)
(*goal: ‹∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
consider "[a;b;c;d]" | "[a;c;b;d]" | "[a;c;d;b]"
(*goal: ‹⟦[a;b;c;d] ⟹ thesis; [a;c;b;d] ⟹ thesis; [a;c;d;b] ⟹ thesis⟧ ⟹ thesis›*)
using ‹[a;b;c;d] ∨ [a;c;b;d] ∨ [a;c;d;b]› (*‹[a;b;c;d] ∨ [a;c;b;d] ∨ [a;c;d;b]›*) by fastforce
thus "?thesis"
(*goal: ‹∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
proof (cases)
(*goals:
1. ‹[a;b;c;d] ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
2. ‹[a;c;b;d] ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
3. ‹[a;c;d;b] ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
assume asm: "[a;b;c;d]" (*‹[a::'a;b::'a;c::'a;d::'a]›*)
show "?P I J"
proof (-)
(*goal: ‹∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
have "∀x∈ I∪J. [a;x;d]"
by (metis Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) asm (*‹[a;b;c;d]›*) betw4_strong (*‹[?a;?b;?c;?d] ⟹ [?a;?b;?d] ∧ [?a;?c;?d]›*) betw4_weak (*‹[?a;?b;?c] ∧ [?a;?c;?d] ∨ [?a;?b;?c;?d] ∨ [?a;?b;?d] ∧ [?b;?c;?d] ∨ [?a;?b;?d] ∧ [?b;?c;?d] ⟹ [?a;?b;?c;?d]›*) that( (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])›*) 1) that( (*‹(1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d])›*) 2))
moreover have "a∈Q" "d∈Q"
using assms(5) (*‹Q ∈ 𝒫›*) on_path (*‹⟦?A ⊆ Q; (1 < card ?A ∨ infinite ?A) ∧ (∀x∈?A. [?a;x;?b])⟧ ⟹ ?b ∈ Q ∧ ?a ∈ Q›*) that(1-4) (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹(1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d])› ‹I ⊆ Q› ‹J ⊆ Q›*) apply -
(*goals:
1. ‹⟦Q ∈ 𝒫; ⋀A a b. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; (1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b]); (1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d]); I ⊆ Q; J ⊆ Q⟧ ⟹ a ∈ Q›
2. ‹⟦Q ∈ 𝒫; ⋀A a b. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; (1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b]); (1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d]); I ⊆ Q; J ⊆ Q⟧ ⟹ d ∈ Q›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
ultimately show "?thesis"
(*goal: ‹∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
by blast
qed
next
(*goals:
1. ‹[a;c;b;d] ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
2. ‹[a;c;d;b] ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
assume "[a;c;b;d]" (*‹[a::'a;c::'a;b::'a;d::'a]›*)
show "?P I J"
proof (-)
(*goal: ‹∃l::'a::type∈Q::'a::type set. ∃u::'a::type∈Q. ∀x::'a::type∈(I::'a::type set) ∪ (J::'a::type set). [l;x;u]›*)
have "∀x∈ I∪J. [a;x;d]"
by (metis Un_iff (*‹((?c::?'a) ∈ (?A::?'a set) ∪ (?B::?'a set)) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) ‹betw4 a c b d› abc_bcd_abd (*‹⟦[?a::'a;?b::'a;?c::'a]; [?b;?c;?d::'a]⟧ ⟹ [?a;?b;?d]›*) abc_bcd_acd (*‹⟦[?a::'a;?b::'a;?c::'a]; [?b;?c;?d::'a]⟧ ⟹ [?a;?c;?d]›*) betw4_weak (*‹[?a::'a;?b::'a;?c::'a] ∧ [?a;?c;?d::'a] ∨ [?a;?b;?c;?d] ∨ [?a;?b;?d] ∧ [?b;?c;?d] ∨ [?a;?b;?d] ∧ [?b;?c;?d] ⟹ [?a;?b;?c;?d]›*) that( (*‹((1::nat) < card (I::'a set) ∨ infinite I) ∧ (∀x::'a∈I. [a::'a;x;b::'a])› ‹((1::nat) < card (J::'a set) ∨ infinite J) ∧ (∀x::'a∈J. [c::'a;x;d::'a])›*) 1,2))
moreover have "a∈Q" "d∈Q"
using assms(5) (*‹Q ∈ 𝒫›*) on_path (*‹⟦?A ⊆ Q; (1 < card ?A ∨ infinite ?A) ∧ (∀x∈?A. [?a;x;?b])⟧ ⟹ ?b ∈ Q ∧ ?a ∈ Q›*) that(1-4) (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹(1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d])› ‹I ⊆ Q› ‹J ⊆ Q›*) apply -
(*goals:
1. ‹⟦Q ∈ 𝒫; ⋀A a b. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; (1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b]); (1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d]); I ⊆ Q; J ⊆ Q⟧ ⟹ a ∈ Q›
2. ‹⟦Q ∈ 𝒫; ⋀A a b. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; (1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b]); (1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d]); I ⊆ Q; J ⊆ Q⟧ ⟹ d ∈ Q›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
ultimately show "?thesis"
(*goal: ‹∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
by blast
qed
next
(*goal: ‹[a;c;d;b] ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
assume "[a;c;d;b]" (*‹[a::'a;c::'a;d::'a;b::'a]›*)
show "?P I J"
proof (-)
(*goal: ‹∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
have "∀x∈ I∪J. [a;x;b]"
using ‹betw4 a c d b› (*‹[a;c;d;b]›*) abc_bcd_abd (*‹⟦[?a::'a;?b::'a;?c::'a]; [?b;?c;?d::'a]⟧ ⟹ [?a;?b;?d]›*) abc_bcd_acd (*‹⟦[?a;?b;?c]; [?b;?c;?d]⟧ ⟹ [?a;?c;?d]›*) abe_ade_bcd_ace (*‹⟦[?a;?b;?e]; [?a;?d;?e]; [?b;?c;?d]⟧ ⟹ [?a;?c;?e]›*) by (meson UnE (*‹⟦?c ∈ ?A ∪ ?B; ?c ∈ ?A ⟹ ?P; ?c ∈ ?B ⟹ ?P⟧ ⟹ ?P›*) that( (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹(1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d])›*) 1,2))
moreover have "a∈Q" "b∈Q"
using assms(5) (*‹Q ∈ 𝒫›*) on_path (*‹⟦(?A::'a set) ⊆ (Q::'a set); ((1::nat) < card ?A ∨ infinite ?A) ∧ (∀x::'a∈?A. [?a::'a;x;?b::'a])⟧ ⟹ ?b ∈ Q ∧ ?a ∈ Q›*) that(1-4) (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹(1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d])› ‹I ⊆ Q› ‹J ⊆ Q›*) apply -
(*goals:
1. ‹⟦Q ∈ 𝒫; ⋀A a b. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; (1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b]); (1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d]); I ⊆ Q; J ⊆ Q⟧ ⟹ a ∈ Q›
2. ‹⟦Q ∈ 𝒫; ⋀A a b. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; (1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b]); (1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d]); I ⊆ Q; J ⊆ Q⟧ ⟹ b ∈ Q›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
ultimately show "?thesis"
(*goal: ‹∃l::'a∈Q::'a set. ∃u::'a∈Q. ∀x::'a∈(I::'a set) ∪ (J::'a set). [l;x;u]›*)
by blast
qed
qed
qed
qed
next
(*goal: ‹¬ (a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d) ⟹ ∃l∈Q. ∃u∈Q. ∀x∈A ∪ B. [l;x;u]›*)
assume "¬(a≠b ∧ a≠c ∧ a≠d ∧ b≠c ∧ b≠d ∧ c≠d)" (*‹¬ ((a::'a) ≠ (b::'a) ∧ a ≠ (c::'a) ∧ a ≠ (d::'a) ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d)›*)
show "?P A B"
proof (rule_tac P="?P" and A=Q in wlog_endpoints_degenerate (*‹⟦(?A::'a::type set) ∈ (𝒫::'a::type set set); ⋀(a::'a::type) (b::'a::type) I::'a::type set. (?Q::'a::type set ⇒ 'a::type ⇒ 'a::type ⇒ bool) I a b ⟹ ?Q I b a; ⋀(a::'a::type) (b::'a::type) I::'a::type set. ⟦I ⊆ ?A; ?Q I a b⟧ ⟹ b ∈ ?A ∧ a ∈ ?A; ⋀(I::'a::type set) J::'a::type set. ⟦∃(a::'a::type) b::'a::type. ?Q I a b; ∃(a::'a::type) b::'a::type. ?Q J a b; (?P::'a::type set ⇒ 'a::type set ⇒ bool) I J⟧ ⟹ ?P J I; ⋀(I::'a::type set) (J::'a::type set) (a::'a::type) (b::'a::type) (c::'a::type) d::'a::type. ⟦?Q I a b; ?Q J c d; I ⊆ ?A; J ⊆ ?A⟧ ⟹ (a = b ∧ b = c ∧ c = d ⟶ ?P I J) ∧ (a = b ∧ b ≠ c ∧ c = d ⟶ ?P I J) ∧ (a = b ∧ b = c ∧ c ≠ d ⟶ ?P I J) ∧ (a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟶ ?P I J) ∧ (a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟶ ?P I J) ∧ ([a;b;c] ∧ a = d ⟶ ?P I J) ∧ ([b;a;c] ∧ a = d ⟶ ?P I J); ?Q (?I::'a::type set) (?a::'a::type) (?b::'a::type); ?Q (?J::'a::type set) (?c::'a::type) (?d::'a::type); ?I ⊆ ?A; ?J ⊆ ?A; ¬ (?a ≠ ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ∧ ?a ≠ ?c ∧ ?b ≠ ?d)⟧ ⟹ ?P ?I ?J›*))
(*goals:
1. ‹Q ∈ 𝒫›
2. ‹⋀a b I. ?Q I a b ⟹ ?Q I b a›
3. ‹⋀a b I. ⟦I ⊆ Q; ?Q I a b⟧ ⟹ b ∈ Q ∧ a ∈ Q›
4. ‹⋀I J. ⟦∃a b. ?Q I a b; ∃a b. ?Q J a b; ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]⟧ ⟹ ∃l∈Q. ∃u∈Q. ∀x∈J ∪ I. [l;x;u]›
5. ‹⋀I J a b c d. ⟦?Q I a b; ?Q J c d; I ⊆ Q; J ⊆ Q⟧ ⟹ (a = b ∧ b = c ∧ c = d ⟶ (∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u])) ∧ (a = b ∧ b ≠ c ∧ c = d ⟶ (∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u])) ∧ (a = b ∧ b = c ∧ c ≠ d ⟶ (∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u])) ∧ (a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟶ (∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u])) ∧ (a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟶ (∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u])) ∧ ([a;b;c] ∧ a = d ⟶ (∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u])) ∧ ([b;a;c] ∧ a = d ⟶ (∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]))›
6. ‹?Q A ?a ?b›
7. ‹?Q B ?c ?d›
8. ‹A ⊆ Q›
9. ‹B ⊆ Q›
10. ‹¬ (?a ≠ ?b ∧ ?b ≠ ?c ∧ ?c ≠ ?d ∧ ?a ≠ ?d ∧ ?a ≠ ?c ∧ ?b ≠ ?d)›*)
text ‹
This case follows the same pattern as above: the next five ‹show› statements
are effectively bookkeeping.›
show "⋀a b I. ?I I a b ⟹ ?I I b a"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by blast
show "⋀a b A. A ⊆ Q ⟹ ?I A a b ⟹ b ∈ Q ∧ a ∈ Q"
using on_path (*‹⟦?A ⊆ Q; (1 < card ?A ∨ infinite ?A) ∧ (∀x∈?A. [?a;x;?b])⟧ ⟹ ?b ∈ Q ∧ ?a ∈ Q›*) ‹Q∈𝒫› (*‹Q ∈ 𝒫›*) by blast
show "⋀I J. ?R I ⟹ ?R J ⟹ ?P I J ⟹ ?P J I"
by (simp add: Un_commute (*‹?A ∪ ?B = ?B ∪ ?A›*))
show "?I A a b" "?I B c d" "A⊆Q" "B⊆Q" "Q∈𝒫"
using assms (*‹∀x::'a∈A::'a set. [a::'a;x;b::'a]› ‹∀x::'a::type∈B::'a::type set. [c::'a::type;x;d::'a::type]› ‹A ⊆ Q› ‹B ⊆ Q› ‹Q ∈ 𝒫› ‹1 < card A ∨ infinite A› ‹1 < card B ∨ infinite B›*) apply -
(*goals:
1. ‹⟦∀x∈A. [a;x;b]; ∀x∈B. [c;x;d]; A ⊆ Q; B ⊆ Q; Q ∈ 𝒫; 1 < card A ∨ infinite A; 1 < card B ∨ infinite B⟧ ⟹ (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])›
2. ‹⟦∀x∈A. [a;x;b]; ∀x∈B. [c;x;d]; A ⊆ Q; B ⊆ Q; Q ∈ 𝒫; 1 < card A ∨ infinite A; 1 < card B ∨ infinite B⟧ ⟹ (1 < card B ∨ infinite B) ∧ (∀x∈B. [c;x;d])›
3. ‹⟦∀x∈A. [a;x;b]; ∀x∈B. [c;x;d]; A ⊆ Q; B ⊆ Q; Q ∈ 𝒫; 1 < card A ∨ infinite A; 1 < card B ∨ infinite B⟧ ⟹ A ⊆ Q›
4. ‹⟦∀x∈A. [a;x;b]; ∀x∈B. [c;x;d]; A ⊆ Q; B ⊆ Q; Q ∈ 𝒫; 1 < card A ∨ infinite A; 1 < card B ∨ infinite B⟧ ⟹ B ⊆ Q›
5. ‹⟦∀x∈A. [a;x;b]; ∀x∈B. [c;x;d]; A ⊆ Q; B ⊆ Q; Q ∈ 𝒫; 1 < card A ∨ infinite A; 1 < card B ∨ infinite B⟧ ⟹ Q ∈ 𝒫›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*proven 5 subgoals*) .
show "¬ (a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ∧ a ≠ c ∧ b ≠ d)"
using ‹¬ (a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d)› (*‹¬ (a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d)›*) by blast
text ‹Again, this is the important bit: proofs for the necessary cases of degeneracy.›
show "(a = b ∧ b = c ∧ c = d ⟶ ?P I J) ∧ (a = b ∧ b ≠ c ∧ c = d ⟶ ?P I J) ∧
(a = b ∧ b = c ∧ c ≠ d ⟶ ?P I J) ∧ (a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟶ ?P I J) ∧
(a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟶ ?P I J) ∧
([a;b;c] ∧ a = d ⟶ ?P I J) ∧ ([b;a;c] ∧ a = d ⟶ ?P I J)" if "?I I a b" "?I J c d" "I ⊆ Q" "J ⊆ Q" for I and J and a and b and c and d
proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goals:
1. ‹(a::'a::type) = (b::'a::type) ∧ b = (c::'a::type) ∧ c = (d::'a::type) ⟹ ∃l::'a::type∈Q::'a::type set. ∃u::'a::type∈Q. ∀x::'a::type∈(I::'a::type set) ∪ (J::'a::type set). [l;x;u]›
2. ‹(a::'a::type) = (b::'a::type) ∧ b ≠ (c::'a::type) ∧ c = (d::'a::type) ⟹ ∃l::'a::type∈Q::'a::type set. ∃u::'a::type∈Q. ∀x::'a::type∈(I::'a::type set) ∪ (J::'a::type set). [l;x;u]›
3. ‹(a::'a::type) = (b::'a::type) ∧ b = (c::'a::type) ∧ c ≠ (d::'a::type) ⟹ ∃l::'a::type∈Q::'a::type set. ∃u::'a::type∈Q. ∀x::'a::type∈(I::'a::type set) ∪ (J::'a::type set). [l;x;u]›
4. ‹(a::'a::type) = (b::'a::type) ∧ b ≠ (c::'a::type) ∧ c ≠ (d::'a::type) ∧ a ≠ d ⟹ ∃l::'a::type∈Q::'a::type set. ∃u::'a::type∈Q. ∀x::'a::type∈(I::'a::type set) ∪ (J::'a::type set). [l;x;u]›
5. ‹(a::'a::type) ≠ (b::'a::type) ∧ b = (c::'a::type) ∧ c ≠ (d::'a::type) ∧ a = d ⟹ ∃l::'a::type∈Q::'a::type set. ∃u::'a::type∈Q. ∀x::'a::type∈(I::'a::type set) ∪ (J::'a::type set). [l;x;u]›
6. ‹[a::'a::type;b::'a::type;c::'a::type] ∧ a = (d::'a::type) ⟹ ∃l::'a::type∈Q::'a::type set. ∃u::'a::type∈Q. ∀x::'a::type∈(I::'a::type set) ∪ (J::'a::type set). [l;x;u]›
7. ‹[b::'a::type;a::'a::type;c::'a::type] ∧ a = (d::'a::type) ⟹ ∃l::'a::type∈Q::'a::type set. ∃u::'a::type∈Q. ∀x::'a::type∈(I::'a::type set) ∪ (J::'a::type set). [l;x;u]›*)
assume "a = b ∧ b = c ∧ c = d" (*‹(a::'a) = (b::'a) ∧ b = (c::'a) ∧ c = (d::'a)›*)
show "∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]"
using ‹a = b ∧ b = c ∧ c = d› (*‹a = b ∧ b = c ∧ c = d›*) abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) assms(5) (*‹Q ∈ 𝒫›*) ex_crossing_path (*‹(?Q::'a::type set) ∈ (𝒫::'a::type set set) ⟹ ∃R::'a::type set∈𝒫. R ≠ ?Q ∧ (∃c::'a::type. c ∈ R ∧ c ∈ ?Q)›*) that(1,2) (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹(1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d])›*) by fastforce
next
(*goals:
1. ‹a = b ∧ b ≠ c ∧ c = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
2. ‹a = b ∧ b = c ∧ c ≠ d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
3. ‹a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
4. ‹a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
5. ‹[a;b;c] ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
6. ‹[b;a;c] ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
assume "a = b ∧ b ≠ c ∧ c = d" (*‹(a::'a) = (b::'a) ∧ b ≠ (c::'a) ∧ c = (d::'a)›*)
show "∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]"
using ‹a = b ∧ b ≠ c ∧ c = d› (*‹(a::'a::type) = (b::'a::type) ∧ b ≠ (c::'a::type) ∧ c = (d::'a::type)›*) abc_ac_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?c›*) assms(5) (*‹Q ∈ 𝒫›*) ex_crossing_path (*‹?Q ∈ 𝒫 ⟹ ∃R∈𝒫. R ≠ ?Q ∧ (∃c. c ∈ R ∧ c ∈ ?Q)›*) that(1,2) (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹((1::nat) < card (J::'a set) ∨ infinite J) ∧ (∀x::'a∈J. [c::'a;x;d::'a])›*) by (metis Un_iff (*‹((?c::?'a) ∈ (?A::?'a set) ∪ (?B::?'a set)) = (?c ∈ ?A ∨ ?c ∈ ?B)›*))
next
(*goals:
1. ‹a = b ∧ b = c ∧ c ≠ d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
2. ‹a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
3. ‹a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
4. ‹[a;b;c] ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
5. ‹[b;a;c] ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
assume "a = b ∧ b = c ∧ c ≠ d" (*‹(a::'a) = (b::'a) ∧ b = (c::'a) ∧ c ≠ (d::'a)›*)
hence "∀x∈ I∪J. [c;x;d]"
using abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) that(1,2) (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹((1::nat) < card (J::'a set) ∨ infinite J) ∧ (∀x::'a∈J. [c::'a;x;d::'a])›*) by fastforce
moreover have "c∈Q" "d∈Q"
using on_path (*‹⟦?A ⊆ Q; (1 < card ?A ∨ infinite ?A) ∧ (∀x∈?A. [?a;x;?b])⟧ ⟹ ?b ∈ Q ∧ ?a ∈ Q›*) ‹a = b ∧ b = c ∧ c ≠ d› (*‹a = b ∧ b = c ∧ c ≠ d›*) that(1,3) (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹I ⊆ Q›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) apply -
(*goals:
1. ‹⟦⋀A a b. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; a = b ∧ b = c ∧ c ≠ d; (1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b]); I ⊆ Q; ⋀a b c. [a;b;c] ⟹ a ≠ b ∧ a ≠ c ∧ b ≠ c⟧ ⟹ c ∈ Q›
2. ‹⟦⋀A a b. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; a = b ∧ b = c ∧ c ≠ d; (1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b]); I ⊆ Q; ⋀a b c. [a;b;c] ⟹ a ≠ b ∧ a ≠ c ∧ b ≠ c⟧ ⟹ d ∈ Q›
discuss goal 1*)
apply metis
(*discuss goal 2*)
apply metis
(*proven 2 subgoals*) .
ultimately show "∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]"
by blast
next
(*goals:
1. ‹a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
2. ‹a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
3. ‹[a;b;c] ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
4. ‹[b;a;c] ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
assume "a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d" (*‹(a::'a) = (b::'a) ∧ b ≠ (c::'a) ∧ c ≠ (d::'a) ∧ a ≠ d›*)
hence "∀x∈ I∪J. [c;x;d]"
using abc_abc_neq (*‹[?a::'a;?b::'a;?c::'a] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) that(1,2) (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹(1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d])›*) by fastforce
moreover have "c∈Q" "d∈Q"
using on_path (*‹⟦?A ⊆ Q; (1 < card ?A ∨ infinite ?A) ∧ (∀x∈?A. [?a;x;?b])⟧ ⟹ ?b ∈ Q ∧ ?a ∈ Q›*) ‹a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d› (*‹a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d›*) that(1,3) (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹I ⊆ Q›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) apply -
(*goals:
1. ‹⟦⋀A a b. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d; (1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b]); I ⊆ Q; ⋀a b c. [a;b;c] ⟹ a ≠ b ∧ a ≠ c ∧ b ≠ c⟧ ⟹ c ∈ Q›
2. ‹⟦⋀A a b. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; a = b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ d; (1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b]); I ⊆ Q; ⋀a b c. [a;b;c] ⟹ a ≠ b ∧ a ≠ c ∧ b ≠ c⟧ ⟹ d ∈ Q›
discuss goal 1*)
apply metis
(*discuss goal 2*)
apply metis
(*proven 2 subgoals*) .
ultimately show "∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]"
by blast
next
(*goals:
1. ‹a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
2. ‹[a;b;c] ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
3. ‹[b;a;c] ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
assume "a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d" (*‹(a::'a) ≠ (b::'a) ∧ b = (c::'a) ∧ c ≠ (d::'a) ∧ a = d›*)
hence "∀x∈ I∪J. [c;x;d]"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) that(1,2) (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹(1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d])›*) by auto
moreover have "c∈Q" "d∈Q"
using on_path (*‹⟦?A ⊆ Q; (1 < card ?A ∨ infinite ?A) ∧ (∀x∈?A. [?a;x;?b])⟧ ⟹ ?b ∈ Q ∧ ?a ∈ Q›*) ‹a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d› (*‹a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d›*) that(1,3) (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹I ⊆ Q›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) apply -
(*goals:
1. ‹⟦⋀A a b. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d; (1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b]); I ⊆ Q; ⋀a b c. [a;b;c] ⟹ a ≠ b ∧ a ≠ c ∧ b ≠ c⟧ ⟹ c ∈ Q›
2. ‹⟦⋀A a b. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; a ≠ b ∧ b = c ∧ c ≠ d ∧ a = d; (1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b]); I ⊆ Q; ⋀a b c. [a;b;c] ⟹ a ≠ b ∧ a ≠ c ∧ b ≠ c⟧ ⟹ d ∈ Q›
discuss goal 1*)
apply metis
(*discuss goal 2*)
apply metis
(*proven 2 subgoals*) .
ultimately show "∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]"
by blast
next
(*goals:
1. ‹[a;b;c] ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›
2. ‹[b;a;c] ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
assume "[a;b;c] ∧ a = d" (*‹[a::'a;b::'a;c::'a] ∧ a = (d::'a)›*)
hence "∀x∈ I∪J. [c;x;d]"
by (metis UnE (*‹⟦?c ∈ ?A ∪ ?B; ?c ∈ ?A ⟹ ?P; ?c ∈ ?B ⟹ ?P⟧ ⟹ ?P›*) abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) that( (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹(1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d])›*) 1,2))
moreover have "c∈Q" "d∈Q"
using on_path (*‹⟦?A ⊆ Q; (1 < card ?A ∨ infinite ?A) ∧ (∀x∈?A. [?a;x;?b])⟧ ⟹ ?b ∈ Q ∧ ?a ∈ Q›*) that(2,4) (*‹(1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d])› ‹J ⊆ Q›*) apply -
(*goals:
1. ‹⟦⋀(A::'a::type set) (a::'a::type) b::'a::type. ⟦A ⊆ (Q::'a::type set); ((1::nat) < card A ∨ infinite A) ∧ (∀x::'a::type∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; ((1::nat) < card (J::'a::type set) ∨ infinite J) ∧ (∀x::'a::type∈J. [c::'a::type;x;d::'a::type]); J ⊆ Q⟧ ⟹ c ∈ Q›
2. ‹⟦⋀(A::'a::type set) (a::'a::type) b::'a::type. ⟦A ⊆ (Q::'a::type set); ((1::nat) < card A ∨ infinite A) ∧ (∀x::'a::type∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; ((1::nat) < card (J::'a::type set) ∨ infinite J) ∧ (∀x::'a::type∈J. [c::'a::type;x;d::'a::type]); J ⊆ Q⟧ ⟹ d ∈ Q›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
ultimately show "∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]"
by blast
next
(*goal: ‹[b;a;c] ∧ a = d ⟹ ∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]›*)
assume "[b;a;c] ∧ a = d" (*‹[b::'a;a::'a;c::'a] ∧ a = (d::'a)›*)
hence "∀x∈ I∪J. [c;x;b]"
using abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) abd_bcd_abc (*‹⟦[?a::'a;?b::'a;?d::'a]; [?b;?c::'a;?d]⟧ ⟹ [?a;?b;?c]›*) betw4_strong (*‹[?a;?b;?c;?d] ⟹ [?a;?b;?d] ∧ [?a;?c;?d]›*) that(1,2) (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹(1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d])›*) by (metis Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*))
moreover have "c∈Q" "b∈Q"
using on_path (*‹⟦(?A::'a set) ⊆ (Q::'a set); ((1::nat) < card ?A ∨ infinite ?A) ∧ (∀x::'a∈?A. [?a::'a;x;?b::'a])⟧ ⟹ ?b ∈ Q ∧ ?a ∈ Q›*) that (*‹(1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b])› ‹(1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d])› ‹I ⊆ Q› ‹J ⊆ Q›*) apply -
(*goals:
1. ‹⟦⋀A a b. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; (1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b]); (1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d]); I ⊆ Q; J ⊆ Q⟧ ⟹ c ∈ Q›
2. ‹⟦⋀A a b. ⟦A ⊆ Q; (1 < card A ∨ infinite A) ∧ (∀x∈A. [a;x;b])⟧ ⟹ b ∈ Q ∧ a ∈ Q; (1 < card I ∨ infinite I) ∧ (∀x∈I. [a;x;b]); (1 < card J ∨ infinite J) ∧ (∀x∈J. [c;x;d]); I ⊆ Q; J ⊆ Q⟧ ⟹ b ∈ Q›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
ultimately show "∃l∈Q. ∃u∈Q. ∀x∈I ∪ J. [l;x;u]"
by blast
qed
qed
qed
qed
lemma (*for 14i*) union_of_bounded_sets_is_bounded2:
assumes "∀x∈A. [a;x;b]" "∀x∈B. [c;x;d]" "A⊆Q" "B⊆Q" "Q∈𝒫"
"1<card A ∨ infinite A" "1<card B ∨ infinite B"
shows "∃l∈Q-(A∪B). ∃u∈Q-(A∪B). ∀x∈A∪B. [l;x;u]"
using assms (*‹∀x∈A. [a;x;b]› ‹∀x∈B. [c;x;d]› ‹A ⊆ Q› ‹B ⊆ Q› ‹(Q::'a set) ∈ (𝒫::'a set set)› ‹1 < card A ∨ infinite A› ‹1 < card B ∨ infinite B›*) union_of_bounded_sets_is_bounded[where A = A and a = a and b = b and B = B and c = c and d = d and Q = Q] (*‹⟦∀x∈A. [a;x;b]; ∀x∈B. [c;x;d]; A ⊆ Q; B ⊆ Q; Q ∈ 𝒫; 1 < card A ∨ infinite A; 1 < card B ∨ infinite B⟧ ⟹ ∃l∈Q. ∃u∈Q. ∀x∈A ∪ B. [l;x;u]›*) by (metis Diff_iff (*‹(?c ∈ ?A - ?B) = (?c ∈ ?A ∧ ?c ∉ ?B)›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*))
text ‹
Schutz proves a mildly stronger version of this theorem than he states. Namely, he gives an
additional condition that has to be fulfilled by the bounds $y,z$ in the proof (‹y,z∉unreach-on Q from ab›).
This condition is trivial given ‹abc_abc_neq›. His stating it in the proof makes me wonder
whether his (strictly speaking) undefined notion of bounded set is somehow weaker than the
version using strict betweenness in his theorem statement and used here in Isabelle.
This would make sense, given the obvious analogy with sets on the real line.
›
theorem (*14i*) second_existence_thm_1:
assumes path_Q: "Q∈𝒫"
and events: "a∉Q" "b∉Q"
and reachable: "path_ex a q1" "path_ex b q2" "q1∈Q" "q2∈Q"
shows "∃y∈Q. ∃z∈Q. (∀x∈unreach-on Q from a. [y;x;z]) ∧ (∀x∈unreach-on Q from b. [y;x;z])"
proof (-)
(*goal: ‹∃y∈Q. ∃z∈Q. (∀x∈unreach-on Q from a. [y;x;z]) ∧ (∀x∈unreach-on Q from b. [y;x;z])›*)
text ‹Slightly annoying: Schutz implicitly extends ‹bounded› to sets, so his statements are neater.›
have "∃q∈Q. q∉(unreach-on Q from a)" "∃q∈Q. q∉(unreach-on Q from b)"
using cross_in_reachable (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R⟧ ⟹ ?b ∈ ?R - unreach-on ?R from ?a›*) reachable (*‹∃Q::'a set. path Q (a::'a) (q1::'a)› ‹∃Q. path Q b q2› ‹q1 ∈ Q› ‹q2 ∈ Q›*) apply -
(*goals:
1. ‹⟦⋀Q a b R. ⟦Q ∈ 𝒫; a ∈ Q; b ∈ Q; b ∈ R⟧ ⟹ b ∈ R - unreach-on R from a; ∃Q. path Q a q1; ∃Q. path Q b q2; q1 ∈ Q; q2 ∈ Q⟧ ⟹ ∃q∈Q. q ∉ unreach-on Q from a›
2. ‹⟦⋀Q a b R. ⟦Q ∈ 𝒫; a ∈ Q; b ∈ Q; b ∈ R⟧ ⟹ b ∈ R - unreach-on R from a; ∃Q. path Q a q1; ∃Q. path Q b q2; q1 ∈ Q; q2 ∈ Q⟧ ⟹ ∃q∈Q. q ∉ unreach-on Q from b›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
text ‹This is a helper statement for obtaining bounds in both directions of both unreachable sets.
Notice this needs Theorem 13 right now, Schutz claims only Theorem 4. I think this is necessary?›
have get_bds: "∃la∈Q. ∃ua∈Q. la∉unreach-on Q from a ∧ ua∉unreach-on Q from a ∧ (∀x∈unreach-on Q from a. [la;x;ua])" if asm: "a∉Q" "path_ex a q" "q∈Q" for a and q
proof (-)
(*goal: ‹∃la∈Q. ∃ua∈Q. la ∉ unreach-on Q from a ∧ ua ∉ unreach-on Q from a ∧ (∀x∈unreach-on Q from a. [la;x;ua])›*)
obtain Qy where "Qy∈unreach-on Q from a"
(*goal: ‹(⋀Qy. Qy ∈ unreach-on Q from a ⟹ thesis) ⟹ thesis›*)
using asm(2) (*‹∃Q. path Q a q›*) ‹a ∉ Q› (*‹a ∉ Q›*) in_path_event (*‹⟦(?Q::'a::type set) ∈ (𝒫::'a::type set set); (?a::'a::type) ∈ ?Q⟧ ⟹ ?a ∈ (ℰ::'a::type set)›*) path_Q (*‹(Q::'a set) ∈ (𝒫::'a set set)›*) two_in_unreach (*‹⟦?Q ∈ 𝒫; ?b ∈ ℰ; ?b ∉ ?Q⟧ ⟹ ∃x∈unreach-on ?Q from ?b. ∃y∈unreach-on ?Q from ?b. x ≠ y›*) by blast
then obtain la where "la ∈ Q - unreach-on Q from a"
(*goal: ‹(⋀la. la ∈ Q - unreach-on Q from a ⟹ thesis) ⟹ thesis›*)
using asm(2,3) (*‹∃Q::'a set. path Q (a::'a) (q::'a)› ‹(q::'a) ∈ (Q::'a set)›*) cross_in_reachable (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R⟧ ⟹ ?b ∈ ?R - unreach-on ?R from ?a›*) by blast
then obtain ua where "ua ∈ Q - unreach-on Q from a" "[la;Qy;ua]" "la ≠ ua"
(*goal: ‹(⋀ua. ⟦ua ∈ Q - unreach-on Q from a; [la;Qy;ua]; la ≠ ua⟧ ⟹ thesis) ⟹ thesis›*)
using unreachable_set_bounded[where Q = Q and b = a and Qx = la and Qy = Qy] (*‹⟦Q ∈ 𝒫; a ∉ Q; a ∈ ℰ; la ∈ Q - unreach-on Q from a; Qy ∈ unreach-on Q from a⟧ ⟹ ∃Qz∈Q - unreach-on Q from a. [la;Qy;Qz] ∧ la ≠ Qz›*) using ‹Qy ∈ unreach-on Q from a› (*‹Qy ∈ unreach-on Q from a›*) asm (*‹a ∉ Q› ‹∃Q::'a::type set. path Q (a::'a::type) (q::'a::type)› ‹(q::'a) ∈ (Q::'a set)›*) in_path_event (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q⟧ ⟹ ?a ∈ (ℰ::'a set)›*) path_Q (*‹(Q::'a set) ∈ (𝒫::'a set set)›*) by blast
have "la ∉ unreach-on Q from a ∧ ua ∉ unreach-on Q from a ∧ (∀x∈unreach-on Q from a. (x≠la ∧ x≠ua) ⟶ [la;x;ua])"
proof (intro conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹la ∉ unreach-on Q from a›
2. ‹ua ∉ unreach-on Q from a›
3. ‹∀x∈unreach-on Q from a. x ≠ la ∧ x ≠ ua ⟶ [la;x;ua]›*)
show "la ∉ unreach-on Q from a"
using ‹la ∈ Q - unreach-on Q from a› (*‹la ∈ Q - unreach-on Q from a›*) by force
next
(*goals:
1. ‹ua ∉ unreach-on Q from a›
2. ‹∀x∈unreach-on Q from a. x ≠ la ∧ x ≠ ua ⟶ [la;x;ua]›*)
show "ua ∉ unreach-on Q from a"
using ‹ua ∈ Q - unreach-on Q from a› (*‹ua ∈ Q - unreach-on Q from a›*) by force
next
(*goal: ‹∀x::'a∈unreach-on (Q::'a set) from (a::'a). x ≠ (la::'a) ∧ x ≠ (ua::'a) ⟶ [la;x;ua]›*)
show "∀x∈unreach-on Q from a. x ≠ la ∧ x ≠ ua ⟶ [la;x;ua]"
proof (safe)
(*goal: ‹⋀x::'a. ⟦x ∈ unreach-on (Q::'a set) from (a::'a); x ≠ (la::'a); x ≠ (ua::'a)⟧ ⟹ [la;x;ua]›*)
fix x
assume "x∈unreach-on Q from a" "x≠la" "x≠ua" (*‹(x::'a) ∈ unreach-on (Q::'a set) from (a::'a)› ‹(x::'a) ≠ (la::'a)› ‹(x::'a) ≠ (ua::'a)›*)
{
assume "x=Qy" (*‹(x::'a) = (Qy::'a)›*)
hence "[la;x;ua]"
by (simp add: ‹[la;Qy;ua]›)
}
moreover {
assume "x≠Qy" (*‹(x::'a) ≠ (Qy::'a)›*)
have "[Qy;x;la] ∨ [la;Qy;x]"
proof (-)
(*goal: ‹[Qy;x;la] ∨ [la;Qy;x]›*)
{
assume "[x;la;Qy]" (*‹[x::'a;la::'a;Qy::'a]›*)
hence "la∈unreach-on Q from a"
using unreach_connected (*‹⟦?Q ∈ 𝒫; ?b ∉ ?Q; ?b ∈ ℰ; ?Q⇩x ∈ unreach-on ?Q from ?b; ?Q⇩z ∈ unreach-on ?Q from ?b; [?Q⇩x;?Q⇩y;?Q⇩z]⟧ ⟹ ?Q⇩y ∈ unreach-on ?Q from ?b›*) ‹Qy∈unreach-on Q from a› (*‹Qy ∈ unreach-on Q from a›*) ‹x∈unreach-on Q from a› (*‹x ∈ unreach-on Q from a›*) ‹x≠Qy› (*‹(x::'a) ≠ (Qy::'a)›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_Q (*‹Q ∈ 𝒫›*) that (*‹a ∉ Q› ‹∃Q. path Q a q› ‹q ∈ Q›*) by blast
hence False
using ‹la ∈ Q - unreach-on Q from a› (*‹la ∈ Q - unreach-on Q from a›*) by blast
}
thus "[Qy;x;la] ∨ [la;Qy;x]"
using some_betw[where Q = Q and a = x and b = la and c = Qy] (*‹⟦Q ∈ 𝒫; x ∈ Q; la ∈ Q; Qy ∈ Q; x ≠ la; x ≠ Qy; la ≠ Qy⟧ ⟹ [x;la;Qy] ∨ [la;Qy;x] ∨ [Qy;x;la]›*) path_Q (*‹Q ∈ 𝒫›*) unreach_on_path (*‹?a ∈ unreach-on ?Q from ?b ⟹ ?a ∈ ?Q›*) using ‹Qy ∈ unreach-on Q from a› (*‹Qy ∈ unreach-on Q from a›*) ‹la ∈ Q - unreach-on Q from a› (*‹la ∈ Q - unreach-on Q from a›*) ‹x ∈ unreach-on Q from a› (*‹x ∈ unreach-on Q from a›*) ‹x ≠ Qy› (*‹(x::'a::type) ≠ (Qy::'a::type)›*) ‹x ≠ la› (*‹x ≠ la›*) by force
qed
hence "[la;x;ua]"
proof (standard)
(*goals:
1. ‹[Qy::'a;x::'a;la::'a] ⟹ [la;x;ua::'a]›
2. ‹[la::'a;Qy::'a;x::'a] ⟹ [la;x;ua::'a]›*)
assume "[Qy;x;la]" (*‹[Qy::'a;x::'a;la::'a]›*)
thus "?thesis"
(*goal: ‹[la::'a;x::'a;ua::'a]›*)
using ‹[la;Qy;ua]› (*‹[la::'a::type;Qy::'a::type;ua::'a::type]›*) abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) by blast
next
(*goal: ‹[la::'a;Qy::'a;x::'a] ⟹ [la;x;ua::'a]›*)
assume "[la;Qy;x]" (*‹[la::'a;Qy::'a;x::'a]›*)
hence "[la;x;ua] ∨ [la;ua;x]"
using ‹[la;Qy;ua]› (*‹[la;Qy;ua]›*) ‹x ≠ ua› (*‹x ≠ ua›*) abc_abd_acdadc (*‹⟦[?a;?b;?c]; [?a;?b;?d]; ?c ≠ ?d⟧ ⟹ [?a;?c;?d] ∨ [?a;?d;?c]›*) by auto
have "¬[la;ua;x]"
using unreach_connected (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?b::'a) ∉ ?Q; ?b ∈ (ℰ::'a set); (?Q⇩x::'a) ∈ unreach-on ?Q from ?b; (?Q⇩z::'a) ∈ unreach-on ?Q from ?b; [?Q⇩x;?Q⇩y::'a;?Q⇩z]⟧ ⟹ ?Q⇩y ∈ unreach-on ?Q from ?b›*) that (*‹a ∉ Q› ‹∃Q::'a set. path Q (a::'a) (q::'a)› ‹q ∈ Q›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_acd_bcd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?b;?c;?d]›*) in_path_event (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q⟧ ⟹ ?a ∈ (ℰ::'a set)›*) path_Q (*‹(Q::'a::type set) ∈ (𝒫::'a::type set set)›*) by (metis DiffD2 (*‹⟦?c ∈ ?A - ?B; ?c ∈ ?B⟧ ⟹ ?P›*) ‹Qy ∈ unreach-on Q from a› ‹[la;Qy;ua]› ‹ua ∈ Q - unreach-on Q from a› ‹x ∈ unreach-on Q from a›)
show "?thesis"
(*goal: ‹[la;x;ua]›*)
using ‹[la;x;ua] ∨ [la;ua;x]› (*‹[la;x;ua] ∨ [la;ua;x]›*) ‹¬ [la;ua;x]› (*‹¬ [la;ua;x]›*) by linarith
qed
}
ultimately show "[la;x;ua]"
by blast
qed
qed
thus "?thesis"
(*goal: ‹∃la∈Q. ∃ua∈Q. la ∉ unreach-on Q from a ∧ ua ∉ unreach-on Q from a ∧ (∀x∈unreach-on Q from a. [la;x;ua])›*)
using ‹la ∈ Q - unreach-on Q from a› (*‹la ∈ Q - unreach-on Q from a›*) ‹ua ∈ Q - unreach-on Q from a› (*‹(ua::'a) ∈ (Q::'a set) - unreach-on Q from (a::'a)›*) by force
qed
have "∃y∈Q. ∃z∈Q. (∀x∈(unreach-on Q from a)∪(unreach-on Q from b). [y;x;z])"
proof (-)
(*goal: ‹∃y∈Q. ∃z∈Q. ∀x∈unreach-on Q from a ∪ unreach-on Q from b. [y;x;z]›*)
obtain la and ua where "∀x∈unreach-on Q from a. [la;x;ua]"
(*goal: ‹(⋀(la::'a::type) ua::'a::type. ∀x::'a::type∈unreach-on (Q::'a::type set) from (a::'a::type). [la;x;ua] ⟹ thesis::bool) ⟹ thesis›*)
using events(1) (*‹a ∉ Q›*) get_bds (*‹⟦(?a::'a::type) ∉ (Q::'a::type set); ∃Q::'a::type set. path Q ?a (?q::'a::type); ?q ∈ Q⟧ ⟹ ∃la::'a::type∈Q. ∃ua::'a::type∈Q. la ∉ unreach-on Q from ?a ∧ ua ∉ unreach-on Q from ?a ∧ (∀x::'a::type∈unreach-on Q from ?a. [la;x;ua])›*) reachable(1,3) (*‹∃Q. path Q a q1› ‹q1 ∈ Q›*) by blast
obtain lb and ub where "∀x∈unreach-on Q from b. [lb;x;ub]"
(*goal: ‹(⋀(lb::'a) ub::'a. ∀x::'a∈unreach-on (Q::'a set) from (b::'a). [lb;x;ub] ⟹ thesis::bool) ⟹ thesis›*)
using events(2) (*‹b ∉ Q›*) get_bds (*‹⟦?a ∉ Q; ∃Q. path Q ?a ?q; ?q ∈ Q⟧ ⟹ ∃la∈Q. ∃ua∈Q. la ∉ unreach-on Q from ?a ∧ ua ∉ unreach-on Q from ?a ∧ (∀x∈unreach-on Q from ?a. [la;x;ua])›*) reachable(2,4) (*‹∃Q::'a set. path Q (b::'a) (q2::'a)› ‹q2 ∈ Q›*) by blast
have "unreach-on Q from a ⊆ Q" "unreach-on Q from b ⊆ Q"
(*goals:
1. ‹unreach-on Q from a ⊆ Q›
2. ‹unreach-on Q from b ⊆ Q›
discuss goal 1*)
apply (simp add: subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) unreach_on_path (*‹?a ∈ unreach-on ?Q from ?b ⟹ ?a ∈ ?Q›*))
(*discuss goal 2*)
apply (simp add: subsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ∈ (?B::?'a set)) ⟹ ?A ⊆ ?B›*) unreach_on_path (*‹(?a::'a) ∈ unreach-on (?Q::'a set) from (?b::'a) ⟹ ?a ∈ ?Q›*))
(*proven 2 subgoals*) .
moreover have "1 < card (unreach-on Q from a) ∨ infinite (unreach-on Q from a)"
using two_in_unreach (*‹⟦?Q ∈ 𝒫; ?b ∈ ℰ; ?b ∉ ?Q⟧ ⟹ ∃x∈unreach-on ?Q from ?b. ∃y∈unreach-on ?Q from ?b. x ≠ y›*) events(1) (*‹a ∉ Q›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_Q (*‹Q ∈ 𝒫›*) reachable(1) (*‹∃Q. path Q a q1›*) by (metis One_nat_def (*‹1 = Suc 0›*) card_le_Suc0_iff_eq (*‹finite ?A ⟹ (card ?A ≤ Suc 0) = (∀a1∈?A. ∀a2∈?A. a1 = a2)›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*))
moreover have "1 < card (unreach-on Q from b) ∨ infinite (unreach-on Q from b)"
using two_in_unreach (*‹⟦?Q ∈ 𝒫; ?b ∈ ℰ; ?b ∉ ?Q⟧ ⟹ ∃x∈unreach-on ?Q from ?b. ∃y∈unreach-on ?Q from ?b. x ≠ y›*) events(2) (*‹b ∉ Q›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_Q (*‹Q ∈ 𝒫›*) reachable(2) (*‹∃Q. path Q b q2›*) by (metis One_nat_def (*‹(1::nat) = Suc (0::nat)›*) card_le_Suc0_iff_eq (*‹finite (?A::?'a set) ⟹ (card ?A ≤ Suc (0::nat)) = (∀a1::?'a∈?A. ∀a2::?'a∈?A. a1 = a2)›*) not_less (*‹(¬ (?x::?'a) < (?y::?'a)) = (?y ≤ ?x)›*))
ultimately show "?thesis"
(*goal: ‹∃y::'a∈Q::'a set. ∃z::'a∈Q. ∀x::'a∈unreach-on Q from (a::'a) ∪ unreach-on Q from (b::'a). [y;x;z]›*)
using union_of_bounded_sets_is_bounded[where Q = Q and A = "unreach-on Q from a" and B = "unreach-on Q from b"] (*‹⟦∀x∈unreach-on Q from a. [?a;x;?b]; ∀x∈unreach-on Q from b. [?c;x;?d]; unreach-on Q from a ⊆ Q; unreach-on Q from b ⊆ Q; Q ∈ 𝒫; 1 < card unreach-on Q from a ∨ infinite unreach-on Q from a; 1 < card unreach-on Q from b ∨ infinite unreach-on Q from b⟧ ⟹ ∃l∈Q. ∃u∈Q. ∀x∈unreach-on Q from a ∪ unreach-on Q from b. [l;x;u]›*) using get_bds (*‹⟦?a ∉ Q; ∃Q. path Q ?a ?q; ?q ∈ Q⟧ ⟹ ∃la∈Q. ∃ua∈Q. la ∉ unreach-on Q from ?a ∧ ua ∉ unreach-on Q from ?a ∧ (∀x∈unreach-on Q from ?a. [la;x;ua])›*) assms (*‹Q ∈ 𝒫› ‹a ∉ Q› ‹b ∉ Q› ‹∃Q. path Q a q1› ‹∃Q. path Q b q2› ‹q1 ∈ Q› ‹q2 ∈ Q›*) ‹∀x∈unreach-on Q from a. [la;x;ua]› (*‹∀x∈unreach-on Q from a. [la;x;ua]›*) ‹∀x∈unreach-on Q from b. [lb;x;ub]› (*‹∀x∈unreach-on Q from b. [lb;x;ub]›*) by blast
qed
then obtain y and z where "y∈Q" "z∈Q" "(∀x∈(unreach-on Q from a)∪(unreach-on Q from b). [y;x;z])"
(*goal: ‹(⋀y z. ⟦y ∈ Q; z ∈ Q; ∀x∈unreach-on Q from a ∪ unreach-on Q from b. [y;x;z]⟧ ⟹ thesis) ⟹ thesis›*)
by blast
show "?thesis"
(*goal: ‹∃y::'a∈Q::'a set. ∃z::'a∈Q. (∀x::'a∈unreach-on Q from (a::'a). [y;x;z]) ∧ (∀x::'a∈unreach-on Q from (b::'a). [y;x;z])›*)
proof ((rule bexI (*‹⟦?P ?x; ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*))+)
(*goals:
1. ‹(∀x∈unreach-on Q from a. [?y;x;?z3]) ∧ (∀x∈unreach-on Q from b. [?y;x;?z3])›
2. ‹?z3 ∈ Q›
3. ‹?y ∈ Q›*)
show "y∈Q"
by (simp add: ‹y ∈ Q›)
show "z∈Q"
by (simp add: ‹z ∈ Q›)
show "(∀x∈unreach-on Q from a. [z;x;y]) ∧ (∀x∈unreach-on Q from b. [z;x;y])"
by (simp add: ‹∀x∈unreach-on Q from a ∪ unreach-on Q from b. [y;x;z]› abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*))
qed
qed
theorem (*14*) second_existence_thm_2:
assumes path_Q: "Q∈𝒫"
and events: "a∉Q" "b∉Q" "c∈Q" "d∈Q" "c≠d"
and reachable: "∃P∈𝒫. ∃q∈Q. path P a q" "∃P∈𝒫. ∃q∈Q. path P b q"
shows "∃e∈Q. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ [c;d;e]"
proof (-)
(*goal: ‹∃e∈Q. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ [c;d;e]›*)
obtain y and z where bounds_yz: "(∀x∈unreach-on Q from a. [z;x;y]) ∧ (∀x∈unreach-on Q from b. [z;x;y])" and yz_inQ: "y∈Q" "z∈Q"
(*goal: ‹(⋀(z::'a::type) y::'a::type. ⟦(∀x::'a::type∈unreach-on (Q::'a::type set) from (a::'a::type). [z;x;y]) ∧ (∀x::'a::type∈unreach-on Q from (b::'a::type). [z;x;y]); y ∈ Q; z ∈ Q⟧ ⟹ thesis::bool) ⟹ thesis›*)
using second_existence_thm_1[where Q = Q and a = a and b = b] (*‹⟦Q ∈ 𝒫; a ∉ Q; b ∉ Q; ∃Q. path Q a ?q1.0; ∃Q. path Q b ?q2.0; ?q1.0 ∈ Q; ?q2.0 ∈ Q⟧ ⟹ ∃y∈Q. ∃z∈Q. (∀x∈unreach-on Q from a. [y;x;z]) ∧ (∀x∈unreach-on Q from b. [y;x;z])›*) using path_Q (*‹Q ∈ 𝒫›*) events(1,2) (*‹(a::'a) ∉ (Q::'a set)› ‹b ∉ Q›*) reachable (*‹∃P∈𝒫. ∃q∈Q. path P a q› ‹∃P∈𝒫. ∃q∈Q. path P b q›*) by blast
have "y∉(unreach-on Q from a)∪(unreach-on Q from b)" "z∉(unreach-on Q from a)∪(unreach-on Q from b)"
(*goals:
1. ‹y ∉ unreach-on Q from a ∪ unreach-on Q from b›
2. ‹z ∉ unreach-on Q from a ∪ unreach-on Q from b›
discuss goal 1*)
apply (meson Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) ‹(∀x∈unreach-on Q from a. [z;x;y]) ∧ (∀x∈unreach-on Q from b. [z;x;y])› abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*))
(*discuss goal 2*)
apply (meson Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) ‹(∀x∈unreach-on Q from a. [z;x;y]) ∧ (∀x∈unreach-on Q from b. [z;x;y])› abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*))
(*proven 2 subgoals*) .
let ?P = "λe ae be. (e∈Q ∧ path ae a e ∧ path be b e ∧ [c;d;e])"
have exist_ay: "∃ay. path ay a y" if "a∉Q" "∃P∈𝒫. ∃q∈Q. path P a q" "y∉(unreach-on Q from a)" "y∈Q" for a and y
using in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_Q (*‹(Q::'a set) ∈ (𝒫::'a set set)›*) that (*‹(a::'a) ∉ (Q::'a set)› ‹∃P∈𝒫. ∃q∈Q. path P a q› ‹y ∉ unreach-on Q from a› ‹y ∈ Q›*) unreachable_bounded_path_only (*‹⟦?d' ∉ unreach-on ?ab from ?e; ?d' ∈ ?ab; ?d' ≠ ?e; ?e ∈ ℰ; ?ab ∈ 𝒫; ?e ∉ ?ab⟧ ⟹ ∃d'e. path d'e ?d' ?e›*) by blast
have "[c;d;y] ∨ ⟦y;c;d] ∨ [c;y;d⟧"
by (meson ‹y ∈ Q› abc_sym (*‹[?a::'a;?b::'a;?c::'a] ⟹ [?c;?b;?a]›*) events( (*‹(c::'a) ∈ (Q::'a set)› ‹(d::'a) ∈ (Q::'a set)› ‹(c::'a) ≠ (d::'a)›*) 3-5) path_Q (*‹(Q::'a set) ∈ (𝒫::'a set set)›*) some_betw (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q; (?b::'a) ∈ ?Q; (?c::'a) ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*))
moreover have "[c;d;z] ∨ ⟦z;c;d] ∨ [c;z;d⟧"
by (meson ‹z ∈ Q› abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) events( (*‹c ∈ Q› ‹d ∈ Q› ‹c ≠ d›*) 3-5) path_Q (*‹Q ∈ 𝒫›*) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*))
ultimately consider "[c;d;y]" | "[c;d;z]" | "((⟦y;c;d] ∨ [c;y;d⟧) ∧ (⟦z;c;d] ∨ [c;z;d⟧))"
(*goal: ‹⟦[c;d;y] ⟹ thesis; [c;d;z] ⟹ thesis; (⟦y;c;d] ∨ [c;y;d⟧) ∧ (⟦z;c;d] ∨ [c;z;d⟧) ⟹ thesis⟧ ⟹ thesis›*)
by auto
thus "?thesis"
(*goal: ‹∃e∈Q. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ [c;d;e]›*)
proof (cases)
(*goals:
1. ‹[c;d;y] ⟹ ∃e∈Q. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ [c;d;e]›
2. ‹[c;d;z] ⟹ ∃e∈Q. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ [c;d;e]›
3. ‹(⟦y;c;d] ∨ [c;y;d⟧) ∧ (⟦z;c;d] ∨ [c;z;d⟧) ⟹ ∃e∈Q. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ [c;d;e]›*)
assume "[c;d;y]" (*‹[c::'a;d::'a;y::'a]›*)
have "y∉(unreach-on Q from a)" "y∉(unreach-on Q from b)"
using ‹y ∉ unreach-on Q from a ∪ unreach-on Q from b› (*‹y ∉ unreach-on Q from a ∪ unreach-on Q from b›*) apply -
(*goals:
1. ‹y ∉ unreach-on Q from a ∪ unreach-on Q from b ⟹ y ∉ unreach-on Q from a›
2. ‹y ∉ unreach-on Q from a ∪ unreach-on Q from b ⟹ y ∉ unreach-on Q from b›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
then obtain ay and yb where "path ay a y" "path yb b y"
(*goal: ‹(⋀ay yb. ⟦path ay a y; path yb b y⟧ ⟹ thesis) ⟹ thesis›*)
using ‹y∈Q› (*‹y ∈ Q›*) exist_ay (*‹⟦?a ∉ Q; ∃P∈𝒫. ∃q∈Q. path P ?a q; ?y ∉ unreach-on Q from ?a; ?y ∈ Q⟧ ⟹ ∃ay. path ay ?a ?y›*) events(1,2) (*‹(a::'a::type) ∉ (Q::'a::type set)› ‹b ∉ Q›*) reachable(1,2) (*‹∃P∈𝒫. ∃q∈Q. path P a q› ‹∃P∈𝒫. ∃q∈Q. path P b q›*) by blast
have "?P y ay yb"
using ‹[c;d;y]› (*‹[c;d;y]›*) ‹path ay a y› (*‹path ay a y›*) ‹path yb b y› (*‹path yb b y›*) ‹y ∈ Q› (*‹y ∈ Q›*) by blast
thus "?thesis"
(*goal: ‹∃e∈Q. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ [c;d;e]›*)
by blast
next
(*goals:
1. ‹[c;d;z] ⟹ ∃e∈Q. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ [c;d;e]›
2. ‹(⟦y;c;d] ∨ [c;y;d⟧) ∧ (⟦z;c;d] ∨ [c;z;d⟧) ⟹ ∃e∈Q. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ [c;d;e]›*)
assume "[c;d;z]" (*‹[c::'a;d::'a;z::'a]›*)
have "z∉(unreach-on Q from a)" "z∉(unreach-on Q from b)"
using ‹z ∉ unreach-on Q from a ∪ unreach-on Q from b› (*‹z ∉ unreach-on Q from a ∪ unreach-on Q from b›*) apply -
(*goals:
1. ‹z ∉ unreach-on Q from a ∪ unreach-on Q from b ⟹ z ∉ unreach-on Q from a›
2. ‹z ∉ unreach-on Q from a ∪ unreach-on Q from b ⟹ z ∉ unreach-on Q from b›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
then obtain az and bz where "path az a z" "path bz b z"
(*goal: ‹(⋀az bz. ⟦path az a z; path bz b z⟧ ⟹ thesis) ⟹ thesis›*)
using ‹z∈Q› (*‹z ∈ Q›*) exist_ay (*‹⟦?a ∉ Q; ∃P∈𝒫. ∃q∈Q. path P ?a q; ?y ∉ unreach-on Q from ?a; ?y ∈ Q⟧ ⟹ ∃ay. path ay ?a ?y›*) events(1,2) (*‹a ∉ Q› ‹b ∉ Q›*) reachable(1,2) (*‹∃P∈𝒫. ∃q∈Q. path P a q› ‹∃P::'a::type set∈𝒫::'a::type set set. ∃q::'a::type∈Q::'a::type set. path P (b::'a::type) q›*) by blast
have "?P z az bz"
using ‹[c;d;z]› (*‹[c;d;z]›*) ‹path az a z› (*‹path (az::'a set) (a::'a) (z::'a)›*) ‹path bz b z› (*‹path (bz::'a set) (b::'a) (z::'a)›*) ‹z ∈ Q› (*‹(z::'a) ∈ (Q::'a set)›*) by blast
thus "?thesis"
(*goal: ‹∃e∈Q. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ [c;d;e]›*)
by blast
next
(*goal: ‹(⟦y;c;d] ∨ [c;y;d⟧) ∧ (⟦z;c;d] ∨ [c;z;d⟧) ⟹ ∃e∈Q. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ [c;d;e]›*)
assume "(⟦y;c;d] ∨ [c;y;d⟧) ∧ (⟦z;c;d] ∨ [c;z;d⟧)" (*‹(⟦y::'a;c::'a;d::'a] ∨ [c;y;d⟧) ∧ (⟦z::'a;c;d] ∨ [c;z;d⟧)›*)
have "∃e. [c;d;e]"
using prolong_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ∃c∈ℰ. [?a;?b;c]›*) using events(3-5) (*‹c ∈ Q› ‹d ∈ Q› ‹c ≠ d›*) path_Q (*‹(Q::'a set) ∈ (𝒫::'a set set)›*) by blast
then obtain e where "[c;d;e]"
(*goal: ‹(⋀e. [c;d;e] ⟹ thesis) ⟹ thesis›*)
by auto
have "¬[y;e;z]"
proof (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹[y;e;z] ⟹ False›*)
text ‹Notice Theorem 10 is not needed for this proof, and does not seem to help ‹sledgehammer›.
I think this is because it cannot be easily/automatically reconciled with non-strict
notation.›
assume "[y;e;z]" (*‹[y::'a;e::'a;z::'a]›*)
moreover consider "(⟦y;c;d] ∧ ⟦z;c;d])" | "(⟦y;c;d] ∧ [c;z;d⟧)" | "([c;y;d⟧ ∧ ⟦z;c;d])" | "([c;y;d⟧ ∧ [c;z;d⟧)"
(*goal: ‹⟦⟦y::'a;c::'a;d::'a] ∧ ⟦z::'a;c;d] ⟹ thesis::bool; ⟦y;c;d] ∧ [c;z;d⟧ ⟹ thesis; [c;y;d⟧ ∧ ⟦z;c;d] ⟹ thesis; [c;y;d⟧ ∧ [c;z;d⟧ ⟹ thesis⟧ ⟹ thesis›*)
using ‹(⟦y;c;d] ∨ [c;y;d⟧) ∧ (⟦z;c;d] ∨ [c;z;d⟧)› (*‹(⟦y;c;d] ∨ [c;y;d⟧) ∧ (⟦z;c;d] ∨ [c;z;d⟧)›*) by linarith
ultimately show False
by (smt ‹[c;d;e]› abc_ac_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?c›*) betw4_strong (*‹[?a;?b;?c;?d] ⟹ [?a;?b;?d] ∧ [?a;?c;?d]›*) betw4_weak (*‹[?a;?b;?c] ∧ [?a;?c;?d] ∨ [?a;?b;?c;?d] ∨ [?a;?b;?d] ∧ [?b;?c;?d] ∨ [?a;?b;?d] ∧ [?b;?c;?d] ⟹ [?a;?b;?c;?d]›*))
qed
have "e∈Q"
using ‹[c;d;e]› (*‹[c;d;e]›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) events(3-5) (*‹c ∈ Q› ‹d ∈ Q› ‹c ≠ d›*) path_Q (*‹Q ∈ 𝒫›*) by blast
have "e∉ unreach-on Q from a" "e∉ unreach-on Q from b"
using bounds_yz (*‹(∀x∈unreach-on Q from a. [z;x;y]) ∧ (∀x∈unreach-on Q from b. [z;x;y])›*) ‹¬ [y;e;z]› (*‹¬ [y;e;z]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) apply -
(*goals:
1. ‹⟦(∀x::'a∈unreach-on (Q::'a set) from (a::'a). [z::'a;x;y::'a]) ∧ (∀x::'a∈unreach-on Q from (b::'a). [z;x;y]); ¬ [y;e::'a;z]; ⋀(a::'a) (b::'a) c::'a. [a;b;c] ⟹ [c;b;a]⟧ ⟹ e ∉ unreach-on Q from a›
2. ‹⟦(∀x::'a∈unreach-on (Q::'a set) from (a::'a). [z::'a;x;y::'a]) ∧ (∀x::'a∈unreach-on Q from (b::'a). [z;x;y]); ¬ [y;e::'a;z]; ⋀(a::'a) (b::'a) c::'a. [a;b;c] ⟹ [c;b;a]⟧ ⟹ e ∉ unreach-on Q from b›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
hence ex_aebe: "∃ae be. path ae a e ∧ path be b e"
using ‹e ∈ Q› (*‹e ∈ Q›*) events(1,2) (*‹(a::'a) ∉ (Q::'a set)› ‹(b::'a::type) ∉ (Q::'a::type set)›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) path_Q (*‹Q ∈ 𝒫›*) reachable(1,2) (*‹∃P∈𝒫. ∃q∈Q. path P a q› ‹∃P∈𝒫. ∃q∈Q. path P b q›*) unreachable_bounded_path_only (*‹⟦?d' ∉ unreach-on ?ab from ?e; ?d' ∈ ?ab; ?d' ≠ ?e; ?e ∈ ℰ; ?ab ∈ 𝒫; ?e ∉ ?ab⟧ ⟹ ∃d'e. path d'e ?d' ?e›*) by metis
thus "?thesis"
(*goal: ‹∃e∈Q. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ [c;d;e]›*)
using ‹[c;d;e]› (*‹[c;d;e]›*) ‹e ∈ Q› (*‹(e::'a::type) ∈ (Q::'a::type set)›*) by blast
qed
qed
text ‹
The assumption ‹Q≠R› in Theorem 14(iii) is somewhat implicit in Schutz.
If ‹Q=R›, ‹unreach-on Q from a› is empty, so the third conjunct of the conclusion is meaningless.
›
theorem (*14*) second_existence_thm_3:
assumes paths: "Q∈𝒫" "R∈𝒫" "Q≠R"
and events: "x∈Q" "x∈R" "a∈R" "a≠x" "b∉Q"
and reachable: "∃P∈𝒫. ∃q∈Q. path P b q"
shows "∃e∈ℰ. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ (∀y∈unreach-on Q from a. [x;y;e])"
proof (-)
(*goal: ‹∃e∈ℰ. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ (∀y∈unreach-on Q from a. [x;y;e])›*)
have "a∉Q"
using events(1-4) (*‹x ∈ Q› ‹x ∈ R› ‹a ∈ R› ‹a ≠ x›*) paths (*‹Q ∈ 𝒫› ‹R ∈ 𝒫› ‹Q ≠ R›*) eq_paths (*‹⟦?P ∈ 𝒫; ?Q ∈ 𝒫; ?a ∈ ?P; ?b ∈ ?P; ?a ∈ ?Q; ?b ∈ ?Q; ?a ≠ ?b⟧ ⟹ ?P = ?Q›*) by blast
hence "unreach-on Q from a ≠ {}"
by (metis events( (*‹a ∈ R›*) 3) ex_in_conv (*‹(∃x. x ∈ ?A) = (?A ≠ {})›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) paths( (*‹Q ∈ 𝒫› ‹R ∈ 𝒫›*) 1,2) two_in_unreach (*‹⟦?Q ∈ 𝒫; ?b ∈ ℰ; ?b ∉ ?Q⟧ ⟹ ∃x∈unreach-on ?Q from ?b. ∃y∈unreach-on ?Q from ?b. x ≠ y›*))
then obtain d where "d∈ unreach-on Q from a"
(*goal: ‹(⋀d. d ∈ unreach-on Q from a ⟹ thesis) ⟹ thesis›*)
by blast
have "x≠d"
using ‹d ∈ unreach-on Q from a› (*‹d ∈ unreach-on Q from a›*) cross_in_reachable (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?b ∈ ?R⟧ ⟹ ?b ∈ ?R - unreach-on ?R from ?a›*) events(1) (*‹x ∈ Q›*) events(2) (*‹x ∈ R›*) events(3) (*‹a ∈ R›*) paths(2) (*‹R ∈ 𝒫›*) by auto
have "d∈Q"
using ‹d ∈ unreach-on Q from a› (*‹d ∈ unreach-on Q from a›*) unreach_on_path (*‹?a ∈ unreach-on ?Q from ?b ⟹ ?a ∈ ?Q›*) by blast
have "∃e∈Q. ∃ae be. [x;d;e] ∧ path ae a e ∧ path be b e"
using second_existence_thm_2[where c = x and Q = Q and a = a and b = b and d = d] (*‹⟦Q ∈ 𝒫; a ∉ Q; b ∉ Q; x ∈ Q; d ∈ Q; x ≠ d; ∃P∈𝒫. ∃q∈Q. path P a q; ∃P∈𝒫. ∃q∈Q. path P b q⟧ ⟹ ∃e∈Q. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ [x;d;e]›*) using ‹a ∉ Q› (*‹a ∉ Q›*) ‹d ∈ Q› (*‹d ∈ Q›*) ‹x ≠ d› (*‹(x::'a) ≠ (d::'a)›*) events(1-3,5) (*‹x ∈ Q› ‹x ∈ R› ‹a ∈ R› ‹b ∉ Q›*) paths(1,2) (*‹(Q::'a set) ∈ (𝒫::'a set set)› ‹R ∈ 𝒫›*) reachable (*‹∃P∈𝒫. ∃q∈Q. path P b q›*) by blast
then obtain e and ae and be where conds: "[x;d;e] ∧ path ae a e ∧ path be b e"
(*goal: ‹(⋀e ae be. [x;d;e] ∧ path ae a e ∧ path be b e ⟹ thesis) ⟹ thesis›*)
by blast
have "∀y∈(unreach-on Q from a). [x;y;e]"
proof (standard)
(*goal: ‹⋀y. y ∈ unreach-on Q from a ⟹ [x;y;e]›*)
fix y
assume "y∈(unreach-on Q from a)" (*‹(y::'a) ∈ unreach-on (Q::'a set) from (a::'a)›*)
hence "y∈Q"
using unreach_on_path (*‹(?a::'a::type) ∈ unreach-on (?Q::'a::type set) from (?b::'a::type) ⟹ ?a ∈ ?Q›*) by blast
show "[x;y;e]"
proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*))
(*goal: ‹¬ [x;y;e] ⟹ False›*)
assume "¬[x;y;e]" (*‹¬ [x::'a;y::'a;e::'a]›*)
then consider "y=x" | "y=e" | "[y;x;e]" | "[x;e;y]"
(*goal: ‹⟦y = x ⟹ thesis; y = e ⟹ thesis; [y;x;e] ⟹ thesis; [x;e;y] ⟹ thesis⟧ ⟹ thesis›*)
by (metis ‹d∈Q› ‹y∈Q› abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) betw_c_in_path (*‹⟦[?a;?b;?c]; path ?ab ?a ?b⟧ ⟹ ?c ∈ ?ab›*) conds (*‹[x;d;e] ∧ path ae a e ∧ path be b e›*) events( (*‹x ∈ Q›*) 1) paths( (*‹Q ∈ 𝒫›*) 1) some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*))
thus False
proof (cases)
(*goals:
1. ‹y = x ⟹ False›
2. ‹y = e ⟹ False›
3. ‹[y;x;e] ⟹ False›
4. ‹[x;e;y] ⟹ False›*)
assume "y=x" (*‹(y::'a) = (x::'a)›*)
thus False
using ‹y ∈ unreach-on Q from a› (*‹y ∈ unreach-on Q from a›*) events(2,3) (*‹x ∈ R› ‹(a::'a) ∈ (R::'a set)›*) paths(1,2) (*‹Q ∈ 𝒫› ‹R ∈ 𝒫›*) same_empty_unreach (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ unreach-on ?Q from ?a = {}›*) unreach_equiv (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?R::'a set) ∈ 𝒫; (?a::'a) ∈ ?Q; (?b::'a) ∈ ?R; ?a ∈ unreach-on ?Q from ?b⟧ ⟹ ?b ∈ unreach-on ?R from ?a›*) unreach_on_path (*‹?a ∈ unreach-on ?Q from ?b ⟹ ?a ∈ ?Q›*) by blast
next
(*goals:
1. ‹y = e ⟹ False›
2. ‹[y;x;e] ⟹ False›
3. ‹[x;e;y] ⟹ False›*)
assume "y=e" (*‹(y::'a) = (e::'a)›*)
thus False
by (metis ‹y∈Q› assms( (*‹Q ∈ 𝒫›*) 1) conds (*‹[x;d;e] ∧ path ae a e ∧ path be b e›*) empty_iff (*‹(?c ∈ {}) = False›*) same_empty_unreach (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ unreach-on ?Q from ?a = {}›*) unreach_equiv (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?R; ?a ∈ unreach-on ?Q from ?b⟧ ⟹ ?b ∈ unreach-on ?R from ?a›*) ‹y ∈ unreach-on Q from a›)
next
(*goals:
1. ‹[y::'a::type;x::'a::type;e::'a::type] ⟹ False›
2. ‹[x::'a::type;e::'a::type;y::'a::type] ⟹ False›*)
assume "[y;x;e]" (*‹[y::'a;x::'a;e::'a]›*)
hence "[y;x;d]"
using abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) conds (*‹[x;d;e] ∧ path ae a e ∧ path be b e›*) by blast
hence "x∈(unreach-on Q from a)"
using unreach_connected[where Q = Q and Q⇩x = y and Q⇩y = x and Q⇩z = d and b = a] (*‹⟦Q ∈ 𝒫; a ∉ Q; a ∈ ℰ; y ∈ unreach-on Q from a; d ∈ unreach-on Q from a; [y;x;d]⟧ ⟹ x ∈ unreach-on Q from a›*) using ‹¬[x;y;e]› (*‹¬ [x::'a::type;y::'a::type;e::'a::type]›*) ‹a∉Q› (*‹a ∉ Q›*) ‹d∈unreach-on Q from a› (*‹d ∈ unreach-on Q from a›*) ‹y∈unreach-on Q from a› (*‹y ∈ unreach-on Q from a›*) conds (*‹[x;d;e] ∧ path ae a e ∧ path be b e›*) in_path_event (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q⟧ ⟹ ?a ∈ (ℰ::'a set)›*) paths(1) (*‹Q ∈ 𝒫›*) by blast
thus False
using empty_iff (*‹(?c ∈ {}) = False›*) events(2,3) (*‹x ∈ R› ‹a ∈ R›*) paths(1,2) (*‹Q ∈ 𝒫› ‹R ∈ 𝒫›*) same_empty_unreach (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ unreach-on ?Q from ?a = {}›*) unreach_equiv (*‹⟦(?Q::'a::type set) ∈ (𝒫::'a::type set set); (?R::'a::type set) ∈ 𝒫; (?a::'a::type) ∈ ?Q; (?b::'a::type) ∈ ?R; ?a ∈ unreach-on ?Q from ?b⟧ ⟹ ?b ∈ unreach-on ?R from ?a›*) unreach_on_path (*‹?a ∈ unreach-on ?Q from ?b ⟹ ?a ∈ ?Q›*) by metis
next
(*goal: ‹[x;e;y] ⟹ False›*)
assume "[x;e;y]" (*‹[x::'a;e::'a;y::'a]›*)
hence "[d;e;y]"
using abc_acd_bcd (*‹⟦[?a::'a;?b::'a;?c::'a]; [?a;?c;?d::'a]⟧ ⟹ [?b;?c;?d]›*) conds (*‹[x;d;e] ∧ path ae a e ∧ path be b e›*) by blast
hence "e∈(unreach-on Q from a)"
using unreach_connected[where Q = Q and Q⇩x = y and Q⇩y = e and Q⇩z = d and b = a] (*‹⟦Q ∈ 𝒫; a ∉ Q; a ∈ ℰ; y ∈ unreach-on Q from a; d ∈ unreach-on Q from a; [y;e;d]⟧ ⟹ e ∈ unreach-on Q from a›*) using ‹a ∉ Q› (*‹a ∉ Q›*) ‹d ∈ unreach-on Q from a› (*‹d ∈ unreach-on Q from a›*) ‹y ∈ unreach-on Q from a› (*‹y ∈ unreach-on Q from a›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) events(3) (*‹(a::'a::type) ∈ (R::'a::type set)›*) in_path_event (*‹⟦(?Q::'a set) ∈ (𝒫::'a set set); (?a::'a) ∈ ?Q⟧ ⟹ ?a ∈ (ℰ::'a set)›*) paths(1,2) (*‹Q ∈ 𝒫› ‹(R::'a::type set) ∈ (𝒫::'a::type set set)›*) by blast
thus False
by (metis conds (*‹[x;d;e] ∧ path ae a e ∧ path be b e›*) empty_iff (*‹(?c ∈ {}) = False›*) paths( (*‹Q ∈ 𝒫›*) 1) same_empty_unreach (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ unreach-on ?Q from ?a = {}›*) unreach_equiv (*‹⟦?Q ∈ 𝒫; ?R ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?R; ?a ∈ unreach-on ?Q from ?b⟧ ⟹ ?b ∈ unreach-on ?R from ?a›*) unreach_on_path (*‹?a ∈ unreach-on ?Q from ?b ⟹ ?a ∈ ?Q›*))
qed
qed
qed
thus "?thesis"
(*goal: ‹∃e∈ℰ. ∃ae∈𝒫. ∃be∈𝒫. path ae a e ∧ path be b e ∧ (∀y∈unreach-on Q from a. [x;y;e])›*)
using conds (*‹[x;d;e] ∧ path ae a e ∧ path be b e›*) in_path_event (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q⟧ ⟹ ?a ∈ ℰ›*) by blast
qed
end (* context MinkowskiSpacetime *)
section "Theorem 11 - with path density assumed"
locale MinkowskiDense = MinkowskiSpacetime +
assumes path_dense: "path ab a b ⟹ ∃x. [a;x;b]"
begin
text ‹
Path density: if $a$ and $b$ are connected by a path, then the segment between them is nonempty.
Since Schutz insists on the number of segments in his segmentation (Theorem 11), we prove it here,
showcasing where his missing assumption of path density fits in (it is used three times
in ‹number_of_segments›, once in each separate meaningful \<^term>‹local_ordering› case).
›
lemma segment_nonempty:
assumes "path ab a b"
obtains x where "x ∈ segment a b"
using path_dense (*‹path (?ab::'a set) (?a::'a) (?b::'a) ⟹ ∃x::'a. [?a;x;?b]›*) by (metis seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) assms (*‹path ab a b›*))
lemma (*for 11*) number_of_segments:
assumes path_P: "P∈𝒫"
and Q_def: "Q⊆P"
and f_def: "[f↝Q|a..b..c]"
shows "card {segment (f i) (f (i+1)) | i. i<(card Q-1)} = card Q - 1"
proof (-)
(*goal: ‹card {segment (f i) (f (i + 1)) |i. i < card Q - 1} = card Q - 1›*)
let ?S = "{segment (f i) (f (i+1)) | i. i<(card Q-1)}"
let ?N = "card Q"
let ?g = "λ i. segment (f i) (f (i+1))"
have "?N ≥ 3"
using chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch (?X::'a set) ≡ short_ch ?X ∨ (∃f::nat ⇒ 'a. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) f_def (*‹[f↝Q|a..b..c]›*) by (meson finite_long_chain_with_card (*‹[?f↝?Q|?x..?y..?z] ⟹ 3 ≤ card ?Q›*))
have "?g ` {0..?N-2} = ?S"
proof (safe)
(*goals:
1. ‹⋀(x::'a set) i::nat. i ∈ {0::nat..card (Q::'a set) - (2::nat)} ⟹ ∃ia::nat. segment ((f::nat ⇒ 'a) i) (f (i + (1::nat))) = segment (f ia) (f (ia + (1::nat))) ∧ ia < card Q - (1::nat)›
2. ‹⋀(x::'a set) i::nat. i < card (Q::'a set) - (1::nat) ⟹ segment ((f::nat ⇒ 'a) i) (f (i + (1::nat))) ∈ (λi::nat. segment (f i) (f (i + (1::nat)))) ` {0::nat..card Q - (2::nat)}›*)
fix i
assume "i∈{(0::nat)..?N-2}" (*‹(i::nat) ∈ {0::nat..card (Q::'a set) - (2::nat)}›*)
show "∃ia. segment (f i) (f (i+1)) = segment (f ia) (f (ia+1)) ∧ ia<card Q - 1"
proof (standard)
(*goal: ‹segment (f i) (f (i + 1)) = segment (f ?ia) (f (?ia + 1)) ∧ ?ia < card Q - 1›*)
have "i<?N-1"
using assms (*‹P ∈ 𝒫› ‹Q ⊆ P› ‹[f::nat ⇒ 'a↝Q::'a set|a::'a..b::'a..c::'a]›*) ‹i∈{(0::nat)..?N-2}› (*‹(i::nat) ∈ {0::nat..card (Q::'a::type set) - (2::nat)}›*) ‹?N≥3› (*‹3 ≤ card Q›*) by (metis One_nat_def (*‹(1::nat) = Suc (0::nat)›*) Suc_diff_Suc (*‹(?n::nat) < (?m::nat) ⟹ Suc (?m - Suc ?n) = ?m - ?n›*) atLeastAtMost_iff (*‹((?i::?'a::ord) ∈ {?l::?'a::ord..?u::?'a::ord}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) le_less_trans (*‹⟦(?x::?'a::preorder) ≤ (?y::?'a::preorder); ?y < (?z::?'a::preorder)⟧ ⟹ ?x < ?z›*) lessI (*‹(?n::nat) < Suc ?n›*) less_le_trans (*‹⟦(?x::?'a::preorder) < (?y::?'a::preorder); ?y ≤ (?z::?'a::preorder)⟧ ⟹ ?x < ?z›*) less_trans (*‹⟦(?x::?'a::preorder) < (?y::?'a::preorder); ?y < (?z::?'a::preorder)⟧ ⟹ ?x < ?z›*) numeral_2_eq_2 (*‹(2::nat) = Suc (Suc (0::nat))›*) numeral_3_eq_3 (*‹(3::nat) = Suc (Suc (Suc (0::nat)))›*))
then show "segment (f i) (f (i + 1)) = segment (f i) (f (i + 1)) ∧ i<?N-1"
by blast
qed
next
(*goal: ‹⋀x i. i < card Q - 1 ⟹ segment (f i) (f (i + 1)) ∈ (λi. segment (f i) (f (i + 1))) ` {0..card Q - 2}›*)
fix x and i
assume "i < card Q - 1" (*‹(i::nat) < card (Q::'a set) - (1::nat)›*)
let ?s = "segment (f i) (f (i + 1))"
show "?s ∈ ?g ` {0..?N - 2}"
proof (-)
(*goal: ‹segment (f i) (f (i + 1)) ∈ (λi. segment (f i) (f (i + 1))) ` {0..card Q - 2}›*)
have "i∈{0..?N-2}"
using ‹i < card Q - 1› (*‹i < card Q - 1›*) by force
thus "?thesis"
(*goal: ‹segment (f i) (f (i + 1)) ∈ (λi. segment (f i) (f (i + 1))) ` {0..card Q - 2}›*)
by blast
qed
qed
moreover have "inj_on ?g {0..?N-2}"
proof (standard)
(*goal: ‹⋀x y. ⟦x ∈ {0..card Q - 2}; y ∈ {0..card Q - 2}; segment (f x) (f (x + 1)) = segment (f y) (f (y + 1))⟧ ⟹ x = y›*)
fix i and j
assume asm: "i∈{0..?N-2}" "j∈{0..?N-2}" "?g i = ?g j" (*‹(i::nat) ∈ {0::nat..card (Q::'a set) - (2::nat)}› ‹(j::nat) ∈ {0::nat..card (Q::'a set) - (2::nat)}› ‹segment ((f::nat ⇒ 'a) (i::nat)) (f (i + (1::nat))) = segment (f (j::nat)) (f (j + (1::nat)))›*)
show "i=j"
proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*))
(*goal: ‹i ≠ j ⟹ False›*)
assume "i≠j" (*‹(i::nat) ≠ (j::nat)›*)
hence "f i ≠ f j"
using asm(1,2) (*‹i ∈ {0..card Q - 2}› ‹j ∈ {0..card Q - 2}›*) f_def (*‹[f↝Q|a..b..c]›*) assms(3) (*‹[f::nat ⇒ 'a::type↝Q::'a::type set|a::'a::type..b::'a::type..c::'a::type]›*) indices_neq_imp_events_neq[where X = Q and f = f and a = a and b = b and c = c and i = i and j = j] (*‹⟦[f↝Q|a..b..c]; i ≠ j; j < card Q; i < card Q⟧ ⟹ f i ≠ f j›*) by auto
show False
proof (cases)
(*goals:
1. ‹?P ⟹ False›
2. ‹¬ ?P ⟹ False›*)
assume "j=i+1" (*‹(j::nat) = (i::nat) + (1::nat)›*)
hence "j=Suc i"
by linarith
have "Suc(Suc i) < ?N"
using asm(1,2) (*‹i ∈ {0..card Q - 2}› ‹j ∈ {0..card Q - 2}›*) eval_nat_numeral (*‹Numeral1 = Suc 0› ‹numeral (num.Bit0 (?n::num)) = Suc (numeral (Num.BitM ?n))› ‹numeral (num.Bit1 (?n::num)) = Suc (numeral (num.Bit0 ?n))›*) ‹j = Suc i› (*‹j = Suc i›*) by auto
hence "[f i; f (Suc i); f (Suc (Suc i))]"
using assms (*‹P ∈ 𝒫› ‹(Q::'a set) ⊆ (P::'a set)› ‹[f::nat ⇒ 'a::type↝Q::'a::type set|a::'a::type..b::'a::type..c::'a::type]›*) short_ch_card (*‹short_ch_by_ord ?f ?Q ⟹ card ?Q = 2› ‹short_ch (?Q::'a set) ⟹ card ?Q = (2::nat)›*) ‹?N≥3› (*‹3 ≤ card Q›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a) (?X::'a set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain (?f::nat ⇒ 'a) (?Q::'a set) ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x ..] ≡ infinite_chain ?f ?Q ∧ ?f 0 = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type .. ?y::'a::type] ≡ finite_chain ?f ?Q ∧ ?f (0::nat) = ?x ∧ ?f (card ?Q - (1::nat)) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) local_ordering_def (*‹local_ordering ?f ?ord ?X ≡ (∀n. (finite ?X ⟶ n < card ?X) ⟶ ?f n ∈ ?X) ∧ (∀x∈?X. ∃n. (finite ?X ⟶ n < card ?X) ∧ ?f n = x) ∧ (∀n. (finite ?X ⟶ Suc (Suc n) < card ?X) ⟶ ?ord (?f n) (?f (Suc n)) (?f (Suc (Suc n))))›*) by (metis short_ch_alt( (*‹short_ch (?X::'a set) = (∃x::'a∈?X. ∃y::'a∈?X. (∃Q::'a set. path Q x y) ∧ ¬ (∃z::'a∈?X. z ≠ x ∧ z ≠ y))›*) 1) three_in_set3 (*‹⟦(3::nat) ≤ card (?X::?'a set); ⋀(x::?'a) (y::?'a) z::?'a. ⟦x ∈ ?X; y ∈ ?X; z ∈ ?X; x ≠ y; x ≠ z; y ≠ z⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*))
hence "[f i; f j; f (j+1)]"
by (simp add: ‹j = i + 1›)
obtain e where "e∈?g j"
(*goal: ‹(⋀e. e ∈ segment (f j) (f (j + 1)) ⟹ thesis) ⟹ thesis›*)
using segment_nonempty (*‹⟦path ?ab ?a ?b; ⋀x. x ∈ segment ?a ?b ⟹ ?thesis⟧ ⟹ ?thesis›*) abc_ex_path (*‹[?a;?b;?c] ⟹ ∃Q∈𝒫. ?a ∈ Q ∧ ?b ∈ Q ∧ ?c ∈ Q›*) asm(3) (*‹segment (f i) (f (i + 1)) = segment (f j) (f (j + 1))›*) by (metis ‹[f i; f j; f (j+1)]› ‹f i ≠ f j› ‹j = i + 1›)
hence "e∈?g i"
using asm(3) (*‹segment (f i) (f (i + 1)) = segment (f j) (f (j + 1))›*) by blast
have "[f i; f j; e]"
using abd_bcd_abc (*‹⟦[?a;?b;?d]; [?b;?c;?d]⟧ ⟹ [?a;?b;?c]›*) ‹[f i; f j; f (j+1)]› (*‹[f i;f j;f (j + 1)]›*) by (meson ‹e ∈ segment (f j) (f (j + 1))› seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*))
thus False
using ‹e ∈ segment (f i) (f (i + 1))› (*‹e ∈ segment (f i) (f (i + 1))›*) ‹j = i + 1› (*‹(j::nat) = (i::nat) + (1::nat)›*) abc_only_cba(2) (*‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by auto
next
(*goal: ‹j ≠ i + 1 ⟹ False›*)
assume "j≠i+1" (*‹(j::nat) ≠ (i::nat) + (1::nat)›*)
have "i < card Q ∧ j < card Q ∧ (i+1) < card Q"
using add_mono_thms_linordered_field(3) (*‹?i < ?j ∧ ?k ≤ ?l ⟹ ?i + ?k < ?j + ?l›*) asm(1,2) (*‹i ∈ {0..card Q - 2}› ‹(j::nat) ∈ {0::nat..card (Q::'a::type set) - (2::nat)}›*) assms (*‹(P::'a::type set) ∈ (𝒫::'a::type set set)› ‹Q ⊆ P› ‹[f::nat ⇒ 'a::type↝Q::'a::type set|a::'a::type..b::'a::type..c::'a::type]›*) ‹?N≥3› (*‹3 ≤ card Q›*) by auto
hence "f i ∈ Q ∧ f j ∈ Q ∧ f (i+1) ∈ Q"
using f_def (*‹[f↝Q|a..b..c]›*) unfolding chain_defs local_ordering_def
(*goal: ‹(f::nat ⇒ 'a) (i::nat) ∈ (Q::'a set) ∧ f (j::nat) ∈ Q ∧ f (i + (1::nat)) ∈ Q›*)
by (metis One_nat_def (*‹(1::nat) = Suc (0::nat)›*) Suc_diff_le (*‹(?n::nat) ≤ (?m::nat) ⟹ Suc ?m - ?n = Suc (?m - ?n)›*) Suc_eq_plus1 (*‹Suc (?n::nat) = ?n + (1::nat)›*) ‹3 ≤ card Q› add_Suc (*‹Suc (?m::nat) + (?n::nat) = Suc (?m + ?n)›*) card_1_singleton_iff (*‹(card (?A::?'a set) = Suc (0::nat)) = (∃x::?'a. ?A = {x})›*) card_gt_0_iff (*‹((0::nat) < card (?A::?'a set)) = (?A ≠ {} ∧ finite ?A)›*) card_insert_if (*‹finite (?A::?'a set) ⟹ card (insert (?x::?'a) ?A) = (if ?x ∈ ?A then card ?A else Suc (card ?A))›*) diff_Suc_1 (*‹Suc (?n::nat) - (1::nat) = ?n›*) diff_Suc_Suc (*‹Suc (?m::nat) - Suc (?n::nat) = ?m - ?n›*) less_natE (*‹⟦(?m::nat) < (?n::nat); ⋀q::nat. ?n = Suc (?m + q) ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) less_numeral_extra( (*‹(0::?'a) < (1::?'a)›*) 1) nat.discI (*‹(?nat::nat) = Suc (?x2.0::nat) ⟹ ?nat ≠ (0::nat)›*) numeral_3_eq_3 (*‹(3::nat) = Suc (Suc (Suc (0::nat)))›*))
hence "f i ∈ P ∧ f j ∈ P ∧ f (i+1) ∈ P"
using path_is_union (*‹⟦?P ∈ 𝒫; finite ?Q; card ?Q = ?N; ?Q ⊆ ?P; 3 ≤ ?N; ?a ∈ ?Q ∧ ?b ∈ ?Q ∧ ?c ∈ ?Q; [?f↝?Q|?a..?b..?c]; ?S = {s. ∃i<?N - 1. s = segment (?f i) (?f (i + 1))}; ?P1.0 = prolongation ?b ?a; ?P2.0 = prolongation ?b ?c⟧ ⟹ ?P = ⋃ ?S ∪ ?P1.0 ∪ ?P2.0 ∪ ?Q›*) assms (*‹(P::'a set) ∈ (𝒫::'a set set)› ‹Q ⊆ P› ‹[f::nat ⇒ 'a↝Q::'a set|a::'a..b::'a..c::'a]›*) by (simp add: subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*))
then consider "[f i; (f(i+1)); f j]" | "[f i; f j; (f(i+1))]" | "[(f(i+1)); f i; f j]"
(*goal: ‹⟦[f i;f (i + 1);f j] ⟹ thesis; [f i;f j;f (i + 1)] ⟹ thesis; [f (i + 1);f i;f j] ⟹ thesis⟧ ⟹ thesis›*)
using some_betw (*‹⟦?Q ∈ 𝒫; ?a ∈ ?Q; ?b ∈ ?Q; ?c ∈ ?Q; ?a ≠ ?b; ?a ≠ ?c; ?b ≠ ?c⟧ ⟹ [?a;?b;?c] ∨ [?b;?c;?a] ∨ [?c;?a;?b]›*) path_P (*‹P ∈ 𝒫›*) f_def (*‹[f↝Q|a..b..c]›*) indices_neq_imp_events_neq (*‹⟦[?f↝?X|?a..?b..?c]; ?i ≠ ?j; ?j < card ?X; ?i < card ?X⟧ ⟹ ?f ?i ≠ ?f ?j›*) ‹f i ≠ f j› (*‹f i ≠ f j›*) ‹i < card Q ∧ j < card Q ∧ i + 1 < card Q› (*‹i < card Q ∧ j < card Q ∧ i + 1 < card Q›*) ‹j ≠ i + 1› (*‹j ≠ i + 1›*) by (metis abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) less_add_one (*‹?a < ?a + 1›*) less_irrefl_nat (*‹?n < ?n ⟹ ?R›*))
thus False
proof (cases)
(*goals:
1. ‹[f i;f (i + 1);f j] ⟹ False›
2. ‹[f i;f j;f (i + 1)] ⟹ False›
3. ‹[f (i + 1);f i;f j] ⟹ False›*)
assume "[(f(i+1)); f i; f j]" (*‹[(f::nat ⇒ 'a) ((i::nat) + (1::nat));f i;f (j::nat)]›*)
then obtain e where "e∈?g i"
(*goal: ‹(⋀e. e ∈ segment (f i) (f (i + 1)) ⟹ thesis) ⟹ thesis›*)
using segment_nonempty (*‹⟦path ?ab ?a ?b; ⋀x. x ∈ segment ?a ?b ⟹ ?thesis⟧ ⟹ ?thesis›*) by (metis ‹f i ∈ P ∧ f j ∈ P ∧ f (i + 1) ∈ P› abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) path_P (*‹P ∈ 𝒫›*))
hence "[e; f j; (f(j+1))]"
using ‹[(f(i+1)); f i; f j]› (*‹[f (i + 1);f i;f j]›*) by (smt abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_acd_bcd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?b;?c;?d]›*) abc_only_cba (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]› ‹[?a;?b;?c] ⟹ ¬ [?a;?c;?b]› ‹[?a;?b;?c] ⟹ ¬ [?b;?c;?a]› ‹[?a;?b;?c] ⟹ ¬ [?c;?a;?b]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*) asm( (*‹segment (f i) (f (i + 1)) = segment (f j) (f (j + 1))›*) 3) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*))
moreover have "e∈?g j"
using ‹e ∈ ?g i› (*‹(e::'a) ∈ segment ((f::nat ⇒ 'a) (i::nat)) (f (i + (1::nat)))›*) asm(3) (*‹segment (f i) (f (i + 1)) = segment (f j) (f (j + 1))›*) by blast
ultimately show False
by (simp add: abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]›*) 1) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*))
next
(*goals:
1. ‹[f i;f (i + 1);f j] ⟹ False›
2. ‹[f i;f j;f (i + 1)] ⟹ False›*)
assume "[f i; f j; (f(i+1))]" (*‹[(f::nat ⇒ 'a) (i::nat);f (j::nat);f (i + (1::nat))]›*)
thus False
using abc_abc_neq[where b = "f j" and a = "f i" and c = "f(i+1)"] (*‹[f i;f j;f (i + 1)] ⟹ f i ≠ f j ∧ f i ≠ f (i + 1) ∧ f j ≠ f (i + 1)›*) asm(3) (*‹segment (f i) (f (i + 1)) = segment (f j) (f (j + 1))›*) seg_betw[where x = "f j"] (*‹(f j ∈ segment ?a ?b) = [?a;f j;?b]›*) using ends_notin_segment (*‹?a ∉ segment ?a ?b ∧ ?b ∉ segment ?a ?b›*) by blast
next
(*goal: ‹[(f::nat ⇒ 'a) (i::nat);f (i + (1::nat));f (j::nat)] ⟹ False›*)
assume "[f i; (f(i+1)); f j]" (*‹[(f::nat ⇒ 'a) (i::nat);f (i + (1::nat));f (j::nat)]›*)
then obtain e where "e∈?g i"
(*goal: ‹(⋀e. e ∈ segment (f i) (f (i + 1)) ⟹ thesis) ⟹ thesis›*)
using segment_nonempty (*‹⟦path ?ab ?a ?b; ⋀x. x ∈ segment ?a ?b ⟹ ?thesis⟧ ⟹ ?thesis›*) by (metis ‹f i ∈ P ∧ f j ∈ P ∧ f (i + 1) ∈ P› abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) path_P (*‹P ∈ 𝒫›*))
hence "[e; f j; (f(j+1))]"
proof (-)
(*goal: ‹e ∈ segment (f i) (f (i + 1)) ⟹ [e;f j;f (j + 1)]›*)
have "f (i+1) ≠ f j"
using ‹[f i; (f(i+1)); f j]› (*‹[f i;f (i + 1);f j]›*) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) by presburger
then show "?thesis"
(*goal: ‹[e;f j;f (j + 1)]›*)
using ‹e ∈ segment (f i) (f (i+1))› (*‹e ∈ segment (f i) (f (i + 1))›*) ‹[f i; (f(i+1)); f j]› (*‹[f i;f (i + 1);f j]›*) asm(3) (*‹segment (f i) (f (i + 1)) = segment (f j) (f (j + 1))›*) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*) by (metis (no_types) abc_abc_neq (*‹[?a;?b;?c] ⟹ ?a ≠ ?b ∧ ?a ≠ ?c ∧ ?b ≠ ?c›*) abc_acd_abd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?a;?b;?d]›*) abc_acd_bcd (*‹⟦[?a;?b;?c]; [?a;?c;?d]⟧ ⟹ [?b;?c;?d]›*) abc_sym (*‹[?a;?b;?c] ⟹ [?c;?b;?a]›*))
qed
moreover have "e∈?g j"
using ‹e ∈ ?g i› (*‹e ∈ segment (f i) (f (i + 1))›*) asm(3) (*‹segment (f i) (f (i + 1)) = segment (f j) (f (j + 1))›*) by blast
ultimately show False
by (simp add: abc_only_cba( (*‹[?a;?b;?c] ⟹ ¬ [?b;?a;?c]›*) 1) seg_betw (*‹(?x ∈ segment ?a ?b) = [?a;?x;?b]›*))
qed
qed
qed
qed
ultimately have "bij_betw ?g {0..?N-2} ?S"
using inj_on_imp_bij_betw (*‹inj_on ?f ?A ⟹ bij_betw ?f ?A (?f ` ?A)›*) by fastforce
thus "?thesis"
(*goal: ‹card {segment (f i) (f (i + 1)) |i. i < card Q - 1} = card Q - 1›*)
using assms(2) (*‹Q ⊆ P›*) bij_betw_same_card (*‹bij_betw ?f ?A ?B ⟹ card ?A = card ?B›*) numeral_2_eq_2 (*‹2 = Suc (Suc 0)›*) numeral_3_eq_3 (*‹3 = Suc (Suc (Suc 0))›*) ‹?N≥3› (*‹3 ≤ card Q›*) by (metis (no_types, lifting) One_nat_def (*‹1 = Suc 0›*) Suc_diff_Suc (*‹?n < ?m ⟹ Suc (?m - Suc ?n) = ?m - ?n›*) card_atLeastAtMost (*‹card {?l..?u} = Suc ?u - ?l›*) le_less_trans (*‹⟦?x ≤ ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*) minus_nat.diff_0 (*‹?m - 0 = ?m›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) not_numeral_le_zero (*‹¬ numeral ?n ≤ 0›*))
qed
theorem (*11*) segmentation_card:
assumes path_P: "P∈𝒫"
and Q_def: "Q⊆P"
and f_def: "[f↝Q|a..b]" (* This always exists given card Q > 2 *)
fixes P1 defines P1_def: "P1 ≡ prolongation b a"
fixes P2 defines P2_def: "P2 ≡ prolongation a b"
fixes S defines S_def: "S ≡ {segment (f i) (f (i+1)) | i. i<card Q-1}"
shows "P = ((⋃S) ∪ P1 ∪ P2 ∪ Q)"
(* The union of these segments and prolongations with the separating points is the path. *)
"card S = (card Q-1) ∧ (∀x∈S. is_segment x)"
(* There are N-1 segments. *)
(* There are two prolongations. *)
"disjoint (S∪{P1,P2})" "P1≠P2" "P1∉S" "P2∉S"
(* The prolongations and all the segments are disjoint. *)
proof (-)
(*goals:
1. ‹P = ⋃ S ∪ P1 ∪ P2 ∪ Q›
2. ‹card S = card Q - 1 ∧ (∀x∈S. is_segment x)›
3. ‹disjoint (S ∪ {P1, P2})›
4. ‹P1 ≠ P2›
5. ‹P1 ∉ S›
6. ‹P2 ∉ S›*)
let ?N = "card Q"
have "2 ≤ card Q"
using f_def (*‹[f↝Q|a .. b]›*) fin_chain_card_geq_2 (*‹[?f↝?X|?a .. ?b] ⟹ 2 ≤ card ?X›*) by blast
have seg_facts: "P = (⋃S ∪ P1 ∪ P2 ∪ Q)" "(∀x∈S. is_segment x)" "disjoint (S∪{P1,P2})" "P1≠P2" "P1∉S" "P2∉S"
using show_segmentation[OF path_P Q_def f_def] (*‹P = ⋃ {segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ prolongation b a ∪ prolongation a b ∪ Q› ‹∀x∈{segment (f i) (f (i + 1)) |i. i < card Q - 1}. is_segment x› ‹disjoint ({segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ {prolongation b a, prolongation a b})› ‹prolongation b a ≠ prolongation a b› ‹prolongation b a ∉ {segment (f i) (f (i + 1)) |i. i < card Q - 1}› ‹prolongation (a::'a) (b::'a) ∉ {segment ((f::nat ⇒ 'a) i) (f (i + (1::nat))) |i::nat. i < card (Q::'a set) - (1::nat)}›*) using P1_def (*‹P1 ≡ prolongation b a›*) P2_def (*‹P2::'a::type set ≡ prolongation (a::'a::type) (b::'a::type)›*) S_def (*‹S::'a::type set set ≡ {segment ((f::nat ⇒ 'a::type) i) (f (i + (1::nat))) |i::nat. i < card (Q::'a::type set) - (1::nat)}›*) apply -
(*goals:
1. ‹⟦P = ⋃ {segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ prolongation b a ∪ prolongation a b ∪ Q; ∀x∈{segment (f i) (f (i + 1)) |i. i < card Q - 1}. is_segment x; disjoint ({segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ {prolongation b a, prolongation a b}); prolongation b a ≠ prolongation a b; prolongation b a ∉ {segment (f i) (f (i + 1)) |i. i < card Q - 1}; prolongation a b ∉ {segment (f i) (f (i + 1)) |i. i < card Q - 1}; P1 ≡ prolongation b a; P2 ≡ prolongation a b; S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}⟧ ⟹ P = ⋃ S ∪ P1 ∪ P2 ∪ Q›
2. ‹⟦P = ⋃ {segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ prolongation b a ∪ prolongation a b ∪ Q; ∀x∈{segment (f i) (f (i + 1)) |i. i < card Q - 1}. is_segment x; disjoint ({segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ {prolongation b a, prolongation a b}); prolongation b a ≠ prolongation a b; prolongation b a ∉ {segment (f i) (f (i + 1)) |i. i < card Q - 1}; prolongation a b ∉ {segment (f i) (f (i + 1)) |i. i < card Q - 1}; P1 ≡ prolongation b a; P2 ≡ prolongation a b; S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}⟧ ⟹ ∀x∈S. is_segment x›
3. ‹⟦P = ⋃ {segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ prolongation b a ∪ prolongation a b ∪ Q; ∀x∈{segment (f i) (f (i + 1)) |i. i < card Q - 1}. is_segment x; disjoint ({segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ {prolongation b a, prolongation a b}); prolongation b a ≠ prolongation a b; prolongation b a ∉ {segment (f i) (f (i + 1)) |i. i < card Q - 1}; prolongation a b ∉ {segment (f i) (f (i + 1)) |i. i < card Q - 1}; P1 ≡ prolongation b a; P2 ≡ prolongation a b; S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}⟧ ⟹ disjoint (S ∪ {P1, P2})›
4. ‹⟦P = ⋃ {segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ prolongation b a ∪ prolongation a b ∪ Q; ∀x∈{segment (f i) (f (i + 1)) |i. i < card Q - 1}. is_segment x; disjoint ({segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ {prolongation b a, prolongation a b}); prolongation b a ≠ prolongation a b; prolongation b a ∉ {segment (f i) (f (i + 1)) |i. i < card Q - 1}; prolongation a b ∉ {segment (f i) (f (i + 1)) |i. i < card Q - 1}; P1 ≡ prolongation b a; P2 ≡ prolongation a b; S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}⟧ ⟹ P1 ≠ P2›
5. ‹⟦P = ⋃ {segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ prolongation b a ∪ prolongation a b ∪ Q; ∀x∈{segment (f i) (f (i + 1)) |i. i < card Q - 1}. is_segment x; disjoint ({segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ {prolongation b a, prolongation a b}); prolongation b a ≠ prolongation a b; prolongation b a ∉ {segment (f i) (f (i + 1)) |i. i < card Q - 1}; prolongation a b ∉ {segment (f i) (f (i + 1)) |i. i < card Q - 1}; P1 ≡ prolongation b a; P2 ≡ prolongation a b; S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}⟧ ⟹ P1 ∉ S›
6. ‹⟦P = ⋃ {segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ prolongation b a ∪ prolongation a b ∪ Q; ∀x∈{segment (f i) (f (i + 1)) |i. i < card Q - 1}. is_segment x; disjoint ({segment (f i) (f (i + 1)) |i. i < card Q - 1} ∪ {prolongation b a, prolongation a b}); prolongation b a ≠ prolongation a b; prolongation b a ∉ {segment (f i) (f (i + 1)) |i. i < card Q - 1}; prolongation a b ∉ {segment (f i) (f (i + 1)) |i. i < card Q - 1}; P1 ≡ prolongation b a; P2 ≡ prolongation a b; S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}⟧ ⟹ P2 ∉ S›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply fastforce
(*discuss goal 3*)
apply fastforce
(*discuss goal 4*)
apply fastforce
(*discuss goal 5*)
apply fastforce
(*discuss goal 6*)
apply fastforce
(*proven 6 subgoals*) .
show "P = ⋃S ∪ P1 ∪ P2 ∪ Q"
by (simp add: seg_facts( (*‹(P::'a set) = ⋃ (S::'a set set) ∪ (P1::'a set) ∪ (P2::'a set) ∪ (Q::'a set)›*) 1))
show "disjoint (S∪{P1,P2})" "P1≠P2" "P1∉S" "P2∉S"
using seg_facts(3-6) (*‹disjoint (S ∪ {P1, P2})› ‹(P1::'a set) ≠ (P2::'a set)› ‹P1 ∉ S› ‹P2 ∉ S›*) apply -
(*goals:
1. ‹⟦disjoint ((S::'a set set) ∪ {P1::'a set, P2::'a set}); P1 ≠ P2; P1 ∉ S; P2 ∉ S⟧ ⟹ disjoint (S ∪ {P1, P2})›
2. ‹⟦disjoint ((S::'a set set) ∪ {P1::'a set, P2::'a set}); P1 ≠ P2; P1 ∉ S; P2 ∉ S⟧ ⟹ P1 ≠ P2›
3. ‹⟦disjoint ((S::'a set set) ∪ {P1::'a set, P2::'a set}); P1 ≠ P2; P1 ∉ S; P2 ∉ S⟧ ⟹ P1 ∉ S›
4. ‹⟦disjoint ((S::'a set set) ∪ {P1::'a set, P2::'a set}); P1 ≠ P2; P1 ∉ S; P2 ∉ S⟧ ⟹ P2 ∉ S›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*discuss goal 3*)
apply blast
(*discuss goal 4*)
apply blast
(*proven 4 subgoals*) .
have "card S = (?N-1)"
proof (cases)
(*goals:
1. ‹?P ⟹ card S = card Q - 1›
2. ‹¬ ?P ⟹ card S = card Q - 1›*)
assume "?N=2" (*‹card (Q::'a set) = (2::nat)›*)
hence "card S = 1"
by (simp add: S_def (*‹S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}›*))
thus "?thesis"
(*goal: ‹card (S::'a set set) = card (Q::'a set) - (1::nat)›*)
by (simp add: ‹?N = 2›)
next
(*goal: ‹card Q ≠ 2 ⟹ card S = card Q - 1›*)
assume "?N≠2" (*‹card (Q::'a set) ≠ (2::nat)›*)
hence "?N≥3"
using ‹2 ≤ card Q› (*‹(2::nat) ≤ card (Q::'a set)›*) by linarith
then obtain c where "[f↝Q|a..c..b]"
(*goal: ‹(⋀c. [f↝Q|a..c..b] ⟹ thesis) ⟹ thesis›*)
using assms (*‹(P::'a set) ∈ (𝒫::'a set set)› ‹Q ⊆ P› ‹[f↝Q|a .. b]› ‹P1 ≡ prolongation b a› ‹P2 ≡ prolongation a b› ‹S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}›*) chain_defs (*‹short_ch ?X ≡ card ?X = 2 ∧ (∃P∈𝒫. ?X ⊆ P)› ‹local_long_ch_by_ord (?f::nat ⇒ 'a::type) (?X::'a::type set) ≡ (infinite ?X ∨ (3::nat) ≤ card ?X) ∧ local_ordering ?f betw ?X› ‹[?f↝?X] ≡ short_ch_by_ord ?f ?X ∨ local_long_ch_by_ord ?f ?X› ‹short_ch_by_ord ?f ?Q ≡ ?Q = {?f 0, ?f 1} ∧ (∃Q. path Q (?f 0) (?f 1))› ‹ch ?X ≡ short_ch ?X ∨ (∃f. local_long_ch_by_ord f ?X)› ‹infinite_chain ?f ?Q ≡ infinite ?Q ∧ [?f↝?Q]› ‹[?f::nat ⇒ 'a::type↝?Q::'a::type set|?x::'a::type ..] ≡ infinite_chain ?f ?Q ∧ ?f (0::nat) = ?x› ‹finite_chain ?f ?Q ≡ finite ?Q ∧ [?f↝?Q]› ‹[?f↝?Q|?x .. ?y] ≡ finite_chain ?f ?Q ∧ ?f 0 = ?x ∧ ?f (card ?Q - 1) = ?y› ‹[?f↝?Q|?x..?y..?z] ≡ [?f↝?Q|?x .. ?z] ∧ ?x ≠ ?y ∧ ?y ≠ ?z ∧ ?y ∈ ?Q›*) short_ch_card_2 (*‹[?f↝?X] ⟹ short_ch ?X = (card ?X = 2)›*) ‹2 ≤ card Q› (*‹2 ≤ card Q›*) ‹card Q ≠ 2› (*‹card Q ≠ 2›*) by (metis three_in_set3 (*‹⟦3 ≤ card ?X; ⋀x y z. ⟦x ∈ ?X; y ∈ ?X; z ∈ ?X; x ≠ y; x ≠ z; y ≠ z⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
show "?thesis"
(*goal: ‹card S = card Q - 1›*)
using number_of_segments[OF assms ( 1 , 2 ) ‹[f↝Q|a..c..b]›] (*‹card {segment (f i) (f (i + 1)) |i. i < card Q - 1} = card Q - 1›*) using S_def (*‹S ≡ {segment (f i) (f (i + 1)) |i. i < card Q - 1}›*) ‹card Q ≠ 2› (*‹card Q ≠ 2›*) by presburger
qed
thus "card S = card Q - 1 ∧ Ball S is_segment"
using seg_facts(2) (*‹∀x::'a set∈S::'a set set. is_segment x›*) by blast
qed
end (* context MinkowskiDense *)
(*
context MinkowskiSpacetime begin
interpretation is_dense: MinkowskiDense apply unfold_locales oops
end
*)
end | {
"path": "afp-2025-02-12/thys/Schutz_Spacetime/TemporalOrderOnPath.thy",
"repo": "afp-2025-02-12",
"sha": "07d4b3e0867fce18333423d5fb2c0daaae4d9858c260d40fb290252bc16a7d20"
} |
(* Author: Tobias Nipkow, 2007 *)
section‹Presburger arithmetic›
theory PresArith
imports QE "HOL-Library.ListVector"
begin
declare iprod_assoc[simp]
subsection‹Syntax›
datatype atom =
Le int "int list" | Dvd int int "int list" | NDvd int int "int list"
fun divisor :: "atom ⇒ int" where
"divisor (Le i ks) = 1" |
"divisor (Dvd d i ks) = d" |
"divisor (NDvd d i ks) = d"
fun neg⇩Z :: "atom ⇒ atom fm" where
"neg⇩Z (Le i ks) = Atom(Le (1-i) (-ks))" |
"neg⇩Z (Dvd d i ks) = Atom(NDvd d i ks)" |
"neg⇩Z (NDvd d i ks) = Atom(Dvd d i ks)"
fun hd_coeff :: "atom ⇒ int" where
"hd_coeff (Le i ks) = (case ks of [] ⇒ 0 | k#_ ⇒ k)" |
"hd_coeff (Dvd d i ks) = (case ks of [] ⇒ 0 | k#_ ⇒ k)" |
"hd_coeff (NDvd d i ks) = (case ks of [] ⇒ 0 | k#_ ⇒ k)"
fun decr⇩Z :: "atom ⇒ atom" where
"decr⇩Z (Le i ks) = Le i (tl ks)" |
"decr⇩Z (Dvd d i ks) = Dvd d i (tl ks)" |
"decr⇩Z (NDvd d i ks) = NDvd d i (tl ks)"
fun I⇩Z :: "atom ⇒ int list ⇒ bool" where
"I⇩Z (Le i ks) xs = (i ≤ ⟨ks,xs⟩)" |
"I⇩Z (Dvd d i ks) xs = (d dvd i+⟨ks,xs⟩)" |
"I⇩Z (NDvd d i ks) xs = (¬ d dvd i+⟨ks,xs⟩)"
definition "atoms₀ = ATOM.atoms₀ (λa. hd_coeff a ≠ 0)"
(* FIXME !!! (incl: display should hide params)*)
interpretation Z:
ATOM neg⇩Z "(λa. divisor a ≠ 0)" I⇩Z "(λa. hd_coeff a ≠ 0)" decr⇩Z
rewrites "ATOM.atoms₀ (λa. hd_coeff a ≠ 0) = atoms₀"
proof (goal_cases)
(*goals:
1. ‹ATOM neg⇩Z (λa::atom. divisor a ≠ (0::int)) I⇩Z (λa::atom. hd_coeff a ≠ (0::int)) decr⇩Z›
2. ‹ATOM.atoms₀ (λa::atom. hd_coeff a ≠ (0::int)) = atoms₀›*)
case 1 (*no hyothesis introduced yet*)
thus "?case"
(*goal: ‹ATOM neg⇩Z (λa. divisor a ≠ 0) I⇩Z (λa. hd_coeff a ≠ 0) decr⇩Z›*)
apply unfold_locales
(*goals:
1. ‹⋀a. nqfree (neg⇩Z a)›
2. ‹⋀a. divisor a ≠ 0 ⟹ ∀b∈atoms (neg⇩Z a). divisor b ≠ 0›
3. ‹⋀a xs. interpret I⇩Z (neg⇩Z a) xs = (¬ I⇩Z a xs)›
4. ‹⋀a x xs. ¬ hd_coeff a ≠ 0 ⟹ I⇩Z a (x # xs) = I⇩Z (decr⇩Z a) xs›
5. ‹⋀a. ⟦¬ hd_coeff a ≠ 0; divisor a ≠ 0⟧ ⟹ divisor (decr⇩Z a) ≠ 0›
discuss goal 1*)
apply (case_tac a)
(*goals:
1. ‹⋀a x11 x12. a = Le x11 x12 ⟹ nqfree (neg⇩Z a)›
2. ‹⋀a x21 x22 x23. a = Dvd x21 x22 x23 ⟹ nqfree (neg⇩Z a)›
3. ‹⋀a x31 x32 x33. a = NDvd x31 x32 x33 ⟹ nqfree (neg⇩Z a)›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*)
(*discuss goal 2*)
apply (case_tac a)
(*goals:
1. ‹⋀a x11 x12. ⟦divisor a ≠ 0; a = Le x11 x12⟧ ⟹ ∀b∈atoms (neg⇩Z a). divisor b ≠ 0›
2. ‹⋀a x21 x22 x23. ⟦divisor a ≠ 0; a = Dvd x21 x22 x23⟧ ⟹ ∀b∈atoms (neg⇩Z a). divisor b ≠ 0›
3. ‹⋀a x31 x32 x33. ⟦divisor a ≠ 0; a = NDvd x31 x32 x33⟧ ⟹ ∀b∈atoms (neg⇩Z a). divisor b ≠ 0›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*)
(*discuss goal 3*)
apply (case_tac a)
(*goals:
1. ‹⋀a xs x11 x12. a = Le x11 x12 ⟹ interpret I⇩Z (neg⇩Z a) xs = (¬ I⇩Z a xs)›
2. ‹⋀a xs x21 x22 x23. a = Dvd x21 x22 x23 ⟹ interpret I⇩Z (neg⇩Z a) xs = (¬ I⇩Z a xs)›
3. ‹⋀a xs x31 x32 x33. a = NDvd x31 x32 x33 ⟹ interpret I⇩Z (neg⇩Z a) xs = (¬ I⇩Z a xs)›
discuss goal 1*)
apply simp
(*top goal: ‹⋀a xs x11 x12. a = Le x11 x12 ⟹ interpret I⇩Z (neg⇩Z a) xs = (¬ I⇩Z a xs)› and 4 goals remain*)
apply arith
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*)
(*discuss goal 4*)
apply simp
(*top goal: ‹⋀(a::atom) (x::int) xs::int list. ¬ hd_coeff a ≠ (0::int) ⟹ I⇩Z a (x # xs) = I⇩Z (decr⇩Z a) xs› and 1 goal remains*)
apply (case_tac a)
(*goals:
1. ‹⋀a x xs x11 x12. ⟦hd_coeff a = 0; a = Le x11 x12⟧ ⟹ I⇩Z a (x # xs) = I⇩Z (decr⇩Z a) xs›
2. ‹⋀a x xs x21 x22 x23. ⟦hd_coeff a = 0; a = Dvd x21 x22 x23⟧ ⟹ I⇩Z a (x # xs) = I⇩Z (decr⇩Z a) xs›
3. ‹⋀a x xs x31 x32 x33. ⟦hd_coeff a = 0; a = NDvd x31 x32 x33⟧ ⟹ I⇩Z a (x # xs) = I⇩Z (decr⇩Z a) xs›
discuss goal 1*)
apply (simp add: split: (*‹(case (?a, ?b) of (c, d) ⇒ ?f c d) = ?f ?a ?b›*) list.splits (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))› ‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*))
(*discuss goal 2*)
apply (simp add: split: (*‹(case (?a::?'b, ?b::?'c) of (c::?'b, d::?'c) ⇒ (?f::?'b ⇒ ?'c ⇒ ?'a) c d) = ?f ?a ?b›*) list.splits (*‹(?P::?'b ⇒ bool) (case ?list::?'a list of [] ⇒ ?f1.0::?'b | (x::?'a) # (xa::?'a list) ⇒ (?f2.0::?'a ⇒ ?'a list ⇒ ?'b) x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀(x21::?'a) x22::?'a list. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))› ‹(?P::?'b ⇒ bool) (case ?list::?'a list of [] ⇒ ?f1.0::?'b | (x::?'a) # (xa::?'a list) ⇒ (?f2.0::?'a ⇒ ?'a list ⇒ ?'b) x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃(x21::?'a) x22::?'a list. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*))
(*discuss goal 3*)
apply (simp add: split: (*‹(case (?a, ?b) of (c, d) ⇒ ?f c d) = ?f ?a ?b›*) list.splits (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))› ‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*))
(*proven 3 subgoals*)
(*discuss goal 5*)
apply simp
(*goal: ‹⋀a. ⟦¬ hd_coeff a ≠ 0; divisor a ≠ 0⟧ ⟹ divisor (decr⇩Z a) ≠ 0›*)
apply (case_tac a)
(*goals:
1. ‹⋀a x11 x12. ⟦hd_coeff a = 0; divisor a ≠ 0; a = Le x11 x12⟧ ⟹ divisor (decr⇩Z a) ≠ 0›
2. ‹⋀a x21 x22 x23. ⟦hd_coeff a = 0; divisor a ≠ 0; a = Dvd x21 x22 x23⟧ ⟹ divisor (decr⇩Z a) ≠ 0›
3. ‹⋀a x31 x32 x33. ⟦hd_coeff a = 0; divisor a ≠ 0; a = NDvd x31 x32 x33⟧ ⟹ divisor (decr⇩Z a) ≠ 0›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*)
(*proven 5 subgoals*) .
next
(*goal: ‹ATOM.atoms₀ (λa. hd_coeff a ≠ 0) = atoms₀›*)
case 2 (*no hyothesis introduced yet*)
thus "?case"
(*goal: ‹ATOM.atoms₀ (λa::atom. hd_coeff a ≠ (0::int)) = atoms₀›*)
by (simp add:atoms₀_def (*‹atoms₀ = ATOM.atoms₀ (λa. hd_coeff a ≠ 0)›*))
qed
setup ‹Sign.revert_abbrev "" @{const_abbrev Z.I}›
setup ‹Sign.revert_abbrev "" @{const_abbrev Z.lift_dnf_qe}›
(* FIXME doesn't work*)
(* FIXME does not help
setup {* Sign.revert_abbrev "" @{const_abbrev Z.normal} *}
*)
abbreviation
"hd_coeff_is1 a ≡
(case a of Le _ _ ⇒ hd_coeff a ∈ {1,-1} | _ ⇒ hd_coeff a = 1)"
fun asubst :: "int ⇒ int list ⇒ atom ⇒ atom" where
"asubst i' ks' (Le i (k#ks)) = Le (i - k*i') (k *⇩s ks' + ks)" |
"asubst i' ks' (Dvd d i (k#ks)) = Dvd d (i + k*i') (k *⇩s ks' + ks)" |
"asubst i' ks' (NDvd d i (k#ks)) = NDvd d (i + k*i') (k *⇩s ks' + ks)" |
"asubst i' ks' a = a"
abbreviation subst :: "int ⇒ int list ⇒ atom fm ⇒ atom fm"
where "subst i ks ≡ map⇩f⇩m (asubst i ks)"
lemma IZ_asubst: "I⇩Z (asubst i ks a) xs = I⇩Z a ((i + ⟨ks,xs⟩) # xs)"
apply (cases a)
(*goals:
1. ‹⋀x11 x12. a = Le x11 x12 ⟹ I⇩Z (asubst i ks a) xs = I⇩Z a ((i + ⟨ks,xs⟩) # xs)›
2. ‹⋀x21 x22 x23. a = Dvd x21 x22 x23 ⟹ I⇩Z (asubst i ks a) xs = I⇩Z a ((i + ⟨ks,xs⟩) # xs)›
3. ‹⋀x31 x32 x33. a = NDvd x31 x32 x33 ⟹ I⇩Z (asubst i ks a) xs = I⇩Z a ((i + ⟨ks,xs⟩) # xs)›
discuss goal 1*)
apply (rename_tac list)
(*top goal: ‹⋀(x11::int) x12::int list. (a::atom) = Le x11 x12 ⟹ I⇩Z (asubst (i::int) (ks::int list) a) (xs::int list) = I⇩Z a ((i + ⟨ks,xs⟩) # xs)› and 2 goals remain*)
apply (case_tac list)
(*goals:
1. ‹⋀x11 list. ⟦a = Le x11 list; list = []⟧ ⟹ I⇩Z (asubst i ks a) xs = I⇩Z a ((i + ⟨ks,xs⟩) # xs)›
2. ‹⋀x11 list aa lista. ⟦a = Le x11 list; list = aa # lista⟧ ⟹ I⇩Z (asubst i ks a) xs = I⇩Z a ((i + ⟨ks,xs⟩) # xs)›
discuss goal 1*)
apply (simp add:algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 11 facts*) iprod_left_add_distrib (*‹⟨(?xs::?'a list) + (?ys::?'a list),?zs::?'a list⟩ = ⟨?xs,?zs⟩ + ⟨?ys,?zs⟩›*))
(*discuss goal 2*)
apply (simp add:algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*) iprod_left_add_distrib (*‹⟨?xs + ?ys,?zs⟩ = ⟨?xs,?zs⟩ + ⟨?ys,?zs⟩›*))
(*proven 2 subgoals*)
(*discuss goal 2*)
apply (simp add:algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*) iprod_left_add_distrib (*‹⟨?xs + ?ys,?zs⟩ = ⟨?xs,?zs⟩ + ⟨?ys,?zs⟩›*))
(*top goal: ‹⋀x21 x22 x23. a = Dvd x21 x22 x23 ⟹ I⇩Z (asubst i ks a) xs = I⇩Z a ((i + ⟨ks,xs⟩) # xs)› and 1 goal remains*)
apply (rename_tac list)
(*top goal: ‹⋀x21 x22 x23. a = Dvd x21 x22 x23 ⟹ I⇩Z (asubst i ks (Dvd x21 x22 x23)) xs = (x21 dvd x22 + ⟨x23,(i + ⟨ks,xs⟩) # xs⟩)› and 1 goal remains*)
apply (case_tac list)
(*goals:
1. ‹⋀x21 x22 list. ⟦a = Dvd x21 x22 list; list = []⟧ ⟹ I⇩Z (asubst i ks (Dvd x21 x22 list)) xs = (x21 dvd x22 + ⟨list,(i + ⟨ks,xs⟩) # xs⟩)›
2. ‹⋀x21 x22 list aa lista. ⟦a = Dvd x21 x22 list; list = aa # lista⟧ ⟹ I⇩Z (asubst i ks (Dvd x21 x22 list)) xs = (x21 dvd x22 + ⟨list,(i + ⟨ks,xs⟩) # xs⟩)›
discuss goal 1*)
apply (simp add:algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*) iprod_left_add_distrib (*‹⟨?xs + ?ys,?zs⟩ = ⟨?xs,?zs⟩ + ⟨?ys,?zs⟩›*))
(*discuss goal 2*)
apply (simp add:algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*) iprod_left_add_distrib (*‹⟨?xs + ?ys,?zs⟩ = ⟨?xs,?zs⟩ + ⟨?ys,?zs⟩›*))
(*proven 2 subgoals*)
(*discuss goal 3*)
apply (simp add:algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*) iprod_left_add_distrib (*‹⟨?xs + ?ys,?zs⟩ = ⟨?xs,?zs⟩ + ⟨?ys,?zs⟩›*))
(*goal: ‹⋀x31 x32 x33. a = NDvd x31 x32 x33 ⟹ I⇩Z (asubst i ks a) xs = I⇩Z a ((i + ⟨ks,xs⟩) # xs)›*)
apply (rename_tac list)
(*goal: ‹⋀x31 x32 x33. a = NDvd x31 x32 x33 ⟹ I⇩Z (asubst i ks (NDvd x31 x32 x33)) xs = (¬ x31 dvd x32 + ⟨x33,(i + ⟨ks,xs⟩) # xs⟩)›*)
apply (case_tac list)
(*goals:
1. ‹⋀x31 x32 list. ⟦a = NDvd x31 x32 list; list = []⟧ ⟹ I⇩Z (asubst i ks (NDvd x31 x32 list)) xs = (¬ x31 dvd x32 + ⟨list,(i + ⟨ks,xs⟩) # xs⟩)›
2. ‹⋀x31 x32 list aa lista. ⟦a = NDvd x31 x32 list; list = aa # lista⟧ ⟹ I⇩Z (asubst i ks (NDvd x31 x32 list)) xs = (¬ x31 dvd x32 + ⟨list,(i + ⟨ks,xs⟩) # xs⟩)›
discuss goal 1*)
apply (simp add:algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*) iprod_left_add_distrib (*‹⟨?xs + ?ys,?zs⟩ = ⟨?xs,?zs⟩ + ⟨?ys,?zs⟩›*))
(*discuss goal 2*)
apply (simp add:algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 11 facts*) iprod_left_add_distrib (*‹⟨(?xs::?'a list) + (?ys::?'a list),?zs::?'a list⟩ = ⟨?xs,?zs⟩ + ⟨?ys,?zs⟩›*))
(*proven 2 subgoals*)
(*proven 3 subgoals*) .
lemma I_subst:
"qfree φ ⟹ Z.I φ ((i + ⟨ks,xs⟩) # xs) = Z.I (subst i ks φ) xs"
apply (induct φ)
(*goals:
1. ‹qfree TrueF ⟹ Z.I TrueF ((i + ⟨ks,xs⟩) # xs) = Z.I (subst i ks TrueF) xs›
2. ‹qfree FalseF ⟹ Z.I FalseF ((i + ⟨ks,xs⟩) # xs) = Z.I (subst i ks FalseF) xs›
3. ‹⋀x. qfree (Atom x) ⟹ Z.I (Atom x) ((i + ⟨ks,xs⟩) # xs) = Z.I (subst i ks (Atom x)) xs›
4. ‹⋀φ1 φ2. ⟦qfree φ1 ⟹ Z.I φ1 ((i + ⟨ks,xs⟩) # xs) = Z.I (subst i ks φ1) xs; qfree φ2 ⟹ Z.I φ2 ((i + ⟨ks,xs⟩) # xs) = Z.I (subst i ks φ2) xs; qfree (And φ1 φ2)⟧ ⟹ Z.I (And φ1 φ2) ((i + ⟨ks,xs⟩) # xs) = Z.I (subst i ks (And φ1 φ2)) xs›
5. ‹⋀φ1 φ2. ⟦qfree φ1 ⟹ Z.I φ1 ((i + ⟨ks,xs⟩) # xs) = Z.I (subst i ks φ1) xs; qfree φ2 ⟹ Z.I φ2 ((i + ⟨ks,xs⟩) # xs) = Z.I (subst i ks φ2) xs; qfree (Or φ1 φ2)⟧ ⟹ Z.I (Or φ1 φ2) ((i + ⟨ks,xs⟩) # xs) = Z.I (subst i ks (Or φ1 φ2)) xs›
6. ‹⋀φ. ⟦qfree φ ⟹ Z.I φ ((i + ⟨ks,xs⟩) # xs) = Z.I (subst i ks φ) xs; qfree (Neg φ)⟧ ⟹ Z.I (Neg φ) ((i + ⟨ks,xs⟩) # xs) = Z.I (subst i ks (Neg φ)) xs›
7. ‹⋀φ. ⟦qfree φ ⟹ Z.I φ ((i + ⟨ks,xs⟩) # xs) = Z.I (subst i ks φ) xs; qfree (ExQ φ)⟧ ⟹ Z.I (ExQ φ) ((i + ⟨ks,xs⟩) # xs) = Z.I (subst i ks (ExQ φ)) xs›
discuss goal 1*)
apply (simp add:IZ_asubst (*‹I⇩Z (asubst ?i ?ks ?a) ?xs = I⇩Z ?a ((?i + ⟨?ks,?xs⟩) # ?xs)›*))
(*discuss goal 2*)
apply (simp add:IZ_asubst (*‹I⇩Z (asubst ?i ?ks ?a) ?xs = I⇩Z ?a ((?i + ⟨?ks,?xs⟩) # ?xs)›*))
(*discuss goal 3*)
apply (simp add:IZ_asubst (*‹I⇩Z (asubst ?i ?ks ?a) ?xs = I⇩Z ?a ((?i + ⟨?ks,?xs⟩) # ?xs)›*))
(*discuss goal 4*)
apply (simp add:IZ_asubst (*‹I⇩Z (asubst (?i::int) (?ks::int list) (?a::atom)) (?xs::int list) = I⇩Z ?a ((?i + ⟨?ks,?xs⟩) # ?xs)›*))
(*discuss goal 5*)
apply (simp add:IZ_asubst (*‹I⇩Z (asubst ?i ?ks ?a) ?xs = I⇩Z ?a ((?i + ⟨?ks,?xs⟩) # ?xs)›*))
(*discuss goal 6*)
apply (simp add:IZ_asubst (*‹I⇩Z (asubst (?i::int) (?ks::int list) (?a::atom)) (?xs::int list) = I⇩Z ?a ((?i + ⟨?ks,?xs⟩) # ?xs)›*))
(*discuss goal 7*)
apply (simp add:IZ_asubst (*‹I⇩Z (asubst ?i ?ks ?a) ?xs = I⇩Z ?a ((?i + ⟨?ks,?xs⟩) # ?xs)›*))
(*proven 7 subgoals*) .
lemma divisor_asubst[simp]: "divisor (asubst i ks a) = divisor a"
apply (induct i ks a rule:asubst.induct (*‹⟦⋀i' ks' i k ks. ?P i' ks' (Le i (k # ks)); ⋀i' ks' d i k ks. ?P i' ks' (Dvd d i (k # ks)); ⋀i' ks' d i k ks. ?P i' ks' (NDvd d i (k # ks)); ⋀i' ks' v. ?P i' ks' (Le v []); ⋀i' ks' v va. ?P i' ks' (Dvd v va []); ⋀i' ks' v va. ?P i' ks' (NDvd v va [])⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*))
(*goals:
1. ‹⋀i' ks' i k ks. divisor (asubst i' ks' (Le i (k # ks))) = divisor (Le i (k # ks))›
2. ‹⋀i' ks' d i k ks. divisor (asubst i' ks' (Dvd d i (k # ks))) = divisor (Dvd d i (k # ks))›
3. ‹⋀i' ks' d i k ks. divisor (asubst i' ks' (NDvd d i (k # ks))) = divisor (NDvd d i (k # ks))›
4. ‹⋀i' ks' v. divisor (asubst i' ks' (Le v [])) = divisor (Le v [])›
5. ‹⋀i' ks' v va. divisor (asubst i' ks' (Dvd v va [])) = divisor (Dvd v va [])›
6. ‹⋀i' ks' v va. divisor (asubst i' ks' (NDvd v va [])) = divisor (NDvd v va [])›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*discuss goal 6*)
apply ((auto)[1])
(*proven 6 subgoals*) .
definition "lbounds as = [(i,ks). Le i (k#ks) ← as, k>0]"
definition "ubounds as = [(i,ks). Le i (k#ks) ← as, k<0]"
lemma set_lbounds:
"set(lbounds as) = {(i,ks)|i k ks. Le i (k#ks) ∈ set as ∧ k>0}"
by (auto simp: lbounds_def (*‹lbounds (?as::atom list) = concat (map (λx::atom. case x of Le (i::int) [] ⇒ [] | Le (i::int) ((k::int) # (ks::int list)) ⇒ if (0::int) < k then [(i, ks)] else [] | _ ⇒ []) ?as)›*) split:list.splits (*‹(?P::?'b ⇒ bool) (case ?list::?'a list of [] ⇒ ?f1.0::?'b | (x::?'a) # (xa::?'a list) ⇒ (?f2.0::?'a ⇒ ?'a list ⇒ ?'b) x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀(x21::?'a) x22::?'a list. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))› ‹(?P::?'b ⇒ bool) (case ?list::?'a list of [] ⇒ ?f1.0::?'b | (x::?'a) # (xa::?'a list) ⇒ (?f2.0::?'a ⇒ ?'a list ⇒ ?'b) x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃(x21::?'a) x22::?'a list. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*) atom.splits (*‹(?P::?'a ⇒ bool) (case ?atom::atom of Le (x::int) (xa::int list) ⇒ (?f1.0::int ⇒ int list ⇒ ?'a) x xa | Dvd (x::int) (xa::int) (xb::int list) ⇒ (?f2.0::int ⇒ int ⇒ int list ⇒ ?'a) x xa xb | NDvd (x::int) (xa::int) (xb::int list) ⇒ (?f3.0::int ⇒ int ⇒ int list ⇒ ?'a) x xa xb) = ((∀(x11::int) x12::int list. ?atom = Le x11 x12 ⟶ ?P (?f1.0 x11 x12)) ∧ (∀(x21::int) (x22::int) x23::int list. ?atom = Dvd x21 x22 x23 ⟶ ?P (?f2.0 x21 x22 x23)) ∧ (∀(x31::int) (x32::int) x33::int list. ?atom = NDvd x31 x32 x33 ⟶ ?P (?f3.0 x31 x32 x33)))› ‹(?P::?'a ⇒ bool) (case ?atom::atom of Le (x::int) (xa::int list) ⇒ (?f1.0::int ⇒ int list ⇒ ?'a) x xa | Dvd (x::int) (xa::int) (xb::int list) ⇒ (?f2.0::int ⇒ int ⇒ int list ⇒ ?'a) x xa xb | NDvd (x::int) (xa::int) (xb::int list) ⇒ (?f3.0::int ⇒ int ⇒ int list ⇒ ?'a) x xa xb) = (¬ ((∃(x11::int) x12::int list. ?atom = Le x11 x12 ∧ ¬ ?P (?f1.0 x11 x12)) ∨ (∃(x21::int) (x22::int) x23::int list. ?atom = Dvd x21 x22 x23 ∧ ¬ ?P (?f2.0 x21 x22 x23)) ∨ (∃(x31::int) (x32::int) x33::int list. ?atom = NDvd x31 x32 x33 ∧ ¬ ?P (?f3.0 x31 x32 x33))))›*) if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
lemma set_ubounds:
"set(ubounds as) = {(i,ks)|i k ks. Le i (k#ks) ∈ set as ∧ k<0}"
by (auto simp: ubounds_def (*‹ubounds ?as = concat (map (λx. case x of Le i [] ⇒ [] | Le i (k # ks) ⇒ if k < 0 then [(i, ks)] else [] | _ ⇒ []) ?as)›*) split:list.splits (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))› ‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*) atom.splits (*‹?P (case ?atom of Le x xa ⇒ ?f1.0 x xa | Dvd x xa xb ⇒ ?f2.0 x xa xb | NDvd x xa xb ⇒ ?f3.0 x xa xb) = ((∀x11 x12. ?atom = Le x11 x12 ⟶ ?P (?f1.0 x11 x12)) ∧ (∀x21 x22 x23. ?atom = Dvd x21 x22 x23 ⟶ ?P (?f2.0 x21 x22 x23)) ∧ (∀x31 x32 x33. ?atom = NDvd x31 x32 x33 ⟶ ?P (?f3.0 x31 x32 x33)))› ‹?P (case ?atom of Le x xa ⇒ ?f1.0 x xa | Dvd x xa xb ⇒ ?f2.0 x xa xb | NDvd x xa xb ⇒ ?f3.0 x xa xb) = (¬ ((∃x11 x12. ?atom = Le x11 x12 ∧ ¬ ?P (?f1.0 x11 x12)) ∨ (∃x21 x22 x23. ?atom = Dvd x21 x22 x23 ∧ ¬ ?P (?f2.0 x21 x22 x23)) ∨ (∃x31 x32 x33. ?atom = NDvd x31 x32 x33 ∧ ¬ ?P (?f3.0 x31 x32 x33))))›*) if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
lemma lbounds_append[simp]: "lbounds(as @ bs) = lbounds as @ lbounds bs"
by (simp add:lbounds_def (*‹lbounds ?as = concat (map (λx. case x of Le i [] ⇒ [] | Le i (k # ks) ⇒ if 0 < k then [(i, ks)] else [] | _ ⇒ []) ?as)›*))
subsection‹LCM and lemmas›
fun zlcms :: "int list ⇒ int" where
"zlcms [] = 1" |
"zlcms (i#is) = lcm i (zlcms is)"
lemma dvd_zlcms: "i ∈ set is ⟹ i dvd zlcms is"
apply (induct "is")
(*goals:
1. ‹i ∈ set [] ⟹ i dvd zlcms []›
2. ‹⋀a is. ⟦i ∈ set is ⟹ i dvd zlcms is; i ∈ set (a # is)⟧ ⟹ i dvd zlcms (a # is)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma zlcms_pos: "∀i ∈ set is. i≠0 ⟹ zlcms is > 0"
apply (induct "is")
(*goals:
1. ‹∀i∈set []. i ≠ 0 ⟹ 0 < zlcms []›
2. ‹⋀a is. ⟦∀i∈set is. i ≠ 0 ⟹ 0 < zlcms is; ∀i∈set (a # is). i ≠ 0⟧ ⟹ 0 < zlcms (a # is)›
discuss goal 1*)
apply ((auto simp:lcm_pos_int (*‹⟦(?m::int) ≠ (0::int); (?n::int) ≠ (0::int)⟧ ⟹ (0::int) < lcm ?m ?n›*))[1])
(*discuss goal 2*)
apply ((auto simp:lcm_pos_int (*‹⟦(?m::int) ≠ (0::int); (?n::int) ≠ (0::int)⟧ ⟹ (0::int) < lcm ?m ?n›*))[1])
(*proven 2 subgoals*) .
lemma zlcms0_iff[simp]: "(zlcms is = 0) = (0 ∈ set is)"
by (metis mod_by_0 (*‹?a mod 0 = ?a›*) dvd_eq_mod_eq_0 (*‹(?a dvd ?b) = (?b mod ?a = 0)›*) dvd_zlcms (*‹?i ∈ set ?is ⟹ ?i dvd zlcms ?is›*) zlcms_pos (*‹∀i∈set ?is. i ≠ 0 ⟹ 0 < zlcms ?is›*) less_le (*‹(?x < ?y) = (?x ≤ ?y ∧ ?x ≠ ?y)›*))
lemma elem_le_zlcms: "∀i ∈ set is. i ≠ 0 ⟹ i ∈ set is ⟹ i ≤ zlcms is"
by (metis dvd_zlcms (*‹?i ∈ set ?is ⟹ ?i dvd zlcms ?is›*) zdvd_imp_le (*‹⟦?z dvd ?n; 0 < ?n⟧ ⟹ ?z ≤ ?n›*) zlcms_pos (*‹∀i∈set ?is. i ≠ 0 ⟹ 0 < zlcms ?is›*))
subsection‹Setting coeffiencients to 1 or -1›
fun hd_coeff1 :: "int ⇒ atom ⇒ atom" where
"hd_coeff1 m (Le i (k#ks)) =
(if k=0 then Le i (k#ks)
else let m' = m div (abs k) in Le (m'*i) (sgn k # (m' *⇩s ks)))" |
"hd_coeff1 m (Dvd d i (k#ks)) =
(if k=0 then Dvd d i (k#ks)
else let m' = m div k in Dvd (m'*d) (m'*i) (1 # (m' *⇩s ks)))" |
"hd_coeff1 m (NDvd d i (k#ks)) =
(if k=0 then NDvd d i (k#ks)
else let m' = m div k in NDvd (m'*d) (m'*i) (1 # (m' *⇩s ks)))" |
"hd_coeff1 _ a = a"
text‹The def of @{const hd_coeff1} on @{const Dvd} and @{const NDvd} is
different from the @{const Le} because it allows the resulting head
coefficient to be 1 rather than 1 or -1. We show that the other version has
the same semantics:›
lemma "⟦ k ≠ 0; k dvd m ⟧ ⟹
I⇩Z (hd_coeff1 m (Dvd d i (k#ks))) (x#e) = (let m' = m div (abs k) in
I⇩Z (Dvd (m'*d) (m'*i) (sgn k # (m' *⇩s ks))) (x#e))"
apply (auto simp:algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*) abs_if (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*) sgn_if (*‹sgn ?x = (if ?x = 0 then 0 else if 0 < ?x then 1 else - 1)›*))
(*goals:
1. ‹⟦(k::int) ≠ (0::int); k dvd (m::int); ¬ (0::int) < k; (d::int) * (m div k) dvd (x::int) + ((i::int) * (m div k) + ⟨ks::int list,e::int list⟩ * (m div k))⟧ ⟹ d * (m div - k) dvd i * (m div - k) + ⟨ks,e⟩ * (m div - k) - x›
2. ‹⟦(k::int) ≠ (0::int); k dvd (m::int); ¬ (0::int) < k; (d::int) * (m div - k) dvd (i::int) * (m div - k) + ⟨ks::int list,e::int list⟩ * (m div - k) - (x::int)⟧ ⟹ d * (m div k) dvd x + (i * (m div k) + ⟨ks,e⟩ * (m div k))›
discuss goal 1*)
apply (simp add: zdiv_zminus2_eq_if (*‹?b ≠ 0 ⟹ ?a div - ?b = (if ?a mod ?b = 0 then - (?a div ?b) else - (?a div ?b) - 1)›*) dvd_eq_mod_eq_0[THEN iffD1] (*‹?a1 dvd ?b1 ⟹ ?b1 mod ?a1 = 0›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*))
(*top goal: ‹⟦k ≠ 0; k dvd m; ¬ 0 < k; d * (m div k) dvd x + (i * (m div k) + ⟨ks,e⟩ * (m div k))⟧ ⟹ d * (m div - k) dvd i * (m div - k) + ⟨ks,e⟩ * (m div - k) - x› and 1 goal remains*)
apply (metis diff_conv_add_uminus (*‹?a - ?b = ?a + - ?b›*) add.left_commute (*‹?b + (?a + ?c) = ?a + (?b + ?c)›*) dvd_minus_iff (*‹(?x dvd - ?y) = (?x dvd ?y)›*) minus_add_distrib (*‹- (?a + ?b) = - ?a + - ?b›*))
(*discuss goal 2*)
apply (simp add: zdiv_zminus2_eq_if (*‹?b ≠ 0 ⟹ ?a div - ?b = (if ?a mod ?b = 0 then - (?a div ?b) else - (?a div ?b) - 1)›*) dvd_eq_mod_eq_0[THEN iffD1] (*‹?a1 dvd ?b1 ⟹ ?b1 mod ?a1 = 0›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*))
(*goal: ‹⟦k ≠ 0; k dvd m; ¬ 0 < k; d * (m div - k) dvd i * (m div - k) + ⟨ks,e⟩ * (m div - k) - x⟧ ⟹ d * (m div k) dvd x + (i * (m div k) + ⟨ks,e⟩ * (m div k))›*)
apply (metis diff_conv_add_uminus (*‹?a - ?b = ?a + - ?b›*) add.left_commute (*‹?b + (?a + ?c) = ?a + (?b + ?c)›*) dvd_minus_iff (*‹(?x dvd - ?y) = (?x dvd ?y)›*) minus_add_distrib (*‹- (?a + ?b) = - ?a + - ?b›*))
(*proven 2 subgoals*) .
lemma I_hd_coeff1_mult_a: assumes "m>0"
shows "hd_coeff a dvd m | hd_coeff a = 0 ⟹ I⇩Z (hd_coeff1 m a) (m*x#xs) = I⇩Z a (x#xs)"
proof (induct a)
(*goals:
1. ‹⋀x1 x2. hd_coeff (Le x1 x2) dvd m ∨ hd_coeff (Le x1 x2) = 0 ⟹ I⇩Z (hd_coeff1 m (Le x1 x2)) (m * x # xs) = I⇩Z (Le x1 x2) (x # xs)›
2. ‹⋀x1 x2 x3. hd_coeff (Dvd x1 x2 x3) dvd m ∨ hd_coeff (Dvd x1 x2 x3) = 0 ⟹ I⇩Z (hd_coeff1 m (Dvd x1 x2 x3)) (m * x # xs) = I⇩Z (Dvd x1 x2 x3) (x # xs)›
3. ‹⋀x1 x2 x3. hd_coeff (NDvd x1 x2 x3) dvd m ∨ hd_coeff (NDvd x1 x2 x3) = 0 ⟹ I⇩Z (hd_coeff1 m (NDvd x1 x2 x3)) (m * x # xs) = I⇩Z (NDvd x1 x2 x3) (x # xs)›*)
case [simp]: (Le i ks) (*‹hd_coeff (Le i ks) dvd m ∨ hd_coeff (Le i ks) = 0›*)
show "?case"
(*goal: ‹I⇩Z (hd_coeff1 m (Le i ks)) (m * x # xs) = I⇩Z (Le i ks) (x # xs)›*)
proof (cases ks)
(*goals:
1. ‹ks = [] ⟹ I⇩Z (hd_coeff1 m (Le i ks)) (m * x # xs) = I⇩Z (Le i ks) (x # xs)›
2. ‹⋀a list. ks = a # list ⟹ I⇩Z (hd_coeff1 m (Le i ks)) (m * x # xs) = I⇩Z (Le i ks) (x # xs)›*)
case Nil (*‹ks = []›*)
thus "?thesis"
(*goal: ‹I⇩Z (hd_coeff1 m (Le i ks)) (m * x # xs) = I⇩Z (Le i ks) (x # xs)›*)
by simp
next
(*goal: ‹⋀a list. ks = a # list ⟹ I⇩Z (hd_coeff1 m (Le i ks)) (m * x # xs) = I⇩Z (Le i ks) (x # xs)›*)
case [simp]: (Cons k ks') (*‹ks = k # ks'›*)
show "?thesis"
(*goal: ‹I⇩Z (hd_coeff1 (m::int) (Le (i::int) (ks::int list))) (m * (x::int) # (xs::int list)) = I⇩Z (Le i ks) (x # xs)›*)
proof (cases)
(*goals:
1. ‹?P ⟹ I⇩Z (hd_coeff1 m (Le i ks)) (m * x # xs) = I⇩Z (Le i ks) (x # xs)›
2. ‹¬ ?P ⟹ I⇩Z (hd_coeff1 m (Le i ks)) (m * x # xs) = I⇩Z (Le i ks) (x # xs)›*)
assume "k=0" (*‹(k::int) = (0::int)›*)
thus "?thesis"
(*goal: ‹I⇩Z (hd_coeff1 (m::int) (Le (i::int) (ks::int list))) (m * (x::int) # (xs::int list)) = I⇩Z (Le i ks) (x # xs)›*)
by simp
next
(*goal: ‹(k::int) ≠ (0::int) ⟹ I⇩Z (hd_coeff1 (m::int) (Le (i::int) (ks::int list))) (m * (x::int) # (xs::int list)) = I⇩Z (Le i ks) (x # xs)›*)
assume "k≠0" (*‹(k::int) ≠ (0::int)›*)
with Le (*‹hd_coeff (Le i ks) dvd m ∨ hd_coeff (Le i ks) = 0›*) have "¦k¦ dvd m"
by simp
let ?m' = "m div ¦k¦"
have "?m' > 0"
using ‹¦k¦ dvd m› (*‹¦k¦ dvd m›*) pos_imp_zdiv_pos_iff (*‹0 < ?k ⟹ (0 < ?i div ?k) = (?k ≤ ?i)›*) ‹m>0› (*‹0 < m›*) ‹k≠0› (*‹k ≠ 0›*) by (simp add:zdvd_imp_le (*‹⟦?z dvd ?n; 0 < ?n⟧ ⟹ ?z ≤ ?n›*))
have 1: "k*(x*?m') = sgn k * x * m"
proof (-)
(*goal: ‹k * (x * (m div ¦k¦)) = sgn k * x * m›*)
have "k*(x*?m') = (sgn k * abs k) * (x * ?m')"
by (simp only: mult_sgn_abs (*‹sgn (?x::?'a) * ¦?x¦ = ?x›*))
also (*calculation: ‹(k::int) * ((x::int) * ((m::int) div ¦k¦)) = sgn k * ¦k¦ * (x * (m div ¦k¦))›*) have "… = sgn k * x * (abs k * ?m')"
by simp
also (*calculation: ‹(k::int) * ((x::int) * ((m::int) div ¦k¦)) = sgn k * x * (¦k¦ * (m div ¦k¦))›*) have "… = sgn k * x * m"
using dvd_mult_div_cancel[OF ‹¦k¦ dvd m›] (*‹¦k¦ * (m div ¦k¦) = m›*) by (simp add:algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 11 facts*))
finally (*calculation: ‹k * (x * (m div ¦k¦)) = sgn k * x * m›*) show "?thesis"
(*goal: ‹k * (x * (m div ¦k¦)) = sgn k * x * m›*) .
qed
have "I⇩Z (hd_coeff1 m (Le i ks)) (m*x#xs) ⟷
(i*?m' ≤ sgn k * m*x + ?m' * ⟨ks',xs⟩)"
using ‹k≠0› (*‹k ≠ 0›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*))
also (*calculation: ‹I⇩Z (hd_coeff1 (m::int) (Le (i::int) (ks::int list))) (m * (x::int) # (xs::int list)) = (i * (m div ¦k::int¦) ≤ sgn k * m * x + m div ¦k¦ * ⟨ks'::int list,xs⟩)›*) have "… ⟷ ?m'*i ≤ ?m' * (k*x + ⟨ks',xs⟩)"
using "1" (*‹k * (x * (m div ¦k¦)) = sgn k * x * m›*) by (simp (no_asm_simp) add:algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*))
also (*calculation: ‹I⇩Z (hd_coeff1 m (Le i ks)) (m * x # xs) = (m div ¦k¦ * i ≤ m div ¦k¦ * (k * x + ⟨ks',xs⟩))›*) have "… ⟷ i ≤ k*x + ⟨ks',xs⟩"
using ‹?m'>0› (*‹0 < m div ¦k¦›*) by simp
finally (*calculation: ‹I⇩Z (hd_coeff1 m (Le i ks)) (m * x # xs) = (i ≤ k * x + ⟨ks',xs⟩)›*) show "?thesis"
(*goal: ‹I⇩Z (hd_coeff1 m (Le i ks)) (m * x # xs) = I⇩Z (Le i ks) (x # xs)›*)
by simp
qed
qed
next
(*goals:
1. ‹⋀x1 x2 x3. hd_coeff (Dvd x1 x2 x3) dvd m ∨ hd_coeff (Dvd x1 x2 x3) = 0 ⟹ I⇩Z (hd_coeff1 m (Dvd x1 x2 x3)) (m * x # xs) = I⇩Z (Dvd x1 x2 x3) (x # xs)›
2. ‹⋀x1 x2 x3. hd_coeff (NDvd x1 x2 x3) dvd m ∨ hd_coeff (NDvd x1 x2 x3) = 0 ⟹ I⇩Z (hd_coeff1 m (NDvd x1 x2 x3)) (m * x # xs) = I⇩Z (NDvd x1 x2 x3) (x # xs)›*)
case [simp]: (Dvd d i ks) (*‹hd_coeff (Dvd (d::int) (i::int) (ks::int list)) dvd (m::int) ∨ hd_coeff (Dvd d i ks) = (0::int)›*)
show "?case"
(*goal: ‹I⇩Z (hd_coeff1 m (Dvd d i ks)) (m * x # xs) = I⇩Z (Dvd d i ks) (x # xs)›*)
proof (cases ks)
(*goals:
1. ‹ks = [] ⟹ I⇩Z (hd_coeff1 m (Dvd d i ks)) (m * x # xs) = I⇩Z (Dvd d i ks) (x # xs)›
2. ‹⋀a list. ks = a # list ⟹ I⇩Z (hd_coeff1 m (Dvd d i ks)) (m * x # xs) = I⇩Z (Dvd d i ks) (x # xs)›*)
case Nil (*‹(ks::int list) = []›*)
thus "?thesis"
(*goal: ‹I⇩Z (hd_coeff1 (m::int) (Dvd (d::int) (i::int) (ks::int list))) (m * (x::int) # (xs::int list)) = I⇩Z (Dvd d i ks) (x # xs)›*)
by simp
next
(*goal: ‹⋀(a::int) list::int list. (ks::int list) = a # list ⟹ I⇩Z (hd_coeff1 (m::int) (Dvd (d::int) (i::int) ks)) (m * (x::int) # (xs::int list)) = I⇩Z (Dvd d i ks) (x # xs)›*)
case [simp]: (Cons k ks') (*‹(ks::int list) = (k::int) # (ks'::int list)›*)
show "?thesis"
(*goal: ‹I⇩Z (hd_coeff1 m (Dvd d i ks)) (m * x # xs) = I⇩Z (Dvd d i ks) (x # xs)›*)
proof (cases)
(*goals:
1. ‹?P::bool ⟹ I⇩Z (hd_coeff1 (m::int) (Dvd (d::int) (i::int) (ks::int list))) (m * (x::int) # (xs::int list)) = I⇩Z (Dvd d i ks) (x # xs)›
2. ‹¬ (?P::bool) ⟹ I⇩Z (hd_coeff1 (m::int) (Dvd (d::int) (i::int) (ks::int list))) (m * (x::int) # (xs::int list)) = I⇩Z (Dvd d i ks) (x # xs)›*)
assume "k=0" (*‹(k::int) = (0::int)›*)
thus "?thesis"
(*goal: ‹I⇩Z (hd_coeff1 m (Dvd d i ks)) (m * x # xs) = I⇩Z (Dvd d i ks) (x # xs)›*)
by simp
next
(*goal: ‹k ≠ 0 ⟹ I⇩Z (hd_coeff1 m (Dvd d i ks)) (m * x # xs) = I⇩Z (Dvd d i ks) (x # xs)›*)
assume "k≠0" (*‹(k::int) ≠ (0::int)›*)
with Dvd (*‹hd_coeff (Dvd d i ks) dvd m ∨ hd_coeff (Dvd d i ks) = 0›*) have "k dvd m"
by simp
let ?m' = "m div k"
have "?m' ≠ 0"
using ‹k dvd m› (*‹k dvd m›*) zdiv_eq_0_iff (*‹((?i::int) div (?k::int) = (0::int)) = (?k = (0::int) ∨ (0::int) ≤ ?i ∧ ?i < ?k ∨ ?i ≤ (0::int) ∧ ?k < ?i)›*) ‹m>0› (*‹(0::int) < (m::int)›*) ‹k≠0› (*‹(k::int) ≠ (0::int)›*) by (simp add:linorder_not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) zdvd_imp_le (*‹⟦?z dvd ?n; 0 < ?n⟧ ⟹ ?z ≤ ?n›*))
have 1: "k*(x*?m') = x * m"
proof (-)
(*goal: ‹(k::int) * ((x::int) * ((m::int) div k)) = x * m›*)
have "k*(x*?m') = x*(k*?m')"
by (simp add:algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*))
also (*calculation: ‹k * (x * (m div k)) = x * (k * (m div k))›*) have "… = x*m"
using dvd_mult_div_cancel[OF ‹k dvd m›] (*‹k * (m div k) = m›*) by (simp add:algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*))
finally (*calculation: ‹k * (x * (m div k)) = x * m›*) show "?thesis"
(*goal: ‹k * (x * (m div k)) = x * m›*) .
qed
have "I⇩Z (hd_coeff1 m (Dvd d i ks)) (m*x#xs) ⟷
(?m'*d dvd ?m'*i + m*x + ?m' * ⟨ks',xs⟩)"
using ‹k≠0› (*‹k ≠ 0›*) by (simp add: algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 11 facts*))
also (*calculation: ‹I⇩Z (hd_coeff1 m (Dvd d i ks)) (m * x # xs) = (m div k * d dvd m div k * i + m * x + m div k * ⟨ks',xs⟩)›*) have "… ⟷ ?m'*d dvd ?m' * (i + k*x + ⟨ks',xs⟩)"
using "1" (*‹k * (x * (m div k)) = x * m›*) by (simp (no_asm_simp) add:algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*))
also (*calculation: ‹I⇩Z (hd_coeff1 m (Dvd d i ks)) (m * x # xs) = (m div k * d dvd m div k * (i + k * x + ⟨ks',xs⟩))›*) have "… ⟷ d dvd i + k*x + ⟨ks',xs⟩"
using ‹?m'≠0› (*‹m div k ≠ 0›*) by simp
finally (*calculation: ‹I⇩Z (hd_coeff1 m (Dvd d i ks)) (m * x # xs) = (d dvd i + k * x + ⟨ks',xs⟩)›*) show "?thesis"
(*goal: ‹I⇩Z (hd_coeff1 m (Dvd d i ks)) (m * x # xs) = I⇩Z (Dvd d i ks) (x # xs)›*)
by (simp add:algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 11 facts*))
qed
qed
next
(*goal: ‹⋀x1 x2 x3. hd_coeff (NDvd x1 x2 x3) dvd m ∨ hd_coeff (NDvd x1 x2 x3) = 0 ⟹ I⇩Z (hd_coeff1 m (NDvd x1 x2 x3)) (m * x # xs) = I⇩Z (NDvd x1 x2 x3) (x # xs)›*)
case [simp]: (NDvd d i ks) (*‹hd_coeff (NDvd d i ks) dvd m ∨ hd_coeff (NDvd d i ks) = 0›*)
show "?case"
(*goal: ‹I⇩Z (hd_coeff1 m (NDvd d i ks)) (m * x # xs) = I⇩Z (NDvd d i ks) (x # xs)›*)
proof (cases ks)
(*goals:
1. ‹(ks::int list) = [] ⟹ I⇩Z (hd_coeff1 (m::int) (NDvd (d::int) (i::int) ks)) (m * (x::int) # (xs::int list)) = I⇩Z (NDvd d i ks) (x # xs)›
2. ‹⋀(a::int) list::int list. (ks::int list) = a # list ⟹ I⇩Z (hd_coeff1 (m::int) (NDvd (d::int) (i::int) ks)) (m * (x::int) # (xs::int list)) = I⇩Z (NDvd d i ks) (x # xs)›*)
case Nil (*‹ks = []›*)
thus "?thesis"
(*goal: ‹I⇩Z (hd_coeff1 m (NDvd d i ks)) (m * x # xs) = I⇩Z (NDvd d i ks) (x # xs)›*)
by simp
next
(*goal: ‹⋀a list. ks = a # list ⟹ I⇩Z (hd_coeff1 m (NDvd d i ks)) (m * x # xs) = I⇩Z (NDvd d i ks) (x # xs)›*)
case [simp]: (Cons k ks') (*‹ks = k # ks'›*)
show "?thesis"
(*goal: ‹I⇩Z (hd_coeff1 m (NDvd d i ks)) (m * x # xs) = I⇩Z (NDvd d i ks) (x # xs)›*)
proof (cases)
(*goals:
1. ‹?P ⟹ I⇩Z (hd_coeff1 m (NDvd d i ks)) (m * x # xs) = I⇩Z (NDvd d i ks) (x # xs)›
2. ‹¬ ?P ⟹ I⇩Z (hd_coeff1 m (NDvd d i ks)) (m * x # xs) = I⇩Z (NDvd d i ks) (x # xs)›*)
assume "k=0" (*‹(k::int) = (0::int)›*)
thus "?thesis"
(*goal: ‹I⇩Z (hd_coeff1 m (NDvd d i ks)) (m * x # xs) = I⇩Z (NDvd d i ks) (x # xs)›*)
by simp
next
(*goal: ‹k ≠ 0 ⟹ I⇩Z (hd_coeff1 m (NDvd d i ks)) (m * x # xs) = I⇩Z (NDvd d i ks) (x # xs)›*)
assume "k≠0" (*‹(k::int) ≠ (0::int)›*)
with NDvd (*‹hd_coeff (NDvd (d::int) (i::int) (ks::int list)) dvd (m::int) ∨ hd_coeff (NDvd d i ks) = (0::int)›*) have "k dvd m"
by simp
let ?m' = "m div k"
have "?m' ≠ 0"
using ‹k dvd m› (*‹(k::int) dvd (m::int)›*) zdiv_eq_0_iff (*‹(?i div ?k = 0) = (?k = 0 ∨ 0 ≤ ?i ∧ ?i < ?k ∨ ?i ≤ 0 ∧ ?k < ?i)›*) ‹m>0› (*‹(0::int) < (m::int)›*) ‹k≠0› (*‹k ≠ 0›*) by (simp add:linorder_not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) zdvd_imp_le (*‹⟦?z dvd ?n; 0 < ?n⟧ ⟹ ?z ≤ ?n›*))
have 1: "k*(x*?m') = x * m"
proof (-)
(*goal: ‹k * (x * (m div k)) = x * m›*)
have "k*(x*?m') = x*(k*?m')"
by (simp add:algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*))
also (*calculation: ‹k * (x * (m div k)) = x * (k * (m div k))›*) have "… = x*m"
using dvd_mult_div_cancel[OF ‹k dvd m›] (*‹k * (m div k) = m›*) by (simp add:algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*))
finally (*calculation: ‹k * (x * (m div k)) = x * m›*) show "?thesis"
(*goal: ‹k * (x * (m div k)) = x * m›*) .
qed
have "I⇩Z (hd_coeff1 m (NDvd d i ks)) (m*x#xs) ⟷
¬(?m'*d dvd ?m'*i + m*x + ?m' * ⟨ks',xs⟩)"
using ‹k≠0› (*‹k ≠ 0›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*))
also (*calculation: ‹I⇩Z (hd_coeff1 m (NDvd d i ks)) (m * x # xs) = (¬ m div k * d dvd m div k * i + m * x + m div k * ⟨ks',xs⟩)›*) have "… ⟷ ¬ ?m'*d dvd ?m' * (i + k*x + ⟨ks',xs⟩)"
using "1" (*‹k * (x * (m div k)) = x * m›*) by (simp (no_asm_simp) add:algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*))
also (*calculation: ‹I⇩Z (hd_coeff1 (m::int) (NDvd (d::int) (i::int) (ks::int list))) (m * (x::int) # (xs::int list)) = (¬ m div (k::int) * d dvd m div k * (i + k * x + ⟨ks'::int list,xs⟩))›*) have "… ⟷ ¬ d dvd i + k*x + ⟨ks',xs⟩"
using ‹?m'≠0› (*‹m div k ≠ 0›*) by simp
finally (*calculation: ‹I⇩Z (hd_coeff1 m (NDvd d i ks)) (m * x # xs) = (¬ d dvd i + k * x + ⟨ks',xs⟩)›*) show "?thesis"
(*goal: ‹I⇩Z (hd_coeff1 m (NDvd d i ks)) (m * x # xs) = I⇩Z (NDvd d i ks) (x # xs)›*)
by (simp add:algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 11 facts*))
qed
qed
qed
lemma I_hd_coeff1_mult: assumes "m>0"
shows "qfree φ ⟹ ∀ a ∈ set(Z.atoms₀ φ). hd_coeff a dvd m ⟹
Z.I (map⇩f⇩m (hd_coeff1 m) φ) (m*x#xs) = Z.I φ (x#xs)"
proof (induct φ)
(*goals:
1. ‹⟦qfree TrueF; ∀a∈set (atoms₀ TrueF). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) TrueF) (m * x # xs) = Z.I TrueF (x # xs)›
2. ‹⟦qfree FalseF; ∀a∈set (atoms₀ FalseF). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) FalseF) (m * x # xs) = Z.I FalseF (x # xs)›
3. ‹⋀xa. ⟦qfree (Atom xa); ∀a∈set (atoms₀ (Atom xa)). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) (Atom xa)) (m * x # xs) = Z.I (Atom xa) (x # xs)›
4. ‹⋀φ1 φ2. ⟦⟦qfree φ1; ∀a∈set (atoms₀ φ1). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) φ1) (m * x # xs) = Z.I φ1 (x # xs); ⟦qfree φ2; ∀a∈set (atoms₀ φ2). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) φ2) (m * x # xs) = Z.I φ2 (x # xs); qfree (And φ1 φ2); ∀a∈set (atoms₀ (And φ1 φ2)). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) (And φ1 φ2)) (m * x # xs) = Z.I (And φ1 φ2) (x # xs)›
5. ‹⋀φ1 φ2. ⟦⟦qfree φ1; ∀a∈set (atoms₀ φ1). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) φ1) (m * x # xs) = Z.I φ1 (x # xs); ⟦qfree φ2; ∀a∈set (atoms₀ φ2). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) φ2) (m * x # xs) = Z.I φ2 (x # xs); qfree (Or φ1 φ2); ∀a∈set (atoms₀ (Or φ1 φ2)). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) (Or φ1 φ2)) (m * x # xs) = Z.I (Or φ1 φ2) (x # xs)›
6. ‹⋀φ. ⟦⟦qfree φ; ∀a∈set (atoms₀ φ). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) φ) (m * x # xs) = Z.I φ (x # xs); qfree (Neg φ); ∀a∈set (atoms₀ (Neg φ)). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) (Neg φ)) (m * x # xs) = Z.I (Neg φ) (x # xs)›
7. ‹⋀φ. ⟦⟦qfree φ; ∀a∈set (atoms₀ φ). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) φ) (m * x # xs) = Z.I φ (x # xs); qfree (ExQ φ); ∀a∈set (atoms₀ (ExQ φ)). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) (ExQ φ)) (m * x # xs) = Z.I (ExQ φ) (x # xs)›*)
case (Atom a) (*‹qfree (Atom (a::atom))› ‹∀a∈set (atoms₀ (Atom a)). hd_coeff a dvd m›*)
thus "?case"
(*goal: ‹Z.I (map⇩f⇩m (hd_coeff1 m) (Atom a)) (m * x # xs) = Z.I (Atom a) (x # xs)›*)
using I_hd_coeff1_mult_a[OF ‹m>0›] (*‹hd_coeff ?a dvd m ∨ hd_coeff ?a = 0 ⟹ I⇩Z (hd_coeff1 m ?a) (m * ?x # ?xs) = I⇩Z ?a (?x # ?xs)›*) by auto
qed (simp_all)
(*solves the remaining goals:
1. ‹⟦qfree TrueF; ∀a∈set (atoms₀ TrueF). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) TrueF) (m * x # xs) = Z.I TrueF (x # xs)›
2. ‹⟦qfree FalseF; ∀a∈set (atoms₀ FalseF). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) FalseF) (m * x # xs) = Z.I FalseF (x # xs)›
3. ‹⋀φ1 φ2. ⟦⟦qfree φ1; ∀a∈set (atoms₀ φ1). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) φ1) (m * x # xs) = Z.I φ1 (x # xs); ⟦qfree φ2; ∀a∈set (atoms₀ φ2). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) φ2) (m * x # xs) = Z.I φ2 (x # xs); qfree (And φ1 φ2); ∀a∈set (atoms₀ (And φ1 φ2)). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) (And φ1 φ2)) (m * x # xs) = Z.I (And φ1 φ2) (x # xs)›
4. ‹⋀φ1 φ2. ⟦⟦qfree φ1; ∀a∈set (atoms₀ φ1). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) φ1) (m * x # xs) = Z.I φ1 (x # xs); ⟦qfree φ2; ∀a∈set (atoms₀ φ2). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) φ2) (m * x # xs) = Z.I φ2 (x # xs); qfree (Or φ1 φ2); ∀a∈set (atoms₀ (Or φ1 φ2)). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) (Or φ1 φ2)) (m * x # xs) = Z.I (Or φ1 φ2) (x # xs)›
5. ‹⋀φ. ⟦⟦qfree φ; ∀a∈set (atoms₀ φ). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) φ) (m * x # xs) = Z.I φ (x # xs); qfree (Neg φ); ∀a∈set (atoms₀ (Neg φ)). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) (Neg φ)) (m * x # xs) = Z.I (Neg φ) (x # xs)›
6. ‹⋀φ. ⟦⟦qfree φ; ∀a∈set (atoms₀ φ). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) φ) (m * x # xs) = Z.I φ (x # xs); qfree (ExQ φ); ∀a∈set (atoms₀ (ExQ φ)). hd_coeff a dvd m⟧ ⟹ Z.I (map⇩f⇩m (hd_coeff1 m) (ExQ φ)) (m * x # xs) = Z.I (ExQ φ) (x # xs)›*)
end
| {
"path": "afp-2025-02-12/thys/LinearQuantifierElim/Thys/PresArith.thy",
"repo": "afp-2025-02-12",
"sha": "830373c04ac558d846d8841f6c6f0dac70bf8a2f1c3371d416af86e1adf24303"
} |
(*
Title: Psi-calculi
Author/Maintainer: Jesper Bengtson (jebe@itu.dk), 2012
*)
theory Tau_Laws_Weak
imports Weaken_Bisimulation Weak_Congruence Tau_Sim Tau_Stat_Imp
begin
context weakTauLaws begin
lemma tauLaw1:
fixes Ψ :: 'b
and P :: "('a, 'b, 'c) psi"
shows "Ψ ⊳ τ.(P) ≈ P"
proof (-)
(*goal: ‹Ψ ⊳ τ.P ≈ P›*)
let ?X = "{(Ψ, τ.(P), P) | Ψ P. True}"
let ?Y = "{(Ψ, P, τ.(P)) | Ψ P. True}"
have "(Ψ, τ.(P), P) ∈ ?X ∪ ?Y"
by auto
moreover have "eqvt(?X ∪ ?Y)"
by (auto simp add: eqvt_def (*‹eqvt ?X ≡ ∀x∈?X. ∀p. p ∙ x ∈ ?X›*) simp add: eqvts (*‹?p ∙ ?α⋅?P = (?p ∙ ?α)⋅(?p ∙ ?P)› ‹?p ∙ τ.?P = τ.(?p ∙ ?P)› ‹?p ∙ nameTerm ?x = nameTerm (?p ∙ ?x)› ‹?p1 ∙ (?Ψ1 ⊳ ?P1 ∼⇩s ?Q1) = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ∼⇩s ?p1 ∙ ?Q1› ‹?Ψ ⊳ ?P ∼⇩s ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼⇩s ?p ∙ ?Q› ‹?p1 ∙ ?Ψ1 : ?Q1 ⊳ ?P1 ⟹?α1 ≺ ?P'1 = ?p1 ∙ ?Ψ1 : ?p1 ∙ ?Q1 ⊳ ?p1 ∙ ?P1 ⟹?p1 ∙ ?α1 ≺ ?p1 ∙ ?P'1› ‹?Ψ : ?Q ⊳ ?P ⟹?α ≺ ?P' ⟹ ?p ∙ ?Ψ : ?p ∙ ?Q ⊳ ?p ∙ ?P ⟹?p ∙ ?α ≺ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇧^⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇧^⇩τ ?p1 ∙ ?P'1› ‹?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇩τ ?p1 ∙ ?P'1› and more 127 facts*))
ultimately have "Ψ ⊳ τ.(P) ≈⇩w P"
proof (coinduct rule: weakenTransitiveCoinduct)
(*goals:
1. ‹⋀Ψ P Q. (Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ⟹ Ψ ⊳ P ⪅⇩w<({(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim)> Q›
2. ‹⋀Ψ P Q. (Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ⟹ Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›
3. ‹⋀Ψ P Q Ψ'. (Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ⟹ (Ψ ⊗ Ψ', P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim›
4. ‹⋀Ψ P Q. (Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ⟹ (Ψ, Q, P) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim›*)
case (cStatImp Ψ P Q) (*‹(Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True}›*)
show "?case"
(*goal: ‹Ψ ⊳ P ⪅⇩w<({(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim)> Q›*)
proof (cases "(Ψ, P, Q) ∈ ?X")
(*goals:
1. ‹(Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ⟹ Ψ ⊳ P ⪅⇩w<({(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim)> Q›
2. ‹(Ψ, P, Q) ∉ {(Ψ, τ.P, P) |Ψ P. True} ⟹ Ψ ⊳ P ⪅⇩w<({(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim)> Q›*)
case True (*‹(Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True}›*)
{
fix Ψ and P
have "Ψ ⊳ P ⪅⇩w<(?X ∪ ?Y ∪ weakBisim)> P"
by (auto simp add: weakenStatImp_def (*‹?Ψ ⊳ ?P ⪅⇩w<?Rel> ?Q ≡ ∃Q'. ?Ψ ⊳ ?Q ⟹⇧^⇩τ Q' ∧ insertAssertion (extractFrame ?P) ?Ψ ↪⇩F insertAssertion (extractFrame Q') ?Ψ ∧ (?Ψ, ?P, Q') ∈ ?Rel›*) intro: weakBisimReflexive (*‹?Ψ ⊳ ?P ≈ ?P›*))
moreover have "(Ψ, τ.(P), P) ∈ ?X ∪ ?Y ∪ weakBisim"
by auto
ultimately have "Ψ ⊳ τ.(P) ⪅⇩w<(?X ∪ ?Y ∪ weakBisim)> P"
by (rule tauLaw1StatImpLeft (*‹⟦?Ψ ⊳ ?P ⪅⇩w<?Rel> ?Q; (?Ψ, τ.?P, ?Q) ∈ ?Rel⟧ ⟹ ?Ψ ⊳ τ.?P ⪅⇩w<?Rel> ?Q›*))
}
with ‹(Ψ, P, Q) ∈ ?X› (*‹(Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True}›*) show "?thesis"
(*goal: ‹Ψ ⊳ P ⪅⇩w<({(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim)> Q›*)
by auto
next
(*goal: ‹(Ψ, P, Q) ∉ {(Ψ, τ.P, P) |Ψ P. True} ⟹ Ψ ⊳ P ⪅⇩w<({(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim)> Q›*)
case False (*‹(Ψ, P, Q) ∉ {(Ψ, τ.P, P) |Ψ P. True}›*)
from ‹(Ψ, P, Q) ∉ ?X› (*‹(Ψ, P, Q) ∉ {(Ψ, τ.P, P) |Ψ P. True}›*) ‹(Ψ, P, Q) ∈ ?X ∪ ?Y› (*‹(Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True}›*) have "(Ψ, P, Q) ∈ ?Y"
by auto
{
fix Ψ and P
have "Ψ ⊳ P ⪅<weakBisim> P"
using weakBisimReflexive (*‹(?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ≈ ?P›*) by (rule weakBisimE (*‹?Ψ ⊳ ?P ≈ ?Q ⟹ ?Ψ ⊳ ?P ⪅<weakBisim> ?Q› ‹?Ψ ⊳ ?P ≈ ?Q ⟹ ?Ψ ⊳ ?P ↝<weakBisim> ?Q› ‹?Ψ ⊳ ?P ≈ ?Q ⟹ ?Ψ ⊗ ?Ψ' ⊳ ?P ≈ ?Q› ‹?Ψ ⊳ ?P ≈ ?Q ⟹ ?Ψ ⊳ ?Q ≈ ?P›*))
moreover have "⋀Ψ P Q R. ⟦Ψ ⊳ P ≈ Q; Ψ ⊳ Q ∼ R⟧ ⟹ (Ψ, P, R) ∈ ?X ∪ ?Y ∪ weakBisim"
by (fastforce intro: weakBisimTransitive (*‹⟦?Ψ ⊳ ?P ≈ ?Q; ?Ψ ⊳ ?Q ≈ ?R⟧ ⟹ ?Ψ ⊳ ?P ≈ ?R›*) strongBisimWeakBisim (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?Ψ ⊳ ?P ≈ ?Q›*))
ultimately have "Ψ ⊳ P ⪅<( ?X ∪ ?Y ∪ weakBisim)> τ.(P)"
apply (rule tauLaw1StatImpRight (*‹⟦?Ψ ⊳ ?P ⪅<?Rel> ?Q; ⋀Ψ P Q R. ⟦(Ψ, P, Q) ∈ ?Rel; Ψ ⊳ Q ∼ R⟧ ⟹ (Ψ, P, R) ∈ ?Rel'⟧ ⟹ ?Ψ ⊳ ?P ⪅<?Rel'> τ.?Q›*))
(*goals:
1. ‹⋀(Ψ::'b) (P::('a, 'b, 'c) psi) (Q::('a, 'b, 'c) psi) R::('a, 'b, 'c) psi. ⟦Ψ ⊳ P ≈ Q; Ψ ⊳ Q ∼ R⟧ ⟹ Ψ ⊳ P ≈ (?Q4::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi) Ψ P Q R›
2. ‹⋀(Ψ::'b) (P::('a, 'b, 'c) psi) (Q::('a, 'b, 'c) psi) R::('a, 'b, 'c) psi. ⟦Ψ ⊳ P ≈ Q; Ψ ⊳ Q ∼ R⟧ ⟹ Ψ ⊳ (?Q4::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi) Ψ P Q R ∼ R›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
moreover have "⋀Ψ P Q Ψ'. ⟦(Ψ, P, Q) ∈ ?X ∪ ?Y ∪ weakBisim; Ψ ≃ Ψ'⟧ ⟹ (Ψ', P, Q) ∈ ?X ∪ ?Y ∪ weakBisim"
by (auto dest: statEqWeakBisim (*‹⟦?Ψ ⊳ ?P ≈ ?Q; ?Ψ ≃ ?Ψ'⟧ ⟹ ?Ψ' ⊳ ?P ≈ ?Q›*))
ultimately have "Ψ ⊳ P ⪅⇩w<( ?X ∪ ?Y ∪ weakBisim)> τ.(P)"
apply (rule weakStatImpWeakenStatImp (*‹⟦?Ψ ⊳ ?P ⪅<?Rel> ?Q; ⋀Ψ' R S Ψ''. ⟦(Ψ', R, S) ∈ ?Rel; Ψ' ≃ Ψ''⟧ ⟹ (Ψ'', R, S) ∈ ?Rel⟧ ⟹ ?Ψ ⊳ ?P ⪅⇩w<?Rel> ?Q›*))
(*goals:
1. ‹⋀(Ψ'::'b) (R::('a, 'b, 'c) psi) (S::('a, 'b, 'c) psi) Ψ''::'b. ⟦(Ψ', R, S) ∈ {(Ψ, τ.P, P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, P, τ.P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ weakBisim; Ψ' ≃ Ψ''⟧ ⟹ ((?Ψ4::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ 'b ⇒ 'b) Ψ' R S Ψ'', R, S) ∈ {(Ψ, τ.P, P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, P, τ.P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ weakBisim›
2. ‹⋀(Ψ'::'b) (R::('a, 'b, 'c) psi) (S::('a, 'b, 'c) psi) Ψ''::'b. ⟦(Ψ', R, S) ∈ {(Ψ, τ.P, P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, P, τ.P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ weakBisim; Ψ' ≃ Ψ''⟧ ⟹ (?Ψ4::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ 'b ⇒ 'b) Ψ' R S Ψ'' ≃ Ψ''›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
}
with ‹(Ψ, P, Q) ∈ ?Y› (*‹(Ψ, P, Q) ∈ {(Ψ, P, τ.P) |Ψ P. True}›*) show "?thesis"
(*goal: ‹(Ψ::'b::fs_name) ⊳ (P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) ⪅⇩w<({(Ψ, τ.P, P) |(Ψ::'b::fs_name) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True} ∪ {(Ψ, P, τ.P) |(Ψ::'b::fs_name) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True} ∪ weakenBisim)> (Q::('a::fs_name, 'b::fs_name, 'c::fs_name) psi)›*)
by auto
qed
next
(*goals:
1. ‹⋀Ψ P Q. (Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ⟹ Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›
2. ‹⋀Ψ P Q Ψ'. (Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ⟹ (Ψ ⊗ Ψ', P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim›
3. ‹⋀Ψ P Q. (Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ⟹ (Ψ, Q, P) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim›*)
case (cSim Ψ P Q) (*‹(Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True}›*)
let ?Z = "{(Ψ, P, Q) | Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ ?X ∪ ?Y ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}"
have "eqvt ?Z"
apply auto
(*goal: ‹eqvt {(Ψ, P, Q) |(Ψ::'b::fs_name) (P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) Q::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. ∃(P'::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) Q'::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |(Ψ::'b::fs_name) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True} ∪ {(Ψ, P, τ.P) |(Ψ::'b::fs_name) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›*)
apply (auto simp add: eqvt_def (*‹eqvt ?X ≡ ∀x∈?X. ∀p. p ∙ x ∈ ?X›*) eqvts (*‹?p ∙ ?α⋅?P = (?p ∙ ?α)⋅(?p ∙ ?P)› ‹?p ∙ τ.?P = τ.(?p ∙ ?P)› ‹?p ∙ nameTerm ?x = nameTerm (?p ∙ ?x)› ‹?p1 ∙ (?Ψ1 ⊳ ?P1 ∼⇩s ?Q1) = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ∼⇩s ?p1 ∙ ?Q1› ‹?Ψ ⊳ ?P ∼⇩s ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼⇩s ?p ∙ ?Q› ‹?p1 ∙ ?Ψ1 : ?Q1 ⊳ ?P1 ⟹?α1 ≺ ?P'1 = ?p1 ∙ ?Ψ1 : ?p1 ∙ ?Q1 ⊳ ?p1 ∙ ?P1 ⟹?p1 ∙ ?α1 ≺ ?p1 ∙ ?P'1› ‹?Ψ : ?Q ⊳ ?P ⟹?α ≺ ?P' ⟹ ?p ∙ ?Ψ : ?p ∙ ?Q ⊳ ?p ∙ ?P ⟹?p ∙ ?α ≺ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇧^⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇧^⇩τ ?p1 ∙ ?P'1› ‹?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇩τ ?p1 ∙ ?P'1› and more 127 facts*))
(*goals:
1. ‹⋀(a::'b) (aa::('a, 'b, 'c) psi) (b::('a, 'b, 'c) psi) (p::(name × name) list) Q'::('a, 'b, 'c) psi. ⟦a ⊳ aa ∼ τ.Q'; a ⊳ Q' ∼ b⟧ ⟹ ∃P'::('a, 'b, 'c) psi. p ∙ a ⊳ p ∙ aa ∼ P' ∧ (∃Q'::('a, 'b, 'c) psi. (P' = τ.Q' ∨ Q' = τ.P' ∨ p ∙ a ⊳ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)›
2. ‹⋀(a::'b) (aa::('a, 'b, 'c) psi) (b::('a, 'b, 'c) psi) (P'::('a, 'b, 'c) psi) p::(name × name) list. ⟦a ⊳ aa ∼ P'; a ⊳ τ.P' ∼ b⟧ ⟹ ∃P'::('a, 'b, 'c) psi. p ∙ a ⊳ p ∙ aa ∼ P' ∧ (∃Q'::('a, 'b, 'c) psi. (P' = τ.Q' ∨ Q' = τ.P' ∨ p ∙ a ⊳ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)›
3. ‹⋀(a::'b) (aa::('a, 'b, 'c) psi) (b::('a, 'b, 'c) psi) (P'::('a, 'b, 'c) psi) (p::(name × name) list) Q'::('a, 'b, 'c) psi. ⟦a ⊳ aa ∼ P'; a ⊳ Q' ∼ b; a ⊳ P' ≈ Q'⟧ ⟹ ∃P'::('a, 'b, 'c) psi. p ∙ a ⊳ p ∙ aa ∼ P' ∧ (∃Q'::('a, 'b, 'c) psi. (P' = τ.Q' ∨ Q' = τ.P' ∨ p ∙ a ⊳ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)›
discuss goal 1*)
apply (rule_tac x="(p ∙ (τ.(Q')))" in exI (*‹?P ?x ⟹ ∃x. ?P x›*))
(*top goal: ‹⋀a aa b p Q'. ⟦a ⊳ aa ∼ τ.Q'; a ⊳ Q' ∼ b⟧ ⟹ ∃P'. p ∙ a ⊳ p ∙ aa ∼ P' ∧ (∃Q'. (P' = τ.Q' ∨ Q' = τ.P' ∨ p ∙ a ⊳ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)› and 2 goals remain*)
apply (auto intro: bisimClosed (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼ ?p ∙ ?Q›*))
(*top goal: ‹⋀a aa b p Q'. ⟦a ⊳ aa ∼ τ.Q'; a ⊳ Q' ∼ b⟧ ⟹ p ∙ a ⊳ p ∙ aa ∼ p ∙ τ.Q' ∧ (∃Q'a. (p ∙ τ.Q' = τ.Q'a ∨ Q'a = τ.(p ∙ τ.Q') ∨ p ∙ a ⊳ p ∙ τ.Q' ≈ Q'a) ∧ p ∙ a ⊳ Q'a ∼ p ∙ b)› and 2 goals remain*)
apply (simp add: eqvts (*‹(?p::(name × name) list) ∙ (?α::'a prefix)⋅(?P::('a, 'b, 'c) psi) = (?p ∙ ?α)⋅(?p ∙ ?P)› ‹(?p::(name × name) list) ∙ τ.(?P::('a, 'b, 'c) psi) = τ.(?p ∙ ?P)› ‹(?p::(name × name) list) ∙ (nameTerm::name ⇒ 'a) (?x::name) = nameTerm (?p ∙ ?x)› ‹(?p1::(name × name) list) ∙ ((?Ψ1::'b) ⊳ (?P1::('a, 'b, 'c) psi) ∼⇩s (?Q1::('a, 'b, 'c) psi)) = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ∼⇩s ?p1 ∙ ?Q1› ‹(?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ∼⇩s (?Q::('a, 'b, 'c) psi) ⟹ (?p::(name × name) list) ∙ ?Ψ ⊳ ?p ∙ ?P ∼⇩s ?p ∙ ?Q› ‹(?p1::(name × name) list) ∙ (?Ψ1::'b) : (?Q1::('a, 'b, 'c) psi) ⊳ (?P1::('a, 'b, 'c) psi) ⟹(?α1::'a action) ≺ (?P'1::('a, 'b, 'c) psi) = ?p1 ∙ ?Ψ1 : ?p1 ∙ ?Q1 ⊳ ?p1 ∙ ?P1 ⟹?p1 ∙ ?α1 ≺ ?p1 ∙ ?P'1› ‹(?Ψ::'b) : (?Q::('a, 'b, 'c) psi) ⊳ (?P::('a, 'b, 'c) psi) ⟹(?α::'a action) ≺ (?P'::('a, 'b, 'c) psi) ⟹ (?p::(name × name) list) ∙ ?Ψ : ?p ∙ ?Q ⊳ ?p ∙ ?P ⟹?p ∙ ?α ≺ ?p ∙ ?P'› ‹(?p::(name × name) list) ∙ (?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ⟹⇧^⇩τ (?P'::('a, 'b, 'c) psi) = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹(?p::(name × name) list) ∙ (?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ⟹⇩τ (?P'::('a, 'b, 'c) psi) = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇩τ ?p ∙ ?P'› ‹(?p1::(name × name) list) ∙ (?Ψ1::'b) ⊳ (?P1::('a, 'b, 'c) psi) ⟹⇧^⇩τ (?P'1::('a, 'b, 'c) psi) = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇧^⇩τ ?p1 ∙ ?P'1› ‹(?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ⟹⇧^⇩τ (?P'::('a, 'b, 'c) psi) ⟹ (?p::(name × name) list) ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹(?p1::(name × name) list) ∙ (?Ψ1::'b) ⊳ (?P1::('a, 'b, 'c) psi) ⟹⇩τ (?P'1::('a, 'b, 'c) psi) = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇩τ ?p1 ∙ ?P'1› and more 127 facts*))
(*top goal: ‹⋀(a::'b) (aa::('a, 'b, 'c) psi) (b::('a, 'b, 'c) psi) (p::(name × name) list) Q'::('a, 'b, 'c) psi. ⟦a ⊳ aa ∼ τ.Q'; a ⊳ Q' ∼ b⟧ ⟹ ∃Q'a::('a, 'b, 'c) psi. (p ∙ τ.Q' = τ.Q'a ∨ Q'a = τ.(p ∙ τ.Q') ∨ p ∙ a ⊳ p ∙ τ.Q' ≈ Q'a) ∧ p ∙ a ⊳ Q'a ∼ p ∙ b› and 2 goals remain*)
apply (blast intro: bisimClosed (*‹(?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ∼ (?Q::('a, 'b, 'c) psi) ⟹ (?p::(name × name) list) ∙ ?Ψ ⊳ ?p ∙ ?P ∼ ?p ∙ ?Q›*) weakBisimClosed (*‹(?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ≈ (?Q::('a, 'b, 'c) psi) ⟹ (?p::(name × name) list) ∙ ?Ψ ⊳ ?p ∙ ?P ≈ ?p ∙ ?Q›*))
(*discuss goal 2*)
apply (rule_tac x="(p ∙ P')" in exI (*‹?P ?x ⟹ ∃x. ?P x›*))
(*top goal: ‹⋀a aa b P' p. ⟦a ⊳ aa ∼ P'; a ⊳ τ.P' ∼ b⟧ ⟹ ∃P'. p ∙ a ⊳ p ∙ aa ∼ P' ∧ (∃Q'. (P' = τ.Q' ∨ Q' = τ.P' ∨ p ∙ a ⊳ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)› and 1 goal remains*)
apply (auto intro: bisimClosed (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼ ?p ∙ ?Q›*))
(*top goal: ‹⋀a aa b P' p. ⟦a ⊳ aa ∼ P'; a ⊳ τ.P' ∼ b⟧ ⟹ p ∙ a ⊳ p ∙ aa ∼ p ∙ P' ∧ (∃Q'. (p ∙ P' = τ.Q' ∨ Q' = τ.(p ∙ P') ∨ p ∙ a ⊳ p ∙ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)› and 1 goal remains*)
apply (rule_tac x="τ.(p ∙ P')" in exI (*‹?P ?x ⟹ ∃x. ?P x›*))
(*top goal: ‹⋀a aa b P' p. ⟦a ⊳ aa ∼ P'; a ⊳ τ.P' ∼ b⟧ ⟹ ∃Q'. (p ∙ P' = τ.Q' ∨ Q' = τ.(p ∙ P') ∨ p ∙ a ⊳ p ∙ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b› and 1 goal remains*)
apply auto
(*top goal: ‹⋀a aa b P' p. ⟦a ⊳ aa ∼ P'; a ⊳ τ.P' ∼ b⟧ ⟹ (p ∙ P' = τ.τ.(p ∙ P') ∨ τ.(p ∙ P') = τ.(p ∙ P') ∨ p ∙ a ⊳ p ∙ P' ≈ τ.(p ∙ P')) ∧ p ∙ a ⊳ τ.(p ∙ P') ∼ p ∙ b› and 1 goal remains*)
apply (drule_tac p=p and Q=b in bisimClosed (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼ ?p ∙ ?Q›*))
(*top goal: ‹⋀a aa b P' p. ⟦a ⊳ aa ∼ P'; a ⊳ τ.P' ∼ b⟧ ⟹ p ∙ a ⊳ τ.(p ∙ P') ∼ p ∙ b› and 1 goal remains*)
apply (simp add: eqvts (*‹?p ∙ ?α⋅?P = (?p ∙ ?α)⋅(?p ∙ ?P)› ‹?p ∙ τ.?P = τ.(?p ∙ ?P)› ‹?p ∙ nameTerm ?x = nameTerm (?p ∙ ?x)› ‹?p1 ∙ (?Ψ1 ⊳ ?P1 ∼⇩s ?Q1) = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ∼⇩s ?p1 ∙ ?Q1› ‹?Ψ ⊳ ?P ∼⇩s ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼⇩s ?p ∙ ?Q› ‹?p1 ∙ ?Ψ1 : ?Q1 ⊳ ?P1 ⟹?α1 ≺ ?P'1 = ?p1 ∙ ?Ψ1 : ?p1 ∙ ?Q1 ⊳ ?p1 ∙ ?P1 ⟹?p1 ∙ ?α1 ≺ ?p1 ∙ ?P'1› ‹?Ψ : ?Q ⊳ ?P ⟹?α ≺ ?P' ⟹ ?p ∙ ?Ψ : ?p ∙ ?Q ⊳ ?p ∙ ?P ⟹?p ∙ ?α ≺ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇧^⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇧^⇩τ ?p1 ∙ ?P'1› ‹?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇩τ ?p1 ∙ ?P'1› and more 127 facts*))
(*discuss goal 3*)
apply (rule_tac x="(p ∙ P')" in exI (*‹?P ?x ⟹ ∃x. ?P x›*))
(*goal: ‹⋀(a::'b) (aa::('a, 'b, 'c) psi) (b::('a, 'b, 'c) psi) (P'::('a, 'b, 'c) psi) (p::(name × name) list) Q'::('a, 'b, 'c) psi. ⟦a ⊳ aa ∼ P'; a ⊳ Q' ∼ b; a ⊳ P' ≈ Q'⟧ ⟹ ∃P'::('a, 'b, 'c) psi. p ∙ a ⊳ p ∙ aa ∼ P' ∧ (∃Q'::('a, 'b, 'c) psi. (P' = τ.Q' ∨ Q' = τ.P' ∨ p ∙ a ⊳ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)›*)
apply (auto intro: bisimClosed (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼ ?p ∙ ?Q›*))
(*goal: ‹⋀a aa b P' p Q'. ⟦a ⊳ aa ∼ P'; a ⊳ Q' ∼ b; a ⊳ P' ≈ Q'⟧ ⟹ p ∙ a ⊳ p ∙ aa ∼ p ∙ P' ∧ (∃Q'. (p ∙ P' = τ.Q' ∨ Q' = τ.(p ∙ P') ∨ p ∙ a ⊳ p ∙ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)›*)
apply (rule_tac x="p ∙ Q'" in exI (*‹?P ?x ⟹ ∃x. ?P x›*))
(*goal: ‹⋀a aa b P' p Q'. ⟦a ⊳ aa ∼ P'; a ⊳ Q' ∼ b; a ⊳ P' ≈ Q'⟧ ⟹ ∃Q'. (p ∙ P' = τ.Q' ∨ Q' = τ.(p ∙ P') ∨ p ∙ a ⊳ p ∙ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b›*)
apply auto
(*goals:
1. ‹⋀a aa b P' p Q'. ⟦a ⊳ aa ∼ P'; a ⊳ Q' ∼ b; a ⊳ P' ≈ Q'; p ∙ P' ≠ τ.(p ∙ Q'); (p ∙ a, p ∙ P', p ∙ Q') ∉ weakBisim⟧ ⟹ p ∙ Q' = τ.(p ∙ P')›
2. ‹⋀a aa b P' p Q'. ⟦a ⊳ aa ∼ P'; a ⊳ Q' ∼ b; a ⊳ P' ≈ Q'⟧ ⟹ p ∙ a ⊳ p ∙ Q' ∼ p ∙ b›
discuss goal 1*)
apply (blast intro: bisimClosed (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼ ?p ∙ ?Q›*) dest: weakBisimClosed (*‹?Ψ ⊳ ?P ≈ ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ≈ ?p ∙ ?Q›*))
(*discuss goal 2*)
apply (blast intro: bisimClosed (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼ ?p ∙ ?Q›*) dest: weakBisimClosed (*‹?Ψ ⊳ ?P ≈ ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ≈ ?p ∙ ?Q›*))
(*proven 2 subgoals*)
(*proven 3 subgoals*) .
show "?case"
(*goal: ‹Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›*)
proof (cases "(Ψ, P, Q) ∈ ?X")
(*goals:
1. ‹(Ψ::'b, P::('a, 'b, 'c) psi, Q::('a, 'b, 'c) psi) ∈ {(Ψ, τ.P, P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ⟹ Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, P, τ.P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›
2. ‹(Ψ::'b, P::('a, 'b, 'c) psi, Q::('a, 'b, 'c) psi) ∉ {(Ψ, τ.P, P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ⟹ Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, P, τ.P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›*)
case True (*‹(Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True}›*)
{
fix P
have "Ψ ⊳ P ↝<?Z> P"
using weakenBisimEqWeakBisim (*‹weakenBisim = weakBisim›*) by (blast intro: weakSimReflexive (*‹{(Ψ, P, P) |(Ψ::'b::fs_name) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True} ⊆ (?Rel::('b::fs_name × ('a::fs_name, 'b::fs_name, 'c::fs_name) psi × ('a::fs_name, 'b::fs_name, 'c::fs_name) psi) set) ⟹ (?Ψ::'b::fs_name) ⊳ (?P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) ↝<?Rel> ?P›*) weakBisimReflexive (*‹(?Ψ::'b::fs_name) ⊳ (?P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) ≈ ?P›*) bisimReflexive (*‹(?Ψ::'b::fs_name) ⊳ (?P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) ∼ ?P›*))
moreover note ‹eqvt ?Z› (*‹eqvt {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›*)
moreover have "⋀Ψ P Q R. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ ?Z⟧ ⟹ (Ψ, P, R) ∈ ?Z"
by (blast intro: bisimTransitive (*‹⟦(?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ∼ (?Q::('a, 'b, 'c) psi); ?Ψ ⊳ ?Q ∼ (?R::('a, 'b, 'c) psi)⟧ ⟹ ?Ψ ⊳ ?P ∼ ?R›*))
ultimately have "Ψ ⊳ τ.(P) ↝<?Z> P"
apply (rule tauLaw1SimLeft (*‹⟦(?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ↝<(?Rel::('b × ('a, 'b, 'c) psi × ('a, 'b, 'c) psi) set)> (?Q::('a, 'b, 'c) psi); eqvt ?Rel; ⋀(Ψ::'b) (P::('a, 'b, 'c) psi) (Q::('a, 'b, 'c) psi) R::('a, 'b, 'c) psi. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ ?Rel⟧ ⟹ (Ψ, P, R) ∈ ?Rel⟧ ⟹ ?Ψ ⊳ τ.?P ↝<?Rel> ?Q›*))
(*goals:
1. ‹⋀Ψ P Q R. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}⟧ ⟹ Ψ ⊳ P ∼ ?Q4 Ψ P Q R›
2. ‹⋀Ψ P Q R. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}⟧ ⟹ (Ψ, ?Q4 Ψ P Q R, R) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
moreover have "⋀Ψ P Q Ψ'. ⟦(Ψ, P, Q) ∈ ?Z; Ψ ≃ Ψ'⟧ ⟹ (Ψ', P, Q) ∈ ?Z"
apply simp
(*goal: ‹⋀Ψ P Q Ψ'. ⟦(Ψ, P, Q) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ ≃ Ψ'⟧ ⟹ (Ψ', P, Q) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›*)
by (blast intro: statEqWeakBisim (*‹⟦?Ψ ⊳ ?P ≈ ?Q; ?Ψ ≃ ?Ψ'⟧ ⟹ ?Ψ' ⊳ ?P ≈ ?Q›*) statEqBisim (*‹⟦?Ψ ⊳ ?P ∼ ?Q; ?Ψ ≃ ?Ψ'⟧ ⟹ ?Ψ' ⊳ ?P ∼ ?Q›*))
ultimately have "Ψ ⊳ τ.(P) ↝⇩w<?Z> P"
apply (rule weakSimWeakenSim (*‹⟦?Ψ ⊳ ?P ↝<?Rel> ?Q; ⋀Ψ' R S Ψ''. ⟦(Ψ', R, S) ∈ ?Rel; Ψ' ≃ Ψ''⟧ ⟹ (Ψ'', R, S) ∈ ?Rel⟧ ⟹ ?Ψ ⊳ ?P ↝⇩w<?Rel> ?Q›*))
(*goals:
1. ‹⋀Ψ' R S Ψ''. ⟦(Ψ', R, S) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ' ≃ Ψ''⟧ ⟹ (?Ψ4 Ψ' R S Ψ'', R, S) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›
2. ‹⋀Ψ' R S Ψ''. ⟦(Ψ', R, S) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ' ≃ Ψ''⟧ ⟹ ?Ψ4 Ψ' R S Ψ'' ≃ Ψ''›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
}
with ‹(Ψ, P, Q) ∈ ?X› (*‹(Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True}›*) show "?thesis"
(*goal: ‹Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›*)
by auto
next
(*goal: ‹(Ψ, P, Q) ∉ {(Ψ, τ.P, P) |Ψ P. True} ⟹ Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›*)
case False (*‹(Ψ, P, Q) ∉ {(Ψ, τ.P, P) |Ψ P. True}›*)
from ‹(Ψ, P, Q) ∉ ?X› (*‹(Ψ::'b, P::('a, 'b, 'c) psi, Q::('a, 'b, 'c) psi) ∉ {(Ψ, τ.P, P) |(Ψ::'b) P::('a, 'b, 'c) psi. True}›*) ‹(Ψ, P, Q) ∈ ?X ∪ ?Y› (*‹(Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True}›*) have "(Ψ, P, Q) ∈ ?Y"
by auto
moreover {
fix P
note ‹eqvt ?Z› (*‹eqvt {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›*)
moreover have "(Ψ, P, P) ∈ ?Z"
apply simp
(*goal: ‹(Ψ, P, P) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›*)
by (blast intro: weakBisimReflexive (*‹(?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ≈ ?P›*) bisimReflexive (*‹(?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ∼ ?P›*))
moreover have "⋀Ψ P Q R. ⟦(Ψ, P, Q) ∈ ?Z; Ψ ⊳ Q ∼ R⟧ ⟹ (Ψ, P, R) ∈ ?Z"
by (blast intro: bisimTransitive (*‹⟦?Ψ ⊳ ?P ∼ ?Q; ?Ψ ⊳ ?Q ∼ ?R⟧ ⟹ ?Ψ ⊳ ?P ∼ ?R›*))
ultimately have "Ψ ⊳ P ↝<?Z> τ.(P)"
apply (rule tauLaw1SimRight (*‹⟦eqvt ?Rel; (?Ψ, ?P, ?Q) ∈ ?Rel; ⋀Ψ P Q R. ⟦(Ψ, P, Q) ∈ ?Rel; Ψ ⊳ Q ∼ R⟧ ⟹ (Ψ, P, R) ∈ ?Rel⟧ ⟹ ?Ψ ⊳ ?P ↝<?Rel> τ.?Q›*))
(*goals:
1. ‹⋀Ψ P Q R. ⟦(Ψ, P, Q) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ ⊳ Q ∼ R⟧ ⟹ (Ψ, P, ?Q4 Ψ P Q R) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›
2. ‹⋀Ψ P Q R. ⟦(Ψ, P, Q) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ ⊳ Q ∼ R⟧ ⟹ Ψ ⊳ ?Q4 Ψ P Q R ∼ R›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
moreover have "⋀Ψ P Q Ψ'. ⟦(Ψ, P, Q) ∈ ?Z; Ψ ≃ Ψ'⟧ ⟹ (Ψ', P, Q) ∈ ?Z"
apply simp
(*goal: ‹⋀Ψ P Q Ψ'. ⟦(Ψ, P, Q) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ ≃ Ψ'⟧ ⟹ (Ψ', P, Q) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›*)
by (blast intro: statEqWeakBisim (*‹⟦?Ψ ⊳ ?P ≈ ?Q; ?Ψ ≃ ?Ψ'⟧ ⟹ ?Ψ' ⊳ ?P ≈ ?Q›*) statEqBisim (*‹⟦?Ψ ⊳ ?P ∼ ?Q; ?Ψ ≃ ?Ψ'⟧ ⟹ ?Ψ' ⊳ ?P ∼ ?Q›*))
ultimately have "Ψ ⊳ P ↝⇩w<?Z> τ.(P)"
apply (rule weakSimWeakenSim (*‹⟦?Ψ ⊳ ?P ↝<?Rel> ?Q; ⋀Ψ' R S Ψ''. ⟦(Ψ', R, S) ∈ ?Rel; Ψ' ≃ Ψ''⟧ ⟹ (Ψ'', R, S) ∈ ?Rel⟧ ⟹ ?Ψ ⊳ ?P ↝⇩w<?Rel> ?Q›*))
(*goals:
1. ‹⋀(Ψ'::'b) (R::('a, 'b, 'c) psi) (S::('a, 'b, 'c) psi) Ψ''::'b. ⟦(Ψ', R, S) ∈ {(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, P, τ.P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ' ≃ Ψ''⟧ ⟹ ((?Ψ4::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ 'b ⇒ 'b) Ψ' R S Ψ'', R, S) ∈ {(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, P, τ.P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›
2. ‹⋀(Ψ'::'b) (R::('a, 'b, 'c) psi) (S::('a, 'b, 'c) psi) Ψ''::'b. ⟦(Ψ', R, S) ∈ {(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, P, τ.P) |(Ψ::'b) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ' ≃ Ψ''⟧ ⟹ (?Ψ4::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ 'b ⇒ 'b) Ψ' R S Ψ'' ≃ Ψ''›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
}
ultimately show "?thesis"
(*goal: ‹Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›*)
by auto
qed
next
(*goals:
1. ‹⋀Ψ P Q Ψ'. (Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ⟹ (Ψ ⊗ Ψ', P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim›
2. ‹⋀Ψ P Q. (Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ⟹ (Ψ, Q, P) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim›*)
case (cExt Ψ P Q Ψ') (*‹(Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True}›*)
thus "?case"
(*goal: ‹(Ψ ⊗ Ψ', P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim›*)
by auto
next
(*goal: ‹⋀Ψ P Q. (Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ⟹ (Ψ, Q, P) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim›*)
case (cSym Ψ P Q) (*‹(Ψ, P, Q) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True}›*)
thus "?case"
(*goal: ‹(Ψ, Q, P) ∈ {(Ψ, τ.P, P) |Ψ P. True} ∪ {(Ψ, P, τ.P) |Ψ P. True} ∪ weakenBisim›*)
by auto
qed
thus "?thesis"
(*goal: ‹Ψ ⊳ τ.P ≈ P›*)
by simp
qed
lemma tauLaw3:
fixes Ψ :: 'b
and α :: "'a prefix"
and P :: "('a, 'b, 'c) psi"
shows "Ψ ⊳ α⋅(τ.(P)) ≈ α⋅P"
proof (-)
(*goal: ‹Ψ ⊳ α⋅(τ.P) ≈ α⋅P›*)
let ?X = "({(Ψ, α⋅(τ.(P)), α⋅P) | Ψ α P. True})"
let ?Y = "({(Ψ, α⋅P, α⋅(τ.(P))) | Ψ α P. True})"
have "(Ψ, α⋅(τ.(P)), α⋅P) ∈ ?X ∪ ?Y"
by blast
moreover have "eqvt(?X ∪ ?Y)"
by (fastforce simp add: eqvt_def (*‹eqvt ?X ≡ ∀x∈?X. ∀p. p ∙ x ∈ ?X›*) simp add: eqvts (*‹?p ∙ ?α⋅?P = (?p ∙ ?α)⋅(?p ∙ ?P)› ‹?p ∙ τ.?P = τ.(?p ∙ ?P)› ‹?p ∙ nameTerm ?x = nameTerm (?p ∙ ?x)› ‹?p1 ∙ (?Ψ1 ⊳ ?P1 ∼⇩s ?Q1) = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ∼⇩s ?p1 ∙ ?Q1› ‹?Ψ ⊳ ?P ∼⇩s ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼⇩s ?p ∙ ?Q› ‹?p1 ∙ ?Ψ1 : ?Q1 ⊳ ?P1 ⟹?α1 ≺ ?P'1 = ?p1 ∙ ?Ψ1 : ?p1 ∙ ?Q1 ⊳ ?p1 ∙ ?P1 ⟹?p1 ∙ ?α1 ≺ ?p1 ∙ ?P'1› ‹?Ψ : ?Q ⊳ ?P ⟹?α ≺ ?P' ⟹ ?p ∙ ?Ψ : ?p ∙ ?Q ⊳ ?p ∙ ?P ⟹?p ∙ ?α ≺ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇧^⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇧^⇩τ ?p1 ∙ ?P'1› ‹?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇩τ ?p1 ∙ ?P'1› and more 127 facts*))
ultimately have "Ψ ⊳ α⋅(τ.(P)) ≈⇩w α⋅P"
proof (coinduct rule: weakenTransitiveCoinduct)
(*goals:
1. ‹⋀Ψ P Q. (Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ⟹ Ψ ⊳ P ⪅⇩w<({(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim)> Q›
2. ‹⋀Ψ P Q. (Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ⟹ Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›
3. ‹⋀Ψ P Q Ψ'. (Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ⟹ (Ψ ⊗ Ψ', P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim›
4. ‹⋀Ψ P Q. (Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ⟹ (Ψ, Q, P) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim›*)
case (cStatImp Ψ P Q) (*‹(Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True}›*)
show "?case"
(*goal: ‹Ψ ⊳ P ⪅⇩w<({(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim)> Q›*)
proof (cases "(Ψ, P, Q) ∈ ?X")
(*goals:
1. ‹(Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ⟹ Ψ ⊳ P ⪅⇩w<({(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim)> Q›
2. ‹(Ψ, P, Q) ∉ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ⟹ Ψ ⊳ P ⪅⇩w<({(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim)> Q›*)
case True (*‹(Ψ::'b, P::('a, 'b, 'c) psi, Q::('a, 'b, 'c) psi) ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True}›*)
{
fix Ψ and α and P
have "⋀Ψ'. (Ψ ⊗ Ψ', α⋅(τ.(P)), α⋅P) ∈ ?X ∪ ?Y ∪ weakenBisim"
by auto
hence "Ψ ⊳ α⋅(τ.(P)) ⪅<(?X ∪ ?Y ∪ weakenBisim)> α⋅P"
by (rule tauLaw3StatImpLeft (*‹(⋀Ψ'. (?Ψ ⊗ Ψ', ?α⋅(τ.?P), ?α⋅?Q) ∈ ?Rel) ⟹ ?Ψ ⊳ ?α⋅(τ.?P) ⪅<?Rel> ?α⋅?Q›*))
moreover have "⋀Ψ P Q Ψ'. ⟦(Ψ, P, Q) ∈ ?X ∪ ?Y ∪ weakenBisim; Ψ ≃ Ψ'⟧ ⟹ (Ψ', P, Q) ∈ ?X ∪ ?Y ∪ weakenBisim"
by (fastforce intro: statEqWeakBisim (*‹⟦?Ψ ⊳ ?P ≈ ?Q; ?Ψ ≃ ?Ψ'⟧ ⟹ ?Ψ' ⊳ ?P ≈ ?Q›*))
ultimately have "Ψ ⊳ α⋅(τ.(P)) ⪅⇩w<(?X ∪ ?Y ∪ weakenBisim)> α⋅P"
apply (rule weakStatImpWeakenStatImp (*‹⟦?Ψ ⊳ ?P ⪅<?Rel> ?Q; ⋀Ψ' R S Ψ''. ⟦(Ψ', R, S) ∈ ?Rel; Ψ' ≃ Ψ''⟧ ⟹ (Ψ'', R, S) ∈ ?Rel⟧ ⟹ ?Ψ ⊳ ?P ⪅⇩w<?Rel> ?Q›*))
(*goals:
1. ‹⋀Ψ' R S Ψ''. ⟦(Ψ', R, S) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim; Ψ' ≃ Ψ''⟧ ⟹ (?Ψ4 Ψ' R S Ψ'', R, S) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim›
2. ‹⋀Ψ' R S Ψ''. ⟦(Ψ', R, S) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim; Ψ' ≃ Ψ''⟧ ⟹ ?Ψ4 Ψ' R S Ψ'' ≃ Ψ''›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
}
with ‹(Ψ, P, Q) ∈ ?X› (*‹(Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True}›*) show "?thesis"
(*goal: ‹Ψ ⊳ P ⪅⇩w<({(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim)> Q›*)
by blast
next
(*goal: ‹(Ψ, P, Q) ∉ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ⟹ Ψ ⊳ P ⪅⇩w<({(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim)> Q›*)
case False (*‹(Ψ, P, Q) ∉ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True}›*)
{
fix Ψ and α and P
have "⋀Ψ'. (Ψ ⊗ Ψ', α⋅P, α⋅(τ.(P))) ∈ ?X ∪ ?Y ∪ weakenBisim"
by auto
hence "Ψ ⊳ α⋅P ⪅<(?X ∪ ?Y ∪ weakenBisim)> α⋅(τ.(P))"
by (rule tauLaw3StatImpRight (*‹(⋀Ψ'. (?Ψ ⊗ Ψ', ?α⋅?P, ?α⋅(τ.?Q)) ∈ ?Rel) ⟹ ?Ψ ⊳ ?α⋅?P ⪅<?Rel> ?α⋅(τ.?Q)›*))
moreover have "⋀Ψ P Q Ψ'. ⟦(Ψ, P, Q) ∈ ?X ∪ ?Y ∪ weakenBisim; Ψ ≃ Ψ'⟧ ⟹ (Ψ', P, Q) ∈ ?X ∪ ?Y ∪ weakenBisim"
by (fastforce intro: statEqWeakBisim (*‹⟦?Ψ ⊳ ?P ≈ ?Q; ?Ψ ≃ ?Ψ'⟧ ⟹ ?Ψ' ⊳ ?P ≈ ?Q›*))
ultimately have "Ψ ⊳ α⋅P ⪅⇩w<(?X ∪ ?Y ∪ weakenBisim)> α⋅(τ.(P))"
apply (rule weakStatImpWeakenStatImp (*‹⟦?Ψ ⊳ ?P ⪅<?Rel> ?Q; ⋀Ψ' R S Ψ''. ⟦(Ψ', R, S) ∈ ?Rel; Ψ' ≃ Ψ''⟧ ⟹ (Ψ'', R, S) ∈ ?Rel⟧ ⟹ ?Ψ ⊳ ?P ⪅⇩w<?Rel> ?Q›*))
(*goals:
1. ‹⋀(Ψ'::'b::fs_name) (R::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) (S::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) Ψ''::'b::fs_name. ⟦(Ψ', R, S) ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b::fs_name) (α::'a::fs_name prefix) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b::fs_name) (α::'a::fs_name prefix) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True} ∪ weakenBisim; Ψ' ≃ Ψ''⟧ ⟹ ((?Ψ4::'b::fs_name ⇒ ('a::fs_name, 'b::fs_name, 'c::fs_name) psi ⇒ ('a::fs_name, 'b::fs_name, 'c::fs_name) psi ⇒ 'b::fs_name ⇒ 'b::fs_name) Ψ' R S Ψ'', R, S) ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b::fs_name) (α::'a::fs_name prefix) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b::fs_name) (α::'a::fs_name prefix) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True} ∪ weakenBisim›
2. ‹⋀(Ψ'::'b::fs_name) (R::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) (S::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) Ψ''::'b::fs_name. ⟦(Ψ', R, S) ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b::fs_name) (α::'a::fs_name prefix) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b::fs_name) (α::'a::fs_name prefix) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True} ∪ weakenBisim; Ψ' ≃ Ψ''⟧ ⟹ (?Ψ4::'b::fs_name ⇒ ('a::fs_name, 'b::fs_name, 'c::fs_name) psi ⇒ ('a::fs_name, 'b::fs_name, 'c::fs_name) psi ⇒ 'b::fs_name ⇒ 'b::fs_name) Ψ' R S Ψ'' ≃ Ψ''›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
}
moreover from ‹(Ψ, P, Q) ∉ ?X› (*‹(Ψ, P, Q) ∉ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True}›*) ‹(Ψ, P, Q) ∈ ?X ∪ ?Y› (*‹(Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True}›*) have "(Ψ, P, Q) ∈ ?Y"
by blast
ultimately show "?thesis"
(*goal: ‹Ψ ⊳ P ⪅⇩w<({(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim)> Q›*)
by auto
qed
next
(*goals:
1. ‹⋀Ψ P Q. (Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ⟹ Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›
2. ‹⋀Ψ P Q Ψ'. (Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ⟹ (Ψ ⊗ Ψ', P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim›
3. ‹⋀Ψ P Q. (Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ⟹ (Ψ, Q, P) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim›*)
case (cSim Ψ P Q) (*‹(Ψ::'b::fs_name, P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi, Q::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b::fs_name) (α::'a::fs_name prefix) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b::fs_name) (α::'a::fs_name prefix) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True}›*)
let ?Z = "{(Ψ, P, Q) | Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ ?X ∪ ?Y ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}"
have "eqvt ?Z"
apply (clarsimp simp add: eqvt_def (*‹eqvt (?X::?'a::fs_name set) ≡ ∀x::?'a::fs_name∈?X. ∀p::(name × name) list. p ∙ x ∈ ?X›*))
(*goal: ‹eqvt {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›*)
apply (elim disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹⋀a aa b P' p Q'. ⟦a ⊳ aa ∼ P'; a ⊳ Q' ∼ b; ∃α P. P' = α⋅(τ.P) ∧ Q' = α⋅P⟧ ⟹ ∃P'. p ∙ a ⊳ p ∙ aa ∼ P' ∧ (∃Q'. ((∃α P. P' = α⋅(τ.P) ∧ Q' = α⋅P) ∨ (∃α P. P' = α⋅P ∧ Q' = α⋅(τ.P)) ∨ p ∙ a ⊳ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)›
2. ‹⋀a aa b P' p Q'. ⟦a ⊳ aa ∼ P'; a ⊳ Q' ∼ b; ∃α P. P' = α⋅P ∧ Q' = α⋅(τ.P)⟧ ⟹ ∃P'. p ∙ a ⊳ p ∙ aa ∼ P' ∧ (∃Q'. ((∃α P. P' = α⋅(τ.P) ∧ Q' = α⋅P) ∨ (∃α P. P' = α⋅P ∧ Q' = α⋅(τ.P)) ∨ p ∙ a ⊳ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)›
3. ‹⋀a aa b P' p Q'. ⟦a ⊳ aa ∼ P'; a ⊳ Q' ∼ b; a ⊳ P' ≈ Q'⟧ ⟹ ∃P'. p ∙ a ⊳ p ∙ aa ∼ P' ∧ (∃Q'. ((∃α P. P' = α⋅(τ.P) ∧ Q' = α⋅P) ∨ (∃α P. P' = α⋅P ∧ Q' = α⋅(τ.P)) ∨ p ∙ a ⊳ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)›
discuss goal 1*)
apply (rule_tac x="p ∙ P'" in exI (*‹?P ?x ⟹ ∃x. ?P x›*))
(*top goal: ‹⋀a aa b P' p Q'. ⟦a ⊳ aa ∼ P'; a ⊳ Q' ∼ b; ∃α P. P' = α⋅(τ.P) ∧ Q' = α⋅P⟧ ⟹ ∃P'. p ∙ a ⊳ p ∙ aa ∼ P' ∧ (∃Q'. ((∃α P. P' = α⋅(τ.P) ∧ Q' = α⋅P) ∨ (∃α P. P' = α⋅P ∧ Q' = α⋅(τ.P)) ∨ p ∙ a ⊳ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)› and 2 goals remain*)
apply (clarsimp simp add: bisimClosed (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼ ?p ∙ ?Q›*) eqvts (*‹?p ∙ ?α⋅?P = (?p ∙ ?α)⋅(?p ∙ ?P)› ‹?p ∙ τ.?P = τ.(?p ∙ ?P)› ‹?p ∙ nameTerm ?x = nameTerm (?p ∙ ?x)› ‹?p1 ∙ (?Ψ1 ⊳ ?P1 ∼⇩s ?Q1) = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ∼⇩s ?p1 ∙ ?Q1› ‹?Ψ ⊳ ?P ∼⇩s ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼⇩s ?p ∙ ?Q› ‹?p1 ∙ ?Ψ1 : ?Q1 ⊳ ?P1 ⟹?α1 ≺ ?P'1 = ?p1 ∙ ?Ψ1 : ?p1 ∙ ?Q1 ⊳ ?p1 ∙ ?P1 ⟹?p1 ∙ ?α1 ≺ ?p1 ∙ ?P'1› ‹?Ψ : ?Q ⊳ ?P ⟹?α ≺ ?P' ⟹ ?p ∙ ?Ψ : ?p ∙ ?Q ⊳ ?p ∙ ?P ⟹?p ∙ ?α ≺ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇧^⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇧^⇩τ ?p1 ∙ ?P'1› ‹?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇩τ ?p1 ∙ ?P'1› and more 127 facts*))
(*top goal: ‹⋀a aa b P' p Q'. ⟦a ⊳ aa ∼ P'; a ⊳ Q' ∼ b; ∃α P. P' = α⋅(τ.P) ∧ Q' = α⋅P⟧ ⟹ p ∙ a ⊳ p ∙ aa ∼ p ∙ P' ∧ (∃Q'. ((∃α P. p ∙ P' = α⋅(τ.P) ∧ Q' = α⋅P) ∨ (∃α P. p ∙ P' = α⋅P ∧ Q' = α⋅(τ.P)) ∨ p ∙ a ⊳ p ∙ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)› and 2 goals remain*)
apply (blast intro: bisimClosed (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼ ?p ∙ ?Q›*) eqvts (*‹?p ∙ ?α⋅?P = (?p ∙ ?α)⋅(?p ∙ ?P)› ‹?p ∙ τ.?P = τ.(?p ∙ ?P)› ‹?p ∙ nameTerm ?x = nameTerm (?p ∙ ?x)› ‹?p1 ∙ (?Ψ1 ⊳ ?P1 ∼⇩s ?Q1) = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ∼⇩s ?p1 ∙ ?Q1› ‹?Ψ ⊳ ?P ∼⇩s ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼⇩s ?p ∙ ?Q› ‹?p1 ∙ ?Ψ1 : ?Q1 ⊳ ?P1 ⟹?α1 ≺ ?P'1 = ?p1 ∙ ?Ψ1 : ?p1 ∙ ?Q1 ⊳ ?p1 ∙ ?P1 ⟹?p1 ∙ ?α1 ≺ ?p1 ∙ ?P'1› ‹?Ψ : ?Q ⊳ ?P ⟹?α ≺ ?P' ⟹ ?p ∙ ?Ψ : ?p ∙ ?Q ⊳ ?p ∙ ?P ⟹?p ∙ ?α ≺ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇧^⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇧^⇩τ ?p1 ∙ ?P'1› ‹?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇩τ ?p1 ∙ ?P'1› and more 127 facts*))
(*discuss goal 2*)
apply (rule_tac x="p ∙ P'" in exI (*‹?P ?x ⟹ ∃x. ?P x›*))
(*top goal: ‹⋀(a::'b) (aa::('a, 'b, 'c) psi) (b::('a, 'b, 'c) psi) (P'::('a, 'b, 'c) psi) (p::(name × name) list) Q'::('a, 'b, 'c) psi. ⟦a ⊳ aa ∼ P'; a ⊳ Q' ∼ b; ∃(α::'a prefix) P::('a, 'b, 'c) psi. P' = α⋅P ∧ Q' = α⋅(τ.P)⟧ ⟹ ∃P'::('a, 'b, 'c) psi. p ∙ a ⊳ p ∙ aa ∼ P' ∧ (∃Q'::('a, 'b, 'c) psi. ((∃(α::'a prefix) P::('a, 'b, 'c) psi. P' = α⋅(τ.P) ∧ Q' = α⋅P) ∨ (∃(α::'a prefix) P::('a, 'b, 'c) psi. P' = α⋅P ∧ Q' = α⋅(τ.P)) ∨ p ∙ a ⊳ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)› and 1 goal remains*)
apply (clarsimp simp add: bisimClosed (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼ ?p ∙ ?Q›*) eqvts (*‹?p ∙ ?α⋅?P = (?p ∙ ?α)⋅(?p ∙ ?P)› ‹?p ∙ τ.?P = τ.(?p ∙ ?P)› ‹?p ∙ nameTerm ?x = nameTerm (?p ∙ ?x)› ‹?p1 ∙ (?Ψ1 ⊳ ?P1 ∼⇩s ?Q1) = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ∼⇩s ?p1 ∙ ?Q1› ‹?Ψ ⊳ ?P ∼⇩s ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼⇩s ?p ∙ ?Q› ‹?p1 ∙ ?Ψ1 : ?Q1 ⊳ ?P1 ⟹?α1 ≺ ?P'1 = ?p1 ∙ ?Ψ1 : ?p1 ∙ ?Q1 ⊳ ?p1 ∙ ?P1 ⟹?p1 ∙ ?α1 ≺ ?p1 ∙ ?P'1› ‹?Ψ : ?Q ⊳ ?P ⟹?α ≺ ?P' ⟹ ?p ∙ ?Ψ : ?p ∙ ?Q ⊳ ?p ∙ ?P ⟹?p ∙ ?α ≺ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇧^⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇧^⇩τ ?p1 ∙ ?P'1› ‹?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇩τ ?p1 ∙ ?P'1› and more 127 facts*))
(*top goal: ‹⋀a aa b P' p Q'. ⟦a ⊳ aa ∼ P'; a ⊳ Q' ∼ b; ∃α P. P' = α⋅P ∧ Q' = α⋅(τ.P)⟧ ⟹ p ∙ a ⊳ p ∙ aa ∼ p ∙ P' ∧ (∃Q'. ((∃α P. p ∙ P' = α⋅(τ.P) ∧ Q' = α⋅P) ∨ (∃α P. p ∙ P' = α⋅P ∧ Q' = α⋅(τ.P)) ∨ p ∙ a ⊳ p ∙ P' ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b)› and 1 goal remains*)
apply (rule_tac x="p ∙ (α⋅(τ.(P)))" in exI (*‹?P ?x ⟹ ∃x. ?P x›*))
(*top goal: ‹⋀a aa b p α P. ⟦a ⊳ aa ∼ α⋅P; a ⊳ α⋅(τ.P) ∼ b⟧ ⟹ ∃Q'. ((∃α' Pa. (p ∙ α)⋅(p ∙ P) = α'⋅(τ.Pa) ∧ Q' = α'⋅Pa) ∨ (∃α' Pa. (p ∙ α)⋅(p ∙ P) = α'⋅Pa ∧ Q' = α'⋅(τ.Pa)) ∨ p ∙ a ⊳ (p ∙ α)⋅(p ∙ P) ≈ Q') ∧ p ∙ a ⊳ Q' ∼ p ∙ b› and 1 goal remains*)
apply (clarsimp simp add: eqvts (*‹?p ∙ ?α⋅?P = (?p ∙ ?α)⋅(?p ∙ ?P)› ‹?p ∙ τ.?P = τ.(?p ∙ ?P)› ‹?p ∙ nameTerm ?x = nameTerm (?p ∙ ?x)› ‹?p1 ∙ (?Ψ1 ⊳ ?P1 ∼⇩s ?Q1) = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ∼⇩s ?p1 ∙ ?Q1› ‹?Ψ ⊳ ?P ∼⇩s ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼⇩s ?p ∙ ?Q› ‹?p1 ∙ ?Ψ1 : ?Q1 ⊳ ?P1 ⟹?α1 ≺ ?P'1 = ?p1 ∙ ?Ψ1 : ?p1 ∙ ?Q1 ⊳ ?p1 ∙ ?P1 ⟹?p1 ∙ ?α1 ≺ ?p1 ∙ ?P'1› ‹?Ψ : ?Q ⊳ ?P ⟹?α ≺ ?P' ⟹ ?p ∙ ?Ψ : ?p ∙ ?Q ⊳ ?p ∙ ?P ⟹?p ∙ ?α ≺ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇧^⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇧^⇩τ ?p1 ∙ ?P'1› ‹?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇩τ ?p1 ∙ ?P'1› and more 127 facts*))
(*top goal: ‹⋀a aa b p α P. ⟦a ⊳ aa ∼ α⋅P; a ⊳ α⋅(τ.P) ∼ b⟧ ⟹ ((∃α' Pa. (p ∙ α)⋅(p ∙ P) = α'⋅(τ.Pa) ∧ p ∙ α⋅(τ.P) = α'⋅Pa) ∨ (∃α' Pa. (p ∙ α)⋅(p ∙ P) = α'⋅Pa ∧ p ∙ α⋅(τ.P) = α'⋅(τ.Pa)) ∨ p ∙ a ⊳ (p ∙ α)⋅(p ∙ P) ≈ p ∙ α⋅(τ.P)) ∧ p ∙ a ⊳ p ∙ α⋅(τ.P) ∼ p ∙ b› and 1 goal remains*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⋀a aa b p α P. ⟦a ⊳ aa ∼ α⋅P; a ⊳ α⋅(τ.P) ∼ b⟧ ⟹ (∃α' Pa. (p ∙ α)⋅(p ∙ P) = α'⋅(τ.Pa) ∧ (p ∙ α)⋅(τ.(p ∙ P)) = α'⋅Pa) ∨ (∃α' Pa. (p ∙ α)⋅(p ∙ P) = α'⋅Pa ∧ (p ∙ α)⋅(τ.(p ∙ P)) = α'⋅(τ.Pa)) ∨ p ∙ a ⊳ (p ∙ α)⋅(p ∙ P) ≈ (p ∙ α)⋅(τ.(p ∙ P))›
2. ‹⋀a aa b p α P. ⟦a ⊳ aa ∼ α⋅P; a ⊳ α⋅(τ.P) ∼ b⟧ ⟹ p ∙ a ⊳ (p ∙ α)⋅(τ.(p ∙ P)) ∼ p ∙ b›
discuss goal 1*)
apply (rule disjI2 (*‹?Q::bool ⟹ (?P::bool) ∨ ?Q›*))
(*top goal: ‹⋀a aa b p α P. ⟦a ⊳ aa ∼ α⋅P; a ⊳ α⋅(τ.P) ∼ b⟧ ⟹ (∃α' Pa. (p ∙ α)⋅(p ∙ P) = α'⋅(τ.Pa) ∧ (p ∙ α)⋅(τ.(p ∙ P)) = α'⋅Pa) ∨ (∃α' Pa. (p ∙ α)⋅(p ∙ P) = α'⋅Pa ∧ (p ∙ α)⋅(τ.(p ∙ P)) = α'⋅(τ.Pa)) ∨ p ∙ a ⊳ (p ∙ α)⋅(p ∙ P) ≈ (p ∙ α)⋅(τ.(p ∙ P))› and 2 goals remain*)
apply (blast intro: bisimClosed (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼ ?p ∙ ?Q›*) eqvts (*‹?p ∙ ?α⋅?P = (?p ∙ ?α)⋅(?p ∙ ?P)› ‹?p ∙ τ.?P = τ.(?p ∙ ?P)› ‹?p ∙ nameTerm ?x = nameTerm (?p ∙ ?x)› ‹?p1 ∙ (?Ψ1 ⊳ ?P1 ∼⇩s ?Q1) = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ∼⇩s ?p1 ∙ ?Q1› ‹?Ψ ⊳ ?P ∼⇩s ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼⇩s ?p ∙ ?Q› ‹?p1 ∙ ?Ψ1 : ?Q1 ⊳ ?P1 ⟹?α1 ≺ ?P'1 = ?p1 ∙ ?Ψ1 : ?p1 ∙ ?Q1 ⊳ ?p1 ∙ ?P1 ⟹?p1 ∙ ?α1 ≺ ?p1 ∙ ?P'1› ‹?Ψ : ?Q ⊳ ?P ⟹?α ≺ ?P' ⟹ ?p ∙ ?Ψ : ?p ∙ ?Q ⊳ ?p ∙ ?P ⟹?p ∙ ?α ≺ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇧^⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇧^⇩τ ?p1 ∙ ?P'1› ‹?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇩τ ?p1 ∙ ?P'1› and more 127 facts*))
(*discuss goal 2*)
apply (drule_tac p=p in bisimClosed (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼ ?p ∙ ?Q›*))
(*top goal: ‹⋀a aa b p α P. ⟦a ⊳ aa ∼ α⋅P; a ⊳ α⋅(τ.P) ∼ b⟧ ⟹ p ∙ a ⊳ (p ∙ α)⋅(τ.(p ∙ P)) ∼ p ∙ b› and 1 goal remains*)
apply (drule_tac p=p in bisimClosed (*‹(?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ∼ (?Q::('a, 'b, 'c) psi) ⟹ (?p::(name × name) list) ∙ ?Ψ ⊳ ?p ∙ ?P ∼ ?p ∙ ?Q›*))
(*top goal: ‹⋀a aa b p α P. ⟦a ⊳ α⋅(τ.P) ∼ b; p ∙ a ⊳ p ∙ aa ∼ p ∙ α⋅P⟧ ⟹ p ∙ a ⊳ (p ∙ α)⋅(τ.(p ∙ P)) ∼ p ∙ b› and 1 goal remains*)
apply (simp add: eqvts (*‹?p ∙ ?α⋅?P = (?p ∙ ?α)⋅(?p ∙ ?P)› ‹?p ∙ τ.?P = τ.(?p ∙ ?P)› ‹?p ∙ nameTerm ?x = nameTerm (?p ∙ ?x)› ‹?p1 ∙ (?Ψ1 ⊳ ?P1 ∼⇩s ?Q1) = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ∼⇩s ?p1 ∙ ?Q1› ‹?Ψ ⊳ ?P ∼⇩s ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼⇩s ?p ∙ ?Q› ‹?p1 ∙ ?Ψ1 : ?Q1 ⊳ ?P1 ⟹?α1 ≺ ?P'1 = ?p1 ∙ ?Ψ1 : ?p1 ∙ ?Q1 ⊳ ?p1 ∙ ?P1 ⟹?p1 ∙ ?α1 ≺ ?p1 ∙ ?P'1› ‹?Ψ : ?Q ⊳ ?P ⟹?α ≺ ?P' ⟹ ?p ∙ ?Ψ : ?p ∙ ?Q ⊳ ?p ∙ ?P ⟹?p ∙ ?α ≺ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇧^⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇧^⇩τ ?p1 ∙ ?P'1› ‹?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇩τ ?p1 ∙ ?P'1› and more 127 facts*))
(*proven 2 subgoals*)
(*discuss goal 3*)
apply (blast dest: bisimClosed (*‹(?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ∼ (?Q::('a, 'b, 'c) psi) ⟹ (?p::(name × name) list) ∙ ?Ψ ⊳ ?p ∙ ?P ∼ ?p ∙ ?Q›*) weakBisimClosed (*‹(?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ≈ (?Q::('a, 'b, 'c) psi) ⟹ (?p::(name × name) list) ∙ ?Ψ ⊳ ?p ∙ ?P ≈ ?p ∙ ?Q›*))
(*proven 3 subgoals*) .
show "?case"
(*goal: ‹Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›*)
proof (cases "(Ψ, P, Q) ∈ ?X")
(*goals:
1. ‹(Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ⟹ Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›
2. ‹(Ψ, P, Q) ∉ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ⟹ Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›*)
case True (*‹(Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True}›*)
note ‹(Ψ, P, Q) ∈ ?X› (*‹(Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True}›*)
moreover {
fix Ψ and P and α
note ‹eqvt ?Z› (*‹eqvt {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›*)
moreover have "(Ψ, P, P) ∈ ?Z"
using weakenBisimEqWeakBisim (*‹weakenBisim = weakBisim›*) by (blast intro: weakBisimReflexive (*‹?Ψ ⊳ ?P ≈ ?P›*) bisimReflexive (*‹?Ψ ⊳ ?P ∼ ?P›*))
moreover have "⋀xvec Tvec. length xvec = length Tvec ⟹ (Ψ, P[xvec::=Tvec], P[xvec::=Tvec]) ∈ ?Z"
using weakenBisimEqWeakBisim (*‹weakenBisim = weakBisim›*) by (blast intro: weakBisimReflexive (*‹?Ψ ⊳ ?P ≈ ?P›*) bisimReflexive (*‹?Ψ ⊳ ?P ∼ ?P›*))
moreover have "⋀Ψ P Q R S. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ ?Z; Ψ ⊳ R ∼ S⟧ ⟹ (Ψ, P, S) ∈ ?Z"
by (blast intro: bisimTransitive (*‹⟦?Ψ ⊳ ?P ∼ ?Q; ?Ψ ⊳ ?Q ∼ ?R⟧ ⟹ ?Ψ ⊳ ?P ∼ ?R›*))
moreover have "⋀Ψ P Q Ψ'. (Ψ, P, Q) ∈ ?Z ⟹ (Ψ ⊗ Ψ', P, Q) ∈ ?Z"
by (blast dest: weakenBisimE( (*‹?Ψ ⊳ ?P ≈⇩w ?Q ⟹ ?Ψ ⊗ ?Ψ' ⊳ ?P ≈⇩w ?Q›*) 3) bisimE( (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?Ψ ⊗ ?Ψ' ⊳ ?P ∼ ?Q›*) 3))
ultimately have "Ψ ⊳ α⋅(τ.(P)) ↝<?Z> α⋅P"
apply (rule tauLaw3SimLeft (*‹⟦eqvt (?Rel::('b::fs_name × ('a::fs_name, 'b::fs_name, 'c::fs_name) psi × ('a::fs_name, 'b::fs_name, 'c::fs_name) psi) set); (?Ψ::'b::fs_name, ?P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi, ?Q::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) ∈ ?Rel; ⋀(xvec::name list) Tvec::'a::fs_name list. length xvec = length Tvec ⟹ (?Ψ, ?P[xvec::=Tvec], ?Q[xvec::=Tvec]) ∈ ?Rel; ⋀(Ψ::'b::fs_name) (P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) (Q::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) (R::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) S::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ ?Rel; Ψ ⊳ R ∼ S⟧ ⟹ (Ψ, P, S) ∈ ?Rel; ⋀(Ψ::'b::fs_name) (P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) (Q::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) Ψ'::'b::fs_name. (Ψ, P, Q) ∈ ?Rel ⟹ (Ψ ⊗ Ψ', P, Q) ∈ ?Rel⟧ ⟹ ?Ψ ⊳ (?α::'a::fs_name prefix)⋅(τ.?P) ↝<?Rel> ?α⋅?Q›*))
(*goals:
1. ‹⋀(xvec::name list) Tvec::'a list. length xvec = length Tvec ⟹ length xvec = length Tvec›
2. ‹⋀(Ψ::'b) (P::('a, 'b, 'c) psi) (Q::('a, 'b, 'c) psi) (R::('a, 'b, 'c) psi) S::('a, 'b, 'c) psi. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ {(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ ⊳ R ∼ S⟧ ⟹ Ψ ⊳ P ∼ (?Q8::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi) Ψ P Q R S›
3. ‹⋀(Ψ::'b) (P::('a, 'b, 'c) psi) (Q::('a, 'b, 'c) psi) (R::('a, 'b, 'c) psi) S::('a, 'b, 'c) psi. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ {(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ ⊳ R ∼ S⟧ ⟹ (Ψ, (?Q8::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi) Ψ P Q R S, (?R8::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi) Ψ P Q R S) ∈ {(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›
4. ‹⋀(Ψ::'b) (P::('a, 'b, 'c) psi) (Q::('a, 'b, 'c) psi) (R::('a, 'b, 'c) psi) S::('a, 'b, 'c) psi. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ {(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ ⊳ R ∼ S⟧ ⟹ Ψ ⊳ (?R8::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi) Ψ P Q R S ∼ S›
5. ‹⋀(Ψ::'b) (P::('a, 'b, 'c) psi) (Q::('a, 'b, 'c) psi) Ψ'::'b. (Ψ, P, Q) ∈ {(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q} ⟹ (Ψ, P, Q) ∈ {(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*)
apply ((assumption)[1])
(*discuss goal 3*)
apply ((assumption)[1])
(*discuss goal 4*)
apply ((assumption)[1])
(*discuss goal 5*) .
(*proven 5 subgoals*)
moreover have "⋀Ψ P Q Ψ'. ⟦(Ψ, P, Q) ∈ ?Z; Ψ ≃ Ψ'⟧ ⟹ (Ψ', P, Q) ∈ ?Z"
apply simp
(*goal: ‹⋀Ψ P Q Ψ'. ⟦(Ψ, P, Q) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ ≃ Ψ'⟧ ⟹ (Ψ', P, Q) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›*)
by (blast dest: statEqWeakBisim (*‹⟦?Ψ ⊳ ?P ≈ ?Q; ?Ψ ≃ ?Ψ'⟧ ⟹ ?Ψ' ⊳ ?P ≈ ?Q›*) statEqBisim (*‹⟦?Ψ ⊳ ?P ∼ ?Q; ?Ψ ≃ ?Ψ'⟧ ⟹ ?Ψ' ⊳ ?P ∼ ?Q›*))
ultimately have "Ψ ⊳ α⋅(τ.(P)) ↝⇩w<?Z> α⋅P"
apply (rule weakSimWeakenSim (*‹⟦?Ψ ⊳ ?P ↝<?Rel> ?Q; ⋀Ψ' R S Ψ''. ⟦(Ψ', R, S) ∈ ?Rel; Ψ' ≃ Ψ''⟧ ⟹ (Ψ'', R, S) ∈ ?Rel⟧ ⟹ ?Ψ ⊳ ?P ↝⇩w<?Rel> ?Q›*))
(*goals:
1. ‹⋀(Ψ'::'b) (R::('a, 'b, 'c) psi) (S::('a, 'b, 'c) psi) Ψ''::'b. ⟦(Ψ', R, S) ∈ {(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ' ≃ Ψ''⟧ ⟹ ((?Ψ4::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ 'b ⇒ 'b) Ψ' R S Ψ'', R, S) ∈ {(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›
2. ‹⋀(Ψ'::'b) (R::('a, 'b, 'c) psi) (S::('a, 'b, 'c) psi) Ψ''::'b. ⟦(Ψ', R, S) ∈ {(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ' ≃ Ψ''⟧ ⟹ (?Ψ4::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ 'b ⇒ 'b) Ψ' R S Ψ'' ≃ Ψ''›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
}
ultimately show "?thesis"
(*goal: ‹Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›*)
by auto
next
(*goal: ‹(Ψ, P, Q) ∉ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ⟹ Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›*)
case False (*‹(Ψ, P, Q) ∉ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True}›*)
from ‹(Ψ, P, Q) ∉ ?X› (*‹(Ψ, P, Q) ∉ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True}›*) ‹(Ψ, P, Q) ∈ ?X ∪ ?Y› (*‹(Ψ::'b, P::('a, 'b, 'c) psi, Q::('a, 'b, 'c) psi) ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True}›*) have "(Ψ, P, Q) ∈ ?Y"
by blast
moreover {
fix Ψ and P and α
note ‹eqvt ?Z› (*‹eqvt {(Ψ, P, Q) |(Ψ::'b::fs_name) (P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) Q::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. ∃(P'::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) Q'::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b::fs_name) (α::'a::fs_name prefix) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b::fs_name) (α::'a::fs_name prefix) P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›*)
moreover have "⋀Ψ xvec Tvec. length xvec=length Tvec ⟹ (Ψ, P[xvec::=Tvec], τ.(P[xvec::=Tvec])) ∈ ?Z"
apply simp
(*goal: ‹⋀Ψ xvec Tvec. length xvec = length Tvec ⟹ (Ψ, P[xvec::=Tvec], τ.P[xvec::=Tvec]) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›*)
by (blast intro: weakBisimE( (*‹?Ψ ⊳ ?P ≈ ?Q ⟹ ?Ψ ⊳ ?Q ≈ ?P›*) 4) bisimReflexive (*‹?Ψ ⊳ ?P ∼ ?P›*) tauLaw1 (*‹?Ψ ⊳ τ.?P ≈ ?P›*))
moreover have "⋀Ψ P Q R S. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ ?Z; Ψ ⊳ R ∼ S⟧ ⟹ (Ψ, P, S) ∈ ?Z"
by (blast intro: bisimTransitive (*‹⟦?Ψ ⊳ ?P ∼ ?Q; ?Ψ ⊳ ?Q ∼ ?R⟧ ⟹ ?Ψ ⊳ ?P ∼ ?R›*))
moreover have "⋀Ψ. (Ψ, P, τ.(P)) ∈ ?Z"
apply simp
(*goal: ‹⋀Ψ. (Ψ, P, τ.P) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›*)
by (blast intro: weakBisimE( (*‹?Ψ ⊳ ?P ≈ ?Q ⟹ ?Ψ ⊳ ?Q ≈ ?P›*) 4) bisimReflexive (*‹?Ψ ⊳ ?P ∼ ?P›*) tauLaw1 (*‹?Ψ ⊳ τ.?P ≈ ?P›*))
ultimately have "Ψ ⊳ α⋅P ↝<?Z> α⋅(τ.(P))"
apply (rule tauLaw3SimRight (*‹⟦eqvt ?Rel; ⋀Ψ xvec Tvec. length xvec = length Tvec ⟹ (Ψ, ?P[xvec::=Tvec], τ.?Q[xvec::=Tvec]) ∈ ?Rel; ⋀Ψ P Q R S. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ ?Rel; Ψ ⊳ R ∼ S⟧ ⟹ (Ψ, P, S) ∈ ?Rel; ⋀Ψ. (Ψ, ?P, τ.?Q) ∈ ?Rel⟧ ⟹ ?Ψ ⊳ ?α⋅?P ↝<?Rel> ?α⋅(τ.?Q)›*))
(*goals:
1. ‹⋀Ψ xvec Tvec. length xvec = length Tvec ⟹ length xvec = length Tvec›
2. ‹⋀Ψ P Q R S. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ ⊳ R ∼ S⟧ ⟹ Ψ ⊳ P ∼ ?Q8 Ψ P Q R S›
3. ‹⋀Ψ P Q R S. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ ⊳ R ∼ S⟧ ⟹ (Ψ, ?Q8 Ψ P Q R S, ?R8 Ψ P Q R S) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›
4. ‹⋀Ψ P Q R S. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ ⊳ R ∼ S⟧ ⟹ Ψ ⊳ ?R8 Ψ P Q R S ∼ S›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*)
apply ((assumption)[1])
(*discuss goal 3*)
apply ((assumption)[1])
(*discuss goal 4*) .
(*proven 4 subgoals*)
moreover have "⋀Ψ P Q Ψ'. ⟦(Ψ, P, Q) ∈ ?Z; Ψ ≃ Ψ'⟧ ⟹ (Ψ', P, Q) ∈ ?Z"
apply simp
(*goal: ‹⋀(Ψ::'b) (P::('a, 'b, 'c) psi) (Q::('a, 'b, 'c) psi) Ψ'::'b. ⟦(Ψ, P, Q) ∈ {(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ ≃ Ψ'⟧ ⟹ (Ψ', P, Q) ∈ {(Ψ, P, Q) |(Ψ::'b) (P::('a, 'b, 'c) psi) Q::('a, 'b, 'c) psi. ∃(P'::('a, 'b, 'c) psi) Q'::('a, 'b, 'c) psi. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›*)
by (blast dest: statEqWeakBisim (*‹⟦?Ψ ⊳ ?P ≈ ?Q; ?Ψ ≃ ?Ψ'⟧ ⟹ ?Ψ' ⊳ ?P ≈ ?Q›*) statEqBisim (*‹⟦?Ψ ⊳ ?P ∼ ?Q; ?Ψ ≃ ?Ψ'⟧ ⟹ ?Ψ' ⊳ ?P ∼ ?Q›*))
ultimately have "Ψ ⊳ α⋅P ↝⇩w<?Z> α⋅(τ.(P))"
apply (rule weakSimWeakenSim (*‹⟦?Ψ ⊳ ?P ↝<?Rel> ?Q; ⋀Ψ' R S Ψ''. ⟦(Ψ', R, S) ∈ ?Rel; Ψ' ≃ Ψ''⟧ ⟹ (Ψ'', R, S) ∈ ?Rel⟧ ⟹ ?Ψ ⊳ ?P ↝⇩w<?Rel> ?Q›*))
(*goals:
1. ‹⋀Ψ' R S Ψ''. ⟦(Ψ', R, S) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ' ≃ Ψ''⟧ ⟹ (?Ψ4 Ψ' R S Ψ'', R, S) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}›
2. ‹⋀Ψ' R S Ψ''. ⟦(Ψ', R, S) ∈ {(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}; Ψ' ≃ Ψ''⟧ ⟹ ?Ψ4 Ψ' R S Ψ'' ≃ Ψ''›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
}
ultimately show "?thesis"
(*goal: ‹Ψ ⊳ P ↝⇩w<{(Ψ, P, Q) |Ψ P Q. ∃P' Q'. Ψ ⊳ P ∼ P' ∧ (Ψ, P', Q') ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim ∧ Ψ ⊳ Q' ∼ Q}> Q›*)
by auto
qed
next
(*goals:
1. ‹⋀Ψ P Q Ψ'. (Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ⟹ (Ψ ⊗ Ψ', P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim›
2. ‹⋀Ψ P Q. (Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ⟹ (Ψ, Q, P) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim›*)
case (cExt Ψ P Q Ψ') (*‹(Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True}›*)
thus "?case"
(*goal: ‹(Ψ ⊗ Ψ', P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim›*)
by auto
next
(*goal: ‹⋀Ψ P Q. (Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ⟹ (Ψ, Q, P) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True} ∪ weakenBisim›*)
case (cSym Ψ P Q) (*‹(Ψ, P, Q) ∈ {(Ψ, α⋅(τ.P), α⋅P) |Ψ α P. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |Ψ α P. True}›*)
thus "?case"
(*goal: ‹(Ψ::'b, Q::('a, 'b, 'c) psi, P::('a, 'b, 'c) psi) ∈ {(Ψ, α⋅(τ.P), α⋅P) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ {(Ψ, α⋅P, α⋅(τ.P)) |(Ψ::'b) (α::'a prefix) P::('a, 'b, 'c) psi. True} ∪ weakenBisim›*)
by blast
qed
thus "?thesis"
(*goal: ‹(Ψ::'b) ⊳ (α::'a prefix)⋅(τ.(P::('a, 'b, 'c) psi)) ≈ α⋅P›*)
by simp
qed
lemma tauLaw3PsiCong:
fixes Ψ :: 'b
and P :: "('a, 'b, 'c) psi"
shows "Ψ ⊳ α⋅(τ.(P)) ≐ α⋅P"
proof (induct rule: weakPsiCongI (*‹⟦?Ψ ⊳ ?P ≈ ?Q; ?Ψ ⊳ ?P ↝«weakBisim» ?Q; ?Ψ ⊳ ?Q ↝«weakBisim» ?P⟧ ⟹ ?Ψ ⊳ ?P ≐ ?Q›*))
(*goals:
1. ‹Ψ ⊳ α⋅(τ.P) ≈ α⋅P›
2. ‹Ψ ⊳ α⋅(τ.P) ↝«weakBisim» α⋅P›
3. ‹Ψ ⊳ α⋅P ↝«weakBisim» α⋅(τ.P)›*)
case cWeakBisim (*no hyothesis introduced yet*)
show "?case"
(*goal: ‹(Ψ::'b) ⊳ (α::'a prefix)⋅(τ.(P::('a, 'b, 'c) psi)) ≈ α⋅P›*)
by (rule tauLaw3 (*‹?Ψ ⊳ ?α⋅(τ.?P) ≈ ?α⋅?P›*))
next
(*goals:
1. ‹Ψ ⊳ α⋅(τ.P) ↝«weakBisim» α⋅P›
2. ‹Ψ ⊳ α⋅P ↝«weakBisim» α⋅(τ.P)›*)
case cSimLeft (*no hyothesis introduced yet*)
have "Ψ ⊳ P ≈ P"
by (rule weakBisimReflexive (*‹?Ψ ⊳ ?P ≈ ?P›*))
moreover have "⋀Ψ P Q R S. ⟦Ψ ⊳ P ∼ Q; Ψ ⊳ Q ≈ R; Ψ ⊳ R ∼ S⟧ ⟹ Ψ ⊳ P ≈ S"
by (blast intro: weakBisimTransitive (*‹⟦?Ψ ⊳ ?P ≈ ?Q; ?Ψ ⊳ ?Q ≈ ?R⟧ ⟹ ?Ψ ⊳ ?P ≈ ?R›*) strongBisimWeakBisim (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?Ψ ⊳ ?P ≈ ?Q›*))
ultimately show "?case"
(*goal: ‹Ψ ⊳ α⋅(τ.P) ↝«weakBisim» α⋅P›*)
using weakBisimE(3) (*‹?Ψ ⊳ ?P ≈ ?Q ⟹ ?Ψ ⊗ ?Ψ' ⊳ ?P ≈ ?Q›*) apply (rule tauLaw3CongSimLeft (*‹⟦(?Ψ, ?P, ?Q) ∈ ?Rel; ⋀Ψ P Q R S. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ ?Rel; Ψ ⊳ R ∼ S⟧ ⟹ (Ψ, P, S) ∈ ?Rel; ⋀Ψ P Q Ψ'. (Ψ, P, Q) ∈ ?Rel ⟹ (Ψ ⊗ Ψ', P, Q) ∈ ?Rel⟧ ⟹ ?Ψ ⊳ ?α⋅(τ.?P) ↝«?Rel» ?α⋅?Q›*))
(*goals:
1. ‹⋀Ψ P Q R S. ⟦Ψ ⊳ P ∼ Q; Ψ ⊳ Q ≈ R; Ψ ⊳ R ∼ S⟧ ⟹ Ψ ⊳ P ∼ ?Q2 Ψ P Q R S›
2. ‹⋀Ψ P Q R S. ⟦Ψ ⊳ P ∼ Q; Ψ ⊳ Q ≈ R; Ψ ⊳ R ∼ S⟧ ⟹ Ψ ⊳ ?Q2 Ψ P Q R S ≈ ?R2 Ψ P Q R S›
3. ‹⋀Ψ P Q R S. ⟦Ψ ⊳ P ∼ Q; Ψ ⊳ Q ≈ R; Ψ ⊳ R ∼ S⟧ ⟹ Ψ ⊳ ?R2 Ψ P Q R S ∼ S›
4. ‹⋀Ψ P Q Ψ'. Ψ ⊳ P ≈ Q ⟹ Ψ ⊳ P ≈ Q›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*)
apply ((assumption)[1])
(*discuss goal 3*)
apply ((assumption)[1])
(*discuss goal 4*) .
(*proven 4 subgoals*)
next
(*goal: ‹Ψ ⊳ α⋅P ↝«weakBisim» α⋅(τ.P)›*)
case cSimRight (*no hyothesis introduced yet*)
have "Ψ ⊳ P ≈ P"
by (rule weakBisimReflexive (*‹?Ψ ⊳ ?P ≈ ?P›*))
moreover have "⋀Ψ P Q R S. ⟦Ψ ⊳ P ∼ Q; Ψ ⊳ Q ≈ R; Ψ ⊳ R ∼ S⟧ ⟹ Ψ ⊳ P ≈ S"
by (blast intro: weakBisimTransitive (*‹⟦?Ψ ⊳ ?P ≈ ?Q; ?Ψ ⊳ ?Q ≈ ?R⟧ ⟹ ?Ψ ⊳ ?P ≈ ?R›*) strongBisimWeakBisim (*‹?Ψ ⊳ ?P ∼ ?Q ⟹ ?Ψ ⊳ ?P ≈ ?Q›*))
ultimately show "?case"
(*goal: ‹(Ψ::'b::fs_name) ⊳ (α::'a::fs_name prefix)⋅(P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) ↝«weakBisim» α⋅(τ.P)›*)
using tauLaw1[THEN weakBisimE ( 4 )] (*‹?Ψ ⊳ ?Q ≈ τ.?Q›*) apply (rule tauLaw3CongSimRight (*‹⟦(?Ψ, ?P, ?Q) ∈ ?Rel; ⋀Ψ P Q R S. ⟦Ψ ⊳ P ∼ Q; (Ψ, Q, R) ∈ ?Rel; Ψ ⊳ R ∼ S⟧ ⟹ (Ψ, P, S) ∈ ?Rel; ⋀Ψ. (Ψ, ?P, τ.?Q) ∈ ?Rel⟧ ⟹ ?Ψ ⊳ ?α⋅?P ↝«?Rel» ?α⋅(τ.?Q)›*))
(*goals:
1. ‹⋀(Ψ::'b) (P::('a, 'b, 'c) psi) (Q::('a, 'b, 'c) psi) (R::('a, 'b, 'c) psi) S::('a, 'b, 'c) psi. ⟦Ψ ⊳ P ∼ Q; Ψ ⊳ Q ≈ R; Ψ ⊳ R ∼ S⟧ ⟹ Ψ ⊳ P ∼ (?Q3::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi) Ψ P Q R S›
2. ‹⋀(Ψ::'b) (P::('a, 'b, 'c) psi) (Q::('a, 'b, 'c) psi) (R::('a, 'b, 'c) psi) S::('a, 'b, 'c) psi. ⟦Ψ ⊳ P ∼ Q; Ψ ⊳ Q ≈ R; Ψ ⊳ R ∼ S⟧ ⟹ Ψ ⊳ (?Q3::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi) Ψ P Q R S ≈ (?R3::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi) Ψ P Q R S›
3. ‹⋀(Ψ::'b) (P::('a, 'b, 'c) psi) (Q::('a, 'b, 'c) psi) (R::('a, 'b, 'c) psi) S::('a, 'b, 'c) psi. ⟦Ψ ⊳ P ∼ Q; Ψ ⊳ Q ≈ R; Ψ ⊳ R ∼ S⟧ ⟹ Ψ ⊳ (?R3::'b ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi) Ψ P Q R S ∼ S›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*)
apply ((assumption)[1])
(*discuss goal 3*) .
(*proven 3 subgoals*)
qed
lemma tauLaw3Cong:
fixes Ψ :: 'b
and P :: "('a, 'b, 'c) psi"
shows "α⋅(τ.(P)) ≐⇩c α⋅P"
proof (induct rule: weakCongI (*‹(⋀Ψ σ. wellFormedSubst σ ⟹ Ψ ⊳ ?P[<σ>] ≐ ?Q[<σ>]) ⟹ ?P ≐⇩c ?Q›*))
(*goal: ‹⋀Ψ σ. wellFormedSubst σ ⟹ Ψ ⊳ α⋅(τ.P)[<σ>] ≐ α⋅P[<σ>]›*)
case (cWeakPsiCong Ψ σ) (*‹wellFormedSubst σ›*)
show "?case"
(*goal: ‹Ψ ⊳ α⋅(τ.P)[<σ>] ≐ α⋅P[<σ>]›*)
proof (nominal_induct α rule: prefix.strong_inducts)
(*goals:
1. ‹⋀a1 list a2. Ψ ⊳ pInput a1 list a2⋅(τ.P)[<σ>] ≐ pInput a1 list a2⋅P[<σ>]›
2. ‹⋀a1 a2. Ψ ⊳ pOutput a1 a2⋅(τ.P)[<σ>] ≐ pOutput a1 a2⋅P[<σ>]›
3. ‹Ψ ⊳ pTau⋅(τ.P)[<σ>] ≐ pTau⋅P[<σ>]›*)
next
(*goals:
1. ‹⋀a1 list a2. Ψ ⊳ pInput a1 list a2⋅(τ.P)[<σ>] ≐ pInput a1 list a2⋅P[<σ>]›
2. ‹⋀a1 a2. Ψ ⊳ pOutput a1 a2⋅(τ.P)[<σ>] ≐ pOutput a1 a2⋅P[<σ>]›
3. ‹Ψ ⊳ pTau⋅(τ.P)[<σ>] ≐ pTau⋅P[<σ>]›*)
case (pInput M yvec N) (*no hyothesis introduced yet*)
obtain p where "set p ⊆ set yvec × set(p ∙ yvec)" and "(p ∙ yvec) ♯* N" and "(p ∙ yvec) ♯* P" and "(p ∙ yvec) ♯* σ"
(*goal: ‹(⋀p. ⟦set p ⊆ set yvec × set (p ∙ yvec); (p ∙ yvec) ♯* N; (p ∙ yvec) ♯* P; (p ∙ yvec) ♯* σ⟧ ⟹ thesis) ⟹ thesis›*)
apply (rule_tac xvec=yvec and c="(N, P, σ)" in name_list_avoiding (*‹(⋀pi. ⟦(pi ∙ ?xvec) ♯* ?c; distinctPerm pi; set pi ⊆ set ?xvec × set (pi ∙ ?xvec)⟧ ⟹ ?thesis) ⟹ ?thesis›*))
(*goal: ‹(⋀p. ⟦set p ⊆ set yvec × set (p ∙ yvec); (p ∙ yvec) ♯* N; (p ∙ yvec) ♯* P; (p ∙ yvec) ♯* σ⟧ ⟹ thesis) ⟹ thesis›*)
by auto
thus "?case"
(*goal: ‹Ψ ⊳ pInput M yvec N⋅(τ.P)[<σ>] ≐ pInput M yvec N⋅P[<σ>]›*)
using ‹wellFormedSubst σ› (*‹wellFormedSubst σ›*) tauLaw3PsiCong[where α = "pInput (substTerm.seqSubst M σ) (p ∙ yvec) (substTerm.seqSubst (p ∙ N) σ)"] (*‹(?Ψ::'b) ⊳ pInput ((M::'a)[<(σ::(name list × 'a list) list)>]) ((p::(name × name) list) ∙ (yvec::name list)) ((p ∙ (N::'a))[<σ>])⋅(τ.(?P::('a, 'b, 'c) psi)) ≐ pInput (M[<σ>]) (p ∙ yvec) ((p ∙ N)[<σ>])⋅?P›*) by (simp add: inputChainAlpha' (*‹⟦(?p ∙ ?xvec) ♯* ?P; (?p ∙ ?xvec) ♯* ?N; set ?p ⊆ set ?xvec × set (?p ∙ ?xvec)⟧ ⟹ inputChain ?xvec ?N ?P = inputChain (?p ∙ ?xvec) (?p ∙ ?N) (?p ∙ ?P)›*) eqvts (*‹?p ∙ ?α⋅?P = (?p ∙ ?α)⋅(?p ∙ ?P)› ‹?p ∙ τ.?P = τ.(?p ∙ ?P)› ‹?p ∙ nameTerm ?x = nameTerm (?p ∙ ?x)› ‹?p1 ∙ (?Ψ1 ⊳ ?P1 ∼⇩s ?Q1) = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ∼⇩s ?p1 ∙ ?Q1› ‹?Ψ ⊳ ?P ∼⇩s ?Q ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ∼⇩s ?p ∙ ?Q› ‹?p1 ∙ ?Ψ1 : ?Q1 ⊳ ?P1 ⟹?α1 ≺ ?P'1 = ?p1 ∙ ?Ψ1 : ?p1 ∙ ?Q1 ⊳ ?p1 ∙ ?P1 ⟹?p1 ∙ ?α1 ≺ ?p1 ∙ ?P'1› ‹?Ψ : ?Q ⊳ ?P ⟹?α ≺ ?P' ⟹ ?p ∙ ?Ψ : ?p ∙ ?Q ⊳ ?p ∙ ?P ⟹?p ∙ ?α ≺ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p ∙ ?Ψ ⊳ ?P ⟹⇩τ ?P' = ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇧^⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇧^⇩τ ?p1 ∙ ?P'1› ‹?Ψ ⊳ ?P ⟹⇧^⇩τ ?P' ⟹ ?p ∙ ?Ψ ⊳ ?p ∙ ?P ⟹⇧^⇩τ ?p ∙ ?P'› ‹?p1 ∙ ?Ψ1 ⊳ ?P1 ⟹⇩τ ?P'1 = ?p1 ∙ ?Ψ1 ⊳ ?p1 ∙ ?P1 ⟹⇩τ ?p1 ∙ ?P'1› and more 127 facts*))
next
(*goals:
1. ‹⋀a1 a2. Ψ ⊳ pOutput a1 a2⋅(τ.P)[<σ>] ≐ pOutput a1 a2⋅P[<σ>]›
2. ‹Ψ ⊳ pTau⋅(τ.P)[<σ>] ≐ pTau⋅P[<σ>]›*)
case (pOutput M N) (*no hyothesis introduced yet*)
thus "?case"
(*goal: ‹Ψ ⊳ pOutput M N⋅(τ.P)[<σ>] ≐ pOutput M N⋅P[<σ>]›*)
using ‹wellFormedSubst σ› (*‹wellFormedSubst σ›*) tauLaw3PsiCong[where α = "pOutput (substTerm.seqSubst M σ) (substTerm.seqSubst N σ)"] (*‹?Ψ ⊳ pOutput (M[<σ>]) (N[<σ>])⋅(τ.?P) ≐ pOutput (M[<σ>]) (N[<σ>])⋅?P›*) by simp
next
(*goal: ‹Ψ ⊳ pTau⋅(τ.P)[<σ>] ≐ pTau⋅P[<σ>]›*)
case pTau (*no hyothesis introduced yet*)
thus "?case"
(*goal: ‹Ψ ⊳ pTau⋅(τ.P)[<σ>] ≐ pTau⋅P[<σ>]›*)
using ‹wellFormedSubst σ› (*‹wellFormedSubst (σ::(name list × 'a::fs_name list) list)›*) tauLaw3PsiCong[where α = "pTau"] (*‹(?Ψ::'b) ⊳ pTau⋅(τ.(?P::('a, 'b, 'c) psi)) ≐ pTau⋅?P›*) by simp
qed
qed
end
end
| {
"path": "afp-2025-02-12/thys/Psi_Calculi/Tau_Laws_Weak.thy",
"repo": "afp-2025-02-12",
"sha": "94a5d1af9f5b8ce9fdc5c34e23e437845ae23a328434426ce94a52904b8fd798"
} |
(* Title: thys/DitherTM.thy
Author: Jian Xu, Xingyuan Zhang, and Christian Urban
Modifications: Sebastiaan Joosten
Further contributions by Franz Regensburger (FABR) 02/2022 :
* Re-ordering of sections;
Now, the dithering machine is discussed before the tm_copy machine
* Added comments
Editorial note FABR:
this file was part of the theory file Uncomputable.thy
in the original AFP entry.
*)
section ‹A Variation of the theme due to Boolos, Burgess and, Jeffrey›
text ‹In sections \ref{sec_K1_H1} and \ref{sec_K1_v} we discussed two variants of the proof
of the undecidability of the Sepcial Halting Problem. There, we used the Turing Machines
@{term "tm_semi_id_eq0"} and @{term "tm_semi_id_gt0"} for the construction a contradiction.
The machine @{term "tm_semi_id_gt0"} is identical to the machine {\em dither}, which is discussed
in length together with the Turing Machine {\em copy} in the book
by Boolos, Burgess, and Jeffrey~\<^cite>‹"Boolos07"›.
For backwards compatibility with the original AFP entry, we again present the formalization of
the machines{\em dither} and {\em copy} here in this section.
This allows for reuse of theory CopyTM, which in turn is referenced
in the original proof about the existence of an uncomputable function in theory
TuringUnComputable\_H2\_original.
In addition we present an enhanced version in theory TuringUnComputable\_H2, which is in
line with the principles of Conservative Extension.
›
subsection ‹The Dithering Turing Machine›
(*
The machine tm_dither
terminates on: Oc ↑ n with result Oc ↑ n for 1 < n
loops on: [] which is the empty input
loops on: Oc ↑ 1 which is the numeral <0>
*)
text ‹
If the input is empty or the numeral $<\!0\!>$,
the {\em Dithering} TM will loop forever,
otherwise it will terminate.
›
theory DitherTM
imports Turing_Hoare
begin
(* Cleanup the global simpset for proofs of several theorems about tm_dither *)
declare adjust.simps[simp del]
declare seq_tm.simps [simp del]
declare shift.simps[simp del]
declare composable_tm.simps[simp del]
declare step.simps[simp del]
declare steps.simps[simp del]
definition tm_dither :: "instr list"
where
"tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]"
(* ------ Important properties used in subsequent theories ------ *)
(* The dithering machine is well-formed *)
lemma composable_tm0_tm_dither[intro, simp]: "composable_tm0 tm_dither"
by (auto simp: composable_tm.simps (*‹composable_tm (?p::(action × nat) list, ?off::nat) = ((2::nat) ≤ length ?p ∧ is_even (length ?p) ∧ (∀(a::action, s::nat)∈set ?p. s ≤ length ?p div (2::nat) + ?off ∧ ?off ≤ s))›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1::nat), (R, 2::nat), (L, 1::nat), (L, 0::nat)]›*))
lemma tm_dither_loops_aux:
"(steps0 (1, Bk ↑ m, [Oc]) tm_dither stp = (1, Bk ↑ m, [Oc])) ∨
(steps0 (1, Bk ↑ m, [Oc]) tm_dither stp = (2, Oc # Bk ↑ m, []))"
apply (induct stp)
(*goals:
1. ‹steps0 (1, Bk ↑ m, [Oc]) tm_dither 0 = (1, Bk ↑ m, [Oc]) ∨ steps0 (1, Bk ↑ m, [Oc]) tm_dither 0 = (2, Oc # Bk ↑ m, [])›
2. ‹⋀stp. steps0 (1, Bk ↑ m, [Oc]) tm_dither stp = (1, Bk ↑ m, [Oc]) ∨ steps0 (1, Bk ↑ m, [Oc]) tm_dither stp = (2, Oc # Bk ↑ m, []) ⟹ steps0 (1, Bk ↑ m, [Oc]) tm_dither (Suc stp) = (1, Bk ↑ m, [Oc]) ∨ steps0 (1, Bk ↑ m, [Oc]) tm_dither (Suc stp) = (2, Oc # Bk ↑ m, [])›
discuss goal 1*)
apply ((auto simp: steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]›*) numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*))[1])
(*discuss goal 2*)
apply ((auto simp: steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]›*) numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*))[1])
(*proven 2 subgoals*) .
lemma tm_dither_loops_aux':
"(steps0 (1, Bk ↑ m, [Oc] @ Bk ↑ n) tm_dither stp = (1, Bk ↑ m, [Oc] @ Bk ↑ n)) ∨
(steps0 (1, Bk ↑ m, [Oc] @ Bk ↑ n) tm_dither stp = (2, Oc # Bk ↑ m, Bk ↑ n))"
apply (induct stp)
(*goals:
1. ‹steps0 (1, Bk ↑ m, [Oc] @ Bk ↑ n) tm_dither 0 = (1, Bk ↑ m, [Oc] @ Bk ↑ n) ∨ steps0 (1, Bk ↑ m, [Oc] @ Bk ↑ n) tm_dither 0 = (2, Oc # Bk ↑ m, Bk ↑ n)›
2. ‹⋀stp. steps0 (1, Bk ↑ m, [Oc] @ Bk ↑ n) tm_dither stp = (1, Bk ↑ m, [Oc] @ Bk ↑ n) ∨ steps0 (1, Bk ↑ m, [Oc] @ Bk ↑ n) tm_dither stp = (2, Oc # Bk ↑ m, Bk ↑ n) ⟹ steps0 (1, Bk ↑ m, [Oc] @ Bk ↑ n) tm_dither (Suc stp) = (1, Bk ↑ m, [Oc] @ Bk ↑ n) ∨ steps0 (1, Bk ↑ m, [Oc] @ Bk ↑ n) tm_dither (Suc stp) = (2, Oc # Bk ↑ m, Bk ↑ n)›
discuss goal 1*)
apply ((auto simp: steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]›*) numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*))[1])
(*discuss goal 2*)
apply ((auto simp: steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]›*) numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*))[1])
(*proven 2 subgoals*) .
(* ------ Auxiliary properties for clarification ------ *)
text ‹
If the input is @{term "Oc↑1"} the {\em Dithering} TM will loop forever,
for other non-blank inputs @{term "Oc↑(n+1)"} with @{term "1 < (n::nat)"} it will
reach the final state in a standard configuration.
Please note that our short notation @{term "<n::nat>"} means @{term "Oc↑(n+1)"}
where @{term "0 ≤ (n::nat)"}.
›
lemma "<0::nat> = [Oc]" by (simp add: tape_of_nat_def (*‹<?n> ≡ Oc ↑ Suc ?n›*))
lemma "Oc↑(0+1) = [Oc]" by simp
lemma "<n::nat> = Oc↑(n+1)" by (auto simp add: tape_of_nat_def (*‹<?n> ≡ Oc ↑ Suc ?n›*))
lemma "<1::nat> = [Oc, Oc]" by (simp add: tape_of_nat_def (*‹<?n> ≡ Oc ↑ Suc ?n›*))
subsubsection ‹Dither in action.›
(* steps0 (1, [], [Oc]) tm_dither n loops forever for 0 ≤ n *)
lemma "steps0 (1, [], [Oc]) tm_dither 0 = (1, [], [Oc])" by (simp add: step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]›*))
lemma "steps0 (1, [], [Oc]) tm_dither 1 = (2, [Oc], [])" by (simp add: step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]›*))
lemma "steps0 (1, [], [Oc]) tm_dither 2 = (1, [], [Oc])" by (simp add: step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]›*))
lemma "steps0 (1, [], [Oc]) tm_dither 3 = (2, [Oc], [])" by (simp add: step.simps (*‹step (?s::nat, ?l::cell list, ?r::cell list) (?p::(action × nat) list, ?off::nat) = (let (a::action, s'::nat) = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) steps.simps (*‹steps (?c::nat × cell list × cell list) (?p::(action × nat) list × nat) (0::nat) = ?c› ‹steps (?c::nat × cell list × cell list) (?p::(action × nat) list × nat) (Suc (?n::nat)) = steps (step ?c ?p) ?p ?n›*) numeral_eqs_upto_12 (*‹(2::nat) = Suc (1::nat)› ‹(3::nat) = Suc (2::nat)› ‹(4::nat) = Suc (3::nat)› ‹(5::nat) = Suc (4::nat)› ‹(6::nat) = Suc (5::nat)› ‹(7::nat) = Suc (6::nat)› ‹(8::nat) = Suc (7::nat)› ‹(9::nat) = Suc (8::nat)› ‹(10::nat) = Suc (9::nat)› ‹(11::nat) = Suc (10::nat)› ‹(12::nat) = Suc (11::nat)›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1::nat), (R, 2::nat), (L, 1::nat), (L, 0::nat)]›*))
lemma "steps0 (1, [], [Oc]) tm_dither 4 = (1, [], [Oc])" by (simp add: step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]›*))
(* steps0 (1, [], [Oc, Oc]) tm_dither n terminates after 2 steps with final configuration "(0, [], [Oc, Oc])" *)
lemma "steps0 (1, [], [Oc, Oc]) tm_dither 0 = (1, [], [Oc, Oc])" by (simp add: step.simps (*‹step (?s::nat, ?l::cell list, ?r::cell list) (?p::(action × nat) list, ?off::nat) = (let (a::action, s'::nat) = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) steps.simps (*‹steps (?c::nat × cell list × cell list) (?p::(action × nat) list × nat) (0::nat) = ?c› ‹steps (?c::nat × cell list × cell list) (?p::(action × nat) list × nat) (Suc (?n::nat)) = steps (step ?c ?p) ?p ?n›*) numeral_eqs_upto_12 (*‹(2::nat) = Suc (1::nat)› ‹(3::nat) = Suc (2::nat)› ‹(4::nat) = Suc (3::nat)› ‹(5::nat) = Suc (4::nat)› ‹(6::nat) = Suc (5::nat)› ‹(7::nat) = Suc (6::nat)› ‹(8::nat) = Suc (7::nat)› ‹(9::nat) = Suc (8::nat)› ‹(10::nat) = Suc (9::nat)› ‹(11::nat) = Suc (10::nat)› ‹(12::nat) = Suc (11::nat)›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1::nat), (R, 2::nat), (L, 1::nat), (L, 0::nat)]›*))
lemma "steps0 (1, [], [Oc, Oc]) tm_dither 1 = (2, [Oc], [Oc])" by (simp add: step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]›*))
lemma "steps0 (1, [], [Oc, Oc]) tm_dither 2 = (0, [], [Oc, Oc])" by (simp add: step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]›*))
lemma "steps0 (1, [], [Oc, Oc]) tm_dither 3 = (0, [], [Oc, Oc])" by (simp add: step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]›*))
(* steps0 (1, [], [Oc, Oc, Oc]) tm_dither n terminates after 2 steps with final configuration "(0, [], [Oc, Oc, Oc])" *)
lemma "steps0 (1, [], [Oc, Oc, Oc]) tm_dither 0 = (1, [], [Oc, Oc, Oc])" by (simp add: step.simps (*‹step (?s::nat, ?l::cell list, ?r::cell list) (?p::(action × nat) list, ?off::nat) = (let (a::action, s'::nat) = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) steps.simps (*‹steps (?c::nat × cell list × cell list) (?p::(action × nat) list × nat) (0::nat) = ?c› ‹steps (?c::nat × cell list × cell list) (?p::(action × nat) list × nat) (Suc (?n::nat)) = steps (step ?c ?p) ?p ?n›*) numeral_eqs_upto_12 (*‹(2::nat) = Suc (1::nat)› ‹(3::nat) = Suc (2::nat)› ‹(4::nat) = Suc (3::nat)› ‹(5::nat) = Suc (4::nat)› ‹(6::nat) = Suc (5::nat)› ‹(7::nat) = Suc (6::nat)› ‹(8::nat) = Suc (7::nat)› ‹(9::nat) = Suc (8::nat)› ‹(10::nat) = Suc (9::nat)› ‹(11::nat) = Suc (10::nat)› ‹(12::nat) = Suc (11::nat)›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1::nat), (R, 2::nat), (L, 1::nat), (L, 0::nat)]›*))
lemma "steps0 (1, [], [Oc, Oc, Oc]) tm_dither 1 = (2, [Oc], [Oc, Oc])" by (simp add: step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]›*))
lemma "steps0 (1, [], [Oc, Oc, Oc]) tm_dither 2 = (0, [], [Oc, Oc, Oc])" by (simp add: step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]›*))
lemma "steps0 (1, [], [Oc, Oc, Oc]) tm_dither 3 = (0, [], [Oc, Oc, Oc])" by (simp add: step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*) tm_dither_def (*‹tm_dither ≡ [(WB, 1), (R, 2), (L, 1), (L, 0)]›*))
subsubsection ‹Proving properties of tm\_dither with Hoare rules›
text ‹Using Hoare style rules is more elegant since they allow for compositional
reasoning. Therefore, its preferable to use them, if the program that we reason about
can be decomposed appropriately.›
(* Assertions and invariants of tm_dither *)
abbreviation (input)
"tm_dither_halt_inv ≡ λtap. ∃k. tap = (Bk ↑ k, <1::nat>)"
abbreviation (input)
"tm_dither_unhalt_ass ≡ λtap. ∃k. tap = (Bk ↑ k, <0::nat>)"
lemma "<0::nat> = [Oc]" by (simp add: tape_of_nat_def (*‹<?n> ≡ Oc ↑ Suc ?n›*))
lemma tm_dither_loops:
shows "⦃tm_dither_unhalt_ass⦄ tm_dither ↑"
apply (rule Hoare_unhaltI (*‹(⋀l r n. ?P (l, r) ⟹ ¬ is_final (steps0 (1, l, r) ?p n)) ⟹ ⦃?P⦄ ?p ↑›*))
(*goal: ‹⦃λtap. ∃k. tap = (Bk ↑ k, <0>)⦄ tm_dither ↑›*)
using tm_dither_loops_aux (*‹steps0 (1, Bk ↑ ?m, [Oc]) tm_dither ?stp = (1, Bk ↑ ?m, [Oc]) ∨ steps0 (1, Bk ↑ ?m, [Oc]) tm_dither ?stp = (2, Oc # Bk ↑ ?m, [])›*) apply (auto simp add: numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*) tape_of_nat_def (*‹<?n> ≡ Oc ↑ Suc ?n›*))
(*goal: ‹⋀l r n. ∃k. (l, r) = (Bk ↑ k, <0>) ⟹ ¬ is_final (steps0 (1, l, r) tm_dither n)›*)
by (metis Suc_neq_Zero (*‹Suc ?m = 0 ⟹ ?R›*) is_final_eq (*‹is_final (?s, ?tap) = (?s = 0)›*))
lemma tm_dither_loops'':
shows "⦃λtap. ∃k l. tap = (Bk↑k, [Oc] @ Bk↑ l)⦄ tm_dither ↑"
apply (rule Hoare_unhaltI (*‹(⋀l r n. ?P (l, r) ⟹ ¬ is_final (steps0 (1, l, r) ?p n)) ⟹ ⦃?P⦄ ?p ↑›*))
(*goal: ‹⦃λtap. ∃k l. tap = (Bk ↑ k, [Oc] @ Bk ↑ l)⦄ tm_dither ↑›*)
using tm_dither_loops_aux' (*‹steps0 (1, Bk ↑ ?m, [Oc] @ Bk ↑ ?n) tm_dither ?stp = (1, Bk ↑ ?m, [Oc] @ Bk ↑ ?n) ∨ steps0 (1, Bk ↑ ?m, [Oc] @ Bk ↑ ?n) tm_dither ?stp = (2, Oc # Bk ↑ ?m, Bk ↑ ?n)›*) apply (auto simp add: numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*) tape_of_nat_def (*‹<?n> ≡ Oc ↑ Suc ?n›*))
(*goal: ‹⋀l r n. ∃k la. (l, r) = (Bk ↑ k, [Oc] @ Bk ↑ la) ⟹ ¬ is_final (steps0 (1, l, r) tm_dither n)›*)
by (metis Zero_neq_Suc (*‹0 = Suc ?m ⟹ ?R›*) is_final_eq (*‹is_final (?s, ?tap) = (?s = 0)›*))
lemma tm_dither_halts_aux:
shows "steps0 (1, Bk ↑ m, [Oc, Oc]) tm_dither 2 = (0, Bk ↑ m, [Oc, Oc])"
unfolding tm_dither_def
(*goal: ‹steps0 (1, Bk ↑ m, [Oc, Oc]) [(WB, 1), (R, 2), (L, 1), (L, 0)] 2 = (0, Bk ↑ m, [Oc, Oc])›*)
by (simp add: steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*))
lemma tm_dither_halts_aux':
shows "steps0 (1, Bk ↑ m, [Oc, Oc]@Bk ↑ n) tm_dither 2 = (0, Bk ↑ m, [Oc, Oc]@Bk ↑ n)"
unfolding tm_dither_def
(*goal: ‹steps0 (1, Bk ↑ m, [Oc, Oc] @ Bk ↑ n) [(WB, 1), (R, 2), (L, 1), (L, 0)] 2 = (0, Bk ↑ m, [Oc, Oc] @ Bk ↑ n)›*)
by (simp add: steps.simps (*‹steps ?c ?p 0 = ?c› ‹steps ?c ?p (Suc ?n) = steps (step ?c ?p) ?p ?n›*) step.simps (*‹step (?s, ?l, ?r) (?p, ?off) = (let (a, s') = fetch ?p (?s - ?off) (read ?r) in (s', update a (?l, ?r)))›*) numeral_eqs_upto_12 (*‹2 = Suc 1› ‹3 = Suc 2› ‹4 = Suc 3› ‹5 = Suc 4› ‹6 = Suc 5› ‹7 = Suc 6› ‹8 = Suc 7› ‹9 = Suc 8› ‹10 = Suc 9› ‹11 = Suc 10› ‹12 = Suc 11›*))
lemma tm_dither_halts:
shows "⦃tm_dither_halt_inv⦄ tm_dither ⦃tm_dither_halt_inv⦄"
apply (rule Hoare_haltI (*‹(⋀l r. ?P (l, r) ⟹ ∃n. is_final (steps0 (1, l, r) ?p n) ∧ ?Q holds_for steps0 (1, l, r) ?p n) ⟹ ⦃?P⦄ ?p ⦃?Q⦄›*))
(*goal: ‹⦃λtap::cell list × cell list. ∃k::nat. tap = (Bk ↑ k, <1::nat>)⦄ tm_dither ⦃λtap::cell list × cell list. ∃k::nat. tap = (Bk ↑ k, <1::nat>)⦄›*)
using tm_dither_halts_aux (*‹steps0 (1, Bk ↑ ?m, [Oc, Oc]) tm_dither 2 = (0, Bk ↑ ?m, [Oc, Oc])›*) apply (auto simp add: tape_of_nat_def (*‹<?n> ≡ Oc ↑ Suc ?n›*))
(*goal: ‹⋀l r. ∃k. (l, r) = (Bk ↑ k, <1>) ⟹ ∃n. is_final (steps0 (1, l, r) tm_dither n) ∧ (λtap. ∃k. tap = (Bk ↑ k, <1>)) holds_for steps0 (1, l, r) tm_dither n›*)
by (metis (lifting, mono_tags) holds_for.simps (*‹(?P::cell list × cell list ⇒ bool) holds_for (?s::nat, ?l::cell list, ?r::cell list) = ?P (?l, ?r)›*) is_final_eq (*‹is_final (?s::nat, ?tap::cell list × cell list) = (?s = (0::nat))›*))
lemma tm_dither_halts'':
shows "⦃ λtap. ∃k l. tap = (Bk↑ k, [Oc, Oc] @ Bk↑ l)⦄ tm_dither ⦃λtap. ∃k l. tap = (Bk↑ k, [Oc, Oc] @ Bk↑ l)⦄"
apply (rule Hoare_haltI (*‹(⋀(l::cell list) r::cell list. (?P::cell list × cell list ⇒ bool) (l, r) ⟹ ∃n::nat. is_final (steps0 (1::nat, l, r) (?p::(action × nat) list) n) ∧ (?Q::cell list × cell list ⇒ bool) holds_for steps0 (1::nat, l, r) ?p n) ⟹ ⦃?P⦄ ?p ⦃?Q⦄›*))
(*goal: ‹⦃λtap. ∃k l. tap = (Bk ↑ k, [Oc, Oc] @ Bk ↑ l)⦄ tm_dither ⦃λtap. ∃k l. tap = (Bk ↑ k, [Oc, Oc] @ Bk ↑ l)⦄›*)
using tm_dither_halts_aux' (*‹steps0 (1, Bk ↑ ?m, [Oc, Oc] @ Bk ↑ ?n) tm_dither 2 = (0, Bk ↑ ?m, [Oc, Oc] @ Bk ↑ ?n)›*) apply (auto simp add: tape_of_nat_def (*‹<?n> ≡ Oc ↑ Suc ?n›*))
(*goal: ‹⋀l r. ∃k la. (l, r) = (Bk ↑ k, [Oc, Oc] @ Bk ↑ la) ⟹ ∃n. is_final (steps0 (1, l, r) tm_dither n) ∧ (λtap. ∃k l. tap = (Bk ↑ k, [Oc, Oc] @ Bk ↑ l)) holds_for steps0 (1, l, r) tm_dither n›*)
by (metis (mono_tags, lifting) Suc_1 (*‹Suc 1 = 2›*) holds_for.simps (*‹?P holds_for (?s, ?l, ?r) = ?P (?l, ?r)›*) is_finalI (*‹is_final (0, ?tap)›*) numeral_1_eq_Suc_0 (*‹Numeral1 = Suc 0›*) numeral_One (*‹Numeral1 = 1›*))
end
| {
"path": "afp-2025-02-12/thys/Universal_Turing_Machine/DitherTM.thy",
"repo": "afp-2025-02-12",
"sha": "76202fdd497982426276123e432a10a05dac0a53f64cb64bc9076b30366a76fb"
} |
(* Theory: Lovasz_Local_Lemma
Author: Chelsea Edmonds *)
section ‹Lovasz Local Lemma ›
theory Lovasz_Local_Lemma
imports
Basic_Method
"HOL-Real_Asymp.Real_Asymp"
Indep_Events
Digraph_Extensions
begin
subsection ‹Random Lemmas on Product Operator ›
lemma prod_constant_ge:
fixes y :: "'b :: {comm_monoid_mult, linordered_semidom}"
assumes "card A ≤ k"
assumes "y ≥ 0" and "y < 1"
shows "(∏x∈A. y) ≥ y ^ k"
using assms (*‹card A ≤ k› ‹0 ≤ y› ‹(y::'b) < (1::'b)›*) power_decreasing (*‹⟦?n ≤ ?N; 0 ≤ ?a; ?a ≤ 1⟧ ⟹ ?a ^ ?N ≤ ?a ^ ?n›*) by fastforce
lemma (in linordered_idom) prod_mono3:
assumes "finite J" "I ⊆ J" "⋀i. i ∈ J ⟹ 0 ≤ f i" "(⋀i. i ∈ J ⟹ f i ≤ 1)"
shows "prod f J ≤ prod f I"
proof (-)
(*goal: ‹prod f J ≤ prod f I›*)
have "prod f J ≤ (∏i∈J. if i ∈ I then f i else 1)"
using assms (*‹finite (J::'b set)› ‹I ⊆ J› ‹?i1 ∈ J ⟹ 0 ≤ f ?i1› ‹?i1 ∈ J ⟹ f ?i1 ≤ 1›*) apply (intro prod_mono (*‹(⋀i. i ∈ ?A ⟹ 0 ≤ ?f i ∧ ?f i ≤ ?g i) ⟹ prod ?f ?A ≤ prod ?g ?A›*))
(*goal: ‹prod (f::'b ⇒ 'a) (J::'b set) ≤ (∏i::'b∈J. if i ∈ (I::'b set) then f i else (1::'a))›*)
by auto
also (*calculation: ‹prod (f::'b ⇒ 'a) (J::'b set) ≤ (∏i::'b∈J. if i ∈ (I::'b set) then f i else (1::'a))›*) have "… = prod f I"
using ‹finite J› (*‹finite J›*) ‹I ⊆ J› (*‹I ⊆ J›*) by (simp add: prod.If_cases (*‹finite ?A ⟹ (∏x∈?A. if ?P x then ?h x else ?g x) = prod ?h (?A ∩ {x. ?P x}) * prod ?g (?A ∩ - {x. ?P x})›*) Int_absorb1 (*‹?B ⊆ ?A ⟹ ?A ∩ ?B = ?B›*))
finally (*calculation: ‹prod f J ≤ prod f I›*) show "?thesis"
(*goal: ‹prod f J ≤ prod f I›*) .
qed
lemma bij_on_ss_image:
assumes "A ⊆ B"
assumes "bij_betw g B B'"
shows "g ` A ⊆ B'"
using assms (*‹A ⊆ B› ‹bij_betw g B B'›*) by (auto simp add: bij_betw_apply (*‹⟦bij_betw ?f ?A ?B; ?a ∈ ?A⟧ ⟹ ?f ?a ∈ ?B›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*))
lemma bij_on_ss_proper_image:
assumes "A ⊂ B"
assumes "bij_betw g B B'"
shows "g ` A ⊂ B'"
by (smt (verit, ccfv_SIG) assms (*‹A ⊂ B› ‹bij_betw g B B'›*) bij_betw_iff_bijections (*‹bij_betw ?f ?A ?B = (∃g. (∀x∈?A. ?f x ∈ ?B ∧ g (?f x) = x) ∧ (∀y∈?B. g y ∈ ?A ∧ ?f (g y) = y))›*) bij_betw_subset (*‹⟦bij_betw ?f ?A ?A'; ?B ⊆ ?A; ?f ` ?B = ?B'⟧ ⟹ bij_betw ?f ?B ?B'›*) leD (*‹?y ≤ ?x ⟹ ¬ ?x < ?y›*) psubsetD (*‹⟦?A ⊂ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) psubsetI (*‹⟦?A ⊆ ?B; ?A ≠ ?B⟧ ⟹ ?A ⊂ ?B›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*))
subsection ‹Dependency Graph Concept ›
text ‹Uses directed graphs. The pair\_digraph locale was sufficient as multi-edges are irrelevant ›
locale dependency_digraph = pair_digraph "G :: nat pair_pre_digraph" + prob_space "M :: 'a measure"
for G M + fixes F :: "nat ⇒ 'a set"
assumes vss: "F ` (pverts G) ⊆ events"
assumes mis: "⋀ i. i ∈ (pverts G) ⟹ mutual_indep_events (F i) F ((pverts G) - ({i} ∪ neighborhood i))"
begin
lemma dep_graph_indiv_nh_indep:
assumes "A ∈ pverts G" "B ∈ pverts G"
assumes "B ∉ neighborhood A"
assumes "A ≠ B"
assumes "prob (F B) ≠ 0"
shows "𝒫((F A) | (F B)) = prob (F A)"
proof (-)
(*goal: ‹𝒫(F A | F B) = prob (F A)›*)
have "B ∉ {A} ∪ neighborhood A"
using assms(3) (*‹B ∉ neighborhood A›*) assms(4) (*‹A ≠ B›*) by auto
then have "B ∈ (pverts G - ({A} ∪ neighborhood A))"
using assms(2) (*‹B ∈ pverts G›*) by auto
moreover have "mutual_indep_events (F A) F (pverts G - ({A} ∪ neighborhood A))"
using mis (*‹?i ∈ pverts G ⟹ mutual_indep_events (F ?i) F (pverts G - ({?i} ∪ neighborhood ?i))›*) assms (*‹(A::nat) ∈ pverts (G::nat pair_pre_digraph)› ‹B ∈ pverts G› ‹(B::nat) ∉ neighborhood (A::nat)› ‹A ≠ B› ‹prob (F B) ≠ 0›*) by auto
ultimately show "?thesis"
(*goal: ‹𝒫((F::nat ⇒ 'a set) (A::nat) | F (B::nat)) = prob (F A)›*)
using assms(5) (*‹prob (F B) ≠ 0›*) assms(1) (*‹(A::nat) ∈ pverts (G::nat pair_pre_digraph)›*) assms(2) (*‹B ∈ pverts G›*) vss (*‹F ` pverts G ⊆ events›*) mutual_indep_ev_cond_single (*‹⟦?A ∈ events; ?B ∈ events; mutual_indep_events ?A ?F ?I; ?B ∈ ?F ` ?I; prob ?B ≠ 0⟧ ⟹ 𝒫(?A | ?B) = prob ?A›*) by auto
qed
lemma mis_subset:
assumes "i ∈ pverts G"
assumes "A ⊆ pverts G"
shows "mutual_indep_events (F i) F (A - ({i} ∪ neighborhood i))"
proof (cases "A ⊆ ({i} ∪ neighborhood i)")
(*goals:
1. ‹A ⊆ {i} ∪ neighborhood i ⟹ mutual_indep_events (F i) F (A - ({i} ∪ neighborhood i))›
2. ‹¬ A ⊆ {i} ∪ neighborhood i ⟹ mutual_indep_events (F i) F (A - ({i} ∪ neighborhood i))›*)
case True (*‹A ⊆ {i} ∪ neighborhood i›*)
then have "A - ({i} ∪ neighborhood i) = {}"
by auto
then show "?thesis"
(*goal: ‹mutual_indep_events (F i) F (A - ({i} ∪ neighborhood i))›*)
using mutual_indep_ev_empty (*‹?A ∈ events ⟹ mutual_indep_events ?A ?F {}›*) vss (*‹F ` pverts G ⊆ events›*) assms(1) (*‹i ∈ pverts G›*) by blast
next
(*goal: ‹¬ A ⊆ {i} ∪ neighborhood i ⟹ mutual_indep_events (F i) F (A - ({i} ∪ neighborhood i))›*)
case False (*‹¬ A ⊆ {i} ∪ neighborhood i›*)
then have "A - ({i} ∪ neighborhood i) ⊆ pverts G - ({i} ∪ neighborhood i)"
using assms(2) (*‹A ⊆ pverts G›*) by auto
then show "?thesis"
(*goal: ‹mutual_indep_events (F i) F (A - ({i} ∪ neighborhood i))›*)
using mutual_indep_ev_subset (*‹⟦mutual_indep_events ?A ?F ?I; ?J ⊆ ?I⟧ ⟹ mutual_indep_events ?A ?F ?J›*) mis (*‹(?i::nat) ∈ pverts (G::nat pair_pre_digraph) ⟹ mutual_indep_events ((F::nat ⇒ 'a::type set) ?i) F (pverts G - ({?i} ∪ neighborhood ?i))›*) assms(1) (*‹i ∈ pverts G›*) by blast
qed
lemma dep_graph_indep_events:
assumes "A ⊆ pverts G"
assumes "⋀ Ai. Ai ∈ A ⟹ out_degree G Ai = 0"
shows "indep_events F A"
proof (-)
(*goal: ‹indep_events F A›*)
have "⋀ Ai. Ai ∈ A ⟹ (mutual_indep_events (F Ai) F (A - {Ai}))"
proof (-)
(*goal: ‹⋀Ai. Ai ∈ A ⟹ mutual_indep_events (F Ai) F (A - {Ai})›*)
fix Ai
assume ain: "Ai ∈ A" (*‹(Ai::nat) ∈ (A::nat set)›*)
then have "(neighborhood Ai) = {}"
using assms(2) (*‹?Ai12 ∈ A ⟹ out_degree (with_proj G) ?Ai12 = 0›*) neighborhood_empty_iff (*‹(out_degree (with_proj (G::nat pair_pre_digraph)) (?u::nat) = (0::nat)) = (neighborhood ?u = {})›*) by simp
moreover have "mutual_indep_events (F Ai) F (A - ({Ai} ∪ neighborhood Ai))"
using mis_subset[of Ai A] (*‹⟦(Ai::nat) ∈ pverts (G::nat pair_pre_digraph); (A::nat set) ⊆ pverts G⟧ ⟹ mutual_indep_events ((F::nat ⇒ 'a set) Ai) F (A - ({Ai} ∪ neighborhood Ai))›*) ain (*‹Ai ∈ A›*) assms(1) (*‹A ⊆ pverts G›*) by auto
ultimately show "mutual_indep_events (F Ai) F (A - {Ai})"
by simp
qed
then show "?thesis"
(*goal: ‹indep_events F A›*)
using mutual_indep_ev_set_all[of F A] (*‹⟦F ` A ⊆ events; ⋀i. i ∈ A ⟹ mutual_indep_events (F i) F (A - {i})⟧ ⟹ indep_events F A›*) vss (*‹F ` pverts G ⊆ events›*) by auto
qed
end
subsection ‹Lovasz Local General Lemma ›
context prob_space
begin
lemma compl_sets_index:
assumes "F ` A ⊆ events"
shows "(λ i. space M - F i) ` A ⊆ events"
proof (intro subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*))
(*goal: ‹⋀x. x ∈ (λi. space M - F i) ` A ⟹ x ∈ events›*)
fix x
assume "x ∈ (λi. space M - F i) ` A" (*‹(x::'a set) ∈ (λi::'b. space (M::'a measure) - (F::'b ⇒ 'a set) i) ` (A::'b set)›*)
then obtain i where xeq: "x = space M - F i" and "i ∈ A"
(*goal: ‹(⋀i. ⟦x = space M - F i; i ∈ A⟧ ⟹ thesis) ⟹ thesis›*)
by blast
then have "F i ∈ events"
using assms (*‹F ` A ⊆ events›*) by auto
thus "x ∈ events"
using sets.compl_sets (*‹?a ∈ sets ?M ⟹ space ?M - ?a ∈ sets ?M›*) xeq (*‹(x::'a set) = space (M::'a measure) - (F::'b ⇒ 'a set) (i::'b)›*) by simp
qed
lemma lovasz_inductive_base:
assumes "dependency_digraph G M F"
assumes "⋀ Ai . Ai ∈ A ⟹ g Ai ≥ 0 ∧ g Ai < 1"
assumes "⋀ Ai. Ai ∈ A ⟹ (prob (F Ai) ≤ (g Ai) * (∏ Aj ∈ pre_digraph.neighborhood G Ai. (1 - (g Aj))))"
assumes "Ai ∈ A"
assumes "pverts G = A"
shows "prob (F Ai) ≤ g Ai"
proof (-)
(*goal: ‹prob ((F::nat ⇒ 'a::type set) (Ai::nat)) ≤ (g::nat ⇒ real) Ai›*)
have genprod: "⋀ S. S ⊆ A ⟹ (∏Aj ∈ S . (1 - (g Aj))) ≤ 1"
using assms(2) (*‹?Ai12 ∈ A ⟹ 0 ≤ g ?Ai12 ∧ g ?Ai12 < 1›*) by (smt (verit) prod_le_1 (*‹(⋀x. x ∈ ?A ⟹ 0 ≤ ?f x ∧ ?f x ≤ 1) ⟹ prod ?f ?A ≤ 1›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*))
interpret dg: dependency_digraph G M F
using assms(1) (*‹dependency_digraph G M F›*) by simp
have "dg.neighborhood Ai ⊆ A"
using assms(3) (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ g ?Ai12 * (∏Aj∈dg.neighborhood ?Ai12. 1 - g Aj)›*) dg.neighborhood_wf (*‹dg.neighborhood (?v::nat) ⊆ pverts (G::nat pair_pre_digraph)›*) assms(5) (*‹pverts G = A›*) by simp
then show "?thesis"
(*goal: ‹prob (F Ai) ≤ g Ai›*)
using genprod (*‹?S12 ⊆ A ⟹ (∏Aj∈?S12. 1 - g Aj) ≤ 1›*) assms (*‹dependency_digraph G M F› ‹?Ai12 ∈ A ⟹ 0 ≤ g ?Ai12 ∧ g ?Ai12 < 1› ‹(?Ai12::nat) ∈ (A::nat set) ⟹ prob ((F::nat ⇒ 'a set) ?Ai12) ≤ (g::nat ⇒ real) ?Ai12 * (∏Aj::nat∈dg.neighborhood ?Ai12. (1::real) - g Aj)› ‹Ai ∈ A› ‹pverts G = A›*) mult_left_le (*‹⟦(?c::?'a) ≤ (1::?'a); (0::?'a) ≤ (?a::?'a)⟧ ⟹ ?a * ?c ≤ ?a›*) by (smt (verit))
qed
lemma lovasz_inductive_base_set:
assumes "N ⊆ A"
assumes "⋀ Ai . Ai ∈ A ⟹ g Ai ≥ 0 ∧ g Ai < 1"
assumes "⋀ Ai. Ai ∈ A ⟹ (prob (F Ai) ≤ (g Ai) * (∏ Aj ∈ N. (1 - (g Aj))))"
assumes "Ai ∈ A"
shows "prob (F Ai) ≤ g Ai"
proof (-)
(*goal: ‹prob (F Ai) ≤ g Ai›*)
have genprod: "⋀ S. S ⊆ A ⟹ (∏Aj ∈ S . (1 - (g Aj))) ≤ 1"
using assms(2) (*‹?Ai12 ∈ A ⟹ 0 ≤ g ?Ai12 ∧ g ?Ai12 < 1›*) by (smt (verit) prod_le_1 (*‹(⋀x. x ∈ ?A ⟹ 0 ≤ ?f x ∧ ?f x ≤ 1) ⟹ prod ?f ?A ≤ 1›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*))
then show "?thesis"
(*goal: ‹prob (F Ai) ≤ g Ai›*)
using genprod (*‹(?S12::'b set) ⊆ (A::'b set) ⟹ (∏Aj::'b∈?S12. (1::real) - (g::'b ⇒ real) Aj) ≤ (1::real)›*) assms (*‹N ⊆ A› ‹(?Ai12::'b) ∈ (A::'b set) ⟹ (0::real) ≤ (g::'b ⇒ real) ?Ai12 ∧ g ?Ai12 < (1::real)› ‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ g ?Ai12 * (∏Aj∈N. 1 - g Aj)› ‹Ai ∈ A›*) mult_left_le (*‹⟦?c ≤ 1; 0 ≤ ?a⟧ ⟹ ?a * ?c ≤ ?a›*) by (smt (verit))
qed
lemma split_prob_lt_helper:
assumes dep_graph: "dependency_digraph G M F"
assumes dep_graph_verts: "pverts G = A"
assumes fbounds: "⋀ i . i ∈ A ⟹ f i ≥ 0 ∧ f i < 1"
assumes prob_Ai: "⋀ Ai. Ai ∈ A ⟹ prob (F Ai) ≤
(f Ai) * (∏ Aj ∈ pre_digraph.neighborhood G Ai . (1 - (f Aj)))"
assumes aiin: "Ai ∈ A"
assumes "N ⊆ pre_digraph.neighborhood G Ai"
assumes "∃ P1 P2. 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) = P1/P2 ∧
P1 ≤ prob (F Ai)∧ P2 ≥ (∏ Aj ∈ N . (1 - (f Aj)))"
shows "𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai"
proof (-)
(*goal: ‹𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai›*)
interpret dg: dependency_digraph G M F
using assms(1) (*‹dependency_digraph G M F›*) by simp
have lt1: "⋀ Aj. Aj ∈ A ⟹ (1 - (f Aj)) ≤ 1"
using assms(3) (*‹?i12 ∈ A ⟹ 0 ≤ f ?i12 ∧ f ?i12 < 1›*) by auto
have gt0: "⋀ Aj. Aj ∈ A ⟹ (1 - (f Aj)) > 0"
using assms(3) (*‹?i12 ∈ A ⟹ 0 ≤ f ?i12 ∧ f ?i12 < 1›*) by auto
then have prodgt0: "⋀ S'. S' ⊆ A ⟹ (∏ Aj ∈ S' . (1 - f Aj)) > 0"
using prod_pos (*‹(⋀a. a ∈ ?A ⟹ 0 < ?f a) ⟹ 0 < prod ?f ?A›*) by (metis subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*))
obtain P1 and P2 where peq: "𝒫(F Ai | ⋂Aj∈S. space M - F Aj) = P1/P2" and "P1 ≤ prob (F Ai)" and p2gt: "P2 ≥ (∏ Aj ∈ N . (1 - (f Aj)))"
(*goal: ‹(⋀P1 P2. ⟦𝒫(F Ai | ⋂Aj∈S. space M - F Aj) = P1 / P2; P1 ≤ prob (F Ai); (∏Aj∈N. 1 - f Aj) ≤ P2⟧ ⟹ thesis) ⟹ thesis›*)
using assms(7) (*‹∃P1 P2. 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) = P1 / P2 ∧ P1 ≤ prob (F Ai) ∧ (∏Aj∈N. 1 - f Aj) ≤ P2›*) by auto
then have "P1 ≤ (f Ai) * (∏ Aj ∈ pre_digraph.neighborhood G Ai . (1 - (f Aj)))"
using prob_Ai (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ f ?Ai12 * (∏Aj∈dg.neighborhood ?Ai12. 1 - f Aj)›*) aiin (*‹Ai ∈ A›*) by fastforce
moreover have "P2 ≥ (∏ Aj ∈ dg.neighborhood Ai . (1 - (f Aj)))"
using assms(6) (*‹(N::nat set) ⊆ dg.neighborhood (Ai::nat)›*) gt0 (*‹(?Aj12::nat) ∈ (A::nat set) ⟹ (0::real) < (1::real) - (f::nat ⇒ real) ?Aj12›*) dg.neighborhood_wf (*‹dg.neighborhood ?v ⊆ pverts G›*) dep_graph_verts (*‹pverts G = A›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) lt1 (*‹(?Aj12::nat) ∈ (A::nat set) ⟹ (1::real) - (f::nat ⇒ real) ?Aj12 ≤ (1::real)›*) dg.neighborhood_finite (*‹finite (dg.neighborhood (?v::nat))›*) p2gt (*‹(∏Aj∈N. 1 - f Aj) ≤ P2›*) by (smt (verit, ccfv_threshold) prod_mono3 (*‹⟦finite ?J; ?I ⊆ ?J; ⋀i. i ∈ ?J ⟹ 0 ≤ ?f i; ⋀i. i ∈ ?J ⟹ ?f i ≤ 1⟧ ⟹ prod ?f ?J ≤ prod ?f ?I›*))
ultimately have "P1/P2 ≤ ((f Ai) * (∏ Aj ∈ dg.neighborhood Ai . (1 - (f Aj)))/(∏ Aj ∈ dg.neighborhood Ai . (1 - (f Aj))))"
using frac_le[of "(f Ai) * (∏ Aj ∈ dg.neighborhood Ai . (1 - (f Aj)))" "P1" "(∏ Aj ∈ dg.neighborhood Ai . (1 - (f Aj)))"] (*‹⟦(0::real) ≤ (f::nat ⇒ real) (Ai::nat) * (∏Aj::nat∈dg.neighborhood Ai. (1::real) - f Aj); (P1::real) ≤ f Ai * (∏Aj::nat∈dg.neighborhood Ai. (1::real) - f Aj); (0::real) < (∏Aj::nat∈dg.neighborhood Ai. (1::real) - f Aj); (∏Aj::nat∈dg.neighborhood Ai. (1::real) - f Aj) ≤ (?z::real)⟧ ⟹ P1 / ?z ≤ f Ai * (∏Aj::nat∈dg.neighborhood Ai. (1::real) - f Aj) / (∏Aj::nat∈dg.neighborhood Ai. (1::real) - f Aj)›*) prodgt0[of "dg.neighborhood Ai"] (*‹dg.neighborhood Ai ⊆ A ⟹ 0 < (∏Aj∈dg.neighborhood Ai. 1 - f Aj)›*) assms(3) (*‹?i12 ∈ A ⟹ 0 ≤ f ?i12 ∧ f ?i12 < 1›*) dg.neighborhood_wf[of Ai] (*‹dg.neighborhood Ai ⊆ pverts G›*) by (simp add: assms( (*‹pverts (G::nat pair_pre_digraph) = (A::nat set)›*) 2) bounded_measure (*‹prob (?A::'a set) ≤ prob (space (M::'a measure))›*) finite_measure_compl (*‹(?S::'a set) ∈ events ⟹ prob (space (M::'a measure) - ?S) = prob (space M) - prob ?S›*) assms( (*‹(Ai::nat) ∈ (A::nat set)›*) 5))
then show "?thesis"
(*goal: ‹𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai›*)
using prodgt0[of "dg.neighborhood Ai"] (*‹dg.neighborhood (Ai::nat) ⊆ (A::nat set) ⟹ (0::real) < (∏Aj::nat∈dg.neighborhood Ai. (1::real) - (f::nat ⇒ real) Aj)›*) dg.neighborhood_wf[of Ai] (*‹dg.neighborhood (Ai::nat) ⊆ pverts (G::nat pair_pre_digraph)›*) assms(2) (*‹pverts G = A›*) peq (*‹𝒫(F Ai | ⋂Aj∈S. space M - F Aj) = P1 / P2›*) by (metis divide_eq_imp (*‹⟦?c ≠ 0; ?b = ?a * ?c⟧ ⟹ ?b / ?c = ?a›*) rel_simps( (*‹¬ 0 < 0›*) 70))
qed
lemma lovasz_inequality:
assumes finS: "finite S"
assumes sevents: "F ` S ⊆ events"
assumes S_subset: "S ⊆ A - {Ai}"
assumes prob2: "prob (⋂ Aj ∈ S . (space M - (F Aj))) > 0"
assumes irange: "i ∈ {0..<card S1}"
assumes bb: "bij_betw g {0..<card S1} S1"
assumes s1_def: "S1 = (S ∩ N)"
assumes s2_def: "S2 = S - S1"
assumes ne_cond: "i > 0 ∨ S2 ≠ {}"
assumes hyps: "⋀ B. B ⊂ S ⟹ g i ∈ A ⟹ B ⊆ A - {g i} ⟹ B ≠ {} ⟹
0 < prob (⋂Aj∈B. space M - F Aj) ⟹ 𝒫(F (g i) | ⋂Aj∈B. space M - F Aj) ≤ f (g i)"
shows "𝒫((space M - F (g i)) | (⋂ ((λ i. space M - F i) ` g ` {0..<i} ∪ ((λ i. space M - F i) ` S2))))
≥ (1 - f (g i))"
proof (-)
(*goal: ‹1 - f (g i) ≤ 𝒫(space M - F (g i) | ⋂ ((λi. space M - F i) ` g ` {0..<i} ∪ (λi. space M - F i) ` S2))›*)
let ?c = "(λ i. space M - F i)"
define S1ss where "S1ss = g ` {0..<i}"
have "i ∉ {0..<i}"
by simp
moreover have "{0..<i} ⊆ {0..<card S1}"
using irange (*‹i ∈ {0..<card S1}›*) by simp
ultimately have ginotin1: "g i ∉ S1ss"
using bb (*‹bij_betw g {0..<card S1} S1›*) S1ss_def (*‹S1ss = g ` {0..<i}›*) irange (*‹(i::nat) ∈ {0::nat..<card (S1::'b set)}›*) by (smt (verit, best) bij_betw_iff_bijections (*‹bij_betw ?f ?A ?B = (∃g. (∀x∈?A. ?f x ∈ ?B ∧ g (?f x) = x) ∧ (∀y∈?B. g y ∈ ?A ∧ ?f (g y) = y))›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*))
have ginotin2: "g i ∉ S2"
unfolding s2_def
(*goal: ‹g i ∉ S - S1›*)
using irange (*‹i ∈ {0..<card S1}›*) bb (*‹bij_betw g {0..<card S1} S1›*) by (simp add: bij_betwE (*‹bij_betw (?f::?'a ⇒ ?'b) (?A::?'a set) (?B::?'b set) ⟹ ∀a::?'a∈?A. ?f a ∈ ?B›*))
have giS: "g i ∈ S"
using irange (*‹i ∈ {0..<card S1}›*) bij_betw_imp_surj_on (*‹bij_betw (?f::?'a ⇒ ?'b) (?A::?'a set) (?B::?'b set) ⟹ ?f ` ?A = ?B›*) imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*) Int_iff (*‹((?c::?'a::type) ∈ (?A::?'a::type set) ∩ (?B::?'a::type set)) = (?c ∈ ?A ∧ ?c ∈ ?B)›*) s1_def (*‹S1 = S ∩ N›*) bb (*‹bij_betw g {0..<card S1} S1›*) by blast
have "{0..<i} ⊂ {0..<card S1}"
using irange (*‹i ∈ {0..<card S1}›*) by auto
then have "S1ss ⊂ S1"
unfolding S1ss_def
(*goal: ‹g ` {0..<i} ⊂ S1›*)
using irange (*‹i ∈ {0..<card S1}›*) bb (*‹bij_betw g {0..<card S1} S1›*) bij_on_ss_proper_image (*‹⟦?A ⊂ ?B; bij_betw ?g ?B ?B'⟧ ⟹ ?g ` ?A ⊂ ?B'›*) by meson
then have sss: "S1ss ∪ S2 ⊂ S"
using s1_def (*‹S1 = S ∩ N›*) s2_def (*‹(S2::'b set) = (S::'b set) - (S1::'b set)›*) by blast
moreover have xsiin: "g i ∈ A"
using irange (*‹i ∈ {0..<card S1}›*) using giS (*‹g i ∈ S›*) S_subset (*‹S ⊆ A - {Ai}›*) by (metis DiffE (*‹⟦?c ∈ ?A - ?B; ⟦?c ∈ ?A; ?c ∉ ?B⟧ ⟹ ?P⟧ ⟹ ?P›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*))
moreover have ne: "S1ss ∪ S2 ≠ {}"
using ne_cond (*‹0 < i ∨ S2 ≠ {}›*) S1ss_def (*‹S1ss = g ` {0..<i}›*) by auto
moreover have "S1ss ∪ S2 ⊆ A - {g i}"
using S_subset (*‹S ⊆ A - {Ai}›*) sss (*‹(S1ss::'b::type set) ∪ (S2::'b::type set) ⊂ (S::'b::type set)›*) ginotin1 (*‹g i ∉ S1ss›*) ginotin2 (*‹g i ∉ S2›*) by auto
moreover have gt02: "0 < prob (⋂ (?c ` (S1ss ∪ S2)))"
using finS (*‹finite S›*) prob2 (*‹0 < prob (⋂Aj∈S. space M - F Aj)›*) sevents (*‹(F::'b ⇒ 'a set) ` (S::'b set) ⊆ events›*) prob_inter_ss_lt_index[of S ?c "S1ss ∪ S2"] (*‹⟦finite S; (λi. space M - F i) ` S ⊆ events; S1ss ∪ S2 ≠ {}; S1ss ∪ S2 ⊆ S⟧ ⟹ prob (⋂i∈S. space M - F i) ≤ prob (⋂i∈S1ss ∪ S2. space M - F i)›*) ne (*‹S1ss ∪ S2 ≠ {}›*) sss (*‹S1ss ∪ S2 ⊂ S›*) compl_sets_index[of F S] (*‹F ` S ⊆ events ⟹ (λi. space M - F i) ` S ⊆ events›*) by fastforce
ultimately have ltfAi: "𝒫(F (g i) | ⋂ (?c ` (S1ss ∪ S2))) ≤ f (g i)"
using hyps[of "S1ss ∪ S2"] (*‹⟦S1ss ∪ S2 ⊂ S; g i ∈ A; S1ss ∪ S2 ⊆ A - {g i}; S1ss ∪ S2 ≠ {}; 0 < prob (⋂Aj∈S1ss ∪ S2. space M - F Aj)⟧ ⟹ 𝒫(F (g i) | ⋂Aj∈S1ss ∪ S2. space M - F Aj) ≤ f (g i)›*) by blast
have "?c ` (S1ss ∪ S2) ⊆ events"
using sss (*‹S1ss ∪ S2 ⊂ S›*) ‹S1ss ⊂ S1› (*‹(S1ss::'b set) ⊂ (S1::'b set)›*) compl_subset_in_events (*‹?S ⊆ events ⟹ (-) (space M) ` ?S ⊆ events›*) sevents (*‹F ` S ⊆ events›*) s1_def (*‹(S1::'b set) = (S::'b set) ∩ (N::'b set)›*) s2_def (*‹S2 = S - S1›*) by fastforce
then have "⋂ (?c ` (S1ss ∪ S2)) ∈ events"
using Inter_event_ss (*‹⟦finite (?A::'a set set); ?A ⊆ events; ?A ≠ {}⟧ ⟹ ⋂ ?A ∈ events›*) sss (*‹S1ss ∪ S2 ⊂ S›*) by (meson ‹S1ss ∪ S2 ≠ {}› finite_imageI (*‹finite ?F ⟹ finite (?h ` ?F)›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) image_is_empty (*‹(?f ` ?A = {}) = (?A = {})›*) finS (*‹finite S›*) subset_iff_psubset_eq (*‹(?A ⊆ ?B) = (?A ⊂ ?B ∨ ?A = ?B)›*))
moreover have "F (g i) ∈ events"
using xsiin (*‹g i ∈ A›*) giS (*‹(g::nat ⇒ 'b) (i::nat) ∈ (S::'b set)›*) sevents (*‹(F::'b ⇒ 'a set) ` (S::'b set) ⊆ events›*) by auto
ultimately have "𝒫(?c (g i) | ⋂ (?c ` (S1ss ∪ S2))) ≥ 1 - f (g i)"
using cond_prob_neg[of "⋂ (?c ` (S1ss ∪ S2))" "F (g i)"] (*‹⟦(⋂i∈S1ss ∪ S2. space M - F i) ∈ events; F (g i) ∈ events; 0 < prob (⋂i∈S1ss ∪ S2. space M - F i)⟧ ⟹ 𝒫(space M - F (g i) | ⋂i∈S1ss ∪ S2. space M - F i) = 1 - 𝒫(F (g i) | ⋂i∈S1ss ∪ S2. space M - F i)›*) gt02 (*‹0 < prob (⋂i∈S1ss ∪ S2. space M - F i)›*) xsiin (*‹g i ∈ A›*) ltfAi (*‹𝒫(F (g i) | ⋂i∈S1ss ∪ S2. space M - F i) ≤ f (g i)›*) by simp
then show "𝒫(?c (g i) | (⋂ (?c ` g ` {0..<i} ∪ (?c ` S2)))) ≥ (1 - f (g i))"
by (simp add: S1ss_def (*‹S1ss = g ` {0..<i}›*) image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*))
qed
text ‹The main helper lemma ›
lemma lovasz_inductive:
assumes finA: "finite A"
assumes Aevents: "F ` A ⊆ events"
assumes fbounds: "⋀ i . i ∈ A ⟹ f i ≥ 0 ∧ f i < 1"
assumes dep_graph: "dependency_digraph G M F"
assumes dep_graph_verts: "pverts G = A"
assumes prob_Ai: "⋀ Ai. Ai ∈ A ⟹ prob (F Ai) ≤
(f Ai) * (∏ Aj ∈ pre_digraph.neighborhood G Ai . (1 - (f Aj)))"
assumes Ai_in: "Ai ∈ A"
assumes S_subset: "S ⊆ A - {Ai}"
assumes S_nempty: "S ≠ {}"
assumes prob2: "prob (⋂ Aj ∈ S . (space M - (F Aj))) > 0"
shows "𝒫((F Ai) | (⋂ Aj ∈ S . (space M - (F Aj)))) ≤ f Ai"
proof (-)
(*goal: ‹𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai›*)
let ?c = "λ i. space M - F i"
have ceq: "⋀ A. ?c ` A = ((-) (space M)) ` (F ` A)"
by auto
interpret dg: dependency_digraph G M F
using assms(4) (*‹dependency_digraph G M F›*) by simp
have finS: "finite S"
using assms (*‹finite (A::nat set)› ‹F ` A ⊆ events› ‹?i12 ∈ A ⟹ 0 ≤ f ?i12 ∧ f ?i12 < 1› ‹dependency_digraph G M F› ‹pverts (G::nat pair_pre_digraph) = (A::nat set)› ‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ f ?Ai12 * (∏Aj∈dg.neighborhood ?Ai12. 1 - f Aj)› ‹Ai ∈ A› ‹(S::nat set) ⊆ (A::nat set) - {Ai::nat}› ‹S ≠ {}› ‹(0::real) < prob (⋂Aj::nat∈S::nat set. space (M::'a::type measure) - (F::nat ⇒ 'a::type set) Aj)›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by (metis finite_Diff (*‹finite ?A ⟹ finite (?A - ?B)›*))
show "𝒫(( F Ai) | (⋂ Aj ∈ S . (space M - (F Aj)))) ≤ f Ai"
using finS (*‹finite S›*) Ai_in (*‹Ai ∈ A›*) S_subset (*‹S ⊆ A - {Ai}›*) S_nempty (*‹S ≠ {}›*) prob2 (*‹0 < prob (⋂Aj∈S. space M - F Aj)›*) proof (induct S arbitrary: Ai rule: finite_psubset_induct)
(*goal: ‹⋀Aa Ai. ⟦finite Aa; ⋀B Ai. ⟦B ⊂ Aa; Ai ∈ A; B ⊆ A - {Ai}; B ≠ {}; 0 < prob (⋂Aj∈B. space M - F Aj)⟧ ⟹ 𝒫(F Ai | ⋂Aj∈B. space M - F Aj) ≤ f Ai; Ai ∈ A; Aa ⊆ A - {Ai}; Aa ≠ {}; 0 < prob (⋂Aj∈Aa. space M - F Aj)⟧ ⟹ 𝒫(F Ai | ⋂Aj∈Aa. space M - F Aj) ≤ f Ai›*)
case (psubset S) (*‹finite S› ‹⟦(?B12::nat set) ⊂ (S::nat set); (?Ai12::nat) ∈ (A::nat set); ?B12 ⊆ A - {?Ai12}; ?B12 ≠ {}; (0::real) < prob (⋂Aj::nat∈?B12. space (M::'a measure) - (F::nat ⇒ 'a set) Aj)⟧ ⟹ 𝒫(F ?Ai12 | ⋂Aj::nat∈?B12. space M - F Aj) ≤ (f::nat ⇒ real) ?Ai12› ‹Ai ∈ A› ‹S ⊆ A - {Ai}› ‹(S::nat set) ≠ {}› ‹(0::real) < prob (⋂Aj::nat∈S::nat set. space (M::'a::type measure) - (F::nat ⇒ 'a::type set) Aj)›*)
define S1 where "S1 = (S ∩ dg.neighborhood Ai)"
define S2 where "S2 = S - S1"
have "⋀ s . s ∈ S2 ⟹ s ∈ A - ({Ai} ∪ dg.neighborhood Ai)"
using S1_def (*‹S1 = S ∩ dg.neighborhood Ai›*) S2_def (*‹(S2::nat set) = (S::nat set) - (S1::nat set)›*) psubset.prems(2) (*‹S ⊆ A - {Ai}›*) by blast
then have s2ssmis: "S2 ⊆ A - ({Ai} ∪ dg.neighborhood Ai)"
by auto
have sevents: "F ` S ⊆ events"
using assms(2) (*‹F ` A ⊆ events›*) psubset.prems(2) (*‹S ⊆ A - {Ai}›*) by auto
then have s1events: "F ` S1 ⊆ events"
using S1_def (*‹S1 = S ∩ dg.neighborhood Ai›*) by auto
have finS2: "finite S2" and finS1: "finite S1"
using S2_def (*‹S2 = S - S1›*) S1_def (*‹S1 = S ∩ dg.neighborhood Ai›*) apply -
(*goals:
1. ‹⟦S2 = S - S1; S1 = S ∩ dg.neighborhood Ai⟧ ⟹ finite S2›
2. ‹⟦S2 = S - S1; S1 = S ∩ dg.neighborhood Ai⟧ ⟹ finite S1›
discuss goal 1*)
apply (simp add: psubset( (*‹finite S›*) 1))
(*discuss goal 2*)
apply (simp add: psubset( (*‹finite S›*) 1))
(*proven 2 subgoals*) .
have "mutual_indep_set (F Ai) (F ` S2)"
using dg.mis[of Ai] (*‹Ai ∈ pverts G ⟹ mutual_indep_events (F Ai) F (pverts G - ({Ai} ∪ dg.neighborhood Ai))›*) mutual_indep_ev_subset (*‹⟦mutual_indep_events (?A::'a set) (?F::nat ⇒ 'a set) (?I::nat set); (?J::nat set) ⊆ ?I⟧ ⟹ mutual_indep_events ?A ?F ?J›*) s2ssmis (*‹S2 ⊆ A - ({Ai} ∪ dg.neighborhood Ai)›*) psubset.prems(1) (*‹Ai ∈ A›*) dep_graph_verts (*‹pverts G = A›*) mutual_indep_iff (*‹mutual_indep_events ?A ?F ?I = mutual_indep_set ?A (?F ` ?I)›*) by auto
then have mis2: "mutual_indep_set (F Ai) (?c ` S2)"
using mutual_indep_events_compl[of "F ` S2" "F Ai"] (*‹⟦finite (F ` S2); mutual_indep_set (F Ai) (F ` S2)⟧ ⟹ mutual_indep_set (F Ai) ((-) (space M) ` F ` S2)›*) finS2 (*‹finite S2›*) ceq[of S2] (*‹(λi. space M - F i) ` S2 = (-) (space M) ` F ` S2›*) by simp
have scompl_ev: "?c ` S ⊆ events"
using compl_sets_index (*‹(?F::?'b::type ⇒ 'a::type set) ` (?A::?'b::type set) ⊆ events ⟹ (λi::?'b::type. space (M::'a::type measure) - ?F i) ` ?A ⊆ events›*) sevents (*‹F ` S ⊆ events›*) by simp
then have s2cev: "?c ` S2 ⊆ events"
using S2_def (*‹(S2::nat set) = (S::nat set) - (S1::nat set)›*) scompl_ev (*‹(λi. space M - F i) ` S ⊆ events›*) by blast
have "(⋂ Aj ∈ S . space M - (F Aj)) ⊆ (⋂ Aj ∈ S2 . space M - (F Aj))"
unfolding S2_def
(*goal: ‹(⋂Aj::nat∈S::nat set. space (M::'a::type measure) - (F::nat ⇒ 'a::type set) Aj) ⊆ (⋂Aj::nat∈S - (S1::nat set). space M - F Aj)›*)
using Diff_subset (*‹?A - ?B ⊆ ?A›*) image_mono (*‹?A ⊆ ?B ⟹ ?f ` ?A ⊆ ?f ` ?B›*) Inter_anti_mono (*‹?B ⊆ ?A ⟹ ⋂ ?A ⊆ ⋂ ?B›*) by blast
then have "S2 ≠ {} ⟹ prob (⋂ Aj ∈ S2 . space M - (F Aj)) ≠ 0"
using psubset.prems(4) (*‹0 < prob (⋂Aj∈S. space M - F Aj)›*) s2cev (*‹(λi. space M - F i) ` S2 ⊆ events›*) finS2 (*‹finite S2›*) Inter_event_ss[of "?c ` S2"] (*‹⟦finite ((λi. space M - F i) ` S2); (λi. space M - F i) ` S2 ⊆ events; (λi. space M - F i) ` S2 ≠ {}⟧ ⟹ (⋂i∈S2. space M - F i) ∈ events›*) finite_measure_mono[of "⋂ (?c ` S)" "⋂(?c ` S2)"] (*‹⟦(⋂i∈S. space M - F i) ⊆ (⋂i∈S2. space M - F i); (⋂i∈S2. space M - F i) ∈ events⟧ ⟹ prob (⋂i∈S. space M - F i) ≤ prob (⋂i∈S2. space M - F i)›*) by simp
then have s2prob_eq: "S2 ≠ {} ⟹ 𝒫((F Ai) | (⋂ (?c ` S2))) = prob (F Ai)"
using assms(2) (*‹F ` A ⊆ events›*) mutual_indep_cond_full[of " F Ai" "?c ` S2"] (*‹⟦F Ai ∈ events; (λi. space M - F i) ` S2 ⊆ events; finite ((λi. space M - F i) ` S2); mutual_indep_set (F Ai) ((λi. space M - F i) ` S2); (λi. space M - F i) ` S2 ≠ {}; prob (⋂i∈S2. space M - F i) ≠ 0⟧ ⟹ 𝒫(F Ai | ⋂i∈S2. space M - F i) = prob (F Ai)›*) psubset.prems(1) (*‹Ai ∈ A›*) s2cev (*‹(λi. space M - F i) ` S2 ⊆ events›*) finS2 (*‹finite S2›*) mis2 (*‹mutual_indep_set (F Ai) ((λi. space M - F i) ` S2)›*) by simp
show "?case"
(*goal: ‹𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai›*)
proof (cases "S1 = {}")
(*goals:
1. ‹S1 = {} ⟹ 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai›
2. ‹S1 ≠ {} ⟹ 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai›*)
case True (*‹S1 = {}›*)
then show "?thesis"
(*goal: ‹𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai›*)
using lovasz_inductive_base[of G F A f Ai] (*‹⟦dependency_digraph G M F; ⋀Ai. Ai ∈ A ⟹ 0 ≤ f Ai ∧ f Ai < 1; ⋀Ai. Ai ∈ A ⟹ prob (F Ai) ≤ f Ai * (∏Aj∈dg.neighborhood Ai. 1 - f Aj); Ai ∈ A; pverts G = A⟧ ⟹ prob (F Ai) ≤ f Ai›*) psubset.prems(3) (*‹S ≠ {}›*) S2_def (*‹S2 = S - S1›*) assms(3) (*‹?i12 ∈ A ⟹ 0 ≤ f ?i12 ∧ f ?i12 < 1›*) assms(4) (*‹dependency_digraph G M F›*) psubset.prems(1) (*‹Ai ∈ A›*) prob_Ai (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ f ?Ai12 * (∏Aj∈dg.neighborhood ?Ai12. 1 - f Aj)›*) s2prob_eq (*‹S2 ≠ {} ⟹ 𝒫(F Ai | ⋂i∈S2. space M - F i) = prob (F Ai)›*) dep_graph_verts (*‹pverts G = A›*) by simp
next
(*goal: ‹S1 ≠ {} ⟹ 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai›*)
case s1F: False (*‹S1 ≠ {}›*)
then have csgt0: "card S1 > 0"
using s1F (*‹S1 ≠ {}›*) finS1 (*‹finite (S1::nat set)›*) card_gt_0_iff (*‹(0 < card ?A) = (?A ≠ {} ∧ finite ?A)›*) by blast
obtain g where bb: "bij_betw g {0..<card S1} S1"
(*goal: ‹(⋀g. bij_betw g {0..<card S1} S1 ⟹ thesis) ⟹ thesis›*)
using finS1 (*‹finite S1›*) ex_bij_betw_nat_finite (*‹finite ?M ⟹ ∃h. bij_betw h {0..<card ?M} ?M›*) by auto
have igt0: "⋀i. i ∈ {0..<card S1} ⟹ 1 - f (g i) ≥ 0"
using S1_def (*‹S1 = S ∩ dg.neighborhood Ai›*) psubset.prems(2) (*‹S ⊆ A - {Ai}›*) bb (*‹bij_betw (g::nat ⇒ nat) {0::nat..<card (S1::nat set)} S1›*) bij_betw_apply (*‹⟦bij_betw ?f ?A ?B; ?a ∈ ?A⟧ ⟹ ?f ?a ∈ ?B›*) assms(3) (*‹?i12 ∈ A ⟹ 0 ≤ f ?i12 ∧ f ?i12 < 1›*) by fastforce
have s1ss: "S1 ⊆ dg.neighborhood Ai"
using S1_def (*‹S1 = S ∩ dg.neighborhood Ai›*) by auto
moreover have "∃ P1 P2. 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) = P1/P2 ∧ P1 ≤ prob (F Ai)
∧ P2 ≥ (∏ Aj ∈ S1 . (1 - (f Aj)))"
proof (cases "S2 = {}")
(*goals:
1. ‹S2 = {} ⟹ ∃P1 P2. 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) = P1 / P2 ∧ P1 ≤ prob (F Ai) ∧ (∏Aj∈S1. 1 - f Aj) ≤ P2›
2. ‹S2 ≠ {} ⟹ ∃P1 P2. 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) = P1 / P2 ∧ P1 ≤ prob (F Ai) ∧ (∏Aj∈S1. 1 - f Aj) ≤ P2›*)
case True (*‹S2 = {}›*)
then have Seq: "S1 = S"
using S1_def (*‹S1 = S ∩ dg.neighborhood Ai›*) S2_def (*‹S2 = S - S1›*) by auto
have inter_eventsS: "(⋂ Aj ∈ S . (space M - (F Aj))) ∈ events"
using psubset.prems (*‹Ai ∈ A› ‹S ⊆ A - {Ai}› ‹S ≠ {}› ‹0 < prob (⋂Aj∈S. space M - F Aj)›*) assms (*‹finite A› ‹F ` A ⊆ events› ‹?i12 ∈ A ⟹ 0 ≤ f ?i12 ∧ f ?i12 < 1› ‹dependency_digraph (G::nat pair_pre_digraph) (M::'a measure) (F::nat ⇒ 'a set)› ‹pverts G = A› ‹(?Ai12::nat) ∈ (A::nat set) ⟹ prob ((F::nat ⇒ 'a set) ?Ai12) ≤ (f::nat ⇒ real) ?Ai12 * (∏Aj::nat∈dg.neighborhood ?Ai12. (1::real) - f Aj)› ‹Ai ∈ A› ‹S ⊆ A - {Ai}› ‹(S::nat set) ≠ {}› ‹0 < prob (⋂Aj∈S. space M - F Aj)›*) by (meson measure_notin_sets (*‹?A ∉ sets ?M ⟹ Sigma_Algebra.measure ?M ?A = 0›*) zero_less_measure_iff (*‹(0 < Sigma_Algebra.measure ?M ?A) = (Sigma_Algebra.measure ?M ?A ≠ 0)›*))
then have peq: "𝒫((F Ai) | (⋂ Aj ∈ S1 . ?c Aj)) =
prob ((⋂ Aj ∈ S1 . ?c Aj) ∩ (F Ai))/prob ((⋂ (?c ` S1)))" (is "𝒫((F Ai) | (⋂ Aj ∈ S1 . ?c Aj)) = ?Num/?Den")
using cond_prob_ev_def[of "(⋂ Aj ∈ S1 . (space M - (F Aj)))" "F Ai"] (*‹⟦(⋂Aj∈S1. space M - F Aj) ∈ events; F Ai ∈ events⟧ ⟹ 𝒫(F Ai | ⋂Aj∈S1. space M - F Aj) = prob ((⋂Aj∈S1. space M - F Aj) ∩ F Ai) / prob (⋂Aj∈S1. space M - F Aj)›*) using Seq (*‹S1 = S›*) psubset.prems(1) (*‹Ai ∈ A›*) assms(2) (*‹F ` A ⊆ events›*) by blast
have "?Num ≤ prob (F Ai)"
using finite_measure_mono (*‹⟦?A ⊆ ?B; ?B ∈ events⟧ ⟹ prob ?A ≤ prob ?B›*) assms(2) (*‹F ` A ⊆ events›*) psubset.prems(1) (*‹(Ai::nat) ∈ (A::nat set)›*) by simp
moreover have "?Den ≥ (∏ Aj ∈ S1 . (1 - (f Aj)))"
proof (-)
(*goal: ‹(∏Aj::nat∈(S1::nat set). (1::real) - (f::nat ⇒ real) Aj) ≤ prob (⋂i::nat∈S1. space (M::'a measure) - (F::nat ⇒ 'a set) i)›*)
have pcond: "prob (⋂(?c ` S1)) =
prob (?c (g 0)) * (∏i ∈ {1..<card S1} . 𝒫(?c (g i) | (⋂(?c ` g ` {0..<i}))))"
using prob_cond_inter_index_fn_compl[of "S1" F] (*‹⟦S1 ≠ {}; F ` S1 ⊆ events; finite S1; bij_betw ?f {0..<card S1} S1⟧ ⟹ prob (⋂ ((-) (space M) ` F ` S1)) = prob (space M - F (?f 0)) * (∏i = 1..<card S1. 𝒫(space M - F (?f i) | ⋂ ((-) (space M) ` F ` ?f ` {0..<i})))›*) Seq (*‹S1 = S›*) s1events (*‹F ` S1 ⊆ events›*) psubset(1) (*‹finite S›*) s1F (*‹S1 ≠ {}›*) bb (*‹bij_betw g {0..<card S1} S1›*) by auto
have ineq: "⋀ i. i ∈ {1..<card S1} ⟹ 𝒫(?c (g i) | (⋂(?c ` g ` {0..<i}))) ≥ (1 - (f (g i)))"
using lovasz_inequality[of S1 F A Ai _ S1 g S1 "{}" f] (*‹⟦finite S1; F ` S1 ⊆ events; S1 ⊆ A - {Ai}; 0 < prob (⋂Aj∈S1. space M - F Aj); ?i ∈ {0..<card S1}; bij_betw g {0..<card S1} S1; S1 = S1 ∩ S1; {} = S1 - S1; 0 < ?i ∨ {} ≠ {}; ⋀B. ⟦B ⊂ S1; g ?i ∈ A; B ⊆ A - {g ?i}; B ≠ {}; 0 < prob (⋂Aj∈B. space M - F Aj)⟧ ⟹ 𝒫(F (g ?i) | ⋂Aj∈B. space M - F Aj) ≤ f (g ?i)⟧ ⟹ 1 - f (g ?i) ≤ 𝒫(space M - F (g ?i) | ⋂ ((λi. space M - F i) ` g ` {0..<?i} ∪ (λi. space M - F i) ` {}))›*) sevents (*‹(F::nat ⇒ 'a set) ` (S::nat set) ⊆ events›*) finS (*‹finite S›*) psubset.prems(2) (*‹S ⊆ A - {Ai}›*) psubset.prems(4) (*‹0 < prob (⋂Aj∈S. space M - F Aj)›*) bb (*‹bij_betw g {0..<card S1} S1›*) psubset.hyps(2)[of _ "g _"] (*‹⟦?B12 ⊂ S; g ?uu16 ∈ A; ?B12 ⊆ A - {g ?uu16}; ?B12 ≠ {}; 0 < prob (⋂Aj∈?B12. space M - F Aj)⟧ ⟹ 𝒫(F (g ?uu16) | ⋂Aj∈?B12. space M - F Aj) ≤ f (g ?uu16)›*) Seq (*‹(S1::nat set) = (S::nat set)›*) by fastforce
have "(⋀i. i ∈ {1..<card S1} ⟹ 1 - f (g i) ≥ 0)"
using igt0 (*‹?i12 ∈ {0..<card S1} ⟹ 0 ≤ 1 - f (g ?i12)›*) by simp
then have "(∏i ∈ {1..<(card S1)} . 𝒫(?c (g i) | (⋂(?c ` g ` {0..<i}))))
≥ (∏i ∈ {1..<(card S1)} . (1 - (f (g i))))"
using ineq (*‹(?i12::nat) ∈ {1::nat..<card (S1::nat set)} ⟹ (1::real) - (f::nat ⇒ real) ((g::nat ⇒ nat) ?i12) ≤ 𝒫(space (M::'a measure) - (F::nat ⇒ 'a set) (g ?i12) | ⋂Aj::nat∈g ` {0::nat..<?i12}. space M - F Aj)›*) prod_mono (*‹(⋀i::?'b. i ∈ (?A::?'b set) ⟹ (0::?'a) ≤ (?f::?'b ⇒ ?'a) i ∧ ?f i ≤ (?g::?'b ⇒ ?'a) i) ⟹ prod ?f ?A ≤ prod ?g ?A›*) by (smt(verit, ccfv_threshold))
moreover have "prob (?c (g 0)) ≥ (1 - f (g 0))"
proof (-)
(*goal: ‹1 - f (g 0) ≤ prob (space M - F (g 0))›*)
have g0in: "g 0 ∈ A"
using bb (*‹bij_betw g {0..<card S1} S1›*) csgt0 (*‹0 < card S1›*) using psubset.prems(2) (*‹S ⊆ A - {Ai}›*) bij_betwE (*‹bij_betw ?f ?A ?B ⟹ ∀a∈?A. ?f a ∈ ?B›*) Seq (*‹S1 = S›*) by fastforce
then have "prob (?c (g 0)) = 1 - prob (F (g 0))"
using Aevents (*‹F ` A ⊆ events›*) by (simp add: prob_compl (*‹?A ∈ events ⟹ prob (space M - ?A) = 1 - prob ?A›*))
then show "?thesis"
(*goal: ‹1 - f (g 0) ≤ prob (space M - F (g 0))›*)
using lovasz_inductive_base[of G F A f "g 0"] (*‹⟦dependency_digraph G M F; ⋀Ai. Ai ∈ A ⟹ 0 ≤ f Ai ∧ f Ai < 1; ⋀Ai. Ai ∈ A ⟹ prob (F Ai) ≤ f Ai * (∏Aj∈dg.neighborhood Ai. 1 - f Aj); g 0 ∈ A; pverts G = A⟧ ⟹ prob (F (g 0)) ≤ f (g 0)›*) prob_Ai (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ f ?Ai12 * (∏Aj∈dg.neighborhood ?Ai12. 1 - f Aj)›*) assms(4) (*‹dependency_digraph G M F›*) dep_graph_verts (*‹pverts G = A›*) fbounds (*‹?i12 ∈ A ⟹ 0 ≤ f ?i12 ∧ f ?i12 < 1›*) g0in (*‹g 0 ∈ A›*) by auto
qed
moreover have "0 ≤ (∏i = 1..<card S1. 1 - f (g i))"
using igt0 (*‹?i12 ∈ {0..<card S1} ⟹ 0 ≤ 1 - f (g ?i12)›*) by (force intro: prod_nonneg (*‹(⋀a. a ∈ ?A ⟹ 0 ≤ ?f a) ⟹ 0 ≤ prod ?f ?A›*))
ultimately have "prob (⋂(?c ` S1)) ≥ (1 - (f (g 0))) * (∏i ∈ {1..<(card S1)} . (1 - (f (g i))))"
using pcond (*‹prob (⋂Aj∈S1. space M - F Aj) = prob (space M - F (g 0)) * (∏i = 1..<card S1. 𝒫(space M - F (g i) | ⋂Aj∈g ` {0..<i}. space M - F Aj))›*) igt0 (*‹?i12 ∈ {0..<card S1} ⟹ 0 ≤ 1 - f (g ?i12)›*) mult_mono'[of "(1 - (f (g 0)))"] (*‹⟦1 - f (g 0) ≤ ?b; ?c ≤ ?d; 0 ≤ 1 - f (g 0); 0 ≤ ?c⟧ ⟹ (1 - f (g 0)) * ?c ≤ ?b * ?d›*) by fastforce
moreover have "{0..<card S1} = {0} ∪ {1..<card S1}"
using csgt0 (*‹0 < card S1›*) by auto
ultimately have "prob (⋂(?c ` S1)) ≥ (∏i ∈ {0..<(card S1)} . (1 - (f (g i))))"
by auto
moreover have "(∏i ∈ {0..<(card S1)} . (1 - (f (g i)))) = (∏i ∈ S1 . (1 - (f (i))))"
using prod.reindex_bij_betw (*‹bij_betw ?h ?S ?T ⟹ (∏x∈?S. ?g (?h x)) = prod ?g ?T›*) bb (*‹bij_betw g {0..<card S1} S1›*) by simp
ultimately show "?thesis"
(*goal: ‹(∏Aj∈S1. 1 - f Aj) ≤ prob (⋂i∈S1. space M - F i)›*)
by simp
qed
ultimately show "?thesis"
(*goal: ‹∃P1 P2. 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) = P1 / P2 ∧ P1 ≤ prob (F Ai) ∧ (∏Aj∈S1. 1 - f Aj) ≤ P2›*)
using peq (*‹𝒫(F Ai | ⋂Aj∈S1. space M - F Aj) = prob ((⋂Aj∈S1. space M - F Aj) ∩ F Ai) / prob (⋂i∈S1. space M - F i)›*) Seq (*‹(S1::nat set) = (S::nat set)›*) by blast
next
(*goal: ‹S2 ≠ {} ⟹ ∃P1 P2. 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) = P1 / P2 ∧ P1 ≤ prob (F Ai) ∧ (∏Aj∈S1. 1 - f Aj) ≤ P2›*)
case s2F: False (*‹S2 ≠ {}›*)
have s2inter: "⋂ (?c ` S2) ∈ events"
using s2F (*‹(S2::nat set) ≠ {}›*) finS2 (*‹finite S2›*) s2cev (*‹(λi. space M - F i) ` S2 ⊆ events›*) Inter_event_ss[of "?c ` S2"] (*‹⟦finite ((λi::nat. space (M::'a measure) - (F::nat ⇒ 'a set) i) ` (S2::nat set)); (λi::nat. space M - F i) ` S2 ⊆ events; (λi::nat. space M - F i) ` S2 ≠ {}⟧ ⟹ (⋂i::nat∈S2. space M - F i) ∈ events›*) by auto
have split: "(⋂ Aj ∈ S . (?c Aj)) = (⋂ (?c `S1)) ∩ (⋂ (?c ` S2))"
using S1_def (*‹S1 = S ∩ dg.neighborhood Ai›*) S2_def (*‹S2 = S - S1›*) by auto
then have "𝒫(F Ai | (⋂ Aj ∈ S . (?c Aj))) = 𝒫(F Ai | (⋂ (?c `S1)) ∩ (⋂ (?c ` S2)))"
by simp
moreover have s2n0: "prob (⋂ (?c ` S2)) ≠ 0"
using psubset.prems(4) (*‹(0::real) < prob (⋂Aj::nat∈S::nat set. space (M::'a measure) - (F::nat ⇒ 'a set) Aj)›*) S2_def (*‹S2 = S - S1›*) by (metis Int_lower2 (*‹?A ∩ ?B ⊆ ?B›*) split (*‹(⋂Aj∈S. space M - F Aj) = (⋂i∈S1. space M - F i) ∩ (⋂i∈S2. space M - F i)›*) finite_measure_mono (*‹⟦?A ⊆ ?B; ?B ∈ events⟧ ⟹ prob ?A ≤ prob ?B›*) measure_le_0_iff (*‹(Sigma_Algebra.measure ?M ?X ≤ 0) = (Sigma_Algebra.measure ?M ?X = 0)›*) s2inter (*‹(⋂i∈S2. space M - F i) ∈ events›*) semiring_norm( (*‹¬ 0 < 0›*) 137))
moreover have "⋂ (?c ` S1) ∈ events"
using finS1 (*‹finite S1›*) S1_def (*‹(S1::nat set) = (S::nat set) ∩ dg.neighborhood (Ai::nat)›*) scompl_ev (*‹(λi. space M - F i) ` S ⊆ events›*) s1F (*‹S1 ≠ {}›*) Inter_event_ss[of "(?c ` S1)"] (*‹⟦finite ((λi. space M - F i) ` S1); (λi. space M - F i) ` S1 ⊆ events; (λi. space M - F i) ` S1 ≠ {}⟧ ⟹ (⋂i∈S1. space M - F i) ∈ events›*) by auto
ultimately have peq: "𝒫(F Ai | (⋂ Aj ∈ S . (?c Aj))) = 𝒫(F Ai ∩ (⋂ (?c `S1)) | ⋂ (?c ` S2))/
𝒫(⋂ (?c `S1) | ⋂ (?c `S2))" (is "𝒫(F Ai | (⋂ Aj ∈ S . (?c Aj))) = ?Num/?Den")
using cond_prob_dual_intersect[of "F Ai" "⋂ (?c `S1)" "⋂ (?c `S2)"] (*‹⟦F Ai ∈ events; (⋂Aj∈S1. space M - F Aj) ∈ events; (⋂Aj∈S2. space M - F Aj) ∈ events; prob (⋂Aj∈S2. space M - F Aj) ≠ 0⟧ ⟹ 𝒫(F Ai | (⋂Aj∈S1. space M - F Aj) ∩ (⋂Aj∈S2. space M - F Aj)) = 𝒫(F Ai ∩ (⋂Aj∈S1. space M - F Aj) | ⋂Aj∈S2. space M - F Aj) / 𝒫(⋂Aj∈S1. space M - F Aj | ⋂Aj∈S2. space M - F Aj)›*) assms(2) (*‹F ` A ⊆ events›*) psubset.prems(1) (*‹Ai ∈ A›*) s2inter (*‹(⋂i∈S2. space M - F i) ∈ events›*) by fastforce
have "?Num ≤ 𝒫(F Ai | ⋂ (?c `S2))"
using cond_prob_inter_set_lt[of "F Ai" "⋂ (?c `S2)" "?c ` S1"] (*‹⟦F Ai ∈ events; (⋂Aj∈S2. space M - F Aj) ∈ events; (λAj. space M - F Aj) ` S1 ⊆ events; finite ((λAj. space M - F Aj) ` S1)⟧ ⟹ 𝒫(F Ai ∩ (⋂Aj∈S1. space M - F Aj) | ⋂Aj∈S2. space M - F Aj) ≤ 𝒫(F Ai | ⋂Aj∈S2. space M - F Aj)›*) using s1events (*‹F ` S1 ⊆ events›*) finS1 (*‹finite S1›*) psubset.prems(1) (*‹(Ai::nat) ∈ (A::nat set)›*) assms(2) (*‹(F::nat ⇒ 'a set) ` (A::nat set) ⊆ events›*) s2inter (*‹(⋂i∈S2. space M - F i) ∈ events›*) finite_imageI[of S1 F] (*‹finite S1 ⟹ finite (F ` S1)›*) by blast
then have "?Num ≤ prob (F Ai)"
using s2F (*‹(S2::nat set) ≠ {}›*) s2prob_eq (*‹S2 ≠ {} ⟹ 𝒫(F Ai | ⋂i∈S2. space M - F i) = prob (F Ai)›*) by auto
moreover have "?Den ≥ (∏ Aj ∈ S1 . (1 - (f Aj)))"
using psubset.hyps (*‹finite S› ‹⟦?B12 ⊂ S; ?Ai12 ∈ A; ?B12 ⊆ A - {?Ai12}; ?B12 ≠ {}; 0 < prob (⋂Aj∈?B12. space M - F Aj)⟧ ⟹ 𝒫(F ?Ai12 | ⋂Aj∈?B12. space M - F Aj) ≤ f ?Ai12›*) proof (-)
(*goal: ‹⟦finite S; ⋀B Ai. ⟦B ⊂ S; Ai ∈ A; B ⊆ A - {Ai}; B ≠ {}; 0 < prob (⋂Aj∈B. space M - F Aj)⟧ ⟹ 𝒫(F Ai | ⋂Aj∈B. space M - F Aj) ≤ f Ai⟧ ⟹ (∏Aj∈S1. 1 - f Aj) ≤ 𝒫(⋂i∈S1. space M - F i | ⋂i∈S2. space M - F i)›*)
have "prob (⋂(?c ` S2)) > 0"
using s2n0 (*‹prob (⋂i∈S2. space M - F i) ≠ 0›*) by (meson zero_less_measure_iff (*‹(0 < Sigma_Algebra.measure ?M ?A) = (Sigma_Algebra.measure ?M ?A ≠ 0)›*))
then have pcond: "𝒫(⋂ (?c `S1) | ⋂ (?c `S2)) =
(∏i = 0..<card S1 . 𝒫(?c (g i) | (⋂ (?c ` g ` {0..<i} ∪ (?c ` S2)))))"
using prob_cond_Inter_index_cond_compl_fn[of S1 "?c ` S2" F] (*‹⟦S1 ≠ {}; finite S1; finite ((λAj. space M - F Aj) ` S2); (λAj. space M - F Aj) ` S2 ≠ {}; (λAj. space M - F Aj) ` S2 ⊆ events; F ` S1 ⊆ events; 0 < prob (⋂Aj∈S2. space M - F Aj); bij_betw ?g {0..<card S1} S1⟧ ⟹ 𝒫(⋂Aj∈S1. space M - F Aj | ⋂Aj∈S2. space M - F Aj) = (∏i = 0..<card S1. 𝒫(space M - F (?g i) | ⋂ ((λAj. space M - F Aj) ` ?g ` {0..<i} ∪ (λAj. space M - F Aj) ` S2)))›*) s1F (*‹S1 ≠ {}›*) finS1 (*‹finite (S1::nat set)›*) s2cev (*‹(λi::nat. space (M::'a measure) - (F::nat ⇒ 'a set) i) ` (S2::nat set) ⊆ events›*) finS2 (*‹finite S2›*) s2F (*‹S2 ≠ {}›*) s1events (*‹F ` S1 ⊆ events›*) bb (*‹bij_betw (g::nat ⇒ nat) {0::nat..<card (S1::nat set)} S1›*) by auto
have "⋀ i. i ∈ {0..<card S1} ⟹ 𝒫(?c (g i) | (⋂ (?c ` g ` {0..<i} ∪ (?c ` S2)))) ≥ (1 - f (g i))"
using lovasz_inequality[of S F A Ai _ S1 g "dg.neighborhood Ai" S2 f] (*‹⟦finite S; F ` S ⊆ events; S ⊆ A - {Ai}; 0 < prob (⋂Aj∈S. space M - F Aj); ?i ∈ {0..<card S1}; bij_betw g {0..<card S1} S1; S1 = S ∩ dg.neighborhood Ai; S2 = S - S1; 0 < ?i ∨ S2 ≠ {}; ⋀B. ⟦B ⊂ S; g ?i ∈ A; B ⊆ A - {g ?i}; B ≠ {}; 0 < prob (⋂Aj∈B. space M - F Aj)⟧ ⟹ 𝒫(F (g ?i) | ⋂Aj∈B. space M - F Aj) ≤ f (g ?i)⟧ ⟹ 1 - f (g ?i) ≤ 𝒫(space M - F (g ?i) | ⋂ ((λi. space M - F i) ` g ` {0..<?i} ∪ (λi. space M - F i) ` S2))›*) S1_def (*‹S1 = S ∩ dg.neighborhood Ai›*) S2_def (*‹S2 = S - S1›*) sevents (*‹(F::nat ⇒ 'a set) ` (S::nat set) ⊆ events›*) finS (*‹finite S›*) psubset.prems(2) (*‹(S::nat set) ⊆ (A::nat set) - {Ai::nat}›*) psubset.prems(4) (*‹0 < prob (⋂Aj∈S. space M - F Aj)›*) bb (*‹bij_betw g {0..<card S1} S1›*) psubset.hyps(2)[of _ "g _"] (*‹⟦?B12 ⊂ S; g ?uu16 ∈ A; ?B12 ⊆ A - {g ?uu16}; ?B12 ≠ {}; 0 < prob (⋂Aj∈?B12. space M - F Aj)⟧ ⟹ 𝒫(F (g ?uu16) | ⋂Aj∈?B12. space M - F Aj) ≤ f (g ?uu16)›*) psubset(1) (*‹finite S›*) s2F (*‹S2 ≠ {}›*) by meson
then have c1: "𝒫(⋂ (?c `S1) | ⋂ (?c `S2)) ≥ (∏i = 0..<card S1 . (1 - f (g i)))"
using prod_mono (*‹(⋀i. i ∈ ?A ⟹ 0 ≤ ?f i ∧ ?f i ≤ ?g i) ⟹ prod ?f ?A ≤ prod ?g ?A›*) igt0 (*‹?i12 ∈ {0..<card S1} ⟹ 0 ≤ 1 - f (g ?i12)›*) pcond (*‹𝒫(⋂Aj∈S1. space M - F Aj | ⋂Aj∈S2. space M - F Aj) = (∏i = 0..<card S1. 𝒫(space M - F (g i) | ⋂ ((λAj. space M - F Aj) ` g ` {0..<i} ∪ (λAj. space M - F Aj) ` S2)))›*) bb (*‹bij_betw g {0..<card S1} S1›*) by (smt(verit, ccfv_threshold))
then have "𝒫(⋂ (?c `S1) | ⋂ (?c `S2)) ≥ (∏i ∈ {0..<card S1} . (1 - f (g i)))"
by blast
moreover have "(∏i ∈ {0..<card S1} . (1 - f (g i))) = (∏x ∈ S1 . (1 - f x))"
using bb (*‹bij_betw g {0..<card S1} S1›*) using prod.reindex_bij_betw (*‹bij_betw (?h::?'b ⇒ ?'c) (?S::?'b set) (?T::?'c set) ⟹ (∏x::?'b∈?S. (?g::?'c ⇒ ?'a) (?h x)) = prod ?g ?T›*) by fastforce
ultimately show "?thesis"
(*goal: ‹(∏Aj∈S1. 1 - f Aj) ≤ 𝒫(⋂i∈S1. space M - F i | ⋂i∈S2. space M - F i)›*)
by simp
qed
ultimately show "?thesis"
(*goal: ‹∃(P1::real) P2::real. 𝒫((F::nat ⇒ 'a set) (Ai::nat) | ⋂Aj::nat∈S::nat set. space (M::'a measure) - F Aj) = P1 / P2 ∧ P1 ≤ prob (F Ai) ∧ (∏Aj::nat∈(S1::nat set). (1::real) - (f::nat ⇒ real) Aj) ≤ P2›*)
using peq (*‹𝒫(F Ai | ⋂Aj∈S. space M - F Aj) = 𝒫(F Ai ∩ (⋂i∈S1. space M - F i) | ⋂i∈S2. space M - F i) / 𝒫(⋂i∈S1. space M - F i | ⋂i∈S2. space M - F i)›*) by blast
qed
ultimately show "?thesis"
(*goal: ‹𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai›*)
apply (intro split_prob_lt_helper[of G F A] (*‹⟦dependency_digraph G M F; pverts G = A; ⋀i. i ∈ A ⟹ 0 ≤ ?f i ∧ ?f i < 1; ⋀Ai. Ai ∈ A ⟹ prob (F Ai) ≤ ?f Ai * (∏Aj∈dg.neighborhood Ai. 1 - ?f Aj); ?Ai ∈ A; ?N ⊆ dg.neighborhood ?Ai; ∃P1 P2. 𝒫(F ?Ai | ⋂Aj∈?S. space M - F Aj) = P1 / P2 ∧ P1 ≤ prob (F ?Ai) ∧ (∏Aj∈?N. 1 - ?f Aj) ≤ P2⟧ ⟹ 𝒫(F ?Ai | ⋂Aj∈?S. space M - F Aj) ≤ ?f ?Ai›*))
(*goals:
1. ‹⟦(S1::nat set) ⊆ dg.neighborhood (Ai::nat); ∃(P1::real) P2::real. 𝒫((F::nat ⇒ 'a set) Ai | ⋂Aj::nat∈S::nat set. space (M::'a measure) - F Aj) = P1 / P2 ∧ P1 ≤ prob (F Ai) ∧ (∏Aj::nat∈S1. (1::real) - (f::nat ⇒ real) Aj) ≤ P2⟧ ⟹ dependency_digraph (G::nat pair_pre_digraph) M F›
2. ‹⟦(S1::nat set) ⊆ dg.neighborhood (Ai::nat); ∃(P1::real) P2::real. 𝒫((F::nat ⇒ 'a set) Ai | ⋂Aj::nat∈S::nat set. space (M::'a measure) - F Aj) = P1 / P2 ∧ P1 ≤ prob (F Ai) ∧ (∏Aj::nat∈S1. (1::real) - (f::nat ⇒ real) Aj) ≤ P2⟧ ⟹ pverts (G::nat pair_pre_digraph) = (A::nat set)›
3. ‹⋀i::nat. ⟦(S1::nat set) ⊆ dg.neighborhood (Ai::nat); ∃(P1::real) P2::real. 𝒫((F::nat ⇒ 'a set) Ai | ⋂Aj::nat∈S::nat set. space (M::'a measure) - F Aj) = P1 / P2 ∧ P1 ≤ prob (F Ai) ∧ (∏Aj::nat∈S1. (1::real) - (f::nat ⇒ real) Aj) ≤ P2; i ∈ (A::nat set)⟧ ⟹ (0::real) ≤ f i ∧ f i < (1::real)›
4. ‹⋀Ai::nat. ⟦(S1::nat set) ⊆ dg.neighborhood (Ai::nat); ∃(P1::real) P2::real. 𝒫((F::nat ⇒ 'a set) Ai | ⋂Aj::nat∈S::nat set. space (M::'a measure) - F Aj) = P1 / P2 ∧ P1 ≤ prob (F Ai) ∧ (∏Aj::nat∈S1. (1::real) - (f::nat ⇒ real) Aj) ≤ P2; Ai ∈ (A::nat set)⟧ ⟹ prob (F Ai) ≤ f Ai * (∏Aj::nat∈dg.neighborhood Ai. (1::real) - f Aj)›
5. ‹⟦(S1::nat set) ⊆ dg.neighborhood (Ai::nat); ∃(P1::real) P2::real. 𝒫((F::nat ⇒ 'a set) Ai | ⋂Aj::nat∈S::nat set. space (M::'a measure) - F Aj) = P1 / P2 ∧ P1 ≤ prob (F Ai) ∧ (∏Aj::nat∈S1. (1::real) - (f::nat ⇒ real) Aj) ≤ P2⟧ ⟹ Ai ∈ (A::nat set)›
6. ‹⟦(S1::nat set) ⊆ dg.neighborhood (Ai::nat); ∃(P1::real) P2::real. 𝒫((F::nat ⇒ 'a set) Ai | ⋂Aj::nat∈S::nat set. space (M::'a measure) - F Aj) = P1 / P2 ∧ P1 ≤ prob (F Ai) ∧ (∏Aj::nat∈S1. (1::real) - (f::nat ⇒ real) Aj) ≤ P2⟧ ⟹ (?N2::nat set) ⊆ dg.neighborhood Ai›
7. ‹⟦(S1::nat set) ⊆ dg.neighborhood (Ai::nat); ∃(P1::real) P2::real. 𝒫((F::nat ⇒ 'a set) Ai | ⋂Aj::nat∈S::nat set. space (M::'a measure) - F Aj) = P1 / P2 ∧ P1 ≤ prob (F Ai) ∧ (∏Aj::nat∈S1. (1::real) - (f::nat ⇒ real) Aj) ≤ P2⟧ ⟹ ∃(P1::real) P2::real. 𝒫(F Ai | ⋂Aj::nat∈S. space M - F Aj) = P1 / P2 ∧ P1 ≤ prob (F Ai) ∧ (∏Aj::nat∈(?N2::nat set). (1::real) - f Aj) ≤ P2›
discuss goal 1*)
apply (simp add: dep_graph (*‹dependency_digraph G M F›*) dep_graph_verts (*‹pverts G = A›*) fbounds (*‹?i12 ∈ A ⟹ 0 ≤ f ?i12 ∧ f ?i12 < 1›*) psubset.prems( (*‹Ai ∈ A›*) 1) prob_Ai (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ f ?Ai12 * (∏Aj∈dg.neighborhood ?Ai12. 1 - f Aj)›*))
(*discuss goal 2*)
apply (simp add: dep_graph (*‹dependency_digraph G M F›*) dep_graph_verts (*‹pverts G = A›*) fbounds (*‹?i12 ∈ A ⟹ 0 ≤ f ?i12 ∧ f ?i12 < 1›*) psubset.prems( (*‹Ai ∈ A›*) 1) prob_Ai (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ f ?Ai12 * (∏Aj∈dg.neighborhood ?Ai12. 1 - f Aj)›*))
(*discuss goal 3*)
apply (simp add: dep_graph (*‹dependency_digraph G M F›*) dep_graph_verts (*‹pverts G = A›*) fbounds (*‹?i12 ∈ A ⟹ 0 ≤ f ?i12 ∧ f ?i12 < 1›*) psubset.prems( (*‹Ai ∈ A›*) 1) prob_Ai (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ f ?Ai12 * (∏Aj∈dg.neighborhood ?Ai12. 1 - f Aj)›*))
(*discuss goal 4*)
apply (simp add: dep_graph (*‹dependency_digraph G M F›*) dep_graph_verts (*‹pverts G = A›*) fbounds (*‹?i12 ∈ A ⟹ 0 ≤ f ?i12 ∧ f ?i12 < 1›*) psubset.prems( (*‹Ai ∈ A›*) 1) prob_Ai (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ f ?Ai12 * (∏Aj∈dg.neighborhood ?Ai12. 1 - f Aj)›*))
(*discuss goal 5*)
apply (simp add: dep_graph (*‹dependency_digraph G M F›*) dep_graph_verts (*‹pverts G = A›*) fbounds (*‹?i12 ∈ A ⟹ 0 ≤ f ?i12 ∧ f ?i12 < 1›*) psubset.prems( (*‹Ai ∈ A›*) 1) prob_Ai (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ f ?Ai12 * (∏Aj∈dg.neighborhood ?Ai12. 1 - f Aj)›*))
(*discuss goal 6*)
apply (simp add: dep_graph (*‹dependency_digraph (G::nat pair_pre_digraph) (M::'a measure) (F::nat ⇒ 'a set)›*) dep_graph_verts (*‹pverts (G::nat pair_pre_digraph) = (A::nat set)›*) fbounds (*‹(?i12::nat) ∈ (A::nat set) ⟹ (0::real) ≤ (f::nat ⇒ real) ?i12 ∧ f ?i12 < (1::real)›*) psubset.prems( (*‹(Ai::nat) ∈ (A::nat set)›*) 1) prob_Ai (*‹(?Ai12::nat) ∈ (A::nat set) ⟹ prob ((F::nat ⇒ 'a set) ?Ai12) ≤ (f::nat ⇒ real) ?Ai12 * (∏Aj::nat∈dg.neighborhood ?Ai12. (1::real) - f Aj)›*))
(*discuss goal 7*)
apply (simp add: dep_graph (*‹dependency_digraph G M F›*) dep_graph_verts (*‹pverts G = A›*) fbounds (*‹?i12 ∈ A ⟹ 0 ≤ f ?i12 ∧ f ?i12 < 1›*) psubset.prems( (*‹Ai ∈ A›*) 1) prob_Ai (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ f ?Ai12 * (∏Aj∈dg.neighborhood ?Ai12. 1 - f Aj)›*))
(*proven 7 subgoals*) .
qed
qed
qed
text ‹The main lemma ›
theorem lovasz_local_general:
assumes "A ≠ {}"
assumes "F ` A ⊆ events"
assumes "finite A"
assumes "⋀ Ai . Ai ∈ A ⟹ f Ai ≥ 0 ∧ f Ai < 1"
assumes "dependency_digraph G M F"
assumes "⋀ Ai. Ai ∈ A ⟹ (prob (F Ai) ≤ (f Ai) * (∏ Aj ∈ pre_digraph.neighborhood G Ai. (1 - (f Aj))))"
assumes "pverts G = A"
shows "prob (⋂ Ai ∈ A . (space M - (F Ai))) ≥ (∏ Ai ∈ A . (1 - f Ai))" "(∏ Ai ∈ A . (1 - f Ai)) > 0"
proof (-)
(*goals:
1. ‹(∏Ai∈A. 1 - f Ai) ≤ prob (⋂Ai∈A. space M - F Ai)›
2. ‹0 < (∏Ai∈A. 1 - f Ai)›*)
show gt0: "(∏ Ai ∈ A . (1 - f Ai)) > 0"
using assms(4) (*‹(?Ai12::nat) ∈ (A::nat set) ⟹ (0::real) ≤ (f::nat ⇒ real) ?Ai12 ∧ f ?Ai12 < (1::real)›*) by (simp add: prod_pos (*‹(⋀a. a ∈ ?A ⟹ 0 < ?f a) ⟹ 0 < prod ?f ?A›*))
let ?c = "λ i. space M - F i"
interpret dg: dependency_digraph G M F
using assms(5) (*‹dependency_digraph (G::nat pair_pre_digraph) (M::'a::type measure) (F::nat ⇒ 'a::type set)›*) by simp
have general: "⋀Ai S. Ai ∈ A ⟹ S ⊆ A - {Ai} ⟹ S ≠ {} ⟹ prob (⋂ Aj ∈ S . (?c Aj)) > 0
⟹ 𝒫(F Ai | (⋂ Aj ∈ S . (?c Aj))) ≤ f Ai"
using assms (*‹A ≠ {}› ‹F ` A ⊆ events› ‹finite A› ‹(?Ai12::nat) ∈ (A::nat set) ⟹ (0::real) ≤ (f::nat ⇒ real) ?Ai12 ∧ f ?Ai12 < (1::real)› ‹dependency_digraph G M F› ‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ f ?Ai12 * (∏Aj∈dg.neighborhood ?Ai12. 1 - f Aj)› ‹pverts G = A›*) lovasz_inductive[of A F f G] (*‹⟦finite A; F ` A ⊆ events; ⋀i. i ∈ A ⟹ 0 ≤ f i ∧ f i < 1; dependency_digraph G M F; pverts G = A; ⋀Ai. Ai ∈ A ⟹ prob (F Ai) ≤ f Ai * (∏Aj∈dg.neighborhood Ai. 1 - f Aj); ?Ai ∈ A; ?S ⊆ A - {?Ai}; ?S ≠ {}; 0 < prob (⋂Aj∈?S. space M - F Aj)⟧ ⟹ 𝒫(F ?Ai | ⋂Aj∈?S. space M - F Aj) ≤ f ?Ai›*) by simp
have base: "⋀ Ai. Ai ∈ A ⟹ prob (F Ai) ≤ f Ai"
using lovasz_inductive_base (*‹⟦dependency_digraph ?G M ?F; ⋀Ai. Ai ∈ ?A ⟹ 0 ≤ ?g Ai ∧ ?g Ai < 1; ⋀Ai. Ai ∈ ?A ⟹ prob (?F Ai) ≤ ?g Ai * (∏Aj∈pre_digraph.neighborhood (with_proj ?G) Ai. 1 - ?g Aj); ?Ai ∈ ?A; pverts ?G = ?A⟧ ⟹ prob (?F ?Ai) ≤ ?g ?Ai›*) assms(4) (*‹(?Ai12::nat) ∈ (A::nat set) ⟹ (0::real) ≤ (f::nat ⇒ real) ?Ai12 ∧ f ?Ai12 < (1::real)›*) assms(6) (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ f ?Ai12 * (∏Aj∈dg.neighborhood ?Ai12. 1 - f Aj)›*) assms(5) (*‹dependency_digraph G M F›*) assms(7) (*‹pverts (G::nat pair_pre_digraph) = (A::nat set)›*) by blast
show "prob (⋂ Ai ∈ A . (?c Ai)) ≥ (∏ Ai ∈ A . (1 - f Ai))"
using assms(3) (*‹finite A›*) assms(1) (*‹A ≠ {}›*) assms(2) (*‹(F::nat ⇒ 'a set) ` (A::nat set) ⊆ events›*) assms(4) (*‹?Ai12 ∈ A ⟹ 0 ≤ f ?Ai12 ∧ f ?Ai12 < 1›*) general (*‹⟦?Ai12 ∈ A; ?S12 ⊆ A - {?Ai12}; ?S12 ≠ {}; 0 < prob (⋂Aj∈?S12. space M - F Aj)⟧ ⟹ 𝒫(F ?Ai12 | ⋂Aj∈?S12. space M - F Aj) ≤ f ?Ai12›*) base (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ f ?Ai12›*) proof (induct A rule: finite_ne_induct (*‹⟦finite ?F; ?F ≠ {}; ⋀x. ?P {x}; ⋀x F. ⟦finite F; F ≠ {}; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?F›*))
(*goals:
1. ‹⋀x. ⟦F ` {x} ⊆ events; ⋀Ai. Ai ∈ {x} ⟹ 0 ≤ f Ai ∧ f Ai < 1; ⋀Ai S. ⟦Ai ∈ {x}; S ⊆ {x} - {Ai}; S ≠ {}; 0 < prob (⋂Aj∈S. space M - F Aj)⟧ ⟹ 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai; ⋀Ai. Ai ∈ {x} ⟹ prob (F Ai) ≤ f Ai⟧ ⟹ (∏Ai∈{x}. 1 - f Ai) ≤ prob (⋂Ai∈{x}. space M - F Ai)›
2. ‹⋀x Fa. ⟦finite Fa; Fa ≠ {}; x ∉ Fa; ⟦F ` Fa ⊆ events; ⋀Ai. Ai ∈ Fa ⟹ 0 ≤ f Ai ∧ f Ai < 1; ⋀Ai S. ⟦Ai ∈ Fa; S ⊆ Fa - {Ai}; S ≠ {}; 0 < prob (⋂Aj∈S. space M - F Aj)⟧ ⟹ 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai; ⋀Ai. Ai ∈ Fa ⟹ prob (F Ai) ≤ f Ai⟧ ⟹ (∏Ai∈Fa. 1 - f Ai) ≤ prob (⋂Ai∈Fa. space M - F Ai); F ` insert x Fa ⊆ events; ⋀Ai. Ai ∈ insert x Fa ⟹ 0 ≤ f Ai ∧ f Ai < 1; ⋀Ai S. ⟦Ai ∈ insert x Fa; S ⊆ insert x Fa - {Ai}; S ≠ {}; 0 < prob (⋂Aj∈S. space M - F Aj)⟧ ⟹ 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai; ⋀Ai. Ai ∈ insert x Fa ⟹ prob (F Ai) ≤ f Ai⟧ ⟹ (∏Ai∈insert x Fa. 1 - f Ai) ≤ prob (⋂Ai∈insert x Fa. space M - F Ai)›*)
case (singleton x) (*‹F ` {x} ⊆ events› ‹?Ai12 ∈ {x} ⟹ 0 ≤ f ?Ai12 ∧ f ?Ai12 < 1› ‹⟦?Ai12 ∈ {x}; ?S12 ⊆ {x} - {?Ai12}; ?S12 ≠ {}; 0 < prob (⋂Aj∈?S12. space M - F Aj)⟧ ⟹ 𝒫(F ?Ai12 | ⋂Aj∈?S12. space M - F Aj) ≤ f ?Ai12› ‹(?Ai12::nat) ∈ {x::nat} ⟹ prob ((F::nat ⇒ 'a::type set) ?Ai12) ≤ (f::nat ⇒ real) ?Ai12›*)
then show "?case"
(*goal: ‹(∏Ai∈{x}. 1 - f Ai) ≤ prob (⋂Ai∈{x}. space M - F Ai)›*)
using singleton.prems (*‹F ` {x} ⊆ events› ‹?Ai12 ∈ {x} ⟹ 0 ≤ f ?Ai12 ∧ f ?Ai12 < 1› ‹⟦?Ai12 ∈ {x}; ?S12 ⊆ {x} - {?Ai12}; ?S12 ≠ {}; 0 < prob (⋂Aj∈?S12. space M - F Aj)⟧ ⟹ 𝒫(F ?Ai12 | ⋂Aj∈?S12. space M - F Aj) ≤ f ?Ai12› ‹(?Ai12::nat) ∈ {x::nat} ⟹ prob ((F::nat ⇒ 'a set) ?Ai12) ≤ (f::nat ⇒ real) ?Ai12›*) singleton (*‹F ` {x} ⊆ events› ‹?Ai12 ∈ {x} ⟹ 0 ≤ f ?Ai12 ∧ f ?Ai12 < 1› ‹⟦?Ai12 ∈ {x}; ?S12 ⊆ {x} - {?Ai12}; ?S12 ≠ {}; 0 < prob (⋂Aj∈?S12. space M - F Aj)⟧ ⟹ 𝒫(F ?Ai12 | ⋂Aj∈?S12. space M - F Aj) ≤ f ?Ai12› ‹?Ai12 ∈ {x} ⟹ prob (F ?Ai12) ≤ f ?Ai12›*) prob_compl (*‹?A ∈ events ⟹ prob (space M - ?A) = 1 - prob ?A›*) by auto
next
(*goal: ‹⋀x Fa. ⟦finite Fa; Fa ≠ {}; x ∉ Fa; ⟦F ` Fa ⊆ events; ⋀Ai. Ai ∈ Fa ⟹ 0 ≤ f Ai ∧ f Ai < 1; ⋀Ai S. ⟦Ai ∈ Fa; S ⊆ Fa - {Ai}; S ≠ {}; 0 < prob (⋂Aj∈S. space M - F Aj)⟧ ⟹ 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai; ⋀Ai. Ai ∈ Fa ⟹ prob (F Ai) ≤ f Ai⟧ ⟹ (∏Ai∈Fa. 1 - f Ai) ≤ prob (⋂Ai∈Fa. space M - F Ai); F ` insert x Fa ⊆ events; ⋀Ai. Ai ∈ insert x Fa ⟹ 0 ≤ f Ai ∧ f Ai < 1; ⋀Ai S. ⟦Ai ∈ insert x Fa; S ⊆ insert x Fa - {Ai}; S ≠ {}; 0 < prob (⋂Aj∈S. space M - F Aj)⟧ ⟹ 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai; ⋀Ai. Ai ∈ insert x Fa ⟹ prob (F Ai) ≤ f Ai⟧ ⟹ (∏Ai∈insert x Fa. 1 - f Ai) ≤ prob (⋂Ai∈insert x Fa. space M - F Ai)›*)
case (insert x X) (*‹finite X› ‹(X::nat set) ≠ {}› ‹x ∉ X› ‹⟦F ` X ⊆ events; ⋀Ai. Ai ∈ X ⟹ 0 ≤ f Ai ∧ f Ai < 1; ⋀Ai S. ⟦Ai ∈ X; S ⊆ X - {Ai}; S ≠ {}; 0 < prob (⋂Aj∈S. space M - F Aj)⟧ ⟹ 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai; ⋀Ai. Ai ∈ X ⟹ prob (F Ai) ≤ f Ai⟧ ⟹ (∏Ai∈X. 1 - f Ai) ≤ prob (⋂Ai∈X. space M - F Ai)› ‹F ` insert x X ⊆ events› ‹?Ai12 ∈ insert x X ⟹ 0 ≤ f ?Ai12 ∧ f ?Ai12 < 1› ‹⟦?Ai12 ∈ insert x X; ?S12 ⊆ insert x X - {?Ai12}; ?S12 ≠ {}; 0 < prob (⋂Aj∈?S12. space M - F Aj)⟧ ⟹ 𝒫(F ?Ai12 | ⋂Aj∈?S12. space M - F Aj) ≤ f ?Ai12› ‹?Ai12 ∈ insert x X ⟹ prob (F ?Ai12) ≤ f ?Ai12›*)
define Ax where "Ax = ?c ` (insert x X)"
have xie: "F x ∈ events"
using insert.prems (*‹F ` insert x X ⊆ events› ‹?Ai12 ∈ insert x X ⟹ 0 ≤ f ?Ai12 ∧ f ?Ai12 < 1› ‹⟦?Ai12 ∈ insert x X; ?S12 ⊆ insert x X - {?Ai12}; ?S12 ≠ {}; 0 < prob (⋂Aj∈?S12. space M - F Aj)⟧ ⟹ 𝒫(F ?Ai12 | ⋂Aj∈?S12. space M - F Aj) ≤ f ?Ai12› ‹(?Ai12::nat) ∈ insert (x::nat) (X::nat set) ⟹ prob ((F::nat ⇒ 'a::type set) ?Ai12) ≤ (f::nat ⇒ real) ?Ai12›*) by simp
have A'ie: "⋂(?c ` X) ∈ events"
using insert.prems (*‹(F::nat ⇒ 'a::type set) ` insert (x::nat) (X::nat set) ⊆ events› ‹?Ai12 ∈ insert x X ⟹ 0 ≤ f ?Ai12 ∧ f ?Ai12 < 1› ‹⟦?Ai12 ∈ insert x X; ?S12 ⊆ insert x X - {?Ai12}; ?S12 ≠ {}; 0 < prob (⋂Aj∈?S12. space M - F Aj)⟧ ⟹ 𝒫(F ?Ai12 | ⋂Aj∈?S12. space M - F Aj) ≤ f ?Ai12› ‹(?Ai12::nat) ∈ insert (x::nat) (X::nat set) ⟹ prob ((F::nat ⇒ 'a set) ?Ai12) ≤ (f::nat ⇒ real) ?Ai12›*) insert.hyps (*‹finite X› ‹X ≠ {}› ‹x ∉ X› ‹⟦F ` X ⊆ events; ⋀Ai. Ai ∈ X ⟹ 0 ≤ f Ai ∧ f Ai < 1; ⋀Ai S. ⟦Ai ∈ X; S ⊆ X - {Ai}; S ≠ {}; 0 < prob (⋂Aj∈S. space M - F Aj)⟧ ⟹ 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai; ⋀Ai. Ai ∈ X ⟹ prob (F Ai) ≤ f Ai⟧ ⟹ (∏Ai∈X. 1 - f Ai) ≤ prob (⋂Ai∈X. space M - F Ai)›*) by auto
have "(⋀Ai S. Ai ∈ insert x X ⟹ S ⊆ insert x X - {Ai} ⟹ S ≠ {} ⟹ prob (⋂ Aj ∈ S . (?c Aj)) > 0
⟹ 𝒫(F Ai | ⋂ (?c ` S)) ≤ f Ai)"
using insert.prems (*‹F ` insert x X ⊆ events› ‹(?Ai12::nat) ∈ insert (x::nat) (X::nat set) ⟹ (0::real) ≤ (f::nat ⇒ real) ?Ai12 ∧ f ?Ai12 < (1::real)› ‹⟦?Ai12 ∈ insert x X; ?S12 ⊆ insert x X - {?Ai12}; ?S12 ≠ {}; 0 < prob (⋂Aj∈?S12. space M - F Aj)⟧ ⟹ 𝒫(F ?Ai12 | ⋂Aj∈?S12. space M - F Aj) ≤ f ?Ai12› ‹?Ai12 ∈ insert x X ⟹ prob (F ?Ai12) ≤ f ?Ai12›*) by simp
then have "(⋀Ai S. Ai ∈ X ⟹ S ⊆ X - {Ai} ⟹ S ≠ {} ⟹ prob (⋂ Aj ∈ S . (?c Aj)) > 0
⟹ 𝒫(F Ai | ⋂ (?c ` S)) ≤ f Ai)"
by auto
then have A'gt: "(∏Ai∈X. 1 - f Ai) ≤ prob (⋂ (?c ` X))"
using insert.hyps(4) (*‹⟦F ` X ⊆ events; ⋀Ai. Ai ∈ X ⟹ 0 ≤ f Ai ∧ f Ai < 1; ⋀Ai S. ⟦Ai ∈ X; S ⊆ X - {Ai}; S ≠ {}; 0 < prob (⋂Aj∈S. space M - F Aj)⟧ ⟹ 𝒫(F Ai | ⋂Aj∈S. space M - F Aj) ≤ f Ai; ⋀Ai. Ai ∈ X ⟹ prob (F Ai) ≤ f Ai⟧ ⟹ (∏Ai∈X. 1 - f Ai) ≤ prob (⋂Ai∈X. space M - F Ai)›*) insert.prems(2) (*‹?Ai12 ∈ insert x X ⟹ 0 ≤ f ?Ai12 ∧ f ?Ai12 < 1›*) insert.prems(1) (*‹F ` insert x X ⊆ events›*) insert.prems(4) (*‹?Ai12 ∈ insert x X ⟹ prob (F ?Ai12) ≤ f ?Ai12›*) by auto
then have "prob (⋂(?c ` X)) > 0"
using insert.hyps (*‹finite (X::nat set)› ‹X ≠ {}› ‹x ∉ X› ‹⟦(F::nat ⇒ 'a set) ` (X::nat set) ⊆ events; ⋀Ai::nat. Ai ∈ X ⟹ (0::real) ≤ (f::nat ⇒ real) Ai ∧ f Ai < (1::real); ⋀(Ai::nat) S::nat set. ⟦Ai ∈ X; S ⊆ X - {Ai}; S ≠ {}; (0::real) < prob (⋂Aj::nat∈S. space (M::'a measure) - F Aj)⟧ ⟹ 𝒫(F Ai | ⋂Aj::nat∈S. space M - F Aj) ≤ f Ai; ⋀Ai::nat. Ai ∈ X ⟹ prob (F Ai) ≤ f Ai⟧ ⟹ (∏Ai::nat∈X. (1::real) - f Ai) ≤ prob (⋂Ai::nat∈X. space M - F Ai)›*) insert.prems (*‹F ` insert x X ⊆ events› ‹(?Ai12::nat) ∈ insert (x::nat) (X::nat set) ⟹ (0::real) ≤ (f::nat ⇒ real) ?Ai12 ∧ f ?Ai12 < (1::real)› ‹⟦?Ai12 ∈ insert x X; ?S12 ⊆ insert x X - {?Ai12}; ?S12 ≠ {}; 0 < prob (⋂Aj∈?S12. space M - F Aj)⟧ ⟹ 𝒫(F ?Ai12 | ⋂Aj∈?S12. space M - F Aj) ≤ f ?Ai12› ‹?Ai12 ∈ insert x X ⟹ prob (F ?Ai12) ≤ f ?Ai12›*) prod_pos (*‹(⋀a. a ∈ ?A ⟹ 0 < ?f a) ⟹ 0 < prod ?f ?A›*) basic_trans_rules(22) (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*) diff_gt_0_iff_gt (*‹(0 < ?a - ?b) = (?b < ?a)›*) by (metis (no_types, lifting) insert_Diff (*‹?a ∈ ?A ⟹ insert ?a (?A - {?a}) = ?A›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) subset_insertI (*‹?B ⊆ insert ?a ?B›*))
then have "𝒫((?c x) | (⋂(?c ` X))) = 1 - 𝒫(F x | (⋂(?c ` X)))"
using cond_prob_neg[of "⋂(?c ` X)" "F x"] (*‹⟦(⋂i∈X. space M - F i) ∈ events; F x ∈ events; 0 < prob (⋂i∈X. space M - F i)⟧ ⟹ 𝒫(space M - F x | ⋂i∈X. space M - F i) = 1 - 𝒫(F x | ⋂i∈X. space M - F i)›*) xie (*‹(F::nat ⇒ 'a set) (x::nat) ∈ events›*) A'ie (*‹(⋂i∈X. space M - F i) ∈ events›*) by simp
moreover have "𝒫(F x | (⋂(?c ` X))) ≤ f x"
using insert.prems(3)[of x X] (*‹⟦(x::nat) ∈ insert x (X::nat set); X ⊆ insert x X - {x}; X ≠ {}; (0::real) < prob (⋂Aj::nat∈X. space (M::'a::type measure) - (F::nat ⇒ 'a::type set) Aj)⟧ ⟹ 𝒫(F x | ⋂Aj::nat∈X. space M - F Aj) ≤ (f::nat ⇒ real) x›*) insert.hyps(2) (*‹(X::nat set) ≠ {}›*) insert(3) (*‹(x::nat) ∉ (X::nat set)›*) A'gt (*‹(∏Ai∈X. 1 - f Ai) ≤ prob (⋂i∈X. space M - F i)›*) ‹0 < prob (⋂ (?c ` X))› (*‹0 < prob (⋂i∈X. space M - F i)›*) by fastforce
ultimately have pnxgt: "𝒫((?c x) | (⋂(?c ` X))) ≥ 1 - f x"
by simp
have xgt0: "1 - f x ≥ 0"
using insert.prems(2)[of x] (*‹x ∈ insert x X ⟹ 0 ≤ f x ∧ f x < 1›*) by auto
have "prob (⋂ Ax) = prob ((?c x) ∩ ⋂(?c ` X))"
using Ax_def (*‹Ax = (λi. space M - F i) ` insert x X›*) by simp
also (*calculation: ‹prob (⋂ Ax) = prob ((space M - F x) ∩ (⋂i∈X. space M - F i))›*) have "... = prob (⋂(?c ` X)) * 𝒫((?c x) | (⋂(?c ` X)))"
using prob_intersect_B (*‹⟦(?A::'a::type set) ∈ events; (?B::'a::type set) ∈ events⟧ ⟹ prob (?A ∩ ?B) = prob ?B * 𝒫(?A | ?B)›*) xie (*‹F x ∈ events›*) A'ie (*‹(⋂i∈X. space M - F i) ∈ events›*) by simp
also (*calculation: ‹prob (⋂ Ax) = prob (⋂i∈X. space M - F i) * 𝒫(space M - F x | ⋂i∈X. space M - F i)›*) have "... ≥ (∏Ai∈X. 1 - f Ai) * (1 - f x)"
using A'gt (*‹(∏Ai∈X. 1 - f Ai) ≤ prob (⋂i∈X. space M - F i)›*) pnxgt (*‹1 - f x ≤ 𝒫(space M - F x | ⋂i∈X. space M - F i)›*) mult_left_le (*‹⟦?c ≤ 1; 0 ≤ ?a⟧ ⟹ ?a * ?c ≤ ?a›*) ‹0 < prob (⋂(?c ` X))› (*‹(0::real) < prob (⋂i::nat∈X::nat set. space (M::'a::type measure) - (F::nat ⇒ 'a::type set) i)›*) xgt0 (*‹0 ≤ 1 - f x›*) mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) by (smt(verit))
finally (*calculation: ‹(∏Ai∈X. 1 - f Ai) * (1 - f x) ≤ prob (⋂ Ax)›*) have "prob (⋂ Ax) ≥ (∏Ai∈insert x X. 1 - f Ai)"
by (simp add: local.insert( (*‹finite X›*) 1) local.insert( (*‹x ∉ X›*) 3) mult.commute (*‹?a * ?b = ?b * ?a›*))
then show "?case"
(*goal: ‹(∏Ai∈insert x X. 1 - f Ai) ≤ prob (⋂Ai∈insert x X. space M - F Ai)›*)
using Ax_def (*‹Ax = (λi. space M - F i) ` insert x X›*) by auto
qed
qed
subsection ‹Lovasz Corollaries and Variations ›
corollary lovasz_local_general_positive:
assumes "A ≠ {}"
assumes "F ` A ⊆ events"
assumes "finite A"
assumes "⋀ Ai . Ai ∈ A ⟹ f Ai ≥ 0 ∧ f Ai < 1"
assumes "dependency_digraph G M F"
assumes "⋀ Ai. Ai ∈ A ⟹ (prob (F Ai) ≤
(f Ai) * (∏ Aj ∈ pre_digraph.neighborhood G Ai. (1 - (f Aj))))"
assumes "pverts G = A"
shows "prob (⋂ Ai ∈ A . (space M - (F Ai))) > 0"
using assms (*‹A ≠ {}› ‹(F::nat ⇒ 'a set) ` (A::nat set) ⊆ events› ‹finite A› ‹(?Ai12::nat) ∈ (A::nat set) ⟹ (0::real) ≤ (f::nat ⇒ real) ?Ai12 ∧ f ?Ai12 < (1::real)› ‹dependency_digraph G M F› ‹(?Ai12::nat) ∈ (A::nat set) ⟹ prob ((F::nat ⇒ 'a set) ?Ai12) ≤ (f::nat ⇒ real) ?Ai12 * (∏Aj::nat∈pre_digraph.neighborhood (with_proj (G::nat pair_pre_digraph)) ?Ai12. (1::real) - f Aj)› ‹pverts G = A›*) lovasz_local_general(1)[of A F f G] (*‹⟦A ≠ {}; F ` A ⊆ events; finite A; ⋀Ai. Ai ∈ A ⟹ 0 ≤ f Ai ∧ f Ai < 1; dependency_digraph G M F; ⋀Ai. Ai ∈ A ⟹ prob (F Ai) ≤ f Ai * (∏Aj∈pre_digraph.neighborhood (with_proj G) Ai. 1 - f Aj); pverts G = A⟧ ⟹ (∏Ai∈A. 1 - f Ai) ≤ prob (⋂Ai∈A. space M - F Ai)›*) lovasz_local_general(2)[of A F f G] (*‹⟦A ≠ {}; F ` A ⊆ events; finite A; ⋀Ai. Ai ∈ A ⟹ 0 ≤ f Ai ∧ f Ai < 1; dependency_digraph G M F; ⋀Ai. Ai ∈ A ⟹ prob (F Ai) ≤ f Ai * (∏Aj∈pre_digraph.neighborhood (with_proj G) Ai. 1 - f Aj); pverts G = A⟧ ⟹ 0 < (∏Ai∈A. 1 - f Ai)›*) by simp
theorem lovasz_local_symmetric_dep_graph:
fixes e :: real
fixes d :: nat
assumes "A ≠ {}"
assumes "F ` A ⊆ events"
assumes "finite A"
assumes "dependency_digraph G M F"
assumes "⋀ Ai. Ai ∈ A ⟹ out_degree G Ai ≤ d"
assumes "⋀ Ai. Ai ∈ A ⟹ prob (F Ai) ≤ p"
assumes "exp(1)* p * (d + 1) ≤ 1" (* e should be euler's number ⇒ using exponential function? *)
assumes "pverts G = A"
shows "prob (⋂ Ai ∈ A . (space M - (F Ai))) > 0"
proof (cases "d = 0")
(*goals:
1. ‹d = 0 ⟹ 0 < prob (⋂Ai∈A. space M - F Ai)›
2. ‹d ≠ 0 ⟹ 0 < prob (⋂Ai∈A. space M - F Ai)›*)
case True (*‹d = 0›*)
interpret g: dependency_digraph G M F
using assms(4) (*‹dependency_digraph G M F›*) by simp
have "indep_events F A"
using g.dep_graph_indep_events[of A] (*‹⟦A ⊆ pverts G; ⋀Ai. Ai ∈ A ⟹ out_degree (with_proj G) Ai = 0⟧ ⟹ indep_events F A›*) assms(8) (*‹pverts G = A›*) assms(5) (*‹(?Ai12::nat) ∈ (A::nat set) ⟹ out_degree (with_proj (G::nat pair_pre_digraph)) ?Ai12 ≤ (d::nat)›*) True (*‹d = 0›*) by simp
moreover have "p < 1"
proof (-)
(*goal: ‹p < 1›*)
have "exp (1) * p ≤ 1"
using assms(7) (*‹exp (1::real) * (p::real) * real ((d::nat) + (1::nat)) ≤ (1::real)›*) True (*‹(d::nat) = (0::nat)›*) by simp
then show "?thesis"
(*goal: ‹(p::real) < (1::real)›*)
using exp_gt_one (*‹0 < ?x ⟹ 1 < exp ?x›*) less_1_mult (*‹⟦(1::?'a) < (?m::?'a); (1::?'a) < (?n::?'a)⟧ ⟹ (1::?'a) < ?m * ?n›*) linorder_neqE_linordered_idom (*‹⟦?x ≠ ?y; ?x < ?y ⟹ ?thesis; ?y < ?x ⟹ ?thesis⟧ ⟹ ?thesis›*) rel_simps(68) (*‹0 < 1›*) verit_prod_simplify(2) (*‹?a * 1 = ?a›*) by (smt (verit) mult_le_cancel_left1 (*‹(?c ≤ ?c * ?b) = ((0 < ?c ⟶ 1 ≤ ?b) ∧ (?c < 0 ⟶ ?b ≤ 1))›*))
qed
ultimately show "?thesis"
(*goal: ‹0 < prob (⋂Ai∈A. space M - F Ai)›*)
using complete_indep_bound3[of A F] (*‹⟦finite (A::nat set); A ≠ {}; (F::nat ⇒ 'a set) ` A ⊆ events; indep_events F A; ⋀a::nat. a ∈ A ⟹ prob (F a) < (1::real)⟧ ⟹ (0::real) < prob (⋂a::nat∈A. space (M::'a measure) - F a)›*) assms(2) (*‹F ` A ⊆ events›*) assms(1) (*‹A ≠ {}›*) assms(3) (*‹finite A›*) assms(6) (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ p›*) by force
next
(*goal: ‹d ≠ 0 ⟹ 0 < prob (⋂Ai∈A. space M - F Ai)›*)
case False (*‹d ≠ 0›*)
define f :: "nat ⇒ real" where "f ≡ (λ Ai . 1 /(d + 1))"
then have fbounds: "⋀ Ai. f Ai ≥ 0 ∧ f Ai < 1"
using f_def (*‹f::nat ⇒ real ≡ λAi::nat. (1::real) / real ((d::nat) + (1::nat))›*) False (*‹d ≠ 0›*) by simp
interpret dg: dependency_digraph G M F
using assms(4) (*‹dependency_digraph G M F›*) by auto
have "⋀ Ai. Ai ∈ A ⟹ prob (F Ai) ≤ (f Ai) * (∏ Aj ∈ dg.neighborhood Ai . (1 - (f Aj)))"
proof (-)
(*goal: ‹⋀Ai. Ai ∈ A ⟹ prob (F Ai) ≤ f Ai * (∏Aj∈dg.neighborhood Ai. 1 - f Aj)›*)
fix Ai
assume ain: "Ai ∈ A" (*‹(Ai::nat) ∈ (A::nat set)›*)
have d_boundslt1: "(1/(d + 1)) < 1" and d_boundsgt0: "(1/(d + 1))> 0"
using False (*‹d ≠ 0›*)
(*goals:
1. ‹(1::real) / real ((d::nat) + (1::nat)) < (1::real)›
2. ‹(0::real) < (1::real) / real ((d::nat) + (1::nat))›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply fastforce
(*proven 2 subgoals*) .
have d_bounds2: "(1 - (1 /(d + 1)))^d < 1"
using False (*‹d ≠ 0›*) apply (simp add: field_simps (*‹(?a::?'a::semigroup_add) + (?b::?'a::semigroup_add) + (?c::?'a::semigroup_add) = ?a + (?b + ?c)› ‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a› ‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)› ‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)› ‹(?a::?'a::ab_semigroup_mult) * (?b::?'a::ab_semigroup_mult) = ?b * ?a› ‹(?b::?'a::ab_semigroup_mult) * ((?a::?'a::ab_semigroup_mult) * (?c::?'a::ab_semigroup_mult)) = ?a * (?b * ?c)› ‹(?a::?'a::cancel_ab_semigroup_add) - (?b::?'a::cancel_ab_semigroup_add) - (?c::?'a::cancel_ab_semigroup_add) = ?a - (?b + ?c)› ‹(?a::?'a::group_add) + ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?b - ?c› ‹((?a::?'a::group_add) - (?b::?'a::group_add) = (?c::?'a::group_add)) = (?a = ?c + ?b)› ‹((?a::?'a::group_add) = (?c::?'a::group_add) - (?b::?'a::group_add)) = (?a + ?b = ?c)› ‹(?a::?'a::group_add) - ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?c - ?b› ‹(?a::?'a::ab_group_add) - (?b::?'a::ab_group_add) + (?c::?'a::ab_group_add) = ?a + ?c - ?b› and more 77 facts*))
(*goal: ‹(1 - 1 / real (d + 1)) ^ d < 1›*)
by (smt (verit) of_nat_0_le_iff (*‹0 ≤ of_nat ?n›*) power_mono_iff (*‹⟦0 ≤ ?a; 0 ≤ ?b; 0 < ?n⟧ ⟹ (?a ^ ?n ≤ ?b ^ ?n) = (?a ≤ ?b)›*))
have d_bounds0: "(1 - (1 /(d + 1)))^d > 0"
using False (*‹d ≠ 0›*) by simp
have "exp(1) > (1 + 1/d) powr d"
using exp_1_gt_powr (*‹0 < ?x ⟹ (1 + 1 / ?x) powr ?x < exp 1›*) False (*‹d ≠ 0›*) by simp
then have "exp(1) > (1 + 1/d)^d"
using False (*‹d ≠ 0›*) by (simp add: powr_realpow (*‹0 < ?x ⟹ ?x powr real ?n = ?x ^ ?n›*) zero_compare_simps( (*‹⟦0 ≤ ?a; ?b < ?c⟧ ⟹ ?b < ?a + ?c›*) 2))
moreover have "1/(1+ 1/d)^d = (1 - (1/(d+1)))^d"
proof (-)
(*goal: ‹1 / (1 + 1 / real d) ^ d = (1 - 1 / real (d + 1)) ^ d›*)
have "1/(1+ 1/d)^d = 1/((d/d) + 1/d)^d"
by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))
then show "?thesis"
(*goal: ‹(1::real) / ((1::real) + (1::real) / real (d::nat)) ^ d = ((1::real) - (1::real) / real (d + (1::nat))) ^ d›*)
by (simp add: field_simps (*‹(?a::?'a::semigroup_add) + (?b::?'a::semigroup_add) + (?c::?'a::semigroup_add) = ?a + (?b + ?c)› ‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a› ‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)› ‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)› ‹(?a::?'a::ab_semigroup_mult) * (?b::?'a::ab_semigroup_mult) = ?b * ?a› ‹(?b::?'a::ab_semigroup_mult) * ((?a::?'a::ab_semigroup_mult) * (?c::?'a::ab_semigroup_mult)) = ?a * (?b * ?c)› ‹(?a::?'a::cancel_ab_semigroup_add) - (?b::?'a::cancel_ab_semigroup_add) - (?c::?'a::cancel_ab_semigroup_add) = ?a - (?b + ?c)› ‹(?a::?'a::group_add) + ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?b - ?c› ‹((?a::?'a::group_add) - (?b::?'a::group_add) = (?c::?'a::group_add)) = (?a = ?c + ?b)› ‹((?a::?'a::group_add) = (?c::?'a::group_add) - (?b::?'a::group_add)) = (?a + ?b = ?c)› ‹(?a::?'a::group_add) - ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?c - ?b› ‹(?a::?'a::ab_group_add) - (?b::?'a::ab_group_add) + (?c::?'a::ab_group_add) = ?a + ?c - ?b› and more 77 facts*))
qed
ultimately have exp_lt: "1/exp(1) < (1 - (1 /(d + 1)))^d"
by (metis d_bounds0 (*‹0 < (1 - 1 / real (d + 1)) ^ d›*) frac_less2 (*‹⟦0 < ?x; ?x ≤ ?y; 0 < ?w; ?w < ?z⟧ ⟹ ?x / ?z < ?y / ?w›*) less_eq_real_def (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*) of_nat_zero_less_power_iff (*‹(0 < of_nat ?x ^ ?n) = (0 < ?x ∨ ?n = 0)›*) power_eq_if (*‹?p ^ ?m = (if ?m = 0 then 1 else ?p * ?p ^ (?m - 1))›*) zero_less_divide_1_iff (*‹(0 < 1 / ?a) = (0 < ?a)›*))
then have "(1 /(d + 1))* (1 - (1 /(d + 1)))^d > (1 /(d + 1))*(1/exp(1))"
using exp_lt (*‹1 / exp 1 < (1 - 1 / real (d + 1)) ^ d›*) mult_strict_left_mono[of "1/exp(1)" "(1 - (1 /(d + 1)))^d" "(1/(d+1))"] (*‹⟦1 / exp 1 < (1 - 1 / real (d + 1)) ^ d; 0 < 1 / real (d + 1)⟧ ⟹ 1 / real (d + 1) * (1 / exp 1) < 1 / real (d + 1) * (1 - 1 / real (d + 1)) ^ d›*) d_boundslt1 (*‹1 / real (d + 1) < 1›*) by simp
then have "(1 /(d + 1))* (1 - (1 /(d + 1)))^d > (1/((d+1)*exp(1)))"
by auto
then have gtp: "(1 /(d + 1))* (1 - (1 /(d + 1)))^d > p"
by (smt (verit, ccfv_SIG) d_boundslt1 (*‹1 / real (d + 1) < 1›*) d_boundsgt0 (*‹0 < 1 / real (d + 1)›*) assms( (*‹exp 1 * p * real (d + 1) ≤ 1›*) 7) divide_divide_eq_left (*‹?a / ?b / ?c = ?a / (?b * ?c)›*) divide_less_cancel (*‹(?a / ?c < ?b / ?c) = ((0 < ?c ⟶ ?a < ?b) ∧ (?c < 0 ⟶ ?b < ?a) ∧ ?c ≠ 0)›*) divide_less_eq (*‹(?b / ?c < ?a) = (if 0 < ?c then ?b < ?a * ?c else if ?c < 0 then ?a * ?c < ?b else 0 < ?a)›*) divide_nonneg_nonpos (*‹⟦0 ≤ ?x; ?y ≤ 0⟧ ⟹ ?x / ?y ≤ 0›*) nonzero_mult_div_cancel_left (*‹?a ≠ 0 ⟹ ?a * ?b div ?a = ?b›*) not_exp_le_zero (*‹¬ exp ?x ≤ 0›*))
have "card (dg.neighborhood Ai) ≤ d"
using assms(5) (*‹?Ai12 ∈ A ⟹ out_degree (with_proj G) ?Ai12 ≤ d›*) dg.out_degree_neighborhood (*‹out_degree (with_proj (G::nat pair_pre_digraph)) (?u::nat) = card (dg.neighborhood ?u)›*) ain (*‹Ai ∈ A›*) by auto
then have "(∏ Aj ∈ dg.neighborhood Ai . (1 - (1 /(d + 1)))) ≥ (1 - (1 /(d + 1)))^d"
using prod_constant_ge[of "dg.neighborhood Ai" "d" "1 - (1/d+1)"] (*‹⟦card (dg.neighborhood Ai) ≤ d; 0 ≤ 1 - (1 / real d + 1); 1 - (1 / real d + 1) < 1⟧ ⟹ (1 - (1 / real d + 1)) ^ d ≤ (∏x∈dg.neighborhood Ai. 1 - (1 / real d + 1))›*) using d_boundslt1 (*‹1 / real (d + 1) < 1›*) by auto
then have "(1 /(d + 1)) * (∏ Aj ∈ dg.neighborhood Ai . (1 - (1 /(d + 1)))) ≥ (1 /(d + 1))* (1 - (1 /(d + 1)))^d"
by (simp add: divide_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a / ?c ≤ ?b / ?c›*))
then have "(1 /(d + 1)) * (∏ Aj ∈ dg.neighborhood Ai . (1 - (1 /(d + 1)))) > p"
using gtp (*‹p < 1 / real (d + 1) * (1 - 1 / real (d + 1)) ^ d›*) by simp
then show "prob (F Ai) ≤ f Ai * (∏ Aj ∈ dg.neighborhood Ai . (1 - f Aj))"
using assms(6) (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ p›*) ‹Ai ∈ A› (*‹Ai ∈ A›*) f_def (*‹f ≡ λAi. 1 / real (d + 1)›*) by force
qed
then show "?thesis"
(*goal: ‹0 < prob (⋂Ai∈A. space M - F Ai)›*)
using lovasz_local_general_positive[of A F f G] (*‹⟦(A::nat set) ≠ {}; (F::nat ⇒ 'a set) ` A ⊆ events; finite A; ⋀Ai::nat. Ai ∈ A ⟹ (0::real) ≤ (f::nat ⇒ real) Ai ∧ f Ai < (1::real); dependency_digraph (G::nat pair_pre_digraph) (M::'a measure) F; ⋀Ai::nat. Ai ∈ A ⟹ prob (F Ai) ≤ f Ai * (∏Aj::nat∈dg.neighborhood Ai. (1::real) - f Aj); pverts G = A⟧ ⟹ (0::real) < prob (⋂Ai::nat∈A. space M - F Ai)›*) assms(4) (*‹dependency_digraph G M F›*) assms(1) (*‹A ≠ {}›*) assms(2) (*‹F ` A ⊆ events›*) assms(3) (*‹finite A›*) assms(8) (*‹pverts G = A›*) fbounds (*‹0 ≤ f ?Ai12 ∧ f ?Ai12 < 1›*) by auto
qed
corollary lovasz_local_symmetric4gt:
fixes e :: real
fixes d :: nat
assumes "A ≠ {}"
assumes "F ` A ⊆ events"
assumes "finite A"
assumes "dependency_digraph G M F"
assumes "⋀ Ai. Ai ∈ A ⟹ out_degree G Ai ≤ d"
assumes "⋀ Ai. Ai ∈ A ⟹ prob (F Ai) ≤ p"
assumes "4 * p * d ≤ 1" (* only works if d \ge 3 *)
assumes "d ≥ 3"
assumes "pverts G = A"
shows "prob (⋂ Ai ∈ A . (space M - F Ai)) > 0"
proof (-)
(*goal: ‹0 < prob (⋂Ai∈A. space M - F Ai)›*)
have "exp(1)* p * (d + 1) ≤ 1"
proof (cases "p = 0")
(*goals:
1. ‹p = 0 ⟹ exp 1 * p * real (d + 1) ≤ 1›
2. ‹p ≠ 0 ⟹ exp 1 * p * real (d + 1) ≤ 1›*)
case True (*‹p = 0›*)
then show "?thesis"
(*goal: ‹exp 1 * p * real (d + 1) ≤ 1›*)
by simp
next
(*goal: ‹(p::real) ≠ (0::real) ⟹ exp (1::real) * p * real ((d::nat) + (1::nat)) ≤ (1::real)›*)
case False (*‹(p::real) ≠ (0::real)›*)
then have pgt: "p > 0"
using assms(1) (*‹A ≠ {}›*) assms(6) (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ p›*) assms(3) (*‹finite A›*) ex_min_if_finite (*‹⟦finite ?S; ?S ≠ {}⟧ ⟹ ∃m∈?S. ¬ (∃x∈?S. x < m)›*) less_eq_real_def (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*) by (meson basic_trans_rules( (*‹⟦(?x::?'a) ≤ (?y::?'a); ?y ≤ (?z::?'a)⟧ ⟹ ?x ≤ ?z›*) 23) basic_trans_rules( (*‹⟦(?a::?'a) ≤ (?b::?'a); ?b ≤ ?a⟧ ⟹ ?a = ?b›*) 24) linorder_neqE_linordered_idom (*‹⟦(?x::?'a) ≠ (?y::?'a); ?x < ?y ⟹ ?thesis::bool; ?y < ?x ⟹ ?thesis⟧ ⟹ ?thesis›*) measure_nonneg (*‹(0::real) ≤ Sigma_Algebra.measure (?M::?'a measure) (?A::?'a set)›*))
have "3 * (d + 1) ≤ 4 * d"
by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) assms( (*‹3 ≤ d›*) 8))
then have "exp(1) * (d + 1) ≤ 4 *d"
using exp_le (*‹exp (1::real) ≤ (3::real)›*) exp_gt_one[of 1] (*‹0 < 1 ⟹ 1 < exp 1›*) assms(8) (*‹3 ≤ d›*) by (smt (verit, del_insts) Num.of_nat_simps( (*‹of_nat 1 = 1›*) 2) Num.of_nat_simps( (*‹of_nat (?m * ?n) = of_nat ?m * of_nat ?n›*) 5) le_add2 (*‹?n ≤ ?m + ?n›*) le_eq_less_or_eq (*‹(?m ≤ ?n) = (?m < ?n ∨ ?m = ?n)›*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) nat_less_real_le (*‹(?n < ?m) = (real ?n + 1 ≤ real ?m)›*) numeral.simps( (*‹numeral (num.Bit1 ?n) = numeral ?n + numeral ?n + 1›*) 3) numerals( (*‹Numeral1 = 1›*) 1) of_nat_numeral (*‹of_nat (numeral ?n) = numeral ?n›*))
then have "exp(1) * (d + 1) * p ≤ 4 *d *p"
using pgt (*‹0 < p›*) by simp
then show "?thesis"
(*goal: ‹exp (1::real) * (p::real) * real ((d::nat) + (1::nat)) ≤ (1::real)›*)
using assms(7) (*‹4 * p * real d ≤ 1›*) by (simp add: field_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 77 facts*))
qed
then show "?thesis"
(*goal: ‹0 < prob (⋂Ai∈A. space M - F Ai)›*)
using assms (*‹(A::nat set) ≠ {}› ‹F ` A ⊆ events› ‹finite A› ‹dependency_digraph (G::nat pair_pre_digraph) (M::'a::type measure) (F::nat ⇒ 'a::type set)› ‹?Ai12 ∈ A ⟹ out_degree (with_proj G) ?Ai12 ≤ d› ‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ p› ‹4 * p * real d ≤ 1› ‹3 ≤ d› ‹pverts (G::nat pair_pre_digraph) = (A::nat set)›*) lovasz_local_symmetric_dep_graph[of A F G d p] (*‹⟦A ≠ {}; F ` A ⊆ events; finite A; dependency_digraph G M F; ⋀Ai. Ai ∈ A ⟹ out_degree (with_proj G) Ai ≤ d; ⋀Ai. Ai ∈ A ⟹ prob (F Ai) ≤ p; exp 1 * p * real (d + 1) ≤ 1; pverts G = A⟧ ⟹ 0 < prob (⋂Ai∈A. space M - F Ai)›*) by auto
qed
lemma lovasz_local_symmetric4:
fixes e :: real
fixes d :: nat
assumes "A ≠ {}"
assumes "F ` A ⊆ events"
assumes "finite A"
assumes "dependency_digraph G M F"
assumes "⋀ Ai. Ai ∈ A ⟹ out_degree G Ai ≤ d"
assumes "⋀ Ai. Ai ∈ A ⟹ prob (F Ai) ≤ p"
assumes "4 * p * d ≤ 1"
assumes "d ≥ 1"
assumes "pverts G = A"
shows "prob (⋂ Ai ∈ A . (space M - F Ai)) > 0"
proof (cases "d ≥ 3")
(*goals:
1. ‹3 ≤ d ⟹ 0 < prob (⋂Ai∈A. space M - F Ai)›
2. ‹¬ 3 ≤ d ⟹ 0 < prob (⋂Ai∈A. space M - F Ai)›*)
case True (*‹3 ≤ d›*)
then show "?thesis"
(*goal: ‹0 < prob (⋂Ai∈A. space M - F Ai)›*)
using lovasz_local_symmetric4gt (*‹⟦?A ≠ {}; ?F ` ?A ⊆ events; finite ?A; dependency_digraph ?G M ?F; ⋀Ai. Ai ∈ ?A ⟹ out_degree (with_proj ?G) Ai ≤ ?d; ⋀Ai. Ai ∈ ?A ⟹ prob (?F Ai) ≤ ?p; 4 * ?p * real ?d ≤ 1; 3 ≤ ?d; pverts ?G = ?A⟧ ⟹ 0 < prob (⋂Ai∈?A. space M - ?F Ai)›*) assms (*‹A ≠ {}› ‹(F::nat ⇒ 'a set) ` (A::nat set) ⊆ events› ‹finite A› ‹dependency_digraph G M F› ‹?Ai12 ∈ A ⟹ out_degree (with_proj G) ?Ai12 ≤ d› ‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ p› ‹(4::real) * (p::real) * real (d::nat) ≤ (1::real)› ‹1 ≤ d› ‹pverts G = A›*) by presburger
next
(*goal: ‹¬ (3::nat) ≤ (d::nat) ⟹ (0::real) < prob (⋂Ai::nat∈A::nat set. space (M::'a::type measure) - (F::nat ⇒ 'a::type set) Ai)›*)
case d3: False (*‹¬ (3::nat) ≤ (d::nat)›*)
define f :: "nat ⇒ real" where "f ≡ (λ Ai . 1 /(d + 1))"
then have fbounds: "⋀ Ai. f Ai ≥ 0 ∧ f Ai < 1"
using f_def (*‹f ≡ λAi. 1 / real (d + 1)›*) assms(8) (*‹1 ≤ d›*) by simp
interpret dg: dependency_digraph G M F
using assms(4) (*‹dependency_digraph (G::nat pair_pre_digraph) (M::'a measure) (F::nat ⇒ 'a set)›*) by auto
have "⋀ Ai. Ai ∈ A ⟹ prob (F Ai) ≤ (f Ai) * (∏ Aj ∈ dg.neighborhood Ai . (1 - (f Aj)))"
proof (-)
(*goal: ‹⋀Ai. Ai ∈ A ⟹ prob (F Ai) ≤ f Ai * (∏Aj∈dg.neighborhood Ai. 1 - f Aj)›*)
fix Ai
assume ain: "Ai ∈ A" (*‹(Ai::nat) ∈ (A::nat set)›*)
have d_boundslt1: "(1/(d + 1)) < 1" and d_boundsgt0: "(1/(d + 1))> 0"
using assms (*‹(A::nat set) ≠ {}› ‹F ` A ⊆ events› ‹finite (A::nat set)› ‹dependency_digraph G M F› ‹?Ai12 ∈ A ⟹ out_degree (with_proj G) ?Ai12 ≤ d› ‹(?Ai12::nat) ∈ (A::nat set) ⟹ prob ((F::nat ⇒ 'a set) ?Ai12) ≤ (p::real)› ‹4 * p * real d ≤ 1› ‹1 ≤ d› ‹pverts (G::nat pair_pre_digraph) = (A::nat set)›*)
(*goals:
1. ‹1 / real (d + 1) < 1›
2. ‹0 < 1 / real (d + 1)›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply fastforce
(*proven 2 subgoals*) .
have plt: "1/(4*d) ≥ p"
using assms(7) (*‹4 * p * real d ≤ 1›*) assms(8) (*‹1 ≤ d›*) by (metis (mono_tags, opaque_lifting) Num.of_nat_simps( (*‹of_nat (?m * ?n) = of_nat ?m * of_nat ?n›*) 5) bot_nat_0.not_eq_extremum (*‹(?a ≠ 0) = (0 < ?a)›*) le_numeral_extra( (*‹¬ 1 ≤ 0›*) 2) more_arith_simps( (*‹?a * ?b * ?c = ?a * (?b * ?c)›*) 11) mult_of_nat_commute (*‹of_nat ?x * ?y = ?y * of_nat ?x›*) nat_0_less_mult_iff (*‹(0 < ?m * ?n) = (0 < ?m ∧ 0 < ?n)›*) of_nat_0_less_iff (*‹(0 < of_nat ?n) = (0 < ?n)›*) of_nat_numeral (*‹of_nat (numeral ?n) = numeral ?n›*) pos_divide_less_eq (*‹0 < ?c ⟹ (?b / ?c < ?a) = (?b < ?a * ?c)›*) rel_simps( (*‹0 < numeral ?n›*) 51) verit_comp_simplify( (*‹(¬ ?b' ≤ ?a') = (?a' < ?b')›*) 3))
then have gtp: "(1 /(d + 1))* (1 - (1 /(d + 1)))^d ≥ p"
proof (cases "d = 1")
(*goals:
1. ‹⟦(p::real) ≤ (1::real) / real ((4::nat) * (d::nat)); d = (1::nat)⟧ ⟹ p ≤ (1::real) / real (d + (1::nat)) * ((1::real) - (1::real) / real (d + (1::nat))) ^ d›
2. ‹⟦(p::real) ≤ (1::real) / real ((4::nat) * (d::nat)); d ≠ (1::nat)⟧ ⟹ p ≤ (1::real) / real (d + (1::nat)) * ((1::real) - (1::real) / real (d + (1::nat))) ^ d›*)
case False (*‹(d::nat) ≠ (1::nat)›*)
then have "d = 2"
using d3 (*‹¬ (3::nat) ≤ (d::nat)›*) assms(8) (*‹1 ≤ d›*) by auto
then show "?thesis"
(*goal: ‹(p::real) ≤ (1::real) / real ((d::nat) + (1::nat)) * ((1::real) - (1::real) / real (d + (1::nat))) ^ d›*)
using plt (*‹p ≤ 1 / real (4 * d)›*) by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))
qed (simp)
(*solved the remaining goal: ‹⟦p ≤ 1 / real (4 * d); d = 1⟧ ⟹ p ≤ 1 / real (d + 1) * (1 - 1 / real (d + 1)) ^ d›*)
have "card (dg.neighborhood Ai) ≤ d"
using assms(5) (*‹?Ai12 ∈ A ⟹ out_degree (with_proj G) ?Ai12 ≤ d›*) dg.out_degree_neighborhood (*‹out_degree (with_proj G) ?u = card (dg.neighborhood ?u)›*) ain (*‹Ai ∈ A›*) by auto
then have "(∏ Aj ∈ dg.neighborhood Ai . (1 - (1 /(d + 1)))) ≥ (1 - (1 /(d + 1)))^d"
using prod_constant_ge[of "dg.neighborhood Ai" "d" "1 - (1/d+1)"] (*‹⟦card (dg.neighborhood Ai) ≤ d; 0 ≤ 1 - (1 / real d + 1); 1 - (1 / real d + 1) < 1⟧ ⟹ (1 - (1 / real d + 1)) ^ d ≤ (∏x∈dg.neighborhood Ai. 1 - (1 / real d + 1))›*) using d_boundslt1 (*‹1 / real (d + 1) < 1›*) by auto
then have "(1 /(d + 1)) * (∏ Aj ∈ dg.neighborhood Ai . (1 - (1 /(d + 1)))) ≥ (1 /(d + 1))* (1 - (1 /(d + 1)))^d"
by (simp add: divide_right_mono (*‹⟦(?a::?'a) ≤ (?b::?'a); (0::?'a) ≤ (?c::?'a)⟧ ⟹ ?a / ?c ≤ ?b / ?c›*))
then have "(1 /(d + 1)) * (∏ Aj ∈ dg.neighborhood Ai . (1 - (1 /(d + 1)))) ≥ p"
using gtp (*‹p ≤ 1 / real (d + 1) * (1 - 1 / real (d + 1)) ^ d›*) by simp
then show "prob (F Ai) ≤ f Ai * (∏ Aj ∈ dg.neighborhood Ai . (1 - f Aj))"
using assms(6) (*‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ p›*) ‹Ai ∈ A› (*‹Ai ∈ A›*) f_def (*‹f ≡ λAi. 1 / real (d + 1)›*) by force
qed
then show "?thesis"
(*goal: ‹0 < prob (⋂Ai∈A. space M - F Ai)›*)
using lovasz_local_general_positive[of A F f G] (*‹⟦(A::nat set) ≠ {}; (F::nat ⇒ 'a::type set) ` A ⊆ events; finite A; ⋀Ai::nat. Ai ∈ A ⟹ (0::real) ≤ (f::nat ⇒ real) Ai ∧ f Ai < (1::real); dependency_digraph (G::nat pair_pre_digraph) (M::'a::type measure) F; ⋀Ai::nat. Ai ∈ A ⟹ prob (F Ai) ≤ f Ai * (∏Aj::nat∈dg.neighborhood Ai. (1::real) - f Aj); pverts G = A⟧ ⟹ (0::real) < prob (⋂Ai::nat∈A. space M - F Ai)›*) assms(4) (*‹dependency_digraph (G::nat pair_pre_digraph) (M::'a::type measure) (F::nat ⇒ 'a::type set)›*) assms(1) (*‹A ≠ {}›*) assms(2) (*‹(F::nat ⇒ 'a set) ` (A::nat set) ⊆ events›*) assms(3) (*‹finite A›*) assms(9) (*‹pverts G = A›*) fbounds (*‹0 ≤ f ?Ai12 ∧ f ?Ai12 < 1›*) by auto
qed
text ‹Converting between dependency graph and indexed set representation of mutual independence ›
lemma (in pair_digraph) g_Ai_simplification:
assumes "Ai ∈ A"
assumes "g Ai ⊆ A - {Ai}"
assumes "pverts G = A"
assumes "parcs G = {e ∈ A × A . snd e ∈ (A - ({fst e} ∪ (g (fst e))))}"
shows "g Ai = A - ({Ai} ∪ neighborhood Ai)"
proof (-)
(*goal: ‹g Ai = A - ({Ai} ∪ neighborhood Ai)›*)
have "g Ai = A - ({Ai} ∪ {v ∈ A . v ∈ (A - ({Ai} ∪ (g (Ai))))})"
using assms(2) (*‹g Ai ⊆ A - {Ai}›*) by auto
then have "g Ai = A - ({Ai} ∪ {v ∈ A . (Ai, v) ∈ parcs G})"
using Collect_cong (*‹(⋀x. ?P x = ?Q x) ⟹ {x. ?P x} = {x. ?Q x}›*) assms(1) (*‹Ai ∈ A›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) assms(3) (*‹pverts (G::'a pair_pre_digraph) = (A::'a set)›*) assms(4) (*‹parcs (G::'a pair_pre_digraph) = {e::'a × 'a ∈ (A::'a set) × A. snd e ∈ A - ({fst e} ∪ (g::'a ⇒ 'a set) (fst e))}›*) by auto
then show "g Ai = A - ({Ai} ∪ neighborhood Ai)"
unfolding neighborhood_def
(*goal: ‹(g::'a ⇒ 'a set) (Ai::'a) = (A::'a set) - ({Ai} ∪ {v::'a ∈ pverts (G::'a pair_pre_digraph). (Ai, v) ∈ parcs G})›*)
using assms(3) (*‹pverts G = A›*) by simp
qed
lemma define_dep_graph_set:
assumes "A ≠ {}"
assumes "F ` A ⊆ events"
assumes "finite A"
assumes "⋀ Ai. Ai ∈ A ⟹ g Ai ⊆ A - {Ai} ∧ mutual_indep_events (F Ai) F (g Ai)"
shows "dependency_digraph ⦇ pverts = A, parcs = {e ∈ A × A . snd e ∈ (A - ({fst e} ∪ (g (fst e))))} ⦈ M F"
(is "dependency_digraph ?G M F")
proof (-)
(*goal: ‹dependency_digraph ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈ M F›*)
interpret pd: pair_digraph "?G"
using assms(3) (*‹finite A›*) apply unfold_locales
(*goals:
1. ‹⋀e. ⟦finite A; e ∈ parcs ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈⟧ ⟹ fst e ∈ pverts ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈›
2. ‹⋀e. ⟦finite A; e ∈ parcs ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈⟧ ⟹ snd e ∈ pverts ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈›
3. ‹finite A ⟹ finite (pverts ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈)›
4. ‹finite A ⟹ finite (parcs ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈)›
5. ‹⋀e. ⟦finite A; e ∈ parcs ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈⟧ ⟹ fst e ≠ snd e›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .
have "⋀ Ai. Ai ∈ A ⟹ g Ai ⊆ A - {Ai}"
using assms(4) (*‹?Ai12 ∈ A ⟹ g ?Ai12 ⊆ A - {?Ai12} ∧ mutual_indep_events (F ?Ai12) F (g ?Ai12)›*) by simp
then have "⋀ i. i ∈ A ⟹ g i = A - ({i} ∪ pd.neighborhood i)"
using pd.g_Ai_simplification[of _ A g] (*‹⟦?Ai ∈ A; g ?Ai ⊆ A - {?Ai}; pverts ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈ = A; parcs ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈ = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⟧ ⟹ g ?Ai = A - ({?Ai} ∪ pd.neighborhood ?Ai)›*) pd.pair_digraph (*‹pair_digraph ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈›*) by auto
then have "dependency_digraph ?G M F"
using assms(2) (*‹(F::nat ⇒ 'a set) ` (A::nat set) ⊆ events›*) assms(4) (*‹?Ai12 ∈ A ⟹ g ?Ai12 ⊆ A - {?Ai12} ∧ mutual_indep_events (F ?Ai12) F (g ?Ai12)›*) apply unfold_locales
(*goals:
1. ‹⟦⋀i. i ∈ A ⟹ g i = A - ({i} ∪ pd.neighborhood i); F ` A ⊆ events; ⋀Ai. Ai ∈ A ⟹ g Ai ⊆ A - {Ai} ∧ mutual_indep_events (F Ai) F (g Ai)⟧ ⟹ F ` pverts ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈ ⊆ events›
2. ‹⋀i. ⟦⋀i. i ∈ A ⟹ g i = A - ({i} ∪ pd.neighborhood i); F ` A ⊆ events; ⋀Ai. Ai ∈ A ⟹ g Ai ⊆ A - {Ai} ∧ mutual_indep_events (F Ai) F (g Ai); i ∈ pverts ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈⟧ ⟹ mutual_indep_events (F i) F (pverts ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈ - ({i} ∪ pd.neighborhood i))›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
then show "?thesis"
(*goal: ‹dependency_digraph ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈ M F›*)
by simp
qed
lemma define_dep_graph_deg_bound:
assumes "A ≠ {}"
assumes "F ` A ⊆ events"
assumes "finite A"
assumes "⋀ Ai. Ai ∈ A ⟹ g Ai ⊆ A - {Ai} ∧ card (g Ai) ≥ card A - d - 1 ∧
mutual_indep_events (F Ai) F (g Ai)"
shows "⋀ Ai. Ai ∈ A ⟹
out_degree ⦇ pverts = A, parcs = {e ∈ A × A . snd e ∈ (A - ({fst e} ∪ (g (fst e))))} ⦈ Ai ≤ d"
(is "⋀ Ai. Ai ∈ A ⟹ out_degree (with_proj ?G) Ai ≤ d")
proof (-)
(*goal: ‹⋀Ai. Ai ∈ A ⟹ out_degree (with_proj ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈) Ai ≤ d›*)
interpret pd: dependency_digraph "?G" M F
using assms (*‹(A::nat set) ≠ {}› ‹F ` A ⊆ events› ‹finite A› ‹?Ai12 ∈ A ⟹ g ?Ai12 ⊆ A - {?Ai12} ∧ card A - d - 1 ≤ card (g ?Ai12) ∧ mutual_indep_events (F ?Ai12) F (g ?Ai12)›*) define_dep_graph_set (*‹⟦?A ≠ {}; ?F ` ?A ⊆ events; finite ?A; ⋀Ai. Ai ∈ ?A ⟹ ?g Ai ⊆ ?A - {Ai} ∧ mutual_indep_events (?F Ai) ?F (?g Ai)⟧ ⟹ dependency_digraph ⦇pverts = ?A, parcs = {e ∈ ?A × ?A. snd e ∈ ?A - ({fst e} ∪ ?g (fst e))}⦈ M ?F›*) by simp
show "⋀ Ai. Ai ∈ A ⟹ out_degree ?G Ai ≤ d"
proof (-)
(*goal: ‹⋀Ai. Ai ∈ A ⟹ out_degree (with_proj ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈) Ai ≤ d›*)
fix Ai
assume a: "Ai ∈ A" (*‹(Ai::nat) ∈ (A::nat set)›*)
then have geq: "g Ai = A - ({Ai} ∪ pd.neighborhood Ai)"
using assms(4)[of Ai] (*‹Ai ∈ A ⟹ g Ai ⊆ A - {Ai} ∧ card A - d - 1 ≤ card (g Ai) ∧ mutual_indep_events (F Ai) F (g Ai)›*) pd.pair_digraph (*‹pair_digraph ⦇pverts = A::nat set, parcs = {e::nat × nat ∈ A × A. snd e ∈ A - ({fst e} ∪ (g::nat ⇒ nat set) (fst e))}⦈›*) pd.g_Ai_simplification[of Ai A g] (*‹⟦Ai ∈ A; g Ai ⊆ A - {Ai}; pverts ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈ = A; parcs ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈ = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⟧ ⟹ g Ai = A - ({Ai} ∪ pd.neighborhood Ai)›*) by simp
then have pss: "g Ai ⊂ A"
using a (*‹Ai ∈ A›*) by auto
then have "card (g Ai) = card (A - ({Ai} ∪ pd.neighborhood Ai))"
using assms(4) (*‹?Ai12 ∈ A ⟹ g ?Ai12 ⊆ A - {?Ai12} ∧ card A - d - 1 ≤ card (g ?Ai12) ∧ mutual_indep_events (F ?Ai12) F (g ?Ai12)›*) geq (*‹g Ai = A - ({Ai} ∪ pd.neighborhood Ai)›*) by argo
moreover have ss: "({Ai} ∪ pd.neighborhood Ai) ⊆ A"
using pd.neighborhood_wf (*‹pd.neighborhood (?v::nat) ⊆ pverts ⦇pverts = A::nat set, parcs = {e::nat × nat ∈ A × A. snd e ∈ A - ({fst e} ∪ (g::nat ⇒ nat set) (fst e))}⦈›*) a (*‹Ai ∈ A›*) by simp
moreover have "finite ({Ai} ∪ pd.neighborhood Ai)"
using calculation(2) (*‹{Ai} ∪ pd.neighborhood Ai ⊆ A›*) assms(3) (*‹finite A›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by auto
moreover have "Ai ∉ pd.neighborhood Ai"
using pd.neighborhood_self_not (*‹?v ∉ pd.neighborhood ?v›*) by simp
moreover have "card {Ai} = 1"
using is_singleton_altdef (*‹is_singleton ?A = (card ?A = 1)›*) by auto
moreover have cardss: "card ({Ai} ∪ pd.neighborhood Ai) = 1 + card (pd.neighborhood Ai)"
using calculation(5) (*‹card {Ai} = 1›*) calculation(4) (*‹(Ai::nat) ∉ pd.neighborhood Ai›*) card_Un_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*) pd.neighborhood_finite (*‹finite (pd.neighborhood (?v::nat))›*) by auto
ultimately have eq: "card (g Ai) = card A - 1 - card (pd.neighborhood Ai)"
using card_Diff_subset[of "({Ai} ∪ pd.neighborhood Ai)" A] (*‹⟦finite ({Ai} ∪ pd.neighborhood Ai); {Ai} ∪ pd.neighborhood Ai ⊆ A⟧ ⟹ card (A - ({Ai} ∪ pd.neighborhood Ai)) = card A - card ({Ai} ∪ pd.neighborhood Ai)›*) assms(3) (*‹finite (A::nat set)›*) by presburger
have ggt: "⋀ Ai. Ai ∈ A ⟹ card (g Ai) ≥ int (card A) - int d - 1"
using assms(4) (*‹?Ai12 ∈ A ⟹ g ?Ai12 ⊆ A - {?Ai12} ∧ card A - d - 1 ≤ card (g ?Ai12) ∧ mutual_indep_events (F ?Ai12) F (g ?Ai12)›*) by fastforce
have "card (pd.neighborhood Ai) = card A - 1 - card (g Ai)"
using cardss (*‹card ({Ai} ∪ pd.neighborhood Ai) = 1 + card (pd.neighborhood Ai)›*) assms(3) (*‹finite (A::nat set)›*) card_mono (*‹⟦finite ?B; ?A ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*) diff_add_inverse (*‹(?n::nat) + (?m::nat) - ?n = ?m›*) diff_diff_cancel (*‹?i ≤ ?n ⟹ ?n - (?n - ?i) = ?i›*) diff_le_mono (*‹?m ≤ ?n ⟹ ?m - ?l ≤ ?n - ?l›*) ss (*‹{Ai} ∪ pd.neighborhood Ai ⊆ A›*) eq (*‹card (g Ai) = card A - 1 - card (pd.neighborhood Ai)›*) by (metis (no_types, lifting))
moreover have "card A ≥ (1 + card (g Ai))"
using pss (*‹g Ai ⊂ A›*) assms(3) (*‹finite (A::nat set)›*) card_seteq (*‹⟦finite ?B; ?A ⊆ ?B; card ?B ≤ card ?A⟧ ⟹ ?A = ?B›*) not_less_eq_eq (*‹(¬ ?m ≤ ?n) = (Suc ?n ≤ ?m)›*) by auto
ultimately have "card (pd.neighborhood Ai) = int (card A) - 1 - int (card (g Ai))"
by auto
moreover have "int (card (g Ai)) ≥ (card A) - (int d) - 1"
using ggt (*‹?Ai12 ∈ A ⟹ int (card A) - int d - 1 ≤ int (card (g ?Ai12))›*) a (*‹Ai ∈ A›*) by simp
ultimately show "out_degree ?G Ai ≤ d"
using pd.out_degree_neighborhood (*‹out_degree (with_proj ⦇pverts = A::nat set, parcs = {e::nat × nat ∈ A × A. snd e ∈ A - ({fst e} ∪ (g::nat ⇒ nat set) (fst e))}⦈) (?u::nat) = card (pd.neighborhood ?u)›*) by simp
qed
qed
lemma obtain_dependency_graph:
assumes "A ≠ {}"
assumes "F ` A ⊆ events"
assumes "finite A"
assumes "⋀ Ai. Ai ∈ A ⟹
(∃ S . S ⊆ A - {Ai} ∧ card S ≥ card A - d - 1 ∧ mutual_indep_events (F Ai) F S)"
obtains G where "dependency_digraph G M F" "pverts G = A" "⋀ Ai. Ai ∈ A ⟹ out_degree G Ai ≤ d"
proof (-)
(*goal: ‹(⋀G. ⟦dependency_digraph G M F; pverts G = A; ⋀Ai. Ai ∈ A ⟹ out_degree (with_proj G) Ai ≤ d⟧ ⟹ thesis) ⟹ thesis›*)
obtain g where gdef: "⋀ Ai. Ai ∈ A ⟹ g Ai ⊆ A - {Ai} ∧ card (g Ai) ≥ card A - d - 1 ∧
mutual_indep_events (F Ai) F (g Ai)"
(*goal: ‹(⋀g. (⋀Ai. Ai ∈ A ⟹ g Ai ⊆ A - {Ai} ∧ card A - d - 1 ≤ card (g Ai) ∧ mutual_indep_events (F Ai) F (g Ai)) ⟹ thesis) ⟹ thesis›*)
using assms(4) (*‹?Ai12 ∈ A ⟹ ∃S⊆A - {?Ai12}. card A - d - 1 ≤ card S ∧ mutual_indep_events (F ?Ai12) F S›*) by metis
then show "?thesis"
(*goal: ‹thesis›*)
using define_dep_graph_set[of A F g] (*‹⟦A ≠ {}; F ` A ⊆ events; finite A; ⋀Ai. Ai ∈ A ⟹ g Ai ⊆ A - {Ai} ∧ mutual_indep_events (F Ai) F (g Ai)⟧ ⟹ dependency_digraph ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈ M F›*) define_dep_graph_deg_bound[of A F g d] (*‹⟦A ≠ {}; F ` A ⊆ events; finite A; ⋀Ai. Ai ∈ A ⟹ g Ai ⊆ A - {Ai} ∧ card A - d - 1 ≤ card (g Ai) ∧ mutual_indep_events (F Ai) F (g Ai); ?Ai ∈ A⟧ ⟹ out_degree (with_proj ⦇pverts = A, parcs = {e ∈ A × A. snd e ∈ A - ({fst e} ∪ g (fst e))}⦈) ?Ai ≤ d›*) that (*‹⟦dependency_digraph ?G12 M F; pverts ?G12 = A; ⋀Ai. Ai ∈ A ⟹ out_degree (with_proj ?G12) Ai ≤ d⟧ ⟹ thesis›*) assms (*‹A ≠ {}› ‹F ` A ⊆ events› ‹finite (A::nat set)› ‹?Ai12 ∈ A ⟹ ∃S⊆A - {?Ai12}. card A - d - 1 ≤ card S ∧ mutual_indep_events (F ?Ai12) F S›*) by auto
qed
text ‹This is the variation of the symmetric version most commonly in use ›
theorem lovasz_local_symmetric:
fixes d :: nat
assumes "A ≠ {}"
assumes "F ` A ⊆ events"
assumes "finite A"
assumes "⋀ Ai. Ai ∈ A ⟹ (∃ S . S ⊆ A - {Ai} ∧ card S ≥ card A - d - 1 ∧ mutual_indep_events (F Ai) F S)"
assumes "⋀ Ai. Ai ∈ A ⟹ prob (F Ai) ≤ p"
assumes "exp(1)* p * (d + 1) ≤ 1"
shows "prob (⋂ Ai ∈ A . (space M - (F Ai))) > 0"
proof (-)
(*goal: ‹0 < prob (⋂Ai∈A. space M - F Ai)›*)
obtain G where odg: "dependency_digraph G M F" "pverts G = A" "⋀ Ai. Ai ∈ A ⟹ out_degree G Ai ≤ d"
(*goal: ‹(⋀G::nat pair_pre_digraph. ⟦dependency_digraph G (M::'a measure) (F::nat ⇒ 'a set); pverts G = (A::nat set); ⋀Ai::nat. Ai ∈ A ⟹ out_degree (with_proj G) Ai ≤ (d::nat)⟧ ⟹ thesis::bool) ⟹ thesis›*)
using assms (*‹(A::nat set) ≠ {}› ‹F ` A ⊆ events› ‹finite A› ‹?Ai12 ∈ A ⟹ ∃S⊆A - {?Ai12}. card A - d - 1 ≤ card S ∧ mutual_indep_events (F ?Ai12) F S› ‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ p› ‹exp (1::real) * (p::real) * real ((d::nat) + (1::nat)) ≤ (1::real)›*) obtain_dependency_graph (*‹⟦(?A::nat set) ≠ {}; (?F::nat ⇒ 'a set) ` ?A ⊆ events; finite ?A; ⋀Ai::nat. Ai ∈ ?A ⟹ ∃S⊆?A - {Ai}. card ?A - (?d::nat) - (1::nat) ≤ card S ∧ mutual_indep_events (?F Ai) ?F S; ⋀G::nat pair_pre_digraph. ⟦dependency_digraph G (M::'a measure) ?F; pverts G = ?A; ⋀Ai::nat. Ai ∈ ?A ⟹ out_degree (with_proj G) Ai ≤ ?d⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) by metis
then show "?thesis"
(*goal: ‹0 < prob (⋂Ai∈A. space M - F Ai)›*)
using odg (*‹dependency_digraph G M F› ‹pverts (G::nat pair_pre_digraph) = (A::nat set)› ‹?Ai12 ∈ A ⟹ out_degree (with_proj G) ?Ai12 ≤ d›*) assms (*‹A ≠ {}› ‹F ` A ⊆ events› ‹finite A› ‹?Ai12 ∈ A ⟹ ∃S⊆A - {?Ai12}. card A - d - 1 ≤ card S ∧ mutual_indep_events (F ?Ai12) F S› ‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ p› ‹exp 1 * p * real (d + 1) ≤ 1›*) lovasz_local_symmetric_dep_graph[of A F G d p] (*‹⟦A ≠ {}; F ` A ⊆ events; finite A; dependency_digraph G M F; ⋀Ai. Ai ∈ A ⟹ out_degree (with_proj G) Ai ≤ d; ⋀Ai. Ai ∈ A ⟹ prob (F Ai) ≤ p; exp 1 * p * real (d + 1) ≤ 1; pverts G = A⟧ ⟹ 0 < prob (⋂Ai∈A. space M - F Ai)›*) by auto
qed
lemma lovasz_local_symmetric4_set:
fixes d :: nat
assumes "A ≠ {}"
assumes "F ` A ⊆ events"
assumes "finite A"
assumes "⋀ Ai. Ai ∈ A ⟹ (∃ S . S ⊆ A - {Ai} ∧ card S ≥ card A - d - 1 ∧ mutual_indep_events (F Ai) F S)"
assumes "⋀ Ai. Ai ∈ A ⟹ prob (F Ai) ≤ p"
assumes "4 * p * d ≤ 1"
assumes "d ≥ 1"
shows "prob (⋂ Ai ∈ A . (space M - F Ai)) > 0"
proof (-)
(*goal: ‹0 < prob (⋂Ai∈A. space M - F Ai)›*)
obtain G where odg: "dependency_digraph G M F" "pverts G = A" "⋀ Ai. Ai ∈ A ⟹ out_degree G Ai ≤ d"
(*goal: ‹(⋀G. ⟦dependency_digraph G M F; pverts G = A; ⋀Ai. Ai ∈ A ⟹ out_degree (with_proj G) Ai ≤ d⟧ ⟹ thesis) ⟹ thesis›*)
using assms (*‹(A::nat set) ≠ {}› ‹F ` A ⊆ events› ‹finite A› ‹?Ai12 ∈ A ⟹ ∃S⊆A - {?Ai12}. card A - d - 1 ≤ card S ∧ mutual_indep_events (F ?Ai12) F S› ‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ p› ‹4 * p * real d ≤ 1› ‹1 ≤ d›*) obtain_dependency_graph (*‹⟦?A ≠ {}; ?F ` ?A ⊆ events; finite ?A; ⋀Ai. Ai ∈ ?A ⟹ ∃S⊆?A - {Ai}. card ?A - ?d - 1 ≤ card S ∧ mutual_indep_events (?F Ai) ?F S; ⋀G. ⟦dependency_digraph G M ?F; pverts G = ?A; ⋀Ai. Ai ∈ ?A ⟹ out_degree (with_proj G) Ai ≤ ?d⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by metis
then show "?thesis"
(*goal: ‹0 < prob (⋂Ai∈A. space M - F Ai)›*)
using odg (*‹dependency_digraph G M F› ‹pverts G = A› ‹?Ai12 ∈ A ⟹ out_degree (with_proj G) ?Ai12 ≤ d›*) assms (*‹(A::nat set) ≠ {}› ‹F ` A ⊆ events› ‹finite A› ‹?Ai12 ∈ A ⟹ ∃S⊆A - {?Ai12}. card A - d - 1 ≤ card S ∧ mutual_indep_events (F ?Ai12) F S› ‹?Ai12 ∈ A ⟹ prob (F ?Ai12) ≤ p› ‹4 * p * real d ≤ 1› ‹1 ≤ d›*) lovasz_local_symmetric4[of A F G d p] (*‹⟦A ≠ {}; F ` A ⊆ events; finite A; dependency_digraph G M F; ⋀Ai. Ai ∈ A ⟹ out_degree (with_proj G) Ai ≤ d; ⋀Ai. Ai ∈ A ⟹ prob (F Ai) ≤ p; 4 * p * real d ≤ 1; 1 ≤ d; pverts G = A⟧ ⟹ 0 < prob (⋂Ai∈A. space M - F Ai)›*) by auto
qed
end
end | {
"path": "afp-2025-02-12/thys/Lovasz_Local/Lovasz_Local_Lemma.thy",
"repo": "afp-2025-02-12",
"sha": "7e8016e0212971e7c700260bf5f256d87498832679c0b1030ba1f2ebb5463df6"
} |
(*
Title: HOL/Analysis/FPS_Convergence.thy
Author: Manuel Eberl, TU München
Connection of formal power series and actual convergent power series on Banach spaces
(most notably the complex numbers).
*)
section ‹Convergence of Formal Power Series›
theory FPS_Convergence
imports
Generalised_Binomial_Theorem
"HOL-Computational_Algebra.Formal_Power_Series"
begin
text ‹
In this theory, we will connect formal power series (which are algebraic objects) with analytic
functions. This will become more important in complex analysis, and indeed some of the less
trivial results will only be proven there.
›
subsection✐‹tag unimportant› ‹Balls with extended real radius›
(* TODO: This should probably go somewhere else *)
text ‹
The following is a variant of \<^const>‹ball› that also allows an infinite radius.
›
definition eball :: "'a :: metric_space ⇒ ereal ⇒ 'a set" where
"eball z r = {z'. ereal (dist z z') < r}"
lemma in_eball_iff [simp]: "z ∈ eball z0 r ⟷ ereal (dist z0 z) < r"
by (simp add: eball_def (*‹eball ?z ?r = {z'. ereal (dist ?z z') < ?r}›*))
lemma eball_ereal [simp]: "eball z (ereal r) = ball z r"
by auto
lemma eball_inf [simp]: "eball z ∞ = UNIV"
by auto
lemma eball_empty [simp]: "r ≤ 0 ⟹ eball z r = {}"
proof (safe)
(*goal: ‹⋀x. ⟦r ≤ 0; x ∈ eball z r⟧ ⟹ x ∈ {}›*)
fix x
assume "r ≤ 0" "x ∈ eball z r" (*‹(r::ereal) ≤ (0::ereal)› ‹(x::'a) ∈ eball (z::'a) (r::ereal)›*)
hence "dist z x < r"
by simp
also (*calculation: ‹ereal (dist z x) < r›*) have "… ≤ ereal 0"
using ‹r ≤ 0› (*‹r ≤ 0›*) by (simp add: zero_ereal_def (*‹0 = ereal 0›*))
finally (*calculation: ‹ereal (dist (z::'a) (x::'a)) < ereal (0::real)›*) show "x ∈ {}"
by simp
qed
lemma eball_conv_UNION_balls:
"eball z r = (⋃r'∈{r'. ereal r' < r}. ball z r')"
apply (cases r)
(*goals:
1. ‹⋀ra. r = ereal ra ⟹ eball z r = ⋃ (ball z ` {r'. ereal r' < r})›
2. ‹r = ∞ ⟹ eball z r = ⋃ (ball z ` {r'. ereal r' < r})›
3. ‹r = - ∞ ⟹ eball z r = ⋃ (ball z ` {r'. ereal r' < r})›
discuss goal 1*)
apply (use dense gt_ex in force)
(*discuss goal 2*)
apply (use dense gt_ex in force)
(*discuss goal 3*)
apply (use dense gt_ex in force)
(*proven 3 subgoals*) .
lemma eball_mono: "r ≤ r' ⟹ eball z r ≤ eball z r'"
by auto
lemma ball_eball_mono: "ereal r ≤ r' ⟹ ball z r ≤ eball z r'"
using eball_mono[of "ereal r" r'] (*‹ereal r ≤ r' ⟹ eball ?z (ereal r) ⊆ eball ?z r'›*) by simp
lemma open_eball [simp, intro]: "open (eball z r)"
apply (cases r)
(*goals:
1. ‹⋀ra. r = ereal ra ⟹ open (eball z r)›
2. ‹r = ∞ ⟹ open (eball z r)›
3. ‹r = - ∞ ⟹ open (eball z r)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
subsection ‹Basic properties of convergent power series›
definition✐‹tag important› fps_conv_radius :: "'a :: {banach, real_normed_div_algebra} fps ⇒ ereal" where
"fps_conv_radius f = conv_radius (fps_nth f)"
definition✐‹tag important› eval_fps :: "'a :: {banach, real_normed_div_algebra} fps ⇒ 'a ⇒ 'a" where
"eval_fps f z = (∑n. fps_nth f n * z ^ n)"
lemma norm_summable_fps:
fixes f :: "'a :: {banach, real_normed_div_algebra} fps"
shows "norm z < fps_conv_radius f ⟹ summable (λn. norm (fps_nth f n * z ^ n))"
apply (rule abs_summable_in_conv_radius (*‹ereal (norm ?z) < conv_radius ?f ⟹ summable (λn. norm (?f n * ?z ^ n))›*))
(*goal: ‹ereal (norm z) < fps_conv_radius f ⟹ summable (λn. norm (fps_nth f n * z ^ n))›*)
by (simp add: fps_conv_radius_def (*‹fps_conv_radius ?f = conv_radius (fps_nth ?f)›*))
lemma summable_fps:
fixes f :: "'a :: {banach, real_normed_div_algebra} fps"
shows "norm z < fps_conv_radius f ⟹ summable (λn. fps_nth f n * z ^ n)"
apply (rule summable_in_conv_radius (*‹ereal (norm ?z) < conv_radius ?f ⟹ summable (λn. ?f n * ?z ^ n)›*))
(*goal: ‹ereal (norm z) < fps_conv_radius f ⟹ summable (λn. fps_nth f n * z ^ n)›*)
by (simp add: fps_conv_radius_def (*‹fps_conv_radius ?f = conv_radius (fps_nth ?f)›*))
theorem sums_eval_fps:
fixes f :: "'a :: {banach, real_normed_div_algebra} fps"
assumes "norm z < fps_conv_radius f"
shows "(λn. fps_nth f n * z ^ n) sums eval_fps f z"
using assms (*‹ereal (norm z) < fps_conv_radius f›*) unfolding eval_fps_def fps_conv_radius_def
(*goal: ‹(λn. fps_nth f n * z ^ n) sums (∑n. fps_nth f n * z ^ n)›*)
apply (intro summable_sums (*‹summable ?f ⟹ ?f sums suminf ?f›*) summable_in_conv_radius (*‹ereal (norm ?z) < conv_radius ?f ⟹ summable (λn. ?f n * ?z ^ n)›*))
(*goal: ‹(λn. fps_nth f n * z ^ n) sums (∑n. fps_nth f n * z ^ n)›*)
by simp
lemma continuous_on_eval_fps:
fixes f :: "'a :: {banach, real_normed_div_algebra} fps"
shows "continuous_on (eball 0 (fps_conv_radius f)) (eval_fps f)"
apply (subst continuous_on_eq_continuous_at [OF open_eball] (*‹continuous_on (eball ?z1 ?r1) ?f = (∀x∈eball ?z1 ?r1. isCont ?f x)›*))
(*goal: ‹continuous_on (eball 0 (fps_conv_radius f)) (eval_fps f)›*)
proof (safe)
(*goal: ‹⋀x. x ∈ eball 0 (fps_conv_radius f) ⟹ isCont (eval_fps f) x›*)
fix x :: 'a
assume x: "x ∈ eball 0 (fps_conv_radius f)" (*‹(x::'a) ∈ eball (0::'a) (fps_conv_radius (f::'a fps))›*)
define r where "r = (if fps_conv_radius f = ∞ then norm x + 1 else
(norm x + real_of_ereal (fps_conv_radius f)) / 2)"
have r: "norm x < r ∧ ereal r < fps_conv_radius f"
using x (*‹x ∈ eball 0 (fps_conv_radius f)›*) apply (cases "fps_conv_radius f")
(*goals:
1. ‹⋀ra. ⟦x ∈ eball 0 (fps_conv_radius f); fps_conv_radius f = ereal ra⟧ ⟹ norm x < r ∧ ereal r < fps_conv_radius f›
2. ‹⟦x ∈ eball 0 (fps_conv_radius f); fps_conv_radius f = ∞⟧ ⟹ norm x < r ∧ ereal r < fps_conv_radius f›
3. ‹⟦x ∈ eball 0 (fps_conv_radius f); fps_conv_radius f = - ∞⟧ ⟹ norm x < r ∧ ereal r < fps_conv_radius f›
discuss goal 1*)
apply ((auto simp: r_def (*‹r = (if fps_conv_radius f = ∞ then norm x + 1 else (norm x + real_of_ereal (fps_conv_radius f)) / 2)›*) eball_def (*‹eball ?z ?r = {z'. ereal (dist ?z z') < ?r}›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*discuss goal 2*)
apply ((auto simp: r_def (*‹r = (if fps_conv_radius f = ∞ then norm x + 1 else (norm x + real_of_ereal (fps_conv_radius f)) / 2)›*) eball_def (*‹eball ?z ?r = {z'. ereal (dist ?z z') < ?r}›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*discuss goal 3*)
apply ((auto simp: r_def (*‹r = (if fps_conv_radius f = ∞ then norm x + 1 else (norm x + real_of_ereal (fps_conv_radius f)) / 2)›*) eball_def (*‹eball ?z ?r = {z'. ereal (dist ?z z') < ?r}›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*proven 3 subgoals*) .
have "continuous_on (cball 0 r) (λx. ∑i. fps_nth f i * (x - 0) ^ i)"
apply (rule powser_continuous_suminf (*‹ereal ?r < conv_radius ?a ⟹ continuous_on (cball ?ξ ?r) (λx. ∑i. ?a i * (x - ?ξ) ^ i)›*))
(*goal: ‹continuous_on (cball (0::'a) (r::real)) (λx::'a. ∑i::nat. fps_nth (f::'a fps) i * (x - (0::'a)) ^ i)›*)
apply (insert r (*‹norm x < r ∧ ereal r < fps_conv_radius f›*))
(*goal: ‹ereal r < conv_radius (fps_nth f)›*)
by (auto simp: fps_conv_radius_def (*‹fps_conv_radius ?f = conv_radius (fps_nth ?f)›*))
hence "continuous_on (cball 0 r) (eval_fps f)"
by (simp add: eval_fps_def (*‹eval_fps ?f ?z = (∑n. fps_nth ?f n * ?z ^ n)›*))
thus "isCont (eval_fps f) x"
apply (rule continuous_on_interior (*‹⟦continuous_on ?S ?f; ?x ∈ interior ?S⟧ ⟹ isCont ?f ?x›*))
(*goal: ‹isCont (eval_fps f) x›*)
by (use r in auto)
qed
lemma continuous_on_eval_fps' [continuous_intros]:
assumes "continuous_on A g"
assumes "g ` A ⊆ eball 0 (fps_conv_radius f)"
shows "continuous_on A (λx. eval_fps f (g x))"
using continuous_on_compose2[OF continuous_on_eval_fps assms] (*‹continuous_on A (λx. eval_fps f (g x))›*) .
lemma has_field_derivative_powser:
fixes z :: "'a :: {banach, real_normed_field}"
assumes "ereal (norm z) < conv_radius f"
shows "((λz. ∑n. f n * z ^ n) has_field_derivative (∑n. diffs f n * z ^ n)) (at z within A)"
proof (-)
(*goal: ‹((λz. ∑n. f n * z ^ n) has_field_derivative (∑n. diffs f n * z ^ n)) (at z within A)›*)
define K where "K = (if conv_radius f = ∞ then norm z + 1
else (norm z + real_of_ereal (conv_radius f)) / 2)"
have K: "norm z < K ∧ ereal K < conv_radius f"
using assms (*‹ereal (norm z) < conv_radius f›*) apply (cases "conv_radius f")
(*goals:
1. ‹⋀r::real. ⟦ereal (norm (z::'a::{banach,real_normed_field})) < conv_radius (f::nat ⇒ 'a::{banach,real_normed_field}); conv_radius f = ereal r⟧ ⟹ norm z < (K::real) ∧ ereal K < conv_radius f›
2. ‹⟦ereal (norm (z::'a::{banach,real_normed_field})) < conv_radius (f::nat ⇒ 'a::{banach,real_normed_field}); conv_radius f = ∞⟧ ⟹ norm z < (K::real) ∧ ereal K < conv_radius f›
3. ‹⟦ereal (norm (z::'a::{banach,real_normed_field})) < conv_radius (f::nat ⇒ 'a::{banach,real_normed_field}); conv_radius f = - ∞⟧ ⟹ norm z < (K::real) ∧ ereal K < conv_radius f›
discuss goal 1*)
apply ((auto simp: K_def (*‹K = (if conv_radius f = ∞ then norm z + 1 else (norm z + real_of_ereal (conv_radius f)) / 2)›*))[1])
(*discuss goal 2*)
apply ((auto simp: K_def (*‹K = (if conv_radius f = ∞ then norm z + 1 else (norm z + real_of_ereal (conv_radius f)) / 2)›*))[1])
(*discuss goal 3*)
apply ((auto simp: K_def (*‹(K::real) = (if conv_radius (f::nat ⇒ 'a) = ∞ then norm (z::'a) + (1::real) else (norm z + real_of_ereal (conv_radius f)) / (2::real))›*))[1])
(*proven 3 subgoals*) .
have "0 ≤ norm z"
by simp
also (*calculation: ‹0 ≤ norm z›*) from K (*‹norm z < K ∧ ereal K < conv_radius f›*) have "… < K"
by simp
finally (*calculation: ‹0 < K›*) have K_pos: "K > 0"
by simp
have "summable (λn. f n * of_real K ^ n)"
using K (*‹norm z < K ∧ ereal K < conv_radius f›*) K_pos (*‹0 < K›*) apply (intro summable_in_conv_radius (*‹ereal (norm (?z::?'a)) < conv_radius (?f::nat ⇒ ?'a) ⟹ summable (λn::nat. ?f n * ?z ^ n)›*))
(*goal: ‹summable (λn::nat. (f::nat ⇒ 'a::{banach,real_normed_field}) n * of_real (K::real) ^ n)›*)
by auto
moreover from K (*‹norm z < K ∧ ereal K < conv_radius f›*) K_pos (*‹(0::real) < (K::real)›*) have "norm z < norm (of_real K :: 'a)"
by auto
ultimately show "?thesis"
(*goal: ‹((λz. ∑n. f n * z ^ n) has_field_derivative (∑n. diffs f n * z ^ n)) (at z within A)›*)
by (rule has_field_derivative_at_within [OF termdiffs_strong] (*‹⟦summable (λn. ?c1 n * ?K1 ^ n); norm ?x < norm ?K1⟧ ⟹ ((λx. ∑n. ?c1 n * x ^ n) has_field_derivative (∑n. diffs ?c1 n * ?x ^ n)) (at ?x within ?s)›*))
qed
lemma has_field_derivative_eval_fps:
fixes z :: "'a :: {banach, real_normed_field}"
assumes "norm z < fps_conv_radius f"
shows "(eval_fps f has_field_derivative eval_fps (fps_deriv f) z) (at z within A)"
proof (-)
(*goal: ‹(eval_fps f has_field_derivative eval_fps (fps_deriv f) z) (at z within A)›*)
have "(eval_fps f has_field_derivative eval_fps (Abs_fps (diffs (fps_nth f))) z) (at z within A)"
using assms (*‹ereal (norm (z::'a::{banach,real_normed_field})) < fps_conv_radius (f::'a::{banach,real_normed_field} fps)›*) unfolding eval_fps_def fps_nth_Abs_fps fps_conv_radius_def
(*goal: ‹((λz. ∑n. fps_nth f n * z ^ n) has_field_derivative (∑n. diffs (fps_nth f) n * z ^ n)) (at z within A)›*)
apply (intro has_field_derivative_powser (*‹ereal (norm (?z::?'a)) < conv_radius (?f::nat ⇒ ?'a) ⟹ ((λz::?'a. ∑n::nat. ?f n * z ^ n) has_field_derivative (∑n::nat. diffs ?f n * ?z ^ n)) (at ?z within (?A::?'a set))›*))
(*goal: ‹((λz. ∑n. fps_nth f n * z ^ n) has_field_derivative (∑n. diffs (fps_nth f) n * z ^ n)) (at z within A)›*)
by auto
also (*calculation: ‹(eval_fps f has_field_derivative eval_fps (Abs_fps (diffs (fps_nth f))) z) (at z within A)›*) have "Abs_fps (diffs (fps_nth f)) = fps_deriv f"
by (simp add: fps_eq_iff (*‹(?p = ?q) = (∀n. fps_nth ?p n = fps_nth ?q n)›*) diffs_def (*‹diffs ?c = (λn. of_nat (Suc n) * ?c (Suc n))›*))
finally (*calculation: ‹(eval_fps (f::'a fps) has_field_derivative eval_fps (fps_deriv f) (z::'a)) (at z within (A::'a set))›*) show "?thesis"
(*goal: ‹(eval_fps f has_field_derivative eval_fps (fps_deriv f) z) (at z within A)›*) .
qed
lemma holomorphic_on_eval_fps [holomorphic_intros]:
fixes z :: "'a :: {banach, real_normed_field}"
assumes "A ⊆ eball 0 (fps_conv_radius f)"
shows "eval_fps f holomorphic_on A"
proof (rule holomorphic_on_subset [OF _ assms] (*‹?f holomorphic_on eball 0 (fps_conv_radius f) ⟹ ?f holomorphic_on A›*))
(*goal: ‹eval_fps f holomorphic_on eball 0 (fps_conv_radius f)›*)
show "eval_fps f holomorphic_on eball 0 (fps_conv_radius f)"
apply (subst holomorphic_on_open [OF open_eball] (*‹(?f holomorphic_on eball ?z1 ?r1) = (∀x∈eball ?z1 ?r1. ∃f'. (?f has_field_derivative f') (at x))›*))
(*goal: ‹eval_fps f holomorphic_on eball 0 (fps_conv_radius f)›*)
apply safe
(*goal: ‹∀x::complex∈eball (0::complex) (fps_conv_radius (f::complex fps)). ∃f'::complex. (eval_fps f has_field_derivative f') (at x)›*)
proof (goal_cases)
(*goal: ‹⋀x. x ∈ eball 0 (fps_conv_radius f) ⟹ ∃f'. (eval_fps f has_field_derivative f') (at x)›*)
case (1 x) (*‹x ∈ eball 0 (fps_conv_radius f)›*)
thus "?case"
(*goal: ‹∃f'::complex. (eval_fps (f::complex fps) has_field_derivative f') (at (x::complex))›*)
apply (intro exI[of _ "eval_fps (fps_deriv f) x"] (*‹(?P::complex ⇒ bool) (eval_fps (fps_deriv (f::complex fps)) (x::complex)) ⟹ ∃x::complex. ?P x›*))
(*goal: ‹∃f'. (eval_fps f has_field_derivative f') (at x)›*)
by (auto intro: has_field_derivative_eval_fps (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ (eval_fps ?f has_field_derivative eval_fps (fps_deriv ?f) ?z) (at ?z within ?A)›*))
qed
qed
lemma analytic_on_eval_fps:
fixes z :: "'a :: {banach, real_normed_field}"
assumes "A ⊆ eball 0 (fps_conv_radius f)"
shows "eval_fps f analytic_on A"
proof (rule analytic_on_subset [OF _ assms] (*‹?f analytic_on eball 0 (fps_conv_radius f) ⟹ ?f analytic_on A›*))
(*goal: ‹eval_fps f analytic_on eball 0 (fps_conv_radius f)›*)
show "eval_fps f analytic_on eball 0 (fps_conv_radius f)"
using holomorphic_on_eval_fps[of "eball 0 (fps_conv_radius f)"] (*‹eball (0::complex) (fps_conv_radius (f::complex fps)) ⊆ eball (0::complex) (fps_conv_radius (?f::complex fps)) ⟹ eval_fps ?f holomorphic_on eball (0::complex) (fps_conv_radius f)›*) apply (subst analytic_on_open (*‹open ?S ⟹ (?f analytic_on ?S) = (?f holomorphic_on ?S)›*))
(*goals:
1. ‹(⋀fa. eball 0 (fps_conv_radius f) ⊆ eball 0 (fps_conv_radius fa) ⟹ eval_fps fa holomorphic_on eball 0 (fps_conv_radius f)) ⟹ open (eball 0 (fps_conv_radius f))›
2. ‹(⋀fa. eball 0 (fps_conv_radius f) ⊆ eball 0 (fps_conv_radius fa) ⟹ eval_fps fa holomorphic_on eball 0 (fps_conv_radius f)) ⟹ eval_fps f holomorphic_on eball 0 (fps_conv_radius f)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
qed
lemma continuous_eval_fps [continuous_intros]:
fixes z :: "'a::{real_normed_field,banach}"
assumes "norm z < fps_conv_radius F"
shows "continuous (at z within A) (eval_fps F)"
proof (-)
(*goal: ‹continuous (at (z::'a) within (A::'a set)) (eval_fps (F::'a fps))›*)
from ereal_dense2[OF assms] (*‹∃za. ereal (norm z) < ereal za ∧ ereal za < fps_conv_radius F›*) obtain K :: real where K: "norm z < K" "K < fps_conv_radius F"
(*goal: ‹(⋀K. ⟦norm z < K; ereal K < fps_conv_radius F⟧ ⟹ thesis) ⟹ thesis›*)
by auto
have "0 ≤ norm z"
by simp
also (*calculation: ‹0 ≤ norm z›*) have "norm z < K"
by fact
finally (*calculation: ‹(0::real) < (K::real)›*) have "K > 0" .
from K (*‹norm z < K› ‹ereal K < fps_conv_radius F›*) ‹K > 0› (*‹0 < K›*) have "summable (λn. fps_nth F n * of_real K ^ n)"
apply (intro summable_fps (*‹ereal (norm (?z::?'a)) < fps_conv_radius (?f::?'a fps) ⟹ summable (λn::nat. fps_nth ?f n * ?z ^ n)›*))
(*goal: ‹summable (λn. fps_nth F n * of_real K ^ n)›*)
by auto
from this (*‹summable (λn. fps_nth F n * of_real K ^ n)›*) have "isCont (eval_fps F) z"
unfolding eval_fps_def
(*goal: ‹isCont (λz::'a. ∑n::nat. fps_nth (F::'a fps) n * z ^ n) (z::'a)›*)
apply (rule isCont_powser (*‹⟦summable (λn. ?c n * ?K ^ n); norm ?x < norm ?K⟧ ⟹ isCont (λx. ∑n. ?c n * x ^ n) ?x›*))
(*goal: ‹isCont (λz. ∑n. fps_nth F n * z ^ n) z›*)
by (use K in auto)
thus "continuous (at z within A) (eval_fps F)"
by (simp add: continuous_at_imp_continuous_within (*‹isCont ?f ?x ⟹ continuous (at ?x within ?s) ?f›*))
qed
subsection✐‹tag unimportant› ‹Lower bounds on radius of convergence›
lemma fps_conv_radius_deriv:
fixes f :: "'a :: {banach, real_normed_field} fps"
shows "fps_conv_radius (fps_deriv f) ≥ fps_conv_radius f"
unfolding fps_conv_radius_def
(*goal: ‹conv_radius (fps_nth f) ≤ conv_radius (fps_nth (fps_deriv f))›*)
proof (rule conv_radius_geI_ex (*‹(⋀r::real. ⟦(0::real) < r; ereal r < (?R::ereal)⟧ ⟹ ∃z::?'a. norm z = r ∧ summable (λn::nat. (?f::nat ⇒ ?'a) n * z ^ n)) ⟹ ?R ≤ conv_radius ?f›*))
(*goal: ‹⋀r. ⟦0 < r; ereal r < conv_radius (fps_nth f)⟧ ⟹ ∃z. norm z = r ∧ summable (λn. fps_nth (fps_deriv f) n * z ^ n)›*)
fix r :: real
assume r: "r > 0" "ereal r < conv_radius (fps_nth f)" (*‹(0::real) < (r::real)› ‹ereal (r::real) < conv_radius (fps_nth (f::'a fps))›*)
define K where "K = (if conv_radius (fps_nth f) = ∞ then r + 1
else (real_of_ereal (conv_radius (fps_nth f)) + r) / 2)"
have K: "r < K ∧ ereal K < conv_radius (fps_nth f)"
using r (*‹0 < r› ‹ereal r < conv_radius (fps_nth f)›*) apply (cases "conv_radius (fps_nth f)")
(*goals:
1. ‹⋀ra. ⟦0 < r; ereal r < conv_radius (fps_nth f); conv_radius (fps_nth f) = ereal ra⟧ ⟹ r < K ∧ ereal K < conv_radius (fps_nth f)›
2. ‹⟦0 < r; ereal r < conv_radius (fps_nth f); conv_radius (fps_nth f) = ∞⟧ ⟹ r < K ∧ ereal K < conv_radius (fps_nth f)›
3. ‹⟦0 < r; ereal r < conv_radius (fps_nth f); conv_radius (fps_nth f) = - ∞⟧ ⟹ r < K ∧ ereal K < conv_radius (fps_nth f)›
discuss goal 1*)
apply ((auto simp: K_def (*‹K = (if conv_radius (fps_nth f) = ∞ then r + 1 else (real_of_ereal (conv_radius (fps_nth f)) + r) / 2)›*))[1])
(*discuss goal 2*)
apply ((auto simp: K_def (*‹K = (if conv_radius (fps_nth f) = ∞ then r + 1 else (real_of_ereal (conv_radius (fps_nth f)) + r) / 2)›*))[1])
(*discuss goal 3*)
apply ((auto simp: K_def (*‹(K::real) = (if conv_radius (fps_nth (f::'a fps)) = ∞ then (r::real) + (1::real) else (real_of_ereal (conv_radius (fps_nth f)) + r) / (2::real))›*))[1])
(*proven 3 subgoals*) .
have "summable (λn. diffs (fps_nth f) n * of_real r ^ n)"
proof (rule termdiff_converges (*‹⟦norm ?x < ?K; ⋀x. norm x < ?K ⟹ summable (λn. ?c n * x ^ n)⟧ ⟹ summable (λn. diffs ?c n * ?x ^ n)›*))
(*goals:
1. ‹norm (of_real r) < ?K›
2. ‹⋀x. norm x < ?K ⟹ summable (λn. fps_nth f n * x ^ n)›*)
fix x :: 'a
assume "norm x < K" (*‹norm (x::'a) < (K::real)›*)
hence "ereal (norm x) < ereal K"
by simp
also (*calculation: ‹ereal (norm x) < ereal K›*) have "… < conv_radius (fps_nth f)"
using K (*‹r < K ∧ ereal K < conv_radius (fps_nth f)›*) by simp
finally (*calculation: ‹ereal (norm x) < conv_radius (fps_nth f)›*) show "summable (λn. fps_nth f n * x ^ n)"
apply (intro summable_in_conv_radius (*‹ereal (norm (?z::?'a::{banach,real_normed_div_algebra})) < conv_radius (?f::nat ⇒ ?'a::{banach,real_normed_div_algebra}) ⟹ summable (λn::nat. ?f n * ?z ^ n)›*))
(*goal: ‹summable (λn. fps_nth f n * x ^ n)›*)
by auto
qed (insert K (*‹r < K ∧ ereal K < conv_radius (fps_nth f)›*) r (*‹0 < r› ‹ereal r < conv_radius (fps_nth f)›*), auto)
(*solved the remaining goal: ‹norm (of_real r) < K›*)
also (*calculation: ‹summable (λn. diffs (fps_nth f) n * of_real r ^ n)›*) have "… = (λn. fps_nth (fps_deriv f) n * of_real r ^ n)"
by (simp add: fps_deriv_def (*‹fps_deriv ?f = Abs_fps (λn. of_nat (n + 1) * fps_nth ?f (n + 1))›*) diffs_def (*‹diffs ?c = (λn. of_nat (Suc n) * ?c (Suc n))›*))
finally (*calculation: ‹summable (λn. fps_nth (fps_deriv f) n * of_real r ^ n)›*) show "∃z::'a. norm z = r ∧ summable (λn. fps_nth (fps_deriv f) n * z ^ n)"
using r (*‹0 < r› ‹ereal (r::real) < conv_radius (fps_nth (f::'a::{banach,real_normed_field} fps))›*) apply (intro exI[of _ "of_real r"] (*‹?P (of_real r) ⟹ ∃x. ?P x›*))
(*goal: ‹∃z. norm z = r ∧ summable (λn. fps_nth (fps_deriv f) n * z ^ n)›*)
by auto
qed
lemma eval_fps_at_0: "eval_fps f 0 = fps_nth f 0"
by (simp add: eval_fps_def (*‹eval_fps ?f ?z = (∑n. fps_nth ?f n * ?z ^ n)›*))
lemma fps_conv_radius_norm [simp]:
"fps_conv_radius (Abs_fps (λn. norm (fps_nth f n))) = fps_conv_radius f"
by (simp add: fps_conv_radius_def (*‹fps_conv_radius ?f = conv_radius (fps_nth ?f)›*))
lemma fps_conv_radius_const [simp]: "fps_conv_radius (fps_const c) = ∞"
proof (-)
(*goal: ‹fps_conv_radius (fps_const c) = ∞›*)
have "fps_conv_radius (fps_const c) = conv_radius (λ_. 0 :: 'a)"
unfolding fps_conv_radius_def
(*goal: ‹conv_radius (fps_nth (fps_const c)) = conv_radius (λ_. 0)›*)
apply (intro conv_radius_cong (*‹∀⇩F x in sequentially. norm (?f x) = norm (?g x) ⟹ conv_radius ?f = conv_radius ?g›*) eventually_mono[OF eventually_gt_at_top[of 0]] (*‹(⋀x. 0 < x ⟹ ?Q x) ⟹ eventually ?Q at_top›*))
(*goal: ‹conv_radius (fps_nth (fps_const c)) = conv_radius (λ_. 0)›*)
by auto
thus "?thesis"
(*goal: ‹fps_conv_radius (fps_const c) = ∞›*)
by simp
qed
lemma fps_conv_radius_0 [simp]: "fps_conv_radius 0 = ∞"
by (simp only: fps_const_0_eq_0 [symmetric] (*‹0 = fps_const 0›*) fps_conv_radius_const (*‹fps_conv_radius (fps_const ?c) = ∞›*))
lemma fps_conv_radius_1 [simp]: "fps_conv_radius 1 = ∞"
by (simp only: fps_const_1_eq_1 [symmetric] (*‹1 = fps_const 1›*) fps_conv_radius_const (*‹fps_conv_radius (fps_const ?c) = ∞›*))
lemma fps_conv_radius_numeral [simp]: "fps_conv_radius (numeral n) = ∞"
by (simp add: numeral_fps_const (*‹numeral ?k = fps_const (numeral ?k)›*))
lemma fps_conv_radius_fps_X_power [simp]: "fps_conv_radius (fps_X ^ n) = ∞"
proof (-)
(*goal: ‹fps_conv_radius (fps_X ^ n) = ∞›*)
have "fps_conv_radius (fps_X ^ n :: 'a fps) = conv_radius (λ_. 0 :: 'a)"
unfolding fps_conv_radius_def
(*goal: ‹conv_radius (fps_nth (fps_X ^ n)) = conv_radius (λ_. 0)›*)
apply (intro conv_radius_cong (*‹∀⇩F x in sequentially. norm (?f x) = norm (?g x) ⟹ conv_radius ?f = conv_radius ?g›*) eventually_mono[OF eventually_gt_at_top[of n]] (*‹(⋀x. n < x ⟹ ?Q x) ⟹ eventually ?Q sequentially›*))
(*goal: ‹conv_radius (fps_nth (fps_X ^ n)) = conv_radius (λ_. 0)›*)
by (auto simp: fps_X_power_iff (*‹fps_X ^ ?n = Abs_fps (λm. if m = ?n then 1 else 0)›*))
thus "?thesis"
(*goal: ‹fps_conv_radius (fps_X ^ n) = ∞›*)
by simp
qed
lemma fps_conv_radius_fps_X [simp]: "fps_conv_radius fps_X = ∞"
using fps_conv_radius_fps_X_power[of 1] (*‹fps_conv_radius (fps_X ^ 1) = ∞›*) by (simp only: power_one_right (*‹?a ^ 1 = ?a›*))
lemma fps_conv_radius_shift [simp]:
"fps_conv_radius (fps_shift n f) = fps_conv_radius f"
by (simp add: fps_conv_radius_def (*‹fps_conv_radius ?f = conv_radius (fps_nth ?f)›*) fps_shift_def (*‹fps_shift ?n ?f = Abs_fps (λi. fps_nth ?f (i + ?n))›*) conv_radius_shift (*‹conv_radius (λn. ?f (n + ?m)) = conv_radius ?f›*))
lemma fps_conv_radius_cmult_left:
"c ≠ 0 ⟹ fps_conv_radius (fps_const c * f) = fps_conv_radius f"
unfolding fps_conv_radius_def
(*goal: ‹c ≠ 0 ⟹ conv_radius (fps_nth (fps_const c * f)) = conv_radius (fps_nth f)›*)
by (simp add: conv_radius_cmult_left (*‹(?c::?'a::{banach,real_normed_div_algebra}) ≠ (0::?'a::{banach,real_normed_div_algebra}) ⟹ conv_radius (λn::nat. ?c * (?f::nat ⇒ ?'a::{banach,real_normed_div_algebra}) n) = conv_radius ?f›*))
lemma fps_conv_radius_cmult_right:
"c ≠ 0 ⟹ fps_conv_radius (f * fps_const c) = fps_conv_radius f"
unfolding fps_conv_radius_def
(*goal: ‹c ≠ 0 ⟹ conv_radius (fps_nth (f * fps_const c)) = conv_radius (fps_nth f)›*)
by (simp add: conv_radius_cmult_right (*‹?c ≠ 0 ⟹ conv_radius (λn. ?f n * ?c) = conv_radius ?f›*))
lemma fps_conv_radius_uminus [simp]:
"fps_conv_radius (-f) = fps_conv_radius f"
using fps_conv_radius_cmult_left[of "-1" f] (*‹- (1::'a::{banach,real_normed_div_algebra}) ≠ (0::'a::{banach,real_normed_div_algebra}) ⟹ fps_conv_radius (fps_const (- (1::'a::{banach,real_normed_div_algebra})) * (f::'a::{banach,real_normed_div_algebra} fps)) = fps_conv_radius f›*) by (simp flip: fps_const_neg (*‹- fps_const ?c = fps_const (- ?c)›*))
lemma fps_conv_radius_add: "fps_conv_radius (f + g) ≥ min (fps_conv_radius f) (fps_conv_radius g)"
unfolding fps_conv_radius_def
(*goal: ‹min (conv_radius (fps_nth f)) (conv_radius (fps_nth g)) ≤ conv_radius (fps_nth (f + g))›*)
using conv_radius_add_ge[of "fps_nth f" "fps_nth g"] (*‹min (conv_radius (fps_nth (f::'a::{banach,real_normed_div_algebra} fps))) (conv_radius (fps_nth (g::'a::{banach,real_normed_div_algebra} fps))) ≤ conv_radius (λx::nat. fps_nth f x + fps_nth g x)›*) by simp
lemma fps_conv_radius_diff: "fps_conv_radius (f - g) ≥ min (fps_conv_radius f) (fps_conv_radius g)"
using fps_conv_radius_add[of f "-g"] (*‹min (fps_conv_radius (f::'a fps)) (fps_conv_radius (- (g::'a fps))) ≤ fps_conv_radius (f + - g)›*) by simp
lemma fps_conv_radius_mult: "fps_conv_radius (f * g) ≥ min (fps_conv_radius f) (fps_conv_radius g)"
using conv_radius_mult_ge[of "fps_nth f" "fps_nth g"] (*‹min (conv_radius (fps_nth f)) (conv_radius (fps_nth g)) ≤ conv_radius (λx. ∑i≤x. fps_nth f i * fps_nth g (x - i))›*) by (simp add: fps_mult_nth (*‹fps_nth (?f * ?g) ?n = (∑i = 0..?n. fps_nth ?f i * fps_nth ?g (?n - i))›*) fps_conv_radius_def (*‹fps_conv_radius ?f = conv_radius (fps_nth ?f)›*) atLeast0AtMost (*‹{0..?n} = {..?n}›*))
lemma fps_conv_radius_power: "fps_conv_radius (f ^ n) ≥ fps_conv_radius f"
proof (induction n)
(*goals:
1. ‹fps_conv_radius f ≤ fps_conv_radius (f ^ 0)›
2. ‹⋀n. fps_conv_radius f ≤ fps_conv_radius (f ^ n) ⟹ fps_conv_radius f ≤ fps_conv_radius (f ^ Suc n)›*)
case (Suc n) (*‹fps_conv_radius (f::'a fps) ≤ fps_conv_radius (f ^ (n::nat))›*)
hence "fps_conv_radius f ≤ min (fps_conv_radius f) (fps_conv_radius (f ^ n))"
by simp
also (*calculation: ‹fps_conv_radius f ≤ min (fps_conv_radius f) (fps_conv_radius (f ^ n))›*) have "… ≤ fps_conv_radius (f * f ^ n)"
by (rule fps_conv_radius_mult (*‹min (fps_conv_radius ?f) (fps_conv_radius ?g) ≤ fps_conv_radius (?f * ?g)›*))
finally (*calculation: ‹fps_conv_radius f ≤ fps_conv_radius (f * f ^ n)›*) show "?case"
(*goal: ‹fps_conv_radius f ≤ fps_conv_radius (f ^ Suc n)›*)
by simp
qed (simp_all)
(*solved the remaining goal: ‹fps_conv_radius f ≤ fps_conv_radius (f ^ 0)›*)
context
begin
lemma natfun_inverse_bound:
fixes f :: "'a :: {real_normed_field} fps"
assumes "fps_nth f 0 = 1" and "δ > 0"
and summable: "summable (λn. norm (fps_nth f (Suc n)) * δ ^ Suc n)"
and le: "(∑n. norm (fps_nth f (Suc n)) * δ ^ Suc n) ≤ 1"
shows "norm (natfun_inverse f n) ≤ inverse (δ ^ n)"
proof (induction n rule: less_induct (*‹(⋀x. (⋀y. y < x ⟹ ?P y) ⟹ ?P x) ⟹ ?P ?a›*))
(*goal: ‹⋀x::nat. (⋀y::nat. y < x ⟹ norm (natfun_inverse (f::'a fps) y) ≤ inverse ((δ::real) ^ y)) ⟹ norm (natfun_inverse f x) ≤ inverse (δ ^ x)›*)
case (less m) (*‹?y < m ⟹ norm (natfun_inverse f ?y) ≤ inverse (δ ^ ?y)›*)
show "?case"
(*goal: ‹norm (natfun_inverse f m) ≤ inverse (δ ^ m)›*)
proof (cases m)
(*goals:
1. ‹m = 0 ⟹ norm (natfun_inverse f m) ≤ inverse (δ ^ m)›
2. ‹⋀nat. m = Suc nat ⟹ norm (natfun_inverse f m) ≤ inverse (δ ^ m)›*)
case 0 (*‹m = 0›*)
thus "?thesis"
(*goal: ‹norm (natfun_inverse f m) ≤ inverse (δ ^ m)›*)
using assms (*‹fps_nth f 0 = 1› ‹0 < δ› ‹summable (λn. norm (fps_nth f (Suc n)) * δ ^ Suc n)› ‹(∑n. norm (fps_nth f (Suc n)) * δ ^ Suc n) ≤ 1›*) by (simp add: field_split_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 65 facts*) norm_inverse (*‹norm (inverse (?a::?'a)) = inverse (norm ?a)›*) norm_divide (*‹norm ((?a::?'a) / (?b::?'a)) = norm ?a / norm ?b›*))
next
(*goal: ‹⋀nat::nat. (m::nat) = Suc nat ⟹ norm (natfun_inverse (f::'a::real_normed_field fps) m) ≤ inverse ((δ::real) ^ m)›*)
case [simp]: (Suc n) (*‹m = Suc n›*)
have "norm (natfun_inverse f (Suc n)) =
norm (∑i = Suc 0..Suc n. fps_nth f i * natfun_inverse f (Suc n - i))" (is "_ = norm ?S")
using assms (*‹fps_nth f 0 = 1› ‹0 < δ› ‹summable (λn. norm (fps_nth f (Suc n)) * δ ^ Suc n)› ‹(∑n. norm (fps_nth f (Suc n)) * δ ^ Suc n) ≤ 1›*) by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) norm_mult (*‹norm (?x * ?y) = norm ?x * norm ?y›*) norm_divide (*‹norm (?a / ?b) = norm ?a / norm ?b›*) del: sum.cl_ivl_Suc (*‹sum ?g {?m..Suc ?n} = (if Suc ?n < ?m then 0 else sum ?g {?m..?n} + ?g (Suc ?n))›*))
also (*calculation: ‹norm (natfun_inverse f (Suc n)) = norm (∑i = Suc 0..Suc n. fps_nth f i * natfun_inverse f (Suc n - i))›*) have "norm ?S ≤ (∑i = Suc 0..Suc n. norm (fps_nth f i * natfun_inverse f (Suc n - i)))"
by (rule norm_sum (*‹norm (sum ?f ?A) ≤ (∑i∈?A. norm (?f i))›*))
also (*calculation: ‹norm (natfun_inverse f (Suc n)) ≤ (∑i = Suc 0..Suc n. norm (fps_nth f i * natfun_inverse f (Suc n - i)))›*) have "… ≤ (∑i = Suc 0..Suc n. norm (fps_nth f i) / δ ^ (Suc n - i))"
apply (intro sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*))
(*goal: ‹(∑i = Suc 0..Suc n. norm (fps_nth f i * natfun_inverse f (Suc n - i))) ≤ (∑i = Suc 0..Suc n. norm (fps_nth f i) / δ ^ (Suc n - i))›*)
proof (goal_cases)
(*goal: ‹⋀i. i ∈ {Suc 0..Suc n} ⟹ norm (fps_nth f i * natfun_inverse f (Suc n - i)) ≤ norm (fps_nth f i) / δ ^ (Suc n - i)›*)
case (1 i) (*‹i ∈ {Suc 0..Suc n}›*)
have "norm (fps_nth f i * natfun_inverse f (Suc n - i)) =
norm (fps_nth f i) * norm (natfun_inverse f (Suc n - i))"
by (simp add: norm_mult (*‹norm ((?x::?'a) * (?y::?'a)) = norm ?x * norm ?y›*))
also (*calculation: ‹norm (fps_nth f i * natfun_inverse f (Suc n - i)) = norm (fps_nth f i) * norm (natfun_inverse f (Suc n - i))›*) have "… ≤ norm (fps_nth f i) * inverse (δ ^ (Suc n - i))"
using "1" (*‹(i::nat) ∈ {Suc (0::nat)..Suc (n::nat)}›*) apply (intro mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) less.IH (*‹?y < m ⟹ norm (natfun_inverse f ?y) ≤ inverse (δ ^ ?y)›*))
(*goals:
1. ‹(i::nat) ∈ {Suc (0::nat)..Suc (n::nat)} ⟹ Suc n - i < (m::nat)›
2. ‹(i::nat) ∈ {Suc (0::nat)..Suc (n::nat)} ⟹ (0::real) ≤ norm (fps_nth (f::'a::real_normed_field fps) i)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
also (*calculation: ‹norm (fps_nth f i * natfun_inverse f (Suc n - i)) ≤ norm (fps_nth f i) * inverse (δ ^ (Suc n - i))›*) have "… = norm (fps_nth f i) / δ ^ (Suc n - i)"
by (simp add: field_split_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 65 facts*))
finally (*calculation: ‹norm (fps_nth f i * natfun_inverse f (Suc n - i)) ≤ norm (fps_nth f i) / δ ^ (Suc n - i)›*) show "?case"
(*goal: ‹norm (fps_nth f i * natfun_inverse f (Suc n - i)) ≤ norm (fps_nth f i) / δ ^ (Suc n - i)›*) .
qed
also (*calculation: ‹norm (natfun_inverse (f::'a fps) (Suc (n::nat))) ≤ (∑i::nat = Suc (0::nat)..Suc n. norm (fps_nth f i) / (δ::real) ^ (Suc n - i))›*) have "… = (∑i = Suc 0..Suc n. norm (fps_nth f i) * δ ^ i) / δ ^ Suc n"
apply (subst sum_divide_distrib (*‹sum ?f ?A / ?r = (∑n∈?A. ?f n / ?r)›*))
(*goal: ‹(∑i::nat = Suc (0::nat)..Suc n. norm (fps_nth (f::'a fps) i) / (δ::real) ^ (Suc (n::nat) - i)) = (∑i::nat = Suc (0::nat)..Suc n. norm (fps_nth f i) * δ ^ i) / δ ^ Suc n›*)
apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))
(*goals:
1. ‹{Suc 0..Suc n} = {Suc 0..Suc n}›
2. ‹⋀x. x ∈ {Suc 0..Suc n} ⟹ norm (fps_nth f x) / δ ^ (Suc n - x) = norm (fps_nth f x) * δ ^ x / δ ^ Suc n›
discuss goal 1*)
apply ((insert ‹δ > 0›)[1])
(*top goal: ‹{Suc 0..Suc n} = {Suc 0..Suc n}› and 1 goal remains*)
apply ((auto simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) power_diff (*‹⟦?a ≠ 0; ?n ≤ ?m⟧ ⟹ ?a ^ (?m - ?n) = ?a ^ ?m div ?a ^ ?n›*))[1])
(*discuss goal 2*)
apply ((insert ‹δ > 0›)[1])
(*goal: ‹⋀x. x ∈ {Suc 0..Suc n} ⟹ norm (fps_nth f x) / δ ^ (Suc n - x) = norm (fps_nth f x) * δ ^ x / δ ^ Suc n›*)
apply ((auto simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) power_diff (*‹⟦?a ≠ 0; ?n ≤ ?m⟧ ⟹ ?a ^ (?m - ?n) = ?a ^ ?m div ?a ^ ?n›*))[1])
(*proven 2 subgoals*) .
also (*calculation: ‹norm (natfun_inverse (f::'a fps) (Suc (n::nat))) ≤ (∑i::nat = Suc (0::nat)..Suc n. norm (fps_nth f i) * (δ::real) ^ i) / δ ^ Suc n›*) have "(∑i = Suc 0..Suc n. norm (fps_nth f i) * δ ^ i) =
(∑i=0..n. norm (fps_nth f (Suc i)) * δ ^ (Suc i))"
apply (subst sum.atLeast_Suc_atMost_Suc_shift (*‹sum ?g {Suc ?m..Suc ?n} = sum (?g ∘ Suc) {?m..?n}›*))
(*goal: ‹(∑i = Suc 0..Suc n. norm (fps_nth f i) * δ ^ i) = (∑i = 0..n. norm (fps_nth f (Suc i)) * δ ^ Suc i)›*)
by simp
also (*calculation: ‹norm (natfun_inverse f (Suc n)) ≤ (∑i = 0..n. norm (fps_nth f (Suc i)) * δ ^ Suc i) / δ ^ Suc n›*) have "{0..n} = {..<Suc n}"
by auto
also (*calculation: ‹norm (natfun_inverse (f::'a fps) (Suc (n::nat))) ≤ (∑i::nat<Suc n. norm (fps_nth f (Suc i)) * (δ::real) ^ Suc i) / δ ^ Suc n›*) have "(∑i< Suc n. norm (fps_nth f (Suc i)) * δ ^ (Suc i)) ≤
(∑n. norm (fps_nth f (Suc n)) * δ ^ (Suc n))"
using ‹δ > 0› (*‹0 < δ›*) apply (intro sum_le_suminf (*‹⟦summable ?f; finite ?I; ⋀n. n ∈ - ?I ⟹ 0 ≤ ?f n⟧ ⟹ sum ?f ?I ≤ suminf ?f›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*) mult_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a * ?b›*) zero_le_power (*‹0 ≤ ?a ⟹ 0 ≤ ?a ^ ?n›*) summable (*‹summable (λn. norm (fps_nth f (Suc n)) * δ ^ Suc n)›*))
(*goals:
1. ‹0 < δ ⟹ finite {..<Suc n}›
2. ‹⋀n. ⟦0 < δ; n ∈ - {..<Suc n}⟧ ⟹ 0 ≤ norm (fps_nth f (Suc n))›
3. ‹⋀n. ⟦0 < δ; n ∈ - {..<Suc n}⟧ ⟹ 0 ≤ δ›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
also (*calculation: ‹(⋀x y. x ≤ y ⟹ x / δ ^ Suc n ≤ y / δ ^ Suc n) ⟹ norm (natfun_inverse f (Suc n)) ≤ (∑n. norm (fps_nth f (Suc n)) * δ ^ Suc n) / δ ^ Suc n›*) have "… ≤ 1"
by fact
finally (*calculation: ‹⟦⋀x y. x ≤ y ⟹ x / δ ^ Suc n ≤ y / δ ^ Suc n; ⋀x y. x ≤ y ⟹ x / δ ^ Suc n ≤ y / δ ^ Suc n⟧ ⟹ norm (natfun_inverse f (Suc n)) ≤ 1 / δ ^ Suc n›*) show "?thesis"
(*goal: ‹norm (natfun_inverse f m) ≤ inverse (δ ^ m)›*)
using ‹δ > 0› (*‹(0::real) < (δ::real)›*) by (simp add: divide_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a / ?c ≤ ?b / ?c›*) field_split_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 65 facts*))
qed
qed
private lemma fps_conv_radius_inverse_pos_aux:
fixes f :: "'a :: {banach, real_normed_field} fps"
assumes "fps_nth f 0 = 1" "fps_conv_radius f > 0"
shows "fps_conv_radius (inverse f) > 0"
proof (-)
(*goal: ‹0 < fps_conv_radius (inverse f)›*)
let ?R = "fps_conv_radius f"
define h where "h = Abs_fps (λn. norm (fps_nth f n))"
have [simp]: "fps_conv_radius h = ?R"
by (simp add: h_def (*‹(h::real fps) = Abs_fps (λn::nat. norm (fps_nth (f::'a::{banach,real_normed_field} fps) n))›*))
have "continuous_on (eball 0 (fps_conv_radius h)) (eval_fps h)"
by (intro continuous_on_eval_fps (*‹continuous_on (eball 0 (fps_conv_radius ?f)) (eval_fps ?f)›*))
hence "*": "open (eval_fps h -` A ∩ eball 0 ?R)" if "open A" for A
using that (*‹open (A::real set)›*) apply (subst (asm) continuous_on_open_vimage (*‹open ?s ⟹ continuous_on ?s ?f = (∀B. open B ⟶ open (?f -` B ∩ ?s))›*))
(*goals:
1. ‹open A ⟹ open (eball 0 (fps_conv_radius h))›
2. ‹⟦∀B. open B ⟶ open (eval_fps h -` B ∩ eball 0 (fps_conv_radius h)); open A⟧ ⟹ open (eval_fps h -` A ∩ eball 0 (fps_conv_radius f))›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
have "open (eval_fps h -` {..<2} ∩ eball 0 ?R)"
apply (rule * (*‹open (?A::real set) ⟹ open (eval_fps (h::real fps) -` ?A ∩ eball (0::real) (fps_conv_radius (f::'a fps)))›*))
(*goal: ‹open (eval_fps h -` {..<2} ∩ eball 0 (fps_conv_radius f))›*)
by auto
moreover have "0 ∈ eval_fps h -` {..<2} ∩ eball 0 ?R"
using assms (*‹fps_nth f 0 = 1› ‹0 < fps_conv_radius f›*) by (auto simp: eball_def (*‹eball ?z ?r = {z'. ereal (dist ?z z') < ?r}›*) zero_ereal_def (*‹0 = ereal 0›*) eval_fps_at_0 (*‹eval_fps ?f 0 = fps_nth ?f 0›*) h_def (*‹h = Abs_fps (λn. norm (fps_nth f n))›*))
ultimately obtain ε where "ε": "ε > 0" "ball 0 ε ⊆ eval_fps h -` {..<2} ∩ eball 0 ?R"
(*goal: ‹(⋀ε. ⟦0 < ε; ball 0 ε ⊆ eval_fps h -` {..<2} ∩ eball 0 (fps_conv_radius f)⟧ ⟹ thesis) ⟹ thesis›*)
apply (subst (asm) open_contains_ball_eq (*‹open ?S ⟹ (?x ∈ ?S) = (∃e>0. ball ?x e ⊆ ?S)›*))
(*goals:
1. ‹⟦⋀ε. ⟦0 < ε; ball 0 ε ⊆ eval_fps h -` {..<2} ∩ eball 0 (fps_conv_radius f)⟧ ⟹ thesis; open (eval_fps h -` {..<2} ∩ eball 0 (fps_conv_radius f))⟧ ⟹ open (eval_fps h -` {..<2} ∩ eball 0 (fps_conv_radius f))›
2. ‹⟦⋀ε. ⟦0 < ε; ball 0 ε ⊆ eval_fps h -` {..<2} ∩ eball 0 (fps_conv_radius f)⟧ ⟹ thesis; open (eval_fps h -` {..<2} ∩ eball 0 (fps_conv_radius f)); ∃e>0. ball 0 e ⊆ eval_fps h -` {..<2} ∩ eball 0 (fps_conv_radius f)⟧ ⟹ thesis›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
define δ where "δ = real_of_ereal (min (ereal ε / 2) (?R / 2))"
have "δ": "0 < δ ∧ δ < ε ∧ ereal δ < ?R"
using ‹ε > 0› (*‹0 < ε›*) assms (*‹fps_nth f 0 = 1› ‹0 < fps_conv_radius f›*) apply (cases ?R)
(*goals:
1. ‹⋀r. ⟦0 < ε; fps_nth f 0 = 1; 0 < fps_conv_radius f; fps_conv_radius f = ereal r⟧ ⟹ 0 < δ ∧ δ < ε ∧ ereal δ < fps_conv_radius f›
2. ‹⟦0 < ε; fps_nth f 0 = 1; 0 < fps_conv_radius f; fps_conv_radius f = ∞⟧ ⟹ 0 < δ ∧ δ < ε ∧ ereal δ < fps_conv_radius f›
3. ‹⟦0 < ε; fps_nth f 0 = 1; 0 < fps_conv_radius f; fps_conv_radius f = - ∞⟧ ⟹ 0 < δ ∧ δ < ε ∧ ereal δ < fps_conv_radius f›
discuss goal 1*)
apply ((auto simp: δ_def (*‹(δ::real) = real_of_ereal (min (ereal (ε::real) / (2::ereal)) (fps_conv_radius (f::'a fps) / (2::ereal)))›*) min_def (*‹min (?a::?'a) (?b::?'a) = (if ?a ≤ ?b then ?a else ?b)›*))[1])
(*discuss goal 2*)
apply ((auto simp: δ_def (*‹δ = real_of_ereal (min (ereal ε / 2) (fps_conv_radius f / 2))›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*))[1])
(*discuss goal 3*)
apply ((auto simp: δ_def (*‹δ = real_of_ereal (min (ereal ε / 2) (fps_conv_radius f / 2))›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*))[1])
(*proven 3 subgoals*) .
have summable: "summable (λn. norm (fps_nth f n) * δ ^ n)"
using "δ" (*‹0 < δ ∧ δ < ε ∧ ereal δ < fps_conv_radius f›*) apply (intro summable_in_conv_radius (*‹ereal (norm ?z) < conv_radius ?f ⟹ summable (λn. ?f n * ?z ^ n)›*))
(*goal: ‹summable (λn. norm (fps_nth f n) * δ ^ n)›*)
by (simp add: fps_conv_radius_def (*‹fps_conv_radius ?f = conv_radius (fps_nth ?f)›*))
hence "(λn. norm (fps_nth f n) * δ ^ n) sums eval_fps h δ"
by (simp add: eval_fps_def (*‹eval_fps ?f ?z = (∑n. fps_nth ?f n * ?z ^ n)›*) summable_sums (*‹summable ?f ⟹ ?f sums suminf ?f›*) h_def (*‹h = Abs_fps (λn. norm (fps_nth f n))›*))
hence "(λn. norm (fps_nth f (Suc n)) * δ ^ Suc n) sums (eval_fps h δ - 1)"
apply (subst sums_Suc_iff (*‹(λn. ?f (Suc n)) sums ?s = ?f sums (?s + ?f 0)›*))
(*goal: ‹(λn. norm (fps_nth f (Suc n)) * δ ^ Suc n) sums (eval_fps h δ - 1)›*)
by (auto simp: assms (*‹fps_nth (f::'a::{banach,real_normed_field} fps) (0::nat) = (1::'a::{banach,real_normed_field})› ‹(0::ereal) < fps_conv_radius (f::'a::{banach,real_normed_field} fps)›*))
moreover {
from "δ" (*‹0 < δ ∧ δ < ε ∧ ereal δ < fps_conv_radius f›*) have "δ ∈ ball 0 ε"
by auto
also (*calculation: ‹δ ∈ ball 0 ε›*) have "… ⊆ eval_fps h -` {..<2} ∩ eball 0 ?R"
by fact
finally (*calculation: ‹δ ∈ eval_fps h -` {..<2} ∩ eball 0 (fps_conv_radius f)›*) have "eval_fps h δ < 2"
by simp
}
ultimately have le: "(∑n. norm (fps_nth f (Suc n)) * δ ^ Suc n) ≤ 1"
by (simp add: sums_iff (*‹?f sums ?x = (summable ?f ∧ suminf ?f = ?x)›*))
from summable (*‹summable (λn. norm (fps_nth f n) * δ ^ n)›*) have summable: "summable (λn. norm (fps_nth f (Suc n)) * δ ^ Suc n)"
by (subst summable_Suc_iff (*‹summable (λn. ?f (Suc n)) = summable ?f›*))
have "0 < δ"
using "δ" (*‹(0::real) < (δ::real) ∧ δ < (ε::real) ∧ ereal δ < fps_conv_radius (f::'a fps)›*) by blast
also (*calculation: ‹(0::real) < (δ::real)›*) have "δ = inverse (limsup (λn. ereal (inverse δ)))"
using "δ" (*‹0 < δ ∧ δ < ε ∧ ereal δ < fps_conv_radius f›*) apply (subst Limsup_const (*‹?F ≠ bot ⟹ Limsup ?F (λx. ?c) = ?c›*))
(*goals:
1. ‹0 < δ ∧ δ < ε ∧ ereal δ < fps_conv_radius f ⟹ sequentially ≠ bot›
2. ‹0 < δ ∧ δ < ε ∧ ereal δ < fps_conv_radius f ⟹ ereal δ = inverse (ereal (inverse δ))›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
also (*calculation: ‹(⋀x y. x < y ⟹ ereal x < ereal y) ⟹ ereal 0 < inverse (limsup (λn. ereal (inverse δ)))›*) have "… ≤ conv_radius (natfun_inverse f)"
unfolding conv_radius_def
(*goal: ‹inverse (limsup (λn. ereal (inverse δ))) ≤ inverse (limsup (λn. ereal (root n (norm (natfun_inverse f n)))))›*)
proof (intro ereal_inverse_antimono (*‹⟦(0::ereal) ≤ (?x::ereal); ?x ≤ (?y::ereal)⟧ ⟹ inverse ?y ≤ inverse ?x›*) Limsup_mono (*‹∀⇩F x::?'a in ?F::?'a filter. (?f::?'a ⇒ ?'b) x ≤ (?g::?'a ⇒ ?'b) x ⟹ Limsup ?F ?f ≤ Limsup ?F ?g›*) eventually_mono[OF eventually_gt_at_top[of 0]] (*‹(⋀x::?'b2. (0::?'b2) < x ⟹ (?Q::?'b2 ⇒ bool) x) ⟹ eventually ?Q at_top›*))
(*goals:
1. ‹0 ≤ limsup (λn. ereal (root n (norm (natfun_inverse f n))))›
2. ‹⋀x. 0 < x ⟹ ereal (root x (norm (natfun_inverse f x))) ≤ ereal (inverse δ)›*)
fix n :: nat
assume n: "n > 0" (*‹(0::nat) < (n::nat)›*)
have "root n (norm (natfun_inverse f n)) ≤ root n (inverse (δ ^ n))"
using n (*‹0 < n›*) assms (*‹fps_nth f 0 = 1› ‹(0::ereal) < fps_conv_radius (f::'a::{banach,real_normed_field} fps)›*) "δ" (*‹(0::real) < (δ::real) ∧ δ < (ε::real) ∧ ereal δ < fps_conv_radius (f::'a fps)›*) le (*‹(∑n. norm (fps_nth f (Suc n)) * δ ^ Suc n) ≤ 1›*) summable (*‹summable (λn. norm (fps_nth f (Suc n)) * δ ^ Suc n)›*) apply (intro real_root_le_mono (*‹⟦0 < ?n; ?x ≤ ?y⟧ ⟹ root ?n ?x ≤ root ?n ?y›*) natfun_inverse_bound (*‹⟦fps_nth ?f 0 = 1; 0 < ?δ; summable (λn. norm (fps_nth ?f (Suc n)) * ?δ ^ Suc n); (∑n. norm (fps_nth ?f (Suc n)) * ?δ ^ Suc n) ≤ 1⟧ ⟹ norm (natfun_inverse ?f ?n) ≤ inverse (?δ ^ ?n)›*))
(*goals:
1. ‹⟦0 < n; fps_nth f 0 = 1; 0 < fps_conv_radius f; 0 < δ ∧ δ < ε ∧ ereal δ < fps_conv_radius f; (∑n. norm (fps_nth f (Suc n)) * δ ^ Suc n) ≤ 1; summable (λn. norm (fps_nth f (Suc n)) * δ ^ Suc n)⟧ ⟹ 0 < n›
2. ‹⟦0 < n; fps_nth f 0 = 1; 0 < fps_conv_radius f; 0 < δ ∧ δ < ε ∧ ereal δ < fps_conv_radius f; (∑n. norm (fps_nth f (Suc n)) * δ ^ Suc n) ≤ 1; summable (λn. norm (fps_nth f (Suc n)) * δ ^ Suc n)⟧ ⟹ fps_nth f 0 = 1›
3. ‹⟦0 < n; fps_nth f 0 = 1; 0 < fps_conv_radius f; 0 < δ ∧ δ < ε ∧ ereal δ < fps_conv_radius f; (∑n. norm (fps_nth f (Suc n)) * δ ^ Suc n) ≤ 1; summable (λn. norm (fps_nth f (Suc n)) * δ ^ Suc n)⟧ ⟹ 0 < δ›
4. ‹⟦0 < n; fps_nth f 0 = 1; 0 < fps_conv_radius f; 0 < δ ∧ δ < ε ∧ ereal δ < fps_conv_radius f; (∑n. norm (fps_nth f (Suc n)) * δ ^ Suc n) ≤ 1; summable (λn. norm (fps_nth f (Suc n)) * δ ^ Suc n)⟧ ⟹ summable (λn. norm (fps_nth f (Suc n)) * δ ^ Suc n)›
5. ‹⟦0 < n; fps_nth f 0 = 1; 0 < fps_conv_radius f; 0 < δ ∧ δ < ε ∧ ereal δ < fps_conv_radius f; (∑n. norm (fps_nth f (Suc n)) * δ ^ Suc n) ≤ 1; summable (λn. norm (fps_nth f (Suc n)) * δ ^ Suc n)⟧ ⟹ (∑n. norm (fps_nth f (Suc n)) * δ ^ Suc n) ≤ 1›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .
also (*calculation: ‹root n (norm (natfun_inverse f n)) ≤ root n (inverse (δ ^ n))›*) have "… = inverse δ"
using n (*‹(0::nat) < (n::nat)›*) "δ" (*‹0 < δ ∧ δ < ε ∧ ereal δ < fps_conv_radius f›*) by (simp add: power_inverse [symmetric] (*‹inverse ((?a::?'a) ^ (?n::nat)) = inverse ?a ^ ?n›*) real_root_pos2 (*‹⟦(0::nat) < (?n::nat); (0::real) ≤ (?x::real)⟧ ⟹ root ?n (?x ^ ?n) = ?x›*))
finally (*calculation: ‹root n (norm (natfun_inverse f n)) ≤ inverse δ›*) show "ereal (inverse δ) ≥ ereal (root n (norm (natfun_inverse f n)))"
by (subst ereal_less_eq (*‹?x ≤ ∞› ‹- ∞ ≤ ?x› ‹(ereal ?r ≤ ereal ?p) = (?r ≤ ?p)› ‹(ereal ?r ≤ 0) = (?r ≤ 0)› ‹(0 ≤ ereal ?r) = (0 ≤ ?r)› ‹(ereal ?r ≤ 1) = (?r ≤ 1)› ‹(1 ≤ ereal ?r) = (1 ≤ ?r)›*))
next
(*goal: ‹0 ≤ limsup (λn. ereal (root n (norm (natfun_inverse f n))))›*)
have "0 = limsup (λn. 0::ereal)"
apply (rule Limsup_const [symmetric] (*‹?F ≠ bot ⟹ ?t = Limsup ?F (λx. ?t)›*))
(*goal: ‹0 = limsup (λn. 0)›*)
by auto
also (*calculation: ‹0 = limsup (λn. 0)›*) have "… ≤ limsup (λn. ereal (root n (norm (natfun_inverse f n))))"
apply (intro Limsup_mono (*‹∀⇩F x in ?F. ?f x ≤ ?g x ⟹ Limsup ?F ?f ≤ Limsup ?F ?g›*))
(*goal: ‹limsup (λn. 0) ≤ limsup (λn. ereal (root n (norm (natfun_inverse f n))))›*)
by (auto simp: real_root_ge_zero (*‹0 ≤ ?x ⟹ 0 ≤ root ?n ?x›*))
finally (*calculation: ‹0 ≤ limsup (λn. ereal (root n (norm (natfun_inverse f n))))›*) show "0 ≤ …"
by simp
qed
also (*calculation: ‹(⋀x y. x < y ⟹ ereal x < ereal y) ⟹ ereal 0 < conv_radius (natfun_inverse f)›*) have "… = fps_conv_radius (inverse f)"
using assms (*‹fps_nth (f::'a fps) (0::nat) = (1::'a)› ‹0 < fps_conv_radius f›*) by (simp add: fps_conv_radius_def (*‹fps_conv_radius ?f = conv_radius (fps_nth ?f)›*) fps_inverse_def (*‹inverse ?f = fps_right_inverse ?f (inverse (fps_nth ?f 0))›*))
finally (*calculation: ‹(⋀x y. x < y ⟹ ereal x < ereal y) ⟹ ereal 0 < fps_conv_radius (inverse f)›*) show "?thesis"
(*goal: ‹0 < fps_conv_radius (inverse f)›*)
by (simp add: zero_ereal_def (*‹0 = ereal 0›*))
qed
lemma fps_conv_radius_inverse_pos:
fixes f :: "'a :: {banach, real_normed_field} fps"
assumes "fps_nth f 0 ≠ 0" and "fps_conv_radius f > 0"
shows "fps_conv_radius (inverse f) > 0"
proof (-)
(*goal: ‹0 < fps_conv_radius (inverse f)›*)
let ?c = "fps_nth f 0"
have "fps_conv_radius (inverse f) = fps_conv_radius (fps_const ?c * inverse f)"
using assms (*‹fps_nth f 0 ≠ 0› ‹0 < fps_conv_radius f›*) apply (subst fps_conv_radius_cmult_left (*‹?c ≠ 0 ⟹ fps_conv_radius (fps_const ?c * ?f) = fps_conv_radius ?f›*))
(*goals:
1. ‹⟦fps_nth f 0 ≠ 0; 0 < fps_conv_radius f⟧ ⟹ fps_nth f 0 ≠ 0›
2. ‹⟦fps_nth f 0 ≠ 0; 0 < fps_conv_radius f⟧ ⟹ fps_conv_radius (inverse f) = fps_conv_radius (inverse f)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
also (*calculation: ‹fps_conv_radius (inverse f) = fps_conv_radius (fps_const (fps_nth f 0) * inverse f)›*) have "fps_const ?c * inverse f = inverse (fps_const (inverse ?c) * f)"
using assms (*‹fps_nth f 0 ≠ 0› ‹0 < fps_conv_radius f›*) by (simp add: fps_inverse_mult (*‹inverse (?f * ?g) = inverse ?f * inverse ?g›*) fps_const_inverse (*‹inverse (fps_const ?a) = fps_const (inverse ?a)›*))
also (*calculation: ‹fps_conv_radius (inverse f) = fps_conv_radius (inverse (fps_const (inverse (fps_nth f 0)) * f))›*) have "fps_conv_radius … > 0"
using assms (*‹fps_nth f 0 ≠ 0› ‹0 < fps_conv_radius f›*) apply (intro fps_conv_radius_inverse_pos_aux (*‹⟦fps_nth ?f 0 = 1; 0 < fps_conv_radius ?f⟧ ⟹ 0 < fps_conv_radius (inverse ?f)›*))
(*goals:
1. ‹⟦fps_nth f 0 ≠ 0; 0 < fps_conv_radius f⟧ ⟹ fps_nth (fps_const (inverse (fps_nth f 0)) * f) 0 = 1›
2. ‹⟦fps_nth f 0 ≠ 0; 0 < fps_conv_radius f⟧ ⟹ 0 < fps_conv_radius (fps_const (inverse (fps_nth f 0)) * f)›
discuss goal 1*)
apply ((auto simp: fps_conv_radius_cmult_left (*‹?c ≠ 0 ⟹ fps_conv_radius (fps_const ?c * ?f) = fps_conv_radius ?f›*))[1])
(*discuss goal 2*)
apply ((auto simp: fps_conv_radius_cmult_left (*‹?c ≠ 0 ⟹ fps_conv_radius (fps_const ?c * ?f) = fps_conv_radius ?f›*))[1])
(*proven 2 subgoals*) .
finally (*calculation: ‹0 < fps_conv_radius (inverse f)›*) show "?thesis"
(*goal: ‹0 < fps_conv_radius (inverse f)›*) .
qed
end
lemma fps_conv_radius_exp [simp]:
fixes c :: "'a :: {banach, real_normed_field}"
shows "fps_conv_radius (fps_exp c) = ∞"
unfolding fps_conv_radius_def
(*goal: ‹conv_radius (fps_nth (fps_exp c)) = ∞›*)
proof (rule conv_radius_inftyI'' (*‹(⋀z. summable (λn. ?f n * z ^ n)) ⟹ conv_radius ?f = ∞›*))
(*goal: ‹⋀z::'a. summable (λn::nat. fps_nth (fps_exp (c::'a)) n * z ^ n)›*)
fix z :: 'a
have "(λn. norm (c * z) ^ n /⇩R fact n) sums exp (norm (c * z))"
by (rule exp_converges (*‹(λn. ?x ^ n /⇩R fact n) sums exp ?x›*))
also (*calculation: ‹(λn. norm (c * z) ^ n /⇩R fact n) sums exp (norm (c * z))›*) have "(λn. norm (c * z) ^ n /⇩R fact n) = (λn. norm (fps_nth (fps_exp c) n * z ^ n))"
apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*))
(*goal: ‹(λn. norm (c * z) ^ n /⇩R fact n) = (λn. norm (fps_nth (fps_exp c) n * z ^ n))›*)
by (simp add: norm_divide (*‹norm (?a / ?b) = norm ?a / norm ?b›*) norm_mult (*‹norm (?x * ?y) = norm ?x * norm ?y›*) norm_power (*‹norm (?x ^ ?n) = norm ?x ^ ?n›*) field_split_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 65 facts*))
finally (*calculation: ‹(λn. norm (fps_nth (fps_exp c) n * z ^ n)) sums exp (norm (c * z))›*) have "summable …"
by (simp add: sums_iff (*‹?f sums ?x = (summable ?f ∧ suminf ?f = ?x)›*))
thus "summable (λn. fps_nth (fps_exp c) n * z ^ n)"
by (rule summable_norm_cancel (*‹summable (λn. norm (?f n)) ⟹ summable ?f›*))
qed
subsection ‹Evaluating power series›
theorem eval_fps_deriv:
assumes "norm z < fps_conv_radius f"
shows "eval_fps (fps_deriv f) z = deriv (eval_fps f) z"
by (intro DERIV_imp_deriv [symmetric] (*‹(?f has_field_derivative ?t) (at ?x) ⟹ ?t = deriv ?f ?x›*) has_field_derivative_eval_fps (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ (eval_fps ?f has_field_derivative eval_fps (fps_deriv ?f) ?z) (at ?z within ?A)›*) assms (*‹ereal (norm z) < fps_conv_radius f›*))
theorem fps_nth_conv_deriv:
fixes f :: "complex fps"
assumes "fps_conv_radius f > 0"
shows "fps_nth f n = (deriv ^^ n) (eval_fps f) 0 / fact n"
using assms (*‹0 < fps_conv_radius f›*) proof (induction n arbitrary: f)
(*goals:
1. ‹⋀f::complex fps. (0::ereal) < fps_conv_radius f ⟹ fps_nth f (0::nat) = (deriv ^^ (0::nat)) (eval_fps f) (0::complex) / fact (0::nat)›
2. ‹⋀(n::nat) f::complex fps. ⟦⋀f::complex fps. (0::ereal) < fps_conv_radius f ⟹ fps_nth f n = (deriv ^^ n) (eval_fps f) (0::complex) / fact n; (0::ereal) < fps_conv_radius f⟧ ⟹ fps_nth f (Suc n) = (deriv ^^ Suc n) (eval_fps f) (0::complex) / fact (Suc n)›*)
case 0 (*‹0 < fps_conv_radius f›*)
thus "?case"
(*goal: ‹fps_nth f 0 = (deriv ^^ 0) (eval_fps f) 0 / fact 0›*)
by (simp add: eval_fps_def (*‹eval_fps ?f ?z = (∑n. fps_nth ?f n * ?z ^ n)›*))
next
(*goal: ‹⋀n f. ⟦⋀f. 0 < fps_conv_radius f ⟹ fps_nth f n = (deriv ^^ n) (eval_fps f) 0 / fact n; 0 < fps_conv_radius f⟧ ⟹ fps_nth f (Suc n) = (deriv ^^ Suc n) (eval_fps f) 0 / fact (Suc n)›*)
case (Suc n f) (*‹0 < fps_conv_radius ?f ⟹ fps_nth ?f n = (deriv ^^ n) (eval_fps ?f) 0 / fact n› ‹0 < fps_conv_radius f›*)
have "(deriv ^^ Suc n) (eval_fps f) 0 = (deriv ^^ n) (deriv (eval_fps f)) 0"
unfolding funpow_Suc_right o_def
(*goal: ‹(deriv ^^ n) (deriv (eval_fps f)) 0 = (deriv ^^ n) (deriv (eval_fps f)) 0›*)
by standard
also (*calculation: ‹(deriv ^^ Suc (n::nat)) (eval_fps (f::complex fps)) (0::complex) = (deriv ^^ n) (deriv (eval_fps f)) (0::complex)›*) have "eventually (λz::complex. z ∈ eball 0 (fps_conv_radius f)) (nhds 0)"
using Suc.prems (*‹(0::ereal) < fps_conv_radius (f::complex fps)›*) apply (intro eventually_nhds_in_open (*‹⟦open (?s::?'a set); (?x::?'a) ∈ ?s⟧ ⟹ ∀⇩F y::?'a in nhds ?x. y ∈ ?s›*))
(*goals:
1. ‹0 < fps_conv_radius f ⟹ open (eball 0 (fps_conv_radius f))›
2. ‹0 < fps_conv_radius f ⟹ 0 ∈ eball 0 (fps_conv_radius f)›
discuss goal 1*)
apply ((auto simp: zero_ereal_def (*‹0 = ereal 0›*))[1])
(*discuss goal 2*)
apply ((auto simp: zero_ereal_def (*‹0 = ereal 0›*))[1])
(*proven 2 subgoals*) .
hence "eventually (λz. deriv (eval_fps f) z = eval_fps (fps_deriv f) z) (nhds 0)"
apply eventually_elim
(*goal: ‹∀⇩F z in nhds 0. deriv (eval_fps f) z = eval_fps (fps_deriv f) z›*)
by (simp add: eval_fps_deriv (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ eval_fps (fps_deriv ?f) ?z = deriv (eval_fps ?f) ?z›*))
hence "(deriv ^^ n) (deriv (eval_fps f)) 0 = (deriv ^^ n) (eval_fps (fps_deriv f)) 0"
by (intro higher_deriv_cong_ev (*‹⟦∀⇩F x::?'a in nhds (?x::?'a). (?f::?'a ⇒ ?'a) x = (?g::?'a ⇒ ?'a) x; ?x = (?y::?'a)⟧ ⟹ (deriv ^^ (?n::nat)) ?f ?x = (deriv ^^ ?n) ?g ?y›*) refl (*‹(?t::?'a) = ?t›*))
also (*calculation: ‹(deriv ^^ Suc n) (eval_fps f) 0 = (deriv ^^ n) (eval_fps (fps_deriv f)) 0›*) have "… / fact n = fps_nth (fps_deriv f) n"
using Suc.prems (*‹0 < fps_conv_radius f›*) fps_conv_radius_deriv[of f] (*‹fps_conv_radius (f::complex fps) ≤ fps_conv_radius (fps_deriv f)›*) apply (intro Suc.IH [symmetric] (*‹0 < fps_conv_radius ?f ⟹ (deriv ^^ n) (eval_fps ?f) 0 / fact n = fps_nth ?f n›*))
(*goal: ‹(deriv ^^ (n::nat)) (eval_fps (fps_deriv (f::complex fps))) (0::complex) / fact n = fps_nth (fps_deriv f) n›*)
by auto
also (*calculation: ‹(deriv ^^ Suc (n::nat)) (eval_fps (f::complex fps)) (0::complex) / fact n = fps_nth (fps_deriv f) n›*) have "… / of_nat (Suc n) = fps_nth f (Suc n)"
by (simp add: fps_deriv_def (*‹fps_deriv ?f = Abs_fps (λn. of_nat (n + 1) * fps_nth ?f (n + 1))›*) del: of_nat_Suc (*‹of_nat (Suc ?m) = 1 + of_nat ?m›*))
finally (*calculation: ‹(deriv ^^ Suc n) (eval_fps f) 0 / fact n / complex_of_nat (Suc n) = fps_nth f (Suc n)›*) show "?case"
(*goal: ‹fps_nth f (Suc n) = (deriv ^^ Suc n) (eval_fps f) 0 / fact (Suc n)›*)
by (simp add: field_split_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 65 facts*))
qed
theorem eval_fps_eqD:
fixes f g :: "complex fps"
assumes "fps_conv_radius f > 0" "fps_conv_radius g > 0"
assumes "eventually (λz. eval_fps f z = eval_fps g z) (nhds 0)"
shows "f = g"
proof (rule fps_ext (*‹(⋀n::nat. fps_nth (?p::?'a fps) n = fps_nth (?q::?'a fps) n) ⟹ ?p = ?q›*))
(*goal: ‹⋀n. fps_nth f n = fps_nth g n›*)
fix n :: nat
have "fps_nth f n = (deriv ^^ n) (eval_fps f) 0 / fact n"
using assms (*‹0 < fps_conv_radius f› ‹0 < fps_conv_radius g› ‹∀⇩F z in nhds 0. eval_fps f z = eval_fps g z›*) by (intro fps_nth_conv_deriv (*‹0 < fps_conv_radius ?f ⟹ fps_nth ?f ?n = (deriv ^^ ?n) (eval_fps ?f) 0 / fact ?n›*))
also (*calculation: ‹fps_nth f n = (deriv ^^ n) (eval_fps f) 0 / fact n›*) have "(deriv ^^ n) (eval_fps f) 0 = (deriv ^^ n) (eval_fps g) 0"
by (intro higher_deriv_cong_ev (*‹⟦∀⇩F x in nhds ?x. ?f x = ?g x; ?x = ?y⟧ ⟹ (deriv ^^ ?n) ?f ?x = (deriv ^^ ?n) ?g ?y›*) refl (*‹?t = ?t›*) assms (*‹0 < fps_conv_radius f› ‹0 < fps_conv_radius g› ‹∀⇩F z in nhds 0. eval_fps f z = eval_fps g z›*))
also (*calculation: ‹fps_nth f n = (deriv ^^ n) (eval_fps g) 0 / fact n›*) have "… / fact n = fps_nth g n"
using assms (*‹0 < fps_conv_radius f› ‹0 < fps_conv_radius g› ‹∀⇩F z in nhds 0. eval_fps f z = eval_fps g z›*) by (intro fps_nth_conv_deriv [symmetric] (*‹(0::ereal) < fps_conv_radius (?f::complex fps) ⟹ (deriv ^^ (?n::nat)) (eval_fps ?f) (0::complex) / fact ?n = fps_nth ?f ?n›*))
finally (*calculation: ‹fps_nth f n = fps_nth g n›*) show "fps_nth f n = fps_nth g n" .
qed
lemma eval_fps_const [simp]:
fixes c :: "'a :: {banach, real_normed_div_algebra}"
shows "eval_fps (fps_const c) z = c"
proof (-)
(*goal: ‹eval_fps (fps_const c) z = c›*)
have "(λn::nat. if n ∈ {0} then c else 0) sums (∑n∈{0::nat}. c)"
apply (rule sums_If_finite_set (*‹finite ?A ⟹ (λr. if r ∈ ?A then ?f r else 0) sums sum ?f ?A›*))
(*goal: ‹(λn. if n ∈ {0} then c else 0) sums (∑n∈{0}. c)›*)
by auto
also (*calculation: ‹(λn. if n ∈ {0} then c else 0) sums (∑n∈{0}. c)›*) have "?this ⟷ (λn::nat. fps_nth (fps_const c) n * z ^ n) sums (∑n∈{0::nat}. c)"
apply (intro sums_cong (*‹(⋀n::nat. (?f::nat ⇒ ?'a::{comm_monoid_add,topological_space}) n = (?g::nat ⇒ ?'a::{comm_monoid_add,topological_space}) n) ⟹ ?f sums (?c::?'a::{comm_monoid_add,topological_space}) = ?g sums ?c›*))
(*goal: ‹(λn. if n ∈ {0} then c else 0) sums (∑n∈{0}. c) = (λn. fps_nth (fps_const c) n * z ^ n) sums (∑n∈{0}. c)›*)
by auto
also (*calculation: ‹(λn. fps_nth (fps_const c) n * z ^ n) sums (∑n∈{0}. c)›*) have "(∑n∈{0::nat}. c) = c"
by simp
finally (*calculation: ‹(λn. fps_nth (fps_const c) n * z ^ n) sums c›*) show "?thesis"
(*goal: ‹eval_fps (fps_const c) z = c›*)
by (simp add: eval_fps_def (*‹eval_fps ?f ?z = (∑n. fps_nth ?f n * ?z ^ n)›*) sums_iff (*‹?f sums ?x = (summable ?f ∧ suminf ?f = ?x)›*))
qed
lemma eval_fps_0 [simp]:
"eval_fps (0 :: 'a :: {banach, real_normed_div_algebra} fps) z = 0"
by (simp only: fps_const_0_eq_0 [symmetric] (*‹0 = fps_const 0›*) eval_fps_const (*‹eval_fps (fps_const ?c) ?z = ?c›*))
lemma eval_fps_1 [simp]:
"eval_fps (1 :: 'a :: {banach, real_normed_div_algebra} fps) z = 1"
by (simp only: fps_const_1_eq_1 [symmetric] (*‹1 = fps_const 1›*) eval_fps_const (*‹eval_fps (fps_const ?c) ?z = ?c›*))
lemma eval_fps_numeral [simp]:
"eval_fps (numeral n :: 'a :: {banach, real_normed_div_algebra} fps) z = numeral n"
by (simp only: numeral_fps_const (*‹numeral ?k = fps_const (numeral ?k)›*) eval_fps_const (*‹eval_fps (fps_const ?c) ?z = ?c›*))
lemma eval_fps_X_power [simp]:
"eval_fps (fps_X ^ m :: 'a :: {banach, real_normed_div_algebra} fps) z = z ^ m"
proof (-)
(*goal: ‹eval_fps (fps_X ^ (m::nat)) (z::'a) = z ^ m›*)
have "(λn::nat. if n ∈ {m} then z ^ n else 0 :: 'a) sums (∑n∈{m::nat}. z ^ n)"
apply (rule sums_If_finite_set (*‹finite ?A ⟹ (λr. if r ∈ ?A then ?f r else 0) sums sum ?f ?A›*))
(*goal: ‹(λn. if n ∈ {m} then z ^ n else 0) sums sum ((^) z) {m}›*)
by auto
also (*calculation: ‹(λn. if n ∈ {m} then z ^ n else 0) sums sum ((^) z) {m}›*) have "?this ⟷ (λn::nat. fps_nth (fps_X ^ m) n * z ^ n) sums (∑n∈{m::nat}. z ^ n)"
apply (intro sums_cong (*‹(⋀n. ?f n = ?g n) ⟹ ?f sums ?c = ?g sums ?c›*))
(*goal: ‹(λn. if n ∈ {m} then z ^ n else 0) sums sum ((^) z) {m} = (λn. fps_nth (fps_X ^ m) n * z ^ n) sums sum ((^) z) {m}›*)
by (auto simp: fps_X_power_iff (*‹fps_X ^ ?n = Abs_fps (λm. if m = ?n then 1 else 0)›*))
also (*calculation: ‹(λn. fps_nth (fps_X ^ m) n * z ^ n) sums sum ((^) z) {m}›*) have "(∑n∈{m::nat}. z ^ n) = z ^ m"
by simp
finally (*calculation: ‹(λn. fps_nth (fps_X ^ m) n * z ^ n) sums z ^ m›*) show "?thesis"
(*goal: ‹eval_fps (fps_X ^ m) z = z ^ m›*)
by (simp add: eval_fps_def (*‹eval_fps ?f ?z = (∑n. fps_nth ?f n * ?z ^ n)›*) sums_iff (*‹?f sums ?x = (summable ?f ∧ suminf ?f = ?x)›*))
qed
lemma eval_fps_X [simp]:
"eval_fps (fps_X :: 'a :: {banach, real_normed_div_algebra} fps) z = z"
using eval_fps_X_power[of 1 z] (*‹eval_fps (fps_X ^ 1) z = z ^ 1›*) by (simp only: power_one_right (*‹?a ^ 1 = ?a›*))
lemma eval_fps_minus:
fixes f :: "'a :: {banach, real_normed_div_algebra} fps"
assumes "norm z < fps_conv_radius f"
shows "eval_fps (-f) z = -eval_fps f z"
using assms (*‹ereal (norm (z::'a)) < fps_conv_radius (f::'a fps)›*) unfolding eval_fps_def
(*goal: ‹(∑n. fps_nth (- f) n * z ^ n) = - (∑n. fps_nth f n * z ^ n)›*)
apply (subst suminf_minus [symmetric] (*‹summable ?f ⟹ - (∑n. ?f n) = (∑n. - ?f n)›*))
(*goals:
1. ‹ereal (norm (z::'a::{banach,real_normed_div_algebra})) < fps_conv_radius (f::'a::{banach,real_normed_div_algebra} fps) ⟹ summable (λn::nat. fps_nth f n * z ^ n)›
2. ‹ereal (norm (z::'a::{banach,real_normed_div_algebra})) < fps_conv_radius (f::'a::{banach,real_normed_div_algebra} fps) ⟹ (∑n::nat. fps_nth (- f) n * z ^ n) = (∑n::nat. - (fps_nth f n * z ^ n))›
discuss goal 1*)
apply ((auto intro!: summable_fps (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ summable (λn. fps_nth ?f n * ?z ^ n)›*))[1])
(*discuss goal 2*)
apply ((auto intro!: summable_fps (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ summable (λn. fps_nth ?f n * ?z ^ n)›*))[1])
(*proven 2 subgoals*) .
lemma eval_fps_add:
fixes f g :: "'a :: {banach, real_normed_div_algebra} fps"
assumes "norm z < fps_conv_radius f" "norm z < fps_conv_radius g"
shows "eval_fps (f + g) z = eval_fps f z + eval_fps g z"
using assms (*‹ereal (norm z) < fps_conv_radius f› ‹ereal (norm z) < fps_conv_radius g›*) unfolding eval_fps_def
(*goal: ‹(∑n. fps_nth (f + g) n * z ^ n) = (∑n. fps_nth f n * z ^ n) + (∑n. fps_nth g n * z ^ n)›*)
apply (subst suminf_add (*‹⟦summable ?f; summable ?g⟧ ⟹ suminf ?f + suminf ?g = (∑n. ?f n + ?g n)›*))
(*goals:
1. ‹⟦ereal (norm z) < fps_conv_radius f; ereal (norm z) < fps_conv_radius g⟧ ⟹ summable (λn. fps_nth f n * z ^ n)›
2. ‹⟦ereal (norm z) < fps_conv_radius f; ereal (norm z) < fps_conv_radius g⟧ ⟹ summable (λn. fps_nth g n * z ^ n)›
3. ‹⟦ereal (norm z) < fps_conv_radius f; ereal (norm z) < fps_conv_radius g⟧ ⟹ (∑n. fps_nth (f + g) n * z ^ n) = (∑n. fps_nth f n * z ^ n + fps_nth g n * z ^ n)›
discuss goal 1*)
apply ((auto simp: ring_distribs (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c› ‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c› ‹(?a - ?b) * ?c = ?a * ?c - ?b * ?c› ‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*) intro!: summable_fps (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ summable (λn. fps_nth ?f n * ?z ^ n)›*))[1])
(*discuss goal 2*)
apply ((auto simp: ring_distribs (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c› ‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c› ‹(?a - ?b) * ?c = ?a * ?c - ?b * ?c› ‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*) intro!: summable_fps (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ summable (λn. fps_nth ?f n * ?z ^ n)›*))[1])
(*discuss goal 3*)
apply ((auto simp: ring_distribs (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c› ‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c› ‹(?a - ?b) * ?c = ?a * ?c - ?b * ?c› ‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*) intro!: summable_fps (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ summable (λn. fps_nth ?f n * ?z ^ n)›*))[1])
(*proven 3 subgoals*) .
lemma eval_fps_diff:
fixes f g :: "'a :: {banach, real_normed_div_algebra} fps"
assumes "norm z < fps_conv_radius f" "norm z < fps_conv_radius g"
shows "eval_fps (f - g) z = eval_fps f z - eval_fps g z"
using assms (*‹ereal (norm z) < fps_conv_radius f› ‹ereal (norm z) < fps_conv_radius g›*) unfolding eval_fps_def
(*goal: ‹(∑n::nat. fps_nth ((f::'a::{banach,real_normed_div_algebra} fps) - (g::'a::{banach,real_normed_div_algebra} fps)) n * (z::'a::{banach,real_normed_div_algebra}) ^ n) = (∑n::nat. fps_nth f n * z ^ n) - (∑n::nat. fps_nth g n * z ^ n)›*)
apply (subst suminf_diff (*‹⟦summable ?f; summable ?g⟧ ⟹ suminf ?f - suminf ?g = (∑n. ?f n - ?g n)›*))
(*goals:
1. ‹⟦ereal (norm z) < fps_conv_radius f; ereal (norm z) < fps_conv_radius g⟧ ⟹ summable (λn. fps_nth f n * z ^ n)›
2. ‹⟦ereal (norm z) < fps_conv_radius f; ereal (norm z) < fps_conv_radius g⟧ ⟹ summable (λn. fps_nth g n * z ^ n)›
3. ‹⟦ereal (norm z) < fps_conv_radius f; ereal (norm z) < fps_conv_radius g⟧ ⟹ (∑n. fps_nth (f - g) n * z ^ n) = (∑n. fps_nth f n * z ^ n - fps_nth g n * z ^ n)›
discuss goal 1*)
apply ((auto simp: ring_distribs (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c› ‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c› ‹(?a - ?b) * ?c = ?a * ?c - ?b * ?c› ‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*) intro!: summable_fps (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ summable (λn. fps_nth ?f n * ?z ^ n)›*))[1])
(*discuss goal 2*)
apply ((auto simp: ring_distribs (*‹(?a::?'a::semiring) * ((?b::?'a::semiring) + (?c::?'a::semiring)) = ?a * ?b + ?a * ?c› ‹((?a::?'a::semiring) + (?b::?'a::semiring)) * (?c::?'a::semiring) = ?a * ?c + ?b * ?c› ‹((?a::?'a::ring) - (?b::?'a::ring)) * (?c::?'a::ring) = ?a * ?c - ?b * ?c› ‹(?a::?'a::ring) * ((?b::?'a::ring) - (?c::?'a::ring)) = ?a * ?b - ?a * ?c›*) intro!: summable_fps (*‹ereal (norm (?z::?'a::{banach,real_normed_div_algebra})) < fps_conv_radius (?f::?'a::{banach,real_normed_div_algebra} fps) ⟹ summable (λn::nat. fps_nth ?f n * ?z ^ n)›*))[1])
(*discuss goal 3*)
apply ((auto simp: ring_distribs (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c› ‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c› ‹(?a - ?b) * ?c = ?a * ?c - ?b * ?c› ‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*) intro!: summable_fps (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ summable (λn. fps_nth ?f n * ?z ^ n)›*))[1])
(*proven 3 subgoals*) .
lemma eval_fps_mult:
fixes f g :: "'a :: {banach, real_normed_div_algebra, comm_ring_1} fps"
assumes "norm z < fps_conv_radius f" "norm z < fps_conv_radius g"
shows "eval_fps (f * g) z = eval_fps f z * eval_fps g z"
proof (-)
(*goal: ‹eval_fps (f * g) z = eval_fps f z * eval_fps g z›*)
have "eval_fps f z * eval_fps g z =
(∑k. ∑i≤k. fps_nth f i * fps_nth g (k - i) * (z ^ i * z ^ (k - i)))"
unfolding eval_fps_def
(*goal: ‹(∑n::nat. fps_nth (f::'a fps) n * (z::'a) ^ n) * (∑n::nat. fps_nth (g::'a fps) n * z ^ n) = (∑k::nat. ∑i::nat≤k. fps_nth f i * fps_nth g (k - i) * (z ^ i * z ^ (k - i)))›*)
proof (subst Cauchy_product (*‹⟦summable (λk::nat. norm ((?a::nat ⇒ ?'a) k)); summable (λk::nat. norm ((?b::nat ⇒ ?'a) k))⟧ ⟹ (∑k::nat. ?a k) * (∑k::nat. ?b k) = (∑k::nat. ∑i::nat≤k. ?a i * ?b (k - i))›*))
(*goals:
1. ‹summable (λk. norm (fps_nth f k * z ^ k))›
2. ‹summable (λk. norm (fps_nth g k * z ^ k))›
3. ‹(∑k. ∑i≤k. fps_nth f i * z ^ i * (fps_nth g (k - i) * z ^ (k - i))) = (∑k. ∑i≤k. fps_nth f i * fps_nth g (k - i) * (z ^ i * z ^ (k - i)))›*)
show "summable (λk. norm (fps_nth f k * z ^ k))" "summable (λk. norm (fps_nth g k * z ^ k))"
(*goals:
1. ‹summable (λk. norm (fps_nth f k * z ^ k))›
2. ‹summable (λk. norm (fps_nth g k * z ^ k))›
discuss goal 1*)
apply (rule norm_summable_fps (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ summable (λn. norm (fps_nth ?f n * ?z ^ n))›*) assms (*‹ereal (norm z) < fps_conv_radius f› ‹ereal (norm z) < fps_conv_radius g›*))
(*top goal: ‹summable (λk. norm (fps_nth f k * z ^ k))› and 1 goal remains*)
apply (rule norm_summable_fps (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ summable (λn. norm (fps_nth ?f n * ?z ^ n))›*) assms (*‹ereal (norm z) < fps_conv_radius f› ‹ereal (norm z) < fps_conv_radius g›*))
(*discuss goal 2*)
apply (rule norm_summable_fps (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ summable (λn. norm (fps_nth ?f n * ?z ^ n))›*) assms (*‹ereal (norm z) < fps_conv_radius f› ‹ereal (norm z) < fps_conv_radius g›*))
(*goal: ‹summable (λk::nat. norm (fps_nth (g::'a::{banach,real_normed_div_algebra,comm_ring_1} fps) k * (z::'a::{banach,real_normed_div_algebra,comm_ring_1}) ^ k))›*)
apply (rule norm_summable_fps (*‹ereal (norm (?z::?'a)) < fps_conv_radius (?f::?'a fps) ⟹ summable (λn::nat. norm (fps_nth ?f n * ?z ^ n))›*) assms (*‹ereal (norm (z::'a)) < fps_conv_radius (f::'a fps)› ‹ereal (norm (z::'a)) < fps_conv_radius (g::'a fps)›*))
(*proven 2 subgoals*) .
qed (simp_all add: algebra_simps)
(*solved the remaining goal: ‹(∑k. ∑i≤k. fps_nth f i * z ^ i * (fps_nth g (k - i) * z ^ (k - i))) = (∑k. ∑i≤k. fps_nth f i * fps_nth g (k - i) * (z ^ i * z ^ (k - i)))›*)
also (*calculation: ‹eval_fps (f::'a fps) (z::'a) * eval_fps (g::'a fps) z = (∑k::nat. ∑i::nat≤k. fps_nth f i * fps_nth g (k - i) * (z ^ i * z ^ (k - i)))›*) have "(λk. ∑i≤k. fps_nth f i * fps_nth g (k - i) * (z ^ i * z ^ (k - i))) =
(λk. ∑i≤k. fps_nth f i * fps_nth g (k - i) * z ^ k)"
apply (intro ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) refl (*‹?t = ?t›*))
(*goal: ‹(λk::nat. ∑i::nat≤k. fps_nth (f::'a::{banach,real_normed_div_algebra,comm_ring_1} fps) i * fps_nth (g::'a::{banach,real_normed_div_algebra,comm_ring_1} fps) (k - i) * ((z::'a::{banach,real_normed_div_algebra,comm_ring_1}) ^ i * z ^ (k - i))) = (λk::nat. ∑i::nat≤k. fps_nth f i * fps_nth g (k - i) * z ^ k)›*)
by (simp add: power_add [symmetric] (*‹?a ^ ?m * ?a ^ ?n = ?a ^ (?m + ?n)›*))
also (*calculation: ‹eval_fps f z * eval_fps g z = (∑k. ∑i≤k. fps_nth f i * fps_nth g (k - i) * z ^ k)›*) have "suminf … = eval_fps (f * g) z"
by (simp add: eval_fps_def (*‹eval_fps ?f ?z = (∑n. fps_nth ?f n * ?z ^ n)›*) fps_mult_nth (*‹fps_nth (?f * ?g) ?n = (∑i = 0..?n. fps_nth ?f i * fps_nth ?g (?n - i))›*) atLeast0AtMost (*‹{0..?n} = {..?n}›*) sum_distrib_right (*‹sum ?f ?A * ?r = (∑n∈?A. ?f n * ?r)›*))
finally (*calculation: ‹eval_fps f z * eval_fps g z = eval_fps (f * g) z›*) show "?thesis"
(*goal: ‹eval_fps (f * g) z = eval_fps f z * eval_fps g z›*)
by standard
qed
lemma eval_fps_shift:
fixes f :: "'a :: {banach, real_normed_div_algebra, comm_ring_1} fps"
assumes "n ≤ subdegree f" "norm z < fps_conv_radius f"
shows "eval_fps (fps_shift n f) z = (if z = 0 then fps_nth f n else eval_fps f z / z ^ n)"
proof (cases "z = 0")
(*goals:
1. ‹(z::'a) = (0::'a) ⟹ eval_fps (fps_shift (n::nat) (f::'a fps)) z = (if z = (0::'a) then fps_nth f n else eval_fps f z / z ^ n)›
2. ‹(z::'a) ≠ (0::'a) ⟹ eval_fps (fps_shift (n::nat) (f::'a fps)) z = (if z = (0::'a) then fps_nth f n else eval_fps f z / z ^ n)›*)
case False (*‹(z::'a) ≠ (0::'a)›*)
have "eval_fps (fps_shift n f * fps_X ^ n) z = eval_fps (fps_shift n f) z * z ^ n"
using assms (*‹n ≤ subdegree f› ‹ereal (norm z) < fps_conv_radius f›*) apply (subst eval_fps_mult (*‹⟦ereal (norm (?z::?'a::{banach,real_normed_div_algebra,comm_ring_1})) < fps_conv_radius (?f::?'a::{banach,real_normed_div_algebra,comm_ring_1} fps); ereal (norm ?z) < fps_conv_radius (?g::?'a::{banach,real_normed_div_algebra,comm_ring_1} fps)⟧ ⟹ eval_fps (?f * ?g) ?z = eval_fps ?f ?z * eval_fps ?g ?z›*))
(*goals:
1. ‹⟦(n::nat) ≤ subdegree (f::'a fps); ereal (norm (z::'a)) < fps_conv_radius f⟧ ⟹ ereal (norm z) < fps_conv_radius (fps_shift n f)›
2. ‹⟦(n::nat) ≤ subdegree (f::'a fps); ereal (norm (z::'a)) < fps_conv_radius f⟧ ⟹ ereal (norm z) < fps_conv_radius (fps_X ^ n)›
3. ‹⟦(n::nat) ≤ subdegree (f::'a fps); ereal (norm (z::'a)) < fps_conv_radius f⟧ ⟹ eval_fps (fps_shift n f) z * eval_fps (fps_X ^ n) z = eval_fps (fps_shift n f) z * z ^ n›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*) .
also (*calculation: ‹eval_fps (fps_shift n f * fps_X ^ n) z = eval_fps (fps_shift n f) z * z ^ n›*) from assms (*‹n ≤ subdegree f› ‹ereal (norm z) < fps_conv_radius f›*) have "fps_shift n f * fps_X ^ n = f"
by (simp add: fps_shift_times_fps_X_power (*‹?n ≤ subdegree ?f ⟹ fps_shift ?n ?f * fps_X ^ ?n = ?f›*))
finally (*calculation: ‹eval_fps (f::'a fps) (z::'a) = eval_fps (fps_shift (n::nat) f) z * z ^ n›*) show "?thesis"
(*goal: ‹eval_fps (fps_shift n f) z = (if z = 0 then fps_nth f n else eval_fps f z / z ^ n)›*)
using False (*‹z ≠ 0›*) by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))
qed (simp_all add: eval_fps_at_0)
(*solved the remaining goal: ‹(z::'a) = (0::'a) ⟹ eval_fps (fps_shift (n::nat) (f::'a fps)) z = (if z = (0::'a) then fps_nth f n else eval_fps f z / z ^ n)›*)
lemma eval_fps_exp [simp]:
fixes c :: "'a :: {banach, real_normed_field}"
shows "eval_fps (fps_exp c) z = exp (c * z)" unfolding eval_fps_def exp_def
(*goal: ‹(∑n. fps_nth (fps_exp c) n * z ^ n) = (∑n. (c * z) ^ n /⇩R fact n)›*)
by (simp add: eval_fps_def (*‹eval_fps (?f::?'a fps) (?z::?'a) = (∑n::nat. fps_nth ?f n * ?z ^ n)›*) exp_def (*‹exp = (λx::?'a. ∑n::nat. x ^ n /⇩R fact n)›*) scaleR_conv_of_real (*‹(?r::real) *⇩R (?x::?'a) = of_real ?r * ?x›*) field_split_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 65 facts*))
text ‹
The case of division is more complicated and will therefore not be handled here.
Handling division becomes much more easy using complex analysis, and we will do so once
that is available.
›
subsection ‹Power series expansions of analytic functions›
text ‹
This predicate contains the notion that the given formal power series converges
in some disc of positive radius around the origin and is equal to the given complex
function there.
This relationship is unique in the sense that no complex function can have more than
one formal power series to which it expands, and if two holomorphic functions that are
holomorphic on a connected open set around the origin and have the same power series
expansion, they must be equal on that set.
More concrete statements about the radius of convergence can usually be made, but for
many purposes, the statment that the series converges to the function in some neighbourhood
of the origin is enough, and that can be shown almost fully automatically in most cases,
as there are straightforward introduction rules to show this.
In particular, when one wants to relate the coefficients of the power series to the
values of the derivatives of the function at the origin, or if one wants to approximate
the coefficients of the series with the singularities of the function, this predicate
is enough.
›
definition✐‹tag important›
has_fps_expansion :: "('a :: {banach,real_normed_div_algebra} ⇒ 'a) ⇒ 'a fps ⇒ bool"
(infixl "has'_fps'_expansion" 60)
where "(f has_fps_expansion F) ⟷
fps_conv_radius F > 0 ∧ eventually (λz. eval_fps F z = f z) (nhds 0)"
named_theorems fps_expansion_intros
lemma has_fps_expansion_schematicI:
"f has_fps_expansion A ⟹ A = B ⟹ f has_fps_expansion B"
by simp
lemma fps_nth_fps_expansion:
fixes f :: "complex ⇒ complex"
assumes "f has_fps_expansion F"
shows "fps_nth F n = (deriv ^^ n) f 0 / fact n"
proof (-)
(*goal: ‹fps_nth F n = (deriv ^^ n) f 0 / fact n›*)
have "fps_nth F n = (deriv ^^ n) (eval_fps F) 0 / fact n"
using assms (*‹f has_fps_expansion F›*) apply (intro fps_nth_conv_deriv (*‹(0::ereal) < fps_conv_radius (?f::complex fps) ⟹ fps_nth ?f (?n::nat) = (deriv ^^ ?n) (eval_fps ?f) (0::complex) / fact ?n›*))
(*goal: ‹fps_nth F n = (deriv ^^ n) (eval_fps F) 0 / fact n›*)
by (auto simp: has_fps_expansion_def (*‹(?f::?'a::{banach,real_normed_div_algebra} ⇒ ?'a::{banach,real_normed_div_algebra}) has_fps_expansion (?F::?'a::{banach,real_normed_div_algebra} fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a::{banach,real_normed_div_algebra} in nhds (0::?'a::{banach,real_normed_div_algebra}). eval_fps ?F z = ?f z))›*))
also (*calculation: ‹fps_nth (F::complex fps) (n::nat) = (deriv ^^ n) (eval_fps F) (0::complex) / fact n›*) have "(deriv ^^ n) (eval_fps F) 0 = (deriv ^^ n) f 0"
using assms (*‹(f::complex ⇒ complex) has_fps_expansion (F::complex fps)›*) apply (intro higher_deriv_cong_ev (*‹⟦∀⇩F x in nhds ?x. ?f x = ?g x; ?x = ?y⟧ ⟹ (deriv ^^ ?n) ?f ?x = (deriv ^^ ?n) ?g ?y›*))
(*goals:
1. ‹f has_fps_expansion F ⟹ ∀⇩F x in nhds 0. eval_fps F x = f x›
2. ‹f has_fps_expansion F ⟹ 0 = 0›
discuss goal 1*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))[1])
(*discuss goal 2*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))[1])
(*proven 2 subgoals*) .
finally (*calculation: ‹fps_nth F n = (deriv ^^ n) f 0 / fact n›*) show "?thesis"
(*goal: ‹fps_nth F n = (deriv ^^ n) f 0 / fact n›*) .
qed
lemma has_fps_expansion_imp_continuous:
fixes F :: "'a::{real_normed_field,banach} fps"
assumes "f has_fps_expansion F"
shows "continuous (at 0 within A) f"
proof (-)
(*goal: ‹continuous (at 0 within A) f›*)
from assms (*‹f has_fps_expansion F›*) have "isCont (eval_fps F) 0"
apply (intro continuous_eval_fps (*‹ereal (norm (?z::?'a::{banach,real_normed_field})) < fps_conv_radius (?F::?'a::{banach,real_normed_field} fps) ⟹ continuous (at ?z within (?A::?'a::{banach,real_normed_field} set)) (eval_fps ?F)›*))
(*goal: ‹isCont (eval_fps (F::'a::{banach,real_normed_field} fps)) (0::'a::{banach,real_normed_field})›*)
by (auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))
also (*calculation: ‹isCont (eval_fps F) 0›*) have "?this ⟷ isCont f 0"
using assms (*‹f has_fps_expansion F›*) apply (intro isCont_cong (*‹∀⇩F x in nhds ?x. ?f x = ?g x ⟹ isCont ?f ?x = isCont ?g ?x›*))
(*goal: ‹isCont (eval_fps F) 0 = isCont f 0›*)
by (auto simp: has_fps_expansion_def (*‹(?f::?'a::{banach,real_normed_div_algebra} ⇒ ?'a::{banach,real_normed_div_algebra}) has_fps_expansion (?F::?'a::{banach,real_normed_div_algebra} fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a::{banach,real_normed_div_algebra} in nhds (0::?'a::{banach,real_normed_div_algebra}). eval_fps ?F z = ?f z))›*))
finally (*calculation: ‹isCont f 0›*) have "isCont f 0" .
thus "continuous (at 0 within A) f"
by (simp add: continuous_at_imp_continuous_within (*‹isCont ?f ?x ⟹ continuous (at ?x within ?s) ?f›*))
qed
lemma has_fps_expansion_const [simp, intro, fps_expansion_intros]:
"(λ_. c) has_fps_expansion fps_const c"
by (auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))
lemma has_fps_expansion_0 [simp, intro, fps_expansion_intros]:
"(λ_. 0) has_fps_expansion 0"
by (auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))
lemma has_fps_expansion_1 [simp, intro, fps_expansion_intros]:
"(λ_. 1) has_fps_expansion 1"
by (auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))
lemma has_fps_expansion_numeral [simp, intro, fps_expansion_intros]:
"(λ_. numeral n) has_fps_expansion numeral n"
by (auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))
lemma has_fps_expansion_fps_X_power [fps_expansion_intros]:
"(λx. x ^ n) has_fps_expansion (fps_X ^ n)"
by (auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))
lemma has_fps_expansion_fps_X [fps_expansion_intros]:
"(λx. x) has_fps_expansion fps_X"
by (auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))
lemma has_fps_expansion_cmult_left [fps_expansion_intros]:
fixes c :: "'a :: {banach, real_normed_div_algebra, comm_ring_1}"
assumes "f has_fps_expansion F"
shows "(λx. c * f x) has_fps_expansion fps_const c * F"
proof (cases "c = 0")
(*goals:
1. ‹c = 0 ⟹ (λx. c * f x) has_fps_expansion fps_const c * F›
2. ‹c ≠ 0 ⟹ (λx. c * f x) has_fps_expansion fps_const c * F›*)
case False (*‹c ≠ 0›*)
from assms (*‹f has_fps_expansion F›*) have "eventually (λz. z ∈ eball 0 (fps_conv_radius F)) (nhds 0)"
apply (intro eventually_nhds_in_open (*‹⟦open ?s; ?x ∈ ?s⟧ ⟹ ∀⇩F y in nhds ?x. y ∈ ?s›*))
(*goals:
1. ‹f has_fps_expansion F ⟹ open (eball 0 (fps_conv_radius F))›
2. ‹f has_fps_expansion F ⟹ 0 ∈ eball 0 (fps_conv_radius F)›
discuss goal 1*)
apply ((auto simp: has_fps_expansion_def (*‹(?f::?'a::{banach,real_normed_div_algebra} ⇒ ?'a::{banach,real_normed_div_algebra}) has_fps_expansion (?F::?'a::{banach,real_normed_div_algebra} fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a::{banach,real_normed_div_algebra} in nhds (0::?'a::{banach,real_normed_div_algebra}). eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹(0::ereal) = ereal (0::real)›*))[1])
(*discuss goal 2*)
apply ((auto simp: has_fps_expansion_def (*‹(?f::?'a ⇒ ?'a) has_fps_expansion (?F::?'a fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a in nhds (0::?'a). eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹(0::ereal) = ereal (0::real)›*))[1])
(*proven 2 subgoals*) .
moreover from assms (*‹f has_fps_expansion F›*) have "eventually (λz. eval_fps F z = f z) (nhds 0)"
by (auto simp: has_fps_expansion_def (*‹(?f::?'a ⇒ ?'a) has_fps_expansion (?F::?'a fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a in nhds (0::?'a). eval_fps ?F z = ?f z))›*))
ultimately have "eventually (λz. eval_fps (fps_const c * F) z = c * f z) (nhds 0)"
apply eventually_elim
(*goal: ‹∀⇩F z in nhds 0. eval_fps (fps_const c * F) z = c * f z›*)
by (simp add: eval_fps_mult (*‹⟦ereal (norm ?z) < fps_conv_radius ?f; ereal (norm ?z) < fps_conv_radius ?g⟧ ⟹ eval_fps (?f * ?g) ?z = eval_fps ?f ?z * eval_fps ?g ?z›*))
with assms (*‹f has_fps_expansion F›*) False (*‹(c::'a::{banach,real_normed_div_algebra,comm_ring_1}) ≠ (0::'a::{banach,real_normed_div_algebra,comm_ring_1})›*) show "?thesis"
(*goal: ‹(λx. c * f x) has_fps_expansion fps_const c * F›*)
by (auto simp: has_fps_expansion_def (*‹(?f::?'a::{banach,real_normed_div_algebra} ⇒ ?'a::{banach,real_normed_div_algebra}) has_fps_expansion (?F::?'a::{banach,real_normed_div_algebra} fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a::{banach,real_normed_div_algebra} in nhds (0::?'a::{banach,real_normed_div_algebra}). eval_fps ?F z = ?f z))›*) fps_conv_radius_cmult_left (*‹(?c::?'a::{banach,real_normed_div_algebra}) ≠ (0::?'a::{banach,real_normed_div_algebra}) ⟹ fps_conv_radius (fps_const ?c * (?f::?'a::{banach,real_normed_div_algebra} fps)) = fps_conv_radius ?f›*))
qed (auto)
(*solved the remaining goal: ‹c = 0 ⟹ (λx. c * f x) has_fps_expansion fps_const c * F›*)
lemma has_fps_expansion_cmult_right [fps_expansion_intros]:
fixes c :: "'a :: {banach, real_normed_div_algebra, comm_ring_1}"
assumes "f has_fps_expansion F"
shows "(λx. f x * c) has_fps_expansion F * fps_const c"
proof (-)
(*goal: ‹(λx. f x * c) has_fps_expansion F * fps_const c›*)
have "F * fps_const c = fps_const c * F"
apply (intro fps_ext (*‹(⋀n. fps_nth ?p n = fps_nth ?q n) ⟹ ?p = ?q›*))
(*goal: ‹F * fps_const c = fps_const c * F›*)
by (auto simp: mult.commute (*‹?a * ?b = ?b * ?a›*))
with has_fps_expansion_cmult_left[OF assms] (*‹(λx. ?c * f x) has_fps_expansion fps_const ?c * F›*) show "?thesis"
(*goal: ‹(λx::'a. (f::'a ⇒ 'a) x * (c::'a)) has_fps_expansion (F::'a fps) * fps_const c›*)
by (simp add: mult.commute (*‹(?a::?'a) * (?b::?'a) = ?b * ?a›*))
qed
lemma has_fps_expansion_minus [fps_expansion_intros]:
assumes "f has_fps_expansion F"
shows "(λx. - f x) has_fps_expansion -F"
proof (-)
(*goal: ‹(λx. - f x) has_fps_expansion - F›*)
from assms (*‹f has_fps_expansion F›*) have "eventually (λx. x ∈ eball 0 (fps_conv_radius F)) (nhds 0)"
apply (intro eventually_nhds_in_open (*‹⟦open ?s; ?x ∈ ?s⟧ ⟹ ∀⇩F y in nhds ?x. y ∈ ?s›*))
(*goals:
1. ‹f has_fps_expansion F ⟹ open (eball 0 (fps_conv_radius F))›
2. ‹f has_fps_expansion F ⟹ 0 ∈ eball 0 (fps_conv_radius F)›
discuss goal 1*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))[1])
(*discuss goal 2*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))[1])
(*proven 2 subgoals*) .
moreover from assms (*‹f has_fps_expansion F›*) have "eventually (λx. eval_fps F x = f x) (nhds 0)"
by (auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))
ultimately have "eventually (λx. eval_fps (-F) x = -f x) (nhds 0)"
apply eventually_elim
(*goal: ‹∀⇩F x::'a in nhds (0::'a). eval_fps (- (F::'a fps)) x = - (f::'a ⇒ 'a) x›*)
by (auto simp: eval_fps_minus (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ eval_fps (- ?f) ?z = - eval_fps ?f ?z›*))
thus "?thesis"
(*goal: ‹(λx. - f x) has_fps_expansion - F›*)
using assms (*‹f has_fps_expansion F›*) by (auto simp: has_fps_expansion_def (*‹(?f::?'a ⇒ ?'a) has_fps_expansion (?F::?'a fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a in nhds (0::?'a). eval_fps ?F z = ?f z))›*))
qed
lemma has_fps_expansion_add [fps_expansion_intros]:
assumes "f has_fps_expansion F" "g has_fps_expansion G"
shows "(λx. f x + g x) has_fps_expansion F + G"
proof (-)
(*goal: ‹(λx. f x + g x) has_fps_expansion F + G›*)
from assms (*‹f has_fps_expansion F› ‹g has_fps_expansion G›*) have "0 < min (fps_conv_radius F) (fps_conv_radius G)"
by (auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))
also (*calculation: ‹0 < min (fps_conv_radius F) (fps_conv_radius G)›*) have "… ≤ fps_conv_radius (F + G)"
by (rule fps_conv_radius_add (*‹min (fps_conv_radius ?f) (fps_conv_radius ?g) ≤ fps_conv_radius (?f + ?g)›*))
finally (*calculation: ‹0 < fps_conv_radius (F + G)›*) have radius: "… > 0" .
from assms (*‹f has_fps_expansion F› ‹g has_fps_expansion G›*) have "eventually (λx. x ∈ eball 0 (fps_conv_radius F)) (nhds 0)" "eventually (λx. x ∈ eball 0 (fps_conv_radius G)) (nhds 0)"
apply -
(*goals:
1. ‹⟦f has_fps_expansion F; g has_fps_expansion G⟧ ⟹ ∀⇩F x in nhds 0. x ∈ eball 0 (fps_conv_radius F)›
2. ‹⟦f has_fps_expansion F; g has_fps_expansion G⟧ ⟹ ∀⇩F x in nhds 0. x ∈ eball 0 (fps_conv_radius G)›
discuss goal 1*)
apply (intro eventually_nhds_in_open (*‹⟦open ?s; ?x ∈ ?s⟧ ⟹ ∀⇩F y in nhds ?x. y ∈ ?s›*))
(*goals:
1. ‹⟦f has_fps_expansion F; g has_fps_expansion G⟧ ⟹ open (eball 0 (fps_conv_radius F))›
2. ‹⟦f has_fps_expansion F; g has_fps_expansion G⟧ ⟹ 0 ∈ eball 0 (fps_conv_radius F)›
discuss goal 1*)
apply (force simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))
(*discuss goal 2*)
apply (force simp: has_fps_expansion_def (*‹(?f::?'a ⇒ ?'a) has_fps_expansion (?F::?'a fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a in nhds (0::?'a). eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹(0::ereal) = ereal (0::real)›*))
(*proven 2 subgoals*)
(*discuss goal 2*)
apply (intro eventually_nhds_in_open (*‹⟦open ?s; ?x ∈ ?s⟧ ⟹ ∀⇩F y in nhds ?x. y ∈ ?s›*))
(*goals:
1. ‹⟦f has_fps_expansion F; g has_fps_expansion G⟧ ⟹ open (eball 0 (fps_conv_radius G))›
2. ‹⟦f has_fps_expansion F; g has_fps_expansion G⟧ ⟹ 0 ∈ eball 0 (fps_conv_radius G)›
discuss goal 1*)
apply (force simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))
(*discuss goal 2*)
apply (force simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
moreover have "eventually (λx. eval_fps F x = f x) (nhds 0)" and "eventually (λx. eval_fps G x = g x) (nhds 0)"
using assms (*‹f has_fps_expansion F› ‹g has_fps_expansion G›*) apply -
(*goals:
1. ‹⟦f has_fps_expansion F; g has_fps_expansion G⟧ ⟹ ∀⇩F x in nhds 0. eval_fps F x = f x›
2. ‹⟦f has_fps_expansion F; g has_fps_expansion G⟧ ⟹ ∀⇩F x in nhds 0. eval_fps G x = g x›
discuss goal 1*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))[1])
(*discuss goal 2*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))[1])
(*proven 2 subgoals*) .
ultimately have "eventually (λx. eval_fps (F + G) x = f x + g x) (nhds 0)"
apply eventually_elim
(*goal: ‹∀⇩F x::'a::{banach,real_normed_div_algebra} in nhds (0::'a::{banach,real_normed_div_algebra}). eval_fps ((F::'a::{banach,real_normed_div_algebra} fps) + (G::'a::{banach,real_normed_div_algebra} fps)) x = (f::'a::{banach,real_normed_div_algebra} ⇒ 'a::{banach,real_normed_div_algebra}) x + (g::'a::{banach,real_normed_div_algebra} ⇒ 'a::{banach,real_normed_div_algebra}) x›*)
by (auto simp: eval_fps_add (*‹⟦ereal (norm ?z) < fps_conv_radius ?f; ereal (norm ?z) < fps_conv_radius ?g⟧ ⟹ eval_fps (?f + ?g) ?z = eval_fps ?f ?z + eval_fps ?g ?z›*))
with radius (*‹0 < fps_conv_radius (F + G)›*) show "?thesis"
(*goal: ‹(λx. f x + g x) has_fps_expansion F + G›*)
by (auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))
qed
lemma has_fps_expansion_diff [fps_expansion_intros]:
assumes "f has_fps_expansion F" "g has_fps_expansion G"
shows "(λx. f x - g x) has_fps_expansion F - G"
using has_fps_expansion_add[of f F "λx. - g x" "-G"] (*‹⟦f has_fps_expansion F; (λx. - g x) has_fps_expansion - G⟧ ⟹ (λx. f x + - g x) has_fps_expansion F + - G›*) assms (*‹f has_fps_expansion F› ‹g has_fps_expansion G›*) by (simp add: has_fps_expansion_minus (*‹(?f::?'a ⇒ ?'a) has_fps_expansion (?F::?'a fps) ⟹ (λx::?'a. - ?f x) has_fps_expansion - ?F›*))
lemma has_fps_expansion_mult [fps_expansion_intros]:
fixes F G :: "'a :: {banach, real_normed_div_algebra, comm_ring_1} fps"
assumes "f has_fps_expansion F" "g has_fps_expansion G"
shows "(λx. f x * g x) has_fps_expansion F * G"
proof (-)
(*goal: ‹(λx. f x * g x) has_fps_expansion F * G›*)
from assms (*‹f has_fps_expansion F› ‹g has_fps_expansion G›*) have "0 < min (fps_conv_radius F) (fps_conv_radius G)"
by (auto simp: has_fps_expansion_def (*‹(?f::?'a ⇒ ?'a) has_fps_expansion (?F::?'a fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a in nhds (0::?'a). eval_fps ?F z = ?f z))›*))
also (*calculation: ‹(0::ereal) < min (fps_conv_radius (F::'a fps)) (fps_conv_radius (G::'a fps))›*) have "… ≤ fps_conv_radius (F * G)"
by (rule fps_conv_radius_mult (*‹min (fps_conv_radius ?f) (fps_conv_radius ?g) ≤ fps_conv_radius (?f * ?g)›*))
finally (*calculation: ‹0 < fps_conv_radius (F * G)›*) have radius: "… > 0" .
from assms (*‹f has_fps_expansion F› ‹g has_fps_expansion G›*) have "eventually (λx. x ∈ eball 0 (fps_conv_radius F)) (nhds 0)" "eventually (λx. x ∈ eball 0 (fps_conv_radius G)) (nhds 0)"
apply -
(*goals:
1. ‹⟦f has_fps_expansion F; g has_fps_expansion G⟧ ⟹ ∀⇩F x in nhds 0. x ∈ eball 0 (fps_conv_radius F)›
2. ‹⟦f has_fps_expansion F; g has_fps_expansion G⟧ ⟹ ∀⇩F x in nhds 0. x ∈ eball 0 (fps_conv_radius G)›
discuss goal 1*)
apply (intro eventually_nhds_in_open (*‹⟦open ?s; ?x ∈ ?s⟧ ⟹ ∀⇩F y in nhds ?x. y ∈ ?s›*))
(*goals:
1. ‹⟦(f::'a ⇒ 'a) has_fps_expansion (F::'a fps); (g::'a ⇒ 'a) has_fps_expansion (G::'a fps)⟧ ⟹ open (eball (0::'b) (fps_conv_radius F))›
2. ‹⟦(f::'a ⇒ 'a) has_fps_expansion (F::'a fps); (g::'a ⇒ 'a) has_fps_expansion (G::'a fps)⟧ ⟹ (0::'b) ∈ eball (0::'b) (fps_conv_radius F)›
discuss goal 1*)
apply (force simp: has_fps_expansion_def (*‹(?f::?'a ⇒ ?'a) has_fps_expansion (?F::?'a fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a in nhds (0::?'a). eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹(0::ereal) = ereal (0::real)›*))
(*discuss goal 2*)
apply (force simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))
(*proven 2 subgoals*)
(*discuss goal 2*)
apply (intro eventually_nhds_in_open (*‹⟦open ?s; ?x ∈ ?s⟧ ⟹ ∀⇩F y in nhds ?x. y ∈ ?s›*))
(*goals:
1. ‹⟦f has_fps_expansion F; g has_fps_expansion G⟧ ⟹ open (eball 0 (fps_conv_radius G))›
2. ‹⟦f has_fps_expansion F; g has_fps_expansion G⟧ ⟹ 0 ∈ eball 0 (fps_conv_radius G)›
discuss goal 1*)
apply (force simp: has_fps_expansion_def (*‹(?f::?'a ⇒ ?'a) has_fps_expansion (?F::?'a fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a in nhds (0::?'a). eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹(0::ereal) = ereal (0::real)›*))
(*discuss goal 2*)
apply (force simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
moreover have "eventually (λx. eval_fps F x = f x) (nhds 0)" and "eventually (λx. eval_fps G x = g x) (nhds 0)"
using assms (*‹(f::'a ⇒ 'a) has_fps_expansion (F::'a fps)› ‹g has_fps_expansion G›*) apply -
(*goals:
1. ‹⟦f has_fps_expansion F; g has_fps_expansion G⟧ ⟹ ∀⇩F x in nhds 0. eval_fps F x = f x›
2. ‹⟦f has_fps_expansion F; g has_fps_expansion G⟧ ⟹ ∀⇩F x in nhds 0. eval_fps G x = g x›
discuss goal 1*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))[1])
(*discuss goal 2*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))[1])
(*proven 2 subgoals*) .
ultimately have "eventually (λx. eval_fps (F * G) x = f x * g x) (nhds 0)"
apply eventually_elim
(*goal: ‹∀⇩F x in nhds 0. eval_fps (F * G) x = f x * g x›*)
by (auto simp: eval_fps_mult (*‹⟦ereal (norm ?z) < fps_conv_radius ?f; ereal (norm ?z) < fps_conv_radius ?g⟧ ⟹ eval_fps (?f * ?g) ?z = eval_fps ?f ?z * eval_fps ?g ?z›*))
with radius (*‹0 < fps_conv_radius (F * G)›*) show "?thesis"
(*goal: ‹(λx::'a. (f::'a ⇒ 'a) x * (g::'a ⇒ 'a) x) has_fps_expansion (F::'a fps) * (G::'a fps)›*)
by (auto simp: has_fps_expansion_def (*‹(?f::?'a::{banach,real_normed_div_algebra} ⇒ ?'a::{banach,real_normed_div_algebra}) has_fps_expansion (?F::?'a::{banach,real_normed_div_algebra} fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a::{banach,real_normed_div_algebra} in nhds (0::?'a::{banach,real_normed_div_algebra}). eval_fps ?F z = ?f z))›*))
qed
lemma has_fps_expansion_inverse [fps_expansion_intros]:
fixes F :: "'a :: {banach, real_normed_field} fps"
assumes "f has_fps_expansion F"
assumes "fps_nth F 0 ≠ 0"
shows "(λx. inverse (f x)) has_fps_expansion inverse F"
proof (-)
(*goal: ‹(λx. inverse (f x)) has_fps_expansion inverse F›*)
have radius: "fps_conv_radius (inverse F) > 0"
using assms (*‹f has_fps_expansion F› ‹fps_nth F 0 ≠ 0›*) unfolding has_fps_expansion_def
(*goal: ‹0 < fps_conv_radius (inverse F)›*)
apply (intro fps_conv_radius_inverse_pos (*‹⟦fps_nth ?f 0 ≠ 0; 0 < fps_conv_radius ?f⟧ ⟹ 0 < fps_conv_radius (inverse ?f)›*))
(*goals:
1. ‹⟦0 < fps_conv_radius F ∧ (∀⇩F z in nhds 0. eval_fps F z = f z); fps_nth F 0 ≠ 0⟧ ⟹ fps_nth F 0 ≠ 0›
2. ‹⟦0 < fps_conv_radius F ∧ (∀⇩F z in nhds 0. eval_fps F z = f z); fps_nth F 0 ≠ 0⟧ ⟹ 0 < fps_conv_radius F›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
let ?R = "min (fps_conv_radius F) (fps_conv_radius (inverse F))"
from assms (*‹(f::'a ⇒ 'a) has_fps_expansion (F::'a fps)› ‹fps_nth F 0 ≠ 0›*) radius (*‹(0::ereal) < fps_conv_radius (inverse (F::'a fps))›*) have "eventually (λx. x ∈ eball 0 (fps_conv_radius F)) (nhds 0)" "eventually (λx. x ∈ eball 0 (fps_conv_radius (inverse F))) (nhds 0)"
apply -
(*goals:
1. ‹⟦f has_fps_expansion F; fps_nth F 0 ≠ 0; 0 < fps_conv_radius (inverse F)⟧ ⟹ ∀⇩F x in nhds 0. x ∈ eball 0 (fps_conv_radius F)›
2. ‹⟦f has_fps_expansion F; fps_nth F 0 ≠ 0; 0 < fps_conv_radius (inverse F)⟧ ⟹ ∀⇩F x in nhds 0. x ∈ eball 0 (fps_conv_radius (inverse F))›
discuss goal 1*)
apply (intro eventually_nhds_in_open (*‹⟦open ?s; ?x ∈ ?s⟧ ⟹ ∀⇩F y in nhds ?x. y ∈ ?s›*))
(*goals:
1. ‹⟦(f::'a ⇒ 'a) has_fps_expansion (F::'a fps); fps_nth F (0::nat) ≠ (0::'a); (0::ereal) < fps_conv_radius (inverse F)⟧ ⟹ open (eball (0::'b) (fps_conv_radius F))›
2. ‹⟦(f::'a ⇒ 'a) has_fps_expansion (F::'a fps); fps_nth F (0::nat) ≠ (0::'a); (0::ereal) < fps_conv_radius (inverse F)⟧ ⟹ (0::'b) ∈ eball (0::'b) (fps_conv_radius F)›
discuss goal 1*)
apply (force simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))
(*discuss goal 2*)
apply (force simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))
(*proven 2 subgoals*)
(*discuss goal 2*)
apply (intro eventually_nhds_in_open (*‹⟦open ?s; ?x ∈ ?s⟧ ⟹ ∀⇩F y in nhds ?x. y ∈ ?s›*))
(*goals:
1. ‹⟦(f::'a ⇒ 'a) has_fps_expansion (F::'a fps); fps_nth F (0::nat) ≠ (0::'a); (0::ereal) < fps_conv_radius (inverse F)⟧ ⟹ open (eball (0::'c) (fps_conv_radius (inverse F)))›
2. ‹⟦(f::'a ⇒ 'a) has_fps_expansion (F::'a fps); fps_nth F (0::nat) ≠ (0::'a); (0::ereal) < fps_conv_radius (inverse F)⟧ ⟹ (0::'c) ∈ eball (0::'c) (fps_conv_radius (inverse F))›
discuss goal 1*)
apply (force simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))
(*discuss goal 2*)
apply (force simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
moreover have "eventually (λz. eval_fps F z = f z) (nhds 0)"
using assms (*‹f has_fps_expansion F› ‹fps_nth F 0 ≠ 0›*) by (auto simp: has_fps_expansion_def (*‹(?f::?'a::{banach,real_normed_div_algebra} ⇒ ?'a::{banach,real_normed_div_algebra}) has_fps_expansion (?F::?'a::{banach,real_normed_div_algebra} fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a::{banach,real_normed_div_algebra} in nhds (0::?'a::{banach,real_normed_div_algebra}). eval_fps ?F z = ?f z))›*))
ultimately have "eventually (λz. eval_fps (inverse F) z = inverse (f z)) (nhds 0)"
proof (eventually_elim)
(*goal: ‹⋀z::'a. ⟦z ∈ eball (0::'a) (fps_conv_radius (F::'a fps)); z ∈ eball (0::'a) (fps_conv_radius (inverse F)); eval_fps F z = (f::'a ⇒ 'a) z⟧ ⟹ eval_fps (inverse F) z = inverse (f z)›*)
case (elim z) (*‹z ∈ eball 0 (fps_conv_radius F)› ‹z ∈ eball 0 (fps_conv_radius (inverse F))› ‹eval_fps F z = f z›*)
hence "eval_fps (inverse F * F) z = eval_fps (inverse F) z * f z"
apply (subst eval_fps_mult (*‹⟦ereal (norm ?z) < fps_conv_radius ?f; ereal (norm ?z) < fps_conv_radius ?g⟧ ⟹ eval_fps (?f * ?g) ?z = eval_fps ?f ?z * eval_fps ?g ?z›*))
(*goals:
1. ‹⟦z ∈ eball 0 (fps_conv_radius F); z ∈ eball 0 (fps_conv_radius (inverse F)); eval_fps F z = f z⟧ ⟹ ereal (norm z) < fps_conv_radius (inverse F)›
2. ‹⟦z ∈ eball 0 (fps_conv_radius F); z ∈ eball 0 (fps_conv_radius (inverse F)); eval_fps F z = f z⟧ ⟹ ereal (norm z) < fps_conv_radius F›
3. ‹⟦z ∈ eball 0 (fps_conv_radius F); z ∈ eball 0 (fps_conv_radius (inverse F)); eval_fps F z = f z⟧ ⟹ eval_fps (inverse F) z * eval_fps F z = eval_fps (inverse F) z * f z›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
also (*calculation: ‹eval_fps (inverse (F::'a::{banach,real_normed_field} fps) * F) (z::'a::{banach,real_normed_field}) = eval_fps (inverse F) z * (f::'a::{banach,real_normed_field} ⇒ 'a::{banach,real_normed_field}) z›*) have "eval_fps (inverse F * F) z = 1"
using assms (*‹f has_fps_expansion F› ‹fps_nth F 0 ≠ 0›*) by (simp add: inverse_mult_eq_1 (*‹fps_nth ?f 0 ≠ 0 ⟹ inverse ?f * ?f = 1›*))
finally (*calculation: ‹1 = eval_fps (inverse F) z * f z›*) show "?case"
(*goal: ‹eval_fps (inverse F) z = inverse (f z)›*)
by (auto simp: field_split_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 65 facts*))
qed
with radius (*‹0 < fps_conv_radius (inverse F)›*) show "?thesis"
(*goal: ‹(λx. inverse (f x)) has_fps_expansion inverse F›*)
by (auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))
qed
lemma has_fps_expansion_exp [fps_expansion_intros]:
fixes c :: "'a :: {banach, real_normed_field}"
shows "(λx. exp (c * x)) has_fps_expansion fps_exp c"
by (auto simp: has_fps_expansion_def (*‹(?f::?'a ⇒ ?'a) has_fps_expansion (?F::?'a fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a in nhds (0::?'a). eval_fps ?F z = ?f z))›*))
lemma has_fps_expansion_exp1 [fps_expansion_intros]:
"(λx::'a :: {banach, real_normed_field}. exp x) has_fps_expansion fps_exp 1"
using has_fps_expansion_exp[of 1] (*‹(λx. exp (1 * x)) has_fps_expansion fps_exp 1›*) by simp
lemma has_fps_expansion_exp_neg1 [fps_expansion_intros]:
"(λx::'a :: {banach, real_normed_field}. exp (-x)) has_fps_expansion fps_exp (-1)"
using has_fps_expansion_exp[of "-1"] (*‹(λx. exp (- 1 * x)) has_fps_expansion fps_exp (- 1)›*) by simp
lemma has_fps_expansion_deriv [fps_expansion_intros]:
assumes "f has_fps_expansion F"
shows "deriv f has_fps_expansion fps_deriv F"
proof (-)
(*goal: ‹deriv f has_fps_expansion fps_deriv F›*)
have "eventually (λz. z ∈ eball 0 (fps_conv_radius F)) (nhds 0)"
using assms (*‹(f::'a ⇒ 'a) has_fps_expansion (F::'a fps)›*) apply (intro eventually_nhds_in_open (*‹⟦open (?s::?'a set); (?x::?'a) ∈ ?s⟧ ⟹ ∀⇩F y::?'a in nhds ?x. y ∈ ?s›*))
(*goals:
1. ‹f has_fps_expansion F ⟹ open (eball 0 (fps_conv_radius F))›
2. ‹f has_fps_expansion F ⟹ 0 ∈ eball 0 (fps_conv_radius F)›
discuss goal 1*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))[1])
(*discuss goal 2*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))[1])
(*proven 2 subgoals*) .
moreover from assms (*‹f has_fps_expansion F›*) have "eventually (λz. eval_fps F z = f z) (nhds 0)"
by (auto simp: has_fps_expansion_def (*‹(?f::?'a::{banach,real_normed_div_algebra} ⇒ ?'a::{banach,real_normed_div_algebra}) has_fps_expansion (?F::?'a::{banach,real_normed_div_algebra} fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a::{banach,real_normed_div_algebra} in nhds (0::?'a::{banach,real_normed_div_algebra}). eval_fps ?F z = ?f z))›*))
then obtain s where "open s" "0 ∈ s" and s: "⋀w. w ∈ s ⟹ eval_fps F w = f w"
(*goal: ‹(⋀s. ⟦open s; 0 ∈ s; ⋀w. w ∈ s ⟹ eval_fps F w = f w⟧ ⟹ thesis) ⟹ thesis›*)
by (auto simp: eventually_nhds (*‹eventually (?P::?'a::topological_space ⇒ bool) (nhds (?a::?'a::topological_space)) = (∃S::?'a::topological_space set. open S ∧ ?a ∈ S ∧ (∀x::?'a::topological_space∈S. ?P x))›*))
hence "eventually (λw. w ∈ s) (nhds 0)"
apply (intro eventually_nhds_in_open (*‹⟦open ?s; ?x ∈ ?s⟧ ⟹ ∀⇩F y in nhds ?x. y ∈ ?s›*))
(*goals:
1. ‹⟦open s; 0 ∈ s; ⋀w. w ∈ s ⟹ eval_fps F w = f w⟧ ⟹ open s›
2. ‹⟦open s; 0 ∈ s; ⋀w. w ∈ s ⟹ eval_fps F w = f w⟧ ⟹ 0 ∈ s›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
ultimately have "eventually (λz. eval_fps (fps_deriv F) z = deriv f z) (nhds 0)"
proof (eventually_elim)
(*goal: ‹⋀z. ⟦z ∈ eball 0 (fps_conv_radius F); z ∈ s⟧ ⟹ eval_fps (fps_deriv F) z = deriv f z›*)
case (elim z) (*‹z ∈ eball 0 (fps_conv_radius F)› ‹(z::'a::{banach,real_normed_field}) ∈ (s::'a::{banach,real_normed_field} set)›*)
hence "eval_fps (fps_deriv F) z = deriv (eval_fps F) z"
by (simp add: eval_fps_deriv (*‹ereal (norm ?z) < fps_conv_radius ?f ⟹ eval_fps (fps_deriv ?f) ?z = deriv (eval_fps ?f) ?z›*))
also (*calculation: ‹eval_fps (fps_deriv F) z = deriv (eval_fps F) z›*) have "eventually (λw. w ∈ s) (nhds z)"
using elim (*‹(z::'a) ∈ eball (0::'a) (fps_conv_radius (F::'a fps))› ‹(z::'a) ∈ (s::'a set)›*) ‹open s› (*‹open (s::'a::{banach,real_normed_field} set)›*) apply (intro eventually_nhds_in_open (*‹⟦open (?s::?'a::topological_space set); (?x::?'a::topological_space) ∈ ?s⟧ ⟹ ∀⇩F y::?'a::topological_space in nhds ?x. y ∈ ?s›*))
(*goals:
1. ‹⟦(z::'a) ∈ eball (0::'a) (fps_conv_radius (F::'a fps)); z ∈ (s::'a set); open s⟧ ⟹ open s›
2. ‹⟦(z::'a) ∈ eball (0::'a) (fps_conv_radius (F::'a fps)); z ∈ (s::'a set); open s⟧ ⟹ z ∈ s›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
hence "eventually (λw. eval_fps F w = f w) (nhds z)"
apply eventually_elim
(*goal: ‹∀⇩F w in nhds z. eval_fps F w = f w›*)
by (simp add: s (*‹?w1 ∈ s ⟹ eval_fps F ?w1 = f ?w1›*))
hence "deriv (eval_fps F) z = deriv f z"
by (intro deriv_cong_ev (*‹⟦∀⇩F x::?'a in nhds (?x::?'a). (?f::?'a ⇒ ?'a) x = (?g::?'a ⇒ ?'a) x; ?x = (?y::?'a)⟧ ⟹ deriv ?f ?x = deriv ?g ?y›*) refl (*‹(?t::?'a) = ?t›*))
finally (*calculation: ‹eval_fps (fps_deriv F) z = deriv f z›*) show "?case"
(*goal: ‹eval_fps (fps_deriv F) z = deriv f z›*) .
qed
with assms (*‹f has_fps_expansion F›*) fps_conv_radius_deriv[of F] (*‹fps_conv_radius F ≤ fps_conv_radius (fps_deriv F)›*) show "?thesis"
(*goal: ‹deriv f has_fps_expansion fps_deriv F›*)
by (auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))
qed
lemma fps_conv_radius_binomial:
fixes c :: "'a :: {real_normed_field,banach}"
shows "fps_conv_radius (fps_binomial c) = (if c ∈ ℕ then ∞ else 1)"
unfolding fps_conv_radius_def
(*goal: ‹conv_radius (fps_nth (fps_binomial (c::'a))) = (if c ∈ ℕ then ∞ else (1::ereal))›*)
by (simp add: conv_radius_gchoose (*‹conv_radius ((gchoose) ?a) = (if ?a ∈ ℕ then ∞ else 1)›*))
lemma fps_conv_radius_ln:
fixes c :: "'a :: {banach, real_normed_field, field_char_0}"
shows "fps_conv_radius (fps_ln c) = (if c = 0 then ∞ else 1)"
proof (cases "c = 0")
(*goals:
1. ‹c = 0 ⟹ fps_conv_radius (fps_ln c) = (if c = 0 then ∞ else 1)›
2. ‹c ≠ 0 ⟹ fps_conv_radius (fps_ln c) = (if c = 0 then ∞ else 1)›*)
case False (*‹c ≠ 0›*)
have "conv_radius (λn. 1 / of_nat n :: 'a) = 1"
proof (rule conv_radius_ratio_limit_nonzero (*‹⟦?c' = ereal ?c; ?c ≠ 0; (λn. norm (?f n) / norm (?f (Suc n))) ⇢ ?c⟧ ⟹ conv_radius ?f = ?c'›*))
(*goals:
1. ‹(1::ereal) = ereal (?c::real)›
2. ‹(?c::real) ≠ (0::real)›
3. ‹(λn::nat. norm ((1::'a::{banach,real_normed_field}) / of_nat n) / norm ((1::'a::{banach,real_normed_field}) / of_nat (Suc n))) ⇢ (?c::real)›*)
show "(λn. norm (1 / of_nat n :: 'a) / norm (1 / of_nat (Suc n) :: 'a)) ⇢ 1"
using LIMSEQ_Suc_n_over_n (*‹(λn. of_nat (Suc n) / of_nat n) ⇢ 1›*) by (simp add: norm_divide (*‹norm (?a / ?b) = norm ?a / norm ?b›*) del: of_nat_Suc (*‹of_nat (Suc ?m) = 1 + of_nat ?m›*))
qed (auto)
(*solves the remaining goals:
1. ‹1 = ereal 1›
2. ‹1 ≠ 0›*)
also (*calculation: ‹conv_radius (λn. 1 / of_nat n) = 1›*) have "conv_radius (λn. 1 / of_nat n :: 'a) =
conv_radius (λn. if n = 0 then 0 else (- 1) ^ (n - 1) / of_nat n :: 'a)"
apply (intro conv_radius_cong (*‹∀⇩F x in sequentially. norm (?f x) = norm (?g x) ⟹ conv_radius ?f = conv_radius ?g›*) eventually_mono[OF eventually_gt_at_top[of 0]] (*‹(⋀x. 0 < x ⟹ ?Q x) ⟹ eventually ?Q at_top›*))
(*goal: ‹conv_radius (λn::nat. (1::'a::{banach,real_normed_field}) / of_nat n) = conv_radius (λn::nat. if n = (0::nat) then 0::'a::{banach,real_normed_field} else (- (1::'a::{banach,real_normed_field})) ^ (n - (1::nat)) / of_nat n)›*)
by (simp add: norm_mult (*‹norm (?x * ?y) = norm ?x * norm ?y›*) norm_divide (*‹norm (?a / ?b) = norm ?a / norm ?b›*) norm_power (*‹norm (?x ^ ?n) = norm ?x ^ ?n›*))
finally (*calculation: ‹conv_radius (λn. if n = 0 then 0 else (- 1) ^ (n - 1) / of_nat n) = 1›*) show "?thesis"
(*goal: ‹fps_conv_radius (fps_ln c) = (if c = 0 then ∞ else 1)›*)
using False (*‹c ≠ 0›*) unfolding fps_ln_def
(*goal: ‹fps_conv_radius (fps_const (1 / c) * Abs_fps (λn. if n = 0 then 0 else (- 1) ^ (n - 1) / of_nat n)) = (if c = 0 then ∞ else 1)›*)
apply (subst fps_conv_radius_cmult_left (*‹?c ≠ 0 ⟹ fps_conv_radius (fps_const ?c * ?f) = fps_conv_radius ?f›*))
(*goals:
1. ‹⟦conv_radius (λn. if n = 0 then 0 else (- 1) ^ (n - 1) / of_nat n) = 1; c ≠ 0⟧ ⟹ 1 / c ≠ 0›
2. ‹⟦conv_radius (λn. if n = 0 then 0 else (- 1) ^ (n - 1) / of_nat n) = 1; c ≠ 0⟧ ⟹ fps_conv_radius (Abs_fps (λn. if n = 0 then 0 else (- 1) ^ (n - 1) / of_nat n)) = (if c = 0 then ∞ else 1)›
discuss goal 1*)
apply (simp add: fps_conv_radius_def (*‹fps_conv_radius ?f = conv_radius (fps_nth ?f)›*))
(*discuss goal 2*)
apply (simp add: fps_conv_radius_def (*‹fps_conv_radius ?f = conv_radius (fps_nth ?f)›*))
(*proven 2 subgoals*) .
qed (auto simp: fps_ln_def (*‹fps_ln ?c = fps_const (1 / ?c) * Abs_fps (λn. if n = 0 then 0 else (- 1) ^ (n - 1) / of_nat n)›*))
(*solved the remaining goal: ‹c = 0 ⟹ fps_conv_radius (fps_ln c) = (if c = 0 then ∞ else 1)›*)
lemma fps_conv_radius_ln_nonzero [simp]:
assumes "c ≠ (0 :: 'a :: {banach,real_normed_field,field_char_0})"
shows "fps_conv_radius (fps_ln c) = 1"
using assms (*‹(c::'a::{banach,real_normed_field}) ≠ (0::'a::{banach,real_normed_field})›*) by (simp add: fps_conv_radius_ln (*‹fps_conv_radius (fps_ln ?c) = (if ?c = 0 then ∞ else 1)›*))
lemma fps_conv_radius_sin [simp]:
fixes c :: "'a :: {banach, real_normed_field, field_char_0}"
shows "fps_conv_radius (fps_sin c) = ∞"
proof (cases "c = 0")
(*goals:
1. ‹c = 0 ⟹ fps_conv_radius (fps_sin c) = ∞›
2. ‹c ≠ 0 ⟹ fps_conv_radius (fps_sin c) = ∞›*)
case False (*‹c ≠ 0›*)
have "∞ = conv_radius (λn. of_real (sin_coeff n) :: 'a)"
apply (rule sym (*‹?s = ?t ⟹ ?t = ?s›*))
(*goal: ‹∞ = conv_radius (λn. of_real (sin_coeff n))›*)
apply (rule conv_radius_inftyI'' (*‹(⋀z::?'a::{banach,real_normed_div_algebra}. summable (λn::nat. (?f::nat ⇒ ?'a::{banach,real_normed_div_algebra}) n * z ^ n)) ⟹ conv_radius ?f = ∞›*))
(*goal: ‹conv_radius (λn::nat. of_real (sin_coeff n)) = ∞›*)
apply (rule summable_norm_cancel (*‹summable (λn. norm (?f n)) ⟹ summable ?f›*))
(*goal: ‹⋀z. summable (λn. of_real (sin_coeff n) * z ^ n)›*)
proof (goal_cases)
(*goal: ‹⋀z. summable (λn. norm (of_real (sin_coeff n) * z ^ n))›*)
case (1 z) (*no hyothesis introduced yet*)
show "?case"
(*goal: ‹summable (λn. norm (of_real (sin_coeff n) * z ^ n))›*)
using summable_norm_sin[of z] (*‹summable (λn. norm (sin_coeff n *⇩R z ^ n))›*) by (simp add: norm_mult (*‹norm (?x * ?y) = norm ?x * norm ?y›*))
qed
also (*calculation: ‹∞ = conv_radius (λn. of_real (sin_coeff n))›*) have "… / norm c = conv_radius (λn. c ^ n * of_real (sin_coeff n) :: 'a)"
using False (*‹c ≠ 0›*) apply (subst conv_radius_mult_power (*‹?c ≠ 0 ⟹ conv_radius (λn. ?c ^ n * ?f n) = conv_radius ?f / ereal (norm ?c)›*))
(*goals:
1. ‹(c::'a) ≠ (0::'a) ⟹ c ≠ (0::'a)›
2. ‹(c::'a) ≠ (0::'a) ⟹ conv_radius (λn::nat. of_real (sin_coeff n)) / ereal (norm c) = conv_radius (λn::nat. of_real (sin_coeff n)) / ereal (norm c)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
also (*calculation: ‹∞ / ereal (norm (c::'a)) = conv_radius (λn::nat. c ^ n * of_real (sin_coeff n))›*) have "… = fps_conv_radius (fps_sin c)"
unfolding fps_conv_radius_def
(*goal: ‹conv_radius (λn::nat. (c::'a::{banach,real_normed_field}) ^ n * of_real (sin_coeff n)) = conv_radius (fps_nth (fps_sin c))›*)
apply (rule conv_radius_cong_weak (*‹(⋀n::nat. (?f::nat ⇒ ?'a::banach) n = (?g::nat ⇒ ?'a::banach) n) ⟹ conv_radius ?f = conv_radius ?g›*))
(*goal: ‹conv_radius (λn. c ^ n * of_real (sin_coeff n)) = conv_radius (fps_nth (fps_sin c))›*)
by (auto simp add: fps_sin_def (*‹fps_sin (?c::?'a) = Abs_fps (λn::nat. if even n then 0::?'a else (- (1::?'a)) ^ ((n - (1::nat)) div (2::nat)) * ?c ^ n / of_nat (fact n))›*) sin_coeff_def (*‹sin_coeff = (λn::nat. if even n then 0::real else (- (1::real)) ^ ((n - Suc (0::nat)) div (2::nat)) / fact n)›*))
finally (*calculation: ‹∞ / ereal (norm c) = fps_conv_radius (fps_sin c)›*) show "?thesis"
(*goal: ‹fps_conv_radius (fps_sin c) = ∞›*)
by simp
qed (simp_all)
(*solved the remaining goal: ‹c = 0 ⟹ fps_conv_radius (fps_sin c) = ∞›*)
lemma fps_conv_radius_cos [simp]:
fixes c :: "'a :: {banach, real_normed_field, field_char_0}"
shows "fps_conv_radius (fps_cos c) = ∞"
proof (cases "c = 0")
(*goals:
1. ‹c = 0 ⟹ fps_conv_radius (fps_cos c) = ∞›
2. ‹c ≠ 0 ⟹ fps_conv_radius (fps_cos c) = ∞›*)
case False (*‹c ≠ 0›*)
have "∞ = conv_radius (λn. of_real (cos_coeff n) :: 'a)"
apply (rule sym (*‹?s = ?t ⟹ ?t = ?s›*))
(*goal: ‹∞ = conv_radius (λn::nat. of_real (cos_coeff n))›*)
apply (rule conv_radius_inftyI'' (*‹(⋀z. summable (λn. ?f n * z ^ n)) ⟹ conv_radius ?f = ∞›*))
(*goal: ‹conv_radius (λn. of_real (cos_coeff n)) = ∞›*)
apply (rule summable_norm_cancel (*‹summable (λn::nat. norm ((?f::nat ⇒ ?'a) n)) ⟹ summable ?f›*))
(*goal: ‹⋀z. summable (λn. of_real (cos_coeff n) * z ^ n)›*)
proof (goal_cases)
(*goal: ‹⋀z. summable (λn. norm (of_real (cos_coeff n) * z ^ n))›*)
case (1 z) (*no hyothesis introduced yet*)
show "?case"
(*goal: ‹summable (λn. norm (of_real (cos_coeff n) * z ^ n))›*)
using summable_norm_cos[of z] (*‹summable (λn. norm (cos_coeff n *⇩R z ^ n))›*) by (simp add: norm_mult (*‹norm ((?x::?'a::real_normed_div_algebra) * (?y::?'a::real_normed_div_algebra)) = norm ?x * norm ?y›*))
qed
also (*calculation: ‹∞ = conv_radius (λn. of_real (cos_coeff n))›*) have "… / norm c = conv_radius (λn. c ^ n * of_real (cos_coeff n) :: 'a)"
using False (*‹c ≠ 0›*) apply (subst conv_radius_mult_power (*‹?c ≠ 0 ⟹ conv_radius (λn. ?c ^ n * ?f n) = conv_radius ?f / ereal (norm ?c)›*))
(*goals:
1. ‹c ≠ 0 ⟹ c ≠ 0›
2. ‹c ≠ 0 ⟹ conv_radius (λn. of_real (cos_coeff n)) / ereal (norm c) = conv_radius (λn. of_real (cos_coeff n)) / ereal (norm c)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
also (*calculation: ‹∞ / ereal (norm c) = conv_radius (λn. c ^ n * of_real (cos_coeff n))›*) have "… = fps_conv_radius (fps_cos c)"
unfolding fps_conv_radius_def
(*goal: ‹conv_radius (λn. c ^ n * of_real (cos_coeff n)) = conv_radius (fps_nth (fps_cos c))›*)
apply (rule conv_radius_cong_weak (*‹(⋀n. ?f n = ?g n) ⟹ conv_radius ?f = conv_radius ?g›*))
(*goal: ‹conv_radius (λn. c ^ n * of_real (cos_coeff n)) = conv_radius (fps_nth (fps_cos c))›*)
by (auto simp add: fps_cos_def (*‹fps_cos (?c::?'a::field_char_0) = Abs_fps (λn::nat. if even n then (- (1::?'a::field_char_0)) ^ (n div (2::nat)) * ?c ^ n / of_nat (fact n) else (0::?'a::field_char_0))›*) cos_coeff_def (*‹cos_coeff = (λn::nat. if even n then (- (1::real)) ^ (n div (2::nat)) / fact n else (0::real))›*))
finally (*calculation: ‹∞ / ereal (norm c) = fps_conv_radius (fps_cos c)›*) show "?thesis"
(*goal: ‹fps_conv_radius (fps_cos c) = ∞›*)
by simp
qed (simp_all)
(*solved the remaining goal: ‹(c::'a) = (0::'a) ⟹ fps_conv_radius (fps_cos c) = ∞›*)
lemma eval_fps_sin [simp]:
fixes z :: "'a :: {banach, real_normed_field, field_char_0}"
shows "eval_fps (fps_sin c) z = sin (c * z)"
proof (-)
(*goal: ‹eval_fps (fps_sin c) z = sin (c * z)›*)
have "(λn. sin_coeff n *⇩R (c * z) ^ n) sums sin (c * z)"
by (rule sin_converges (*‹(λn::nat. sin_coeff n *⇩R (?x::?'a) ^ n) sums sin ?x›*))
also (*calculation: ‹(λn. sin_coeff n *⇩R (c * z) ^ n) sums sin (c * z)›*) have "(λn. sin_coeff n *⇩R (c * z) ^ n) = (λn. fps_nth (fps_sin c) n * z ^ n)"
apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*))
(*goal: ‹(λn. sin_coeff n *⇩R (c * z) ^ n) = (λn. fps_nth (fps_sin c) n * z ^ n)›*)
by (auto simp: sin_coeff_def (*‹sin_coeff = (λn. if even n then 0 else (- 1) ^ ((n - Suc 0) div 2) / fact n)›*) fps_sin_def (*‹fps_sin ?c = Abs_fps (λn. if even n then 0 else (- 1) ^ ((n - 1) div 2) * ?c ^ n / of_nat (fact n))›*) power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*) scaleR_conv_of_real (*‹?r *⇩R ?x = of_real ?r * ?x›*))
finally (*calculation: ‹(λn. fps_nth (fps_sin c) n * z ^ n) sums sin (c * z)›*) show "?thesis"
(*goal: ‹eval_fps (fps_sin c) z = sin (c * z)›*)
by (simp add: sums_iff (*‹?f sums ?x = (summable ?f ∧ suminf ?f = ?x)›*) eval_fps_def (*‹eval_fps ?f ?z = (∑n. fps_nth ?f n * ?z ^ n)›*))
qed
lemma eval_fps_cos [simp]:
fixes z :: "'a :: {banach, real_normed_field, field_char_0}"
shows "eval_fps (fps_cos c) z = cos (c * z)"
proof (-)
(*goal: ‹eval_fps (fps_cos c) z = cos (c * z)›*)
have "(λn. cos_coeff n *⇩R (c * z) ^ n) sums cos (c * z)"
by (rule cos_converges (*‹(λn. cos_coeff n *⇩R ?x ^ n) sums cos ?x›*))
also (*calculation: ‹(λn. cos_coeff n *⇩R (c * z) ^ n) sums cos (c * z)›*) have "(λn. cos_coeff n *⇩R (c * z) ^ n) = (λn. fps_nth (fps_cos c) n * z ^ n)"
apply (rule ext (*‹(⋀x::?'a. (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x) ⟹ ?f = ?g›*))
(*goal: ‹(λn. cos_coeff n *⇩R (c * z) ^ n) = (λn. fps_nth (fps_cos c) n * z ^ n)›*)
by (auto simp: cos_coeff_def (*‹cos_coeff = (λn. if even n then (- 1) ^ (n div 2) / fact n else 0)›*) fps_cos_def (*‹fps_cos ?c = Abs_fps (λn. if even n then (- 1) ^ (n div 2) * ?c ^ n / of_nat (fact n) else 0)›*) power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*) scaleR_conv_of_real (*‹?r *⇩R ?x = of_real ?r * ?x›*))
finally (*calculation: ‹(λn. fps_nth (fps_cos c) n * z ^ n) sums cos (c * z)›*) show "?thesis"
(*goal: ‹eval_fps (fps_cos c) z = cos (c * z)›*)
by (simp add: sums_iff (*‹?f sums ?x = (summable ?f ∧ suminf ?f = ?x)›*) eval_fps_def (*‹eval_fps ?f ?z = (∑n. fps_nth ?f n * ?z ^ n)›*))
qed
lemma cos_eq_zero_imp_norm_ge:
assumes "cos (z :: complex) = 0"
shows "norm z ≥ pi / 2"
proof (-)
(*goal: ‹pi / 2 ≤ cmod z›*)
from assms (*‹cos z = 0›*) obtain n where "z = complex_of_real ((of_int n + 1 / 2) * pi)"
(*goal: ‹(⋀n. z = complex_of_real ((real_of_int n + 1 / 2) * pi) ⟹ thesis) ⟹ thesis›*)
by (auto simp: cos_eq_0 (*‹(cos ?z = 0) = (∃x. ?z = complex_of_real (real_of_int x * pi) + complex_of_real pi / 2)›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*))
also (*calculation: ‹z = complex_of_real ((real_of_int n + 1 / 2) * pi)›*) have "norm … = ¦real_of_int n + 1 / 2¦ * pi"
apply (subst norm_of_real (*‹norm (of_real ?r) = ¦?r¦›*))
(*goal: ‹cmod (complex_of_real ((real_of_int n + 1 / 2) * pi)) = ¦real_of_int n + 1 / 2¦ * pi›*)
by (simp add: abs_mult (*‹¦?a * ?b¦ = ¦?a¦ * ¦?b¦›*))
also (*calculation: ‹cmod z = ¦real_of_int n + 1 / 2¦ * pi›*) have "real_of_int n + 1 / 2 = of_int (2 * n + 1) / 2"
by simp
also (*calculation: ‹cmod z = ¦real_of_int (2 * n + 1) / 2¦ * pi›*) have "¦…¦ = of_int ¦2 * n + 1¦ / 2"
apply (subst abs_divide (*‹¦(?a::?'a) / (?b::?'a)¦ = ¦?a¦ / ¦?b¦›*))
(*goal: ‹¦real_of_int (2 * n + 1) / 2¦ = real_of_int ¦2 * n + 1¦ / 2›*)
by simp
also (*calculation: ‹cmod z = real_of_int ¦2 * n + 1¦ / 2 * pi›*) have "… * pi = of_int ¦2 * n + 1¦ * (pi / 2)"
by simp
also (*calculation: ‹cmod z = real_of_int ¦2 * n + 1¦ * (pi / 2)›*) have "… ≥ of_int 1 * (pi / 2)"
apply (intro mult_right_mono (*‹⟦(?a::?'a) ≤ (?b::?'a); (0::?'a) ≤ (?c::?'a)⟧ ⟹ ?a * ?c ≤ ?b * ?c›*))
(*goals:
1. ‹real_of_int 1 ≤ real_of_int ¦2 * n + 1¦›
2. ‹0 ≤ pi / 2›
discuss goal 1*)
apply (subst of_int_le_iff (*‹(of_int ?w ≤ of_int ?z) = (?w ≤ ?z)›*))
(*top goal: ‹real_of_int (1::int) ≤ real_of_int ¦(2::int) * (n::int) + (1::int)¦› and 1 goal remains*)
apply ((auto simp: abs_if (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*))[1])
(*discuss goal 2*)
apply ((auto simp: abs_if (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*))[1])
(*proven 2 subgoals*) .
finally (*calculation: ‹real_of_int 1 * (pi / 2) ≤ cmod z›*) show "?thesis"
(*goal: ‹pi / (2::real) ≤ cmod (z::complex)›*)
by simp
qed
lemma eval_fps_binomial:
fixes c :: complex
assumes "norm z < 1"
shows "eval_fps (fps_binomial c) z = (1 + z) powr c"
using gen_binomial_complex[OF assms] (*‹(λn. (?a gchoose n) * z ^ n) sums (1 + z) powr ?a›*) by (simp add: sums_iff (*‹?f sums ?x = (summable ?f ∧ suminf ?f = ?x)›*) eval_fps_def (*‹eval_fps ?f ?z = (∑n. fps_nth ?f n * ?z ^ n)›*))
lemma has_fps_expansion_binomial_complex [fps_expansion_intros]:
fixes c :: complex
shows "(λx. (1 + x) powr c) has_fps_expansion fps_binomial c"
proof (-)
(*goal: ‹(λx. (1 + x) powr c) has_fps_expansion fps_binomial c›*)
have "*": "eventually (λz::complex. z ∈ eball 0 1) (nhds 0)"
apply (intro eventually_nhds_in_open (*‹⟦open ?s; ?x ∈ ?s⟧ ⟹ ∀⇩F y in nhds ?x. y ∈ ?s›*))
(*goals:
1. ‹open (eball 0 1)›
2. ‹0 ∈ eball 0 1›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
thus "?thesis"
(*goal: ‹(λx::complex. ((1::complex) + x) powr (c::complex)) has_fps_expansion fps_binomial c›*)
by (auto simp: has_fps_expansion_def (*‹(?f::?'a ⇒ ?'a) has_fps_expansion (?F::?'a fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a in nhds (0::?'a). eval_fps ?F z = ?f z))›*) eval_fps_binomial (*‹cmod (?z::complex) < (1::real) ⟹ eval_fps (fps_binomial (?c::complex)) ?z = ((1::complex) + ?z) powr ?c›*) fps_conv_radius_binomial (*‹fps_conv_radius (fps_binomial (?c::?'a)) = (if ?c ∈ ℕ then ∞ else (1::ereal))›*) intro!: eventually_mono [OF *] (*‹(⋀x::complex. x ∈ eball (0::complex) (1::ereal) ⟹ (?Q::complex ⇒ bool) x) ⟹ eventually ?Q (nhds (0::complex))›*))
qed
lemma has_fps_expansion_sin [fps_expansion_intros]:
fixes c :: "'a :: {banach, real_normed_field, field_char_0}"
shows "(λx. sin (c * x)) has_fps_expansion fps_sin c"
by (auto simp: has_fps_expansion_def (*‹(?f::?'a ⇒ ?'a) has_fps_expansion (?F::?'a fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a in nhds (0::?'a). eval_fps ?F z = ?f z))›*))
lemma has_fps_expansion_sin' [fps_expansion_intros]:
"(λx::'a :: {banach, real_normed_field}. sin x) has_fps_expansion fps_sin 1"
using has_fps_expansion_sin[of 1] (*‹(λx. sin (1 * x)) has_fps_expansion fps_sin 1›*) by simp
lemma has_fps_expansion_cos [fps_expansion_intros]:
fixes c :: "'a :: {banach, real_normed_field, field_char_0}"
shows "(λx. cos (c * x)) has_fps_expansion fps_cos c"
by (auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))
lemma has_fps_expansion_cos' [fps_expansion_intros]:
"(λx::'a :: {banach, real_normed_field}. cos x) has_fps_expansion fps_cos 1"
using has_fps_expansion_cos[of 1] (*‹(λx. cos (1 * x)) has_fps_expansion fps_cos 1›*) by simp
lemma has_fps_expansion_shift [fps_expansion_intros]:
fixes F :: "'a :: {banach, real_normed_field} fps"
assumes "f has_fps_expansion F" and "n ≤ subdegree F"
assumes "c = fps_nth F n"
shows "(λx. if x = 0 then c else f x / x ^ n) has_fps_expansion (fps_shift n F)"
proof (-)
(*goal: ‹(λx. if x = 0 then c else f x / x ^ n) has_fps_expansion fps_shift n F›*)
have "eventually (λx. x ∈ eball 0 (fps_conv_radius F)) (nhds 0)"
using assms (*‹(f::'a ⇒ 'a) has_fps_expansion (F::'a fps)› ‹n ≤ subdegree F› ‹c = fps_nth F n›*) apply (intro eventually_nhds_in_open (*‹⟦open (?s::?'a::topological_space set); (?x::?'a::topological_space) ∈ ?s⟧ ⟹ ∀⇩F y::?'a::topological_space in nhds ?x. y ∈ ?s›*))
(*goals:
1. ‹⟦(f::'a ⇒ 'a) has_fps_expansion (F::'a fps); (n::nat) ≤ subdegree F; (c::'a) = fps_nth F n⟧ ⟹ open (eball (0::'b) (fps_conv_radius F))›
2. ‹⟦(f::'a ⇒ 'a) has_fps_expansion (F::'a fps); (n::nat) ≤ subdegree F; (c::'a) = fps_nth F n⟧ ⟹ (0::'b) ∈ eball (0::'b) (fps_conv_radius F)›
discuss goal 1*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))[1])
(*discuss goal 2*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))[1])
(*proven 2 subgoals*) .
moreover have "eventually (λx. eval_fps F x = f x) (nhds 0)"
using assms (*‹f has_fps_expansion F› ‹n ≤ subdegree F› ‹(c::'a) = fps_nth (F::'a fps) (n::nat)›*) by (auto simp: has_fps_expansion_def (*‹(?f::?'a ⇒ ?'a) has_fps_expansion (?F::?'a fps) = ((0::ereal) < fps_conv_radius ?F ∧ (∀⇩F z::?'a in nhds (0::?'a). eval_fps ?F z = ?f z))›*))
ultimately have "eventually (λx. eval_fps (fps_shift n F) x =
(if x = 0 then c else f x / x ^ n)) (nhds 0)"
apply eventually_elim
(*goal: ‹∀⇩F x::'a in nhds (0::'a). eval_fps (fps_shift (n::nat) (F::'a fps)) x = (if x = (0::'a) then c::'a else (f::'a ⇒ 'a) x / x ^ n)›*)
by (auto simp: eval_fps_shift (*‹⟦?n ≤ subdegree ?f; ereal (norm ?z) < fps_conv_radius ?f⟧ ⟹ eval_fps (fps_shift ?n ?f) ?z = (if ?z = 0 then fps_nth ?f ?n else eval_fps ?f ?z / ?z ^ ?n)›*) assms (*‹f has_fps_expansion F› ‹n ≤ subdegree F› ‹c = fps_nth F n›*))
with assms (*‹f has_fps_expansion F› ‹n ≤ subdegree F› ‹(c::'a) = fps_nth (F::'a fps) (n::nat)›*) show "?thesis"
(*goal: ‹(λx. if x = 0 then c else f x / x ^ n) has_fps_expansion fps_shift n F›*)
by (auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*))
qed
lemma has_fps_expansion_divide [fps_expansion_intros]:
fixes F G :: "'a :: {banach, real_normed_field} fps"
assumes "f has_fps_expansion F" and "g has_fps_expansion G" and
"subdegree G ≤ subdegree F" "G ≠ 0"
"c = fps_nth F (subdegree G) / fps_nth G (subdegree G)"
shows "(λx. if x = 0 then c else f x / g x) has_fps_expansion (F / G)"
proof (-)
(*goal: ‹(λx::'a::{banach,real_normed_field}. if x = (0::'a::{banach,real_normed_field}) then c::'a::{banach,real_normed_field} else (f::'a::{banach,real_normed_field} ⇒ 'a::{banach,real_normed_field}) x / (g::'a::{banach,real_normed_field} ⇒ 'a::{banach,real_normed_field}) x) has_fps_expansion (F::'a::{banach,real_normed_field} fps) / (G::'a::{banach,real_normed_field} fps)›*)
define n where "n = subdegree G"
define F' and G' where "F' = fps_shift n F" and "G' = fps_shift n G"
have "F = F' * fps_X ^ n" "G = G' * fps_X ^ n"
unfolding F'_def G'_def n_def
(*goals:
1. ‹F = fps_shift (subdegree G) F * fps_X ^ subdegree G›
2. ‹G = fps_shift (subdegree G) G * fps_X ^ subdegree G›*)
(*goals:
1. ‹F = fps_shift (subdegree G) F * fps_X ^ subdegree G›
2. ‹G = fps_shift (subdegree G) G * fps_X ^ subdegree G›
discuss goal 1*)
apply (rule fps_shift_times_fps_X_power [symmetric] (*‹?n ≤ subdegree ?t ⟹ ?t = fps_shift ?n ?t * fps_X ^ ?n›*) le_refl (*‹?n ≤ ?n›*))
(*top goal: ‹F = fps_shift (subdegree G) F * fps_X ^ subdegree G› and 1 goal remains*)
apply fact
(*discuss goal 2*)
apply (rule fps_shift_times_fps_X_power [symmetric] (*‹?n ≤ subdegree ?t ⟹ ?t = fps_shift ?n ?t * fps_X ^ ?n›*) le_refl (*‹?n ≤ ?n›*))
(*goal: ‹(G::'a::{banach,real_normed_field} fps) = fps_shift (subdegree G) G * fps_X ^ subdegree G›*)
apply (rule fps_shift_times_fps_X_power [symmetric] (*‹(?n::nat) ≤ subdegree (?t::?'a fps) ⟹ ?t = fps_shift ?n ?t * fps_X ^ ?n›*) le_refl (*‹(?n::nat) ≤ ?n›*))
(*proven 2 subgoals*) .
moreover from assms (*‹f has_fps_expansion F› ‹g has_fps_expansion G› ‹subdegree G ≤ subdegree F› ‹G ≠ 0› ‹(c::'a) = fps_nth (F::'a fps) (subdegree (G::'a fps)) / fps_nth G (subdegree G)›*) have "fps_nth G' 0 ≠ 0"
by (simp add: G'_def (*‹G' = fps_shift n G›*) n_def (*‹n = subdegree G›*))
ultimately have FG: "F / G = F' * inverse G'"
by (simp add: fps_divide_unit (*‹fps_nth ?g 0 ≠ 0 ⟹ ?f / ?g = ?f * inverse ?g›*))
have "(λx. (if x = 0 then fps_nth F n else f x / x ^ n) *
inverse (if x = 0 then fps_nth G n else g x / x ^ n)) has_fps_expansion F / G" (is "?h has_fps_expansion _")
unfolding FG F'_def G'_def n_def
(*goal: ‹(λx. (if x = 0 then fps_nth F (subdegree G) else f x / x ^ subdegree G) * inverse (if x = 0 then fps_nth G (subdegree G) else g x / x ^ subdegree G)) has_fps_expansion fps_shift (subdegree G) F * inverse (fps_shift (subdegree G) G)›*)
using ‹G ≠ 0› (*‹G ≠ 0›*) apply (intro has_fps_expansion_mult (*‹⟦?f has_fps_expansion ?F; ?g has_fps_expansion ?G⟧ ⟹ (λx. ?f x * ?g x) has_fps_expansion ?F * ?G›*) has_fps_expansion_inverse (*‹⟦?f has_fps_expansion ?F; fps_nth ?F 0 ≠ 0⟧ ⟹ (λx. inverse (?f x)) has_fps_expansion inverse ?F›*) has_fps_expansion_shift (*‹⟦?f has_fps_expansion ?F; ?n ≤ subdegree ?F; ?c = fps_nth ?F ?n⟧ ⟹ (λx. if x = 0 then ?c else ?f x / x ^ ?n) has_fps_expansion fps_shift ?n ?F›*) assms (*‹f has_fps_expansion F› ‹g has_fps_expansion G› ‹subdegree G ≤ subdegree F› ‹G ≠ 0› ‹c = fps_nth F (subdegree G) / fps_nth G (subdegree G)›*))
(*goals:
1. ‹G ≠ 0 ⟹ fps_nth F (subdegree G) = fps_nth F (subdegree G)›
2. ‹G ≠ 0 ⟹ subdegree G ≤ subdegree G›
3. ‹G ≠ 0 ⟹ fps_nth G (subdegree G) = fps_nth G (subdegree G)›
4. ‹G ≠ 0 ⟹ fps_nth (fps_shift (subdegree G) G) 0 ≠ 0›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*proven 4 subgoals*) .
also (*calculation: ‹(λx. (if x = 0 then fps_nth F n else f x / x ^ n) * inverse (if x = 0 then fps_nth G n else g x / x ^ n)) has_fps_expansion F / G›*) have "?h = (λx. if x = 0 then c else f x / g x)"
using assms(5) (*‹c = fps_nth F (subdegree G) / fps_nth G (subdegree G)›*) unfolding n_def
(*goal: ‹(λx. (if x = 0 then fps_nth F (subdegree G) else f x / x ^ subdegree G) * inverse (if x = 0 then fps_nth G (subdegree G) else g x / x ^ subdegree G)) = (λx. if x = 0 then c else f x / g x)›*)
apply (intro ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*))
(*goal: ‹(λx. (if x = 0 then fps_nth F (subdegree G) else f x / x ^ subdegree G) * inverse (if x = 0 then fps_nth G (subdegree G) else g x / x ^ subdegree G)) = (λx. if x = 0 then c else f x / g x)›*)
by (auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*))
finally (*calculation: ‹(λx. if x = 0 then c else f x / g x) has_fps_expansion F / G›*) show "?thesis"
(*goal: ‹(λx::'a. if x = (0::'a) then c::'a else (f::'a ⇒ 'a) x / (g::'a ⇒ 'a) x) has_fps_expansion (F::'a fps) / (G::'a fps)›*) .
qed
lemma has_fps_expansion_divide' [fps_expansion_intros]:
fixes F G :: "'a :: {banach, real_normed_field} fps"
assumes "f has_fps_expansion F" and "g has_fps_expansion G" and "fps_nth G 0 ≠ 0"
shows "(λx. f x / g x) has_fps_expansion (F / G)"
proof (-)
(*goal: ‹(λx. f x / g x) has_fps_expansion F / G›*)
have "(λx. if x = 0 then fps_nth F 0 / fps_nth G 0 else f x / g x) has_fps_expansion (F / G)" (is "?h has_fps_expansion _")
using assms(3) (*‹fps_nth (G::'a::{banach,real_normed_field} fps) (0::nat) ≠ (0::'a::{banach,real_normed_field})›*) apply (intro has_fps_expansion_divide (*‹⟦?f has_fps_expansion ?F; ?g has_fps_expansion ?G; subdegree ?G ≤ subdegree ?F; ?G ≠ 0; ?c = fps_nth ?F (subdegree ?G) / fps_nth ?G (subdegree ?G)⟧ ⟹ (λx. if x = 0 then ?c else ?f x / ?g x) has_fps_expansion ?F / ?G›*) assms (*‹f has_fps_expansion F› ‹g has_fps_expansion G› ‹fps_nth G 0 ≠ 0›*))
(*goals:
1. ‹fps_nth G 0 ≠ 0 ⟹ subdegree G ≤ subdegree F›
2. ‹fps_nth G 0 ≠ 0 ⟹ G ≠ 0›
3. ‹fps_nth G 0 ≠ 0 ⟹ fps_nth F 0 / fps_nth G 0 = fps_nth F (subdegree G) / fps_nth G (subdegree G)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
also (*calculation: ‹(λx::'a. if x = (0::'a) then fps_nth (F::'a fps) (0::nat) / fps_nth (G::'a fps) (0::nat) else (f::'a ⇒ 'a) x / (g::'a ⇒ 'a) x) has_fps_expansion F / G›*) from assms (*‹f has_fps_expansion F› ‹(g::'a ⇒ 'a) has_fps_expansion (G::'a fps)› ‹fps_nth G 0 ≠ 0›*) have "fps_nth F 0 = f 0" "fps_nth G 0 = g 0"
apply -
(*goals:
1. ‹⟦f has_fps_expansion F; g has_fps_expansion G; fps_nth G 0 ≠ 0⟧ ⟹ fps_nth F 0 = f 0›
2. ‹⟦f has_fps_expansion F; g has_fps_expansion G; fps_nth G 0 ≠ 0⟧ ⟹ fps_nth G 0 = g 0›
discuss goal 1*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) eval_fps_at_0 (*‹eval_fps ?f 0 = fps_nth ?f 0›*) dest: eventually_nhds_x_imp_x (*‹eventually ?P (nhds ?x) ⟹ ?P ?x›*))[1])
(*discuss goal 2*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) eval_fps_at_0 (*‹eval_fps ?f 0 = fps_nth ?f 0›*) dest: eventually_nhds_x_imp_x (*‹eventually ?P (nhds ?x) ⟹ ?P ?x›*))[1])
(*proven 2 subgoals*) .
hence "?h = (λx. f x / g x)"
by auto
finally (*calculation: ‹(λx::'a. (f::'a ⇒ 'a) x / (g::'a ⇒ 'a) x) has_fps_expansion (F::'a fps) / (G::'a fps)›*) show "?thesis"
(*goal: ‹(λx. f x / g x) has_fps_expansion F / G›*) .
qed
lemma has_fps_expansion_tan [fps_expansion_intros]:
fixes c :: "'a :: {banach, real_normed_field, field_char_0}"
shows "(λx. tan (c * x)) has_fps_expansion fps_tan c"
proof (-)
(*goal: ‹(λx. tan (c * x)) has_fps_expansion fps_tan c›*)
have "(λx. sin (c * x) / cos (c * x)) has_fps_expansion fps_sin c / fps_cos c"
apply (intro fps_expansion_intros (*‹(λ_. ?c) has_fps_expansion fps_const ?c› ‹(λ_. 0) has_fps_expansion 0› ‹(λ_. 1) has_fps_expansion 1› ‹(λ_. numeral ?n) has_fps_expansion numeral ?n› ‹(λx. x ^ ?n) has_fps_expansion fps_X ^ ?n› ‹(λx. x) has_fps_expansion fps_X› ‹?f has_fps_expansion ?F ⟹ (λx. ?c * ?f x) has_fps_expansion fps_const ?c * ?F› ‹?f has_fps_expansion ?F ⟹ (λx. ?f x * ?c) has_fps_expansion ?F * fps_const ?c› ‹?f has_fps_expansion ?F ⟹ (λx. - ?f x) has_fps_expansion - ?F› ‹⟦?f has_fps_expansion ?F; ?g has_fps_expansion ?G⟧ ⟹ (λx. ?f x + ?g x) has_fps_expansion ?F + ?G› ‹⟦?f has_fps_expansion ?F; ?g has_fps_expansion ?G⟧ ⟹ (λx. ?f x - ?g x) has_fps_expansion ?F - ?G› ‹⟦?f has_fps_expansion ?F; ?g has_fps_expansion ?G⟧ ⟹ (λx. ?f x * ?g x) has_fps_expansion ?F * ?G› and more 13 facts*))
(*goal: ‹(λx. sin (c * x) / cos (c * x)) has_fps_expansion fps_sin c / fps_cos c›*)
by auto
thus "?thesis"
(*goal: ‹(λx. tan (c * x)) has_fps_expansion fps_tan c›*)
by (simp add: tan_def (*‹tan = (λx. sin x / cos x)›*) fps_tan_def (*‹fps_tan ?c = fps_sin ?c / fps_cos ?c›*))
qed
lemma has_fps_expansion_tan' [fps_expansion_intros]:
"tan has_fps_expansion fps_tan (1 :: 'a :: {banach, real_normed_field, field_char_0})"
using has_fps_expansion_tan[of 1] (*‹(λx. tan (1 * x)) has_fps_expansion fps_tan 1›*) by simp
lemma has_fps_expansion_imp_holomorphic:
assumes "f has_fps_expansion F"
obtains s where "open s" "0 ∈ s" "f holomorphic_on s" "⋀z. z ∈ s ⟹ f z = eval_fps F z"
proof (-)
(*goal: ‹(⋀s::complex set. ⟦open s; (0::complex) ∈ s; (f::complex ⇒ complex) holomorphic_on s; ⋀z::complex. z ∈ s ⟹ f z = eval_fps (F::complex fps) z⟧ ⟹ thesis::bool) ⟹ thesis›*)
from assms (*‹f has_fps_expansion F›*) obtain s where s: "open s" "0 ∈ s" "⋀z. z ∈ s ⟹ eval_fps F z = f z"
(*goal: ‹(⋀s. ⟦open s; 0 ∈ s; ⋀z. z ∈ s ⟹ eval_fps F z = f z⟧ ⟹ thesis) ⟹ thesis›*)
unfolding has_fps_expansion_def eventually_nhds
(*goal: ‹(⋀s. ⟦open s; 0 ∈ s; ⋀z. z ∈ s ⟹ eval_fps F z = f z⟧ ⟹ thesis) ⟹ thesis›*)
by blast
let ?s' = "eball 0 (fps_conv_radius F) ∩ s"
have "eval_fps F holomorphic_on ?s'"
apply (intro holomorphic_intros (*‹?f holomorphic_on {}› ‹(*) ?c holomorphic_on ?s› ‹(λz. ?c) holomorphic_on ?s› ‹(λx. x) holomorphic_on ?s› ‹id holomorphic_on ?s› ‹?f holomorphic_on ?A ⟹ (λz. - ?f z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z + ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z - ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z * ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?f z ≠ 0⟧ ⟹ (λz. inverse (?f z)) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?g z ≠ 0⟧ ⟹ (λz. ?f z / ?g z) holomorphic_on ?A› ‹?f holomorphic_on ?A ⟹ (λz. ?f z ^ ?n) holomorphic_on ?A› and more 19 facts*))
(*goal: ‹eval_fps (F::complex fps) holomorphic_on eball (0::complex) (fps_conv_radius F) ∩ (s::complex set)›*)
by auto
also (*calculation: ‹eval_fps F holomorphic_on eball 0 (fps_conv_radius F) ∩ s›*) have "?this ⟷ f holomorphic_on ?s'"
using s (*‹open (s::complex set)› ‹(0::complex) ∈ (s::complex set)› ‹?z ∈ s ⟹ eval_fps F ?z = f ?z›*) apply (intro holomorphic_cong (*‹⟦?s = ?t; ⋀x. x ∈ ?s ⟹ ?f x = ?g x⟧ ⟹ (?f holomorphic_on ?s) = (?g holomorphic_on ?t)›*))
(*goals:
1. ‹⟦open s; 0 ∈ s; ⋀z. z ∈ s ⟹ eval_fps F z = f z⟧ ⟹ eball 0 (fps_conv_radius F) ∩ s = eball 0 (fps_conv_radius F) ∩ s›
2. ‹⋀x. ⟦open s; 0 ∈ s; ⋀z. z ∈ s ⟹ eval_fps F z = f z; x ∈ eball 0 (fps_conv_radius F) ∩ s⟧ ⟹ eval_fps F x = f x›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
finally (*calculation: ‹f holomorphic_on eball 0 (fps_conv_radius F) ∩ s›*) show "?thesis"
(*goal: ‹thesis›*)
using s (*‹open s› ‹0 ∈ s› ‹?z ∈ s ⟹ eval_fps F ?z = f ?z›*) assms (*‹f has_fps_expansion F›*) apply (intro that[of ?s'] (*‹⟦open (eball (0::complex) (fps_conv_radius (F::complex fps)) ∩ (s::complex set)); (0::complex) ∈ eball (0::complex) (fps_conv_radius F) ∩ s; (f::complex ⇒ complex) holomorphic_on eball (0::complex) (fps_conv_radius F) ∩ s; ⋀z::complex. z ∈ eball (0::complex) (fps_conv_radius F) ∩ s ⟹ f z = eval_fps F z⟧ ⟹ thesis::bool›*))
(*goals:
1. ‹⟦f holomorphic_on eball 0 (fps_conv_radius F) ∩ s; open s; 0 ∈ s; ⋀z. z ∈ s ⟹ eval_fps F z = f z; f has_fps_expansion F⟧ ⟹ open (eball 0 (fps_conv_radius F) ∩ s)›
2. ‹⟦f holomorphic_on eball 0 (fps_conv_radius F) ∩ s; open s; 0 ∈ s; ⋀z. z ∈ s ⟹ eval_fps F z = f z; f has_fps_expansion F⟧ ⟹ 0 ∈ eball 0 (fps_conv_radius F) ∩ s›
3. ‹⟦f holomorphic_on eball 0 (fps_conv_radius F) ∩ s; open s; 0 ∈ s; ⋀z. z ∈ s ⟹ eval_fps F z = f z; f has_fps_expansion F⟧ ⟹ f holomorphic_on eball 0 (fps_conv_radius F) ∩ s›
4. ‹⋀z. ⟦f holomorphic_on eball 0 (fps_conv_radius F) ∩ s; open s; 0 ∈ s; ⋀z. z ∈ s ⟹ eval_fps F z = f z; f has_fps_expansion F; z ∈ eball 0 (fps_conv_radius F) ∩ s⟧ ⟹ f z = eval_fps F z›
discuss goal 1*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))[1])
(*discuss goal 2*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))[1])
(*discuss goal 3*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))[1])
(*discuss goal 4*)
apply ((auto simp: has_fps_expansion_def (*‹?f has_fps_expansion ?F = (0 < fps_conv_radius ?F ∧ (∀⇩F z in nhds 0. eval_fps ?F z = ?f z))›*) zero_ereal_def (*‹0 = ereal 0›*))[1])
(*proven 4 subgoals*) .
qed
end | {
"path": "Isabelle2024/src/HOL/Analysis/FPS_Convergence.thy",
"repo": "Isabelle2024",
"sha": "cea1048a7a1e92c1f5a98a6e3582770d282c9d345169b866fc45dab95974aabc"
} |
(* The value setup for friendship status confidentiality *)
theory Friend_Value_Setup
imports "Friend_Openness"
begin
subsection ‹Value Setup›
context Friend
begin
datatype "value" =
FrVal bool ― ‹updated friendship status between ‹UID1› and ‹UID2››
| OVal bool ― ‹updated dynamic declassification trigger condition›
fun φ :: "(state,act,out) trans ⇒ bool" where
"φ (Trans s (Cact (cFriend uid p uid')) ou s') =
((uid,uid') ∈ {(UID1,UID2), (UID2,UID1)} ∧ ou = outOK ∨
open s ≠ open s')"
|
"φ (Trans s (Dact (dFriend uid p uid')) ou s') =
((uid,uid') ∈ {(UID1,UID2), (UID2,UID1)} ∧ ou = outOK ∨
open s ≠ open s')"
|
"φ (Trans s (Cact (cUser uid p uid' p')) ou s') =
(open s ≠ open s')"
|
"φ _ = False"
fun f :: "(state,act,out) trans ⇒ value" where
"f (Trans s (Cact (cFriend uid p uid')) ou s') =
(if (uid,uid') ∈ {(UID1,UID2), (UID2,UID1)} then FrVal True
else OVal True)"
|
"f (Trans s (Dact (dFriend uid p uid')) ou s') =
(if (uid,uid') ∈ {(UID1,UID2), (UID2,UID1)} then FrVal False
else OVal False)"
|
"f (Trans s (Cact (cUser uid p uid' p')) ou s') = OVal False"
|
"f _ = undefined"
lemma φE:
assumes φ: "φ (Trans s a ou s')" (is "φ ?trn")
and step: "step s a = (ou, s')"
and rs: "reach s"
obtains (Friend) uid p uid' where "a = Cact (cFriend uid p uid')" "ou = outOK" "f ?trn = FrVal True"
"uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1"
"IDsOK s [UID1, UID2] [] [] []"
"¬friends12 s" "friends12 s'"
| (Unfriend) uid p uid' where "a = Dact (dFriend uid p uid')" "ou = outOK" "f ?trn = FrVal False"
"uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1"
"IDsOK s [UID1, UID2] [] [] []"
"friends12 s" "¬friends12 s'"
| (OpenF) uid p uid' where "a = Cact (cFriend uid p uid')"
"(uid ∈ UIDs ∧ uid' ∈ {UID1,UID2}) ∨ (uid' ∈ UIDs ∧ uid ∈ {UID1,UID2})"
"ou = outOK" "f ?trn = OVal True" "¬openByF s" "openByF s'"
"¬openByA s" "¬openByA s'"
| (CloseF) uid p uid' where "a = Dact (dFriend uid p uid')"
"(uid ∈ UIDs ∧ uid' ∈ {UID1,UID2}) ∨ (uid' ∈ UIDs ∧ uid ∈ {UID1,UID2})"
"ou = outOK" "f ?trn = OVal False" "openByF s" "¬openByF s'"
"¬openByA s" "¬openByA s'"
| (CloseA) uid p uid' p' where "a = Cact (cUser uid p uid' p')"
"uid' ∈ {UID1,UID2}" "openByA s" "¬openByA s'"
"¬openByF s" "¬openByF s'"
"ou = outOK" "f ?trn = OVal False"
using "φ" (*‹φ (Trans s a ou s')›*) proof (elim φ.elims (*‹⟦φ (?x::(state, act, out) trans) = (?y::bool); ⋀(s::state) (uid::userID) (p::password) (uid'::userID) (ou::out) s'::state. ⟦?x = Trans s (Cact (cFriend uid p uid')) ou s'; ?y = ((uid, uid') ∈ {(UID1::userID, UID2::userID), (UID2, UID1)} ∧ ou = outOK ∨ open s ≠ open s')⟧ ⟹ ?P::bool; ⋀(s::state) (uid::userID) (p::password) (uid'::userID) (ou::out) s'::state. ⟦?x = Trans s (Dact (dFriend uid p uid')) ou s'; ?y = ((uid, uid') ∈ {(UID1, UID2), (UID2, UID1)} ∧ ou = outOK ∨ open s ≠ open s')⟧ ⟹ ?P; ⋀(s::state) (uid::userID) (p::password) (uid'::userID) (p'::password) (ou::out) s'::state. ⟦?x = Trans s (Cact (cUser uid p uid' p')) ou s'; ?y = (open s ≠ open s')⟧ ⟹ ?P; ⋀(v::state) (vd::sActt) (vb::out) vc::state. ⟦?x = Trans v (Sact vd) vb vc; ¬ ?y⟧ ⟹ ?P; ⋀(v::state) (ve::userID) (vf::requestInfo) (vb::out) vc::state. ⟦?x = Trans v (Cact (cNUReq ve vf)) vb vc; ¬ ?y⟧ ⟹ ?P; ⋀(v::state) (ve::userID) (vf::password) (vg::postID) (vb::out) vc::state. ⟦?x = Trans v (Cact (cPost ve vf vg)) vb vc; ¬ ?y⟧ ⟹ ?P; ⋀(v::state) (ve::userID) (vf::password) (vg::userID) (vh::requestInfo) (vb::out) vc::state. ⟦?x = Trans v (Cact (cFriendReq ve vf vg vh)) vb vc; ¬ ?y⟧ ⟹ ?P; ⋀(v::state) (vd::uActt) (vb::out) vc::state. ⟦?x = Trans v (Uact vd) vb vc; ¬ ?y⟧ ⟹ ?P; ⋀(v::state) (vd::rActt) (vb::out) vc::state. ⟦?x = Trans v (Ract vd) vb vc; ¬ ?y⟧ ⟹ ?P; ⋀(v::state) (vd::lActt) (vb::out) vc::state. ⟦?x = Trans v (Lact vd) vb vc; ¬ ?y⟧ ⟹ ?P; ⋀(v::state) (vd::comActt) (vb::out) vc::state. ⟦?x = Trans v (COMact vd) vb vc; ¬ ?y⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦φ (?x::(state, act, out) trans); ⋀(s::state) (uid::userID) (p::password) (uid'::userID) (ou::out) s'::state. ⟦?x = Trans s (Cact (cFriend uid p uid')) ou s'; (uid, uid') ∈ {(UID1::userID, UID2::userID), (UID2, UID1)} ∧ ou = outOK ∨ open s ≠ open s'⟧ ⟹ ?P::bool; ⋀(s::state) (uid::userID) (p::password) (uid'::userID) (ou::out) s'::state. ⟦?x = Trans s (Dact (dFriend uid p uid')) ou s'; (uid, uid') ∈ {(UID1, UID2), (UID2, UID1)} ∧ ou = outOK ∨ open s ≠ open s'⟧ ⟹ ?P; ⋀(s::state) (uid::userID) (p::password) (uid'::userID) (p'::password) (ou::out) s'::state. ⟦?x = Trans s (Cact (cUser uid p uid' p')) ou s'; open s ≠ open s'⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦¬ φ (?x::(state, act, out) trans); ⋀(s::state) (uid::userID) (p::password) (uid'::userID) (ou::out) s'::state. ⟦?x = Trans s (Cact (cFriend uid p uid')) ou s'; ¬ ((uid, uid') ∈ {(UID1::userID, UID2::userID), (UID2, UID1)} ∧ ou = outOK ∨ open s ≠ open s')⟧ ⟹ ?P::bool; ⋀(s::state) (uid::userID) (p::password) (uid'::userID) (ou::out) s'::state. ⟦?x = Trans s (Dact (dFriend uid p uid')) ou s'; ¬ ((uid, uid') ∈ {(UID1, UID2), (UID2, UID1)} ∧ ou = outOK ∨ open s ≠ open s')⟧ ⟹ ?P; ⋀(s::state) (uid::userID) (p::password) (uid'::userID) (p'::password) (ou::out) s'::state. ⟦?x = Trans s (Cact (cUser uid p uid' p')) ou s'; ¬ open s ≠ open s'⟧ ⟹ ?P; ⋀(v::state) (vd::sActt) (vb::out) vc::state. ?x = Trans v (Sact vd) vb vc ⟹ ?P; ⋀(v::state) (ve::userID) (vf::requestInfo) (vb::out) vc::state. ?x = Trans v (Cact (cNUReq ve vf)) vb vc ⟹ ?P; ⋀(v::state) (ve::userID) (vf::password) (vg::postID) (vb::out) vc::state. ?x = Trans v (Cact (cPost ve vf vg)) vb vc ⟹ ?P; ⋀(v::state) (ve::userID) (vf::password) (vg::userID) (vh::requestInfo) (vb::out) vc::state. ?x = Trans v (Cact (cFriendReq ve vf vg vh)) vb vc ⟹ ?P; ⋀(v::state) (vd::uActt) (vb::out) vc::state. ?x = Trans v (Uact vd) vb vc ⟹ ?P; ⋀(v::state) (vd::rActt) (vb::out) vc::state. ?x = Trans v (Ract vd) vb vc ⟹ ?P; ⋀(v::state) (vd::lActt) (vb::out) vc::state. ?x = Trans v (Lact vd) vb vc ⟹ ?P; ⋀(v::state) (vd::comActt) (vb::out) vc::state. ?x = Trans v (COMact vd) vb vc ⟹ ?P⟧ ⟹ ?P›*) disjE (*‹⟦(?P::bool) ∨ (?Q::bool); ?P ⟹ ?R::bool; ?Q ⟹ ?R⟧ ⟹ ?R›*) conjE (*‹⟦(?P::bool) ∧ (?Q::bool); ⟦?P; ?Q⟧ ⟹ ?R::bool⟧ ⟹ ?R›*))
(*goals:
1. ‹⋀(sa::state) (uid::userID) (p::password) (uid'::userID) (oua::out) s'a::state. ⟦⋀(uid::userID) (p::password) uid'::userID. ⟦(a::act) = Cact (cFriend uid p uid'); (ou::out) = outOK; f (Trans (s::state) a ou (s'::state)) = FrVal True; uid = (UID1::userID) ∧ uid' = (UID2::userID) ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis::bool; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Cact (cFriend uid p uid'); uid ∈ (UIDs::userID set) ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) (uid'::userID) p'::password. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Cact (cFriend uid p uid')) oua s'a; (uid, uid') ∈ {(UID1, UID2), (UID2, UID1)}; oua = outOK⟧ ⟹ thesis›
2. ‹⋀(sa::state) (uid::userID) (p::password) (uid'::userID) (oua::out) s'a::state. ⟦⋀(uid::userID) (p::password) uid'::userID. ⟦(a::act) = Cact (cFriend uid p uid'); (ou::out) = outOK; f (Trans (s::state) a ou (s'::state)) = FrVal True; uid = (UID1::userID) ∧ uid' = (UID2::userID) ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis::bool; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Cact (cFriend uid p uid'); uid ∈ (UIDs::userID set) ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) (uid'::userID) p'::password. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Cact (cFriend uid p uid')) oua s'a; open sa ≠ open s'a⟧ ⟹ thesis›
3. ‹⋀(sa::state) (uid::userID) (p::password) (uid'::userID) (oua::out) s'a::state. ⟦⋀(uid::userID) (p::password) uid'::userID. ⟦(a::act) = Cact (cFriend uid p uid'); (ou::out) = outOK; f (Trans (s::state) a ou (s'::state)) = FrVal True; uid = (UID1::userID) ∧ uid' = (UID2::userID) ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis::bool; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Cact (cFriend uid p uid'); uid ∈ (UIDs::userID set) ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) (uid'::userID) p'::password. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Dact (dFriend uid p uid')) oua s'a; (uid, uid') ∈ {(UID1, UID2), (UID2, UID1)}; oua = outOK⟧ ⟹ thesis›
4. ‹⋀(sa::state) (uid::userID) (p::password) (uid'::userID) (oua::out) s'a::state. ⟦⋀(uid::userID) (p::password) uid'::userID. ⟦(a::act) = Cact (cFriend uid p uid'); (ou::out) = outOK; f (Trans (s::state) a ou (s'::state)) = FrVal True; uid = (UID1::userID) ∧ uid' = (UID2::userID) ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis::bool; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Cact (cFriend uid p uid'); uid ∈ (UIDs::userID set) ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) (uid'::userID) p'::password. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Dact (dFriend uid p uid')) oua s'a; open sa ≠ open s'a⟧ ⟹ thesis›
5. ‹⋀(sa::state) (uid::userID) (p::password) (uid'::userID) (p'::password) (oua::out) s'a::state. ⟦⋀(uid::userID) (p::password) uid'::userID. ⟦(a::act) = Cact (cFriend uid p uid'); (ou::out) = outOK; f (Trans (s::state) a ou (s'::state)) = FrVal True; uid = (UID1::userID) ∧ uid' = (UID2::userID) ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis::bool; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Cact (cFriend uid p uid'); uid ∈ (UIDs::userID set) ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) (uid'::userID) p'::password. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Cact (cUser uid p uid' p')) oua s'a; open sa ≠ open s'a⟧ ⟹ thesis›*)
fix s1 and uid and p and uid' and ou1 and s1'
assume "(uid,uid') ∈ {(UID1,UID2), (UID2,UID1)}" and ou: "ou1 = outOK" and "?trn = Trans s1 (Cact (cFriend uid p uid')) ou1 s1'" (*‹(uid::userID, uid'::userID) ∈ {(UID1::userID, UID2::userID), (UID2, UID1)}› ‹(ou1::out) = outOK› ‹Trans (s::state) (a::act) (ou::out) (s'::state) = Trans (s1::state) (Cact (cFriend (uid::userID) (p::password) (uid'::userID))) (ou1::out) (s1'::state)›*)
then have trn: "a = Cact (cFriend uid p uid')" "s = s1" "s' = s1'" "ou = ou1" and uids: "uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1"
using UID1_UID2 (*‹UID1 ≠ UID2›*) apply -
(*goals:
1. ‹⟦(uid, uid') ∈ {(UID1, UID2), (UID2, UID1)}; ou1 = outOK; Trans s a ou s' = Trans s1 (Cact (cFriend uid p uid')) ou1 s1'; UID1 ≠ UID2⟧ ⟹ a = Cact (cFriend uid p uid')›
2. ‹⟦(uid, uid') ∈ {(UID1, UID2), (UID2, UID1)}; ou1 = outOK; Trans s a ou s' = Trans s1 (Cact (cFriend uid p uid')) ou1 s1'; UID1 ≠ UID2⟧ ⟹ s = s1›
3. ‹⟦(uid, uid') ∈ {(UID1, UID2), (UID2, UID1)}; ou1 = outOK; Trans s a ou s' = Trans s1 (Cact (cFriend uid p uid')) ou1 s1'; UID1 ≠ UID2⟧ ⟹ s' = s1'›
4. ‹⟦(uid, uid') ∈ {(UID1, UID2), (UID2, UID1)}; ou1 = outOK; Trans s a ou s' = Trans s1 (Cact (cFriend uid p uid')) ou1 s1'; UID1 ≠ UID2⟧ ⟹ ou = ou1›
5. ‹⟦(uid, uid') ∈ {(UID1, UID2), (UID2, UID1)}; ou1 = outOK; Trans s a ou s' = Trans s1 (Cact (cFriend uid p uid')) ou1 s1'; UID1 ≠ UID2⟧ ⟹ uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .
then show thesis
using ou (*‹ou1 = outOK›*) uids (*‹uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1›*) trn (*‹a = Cact (cFriend uid p uid')› ‹s = s1› ‹s' = s1'› ‹ou = ou1›*) step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) UID1_UID2_UIDs (*‹{UID1::userID, UID2::userID} ∩ (UIDs::userID set) = {}›*) UID1_UID2 (*‹UID1 ≠ UID2›*) reach_distinct_friends_reqs[OF rs] (*‹distinct (friendIDs s ?uid)› ‹distinct (pendingFReqs (s::state) (?uid::userID))› ‹distinct (sentOuterFriendIDs s ?uid)› ‹distinct (recvOuterFriendIDs s ?uid)› ‹(?uid'::userID) ∈∈ pendingFReqs (s::state) (?uid::userID) ⟹ ?uid' ∉ set (friendIDs s ?uid)› ‹?uid' ∈∈ pendingFReqs s ?uid ⟹ ?uid ∉ set (friendIDs s ?uid')›*) apply (intro Friend[of uid p uid'] (*‹⟦a = Cact (cFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal True; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis›*))
(*goals:
1. ‹⟦(a::act) = Cact (cFriend (uid::userID) (p::password) (uid'::userID)); (s::state) = (s1::state); (s'::state) = (s1'::state); (ou::out) = (ou1::out); uid = (UID1::userID) ∧ uid' = (UID2::userID) ∨ uid = UID2 ∧ uid' = UID1; ou1 = outOK; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; a = Cact (cFriend uid p uid'); s = s1; s' = s1'; ou = ou1; step s a = (ou, s'); {UID1, UID2} ∩ (UIDs::userID set) = {}; UID1 ≠ UID2; ⋀uid::userID. distinct (friendIDs s uid); ⋀uid::userID. distinct (pendingFReqs s uid); ⋀uid::userID. distinct (sentOuterFriendIDs s uid); ⋀uid::userID. distinct (recvOuterFriendIDs s uid); ⋀(uid'::userID) uid::userID. uid' ∈∈ pendingFReqs s uid ⟹ uid' ∉ set (friendIDs s uid); ⋀(uid'::userID) uid::userID. uid' ∈∈ pendingFReqs s uid ⟹ uid ∉ set (friendIDs s uid')⟧ ⟹ a = Cact (cFriend uid p uid')›
2. ‹⟦(a::act) = Cact (cFriend (uid::userID) (p::password) (uid'::userID)); (s::state) = (s1::state); (s'::state) = (s1'::state); (ou::out) = (ou1::out); uid = (UID1::userID) ∧ uid' = (UID2::userID) ∨ uid = UID2 ∧ uid' = UID1; ou1 = outOK; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; a = Cact (cFriend uid p uid'); s = s1; s' = s1'; ou = ou1; step s a = (ou, s'); {UID1, UID2} ∩ (UIDs::userID set) = {}; UID1 ≠ UID2; ⋀uid::userID. distinct (friendIDs s uid); ⋀uid::userID. distinct (pendingFReqs s uid); ⋀uid::userID. distinct (sentOuterFriendIDs s uid); ⋀uid::userID. distinct (recvOuterFriendIDs s uid); ⋀(uid'::userID) uid::userID. uid' ∈∈ pendingFReqs s uid ⟹ uid' ∉ set (friendIDs s uid); ⋀(uid'::userID) uid::userID. uid' ∈∈ pendingFReqs s uid ⟹ uid ∉ set (friendIDs s uid')⟧ ⟹ ou = outOK›
3. ‹⟦(a::act) = Cact (cFriend (uid::userID) (p::password) (uid'::userID)); (s::state) = (s1::state); (s'::state) = (s1'::state); (ou::out) = (ou1::out); uid = (UID1::userID) ∧ uid' = (UID2::userID) ∨ uid = UID2 ∧ uid' = UID1; ou1 = outOK; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; a = Cact (cFriend uid p uid'); s = s1; s' = s1'; ou = ou1; step s a = (ou, s'); {UID1, UID2} ∩ (UIDs::userID set) = {}; UID1 ≠ UID2; ⋀uid::userID. distinct (friendIDs s uid); ⋀uid::userID. distinct (pendingFReqs s uid); ⋀uid::userID. distinct (sentOuterFriendIDs s uid); ⋀uid::userID. distinct (recvOuterFriendIDs s uid); ⋀(uid'::userID) uid::userID. uid' ∈∈ pendingFReqs s uid ⟹ uid' ∉ set (friendIDs s uid); ⋀(uid'::userID) uid::userID. uid' ∈∈ pendingFReqs s uid ⟹ uid ∉ set (friendIDs s uid')⟧ ⟹ f (Trans s a ou s') = FrVal True›
4. ‹⟦(a::act) = Cact (cFriend (uid::userID) (p::password) (uid'::userID)); (s::state) = (s1::state); (s'::state) = (s1'::state); (ou::out) = (ou1::out); uid = (UID1::userID) ∧ uid' = (UID2::userID) ∨ uid = UID2 ∧ uid' = UID1; ou1 = outOK; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; a = Cact (cFriend uid p uid'); s = s1; s' = s1'; ou = ou1; step s a = (ou, s'); {UID1, UID2} ∩ (UIDs::userID set) = {}; UID1 ≠ UID2; ⋀uid::userID. distinct (friendIDs s uid); ⋀uid::userID. distinct (pendingFReqs s uid); ⋀uid::userID. distinct (sentOuterFriendIDs s uid); ⋀uid::userID. distinct (recvOuterFriendIDs s uid); ⋀(uid'::userID) uid::userID. uid' ∈∈ pendingFReqs s uid ⟹ uid' ∉ set (friendIDs s uid); ⋀(uid'::userID) uid::userID. uid' ∈∈ pendingFReqs s uid ⟹ uid ∉ set (friendIDs s uid')⟧ ⟹ uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1›
5. ‹⟦(a::act) = Cact (cFriend (uid::userID) (p::password) (uid'::userID)); (s::state) = (s1::state); (s'::state) = (s1'::state); (ou::out) = (ou1::out); uid = (UID1::userID) ∧ uid' = (UID2::userID) ∨ uid = UID2 ∧ uid' = UID1; ou1 = outOK; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; a = Cact (cFriend uid p uid'); s = s1; s' = s1'; ou = ou1; step s a = (ou, s'); {UID1, UID2} ∩ (UIDs::userID set) = {}; UID1 ≠ UID2; ⋀uid::userID. distinct (friendIDs s uid); ⋀uid::userID. distinct (pendingFReqs s uid); ⋀uid::userID. distinct (sentOuterFriendIDs s uid); ⋀uid::userID. distinct (recvOuterFriendIDs s uid); ⋀(uid'::userID) uid::userID. uid' ∈∈ pendingFReqs s uid ⟹ uid' ∉ set (friendIDs s uid); ⋀(uid'::userID) uid::userID. uid' ∈∈ pendingFReqs s uid ⟹ uid ∉ set (friendIDs s uid')⟧ ⟹ IDsOK s [UID1, UID2] [] [] []›
6. ‹⟦(a::act) = Cact (cFriend (uid::userID) (p::password) (uid'::userID)); (s::state) = (s1::state); (s'::state) = (s1'::state); (ou::out) = (ou1::out); uid = (UID1::userID) ∧ uid' = (UID2::userID) ∨ uid = UID2 ∧ uid' = UID1; ou1 = outOK; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; a = Cact (cFriend uid p uid'); s = s1; s' = s1'; ou = ou1; step s a = (ou, s'); {UID1, UID2} ∩ (UIDs::userID set) = {}; UID1 ≠ UID2; ⋀uid::userID. distinct (friendIDs s uid); ⋀uid::userID. distinct (pendingFReqs s uid); ⋀uid::userID. distinct (sentOuterFriendIDs s uid); ⋀uid::userID. distinct (recvOuterFriendIDs s uid); ⋀(uid'::userID) uid::userID. uid' ∈∈ pendingFReqs s uid ⟹ uid' ∉ set (friendIDs s uid); ⋀(uid'::userID) uid::userID. uid' ∈∈ pendingFReqs s uid ⟹ uid ∉ set (friendIDs s uid')⟧ ⟹ ¬ friends12 s›
7. ‹⟦(a::act) = Cact (cFriend (uid::userID) (p::password) (uid'::userID)); (s::state) = (s1::state); (s'::state) = (s1'::state); (ou::out) = (ou1::out); uid = (UID1::userID) ∧ uid' = (UID2::userID) ∨ uid = UID2 ∧ uid' = UID1; ou1 = outOK; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; a = Cact (cFriend uid p uid'); s = s1; s' = s1'; ou = ou1; step s a = (ou, s'); {UID1, UID2} ∩ (UIDs::userID set) = {}; UID1 ≠ UID2; ⋀uid::userID. distinct (friendIDs s uid); ⋀uid::userID. distinct (pendingFReqs s uid); ⋀uid::userID. distinct (sentOuterFriendIDs s uid); ⋀uid::userID. distinct (recvOuterFriendIDs s uid); ⋀(uid'::userID) uid::userID. uid' ∈∈ pendingFReqs s uid ⟹ uid' ∉ set (friendIDs s uid); ⋀(uid'::userID) uid::userID. uid' ∈∈ pendingFReqs s uid ⟹ uid ∉ set (friendIDs s uid')⟧ ⟹ friends12 s'›
discuss goal 1*)
apply ((auto simp add: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*) friends12_def (*‹friends12 ?s ≡ UID1 ∈∈ friendIDs ?s UID2 ∧ UID2 ∈∈ friendIDs ?s UID1›*))[1])
(*discuss goal 2*)
apply ((auto simp add: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*) friends12_def (*‹friends12 ?s ≡ UID1 ∈∈ friendIDs ?s UID2 ∧ UID2 ∈∈ friendIDs ?s UID1›*))[1])
(*discuss goal 3*)
apply ((auto simp add: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*) friends12_def (*‹friends12 ?s ≡ UID1 ∈∈ friendIDs ?s UID2 ∧ UID2 ∈∈ friendIDs ?s UID1›*))[1])
(*discuss goal 4*)
apply ((auto simp add: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*) friends12_def (*‹friends12 ?s ≡ UID1 ∈∈ friendIDs ?s UID2 ∧ UID2 ∈∈ friendIDs ?s UID1›*))[1])
(*discuss goal 5*)
apply ((auto simp add: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*) friends12_def (*‹friends12 ?s ≡ UID1 ∈∈ friendIDs ?s UID2 ∧ UID2 ∈∈ friendIDs ?s UID1›*))[1])
(*discuss goal 6*)
apply ((auto simp add: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*) friends12_def (*‹friends12 ?s ≡ UID1 ∈∈ friendIDs ?s UID2 ∧ UID2 ∈∈ friendIDs ?s UID1›*))[1])
(*discuss goal 7*)
apply ((auto simp add: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*) friends12_def (*‹friends12 ?s ≡ UID1 ∈∈ friendIDs ?s UID2 ∧ UID2 ∈∈ friendIDs ?s UID1›*))[1])
(*proven 7 subgoals*) .
next
(*goals:
1. ‹⋀sa uid p uid' oua s'a. ⟦⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal True; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid' p'. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Cact (cFriend uid p uid')) oua s'a; open sa ≠ open s'a⟧ ⟹ thesis›
2. ‹⋀sa uid p uid' oua s'a. ⟦⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal True; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid' p'. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Dact (dFriend uid p uid')) oua s'a; (uid, uid') ∈ {(UID1, UID2), (UID2, UID1)}; oua = outOK⟧ ⟹ thesis›
3. ‹⋀sa uid p uid' oua s'a. ⟦⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal True; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid' p'. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Dact (dFriend uid p uid')) oua s'a; open sa ≠ open s'a⟧ ⟹ thesis›
4. ‹⋀sa uid p uid' p' oua s'a. ⟦⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal True; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid' p'. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Cact (cUser uid p uid' p')) oua s'a; open sa ≠ open s'a⟧ ⟹ thesis›*)
fix s1 and uid and p and uid' and ou1 and s1'
assume op: "open s1 ≠ open s1'" and "?trn = Trans s1 (Cact (cFriend uid p uid')) ou1 s1'" (*‹open (s1::state) ≠ open (s1'::state)› ‹Trans (s::state) (a::act) (ou::out) (s'::state) = Trans (s1::state) (Cact (cFriend (uid::userID) (p::password) (uid'::userID))) (ou1::out) (s1'::state)›*)
then have trn: "open s ≠ open s'" "s = s1" "s' = s1'" "ou = ou1" and a: "a = Cact (cFriend uid p uid')"
apply -
(*goals:
1. ‹⟦open s1 ≠ open s1'; Trans s a ou s' = Trans s1 (Cact (cFriend uid p uid')) ou1 s1'⟧ ⟹ open s ≠ open s'›
2. ‹⟦open s1 ≠ open s1'; Trans s a ou s' = Trans s1 (Cact (cFriend uid p uid')) ou1 s1'⟧ ⟹ s = s1›
3. ‹⟦open s1 ≠ open s1'; Trans s a ou s' = Trans s1 (Cact (cFriend uid p uid')) ou1 s1'⟧ ⟹ s' = s1'›
4. ‹⟦open s1 ≠ open s1'; Trans s a ou s' = Trans s1 (Cact (cFriend uid p uid')) ou1 s1'⟧ ⟹ ou = ou1›
5. ‹⟦open s1 ≠ open s1'; Trans s a ou s' = Trans s1 (Cact (cFriend uid p uid')) ou1 s1'⟧ ⟹ a = Cact (cFriend uid p uid')›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .
with step (*‹step s a = (ou, s')›*) have uids: "(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧
ou = outOK ∧ ¬openByF s ∧ openByF s' ∧ ¬openByA s ∧ ¬openByA s'"
apply (cases rule: step_open_cases (*‹⟦step ?s ?a = (?ou, ?s'); open ?s ≠ open ?s'; ⋀uid p uid' p'. ⟦?a = Cact (cUser uid p uid' p'); uid' = UID1 ∨ uid' = UID2; ?ou = outOK; p = pass ?s uid; openByA ?s; ¬ openByA ?s'; ¬ openByF ?s; ¬ openByF ?s'⟧ ⟹ ?thesis; ⋀uid p uid'. ⟦?a = Cact (cFriend uid p uid'); ?ou = outOK; p = pass ?s uid; uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs; openByF ?s'; ¬ openByF ?s; ¬ openByA ?s; ¬ openByA ?s'⟧ ⟹ ?thesis; ⋀uid p uid'. ⟦?a = Dact (dFriend uid p uid'); ?ou = outOK; p = pass ?s uid; uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs; openByF ?s; ¬ openByF ?s'; ¬ openByA ?s; ¬ openByA ?s'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⋀(uida::userID) (pa::password) (uid'a::userID) p'::password. ⟦(s::state) = (s1::state); (s'::state) = (s1'::state); (ou::out) = (ou1::out); (a::act) = Cact (cFriend (uid::userID) (p::password) (uid'::userID)); a = Cact (cUser uida pa uid'a p'); uid'a = (UID1::userID) ∨ uid'a = (UID2::userID); ou = outOK; pa = pass s uida; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'⟧ ⟹ (uid ∈ (UIDs::userID set) ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ ¬ openByF s ∧ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'›
2. ‹⋀(uida::userID) (pa::password) uid'a::userID. ⟦(s::state) = (s1::state); (s'::state) = (s1'::state); (ou::out) = (ou1::out); (a::act) = Cact (cFriend (uid::userID) (p::password) (uid'::userID)); a = Cact (cFriend uida pa uid'a); ou = outOK; pa = pass s uida; uida ∈ (UIDs::userID set) ∧ uid'a ∈ {UID1::userID, UID2::userID} ∨ uida ∈ {UID1, UID2} ∧ uid'a ∈ UIDs; openByF s'; ¬ openByF s; ¬ openByA s; ¬ openByA s'⟧ ⟹ (uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ ¬ openByF s ∧ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'›
3. ‹⋀(uida::userID) (pa::password) uid'a::userID. ⟦(s::state) = (s1::state); (s'::state) = (s1'::state); (ou::out) = (ou1::out); (a::act) = Cact (cFriend (uid::userID) (p::password) (uid'::userID)); a = Dact (dFriend uida pa uid'a); ou = outOK; pa = pass s uida; uida ∈ (UIDs::userID set) ∧ uid'a ∈ {UID1::userID, UID2::userID} ∨ uida ∈ {UID1, UID2} ∧ uid'a ∈ UIDs; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ (uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ ¬ openByF s ∧ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
then show thesis
using a (*‹a = Cact (cFriend uid p uid')›*) UID1_UID2_UIDs (*‹{UID1::userID, UID2::userID} ∩ (UIDs::userID set) = {}›*) apply (intro OpenF (*‹⟦a = Cact (cFriend ?uid1 ?p1 ?uid'1); ?uid1 ∈ UIDs ∧ ?uid'1 ∈ {UID1, UID2} ∨ ?uid'1 ∈ UIDs ∧ ?uid1 ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis›*))
(*goals:
1. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ ¬ openByF s ∧ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Cact (cFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ a = Cact (cFriend ?uid4 ?p4 ?uid'4)›
2. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ ¬ openByF s ∧ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Cact (cFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ ?uid4 ∈ UIDs ∧ ?uid'4 ∈ {UID1, UID2} ∨ ?uid'4 ∈ UIDs ∧ ?uid4 ∈ {UID1, UID2}›
3. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ ¬ openByF s ∧ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Cact (cFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ ou = outOK›
4. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ ¬ openByF s ∧ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Cact (cFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ f (Trans s a ou s') = OVal True›
5. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ ¬ openByF s ∧ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Cact (cFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ ¬ openByF s›
6. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ ¬ openByF s ∧ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Cact (cFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ openByF s'›
7. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ ¬ openByF s ∧ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Cact (cFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ ¬ openByA s›
8. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ ¬ openByF s ∧ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Cact (cFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ ¬ openByA s'›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*discuss goal 6*)
apply ((auto)[1])
(*discuss goal 7*)
apply ((auto)[1])
(*discuss goal 8*)
apply ((auto)[1])
(*proven 8 subgoals*) .
next
(*goals:
1. ‹⋀sa uid p uid' oua s'a. ⟦⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal True; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid' p'. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Dact (dFriend uid p uid')) oua s'a; (uid, uid') ∈ {(UID1, UID2), (UID2, UID1)}; oua = outOK⟧ ⟹ thesis›
2. ‹⋀sa uid p uid' oua s'a. ⟦⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal True; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid' p'. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Dact (dFriend uid p uid')) oua s'a; open sa ≠ open s'a⟧ ⟹ thesis›
3. ‹⋀sa uid p uid' p' oua s'a. ⟦⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal True; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid' p'. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Cact (cUser uid p uid' p')) oua s'a; open sa ≠ open s'a⟧ ⟹ thesis›*)
fix s1 and uid and p and uid' and ou1 and s1'
assume "(uid,uid') ∈ {(UID1,UID2), (UID2,UID1)}" and ou: "ou1 = outOK" and "?trn = Trans s1 (Dact (dFriend uid p uid')) ou1 s1'" (*‹(uid::userID, uid'::userID) ∈ {(UID1::userID, UID2::userID), (UID2, UID1)}› ‹(ou1::out) = outOK› ‹Trans (s::state) (a::act) (ou::out) (s'::state) = Trans (s1::state) (Dact (dFriend (uid::userID) (p::password) (uid'::userID))) (ou1::out) (s1'::state)›*)
then have trn: "a = Dact (dFriend uid p uid')" "s = s1" "s' = s1'" "ou = ou1" and uids: "uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1"
using UID1_UID2 (*‹UID1 ≠ UID2›*) apply -
(*goals:
1. ‹⟦(uid, uid') ∈ {(UID1, UID2), (UID2, UID1)}; ou1 = outOK; Trans s a ou s' = Trans s1 (Dact (dFriend uid p uid')) ou1 s1'; UID1 ≠ UID2⟧ ⟹ a = Dact (dFriend uid p uid')›
2. ‹⟦(uid, uid') ∈ {(UID1, UID2), (UID2, UID1)}; ou1 = outOK; Trans s a ou s' = Trans s1 (Dact (dFriend uid p uid')) ou1 s1'; UID1 ≠ UID2⟧ ⟹ s = s1›
3. ‹⟦(uid, uid') ∈ {(UID1, UID2), (UID2, UID1)}; ou1 = outOK; Trans s a ou s' = Trans s1 (Dact (dFriend uid p uid')) ou1 s1'; UID1 ≠ UID2⟧ ⟹ s' = s1'›
4. ‹⟦(uid, uid') ∈ {(UID1, UID2), (UID2, UID1)}; ou1 = outOK; Trans s a ou s' = Trans s1 (Dact (dFriend uid p uid')) ou1 s1'; UID1 ≠ UID2⟧ ⟹ ou = ou1›
5. ‹⟦(uid, uid') ∈ {(UID1, UID2), (UID2, UID1)}; ou1 = outOK; Trans s a ou s' = Trans s1 (Dact (dFriend uid p uid')) ou1 s1'; UID1 ≠ UID2⟧ ⟹ uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .
then show thesis
using step (*‹step s a = (ou, s')›*) ou (*‹ou1 = outOK›*) reach_friendIDs_symmetric[OF rs] (*‹(?uID1.0 ∈∈ friendIDs s ?uID2.0) = (?uID2.0 ∈∈ friendIDs s ?uID1.0)›*) apply (intro Unfriend (*‹⟦(a::act) = Dact (dFriend (?uid1::userID) (?p1::password) (?uid'1::userID)); (ou::out) = outOK; f (Trans (s::state) a ou (s'::state)) = FrVal False; ?uid1 = (UID1::userID) ∧ ?uid'1 = (UID2::userID) ∨ ?uid1 = UID2 ∧ ?uid'1 = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis::bool›*))
(*goals:
1. ‹⟦a = Dact (dFriend uid p uid'); s = s1; s' = s1'; ou = ou1; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; step s a = (ou, s'); ou1 = outOK; ⋀uID1 uID2. (uID1 ∈∈ friendIDs s uID2) = (uID2 ∈∈ friendIDs s uID1)⟧ ⟹ a = Dact (dFriend ?uid10 ?p10 ?uid'10)›
2. ‹⟦a = Dact (dFriend uid p uid'); s = s1; s' = s1'; ou = ou1; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; step s a = (ou, s'); ou1 = outOK; ⋀uID1 uID2. (uID1 ∈∈ friendIDs s uID2) = (uID2 ∈∈ friendIDs s uID1)⟧ ⟹ ou = outOK›
3. ‹⟦a = Dact (dFriend uid p uid'); s = s1; s' = s1'; ou = ou1; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; step s a = (ou, s'); ou1 = outOK; ⋀uID1 uID2. (uID1 ∈∈ friendIDs s uID2) = (uID2 ∈∈ friendIDs s uID1)⟧ ⟹ f (Trans s a ou s') = FrVal False›
4. ‹⟦a = Dact (dFriend uid p uid'); s = s1; s' = s1'; ou = ou1; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; step s a = (ou, s'); ou1 = outOK; ⋀uID1 uID2. (uID1 ∈∈ friendIDs s uID2) = (uID2 ∈∈ friendIDs s uID1)⟧ ⟹ ?uid10 = UID1 ∧ ?uid'10 = UID2 ∨ ?uid10 = UID2 ∧ ?uid'10 = UID1›
5. ‹⟦a = Dact (dFriend uid p uid'); s = s1; s' = s1'; ou = ou1; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; step s a = (ou, s'); ou1 = outOK; ⋀uID1 uID2. (uID1 ∈∈ friendIDs s uID2) = (uID2 ∈∈ friendIDs s uID1)⟧ ⟹ IDsOK s [UID1, UID2] [] [] []›
6. ‹⟦a = Dact (dFriend uid p uid'); s = s1; s' = s1'; ou = ou1; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; step s a = (ou, s'); ou1 = outOK; ⋀uID1 uID2. (uID1 ∈∈ friendIDs s uID2) = (uID2 ∈∈ friendIDs s uID1)⟧ ⟹ friends12 s›
7. ‹⟦a = Dact (dFriend uid p uid'); s = s1; s' = s1'; ou = ou1; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; step s a = (ou, s'); ou1 = outOK; ⋀uID1 uID2. (uID1 ∈∈ friendIDs s uID2) = (uID2 ∈∈ friendIDs s uID1)⟧ ⟹ ¬ friends12 s'›
discuss goal 1*)
apply ((auto simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*) friends12_def (*‹friends12 ?s ≡ UID1 ∈∈ friendIDs ?s UID2 ∧ UID2 ∈∈ friendIDs ?s UID1›*))[1])
(*discuss goal 2*)
apply ((auto simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*) friends12_def (*‹friends12 ?s ≡ UID1 ∈∈ friendIDs ?s UID2 ∧ UID2 ∈∈ friendIDs ?s UID1›*))[1])
(*discuss goal 3*)
apply ((auto simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*) friends12_def (*‹friends12 ?s ≡ UID1 ∈∈ friendIDs ?s UID2 ∧ UID2 ∈∈ friendIDs ?s UID1›*))[1])
(*discuss goal 4*)
apply ((auto simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*) friends12_def (*‹friends12 ?s ≡ UID1 ∈∈ friendIDs ?s UID2 ∧ UID2 ∈∈ friendIDs ?s UID1›*))[1])
(*discuss goal 5*)
apply ((auto simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*) friends12_def (*‹friends12 ?s ≡ UID1 ∈∈ friendIDs ?s UID2 ∧ UID2 ∈∈ friendIDs ?s UID1›*))[1])
(*discuss goal 6*)
apply ((auto simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*) friends12_def (*‹friends12 ?s ≡ UID1 ∈∈ friendIDs ?s UID2 ∧ UID2 ∈∈ friendIDs ?s UID1›*))[1])
(*discuss goal 7*)
apply ((auto simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*) friends12_def (*‹friends12 ?s ≡ UID1 ∈∈ friendIDs ?s UID2 ∧ UID2 ∈∈ friendIDs ?s UID1›*))[1])
(*proven 7 subgoals*) .
next
(*goals:
1. ‹⋀(sa::state) (uid::userID) (p::password) (uid'::userID) (oua::out) s'a::state. ⟦⋀(uid::userID) (p::password) uid'::userID. ⟦(a::act) = Cact (cFriend uid p uid'); (ou::out) = outOK; f (Trans (s::state) a ou (s'::state)) = FrVal True; uid = (UID1::userID) ∧ uid' = (UID2::userID) ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis::bool; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Cact (cFriend uid p uid'); uid ∈ (UIDs::userID set) ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) (uid'::userID) p'::password. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Dact (dFriend uid p uid')) oua s'a; open sa ≠ open s'a⟧ ⟹ thesis›
2. ‹⋀(sa::state) (uid::userID) (p::password) (uid'::userID) (p'::password) (oua::out) s'a::state. ⟦⋀(uid::userID) (p::password) uid'::userID. ⟦(a::act) = Cact (cFriend uid p uid'); (ou::out) = outOK; f (Trans (s::state) a ou (s'::state)) = FrVal True; uid = (UID1::userID) ∧ uid' = (UID2::userID) ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis::bool; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Cact (cFriend uid p uid'); uid ∈ (UIDs::userID set) ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) uid'::userID. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀(uid::userID) (p::password) (uid'::userID) p'::password. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Cact (cUser uid p uid' p')) oua s'a; open sa ≠ open s'a⟧ ⟹ thesis›*)
fix s1 and uid and p and uid' and ou1 and s1'
assume op: "open s1 ≠ open s1'" and "?trn = Trans s1 (Dact (dFriend uid p uid')) ou1 s1'" (*‹open (s1::state) ≠ open (s1'::state)› ‹Trans (s::state) (a::act) (ou::out) (s'::state) = Trans (s1::state) (Dact (dFriend (uid::userID) (p::password) (uid'::userID))) (ou1::out) (s1'::state)›*)
then have trn: "open s ≠ open s'" "s = s1" "s' = s1'" "ou = ou1" and a: "a = Dact (dFriend uid p uid')"
apply -
(*goals:
1. ‹⟦open s1 ≠ open s1'; Trans s a ou s' = Trans s1 (Dact (dFriend uid p uid')) ou1 s1'⟧ ⟹ open s ≠ open s'›
2. ‹⟦open s1 ≠ open s1'; Trans s a ou s' = Trans s1 (Dact (dFriend uid p uid')) ou1 s1'⟧ ⟹ s = s1›
3. ‹⟦open s1 ≠ open s1'; Trans s a ou s' = Trans s1 (Dact (dFriend uid p uid')) ou1 s1'⟧ ⟹ s' = s1'›
4. ‹⟦open s1 ≠ open s1'; Trans s a ou s' = Trans s1 (Dact (dFriend uid p uid')) ou1 s1'⟧ ⟹ ou = ou1›
5. ‹⟦open s1 ≠ open s1'; Trans s a ou s' = Trans s1 (Dact (dFriend uid p uid')) ou1 s1'⟧ ⟹ a = Dact (dFriend uid p uid')›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .
with step (*‹step s a = (ou, s')›*) have uids: "(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧
ou = outOK ∧ openByF s ∧ (¬openByF s') ∧ (¬openByA s) ∧ (¬openByA s')"
apply (cases rule: step_open_cases (*‹⟦step ?s ?a = (?ou, ?s'); open ?s ≠ open ?s'; ⋀uid p uid' p'. ⟦?a = Cact (cUser uid p uid' p'); uid' = UID1 ∨ uid' = UID2; ?ou = outOK; p = pass ?s uid; openByA ?s; ¬ openByA ?s'; ¬ openByF ?s; ¬ openByF ?s'⟧ ⟹ ?thesis; ⋀uid p uid'. ⟦?a = Cact (cFriend uid p uid'); ?ou = outOK; p = pass ?s uid; uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs; openByF ?s'; ¬ openByF ?s; ¬ openByA ?s; ¬ openByA ?s'⟧ ⟹ ?thesis; ⋀uid p uid'. ⟦?a = Dact (dFriend uid p uid'); ?ou = outOK; p = pass ?s uid; uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs; openByF ?s; ¬ openByF ?s'; ¬ openByA ?s; ¬ openByA ?s'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⋀uida pa uid'a p'. ⟦s = s1; s' = s1'; ou = ou1; a = Dact (dFriend uid p uid'); a = Cact (cUser uida pa uid'a p'); uid'a = UID1 ∨ uid'a = UID2; ou = outOK; pa = pass s uida; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'⟧ ⟹ (uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ openByF s ∧ ¬ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'›
2. ‹⋀uida pa uid'a. ⟦s = s1; s' = s1'; ou = ou1; a = Dact (dFriend uid p uid'); a = Cact (cFriend uida pa uid'a); ou = outOK; pa = pass s uida; uida ∈ UIDs ∧ uid'a ∈ {UID1, UID2} ∨ uida ∈ {UID1, UID2} ∧ uid'a ∈ UIDs; openByF s'; ¬ openByF s; ¬ openByA s; ¬ openByA s'⟧ ⟹ (uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ openByF s ∧ ¬ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'›
3. ‹⋀uida pa uid'a. ⟦s = s1; s' = s1'; ou = ou1; a = Dact (dFriend uid p uid'); a = Dact (dFriend uida pa uid'a); ou = outOK; pa = pass s uida; uida ∈ UIDs ∧ uid'a ∈ {UID1, UID2} ∨ uida ∈ {UID1, UID2} ∧ uid'a ∈ UIDs; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ (uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ openByF s ∧ ¬ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
then show thesis
using a (*‹a = Dact (dFriend uid p uid')›*) UID1_UID2_UIDs (*‹{UID1, UID2} ∩ UIDs = {}›*) apply (intro CloseF (*‹⟦a = Dact (dFriend ?uid1 ?p1 ?uid'1); ?uid1 ∈ UIDs ∧ ?uid'1 ∈ {UID1, UID2} ∨ ?uid'1 ∈ UIDs ∧ ?uid1 ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis›*))
(*goals:
1. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ openByF s ∧ ¬ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Dact (dFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ a = Dact (dFriend ?uid4 ?p4 ?uid'4)›
2. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ openByF s ∧ ¬ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Dact (dFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ ?uid4 ∈ UIDs ∧ ?uid'4 ∈ {UID1, UID2} ∨ ?uid'4 ∈ UIDs ∧ ?uid4 ∈ {UID1, UID2}›
3. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ openByF s ∧ ¬ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Dact (dFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ ou = outOK›
4. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ openByF s ∧ ¬ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Dact (dFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ f (Trans s a ou s') = OVal False›
5. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ openByF s ∧ ¬ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Dact (dFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ openByF s›
6. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ openByF s ∧ ¬ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Dact (dFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ ¬ openByF s'›
7. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ openByF s ∧ ¬ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Dact (dFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ ¬ openByA s›
8. ‹⟦(uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs) ∧ ou = outOK ∧ openByF s ∧ ¬ openByF s' ∧ ¬ openByA s ∧ ¬ openByA s'; a = Dact (dFriend uid p uid'); {UID1, UID2} ∩ UIDs = {}⟧ ⟹ ¬ openByA s'›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*discuss goal 6*)
apply ((auto)[1])
(*discuss goal 7*)
apply ((auto)[1])
(*discuss goal 8*)
apply ((auto)[1])
(*proven 8 subgoals*) .
next
(*goal: ‹⋀sa uid p uid' p' oua s'a. ⟦⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal True; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; ¬ friends12 s; friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); ou = outOK; f (Trans s a ou s') = FrVal False; uid = UID1 ∧ uid' = UID2 ∨ uid = UID2 ∧ uid' = UID1; IDsOK s [UID1, UID2] [] [] []; friends12 s; ¬ friends12 s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal True; ¬ openByF s; openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid' ∈ UIDs ∧ uid ∈ {UID1, UID2}; ou = outOK; f (Trans s a ou s') = OVal False; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ thesis; ⋀uid p uid' p'. ⟦a = Cact (cUser uid p uid' p'); uid' ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis; Trans s a ou s' = Trans sa (Cact (cUser uid p uid' p')) oua s'a; open sa ≠ open s'a⟧ ⟹ thesis›*)
fix s1 and uid and p and uid' and p' and ou1 and s1'
assume op: "open s1 ≠ open s1'" and "?trn = Trans s1 (Cact (cUser uid p uid' p')) ou1 s1'" (*‹open (s1::state) ≠ open (s1'::state)› ‹Trans (s::state) (a::act) (ou::out) (s'::state) = Trans (s1::state) (Cact (cUser (uid::userID) (p::password) (uid'::userID) (p'::password))) (ou1::out) (s1'::state)›*)
then have trn: "open s ≠ open s'" "s = s1" "s' = s1'" "ou = ou1" and a: "a = Cact (cUser uid p uid' p')"
apply -
(*goals:
1. ‹⟦open (s1::state) ≠ open (s1'::state); Trans (s::state) (a::act) (ou::out) (s'::state) = Trans s1 (Cact (cUser (uid::userID) (p::password) (uid'::userID) (p'::password))) (ou1::out) s1'⟧ ⟹ open s ≠ open s'›
2. ‹⟦open (s1::state) ≠ open (s1'::state); Trans (s::state) (a::act) (ou::out) (s'::state) = Trans s1 (Cact (cUser (uid::userID) (p::password) (uid'::userID) (p'::password))) (ou1::out) s1'⟧ ⟹ s = s1›
3. ‹⟦open (s1::state) ≠ open (s1'::state); Trans (s::state) (a::act) (ou::out) (s'::state) = Trans s1 (Cact (cUser (uid::userID) (p::password) (uid'::userID) (p'::password))) (ou1::out) s1'⟧ ⟹ s' = s1'›
4. ‹⟦open (s1::state) ≠ open (s1'::state); Trans (s::state) (a::act) (ou::out) (s'::state) = Trans s1 (Cact (cUser (uid::userID) (p::password) (uid'::userID) (p'::password))) (ou1::out) s1'⟧ ⟹ ou = ou1›
5. ‹⟦open (s1::state) ≠ open (s1'::state); Trans (s::state) (a::act) (ou::out) (s'::state) = Trans s1 (Cact (cUser (uid::userID) (p::password) (uid'::userID) (p'::password))) (ou1::out) s1'⟧ ⟹ a = Cact (cUser uid p uid' p')›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*) .
with step (*‹step s a = (ou, s')›*) have uids: "(uid' = UID2 ∨ uid' = UID1) ∧ ou = outOK ∧
(¬openByF s) ∧ (¬openByF s') ∧ openByA s ∧ (¬openByA s')"
apply (cases rule: step_open_cases (*‹⟦step ?s ?a = (?ou, ?s'); open ?s ≠ open ?s'; ⋀uid p uid' p'. ⟦?a = Cact (cUser uid p uid' p'); uid' = UID1 ∨ uid' = UID2; ?ou = outOK; p = pass ?s uid; openByA ?s; ¬ openByA ?s'; ¬ openByF ?s; ¬ openByF ?s'⟧ ⟹ ?thesis; ⋀uid p uid'. ⟦?a = Cact (cFriend uid p uid'); ?ou = outOK; p = pass ?s uid; uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs; openByF ?s'; ¬ openByF ?s; ¬ openByA ?s; ¬ openByA ?s'⟧ ⟹ ?thesis; ⋀uid p uid'. ⟦?a = Dact (dFriend uid p uid'); ?ou = outOK; p = pass ?s uid; uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs; openByF ?s; ¬ openByF ?s'; ¬ openByA ?s; ¬ openByA ?s'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⋀uida pa uid'a p'a. ⟦s = s1; s' = s1'; ou = ou1; a = Cact (cUser uid p uid' p'); a = Cact (cUser uida pa uid'a p'a); uid'a = UID1 ∨ uid'a = UID2; ou = outOK; pa = pass s uida; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'⟧ ⟹ (uid' = UID2 ∨ uid' = UID1) ∧ ou = outOK ∧ ¬ openByF s ∧ ¬ openByF s' ∧ openByA s ∧ ¬ openByA s'›
2. ‹⋀uida pa uid'a. ⟦s = s1; s' = s1'; ou = ou1; a = Cact (cUser uid p uid' p'); a = Cact (cFriend uida pa uid'a); ou = outOK; pa = pass s uida; uida ∈ UIDs ∧ uid'a ∈ {UID1, UID2} ∨ uida ∈ {UID1, UID2} ∧ uid'a ∈ UIDs; openByF s'; ¬ openByF s; ¬ openByA s; ¬ openByA s'⟧ ⟹ (uid' = UID2 ∨ uid' = UID1) ∧ ou = outOK ∧ ¬ openByF s ∧ ¬ openByF s' ∧ openByA s ∧ ¬ openByA s'›
3. ‹⋀uida pa uid'a. ⟦s = s1; s' = s1'; ou = ou1; a = Cact (cUser uid p uid' p'); a = Dact (dFriend uida pa uid'a); ou = outOK; pa = pass s uida; uida ∈ UIDs ∧ uid'a ∈ {UID1, UID2} ∨ uida ∈ {UID1, UID2} ∧ uid'a ∈ UIDs; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ (uid' = UID2 ∨ uid' = UID1) ∧ ou = outOK ∧ ¬ openByF s ∧ ¬ openByF s' ∧ openByA s ∧ ¬ openByA s'›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
then show thesis
using a (*‹a = Cact (cUser uid p uid' p')›*) UID1_UID2_UIDs (*‹{UID1, UID2} ∩ UIDs = {}›*) apply (intro CloseA (*‹⟦a = Cact (cUser ?uid1 ?p1 ?uid'1 ?p'1); ?uid'1 ∈ {UID1, UID2}; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'; ou = outOK; f (Trans s a ou s') = OVal False⟧ ⟹ thesis›*))
(*goal: ‹thesis›*)
by auto
qed
lemma step_open_φ:
assumes "step s a = (ou, s')"
and "open s ≠ open s'"
shows "φ (Trans s a ou s')"
using assms (*‹step s a = (ou, s')› ‹open (s::state) ≠ open (s'::state)›*) apply (cases rule: step_open_cases (*‹⟦step ?s ?a = (?ou, ?s'); open ?s ≠ open ?s'; ⋀uid p uid' p'. ⟦?a = Cact (cUser uid p uid' p'); uid' = UID1 ∨ uid' = UID2; ?ou = outOK; p = pass ?s uid; openByA ?s; ¬ openByA ?s'; ¬ openByF ?s; ¬ openByF ?s'⟧ ⟹ ?thesis; ⋀uid p uid'. ⟦?a = Cact (cFriend uid p uid'); ?ou = outOK; p = pass ?s uid; uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs; openByF ?s'; ¬ openByF ?s; ¬ openByA ?s; ¬ openByA ?s'⟧ ⟹ ?thesis; ⋀uid p uid'. ⟦?a = Dact (dFriend uid p uid'); ?ou = outOK; p = pass ?s uid; uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs; openByF ?s; ¬ openByF ?s'; ¬ openByA ?s; ¬ openByA ?s'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⋀uid p uid' p'. ⟦a = Cact (cUser uid p uid' p'); uid' = UID1 ∨ uid' = UID2; ou = outOK; p = pass s uid; openByA s; ¬ openByA s'; ¬ openByF s; ¬ openByF s'⟧ ⟹ φ (Trans s a ou s')›
2. ‹⋀uid p uid'. ⟦a = Cact (cFriend uid p uid'); ou = outOK; p = pass s uid; uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs; openByF s'; ¬ openByF s; ¬ openByA s; ¬ openByA s'⟧ ⟹ φ (Trans s a ou s')›
3. ‹⋀uid p uid'. ⟦a = Dact (dFriend uid p uid'); ou = outOK; p = pass s uid; uid ∈ UIDs ∧ uid' ∈ {UID1, UID2} ∨ uid ∈ {UID1, UID2} ∧ uid' ∈ UIDs; openByF s; ¬ openByF s'; ¬ openByA s; ¬ openByA s'⟧ ⟹ φ (Trans s a ou s')›
discuss goal 1*)
apply ((auto simp: open_def (*‹open ?s ≡ openByA ?s ∨ openByF ?s›*))[1])
(*discuss goal 2*)
apply ((auto simp: open_def (*‹open ?s ≡ openByA ?s ∨ openByF ?s›*))[1])
(*discuss goal 3*)
apply ((auto simp: open_def (*‹open ?s ≡ openByA ?s ∨ openByF ?s›*))[1])
(*proven 3 subgoals*) .
lemma step_friends12_φ:
assumes "step s a = (ou, s')"
and "friends12 s ≠ friends12 s'"
shows "φ (Trans s a ou s')"
proof (-)
(*goal: ‹φ (Trans s a ou s')›*)
have "a = Cact (cFriend UID1 (pass s UID1) UID2) ∨ a = Cact (cFriend UID2 (pass s UID2) UID1) ∨
a = Dact (dFriend UID1 (pass s UID1) UID2) ∨ a = Dact (dFriend UID2 (pass s UID2) UID1)"
using assms (*‹step (s::state) (a::act) = (ou::out, s'::state)› ‹friends12 (s::state) ≠ friends12 (s'::state)›*) step_friends12 (*‹⟦step ?s ?a = (?ou, ?s'); ?a ≠ Cact (cFriend UID1 (pass ?s UID1) UID2) ∧ ?a ≠ Cact (cFriend UID2 (pass ?s UID2) UID1) ∧ ?a ≠ Dact (dFriend UID1 (pass ?s UID1) UID2) ∧ ?a ≠ Dact (dFriend UID2 (pass ?s UID2) UID1)⟧ ⟹ friends12 ?s' = friends12 ?s›*) apply (cases "ou = outOK")
(*goals:
1. ‹⟦step s a = (ou, s'); friends12 s ≠ friends12 s'; ⋀s a ou s'. ⟦step s a = (ou, s'); a ≠ Cact (cFriend UID1 (pass s UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s UID2) UID1)⟧ ⟹ friends12 s' = friends12 s; ou = outOK⟧ ⟹ a = Cact (cFriend UID1 (pass s UID1) UID2) ∨ a = Cact (cFriend UID2 (pass s UID2) UID1) ∨ a = Dact (dFriend UID1 (pass s UID1) UID2) ∨ a = Dact (dFriend UID2 (pass s UID2) UID1)›
2. ‹⟦step s a = (ou, s'); friends12 s ≠ friends12 s'; ⋀s a ou s'. ⟦step s a = (ou, s'); a ≠ Cact (cFriend UID1 (pass s UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s UID2) UID1)⟧ ⟹ friends12 s' = friends12 s; ou ≠ outOK⟧ ⟹ a = Cact (cFriend UID1 (pass s UID1) UID2) ∨ a = Cact (cFriend UID2 (pass s UID2) UID1) ∨ a = Dact (dFriend UID1 (pass s UID1) UID2) ∨ a = Dact (dFriend UID2 (pass s UID2) UID1)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
moreover then have "ou = outOK"
using assms (*‹step s a = (ou, s')› ‹friends12 s ≠ friends12 s'›*) by auto
ultimately show "φ (Trans s a ou s')"
by auto
qed
lemma eqButUID_step_φ_imp:
assumes ss1: "eqButUID s s1"
and rs: "reach s" and rs1: "reach s1"
and step: "step s a = (ou,s')" and step1: "step s1 a = (ou1,s1')"
and a: "a ≠ Cact (cFriend UID1 (pass s UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s UID2) UID1) ∧
a ≠ Dact (dFriend UID1 (pass s UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s UID2) UID1)"
and φ: "φ (Trans s a ou s')"
shows "φ (Trans s1 a ou1 s1')"
proof (-)
(*goal: ‹φ (Trans s1 a ou1 s1')›*)
have "eqButUID s' s1'"
using eqButUID_step[OF ss1 step step1 rs rs1] (*‹eqButUID s' s1'›*) .
then have "open s = open s1" and "open s' = open s1'" and "openByA s = openByA s1" and "openByA s' = openByA s1'" and "openByF s = openByF s1" and "openByF s' = openByF s1'"
using ss1 (*‹eqButUID s s1›*) apply -
(*goals:
1. ‹⟦eqButUID s' s1'; eqButUID s s1⟧ ⟹ open s = open s1›
2. ‹⟦eqButUID s' s1'; eqButUID s s1⟧ ⟹ open s' = open s1'›
3. ‹⟦eqButUID s' s1'; eqButUID s s1⟧ ⟹ openByA s = openByA s1›
4. ‹⟦eqButUID s' s1'; eqButUID s s1⟧ ⟹ openByA s' = openByA s1'›
5. ‹⟦eqButUID s' s1'; eqButUID s s1⟧ ⟹ openByF s = openByF s1›
6. ‹⟦eqButUID s' s1'; eqButUID s s1⟧ ⟹ openByF s' = openByF s1'›
discuss goal 1*)
apply ((auto simp: eqButUID_open_eq (*‹eqButUID ?s ?s1.0 ⟹ open ?s = open ?s1.0›*) eqButUID_openByA_eq (*‹eqButUID ?s ?s1.0 ⟹ openByA ?s = openByA ?s1.0›*) eqButUID_openByF_eq (*‹eqButUID ?s ?s1.0 ⟹ openByF ?s = openByF ?s1.0›*))[1])
(*discuss goal 2*)
apply ((auto simp: eqButUID_open_eq (*‹eqButUID (?s::state) (?s1.0::state) ⟹ open ?s = open ?s1.0›*) eqButUID_openByA_eq (*‹eqButUID (?s::state) (?s1.0::state) ⟹ openByA ?s = openByA ?s1.0›*) eqButUID_openByF_eq (*‹eqButUID (?s::state) (?s1.0::state) ⟹ openByF ?s = openByF ?s1.0›*))[1])
(*discuss goal 3*)
apply ((auto simp: eqButUID_open_eq (*‹eqButUID ?s ?s1.0 ⟹ open ?s = open ?s1.0›*) eqButUID_openByA_eq (*‹eqButUID ?s ?s1.0 ⟹ openByA ?s = openByA ?s1.0›*) eqButUID_openByF_eq (*‹eqButUID ?s ?s1.0 ⟹ openByF ?s = openByF ?s1.0›*))[1])
(*discuss goal 4*)
apply ((auto simp: eqButUID_open_eq (*‹eqButUID ?s ?s1.0 ⟹ open ?s = open ?s1.0›*) eqButUID_openByA_eq (*‹eqButUID ?s ?s1.0 ⟹ openByA ?s = openByA ?s1.0›*) eqButUID_openByF_eq (*‹eqButUID ?s ?s1.0 ⟹ openByF ?s = openByF ?s1.0›*))[1])
(*discuss goal 5*)
apply ((auto simp: eqButUID_open_eq (*‹eqButUID (?s::state) (?s1.0::state) ⟹ open ?s = open ?s1.0›*) eqButUID_openByA_eq (*‹eqButUID (?s::state) (?s1.0::state) ⟹ openByA ?s = openByA ?s1.0›*) eqButUID_openByF_eq (*‹eqButUID (?s::state) (?s1.0::state) ⟹ openByF ?s = openByF ?s1.0›*))[1])
(*discuss goal 6*)
apply ((auto simp: eqButUID_open_eq (*‹eqButUID ?s ?s1.0 ⟹ open ?s = open ?s1.0›*) eqButUID_openByA_eq (*‹eqButUID ?s ?s1.0 ⟹ openByA ?s = openByA ?s1.0›*) eqButUID_openByF_eq (*‹eqButUID ?s ?s1.0 ⟹ openByF ?s = openByF ?s1.0›*))[1])
(*proven 6 subgoals*) .
with "φ" (*‹φ (Trans s a ou s')›*) a (*‹a ≠ Cact (cFriend UID1 (pass s UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s UID2) UID1)›*) step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) step1 (*‹step (s1::state) (a::act) = (ou1::out, s1'::state)›*) show "φ (Trans s1 a ou1 s1')"
using UID1_UID2_UIDs (*‹{UID1, UID2} ∩ UIDs = {}›*) apply (elim φ.elims (*‹⟦φ ?x = ?y; ⋀s uid p uid' ou s'. ⟦?x = Trans s (Cact (cFriend uid p uid')) ou s'; ?y = ((uid, uid') ∈ {(UID1, UID2), (UID2, UID1)} ∧ ou = outOK ∨ open s ≠ open s')⟧ ⟹ ?P; ⋀s uid p uid' ou s'. ⟦?x = Trans s (Dact (dFriend uid p uid')) ou s'; ?y = ((uid, uid') ∈ {(UID1, UID2), (UID2, UID1)} ∧ ou = outOK ∨ open s ≠ open s')⟧ ⟹ ?P; ⋀s uid p uid' p' ou s'. ⟦?x = Trans s (Cact (cUser uid p uid' p')) ou s'; ?y = (open s ≠ open s')⟧ ⟹ ?P; ⋀v vd vb vc. ⟦?x = Trans v (Sact vd) vb vc; ¬ ?y⟧ ⟹ ?P; ⋀v ve vf vb vc. ⟦?x = Trans v (Cact (cNUReq ve vf)) vb vc; ¬ ?y⟧ ⟹ ?P; ⋀v ve vf vg vb vc. ⟦?x = Trans v (Cact (cPost ve vf vg)) vb vc; ¬ ?y⟧ ⟹ ?P; ⋀v ve vf vg vh vb vc. ⟦?x = Trans v (Cact (cFriendReq ve vf vg vh)) vb vc; ¬ ?y⟧ ⟹ ?P; ⋀v vd vb vc. ⟦?x = Trans v (Uact vd) vb vc; ¬ ?y⟧ ⟹ ?P; ⋀v vd vb vc. ⟦?x = Trans v (Ract vd) vb vc; ¬ ?y⟧ ⟹ ?P; ⋀v vd vb vc. ⟦?x = Trans v (Lact vd) vb vc; ¬ ?y⟧ ⟹ ?P; ⋀v vd vb vc. ⟦?x = Trans v (COMact vd) vb vc; ¬ ?y⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦φ ?x; ⋀s uid p uid' ou s'. ⟦?x = Trans s (Cact (cFriend uid p uid')) ou s'; (uid, uid') ∈ {(UID1, UID2), (UID2, UID1)} ∧ ou = outOK ∨ open s ≠ open s'⟧ ⟹ ?P; ⋀s uid p uid' ou s'. ⟦?x = Trans s (Dact (dFriend uid p uid')) ou s'; (uid, uid') ∈ {(UID1, UID2), (UID2, UID1)} ∧ ou = outOK ∨ open s ≠ open s'⟧ ⟹ ?P; ⋀s uid p uid' p' ou s'. ⟦?x = Trans s (Cact (cUser uid p uid' p')) ou s'; open s ≠ open s'⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦¬ φ ?x; ⋀s uid p uid' ou s'. ⟦?x = Trans s (Cact (cFriend uid p uid')) ou s'; ¬ ((uid, uid') ∈ {(UID1, UID2), (UID2, UID1)} ∧ ou = outOK ∨ open s ≠ open s')⟧ ⟹ ?P; ⋀s uid p uid' ou s'. ⟦?x = Trans s (Dact (dFriend uid p uid')) ou s'; ¬ ((uid, uid') ∈ {(UID1, UID2), (UID2, UID1)} ∧ ou = outOK ∨ open s ≠ open s')⟧ ⟹ ?P; ⋀s uid p uid' p' ou s'. ⟦?x = Trans s (Cact (cUser uid p uid' p')) ou s'; ¬ open s ≠ open s'⟧ ⟹ ?P; ⋀v vd vb vc. ?x = Trans v (Sact vd) vb vc ⟹ ?P; ⋀v ve vf vb vc. ?x = Trans v (Cact (cNUReq ve vf)) vb vc ⟹ ?P; ⋀v ve vf vg vb vc. ?x = Trans v (Cact (cPost ve vf vg)) vb vc ⟹ ?P; ⋀v ve vf vg vh vb vc. ?x = Trans v (Cact (cFriendReq ve vf vg vh)) vb vc ⟹ ?P; ⋀v vd vb vc. ?x = Trans v (Uact vd) vb vc ⟹ ?P; ⋀v vd vb vc. ?x = Trans v (Ract vd) vb vc ⟹ ?P; ⋀v vd vb vc. ?x = Trans v (Lact vd) vb vc ⟹ ?P; ⋀v vd vb vc. ?x = Trans v (COMact vd) vb vc ⟹ ?P⟧ ⟹ ?P›*))
(*goals:
1. ‹⋀sa uid p uid' oua s'a. ⟦a ≠ Cact (cFriend UID1 (pass s UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s UID2) UID1); step s a = (ou, s'); step s1 a = (ou1, s1'); open s = open s1; open s' = open s1'; openByA s = openByA s1; openByA s' = openByA s1'; openByF s = openByF s1; openByF s' = openByF s1'; {UID1, UID2} ∩ UIDs = {}; Trans s a ou s' = Trans sa (Cact (cFriend uid p uid')) oua s'a; (uid, uid') ∈ {(UID1, UID2), (UID2, UID1)} ∧ oua = outOK ∨ open sa ≠ open s'a⟧ ⟹ φ (Trans s1 a ou1 s1')›
2. ‹⋀sa uid p uid' oua s'a. ⟦a ≠ Cact (cFriend UID1 (pass s UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s UID2) UID1); step s a = (ou, s'); step s1 a = (ou1, s1'); open s = open s1; open s' = open s1'; openByA s = openByA s1; openByA s' = openByA s1'; openByF s = openByF s1; openByF s' = openByF s1'; {UID1, UID2} ∩ UIDs = {}; Trans s a ou s' = Trans sa (Dact (dFriend uid p uid')) oua s'a; (uid, uid') ∈ {(UID1, UID2), (UID2, UID1)} ∧ oua = outOK ∨ open sa ≠ open s'a⟧ ⟹ φ (Trans s1 a ou1 s1')›
3. ‹⋀sa uid p uid' p' oua s'a. ⟦a ≠ Cact (cFriend UID1 (pass s UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s UID2) UID1); step s a = (ou, s'); step s1 a = (ou1, s1'); open s = open s1; open s' = open s1'; openByA s = openByA s1; openByA s' = openByA s1'; openByF s = openByF s1; openByF s' = openByF s1'; {UID1, UID2} ∩ UIDs = {}; Trans s a ou s' = Trans sa (Cact (cUser uid p uid' p')) oua s'a; open sa ≠ open s'a⟧ ⟹ φ (Trans s1 a ou1 s1')›
discuss goal 1*)
apply ((auto simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*) d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*))[1])
(*discuss goal 2*)
apply ((auto simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*) d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*))[1])
(*discuss goal 3*)
apply ((auto simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*) d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*))[1])
(*proven 3 subgoals*) .
qed
lemma eqButUID_step_φ:
assumes ss1: "eqButUID s s1"
and rs: "reach s" and rs1: "reach s1"
and step: "step s a = (ou,s')" and step1: "step s1 a = (ou1,s1')"
and a: "a ≠ Cact (cFriend UID1 (pass s UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s UID2) UID1) ∧
a ≠ Dact (dFriend UID1 (pass s UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s UID2) UID1)"
shows "φ (Trans s a ou s') = φ (Trans s1 a ou1 s1')"
proof (standard)
(*goals:
1. ‹φ (Trans s a ou s') ⟹ φ (Trans s1 a ou1 s1')›
2. ‹φ (Trans s1 a ou1 s1') ⟹ φ (Trans s a ou s')›*)
assume "φ (Trans s a ou s')" (*‹φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*)
with assms (*‹eqButUID s s1› ‹reach s› ‹reach s1› ‹step (s::state) (a::act) = (ou::out, s'::state)› ‹step s1 a = (ou1, s1')› ‹a ≠ Cact (cFriend UID1 (pass s UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s UID2) UID1)›*) show "φ (Trans s1 a ou1 s1')"
by (rule eqButUID_step_φ_imp (*‹⟦eqButUID ?s ?s1.0; reach ?s; reach ?s1.0; step ?s ?a = (?ou, ?s'); step ?s1.0 ?a = (?ou1.0, ?s1'); ?a ≠ Cact (cFriend UID1 (pass ?s UID1) UID2) ∧ ?a ≠ Cact (cFriend UID2 (pass ?s UID2) UID1) ∧ ?a ≠ Dact (dFriend UID1 (pass ?s UID1) UID2) ∧ ?a ≠ Dact (dFriend UID2 (pass ?s UID2) UID1); φ (Trans ?s ?a ?ou ?s')⟧ ⟹ φ (Trans ?s1.0 ?a ?ou1.0 ?s1')›*))
next
(*goal: ‹φ (Trans s1 a ou1 s1') ⟹ φ (Trans s a ou s')›*)
assume "φ (Trans s1 a ou1 s1')" (*‹φ (Trans (s1::state) (a::act) (ou1::out) (s1'::state))›*)
moreover have "eqButUID s1 s"
using ss1 (*‹eqButUID s s1›*) by (rule eqButUID_sym (*‹eqButUID ?s ?s1.0 ⟹ eqButUID ?s1.0 ?s›*))
moreover have "a ≠ Cact (cFriend UID1 (pass s1 UID1) UID2) ∧
a ≠ Cact (cFriend UID2 (pass s1 UID2) UID1) ∧
a ≠ Dact (dFriend UID1 (pass s1 UID1) UID2) ∧
a ≠ Dact (dFriend UID2 (pass s1 UID2) UID1)"
using a (*‹a ≠ Cact (cFriend UID1 (pass s UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s UID2) UID1)›*) ss1 (*‹eqButUID s s1›*) by (auto simp: eqButUID_stateSelectors (*‹eqButUID ?s ?s1.0 ⟹ admin ?s = admin ?s1.0› ‹eqButUID ?s ?s1.0 ⟹ pendingUReqs ?s = pendingUReqs ?s1.0› ‹eqButUID ?s ?s1.0 ⟹ userReq ?s = userReq ?s1.0› ‹eqButUID ?s ?s1.0 ⟹ userIDs ?s = userIDs ?s1.0› ‹eqButUID ?s ?s1.0 ⟹ user ?s = user ?s1.0› ‹eqButUID ?s ?s1.0 ⟹ pass ?s = pass ?s1.0› ‹eqButUID ?s ?s1.0 ⟹ eqButUIDf (pendingFReqs ?s) (pendingFReqs ?s1.0)› ‹eqButUID ?s ?s1.0 ⟹ eqButUID12 (friendReq ?s) (friendReq ?s1.0)› ‹eqButUID ?s ?s1.0 ⟹ eqButUIDf (friendIDs ?s) (friendIDs ?s1.0)› ‹eqButUID ?s ?s1.0 ⟹ postIDs ?s = postIDs ?s1.0› ‹eqButUID ?s ?s1.0 ⟹ post ?s = post ?s1.0› ‹eqButUID ?s ?s1.0 ⟹ vis ?s = vis ?s1.0› and more 17 facts*))
ultimately show "φ (Trans s a ou s')"
using rs (*‹reach (s::state)›*) rs1 (*‹reach s1›*) step (*‹step s a = (ou, s')›*) step1 (*‹step (s1::state) (a::act) = (ou1::out, s1'::state)›*) apply (intro eqButUID_step_φ_imp[of s1 s] (*‹⟦eqButUID s1 s; reach s1; reach s; step s1 ?a = (?ou, ?s'); step s ?a = (?ou1.0, ?s1'); ?a ≠ Cact (cFriend UID1 (pass s1 UID1) UID2) ∧ ?a ≠ Cact (cFriend UID2 (pass s1 UID2) UID1) ∧ ?a ≠ Dact (dFriend UID1 (pass s1 UID1) UID2) ∧ ?a ≠ Dact (dFriend UID2 (pass s1 UID2) UID1); φ (Trans s1 ?a ?ou ?s')⟧ ⟹ φ (Trans s ?a ?ou1.0 ?s1')›*))
(*goals:
1. ‹⟦φ (Trans s1 a ou1 s1'); eqButUID s1 s; a ≠ Cact (cFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s1 UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s1 UID2) UID1); reach s; reach s1; step s a = (ou, s'); step s1 a = (ou1, s1')⟧ ⟹ eqButUID s1 s›
2. ‹⟦φ (Trans s1 a ou1 s1'); eqButUID s1 s; a ≠ Cact (cFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s1 UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s1 UID2) UID1); reach s; reach s1; step s a = (ou, s'); step s1 a = (ou1, s1')⟧ ⟹ reach s1›
3. ‹⟦φ (Trans s1 a ou1 s1'); eqButUID s1 s; a ≠ Cact (cFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s1 UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s1 UID2) UID1); reach s; reach s1; step s a = (ou, s'); step s1 a = (ou1, s1')⟧ ⟹ reach s›
4. ‹⟦φ (Trans s1 a ou1 s1'); eqButUID s1 s; a ≠ Cact (cFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s1 UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s1 UID2) UID1); reach s; reach s1; step s a = (ou, s'); step s1 a = (ou1, s1')⟧ ⟹ step s1 a = (?ou7, ?s'7)›
5. ‹⟦φ (Trans s1 a ou1 s1'); eqButUID s1 s; a ≠ Cact (cFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s1 UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s1 UID2) UID1); reach s; reach s1; step s a = (ou, s'); step s1 a = (ou1, s1')⟧ ⟹ step s a = (ou, s')›
6. ‹⟦φ (Trans s1 a ou1 s1'); eqButUID s1 s; a ≠ Cact (cFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s1 UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s1 UID2) UID1); reach s; reach s1; step s a = (ou, s'); step s1 a = (ou1, s1')⟧ ⟹ a ≠ Cact (cFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s1 UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s1 UID2) UID1)›
7. ‹⟦φ (Trans s1 a ou1 s1'); eqButUID s1 s; a ≠ Cact (cFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Cact (cFriend UID2 (pass s1 UID2) UID1) ∧ a ≠ Dact (dFriend UID1 (pass s1 UID1) UID2) ∧ a ≠ Dact (dFriend UID2 (pass s1 UID2) UID1); reach s; reach s1; step s a = (ou, s'); step s1 a = (ou1, s1')⟧ ⟹ φ (Trans s1 a ?ou7 ?s'7)›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*)
apply ((assumption)[1])
(*discuss goal 3*)
apply ((assumption)[1])
(*discuss goal 4*)
apply ((assumption)[1])
(*discuss goal 5*)
apply ((assumption)[1])
(*discuss goal 6*)
apply ((assumption)[1])
(*discuss goal 7*) .
(*proven 7 subgoals*)
qed
end
end
| {
"path": "afp-2025-02-12/thys/CoSMeDis/Friend_Confidentiality/Friend_Value_Setup.thy",
"repo": "afp-2025-02-12",
"sha": "97ecccc0075cac48e52167975623ed389c94c5370585173632268660d189fd47"
} |
theory Cones
imports
"HOL-Analysis.Analysis"
Triangle.Triangle
"../ODE_Auxiliarities"
begin
lemma arcsin_eq_zero_iff[simp]: "-1 ≤ x ⟹ x ≤ 1 ⟹ arcsin x = 0 ⟷ x = 0"
using sin_arcsin (*‹⟦- 1 ≤ ?y; ?y ≤ 1⟧ ⟹ sin (arcsin ?y) = ?y›*) by fastforce
definition conemem :: "'a::real_vector ⇒ 'a ⇒ real ⇒ 'a" where "conemem u v t = cos t *⇩R u + sin t *⇩R v"
definition "conesegment u v = conemem u v ` {0.. pi / 2}"
lemma
bounded_linear_image_conemem:
assumes "bounded_linear F"
shows "F (conemem u v t) = conemem (F u) (F v) t"
proof (-)
(*goal: ‹(F::'a ⇒ 'b) (conemem (u::'a) (v::'a) (t::real)) = conemem (F u) (F v) t›*)
from assms (*‹bounded_linear F›*) interpret bounded_linear F .
show "?thesis"
(*goal: ‹F (conemem u v t) = conemem (F u) (F v) t›*)
by (auto simp: conemem_def[abs_def] (*‹conemem ≡ λu v t. cos t *⇩R u + sin t *⇩R v›*) cone_hull_expl (*‹cone hull ?S = {c *⇩R x |c x. 0 ≤ c ∧ x ∈ ?S}›*) closed_segment_def (*‹{?a--?b} = {(1 - u) *⇩R ?a + u *⇩R ?b |u. 0 ≤ u ∧ u ≤ 1}›*) add (*‹F (?b1.0 + ?b2.0) = F ?b1.0 + F ?b2.0›*) scaleR (*‹F (?r *⇩R ?b) = ?r *⇩R F ?b›*))
qed
lemma
bounded_linear_image_conesegment:
assumes "bounded_linear F"
shows "F ` conesegment u v = conesegment (F u) (F v)"
proof (-)
(*goal: ‹F ` conesegment u v = conesegment (F u) (F v)›*)
from assms (*‹bounded_linear F›*) interpret bounded_linear F .
show "?thesis"
(*goal: ‹F ` conesegment u v = conesegment (F u) (F v)›*)
apply (auto simp: conesegment_def (*‹conesegment ?u ?v = conemem ?u ?v ` {0..pi / 2}›*) conemem_def[abs_def] (*‹conemem ≡ λu v t. cos t *⇩R u + sin t *⇩R v›*) cone_hull_expl (*‹cone hull ?S = {c *⇩R x |c x. 0 ≤ c ∧ x ∈ ?S}›*) closed_segment_def (*‹{?a--?b} = {(1 - u) *⇩R ?a + u *⇩R ?b |u. 0 ≤ u ∧ u ≤ 1}›*) add (*‹F (?b1.0 + ?b2.0) = F ?b1.0 + F ?b2.0›*) scaleR (*‹F (?r *⇩R ?b) = ?r *⇩R F ?b›*))
(*goal: ‹F ` conesegment u v = conesegment (F u) (F v)›*)
by (auto simp: add[symmetric] (*‹F ?b1.0 + F ?b2.0 = F (?b1.0 + ?b2.0)›*) scaleR[symmetric] (*‹?r *⇩R F ?b = F (?r *⇩R ?b)›*))
qed
(* This is vangle in $AFP/Triangles/Angles *)
lemma discriminant: "a * x² + b * x + c = (0::real) ⟹ 0 ≤ b² - 4 * a * c"
by (sos "(((A<0 * R<1) + (R<1 * (R<1 * [2*a*x + b]^2))))")
lemma quadratic_eq_factoring:
assumes D: "D = b² - 4 * a * c"
assumes nn: "0 ≤ D"
assumes x1: "x₁ = (-b + sqrt D) / (2 * a)"
assumes x2: "x₂ = (-b - sqrt D) / (2 * a)"
assumes a: "a ≠ 0"
shows "a * x² + b * x + c = a * (x - x₁) * (x - x₂)"
using nn (*‹0 ≤ D›*) apply (simp add: D (*‹D = b² - 4 * a * c›*) x1 (*‹x₁ = (- b + sqrt D) / (2 * a)›*) x2 (*‹x₂ = (- b - sqrt D) / (2 * a)›*))
(*goal: ‹a * x² + b * x + c = a * (x - x₁) * (x - x₂)›*)
by (simp add: assms (*‹D = b² - 4 * a * c› ‹0 ≤ D› ‹x₁ = (- b + sqrt D) / (2 * a)› ‹x₂ = (- b - sqrt D) / (2 * a)› ‹a ≠ 0›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) power2_eq_square (*‹?a² = ?a * ?a›*) power3_eq_cube (*‹?a ^ 3 = ?a * ?a * ?a›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*))
lemma quadratic_eq_zeroes_iff:
assumes D: "D = b² - 4 * a * c"
assumes x1: "x₁ = (-b + sqrt D) / (2 * a)"
assumes x2: "x₂ = (-b - sqrt D) / (2 * a)"
assumes a: "a ≠ 0"
shows "a * x² + b * x + c = 0 ⟷ (D ≥ 0 ∧ (x = x₁ ∨ x = x₂))" (is "?z ⟷ _")
using quadratic_eq_factoring[OF D _ x1 x2 a, of x] (*‹0 ≤ D ⟹ a * x² + b * x + c = a * (x - x₁) * (x - x₂)›*) discriminant[of a x b c] (*‹a * x² + b * x + c = 0 ⟹ 0 ≤ b² - 4 * a * c›*) a (*‹a ≠ 0›*) by (auto simp: D (*‹D = b² - 4 * a * c›*))
lemma quadratic_ex_zero_iff:
"(∃x. a * x² + b * x + c = 0) ⟷ (a ≠ 0 ∧ b² - 4 * a * c ≥ 0 ∨ a = 0 ∧ (b = 0 ⟶ c = 0))"
for a b c::real
apply (cases "a = 0")
(*goal: ‹(∃x. a * x² + b * x + c = 0) = (a ≠ 0 ∧ 0 ≤ b² - 4 * a * c ∨ a = 0 ∧ (b = 0 ⟶ c = 0))›*)
subgoal for
by (auto simp: intro: exI[where x="- c / b"] (*‹?P (- c / b) ⟹ ∃x. ?P x›*))
subgoal for
apply (subst quadratic_eq_zeroes_iff[OF refl refl refl] (*‹?a ≠ 0 ⟹ (?a * ?x² + ?b * ?x + ?c = 0) = (0 ≤ ?b² - 4 * ?a * ?c ∧ (?x = (- ?b + sqrt (?b² - 4 * ?a * ?c)) / (2 * ?a) ∨ ?x = (- ?b - sqrt (?b² - 4 * ?a * ?c)) / (2 * ?a)))›*))
(*goals:
1. ‹⋀x. a ≠ 0 ⟹ a ≠ 0›
2. ‹a ≠ 0 ⟹ (∃x. 0 ≤ b² - 4 * a * c ∧ (x = (- b + sqrt (b² - 4 * a * c)) / (2 * a) ∨ x = (- b - sqrt (b² - 4 * a * c)) / (2 * a))) = (a ≠ 0 ∧ 0 ≤ b² - 4 * a * c ∨ a = 0 ∧ (b = 0 ⟶ c = 0))›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) . .
lemma Cauchy_Schwarz_eq_iff:
shows "(inner x y)² = inner x x * inner y y ⟷ ((∃k. x = k *⇩R y) ∨ y = 0)"
proof (safe)
(*goals:
1. ‹⟦(x ∙ y)² = x ∙ x * (y ∙ y); y ≠ 0⟧ ⟹ ∃k. x = k *⇩R y›
2. ‹⋀k. x = k *⇩R y ⟹ (k *⇩R y ∙ y)² = k *⇩R y ∙ k *⇩R y * (y ∙ y)›
3. ‹y = 0 ⟹ (x ∙ 0)² = x ∙ x * (0 ∙ 0)›*)
assume eq: "(x ∙ y)² = x ∙ x * (y ∙ y)" and "y ≠ 0" (*‹((x::'a) ∙ (y::'a))² = x ∙ x * (y ∙ y)› ‹(y::'a) ≠ (0::'a)›*)
define f where "f ≡ λl. inner (x - l *⇩R y) (x - l *⇩R y)"
have f_quadratic: "f l = inner y y * l² + - 2 * inner x y * l + inner x x" for l
by (auto simp: f_def (*‹f::real ⇒ real ≡ λl::real. ((x::'a) - l *⇩R (y::'a)) ∙ (x - l *⇩R y)›*) algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 34 facts*) power2_eq_square (*‹(?a::?'a)² = ?a * ?a›*) inner_commute (*‹(?x::?'a) ∙ (?y::?'a) = ?y ∙ ?x›*))
have "∃l. f l = 0"
unfolding f_quadratic quadratic_ex_zero_iff
(*goal: ‹(y::'a) ∙ y ≠ (0::real) ∧ (0::real) ≤ (- (2::real) * ((x::'a) ∙ y))² - (4::real) * (y ∙ y) * (x ∙ x) ∨ y ∙ y = (0::real) ∧ (- (2::real) * (x ∙ y) = (0::real) ⟶ x ∙ x = (0::real))›*)
using ‹y ≠ 0› (*‹y ≠ 0›*) by (auto simp: eq (*‹((x::'a) ∙ (y::'a))² = x ∙ x * (y ∙ y)›*))
then show "(∃k. x = k *⇩R y)"
by (auto simp: f_def (*‹f ≡ λl. (x - l *⇩R y) ∙ (x - l *⇩R y)›*))
qed (auto simp: power2_eq_square (*‹?a² = ?a * ?a›*))
(*solves the remaining goals:
1. ‹⋀k::real. (x::'a::real_inner) = k *⇩R (y::'a::real_inner) ⟹ (k *⇩R y ∙ y)² = k *⇩R y ∙ k *⇩R y * (y ∙ y)›
2. ‹(y::'a::real_inner) = (0::'a::real_inner) ⟹ ((x::'a::real_inner) ∙ (0::'a::real_inner))² = x ∙ x * ((0::'a::real_inner) ∙ (0::'a::real_inner))›*)
lemma Cauchy_Schwarz_strict_ineq:
"(inner x y)² < inner x x * inner y y" if "y ≠ 0" "⋀k. x ≠ k *⇩R y"
apply (rule neq_le_trans (*‹⟦?a ≠ ?b; ?a ≤ ?b⟧ ⟹ ?a < ?b›*))
(*goal: ‹(x ∙ y)² < x ∙ x * (y ∙ y)›*)
subgoal for
using that (*‹y ≠ 0› ‹x ≠ ?k *⇩R y›*) unfolding Cauchy_Schwarz_eq_iff
(*goal: ‹¬ ((∃k. x = k *⇩R y) ∨ y = 0)›*)
by auto
subgoal for
by (rule Cauchy_Schwarz_ineq (*‹(?x ∙ ?y)² ≤ ?x ∙ ?x * (?y ∙ ?y)›*)) .
lemma Cauchy_Schwarz_eq2_iff:
"¦inner x y¦ = norm x * norm y ⟷ ((∃k. x = k *⇩R y) ∨ y = 0)"
using Cauchy_Schwarz_eq_iff[of x y] (*‹((x ∙ y)² = x ∙ x * (y ∙ y)) = ((∃k. x = k *⇩R y) ∨ y = 0)›*) apply (subst power_eq_iff_eq_base[symmetric, where n = 2] (*‹⟦0 < 2; 0 ≤ ?a; 0 ≤ ?b⟧ ⟹ (?a = ?b) = (?a² = ?b²)›*))
(*goals:
1. ‹((x ∙ y)² = x ∙ x * (y ∙ y)) = ((∃k. x = k *⇩R y) ∨ y = 0) ⟹ 0 < 2›
2. ‹((x ∙ y)² = x ∙ x * (y ∙ y)) = ((∃k. x = k *⇩R y) ∨ y = 0) ⟹ 0 ≤ ¦x ∙ y¦›
3. ‹((x ∙ y)² = x ∙ x * (y ∙ y)) = ((∃k. x = k *⇩R y) ∨ y = 0) ⟹ 0 ≤ norm x * norm y›
4. ‹((x ∙ y)² = x ∙ x * (y ∙ y)) = ((∃k. x = k *⇩R y) ∨ y = 0) ⟹ (¦x ∙ y¦² = (norm x * norm y)²) = ((∃k. x = k *⇩R y) ∨ y = 0)›
discuss goal 1*)
apply (simp add: dot_square_norm (*‹(?x::?'a) ∙ ?x = (norm ?x)²›*) power_mult_distrib (*‹((?a::?'a) * (?b::?'a)) ^ (?n::nat) = ?a ^ ?n * ?b ^ ?n›*))
(*discuss goal 2*)
apply (simp add: dot_square_norm (*‹?x ∙ ?x = (norm ?x)²›*) power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*))
(*discuss goal 3*)
apply (simp add: dot_square_norm (*‹(?x::?'a) ∙ ?x = (norm ?x)²›*) power_mult_distrib (*‹((?a::?'a) * (?b::?'a)) ^ (?n::nat) = ?a ^ ?n * ?b ^ ?n›*))
(*discuss goal 4*)
apply (simp add: dot_square_norm (*‹?x ∙ ?x = (norm ?x)²›*) power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*))
(*proven 4 subgoals*) .
lemma Cauchy_Schwarz_strict_ineq2:
"¦inner x y¦ < norm x * norm y" if "y ≠ 0" "⋀k. x ≠ k *⇩R y"
apply (rule neq_le_trans (*‹⟦?a ≠ ?b; ?a ≤ ?b⟧ ⟹ ?a < ?b›*))
(*goal: ‹¦x ∙ y¦ < norm x * norm y›*)
subgoal for
using that (*‹y ≠ 0› ‹x ≠ ?k *⇩R y›*) unfolding Cauchy_Schwarz_eq2_iff
(*goal: ‹¬ ((∃k. x = k *⇩R y) ∨ y = 0)›*)
by auto
subgoal for
by (rule Cauchy_Schwarz_ineq2 (*‹¦?x ∙ ?y¦ ≤ norm ?x * norm ?y›*)) .
lemma gt_minus_one_absI: "abs k < 1 ⟹ - 1 < k" for k::real
by auto
lemma gt_one_absI: "abs k < 1 ⟹ k < 1" for k::real
by auto
lemma abs_impossible:
"¦y1¦ < x1 ⟹ ¦y2¦ < x2 ⟹ x1 * x2 + y1 * y2 ≠ 0" for x1 x2::real
proof (goal_cases)
(*goal: ‹⟦¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ x1 * x2 + y1 * y2 ≠ 0›*)
case 1 (*‹¦y1¦ < x1› ‹¦y2¦ < x2›*)
have "- y1 * y2 ≤ abs y1 * abs y2"
by (metis abs_ge_minus_self (*‹- ?a ≤ ¦?a¦›*) abs_mult (*‹¦?a * ?b¦ = ¦?a¦ * ¦?b¦›*) mult.commute (*‹?a * ?b = ?b * ?a›*) mult_minus_right (*‹?a * - ?b = - (?a * ?b)›*))
also (*calculation: ‹- y1 * y2 ≤ ¦y1¦ * ¦y2¦›*) have "… < x1 * x2"
apply (rule mult_strict_mono (*‹⟦?a < ?b; ?c < ?d; 0 < ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c < ?b * ?d›*))
(*goal: ‹¦y1¦ * ¦y2¦ < x1 * x2›*)
using "1" (*‹¦y1¦ < x1› ‹¦y2¦ < x2›*) apply -
(*goals:
1. ‹⟦¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real)⟧ ⟹ ¦y1¦ < x1›
2. ‹⟦¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real)⟧ ⟹ ¦y2¦ < x2›
3. ‹⟦¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real)⟧ ⟹ (0::real) < x1›
4. ‹⟦¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real)⟧ ⟹ (0::real) ≤ ¦y2¦›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*proven 4 subgoals*) .
finally (*calculation: ‹- (y1::real) * (y2::real) < (x1::real) * (x2::real)›*) show "?case"
(*goal: ‹x1 * x2 + y1 * y2 ≠ 0›*)
by auto
qed
lemma vangle_eq_arctan_minus:― ‹TODO: generalize?!›
assumes ij: "i ∈ Basis" "j ∈ Basis" and ij_neq: "i ≠ j"
assumes xy1: "¦y1¦ < x1"
assumes xy2: "¦y2¦ < x2"
assumes less: "y2 / x2 > y1 / x1"
shows "vangle (x1 *⇩R i + y1 *⇩R j) (x2 *⇩R i + y2 *⇩R j) = arctan (y2 / x2) - arctan (y1 / x1)"
(is "vangle ?u ?v = _")
proof (-)
(*goal: ‹vangle (x1 *⇩R i + y1 *⇩R j) (x2 *⇩R i + y2 *⇩R j) = arctan (y2 / x2) - arctan (y1 / x1)›*)
from assms (*‹(i::'a) ∈ Basis› ‹j ∈ Basis› ‹i ≠ j› ‹¦y1¦ < x1› ‹¦y2¦ < x2› ‹y1 / x1 < y2 / x2›*) have less2: "x2 * y1 - x1 * y2 < 0"
by (auto simp: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) abs_real_def (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
have norm_eucl: "norm (x *⇩R i + y *⇩R j) = sqrt ((norm x)² + (norm y)²)" for x and y
apply (subst norm_eq_sqrt_inner (*‹norm ?x = sqrt (?x ∙ ?x)›*))
(*goal: ‹norm ((x::real) *⇩R (i::'a) + (y::real) *⇩R (j::'a)) = sqrt ((norm x)² + (norm y)²)›*)
using ij (*‹i ∈ Basis› ‹(j::'a) ∈ Basis›*) ij_neq (*‹i ≠ j›*) by (auto simp: inner_simps (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z› ‹?x ∙ (?y + ?z) = ?x ∙ ?y + ?x ∙ ?z› ‹?x ∙ (?y - ?z) = ?x ∙ ?y - ?x ∙ ?z› ‹(?x - ?y) ∙ ?z = ?x ∙ ?z - ?y ∙ ?z› ‹?r *⇩R ?x ∙ ?y = ?r * (?x ∙ ?y)› ‹?x ∙ ?r *⇩R ?y = ?r * (?x ∙ ?y)›*) inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) power2_eq_square (*‹?a² = ?a * ?a›*))
have nonzeroes: "x1 *⇩R i + y1 *⇩R j ≠ 0" "x2 *⇩R i + y2 *⇩R j ≠ 0"
apply (auto simp: euclidean_eq_iff[where 'a='a] (*‹(?x = ?y) = (∀b∈Basis. ?x ∙ b = ?y ∙ b)›*) inner_simps (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z› ‹?x ∙ (?y + ?z) = ?x ∙ ?y + ?x ∙ ?z› ‹?x ∙ (?y - ?z) = ?x ∙ ?y - ?x ∙ ?z› ‹(?x - ?y) ∙ ?z = ?x ∙ ?z - ?y ∙ ?z› ‹?r *⇩R ?x ∙ ?y = ?r * (?x ∙ ?y)› ‹?x ∙ ?r *⇩R ?y = ?r * (?x ∙ ?y)›*) intro!: bexI[where x=i] (*‹⟦?P i; i ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*))
(*top goal: ‹x1 *⇩R i + y1 *⇩R j ≠ 0› and 1 goal remains*)
using assms (*‹(i::'a::euclidean_space) ∈ Basis› ‹j ∈ Basis› ‹i ≠ j› ‹¦y1¦ < x1› ‹¦y2¦ < x2› ‹(y1::real) / (x1::real) < (y2::real) / (x2::real)›*) apply -
(*goals:
1. ‹⟦x1 * (i ∙ i) + y1 * (j ∙ i) = 0; i ∈ Basis; j ∈ Basis; i ≠ j; ¦y1¦ < x1; ¦y2¦ < x2; y1 / x1 < y2 / x2⟧ ⟹ False›
2. ‹⟦i ∈ Basis; j ∈ Basis; i ≠ j; ¦y1¦ < x1; ¦y2¦ < x2; y1 / x1 < y2 / x2⟧ ⟹ i ∈ Basis›
3. ‹⟦x2 * (i ∙ i) + y2 * (j ∙ i) = 0; i ∈ Basis; j ∈ Basis; i ≠ j; ¦y1¦ < x1; ¦y2¦ < x2; y1 / x1 < y2 / x2⟧ ⟹ False›
4. ‹⟦i ∈ Basis; j ∈ Basis; i ≠ j; ¦y1¦ < x1; ¦y2¦ < x2; y1 / x1 < y2 / x2⟧ ⟹ i ∈ Basis›
discuss goal 1*)
apply ((auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*))[1])
(*discuss goal 2*)
apply ((auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*))[1])
(*discuss goal 3*)
apply ((auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*))[1])
(*discuss goal 4*)
apply ((auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*))[1])
(*proven 4 subgoals*) .
have indep: "x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)" for k
proof (standard)
(*goal: ‹x1 *⇩R i + y1 *⇩R j = k *⇩R (x2 *⇩R i + y2 *⇩R j) ⟹ False›*)
assume "x1 *⇩R i + y1 *⇩R j = k *⇩R (x2 *⇩R i + y2 *⇩R j)" (*‹(x1::real) *⇩R (i::'a) + (y1::real) *⇩R (j::'a) = (k::real) *⇩R ((x2::real) *⇩R i + (y2::real) *⇩R j)›*)
then have "x1 / x2 = k" "y1 = k * y2"
using ij (*‹i ∈ Basis› ‹j ∈ Basis›*) ij_neq (*‹i ≠ j›*) xy1 (*‹¦y1¦ < x1›*) xy2 (*‹¦y2¦ < x2›*) apply -
(*goals:
1. ‹⟦x1 *⇩R i + y1 *⇩R j = k *⇩R (x2 *⇩R i + y2 *⇩R j); i ∈ Basis; j ∈ Basis; i ≠ j; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ x1 / x2 = k›
2. ‹⟦x1 *⇩R i + y1 *⇩R j = k *⇩R (x2 *⇩R i + y2 *⇩R j); i ∈ Basis; j ∈ Basis; i ≠ j; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ y1 = k * y2›
discuss goal 1*)
apply ((auto simp: abs_real_def (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) euclidean_eq_iff[where 'a='a] (*‹(?x = ?y) = (∀b∈Basis. ?x ∙ b = ?y ∙ b)›*) inner_simps (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z› ‹?x ∙ (?y + ?z) = ?x ∙ ?y + ?x ∙ ?z› ‹?x ∙ (?y - ?z) = ?x ∙ ?y - ?x ∙ ?z› ‹(?x - ?y) ∙ ?z = ?x ∙ ?z - ?y ∙ ?z› ‹?r *⇩R ?x ∙ ?y = ?r * (?x ∙ ?y)› ‹?x ∙ ?r *⇩R ?y = ?r * (?x ∙ ?y)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*goals:
1. ‹⋀b. ⟦∀b∈Basis. x1 * (i ∙ b) + y1 * (j ∙ b) = k * (x2 * (i ∙ b)) + k * (y2 * (j ∙ b)); i ∈ Basis; j ∈ Basis; y1 < 0; - y1 < x1; y2 < 0; - y2 < x2; b ∈ Basis; i ∙ b ≠ j ∙ b⟧ ⟹ x1 = k * x2›
2. ‹⋀b. ⟦∀b∈Basis. x1 * (i ∙ b) + y1 * (j ∙ b) = k * (x2 * (i ∙ b)) + k * (y2 * (j ∙ b)); i ∈ Basis; j ∈ Basis; y1 < 0; - y1 < x1; ¬ y2 < 0; y2 < x2; b ∈ Basis; i ∙ b ≠ j ∙ b⟧ ⟹ x1 = k * x2›
3. ‹⋀b. ⟦∀b∈Basis. x1 * (i ∙ b) + y1 * (j ∙ b) = k * (x2 * (i ∙ b)) + k * (y2 * (j ∙ b)); i ∈ Basis; j ∈ Basis; ¬ y1 < 0; y1 < x1; y2 < 0; - y2 < x2; b ∈ Basis; i ∙ b ≠ j ∙ b⟧ ⟹ x1 = k * x2›
4. ‹⋀b. ⟦∀b∈Basis. x1 * (i ∙ b) + y1 * (j ∙ b) = k * (x2 * (i ∙ b)) + k * (y2 * (j ∙ b)); i ∈ Basis; j ∈ Basis; ¬ y1 < 0; y1 < x1; ¬ y2 < 0; y2 < x2; b ∈ Basis; i ∙ b ≠ j ∙ b⟧ ⟹ x1 = k * x2›
discuss goal 1*)
apply ((auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*discuss goal 2*)
apply ((auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*discuss goal 3*)
apply ((auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*discuss goal 4*)
apply ((auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*proven 4 subgoals*)
(*discuss goal 2*)
apply ((auto simp: abs_real_def (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) euclidean_eq_iff[where 'a='a] (*‹(?x = ?y) = (∀b∈Basis. ?x ∙ b = ?y ∙ b)›*) inner_simps (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z› ‹?x ∙ (?y + ?z) = ?x ∙ ?y + ?x ∙ ?z› ‹?x ∙ (?y - ?z) = ?x ∙ ?y - ?x ∙ ?z› ‹(?x - ?y) ∙ ?z = ?x ∙ ?z - ?y ∙ ?z› ‹?r *⇩R ?x ∙ ?y = ?r * (?x ∙ ?y)› ‹?x ∙ ?r *⇩R ?y = ?r * (?x ∙ ?y)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*goals:
1. ‹⋀b. ⟦∀b∈Basis. x1 * (i ∙ b) + y1 * (j ∙ b) = k * (x2 * (i ∙ b)) + k * (y2 * (j ∙ b)); i ∈ Basis; j ∈ Basis; y1 < 0; - y1 < x1; y2 < 0; - y2 < x2; b ∈ Basis; i ∙ b ≠ j ∙ b⟧ ⟹ y1 = k * y2›
2. ‹⋀b. ⟦∀b∈Basis. x1 * (i ∙ b) + y1 * (j ∙ b) = k * (x2 * (i ∙ b)) + k * (y2 * (j ∙ b)); i ∈ Basis; j ∈ Basis; y1 < 0; - y1 < x1; ¬ y2 < 0; y2 < x2; b ∈ Basis; i ∙ b ≠ j ∙ b⟧ ⟹ y1 = k * y2›
3. ‹⋀b. ⟦∀b∈Basis. x1 * (i ∙ b) + y1 * (j ∙ b) = k * (x2 * (i ∙ b)) + k * (y2 * (j ∙ b)); i ∈ Basis; j ∈ Basis; ¬ y1 < 0; y1 < x1; y2 < 0; - y2 < x2; b ∈ Basis; i ∙ b ≠ j ∙ b⟧ ⟹ y1 = k * y2›
4. ‹⋀b. ⟦∀b∈Basis. x1 * (i ∙ b) + y1 * (j ∙ b) = k * (x2 * (i ∙ b)) + k * (y2 * (j ∙ b)); i ∈ Basis; j ∈ Basis; ¬ y1 < 0; y1 < x1; ¬ y2 < 0; y2 < x2; b ∈ Basis; i ∙ b ≠ j ∙ b⟧ ⟹ y1 = k * y2›
discuss goal 1*)
apply ((auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*discuss goal 2*)
apply ((auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*discuss goal 3*)
apply ((auto simp: inner_Basis (*‹⟦(?u::?'a) ∈ Basis; (?v::?'a) ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1::real else (0::real))›*) split: if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*discuss goal 4*)
apply ((auto simp: inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*proven 4 subgoals*)
(*proven 2 subgoals*) .
then have "y1 = x1 / x2 * y2"
by simp
with less (*‹y1 / x1 < y2 / x2›*) show False
using xy1 (*‹¦y1¦ < x1›*) by (auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
qed
have "((x1² + y1²) * (x2² + y2²) *
(1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j))² / ((x1² + y1²) * (x2² + y2²)))) =
((x1² + y1²) * (x2² + y2²) *
(1 - (x1 * x2 + y1 * y2)² / ((x1² + y1²) * (x2² + y2²))))"
using ij_neq (*‹i ≠ j›*) ij (*‹(i::'a::euclidean_space) ∈ Basis› ‹j ∈ Basis›*) by (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) inner_simps (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z› ‹?x ∙ (?y + ?z) = ?x ∙ ?y + ?x ∙ ?z› ‹?x ∙ (?y - ?z) = ?x ∙ ?y - ?x ∙ ?z› ‹(?x - ?y) ∙ ?z = ?x ∙ ?z - ?y ∙ ?z› ‹?r *⇩R ?x ∙ ?y = ?r * (?x ∙ ?y)› ‹?x ∙ ?r *⇩R ?y = ?r * (?x ∙ ?y)›*) inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*))
also (*calculation: ‹((x1::real)² + (y1::real)²) * ((x2::real)² + (y2::real)²) * ((1::real) - ((x1 *⇩R (i::'a) + y1 *⇩R (j::'a)) ∙ (x2 *⇩R i + y2 *⇩R j))² / ((x1² + y1²) * (x2² + y2²))) = (x1² + y1²) * (x2² + y2²) * ((1::real) - (x1 * x2 + y1 * y2)² / ((x1² + y1²) * (x2² + y2²)))›*) have "… = (x1² + y1²) * (x2² + y2²) - (x1 * x2 + y1 * y2)²"
unfolding right_diff_distrib
(*goal: ‹(x1² + y1²) * (x2² + y2²) * 1 - (x1² + y1²) * (x2² + y2²) * ((x1 * x2 + y1 * y2)² / ((x1² + y1²) * (x2² + y2²))) = (x1² + y1²) * (x2² + y2²) - (x1 * x2 + y1 * y2)²›*)
by simp
also (*calculation: ‹(x1² + y1²) * (x2² + y2²) * (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j))² / ((x1² + y1²) * (x2² + y2²))) = (x1² + y1²) * (x2² + y2²) - (x1 * x2 + y1 * y2)²›*) have "… = (x2 * y1 - x1 * y2)^2"
by (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) power2_eq_square (*‹?a² = ?a * ?a›*))
also (*calculation: ‹(x1² + y1²) * (x2² + y2²) * (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j))² / ((x1² + y1²) * (x2² + y2²))) = (x2 * y1 - x1 * y2)²›*) have "sqrt … = ¦x2 * y1 - x1 * y2¦"
by simp
also (*calculation: ‹sqrt (((x1::real)² + (y1::real)²) * ((x2::real)² + (y2::real)²) * ((1::real) - ((x1 *⇩R (i::'a) + y1 *⇩R (j::'a)) ∙ (x2 *⇩R i + y2 *⇩R j))² / ((x1² + y1²) * (x2² + y2²)))) = ¦x2 * y1 - x1 * y2¦›*) have "… = x1 * y2 - x2 * y1"
using less2 (*‹x2 * y1 - x1 * y2 < 0›*) by (simp add: abs_real_def (*‹¦?a::real¦ = (if ?a < (0::real) then - ?a else ?a)›*))
finally (*calculation: ‹sqrt ((x1² + y1²) * (x2² + y2²) * (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j))² / ((x1² + y1²) * (x2² + y2²)))) = x1 * y2 - x2 * y1›*) have sqrt_eq: "sqrt ((x1² + y1²) * (x2² + y2²) *
(1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j))² / ((x1² + y1²) * (x2² + y2²)))) =
x1 * y2 - x2 * y1" .
show "?thesis"
(*goal: ‹vangle (x1 *⇩R i + y1 *⇩R j) (x2 *⇩R i + y2 *⇩R j) = arctan (y2 / x2) - arctan (y1 / x1)›*)
using ij (*‹i ∈ Basis› ‹j ∈ Basis›*) xy1 (*‹¦y1::real¦ < (x1::real)›*) xy2 (*‹¦y2¦ < x2›*) unfolding vangle_def
(*goal: ‹(if (x1::real) *⇩R (i::'a) + (y1::real) *⇩R (j::'a) = (0::'a) ∨ (x2::real) *⇩R i + (y2::real) *⇩R j = (0::'a) then pi / (2::real) else arccos ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))) = arctan (y2 / x2) - arctan (y1 / x1)›*)
apply (subst arccos_arctan (*‹⟦- 1 < ?x; ?x < 1⟧ ⟹ arccos ?x = pi / 2 - arctan (?x / sqrt (1 - ?x²))›*))
(*goal: ‹(if x1 *⇩R i + y1 *⇩R j = 0 ∨ x2 *⇩R i + y2 *⇩R j = 0 then pi / 2 else arccos ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))) = arctan (y2 / x2) - arctan (y1 / x1)›*)
subgoal for
apply (rule gt_minus_one_absI (*‹¦?k::real¦ < (1::real) ⟹ - (1::real) < ?k›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ - 1 < (x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j))›*)
apply simp
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ ¦(x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j))¦ < 1›*)
apply (subst pos_divide_less_eq (*‹0 < ?c ⟹ (?b / ?c < ?a) = (?b < ?a * ?c)›*))
(*goal: ‹⟦(i::'a::euclidean_space) ∈ Basis; (j::'a::euclidean_space) ∈ Basis; ¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real)⟧ ⟹ ¦(x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j)¦ / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)) < (1::real)›*)
subgoal for
apply (rule mult_pos_pos (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a * ?b›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ 0 < norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)›*)
using nonzeroes (*‹x1 *⇩R i + y1 *⇩R j ≠ 0› ‹x2 *⇩R i + y2 *⇩R j ≠ 0›*) apply -
(*goals:
1. ‹⟦(i::'a::euclidean_space) ∈ Basis; (j::'a::euclidean_space) ∈ Basis; ¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real); x1 *⇩R i + y1 *⇩R j ≠ (0::'a::euclidean_space); x2 *⇩R i + y2 *⇩R j ≠ (0::'a::euclidean_space)⟧ ⟹ (0::real) < norm (x1 *⇩R i + y1 *⇩R j)›
2. ‹⟦(i::'a::euclidean_space) ∈ Basis; (j::'a::euclidean_space) ∈ Basis; ¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real); x1 *⇩R i + y1 *⇩R j ≠ (0::'a::euclidean_space); x2 *⇩R i + y2 *⇩R j ≠ (0::'a::euclidean_space)⟧ ⟹ (0::real) < norm (x2 *⇩R i + y2 *⇩R j)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
subgoal for
apply simp
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ ¦(x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j)¦ < 1 * (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j))›*)
apply (rule Cauchy_Schwarz_strict_ineq2 (*‹⟦?y ≠ 0; ⋀k. ?x ≠ k *⇩R ?y⟧ ⟹ ¦?x ∙ ?y¦ < norm ?x * norm ?y›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ ¦(x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j)¦ < norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)›*)
using nonzeroes (*‹(x1::real) *⇩R (i::'a) + (y1::real) *⇩R (j::'a) ≠ (0::'a)› ‹(x2::real) *⇩R (i::'a) + (y2::real) *⇩R (j::'a) ≠ (0::'a)›*) indep (*‹(x1::real) *⇩R (i::'a::euclidean_space) + (y1::real) *⇩R (j::'a::euclidean_space) ≠ (?k::real) *⇩R ((x2::real) *⇩R i + (y2::real) *⇩R j)›*) apply -
(*goals:
1. ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; ⋀k. x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)⟧ ⟹ x2 *⇩R i + y2 *⇩R j ≠ 0›
2. ‹⋀k. ⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; ⋀k. x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)⟧ ⟹ x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) . .
subgoal for
apply (rule gt_one_absI (*‹¦?k::real¦ < (1::real) ⟹ ?k < (1::real)›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ (x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)) < 1›*)
apply simp
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ ¦(x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j))¦ < 1›*)
apply (subst pos_divide_less_eq (*‹0 < ?c ⟹ (?b / ?c < ?a) = (?b < ?a * ?c)›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ ¦(x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j)¦ / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)) < 1›*)
subgoal for
apply (rule mult_pos_pos (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a * ?b›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ 0 < norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)›*)
using nonzeroes (*‹x1 *⇩R i + y1 *⇩R j ≠ 0› ‹x2 *⇩R i + y2 *⇩R j ≠ 0›*) apply -
(*goals:
1. ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0⟧ ⟹ 0 < norm (x1 *⇩R i + y1 *⇩R j)›
2. ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0⟧ ⟹ 0 < norm (x2 *⇩R i + y2 *⇩R j)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
subgoal for
apply simp
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ ¦(x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j)¦ < 1 * (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j))›*)
apply (rule Cauchy_Schwarz_strict_ineq2 (*‹⟦(?y::?'a::real_inner) ≠ (0::?'a::real_inner); ⋀k::real. (?x::?'a::real_inner) ≠ k *⇩R ?y⟧ ⟹ ¦?x ∙ ?y¦ < norm ?x * norm ?y›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ ¦(x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j)¦ < norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)›*)
using nonzeroes (*‹x1 *⇩R i + y1 *⇩R j ≠ 0› ‹x2 *⇩R i + y2 *⇩R j ≠ 0›*) indep (*‹x1 *⇩R i + y1 *⇩R j ≠ ?k *⇩R (x2 *⇩R i + y2 *⇩R j)›*) apply -
(*goals:
1. ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; ⋀k. x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)⟧ ⟹ x2 *⇩R i + y2 *⇩R j ≠ 0›
2. ‹⋀k. ⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; ⋀k. x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)⟧ ⟹ x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) . .
subgoal for
apply (auto simp: nonzeroes (*‹(x1::real) *⇩R (i::'a) + (y1::real) *⇩R (j::'a) ≠ (0::'a)› ‹(x2::real) *⇩R (i::'a) + (y2::real) *⇩R (j::'a) ≠ (0::'a)›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ (if x1 *⇩R i + y1 *⇩R j = 0 ∨ x2 *⇩R i + y2 *⇩R j = 0 then pi / 2 else pi / 2 - arctan ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)) / sqrt (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))²))) = arctan (y2 / x2) - arctan (y1 / x1)›*)
apply (subst (3) diff_conv_add_uminus (*‹?a - ?b = ?a + - ?b›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ pi / 2 - arctan ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j) * sqrt (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))²))) = arctan (y2 / x2) - arctan (y1 / x1)›*)
apply (subst arctan_minus[symmetric] (*‹- arctan ?x = arctan (- ?x)›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ pi / 2 - arctan ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j) * sqrt (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))²))) = arctan (y2 / x2) + - arctan (y1 / x1)›*)
apply (subst arctan_add (*‹⟦¦?x¦ ≤ 1; ¦?y¦ < 1⟧ ⟹ arctan ?x + arctan ?y = arctan ((?x + ?y) / (1 - ?x * ?y))›*))
(*goal: ‹⟦(i::'a) ∈ Basis; (j::'a) ∈ Basis; ¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real)⟧ ⟹ pi / (2::real) - arctan ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j) * sqrt ((1::real) - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))²))) = arctan (y2 / x2) + arctan (- (y1 / x1))›*)
apply force
(*top goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ ¦y2 / x2¦ ≤ 1› and 2 goals remain*)
apply force
(*top goal: ‹⟦(i::'a::euclidean_space) ∈ Basis; (j::'a::euclidean_space) ∈ Basis; ¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real)⟧ ⟹ ¦- (y1 / x1)¦ < (1::real)› and 1 goal remains*)
apply (subst arctan_inverse[symmetric] (*‹(0::real) < (?x::real) ⟹ pi / (2::real) - arctan ?x = arctan (inverse ?x)›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ pi / 2 - arctan ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j) * sqrt (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))²))) = arctan ((y2 / x2 + - (y1 / x1)) / (1 - y2 / x2 * - (y1 / x1)))›*)
subgoal for
apply (rule divide_pos_pos (*‹⟦0 < ?x; 0 < ?y⟧ ⟹ 0 < ?x / ?y›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ 0 < (x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j) * sqrt (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))²))›*)
subgoal for
apply (auto simp add: inner_simps (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z› ‹?x ∙ (?y + ?z) = ?x ∙ ?y + ?x ∙ ?z› ‹?x ∙ (?y - ?z) = ?x ∙ ?y - ?x ∙ ?z› ‹(?x - ?y) ∙ ?z = ?x ∙ ?z - ?y ∙ ?z› ‹?r *⇩R ?x ∙ ?y = ?r * (?x ∙ ?y)› ‹?x ∙ ?r *⇩R ?y = ?r * (?x ∙ ?y)›*) inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*))
(*goals:
1. ‹⟦i ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; j = i⟧ ⟹ 0 < x1 * x2 + (x1 * y2 + (x2 * y1 + y1 * y2))›
2. ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; j ≠ i⟧ ⟹ 0 < x1 * x2 + y1 * y2›
discuss goal 1*)
apply (thin_tac "_ ∈ Basis")
(*top goal: ‹⟦i ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; j = i⟧ ⟹ 0 < x1 * x2 + (x1 * y2 + (x2 * y1 + y1 * y2))› and 1 goal remains*)
apply (thin_tac "j = i")
(*top goal: ‹⟦¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real); (j::'a) = (i::'a)⟧ ⟹ (0::real) < x1 * x2 + (x1 * y2 + (x2 * y1 + y1 * y2))› and 1 goal remains*)
apply (sos "((((A<0 * (A<1 * (A<2 * A<3))) * R<1) + ((A<=0 * (A<0 * (A<2 * R<1))) * (R<1 * [1]^2))))")
(*discuss goal 2*)
apply (thin_tac "_ ∈ Basis")
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; j ≠ i⟧ ⟹ 0 < x1 * x2 + y1 * y2›*)
apply (thin_tac "_ ∈ Basis")
(*goal: ‹⟦(j::'a) ∈ Basis; ¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real); j ≠ (i::'a)⟧ ⟹ (0::real) < x1 * x2 + y1 * y2›*)
apply (thin_tac "j ≠ i")
(*goal: ‹⟦¦y1¦ < x1; ¦y2¦ < x2; j ≠ i⟧ ⟹ 0 < x1 * x2 + y1 * y2›*)
apply (sos "((((A<0 * (A<1 * (A<2 * A<3))) * R<1) + (((A<2 * (A<3 * R<1)) * (R<1/3 * [y1]^2)) + (((A<1 * (A<3 * R<1)) * ((R<1/12 * [x2 + y1]^2) + (R<1/12 * [x1 + y2]^2))) + (((A<1 * (A<2 * R<1)) * (R<1/12 * [~1*x1 + x2 + y1 + y2]^2)) + (((A<0 * (A<3 * R<1)) * (R<1/12 * [~1*x1 + x2 + ~1*y1 + ~1*y2]^2)) + (((A<0 * (A<2 * R<1)) * ((R<1/12 * [x2 + ~1*y1]^2) + (R<1/12 * [~1*x1 + y2]^2))) + (((A<0 * (A<1 * R<1)) * (R<1/3 * [y2]^2)) + ((A<=0 * R<1) * (R<1/3 * [x1 + x2]^2))))))))))")
(*proven 2 subgoals*) .
subgoal for
apply (intro mult_pos_pos (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a * ?b›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ 0 < norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j) * sqrt (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))²)›*)
using nonzeroes (*‹x1 *⇩R i + y1 *⇩R j ≠ 0› ‹x2 *⇩R i + y2 *⇩R j ≠ 0›*) indep (*‹x1 *⇩R i + y1 *⇩R j ≠ ?k *⇩R (x2 *⇩R i + y2 *⇩R j)›*) apply -
(*goals:
1. ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; ⋀k. x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)⟧ ⟹ 0 < norm (x1 *⇩R i + y1 *⇩R j)›
2. ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; ⋀k. x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)⟧ ⟹ 0 < norm (x2 *⇩R i + y2 *⇩R j)›
3. ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; ⋀k. x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)⟧ ⟹ 0 < sqrt (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))²)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; ⋀k. x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)⟧ ⟹ 0 < sqrt (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))²)›*)
apply (rule gt_one_absI (*‹¦?k¦ < 1 ⟹ ?k < 1›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; ⋀k. x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)⟧ ⟹ ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))² < 1›*)
apply (simp add: power_divide (*‹(?a / ?b) ^ ?n = ?a ^ ?n / ?b ^ ?n›*) power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*) power2_norm_eq_inner (*‹(norm ?x)² = ?x ∙ ?x›*))
(*goal: ‹⟦(i::'a) ∈ Basis; (j::'a) ∈ Basis; ¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real); x1 *⇩R i + y1 *⇩R j ≠ (0::'a); x2 *⇩R i + y2 *⇩R j ≠ (0::'a); ⋀k::real. x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)⟧ ⟹ ¦((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))²¦ < (1::real)›*)
apply (rule Cauchy_Schwarz_strict_ineq (*‹⟦?y ≠ 0; ⋀k. ?x ≠ k *⇩R ?y⟧ ⟹ (?x ∙ ?y)² < ?x ∙ ?x * (?y ∙ ?y)›*))
(*goals:
1. ‹⟦(i::'a::euclidean_space) ∈ Basis; (j::'a::euclidean_space) ∈ Basis; ¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real); x1 *⇩R i + y1 *⇩R j ≠ (0::'a::euclidean_space); x2 *⇩R i + y2 *⇩R j ≠ (0::'a::euclidean_space); ⋀k::real. x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)⟧ ⟹ x2 *⇩R i + y2 *⇩R j ≠ (0::'a::euclidean_space)›
2. ‹⋀k::real. ⟦(i::'a::euclidean_space) ∈ Basis; (j::'a::euclidean_space) ∈ Basis; ¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real); x1 *⇩R i + y1 *⇩R j ≠ (0::'a::euclidean_space); x2 *⇩R i + y2 *⇩R j ≠ (0::'a::euclidean_space); ⋀k::real. x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)⟧ ⟹ x1 *⇩R i + y1 *⇩R j ≠ k *⇩R (x2 *⇩R i + y2 *⇩R j)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*)
(*proven 3 subgoals*) . .
subgoal for
apply (rule arg_cong[where f=arctan] (*‹?x = ?y ⟹ arctan ?x = arctan ?y›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ arctan (inverse ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j) * sqrt (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))²)))) = arctan ((y2 / x2 + - (y1 / x1)) / (1 - y2 / x2 * - (y1 / x1)))›*)
using nonzeroes (*‹x1 *⇩R i + y1 *⇩R j ≠ 0› ‹x2 *⇩R i + y2 *⇩R j ≠ 0›*) ij_neq (*‹i ≠ j›*) apply (auto simp: norm_eucl (*‹norm (?x *⇩R i + ?y *⇩R j) = sqrt ((norm ?x)² + (norm ?y)²)›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2⟧ ⟹ inverse ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j) * sqrt (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (norm (x1 *⇩R i + y1 *⇩R j) * norm (x2 *⇩R i + y2 *⇩R j)))²))) = (y2 / x2 + - (y1 / x1)) / (1 - y2 / x2 * - (y1 / x1))›*)
apply (subst real_sqrt_mult[symmetric] (*‹sqrt (?x::real) * sqrt (?y::real) = sqrt (?x * ?y)›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; i ≠ j⟧ ⟹ sqrt (x1² + y1²) * sqrt (x2² + y2²) * sqrt (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (sqrt (x1² + y1²) * sqrt (x2² + y2²)))²) / ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j)) = (y2 / x2 - y1 / x1) / (1 + y2 * y1 / (x2 * x1))›*)
apply (subst real_sqrt_mult[symmetric] (*‹sqrt (?x::real) * sqrt (?y::real) = sqrt (?x * ?y)›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; i ≠ j⟧ ⟹ sqrt ((x1² + y1²) * (x2² + y2²)) * sqrt (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (sqrt (x1² + y1²) * sqrt (x2² + y2²)))²) / ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j)) = (y2 / x2 - y1 / x1) / (1 + y2 * y1 / (x2 * x1))›*)
apply (subst real_sqrt_mult[symmetric] (*‹sqrt ?x * sqrt ?y = sqrt (?x * ?y)›*))
(*goal: ‹⟦(i::'a) ∈ Basis; (j::'a) ∈ Basis; ¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real); x1 *⇩R i + y1 *⇩R j ≠ (0::'a); x2 *⇩R i + y2 *⇩R j ≠ (0::'a); i ≠ j⟧ ⟹ sqrt ((x1² + y1²) * (x2² + y2²) * ((1::real) - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / (sqrt (x1² + y1²) * sqrt (x2² + y2²)))²)) / ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j)) = (y2 / x2 - y1 / x1) / ((1::real) + y2 * y1 / (x2 * x1))›*)
apply (subst power_divide (*‹((?a::?'a) / (?b::?'a)) ^ (?n::nat) = ?a ^ ?n / ?b ^ ?n›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; i ≠ j⟧ ⟹ sqrt ((x1² + y1²) * (x2² + y2²) * (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) / sqrt ((x1² + y1²) * (x2² + y2²)))²)) / ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j)) = (y2 / x2 - y1 / x1) / (1 + y2 * y1 / (x2 * x1))›*)
apply (subst real_sqrt_pow2 (*‹0 ≤ ?x ⟹ (sqrt ?x)² = ?x›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; i ≠ j⟧ ⟹ sqrt ((x1² + y1²) * (x2² + y2²) * (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j))² / (sqrt ((x1² + y1²) * (x2² + y2²)))²)) / ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j)) = (y2 / x2 - y1 / x1) / (1 + y2 * y1 / (x2 * x1))›*)
apply simp
(*top goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; i ≠ j⟧ ⟹ 0 ≤ (x1² + y1²) * (x2² + y2²)› and 1 goal remains*)
apply (subst nonzero_divide_eq_eq (*‹?c ≠ 0 ⟹ (?b / ?c = ?a) = (?b = ?a * ?c)›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; i ≠ j⟧ ⟹ sqrt ((x1² + y1²) * (x2² + y2²) * (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j))² / ((x1² + y1²) * (x2² + y2²)))) / ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j)) = (y2 / x2 - y1 / x1) / (1 + y2 * y1 / (x2 * x1))›*)
subgoal for
apply (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) inner_simps (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z› ‹?x ∙ (?y + ?z) = ?x ∙ ?y + ?x ∙ ?z› ‹?x ∙ (?y - ?z) = ?x ∙ ?y - ?x ∙ ?z› ‹(?x - ?y) ∙ ?z = ?x ∙ ?z - ?y ∙ ?z› ‹?r *⇩R ?x ∙ ?y = ?r * (?x ∙ ?y)› ‹?x ∙ ?r *⇩R ?y = ?r * (?x ∙ ?y)›*) inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; i ≠ j⟧ ⟹ (x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j) ≠ 0›*)
by (auto simp: algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 34 facts*) divide_simps (*‹inverse (?a::?'a) = (1::?'a) / ?a› ‹(?a::?'a) + (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z + ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (?a + ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (- ?a + ?b * ?z) / ?z)› ‹(?a::?'a) - (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z - ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (?a - ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (- ?a - ?b * ?z) / ?z)› ‹((?b::?'a) / (?c::?'a) = (?a::?'a)) = (if ?c ≠ (0::?'a) then ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = (?b::?'a) / (?c::?'a)) = (if ?c ≠ (0::?'a) then ?a * ?c = ?b else ?a = (0::?'a))› ‹(- ((?b::?'a) / (?c::?'a)) = (?a::?'a)) = (if ?c ≠ (0::?'a) then - ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = - ((?b::?'a) / (?c::?'a))) = (if ?c ≠ (0::?'a) then ?a * ?c = - ?b else ?a = (0::?'a))› ‹((?a::?'a) ≤ (?b::?'a) / (?c::?'a)) = (if (0::?'a) < ?c then ?a * ?c ≤ ?b else if ?c < (0::?'a) then ?b ≤ ?a * ?c else ?a ≤ (0::?'a))› and more 13 facts*) abs_real_def (*‹¦?a::real¦ = (if ?a < (0::real) then - ?a else ?a)›*) abs_impossible (*‹⟦¦?y1.0::real¦ < (?x1.0::real); ¦?y2.0::real¦ < (?x2.0::real)⟧ ⟹ ?x1.0 * ?x2.0 + ?y1.0 * ?y2.0 ≠ (0::real)›*))
apply (subst sqrt_eq (*‹sqrt (((x1::real)² + (y1::real)²) * ((x2::real)² + (y2::real)²) * ((1::real) - ((x1 *⇩R (i::'a::euclidean_space) + y1 *⇩R (j::'a::euclidean_space)) ∙ (x2 *⇩R i + y2 *⇩R j))² / ((x1² + y1²) * (x2² + y2²)))) = x1 * y2 - x2 * y1›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; i ≠ j⟧ ⟹ sqrt ((x1² + y1²) * (x2² + y2²) * (1 - ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j))² / ((x1² + y1²) * (x2² + y2²)))) = (y2 / x2 - y1 / x1) / (1 + y2 * y1 / (x2 * x1)) * ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j))›*)
apply (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) inner_simps (*‹(?x + ?y) ∙ ?z = ?x ∙ ?z + ?y ∙ ?z› ‹?x ∙ (?y + ?z) = ?x ∙ ?y + ?x ∙ ?z› ‹?x ∙ (?y - ?z) = ?x ∙ ?y - ?x ∙ ?z› ‹(?x - ?y) ∙ ?z = ?x ∙ ?z - ?y ∙ ?z› ‹?r *⇩R ?x ∙ ?y = ?r * (?x ∙ ?y)› ‹?x ∙ ?r *⇩R ?y = ?r * (?x ∙ ?y)›*) inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*))
(*goal: ‹⟦(i::'a) ∈ Basis; (j::'a) ∈ Basis; ¦y1::real¦ < (x1::real); ¦y2::real¦ < (x2::real); x1 *⇩R i + y1 *⇩R j ≠ (0::'a); x2 *⇩R i + y2 *⇩R j ≠ (0::'a); i ≠ j⟧ ⟹ x1 * y2 - x2 * y1 = (y2 / x2 - y1 / x1) / ((1::real) + y2 * y1 / (x2 * x1)) * ((x1 *⇩R i + y1 *⇩R j) ∙ (x2 *⇩R i + y2 *⇩R j))›*)
apply (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) abs_real_def (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*) abs_impossible (*‹⟦¦?y1.0¦ < ?x1.0; ¦?y2.0¦ < ?x2.0⟧ ⟹ ?x1.0 * ?x2.0 + ?y1.0 * ?y2.0 ≠ 0›*))
(*goal: ‹⟦i ∈ Basis; j ∈ Basis; ¦y1¦ < x1; ¦y2¦ < x2; x1 *⇩R i + y1 *⇩R j ≠ 0; x2 *⇩R i + y2 *⇩R j ≠ 0; i ≠ j; x2 ≠ 0⟧ ⟹ x1 * y2 = x2 * y1 + (x1 * y2 + y1 * (y2 * y2) / x2 - (x2 * y1 + y1 * (y1 * y2) / x1)) / (1 + y1 * y2 / (x1 * x2))›*)
by (auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) . .
qed
lemma vangle_le_pi2: "0 ≤ u ∙ v ⟹ vangle u v ≤ pi/2"
unfolding vangle_def atLeastAtMost_iff
(*goal: ‹0 ≤ u ∙ v ⟹ (if u = 0 ∨ v = 0 then pi / 2 else arccos (u ∙ v / (norm u * norm v))) ≤ pi / 2›*)
apply (simp del: le_divide_eq_numeral1 (*‹((?a::?'a) ≤ (?b::?'a) / numeral (?w::num)) = (?a * numeral ?w ≤ ?b)› ‹((?a::?'a) ≤ (?b::?'a) / - numeral (?w::num)) = (?b ≤ ?a * - numeral ?w)›*))
(*goal: ‹0 ≤ u ∙ v ⟹ (if u = 0 ∨ v = 0 then pi / 2 else arccos (u ∙ v / (norm u * norm v))) ≤ pi / 2›*)
apply (intro impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) arccos_le_pi2 (*‹⟦0 ≤ ?y; ?y ≤ 1⟧ ⟹ arccos ?y ≤ pi / 2›*) arccos_lbound (*‹⟦- 1 ≤ ?y; ?y ≤ 1⟧ ⟹ 0 ≤ arccos ?y›*))
(*goal: ‹0 ≤ u ∙ v ⟹ u ≠ 0 ∧ v ≠ 0 ⟶ arccos (u ∙ v / (norm u * norm v)) ≤ pi / 2›*)
using Cauchy_Schwarz_ineq2[of u v] (*‹¦(u::'a) ∙ (v::'a)¦ ≤ norm u * norm v›*) apply -
(*goals:
1. ‹⟦0 ≤ u ∙ v; u ≠ 0 ∧ v ≠ 0; ¦u ∙ v¦ ≤ norm u * norm v⟧ ⟹ 0 ≤ u ∙ v / (norm u * norm v)›
2. ‹⟦0 ≤ u ∙ v; u ≠ 0 ∧ v ≠ 0; ¦u ∙ v¦ ≤ norm u * norm v⟧ ⟹ u ∙ v / (norm u * norm v) ≤ 1›
discuss goal 1*)
apply ((auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*))[1])
(*discuss goal 2*)
apply ((auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*))[1])
(*proven 2 subgoals*) .
lemma inner_eq_vangle: "u ∙ v = cos (vangle u v) * (norm u * norm v)"
by (simp add: cos_vangle (*‹cos (vangle ?u ?v) = ?u ∙ ?v / (norm ?u * norm ?v)›*))
lemma vangle_scaleR_self:
"vangle (k *⇩R v) v = (if k = 0 ∨ v = 0 then pi / 2 else if k > 0 then 0 else pi)"
"vangle v (k *⇩R v) = (if k = 0 ∨ v = 0 then pi / 2 else if k > 0 then 0 else pi)"
(*goals:
1. ‹vangle (k *⇩R v) v = (if k = 0 ∨ v = 0 then pi / 2 else if 0 < k then 0 else pi)›
2. ‹vangle v (k *⇩R v) = (if k = 0 ∨ v = 0 then pi / 2 else if 0 < k then 0 else pi)›
discuss goal 1*)
apply ((auto simp: vangle_def (*‹vangle ?u ?v = (if ?u = 0 ∨ ?v = 0 then pi / 2 else arccos (?u ∙ ?v / (norm ?u * norm ?v)))›*) dot_square_norm (*‹?x ∙ ?x = (norm ?x)²›*) power2_eq_square (*‹?a² = ?a * ?a›*))[1])
(*discuss goal 2*)
apply ((auto simp: vangle_def (*‹vangle ?u ?v = (if ?u = 0 ∨ ?v = 0 then pi / 2 else arccos (?u ∙ ?v / (norm ?u * norm ?v)))›*) dot_square_norm (*‹?x ∙ ?x = (norm ?x)²›*) power2_eq_square (*‹?a² = ?a * ?a›*))[1])
(*proven 2 subgoals*) .
lemma vangle_scaleR:
"vangle (k *⇩R v) w = vangle v w" "vangle w (k *⇩R v) = vangle w v" if "k > 0"
using that (*‹0 < k›*) apply -
(*goals:
1. ‹0 < k ⟹ vangle (k *⇩R v) w = vangle v w›
2. ‹0 < k ⟹ vangle w (k *⇩R v) = vangle w v›
discuss goal 1*)
apply ((auto simp: vangle_def (*‹vangle ?u ?v = (if ?u = 0 ∨ ?v = 0 then pi / 2 else arccos (?u ∙ ?v / (norm ?u * norm ?v)))›*))[1])
(*discuss goal 2*)
apply ((auto simp: vangle_def (*‹vangle ?u ?v = (if ?u = 0 ∨ ?v = 0 then pi / 2 else arccos (?u ∙ ?v / (norm ?u * norm ?v)))›*))[1])
(*proven 2 subgoals*) .
lemma cos_vangle_eq_zero_iff_vangle:
"cos (vangle u v) = 0 ⟷ (u = 0 ∨ v = 0 ∨ u ∙ v = 0)"
using Cauchy_Schwarz_ineq2[of u v] (*‹¦u ∙ v¦ ≤ norm u * norm v›*) by (auto simp: vangle_def (*‹vangle ?u ?v = (if ?u = 0 ∨ ?v = 0 then pi / 2 else arccos (?u ∙ ?v / (norm ?u * norm ?v)))›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) algebra_split_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 27 facts*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
lemma ortho_imp_angle_pi_half: "u ∙ v = 0 ⟹ vangle u v = pi / 2"
using orthogonal_iff_vangle[of u v] (*‹orthogonal u v = (vangle u v = pi / 2)›*) by (auto simp: orthogonal_def (*‹orthogonal ?x ?y = (?x ∙ ?y = 0)›*))
lemma arccos_eq_zero_iff: "arccos x = 0 ⟷ x = 1" if "-1 ≤ x" "x ≤ 1"
using that (*‹- 1 ≤ x› ‹(x::real) ≤ (1::real)›*) apply auto
(*goal: ‹(arccos x = 0) = (x = 1)›*)
using cos_arccos (*‹⟦- 1 ≤ ?y; ?y ≤ 1⟧ ⟹ cos (arccos ?y) = ?y›*) by fastforce
lemma vangle_eq_zeroD: "vangle u v = 0 ⟹ (∃k. v = k *⇩R u)"
apply (auto simp: vangle_def (*‹vangle ?u ?v = (if ?u = 0 ∨ ?v = 0 then pi / 2 else arccos (?u ∙ ?v / (norm ?u * norm ?v)))›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
(*goal: ‹vangle u v = 0 ⟹ ∃k. v = k *⇩R u›*)
apply (subst (asm) arccos_eq_zero_iff (*‹⟦- (1::real) ≤ (?x::real); ?x ≤ (1::real)⟧ ⟹ (arccos ?x = (0::real)) = (?x = (1::real))›*))
(*goals:
1. ‹⟦u ≠ 0; v ≠ 0⟧ ⟹ - 1 ≤ u ∙ v / (norm u * norm v)›
2. ‹⟦u ≠ 0; v ≠ 0⟧ ⟹ u ∙ v / (norm u * norm v) ≤ 1›
3. ‹⟦u ∙ v / (norm u * norm v) = 1; u ≠ 0; v ≠ 0⟧ ⟹ ∃k. v = k *⇩R u›
discuss goal 1*)
apply ((auto simp: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) mult_less_0_iff (*‹(?a * ?b < 0) = (0 < ?a ∧ ?b < 0 ∨ ?a < 0 ∧ 0 < ?b)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*top goal: ‹⟦(u::'a::real_inner) ≠ (0::'a::real_inner); (v::'a::real_inner) ≠ (0::'a::real_inner)⟧ ⟹ - (1::real) ≤ u ∙ v / (norm u * norm v)› and 2 goals remain*)
apply (metis Real_Vector_Spaces.norm_minus_cancel (*‹norm (- (?x::?'a::real_normed_vector)) = norm ?x›*) inner_minus_left (*‹- (?x::?'a::real_inner) ∙ (?y::?'a::real_inner) = - (?x ∙ ?y)›*) minus_le_iff (*‹(- (?a::?'a::ordered_ab_group_add) ≤ (?b::?'a::ordered_ab_group_add)) = (- ?b ≤ ?a)›*) norm_cauchy_schwarz (*‹(?x::?'a::real_inner) ∙ (?y::?'a::real_inner) ≤ norm ?x * norm ?y›*))
(*discuss goal 2*)
apply ((auto simp: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) mult_less_0_iff (*‹(?a * ?b < 0) = (0 < ?a ∧ ?b < 0 ∨ ?a < 0 ∧ 0 < ?b)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*top goal: ‹⟦u ≠ 0; v ≠ 0⟧ ⟹ u ∙ v / (norm u * norm v) ≤ 1› and 1 goal remains*)
apply (metis norm_cauchy_schwarz (*‹?x ∙ ?y ≤ norm ?x * norm ?y›*))
(*discuss goal 3*)
apply ((auto simp: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) mult_less_0_iff (*‹(?a * ?b < 0) = (0 < ?a ∧ ?b < 0 ∨ ?a < 0 ∧ 0 < ?b)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1])
(*goal: ‹⟦u ∙ v / (norm u * norm v) = 1; u ≠ 0; v ≠ 0⟧ ⟹ ∃k. v = k *⇩R u›*)
apply (metis Cauchy_Schwarz_eq2_iff (*‹(¦?x ∙ ?y¦ = norm ?x * norm ?y) = ((∃k. ?x = k *⇩R ?y) ∨ ?y = 0)›*) abs_of_pos (*‹0 < ?a ⟹ ¦?a¦ = ?a›*) inner_commute (*‹?x ∙ ?y = ?y ∙ ?x›*) mult.commute (*‹?a * ?b = ?b * ?a›*) mult_sign_intros( (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a * ?b›*) 5) zero_less_norm_iff (*‹(0 < norm ?x) = (?x ≠ 0)›*))
(*proven 3 subgoals*) .
lemma less_one_multI:― ‹TODO: also in AA!›
fixes e x::real
shows "e ≤ 1 ⟹ 0 < x ⟹ x < 1 ⟹ e * x < 1"
by (metis (erased, opaque_lifting) less_eq_real_def (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*) monoid_mult_class.mult.left_neutral (*‹1 * ?a = ?a›*) mult_strict_mono (*‹⟦?a < ?b; ?c < ?d; 0 < ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c < ?b * ?d›*) zero_less_one (*‹0 < 1›*))
lemma conemem_expansion_estimate:
fixes u v u' v'::"'a::euclidean_space"
assumes "t ∈ {0 .. pi / 2}"
assumes angle_pos: "0 < vangle u v" "vangle u v < pi / 2"
assumes angle_le: "(vangle u' v') ≤ (vangle u v)"
assumes "norm u = 1" "norm v = 1"
shows "norm (conemem u' v' t) ≥ min (norm u') (norm v') * norm (conemem u v t)"
proof -
define e_pre where "e_pre = min (norm u') (norm v')"
let ?w = "conemem u v"
let ?w' = "conemem u' v'"
have cos_angle_le: "cos (vangle u' v') ≥ cos (vangle u v)"
using angle_pos vangle_bounds
by (auto intro!: cos_monotone_0_pi_le angle_le)
have e_pre_le: "e_pre² ≤ norm u' * norm v'"
by (auto simp: e_pre_def min_def power2_eq_square intro: mult_left_mono mult_right_mono)
have lt: "0 < 1 + 2 * (u ∙ v) * sin t * cos t"
proof -
have "¦u ∙ v¦ < norm u * norm v"
apply (rule Cauchy_Schwarz_strict_ineq2)
using assms
apply auto
apply (subst (asm) vangle_scaleR_self)+
by (auto simp: split: if_splits)
then have "abs (u ∙ v * sin (2 * t)) < 1"
using assms
apply (auto simp add: abs_mult)
apply (subst mult.commute)
apply (rule less_one_multI)
apply (auto simp add: abs_mult inner_eq_vangle )
by (auto simp: cos_vangle_eq_zero_iff_vangle dest!: ortho_imp_angle_pi_half)
then show ?thesis
by (subst mult.assoc sin_times_cos)+ auto
qed
have le: "0 ≤ 1 + 2 * (u ∙ v) * sin t * cos t"
proof -
have "¦u ∙ v¦ ≤ norm u * norm v"
by (rule Cauchy_Schwarz_ineq2)
then have "abs (u ∙ v * sin (2 * t)) ≤ 1"
by (auto simp add: abs_mult assms intro!: mult_le_one)
then show ?thesis
by (subst mult.assoc sin_times_cos)+ auto
qed
have "(norm (?w t))² = (cos t)² *⇩R (norm u)² + (sin t)² *⇩R (norm v)² + 2 * (u ∙ v) * sin t * cos t"
by (auto simp: conemem_def algebra_simps power2_norm_eq_inner)
(auto simp: power2_eq_square inner_commute)
also have "… = 1 + 2 * (u ∙ v) * sin t * cos t"
by (auto simp: sin_squared_eq algebra_simps assms)
finally have "(norm (conemem u v t))² = 1 + 2 * (u ∙ v) * sin t * cos t" by simp
moreover
have "(norm (?w' t))² = (cos t)² *⇩R (norm u')² + (sin t)² *⇩R (norm v')² + 2 * (u' ∙ v') * sin t * cos t"
by (auto simp: conemem_def algebra_simps power2_norm_eq_inner)
(auto simp: power2_eq_square inner_commute)
ultimately
have "(norm (?w' t) / norm (?w t))² =
((cos t)² *⇩R (norm u')² + (sin t)² *⇩R (norm v')² + 2 * (u' ∙ v') * sin t * cos t) /
(1 + 2 * (u ∙ v) * sin t * cos t)"
(is "_ = (?a + ?b) / ?c")
by (auto simp: divide_inverse power_mult_distrib) (auto simp: inverse_eq_divide power2_eq_square)
also have "… ≥ (e_pre² + ?b) / ?c"
apply (rule divide_right_mono)
apply (rule add_right_mono)
subgoal using assms e_pre_def
apply (auto simp: min_def)
subgoal by (auto simp: algebra_simps cos_squared_eq intro!: mult_right_mono power_mono)
subgoal by (auto simp: algebra_simps sin_squared_eq intro!: mult_right_mono power_mono)
done
subgoal by (rule le)
done
also (xtrans)
have inner_nonneg: "u' ∙ v' ≥ 0"
using angle_le(1) angle_pos vangle_bounds[of u' v']
by (auto simp: inner_eq_vangle intro!: mult_nonneg_nonneg cos_ge_zero)
from vangle_bounds[of u' v'] vangle_le_pi2[OF this]
have u'v'e_pre: "u' ∙ v' ≥ cos (vangle u' v') * e_pre²"
apply (subst inner_eq_vangle)
apply (rule mult_left_mono)
apply (rule e_pre_le)
apply (rule cos_ge_zero)
by auto
have "(e_pre² + ?b) / ?c ≥ (e_pre² + 2 * (cos (vangle u' v') * e_pre²) * sin t * cos t) / ?c"
(is "_ ≥ ?ddd")
apply (intro divide_right_mono add_left_mono mult_right_mono mult_left_mono u'v'e_pre)
using ‹t ∈ _›
by (auto intro!: mult_right_mono sin_ge_zero divide_right_mono le cos_ge_zero
simp: sin_times_cos u'v'e_pre)
also (xtrans) have "?ddd = e_pre² * ((1 + 2 * cos (vangle u' v') * sin t * cos t) / ?c)" (is "_ = ?ddd")
by (auto simp add: divide_simps algebra_simps)
also (xtrans)
have sc_ge_0: "0 ≤ sin t * cos t"
using ‹t ∈ _›
by (auto simp: assms cos_angle_le intro!: mult_nonneg_nonneg sin_ge_zero cos_ge_zero)
have "?ddd ≥ e_pre²"
apply (subst mult_le_cancel_left1)
apply (auto simp add: divide_simps split: if_splits)
apply (rule mult_right_mono)
using lt
by (auto simp: assms inner_eq_vangle intro!: mult_right_mono sc_ge_0 cos_angle_le)
finally (xtrans)
have "(norm (conemem u' v' t))² ≥ (e_pre * norm (conemem u v t))²"
by (simp add: divide_simps power_mult_distrib split: if_splits)
then show "norm (conemem u' v' t) ≥ e_pre * norm (conemem u v t)"
using norm_imp_pos_and_ge power2_le_imp_le by blast
qed
lemma conemem_commute: "conemem a b t = conemem b a (pi / 2 - t)" if "0 ≤ t" "t ≤ pi / 2"
using that (*‹0 ≤ t› ‹t ≤ pi / 2›*) by (auto simp: conemem_def (*‹conemem ?u ?v ?t = cos ?t *⇩R ?u + sin ?t *⇩R ?v›*) cos_sin_eq (*‹cos ?x = sin (of_real pi / 2 - ?x)›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*))
lemma conesegment_commute: "conesegment a b = conesegment b a"
apply (auto simp: conesegment_def (*‹conesegment ?u ?v = conemem ?u ?v ` {0..pi / 2}›*))
(*goals:
1. ‹⋀xa::real. ⟦(0::real) ≤ xa; xa * (2::real) ≤ pi⟧ ⟹ conemem (a::'a::real_vector) (b::'a::real_vector) xa ∈ conemem b a ` {0::real..pi / (2::real)}›
2. ‹⋀xa::real. ⟦(0::real) ≤ xa; xa * (2::real) ≤ pi⟧ ⟹ conemem (b::'a::real_vector) (a::'a::real_vector) xa ∈ conemem a b ` {0::real..pi / (2::real)}›
discuss goal 1*)
apply (subst conemem_commute (*‹⟦0 ≤ ?t; ?t ≤ pi / 2⟧ ⟹ conemem ?a ?b ?t = conemem ?b ?a (pi / 2 - ?t)›*))
(*goals:
1. ‹⋀xa. ⟦0 ≤ xa; xa * 2 ≤ pi⟧ ⟹ 0 ≤ xa›
2. ‹⋀xa. ⟦0 ≤ xa; xa * 2 ≤ pi⟧ ⟹ xa ≤ pi / 2›
3. ‹⋀xa. ⟦0 ≤ xa; xa * 2 ≤ pi⟧ ⟹ conemem b a (pi / 2 - xa) ∈ conemem b a ` {0..pi / 2}›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*)
(*discuss goal 2*)
apply (subst conemem_commute (*‹⟦0 ≤ ?t; ?t ≤ pi / 2⟧ ⟹ conemem ?a ?b ?t = conemem ?b ?a (pi / 2 - ?t)›*))
(*goals:
1. ‹⋀xa. ⟦0 ≤ xa; xa * 2 ≤ pi⟧ ⟹ 0 ≤ xa›
2. ‹⋀xa. ⟦0 ≤ xa; xa * 2 ≤ pi⟧ ⟹ xa ≤ pi / 2›
3. ‹⋀xa. ⟦0 ≤ xa; xa * 2 ≤ pi⟧ ⟹ conemem a b (pi / 2 - xa) ∈ conemem a b ` {0..pi / 2}›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*)
(*proven 2 subgoals*) .
definition "conefield u v = cone hull (conesegment u v)"
lemma conefield_alt_def: "conefield u v = cone hull {u--v}"
apply (auto simp: conesegment_def (*‹conesegment (?u::?'a) (?v::?'a) = conemem ?u ?v ` {0::real..pi / (2::real)}›*) conefield_def (*‹conefield (?u::?'a) (?v::?'a) = cone hull conesegment ?u ?v›*) cone_hull_expl (*‹cone hull (?S::?'a set) = {c *⇩R x |(c::real) x::?'a. (0::real) ≤ c ∧ x ∈ ?S}›*) in_segment (*‹((?x::?'a) ∈ {?a::?'a--?b::?'a}) = (∃u≥0::real. u ≤ (1::real) ∧ ?x = ((1::real) - u) *⇩R ?a + u *⇩R ?b)› ‹((?x::?'a) ∈ {?a::?'a<--<?b::?'a}) = (?a ≠ ?b ∧ (∃u>0::real. u < (1::real) ∧ ?x = ((1::real) - u) *⇩R ?a + u *⇩R ?b))›*))
(*goal: ‹conefield u v = cone hull {u--v}›*)
subgoalpremises prems for c and t
proof (-)
(*goal: ‹∃ca x. c *⇩R conemem u v t = ca *⇩R x ∧ 0 ≤ ca ∧ (∃ua≥0. ua ≤ 1 ∧ x = (1 - ua) *⇩R u + ua *⇩R v)›*)
from prems (*‹0 ≤ c› ‹0 ≤ t› ‹t * 2 ≤ pi›*) have sc_pos: "sin t + cos t > 0"
apply (cases "t = 0")
(*goal: ‹0 < sin t + cos t›*)
subgoal for
apply (rule add_nonneg_pos (*‹⟦0 ≤ ?a; 0 < ?b⟧ ⟹ 0 < ?a + ?b›*))
(*goals:
1. ‹⟦0 ≤ c; 0 ≤ t; t * 2 ≤ pi; t = 0⟧ ⟹ 0 ≤ sin t›
2. ‹⟦0 ≤ c; 0 ≤ t; t * 2 ≤ pi; t = 0⟧ ⟹ 0 < cos t›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
subgoal for
by (auto intro!: add_pos_nonneg (*‹⟦0 < ?a; 0 ≤ ?b⟧ ⟹ 0 < ?a + ?b›*) sin_gt_zero (*‹⟦0 < ?x; ?x < pi⟧ ⟹ 0 < sin ?x›*) cos_ge_zero (*‹⟦- (pi / 2) ≤ ?x; ?x ≤ pi / 2⟧ ⟹ 0 ≤ cos ?x›*)) .
then have 1: "(sin t / (sin t + cos t) + cos t / (sin t + cos t)) = 1"
by (auto simp: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*))
have "∃c x. c > 0 ∧ 0 ≤ x ∧ x ≤ 1 ∧ c *⇩R conemem u v t = (1 - x) *⇩R u + x *⇩R v"
apply (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) conemem_def (*‹conemem ?u ?v ?t = cos ?t *⇩R ?u + sin ?t *⇩R ?v›*))
(*goal: ‹∃c x. 0 < c ∧ 0 ≤ x ∧ x ≤ 1 ∧ c *⇩R conemem u v t = (1 - x) *⇩R u + x *⇩R v›*)
apply (rule exI[where x="1 / (sin t + cos t)"] (*‹(?P::real ⇒ bool) ((1::real) / (sin (t::real) + cos t)) ⟹ ∃x::real. ?P x›*))
(*goal: ‹∃c>0::real. ∃x≥0::real. x ≤ (1::real) ∧ x *⇩R (u::'a::real_vector) + ((c * cos (t::real)) *⇩R u + (c * sin t) *⇩R (v::'a::real_vector)) = u + x *⇩R v›*)
using prems (*‹0 ≤ c› ‹(0::real) ≤ (t::real)› ‹t * 2 ≤ pi›*) by (auto intro!: exI[where x="(1 / (sin t + cos t) * sin t)"] (*‹?P (1 / (sin t + cos t) * sin t) ⟹ ∃x. ?P x›*) sc_pos (*‹0 < sin t + cos t›*) divide_nonneg_nonneg (*‹⟦0 ≤ ?x; 0 ≤ ?y⟧ ⟹ 0 ≤ ?x / ?y›*) sin_ge_zero (*‹⟦0 ≤ ?x; ?x ≤ pi⟧ ⟹ 0 ≤ sin ?x›*) add_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a + ?b›*) cos_ge_zero (*‹⟦- (pi / 2) ≤ ?x; ?x ≤ pi / 2⟧ ⟹ 0 ≤ cos ?x›*) simp: scaleR_add_left[symmetric] (*‹?a *⇩R ?x + ?b *⇩R ?x = (?a + ?b) *⇩R ?x›*) 1 (*‹sin t / (sin t + cos t) + cos t / (sin t + cos t) = 1›*) divide_le_eq_1 (*‹(?b / ?a ≤ 1) = (0 < ?a ∧ ?b ≤ ?a ∨ ?a < 0 ∧ ?a ≤ ?b ∨ ?a = 0)›*))
then obtain d and x where dx: "d > 0" "conemem u v t = (1 / d) *⇩R ((1 - x) *⇩R u + x *⇩R v)" "0 ≤ x" "x ≤ 1"
(*goal: ‹(⋀d x. ⟦0 < d; conemem u v t = (1 / d) *⇩R ((1 - x) *⇩R u + x *⇩R v); 0 ≤ x; x ≤ 1⟧ ⟹ thesis) ⟹ thesis›*)
by (auto simp: eq_vector_fraction_iff (*‹(?x = (?u / ?v) *⇩R ?a) = (if ?v = 0 then ?x = 0 else ?v *⇩R ?x = ?u *⇩R ?a)›*))
show "?thesis"
(*goal: ‹∃ca x. c *⇩R conemem u v t = ca *⇩R x ∧ 0 ≤ ca ∧ (∃ua≥0. ua ≤ 1 ∧ x = (1 - ua) *⇩R u + ua *⇩R v)›*)
apply (rule exI[where x="c / d"] (*‹(?P::real ⇒ bool) ((c::real) / (d::real)) ⟹ ∃x::real. ?P x›*))
(*goal: ‹∃(ca::real) x::'a::real_vector. (c::real) *⇩R conemem (u::'a::real_vector) (v::'a::real_vector) (t::real) = ca *⇩R x ∧ (0::real) ≤ ca ∧ (∃ua≥0::real. ua ≤ (1::real) ∧ x = ((1::real) - ua) *⇩R u + ua *⇩R v)›*)
using dx (*‹0 < d› ‹conemem u v t = (1 / d) *⇩R ((1 - x) *⇩R u + x *⇩R v)› ‹0 ≤ x› ‹x ≤ 1›*) by (auto simp: intro!: divide_nonneg_nonneg (*‹⟦0 ≤ ?x; 0 ≤ ?y⟧ ⟹ 0 ≤ ?x / ?y›*) prems (*‹0 ≤ c› ‹0 ≤ t› ‹t * 2 ≤ pi›*))
qed
subgoalpremises prems for c and t
proof (-)
(*goal: ‹∃ca x. c *⇩R ((1 - t) *⇩R u + t *⇩R v) = ca *⇩R x ∧ 0 ≤ ca ∧ x ∈ conemem u v ` {0..pi / 2}›*)
let ?x = "arctan (t / (1 - t))"
let ?s = "t / sin ?x"
have "*": "c *⇩R ((1 - t) *⇩R u + t *⇩R v) = (c * ?s) *⇩R (cos ?x *⇩R u + sin ?x *⇩R v)" if "0 < t" "t < 1"
using that (*‹0 < t› ‹(t::real) < (1::real)›*) by (auto simp: scaleR_add_right (*‹?a *⇩R (?x + ?y) = ?a *⇩R ?x + ?a *⇩R ?y›*) sin_arctan (*‹sin (arctan ?x) = ?x / sqrt (1 + ?x²)›*) cos_arctan (*‹cos (arctan ?x) = 1 / sqrt (1 + ?x²)›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*))
show "?thesis"
(*goal: ‹∃ca x. c *⇩R ((1 - t) *⇩R u + t *⇩R v) = ca *⇩R x ∧ 0 ≤ ca ∧ x ∈ conemem u v ` {0..pi / 2}›*)
apply (cases "t = 0")
(*goal: ‹∃(ca::real) x::'a::real_vector. (c::real) *⇩R (((1::real) - (t::real)) *⇩R (u::'a::real_vector) + t *⇩R (v::'a::real_vector)) = ca *⇩R x ∧ (0::real) ≤ ca ∧ x ∈ conemem u v ` {0::real..pi / (2::real)}›*)
subgoal for
apply simp
(*goal: ‹(t::real) = (0::real) ⟹ ∃(ca::real) x::'a::real_vector. (c::real) *⇩R (((1::real) - t) *⇩R (u::'a::real_vector) + t *⇩R (v::'a::real_vector)) = ca *⇩R x ∧ (0::real) ≤ ca ∧ x ∈ conemem u v ` {0::real..pi / (2::real)}›*)
apply (rule exI[where x=c] (*‹(?P::real ⇒ bool) (c::real) ⟹ ∃x::real. ?P x›*))
(*goal: ‹t = 0 ⟹ ∃ca x. c *⇩R u = ca *⇩R x ∧ 0 ≤ ca ∧ x ∈ conemem u v ` {0..pi / 2}›*)
apply (rule exI[where x=u] (*‹?P u ⟹ ∃x. ?P x›*))
(*goal: ‹t = 0 ⟹ ∃x. c *⇩R u = c *⇩R x ∧ 0 ≤ c ∧ x ∈ conemem u v ` {0..pi / 2}›*)
using prems (*‹(0::real) ≤ (c::real)› ‹0 ≤ t› ‹(t::real) ≤ (1::real)›*) by (auto simp: conemem_def[abs_def] (*‹conemem ≡ λu v t. cos t *⇩R u + sin t *⇩R v›*) intro!: image_eqI[where x=0] (*‹⟦?b = ?f 0; 0 ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*))
subgoal for
apply (cases "t = 1")
(*goal: ‹t ≠ 0 ⟹ ∃ca x. c *⇩R ((1 - t) *⇩R u + t *⇩R v) = ca *⇩R x ∧ 0 ≤ ca ∧ x ∈ conemem u v ` {0..pi / 2}›*)
subgoal for
apply simp
(*goal: ‹⟦(t::real) ≠ (0::real); t = (1::real)⟧ ⟹ ∃(ca::real) x::'a::real_vector. (c::real) *⇩R (((1::real) - t) *⇩R (u::'a::real_vector) + t *⇩R (v::'a::real_vector)) = ca *⇩R x ∧ (0::real) ≤ ca ∧ x ∈ conemem u v ` {0::real..pi / (2::real)}›*)
apply (rule exI[where x=c] (*‹?P c ⟹ ∃x. ?P x›*))
(*goal: ‹t = 1 ⟹ ∃ca x. c *⇩R v = ca *⇩R x ∧ 0 ≤ ca ∧ x ∈ conemem u v ` {0..pi / 2}›*)
apply (rule exI[where x=v] (*‹?P v ⟹ ∃x. ?P x›*))
(*goal: ‹t = 1 ⟹ ∃x. c *⇩R v = c *⇩R x ∧ 0 ≤ c ∧ x ∈ conemem u v ` {0..pi / 2}›*)
using prems (*‹(0::real) ≤ (c::real)› ‹(0::real) ≤ (t::real)› ‹(t::real) ≤ (1::real)›*) by (auto simp: conemem_def[abs_def] (*‹conemem ≡ λu v t. cos t *⇩R u + sin t *⇩R v›*) intro!: image_eqI[where x="pi/2"] (*‹⟦?b = ?f (pi / 2); pi / 2 ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*))
subgoal for
apply (rule exI[where x="(c * ?s)"] (*‹?P (c * (t / sin (arctan (t / (1 - t))))) ⟹ ∃x. ?P x›*))
(*goal: ‹⟦t ≠ 0; t ≠ 1⟧ ⟹ ∃ca x. c *⇩R ((1 - t) *⇩R u + t *⇩R v) = ca *⇩R x ∧ 0 ≤ ca ∧ x ∈ conemem u v ` {0..pi / 2}›*)
apply (rule exI[where x="(cos ?x *⇩R u + sin ?x *⇩R v)"] (*‹(?P::'a::real_vector ⇒ bool) (cos (arctan ((t::real) / ((1::real) - t))) *⇩R (u::'a::real_vector) + sin (arctan (t / ((1::real) - t))) *⇩R (v::'a::real_vector)) ⟹ ∃x::'a::real_vector. ?P x›*))
(*goal: ‹⟦t ≠ 0; t ≠ 1⟧ ⟹ ∃x. c *⇩R ((1 - t) *⇩R u + t *⇩R v) = (c * (t / sin (arctan (t / (1 - t))))) *⇩R x ∧ 0 ≤ c * (t / sin (arctan (t / (1 - t)))) ∧ x ∈ conemem u v ` {0..pi / 2}›*)
using prems (*‹0 ≤ c› ‹0 ≤ t› ‹t ≤ 1›*) "*" (*‹⟦0 < t; t < 1⟧ ⟹ c *⇩R ((1 - t) *⇩R u + t *⇩R v) = (c * (t / sin (arctan (t / (1 - t))))) *⇩R (cos (arctan (t / (1 - t))) *⇩R u + sin (arctan (t / (1 - t))) *⇩R v)›*) arctan_ubound[of "t / (1 - t)"] (*‹arctan (t / (1 - t)) < pi / 2›*) apply (auto simp: conemem_def[abs_def] (*‹conemem ≡ λu v t. cos t *⇩R u + sin t *⇩R v›*) intro!: imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*))
(*goal: ‹⟦t ≠ 0; t ≠ 1⟧ ⟹ c *⇩R ((1 - t) *⇩R u + t *⇩R v) = (c * (t / sin (arctan (t / (1 - t))))) *⇩R (cos (arctan (t / (1 - t))) *⇩R u + sin (arctan (t / (1 - t))) *⇩R v) ∧ 0 ≤ c * (t / sin (arctan (t / (1 - t)))) ∧ cos (arctan (t / (1 - t))) *⇩R u + sin (arctan (t / (1 - t))) *⇩R v ∈ conemem u v ` {0..pi / 2}›*)
by (auto simp: scaleR_add_right (*‹?a *⇩R (?x + ?y) = ?a *⇩R ?x + ?a *⇩R ?y›*) sin_arctan (*‹sin (arctan ?x) = ?x / sqrt (1 + ?x²)›*)) . .
qed .
lemma
bounded_linear_image_cone_hull:
assumes "bounded_linear F"
shows "F ` (cone hull T) = cone hull (F ` T)"
proof (-)
(*goal: ‹(F::'a ⇒ 'b) ` (cone hull (T::'a set)) = cone hull F ` T›*)
from assms (*‹bounded_linear (F::'a::real_normed_vector ⇒ 'b::real_normed_vector)›*) interpret bounded_linear F .
show "?thesis"
(*goal: ‹F ` (cone hull T) = cone hull F ` T›*)
apply (auto simp: conefield_def (*‹conefield ?u ?v = cone hull conesegment ?u ?v›*) cone_hull_expl (*‹cone hull ?S = {c *⇩R x |c x. 0 ≤ c ∧ x ∈ ?S}›*) closed_segment_def (*‹{?a--?b} = {(1 - u) *⇩R ?a + u *⇩R ?b |u. 0 ≤ u ∧ u ≤ 1}›*) add (*‹F (?b1.0 + ?b2.0) = F ?b1.0 + F ?b2.0›*) scaleR (*‹F (?r *⇩R ?b) = ?r *⇩R F ?b›*))
(*goals:
1. ‹⋀c xb. ⟦0 ≤ c; xb ∈ T⟧ ⟹ ∃ca x. c *⇩R F xb = ca *⇩R x ∧ 0 ≤ ca ∧ x ∈ F ` T›
2. ‹⋀c xb. ⟦0 ≤ c; xb ∈ T⟧ ⟹ c *⇩R F xb ∈ F ` {c *⇩R x |c x. 0 ≤ c ∧ x ∈ T}›
discuss goal 1*)
apply auto
(*discuss goal 2*)
apply (auto simp: add[symmetric] (*‹F ?b1.0 + F ?b2.0 = F (?b1.0 + ?b2.0)›*) scaleR[symmetric] (*‹?r *⇩R F ?b = F (?r *⇩R ?b)›*))
(*proven 2 subgoals*) .
qed
lemma
bounded_linear_image_conefield:
assumes "bounded_linear F"
shows "F ` conefield u v = conefield (F u) (F v)"
unfolding conefield_def
(*goal: ‹F ` (cone hull conesegment u v) = cone hull conesegment (F u) (F v)›*)
using assms (*‹bounded_linear (F::'a ⇒ 'b)›*) by (auto simp: bounded_linear_image_conesegment (*‹bounded_linear ?F ⟹ ?F ` conesegment ?u ?v = conesegment (?F ?u) (?F ?v)›*) bounded_linear_image_cone_hull (*‹bounded_linear ?F ⟹ ?F ` (cone hull ?T) = cone hull ?F ` ?T›*))
lemma conefield_commute: "conefield x y = conefield y x"
by (auto simp: conefield_def (*‹conefield ?u ?v = cone hull conesegment ?u ?v›*) conesegment_commute (*‹conesegment ?a ?b = conesegment ?b ?a›*))
lemma convex_conefield: "convex (conefield x y)"
by (auto simp: conefield_alt_def (*‹conefield (?u::?'a) (?v::?'a) = cone hull {?u--?v}›*) convex_cone_hull (*‹convex (?S::?'a set) ⟹ convex (cone hull ?S)›*))
lemma conefield_scaleRI: "v ∈ conefield (r *⇩R x) y" if "v ∈ conefield x y" "r > 0"
using that (*‹v ∈ conefield x y› ‹0 < r›*) using ‹r > 0› (*‹0 < r›*) unfolding conefield_alt_def cone_hull_expl
(*goal: ‹v ∈ {c *⇩R xa |c xa. 0 ≤ c ∧ xa ∈ {r *⇩R x--y}}›*)
apply (auto simp: in_segment (*‹(?x ∈ {?a--?b}) = (∃u≥0. u ≤ 1 ∧ ?x = (1 - u) *⇩R ?a + u *⇩R ?b)› ‹(?x ∈ {?a<--<?b}) = (?a ≠ ?b ∧ (∃u>0. u < 1 ∧ ?x = (1 - u) *⇩R ?a + u *⇩R ?b))›*))
(*goal: ‹(v::'a::real_vector) ∈ {c *⇩R xa |(c::real) xa::'a::real_vector. (0::real) ≤ c ∧ xa ∈ {(r::real) *⇩R (x::'a::real_vector)--y::'a::real_vector}}›*)
proof (goal_cases)
(*goal: ‹⋀c u. ⟦0 < r; v = c *⇩R ((1 - u) *⇩R x + u *⇩R y); 0 ≤ c; 0 ≤ u; u ≤ 1⟧ ⟹ ∃ca xa. c *⇩R ((1 - u) *⇩R x + u *⇩R y) = ca *⇩R xa ∧ 0 ≤ ca ∧ (∃u≥0. u ≤ 1 ∧ xa = ((1 - u) * r) *⇩R x + u *⇩R y)›*)
case (1 c u) (*‹0 < r› ‹v = c *⇩R ((1 - u) *⇩R x + u *⇩R y)› ‹(0::real) ≤ (c::real)› ‹0 ≤ u› ‹u ≤ 1›*)
let ?d = "c * (1 - u) / r + c * u"
let ?t = "c * u / ?d"
have "c * (1 - u) = ?d * (1 - ?t) * r" if "0 < u"
using ‹0 < r› (*‹0 < r›*) that(1) (*‹0 < u›*) "1"(3,5) (*‹(0::real) ≤ (c::real)› ‹u ≤ 1›*) mult_pos_pos (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a * ?b›*) by (force simp: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 37 facts*) ring_distribs[symmetric] (*‹?a * ?b + ?a * ?c = ?a * (?b + ?c)› ‹?a * ?c + ?b * ?c = (?a + ?b) * ?c› ‹?a * ?c - ?b * ?c = (?a - ?b) * ?c› ‹?a * ?b - ?a * ?c = ?a * (?b - ?c)›*))
then have eq1: "(c * (1 - u)) *⇩R x = (?d * (1 - ?t) * r) *⇩R x" if "0 < u"
using that (*‹0 < u›*) by simp
have "c * u = ?d * ?t" if "u < 1"
using ‹0 < r› (*‹0 < r›*) that(1) (*‹u < 1›*) "1"(3,4,5) (*‹(0::real) ≤ (c::real)› ‹0 ≤ u› ‹(u::real) ≤ (1::real)›*) mult_pos_pos (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a * ?b›*) proof (auto simp: divide_simps (*‹inverse (?a::?'a) = (1::?'a) / ?a› ‹(?a::?'a) + (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z + ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (?a + ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (- ?a + ?b * ?z) / ?z)› ‹(?a::?'a) - (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z - ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (?a - ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (- ?a - ?b * ?z) / ?z)› ‹((?b::?'a) / (?c::?'a) = (?a::?'a)) = (if ?c ≠ (0::?'a) then ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = (?b::?'a) / (?c::?'a)) = (if ?c ≠ (0::?'a) then ?a * ?c = ?b else ?a = (0::?'a))› ‹(- ((?b::?'a) / (?c::?'a)) = (?a::?'a)) = (if ?c ≠ (0::?'a) then - ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = - ((?b::?'a) / (?c::?'a))) = (if ?c ≠ (0::?'a) then ?a * ?c = - ?b else ?a = (0::?'a))› ‹((?a::?'a) ≤ (?b::?'a) / (?c::?'a)) = (if (0::?'a) < ?c then ?a * ?c ≤ ?b else if ?c < (0::?'a) then ?b ≤ ?a * ?c else ?a ≤ (0::?'a))› and more 13 facts*) ac_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 37 facts*) ring_distribs[symmetric] (*‹(?a::?'a) * (?b::?'a) + ?a * (?c::?'a) = ?a * (?b + ?c)› ‹(?a::?'a) * (?c::?'a) + (?b::?'a) * ?c = (?a + ?b) * ?c› ‹(?a::?'a) * (?c::?'a) - (?b::?'a) * ?c = (?a - ?b) * ?c› ‹(?a::?'a) * (?b::?'a) - ?a * (?c::?'a) = ?a * (?b - ?c)›*))
(*goal: ‹⟦0 < r; u < 1; 0 ≤ c; 0 ≤ u; ⋀a b. ⟦0 < a; 0 < b⟧ ⟹ 0 < a * b; 1 - u + r * u = 0; c ≠ 0⟧ ⟹ u = 0›*)
assume "0 ≤ u" "0 < r" "1 - u + r * u = 0" "u < 1" (*‹(0::real) ≤ (u::real)› ‹(0::real) < (r::real)› ‹(1::real) - (u::real) + (r::real) * u = (0::real)› ‹(u::real) < (1::real)›*)
then have False
by (sos "((((A<0 * A<1) * R<1) + (([~1*r] * A=0) + ((A<=0 * R<1) * (R<1 * [r]^2)))))")
then show "u = 0"
by metis
qed
then have eq2: "(c * u) *⇩R y = (?d * ?t) *⇩R y" if "u < 1"
using that (*‹u < 1›*) by simp
have "*": "c *⇩R ((1 - u) *⇩R x + u *⇩R y) = ?d *⇩R ((1 - ?t) *⇩R r *⇩R x + ?t *⇩R y)" if "0 < u" "u < 1"
using that (*‹0 < u› ‹u < 1›*) eq1 (*‹0 < u ⟹ (c * (1 - u)) *⇩R x = ((c * (1 - u) / r + c * u) * (1 - c * u / (c * (1 - u) / r + c * u)) * r) *⇩R x›*) eq2 (*‹(u::real) < (1::real) ⟹ ((c::real) * u) *⇩R (y::'a) = ((c * ((1::real) - u) / (r::real) + c * u) * (c * u / (c * ((1::real) - u) / r + c * u))) *⇩R y›*) by (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*))
show "?case"
(*goal: ‹∃(ca::real) xa::'a. (c::real) *⇩R (((1::real) - (u::real)) *⇩R (x::'a) + u *⇩R (y::'a)) = ca *⇩R xa ∧ (0::real) ≤ ca ∧ (∃u≥0::real. u ≤ (1::real) ∧ xa = (((1::real) - u) * (r::real)) *⇩R x + u *⇩R y)›*)
apply (cases "u = 0")
(*goal: ‹∃ca xa. c *⇩R ((1 - u) *⇩R x + u *⇩R y) = ca *⇩R xa ∧ 0 ≤ ca ∧ (∃u≥0. u ≤ 1 ∧ xa = ((1 - u) * r) *⇩R x + u *⇩R y)›*)
subgoal for
using "1" (*‹0 < r› ‹v = c *⇩R ((1 - u) *⇩R x + u *⇩R y)› ‹0 ≤ c› ‹0 ≤ u› ‹(u::real) ≤ (1::real)›*) apply (intro exI[where x="c / r"] (*‹?P (c / r) ⟹ ∃x. ?P x›*) exI[where x="r *⇩R x"] (*‹?P (r *⇩R x) ⟹ ∃x. ?P x›*))
(*goal: ‹u = 0 ⟹ ∃ca xa. c *⇩R ((1 - u) *⇩R x + u *⇩R y) = ca *⇩R xa ∧ 0 ≤ ca ∧ (∃u≥0. u ≤ 1 ∧ xa = ((1 - u) * r) *⇩R x + u *⇩R y)›*)
by auto
apply (cases "u = 1")
(*goal: ‹u ≠ 0 ⟹ ∃ca xa. c *⇩R ((1 - u) *⇩R x + u *⇩R y) = ca *⇩R xa ∧ 0 ≤ ca ∧ (∃u≥0. u ≤ 1 ∧ xa = ((1 - u) * r) *⇩R x + u *⇩R y)›*)
subgoal for
using "1" (*‹0 < r› ‹v = c *⇩R ((1 - u) *⇩R x + u *⇩R y)› ‹0 ≤ c› ‹0 ≤ u› ‹u ≤ 1›*) apply (intro exI[where x="c"] (*‹?P c ⟹ ∃x. ?P x›*) exI[where x="y"] (*‹?P y ⟹ ∃x. ?P x›*))
(*goal: ‹⟦u ≠ 0; u = 1⟧ ⟹ ∃ca xa. c *⇩R ((1 - u) *⇩R x + u *⇩R y) = ca *⇩R xa ∧ 0 ≤ ca ∧ (∃u≥0. u ≤ 1 ∧ xa = ((1 - u) * r) *⇩R x + u *⇩R y)›*)
by (auto intro!: exI[where x=1] (*‹?P 1 ⟹ ∃x. ?P x›*))
subgoal for
apply (rule exI[where x="?d"] (*‹?P (c * (1 - u) / r + c * u) ⟹ ∃x. ?P x›*))
(*goal: ‹⟦u ≠ 0; u ≠ 1⟧ ⟹ ∃ca xa. c *⇩R ((1 - u) *⇩R x + u *⇩R y) = ca *⇩R xa ∧ 0 ≤ ca ∧ (∃u≥0. u ≤ 1 ∧ xa = ((1 - u) * r) *⇩R x + u *⇩R y)›*)
apply (rule exI[where x="((1 - ?t) *⇩R r *⇩R x + ?t *⇩R y)"] (*‹(?P::'a::real_vector ⇒ bool) (((1::real) - (c::real) * (u::real) / (c * ((1::real) - u) / (r::real) + c * u)) *⇩R r *⇩R (x::'a::real_vector) + (c * u / (c * ((1::real) - u) / r + c * u)) *⇩R (y::'a::real_vector)) ⟹ ∃x::'a::real_vector. ?P x›*))
(*goal: ‹⟦u ≠ 0; u ≠ 1⟧ ⟹ ∃xa. c *⇩R ((1 - u) *⇩R x + u *⇩R y) = (c * (1 - u) / r + c * u) *⇩R xa ∧ 0 ≤ c * (1 - u) / r + c * u ∧ (∃u≥0. u ≤ 1 ∧ xa = ((1 - u) * r) *⇩R x + u *⇩R y)›*)
apply (subst * (*‹⟦0 < u; u < 1⟧ ⟹ c *⇩R ((1 - u) *⇩R x + u *⇩R y) = (c * (1 - u) / r + c * u) *⇩R ((1 - c * u / (c * (1 - u) / r + c * u)) *⇩R r *⇩R x + (c * u / (c * (1 - u) / r + c * u)) *⇩R y)›*))
(*goal: ‹⟦u ≠ 0; u ≠ 1⟧ ⟹ c *⇩R ((1 - u) *⇩R x + u *⇩R y) = (c * (1 - u) / r + c * u) *⇩R ((1 - c * u / (c * (1 - u) / r + c * u)) *⇩R r *⇩R x + (c * u / (c * (1 - u) / r + c * u)) *⇩R y) ∧ 0 ≤ c * (1 - u) / r + c * u ∧ (∃ua≥0. ua ≤ 1 ∧ (1 - c * u / (c * (1 - u) / r + c * u)) *⇩R r *⇩R x + (c * u / (c * (1 - u) / r + c * u)) *⇩R y = ((1 - ua) * r) *⇩R x + ua *⇩R y)›*)
using "1" (*‹0 < r› ‹v = c *⇩R ((1 - u) *⇩R x + u *⇩R y)› ‹0 ≤ c› ‹0 ≤ u› ‹u ≤ 1›*) apply (auto intro!: exI[where x = ?t] (*‹?P (c * u / (c * (1 - u) / r + c * u)) ⟹ ∃x. ?P x›*))
(*top goal: ‹⟦u ≠ 0; u ≠ 1⟧ ⟹ 0 < u› and 2 goals remain*)
apply (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*))
(*goal: ‹⟦u ≠ 0; u ≠ 1; 0 < r; v = c *⇩R ((1 - u) *⇩R x + u *⇩R y); 0 ≤ c; 0 ≤ u; u ≤ 1⟧ ⟹ c * u / (c * (1 - u) / r + c * u) ≤ 1›*)
defer 1
(*top goal: ‹⟦u ≠ 0; u ≠ 1; 0 < r; v + (c * u) *⇩R x = c *⇩R x + (c * u) *⇩R y; 0 ≤ c; 0 ≤ u; u ≤ 1; c * u < c + c * (r * u)⟧ ⟹ c * u ≤ c› and 1 goal remains*)
proof (-)
(*goals:
1. ‹⟦u ≠ 0; u ≠ 1; 0 < r; v + (c * u) *⇩R x = c *⇩R x + (c * u) *⇩R y; 0 ≤ c; 0 ≤ u; u ≤ 1; c * u < c + c * (r * u)⟧ ⟹ c * u ≤ c›
2. ‹⟦u ≠ 0; u ≠ 1; 0 < r; v + (c * u) *⇩R x = c *⇩R x + (c * u) *⇩R y; 0 ≤ c; 0 ≤ u; u ≤ 1; c + c * (r * u) < c * u⟧ ⟹ c ≤ c * u›*)
assume a1: "c + c * (r * u) < c * u" (*‹(c::real) + c * ((r::real) * (u::real)) < c * u›*)
assume a2: "0 ≤ c" (*‹(0::real) ≤ (c::real)›*)
assume a3: "0 ≤ u" (*‹(0::real) ≤ (u::real)›*)
assume a4: "u ≠ 0" (*‹(u::real) ≠ (0::real)›*)
assume a5: "0 < r" (*‹(0::real) < (r::real)›*)
have "c + c * (r * u) ≤ c * u"
using a1 (*‹c + c * (r * u) < c * u›*) less_eq_real_def (*‹((?x::real) ≤ (?y::real)) = (?x < ?y ∨ ?x = ?y)›*) by blast
then show "c ≤ c * u"
using a5 (*‹(0::real) < (r::real)›*) a4 (*‹u ≠ 0›*) a3 (*‹0 ≤ u›*) a2 (*‹(0::real) ≤ (c::real)›*) by (metis (no_types) less_add_same_cancel1 (*‹(?a < ?a + ?b) = (0 < ?b)›*) less_eq_real_def (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*) mult_pos_pos (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a * ?b›*) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) real_scaleR_def (*‹?a *⇩R ?x = ?a * ?x›*) real_vector.scale_zero_left (*‹0 *⇩R ?x = 0›*))
next
(*goal: ‹⟦u ≠ 0; u ≠ 1; 0 < r; v + (c * u) *⇩R x = c *⇩R x + (c * u) *⇩R y; 0 ≤ c; 0 ≤ u; u ≤ 1; c * u < c + c * (r * u)⟧ ⟹ c * u ≤ c›*)
assume a1: "0 ≤ c" (*‹(0::real) ≤ (c::real)›*)
assume a2: "u ≤ 1" (*‹(u::real) ≤ (1::real)›*)
have f3: "∀x0. ((x0::real) < 1) = (¬ 1 ≤ x0)"
by auto
have f4: "∀x0. ((1::real) < x0) = (¬ x0 ≤ 1)"
by fastforce
have "∀x0 x1. ((x1::real) < x1 * x0) = (¬ 0 ≤ x1 + - 1 * (x1 * x0))"
by auto
then have "(∀r ra. ((r::real) < r * ra) = ((0 ≤ r ⟶ 1 < ra) ∧ (r ≤ 0 ⟶ ra < 1))) = (∀r ra. (¬ (0::real) ≤ r + - 1 * (r * ra)) = ((¬ 0 ≤ r ∨ ¬ ra ≤ 1) ∧ (¬ r ≤ 0 ∨ ¬ 1 ≤ ra)))"
using f4 (*‹∀x0. (1 < x0) = (¬ x0 ≤ 1)›*) f3 (*‹∀x0. (x0 < 1) = (¬ 1 ≤ x0)›*) by presburger
then have "0 ≤ c + - 1 * (c * u)"
using a2 (*‹u ≤ 1›*) a1 (*‹0 ≤ c›*) mult_less_cancel_left1 (*‹(?c < ?c * ?b) = ((0 ≤ ?c ⟶ 1 < ?b) ∧ (?c ≤ 0 ⟶ ?b < 1))›*) by blast
then show "c * u ≤ c"
by auto
qed .
qed
lemma conefield_scaleRD: "v ∈ conefield x y" if "v ∈ conefield (r *⇩R x) y" "r > 0"
using conefield_scaleRI[OF that ( 1 ) positive_imp_inverse_positive [ OF that ( 2 ) ]] (*‹v ∈ conefield (r *⇩R x /⇩R r) y›*) that(2) (*‹0 < r›*) by auto
lemma conefield_scaleR: "conefield (r *⇩R x) y = conefield x y" if "r > 0"
using conefield_scaleRD (*‹⟦?v ∈ conefield (?r *⇩R ?x) ?y; 0 < ?r⟧ ⟹ ?v ∈ conefield ?x ?y›*) conefield_scaleRI (*‹⟦?v ∈ conefield ?x ?y; 0 < ?r⟧ ⟹ ?v ∈ conefield (?r *⇩R ?x) ?y›*) that (*‹0 < r›*) by blast
lemma conefield_expansion_estimate:
fixes u v::"'a::euclidean_space" and F::"'a ⇒ 'a"
assumes "t ∈ {0 .. pi / 2}"
assumes angle_pos: "0 < vangle u v" "vangle u v < pi / 2"
assumes angle_le: "vangle (F u) (F v) ≤ vangle u v"
assumes "bounded_linear F"
assumes "x ∈ conefield u v"
shows "norm (F x) ≥ min (norm (F u)/norm u) (norm (F v)/norm v) * norm x"
proof (cases)
(*goals:
1. ‹?P ⟹ min (norm (F u) / norm u) (norm (F v) / norm v) * norm x ≤ norm (F x)›
2. ‹¬ ?P ⟹ min (norm (F u) / norm u) (norm (F v) / norm v) * norm x ≤ norm (F x)›*)
assume [simp]: "x ≠ 0" (*‹(x::'a) ≠ (0::'a)›*)
from assms (*‹t ∈ {0..pi / 2}› ‹0 < vangle u v› ‹vangle u v < pi / 2› ‹vangle (F u) (F v) ≤ vangle u v› ‹bounded_linear (F::'a ⇒ 'a)› ‹x ∈ conefield u v›*) have [simp]: "u ≠ 0" "v ≠ 0"
apply -
(*goals:
1. ‹⟦t ∈ {0..pi / 2}; 0 < vangle u v; vangle u v < pi / 2; vangle (F u) (F v) ≤ vangle u v; bounded_linear F; x ∈ conefield u v⟧ ⟹ u ≠ 0›
2. ‹⟦t ∈ {0..pi / 2}; 0 < vangle u v; vangle u v < pi / 2; vangle (F u) (F v) ≤ vangle u v; bounded_linear F; x ∈ conefield u v⟧ ⟹ v ≠ 0›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
interpret bounded_linear F
by fact
define u1 where "u1 = u /⇩R norm u"
define v1 where "v1 = v /⇩R norm v"
note ‹x ∈ conefield u v› (*‹x ∈ conefield u v›*)
also (*calculation: ‹x ∈ conefield u v›*) have "conefield u v = conefield u1 v1"
by (auto simp: u1_def (*‹u1 = u /⇩R norm u›*) v1_def (*‹v1 = v /⇩R norm v›*) conefield_scaleR (*‹0 < ?r ⟹ conefield (?r *⇩R ?x) ?y = conefield ?x ?y›*) conefield_commute[of u] (*‹conefield u ?y = conefield ?y u›*))
finally (*calculation: ‹x ∈ conefield u1 v1›*) obtain c and t where x: "x = c *⇩R conemem u1 v1 t" "t ∈ {0 .. pi / 2}" "c ≥ 0"
(*goal: ‹(⋀c t. ⟦x = c *⇩R conemem u1 v1 t; t ∈ {0..pi / 2}; 0 ≤ c⟧ ⟹ thesis) ⟹ thesis›*)
by (auto simp: conefield_def (*‹conefield ?u ?v = cone hull conesegment ?u ?v›*) cone_hull_expl (*‹cone hull ?S = {c *⇩R x |c x. 0 ≤ c ∧ x ∈ ?S}›*) conesegment_def (*‹conesegment ?u ?v = conemem ?u ?v ` {0..pi / 2}›*))
then have xc: "x /⇩R c = conemem u1 v1 t"
by (auto simp: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*))
also (*calculation: ‹(x::'a) /⇩R (c::real) = conemem (u1::'a) (v1::'a) (t::real)›*) have "F … = conemem (F u1) (F v1) t"
by (simp add: bounded_linear_image_conemem (*‹bounded_linear (?F::?'a ⇒ ?'b) ⟹ ?F (conemem (?u::?'a) (?v::?'a) (?t::real)) = conemem (?F ?u) (?F ?v) ?t›*) assms (*‹(t::real) ∈ {0::real..pi / (2::real)}› ‹(0::real) < vangle (u::'a) (v::'a)› ‹vangle (u::'a) (v::'a) < pi / (2::real)› ‹vangle ((F::'a ⇒ 'a) (u::'a)) (F (v::'a)) ≤ vangle u v› ‹bounded_linear (F::'a ⇒ 'a)› ‹(x::'a) ∈ conefield (u::'a) (v::'a)›*))
also (*calculation: ‹(F::'a ⇒ 'a) ((x::'a) /⇩R (c::real)) = conemem (F (u1::'a)) (F (v1::'a)) (t::real)›*) have "norm … ≥ min (norm (F u1)) (norm (F v1)) * norm (conemem u1 v1 t)"
apply (rule conemem_expansion_estimate (*‹⟦?t ∈ {0..pi / 2}; 0 < vangle ?u ?v; vangle ?u ?v < pi / 2; vangle ?u' ?v' ≤ vangle ?u ?v; norm ?u = 1; norm ?v = 1⟧ ⟹ min (norm ?u') (norm ?v') * norm (conemem ?u ?v ?t) ≤ norm (conemem ?u' ?v' ?t)›*))
(*goal: ‹min (norm (F u1)) (norm (F v1)) * norm (conemem u1 v1 t) ≤ norm (conemem (F u1) (F v1) t)›*)
subgoal for
by fact
subgoal for
using angle_pos (*‹0 < vangle u v› ‹vangle u v < pi / 2›*) by (simp add: u1_def (*‹u1 = u /⇩R norm u›*) v1_def (*‹v1 = v /⇩R norm v›*) vangle_scaleR (*‹0 < ?k ⟹ vangle (?k *⇩R ?v) ?w = vangle ?v ?w› ‹0 < ?k ⟹ vangle ?w (?k *⇩R ?v) = vangle ?w ?v›*))
subgoal for
using angle_pos (*‹0 < vangle u v› ‹vangle u v < pi / 2›*) by (simp add: u1_def (*‹u1 = u /⇩R norm u›*) v1_def (*‹v1 = v /⇩R norm v›*) vangle_scaleR (*‹0 < ?k ⟹ vangle (?k *⇩R ?v) ?w = vangle ?v ?w› ‹0 < ?k ⟹ vangle ?w (?k *⇩R ?v) = vangle ?w ?v›*))
subgoal for
using angle_le (*‹vangle ((F::'a ⇒ 'a) (u::'a)) (F (v::'a)) ≤ vangle u v›*) by (simp add: u1_def (*‹u1 = u /⇩R norm u›*) v1_def (*‹v1 = v /⇩R norm v›*) scaleR (*‹F (?r *⇩R ?b) = ?r *⇩R F ?b›*) vangle_scaleR (*‹0 < ?k ⟹ vangle (?k *⇩R ?v) ?w = vangle ?v ?w› ‹0 < ?k ⟹ vangle ?w (?k *⇩R ?v) = vangle ?w ?v›*))
subgoal for
using angle_le (*‹vangle (F u) (F v) ≤ vangle u v›*) by (simp add: u1_def (*‹u1 = u /⇩R norm u›*) v1_def (*‹v1 = v /⇩R norm v›*) scaleR (*‹F (?r *⇩R ?b) = ?r *⇩R F ?b›*) vangle_scaleR (*‹0 < ?k ⟹ vangle (?k *⇩R ?v) ?w = vangle ?v ?w› ‹0 < ?k ⟹ vangle ?w (?k *⇩R ?v) = vangle ?w ?v›*))
subgoal for
using angle_le (*‹vangle ((F::'a::euclidean_space ⇒ 'a::euclidean_space) (u::'a::euclidean_space)) (F (v::'a::euclidean_space)) ≤ vangle u v›*) by (simp add: u1_def (*‹u1 = u /⇩R norm u›*) v1_def (*‹v1 = v /⇩R norm v›*) scaleR (*‹F (?r *⇩R ?b) = ?r *⇩R F ?b›*) vangle_scaleR (*‹0 < ?k ⟹ vangle (?k *⇩R ?v) ?w = vangle ?v ?w› ‹0 < ?k ⟹ vangle ?w (?k *⇩R ?v) = vangle ?w ?v›*)) .
finally (*calculation: ‹min (norm ((F::'a::euclidean_space ⇒ 'a::euclidean_space) (u1::'a::euclidean_space))) (norm (F (v1::'a::euclidean_space))) * norm (conemem u1 v1 (t::real)) ≤ norm (F ((x::'a::euclidean_space) /⇩R (c::real)))›*) show "norm (F x) ≥ min (norm (F u)/norm u) (norm (F v)/norm v) * norm x"
unfolding xc[symmetric] scaleR u1_def v1_def norm_scaleR x
(*goal: ‹min (norm ((F::'a ⇒ 'a) (u::'a)) / norm u) (norm (F (v::'a)) / norm v) * (¦c::real¦ * norm (conemem (u /⇩R norm u) (v /⇩R norm v) (t::real))) ≤ ¦c¦ * norm (F (conemem (u /⇩R norm u) (v /⇩R norm v) t))›*)
using ‹c ≥ 0› (*‹0 ≤ c›*) by (simp add: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
qed (simp)
(*solved the remaining goal: ‹¬ (x::'a::euclidean_space) ≠ (0::'a::euclidean_space) ⟹ min (norm ((F::'a::euclidean_space ⇒ 'a::euclidean_space) (u::'a::euclidean_space)) / norm u) (norm (F (v::'a::euclidean_space)) / norm v) * norm x ≤ norm (F x)›*)
lemma conefield_rightI:
assumes ij: "i ∈ Basis" "j ∈ Basis" and ij_neq: "i ≠ j"
assumes "y ∈ {y1 .. y2}"
shows "(i + y *⇩R j) ∈ conefield (i + y1 *⇩R j) (i + y2 *⇩R j)"
sorry
lemma conefield_right_vangleI:
assumes ij: "i ∈ Basis" "j ∈ Basis" and ij_neq: "i ≠ j"
assumes "y ∈ {y1 .. y2}" "y1 < y2"
shows "(i + y *⇩R j) ∈ conefield (i + y1 *⇩R j) (i + y2 *⇩R j)"
unfolding conefield_alt_def
(*goal: ‹i + y *⇩R j ∈ cone hull {i + y1 *⇩R j--i + y2 *⇩R j}›*)
apply (rule hull_inc (*‹?x ∈ ?S ⟹ ?x ∈ ?P hull ?S›*))
(*goal: ‹i + y *⇩R j ∈ cone hull {i + y1 *⇩R j--i + y2 *⇩R j}›*)
using assms (*‹i ∈ Basis› ‹j ∈ Basis› ‹i ≠ j› ‹(y::real) ∈ {y1::real..y2::real}› ‹y1 < y2›*) by (auto simp: in_segment (*‹(?x ∈ {?a--?b}) = (∃u≥0. u ≤ 1 ∧ ?x = (1 - u) *⇩R ?a + u *⇩R ?b)› ‹(?x ∈ {?a<--<?b}) = (?a ≠ ?b ∧ (∃u>0. u < 1 ∧ ?x = (1 - u) *⇩R ?a + u *⇩R ?b))›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) intro!: exI[where x="(y - y1) / (y2 - y1)"] (*‹?P ((y - y1) / (y2 - y1)) ⟹ ∃x. ?P x›*) euclidean_eqI[where 'a='a] (*‹(⋀b. b ∈ Basis ⟹ ?x ∙ b = ?y ∙ b) ⟹ ?x = ?y›*))
lemma cone_conefield[intro, simp]: "cone (conefield x y)"
unfolding conefield_def
(*goal: ‹cone (cone hull conesegment x y)›*)
by (rule cone_cone_hull (*‹cone (cone hull ?S)›*))
lemma conefield_mk_rightI:
assumes ij: "i ∈ Basis" "j ∈ Basis" and ij_neq: "i ≠ j"
assumes "(i + (y / x) *⇩R j) ∈ conefield (i + (y1 / x1) *⇩R j) (i + (y2 / x2) *⇩R j)"
assumes "x > 0" "x1 > 0" "x2 > 0"
shows "(x *⇩R i + y *⇩R j) ∈ conefield (x1 *⇩R i + y1 *⇩R j) (x2 *⇩R i + y2 *⇩R j)"
proof (-)
(*goal: ‹x *⇩R i + y *⇩R j ∈ conefield (x1 *⇩R i + y1 *⇩R j) (x2 *⇩R i + y2 *⇩R j)›*)
have rescale: "(x *⇩R i + y *⇩R j) = x *⇩R (i + (y / x) *⇩R j)" if "x > 0" for x and y
using that (*‹0 < x›*) by (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*))
show "?thesis"
(*goal: ‹(x::real) *⇩R (i::'a::euclidean_space) + (y::real) *⇩R (j::'a::euclidean_space) ∈ conefield ((x1::real) *⇩R i + (y1::real) *⇩R j) ((x2::real) *⇩R i + (y2::real) *⇩R j)›*)
unfolding rescale[OF ‹x > 0›] rescale[OF ‹x1 > 0›] rescale[OF ‹x2 > 0›] conefield_scaleR[OF ‹x1 > 0›]
(*goal: ‹(x::real) *⇩R ((i::'a) + ((y::real) / x) *⇩R (j::'a)) ∈ conefield (i + ((y1::real) / (x1::real)) *⇩R j) ((x2::real) *⇩R (i + ((y2::real) / x2) *⇩R j))›*)
apply (subst conefield_commute (*‹conefield ?x ?y = conefield ?y ?x›*))
(*goal: ‹(x::real) *⇩R ((i::'a) + ((y::real) / x) *⇩R (j::'a)) ∈ conefield (i + ((y1::real) / (x1::real)) *⇩R j) ((x2::real) *⇩R (i + ((y2::real) / x2) *⇩R j))›*)
unfolding conefield_scaleR[OF ‹x2 > 0›]
(*goal: ‹(x::real) *⇩R ((i::'a) + ((y::real) / x) *⇩R (j::'a)) ∈ conefield (i + ((y2::real) / (x2::real)) *⇩R j) (i + ((y1::real) / (x1::real)) *⇩R j)›*)
apply (rule mem_cone (*‹⟦cone ?S; ?x ∈ ?S; 0 ≤ ?c⟧ ⟹ ?c *⇩R ?x ∈ ?S›*))
(*goals:
1. ‹cone (conefield (i + (y2 / x2) *⇩R j) (i + (y1 / x1) *⇩R j))›
2. ‹i + (y / x) *⇩R j ∈ conefield (i + (y2 / x2) *⇩R j) (i + (y1 / x1) *⇩R j)›
3. ‹0 ≤ x›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (subst conefield_commute (*‹conefield ?x ?y = conefield ?y ?x›*))
(*top goal: ‹(i::'a::euclidean_space) + ((y::real) / (x::real)) *⇩R (j::'a::euclidean_space) ∈ conefield (i + ((y2::real) / (x2::real)) *⇩R j) (i + ((y1::real) / (x1::real)) *⇩R j)› and 1 goal remains*)
apply ((auto intro!: assms (*‹i ∈ Basis› ‹j ∈ Basis› ‹i ≠ j› ‹i + (y / x) *⇩R j ∈ conefield (i + (y1 / x1) *⇩R j) (i + (y2 / x2) *⇩R j)› ‹0 < x› ‹0 < x1› ‹0 < x2›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1])
(*discuss goal 3*)
apply ((auto intro!: assms (*‹i ∈ Basis› ‹j ∈ Basis› ‹i ≠ j› ‹i + (y / x) *⇩R j ∈ conefield (i + (y1 / x1) *⇩R j) (i + (y2 / x2) *⇩R j)› ‹0 < x› ‹0 < x1› ‹0 < x2›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1])
(*proven 3 subgoals*) .
qed
lemma conefield_prod3I:
assumes "x > 0" "x1 > 0" "x2 > 0"
assumes "y1 / x1 ≤ y / x" "y / x ≤ y2 / x2"
shows "(x, y, 0) ∈ (conefield (x1, y1, 0) (x2, y2, 0)::(real*real*real) set)"
proof (-)
(*goal: ‹(x, y, 0) ∈ conefield (x1, y1, 0) (x2, y2, 0)›*)
have "(x *⇩R (1, 0, 0) + y *⇩R (0, 1, 0)) ∈
(conefield (x1 *⇩R (1, 0, 0) + y1 *⇩R (0, 1, 0)) (x2 *⇩R (1, 0, 0) + y2 *⇩R (0, 1, 0))::(real*real*real) set)"
apply (rule conefield_mk_rightI (*‹⟦?i ∈ Basis; ?j ∈ Basis; ?i ≠ ?j; ?i + (?y / ?x) *⇩R ?j ∈ conefield (?i + (?y1.0 / ?x1.0) *⇩R ?j) (?i + (?y2.0 / ?x2.0) *⇩R ?j); 0 < ?x; 0 < ?x1.0; 0 < ?x2.0⟧ ⟹ ?x *⇩R ?i + ?y *⇩R ?j ∈ conefield (?x1.0 *⇩R ?i + ?y1.0 *⇩R ?j) (?x2.0 *⇩R ?i + ?y2.0 *⇩R ?j)›*))
(*goal: ‹(x::real) *⇩R (1::real, 0::real, 0::real) + (y::real) *⇩R (0::real, 1::real, 0::real) ∈ conefield ((x1::real) *⇩R (1::real, 0::real, 0::real) + (y1::real) *⇩R (0::real, 1::real, 0::real)) ((x2::real) *⇩R (1::real, 0::real, 0::real) + (y2::real) *⇩R (0::real, 1::real, 0::real))›*)
subgoal for
by (auto simp: Basis_prod_def (*‹Basis = (λu. (u, 0)) ` Basis ∪ Pair 0 ` Basis›*) zero_prod_def (*‹0 = (0, 0)›*))
subgoal for
by (auto simp: Basis_prod_def (*‹Basis = (λu. (u, 0)) ` Basis ∪ Pair 0 ` Basis›*) zero_prod_def (*‹0 = (0, 0)›*))
subgoal for
by (auto simp: Basis_prod_def (*‹Basis = (λu. (u, 0)) ` Basis ∪ Pair 0 ` Basis›*) zero_prod_def (*‹0 = (0, 0)›*))
subgoal for
using assms (*‹0 < x› ‹0 < x1› ‹0 < x2› ‹y1 / x1 ≤ y / x› ‹y / x ≤ y2 / x2›*) apply (intro conefield_rightI (*‹⟦(?i::?'a) ∈ Basis; (?j::?'a) ∈ Basis; ?i ≠ ?j; (?y::real) ∈ {?y1.0::real..?y2.0::real}⟧ ⟹ ?i + ?y *⇩R ?j ∈ conefield (?i + ?y1.0 *⇩R ?j) (?i + ?y2.0 *⇩R ?j)›*))
(*goals:
1. ‹⟦0 < x; 0 < x1; 0 < x2; y1 / x1 ≤ y / x; y / x ≤ y2 / x2⟧ ⟹ (1, 0, 0) ∈ Basis›
2. ‹⟦0 < x; 0 < x1; 0 < x2; y1 / x1 ≤ y / x; y / x ≤ y2 / x2⟧ ⟹ (0, 1, 0) ∈ Basis›
3. ‹⟦0 < x; 0 < x1; 0 < x2; y1 / x1 ≤ y / x; y / x ≤ y2 / x2⟧ ⟹ (1, 0, 0) ≠ (0, 1, 0)›
4. ‹⟦0 < x; 0 < x1; 0 < x2; y1 / x1 ≤ y / x; y / x ≤ y2 / x2⟧ ⟹ y / x ∈ {y1 / x1..y2 / x2}›
discuss goal 1*)
apply ((auto simp: Basis_prod_def (*‹Basis = (λu. (u, 0)) ` Basis ∪ Pair 0 ` Basis›*) zero_prod_def (*‹0 = (0, 0)›*))[1])
(*discuss goal 2*)
apply ((auto simp: Basis_prod_def (*‹Basis = (λu. (u, 0)) ` Basis ∪ Pair 0 ` Basis›*) zero_prod_def (*‹0 = (0, 0)›*))[1])
(*discuss goal 3*)
apply ((auto simp: Basis_prod_def (*‹Basis = (λu::?'a::euclidean_space. (u, 0::?'b::euclidean_space)) ` Basis ∪ Pair (0::?'a::euclidean_space) ` Basis›*) zero_prod_def (*‹(0::?'a::zero × ?'b::zero) = (0::?'a::zero, 0::?'b::zero)›*))[1])
(*discuss goal 4*)
apply ((auto simp: Basis_prod_def (*‹Basis = (λu. (u, 0)) ` Basis ∪ Pair 0 ` Basis›*) zero_prod_def (*‹0 = (0, 0)›*))[1])
(*proven 4 subgoals*) .
(*goals:
1. ‹(0::real) < (x::real)›
2. ‹(0::real) < (x1::real)›
3. ‹(0::real) < (x2::real)›
discuss goal 1*)
apply ((auto intro: assms (*‹0 < x› ‹0 < x1› ‹0 < x2› ‹y1 / x1 ≤ y / x› ‹y / x ≤ y2 / x2›*))[1])
(*discuss goal 2*)
apply ((auto intro: assms (*‹0 < x› ‹0 < x1› ‹0 < x2› ‹y1 / x1 ≤ y / x› ‹y / x ≤ y2 / x2›*))[1])
(*discuss goal 3*)
apply ((auto intro: assms (*‹0 < x› ‹0 < x1› ‹0 < x2› ‹y1 / x1 ≤ y / x› ‹y / x ≤ y2 / x2›*))[1])
(*proven 3 subgoals*) .
then show "?thesis"
(*goal: ‹(x, y, 0) ∈ conefield (x1, y1, 0) (x2, y2, 0)›*)
by simp
qed
end
| {
"path": "afp-2025-02-12/thys/Ordinary_Differential_Equations/IVP/Cones.thy",
"repo": "afp-2025-02-12",
"sha": "e36a2519331c2e0b88c9f1a721fba7bc0670e2e70a0afe1899297f3563a3a027"
} |
theory ResNormDirect
imports ResNormalForm
begin
section‹Direct Resource Term Normalisation›
text‹
In this section we define a normalisation procedure for resource terms that directly normalises a
term in a single bottom-up pass.
This could be considered normalisation by evaluation as opposed to by rewriting.
Note that, while this procedure is more computationally efficient, it is less useful in proofs.
In this way it is complemented by rewriting-based normalisation that is less direct but more
helpful in inductive proofs.
›
text‹
First, for a list of terms where no @{const Parallel} term contains an @{const Empty} term, the
order of @{const merge_all_parallel} and @{const remove_all_empty} does not matter.
This is specifically the case for a list of normalised terms.
As such, our choice of order in the normalisation definition does not matter.
›
lemma merge_all_parallel_remove_all_empty_comm:
assumes "⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Empty ys"
shows "merge_all_parallel (remove_all_empty xs) = remove_all_empty (merge_all_parallel xs)"
using assms (*‹Parallel ?ys ∈ set xs ⟹ ¬ list_ex is_Empty ?ys›*) proof (induct xs)
(*goals:
1. ‹(⋀ys::('a::type, 'b::type) res_term list. Parallel ys ∈ set [] ⟹ ¬ list_ex is_Empty ys) ⟹ merge_all_parallel (remove_all_empty []) = remove_all_empty (merge_all_parallel [])›
2. ‹⋀(a::('a::type, 'b::type) res_term) xs::('a::type, 'b::type) res_term list. ⟦(⋀ys::('a::type, 'b::type) res_term list. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Empty ys) ⟹ merge_all_parallel (remove_all_empty xs) = remove_all_empty (merge_all_parallel xs); ⋀ys::('a::type, 'b::type) res_term list. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Empty ys⟧ ⟹ merge_all_parallel (remove_all_empty (a # xs)) = remove_all_empty (merge_all_parallel (a # xs))›*)
case Nil (*‹Parallel (?ys::('a::type, 'b::type) res_term list) ∈ set [] ⟹ ¬ list_ex is_Empty ?ys›*)
then show "?case"
(*goal: ‹merge_all_parallel (remove_all_empty []) = remove_all_empty (merge_all_parallel [])›*)
by simp
next
(*goal: ‹⋀(a::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦(⋀ys::('a, 'b) res_term list. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Empty ys) ⟹ merge_all_parallel (remove_all_empty xs) = remove_all_empty (merge_all_parallel xs); ⋀ys::('a, 'b) res_term list. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Empty ys⟧ ⟹ merge_all_parallel (remove_all_empty (a # xs)) = remove_all_empty (merge_all_parallel (a # xs))›*)
case (Cons a xs) (*‹(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Empty ys) ⟹ merge_all_parallel (remove_all_empty xs) = remove_all_empty (merge_all_parallel xs)› ‹Parallel ?ys ∈ set (a # xs) ⟹ ¬ list_ex is_Empty ?ys›*)
then show "?case"
(*goal: ‹merge_all_parallel (remove_all_empty (a # xs)) = remove_all_empty (merge_all_parallel (a # xs))›*)
apply (cases a)
(*goals:
1. ‹⋀x1. ⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Empty ys) ⟹ merge_all_parallel (remove_all_empty xs) = remove_all_empty (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Empty ys; a = Res x1⟧ ⟹ merge_all_parallel (remove_all_empty (a # xs)) = remove_all_empty (merge_all_parallel (a # xs))›
2. ‹⋀x2. ⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Empty ys) ⟹ merge_all_parallel (remove_all_empty xs) = remove_all_empty (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Empty ys; a = Copyable x2⟧ ⟹ merge_all_parallel (remove_all_empty (a # xs)) = remove_all_empty (merge_all_parallel (a # xs))›
3. ‹⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Empty ys) ⟹ merge_all_parallel (remove_all_empty xs) = remove_all_empty (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Empty ys; a = Empty⟧ ⟹ merge_all_parallel (remove_all_empty (a # xs)) = remove_all_empty (merge_all_parallel (a # xs))›
4. ‹⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Empty ys) ⟹ merge_all_parallel (remove_all_empty xs) = remove_all_empty (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Empty ys; a = Anything⟧ ⟹ merge_all_parallel (remove_all_empty (a # xs)) = remove_all_empty (merge_all_parallel (a # xs))›
5. ‹⋀x5. ⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Empty ys) ⟹ merge_all_parallel (remove_all_empty xs) = remove_all_empty (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Empty ys; a = Parallel x5⟧ ⟹ merge_all_parallel (remove_all_empty (a # xs)) = remove_all_empty (merge_all_parallel (a # xs))›
6. ‹⋀x61 x62. ⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Empty ys) ⟹ merge_all_parallel (remove_all_empty xs) = remove_all_empty (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Empty ys; a = NonD x61 x62⟧ ⟹ merge_all_parallel (remove_all_empty (a # xs)) = remove_all_empty (merge_all_parallel (a # xs))›
7. ‹⋀x71 x72. ⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Empty ys) ⟹ merge_all_parallel (remove_all_empty xs) = remove_all_empty (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Empty ys; a = Executable x71 x72⟧ ⟹ merge_all_parallel (remove_all_empty (a # xs)) = remove_all_empty (merge_all_parallel (a # xs))›
8. ‹⋀x81 x82. ⟦(⋀ys. Parallel ys ∈ set xs ⟹ ¬ list_ex is_Empty ys) ⟹ merge_all_parallel (remove_all_empty xs) = remove_all_empty (merge_all_parallel xs); ⋀ys. Parallel ys ∈ set (a # xs) ⟹ ¬ list_ex is_Empty ys; a = Repeatable x81 x82⟧ ⟹ merge_all_parallel (remove_all_empty (a # xs)) = remove_all_empty (merge_all_parallel (a # xs))›
discuss goal 1*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) remove_all_empty_none (*‹¬ list_ex is_Empty ?xs ⟹ remove_all_empty ?xs = ?xs›*))
(*discuss goal 2*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) remove_all_empty_none (*‹¬ list_ex is_Empty ?xs ⟹ remove_all_empty ?xs = ?xs›*))
(*discuss goal 3*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) remove_all_empty_none (*‹¬ list_ex is_Empty ?xs ⟹ remove_all_empty ?xs = ?xs›*))
(*discuss goal 4*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) remove_all_empty_none (*‹¬ list_ex is_Empty ?xs ⟹ remove_all_empty ?xs = ?xs›*))
(*discuss goal 5*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty ((?xs::(?'a, ?'b) res_term list) @ (?ys::(?'a, ?'b) res_term list)) = remove_all_empty ?xs @ remove_all_empty ?ys›*) remove_all_empty_none (*‹¬ list_ex is_Empty (?xs::(?'a, ?'b) res_term list) ⟹ remove_all_empty ?xs = ?xs›*))
(*discuss goal 6*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) remove_all_empty_none (*‹¬ list_ex is_Empty ?xs ⟹ remove_all_empty ?xs = ?xs›*))
(*discuss goal 7*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) remove_all_empty_none (*‹¬ list_ex is_Empty ?xs ⟹ remove_all_empty ?xs = ?xs›*))
(*discuss goal 8*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) remove_all_empty_none (*‹¬ list_ex is_Empty ?xs ⟹ remove_all_empty ?xs = ?xs›*))
(*proven 8 subgoals*) .
qed
text‹
Direct normalisation of resource terms proceeds in a single bottom-up pass.
The interesting case is for @{const Parallel} terms, where any @{const Empty} and nested
@{const Parallel} children are handled using @{const parallel_parts} and the resulting list is
turned into the simplest term representing its parallel combination using @{const parallelise}.
›
primrec normal_dir :: "('a, 'b) res_term ⇒ ('a, 'b) res_term"
where
"normal_dir Empty = Empty"
| "normal_dir Anything = Anything"
| "normal_dir (Res x) = Res x"
| "normal_dir (Copyable x) = Copyable x"
| "normal_dir (Parallel xs) =
parallelise (merge_all_parallel (remove_all_empty (map normal_dir xs)))"
| "normal_dir (NonD x y) = NonD (normal_dir x) (normal_dir y)"
| "normal_dir (Executable x y) = Executable (normal_dir x) (normal_dir y)"
| "normal_dir (Repeatable x y) = Repeatable (normal_dir x) (normal_dir y)"
text‹Any resource term is equivalent to its direct normalisation›
lemma normal_dir_equiv:
"a ∼ normal_dir a"
proof (induct a)
(*goals:
1. ‹⋀x. Res x ∼ normal_dir (Res x)›
2. ‹⋀x. Copyable x ∼ normal_dir (Copyable x)›
3. ‹Empty ∼ normal_dir Empty›
4. ‹Anything ∼ normal_dir Anything›
5. ‹⋀x. (⋀xa. xa ∈ set x ⟹ xa ∼ normal_dir xa) ⟹ Parallel x ∼ normal_dir (Parallel x)›
6. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ NonD a1 a2 ∼ normal_dir (NonD a1 a2)›
7. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Executable a1 a2 ∼ normal_dir (Executable a1 a2)›
8. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Repeatable a1 a2 ∼ normal_dir (Repeatable a1 a2)›*)
case Empty (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹Empty ∼ normal_dir Empty›*)
by simp
next
(*goals:
1. ‹⋀x::'a. Res x ∼ normal_dir (Res x)›
2. ‹⋀x::'b. Copyable x ∼ normal_dir (Copyable x)›
3. ‹Anything ∼ normal_dir Anything›
4. ‹⋀x::('a, 'b) res_term list. (⋀xa::('a, 'b) res_term. xa ∈ set x ⟹ xa ∼ normal_dir xa) ⟹ Parallel x ∼ normal_dir (Parallel x)›
5. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ NonD a1 a2 ∼ normal_dir (NonD a1 a2)›
6. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Executable a1 a2 ∼ normal_dir (Executable a1 a2)›
7. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Repeatable a1 a2 ∼ normal_dir (Repeatable a1 a2)›*)
case Anything (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹Anything ∼ normal_dir Anything›*)
by simp
next
(*goals:
1. ‹⋀x. Res x ∼ normal_dir (Res x)›
2. ‹⋀x. Copyable x ∼ normal_dir (Copyable x)›
3. ‹⋀x. (⋀xa. xa ∈ set x ⟹ xa ∼ normal_dir xa) ⟹ Parallel x ∼ normal_dir (Parallel x)›
4. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ NonD a1 a2 ∼ normal_dir (NonD a1 a2)›
5. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Executable a1 a2 ∼ normal_dir (Executable a1 a2)›
6. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Repeatable a1 a2 ∼ normal_dir (Repeatable a1 a2)›*)
case (Res x) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹Res (x::'a::type) ∼ normal_dir (Res x)›*)
by simp
next
(*goals:
1. ‹⋀x. Copyable x ∼ normal_dir (Copyable x)›
2. ‹⋀x. (⋀xa. xa ∈ set x ⟹ xa ∼ normal_dir xa) ⟹ Parallel x ∼ normal_dir (Parallel x)›
3. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ NonD a1 a2 ∼ normal_dir (NonD a1 a2)›
4. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Executable a1 a2 ∼ normal_dir (Executable a1 a2)›
5. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Repeatable a1 a2 ∼ normal_dir (Repeatable a1 a2)›*)
case (Copyable a) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹Copyable a ∼ normal_dir (Copyable a)›*)
by simp
next
(*goals:
1. ‹⋀x. (⋀xa. xa ∈ set x ⟹ xa ∼ normal_dir xa) ⟹ Parallel x ∼ normal_dir (Parallel x)›
2. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ NonD a1 a2 ∼ normal_dir (NonD a1 a2)›
3. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Executable a1 a2 ∼ normal_dir (Executable a1 a2)›
4. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Repeatable a1 a2 ∼ normal_dir (Repeatable a1 a2)›*)
case (Parallel xs) (*‹?xa ∈ set xs ⟹ ?xa ∼ normal_dir ?xa›*)
then have "Parallel xs ∼ Parallel (map normal_dir xs)"
apply (intro res_term_equiv.parallel (*‹list_all2 (∼) ?xs ?ys ⟹ Parallel ?xs ∼ Parallel ?ys›*))
(*goal: ‹Parallel xs ∼ Parallel (map normal_dir xs)›*)
by (simp add: list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*))
also (*calculation: ‹Parallel (xs::('a, 'b) res_term list) ∼ Parallel (map normal_dir xs)›*) have "... ∼ Parallel (remove_all_empty (map normal_dir xs))"
by (rule remove_all_empty_equiv (*‹Parallel ?xs ∼ Parallel (remove_all_empty ?xs)›*))
also (*calculation: ‹Parallel xs ∼ Parallel (remove_all_empty (map normal_dir xs))›*) have "... ∼ Parallel (merge_all_parallel (remove_all_empty (map normal_dir xs)))"
by (rule merge_all_parallel_equiv (*‹Parallel ?xs ∼ Parallel (merge_all_parallel ?xs)›*))
finally (*calculation: ‹Parallel xs ∼ Parallel (merge_all_parallel (remove_all_empty (map normal_dir xs)))›*) show "?case"
(*goal: ‹Parallel xs ∼ normal_dir (Parallel xs)›*)
using parallelise_equiv (*‹parallelise (?xs::(?'a, ?'b) res_term list) ∼ Parallel ?xs›*) res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*) res_term_equiv.sym (*‹?x ∼ ?y ⟹ ?y ∼ ?x›*) by fastforce
next
(*goals:
1. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ NonD a1 a2 ∼ normal_dir (NonD a1 a2)›
2. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Executable a1 a2 ∼ normal_dir (Executable a1 a2)›
3. ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Repeatable a1 a2 ∼ normal_dir (Repeatable a1 a2)›*)
case (NonD a1 a2) (*‹a1 ∼ normal_dir a1› ‹a2 ∼ normal_dir a2›*)
then show "?case"
(*goal: ‹NonD (a1::('a, 'b) res_term) (a2::('a, 'b) res_term) ∼ normal_dir (NonD a1 a2)›*)
by (simp add: res_term_equiv.nondet (*‹⟦(?x::(?'a::type, ?'b::type) res_term) ∼ (?y::(?'a::type, ?'b::type) res_term); (?u::(?'a::type, ?'b::type) res_term) ∼ (?v::(?'a::type, ?'b::type) res_term)⟧ ⟹ NonD ?x ?u ∼ NonD ?y ?v›*))
next
(*goals:
1. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Executable a1 a2 ∼ normal_dir (Executable a1 a2)›
2. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Repeatable a1 a2 ∼ normal_dir (Repeatable a1 a2)›*)
case (Executable a1 a2) (*‹a1 ∼ normal_dir a1› ‹a2 ∼ normal_dir a2›*)
then show "?case"
(*goal: ‹Executable a1 a2 ∼ normal_dir (Executable a1 a2)›*)
by (simp add: res_term_equiv.executable (*‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Executable ?x ?u ∼ Executable ?y ?v›*))
next
(*goal: ‹⋀a1 a2. ⟦a1 ∼ normal_dir a1; a2 ∼ normal_dir a2⟧ ⟹ Repeatable a1 a2 ∼ normal_dir (Repeatable a1 a2)›*)
case (Repeatable a1 a2) (*‹a1 ∼ normal_dir a1› ‹(a2::('a::type, 'b::type) res_term) ∼ normal_dir a2›*)
then show "?case"
(*goal: ‹Repeatable a1 a2 ∼ normal_dir (Repeatable a1 a2)›*)
by (simp add: res_term_equiv.repeatable (*‹⟦?x ∼ ?y; ?u ∼ ?v⟧ ⟹ Repeatable ?x ?u ∼ Repeatable ?y ?v›*))
qed
text‹Thus terms with equal normalisation are equivalent›
lemma normal_dir_eq_imp_equiv:
"normal_dir a = normal_dir b ⟹ a ∼ b"
using normal_dir_equiv (*‹(?a::(?'a, ?'b) res_term) ∼ normal_dir ?a›*) res_term_equiv.sym (*‹?x ∼ ?y ⟹ ?y ∼ ?x›*) res_term_equiv.trans (*‹⟦?x ∼ ?y; ?y ∼ ?z⟧ ⟹ ?x ∼ ?z›*) by metis
text‹
If the output of @{const merge_all_parallel} still contains a @{const Parallel} term then it must
have been nested in one of the input elements
›
lemma merge_all_parallel_has_Parallel:
assumes "list_ex is_Parallel (merge_all_parallel xs)"
obtains ys
where "Parallel ys ∈ set xs"
and "list_ex is_Parallel ys"
using assms (*‹list_ex is_Parallel (merge_all_parallel (xs::('a, 'b) res_term list))›*) proof (induct xs)
(*goals:
1. ‹⟦⋀ys. ⟦Parallel ys ∈ set []; list_ex is_Parallel ys⟧ ⟹ thesis; list_ex is_Parallel (merge_all_parallel [])⟧ ⟹ thesis›
2. ‹⋀a xs. ⟦⟦⋀ys. ⟦Parallel ys ∈ set xs; list_ex is_Parallel ys⟧ ⟹ thesis; list_ex is_Parallel (merge_all_parallel xs)⟧ ⟹ thesis; ⋀ys. ⟦Parallel ys ∈ set (a # xs); list_ex is_Parallel ys⟧ ⟹ thesis; list_ex is_Parallel (merge_all_parallel (a # xs))⟧ ⟹ thesis›*)
case Nil (*‹⟦Parallel (?ys::('a, 'b) res_term list) ∈ set []; list_ex is_Parallel ?ys⟧ ⟹ thesis::bool› ‹list_ex is_Parallel (merge_all_parallel [])›*)
then show "?case"
(*goal: ‹thesis›*)
by simp
next
(*goal: ‹⋀a xs. ⟦⟦⋀ys. ⟦Parallel ys ∈ set xs; list_ex is_Parallel ys⟧ ⟹ thesis; list_ex is_Parallel (merge_all_parallel xs)⟧ ⟹ thesis; ⋀ys. ⟦Parallel ys ∈ set (a # xs); list_ex is_Parallel ys⟧ ⟹ thesis; list_ex is_Parallel (merge_all_parallel (a # xs))⟧ ⟹ thesis›*)
case (Cons a xs) (*‹⟦⋀ys. ⟦Parallel ys ∈ set xs; list_ex is_Parallel ys⟧ ⟹ thesis; list_ex is_Parallel (merge_all_parallel xs)⟧ ⟹ thesis› ‹⟦Parallel ?ys ∈ set (a # xs); list_ex is_Parallel ?ys⟧ ⟹ thesis› ‹list_ex is_Parallel (merge_all_parallel (a # xs))›*)
then show "?case"
(*goal: ‹thesis›*)
using merge_all_parallel_result (*‹(⋀ys. Parallel ys ∈ set ?xs ⟹ ¬ list_ex is_Parallel ys) ⟹ ¬ list_ex is_Parallel (merge_all_parallel ?xs)›*) by blast
qed
text‹
If the output of @{const remove_all_empty} contains a @{const Parallel} term then it must have
been in the input
›
lemma remove_all_empty_has_Parallel:
assumes "Parallel ys ∈ set (remove_all_empty xs)"
shows "Parallel ys ∈ set xs"
using assms (*‹Parallel (ys::('a, 'b) res_term list) ∈ set (remove_all_empty (xs::('a, 'b) res_term list))›*) proof (induct xs)
(*goals:
1. ‹Parallel ys ∈ set (remove_all_empty []) ⟹ Parallel ys ∈ set []›
2. ‹⋀a xs. ⟦Parallel ys ∈ set (remove_all_empty xs) ⟹ Parallel ys ∈ set xs; Parallel ys ∈ set (remove_all_empty (a # xs))⟧ ⟹ Parallel ys ∈ set (a # xs)›*)
case Nil (*‹Parallel ys ∈ set (remove_all_empty [])›*)
then show "?case"
(*goal: ‹Parallel ys ∈ set []›*)
by simp
next
(*goal: ‹⋀a xs. ⟦Parallel ys ∈ set (remove_all_empty xs) ⟹ Parallel ys ∈ set xs; Parallel ys ∈ set (remove_all_empty (a # xs))⟧ ⟹ Parallel ys ∈ set (a # xs)›*)
case (Cons a xs) (*‹Parallel ys ∈ set (remove_all_empty xs) ⟹ Parallel ys ∈ set xs› ‹Parallel ys ∈ set (remove_all_empty (a # xs))›*)
then show "?case"
(*goal: ‹Parallel ys ∈ set (a # xs)›*)
using remove_all_empty_subset (*‹(?x::(?'a, ?'b) res_term) ∈ set (remove_all_empty (?xs::(?'a, ?'b) res_term list)) ⟹ ?x ∈ set ?xs›*) by blast
qed
text‹If a resource term normalises to a @{const Parallel} term then that does not contain any nested›
lemma normal_dir_no_nested_Parallel:
"normal_dir a = Parallel xs ⟹ ¬ list_ex is_Parallel xs"
proof (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*), induct a arbitrary: xs)
(*goals:
1. ‹⋀(x::'a) xs::('a, 'b) res_term list. ⟦normal_dir (Res x) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
2. ‹⋀(x::'b) xs::('a, 'b) res_term list. ⟦normal_dir (Copyable x) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
3. ‹⋀xs::('a, 'b) res_term list. ⟦normal_dir Empty = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
4. ‹⋀xs::('a, 'b) res_term list. ⟦normal_dir Anything = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
5. ‹⋀(x::('a, 'b) res_term list) xs::('a, 'b) res_term list. ⟦⋀(xa::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦xa ∈ set x; normal_dir xa = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Parallel x) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
6. ‹⋀(a1::('a, 'b) res_term) (a2::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦⋀xs::('a, 'b) res_term list. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs::('a, 'b) res_term list. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (NonD a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
7. ‹⋀(a1::('a, 'b) res_term) (a2::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦⋀xs::('a, 'b) res_term list. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs::('a, 'b) res_term list. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Executable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
8. ‹⋀(a1::('a, 'b) res_term) (a2::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦⋀xs::('a, 'b) res_term list. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs::('a, 'b) res_term list. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›*)
case Empty (*‹normal_dir Empty = Parallel xs› ‹list_ex is_Parallel (xs::('a, 'b) res_term list)›*)
then show "?case"
(*goal: ‹False›*)
by simp
next
(*goals:
1. ‹⋀x xs. ⟦normal_dir (Res x) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
2. ‹⋀x xs. ⟦normal_dir (Copyable x) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
3. ‹⋀xs. ⟦normal_dir Anything = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
4. ‹⋀x xs. ⟦⋀xa xs. ⟦xa ∈ set x; normal_dir xa = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Parallel x) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
5. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (NonD a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
6. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Executable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
7. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›*)
case Anything (*‹normal_dir Anything = Parallel xs› ‹list_ex is_Parallel (xs::('a::type, 'b::type) res_term list)›*)
then show "?case"
(*goal: ‹False›*)
by simp
next
(*goals:
1. ‹⋀(x::'a) xs::('a, 'b) res_term list. ⟦normal_dir (Res x) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
2. ‹⋀(x::'b) xs::('a, 'b) res_term list. ⟦normal_dir (Copyable x) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
3. ‹⋀(x::('a, 'b) res_term list) xs::('a, 'b) res_term list. ⟦⋀(xa::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦xa ∈ set x; normal_dir xa = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Parallel x) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
4. ‹⋀(a1::('a, 'b) res_term) (a2::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦⋀xs::('a, 'b) res_term list. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs::('a, 'b) res_term list. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (NonD a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
5. ‹⋀(a1::('a, 'b) res_term) (a2::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦⋀xs::('a, 'b) res_term list. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs::('a, 'b) res_term list. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Executable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
6. ‹⋀(a1::('a, 'b) res_term) (a2::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦⋀xs::('a, 'b) res_term list. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs::('a, 'b) res_term list. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›*)
case (Res x) (*‹normal_dir (Res (x::'a)) = Parallel (xs::('a, 'b) res_term list)› ‹list_ex is_Parallel xs›*)
then show "?case"
(*goal: ‹False›*)
by simp
next
(*goals:
1. ‹⋀(x::'b) xs::('a, 'b) res_term list. ⟦normal_dir (Copyable x) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
2. ‹⋀(x::('a, 'b) res_term list) xs::('a, 'b) res_term list. ⟦⋀(xa::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦xa ∈ set x; normal_dir xa = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Parallel x) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
3. ‹⋀(a1::('a, 'b) res_term) (a2::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦⋀xs::('a, 'b) res_term list. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs::('a, 'b) res_term list. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (NonD a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
4. ‹⋀(a1::('a, 'b) res_term) (a2::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦⋀xs::('a, 'b) res_term list. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs::('a, 'b) res_term list. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Executable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
5. ‹⋀(a1::('a, 'b) res_term) (a2::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦⋀xs::('a, 'b) res_term list. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs::('a, 'b) res_term list. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›*)
case (Copyable a) (*‹normal_dir (Copyable a) = Parallel xs› ‹list_ex is_Parallel xs›*)
then show "?case"
(*goal: ‹False›*)
by simp
next
(*goals:
1. ‹⋀x xs. ⟦⋀xa xs. ⟦xa ∈ set x; normal_dir xa = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Parallel x) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
2. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (NonD a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
3. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Executable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
4. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›*)
case (Parallel x) (*‹⟦?xa ∈ set x; normal_dir ?xa = Parallel ?xs; list_ex is_Parallel ?xs⟧ ⟹ False› ‹normal_dir (Parallel x) = Parallel xs› ‹list_ex is_Parallel xs›*)
then have "parallelise (merge_all_parallel (remove_all_empty (map normal_dir x))) = Parallel xs"
by simp
then have "list_ex is_Parallel (merge_all_parallel (remove_all_empty (map normal_dir x)))"
using Parallel(3) (*‹list_ex is_Parallel xs›*) ResTerm.parallelise_to_parallel_has_paralell (*‹⟦parallelise ?xs = Parallel ?ys; list_ex is_Parallel ?ys⟧ ⟹ list_ex is_Parallel ?xs›*) by blast
then obtain ys where "Parallel ys ∈ set (remove_all_empty (map normal_dir x))" and ex_ys: "list_ex is_Parallel ys"
(*goal: ‹(⋀ys. ⟦Parallel ys ∈ set (remove_all_empty (map normal_dir x)); list_ex is_Parallel ys⟧ ⟹ thesis) ⟹ thesis›*)
by (erule merge_all_parallel_has_Parallel (*‹⟦list_ex is_Parallel (merge_all_parallel ?xs); ⋀ys. ⟦Parallel ys ∈ set ?xs; list_ex is_Parallel ys⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
then have "Parallel ys ∈ set (map normal_dir x)"
using remove_all_empty_has_Parallel (*‹Parallel ?ys ∈ set (remove_all_empty ?xs) ⟹ Parallel ?ys ∈ set ?xs›*) by blast
then show "?case"
(*goal: ‹False›*)
using Parallel(1) (*‹⟦?xa ∈ set x; normal_dir ?xa = Parallel ?xs; list_ex is_Parallel ?xs⟧ ⟹ False›*) ex_ys (*‹list_ex is_Parallel ys›*) by fastforce
next
(*goals:
1. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (NonD a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
2. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Executable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
3. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›*)
case (NonD a1 a2) (*‹⟦normal_dir a1 = Parallel ?xs; list_ex is_Parallel ?xs⟧ ⟹ False› ‹⟦normal_dir a2 = Parallel ?xs; list_ex is_Parallel ?xs⟧ ⟹ False› ‹normal_dir (NonD a1 a2) = Parallel xs› ‹list_ex is_Parallel (xs::('a, 'b) res_term list)›*)
then show "?case"
(*goal: ‹False›*)
by simp
next
(*goals:
1. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Executable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›
2. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›*)
case (Executable a1 a2) (*‹⟦normal_dir a1 = Parallel ?xs; list_ex is_Parallel ?xs⟧ ⟹ False› ‹⟦normal_dir a2 = Parallel ?xs; list_ex is_Parallel ?xs⟧ ⟹ False› ‹normal_dir (Executable a1 a2) = Parallel xs› ‹list_ex is_Parallel xs›*)
then show "?case"
(*goal: ‹False›*)
by simp
next
(*goal: ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Parallel xs⟧ ⟹ False›*)
case (Repeatable a1 a2) (*‹⟦normal_dir a1 = Parallel ?xs; list_ex is_Parallel ?xs⟧ ⟹ False› ‹⟦normal_dir a2 = Parallel ?xs; list_ex is_Parallel ?xs⟧ ⟹ False› ‹normal_dir (Repeatable a1 a2) = Parallel xs› ‹list_ex is_Parallel (xs::('a::type, 'b::type) res_term list)›*)
then show "?case"
(*goal: ‹False›*)
by simp
qed
text‹
If a resource term normalises to a @{const Parallel} term then it does not contain @{const Empty}
›
lemma normal_dir_no_nested_Empty:
"normal_dir a = Parallel xs ⟹ ¬ list_ex is_Empty xs"
proof (rule notI (*‹(?P::bool ⟹ False) ⟹ ¬ ?P›*), induct a arbitrary: xs)
(*goals:
1. ‹⋀x xs. ⟦normal_dir (Res x) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
2. ‹⋀x xs. ⟦normal_dir (Copyable x) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
3. ‹⋀xs. ⟦normal_dir Empty = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
4. ‹⋀xs. ⟦normal_dir Anything = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
5. ‹⋀x xs. ⟦⋀xa xs. ⟦xa ∈ set x; normal_dir xa = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Parallel x) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
6. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (NonD a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
7. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Executable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
8. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›*)
case Empty (*‹normal_dir Empty = Parallel xs› ‹list_ex is_Empty (xs::('a, 'b) res_term list)›*)
then show "?case"
(*goal: ‹False›*)
by simp
next
(*goals:
1. ‹⋀x xs. ⟦normal_dir (Res x) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
2. ‹⋀x xs. ⟦normal_dir (Copyable x) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
3. ‹⋀xs. ⟦normal_dir Anything = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
4. ‹⋀x xs. ⟦⋀xa xs. ⟦xa ∈ set x; normal_dir xa = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Parallel x) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
5. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (NonD a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
6. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Executable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
7. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›*)
case Anything (*‹normal_dir Anything = Parallel xs› ‹list_ex is_Empty (xs::('a::type, 'b::type) res_term list)›*)
then show "?case"
(*goal: ‹False›*)
by simp
next
(*goals:
1. ‹⋀x xs. ⟦normal_dir (Res x) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
2. ‹⋀x xs. ⟦normal_dir (Copyable x) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
3. ‹⋀x xs. ⟦⋀xa xs. ⟦xa ∈ set x; normal_dir xa = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Parallel x) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
4. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (NonD a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
5. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Executable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
6. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›*)
case (Res x) (*‹normal_dir (Res x) = Parallel xs› ‹list_ex is_Empty xs›*)
then show "?case"
(*goal: ‹False›*)
by simp
next
(*goals:
1. ‹⋀x xs. ⟦normal_dir (Copyable x) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
2. ‹⋀x xs. ⟦⋀xa xs. ⟦xa ∈ set x; normal_dir xa = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Parallel x) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
3. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (NonD a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
4. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Executable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
5. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›*)
case (Copyable a) (*‹normal_dir (Copyable a) = Parallel xs› ‹list_ex is_Empty xs›*)
then show "?case"
(*goal: ‹False›*)
by simp
next
(*goals:
1. ‹⋀x xs. ⟦⋀xa xs. ⟦xa ∈ set x; normal_dir xa = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Parallel x) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
2. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (NonD a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
3. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Executable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
4. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›*)
case (Parallel x) (*‹⟦?xa ∈ set x; normal_dir ?xa = Parallel ?xs; list_ex is_Empty ?xs⟧ ⟹ False› ‹normal_dir (Parallel x) = Parallel xs› ‹list_ex is_Empty xs›*)
then have "parallelise (merge_all_parallel (remove_all_empty (map normal_dir x))) = Parallel xs"
by simp
then have "merge_all_parallel (remove_all_empty (map normal_dir x)) = xs"
proof (elim parallelise_to_parallel_has_empty (*‹⟦parallelise ?xs = Parallel ?ys; ?xs = [Parallel ?ys] ⟹ ?thesis; ?xs = ?ys ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹merge_all_parallel (remove_all_empty (map normal_dir x)) = [Parallel xs] ⟹ merge_all_parallel (remove_all_empty (map normal_dir x)) = xs›
2. ‹merge_all_parallel (remove_all_empty (map normal_dir x)) = xs ⟹ merge_all_parallel (remove_all_empty (map normal_dir x)) = xs›*)
assume "merge_all_parallel (remove_all_empty (map normal_dir x)) = [Parallel xs]" (*‹merge_all_parallel (remove_all_empty (map normal_dir (x::('a, 'b) res_term list))) = [Parallel (xs::('a, 'b) res_term list)]›*)
then show "?thesis"
(*goal: ‹merge_all_parallel (remove_all_empty (map normal_dir x)) = xs›*)
using Parallel(3) (*‹list_ex is_Empty xs›*) merge_all_parallel_has_Parallel (*‹⟦list_ex is_Parallel (merge_all_parallel ?xs); ⋀ys. ⟦Parallel ys ∈ set ?xs; list_ex is_Parallel ys⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) normal_dir_no_nested_Parallel (*‹normal_dir ?a = Parallel ?xs ⟹ ¬ list_ex is_Parallel ?xs›*) remove_all_empty_has_Parallel (*‹Parallel ?ys ∈ set (remove_all_empty ?xs) ⟹ Parallel ?ys ∈ set ?xs›*) by (smt (verit, best) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) list.set_map (*‹set (map ?f ?v) = ?f ` set ?v›*) list_ex_simps( (*‹list_ex ?P (?x # ?xs) = (?P ?x ∨ list_ex ?P ?xs)›*) 1) res_term.discI( (*‹?res_term = Parallel ?x5.0 ⟹ is_Parallel ?res_term›*) 5))
next
(*goal: ‹merge_all_parallel (remove_all_empty (map normal_dir x)) = xs ⟹ merge_all_parallel (remove_all_empty (map normal_dir x)) = xs›*)
assume "merge_all_parallel (remove_all_empty (map normal_dir x)) = xs" (*‹merge_all_parallel (remove_all_empty (map normal_dir (x::('a, 'b) res_term list))) = (xs::('a, 'b) res_term list)›*)
then show "?thesis"
(*goal: ‹merge_all_parallel (remove_all_empty (map normal_dir (x::('a, 'b) res_term list))) = (xs::('a, 'b) res_term list)›*) .
qed
then have "list_ex is_Empty (merge_all_parallel (remove_all_empty (map normal_dir x)))"
using Parallel(3) (*‹list_ex is_Empty (xs::('a, 'b) res_term list)›*) by blast
then have "list_ex is_Empty (remove_all_empty (map normal_dir x))"
proof (elim merge_all_parallel_has_empty (*‹⟦list_ex is_Empty (merge_all_parallel ?xs); ⋀ys. ⟦Parallel ys ∈ set ?xs; list_ex is_Empty ys⟧ ⟹ ?thesis; list_ex is_Empty ?xs ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹⋀ys. ⟦Parallel ys ∈ set (remove_all_empty (map normal_dir x)); list_ex is_Empty ys⟧ ⟹ list_ex is_Empty (remove_all_empty (map normal_dir x))›
2. ‹list_ex is_Empty (remove_all_empty (map normal_dir x)) ⟹ list_ex is_Empty (remove_all_empty (map normal_dir x))›*)
fix ys
assume "Parallel ys ∈ set (remove_all_empty (map normal_dir x))" and "list_ex is_Empty ys" (*‹Parallel (ys::('a, 'b) res_term list) ∈ set (remove_all_empty (map normal_dir (x::('a, 'b) res_term list)))› ‹list_ex is_Empty (ys::('a, 'b) res_term list)›*)
then show "?thesis"
(*goal: ‹list_ex is_Empty (remove_all_empty (map normal_dir x))›*)
using Parallel(1) (*‹⟦?xa ∈ set x; normal_dir ?xa = Parallel ?xs; list_ex is_Empty ?xs⟧ ⟹ False›*) remove_all_empty_has_Parallel (*‹Parallel (?ys::(?'a, ?'b) res_term list) ∈ set (remove_all_empty (?xs::(?'a, ?'b) res_term list)) ⟹ Parallel ?ys ∈ set ?xs›*) by (metis (mono_tags, lifting) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) list.set_map (*‹set (map ?f ?v) = ?f ` set ?v›*))
next
(*goal: ‹list_ex is_Empty (remove_all_empty (map normal_dir x)) ⟹ list_ex is_Empty (remove_all_empty (map normal_dir x))›*)
assume "list_ex is_Empty (remove_all_empty (map normal_dir x))" (*‹list_ex is_Empty (remove_all_empty (map normal_dir (x::('a, 'b) res_term list)))›*)
then show "?thesis"
(*goal: ‹list_ex is_Empty (remove_all_empty (map normal_dir (x::('a, 'b) res_term list)))›*) .
qed
then show "?case"
(*goal: ‹False›*)
using remove_all_empty_result (*‹¬ list_ex is_Empty (remove_all_empty ?xs)›*) by blast
next
(*goals:
1. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (NonD a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
2. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Executable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
3. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›*)
case (NonD a1 a2) (*‹⟦normal_dir a1 = Parallel ?xs; list_ex is_Empty ?xs⟧ ⟹ False› ‹⟦normal_dir (a2::('a, 'b) res_term) = Parallel (?xs::('a, 'b) res_term list); list_ex is_Empty ?xs⟧ ⟹ False› ‹normal_dir (NonD a1 a2) = Parallel xs› ‹list_ex is_Empty xs›*)
then show "?case"
(*goal: ‹False›*)
by simp
next
(*goals:
1. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Executable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›
2. ‹⋀a1 a2 xs. ⟦⋀xs. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›*)
case (Executable a1 a2) (*‹⟦normal_dir a1 = Parallel ?xs; list_ex is_Empty ?xs⟧ ⟹ False› ‹⟦normal_dir a2 = Parallel ?xs; list_ex is_Empty ?xs⟧ ⟹ False› ‹normal_dir (Executable a1 a2) = Parallel xs› ‹list_ex is_Empty (xs::('a, 'b) res_term list)›*)
then show "?case"
(*goal: ‹False›*)
by simp
next
(*goal: ‹⋀(a1::('a, 'b) res_term) (a2::('a, 'b) res_term) xs::('a, 'b) res_term list. ⟦⋀xs::('a, 'b) res_term list. ⟦normal_dir a1 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; ⋀xs::('a, 'b) res_term list. ⟦normal_dir a2 = Parallel xs; list_ex is_Empty xs⟧ ⟹ False; normal_dir (Repeatable a1 a2) = Parallel xs; list_ex is_Empty xs⟧ ⟹ False›*)
case (Repeatable a1 a2) (*‹⟦normal_dir a1 = Parallel ?xs; list_ex is_Empty ?xs⟧ ⟹ False› ‹⟦normal_dir a2 = Parallel ?xs; list_ex is_Empty ?xs⟧ ⟹ False› ‹normal_dir (Repeatable (a1::('a, 'b) res_term) (a2::('a, 'b) res_term)) = Parallel (xs::('a, 'b) res_term list)› ‹list_ex is_Empty xs›*)
then show "?case"
(*goal: ‹False›*)
by simp
qed
text‹
Merging @{const Parallel} terms in a list of normalised terms keeps all terms in the result
normalised
›
lemma normalised_merge_all_parallel:
assumes "x ∈ set (merge_all_parallel xs)"
and "⋀x. x ∈ set xs ⟹ normalised x"
shows "normalised x"
using assms (*‹x ∈ set (merge_all_parallel xs)› ‹?x ∈ set xs ⟹ normalised ?x›*) proof (induct xs arbitrary: x)
(*goals:
1. ‹⋀x. ⟦x ∈ set (merge_all_parallel []); ⋀x. x ∈ set [] ⟹ normalised x⟧ ⟹ normalised x›
2. ‹⋀a xs x. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x⟧ ⟹ normalised x›*)
case Nil (*‹(x::('a, 'b) res_term) ∈ set (merge_all_parallel [])› ‹?x ∈ set [] ⟹ normalised ?x›*)
then show "?case"
(*goal: ‹normalised (x::('a::type, 'b::type) res_term)›*)
by simp
next
(*goal: ‹⋀(a::('a, 'b) res_term) (xs::('a, 'b) res_term list) x::('a, 'b) res_term. ⟦⋀x::('a, 'b) res_term. ⟦x ∈ set (merge_all_parallel xs); ⋀x::('a, 'b) res_term. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x::('a, 'b) res_term. x ∈ set (a # xs) ⟹ normalised x⟧ ⟹ normalised x›*)
case (Cons a xs) (*‹⟦?x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised ?x› ‹x ∈ set (merge_all_parallel (a # xs))› ‹?x ∈ set (a # xs) ⟹ normalised ?x›*)
then show "?case"
(*goal: ‹normalised x›*)
proof (cases a)
(*goals:
1. ‹⋀x1::'a. ⟦⋀x::('a, 'b) res_term. ⟦x ∈ set (merge_all_parallel (xs::('a, 'b) res_term list)); ⋀x::('a, 'b) res_term. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; (x::('a, 'b) res_term) ∈ set (merge_all_parallel ((a::('a, 'b) res_term) # xs)); ⋀x::('a, 'b) res_term. x ∈ set (a # xs) ⟹ normalised x; a = Res x1⟧ ⟹ normalised x›
2. ‹⋀x2::'b. ⟦⋀x::('a, 'b) res_term. ⟦x ∈ set (merge_all_parallel (xs::('a, 'b) res_term list)); ⋀x::('a, 'b) res_term. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; (x::('a, 'b) res_term) ∈ set (merge_all_parallel ((a::('a, 'b) res_term) # xs)); ⋀x::('a, 'b) res_term. x ∈ set (a # xs) ⟹ normalised x; a = Copyable x2⟧ ⟹ normalised x›
3. ‹⟦⋀x::('a, 'b) res_term. ⟦x ∈ set (merge_all_parallel (xs::('a, 'b) res_term list)); ⋀x::('a, 'b) res_term. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; (x::('a, 'b) res_term) ∈ set (merge_all_parallel ((a::('a, 'b) res_term) # xs)); ⋀x::('a, 'b) res_term. x ∈ set (a # xs) ⟹ normalised x; a = Empty⟧ ⟹ normalised x›
4. ‹⟦⋀x::('a, 'b) res_term. ⟦x ∈ set (merge_all_parallel (xs::('a, 'b) res_term list)); ⋀x::('a, 'b) res_term. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; (x::('a, 'b) res_term) ∈ set (merge_all_parallel ((a::('a, 'b) res_term) # xs)); ⋀x::('a, 'b) res_term. x ∈ set (a # xs) ⟹ normalised x; a = Anything⟧ ⟹ normalised x›
5. ‹⋀x5::('a, 'b) res_term list. ⟦⋀x::('a, 'b) res_term. ⟦x ∈ set (merge_all_parallel (xs::('a, 'b) res_term list)); ⋀x::('a, 'b) res_term. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; (x::('a, 'b) res_term) ∈ set (merge_all_parallel ((a::('a, 'b) res_term) # xs)); ⋀x::('a, 'b) res_term. x ∈ set (a # xs) ⟹ normalised x; a = Parallel x5⟧ ⟹ normalised x›
6. ‹⋀(x61::('a, 'b) res_term) x62::('a, 'b) res_term. ⟦⋀x::('a, 'b) res_term. ⟦x ∈ set (merge_all_parallel (xs::('a, 'b) res_term list)); ⋀x::('a, 'b) res_term. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; (x::('a, 'b) res_term) ∈ set (merge_all_parallel ((a::('a, 'b) res_term) # xs)); ⋀x::('a, 'b) res_term. x ∈ set (a # xs) ⟹ normalised x; a = NonD x61 x62⟧ ⟹ normalised x›
7. ‹⋀(x71::('a, 'b) res_term) x72::('a, 'b) res_term. ⟦⋀x::('a, 'b) res_term. ⟦x ∈ set (merge_all_parallel (xs::('a, 'b) res_term list)); ⋀x::('a, 'b) res_term. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; (x::('a, 'b) res_term) ∈ set (merge_all_parallel ((a::('a, 'b) res_term) # xs)); ⋀x::('a, 'b) res_term. x ∈ set (a # xs) ⟹ normalised x; a = Executable x71 x72⟧ ⟹ normalised x›
8. ‹⋀(x81::('a, 'b) res_term) x82::('a, 'b) res_term. ⟦⋀x::('a, 'b) res_term. ⟦x ∈ set (merge_all_parallel (xs::('a, 'b) res_term list)); ⋀x::('a, 'b) res_term. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; (x::('a, 'b) res_term) ∈ set (merge_all_parallel ((a::('a, 'b) res_term) # xs)); ⋀x::('a, 'b) res_term. x ∈ set (a # xs) ⟹ normalised x; a = Repeatable x81 x82⟧ ⟹ normalised x›*)
case Empty (*‹a = Empty›*)
then show "?thesis"
(*goal: ‹normalised x›*)
using Cons (*‹⟦(?x::('a, 'b) res_term) ∈ set (merge_all_parallel (xs::('a, 'b) res_term list)); ⋀x::('a, 'b) res_term. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised ?x› ‹x ∈ set (merge_all_parallel (a # xs))› ‹?x ∈ set (a # xs) ⟹ normalised ?x›*) apply simp
(*goal: ‹normalised x›*)
by metis
next
(*goals:
1. ‹⋀x1. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Res x1⟧ ⟹ normalised x›
2. ‹⋀x2. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Copyable x2⟧ ⟹ normalised x›
3. ‹⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Anything⟧ ⟹ normalised x›
4. ‹⋀x5. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Parallel x5⟧ ⟹ normalised x›
5. ‹⋀x61 x62. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = NonD x61 x62⟧ ⟹ normalised x›
6. ‹⋀x71 x72. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Executable x71 x72⟧ ⟹ normalised x›
7. ‹⋀x81 x82. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Repeatable x81 x82⟧ ⟹ normalised x›*)
case Anything (*‹a = Anything›*)
then show "?thesis"
(*goal: ‹normalised x›*)
using Cons (*‹⟦?x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised ?x› ‹x ∈ set (merge_all_parallel (a # xs))› ‹?x ∈ set (a # xs) ⟹ normalised ?x›*) apply simp
(*goal: ‹normalised x›*)
by metis
next
(*goals:
1. ‹⋀x1. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Res x1⟧ ⟹ normalised x›
2. ‹⋀x2. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Copyable x2⟧ ⟹ normalised x›
3. ‹⋀x5. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Parallel x5⟧ ⟹ normalised x›
4. ‹⋀x61 x62. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = NonD x61 x62⟧ ⟹ normalised x›
5. ‹⋀x71 x72. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Executable x71 x72⟧ ⟹ normalised x›
6. ‹⋀x81 x82. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Repeatable x81 x82⟧ ⟹ normalised x›*)
case (Res x3) (*‹a = Res x3›*)
then show "?thesis"
(*goal: ‹normalised x›*)
using Cons (*‹⟦?x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised ?x› ‹x ∈ set (merge_all_parallel (a # xs))› ‹?x ∈ set (a # xs) ⟹ normalised ?x›*) apply simp
(*goal: ‹normalised x›*)
by metis
next
(*goals:
1. ‹⋀x2. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Copyable x2⟧ ⟹ normalised x›
2. ‹⋀x5. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Parallel x5⟧ ⟹ normalised x›
3. ‹⋀x61 x62. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = NonD x61 x62⟧ ⟹ normalised x›
4. ‹⋀x71 x72. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Executable x71 x72⟧ ⟹ normalised x›
5. ‹⋀x81 x82. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Repeatable x81 x82⟧ ⟹ normalised x›*)
case (Copyable x4) (*‹a = Copyable x4›*)
then show "?thesis"
(*goal: ‹normalised x›*)
using Cons (*‹⟦(?x::('a, 'b) res_term) ∈ set (merge_all_parallel (xs::('a, 'b) res_term list)); ⋀x::('a, 'b) res_term. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised ?x› ‹x ∈ set (merge_all_parallel (a # xs))› ‹?x ∈ set (a # xs) ⟹ normalised ?x›*) apply simp
(*goal: ‹normalised x›*)
by metis
next
(*goals:
1. ‹⋀x5. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Parallel x5⟧ ⟹ normalised x›
2. ‹⋀x61 x62. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = NonD x61 x62⟧ ⟹ normalised x›
3. ‹⋀x71 x72. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Executable x71 x72⟧ ⟹ normalised x›
4. ‹⋀x81 x82. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Repeatable x81 x82⟧ ⟹ normalised x›*)
case (Parallel x5) (*‹a = Parallel x5›*)
then show "?thesis"
(*goal: ‹normalised (x::('a, 'b) res_term)›*)
using Cons (*‹⟦?x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised ?x› ‹(x::('a, 'b) res_term) ∈ set (merge_all_parallel ((a::('a, 'b) res_term) # (xs::('a, 'b) res_term list)))› ‹?x ∈ set (a # xs) ⟹ normalised ?x›*) apply simp
(*goal: ‹normalised x›*)
by (metis Ball_set (*‹Ball (set ?xs) ?P = list_all ?P ?xs›*) normalised.simps( (*‹normalised (Parallel ?xs) = (list_all normalised ?xs ∧ list_all (λx. ¬ is_Empty x) ?xs ∧ list_all (λx. ¬ is_Parallel x) ?xs ∧ 1 < length ?xs)›*) 5))
next
(*goals:
1. ‹⋀x61 x62. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = NonD x61 x62⟧ ⟹ normalised x›
2. ‹⋀x71 x72. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Executable x71 x72⟧ ⟹ normalised x›
3. ‹⋀x81 x82. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Repeatable x81 x82⟧ ⟹ normalised x›*)
case (NonD x61 x62) (*‹a = NonD x61 x62›*)
then show "?thesis"
(*goal: ‹normalised (x::('a::type, 'b::type) res_term)›*)
using Cons (*‹⟦(?x::('a::type, 'b::type) res_term) ∈ set (merge_all_parallel (xs::('a::type, 'b::type) res_term list)); ⋀x::('a::type, 'b::type) res_term. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised ?x› ‹x ∈ set (merge_all_parallel (a # xs))› ‹?x ∈ set (a # xs) ⟹ normalised ?x›*) apply simp
(*goal: ‹normalised x›*)
by metis
next
(*goals:
1. ‹⋀x71 x72. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Executable x71 x72⟧ ⟹ normalised x›
2. ‹⋀x81 x82. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Repeatable x81 x82⟧ ⟹ normalised x›*)
case (Executable x71 x72) (*‹a = Executable x71 x72›*)
then show "?thesis"
(*goal: ‹normalised x›*)
using Cons (*‹⟦?x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised ?x› ‹x ∈ set (merge_all_parallel (a # xs))› ‹(?x::('a, 'b) res_term) ∈ set ((a::('a, 'b) res_term) # (xs::('a, 'b) res_term list)) ⟹ normalised ?x›*) apply simp
(*goal: ‹normalised x›*)
by metis
next
(*goal: ‹⋀x81 x82. ⟦⋀x. ⟦x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised x; x ∈ set (merge_all_parallel (a # xs)); ⋀x. x ∈ set (a # xs) ⟹ normalised x; a = Repeatable x81 x82⟧ ⟹ normalised x›*)
case (Repeatable x71 x72) (*‹a = Repeatable x71 x72›*)
then show "?thesis"
(*goal: ‹normalised x›*)
using Cons (*‹⟦?x ∈ set (merge_all_parallel xs); ⋀x. x ∈ set xs ⟹ normalised x⟧ ⟹ normalised ?x› ‹x ∈ set (merge_all_parallel (a # xs))› ‹?x ∈ set (a # xs) ⟹ normalised ?x›*) apply simp
(*goal: ‹normalised x›*)
by metis
qed
qed
text‹Normalisation produces resources in normal form›
lemma normalised_normal_dir:
"normalised (normal_dir a)"
proof (induct a)
(*goals:
1. ‹⋀x::'a. normalised (normal_dir (Res x))›
2. ‹⋀x::'b. normalised (normal_dir (Copyable x))›
3. ‹normalised (normal_dir Empty)›
4. ‹normalised (normal_dir Anything)›
5. ‹⋀x::('a, 'b) res_term list. (⋀xa::('a, 'b) res_term. xa ∈ set x ⟹ normalised (normal_dir xa)) ⟹ normalised (normal_dir (Parallel x))›
6. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (NonD a1 a2))›
7. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Executable a1 a2))›
8. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Repeatable a1 a2))›*)
case Empty (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹normalised (normal_dir Empty)›*)
by simp
next
(*goals:
1. ‹⋀x::'a. normalised (normal_dir (Res x))›
2. ‹⋀x::'b. normalised (normal_dir (Copyable x))›
3. ‹normalised (normal_dir Anything)›
4. ‹⋀x::('a, 'b) res_term list. (⋀xa::('a, 'b) res_term. xa ∈ set x ⟹ normalised (normal_dir xa)) ⟹ normalised (normal_dir (Parallel x))›
5. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (NonD a1 a2))›
6. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Executable a1 a2))›
7. ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Repeatable a1 a2))›*)
case Anything (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹normalised (normal_dir Anything)›*)
by simp
next
(*goals:
1. ‹⋀x. normalised (normal_dir (Res x))›
2. ‹⋀x. normalised (normal_dir (Copyable x))›
3. ‹⋀x. (⋀xa. xa ∈ set x ⟹ normalised (normal_dir xa)) ⟹ normalised (normal_dir (Parallel x))›
4. ‹⋀a1 a2. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (NonD a1 a2))›
5. ‹⋀a1 a2. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Executable a1 a2))›
6. ‹⋀a1 a2. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Repeatable a1 a2))›*)
case (Res x) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹normalised (normal_dir (Res (x::'a::type)))›*)
by simp
next
(*goals:
1. ‹⋀x. normalised (normal_dir (Copyable x))›
2. ‹⋀x. (⋀xa. xa ∈ set x ⟹ normalised (normal_dir xa)) ⟹ normalised (normal_dir (Parallel x))›
3. ‹⋀a1 a2. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (NonD a1 a2))›
4. ‹⋀a1 a2. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Executable a1 a2))›
5. ‹⋀a1 a2. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Repeatable a1 a2))›*)
case (Copyable a) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹normalised (normal_dir (Copyable a))›*)
by simp
next
(*goals:
1. ‹⋀x. (⋀xa. xa ∈ set x ⟹ normalised (normal_dir xa)) ⟹ normalised (normal_dir (Parallel x))›
2. ‹⋀a1 a2. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (NonD a1 a2))›
3. ‹⋀a1 a2. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Executable a1 a2))›
4. ‹⋀a1 a2. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Repeatable a1 a2))›*)
case (Parallel xs) (*‹?xa ∈ set xs ⟹ normalised (normal_dir ?xa)›*)
have "normalised (parallelise (merge_all_parallel (remove_all_empty (map normal_dir xs))))"
proof (intro normalised_parallelise (*‹⟦⋀x. x ∈ set ?xs ⟹ normalised x; ¬ list_ex is_Empty ?xs; ¬ list_ex is_Parallel ?xs⟧ ⟹ normalised (parallelise ?xs)›*))
(*goals:
1. ‹⋀x::('a, 'b) res_term. x ∈ set (merge_all_parallel (remove_all_empty (map normal_dir (xs::('a, 'b) res_term list)))) ⟹ normalised x›
2. ‹¬ list_ex is_Empty (merge_all_parallel (remove_all_empty (map normal_dir (xs::('a, 'b) res_term list))))›
3. ‹¬ list_ex is_Parallel (merge_all_parallel (remove_all_empty (map normal_dir (xs::('a, 'b) res_term list))))›*)
fix x
assume "x ∈ set (merge_all_parallel (remove_all_empty (map normal_dir xs)))" (*‹(x::('a, 'b) res_term) ∈ set (merge_all_parallel (remove_all_empty (map normal_dir (xs::('a, 'b) res_term list))))›*)
then show "normalised x"
using Parallel(1) (*‹?xa ∈ set xs ⟹ normalised (normal_dir ?xa)›*) normalised_merge_all_parallel (*‹⟦?x ∈ set (merge_all_parallel ?xs); ⋀x. x ∈ set ?xs ⟹ normalised x⟧ ⟹ normalised ?x›*) remove_all_empty_subset (*‹(?x::(?'a::type, ?'b::type) res_term) ∈ set (remove_all_empty (?xs::(?'a::type, ?'b::type) res_term list)) ⟹ ?x ∈ set ?xs›*) by (metis (mono_tags, lifting) imageE (*‹⟦?b ∈ ?f ` ?A; ⋀x. ⟦?b = ?f x; x ∈ ?A⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) list.set_map (*‹set (map ?f ?v) = ?f ` set ?v›*))
next
(*goals:
1. ‹¬ list_ex is_Empty (merge_all_parallel (remove_all_empty (map normal_dir xs)))›
2. ‹¬ list_ex is_Parallel (merge_all_parallel (remove_all_empty (map normal_dir xs)))›*)
show "¬ list_ex is_Empty (merge_all_parallel (remove_all_empty (map normal_dir xs)))"
using merge_all_parallel_has_empty (*‹⟦list_ex is_Empty (merge_all_parallel ?xs); ⋀ys. ⟦Parallel ys ∈ set ?xs; list_ex is_Empty ys⟧ ⟹ ?thesis; list_ex is_Empty ?xs ⟹ ?thesis⟧ ⟹ ?thesis›*) remove_all_empty_has_Parallel (*‹Parallel ?ys ∈ set (remove_all_empty ?xs) ⟹ Parallel ?ys ∈ set ?xs›*) remove_all_empty_result (*‹¬ list_ex is_Empty (remove_all_empty ?xs)›*) normal_dir_no_nested_Empty (*‹normal_dir ?a = Parallel ?xs ⟹ ¬ list_ex is_Empty ?xs›*) by (metis imageE (*‹⟦?b ∈ ?f ` ?A; ⋀x. ⟦?b = ?f x; x ∈ ?A⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) list.set_map (*‹set (map ?f ?v) = ?f ` set ?v›*))
next
(*goal: ‹¬ list_ex is_Parallel (merge_all_parallel (remove_all_empty (map normal_dir xs)))›*)
show "¬ list_ex is_Parallel (merge_all_parallel (remove_all_empty (map normal_dir xs)))"
using merge_all_parallel_has_Parallel (*‹⟦list_ex is_Parallel (merge_all_parallel (?xs::(?'a::type, ?'b::type) res_term list)); ⋀ys::(?'a::type, ?'b::type) res_term list. ⟦Parallel ys ∈ set ?xs; list_ex is_Parallel ys⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) remove_all_empty_has_Parallel (*‹Parallel ?ys ∈ set (remove_all_empty ?xs) ⟹ Parallel ?ys ∈ set ?xs›*) normal_dir_no_nested_Parallel (*‹normal_dir ?a = Parallel ?xs ⟹ ¬ list_ex is_Parallel ?xs›*) by (metis imageE (*‹⟦?b ∈ ?f ` ?A; ⋀x. ⟦?b = ?f x; x ∈ ?A⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) list.set_map (*‹set (map ?f ?v) = ?f ` set ?v›*))
qed
then show "?case"
(*goal: ‹normalised (normal_dir (Parallel xs))›*)
by simp
next
(*goals:
1. ‹⋀a1 a2. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (NonD a1 a2))›
2. ‹⋀a1 a2. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Executable a1 a2))›
3. ‹⋀a1 a2. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Repeatable a1 a2))›*)
case (NonD a1 a2) (*‹normalised (normal_dir a1)› ‹normalised (normal_dir a2)›*)
then show "?case"
(*goal: ‹normalised (normal_dir (NonD a1 a2))›*)
by simp
next
(*goals:
1. ‹⋀a1 a2. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Executable a1 a2))›
2. ‹⋀a1 a2. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Repeatable a1 a2))›*)
case (Executable a1 a2) (*‹normalised (normal_dir a1)› ‹normalised (normal_dir a2)›*)
then show "?case"
(*goal: ‹normalised (normal_dir (Executable a1 a2))›*)
by simp
next
(*goal: ‹⋀(a1::('a, 'b) res_term) a2::('a, 'b) res_term. ⟦normalised (normal_dir a1); normalised (normal_dir a2)⟧ ⟹ normalised (normal_dir (Repeatable a1 a2))›*)
case (Repeatable a1 a2) (*‹normalised (normal_dir a1)› ‹normalised (normal_dir (a2::('a, 'b) res_term))›*)
then show "?case"
(*goal: ‹normalised (normal_dir (Repeatable a1 a2))›*)
by simp
qed
text‹Normalisation does nothing to resource terms in normal form›
lemma normal_dir_normalised:
"normalised x ⟹ normal_dir x = x"
proof (induct x)
(*goals:
1. ‹⋀x::'a::type. normalised (Res x) ⟹ normal_dir (Res x) = Res x›
2. ‹⋀x::'b::type. normalised (Copyable x) ⟹ normal_dir (Copyable x) = Copyable x›
3. ‹normalised Empty ⟹ normal_dir Empty = Empty›
4. ‹normalised Anything ⟹ normal_dir Anything = Anything›
5. ‹⋀x::('a::type, 'b::type) res_term list. ⟦⋀xa::('a::type, 'b::type) res_term. ⟦xa ∈ set x; normalised xa⟧ ⟹ normal_dir xa = xa; normalised (Parallel x)⟧ ⟹ normal_dir (Parallel x) = Parallel x›
6. ‹⋀(x1::('a::type, 'b::type) res_term) x2::('a::type, 'b::type) res_term. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (NonD x1 x2)⟧ ⟹ normal_dir (NonD x1 x2) = NonD x1 x2›
7. ‹⋀(x1::('a::type, 'b::type) res_term) x2::('a::type, 'b::type) res_term. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Executable x1 x2)⟧ ⟹ normal_dir (Executable x1 x2) = Executable x1 x2›
8. ‹⋀(x1::('a::type, 'b::type) res_term) x2::('a::type, 'b::type) res_term. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Repeatable x1 x2)⟧ ⟹ normal_dir (Repeatable x1 x2) = Repeatable x1 x2›*)
case Empty (*‹normalised Empty›*)
then show "?case"
(*goal: ‹normal_dir Empty = Empty›*)
by simp
next
(*goals:
1. ‹⋀x::'a. normalised (Res x) ⟹ normal_dir (Res x) = Res x›
2. ‹⋀x::'b. normalised (Copyable x) ⟹ normal_dir (Copyable x) = Copyable x›
3. ‹normalised Anything ⟹ normal_dir Anything = Anything›
4. ‹⋀x::('a, 'b) res_term list. ⟦⋀xa::('a, 'b) res_term. ⟦xa ∈ set x; normalised xa⟧ ⟹ normal_dir xa = xa; normalised (Parallel x)⟧ ⟹ normal_dir (Parallel x) = Parallel x›
5. ‹⋀(x1::('a, 'b) res_term) x2::('a, 'b) res_term. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (NonD x1 x2)⟧ ⟹ normal_dir (NonD x1 x2) = NonD x1 x2›
6. ‹⋀(x1::('a, 'b) res_term) x2::('a, 'b) res_term. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Executable x1 x2)⟧ ⟹ normal_dir (Executable x1 x2) = Executable x1 x2›
7. ‹⋀(x1::('a, 'b) res_term) x2::('a, 'b) res_term. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Repeatable x1 x2)⟧ ⟹ normal_dir (Repeatable x1 x2) = Repeatable x1 x2›*)
case Anything (*‹normalised Anything›*)
then show "?case"
(*goal: ‹normal_dir Anything = Anything›*)
by simp
next
(*goals:
1. ‹⋀x. normalised (Res x) ⟹ normal_dir (Res x) = Res x›
2. ‹⋀x. normalised (Copyable x) ⟹ normal_dir (Copyable x) = Copyable x›
3. ‹⋀x. ⟦⋀xa. ⟦xa ∈ set x; normalised xa⟧ ⟹ normal_dir xa = xa; normalised (Parallel x)⟧ ⟹ normal_dir (Parallel x) = Parallel x›
4. ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (NonD x1 x2)⟧ ⟹ normal_dir (NonD x1 x2) = NonD x1 x2›
5. ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Executable x1 x2)⟧ ⟹ normal_dir (Executable x1 x2) = Executable x1 x2›
6. ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Repeatable x1 x2)⟧ ⟹ normal_dir (Repeatable x1 x2) = Repeatable x1 x2›*)
case (Res x) (*‹normalised (Res x)›*)
then show "?case"
(*goal: ‹normal_dir (Res x) = Res x›*)
by simp
next
(*goals:
1. ‹⋀x. normalised (Copyable x) ⟹ normal_dir (Copyable x) = Copyable x›
2. ‹⋀x. ⟦⋀xa. ⟦xa ∈ set x; normalised xa⟧ ⟹ normal_dir xa = xa; normalised (Parallel x)⟧ ⟹ normal_dir (Parallel x) = Parallel x›
3. ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (NonD x1 x2)⟧ ⟹ normal_dir (NonD x1 x2) = NonD x1 x2›
4. ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Executable x1 x2)⟧ ⟹ normal_dir (Executable x1 x2) = Executable x1 x2›
5. ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Repeatable x1 x2)⟧ ⟹ normal_dir (Repeatable x1 x2) = Repeatable x1 x2›*)
case (Copyable x) (*‹normalised (Copyable x)›*)
then show "?case"
(*goal: ‹normal_dir (Copyable x) = Copyable x›*)
by simp
next
(*goals:
1. ‹⋀x. ⟦⋀xa. ⟦xa ∈ set x; normalised xa⟧ ⟹ normal_dir xa = xa; normalised (Parallel x)⟧ ⟹ normal_dir (Parallel x) = Parallel x›
2. ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (NonD x1 x2)⟧ ⟹ normal_dir (NonD x1 x2) = NonD x1 x2›
3. ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Executable x1 x2)⟧ ⟹ normal_dir (Executable x1 x2) = Executable x1 x2›
4. ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Repeatable x1 x2)⟧ ⟹ normal_dir (Repeatable x1 x2) = Repeatable x1 x2›*)
case (Parallel x) (*‹⟦?xa ∈ set x; normalised ?xa⟧ ⟹ normal_dir ?xa = ?xa› ‹normalised (Parallel x)›*)
then show "?case"
(*goal: ‹normal_dir (Parallel x) = Parallel x›*)
by (simp add: map_idI (*‹(⋀x. x ∈ set ?xs ⟹ ?f x = x) ⟹ map ?f ?xs = ?xs›*) merge_all_parallel_none (*‹¬ list_ex is_Parallel ?xs ⟹ merge_all_parallel ?xs = ?xs›*) normalised_parallel_children (*‹⟦normalised (Parallel ?xs); ?x ∈ set ?xs⟧ ⟹ normalised ?x›*) not_list_ex (*‹(¬ list_ex ?P ?xs) = list_all (λx. ¬ ?P x) ?xs›*) parallelise_to_parallel_conv (*‹(parallelise ?xs = Parallel ?ys) = (?xs = [Parallel ?ys] ∨ 1 < length ?xs ∧ ?xs = ?ys)›*) remove_all_empty_none (*‹¬ list_ex is_Empty ?xs ⟹ remove_all_empty ?xs = ?xs›*))
next
(*goals:
1. ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (NonD x1 x2)⟧ ⟹ normal_dir (NonD x1 x2) = NonD x1 x2›
2. ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Executable x1 x2)⟧ ⟹ normal_dir (Executable x1 x2) = Executable x1 x2›
3. ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Repeatable x1 x2)⟧ ⟹ normal_dir (Repeatable x1 x2) = Repeatable x1 x2›*)
case (NonD x1 x2) (*‹normalised x1 ⟹ normal_dir x1 = x1› ‹normalised (x2::('a::type, 'b::type) res_term) ⟹ normal_dir x2 = x2› ‹normalised (NonD (x1::('a, 'b) res_term) (x2::('a, 'b) res_term))›*)
then show "?case"
(*goal: ‹normal_dir (NonD x1 x2) = NonD x1 x2›*)
by simp
next
(*goals:
1. ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Executable x1 x2)⟧ ⟹ normal_dir (Executable x1 x2) = Executable x1 x2›
2. ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Repeatable x1 x2)⟧ ⟹ normal_dir (Repeatable x1 x2) = Repeatable x1 x2›*)
case (Executable x1 x2) (*‹normalised (x1::('a, 'b) res_term) ⟹ normal_dir x1 = x1› ‹normalised x2 ⟹ normal_dir x2 = x2› ‹normalised (Executable (x1::('a::type, 'b::type) res_term) (x2::('a::type, 'b::type) res_term))›*)
then show "?case"
(*goal: ‹normal_dir (Executable x1 x2) = Executable x1 x2›*)
by simp
next
(*goal: ‹⋀x1 x2. ⟦normalised x1 ⟹ normal_dir x1 = x1; normalised x2 ⟹ normal_dir x2 = x2; normalised (Repeatable x1 x2)⟧ ⟹ normal_dir (Repeatable x1 x2) = Repeatable x1 x2›*)
case (Repeatable a1 a2) (*‹normalised a1 ⟹ normal_dir a1 = a1› ‹normalised a2 ⟹ normal_dir a2 = a2› ‹normalised (Repeatable a1 a2)›*)
then show "?case"
(*goal: ‹normal_dir (Repeatable (a1::('a, 'b) res_term) (a2::('a, 'b) res_term)) = Repeatable a1 a2›*)
by simp
qed
text‹
Parallelising to anything but @{const Empty} or @{const Parallel} means the input list contained
just that
›
lemma parallelise_eq_Anything [simp]: "(parallelise xs = Anything) = (xs = [Anything])"
and parallelise_eq_Res [simp]: "(parallelise xs = Res a) = (xs = [Res a])"
and parallelise_eq_Copyable [simp]: "(parallelise xs = Copyable b) = (xs = [Copyable b])"
and parallelise_eq_NonD [simp]: "(parallelise xs = NonD x y) = (xs = [NonD x y])"
and parallelise_eq_Executable [simp]:"(parallelise xs = Executable x y) = (xs = [Executable x y])"
and parallelise_eq_Repeatable [simp]:"(parallelise xs = Repeatable x y) = (xs = [Repeatable x y])"
using parallelise.elims (*‹⟦parallelise ?x = ?y; ⟦?x = []; ?y = Empty⟧ ⟹ ?P; ⋀x. ⟦?x = [x]; ?y = x⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v # vb # vc; ?y = Parallel (v # vb # vc)⟧ ⟹ ?P⟧ ⟹ ?P›*) parallelise.simps(2) (*‹parallelise [?x] = ?x›*) apply -
(*goals:
1. ‹⟦⋀(x::(?'a20::type, ?'b20::type) res_term list) (y::(?'a20::type, ?'b20::type) res_term) P::bool. ⟦parallelise x = y; ⟦x = []; y = Empty⟧ ⟹ P; ⋀xa::(?'a20::type, ?'b20::type) res_term. ⟦x = [xa]; y = xa⟧ ⟹ P; ⋀(v::(?'a20::type, ?'b20::type) res_term) (vb::(?'a20::type, ?'b20::type) res_term) vc::(?'a20::type, ?'b20::type) res_term list. ⟦x = v # vb # vc; y = Parallel (v # vb # vc)⟧ ⟹ P⟧ ⟹ P; ⋀x::(?'a22::type, ?'b22::type) res_term. parallelise [x] = x⟧ ⟹ (parallelise (xs::('a::type, 'b::type) res_term list) = Anything) = (xs = [Anything])›
2. ‹⟦⋀(x::(?'a16::type, ?'b16::type) res_term list) (y::(?'a16::type, ?'b16::type) res_term) P::bool. ⟦parallelise x = y; ⟦x = []; y = Empty⟧ ⟹ P; ⋀xa::(?'a16::type, ?'b16::type) res_term. ⟦x = [xa]; y = xa⟧ ⟹ P; ⋀(v::(?'a16::type, ?'b16::type) res_term) (vb::(?'a16::type, ?'b16::type) res_term) vc::(?'a16::type, ?'b16::type) res_term list. ⟦x = v # vb # vc; y = Parallel (v # vb # vc)⟧ ⟹ P⟧ ⟹ P; ⋀x::(?'a18::type, ?'b18::type) res_term. parallelise [x] = x⟧ ⟹ (parallelise (xs::('a::type, 'b::type) res_term list) = Res (a::'a::type)) = (xs = [Res a])›
3. ‹⟦⋀(x::(?'a12::type, ?'b12::type) res_term list) (y::(?'a12::type, ?'b12::type) res_term) P::bool. ⟦parallelise x = y; ⟦x = []; y = Empty⟧ ⟹ P; ⋀xa::(?'a12::type, ?'b12::type) res_term. ⟦x = [xa]; y = xa⟧ ⟹ P; ⋀(v::(?'a12::type, ?'b12::type) res_term) (vb::(?'a12::type, ?'b12::type) res_term) vc::(?'a12::type, ?'b12::type) res_term list. ⟦x = v # vb # vc; y = Parallel (v # vb # vc)⟧ ⟹ P⟧ ⟹ P; ⋀x::(?'a14::type, ?'b14::type) res_term. parallelise [x] = x⟧ ⟹ (parallelise (xs::('a::type, 'b::type) res_term list) = Copyable (b::'b::type)) = (xs = [Copyable b])›
4. ‹⟦⋀(x::(?'a8::type, ?'b8::type) res_term list) (y::(?'a8::type, ?'b8::type) res_term) P::bool. ⟦parallelise x = y; ⟦x = []; y = Empty⟧ ⟹ P; ⋀xa::(?'a8::type, ?'b8::type) res_term. ⟦x = [xa]; y = xa⟧ ⟹ P; ⋀(v::(?'a8::type, ?'b8::type) res_term) (vb::(?'a8::type, ?'b8::type) res_term) vc::(?'a8::type, ?'b8::type) res_term list. ⟦x = v # vb # vc; y = Parallel (v # vb # vc)⟧ ⟹ P⟧ ⟹ P; ⋀x::(?'a10::type, ?'b10::type) res_term. parallelise [x] = x⟧ ⟹ (parallelise (xs::('a::type, 'b::type) res_term list) = NonD (x::('a::type, 'b::type) res_term) (y::('a::type, 'b::type) res_term)) = (xs = [NonD x y])›
5. ‹⟦⋀(x::(?'a4::type, ?'b4::type) res_term list) (y::(?'a4::type, ?'b4::type) res_term) P::bool. ⟦parallelise x = y; ⟦x = []; y = Empty⟧ ⟹ P; ⋀xa::(?'a4::type, ?'b4::type) res_term. ⟦x = [xa]; y = xa⟧ ⟹ P; ⋀(v::(?'a4::type, ?'b4::type) res_term) (vb::(?'a4::type, ?'b4::type) res_term) vc::(?'a4::type, ?'b4::type) res_term list. ⟦x = v # vb # vc; y = Parallel (v # vb # vc)⟧ ⟹ P⟧ ⟹ P; ⋀x::(?'a6::type, ?'b6::type) res_term. parallelise [x] = x⟧ ⟹ (parallelise (xs::('a::type, 'b::type) res_term list) = Executable (x::('a::type, 'b::type) res_term) (y::('a::type, 'b::type) res_term)) = (xs = [Executable x y])›
6. ‹⟦⋀(x::(?'a::type, ?'b::type) res_term list) (y::(?'a::type, ?'b::type) res_term) P::bool. ⟦parallelise x = y; ⟦x = []; y = Empty⟧ ⟹ P; ⋀xa::(?'a::type, ?'b::type) res_term. ⟦x = [xa]; y = xa⟧ ⟹ P; ⋀(v::(?'a::type, ?'b::type) res_term) (vb::(?'a::type, ?'b::type) res_term) vc::(?'a::type, ?'b::type) res_term list. ⟦x = v # vb # vc; y = Parallel (v # vb # vc)⟧ ⟹ P⟧ ⟹ P; ⋀x::(?'a2::type, ?'b2::type) res_term. parallelise [x] = x⟧ ⟹ (parallelise (xs::('a::type, 'b::type) res_term list) = Repeatable (x::('a::type, 'b::type) res_term) (y::('a::type, 'b::type) res_term)) = (xs = [Repeatable x y])›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*discuss goal 3*)
apply blast
(*discuss goal 4*)
apply blast
(*discuss goal 5*)
apply blast
(*discuss goal 6*)
apply blast
(*proven 6 subgoals*) .
text‹Equivalent resource terms normalise to equal results›
lemma res_term_equiv_normal_dir:
"a ∼ b ⟹ normal_dir a = normal_dir b"
proof (induct a b rule: res_term_equiv.induct (*‹⟦(?x1.0::(?'a::type, ?'b::type) res_term) ∼ (?x2.0::(?'a::type, ?'b::type) res_term); (?P::(?'a::type, ?'b::type) res_term ⇒ (?'a::type, ?'b::type) res_term ⇒ bool) (Parallel []) Empty; ⋀a::(?'a::type, ?'b::type) res_term. ?P (Parallel [a]) a; ⋀(x::(?'a::type, ?'b::type) res_term list) (y::(?'a::type, ?'b::type) res_term list) z::(?'a::type, ?'b::type) res_term list. ?P (Parallel (x @ [Parallel y] @ z)) (Parallel (x @ y @ z)); ?P Empty Empty; ?P Anything Anything; ⋀x::?'a::type. ?P (Res x) (Res x); ⋀x::?'b::type. ?P (Copyable x) (Copyable x); ⋀(xs::(?'a::type, ?'b::type) res_term list) ys::(?'a::type, ?'b::type) res_term list. list_all2 (λ(x1::(?'a::type, ?'b::type) res_term) x2::(?'a::type, ?'b::type) res_term. x1 ∼ x2 ∧ ?P x1 x2) xs ys ⟹ ?P (Parallel xs) (Parallel ys); ⋀(x::(?'a::type, ?'b::type) res_term) (y::(?'a::type, ?'b::type) res_term) (u::(?'a::type, ?'b::type) res_term) v::(?'a::type, ?'b::type) res_term. ⟦x ∼ y; ?P x y; u ∼ v; ?P u v⟧ ⟹ ?P (NonD x u) (NonD y v); ⋀(x::(?'a::type, ?'b::type) res_term) (y::(?'a::type, ?'b::type) res_term) (u::(?'a::type, ?'b::type) res_term) v::(?'a::type, ?'b::type) res_term. ⟦x ∼ y; ?P x y; u ∼ v; ?P u v⟧ ⟹ ?P (Executable x u) (Executable y v); ⋀(x::(?'a::type, ?'b::type) res_term) (y::(?'a::type, ?'b::type) res_term) (u::(?'a::type, ?'b::type) res_term) v::(?'a::type, ?'b::type) res_term. ⟦x ∼ y; ?P x y; u ∼ v; ?P u v⟧ ⟹ ?P (Repeatable x u) (Repeatable y v); ⋀(x::(?'a::type, ?'b::type) res_term) y::(?'a::type, ?'b::type) res_term. ⟦x ∼ y; ?P x y⟧ ⟹ ?P y x; ⋀(x::(?'a::type, ?'b::type) res_term) (y::(?'a::type, ?'b::type) res_term) z::(?'a::type, ?'b::type) res_term. ⟦x ∼ y; ?P x y; y ∼ z; ?P y z⟧ ⟹ ?P x z⟧ ⟹ ?P ?x1.0 ?x2.0›*))
(*goals:
1. ‹normal_dir (Parallel []) = normal_dir Empty›
2. ‹⋀a. normal_dir (Parallel [a]) = normal_dir a›
3. ‹⋀x y z. normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
4. ‹normal_dir Empty = normal_dir Empty›
5. ‹normal_dir Anything = normal_dir Anything›
6. ‹⋀x. normal_dir (Res x) = normal_dir (Res x)›
7. ‹⋀x. normal_dir (Copyable x) = normal_dir (Copyable x)›
8. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ normal_dir x1 = normal_dir x2) xs ys ⟹ normal_dir (Parallel xs) = normal_dir (Parallel ys)›
9. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (NonD x u) = normal_dir (NonD y v)›
10. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Executable x u) = normal_dir (Executable y v)›
11. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Repeatable x u) = normal_dir (Repeatable y v)›
12. ‹⋀x y. ⟦x ∼ y; normal_dir x = normal_dir y⟧ ⟹ normal_dir y = normal_dir x›
13. ‹⋀x y z. ⟦x ∼ y; normal_dir x = normal_dir y; y ∼ z; normal_dir y = normal_dir z⟧ ⟹ normal_dir x = normal_dir z›*)
case empty (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹normal_dir Empty = normal_dir Empty›*)
by simp
next
(*goals:
1. ‹normal_dir (Parallel []) = normal_dir Empty›
2. ‹⋀a. normal_dir (Parallel [a]) = normal_dir a›
3. ‹⋀x y z. normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
4. ‹normal_dir Anything = normal_dir Anything›
5. ‹⋀x. normal_dir (Res x) = normal_dir (Res x)›
6. ‹⋀x. normal_dir (Copyable x) = normal_dir (Copyable x)›
7. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ normal_dir x1 = normal_dir x2) xs ys ⟹ normal_dir (Parallel xs) = normal_dir (Parallel ys)›
8. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (NonD x u) = normal_dir (NonD y v)›
9. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Executable x u) = normal_dir (Executable y v)›
10. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Repeatable x u) = normal_dir (Repeatable y v)›
11. ‹⋀x y. ⟦x ∼ y; normal_dir x = normal_dir y⟧ ⟹ normal_dir y = normal_dir x›
12. ‹⋀x y z. ⟦x ∼ y; normal_dir x = normal_dir y; y ∼ z; normal_dir y = normal_dir z⟧ ⟹ normal_dir x = normal_dir z›*)
case anything (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹normal_dir Anything = normal_dir Anything›*)
by simp
next
(*goals:
1. ‹normal_dir (Parallel []) = normal_dir Empty›
2. ‹⋀a::('a, 'b) res_term. normal_dir (Parallel [a]) = normal_dir a›
3. ‹⋀(x::('a, 'b) res_term list) (y::('a, 'b) res_term list) z::('a, 'b) res_term list. normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
4. ‹⋀x::'a. normal_dir (Res x) = normal_dir (Res x)›
5. ‹⋀x::'b. normal_dir (Copyable x) = normal_dir (Copyable x)›
6. ‹⋀(xs::('a, 'b) res_term list) ys::('a, 'b) res_term list. list_all2 (λ(x1::('a, 'b) res_term) x2::('a, 'b) res_term. x1 ∼ x2 ∧ normal_dir x1 = normal_dir x2) xs ys ⟹ normal_dir (Parallel xs) = normal_dir (Parallel ys)›
7. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (NonD x u) = normal_dir (NonD y v)›
8. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Executable x u) = normal_dir (Executable y v)›
9. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Repeatable x u) = normal_dir (Repeatable y v)›
10. ‹⋀(x::('a, 'b) res_term) y::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y⟧ ⟹ normal_dir y = normal_dir x›
11. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) z::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; y ∼ z; normal_dir y = normal_dir z⟧ ⟹ normal_dir x = normal_dir z›*)
case (res x) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹normal_dir (Res x) = normal_dir (Res x)›*)
by simp
next
(*goals:
1. ‹normal_dir (Parallel []) = normal_dir Empty›
2. ‹⋀a. normal_dir (Parallel [a]) = normal_dir a›
3. ‹⋀x y z. normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
4. ‹⋀x. normal_dir (Copyable x) = normal_dir (Copyable x)›
5. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ normal_dir x1 = normal_dir x2) xs ys ⟹ normal_dir (Parallel xs) = normal_dir (Parallel ys)›
6. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (NonD x u) = normal_dir (NonD y v)›
7. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Executable x u) = normal_dir (Executable y v)›
8. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Repeatable x u) = normal_dir (Repeatable y v)›
9. ‹⋀x y. ⟦x ∼ y; normal_dir x = normal_dir y⟧ ⟹ normal_dir y = normal_dir x›
10. ‹⋀x y z. ⟦x ∼ y; normal_dir x = normal_dir y; y ∼ z; normal_dir y = normal_dir z⟧ ⟹ normal_dir x = normal_dir z›*)
case (copyable x) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹normal_dir (Copyable x) = normal_dir (Copyable x)›*)
by simp
next
(*goals:
1. ‹normal_dir (Parallel []) = normal_dir Empty›
2. ‹⋀a. normal_dir (Parallel [a]) = normal_dir a›
3. ‹⋀x y z. normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
4. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ normal_dir x1 = normal_dir x2) xs ys ⟹ normal_dir (Parallel xs) = normal_dir (Parallel ys)›
5. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (NonD x u) = normal_dir (NonD y v)›
6. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Executable x u) = normal_dir (Executable y v)›
7. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Repeatable x u) = normal_dir (Repeatable y v)›
8. ‹⋀x y. ⟦x ∼ y; normal_dir x = normal_dir y⟧ ⟹ normal_dir y = normal_dir x›
9. ‹⋀x y z. ⟦x ∼ y; normal_dir x = normal_dir y; y ∼ z; normal_dir y = normal_dir z⟧ ⟹ normal_dir x = normal_dir z›*)
case nil (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹normal_dir (Parallel []) = normal_dir Empty›*)
by simp
next
(*goals:
1. ‹⋀a::('a::type, 'b::type) res_term. normal_dir (Parallel [a]) = normal_dir a›
2. ‹⋀(x::('a::type, 'b::type) res_term list) (y::('a::type, 'b::type) res_term list) z::('a::type, 'b::type) res_term list. normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
3. ‹⋀(xs::('a::type, 'b::type) res_term list) ys::('a::type, 'b::type) res_term list. list_all2 (λ(x1::('a::type, 'b::type) res_term) x2::('a::type, 'b::type) res_term. x1 ∼ x2 ∧ normal_dir x1 = normal_dir x2) xs ys ⟹ normal_dir (Parallel xs) = normal_dir (Parallel ys)›
4. ‹⋀(x::('a::type, 'b::type) res_term) (y::('a::type, 'b::type) res_term) (u::('a::type, 'b::type) res_term) v::('a::type, 'b::type) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (NonD x u) = normal_dir (NonD y v)›
5. ‹⋀(x::('a::type, 'b::type) res_term) (y::('a::type, 'b::type) res_term) (u::('a::type, 'b::type) res_term) v::('a::type, 'b::type) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Executable x u) = normal_dir (Executable y v)›
6. ‹⋀(x::('a::type, 'b::type) res_term) (y::('a::type, 'b::type) res_term) (u::('a::type, 'b::type) res_term) v::('a::type, 'b::type) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Repeatable x u) = normal_dir (Repeatable y v)›
7. ‹⋀(x::('a::type, 'b::type) res_term) y::('a::type, 'b::type) res_term. ⟦x ∼ y; normal_dir x = normal_dir y⟧ ⟹ normal_dir y = normal_dir x›
8. ‹⋀(x::('a::type, 'b::type) res_term) (y::('a::type, 'b::type) res_term) z::('a::type, 'b::type) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; y ∼ z; normal_dir y = normal_dir z⟧ ⟹ normal_dir x = normal_dir z›*)
case (singleton a) (*no hyothesis introduced yet*)
have "⋀xs. normal_dir a = Parallel xs ⟹ parallelise xs = Parallel xs"
using normalised_normal_dir (*‹normalised (normal_dir (?a::(?'a, ?'b) res_term))›*) normalised.simps(5) (*‹normalised (Parallel ?xs) = (list_all normalised ?xs ∧ list_all (λx. ¬ is_Empty x) ?xs ∧ list_all (λx. ¬ is_Parallel x) ?xs ∧ 1 < length ?xs)›*) parallelise_to_parallel_same_length (*‹(parallelise ?xs = Parallel ?xs) = (1 < length ?xs)›*) by metis
then show "?case"
(*goal: ‹normal_dir (Parallel [a]) = normal_dir a›*)
apply (cases "normal_dir a")
(*goals:
1. ‹⋀x1. ⟦⋀xs. normal_dir a = Parallel xs ⟹ parallelise xs = Parallel xs; normal_dir a = Res x1⟧ ⟹ normal_dir (Parallel [a]) = normal_dir a›
2. ‹⋀x2. ⟦⋀xs. normal_dir a = Parallel xs ⟹ parallelise xs = Parallel xs; normal_dir a = Copyable x2⟧ ⟹ normal_dir (Parallel [a]) = normal_dir a›
3. ‹⟦⋀xs. normal_dir a = Parallel xs ⟹ parallelise xs = Parallel xs; normal_dir a = Empty⟧ ⟹ normal_dir (Parallel [a]) = normal_dir a›
4. ‹⟦⋀xs. normal_dir a = Parallel xs ⟹ parallelise xs = Parallel xs; normal_dir a = Anything⟧ ⟹ normal_dir (Parallel [a]) = normal_dir a›
5. ‹⋀x5. ⟦⋀xs. normal_dir a = Parallel xs ⟹ parallelise xs = Parallel xs; normal_dir a = Parallel x5⟧ ⟹ normal_dir (Parallel [a]) = normal_dir a›
6. ‹⋀x61 x62. ⟦⋀xs. normal_dir a = Parallel xs ⟹ parallelise xs = Parallel xs; normal_dir a = NonD x61 x62⟧ ⟹ normal_dir (Parallel [a]) = normal_dir a›
7. ‹⋀x71 x72. ⟦⋀xs. normal_dir a = Parallel xs ⟹ parallelise xs = Parallel xs; normal_dir a = Executable x71 x72⟧ ⟹ normal_dir (Parallel [a]) = normal_dir a›
8. ‹⋀x81 x82. ⟦⋀xs. normal_dir a = Parallel xs ⟹ parallelise xs = Parallel xs; normal_dir a = Repeatable x81 x82⟧ ⟹ normal_dir (Parallel [a]) = normal_dir a›
discuss goal 1*)
apply (simp add: is_Parallel_def (*‹is_Parallel ?res_term = (∃x5. ?res_term = Parallel x5)›*))
(*discuss goal 2*)
apply (simp add: is_Parallel_def (*‹is_Parallel ?res_term = (∃x5. ?res_term = Parallel x5)›*))
(*discuss goal 3*)
apply (simp add: is_Parallel_def (*‹is_Parallel ?res_term = (∃x5. ?res_term = Parallel x5)›*))
(*discuss goal 4*)
apply (simp add: is_Parallel_def (*‹is_Parallel ?res_term = (∃x5. ?res_term = Parallel x5)›*))
(*discuss goal 5*)
apply (simp add: is_Parallel_def (*‹is_Parallel ?res_term = (∃x5. ?res_term = Parallel x5)›*))
(*discuss goal 6*)
apply (simp add: is_Parallel_def (*‹is_Parallel (?res_term::(?'a, ?'b) res_term) = (∃x5::(?'a, ?'b) res_term list. ?res_term = Parallel x5)›*))
(*discuss goal 7*)
apply (simp add: is_Parallel_def (*‹is_Parallel ?res_term = (∃x5. ?res_term = Parallel x5)›*))
(*discuss goal 8*)
apply (simp add: is_Parallel_def (*‹is_Parallel ?res_term = (∃x5. ?res_term = Parallel x5)›*))
(*proven 8 subgoals*) .
next
(*goals:
1. ‹⋀(x::('a, 'b) res_term list) (y::('a, 'b) res_term list) z::('a, 'b) res_term list. normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
2. ‹⋀(xs::('a, 'b) res_term list) ys::('a, 'b) res_term list. list_all2 (λ(x1::('a, 'b) res_term) x2::('a, 'b) res_term. x1 ∼ x2 ∧ normal_dir x1 = normal_dir x2) xs ys ⟹ normal_dir (Parallel xs) = normal_dir (Parallel ys)›
3. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (NonD x u) = normal_dir (NonD y v)›
4. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Executable x u) = normal_dir (Executable y v)›
5. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Repeatable x u) = normal_dir (Repeatable y v)›
6. ‹⋀(x::('a, 'b) res_term) y::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y⟧ ⟹ normal_dir y = normal_dir x›
7. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) z::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; y ∼ z; normal_dir y = normal_dir z⟧ ⟹ normal_dir x = normal_dir z›*)
case (merge x y z) (*no hyothesis introduced yet*)
then show "?case"
(*goal: ‹normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›*)
proof (cases "normal_dir (Parallel y) = Empty")
(*goals:
1. ‹normal_dir (Parallel y) = Empty ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
2. ‹normal_dir (Parallel y) ≠ Empty ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›*)
case True (*‹normal_dir (Parallel y) = Empty›*)
then consider "merge_all_parallel (remove_all_empty (map normal_dir y)) = []" | "merge_all_parallel (remove_all_empty (map normal_dir y)) = [Empty]"
(*goal: ‹⟦merge_all_parallel (remove_all_empty (map normal_dir y)) = [] ⟹ thesis; merge_all_parallel (remove_all_empty (map normal_dir y)) = [Empty] ⟹ thesis⟧ ⟹ thesis›*)
using parallelise_to_empty_eq (*‹⟦parallelise ?xs = Empty; ?xs = [] ⟹ ?thesis; ?xs = [Empty] ⟹ ?thesis⟧ ⟹ ?thesis›*) by fastforce
then show "?thesis"
(*goal: ‹normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›*)
proof (cases)
(*goals:
1. ‹merge_all_parallel (remove_all_empty (map normal_dir y)) = [] ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
2. ‹merge_all_parallel (remove_all_empty (map normal_dir y)) = [Empty] ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›*)
case 1 (*‹merge_all_parallel (remove_all_empty (map normal_dir y)) = []›*)
then show "?thesis"
(*goal: ‹normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›*)
by (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) merge_all_parallel_append (*‹merge_all_parallel (?xs @ ?ys) = merge_all_parallel ?xs @ merge_all_parallel ?ys›*))
next
(*goal: ‹merge_all_parallel (remove_all_empty (map normal_dir y)) = [Empty] ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›*)
case 2 (*‹merge_all_parallel (remove_all_empty (map normal_dir (y::('a, 'b) res_term list))) = [Empty]›*)
have "list_ex is_Empty (remove_all_empty (map normal_dir y))"
proof (rule merge_all_parallel_has_empty (*‹⟦list_ex is_Empty (merge_all_parallel ?xs); ⋀ys. ⟦Parallel ys ∈ set ?xs; list_ex is_Empty ys⟧ ⟹ ?thesis; list_ex is_Empty ?xs ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*goals:
1. ‹list_ex is_Empty (merge_all_parallel ?xs)›
2. ‹⋀ys. ⟦Parallel ys ∈ set ?xs; list_ex is_Empty ys⟧ ⟹ list_ex is_Empty (remove_all_empty (map normal_dir y))›
3. ‹list_ex is_Empty ?xs ⟹ list_ex is_Empty (remove_all_empty (map normal_dir y))›*)
show "list_ex is_Empty (merge_all_parallel (remove_all_empty (map normal_dir y)))"
using "2" (*‹merge_all_parallel (remove_all_empty (map normal_dir y)) = [Empty]›*) by simp
show "list_ex is_Empty (remove_all_empty (map normal_dir y))" if "Parallel ys ∈ set (remove_all_empty (map normal_dir y))" and "list_ex is_Empty ys" for ys
using that (*‹Parallel ys ∈ set (remove_all_empty (map normal_dir y))› ‹list_ex is_Empty ys›*) remove_all_empty_has_Parallel (*‹Parallel ?ys ∈ set (remove_all_empty ?xs) ⟹ Parallel ?ys ∈ set ?xs›*) normal_dir_no_nested_Empty (*‹normal_dir (?a::(?'a::type, ?'b::type) res_term) = Parallel (?xs::(?'a::type, ?'b::type) res_term list) ⟹ ¬ list_ex is_Empty ?xs›*) by (metis ex_map_conv (*‹(∃xs. ?ys = map ?f xs) = (∀y∈set ?ys. ∃x. y = ?f x)›*))
qed
then show "?thesis"
(*goal: ‹normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›*)
using remove_all_empty_result (*‹¬ list_ex is_Empty (remove_all_empty ?xs)›*) by blast
qed
next
(*goal: ‹normal_dir (Parallel y) ≠ Empty ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›*)
case False (*‹normal_dir (Parallel (y::('a::type, 'b::type) res_term list)) ≠ Empty›*)
have "?thesis" if y: "normal_dir (Parallel y) = Parallel ys" for ys
proof (-)
(*goal: ‹normal_dir (Parallel ((x::('a, 'b) res_term list) @ [Parallel (y::('a, 'b) res_term list)] @ (z::('a, 'b) res_term list))) = normal_dir (Parallel (x @ y @ z))›*)
consider "merge_all_parallel (remove_all_empty (map normal_dir y)) = [Parallel ys]" | "1 < length (merge_all_parallel (remove_all_empty (map normal_dir y)))" and "merge_all_parallel (remove_all_empty (map normal_dir y)) = ys"
(*goal: ‹⟦merge_all_parallel (remove_all_empty (map normal_dir y)) = [Parallel ys] ⟹ thesis; ⟦1 < length (merge_all_parallel (remove_all_empty (map normal_dir y))); merge_all_parallel (remove_all_empty (map normal_dir y)) = ys⟧ ⟹ thesis⟧ ⟹ thesis›*)
using y (*‹normal_dir (Parallel (y::('a::type, 'b::type) res_term list)) = Parallel (ys::('a::type, 'b::type) res_term list)›*) parallelise_to_parallel_conv (*‹(parallelise ?xs = Parallel ?ys) = (?xs = [Parallel ?ys] ∨ 1 < length ?xs ∧ ?xs = ?ys)›*) by (fastforce simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) merge_all_parallel_append (*‹merge_all_parallel (?xs @ ?ys) = merge_all_parallel ?xs @ merge_all_parallel ?ys›*))
then show "?thesis"
(*goal: ‹normal_dir (Parallel ((x::('a, 'b) res_term list) @ [Parallel (y::('a, 'b) res_term list)] @ (z::('a, 'b) res_term list))) = normal_dir (Parallel (x @ y @ z))›*)
proof (cases)
(*goals:
1. ‹merge_all_parallel (remove_all_empty (map normal_dir y)) = [Parallel ys] ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
2. ‹⟦1 < length (merge_all_parallel (remove_all_empty (map normal_dir y))); merge_all_parallel (remove_all_empty (map normal_dir y)) = ys⟧ ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›*)
case 1 (*‹merge_all_parallel (remove_all_empty (map normal_dir y)) = [Parallel ys]›*)
then show "?thesis"
(*goal: ‹normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) merge_all_parallel_append (*‹merge_all_parallel (?xs @ ?ys) = merge_all_parallel ?xs @ merge_all_parallel ?ys›*))
(*goal: ‹normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›*)
by (smt (z3) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) list.set_map (*‹set (map ?f ?v) = ?f ` set ?v›*) list_ex_simps( (*‹list_ex ?P (?x # ?xs) = (?P ?x ∨ list_ex ?P ?xs)›*) 1) merge_all_parallel_has_Parallel (*‹⟦list_ex is_Parallel (merge_all_parallel ?xs); ⋀ys. ⟦Parallel ys ∈ set ?xs; list_ex is_Parallel ys⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) remove_all_empty_has_Parallel (*‹Parallel ?ys ∈ set (remove_all_empty ?xs) ⟹ Parallel ?ys ∈ set ?xs›*) res_term.discI( (*‹?res_term = Parallel ?x5.0 ⟹ is_Parallel ?res_term›*) 5) normal_dir_no_nested_Parallel (*‹normal_dir ?a = Parallel ?xs ⟹ ¬ list_ex is_Parallel ?xs›*))
next
(*goal: ‹⟦1 < length (merge_all_parallel (remove_all_empty (map normal_dir y))); merge_all_parallel (remove_all_empty (map normal_dir y)) = ys⟧ ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›*)
case 2 (*‹1 < length (merge_all_parallel (remove_all_empty (map normal_dir y)))› ‹merge_all_parallel (remove_all_empty (map normal_dir y)) = ys›*)
then show "?thesis"
(*goal: ‹normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›*)
using False (*‹normal_dir (Parallel y) ≠ Empty›*) y (*‹normal_dir (Parallel y) = Parallel ys›*) by (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) merge_all_parallel_append (*‹merge_all_parallel (?xs @ ?ys) = merge_all_parallel ?xs @ merge_all_parallel ?ys›*))
qed
qed
then show "?thesis"
(*goal: ‹normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›*)
using False (*‹normal_dir (Parallel y) ≠ Empty›*) apply (cases "normal_dir (Parallel y)")
(*goals:
1. ‹⋀x1. ⟦⋀ys. normal_dir (Parallel y) = Parallel ys ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z)); normal_dir (Parallel y) ≠ Empty; normal_dir (Parallel y) = Res x1⟧ ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
2. ‹⋀x2. ⟦⋀ys. normal_dir (Parallel y) = Parallel ys ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z)); normal_dir (Parallel y) ≠ Empty; normal_dir (Parallel y) = Copyable x2⟧ ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
3. ‹⟦⋀ys. normal_dir (Parallel y) = Parallel ys ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z)); normal_dir (Parallel y) ≠ Empty; normal_dir (Parallel y) = Empty⟧ ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
4. ‹⟦⋀ys. normal_dir (Parallel y) = Parallel ys ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z)); normal_dir (Parallel y) ≠ Empty; normal_dir (Parallel y) = Anything⟧ ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
5. ‹⋀x5. ⟦⋀ys. normal_dir (Parallel y) = Parallel ys ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z)); normal_dir (Parallel y) ≠ Empty; normal_dir (Parallel y) = Parallel x5⟧ ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
6. ‹⋀x61 x62. ⟦⋀ys. normal_dir (Parallel y) = Parallel ys ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z)); normal_dir (Parallel y) ≠ Empty; normal_dir (Parallel y) = NonD x61 x62⟧ ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
7. ‹⋀x71 x72. ⟦⋀ys. normal_dir (Parallel y) = Parallel ys ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z)); normal_dir (Parallel y) ≠ Empty; normal_dir (Parallel y) = Executable x71 x72⟧ ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
8. ‹⋀x81 x82. ⟦⋀ys. normal_dir (Parallel y) = Parallel ys ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z)); normal_dir (Parallel y) ≠ Empty; normal_dir (Parallel y) = Repeatable x81 x82⟧ ⟹ normal_dir (Parallel (x @ [Parallel y] @ z)) = normal_dir (Parallel (x @ y @ z))›
discuss goal 1*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) merge_all_parallel_append (*‹merge_all_parallel (?xs @ ?ys) = merge_all_parallel ?xs @ merge_all_parallel ?ys›*))
(*discuss goal 2*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) merge_all_parallel_append (*‹merge_all_parallel (?xs @ ?ys) = merge_all_parallel ?xs @ merge_all_parallel ?ys›*))
(*discuss goal 3*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) merge_all_parallel_append (*‹merge_all_parallel (?xs @ ?ys) = merge_all_parallel ?xs @ merge_all_parallel ?ys›*))
(*discuss goal 4*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) merge_all_parallel_append (*‹merge_all_parallel (?xs @ ?ys) = merge_all_parallel ?xs @ merge_all_parallel ?ys›*))
(*discuss goal 5*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) merge_all_parallel_append (*‹merge_all_parallel (?xs @ ?ys) = merge_all_parallel ?xs @ merge_all_parallel ?ys›*))
(*discuss goal 6*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) merge_all_parallel_append (*‹merge_all_parallel (?xs @ ?ys) = merge_all_parallel ?xs @ merge_all_parallel ?ys›*))
(*discuss goal 7*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty (?xs @ ?ys) = remove_all_empty ?xs @ remove_all_empty ?ys›*) merge_all_parallel_append (*‹merge_all_parallel (?xs @ ?ys) = merge_all_parallel ?xs @ merge_all_parallel ?ys›*))
(*discuss goal 8*)
apply (simp add: remove_all_empty_append (*‹remove_all_empty ((?xs::(?'a, ?'b) res_term list) @ (?ys::(?'a, ?'b) res_term list)) = remove_all_empty ?xs @ remove_all_empty ?ys›*) merge_all_parallel_append (*‹merge_all_parallel ((?xs::(?'a, ?'b) res_term list) @ (?ys::(?'a, ?'b) res_term list)) = merge_all_parallel ?xs @ merge_all_parallel ?ys›*))
(*proven 8 subgoals*) .
qed
next
(*goals:
1. ‹⋀xs ys. list_all2 (λx1 x2. x1 ∼ x2 ∧ normal_dir x1 = normal_dir x2) xs ys ⟹ normal_dir (Parallel xs) = normal_dir (Parallel ys)›
2. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (NonD x u) = normal_dir (NonD y v)›
3. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Executable x u) = normal_dir (Executable y v)›
4. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Repeatable x u) = normal_dir (Repeatable y v)›
5. ‹⋀x y. ⟦x ∼ y; normal_dir x = normal_dir y⟧ ⟹ normal_dir y = normal_dir x›
6. ‹⋀x y z. ⟦x ∼ y; normal_dir x = normal_dir y; y ∼ z; normal_dir y = normal_dir z⟧ ⟹ normal_dir x = normal_dir z›*)
case (parallel xs ys) (*‹list_all2 (λx1 x2. x1 ∼ x2 ∧ normal_dir x1 = normal_dir x2) xs ys›*)
then have "map normal_dir xs = map normal_dir ys"
by (clarsimp simp add: list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*) list_eq_iff_nth_eq (*‹(?xs = ?ys) = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?xs ! i = ?ys ! i))›*))
then show "?case"
(*goal: ‹normal_dir (Parallel xs) = normal_dir (Parallel ys)›*)
by simp
next
(*goals:
1. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (NonD x u) = normal_dir (NonD y v)›
2. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Executable x u) = normal_dir (Executable y v)›
3. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) (u::('a, 'b) res_term) v::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Repeatable x u) = normal_dir (Repeatable y v)›
4. ‹⋀(x::('a, 'b) res_term) y::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y⟧ ⟹ normal_dir y = normal_dir x›
5. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) z::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; y ∼ z; normal_dir y = normal_dir z⟧ ⟹ normal_dir x = normal_dir z›*)
case (nondet x y u v) (*‹(x::('a, 'b) res_term) ∼ (y::('a, 'b) res_term)› ‹normal_dir x = normal_dir y› ‹(u::('a, 'b) res_term) ∼ (v::('a, 'b) res_term)› ‹normal_dir u = normal_dir v›*)
then show "?case"
(*goal: ‹normal_dir (NonD x u) = normal_dir (NonD y v)›*)
by simp
next
(*goals:
1. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Executable x u) = normal_dir (Executable y v)›
2. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Repeatable x u) = normal_dir (Repeatable y v)›
3. ‹⋀x y. ⟦x ∼ y; normal_dir x = normal_dir y⟧ ⟹ normal_dir y = normal_dir x›
4. ‹⋀x y z. ⟦x ∼ y; normal_dir x = normal_dir y; y ∼ z; normal_dir y = normal_dir z⟧ ⟹ normal_dir x = normal_dir z›*)
case (executable x y u v) (*‹(x::('a::type, 'b::type) res_term) ∼ (y::('a::type, 'b::type) res_term)› ‹normal_dir x = normal_dir y› ‹(u::('a, 'b) res_term) ∼ (v::('a, 'b) res_term)› ‹normal_dir u = normal_dir v›*)
then show "?case"
(*goal: ‹normal_dir (Executable (x::('a, 'b) res_term) (u::('a, 'b) res_term)) = normal_dir (Executable (y::('a, 'b) res_term) (v::('a, 'b) res_term))›*)
by simp
next
(*goals:
1. ‹⋀x y u v. ⟦x ∼ y; normal_dir x = normal_dir y; u ∼ v; normal_dir u = normal_dir v⟧ ⟹ normal_dir (Repeatable x u) = normal_dir (Repeatable y v)›
2. ‹⋀x y. ⟦x ∼ y; normal_dir x = normal_dir y⟧ ⟹ normal_dir y = normal_dir x›
3. ‹⋀x y z. ⟦x ∼ y; normal_dir x = normal_dir y; y ∼ z; normal_dir y = normal_dir z⟧ ⟹ normal_dir x = normal_dir z›*)
case (repeatable x y u v) (*‹x ∼ y› ‹normal_dir x = normal_dir y› ‹u ∼ v› ‹normal_dir u = normal_dir v›*)
then show "?case"
(*goal: ‹normal_dir (Repeatable x u) = normal_dir (Repeatable y v)›*)
by simp
next
(*goals:
1. ‹⋀(x::('a, 'b) res_term) y::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y⟧ ⟹ normal_dir y = normal_dir x›
2. ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) z::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; y ∼ z; normal_dir y = normal_dir z⟧ ⟹ normal_dir x = normal_dir z›*)
case (sym x y) (*‹x ∼ y› ‹normal_dir x = normal_dir y›*)
then show "?case"
(*goal: ‹normal_dir y = normal_dir x›*)
by simp
next
(*goal: ‹⋀(x::('a, 'b) res_term) (y::('a, 'b) res_term) z::('a, 'b) res_term. ⟦x ∼ y; normal_dir x = normal_dir y; y ∼ z; normal_dir y = normal_dir z⟧ ⟹ normal_dir x = normal_dir z›*)
case (trans x y z) (*‹x ∼ y› ‹normal_dir (x::('a, 'b) res_term) = normal_dir (y::('a, 'b) res_term)› ‹y ∼ z› ‹normal_dir y = normal_dir z›*)
then show "?case"
(*goal: ‹normal_dir x = normal_dir z›*)
by simp
qed
text‹Equivalence of resource term is equality of their normal forms›
lemma res_term_equiv_is_normal_dir:
"a ∼ b = (normal_dir a = normal_dir b)"
using res_term_equiv_normal_dir (*‹?a ∼ ?b ⟹ normal_dir ?a = normal_dir ?b›*) normal_dir_eq_imp_equiv (*‹normal_dir ?a = normal_dir ?b ⟹ ?a ∼ ?b›*) apply standard
(*goals:
1. ‹a ∼ b ⟹ a ∼ b›
2. ‹normal_dir a = normal_dir b ⟹ normal_dir a = normal_dir b›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
text‹We use this fact to give a code equation for @{const res_term_equiv}›
lemmas [code] = res_term_equiv_is_normal_dir
text‹The normal form is unique in each resource term equivalence class›
lemma normal_dir_unique:
"⟦normal_dir x = x; normal_dir y = y; x ∼ y⟧ ⟹ x = y"
using res_term_equiv_normal_dir (*‹?a ∼ ?b ⟹ normal_dir ?a = normal_dir ?b›*) by metis
end | {
"path": "afp-2025-02-12/thys/ProcessComposition/ResNormDirect.thy",
"repo": "afp-2025-02-12",
"sha": "7a88ceab69743083a589e19aad44a6996706e40d4474ceb0083580da5f6a8f22"
} |
(* Formalization adapted from:
Fabián Fernando Serrano Suárez, "Formalización en Isar de la
Meta-Lógica de Primer Orden." PhD thesis,
Departamento de Ciencias de la Computación e Inteligencia Artificial,
Universidad de Sevilla, Spain, 2012.
https://idus.us.es/handle/11441/57780. In Spanish *)
theory PropCompactness
imports Main
"HOL-Library.Countable_Set"
"ModelExistence"
begin
section ‹Compactness Theorem for Propositional Logic ›
text ‹This theory formalises the compactness theorem based on the existence model theorem. The formalisation, initially published as \cite{Serrano2011} in Spanish, was adapted to extend several combinatorial theorems over finite structures to the infinite case (e.g., see Serrano, Ayala-Rincón, and de Lima formalizations of Hall's Theorem for infinite families of sets and infinite graphs \cite{SARdL2022,SARdL2024}.)
The formalization shows first Hintikka's Lemma: Hintikka sets of propositional formulas are satisfiable. Such a set is defined as a set of propositional formulas that does neither include both $A$ and $\neg A$ for a propositional letter nor $\bot$, or $\neg\top$. Additionally, if it includes $\neg\neg F$, $F$ is included; if it includes a conjunctive formula, which is an $\alpha$ formula, then the two components of the conjunction are included; and finally, if it includes a disjunction, which is a $\beta$ formula, at least one of the components of the disjunction is included.
The satisfiability of any Hintikka set is proved by assuming a valuation that maps all propositional letters in the set to true and all other propositional letters to false. The second step consists in proving that families of sets of propositional formulas, which hold the so-called ``propositional consistency property,'' consist of satisfiable sets. The last is indeed the model existence theorem. The model existence theorem compiles the essence of completeness: a family of sets of propositional formulas that holds the propositional consistency property can be extended, preserving this property to a set collection that is closed for subsets and satisfies the finite character property. The finite character property states that a set belongs to the family if and only if each of its finite subsets belongs to the family. With the model existence theorem in hands, the compactness theorem is obtained easily: given a set of propositional formulas $S$ such that all its finite subsets are satisfiable, one considers the family $\cal C$ of subsets in $S$ such that all their finite subsets are satisfiable. $S$ belongs to the family $\cal C$ and the latter holds the propositional consistence property.
The auxiliary lemma of Consistence Compactness is required to apply the Model Existence Theorem to obtain the compactness theorem. This lemma states the general fact that the collection $\mathcal{C}$ of all sets of propositional formulas such that all their subsets are satisfiable is a propositional consistency property.
›
lemma UnsatisfiableAtom:
shows "¬ (satisfiable {F, ¬.F})"
proof (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹satisfiable {F, ¬.F} ⟹ False›*)
assume hip: "satisfiable {F, ¬.F}" (*‹satisfiable {F::'a formula, ¬.F}›*)
show False
proof (-)
(*goal: ‹False›*)
have "∃I. I model {F, ¬.F}"
using hip (*‹satisfiable {F, ¬.F}›*) apply (unfold satisfiable_def (*‹satisfiable ?S ≡ ∃v. v model ?S›*))
(*goal: ‹∃I. I model {F, ¬.F}›*)
by auto
then obtain I where I: "(t_v_evaluation I F) = Ttrue" and "(t_v_evaluation I (¬.F)) = Ttrue"
(*goal: ‹(⋀I. ⟦t_v_evaluation I F = Ttrue; t_v_evaluation I (¬.F) = Ttrue⟧ ⟹ thesis) ⟹ thesis›*)
apply (unfold model_def (*‹?I model ?S ≡ ∀F∈?S. t_v_evaluation ?I F = Ttrue›*))
(*goal: ‹(⋀I. ⟦t_v_evaluation I F = Ttrue; t_v_evaluation I (¬.F) = Ttrue⟧ ⟹ thesis) ⟹ thesis›*)
by auto
thus False
by (auto simp add: v_negation_def (*‹v_negation (?x::v_truth) ≡ if ?x = Ttrue then Ffalse else Ttrue›*))
qed
qed
lemma consistenceP_Prop1:
assumes "∀ (A::'b formula set). (A⊆ W ∧ finite A) ⟶ satisfiable A"
shows "(∀P. ¬ (Atom P ∈ W ∧ (¬. Atom P) ∈ W))"
apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹∀P. ¬ (Atom P ∈ W ∧ ¬.Atom P ∈ W)›*)
proof (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹⋀P. Atom P ∈ W ∧ ¬.Atom P ∈ W ⟹ False›*)
fix P
assume h1: "Atom P ∈ W ∧ (¬.Atom P) ∈ W" (*‹(Atom::'a ⇒ 'b formula) (P::'a) ∈ (W::'b formula set) ∧ ¬.Atom P ∈ W›*)
show False
proof (-)
(*goal: ‹False›*)
have "{Atom P, (¬.Atom P)} ⊆ W"
using h1 (*‹Atom P ∈ W ∧ ¬.Atom P ∈ W›*) by simp
moreover have "finite {Atom P, (¬.Atom P)}"
by simp
ultimately have "{Atom P, (¬.Atom P)} ⊆ W ∧ finite {Atom P, (¬.Atom P)}"
by simp
thus False
using UnsatisfiableAtom (*‹¬ satisfiable {?F::?'a formula, ¬.?F}›*) assms (*‹∀A. A ⊆ W ∧ finite A ⟶ satisfiable A›*) by metis
qed
qed
lemma UnsatisfiableFF:
shows "¬ (satisfiable {FF})"
proof (-)
(*goal: ‹¬ satisfiable {FF}›*)
have "∀ I. t_v_evaluation I FF = Ffalse"
by simp
hence "∀ I. ¬ (I model {FF})"
apply (unfold model_def (*‹?I model ?S ≡ ∀F∈?S. t_v_evaluation ?I F = Ttrue›*))
(*goal: ‹∀I. ¬ I model {FF}›*)
by auto
thus "?thesis"
(*goal: ‹¬ satisfiable {FF}›*)
apply (unfold satisfiable_def (*‹satisfiable ?S ≡ ∃v. v model ?S›*))
(*goal: ‹¬ satisfiable {FF}›*)
by auto
qed
lemma consistenceP_Prop2:
assumes "∀ (A::'b formula set). (A⊆ W ∧ finite A) ⟶ satisfiable A"
shows "FF ∉ W"
proof (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹FF ∈ W ⟹ False›*)
assume hip: "FF ∈ W" (*‹FF ∈ (W::'b formula set)›*)
show False
proof (-)
(*goal: ‹False›*)
have "{FF} ⊆ W"
using hip (*‹FF ∈ W›*) by simp
moreover have "finite {FF}"
by simp
ultimately have "{FF} ⊆ W ∧ finite {FF}"
by simp
moreover have "({FF::'b formula} ⊆ W ∧ finite {FF}) ⟶ satisfiable {FF::'b formula}"
using assms (*‹∀A. A ⊆ W ∧ finite A ⟶ satisfiable A›*) by auto
ultimately show False
using UnsatisfiableFF (*‹¬ satisfiable {FF}›*) by auto
qed
qed
lemma UnsatisfiableFFa:
shows "¬ (satisfiable {¬.TT})"
proof (-)
(*goal: ‹¬ satisfiable {¬.TT}›*)
have "∀ I. t_v_evaluation I TT = Ttrue"
by simp
have "∀ I. t_v_evaluation I (¬.TT) = Ffalse"
by (auto simp add:v_negation_def (*‹v_negation ?x ≡ if ?x = Ttrue then Ffalse else Ttrue›*))
hence "∀ I. ¬ (I model {¬.TT})"
apply (unfold model_def (*‹(?I::?'b::type ⇒ v_truth) model (?S::?'b::type formula set) ≡ ∀F::?'b::type formula∈?S. t_v_evaluation ?I F = Ttrue›*))
(*goal: ‹∀I. ¬ I model {¬.TT}›*)
by auto
thus "?thesis"
(*goal: ‹¬ satisfiable {¬.TT}›*)
apply (unfold satisfiable_def (*‹satisfiable (?S::?'b formula set) ≡ ∃v::?'b ⇒ v_truth. v model ?S›*))
(*goal: ‹¬ satisfiable {¬.TT}›*)
by auto
qed
lemma consistenceP_Prop3:
assumes "∀ (A::'b formula set). (A⊆ W ∧ finite A) ⟶ satisfiable A"
shows "¬.TT ∉ W"
proof (rule notI (*‹(?P::bool ⟹ False) ⟹ ¬ ?P›*))
(*goal: ‹¬.TT ∈ W ⟹ False›*)
assume hip: "¬.TT ∈ W" (*‹¬.TT ∈ (W::'b formula set)›*)
show False
proof (-)
(*goal: ‹False›*)
have "{¬.TT} ⊆ W"
using hip (*‹¬.TT ∈ W›*) by simp
moreover have "finite {¬.TT}"
by simp
ultimately have "{¬.TT} ⊆ W ∧ finite {¬.TT}"
by simp
moreover have "({¬.TT::'b formula} ⊆ W ∧ finite {¬.TT}) ⟶
satisfiable {¬.TT::'b formula}"
using assms (*‹∀A. A ⊆ W ∧ finite A ⟶ satisfiable A›*) by auto
thus False
using UnsatisfiableFFa (*‹¬ satisfiable {¬.TT}›*) using ‹{¬.TT} ⊆ W› (*‹{¬.TT} ⊆ W›*) by auto
qed
qed
lemma Subset_Sat:
assumes hip1: "satisfiable S" and hip2: "S'⊆ S"
shows "satisfiable S'"
using assms (*‹satisfiable S› ‹S' ⊆ S›*) satisfiable_subset (*‹⟦satisfiable (?S::?'a::type formula set); (?H::?'a::type formula set) ⊆ ?S⟧ ⟹ satisfiable ?H›*) by blast
text‹ ›
lemma satisfiableUnion1:
assumes "satisfiable (A ∪ {¬.¬.F})"
shows "satisfiable (A ∪ {F})"
proof (-)
(*goal: ‹satisfiable (A ∪ {F})›*)
have "∃I. ∀ G ∈ (A ∪ {¬.¬.F}). t_v_evaluation I G = Ttrue"
using assms (*‹satisfiable (A ∪ {¬.¬.F})›*) apply (unfold satisfiable_def (*‹satisfiable ?S ≡ ∃v. v model ?S›*))
(*goal: ‹∃I. ∀G∈A ∪ {¬.¬.F}. t_v_evaluation I G = Ttrue›*)
apply (unfold model_def (*‹?I model ?S ≡ ∀F∈?S. t_v_evaluation ?I F = Ttrue›*))
(*goal: ‹∃v::'a ⇒ v_truth. v model ((A::'a formula set) ∪ {¬.¬.(F::'a formula)}) ⟹ ∃I::'a ⇒ v_truth. ∀G::'a formula∈A ∪ {¬.¬.F}. t_v_evaluation I G = Ttrue›*)
by auto
then obtain I where I: "∀ G ∈ (A ∪ {¬.¬.F}). t_v_evaluation I G = Ttrue"
(*goal: ‹(⋀I::'a ⇒ v_truth. ∀G::'a formula∈(A::'a formula set) ∪ {¬.¬.(F::'a formula)}. t_v_evaluation I G = Ttrue ⟹ thesis::bool) ⟹ thesis›*)
by auto
hence 1: "∀ G ∈ A. t_v_evaluation I G = Ttrue" and 2: "t_v_evaluation I (¬.¬.F) = Ttrue"
apply -
(*goals:
1. ‹∀G∈A ∪ {¬.¬.F}. t_v_evaluation I G = Ttrue ⟹ ∀G∈A. t_v_evaluation I G = Ttrue›
2. ‹∀G∈A ∪ {¬.¬.F}. t_v_evaluation I G = Ttrue ⟹ t_v_evaluation I (¬.¬.F) = Ttrue›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
have "typeFormula (¬.¬.F) = NoNo"
by auto
hence "t_v_evaluation I F = Ttrue"
using EquivNoNoComp[of "¬.¬.F"] (*‹typeFormula (¬.¬.F) = NoNo ⟹ equivalent (¬.¬.F) (Comp1 (¬.¬.F))›*) "2" (*‹t_v_evaluation I (¬.¬.F) = Ttrue›*) apply (unfold equivalent_def (*‹equivalent (?F::?'b formula) (?G::?'b formula) ≡ ∀I::?'b ⇒ v_truth. t_v_evaluation I ?F = t_v_evaluation I ?G›*))
(*goal: ‹t_v_evaluation I F = Ttrue›*)
apply (unfold Comp1_def (*‹Comp1 ?F = hd (componentes ?F)›*))
(*goal: ‹⟦typeFormula (¬.¬.F) = NoNo; typeFormula (¬.¬.F) = NoNo ⟹ ∀I. t_v_evaluation I (¬.¬.F) = t_v_evaluation I (Comp1 (¬.¬.F)); t_v_evaluation I (¬.¬.F) = Ttrue⟧ ⟹ t_v_evaluation I F = Ttrue›*)
by auto
hence "∀ G ∈ A ∪ {F}. t_v_evaluation I G = Ttrue"
using "1" (*‹∀G∈A. t_v_evaluation I G = Ttrue›*) by auto
thus "satisfiable (A ∪ {F})"
apply (unfold satisfiable_def (*‹satisfiable ?S ≡ ∃v. v model ?S›*))
(*goal: ‹satisfiable (A ∪ {F})›*)
apply (unfold model_def (*‹?I model ?S ≡ ∀F∈?S. t_v_evaluation ?I F = Ttrue›*))
(*goal: ‹∀G∈A ∪ {F}. t_v_evaluation I G = Ttrue ⟹ ∃v. v model (A ∪ {F})›*)
by auto
qed
lemma consistenceP_Prop4:
assumes hip1: "∀ (A::'b formula set). (A⊆ W ∧ finite A) ⟶ satisfiable A"
and hip2: "¬.¬.F ∈ W"
shows "∀ (A::'b formula set). (A⊆ W ∪ {F} ∧ finite A) ⟶ satisfiable A"
apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*))
(*goal: ‹∀A. A ⊆ W ∪ {F} ∧ finite A ⟶ satisfiable A›*)
proof (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀A. A ⊆ W ∪ {F} ∧ finite A ⟹ satisfiable A›*)
fix A
assume hip: "A ⊆ W ∪ {F} ∧ finite A" (*‹(A::'b formula set) ⊆ (W::'b formula set) ∪ {F::'b formula} ∧ finite A›*)
show "satisfiable A"
proof (-)
(*goal: ‹satisfiable (A::'b formula set)›*)
have "A-{F} ⊆ W ∧ finite (A-{F})"
using hip (*‹A ⊆ W ∪ {F} ∧ finite A›*) by auto
hence "(A-{F}) ∪ {¬.¬.F} ⊆ W ∧ finite ((A-{F}) ∪ {¬.¬.F})"
using hip2 (*‹¬.¬.F ∈ W›*) by auto
hence "satisfiable ((A-{F}) ∪ {¬.¬.F})"
using hip1 (*‹∀A. A ⊆ W ∧ finite A ⟶ satisfiable A›*) by auto
hence "satisfiable ((A-{F}) ∪ {F})"
using satisfiableUnion1 (*‹satisfiable (?A ∪ {¬.¬.?F}) ⟹ satisfiable (?A ∪ {?F})›*) by blast
moreover have "A⊆ (A-{F}) ∪ {F}"
by auto
ultimately show "satisfiable A"
using Subset_Sat (*‹⟦satisfiable ?S; ?S' ⊆ ?S⟧ ⟹ satisfiable ?S'›*) by auto
qed
qed
lemma satisfiableUnion2:
assumes hip1: "FormulaAlfa F" and hip2: "satisfiable (A ∪ {F})"
shows "satisfiable (A ∪ {Comp1 F,Comp2 F})"
proof (-)
(*goal: ‹satisfiable (A ∪ {Comp1 F, Comp2 F})›*)
have "∃I.∀ G ∈ A ∪ {F}. t_v_evaluation I G = Ttrue"
using hip2 (*‹satisfiable (A ∪ {F})›*) apply (unfold satisfiable_def (*‹satisfiable ?S ≡ ∃v. v model ?S›*))
(*goal: ‹∃I. ∀G∈A ∪ {F}. t_v_evaluation I G = Ttrue›*)
apply (unfold model_def (*‹?I model ?S ≡ ∀F∈?S. t_v_evaluation ?I F = Ttrue›*))
(*goal: ‹∃v. v model (A ∪ {F}) ⟹ ∃I. ∀G∈A ∪ {F}. t_v_evaluation I G = Ttrue›*)
by auto
then obtain I where I: "∀ G ∈ A ∪ {F}. t_v_evaluation I G = Ttrue"
(*goal: ‹(⋀I::'a ⇒ v_truth. ∀G::'a formula∈(A::'a formula set) ∪ {F::'a formula}. t_v_evaluation I G = Ttrue ⟹ thesis::bool) ⟹ thesis›*)
by auto
hence 1: "∀ G ∈ A. t_v_evaluation I G = Ttrue" and 2: "t_v_evaluation I F = Ttrue"
apply -
(*goals:
1. ‹∀G∈A ∪ {F}. t_v_evaluation I G = Ttrue ⟹ ∀G∈A. t_v_evaluation I G = Ttrue›
2. ‹∀G∈A ∪ {F}. t_v_evaluation I G = Ttrue ⟹ t_v_evaluation I F = Ttrue›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
have "typeFormula F = Alfa"
using hip1 (*‹FormulaAlfa F›*) noAlfaBeta (*‹FormulaAlfa ?formula ⟹ ¬ FormulaBeta ?formula›*) noAlfaNoNo (*‹FormulaAlfa ?formula ⟹ ¬ FormulaNoNo ?formula›*) by auto
hence "equivalent F (Comp1 F ∧. Comp2 F)"
using "2" (*‹t_v_evaluation (I::'a ⇒ v_truth) (F::'a formula) = Ttrue›*) EquivAlfaComp[of F] (*‹typeFormula F = Alfa ⟹ equivalent F (Comp1 F ∧. Comp2 F)›*) by auto
hence "t_v_evaluation I (Comp1 F ∧. Comp2 F) = Ttrue"
using "2" (*‹t_v_evaluation I F = Ttrue›*) apply (unfold equivalent_def (*‹equivalent ?F ?G ≡ ∀I. t_v_evaluation I ?F = t_v_evaluation I ?G›*))
(*goal: ‹t_v_evaluation I (Comp1 F ∧. Comp2 F) = Ttrue›*)
by auto
hence "t_v_evaluation I (Comp1 F) = Ttrue ∧ t_v_evaluation I (Comp2 F) = Ttrue"
using ConjunctionValues (*‹t_v_evaluation ?I (?F ∧. ?G) = Ttrue ⟹ t_v_evaluation ?I ?F = Ttrue ∧ t_v_evaluation ?I ?G = Ttrue›*) by auto
hence "∀ G ∈ A ∪ {Comp1 F, Comp2 F} . t_v_evaluation I G = Ttrue"
using "1" (*‹∀G∈A. t_v_evaluation I G = Ttrue›*) by auto
thus "satisfiable (A ∪ {Comp1 F,Comp2 F})"
apply (unfold satisfiable_def (*‹satisfiable ?S ≡ ∃v. v model ?S›*))
(*goal: ‹satisfiable (A ∪ {Comp1 F, Comp2 F})›*)
apply (unfold model_def (*‹?I model ?S ≡ ∀F∈?S. t_v_evaluation ?I F = Ttrue›*))
(*goal: ‹∀G∈A ∪ {Comp1 F, Comp2 F}. t_v_evaluation I G = Ttrue ⟹ ∃v. v model (A ∪ {Comp1 F, Comp2 F})›*)
by auto
qed
lemma consistenceP_Prop5:
assumes hip0: "FormulaAlfa F"
and hip1: "∀ (A::'b formula set). (A⊆ W ∧ finite A) ⟶ satisfiable A"
and hip2: "F ∈ W"
shows "∀ (A::'b formula set). (A⊆ W ∪ {Comp1 F, Comp2 F} ∧ finite A) ⟶
satisfiable A"
proof (intro allI (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x) ⟹ ∀x::?'a. ?P x›*) impI (*‹(?P::bool ⟹ ?Q::bool) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀A. A ⊆ W ∪ {Comp1 F, Comp2 F} ∧ finite A ⟹ satisfiable A›*)
fix A
assume hip: "A ⊆ W ∪ {Comp1 F, Comp2 F} ∧ finite A" (*‹(A::'b formula set) ⊆ (W::'b formula set) ∪ {Comp1 (F::'b formula), Comp2 F} ∧ finite A›*)
show "satisfiable A"
proof (-)
(*goal: ‹satisfiable A›*)
have "A-{Comp1 F, Comp2 F} ⊆ W ∧ finite (A-{Comp1 F, Comp2 F})"
using hip (*‹A ⊆ W ∪ {Comp1 F, Comp2 F} ∧ finite A›*) by auto
hence "(A-{Comp1 F, Comp2 F}) ∪ {F} ⊆ W ∧
finite ((A-{Comp1 F, Comp2 F}) ∪ {F})"
using hip2 (*‹F ∈ W›*) by auto
hence "satisfiable ((A-{Comp1 F, Comp2 F}) ∪ {F})"
using hip1 (*‹∀A. A ⊆ W ∧ finite A ⟶ satisfiable A›*) by auto
hence "satisfiable ((A-{Comp1 F, Comp2 F}) ∪ {Comp1 F, Comp2 F})"
using hip0 (*‹FormulaAlfa (F::'b::type formula)›*) satisfiableUnion2 (*‹⟦FormulaAlfa (?F::?'a formula); satisfiable ((?A::?'a formula set) ∪ {?F})⟧ ⟹ satisfiable (?A ∪ {Comp1 ?F, Comp2 ?F})›*) by auto
moreover have "A ⊆ (A-{Comp1 F, Comp2 F}) ∪ {Comp1 F, Comp2 F}"
by auto
ultimately show "satisfiable A"
using Subset_Sat (*‹⟦satisfiable ?S; ?S' ⊆ ?S⟧ ⟹ satisfiable ?S'›*) by auto
qed
qed
lemma satisfiableUnion3:
assumes hip1: "FormulaBeta F" and hip2: "satisfiable (A ∪ {F})"
shows "satisfiable (A ∪ {Comp1 F}) ∨ satisfiable (A ∪ {Comp2 F})"
proof (-)
(*goal: ‹satisfiable ((A::'a formula set) ∪ {Comp1 (F::'a formula)}) ∨ satisfiable (A ∪ {Comp2 F})›*)
obtain I where I: "∀G ∈ (A ∪ {F}). t_v_evaluation I G = Ttrue"
(*goal: ‹(⋀I. ∀G∈A ∪ {F}. t_v_evaluation I G = Ttrue ⟹ thesis) ⟹ thesis›*)
using hip2 (*‹satisfiable (A ∪ {F})›*) apply (unfold satisfiable_def (*‹satisfiable (?S::?'b::type formula set) ≡ ∃v::?'b::type ⇒ v_truth. v model ?S›*))
(*goal: ‹(⋀I. ∀G∈A ∪ {F}. t_v_evaluation I G = Ttrue ⟹ thesis) ⟹ thesis›*)
apply (unfold model_def (*‹?I model ?S ≡ ∀F∈?S. t_v_evaluation ?I F = Ttrue›*))
(*goal: ‹⟦⋀I. ∀G∈A ∪ {F}. t_v_evaluation I G = Ttrue ⟹ thesis; ∃v. v model (A ∪ {F})⟧ ⟹ thesis›*)
by auto
hence S1: "∀G ∈ A. t_v_evaluation I G = Ttrue" and S2: " t_v_evaluation I F = Ttrue"
apply -
(*goals:
1. ‹∀G::'a::type formula∈(A::'a::type formula set) ∪ {F::'a::type formula}. t_v_evaluation (I::'a::type ⇒ v_truth) G = Ttrue ⟹ ∀G::'a::type formula∈A. t_v_evaluation I G = Ttrue›
2. ‹∀G::'a::type formula∈(A::'a::type formula set) ∪ {F::'a::type formula}. t_v_evaluation (I::'a::type ⇒ v_truth) G = Ttrue ⟹ t_v_evaluation I F = Ttrue›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
have V: "t_v_evaluation I (Comp1 F) = Ttrue ∨ t_v_evaluation I (Comp2 F) = Ttrue"
using hip1 (*‹FormulaBeta F›*) S2 (*‹t_v_evaluation (I::'a::type ⇒ v_truth) (F::'a::type formula) = Ttrue›*) EquivBetaComp[of F] (*‹typeFormula F = Beta ⟹ equivalent F (Comp1 F ∨. Comp2 F)›*) DisjunctionValues (*‹t_v_evaluation ?I (?F ∨. ?G) = Ttrue ⟹ t_v_evaluation ?I ?F = Ttrue ∨ t_v_evaluation ?I ?G = Ttrue›*) apply (unfold equivalent_def (*‹equivalent ?F ?G ≡ ∀I. t_v_evaluation I ?F = t_v_evaluation I ?G›*))
(*goal: ‹t_v_evaluation I (Comp1 F) = Ttrue ∨ t_v_evaluation I (Comp2 F) = Ttrue›*)
by auto
have "((∀G ∈ A. t_v_evaluation I G = Ttrue) ∧ t_v_evaluation I (Comp1 F) = Ttrue) ∨
((∀G ∈ A. t_v_evaluation I G = Ttrue) ∧ t_v_evaluation I (Comp2 F) = Ttrue)"
using V (*‹t_v_evaluation I (Comp1 F) = Ttrue ∨ t_v_evaluation I (Comp2 F) = Ttrue›*) proof (rule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goals:
1. ‹t_v_evaluation I (Comp1 F) = Ttrue ⟹ (∀G∈A. t_v_evaluation I G = Ttrue) ∧ t_v_evaluation I (Comp1 F) = Ttrue ∨ (∀G∈A. t_v_evaluation I G = Ttrue) ∧ t_v_evaluation I (Comp2 F) = Ttrue›
2. ‹t_v_evaluation I (Comp2 F) = Ttrue ⟹ (∀G∈A. t_v_evaluation I G = Ttrue) ∧ t_v_evaluation I (Comp1 F) = Ttrue ∨ (∀G∈A. t_v_evaluation I G = Ttrue) ∧ t_v_evaluation I (Comp2 F) = Ttrue›*)
assume "t_v_evaluation I (Comp1 F) = Ttrue" (*‹t_v_evaluation (I::'a ⇒ v_truth) (Comp1 (F::'a formula)) = Ttrue›*)
hence "(∀G ∈ A. t_v_evaluation I G = Ttrue) ∧ t_v_evaluation I (Comp1 F) = Ttrue"
using S1 (*‹∀G∈A. t_v_evaluation I G = Ttrue›*) by auto
thus "?thesis"
(*goal: ‹(∀G::'a formula∈A::'a formula set. t_v_evaluation (I::'a ⇒ v_truth) G = Ttrue) ∧ t_v_evaluation I (Comp1 (F::'a formula)) = Ttrue ∨ (∀G::'a formula∈A. t_v_evaluation I G = Ttrue) ∧ t_v_evaluation I (Comp2 F) = Ttrue›*)
by simp
next
(*goal: ‹t_v_evaluation I (Comp2 F) = Ttrue ⟹ (∀G∈A. t_v_evaluation I G = Ttrue) ∧ t_v_evaluation I (Comp1 F) = Ttrue ∨ (∀G∈A. t_v_evaluation I G = Ttrue) ∧ t_v_evaluation I (Comp2 F) = Ttrue›*)
assume "t_v_evaluation I (Comp2 F) = Ttrue" (*‹t_v_evaluation (I::'a ⇒ v_truth) (Comp2 (F::'a formula)) = Ttrue›*)
hence "(∀G ∈ A. t_v_evaluation I G = Ttrue) ∧ t_v_evaluation I (Comp2 F) = Ttrue"
using S1 (*‹∀G::'a formula∈A::'a formula set. t_v_evaluation (I::'a ⇒ v_truth) G = Ttrue›*) by auto
thus "?thesis"
(*goal: ‹(∀G∈A. t_v_evaluation I G = Ttrue) ∧ t_v_evaluation I (Comp1 F) = Ttrue ∨ (∀G∈A. t_v_evaluation I G = Ttrue) ∧ t_v_evaluation I (Comp2 F) = Ttrue›*)
by simp
qed
hence "(∀G ∈ A ∪ {Comp1 F}. t_v_evaluation I G = Ttrue) ∨
(∀G ∈ A ∪ {Comp2 F}. t_v_evaluation I G = Ttrue)"
by auto
hence "(∃I.∀G ∈ A ∪ {Comp1 F}. t_v_evaluation I G = Ttrue) ∨
(∃I.∀G ∈ A ∪ {Comp2 F}. t_v_evaluation I G = Ttrue)"
by auto
thus "satisfiable (A ∪ {Comp1 F}) ∨ satisfiable (A ∪ {Comp2 F})"
apply (unfold satisfiable_def (*‹satisfiable ?S ≡ ∃v. v model ?S›*))
(*goal: ‹satisfiable (A ∪ {Comp1 F}) ∨ satisfiable (A ∪ {Comp2 F})›*)
apply (unfold model_def (*‹(?I::?'b ⇒ v_truth) model (?S::?'b formula set) ≡ ∀F::?'b formula∈?S. t_v_evaluation ?I F = Ttrue›*))
(*goal: ‹(∃I::'a ⇒ v_truth. ∀G::'a formula∈(A::'a formula set) ∪ {Comp1 (F::'a formula)}. t_v_evaluation I G = Ttrue) ∨ (∃I::'a ⇒ v_truth. ∀G::'a formula∈A ∪ {Comp2 F}. t_v_evaluation I G = Ttrue) ⟹ (∃v::'a ⇒ v_truth. v model (A ∪ {Comp1 F})) ∨ (∃v::'a ⇒ v_truth. v model (A ∪ {Comp2 F}))›*)
by auto
qed
lemma consistenceP_Prop6:
assumes hip0: "FormulaBeta F"
and hip1: "∀ (A::'b formula set). (A⊆ W ∧ finite A) ⟶ satisfiable A"
and hip2: "F ∈ W"
shows "(∀ (A::'b formula set). (A⊆ W ∪ {Comp1 F} ∧ finite A) ⟶
satisfiable A) ∨
(∀ (A::'b formula set). (A⊆ W ∪ {Comp2 F} ∧ finite A) ⟶
satisfiable A)"
proof (-)
(*goal: ‹(∀A. A ⊆ W ∪ {Comp1 F} ∧ finite A ⟶ satisfiable A) ∨ (∀A. A ⊆ W ∪ {Comp2 F} ∧ finite A ⟶ satisfiable A)›*)
{
assume hip3: "¬((∀ (A::'b formula set). (A⊆ W ∪ {Comp1 F} ∧ finite A) ⟶
satisfiable A) ∨
(∀ (A::'b formula set). (A⊆ W ∪ {Comp2 F} ∧ finite A) ⟶
satisfiable A))" (*‹¬ ((∀A::'b formula set. A ⊆ (W::'b formula set) ∪ {Comp1 (F::'b formula)} ∧ finite A ⟶ satisfiable A) ∨ (∀A::'b formula set. A ⊆ W ∪ {Comp2 F} ∧ finite A ⟶ satisfiable A))›*)
have False
proof (-)
(*goal: ‹False›*)
obtain A and B where A1: "A ⊆ W ∪ {Comp1 F}" and A2: "finite A" and A3: " ¬ satisfiable A" and B1: "B ⊆ W ∪ {Comp2 F}" and B2: "finite B" and B3: "¬ satisfiable B"
(*goal: ‹(⋀(A::'b formula set) B::'b formula set. ⟦A ⊆ (W::'b formula set) ∪ {Comp1 (F::'b formula)}; finite A; ¬ satisfiable A; B ⊆ W ∪ {Comp2 F}; finite B; ¬ satisfiable B⟧ ⟹ thesis::bool) ⟹ thesis›*)
using hip3 (*‹¬ ((∀A. A ⊆ W ∪ {Comp1 F} ∧ finite A ⟶ satisfiable A) ∨ (∀A. A ⊆ W ∪ {Comp2 F} ∧ finite A ⟶ satisfiable A))›*) by auto
have a1: "A - {Comp1 F} ⊆ W" and a2: "finite (A - {Comp1 F})"
using A1 (*‹A ⊆ W ∪ {Comp1 F}›*) A2 (*‹finite A›*) apply -
(*goals:
1. ‹⟦A ⊆ W ∪ {Comp1 F}; finite A⟧ ⟹ A - {Comp1 F} ⊆ W›
2. ‹⟦A ⊆ W ∪ {Comp1 F}; finite A⟧ ⟹ finite (A - {Comp1 F})›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
hence "satisfiable (A - {Comp1 F})"
using hip1 (*‹∀A. A ⊆ W ∧ finite A ⟶ satisfiable A›*) by simp
have b1: "B - {Comp2 F} ⊆ W" and b2: "finite (B - {Comp2 F})"
using B1 (*‹(B::'b formula set) ⊆ (W::'b formula set) ∪ {Comp2 (F::'b formula)}›*) B2 (*‹finite B›*) apply -
(*goals:
1. ‹⟦B ⊆ W ∪ {Comp2 F}; finite B⟧ ⟹ B - {Comp2 F} ⊆ W›
2. ‹⟦B ⊆ W ∪ {Comp2 F}; finite B⟧ ⟹ finite (B - {Comp2 F})›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
hence "satisfiable (B - {Comp2 F})"
using hip1 (*‹∀A. A ⊆ W ∧ finite A ⟶ satisfiable A›*) by simp
moreover have "(A - {Comp1 F}) ∪ (B - {Comp2 F}) ∪ {F} ⊆ W" and "finite ((A - {Comp1 F}) ∪ (B - {Comp2 F}) ∪ {F})"
using a1 (*‹A - {Comp1 F} ⊆ W›*) a2 (*‹finite (A - {Comp1 F})›*) b1 (*‹B - {Comp2 F} ⊆ W›*) b2 (*‹finite (B - {Comp2 F})›*) hip2 (*‹F ∈ W›*) apply -
(*goals:
1. ‹⟦A - {Comp1 F} ⊆ W; finite (A - {Comp1 F}); B - {Comp2 F} ⊆ W; finite (B - {Comp2 F}); F ∈ W⟧ ⟹ A - {Comp1 F} ∪ (B - {Comp2 F}) ∪ {F} ⊆ W›
2. ‹⟦A - {Comp1 F} ⊆ W; finite (A - {Comp1 F}); B - {Comp2 F} ⊆ W; finite (B - {Comp2 F}); F ∈ W⟧ ⟹ finite (A - {Comp1 F} ∪ (B - {Comp2 F}) ∪ {F})›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
hence "satisfiable ((A - {Comp1 F}) ∪ (B - {Comp2 F}) ∪ {F})"
using hip1 (*‹∀A. A ⊆ W ∧ finite A ⟶ satisfiable A›*) by simp
hence "satisfiable ((A - {Comp1 F}) ∪ (B - {Comp2 F}) ∪ {Comp1 F})
∨ satisfiable ((A - {Comp1 F}) ∪ (B - {Comp2 F}) ∪ {Comp2 F})"
using hip0 (*‹FormulaBeta (F::'b formula)›*) satisfiableUnion3 (*‹⟦FormulaBeta ?F; satisfiable (?A ∪ {?F})⟧ ⟹ satisfiable (?A ∪ {Comp1 ?F}) ∨ satisfiable (?A ∪ {Comp2 ?F})›*) by auto
moreover have "A ⊆ (A - {Comp1 F}) ∪ (B - {Comp2 F}) ∪ {Comp1 F}" and "B ⊆ (A - {Comp1 F}) ∪ (B - {Comp2 F}) ∪ {Comp2 F}"
(*goals:
1. ‹A ⊆ A - {Comp1 F} ∪ (B - {Comp2 F}) ∪ {Comp1 F}›
2. ‹B ⊆ A - {Comp1 F} ∪ (B - {Comp2 F}) ∪ {Comp2 F}›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
ultimately have "satisfiable A ∨ satisfiable B"
using Subset_Sat (*‹⟦satisfiable ?S; ?S' ⊆ ?S⟧ ⟹ satisfiable ?S'›*) by auto
thus False
using A3 (*‹¬ satisfiable (A::'b::type formula set)›*) B3 (*‹¬ satisfiable (B::'b::type formula set)›*) by simp
qed
}
thus "?thesis"
(*goal: ‹(∀A. A ⊆ W ∪ {Comp1 F} ∧ finite A ⟶ satisfiable A) ∨ (∀A. A ⊆ W ∪ {Comp2 F} ∧ finite A ⟶ satisfiable A)›*)
by auto
qed
lemma ConsistenceCompactness:
shows "consistenceP{W::'b formula set. ∀A. (A⊆ W ∧ finite A) ⟶
satisfiable A}"
apply (unfold consistenceP_def (*‹consistenceP (?𝒞::?'b formula set set) = (∀S::?'b formula set. S ∈ ?𝒞 ⟶ (∀P::?'b. ¬ (atom P ∈ S ∧ ¬.atom P ∈ S)) ∧ FF ∉ S ∧ ¬.TT ∉ S ∧ (∀F::?'b formula. ¬.¬.F ∈ S ⟶ S ∪ {F} ∈ ?𝒞) ∧ (∀F::?'b formula. FormulaAlfa F ∧ F ∈ S ⟶ S ∪ {Comp1 F, Comp2 F} ∈ ?𝒞) ∧ (∀F::?'b formula. FormulaBeta F ∧ F ∈ S ⟶ S ∪ {Comp1 F} ∈ ?𝒞 ∨ S ∪ {Comp2 F} ∈ ?𝒞))›*))
(*goal: ‹consistenceP {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A}›*)
apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*))
(*goal: ‹∀S::'b formula set. S ∈ {W::'b formula set. ∀A::'b formula set. A ⊆ W ∧ finite A ⟶ satisfiable A} ⟶ (∀P::'b. ¬ (atom P ∈ S ∧ ¬.atom P ∈ S)) ∧ FF ∉ S ∧ ¬.TT ∉ S ∧ (∀F::'b formula. ¬.¬.F ∈ S ⟶ S ∪ {F} ∈ {W::'b formula set. ∀A::'b formula set. A ⊆ W ∧ finite A ⟶ satisfiable A}) ∧ (∀F::'b formula. FormulaAlfa F ∧ F ∈ S ⟶ S ∪ {Comp1 F, Comp2 F} ∈ {W::'b formula set. ∀A::'b formula set. A ⊆ W ∧ finite A ⟶ satisfiable A}) ∧ (∀F::'b formula. FormulaBeta F ∧ F ∈ S ⟶ S ∪ {Comp1 F} ∈ {W::'b formula set. ∀A::'b formula set. A ⊆ W ∧ finite A ⟶ satisfiable A} ∨ S ∪ {Comp2 F} ∈ {W::'b formula set. ∀A::'b formula set. A ⊆ W ∧ finite A ⟶ satisfiable A})›*)
proof (rule impI (*‹(?P::bool ⟹ ?Q::bool) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀S. S ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A} ⟹ (∀P. ¬ (atom P ∈ S ∧ ¬.atom P ∈ S)) ∧ FF ∉ S ∧ ¬.TT ∉ S ∧ (∀F. ¬.¬.F ∈ S ⟶ S ∪ {F} ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A}) ∧ (∀F. FormulaAlfa F ∧ F ∈ S ⟶ S ∪ {Comp1 F, Comp2 F} ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A}) ∧ (∀F. FormulaBeta F ∧ F ∈ S ⟶ S ∪ {Comp1 F} ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A} ∨ S ∪ {Comp2 F} ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A})›*)
let ?C = "{W::'b formula set. ∀A. (A⊆ W ∧ finite A) ⟶ satisfiable A}"
fix W :: " 'b formula set"
assume "W ∈ ?C" (*‹(W::'b formula set) ∈ {W::'b formula set. ∀A::'b formula set. A ⊆ W ∧ finite A ⟶ satisfiable A}›*)
hence hip: "∀A. (A⊆ W ∧ finite A) ⟶ satisfiable A"
by simp
show "(∀P. ¬ (atom P ∈ W ∧ (¬.atom P ) ∈ W)) ∧
FF ∉ W ∧
¬.TT ∉ W ∧
(∀F. ¬.¬.F ∈ W ⟶ W ∪ {F} ∈ ?C) ∧
(∀F. (FormulaAlfa F) ∧ F ∈ W ⟶
(W ∪ {Comp1 F, Comp2 F} ∈ ?C)) ∧
(∀F. (FormulaBeta F) ∧ F ∈ W ⟶
(W ∪ {Comp1 F} ∈ ?C ∨ W ∪ {Comp2 F} ∈ ?C))"
proof (-)
(*goal: ‹(∀P::'b. ¬ (atom P ∈ (W::'b formula set) ∧ ¬.atom P ∈ W)) ∧ FF ∉ W ∧ ¬.TT ∉ W ∧ (∀F::'b formula. ¬.¬.F ∈ W ⟶ W ∪ {F} ∈ {W::'b formula set. ∀A::'b formula set. A ⊆ W ∧ finite A ⟶ satisfiable A}) ∧ (∀F::'b formula. FormulaAlfa F ∧ F ∈ W ⟶ W ∪ {Comp1 F, Comp2 F} ∈ {W::'b formula set. ∀A::'b formula set. A ⊆ W ∧ finite A ⟶ satisfiable A}) ∧ (∀F::'b formula. FormulaBeta F ∧ F ∈ W ⟶ W ∪ {Comp1 F} ∈ {W::'b formula set. ∀A::'b formula set. A ⊆ W ∧ finite A ⟶ satisfiable A} ∨ W ∪ {Comp2 F} ∈ {W::'b formula set. ∀A::'b formula set. A ⊆ W ∧ finite A ⟶ satisfiable A})›*)
have "(∀P. ¬ (atom P ∈ W ∧ (¬. atom P) ∈ W))"
using hip (*‹∀A. A ⊆ W ∧ finite A ⟶ satisfiable A›*) consistenceP_Prop1 (*‹∀A. A ⊆ ?W ∧ finite A ⟶ satisfiable A ⟹ ∀P. ¬ (?Atom P ∈ ?W ∧ ¬.?Atom P ∈ ?W)›*) by simp
moreover have "FF ∉ W"
using hip (*‹∀A::'b formula set. A ⊆ (W::'b formula set) ∧ finite A ⟶ satisfiable A›*) consistenceP_Prop2 (*‹∀A::?'b formula set. A ⊆ (?W::?'b formula set) ∧ finite A ⟶ satisfiable A ⟹ FF ∉ ?W›*) by auto
moreover have "¬. TT ∉ W"
using hip (*‹∀A. A ⊆ W ∧ finite A ⟶ satisfiable A›*) consistenceP_Prop3 (*‹∀A. A ⊆ ?W ∧ finite A ⟶ satisfiable A ⟹ ¬.TT ∉ ?W›*) by auto
moreover have "∀F. (¬.¬.F) ∈ W ⟶ W ∪ {F} ∈ ?C"
apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹∀F. ¬.¬.F ∈ W ⟶ W ∪ {F} ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A}›*)
proof (rule allI (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x) ⟹ ∀x::?'a. ?P x›*) impI (*‹(?P::bool ⟹ ?Q::bool) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀F. ¬.¬.F ∈ W ⟹ W ∪ {F} ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A}›*)
fix F
assume hip1: "¬.¬.F ∈ W" (*‹¬.¬.(F::'b formula) ∈ (W::'b formula set)›*)
show "W ∪ {F} ∈ ?C"
using hip (*‹∀A. A ⊆ W ∧ finite A ⟶ satisfiable A›*) hip1 (*‹¬.¬.F ∈ W›*) consistenceP_Prop4 (*‹⟦∀A. A ⊆ ?W ∧ finite A ⟶ satisfiable A; ¬.¬.?F ∈ ?W⟧ ⟹ ∀A. A ⊆ ?W ∪ {?F} ∧ finite A ⟶ satisfiable A›*) by simp
qed
moreover have "∀F. (FormulaAlfa F) ∧ F ∈ W ⟶ (W ∪ {Comp1 F, Comp2 F} ∈ ?C)"
apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹∀F::'b formula. FormulaAlfa F ∧ F ∈ (W::'b formula set) ⟶ W ∪ {Comp1 F, Comp2 F} ∈ {W::'b formula set. ∀A::'b formula set. A ⊆ W ∧ finite A ⟶ satisfiable A}›*)
proof (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀F. FormulaAlfa F ∧ F ∈ W ⟹ W ∪ {Comp1 F, Comp2 F} ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A}›*)
fix F
assume "FormulaAlfa F ∧ F ∈ W" (*‹FormulaAlfa (F::'b formula) ∧ F ∈ (W::'b formula set)›*)
thus "W ∪ {Comp1 F, Comp2 F} ∈ ?C"
using hip (*‹∀A. A ⊆ W ∧ finite A ⟶ satisfiable A›*) consistenceP_Prop5[of F] (*‹⟦FormulaAlfa (F::'b::type formula); ∀A::'b::type formula set. A ⊆ (?W::'b::type formula set) ∧ finite A ⟶ satisfiable A; F ∈ ?W⟧ ⟹ ∀A::'b::type formula set. A ⊆ ?W ∪ {Comp1 F, Comp2 F} ∧ finite A ⟶ satisfiable A›*) by blast
qed
moreover have "∀F. (FormulaBeta F) ∧ F ∈ W ⟶
(W ∪ {Comp1 F} ∈ ?C ∨ W ∪ {Comp2 F} ∈ ?C)"
apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹∀F::'b::type formula. FormulaBeta F ∧ F ∈ (W::'b::type formula set) ⟶ W ∪ {Comp1 F} ∈ {W::'b::type formula set. ∀A::'b::type formula set. A ⊆ W ∧ finite A ⟶ satisfiable A} ∨ W ∪ {Comp2 F} ∈ {W::'b::type formula set. ∀A::'b::type formula set. A ⊆ W ∧ finite A ⟶ satisfiable A}›*)
proof (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀F. FormulaBeta F ∧ F ∈ W ⟹ W ∪ {Comp1 F} ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A} ∨ W ∪ {Comp2 F} ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A}›*)
fix F
assume "(FormulaBeta F) ∧ F ∈ W" (*‹FormulaBeta (F::'b formula) ∧ F ∈ (W::'b formula set)›*)
thus "W ∪ {Comp1 F} ∈ ?C ∨ W ∪ {Comp2 F} ∈ ?C"
using hip (*‹∀A. A ⊆ W ∧ finite A ⟶ satisfiable A›*) consistenceP_Prop6[of F] (*‹⟦FormulaBeta F; ∀A. A ⊆ ?W ∧ finite A ⟶ satisfiable A; F ∈ ?W⟧ ⟹ (∀A. A ⊆ ?W ∪ {Comp1 F} ∧ finite A ⟶ satisfiable A) ∨ (∀A. A ⊆ ?W ∪ {Comp2 F} ∧ finite A ⟶ satisfiable A)›*) by blast
qed
ultimately show "?thesis"
(*goal: ‹(∀P. ¬ (atom P ∈ W ∧ ¬.atom P ∈ W)) ∧ FF ∉ W ∧ ¬.TT ∉ W ∧ (∀F. ¬.¬.F ∈ W ⟶ W ∪ {F} ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A}) ∧ (∀F. FormulaAlfa F ∧ F ∈ W ⟶ W ∪ {Comp1 F, Comp2 F} ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A}) ∧ (∀F. FormulaBeta F ∧ F ∈ W ⟶ W ∪ {Comp1 F} ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A} ∨ W ∪ {Comp2 F} ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A})›*)
by auto
qed
qed
lemma countable_enumeration_formula:
shows "∃f. enumeration (f:: nat ⇒'a::countable formula)"
by (metis(full_types) EnumerationFormulasP1 (*‹enumeration ?g ⟹ enumeration (ΔP ?g)›*) enumeration_def (*‹enumeration ?f = (∀y. ∃n. y = ?f n)›*) surj_def (*‹surj ?f = (∀y. ∃x. y = ?f x)›*) surj_from_nat (*‹surj from_nat›*))
theorem Compactness_Theorem:
assumes "∀A. (A ⊆ (S:: 'a::countable formula set) ∧ finite A) ⟶ satisfiable A"
shows "satisfiable S"
proof (-)
(*goal: ‹satisfiable S›*)
have enum: "∃g. enumeration (g:: nat ⇒ 'a formula)"
using countable_enumeration_formula (*‹∃f::nat ⇒ ?'a formula. enumeration f›*) by auto
let ?C = "{W:: 'a formula set. ∀A. (A ⊆ W ∧ finite A) ⟶ satisfiable A}"
have "consistenceP ?C"
using ConsistenceCompactness (*‹consistenceP {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A}›*) by simp
moreover have "S ∈ ?C"
using assms (*‹∀A. A ⊆ S ∧ finite A ⟶ satisfiable A›*) by simp
ultimately show "satisfiable S"
using enum (*‹∃g. enumeration g›*) Theo_ExistenceModels[of ?C S] (*‹⟦∃g. enumeration g; consistenceP {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A}; S ∈ {W. ∀A. A ⊆ W ∧ finite A ⟶ satisfiable A}⟧ ⟹ satisfiable S›*) by auto
qed
end
| {
"path": "afp-2025-02-12/thys/Prop_Compactness/PropCompactness.thy",
"repo": "afp-2025-02-12",
"sha": "f81d2369d200bd5c0e01105a931535aca3b923b3b37b906708baf2043a7da11c"
} |
(* Title: Quality_Increases.thy
License: BSD 2-Clause. See LICENSE.
Author: Timothy Bourke, Inria
*)
section "The quality increases predicate"
theory Quality_Increases
imports Aodv_Predicates Fresher
begin
definition quality_increases :: "state ⇒ state ⇒ bool"
where "quality_increases ξ ξ' ≡ (∀dip∈kD(rt ξ). dip ∈ kD(rt ξ') ∧ rt ξ ⊑⇘dip⇙ rt ξ')
∧ (∀dip. sqn (rt ξ) dip ≤ sqn (rt ξ') dip)"
lemma quality_increasesI [intro!]:
assumes "⋀dip. dip ∈ kD(rt ξ) ⟹ dip ∈ kD(rt ξ')"
and "⋀dip. ⟦ dip ∈ kD(rt ξ); dip ∈ kD(rt ξ') ⟧ ⟹ rt ξ ⊑⇘dip⇙ rt ξ'"
and "⋀dip. sqn (rt ξ) dip ≤ sqn (rt ξ') dip"
shows "quality_increases ξ ξ'"
unfolding quality_increases_def
(*goal: ‹(∀dip∈kD (rt ξ). dip ∈ kD (rt ξ') ∧ rt ξ ⊑⇘dip⇙ rt ξ') ∧ (∀dip. sqn (rt ξ) dip ≤ sqn (rt ξ') dip)›*)
using assms (*‹?dip ∈ kD (rt ξ) ⟹ ?dip ∈ kD (rt ξ')› ‹⟦?dip ∈ kD (rt ξ); ?dip ∈ kD (rt ξ')⟧ ⟹ rt ξ ⊑⇘?dip⇙ rt ξ'› ‹sqn (rt (ξ::state)) (?dip::nat) ≤ sqn (rt (ξ'::state)) ?dip›*) by clarsimp
lemma quality_increasesE [elim]:
fixes dip
assumes "quality_increases ξ ξ'"
and "dip∈kD(rt ξ)"
and "⟦ dip ∈ kD(rt ξ'); rt ξ ⊑⇘dip⇙ rt ξ'; sqn (rt ξ) dip ≤ sqn (rt ξ') dip ⟧ ⟹ R dip ξ ξ'"
shows "R dip ξ ξ'"
using assms (*‹quality_increases ξ ξ'› ‹dip ∈ kD (rt ξ)› ‹⟦dip ∈ kD (rt ξ'); rt ξ ⊑⇘dip⇙ rt ξ'; sqn (rt ξ) dip ≤ sqn (rt ξ') dip⟧ ⟹ R dip ξ ξ'›*) unfolding quality_increases_def
(*goal: ‹R dip ξ ξ'›*)
by clarsimp
lemma quality_increases_rt_fresherD [dest]:
fixes ip
assumes "quality_increases ξ ξ'"
and "ip∈kD(rt ξ)"
shows "rt ξ ⊑⇘ip⇙ rt ξ'"
using assms (*‹quality_increases ξ ξ'› ‹(ip::nat) ∈ kD (rt (ξ::state))›*) by auto
lemma quality_increases_sqnE [elim]:
fixes dip
assumes "quality_increases ξ ξ'"
and "sqn (rt ξ) dip ≤ sqn (rt ξ') dip ⟹ R dip ξ ξ'"
shows "R dip ξ ξ'"
using assms (*‹quality_increases ξ ξ'› ‹sqn (rt (ξ::state)) (dip::nat) ≤ sqn (rt (ξ'::state)) dip ⟹ (R::nat ⇒ state ⇒ state ⇒ bool) dip ξ ξ'›*) unfolding quality_increases_def
(*goal: ‹R dip ξ ξ'›*)
by clarsimp
lemma quality_increases_refl [intro, simp]: "quality_increases ξ ξ"
apply rule
(*goals:
1. ‹⋀dip. dip ∈ kD (rt ξ) ⟹ dip ∈ kD (rt ξ)›
2. ‹⋀dip. ⟦dip ∈ kD (rt ξ); dip ∈ kD (rt ξ)⟧ ⟹ rt ξ ⊑⇘dip⇙ rt ξ›
3. ‹⋀dip. sqn (rt ξ) dip ≤ sqn (rt ξ) dip›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*) .
lemma strictly_fresher_quality_increases_right [elim]:
fixes σ σ' dip
assumes "rt (σ i) ⊏⇘dip⇙ rt (σ nhip)"
and qinc: "quality_increases (σ nhip) (σ' nhip)"
and "dip∈kD(rt (σ nhip))"
shows "rt (σ i) ⊏⇘dip⇙ rt (σ' nhip)"
proof (-)
(*goal: ‹rt (σ i) ⊏⇘dip⇙ rt (σ' nhip)›*)
from qinc (*‹quality_increases (σ nhip) (σ' nhip)›*) have "rt (σ nhip) ⊑⇘dip⇙ rt (σ' nhip)"
using ‹dip∈kD(rt (σ nhip))› (*‹(dip::nat) ∈ kD (rt ((σ::'a ⇒ state) (nhip::'a)))›*) by auto
with ‹rt (σ i) ⊏⇘dip⇙ rt (σ nhip)› (*‹rt (σ i) ⊏⇘dip⇙ rt (σ nhip)›*) show "?thesis"
(*goal: ‹rt ((σ::'a ⇒ state) (i::'a)) ⊏⇘(dip::nat)⇙ rt ((σ'::'a ⇒ state) (nhip::'a))›*)
by standard
qed
lemma kD_quality_increases [elim]:
assumes "i∈kD(rt ξ)"
and "quality_increases ξ ξ'"
shows "i∈kD(rt ξ')"
using assms (*‹(i::nat) ∈ kD (rt (ξ::state))› ‹quality_increases ξ ξ'›*) by auto
lemma kD_nsqn_quality_increases [elim]:
assumes "i∈kD(rt ξ)"
and "quality_increases ξ ξ'"
shows "i∈kD(rt ξ') ∧ nsqn (rt ξ) i ≤ nsqn (rt ξ') i"
proof (-)
(*goal: ‹i ∈ kD (rt ξ') ∧ nsqn (rt ξ) i ≤ nsqn (rt ξ') i›*)
from assms (*‹i ∈ kD (rt ξ)› ‹quality_increases ξ ξ'›*) have "i∈kD(rt ξ')"
by standard
moreover with assms (*‹i ∈ kD (rt ξ)› ‹quality_increases ξ ξ'›*) have "rt ξ ⊑⇘i⇙ rt ξ'"
by auto
ultimately have "nsqn (rt ξ) i ≤ nsqn (rt ξ') i"
using ‹i∈kD(rt ξ)› (*‹(i::nat) ∈ kD (rt (ξ::state))›*) apply -
(*goal: ‹nsqn (rt ξ) i ≤ nsqn (rt ξ') i›*)
by (erule(2) rt_fresher_imp_nsqn_le (*‹⟦(?rt1.0::nat ⇒ (nat × k × f × nat × nat × nat set) option) ⊑⇘(?ip::nat)⇙ (?rt2.0::nat ⇒ (nat × k × f × nat × nat × nat set) option); ?ip ∈ kD ?rt1.0; ?ip ∈ kD ?rt2.0⟧ ⟹ nsqn ?rt1.0 ?ip ≤ nsqn ?rt2.0 ?ip›*))
with ‹i∈kD(rt ξ')› (*‹i ∈ kD (rt ξ')›*) show "?thesis"
(*goal: ‹i ∈ kD (rt ξ') ∧ nsqn (rt ξ) i ≤ nsqn (rt ξ') i›*)
by standard
qed
lemma nsqn_quality_increases [elim]:
assumes "i∈kD(rt ξ)"
and "quality_increases ξ ξ'"
shows "nsqn (rt ξ) i ≤ nsqn (rt ξ') i"
using assms (*‹(i::nat) ∈ kD (rt (ξ::state))› ‹quality_increases (ξ::state) (ξ'::state)›*) by (rule kD_nsqn_quality_increases [THEN conjunct2] (*‹⟦?i1 ∈ kD (rt ?ξ1); quality_increases ?ξ1 ?ξ'1⟧ ⟹ nsqn (rt ?ξ1) ?i1 ≤ nsqn (rt ?ξ'1) ?i1›*))
lemma kD_nsqn_quality_increases_trans [elim]:
assumes "i∈kD(rt ξ)"
and "s ≤ nsqn (rt ξ) i"
and "quality_increases ξ ξ'"
shows "i∈kD(rt ξ') ∧ s ≤ nsqn (rt ξ') i"
proof (standard)
(*goals:
1. ‹i ∈ kD (rt ξ')›
2. ‹s ≤ nsqn (rt ξ') i›*)
from ‹i∈kD(rt ξ)› (*‹i ∈ kD (rt ξ)›*) ‹quality_increases ξ ξ'› (*‹quality_increases ξ ξ'›*) show "i∈kD(rt ξ')"
by standard
next
(*goal: ‹s ≤ nsqn (rt ξ') i›*)
from ‹i∈kD(rt ξ)› (*‹i ∈ kD (rt ξ)›*) ‹quality_increases ξ ξ'› (*‹quality_increases ξ ξ'›*) have "nsqn (rt ξ) i ≤ nsqn (rt ξ') i"
by standard
with ‹s ≤ nsqn (rt ξ) i› (*‹s ≤ nsqn (rt ξ) i›*) show "s ≤ nsqn (rt ξ') i"
by (rule le_trans (*‹⟦?i ≤ ?j; ?j ≤ ?k⟧ ⟹ ?i ≤ ?k›*))
qed
lemma nsqn_quality_increases_nsqn_lt_lt [elim]:
assumes "i∈kD(rt ξ)"
and "quality_increases ξ ξ'"
and "s < nsqn (rt ξ) i"
shows "s < nsqn (rt ξ') i"
proof (-)
(*goal: ‹s < nsqn (rt ξ') i›*)
from assms(1-2) (*‹i ∈ kD (rt ξ)› ‹quality_increases ξ ξ'›*) have "nsqn (rt ξ) i ≤ nsqn (rt ξ') i"
by standard
with ‹s < nsqn (rt ξ) i› (*‹s < nsqn (rt ξ) i›*) show "s < nsqn (rt ξ') i"
by simp
qed
lemma nsqn_quality_increases_dhops [elim]:
assumes "i∈kD(rt ξ)"
and "quality_increases ξ ξ'"
and "nsqn (rt ξ) i = nsqn (rt ξ') i"
shows "the (dhops (rt ξ) i) ≥ the (dhops (rt ξ') i)"
using assms (*‹i ∈ kD (rt ξ)› ‹quality_increases ξ ξ'› ‹nsqn (rt ξ) i = nsqn (rt ξ') i›*) unfolding quality_increases_def
(*goal: ‹the (dhops (rt ξ') i) ≤ the (dhops (rt ξ) i)›*)
apply clarsimp
(*goal: ‹the (dhops (rt ξ') i) ≤ the (dhops (rt ξ) i)›*)
apply (drule(1) bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))
(*goal: ‹⟦(i::nat) ∈ kD (rt (ξ::state)); nsqn (rt ξ) i = nsqn (rt (ξ'::state)) i; ∀dip::nat∈kD (rt ξ). dip ∈ kD (rt ξ') ∧ rt ξ ⊑⇘dip⇙ rt ξ'; ∀dip::nat. sqn (rt ξ) dip ≤ sqn (rt ξ') dip⟧ ⟹ the (dhops (rt ξ') i) ≤ the (dhops (rt ξ) i)›*)
by (clarsimp simp: rt_fresher_def2 (*‹⟦?dip ∈ kD ?rt1.0; ?dip ∈ kD ?rt2.0⟧ ⟹ (?rt1.0 ⊑⇘?dip⇙ ?rt2.0) = (nsqn ?rt1.0 ?dip < nsqn ?rt2.0 ?dip ∨ nsqn ?rt1.0 ?dip = nsqn ?rt2.0 ?dip ∧ the (dhops ?rt2.0 ?dip) ≤ the (dhops ?rt1.0 ?dip))›*))
lemma nsqn_quality_increases_nsqn_eq_le [elim]:
assumes "i∈kD(rt ξ)"
and "quality_increases ξ ξ'"
and "s = nsqn (rt ξ) i"
shows "s < nsqn (rt ξ') i ∨ (s = nsqn (rt ξ') i ∧ the (dhops (rt ξ) i) ≥ the (dhops (rt ξ') i))"
using assms (*‹i ∈ kD (rt ξ)› ‹quality_increases ξ ξ'› ‹s = nsqn (rt ξ) i›*) by (metis nat_less_le (*‹(?m < ?n) = (?m ≤ ?n ∧ ?m ≠ ?n)›*) nsqn_quality_increases (*‹⟦?i ∈ kD (rt ?ξ); quality_increases ?ξ ?ξ'⟧ ⟹ nsqn (rt ?ξ) ?i ≤ nsqn (rt ?ξ') ?i›*) nsqn_quality_increases_dhops (*‹⟦?i ∈ kD (rt ?ξ); quality_increases ?ξ ?ξ'; nsqn (rt ?ξ) ?i = nsqn (rt ?ξ') ?i⟧ ⟹ the (dhops (rt ?ξ') ?i) ≤ the (dhops (rt ?ξ) ?i)›*))
lemma quality_increases_rreq_rrep_props [elim]:
fixes sn ip hops sip
assumes qinc: "quality_increases (σ sip) (σ' sip)"
and "1 ≤ sn"
and *: "ip∈kD(rt (σ sip)) ∧ sn ≤ nsqn (rt (σ sip)) ip
∧ (nsqn (rt (σ sip)) ip = sn
⟶ (the (dhops (rt (σ sip)) ip) ≤ hops
∨ the (flag (rt (σ sip)) ip) = inv))"
shows "ip∈kD(rt (σ' sip)) ∧ sn ≤ nsqn (rt (σ' sip)) ip
∧ (nsqn (rt (σ' sip)) ip = sn
⟶ (the (dhops (rt (σ' sip)) ip) ≤ hops
∨ the (flag (rt (σ' sip)) ip) = inv))"
(is "_ ∧ ?nsqnafter")
proof (-)
(*goal: ‹ip ∈ kD (rt (σ' sip)) ∧ sn ≤ nsqn (rt (σ' sip)) ip ∧ (nsqn (rt (σ' sip)) ip = sn ⟶ the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
from "*" (*‹ip ∈ kD (rt (σ sip)) ∧ sn ≤ nsqn (rt (σ sip)) ip ∧ (nsqn (rt (σ sip)) ip = sn ⟶ the (dhops (rt (σ sip)) ip) ≤ hops ∨ the (flag (rt (σ sip)) ip) = Aodv_Basic.inv)›*) obtain "ip∈kD(rt (σ sip))" and "sn ≤ nsqn (rt (σ sip)) ip"
(*goal: ‹(⟦ip ∈ kD (rt (σ sip)); sn ≤ nsqn (rt (σ sip)) ip⟧ ⟹ thesis) ⟹ thesis›*)
by auto
from ‹quality_increases (σ sip) (σ' sip)› (*‹quality_increases (σ sip) (σ' sip)›*) have "sqn (rt (σ sip)) ip ≤ sqn (rt (σ' sip)) ip"
apply -
(*goal: ‹sqn (rt (σ sip)) ip ≤ sqn (rt (σ' sip)) ip›*)
apply standard
(*goals:
1. ‹quality_increases (σ sip) (σ' sip) ⟹ sqn (rt (σ sip)) ip ≤ sqn (rt (σ' sip)) ip›
2. ‹quality_increases (σ sip) (σ' sip) ⟹ sqn (rt (σ sip)) ip ≤ sqn (rt (σ' sip)) ip›
discuss goal 1*)
apply ((msorry)[1])
(*discuss goal 2*)
apply ((msorry)[1])
(*proven 2 subgoals*) .
from ‹quality_increases (σ sip) (σ' sip)› (*‹quality_increases (σ sip) (σ' sip)›*) ‹ip∈kD (rt (σ sip))› (*‹ip ∈ kD (rt (σ sip))›*) have "ip∈kD (rt (σ' sip))"
apply -
(*goal: ‹ip ∈ kD (rt (σ' sip))›*)
apply standard
(*goals:
1. ‹⟦quality_increases (σ sip) (σ' sip); ip ∈ kD (rt (σ sip))⟧ ⟹ ip ∈ kD (rt (σ' sip))›
2. ‹⟦quality_increases (σ sip) (σ' sip); ip ∈ kD (rt (σ sip))⟧ ⟹ ip ∈ kD (rt (σ' sip))›
discuss goal 1*)
apply ((msorry)[1])
(*discuss goal 2*)
apply ((msorry)[1])
(*proven 2 subgoals*) .
from ‹sn ≤ nsqn (rt (σ sip)) ip› (*‹(sn::nat) ≤ nsqn (rt ((σ::'a ⇒ state) (sip::'a))) (ip::nat)›*) have "?nsqnafter"
proof (standard)
(*goals:
1. ‹sn = nsqn (rt (σ sip)) ip ⟹ sn ≤ nsqn (rt (σ' sip)) ip ∧ (nsqn (rt (σ' sip)) ip = sn ⟶ the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›
2. ‹sn < nsqn (rt (σ sip)) ip ⟹ sn ≤ nsqn (rt (σ' sip)) ip ∧ (nsqn (rt (σ' sip)) ip = sn ⟶ the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
assume "sn < nsqn (rt (σ sip)) ip" (*‹(sn::nat) < nsqn (rt ((σ::'a ⇒ state) (sip::'a))) (ip::nat)›*)
also (*calculation: ‹sn < nsqn (rt (σ sip)) ip›*) from ‹ip∈kD(rt (σ sip))› (*‹ip ∈ kD (rt (σ sip))›*) ‹quality_increases (σ sip) (σ' sip)› (*‹quality_increases (σ sip) (σ' sip)›*) have "... ≤ nsqn (rt (σ' sip)) ip"
by standard
finally (*calculation: ‹sn < nsqn (rt (σ' sip)) ip›*) have "sn < nsqn (rt (σ' sip)) ip" .
thus "?thesis"
(*goal: ‹sn ≤ nsqn (rt (σ' sip)) ip ∧ (nsqn (rt (σ' sip)) ip = sn ⟶ the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
by simp
next
(*goal: ‹sn = nsqn (rt (σ sip)) ip ⟹ sn ≤ nsqn (rt (σ' sip)) ip ∧ (nsqn (rt (σ' sip)) ip = sn ⟶ the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
assume "sn = nsqn (rt (σ sip)) ip" (*‹(sn::nat) = nsqn (rt ((σ::'a ⇒ state) (sip::'a))) (ip::nat)›*)
with ‹ip∈kD(rt (σ sip))› (*‹ip ∈ kD (rt (σ sip))›*) ‹quality_increases (σ sip) (σ' sip)› (*‹quality_increases (σ sip) (σ' sip)›*) have "sn < nsqn (rt (σ' sip)) ip
∨ (sn = nsqn (rt (σ' sip)) ip
∧ the (dhops (rt (σ' sip)) ip) ≤ the (dhops (rt (σ sip)) ip))"
by standard
hence "sn < nsqn (rt (σ' sip)) ip
∨ (nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ hops
∨ the (flag (rt (σ' sip)) ip) = inv))"
proof (standard)
(*goals:
1. ‹sn < nsqn (rt (σ' sip)) ip ⟹ sn < nsqn (rt (σ' sip)) ip ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›
2. ‹sn = nsqn (rt (σ' sip)) ip ∧ the (dhops (rt (σ' sip)) ip) ≤ the (dhops (rt (σ sip)) ip) ⟹ sn < nsqn (rt (σ' sip)) ip ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
assume "sn < nsqn (rt (σ' sip)) ip" (*‹(sn::nat) < nsqn (rt ((σ'::'a ⇒ state) (sip::'a))) (ip::nat)›*)
thus "?thesis"
(*goal: ‹sn < nsqn (rt (σ' sip)) ip ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
by standard
next
(*goal: ‹(sn::nat) = nsqn (rt ((σ'::'a ⇒ state) (sip::'a))) (ip::nat) ∧ the (dhops (rt (σ' sip)) ip) ≤ the (dhops (rt ((σ::'a ⇒ state) sip)) ip) ⟹ sn < nsqn (rt (σ' sip)) ip ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ (hops::nat) ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
assume "sn = nsqn (rt (σ' sip)) ip
∧ the (dhops (rt (σ sip)) ip) ≥ the (dhops (rt (σ' sip)) ip)" (*‹(sn::nat) = nsqn (rt ((σ'::'a ⇒ state) (sip::'a))) (ip::nat) ∧ the (dhops (rt (σ' sip)) ip) ≤ the (dhops (rt ((σ::'a ⇒ state) sip)) ip)›*)
hence "sn = nsqn (rt (σ' sip)) ip" and "the (dhops (rt (σ' sip)) ip) ≤ the (dhops (rt (σ sip)) ip)"
apply -
(*goals:
1. ‹sn = nsqn (rt (σ' sip)) ip ∧ the (dhops (rt (σ' sip)) ip) ≤ the (dhops (rt (σ sip)) ip) ⟹ sn = nsqn (rt (σ' sip)) ip›
2. ‹sn = nsqn (rt (σ' sip)) ip ∧ the (dhops (rt (σ' sip)) ip) ≤ the (dhops (rt (σ sip)) ip) ⟹ the (dhops (rt (σ' sip)) ip) ≤ the (dhops (rt (σ sip)) ip)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
from "*" (*‹ip ∈ kD (rt (σ sip)) ∧ sn ≤ nsqn (rt (σ sip)) ip ∧ (nsqn (rt (σ sip)) ip = sn ⟶ the (dhops (rt (σ sip)) ip) ≤ hops ∨ the (flag (rt (σ sip)) ip) = Aodv_Basic.inv)›*) ‹sn = nsqn (rt (σ sip)) ip› (*‹sn = nsqn (rt (σ sip)) ip›*) have "the (dhops (rt (σ sip)) ip) ≤ hops
∨ the (flag (rt (σ sip)) ip) = inv"
by simp
thus "?thesis"
(*goal: ‹(sn::nat) < nsqn (rt ((σ'::'a ⇒ state) (sip::'a))) (ip::nat) ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ (hops::nat) ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
proof (standard)
(*goals:
1. ‹the (dhops (rt (σ sip)) ip) ≤ hops ⟹ sn < nsqn (rt (σ' sip)) ip ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›
2. ‹the (flag (rt (σ sip)) ip) = Aodv_Basic.inv ⟹ sn < nsqn (rt (σ' sip)) ip ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
assume "the (dhops (rt (σ sip)) ip) ≤ hops" (*‹the (dhops (rt ((σ::'a ⇒ state) (sip::'a))) (ip::nat)) ≤ (hops::nat)›*)
with ‹the (dhops (rt (σ' sip)) ip) ≤ the (dhops (rt (σ sip)) ip)› (*‹the (dhops (rt ((σ'::'a ⇒ state) (sip::'a))) (ip::nat)) ≤ the (dhops (rt ((σ::'a ⇒ state) sip)) ip)›*) have "the (dhops (rt (σ' sip)) ip) ≤ hops"
by simp
with ‹sn = nsqn (rt (σ' sip)) ip› (*‹sn = nsqn (rt (σ' sip)) ip›*) show "?thesis"
(*goal: ‹sn < nsqn (rt (σ' sip)) ip ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
by simp
next
(*goal: ‹the (flag (rt ((σ::'a::type ⇒ state) (sip::'a::type))) (ip::nat)) = Aodv_Basic.inv ⟹ (sn::nat) < nsqn (rt ((σ'::'a::type ⇒ state) sip)) ip ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ (hops::nat) ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
assume "the (flag (rt (σ sip)) ip) = inv" (*‹the (flag (rt ((σ::'a ⇒ state) (sip::'a))) (ip::nat)) = Aodv_Basic.inv›*)
with ‹ip∈kD(rt (σ sip))› (*‹ip ∈ kD (rt (σ sip))›*) have "nsqn (rt (σ sip)) ip = sqn (rt (σ sip)) ip - 1"
by standard
with ‹sn ≥ 1› (*‹(1::nat) ≤ (sn::nat)›*) ‹sn = nsqn (rt (σ sip)) ip› (*‹sn = nsqn (rt (σ sip)) ip›*) have "sqn (rt (σ sip)) ip > 1"
by simp
from ‹ip∈kD(rt (σ' sip))› (*‹ip ∈ kD (rt (σ' sip))›*) show "?thesis"
(*goal: ‹sn < nsqn (rt (σ' sip)) ip ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
proof (rule vD_or_iD (*‹⟦?ip ∈ kD ?rt; ?ip ∈ vD ?rt ⟹ ?P ?rt ?ip; ?ip ∈ iD ?rt ⟹ ?P ?rt ?ip⟧ ⟹ ?P ?rt ?ip›*))
(*goals:
1. ‹ip ∈ vD (rt (σ' sip)) ⟹ sn < nsqn (rt (σ' sip)) ip ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›
2. ‹ip ∈ iD (rt (σ' sip)) ⟹ sn < nsqn (rt (σ' sip)) ip ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
assume "ip∈iD(rt (σ' sip))" (*‹(ip::nat) ∈ iD (rt ((σ'::'a ⇒ state) (sip::'a)))›*)
hence "the (flag (rt (σ' sip)) ip) = inv"
by standard
with ‹sn = nsqn (rt (σ' sip)) ip› (*‹(sn::nat) = nsqn (rt ((σ'::'a ⇒ state) (sip::'a))) (ip::nat)›*) show "?thesis"
(*goal: ‹sn < nsqn (rt (σ' sip)) ip ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
by simp
next
(*goal: ‹ip ∈ vD (rt (σ' sip)) ⟹ sn < nsqn (rt (σ' sip)) ip ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
assume "ip∈vD(rt (σ' sip))" (*‹(ip::nat) ∈ vD (rt ((σ'::'a ⇒ state) (sip::'a)))›*)
hence "nsqn (rt (σ' sip)) ip = sqn (rt (σ' sip)) ip"
by standard
with ‹sqn (rt (σ sip)) ip ≤ sqn (rt (σ' sip)) ip› (*‹sqn (rt (σ sip)) ip ≤ sqn (rt (σ' sip)) ip›*) have "nsqn (rt (σ' sip)) ip ≥ sqn (rt (σ sip)) ip"
by simp
with ‹sqn (rt (σ sip)) ip > 1› (*‹1 < sqn (rt (σ sip)) ip›*) have "nsqn (rt (σ' sip)) ip > sqn (rt (σ sip)) ip - 1"
by simp
with ‹nsqn (rt (σ sip)) ip = sqn (rt (σ sip)) ip - 1› (*‹nsqn (rt (σ sip)) ip = sqn (rt (σ sip)) ip - 1›*) have "nsqn (rt (σ' sip)) ip > nsqn (rt (σ sip)) ip"
by simp
with ‹sn = nsqn (rt (σ sip)) ip› (*‹sn = nsqn (rt (σ sip)) ip›*) have "nsqn (rt (σ' sip)) ip > sn"
by simp
thus "?thesis"
(*goal: ‹(sn::nat) < nsqn (rt ((σ'::'a ⇒ state) (sip::'a))) (ip::nat) ∨ nsqn (rt (σ' sip)) ip = sn ∧ (the (dhops (rt (σ' sip)) ip) ≤ (hops::nat) ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
by standard
qed
qed
qed
thus "?thesis"
(*goal: ‹sn ≤ nsqn (rt (σ' sip)) ip ∧ (nsqn (rt (σ' sip)) ip = sn ⟶ the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
by (metis (mono_tags) le_cases (*‹⟦?x ≤ ?y ⟹ ?P; ?y ≤ ?x ⟹ ?P⟧ ⟹ ?P›*) not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*))
qed
with ‹ip∈kD (rt (σ' sip))› (*‹ip ∈ kD (rt (σ' sip))›*) show "ip∈kD (rt (σ' sip)) ∧ ?nsqnafter"
by standard
qed
lemma quality_increases_rreq_rrep_props':
fixes sn ip hops sip
assumes "∀j. quality_increases (σ j) (σ' j)"
and "1 ≤ sn"
and *: "ip∈kD(rt (σ sip)) ∧ sn ≤ nsqn (rt (σ sip)) ip
∧ (nsqn (rt (σ sip)) ip = sn
⟶ (the (dhops (rt (σ sip)) ip) ≤ hops
∨ the (flag (rt (σ sip)) ip) = inv))"
shows "ip∈kD(rt (σ' sip)) ∧ sn ≤ nsqn (rt (σ' sip)) ip
∧ (nsqn (rt (σ' sip)) ip = sn
⟶ (the (dhops (rt (σ' sip)) ip) ≤ hops
∨ the (flag (rt (σ' sip)) ip) = inv))"
proof (-)
(*goal: ‹(ip::nat) ∈ kD (rt ((σ'::'a ⇒ state) (sip::'a))) ∧ (sn::nat) ≤ nsqn (rt (σ' sip)) ip ∧ (nsqn (rt (σ' sip)) ip = sn ⟶ the (dhops (rt (σ' sip)) ip) ≤ (hops::nat) ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
from assms(1) (*‹∀j. quality_increases (σ j) (σ' j)›*) have "quality_increases (σ sip) (σ' sip)"
by standard
thus "?thesis"
(*goal: ‹ip ∈ kD (rt (σ' sip)) ∧ sn ≤ nsqn (rt (σ' sip)) ip ∧ (nsqn (rt (σ' sip)) ip = sn ⟶ the (dhops (rt (σ' sip)) ip) ≤ hops ∨ the (flag (rt (σ' sip)) ip) = Aodv_Basic.inv)›*)
using assms(2-3) (*‹(1::nat) ≤ (sn::nat)› ‹ip ∈ kD (rt (σ sip)) ∧ sn ≤ nsqn (rt (σ sip)) ip ∧ (nsqn (rt (σ sip)) ip = sn ⟶ the (dhops (rt (σ sip)) ip) ≤ hops ∨ the (flag (rt (σ sip)) ip) = Aodv_Basic.inv)›*) by (rule quality_increases_rreq_rrep_props (*‹⟦quality_increases (?σ ?sip) (?σ' ?sip); 1 ≤ ?sn; ?ip ∈ kD (rt (?σ ?sip)) ∧ ?sn ≤ nsqn (rt (?σ ?sip)) ?ip ∧ (nsqn (rt (?σ ?sip)) ?ip = ?sn ⟶ the (dhops (rt (?σ ?sip)) ?ip) ≤ ?hops ∨ the (flag (rt (?σ ?sip)) ?ip) = Aodv_Basic.inv)⟧ ⟹ ?ip ∈ kD (rt (?σ' ?sip)) ∧ ?sn ≤ nsqn (rt (?σ' ?sip)) ?ip ∧ (nsqn (rt (?σ' ?sip)) ?ip = ?sn ⟶ the (dhops (rt (?σ' ?sip)) ?ip) ≤ ?hops ∨ the (flag (rt (?σ' ?sip)) ?ip) = Aodv_Basic.inv)›*))
qed
lemma rteq_quality_increases:
assumes "∀j. j ≠ i ⟶ quality_increases (σ j) (σ' j)"
and "rt (σ' i) = rt (σ i)"
shows "∀j. quality_increases (σ j) (σ' j)"
using assms (*‹∀j. j ≠ i ⟶ quality_increases (σ j) (σ' j)› ‹rt ((σ'::'a::type ⇒ state) (i::'a::type)) = rt ((σ::'a::type ⇒ state) i)›*) apply clarsimp
(*goal: ‹∀j. quality_increases (σ j) (σ' j)›*)
by (metis order_refl (*‹?x ≤ ?x›*) quality_increasesI (*‹⟦⋀dip. dip ∈ kD (rt ?ξ) ⟹ dip ∈ kD (rt ?ξ'); ⋀dip. ⟦dip ∈ kD (rt ?ξ); dip ∈ kD (rt ?ξ')⟧ ⟹ rt ?ξ ⊑⇘dip⇙ rt ?ξ'; ⋀dip. sqn (rt ?ξ) dip ≤ sqn (rt ?ξ') dip⟧ ⟹ quality_increases ?ξ ?ξ'›*) rt_fresher_refl (*‹?rt ⊑⇘?dip⇙ ?rt›*))
definition msg_fresh :: "(ip ⇒ state) ⇒ msg ⇒ bool"
where "msg_fresh σ m ≡
case m of Rreq hopsc _ _ _ _ oipc osnc sipc ⇒ osnc ≥ 1 ∧ (sipc ≠ oipc ⟶
oipc∈kD(rt (σ sipc)) ∧ nsqn (rt (σ sipc)) oipc ≥ osnc
∧ (nsqn (rt (σ sipc)) oipc = osnc
⟶ (hopsc ≥ the (dhops (rt (σ sipc)) oipc)
∨ the (flag (rt (σ sipc)) oipc) = inv)))
| Rrep hopsc dipc dsnc _ sipc ⇒ dsnc ≥ 1 ∧ (sipc ≠ dipc ⟶
dipc∈kD(rt (σ sipc)) ∧ nsqn (rt (σ sipc)) dipc ≥ dsnc
∧ (nsqn (rt (σ sipc)) dipc = dsnc
⟶ (hopsc ≥ the (dhops (rt (σ sipc)) dipc)
∨ the (flag (rt (σ sipc)) dipc) = inv)))
| Rerr destsc sipc ⇒ (∀ripc∈dom(destsc). (ripc∈kD(rt (σ sipc))
∧ the (destsc ripc) - 1 ≤ nsqn (rt (σ sipc)) ripc))
| _ ⇒ True"
lemma msg_fresh [simp]:
"⋀hops rreqid dip dsn dsk oip osn sip.
msg_fresh σ (Rreq hops rreqid dip dsn dsk oip osn sip) =
(osn ≥ 1 ∧ (sip ≠ oip ⟶ oip∈kD(rt (σ sip))
∧ nsqn (rt (σ sip)) oip ≥ osn
∧ (nsqn (rt (σ sip)) oip = osn
⟶ (hops ≥ the (dhops (rt (σ sip)) oip)
∨ the (flag (rt (σ sip)) oip) = inv))))"
"⋀hops dip dsn oip sip. msg_fresh σ (Rrep hops dip dsn oip sip) =
(dsn ≥ 1 ∧ (sip ≠ dip ⟶ dip∈kD(rt (σ sip))
∧ nsqn (rt (σ sip)) dip ≥ dsn
∧ (nsqn (rt (σ sip)) dip = dsn
⟶ (hops ≥ the (dhops (rt (σ sip)) dip))
∨ the (flag (rt (σ sip)) dip) = inv)))"
"⋀dests sip. msg_fresh σ (Rerr dests sip) =
(∀ripc∈dom(dests). (ripc∈kD(rt (σ sip))
∧ the (dests ripc) - 1 ≤ nsqn (rt (σ sip)) ripc))"
"⋀d dip. msg_fresh σ (Newpkt d dip) = True"
"⋀d dip sip. msg_fresh σ (Pkt d dip sip) = True"
unfolding msg_fresh_def
(*goals:
1. ‹⋀hops rreqid dip dsn dsk oip osn sip. (case Rreq hops rreqid dip dsn dsk oip osn sip of Rreq hopsc x xa xb xc oipc osnc sipc ⇒ 1 ≤ osnc ∧ (sipc ≠ oipc ⟶ oipc ∈ kD (rt (σ sipc)) ∧ osnc ≤ nsqn (rt (σ sipc)) oipc ∧ (nsqn (rt (σ sipc)) oipc = osnc ⟶ the (dhops (rt (σ sipc)) oipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) oipc) = Aodv_Basic.inv)) | Rrep hopsc dipc dsnc x sipc ⇒ 1 ≤ dsnc ∧ (sipc ≠ dipc ⟶ dipc ∈ kD (rt (σ sipc)) ∧ dsnc ≤ nsqn (rt (σ sipc)) dipc ∧ (nsqn (rt (σ sipc)) dipc = dsnc ⟶ the (dhops (rt (σ sipc)) dipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) dipc) = Aodv_Basic.inv)) | Rerr destsc sipc ⇒ ∀ripc∈dom destsc. ripc ∈ kD (rt (σ sipc)) ∧ the (destsc ripc) - 1 ≤ nsqn (rt (σ sipc)) ripc | _ ⇒ True) = (1 ≤ osn ∧ (sip ≠ oip ⟶ oip ∈ kD (rt (σ sip)) ∧ osn ≤ nsqn (rt (σ sip)) oip ∧ (nsqn (rt (σ sip)) oip = osn ⟶ the (dhops (rt (σ sip)) oip) ≤ hops ∨ the (flag (rt (σ sip)) oip) = Aodv_Basic.inv)))›
2. ‹⋀hops dip dsn oip sip. (case Rrep hops dip dsn oip sip of Rreq hopsc x xa xb xc oipc osnc sipc ⇒ 1 ≤ osnc ∧ (sipc ≠ oipc ⟶ oipc ∈ kD (rt (σ sipc)) ∧ osnc ≤ nsqn (rt (σ sipc)) oipc ∧ (nsqn (rt (σ sipc)) oipc = osnc ⟶ the (dhops (rt (σ sipc)) oipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) oipc) = Aodv_Basic.inv)) | Rrep hopsc dipc dsnc x sipc ⇒ 1 ≤ dsnc ∧ (sipc ≠ dipc ⟶ dipc ∈ kD (rt (σ sipc)) ∧ dsnc ≤ nsqn (rt (σ sipc)) dipc ∧ (nsqn (rt (σ sipc)) dipc = dsnc ⟶ the (dhops (rt (σ sipc)) dipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) dipc) = Aodv_Basic.inv)) | Rerr destsc sipc ⇒ ∀ripc∈dom destsc. ripc ∈ kD (rt (σ sipc)) ∧ the (destsc ripc) - 1 ≤ nsqn (rt (σ sipc)) ripc | _ ⇒ True) = (1 ≤ dsn ∧ (sip ≠ dip ⟶ dip ∈ kD (rt (σ sip)) ∧ dsn ≤ nsqn (rt (σ sip)) dip ∧ (nsqn (rt (σ sip)) dip = dsn ⟶ the (dhops (rt (σ sip)) dip) ≤ hops ∨ the (flag (rt (σ sip)) dip) = Aodv_Basic.inv)))›
3. ‹⋀dests sip. (case Rerr dests sip of Rreq hopsc x xa xb xc oipc osnc sipc ⇒ 1 ≤ osnc ∧ (sipc ≠ oipc ⟶ oipc ∈ kD (rt (σ sipc)) ∧ osnc ≤ nsqn (rt (σ sipc)) oipc ∧ (nsqn (rt (σ sipc)) oipc = osnc ⟶ the (dhops (rt (σ sipc)) oipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) oipc) = Aodv_Basic.inv)) | Rrep hopsc dipc dsnc x sipc ⇒ 1 ≤ dsnc ∧ (sipc ≠ dipc ⟶ dipc ∈ kD (rt (σ sipc)) ∧ dsnc ≤ nsqn (rt (σ sipc)) dipc ∧ (nsqn (rt (σ sipc)) dipc = dsnc ⟶ the (dhops (rt (σ sipc)) dipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) dipc) = Aodv_Basic.inv)) | Rerr destsc sipc ⇒ ∀ripc∈dom destsc. ripc ∈ kD (rt (σ sipc)) ∧ the (destsc ripc) - 1 ≤ nsqn (rt (σ sipc)) ripc | _ ⇒ True) = (∀ripc∈dom dests. ripc ∈ kD (rt (σ sip)) ∧ the (dests ripc) - 1 ≤ nsqn (rt (σ sip)) ripc)›
4. ‹⋀d dip. (case Newpkt d dip of Rreq hopsc x xa xb xc oipc osnc sipc ⇒ 1 ≤ osnc ∧ (sipc ≠ oipc ⟶ oipc ∈ kD (rt (σ sipc)) ∧ osnc ≤ nsqn (rt (σ sipc)) oipc ∧ (nsqn (rt (σ sipc)) oipc = osnc ⟶ the (dhops (rt (σ sipc)) oipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) oipc) = Aodv_Basic.inv)) | Rrep hopsc dipc dsnc x sipc ⇒ 1 ≤ dsnc ∧ (sipc ≠ dipc ⟶ dipc ∈ kD (rt (σ sipc)) ∧ dsnc ≤ nsqn (rt (σ sipc)) dipc ∧ (nsqn (rt (σ sipc)) dipc = dsnc ⟶ the (dhops (rt (σ sipc)) dipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) dipc) = Aodv_Basic.inv)) | Rerr destsc sipc ⇒ ∀ripc∈dom destsc. ripc ∈ kD (rt (σ sipc)) ∧ the (destsc ripc) - 1 ≤ nsqn (rt (σ sipc)) ripc | _ ⇒ True) = True›
5. ‹⋀d dip sip. (case Pkt d dip sip of Rreq hopsc x xa xb xc oipc osnc sipc ⇒ 1 ≤ osnc ∧ (sipc ≠ oipc ⟶ oipc ∈ kD (rt (σ sipc)) ∧ osnc ≤ nsqn (rt (σ sipc)) oipc ∧ (nsqn (rt (σ sipc)) oipc = osnc ⟶ the (dhops (rt (σ sipc)) oipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) oipc) = Aodv_Basic.inv)) | Rrep hopsc dipc dsnc x sipc ⇒ 1 ≤ dsnc ∧ (sipc ≠ dipc ⟶ dipc ∈ kD (rt (σ sipc)) ∧ dsnc ≤ nsqn (rt (σ sipc)) dipc ∧ (nsqn (rt (σ sipc)) dipc = dsnc ⟶ the (dhops (rt (σ sipc)) dipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) dipc) = Aodv_Basic.inv)) | Rerr destsc sipc ⇒ ∀ripc∈dom destsc. ripc ∈ kD (rt (σ sipc)) ∧ the (destsc ripc) - 1 ≤ nsqn (rt (σ sipc)) ripc | _ ⇒ True) = True›*)
(*goals:
1. ‹⋀hops rreqid dip dsn dsk oip osn sip. (case Rreq hops rreqid dip dsn dsk oip osn sip of Rreq hopsc x xa xb xc oipc osnc sipc ⇒ 1 ≤ osnc ∧ (sipc ≠ oipc ⟶ oipc ∈ kD (rt (σ sipc)) ∧ osnc ≤ nsqn (rt (σ sipc)) oipc ∧ (nsqn (rt (σ sipc)) oipc = osnc ⟶ the (dhops (rt (σ sipc)) oipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) oipc) = Aodv_Basic.inv)) | Rrep hopsc dipc dsnc x sipc ⇒ 1 ≤ dsnc ∧ (sipc ≠ dipc ⟶ dipc ∈ kD (rt (σ sipc)) ∧ dsnc ≤ nsqn (rt (σ sipc)) dipc ∧ (nsqn (rt (σ sipc)) dipc = dsnc ⟶ the (dhops (rt (σ sipc)) dipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) dipc) = Aodv_Basic.inv)) | Rerr destsc sipc ⇒ ∀ripc∈dom destsc. ripc ∈ kD (rt (σ sipc)) ∧ the (destsc ripc) - 1 ≤ nsqn (rt (σ sipc)) ripc | _ ⇒ True) = (1 ≤ osn ∧ (sip ≠ oip ⟶ oip ∈ kD (rt (σ sip)) ∧ osn ≤ nsqn (rt (σ sip)) oip ∧ (nsqn (rt (σ sip)) oip = osn ⟶ the (dhops (rt (σ sip)) oip) ≤ hops ∨ the (flag (rt (σ sip)) oip) = Aodv_Basic.inv)))›
2. ‹⋀hops dip dsn oip sip. (case Rrep hops dip dsn oip sip of Rreq hopsc x xa xb xc oipc osnc sipc ⇒ 1 ≤ osnc ∧ (sipc ≠ oipc ⟶ oipc ∈ kD (rt (σ sipc)) ∧ osnc ≤ nsqn (rt (σ sipc)) oipc ∧ (nsqn (rt (σ sipc)) oipc = osnc ⟶ the (dhops (rt (σ sipc)) oipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) oipc) = Aodv_Basic.inv)) | Rrep hopsc dipc dsnc x sipc ⇒ 1 ≤ dsnc ∧ (sipc ≠ dipc ⟶ dipc ∈ kD (rt (σ sipc)) ∧ dsnc ≤ nsqn (rt (σ sipc)) dipc ∧ (nsqn (rt (σ sipc)) dipc = dsnc ⟶ the (dhops (rt (σ sipc)) dipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) dipc) = Aodv_Basic.inv)) | Rerr destsc sipc ⇒ ∀ripc∈dom destsc. ripc ∈ kD (rt (σ sipc)) ∧ the (destsc ripc) - 1 ≤ nsqn (rt (σ sipc)) ripc | _ ⇒ True) = (1 ≤ dsn ∧ (sip ≠ dip ⟶ dip ∈ kD (rt (σ sip)) ∧ dsn ≤ nsqn (rt (σ sip)) dip ∧ (nsqn (rt (σ sip)) dip = dsn ⟶ the (dhops (rt (σ sip)) dip) ≤ hops ∨ the (flag (rt (σ sip)) dip) = Aodv_Basic.inv)))›
3. ‹⋀dests sip. (case Rerr dests sip of Rreq hopsc x xa xb xc oipc osnc sipc ⇒ 1 ≤ osnc ∧ (sipc ≠ oipc ⟶ oipc ∈ kD (rt (σ sipc)) ∧ osnc ≤ nsqn (rt (σ sipc)) oipc ∧ (nsqn (rt (σ sipc)) oipc = osnc ⟶ the (dhops (rt (σ sipc)) oipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) oipc) = Aodv_Basic.inv)) | Rrep hopsc dipc dsnc x sipc ⇒ 1 ≤ dsnc ∧ (sipc ≠ dipc ⟶ dipc ∈ kD (rt (σ sipc)) ∧ dsnc ≤ nsqn (rt (σ sipc)) dipc ∧ (nsqn (rt (σ sipc)) dipc = dsnc ⟶ the (dhops (rt (σ sipc)) dipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) dipc) = Aodv_Basic.inv)) | Rerr destsc sipc ⇒ ∀ripc∈dom destsc. ripc ∈ kD (rt (σ sipc)) ∧ the (destsc ripc) - 1 ≤ nsqn (rt (σ sipc)) ripc | _ ⇒ True) = (∀ripc∈dom dests. ripc ∈ kD (rt (σ sip)) ∧ the (dests ripc) - 1 ≤ nsqn (rt (σ sip)) ripc)›
4. ‹⋀d dip. (case Newpkt d dip of Rreq hopsc x xa xb xc oipc osnc sipc ⇒ 1 ≤ osnc ∧ (sipc ≠ oipc ⟶ oipc ∈ kD (rt (σ sipc)) ∧ osnc ≤ nsqn (rt (σ sipc)) oipc ∧ (nsqn (rt (σ sipc)) oipc = osnc ⟶ the (dhops (rt (σ sipc)) oipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) oipc) = Aodv_Basic.inv)) | Rrep hopsc dipc dsnc x sipc ⇒ 1 ≤ dsnc ∧ (sipc ≠ dipc ⟶ dipc ∈ kD (rt (σ sipc)) ∧ dsnc ≤ nsqn (rt (σ sipc)) dipc ∧ (nsqn (rt (σ sipc)) dipc = dsnc ⟶ the (dhops (rt (σ sipc)) dipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) dipc) = Aodv_Basic.inv)) | Rerr destsc sipc ⇒ ∀ripc∈dom destsc. ripc ∈ kD (rt (σ sipc)) ∧ the (destsc ripc) - 1 ≤ nsqn (rt (σ sipc)) ripc | _ ⇒ True) = True›
5. ‹⋀d dip sip. (case Pkt d dip sip of Rreq hopsc x xa xb xc oipc osnc sipc ⇒ 1 ≤ osnc ∧ (sipc ≠ oipc ⟶ oipc ∈ kD (rt (σ sipc)) ∧ osnc ≤ nsqn (rt (σ sipc)) oipc ∧ (nsqn (rt (σ sipc)) oipc = osnc ⟶ the (dhops (rt (σ sipc)) oipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) oipc) = Aodv_Basic.inv)) | Rrep hopsc dipc dsnc x sipc ⇒ 1 ≤ dsnc ∧ (sipc ≠ dipc ⟶ dipc ∈ kD (rt (σ sipc)) ∧ dsnc ≤ nsqn (rt (σ sipc)) dipc ∧ (nsqn (rt (σ sipc)) dipc = dsnc ⟶ the (dhops (rt (σ sipc)) dipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) dipc) = Aodv_Basic.inv)) | Rerr destsc sipc ⇒ ∀ripc∈dom destsc. ripc ∈ kD (rt (σ sipc)) ∧ the (destsc ripc) - 1 ≤ nsqn (rt (σ sipc)) ripc | _ ⇒ True) = True›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*proven 5 subgoals*) .
lemma msg_fresh_inc_sn [simp, elim]:
"msg_fresh σ m ⟹ rreq_rrep_sn m"
apply (cases m)
(*goals:
1. ‹⋀x11 x12 x13 x14 x15 x16 x17 x18. ⟦msg_fresh σ m; m = Rreq x11 x12 x13 x14 x15 x16 x17 x18⟧ ⟹ rreq_rrep_sn m›
2. ‹⋀x21 x22 x23 x24 x25. ⟦msg_fresh σ m; m = Rrep x21 x22 x23 x24 x25⟧ ⟹ rreq_rrep_sn m›
3. ‹⋀x31 x32. ⟦msg_fresh σ m; m = Rerr x31 x32⟧ ⟹ rreq_rrep_sn m›
4. ‹⋀x41 x42. ⟦msg_fresh σ m; m = Newpkt x41 x42⟧ ⟹ rreq_rrep_sn m›
5. ‹⋀x51 x52 x53. ⟦msg_fresh σ m; m = Pkt x51 x52 x53⟧ ⟹ rreq_rrep_sn m›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*proven 5 subgoals*) .
lemma recv_msg_fresh_inc_sn [simp, elim]:
"orecvmsg (msg_fresh) σ m ⟹ recvmsg rreq_rrep_sn m"
apply (cases m)
(*goals:
1. ‹⋀x1. ⟦orecvmsg msg_fresh σ m; m = broadcast x1⟧ ⟹ recvmsg rreq_rrep_sn m›
2. ‹⋀x21 x22. ⟦orecvmsg msg_fresh σ m; m = groupcast x21 x22⟧ ⟹ recvmsg rreq_rrep_sn m›
3. ‹⋀x31 x32. ⟦orecvmsg msg_fresh σ m; m = unicast x31 x32⟧ ⟹ recvmsg rreq_rrep_sn m›
4. ‹⋀x4. ⟦orecvmsg msg_fresh σ m; m = ¬unicast x4⟧ ⟹ recvmsg rreq_rrep_sn m›
5. ‹⋀x5. ⟦orecvmsg msg_fresh σ m; m = send x5⟧ ⟹ recvmsg rreq_rrep_sn m›
6. ‹⋀x6. ⟦orecvmsg msg_fresh σ m; m = deliver x6⟧ ⟹ recvmsg rreq_rrep_sn m›
7. ‹⋀x7. ⟦orecvmsg msg_fresh σ m; m = receive x7⟧ ⟹ recvmsg rreq_rrep_sn m›
8. ‹⟦orecvmsg msg_fresh σ m; m = τ⇩s⟧ ⟹ recvmsg rreq_rrep_sn m›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
lemma rreq_nsqn_is_fresh [simp]:
fixes σ msg hops rreqid dip dsn dsk oip osn sip
assumes "rreq_rrep_fresh (rt (σ sip)) (Rreq hops rreqid dip dsn dsk oip osn sip)"
and "rreq_rrep_sn (Rreq hops rreqid dip dsn dsk oip osn sip)"
shows "msg_fresh σ (Rreq hops rreqid dip dsn dsk oip osn sip)"
(is "msg_fresh σ ?msg")
proof (-)
(*goal: ‹msg_fresh (σ::nat ⇒ state) (Rreq (hops::nat) (rreqid::nat) (dip::nat) (dsn::nat) (dsk::k) (oip::nat) (osn::nat) (sip::nat))›*)
let ?rt = "rt (σ sip)"
from assms(2) (*‹rreq_rrep_sn (Rreq hops rreqid dip dsn dsk oip osn sip)›*) have "1 ≤ osn"
by simp
thus "?thesis"
(*goal: ‹msg_fresh σ (Rreq hops rreqid dip dsn dsk oip osn sip)›*)
unfolding msg_fresh_def
(*goal: ‹case Rreq (hops::nat) (rreqid::nat) (dip::nat) (dsn::nat) (dsk::k) (oip::nat) (osn::nat) (sip::nat) of Rreq (hopsc::nat) (x::nat) (xa::nat) (xb::nat) (xc::k) (oipc::nat) (osnc::nat) (sipc::nat) ⇒ (1::nat) ≤ osnc ∧ (sipc ≠ oipc ⟶ oipc ∈ kD (rt ((σ::nat ⇒ state) sipc)) ∧ osnc ≤ nsqn (rt (σ sipc)) oipc ∧ (nsqn (rt (σ sipc)) oipc = osnc ⟶ the (dhops (rt (σ sipc)) oipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) oipc) = Aodv_Basic.inv)) | Rrep (hopsc::nat) (dipc::nat) (dsnc::nat) (x::nat) (sipc::nat) ⇒ (1::nat) ≤ dsnc ∧ (sipc ≠ dipc ⟶ dipc ∈ kD (rt (σ sipc)) ∧ dsnc ≤ nsqn (rt (σ sipc)) dipc ∧ (nsqn (rt (σ sipc)) dipc = dsnc ⟶ the (dhops (rt (σ sipc)) dipc) ≤ hopsc ∨ the (flag (rt (σ sipc)) dipc) = Aodv_Basic.inv)) | Rerr (destsc::nat ⇒ nat option) (sipc::nat) ⇒ ∀ripc::nat∈dom destsc. ripc ∈ kD (rt (σ sipc)) ∧ the (destsc ripc) - (1::nat) ≤ nsqn (rt (σ sipc)) ripc | _ ⇒ True›*)
proof (simp only: msg.case (*‹(case Rreq ?x11.0 ?x12.0 ?x13.0 ?x14.0 ?x15.0 ?x16.0 ?x17.0 ?x18.0 of Rreq x xa xb xc xd xe xf xg ⇒ ?f1.0 x xa xb xc xd xe xf xg | Rrep x xa xb xc xd ⇒ ?f2.0 x xa xb xc xd | Rerr x xa ⇒ ?f3.0 x xa | Newpkt x xa ⇒ ?f4.0 x xa | Pkt x xa xb ⇒ ?f5.0 x xa xb) = ?f1.0 ?x11.0 ?x12.0 ?x13.0 ?x14.0 ?x15.0 ?x16.0 ?x17.0 ?x18.0› ‹(case Rrep ?x21.0 ?x22.0 ?x23.0 ?x24.0 ?x25.0 of Rreq x xa xb xc xd xe xf xg ⇒ ?f1.0 x xa xb xc xd xe xf xg | Rrep x xa xb xc xd ⇒ ?f2.0 x xa xb xc xd | Rerr x xa ⇒ ?f3.0 x xa | Newpkt x xa ⇒ ?f4.0 x xa | Pkt x xa xb ⇒ ?f5.0 x xa xb) = ?f2.0 ?x21.0 ?x22.0 ?x23.0 ?x24.0 ?x25.0› ‹(case Rerr ?x31.0 ?x32.0 of Rreq x xa xb xc xd xe xf xg ⇒ ?f1.0 x xa xb xc xd xe xf xg | Rrep x xa xb xc xd ⇒ ?f2.0 x xa xb xc xd | Rerr x xa ⇒ ?f3.0 x xa | Newpkt x xa ⇒ ?f4.0 x xa | Pkt x xa xb ⇒ ?f5.0 x xa xb) = ?f3.0 ?x31.0 ?x32.0› ‹(case Newpkt ?x41.0 ?x42.0 of Rreq x xa xb xc xd xe xf xg ⇒ ?f1.0 x xa xb xc xd xe xf xg | Rrep x xa xb xc xd ⇒ ?f2.0 x xa xb xc xd | Rerr x xa ⇒ ?f3.0 x xa | Newpkt x xa ⇒ ?f4.0 x xa | Pkt x xa xb ⇒ ?f5.0 x xa xb) = ?f4.0 ?x41.0 ?x42.0› ‹(case Pkt ?x51.0 ?x52.0 ?x53.0 of Rreq x xa xb xc xd xe xf xg ⇒ ?f1.0 x xa xb xc xd xe xf xg | Rrep x xa xb xc xd ⇒ ?f2.0 x xa xb xc xd | Rerr x xa ⇒ ?f3.0 x xa | Newpkt x xa ⇒ ?f4.0 x xa | Pkt x xa xb ⇒ ?f5.0 x xa xb) = ?f5.0 ?x51.0 ?x52.0 ?x53.0›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goals:
1. ‹⟦1 ≤ osn; 1 ≤ osn⟧ ⟹ True›
2. ‹⟦1 ≤ osn; 1 ≤ osn; sip ≠ oip⟧ ⟹ oip ∈ kD (rt (σ sip))›
3. ‹⟦1 ≤ osn; 1 ≤ osn; sip ≠ oip⟧ ⟹ osn ≤ nsqn (rt (σ sip)) oip›
4. ‹⟦1 ≤ osn; 1 ≤ osn; sip ≠ oip; nsqn (rt (σ sip)) oip = osn⟧ ⟹ the (dhops (rt (σ sip)) oip) ≤ hops ∨ the (flag (rt (σ sip)) oip) = Aodv_Basic.inv›*)
assume "sip ≠ oip" (*‹(sip::nat) ≠ (oip::nat)›*)
with assms(1) (*‹rreq_rrep_fresh (rt (σ sip)) (Rreq hops rreqid dip dsn dsk oip osn sip)›*) show "oip ∈ kD(?rt)"
by simp
next
(*goals:
1. ‹⟦1 ≤ osn; 1 ≤ osn⟧ ⟹ True›
2. ‹⟦1 ≤ osn; 1 ≤ osn; sip ≠ oip⟧ ⟹ osn ≤ nsqn (rt (σ sip)) oip›
3. ‹⟦1 ≤ osn; 1 ≤ osn; sip ≠ oip; nsqn (rt (σ sip)) oip = osn⟧ ⟹ the (dhops (rt (σ sip)) oip) ≤ hops ∨ the (flag (rt (σ sip)) oip) = Aodv_Basic.inv›*)
assume "sip ≠ oip" and "nsqn ?rt oip = osn" (*‹(sip::nat) ≠ (oip::nat)› ‹nsqn (rt ((σ::nat ⇒ state) (sip::nat))) (oip::nat) = (osn::nat)›*)
show "the (dhops ?rt oip) ≤ hops ∨ the (flag ?rt oip) = inv"
proof (cases "oip∈vD(?rt)")
(*goals:
1. ‹oip ∈ vD (rt (σ sip)) ⟹ the (dhops (rt (σ sip)) oip) ≤ hops ∨ the (flag (rt (σ sip)) oip) = Aodv_Basic.inv›
2. ‹oip ∉ vD (rt (σ sip)) ⟹ the (dhops (rt (σ sip)) oip) ≤ hops ∨ the (flag (rt (σ sip)) oip) = Aodv_Basic.inv›*)
assume "oip∈vD(?rt)" (*‹(oip::nat) ∈ vD (rt ((σ::nat ⇒ state) (sip::nat)))›*)
hence "nsqn ?rt oip = sqn ?rt oip"
by standard
with ‹nsqn ?rt oip = osn› (*‹nsqn (rt ((σ::nat ⇒ state) (sip::nat))) (oip::nat) = (osn::nat)›*) have "sqn ?rt oip = osn"
by simp
with assms(1) (*‹rreq_rrep_fresh (rt (σ sip)) (Rreq hops rreqid dip dsn dsk oip osn sip)›*) ‹sip ≠ oip› (*‹sip ≠ oip›*) have "the (dhops ?rt oip) ≤ hops"
by simp
thus "?thesis"
(*goal: ‹the (dhops (rt (σ sip)) oip) ≤ hops ∨ the (flag (rt (σ sip)) oip) = Aodv_Basic.inv›*)
by standard
next
(*goal: ‹oip ∉ vD (rt (σ sip)) ⟹ the (dhops (rt (σ sip)) oip) ≤ hops ∨ the (flag (rt (σ sip)) oip) = Aodv_Basic.inv›*)
assume "oip∉vD(?rt)" (*‹(oip::nat) ∉ vD (rt ((σ::nat ⇒ state) (sip::nat)))›*)
moreover from assms(1) (*‹rreq_rrep_fresh (rt (σ sip)) (Rreq hops rreqid dip dsn dsk oip osn sip)›*) ‹sip ≠ oip› (*‹sip ≠ oip›*) have "oip∈kD(?rt)"
by simp
ultimately have "oip∈iD(?rt)"
by auto
hence "the (flag ?rt oip) = inv"
by standard
thus "?thesis"
(*goal: ‹the (dhops (rt (σ sip)) oip) ≤ hops ∨ the (flag (rt (σ sip)) oip) = Aodv_Basic.inv›*)
by standard
qed
next
(*goals:
1. ‹⟦1 ≤ osn; 1 ≤ osn⟧ ⟹ True›
2. ‹⟦1 ≤ osn; 1 ≤ osn; sip ≠ oip⟧ ⟹ osn ≤ nsqn (rt (σ sip)) oip›*)
assume "sip ≠ oip" (*‹(sip::nat) ≠ (oip::nat)›*)
with assms(1) (*‹rreq_rrep_fresh (rt ((σ::nat ⇒ state) (sip::nat))) (Rreq (hops::nat) (rreqid::nat) (dip::nat) (dsn::nat) (dsk::k) (oip::nat) (osn::nat) sip)›*) have "osn ≤ sqn ?rt oip"
by auto
thus "osn ≤ nsqn (rt (σ sip)) oip"
proof (rule nat_le_eq_or_lt (*‹⟦(?x::nat) ≤ (?y::nat); ?x = ?y ⟹ (?P::nat ⇒ nat ⇒ bool) ?x ?y; ?x < ?y ⟹ ?P ?x ?y⟧ ⟹ ?P ?x ?y›*))
(*goals:
1. ‹osn = sqn (rt (σ sip)) oip ⟹ osn ≤ nsqn (rt (σ sip)) oip›
2. ‹osn < sqn (rt (σ sip)) oip ⟹ osn ≤ nsqn (rt (σ sip)) oip›*)
assume "osn < sqn ?rt oip" (*‹(osn::nat) < sqn (rt ((σ::nat ⇒ state) (sip::nat))) (oip::nat)›*)
hence "osn ≤ sqn ?rt oip - 1"
by simp
also (*calculation: ‹(osn::nat) ≤ sqn (rt ((σ::nat ⇒ state) (sip::nat))) (oip::nat) - (1::nat)›*) have "... ≤ nsqn ?rt oip"
by (rule sqn_nsqn (*‹sqn ?rt ?dip - 1 ≤ nsqn ?rt ?dip›*))
finally (*calculation: ‹osn ≤ nsqn (rt (σ sip)) oip›*) show "osn ≤ nsqn ?rt oip" .
next
(*goal: ‹(osn::nat) = sqn (rt ((σ::nat ⇒ state) (sip::nat))) (oip::nat) ⟹ osn ≤ nsqn (rt (σ sip)) oip›*)
assume "osn = sqn ?rt oip" (*‹(osn::nat) = sqn (rt ((σ::nat ⇒ state) (sip::nat))) (oip::nat)›*)
with assms(1) (*‹rreq_rrep_fresh (rt ((σ::nat ⇒ state) (sip::nat))) (Rreq (hops::nat) (rreqid::nat) (dip::nat) (dsn::nat) (dsk::k) (oip::nat) (osn::nat) sip)›*) ‹sip ≠ oip› (*‹(sip::nat) ≠ (oip::nat)›*) have "oip∈kD(?rt)" and "the (flag ?rt oip) = val"
apply -
(*goals:
1. ‹⟦rreq_rrep_fresh (rt (σ sip)) (Rreq hops rreqid dip dsn dsk oip osn sip); sip ≠ oip; osn = sqn (rt (σ sip)) oip⟧ ⟹ oip ∈ kD (rt (σ sip))›
2. ‹⟦rreq_rrep_fresh (rt (σ sip)) (Rreq hops rreqid dip dsn dsk oip osn sip); sip ≠ oip; osn = sqn (rt (σ sip)) oip⟧ ⟹ the (flag (rt (σ sip)) oip) = val›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
hence "nsqn ?rt oip = sqn ?rt oip"
by standard
with ‹osn = sqn ?rt oip› (*‹osn = sqn (rt (σ sip)) oip›*) have "nsqn ?rt oip = osn"
by simp
thus "osn ≤ nsqn ?rt oip"
by simp
qed
qed (simp)
(*solved the remaining goal: ‹⟦1 ≤ osn; 1 ≤ osn⟧ ⟹ True›*)
qed
lemma rrep_nsqn_is_fresh [simp]:
fixes σ msg hops dip dsn oip sip
assumes "rreq_rrep_fresh (rt (σ sip)) (Rrep hops dip dsn oip sip)"
and "rreq_rrep_sn (Rrep hops dip dsn oip sip)"
shows "msg_fresh σ (Rrep hops dip dsn oip sip)"
(is "msg_fresh σ ?msg")
proof (-)
(*goal: ‹msg_fresh σ (Rrep hops dip dsn oip sip)›*)
let ?rt = "rt (σ sip)"
from assms (*‹rreq_rrep_fresh (rt (σ sip)) (Rrep hops dip dsn oip sip)› ‹rreq_rrep_sn (Rrep hops dip dsn oip sip)›*) have "sip ≠ dip ⟶ dip∈kD(?rt) ∧ sqn ?rt dip = dsn ∧ the (flag ?rt dip) = val"
by simp
hence "sip ≠ dip ⟶ dip∈kD(?rt) ∧ nsqn ?rt dip ≥ dsn"
by clarsimp
with assms (*‹rreq_rrep_fresh (rt (σ sip)) (Rrep hops dip dsn oip sip)› ‹rreq_rrep_sn (Rrep hops dip dsn oip sip)›*) show "msg_fresh σ ?msg"
by clarsimp
qed
lemma rerr_nsqn_is_fresh [simp]:
fixes σ msg dests sip
assumes "rerr_invalid (rt (σ sip)) (Rerr dests sip)"
shows "msg_fresh σ (Rerr dests sip)"
(is "msg_fresh σ ?msg")
proof (-)
(*goal: ‹msg_fresh σ (Rerr dests sip)›*)
let ?rt = "rt (σ sip)"
from assms (*‹rerr_invalid (rt (σ sip)) (Rerr dests sip)›*) have "*": "(∀rip∈dom(dests). (rip∈iD(rt (σ sip))
∧ the (dests rip) = sqn (rt (σ sip)) rip))"
by clarsimp
have "(∀rip∈dom(dests). (rip∈kD(rt (σ sip))
∧ the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip))"
proof (standard)
(*goal: ‹⋀rip. rip ∈ dom dests ⟹ rip ∈ kD (rt (σ sip)) ∧ the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip›*)
fix rip
assume "rip ∈ dom dests" (*‹(rip::nat) ∈ dom (dests::nat ⇒ nat option)›*)
with "*" (*‹∀rip∈dom dests. rip ∈ iD (rt (σ sip)) ∧ the (dests rip) = sqn (rt (σ sip)) rip›*) have "rip∈iD(rt (σ sip))" and "the (dests rip) = sqn (rt (σ sip)) rip"
apply -
(*goals:
1. ‹⟦∀rip∈dom dests. rip ∈ iD (rt (σ sip)) ∧ the (dests rip) = sqn (rt (σ sip)) rip; rip ∈ dom dests⟧ ⟹ rip ∈ iD (rt (σ sip))›
2. ‹⟦∀rip∈dom dests. rip ∈ iD (rt (σ sip)) ∧ the (dests rip) = sqn (rt (σ sip)) rip; rip ∈ dom dests⟧ ⟹ the (dests rip) = sqn (rt (σ sip)) rip›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
from this(2) (*‹the (dests rip) = sqn (rt (σ sip)) rip›*) have "the (dests rip) - 1 = sqn (rt (σ sip)) rip - 1"
by simp
also (*calculation: ‹the (dests rip) - 1 = sqn (rt (σ sip)) rip - 1›*) have "... ≤ nsqn (rt (σ sip)) rip"
by (rule sqn_nsqn (*‹sqn ?rt ?dip - 1 ≤ nsqn ?rt ?dip›*))
finally (*calculation: ‹the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip›*) have "the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip" .
with ‹rip∈iD(rt (σ sip))› (*‹rip ∈ iD (rt (σ sip))›*) show "rip∈kD(rt (σ sip)) ∧ the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip"
by clarsimp
qed
thus "msg_fresh σ ?msg"
by simp
qed
lemma quality_increases_msg_fresh [elim]:
assumes qinc: "∀j. quality_increases (σ j) (σ' j)"
and "msg_fresh σ m"
shows "msg_fresh σ' m"
using assms(2) (*‹msg_fresh σ m›*) proof (cases m)
(*goals:
1. ‹⋀x11 x12 x13 x14 x15 x16 x17 x18. ⟦msg_fresh σ m; m = Rreq x11 x12 x13 x14 x15 x16 x17 x18⟧ ⟹ msg_fresh σ' m›
2. ‹⋀x21 x22 x23 x24 x25. ⟦msg_fresh σ m; m = Rrep x21 x22 x23 x24 x25⟧ ⟹ msg_fresh σ' m›
3. ‹⋀x31 x32. ⟦msg_fresh σ m; m = Rerr x31 x32⟧ ⟹ msg_fresh σ' m›
4. ‹⋀x41 x42. ⟦msg_fresh σ m; m = Newpkt x41 x42⟧ ⟹ msg_fresh σ' m›
5. ‹⋀x51 x52 x53. ⟦msg_fresh σ m; m = Pkt x51 x52 x53⟧ ⟹ msg_fresh σ' m›*)
fix hops and rreqid and dip and dsn and dsk and oip and osn and sip
assume [simp]: "m = Rreq hops rreqid dip dsn dsk oip osn sip" and "msg_fresh σ m" (*‹(m::msg) = Rreq (hops::nat) (rreqid::nat) (dip::nat) (dsn::nat) (dsk::k) (oip::nat) (osn::nat) (sip::nat)› ‹msg_fresh (σ::nat ⇒ state) (m::msg)›*)
then have "osn ≥ 1" and "sip = oip ∨ (oip∈kD(rt (σ sip)) ∧ osn ≤ nsqn (rt (σ sip)) oip
∧ (nsqn (rt (σ sip)) oip = osn
⟶ (the (dhops (rt (σ sip)) oip) ≤ hops
∨ the (flag (rt (σ sip)) oip) = inv)))"
apply -
(*goals:
1. ‹⟦m = Rreq hops rreqid dip dsn dsk oip osn sip; msg_fresh σ m⟧ ⟹ 1 ≤ osn›
2. ‹⟦m = Rreq hops rreqid dip dsn dsk oip osn sip; msg_fresh σ m⟧ ⟹ sip = oip ∨ oip ∈ kD (rt (σ sip)) ∧ osn ≤ nsqn (rt (σ sip)) oip ∧ (nsqn (rt (σ sip)) oip = osn ⟶ the (dhops (rt (σ sip)) oip) ≤ hops ∨ the (flag (rt (σ sip)) oip) = Aodv_Basic.inv)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
from this(2) (*‹(sip::nat) = (oip::nat) ∨ oip ∈ kD (rt ((σ::nat ⇒ state) sip)) ∧ (osn::nat) ≤ nsqn (rt (σ sip)) oip ∧ (nsqn (rt (σ sip)) oip = osn ⟶ the (dhops (rt (σ sip)) oip) ≤ (hops::nat) ∨ the (flag (rt (σ sip)) oip) = Aodv_Basic.inv)›*) show "?thesis"
(*goal: ‹msg_fresh σ' m›*)
proof (standard)
(*goals:
1. ‹sip = oip ⟹ msg_fresh σ' m›
2. ‹oip ∈ kD (rt (σ sip)) ∧ osn ≤ nsqn (rt (σ sip)) oip ∧ (nsqn (rt (σ sip)) oip = osn ⟶ the (dhops (rt (σ sip)) oip) ≤ hops ∨ the (flag (rt (σ sip)) oip) = Aodv_Basic.inv) ⟹ msg_fresh σ' m›*)
assume "sip = oip" (*‹(sip::nat) = (oip::nat)›*)
with ‹osn ≥ 1› (*‹(1::nat) ≤ (osn::nat)›*) show "?thesis"
(*goal: ‹msg_fresh σ' m›*)
by simp
next
(*goal: ‹oip ∈ kD (rt (σ sip)) ∧ osn ≤ nsqn (rt (σ sip)) oip ∧ (nsqn (rt (σ sip)) oip = osn ⟶ the (dhops (rt (σ sip)) oip) ≤ hops ∨ the (flag (rt (σ sip)) oip) = Aodv_Basic.inv) ⟹ msg_fresh σ' m›*)
assume "oip∈kD(rt (σ sip)) ∧ osn ≤ nsqn (rt (σ sip)) oip
∧ (nsqn (rt (σ sip)) oip = osn
⟶ (the (dhops (rt (σ sip)) oip) ≤ hops
∨ the (flag (rt (σ sip)) oip) = inv))" (*‹(oip::nat) ∈ kD (rt ((σ::nat ⇒ state) (sip::nat))) ∧ (osn::nat) ≤ nsqn (rt (σ sip)) oip ∧ (nsqn (rt (σ sip)) oip = osn ⟶ the (dhops (rt (σ sip)) oip) ≤ (hops::nat) ∨ the (flag (rt (σ sip)) oip) = Aodv_Basic.inv)›*)
moreover from qinc (*‹∀j. quality_increases (σ j) (σ' j)›*) have "quality_increases (σ sip) (σ' sip)"
by standard
ultimately have "oip∈kD(rt (σ' sip)) ∧ osn ≤ nsqn (rt (σ' sip)) oip
∧ (nsqn (rt (σ' sip)) oip = osn
⟶ (the (dhops (rt (σ' sip)) oip) ≤ hops
∨ the (flag (rt (σ' sip)) oip) = inv))"
using ‹osn ≥ 1› (*‹(1::nat) ≤ (osn::nat)›*) by (rule quality_increases_rreq_rrep_props [rotated 2] (*‹⟦?ip ∈ kD (rt (?σ ?sip)) ∧ ?sn ≤ nsqn (rt (?σ ?sip)) ?ip ∧ (nsqn (rt (?σ ?sip)) ?ip = ?sn ⟶ the (dhops (rt (?σ ?sip)) ?ip) ≤ ?hops ∨ the (flag (rt (?σ ?sip)) ?ip) = Aodv_Basic.inv); quality_increases (?σ ?sip) (?σ' ?sip); 1 ≤ ?sn⟧ ⟹ ?ip ∈ kD (rt (?σ' ?sip)) ∧ ?sn ≤ nsqn (rt (?σ' ?sip)) ?ip ∧ (nsqn (rt (?σ' ?sip)) ?ip = ?sn ⟶ the (dhops (rt (?σ' ?sip)) ?ip) ≤ ?hops ∨ the (flag (rt (?σ' ?sip)) ?ip) = Aodv_Basic.inv)›*))
with ‹osn ≥ 1› (*‹1 ≤ osn›*) show "msg_fresh σ' m"
by clarsimp
qed
next
(*goals:
1. ‹⋀x21 x22 x23 x24 x25. ⟦msg_fresh σ m; m = Rrep x21 x22 x23 x24 x25⟧ ⟹ msg_fresh σ' m›
2. ‹⋀x31 x32. ⟦msg_fresh σ m; m = Rerr x31 x32⟧ ⟹ msg_fresh σ' m›
3. ‹⋀x41 x42. ⟦msg_fresh σ m; m = Newpkt x41 x42⟧ ⟹ msg_fresh σ' m›
4. ‹⋀x51 x52 x53. ⟦msg_fresh σ m; m = Pkt x51 x52 x53⟧ ⟹ msg_fresh σ' m›*)
fix hops and dip and dsn and oip and sip
assume [simp]: "m = Rrep hops dip dsn oip sip" and "msg_fresh σ m" (*‹(m::msg) = Rrep (hops::nat) (dip::nat) (dsn::nat) (oip::nat) (sip::nat)› ‹msg_fresh (σ::nat ⇒ state) (m::msg)›*)
then have "dsn ≥ 1" and "sip = dip ∨ (dip∈kD(rt (σ sip)) ∧ dsn ≤ nsqn (rt (σ sip)) dip
∧ (nsqn (rt (σ sip)) dip = dsn
⟶ (the (dhops (rt (σ sip)) dip) ≤ hops
∨ the (flag (rt (σ sip)) dip) = inv)))"
apply -
(*goals:
1. ‹⟦m = Rrep hops dip dsn oip sip; msg_fresh σ m⟧ ⟹ 1 ≤ dsn›
2. ‹⟦m = Rrep hops dip dsn oip sip; msg_fresh σ m⟧ ⟹ sip = dip ∨ dip ∈ kD (rt (σ sip)) ∧ dsn ≤ nsqn (rt (σ sip)) dip ∧ (nsqn (rt (σ sip)) dip = dsn ⟶ the (dhops (rt (σ sip)) dip) ≤ hops ∨ the (flag (rt (σ sip)) dip) = Aodv_Basic.inv)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
from this(2) (*‹sip = dip ∨ dip ∈ kD (rt (σ sip)) ∧ dsn ≤ nsqn (rt (σ sip)) dip ∧ (nsqn (rt (σ sip)) dip = dsn ⟶ the (dhops (rt (σ sip)) dip) ≤ hops ∨ the (flag (rt (σ sip)) dip) = Aodv_Basic.inv)›*) show "?thesis"
(*goal: ‹msg_fresh σ' m›*)
proof (standard)
(*goals:
1. ‹sip = dip ⟹ msg_fresh σ' m›
2. ‹dip ∈ kD (rt (σ sip)) ∧ dsn ≤ nsqn (rt (σ sip)) dip ∧ (nsqn (rt (σ sip)) dip = dsn ⟶ the (dhops (rt (σ sip)) dip) ≤ hops ∨ the (flag (rt (σ sip)) dip) = Aodv_Basic.inv) ⟹ msg_fresh σ' m›*)
assume "sip = dip" (*‹(sip::nat) = (dip::nat)›*)
with ‹dsn ≥ 1› (*‹1 ≤ dsn›*) show "?thesis"
(*goal: ‹msg_fresh σ' m›*)
by simp
next
(*goal: ‹dip ∈ kD (rt (σ sip)) ∧ dsn ≤ nsqn (rt (σ sip)) dip ∧ (nsqn (rt (σ sip)) dip = dsn ⟶ the (dhops (rt (σ sip)) dip) ≤ hops ∨ the (flag (rt (σ sip)) dip) = Aodv_Basic.inv) ⟹ msg_fresh σ' m›*)
assume "dip∈kD(rt (σ sip)) ∧ dsn ≤ nsqn (rt (σ sip)) dip
∧ (nsqn (rt (σ sip)) dip = dsn
⟶ (the (dhops (rt (σ sip)) dip) ≤ hops
∨ the (flag (rt (σ sip)) dip) = inv))" (*‹(dip::nat) ∈ kD (rt ((σ::nat ⇒ state) (sip::nat))) ∧ (dsn::nat) ≤ nsqn (rt (σ sip)) dip ∧ (nsqn (rt (σ sip)) dip = dsn ⟶ the (dhops (rt (σ sip)) dip) ≤ (hops::nat) ∨ the (flag (rt (σ sip)) dip) = Aodv_Basic.inv)›*)
moreover from qinc (*‹∀j. quality_increases (σ j) (σ' j)›*) have "quality_increases (σ sip) (σ' sip)"
by standard
ultimately have "dip∈kD(rt (σ' sip)) ∧ dsn ≤ nsqn (rt (σ' sip)) dip
∧ (nsqn (rt (σ' sip)) dip = dsn
⟶ (the (dhops (rt (σ' sip)) dip) ≤ hops
∨ the (flag (rt (σ' sip)) dip) = inv))"
using ‹dsn ≥ 1› (*‹1 ≤ dsn›*) by (rule quality_increases_rreq_rrep_props [rotated 2] (*‹⟦?ip ∈ kD (rt (?σ ?sip)) ∧ ?sn ≤ nsqn (rt (?σ ?sip)) ?ip ∧ (nsqn (rt (?σ ?sip)) ?ip = ?sn ⟶ the (dhops (rt (?σ ?sip)) ?ip) ≤ ?hops ∨ the (flag (rt (?σ ?sip)) ?ip) = Aodv_Basic.inv); quality_increases (?σ ?sip) (?σ' ?sip); 1 ≤ ?sn⟧ ⟹ ?ip ∈ kD (rt (?σ' ?sip)) ∧ ?sn ≤ nsqn (rt (?σ' ?sip)) ?ip ∧ (nsqn (rt (?σ' ?sip)) ?ip = ?sn ⟶ the (dhops (rt (?σ' ?sip)) ?ip) ≤ ?hops ∨ the (flag (rt (?σ' ?sip)) ?ip) = Aodv_Basic.inv)›*))
with ‹dsn ≥ 1› (*‹1 ≤ dsn›*) show "msg_fresh σ' m"
by clarsimp
qed
next
(*goals:
1. ‹⋀x31 x32. ⟦msg_fresh σ m; m = Rerr x31 x32⟧ ⟹ msg_fresh σ' m›
2. ‹⋀x41 x42. ⟦msg_fresh σ m; m = Newpkt x41 x42⟧ ⟹ msg_fresh σ' m›
3. ‹⋀x51 x52 x53. ⟦msg_fresh σ m; m = Pkt x51 x52 x53⟧ ⟹ msg_fresh σ' m›*)
fix dests and sip
assume [simp]: "m = Rerr dests sip" and "msg_fresh σ m" (*‹(m::msg) = Rerr (dests::nat ⇒ nat option) (sip::nat)› ‹msg_fresh (σ::nat ⇒ state) (m::msg)›*)
then have "*": "∀rip∈dom(dests). rip∈kD(rt (σ sip))
∧ the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip"
by simp
have "∀rip∈dom(dests). rip∈kD(rt (σ' sip))
∧ the (dests rip) - 1 ≤ nsqn (rt (σ' sip)) rip"
proof (standard)
(*goal: ‹⋀rip. rip ∈ dom dests ⟹ rip ∈ kD (rt (σ' sip)) ∧ the (dests rip) - 1 ≤ nsqn (rt (σ' sip)) rip›*)
fix rip
assume "rip∈dom(dests)" (*‹(rip::nat) ∈ dom (dests::nat ⇒ nat option)›*)
with "*" (*‹∀rip∈dom dests. rip ∈ kD (rt (σ sip)) ∧ the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip›*) have "rip∈kD(rt (σ sip))" and "the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip"
apply -
(*goals:
1. ‹⟦∀rip∈dom dests. rip ∈ kD (rt (σ sip)) ∧ the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip; rip ∈ dom dests⟧ ⟹ rip ∈ kD (rt (σ sip))›
2. ‹⟦∀rip∈dom dests. rip ∈ kD (rt (σ sip)) ∧ the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip; rip ∈ dom dests⟧ ⟹ the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip›
discuss goal 1*)
apply -
(*top goal: ‹⟦∀rip∈dom dests. rip ∈ kD (rt (σ sip)) ∧ the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip; rip ∈ dom dests⟧ ⟹ rip ∈ kD (rt (σ sip))› and 1 goal remains*)
apply (drule(1) bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))
(*top goal: ‹⟦∀rip∈dom dests. rip ∈ kD (rt (σ sip)) ∧ the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip; rip ∈ dom dests⟧ ⟹ rip ∈ kD (rt (σ sip))› and 1 goal remains*)
apply clarsimp
(*discuss goal 2*)
apply (drule(1) bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*))
(*goal: ‹⟦∀rip∈dom dests. rip ∈ kD (rt (σ sip)) ∧ the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip; rip ∈ dom dests⟧ ⟹ the (dests rip) - 1 ≤ nsqn (rt (σ sip)) rip›*)
apply clarsimp
(*proven 2 subgoals*) .
moreover from qinc (*‹∀j. quality_increases (σ j) (σ' j)›*) have "quality_increases (σ sip) (σ' sip)"
by simp
ultimately show "rip∈kD(rt (σ' sip)) ∧ the (dests rip) - 1 ≤ nsqn (rt (σ' sip)) rip"
by standard
qed
thus "?thesis"
(*goal: ‹msg_fresh σ' m›*)
by simp
qed (simp_all)
(*solves the remaining goals:
1. ‹⋀x41 x42. ⟦msg_fresh σ m; m = Newpkt x41 x42⟧ ⟹ msg_fresh σ' m›
2. ‹⋀x51 x52 x53. ⟦msg_fresh σ m; m = Pkt x51 x52 x53⟧ ⟹ msg_fresh σ' m›*)
end
| {
"path": "afp-2025-02-12/thys/AODV/Quality_Increases.thy",
"repo": "afp-2025-02-12",
"sha": "468208793b59d27d7ebfc79696bfbcffa2368c289ff3f955c55607cdcca43700"
} |
(* Title: HOL/Examples/Peirce.thy
Author: Makarius
*)
section ‹Peirce's Law›
theory Peirce
imports Main
begin
text ‹
We consider Peirce's Law: ‹((A ⟶ B) ⟶ A) ⟶ A›. This is an inherently
non-intuitionistic statement, so its proof will certainly involve some form
of classical contradiction.
The first proof is again a well-balanced combination of plain backward and
forward reasoning. The actual classical step is where the negated goal may
be introduced as additional assumption. This eventually leads to a
contradiction.⁋‹The rule involved there is negation elimination; it holds in
intuitionistic logic as well.››
theorem "((A ⟶ B) ⟶ A) ⟶ A"
proof (standard)
(*goal: ‹(A ⟶ B) ⟶ A ⟹ A›*)
assume "(A ⟶ B) ⟶ A" (*‹((A::bool) ⟶ (B::bool)) ⟶ A›*)
show A
proof (rule classical (*‹(¬ ?P ⟹ ?P) ⟹ ?P›*))
(*goal: ‹¬ A ⟹ A›*)
assume "¬ A" (*‹¬ (A::bool)›*)
have "A ⟶ B"
proof (standard)
(*goal: ‹A ⟹ B›*)
assume A (*‹A::bool›*)
with ‹¬ A› (*‹¬ A›*) show B
by contradiction
qed
with ‹(A ⟶ B) ⟶ A› (*‹(A ⟶ B) ⟶ A›*) show A
by standard
qed
qed
text ‹
In the subsequent version the reasoning is rearranged by means of ``weak
assumptions'' (as introduced by ⬚‹presume›). Before assuming the negated
goal ‹¬ A›, its intended consequence ‹A ⟶ B› is put into place in order to
solve the main problem. Nevertheless, we do not get anything for free, but
have to establish ‹A ⟶ B› later on. The overall effect is that of a logical
∗‹cut›.
Technically speaking, whenever some goal is solved by ⬚‹show› in the context
of weak assumptions then the latter give rise to new subgoals, which may be
established separately. In contrast, strong assumptions (as introduced by
⬚‹assume›) are solved immediately.
›
theorem "((A ⟶ B) ⟶ A) ⟶ A"
proof
assume "(A ⟶ B) ⟶ A"
show A
proof (rule classical)
presume "A ⟶ B"
with ‹(A ⟶ B) ⟶ A› show A ..
next
assume "¬ A"
show "A ⟶ B"
proof
assume A
with ‹¬ A› show B by contradiction
qed
qed
qed
text ‹
Note that the goals stemming from weak assumptions may be even left until
qed time, where they get eventually solved ``by assumption'' as well. In
that case there is really no fundamental difference between the two kinds of
assumptions, apart from the order of reducing the individual parts of the
proof configuration.
Nevertheless, the ``strong'' mode of plain assumptions is quite important in
practice to achieve robustness of proof text interpretation. By forcing both
the conclusion ∗‹and› the assumptions to unify with the pending goal to be
solved, goal selection becomes quite deterministic. For example,
decomposition with rules of the ``case-analysis'' type usually gives rise to
several goals that only differ in there local contexts. With strong
assumptions these may be still solved in any order in a predictable way,
while weak ones would quickly lead to great confusion, eventually demanding
even some backtracking.
›
end
| {
"path": "Isabelle2024/src/HOL/Examples/Peirce.thy",
"repo": "Isabelle2024",
"sha": "c1c14c7e5141c72a5bc12290b60239518d75b39babcf85b608fe3ace9773f33e"
} |
(* Title: HOL/Induct/ABexp.thy
Author: Stefan Berghofer, TU Muenchen
*)
section ‹Arithmetic and boolean expressions›
theory ABexp
imports Main
begin
datatype 'a aexp =
IF "'a bexp" "'a aexp" "'a aexp"
| Sum "'a aexp" "'a aexp"
| Diff "'a aexp" "'a aexp"
| Var 'a
| Num nat
and 'a bexp =
Less "'a aexp" "'a aexp"
| And "'a bexp" "'a bexp"
| Neg "'a bexp"
text ‹\medskip Evaluation of arithmetic and boolean expressions›
primrec evala :: "('a ⇒ nat) ⇒ 'a aexp ⇒ nat"
and evalb :: "('a ⇒ nat) ⇒ 'a bexp ⇒ bool"
where
"evala env (IF b a1 a2) = (if evalb env b then evala env a1 else evala env a2)"
| "evala env (Sum a1 a2) = evala env a1 + evala env a2"
| "evala env (Diff a1 a2) = evala env a1 - evala env a2"
| "evala env (Var v) = env v"
| "evala env (Num n) = n"
| "evalb env (Less a1 a2) = (evala env a1 < evala env a2)"
| "evalb env (And b1 b2) = (evalb env b1 ∧ evalb env b2)"
| "evalb env (Neg b) = (¬ evalb env b)"
text ‹\medskip Substitution on arithmetic and boolean expressions›
primrec substa :: "('a ⇒ 'b aexp) ⇒ 'a aexp ⇒ 'b aexp"
and substb :: "('a ⇒ 'b aexp) ⇒ 'a bexp ⇒ 'b bexp"
where
"substa f (IF b a1 a2) = IF (substb f b) (substa f a1) (substa f a2)"
| "substa f (Sum a1 a2) = Sum (substa f a1) (substa f a2)"
| "substa f (Diff a1 a2) = Diff (substa f a1) (substa f a2)"
| "substa f (Var v) = f v"
| "substa f (Num n) = Num n"
| "substb f (Less a1 a2) = Less (substa f a1) (substa f a2)"
| "substb f (And b1 b2) = And (substb f b1) (substb f b2)"
| "substb f (Neg b) = Neg (substb f b)"
lemma subst1_aexp:
"evala env (substa (Var (v := a')) a) = evala (env (v := evala env a')) a"
and subst1_bexp:
"evalb env (substb (Var (v := a')) b) = evalb (env (v := evala env a')) b"
― ‹one variable›
apply (induct a and b)
(*goals:
1. ‹⋀x1 x2 x3. ⟦evalb env (substb (Var(v := a')) x1) = evalb (env(v := evala env a')) x1; evala env (substa (Var(v := a')) x2) = evala (env(v := evala env a')) x2; evala env (substa (Var(v := a')) x3) = evala (env(v := evala env a')) x3⟧ ⟹ evala env (substa (Var(v := a')) (IF x1 x2 x3)) = evala (env(v := evala env a')) (IF x1 x2 x3)›
2. ‹⋀x1 x2. ⟦evala env (substa (Var(v := a')) x1) = evala (env(v := evala env a')) x1; evala env (substa (Var(v := a')) x2) = evala (env(v := evala env a')) x2⟧ ⟹ evala env (substa (Var(v := a')) (aexp.Sum x1 x2)) = evala (env(v := evala env a')) (aexp.Sum x1 x2)›
3. ‹⋀x1 x2. ⟦evala env (substa (Var(v := a')) x1) = evala (env(v := evala env a')) x1; evala env (substa (Var(v := a')) x2) = evala (env(v := evala env a')) x2⟧ ⟹ evala env (substa (Var(v := a')) (Diff x1 x2)) = evala (env(v := evala env a')) (Diff x1 x2)›
4. ‹⋀x. evala env (substa (Var(v := a')) (Var x)) = evala (env(v := evala env a')) (Var x)›
5. ‹⋀x. evala env (substa (Var(v := a')) (Num x)) = evala (env(v := evala env a')) (Num x)›
6. ‹⋀x1 x2. ⟦evala env (substa (Var(v := a')) x1) = evala (env(v := evala env a')) x1; evala env (substa (Var(v := a')) x2) = evala (env(v := evala env a')) x2⟧ ⟹ evalb env (substb (Var(v := a')) (Less x1 x2)) = evalb (env(v := evala env a')) (Less x1 x2)›
7. ‹⋀x1 x2. ⟦evalb env (substb (Var(v := a')) x1) = evalb (env(v := evala env a')) x1; evalb env (substb (Var(v := a')) x2) = evalb (env(v := evala env a')) x2⟧ ⟹ evalb env (substb (Var(v := a')) (And x1 x2)) = evalb (env(v := evala env a')) (And x1 x2)›
8. ‹⋀x. evalb env (substb (Var(v := a')) x) = evalb (env(v := evala env a')) x ⟹ evalb env (substb (Var(v := a')) (Neg x)) = evalb (env(v := evala env a')) (Neg x)›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*discuss goal 4*)
apply simp
(*discuss goal 5*)
apply simp
(*discuss goal 6*)
apply simp
(*discuss goal 7*)
apply simp
(*discuss goal 8*)
apply simp
(*proven 8 subgoals*) .
lemma subst_all_aexp:
"evala env (substa s a) = evala (λx. evala env (s x)) a"
and subst_all_bexp:
"evalb env (substb s b) = evalb (λx. evala env (s x)) b"
apply (induct a and b)
(*goals:
1. ‹⋀x1 x2 x3. ⟦evalb env (substb s x1) = evalb (λx. evala env (s x)) x1; evala env (substa s x2) = evala (λx. evala env (s x)) x2; evala env (substa s x3) = evala (λx. evala env (s x)) x3⟧ ⟹ evala env (substa s (IF x1 x2 x3)) = evala (λx. evala env (s x)) (IF x1 x2 x3)›
2. ‹⋀x1 x2. ⟦evala env (substa s x1) = evala (λx. evala env (s x)) x1; evala env (substa s x2) = evala (λx. evala env (s x)) x2⟧ ⟹ evala env (substa s (aexp.Sum x1 x2)) = evala (λx. evala env (s x)) (aexp.Sum x1 x2)›
3. ‹⋀x1 x2. ⟦evala env (substa s x1) = evala (λx. evala env (s x)) x1; evala env (substa s x2) = evala (λx. evala env (s x)) x2⟧ ⟹ evala env (substa s (Diff x1 x2)) = evala (λx. evala env (s x)) (Diff x1 x2)›
4. ‹⋀x. evala env (substa s (Var x)) = evala (λx. evala env (s x)) (Var x)›
5. ‹⋀x. evala env (substa s (Num x)) = evala (λx. evala env (s x)) (Num x)›
6. ‹⋀x1 x2. ⟦evala env (substa s x1) = evala (λx. evala env (s x)) x1; evala env (substa s x2) = evala (λx. evala env (s x)) x2⟧ ⟹ evalb env (substb s (Less x1 x2)) = evalb (λx. evala env (s x)) (Less x1 x2)›
7. ‹⋀x1 x2. ⟦evalb env (substb s x1) = evalb (λx. evala env (s x)) x1; evalb env (substb s x2) = evalb (λx. evala env (s x)) x2⟧ ⟹ evalb env (substb s (And x1 x2)) = evalb (λx. evala env (s x)) (And x1 x2)›
8. ‹⋀x. evalb env (substb s x) = evalb (λx. evala env (s x)) x ⟹ evalb env (substb s (Neg x)) = evalb (λx. evala env (s x)) (Neg x)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*discuss goal 6*)
apply ((auto)[1])
(*discuss goal 7*)
apply ((auto)[1])
(*discuss goal 8*)
apply ((auto)[1])
(*proven 8 subgoals*) .
end
| {
"path": "Isabelle2024/src/HOL/Induct/ABexp.thy",
"repo": "Isabelle2024",
"sha": "a28bbcb56938dabc6422a814f11b7ef0cf1b4eac2af802c49f51e991cfe53250"
} |
(* Title: JinjaThreads/JVM/JVMDefensive.thy
Author: Andreas Lochbihler
*)
section ‹Instantiating the framework semantics with the JVM›
theory JVMThreaded
imports
JVMDefensive
"../Common/ConformThreaded"
"../Framework/FWLiftingSem"
"../Framework/FWProgressAux"
begin
primrec JVM_final :: "'addr jvm_thread_state ⇒ bool"
where
"JVM_final (xcp, frs) = (frs = [])"
text‹The aggressive JVM›
context JVM_heap_base begin
abbreviation mexec ::
"'addr jvm_prog ⇒ 'thread_id ⇒ ('addr jvm_thread_state × 'heap)
⇒ ('addr, 'thread_id, 'heap) jvm_thread_action ⇒ ('addr jvm_thread_state × 'heap) ⇒ bool"
where
"mexec P t ≡ (λ((xcp, frstls), h) ta ((xcp', frstls'), h'). P,t ⊢ (xcp, h, frstls) -ta-jvm→ (xcp', h', frstls'))"
lemma NewThread_memory_exec_instr:
"⟦ (ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙ ⟧ ⟹ m = fst (snd s)"
apply ((cases I)[1])
(*goals:
1. ‹⋀x1. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = Load x1⟧ ⟹ m = fst (snd s)›
2. ‹⋀x2. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = Store x2⟧ ⟹ m = fst (snd s)›
3. ‹⋀x3. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = Push x3⟧ ⟹ m = fst (snd s)›
4. ‹⋀x4. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = New x4⟧ ⟹ m = fst (snd s)›
5. ‹⋀x5. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = NewArray x5⟧ ⟹ m = fst (snd s)›
6. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = ALoad⟧ ⟹ m = fst (snd s)›
7. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = AStore⟧ ⟹ m = fst (snd s)›
8. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = ALength⟧ ⟹ m = fst (snd s)›
9. ‹⋀x91 x92. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = Getfield x91 x92⟧ ⟹ m = fst (snd s)›
10. ‹⋀x101 x102. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = Putfield x101 x102⟧ ⟹ m = fst (snd s)›
11. ‹⋀x111 x112. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = CAS x111 x112⟧ ⟹ m = fst (snd s)›
12. ‹⋀x12. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = Checkcast x12⟧ ⟹ m = fst (snd s)›
13. ‹⋀x13. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = Instanceof x13⟧ ⟹ m = fst (snd s)›
14. ‹⋀x141 x142. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = Invoke x141 x142⟧ ⟹ m = fst (snd s)›
15. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = Return⟧ ⟹ m = fst (snd s)›
16. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = Pop⟧ ⟹ m = fst (snd s)›
17. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = Dup⟧ ⟹ m = fst (snd s)›
18. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = Swap⟧ ⟹ m = fst (snd s)›
19. ‹⋀x19. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = BinOpInstr x19⟧ ⟹ m = fst (snd s)›
20. ‹⋀x20. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = Goto x20⟧ ⟹ m = fst (snd s)›
21. ‹⋀x21. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = IfFalse x21⟧ ⟹ m = fst (snd s)›
22. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = ThrowExc⟧ ⟹ m = fst (snd s)›
23. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = MEnter⟧ ⟹ m = fst (snd s)›
24. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = MExit⟧ ⟹ m = fst (snd s)›
discuss goal 1*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 2*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 3*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 4*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 5*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 6*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 7*)
apply ((auto split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?obs::?'t::type interrupt_action list × ?'o::type list) (?lta::lock_action) (?l::?'l::type) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?nt::(?'t::type, ?'x::type, ?'m::type) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?j::?'t::type conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?ws::(?'t::type, ?'w::type) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?i::?'t::type interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?ob::?'o::type) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l::type) (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t::type, ?'x::type, ?'m::type) new_thread_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t::type conditional_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t::type, ?'w::type) wait_set_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t::type interrupt_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o::obs_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 8*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 9*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 10*)
apply ((auto split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 11*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 12*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 13*)
apply ((auto split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 14*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*top goal: ‹⋀x141 x142. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; I = Invoke x141 x142⟧ ⟹ m = fst (snd s)› and 10 goals remain*)
apply ((auto dest!: red_ext_aggr_new_thread_heap (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; NewThread ?t' ?ex ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ?h'' = ?h'›*) simp add: extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*) split: extCallRet.split (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))›*))[1])
(*discuss goal 15*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 16*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 17*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 18*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 19*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 20*)
apply ((auto split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 21*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 22*)
apply ((auto split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?obs::?'t::type interrupt_action list × ?'o::type list) (?lta::lock_action) (?l::?'l::type) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?nt::(?'t::type, ?'x::type, ?'m::type) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?j::?'t::type conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?ws::(?'t::type, ?'w::type) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?i::?'t::type interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?ob::?'o::type) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l::type) (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t::type, ?'x::type, ?'m::type) new_thread_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t::type conditional_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t::type, ?'w::type) wait_set_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t::type interrupt_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o::obs_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 23*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*))[1])
(*discuss goal 24*)
apply ((auto split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*))[1])
(*proven 24 subgoals*) .
lemma NewThread_memory_exec:
"⟦ P,t ⊢ σ -ta-jvm→ σ'; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙ ⟧ ⟹ m = (fst (snd σ'))"
apply (erule exec_1.cases (*‹⟦?P,?t ⊢ ?a1.0 -?a2.0-jvm→ ?a3.0; ⋀ta σ' σ. ⟦?a1.0 = σ; ?a2.0 = ta; ?a3.0 = σ'; (ta, σ') ∈ exec ?P ?t σ⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*))
(*goal: ‹⟦P,t ⊢ σ -ta-jvm→ σ'; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙⟧ ⟹ m = fst (snd σ')›*)
apply clarsimp
(*goal: ‹⋀taa σ'' σ'''. ⟦NewThread t' x m ∈ set ⦃ta⦄⇘t⇙; σ = σ'''; ta = taa; σ' = σ''; (taa, σ'') ∈ exec P t σ'''⟧ ⟹ m = fst (snd σ')›*)
apply (case_tac bb)
(*goals:
1. ‹⋀a aa ab ac ad b ae af ba ag ah bb. ⟦NewThread t' x m ∈ set aa; σ = (ag, ah, bb); ta = (a, aa, ab, ac, ad, b); σ' = (ae, af, ba); ((a, aa, ab, ac, ad, b), ae, af, ba) ∈ exec P t (ag, ah, bb); bb = []⟧ ⟹ m = af›
2. ‹⋀a aa ab ac ad b ae af ba ag ah bb ai list. ⟦NewThread t' x m ∈ set aa; σ = (ag, ah, bb); ta = (a, aa, ab, ac, ad, b); σ' = (ae, af, ba); ((a, aa, ab, ac, ad, b), ae, af, ba) ∈ exec P t (ag, ah, bb); bb = ai # list⟧ ⟹ m = af›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (case_tac ag)
(*goals:
1. ‹⋀a aa ab ac ad b ae af ba ag ah bb ai list. ⟦NewThread t' x m ∈ set aa; σ = (ag, ah, bb); ta = (a, aa, ab, ac, ad, b); σ' = (ae, af, ba); ((a, aa, ab, ac, ad, b), ae, af, ba) ∈ exec P t (ag, ah, bb); bb = ai # list; ag = None⟧ ⟹ m = af›
2. ‹⋀a aa ab ac ad b ae af ba ag ah bb ai list aj. ⟦NewThread t' x m ∈ set aa; σ = (ag, ah, bb); ta = (a, aa, ab, ac, ad, b); σ' = (ae, af, ba); ((a, aa, ab, ac, ad, b), ae, af, ba) ∈ exec P t (ag, ah, bb); bb = ai # list; ag = ⌊aj⌋⟧ ⟹ m = af›
discuss goal 1*)
apply ((auto simp add: exception_step_def_raw (*‹exception_step = (λP a h (stk, loc, C, M, pc) frs. case match_ex_table P (cname_of h a) pc (ex_table_of P C M) of None ⇒ (⌊a⌋, h, frs) | ⌊(pc', d)⌋ ⇒ (None, h, (Addr a # drop (length stk - d) stk, loc, C, M, pc') # frs))›*) split: list.split_asm (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*))[1])
(*top goal: ‹⋀a aa ab ac ad b ae af ba ag ah bb ai list. ⟦NewThread t' x m ∈ set aa; σ = (ag, ah, bb); ta = (a, aa, ab, ac, ad, b); σ' = (ae, af, ba); ((a, aa, ab, ac, ad, b), ae, af, ba) ∈ exec P t (ag, ah, bb); bb = ai # list; ag = None⟧ ⟹ m = af› and 1 goal remains*)
apply (drule NewThread_memory_exec_instr (*‹⟦(?ta, ?s) ∈ exec_instr ?I ?P ?t ?h ?stk ?loc ?C ?M ?pc ?frs; NewThread ?t' ?x ?m ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ?m = fst (snd ?s)›*))
(*goals:
1. ‹⋀a aa ab ac ad b ae af ba ah ai aj ak al bc list. ⟦NewThread t' x m ∈ set aa; σ = (None, ah, (ai, aj, ak, al, bc) # list); ta = (a, aa, ab, ac, ad, b); σ' = (ae, af, ba)⟧ ⟹ NewThread (?t'8 a aa ab ac ad b ae af ba ah ai aj ak al bc list) (?x8 a aa ab ac ad b ae af ba ah ai aj ak al bc list) (?m8 a aa ab ac ad b ae af ba ah ai aj ak al bc list) ∈ set ⦃(a, aa, ab, ac, ad, b)⦄⇘t⇙›
2. ‹⋀a aa ab ac ad b ae af ba ah ai aj ak al bc list. ⟦NewThread t' x m ∈ set aa; σ = (None, ah, (ai, aj, ak, al, bc) # list); ta = (a, aa, ab, ac, ad, b); σ' = (ae, af, ba); ?m8 a aa ab ac ad b ae af ba ah ai aj ak al bc list = fst (snd (ae, af, ba))⟧ ⟹ m = af›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*)
(*discuss goal 2*)
apply ((auto simp add: exception_step_def_raw (*‹exception_step = (λP a h (stk, loc, C, M, pc) frs. case match_ex_table P (cname_of h a) pc (ex_table_of P C M) of None ⇒ (⌊a⌋, h, frs) | ⌊(pc', d)⌋ ⇒ (None, h, (Addr a # drop (length stk - d) stk, loc, C, M, pc') # frs))›*) split: list.split_asm (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*))[1])
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
lemma exec_instr_Wakeup_no_Lock_no_Join_no_Interrupt:
"⟦ (ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙ ⟧
⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}"
apply (cases I)
(*goals:
1. ‹⋀x1. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = Load x1⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
2. ‹⋀x2. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = Store x2⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
3. ‹⋀x3. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = Push x3⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
4. ‹⋀x4. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = New x4⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
5. ‹⋀x5. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = NewArray x5⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
6. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = ALoad⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
7. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = AStore⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
8. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = ALength⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
9. ‹⋀x91 x92. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = Getfield x91 x92⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
10. ‹⋀x101 x102. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = Putfield x101 x102⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
11. ‹⋀x111 x112. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = CAS x111 x112⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
12. ‹⋀x12. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = Checkcast x12⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
13. ‹⋀x13. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = Instanceof x13⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
14. ‹⋀x141 x142. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = Invoke x141 x142⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
15. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = Return⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
16. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = Pop⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
17. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = Dup⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
18. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = Swap⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
19. ‹⋀x19. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = BinOpInstr x19⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
20. ‹⋀x20. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = Goto x20⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
21. ‹⋀x21. ⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = IfFalse x21⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
22. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = ThrowExc⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
23. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = MEnter⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
24. ‹⟦(ta, s) ∈ exec_instr I P t h stk loc C M pc frs; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; I = MExit⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›
discuss goal 1*)
apply ((auto split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?obs::?'t::type interrupt_action list × ?'o::type list) (?lta::lock_action) (?l::?'l::type) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?nt::(?'t::type, ?'x::type, ?'m::type) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?j::?'t::type conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?ws::(?'t::type, ?'w::type) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?i::?'t::type interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?ob::?'o::type) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l::type) (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t::type, ?'x::type, ?'m::type) new_thread_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t::type conditional_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t::type, ?'w::type) wait_set_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t::type interrupt_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o::obs_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta::('addr::addr, 'thread_id::type, 'heap::type) external_thread_action, ?va::'addr::addr extCallRet, ?h'::'heap::type) ∈ red_external_aggr (?P::?'a::type prog) (?t::'thread_id::type) (?a::'addr::addr) (?M::String.literal) (?vs::'addr::addr val list) (?h::'heap::type); Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 2*)
apply ((auto split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta::('addr, 'thread_id, 'heap) external_thread_action, ?va::'addr extCallRet, ?h'::'heap) ∈ red_external_aggr (?P::?'a prog) (?t::'thread_id) (?a::'addr) (?M::String.literal) (?vs::'addr val list) (?h::'heap); Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 3*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 4*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 5*)
apply ((auto split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?obs::?'t::type interrupt_action list × ?'o::type list) (?lta::lock_action) (?l::?'l::type) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?nt::(?'t::type, ?'x::type, ?'m::type) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?j::?'t::type conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?ws::(?'t::type, ?'w::type) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?i::?'t::type interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?ob::?'o::type) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l::type) (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t::type, ?'x::type, ?'m::type) new_thread_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t::type conditional_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t::type, ?'w::type) wait_set_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t::type interrupt_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o::obs_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta::('addr::addr, 'thread_id::type, 'heap::type) external_thread_action, ?va::'addr::addr extCallRet, ?h'::'heap::type) ∈ red_external_aggr (?P::?'a::type prog) (?t::'thread_id::type) (?a::'addr::addr) (?M::String.literal) (?vs::'addr::addr val list) (?h::'heap::type); Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 6*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 7*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 8*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 9*)
apply ((auto split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta::('addr, 'thread_id, 'heap) external_thread_action, ?va::'addr extCallRet, ?h'::'heap) ∈ red_external_aggr (?P::?'a prog) (?t::'thread_id) (?a::'addr) (?M::String.literal) (?vs::'addr val list) (?h::'heap); Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 10*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 11*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 12*)
apply ((auto split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta::('addr, 'thread_id, 'heap) external_thread_action, ?va::'addr extCallRet, ?h'::'heap) ∈ red_external_aggr (?P::?'a prog) (?t::'thread_id) (?a::'addr) (?M::String.literal) (?vs::'addr val list) (?h::'heap); Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 13*)
apply ((auto split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta::('addr, 'thread_id, 'heap) external_thread_action, ?va::'addr extCallRet, ?h'::'heap) ∈ red_external_aggr (?P::?'a prog) (?t::'thread_id) (?a::'addr) (?M::String.literal) (?vs::'addr val list) (?h::'heap); Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 14*)
apply ((auto split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta::('addr, 'thread_id, 'heap) external_thread_action, ?va::'addr extCallRet, ?h'::'heap) ∈ red_external_aggr (?P::?'a prog) (?t::'thread_id) (?a::'addr) (?M::String.literal) (?vs::'addr val list) (?h::'heap); Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 15*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 16*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 17*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 18*)
apply ((auto split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta::('addr, 'thread_id, 'heap) external_thread_action, ?va::'addr extCallRet, ?h'::'heap) ∈ red_external_aggr (?P::?'a prog) (?t::'thread_id) (?a::'addr) (?M::String.literal) (?vs::'addr val list) (?h::'heap); Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 19*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 20*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 21*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 22*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 23*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*discuss goal 24*)
apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) dest: red_external_aggr_Wakeup_no_Join (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))[1])
(*proven 24 subgoals*) .
lemma mexec_instr_Wakeup_no_Join:
"⟦ P,t ⊢ σ -ta-jvm→ σ'; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙ ⟧
⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}"
apply (erule exec_1.cases (*‹⟦?P,?t ⊢ ?a1.0 -?a2.0-jvm→ ?a3.0; ⋀ta σ' σ. ⟦?a1.0 = σ; ?a2.0 = ta; ?a3.0 = σ'; (ta, σ') ∈ exec ?P ?t σ⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*))
(*goal: ‹⟦P,t ⊢ σ -ta-jvm→ σ'; Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›*)
apply clarsimp
(*goal: ‹⋀taa σ'' σ'''. ⟦Notified ∈ set ⦃ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃ta⦄⇘w⇙; σ = σ'''; ta = taa; σ' = σ''; (taa, σ'') ∈ exec P t σ'''⟧ ⟹ collect_locks ⦃ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃ta⦄⇘i⇙ = {}›*)
apply (case_tac bb)
(*goals:
1. ‹⋀a aa ab ac ad b ae af ba ag ah bb. ⟦Notified ∈ set ac ∨ WokenUp ∈ set ac; σ = (ag, ah, bb); ta = (a, aa, ab, ac, ad, b); σ' = (ae, af, ba); ((a, aa, ab, ac, ad, b), ae, af, ba) ∈ exec P t (ag, ah, bb); bb = []⟧ ⟹ collect_locks a = {} ∧ (∀x. Join x ∉ set ab) ∧ collect_interrupts ad = {}›
2. ‹⋀a aa ab ac ad b ae af ba ag ah bb ai list. ⟦Notified ∈ set ac ∨ WokenUp ∈ set ac; σ = (ag, ah, bb); ta = (a, aa, ab, ac, ad, b); σ' = (ae, af, ba); ((a, aa, ab, ac, ad, b), ae, af, ba) ∈ exec P t (ag, ah, bb); bb = ai # list⟧ ⟹ collect_locks a = {} ∧ (∀x. Join x ∉ set ab) ∧ collect_interrupts ad = {}›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (case_tac ag)
(*goals:
1. ‹⋀a aa ab ac ad b ae af ba ag ah bb ai list. ⟦Notified ∈ set ac ∨ WokenUp ∈ set ac; σ = (ag, ah, bb); ta = (a, aa, ab, ac, ad, b); σ' = (ae, af, ba); ((a, aa, ab, ac, ad, b), ae, af, ba) ∈ exec P t (ag, ah, bb); bb = ai # list; ag = None⟧ ⟹ collect_locks a = {} ∧ (∀x. Join x ∉ set ab) ∧ collect_interrupts ad = {}›
2. ‹⋀a aa ab ac ad b ae af ba ag ah bb ai list aj. ⟦Notified ∈ set ac ∨ WokenUp ∈ set ac; σ = (ag, ah, bb); ta = (a, aa, ab, ac, ad, b); σ' = (ae, af, ba); ((a, aa, ab, ac, ad, b), ae, af, ba) ∈ exec P t (ag, ah, bb); bb = ai # list; ag = ⌊aj⌋⟧ ⟹ collect_locks a = {} ∧ (∀x. Join x ∉ set ab) ∧ collect_interrupts ad = {}›
discuss goal 1*)
apply (clarsimp simp add: exception_step_def_raw (*‹exception_step = (λP a h (stk, loc, C, M, pc) frs. case match_ex_table P (cname_of h a) pc (ex_table_of P C M) of None ⇒ (⌊a⌋, h, frs) | ⌊(pc', d)⌋ ⇒ (None, h, (Addr a # drop (length stk - d) stk, loc, C, M, pc') # frs))›*) split: list.split_asm (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = (¬ (?list = [] ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22. ?list = x21 # x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*) del: disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*top goal: ‹⋀(a::'addr lock_actions) (aa::('thread_id, 'addr option × 'addr frame list, 'heap) new_thread_action list) (ab::'thread_id conditional_action list) (ac::('thread_id, 'addr) wait_set_action list) (ad::'thread_id interrupt_action list) (b::('addr, 'thread_id) obs_event list) (ae::'addr option) (af::'heap) (ba::'addr frame list) (ag::'addr option) (ah::'heap) (bb::'addr frame list) (ai::'addr frame) list::'addr frame list. ⟦Notified ∈ set ac ∨ WokenUp ∈ set ac; (σ::'addr option × 'heap × 'addr frame list) = (ag, ah, bb); (ta::('addr, 'thread_id, 'heap) jvm_thread_action) = (a, aa, ab, ac, ad, b); (σ'::'addr option × 'heap × 'addr frame list) = (ae, af, ba); ((a, aa, ab, ac, ad, b), ae, af, ba) ∈ exec (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (ag, ah, bb); bb = ai # list; ag = None⟧ ⟹ collect_locks a = {} ∧ (∀x::'thread_id. Join x ∉ set ab) ∧ collect_interrupts ad = {}› and 1 goal remains*)
apply (drule exec_instr_Wakeup_no_Lock_no_Join_no_Interrupt (*‹⟦(?ta, ?s) ∈ exec_instr ?I ?P ?t ?h ?stk ?loc ?C ?M ?pc ?frs; Notified ∈ set ⦃?ta⦄⇘w⇙ ∨ WokenUp ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ collect_locks ⦃?ta⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃?ta⦄⇘c⇙ = {} ∧ collect_interrupts ⦃?ta⦄⇘i⇙ = {}›*))
(*goals:
1. ‹⋀a aa ab ac ad b ae af ba ah ai aj ak al bc list. ⟦Notified ∈ set ac ∨ WokenUp ∈ set ac; σ = (None, ah, (ai, aj, ak, al, bc) # list); ta = (a, aa, ab, ac, ad, b); σ' = (ae, af, ba)⟧ ⟹ Notified ∈ set ⦃(a, aa, ab, ac, ad, b)⦄⇘w⇙ ∨ WokenUp ∈ set ⦃(a, aa, ab, ac, ad, b)⦄⇘w⇙›
2. ‹⋀a aa ab ac ad b ae af ba ah ai aj ak al bc list. ⟦Notified ∈ set ac ∨ WokenUp ∈ set ac; σ = (None, ah, (ai, aj, ak, al, bc) # list); ta = (a, aa, ab, ac, ad, b); σ' = (ae, af, ba); collect_locks ⦃(a, aa, ab, ac, ad, b)⦄⇘l⇙ = {} ∧ collect_cond_actions ⦃(a, aa, ab, ac, ad, b)⦄⇘c⇙ = {} ∧ collect_interrupts ⦃(a, aa, ab, ac, ad, b)⦄⇘i⇙ = {}⟧ ⟹ collect_locks a = {} ∧ (∀x. Join x ∉ set ab) ∧ collect_interrupts ad = {}›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*)
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
lemma mexec_final:
"⟦ mexec P t (x, m) ta (x', m'); JVM_final x ⟧ ⟹ False"
apply (cases x)
(*goal: ‹⟦mexec P t (x, m) ta (x', m'); JVM_final x⟧ ⟹ False›*)
by (auto simp add: exec_1_iff (*‹?P,?t ⊢ ?σ -?ta-jvm→ ?σ' = ((?ta, ?σ') ∈ exec ?P ?t ?σ)›*))
lemma exec_mthr: "multithreaded JVM_final (mexec P)"
apply unfold_locales
(*goals:
1. ‹⋀t s ta s' t' x m. ⟦mexec P t s ta s'; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙⟧ ⟹ m = snd s'›
2. ‹⋀t x m ta x' m'. ⟦mexec P t (x, m) ta (x', m'); JVM_final x⟧ ⟹ False›
discuss goal 1*)
apply clarsimp
(*top goal: ‹⋀t s ta s' t' x m. ⟦mexec P t s ta s'; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙⟧ ⟹ m = snd s'› and 1 goal remains*)
apply (drule NewThread_memory_exec (*‹⟦?P,?t ⊢ ?σ -?ta-jvm→ ?σ'; NewThread ?t' ?x ?m ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ?m = fst (snd ?σ')›*))
(*goals:
1. ‹⋀t a b ba aa ab ac ad ae bb af bc bd t' ag be m. NewThread t' (ag, be) m ∈ set ab ⟹ NewThread (?t'3 t a b ba aa ab ac ad ae bb af bc bd t' ag be m) (?x3 t a b ba aa ab ac ad ae bb af bc bd t' ag be m) (?m3 t a b ba aa ab ac ad ae bb af bc bd t' ag be m) ∈ set ⦃(aa, ab, ac, ad, ae, bb)⦄⇘t⇙›
2. ‹⋀t a b ba aa ab ac ad ae bb af bc bd t' ag be m. ⟦NewThread t' (ag, be) m ∈ set ab; ?m3 t a b ba aa ab ac ad ae bb af bc bd t' ag be m = fst (snd (af, bd, bc))⟧ ⟹ m = bd›
discuss goal 1*)
apply fastforce
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*)
(*discuss goal 2*)
apply (erule (1) mexec_final (*‹⟦mexec ?P ?t (?x, ?m) ?ta (?x', ?m'); JVM_final ?x⟧ ⟹ False›*))
(*proven 2 subgoals*) .
end
sublocale JVM_heap_base < exec_mthr:
multithreaded
JVM_final
"mexec P"
convert_RA
for P
by (rule exec_mthr (*‹multithreaded JVM_final (mexec ?P)›*))
context JVM_heap_base begin
abbreviation mexecT ::
"'addr jvm_prog
⇒ ('addr,'thread_id,'addr jvm_thread_state,'heap,'addr) state
⇒ 'thread_id × ('addr, 'thread_id, 'heap) jvm_thread_action
⇒ ('addr,'thread_id,'addr jvm_thread_state,'heap,'addr) state ⇒ bool"
where
"mexecT P ≡ exec_mthr.redT P"
abbreviation mexecT_syntax1 ::
"'addr jvm_prog ⇒ ('addr,'thread_id,'addr jvm_thread_state,'heap,'addr) state
⇒ 'thread_id ⇒ ('addr, 'thread_id, 'heap) jvm_thread_action
⇒ ('addr,'thread_id,'addr jvm_thread_state,'heap,'addr) state ⇒ bool"
("_ ⊢ _ -_▹_→⇘jvm⇙ _" [50,0,0,0,50] 80)
where
"mexecT_syntax1 P s t ta s' ≡ mexecT P s (t, ta) s'"
abbreviation mExecT_syntax1 ::
"'addr jvm_prog ⇒ ('addr,'thread_id,'addr jvm_thread_state,'heap,'addr) state
⇒ ('thread_id × ('addr, 'thread_id, 'heap) jvm_thread_action) list
⇒ ('addr,'thread_id,'addr jvm_thread_state,'heap,'addr) state ⇒ bool"
("_ ⊢ _ -▹_→⇘jvm⇙* _" [50,0,0,50] 80)
where
"P ⊢ s -▹ttas→⇘jvm⇙* s' ≡ exec_mthr.RedT P s ttas s'"
text‹The defensive JVM›
abbreviation mexecd ::
"'addr jvm_prog ⇒ 'thread_id ⇒ 'addr jvm_thread_state × 'heap
⇒ ('addr, 'thread_id, 'heap) jvm_thread_action ⇒ 'addr jvm_thread_state × 'heap ⇒ bool"
where
"mexecd P t ≡ (λ((xcp, frstls), h) ta ((xcp', frstls'), h'). P,t ⊢ Normal (xcp, h, frstls) -ta-jvmd→ Normal (xcp', h', frstls'))"
lemma execd_mthr: "multithreaded JVM_final (mexecd P)"
apply unfold_locales
(*goals:
1. ‹⋀t s ta s' t' x m. ⟦mexecd P t s ta s'; NewThread t' x m ∈ set ⦃ta⦄⇘t⇙⟧ ⟹ m = snd s'›
2. ‹⋀t x m ta x' m'. ⟦mexecd P t (x, m) ta (x', m'); JVM_final x⟧ ⟹ False›
discuss goal 1*)
apply (fastforce dest: defensive_imp_aggressive_1 (*‹?P,?t ⊢ Normal ?σ -?tas-jvmd→ Normal ?σ' ⟹ ?P,?t ⊢ ?σ -?tas-jvm→ ?σ'›*) NewThread_memory_exec (*‹⟦?P,?t ⊢ ?σ -?ta-jvm→ ?σ'; NewThread ?t' ?x ?m ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ?m = fst (snd ?σ')›*))
(*discuss goal 2*)
apply (auto elim: jvmd_NormalE (*‹⟦(?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),?t::'thread_id ⊢ Normal (?σ::'addr option × 'heap × 'addr frame list) -?ta::('addr, 'thread_id, 'heap) jvm_thread_action-jvmd→ Normal (?σ'::'addr option × 'heap × 'addr frame list); ⋀(xcp::'addr option) (h::'heap) (f::'addr frame) frs::'addr frame list. ⟦check ?P ?σ; (?ta, ?σ') ∈ exec ?P ?t ?σ; ?σ = (xcp, h, f # frs)⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*))
(*proven 2 subgoals*) .
end
sublocale JVM_heap_base < execd_mthr:
multithreaded
JVM_final
"mexecd P"
convert_RA
for P
by (rule execd_mthr (*‹multithreaded JVM_final (mexecd ?P)›*))
context JVM_heap_base begin
abbreviation mexecdT ::
"'addr jvm_prog ⇒ ('addr,'thread_id,'addr jvm_thread_state,'heap,'addr) state
⇒ 'thread_id × ('addr, 'thread_id, 'heap) jvm_thread_action
⇒ ('addr,'thread_id,'addr jvm_thread_state,'heap,'addr) state ⇒ bool"
where
"mexecdT P ≡ execd_mthr.redT P"
abbreviation mexecdT_syntax1 ::
"'addr jvm_prog ⇒ ('addr,'thread_id,'addr jvm_thread_state,'heap,'addr) state
⇒ 'thread_id ⇒ ('addr, 'thread_id, 'heap) jvm_thread_action
⇒ ('addr,'thread_id,'addr jvm_thread_state,'heap,'addr) state ⇒ bool"
("_ ⊢ _ -_▹_→⇘jvmd⇙ _" [50,0,0,0,50] 80)
where
"mexecdT_syntax1 P s t ta s' ≡ mexecdT P s (t, ta) s'"
abbreviation mExecdT_syntax1 ::
"'addr jvm_prog ⇒ ('addr,'thread_id,'addr jvm_thread_state,'heap,'addr) state
⇒ ('thread_id × ('addr, 'thread_id, 'heap) jvm_thread_action) list
⇒ ('addr,'thread_id,'addr jvm_thread_state,'heap,'addr) state ⇒ bool"
("_ ⊢ _ -▹_→⇘jvmd⇙* _" [50,0,0,50] 80)
where
"P ⊢ s -▹ttas→⇘jvmd⇙* s' ≡ execd_mthr.RedT P s ttas s'"
lemma mexecd_Suspend_Invoke:
"⟦ mexecd P t (x, m) ta (x', m'); Suspend w ∈ set ⦃ta⦄⇘w⇙ ⟧
⟹ ∃stk loc C M pc frs' n a T Ts Tr D. x' = (None, (stk, loc, C, M, pc) # frs') ∧ instrs_of P C M ! pc = Invoke wait n ∧ stk ! n = Addr a ∧ typeof_addr m a = ⌊T⌋ ∧ P ⊢ class_type_of T sees wait:Ts→Tr = Native in D ∧ D∙wait(Ts) :: Tr"
apply (cases x')
(*goal: ‹⟦execd_mthr.r_syntax P t x m ta x' m'; Suspend w ∈ set ⦃ta⦄⇘w⇙⟧ ⟹ ∃stk loc C M pc frs' n a T Ts Tr D. x' = (None, (stk, loc, C, M, pc) # frs') ∧ instrs_of P C M ! pc = Invoke wait n ∧ stk ! n = Addr a ∧ typeof_addr m a = ⌊T⌋ ∧ P ⊢ class_type_of T sees wait: Ts→Tr = Native in D ∧ D∙wait(Ts) :: Tr›*)
apply (cases x)
(*goal: ‹⋀a b. ⟦execd_mthr.r_syntax P t x m ta x' m'; Suspend w ∈ set ⦃ta⦄⇘w⇙; x' = (a, b)⟧ ⟹ ∃stk loc C M pc frs' n a T Ts Tr D. x' = (None, (stk, loc, C, M, pc) # frs') ∧ instrs_of P C M ! pc = Invoke wait n ∧ stk ! n = Addr a ∧ typeof_addr m a = ⌊T⌋ ∧ P ⊢ class_type_of T sees wait: Ts→Tr = Native in D ∧ D∙wait(Ts) :: Tr›*)
apply (cases "fst x")
(*goal: ‹⋀(a::'addr::addr option) (b::'addr::addr frame list) (aa::'addr::addr option) ba::'addr::addr frame list. ⟦execd_mthr.r_syntax (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (x::'addr::addr option × 'addr::addr frame list) (m::'heap::type) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (x'::'addr::addr option × 'addr::addr frame list) (m'::'heap::type); Suspend (w::'addr::addr) ∈ set ⦃ta⦄⇘w⇙; x' = (a, b); x = (aa, ba)⟧ ⟹ ∃(stk::'addr::addr val list) (loc::'addr::addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs'::'addr::addr frame list) (n::nat) (a::'addr::addr) (T::htype) (Ts::ty list) (Tr::ty) D::String.literal. x' = (None, (stk, loc, C, M, pc) # frs') ∧ instrs_of P C M ! pc = Invoke wait n ∧ stk ! n = Addr a ∧ (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) m a = ⌊T⌋ ∧ P ⊢ class_type_of T sees wait: Ts→Tr = Native in D ∧ D∙wait(Ts) :: Tr›*)
apply (auto elim!: jvmd_NormalE (*‹⟦(?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),?t::'thread_id ⊢ Normal (?σ::'addr option × 'heap × 'addr frame list) -?ta::('addr, 'thread_id, 'heap) jvm_thread_action-jvmd→ Normal (?σ'::'addr option × 'heap × 'addr frame list); ⋀(xcp::'addr option) (h::'heap) (f::'addr frame) frs::'addr frame list. ⟦check ?P ?σ; (?ta, ?σ') ∈ exec ?P ?t ?σ; ?σ = (xcp, h, f # frs)⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*))
(*top goal: ‹⋀a b aa ba. ⟦execd_mthr.r_syntax P t x m ta x' m'; Suspend w ∈ set ⦃ta⦄⇘w⇙; x' = (a, b); x = (aa, ba); fst x = None⟧ ⟹ ∃stk loc C M pc frs' n a T Ts Tr D. x' = (None, (stk, loc, C, M, pc) # frs') ∧ instrs_of P C M ! pc = Invoke wait n ∧ stk ! n = Addr a ∧ typeof_addr m a = ⌊T⌋ ∧ P ⊢ class_type_of T sees wait: Ts→Tr = Native in D ∧ D∙wait(Ts) :: Tr› and 1 goal remains*)
apply (rename_tac [!] stk loc C M pc frs)
(*top goal: ‹⋀(a::'addr::addr option) (b::'addr::addr frame list) (ab::'addr::addr val list) (ac::'addr::addr val list) (ad::String.literal) (ae::String.literal) (bb::nat) frs::'addr::addr frame list. ⟦Suspend (w::'addr::addr) ∈ set ⦃ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action⦄⇘w⇙; (x'::'addr::addr option × 'addr::addr frame list) = (a, b); (x::'addr::addr option × 'addr::addr frame list) = (None, (ab, ac, ad, ae, bb) # frs); check (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (None, m::'heap::type, (ab, ac, ad, ae, bb) # frs); (ta, a, m'::'heap::type, b) ∈ exec_instr (instrs_of P ad ae ! bb) P (t::'thread_id::type) m ab ac ad ae bb frs⟧ ⟹ a = None› and 1 goal remains*)
apply (case_tac [!] "instrs_of P C M ! pc")
(*top goal: ‹⋀a b stk loc C M pc frs. ⟦Suspend w ∈ set ⦃ta⦄⇘w⇙; x' = (a, b); x = (None, (stk, loc, C, M, pc) # frs); check P (None, m, (stk, loc, C, M, pc) # frs); (ta, a, m', b) ∈ exec_instr (instrs_of P C M ! pc) P t m stk loc C M pc frs⟧ ⟹ a = None› and 1 goal remains*)
apply (auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) check_def (*‹check ?P ?σ ≡ let (xcpt, h, frs) = ?σ in case frs of [] ⇒ True | (stk, loc, C, M, pc) # frs' ⇒ ?P ⊢ C has M ∧ (let (C', Ts, T, meth) = method ?P C M; (mxs, mxl₀, ins, xt) = the meth; i = ins ! pc in meth ≠ None ∧ pc < length ins ∧ length stk ≤ mxs ∧ (case xcpt of None ⇒ check_instr i ?P h stk loc C M pc frs' | ⌊a⌋ ⇒ check_xcpt ?P h (length stk) pc xt a))›*) is_Ref_def (*‹is_Ref ?v ≡ ?v = Null ∨ is_Addr ?v›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*))
(*top goal: ‹⋀a b stk loc C M pc frs x1. ⟦Suspend w ∈ set ⦃ta⦄⇘w⇙; x' = (a, b); x = (None, (stk, loc, C, M, pc) # frs); check P (None, m, (stk, loc, C, M, pc) # frs); (ta, a, m', b) ∈ exec_instr (instrs_of P C M ! pc) P t m stk loc C M pc frs; instrs_of P C M ! pc = Load x1⟧ ⟹ a = None› and 47 goals remain*)
by ((frule red_external_aggr_Suspend_StaySame (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Suspend ?w ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ ?va = RetStaySame›*), simp, drule red_external_aggr_Suspend_waitD (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h; Suspend ?w ∈ set ⦃?ta⦄⇘w⇙⟧ ⟹ ?M = wait›*), simp, fastforce)+)
end
context JVM_heap begin
lemma exec_instr_New_Thread_exists_thread_object:
"⟦ (ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs;
check_instr ins P h stk loc C M pc frs;
NewThread t' x h'' ∈ set ⦃ta⦄⇘t⇙ ⟧
⟹ ∃C. typeof_addr h' (thread_id2addr t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread"
apply (cases ins)
(*goals:
1. ‹⋀x1::nat. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = Load x1⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
2. ‹⋀x2::nat. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = Store x2⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
3. ‹⋀x3::'addr val. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = Push x3⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
4. ‹⋀x4::String.literal. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = New x4⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
5. ‹⋀x5::ty. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = NewArray x5⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
6. ‹⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = ALoad⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
7. ‹⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = AStore⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
8. ‹⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = ALength⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
9. ‹⋀(x91::String.literal) x92::String.literal. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = Getfield x91 x92⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
10. ‹⋀(x101::String.literal) x102::String.literal. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = Putfield x101 x102⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
11. ‹⋀(x111::String.literal) x112::String.literal. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = CAS x111 x112⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
12. ‹⋀x12::ty. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = Checkcast x12⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
13. ‹⋀x13::ty. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = Instanceof x13⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
14. ‹⋀(x141::String.literal) x142::nat. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = Invoke x141 x142⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
15. ‹⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = Return⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
16. ‹⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = Pop⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
17. ‹⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = Dup⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
18. ‹⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = Swap⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
19. ‹⋀x19::bop. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = BinOpInstr x19⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
20. ‹⋀x20::int. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = Goto x20⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
21. ‹⋀x21::int. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = IfFalse x21⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
22. ‹⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = ThrowExc⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
23. ‹⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = MEnter⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
24. ‹⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, frs'::'addr frame list) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list); check_instr ins P h stk loc C M pc frs; NewThread (t'::'thread_id) (x::'addr option × 'addr frame list) (h''::'heap) ∈ set ⦃ta⦄⇘t⇙; ins = MExit⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) h' ((thread_id2addr::'thread_id ⇒ 'addr) t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
discuss goal 1*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 2*)
apply (fastforce simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta::('addr, 'thread_id, 'heap) external_thread_action, ?va::'addr extCallRet, ?h'::'heap) ∈ red_external_aggr (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?a::'addr) (?M::String.literal) (?vs::'addr val list) (?h::'heap); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h ?a ≠ None; NewThread (?t'::'thread_id) (?x::String.literal × String.literal × 'addr) (?h''::'heap) ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C::String.literal. typeof_addr ?h' ((thread_id2addr::'thread_id ⇒ 'addr) ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 3*)
apply (fastforce simp add: split_beta (*‹(case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?obs::?'t::type interrupt_action list × ?'o::type list) (?lta::lock_action) (?l::?'l::type) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?nt::(?'t::type, ?'x::type, ?'m::type) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?j::?'t::type conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?ws::(?'t::type, ?'w::type) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?i::?'t::type interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?ob::?'o::type) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l::type) (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t::type, ?'x::type, ?'m::type) new_thread_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t::type conditional_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t::type, ?'w::type) wait_set_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t::type interrupt_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o::obs_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta::('addr::addr, 'thread_id::type, 'heap::type) external_thread_action, ?va::'addr::addr extCallRet, ?h'::'heap::type) ∈ red_external_aggr (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id::type) (?a::'addr::addr) (?M::String.literal) (?vs::'addr::addr val list) (?h::'heap::type); (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) ?h ?a ≠ None; NewThread (?t'::'thread_id::type) (?x::String.literal × String.literal × 'addr::addr) (?h''::'heap::type) ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C::String.literal. typeof_addr ?h' ((thread_id2addr::'thread_id::type ⇒ 'addr::addr) ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 4*)
apply (fastforce simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta::('addr, 'thread_id, 'heap) external_thread_action, ?va::'addr extCallRet, ?h'::'heap) ∈ red_external_aggr (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?a::'addr) (?M::String.literal) (?vs::'addr val list) (?h::'heap); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h ?a ≠ None; NewThread (?t'::'thread_id) (?x::String.literal × String.literal × 'addr) (?h''::'heap) ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C::String.literal. typeof_addr ?h' ((thread_id2addr::'thread_id ⇒ 'addr) ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 5*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 6*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 7*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 8*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 9*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 10*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 11*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 12*)
apply (fastforce simp add: split_beta (*‹(case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?obs::?'t::type interrupt_action list × ?'o::type list) (?lta::lock_action) (?l::?'l::type) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?nt::(?'t::type, ?'x::type, ?'m::type) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?j::?'t::type conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?ws::(?'t::type, ?'w::type) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?i::?'t::type interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l::type lock_actions, ?nts::(?'t::type, ?'x::type, ?'m::type) new_thread_action list, ?js::?'t::type conditional_action list, ?wss::(?'t::type, ?'w::type) wait_set_action list, ?is::?'t::type interrupt_action list, ?obs::?'o::type list) (?ob::?'o::type) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l::type) (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t::type, ?'x::type, ?'m::type) new_thread_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t::type conditional_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t::type, ?'w::type) wait_set_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t::type interrupt_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o::obs_action (?ta::(?'l::type, ?'t::type, ?'x::type, ?'m::type, ?'w::type, ?'o::obs_action) thread_action) = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta::('addr::addr, 'thread_id::type, 'heap::type) external_thread_action, ?va::'addr::addr extCallRet, ?h'::'heap::type) ∈ red_external_aggr (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id::type) (?a::'addr::addr) (?M::String.literal) (?vs::'addr::addr val list) (?h::'heap::type); (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) ?h ?a ≠ None; NewThread (?t'::'thread_id::type) (?x::String.literal × String.literal × 'addr::addr) (?h''::'heap::type) ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C::String.literal. typeof_addr ?h' ((thread_id2addr::'thread_id::type ⇒ 'addr::addr) ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 13*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 14*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 15*)
apply (fastforce simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta::('addr, 'thread_id, 'heap) external_thread_action, ?va::'addr extCallRet, ?h'::'heap) ∈ red_external_aggr (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?a::'addr) (?M::String.literal) (?vs::'addr val list) (?h::'heap); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h ?a ≠ None; NewThread (?t'::'thread_id) (?x::String.literal × String.literal × 'addr) (?h''::'heap) ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C::String.literal. typeof_addr ?h' ((thread_id2addr::'thread_id ⇒ 'addr) ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 16*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 17*)
apply (fastforce simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta::('addr, 'thread_id, 'heap) external_thread_action, ?va::'addr extCallRet, ?h'::'heap) ∈ red_external_aggr (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?a::'addr) (?M::String.literal) (?vs::'addr val list) (?h::'heap); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h ?a ≠ None; NewThread (?t'::'thread_id) (?x::String.literal × String.literal × 'addr) (?h''::'heap) ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C::String.literal. typeof_addr ?h' ((thread_id2addr::'thread_id ⇒ 'addr) ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 18*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 19*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 20*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 21*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 22*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 23*)
apply (fastforce simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls, ?nts, ?js, ?wss, ?obs) ?lta ?l = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?nt = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?j = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ws = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?i = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls, ?nts, ?js, ?wss, ?is, ?obs) ?ob = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la, ?l) ?ta = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt ?ta = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca ?ta = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa ?ta = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia ?ta = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob ?ta = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; typeof_addr ?h ?a ≠ None; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*discuss goal 24*)
apply (fastforce simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) intro: red_external_aggr_new_thread_exists_thread_object (*‹⟦(?ta::('addr, 'thread_id, 'heap) external_thread_action, ?va::'addr extCallRet, ?h'::'heap) ∈ red_external_aggr (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?a::'addr) (?M::String.literal) (?vs::'addr val list) (?h::'heap); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h ?a ≠ None; NewThread (?t'::'thread_id) (?x::String.literal × String.literal × 'addr) (?h''::'heap) ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C::String.literal. typeof_addr ?h' ((thread_id2addr::'thread_id ⇒ 'addr) ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))
(*proven 24 subgoals*) .
lemma exec_New_Thread_exists_thread_object:
"⟦ P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h', frs'); NewThread t' x h'' ∈ set ⦃ta⦄⇘t⇙ ⟧
⟹ ∃C. typeof_addr h' (thread_id2addr t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread"
apply (cases xcp)
(*goals:
1. ‹⟦P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h', frs'); NewThread t' x h'' ∈ set ⦃ta⦄⇘t⇙; xcp = None⟧ ⟹ ∃C. typeof_addr h' (thread_id2addr t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
2. ‹⋀a. ⟦P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h', frs'); NewThread t' x h'' ∈ set ⦃ta⦄⇘t⇙; xcp = ⌊a⌋⟧ ⟹ ∃C. typeof_addr h' (thread_id2addr t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
discuss goal 1*)
apply ((case_tac [!] frs)[1])
(*goals:
1. ‹⟦P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h', frs'); NewThread t' x h'' ∈ set ⦃ta⦄⇘t⇙; xcp = None; frs = []⟧ ⟹ ∃C. typeof_addr h' (thread_id2addr t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
2. ‹⋀a list. ⟦P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h', frs'); NewThread t' x h'' ∈ set ⦃ta⦄⇘t⇙; xcp = None; frs = a # list⟧ ⟹ ∃C. typeof_addr h' (thread_id2addr t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
discuss goal 1*)
apply ((auto simp add: check_def (*‹check (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?σ::'addr option × 'heap × 'addr frame list) ≡ let (xcpt::'addr option, h::'heap, frs::'addr frame list) = ?σ in case frs of [] ⇒ True | (stk::'addr val list, loc::'addr val list, C::String.literal, M::String.literal, pc::nat) # (frs'::'addr frame list) ⇒ ?P ⊢ C has M ∧ (let (C'::String.literal, Ts::ty list, T::ty, meth::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) option) = method ?P C M; (mxs::nat, mxl₀::nat, ins::'addr instr list, xt::(nat × nat × String.literal option × nat × nat) list) = the meth; i::'addr instr = ins ! pc in meth ≠ None ∧ pc < length ins ∧ length stk ≤ mxs ∧ (case xcpt of None ⇒ check_instr i ?P h stk loc C M pc frs' | ⌊a::'addr⌋ ⇒ check_xcpt ?P h (length stk) pc xt a))›*) elim!: jvmd_NormalE (*‹⟦(?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),?t::'thread_id ⊢ Normal (?σ::'addr option × 'heap × 'addr frame list) -?ta::('addr, 'thread_id, 'heap) jvm_thread_action-jvmd→ Normal (?σ'::'addr option × 'heap × 'addr frame list); ⋀(xcp::'addr option) (h::'heap) (f::'addr frame) frs::'addr frame list. ⟦check ?P ?σ; (?ta, ?σ') ∈ exec ?P ?t ?σ; ?σ = (xcp, h, f # frs)⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) dest!: exec_instr_New_Thread_exists_thread_object (*‹⟦(?ta::('addr, 'thread_id, 'heap) jvm_thread_action, ?xcp'::'addr option, ?h'::'heap, ?frs'::'addr frame list) ∈ exec_instr (?ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?h::'heap) (?stk::'addr val list) (?loc::'addr val list) (?C::String.literal) (?M::String.literal) (?pc::nat) (?frs::'addr frame list); check_instr ?ins P ?h ?stk ?loc ?C ?M ?pc ?frs; NewThread (?t'::'thread_id) (?x::'addr option × 'addr frame list) (?h''::'heap) ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h' ((thread_id2addr::'thread_id ⇒ 'addr) ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))[1])
(*discuss goal 2*)
apply ((auto simp add: check_def (*‹check ?P ?σ ≡ let (xcpt, h, frs) = ?σ in case frs of [] ⇒ True | (stk, loc, C, M, pc) # frs' ⇒ ?P ⊢ C has M ∧ (let (C', Ts, T, meth) = method ?P C M; (mxs, mxl₀, ins, xt) = the meth; i = ins ! pc in meth ≠ None ∧ pc < length ins ∧ length stk ≤ mxs ∧ (case xcpt of None ⇒ check_instr i ?P h stk loc C M pc frs' | ⌊a⌋ ⇒ check_xcpt ?P h (length stk) pc xt a))›*) elim!: jvmd_NormalE (*‹⟦?P,?t ⊢ Normal ?σ -?ta-jvmd→ Normal ?σ'; ⋀xcp h f frs. ⟦check ?P ?σ; (?ta, ?σ') ∈ exec ?P ?t ?σ; ?σ = (xcp, h, f # frs)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) dest!: exec_instr_New_Thread_exists_thread_object (*‹⟦(?ta, ?xcp', ?h', ?frs') ∈ exec_instr ?ins P ?t ?h ?stk ?loc ?C ?M ?pc ?frs; check_instr ?ins P ?h ?stk ?loc ?C ?M ?pc ?frs; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))[1])
(*proven 2 subgoals*)
(*discuss goal 2*)
apply ((case_tac [!] frs)[1])
(*goals:
1. ‹⋀a. ⟦P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h', frs'); NewThread t' x h'' ∈ set ⦃ta⦄⇘t⇙; xcp = ⌊a⌋; frs = []⟧ ⟹ ∃C. typeof_addr h' (thread_id2addr t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
2. ‹⋀a aa list. ⟦P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h', frs'); NewThread t' x h'' ∈ set ⦃ta⦄⇘t⇙; xcp = ⌊a⌋; frs = aa # list⟧ ⟹ ∃C. typeof_addr h' (thread_id2addr t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›
discuss goal 1*)
apply ((auto simp add: check_def (*‹check (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?σ::'addr option × 'heap × 'addr frame list) ≡ let (xcpt::'addr option, h::'heap, frs::'addr frame list) = ?σ in case frs of [] ⇒ True | (stk::'addr val list, loc::'addr val list, C::String.literal, M::String.literal, pc::nat) # (frs'::'addr frame list) ⇒ ?P ⊢ C has M ∧ (let (C'::String.literal, Ts::ty list, T::ty, meth::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) option) = method ?P C M; (mxs::nat, mxl₀::nat, ins::'addr instr list, xt::(nat × nat × String.literal option × nat × nat) list) = the meth; i::'addr instr = ins ! pc in meth ≠ None ∧ pc < length ins ∧ length stk ≤ mxs ∧ (case xcpt of None ⇒ check_instr i ?P h stk loc C M pc frs' | ⌊a::'addr⌋ ⇒ check_xcpt ?P h (length stk) pc xt a))›*) elim!: jvmd_NormalE (*‹⟦(?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),?t::'thread_id ⊢ Normal (?σ::'addr option × 'heap × 'addr frame list) -?ta::('addr, 'thread_id, 'heap) jvm_thread_action-jvmd→ Normal (?σ'::'addr option × 'heap × 'addr frame list); ⋀(xcp::'addr option) (h::'heap) (f::'addr frame) frs::'addr frame list. ⟦check ?P ?σ; (?ta, ?σ') ∈ exec ?P ?t ?σ; ?σ = (xcp, h, f # frs)⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) dest!: exec_instr_New_Thread_exists_thread_object (*‹⟦(?ta::('addr, 'thread_id, 'heap) jvm_thread_action, ?xcp'::'addr option, ?h'::'heap, ?frs'::'addr frame list) ∈ exec_instr (?ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?h::'heap) (?stk::'addr val list) (?loc::'addr val list) (?C::String.literal) (?M::String.literal) (?pc::nat) (?frs::'addr frame list); check_instr ?ins P ?h ?stk ?loc ?C ?M ?pc ?frs; NewThread (?t'::'thread_id) (?x::'addr option × 'addr frame list) (?h''::'heap) ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h' ((thread_id2addr::'thread_id ⇒ 'addr) ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))[1])
(*discuss goal 2*)
apply ((auto simp add: check_def (*‹check ?P ?σ ≡ let (xcpt, h, frs) = ?σ in case frs of [] ⇒ True | (stk, loc, C, M, pc) # frs' ⇒ ?P ⊢ C has M ∧ (let (C', Ts, T, meth) = method ?P C M; (mxs, mxl₀, ins, xt) = the meth; i = ins ! pc in meth ≠ None ∧ pc < length ins ∧ length stk ≤ mxs ∧ (case xcpt of None ⇒ check_instr i ?P h stk loc C M pc frs' | ⌊a⌋ ⇒ check_xcpt ?P h (length stk) pc xt a))›*) elim!: jvmd_NormalE (*‹⟦?P,?t ⊢ Normal ?σ -?ta-jvmd→ Normal ?σ'; ⋀xcp h f frs. ⟦check ?P ?σ; (?ta, ?σ') ∈ exec ?P ?t ?σ; ?σ = (xcp, h, f # frs)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) dest!: exec_instr_New_Thread_exists_thread_object (*‹⟦(?ta, ?xcp', ?h', ?frs') ∈ exec_instr ?ins P ?t ?h ?stk ?loc ?C ?M ?pc ?frs; check_instr ?ins P ?h ?stk ?loc ?C ?M ?pc ?frs; NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*))[1])
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
lemma exec_instr_preserve_tconf:
"⟦ (ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs;
check_instr ins P h stk loc C M pc frs;
P,h ⊢ t' √t ⟧
⟹ P,h' ⊢ t' √t"
apply (cases ins)
(*goals:
1. ‹⋀x1. ⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = Load x1⟧ ⟹ P,h' ⊢ t' √t›
2. ‹⋀x2. ⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = Store x2⟧ ⟹ P,h' ⊢ t' √t›
3. ‹⋀x3. ⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = Push x3⟧ ⟹ P,h' ⊢ t' √t›
4. ‹⋀x4. ⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = New x4⟧ ⟹ P,h' ⊢ t' √t›
5. ‹⋀x5. ⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = NewArray x5⟧ ⟹ P,h' ⊢ t' √t›
6. ‹⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = ALoad⟧ ⟹ P,h' ⊢ t' √t›
7. ‹⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = AStore⟧ ⟹ P,h' ⊢ t' √t›
8. ‹⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = ALength⟧ ⟹ P,h' ⊢ t' √t›
9. ‹⋀x91 x92. ⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = Getfield x91 x92⟧ ⟹ P,h' ⊢ t' √t›
10. ‹⋀x101 x102. ⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = Putfield x101 x102⟧ ⟹ P,h' ⊢ t' √t›
11. ‹⋀x111 x112. ⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = CAS x111 x112⟧ ⟹ P,h' ⊢ t' √t›
12. ‹⋀x12. ⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = Checkcast x12⟧ ⟹ P,h' ⊢ t' √t›
13. ‹⋀x13. ⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = Instanceof x13⟧ ⟹ P,h' ⊢ t' √t›
14. ‹⋀x141 x142. ⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = Invoke x141 x142⟧ ⟹ P,h' ⊢ t' √t›
15. ‹⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = Return⟧ ⟹ P,h' ⊢ t' √t›
16. ‹⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = Pop⟧ ⟹ P,h' ⊢ t' √t›
17. ‹⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = Dup⟧ ⟹ P,h' ⊢ t' √t›
18. ‹⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = Swap⟧ ⟹ P,h' ⊢ t' √t›
19. ‹⋀x19. ⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = BinOpInstr x19⟧ ⟹ P,h' ⊢ t' √t›
20. ‹⋀x20. ⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = Goto x20⟧ ⟹ P,h' ⊢ t' √t›
21. ‹⋀x21. ⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = IfFalse x21⟧ ⟹ P,h' ⊢ t' √t›
22. ‹⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = ThrowExc⟧ ⟹ P,h' ⊢ t' √t›
23. ‹⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = MEnter⟧ ⟹ P,h' ⊢ t' √t›
24. ‹⟦(ta, xcp', h', frs') ∈ exec_instr ins P t h stk loc C M pc frs; check_instr ins P h stk loc C M pc frs; P,h ⊢ t' √t; ins = MExit⟧ ⟹ P,h' ⊢ t' √t›
discuss goal 1*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 2*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 3*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 4*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 5*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 6*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 7*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 8*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 9*)
apply ((auto intro: tconf_hext_mono (*‹⟦(P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),(?h::'heap::type) ⊢ (?t::'thread_id::type) √t; ?h ⊴ (?h'::'heap::type)⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h'::'heap::type, ?a::'addr::addr) ∈ (allocate::'heap::type ⇒ htype ⇒ ('heap::type × 'addr::addr) set) (?h::'heap::type) (?hT::htype) ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹(heap_write::'heap::type ⇒ 'addr::addr ⇒ addr_loc ⇒ 'addr::addr val ⇒ 'heap::type ⇒ bool) (?h::'heap::type) (?a::'addr::addr) (?al::addr_loc) (?v::'addr::addr val) (?h'::'heap::type) ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta::('addr::addr, 'thread_id::type, 'heap::type) external_thread_action, ?va::'addr::addr extCallRet, ?h'::'heap::type) ∈ red_external_aggr (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id::type) (?a::'addr::addr) (?M::String.literal) (?vs::'addr::addr val list) (?h::'heap::type); is_native P (the ((typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) ?h ?a)) ?M; P,?h ⊢ (?t'::'thread_id::type) √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c::type ⇒ bool) (case ?sum::?'a::type + ?'b::type of Inl (x::?'a::type) ⇒ (?f1.0::?'a::type ⇒ ?'c::type) x | Inr (x::?'b::type) ⇒ (?f2.0::?'b::type ⇒ ?'c::type) x) = (¬ ((∃x1::?'a::type. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b::type. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹(?P::?'m::type prog) ⊢ ?C::String.literal has (?M::String.literal) ≡ ∃(Ts::ty list) (T::ty) (m::?'m::type option) D::String.literal. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦(?P::?'m::type prog) ⊢ class_type_of (?hT::htype) sees (?M::String.literal): (?Ts::ty list)→(?T::ty) = Native in (?D::String.literal); ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 10*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 11*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 12*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 13*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 14*)
apply ((auto intro: tconf_hext_mono (*‹⟦(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),(?h::'heap) ⊢ (?t::'thread_id) √t; ?h ⊴ (?h'::'heap)⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h'::'heap, ?a::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype) ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹(heap_write::'heap ⇒ 'addr ⇒ addr_loc ⇒ 'addr val ⇒ 'heap ⇒ bool) (?h::'heap) (?a::'addr) (?al::addr_loc) (?v::'addr val) (?h'::'heap) ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta::('addr, 'thread_id, 'heap) external_thread_action, ?va::'addr extCallRet, ?h'::'heap) ∈ red_external_aggr (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?a::'addr) (?M::String.literal) (?vs::'addr val list) (?h::'heap); is_native P (the ((typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h ?a)) ?M; P,?h ⊢ (?t'::'thread_id) √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹(?P::?'m prog) ⊢ ?C::String.literal has (?M::String.literal) ≡ ∃(Ts::ty list) (T::ty) (m::?'m option) D::String.literal. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦(?P::?'m prog) ⊢ class_type_of (?hT::htype) sees (?M::String.literal): (?Ts::ty list)→(?T::ty) = Native in (?D::String.literal); ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 15*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 16*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 17*)
apply ((auto intro: tconf_hext_mono (*‹⟦(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),(?h::'heap) ⊢ (?t::'thread_id) √t; ?h ⊴ (?h'::'heap)⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h'::'heap, ?a::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype) ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹(heap_write::'heap ⇒ 'addr ⇒ addr_loc ⇒ 'addr val ⇒ 'heap ⇒ bool) (?h::'heap) (?a::'addr) (?al::addr_loc) (?v::'addr val) (?h'::'heap) ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta::('addr, 'thread_id, 'heap) external_thread_action, ?va::'addr extCallRet, ?h'::'heap) ∈ red_external_aggr (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?a::'addr) (?M::String.literal) (?vs::'addr val list) (?h::'heap); is_native P (the ((typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h ?a)) ?M; P,?h ⊢ (?t'::'thread_id) √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹(?P::?'m prog) ⊢ ?C::String.literal has (?M::String.literal) ≡ ∃(Ts::ty list) (T::ty) (m::?'m option) D::String.literal. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦(?P::?'m prog) ⊢ class_type_of (?hT::htype) sees (?M::String.literal): (?Ts::ty list)→(?T::ty) = Native in (?D::String.literal); ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 18*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 19*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 20*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 21*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 22*)
apply ((auto intro: tconf_hext_mono (*‹⟦P,?h ⊢ ?t √t; ?h ⊴ ?h'⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta, ?va, ?h') ∈ red_external_aggr P ?t ?a ?M ?vs ?h; is_native P (the (typeof_addr ?h ?a)) ?M; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦?P ⊢ class_type_of ?hT sees ?M: ?Ts→?T = Native in ?D; ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 23*)
apply ((auto intro: tconf_hext_mono (*‹⟦(P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),(?h::'heap::type) ⊢ (?t::'thread_id::type) √t; ?h ⊴ (?h'::'heap::type)⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h'::'heap::type, ?a::'addr::addr) ∈ (allocate::'heap::type ⇒ htype ⇒ ('heap::type × 'addr::addr) set) (?h::'heap::type) (?hT::htype) ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹(heap_write::'heap::type ⇒ 'addr::addr ⇒ addr_loc ⇒ 'addr::addr val ⇒ 'heap::type ⇒ bool) (?h::'heap::type) (?a::'addr::addr) (?al::addr_loc) (?v::'addr::addr val) (?h'::'heap::type) ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta::('addr::addr, 'thread_id::type, 'heap::type) external_thread_action, ?va::'addr::addr extCallRet, ?h'::'heap::type) ∈ red_external_aggr (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id::type) (?a::'addr::addr) (?M::String.literal) (?vs::'addr::addr val list) (?h::'heap::type); is_native P (the ((typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) ?h ?a)) ?M; P,?h ⊢ (?t'::'thread_id::type) √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c::type ⇒ bool) (case ?sum::?'a::type + ?'b::type of Inl (x::?'a::type) ⇒ (?f1.0::?'a::type ⇒ ?'c::type) x | Inr (x::?'b::type) ⇒ (?f2.0::?'b::type ⇒ ?'c::type) x) = (¬ ((∃x1::?'a::type. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b::type. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹(?P::?'m::type prog) ⊢ ?C::String.literal has (?M::String.literal) ≡ ∃(Ts::ty list) (T::ty) (m::?'m::type option) D::String.literal. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦(?P::?'m::type prog) ⊢ class_type_of (?hT::htype) sees (?M::String.literal): (?Ts::ty list)→(?T::ty) = Native in (?D::String.literal); ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*discuss goal 24*)
apply ((auto intro: tconf_hext_mono (*‹⟦(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),(?h::'heap) ⊢ (?t::'thread_id) √t; ?h ⊴ (?h'::'heap)⟧ ⟹ P,?h' ⊢ ?t √t›*) hext_allocate (*‹(?h'::'heap, ?a::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype) ⟹ ?h ⊴ ?h'›*) hext_heap_write (*‹(heap_write::'heap ⇒ 'addr ⇒ addr_loc ⇒ 'addr val ⇒ 'heap ⇒ bool) (?h::'heap) (?a::'addr) (?al::addr_loc) (?v::'addr val) (?h'::'heap) ⟹ ?h ⊴ ?h'›*) red_external_aggr_preserves_tconf (*‹⟦(?ta::('addr, 'thread_id, 'heap) external_thread_action, ?va::'addr extCallRet, ?h'::'heap) ∈ red_external_aggr (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?a::'addr) (?M::String.literal) (?vs::'addr val list) (?h::'heap); is_native P (the ((typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h ?a)) ?M; P,?h ⊢ (?t'::'thread_id) √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) has_method_def (*‹(?P::?'m prog) ⊢ ?C::String.literal has (?M::String.literal) ≡ ∃(Ts::ty list) (T::ty) (m::?'m option) D::String.literal. ?P ⊢ ?C sees ?M: Ts→T = m in D›*) intro!: is_native.intros (*‹⟦(?P::?'m prog) ⊢ class_type_of (?hT::htype) sees (?M::String.literal): (?Ts::ty list)→(?T::ty) = Native in (?D::String.literal); ?D∙?M(?Ts) :: ?T⟧ ⟹ is_native ?P ?hT ?M›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*))[1])
(*proven 24 subgoals*) .
lemma exec_preserve_tconf:
"⟦ P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h', frs'); P,h ⊢ t' √t ⟧ ⟹ P,h' ⊢ t' √t"
apply (cases xcp)
(*goals:
1. ‹⟦P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h', frs'); P,h ⊢ t' √t; xcp = None⟧ ⟹ P,h' ⊢ t' √t›
2. ‹⋀a. ⟦P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h', frs'); P,h ⊢ t' √t; xcp = ⌊a⌋⟧ ⟹ P,h' ⊢ t' √t›
discuss goal 1*)
apply ((case_tac [!] frs)[1])
(*goals:
1. ‹⟦P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h', frs'); P,h ⊢ t' √t; xcp = None; frs = []⟧ ⟹ P,h' ⊢ t' √t›
2. ‹⋀a list. ⟦P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h', frs'); P,h ⊢ t' √t; xcp = None; frs = a # list⟧ ⟹ P,h' ⊢ t' √t›
discuss goal 1*)
apply ((auto simp add: check_def (*‹check (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?σ::'addr option × 'heap × 'addr frame list) ≡ let (xcpt::'addr option, h::'heap, frs::'addr frame list) = ?σ in case frs of [] ⇒ True | (stk::'addr val list, loc::'addr val list, C::String.literal, M::String.literal, pc::nat) # (frs'::'addr frame list) ⇒ ?P ⊢ C has M ∧ (let (C'::String.literal, Ts::ty list, T::ty, meth::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) option) = method ?P C M; (mxs::nat, mxl₀::nat, ins::'addr instr list, xt::(nat × nat × String.literal option × nat × nat) list) = the meth; i::'addr instr = ins ! pc in meth ≠ None ∧ pc < length ins ∧ length stk ≤ mxs ∧ (case xcpt of None ⇒ check_instr i ?P h stk loc C M pc frs' | ⌊a::'addr⌋ ⇒ check_xcpt ?P h (length stk) pc xt a))›*) elim!: jvmd_NormalE (*‹⟦(?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),?t::'thread_id ⊢ Normal (?σ::'addr option × 'heap × 'addr frame list) -?ta::('addr, 'thread_id, 'heap) jvm_thread_action-jvmd→ Normal (?σ'::'addr option × 'heap × 'addr frame list); ⋀(xcp::'addr option) (h::'heap) (f::'addr frame) frs::'addr frame list. ⟦check ?P ?σ; (?ta, ?σ') ∈ exec ?P ?t ?σ; ?σ = (xcp, h, f # frs)⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) elim!: exec_instr_preserve_tconf (*‹⟦(?ta::('addr, 'thread_id, 'heap) jvm_thread_action, ?xcp'::'addr option, ?h'::'heap, ?frs'::'addr frame list) ∈ exec_instr (?ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?h::'heap) (?stk::'addr val list) (?loc::'addr val list) (?C::String.literal) (?M::String.literal) (?pc::nat) (?frs::'addr frame list); check_instr ?ins P ?h ?stk ?loc ?C ?M ?pc ?frs; P,?h ⊢ (?t'::'thread_id) √t⟧ ⟹ P,?h' ⊢ ?t' √t›*))[1])
(*discuss goal 2*)
apply ((auto simp add: check_def (*‹check ?P ?σ ≡ let (xcpt, h, frs) = ?σ in case frs of [] ⇒ True | (stk, loc, C, M, pc) # frs' ⇒ ?P ⊢ C has M ∧ (let (C', Ts, T, meth) = method ?P C M; (mxs, mxl₀, ins, xt) = the meth; i = ins ! pc in meth ≠ None ∧ pc < length ins ∧ length stk ≤ mxs ∧ (case xcpt of None ⇒ check_instr i ?P h stk loc C M pc frs' | ⌊a⌋ ⇒ check_xcpt ?P h (length stk) pc xt a))›*) elim!: jvmd_NormalE (*‹⟦?P,?t ⊢ Normal ?σ -?ta-jvmd→ Normal ?σ'; ⋀xcp h f frs. ⟦check ?P ?σ; (?ta, ?σ') ∈ exec ?P ?t ?σ; ?σ = (xcp, h, f # frs)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) elim!: exec_instr_preserve_tconf (*‹⟦(?ta, ?xcp', ?h', ?frs') ∈ exec_instr ?ins P ?t ?h ?stk ?loc ?C ?M ?pc ?frs; check_instr ?ins P ?h ?stk ?loc ?C ?M ?pc ?frs; P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*))[1])
(*proven 2 subgoals*)
(*discuss goal 2*)
apply ((case_tac [!] frs)[1])
(*goals:
1. ‹⋀a. ⟦P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h', frs'); P,h ⊢ t' √t; xcp = ⌊a⌋; frs = []⟧ ⟹ P,h' ⊢ t' √t›
2. ‹⋀a aa list. ⟦P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h', frs'); P,h ⊢ t' √t; xcp = ⌊a⌋; frs = aa # list⟧ ⟹ P,h' ⊢ t' √t›
discuss goal 1*)
apply ((auto simp add: check_def (*‹check (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?σ::'addr::addr option × 'heap::type × 'addr::addr frame list) ≡ let (xcpt::'addr::addr option, h::'heap::type, frs::'addr::addr frame list) = ?σ in case frs of [] ⇒ True | (stk::'addr::addr val list, loc::'addr::addr val list, C::String.literal, M::String.literal, pc::nat) # (frs'::'addr::addr frame list) ⇒ ?P ⊢ C has M ∧ (let (C'::String.literal, Ts::ty list, T::ty, meth::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) option) = method ?P C M; (mxs::nat, mxl₀::nat, ins::'addr::addr instr list, xt::(nat × nat × String.literal option × nat × nat) list) = the meth; i::'addr::addr instr = ins ! pc in meth ≠ None ∧ pc < length ins ∧ length stk ≤ mxs ∧ (case xcpt of None ⇒ check_instr i ?P h stk loc C M pc frs' | ⌊a::'addr::addr⌋ ⇒ check_xcpt ?P h (length stk) pc xt a))›*) elim!: jvmd_NormalE (*‹⟦(?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),?t::'thread_id::type ⊢ Normal (?σ::'addr::addr option × 'heap::type × 'addr::addr frame list) -?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action-jvmd→ Normal (?σ'::'addr::addr option × 'heap::type × 'addr::addr frame list); ⋀(xcp::'addr::addr option) (h::'heap::type) (f::'addr::addr frame) frs::'addr::addr frame list. ⟦check ?P ?σ; (?ta, ?σ') ∈ exec ?P ?t ?σ; ?σ = (xcp, h, f # frs)⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) elim!: exec_instr_preserve_tconf (*‹⟦(?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, ?xcp'::'addr::addr option, ?h'::'heap::type, ?frs'::'addr::addr frame list) ∈ exec_instr (?ins::'addr::addr instr) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id::type) (?h::'heap::type) (?stk::'addr::addr val list) (?loc::'addr::addr val list) (?C::String.literal) (?M::String.literal) (?pc::nat) (?frs::'addr::addr frame list); check_instr ?ins P ?h ?stk ?loc ?C ?M ?pc ?frs; P,?h ⊢ (?t'::'thread_id::type) √t⟧ ⟹ P,?h' ⊢ ?t' √t›*))[1])
(*discuss goal 2*)
apply ((auto simp add: check_def (*‹check (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?σ::'addr::addr option × 'heap::type × 'addr::addr frame list) ≡ let (xcpt::'addr::addr option, h::'heap::type, frs::'addr::addr frame list) = ?σ in case frs of [] ⇒ True | (stk::'addr::addr val list, loc::'addr::addr val list, C::String.literal, M::String.literal, pc::nat) # (frs'::'addr::addr frame list) ⇒ ?P ⊢ C has M ∧ (let (C'::String.literal, Ts::ty list, T::ty, meth::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) option) = method ?P C M; (mxs::nat, mxl₀::nat, ins::'addr::addr instr list, xt::(nat × nat × String.literal option × nat × nat) list) = the meth; i::'addr::addr instr = ins ! pc in meth ≠ None ∧ pc < length ins ∧ length stk ≤ mxs ∧ (case xcpt of None ⇒ check_instr i ?P h stk loc C M pc frs' | ⌊a::'addr::addr⌋ ⇒ check_xcpt ?P h (length stk) pc xt a))›*) elim!: jvmd_NormalE (*‹⟦(?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),?t::'thread_id::type ⊢ Normal (?σ::'addr::addr option × 'heap::type × 'addr::addr frame list) -?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action-jvmd→ Normal (?σ'::'addr::addr option × 'heap::type × 'addr::addr frame list); ⋀(xcp::'addr::addr option) (h::'heap::type) (f::'addr::addr frame) frs::'addr::addr frame list. ⟦check ?P ?σ; (?ta, ?σ') ∈ exec ?P ?t ?σ; ?σ = (xcp, h, f # frs)⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) elim!: exec_instr_preserve_tconf (*‹⟦(?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, ?xcp'::'addr::addr option, ?h'::'heap::type, ?frs'::'addr::addr frame list) ∈ exec_instr (?ins::'addr::addr instr) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id::type) (?h::'heap::type) (?stk::'addr::addr val list) (?loc::'addr::addr val list) (?C::String.literal) (?M::String.literal) (?pc::nat) (?frs::'addr::addr frame list); check_instr ?ins P ?h ?stk ?loc ?C ?M ?pc ?frs; P,?h ⊢ (?t'::'thread_id::type) √t⟧ ⟹ P,?h' ⊢ ?t' √t›*))[1])
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
lemma lifting_wf_thread_conf: "lifting_wf JVM_final (mexecd P) (λt x m. P,m ⊢ t √t)"
apply unfold_locales
(*goals:
1. ‹⋀t x m ta x' m'. ⟦execd_mthr.r_syntax P t x m ta x' m'; P,m ⊢ t √t⟧ ⟹ P,m' ⊢ t √t›
2. ‹⋀t x m ta x' m' t'' x''. ⟦execd_mthr.r_syntax P t x m ta x' m'; P,m ⊢ t √t; NewThread t'' x'' m' ∈ set ⦃ta⦄⇘t⇙⟧ ⟹ P,m' ⊢ t'' √t›
3. ‹⋀t x m ta x' m' t'' x''. ⟦execd_mthr.r_syntax P t x m ta x' m'; P,m ⊢ t √t; P,m ⊢ t'' √t⟧ ⟹ P,m' ⊢ t'' √t›
discuss goal 1*)
apply ((auto intro: exec_preserve_tconf (*‹⟦P,?t ⊢ Normal (?xcp, ?h, ?frs) -?ta-jvmd→ Normal (?xcp', ?h', ?frs'); P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) dest: exec_New_Thread_exists_thread_object (*‹⟦P,?t ⊢ Normal (?xcp, ?h, ?frs) -?ta-jvmd→ Normal (?xcp', ?h', ?frs'); NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*) intro: tconfI (*‹⟦typeof_addr ?h (thread_id2addr ?t) = ⌊Class_type ?C⌋; ?P ⊢ ?C ≼⇧* Thread⟧ ⟹ ?P,?h ⊢ ?t √t›*))[1])
(*discuss goal 2*)
apply ((auto intro: exec_preserve_tconf (*‹⟦(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),?t::'thread_id ⊢ Normal (?xcp::'addr option, ?h::'heap, ?frs::'addr frame list) -?ta::('addr, 'thread_id, 'heap) jvm_thread_action-jvmd→ Normal (?xcp'::'addr option, ?h'::'heap, ?frs'::'addr frame list); P,?h ⊢ (?t'::'thread_id) √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) dest: exec_New_Thread_exists_thread_object (*‹⟦(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),?t::'thread_id ⊢ Normal (?xcp::'addr option, ?h::'heap, ?frs::'addr frame list) -?ta::('addr, 'thread_id, 'heap) jvm_thread_action-jvmd→ Normal (?xcp'::'addr option, ?h'::'heap, ?frs'::'addr frame list); NewThread (?t'::'thread_id) (?x::'addr option × 'addr frame list) (?h''::'heap) ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h' ((thread_id2addr::'thread_id ⇒ 'addr) ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*) intro: tconfI (*‹⟦(typeof_addr::'heap ⇒ 'addr ⇒ htype option) (?h::'heap) ((thread_id2addr::'thread_id ⇒ 'addr) (?t::'thread_id)) = ⌊Class_type (?C::String.literal)⌋; (?P::?'a prog) ⊢ ?C ≼⇧* Thread⟧ ⟹ ?P,?h ⊢ ?t √t›*))[1])
(*discuss goal 3*)
apply ((auto intro: exec_preserve_tconf (*‹⟦P,?t ⊢ Normal (?xcp, ?h, ?frs) -?ta-jvmd→ Normal (?xcp', ?h', ?frs'); P,?h ⊢ ?t' √t⟧ ⟹ P,?h' ⊢ ?t' √t›*) dest: exec_New_Thread_exists_thread_object (*‹⟦P,?t ⊢ Normal (?xcp, ?h, ?frs) -?ta-jvmd→ Normal (?xcp', ?h', ?frs'); NewThread ?t' ?x ?h'' ∈ set ⦃?ta⦄⇘t⇙⟧ ⟹ ∃C. typeof_addr ?h' (thread_id2addr ?t') = ⌊Class_type C⌋ ∧ P ⊢ C ≼⇧* Thread›*) intro: tconfI (*‹⟦typeof_addr ?h (thread_id2addr ?t) = ⌊Class_type ?C⌋; ?P ⊢ ?C ≼⇧* Thread⟧ ⟹ ?P,?h ⊢ ?t √t›*))[1])
(*proven 3 subgoals*) .
end
sublocale JVM_heap < execd_tconf: lifting_wf JVM_final "mexecd P" convert_RA "λt x m. P,m ⊢ t √t"
by (rule lifting_wf_thread_conf (*‹lifting_wf JVM_final (mexecd (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog)) (λ(t::'thread_id::type) (x::'addr::addr option × 'addr::addr frame list) m::'heap::type. P,m ⊢ t √t)›*))
context JVM_heap begin
lemma execd_hext:
"P ⊢ s -t▹ta→⇘jvmd⇙ s' ⟹ shr s ⊴ shr s'"
by (auto elim!: execd_mthr.redT.cases (*‹⟦mexecdT ?Pa ?a1.0 ?a2.0 ?a3.0; ⋀t x s ta x' m' s'. ⟦?a1.0 = s; ?a2.0 = (t, ta); ?a3.0 = s'; execd_mthr.r_syntax ?Pa t x (shr s) ta x' m'; thr s t = ⌊(x, no_wait_locks)⌋; exec_mthr.actions_ok s t ta; redT_upd s t ta x' m' s'⟧ ⟹ ?P; ⋀s t x n s' ln. ⟦?a1.0 = s; ?a2.0 = (t, K$ [], [], [], [], [], convert_RA ln); ?a3.0 = s'; thr s t = ⌊(x, ln)⌋; ¬ waiting (wset s t); may_acquire_all (locks s) t ln; 0 < ln $ n; s' = (acquire_all (locks s) t ln, ((thr s)(t ↦ (x, no_wait_locks)), shr s), wset s, interrupts s)⟧ ⟹ ?P⟧ ⟹ ?P›*) dest!: exec_1_d_hext (*‹P,?t ⊢ Normal (?xcp, ?h, ?frs) -?ta-jvmd→ Normal (?xcp', ?h', ?frs') ⟹ ?h ⊴ ?h'›*) intro: hext_trans (*‹⟦?h ⊴ ?h'; ?h' ⊴ ?h''⟧ ⟹ ?h ⊴ ?h''›*))
lemma Execd_hext:
assumes "P ⊢ s -▹tta→⇘jvmd⇙* s'"
shows "shr s ⊴ shr s'"
using assms (*‹P ⊢ s -▹tta→⇘jvmd⇙* s'›*) unfolding execd_mthr.RedT_def
(*goal: ‹shr s ⊴ shr s'›*)
apply induct
(*goals:
1. ‹⋀a. shr a ⊴ shr a›
2. ‹⋀a bs a' b a''. ⟦rtrancl3p (mexecdT P) a bs a'; shr a ⊴ shr a'; mexecdT P a' b a''⟧ ⟹ shr a ⊴ shr a''›
discuss goal 1*)
apply ((auto dest!: execd_hext (*‹P ⊢ ?s -?t▹?ta→⇘jvmd⇙ ?s' ⟹ shr ?s ⊴ shr ?s'›*) intro: hext_trans (*‹⟦?h ⊴ ?h'; ?h' ⊴ ?h''⟧ ⟹ ?h ⊴ ?h''›*) simp add: execd_mthr.RedT_def (*‹mExecdT_syntax1 ?P ≡ rtrancl3p (mexecdT ?P)›*))[1])
(*discuss goal 2*)
apply ((auto dest!: execd_hext (*‹(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ ?s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set -?t::'thread_id▹?ta::('addr, 'thread_id, 'heap) jvm_thread_action→⇘jvmd⇙ (?s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) ⟹ shr ?s ⊴ shr ?s'›*) intro: hext_trans (*‹⟦(?h::'heap) ⊴ (?h'::'heap); ?h' ⊴ (?h''::'heap)⟧ ⟹ ?h ⊴ ?h''›*) simp add: execd_mthr.RedT_def (*‹mExecdT_syntax1 (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ≡ rtrancl3p (mexecdT ?P)›*))[1])
(*proven 2 subgoals*) .
end
end
| {
"path": "afp-2025-02-12/thys/JinjaThreads/JVM/JVMThreaded.thy",
"repo": "afp-2025-02-12",
"sha": "a1c13de5279af88b56b9e95009b5bca4e792072d65dca020eaaecf823833312c"
} |
section ‹The Free Group›
theory "FreeGroups"
imports
"HOL-Algebra.Group"
Cancelation
Generators
begin
text ‹
Based on the work in @{theory "Free-Groups.Cancelation"}, the free group is now easily defined
over the set of fully canceled words with the corresponding operations.
›
subsection ‹Inversion›
text ‹
To define the inverse of a word, we first create a helper function that inverts
a single generator, and show that it is self-inverse.
›
definition inv1 :: "'a g_i ⇒ 'a g_i"
where "inv1 = apfst Not"
lemma inv1_inv1: "inv1 ∘ inv1 = id"
by (simp add: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) inv1_def (*‹inv1 = apfst Not›*))
lemmas inv1_inv1_simp [simp] = inv1_inv1[unfolded id_def]
lemma snd_inv1: "snd ∘ inv1 = snd"
by (simp add: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) inv1_def (*‹inv1 = apfst Not›*))
text ‹
The inverse of a word is obtained by reversing the order of the generators and
inverting each generator using @{term inv1}. Some properties of @{term inv_fg}
are noted.
›
definition inv_fg :: "'a word_g_i ⇒ 'a word_g_i"
where "inv_fg l = rev (map inv1 l)"
lemma cancelling_inf[simp]: "canceling (inv1 a) (inv1 b) = canceling a b"
sorry
lemma inv_idemp: "inv_fg (inv_fg l) = l"
by (auto simp add:inv_fg_def (*‹inv_fg (?l::(bool × ?'a::type) list) = rev (map inv1 ?l)›*) rev_map (*‹rev (map (?f::?'b::type ⇒ ?'a::type) (?xs::?'b::type list)) = map ?f (rev ?xs)›*))
lemma inv_fg_cancel: "normalize (l @ inv_fg l) = []"
proof (induct l rule:rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*))
(*goals:
1. ‹Cancelation.normalize ([] @ inv_fg []) = []›
2. ‹⋀(x::bool × 'a::type) xs::(bool × 'a::type) list. Cancelation.normalize (xs @ inv_fg xs) = [] ⟹ Cancelation.normalize ((xs @ [x]) @ inv_fg (xs @ [x])) = []›*)
case Nil (*no hyothesis introduced yet*)
thus "?case"
(*goal: ‹Cancelation.normalize ([] @ inv_fg []) = []›*)
by (auto simp add: inv_fg_def (*‹inv_fg ?l = rev (map inv1 ?l)›*))
next
(*goal: ‹⋀x xs. Cancelation.normalize (xs @ inv_fg xs) = [] ⟹ Cancelation.normalize ((xs @ [x]) @ inv_fg (xs @ [x])) = []›*)
case (snoc x xs) (*‹Cancelation.normalize ((xs::(bool × 'a) list) @ inv_fg xs) = []›*)
have "canceling x (inv1 x)"
by (simp add:inv1_def (*‹inv1 = apfst Not›*) canceling_def (*‹canceling ?a ?b = (snd ?a = snd ?b ∧ fst ?a ≠ fst ?b)›*))
moreover let ?i = "length xs"
have "Suc ?i < length xs + 1 + 1 + length xs"
by auto
moreover have "inv_fg (xs @ [x]) = [inv1 x] @ inv_fg xs"
by (auto simp add:inv_fg_def (*‹inv_fg ?l = rev (map inv1 ?l)›*))
ultimately have "cancels_to_1_at ?i (xs @ [x] @ (inv_fg (xs @ [x]))) (xs @ inv_fg xs)"
by (auto simp add:cancels_to_1_at_def (*‹cancels_to_1_at ?i ?l1.0 ?l2.0 = (0 ≤ ?i ∧ 1 + ?i < length ?l1.0 ∧ canceling (?l1.0 ! ?i) (?l1.0 ! (1 + ?i)) ∧ ?l2.0 = cancel_at ?i ?l1.0)›*) cancel_at_def (*‹cancel_at ?i ?l = take ?i ?l @ drop (2 + ?i) ?l›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*))
hence "cancels_to_1 (xs @ [x] @ (inv_fg (xs @ [x]))) (xs @ inv_fg xs)"
by (auto simp add: cancels_to_1_def (*‹cancels_to_1 ?l1.0 ?l2.0 = (∃i. cancels_to_1_at i ?l1.0 ?l2.0)›*))
hence "cancels_to (xs @ [x] @ (inv_fg (xs @ [x]))) (xs @ inv_fg xs)"
by (auto simp add:cancels_to_def (*‹cancels_to = cancels_to_1⇧*⇧*›*))
with ‹normalize (xs @ (inv_fg xs)) = []› (*‹Cancelation.normalize (xs @ inv_fg xs) = []›*) show "normalize ((xs @ [x]) @ (inv_fg (xs @ [x]))) = []"
by auto
qed
lemma inv_fg_cancel2: "normalize (inv_fg l @ l) = []"
proof (-)
(*goal: ‹Cancelation.normalize (inv_fg (l::(bool × 'a::type) list) @ l) = []›*)
have "normalize (inv_fg l @ inv_fg (inv_fg l)) = []"
by (rule inv_fg_cancel (*‹Cancelation.normalize (?l @ inv_fg ?l) = []›*))
thus "normalize (inv_fg l @ l) = []"
by (simp add: inv_idemp (*‹inv_fg (inv_fg ?l) = ?l›*))
qed
lemma canceled_rev:
assumes "canceled l"
shows "canceled (rev l)"
proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*))
(*goal: ‹¬ canceled (rev l) ⟹ False›*)
assume "¬canceled (rev l)" (*‹¬ canceled (rev (l::(bool × 'a) list))›*)
hence "Domainp cancels_to_1 (rev l)"
by (simp add: canceled_def (*‹canceled ?l = (¬ Domainp cancels_to_1 ?l)›*))
then obtain l' where "cancels_to_1 (rev l) l'"
(*goal: ‹(⋀l'. cancels_to_1 (rev l) l' ⟹ thesis) ⟹ thesis›*)
by auto
then obtain i where "cancels_to_1_at i (rev l) l'"
(*goal: ‹(⋀i::nat. cancels_to_1_at i (rev (l::(bool × 'a) list)) (l'::(bool × 'a) list) ⟹ thesis::bool) ⟹ thesis›*)
by (auto simp add:cancels_to_1_def (*‹cancels_to_1 (?l1.0::(bool × ?'a::type) list) (?l2.0::(bool × ?'a::type) list) = (∃i::nat. cancels_to_1_at i ?l1.0 ?l2.0)›*))
hence "Suc i < length (rev l)" and "canceling (rev l ! i) (rev l ! Suc i)"
apply -
(*goals:
1. ‹cancels_to_1_at i (rev l) l' ⟹ Suc i < length (rev l)›
2. ‹cancels_to_1_at i (rev l) l' ⟹ canceling (rev l ! i) (rev l ! Suc i)›
discuss goal 1*)
apply ((auto simp add:cancels_to_1_at_def (*‹cancels_to_1_at ?i ?l1.0 ?l2.0 = (0 ≤ ?i ∧ 1 + ?i < length ?l1.0 ∧ canceling (?l1.0 ! ?i) (?l1.0 ! (1 + ?i)) ∧ ?l2.0 = cancel_at ?i ?l1.0)›*))[1])
(*discuss goal 2*)
apply ((auto simp add:cancels_to_1_at_def (*‹cancels_to_1_at ?i ?l1.0 ?l2.0 = (0 ≤ ?i ∧ 1 + ?i < length ?l1.0 ∧ canceling (?l1.0 ! ?i) (?l1.0 ! (1 + ?i)) ∧ ?l2.0 = cancel_at ?i ?l1.0)›*))[1])
(*proven 2 subgoals*) .
let ?x = "length l - i - 2"
from ‹Suc i < length (rev l)› (*‹Suc (i::nat) < length (rev (l::(bool × 'a) list))›*) have "Suc ?x < length l"
by auto
moreover from ‹Suc i < length (rev l)› (*‹Suc i < length (rev l)›*) have "i < length l" and "length l - Suc i = Suc(length l - Suc (Suc i))"
apply -
(*goals:
1. ‹Suc i < length (rev l) ⟹ i < length l›
2. ‹Suc i < length (rev l) ⟹ length l - Suc i = Suc (length l - Suc (Suc i))›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
hence "rev l ! i = l ! Suc ?x" and "rev l ! Suc i = l ! ?x"
apply -
(*goals:
1. ‹⟦i < length l; length l - Suc i = Suc (length l - Suc (Suc i))⟧ ⟹ rev l ! i = l ! Suc (length l - i - 2)›
2. ‹⟦i < length l; length l - Suc i = Suc (length l - Suc (Suc i))⟧ ⟹ rev l ! Suc i = l ! (length l - i - 2)›
discuss goal 1*)
apply ((auto simp add: rev_nth (*‹?n < length ?xs ⟹ rev ?xs ! ?n = ?xs ! (length ?xs - Suc ?n)›*) map_nth (*‹map ((!) ?xs) [0..<length ?xs] = ?xs›*))[1])
(*discuss goal 2*)
apply ((auto simp add: rev_nth (*‹(?n::nat) < length (?xs::?'a list) ⟹ rev ?xs ! ?n = ?xs ! (length ?xs - Suc ?n)›*) map_nth (*‹map ((!) (?xs::?'a list)) [0::nat..<length ?xs] = ?xs›*))[1])
(*proven 2 subgoals*) .
with ‹canceling (rev l ! i) (rev l ! Suc i)› (*‹canceling (rev l ! i) (rev l ! Suc i)›*) have "canceling (l ! Suc ?x) (l ! ?x)"
by auto
hence "canceling (l ! ?x) (l ! Suc ?x)"
by (rule cancel_sym (*‹canceling ?a ?b ⟹ canceling ?b ?a›*))
hence "canceling (l ! ?x) (l ! Suc ?x)"
by simp
ultimately have "cancels_to_1_at ?x l (cancel_at ?x l)"
by (auto simp add:cancels_to_1_at_def (*‹cancels_to_1_at (?i::nat) (?l1.0::(bool × ?'a) list) (?l2.0::(bool × ?'a) list) = ((0::nat) ≤ ?i ∧ (1::nat) + ?i < length ?l1.0 ∧ canceling (?l1.0 ! ?i) (?l1.0 ! ((1::nat) + ?i)) ∧ ?l2.0 = cancel_at ?i ?l1.0)›*))
hence "cancels_to_1 l (cancel_at ?x l)"
by (auto simp add:cancels_to_1_def (*‹cancels_to_1 ?l1.0 ?l2.0 = (∃i. cancels_to_1_at i ?l1.0 ?l2.0)›*))
hence "¬canceled l"
by (auto simp add:canceled_def (*‹canceled (?l::(bool × ?'a::type) list) = (¬ Domainp cancels_to_1 ?l)›*))
with ‹canceled l› (*‹canceled l›*) show False
by contradiction
qed
lemma inv_fg_closure1:
assumes "canceled l"
shows "canceled (inv_fg l)"
unfolding inv_fg_def inv1_def apfst_def
(*goal: ‹canceled (rev (map (map_prod Not id) l))›*)
proof (-)
(*goal: ‹canceled (rev (map (map_prod Not id) l))›*)
have "inj Not"
by (auto intro:injI (*‹(⋀x y. ?f x = ?f y ⟹ x = y) ⟹ inj ?f›*))
moreover have "inj_on id (snd ` set l)"
by auto
ultimately have "canceled (map (map_prod Not id) l)"
using ‹canceled l› (*‹canceled l›*) apply -
(*goal: ‹canceled (map (map_prod Not id) l)›*)
apply (rule rename_gens_canceled (*‹⟦inj_on ?g (snd ` set ?l); canceled ?l⟧ ⟹ canceled (map (map_prod ?f ?g) ?l)›*))
(*goals:
1. ‹⟦inj Not; inj_on id (snd ` set l); canceled l⟧ ⟹ inj_on id (snd ` set l)›
2. ‹⟦inj Not; inj_on id (snd ` set l); canceled l⟧ ⟹ canceled l›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
thus "canceled (rev (map (map_prod Not id) l))"
by (rule canceled_rev (*‹canceled ?l ⟹ canceled (rev ?l)›*))
qed
lemma inv_fg_closure2:
"l ∈ lists (UNIV × gens) ⟹ inv_fg l ∈ lists (UNIV × gens)"
sorry
subsection ‹The definition›
text ‹
Finally, we can define the Free Group over a set of generators, and show that it
is indeed a group.
›
definition free_group :: "'a set => ((bool * 'a) list) monoid" ("ℱı")
where
"ℱ⇘gens⇙ ≡ ⦇
carrier = {l∈lists (UNIV × gens). canceled l },
mult = λ x y. normalize (x @ y),
one = []
⦈"
lemma occuring_gens_in_element:
"x ∈ carrier ℱ⇘gens⇙ ⟹ x ∈ lists (UNIV × gens)"
by (auto simp add:free_group_def (*‹ℱ⇘?gens::?'a set⇙ ≡ ⦇carrier = {l::(bool × ?'a) list ∈ lists (UNIV × ?gens). canceled l}, mult = λ(x::(bool × ?'a) list) y::(bool × ?'a) list. Cancelation.normalize (x @ y), one = []⦈›*))
theorem free_group_is_group: "group ℱ⇘gens⇙"
proof (standard)
(*goals:
1. ‹⋀x y. ⟦x ∈ carrier ℱ⇘gens⇙; y ∈ carrier ℱ⇘gens⇙⟧ ⟹ x ⊗⇘ℱ⇘gens⇙⇙ y ∈ carrier ℱ⇘gens⇙›
2. ‹⋀x y z. ⟦x ∈ carrier ℱ⇘gens⇙; y ∈ carrier ℱ⇘gens⇙; z ∈ carrier ℱ⇘gens⇙⟧ ⟹ x ⊗⇘ℱ⇘gens⇙⇙ y ⊗⇘ℱ⇘gens⇙⇙ z = x ⊗⇘ℱ⇘gens⇙⇙ (y ⊗⇘ℱ⇘gens⇙⇙ z)›
3. ‹𝟭⇘ℱ⇘gens⇙⇙ ∈ carrier ℱ⇘gens⇙›
4. ‹⋀x. x ∈ carrier ℱ⇘gens⇙ ⟹ 𝟭⇘ℱ⇘gens⇙⇙ ⊗⇘ℱ⇘gens⇙⇙ x = x›
5. ‹⋀x. x ∈ carrier ℱ⇘gens⇙ ⟹ x ⊗⇘ℱ⇘gens⇙⇙ 𝟭⇘ℱ⇘gens⇙⇙ = x›
6. ‹carrier ℱ⇘gens⇙ ⊆ Units ℱ⇘gens⇙›*)
fix x and y
assume "x ∈ carrier ℱ⇘gens⇙" (*‹(x::(bool × 'a) list) ∈ carrier ℱ⇘gens::'a set⇙›*)
hence x: "x ∈ lists (UNIV × gens)"
by (rule occuring_gens_in_element (*‹?x ∈ carrier ℱ⇘?gens⇙ ⟹ ?x ∈ lists (UNIV × ?gens)›*))
assume "y ∈ carrier ℱ⇘gens⇙" (*‹(y::(bool × 'a) list) ∈ carrier ℱ⇘gens::'a set⇙›*)
hence y: "y ∈ lists (UNIV × gens)"
by (rule occuring_gens_in_element (*‹(?x::(bool × ?'a) list) ∈ carrier ℱ⇘?gens::?'a set⇙ ⟹ ?x ∈ lists (UNIV × ?gens)›*))
from x (*‹x ∈ lists (UNIV × gens)›*) y (*‹y ∈ lists (UNIV × gens)›*) have "x ⊗⇘ℱ⇘gens⇙⇙ y ∈ lists (UNIV × gens)"
by (auto intro!: normalize_preserves_generators (*‹?l ∈ lists (UNIV × ?gens) ⟹ Cancelation.normalize ?l ∈ lists (UNIV × ?gens)›*) simp add:free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*) append_in_lists_conv (*‹(?xs @ ?ys ∈ lists ?A) = (?xs ∈ lists ?A ∧ ?ys ∈ lists ?A)›*))
thus "x ⊗⇘ℱ⇘gens⇙⇙ y ∈ carrier ℱ⇘gens⇙"
by (auto simp add:free_group_def (*‹ℱ⇘?gens::?'a set⇙ ≡ ⦇carrier = {l::(bool × ?'a) list ∈ lists (UNIV × ?gens). canceled l}, mult = λ(x::(bool × ?'a) list) y::(bool × ?'a) list. Cancelation.normalize (x @ y), one = []⦈›*))
next
(*goals:
1. ‹⋀x y z. ⟦x ∈ carrier ℱ⇘gens⇙; y ∈ carrier ℱ⇘gens⇙; z ∈ carrier ℱ⇘gens⇙⟧ ⟹ x ⊗⇘ℱ⇘gens⇙⇙ y ⊗⇘ℱ⇘gens⇙⇙ z = x ⊗⇘ℱ⇘gens⇙⇙ (y ⊗⇘ℱ⇘gens⇙⇙ z)›
2. ‹𝟭⇘ℱ⇘gens⇙⇙ ∈ carrier ℱ⇘gens⇙›
3. ‹⋀x. x ∈ carrier ℱ⇘gens⇙ ⟹ 𝟭⇘ℱ⇘gens⇙⇙ ⊗⇘ℱ⇘gens⇙⇙ x = x›
4. ‹⋀x. x ∈ carrier ℱ⇘gens⇙ ⟹ x ⊗⇘ℱ⇘gens⇙⇙ 𝟭⇘ℱ⇘gens⇙⇙ = x›
5. ‹carrier ℱ⇘gens⇙ ⊆ Units ℱ⇘gens⇙›*)
fix x and y and z
have "cancels_to (x @ y) (normalize (x @ (y::'a word_g_i)))" and "cancels_to z (z::'a word_g_i)"
(*goals:
1. ‹cancels_to (x @ y) (Cancelation.normalize (x @ y))›
2. ‹cancels_to z z›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
hence "normalize (normalize (x @ y) @ z) = normalize ((x @ y) @ z)"
by (rule normalize_append_cancel_to[THEN sym] (*‹⟦cancels_to (?l1.1::(bool × ?'a1) list) (?l1'1::(bool × ?'a1) list); cancels_to (?l2.1::(bool × ?'a1) list) (?l2'1::(bool × ?'a1) list)⟧ ⟹ Cancelation.normalize (?l1'1 @ ?l2'1) = Cancelation.normalize (?l1.1 @ ?l2.1)›*))
also (*calculation: ‹Cancelation.normalize (Cancelation.normalize (x @ y) @ z) = Cancelation.normalize ((x @ y) @ z)›*) have "… = normalize (x @ (y @ z))"
by auto
also (*calculation: ‹Cancelation.normalize (Cancelation.normalize (x @ y) @ z) = Cancelation.normalize (x @ y @ z)›*) have "cancels_to (y @ z) (normalize (y @ (z::'a word_g_i)))" and "cancels_to x (x::'a word_g_i)"
(*goals:
1. ‹cancels_to (y @ z) (Cancelation.normalize (y @ z))›
2. ‹cancels_to x x›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
hence "normalize (x @ (y @ z)) = normalize (x @ normalize (y @ z))"
apply -
(*goal: ‹Cancelation.normalize (x @ y @ z) = Cancelation.normalize (x @ Cancelation.normalize (y @ z))›*)
apply (rule normalize_append_cancel_to (*‹⟦cancels_to ?l1.0 ?l1'; cancels_to ?l2.0 ?l2'⟧ ⟹ Cancelation.normalize (?l1.0 @ ?l2.0) = Cancelation.normalize (?l1' @ ?l2')›*))
(*goals:
1. ‹⟦cancels_to (y @ z) (Cancelation.normalize (y @ z)); cancels_to x x⟧ ⟹ cancels_to x x›
2. ‹⟦cancels_to (y @ z) (Cancelation.normalize (y @ z)); cancels_to x x⟧ ⟹ cancels_to (y @ z) (Cancelation.normalize (y @ z))›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*) .
(*proven 2 subgoals*)
finally (*calculation: ‹Cancelation.normalize (Cancelation.normalize (x @ y) @ z) = Cancelation.normalize (x @ Cancelation.normalize (y @ z))›*) show "x ⊗⇘ℱ⇘gens⇙⇙ y ⊗⇘ℱ⇘gens⇙⇙ z =
x ⊗⇘ℱ⇘gens⇙⇙ (y ⊗⇘ℱ⇘gens⇙⇙ z)"
by (auto simp add:free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*))
next
(*goals:
1. ‹𝟭⇘ℱ⇘gens⇙⇙ ∈ carrier ℱ⇘gens⇙›
2. ‹⋀x. x ∈ carrier ℱ⇘gens⇙ ⟹ 𝟭⇘ℱ⇘gens⇙⇙ ⊗⇘ℱ⇘gens⇙⇙ x = x›
3. ‹⋀x. x ∈ carrier ℱ⇘gens⇙ ⟹ x ⊗⇘ℱ⇘gens⇙⇙ 𝟭⇘ℱ⇘gens⇙⇙ = x›
4. ‹carrier ℱ⇘gens⇙ ⊆ Units ℱ⇘gens⇙›*)
show "𝟭⇘ℱ⇘gens⇙⇙ ∈ carrier ℱ⇘gens⇙"
by (auto simp add:free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*))
next
(*goals:
1. ‹⋀x. x ∈ carrier ℱ⇘gens⇙ ⟹ 𝟭⇘ℱ⇘gens⇙⇙ ⊗⇘ℱ⇘gens⇙⇙ x = x›
2. ‹⋀x. x ∈ carrier ℱ⇘gens⇙ ⟹ x ⊗⇘ℱ⇘gens⇙⇙ 𝟭⇘ℱ⇘gens⇙⇙ = x›
3. ‹carrier ℱ⇘gens⇙ ⊆ Units ℱ⇘gens⇙›*)
fix x
assume "x ∈ carrier ℱ⇘gens⇙" (*‹(x::(bool × 'a) list) ∈ carrier ℱ⇘gens::'a set⇙›*)
thus "𝟭⇘ℱ⇘gens⇙⇙ ⊗⇘ℱ⇘gens⇙⇙ x = x"
by (auto simp add:free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*))
next
(*goals:
1. ‹⋀x. x ∈ carrier ℱ⇘gens⇙ ⟹ x ⊗⇘ℱ⇘gens⇙⇙ 𝟭⇘ℱ⇘gens⇙⇙ = x›
2. ‹carrier ℱ⇘gens⇙ ⊆ Units ℱ⇘gens⇙›*)
fix x
assume "x ∈ carrier ℱ⇘gens⇙" (*‹(x::(bool × 'a) list) ∈ carrier ℱ⇘gens::'a set⇙›*)
thus "x ⊗⇘ℱ⇘gens⇙⇙ 𝟭⇘ℱ⇘gens⇙⇙ = x"
by (auto simp add:free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*))
next
(*goal: ‹carrier ℱ⇘gens⇙ ⊆ Units ℱ⇘gens⇙›*)
show "carrier ℱ⇘gens⇙ ⊆ Units ℱ⇘gens⇙"
apply (simp add:free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*) Units_def (*‹Units ?G = {y ∈ carrier ?G. ∃x∈carrier ?G. x ⊗⇘?G⇙ y = 𝟭⇘?G⇙ ∧ y ⊗⇘?G⇙ x = 𝟭⇘?G⇙}›*))
(*goal: ‹carrier ℱ⇘gens⇙ ⊆ Units ℱ⇘gens⇙›*)
proof (rule subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*))
(*goal: ‹⋀x. x ∈ {l ∈ lists (UNIV × gens). canceled l} ⟹ x ∈ {y ∈ lists (UNIV × gens). canceled y ∧ (∃x. x ∈ lists (UNIV × gens) ∧ canceled x ∧ Cancelation.normalize (x @ y) = [] ∧ Cancelation.normalize (y @ x) = [])}›*)
fix x :: "'a word_g_i"
let ?x' = "inv_fg x"
assume "x ∈ {y∈lists(UNIV×gens). canceled y}" (*‹(x::(bool × 'a) list) ∈ {y::(bool × 'a) list ∈ lists (UNIV × (gens::'a set)). canceled y}›*)
hence "?x' ∈ lists(UNIV×gens) ∧ canceled ?x'"
by (auto elim:inv_fg_closure1 (*‹canceled ?l ⟹ canceled (inv_fg ?l)›*) simp add:inv_fg_closure2 (*‹?l ∈ lists (UNIV × ?gens) ⟹ inv_fg ?l ∈ lists (UNIV × ?gens)›*))
moreover have "normalize (?x' @ x) = []" and "normalize (x @ ?x') = []"
(*goals:
1. ‹Cancelation.normalize (inv_fg x @ x) = []›
2. ‹Cancelation.normalize (x @ inv_fg x) = []›
discuss goal 1*)
apply ((auto simp add:inv_fg_cancel (*‹Cancelation.normalize (?l @ inv_fg ?l) = []›*) inv_fg_cancel2 (*‹Cancelation.normalize (inv_fg ?l @ ?l) = []›*))[1])
(*discuss goal 2*)
apply ((auto simp add:inv_fg_cancel (*‹Cancelation.normalize (?l @ inv_fg ?l) = []›*) inv_fg_cancel2 (*‹Cancelation.normalize (inv_fg ?l @ ?l) = []›*))[1])
(*proven 2 subgoals*) .
ultimately have "∃y. y ∈ lists (UNIV × gens) ∧
canceled y ∧
normalize (y @ x) = [] ∧ normalize (x @ y) = []"
by auto
with ‹x ∈ {y∈lists(UNIV×gens). canceled y}› (*‹(x::(bool × 'a::type) list) ∈ {y::(bool × 'a::type) list ∈ lists (UNIV × (gens::'a::type set)). canceled y}›*) show "x ∈ {y ∈ lists (UNIV × gens). canceled y ∧
(∃x. x ∈ lists (UNIV × gens) ∧
canceled x ∧
normalize (x @ y) = [] ∧ normalize (y @ x) = [])}"
by auto
qed
qed
lemma inv_is_inv_fg[simp]:
"x ∈ carrier ℱ⇘gens⇙ ⟹ inv⇘ℱ⇘gens⇙⇙ x = inv_fg x"
apply (rule group.inv_equality (*‹⟦Group.group ?G; ?y ⊗⇘?G⇙ ?x = 𝟭⇘?G⇙; ?x ∈ carrier ?G; ?y ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x = ?y›*))
(*goals:
1. ‹x ∈ carrier ℱ⇘gens⇙ ⟹ Group.group ℱ⇘gens⇙›
2. ‹x ∈ carrier ℱ⇘gens⇙ ⟹ inv_fg x ⊗⇘ℱ⇘gens⇙⇙ x = 𝟭⇘ℱ⇘gens⇙⇙›
3. ‹x ∈ carrier ℱ⇘gens⇙ ⟹ x ∈ carrier ℱ⇘gens⇙›
4. ‹x ∈ carrier ℱ⇘gens⇙ ⟹ inv_fg x ∈ carrier ℱ⇘gens⇙›
discuss goal 1*)
apply ((auto simp add:free_group_is_group (*‹Group.group ℱ⇘?gens⇙›*))[1])
(*discuss goal 2*)
apply ((auto simp add: free_group_def (*‹ℱ⇘?gens::?'a set⇙ ≡ ⦇carrier = {l::(bool × ?'a) list ∈ lists (UNIV × ?gens). canceled l}, mult = λ(x::(bool × ?'a) list) y::(bool × ?'a) list. Cancelation.normalize (x @ y), one = []⦈›*) inv_fg_cancel (*‹Cancelation.normalize ((?l::(bool × ?'a) list) @ inv_fg ?l) = []›*) inv_fg_cancel2 (*‹Cancelation.normalize (inv_fg (?l::(bool × ?'a) list) @ ?l) = []›*) inv_fg_closure1 (*‹canceled (?l::(bool × ?'a) list) ⟹ canceled (inv_fg ?l)›*) inv_fg_closure2 (*‹(?l::(bool × ?'a) list) ∈ lists (UNIV × (?gens::?'a set)) ⟹ inv_fg ?l ∈ lists (UNIV × ?gens)›*))[1])
(*discuss goal 3*)
apply ((auto simp add:free_group_is_group (*‹Group.group ℱ⇘?gens⇙›*))[1])
(*discuss goal 4*)
apply ((auto simp add: free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*) inv_fg_cancel (*‹Cancelation.normalize (?l @ inv_fg ?l) = []›*) inv_fg_cancel2 (*‹Cancelation.normalize (inv_fg ?l @ ?l) = []›*) inv_fg_closure1 (*‹canceled ?l ⟹ canceled (inv_fg ?l)›*) inv_fg_closure2 (*‹?l ∈ lists (UNIV × ?gens) ⟹ inv_fg ?l ∈ lists (UNIV × ?gens)›*))[1])
(*proven 4 subgoals*) .
subsection ‹The universal property›
text ‹Free Groups are important due to their universal property: Every map of
the set of generators to another group can be extended uniquely to an
homomorphism from the Free Group.›
definition insert ("ι")
where "ι g = [(False, g)]"
lemma insert_closed:
"g ∈ gens ⟹ ι g ∈ carrier ℱ⇘gens⇙"
by (auto simp add:insert_def (*‹ι ?g = [(False, ?g)]›*) free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*))
definition (in group) lift_gi
where "lift_gi f gi = (if fst gi then inv (f (snd gi)) else f (snd gi))"
lemma (in group) lift_gi_closed:
assumes cl: "f ∈ gens → carrier G"
and "snd gi ∈ gens"
shows "lift_gi f gi ∈ carrier G"
using assms (*‹(f::'c ⇒ 'a) ∈ (gens::'c set) → carrier G› ‹snd (gi::bool × 'c) ∈ (gens::'c set)›*) by (auto simp add:lift_gi_def (*‹lift_gi ?f ?gi = (if fst ?gi then inv ?f (snd ?gi) else ?f (snd ?gi))›*))
definition (in group) lift
where "lift f w = m_concat (map (lift_gi f) w)"
lemma (in group) lift_nil[simp]: "lift f [] = 𝟭"
by (auto simp add:lift_def (*‹lift (?f::?'c::type ⇒ 'a::type) (?w::(bool × ?'c::type) list) = m_concat (map (lift_gi ?f) ?w)›*))
lemma (in group) lift_closed[simp]:
assumes cl: "f ∈ gens → carrier G"
and "x ∈ lists (UNIV × gens)"
shows "lift f x ∈ carrier G"
proof (-)
(*goal: ‹lift f x ∈ carrier G›*)
have "set (map (lift_gi f) x) ⊆ carrier G"
using ‹x ∈ lists (UNIV × gens)› (*‹x ∈ lists (UNIV × gens)›*) by (auto simp add:lift_gi_closed[OF cl] (*‹snd ?gi ∈ gens ⟹ lift_gi f ?gi ∈ carrier G›*))
thus "lift f x ∈ carrier G"
by (auto simp add:lift_def (*‹lift ?f ?w = m_concat (map (lift_gi ?f) ?w)›*))
qed
lemma (in group) lift_append[simp]:
assumes cl: "f ∈ gens → carrier G"
and "x ∈ lists (UNIV × gens)"
and "y ∈ lists (UNIV × gens)"
shows "lift f (x @ y) = lift f x ⊗ lift f y"
proof (-)
(*goal: ‹lift f (x @ y) = lift f x ⊗ lift f y›*)
from ‹x ∈ lists (UNIV × gens)› (*‹x ∈ lists (UNIV × gens)›*) have "set (map snd x) ⊆ gens"
by auto
hence "set (map (lift_gi f) x) ⊆ carrier G"
apply (induct x)
(*goals:
1. ‹set (map snd []) ⊆ gens ⟹ set (map (lift_gi f) []) ⊆ carrier G›
2. ‹⋀a x. ⟦set (map snd x) ⊆ gens ⟹ set (map (lift_gi f) x) ⊆ carrier G; set (map snd (a # x)) ⊆ gens⟧ ⟹ set (map (lift_gi f) (a # x)) ⊆ carrier G›
discuss goal 1*)
apply ((auto simp add:lift_gi_closed[OF cl] (*‹snd ?gi ∈ gens ⟹ lift_gi f ?gi ∈ carrier G›*))[1])
(*discuss goal 2*)
apply ((auto simp add:lift_gi_closed[OF cl] (*‹snd (?gi::bool × 'c::type) ∈ (gens::'c::type set) ⟹ lift_gi (f::'c::type ⇒ 'a::type) ?gi ∈ carrier G›*))[1])
(*proven 2 subgoals*) .
moreover from ‹y ∈ lists (UNIV × gens)› (*‹y ∈ lists (UNIV × gens)›*) have "set (map snd y) ⊆ gens"
by auto
hence "set (map (lift_gi f) y) ⊆ carrier G"
apply (induct y)
(*goals:
1. ‹set (map snd []) ⊆ gens ⟹ set (map (lift_gi f) []) ⊆ carrier G›
2. ‹⋀a y. ⟦set (map snd y) ⊆ gens ⟹ set (map (lift_gi f) y) ⊆ carrier G; set (map snd (a # y)) ⊆ gens⟧ ⟹ set (map (lift_gi f) (a # y)) ⊆ carrier G›
discuss goal 1*)
apply ((auto simp add:lift_gi_closed[OF cl] (*‹snd ?gi ∈ gens ⟹ lift_gi f ?gi ∈ carrier G›*))[1])
(*discuss goal 2*)
apply ((auto simp add:lift_gi_closed[OF cl] (*‹snd ?gi ∈ gens ⟹ lift_gi f ?gi ∈ carrier G›*))[1])
(*proven 2 subgoals*) .
ultimately show "lift f (x @ y) = lift f x ⊗ lift f y"
by (auto simp add:lift_def (*‹lift ?f ?w = m_concat (map (lift_gi ?f) ?w)›*) m_assoc (*‹⟦?x ∈ carrier G; ?y ∈ carrier G; ?z ∈ carrier G⟧ ⟹ ?x ⊗ ?y ⊗ ?z = ?x ⊗ (?y ⊗ ?z)›*) simp del:set_map (*‹set (map ?f ?xs) = ?f ` set ?xs›*) foldr_append (*‹foldr ?f (?xs @ ?ys) ?a = foldr ?f ?xs (foldr ?f ?ys ?a)›*))
qed
lemma (in group) lift_cancels_to:
assumes "cancels_to x y"
and "x ∈ lists (UNIV × gens)"
and cl: "f ∈ gens → carrier G"
shows "lift f x = lift f y"
using assms (*‹cancels_to x y› ‹x ∈ lists (UNIV × gens)› ‹f ∈ gens → carrier G›*) unfolding cancels_to_def
(*goal: ‹lift (f::'c::type ⇒ 'a::type) (x::(bool × 'c::type) list) = lift f (y::(bool × 'c::type) list)›*)
proof (induct rule:rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*))
(*goals:
1. ‹⟦(x::(bool × 'c::type) list) ∈ lists (UNIV × (gens::'c::type set)); (f::'c::type ⇒ 'a::type) ∈ gens → carrier G⟧ ⟹ lift f x = lift f x›
2. ‹⋀(y::(bool × 'c::type) list) z::(bool × 'c::type) list. ⟦cancels_to_1⇧*⇧* (x::(bool × 'c::type) list) y; cancels_to_1 y z; ⟦x ∈ lists (UNIV × (gens::'c::type set)); (f::'c::type ⇒ 'a::type) ∈ gens → carrier G⟧ ⟹ lift f x = lift f y; x ∈ lists (UNIV × gens); f ∈ gens → carrier G⟧ ⟹ lift f x = lift f z›*)
case (step y z) (*‹cancels_to_1⇧*⇧* (x::(bool × 'c) list) (y::(bool × 'c) list)› ‹cancels_to_1 y z› ‹⟦x ∈ lists (UNIV × gens); f ∈ gens → carrier G⟧ ⟹ lift f x = lift f y› ‹x ∈ lists (UNIV × gens)› ‹(f::'c ⇒ 'a) ∈ (gens::'c set) → carrier G›*)
from ‹cancels_to_1⇧*⇧* x y› (*‹cancels_to_1⇧*⇧* x y›*) ‹x ∈ lists (UNIV × gens)› (*‹x ∈ lists (UNIV × gens)›*) have "y ∈ lists (UNIV × gens)"
apply -
(*goal: ‹y ∈ lists (UNIV × gens)›*)
apply (rule cancels_to_preserves_generators (*‹⟦cancels_to (?l::(bool × ?'a::type) list) (?l'::(bool × ?'a::type) list); ?l ∈ lists (UNIV × (?gens::?'a::type set))⟧ ⟹ ?l' ∈ lists (UNIV × ?gens)›*))
(*goals:
1. ‹⟦cancels_to_1⇧*⇧* x y; x ∈ lists (UNIV × gens)⟧ ⟹ cancels_to ?l2 y›
2. ‹⟦cancels_to_1⇧*⇧* x y; x ∈ lists (UNIV × gens)⟧ ⟹ ?l2 ∈ lists (UNIV × gens)›
discuss goal 1*)
apply (simp add:cancels_to_def (*‹cancels_to = cancels_to_1⇧*⇧*›*))
(*discuss goal 2*) .
(*proven 2 subgoals*)
hence "lift f x = lift f y"
using step (*‹cancels_to_1⇧*⇧* x y› ‹cancels_to_1 y z› ‹⟦(x::(bool × 'c::type) list) ∈ lists (UNIV × (gens::'c::type set)); (f::'c::type ⇒ 'a::type) ∈ gens → carrier G⟧ ⟹ lift f x = lift f (y::(bool × 'c::type) list)› ‹x ∈ lists (UNIV × gens)› ‹f ∈ gens → carrier G›*) by auto
also (*calculation: ‹lift f x = lift f y›*) from ‹cancels_to_1 y z› (*‹cancels_to_1 (y::(bool × 'c) list) (z::(bool × 'c) list)›*) obtain ys1 and y1 and y2 and ys2 where y: "y = ys1 @ y1 # y2 # ys2" and "z = ys1 @ ys2" and "canceling y1 y2"
(*goal: ‹(⋀ys1 y1 y2 ys2. ⟦y = ys1 @ y1 # y2 # ys2; z = ys1 @ ys2; canceling y1 y2⟧ ⟹ thesis) ⟹ thesis›*)
by (rule cancels_to_1_unfold (*‹⟦cancels_to_1 ?x ?y; ⋀xs1 x1 x2 xs2. ⟦?x = xs1 @ x1 # x2 # xs2; ?y = xs1 @ xs2; canceling x1 x2⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
have "lift f y = lift f (ys1 @ [y1] @ [y2] @ ys2)"
using y (*‹y = ys1 @ y1 # y2 # ys2›*) by simp
also (*calculation: ‹lift f x = lift f (ys1 @ [y1] @ [y2] @ ys2)›*) from y (*‹(y::(bool × 'c::type) list) = (ys1::(bool × 'c::type) list) @ (y1::bool × 'c::type) # (y2::bool × 'c::type) # (ys2::(bool × 'c::type) list)›*) cl (*‹f ∈ gens → carrier G›*) ‹y ∈ lists (UNIV × gens)› (*‹y ∈ lists (UNIV × gens)›*) have "lift f (ys1 @ [y1] @ [y2] @ ys2)
= lift f ys1 ⊗ (lift f [y1] ⊗ lift f [y2]) ⊗ lift f ys2"
by (auto intro:lift_append[OF cl] (*‹⟦?x ∈ lists (UNIV × gens); ?y ∈ lists (UNIV × gens)⟧ ⟹ lift f (?x @ ?y) = lift f ?x ⊗ lift f ?y›*) simp del: append_Cons (*‹(?x # ?xs) @ ?ys = ?x # ?xs @ ?ys›*) simp add:m_assoc (*‹⟦?x ∈ carrier G; ?y ∈ carrier G; ?z ∈ carrier G⟧ ⟹ ?x ⊗ ?y ⊗ ?z = ?x ⊗ (?y ⊗ ?z)›*) iff:lists_eq_set (*‹lists ?A = {xs. set xs ⊆ ?A}›*))
also (*calculation: ‹lift f x = lift f ys1 ⊗ (lift f [y1] ⊗ lift f [y2]) ⊗ lift f ys2›*) from cl[THEN funcset_image] (*‹f ` gens ⊆ carrier G›*) y (*‹y = ys1 @ y1 # y2 # ys2›*) ‹y ∈ lists (UNIV × gens)› (*‹y ∈ lists (UNIV × gens)›*) ‹canceling y1 y2› (*‹canceling y1 y2›*) have "(lift f [y1] ⊗ lift f [y2]) = 𝟭"
by (auto simp add:lift_def (*‹lift ?f ?w = m_concat (map (lift_gi ?f) ?w)›*) lift_gi_def (*‹lift_gi ?f ?gi = (if fst ?gi then inv ?f (snd ?gi) else ?f (snd ?gi))›*) canceling_def (*‹canceling ?a ?b = (snd ?a = snd ?b ∧ fst ?a ≠ fst ?b)›*) iff:lists_eq_set (*‹lists ?A = {xs. set xs ⊆ ?A}›*))
hence "lift f ys1 ⊗ (lift f [y1] ⊗ lift f [y2]) ⊗ lift f ys2
= lift f ys1 ⊗ 𝟭 ⊗ lift f ys2"
by simp
also (*calculation: ‹lift f x = lift f ys1 ⊗ 𝟭 ⊗ lift f ys2›*) from y (*‹y = ys1 @ y1 # y2 # ys2›*) ‹y ∈ lists (UNIV × gens)› (*‹(y::(bool × 'c) list) ∈ lists (UNIV × (gens::'c set))›*) cl (*‹f ∈ gens → carrier G›*) have "lift f ys1 ⊗ 𝟭 ⊗ lift f ys2 = lift f (ys1 @ ys2)"
by (auto intro:lift_append (*‹⟦?f ∈ ?gens → carrier G; ?x ∈ lists (UNIV × ?gens); ?y ∈ lists (UNIV × ?gens)⟧ ⟹ lift ?f (?x @ ?y) = lift ?f ?x ⊗ lift ?f ?y›*) iff:lists_eq_set (*‹lists ?A = {xs. set xs ⊆ ?A}›*))
also (*calculation: ‹lift f x = lift f (ys1 @ ys2)›*) from ‹z = ys1 @ ys2› (*‹z = ys1 @ ys2›*) have "lift f (ys1 @ ys2) = lift f z"
by simp
finally (*calculation: ‹lift f x = lift f z›*) show "lift f x = lift f z" .
qed (auto)
(*solved the remaining goal: ‹⟦x ∈ lists (UNIV × gens); f ∈ gens → carrier G⟧ ⟹ lift f x = lift f x›*)
lemma (in group) lift_is_hom:
assumes cl: "f ∈ gens → carrier G"
shows "lift f ∈ hom ℱ⇘gens⇙ G"
proof (-)
(*goal: ‹lift f ∈ hom ℱ⇘gens⇙ G›*)
{
fix x
assume "x ∈ carrier ℱ⇘gens⇙" (*‹(x::(bool × 'c) list) ∈ carrier ℱ⇘gens::'c set⇙›*)
hence "x ∈ lists (UNIV × gens)"
unfolding free_group_def
(*goal: ‹x ∈ lists (UNIV × gens)›*)
by simp
hence "lift f x ∈ carrier G"
apply (induct x)
(*goals:
1. ‹lift (f::'c::type ⇒ 'a::type) [] ∈ carrier G›
2. ‹⋀(a::bool × 'c::type) l::(bool × 'c::type) list. ⟦a ∈ UNIV × (gens::'c::type set); l ∈ lists (UNIV × gens); lift (f::'c::type ⇒ 'a::type) l ∈ carrier G⟧ ⟹ lift f (a # l) ∈ carrier G›
discuss goal 1*)
apply ((auto simp add:lift_def (*‹lift ?f ?w = m_concat (map (lift_gi ?f) ?w)›*) lift_gi_closed[OF cl] (*‹snd ?gi ∈ gens ⟹ lift_gi f ?gi ∈ carrier G›*))[1])
(*discuss goal 2*)
apply ((auto simp add:lift_def (*‹lift ?f ?w = m_concat (map (lift_gi ?f) ?w)›*) lift_gi_closed[OF cl] (*‹snd ?gi ∈ gens ⟹ lift_gi f ?gi ∈ carrier G›*))[1])
(*proven 2 subgoals*) .
}
moreover {
fix x
assume "x ∈ carrier ℱ⇘gens⇙" (*‹(x::(bool × 'c) list) ∈ carrier ℱ⇘gens::'c set⇙›*)
fix y
assume "y ∈ carrier ℱ⇘gens⇙" (*‹(y::(bool × 'c) list) ∈ carrier ℱ⇘gens::'c set⇙›*)
from ‹x ∈ carrier ℱ⇘gens⇙› (*‹x ∈ carrier ℱ⇘gens⇙›*) ‹y ∈ carrier ℱ⇘gens⇙› (*‹y ∈ carrier ℱ⇘gens⇙›*) have "x ∈ lists (UNIV × gens)" and "y ∈ lists (UNIV × gens)"
apply -
(*goals:
1. ‹⟦x ∈ carrier ℱ⇘gens⇙; y ∈ carrier ℱ⇘gens⇙⟧ ⟹ x ∈ lists (UNIV × gens)›
2. ‹⟦x ∈ carrier ℱ⇘gens⇙; y ∈ carrier ℱ⇘gens⇙⟧ ⟹ y ∈ lists (UNIV × gens)›
discuss goal 1*)
apply ((auto simp add:free_group_def (*‹ℱ⇘?gens::?'a::type set⇙ ≡ ⦇carrier = {l::(bool × ?'a::type) list ∈ lists (UNIV × ?gens). canceled l}, mult = λ(x::(bool × ?'a::type) list) y::(bool × ?'a::type) list. Cancelation.normalize (x @ y), one = []⦈›*))[1])
(*discuss goal 2*)
apply ((auto simp add:free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*))[1])
(*proven 2 subgoals*) .
have "cancels_to (x @ y) (normalize (x @ y))"
by simp
from ‹x ∈ lists (UNIV × gens)› (*‹x ∈ lists (UNIV × gens)›*) ‹y ∈ lists (UNIV × gens)› (*‹(y::(bool × 'c::type) list) ∈ lists (UNIV × (gens::'c::type set))›*) lift_cancels_to[THEN sym, OF ‹cancels_to (x @ y) (normalize (x @ y))›] (*‹⟦x @ y ∈ lists (UNIV × ?gens1); ?f1 ∈ ?gens1 → carrier G⟧ ⟹ lift ?f1 (Cancelation.normalize (x @ y)) = lift ?f1 (x @ y)›*) cl (*‹f ∈ gens → carrier G›*) have "lift f (x ⊗⇘ℱ⇘gens⇙⇙ y) = lift f (x @ y)"
by (auto simp add:free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*) iff:lists_eq_set (*‹lists ?A = {xs. set xs ⊆ ?A}›*))
also (*calculation: ‹lift f (x ⊗⇘ℱ⇘gens⇙⇙ y) = lift f (x @ y)›*) from ‹x ∈ lists (UNIV × gens)› (*‹x ∈ lists (UNIV × gens)›*) ‹y ∈ lists (UNIV × gens)› (*‹y ∈ lists (UNIV × gens)›*) cl (*‹f ∈ gens → carrier G›*) have "lift f (x @ y) = lift f x ⊗ lift f y"
by simp
finally (*calculation: ‹lift (f::'c ⇒ 'a) ((x::(bool × 'c) list) ⊗⇘ℱ⇘gens::'c set⇙⇙ (y::(bool × 'c) list)) = lift f x ⊗ lift f y›*) have "lift f (x ⊗⇘ℱ⇘gens⇙⇙ y) = lift f x ⊗ lift f y" .
}
ultimately show "lift f ∈ hom ℱ⇘gens⇙ G"
by auto
qed
lemma gens_span_free_group:
shows "⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙ = carrier ℱ⇘gens⇙"
proof (standard)
(*goals:
1. ‹⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙ ⊆ carrier ℱ⇘gens⇙›
2. ‹carrier ℱ⇘gens⇙ ⊆ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙›*)
interpret group "ℱ⇘gens⇙"
by (rule free_group_is_group (*‹Group.group ℱ⇘?gens⇙›*))
show "⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙ ⊆ carrier ℱ⇘gens⇙"
apply (rule gen_span_closed (*‹(?gens::(bool × 'a::type) list set) ⊆ carrier ℱ⇘gens::'a::type set⇙ ⟹ ⟨?gens⟩⇘ℱ⇘gens⇙⇙ ⊆ carrier ℱ⇘gens⇙›*))
(*goal: ‹⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙ ⊆ carrier ℱ⇘gens⇙›*)
by (auto simp add:insert_def (*‹ι (?g::?'a) = [(False, ?g)]›*) free_group_def (*‹ℱ⇘?gens::?'a set⇙ ≡ ⦇carrier = {l::(bool × ?'a) list ∈ lists (UNIV × ?gens). canceled l}, mult = λ(x::(bool × ?'a) list) y::(bool × ?'a) list. Cancelation.normalize (x @ y), one = []⦈›*))
show "carrier ℱ⇘gens⇙ ⊆ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙"
proof (standard)
(*goal: ‹⋀x. x ∈ carrier ℱ⇘gens⇙ ⟹ x ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙›*)
fix x
show "x ∈ carrier ℱ⇘gens⇙ ⟹ x ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙"
proof (induct x)
(*goals:
1. ‹[] ∈ carrier ℱ⇘gens⇙ ⟹ [] ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙›
2. ‹⋀a x. ⟦x ∈ carrier ℱ⇘gens⇙ ⟹ x ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙; a # x ∈ carrier ℱ⇘gens⇙⟧ ⟹ a # x ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙›*)
case Nil (*‹[] ∈ carrier ℱ⇘gens⇙›*)
have "one ℱ⇘gens⇙ ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙"
by simp
thus "[] ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙"
by (simp add:free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*))
next
(*goal: ‹⋀a x. ⟦x ∈ carrier ℱ⇘gens⇙ ⟹ x ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙; a # x ∈ carrier ℱ⇘gens⇙⟧ ⟹ a # x ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙›*)
case (Cons a x) (*‹(x::(bool × 'a) list) ∈ carrier ℱ⇘gens::'a set⇙ ⟹ x ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙› ‹a # x ∈ carrier ℱ⇘gens⇙›*)
from ‹a # x ∈ carrier ℱ⇘gens⇙› (*‹(a::bool × 'a) # (x::(bool × 'a) list) ∈ carrier ℱ⇘gens::'a set⇙›*) have "x ∈ carrier ℱ⇘gens⇙"
by (auto intro:cons_canceled (*‹canceled (?a # ?x) ⟹ canceled ?x›*) simp add:free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*))
hence "x ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙"
using Cons (*‹x ∈ carrier ℱ⇘gens⇙ ⟹ x ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙› ‹a # x ∈ carrier ℱ⇘gens⇙›*) by simp
moreover from ‹a # x ∈ carrier ℱ⇘gens⇙› (*‹a # x ∈ carrier ℱ⇘gens⇙›*) have "snd a ∈ gens"
by (auto simp add:free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*))
hence isa: "ι (snd a) ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙"
by (auto simp add:insert_def (*‹ι ?g = [(False, ?g)]›*) intro:gen_gens (*‹?x ∈ ?gens ⟹ ?x ∈ ⟨?gens⟩⇘?G⇙›*))
have "[a] ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙"
proof (cases "fst a")
(*goals:
1. ‹fst a ⟹ [a] ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙›
2. ‹¬ fst a ⟹ [a] ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙›*)
case False (*‹¬ fst a›*)
hence "[a] = ι (snd a)"
apply (cases a)
(*goal: ‹[a::bool × 'a] = ι (snd a)›*)
by (auto simp add:insert_def (*‹ι ?g = [(False, ?g)]›*))
with isa (*‹ι (snd a) ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙›*) show "[a] ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙"
by simp
next
(*goal: ‹fst a ⟹ [a] ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙›*)
case True (*‹fst a›*)
from ‹snd a ∈ gens› (*‹snd a ∈ gens›*) have "ι (snd a) ∈ carrier ℱ⇘gens⇙"
by (auto simp add:free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*) insert_def (*‹ι ?g = [(False, ?g)]›*))
with True (*‹fst a›*) have "[a] = inv⇘ℱ⇘gens⇙⇙ (ι (snd a))"
apply (cases a)
(*goal: ‹[a] = inv⇘ℱ⇘gens⇙⇙ ι (snd a)›*)
by (auto simp add:insert_def (*‹ι ?g = [(False, ?g)]›*) inv_fg_def (*‹inv_fg ?l = rev (map inv1 ?l)›*) inv1_def (*‹inv1 = apfst Not›*))
moreover from isa (*‹ι (snd a) ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙›*) have "inv⇘ℱ⇘gens⇙⇙ (ι (snd a)) ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙"
by (auto intro:gen_inv (*‹?x ∈ ⟨?gens⟩⇘?G⇙ ⟹ inv⇘?G⇙ ?x ∈ ⟨?gens⟩⇘?G⇙›*))
ultimately show "[a] ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙"
by simp
qed
ultimately have "mult ℱ⇘gens⇙ [a] x ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙"
by (auto intro:gen_mult (*‹⟦(?x::?'a::type) ∈ ⟨?gens::?'a::type set⟩⇘?G::(?'a, ?'b) monoid_scheme⇙; (?y::?'a::type) ∈ ⟨?gens⟩⇘?G⇙⟧ ⟹ ?x ⊗⇘?G⇙ ?y ∈ ⟨?gens⟩⇘?G⇙›*))
with ‹a # x ∈ carrier ℱ⇘gens⇙› (*‹a # x ∈ carrier ℱ⇘gens⇙›*) show "a # x ∈ ⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙"
by (simp add:free_group_def (*‹ℱ⇘?gens⇙ ≡ ⦇carrier = {l ∈ lists (UNIV × ?gens). canceled l}, mult = λx y. Cancelation.normalize (x @ y), one = []⦈›*))
qed
qed
qed
lemma (in group) lift_is_unique:
assumes "group G"
and cl: "f ∈ gens → carrier G"
and "h ∈ hom ℱ⇘gens⇙ G"
and "∀ g ∈ gens. h (ι g) = f g"
shows "∀x ∈ carrier ℱ⇘gens⇙. h x = lift f x"
unfolding gens_span_free_group[THEN sym]
(*goal: ‹∀x∈⟨ι ` gens⟩⇘ℱ⇘gens⇙⇙. h x = lift f x›*)
proof (rule hom_unique_on_span[of "ℱ⇘gens⇙" G] (*‹⟦Group.group ℱ⇘gens⇙; Group.group G; ?gens ⊆ carrier ℱ⇘gens⇙; ?h ∈ hom ℱ⇘gens⇙ G; ?h' ∈ hom ℱ⇘gens⇙ G; ∀g∈?gens. ?h g = ?h' g⟧ ⟹ ∀x∈⟨?gens⟩⇘ℱ⇘gens⇙⇙. ?h x = ?h' x›*))
(*goals:
1. ‹Group.group ℱ⇘gens::'c set⇙›
2. ‹Group.group G›
3. ‹ι ` (gens::'c set) ⊆ carrier ℱ⇘gens⇙›
4. ‹(h::(bool × 'c) list ⇒ 'a) ∈ hom ℱ⇘gens::'c set⇙ G›
5. ‹lift (f::'c ⇒ 'a) ∈ hom ℱ⇘gens::'c set⇙ G›
6. ‹∀g::(bool × 'c) list∈ι ` (gens::'c set). (h::(bool × 'c) list ⇒ 'a) g = lift (f::'c ⇒ 'a) g›*)
show "group ℱ⇘gens⇙"
by (rule free_group_is_group (*‹Group.group ℱ⇘?gens⇙›*))
next
(*goals:
1. ‹Group.group G›
2. ‹ι ` gens ⊆ carrier ℱ⇘gens⇙›
3. ‹h ∈ hom ℱ⇘gens⇙ G›
4. ‹lift f ∈ hom ℱ⇘gens⇙ G›
5. ‹∀g∈ι ` gens. h g = lift f g›*)
show "group G"
by fact
next
(*goals:
1. ‹ι ` gens ⊆ carrier ℱ⇘gens⇙›
2. ‹h ∈ hom ℱ⇘gens⇙ G›
3. ‹lift f ∈ hom ℱ⇘gens⇙ G›
4. ‹∀g∈ι ` gens. h g = lift f g›*)
show "ι ` gens ⊆ carrier ℱ⇘gens⇙"
by (auto intro:insert_closed (*‹?g ∈ ?gens ⟹ ι ?g ∈ carrier ℱ⇘?gens⇙›*))
next
(*goals:
1. ‹h ∈ hom ℱ⇘gens⇙ G›
2. ‹lift f ∈ hom ℱ⇘gens⇙ G›
3. ‹∀g∈ι ` gens. h g = lift f g›*)
show "h ∈ hom ℱ⇘gens⇙ G"
by fact
next
(*goals:
1. ‹lift f ∈ hom ℱ⇘gens⇙ G›
2. ‹∀g∈ι ` gens. h g = lift f g›*)
show "lift f ∈ hom ℱ⇘gens⇙ G"
by (rule lift_is_hom[OF cl] (*‹lift f ∈ hom ℱ⇘gens⇙ G›*))
next
(*goal: ‹∀g∈ι ` gens. h g = lift f g›*)
from ‹∀g∈ gens. h (ι g) = f g› (*‹∀g∈gens. h (ι g) = f g›*) cl[THEN funcset_image] (*‹f ` gens ⊆ carrier G›*) show "∀g∈ ι ` gens. h g = lift f g"
by (auto simp add:insert_def (*‹ι ?g = [(False, ?g)]›*) lift_def (*‹lift ?f ?w = m_concat (map (lift_gi ?f) ?w)›*) lift_gi_def (*‹lift_gi ?f ?gi = (if fst ?gi then inv ?f (snd ?gi) else ?f (snd ?gi))›*))
qed
end
| {
"path": "afp-2025-02-12/thys/Free-Groups/FreeGroups.thy",
"repo": "afp-2025-02-12",
"sha": "0e131fba3db27198a4ebcb55430002c3e39cd64b2175f4bd51a13955239115a4"
} |
theory Iterate_GPV imports
"HOL-Library.BNF_Axiomatization"
"HOL-Library.BNF_Corec"
begin
declare [[typedef_overloaded]]
datatype 'a spmf = return_spmf 'a
primrec (transfer) bind_spmf where
"bind_spmf (return_spmf a) f = f a"
datatype (generat_pures: 'a, generat_outs: 'b, generat_conts: 'c) generat
= Pure (result: 'a)
| IO ("output": 'b) (continuation: "'c")
codatatype (results'_gpv: 'a, outs'_gpv: 'out, 'in) gpv
= GPV (the_gpv: "('a, 'out, 'in ⇒ ('a, 'out, 'in) gpv) generat spmf")
declare gpv.rel_eq [relator_eq]
primcorec bind_gpv :: "('a, 'out, 'in) gpv ⇒ ('a ⇒ ('b, 'out, 'in) gpv) ⇒ ('b, 'out, 'in) gpv"
where
"bind_gpv r f = GPV (map_spmf (map_generat id id ((∘) (case_sum id (λr. bind_gpv r f))))
(bind_spmf (the_gpv r)
(case_generat
(λx. map_spmf (map_generat id id ((∘) Inl)) (the_gpv (f x)))
(λout c. return_spmf (IO out (λinput. Inr (c input)))))))"
context includes lifting_syntax begin
lemma bind_gpv_parametric [transfer_rule]:
"(rel_gpv A C ===> (A ===> rel_gpv B C) ===> rel_gpv B C) bind_gpv bind_gpv"
unfolding bind_gpv_def
(*goal: ‹(rel_gpv A C ===> (A ===> rel_gpv B C) ===> rel_gpv B C) (λuu uua. corec_gpv (λ(r, f). map_spmf (map_generat id id ((∘) (λuu. case uu of Inl uu ⇒ Inl (id uu) | Inr r ⇒ Inr (r, f)))) (bind_spmf (the_gpv r) (case_generat (λx. map_spmf (map_generat id id ((∘) Inl)) (the_gpv (f x))) (λout c. return_spmf (IO out (λinput. Inr (c input))))))) (uu, uua)) (λuu uua. corec_gpv (λ(r, f). map_spmf (map_generat id id ((∘) (λuu. case uu of Inl uu ⇒ Inl (id uu) | Inr r ⇒ Inr (r, f)))) (bind_spmf (the_gpv r) (case_generat (λx. map_spmf (map_generat id id ((∘) Inl)) (the_gpv (f x))) (λout c. return_spmf (IO out (λinput. Inr (c input))))))) (uu, uua))›*)
by transfer_prover
end
lemma [friend_of_corec_simps]:
"map_spmf f (bind_spmf x h) = bind_spmf x (map_spmf f o h)"
apply (cases x)
(*goal: ‹map_spmf f (bind_spmf x h) = bind_spmf x (map_spmf f ∘ h)›*)
by auto
lemma [friend_of_corec_simps]:
"bind_spmf (map_spmf f x) h = bind_spmf x (h o f)"
apply (cases x)
(*goal: ‹bind_spmf (map_spmf f x) h = bind_spmf x (h ∘ f)›*)
by auto
friend_of_corec bind_gpv :: "('a, 'out, 'in) gpv ⇒ ('a ⇒ ('a, 'out, 'in) gpv) ⇒ ('a, 'out, 'in) gpv"
where "bind_gpv r f = GPV (map_spmf (map_generat id id ((∘) (case_sum id (λr. bind_gpv r f))))
(bind_spmf (the_gpv r)
(case_generat
(λx. map_spmf (map_generat id id ((∘) Inl)) (the_gpv (f x)))
(λout c. return_spmf (IO out (λinput. Inr (c input)))))))"
apply(rule bind_gpv.ctr)
apply transfer_prover
apply transfer_prover
done
end
| {
"path": "Isabelle2024/src/HOL/Corec_Examples/Tests/Iterate_GPV.thy",
"repo": "Isabelle2024",
"sha": "93085e37fa14c0b4220d06434320ac4d3a9affcc0923ed2a8eadffe5e51c5da5"
} |
(*
Formalization by Cárolos Laméris
Note that
bojanczyk2014automata ~
BojaÅczyk, M., Klin, B., & Lasota, S. (2014).
Automata theory in nominal sets.
Logical Methods in Computer Science, 10.
( https://lmcs.episciences.org/1157 )
*)
section ‹
Myhill-Nerode Theorem for $G$-automata
›
text ‹
We prove the Myhill-Nerode Theorem for $G$-automata / nominal $G$-automata
following the proofs from \cite{bojanczyk2014automata} (The standard Myhill-Nerode theorem is also
proved, as a special case of the $G$-Myhill-Nerode theorem).
Concretely, we formalize the following results from \cite{bojanczyk2014automata}:
lemmas: 3.4, 3.5, 3.6, 3.7, 4.8, 4.9;
proposition: 5.1;
theorems: 3.8 (Myhill-Nerode for $G$-automata), 5.2 (Myhill-Nerode for nominal $G$-automata).
Throughout this document, we maintain the following convention for isar proofs:
If we \texttt{obtain} some term \texttt{t} for which some result holds, we name it \texttt{H\_t}.
An assumption which is an induction hypothesis is named \texttt{A\_IH}
Assumptions start with an "\texttt{A}" and intermediate results start with a "\texttt{H}".
Typically we just name them via indexes, i.e. as \texttt{A\_i} and \texttt{H\_j}.
When encountering nested isar proofs we add an index for how nested the assumption / intermediate
result is.
For example if we have an isar proof in an isar proof in an isar proof, we would name assumptions
of the most nested proof \texttt{A3\_i}.
›
theory Nominal_Myhill_Nerode
imports
Main
HOL.Groups
HOL.Relation
HOL.Fun
"HOL-Algebra.Group_Action"
"HOL-Library.Adhoc_Overloading"
"HOL-Algebra.Elementary_Groups"
begin
text ‹
\texttt{GMN\_simps} will contain selection of lemmas / definitions is updated through out
the document.
›
named_theorems GMN_simps
lemmas GMN_simps
text ‹
We will use the $\star$-symbol for the set of words of elements of a set, $A^{\star}$, the induced
group action on the set of words $\phi^{\star}$ and for the extended transition function
$\delta^{\star}$, thus we introduce the map \texttt{star} and apply \texttt{adhoc\_overloading} to
get the notation working in all three situations:
›
consts star :: "'typ1 ⇒ 'typ2" ("_⇧⋆" [1000] 999)
adhoc_overloading
star lists
text ‹
We use $\odot$ to convert between the definition of group actions via group homomoprhisms
and the more standard infix group action notation.
We deviate from \cite{bojanczyk2014automata} in that we consider left group actions,
rather than right group actions:
›
definition
make_op :: "('grp ⇒ 'X ⇒ 'X) ⇒ 'grp ⇒ 'X ⇒ 'X" (infixl "(⊙ı)" 70)
where " (⊙ ⇘φ⇙) ≡ (λg. (λx. φ g x))"
lemmas make_op_def [simp, GMN_simps]
subsection ‹
Extending Group Actions
›
text ‹
The following lemma is used for a proof in the locale \texttt{alt\_grp\_act}:
›
lemma pre_image_lemma:
"⟦S ⊆ T; x ∈ T ∧ f ∈ Bij T; (restrict f S) ` S = S; f x ∈ S⟧ ⟹ x ∈ S"
apply (clarsimp simp add: extensional_def (*‹extensional ?A = {f. ∀x. x ∉ ?A ⟶ f x = undefined}›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*) restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*) inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))
(*goal: ‹⟦S ⊆ T; x ∈ T ∧ f ∈ Bij T; restrict f S ` S = S; f x ∈ S⟧ ⟹ x ∈ S›*)
by (metis imageE (*‹⟦?b ∈ ?f ` ?A; ⋀x. ⟦?b = ?f x; x ∈ ?A⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
text ‹
The locale \texttt{alt\_grp\_act} is just a renaming of the locale \texttt{group\_action}.
This was done to obtain more easy to interpret type names and context variables closer
to the notation of \cite{bojanczyk2014automata}:
›
locale alt_grp_act = group_action G X φ
for
G :: "('grp, 'b) monoid_scheme" and
X :: "'X set" (structure) and
φ
begin
lemma alt_grp_act_is_left_grp_act:
shows "x ∈ X ⟹ 𝟭⇘G⇙ ⊙⇘φ⇙ x = x" and
"g ∈ carrier G ⟹ h ∈ carrier G ⟹ x ∈ X ⟹ (g ⊗⇘G⇙ h) ⊙⇘φ⇙ x = g ⊙⇘φ⇙ (h ⊙⇘φ⇙ x)"
proof (-)
(*goals:
1. ‹x ∈ X ⟹ 𝟭⇘G⇙ ⊙⇘φ⇙ x = x›
2. ‹⟦g ∈ carrier G; h ∈ carrier G; x ∈ X⟧ ⟹ g ⊗⇘G⇙ h ⊙⇘φ⇙ x = g ⊙⇘φ⇙ (h ⊙⇘φ⇙ x)›*)
assume A_0: "x ∈ X" (*‹(x::'X) ∈ X›*)
show "𝟭⇘G⇙ ⊙⇘φ⇙ x = x"
using group_action_axioms (*‹group_action (G::('grp, 'b) monoid_scheme) X (φ::'grp ⇒ 'X ⇒ 'X)›*) apply (simp add: group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*))
(*goal: ‹𝟭⇘G⇙ ⊙⇘φ⇙ x = x›*)
by (metis A_0 (*‹x ∈ X›*) id_eq_one (*‹(λx∈X. x) = φ 𝟭⇘G⇙›*) restrict_apply' (*‹?x ∈ ?A ⟹ restrict ?f ?A ?x = ?f ?x›*))
next
(*goal: ‹⟦(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); (h::'grp) ∈ carrier G; (x::'X) ∈ X⟧ ⟹ g ⊗⇘G⇙ h ⊙⇘φ::'grp ⇒ 'X ⇒ 'X⇙ x = g ⊙⇘φ⇙ (h ⊙⇘φ⇙ x)›*)
assume A_0: "g ∈ carrier G" and A_1: "h ∈ carrier G" and A_2: "x ∈ X" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹(h::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹(x::'X) ∈ X›*)
show "g ⊗⇘G⇙ h ⊙⇘φ⇙ x = g ⊙⇘φ⇙ (h ⊙⇘φ⇙ x)"
using group_action_axioms (*‹group_action G X φ›*) apply (simp add: group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*))
(*goal: ‹(g::'grp::type) ⊗⇘G::('grp, 'b) monoid_scheme⇙ (h::'grp::type) ⊙⇘φ::'grp::type ⇒ 'X::type ⇒ 'X::type⇙ (x::'X::type) = g ⊙⇘φ⇙ (h ⊙⇘φ⇙ x)›*)
using composition_rule (*‹⟦(?x::'X) ∈ X; (?g1.0::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); (?g2.0::'grp) ∈ carrier G⟧ ⟹ (φ::'grp ⇒ 'X ⇒ 'X) (?g1.0 ⊗⇘G⇙ ?g2.0) ?x = φ ?g1.0 (φ ?g2.0 ?x)›*) A_0 (*‹g ∈ carrier G›*) A_1 (*‹(h::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A_2 (*‹x ∈ X›*) by auto
qed
definition
induced_star_map :: "('grp ⇒ 'X ⇒'X) ⇒ 'grp ⇒ 'X list ⇒ 'X list"
where "induced_star_map func = (λg∈carrier G. (λlst ∈ X⇧⋆. map (func g) lst))"
text ‹
Because the adhoc overloading is used within a locale, isues will be encountered later due to there
being multiple instances of the locale \texttt{alt\_grp\_act} in a single context:
›
adhoc_overloading
star induced_star_map
definition
induced_quot_map ::
"'Y set ⇒ ('grp ⇒ 'Y ⇒ 'Y) ⇒ ('Y ×'Y) set ⇒ 'grp ⇒ 'Y set ⇒ 'Y set" ("[_]⇩_ı" 60)
where "([ func ]⇩R ⇘S⇙) = (λg∈carrier G. (λx ∈ (S // R). R `` {(func g) (SOME z. z∈x)}))"
lemmas induced_star_map_def [simp, GMN_simps]
induced_quot_map_def [simp, GMN_simps]
lemma act_maps_n_distrib:
"∀g∈carrier G. ∀w∈X⇧⋆. ∀v∈X⇧⋆. (φ⇧⋆) g (w @ v) = ((φ⇧⋆) g w) @ ((φ⇧⋆) g v)"
by (auto simp add: group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*))
lemma triv_act:
"a ∈ X ⟹ (φ 𝟭⇘G⇙) a = a"
using group_hom.hom_one[of "G" "BijGroup X" "φ"] (*‹group_hom G (BijGroup X) φ ⟹ φ 𝟭⇘G⇙ = 𝟭⇘BijGroup X⇙›*) group_BijGroup[where S = "X"] (*‹Group.group (BijGroup X)›*) apply (clarsimp simp add: group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*))
(*goal: ‹a ∈ X ⟹ φ 𝟭⇘G⇙ a = a›*)
by (metis id_eq_one (*‹(λx∈X. x) = φ 𝟭⇘G⇙›*) restrict_apply' (*‹?x ∈ ?A ⟹ restrict ?f ?A ?x = ?f ?x›*))
lemma triv_act_map:
"∀w∈X⇧⋆. ((φ⇧⋆) 𝟭⇘G⇙) w = w"
using triv_act (*‹?a ∈ X ⟹ φ 𝟭⇘G⇙ ?a = ?a›*) apply clarsimp
(*goal: ‹∀w::'X::type list∈X⇧⋆. ((φ::'grp::type ⇒ 'X::type ⇒ 'X::type)⇧⋆) 𝟭⇘G::('grp, 'b) monoid_scheme⇙ w = w›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹(⋀a. a ∈ X ⟹ φ 𝟭⇘G⇙ a = a) ⟹ (𝟭⇘G⇙ ∈ carrier G ⟶ (∀w∈X⇧⋆. map (φ 𝟭⇘G⇙) w = w)) ∧ (𝟭⇘G⇙ ∉ carrier G ⟶ (∀w∈X⇧⋆. undefined w = w))›*)
apply clarify
(*top goal: ‹⟦⋀a. a ∈ X ⟹ φ 𝟭⇘G⇙ a = a; 𝟭⇘G⇙ ∈ carrier G⟧ ⟹ ∀w∈X⇧⋆. map (φ 𝟭⇘G⇙) w = w› and 1 goal remains*)
using map_idI (*‹(⋀x::?'a. x ∈ set (?xs::?'a list) ⟹ (?f::?'a ⇒ ?'a) x = x) ⟹ map ?f ?xs = ?xs›*) apply metis
(*top goal: ‹⋀w. ⟦⋀a. a ∈ X ⟹ φ 𝟭⇘G⇙ a = a; 𝟭⇘G⇙ ∈ carrier G; ∀x∈set w. x ∈ X⟧ ⟹ map (φ 𝟭⇘G⇙) w = w› and 1 goal remains*)
using group.subgroup_self (*‹Group.group ?G ⟹ subgroup (carrier ?G) ?G›*) group_hom (*‹group_hom (G::('grp, 'b) monoid_scheme) (BijGroup X) (φ::'grp::type ⇒ 'X::type ⇒ 'X::type)›*) group_hom.axioms(1) (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) subgroup.one_closed (*‹subgroup ?H ?G ⟹ 𝟭⇘?G⇙ ∈ ?H›*) by blast
proposition lists_a_Gset:
"alt_grp_act G (X⇧⋆) (φ⇧⋆)"
proof (-)
(*goal: ‹alt_grp_act G (X⇧⋆) (φ⇧⋆)›*)
have H_0: "⋀g. g ∈ carrier G ⟹
restrict (map (φ g)) (X⇧⋆) ∈ carrier (BijGroup (X⇧⋆))"
proof (-)
(*goal: ‹⋀g. g ∈ carrier G ⟹ restrict (map (φ g)) (X⇧⋆) ∈ carrier (BijGroup (X⇧⋆))›*)
fix g
assume A1_0: "g ∈ carrier G" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*)
from A1_0 (*‹g ∈ carrier G›*) have H1_0: "inj_on (λx. if x ∈ X⇧⋆ then map (φ g) x else undefined) (X⇧⋆)"
apply (clarsimp simp add: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))
(*goal: ‹inj_on (λx. if x ∈ X⇧⋆ then map (φ g) x else undefined) (X⇧⋆)›*)
by (metis (mono_tags, lifting) inj_onD (*‹⟦inj_on ?f ?A; ?f ?x = ?f ?y; ?x ∈ ?A; ?y ∈ ?A⟧ ⟹ ?x = ?y›*) inj_prop (*‹?g ∈ carrier G ⟹ inj_on (φ ?g) X›*) list.inj_map_strong (*‹⟦⋀z za. ⟦z ∈ set ?x; za ∈ set ?xa; ?f z = ?fa za⟧ ⟹ z = za; map ?f ?x = map ?fa ?xa⟧ ⟹ ?x = ?xa›*))
from A1_0 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) have H1_1: "⋀y z. ∀x∈set y. x ∈ X ⟹ z ∈ set y ⟹ φ g z ∈ X"
using element_image (*‹⟦?g ∈ carrier G; ?x ∈ X; φ ?g ?x = ?y⟧ ⟹ ?y ∈ X›*) by blast
have H1_2: "(inv ⇘G⇙ g) ∈ carrier G"
by (meson A1_0 (*‹g ∈ carrier G›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group_hom (*‹group_hom G (BijGroup X) φ›*) group_hom.axioms( (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) 1))
have H1_3: "⋀x. x ∈ X⇧⋆ ⟹
map (comp (φ g) (φ (inv ⇘G⇙ g))) x = map (φ (g ⊗⇘G⇙ (inv ⇘G⇙ g))) x"
using alt_grp_act_axioms (*‹alt_grp_act G X φ›*) apply (simp add: alt_grp_act_def (*‹alt_grp_act ?G ?X ?φ ≡ group_action ?G ?X ?φ›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*))
(*goal: ‹⋀x. x ∈ X⇧⋆ ⟹ map (φ g ∘ φ (inv⇘G⇙ g)) x = map (φ (g ⊗⇘G⇙ inv⇘G⇙ g)) x›*)
apply (rule meta_mp[of "⋀x. x ∈ carrier G ⟹ φ x ∈ Bij X"] (*‹⟦(⋀x. x ∈ carrier G ⟹ φ x ∈ Bij X) ⟹ PROP ?Q; ⋀x. x ∈ carrier G ⟹ φ x ∈ Bij X⟧ ⟹ PROP ?Q›*))
(*goals:
1. ‹⋀x. ⟦x ∈ X⇧⋆; Group.group G ∧ Group.group ⦇carrier = Bij X, mult = λg∈Bij X. restrict (compose X g) (Bij X), one = λx∈X. x⦈ ∧ φ ∈ carrier G → Bij X ∧ (∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = (if φ x ∈ Bij X then restrict (compose X (φ x)) (Bij X) else undefined) (φ y)); ⋀x. x ∈ carrier G ⟹ φ x ∈ Bij X⟧ ⟹ ∀x∈set x. φ g (φ (inv⇘G⇙ g) x) = φ (g ⊗⇘G⇙ inv⇘G⇙ g) x›
2. ‹⋀x xa. ⟦x ∈ X⇧⋆; Group.group G ∧ Group.group ⦇carrier = Bij X, mult = λg∈Bij X. restrict (compose X g) (Bij X), one = λx∈X. x⦈ ∧ φ ∈ carrier G → Bij X ∧ (∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = (if φ x ∈ Bij X then restrict (compose X (φ x)) (Bij X) else undefined) (φ y)); xa ∈ carrier G⟧ ⟹ φ xa ∈ Bij X›
discuss goal 1*)
apply (metis A1_0 (*‹g ∈ carrier G›*) H1_2 (*‹inv⇘G⇙ g ∈ carrier G›*) composition_rule (*‹⟦?x ∈ X; ?g1.0 ∈ carrier G; ?g2.0 ∈ carrier G⟧ ⟹ φ (?g1.0 ⊗⇘G⇙ ?g2.0) ?x = φ ?g1.0 (φ ?g2.0 ?x)›*) in_lists_conv_set (*‹(?xs ∈ ?A⇧⋆) = (∀x∈set ?xs. x ∈ ?A)›*))
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
from H1_2 (*‹inv⇘G⇙ g ∈ carrier G›*) have H1_4: "⋀x. x ∈ X⇧⋆ ⟹ map (φ (inv ⇘G⇙ g)) x ∈ X⇧⋆"
using surj_prop (*‹?g ∈ carrier G ⟹ φ ?g ` X = X›*) by fastforce
have H1_5: "⋀y. ∀x∈set y. x ∈ X ⟹ y ∈ map (φ g) ` X⇧⋆"
apply (simp add: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*goal: ‹⋀y. ∀x∈set y. x ∈ X ⟹ y ∈ map (φ g) ` X⇧⋆›*)
using H1_3 (*‹?x1 ∈ X⇧⋆ ⟹ map (φ g ∘ φ (inv⇘G⇙ g)) ?x1 = map (φ (g ⊗⇘G⇙ inv⇘G⇙ g)) ?x1›*) H1_4 (*‹?x1 ∈ X⇧⋆ ⟹ map (φ (inv⇘G⇙ g)) ?x1 ∈ X⇧⋆›*) by (metis A1_0 (*‹g ∈ carrier G›*) group.r_inv (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ ?x ⊗⇘?G⇙ inv⇘?G⇙ ?x = 𝟭⇘?G⇙›*) group_hom (*‹group_hom G (BijGroup X) φ›*) group_hom.axioms( (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) 1) in_lists_conv_set (*‹(?xs ∈ ?A⇧⋆) = (∀x∈set ?xs. x ∈ ?A)›*) map_idI (*‹(⋀x. x ∈ set ?xs ⟹ ?f x = x) ⟹ map ?f ?xs = ?xs›*) map_map (*‹map ?f (map ?g ?xs) = map (?f ∘ ?g) ?xs›*) triv_act (*‹?a ∈ X ⟹ φ 𝟭⇘G⇙ ?a = ?a›*))
show "restrict (map (φ g)) (X⇧⋆) ∈ carrier (BijGroup (X⇧⋆))"
apply (clarsimp simp add: restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) extensional_def (*‹extensional ?A = {f. ∀x. x ∉ ?A ⟶ f x = undefined}›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*))
(*goal: ‹restrict (map (φ g)) (X⇧⋆) ∈ carrier (BijGroup (X⇧⋆))›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹inj_on (λx::'X::type list. if x ∈ X⇧⋆ then map ((φ::'grp::type ⇒ 'X::type ⇒ 'X::type) (g::'grp::type)) x else undefined) (X⇧⋆) ∧ map (φ g) ` X⇧⋆ = X⇧⋆›*)
using H1_0 (*‹inj_on (λx. if x ∈ X⇧⋆ then map (φ g) x else undefined) (X⇧⋆)›*) apply simp
(*top goal: ‹inj_on (λx. if x ∈ X⇧⋆ then map (φ g) x else undefined) (X⇧⋆)› and 1 goal remains*)
using H1_1 (*‹⟦∀x∈set ?y1. x ∈ X; ?z1 ∈ set ?y1⟧ ⟹ φ g ?z1 ∈ X›*) H1_5 (*‹∀x::'X::type∈set (?y1::'X::type list). x ∈ X ⟹ ?y1 ∈ map ((φ::'grp::type ⇒ 'X::type ⇒ 'X::type) (g::'grp::type)) ` X⇧⋆›*) by (auto simp add: image_def (*‹(?f::?'a::type ⇒ ?'b::type) ` (?A::?'a::type set) = {y::?'b::type. ∃x::?'a::type∈?A. y = ?f x}›*))
qed
have H_1: "⋀x y. ⟦x ∈ carrier G; y ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G⟧ ⟹
restrict (map (φ (x ⊗⇘G⇙ y))) (X⇧⋆) =
restrict (map (φ x)) (X⇧⋆) ⊗⇘BijGroup (X⇧⋆)⇙
restrict (map (φ y)) (X⇧⋆)"
proof (-)
(*goal: ‹⋀(x::'grp) y::'grp. ⟦x ∈ carrier (G::('grp, 'b) monoid_scheme); y ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G⟧ ⟹ restrict (map ((φ::'grp ⇒ 'X ⇒ 'X) (x ⊗⇘G⇙ y))) (X⇧⋆) = restrict (map (φ x)) (X⇧⋆) ⊗⇘BijGroup (X⇧⋆)⇙ restrict (map (φ y)) (X⇧⋆)›*)
fix x and y
assume A1_0: "x ∈ carrier G" and A1_1: " y ∈ carrier G" and A1_2: "x ⊗⇘G⇙ y ∈ carrier G" (*‹(x::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹(y::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹(x::'grp) ⊗⇘G::('grp, 'b) monoid_scheme⇙ (y::'grp) ∈ carrier G›*)
have H1_0: "⋀z. z ∈ carrier G ⟹
bij_betw (λx. if x ∈ X⇧⋆ then map (φ z) x else undefined) (X⇧⋆) (X⇧⋆)"
using ‹⋀g. g ∈ carrier G ⟹ restrict (map (φ g)) (X⇧⋆) ∈ carrier (BijGroup (X⇧⋆))› (*‹?g ∈ carrier G ⟹ restrict (map (φ ?g)) (X⇧⋆) ∈ carrier (BijGroup (X⇧⋆))›*) by (auto simp add: BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*) inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))
from A1_1 (*‹(y::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) have H1_1: "⋀lst. lst ∈ X⇧⋆ ⟹ (map (φ y)) lst ∈ X⇧⋆"
by (metis group_action.surj_prop (*‹⟦group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c set) (?φ::?'a ⇒ ?'c ⇒ ?'c); (?g::?'a) ∈ carrier ?G⟧ ⟹ ?φ ?g ` ?E = ?E›*) group_action_axioms (*‹group_action (G::('grp, 'b) monoid_scheme) X (φ::'grp ⇒ 'X ⇒ 'X)›*) lists_image (*‹((?f::?'b ⇒ ?'a) ` (?A::?'b set))⇧⋆ = map ?f ` ?A⇧⋆›*) rev_image_eqI (*‹⟦(?x::?'a) ∈ (?A::?'a set); (?b::?'b) = (?f::?'a ⇒ ?'b) ?x⟧ ⟹ ?b ∈ ?f ` ?A›*))
have H1_2: "⋀a. a ∈ X⇧⋆ ⟹ map (λxb.
if xb ∈ X
then φ x ((φ y) xb)
else undefined) a = map (φ x) (map (φ y) a)"
by auto
have H1_3: "(λxa. if xa ∈ X⇧⋆ then map (φ (x ⊗⇘G⇙ y)) xa else undefined) =
compose (X⇧⋆) (λxa. if xa ∈ X⇧⋆ then map (φ x) xa else undefined)
(λx. if x ∈ X⇧⋆ then map (φ y) x else undefined)"
using alt_grp_act_axioms (*‹alt_grp_act (G::('grp, 'b) monoid_scheme) X (φ::'grp ⇒ 'X ⇒ 'X)›*) apply (clarsimp simp add: compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*) alt_grp_act_def (*‹alt_grp_act ?G ?X ?φ ≡ group_action ?G ?X ?φ›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*))
(*goal: ‹(λxa::'X::type list. if xa ∈ X⇧⋆ then map ((φ::'grp::type ⇒ 'X::type ⇒ 'X::type) ((x::'grp::type) ⊗⇘G::('grp, 'b) monoid_scheme⇙ (y::'grp::type))) xa else undefined) = compose (X⇧⋆) (λxa::'X::type list. if xa ∈ X⇧⋆ then map (φ x) xa else undefined) (λx::'X::type list. if x ∈ X⇧⋆ then map (φ y) x else undefined)›*)
using A1_0 (*‹x ∈ carrier G›*) A1_1 (*‹y ∈ carrier G›*) H1_2 (*‹?a1 ∈ X⇧⋆ ⟹ map (λxb. if xb ∈ X then φ x (φ y xb) else undefined) ?a1 = map (φ x) (map (φ y) ?a1)›*) H1_1 (*‹?lst1 ∈ X⇧⋆ ⟹ map (φ y) ?lst1 ∈ X⇧⋆›*) bij_prop0 (*‹?g ∈ carrier G ⟹ φ ?g ∈ Bij X›*) by auto
show "restrict (map (φ (x ⊗⇘G⇙ y))) (X⇧⋆) =
restrict (map (φ x)) (X⇧⋆) ⊗⇘BijGroup (X⇧⋆)⇙
restrict (map (φ y)) (X⇧⋆)"
apply (clarsimp simp add: restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) extensional_def (*‹extensional ?A = {f. ∀x. x ∉ ?A ⟶ f x = undefined}›*))
(*goal: ‹restrict (map (φ (x ⊗⇘G⇙ y))) (X⇧⋆) = restrict (map (φ x)) (X⇧⋆) ⊗⇘BijGroup (X⇧⋆)⇙ restrict (map (φ y)) (X⇧⋆)›*)
apply (simp add: H1_3 (*‹(λxa. if xa ∈ X⇧⋆ then map (φ (x ⊗⇘G⇙ y)) xa else undefined) = compose (X⇧⋆) (λxa. if xa ∈ X⇧⋆ then map (φ x) xa else undefined) (λx. if x ∈ X⇧⋆ then map (φ y) x else undefined)›*))
(*goal: ‹(bij_betw (λx. if x ∈ X⇧⋆ then map (φ y) x else undefined) (X⇧⋆) (X⇧⋆) ⟶ (bij_betw (λxa. if xa ∈ X⇧⋆ then map (φ x) xa else undefined) (X⇧⋆) (X⇧⋆) ⟶ (λxa. if xa ∈ X⇧⋆ then map (φ (x ⊗⇘G⇙ y)) xa else undefined) = compose (X⇧⋆) (λxa. if xa ∈ X⇧⋆ then map (φ x) xa else undefined) (λx. if x ∈ X⇧⋆ then map (φ y) x else undefined)) ∧ (¬ bij_betw (λxa. if xa ∈ X⇧⋆ then map (φ x) xa else undefined) (X⇧⋆) (X⇧⋆) ⟶ (λxa. if xa ∈ X⇧⋆ then map (φ (x ⊗⇘G⇙ y)) xa else undefined) = undefined (λx. if x ∈ X⇧⋆ then map (φ y) x else undefined))) ∧ (¬ bij_betw (λx. if x ∈ X⇧⋆ then map (φ y) x else undefined) (X⇧⋆) (X⇧⋆) ⟶ (bij_betw (λxa. if xa ∈ X⇧⋆ then map (φ x) xa else undefined) (X⇧⋆) (X⇧⋆) ⟶ (λxa. if xa ∈ X⇧⋆ then map (φ (x ⊗⇘G⇙ y)) xa else undefined) = undefined) ∧ (¬ bij_betw (λxa. if xa ∈ X⇧⋆ then map (φ x) xa else undefined) (X⇧⋆) (X⇧⋆) ⟶ (λxa. if xa ∈ X⇧⋆ then map (φ (x ⊗⇘G⇙ y)) xa else undefined) = undefined (λx. if x ∈ X⇧⋆ then map (φ y) x else undefined)))›*)
using A1_0 (*‹x ∈ carrier G›*) A1_1 (*‹y ∈ carrier G›*) H1_0 (*‹?z1 ∈ carrier G ⟹ bij_betw (λx. if x ∈ X⇧⋆ then map (φ ?z1) x else undefined) (X⇧⋆) (X⇧⋆)›*) by auto
qed
show "alt_grp_act G (X⇧⋆) (φ⇧⋆)"
apply (clarsimp simp add: alt_grp_act_def (*‹alt_grp_act ?G ?X ?φ ≡ group_action ?G ?X ?φ›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*))
(*goal: ‹alt_grp_act G (X⇧⋆) (φ⇧⋆)›*)
apply (intro conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹Group.group G ∧ Group.group (BijGroup (X⇧⋆)) ∧ (λg∈carrier G. restrict (map (φ g)) (X⇧⋆)) ∈ hom G (BijGroup (X⇧⋆))›*)
using group_hom (*‹group_hom G (BijGroup X) φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*)
(*goals:
1. ‹Group.group G›
2. ‹Group.group (BijGroup (X⇧⋆))›
3. ‹(λg∈carrier G. restrict (map (φ g)) (X⇧⋆)) ∈ hom G (BijGroup (X⇧⋆))›
discuss goal 1*)
apply auto
(*discuss goal 2*)
apply (simp add: group_BijGroup (*‹Group.group (BijGroup ?S)›*))
(*discuss goal 3*)
apply (clarsimp simp add: hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*))
(*goal: ‹⟦group_hom G (BijGroup X) φ; ⋀G H h. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h⟧ ⟹ (λg∈carrier G. restrict (map (φ g)) (X⇧⋆)) ∈ hom G (BijGroup (X⇧⋆))›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⟦group_hom (G::('grp, 'b) monoid_scheme) (BijGroup X) (φ::'grp ⇒ 'X ⇒ 'X); ⋀(G::(?'a4, ?'b4) monoid_scheme) (H::(?'c4, ?'d4) monoid_scheme) h::?'a4 ⇒ ?'c4. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h⟧ ⟹ (λg::'grp∈carrier G. restrict (map (φ g)) (X⇧⋆)) ∈ carrier G → carrier (BijGroup (X⇧⋆))›
2. ‹⟦group_hom (G::('grp, 'b) monoid_scheme) (BijGroup X) (φ::'grp ⇒ 'X ⇒ 'X); ⋀(G::(?'a4, ?'b4) monoid_scheme) (H::(?'c4, ?'d4) monoid_scheme) h::?'a4 ⇒ ?'c4. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h⟧ ⟹ ∀x::'grp∈carrier G. ∀y::'grp∈carrier G. (x ⊗⇘G⇙ y ∈ carrier G ⟶ restrict (map (φ (x ⊗⇘G⇙ y))) (X⇧⋆) = restrict (map (φ x)) (X⇧⋆) ⊗⇘BijGroup (X⇧⋆)⇙ restrict (map (φ y)) (X⇧⋆)) ∧ (x ⊗⇘G⇙ y ∉ carrier G ⟶ undefined = restrict (map (φ x)) (X⇧⋆) ⊗⇘BijGroup (X⇧⋆)⇙ restrict (map (φ y)) (X⇧⋆))›
discuss goal 1*)
apply clarify
(*top goal: ‹⟦group_hom G (BijGroup X) φ; ⋀G H h. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h⟧ ⟹ (λg∈carrier G. restrict (map (φ g)) (X⇧⋆)) ∈ carrier G → carrier (BijGroup (X⇧⋆))› and 1 goal remains*)
apply (rule H_0 (*‹?g1 ∈ carrier G ⟹ restrict (map (φ ?g1)) (X⇧⋆) ∈ carrier (BijGroup (X⇧⋆))›*))
(*top goal: ‹⋀g::'grp. ⟦group_hom (G::('grp, 'b) monoid_scheme) (BijGroup X) (φ::'grp ⇒ 'X ⇒ 'X); ⋀(G::(?'a4, ?'b4) monoid_scheme) (H::(?'c4, ?'d4) monoid_scheme) h::?'a4 ⇒ ?'c4. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h; g ∈ carrier G⟧ ⟹ restrict (map (φ g)) (X⇧⋆) ∈ carrier (BijGroup (X⇧⋆))› and 1 goal remains*)
apply simp
(*discuss goal 2*)
apply clarify
(*goal: ‹⟦group_hom (G::('grp, 'b) monoid_scheme) (BijGroup X) (φ::'grp::type ⇒ 'X::type ⇒ 'X::type); ⋀(G::(?'a4, ?'b4) monoid_scheme) (H::(?'c4, ?'d4) monoid_scheme) h::?'a4::type ⇒ ?'c4::type. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h⟧ ⟹ ∀x::'grp::type∈carrier G. ∀y::'grp::type∈carrier G. (x ⊗⇘G⇙ y ∈ carrier G ⟶ restrict (map (φ (x ⊗⇘G⇙ y))) (X⇧⋆) = restrict (map (φ x)) (X⇧⋆) ⊗⇘BijGroup (X⇧⋆)⇙ restrict (map (φ y)) (X⇧⋆)) ∧ (x ⊗⇘G⇙ y ∉ carrier G ⟶ undefined = restrict (map (φ x)) (X⇧⋆) ⊗⇘BijGroup (X⇧⋆)⇙ restrict (map (φ y)) (X⇧⋆))›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⋀x y. ⟦group_hom G (BijGroup X) φ; ⋀G H h. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h; x ∈ carrier G; y ∈ carrier G⟧ ⟹ x ⊗⇘G⇙ y ∈ carrier G ⟶ restrict (map (φ (x ⊗⇘G⇙ y))) (X⇧⋆) = restrict (map (φ x)) (X⇧⋆) ⊗⇘BijGroup (X⇧⋆)⇙ restrict (map (φ y)) (X⇧⋆)›
2. ‹⋀x y. ⟦group_hom G (BijGroup X) φ; ⋀G H h. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h; x ∈ carrier G; y ∈ carrier G⟧ ⟹ x ⊗⇘G⇙ y ∉ carrier G ⟶ undefined = restrict (map (φ x)) (X⇧⋆) ⊗⇘BijGroup (X⇧⋆)⇙ restrict (map (φ y)) (X⇧⋆)›
discuss goal 1*)
apply (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*top goal: ‹⋀x y. ⟦group_hom G (BijGroup X) φ; ⋀G H h. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h; x ∈ carrier G; y ∈ carrier G⟧ ⟹ x ⊗⇘G⇙ y ∈ carrier G ⟶ restrict (map (φ (x ⊗⇘G⇙ y))) (X⇧⋆) = restrict (map (φ x)) (X⇧⋆) ⊗⇘BijGroup (X⇧⋆)⇙ restrict (map (φ y)) (X⇧⋆)› and 1 goal remains*)
apply (rule H_1 (*‹⟦(?x1::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme); (?y1::'grp::type) ∈ carrier G; ?x1 ⊗⇘G⇙ ?y1 ∈ carrier G⟧ ⟹ restrict (map ((φ::'grp::type ⇒ 'X::type ⇒ 'X::type) (?x1 ⊗⇘G⇙ ?y1))) (X⇧⋆) = restrict (map (φ ?x1)) (X⇧⋆) ⊗⇘BijGroup (X⇧⋆)⇙ restrict (map (φ ?y1)) (X⇧⋆)›*))
(*goals:
1. ‹⋀(x::'grp) y::'grp. ⟦group_hom (G::('grp, 'b) monoid_scheme) (BijGroup X) (φ::'grp ⇒ 'X ⇒ 'X); ⋀(G::(?'a4, ?'b4) monoid_scheme) (H::(?'c4, ?'d4) monoid_scheme) h::?'a4 ⇒ ?'c4. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h; x ∈ carrier G; y ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G⟧ ⟹ x ∈ carrier G›
2. ‹⋀(x::'grp) y::'grp. ⟦group_hom (G::('grp, 'b) monoid_scheme) (BijGroup X) (φ::'grp ⇒ 'X ⇒ 'X); ⋀(G::(?'a4, ?'b4) monoid_scheme) (H::(?'c4, ?'d4) monoid_scheme) h::?'a4 ⇒ ?'c4. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h; x ∈ carrier G; y ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G⟧ ⟹ y ∈ carrier G›
3. ‹⋀(x::'grp) y::'grp. ⟦group_hom (G::('grp, 'b) monoid_scheme) (BijGroup X) (φ::'grp ⇒ 'X ⇒ 'X); ⋀(G::(?'a4, ?'b4) monoid_scheme) (H::(?'c4, ?'d4) monoid_scheme) h::?'a4 ⇒ ?'c4. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h; x ∈ carrier G; y ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G⟧ ⟹ x ⊗⇘G⇙ y ∈ carrier G›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*)
(*discuss goal 2*)
apply (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀x y. ⟦group_hom G (BijGroup X) φ; ⋀G H h. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h; x ∈ carrier G; y ∈ carrier G⟧ ⟹ x ⊗⇘G⇙ y ∉ carrier G ⟶ undefined = restrict (map (φ x)) (X⇧⋆) ⊗⇘BijGroup (X⇧⋆)⇙ restrict (map (φ y)) (X⇧⋆)›*)
apply (rule meta_mp[of "⋀x y. x ∈ carrier G ⟹
y ∈ carrier G ⟹ x ⊗⇘G⇙ y ∈ carrier G" ] (*‹⟦(⋀x y. ⟦x ∈ carrier G; y ∈ carrier G⟧ ⟹ x ⊗⇘G⇙ y ∈ carrier G) ⟹ PROP ?Q; ⋀x y. ⟦x ∈ carrier G; y ∈ carrier G⟧ ⟹ x ⊗⇘G⇙ y ∈ carrier G⟧ ⟹ PROP ?Q›*))
(*goals:
1. ‹⋀x y. ⟦group_hom G (BijGroup X) φ; ⋀G H h. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h; x ∈ carrier G; y ∈ carrier G; x ⊗⇘G⇙ y ∉ carrier G; ⋀x y. ⟦x ∈ carrier G; y ∈ carrier G⟧ ⟹ x ⊗⇘G⇙ y ∈ carrier G⟧ ⟹ undefined = restrict (map (φ x)) (X⇧⋆) ⊗⇘BijGroup (X⇧⋆)⇙ restrict (map (φ y)) (X⇧⋆)›
2. ‹⋀x y xa ya. ⟦group_hom G (BijGroup X) φ; ⋀G H h. group_hom G H h ≡ Group.group G ∧ Group.group H ∧ group_hom_axioms G H h; x ∈ carrier G; y ∈ carrier G; x ⊗⇘G⇙ y ∉ carrier G; xa ∈ carrier G; ya ∈ carrier G⟧ ⟹ xa ⊗⇘G⇙ ya ∈ carrier G›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply (meson group.subgroup_self (*‹Group.group ?G ⟹ subgroup (carrier ?G) ?G›*) group_hom (*‹group_hom G (BijGroup X) φ›*) group_hom.axioms( (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) 1) subgroup.m_closed (*‹⟦subgroup ?H ?G; ?x ∈ ?H; ?y ∈ ?H⟧ ⟹ ?x ⊗⇘?G⇙ ?y ∈ ?H›*))
(*proven 2 subgoals*)
(*proven 2 subgoals*)
(*proven 2 subgoals*)
(*proven 3 subgoals*) .
qed
end
lemma alt_group_act_is_grp_act [simp, GMN_simps]:
"alt_grp_act = group_action"
using alt_grp_act_def (*‹alt_grp_act ?G ?X ?φ ≡ group_action ?G ?X ?φ›*) by blast
lemma prod_group_act:
assumes
grp_act_A: "alt_grp_act G A φ" and
grp_act_B: "alt_grp_act G B ψ"
shows "alt_grp_act G (A×B) (λg∈carrier G. λ(a, b) ∈ (A × B). (φ g a, ψ g b))"
apply (simp add: alt_grp_act_def (*‹alt_grp_act ?G ?X ?φ ≡ group_action ?G ?X ?φ›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*))
(*goal: ‹alt_grp_act (G::('a, 'b) monoid_scheme) ((A::'c set) × (B::'d set)) (λg::'a∈carrier G. λ(a::'c, b::'d)∈A × B. ((φ::'a ⇒ 'c ⇒ 'c) g a, (ψ::'a ⇒ 'd ⇒ 'd) g b))›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹Group.group G ∧ Group.group (BijGroup (A × B)) ∧ group_hom_axioms G (BijGroup (A × B)) (λg∈carrier G. λ(a, b)∈A × B. (φ g a, ψ g b))›*)
subgoal for
using grp_act_A (*‹alt_grp_act G A φ›*) grp_act_B (*‹alt_grp_act G B ψ›*) by (auto simp add: alt_grp_act_def (*‹alt_grp_act ?G ?X ?φ ≡ group_action ?G ?X ?φ›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*))
subgoal for
using grp_act_A (*‹alt_grp_act G A φ›*) grp_act_B (*‹alt_grp_act G B ψ›*) by (auto simp add: alt_grp_act_def (*‹alt_grp_act ?G ?X ?φ ≡ group_action ?G ?X ?φ›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_BijGroup (*‹Group.group (BijGroup ?S)›*))
apply (clarsimp simp add: group_hom_axioms_def (*‹group_hom_axioms (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom (?G::(?'a, ?'c) monoid_scheme) (?H::(?'b, ?'d) monoid_scheme) = {h::?'a ⇒ ?'b ∈ carrier ?G → carrier ?H. ∀x::?'a∈carrier ?G. ∀y::?'a∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) BijGroup_def (*‹BijGroup (?S::?'a set) = ⦇carrier = Bij ?S, mult = λg::?'a ⇒ ?'a∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx::?'a∈?S. x⦈›*))
(*goal: ‹group_hom_axioms G (BijGroup (A × B)) (λg∈carrier G. λ(a, b)∈A × B. (φ g a, ψ g b))›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); clarify)
(*goal: ‹(λg∈carrier G. λ(a, b)∈A × B. (φ g a, ψ g b)) ∈ carrier G → Bij (A × B) ∧ (∀x∈carrier G. ((λ(a, b)∈A × B. (φ x a, ψ x b)) ∈ Bij (A × B) ⟶ (∀y∈carrier G. (x ⊗⇘G⇙ y ∈ carrier G ⟶ ((λ(a, b)∈A × B. (φ y a, ψ y b)) ∈ Bij (A × B) ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = compose (A × B) (λ(a, b)∈A × B. (φ x a, ψ x b)) (λ(a, b)∈A × B. (φ y a, ψ y b))) ∧ ((λ(a, b)∈A × B. (φ y a, ψ y b)) ∉ Bij (A × B) ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = undefined)) ∧ (x ⊗⇘G⇙ y ∉ carrier G ⟶ (λ(a, b)∈A × B. (φ y a, ψ y b)) ∈ Bij (A × B) ⟶ undefined = compose (A × B) (λ(a, b)∈A × B. (φ x a, ψ x b)) (λ(a, b)∈A × B. (φ y a, ψ y b))))) ∧ ((λ(a, b)∈A × B. (φ x a, ψ x b)) ∉ Bij (A × B) ⟶ (∀y∈carrier G. (x ⊗⇘G⇙ y ∈ carrier G ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = undefined (λ(a, b)∈A × B. (φ y a, ψ y b))) ∧ (x ⊗⇘G⇙ y ∉ carrier G ⟶ undefined = undefined (λ(a, b)∈A × B. (φ y a, ψ y b))))))›*)
subgoal for g
apply (clarsimp simp add: Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*) inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*) extensional_def (*‹extensional ?A = {f. ∀x. x ∉ ?A ⟶ f x = undefined}›*))
(*goal: ‹(g::'a) ∈ carrier (G::('a, 'b) monoid_scheme) ⟹ (λ(a::'c, b::'d)∈(A::'c set) × (B::'d set). ((φ::'a ⇒ 'c ⇒ 'c) g a, (ψ::'a ⇒ 'd ⇒ 'd) g b)) ∈ Bij (A × B)›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹g ∈ carrier G ⟹ (∀x∈A. ∀y∈B. ∀xa∈A. ∀ya∈B. φ g x = φ g xa ∧ ψ g y = ψ g ya ⟶ x = xa ∧ y = ya) ∧ (λx. case x of (a, b) ⇒ (φ g a, ψ g b)) ` (A × B) = A × B›*)
using grp_act_A (*‹alt_grp_act G A φ›*) apply (simp add: alt_grp_act_def (*‹alt_grp_act ?G ?X ?φ ≡ group_action ?G ?X ?φ›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) Pi_def (*‹Pi ?A ?B = {f. ∀x. x ∈ ?A ⟶ f x ∈ ?B x}›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*) Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*) inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))
(*top goal: ‹g ∈ carrier G ⟹ ∀x∈A. ∀y∈B. ∀xa∈A. ∀ya∈B. φ g x = φ g xa ∧ ψ g y = ψ g ya ⟶ x = xa ∧ y = ya› and 1 goal remains*)
using grp_act_B (*‹alt_grp_act G B ψ›*) apply (simp add: alt_grp_act_def (*‹alt_grp_act (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X::type set) (?φ::?'grp::type ⇒ ?'X::type ⇒ ?'X::type) ≡ group_action ?G ?X ?φ›*) group_action_def (*‹group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c::type set) (?φ::?'a::type ⇒ ?'c::type ⇒ ?'c::type) ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a::type ⇒ ?'c::type) ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a::type ⇒ ?'c::type) ≡ ?h ∈ hom ?G ?H›*) BijGroup_def (*‹BijGroup (?S::?'a::type set) = ⦇carrier = Bij ?S, mult = λg::?'a::type ⇒ ?'a::type∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx::?'a::type∈?S. x⦈›*) hom_def (*‹hom (?G::(?'a, ?'c) monoid_scheme) (?H::(?'b, ?'d) monoid_scheme) = {h::?'a::type ⇒ ?'b::type ∈ carrier ?G → carrier ?H. ∀x::?'a::type∈carrier ?G. ∀y::?'a::type∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) Pi_def (*‹Pi (?A::?'a::type set) (?B::?'a::type ⇒ ?'b::type set) = {f::?'a::type ⇒ ?'b::type. ∀x::?'a::type. x ∈ ?A ⟶ f x ∈ ?B x}›*) compose_def (*‹compose (?A::?'a::type set) (?g::?'b::type ⇒ ?'c::type) (?f::?'a::type ⇒ ?'b::type) = (λx::?'a::type∈?A. ?g (?f x))›*) Bij_def (*‹Bij (?S::?'a::type set) = extensional ?S ∩ {f::?'a::type ⇒ ?'a::type. bij_betw f ?S ?S}›*) bij_betw_def (*‹bij_betw (?f::?'a::type ⇒ ?'b::type) (?A::?'a::type set) (?B::?'b::type set) = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*) inj_on_def (*‹inj_on (?f::?'a::type ⇒ ?'b::type) (?A::?'a::type set) = (∀x::?'a::type∈?A. ∀y::?'a::type∈?A. ?f x = ?f y ⟶ x = y)›*))
(*top goal: ‹⟦(g::'a) ∈ carrier (G::('a, 'b) monoid_scheme); Group.group G ∧ Group.group ⦇carrier = extensional (A::'c set) ∩ {f::'c ⇒ 'c. (∀x::'c∈A. ∀y::'c∈A. f x = f y ⟶ x = y) ∧ f ` A = A}, mult = λg::'c ⇒ 'c∈extensional A ∩ {f::'c ⇒ 'c. (∀x::'c∈A. ∀y::'c∈A. f x = f y ⟶ x = y) ∧ f ` A = A}. λf::'c ⇒ 'c∈extensional A ∩ {f::'c ⇒ 'c. (∀x::'c∈A. ∀y::'c∈A. f x = f y ⟶ x = y) ∧ f ` A = A}. λx::'c∈A. g (f x), one = λx::'c∈A. x⦈ ∧ (∀x::'a. x ∈ carrier G ⟶ (φ::'a ⇒ 'c ⇒ 'c) x ∈ extensional A ∧ (∀xa::'c∈A. ∀y::'c∈A. φ x xa = φ x y ⟶ xa = y) ∧ φ x ` A = A) ∧ (∀x::'a∈carrier G. ∀y::'a∈carrier G. φ (x ⊗⇘G⇙ y) = (if φ x ∈ extensional A ∧ (∀xa::'c∈A. ∀y::'c∈A. φ x xa = φ x y ⟶ xa = y) ∧ φ x ` A = A then λf::'c ⇒ 'c∈extensional A ∩ {f::'c ⇒ 'c. (∀x::'c∈A. ∀y::'c∈A. f x = f y ⟶ x = y) ∧ f ` A = A}. λxa::'c∈A. φ x (f xa) else undefined) (φ y))⟧ ⟹ ∀x::'c∈A. ∀y::'d∈B::'d set. ∀xa::'c∈A. ∀ya::'d∈B. φ g x = φ g xa ∧ (ψ::'a ⇒ 'd ⇒ 'd) g y = ψ g ya ⟶ y = ya› and 1 goal remains*)
apply (rule meta_mp[of "φ g ∈ Bij A ∧ ψ g ∈ Bij B"] (*‹⟦φ g ∈ Bij A ∧ ψ g ∈ Bij B ⟹ PROP ?Q; φ g ∈ Bij A ∧ ψ g ∈ Bij B⟧ ⟹ PROP ?Q›*))
(*goal: ‹g ∈ carrier G ⟹ (λx. case x of (a, b) ⇒ (φ g a, ψ g b)) ` (A × B) = A × B›*)
apply (clarsimp simp add: Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*))
(*top goal: ‹⟦g ∈ carrier G; φ g ∈ Bij A ∧ ψ g ∈ Bij B⟧ ⟹ (λx. case x of (a, b) ⇒ (φ g a, ψ g b)) ` (A × B) = A × B› and 1 goal remains*)
using grp_act_A (*‹alt_grp_act G A φ›*) grp_act_B (*‹alt_grp_act G B ψ›*) apply (simp add: alt_grp_act_def (*‹alt_grp_act (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) ≡ group_action ?G ?X ?φ›*) group_action_def (*‹group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c set) (?φ::?'a ⇒ ?'c ⇒ ?'c) ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ≡ ?h ∈ hom ?G ?H›*) BijGroup_def (*‹BijGroup (?S::?'a set) = ⦇carrier = Bij ?S, mult = λg::?'a ⇒ ?'a∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx::?'a∈?S. x⦈›*) hom_def (*‹hom (?G::(?'a, ?'c) monoid_scheme) (?H::(?'b, ?'d) monoid_scheme) = {h::?'a ⇒ ?'b ∈ carrier ?G → carrier ?H. ∀x::?'a∈carrier ?G. ∀y::?'a∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) Pi_def (*‹Pi (?A::?'a set) (?B::?'a ⇒ ?'b set) = {f::?'a ⇒ ?'b. ∀x::?'a. x ∈ ?A ⟶ f x ∈ ?B x}›*) Bij_def (*‹Bij (?S::?'a set) = extensional ?S ∩ {f::?'a ⇒ ?'a. bij_betw f ?S ?S}›*))
(*top goal: ‹⟦g ∈ carrier G; φ g ∈ extensional A; inj_on (φ g) A; φ g ` A = A; ψ g ∈ extensional B; inj_on (ψ g) B; ψ g ` B = B⟧ ⟹ (λx. case x of (a, b) ⇒ (φ g a, ψ g b)) ` (A × B) = A × B› and 1 goal remains*)
using grp_act_A (*‹alt_grp_act G A φ›*) grp_act_B (*‹alt_grp_act (G::('a, 'b) monoid_scheme) (B::'d set) (ψ::'a ⇒ 'd ⇒ 'd)›*)
(*goals:
1. ‹⟦g ∈ carrier G; inj_on (φ g) A; φ g ` A = A; inj_on (ψ g) B; ψ g ` B = B; Group.group G ∧ Group.group ⦇carrier = extensional A ∩ {f. bij_betw f A A}, mult = λg∈extensional A ∩ {f. bij_betw f A A}. restrict (compose A g) (extensional A ∩ {f. bij_betw f A A}), one = λx∈A. x⦈ ∧ (∀x. x ∈ carrier G ⟶ φ x ∈ extensional A ∧ bij_betw (φ x) A A) ∧ (∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = (if φ x ∈ extensional A ∧ bij_betw (φ x) A A then restrict (compose A (φ x)) (extensional A ∩ {f. bij_betw f A A}) else undefined) (φ y)); Group.group ⦇carrier = extensional B ∩ {f. bij_betw f B B}, mult = λg∈extensional B ∩ {f. bij_betw f B B}. restrict (compose B g) (extensional B ∩ {f. bij_betw f B B}), one = λx∈B. x⦈ ∧ (∀x. x ∈ carrier G ⟶ ψ x ∈ extensional B ∧ bij_betw (ψ x) B B) ∧ (∀x∈carrier G. ∀y∈carrier G. ψ (x ⊗⇘G⇙ y) = (if ψ x ∈ extensional B ∧ bij_betw (ψ x) B B then restrict (compose B (ψ x)) (extensional B ∩ {f. bij_betw f B B}) else undefined) (ψ y))⟧ ⟹ (λx. case x of (a, b) ⇒ (φ g a, ψ g b)) ` (A × B) = A × B›
2. ‹g ∈ carrier G ⟹ φ g ∈ Bij A ∧ ψ g ∈ Bij B›
discuss goal 1*)
apply (clarsimp simp add: compose_def (*‹compose (?A::?'a::type set) (?g::?'b::type ⇒ ?'c::type) (?f::?'a::type ⇒ ?'b::type) = (λx::?'a::type∈?A. ?g (?f x))›*) restrict_def (*‹restrict (?f::?'a::type ⇒ ?'b::type) (?A::?'a::type set) = (λx::?'a::type. if x ∈ ?A then ?f x else undefined)›*) image_def (*‹(?f::?'a::type ⇒ ?'b::type) ` (?A::?'a::type set) = {y::?'b::type. ∃x::?'a::type∈?A. y = ?f x}›*) alt_grp_act_def (*‹alt_grp_act (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X::type set) (?φ::?'grp::type ⇒ ?'X::type ⇒ ?'X::type) ≡ group_action ?G ?X ?φ›*) group_action_def (*‹group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c::type set) (?φ::?'a::type ⇒ ?'c::type ⇒ ?'c::type) ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a::type ⇒ ?'c::type) ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a::type ⇒ ?'c::type) ≡ ?h ∈ hom ?G ?H›*) BijGroup_def (*‹BijGroup (?S::?'a::type set) = ⦇carrier = Bij ?S, mult = λg::?'a::type ⇒ ?'a::type∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx::?'a::type∈?S. x⦈›*) hom_def (*‹hom (?G::(?'a, ?'c) monoid_scheme) (?H::(?'b, ?'d) monoid_scheme) = {h::?'a::type ⇒ ?'b::type ∈ carrier ?G → carrier ?H. ∀x::?'a::type∈carrier ?G. ∀y::?'a::type∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) Pi_def (*‹Pi (?A::?'a::type set) (?B::?'a::type ⇒ ?'b::type set) = {f::?'a::type ⇒ ?'b::type. ∀x::?'a::type. x ∈ ?A ⟶ f x ∈ ?B x}›*) Bij_def (*‹Bij (?S::?'a::type set) = extensional ?S ∩ {f::?'a::type ⇒ ?'a::type. bij_betw f ?S ?S}›*) bij_betw_def (*‹bij_betw (?f::?'a::type ⇒ ?'b::type) (?A::?'a::type set) (?B::?'b::type set) = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*))
(*top goal: ‹⟦g ∈ carrier G; inj_on (φ g) A; φ g ` A = A; inj_on (ψ g) B; ψ g ` B = B; Group.group G ∧ Group.group ⦇carrier = extensional A ∩ {f. bij_betw f A A}, mult = λg∈extensional A ∩ {f. bij_betw f A A}. restrict (compose A g) (extensional A ∩ {f. bij_betw f A A}), one = λx∈A. x⦈ ∧ (∀x. x ∈ carrier G ⟶ φ x ∈ extensional A ∧ bij_betw (φ x) A A) ∧ (∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = (if φ x ∈ extensional A ∧ bij_betw (φ x) A A then restrict (compose A (φ x)) (extensional A ∩ {f. bij_betw f A A}) else undefined) (φ y)); Group.group ⦇carrier = extensional B ∩ {f. bij_betw f B B}, mult = λg∈extensional B ∩ {f. bij_betw f B B}. restrict (compose B g) (extensional B ∩ {f. bij_betw f B B}), one = λx∈B. x⦈ ∧ (∀x. x ∈ carrier G ⟶ ψ x ∈ extensional B ∧ bij_betw (ψ x) B B) ∧ (∀x∈carrier G. ∀y∈carrier G. ψ (x ⊗⇘G⇙ y) = (if ψ x ∈ extensional B ∧ bij_betw (ψ x) B B then restrict (compose B (ψ x)) (extensional B ∩ {f. bij_betw f B B}) else undefined) (ψ y))⟧ ⟹ (λx. case x of (a, b) ⇒ (φ g a, ψ g b)) ` (A × B) = A × B› and 1 goal remains*)
apply (rule subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*))
(*goals:
1. ‹⟦g ∈ carrier G; Group.group ⦇carrier = extensional A ∩ {f. inj_on f A ∧ {y. ∃x∈A. y = f x} = A}, mult = λx. if x ∈ extensional A ∧ inj_on x A ∧ {y. ∃xa∈A. y = x xa} = A then λxa. if xa ∈ extensional A ∧ inj_on xa A ∧ {y. ∃x∈A. y = xa x} = A then λxb. if xb ∈ A then x (xa xb) else undefined else undefined else undefined, one = λx. if x ∈ A then x else undefined⦈; Group.group ⦇carrier = extensional B ∩ {f. inj_on f B ∧ {y. ∃x∈B. y = f x} = B}, mult = λx. if x ∈ extensional B ∧ inj_on x B ∧ {y. ∃xa∈B. y = x xa} = B then λxa. if xa ∈ extensional B ∧ inj_on xa B ∧ {y. ∃x∈B. y = xa x} = B then λxb. if xb ∈ B then x (xa xb) else undefined else undefined else undefined, one = λx. if x ∈ B then x else undefined⦈; Group.group G; Group.group ⦇carrier = extensional B ∩ {f. inj_on f B ∧ {y. ∃x∈B. y = f x} = B}, mult = λx. if x ∈ extensional B ∧ inj_on x B ∧ {y. ∃xa∈B. y = x xa} = B then λxa. if xa ∈ extensional B ∧ inj_on xa B ∧ {y. ∃x∈B. y = xa x} = B then compose B x xa else undefined else undefined, one = λx. if x ∈ B then x else undefined⦈; Group.group ⦇carrier = extensional A ∩ {f. inj_on f A ∧ {y. ∃x∈A. y = f x} = A}, mult = λx. if x ∈ extensional A ∧ inj_on x A ∧ {y. ∃xa∈A. y = x xa} = A then λxa. if xa ∈ extensional A ∧ inj_on xa A ∧ {y. ∃x∈A. y = xa x} = A then compose A x xa else undefined else undefined, one = λx. if x ∈ A then x else undefined⦈; ∀x. x ∈ carrier G ⟶ ψ x ∈ extensional B ∧ inj_on (ψ x) B ∧ {y. ∃xa∈B. y = ψ x xa} = B; ∀x∈carrier G. ∀y∈carrier G. ψ (x ⊗⇘G⇙ y) = (λxa. if xa ∈ B then ψ x (ψ y xa) else undefined); ∀x. x ∈ carrier G ⟶ φ x ∈ extensional A ∧ inj_on (φ x) A ∧ {y. ∃xa∈A. y = φ x xa} = A; ∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = (λxa. if xa ∈ A then φ x (φ y xa) else undefined)⟧ ⟹ {y. ∃x∈A. ∃ya∈B. y = (φ g x, ψ g ya)} ⊆ A × B›
2. ‹⟦g ∈ carrier G; Group.group ⦇carrier = extensional A ∩ {f. inj_on f A ∧ {y. ∃x∈A. y = f x} = A}, mult = λx. if x ∈ extensional A ∧ inj_on x A ∧ {y. ∃xa∈A. y = x xa} = A then λxa. if xa ∈ extensional A ∧ inj_on xa A ∧ {y. ∃x∈A. y = xa x} = A then λxb. if xb ∈ A then x (xa xb) else undefined else undefined else undefined, one = λx. if x ∈ A then x else undefined⦈; Group.group ⦇carrier = extensional B ∩ {f. inj_on f B ∧ {y. ∃x∈B. y = f x} = B}, mult = λx. if x ∈ extensional B ∧ inj_on x B ∧ {y. ∃xa∈B. y = x xa} = B then λxa. if xa ∈ extensional B ∧ inj_on xa B ∧ {y. ∃x∈B. y = xa x} = B then λxb. if xb ∈ B then x (xa xb) else undefined else undefined else undefined, one = λx. if x ∈ B then x else undefined⦈; Group.group G; Group.group ⦇carrier = extensional B ∩ {f. inj_on f B ∧ {y. ∃x∈B. y = f x} = B}, mult = λx. if x ∈ extensional B ∧ inj_on x B ∧ {y. ∃xa∈B. y = x xa} = B then λxa. if xa ∈ extensional B ∧ inj_on xa B ∧ {y. ∃x∈B. y = xa x} = B then compose B x xa else undefined else undefined, one = λx. if x ∈ B then x else undefined⦈; Group.group ⦇carrier = extensional A ∩ {f. inj_on f A ∧ {y. ∃x∈A. y = f x} = A}, mult = λx. if x ∈ extensional A ∧ inj_on x A ∧ {y. ∃xa∈A. y = x xa} = A then λxa. if xa ∈ extensional A ∧ inj_on xa A ∧ {y. ∃x∈A. y = xa x} = A then compose A x xa else undefined else undefined, one = λx. if x ∈ A then x else undefined⦈; ∀x. x ∈ carrier G ⟶ ψ x ∈ extensional B ∧ inj_on (ψ x) B ∧ {y. ∃xa∈B. y = ψ x xa} = B; ∀x∈carrier G. ∀y∈carrier G. ψ (x ⊗⇘G⇙ y) = (λxa. if xa ∈ B then ψ x (ψ y xa) else undefined); ∀x. x ∈ carrier G ⟶ φ x ∈ extensional A ∧ inj_on (φ x) A ∧ {y. ∃xa∈A. y = φ x xa} = A; ∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = (λxa. if xa ∈ A then φ x (φ y xa) else undefined)⟧ ⟹ A × B ⊆ {y. ∃x∈A. ∃ya∈B. y = (φ g x, ψ g ya)}›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*)
(*discuss goal 2*)
apply (metis alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) group_action.bij_prop0 (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G⟧ ⟹ ?φ ?g ∈ Bij ?E›*) grp_act_A (*‹alt_grp_act G A φ›*) grp_act_B (*‹alt_grp_act G B ψ›*))
(*proven 2 subgoals*) .
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); intro impI (*‹(?P::bool ⟹ ?Q::bool) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀x. x ∈ carrier G ⟹ ((λ(a, b)∈A × B. (φ x a, ψ x b)) ∈ Bij (A × B) ⟶ (∀y∈carrier G. (x ⊗⇘G⇙ y ∈ carrier G ⟶ ((λ(a, b)∈A × B. (φ y a, ψ y b)) ∈ Bij (A × B) ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = compose (A × B) (λ(a, b)∈A × B. (φ x a, ψ x b)) (λ(a, b)∈A × B. (φ y a, ψ y b))) ∧ ((λ(a, b)∈A × B. (φ y a, ψ y b)) ∉ Bij (A × B) ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = undefined)) ∧ (x ⊗⇘G⇙ y ∉ carrier G ⟶ (λ(a, b)∈A × B. (φ y a, ψ y b)) ∈ Bij (A × B) ⟶ undefined = compose (A × B) (λ(a, b)∈A × B. (φ x a, ψ x b)) (λ(a, b)∈A × B. (φ y a, ψ y b))))) ∧ ((λ(a, b)∈A × B. (φ x a, ψ x b)) ∉ Bij (A × B) ⟶ (∀y∈carrier G. (x ⊗⇘G⇙ y ∈ carrier G ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = undefined (λ(a, b)∈A × B. (φ y a, ψ y b))) ∧ (x ⊗⇘G⇙ y ∉ carrier G ⟶ undefined = undefined (λ(a, b)∈A × B. (φ y a, ψ y b)))))›*)
apply clarify
(*top goal: ‹⋀x. ⟦x ∈ carrier G; (λ(a, b)∈A × B. (φ x a, ψ x b)) ∈ Bij (A × B)⟧ ⟹ ∀y∈carrier G. (x ⊗⇘G⇙ y ∈ carrier G ⟶ ((λ(a, b)∈A × B. (φ y a, ψ y b)) ∈ Bij (A × B) ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = compose (A × B) (λ(a, b)∈A × B. (φ x a, ψ x b)) (λ(a, b)∈A × B. (φ y a, ψ y b))) ∧ ((λ(a, b)∈A × B. (φ y a, ψ y b)) ∉ Bij (A × B) ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = undefined)) ∧ (x ⊗⇘G⇙ y ∉ carrier G ⟶ (λ(a, b)∈A × B. (φ y a, ψ y b)) ∈ Bij (A × B) ⟶ undefined = compose (A × B) (λ(a, b)∈A × B. (φ x a, ψ x b)) (λ(a, b)∈A × B. (φ y a, ψ y b)))› and 1 goal remains*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); intro impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*top goal: ‹⋀x y. ⟦x ∈ carrier G; (λ(a, b)∈A × B. (φ x a, ψ x b)) ∈ Bij (A × B); y ∈ carrier G⟧ ⟹ (x ⊗⇘G⇙ y ∈ carrier G ⟶ ((λ(a, b)∈A × B. (φ y a, ψ y b)) ∈ Bij (A × B) ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = compose (A × B) (λ(a, b)∈A × B. (φ x a, ψ x b)) (λ(a, b)∈A × B. (φ y a, ψ y b))) ∧ ((λ(a, b)∈A × B. (φ y a, ψ y b)) ∉ Bij (A × B) ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = undefined)) ∧ (x ⊗⇘G⇙ y ∉ carrier G ⟶ (λ(a, b)∈A × B. (φ y a, ψ y b)) ∈ Bij (A × B) ⟶ undefined = compose (A × B) (λ(a, b)∈A × B. (φ x a, ψ x b)) (λ(a, b)∈A × B. (φ y a, ψ y b)))› and 1 goal remains*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*top goal: ‹⋀x y. ⟦x ∈ carrier G; (λ(a, b)∈A × B. (φ x a, ψ x b)) ∈ Bij (A × B); y ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G⟧ ⟹ ((λ(a, b)∈A × B. (φ y a, ψ y b)) ∈ Bij (A × B) ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = compose (A × B) (λ(a, b)∈A × B. (φ x a, ψ x b)) (λ(a, b)∈A × B. (φ y a, ψ y b))) ∧ ((λ(a, b)∈A × B. (φ y a, ψ y b)) ∉ Bij (A × B) ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = undefined)› and 2 goals remain*)
subgoal for x and y
apply unfold_locales
(*goal: ‹⟦x ∈ carrier G; (λ(a, b)∈A × B. (φ x a, ψ x b)) ∈ Bij (A × B); y ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G⟧ ⟹ (λ(a, b)∈A × B. (φ y a, ψ y b)) ∈ Bij (A × B) ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = compose (A × B) (λ(a, b)∈A × B. (φ x a, ψ x b)) (λ(a, b)∈A × B. (φ y a, ψ y b))›*)
apply (clarsimp simp add: Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*) restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*))
(*goal: ‹⟦x ∈ carrier G; (λ(a, b)∈A × B. (φ x a, ψ x b)) ∈ Bij (A × B); y ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G⟧ ⟹ (λ(a, b)∈A × B. (φ y a, ψ y b)) ∈ Bij (A × B) ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = compose (A × B) (λ(a, b)∈A × B. (φ x a, ψ x b)) (λ(a, b)∈A × B. (φ y a, ψ y b))›*)
apply (rule extensionalityI[where A = "A × B"] (*‹⟦?f ∈ extensional (A × B); ?g ∈ extensional (A × B); ⋀x. x ∈ A × B ⟹ ?f x = ?g x⟧ ⟹ ?f = ?g›*))
(*goal: ‹⟦x ∈ carrier G; y ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G; (λxa. if xa ∈ A × B then case xa of (a, b) ⇒ (φ x a, ψ x b) else undefined) ∈ extensional (A × B); inj_on (λxa. if xa ∈ A × B then case xa of (a, b) ⇒ (φ x a, ψ x b) else undefined) (A × B); (λxa. case xa of (a, b) ⇒ (φ x a, ψ x b)) ` (A × B) = A × B; (λx. if x ∈ A × B then case x of (a, b) ⇒ (φ y a, ψ y b) else undefined) ∈ extensional (A × B); inj_on (λx. if x ∈ A × B then case x of (a, b) ⇒ (φ y a, ψ y b) else undefined) (A × B); (λx. case x of (a, b) ⇒ (φ y a, ψ y b)) ` (A × B) = A × B⟧ ⟹ (λxa. if xa ∈ A × B then case xa of (a, b) ⇒ (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b) else undefined) = (λxa. if xa ∈ A × B then if (if xa ∈ A × B then case xa of (a, b) ⇒ (φ y a, ψ y b) else undefined) ∈ A × B then case if xa ∈ A × B then case xa of (a, b) ⇒ (φ y a, ψ y b) else undefined of (a, b) ⇒ (φ x a, ψ x b) else undefined else undefined)›*)
apply (clarsimp simp add: extensional_def (*‹extensional ?A = {f. ∀x. x ∉ ?A ⟶ f x = undefined}›*))
(*top goal: ‹⟦x ∈ carrier G; y ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G; (λxa. if xa ∈ A × B then case xa of (a, b) ⇒ (φ x a, ψ x b) else undefined) ∈ extensional (A × B); inj_on (λxa. if xa ∈ A × B then case xa of (a, b) ⇒ (φ x a, ψ x b) else undefined) (A × B); (λxa. case xa of (a, b) ⇒ (φ x a, ψ x b)) ` (A × B) = A × B; (λx. if x ∈ A × B then case x of (a, b) ⇒ (φ y a, ψ y b) else undefined) ∈ extensional (A × B); inj_on (λx. if x ∈ A × B then case x of (a, b) ⇒ (φ y a, ψ y b) else undefined) (A × B); (λx. case x of (a, b) ⇒ (φ y a, ψ y b)) ` (A × B) = A × B⟧ ⟹ (λxa. if xa ∈ A × B then case xa of (a, b) ⇒ (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b) else undefined) ∈ extensional (A × B)› and 2 goals remain*)
using grp_act_A (*‹alt_grp_act (G::('a, 'b) monoid_scheme) (A::'c set) (φ::'a ⇒ 'c ⇒ 'c)›*) grp_act_B (*‹alt_grp_act G B ψ›*) apply (simp add: alt_grp_act_def (*‹alt_grp_act ?G ?X ?φ ≡ group_action ?G ?X ?φ›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) Pi_def (*‹Pi ?A ?B = {f. ∀x. x ∈ ?A ⟶ f x ∈ ?B x}›*) Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*) extensional_def (*‹extensional ?A = {f. ∀x. x ∉ ?A ⟶ f x = undefined}›*))
(*top goal: ‹⟦(x::'a) ∈ carrier (G::('a, 'b) monoid_scheme); (y::'a) ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G; (λxa::'c × 'd. if xa ∈ (A::'c set) × (B::'d set) then case xa of (a::'c, b::'d) ⇒ ((φ::'a ⇒ 'c ⇒ 'c) x a, (ψ::'a ⇒ 'd ⇒ 'd) x b) else undefined) ∈ extensional (A × B); inj_on (λxa::'c × 'd. if xa ∈ A × B then case xa of (a::'c, b::'d) ⇒ (φ x a, ψ x b) else undefined) (A × B); (λxa::'c × 'd. case xa of (a::'c, b::'d) ⇒ (φ x a, ψ x b)) ` (A × B) = A × B; (λx::'c × 'd. if x ∈ A × B then case x of (a::'c, b::'d) ⇒ (φ y a, ψ y b) else undefined) ∈ extensional (A × B); inj_on (λx::'c × 'd. if x ∈ A × B then case x of (a::'c, b::'d) ⇒ (φ y a, ψ y b) else undefined) (A × B); (λx::'c × 'd. case x of (a::'c, b::'d) ⇒ (φ y a, ψ y b)) ` (A × B) = A × B⟧ ⟹ (λxa::'c × 'd. if xa ∈ A × B then if (if xa ∈ A × B then case xa of (a::'c, b::'d) ⇒ (φ y a, ψ y b) else undefined) ∈ A × B then case if xa ∈ A × B then case xa of (a::'c, b::'d) ⇒ (φ y a, ψ y b) else undefined of (a::'c, b::'d) ⇒ (φ x a, ψ x b) else undefined else undefined) ∈ extensional (A × B)› and 1 goal remains*)
apply (simp add: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*); rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); rule impI (*‹(?P::bool ⟹ ?Q::bool) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀xa. ⟦x ∈ carrier G; y ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G; (λxa. if xa ∈ A × B then case xa of (a, b) ⇒ (φ x a, ψ x b) else undefined) ∈ extensional (A × B); inj_on (λxa. if xa ∈ A × B then case xa of (a, b) ⇒ (φ x a, ψ x b) else undefined) (A × B); (λxa. case xa of (a, b) ⇒ (φ x a, ψ x b)) ` (A × B) = A × B; (λx. if x ∈ A × B then case x of (a, b) ⇒ (φ y a, ψ y b) else undefined) ∈ extensional (A × B); inj_on (λx. if x ∈ A × B then case x of (a, b) ⇒ (φ y a, ψ y b) else undefined) (A × B); (λx. case x of (a, b) ⇒ (φ y a, ψ y b)) ` (A × B) = A × B; xa ∈ A × B⟧ ⟹ (if xa ∈ A × B then case xa of (a, b) ⇒ (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b) else undefined) = (if xa ∈ A × B then if (if xa ∈ A × B then case xa of (a, b) ⇒ (φ y a, ψ y b) else undefined) ∈ A × B then case if xa ∈ A × B then case xa of (a, b) ⇒ (φ y a, ψ y b) else undefined of (a, b) ⇒ (φ x a, ψ x b) else undefined else undefined)›*)
using group_action.composition_rule[of G A φ] (*‹⟦group_action G A φ; ?x ∈ A; ?g1.0 ∈ carrier G; ?g2.0 ∈ carrier G⟧ ⟹ φ (?g1.0 ⊗⇘G⇙ ?g2.0) ?x = φ ?g1.0 (φ ?g2.0 ?x)›*) group_action.composition_rule[of G B ψ] (*‹⟦group_action G B ψ; ?x ∈ B; ?g1.0 ∈ carrier G; ?g2.0 ∈ carrier G⟧ ⟹ ψ (?g1.0 ⊗⇘G⇙ ?g2.0) ?x = ψ ?g1.0 (ψ ?g2.0 ?x)›*) grp_act_A (*‹alt_grp_act G A φ›*) grp_act_B (*‹alt_grp_act G B ψ›*)
(*goals:
1. ‹⋀xa::'c × 'd. ⟦(x::'a) ∈ carrier (G::('a, 'b) monoid_scheme); (y::'a) ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G; (λxa::'c × 'd. if xa ∈ (A::'c set) × (B::'d set) then case xa of (a::'c, b::'d) ⇒ ((φ::'a ⇒ 'c ⇒ 'c) x a, (ψ::'a ⇒ 'd ⇒ 'd) x b) else undefined) ∈ extensional (A × B); inj_on (λxa::'c × 'd. if xa ∈ A × B then case xa of (a::'c, b::'d) ⇒ (φ x a, ψ x b) else undefined) (A × B); (λxa::'c × 'd. case xa of (a::'c, b::'d) ⇒ (φ x a, ψ x b)) ` (A × B) = A × B; (λx::'c × 'd. if x ∈ A × B then case x of (a::'c, b::'d) ⇒ (φ y a, ψ y b) else undefined) ∈ extensional (A × B); inj_on (λx::'c × 'd. if x ∈ A × B then case x of (a::'c, b::'d) ⇒ (φ y a, ψ y b) else undefined) (A × B); (λx::'c × 'd. case x of (a::'c, b::'d) ⇒ (φ y a, ψ y b)) ` (A × B) = A × B; xa ∈ A × B; (case xa of (a::'c, b::'d) ⇒ (φ y a, ψ y b)) ∈ A × B⟧ ⟹ (case xa of (a::'c, b::'d) ⇒ (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = (case case xa of (a::'c, b::'d) ⇒ (φ y a, ψ y b) of (a::'c, b::'d) ⇒ (φ x a, ψ x b))›
2. ‹⋀xa::'c × 'd. ⟦(x::'a) ∈ carrier (G::('a, 'b) monoid_scheme); (y::'a) ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G; (λxa::'c × 'd. if xa ∈ (A::'c set) × (B::'d set) then case xa of (a::'c, b::'d) ⇒ ((φ::'a ⇒ 'c ⇒ 'c) x a, (ψ::'a ⇒ 'd ⇒ 'd) x b) else undefined) ∈ extensional (A × B); inj_on (λxa::'c × 'd. if xa ∈ A × B then case xa of (a::'c, b::'d) ⇒ (φ x a, ψ x b) else undefined) (A × B); (λxa::'c × 'd. case xa of (a::'c, b::'d) ⇒ (φ x a, ψ x b)) ` (A × B) = A × B; (λx::'c × 'd. if x ∈ A × B then case x of (a::'c, b::'d) ⇒ (φ y a, ψ y b) else undefined) ∈ extensional (A × B); inj_on (λx::'c × 'd. if x ∈ A × B then case x of (a::'c, b::'d) ⇒ (φ y a, ψ y b) else undefined) (A × B); (λx::'c × 'd. case x of (a::'c, b::'d) ⇒ (φ y a, ψ y b)) ` (A × B) = A × B; xa ∈ A × B; (case xa of (a::'c, b::'d) ⇒ (φ y a, ψ y b)) ∉ A × B⟧ ⟹ (case xa of (a::'c, b::'d) ⇒ (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = undefined›
discuss goal 1*)
apply force
(*discuss goal 2*)
apply blast
(*proven 2 subgoals*) .
(*goals:
1. ‹⋀x y. ⟦x ∈ carrier G; (λ(a, b)∈A × B. (φ x a, ψ x b)) ∈ Bij (A × B); y ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G⟧ ⟹ (λ(a, b)∈A × B. (φ y a, ψ y b)) ∉ Bij (A × B) ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = undefined›
2. ‹⋀x y. ⟦x ∈ carrier G; (λ(a, b)∈A × B. (φ x a, ψ x b)) ∈ Bij (A × B); y ∈ carrier G; x ⊗⇘G⇙ y ∉ carrier G; (λ(a, b)∈A × B. (φ y a, ψ y b)) ∈ Bij (A × B)⟧ ⟹ undefined = compose (A × B) (λ(a, b)∈A × B. (φ x a, ψ x b)) (λ(a, b)∈A × B. (φ y a, ψ y b))›
3. ‹⋀x. ⟦x ∈ carrier G; (λ(a, b)∈A × B. (φ x a, ψ x b)) ∉ Bij (A × B)⟧ ⟹ ∀y∈carrier G. (x ⊗⇘G⇙ y ∈ carrier G ⟶ (λ(a, b)∈A × B. (φ (x ⊗⇘G⇙ y) a, ψ (x ⊗⇘G⇙ y) b)) = undefined (λ(a, b)∈A × B. (φ y a, ψ y b))) ∧ (x ⊗⇘G⇙ y ∉ carrier G ⟶ undefined = undefined (λ(a, b)∈A × B. (φ y a, ψ y b)))›
discuss goal 1*)
apply (simp add: ‹⋀g. g ∈ carrier G ⟹ (λ(a, b)∈A × B. (φ g a, ψ g b)) ∈ Bij (A × B)›)
(*discuss goal 2*)
apply (simp add: ‹Group.group G› group.subgroup_self (*‹Group.group (?G::(?'a, ?'b) monoid_scheme) ⟹ subgroup (carrier ?G) ?G›*) subgroup.m_closed (*‹⟦subgroup (?H::?'a::type set) (?G::(?'a, ?'b) monoid_scheme); (?x::?'a::type) ∈ ?H; (?y::?'a::type) ∈ ?H⟧ ⟹ ?x ⊗⇘?G⇙ ?y ∈ ?H›*))
(*discuss goal 3*)
apply (simp add: ‹⋀g. g ∈ carrier G ⟹ (λ(a, b)∈A × B. (φ g a, ψ g b)) ∈ Bij (A × B)›)
(*proven 3 subgoals*) .
subsection ‹
Equivariance and Quotient Actions
›
locale eq_var_subset = alt_grp_act G X φ
for
G :: "('grp, 'b) monoid_scheme" and
X :: "'X set" (structure) and
φ +
fixes
Y
assumes
is_subset: "Y ⊆ X" and
is_equivar: "∀g∈carrier G. (φ g) ` Y = Y"
lemma (in alt_grp_act) eq_var_one_direction:
"⋀Y. Y ⊆ X ⟹ ∀g∈carrier G. (φ g) ` Y ⊆ Y ⟹ eq_var_subset G X φ Y"
proof (-)
(*goal: ‹⋀Y. ⟦Y ⊆ X; ∀g∈carrier G. φ g ` Y ⊆ Y⟧ ⟹ eq_var_subset G X φ Y›*)
fix Y
assume A_0: "Y ⊆ X" and A_1: "∀g∈carrier G. (φ g) ` Y ⊆ Y" (*‹(Y::'X set) ⊆ X› ‹∀g::'grp∈carrier (G::('grp, 'b) monoid_scheme). (φ::'grp ⇒ 'X ⇒ 'X) g ` (Y::'X set) ⊆ Y›*)
have H_0: "⋀g. g ∈ carrier G ⟹ (inv⇘G⇙ g) ∈ carrier G"
by (meson group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group_hom (*‹group_hom G (BijGroup X) φ›*) group_hom.axioms( (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) 1))
hence H_1: "⋀g y. g ∈ carrier G ⟹ y ∈ Y ⟹ (φ (inv⇘G⇙ g)) y ∈ Y"
using A_1 (*‹∀g∈carrier G. φ g ` Y ⊆ Y›*) by (simp add: image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*))
have H_2: "⋀g y. g ∈ carrier G ⟹ y ∈ Y ⟹ φ g ((φ (inv⇘G⇙ g)) y) = y"
by (metis A_0 (*‹Y ⊆ X›*) bij_prop1 (*‹⟦?g ∈ carrier G; ?y ∈ X⟧ ⟹ ∃!x. x ∈ X ∧ φ ?g x = ?y›*) orbit_sym_aux (*‹⟦?g ∈ carrier G; ?x ∈ X; φ ?g ?x = ?y⟧ ⟹ φ (inv⇘G⇙ ?g) ?y = ?x›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*))
show "eq_var_subset G X φ Y"
apply (simp add: eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*))
(*goal: ‹eq_var_subset G X φ Y›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹group_action G X φ ∧ Y ⊆ X ∧ (∀g∈carrier G. φ g ` Y = Y)›*)
apply (simp add: group_action_axioms (*‹group_action G X φ›*))
(*top goal: ‹group_action G X φ› and 2 goals remain*)
apply (rule A_0 (*‹Y ⊆ X›*))
(*top goal: ‹Y ⊆ X› and 1 goal remains*)
apply clarify
(*goal: ‹∀g::'grp::type∈carrier (G::('grp, 'b) monoid_scheme). (φ::'grp::type ⇒ 'X::type ⇒ 'X::type) g ` (Y::'X::type set) = Y›*)
apply (rule subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*))
(*goal: ‹⋀g. g ∈ carrier G ⟹ φ g ` Y = Y›*)
using A_1 (*‹∀g∈carrier G. φ g ` Y ⊆ Y›*) apply simp
(*top goal: ‹⋀g. g ∈ carrier G ⟹ φ g ` Y ⊆ Y› and 1 goal remains*)
apply (simp add: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*goal: ‹⋀g::'grp::type. g ∈ carrier (G::('grp, 'b) monoid_scheme) ⟹ (Y::'X::type set) ⊆ (φ::'grp::type ⇒ 'X::type ⇒ 'X::type) g ` Y›*)
apply (rule subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*))
(*goal: ‹⋀g. g ∈ carrier G ⟹ Y ⊆ {y. ∃x∈Y. y = φ g x}›*)
apply clarify
(*goal: ‹⋀(g::'grp) x::'X. ⟦g ∈ carrier (G::('grp, 'b) monoid_scheme); x ∈ (Y::'X set)⟧ ⟹ x ∈ {y::'X. ∃x::'X∈Y. y = (φ::'grp ⇒ 'X ⇒ 'X) g x}›*)
using H_1 (*‹⟦?g1 ∈ carrier G; ?y1 ∈ Y⟧ ⟹ φ (inv⇘G⇙ ?g1) ?y1 ∈ Y›*) H_2 (*‹⟦?g1 ∈ carrier G; ?y1 ∈ Y⟧ ⟹ φ ?g1 (φ (inv⇘G⇙ ?g1) ?y1) = ?y1›*) by metis
qed
text ‹
The following lemmas are used for proofs in the locale \texttt{eq\_var\_rel}:
›
lemma some_equiv_class_id:
"⟦equiv X R; w ∈ X // R; x ∈ w⟧ ⟹ R `` {x} = R `` {SOME z. z ∈ w}"
by (smt (z3) Eps_cong (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x = (?Q::?'a ⇒ bool) x) ⟹ Eps ?P = Eps ?Q›*) equiv_Eps_in (*‹⟦equiv (?A::?'a set) (?r::(?'a × ?'a) set); (?X::?'a set) ∈ ?A // ?r⟧ ⟹ (SOME x::?'a. x ∈ ?X) ∈ ?X›*) equiv_class_eq_iff (*‹equiv (?A::?'a set) (?r::(?'a × ?'a) set) ⟹ ((?x::?'a, ?y::?'a) ∈ ?r) = (?r `` {?x} = ?r `` {?y} ∧ ?x ∈ ?A ∧ ?y ∈ ?A)›*) quotient_eq_iff (*‹⟦equiv (?A::?'a set) (?r::(?'a × ?'a) set); (?X::?'a set) ∈ ?A // ?r; (?Y::?'a set) ∈ ?A // ?r; (?x::?'a) ∈ ?X; (?y::?'a) ∈ ?Y⟧ ⟹ (?X = ?Y) = ((?x, ?y) ∈ ?r)›*))
lemma nested_somes:
"⟦equiv X R; w ∈ X // R⟧ ⟹ (SOME z. z ∈ w) = (SOME z. z ∈ R``{(SOME z'. z' ∈ w)})"
by (metis proj_Eps (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ BNF_Greatest_Fixpoint.proj ?r (SOME x. x ∈ ?X) = ?X›*) proj_def (*‹BNF_Greatest_Fixpoint.proj ?r ?x = ?r `` {?x}›*))
locale eq_var_rel = alt_grp_act G X φ
for
G :: "('grp, 'b) monoid_scheme" and
X :: "'X set" (structure) and
φ +
fixes R
assumes
is_subrel:
"R ⊆ X × X" and
is_eq_var_rel:
"⋀a b. (a, b) ∈ R ⟹ ∀g ∈ carrier G. (g ⊙⇘φ⇙ a, g ⊙⇘φ⇙ b) ∈ R"
begin
lemma is_eq_var_rel' [simp, GMN_simps]:
"⋀a b. (a, b) ∈ R ⟹ ∀g ∈ carrier G. ((φ g) a, (φ g) b) ∈ R"
using is_eq_var_rel (*‹(?a, ?b) ∈ R ⟹ ∀g∈carrier G. (g ⊙⇘φ⇙ ?a, g ⊙⇘φ⇙ ?b) ∈ R›*) by auto
lemma is_eq_var_rel_rev:
"a ∈ X ⟹ b ∈ X ⟹ g ∈ carrier G ⟹ (g ⊙⇘φ⇙ a, g ⊙⇘φ⇙ b) ∈ R ⟹ (a, b) ∈ R"
proof (-)
(*goal: ‹⟦a ∈ X; b ∈ X; g ∈ carrier G; (g ⊙⇘φ⇙ a, g ⊙⇘φ⇙ b) ∈ R⟧ ⟹ (a, b) ∈ R›*)
assume A_0: "(g ⊙⇘φ⇙ a, g ⊙⇘φ⇙ b) ∈ R" and A_1: "a ∈ X" and A_2: "b ∈ X" and A_3: "g ∈ carrier G" (*‹((g::'grp) ⊙⇘φ::'grp ⇒ 'X ⇒ 'X⇙ (a::'X), g ⊙⇘φ⇙ (b::'X)) ∈ (R::('X × 'X) set)› ‹(a::'X) ∈ X› ‹(b::'X) ∈ X› ‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*)
have H_0: " group_action G X φ" and H_1: "R ⊆ X × X" and H_2: "⋀a b g. (a, b) ∈ R ⟹ g ∈ carrier G ⟹ (φ g a, φ g b) ∈ R"
(*goals:
1. ‹group_action G X φ›
2. ‹R ⊆ X × X›
3. ‹⋀a b g. ⟦(a, b) ∈ R; g ∈ carrier G⟧ ⟹ (φ g a, φ g b) ∈ R›
discuss goal 1*)
apply (simp add: group_action_axioms (*‹group_action G X φ›*) is_subrel (*‹R ⊆ X × X›*))
(*discuss goal 2*)
apply (simp add: group_action_axioms (*‹group_action G X φ›*) is_subrel (*‹R ⊆ X × X›*))
(*discuss goal 3*)
apply (simp add: group_action_axioms (*‹group_action G X φ›*) is_subrel (*‹R ⊆ X × X›*))
(*proven 3 subgoals*) .
from H_0 (*‹group_action G X φ›*) have H_3: "group G"
by (auto simp add: group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*))
have H_4: "(φ (inv⇘G⇙ g) (φ g a), φ (inv⇘G⇙ g) (φ g b)) ∈ R"
apply (rule H_2 (*‹⟦(?a1::'X, ?b1::'X) ∈ (R::('X × 'X) set); (?g1::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)⟧ ⟹ ((φ::'grp ⇒ 'X ⇒ 'X) ?g1 ?a1, φ ?g1 ?b1) ∈ R›*))
(*goal: ‹((φ::'grp::type ⇒ 'X::type ⇒ 'X::type) (inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp::type)) (φ g (a::'X::type)), φ (inv⇘G⇙ g) (φ g (b::'X::type))) ∈ (R::('X::type × 'X::type) set)›*)
using A_0 (*‹(g ⊙⇘φ⇙ a, g ⊙⇘φ⇙ b) ∈ R›*)
(*goals:
1. ‹(φ g a, φ g b) ∈ R›
2. ‹inv⇘G⇙ g ∈ carrier G›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (simp add: A_3 (*‹g ∈ carrier G›*) H_3 (*‹Group.group G›*))
(*proven 2 subgoals*) .
from H_3 (*‹Group.group G›*) A_3 (*‹g ∈ carrier G›*) have H_5: "(inv⇘G⇙ g) ∈ carrier G"
by auto
hence H_6: "⋀e. e ∈ X ⟹ φ (inv⇘G⇙ g) (φ g e) = φ ((inv⇘G⇙ g) ⊗⇘G⇙ g) e"
using H_0 (*‹group_action G X φ›*) A_3 (*‹g ∈ carrier G›*) group_action.composition_rule (*‹⟦group_action ?G ?E ?φ; ?x ∈ ?E; ?g1.0 ∈ carrier ?G; ?g2.0 ∈ carrier ?G⟧ ⟹ ?φ (?g1.0 ⊗⇘?G⇙ ?g2.0) ?x = ?φ ?g1.0 (?φ ?g2.0 ?x)›*) by fastforce
hence H_7: "⋀e. e ∈ X ⟹ φ (inv⇘G⇙ g) (φ g e) = φ 𝟭⇘G⇙ e"
using H_3 (*‹Group.group G›*) A_3 (*‹g ∈ carrier G›*) group.l_inv (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ⊗⇘?G⇙ ?x = 𝟭⇘?G⇙›*) by fastforce
hence H_8: "⋀e. e ∈ X ⟹ φ (inv⇘G⇙ g) (φ g e) = e"
using H_0 (*‹group_action G X φ›*) by (simp add: A_3 (*‹g ∈ carrier G›*) group_action.orbit_sym_aux (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?φ (inv⇘?G⇙ ?g) ?y = ?x›*))
thus "(a, b) ∈ R"
using A_1 (*‹(a::'X::type) ∈ X›*) A_2 (*‹b ∈ X›*) H_4 (*‹(φ (inv⇘G⇙ g) (φ g a), φ (inv⇘G⇙ g) (φ g b)) ∈ R›*) by simp
qed
lemma equiv_equivar_class_some_eq:
assumes
A_0: "equiv X R" and
A_1: "w ∈ X // R" and
A_2: "g ∈ carrier G"
shows "([ φ ]⇩R) g w = R `` {(SOME z'. z' ∈ φ g ` w)}"
proof (-)
(*goal: ‹([φ::'grp ⇒ 'X ⇒ 'X]⇩R::('X × 'X) set) (g::'grp) (w::'X set) = R `` {SOME z'::'X. z' ∈ φ g ` w}›*)
obtain z where H_z: "w = R `` {z} ∧ z ∈ w"
(*goal: ‹(⋀z. w = R `` {z} ∧ z ∈ w ⟹ thesis) ⟹ thesis›*)
by (metis A_0 (*‹equiv X R›*) A_1 (*‹w ∈ X // R›*) equiv_class_self (*‹⟦equiv ?A ?r; ?a ∈ ?A⟧ ⟹ ?a ∈ ?r `` {?a}›*) quotientE (*‹⟦?X ∈ ?A // ?r; ⋀x. ⟦?X = ?r `` {x}; x ∈ ?A⟧ ⟹ ?P⟧ ⟹ ?P›*))
have H_0: "⋀x. (φ g z, x) ∈ R ⟹ x ∈ φ g ` {y. (z, y) ∈ R}"
proof (-)
(*goal: ‹⋀x. (φ g z, x) ∈ R ⟹ x ∈ φ g ` {y. (z, y) ∈ R}›*)
fix y
assume A1_0: "(φ g z, y) ∈ R" (*‹((φ::'grp ⇒ 'X ⇒ 'X) (g::'grp) (z::'X), y::'X) ∈ (R::('X × 'X) set)›*)
obtain y' where H2_y': "y' = φ (inv⇘G⇙ g) y ∧ y' ∈ X"
(*goal: ‹(⋀y'::'X. y' = (φ::'grp ⇒ 'X ⇒ 'X) (inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp)) (y::'X) ∧ y' ∈ X ⟹ thesis::bool) ⟹ thesis›*)
using eq_var_rel_axioms (*‹eq_var_rel G X φ R›*) apply (clarsimp simp add: eq_var_rel_def (*‹eq_var_rel ?G ?X ?φ ?R ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_rel_axioms ?G ?X ?φ ?R›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*))
(*goal: ‹(⋀y'. y' = φ (inv⇘G⇙ g) y ∧ y' ∈ X ⟹ thesis) ⟹ thesis›*)
by (meson A_0 (*‹equiv X R›*) eq_var_rel_axioms (*‹eq_var_rel G X φ R›*) A_2 (*‹g ∈ carrier G›*) A1_0 (*‹(φ g z, y) ∈ R›*) equiv_class_eq_iff (*‹equiv ?A ?r ⟹ ((?x, ?y) ∈ ?r) = (?r `` {?x} = ?r `` {?y} ∧ ?x ∈ ?A ∧ ?y ∈ ?A)›*) eq_var_rel.is_eq_var_rel (*‹⟦eq_var_rel ?G ?X ?φ ?R; (?a, ?b) ∈ ?R⟧ ⟹ ∀g∈carrier ?G. (g ⊙⇘?φ⇙ ?a, g ⊙⇘?φ⇙ ?b) ∈ ?R›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) element_image (*‹⟦?g ∈ carrier G; ?x ∈ X; φ ?g ?x = ?y⟧ ⟹ ?y ∈ X›*))
from A_1 (*‹w ∈ X // R›*) A_2 (*‹g ∈ carrier G›*) H2_y' (*‹y' = φ (inv⇘G⇙ g) y ∧ y' ∈ X›*) have H2_0: "φ g y' = y"
apply (clarsimp simp add: eq_var_rel_def (*‹eq_var_rel (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?R::(?'X × ?'X) set) ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_rel_axioms ?G ?X ?φ ?R›*) eq_var_rel_axioms_def (*‹eq_var_rel_axioms (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?R::(?'X × ?'X) set) ≡ ?R ⊆ ?X × ?X ∧ (∀(a::?'X) b::?'X. (a, b) ∈ ?R ⟶ (∀g::?'grp∈carrier ?G. (g ⊙⇘?φ⇙ a, g ⊙⇘?φ⇙ b) ∈ ?R))›*))
(*goal: ‹φ g y' = y›*)
using A_2 (*‹g ∈ carrier G›*) A1_0 (*‹(φ g z, y) ∈ R›*) group_action.bij_prop1[where G = "G" and E = "X" and φ = "φ"] (*‹⟦group_action G X φ; ?g ∈ carrier G; ?y ∈ X⟧ ⟹ ∃!x. x ∈ X ∧ φ ?g x = ?y›*) by (metis A_0 (*‹equiv X (R::('X × 'X) set)›*) alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) alt_grp_act_axioms (*‹alt_grp_act (G::('grp, 'b) monoid_scheme) X (φ::'grp ⇒ 'X ⇒ 'X)›*) equiv_class_eq_iff (*‹equiv (?A::?'a set) (?r::(?'a × ?'a) set) ⟹ ((?x::?'a, ?y::?'a) ∈ ?r) = (?r `` {?x} = ?r `` {?y} ∧ ?x ∈ ?A ∧ ?y ∈ ?A)›*) orbit_sym_aux (*‹⟦(?g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); (?x::'X) ∈ X; (φ::'grp ⇒ 'X ⇒ 'X) ?g ?x = (?y::'X)⟧ ⟹ φ (inv⇘G⇙ ?g) ?y = ?x›*))
from A_1 (*‹w ∈ X // R›*) A_2 (*‹g ∈ carrier G›*) A1_0 (*‹(φ g z, y) ∈ R›*) have H2_1: "(z, y') ∈ R"
by (metis H2_0 (*‹φ g y' = y›*) A_0 (*‹equiv X R›*) A_2 (*‹g ∈ carrier G›*) H2_y' (*‹y' = φ (inv⇘G⇙ g) y ∧ y' ∈ X›*) H_z (*‹w = R `` {z} ∧ z ∈ w›*) equiv_class_eq_iff (*‹equiv ?A ?r ⟹ ((?x, ?y) ∈ ?r) = (?r `` {?x} = ?r `` {?y} ∧ ?x ∈ ?A ∧ ?y ∈ ?A)›*) is_eq_var_rel_rev (*‹⟦?a ∈ X; ?b ∈ X; ?g ∈ carrier G; (?g ⊙⇘φ⇙ ?a, ?g ⊙⇘φ⇙ ?b) ∈ R⟧ ⟹ (?a, ?b) ∈ R›*) quotient_eq_iff (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r; ?Y ∈ ?A // ?r; ?x ∈ ?X; ?y ∈ ?Y⟧ ⟹ (?X = ?Y) = ((?x, ?y) ∈ ?r)›*) make_op_def (*‹(⊙⇘?φ⇙) ≡ ?φ›*))
thus "y ∈ φ g ` {v. (z, v) ∈ R}"
using H2_0 (*‹φ g y' = y›*) by (auto simp add: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
qed
have H_1: "φ g ` (R `` {z}) = R `` {φ g z}"
apply (clarsimp simp add: Relation.Image_def (*‹(?r::(?'a::type × ?'b::type) set) `` (?s::?'a::type set) = {y::?'b::type. ∃x::?'a::type∈?s. (x, y) ∈ ?r}›*))
(*goal: ‹φ g ` R `` {z} = R `` {φ g z}›*)
apply (rule subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*); simp add: Set.subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*); rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*); rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹φ g ` {y. (z, y) ∈ R} = {y. (φ g z, y) ∈ R}›*)
using eq_var_rel_axioms (*‹eq_var_rel G X φ R›*) A_2 (*‹g ∈ carrier G›*) eq_var_rel.is_eq_var_rel (*‹⟦eq_var_rel ?G ?X ?φ ?R; (?a, ?b) ∈ ?R⟧ ⟹ ∀g∈carrier ?G. (g ⊙⇘?φ⇙ ?a, g ⊙⇘?φ⇙ ?b) ∈ ?R›*)
(*goals:
1. ‹⋀x::'X. (z::'X, x) ∈ (R::('X × 'X) set) ⟹ ((φ::'grp ⇒ 'X ⇒ 'X) (g::'grp) z, φ g x) ∈ R›
2. ‹⋀x::'X. ((φ::'grp ⇒ 'X ⇒ 'X) (g::'grp) (z::'X), x) ∈ (R::('X × 'X) set) ⟹ x ∈ φ g ` {y::'X. (z, y) ∈ R}›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (simp add: H_0 (*‹((φ::'grp::type ⇒ 'X::type ⇒ 'X::type) (g::'grp::type) (z::'X::type), ?x1::'X::type) ∈ (R::('X::type × 'X::type) set) ⟹ ?x1 ∈ φ g ` {y::'X::type. (z, y) ∈ R}›*))
(*proven 2 subgoals*) .
have H_2: "φ g ` w ∈ X // R"
using eq_var_rel_axioms (*‹eq_var_rel G X φ R›*) A_1 (*‹w ∈ X // R›*) A_2 (*‹g ∈ carrier G›*) H_1 (*‹φ g ` R `` {z} = R `` {φ g z}›*) by (metis A_0 (*‹equiv X (R::('X × 'X) set)›*) H_z (*‹(w::'X set) = (R::('X × 'X) set) `` {z::'X} ∧ z ∈ w›*) equiv_class_eq_iff (*‹equiv (?A::?'a set) (?r::(?'a × ?'a) set) ⟹ ((?x::?'a, ?y::?'a) ∈ ?r) = (?r `` {?x} = ?r `` {?y} ∧ ?x ∈ ?A ∧ ?y ∈ ?A)›*) quotientI (*‹(?x::?'a) ∈ (?A::?'a set) ⟹ (?r::(?'a × ?'a) set) `` {?x} ∈ ?A // ?r›*) quotient_eq_iff (*‹⟦equiv (?A::?'a set) (?r::(?'a × ?'a) set); (?X::?'a set) ∈ ?A // ?r; (?Y::?'a set) ∈ ?A // ?r; (?x::?'a) ∈ ?X; (?y::?'a) ∈ ?Y⟧ ⟹ (?X = ?Y) = ((?x, ?y) ∈ ?r)›*) element_image (*‹⟦(?g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); (?x::'X) ∈ X; (φ::'grp ⇒ 'X ⇒ 'X) ?g ?x = (?y::'X)⟧ ⟹ ?y ∈ X›*))
thus "([φ]⇩R) g w = R `` {SOME z'. z' ∈ φ g ` w}"
using A_0 (*‹equiv X R›*) A_1 (*‹w ∈ X // R›*) A_2 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) apply (clarsimp simp add: Image_def (*‹?r `` ?s = {y. ∃x∈?s. (x, y) ∈ ?r}›*))
(*goal: ‹([φ::'grp ⇒ 'X ⇒ 'X]⇩R::('X × 'X) set) (g::'grp) (w::'X set) = R `` {SOME z'::'X. z' ∈ φ g ` w}›*)
apply (intro subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*))
(*goal: ‹⟦(φ::'grp ⇒ 'X ⇒ 'X) (g::'grp) ` (w::'X set) ∈ X // (R::('X × 'X) set); equiv X R; w ∈ X // R; g ∈ carrier (G::('grp, 'b) monoid_scheme)⟧ ⟹ {y::'X. (φ g (SOME z::'X. z ∈ w), y) ∈ R} = {y::'X. (SOME z'::'X. z' ∈ φ g ` w, y) ∈ R}›*)
apply clarify
(*top goal: ‹⟦φ g ` w ∈ X // R; equiv X R; w ∈ X // R; g ∈ carrier G⟧ ⟹ {y. (φ g (SOME z. z ∈ w), y) ∈ R} ⊆ {y. (SOME z'. z' ∈ φ g ` w, y) ∈ R}› and 1 goal remains*)
using A_0 (*‹equiv X R›*) H_z (*‹(w::'X::type set) = (R::('X::type × 'X::type) set) `` {z::'X::type} ∧ z ∈ w›*) imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*) insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*) insert_not_empty (*‹insert ?a ?A ≠ {}›*) some_in_eq (*‹((SOME x. x ∈ ?A) ∈ ?A) = (?A ≠ {})›*) some_equiv_class_id (*‹⟦equiv ?X ?R; ?w ∈ ?X // ?R; ?x ∈ ?w⟧ ⟹ ?R `` {?x} = ?R `` {SOME z. z ∈ ?w}›*)
(*goals:
1. ‹⋀x. ⟦φ g ` w ∈ X // R; equiv X R; w ∈ X // R; g ∈ carrier G; (φ g (SOME z. z ∈ w), x) ∈ R⟧ ⟹ (SOME z'. z' ∈ φ g ` w, x) ∈ R›
2. ‹⟦φ g ` w ∈ X // R; equiv X R; w ∈ X // R; g ∈ carrier G⟧ ⟹ {y. (SOME z'. z' ∈ φ g ` w, y) ∈ R} ⊆ {y. (φ g (SOME z. z ∈ w), y) ∈ R}›
discuss goal 1*)
apply (smt (z3) A_1 (*‹w ∈ X // R›*) Eps_cong (*‹(⋀x. ?P x = ?Q x) ⟹ Eps ?P = Eps ?Q›*) Image_singleton_iff (*‹(?b ∈ ?r `` {?a}) = ((?a, ?b) ∈ ?r)›*) equiv_Eps_in (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ (SOME x. x ∈ ?X) ∈ ?X›*))
(*discuss goal 2*)
apply clarify
(*goal: ‹⟦φ g ` w ∈ X // R; equiv X R; w ∈ X // R; g ∈ carrier G⟧ ⟹ {y. (SOME z'. z' ∈ φ g ` w, y) ∈ R} ⊆ {y. (φ g (SOME z. z ∈ w), y) ∈ R}›*)
apply (smt (z3) Eps_cong (*‹(⋀x. ?P x = ?Q x) ⟹ Eps ?P = Eps ?Q›*) equiv_Eps_in (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ (SOME x. x ∈ ?X) ∈ ?X›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) in_quotient_imp_closed (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r; ?x ∈ ?X; (?x, ?y) ∈ ?r⟧ ⟹ ?y ∈ ?X›*) quotient_eq_iff (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r; ?Y ∈ ?A // ?r; ?x ∈ ?X; ?y ∈ ?Y⟧ ⟹ (?X = ?Y) = ((?x, ?y) ∈ ?r)›*))
(*proven 2 subgoals*) .
qed
lemma ec_er_closed_under_action:
assumes
A_0: "equiv X R" and
A_1: "g ∈ carrier G" and
A_2: "w ∈ X//R"
shows "φ g ` w ∈ X // R"
proof (-)
(*goal: ‹φ g ` w ∈ X // R›*)
obtain z where H_z: "R `` {z} = w ∧ z ∈ X"
(*goal: ‹(⋀z. R `` {z} = w ∧ z ∈ X ⟹ thesis) ⟹ thesis›*)
by (metis A_2 (*‹(w::'X set) ∈ X // (R::('X × 'X) set)›*) quotientE (*‹⟦(?X::?'a set) ∈ (?A::?'a set) // (?r::(?'a × ?'a) set); ⋀x::?'a. ⟦?X = ?r `` {x}; x ∈ ?A⟧ ⟹ ?P::bool⟧ ⟹ ?P›*))
have H_0: "equiv X R ⟹ g ∈ carrier G ⟹ w ∈ X // R ⟹
{y. (φ g z, y) ∈ R} ⊆ {y. ∃x. (z, x) ∈ R ∧ y = φ g x}"
proof (clarify)
(*goal: ‹⋀x. ⟦equiv X R; g ∈ carrier G; w ∈ X // R; (φ g z, x) ∈ R⟧ ⟹ ∃xa. (z, xa) ∈ R ∧ x = φ g xa›*)
fix x
assume A1_0: "equiv X R" and A1_1: "g ∈ carrier G" and A1_2: "w ∈ X // R" and A1_3: "(φ g z, x) ∈ R" (*‹equiv X (R::('X × 'X) set)› ‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹(w::'X set) ∈ X // (R::('X × 'X) set)› ‹((φ::'grp ⇒ 'X ⇒ 'X) (g::'grp) (z::'X), x::'X) ∈ (R::('X × 'X) set)›*)
obtain x' where H2_x': "x = φ g x' ∧ x' ∈ X"
(*goal: ‹(⋀x'::'X::type. (x::'X::type) = (φ::'grp::type ⇒ 'X::type ⇒ 'X::type) (g::'grp::type) x' ∧ x' ∈ X ⟹ thesis::bool) ⟹ thesis›*)
using group_action_axioms (*‹group_action G X φ›*) by (metis A1_1 (*‹g ∈ carrier G›*) is_subrel (*‹R ⊆ X × X›*) A1_3 (*‹(φ g z, x) ∈ R›*) SigmaD2 (*‹(?a, ?b) ∈ Sigma ?A ?B ⟹ ?b ∈ ?B ?a›*) group_action.bij_prop1 (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?y ∈ ?E⟧ ⟹ ∃!x. x ∈ ?E ∧ ?φ ?g x = ?y›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*))
thus "∃y. (z, y) ∈ R ∧ x = φ g y"
using is_eq_var_rel_rev[where g = "g" and a = "z" and b = "x'"] (*‹⟦z ∈ X; x' ∈ X; g ∈ carrier G; (g ⊙⇘φ⇙ z, g ⊙⇘φ⇙ x') ∈ R⟧ ⟹ (z, x') ∈ R›*) A1_3 (*‹(φ g z, x) ∈ R›*) by (auto simp add: eq_var_rel_def (*‹eq_var_rel ?G ?X ?φ ?R ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_rel_axioms ?G ?X ?φ ?R›*) eq_var_rel_axioms_def (*‹eq_var_rel_axioms ?G ?X ?φ ?R ≡ ?R ⊆ ?X × ?X ∧ (∀a b. (a, b) ∈ ?R ⟶ (∀g∈carrier ?G. (g ⊙⇘?φ⇙ a, g ⊙⇘?φ⇙ b) ∈ ?R))›*) A1_1 (*‹g ∈ carrier G›*) A1_2 (*‹w ∈ X // R›*) group_action_axioms (*‹group_action G X φ›*) H_z (*‹R `` {z} = w ∧ z ∈ X›*) H2_x' (*‹x = φ g x' ∧ x' ∈ X›*))
qed
have H_1: "φ g ` R `` {z} = R `` {φ g z}"
using A_0 (*‹equiv X (R::('X × 'X) set)›*) A_1 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A_2 (*‹w ∈ X // R›*) apply ((clarsimp simp add: eq_var_rel_axioms_def (*‹eq_var_rel_axioms ?G ?X ?φ ?R ≡ ?R ⊆ ?X × ?X ∧ (∀a b. (a, b) ∈ ?R ⟶ (∀g∈carrier ?G. (g ⊙⇘?φ⇙ a, g ⊙⇘?φ⇙ b) ∈ ?R))›*) eq_var_rel_def (*‹eq_var_rel ?G ?X ?φ ?R ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_rel_axioms ?G ?X ?φ ?R›*) Image_def (*‹?r `` ?s = {y. ∃x∈?s. (x, y) ∈ ?r}›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*goal: ‹φ g ` R `` {z} = R `` {φ g z}›*)
apply ((intro subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*))[1])
(*goals:
1. ‹⟦equiv X R; g ∈ carrier G; w ∈ X // R⟧ ⟹ {y. ∃x. (z, x) ∈ R ∧ y = φ g x} ⊆ {y. (φ g z, y) ∈ R}›
2. ‹⟦equiv X R; g ∈ carrier G; w ∈ X // R⟧ ⟹ {y. (φ g z, y) ∈ R} ⊆ {y. ∃x. (z, x) ∈ R ∧ y = φ g x}›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply (rule H_0 (*‹⟦equiv X R; g ∈ carrier G; w ∈ X // R⟧ ⟹ {y. (φ g z, y) ∈ R} ⊆ {y. ∃x. (z, x) ∈ R ∧ y = φ g x}›*))
(*goals:
1. ‹⟦equiv X R; g ∈ carrier G; w ∈ X // R⟧ ⟹ equiv X R›
2. ‹⟦equiv X R; g ∈ carrier G; w ∈ X // R⟧ ⟹ g ∈ carrier G›
3. ‹⟦equiv X R; g ∈ carrier G; w ∈ X // R⟧ ⟹ w ∈ X // R›
discuss goal 1*)
apply ((assumption)[1])
(*discuss goal 2*)
apply ((assumption)[1])
(*discuss goal 3*) .
(*proven 3 subgoals*)
(*proven 2 subgoals*)
thus "φ g ` w ∈ X // R"
using H_1 (*‹(φ::'grp ⇒ 'X ⇒ 'X) (g::'grp) ` (R::('X × 'X) set) `` {z::'X} = R `` {φ g z}›*) H_z (*‹R `` {z} = w ∧ z ∈ X›*) by (metis A_1 (*‹g ∈ carrier G›*) quotientI (*‹?x ∈ ?A ⟹ ?r `` {?x} ∈ ?A // ?r›*) element_image (*‹⟦?g ∈ carrier G; ?x ∈ X; φ ?g ?x = ?y⟧ ⟹ ?y ∈ X›*))
qed
text ‹
The following lemma corresponds to the first part of lemma 3.5 from \cite{bojanczyk2014automata}:
›
lemma quot_act_wd:
"⟦equiv X R; x ∈ X; g ∈ carrier G⟧ ⟹ g ⊙⇘[φ]⇩R⇙ (R `` {x}) = (R `` {g ⊙⇘φ⇙ x})"
apply (clarsimp simp add: eq_var_rel_def (*‹eq_var_rel ?G ?X ?φ ?R ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_rel_axioms ?G ?X ?φ ?R›*) eq_var_rel_axioms_def (*‹eq_var_rel_axioms ?G ?X ?φ ?R ≡ ?R ⊆ ?X × ?X ∧ (∀a b. (a, b) ∈ ?R ⟶ (∀g∈carrier ?G. (g ⊙⇘?φ⇙ a, g ⊙⇘?φ⇙ b) ∈ ?R))›*))
(*goal: ‹⟦equiv X R; x ∈ X; g ∈ carrier G⟧ ⟹ g ⊙⇘[φ]⇩R⇙ R `` {x} = R `` {g ⊙⇘φ⇙ x}›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⟦equiv X R; x ∈ X; g ∈ carrier G⟧ ⟹ R `` {x} ∈ X // R ⟶ R `` {φ g (SOME z. (x, z) ∈ R)} = R `` {φ g x}›
2. ‹⟦equiv X R; x ∈ X; g ∈ carrier G⟧ ⟹ R `` {x} ∉ X // R ⟶ undefined = R `` {φ g x}›
discuss goal 1*)
apply (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*top goal: ‹⟦equiv X (R::('X × 'X) set); (x::'X) ∈ X; (g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)⟧ ⟹ R `` {x} ∈ X // R ⟶ R `` {(φ::'grp ⇒ 'X ⇒ 'X) g (SOME z::'X. (x, z) ∈ R)} = R `` {φ g x}› and 1 goal remains*)
apply (smt (verit, best) Eps_cong (*‹(⋀x. ?P x = ?Q x) ⟹ Eps ?P = Eps ?Q›*) Image_singleton_iff (*‹(?b ∈ ?r `` {?a}) = ((?a, ?b) ∈ ?r)›*) eq_var_rel.is_eq_var_rel' (*‹⟦eq_var_rel ?G ?X ?φ ?R; (?a, ?b) ∈ ?R⟧ ⟹ ∀g∈carrier ?G. (?φ g ?a, ?φ g ?b) ∈ ?R›*) eq_var_rel_axioms (*‹eq_var_rel G X φ R›*) equiv_Eps_in (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ (SOME x. x ∈ ?X) ∈ ?X›*) equiv_class_eq (*‹⟦equiv ?A ?r; (?a, ?b) ∈ ?r⟧ ⟹ ?r `` {?a} = ?r `` {?b}›*))
(*discuss goal 2*)
apply (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⟦equiv X R; x ∈ X; g ∈ carrier G⟧ ⟹ R `` {x} ∉ X // R ⟶ undefined = R `` {φ g x}›*)
apply (simp add: quotientI (*‹?x ∈ ?A ⟹ ?r `` {?x} ∈ ?A // ?r›*))
(*proven 2 subgoals*) .
text ‹
The following lemma corresponds to the second part of lemma 3.5 from \cite{bojanczyk2014automata}:
›
lemma quot_act_is_grp_act:
"equiv X R ⟹ alt_grp_act G (X // R) ([φ]⇩R)"
proof (-)
(*goal: ‹equiv X R ⟹ alt_grp_act G (X // R) ([φ]⇩R)›*)
assume A_0: "equiv X R" (*‹equiv X (R::('X × 'X) set)›*)
have H_0: "⋀x. Group.group G ⟹
Group.group (BijGroup X) ⟹
R ⊆ X × X ⟹
φ ∈ carrier G → carrier (BijGroup X) ⟹
∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y ⟹
x ∈ carrier G ⟹ (λxa∈X // R. R `` {φ x (SOME z. z ∈ xa)}) ∈ carrier (BijGroup (X // R))"
proof (-)
(*goal: ‹⋀x. ⟦Group.group G; Group.group (BijGroup X); R ⊆ X × X; φ ∈ carrier G → carrier (BijGroup X); ∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y; x ∈ carrier G⟧ ⟹ (λxa∈X // R. R `` {φ x (SOME z. z ∈ xa)}) ∈ carrier (BijGroup (X // R))›*)
fix g
assume A1_0: "Group.group G" and A1_1: "Group.group (BijGroup X)" and A1_2: "φ ∈ carrier G → carrier (BijGroup X)" and A1_3: "∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y" and A1_4: "g ∈ carrier G" (*‹Group.group (G::('grp, 'b) monoid_scheme)› ‹Group.group (BijGroup X)› ‹(φ::'grp ⇒ 'X ⇒ 'X) ∈ carrier (G::('grp, 'b) monoid_scheme) → carrier (BijGroup X)› ‹∀x::'grp∈carrier (G::('grp, 'b) monoid_scheme). ∀y::'grp∈carrier G. (φ::'grp ⇒ 'X ⇒ 'X) (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y› ‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*)
have H_0: "group_action G X φ"
apply (clarsimp simp add: group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*))
(*goal: ‹group_action (G::('grp, 'b) monoid_scheme) X (φ::'grp::type ⇒ 'X::type ⇒ 'X::type)›*)
apply ((simp add: A1_0 (*‹Group.group (G::('grp, 'b) monoid_scheme)›*) A1_1 (*‹Group.group (BijGroup X)›*))+)
(*goal: ‹Group.group G ∧ Group.group (BijGroup X) ∧ φ ∈ hom G (BijGroup X)›*)
apply (simp add: hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*))
(*goal: ‹φ ∈ hom G (BijGroup X)›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹φ ∈ carrier G → carrier (BijGroup X) ∧ (∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y)›*)
using A1_2 (*‹φ ∈ carrier G → carrier (BijGroup X)›*)
(*goals:
1. ‹(φ::'grp ⇒ 'X ⇒ 'X) ∈ carrier (G::('grp, 'b) monoid_scheme) → carrier (BijGroup X)›
2. ‹∀x::'grp∈carrier (G::('grp, 'b) monoid_scheme). ∀y::'grp∈carrier G. (φ::'grp ⇒ 'X ⇒ 'X) (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply (simp add: A1_3 (*‹∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y›*))
(*proven 2 subgoals*) .
have H1_0: "⋀x y. ⟦x ∈ X // R; y ∈ X // R; R `` {φ g (SOME z. z ∈ x)} =
R `` {φ g (SOME z. z ∈ y)}⟧ ⟹ x ⊆ y"
apply clarify
(*goal: ‹⋀(x::'X set) y::'X set. ⟦x ∈ X // (R::('X × 'X) set); y ∈ X // R; R `` {(φ::'grp ⇒ 'X ⇒ 'X) (g::'grp) (SOME z::'X. z ∈ x)} = R `` {φ g (SOME z::'X. z ∈ y)}⟧ ⟹ x ⊆ y›*)
proof (rename_tac a)
(*goal: ‹⋀x y a. ⟦x ∈ X // R; y ∈ X // R; R `` {φ g (SOME z. z ∈ x)} = R `` {φ g (SOME z. z ∈ y)}; a ∈ x⟧ ⟹ a ∈ y›*)
fix x and y and a
assume A2_0: "x ∈ X // R" and A2_1: "y ∈ X // R" and A2_2: "R `` {φ g (SOME z. z ∈ x)} = R `` {φ g (SOME z. z ∈ y)}" and A2_3: "a ∈ x" (*‹(x::'X set) ∈ X // (R::('X × 'X) set)› ‹(y::'X set) ∈ X // (R::('X × 'X) set)› ‹(R::('X × 'X) set) `` {(φ::'grp ⇒ 'X ⇒ 'X) (g::'grp) (SOME z::'X. z ∈ (x::'X set))} = R `` {φ g (SOME z::'X. z ∈ (y::'X set))}› ‹(a::'X) ∈ (x::'X set)›*)
obtain b where H2_b: "R `` {b} = y ∧ b ∈ X"
(*goal: ‹(⋀b. R `` {b} = y ∧ b ∈ X ⟹ thesis) ⟹ thesis›*)
by (metis A2_1 (*‹y ∈ X // R›*) quotientE (*‹⟦?X ∈ ?A // ?r; ⋀x. ⟦?X = ?r `` {x}; x ∈ ?A⟧ ⟹ ?P⟧ ⟹ ?P›*))
obtain a' and b' where H2_a'_b': "a'∈ x ∧ b'∈ y ∧ R `` {φ g a'} = R `` {φ g b'}"
(*goal: ‹(⋀a' b'. a' ∈ x ∧ b' ∈ y ∧ R `` {φ g a'} = R `` {φ g b'} ⟹ thesis) ⟹ thesis›*)
by (metis A_0 (*‹equiv X (R::('X::type × 'X::type) set)›*) A2_1 (*‹(y::'X::type set) ∈ X // (R::('X::type × 'X::type) set)›*) A2_2 (*‹(R::('X::type × 'X::type) set) `` {(φ::'grp::type ⇒ 'X::type ⇒ 'X::type) (g::'grp::type) (SOME z::'X::type. z ∈ (x::'X::type set))} = R `` {φ g (SOME z::'X::type. z ∈ (y::'X::type set))}›*) A2_3 (*‹(a::'X::type) ∈ (x::'X::type set)›*) equiv_Eps_in (*‹⟦equiv (?A::?'a::type set) (?r::(?'a::type × ?'a::type) set); (?X::?'a::type set) ∈ ?A // ?r⟧ ⟹ (SOME x::?'a::type. x ∈ ?X) ∈ ?X›*) some_eq_imp (*‹⟦Eps (?P::?'a::type ⇒ bool) = (?a::?'a::type); ?P (?b::?'a::type)⟧ ⟹ ?P ?a›*))
from H2_a'_b' (*‹a' ∈ x ∧ b' ∈ y ∧ R `` {φ g a'} = R `` {φ g b'}›*) have H2_2: "(φ g a', φ g b') ∈ R"
by (metis A_0 (*‹equiv X R›*) A1_4 (*‹g ∈ carrier G›*) A2_1 (*‹y ∈ X // R›*) Image_singleton_iff (*‹(?b ∈ ?r `` {?a}) = ((?a, ?b) ∈ ?r)›*) eq_var_rel.is_eq_var_rel' (*‹⟦eq_var_rel ?G ?X ?φ ?R; (?a, ?b) ∈ ?R⟧ ⟹ ∀g∈carrier ?G. (?φ g ?a, ?φ g ?b) ∈ ?R›*) eq_var_rel_axioms (*‹eq_var_rel G X φ R›*) quotient_eq_iff (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r; ?Y ∈ ?A // ?r; ?x ∈ ?X; ?y ∈ ?Y⟧ ⟹ (?X = ?Y) = ((?x, ?y) ∈ ?r)›*))
hence H2_0: "(φ (inv⇘G⇙ g) (φ g a'), φ (inv⇘G⇙ g) (φ g b')) ∈ R"
by (simp add: A1_0 (*‹Group.group (G::('grp, 'b) monoid_scheme)›*) is_eq_var_rel (*‹(?a::'X::type, ?b::'X::type) ∈ (R::('X::type × 'X::type) set) ⟹ ∀g::'grp::type∈carrier (G::('grp, 'b) monoid_scheme). (g ⊙⇘φ::'grp::type ⇒ 'X::type ⇒ 'X::type⇙ ?a, g ⊙⇘φ⇙ ?b) ∈ R›*) A1_4 (*‹(g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme)›*))
have H2_1: "a' ∈ X ∧ b' ∈ X"
using A_0 (*‹equiv X R›*) A2_0 (*‹(x::'X set) ∈ X // (R::('X × 'X) set)›*) A2_1 (*‹y ∈ X // R›*) H2_a'_b' (*‹a' ∈ x ∧ b' ∈ y ∧ R `` {φ g a'} = R `` {φ g b'}›*) in_quotient_imp_subset (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ ?X ⊆ ?A›*) by blast
hence H2_2: "(a', b') ∈ R"
using H2_0 (*‹(φ (inv⇘G⇙ g) (φ g a'), φ (inv⇘G⇙ g) (φ g b')) ∈ R›*) by (metis A1_4 (*‹g ∈ carrier G›*) H_0 (*‹group_action G X φ›*) group_action.orbit_sym_aux (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?φ (inv⇘?G⇙ ?g) ?y = ?x›*))
have H2_3: "(a, a') ∈ R"
by (meson A_0 (*‹equiv X R›*) A2_0 (*‹x ∈ X // R›*) A2_3 (*‹a ∈ x›*) H2_a'_b' (*‹a' ∈ x ∧ b' ∈ y ∧ R `` {φ g a'} = R `` {φ g b'}›*) quotient_eq_iff (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r; ?Y ∈ ?A // ?r; ?x ∈ ?X; ?y ∈ ?Y⟧ ⟹ (?X = ?Y) = ((?x, ?y) ∈ ?r)›*))
hence H2_4: "(b', a) ∈ R"
using H2_2 (*‹(a', b') ∈ R›*) by (metis A_0 (*‹equiv X R›*) A2_0 (*‹x ∈ X // R›*) A2_1 (*‹y ∈ X // R›*) A2_3 (*‹a ∈ x›*) H2_a'_b' (*‹a' ∈ x ∧ b' ∈ y ∧ R `` {φ g a'} = R `` {φ g b'}›*) quotient_eqI (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r; ?Y ∈ ?A // ?r; ?x ∈ ?X; ?y ∈ ?Y; (?x, ?y) ∈ ?r⟧ ⟹ ?X = ?Y›*) quotient_eq_iff (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r; ?Y ∈ ?A // ?r; ?x ∈ ?X; ?y ∈ ?Y⟧ ⟹ (?X = ?Y) = ((?x, ?y) ∈ ?r)›*))
thus "a ∈ y"
by (metis A_0 (*‹equiv X R›*) A2_1 (*‹y ∈ X // R›*) H2_a'_b' (*‹a' ∈ x ∧ b' ∈ y ∧ R `` {φ g a'} = R `` {φ g b'}›*) in_quotient_imp_closed (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r; ?x ∈ ?X; (?x, ?y) ∈ ?r⟧ ⟹ ?y ∈ ?X›*))
qed
have H1_1: "⋀x. x ∈ X // R ⟹ ∃xa∈X // R. x = R `` {φ g (SOME z. z ∈ xa)}"
proof (-)
(*goal: ‹⋀x. x ∈ X // R ⟹ ∃xa∈X // R. x = R `` {φ g (SOME z. z ∈ xa)}›*)
fix x
assume A2_0: "x ∈ X // R" (*‹(x::'X set) ∈ X // (R::('X × 'X) set)›*)
have H2_0: "⋀e. R `` {e} ∈ X // R ⟹ R `` {e} ⊆ R `` {φ g (φ (inv⇘G⇙ g) e)}"
proof (rule subsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ∈ (?B::?'a set)) ⟹ ?A ⊆ ?B›*))
(*goal: ‹⋀e x. ⟦R `` {e} ∈ X // R; x ∈ R `` {e}⟧ ⟹ x ∈ R `` {φ g (φ (inv⇘G⇙ g) e)}›*)
fix e and y
assume A3_0: "R `` {e} ∈ X // R" and A3_1: "y ∈ R `` {e}" (*‹(R::('X × 'X) set) `` {e::'X} ∈ X // R› ‹(y::'X) ∈ (R::('X × 'X) set) `` {e::'X}›*)
have H3_0: "y ∈ X"
using A3_1 (*‹(y::'X) ∈ (R::('X × 'X) set) `` {e::'X}›*) is_subrel (*‹R ⊆ X × X›*) by blast
from H_0 (*‹group_action (G::('grp, 'b) monoid_scheme) X (φ::'grp ⇒ 'X ⇒ 'X)›*) have H3_1: "φ g (φ (inv⇘G⇙ g) y) = y"
by (metis (no_types, lifting) A1_0 (*‹Group.group G›*) A1_4 (*‹g ∈ carrier G›*) H3_0 (*‹y ∈ X›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group.inv_inv (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ (inv⇘?G⇙ ?x) = ?x›*) group_action.orbit_sym_aux (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?φ (inv⇘?G⇙ ?g) ?y = ?x›*))
from A3_1 (*‹y ∈ R `` {e}›*) have H3_2: "(e, y) ∈ R"
by simp
hence H3_3: "((φ (inv⇘G⇙ g) e), (φ (inv⇘G⇙ g) y)) ∈ R"
using is_eq_var_rel (*‹(?a, ?b) ∈ R ⟹ ∀g∈carrier G. (g ⊙⇘φ⇙ ?a, g ⊙⇘φ⇙ ?b) ∈ R›*) A1_4 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A1_0 (*‹Group.group (G::('grp, 'b) monoid_scheme)›*) by simp
hence H3_4: "(φ g (φ (inv⇘G⇙ g) e), φ g (φ (inv⇘G⇙ g) y)) ∈ R"
using is_eq_var_rel (*‹(?a, ?b) ∈ R ⟹ ∀g∈carrier G. (g ⊙⇘φ⇙ ?a, g ⊙⇘φ⇙ ?b) ∈ R›*) A1_4 (*‹g ∈ carrier G›*) A1_0 (*‹Group.group G›*) by simp
hence H3_5: "(φ g (φ (inv⇘G⇙ g) e), y) ∈ R"
using H3_1 (*‹φ g (φ (inv⇘G⇙ g) y) = y›*) by simp
thus "y ∈ R `` {φ g (φ (inv⇘G⇙ g) e)}"
by simp
qed
hence H2_1: "⋀e. R `` {e} ∈ X // R ⟹ R `` {e} = R `` {φ g (φ (inv⇘G⇙ g) e)}"
by (metis A_0 (*‹equiv X R›*) proj_def (*‹BNF_Greatest_Fixpoint.proj ?r ?x = ?r `` {?x}›*) proj_in_iff (*‹equiv ?A ?r ⟹ (BNF_Greatest_Fixpoint.proj ?r ?x ∈ ?A // ?r) = (?x ∈ ?A)›*) equiv_class_eq_iff (*‹equiv ?A ?r ⟹ ((?x, ?y) ∈ ?r) = (?r `` {?x} = ?r `` {?y} ∧ ?x ∈ ?A ∧ ?y ∈ ?A)›*) subset_equiv_class (*‹⟦equiv ?A ?r; ?r `` {?b} ⊆ ?r `` {?a}; ?b ∈ ?A⟧ ⟹ (?a, ?b) ∈ ?r›*))
have H2_2: "⋀e f. R `` {e} ∈ X // R ⟹ R `` {f} ∈ X // R ⟹
R `` {e} = R `` {f} ⟹ ∀f'∈ R `` {f}. R `` {e} = R `` {f'}"
by (metis A_0 (*‹equiv X (R::('X × 'X) set)›*) Image_singleton_iff (*‹((?b::?'a) ∈ (?r::(?'b × ?'a) set) `` {?a::?'b}) = ((?a, ?b) ∈ ?r)›*) equiv_class_eq (*‹⟦equiv (?A::?'a set) (?r::(?'a × ?'a) set); (?a::?'a, ?b::?'a) ∈ ?r⟧ ⟹ ?r `` {?a} = ?r `` {?b}›*))
have H2_3: "x ∈ X // R ⟹ ∃e∈X. x = R `` {e}"
by (meson quotientE (*‹⟦?X ∈ ?A // ?r; ⋀x. ⟦?X = ?r `` {x}; x ∈ ?A⟧ ⟹ ?P⟧ ⟹ ?P›*))
have H2_4: "⋀e. R `` {e} ∈ X // R ⟹ R `` {e} = R `` {φ g (φ (inv⇘G⇙ g) e)} ∧
(φ (inv⇘G⇙ g) e) ∈ R `` {φ (inv⇘G⇙ g) e}"
by (smt (z3) A_0 (*‹equiv X R›*) A1_0 (*‹Group.group G›*) A1_4 (*‹g ∈ carrier G›*) H_0 (*‹group_action G X φ›*) H2_1 (*‹R `` {?e1} ∈ X // R ⟹ R `` {?e1} = R `` {φ g (φ (inv⇘G⇙ g) ?e1)}›*) Image_singleton_iff (*‹(?b ∈ ?r `` {?a}) = ((?a, ?b) ∈ ?r)›*) equiv_class_eq_iff (*‹equiv ?A ?r ⟹ ((?x, ?y) ∈ ?r) = (?r `` {?x} = ?r `` {?y} ∧ ?x ∈ ?A ∧ ?y ∈ ?A)›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group_action.element_image (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?y ∈ ?E›*) in_quotient_imp_non_empty (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ ?X ≠ {}›*) subset_empty (*‹(?A ⊆ {}) = (?A = {})›*) subset_emptyI (*‹(⋀x. x ∈ ?A ⟹ False) ⟹ ?A ⊆ {}›*))
have H2_5: "⋀e. R `` {e} ∈ X // R ⟹ ∀z∈R `` {φ (inv⇘G⇙ g) e}. (φ (inv⇘G⇙ g) e, z) ∈ R"
by simp
hence H2_6: "⋀e. R `` {e} ∈ X // R ⟹
∀z∈R `` {φ (inv⇘G⇙ g) e}. (φ g (φ (inv⇘G⇙ g) e), φ g z) ∈ R"
using is_eq_var_rel' (*‹(?a, ?b) ∈ R ⟹ ∀g∈carrier G. (φ g ?a, φ g ?b) ∈ R›*) A1_4 (*‹g ∈ carrier G›*) A1_0 (*‹Group.group (G::('grp, 'b) monoid_scheme)›*) by blast
hence H2_7: "⋀e. R `` {e} ∈ X // R ⟹ ∀z∈R `` {φ (inv⇘G⇙ g) e}. (e, φ g z) ∈ R"
using H2_1 (*‹R `` {?e1} ∈ X // R ⟹ R `` {?e1} = R `` {φ g (φ (inv⇘G⇙ g) ?e1)}›*) by blast
hence H2_8: "⋀e. R `` {e} ∈ X // R ⟹ ∀z∈R `` {φ (inv⇘G⇙ g) e}. R `` {e} = R `` {φ g z}"
by (meson A_0 (*‹equiv X (R::('X × 'X) set)›*) equiv_class_eq_iff (*‹equiv (?A::?'a set) (?r::(?'a × ?'a) set) ⟹ ((?x::?'a, ?y::?'a) ∈ ?r) = (?r `` {?x} = ?r `` {?y} ∧ ?x ∈ ?A ∧ ?y ∈ ?A)›*))
have H2_9: "⋀e. R `` {e} ∈ X // R ⟹
R `` {e} = R `` {φ g (SOME z. z ∈ R `` {φ (inv⇘G⇙ g) e})}"
proof (-)
(*goal: ‹⋀e. R `` {e} ∈ X // R ⟹ R `` {e} = R `` {φ g (SOME z. z ∈ R `` {φ (inv⇘G⇙ g) e})}›*)
fix e
assume A3_0: "R `` {e} ∈ X // R" (*‹(R::('X × 'X) set) `` {e::'X} ∈ X // R›*)
show "R `` {e} = R `` {φ g (SOME z. z ∈ R `` {φ (inv⇘G⇙ g) e})}"
apply (rule someI2[where Q = "λz. R `` {e} = R `` {φ g z}" and P = "λz. z ∈ R `` {φ (inv⇘G⇙ g) e}" and a = "φ (inv⇘G⇙ g) e"] (*‹⟦φ (inv⇘G⇙ g) e ∈ R `` {φ (inv⇘G⇙ g) e}; ⋀x. x ∈ R `` {φ (inv⇘G⇙ g) e} ⟹ R `` {e} = R `` {φ g x}⟧ ⟹ R `` {e} = R `` {φ g (SOME x. x ∈ R `` {φ (inv⇘G⇙ g) e})}›*))
(*goal: ‹R `` {e} = R `` {φ g (SOME z. z ∈ R `` {φ (inv⇘G⇙ g) e})}›*)
using A3_0 (*‹R `` {e} ∈ X // R›*) H2_4 (*‹R `` {?e1} ∈ X // R ⟹ R `` {?e1} = R `` {φ g (φ (inv⇘G⇙ g) ?e1)} ∧ φ (inv⇘G⇙ g) ?e1 ∈ R `` {φ (inv⇘G⇙ g) ?e1}›*) apply blast
(*top goal: ‹φ (inv⇘G⇙ g) e ∈ R `` {φ (inv⇘G⇙ g) e}› and 1 goal remains*)
using A3_0 (*‹R `` {e} ∈ X // R›*) H2_8 (*‹(R::('X::type × 'X::type) set) `` {?e1::'X::type} ∈ X // R ⟹ ∀z::'X::type∈R `` {(φ::'grp::type ⇒ 'X::type ⇒ 'X::type) (inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp::type)) ?e1}. R `` {?e1} = R `` {φ g z}›*) by auto
qed
have H2_10: "∀e. (R `` {e} ∈ X // R ⟶
(R `` {e} = R `` {φ g (SOME z. z ∈ R `` {φ (inv⇘G⇙ g) e})}))"
using H2_9 (*‹R `` {?e1} ∈ X // R ⟹ R `` {?e1} = R `` {φ g (SOME z. z ∈ R `` {φ (inv⇘G⇙ g) ?e1})}›*) by auto
hence H2_11: "∀e. (R `` {e} ∈ X // R ⟶
(∃xa∈X // R. R `` {e} = R `` {φ g (SOME z. z ∈ xa)}))"
using H2_8 (*‹R `` {?e1} ∈ X // R ⟹ ∀z∈R `` {φ (inv⇘G⇙ g) ?e1}. R `` {?e1} = R `` {φ g z}›*) apply clarsimp
(*goal: ‹∀e::'X. (R::('X × 'X) set) `` {e} ∈ X // R ⟶ (∃xa::'X set∈X // R. R `` {e} = R `` {(φ::'grp ⇒ 'X ⇒ 'X) (g::'grp) (SOME z::'X. z ∈ xa)})›*)
by (smt (verit, best) A_0 (*‹equiv X R›*) H2_3 (*‹x ∈ X // R ⟹ ∃e∈X. x = R `` {e}›*) H2_5 (*‹R `` {?e1} ∈ X // R ⟹ ∀z∈R `` {φ (inv⇘G⇙ g) ?e1}. (φ (inv⇘G⇙ g) ?e1, z) ∈ R›*) H2_4 (*‹R `` {?e1} ∈ X // R ⟹ R `` {?e1} = R `` {φ g (φ (inv⇘G⇙ g) ?e1)} ∧ φ (inv⇘G⇙ g) ?e1 ∈ R `` {φ (inv⇘G⇙ g) ?e1}›*) equiv_Eps_in (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ (SOME x. x ∈ ?X) ∈ ?X›*) equiv_class_eq_iff (*‹equiv ?A ?r ⟹ ((?x, ?y) ∈ ?r) = (?r `` {?x} = ?r `` {?y} ∧ ?x ∈ ?A ∧ ?y ∈ ?A)›*) quotientI (*‹?x ∈ ?A ⟹ ?r `` {?x} ∈ ?A // ?r›*))
have H2_12: "⋀x. x ∈ X // R ⟹ ∃e∈X. x = R `` {e} "
by (meson quotientE (*‹⟦?X ∈ ?A // ?r; ⋀x. ⟦?X = ?r `` {x}; x ∈ ?A⟧ ⟹ ?P⟧ ⟹ ?P›*))
have H2_13: "⋀x. x ∈ X // R ⟹ ∃xa∈X // R. x = R `` {φ g (SOME z. z ∈ xa)}"
using H2_11 (*‹∀e::'X::type. (R::('X::type × 'X::type) set) `` {e} ∈ X // R ⟶ (∃xa::'X::type set∈X // R. R `` {e} = R `` {(φ::'grp::type ⇒ 'X::type ⇒ 'X::type) (g::'grp::type) (SOME z::'X::type. z ∈ xa)})›*) H2_12 (*‹?x1 ∈ X // R ⟹ ∃e∈X. ?x1 = R `` {e}›*) by blast
show "∃xa∈X // R. x = R `` {φ g (SOME z. z ∈ xa)}"
by (simp add: A2_0 (*‹x ∈ X // R›*) H2_13 (*‹?x1 ∈ X // R ⟹ ∃xa∈X // R. ?x1 = R `` {φ g (SOME z. z ∈ xa)}›*))
qed
show "(λx∈X // R. R `` {φ g (SOME z. z ∈ x)}) ∈ carrier (BijGroup (X // R))"
apply (clarsimp simp add: BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*))
(*goal: ‹(λx∈X // R. R `` {φ g (SOME z. z ∈ x)}) ∈ carrier (BijGroup (X // R))›*)
apply (clarsimp simp add: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))
(*goal: ‹inj_on (λx::'X set. (R::('X × 'X) set) `` {(φ::'grp ⇒ 'X ⇒ 'X) (g::'grp) (SOME z::'X. z ∈ x)}) (X // R) ∧ (λx::'X set. R `` {φ g (SOME z::'X. z ∈ x)}) ` X // R = X // R›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹(∀x∈X // R. ∀y∈X // R. R `` {φ g (SOME z. z ∈ x)} = R `` {φ g (SOME z. z ∈ y)} ⟶ x = y) ∧ (λx. R `` {φ g (SOME z. z ∈ x)}) ` X // R = X // R›*)
apply clarsimp
(*top goal: ‹∀x∈X // R. ∀y∈X // R. R `` {φ g (SOME z. z ∈ x)} = R `` {φ g (SOME z. z ∈ y)} ⟶ x = y› and 1 goal remains*)
apply (rule subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*))
(*top goal: ‹⋀x y. ⟦x ∈ X // R; y ∈ X // R; R `` {φ g (SOME z. z ∈ x)} = R `` {φ g (SOME z. z ∈ y)}⟧ ⟹ x = y› and 1 goal remains*)
apply (simp add: H1_0 (*‹⟦?x1 ∈ X // R; ?y1 ∈ X // R; R `` {φ g (SOME z. z ∈ ?x1)} = R `` {φ g (SOME z. z ∈ ?y1)}⟧ ⟹ ?x1 ⊆ ?y1›*))
(*top goal: ‹⋀x y. ⟦x ∈ X // R; y ∈ X // R; R `` {φ g (SOME z. z ∈ x)} = R `` {φ g (SOME z. z ∈ y)}⟧ ⟹ x ⊆ y› and 2 goals remain*)
apply (simp add: ‹⋀y x. ⟦x ∈ X // R;
y ∈ X // R; R `` {φ g (SOME z. z ∈ x)} = R `` {φ g (SOME z. z ∈ y)}⟧ ⟹ x ⊆ y›)
(*top goal: ‹⋀x y. ⟦x ∈ X // R; y ∈ X // R; R `` {φ g (SOME z. z ∈ x)} = R `` {φ g (SOME z. z ∈ y)}⟧ ⟹ y ⊆ x› and 1 goal remains*)
apply (rule subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*); clarify)
(*goal: ‹(λx. R `` {φ g (SOME z. z ∈ x)}) ` X // R = X // R›*)
subgoal for x and y
by (metis A_0 (*‹equiv X R›*) is_eq_var_rel' (*‹(?a, ?b) ∈ R ⟹ ∀g∈carrier G. (φ g ?a, φ g ?b) ∈ R›*) A1_4 (*‹g ∈ carrier G›*) Eps_cong (*‹(⋀x. ?P x = ?Q x) ⟹ Eps ?P = Eps ?Q›*) equiv_Eps_preserves (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ (SOME x. x ∈ ?X) ∈ ?A›*) equiv_class_eq_iff (*‹equiv ?A ?r ⟹ ((?x, ?y) ∈ ?r) = (?r `` {?x} = ?r `` {?y} ∧ ?x ∈ ?A ∧ ?y ∈ ?A)›*) quotientI (*‹?x ∈ ?A ⟹ ?r `` {?x} ∈ ?A // ?r›*))
apply (clarsimp simp add: Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*goal: ‹⋀x. x ∈ X // R ⟹ x ∈ (λx. R `` {φ g (SOME z. z ∈ x)}) ` X // R›*)
by (simp add: H1_1 (*‹(?x1::'X set) ∈ X // (R::('X × 'X) set) ⟹ ∃xa::'X set∈X // R. ?x1 = R `` {(φ::'grp ⇒ 'X ⇒ 'X) (g::'grp) (SOME z::'X. z ∈ xa)}›*))
qed
have H_1: "⋀x y. ⟦Group.group G; Group.group (BijGroup X); R ⊆ X × X;
φ ∈ carrier G → carrier (BijGroup X);
∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y;
x ∈ carrier G; y ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G⟧ ⟹
(λxa∈X // R. R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ xa)}) =
(λxa∈X // R. R `` {φ x (SOME z. z ∈ xa)}) ⊗⇘BijGroup (X // R)⇙
(λx∈X // R. R `` {φ y (SOME z. z ∈ x)})"
proof (-)
(*goal: ‹⋀x y. ⟦Group.group G; Group.group (BijGroup X); R ⊆ X × X; φ ∈ carrier G → carrier (BijGroup X); ∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y; x ∈ carrier G; y ∈ carrier G; x ⊗⇘G⇙ y ∈ carrier G⟧ ⟹ (λxa∈X // R. R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ xa)}) = (λxa∈X // R. R `` {φ x (SOME z. z ∈ xa)}) ⊗⇘BijGroup (X // R)⇙ (λx∈X // R. R `` {φ y (SOME z. z ∈ x)})›*)
fix x and y
assume A1_1: "Group.group G" and A1_2: "Group.group (BijGroup X)" and A1_3: "φ ∈ carrier G → carrier (BijGroup X)" and A1_4: "∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y" and A1_5: "x ∈ carrier G" and A1_6: "y ∈ carrier G" and A1_7: "x ⊗⇘G⇙ y ∈ carrier G" (*‹Group.group (G::('grp, 'b) monoid_scheme)› ‹Group.group (BijGroup X)› ‹(φ::'grp ⇒ 'X ⇒ 'X) ∈ carrier (G::('grp, 'b) monoid_scheme) → carrier (BijGroup X)› ‹∀x::'grp∈carrier (G::('grp, 'b) monoid_scheme). ∀y::'grp∈carrier G. (φ::'grp ⇒ 'X ⇒ 'X) (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y› ‹(x::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹(y::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹(x::'grp) ⊗⇘G::('grp, 'b) monoid_scheme⇙ (y::'grp) ∈ carrier G›*)
have H1_0: "⋀w::'X set. w ∈ X // R ⟹
R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ w)} =
((λv∈X // R. R `` {φ x (SOME z. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙
(λx∈X // R. R `` {φ y (SOME z. z ∈ x)})) w"
proof (-)
(*goal: ‹⋀w. w ∈ X // R ⟹ R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ w)} = ((λv∈X // R. R `` {φ x (SOME z. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙ (λx∈X // R. R `` {φ y (SOME z. z ∈ x)})) w›*)
fix w
assume A2_0: "w ∈ X // R" (*‹(w::'X set) ∈ X // (R::('X × 'X) set)›*)
have H2_4: "φ y ` w ∈ X // R"
using ec_er_closed_under_action[where w = "w" and g = "y"] (*‹⟦equiv X R; y ∈ carrier G; w ∈ X // R⟧ ⟹ φ y ` w ∈ X // R›*) by (clarsimp simp add: group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) A_0 (*‹equiv X R›*) A1_1 (*‹Group.group G›*) A1_2 (*‹Group.group (BijGroup X)›*) is_eq_var_rel' (*‹(?a, ?b) ∈ R ⟹ ∀g∈carrier G. (φ g ?a, φ g ?b) ∈ R›*) A1_3 (*‹φ ∈ carrier G → carrier (BijGroup X)›*) A1_4 (*‹∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y›*) A1_6 (*‹y ∈ carrier G›*) A2_0 (*‹w ∈ X // R›*))
hence H2_1: "R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ w)} =
R `` {φ (x ⊗⇘G⇙ y) (SOME z. z ∈ w)}"
using A1_4 (*‹∀x::'grp::type∈carrier (G::('grp, 'b) monoid_scheme). ∀y::'grp::type∈carrier G. (φ::'grp::type ⇒ 'X::type ⇒ 'X::type) (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y›*) A1_5 (*‹x ∈ carrier G›*) A1_6 (*‹y ∈ carrier G›*) by auto
also (*calculation: ‹R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ w)} = R `` {φ (x ⊗⇘G⇙ y) (SOME z. z ∈ w)}›*) have H2_2: "... = R `` {SOME z. z ∈ φ (x ⊗⇘G⇙ y) ` w}"
using A1_7 (*‹x ⊗⇘G⇙ y ∈ carrier G›*) equiv_equivar_class_some_eq[where w = "w" and g = "x ⊗⇘G⇙ y"] (*‹⟦equiv X R; w ∈ X // R; x ⊗⇘G⇙ y ∈ carrier G⟧ ⟹ ([φ]⇩R) (x ⊗⇘G⇙ y) w = R `` {SOME z'. z' ∈ φ (x ⊗⇘G⇙ y) ` w}›*) by (clarsimp simp add: A1_7 (*‹x ⊗⇘G⇙ y ∈ carrier G›*) A_0 (*‹equiv X R›*) A2_0 (*‹w ∈ X // R›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*))
also (*calculation: ‹R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ w)} = R `` {SOME z. z ∈ φ (x ⊗⇘G⇙ y) ` w}›*) have H2_3: "... = R `` {SOME z. z ∈ φ x ` φ y ` w}"
apply (rule meta_mp[of "¬(∃x. x ∈ w ∧ x ∉ X)"] (*‹⟦∄x. x ∈ w ∧ x ∉ X ⟹ PROP ?Q; ∄x. x ∈ w ∧ x ∉ X⟧ ⟹ PROP ?Q›*))
(*goal: ‹R `` {SOME z. z ∈ φ (x ⊗⇘G⇙ y) ` w} = R `` {SOME z. z ∈ φ x ` φ y ` w}›*)
using A1_1 (*‹Group.group (G::('grp, 'b) monoid_scheme)›*) is_eq_var_rel' (*‹(?a, ?b) ∈ R ⟹ ∀g∈carrier G. (φ g ?a, φ g ?b) ∈ R›*) A1_3 (*‹(φ::'grp ⇒ 'X ⇒ 'X) ∈ carrier (G::('grp, 'b) monoid_scheme) → carrier (BijGroup X)›*) A1_4 (*‹∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y›*) A1_5 (*‹x ∈ carrier G›*) A1_6 (*‹y ∈ carrier G›*) A2_0 (*‹w ∈ X // R›*) apply (clarsimp simp add: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*) Pi_def (*‹Pi ?A ?B = {f. ∀x. x ∈ ?A ⟶ f x ∈ ?B x}›*))
(*top goal: ‹∄x::'X::type. x ∈ (w::'X::type set) ∧ x ∉ X ⟹ (R::('X::type × 'X::type) set) `` {SOME z::'X::type. z ∈ (φ::'grp::type ⇒ 'X::type ⇒ 'X::type) ((x::'grp::type) ⊗⇘G::('grp, 'b) monoid_scheme⇙ (y::'grp::type)) ` w} = R `` {SOME z::'X::type. z ∈ φ x ` φ y ` w}› and 1 goal remains*)
apply (smt (z3) Eps_cong (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x = (?Q::?'a ⇒ bool) x) ⟹ Eps ?P = Eps ?Q›*))
(*top goal: ‹⟦∀x. x ∈ w ⟶ x ∈ X; Group.group G; ∀x. x ∈ carrier G ⟶ φ x ∈ Bij X; ∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = (λxa. if xa ∈ X then φ x (φ y xa) else undefined); x ∈ carrier G; y ∈ carrier G; w ∈ X // R⟧ ⟹ R `` {SOME z. ∃xa∈w. z = φ x (φ y xa)} = R `` {SOME z. ∃xa. (∃x∈w. xa = φ y x) ∧ z = φ x xa}› and 1 goal remains*)
apply clarify
(*goal: ‹∄x. x ∈ w ∧ x ∉ X›*)
using A_0 (*‹equiv X R›*) A2_0 (*‹w ∈ X // R›*) in_quotient_imp_subset (*‹⟦equiv (?A::?'a set) (?r::(?'a × ?'a) set); (?X::?'a set) ∈ ?A // ?r⟧ ⟹ ?X ⊆ ?A›*) by auto
also (*calculation: ‹R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ w)} = R `` {SOME z. z ∈ φ x ` φ y ` w}›*) have H2_5: "... = R `` {φ x (SOME z. z ∈ φ y ` w)}"
using equiv_equivar_class_some_eq[where w = "φ y ` w" and g = "x"] (*‹⟦equiv X R; φ y ` w ∈ X // R; x ∈ carrier G⟧ ⟹ ([φ]⇩R) x (φ y ` w) = R `` {SOME z'. z' ∈ φ x ` φ y ` w}›*) apply (clarsimp simp add: A_0 (*‹equiv X R›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*))
(*goal: ‹R `` {SOME z. z ∈ φ x ` φ y ` w} = R `` {φ x (SOME z. z ∈ φ y ` w)}›*)
by (simp add: A1_1 (*‹Group.group G›*) A1_2 (*‹Group.group (BijGroup X)›*) is_eq_var_rel' (*‹(?a, ?b) ∈ R ⟹ ∀g∈carrier G. (φ g ?a, φ g ?b) ∈ R›*) A1_3 (*‹φ ∈ carrier G → carrier (BijGroup X)›*) A1_4 (*‹∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y›*) A1_5 (*‹x ∈ carrier G›*) H2_4 (*‹φ y ` w ∈ X // R›*))
also (*calculation: ‹R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ w)} = R `` {φ x (SOME z. z ∈ φ y ` w)}›*) have H2_6: "... = R `` {φ x (SOME z. z ∈ R``{(SOME z'. z' ∈ φ y ` w)})}"
using H2_4 (*‹φ y ` w ∈ X // R›*) nested_somes[where w = "φ y ` w" and X = "X" and R = "R"] (*‹⟦equiv X R; φ y ` w ∈ X // R⟧ ⟹ (SOME z. z ∈ φ y ` w) = (SOME z. z ∈ R `` {SOME z'. z' ∈ φ y ` w})›*) A_0 (*‹equiv X R›*) by presburger
also (*calculation: ‹R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ w)} = R `` {φ x (SOME z. z ∈ R `` {SOME z'. z' ∈ φ y ` w})}›*) have H2_7: "... = R `` {φ x (SOME z. z ∈ R `` {φ y (SOME z'. z' ∈ w)})}"
using equiv_equivar_class_some_eq[where g = "y" and w = "w"] (*‹⟦equiv X R; w ∈ X // R; y ∈ carrier G⟧ ⟹ ([φ]⇩R) y w = R `` {SOME z'. z' ∈ φ y ` w}›*) H2_6 (*‹R `` {φ x (SOME z. z ∈ φ y ` w)} = R `` {φ x (SOME z. z ∈ R `` {SOME z'. z' ∈ φ y ` w})}›*) by (simp add: A_0 (*‹equiv X R›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) A1_1 (*‹Group.group G›*) A1_2 (*‹Group.group (BijGroup X)›*) is_eq_var_rel' (*‹(?a, ?b) ∈ R ⟹ ∀g∈carrier G. (φ g ?a, φ g ?b) ∈ R›*) A1_3 (*‹φ ∈ carrier G → carrier (BijGroup X)›*) A1_4 (*‹∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y›*) A2_0 (*‹w ∈ X // R›*) A1_6 (*‹y ∈ carrier G›*))
also (*calculation: ‹(R::('X × 'X) set) `` {((φ::'grp ⇒ 'X ⇒ 'X) (x::'grp) ⊗⇘BijGroup X⇙ φ (y::'grp)) (SOME z::'X. z ∈ (w::'X set))} = R `` {φ x (SOME z::'X. z ∈ R `` {φ y (SOME z'::'X. z' ∈ w)})}›*) have H2_9: "... = ((λv∈X // R. R `` {φ x (SOME z. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙
(λx∈X // R. R `` {φ y (SOME z. z ∈ x)})) w"
proof (-)
(*goal: ‹R `` {φ x (SOME z. z ∈ R `` {φ y (SOME z'. z' ∈ w)})} = ((λv∈X // R. R `` {φ x (SOME z. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙ (λx∈X // R. R `` {φ y (SOME z. z ∈ x)})) w›*)
have H3_0: "⋀u. R `` {φ y (SOME z. z ∈ w)} ∈ X // R ⟹ u ∈ carrier G ⟹
(λv∈X // R. R `` {φ u (SOME z. z ∈ v)}) ∈ Bij (X // R)"
proof (-)
(*goal: ‹⋀u::'grp. ⟦(R::('X × 'X) set) `` {(φ::'grp ⇒ 'X ⇒ 'X) (y::'grp) (SOME z::'X. z ∈ (w::'X set))} ∈ X // R; u ∈ carrier (G::('grp, 'b) monoid_scheme)⟧ ⟹ (λv::'X set∈X // R. R `` {φ u (SOME z::'X. z ∈ v)}) ∈ Bij (X // R)›*)
fix u
assume A4_0: "R `` {φ y (SOME z. z ∈ w)} ∈ X // R" and A4_1: "u ∈ carrier G" (*‹(R::('X × 'X) set) `` {(φ::'grp ⇒ 'X ⇒ 'X) (y::'grp) (SOME z::'X. z ∈ (w::'X set))} ∈ X // R› ‹(u::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*)
have H4_0: "∀g ∈ carrier G.
(λx∈X // R. R `` {φ g (SOME z. z ∈ x)}) ∈ carrier (BijGroup (X // R))"
by (simp add: A_0 (*‹equiv X R›*) A1_1 (*‹Group.group G›*) A1_2 (*‹Group.group (BijGroup X)›*) A1_3 (*‹φ ∈ carrier G → carrier (BijGroup X)›*) A1_4 (*‹∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y›*) H_0 (*‹⟦Group.group G; Group.group (BijGroup X); R ⊆ X × X; φ ∈ carrier G → carrier (BijGroup X); ∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y; ?x1 ∈ carrier G⟧ ⟹ (λxa∈X // R. R `` {φ ?x1 (SOME z. z ∈ xa)}) ∈ carrier (BijGroup (X // R))›*) is_subrel (*‹R ⊆ X × X›*))
thus "(λv∈X // R. R `` {φ u (SOME z. z ∈ v)}) ∈ Bij (X // R)"
by (auto simp add: BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) A4_1 (*‹u ∈ carrier G›*))
qed
have H3_1: "R `` {φ y (SOME z. z ∈ w)} ∈ X // R"
proof (-)
(*goal: ‹R `` {φ y (SOME z. z ∈ w)} ∈ X // R›*)
have H4_0: "φ y ` w ∈ X // R"
using ec_er_closed_under_action (*‹⟦equiv X R; ?g ∈ carrier G; ?w ∈ X // R⟧ ⟹ φ ?g ` ?w ∈ X // R›*) by (simp add: H2_4 (*‹φ y ` w ∈ X // R›*))
hence H4_1: "R `` {(SOME z. z ∈ φ y ` w)} = φ y ` w"
apply (clarsimp simp add: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*goal: ‹(R::('X × 'X) set) `` {SOME z::'X. z ∈ (φ::'grp ⇒ 'X ⇒ 'X) (y::'grp) ` (w::'X set)} = φ y ` w›*)
apply (rule subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*))
(*goal: ‹{ya. ∃x∈w. ya = φ y x} ∈ X // R ⟹ R `` {SOME z. ∃x∈w. z = φ y x} = {ya. ∃x∈w. ya = φ y x}›*)
using A_0 (*‹equiv X R›*) equiv_Eps_in (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ (SOME x. x ∈ ?X) ∈ ?X›*) in_quotient_imp_closed (*‹⟦equiv (?A::?'a::type set) (?r::(?'a::type × ?'a::type) set); (?X::?'a::type set) ∈ ?A // ?r; (?x::?'a::type) ∈ ?X; (?x, ?y::?'a::type) ∈ ?r⟧ ⟹ ?y ∈ ?X›*) apply fastforce
(*top goal: ‹{ya::'X. ∃x::'X∈w::'X set. ya = (φ::'grp ⇒ 'X ⇒ 'X) (y::'grp) x} ∈ X // (R::('X × 'X) set) ⟹ R `` {SOME z::'X. ∃x::'X∈w. z = φ y x} ⊆ {ya::'X. ∃x::'X∈w. ya = φ y x}› and 1 goal remains*)
using A_0 (*‹equiv X R›*) equiv_Eps_in (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ (SOME x. x ∈ ?X) ∈ ?X›*) quotient_eq_iff (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r; ?Y ∈ ?A // ?r; ?x ∈ ?X; ?y ∈ ?Y⟧ ⟹ (?X = ?Y) = ((?x, ?y) ∈ ?r)›*) by fastforce
have H4_2: "R `` {φ y (SOME z. z ∈ w)} = R `` {(SOME z. z ∈ φ y ` w)}"
using equiv_equivar_class_some_eq[where g = "y" and w = "w"] (*‹⟦equiv X R; w ∈ X // R; y ∈ carrier G⟧ ⟹ ([φ]⇩R) y w = R `` {SOME z'. z' ∈ φ y ` w}›*) by (metis A_0 (*‹equiv X R›*) A2_0 (*‹w ∈ X // R›*) H4_0 (*‹φ y ` w ∈ X // R›*) H4_1 (*‹R `` {SOME z. z ∈ φ y ` w} = φ y ` w›*) equiv_Eps_in (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ (SOME x. x ∈ ?X) ∈ ?X›*) imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*) some_equiv_class_id (*‹⟦equiv ?X ?R; ?w ∈ ?X // ?R; ?x ∈ ?w⟧ ⟹ ?R `` {?x} = ?R `` {SOME z. z ∈ ?w}›*))
from H4_0 (*‹φ y ` w ∈ X // R›*) H4_1 (*‹R `` {SOME z. z ∈ φ y ` w} = φ y ` w›*) H4_2 (*‹R `` {φ y (SOME z. z ∈ w)} = R `` {SOME z. z ∈ φ y ` w}›*) show "R `` {φ y (SOME z. z ∈ w)} ∈ X // R"
by auto
qed
show "?thesis"
(*goal: ‹R `` {φ x (SOME z. z ∈ R `` {φ y (SOME z'. z' ∈ w)})} = ((λv∈X // R. R `` {φ x (SOME z. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙ (λx∈X // R. R `` {φ y (SOME z. z ∈ x)})) w›*)
apply (rule meta_mp[of "R `` {φ y (SOME z. z ∈ w)} ∈ X // R"] (*‹⟦R `` {φ y (SOME z. z ∈ w)} ∈ X // R ⟹ PROP ?Q; R `` {φ y (SOME z. z ∈ w)} ∈ X // R⟧ ⟹ PROP ?Q›*))
(*goal: ‹R `` {φ x (SOME z. z ∈ R `` {φ y (SOME z'. z' ∈ w)})} = ((λv∈X // R. R `` {φ x (SOME z. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙ (λx∈X // R. R `` {φ y (SOME z. z ∈ x)})) w›*)
apply (rule meta_mp[of "∀u ∈ carrier G.
(λv∈X // R. R `` {φ u (SOME z. z ∈ v)}) ∈ Bij (X // R)" ] (*‹⟦∀u∈carrier G. (λv∈X // R. R `` {φ u (SOME z. z ∈ v)}) ∈ Bij (X // R) ⟹ PROP ?Q; ∀u∈carrier G. (λv∈X // R. R `` {φ u (SOME z. z ∈ v)}) ∈ Bij (X // R)⟧ ⟹ PROP ?Q›*))
(*top goal: ‹R `` {φ y (SOME z. z ∈ w)} ∈ X // R ⟹ R `` {φ x (SOME z. z ∈ R `` {φ y (SOME z'. z' ∈ w)})} = ((λv∈X // R. R `` {φ x (SOME z. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙ (λx∈X // R. R `` {φ y (SOME z. z ∈ x)})) w› and 1 goal remains*)
using A2_0 (*‹w ∈ X // R›*) A1_5 (*‹(x::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A1_6 (*‹(y::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*)
(*goals:
1. ‹⟦R `` {φ y (SOME z. z ∈ w)} ∈ X // R; ∀u∈carrier G. (λv∈X // R. R `` {φ u (SOME z. z ∈ v)}) ∈ Bij (X // R)⟧ ⟹ R `` {φ x (SOME z. z ∈ R `` {φ y (SOME z'. z' ∈ w)})} = ((λv∈X // R. R `` {φ x (SOME z. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙ (λx∈X // R. R `` {φ y (SOME z. z ∈ x)})) w›
2. ‹R `` {φ y (SOME z. z ∈ w)} ∈ X // R ⟹ ∀u∈carrier G. (λv∈X // R. R `` {φ u (SOME z. z ∈ v)}) ∈ Bij (X // R)›
3. ‹R `` {φ y (SOME z. z ∈ w)} ∈ X // R›
discuss goal 1*)
apply (simp add: BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*))
(*discuss goal 2*)
apply clarify
(*top goal: ‹R `` {φ y (SOME z. z ∈ w)} ∈ X // R ⟹ ∀u∈carrier G. (λv∈X // R. R `` {φ u (SOME z. z ∈ v)}) ∈ Bij (X // R)› and 1 goal remains*)
apply (simp add: H3_0 (*‹⟦R `` {φ y (SOME z. z ∈ w)} ∈ X // R; ?u1 ∈ carrier G⟧ ⟹ (λv∈X // R. R `` {φ ?u1 (SOME z. z ∈ v)}) ∈ Bij (X // R)›*) H3_1 (*‹R `` {φ y (SOME z. z ∈ w)} ∈ X // R›*))
(*discuss goal 3*)
apply (simp add: H3_0 (*‹⟦(R::('X::type × 'X::type) set) `` {(φ::'grp::type ⇒ 'X::type ⇒ 'X::type) (y::'grp::type) (SOME z::'X::type. z ∈ (w::'X::type set))} ∈ X // R; (?u1::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme)⟧ ⟹ (λv::'X::type set∈X // R. R `` {φ ?u1 (SOME z::'X::type. z ∈ v)}) ∈ Bij (X // R)›*) H3_1 (*‹(R::('X::type × 'X::type) set) `` {(φ::'grp::type ⇒ 'X::type ⇒ 'X::type) (y::'grp::type) (SOME z::'X::type. z ∈ (w::'X::type set))} ∈ X // R›*))
(*proven 3 subgoals*) .
qed
finally (*calculation: ‹(R::('X × 'X) set) `` {((φ::'grp ⇒ 'X ⇒ 'X) (x::'grp) ⊗⇘BijGroup X⇙ φ (y::'grp)) (SOME z::'X. z ∈ (w::'X set))} = ((λv::'X set∈X // R. R `` {φ x (SOME z::'X. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙ (λx::'X set∈X // R. R `` {φ y (SOME z::'X. z ∈ x)})) w›*) show "R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ w)} =
((λv∈X // R. R `` {φ x (SOME z. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙
(λx∈X // R. R `` {φ y (SOME z. z ∈ x)})) w"
by simp
qed
have H1_1: "⋀w::'X set. w ∉ X // R ⟹
((λv∈X // R. R `` {φ x (SOME z. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙
(λx∈X // R. R `` {φ y (SOME z. z ∈ x)})) w = undefined"
proof (-)
(*goal: ‹⋀w::'X set. w ∉ X // (R::('X × 'X) set) ⟹ ((λv::'X set∈X // R. R `` {(φ::'grp ⇒ 'X ⇒ 'X) (x::'grp) (SOME z::'X. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙ (λx::'X set∈X // R. R `` {φ (y::'grp) (SOME z::'X. z ∈ x)})) w = undefined›*)
fix w
assume A2_0: "w ∉ X // R" (*‹(w::'X set) ∉ X // (R::('X × 'X) set)›*)
have H2_0: "⋀u. u∈ carrier G ⟹ (λv∈X // R. R `` {φ u (SOME z. z ∈ v)}) ∈ Bij (X // R)"
using H_0 (*‹⟦Group.group G; Group.group (BijGroup X); R ⊆ X × X; φ ∈ carrier G → carrier (BijGroup X); ∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y; ?x1 ∈ carrier G⟧ ⟹ (λxa∈X // R. R `` {φ ?x1 (SOME z. z ∈ xa)}) ∈ carrier (BijGroup (X // R))›*) apply (clarsimp simp add: A_0 (*‹equiv X R›*) A1_1 (*‹Group.group G›*) A1_2 (*‹Group.group (BijGroup X)›*) is_eq_var_rel' (*‹(?a, ?b) ∈ R ⟹ ∀g∈carrier G. (φ g ?a, φ g ?b) ∈ R›*) A1_3 (*‹φ ∈ carrier G → carrier (BijGroup X)›*) A1_4 (*‹∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y›*) is_subrel (*‹R ⊆ X × X›*))
(*goal: ‹⋀u. u ∈ carrier G ⟹ (λv∈X // R. R `` {φ u (SOME z. z ∈ v)}) ∈ Bij (X // R)›*)
by (simp add: BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*))
hence H2_1: "(λx'∈X // R. R `` {φ y (SOME z. z ∈ x')}) ∈ Bij (X // R)"
using A1_6 (*‹y ∈ carrier G›*) by auto
from H2_0 (*‹?u1 ∈ carrier G ⟹ (λv∈X // R. R `` {φ ?u1 (SOME z. z ∈ v)}) ∈ Bij (X // R)›*) have H2_2: "(λx'∈X // R. R `` {φ x (SOME z. z ∈ x')}) ∈ Bij (X // R)"
by (simp add: A1_5 (*‹x ∈ carrier G›*))
thus "((λv∈X // R. R `` {φ x (SOME z. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙
(λx∈X // R. R `` {φ y (SOME z. z ∈ x)})) w = undefined"
using H2_1 (*‹(λx'∈X // R. R `` {φ y (SOME z. z ∈ x')}) ∈ Bij (X // R)›*) H2_2 (*‹(λx'::'X set∈X // R. (R::('X × 'X) set) `` {(φ::'grp ⇒ 'X ⇒ 'X) (x::'grp) (SOME z::'X. z ∈ x')}) ∈ Bij (X // R)›*) by (auto simp add: BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*) A2_0 (*‹w ∉ X // R›*))
qed
from H1_0 (*‹(?w1::'X set) ∈ X // (R::('X × 'X) set) ⟹ R `` {((φ::'grp ⇒ 'X ⇒ 'X) (x::'grp) ⊗⇘BijGroup X⇙ φ (y::'grp)) (SOME z::'X. z ∈ ?w1)} = ((λv::'X set∈X // R. R `` {φ x (SOME z::'X. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙ (λx::'X set∈X // R. R `` {φ y (SOME z::'X. z ∈ x)})) ?w1›*) H1_1 (*‹?w1 ∉ X // R ⟹ ((λv∈X // R. R `` {φ x (SOME z. z ∈ v)}) ⊗⇘BijGroup (X // R)⇙ (λx∈X // R. R `` {φ y (SOME z. z ∈ x)})) ?w1 = undefined›*) have "⋀w. (λxa∈X // R. R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ xa)}) w =
((λxa∈X // R. R `` {φ x (SOME z. z ∈ xa)}) ⊗⇘BijGroup (X // R)⇙
(λx'∈X // R. R `` {φ y (SOME z. z ∈ x')})) w"
by auto
thus "(λxa∈X // R. R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ xa)}) =
(λxa∈X // R. R `` {φ x (SOME z. z ∈ xa)}) ⊗⇘BijGroup (X // R)⇙
(λx∈X // R. R `` {φ y (SOME z. z ∈ x)})"
by (simp add: restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*))
qed
show "?thesis"
(*goal: ‹alt_grp_act G (X // R) ([φ]⇩R)›*)
apply (clarsimp simp add: group_action_def (*‹group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c::type set) (?φ::?'a::type ⇒ ?'c::type ⇒ ?'c::type) ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a::type ⇒ ?'c::type) ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*))
(*goal: ‹alt_grp_act G (X // R) ([φ]⇩R)›*)
using eq_var_rel_axioms (*‹eq_var_rel G X φ R›*) apply (clarsimp simp add: eq_var_rel_def (*‹eq_var_rel ?G ?X ?φ ?R ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_rel_axioms ?G ?X ?φ ?R›*) eq_var_rel_axioms_def (*‹eq_var_rel_axioms ?G ?X ?φ ?R ≡ ?R ⊆ ?X × ?X ∧ (∀a b. (a, b) ∈ ?R ⟶ (∀g∈carrier ?G. (g ⊙⇘?φ⇙ a, g ⊙⇘?φ⇙ b) ∈ ?R))›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*))
(*goal: ‹Group.group G ∧ Group.group (BijGroup (X // R)) ∧ group_hom_axioms G (BijGroup (X // R)) (λg∈carrier G. λx∈X // R. R `` {φ g (SOME z. z ∈ x)})›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⟦Group.group G; Group.group (BijGroup X); group_hom_axioms G (BijGroup X) φ; R ⊆ X × X⟧ ⟹ Group.group (BijGroup (X // R))›
2. ‹⟦Group.group G; Group.group (BijGroup X); group_hom_axioms G (BijGroup X) φ; R ⊆ X × X⟧ ⟹ group_hom_axioms G (BijGroup (X // R)) (λg∈carrier G. λx∈X // R. R `` {φ g (SOME z. z ∈ x)})›
discuss goal 1*)
apply (simp add: group_BijGroup (*‹Group.group (BijGroup ?S)›*))
(*discuss goal 2*)
apply (clarsimp simp add: group_hom_axioms_def (*‹group_hom_axioms (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom (?G::(?'a, ?'c) monoid_scheme) (?H::(?'b, ?'d) monoid_scheme) = {h::?'a ⇒ ?'b ∈ carrier ?G → carrier ?H. ∀x::?'a∈carrier ?G. ∀y::?'a∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*))
(*goal: ‹⟦Group.group (G::('grp, 'b) monoid_scheme); Group.group (BijGroup X); group_hom_axioms G (BijGroup X) (φ::'grp ⇒ 'X ⇒ 'X); (R::('X × 'X) set) ⊆ X × X⟧ ⟹ group_hom_axioms G (BijGroup (X // R)) (λg::'grp∈carrier G. λx::'X set∈X // R. R `` {φ g (SOME z::'X. z ∈ x)})›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⟦Group.group (G::('grp, 'b) monoid_scheme); Group.group (BijGroup X); (R::('X × 'X) set) ⊆ X × X; (φ::'grp ⇒ 'X ⇒ 'X) ∈ carrier G → carrier (BijGroup X); ∀x::'grp∈carrier G. ∀y::'grp∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y⟧ ⟹ (λg::'grp∈carrier G. λx::'X set∈X // R. R `` {φ g (SOME z::'X. z ∈ x)}) ∈ carrier G → carrier (BijGroup (X // R))›
2. ‹⟦Group.group (G::('grp, 'b) monoid_scheme); Group.group (BijGroup X); (R::('X × 'X) set) ⊆ X × X; (φ::'grp ⇒ 'X ⇒ 'X) ∈ carrier G → carrier (BijGroup X); ∀x::'grp∈carrier G. ∀y::'grp∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y⟧ ⟹ ∀x::'grp∈carrier G. ∀y::'grp∈carrier G. (x ⊗⇘G⇙ y ∈ carrier G ⟶ (λxa::'X set∈X // R. R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z::'X. z ∈ xa)}) = (λxa::'X set∈X // R. R `` {φ x (SOME z::'X. z ∈ xa)}) ⊗⇘BijGroup (X // R)⇙ (λx::'X set∈X // R. R `` {φ y (SOME z::'X. z ∈ x)})) ∧ (x ⊗⇘G⇙ y ∉ carrier G ⟶ undefined = (λxa::'X set∈X // R. R `` {φ x (SOME z::'X. z ∈ xa)}) ⊗⇘BijGroup (X // R)⇙ (λx::'X set∈X // R. R `` {φ y (SOME z::'X. z ∈ x)}))›
discuss goal 1*)
apply (rule funcsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ (?f::?'a ⇒ ?'b) x ∈ (?B::?'b set)) ⟹ ?f ∈ ?A → ?B›*))
(*top goal: ‹⟦Group.group G; Group.group (BijGroup X); R ⊆ X × X; φ ∈ carrier G → carrier (BijGroup X); ∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y⟧ ⟹ (λg∈carrier G. λx∈X // R. R `` {φ g (SOME z. z ∈ x)}) ∈ carrier G → carrier (BijGroup (X // R))› and 1 goal remains*)
apply simp
(*top goal: ‹⋀x. ⟦Group.group G; Group.group (BijGroup X); R ⊆ X × X; φ ∈ carrier G → carrier (BijGroup X); ∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y; x ∈ carrier G⟧ ⟹ (λg∈carrier G. λx∈X // R. R `` {φ g (SOME z. z ∈ x)}) x ∈ carrier (BijGroup (X // R))› and 1 goal remains*)
apply (simp add: H_0 (*‹⟦Group.group (G::('grp, 'b) monoid_scheme); Group.group (BijGroup X); (R::('X × 'X) set) ⊆ X × X; (φ::'grp ⇒ 'X ⇒ 'X) ∈ carrier G → carrier (BijGroup X); ∀x::'grp∈carrier G. ∀y::'grp∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y; (?x1::'grp) ∈ carrier G⟧ ⟹ (λxa::'X set∈X // R. R `` {φ ?x1 (SOME z::'X. z ∈ xa)}) ∈ carrier (BijGroup (X // R))›*))
(*discuss goal 2*)
apply clarify
(*goal: ‹⟦Group.group G; Group.group (BijGroup X); R ⊆ X × X; φ ∈ carrier G → carrier (BijGroup X); ∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y⟧ ⟹ ∀x∈carrier G. ∀y∈carrier G. (x ⊗⇘G⇙ y ∈ carrier G ⟶ (λxa∈X // R. R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ xa)}) = (λxa∈X // R. R `` {φ x (SOME z. z ∈ xa)}) ⊗⇘BijGroup (X // R)⇙ (λx∈X // R. R `` {φ y (SOME z. z ∈ x)})) ∧ (x ⊗⇘G⇙ y ∉ carrier G ⟶ undefined = (λxa∈X // R. R `` {φ x (SOME z. z ∈ xa)}) ⊗⇘BijGroup (X // R)⇙ (λx∈X // R. R `` {φ y (SOME z. z ∈ x)}))›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⋀x y. ⟦Group.group G; Group.group (BijGroup X); R ⊆ X × X; φ ∈ carrier G → carrier (BijGroup X); ∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y; x ∈ carrier G; y ∈ carrier G⟧ ⟹ x ⊗⇘G⇙ y ∈ carrier G ⟶ (λxa∈X // R. R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z. z ∈ xa)}) = (λxa∈X // R. R `` {φ x (SOME z. z ∈ xa)}) ⊗⇘BijGroup (X // R)⇙ (λx∈X // R. R `` {φ y (SOME z. z ∈ x)})›
2. ‹⋀x y. ⟦Group.group G; Group.group (BijGroup X); R ⊆ X × X; φ ∈ carrier G → carrier (BijGroup X); ∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y; x ∈ carrier G; y ∈ carrier G⟧ ⟹ x ⊗⇘G⇙ y ∉ carrier G ⟶ undefined = (λxa∈X // R. R `` {φ x (SOME z. z ∈ xa)}) ⊗⇘BijGroup (X // R)⇙ (λx∈X // R. R `` {φ y (SOME z. z ∈ x)})›
discuss goal 1*)
apply (intro impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*top goal: ‹⋀(x::'grp::type) y::'grp::type. ⟦Group.group (G::('grp, 'b) monoid_scheme); Group.group (BijGroup X); (R::('X::type × 'X::type) set) ⊆ X × X; (φ::'grp::type ⇒ 'X::type ⇒ 'X::type) ∈ carrier G → carrier (BijGroup X); ∀x::'grp::type∈carrier G. ∀y::'grp::type∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y; x ∈ carrier G; y ∈ carrier G⟧ ⟹ x ⊗⇘G⇙ y ∈ carrier G ⟶ (λxa::'X::type set∈X // R. R `` {(φ x ⊗⇘BijGroup X⇙ φ y) (SOME z::'X::type. z ∈ xa)}) = (λxa::'X::type set∈X // R. R `` {φ x (SOME z::'X::type. z ∈ xa)}) ⊗⇘BijGroup (X // R)⇙ (λx::'X::type set∈X // R. R `` {φ y (SOME z::'X::type. z ∈ x)})› and 1 goal remains*)
apply (simp add: H_1 (*‹⟦Group.group (G::('grp, 'b) monoid_scheme); Group.group (BijGroup X); (R::('X × 'X) set) ⊆ X × X; (φ::'grp ⇒ 'X ⇒ 'X) ∈ carrier G → carrier (BijGroup X); ∀x::'grp∈carrier G. ∀y::'grp∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y; (?x1::'grp) ∈ carrier G; (?y1::'grp) ∈ carrier G; ?x1 ⊗⇘G⇙ ?y1 ∈ carrier G⟧ ⟹ (λxa::'X set∈X // R. R `` {(φ ?x1 ⊗⇘BijGroup X⇙ φ ?y1) (SOME z::'X. z ∈ xa)}) = (λxa::'X set∈X // R. R `` {φ ?x1 (SOME z::'X. z ∈ xa)}) ⊗⇘BijGroup (X // R)⇙ (λx::'X set∈X // R. R `` {φ ?y1 (SOME z::'X. z ∈ x)})›*))
(*discuss goal 2*)
apply (intro impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀x y. ⟦Group.group G; Group.group (BijGroup X); R ⊆ X × X; φ ∈ carrier G → carrier (BijGroup X); ∀x∈carrier G. ∀y∈carrier G. φ (x ⊗⇘G⇙ y) = φ x ⊗⇘BijGroup X⇙ φ y; x ∈ carrier G; y ∈ carrier G⟧ ⟹ x ⊗⇘G⇙ y ∉ carrier G ⟶ undefined = (λxa∈X // R. R `` {φ x (SOME z. z ∈ xa)}) ⊗⇘BijGroup (X // R)⇙ (λx∈X // R. R `` {φ y (SOME z. z ∈ x)})›*)
apply (auto simp add: group.is_monoid (*‹Group.group ?G ⟹ Group.monoid ?G›*) monoid.m_closed (*‹⟦Group.monoid ?G; ?x ∈ carrier ?G; ?y ∈ carrier ?G⟧ ⟹ ?x ⊗⇘?G⇙ ?y ∈ carrier ?G›*))
(*proven 2 subgoals*)
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
qed
end
locale eq_var_func = GA_0: alt_grp_act G X φ + GA_1: alt_grp_act G Y ψ
for
G :: "('grp, 'b) monoid_scheme" and
X :: "'X set" and
φ and
Y :: "'Y set" and
ψ +
fixes
f :: "'X ⇒ 'Y"
assumes
is_ext_func_bet:
"f ∈ (X →⇩E Y)" and
is_eq_var_func:
"⋀a g. a ∈ X ⟹ g ∈ carrier G ⟹ f (g ⊙⇘φ⇙ a) = g ⊙⇘ψ⇙ (f a)"
begin
lemma is_eq_var_func' [simp]:
"a ∈ X ⟹ g ∈ carrier G ⟹ f (φ g a) = ψ g (f a)"
using is_eq_var_func (*‹⟦?a ∈ X; ?g ∈ carrier G⟧ ⟹ f (?g ⊙⇘φ⇙ ?a) = ?g ⊙⇘ψ⇙ f ?a›*) by auto
end
lemma G_set_equiv:
"alt_grp_act G A φ ⟹ eq_var_subset G A φ A"
by (auto simp add: eq_var_subset_def (*‹eq_var_subset (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'X set) ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'X set) ≡ ?Y ⊆ ?X ∧ (∀g::?'grp∈carrier ?G. ?φ g ` ?Y = ?Y)›*) group_action_def (*‹group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c set) (?φ::?'a ⇒ ?'c ⇒ ?'c) ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom (?G::(?'a, ?'c) monoid_scheme) (?H::(?'b, ?'d) monoid_scheme) = {h::?'a ⇒ ?'b ∈ carrier ?G → carrier ?H. ∀x::?'a∈carrier ?G. ∀y::?'a∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) BijGroup_def (*‹BijGroup (?S::?'a set) = ⦇carrier = Bij ?S, mult = λg::?'a ⇒ ?'a∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx::?'a∈?S. x⦈›*) Bij_def (*‹Bij (?S::?'a set) = extensional ?S ∩ {f::?'a ⇒ ?'a. bij_betw f ?S ?S}›*) bij_betw_def (*‹bij_betw (?f::?'a ⇒ ?'b) (?A::?'a set) (?B::?'b set) = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*))
subsection ‹
Basic ($G$)-Automata Theory
›
locale language =
fixes A :: "'alpha set" and
L
assumes
is_lang: "L ⊆ A⇧⋆"
locale G_lang = alt_grp_act G A φ + language A L
for
G :: "('grp, 'b) monoid_scheme" and
A :: "'alpha set" (structure) and
φ L +
assumes
L_is_equivar:
"eq_var_subset G (A⇧⋆) (induced_star_map φ) L"
begin
lemma G_lang_is_lang[simp]: "language A L"
by (simp add: language_axioms (*‹language A L›*))
end
sublocale G_lang ⊆ language
by simp
fun give_input :: "('state ⇒ 'alpha ⇒ 'state) ⇒ 'state ⇒ 'alpha list ⇒ 'state"
where "give_input trans_func s Nil = s"
| "give_input trans_func s (a#as) = give_input trans_func (trans_func s a) as"
adhoc_overloading
star give_input
locale det_aut =
fixes
labels :: "'alpha set" and
states :: "'state set" and
init_state :: "'state" and
fin_states :: "'state set" and
trans_func :: "'state ⇒ 'alpha ⇒ 'state" ("δ")
assumes
init_state_is_a_state:
"init_state ∈ states" and
fin_states_are_states:
"fin_states ⊆ states" and
trans_func_ext:
"(λ(state, label). trans_func state label) ∈ (states × labels) →⇩E states"
begin
lemma trans_func_well_def:
"⋀state label. state ∈ states ⟹ label ∈ labels ⟹ (δ state label) ∈ states"
using trans_func_ext (*‹(λ(state, label). δ state label) ∈ states × labels →⇩E states›*) by auto
lemma give_input_closed:
"input ∈ (labels⇧⋆) ⟹ s ∈ states ⟹ (δ⇧⋆) s input ∈ states"
apply (induction input arbitrary: s)
(*goals:
1. ‹⋀s. ⟦[] ∈ labels⇧⋆; s ∈ states⟧ ⟹ (δ⇧⋆) s [] ∈ states›
2. ‹⋀a input s. ⟦⋀s. ⟦input ∈ labels⇧⋆; s ∈ states⟧ ⟹ (δ⇧⋆) s input ∈ states; a # input ∈ labels⇧⋆; s ∈ states⟧ ⟹ (δ⇧⋆) s (a # input) ∈ states›
discuss goal 1*)
apply ((auto simp add: trans_func_well_def (*‹⟦?state ∈ states; ?label ∈ labels⟧ ⟹ δ ?state ?label ∈ states›*))[1])
(*discuss goal 2*)
apply ((auto simp add: trans_func_well_def (*‹⟦?state ∈ states; ?label ∈ labels⟧ ⟹ δ ?state ?label ∈ states›*))[1])
(*proven 2 subgoals*) .
lemma input_under_concat:
"w ∈ labels⇧⋆ ⟹ v ∈ labels⇧⋆ ⟹ (δ⇧⋆) s (w @ v) = (δ⇧⋆) ((δ⇧⋆) s w) v"
apply (induction w arbitrary: s)
(*goals:
1. ‹⋀s::'state::type. ⟦[] ∈ (labels::'alpha::type set)⇧⋆; (v::'alpha::type list) ∈ labels⇧⋆⟧ ⟹ (δ⇧⋆) s ([] @ v) = (δ⇧⋆) ((δ⇧⋆) s []) v›
2. ‹⋀(a::'alpha::type) (w::'alpha::type list) s::'state::type. ⟦⋀s::'state::type. ⟦w ∈ (labels::'alpha::type set)⇧⋆; (v::'alpha::type list) ∈ labels⇧⋆⟧ ⟹ (δ⇧⋆) s (w @ v) = (δ⇧⋆) ((δ⇧⋆) s w) v; a # w ∈ labels⇧⋆; v ∈ labels⇧⋆⟧ ⟹ (δ⇧⋆) s ((a # w) @ v) = (δ⇧⋆) ((δ⇧⋆) s (a # w)) v›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
lemma eq_pres_under_concat:
assumes
"w ∈ labels⇧⋆" and
"w' ∈ labels⇧⋆" and
"s ∈ states" and
"(δ⇧⋆) s w = (δ⇧⋆) s w'"
shows "∀v ∈ labels⇧⋆. (δ⇧⋆) s (w @ v) = (δ⇧⋆) s (w' @ v)"
using input_under_concat[where w = w and s = s] (*‹⟦w ∈ labels⇧⋆; ?v ∈ labels⇧⋆⟧ ⟹ (δ⇧⋆) s (w @ ?v) = (δ⇧⋆) ((δ⇧⋆) s w) ?v›*) input_under_concat[where w = w' and s = s] (*‹⟦w' ∈ labels⇧⋆; ?v ∈ labels⇧⋆⟧ ⟹ (δ⇧⋆) s (w' @ ?v) = (δ⇧⋆) ((δ⇧⋆) s w') ?v›*) assms (*‹w ∈ labels⇧⋆› ‹w' ∈ labels⇧⋆› ‹s ∈ states› ‹(δ⇧⋆) (s::'state) (w::'alpha list) = (δ⇧⋆) s (w'::'alpha list)›*) by auto
lemma trans_to_charact:
"⋀s a w. ⟦s ∈ states; a ∈ labels; w ∈ labels⇧⋆; s = (δ⇧⋆) i w⟧ ⟹ (δ⇧⋆) i (w @ [a]) = δ s a"
proof (-)
(*goal: ‹⋀(s::'state::type) (a::'alpha::type) w::'alpha::type list. ⟦s ∈ (states::'state::type set); a ∈ (labels::'alpha::type set); w ∈ labels⇧⋆; s = (δ⇧⋆) (i::'state::type) w⟧ ⟹ (δ⇧⋆) i (w @ [a]) = δ s a›*)
fix s and a and w
assume A_0: "s ∈ states" and A_1: "a ∈ labels" and A_2: "w ∈ labels⇧⋆" and A_3: "s = (δ⇧⋆) i w" (*‹(s::'state) ∈ (states::'state set)› ‹(a::'alpha) ∈ (labels::'alpha set)› ‹(w::'alpha list) ∈ (labels::'alpha set)⇧⋆› ‹(s::'state) = (δ⇧⋆) (i::'state) (w::'alpha list)›*)
have H_0: "trans_func s a = (δ⇧⋆) s [a]"
by auto
from A_2 (*‹w ∈ labels⇧⋆›*) A_3 (*‹s = (δ⇧⋆) i w›*) H_0 (*‹δ s a = (δ⇧⋆) s [a]›*) have H_1: "(δ⇧⋆) s [a] = (δ⇧⋆) ((δ⇧⋆) i w) [a]"
by simp
from A_1 (*‹a ∈ labels›*) A_2 (*‹w ∈ labels⇧⋆›*) have H_2: "(δ⇧⋆) ((δ⇧⋆) i w) [a] = (δ⇧⋆) i (w @ [a])"
using input_under_concat (*‹⟦(?w::'alpha::type list) ∈ (labels::'alpha::type set)⇧⋆; (?v::'alpha::type list) ∈ labels⇧⋆⟧ ⟹ (δ⇧⋆) (?s::'state::type) (?w @ ?v) = (δ⇧⋆) ((δ⇧⋆) ?s ?w) ?v›*) by force
show "(δ⇧⋆) i (w @ [a]) = δ s a"
using A_1 (*‹a ∈ labels›*) H_0 (*‹δ s a = (δ⇧⋆) s [a]›*) A_3 (*‹s = (δ⇧⋆) i w›*) H_1 (*‹(δ⇧⋆) (s::'state) [a::'alpha] = (δ⇧⋆) ((δ⇧⋆) (i::'state) (w::'alpha list)) [a]›*) H_2 (*‹(δ⇧⋆) ((δ⇧⋆) (i::'state) (w::'alpha list)) [a::'alpha] = (δ⇧⋆) i (w @ [a])›*) by force
qed
end
locale aut_hom = Aut0: det_aut A S₀ i₀ F₀ δ₀ + Aut1: det_aut A S₁ i₁ F₁ δ₁ for
A :: "'alpha set" and
S₀ :: "'states_0 set" and
i₀ and F₀ and δ₀ and
S₁ :: "'states_1 set" and
i₁ and F₁ and δ₁ +
fixes f :: "'states_0 ⇒ 'states_1"
assumes
hom_is_ext:
"f ∈ S₀ →⇩E S₁" and
pres_init:
"f i₀ = i₁" and
pres_final:
"s ∈ F₀ ⟷ f s ∈ F₁ ∧ s ∈ S₀" and
pres_trans:
"s₀ ∈ S₀ ⟹ a ∈ A ⟹ f (δ₀ s₀ a) = δ₁ (f s₀) a"
begin
lemma hom_translation:
"input ∈ (A⇧⋆) ⟹ s ∈ S₀ ⟹ (f ((δ₀⇧⋆) s input)) = ((δ₁⇧⋆) (f s) input)"
apply (induction input arbitrary: s)
(*goals:
1. ‹⋀s::'states_0. ⟦[] ∈ (A::'alpha set)⇧⋆; s ∈ (S₀::'states_0 set)⟧ ⟹ (f::'states_0 ⇒ 'states_1) (((δ₀::'states_0 ⇒ 'alpha ⇒ 'states_0)⇧⋆) s []) = ((δ₁::'states_1 ⇒ 'alpha ⇒ 'states_1)⇧⋆) (f s) []›
2. ‹⋀(a::'alpha) (input::'alpha list) s::'states_0. ⟦⋀s::'states_0. ⟦input ∈ (A::'alpha set)⇧⋆; s ∈ (S₀::'states_0 set)⟧ ⟹ (f::'states_0 ⇒ 'states_1) (((δ₀::'states_0 ⇒ 'alpha ⇒ 'states_0)⇧⋆) s input) = ((δ₁::'states_1 ⇒ 'alpha ⇒ 'states_1)⇧⋆) (f s) input; a # input ∈ A⇧⋆; s ∈ S₀⟧ ⟹ f ((δ₀⇧⋆) s (a # input)) = (δ₁⇧⋆) (f s) (a # input)›
discuss goal 1*)
apply ((auto simp add: Aut0.trans_func_well_def (*‹⟦?state ∈ S₀; ?label ∈ A⟧ ⟹ δ₀ ?state ?label ∈ S₀›*) pres_trans (*‹⟦?s₀ ∈ S₀; ?a ∈ A⟧ ⟹ f (δ₀ ?s₀ ?a) = δ₁ (f ?s₀) ?a›*))[1])
(*discuss goal 2*)
apply ((auto simp add: Aut0.trans_func_well_def (*‹⟦?state ∈ S₀; ?label ∈ A⟧ ⟹ δ₀ ?state ?label ∈ S₀›*) pres_trans (*‹⟦?s₀ ∈ S₀; ?a ∈ A⟧ ⟹ f (δ₀ ?s₀ ?a) = δ₁ (f ?s₀) ?a›*))[1])
(*proven 2 subgoals*) .
lemma recognise_same_lang:
"input ∈ A⇧⋆ ⟹ ((δ₀⇧⋆) i₀ input) ∈ F₀ ⟷ ((δ₁⇧⋆) i₁ input) ∈ F₁"
using hom_translation[where input = input and s = i₀] (*‹⟦(input::'alpha list) ∈ (A::'alpha set)⇧⋆; (i₀::'states_0) ∈ (S₀::'states_0 set)⟧ ⟹ (f::'states_0 ⇒ 'states_1) (((δ₀::'states_0 ⇒ 'alpha ⇒ 'states_0)⇧⋆) i₀ input) = ((δ₁::'states_1 ⇒ 'alpha ⇒ 'states_1)⇧⋆) (f i₀) input›*) apply (clarsimp simp add: Aut0.init_state_is_a_state (*‹i₀ ∈ S₀›*) pres_init (*‹f i₀ = i₁›*) pres_final (*‹(?s ∈ F₀) = (f ?s ∈ F₁ ∧ ?s ∈ S₀)›*))
(*goal: ‹input ∈ A⇧⋆ ⟹ ((δ₀⇧⋆) i₀ input ∈ F₀) = ((δ₁⇧⋆) i₁ input ∈ F₁)›*)
apply (induction input)
(*goal: ‹⟦f ((δ₀⇧⋆) i₀ input) = (δ₁⇧⋆) i₁ input; ∀x∈set input. x ∈ A⟧ ⟹ ((δ₁⇧⋆) i₁ input ∈ F₁ ∧ (δ₀⇧⋆) i₀ input ∈ S₀) = ((δ₁⇧⋆) i₁ input ∈ F₁)›*)
apply (clarsimp simp add: Aut0.init_state_is_a_state (*‹(i₀::'states_0::type) ∈ (S₀::'states_0::type set)›*))
(*top goal: ‹⟦(f::'states_0 ⇒ 'states_1) (((δ₀::'states_0 ⇒ 'alpha ⇒ 'states_0)⇧⋆) (i₀::'states_0) []) = ((δ₁::'states_1 ⇒ 'alpha ⇒ 'states_1)⇧⋆) (i₁::'states_1) []; ∀x::'alpha∈set []. x ∈ (A::'alpha set)⟧ ⟹ ((δ₁⇧⋆) i₁ [] ∈ (F₁::'states_1 set) ∧ (δ₀⇧⋆) i₀ [] ∈ (S₀::'states_0 set)) = ((δ₁⇧⋆) i₁ [] ∈ F₁)› and 1 goal remains*)
using Aut0.give_input_closed (*‹⟦?input ∈ A⇧⋆; ?s ∈ S₀⟧ ⟹ (δ₀⇧⋆) ?s ?input ∈ S₀›*) Aut0.init_state_is_a_state (*‹i₀ ∈ S₀›*) by blast
end
locale aut_epi = aut_hom +
assumes
is_epi: "f ` S₀ = S₁"
locale det_G_aut =
is_aut: det_aut A S i F δ +
labels_a_G_set: alt_grp_act G A φ +
states_a_G_set: alt_grp_act G S ψ +
accepting_is_eq_var: eq_var_subset G S ψ F +
init_is_eq_var: eq_var_subset G S ψ "{i}" +
trans_is_eq_var: eq_var_func G "S × A"
"λg∈carrier G. λ(s, a) ∈ (S × A). (ψ g s, φ g a)"
S "ψ" "(λ(s, a) ∈ (S × A). δ s a)"
for A :: "'alpha set" (structure) and
S :: "'states set" and
i F δ and
G :: "('grp, 'b) monoid_scheme" and
φ ψ
begin
adhoc_overloading
star labels_a_G_set.induced_star_map
lemma give_input_eq_var:
"eq_var_func G
(A⇧⋆ × S) (λg∈carrier G. λ(w, s) ∈ (A⇧⋆ × S). ((φ⇧⋆) g w, ψ g s))
S ψ
(λ(w, s) ∈ (A⇧⋆ × S). (δ⇧⋆) s w)"
proof (-)
(*goal: ‹eq_var_func G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)) S ψ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w)›*)
have H_0: "⋀a w s g.
(⋀s. s ∈ S ⟹ (φ⇧⋆) g w ∈ A⇧⋆ ∧ ψ g s ∈ S ⟹
(δ⇧⋆) (ψ g s) ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) s w)) ⟹
s ∈ S ⟹
g ∈ carrier G ⟹
a ∈ A ⟹ ∀x∈set w. x ∈ A ⟹ ψ g s ∈ S ⟹ ∀x∈set ((φ⇧⋆) g (a # w)). x ∈ A ⟹
(δ⇧⋆) (ψ g s) ((φ⇧⋆) g (a # w)) = ψ g ((δ⇧⋆) (δ s a) w)"
proof (-)
(*goal: ‹⋀a w s g. ⟦⋀s. ⟦s ∈ S; (φ⇧⋆) g w ∈ A⇧⋆ ∧ ψ g s ∈ S⟧ ⟹ (δ⇧⋆) (ψ g s) ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) s w); s ∈ S; g ∈ carrier G; a ∈ A; ∀x∈set w. x ∈ A; ψ g s ∈ S; ∀x∈set ((φ⇧⋆) g (a # w)). x ∈ A⟧ ⟹ (δ⇧⋆) (ψ g s) ((φ⇧⋆) g (a # w)) = ψ g ((δ⇧⋆) (δ s a) w)›*)
fix a and w and s and g
assume A_IH: "(⋀s. s ∈ S ⟹
(φ⇧⋆) g w ∈ A⇧⋆ ∧ ψ g s ∈ S ⟹
(δ⇧⋆) (ψ g s) ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) s w))" and A_0: "s ∈ S" and A_1: "ψ g s ∈ S" and A_2: "∀x∈set ((φ⇧⋆) g (a # w)). x ∈ A" and A_3: "g ∈ carrier G" and A_4: " a ∈ A" and A_5: "∀x∈set w. x ∈ A" (*‹⟦(?s1::'states) ∈ (S::'states set); ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) (g::'grp) (w::'alpha list) ∈ A⇧⋆ ∧ (ψ::'grp ⇒ 'states ⇒ 'states) g ?s1 ∈ S⟧ ⟹ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (ψ g ?s1) ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) ?s1 w)› ‹(s::'states) ∈ (S::'states set)› ‹(ψ::'grp ⇒ 'states ⇒ 'states) (g::'grp) (s::'states) ∈ (S::'states set)› ‹∀x::'alpha∈set (((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) (g::'grp) ((a::'alpha) # (w::'alpha list))). x ∈ A› ‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹(a::'alpha) ∈ A› ‹∀x::'alpha∈set (w::'alpha list). x ∈ A›*)
have H_0: "((φ⇧⋆) g (a # w)) = (φ g a) # (φ⇧⋆) g w"
using A_4 (*‹a ∈ A›*) A_5 (*‹∀x∈set w. x ∈ A›*) A_3 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) by auto
hence H_1: "(δ⇧⋆) (ψ g s) ((φ⇧⋆) g (a # w))
= (δ⇧⋆) (ψ g s) ((φ g a) # (φ⇧⋆) g w)"
by simp
have H_2: "... = (δ⇧⋆) ((δ⇧⋆) (ψ g s) [φ g a]) ((φ⇧⋆) g w)"
using is_aut.input_under_concat (*‹⟦?w ∈ A⇧⋆; ?v ∈ A⇧⋆⟧ ⟹ (δ⇧⋆) ?s (?w @ ?v) = (δ⇧⋆) ((δ⇧⋆) ?s ?w) ?v›*) by simp
have H_3: "(δ⇧⋆) (ψ g s) [φ g a] = ψ g (δ s a)"
using trans_is_eq_var.eq_var_func_axioms (*‹eq_var_func (G::('grp, 'b) monoid_scheme) ((S::'states set) × A) (λg::'grp∈carrier G. λ(s::'states, a::'alpha)∈S × A. ((ψ::'grp ⇒ 'states ⇒ 'states) g s, (φ::'grp ⇒ 'alpha ⇒ 'alpha) g a)) S ψ (λ(s::'states, a::'alpha)∈S × A. (δ::'states ⇒ 'alpha ⇒ 'states) s a)›*) A_4 (*‹a ∈ A›*) A_5 (*‹∀x∈set w. x ∈ A›*) A_0 (*‹s ∈ S›*) A_1 (*‹ψ g s ∈ S›*) A_3 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})›*) simp add: eq_var_func_def (*‹eq_var_func ?G ?X ?φ ?Y ?ψ ?f ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*) eq_var_func_axioms_def (*‹eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀a g. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*) make_op_def (*‹(⊙⇘?φ⇙) ≡ ?φ›*))
(*goal: ‹(δ⇧⋆) (ψ g s) [φ g a] = ψ g (δ s a)›*)
apply (rule meta_mp[of "ψ g s ∈ S ∧ φ g a ∈ A ∧ s ∈ S ∧ a ∈ A"] (*‹⟦(ψ::'grp ⇒ 'states ⇒ 'states) (g::'grp) (s::'states) ∈ (S::'states set) ∧ (φ::'grp ⇒ 'alpha ⇒ 'alpha) g (a::'alpha) ∈ A ∧ s ∈ S ∧ a ∈ A ⟹ PROP ?Q::prop; ψ g s ∈ S ∧ φ g a ∈ A ∧ s ∈ S ∧ a ∈ A⟧ ⟹ PROP ?Q›*))
(*goal: ‹⟦(a::'alpha) ∈ A; ∀x::'alpha∈set (w::'alpha list). x ∈ A; (s::'states) ∈ (S::'states set); (ψ::'grp ⇒ 'states ⇒ 'states) (g::'grp) s ∈ S; g ∈ carrier (G::('grp, 'b) monoid_scheme); alt_grp_act G (S × A) (λg::'grp∈carrier G. λ(s::'states, a::'alpha)∈S × A. (ψ g s, (φ::'grp ⇒ 'alpha ⇒ 'alpha) g a)); alt_grp_act G S ψ; (λ(x::'states, y::'alpha). (δ::'states ⇒ 'alpha ⇒ 'states) x y) ∈ S × A → S; ∀(a::'states) b::'alpha. a ∈ S ∧ b ∈ A ⟶ (∀g::'grp. g ∈ carrier G ⟶ (if ψ g a ∈ S ∧ φ g b ∈ A then δ (ψ g a) (φ g b) else undefined) = ψ g (δ a b))⟧ ⟹ δ (ψ g s) (φ g a) = ψ g (δ s a)›*)
apply presburger
(*top goal: ‹⟦a ∈ A; ∀x∈set w. x ∈ A; s ∈ S; ψ g s ∈ S; g ∈ carrier G; alt_grp_act G (S × A) (λg∈carrier G. λ(s, a)∈S × A. (ψ g s, φ g a)); alt_grp_act G S ψ; (λ(x, y). δ x y) ∈ S × A → S; ∀a b. a ∈ S ∧ b ∈ A ⟶ (∀g. g ∈ carrier G ⟶ (if ψ g a ∈ S ∧ φ g b ∈ A then δ (ψ g a) (φ g b) else undefined) = ψ g (δ a b)); ψ g s ∈ S ∧ φ g a ∈ A ∧ s ∈ S ∧ a ∈ A⟧ ⟹ δ (ψ g s) (φ g a) = ψ g (δ s a)› and 1 goal remains*)
apply clarify
(*goal: ‹⟦a ∈ A; ∀x∈set w. x ∈ A; s ∈ S; ψ g s ∈ S; g ∈ carrier G; alt_grp_act G (S × A) (λg∈carrier G. λ(s, a)∈S × A. (ψ g s, φ g a)); alt_grp_act G S ψ; (λ(x, y). δ x y) ∈ S × A → S; ∀a b. a ∈ S ∧ b ∈ A ⟶ (∀g. g ∈ carrier G ⟶ (if ψ g a ∈ S ∧ φ g b ∈ A then δ (ψ g a) (φ g b) else undefined) = ψ g (δ a b))⟧ ⟹ ψ g s ∈ S ∧ φ g a ∈ A ∧ s ∈ S ∧ a ∈ A›*)
using labels_a_G_set.element_image (*‹⟦?g ∈ carrier G; ?x ∈ A; φ ?g ?x = ?y⟧ ⟹ ?y ∈ A›*) by presburger
have H_4: "(δ⇧⋆) (ψ g (δ s a)) ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) (δ s a) w)"
apply (rule A_IH[where s1 = "δ s a"] (*‹⟦δ s a ∈ S; (φ⇧⋆) g w ∈ A⇧⋆ ∧ ψ g (δ s a) ∈ S⟧ ⟹ (δ⇧⋆) (ψ g (δ s a)) ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) (δ s a) w)›*))
(*goal: ‹(δ⇧⋆) (ψ g (δ s a)) ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) (δ s a) w)›*)
subgoal for
using A_4 (*‹a ∈ A›*) A_5 (*‹∀x∈set w. x ∈ A›*) A_0 (*‹s ∈ S›*) by (auto simp add: is_aut.trans_func_well_def (*‹⟦?state ∈ S; ?label ∈ A⟧ ⟹ δ ?state ?label ∈ S›*))
using A_4 (*‹a ∈ A›*) A_5 (*‹∀x::'alpha∈set (w::'alpha list). x ∈ A›*) A_0 (*‹s ∈ S›*) A_3 (*‹g ∈ carrier G›*) ‹δ s a ∈ S› (*‹δ s a ∈ S›*) states_a_G_set.element_image (*‹⟦(?g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); (?x::'states) ∈ (S::'states set); (ψ::'grp ⇒ 'states ⇒ 'states) ?g ?x = (?y::'states)⟧ ⟹ ?y ∈ S›*) by (metis A_2 (*‹∀x∈set ((φ⇧⋆) g (a # w)). x ∈ A›*) Cons_in_lists_iff (*‹(?x # ?xs ∈ ?A⇧⋆) = (?x ∈ ?A ∧ ?xs ∈ ?A⇧⋆)›*) H_0 (*‹(φ⇧⋆) g (a # w) = φ g a # (φ⇧⋆) g w›*) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*))
show "(δ⇧⋆) (ψ g s) ((φ⇧⋆) g (a # w)) = ψ g ((δ⇧⋆) (δ s a) w)"
using H_0 (*‹((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) (g::'grp) ((a::'alpha) # (w::'alpha list)) = φ g a # (φ⇧⋆) g w›*) H_1 (*‹(δ⇧⋆) (ψ g s) ((φ⇧⋆) g (a # w)) = (δ⇧⋆) (ψ g s) (φ g a # (φ⇧⋆) g w)›*) H_2 (*‹(δ⇧⋆) (ψ g s) (φ g a # (φ⇧⋆) g w) = (δ⇧⋆) ((δ⇧⋆) (ψ g s) [φ g a]) ((φ⇧⋆) g w)›*) H_3 (*‹(δ⇧⋆) (ψ g s) [φ g a] = ψ g (δ s a)›*) H_4 (*‹(δ⇧⋆) (ψ g (δ s a)) ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) (δ s a) w)›*) by presburger
qed
show "?thesis"
(*goal: ‹eq_var_func G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)) S ψ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w)›*)
apply (subst eq_var_func_def (*‹eq_var_func ?G ?X ?φ ?Y ?ψ ?f ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*))
(*goal: ‹eq_var_func G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)) S ψ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w)›*)
apply (subst eq_var_func_axioms_def (*‹eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀a g. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*))
(*goal: ‹alt_grp_act G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)) ∧ alt_grp_act G S ψ ∧ eq_var_func_axioms G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)) S ψ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w)›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹alt_grp_act (G::('grp, 'b) monoid_scheme) (A⇧⋆ × (S::'states set)) (λg::'grp∈carrier G. λ(w::'alpha list, s::'states)∈A⇧⋆ × S. (((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) g w, (ψ::'grp ⇒ 'states ⇒ 'states) g s)) ∧ alt_grp_act G S ψ ∧ (λ(w::'alpha list, s::'states)∈A⇧⋆ × S. ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) s w) ∈ A⇧⋆ × S →⇩E S ∧ (∀(a::'alpha list × 'states) g::'grp. a ∈ A⇧⋆ × S ⟶ g ∈ carrier G ⟶ (λ(w::'alpha list, s::'states)∈A⇧⋆ × S. (δ⇧⋆) s w) (g ⊙⇘λg::'grp∈carrier G. λ(w::'alpha list, s::'states)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)⇙ a) = g ⊙⇘ψ⇙ (λ(w::'alpha list, s::'states)∈A⇧⋆ × S. (δ⇧⋆) s w) a)›*)
apply (rule prod_group_act[where G = G and A = "A⇧⋆" and φ = "(φ⇧⋆)" and B = S and ψ = ψ] (*‹⟦alt_grp_act G (A⇧⋆) (φ⇧⋆); alt_grp_act G S ψ⟧ ⟹ alt_grp_act G (A⇧⋆ × S) (λg∈carrier G. λ(a, b)∈A⇧⋆ × S. ((φ⇧⋆) g a, ψ g b))›*))
(*top goal: ‹alt_grp_act G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s))› and 1 goal remains*)
using labels_a_G_set.lists_a_Gset (*‹alt_grp_act G (A⇧⋆) (φ⇧⋆)›*) apply blast
(*top goal: ‹alt_grp_act (G::('grp, 'b) monoid_scheme) (A⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆)› and 2 goals remain*)
apply (simp add: states_a_G_set.group_action_axioms (*‹group_action G S ψ›*))
(*top goal: ‹alt_grp_act (G::('grp, 'b) monoid_scheme) (S::'states::type set) (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type)› and 1 goal remains*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹alt_grp_act G S ψ ∧ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w) ∈ A⇧⋆ × S →⇩E S ∧ (∀a g. a ∈ A⇧⋆ × S ⟶ g ∈ carrier G ⟶ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w) (g ⊙⇘λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)⇙ a) = g ⊙⇘ψ⇙ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w) a)›*)
apply (simp add: states_a_G_set.group_action_axioms (*‹group_action (G::('grp, 'b) monoid_scheme) (S::'states set) (ψ::'grp ⇒ 'states ⇒ 'states)›*))
(*top goal: ‹alt_grp_act (G::('grp, 'b) monoid_scheme) (S::'states::type set) (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type)› and 1 goal remains*)
apply (rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹(λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w) ∈ A⇧⋆ × S →⇩E S ∧ (∀a g. a ∈ A⇧⋆ × S ⟶ g ∈ carrier G ⟶ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w) (g ⊙⇘λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)⇙ a) = g ⊙⇘ψ⇙ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w) a)›*)
apply (subst extensional_funcset_def (*‹?S →⇩E ?T = (?S → ?T) ∩ extensional ?S›*))
(*top goal: ‹(λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w) ∈ A⇧⋆ × S →⇩E S› and 1 goal remains*)
apply (subst restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*))
(*top goal: ‹(λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w) ∈ (A⇧⋆ × S → S) ∩ extensional (A⇧⋆ × S)› and 1 goal remains*)
apply (subst Pi_def (*‹Pi ?A ?B = {f. ∀x. x ∈ ?A ⟶ f x ∈ ?B x}›*))
(*top goal: ‹(λx. if x ∈ A⇧⋆ × S then case x of (w, s) ⇒ (δ⇧⋆) s w else undefined) ∈ (A⇧⋆ × S → S) ∩ extensional (A⇧⋆ × S)› and 1 goal remains*)
apply (subst extensional_def (*‹extensional ?A = {f. ∀x. x ∉ ?A ⟶ f x = undefined}›*))
(*top goal: ‹(λx::'alpha list × 'states. if x ∈ A⇧⋆ × (S::'states set) then case x of (w::'alpha list, s::'states) ⇒ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) s w else undefined) ∈ {f::'alpha list × 'states ⇒ 'states. ∀x::'alpha list × 'states. x ∈ A⇧⋆ × S ⟶ f x ∈ S} ∩ extensional (A⇧⋆ × S)› and 1 goal remains*)
apply ((auto simp add: in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) is_aut.give_input_closed (*‹⟦?input ∈ A⇧⋆; ?s ∈ S⟧ ⟹ (δ⇧⋆) ?s ?input ∈ S›*))[1])
(*top goal: ‹(λx. if x ∈ A⇧⋆ × S then case x of (w, s) ⇒ (δ⇧⋆) s w else undefined) ∈ {f. ∀x. x ∈ A⇧⋆ × S ⟶ f x ∈ S} ∩ {f. ∀x. x ∉ A⇧⋆ × S ⟶ f x = undefined}› and 1 goal remains*)
apply (subst restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*))
(*goal: ‹∀(a::'alpha::type list × 'states::type) g::'grp::type. a ∈ A⇧⋆ × (S::'states::type set) ⟶ g ∈ carrier (G::('grp, 'b) monoid_scheme) ⟶ (λ(w::'alpha::type list, s::'states::type)∈A⇧⋆ × S. ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) s w) (g ⊙⇘λg::'grp::type∈carrier G. λ(w::'alpha::type list, s::'states::type)∈A⇧⋆ × S. (((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆) g w, (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) g s)⇙ a) = g ⊙⇘ψ⇙ (λ(w::'alpha::type list, s::'states::type)∈A⇧⋆ × S. (δ⇧⋆) s w) a›*)
apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})›*) simp add: make_op_def (*‹(⊙⇘?φ⇙) ≡ ?φ›*))
(*goal: ‹∀a g. a ∈ A⇧⋆ × S ⟶ g ∈ carrier G ⟶ (if g ⊙⇘λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)⇙ a ∈ A⇧⋆ × S then case g ⊙⇘λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)⇙ a of (w, s) ⇒ (δ⇧⋆) s w else undefined) = g ⊙⇘ψ⇙ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w) a›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); intro impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀a b g. ⟦b ∈ S; ∀x∈set a. x ∈ A⟧ ⟹ ((φ⇧⋆) g a ∈ A⇧⋆ ∧ ψ g b ∈ S ⟶ g ∈ carrier G ⟶ (δ⇧⋆) (ψ g b) ((φ⇧⋆) g a) = ψ g ((δ⇧⋆) b a)) ∧ (((φ⇧⋆) g a ∈ A⇧⋆ ⟶ ψ g b ∉ S) ⟶ g ∈ carrier G ⟶ undefined = ψ g ((δ⇧⋆) b a))›*)
subgoal for w and s and g
apply (induction w arbitrary: s)
(*goals:
1. ‹⋀s. ⟦s ∈ S; ∀x∈set []. x ∈ A; (φ⇧⋆) g [] ∈ A⇧⋆ ∧ ψ g s ∈ S; g ∈ carrier G⟧ ⟹ (δ⇧⋆) (ψ g s) ((φ⇧⋆) g []) = ψ g ((δ⇧⋆) s [])›
2. ‹⋀a w s. ⟦⋀s. ⟦s ∈ S; ∀x∈set w. x ∈ A; (φ⇧⋆) g w ∈ A⇧⋆ ∧ ψ g s ∈ S; g ∈ carrier G⟧ ⟹ (δ⇧⋆) (ψ g s) ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) s w); s ∈ S; ∀x∈set (a # w). x ∈ A; (φ⇧⋆) g (a # w) ∈ A⇧⋆ ∧ ψ g s ∈ S; g ∈ carrier G⟧ ⟹ (δ⇧⋆) (ψ g s) ((φ⇧⋆) g (a # w)) = ψ g ((δ⇧⋆) s (a # w))›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})›*))
(*goal: ‹⋀(a::'alpha::type) (w::'alpha::type list) s::'states::type. ⟦⋀s::'states::type. ⟦s ∈ (S::'states::type set); ∀x::'alpha::type∈set w. x ∈ A; ((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆) (g::'grp::type) w ∈ A⇧⋆ ∧ (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) g s ∈ S; g ∈ carrier (G::('grp, 'b) monoid_scheme)⟧ ⟹ ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (ψ g s) ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) s w); s ∈ S; ∀x::'alpha::type∈set (a # w). x ∈ A; (φ⇧⋆) g (a # w) ∈ A⇧⋆ ∧ ψ g s ∈ S; g ∈ carrier G⟧ ⟹ (δ⇧⋆) (ψ g s) ((φ⇧⋆) g (a # w)) = ψ g ((δ⇧⋆) s (a # w))›*)
apply (simp add: H_0 (*‹⟦⋀s. ⟦s ∈ S; (φ⇧⋆) ?g1 ?w1 ∈ A⇧⋆ ∧ ψ ?g1 s ∈ S⟧ ⟹ (δ⇧⋆) (ψ ?g1 s) ((φ⇧⋆) ?g1 ?w1) = ψ ?g1 ((δ⇧⋆) s ?w1); ?s1 ∈ S; ?g1 ∈ carrier G; ?a1 ∈ A; ∀x∈set ?w1. x ∈ A; ψ ?g1 ?s1 ∈ S; ∀x∈set ((φ⇧⋆) ?g1 (?a1 # ?w1)). x ∈ A⟧ ⟹ (δ⇧⋆) (ψ ?g1 ?s1) ((φ⇧⋆) ?g1 (?a1 # ?w1)) = ψ ?g1 ((δ⇧⋆) (δ ?s1 ?a1) ?w1)›*) del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})›*))
(*proven 2 subgoals*) .
apply clarsimp
(*goal: ‹⋀(a::'alpha::type list) (b::'states::type) g::'grp::type. ⟦b ∈ (S::'states::type set); ∀x::'alpha::type∈set a. x ∈ A; ((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆) g a ∈ A⇧⋆ ⟶ (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) g b ∉ S; g ∈ carrier (G::('grp, 'b) monoid_scheme)⟧ ⟹ undefined = ψ g (((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) b a)›*)
by (metis (no_types, lifting) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) in_lists_conv_set (*‹(?xs ∈ ?A⇧⋆) = (∀x∈set ?xs. x ∈ ?A)›*) labels_a_G_set.surj_prop (*‹?g ∈ carrier G ⟹ φ ?g ` A = A›*) list.set_map (*‹set (map ?f ?v) = ?f ` set ?v›*) states_a_G_set.element_image (*‹⟦?g ∈ carrier G; ?x ∈ S; ψ ?g ?x = ?y⟧ ⟹ ?y ∈ S›*))
qed
definition
accepted_words :: "'alpha list set"
where "accepted_words = {w. w ∈ A⇧⋆ ∧ ((δ⇧⋆) i w) ∈ F}"
lemma induced_g_lang:
"G_lang G A φ accepted_words"
proof (-)
(*goal: ‹G_lang (G::('grp, 'b) monoid_scheme) A (φ::'grp ⇒ 'alpha ⇒ 'alpha) accepted_words›*)
have H_0: "⋀g w. g ∈ carrier G ⟹ w ∈ A⇧⋆ ∧ (δ⇧⋆) i w ∈ F ⟹ map (φ g) w ∈ A⇧⋆"
apply clarsimp
(*goal: ‹⋀(g::'grp) w::'alpha list. ⟦g ∈ carrier (G::('grp, 'b) monoid_scheme); w ∈ A⇧⋆ ∧ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w ∈ (F::'states set)⟧ ⟹ map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) g) w ∈ A⇧⋆›*)
using labels_a_G_set.element_image (*‹⟦?g ∈ carrier G; ?x ∈ A; φ ?g ?x = ?y⟧ ⟹ ?y ∈ A›*) by blast
have H_1: "⋀g w. g ∈ carrier G ⟹ w ∈ A⇧⋆ ⟹ (δ⇧⋆) i w ∈ F ⟹ (δ⇧⋆) i (map (φ g) w) ∈ F"
proof (-)
(*goal: ‹⋀g w. ⟦g ∈ carrier G; w ∈ A⇧⋆; (δ⇧⋆) i w ∈ F⟧ ⟹ (δ⇧⋆) i (map (φ g) w) ∈ F›*)
fix g and w
assume A_0: "g ∈ carrier G" and A_1: "w ∈ A⇧⋆" and A_2: "(δ⇧⋆) i w ∈ F" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹(w::'alpha list) ∈ A⇧⋆› ‹((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w::'alpha list) ∈ (F::'states set)›*)
have H1_0: "ψ g ((δ⇧⋆) i w) ∈ F"
using accepting_is_eq_var.eq_var_subset_axioms (*‹eq_var_subset G S ψ F›*) A_0 (*‹g ∈ carrier G›*) A_2 (*‹(δ⇧⋆) i w ∈ F›*) accepting_is_eq_var.is_equivar (*‹∀g∈carrier G. ψ g ` F = F›*) by blast
have H1_1: "ψ g i = i"
using init_is_eq_var.eq_var_subset_axioms (*‹eq_var_subset (G::('grp, 'b) monoid_scheme) (S::'states::type set) (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) {i::'states::type}›*) A_0 (*‹g ∈ carrier G›*) init_is_eq_var.is_equivar (*‹∀g∈carrier G. ψ g ` {i} = {i}›*) by auto
have H1_2: "⋀w g. ⟦g ∈ carrier G; w ∈ A⇧⋆; (δ⇧⋆) i w ∈ F⟧ ⟹ (φ⇧⋆) g w ∈ A⇧⋆"
using H_0 (*‹⟦?g1 ∈ carrier G; ?w1 ∈ A⇧⋆ ∧ (δ⇧⋆) i ?w1 ∈ F⟧ ⟹ map (φ ?g1) ?w1 ∈ A⇧⋆›*) by auto
from A_1 (*‹w ∈ A⇧⋆›*) have H1_3: "w ∈ A⇧⋆"
by auto
show "(δ⇧⋆) i (map (φ g) w) ∈ F"
using give_input_eq_var (*‹eq_var_func G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)) S ψ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w)›*) A_0 (*‹g ∈ carrier G›*) A_1 (*‹w ∈ A⇧⋆›*) H1_1 (*‹ψ g i = i›*) H1_3 (*‹(w::'alpha list) ∈ A⇧⋆›*) apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})›*) simp add: eq_var_func_def (*‹eq_var_func ?G ?X ?φ ?Y ?ψ ?f ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*) eq_var_func_axioms_def (*‹eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀a g. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*) make_op_def (*‹(⊙⇘?φ⇙) ≡ ?φ›*))
(*goal: ‹(δ⇧⋆) i (map (φ g) w) ∈ F›*)
using A_2 (*‹(δ⇧⋆) i w ∈ F›*) H1_0 (*‹(ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) (g::'grp::type) (((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) (w::'alpha::type list)) ∈ (F::'states::type set)›*) is_aut.init_state_is_a_state (*‹i ∈ S›*) H1_2 (*‹⟦(?g1::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); (?w1::'alpha list) ∈ A⇧⋆; ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) ?w1 ∈ (F::'states set)⟧ ⟹ ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) ?g1 ?w1 ∈ A⇧⋆›*) by (smt (verit, best) H1_3 (*‹w ∈ A⇧⋆›*) labels_a_G_set.induced_star_map_def (*‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))›*) restrict_apply (*‹restrict ?f ?A ?x = (if ?x ∈ ?A then ?f ?x else undefined)›*))
qed
show "?thesis"
(*goal: ‹G_lang G A φ accepted_words›*)
apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})›*) simp add: G_lang_def (*‹G_lang ?G ?A ?φ ?L ≡ alt_grp_act ?G ?A ?φ ∧ language ?A ?L ∧ G_lang_axioms ?G ?A ?φ ?L›*) accepted_words_def (*‹accepted_words = {w ∈ A⇧⋆. (δ⇧⋆) i w ∈ F}›*) G_lang_axioms_def (*‹G_lang_axioms ?G ?A ?φ ?L ≡ eq_var_subset ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) ?L›*))
(*goal: ‹G_lang G A φ accepted_words›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹alt_grp_act G A φ ∧ language A {w ∈ A⇧⋆. (δ⇧⋆) i w ∈ F} ∧ eq_var_subset G (A⇧⋆) (φ⇧⋆) {w ∈ A⇧⋆. (δ⇧⋆) i w ∈ F}›*)
using labels_a_G_set.alt_grp_act_axioms (*‹alt_grp_act G A φ›*) apply ((auto)[1])
(*top goal: ‹alt_grp_act (G::('grp, 'b) monoid_scheme) A (φ::'grp ⇒ 'alpha ⇒ 'alpha)› and 1 goal remains*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹language A {w ∈ A⇧⋆. (δ⇧⋆) i w ∈ F} ∧ eq_var_subset G (A⇧⋆) (φ⇧⋆) {w ∈ A⇧⋆. (δ⇧⋆) i w ∈ F}›*)
apply (simp add: language.intro (*‹?L ⊆ ?A⇧⋆ ⟹ language ?A ?L›*))
(*top goal: ‹language A {w::'alpha list ∈ A⇧⋆. ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w ∈ (F::'states set)}› and 1 goal remains*)
apply (rule alt_grp_act.eq_var_one_direction (*‹⟦alt_grp_act ?G ?X ?φ; ?Y ⊆ ?X; ∀g∈carrier ?G. ?φ g ` ?Y ⊆ ?Y⟧ ⟹ eq_var_subset ?G ?X ?φ ?Y›*))
(*goal: ‹eq_var_subset G (A⇧⋆) (φ⇧⋆) {w ∈ A⇧⋆. (δ⇧⋆) i w ∈ F}›*)
using labels_a_G_set.alt_grp_act_axioms (*‹alt_grp_act G A φ›*) labels_a_G_set.lists_a_Gset (*‹alt_grp_act G (A⇧⋆) (φ⇧⋆)›*)
(*goals:
1. ‹alt_grp_act G (A⇧⋆) (φ⇧⋆)›
2. ‹{w ∈ A⇧⋆. (δ⇧⋆) i w ∈ F} ⊆ A⇧⋆›
3. ‹∀g∈carrier G. (φ⇧⋆) g ` {w ∈ A⇧⋆. (δ⇧⋆) i w ∈ F} ⊆ {w ∈ A⇧⋆. (δ⇧⋆) i w ∈ F}›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply clarsimp
(*discuss goal 3*)
apply clarsimp
(*goal: ‹∀g∈carrier G. (φ⇧⋆) g ` {w ∈ A⇧⋆. (δ⇧⋆) i w ∈ F} ⊆ {w ∈ A⇧⋆. (δ⇧⋆) i w ∈ F}›*)
apply (simp add: H_0 (*‹⟦?g1 ∈ carrier G; ?w1 ∈ A⇧⋆ ∧ (δ⇧⋆) i ?w1 ∈ F⟧ ⟹ map (φ ?g1) ?w1 ∈ A⇧⋆›*) H_1 (*‹⟦?g1 ∈ carrier G; ?w1 ∈ A⇧⋆; (δ⇧⋆) i ?w1 ∈ F⟧ ⟹ (δ⇧⋆) i (map (φ ?g1) ?w1) ∈ F›*) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*))
(*proven 3 subgoals*) .
qed
end
locale reach_det_aut =
det_aut A S i F δ
for A :: "'alpha set" (structure) and
S :: "'states set" and
i F δ +
assumes
is_reachable:
"s ∈ S ⟹ ∃input ∈ A⇧⋆. (δ⇧⋆) i input = s"
locale reach_det_G_aut =
det_G_aut A S i F δ G φ ψ + reach_det_aut A S i F δ
for A :: "'alpha set" (structure) and
S :: "'states set" and
i and F and δ and
G :: "('grp, 'b) monoid_scheme" and
φ ψ
begin
text ‹
To avoid duplicate variant of "star":
›
no_adhoc_overloading
star labels_a_G_set.induced_star_map
end
sublocale reach_det_G_aut ⊆ reach_det_aut
using reach_det_aut_axioms (*‹reach_det_aut A S i F δ›*) by simp
locale G_aut_hom = Aut0: reach_det_G_aut A S₀ i₀ F₀ δ₀ G φ ψ₀ +
Aut1: reach_det_G_aut A S₁ i₁ F₁ δ₁ G φ ψ₁ +
hom_f: aut_hom A S₀ i₀ F₀ δ₀ S₁ i₁ F₁ δ₁ f +
eq_var_f: eq_var_func G S₀ ψ₀ S₁ ψ₁ f for
A :: "'alpha set" and
S₀ :: "'states_0 set" and
i₀ and F₀ and δ₀ and
S₁ :: "'states_1 set" and
i₁ and F₁ and δ₁ and
G :: "('grp, 'b) monoid_scheme" and
φ ψ₀ ψ₁ f
locale G_aut_epi = G_aut_hom +
assumes
is_epi: "f ` S₀ = S₁"
locale det_aut_rec_lang = det_aut A S i F δ + language A L
for A :: "'alpha set" (structure) and
S :: "'states set" and
i F δ L +
assumes
is_recognised:
"w ∈ L ⟷ w ∈ A⇧⋆ ∧ ((δ⇧⋆) i w) ∈ F"
locale det_G_aut_rec_lang = det_G_aut A S i F δ G φ ψ + det_aut_rec_lang A S i F δ L
for A :: "'alpha set" (structure) and
S :: "'states set" and
i F δ and
G :: "('grp, 'b) monoid_scheme" and
φ ψ L
begin
lemma lang_is_G_lang: "G_lang G A φ L"
proof (-)
(*goal: ‹G_lang G A φ L›*)
have H0: "L = accepted_words"
apply (simp add: accepted_words_def (*‹accepted_words = {w::'alpha list ∈ A⇧⋆. ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w ∈ (F::'states set)}›*))
(*goal: ‹(L::'alpha list set) = accepted_words›*)
apply (subst is_recognised [symmetric] (*‹(?w ∈ A⇧⋆ ∧ (δ⇧⋆) i ?w ∈ F) = (?w ∈ L)›*))
(*goal: ‹L = {w ∈ A⇧⋆. (δ⇧⋆) i w ∈ F}›*)
by simp
show "G_lang G A φ L"
apply (subst H0 (*‹(L::'alpha list set) = accepted_words›*))
(*goal: ‹G_lang G A φ L›*)
apply (rule det_G_aut.induced_g_lang[of A S i F δ G φ ψ] (*‹det_G_aut A (S::'states::type set) (i::'states::type) (F::'states::type set) (δ::'states::type ⇒ 'alpha::type ⇒ 'states::type) (G::('grp, 'b) monoid_scheme) (φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type) (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) ⟹ G_lang G A φ accepted_words›*))
(*goal: ‹G_lang G A φ accepted_words›*)
by (simp add: det_G_aut_axioms (*‹det_G_aut A S i F δ G φ ψ›*))
qed
text ‹
To avoid ambiguous parse trees:
›
no_notation trans_is_eq_var.GA_0.induced_quot_map ("[_]⇩_ı" 60)
no_notation states_a_G_set.induced_quot_map ("[_]⇩_ı" 60)
end
locale reach_det_aut_rec_lang = reach_det_aut A S i F δ + det_aut_rec_lang A S i F δ L
for A :: "'alpha set" and
S :: "'states set" and
i F δ and
L :: "'alpha list set"
locale reach_det_G_aut_rec_lang = det_G_aut_rec_lang A S i F δ G φ ψ L +
reach_det_G_aut A S i F δ G φ ψ
for A :: "'alpha set" and
S :: "'states set" and
i F δ and
G :: "('grp, 'b) monoid_scheme" and
φ ψ and
L :: "'alpha list set"
sublocale reach_det_G_aut_rec_lang ⊆ det_G_aut_rec_lang
apply (simp add: det_G_aut_rec_lang_def (*‹det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ det_aut_rec_lang ?A ?S ?i ?F ?δ ?L›*))
(*goal: ‹det_G_aut_rec_lang A S i F δ G φ ψ L›*)
using reach_det_G_aut_rec_lang_axioms (*‹reach_det_G_aut_rec_lang A S i F δ G φ ψ L›*) by (simp add: det_G_aut_axioms (*‹det_G_aut A S i F δ G φ ψ›*) det_aut_rec_lang_axioms (*‹det_aut_rec_lang A S i F δ L›*))
locale det_G_aut_recog_G_lang = det_G_aut_rec_lang A S i F δ G φ ψ L + G_lang G A φ L
for A :: "'alpha set" (structure) and
S :: "'states set" and
i F δ and
G :: "('grp, 'b) monoid_scheme" and
φ ψ and
L :: "'alpha list set"
sublocale det_G_aut_rec_lang ⊆ det_G_aut_recog_G_lang
apply (simp add: det_G_aut_recog_G_lang_def (*‹det_G_aut_recog_G_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ∧ G_lang ?G ?A ?φ ?L›*))
(*goal: ‹det_G_aut_recog_G_lang A S i F δ G φ ψ L›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹det_G_aut_rec_lang A S i F δ G φ ψ L›
2. ‹G_lang G A φ L›
discuss goal 1*)
apply (simp add: det_G_aut_rec_lang_axioms (*‹det_G_aut_rec_lang A S i F δ G φ ψ L›*))
(*discuss goal 2*)
apply (simp add: lang_is_G_lang (*‹G_lang G A φ L›*))
(*proven 2 subgoals*) .
locale reach_det_G_aut_rec_G_lang = reach_det_G_aut_rec_lang A S i F δ G φ ψ L + G_lang G A φ L
for A :: "'alpha set" (structure) and
S :: "'states set" and
i F δ and
G :: "('grp, 'b) monoid_scheme" and
φ ψ L
sublocale reach_det_G_aut_rec_lang ⊆ reach_det_G_aut_rec_G_lang
apply (simp add: reach_det_G_aut_rec_G_lang_def (*‹reach_det_G_aut_rec_G_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ reach_det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ∧ G_lang ?G ?A ?φ ?L›*))
(*goal: ‹reach_det_G_aut_rec_G_lang A S i F δ G φ ψ L›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹reach_det_G_aut_rec_lang A S i F δ G φ ψ L›
2. ‹G_lang G A φ L›
discuss goal 1*)
apply (simp add: reach_det_G_aut_rec_lang_axioms (*‹reach_det_G_aut_rec_lang A S i F δ G φ ψ L›*))
(*discuss goal 2*)
apply (simp add: lang_is_G_lang (*‹G_lang G A φ L›*))
(*proven 2 subgoals*) .
lemma (in reach_det_G_aut)
"reach_det_G_aut_rec_lang A S i F δ G φ ψ accepted_words"
apply (clarsimp simp del: simp add: reach_det_G_aut_rec_lang_def (*‹reach_det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ∧ reach_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ›*) det_G_aut_rec_lang_def (*‹det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ det_aut_rec_lang ?A ?S ?i ?F ?δ ?L›*) det_aut_rec_lang_axioms_def (*‹det_aut_rec_lang_axioms ?A ?i ?F ?δ ?L ≡ ∀w. (w ∈ ?L) = (w ∈ ?A⇧⋆ ∧ (?δ⇧⋆) ?i w ∈ ?F)›*))
(*goal: ‹reach_det_G_aut_rec_lang A S i F δ G φ ψ accepted_words›*)
apply (intro conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹det_G_aut A S i F δ G φ ψ›
2. ‹det_aut_rec_lang A S i F δ accepted_words›
3. ‹reach_det_G_aut A S i F δ G φ ψ›
discuss goal 1*)
apply (simp add: det_G_aut_axioms (*‹det_G_aut A S i F δ G φ ψ›*))
(*discuss goal 2*)
apply (clarsimp simp add: reach_det_G_aut_axioms (*‹reach_det_G_aut A S i F δ G φ ψ›*) accepted_words_def (*‹accepted_words = {w ∈ A⇧⋆. (δ⇧⋆) i w ∈ F}›*) reach_det_aut_rec_lang_def (*‹reach_det_aut_rec_lang ?A ?S ?i ?F ?δ ?L ≡ reach_det_aut ?A ?S ?i ?F ?δ ∧ det_aut_rec_lang ?A ?S ?i ?F ?δ ?L›*))
(*top goal: ‹det_aut_rec_lang A S i F δ accepted_words› and 1 goal remains*)
apply (simp add: det_aut_rec_lang_def (*‹det_aut_rec_lang ?A ?S ?i ?F ?δ ?L ≡ det_aut ?A ?S ?i ?F ?δ ∧ language ?A ?L ∧ det_aut_rec_lang_axioms ?A ?i ?F ?δ ?L›*) det_aut_rec_lang_axioms.intro (*‹(⋀w. (w ∈ ?L) = (w ∈ ?A⇧⋆ ∧ (?δ⇧⋆) ?i w ∈ ?F)) ⟹ det_aut_rec_lang_axioms ?A ?i ?F ?δ ?L›*) is_aut.det_aut_axioms (*‹det_aut A S i F δ›*) language_def (*‹language ?A ?L ≡ ?L ⊆ ?A⇧⋆›*))
(*discuss goal 3*)
apply (simp add: reach_det_G_aut_axioms (*‹reach_det_G_aut A S i F δ G φ ψ›*))
(*proven 3 subgoals*) .
lemma (in det_G_aut) action_on_input:
"⋀ g w. g ∈ carrier G ⟹ w ∈ A⇧⋆ ⟹ ψ g ((δ⇧⋆) i w) = (δ⇧⋆) i ((φ⇧⋆) g w)"
proof (-)
(*goal: ‹⋀g w. ⟦g ∈ carrier G; w ∈ A⇧⋆⟧ ⟹ ψ g ((δ⇧⋆) i w) = (δ⇧⋆) i ((φ⇧⋆) g w)›*)
fix g and w
assume A_0: "g ∈ carrier G" and A_1: "w ∈ A⇧⋆" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹(w::'alpha list) ∈ A⇧⋆›*)
have H_0: "(δ⇧⋆) (ψ g i) ((φ⇧⋆) g w) = (δ⇧⋆) i ((φ⇧⋆) g w)"
using A_0 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) init_is_eq_var.is_equivar (*‹∀g∈carrier G. ψ g ` {i} = {i}›*) by fastforce
have H_1: "ψ g ((δ⇧⋆) i w) = (δ⇧⋆) (ψ g i) ((φ⇧⋆) g w)"
using A_0 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A_1 (*‹w ∈ A⇧⋆›*) give_input_eq_var (*‹eq_var_func (G::('grp, 'b) monoid_scheme) (A⇧⋆ × (S::'states::type set)) (λg::'grp::type∈carrier G. λ(w::'alpha::type list, s::'states::type)∈A⇧⋆ × S. (((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆) g w, (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) g s)) S ψ (λ(w::'alpha::type list, s::'states::type)∈A⇧⋆ × S. ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) s w)›*) apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})›*) simp add: eq_var_func_axioms_def (*‹eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀a g. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*) eq_var_func_def (*‹eq_var_func ?G ?X ?φ ?Y ?ψ ?f ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*) make_op_def (*‹(⊙⇘?φ⇙) ≡ ?φ›*))
(*goal: ‹ψ g ((δ⇧⋆) i w) = (δ⇧⋆) (ψ g i) ((φ⇧⋆) g w)›*)
apply (rule meta_mp[of "((φ⇧⋆) g w) ∈ A⇧⋆ ∧ ψ g i ∈ S"] (*‹⟦(φ⇧⋆) g w ∈ A⇧⋆ ∧ ψ g i ∈ S ⟹ PROP ?Q; (φ⇧⋆) g w ∈ A⇧⋆ ∧ ψ g i ∈ S⟧ ⟹ PROP ?Q›*))
(*goal: ‹⟦g ∈ carrier G; ∀x∈set w. x ∈ A; alt_grp_act G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)); alt_grp_act G S ψ; (λ(w, s). (δ⇧⋆) s w) ∈ A⇧⋆ × S → S; ∀a b. a ∈ A⇧⋆ ∧ b ∈ S ⟶ (∀g. g ∈ carrier G ⟶ (if (φ⇧⋆) g a ∈ A⇧⋆ ∧ ψ g b ∈ S then (δ⇧⋆) (ψ g b) ((φ⇧⋆) g a) else undefined) = ψ g ((δ⇧⋆) b a))⟧ ⟹ ψ g ((δ⇧⋆) i w) = (δ⇧⋆) (ψ g i) ((φ⇧⋆) g w)›*)
using is_aut.init_state_is_a_state (*‹i ∈ S›*) A_1 (*‹(w::'alpha list) ∈ A⇧⋆›*) apply presburger
(*top goal: ‹⟦g ∈ carrier G; ∀x∈set w. x ∈ A; alt_grp_act G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)); alt_grp_act G S ψ; (λ(w, s). (δ⇧⋆) s w) ∈ A⇧⋆ × S → S; ∀a b. a ∈ A⇧⋆ ∧ b ∈ S ⟶ (∀g. g ∈ carrier G ⟶ (if (φ⇧⋆) g a ∈ A⇧⋆ ∧ ψ g b ∈ S then (δ⇧⋆) (ψ g b) ((φ⇧⋆) g a) else undefined) = ψ g ((δ⇧⋆) b a)); (φ⇧⋆) g w ∈ A⇧⋆ ∧ ψ g i ∈ S⟧ ⟹ ψ g ((δ⇧⋆) i w) = (δ⇧⋆) (ψ g i) ((φ⇧⋆) g w)› and 1 goal remains*)
using det_G_aut_axioms (*‹det_G_aut A (S::'states set) (i::'states) (F::'states set) (δ::'states ⇒ 'alpha ⇒ 'states) (G::('grp, 'b) monoid_scheme) (φ::'grp ⇒ 'alpha ⇒ 'alpha) (ψ::'grp ⇒ 'states ⇒ 'states)›*) apply (clarsimp simp add: det_G_aut_def (*‹det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ (det_aut ?A ?S ?i ?F ?δ ∧ alt_grp_act ?G ?A ?φ ∧ alt_grp_act ?G ?S ?ψ) ∧ eq_var_subset ?G ?S ?ψ ?F ∧ eq_var_subset ?G ?S ?ψ {?i} ∧ eq_var_func ?G (?S × ?A) (λg∈carrier ?G. λ(s, a)∈?S × ?A. (?ψ g s, ?φ g a)) ?S ?ψ (λ(s, a)∈?S × ?A. ?δ s a)›*))
(*goal: ‹⟦g ∈ carrier G; ∀x∈set w. x ∈ A; alt_grp_act G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)); alt_grp_act G S ψ; (λ(w, s). (δ⇧⋆) s w) ∈ A⇧⋆ × S → S; ∀a b. a ∈ A⇧⋆ ∧ b ∈ S ⟶ (∀g. g ∈ carrier G ⟶ (if (φ⇧⋆) g a ∈ A⇧⋆ ∧ ψ g b ∈ S then (δ⇧⋆) (ψ g b) ((φ⇧⋆) g a) else undefined) = ψ g ((δ⇧⋆) b a))⟧ ⟹ (φ⇧⋆) g w ∈ A⇧⋆ ∧ ψ g i ∈ S›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); rule impI (*‹(?P::bool ⟹ ?Q::bool) ⟹ ?P ⟶ ?Q›*); rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹⟦g ∈ carrier G; ∀x∈set w. x ∈ A; group_action G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((if g ∈ carrier G then restrict (map (φ g)) (A⇧⋆) else undefined) w, ψ g s)); group_action G S ψ; (λ(w, s). (δ⇧⋆) s w) ∈ A⇧⋆ × S → S; ∀a b. a ∈ A⇧⋆ ∧ b ∈ S ⟶ (∀g. g ∈ carrier G ⟶ (if map (φ g) a ∈ A⇧⋆ ∧ ψ g b ∈ S then (δ⇧⋆) (ψ g b) ((φ⇧⋆) g a) else undefined) = ψ g ((δ⇧⋆) b a)); det_aut A S i F δ; group_action G A φ; eq_var_subset G S ψ F; eq_var_subset G S ψ {i}; eq_var_func G (S × A) (λg∈carrier G. λ(s, a)∈S × A. (ψ g s, φ g a)) S ψ (λ(x, y)∈S × A. δ x y)⟧ ⟹ (w ∈ A⇧⋆ ⟶ map (φ g) w ∈ A⇧⋆ ∧ ψ g i ∈ S) ∧ (w ∉ A⇧⋆ ⟶ undefined ∈ A⇧⋆ ∧ ψ g i ∈ S)›*)
using labels_a_G_set.element_image (*‹⟦?g ∈ carrier G; ?x ∈ A; φ ?g ?x = ?y⟧ ⟹ ?y ∈ A›*) apply fastforce
(*top goal: ‹⟦g ∈ carrier G; ∀x∈set w. x ∈ A; group_action G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((if g ∈ carrier G then restrict (map (φ g)) (A⇧⋆) else undefined) w, ψ g s)); group_action G S ψ; (λ(w, s). (δ⇧⋆) s w) ∈ A⇧⋆ × S → S; ∀a b. a ∈ A⇧⋆ ∧ b ∈ S ⟶ (∀g. g ∈ carrier G ⟶ (if map (φ g) a ∈ A⇧⋆ ∧ ψ g b ∈ S then (δ⇧⋆) (ψ g b) ((φ⇧⋆) g a) else undefined) = ψ g ((δ⇧⋆) b a)); det_aut A S i F δ; group_action G A φ; eq_var_subset G S ψ F; eq_var_subset G S ψ {i}; eq_var_func G (S × A) (λg∈carrier G. λ(s, a)∈S × A. (ψ g s, φ g a)) S ψ (λ(x, y)∈S × A. δ x y); w ∈ A⇧⋆⟧ ⟹ map (φ g) w ∈ A⇧⋆› and 3 goals remain*)
using is_aut.init_state_is_a_state (*‹(i::'states::type) ∈ (S::'states::type set)›*) states_a_G_set.element_image (*‹⟦?g ∈ carrier G; ?x ∈ S; ψ ?g ?x = ?y⟧ ⟹ ?y ∈ S›*)
(*goals:
1. ‹⟦g ∈ carrier G; ∀x∈set w. x ∈ A; group_action G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((if g ∈ carrier G then restrict (map (φ g)) (A⇧⋆) else undefined) w, ψ g s)); group_action G S ψ; (λ(w, s). (δ⇧⋆) s w) ∈ A⇧⋆ × S → S; ∀a b. a ∈ A⇧⋆ ∧ b ∈ S ⟶ (∀g. g ∈ carrier G ⟶ (if map (φ g) a ∈ A⇧⋆ ∧ ψ g b ∈ S then (δ⇧⋆) (ψ g b) ((φ⇧⋆) g a) else undefined) = ψ g ((δ⇧⋆) b a)); det_aut A S i F δ; group_action G A φ; eq_var_subset G S ψ F; eq_var_subset G S ψ {i}; eq_var_func G (S × A) (λg∈carrier G. λ(s, a)∈S × A. (ψ g s, φ g a)) S ψ (λ(x, y)∈S × A. δ x y); w ∈ A⇧⋆⟧ ⟹ ψ g i ∈ S›
2. ‹⟦g ∈ carrier G; ∀x∈set w. x ∈ A; group_action G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((if g ∈ carrier G then restrict (map (φ g)) (A⇧⋆) else undefined) w, ψ g s)); group_action G S ψ; (λ(w, s). (δ⇧⋆) s w) ∈ A⇧⋆ × S → S; ∀a b. a ∈ A⇧⋆ ∧ b ∈ S ⟶ (∀g. g ∈ carrier G ⟶ (if map (φ g) a ∈ A⇧⋆ ∧ ψ g b ∈ S then (δ⇧⋆) (ψ g b) ((φ⇧⋆) g a) else undefined) = ψ g ((δ⇧⋆) b a)); det_aut A S i F δ; group_action G A φ; eq_var_subset G S ψ F; eq_var_subset G S ψ {i}; eq_var_func G (S × A) (λg∈carrier G. λ(s, a)∈S × A. (ψ g s, φ g a)) S ψ (λ(x, y)∈S × A. δ x y); w ∉ A⇧⋆⟧ ⟹ undefined ∈ A⇧⋆›
3. ‹⟦g ∈ carrier G; ∀x∈set w. x ∈ A; group_action G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((if g ∈ carrier G then restrict (map (φ g)) (A⇧⋆) else undefined) w, ψ g s)); group_action G S ψ; (λ(w, s). (δ⇧⋆) s w) ∈ A⇧⋆ × S → S; ∀a b. a ∈ A⇧⋆ ∧ b ∈ S ⟶ (∀g. g ∈ carrier G ⟶ (if map (φ g) a ∈ A⇧⋆ ∧ ψ g b ∈ S then (δ⇧⋆) (ψ g b) ((φ⇧⋆) g a) else undefined) = ψ g ((δ⇧⋆) b a)); det_aut A S i F δ; group_action G A φ; eq_var_subset G S ψ F; eq_var_subset G S ψ {i}; eq_var_func G (S × A) (λg∈carrier G. λ(s, a)∈S × A. (ψ g s, φ g a)) S ψ (λ(x, y)∈S × A. δ x y); w ∉ A⇧⋆⟧ ⟹ ψ g i ∈ S›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply blast
(*discuss goal 3*)
apply blast
(*proven 3 subgoals*) .
show "ψ g ((δ⇧⋆) i w) = (δ⇧⋆) i ((φ⇧⋆) g w)"
using H_0 (*‹(δ⇧⋆) (ψ g i) ((φ⇧⋆) g w) = (δ⇧⋆) i ((φ⇧⋆) g w)›*) H_1 (*‹ψ g ((δ⇧⋆) i w) = (δ⇧⋆) (ψ g i) ((φ⇧⋆) g w)›*) by simp
qed
definition (in det_G_aut)
reachable_states :: "'states set" ("S⇩r⇩e⇩a⇩c⇩h")
where "S⇩r⇩e⇩a⇩c⇩h = {s . ∃ w ∈ A⇧⋆. (δ⇧⋆) i w = s}"
definition (in det_G_aut)
reachable_trans :: "'states ⇒ 'alpha ⇒ 'states" ("δ⇩r⇩e⇩a⇩c⇩h")
where "δ⇩r⇩e⇩a⇩c⇩h s a = (λ(s', a') ∈ S⇩r⇩e⇩a⇩c⇩h × A. δ s' a') (s, a)"
definition (in det_G_aut)
reachable_action :: "'grp ⇒ 'states ⇒ 'states" ("ψ⇩r⇩e⇩a⇩c⇩h")
where "ψ⇩r⇩e⇩a⇩c⇩h g s = (λ(g', s') ∈ carrier G × S⇩r⇩e⇩a⇩c⇩h. ψ g' s') (g, s)"
lemma (in det_G_aut) reachable_action_is_restict:
"⋀g s. g ∈ carrier G ⟹ s ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ ψ⇩r⇩e⇩a⇩c⇩h g s = ψ g s"
by (auto simp add: reachable_action_def (*‹ψ⇩r⇩e⇩a⇩c⇩h ?g ?s = (λ(g', s')∈carrier G × S⇩r⇩e⇩a⇩c⇩h. ψ g' s') (?g, ?s)›*) reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*))
lemma (in det_G_aut_rec_lang) reach_det_aut_is_det_aut_rec_L:
"reach_det_G_aut_rec_lang A S⇩r⇩e⇩a⇩c⇩h i (F ∩ S⇩r⇩e⇩a⇩c⇩h) δ⇩r⇩e⇩a⇩c⇩h G φ ψ⇩r⇩e⇩a⇩c⇩h L"
proof (-)
(*goal: ‹reach_det_G_aut_rec_lang A S⇩r⇩e⇩a⇩c⇩h (i::'states) ((F::'states set) ∩ S⇩r⇩e⇩a⇩c⇩h) δ⇩r⇩e⇩a⇩c⇩h (G::('grp, 'b) monoid_scheme) (φ::'grp ⇒ 'alpha ⇒ 'alpha) ψ⇩r⇩e⇩a⇩c⇩h (L::'alpha list set)›*)
have H_0: "(λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A →⇩E S⇩r⇩e⇩a⇩c⇩h"
proof (-)
(*goal: ‹(λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A →⇩E S⇩r⇩e⇩a⇩c⇩h›*)
have H1_0: "(λ(x, y). δ x y) ∈ extensional (S × A)"
using is_aut.trans_func_ext (*‹(λ(state, label). δ state label) ∈ S × A →⇩E S›*) by (simp add: PiE_iff (*‹(?f ∈ Pi⇩E ?I ?X) = ((∀i∈?I. ?f i ∈ ?X i) ∧ ?f ∈ extensional ?I)›*))
have H1_1: "(λ(s', a') ∈ S⇩r⇩e⇩a⇩c⇩h × A. δ s' a') ∈ extensional (S⇩r⇩e⇩a⇩c⇩h × A)"
using H1_0 (*‹(λ(x, y). δ x y) ∈ extensional (S × A)›*) by simp
have H1_2: "(λ(s', a')∈S⇩r⇩e⇩a⇩c⇩h × A. δ s' a') = (λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y)"
by (auto simp add: reachable_trans_def (*‹δ⇩r⇩e⇩a⇩c⇩h ?s ?a = (λ(s', a')∈S⇩r⇩e⇩a⇩c⇩h × A. δ s' a') (?s, ?a)›*))
show "(λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A →⇩E S⇩r⇩e⇩a⇩c⇩h"
apply (clarsimp simp add: PiE_iff (*‹((?f::?'a ⇒ ?'b) ∈ Pi⇩E (?I::?'a set) (?X::?'a ⇒ ?'b set)) = ((∀i::?'a∈?I. ?f i ∈ ?X i) ∧ ?f ∈ extensional ?I)›*))
(*goal: ‹(λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A →⇩E S⇩r⇩e⇩a⇩c⇩h›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹(∀x∈S⇩r⇩e⇩a⇩c⇩h. ∀y∈A. δ⇩r⇩e⇩a⇩c⇩h x y ∈ S⇩r⇩e⇩a⇩c⇩h) ∧ (λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ extensional (S⇩r⇩e⇩a⇩c⇩h × A)›*)
apply clarify
(*top goal: ‹∀x::'states∈S⇩r⇩e⇩a⇩c⇩h. ∀y::'alpha∈A. δ⇩r⇩e⇩a⇩c⇩h x y ∈ S⇩r⇩e⇩a⇩c⇩h› and 1 goal remains*)
using reachable_trans_def (*‹δ⇩r⇩e⇩a⇩c⇩h ?s ?a = (λ(s', a')∈S⇩r⇩e⇩a⇩c⇩h × A. δ s' a') (?s, ?a)›*) apply ((simp add: reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s::'states. ∃w::'alpha list∈A⇧⋆. ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = s}›*))[1])
(*top goal: ‹⋀x y. ⟦x ∈ S⇩r⇩e⇩a⇩c⇩h; y ∈ A⟧ ⟹ δ⇩r⇩e⇩a⇩c⇩h x y ∈ S⇩r⇩e⇩a⇩c⇩h› and 1 goal remains*)
apply (metis Cons_in_lists_iff (*‹(?x # ?xs ∈ ?A⇧⋆) = (?x ∈ ?A ∧ ?xs ∈ ?A⇧⋆)›*) append_Nil2 (*‹?xs @ [] = ?xs›*) append_in_lists_conv (*‹(?xs @ ?ys ∈ ?A⇧⋆) = (?xs ∈ ?A⇧⋆ ∧ ?ys ∈ ?A⇧⋆)›*) is_aut.give_input_closed (*‹⟦?input ∈ A⇧⋆; ?s ∈ S⟧ ⟹ (δ⇧⋆) ?s ?input ∈ S›*) is_aut.init_state_is_a_state (*‹i ∈ S›*) is_aut.trans_to_charact (*‹⟦?s ∈ S; ?a ∈ A; ?w ∈ A⇧⋆; ?s = (δ⇧⋆) ?i ?w⟧ ⟹ (δ⇧⋆) ?i (?w @ [?a]) = δ ?s ?a›*))
(*top goal: ‹⋀x y. ⟦∃w∈A⇧⋆. (δ⇧⋆) i w = x; y ∈ A; ⋀s a. δ⇩r⇩e⇩a⇩c⇩h s a = (if (∃w∈A⇧⋆. (δ⇧⋆) i w = s) ∧ a ∈ A then case (s, a) of (x, xa) ⇒ δ x xa else undefined)⟧ ⟹ ∃w∈A⇧⋆. (δ⇧⋆) i w = δ x y› and 1 goal remains*)
using H1_1 (*‹(λ(s', a')∈S⇩r⇩e⇩a⇩c⇩h × A. δ s' a') ∈ extensional (S⇩r⇩e⇩a⇩c⇩h × A)›*) H1_2 (*‹(λ(s', a')∈S⇩r⇩e⇩a⇩c⇩h × A. δ s' a') = (λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y)›*) by simp
qed
have H_1: "⋀g. g ∈ carrier G ⟹
(⋀s. ψ⇩r⇩e⇩a⇩c⇩h g s = (if s ∈ S⇩r⇩e⇩a⇩c⇩h then case (g, s) of (x, xa) ⇒ ψ x xa else undefined)) ⟹
bij_betw (ψ⇩r⇩e⇩a⇩c⇩h g) S⇩r⇩e⇩a⇩c⇩h S⇩r⇩e⇩a⇩c⇩h"
proof (-)
(*goal: ‹⋀g. ⟦g ∈ carrier G; ⋀s. ψ⇩r⇩e⇩a⇩c⇩h g s = (if s ∈ S⇩r⇩e⇩a⇩c⇩h then case (g, s) of (x, xa) ⇒ ψ x xa else undefined)⟧ ⟹ bij_betw (ψ⇩r⇩e⇩a⇩c⇩h g) S⇩r⇩e⇩a⇩c⇩h S⇩r⇩e⇩a⇩c⇩h›*)
fix g
assume A1_0: "g ∈ carrier G" and A1_1: "(⋀s. ψ⇩r⇩e⇩a⇩c⇩h g s =
(if s ∈ S⇩r⇩e⇩a⇩c⇩h
then case (g, s) of (x, xa) ⇒ ψ x xa
else undefined))" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹ψ⇩r⇩e⇩a⇩c⇩h (g::'grp) (?s1::'states) = (if ?s1 ∈ S⇩r⇩e⇩a⇩c⇩h then case (g, ?s1) of (x::'grp, xa::'states) ⇒ (ψ::'grp ⇒ 'states ⇒ 'states) x xa else undefined)›*)
have H1_0: "⋀r. r ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ (ψ⇩r⇩e⇩a⇩c⇩h g) r ∈ S⇩r⇩e⇩a⇩c⇩h"
using A1_0 (*‹g ∈ carrier G›*) apply (clarsimp simp add: reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*) reachable_action_def (*‹ψ⇩r⇩e⇩a⇩c⇩h ?g ?s = (λ(g', s')∈carrier G × S⇩r⇩e⇩a⇩c⇩h. ψ g' s') (?g, ?s)›*))
(*goal: ‹⋀r. r ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ ψ⇩r⇩e⇩a⇩c⇩h g r ∈ S⇩r⇩e⇩a⇩c⇩h›*)
apply (rule meta_mp[of "⋀w. w ∈ A⇧⋆ ⟹ ((φ⇧⋆) g w) ∈ A⇧⋆"] (*‹⟦(⋀w. w ∈ A⇧⋆ ⟹ (φ⇧⋆) g w ∈ A⇧⋆) ⟹ PROP ?Q; ⋀w. w ∈ A⇧⋆ ⟹ (φ⇧⋆) g w ∈ A⇧⋆⟧ ⟹ PROP ?Q›*))
(*goal: ‹⋀w. ⟦g ∈ carrier G; ∀x∈set w. x ∈ A⟧ ⟹ ∃wa∈A⇧⋆. (δ⇧⋆) i wa = ψ g ((δ⇧⋆) i w)›*)
using action_on_input[where g = g] (*‹⟦g ∈ carrier G; ?w ∈ A⇧⋆⟧ ⟹ ψ g ((δ⇧⋆) i ?w) = (δ⇧⋆) i ((φ⇧⋆) g ?w)›*)
(*goals:
1. ‹⋀w::'alpha list. ⟦(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); ∀x::'alpha∈set w. x ∈ A; ⋀w::'alpha list. w ∈ A⇧⋆ ⟹ ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) g w ∈ A⇧⋆⟧ ⟹ ∃wa::'alpha list∈A⇧⋆. ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) wa = (ψ::'grp ⇒ 'states ⇒ 'states) g ((δ⇧⋆) i w)›
2. ‹⋀(w::'alpha list) wa::'alpha list. ⟦(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); ∀x::'alpha∈set w. x ∈ A; wa ∈ A⇧⋆⟧ ⟹ ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) g wa ∈ A⇧⋆›
discuss goal 1*)
apply (metis in_listsI (*‹∀x::?'a∈set (?xs::?'a list). x ∈ (?A::?'a set) ⟹ ?xs ∈ ?A⇧⋆›*))
(*discuss goal 2*)
apply (metis alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) group_action.element_image (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?y ∈ ?E›*) labels_a_G_set.lists_a_Gset (*‹alt_grp_act G (A⇧⋆) (φ⇧⋆)›*))
(*proven 2 subgoals*) .
have H1_1: "⋀f T U. bij_betw f T T ⟹ f ` U = U ⟹ U ⊆ T ⟹ bij_betw (restrict f U) U U"
apply (clarsimp simp add: bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*) inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*goal: ‹⋀f T U. ⟦bij_betw f T T; f ` U = U; U ⊆ T⟧ ⟹ bij_betw (restrict f U) U U›*)
by (meson in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*))
have H1_2: "ψ⇩r⇩e⇩a⇩c⇩h g = restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h"
using reachable_action_def (*‹ψ⇩r⇩e⇩a⇩c⇩h (?g::'grp) (?s::'states) = (λ(g'::'grp, s'::'states)∈carrier (G::('grp, 'b) monoid_scheme) × S⇩r⇩e⇩a⇩c⇩h. (ψ::'grp ⇒ 'states ⇒ 'states) g' s') (?g, ?s)›*) A1_0 (*‹g ∈ carrier G›*) by (auto simp add: restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*))
have H1_3: "bij_betw (ψ g) S S ⟹ (ψ⇩r⇩e⇩a⇩c⇩h g) ` S⇩r⇩e⇩a⇩c⇩h = S⇩r⇩e⇩a⇩c⇩h
⟹ S⇩r⇩e⇩a⇩c⇩h ⊆ S ⟹ bij_betw (ψ⇩r⇩e⇩a⇩c⇩h g) S⇩r⇩e⇩a⇩c⇩h S⇩r⇩e⇩a⇩c⇩h"
by (metis H1_2 (*‹ψ⇩r⇩e⇩a⇩c⇩h (g::'grp::type) = restrict ((ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) g) S⇩r⇩e⇩a⇩c⇩h›*) bij_betw_imp_inj_on (*‹bij_betw (?f::?'a::type ⇒ ?'b::type) (?A::?'a::type set) (?B::?'b::type set) ⟹ inj_on ?f ?A›*) inj_on_imp_bij_betw (*‹inj_on (?f::?'a::type ⇒ ?'b::type) (?A::?'a::type set) ⟹ bij_betw ?f ?A (?f ` ?A)›*) inj_on_restrict_eq (*‹inj_on (restrict (?f::?'a::type ⇒ ?'b::type) (?A::?'a::type set)) ?A = inj_on ?f ?A›*) inj_on_subset (*‹⟦inj_on (?f::?'a::type ⇒ ?'b::type) (?A::?'a::type set); (?B::?'a::type set) ⊆ ?A⟧ ⟹ inj_on ?f ?B›*))
have H1_4: "⋀w s. s = (δ⇧⋆) i w ⟹
∀x∈set w. x ∈ A ⟹
∃x. (∃w∈ A⇧⋆. (δ⇧⋆) i w = x) ∧ (δ⇧⋆) i w = ψ⇩r⇩e⇩a⇩c⇩h g x"
proof (-)
(*goal: ‹⋀w s. ⟦s = (δ⇧⋆) i w; ∀x∈set w. x ∈ A⟧ ⟹ ∃x. (∃w∈A⇧⋆. (δ⇧⋆) i w = x) ∧ (δ⇧⋆) i w = ψ⇩r⇩e⇩a⇩c⇩h g x›*)
fix w and s
assume A2_0: "∀x∈set w. x ∈ A" and A2_1: "s = (δ⇧⋆) i w" (*‹∀x::'alpha∈set (w::'alpha list). x ∈ A› ‹(s::'states) = ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w::'alpha list)›*)
have H2_0: "(inv ⇘G⇙ g) ∈ carrier G"
apply (rule meta_mp[of "group G"] (*‹⟦Group.group G ⟹ PROP ?Q; Group.group G⟧ ⟹ PROP ?Q›*))
(*goal: ‹inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp) ∈ carrier G›*)
using A1_0 (*‹g ∈ carrier G›*) apply simp
(*top goal: ‹Group.group G ⟹ inv⇘G⇙ g ∈ carrier G› and 1 goal remains*)
using det_G_aut_rec_lang_axioms (*‹det_G_aut_rec_lang A S i F δ G φ ψ L›*) by (auto simp add: det_G_aut_rec_lang_def (*‹det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ det_aut_rec_lang ?A ?S ?i ?F ?δ ?L›*) det_aut_rec_lang_axioms_def (*‹det_aut_rec_lang_axioms ?A ?i ?F ?δ ?L ≡ ∀w. (w ∈ ?L) = (w ∈ ?A⇧⋆ ∧ (?δ⇧⋆) ?i w ∈ ?F)›*) det_G_aut_def (*‹det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ (det_aut ?A ?S ?i ?F ?δ ∧ alt_grp_act ?G ?A ?φ ∧ alt_grp_act ?G ?S ?ψ) ∧ eq_var_subset ?G ?S ?ψ ?F ∧ eq_var_subset ?G ?S ?ψ {?i} ∧ eq_var_func ?G (?S × ?A) (λg∈carrier ?G. λ(s, a)∈?S × ?A. (?ψ g s, ?φ g a)) ?S ?ψ (λ(s, a)∈?S × ?A. ?δ s a)›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*))
have H2_1: "ψ (inv ⇘G⇙ g) s = (δ⇧⋆) i ((φ⇧⋆) (inv ⇘G⇙ g) w)"
apply (simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})›*) add: A2_1 (*‹s = (δ⇧⋆) i w›*))
(*goal: ‹ψ (inv⇘G⇙ g) s = (δ⇧⋆) i ((φ⇧⋆) (inv⇘G⇙ g) w)›*)
apply (rule action_on_input[where g = "(inv ⇘G⇙ g)" and w = w] (*‹⟦inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp::type) ∈ carrier G; (w::'alpha::type list) ∈ A⇧⋆⟧ ⟹ (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) (inv⇘G⇙ g) (((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) w) = (δ⇧⋆) i (((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆) (inv⇘G⇙ g) w)›*))
(*goal: ‹ψ (inv⇘G⇙ g) ((δ⇧⋆) i w) = (δ⇧⋆) i ((φ⇧⋆) (inv⇘G⇙ g) w)›*)
using H2_0 (*‹inv⇘G⇙ g ∈ carrier G›*) A2_0 (*‹∀x∈set w. x ∈ A›*) apply -
(*goals:
1. ‹⟦inv⇘G⇙ g ∈ carrier G; ∀x∈set w. x ∈ A⟧ ⟹ inv⇘G⇙ g ∈ carrier G›
2. ‹⟦inv⇘G⇙ g ∈ carrier G; ∀x∈set w. x ∈ A⟧ ⟹ w ∈ A⇧⋆›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
have H2_2: "((φ⇧⋆) (inv ⇘G⇙ g) w) ∈ A⇧⋆"
using A2_0 (*‹∀x∈set w. x ∈ A›*) H2_0 (*‹inv⇘G⇙ g ∈ carrier G›*) det_G_aut_rec_lang_axioms (*‹det_G_aut_rec_lang A S i F δ G φ ψ L›*) apply clarsimp
(*goal: ‹((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) (inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp)) (w::'alpha list) ∈ A⇧⋆›*)
using labels_a_G_set.surj_prop (*‹?g ∈ carrier G ⟹ φ ?g ` A = A›*) list.set_map (*‹set (map ?f ?v) = ?f ` set ?v›*) by fastforce
have H2_3: "∃w∈A⇧⋆. (δ⇧⋆) i w = ψ (inv ⇘G⇙ g) s"
by (metis H2_1 (*‹ψ (inv⇘G⇙ g) s = (δ⇧⋆) i ((φ⇧⋆) (inv⇘G⇙ g) w)›*) H2_2 (*‹(φ⇧⋆) (inv⇘G⇙ g) w ∈ A⇧⋆›*))
from H2_3 (*‹∃w∈A⇧⋆. (δ⇧⋆) i w = ψ (inv⇘G⇙ g) s›*) have H2_4: "ψ (inv ⇘G⇙ g) s ∈ S⇩r⇩e⇩a⇩c⇩h"
by (simp add: reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*))
have H2_5: "ψ⇩r⇩e⇩a⇩c⇩h g (ψ (inv ⇘G⇙ g) s) = ψ g (ψ (inv ⇘G⇙ g) s)"
apply (rule reachable_action_is_restict (*‹⟦?g ∈ carrier G; ?s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ ψ⇩r⇩e⇩a⇩c⇩h ?g ?s = ψ ?g ?s›*))
(*goal: ‹ψ⇩r⇩e⇩a⇩c⇩h (g::'grp::type) ((ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) (inv⇘G::('grp, 'b) monoid_scheme⇙ g) (s::'states::type)) = ψ g (ψ (inv⇘G⇙ g) s)›*)
using A1_0 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) H2_4 (*‹(ψ::'grp ⇒ 'states ⇒ 'states) (inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp)) (s::'states) ∈ S⇩r⇩e⇩a⇩c⇩h›*) apply -
(*goals:
1. ‹⟦(g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme); (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) (inv⇘G⇙ g) (s::'states::type) ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ g ∈ carrier G›
2. ‹⟦(g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme); (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) (inv⇘G⇙ g) (s::'states::type) ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ ψ (inv⇘G⇙ g) s ∈ S⇩r⇩e⇩a⇩c⇩h›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
have H2_6: "(δ⇧⋆) i w = ψ⇩r⇩e⇩a⇩c⇩h g (ψ (inv ⇘G⇙ g) s)"
apply (simp add: H2_5 (*‹ψ⇩r⇩e⇩a⇩c⇩h g (ψ (inv⇘G⇙ g) s) = ψ g (ψ (inv⇘G⇙ g) s)›*) A2_1 (*‹s = (δ⇧⋆) i w›*))
(*goal: ‹((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) (w::'alpha::type list) = ψ⇩r⇩e⇩a⇩c⇩h (g::'grp::type) ((ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) (inv⇘G::('grp, 'b) monoid_scheme⇙ g) (s::'states::type))›*)
by (metis A1_0 (*‹g ∈ carrier G›*) A2_0 (*‹∀x∈set w. x ∈ A›*) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) A2_1 (*‹s = (δ⇧⋆) i w›*) H2_5 (*‹ψ⇩r⇩e⇩a⇩c⇩h g (ψ (inv⇘G⇙ g) s) = ψ g (ψ (inv⇘G⇙ g) s)›*) is_aut.give_input_closed (*‹⟦?input ∈ A⇧⋆; ?s ∈ S⟧ ⟹ (δ⇧⋆) ?s ?input ∈ S›*) is_aut.init_state_is_a_state (*‹i ∈ S›*) states_a_G_set.bij_prop1 (*‹⟦?g ∈ carrier G; ?y ∈ S⟧ ⟹ ∃!x. x ∈ S ∧ ψ ?g x = ?y›*) states_a_G_set.orbit_sym_aux (*‹⟦?g ∈ carrier G; ?x ∈ S; ψ ?g ?x = ?y⟧ ⟹ ψ (inv⇘G⇙ ?g) ?y = ?x›*))
show " ∃x. (∃w∈A⇧⋆. (δ⇧⋆) i w = x) ∧ (δ⇧⋆) i w = ψ⇩r⇩e⇩a⇩c⇩h g x"
using H2_3 (*‹∃w∈A⇧⋆. (δ⇧⋆) i w = ψ (inv⇘G⇙ g) s›*) H2_6 (*‹(δ⇧⋆) i w = ψ⇩r⇩e⇩a⇩c⇩h g (ψ (inv⇘G⇙ g) s)›*) by blast
qed
show "bij_betw (ψ⇩r⇩e⇩a⇩c⇩h g) S⇩r⇩e⇩a⇩c⇩h S⇩r⇩e⇩a⇩c⇩h"
apply (rule H1_3 (*‹⟦bij_betw (ψ g) S S; ψ⇩r⇩e⇩a⇩c⇩h g ` S⇩r⇩e⇩a⇩c⇩h = S⇩r⇩e⇩a⇩c⇩h; S⇩r⇩e⇩a⇩c⇩h ⊆ S⟧ ⟹ bij_betw (ψ⇩r⇩e⇩a⇩c⇩h g) S⇩r⇩e⇩a⇩c⇩h S⇩r⇩e⇩a⇩c⇩h›*))
(*goal: ‹bij_betw (ψ⇩r⇩e⇩a⇩c⇩h (g::'grp)) S⇩r⇩e⇩a⇩c⇩h S⇩r⇩e⇩a⇩c⇩h›*)
apply (simp add: A1_0 (*‹g ∈ carrier G›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*) states_a_G_set.inj_prop (*‹?g ∈ carrier G ⟹ inj_on (ψ ?g) S›*) states_a_G_set.surj_prop (*‹?g ∈ carrier G ⟹ ψ ?g ` S = S›*))
(*top goal: ‹bij_betw (ψ g) S S› and 2 goals remain*)
apply (clarsimp simp add: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*) H1_0 (*‹?r1 ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ ψ⇩r⇩e⇩a⇩c⇩h g ?r1 ∈ S⇩r⇩e⇩a⇩c⇩h›*))
(*top goal: ‹ψ⇩r⇩e⇩a⇩c⇩h g ` S⇩r⇩e⇩a⇩c⇩h = S⇩r⇩e⇩a⇩c⇩h› and 1 goal remains*)
apply (rule subset_antisym (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); ?B ⊆ ?A⟧ ⟹ ?A = ?B›*); simp add: Set.subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*); clarify)
(*top goal: ‹{y. ∃x∈S⇩r⇩e⇩a⇩c⇩h. y = ψ⇩r⇩e⇩a⇩c⇩h g x} = S⇩r⇩e⇩a⇩c⇩h› and 1 goal remains*)
using H1_0 (*‹(?r1::'states::type) ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ ψ⇩r⇩e⇩a⇩c⇩h (g::'grp::type) ?r1 ∈ S⇩r⇩e⇩a⇩c⇩h›*) apply ((auto)[1])
(*top goal: ‹⋀x xa. xa ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ ψ⇩r⇩e⇩a⇩c⇩h g xa ∈ S⇩r⇩e⇩a⇩c⇩h› and 2 goals remain*)
subgoal for s
apply (clarsimp simp add: reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*))
(*goal: ‹s ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ ∃x∈S⇩r⇩e⇩a⇩c⇩h. s = ψ⇩r⇩e⇩a⇩c⇩h g x›*)
by (simp add: H1_4 (*‹⟦(?s2::'states) = ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (?w2::'alpha list); ∀x::'alpha∈set ?w2. x ∈ A⟧ ⟹ ∃x::'states. (∃w::'alpha list∈A⇧⋆. (δ⇧⋆) i w = x) ∧ (δ⇧⋆) i ?w2 = ψ⇩r⇩e⇩a⇩c⇩h (g::'grp) x›*))
apply (simp add: reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*) Set.subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*); rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*); rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹S⇩r⇩e⇩a⇩c⇩h ⊆ S›*)
using is_aut.give_input_closed (*‹⟦?input ∈ A⇧⋆; ?s ∈ S⟧ ⟹ (δ⇧⋆) ?s ?input ∈ S›*) is_aut.init_state_is_a_state (*‹i ∈ S›*) by auto
qed
have H_2: "group G"
using det_G_aut_rec_lang_axioms (*‹det_G_aut_rec_lang A S i F δ G φ ψ L›*) by (auto simp add: det_G_aut_rec_lang_def (*‹det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ det_aut_rec_lang ?A ?S ?i ?F ?δ ?L›*) det_G_aut_def (*‹det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ (det_aut ?A ?S ?i ?F ?δ ∧ alt_grp_act ?G ?A ?φ ∧ alt_grp_act ?G ?S ?ψ) ∧ eq_var_subset ?G ?S ?ψ ?F ∧ eq_var_subset ?G ?S ?ψ {?i} ∧ eq_var_func ?G (?S × ?A) (λg∈carrier ?G. λ(s, a)∈?S × ?A. (?ψ g s, ?φ g a)) ?S ?ψ (λ(s, a)∈?S × ?A. ?δ s a)›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*))
have H_3: "⋀g. g ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h g ∈ carrier (BijGroup S⇩r⇩e⇩a⇩c⇩h)"
subgoal for g
using reachable_action_def[where g = g] (*‹ψ⇩r⇩e⇩a⇩c⇩h g ?s = (λ(g', s')∈carrier G × S⇩r⇩e⇩a⇩c⇩h. ψ g' s') (g, ?s)›*) apply (simp add: BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) extensional_def (*‹extensional ?A = {f. ∀x. x ∉ ?A ⟶ f x = undefined}›*))
(*goal: ‹g ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h g ∈ carrier (BijGroup S⇩r⇩e⇩a⇩c⇩h)›*)
by (simp add: H_1 (*‹⟦(?g1::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); ⋀s::'states. ψ⇩r⇩e⇩a⇩c⇩h ?g1 s = (if s ∈ S⇩r⇩e⇩a⇩c⇩h then case (?g1, s) of (x::'grp, xa::'states) ⇒ (ψ::'grp ⇒ 'states ⇒ 'states) x xa else undefined)⟧ ⟹ bij_betw (ψ⇩r⇩e⇩a⇩c⇩h ?g1) S⇩r⇩e⇩a⇩c⇩h S⇩r⇩e⇩a⇩c⇩h›*)) .
have H_4: "⋀x y. x ∈ carrier G ⟹ y ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h (x ⊗⇘G⇙ y) = ψ⇩r⇩e⇩a⇩c⇩h x ⊗⇘BijGroup S⇩r⇩e⇩a⇩c⇩h⇙
ψ⇩r⇩e⇩a⇩c⇩h y"
proof (-)
(*goal: ‹⋀x y. ⟦x ∈ carrier G; y ∈ carrier G⟧ ⟹ ψ⇩r⇩e⇩a⇩c⇩h (x ⊗⇘G⇙ y) = ψ⇩r⇩e⇩a⇩c⇩h x ⊗⇘BijGroup S⇩r⇩e⇩a⇩c⇩h⇙ ψ⇩r⇩e⇩a⇩c⇩h y›*)
fix g and h
assume A1_0: "g ∈ carrier G" and A1_1: "h ∈ carrier G" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹(h::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*)
have H1_0: "⋀g . g ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h g = restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h"
using reachable_action_def (*‹ψ⇩r⇩e⇩a⇩c⇩h ?g ?s = (λ(g', s')∈carrier G × S⇩r⇩e⇩a⇩c⇩h. ψ g' s') (?g, ?s)›*) by (auto simp add: restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*))
from H1_0 (*‹(?g1::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme) ⟹ ψ⇩r⇩e⇩a⇩c⇩h ?g1 = restrict ((ψ::'grp ⇒ 'states ⇒ 'states) ?g1) S⇩r⇩e⇩a⇩c⇩h›*) have H1_1: "ψ⇩r⇩e⇩a⇩c⇩h (g ⊗⇘G⇙ h) = restrict (ψ (g ⊗⇘G⇙ h)) S⇩r⇩e⇩a⇩c⇩h"
by (simp add: A1_0 (*‹g ∈ carrier G›*) A1_1 (*‹h ∈ carrier G›*) H_2 (*‹Group.group G›*) group.subgroup_self (*‹Group.group ?G ⟹ subgroup (carrier ?G) ?G›*) subgroup.m_closed (*‹⟦subgroup ?H ?G; ?x ∈ ?H; ?y ∈ ?H⟧ ⟹ ?x ⊗⇘?G⇙ ?y ∈ ?H›*))
have H1_2: "ψ⇩r⇩e⇩a⇩c⇩h g ⊗⇘BijGroup S⇩r⇩e⇩a⇩c⇩h⇙ ψ⇩r⇩e⇩a⇩c⇩h h =
(restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h) ⊗⇘BijGroup S⇩r⇩e⇩a⇩c⇩h⇙
(restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h)"
using A1_0 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A1_1 (*‹h ∈ carrier G›*) H1_0 (*‹?g1 ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h ?g1 = restrict (ψ ?g1) S⇩r⇩e⇩a⇩c⇩h›*) by simp
have H1_3: "⋀g. g ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h g ∈ carrier (BijGroup S⇩r⇩e⇩a⇩c⇩h)"
by (simp add: H_3 (*‹?g1 ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h ?g1 ∈ carrier (BijGroup S⇩r⇩e⇩a⇩c⇩h)›*))
have H1_4: "⋀x y. x∈carrier G ⟹ y∈carrier G ⟹ ψ (x ⊗⇘G⇙ y) = ψ x ⊗⇘BijGroup S⇙ ψ y"
using det_G_aut_axioms (*‹det_G_aut A (S::'states set) (i::'states) (F::'states set) (δ::'states ⇒ 'alpha ⇒ 'states) (G::('grp, 'b) monoid_scheme) (φ::'grp ⇒ 'alpha ⇒ 'alpha) (ψ::'grp ⇒ 'states ⇒ 'states)›*) by (simp add: det_G_aut_def (*‹det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ (det_aut ?A ?S ?i ?F ?δ ∧ alt_grp_act ?G ?A ?φ ∧ alt_grp_act ?G ?S ?ψ) ∧ eq_var_subset ?G ?S ?ψ ?F ∧ eq_var_subset ?G ?S ?ψ {?i} ∧ eq_var_func ?G (?S × ?A) (λg∈carrier ?G. λ(s, a)∈?S × ?A. (?ψ g s, ?φ g a)) ?S ?ψ (λ(s, a)∈?S × ?A. ?δ s a)›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*))
hence H1_5: "ψ (g ⊗⇘G⇙ h) = ψ g ⊗⇘BijGroup S⇙ ψ h"
using A1_0 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A1_1 (*‹h ∈ carrier G›*) by simp
have H1_6: "(λx. if x ∈ S⇩r⇩e⇩a⇩c⇩h
then if (if x ∈ S⇩r⇩e⇩a⇩c⇩h
then ψ h x
else undefined) ∈ S⇩r⇩e⇩a⇩c⇩h
then ψ g (if x ∈ S⇩r⇩e⇩a⇩c⇩h
then ψ h x
else undefined)
else undefined
else undefined) =
(λx. if x ∈ S⇩r⇩e⇩a⇩c⇩h
then ψ g (ψ h x)
else undefined)"
apply (rule meta_mp[of "⋀x. x ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ (ψ h x) ∈ S⇩r⇩e⇩a⇩c⇩h"] (*‹⟦(⋀x::'states. x ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ (ψ::'grp ⇒ 'states ⇒ 'states) (h::'grp) x ∈ S⇩r⇩e⇩a⇩c⇩h) ⟹ PROP ?Q::prop; ⋀x::'states. x ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ ψ h x ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ PROP ?Q›*))
(*goal: ‹(λx. if x ∈ S⇩r⇩e⇩a⇩c⇩h then if (if x ∈ S⇩r⇩e⇩a⇩c⇩h then ψ h x else undefined) ∈ S⇩r⇩e⇩a⇩c⇩h then ψ g (if x ∈ S⇩r⇩e⇩a⇩c⇩h then ψ h x else undefined) else undefined else undefined) = (λx. if x ∈ S⇩r⇩e⇩a⇩c⇩h then ψ g (ψ h x) else undefined)›*)
using H1_3[where g1 = h] (*‹h ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h h ∈ carrier (BijGroup S⇩r⇩e⇩a⇩c⇩h)›*) A1_1 (*‹h ∈ carrier G›*) H1_0 (*‹?g1 ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h ?g1 = restrict (ψ ?g1) S⇩r⇩e⇩a⇩c⇩h›*) apply -
(*goals:
1. ‹⟦⋀x. x ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ ψ h x ∈ S⇩r⇩e⇩a⇩c⇩h; h ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h h ∈ carrier (BijGroup S⇩r⇩e⇩a⇩c⇩h); h ∈ carrier G; ⋀g. g ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h g = restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (λx. if x ∈ S⇩r⇩e⇩a⇩c⇩h then if (if x ∈ S⇩r⇩e⇩a⇩c⇩h then ψ h x else undefined) ∈ S⇩r⇩e⇩a⇩c⇩h then ψ g (if x ∈ S⇩r⇩e⇩a⇩c⇩h then ψ h x else undefined) else undefined else undefined) = (λx. if x ∈ S⇩r⇩e⇩a⇩c⇩h then ψ g (ψ h x) else undefined)›
2. ‹⋀x. ⟦x ∈ S⇩r⇩e⇩a⇩c⇩h; h ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h h ∈ carrier (BijGroup S⇩r⇩e⇩a⇩c⇩h); h ∈ carrier G; ⋀g. g ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h g = restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ ψ h x ∈ S⇩r⇩e⇩a⇩c⇩h›
discuss goal 1*)
apply ((auto simp add: A1_1 (*‹h ∈ carrier G›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*))[1])
(*discuss goal 2*)
apply ((auto simp add: A1_1 (*‹h ∈ carrier G›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*))[1])
(*proven 2 subgoals*) .
have H1_7: "... = (λx. if x ∈ S⇩r⇩e⇩a⇩c⇩h
then if x ∈ S
then ψ g (ψ h x)
else undefined
else undefined)"
apply (clarsimp simp add: reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*))
(*goal: ‹(λx. if x ∈ S⇩r⇩e⇩a⇩c⇩h then ψ g (ψ h x) else undefined) = (λx. if x ∈ S⇩r⇩e⇩a⇩c⇩h then if x ∈ S then ψ g (ψ h x) else undefined else undefined)›*)
by (metis is_aut.give_input_closed (*‹⟦(?input::'alpha list) ∈ A⇧⋆; (?s::'states) ∈ (S::'states set)⟧ ⟹ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) ?s ?input ∈ S›*) is_aut.init_state_is_a_state (*‹(i::'states) ∈ (S::'states set)›*))
have H1_8: "(restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h) ⊗⇘BijGroup S⇩r⇩e⇩a⇩c⇩h⇙ (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h) =
restrict (ψ (g ⊗⇘G⇙ h)) S⇩r⇩e⇩a⇩c⇩h"
apply (rule meta_mp[of "⋀g. g ∈ carrier G ⟹ restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ∧
ψ g ∈ Bij S" ] (*‹⟦(⋀g. g ∈ carrier G ⟹ restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ∧ ψ g ∈ Bij S) ⟹ PROP ?Q; ⋀g. g ∈ carrier G ⟹ restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ∧ ψ g ∈ Bij S⟧ ⟹ PROP ?Q›*))
(*goal: ‹restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ⊗⇘BijGroup S⇩r⇩e⇩a⇩c⇩h⇙ restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h = restrict (ψ (g ⊗⇘G⇙ h)) S⇩r⇩e⇩a⇩c⇩h›*)
apply (clarsimp simp add: H1_5 (*‹ψ (g ⊗⇘G⇙ h) = ψ g ⊗⇘BijGroup S⇙ ψ h›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*); intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); intro impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*top goal: ‹(⋀g. g ∈ carrier G ⟹ restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ∧ ψ g ∈ Bij S) ⟹ restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ⊗⇘BijGroup S⇩r⇩e⇩a⇩c⇩h⇙ restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h = restrict (ψ (g ⊗⇘G⇙ h)) S⇩r⇩e⇩a⇩c⇩h› and 1 goal remains*)
subgoal for
using A1_0 (*‹g ∈ carrier G›*) A1_1 (*‹h ∈ carrier G›*) apply (clarsimp simp add: compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*) restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*))
(*goal: ‹⟦⋀g. g ∈ carrier G ⟹ restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ∧ ψ g ∈ Bij S; ψ h ∈ Bij S⟧ ⟹ (ψ g ∈ Bij S ⟶ (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ compose S⇩r⇩e⇩a⇩c⇩h (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h) (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h) = restrict (compose S (ψ g) (ψ h)) S⇩r⇩e⇩a⇩c⇩h) ∧ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∉ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ undefined (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h) = restrict (compose S (ψ g) (ψ h)) S⇩r⇩e⇩a⇩c⇩h)) ∧ (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h ∉ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ undefined = restrict (compose S (ψ g) (ψ h)) S⇩r⇩e⇩a⇩c⇩h) ∧ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∉ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ undefined (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h) = restrict (compose S (ψ g) (ψ h)) S⇩r⇩e⇩a⇩c⇩h))) ∧ (ψ g ∉ Bij S ⟶ (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ compose S⇩r⇩e⇩a⇩c⇩h (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h) (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h) = restrict (undefined (ψ h)) S⇩r⇩e⇩a⇩c⇩h) ∧ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∉ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ undefined (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h) = restrict (undefined (ψ h)) S⇩r⇩e⇩a⇩c⇩h)) ∧ (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h ∉ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ undefined = restrict (undefined (ψ h)) S⇩r⇩e⇩a⇩c⇩h) ∧ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∉ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ undefined (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h) = restrict (undefined (ψ h)) S⇩r⇩e⇩a⇩c⇩h)))›*)
by (simp add: H1_6 (*‹(λx. if x ∈ S⇩r⇩e⇩a⇩c⇩h then if (if x ∈ S⇩r⇩e⇩a⇩c⇩h then ψ h x else undefined) ∈ S⇩r⇩e⇩a⇩c⇩h then ψ g (if x ∈ S⇩r⇩e⇩a⇩c⇩h then ψ h x else undefined) else undefined else undefined) = (λx. if x ∈ S⇩r⇩e⇩a⇩c⇩h then ψ g (ψ h x) else undefined)›*) H1_7 (*‹(λx. if x ∈ S⇩r⇩e⇩a⇩c⇩h then ψ g (ψ h x) else undefined) = (λx. if x ∈ S⇩r⇩e⇩a⇩c⇩h then if x ∈ S then ψ g (ψ h x) else undefined else undefined)›*))
apply ((simp add: A1_0 (*‹g ∈ carrier G›*) A1_1 (*‹h ∈ carrier G›*))+)
(*top goal: ‹⟦⋀g. g ∈ carrier G ⟹ restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ∧ ψ g ∈ Bij S; ψ h ∉ Bij S⟧ ⟹ (ψ g ∈ Bij S ⟶ (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ compose S⇩r⇩e⇩a⇩c⇩h (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h) (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h) = restrict undefined S⇩r⇩e⇩a⇩c⇩h) ∧ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∉ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ undefined (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h) = restrict undefined S⇩r⇩e⇩a⇩c⇩h)) ∧ (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h ∉ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ undefined = restrict undefined S⇩r⇩e⇩a⇩c⇩h) ∧ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∉ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ undefined (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h) = restrict undefined S⇩r⇩e⇩a⇩c⇩h))) ∧ (ψ g ∉ Bij S ⟶ (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ compose S⇩r⇩e⇩a⇩c⇩h (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h) (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h) = restrict (undefined (ψ h)) S⇩r⇩e⇩a⇩c⇩h) ∧ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∉ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ undefined (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h) = restrict (undefined (ψ h)) S⇩r⇩e⇩a⇩c⇩h)) ∧ (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h ∉ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∈ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ undefined = restrict (undefined (ψ h)) S⇩r⇩e⇩a⇩c⇩h) ∧ (restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ∉ Bij S⇩r⇩e⇩a⇩c⇩h ⟶ undefined (restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h) = restrict (undefined (ψ h)) S⇩r⇩e⇩a⇩c⇩h)))› and 1 goal remains*)
subgoal for g
using H1_3[where g1 = g] (*‹g ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h g ∈ carrier (BijGroup S⇩r⇩e⇩a⇩c⇩h)›*) H1_0[of g] (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme) ⟹ ψ⇩r⇩e⇩a⇩c⇩h g = restrict ((ψ::'grp ⇒ 'states ⇒ 'states) g) S⇩r⇩e⇩a⇩c⇩h›*) by (simp add: BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) states_a_G_set.bij_prop0 (*‹?g ∈ carrier G ⟹ ψ ?g ∈ Bij S›*)) .
show "ψ⇩r⇩e⇩a⇩c⇩h (g ⊗⇘G⇙ h) =
ψ⇩r⇩e⇩a⇩c⇩h g ⊗⇘BijGroup S⇩r⇩e⇩a⇩c⇩h⇙ ψ⇩r⇩e⇩a⇩c⇩h h"
by (simp add: H1_1 (*‹ψ⇩r⇩e⇩a⇩c⇩h (g ⊗⇘G⇙ h) = restrict (ψ (g ⊗⇘G⇙ h)) S⇩r⇩e⇩a⇩c⇩h›*) H1_2 (*‹ψ⇩r⇩e⇩a⇩c⇩h g ⊗⇘BijGroup S⇩r⇩e⇩a⇩c⇩h⇙ ψ⇩r⇩e⇩a⇩c⇩h h = restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ⊗⇘BijGroup S⇩r⇩e⇩a⇩c⇩h⇙ restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h›*) H1_8 (*‹restrict (ψ g) S⇩r⇩e⇩a⇩c⇩h ⊗⇘BijGroup S⇩r⇩e⇩a⇩c⇩h⇙ restrict (ψ h) S⇩r⇩e⇩a⇩c⇩h = restrict (ψ (g ⊗⇘G⇙ h)) S⇩r⇩e⇩a⇩c⇩h›*))
qed
have H_5: "⋀w' w g. g ∈ carrier G ⟹
(δ⇧⋆) i w ∈ F ⟹ ∀x∈set w. x ∈ A ⟹ (δ⇧⋆) i w' = (δ⇧⋆) i w ⟹ ∀x∈set w'. x ∈ A ⟹
∃w'∈ A⇧⋆. (δ⇧⋆) i w' = ψ g ((δ⇧⋆) i w)"
proof (-)
(*goal: ‹⋀w' w g. ⟦g ∈ carrier G; (δ⇧⋆) i w ∈ F; ∀x∈set w. x ∈ A; (δ⇧⋆) i w' = (δ⇧⋆) i w; ∀x∈set w'. x ∈ A⟧ ⟹ ∃w'∈A⇧⋆. (δ⇧⋆) i w' = ψ g ((δ⇧⋆) i w)›*)
fix w' and w and g
assume A1_0: "g ∈ carrier G" and A1_1: "(δ⇧⋆) i w ∈ F" and A1_2: "∀x∈set w. x ∈ A" and A1_3: "(δ⇧⋆) i w' = (δ⇧⋆) i w" and A1_4: "∀x∈set w. x ∈ A" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w::'alpha list) ∈ (F::'states set)› ‹∀x::'alpha∈set (w::'alpha list). x ∈ A› ‹((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w'::'alpha list) = (δ⇧⋆) i (w::'alpha list)› ‹∀x::'alpha∈set (w::'alpha list). x ∈ A›*)
from A1_1 (*‹(δ⇧⋆) i w ∈ F›*) A1_2 (*‹∀x::'alpha∈set (w::'alpha list). x ∈ A›*) have H1_0: "((δ⇧⋆) i w) ∈ S⇩r⇩e⇩a⇩c⇩h"
using reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*) by auto
have H1_1: "ψ g ((δ⇧⋆) i w) = ((δ⇧⋆) i ((φ⇧⋆) g w))"
using give_input_eq_var (*‹eq_var_func G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)) S ψ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w)›*) apply (clarsimp simp add: eq_var_func_def (*‹eq_var_func (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'Y set) (?ψ::?'grp ⇒ ?'Y ⇒ ?'Y) (?f::?'X ⇒ ?'Y) ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*) eq_var_func_axioms_def (*‹eq_var_func_axioms (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'Y set) (?ψ::?'grp ⇒ ?'Y ⇒ ?'Y) (?f::?'X ⇒ ?'Y) ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀(a::?'X) g::?'grp. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*) simp del: GMN_simps (*‹(⊙⇘?φ::?'grp ⇒ ?'X ⇒ ?'X⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹(?func::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆ = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map (?func::'grp ⇒ 'states ⇒ 'states) = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) ((S::'states set)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map (?func::'grp ⇒ 'states × 'alpha ⇒ 'states × 'alpha) = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) (((S::'states set) × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map (?S::?'Y set) (?func::'grp ⇒ ?'Y ⇒ ?'Y) (?R::(?'Y × ?'Y) set) = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). λx::?'Y set∈?S // ?R. ?R `` {?func g (SOME z::?'Y. z ∈ x)})›*))
(*goal: ‹ψ g ((δ⇧⋆) i w) = (δ⇧⋆) i ((φ⇧⋆) g w)›*)
using A1_0 (*‹g ∈ carrier G›*) A1_2 (*‹∀x∈set w. x ∈ A›*) action_on_input (*‹⟦(?g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); (?w::'alpha list) ∈ A⇧⋆⟧ ⟹ (ψ::'grp ⇒ 'states ⇒ 'states) ?g (((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) ?w) = (δ⇧⋆) i (((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) ?g ?w)›*) by blast
have H1_2: "(φ⇧⋆) g w ∈ A⇧⋆"
using A1_0 (*‹g ∈ carrier G›*) A1_2 (*‹∀x∈set w. x ∈ A›*) by (metis in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) group_action.element_image (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?y ∈ ?E›*) labels_a_G_set.lists_a_Gset (*‹alt_grp_act G (A⇧⋆) (φ⇧⋆)›*))
show "∃wa∈A⇧⋆. (δ⇧⋆) i wa = ψ g ((δ⇧⋆) i w)"
by (metis H1_1 (*‹ψ g ((δ⇧⋆) i w) = (δ⇧⋆) i ((φ⇧⋆) g w)›*) H1_2 (*‹(φ⇧⋆) g w ∈ A⇧⋆›*))
qed
have H_6: "alt_grp_act G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h"
apply (clarsimp simp add: group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*))
(*goal: ‹alt_grp_act G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹Group.group (G::('grp, 'b) monoid_scheme) ∧ Group.group (BijGroup S⇩r⇩e⇩a⇩c⇩h) ∧ ψ⇩r⇩e⇩a⇩c⇩h ∈ carrier G → carrier (BijGroup S⇩r⇩e⇩a⇩c⇩h) ∧ (∀x::'grp∈carrier G. ∀y::'grp∈carrier G. ψ⇩r⇩e⇩a⇩c⇩h (x ⊗⇘G⇙ y) = ψ⇩r⇩e⇩a⇩c⇩h x ⊗⇘BijGroup S⇩r⇩e⇩a⇩c⇩h⇙ ψ⇩r⇩e⇩a⇩c⇩h y)›*)
apply (simp add: H_2 (*‹Group.group (G::('grp, 'b) monoid_scheme)›*))
(*top goal: ‹Group.group G› and 3 goals remain*)
subgoal for
by (simp add: group_BijGroup (*‹Group.group (BijGroup ?S)›*))
(*goals:
1. ‹ψ⇩r⇩e⇩a⇩c⇩h ∈ carrier G → carrier (BijGroup S⇩r⇩e⇩a⇩c⇩h)›
2. ‹∀x∈carrier G. ∀y∈carrier G. ψ⇩r⇩e⇩a⇩c⇩h (x ⊗⇘G⇙ y) = ψ⇩r⇩e⇩a⇩c⇩h x ⊗⇘BijGroup S⇩r⇩e⇩a⇩c⇩h⇙ ψ⇩r⇩e⇩a⇩c⇩h y›
discuss goal 1*)
apply clarify
(*top goal: ‹ψ⇩r⇩e⇩a⇩c⇩h ∈ carrier G → carrier (BijGroup S⇩r⇩e⇩a⇩c⇩h)› and 1 goal remains*)
apply (simp add: H_3 (*‹?g1 ∈ carrier G ⟹ ψ⇩r⇩e⇩a⇩c⇩h ?g1 ∈ carrier (BijGroup S⇩r⇩e⇩a⇩c⇩h)›*))
(*discuss goal 2*)
apply (simp add: H_4 (*‹⟦(?x1::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); (?y1::'grp) ∈ carrier G⟧ ⟹ ψ⇩r⇩e⇩a⇩c⇩h (?x1 ⊗⇘G⇙ ?y1) = ψ⇩r⇩e⇩a⇩c⇩h ?x1 ⊗⇘BijGroup S⇩r⇩e⇩a⇩c⇩h⇙ ψ⇩r⇩e⇩a⇩c⇩h ?y1›*))
(*proven 2 subgoals*) .
have H_7: "⋀g w. g ∈ carrier G ⟹ (δ⇧⋆) i w ∈ F ⟹ ∀x∈set w. x ∈ A ⟹
∃x. x ∈ F ∧ (∃w∈A⇧⋆. (δ⇧⋆) i w = x) ∧ (δ⇧⋆) i w = ψ g x"
proof (-)
(*goal: ‹⋀g w. ⟦g ∈ carrier G; (δ⇧⋆) i w ∈ F; ∀x∈set w. x ∈ A⟧ ⟹ ∃x. x ∈ F ∧ (∃w∈A⇧⋆. (δ⇧⋆) i w = x) ∧ (δ⇧⋆) i w = ψ g x›*)
fix g and w
assume A1_0: "g ∈ carrier G" and A1_1: "(δ⇧⋆) i w ∈ F" and A1_2: "∀x∈set w. x ∈ A" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w::'alpha list) ∈ (F::'states set)› ‹∀x::'alpha∈set (w::'alpha list). x ∈ A›*)
have H1_0: "(inv ⇘G⇙ g) ∈ carrier G"
by (meson A1_0 (*‹g ∈ carrier G›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group_hom.axioms( (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) 1) labels_a_G_set.group_hom (*‹group_hom G (BijGroup A) φ›*))
have H1_1: "((δ⇧⋆) i w) ∈ S⇩r⇩e⇩a⇩c⇩h"
using A1_1 (*‹(δ⇧⋆) i w ∈ F›*) A1_2 (*‹∀x∈set w. x ∈ A›*) reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*) by auto
have H1_2: "ψ⇩r⇩e⇩a⇩c⇩h (inv ⇘G⇙ g) ((δ⇧⋆) i w) = ψ (inv ⇘G⇙ g) ((δ⇧⋆) i w)"
apply (rule reachable_action_is_restict (*‹⟦(?g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); (?s::'states) ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ ψ⇩r⇩e⇩a⇩c⇩h ?g ?s = (ψ::'grp ⇒ 'states ⇒ 'states) ?g ?s›*))
(*goal: ‹ψ⇩r⇩e⇩a⇩c⇩h (inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp)) (((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w::'alpha list)) = (ψ::'grp ⇒ 'states ⇒ 'states) (inv⇘G⇙ g) ((δ⇧⋆) i w)›*)
using H1_0 (*‹inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp::type) ∈ carrier G›*) H1_1 (*‹(δ⇧⋆) i w ∈ S⇩r⇩e⇩a⇩c⇩h›*) apply -
(*goals:
1. ‹⟦inv⇘G⇙ g ∈ carrier G; (δ⇧⋆) i w ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ inv⇘G⇙ g ∈ carrier G›
2. ‹⟦inv⇘G⇙ g ∈ carrier G; (δ⇧⋆) i w ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (δ⇧⋆) i w ∈ S⇩r⇩e⇩a⇩c⇩h›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
have H1_3: "ψ⇩r⇩e⇩a⇩c⇩h g (ψ (inv ⇘G⇙ g) ((δ⇧⋆) i w)) = ((δ⇧⋆) i w)"
by (smt (verit) A1_0 (*‹g ∈ carrier G›*) H1_1 (*‹(δ⇧⋆) i w ∈ S⇩r⇩e⇩a⇩c⇩h›*) H_6 (*‹alt_grp_act G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h›*) H1_2 (*‹ψ⇩r⇩e⇩a⇩c⇩h (inv⇘G⇙ g) ((δ⇧⋆) i w) = ψ (inv⇘G⇙ g) ((δ⇧⋆) i w)›*) alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) group_action.bij_prop1 (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?y ∈ ?E⟧ ⟹ ∃!x. x ∈ ?E ∧ ?φ ?g x = ?y›*) group_action.orbit_sym_aux (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?φ (inv⇘?G⇙ ?g) ?y = ?x›*))
have H1_4: "ψ (inv ⇘G⇙ g) ((δ⇧⋆) i w) ∈ F"
using A1_1 (*‹(δ⇧⋆) i w ∈ F›*) H1_0 (*‹inv⇘G⇙ g ∈ carrier G›*) accepting_is_eq_var.is_equivar (*‹∀g::'grp∈carrier (G::('grp, 'b) monoid_scheme). (ψ::'grp ⇒ 'states ⇒ 'states) g ` (F::'states set) = F›*) by blast
have H1_5: "ψ (inv ⇘G⇙ g) ((δ⇧⋆) i w) ∈ F ∧ (δ⇧⋆) i w = ψ g (ψ (inv ⇘G⇙ g) ((δ⇧⋆) i w))"
using H1_4 (*‹(ψ::'grp ⇒ 'states ⇒ 'states) (inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp)) (((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w::'alpha list)) ∈ (F::'states set)›*) H1_3 (*‹ψ⇩r⇩e⇩a⇩c⇩h (g::'grp) ((ψ::'grp ⇒ 'states ⇒ 'states) (inv⇘G::('grp, 'b) monoid_scheme⇙ g) (((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w::'alpha list))) = (δ⇧⋆) i w›*) A1_0 (*‹g ∈ carrier G›*) A1_1 (*‹(δ⇧⋆) i w ∈ F›*) H1_0 (*‹inv⇘G⇙ g ∈ carrier G›*) H1_1 (*‹(δ⇧⋆) i w ∈ S⇩r⇩e⇩a⇩c⇩h›*) reachable_action_is_restict (*‹⟦(?g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); (?s::'states) ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ ψ⇩r⇩e⇩a⇩c⇩h ?g ?s = (ψ::'grp ⇒ 'states ⇒ 'states) ?g ?s›*) by (metis H_6 (*‹alt_grp_act G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h›*) alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) group_action.element_image (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?y ∈ ?E›*))
have H1_6: "ψ (inv ⇘G⇙ g) ((δ⇧⋆) i w) = ((δ⇧⋆) i ((φ⇧⋆) (inv ⇘G⇙ g) w))"
using give_input_eq_var (*‹eq_var_func G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)) S ψ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w)›*) apply (clarsimp simp add: eq_var_func_def (*‹eq_var_func (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'Y set) (?ψ::?'grp ⇒ ?'Y ⇒ ?'Y) (?f::?'X ⇒ ?'Y) ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*) eq_var_func_axioms_def (*‹eq_var_func_axioms (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'Y set) (?ψ::?'grp ⇒ ?'Y ⇒ ?'Y) (?f::?'X ⇒ ?'Y) ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀(a::?'X) g::?'grp. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*) simp del: GMN_simps (*‹(⊙⇘?φ::?'grp ⇒ ?'X ⇒ ?'X⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹(?func::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆ = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map (?func::'grp ⇒ 'states ⇒ 'states) = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) ((S::'states set)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map (?func::'grp ⇒ 'states × 'alpha ⇒ 'states × 'alpha) = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) (((S::'states set) × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map (?S::?'Y set) (?func::'grp ⇒ ?'Y ⇒ ?'Y) (?R::(?'Y × ?'Y) set) = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). λx::?'Y set∈?S // ?R. ?R `` {?func g (SOME z::?'Y. z ∈ x)})›*))
(*goal: ‹(ψ::'grp ⇒ 'states ⇒ 'states) (inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp)) (((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w::'alpha list)) = (δ⇧⋆) i (((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) (inv⇘G⇙ g) w)›*)
using A1_2 (*‹∀x::'alpha∈set (w::'alpha list). x ∈ A›*) H1_0 (*‹inv⇘G⇙ g ∈ carrier G›*) action_on_input (*‹⟦?g ∈ carrier G; ?w ∈ A⇧⋆⟧ ⟹ ψ ?g ((δ⇧⋆) i ?w) = (δ⇧⋆) i ((φ⇧⋆) ?g ?w)›*) by blast
have H1_7: "(φ⇧⋆) (inv ⇘G⇙ g) w ∈ A⇧⋆"
by (metis A1_2 (*‹∀x∈set w. x ∈ A›*) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) H1_0 (*‹inv⇘G⇙ g ∈ carrier G›*) alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) group_action.element_image (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?y ∈ ?E›*) labels_a_G_set.lists_a_Gset (*‹alt_grp_act G (A⇧⋆) (φ⇧⋆)›*))
thus "∃x. x ∈ F ∧ (∃w∈A⇧⋆. (δ⇧⋆) i w = x) ∧ (δ⇧⋆) i w = ψ g x"
using H1_5 (*‹ψ (inv⇘G⇙ g) ((δ⇧⋆) i w) ∈ F ∧ (δ⇧⋆) i w = ψ g (ψ (inv⇘G⇙ g) ((δ⇧⋆) i w))›*) H1_6 (*‹ψ (inv⇘G⇙ g) ((δ⇧⋆) i w) = (δ⇧⋆) i ((φ⇧⋆) (inv⇘G⇙ g) w)›*) H1_7 (*‹(φ⇧⋆) (inv⇘G⇙ g) w ∈ A⇧⋆›*) by metis
qed
have H_8: "⋀r a g . r ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ a ∈ A ⟹ ψ⇩r⇩e⇩a⇩c⇩h g r ∈ S⇩r⇩e⇩a⇩c⇩h ∧ φ g a ∈ A ⟹ g ∈ carrier G ⟹
δ⇩r⇩e⇩a⇩c⇩h (ψ⇩r⇩e⇩a⇩c⇩h g r) (φ g a) = ψ⇩r⇩e⇩a⇩c⇩h g (δ⇩r⇩e⇩a⇩c⇩h r a)"
proof (-)
(*goal: ‹⋀r a g. ⟦r ∈ S⇩r⇩e⇩a⇩c⇩h; a ∈ A; ψ⇩r⇩e⇩a⇩c⇩h g r ∈ S⇩r⇩e⇩a⇩c⇩h ∧ φ g a ∈ A; g ∈ carrier G⟧ ⟹ δ⇩r⇩e⇩a⇩c⇩h (ψ⇩r⇩e⇩a⇩c⇩h g r) (φ g a) = ψ⇩r⇩e⇩a⇩c⇩h g (δ⇩r⇩e⇩a⇩c⇩h r a)›*)
fix r and a and g
assume A1_0: "r ∈ S⇩r⇩e⇩a⇩c⇩h" and A1_1: "a ∈ A" and A1_2: "ψ⇩r⇩e⇩a⇩c⇩h g r ∈ S⇩r⇩e⇩a⇩c⇩h ∧ φ g a ∈ A" and A1_3: "g ∈ carrier G" (*‹(r::'states) ∈ S⇩r⇩e⇩a⇩c⇩h› ‹(a::'alpha) ∈ A› ‹ψ⇩r⇩e⇩a⇩c⇩h (g::'grp) (r::'states) ∈ S⇩r⇩e⇩a⇩c⇩h ∧ (φ::'grp ⇒ 'alpha ⇒ 'alpha) g (a::'alpha) ∈ A› ‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*)
have H1_0: "r ∈ S ∧ ψ g r ∈ S"
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹r ∈ S ∧ ψ g r ∈ S›*)
subgoal for
using A1_0 (*‹(r::'states) ∈ S⇩r⇩e⇩a⇩c⇩h›*) apply (clarsimp simp add: reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s::'states. ∃w::'alpha list∈A⇧⋆. ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = s}›*))
(*goal: ‹r ∈ S›*)
by (simp add: in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) is_aut.give_input_closed (*‹⟦?input ∈ A⇧⋆; ?s ∈ S⟧ ⟹ (δ⇧⋆) ?s ?input ∈ S›*) is_aut.init_state_is_a_state (*‹i ∈ S›*))
using ‹r ∈ S› (*‹r ∈ S›*) A1_3 (*‹g ∈ carrier G›*) states_a_G_set.element_image (*‹⟦(?g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme); (?x::'states::type) ∈ (S::'states::type set); (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) ?g ?x = (?y::'states::type)⟧ ⟹ ?y ∈ S›*) by blast
have H1_1: "⋀a b g . a ∈ S ∧ b ∈ A ⟹ g ∈ carrier G ⟹
(if ψ g a ∈ S ∧ φ g b ∈ A then δ (ψ g a) (φ g b) else undefined) =
ψ g (δ a b)"
using det_G_aut_axioms (*‹det_G_aut A (S::'states set) (i::'states) (F::'states set) (δ::'states ⇒ 'alpha ⇒ 'states) (G::('grp, 'b) monoid_scheme) (φ::'grp ⇒ 'alpha ⇒ 'alpha) (ψ::'grp ⇒ 'states ⇒ 'states)›*) A1_0 (*‹r ∈ S⇩r⇩e⇩a⇩c⇩h›*) A1_1 (*‹(a::'alpha::type) ∈ A›*) A1_3 (*‹g ∈ carrier G›*) apply (clarsimp simp add: det_G_aut_def (*‹det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ (det_aut ?A ?S ?i ?F ?δ ∧ alt_grp_act ?G ?A ?φ ∧ alt_grp_act ?G ?S ?ψ) ∧ eq_var_subset ?G ?S ?ψ ?F ∧ eq_var_subset ?G ?S ?ψ {?i} ∧ eq_var_func ?G (?S × ?A) (λg∈carrier ?G. λ(s, a)∈?S × ?A. (?ψ g s, ?φ g a)) ?S ?ψ (λ(s, a)∈?S × ?A. ?δ s a)›*) eq_var_func_def (*‹eq_var_func ?G ?X ?φ ?Y ?ψ ?f ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*) eq_var_func_axioms_def (*‹eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀a g. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*))
(*goal: ‹⋀(a::'states) (b::'alpha) g::'grp. ⟦a ∈ (S::'states set) ∧ b ∈ A; g ∈ carrier (G::('grp, 'b) monoid_scheme)⟧ ⟹ (if (ψ::'grp ⇒ 'states ⇒ 'states) g a ∈ S ∧ (φ::'grp ⇒ 'alpha ⇒ 'alpha) g b ∈ A then (δ::'states ⇒ 'alpha ⇒ 'states) (ψ g a) (φ g b) else undefined) = ψ g (δ a b)›*)
by presburger
hence H1_2: "ψ g (δ r a) = (δ (ψ g r) (φ g a))"
using H1_1[where a1 = r and b1 = a and g1 = g] (*‹⟦r ∈ S ∧ a ∈ A; g ∈ carrier G⟧ ⟹ (if ψ g r ∈ S ∧ φ g a ∈ A then δ (ψ g r) (φ g a) else undefined) = ψ g (δ r a)›*) H1_0 (*‹r ∈ S ∧ ψ g r ∈ S›*) A1_1 (*‹a ∈ A›*) A1_2 (*‹ψ⇩r⇩e⇩a⇩c⇩h (g::'grp) (r::'states) ∈ S⇩r⇩e⇩a⇩c⇩h ∧ (φ::'grp ⇒ 'alpha ⇒ 'alpha) g (a::'alpha) ∈ A›*) A1_3 (*‹g ∈ carrier G›*) by simp
have H1_3: "⋀a w. a ∈ A ⟹ w ∈ A⇧⋆ ⟹ ∃w'∈ A⇧⋆. (δ⇧⋆) i w' = δ ((δ⇧⋆) i w) a"
proof (-)
(*goal: ‹⋀a w. ⟦a ∈ A; w ∈ A⇧⋆⟧ ⟹ ∃w'∈A⇧⋆. (δ⇧⋆) i w' = δ ((δ⇧⋆) i w) a›*)
fix a and w
assume A2_0: "a ∈ A" and A2_1: "w ∈ A⇧⋆" (*‹(a::'alpha) ∈ A› ‹(w::'alpha list) ∈ A⇧⋆›*)
have H2_0: "(w @ [a]) ∈ A⇧⋆ ∧ (w @ [a]) ∈ A⇧⋆ ⟹ (δ⇧⋆) i (w @ [a]) = δ ((δ⇧⋆) i w) a"
by (simp add: is_aut.give_input_closed (*‹⟦?input ∈ A⇧⋆; ?s ∈ S⟧ ⟹ (δ⇧⋆) ?s ?input ∈ S›*) is_aut.trans_to_charact (*‹⟦?s ∈ S; ?a ∈ A; ?w ∈ A⇧⋆; ?s = (δ⇧⋆) ?i ?w⟧ ⟹ (δ⇧⋆) ?i (?w @ [?a]) = δ ?s ?a›*) is_aut.init_state_is_a_state (*‹i ∈ S›*))
show "∃w'∈A⇧⋆. (δ⇧⋆) i w' = δ ((δ⇧⋆) i w) a"
using H2_0 (*‹(w::'alpha list) @ [a::'alpha] ∈ A⇧⋆ ∧ w @ [a] ∈ A⇧⋆ ⟹ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w @ [a]) = δ ((δ⇧⋆) i w) a›*) apply clarsimp
(*goal: ‹∃w'∈A⇧⋆. (δ⇧⋆) i w' = δ ((δ⇧⋆) i w) a›*)
by (metis A2_0 (*‹a ∈ A›*) A2_1 (*‹w ∈ A⇧⋆›*) append_in_lists_conv (*‹(?xs @ ?ys ∈ ?A⇧⋆) = (?xs ∈ ?A⇧⋆ ∧ ?ys ∈ ?A⇧⋆)›*) lists.Cons (*‹⟦?a ∈ ?A; ?l ∈ ?A⇧⋆⟧ ⟹ ?a # ?l ∈ ?A⇧⋆›*) lists.Nil (*‹[] ∈ ?A⇧⋆›*))
qed
have H1_4: "ψ⇩r⇩e⇩a⇩c⇩h g (δ⇩r⇩e⇩a⇩c⇩h r a) = ψ g (δ r a)"
apply (clarsimp simp add: reachable_action_def (*‹ψ⇩r⇩e⇩a⇩c⇩h ?g ?s = (λ(g', s')∈carrier G × S⇩r⇩e⇩a⇩c⇩h. ψ g' s') (?g, ?s)›*) reachable_trans_def (*‹δ⇩r⇩e⇩a⇩c⇩h ?s ?a = (λ(s', a')∈S⇩r⇩e⇩a⇩c⇩h × A. δ s' a') (?s, ?a)›*))
(*goal: ‹ψ⇩r⇩e⇩a⇩c⇩h g (δ⇩r⇩e⇩a⇩c⇩h r a) = ψ g (δ r a)›*)
using A1_0 (*‹r ∈ S⇩r⇩e⇩a⇩c⇩h›*) A1_1 (*‹(a::'alpha) ∈ A›*) A1_3 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) H1_0 (*‹r ∈ S ∧ ψ g r ∈ S›*) H1_3 (*‹⟦?a1 ∈ A; ?w1 ∈ A⇧⋆⟧ ⟹ ∃w'∈A⇧⋆. (δ⇧⋆) i w' = δ ((δ⇧⋆) i ?w1) ?a1›*) using reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s::'states::type. ∃w::'alpha::type list∈A⇧⋆. ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) w = s}›*) by fastforce
have H1_5: "ψ g r = ψ⇩r⇩e⇩a⇩c⇩h g r"
using A1_0 (*‹(r::'states::type) ∈ S⇩r⇩e⇩a⇩c⇩h›*) A1_3 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) by (auto simp add: reachable_action_def (*‹ψ⇩r⇩e⇩a⇩c⇩h ?g ?s = (λ(g', s')∈carrier G × S⇩r⇩e⇩a⇩c⇩h. ψ g' s') (?g, ?s)›*))
hence H1_6: "ψ g r ∈ S⇩r⇩e⇩a⇩c⇩h"
using A1_2 (*‹ψ⇩r⇩e⇩a⇩c⇩h (g::'grp::type) (r::'states::type) ∈ S⇩r⇩e⇩a⇩c⇩h ∧ (φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type) g (a::'alpha::type) ∈ A›*) by simp
have H1_7: "δ⇩r⇩e⇩a⇩c⇩h (ψ⇩r⇩e⇩a⇩c⇩h g r) (φ g a) = δ (ψ g r) (φ g a)"
using A1_0 (*‹(r::'states) ∈ S⇩r⇩e⇩a⇩c⇩h›*) A1_1 (*‹a ∈ A›*) A1_2 (*‹ψ⇩r⇩e⇩a⇩c⇩h (g::'grp::type) (r::'states::type) ∈ S⇩r⇩e⇩a⇩c⇩h ∧ (φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type) g (a::'alpha::type) ∈ A›*) A1_3 (*‹g ∈ carrier G›*) by (auto simp del: simp add:reachable_trans_def (*‹δ⇩r⇩e⇩a⇩c⇩h ?s ?a = (λ(s', a')∈S⇩r⇩e⇩a⇩c⇩h × A. δ s' a') (?s, ?a)›*) reachable_action_def (*‹ψ⇩r⇩e⇩a⇩c⇩h ?g ?s = (λ(g', s')∈carrier G × S⇩r⇩e⇩a⇩c⇩h. ψ g' s') (?g, ?s)›*))
show "δ⇩r⇩e⇩a⇩c⇩h (ψ⇩r⇩e⇩a⇩c⇩h g r) (φ g a) = ψ⇩r⇩e⇩a⇩c⇩h g (δ⇩r⇩e⇩a⇩c⇩h r a)"
using H1_2 (*‹ψ g (δ r a) = δ (ψ g r) (φ g a)›*) H1_4 (*‹ψ⇩r⇩e⇩a⇩c⇩h g (δ⇩r⇩e⇩a⇩c⇩h r a) = ψ g (δ r a)›*) H1_7 (*‹δ⇩r⇩e⇩a⇩c⇩h (ψ⇩r⇩e⇩a⇩c⇩h g r) (φ g a) = δ (ψ g r) (φ g a)›*) by auto
qed
have H_9: "⋀a w s. ⟦(⋀s. s ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ (δ⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w);
a ∈ A ∧ (∀x∈set w. x ∈ A); s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (δ⇧⋆) (δ s a) w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) (δ⇩r⇩e⇩a⇩c⇩h s a) w"
proof (-)
(*goal: ‹⋀(a::'alpha) (w::'alpha list) s::'states. ⟦⋀s::'states. s ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w; a ∈ A ∧ (∀x::'alpha∈set w. x ∈ A); s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (δ⇧⋆) (δ s a) w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) (δ⇩r⇩e⇩a⇩c⇩h s a) w›*)
fix a and w and s
assume A1_IH: "(⋀s. s ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ (δ⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w)" and A1_0: "a ∈ A ∧ (∀x∈set w. x ∈ A)" and A1_1: "s ∈ S⇩r⇩e⇩a⇩c⇩h" (*‹(?s1::'states) ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) ?s1 (w::'alpha list) = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) ?s1 w› ‹(a::'alpha) ∈ A ∧ (∀x::'alpha∈set (w::'alpha list). x ∈ A)› ‹(s::'states) ∈ S⇩r⇩e⇩a⇩c⇩h›*)
have H1_0: "δ⇩r⇩e⇩a⇩c⇩h s a = δ s a"
using A1_1 (*‹s ∈ S⇩r⇩e⇩a⇩c⇩h›*) apply (clarsimp simp add: reachable_trans_def (*‹δ⇩r⇩e⇩a⇩c⇩h (?s::'states::type) (?a::'alpha::type) = (λ(s'::'states::type, a'::'alpha::type)∈S⇩r⇩e⇩a⇩c⇩h × A. (δ::'states::type ⇒ 'alpha::type ⇒ 'states::type) s' a') (?s, ?a)›*))
(*goal: ‹δ⇩r⇩e⇩a⇩c⇩h (s::'states) (a::'alpha) = (δ::'states ⇒ 'alpha ⇒ 'states) s a›*)
apply (rule meta_mp[of "det_aut A S i F δ"] (*‹⟦det_aut A S i F δ ⟹ PROP ?Q; det_aut A S i F δ⟧ ⟹ PROP ?Q›*))
(*goal: ‹⟦s ∈ S⇩r⇩e⇩a⇩c⇩h; a ∉ A⟧ ⟹ undefined = δ s a›*)
using det_aut.trans_func_ext[where labels = A and states = S and init_state = i and fin_states = F and trans_func = δ] (*‹det_aut A S i F δ ⟹ (λ(state, label). δ state label) ∈ S × A →⇩E S›*)
(*goals:
1. ‹⟦s ∈ S⇩r⇩e⇩a⇩c⇩h; a ∉ A; det_aut A S i F δ⟧ ⟹ undefined = δ s a›
2. ‹⟦s ∈ S⇩r⇩e⇩a⇩c⇩h; a ∉ A⟧ ⟹ det_aut A S i F δ›
discuss goal 1*)
apply (simp add: extensional_def (*‹extensional ?A = {f. ∀x. x ∉ ?A ⟶ f x = undefined}›*))
(*top goal: ‹⟦s ∈ S⇩r⇩e⇩a⇩c⇩h; a ∉ A; det_aut A S i F δ⟧ ⟹ undefined = δ s a› and 1 goal remains*)
apply ((auto simp add: A1_0 (*‹a ∈ A ∧ (∀x∈set w. x ∈ A)›*))[1])
(*discuss goal 2*)
apply ((auto simp add: A1_0 (*‹a ∈ A ∧ (∀x∈set w. x ∈ A)›*))[1])
(*proven 2 subgoals*) .
show "(δ⇧⋆) (δ s a) w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) (δ⇩r⇩e⇩a⇩c⇩h s a) w"
apply (simp add: H1_0 (*‹δ⇩r⇩e⇩a⇩c⇩h s a = δ s a›*))
(*goal: ‹(δ⇧⋆) (δ s a) w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) (δ⇩r⇩e⇩a⇩c⇩h s a) w›*)
apply (rule A1_IH[where s1 = "δ s a"] (*‹δ s a ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ (δ⇧⋆) (δ s a) w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) (δ s a) w›*))
(*goal: ‹(δ⇧⋆) (δ s a) w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) (δ s a) w›*)
using A1_0 (*‹(a::'alpha) ∈ A ∧ (∀x::'alpha∈set (w::'alpha list). x ∈ A)›*) A1_1 (*‹s ∈ S⇩r⇩e⇩a⇩c⇩h›*) apply (simp add: reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*))
(*goal: ‹δ s a ∈ S⇩r⇩e⇩a⇩c⇩h›*)
by (metis Cons_in_lists_iff (*‹(?x # ?xs ∈ ?A⇧⋆) = (?x ∈ ?A ∧ ?xs ∈ ?A⇧⋆)›*) append_Nil2 (*‹?xs @ [] = ?xs›*) append_in_lists_conv (*‹(?xs @ ?ys ∈ ?A⇧⋆) = (?xs ∈ ?A⇧⋆ ∧ ?ys ∈ ?A⇧⋆)›*) is_aut.give_input_closed (*‹⟦?input ∈ A⇧⋆; ?s ∈ S⟧ ⟹ (δ⇧⋆) ?s ?input ∈ S›*) is_aut.init_state_is_a_state (*‹i ∈ S›*) is_aut.trans_to_charact (*‹⟦?s ∈ S; ?a ∈ A; ?w ∈ A⇧⋆; ?s = (δ⇧⋆) ?i ?w⟧ ⟹ (δ⇧⋆) ?i (?w @ [?a]) = δ ?s ?a›*))
qed
show "?thesis"
(*goal: ‹reach_det_G_aut_rec_lang A S⇩r⇩e⇩a⇩c⇩h (i::'states::type) ((F::'states::type set) ∩ S⇩r⇩e⇩a⇩c⇩h) δ⇩r⇩e⇩a⇩c⇩h (G::('grp, 'b) monoid_scheme) (φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type) ψ⇩r⇩e⇩a⇩c⇩h (L::'alpha::type list set)›*)
apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})›*) simp add: reach_det_G_aut_rec_lang_def (*‹reach_det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ∧ reach_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ›*) det_G_aut_rec_lang_def (*‹det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ det_aut_rec_lang ?A ?S ?i ?F ?δ ?L›*) det_G_aut_def (*‹det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ (det_aut ?A ?S ?i ?F ?δ ∧ alt_grp_act ?G ?A ?φ ∧ alt_grp_act ?G ?S ?ψ) ∧ eq_var_subset ?G ?S ?ψ ?F ∧ eq_var_subset ?G ?S ?ψ {?i} ∧ eq_var_func ?G (?S × ?A) (λg∈carrier ?G. λ(s, a)∈?S × ?A. (?ψ g s, ?φ g a)) ?S ?ψ (λ(s, a)∈?S × ?A. ?δ s a)›*) det_aut_def (*‹det_aut ?labels ?states ?init_state ?fin_states ?trans_func ≡ ?init_state ∈ ?states ∧ ?fin_states ⊆ ?states ∧ (λ(state, label). ?trans_func state label) ∈ ?states × ?labels →⇩E ?states›*))
(*goal: ‹reach_det_G_aut_rec_lang A S⇩r⇩e⇩a⇩c⇩h i (F ∩ S⇩r⇩e⇩a⇩c⇩h) δ⇩r⇩e⇩a⇩c⇩h G φ ψ⇩r⇩e⇩a⇩c⇩h L›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹i ∈ S⇩r⇩e⇩a⇩c⇩h ∧ (λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A →⇩E S⇩r⇩e⇩a⇩c⇩h ∧ alt_grp_act G A φ ∧ alt_grp_act G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h ∧ eq_var_subset G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h (F ∩ S⇩r⇩e⇩a⇩c⇩h) ∧ eq_var_subset G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h {i} ∧ eq_var_func G (S⇩r⇩e⇩a⇩c⇩h × A) (λg∈carrier G. λ(s, a)∈S⇩r⇩e⇩a⇩c⇩h × A. (ψ⇩r⇩e⇩a⇩c⇩h g s, φ g a)) S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h (λ(x, y)∈S⇩r⇩e⇩a⇩c⇩h × A. δ⇩r⇩e⇩a⇩c⇩h x y) ∧ det_aut_rec_lang A S⇩r⇩e⇩a⇩c⇩h i (F ∩ S⇩r⇩e⇩a⇩c⇩h) δ⇩r⇩e⇩a⇩c⇩h L ∧ reach_det_G_aut A S⇩r⇩e⇩a⇩c⇩h i (F ∩ S⇩r⇩e⇩a⇩c⇩h) δ⇩r⇩e⇩a⇩c⇩h G φ ψ⇩r⇩e⇩a⇩c⇩h›*)
subgoal for
apply (simp add: reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*))
(*goal: ‹i ∈ S⇩r⇩e⇩a⇩c⇩h›*)
by (meson give_input.simps( (*‹(?trans_func⇧⋆) ?s [] = ?s›*) 1) lists.Nil (*‹[] ∈ ?A⇧⋆›*))
apply (simp add: H_0 (*‹(λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A →⇩E S⇩r⇩e⇩a⇩c⇩h›*))
(*top goal: ‹(λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A →⇩E S⇩r⇩e⇩a⇩c⇩h› and 7 goals remain*)
using labels_a_G_set.alt_grp_act_axioms (*‹alt_grp_act (G::('grp, 'b) monoid_scheme) A (φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)›*) apply ((auto)[1])
(*top goal: ‹alt_grp_act G A φ› and 6 goals remain*)
apply (rule H_6 (*‹alt_grp_act (G::('grp, 'b) monoid_scheme) S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h›*))
(*top goal: ‹alt_grp_act G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h› and 5 goals remain*)
subgoal for
apply (clarsimp simp add: eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*))
(*goal: ‹eq_var_subset (G::('grp, 'b) monoid_scheme) S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h ((F::'states set) ∩ S⇩r⇩e⇩a⇩c⇩h)›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹group_action G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h ∧ (∀g∈carrier G. ψ⇩r⇩e⇩a⇩c⇩h g ` (F ∩ S⇩r⇩e⇩a⇩c⇩h) = F ∩ S⇩r⇩e⇩a⇩c⇩h)›*)
using H_6 (*‹alt_grp_act G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h›*) apply ((auto)[1])
(*top goal: ‹group_action G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h› and 1 goal remains*)
apply ((simp del: add: reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*))[1])
(*goal: ‹∀g∈carrier G. ψ⇩r⇩e⇩a⇩c⇩h g ` (F ∩ S⇩r⇩e⇩a⇩c⇩h) = F ∩ S⇩r⇩e⇩a⇩c⇩h›*)
apply (clarify; rule subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*); simp add: Set.subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*); clarify)
(*goal: ‹∀g∈carrier G. ψ⇩r⇩e⇩a⇩c⇩h g ` (F ∩ {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}) = F ∩ {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*top goal: ‹⋀g x w. ⟦g ∈ carrier G; (δ⇧⋆) i w ∈ F; ∀x∈set w. x ∈ A⟧ ⟹ ψ⇩r⇩e⇩a⇩c⇩h g ((δ⇧⋆) i w) ∈ F ∧ (∃wa∈A⇧⋆. (δ⇧⋆) i wa = ψ⇩r⇩e⇩a⇩c⇩h g ((δ⇧⋆) i w))› and 1 goal remains*)
subgoal for g and _ and w
apply (clarsimp simp add: reachable_action_def (*‹ψ⇩r⇩e⇩a⇩c⇩h ?g ?s = (λ(g', s')∈carrier G × S⇩r⇩e⇩a⇩c⇩h. ψ g' s') (?g, ?s)›*) reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*))
(*goal: ‹⟦g ∈ carrier G; (δ⇧⋆) i w ∈ F; ∀x∈set w. x ∈ A⟧ ⟹ ψ⇩r⇩e⇩a⇩c⇩h g ((δ⇧⋆) i w) ∈ F›*)
using accepting_is_eq_var.is_equivar (*‹∀g∈carrier G. ψ g ` F = F›*) by blast
subgoal for g and _ and w
apply (clarsimp simp add: reachable_action_def (*‹ψ⇩r⇩e⇩a⇩c⇩h ?g ?s = (λ(g', s')∈carrier G × S⇩r⇩e⇩a⇩c⇩h. ψ g' s') (?g, ?s)›*) reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*))
(*goal: ‹⟦g ∈ carrier G; (δ⇧⋆) i w ∈ F; ∀x∈set w. x ∈ A⟧ ⟹ ∃wa∈A⇧⋆. (δ⇧⋆) i wa = ψ⇩r⇩e⇩a⇩c⇩h g ((δ⇧⋆) i w)›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⟦(g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme); ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) (w::'alpha::type list) ∈ (F::'states::type set); ∀x::'alpha::type∈set w. x ∈ A⟧ ⟹ (∃wa::'alpha::type list∈A⇧⋆. (δ⇧⋆) i wa = (δ⇧⋆) i w) ⟶ (∃wa::'alpha::type list∈A⇧⋆. (δ⇧⋆) i wa = (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) g ((δ⇧⋆) i w))›
2. ‹⟦(g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme); ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) (w::'alpha::type list) ∈ (F::'states::type set); ∀x::'alpha::type∈set w. x ∈ A⟧ ⟹ (∀wa::'alpha::type list∈A⇧⋆. (δ⇧⋆) i wa ≠ (δ⇧⋆) i w) ⟶ (∃w::'alpha::type list∈A⇧⋆. (δ⇧⋆) i w = undefined)›
discuss goal 1*)
apply clarify
(*top goal: ‹⟦(g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme); ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) (w::'alpha::type list) ∈ (F::'states::type set); ∀x::'alpha::type∈set w. x ∈ A⟧ ⟹ (∃wa::'alpha::type list∈A⇧⋆. (δ⇧⋆) i wa = (δ⇧⋆) i w) ⟶ (∃wa::'alpha::type list∈A⇧⋆. (δ⇧⋆) i wa = (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) g ((δ⇧⋆) i w))› and 1 goal remains*)
apply (simp add: H_5 (*‹⟦?g1 ∈ carrier G; (δ⇧⋆) i ?w1 ∈ F; ∀x∈set ?w1. x ∈ A; (δ⇧⋆) i ?w'1 = (δ⇧⋆) i ?w1; ∀x∈set ?w'1. x ∈ A⟧ ⟹ ∃w'∈A⇧⋆. (δ⇧⋆) i w' = ψ ?g1 ((δ⇧⋆) i ?w1)›*))
(*discuss goal 2*)
apply clarify
(*goal: ‹⟦g ∈ carrier G; (δ⇧⋆) i w ∈ F; ∀x∈set w. x ∈ A⟧ ⟹ (∀wa∈A⇧⋆. (δ⇧⋆) i wa ≠ (δ⇧⋆) i w) ⟶ (∃w∈A⇧⋆. (δ⇧⋆) i w = undefined)›*)
apply ((auto)[1])
(*proven 2 subgoals*) .
apply (clarsimp simp add: reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*) Int_def (*‹?A ∩ ?B = {x ∈ ?A. x ∈ ?B}›*) reachable_action_def (*‹ψ⇩r⇩e⇩a⇩c⇩h ?g ?s = (λ(g', s')∈carrier G × S⇩r⇩e⇩a⇩c⇩h. ψ g' s') (?g, ?s)›*))
(*goal: ‹⋀g x w. ⟦g ∈ carrier G; (δ⇧⋆) i w ∈ F; ∀x∈set w. x ∈ A⟧ ⟹ (δ⇧⋆) i w ∈ ψ⇩r⇩e⇩a⇩c⇩h g ` (F ∩ {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s})›*)
apply (clarsimp simp add: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*goal: ‹⋀g w. ⟦g ∈ carrier G; (δ⇧⋆) i w ∈ F; ∀x∈set w. x ∈ A⟧ ⟹ (δ⇧⋆) i w ∈ ψ g ` {x ∈ F. ∃w∈A⇧⋆. (δ⇧⋆) i w = x}›*)
by (simp add: H_7 (*‹⟦(?g1::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (?w1::'alpha list) ∈ (F::'states set); ∀x::'alpha∈set ?w1. x ∈ A⟧ ⟹ ∃x::'states. x ∈ F ∧ (∃w::'alpha list∈A⇧⋆. (δ⇧⋆) i w = x) ∧ (δ⇧⋆) i ?w1 = (ψ::'grp ⇒ 'states ⇒ 'states) ?g1 x›*))
subgoal for
apply (clarsimp simp add: eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*))
(*goal: ‹eq_var_subset G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h {i}›*)
apply (rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹group_action G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h ∧ eq_var_subset_axioms G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h {i}›*)
using H_6 (*‹alt_grp_act G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h›*) apply ((auto)[1])
(*top goal: ‹group_action G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h› and 1 goal remains*)
apply (clarsimp simp add: eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*))
(*goal: ‹eq_var_subset_axioms G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h {i}›*)
apply (simp add: ‹i ∈ S⇩r⇩e⇩a⇩c⇩h›)
(*goal: ‹i ∈ S⇩r⇩e⇩a⇩c⇩h ∧ (∀g∈carrier G. ψ⇩r⇩e⇩a⇩c⇩h g i = i)›*)
apply (simp add: reachable_action_def (*‹ψ⇩r⇩e⇩a⇩c⇩h ?g ?s = (λ(g', s')∈carrier G × S⇩r⇩e⇩a⇩c⇩h. ψ g' s') (?g, ?s)›*))
(*goal: ‹∀g∈carrier G. ψ⇩r⇩e⇩a⇩c⇩h g i = i›*)
using ‹i ∈ S⇩r⇩e⇩a⇩c⇩h› (*‹i ∈ S⇩r⇩e⇩a⇩c⇩h›*) init_is_eq_var.is_equivar (*‹∀g::'grp::type∈carrier (G::('grp, 'b) monoid_scheme). (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) g ` {i::'states::type} = {i}›*) by fastforce
subgoal for
apply (clarsimp simp add: eq_var_func_def (*‹eq_var_func ?G ?X ?φ ?Y ?ψ ?f ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*) eq_var_func_axioms_def (*‹eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀a g. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*))
(*goal: ‹eq_var_func (G::('grp, 'b) monoid_scheme) (S⇩r⇩e⇩a⇩c⇩h × A) (λg::'grp::type∈carrier G. λ(s::'states::type, a::'alpha::type)∈S⇩r⇩e⇩a⇩c⇩h × A. (ψ⇩r⇩e⇩a⇩c⇩h g s, (φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type) g a)) S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h (λ(x::'states::type, y::'alpha::type)∈S⇩r⇩e⇩a⇩c⇩h × A. δ⇩r⇩e⇩a⇩c⇩h x y)›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹group_action G (S⇩r⇩e⇩a⇩c⇩h × A) (λg∈carrier G. λ(s, a)∈S⇩r⇩e⇩a⇩c⇩h × A. (ψ⇩r⇩e⇩a⇩c⇩h g s, φ g a)) ∧ group_action G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h ∧ (λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A → S⇩r⇩e⇩a⇩c⇩h ∧ (∀a b. a ∈ S⇩r⇩e⇩a⇩c⇩h ∧ b ∈ A ⟶ (∀g. (ψ⇩r⇩e⇩a⇩c⇩h g a ∈ S⇩r⇩e⇩a⇩c⇩h ∧ φ g b ∈ A ⟶ g ∈ carrier G ⟶ δ⇩r⇩e⇩a⇩c⇩h (ψ⇩r⇩e⇩a⇩c⇩h g a) (φ g b) = ψ⇩r⇩e⇩a⇩c⇩h g (δ⇩r⇩e⇩a⇩c⇩h a b)) ∧ ((ψ⇩r⇩e⇩a⇩c⇩h g a ∈ S⇩r⇩e⇩a⇩c⇩h ⟶ φ g b ∉ A) ⟶ g ∈ carrier G ⟶ undefined = ψ⇩r⇩e⇩a⇩c⇩h g (δ⇩r⇩e⇩a⇩c⇩h a b))))›*)
using H_6 (*‹alt_grp_act G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h›*) alt_grp_act.axioms (*‹alt_grp_act ?G ?X ?φ ⟹ group_action ?G ?X ?φ›*) labels_a_G_set.group_action_axioms (*‹group_action G A φ›*) prod_group_act (*‹⟦alt_grp_act (?G::(?'a, ?'b) monoid_scheme) (?A::?'c set) (?φ::?'a ⇒ ?'c ⇒ ?'c); alt_grp_act ?G (?B::?'d set) (?ψ::?'a ⇒ ?'d ⇒ ?'d)⟧ ⟹ alt_grp_act ?G (?A × ?B) (λg::?'a∈carrier ?G. λ(a::?'c, b::?'d)∈?A × ?B. (?φ g a, ?ψ g b))›*) labels_a_G_set.alt_grp_act_axioms (*‹alt_grp_act G A φ›*) apply blast
(*top goal: ‹group_action G (S⇩r⇩e⇩a⇩c⇩h × A) (λg∈carrier G. λ(s, a)∈S⇩r⇩e⇩a⇩c⇩h × A. (ψ⇩r⇩e⇩a⇩c⇩h g s, φ g a))› and 3 goals remain*)
using H_6 (*‹alt_grp_act G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h›*) apply ((auto)[1])
(*top goal: ‹group_action G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h› and 2 goals remain*)
apply (rule funcsetI (*‹(⋀x. x ∈ ?A ⟹ ?f x ∈ ?B) ⟹ ?f ∈ ?A → ?B›*); clarsimp)
(*top goal: ‹(λ(x::'states, y::'alpha). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A → S⇩r⇩e⇩a⇩c⇩h› and 1 goal remains*)
subgoal for s and a
apply (clarsimp simp add: reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*) reachable_trans_def (*‹δ⇩r⇩e⇩a⇩c⇩h ?s ?a = (λ(s', a')∈S⇩r⇩e⇩a⇩c⇩h × A. δ s' a') (?s, ?a)›*))
(*goal: ‹⟦s ∈ S⇩r⇩e⇩a⇩c⇩h; a ∈ A⟧ ⟹ δ⇩r⇩e⇩a⇩c⇩h s a ∈ S⇩r⇩e⇩a⇩c⇩h›*)
by (metis Cons_in_lists_iff (*‹(?x # ?xs ∈ ?A⇧⋆) = (?x ∈ ?A ∧ ?xs ∈ ?A⇧⋆)›*) append_Nil2 (*‹?xs @ [] = ?xs›*) append_in_lists_conv (*‹(?xs @ ?ys ∈ ?A⇧⋆) = (?xs ∈ ?A⇧⋆ ∧ ?ys ∈ ?A⇧⋆)›*) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) is_aut.give_input_closed (*‹⟦?input ∈ A⇧⋆; ?s ∈ S⟧ ⟹ (δ⇧⋆) ?s ?input ∈ S›*) is_aut.init_state_is_a_state (*‹i ∈ S›*) is_aut.trans_to_charact (*‹⟦?s ∈ S; ?a ∈ A; ?w ∈ A⇧⋆; ?s = (δ⇧⋆) ?i ?w⟧ ⟹ (δ⇧⋆) ?i (?w @ [?a]) = δ ?s ?a›*))
apply (intro allI (*‹(⋀x::?'a::type. (?P::?'a::type ⇒ bool) x) ⟹ ∀x::?'a::type. ?P x›*); clarify; rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); intro impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹∀a b. a ∈ S⇩r⇩e⇩a⇩c⇩h ∧ b ∈ A ⟶ (∀g. (ψ⇩r⇩e⇩a⇩c⇩h g a ∈ S⇩r⇩e⇩a⇩c⇩h ∧ φ g b ∈ A ⟶ g ∈ carrier G ⟶ δ⇩r⇩e⇩a⇩c⇩h (ψ⇩r⇩e⇩a⇩c⇩h g a) (φ g b) = ψ⇩r⇩e⇩a⇩c⇩h g (δ⇩r⇩e⇩a⇩c⇩h a b)) ∧ ((ψ⇩r⇩e⇩a⇩c⇩h g a ∈ S⇩r⇩e⇩a⇩c⇩h ⟶ φ g b ∉ A) ⟶ g ∈ carrier G ⟶ undefined = ψ⇩r⇩e⇩a⇩c⇩h g (δ⇩r⇩e⇩a⇩c⇩h a b)))›*)
apply (simp add: H_8 (*‹⟦(?r1::'states) ∈ S⇩r⇩e⇩a⇩c⇩h; (?a1::'alpha) ∈ A; ψ⇩r⇩e⇩a⇩c⇩h (?g1::'grp) ?r1 ∈ S⇩r⇩e⇩a⇩c⇩h ∧ (φ::'grp ⇒ 'alpha ⇒ 'alpha) ?g1 ?a1 ∈ A; ?g1 ∈ carrier (G::('grp, 'b) monoid_scheme)⟧ ⟹ δ⇩r⇩e⇩a⇩c⇩h (ψ⇩r⇩e⇩a⇩c⇩h ?g1 ?r1) (φ ?g1 ?a1) = ψ⇩r⇩e⇩a⇩c⇩h ?g1 (δ⇩r⇩e⇩a⇩c⇩h ?r1 ?a1)›*))
(*top goal: ‹⋀a b g. ⟦a ∈ S⇩r⇩e⇩a⇩c⇩h; b ∈ A; ψ⇩r⇩e⇩a⇩c⇩h g a ∈ S⇩r⇩e⇩a⇩c⇩h ∧ φ g b ∈ A; g ∈ carrier G⟧ ⟹ δ⇩r⇩e⇩a⇩c⇩h (ψ⇩r⇩e⇩a⇩c⇩h g a) (φ g b) = ψ⇩r⇩e⇩a⇩c⇩h g (δ⇩r⇩e⇩a⇩c⇩h a b)› and 1 goal remains*)
using G_set_equiv (*‹alt_grp_act ?G ?A ?φ ⟹ eq_var_subset ?G ?A ?φ ?A›*) H_6 (*‹alt_grp_act (G::('grp, 'b) monoid_scheme) S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h›*) eq_var_subset.is_equivar (*‹eq_var_subset ?G ?X ?φ ?Y ⟹ ∀g∈carrier ?G. ?φ g ` ?Y = ?Y›*) labels_a_G_set.element_image (*‹⟦?g ∈ carrier G; ?x ∈ A; φ ?g ?x = ?y⟧ ⟹ ?y ∈ A›*) by fastforce
apply (rule meta_mp[of "⋀w s. w ∈ A⇧⋆ ⟹ s ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ (δ⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w"] (*‹⟦(⋀(w::'alpha::type list) s::'states::type. ⟦w ∈ A⇧⋆; s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w) ⟹ PROP ?Q::prop; ⋀(w::'alpha::type list) s::'states::type. ⟦w ∈ A⇧⋆; s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (δ⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w⟧ ⟹ PROP ?Q›*))
(*top goal: ‹det_aut_rec_lang A S⇩r⇩e⇩a⇩c⇩h (i::'states::type) ((F::'states::type set) ∩ S⇩r⇩e⇩a⇩c⇩h) δ⇩r⇩e⇩a⇩c⇩h (L::'alpha::type list set)› and 1 goal remains*)
subgoal for
using det_G_aut_rec_lang_axioms (*‹det_G_aut_rec_lang A S i F δ G φ ψ L›*) apply (clarsimp simp add: det_aut_rec_lang_axioms_def (*‹det_aut_rec_lang_axioms ?A ?i ?F ?δ ?L ≡ ∀w. (w ∈ ?L) = (w ∈ ?A⇧⋆ ∧ (?δ⇧⋆) ?i w ∈ ?F)›*) det_aut_rec_lang_def (*‹det_aut_rec_lang ?A ?S ?i ?F ?δ ?L ≡ det_aut ?A ?S ?i ?F ?δ ∧ language ?A ?L ∧ det_aut_rec_lang_axioms ?A ?i ?F ?δ ?L›*) det_G_aut_rec_lang_def (*‹det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ det_aut_rec_lang ?A ?S ?i ?F ?δ ?L›*) det_aut_def (*‹det_aut ?labels ?states ?init_state ?fin_states ?trans_func ≡ ?init_state ∈ ?states ∧ ?fin_states ⊆ ?states ∧ (λ(state, label). ?trans_func state label) ∈ ?states × ?labels →⇩E ?states›*))
(*goal: ‹(⋀w s. ⟦w ∈ A⇧⋆; s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (δ⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w) ⟹ det_aut_rec_lang A S⇩r⇩e⇩a⇩c⇩h i (F ∩ S⇩r⇩e⇩a⇩c⇩h) δ⇩r⇩e⇩a⇩c⇩h L›*)
apply (intro conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹⟦⋀w s. ⟦w ∈ A⇧⋆; s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (δ⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w; det_G_aut A S i F δ G φ ψ; i ∈ S; F ⊆ S; (λ(x, y). δ x y) ∈ S × A →⇩E S; ∀w. (w ∈ L) = (w ∈ A⇧⋆ ∧ (δ⇧⋆) i w ∈ F)⟧ ⟹ i ∈ S⇩r⇩e⇩a⇩c⇩h ∧ (λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A →⇩E S⇩r⇩e⇩a⇩c⇩h ∧ (∀w. (w ∈ A⇧⋆ ∧ (δ⇧⋆) i w ∈ F) = (w ∈ A⇧⋆ ∧ (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) i w ∈ F ∧ (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) i w ∈ S⇩r⇩e⇩a⇩c⇩h))›*)
using ‹i ∈ S⇩r⇩e⇩a⇩c⇩h› (*‹i ∈ S⇩r⇩e⇩a⇩c⇩h›*) apply blast
(*top goal: ‹⟦⋀w s. ⟦w ∈ A⇧⋆; s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (δ⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w; det_G_aut A S i F δ G φ ψ; i ∈ S; F ⊆ S; (λ(x, y). δ x y) ∈ S × A →⇩E S; ∀w. (w ∈ L) = (w ∈ A⇧⋆ ∧ (δ⇧⋆) i w ∈ F)⟧ ⟹ i ∈ S⇩r⇩e⇩a⇩c⇩h› and 2 goals remain*)
using H_0 (*‹(λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A →⇩E S⇩r⇩e⇩a⇩c⇩h›*)
(*goals:
1. ‹⟦⋀w s. ⟦w ∈ A⇧⋆; s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (δ⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w; det_G_aut A S i F δ G φ ψ; i ∈ S; F ⊆ S; (λ(x, y). δ x y) ∈ S × A →⇩E S; ∀w. (w ∈ L) = (w ∈ A⇧⋆ ∧ (δ⇧⋆) i w ∈ F)⟧ ⟹ (λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A →⇩E S⇩r⇩e⇩a⇩c⇩h›
2. ‹⟦⋀w s. ⟦w ∈ A⇧⋆; s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (δ⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w; det_G_aut A S i F δ G φ ψ; i ∈ S; F ⊆ S; (λ(x, y). δ x y) ∈ S × A →⇩E S; ∀w. (w ∈ L) = (w ∈ A⇧⋆ ∧ (δ⇧⋆) i w ∈ F)⟧ ⟹ ∀w. (w ∈ A⇧⋆ ∧ (δ⇧⋆) i w ∈ F) = (w ∈ A⇧⋆ ∧ (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) i w ∈ F ∧ (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) i w ∈ S⇩r⇩e⇩a⇩c⇩h)›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply (metis (mono_tags, lifting) ‹i ∈ S⇩r⇩e⇩a⇩c⇩h› mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*))
(*proven 2 subgoals*) .
subgoal for w and s
apply (induction w arbitrary: s)
(*goals:
1. ‹⋀s::'states::type. ⟦[] ∈ A⇧⋆; s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) s [] = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s []›
2. ‹⋀(a::'alpha::type) (w::'alpha::type list) s::'states::type. ⟦⋀s::'states::type. ⟦w ∈ A⇧⋆; s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w; a # w ∈ A⇧⋆; s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (δ⇧⋆) s (a # w) = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s (a # w)›
discuss goal 1*)
apply clarsimp
(*discuss goal 2*)
apply (simp add: in_lists_conv_set (*‹(?xs ∈ ?A⇧⋆) = (∀x∈set ?xs. x ∈ ?A)›*))
(*goal: ‹⋀a w s. ⟦⋀s. ⟦w ∈ A⇧⋆; s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (δ⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w; a # w ∈ A⇧⋆; s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (δ⇧⋆) s (a # w) = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s (a # w)›*)
apply (simp add: H_9 (*‹⟦⋀s. s ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ (δ⇧⋆) s ?w1 = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s ?w1; ?a1 ∈ A ∧ (∀x∈set ?w1. x ∈ A); ?s1 ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (δ⇧⋆) (δ ?s1 ?a1) ?w1 = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) (δ⇩r⇩e⇩a⇩c⇩h ?s1 ?a1) ?w1›*))
(*proven 2 subgoals*) .
apply (clarsimp simp add: reach_det_G_aut_def (*‹reach_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ reach_det_aut ?A ?S ?i ?F ?δ›*) det_G_aut_def (*‹det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ (det_aut ?A ?S ?i ?F ?δ ∧ alt_grp_act ?G ?A ?φ ∧ alt_grp_act ?G ?S ?ψ) ∧ eq_var_subset ?G ?S ?ψ ?F ∧ eq_var_subset ?G ?S ?ψ {?i} ∧ eq_var_func ?G (?S × ?A) (λg∈carrier ?G. λ(s, a)∈?S × ?A. (?ψ g s, ?φ g a)) ?S ?ψ (λ(s, a)∈?S × ?A. ?δ s a)›*) det_aut_def (*‹det_aut ?labels ?states ?init_state ?fin_states ?trans_func ≡ ?init_state ∈ ?states ∧ ?fin_states ⊆ ?states ∧ (λ(state, label). ?trans_func state label) ∈ ?states × ?labels →⇩E ?states›*))
(*goal: ‹reach_det_G_aut A S⇩r⇩e⇩a⇩c⇩h i (F ∩ S⇩r⇩e⇩a⇩c⇩h) δ⇩r⇩e⇩a⇩c⇩h G φ ψ⇩r⇩e⇩a⇩c⇩h›*)
apply (intro conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹i ∈ S⇩r⇩e⇩a⇩c⇩h ∧ (λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A →⇩E S⇩r⇩e⇩a⇩c⇩h ∧ group_action G A φ ∧ group_action G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h ∧ eq_var_subset G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h (F ∩ S⇩r⇩e⇩a⇩c⇩h) ∧ eq_var_subset G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h {i} ∧ eq_var_func G (S⇩r⇩e⇩a⇩c⇩h × A) (λg∈carrier G. λ(s, a)∈S⇩r⇩e⇩a⇩c⇩h × A. (ψ⇩r⇩e⇩a⇩c⇩h g s, φ g a)) S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h (λ(x, y)∈S⇩r⇩e⇩a⇩c⇩h × A. δ⇩r⇩e⇩a⇩c⇩h x y) ∧ reach_det_aut A S⇩r⇩e⇩a⇩c⇩h i (F ∩ S⇩r⇩e⇩a⇩c⇩h) δ⇩r⇩e⇩a⇩c⇩h›*)
apply (simp add: ‹i ∈ S⇩r⇩e⇩a⇩c⇩h›)
(*top goal: ‹i ∈ S⇩r⇩e⇩a⇩c⇩h› and 7 goals remain*)
apply (simp add: H_0 (*‹(λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A →⇩E S⇩r⇩e⇩a⇩c⇩h›*))
(*top goal: ‹(λ(x, y). δ⇩r⇩e⇩a⇩c⇩h x y) ∈ S⇩r⇩e⇩a⇩c⇩h × A →⇩E S⇩r⇩e⇩a⇩c⇩h› and 6 goals remain*)
apply (simp add: labels_a_G_set.group_action_axioms (*‹group_action G A φ›*))
(*top goal: ‹group_action G A φ› and 5 goals remain*)
using ‹alt_grp_act G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h› (*‹alt_grp_act G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h›*) apply ((auto)[1])
(*top goal: ‹group_action G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h› and 4 goals remain*)
apply (simp add: ‹eq_var_subset G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h (F ∩ S⇩r⇩e⇩a⇩c⇩h)›)
(*top goal: ‹eq_var_subset G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h (F ∩ S⇩r⇩e⇩a⇩c⇩h)› and 3 goals remain*)
apply (simp add: ‹eq_var_subset G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h {i}›)
(*top goal: ‹eq_var_subset (G::('grp, 'b) monoid_scheme) S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h {i::'states}› and 2 goals remain*)
using ‹eq_var_func G (S⇩r⇩e⇩a⇩c⇩h × A) (λg∈carrier G. λ(s, a)∈S⇩r⇩e⇩a⇩c⇩h × A. (ψ⇩r⇩e⇩a⇩c⇩h g s, φ g a))
S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h (λ(x, y)∈S⇩r⇩e⇩a⇩c⇩h × A. δ⇩r⇩e⇩a⇩c⇩h x y)› (*‹eq_var_func G (S⇩r⇩e⇩a⇩c⇩h × A) (λg∈carrier G. λ(s, a)∈S⇩r⇩e⇩a⇩c⇩h × A. (ψ⇩r⇩e⇩a⇩c⇩h g s, φ g a)) S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h (λ(x, y)∈S⇩r⇩e⇩a⇩c⇩h × A. δ⇩r⇩e⇩a⇩c⇩h x y)›*) apply blast
(*top goal: ‹eq_var_func G (S⇩r⇩e⇩a⇩c⇩h × A) (λg∈carrier G. λ(s, a)∈S⇩r⇩e⇩a⇩c⇩h × A. (ψ⇩r⇩e⇩a⇩c⇩h g s, φ g a)) S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h (λ(x, y)∈S⇩r⇩e⇩a⇩c⇩h × A. δ⇩r⇩e⇩a⇩c⇩h x y)› and 1 goal remains*)
apply (simp add: reach_det_aut_axioms_def (*‹reach_det_aut_axioms (?A::?'alpha set) (?S::?'states set) (?i::?'states) (?δ::?'states ⇒ ?'alpha ⇒ ?'states) ≡ ∀s::?'states. s ∈ ?S ⟶ (∃input::?'alpha list∈?A⇧⋆. (?δ⇧⋆) ?i input = s)›*) reach_det_aut_def (*‹reach_det_aut (?A::?'alpha set) (?S::?'states set) (?i::?'states) (?F::?'states set) (?δ::?'states ⇒ ?'alpha ⇒ ?'states) ≡ det_aut ?A ?S ?i ?F ?δ ∧ reach_det_aut_axioms ?A ?S ?i ?δ›*) reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s::'states. ∃w::'alpha list∈A⇧⋆. ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = s}›*))
(*goal: ‹reach_det_aut A S⇩r⇩e⇩a⇩c⇩h i (F ∩ S⇩r⇩e⇩a⇩c⇩h) δ⇩r⇩e⇩a⇩c⇩h›*)
apply (rule meta_mp[of "⋀s input. s ∈ S⇩r⇩e⇩a⇩c⇩h ⟹ input ∈ A⇧⋆ ⟹
(δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s input = (δ⇧⋆) s input" ] (*‹⟦(⋀s input. ⟦s ∈ S⇩r⇩e⇩a⇩c⇩h; input ∈ A⇧⋆⟧ ⟹ (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s input = (δ⇧⋆) s input) ⟹ PROP ?Q; ⋀s input. ⟦s ∈ S⇩r⇩e⇩a⇩c⇩h; input ∈ A⇧⋆⟧ ⟹ (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s input = (δ⇧⋆) s input⟧ ⟹ PROP ?Q›*))
(*goal: ‹det_aut A {s::'states. ∃w::'alpha list∈A⇧⋆. ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = s} i ((F::'states set) ∩ {s::'states. ∃w::'alpha list∈A⇧⋆. (δ⇧⋆) i w = s}) δ⇩r⇩e⇩a⇩c⇩h ∧ (∀s::'states. (∃w::'alpha list∈A⇧⋆. (δ⇧⋆) i w = s) ⟶ (∃input::'alpha list∈A⇧⋆. (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) i input = s))›*)
using ‹i ∈ S⇩r⇩e⇩a⇩c⇩h› (*‹i ∈ S⇩r⇩e⇩a⇩c⇩h›*)
(*goals:
1. ‹(⋀(s::'states) input::'alpha list. ⟦s ∈ S⇩r⇩e⇩a⇩c⇩h; input ∈ A⇧⋆⟧ ⟹ (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s input = ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) s input) ⟹ det_aut A {s::'states. ∃w::'alpha list∈A⇧⋆. (δ⇧⋆) (i::'states) w = s} i ((F::'states set) ∩ {s::'states. ∃w::'alpha list∈A⇧⋆. (δ⇧⋆) i w = s}) δ⇩r⇩e⇩a⇩c⇩h ∧ (∀s::'states. (∃w::'alpha list∈A⇧⋆. (δ⇧⋆) i w = s) ⟶ (∃input::'alpha list∈A⇧⋆. (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) i input = s))›
2. ‹⋀(s::'states) input::'alpha list. ⟦s ∈ S⇩r⇩e⇩a⇩c⇩h; input ∈ A⇧⋆⟧ ⟹ (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s input = ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) s input›
discuss goal 1*)
apply (metis (no_types, lifting) ‹(⋀w s. ⟦w ∈ A⇧⋆; s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹
(δ⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w) ⟹ det_aut_rec_lang A S⇩r⇩e⇩a⇩c⇩h i (F ∩ S⇩r⇩e⇩a⇩c⇩h) δ⇩r⇩e⇩a⇩c⇩h L› det_aut_rec_lang_def (*‹det_aut_rec_lang ?A ?S ?i ?F ?δ ?L ≡ det_aut ?A ?S ?i ?F ?δ ∧ language ?A ?L ∧ det_aut_rec_lang_axioms ?A ?i ?F ?δ ?L›*) reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*))
(*discuss goal 2*)
apply (simp add: ‹⋀w s. ⟦w ∈ A⇧⋆; s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ (δ⇧⋆) s w = (δ⇩r⇩e⇩a⇩c⇩h⇧⋆) s w›)
(*proven 2 subgoals*) .
qed
subsection ‹
Syntactic Automaton
›
context language begin
definition
rel_MN :: "('alpha list × 'alpha list) set" ("≡⇩M⇩N")
where "rel_MN = {(w, w') ∈ (A⇧⋆)×(A⇧⋆). (∀v ∈ A⇧⋆. (w @ v) ∈ L ⟷ (w' @ v) ∈ L)}"
lemma MN_rel_equival:
"equiv (A⇧⋆) rel_MN"
by (auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w::'alpha list, w'::'alpha list). (w, w') ∈ (A::'alpha set)⇧⋆ × A⇧⋆ ∧ (∀v::'alpha list∈A⇧⋆. (w @ v ∈ (L::'alpha list set)) = (w' @ v ∈ L))}›*) equiv_def (*‹equiv (?A::?'a set) (?r::(?'a × ?'a) set) = (refl_on ?A ?r ∧ sym ?r ∧ trans ?r)›*) refl_on_def (*‹refl_on (?A::?'a set) (?r::(?'a × ?'a) set) = (?r ⊆ ?A × ?A ∧ (∀x::?'a∈?A. (x, x) ∈ ?r))›*) sym_def (*‹sym (?r::(?'a × ?'a) set) = (∀(x::?'a) y::?'a. (x, y) ∈ ?r ⟶ (y, x) ∈ ?r)›*) trans_def (*‹trans (?r::(?'a × ?'a) set) = (∀(x::?'a) (y::?'a) z::?'a. (x, y) ∈ ?r ⟶ (y, z) ∈ ?r ⟶ (x, z) ∈ ?r)›*))
abbreviation
MN_equiv
where "MN_equiv ≡ A⇧⋆ // rel_MN"
definition
alt_natural_map_MN :: "'alpha list ⇒ 'alpha list set " ("[_]⇩M⇩N")
where "[w]⇩M⇩N = rel_MN `` {w}"
definition
MN_trans_func :: "('alpha list set) ⇒ 'alpha ⇒ 'alpha list set" ("δ⇩M⇩N")
where "MN_trans_func W' a' =
(λ(W,a) ∈ MN_equiv × A. rel_MN `` {(SOME w. w ∈ W) @ [a]}) (W', a')"
abbreviation
MN_init_state
where "MN_init_state ≡ [Nil::'alpha list]⇩M⇩N"
abbreviation
MN_fin_states
where "MN_fin_states ≡ {v. ∃w∈L. v = [w]⇩M⇩N}"
lemmas
alt_natural_map_MN_def [simp, GMN_simps]
MN_trans_func_def [simp, GMN_simps]
end
context G_lang begin
adhoc_overloading
star induced_star_map
lemma MN_quot_act_wd:
"w' ∈ [w]⇩M⇩N ⟹ ∀g ∈ carrier G. (g ⊙ ⇘φ⇧⋆⇙ w') ∈ [g ⊙ ⇘φ⇧⋆⇙ w]⇩M⇩N"
proof (-)
(*goal: ‹w' ∈ [w]⇩M⇩N ⟹ ∀g∈carrier G. g ⊙⇘φ⇧⋆⇙ w' ∈ [g ⊙⇘φ⇧⋆⇙ w]⇩M⇩N›*)
assume A_0: "w' ∈ [w]⇩M⇩N" (*‹(w'::'alpha list) ∈ [w::'alpha list]⇩M⇩N›*)
have H_0: "⋀g. ⟦(w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ;
group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆;
∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L;
∀x∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ (map (φ g) w, map (φ g) w') ∈ ≡⇩M⇩N"
proof (-)
(*goal: ‹⋀g. ⟦(w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ (map (φ g) w, map (φ g) w') ∈ ≡⇩M⇩N›*)
fix g
assume A1_0: "(w, w') ∈ ≡⇩M⇩N" and A1_1: "g ∈ carrier G" and A1_2: "group_hom G (BijGroup A) φ" and A1_3: "group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆))" and A1_4: "L ⊆ A⇧⋆" and A1_5: "∀g∈carrier G.
map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L" and A1_6: "∀x∈set w. x ∈ A" and A1_7: "w' ∈ A⇧⋆" (*‹(w::'alpha list, w'::'alpha list) ∈ ≡⇩M⇩N› ‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹group_hom (G::('grp, 'b) monoid_scheme) (BijGroup A) (φ::'grp ⇒ 'alpha ⇒ 'alpha)› ‹group_hom (G::('grp, 'b) monoid_scheme) (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) g)) (A⇧⋆))› ‹(L::'alpha list set) ⊆ A⇧⋆› ‹∀g::'grp∈carrier (G::('grp, 'b) monoid_scheme). map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) g) ` ((L::'alpha list set) ∩ A⇧⋆) ∪ (λx::'alpha list. undefined) ` (L ∩ {x::'alpha list. x ∉ A⇧⋆}) = L› ‹∀x::'alpha∈set (w::'alpha list). x ∈ A› ‹(w'::'alpha list) ∈ A⇧⋆›*)
have H1_0: "⋀v w w'. ⟦g ∈ carrier G; group_hom G (BijGroup A) φ;
group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆));
L ⊆ A⇧⋆; ∀g∈carrier G.
{y. ∃x∈L ∩ A⇧⋆. y = map (φ g) x} ∪ {y. y = undefined ∧ (∃x. x ∈ L ∧ x ∉ A⇧⋆)} = L;
∀x∈set w. x ∈ A; ∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L); ∀x∈set w'. x ∈ A; ∀x∈set v. x ∈ A;
map (φ g) w @ v ∈ L⟧ ⟹ map (φ g) w' @ v ∈ L"
proof (-)
(*goal: ‹⋀(v::'alpha list) (w::'alpha list) w'::'alpha list. ⟦(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) (φ::'grp ⇒ 'alpha ⇒ 'alpha); group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); (L::'alpha list set) ⊆ A⇧⋆; ∀g::'grp∈carrier G. {y::'alpha list. ∃x::'alpha list∈L ∩ A⇧⋆. y = map (φ g) x} ∪ {y::'alpha list. y = undefined ∧ (∃x::'alpha list. x ∈ L ∧ x ∉ A⇧⋆)} = L; ∀x::'alpha∈set w. x ∈ A; ∀v::'alpha list∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L); ∀x::'alpha∈set w'. x ∈ A; ∀x::'alpha∈set v. x ∈ A; map (φ g) w @ v ∈ L⟧ ⟹ map (φ g) w' @ v ∈ L›*)
fix v and w and w'
assume A2_0: "g ∈ carrier G" and A2_1: "L ⊆ A⇧⋆" and A2_2: "group_hom G (BijGroup A) φ" and A2_3: "group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆))" and A2_4: "∀g∈carrier G. {y. ∃x∈L ∩ A⇧⋆. y = map (φ g) x} ∪
{y. y = undefined ∧ (∃x. x ∈ L ∧ x ∉ A⇧⋆)} = L" and A2_5: "∀x∈set w. x ∈ A" and A2_6: "∀x∈set w'. x ∈ A" and A2_7: "∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L)" and A2_8: "∀x∈set v. x ∈ A" and A2_9: "map (φ g) w @ v ∈ L" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹(L::'alpha list set) ⊆ A⇧⋆› ‹group_hom (G::('grp, 'b) monoid_scheme) (BijGroup A) (φ::'grp ⇒ 'alpha ⇒ 'alpha)› ‹group_hom (G::('grp, 'b) monoid_scheme) (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) g)) (A⇧⋆))› ‹∀g::'grp∈carrier (G::('grp, 'b) monoid_scheme). {y::'alpha list. ∃x::'alpha list∈(L::'alpha list set) ∩ A⇧⋆. y = map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) g) x} ∪ {y::'alpha list. y = undefined ∧ (∃x::'alpha list. x ∈ L ∧ x ∉ A⇧⋆)} = L› ‹∀x::'alpha∈set (w::'alpha list). x ∈ A› ‹∀x::'alpha∈set (w'::'alpha list). x ∈ A› ‹∀v::'alpha list∈A⇧⋆. ((w::'alpha list) @ v ∈ (L::'alpha list set)) = ((w'::'alpha list) @ v ∈ L)› ‹∀x::'alpha∈set (v::'alpha list). x ∈ A› ‹map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) @ (v::'alpha list) ∈ (L::'alpha list set)›*)
have H2_0: "∀g∈carrier G. {y. ∃x∈L ∩ A⇧⋆. y = map (φ g) x} = L"
using A2_1 (*‹L ⊆ A⇧⋆›*) A2_4 (*‹∀g::'grp::type∈carrier (G::('grp, 'b) monoid_scheme). {y::'alpha::type list. ∃x::'alpha::type list∈(L::'alpha::type list set) ∩ A⇧⋆. y = map ((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type) g) x} ∪ {y::'alpha::type list. y = undefined ∧ (∃x::'alpha::type list. x ∈ L ∧ x ∉ A⇧⋆)} = L›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) by (smt (verit, ccfv_SIG) Collect_mono_iff (*‹(Collect ?P ⊆ Collect ?Q) = (∀x. ?P x ⟶ ?Q x)›*) sup.orderE (*‹⟦?b ≤ ?a; ?a = sup ?a ?b ⟹ ?thesis⟧ ⟹ ?thesis›*))
hence H2_1: "∀g∈carrier G. {y. ∃x∈L. y = map (φ g) x} = L"
using A2_1 (*‹L ⊆ A⇧⋆›*) inf.absorb_iff1 (*‹(?a ≤ ?b) = (inf ?a ?b = ?a)›*) by (smt (verit, ccfv_SIG) Collect_cong (*‹(⋀x::?'a::type. (?P::?'a::type ⇒ bool) x = (?Q::?'a::type ⇒ bool) x) ⟹ {x::?'a::type. ?P x} = {x::?'a::type. ?Q x}›*))
hence H2_2: "∀g∈carrier G.∀x∈L. map (φ g) x ∈ L"
by auto
from A2_2 (*‹group_hom G (BijGroup A) φ›*) have H2_3: "∀h∈carrier G. ∀a∈A. (φ h) a ∈ A"
by (auto simp add: group_hom_def (*‹group_hom (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) BijGroup_def (*‹BijGroup (?S::?'a set) = ⦇carrier = Bij ?S, mult = λg::?'a ⇒ ?'a∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx::?'a∈?S. x⦈›*) group_hom_axioms_def (*‹group_hom_axioms (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom (?G::(?'a, ?'c) monoid_scheme) (?H::(?'b, ?'d) monoid_scheme) = {h::?'a ⇒ ?'b ∈ carrier ?G → carrier ?H. ∀x::?'a∈carrier ?G. ∀y::?'a∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) Bij_def (*‹Bij (?S::?'a set) = extensional ?S ∩ {f::?'a ⇒ ?'a. bij_betw f ?S ?S}›*) bij_betw_def (*‹bij_betw (?f::?'a ⇒ ?'b) (?A::?'a set) (?B::?'b set) = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*))
from A2_8 (*‹∀x∈set v. x ∈ A›*) have H2_4: "v ∈ A⇧⋆"
by (simp add: in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*))
hence H2_5: "∀h∈carrier G. map (φ h) v ∈ A⇧⋆"
using H2_3 (*‹∀h∈carrier G. ∀a∈A. φ h a ∈ A›*) by fastforce
hence H2_6: "∀h∈carrier G. (w @ (map (φ h) v) ∈ L) = (w' @ (map (φ h) v) ∈ L)"
using A2_7 (*‹∀v::'alpha::type list∈A⇧⋆. ((w::'alpha::type list) @ v ∈ (L::'alpha::type list set)) = ((w'::'alpha::type list) @ v ∈ L)›*) by force
hence H2_7: "(w @ (map (φ (inv⇘G⇙ g)) v) ∈ L) = (w' @ (map (φ (inv⇘G⇙ g)) v) ∈ L)"
using A2_0 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) by (meson A2_7 (*‹∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L)›*) A2_1 (*‹L ⊆ A⇧⋆›*) append_in_lists_conv (*‹(?xs @ ?ys ∈ ?A⇧⋆) = (?xs ∈ ?A⇧⋆ ∧ ?ys ∈ ?A⇧⋆)›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*))
have "(map (φ g) w) ∈ (A⇧⋆)"
using A2_0 (*‹g ∈ carrier G›*) A2_2 (*‹group_hom G (BijGroup A) φ›*) A2_5 (*‹∀x∈set w. x ∈ A›*) H2_3 (*‹∀h∈carrier G. ∀a∈A. φ h a ∈ A›*) by (auto simp add: group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*))
hence H2_8: "∀w∈A⇧⋆. ∀g∈carrier G. map (φ (inv⇘G⇙ g)) ((map (φ g) w) @ v) =
w @ (map (φ (inv⇘G⇙ g)) v)"
using act_maps_n_distrib (*‹∀g∈carrier G. ∀w∈A⇧⋆. ∀v∈A⇧⋆. (φ⇧⋆) g (w @ v) = (φ⇧⋆) g w @ (φ⇧⋆) g v›*) triv_act_map (*‹∀w∈A⇧⋆. (φ⇧⋆) 𝟭⇘G⇙ w = w›*) A2_0 (*‹g ∈ carrier G›*) A2_2 (*‹group_hom G (BijGroup A) φ›*) A2_3 (*‹group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆))›*) H2_4 (*‹v ∈ A⇧⋆›*) apply clarsimp
(*goal: ‹∀w∈A⇧⋆. ∀g∈carrier G. map (φ (inv⇘G⇙ g)) (map (φ g) w @ v) = w @ map (φ (inv⇘G⇙ g)) v›*)
by (smt (verit, del_insts) comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) group_action.intro (*‹group_hom ?G (BijGroup ?E) ?φ ⟹ group_action ?G ?E ?φ›*) group_action.orbit_sym_aux (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?φ (inv⇘?G⇙ ?g) ?y = ?x›*) map_idI (*‹(⋀x. x ∈ set ?xs ⟹ ?f x = x) ⟹ map ?f ?xs = ?xs›*))
have H2_9: "map (φ (inv⇘G⇙ g)) ((map (φ g) w) @ v) ∈ L"
using A2_9 (*‹map (φ g) w @ v ∈ L›*) H2_1 (*‹∀g∈carrier G. {y. ∃x∈L. y = map (φ g) x} = L›*) H2_2 (*‹∀g∈carrier G. ∀x∈L. map (φ g) x ∈ L›*) A2_1 (*‹(L::'alpha list set) ⊆ A⇧⋆›*) apply clarsimp
(*goal: ‹map (φ (inv⇘G⇙ g)) (map (φ g) w @ v) ∈ L›*)
by (metis A2_0 (*‹g ∈ carrier G›*) A2_2 (*‹group_hom G (BijGroup A) φ›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group_hom.axioms( (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) 1) list.map_comp (*‹map ?g (map ?f ?v) = map (?g ∘ ?f) ?v›*) map_append (*‹map ?f (?xs @ ?ys) = map ?f ?xs @ map ?f ?ys›*))
hence H2_10: "w @ (map (φ (inv⇘G⇙ g)) v) ∈ L"
using H2_8 (*‹∀w∈A⇧⋆. ∀g∈carrier G. map (φ (inv⇘G⇙ g)) (map (φ g) w @ v) = w @ map (φ (inv⇘G⇙ g)) v›*) A2_0 (*‹g ∈ carrier G›*) by (auto simp add: A2_5 (*‹∀x∈set w. x ∈ A›*) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*))
hence H2_11: "w' @ (map (φ (inv⇘G⇙ g)) v) ∈ L"
using H2_7 (*‹(w @ map (φ (inv⇘G⇙ g)) v ∈ L) = (w' @ map (φ (inv⇘G⇙ g)) v ∈ L)›*) by simp
hence H2_12: "map (φ (inv⇘G⇙ g)) ((map (φ g) w') @ v) ∈ L"
using A2_0 (*‹g ∈ carrier G›*) H2_8 (*‹∀w∈A⇧⋆. ∀g∈carrier G. map (φ (inv⇘G⇙ g)) (map (φ g) w @ v) = w @ map (φ (inv⇘G⇙ g)) v›*) A2_1 (*‹(L::'alpha list set) ⊆ A⇧⋆›*) subsetD (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); (?c::?'a) ∈ ?A⟧ ⟹ ?c ∈ ?B›*) by (metis append_in_lists_conv (*‹(?xs @ ?ys ∈ ?A⇧⋆) = (?xs ∈ ?A⇧⋆ ∧ ?ys ∈ ?A⇧⋆)›*))
have H2_13: "∀g∈carrier G. restrict (map (φ g)) (A⇧⋆) ∈ Bij (A⇧⋆)"
using alt_grp_act.lists_a_Gset[where G = "G" and X = "A" and φ = "φ"] (*‹alt_grp_act G A φ ⟹ alt_grp_act G (A⇧⋆) (φ⇧⋆)›*) A1_3 (*‹group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆))›*) by (auto simp add: group_action_def (*‹group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c set) (?φ::?'a ⇒ ?'c ⇒ ?'c) ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ≡ ?h ∈ hom ?G ?H›*) Pi_def (*‹Pi (?A::?'a set) (?B::?'a ⇒ ?'b set) = {f::?'a ⇒ ?'b. ∀x::?'a. x ∈ ?A ⟶ f x ∈ ?B x}›*) hom_def (*‹hom (?G::(?'a, ?'c) monoid_scheme) (?H::(?'b, ?'d) monoid_scheme) = {h::?'a ⇒ ?'b ∈ carrier ?G → carrier ?H. ∀x::?'a∈carrier ?G. ∀y::?'a∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) BijGroup_def (*‹BijGroup (?S::?'a set) = ⦇carrier = Bij ?S, mult = λg::?'a ⇒ ?'a∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx::?'a∈?S. x⦈›*))
have H2_14: "∀g∈carrier G. restrict (map (φ g)) L ` L = L"
using H2_2 (*‹∀g::'grp::type∈carrier (G::('grp, 'b) monoid_scheme). ∀x::'alpha::type list∈L::'alpha::type list set. map ((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type) g) x ∈ L›*) apply (clarsimp simp add: Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*goal: ‹∀g∈carrier G. restrict (map (φ g)) L ` L = L›*)
using H2_1 (*‹∀g∈carrier G. {y. ∃x∈L. y = map (φ g) x} = L›*) by blast
have H2_15: "map (φ g) w' ∈ A⇧⋆"
using A2_0 (*‹g ∈ carrier G›*) A2_1 (*‹(L::'alpha list set) ⊆ A⇧⋆›*) H2_13 (*‹∀g∈carrier G. restrict (map (φ g)) (A⇧⋆) ∈ Bij (A⇧⋆)›*) H2_2 (*‹∀g∈carrier G. ∀x∈L. map (φ g) x ∈ L›*) by (metis H2_11 (*‹w' @ map (φ (inv⇘G⇙ g)) v ∈ L›*) append_in_lists_conv (*‹(?xs @ ?ys ∈ ?A⇧⋆) = (?xs ∈ ?A⇧⋆ ∧ ?ys ∈ ?A⇧⋆)›*) image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*) lists_image (*‹(?f ` ?A)⇧⋆ = map ?f ` ?A⇧⋆›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) surj_prop (*‹?g ∈ carrier G ⟹ φ ?g ` A = A›*))
have H2_16: "inv⇘G⇙ g ∈ carrier G"
by (metis A2_0 (*‹g ∈ carrier G›*) A2_2 (*‹group_hom G (BijGroup A) φ›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group_hom.axioms( (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) 1))
thus "map (φ g) w' @ v ∈ L"
using A2_0 (*‹g ∈ carrier G›*) A2_1 (*‹L ⊆ A⇧⋆›*) A2_2 (*‹group_hom (G::('grp, 'b) monoid_scheme) (BijGroup A) (φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)›*) H2_4 (*‹v ∈ A⇧⋆›*) H2_12 (*‹map (φ (inv⇘G⇙ g)) (map (φ g) w' @ v) ∈ L›*) H2_13 (*‹∀g∈carrier G. restrict (map (φ g)) (A⇧⋆) ∈ Bij (A⇧⋆)›*) H2_14 (*‹∀g∈carrier G. restrict (map (φ g)) L ` L = L›*) H2_15 (*‹map (φ g) w' ∈ A⇧⋆›*) H2_16 (*‹inv⇘G⇙ g ∈ carrier G›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group_hom.axioms(1) (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) alt_grp_act.lists_a_Gset[where G = "G" and X = "A" and φ = "φ"] (*‹alt_grp_act G A φ ⟹ alt_grp_act G (A⇧⋆) (φ⇧⋆)›*) pre_image_lemma[where S = "L" and T = "A⇧⋆" and f = "map (φ (inv⇘G⇙ g))" and x = "((map (φ g) w') @ v)"] (*‹⟦L ⊆ A⇧⋆; map (φ g) w' @ v ∈ A⇧⋆ ∧ map (φ (inv⇘G⇙ g)) ∈ Bij (A⇧⋆); restrict (map (φ (inv⇘G⇙ g))) L ` L = L; map (φ (inv⇘G⇙ g)) (map (φ g) w' @ v) ∈ L⟧ ⟹ map (φ g) w' @ v ∈ L›*) apply (clarsimp simp add: group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*))
(*goal: ‹map (φ g) w' @ v ∈ L›*)
by (smt (verit, best) A2_1 (*‹L ⊆ A⇧⋆›*) FuncSet.restrict_restrict (*‹restrict (restrict ?f ?A) ?B = restrict ?f (?A ∩ ?B)›*) H2_14 (*‹∀g∈carrier G. restrict (map (φ g)) L ` L = L›*) H2_15 (*‹map (φ g) w' ∈ A⇧⋆›*) H2_16 (*‹inv⇘G⇙ g ∈ carrier G›*) H2_4 (*‹v ∈ A⇧⋆›*) append_in_lists_conv (*‹(?xs @ ?ys ∈ ?A⇧⋆) = (?xs ∈ ?A⇧⋆ ∧ ?ys ∈ ?A⇧⋆)›*) inf.absorb_iff2 (*‹(?b ≤ ?a) = (inf ?a ?b = ?b)›*) map_append (*‹map ?f (?xs @ ?ys) = map ?f ?xs @ map ?f ?ys›*) map_map (*‹map ?f (map ?g ?xs) = map (?f ∘ ?g) ?xs›*) pre_image_lemma (*‹⟦?S ⊆ ?T; ?x ∈ ?T ∧ ?f ∈ Bij ?T; restrict ?f ?S ` ?S = ?S; ?f ?x ∈ ?S⟧ ⟹ ?x ∈ ?S›*) restrict_apply' (*‹?x ∈ ?A ⟹ restrict ?f ?A ?x = ?f ?x›*) restrict_apply' (*‹?x ∈ ?A ⟹ restrict ?f ?A ?x = ?f ?x›*))
qed
show "(map (φ g) w, map (φ g) w') ∈ ≡⇩M⇩N"
apply (clarsimp simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*goal: ‹(map (φ g) w, map (φ g) w') ∈ ≡⇩M⇩N›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) ∈ A⇧⋆ ∧ map (φ g) (w'::'alpha list) ∈ A⇧⋆ ∧ (∀v::'alpha list∈A⇧⋆. (map (φ g) w @ v ∈ (L::'alpha list set)) = (map (φ g) w' @ v ∈ L))›*)
using A1_1 (*‹g ∈ carrier G›*) A1_6 (*‹∀x∈set w. x ∈ A›*) group_action.surj_prop (*‹⟦group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c set) (?φ::?'a ⇒ ?'c ⇒ ?'c); (?g::?'a) ∈ carrier ?G⟧ ⟹ ?φ ?g ` ?E = ?E›*) group_action_axioms (*‹group_action G A φ›*) apply fastforce
(*top goal: ‹map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) ∈ A⇧⋆› and 2 goals remain*)
using A1_1 (*‹g ∈ carrier G›*) A1_7 (*‹w' ∈ A⇧⋆›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) surj_prop (*‹?g ∈ carrier G ⟹ φ ?g ` A = A›*) apply fastforce
(*top goal: ‹map (φ g) w' ∈ A⇧⋆› and 1 goal remains*)
apply (clarify; rule iffI (*‹⟦?P::bool ⟹ ?Q::bool; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))
(*goal: ‹∀v::'alpha list∈A⇧⋆. (map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) @ v ∈ (L::'alpha list set)) = (map (φ g) (w'::'alpha list) @ v ∈ L)›*)
subgoal for v
apply (rule H1_0[where v1 ="v" and w1 = "w" and w'1 = "w'"] (*‹⟦(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) (φ::'grp ⇒ 'alpha ⇒ 'alpha); group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); (L::'alpha list set) ⊆ A⇧⋆; ∀g::'grp∈carrier G. {y::'alpha list. ∃x::'alpha list∈L ∩ A⇧⋆. y = map (φ g) x} ∪ {y::'alpha list. y = undefined ∧ (∃x::'alpha list. x ∈ L ∧ x ∉ A⇧⋆)} = L; ∀x::'alpha∈set (w::'alpha list). x ∈ A; ∀v::'alpha list∈A⇧⋆. (w @ v ∈ L) = ((w'::'alpha list) @ v ∈ L); ∀x::'alpha∈set w'. x ∈ A; ∀x::'alpha∈set (v::'alpha list). x ∈ A; map (φ g) w @ v ∈ L⟧ ⟹ map (φ g) w' @ v ∈ L›*))
(*goal: ‹⟦∀x∈set v. x ∈ A; map (φ g) w @ v ∈ L⟧ ⟹ map (φ g) w' @ v ∈ L›*)
using A1_0 (*‹(w, w') ∈ ≡⇩M⇩N›*) A1_1 (*‹g ∈ carrier G›*) A1_2 (*‹group_hom G (BijGroup A) φ›*) A1_3 (*‹group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆))›*) A1_4 (*‹L ⊆ A⇧⋆›*) A1_5 (*‹∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L›*) A1_6 (*‹∀x∈set w. x ∈ A›*) A1_7 (*‹w' ∈ A⇧⋆›*) apply -
(*goals:
1. ‹⟦∀x::'alpha∈set (v::'alpha list). x ∈ A; map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) @ v ∈ (L::'alpha list set); (w, w'::'alpha list) ∈ ≡⇩M⇩N; g ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g::'grp∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx::'alpha list. undefined) ` (L ∩ {x::'alpha list. x ∉ A⇧⋆}) = L; ∀x::'alpha∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ g ∈ carrier G›
2. ‹⟦∀x::'alpha∈set (v::'alpha list). x ∈ A; map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) @ v ∈ (L::'alpha list set); (w, w'::'alpha list) ∈ ≡⇩M⇩N; g ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g::'grp∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx::'alpha list. undefined) ` (L ∩ {x::'alpha list. x ∉ A⇧⋆}) = L; ∀x::'alpha∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ group_hom G (BijGroup A) φ›
3. ‹⟦∀x::'alpha∈set (v::'alpha list). x ∈ A; map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) @ v ∈ (L::'alpha list set); (w, w'::'alpha list) ∈ ≡⇩M⇩N; g ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g::'grp∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx::'alpha list. undefined) ` (L ∩ {x::'alpha list. x ∉ A⇧⋆}) = L; ∀x::'alpha∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆))›
4. ‹⟦∀x::'alpha∈set (v::'alpha list). x ∈ A; map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) @ v ∈ (L::'alpha list set); (w, w'::'alpha list) ∈ ≡⇩M⇩N; g ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g::'grp∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx::'alpha list. undefined) ` (L ∩ {x::'alpha list. x ∉ A⇧⋆}) = L; ∀x::'alpha∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ L ⊆ A⇧⋆›
5. ‹⟦∀x::'alpha∈set (v::'alpha list). x ∈ A; map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) @ v ∈ (L::'alpha list set); (w, w'::'alpha list) ∈ ≡⇩M⇩N; g ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g::'grp∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx::'alpha list. undefined) ` (L ∩ {x::'alpha list. x ∉ A⇧⋆}) = L; ∀x::'alpha∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ ∀g::'grp∈carrier G. {y::'alpha list. ∃x::'alpha list∈L ∩ A⇧⋆. y = map (φ g) x} ∪ {y::'alpha list. y = undefined ∧ (∃x::'alpha list. x ∈ L ∧ x ∉ A⇧⋆)} = L›
6. ‹⟦∀x::'alpha∈set (v::'alpha list). x ∈ A; map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) @ v ∈ (L::'alpha list set); (w, w'::'alpha list) ∈ ≡⇩M⇩N; g ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g::'grp∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx::'alpha list. undefined) ` (L ∩ {x::'alpha list. x ∉ A⇧⋆}) = L; ∀x::'alpha∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ ∀x::'alpha∈set w. x ∈ A›
7. ‹⟦∀x::'alpha∈set (v::'alpha list). x ∈ A; map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) @ v ∈ (L::'alpha list set); (w, w'::'alpha list) ∈ ≡⇩M⇩N; g ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g::'grp∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx::'alpha list. undefined) ` (L ∩ {x::'alpha list. x ∉ A⇧⋆}) = L; ∀x::'alpha∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ ∀v::'alpha list∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L)›
8. ‹⟦∀x::'alpha∈set (v::'alpha list). x ∈ A; map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) @ v ∈ (L::'alpha list set); (w, w'::'alpha list) ∈ ≡⇩M⇩N; g ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g::'grp∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx::'alpha list. undefined) ` (L ∩ {x::'alpha list. x ∉ A⇧⋆}) = L; ∀x::'alpha∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ ∀x::'alpha∈set w'. x ∈ A›
9. ‹⟦∀x::'alpha∈set (v::'alpha list). x ∈ A; map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) @ v ∈ (L::'alpha list set); (w, w'::'alpha list) ∈ ≡⇩M⇩N; g ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g::'grp∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx::'alpha list. undefined) ` (L ∩ {x::'alpha list. x ∉ A⇧⋆}) = L; ∀x::'alpha∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ ∀x::'alpha∈set v. x ∈ A›
10. ‹⟦∀x::'alpha∈set (v::'alpha list). x ∈ A; map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) @ v ∈ (L::'alpha list set); (w, w'::'alpha list) ∈ ≡⇩M⇩N; g ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g::'grp∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx::'alpha list. undefined) ` (L ∩ {x::'alpha list. x ∉ A⇧⋆}) = L; ∀x::'alpha∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ map (φ g) w @ v ∈ L›
discuss goal 1*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w::'alpha list, w'::'alpha list). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v::'alpha list∈A⇧⋆. (w @ v ∈ (L::'alpha list set)) = (w' @ v ∈ L))}›*) Set.image_def (*‹(?f::?'a ⇒ ?'b) ` (?A::?'a set) = {y::?'b. ∃x::?'a∈?A. y = ?f x}›*))[1])
(*discuss goal 2*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 3*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 4*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 5*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 6*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 7*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 8*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 9*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 10*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*proven 10 subgoals*) .
apply (rule H1_0[where w1 = "w'" and w'1 = "w"] (*‹⟦(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) (φ::'grp ⇒ 'alpha ⇒ 'alpha); group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); (L::'alpha list set) ⊆ A⇧⋆; ∀g::'grp∈carrier G. {y::'alpha list. ∃x::'alpha list∈L ∩ A⇧⋆. y = map (φ g) x} ∪ {y::'alpha list. y = undefined ∧ (∃x::'alpha list. x ∈ L ∧ x ∉ A⇧⋆)} = L; ∀x::'alpha∈set (w'::'alpha list). x ∈ A; ∀v::'alpha list∈A⇧⋆. (w' @ v ∈ L) = ((w::'alpha list) @ v ∈ L); ∀x::'alpha∈set w. x ∈ A; ∀x::'alpha∈set (?v1::'alpha list). x ∈ A; map (φ g) w' @ ?v1 ∈ L⟧ ⟹ map (φ g) w @ ?v1 ∈ L›*))
(*goal: ‹⋀v. ⟦∀x∈set v. x ∈ A; map (φ g) w' @ v ∈ L⟧ ⟹ map (φ g) w @ v ∈ L›*)
using A1_0 (*‹(w, w') ∈ ≡⇩M⇩N›*) A1_1 (*‹(g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A1_2 (*‹group_hom G (BijGroup A) φ›*) A1_3 (*‹group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆))›*) A1_4 (*‹L ⊆ A⇧⋆›*) A1_5 (*‹∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L›*) A1_6 (*‹∀x∈set w. x ∈ A›*) A1_7 (*‹(w'::'alpha list) ∈ A⇧⋆›*) apply -
(*goals:
1. ‹⋀v. ⟦∀x∈set v. x ∈ A; map (φ g) w' @ v ∈ L; (w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ g ∈ carrier G›
2. ‹⋀v. ⟦∀x∈set v. x ∈ A; map (φ g) w' @ v ∈ L; (w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ group_hom G (BijGroup A) φ›
3. ‹⋀v. ⟦∀x∈set v. x ∈ A; map (φ g) w' @ v ∈ L; (w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆))›
4. ‹⋀v. ⟦∀x∈set v. x ∈ A; map (φ g) w' @ v ∈ L; (w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ L ⊆ A⇧⋆›
5. ‹⋀v. ⟦∀x∈set v. x ∈ A; map (φ g) w' @ v ∈ L; (w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ ∀g∈carrier G. {y. ∃x∈L ∩ A⇧⋆. y = map (φ g) x} ∪ {y. y = undefined ∧ (∃x. x ∈ L ∧ x ∉ A⇧⋆)} = L›
6. ‹⋀v. ⟦∀x∈set v. x ∈ A; map (φ g) w' @ v ∈ L; (w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ ∀x∈set w'. x ∈ A›
7. ‹⋀v. ⟦∀x∈set v. x ∈ A; map (φ g) w' @ v ∈ L; (w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ ∀v∈A⇧⋆. (w' @ v ∈ L) = (w @ v ∈ L)›
8. ‹⋀v. ⟦∀x∈set v. x ∈ A; map (φ g) w' @ v ∈ L; (w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ ∀x∈set w. x ∈ A›
9. ‹⋀v. ⟦∀x∈set v. x ∈ A; map (φ g) w' @ v ∈ L; (w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ ∀x∈set v. x ∈ A›
10. ‹⋀v. ⟦∀x∈set v. x ∈ A; map (φ g) w' @ v ∈ L; (w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ map (φ g) w' @ v ∈ L›
discuss goal 1*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 2*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 3*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 4*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w::'alpha::type list, w'::'alpha::type list). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v::'alpha::type list∈A⇧⋆. (w @ v ∈ (L::'alpha::type list set)) = (w' @ v ∈ L))}›*) Set.image_def (*‹(?f::?'a::type ⇒ ?'b::type) ` (?A::?'a::type set) = {y::?'b::type. ∃x::?'a::type∈?A. y = ?f x}›*))[1])
(*discuss goal 5*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 6*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 7*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 8*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) Set.image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*discuss goal 9*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w::'alpha list, w'::'alpha list). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v::'alpha list∈A⇧⋆. (w @ v ∈ (L::'alpha list set)) = (w' @ v ∈ L))}›*) Set.image_def (*‹(?f::?'a ⇒ ?'b) ` (?A::?'a set) = {y::?'b. ∃x::?'a∈?A. y = ?f x}›*))[1])
(*discuss goal 10*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w::'alpha::type list, w'::'alpha::type list). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v::'alpha::type list∈A⇧⋆. (w @ v ∈ (L::'alpha::type list set)) = (w' @ v ∈ L))}›*) Set.image_def (*‹(?f::?'a::type ⇒ ?'b::type) ` (?A::?'a::type set) = {y::?'b::type. ∃x::?'a::type∈?A. y = ?f x}›*))[1])
(*proven 10 subgoals*) .
qed
show "?thesis"
(*goal: ‹∀g∈carrier G. g ⊙⇘φ⇧⋆⇙ w' ∈ [g ⊙⇘φ⇧⋆⇙ w]⇩M⇩N›*)
using G_lang_axioms (*‹G_lang G A φ L›*) A_0 (*‹w' ∈ [w]⇩M⇩N›*) apply (clarsimp simp add: G_lang_def (*‹G_lang (?G::(?'grp, ?'b) monoid_scheme) (?A::?'alpha set) (?φ::?'grp ⇒ ?'alpha ⇒ ?'alpha) (?L::?'alpha list set) ≡ alt_grp_act ?G ?A ?φ ∧ language ?A ?L ∧ G_lang_axioms ?G ?A ?φ ?L›*) G_lang_axioms_def (*‹G_lang_axioms (?G::(?'grp, ?'b) monoid_scheme) (?A::?'alpha set) (?φ::?'grp ⇒ ?'alpha ⇒ ?'alpha) (?L::?'alpha list set) ≡ eq_var_subset ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) ?L›*) eq_var_subset_def (*‹eq_var_subset (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'X set) ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'X set) ≡ ?Y ⊆ ?X ∧ (∀g::?'grp∈carrier ?G. ?φ g ` ?Y = ?Y)›*) alt_grp_act_def (*‹alt_grp_act (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) ≡ group_action ?G ?X ?φ›*) group_action_def (*‹group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c set) (?φ::?'a ⇒ ?'c ⇒ ?'c) ≡ group_hom ?G (BijGroup ?E) ?φ›*))
(*goal: ‹∀g∈carrier G. g ⊙⇘φ⇧⋆⇙ w' ∈ [g ⊙⇘φ⇧⋆⇙ w]⇩M⇩N›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⋀g::'grp. ⟦(w::'alpha list, w'::'alpha list) ∈ ≡⇩M⇩N; g ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) (φ::'grp ⇒ 'alpha ⇒ 'alpha); group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); (L::'alpha list set) ⊆ A⇧⋆; ∀g::'grp∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx::'alpha list. undefined) ` (L ∩ {x::'alpha list. x ∉ A⇧⋆}) = L⟧ ⟹ w ∈ A⇧⋆ ⟶ (w' ∈ A⇧⋆ ⟶ (map (φ g) w, map (φ g) w') ∈ ≡⇩M⇩N) ∧ (w' ∉ A⇧⋆ ⟶ (map (φ g) w, undefined) ∈ ≡⇩M⇩N)›
2. ‹⋀g::'grp. ⟦(w::'alpha list, w'::'alpha list) ∈ ≡⇩M⇩N; g ∈ carrier (G::('grp, 'b) monoid_scheme); group_hom G (BijGroup A) (φ::'grp ⇒ 'alpha ⇒ 'alpha); group_hom G (BijGroup (A⇧⋆)) (λg::'grp∈carrier G. restrict (map (φ g)) (A⇧⋆)); (L::'alpha list set) ⊆ A⇧⋆; ∀g::'grp∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx::'alpha list. undefined) ` (L ∩ {x::'alpha list. x ∉ A⇧⋆}) = L⟧ ⟹ w ∉ A⇧⋆ ⟶ (w' ∈ A⇧⋆ ⟶ (undefined, map (φ g) w') ∈ ≡⇩M⇩N) ∧ (w' ∉ A⇧⋆ ⟶ (undefined, undefined) ∈ ≡⇩M⇩N)›
discuss goal 1*)
apply clarify
(*top goal: ‹⋀g. ⟦(w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L⟧ ⟹ w ∈ A⇧⋆ ⟶ (w' ∈ A⇧⋆ ⟶ (map (φ g) w, map (φ g) w') ∈ ≡⇩M⇩N) ∧ (w' ∉ A⇧⋆ ⟶ (map (φ g) w, undefined) ∈ ≡⇩M⇩N)› and 1 goal remains*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⋀g. ⟦(w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A⟧ ⟹ w' ∈ A⇧⋆ ⟶ (map (φ g) w, map (φ g) w') ∈ ≡⇩M⇩N›
2. ‹⋀g. ⟦(w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A⟧ ⟹ w' ∉ A⇧⋆ ⟶ (map (φ g) w, undefined) ∈ ≡⇩M⇩N›
discuss goal 1*)
apply (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*top goal: ‹⋀g. ⟦(w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A⟧ ⟹ w' ∈ A⇧⋆ ⟶ (map (φ g) w, map (φ g) w') ∈ ≡⇩M⇩N› and 2 goals remain*)
apply (simp add: H_0 (*‹⟦(w, w') ∈ ≡⇩M⇩N; ?g1 ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A; w' ∈ A⇧⋆⟧ ⟹ (map (φ ?g1) w, map (φ ?g1) w') ∈ ≡⇩M⇩N›*))
(*discuss goal 2*)
apply (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*top goal: ‹⋀g. ⟦(w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L; ∀x∈set w. x ∈ A⟧ ⟹ w' ∉ A⇧⋆ ⟶ (map (φ g) w, undefined) ∈ ≡⇩M⇩N› and 1 goal remains*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*))[1])
(*proven 2 subgoals*)
(*discuss goal 2*)
apply clarify
(*goal: ‹⋀g. ⟦(w, w') ∈ ≡⇩M⇩N; g ∈ carrier G; group_hom G (BijGroup A) φ; group_hom G (BijGroup (A⇧⋆)) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); L ⊆ A⇧⋆; ∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L⟧ ⟹ w ∉ A⇧⋆ ⟶ (w' ∈ A⇧⋆ ⟶ (undefined, map (φ g) w') ∈ ≡⇩M⇩N) ∧ (w' ∉ A⇧⋆ ⟶ (undefined, undefined) ∈ ≡⇩M⇩N)›*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*))[1])
(*proven 2 subgoals*) .
qed
text ‹
The following lemma corresponds to lemma 3.4 from \cite{bojanczyk2014automata}:
›
lemma MN_rel_eq_var:
"eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N"
apply (clarsimp simp add: eq_var_rel_def (*‹eq_var_rel ?G ?X ?φ ?R ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_rel_axioms ?G ?X ?φ ?R›*) alt_grp_act_def (*‹alt_grp_act ?G ?X ?φ ≡ group_action ?G ?X ?φ›*) eq_var_rel_axioms_def (*‹eq_var_rel_axioms ?G ?X ?φ ?R ≡ ?R ⊆ ?X × ?X ∧ (∀a b. (a, b) ∈ ?R ⟶ (∀g∈carrier ?G. (g ⊙⇘?φ⇙ a, g ⊙⇘?φ⇙ b) ∈ ?R))›*))
(*goal: ‹eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹group_action G (A⇧⋆) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)) ∧ ≡⇩M⇩N ⊆ A⇧⋆ × A⇧⋆ ∧ (∀a b. (a, b) ∈ ≡⇩M⇩N ⟶ (∀g∈carrier G. (a ∈ A⇧⋆ ⟶ (b ∈ A⇧⋆ ⟶ (map (φ g) a, map (φ g) b) ∈ ≡⇩M⇩N) ∧ (b ∉ A⇧⋆ ⟶ (map (φ g) a, undefined) ∈ ≡⇩M⇩N)) ∧ (a ∉ A⇧⋆ ⟶ (b ∈ A⇧⋆ ⟶ (undefined, map (φ g) b) ∈ ≡⇩M⇩N) ∧ (b ∉ A⇧⋆ ⟶ (undefined, undefined) ∈ ≡⇩M⇩N))))›*)
apply (metis L_is_equivar (*‹eq_var_subset (G::('grp, 'b) monoid_scheme) (A⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) (L::'alpha list set)›*) alt_grp_act.axioms (*‹alt_grp_act (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) ⟹ group_action ?G ?X ?φ›*) eq_var_subset.axioms( (*‹eq_var_subset (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'X set) ⟹ alt_grp_act ?G ?X ?φ›*) 1) induced_star_map_def (*‹(?func::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆ = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) (A⇧⋆))›*))
(*top goal: ‹group_action G (A⇧⋆) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆))› and 2 goals remain*)
using L_is_equivar (*‹eq_var_subset G (A⇧⋆) (φ⇧⋆) L›*) apply (simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*))
(*top goal: ‹≡⇩M⇩N ⊆ A⇧⋆ × A⇧⋆› and 1 goal remains*)
apply fastforce
(*top goal: ‹group_action G (A⇧⋆) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)) ∧ L ⊆ A⇧⋆ ∧ (∀g∈carrier G. map (φ g) ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L) ⟹ {(w, w'). w ∈ A⇧⋆ ∧ w' ∈ A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))} ⊆ A⇧⋆ × A⇧⋆› and 1 goal remains*)
apply clarify
(*goal: ‹∀(a::'alpha list) b::'alpha list. (a, b) ∈ ≡⇩M⇩N ⟶ (∀g::'grp∈carrier (G::('grp, 'b) monoid_scheme). (a ∈ A⇧⋆ ⟶ (b ∈ A⇧⋆ ⟶ (map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) g) a, map (φ g) b) ∈ ≡⇩M⇩N) ∧ (b ∉ A⇧⋆ ⟶ (map (φ g) a, undefined) ∈ ≡⇩M⇩N)) ∧ (a ∉ A⇧⋆ ⟶ (b ∈ A⇧⋆ ⟶ (undefined, map (φ g) b) ∈ ≡⇩M⇩N) ∧ (b ∉ A⇧⋆ ⟶ (undefined, undefined) ∈ ≡⇩M⇩N)))›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*); rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀a b g. ⟦(a, b) ∈ ≡⇩M⇩N; g ∈ carrier G⟧ ⟹ (a ∈ A⇧⋆ ⟶ (b ∈ A⇧⋆ ⟶ (map (φ g) a, map (φ g) b) ∈ ≡⇩M⇩N) ∧ (b ∉ A⇧⋆ ⟶ (map (φ g) a, undefined) ∈ ≡⇩M⇩N)) ∧ (a ∉ A⇧⋆ ⟶ (b ∈ A⇧⋆ ⟶ (undefined, map (φ g) b) ∈ ≡⇩M⇩N) ∧ (b ∉ A⇧⋆ ⟶ (undefined, undefined) ∈ ≡⇩M⇩N))›*)
apply (simp add: in_lists_conv_set (*‹(?xs ∈ ?A⇧⋆) = (∀x∈set ?xs. x ∈ ?A)›*))
(*top goal: ‹⋀(a::'alpha list) (b::'alpha list) g::'grp. ⟦(a, b) ∈ ≡⇩M⇩N; g ∈ carrier (G::('grp, 'b) monoid_scheme); a ∈ A⇧⋆; b ∈ A⇧⋆⟧ ⟹ (map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) g) a, map (φ g) b) ∈ ≡⇩M⇩N› and 3 goals remain*)
apply (clarsimp simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*))
(*top goal: ‹⋀a b g. ⟦(a, b) ∈ ≡⇩M⇩N; g ∈ carrier G; ∀x∈set a. x ∈ A; ∀x∈set b. x ∈ A⟧ ⟹ (map (φ g) a, map (φ g) b) ∈ ≡⇩M⇩N› and 3 goals remain*)
apply (intro conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*top goal: ‹⋀a b g. ⟦g ∈ carrier G; ∀x∈set a. x ∈ A; ∀v∈A⇧⋆. (a @ v ∈ L) = (b @ v ∈ L); ∀x∈set b. x ∈ A⟧ ⟹ map (φ g) a ∈ A⇧⋆ ∧ map (φ g) b ∈ A⇧⋆ ∧ (∀v∈A⇧⋆. (map (φ g) a @ v ∈ L) = (map (φ g) b @ v ∈ L))› and 3 goals remain*)
apply (clarsimp simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*))
(*top goal: ‹⋀a b g. ⟦g ∈ carrier G; ∀x∈set a. x ∈ A; ∀v∈A⇧⋆. (a @ v ∈ L) = (b @ v ∈ L); ∀x∈set b. x ∈ A⟧ ⟹ map (φ g) a ∈ A⇧⋆› and 5 goals remain*)
subgoal for w and v and g and w'
using L_is_equivar (*‹eq_var_subset G (A⇧⋆) (φ⇧⋆) L›*) apply (clarsimp simp add: restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*) eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*))
(*goal: ‹⟦g ∈ carrier G; ∀x∈set w. x ∈ A; ∀va∈A⇧⋆. (w @ va ∈ L) = (v @ va ∈ L); ∀x∈set v. x ∈ A; w' ∈ set w⟧ ⟹ φ g w' ∈ A›*)
by (meson element_image (*‹⟦?g ∈ carrier G; ?x ∈ A; φ ?g ?x = ?y⟧ ⟹ ?y ∈ A›*))
apply (metis image_mono (*‹?A ⊆ ?B ⟹ ?f ` ?A ⊆ ?f ` ?B›*) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*) list.set_map (*‹set (map ?f ?v) = ?f ` set ?v›*) lists_mono (*‹?A ⊆ ?B ⟹ ?A⇧⋆ ⊆ ?B⇧⋆›*) subset_code( (*‹(set ?xs ⊆ ?B) = (∀x∈set ?xs. x ∈ ?B)›*) 1) surj_prop (*‹?g ∈ carrier G ⟹ φ ?g ` A = A›*))
(*top goal: ‹⋀a b g. ⟦g ∈ carrier G; ∀x∈set a. x ∈ A; ∀v∈A⇧⋆. (a @ v ∈ L) = (b @ v ∈ L); ∀x∈set b. x ∈ A⟧ ⟹ map (φ g) b ∈ A⇧⋆› and 4 goals remain*)
apply (clarify; rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))
(*top goal: ‹⋀a b g. ⟦g ∈ carrier G; ∀x∈set a. x ∈ A; ∀v∈A⇧⋆. (a @ v ∈ L) = (b @ v ∈ L); ∀x∈set b. x ∈ A⟧ ⟹ ∀v∈A⇧⋆. (map (φ g) a @ v ∈ L) = (map (φ g) b @ v ∈ L)› and 3 goals remain*)
subgoal for w and v and g and u
using G_lang_axioms (*‹G_lang G A φ L›*) MN_quot_act_wd[where w = "w" and w' = "v"] (*‹v ∈ [w]⇩M⇩N ⟹ ∀g∈carrier G. g ⊙⇘φ⇧⋆⇙ v ∈ [g ⊙⇘φ⇧⋆⇙ w]⇩M⇩N›*) by (auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) G_lang_def (*‹G_lang ?G ?A ?φ ?L ≡ alt_grp_act ?G ?A ?φ ∧ language ?A ?L ∧ G_lang_axioms ?G ?A ?φ ?L›*) G_lang_axioms_def (*‹G_lang_axioms ?G ?A ?φ ?L ≡ eq_var_subset ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) ?L›*) eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*) Set.subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) element_image (*‹⟦?g ∈ carrier G; ?x ∈ A; φ ?g ?x = ?y⟧ ⟹ ?y ∈ A›*))
subgoal for w and v and g and u
using G_lang_axioms (*‹G_lang (G::('grp, 'b) monoid_scheme) A (φ::'grp ⇒ 'alpha ⇒ 'alpha) (L::'alpha list set)›*) MN_quot_act_wd[where w = "w" and w' = "v"] (*‹(v::'alpha::type list) ∈ [w::'alpha::type list]⇩M⇩N ⟹ ∀g::'grp::type∈carrier (G::('grp, 'b) monoid_scheme). g ⊙⇘(φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆⇙ v ∈ [g ⊙⇘φ⇧⋆⇙ w]⇩M⇩N›*) by (auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) G_lang_def (*‹G_lang ?G ?A ?φ ?L ≡ alt_grp_act ?G ?A ?φ ∧ language ?A ?L ∧ G_lang_axioms ?G ?A ?φ ?L›*) G_lang_axioms_def (*‹G_lang_axioms ?G ?A ?φ ?L ≡ eq_var_subset ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) ?L›*) eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*) Set.subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) element_image (*‹⟦?g ∈ carrier G; ?x ∈ A; φ ?g ?x = ?y⟧ ⟹ ?y ∈ A›*))
using G_lang_axioms (*‹G_lang G A φ L›*) MN_quot_act_wd (*‹?w' ∈ [?w]⇩M⇩N ⟹ ∀g∈carrier G. g ⊙⇘φ⇧⋆⇙ ?w' ∈ [g ⊙⇘φ⇧⋆⇙ ?w]⇩M⇩N›*)
(*goals:
1. ‹⋀a b g. ⟦(a, b) ∈ ≡⇩M⇩N; g ∈ carrier G; a ∈ A⇧⋆; b ∉ A⇧⋆⟧ ⟹ (map (φ g) a, undefined) ∈ ≡⇩M⇩N›
2. ‹⋀a b g. ⟦(a, b) ∈ ≡⇩M⇩N; g ∈ carrier G; a ∉ A⇧⋆; b ∈ A⇧⋆⟧ ⟹ (undefined, map (φ g) b) ∈ ≡⇩M⇩N›
3. ‹⋀a b g. ⟦(a, b) ∈ ≡⇩M⇩N; g ∈ carrier G; a ∉ A⇧⋆; b ∉ A⇧⋆⟧ ⟹ (undefined, undefined) ∈ ≡⇩M⇩N›
discuss goal 1*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w::'alpha list, w'::'alpha list). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v::'alpha list∈A⇧⋆. (w @ v ∈ (L::'alpha list set)) = (w' @ v ∈ L))}›*) G_lang_def (*‹G_lang (?G::(?'grp, ?'b) monoid_scheme) (?A::?'alpha set) (?φ::?'grp ⇒ ?'alpha ⇒ ?'alpha) (?L::?'alpha list set) ≡ alt_grp_act ?G ?A ?φ ∧ language ?A ?L ∧ G_lang_axioms ?G ?A ?φ ?L›*) G_lang_axioms_def (*‹G_lang_axioms (?G::(?'grp, ?'b) monoid_scheme) (?A::?'alpha set) (?φ::?'grp ⇒ ?'alpha ⇒ ?'alpha) (?L::?'alpha list set) ≡ eq_var_subset ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) ?L›*) eq_var_subset_def (*‹eq_var_subset (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'X set) ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'X set) ≡ ?Y ⊆ ?X ∧ (∀g::?'grp∈carrier ?G. ?φ g ` ?Y = ?Y)›*) Set.subset_eq (*‹((?A::?'a set) ⊆ (?B::?'a set)) = (∀x::?'a∈?A. x ∈ ?B)›*) element_image (*‹⟦(?g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); (?x::'alpha) ∈ A; (φ::'grp ⇒ 'alpha ⇒ 'alpha) ?g ?x = (?y::'alpha)⟧ ⟹ ?y ∈ A›*))[1])
(*discuss goal 2*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) G_lang_def (*‹G_lang ?G ?A ?φ ?L ≡ alt_grp_act ?G ?A ?φ ∧ language ?A ?L ∧ G_lang_axioms ?G ?A ?φ ?L›*) G_lang_axioms_def (*‹G_lang_axioms ?G ?A ?φ ?L ≡ eq_var_subset ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) ?L›*) eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*) Set.subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) element_image (*‹⟦?g ∈ carrier G; ?x ∈ A; φ ?g ?x = ?y⟧ ⟹ ?y ∈ A›*))[1])
(*discuss goal 3*)
apply ((auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) G_lang_def (*‹G_lang ?G ?A ?φ ?L ≡ alt_grp_act ?G ?A ?φ ∧ language ?A ?L ∧ G_lang_axioms ?G ?A ?φ ?L›*) G_lang_axioms_def (*‹G_lang_axioms ?G ?A ?φ ?L ≡ eq_var_subset ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) ?L›*) eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*) Set.subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) element_image (*‹⟦?g ∈ carrier G; ?x ∈ A; φ ?g ?x = ?y⟧ ⟹ ?y ∈ A›*))[1])
(*proven 3 subgoals*) .
lemma quot_act_wd_alt_notation:
"w ∈ A⇧⋆ ⟹ g ∈ carrier G ⟹ g ⊙⇘[φ⇧⋆]⇩≡⇩M⇩N ⇘A⇧⋆⇙⇙ ([w]⇩M⇩N) = ([g ⊙⇘φ⇧⋆⇙ w]⇩M⇩N)"
using eq_var_rel.quot_act_wd[where G = G and φ = "φ⇧⋆" and X = "A⇧⋆" and R = "≡⇩M⇩N" and x = w and g = g] (*‹⟦eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N; equiv (A⇧⋆) ≡⇩M⇩N; w ∈ A⇧⋆; g ∈ carrier G⟧ ⟹ g ⊙⇘[φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙⇙ ≡⇩M⇩N `` {w} = ≡⇩M⇩N `` {g ⊙⇘φ⇧⋆⇙ w}›*) by (simp del: GMN_simps (*‹(⊙⇘?φ::?'grp ⇒ ?'X ⇒ ?'X⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹(?func::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆ = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) (A⇧⋆))› ‹[?func::'grp ⇒ ?'Y ⇒ ?'Y]⇩?R::(?'Y × ?'Y) set⇘?S::?'Y set⇙ = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). λx::?'Y set∈?S // ?R. ?R `` {?func g (SOME z::?'Y. z ∈ x)})› ‹[?w::'alpha list]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N (?W'::'alpha list set) (?a'::'alpha) = (λ(W::'alpha list set, a::'alpha)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w::'alpha list. w ∈ W) @ [a]}) (?W', ?a')›*) add: alt_natural_map_MN_def (*‹[?w::'alpha list]⇩M⇩N = ≡⇩M⇩N `` {?w}›*) MN_rel_eq_var (*‹eq_var_rel (G::('grp, 'b) monoid_scheme) (A⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) ≡⇩M⇩N›*) MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*))
lemma MN_trans_func_characterization:
"v ∈ (A⇧⋆) ⟹ a ∈ A ⟹ δ⇩M⇩N [v]⇩M⇩N a = [v @ [a]]⇩M⇩N"
proof (-)
(*goal: ‹⟦v ∈ A⇧⋆; a ∈ A⟧ ⟹ δ⇩M⇩N [v]⇩M⇩N a = [v @ [a]]⇩M⇩N›*)
assume A_0: "v ∈ (A⇧⋆)" and A_1: "a ∈ A" (*‹(v::'alpha list) ∈ A⇧⋆› ‹(a::'alpha) ∈ A›*)
have H_0: "⋀u. u ∈ [v]⇩M⇩N ⟹ (u @ [a]) ∈ [v @ [a]]⇩M⇩N"
by (auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w::'alpha list, w'::'alpha list). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v::'alpha list∈A⇧⋆. (w @ v ∈ (L::'alpha list set)) = (w' @ v ∈ L))}›*) A_1 (*‹(a::'alpha) ∈ A›*) A_0 (*‹(v::'alpha list) ∈ A⇧⋆›*))
hence H_1: "(SOME w. (v, w) ∈ ≡⇩M⇩N) ∈ [v]⇩M⇩N ⟹ ((SOME w. (v, w) ∈ ≡⇩M⇩N) @ [a]) ∈ [v @ [a]]⇩M⇩N"
by auto
from A_0 (*‹v ∈ A⇧⋆›*) have "(v, v) ∈ ≡⇩M⇩N ∧ v ∈ [v]⇩M⇩N"
by (auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w::'alpha::type list, w'::'alpha::type list). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v::'alpha::type list∈A⇧⋆. (w @ v ∈ (L::'alpha::type list set)) = (w' @ v ∈ L))}›*))
hence H_2: "(SOME w. (v, w) ∈ ≡⇩M⇩N) ∈ [v]⇩M⇩N"
apply (clarsimp simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*))
(*goal: ‹(SOME w. (v, w) ∈ ≡⇩M⇩N) ∈ [v]⇩M⇩N›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹∀x∈set v. x ∈ A ⟹ (SOME w. w ∈ A⇧⋆ ∧ (∀va∈A⇧⋆. (v @ va ∈ L) = (w @ va ∈ L))) ∈ A⇧⋆›
2. ‹∀x∈set v. x ∈ A ⟹ ∀va∈A⇧⋆. (v @ va ∈ L) = ((SOME w. w ∈ A⇧⋆ ∧ (∀va∈A⇧⋆. (v @ va ∈ L) = (w @ va ∈ L))) @ va ∈ L)›
discuss goal 1*)
apply (smt (verit, ccfv_SIG) A_0 (*‹v ∈ A⇧⋆›*) in_listsD (*‹?xs ∈ ?A⇧⋆ ⟹ ∀x∈set ?xs. x ∈ ?A›*) verit_sko_ex_indirect (*‹?x = (SOME x. ?P x) ⟹ (∃x. ?P x) = ?P ?x›*))
(*discuss goal 2*)
apply (smt (verit, del_insts) A_0 (*‹v ∈ A⇧⋆›*) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) tfl_some (*‹∀P x. P x ⟶ P (Eps P)›*))
(*proven 2 subgoals*) .
hence H_3: " ((SOME w. (v, w) ∈ ≡⇩M⇩N) @ [a]) ∈ [v @ [a]]⇩M⇩N"
using H_1 (*‹(SOME w::'alpha list. (v::'alpha list, w) ∈ ≡⇩M⇩N) ∈ [v]⇩M⇩N ⟹ (SOME w::'alpha list. (v, w) ∈ ≡⇩M⇩N) @ [a::'alpha] ∈ [v @ [a]]⇩M⇩N›*) by simp
thus "δ⇩M⇩N [v]⇩M⇩N a = [v @ [a]]⇩M⇩N"
using A_0 (*‹v ∈ A⇧⋆›*) A_1 (*‹a ∈ A›*) MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*) apply (clarsimp simp add: equiv_def (*‹equiv ?A ?r = (refl_on ?A ?r ∧ sym ?r ∧ trans ?r)›*))
(*goal: ‹δ⇩M⇩N [v::'alpha::type list]⇩M⇩N (a::'alpha::type) = [v @ [a]]⇩M⇩N›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⟦(v @ [a], (SOME w. (v, w) ∈ ≡⇩M⇩N) @ [a]) ∈ ≡⇩M⇩N; a ∈ A; ∀x∈set v. x ∈ A; refl_on (A⇧⋆) ≡⇩M⇩N; sym ≡⇩M⇩N; trans ≡⇩M⇩N⟧ ⟹ ≡⇩M⇩N `` {v} ∈ A⇧⋆ // ≡⇩M⇩N ⟶ ≡⇩M⇩N `` {(SOME w. (v, w) ∈ ≡⇩M⇩N) @ [a]} = ≡⇩M⇩N `` {v @ [a]}›
2. ‹⟦(v @ [a], (SOME w. (v, w) ∈ ≡⇩M⇩N) @ [a]) ∈ ≡⇩M⇩N; a ∈ A; ∀x∈set v. x ∈ A; refl_on (A⇧⋆) ≡⇩M⇩N; sym ≡⇩M⇩N; trans ≡⇩M⇩N⟧ ⟹ ≡⇩M⇩N `` {v} ∉ A⇧⋆ // ≡⇩M⇩N ⟶ undefined = ≡⇩M⇩N `` {v @ [a]}›
discuss goal 1*)
apply (rule impI (*‹(?P::bool ⟹ ?Q::bool) ⟹ ?P ⟶ ?Q›*))
(*top goal: ‹⟦(v @ [a], (SOME w. (v, w) ∈ ≡⇩M⇩N) @ [a]) ∈ ≡⇩M⇩N; a ∈ A; ∀x∈set v. x ∈ A; refl_on (A⇧⋆) ≡⇩M⇩N; sym ≡⇩M⇩N; trans ≡⇩M⇩N⟧ ⟹ ≡⇩M⇩N `` {v} ∈ A⇧⋆ // ≡⇩M⇩N ⟶ ≡⇩M⇩N `` {(SOME w. (v, w) ∈ ≡⇩M⇩N) @ [a]} = ≡⇩M⇩N `` {v @ [a]}› and 1 goal remains*)
apply (metis MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*) equiv_class_eq (*‹⟦equiv ?A ?r; (?a, ?b) ∈ ?r⟧ ⟹ ?r `` {?a} = ?r `` {?b}›*))
(*discuss goal 2*)
apply (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⟦(v @ [a], (SOME w. (v, w) ∈ ≡⇩M⇩N) @ [a]) ∈ ≡⇩M⇩N; a ∈ A; ∀x∈set v. x ∈ A; refl_on (A⇧⋆) ≡⇩M⇩N; sym ≡⇩M⇩N; trans ≡⇩M⇩N⟧ ⟹ ≡⇩M⇩N `` {v} ∉ A⇧⋆ // ≡⇩M⇩N ⟶ undefined = ≡⇩M⇩N `` {v @ [a]}›*)
apply (simp add: A_0 (*‹(v::'alpha list) ∈ A⇧⋆›*) quotientI (*‹(?x::?'a) ∈ (?A::?'a set) ⟹ (?r::(?'a × ?'a) set) `` {?x} ∈ ?A // ?r›*))
(*proven 2 subgoals*) .
qed
lemma MN_trans_eq_var_func :
"eq_var_func G
(MN_equiv × A) (λg∈carrier G. λ(W, a) ∈ (MN_equiv × A). (([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙) g W, φ g a))
MN_equiv ([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙)
(λ(w, a) ∈ MN_equiv × A. δ⇩M⇩N w a)"
proof (-)
(*goal: ‹eq_var_func G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)) (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y)›*)
have H_0: "alt_grp_act G MN_equiv ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙)"
using MN_rel_eq_var (*‹eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N›*) MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*) eq_var_rel.quot_act_is_grp_act (*‹⟦eq_var_rel ?G ?X ?φ ?R; equiv ?X ?R⟧ ⟹ alt_grp_act ?G (?X // ?R) (alt_grp_act.induced_quot_map ?G ?X ?φ ?R)›*) alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) restrict_apply (*‹restrict (?f::?'b::type ⇒ ?'a::type) (?A::?'b::type set) (?x::?'b::type) = (if ?x ∈ ?A then ?f ?x else undefined)›*) by fastforce
have H_1: "⋀a b g.
a ∈ MN_equiv ⟹
b ∈ A ⟹
(([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g a ∈ MN_equiv ∧ φ g b ∈ A ⟶
g ∈ carrier G ⟶ δ⇩M⇩N (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g a) (φ g b) = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (δ⇩M⇩N a b)) ∧
((([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g a ∈ MN_equiv ⟶ φ g b ∉ A) ⟶
g ∈ carrier G ⟶ undefined = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (δ⇩M⇩N a b))"
proof (-)
(*goal: ‹⋀(a::'alpha::type list set) (b::'alpha::type) g::'grp::type. ⟦a ∈ A⇧⋆ // ≡⇩M⇩N; b ∈ A⟧ ⟹ (([(φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g a ∈ A⇧⋆ // ≡⇩M⇩N ∧ φ g b ∈ A ⟶ g ∈ carrier (G::('grp, 'b) monoid_scheme) ⟶ δ⇩M⇩N (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g a) (φ g b) = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (δ⇩M⇩N a b)) ∧ ((([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g a ∈ A⇧⋆ // ≡⇩M⇩N ⟶ φ g b ∉ A) ⟶ g ∈ carrier G ⟶ undefined = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (δ⇩M⇩N a b))›*)
fix C and a and g
assume A1_0: "C ∈ MN_equiv" and A1_1: "a ∈ A" (*‹(C::'alpha list set) ∈ A⇧⋆ // ≡⇩M⇩N› ‹(a::'alpha) ∈ A›*)
have H1_0: "g ∈ carrier G ⟹ φ g a ∈ A"
by (meson A1_1 (*‹a ∈ A›*) element_image (*‹⟦?g ∈ carrier G; ?x ∈ A; φ ?g ?x = ?y⟧ ⟹ ?y ∈ A›*))
from A1_0 (*‹C ∈ A⇧⋆ // ≡⇩M⇩N›*) obtain c where H1_c: "[c]⇩M⇩N = C ∧ c ∈ A⇧⋆"
(*goal: ‹(⋀c. [c]⇩M⇩N = C ∧ c ∈ A⇧⋆ ⟹ thesis) ⟹ thesis›*)
by (auto simp add: quotient_def (*‹?A // ?r = (⋃x∈?A. {?r `` {x}})›*))
have H1_1: "g ∈ carrier G ⟹ δ⇩M⇩N (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C) (φ g a) = ([φ⇧⋆]⇩≡⇩M⇩N ⇘A⇧⋆⇙) g (δ⇩M⇩N [c]⇩M⇩N a)"
proof (-)
(*goal: ‹g ∈ carrier G ⟹ δ⇩M⇩N (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C) (φ g a) = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (δ⇩M⇩N [c]⇩M⇩N a)›*)
assume A2_0: "g ∈ carrier G" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*)
have H2_0: "φ g a ∈ A"
using H1_0 (*‹g ∈ carrier G ⟹ φ g a ∈ A›*) A2_0 (*‹g ∈ carrier G›*) by simp
have H2_1: "(φ⇧⋆) g ∈ Bij (A⇧⋆)"
using G_lang_axioms (*‹G_lang G A φ L›*) lists_a_Gset (*‹alt_grp_act (G::('grp, 'b) monoid_scheme) (A⇧⋆) ((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆)›*) A2_0 (*‹g ∈ carrier G›*) apply (clarsimp simp add: G_lang_def (*‹G_lang ?G ?A ?φ ?L ≡ alt_grp_act ?G ?A ?φ ∧ language ?A ?L ∧ G_lang_axioms ?G ?A ?φ ?L›*) G_lang_axioms_def (*‹G_lang_axioms ?G ?A ?φ ?L ≡ eq_var_subset ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) ?L›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*goal: ‹(φ⇧⋆) g ∈ Bij (A⇧⋆)›*)
by (meson Pi_iff (*‹(?f ∈ Pi ?I ?X) = (∀i∈?I. ?f i ∈ ?X i)›*) restrict_Pi_cancel (*‹(restrict ?x ?I ∈ Pi ?I ?A) = (?x ∈ Pi ?I ?A)›*))
hence H2_2: "(φ⇧⋆) g c ∈ (A⇧⋆)"
using H1_c (*‹[c]⇩M⇩N = C ∧ c ∈ A⇧⋆›*) apply (clarsimp simp add: Bij_def (*‹Bij ?S = extensional ?S ∩ {f. bij_betw f ?S ?S}›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*) inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) Image_def (*‹?r `` ?s = {y. ∃x∈?s. (x, y) ∈ ?r}›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*goal: ‹(φ⇧⋆) g c ∈ A⇧⋆›*)
apply (rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*); rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*); clarify)
(*goal: ‹⟦(if (g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme) then restrict (map ((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type) g)) (A⇧⋆) else undefined) ∈ extensional (A⇧⋆); (C::'alpha::type list set) = {y::'alpha::type list. (c::'alpha::type list, y) ∈ ≡⇩M⇩N}; ∀x::'alpha::type∈set c. x ∈ A; ∀x::'alpha::type list∈A⇧⋆. ∀y::'alpha::type list∈A⇧⋆. (if g ∈ carrier G then restrict (map (φ g)) (A⇧⋆) else undefined) x = (if g ∈ carrier G then restrict (map (φ g)) (A⇧⋆) else undefined) y ⟶ x = y; {y::'alpha::type list. ∃x::'alpha::type list∈A⇧⋆. y = (if g ∈ carrier G then restrict (map (φ g)) (A⇧⋆) else undefined) x} = A⇧⋆⟧ ⟹ (g ∈ carrier G ⟶ map (φ g) c ∈ A⇧⋆) ∧ (g ∉ carrier G ⟶ undefined c ∈ A⇧⋆)›*)
using surj_prop (*‹?g ∈ carrier G ⟹ φ ?g ` A = A›*) apply fastforce
(*top goal: ‹⋀x. ⟦(if g ∈ carrier G then restrict (map (φ g)) (A⇧⋆) else undefined) ∈ extensional (A⇧⋆); C = {y. (c, y) ∈ ≡⇩M⇩N}; ∀x∈set c. x ∈ A; ∀x∈A⇧⋆. ∀y∈A⇧⋆. (if g ∈ carrier G then restrict (map (φ g)) (A⇧⋆) else undefined) x = (if g ∈ carrier G then restrict (map (φ g)) (A⇧⋆) else undefined) y ⟶ x = y; {y. ∃x∈A⇧⋆. y = (if g ∈ carrier G then restrict (map (φ g)) (A⇧⋆) else undefined) x} = A⇧⋆; g ∈ carrier G; x ∈ set (map (φ g) c)⟧ ⟹ x ∈ A› and 1 goal remains*)
using A2_0 (*‹g ∈ carrier G›*) by blast
from H1_c (*‹[c]⇩M⇩N = C ∧ c ∈ A⇧⋆›*) have H2_1: "([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (≡⇩M⇩N `` {c}) = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C"
by auto
also (*calculation: ‹([(φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (g::'grp) (≡⇩M⇩N `` {c::'alpha list}) = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (C::'alpha list set)›*) have H2_2: "([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C = [(φ⇧⋆) g c]⇩M⇩N"
using eq_var_rel.quot_act_wd[where R = "≡⇩M⇩N" and G = G and X = "A⇧⋆" and φ = "φ⇧⋆" and g = g and x = c] (*‹⟦eq_var_rel (G::('grp, 'b) monoid_scheme) (A⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) ≡⇩M⇩N; equiv (A⇧⋆) ≡⇩M⇩N; (c::'alpha list) ∈ A⇧⋆; (g::'grp) ∈ carrier G⟧ ⟹ g ⊙⇘[φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙⇙ ≡⇩M⇩N `` {c} = ≡⇩M⇩N `` {g ⊙⇘φ⇧⋆⇙ c}›*) by (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: alt_natural_map_MN_def (*‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}›*) make_op_def (*‹(⊙⇘?φ⇙) ≡ ?φ›*) MN_rel_eq_var (*‹eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N›*) MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*) H1_c (*‹[c]⇩M⇩N = C ∧ c ∈ A⇧⋆›*) A2_0 (*‹g ∈ carrier G›*) H2_1 (*‹([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (≡⇩M⇩N `` {c}) = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C›*))
hence H2_3: "δ⇩M⇩N (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C) (φ g a) = δ⇩M⇩N ([(φ⇧⋆) g c]⇩M⇩N) (φ g a)"
using H2_2 (*‹([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C = [(φ⇧⋆) g c]⇩M⇩N›*) by simp
also (*calculation: ‹δ⇩M⇩N (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (≡⇩M⇩N `` {c})) (φ g a) = δ⇩M⇩N [(φ⇧⋆) g c]⇩M⇩N (φ g a)›*) have H2_4: "... = [((φ⇧⋆) g c) @ [(φ g a)]]⇩M⇩N"
using MN_trans_func_characterization[where v = "(φ⇧⋆) g c" and a = "φ g a"] (*‹⟦(φ⇧⋆) g c ∈ A⇧⋆; φ g a ∈ A⟧ ⟹ δ⇩M⇩N [(φ⇧⋆) g c]⇩M⇩N (φ g a) = [(φ⇧⋆) g c @ [φ g a]]⇩M⇩N›*) H1_c (*‹[c]⇩M⇩N = C ∧ c ∈ A⇧⋆›*) A2_0 (*‹g ∈ carrier G›*) G_set_equiv (*‹alt_grp_act ?G ?A ?φ ⟹ eq_var_subset ?G ?A ?φ ?A›*) H2_0 (*‹(φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp) (a::'alpha) ∈ A›*) eq_var_subset.is_equivar (*‹eq_var_subset ?G ?X ?φ ?Y ⟹ ∀g∈carrier ?G. ?φ g ` ?Y = ?Y›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) lists_a_Gset (*‹alt_grp_act (G::('grp, 'b) monoid_scheme) (A⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆)›*) by blast
also (*calculation: ‹δ⇩M⇩N (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (≡⇩M⇩N `` {c})) (φ g a) = [(φ⇧⋆) g c @ [φ g a]]⇩M⇩N›*) have H2_5: "... = [(φ⇧⋆) g (c @ [a])]⇩M⇩N"
using A2_0 (*‹g ∈ carrier G›*) H1_c (*‹[c::'alpha list]⇩M⇩N = (C::'alpha list set) ∧ c ∈ A⇧⋆›*) A1_1 (*‹a ∈ A›*) by auto
also (*calculation: ‹δ⇩M⇩N (([(φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (g::'grp) (≡⇩M⇩N `` {c::'alpha list})) (φ g (a::'alpha)) = [(φ⇧⋆) g (c @ [a])]⇩M⇩N›*) have H2_6: "... = ([φ⇧⋆]⇩≡⇩M⇩N ⇘A⇧⋆⇙) g [(c @ [a])]⇩M⇩N"
apply (rule meta_mp[of "c @ [a] ∈ A⇧⋆"] (*‹⟦c @ [a] ∈ A⇧⋆ ⟹ PROP ?Q; c @ [a] ∈ A⇧⋆⟧ ⟹ PROP ?Q›*))
(*goal: ‹[(φ⇧⋆) g (c @ [a])]⇩M⇩N = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g [c @ [a]]⇩M⇩N›*)
using eq_var_rel.quot_act_wd[where R = "≡⇩M⇩N" and G = G and X = "A⇧⋆" and φ = "φ⇧⋆" and g = g and x = "c @ [a]"] (*‹⟦eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N; equiv (A⇧⋆) ≡⇩M⇩N; c @ [a] ∈ A⇧⋆; g ∈ carrier G⟧ ⟹ g ⊙⇘[φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙⇙ ≡⇩M⇩N `` {c @ [a]} = ≡⇩M⇩N `` {g ⊙⇘φ⇧⋆⇙ (c @ [a])}›*) apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: make_op_def (*‹(⊙⇘?φ⇙) ≡ ?φ›*) MN_rel_eq_var (*‹eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N›*) MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*) H1_c (*‹[c]⇩M⇩N = C ∧ c ∈ A⇧⋆›*) A2_0 (*‹g ∈ carrier G›*) H2_1 (*‹([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (≡⇩M⇩N `` {c}) = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C›*))
(*top goal: ‹(c::'alpha list) @ [a::'alpha] ∈ A⇧⋆ ⟹ [((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) (g::'grp) (c @ [a])]⇩M⇩N = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g [c @ [a]]⇩M⇩N› and 1 goal remains*)
using H1_c (*‹[c]⇩M⇩N = C ∧ c ∈ A⇧⋆›*) A1_1 (*‹a ∈ A›*) apply -
(*goals:
1. ‹⟦(a::'alpha) ∈ A; ([(φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (g::'grp) (≡⇩M⇩N `` {(c::'alpha list) @ [a]}) = ≡⇩M⇩N `` {(φ⇧⋆) g (c @ [a])}; [c]⇩M⇩N = (C::'alpha list set) ∧ c ∈ A⇧⋆; a ∈ A⟧ ⟹ [(φ⇧⋆) g (c @ [a])]⇩M⇩N = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g [c @ [a]]⇩M⇩N›
2. ‹⟦[c::'alpha list]⇩M⇩N = (C::'alpha list set) ∧ c ∈ A⇧⋆; (a::'alpha) ∈ A⟧ ⟹ c @ [a] ∈ A⇧⋆›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
also (*calculation: ‹δ⇩M⇩N (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (≡⇩M⇩N `` {c})) (φ g a) = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g [c @ [a]]⇩M⇩N›*) have H2_7: "... = ([φ⇧⋆]⇩≡⇩M⇩N ⇘A⇧⋆⇙) g (δ⇩M⇩N [c]⇩M⇩N a)"
using MN_trans_func_characterization[where v = "c" and a = "a"] (*‹⟦c ∈ A⇧⋆; a ∈ A⟧ ⟹ δ⇩M⇩N [c]⇩M⇩N a = [c @ [a]]⇩M⇩N›*) H1_c (*‹[c]⇩M⇩N = C ∧ c ∈ A⇧⋆›*) A1_1 (*‹a ∈ A›*) by metis
finally (*calculation: ‹δ⇩M⇩N (([(φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (g::'grp::type) (≡⇩M⇩N `` {c::'alpha::type list})) (φ g (a::'alpha::type)) = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (δ⇩M⇩N [c]⇩M⇩N a)›*) show "δ⇩M⇩N (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C) (φ g a) = ([φ⇧⋆]⇩≡⇩M⇩N ⇘A⇧⋆⇙) g (δ⇩M⇩N [c]⇩M⇩N a)"
using H2_1 (*‹([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (≡⇩M⇩N `` {c}) = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C›*) by metis
qed
show "(([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C ∈ MN_equiv ∧ φ g a ∈ A ⟶
g ∈ carrier G ⟶
δ⇩M⇩N (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C) (φ g a) =
([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (δ⇩M⇩N C a)) ∧
((([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C ∈ MN_equiv ⟶ φ g a ∉ A) ⟶
g ∈ carrier G ⟶ undefined = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (δ⇩M⇩N C a))"
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); clarify)
(*goal: ‹(([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C ∈ A⇧⋆ // ≡⇩M⇩N ∧ φ g a ∈ A ⟶ g ∈ carrier G ⟶ δ⇩M⇩N (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C) (φ g a) = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (δ⇩M⇩N C a)) ∧ ((([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C ∈ A⇧⋆ // ≡⇩M⇩N ⟶ φ g a ∉ A) ⟶ g ∈ carrier G ⟶ undefined = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (δ⇩M⇩N C a))›*)
using H1_1 (*‹g ∈ carrier G ⟹ δ⇩M⇩N (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C) (φ g a) = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (δ⇩M⇩N [c]⇩M⇩N a)›*) H1_c (*‹[c]⇩M⇩N = C ∧ c ∈ A⇧⋆›*)
(*goals:
1. ‹⟦([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C ∈ A⇧⋆ // ≡⇩M⇩N; φ g a ∈ A; g ∈ carrier G⟧ ⟹ δ⇩M⇩N (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C) (φ g a) = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (δ⇩M⇩N C a)›
2. ‹⟦([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g C ∈ A⇧⋆ // ≡⇩M⇩N ⟶ φ g a ∉ A; g ∈ carrier G⟧ ⟹ undefined = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g (δ⇩M⇩N C a)›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply (metis A1_0 (*‹C ∈ A⇧⋆ // ≡⇩M⇩N›*) H1_0 (*‹g ∈ carrier G ⟹ φ g a ∈ A›*) H_0 (*‹alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙)›*) alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) group_action.element_image (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?y ∈ ?E›*))
(*proven 2 subgoals*) .
qed
show "?thesis"
(*goal: ‹eq_var_func G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)) (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y)›*)
apply (subst eq_var_func_def (*‹eq_var_func (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'Y set) (?ψ::?'grp ⇒ ?'Y ⇒ ?'Y) (?f::?'X ⇒ ?'Y) ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*))
(*goal: ‹eq_var_func G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)) (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y)›*)
apply (subst eq_var_func_axioms_def (*‹eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀a g. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*))
(*goal: ‹alt_grp_act G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)) ∧ alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) ∧ eq_var_func_axioms G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)) (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y)›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹alt_grp_act (G::('grp, 'b) monoid_scheme) (A⇧⋆ // ≡⇩M⇩N × A) (λg::'grp::type∈carrier G. λ(W::'alpha::type list set, a::'alpha::type)∈A⇧⋆ // ≡⇩M⇩N × A. (([(φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)) ∧ alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) ∧ (λ(x::'alpha::type list set, y::'alpha::type)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) ∈ A⇧⋆ // ≡⇩M⇩N × A →⇩E A⇧⋆ // ≡⇩M⇩N ∧ (∀(a::'alpha::type list set × 'alpha::type) g::'grp::type. a ∈ A⇧⋆ // ≡⇩M⇩N × A ⟶ g ∈ carrier G ⟶ (λ(x::'alpha::type list set, y::'alpha::type)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) (g ⊙⇘λg::'grp::type∈carrier G. λ(W::'alpha::type list set, a::'alpha::type)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)⇙ a) = g ⊙⇘[φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙⇙ (λ(x::'alpha::type list set, y::'alpha::type)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) a)›*)
subgoal for
apply (rule prod_group_act[where G = G and A = "MN_equiv" and φ = "[(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙" and B = A and ψ = φ] (*‹⟦alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙); alt_grp_act G A φ⟧ ⟹ alt_grp_act G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(a, b)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g a, φ g b))›*))
(*goal: ‹alt_grp_act G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a))›*)
apply (rule H_0 (*‹alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙)›*))
(*top goal: ‹alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙)› and 1 goal remains*)
using G_lang_axioms (*‹G_lang (G::('grp, 'b) monoid_scheme) A (φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type) (L::'alpha::type list set)›*) by (auto simp add: G_lang_def (*‹G_lang (?G::(?'grp, ?'b) monoid_scheme) (?A::?'alpha set) (?φ::?'grp ⇒ ?'alpha ⇒ ?'alpha) (?L::?'alpha list set) ≡ alt_grp_act ?G ?A ?φ ∧ language ?A ?L ∧ G_lang_axioms ?G ?A ?φ ?L›*) G_lang_axioms_def (*‹G_lang_axioms (?G::(?'grp, ?'b) monoid_scheme) (?A::?'alpha set) (?φ::?'grp ⇒ ?'alpha ⇒ ?'alpha) (?L::?'alpha list set) ≡ eq_var_subset ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) ?L›*))
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) ∧ (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) ∈ A⇧⋆ // ≡⇩M⇩N × A →⇩E A⇧⋆ // ≡⇩M⇩N ∧ (∀a g. a ∈ A⇧⋆ // ≡⇩M⇩N × A ⟶ g ∈ carrier G ⟶ (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) (g ⊙⇘λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)⇙ a) = g ⊙⇘[φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙⇙ (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) a)›*)
subgoal for
using MN_rel_eq_var (*‹eq_var_rel (G::('grp, 'b) monoid_scheme) (A⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) ≡⇩M⇩N›*) MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*) eq_var_rel.quot_act_is_grp_act (*‹⟦eq_var_rel ?G ?X ?φ ?R; equiv ?X ?R⟧ ⟹ alt_grp_act ?G (?X // ?R) (alt_grp_act.induced_quot_map ?G ?X ?φ ?R)›*) using alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) restrict_apply (*‹restrict ?f ?A ?x = (if ?x ∈ ?A then ?f ?x else undefined)›*) by fastforce
apply (rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹(λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) ∈ A⇧⋆ // ≡⇩M⇩N × A →⇩E A⇧⋆ // ≡⇩M⇩N ∧ (∀a g. a ∈ A⇧⋆ // ≡⇩M⇩N × A ⟶ g ∈ carrier G ⟶ (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) (g ⊙⇘λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)⇙ a) = g ⊙⇘[φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙⇙ (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) a)›*)
subgoal for
apply (subst extensional_funcset_def (*‹?S →⇩E ?T = (?S → ?T) ∩ extensional ?S›*))
(*goal: ‹(λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) ∈ A⇧⋆ // ≡⇩M⇩N × A →⇩E A⇧⋆ // ≡⇩M⇩N›*)
apply (subst restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*))
(*goal: ‹(λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) ∈ (A⇧⋆ // ≡⇩M⇩N × A → A⇧⋆ // ≡⇩M⇩N) ∩ extensional (A⇧⋆ // ≡⇩M⇩N × A)›*)
apply (subst Pi_def (*‹Pi ?A ?B = {f. ∀x. x ∈ ?A ⟶ f x ∈ ?B x}›*))
(*goal: ‹(λx. if x ∈ A⇧⋆ // ≡⇩M⇩N × A then case x of (x, xa) ⇒ δ⇩M⇩N x xa else undefined) ∈ (A⇧⋆ // ≡⇩M⇩N × A → A⇧⋆ // ≡⇩M⇩N) ∩ extensional (A⇧⋆ // ≡⇩M⇩N × A)›*)
apply (subst extensional_def (*‹extensional ?A = {f. ∀x. x ∉ ?A ⟶ f x = undefined}›*))
(*goal: ‹(λx::'alpha list set × 'alpha. if x ∈ A⇧⋆ // ≡⇩M⇩N × A then case x of (x::'alpha list set, xa::'alpha) ⇒ δ⇩M⇩N x xa else undefined) ∈ {f::'alpha list set × 'alpha ⇒ 'alpha list set. ∀x::'alpha list set × 'alpha. x ∈ A⇧⋆ // ≡⇩M⇩N × A ⟶ f x ∈ A⇧⋆ // ≡⇩M⇩N} ∩ extensional (A⇧⋆ // ≡⇩M⇩N × A)›*)
apply clarsimp
(*goal: ‹(λx. if x ∈ A⇧⋆ // ≡⇩M⇩N × A then case x of (x, xa) ⇒ δ⇩M⇩N x xa else undefined) ∈ {f. ∀x. x ∈ A⇧⋆ // ≡⇩M⇩N × A ⟶ f x ∈ A⇧⋆ // ≡⇩M⇩N} ∩ {f. ∀x. x ∉ A⇧⋆ // ≡⇩M⇩N × A ⟶ f x = undefined}›*)
by (metis MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*) append_in_lists_conv (*‹(?xs @ ?ys ∈ ?A⇧⋆) = (?xs ∈ ?A⇧⋆ ∧ ?ys ∈ ?A⇧⋆)›*) equiv_Eps_preserves (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ (SOME x. x ∈ ?X) ∈ ?A›*) lists.Cons (*‹⟦?a ∈ ?A; ?l ∈ ?A⇧⋆⟧ ⟹ ?a # ?l ∈ ?A⇧⋆›*) lists.Nil (*‹[] ∈ ?A⇧⋆›*) quotientI (*‹?x ∈ ?A ⟹ ?r `` {?x} ∈ ?A // ?r›*))
apply (subst restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*))
(*goal: ‹∀a g. a ∈ A⇧⋆ // ≡⇩M⇩N × A ⟶ g ∈ carrier G ⟶ (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) (g ⊙⇘λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)⇙ a) = g ⊙⇘[φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙⇙ (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) a›*)
apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: make_op_def (*‹(⊙⇘?φ⇙) ≡ ?φ›*))
(*goal: ‹∀a g. a ∈ A⇧⋆ // ≡⇩M⇩N × A ⟶ g ∈ carrier G ⟶ (if g ⊙⇘λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)⇙ a ∈ A⇧⋆ // ≡⇩M⇩N × A then case g ⊙⇘λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)⇙ a of (x, xa) ⇒ δ⇩M⇩N x xa else undefined) = g ⊙⇘[φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙⇙ (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) a›*)
by (simp add: H_1 (*‹⟦(?a1::'alpha list set) ∈ A⇧⋆ // ≡⇩M⇩N; (?b1::'alpha) ∈ A⟧ ⟹ (([(φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (?g1::'grp) ?a1 ∈ A⇧⋆ // ≡⇩M⇩N ∧ φ ?g1 ?b1 ∈ A ⟶ ?g1 ∈ carrier (G::('grp, 'b) monoid_scheme) ⟶ δ⇩M⇩N (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) ?g1 ?a1) (φ ?g1 ?b1) = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) ?g1 (δ⇩M⇩N ?a1 ?b1)) ∧ ((([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) ?g1 ?a1 ∈ A⇧⋆ // ≡⇩M⇩N ⟶ φ ?g1 ?b1 ∉ A) ⟶ ?g1 ∈ carrier G ⟶ undefined = ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) ?g1 (δ⇩M⇩N ?a1 ?b1))›*) del: GMN_simps (*‹(⊙⇘?φ::?'grp ⇒ ?'X ⇒ ?'X⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹(?func::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆ = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) (A⇧⋆))› ‹[?func::'grp ⇒ ?'Y ⇒ ?'Y]⇩?R::(?'Y × ?'Y) set⇘?S::?'Y set⇙ = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). λx::?'Y set∈?S // ?R. ?R `` {?func g (SOME z::?'Y. z ∈ x)})› ‹[?w::'alpha list]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N (?W'::'alpha list set) (?a'::'alpha) = (λ(W::'alpha list set, a::'alpha)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w::'alpha list. w ∈ W) @ [a]}) (?W', ?a')›*))
qed
lemma MN_quot_act_on_empty_str:
"⋀g. ⟦g ∈ carrier G; ([], x) ∈ ≡⇩M⇩N⟧ ⟹ x ∈ map (φ g) ` ≡⇩M⇩N `` {[]}"
proof (-)
(*goal: ‹⋀g. ⟦g ∈ carrier G; ([], x) ∈ ≡⇩M⇩N⟧ ⟹ x ∈ map (φ g) ` ≡⇩M⇩N `` {[]}›*)
fix g
assume A_0: "g ∈ carrier G" and A_1: "([], x) ∈ ≡⇩M⇩N" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹([], x::'alpha list) ∈ ≡⇩M⇩N›*)
from A_1 (*‹([], x) ∈ ≡⇩M⇩N›*) have H_0: "x ∈ (A⇧⋆)"
by (auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w::'alpha list, w'::'alpha list). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v::'alpha list∈A⇧⋆. (w @ v ∈ (L::'alpha list set)) = (w' @ v ∈ L))}›*))
from A_0 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) H_0 (*‹x ∈ A⇧⋆›*) have H_1: "x = (φ⇧⋆) g ((φ⇧⋆) (inv ⇘G⇙ g) x)"
by (smt (verit) alt_grp_act_def (*‹alt_grp_act ?G ?X ?φ ≡ group_action ?G ?X ?φ›*) group_action.bij_prop1 (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?y ∈ ?E⟧ ⟹ ∃!x. x ∈ ?E ∧ ?φ ?g x = ?y›*) group_action.orbit_sym_aux (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?φ (inv⇘?G⇙ ?g) ?y = ?x›*) lists_a_Gset (*‹alt_grp_act G (A⇧⋆) (φ⇧⋆)›*))
have H_2: "inv ⇘G ⇙ g ∈ carrier G"
using A_0 (*‹g ∈ carrier G›*) MN_rel_eq_var (*‹eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N›*) by (auto simp add: eq_var_rel_def (*‹eq_var_rel ?G ?X ?φ ?R ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_rel_axioms ?G ?X ?φ ?R›*) eq_var_rel_axioms_def (*‹eq_var_rel_axioms ?G ?X ?φ ?R ≡ ?R ⊆ ?X × ?X ∧ (∀a b. (a, b) ∈ ?R ⟶ (∀g∈carrier ?G. (g ⊙⇘?φ⇙ a, g ⊙⇘?φ⇙ b) ∈ ?R))›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*))
have H_3: "([], (φ⇧⋆) (inv ⇘G⇙ g) x) ∈ ≡⇩M⇩N"
using A_0 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A_1 (*‹([], x::'alpha::type list) ∈ ≡⇩M⇩N›*) H_0 (*‹x ∈ A⇧⋆›*) MN_rel_eq_var (*‹eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N›*) apply (clarsimp simp add: eq_var_rel_def (*‹eq_var_rel (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?R::(?'X × ?'X) set) ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_rel_axioms ?G ?X ?φ ?R›*) eq_var_rel_axioms_def (*‹eq_var_rel_axioms (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?R::(?'X × ?'X) set) ≡ ?R ⊆ ?X × ?X ∧ (∀(a::?'X) b::?'X. (a, b) ∈ ?R ⟶ (∀g::?'grp∈carrier ?G. (g ⊙⇘?φ⇙ a, g ⊙⇘?φ⇙ b) ∈ ?R))›*))
(*goal: ‹([], (φ⇧⋆) (inv⇘G⇙ g) x) ∈ ≡⇩M⇩N›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); clarify)
(*goal: ‹⟦(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); ([], x::'alpha list) ∈ ≡⇩M⇩N; ∀x::'alpha∈set x. x ∈ A; group_action G (A⇧⋆) (λg::'grp∈carrier G. restrict (map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) g)) (A⇧⋆)); ≡⇩M⇩N ⊆ A⇧⋆ × A⇧⋆; ∀(a::'alpha list) b::'alpha list. (a, b) ∈ ≡⇩M⇩N ⟶ (∀g::'grp∈carrier G. (if a ∈ A⇧⋆ then map (φ g) a else undefined, if b ∈ A⇧⋆ then map (φ g) b else undefined) ∈ ≡⇩M⇩N)⟧ ⟹ (inv⇘G⇙ g ∈ carrier G ⟶ ([], map (φ (inv⇘G⇙ g)) x) ∈ ≡⇩M⇩N) ∧ (inv⇘G⇙ g ∉ carrier G ⟶ ([], undefined x) ∈ ≡⇩M⇩N)›*)
apply (smt (verit, best) H_0 (*‹x ∈ A⇧⋆›*) list.simps( (*‹map ?f [] = []›*) 8) lists.Nil (*‹[] ∈ ?A⇧⋆›*))
(*top goal: ‹⟦g ∈ carrier G; ([], x) ∈ ≡⇩M⇩N; ∀x∈set x. x ∈ A; group_action G (A⇧⋆) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)); ≡⇩M⇩N ⊆ A⇧⋆ × A⇧⋆; ∀a b. (a, b) ∈ ≡⇩M⇩N ⟶ (∀g∈carrier G. (if a ∈ A⇧⋆ then map (φ g) a else undefined, if b ∈ A⇧⋆ then map (φ g) b else undefined) ∈ ≡⇩M⇩N); inv⇘G⇙ g ∈ carrier G⟧ ⟹ ([], map (φ (inv⇘G⇙ g)) x) ∈ ≡⇩M⇩N› and 1 goal remains*)
using H_2 (*‹inv⇘G⇙ g ∈ carrier G›*) by simp
hence H_4: "∃y∈≡⇩M⇩N `` {[]}. x = map (φ g) y"
using A_0 (*‹g ∈ carrier G›*) H_0 (*‹(x::'alpha list) ∈ A⇧⋆›*) H_1 (*‹x = (φ⇧⋆) g ((φ⇧⋆) (inv⇘G⇙ g) x)›*) H_2 (*‹inv⇘G⇙ g ∈ carrier G›*) apply clarsimp
(*goal: ‹∃y∈≡⇩M⇩N `` {[]}. x = map (φ g) y›*)
by (metis H_0 (*‹x ∈ A⇧⋆›*) Image_singleton_iff (*‹(?b ∈ ?r `` {?a}) = ((?a, ?b) ∈ ?r)›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) insert_image (*‹?x ∈ ?A ⟹ insert (?f ?x) (?f ` ?A) = ?f ` ?A›*) lists_image (*‹(?f ` ?A)⇧⋆ = map ?f ` ?A⇧⋆›*) surj_prop (*‹?g ∈ carrier G ⟹ φ ?g ` A = A›*))
thus "x ∈ map (φ g) ` ≡⇩M⇩N `` {[]}"
by (auto simp add: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
qed
lemma MN_init_state_equivar:
"eq_var_subset G (A⇧⋆) (φ⇧⋆) MN_init_state"
apply (rule alt_grp_act.eq_var_one_direction (*‹⟦alt_grp_act ?G ?X ?φ; ?Y ⊆ ?X; ∀g∈carrier ?G. ?φ g ` ?Y ⊆ ?Y⟧ ⟹ eq_var_subset ?G ?X ?φ ?Y›*))
(*goal: ‹eq_var_subset G (A⇧⋆) (φ⇧⋆) MN_init_state›*)
using lists_a_Gset (*‹alt_grp_act G (A⇧⋆) (φ⇧⋆)›*) apply ((auto)[1])
(*top goal: ‹alt_grp_act G (A⇧⋆) (φ⇧⋆)› and 2 goals remain*)
apply clarsimp
(*top goal: ‹MN_init_state ⊆ A⇧⋆› and 1 goal remains*)
subgoal for w and a
by (auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*))
apply (simp add: Set.subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*); clarify)
(*goal: ‹∀g∈carrier G. (φ⇧⋆) g ` MN_init_state ⊆ MN_init_state›*)
apply (clarsimp simp add: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*) Image_def (*‹?r `` ?s = {y. ∃x∈?s. (x, y) ∈ ?r}›*) Int_def (*‹?A ∩ ?B = {x ∈ ?A. x ∈ ?B}›*))
(*goal: ‹⋀g x. ⟦g ∈ carrier G; x ∈ map (φ g) ` (≡⇩M⇩N `` {[]} ∩ A⇧⋆) ∪ (λx. undefined) ` (≡⇩M⇩N `` {[]} ∩ {x. x ∉ A⇧⋆})⟧ ⟹ ([], x) ∈ ≡⇩M⇩N›*)
apply (erule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))
(*goal: ‹⋀g x. ⟦g ∈ carrier G; (∃xa. ([], xa) ∈ ≡⇩M⇩N ∧ xa ∈ A⇧⋆ ∧ x = map (φ g) xa) ∨ x = undefined ∧ (∃x. ([], x) ∈ ≡⇩M⇩N ∧ x ∉ A⇧⋆)⟧ ⟹ ([], x) ∈ ≡⇩M⇩N›*)
subgoal for g and w
using MN_rel_eq_var (*‹eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N›*) apply (clarsimp simp add: eq_var_rel_def (*‹eq_var_rel ?G ?X ?φ ?R ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_rel_axioms ?G ?X ?φ ?R›*) eq_var_rel_axioms_def (*‹eq_var_rel_axioms ?G ?X ?φ ?R ≡ ?R ⊆ ?X × ?X ∧ (∀a b. (a, b) ∈ ?R ⟶ (∀g∈carrier ?G. (g ⊙⇘?φ⇙ a, g ⊙⇘?φ⇙ b) ∈ ?R))›*))
(*goal: ‹⟦g ∈ carrier G; ∃x. ([], x) ∈ ≡⇩M⇩N ∧ x ∈ A⇧⋆ ∧ w = map (φ g) x⟧ ⟹ ([], w) ∈ ≡⇩M⇩N›*)
by (metis (full_types, opaque_lifting) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) list.simps( (*‹map ?f [] = []›*) 8) lists.Nil (*‹[] ∈ ?A⇧⋆›*))
by (auto simp add: ‹⋀a w. ⟦([], w) ∈ ≡⇩M⇩N; a ∈ set w⟧ ⟹ a ∈ A›)
lemma MN_init_state_equivar_v2:
"eq_var_subset G (MN_equiv) ([φ⇧⋆]⇩≡⇩M⇩N ⇘A⇧⋆ ⇙) {MN_init_state}"
proof (-)
(*goal: ‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state}›*)
have H_0: "∀g∈carrier G. (φ⇧⋆) g ` MN_init_state = MN_init_state ⟹
∀g∈carrier G. ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g MN_init_state = MN_init_state"
proof (clarify)
(*goal: ‹⋀g. ⟦∀g∈carrier G. (φ⇧⋆) g ` MN_init_state = MN_init_state; g ∈ carrier G⟧ ⟹ ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g MN_init_state = MN_init_state›*)
fix g
assume A_0: "g ∈ carrier G" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*)
have H_0: "⋀x. [x]⇩M⇩N = ≡⇩M⇩N `` {x}"
by simp
have H_1: "([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g [[]]⇩M⇩N = [(φ⇧⋆) g []]⇩M⇩N"
using eq_var_rel.quot_act_wd[where R = "≡⇩M⇩N" and G = G and X = "A⇧⋆" and φ = "φ⇧⋆" and g = g and x = "[]"] (*‹⟦eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N; equiv (A⇧⋆) ≡⇩M⇩N; [] ∈ A⇧⋆; g ∈ carrier G⟧ ⟹ g ⊙⇘[φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙⇙ ≡⇩M⇩N `` {[]} = ≡⇩M⇩N `` {g ⊙⇘φ⇧⋆⇙ []}›*) MN_rel_eq_var (*‹eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N›*) MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*) by (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: H_0 (*‹[?x1]⇩M⇩N = ≡⇩M⇩N `` {?x1}›*) make_op_def (*‹(⊙⇘?φ⇙) ≡ ?φ›*) A_0 (*‹g ∈ carrier G›*))
from A_0 (*‹g ∈ carrier G›*) H_1 (*‹([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g MN_init_state = [(φ⇧⋆) g []]⇩M⇩N›*) show "([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g [[]]⇩M⇩N = [[]]⇩M⇩N"
by auto
qed
show "?thesis"
(*goal: ‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state}›*)
using MN_init_state_equivar (*‹eq_var_subset G (A⇧⋆) (φ⇧⋆) MN_init_state›*) apply (clarsimp simp add: eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*))
(*goal: ‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state}›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹⟦alt_grp_act G (A⇧⋆) (φ⇧⋆); eq_var_subset_axioms G (A⇧⋆) (φ⇧⋆) MN_init_state⟧ ⟹ alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) ∧ eq_var_subset_axioms G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state}›*)
subgoal for
by (metis MN_rel_eq_var (*‹eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N›*) MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*) eq_var_rel.quot_act_is_grp_act (*‹⟦eq_var_rel ?G ?X ?φ ?R; equiv ?X ?R⟧ ⟹ alt_grp_act ?G (?X // ?R) (alt_grp_act.induced_quot_map ?G ?X ?φ ?R)›*))
apply ((clarsimp del: subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*))[1])
(*goal: ‹⟦alt_grp_act G (A⇧⋆) (φ⇧⋆); eq_var_subset_axioms G (A⇧⋆) (φ⇧⋆) MN_init_state⟧ ⟹ eq_var_subset_axioms G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state}›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⟦alt_grp_act (G::('grp, 'b) monoid_scheme) (A⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆); MN_init_state ⊆ A⇧⋆; ∀g::'grp∈carrier G. (φ⇧⋆) g ` MN_init_state = MN_init_state⟧ ⟹ MN_init_state ∈ A⇧⋆ // ≡⇩M⇩N›
2. ‹⟦alt_grp_act (G::('grp, 'b) monoid_scheme) (A⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆); MN_init_state ⊆ A⇧⋆; ∀g::'grp∈carrier G. (φ⇧⋆) g ` MN_init_state = MN_init_state⟧ ⟹ ∀g::'grp∈carrier G. ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g MN_init_state = MN_init_state›
discuss goal 1*)
apply ((auto simp add: quotient_def (*‹(?A::?'a set) // (?r::(?'a × ?'a) set) = (⋃x::?'a∈?A. {?r `` {x}})›*))[1])
(*discuss goal 2*)
apply (simp add: H_0 (*‹∀g∈carrier G. (φ⇧⋆) g ` MN_init_state = MN_init_state ⟹ ∀g∈carrier G. ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g MN_init_state = MN_init_state›*) del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*))
(*proven 2 subgoals*) .
qed
lemma MN_final_state_equiv:
"eq_var_subset G (MN_equiv) ([φ⇧⋆]⇩≡⇩M⇩N ⇘A⇧⋆ ⇙) MN_fin_states"
proof (-)
(*goal: ‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) MN_fin_states›*)
have H_0: "⋀g x w. g ∈ carrier G ⟹ w ∈ L ⟹ ∃wa∈L. ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g [w]⇩M⇩N = [wa]⇩M⇩N"
proof (-)
(*goal: ‹⋀g x w. ⟦g ∈ carrier G; w ∈ L⟧ ⟹ ∃wa∈L. ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g [w]⇩M⇩N = [wa]⇩M⇩N›*)
fix g and w
assume A1_0: "g ∈ carrier G" and A1_1: "w ∈ L" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹(w::'alpha list) ∈ (L::'alpha list set)›*)
have H1_0: "⋀v. v ∈ L ⟹ (φ⇧⋆) g v ∈ L"
using A1_0 (*‹(g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) G_lang_axioms (*‹G_lang G A φ L›*) apply (clarsimp simp add: G_lang_def (*‹G_lang ?G ?A ?φ ?L ≡ alt_grp_act ?G ?A ?φ ∧ language ?A ?L ∧ G_lang_axioms ?G ?A ?φ ?L›*) G_lang_axioms_def (*‹G_lang_axioms ?G ?A ?φ ?L ≡ eq_var_subset ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) ?L›*) eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*))
(*goal: ‹⋀v. v ∈ L ⟹ (φ⇧⋆) g v ∈ L›*)
by blast
hence H1_1: "(φ⇧⋆) g w ∈ L"
using A1_1 (*‹w ∈ L›*) by simp
from A1_1 (*‹w ∈ L›*) have H1_2: "⋀v. v ∈ [w]⇩M⇩N ⟹ v ∈ L"
apply (clarsimp simp add: rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*))
(*goal: ‹⋀v::'alpha list. v ∈ [w::'alpha list]⇩M⇩N ⟹ v ∈ (L::'alpha list set)›*)
by (metis lists.simps (*‹(?a ∈ ?A⇧⋆) = (?a = [] ∨ (∃a l. ?a = a # l ∧ a ∈ ?A ∧ l ∈ ?A⇧⋆))›*) self_append_conv (*‹(?y = ?y @ ?ys) = (?ys = [])›*))
have H1_3: "([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g [w]⇩M⇩N = [(φ⇧⋆) g w]⇩M⇩N"
using eq_var_rel.quot_act_wd[where R = "≡⇩M⇩N" and G = G and X = "A⇧⋆" and φ = "φ⇧⋆" and g = g and x = "w"] (*‹⟦eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N; equiv (A⇧⋆) ≡⇩M⇩N; w ∈ A⇧⋆; g ∈ carrier G⟧ ⟹ g ⊙⇘[φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙⇙ ≡⇩M⇩N `` {w} = ≡⇩M⇩N `` {g ⊙⇘φ⇧⋆⇙ w}›*) MN_rel_eq_var (*‹eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N›*) MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*) G_lang_axioms (*‹G_lang G A φ L›*) by (clarsimp simp add: A1_0 (*‹g ∈ carrier G›*) A1_1 (*‹w ∈ L›*) G_lang_axioms_def (*‹G_lang_axioms ?G ?A ?φ ?L ≡ eq_var_subset ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) ?L›*) G_lang_def (*‹G_lang ?G ?A ?φ ?L ≡ alt_grp_act ?G ?A ?φ ∧ language ?A ?L ∧ G_lang_axioms ?G ?A ?φ ?L›*) eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*))
show "∃wa∈L. ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g [w]⇩M⇩N = [wa]⇩M⇩N"
using H1_1 (*‹(φ⇧⋆) g w ∈ L›*) H1_3 (*‹([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g [w]⇩M⇩N = [(φ⇧⋆) g w]⇩M⇩N›*) by blast
qed
show "?thesis"
(*goal: ‹eq_var_subset (G::('grp, 'b) monoid_scheme) (A⇧⋆ // ≡⇩M⇩N) ([(φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) MN_fin_states›*)
apply (rule alt_grp_act.eq_var_one_direction (*‹⟦alt_grp_act ?G ?X ?φ; ?Y ⊆ ?X; ∀g∈carrier ?G. ?φ g ` ?Y ⊆ ?Y⟧ ⟹ eq_var_subset ?G ?X ?φ ?Y›*))
(*goal: ‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) MN_fin_states›*)
using MN_init_state_equivar_v2 (*‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state}›*) eq_var_subset.axioms(1) (*‹eq_var_subset ?G ?X ?φ ?Y ⟹ alt_grp_act ?G ?X ?φ›*) apply blast
(*top goal: ‹alt_grp_act (G::('grp, 'b) monoid_scheme) (A⇧⋆ // ≡⇩M⇩N) ([(φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙)› and 2 goals remain*)
apply clarsimp
(*top goal: ‹MN_fin_states ⊆ A⇧⋆ // ≡⇩M⇩N› and 1 goal remains*)
subgoal for w
using G_lang_axioms (*‹G_lang G A φ L›*) by (auto simp add: quotient_def (*‹?A // ?r = (⋃x∈?A. {?r `` {x}})›*) G_lang_axioms_def (*‹G_lang_axioms ?G ?A ?φ ?L ≡ eq_var_subset ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) ?L›*) G_lang_def (*‹G_lang ?G ?A ?φ ?L ≡ alt_grp_act ?G ?A ?φ ∧ language ?A ?L ∧ G_lang_axioms ?G ?A ?φ ?L›*) eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*))
apply (simp add: Set.subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*))
(*goal: ‹∀g∈carrier G. ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g ` MN_fin_states ⊆ MN_fin_states›*)
apply clarify
(*goal: ‹∀g∈carrier G. ∀x. (∃w∈L. x = [w]⇩M⇩N) ⟶ (∃w∈L. ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g x = [w]⇩M⇩N)›*)
by (simp add: H_0 (*‹⟦?g1 ∈ carrier G; ?w1 ∈ L⟧ ⟹ ∃wa∈L. ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) ?g1 [?w1]⇩M⇩N = [wa]⇩M⇩N›*) del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*))
qed
interpretation syntac_aut :
det_aut "A" "MN_equiv" "MN_init_state" "MN_fin_states" "MN_trans_func"
proof (-)
(*goal: ‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N›*)
have H_0: "⋀state label. state ∈ MN_equiv ⟹ label ∈ A ⟹ δ⇩M⇩N state label ∈ MN_equiv"
proof (-)
(*goal: ‹⋀state label. ⟦state ∈ A⇧⋆ // ≡⇩M⇩N; label ∈ A⟧ ⟹ δ⇩M⇩N state label ∈ A⇧⋆ // ≡⇩M⇩N›*)
fix state and label
assume A_0: "state ∈ MN_equiv" and A_1: "label ∈ A" (*‹(state::'alpha list set) ∈ A⇧⋆ // ≡⇩M⇩N› ‹(label::'alpha) ∈ A›*)
obtain w where H_w: "state = [w]⇩M⇩N ∧ w ∈ A⇧⋆"
(*goal: ‹(⋀w. state = [w]⇩M⇩N ∧ w ∈ A⇧⋆ ⟹ thesis) ⟹ thesis›*)
by (metis A_0 (*‹state ∈ A⇧⋆ // ≡⇩M⇩N›*) alt_natural_map_MN_def (*‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}›*) quotientE (*‹⟦?X ∈ ?A // ?r; ⋀x. ⟦?X = ?r `` {x}; x ∈ ?A⟧ ⟹ ?P⟧ ⟹ ?P›*))
have H_0: "δ⇩M⇩N [w]⇩M⇩N label = [w @ [label]]⇩M⇩N"
using MN_trans_func_characterization[where v = w and a = label] (*‹⟦w ∈ A⇧⋆; label ∈ A⟧ ⟹ δ⇩M⇩N [w]⇩M⇩N label = [w @ [label]]⇩M⇩N›*) H_w (*‹state = [w]⇩M⇩N ∧ w ∈ A⇧⋆›*) A_1 (*‹label ∈ A›*) by simp
have H_1: "⋀v. v ∈ A⇧⋆ ⟹ [v]⇩M⇩N ∈ MN_equiv"
by (simp add: in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) quotientI (*‹?x ∈ ?A ⟹ ?r `` {?x} ∈ ?A // ?r›*))
show "δ⇩M⇩N state label ∈ MN_equiv"
using H_w (*‹state = [w]⇩M⇩N ∧ w ∈ A⇧⋆›*) H_0 (*‹δ⇩M⇩N [w]⇩M⇩N label = [w @ [label]]⇩M⇩N›*) H_1 (*‹(?v1::'alpha list) ∈ A⇧⋆ ⟹ [?v1]⇩M⇩N ∈ A⇧⋆ // ≡⇩M⇩N›*) by (simp add: A_1 (*‹label ∈ A›*))
qed
show "det_aut A MN_equiv MN_init_state MN_fin_states δ⇩M⇩N"
apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: det_aut_def (*‹det_aut ?labels ?states ?init_state ?fin_states ?trans_func ≡ ?init_state ∈ ?states ∧ ?fin_states ⊆ ?states ∧ (λ(state, label). ?trans_func state label) ∈ ?states × ?labels →⇩E ?states›*) alt_natural_map_MN_def (*‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}›*))
(*goal: ‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹≡⇩M⇩N `` {[]} ∈ A⇧⋆ // ≡⇩M⇩N ∧ {v. ∃w∈L. v = ≡⇩M⇩N `` {w}} ⊆ A⇧⋆ // ≡⇩M⇩N ∧ (λ(x, y). δ⇩M⇩N x y) ∈ A⇧⋆ // ≡⇩M⇩N × A →⇩E A⇧⋆ // ≡⇩M⇩N›*)
apply ((auto simp add: quotient_def (*‹?A // ?r = (⋃x∈?A. {?r `` {x}})›*))[1])
(*top goal: ‹≡⇩M⇩N `` {[]} ∈ A⇧⋆ // ≡⇩M⇩N› and 2 goals remain*)
using G_lang_axioms (*‹G_lang G A φ L›*)
(*goals:
1. ‹{v. ∃w∈L. v = ≡⇩M⇩N `` {w}} ⊆ A⇧⋆ // ≡⇩M⇩N›
2. ‹(λ(x, y). δ⇩M⇩N x y) ∈ A⇧⋆ // ≡⇩M⇩N × A →⇩E A⇧⋆ // ≡⇩M⇩N›
discuss goal 1*)
apply ((auto simp add: quotient_def (*‹?A // ?r = (⋃x∈?A. {?r `` {x}})›*) G_lang_axioms_def (*‹G_lang_axioms ?G ?A ?φ ?L ≡ eq_var_subset ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) ?L›*) G_lang_def (*‹G_lang ?G ?A ?φ ?L ≡ alt_grp_act ?G ?A ?φ ∧ language ?A ?L ∧ G_lang_axioms ?G ?A ?φ ?L›*) eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*))[1])
(*discuss goal 2*)
apply ((auto simp add: extensional_def (*‹extensional ?A = {f. ∀x. x ∉ ?A ⟶ f x = undefined}›*) PiE_iff (*‹(?f ∈ Pi⇩E ?I ?X) = ((∀i∈?I. ?f i ∈ ?X i) ∧ ?f ∈ extensional ?I)›*) simp del: MN_trans_func_def (*‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*))[1])
(*goals:
1. ‹⋀x y. ⟦x ∈ A⇧⋆ // ≡⇩M⇩N; y ∈ A⟧ ⟹ δ⇩M⇩N x y ∈ A⇧⋆ // ≡⇩M⇩N›
2. ‹⋀a b x. ⟦x ∈ δ⇩M⇩N a b; a ∉ A⇧⋆ // ≡⇩M⇩N⟧ ⟹ x ∈ undefined›
3. ‹⋀a b x. ⟦x ∈ δ⇩M⇩N a b; b ∉ A⟧ ⟹ x ∈ undefined›
4. ‹⋀a b x. ⟦x ∈ undefined; a ∉ A⇧⋆ // ≡⇩M⇩N⟧ ⟹ x ∈ δ⇩M⇩N a b›
5. ‹⋀a b x. ⟦x ∈ undefined; b ∉ A⟧ ⟹ x ∈ δ⇩M⇩N a b›
discuss goal 1*)
apply (simp add: H_0 (*‹⟦?state1 ∈ A⇧⋆ // ≡⇩M⇩N; ?label1 ∈ A⟧ ⟹ δ⇩M⇩N ?state1 ?label1 ∈ A⇧⋆ // ≡⇩M⇩N›*) del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*))
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*discuss goal 4*)
apply ((auto)[1])
(*discuss goal 5*)
apply ((auto)[1])
(*proven 5 subgoals*)
(*proven 2 subgoals*) .
qed
corollary syth_aut_is_det_aut:
"det_aut A MN_equiv MN_init_state MN_fin_states δ⇩M⇩N"
using local.syntac_aut.det_aut_axioms (*‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N›*) by simp
lemma give_input_transition_func:
"w ∈ (A⇧⋆) ⟹ ∀v ∈ (A⇧⋆). [v @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N w"
proof (-)
(*goal: ‹w ∈ A⇧⋆ ⟹ ∀v∈A⇧⋆. [v @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N w›*)
assume A_0: "w ∈ A⇧⋆" (*‹(w::'alpha list) ∈ A⇧⋆›*)
have H_0: "⋀ a w v. ⟦a ∈ A; w ∈ A⇧⋆; ∀v∈A⇧⋆. [v @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N w; v ∈ A⇧⋆⟧ ⟹
[v @ a # w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N (a # w)"
proof (-)
(*goal: ‹⋀a w v. ⟦a ∈ A; w ∈ A⇧⋆; ∀v∈A⇧⋆. [v @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N w; v ∈ A⇧⋆⟧ ⟹ [v @ a # w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N (a # w)›*)
fix a and w and v
assume A1_IH: "∀v∈ A⇧⋆. [v @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N w" and A1_0: "a ∈ A" and A1_1: "v ∈ A⇧⋆" and A1_2: "w ∈ A⇧⋆" (*‹∀v::'alpha list∈A⇧⋆. [v @ (w::'alpha list)]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N w› ‹(a::'alpha) ∈ A› ‹(v::'alpha list) ∈ A⇧⋆› ‹(w::'alpha list) ∈ A⇧⋆›*)
from A1_IH (*‹∀v∈A⇧⋆. [v @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N w›*) A1_1 (*‹v ∈ A⇧⋆›*) A1_2 (*‹w ∈ A⇧⋆›*) have H1_1: "[v @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N w"
by auto
have H1_2: "[(v @ [a]) @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v @ [a]]⇩M⇩N w"
apply (rule meta_mp[of "(v @ [a]) ∈ (A⇧⋆)"] (*‹⟦v @ [a] ∈ A⇧⋆ ⟹ PROP ?Q; v @ [a] ∈ A⇧⋆⟧ ⟹ PROP ?Q›*))
(*goal: ‹[(v @ [a]) @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v @ [a]]⇩M⇩N w›*)
using A1_IH (*‹∀v∈A⇧⋆. [v @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N w›*) A1_2 (*‹w ∈ A⇧⋆›*) H1_1 (*‹[v @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N w›*) apply blast
(*top goal: ‹v @ [a] ∈ A⇧⋆ ⟹ [(v @ [a]) @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v @ [a]]⇩M⇩N w› and 1 goal remains*)
using A1_0 (*‹(a::'alpha) ∈ A›*) A1_1 (*‹v ∈ A⇧⋆›*) by auto
have H1_3: "δ⇩M⇩N [v]⇩M⇩N a = [v @ [a]]⇩M⇩N"
using MN_trans_func_characterization[where a = a] (*‹⟦(?v::'alpha list) ∈ A⇧⋆; (a::'alpha) ∈ A⟧ ⟹ δ⇩M⇩N [?v]⇩M⇩N a = [?v @ [a]]⇩M⇩N›*) A1_0 (*‹a ∈ A›*) A1_1 (*‹v ∈ A⇧⋆›*) by auto
hence H1_4: "[v @ a # w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v @ [a]]⇩M⇩N w"
using H1_2 (*‹[(v @ [a]) @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v @ [a]]⇩M⇩N w›*) by auto
also (*calculation: ‹[v @ a # w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v @ [a]]⇩M⇩N w›*) have H1_5: "... = (δ⇩M⇩N⇧⋆) (δ⇩M⇩N [v]⇩M⇩N a) w"
using H1_4 (*‹[(v::'alpha list) @ (a::'alpha) # (w::'alpha list)]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v @ [a]]⇩M⇩N w›*) H1_3 (*‹δ⇩M⇩N [v]⇩M⇩N a = [v @ [a]]⇩M⇩N›*) A1_1 (*‹(v::'alpha::type list) ∈ A⇧⋆›*) by auto
thus "[v @ a # w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N (a # w)"
using calculation (*‹[v @ a # w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v @ [a]]⇩M⇩N w›*) by auto
qed
from A_0 (*‹(w::'alpha list) ∈ A⇧⋆›*) show "?thesis"
(*goal: ‹∀v∈A⇧⋆. [v @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N w›*)
apply ((induction w)[1])
(*goals:
1. ‹∀v::'alpha list∈A⇧⋆. [v @ []]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N []›
2. ‹⋀(a::'alpha) l::'alpha list. ⟦a ∈ A; l ∈ A⇧⋆; ∀v::'alpha list∈A⇧⋆. [v @ l]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N l⟧ ⟹ ∀v::'alpha list∈A⇧⋆. [v @ a # l]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N (a # l)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply (simp add: H_0 (*‹⟦?a1 ∈ A; ?w1 ∈ A⇧⋆; ∀v∈A⇧⋆. [v @ ?w1]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N ?w1; ?v1 ∈ A⇧⋆⟧ ⟹ [?v1 @ ?a1 # ?w1]⇩M⇩N = (δ⇩M⇩N⇧⋆) [?v1]⇩M⇩N (?a1 # ?w1)›*) del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*))
(*proven 2 subgoals*) .
qed
lemma MN_unique_init_state:
"w ∈ (A⇧⋆) ⟹ [w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [Nil]⇩M⇩N w"
using give_input_transition_func[where w = w] (*‹(w::'alpha list) ∈ A⇧⋆ ⟹ ∀v::'alpha list∈A⇧⋆. [v @ w]⇩M⇩N = (δ⇩M⇩N⇧⋆) [v]⇩M⇩N w›*) by (metis append_self_conv2 (*‹(?xs @ ?ys = ?ys) = (?xs = [])›*) lists.Nil (*‹[] ∈ ?A⇧⋆›*))
lemma fin_states_rep_by_lang:
"w ∈ A⇧⋆ ⟹ [w]⇩M⇩N ∈ MN_fin_states ⟹ w ∈ L"
proof (-)
(*goal: ‹⟦w ∈ A⇧⋆; [w]⇩M⇩N ∈ MN_fin_states⟧ ⟹ w ∈ L›*)
assume A_0: "w ∈ A⇧⋆" and A_1: "[w]⇩M⇩N ∈ MN_fin_states" (*‹(w::'alpha list) ∈ A⇧⋆› ‹[w::'alpha list]⇩M⇩N ∈ MN_fin_states›*)
from A_1 (*‹[w]⇩M⇩N ∈ MN_fin_states›*) have H_0: "∃w'∈[w]⇩M⇩N. w' ∈ L"
apply clarsimp
(*goal: ‹∃w'∈[w]⇩M⇩N. w' ∈ L›*)
by (metis A_0 (*‹(w::'alpha list) ∈ A⇧⋆›*) MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*) equiv_class_self (*‹⟦equiv (?A::?'a set) (?r::(?'a × ?'a) set); (?a::?'a) ∈ ?A⟧ ⟹ ?a ∈ ?r `` {?a}›*) proj_def (*‹BNF_Greatest_Fixpoint.proj (?r::(?'b × ?'a) set) (?x::?'b) = ?r `` {?x}›*) proj_in_iff (*‹equiv (?A::?'a set) (?r::(?'a × ?'a) set) ⟹ (BNF_Greatest_Fixpoint.proj ?r (?x::?'a) ∈ ?A // ?r) = (?x ∈ ?A)›*))
from H_0 (*‹∃w'∈[w]⇩M⇩N. w' ∈ L›*) obtain w' where H_w': "w'∈[w]⇩M⇩N ∧ w' ∈ L"
(*goal: ‹(⋀w'. w' ∈ [w]⇩M⇩N ∧ w' ∈ L ⟹ thesis) ⟹ thesis›*)
by auto
have H_1: "⋀v. v ∈ A⇧⋆ ⟹ w'@v ∈ L ⟹ w@v ∈ L"
using H_w' (*‹w' ∈ [w]⇩M⇩N ∧ w' ∈ L›*) A_1 (*‹[w]⇩M⇩N ∈ MN_fin_states›*) A_0 (*‹w ∈ A⇧⋆›*) by (auto simp add: rel_MN_def (*‹≡⇩M⇩N = {(w::'alpha::type list, w'::'alpha::type list). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v::'alpha::type list∈A⇧⋆. (w @ v ∈ (L::'alpha::type list set)) = (w' @ v ∈ L))}›*))
show "w ∈ L"
using H_1 (*‹⟦(?v1::'alpha list) ∈ A⇧⋆; (w'::'alpha list) @ ?v1 ∈ (L::'alpha list set)⟧ ⟹ (w::'alpha list) @ ?v1 ∈ L›*) H_w' (*‹w' ∈ [w]⇩M⇩N ∧ w' ∈ L›*) apply clarify
(*goal: ‹w ∈ L›*)
by (metis append_Nil2 (*‹?xs @ [] = ?xs›*) lists.Nil (*‹[] ∈ ?A⇧⋆›*))
qed
text ‹
The following lemma corresponds to lemma 3.6 from \cite{bojanczyk2014automata}:
›
lemma syntactic_aut_det_G_aut:
"det_G_aut A MN_equiv MN_init_state MN_fin_states MN_trans_func G φ ([φ⇧⋆]⇩≡⇩M⇩N ⇘A⇧⋆⇙)"
apply (clarsimp simp add: det_G_aut_def (*‹det_G_aut (?A::?'alpha set) (?S::?'states set) (?i::?'states) (?F::?'states set) (?δ::?'states ⇒ ?'alpha ⇒ ?'states) (?G::(?'grp, ?'b) monoid_scheme) (?φ::?'grp ⇒ ?'alpha ⇒ ?'alpha) (?ψ::?'grp ⇒ ?'states ⇒ ?'states) ≡ (det_aut ?A ?S ?i ?F ?δ ∧ alt_grp_act ?G ?A ?φ ∧ alt_grp_act ?G ?S ?ψ) ∧ eq_var_subset ?G ?S ?ψ ?F ∧ eq_var_subset ?G ?S ?ψ {?i} ∧ eq_var_func ?G (?S × ?A) (λg::?'grp∈carrier ?G. λ(s::?'states, a::?'alpha)∈?S × ?A. (?ψ g s, ?φ g a)) ?S ?ψ (λ(s::?'states, a::?'alpha)∈?S × ?A. ?δ s a)›*) simp del: GMN_simps (*‹(⊙⇘?φ::?'grp ⇒ ?'X ⇒ ?'X⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹(?func::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆ = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) (A⇧⋆))› ‹[?func::'grp ⇒ ?'Y ⇒ ?'Y]⇩?R::(?'Y × ?'Y) set⇘?S::?'Y set⇙ = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). λx::?'Y set∈?S // ?R. ?R `` {?func g (SOME z::?'Y. z ∈ x)})› ‹[?w::'alpha list]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N (?W'::'alpha list set) (?a'::'alpha) = (λ(W::'alpha list set, a::'alpha)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w::'alpha list. w ∈ W) @ [a]}) (?W', ?a')›*))
(*goal: ‹det_G_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N (G::('grp, 'b) monoid_scheme) (φ::'grp ⇒ 'alpha ⇒ 'alpha) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙)›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N ∧ alt_grp_act G A φ ∧ alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) ∧ eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) MN_fin_states ∧ eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state} ∧ eq_var_func G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(s, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g s, φ g a)) (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y)›*)
using syth_aut_is_det_aut (*‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N›*) apply ((auto)[1])
(*top goal: ‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N› and 5 goals remain*)
using alt_grp_act_axioms (*‹alt_grp_act G A φ›*) apply ((auto)[1])
(*top goal: ‹alt_grp_act G A φ› and 4 goals remain*)
using MN_init_state_equivar_v2 (*‹eq_var_subset (G::('grp, 'b) monoid_scheme) (A⇧⋆ // ≡⇩M⇩N) ([(φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state}›*) eq_var_subset.axioms(1) (*‹eq_var_subset ?G ?X ?φ ?Y ⟹ alt_grp_act ?G ?X ?φ›*) apply blast
(*top goal: ‹alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙)› and 3 goals remain*)
using MN_final_state_equiv (*‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) MN_fin_states›*) apply presburger
(*top goal: ‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) MN_fin_states› and 2 goals remain*)
using MN_init_state_equivar_v2 (*‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state}›*) apply presburger
(*top goal: ‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state}› and 1 goal remains*)
using MN_trans_eq_var_func (*‹eq_var_func G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)) (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y)›*) by linarith
lemma syntactic_aut_det_G_aut_rec_L:
"det_G_aut_rec_lang A MN_equiv MN_init_state MN_fin_states MN_trans_func G φ
([φ⇧⋆]⇩≡⇩M⇩N ⇘A⇧⋆⇙) L"
apply (clarsimp simp add: det_G_aut_rec_lang_def (*‹det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ det_aut_rec_lang ?A ?S ?i ?F ?δ ?L›*) det_aut_rec_lang_axioms_def (*‹det_aut_rec_lang_axioms ?A ?i ?F ?δ ?L ≡ ∀w. (w ∈ ?L) = (w ∈ ?A⇧⋆ ∧ (?δ⇧⋆) ?i w ∈ ?F)›*) det_aut_rec_lang_def (*‹det_aut_rec_lang ?A ?S ?i ?F ?δ ?L ≡ det_aut ?A ?S ?i ?F ?δ ∧ language ?A ?L ∧ det_aut_rec_lang_axioms ?A ?i ?F ?δ ?L›*) simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*))
(*goal: ‹det_G_aut_rec_lang A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N G φ ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) L›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹det_G_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N G φ ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) ∧ det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N ∧ (∀w. (w ∈ L) = (w ∈ A⇧⋆ ∧ (∃wa∈L. (δ⇩M⇩N⇧⋆) MN_init_state w = [wa]⇩M⇩N)))›*)
using syntactic_aut_det_G_aut (*‹det_G_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N G φ ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙)›*) syth_aut_is_det_aut (*‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N›*) apply ((auto)[1])
(*top goal: ‹det_G_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N G φ ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙)› and 2 goals remain*)
using syntactic_aut_det_G_aut (*‹det_G_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N G φ ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙)›*) syth_aut_is_det_aut (*‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N›*) apply ((auto)[1])
(*top goal: ‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N› and 1 goal remains*)
apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*); rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))
(*goal: ‹∀w. (w ∈ L) = (w ∈ A⇧⋆ ∧ (∃wa∈L. (δ⇩M⇩N⇧⋆) MN_init_state w = [wa]⇩M⇩N))›*)
apply (rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*top goal: ‹⋀w. w ∈ L ⟹ w ∈ A⇧⋆ ∧ (∃wa∈L. (δ⇩M⇩N⇧⋆) MN_init_state w = [wa]⇩M⇩N)› and 1 goal remains*)
using L_is_equivar (*‹eq_var_subset G (A⇧⋆) (φ⇧⋆) L›*) eq_var_subset.is_subset (*‹eq_var_subset ?G ?X ?φ ?Y ⟹ ?Y ⊆ ?X›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) image_mono (*‹(?A::?'a set) ⊆ (?B::?'a set) ⟹ (?f::?'a ⇒ ?'b) ` ?A ⊆ ?f ` ?B›*) insert_image (*‹?x ∈ ?A ⟹ insert (?f ?x) (?f ` ?A) = ?f ` ?A›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) apply blast
(*top goal: ‹⋀w::'alpha::type list. w ∈ (L::'alpha::type list set) ⟹ w ∈ A⇧⋆› and 2 goals remain*)
using MN_unique_init_state (*‹?w ∈ A⇧⋆ ⟹ [?w]⇩M⇩N = (δ⇩M⇩N⇧⋆) MN_init_state ?w›*) L_is_equivar (*‹eq_var_subset G (A⇧⋆) (φ⇧⋆) L›*) eq_var_subset.is_subset (*‹eq_var_subset ?G ?X ?φ ?Y ⟹ ?Y ⊆ ?X›*) apply blast
(*top goal: ‹⋀w. w ∈ L ⟹ ∃wa∈L. (δ⇩M⇩N⇧⋆) MN_init_state w = [wa]⇩M⇩N› and 1 goal remains*)
using MN_unique_init_state (*‹?w ∈ A⇧⋆ ⟹ [?w]⇩M⇩N = (δ⇩M⇩N⇧⋆) MN_init_state ?w›*) fin_states_rep_by_lang (*‹⟦?w ∈ A⇧⋆; [?w]⇩M⇩N ∈ MN_fin_states⟧ ⟹ ?w ∈ L›*) in_lists_conv_set (*‹((?xs::?'a list) ∈ (?A::?'a set)⇧⋆) = (∀x::?'a∈set ?xs. x ∈ ?A)›*) by (smt (verit) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*))
lemma syntact_aut_is_reach_aut_rec_lang:
"reach_det_G_aut_rec_lang A MN_equiv MN_init_state MN_fin_states MN_trans_func G φ
([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) L"
apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: reach_det_G_aut_rec_lang_def (*‹reach_det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ∧ reach_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ›*) det_G_aut_rec_lang_def (*‹det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ det_aut_rec_lang ?A ?S ?i ?F ?δ ?L›*) det_aut_rec_lang_axioms_def (*‹det_aut_rec_lang_axioms ?A ?i ?F ?δ ?L ≡ ∀w. (w ∈ ?L) = (w ∈ ?A⇧⋆ ∧ (?δ⇧⋆) ?i w ∈ ?F)›*) reach_det_G_aut_def (*‹reach_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ reach_det_aut ?A ?S ?i ?F ?δ›*) reach_det_aut_def (*‹reach_det_aut ?A ?S ?i ?F ?δ ≡ det_aut ?A ?S ?i ?F ?δ ∧ reach_det_aut_axioms ?A ?S ?i ?δ›*) reach_det_aut_axioms_def (*‹reach_det_aut_axioms ?A ?S ?i ?δ ≡ ∀s. s ∈ ?S ⟶ (∃input∈?A⇧⋆. (?δ⇧⋆) ?i input = s)›*) det_G_aut_def (*‹det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ (det_aut ?A ?S ?i ?F ?δ ∧ alt_grp_act ?G ?A ?φ ∧ alt_grp_act ?G ?S ?ψ) ∧ eq_var_subset ?G ?S ?ψ ?F ∧ eq_var_subset ?G ?S ?ψ {?i} ∧ eq_var_func ?G (?S × ?A) (λg∈carrier ?G. λ(s, a)∈?S × ?A. (?ψ g s, ?φ g a)) ?S ?ψ (λ(s, a)∈?S × ?A. ?δ s a)›*) det_aut_rec_lang_def (*‹det_aut_rec_lang ?A ?S ?i ?F ?δ ?L ≡ det_aut ?A ?S ?i ?F ?δ ∧ language ?A ?L ∧ det_aut_rec_lang_axioms ?A ?i ?F ?δ ?L›*))
(*goal: ‹reach_det_G_aut_rec_lang A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N (G::('grp, 'b) monoid_scheme) (φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (L::'alpha::type list set)›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N ∧ alt_grp_act (G::('grp, 'b) monoid_scheme) A (φ::'grp ⇒ 'alpha ⇒ 'alpha) ∧ alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) ∧ eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) MN_fin_states ∧ eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state} ∧ eq_var_func G (A⇧⋆ // ≡⇩M⇩N × A) (λg::'grp∈carrier G. λ(s::'alpha list set, a::'alpha)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g s, φ g a)) (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (λ(x::'alpha list set, y::'alpha)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) ∧ det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N ∧ (∀w::'alpha list. (w ∈ (L::'alpha list set)) = (w ∈ A⇧⋆ ∧ (∃wa::'alpha list∈L. (δ⇩M⇩N⇧⋆) MN_init_state w = [wa]⇩M⇩N))) ∧ det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N ∧ alt_grp_act G A φ ∧ alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) ∧ eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) MN_fin_states ∧ eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state} ∧ eq_var_func G (A⇧⋆ // ≡⇩M⇩N × A) (λg::'grp∈carrier G. λ(s::'alpha list set, a::'alpha)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g s, φ g a)) (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (λ(x::'alpha list set, y::'alpha)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) ∧ det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N ∧ (∀s::'alpha list set. s ∈ A⇧⋆ // ≡⇩M⇩N ⟶ (∃input::'alpha list∈A⇧⋆. (δ⇩M⇩N⇧⋆) MN_init_state input = s))›*)
using syth_aut_is_det_aut (*‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N›*) apply blast
(*top goal: ‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N› and 15 goals remain*)
using alt_grp_act_axioms (*‹alt_grp_act G A φ›*) apply ((auto)[1])
(*top goal: ‹alt_grp_act G A φ› and 14 goals remain*)
subgoal for
using MN_init_state_equivar_v2 (*‹eq_var_subset (G::('grp, 'b) monoid_scheme) (A⇧⋆ // ≡⇩M⇩N) ([(φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state}›*) eq_var_subset.axioms(1) (*‹eq_var_subset ?G ?X ?φ ?Y ⟹ alt_grp_act ?G ?X ?φ›*) by blast
using MN_final_state_equiv (*‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) MN_fin_states›*) apply presburger
(*top goal: ‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) MN_fin_states› and 12 goals remain*)
using MN_init_state_equivar_v2 (*‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state}›*) subgoal for
by presburger
using MN_trans_eq_var_func (*‹eq_var_func G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)) (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y)›*) apply linarith
(*top goal: ‹eq_var_func G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(s, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g s, φ g a)) (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y)› and 10 goals remain*)
using syth_aut_is_det_aut (*‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N›*) apply ((auto)[1])
(*top goal: ‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N› and 9 goals remain*)
apply (metis (mono_tags, lifting) G_lang.MN_unique_init_state (*‹⟦G_lang ?G ?A ?φ ?L; ?w ∈ ?A⇧⋆⟧ ⟹ language.alt_natural_map_MN ?A ?L ?w = ((language.MN_trans_func ?A ?L)⇧⋆) (language.alt_natural_map_MN ?A ?L []) ?w›*) G_lang_axioms (*‹G_lang G A φ L›*) det_G_aut_rec_lang_def (*‹det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ det_aut_rec_lang ?A ?S ?i ?F ?δ ?L›*) det_aut_rec_lang.is_recognised (*‹det_aut_rec_lang ?A ?S ?i ?F ?δ ?L ⟹ (?w ∈ ?L) = (?w ∈ ?A⇧⋆ ∧ (?δ⇧⋆) ?i ?w ∈ ?F)›*) syntactic_aut_det_G_aut_rec_L (*‹det_G_aut_rec_lang A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N G φ ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) L›*))
(*top goal: ‹∀w::'alpha list. (w ∈ (L::'alpha list set)) = (w ∈ A⇧⋆ ∧ (∃wa::'alpha list∈L. (δ⇩M⇩N⇧⋆) MN_init_state w = [wa]⇩M⇩N))› and 8 goals remain*)
using syth_aut_is_det_aut (*‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N›*) apply ((auto)[1])
(*top goal: ‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N› and 7 goals remain*)
using alt_grp_act_axioms (*‹alt_grp_act G A φ›*) apply ((auto)[1])
(*top goal: ‹alt_grp_act G A φ› and 6 goals remain*)
using ‹alt_grp_act G MN_equiv ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙)› (*‹alt_grp_act (G::('grp, 'b) monoid_scheme) (A⇧⋆ // ≡⇩M⇩N) ([(φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙)›*) apply blast
(*top goal: ‹alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙)› and 5 goals remain*)
using ‹eq_var_subset G MN_equiv ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) MN_fin_states› (*‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) MN_fin_states›*) apply blast
(*top goal: ‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) MN_fin_states› and 4 goals remain*)
using ‹eq_var_subset G MN_equiv ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state}› (*‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state}›*) apply blast
(*top goal: ‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) {MN_init_state}› and 3 goals remain*)
using MN_trans_eq_var_func (*‹eq_var_func G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g W, φ g a)) (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y)›*) apply blast
(*top goal: ‹eq_var_func G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(s, a)∈A⇧⋆ // ≡⇩M⇩N × A. (([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) g s, φ g a)) (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y)› and 2 goals remain*)
using syth_aut_is_det_aut (*‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N›*)
(*goals:
1. ‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N›
2. ‹∀s. s ∈ A⇧⋆ // ≡⇩M⇩N ⟶ (∃input∈A⇧⋆. (δ⇩M⇩N⇧⋆) MN_init_state input = s)›
discuss goal 1*)
apply auto
(*discuss goal 2*)
apply (metis MN_unique_init_state (*‹(?w::'alpha list) ∈ A⇧⋆ ⟹ [?w]⇩M⇩N = (δ⇩M⇩N⇧⋆) MN_init_state ?w›*) alt_natural_map_MN_def (*‹[?w::'alpha list]⇩M⇩N = ≡⇩M⇩N `` {?w}›*) quotientE (*‹⟦(?X::?'a set) ∈ (?A::?'a set) // (?r::(?'a × ?'a) set); ⋀x::?'a. ⟦?X = ?r `` {x}; x ∈ ?A⟧ ⟹ ?P::bool⟧ ⟹ ?P›*))
(*proven 2 subgoals*) .
end
subsection ‹
Proving the Myhill-Nerode Theorem for $G$-Automata
›
context det_G_aut begin
no_adhoc_overloading
star labels_a_G_set.induced_star_map
end
context reach_det_G_aut_rec_lang begin
adhoc_overloading
star labels_a_G_set.induced_star_map
definition
states_to_words :: "'states ⇒ 'alpha list"
where "states_to_words = (λs ∈ S. SOME w. w ∈ A⇧⋆ ∧ ((δ⇧⋆) i w = s))"
definition
words_to_syth_states :: "'alpha list ⇒ 'alpha list set"
where "words_to_syth_states w = [w]⇩M⇩N"
definition
induced_epi:: "'states ⇒ 'alpha list set"
where "induced_epi = compose S words_to_syth_states states_to_words"
lemma induced_epi_wd1:
"s ∈ S ⟹ ∃w. w ∈ A⇧⋆ ∧ ((δ⇧⋆) i w = s)"
using reach_det_G_aut_rec_lang_axioms (*‹reach_det_G_aut_rec_lang A S i F δ G φ ψ L›*) is_reachable (*‹?s ∈ S ⟹ ∃input∈A⇧⋆. (δ⇧⋆) i input = ?s›*) by auto
lemma induced_epi_wd2:
"w ∈ A⇧⋆ ⟹ w' ∈ A⇧⋆ ⟹ (δ⇧⋆) i w = (δ⇧⋆) i w' ⟹ [w]⇩M⇩N = [w']⇩M⇩N"
proof (-)
(*goal: ‹⟦w ∈ A⇧⋆; w' ∈ A⇧⋆; (δ⇧⋆) i w = (δ⇧⋆) i w'⟧ ⟹ [w]⇩M⇩N = [w']⇩M⇩N›*)
assume A_0: "w ∈ A⇧⋆" and A_1: "w' ∈ A⇧⋆" and A_2: "(δ⇧⋆) i w = (δ⇧⋆) i w'" (*‹(w::'alpha list) ∈ (A::'alpha set)⇧⋆› ‹(w'::'alpha list) ∈ (A::'alpha set)⇧⋆› ‹((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w::'alpha list) = (δ⇧⋆) i (w'::'alpha list)›*)
have H_0: "⋀v. v ∈ A⇧⋆ ⟹ w @ v ∈ L ⟷ w' @ v ∈ L"
apply clarify
(*goal: ‹⋀v::'alpha list. v ∈ (A::'alpha set)⇧⋆ ⟹ ((w::'alpha list) @ v ∈ (L::'alpha list set)) = ((w'::'alpha list) @ v ∈ L)›*)
by (smt (z3) A_0 (*‹w ∈ A⇧⋆›*) A_1 (*‹w' ∈ A⇧⋆›*) A_2 (*‹(δ⇧⋆) i w = (δ⇧⋆) i w'›*) append_in_lists_conv (*‹(?xs @ ?ys ∈ ?A⇧⋆) = (?xs ∈ ?A⇧⋆ ∧ ?ys ∈ ?A⇧⋆)›*) is_aut.eq_pres_under_concat (*‹⟦?w ∈ A⇧⋆; ?w' ∈ A⇧⋆; ?s ∈ S; (δ⇧⋆) ?s ?w = (δ⇧⋆) ?s ?w'⟧ ⟹ ∀v∈A⇧⋆. (δ⇧⋆) ?s (?w @ v) = (δ⇧⋆) ?s (?w' @ v)›*) is_aut.init_state_is_a_state (*‹i ∈ S›*) is_lang (*‹L ⊆ A⇧⋆›*) is_recognised (*‹(?w ∈ L) = (?w ∈ A⇧⋆ ∧ (δ⇧⋆) i ?w ∈ F)›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*))
show "[w]⇩M⇩N = [w']⇩M⇩N "
apply (simp add: rel_MN_def (*‹≡⇩M⇩N = {(w::'alpha list, w'::'alpha list). (w, w') ∈ (A::'alpha set)⇧⋆ × A⇧⋆ ∧ (∀v::'alpha list∈A⇧⋆. (w @ v ∈ (L::'alpha list set)) = (w' @ v ∈ L))}›*))
(*goal: ‹[w]⇩M⇩N = [w']⇩M⇩N›*)
using H_0 (*‹(?v1::'alpha list) ∈ (A::'alpha set)⇧⋆ ⟹ ((w::'alpha list) @ ?v1 ∈ (L::'alpha list set)) = ((w'::'alpha list) @ ?v1 ∈ L)›*) A_0 (*‹w ∈ A⇧⋆›*) A_1 (*‹w' ∈ A⇧⋆›*) by auto
qed
lemma states_to_words_on_final:
"states_to_words ∈ (F → L)"
proof (-)
(*goal: ‹states_to_words ∈ F → L›*)
have H_0: "⋀x. x ∈ F ⟹ x ∈ S ⟹ (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = x) ∈ L"
proof (-)
(*goal: ‹⋀x::'states::type. ⟦x ∈ (F::'states::type set); x ∈ (S::'states::type set)⟧ ⟹ (SOME w::'alpha::type list. w ∈ (A::'alpha::type set)⇧⋆ ∧ ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) w = x) ∈ (L::'alpha::type list set)›*)
fix s
assume A1_0: "s ∈ F" (*‹(s::'states) ∈ (F::'states set)›*)
have H1_0: "∃w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s"
using A1_0 (*‹s ∈ F›*) is_reachable (*‹?s ∈ S ⟹ ∃input∈A⇧⋆. (δ⇧⋆) i input = ?s›*) by (metis is_aut.fin_states_are_states (*‹F ⊆ S›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*))
have H1_1: "⋀w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s ⟹ w ∈ L"
using A1_0 (*‹s ∈ F›*) is_recognised (*‹((?w::'alpha list) ∈ (L::'alpha list set)) = (?w ∈ (A::'alpha set)⇧⋆ ∧ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) ?w ∈ (F::'states set))›*) by auto
show "(SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s) ∈ L "
by (metis (mono_tags, lifting) H1_0 (*‹∃w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s›*) H1_1 (*‹?w1 ∈ A⇧⋆ ∧ (δ⇧⋆) i ?w1 = s ⟹ ?w1 ∈ L›*) someI_ex (*‹∃x. ?P x ⟹ ?P (SOME x. ?P x)›*))
qed
show "?thesis"
(*goal: ‹states_to_words ∈ F → L›*)
apply (clarsimp simp add: states_to_words_def (*‹states_to_words = (λs∈S. SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)›*))
(*goal: ‹states_to_words ∈ F → L›*)
apply (rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*); rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀x. x ∈ F ⟹ (x ∈ S ⟶ (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = x) ∈ L) ∧ (x ∉ S ⟶ undefined ∈ L)›*)
apply (simp add: H_0 (*‹⟦?x1 ∈ F; ?x1 ∈ S⟧ ⟹ (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ?x1) ∈ L›*))
(*top goal: ‹⋀x. ⟦x ∈ F; x ∈ S⟧ ⟹ (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = x) ∈ L› and 1 goal remains*)
using is_aut.fin_states_are_states (*‹F ⊆ S›*) by blast
qed
lemma induced_epi_eq_var:
"eq_var_func G S ψ MN_equiv ([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙) induced_epi"
proof (-)
(*goal: ‹eq_var_func G S ψ (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) induced_epi›*)
have H_0: "⋀ s g. ⟦s ∈ S; g ∈ carrier G; ψ g s ∈ S⟧ ⟹
words_to_syth_states (states_to_words (ψ g s)) =
([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙) g (words_to_syth_states (states_to_words s))"
proof (-)
(*goal: ‹⋀s g. ⟦s ∈ S; g ∈ carrier G; ψ g s ∈ S⟧ ⟹ words_to_syth_states (states_to_words (ψ g s)) = trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g (words_to_syth_states (states_to_words s))›*)
fix s and g
assume A1_0: "s ∈ S" and A1_1: "g ∈ carrier G" and A1_2: "ψ g s ∈ S" (*‹(s::'states) ∈ (S::'states set)› ‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹(ψ::'grp ⇒ 'states ⇒ 'states) (g::'grp) (s::'states) ∈ (S::'states set)›*)
have H1_0: "([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙) g (words_to_syth_states (states_to_words s)) =
[(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N"
apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: words_to_syth_states_def (*‹words_to_syth_states ?w = [?w]⇩M⇩N›*) states_to_words_def (*‹states_to_words = (λs∈S. SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)›*) A1_0 (*‹s ∈ S›*))
(*goal: ‹trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g (words_to_syth_states (states_to_words s)) = [(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N›*)
apply (rule meta_mp[of "(SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s) ∈ A⇧⋆"] (*‹⟦(SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s) ∈ A⇧⋆ ⟹ PROP ?Q; (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s) ∈ A⇧⋆⟧ ⟹ PROP ?Q›*))
(*goal: ‹trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s]⇩M⇩N = [(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N›*)
using quot_act_wd_alt_notation[where w = "(SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)" and g = g] (*‹⟦(SOME w::'alpha list. w ∈ (A::'alpha set)⇧⋆ ∧ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = (s::'states)) ∈ A⇧⋆; (g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)⟧ ⟹ g ⊙⇘trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) ≡⇩M⇩N⇙ [SOME w::'alpha list. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s]⇩M⇩N = [g ⊙⇘φ⇧⋆⇙ (SOME w::'alpha list. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N›*) A1_1 (*‹g ∈ carrier G›*) apply simp
(*top goal: ‹(SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s) ∈ A⇧⋆ ⟹ trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s]⇩M⇩N = [(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N› and 1 goal remains*)
using A1_0 (*‹s ∈ S›*) by (metis (mono_tags, lifting) induced_epi_wd1 (*‹?s ∈ S ⟹ ∃w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ?s›*) some_eq_imp (*‹⟦Eps ?P = ?a; ?P ?b⟧ ⟹ ?P ?a›*))
have H1_1: "⋀g s' w'. ⟦s'∈ S; w'∈ A⇧⋆; g ∈ carrier G; (φ⇧⋆) g w' ∈ A⇧⋆ ∧ ψ g s' ∈ S⟧
⟹ (δ⇧⋆) (ψ g s') ((φ⇧⋆) g w') = ψ g ((δ⇧⋆) s' w')"
using give_input_eq_var (*‹eq_var_func G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)) S ψ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w)›*) apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: eq_var_func_axioms_def (*‹eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀a g. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*) eq_var_func_def (*‹eq_var_func ?G ?X ?φ ?Y ?ψ ?f ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*) make_op_def (*‹(⊙⇘?φ⇙) ≡ ?φ›*))
(*goal: ‹⋀(g::'grp::type) (s'::'states::type) w'::'alpha::type list. ⟦s' ∈ (S::'states::type set); w' ∈ (A::'alpha::type set)⇧⋆; g ∈ carrier (G::('grp, 'b) monoid_scheme); ((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆) g w' ∈ A⇧⋆ ∧ (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) g s' ∈ S⟧ ⟹ ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (ψ g s') ((φ⇧⋆) g w') = ψ g ((δ⇧⋆) s' w')›*)
by (meson in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*))
have H1_2: "{w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s} =
{w'. ∃w ∈ A⇧⋆. (φ⇧⋆) g w = w' ∧ (δ⇧⋆) i w = s}"
proof (rule subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*); clarify)
(*goals:
1. ‹⋀x::'alpha::type list. ⟦((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) x = (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) (g::'grp::type) (s::'states::type); ∀x::'alpha::type∈set x. x ∈ (A::'alpha::type set)⟧ ⟹ ∃w::'alpha::type list∈A⇧⋆. ((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆) g w = x ∧ (δ⇧⋆) i w = s›
2. ‹⋀(x::'alpha::type list) w::'alpha::type list. ⟦∀x::'alpha::type∈set w. x ∈ (A::'alpha::type set); (s::'states::type) = ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) w⟧ ⟹ ((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆) (g::'grp::type) w ∈ A⇧⋆ ∧ (δ⇧⋆) i ((φ⇧⋆) g w) = (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) g ((δ⇧⋆) i w)›*)
fix w'
assume A2_0: "(δ⇧⋆) i w' = ψ g s" and A2_1: "∀x∈set w'. x ∈ A" (*‹((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w'::'alpha list) = (ψ::'grp ⇒ 'states ⇒ 'states) (g::'grp) (s::'states)› ‹∀x::'alpha∈set (w'::'alpha list). x ∈ (A::'alpha set)›*)
have H2_0: "(inv ⇘G⇙ g) ∈ carrier G"
by (meson A1_1 (*‹g ∈ carrier G›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group_hom.axioms( (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) 1) states_a_G_set.group_hom (*‹group_hom G (BijGroup S) ψ›*))
have H2_1: "(φ⇧⋆) g ((φ⇧⋆) (inv ⇘G⇙ g) w') = w'"
by (smt (verit) A1_1 (*‹(g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A2_1 (*‹∀x::'alpha::type∈set (w'::'alpha::type list). x ∈ (A::'alpha::type set)›*) alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) group_action.bij_prop1 (*‹⟦group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c::type set) (?φ::?'a::type ⇒ ?'c::type ⇒ ?'c::type); (?g::?'a::type) ∈ carrier ?G; (?y::?'c::type) ∈ ?E⟧ ⟹ ∃!x::?'c::type. x ∈ ?E ∧ ?φ ?g x = ?y›*) group_action.orbit_sym_aux (*‹⟦group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c::type set) (?φ::?'a::type ⇒ ?'c::type ⇒ ?'c::type); (?g::?'a::type) ∈ carrier ?G; (?x::?'c::type) ∈ ?E; ?φ ?g ?x = (?y::?'c::type)⟧ ⟹ ?φ (inv⇘?G⇙ ?g) ?y = ?x›*) in_listsI (*‹∀x::?'a::type∈set (?xs::?'a::type list). x ∈ (?A::?'a::type set) ⟹ ?xs ∈ ?A⇧⋆›*) labels_a_G_set.lists_a_Gset (*‹alt_grp_act (G::('grp, 'b) monoid_scheme) ((A::'alpha::type set)⇧⋆) ((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆)›*))
have H2_2: "⋀g w. g ∈ carrier G ⟹ w ∈ A⇧⋆ ⟹ (δ⇧⋆) i ((φ⇧⋆) g w) = (δ⇧⋆) (ψ g i) ((φ⇧⋆) g w)"
using init_is_eq_var.eq_var_subset_axioms (*‹eq_var_subset (G::('grp, 'b) monoid_scheme) (S::'states set) (ψ::'grp ⇒ 'states ⇒ 'states) {i::'states}›*) init_is_eq_var.is_equivar (*‹∀g∈carrier G. ψ g ` {i} = {i}›*) by auto
have H2_3: "⋀g w. g ∈ carrier G ⟹ w ∈ A⇧⋆ ⟹ (δ⇧⋆) (ψ g i) ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) i w)"
apply (rule H1_1[where s'1 = i] (*‹⟦i ∈ S; ?w'1 ∈ A⇧⋆; ?g1 ∈ carrier G; (φ⇧⋆) ?g1 ?w'1 ∈ A⇧⋆ ∧ ψ ?g1 i ∈ S⟧ ⟹ (δ⇧⋆) (ψ ?g1 i) ((φ⇧⋆) ?g1 ?w'1) = ψ ?g1 ((δ⇧⋆) i ?w'1)›*))
(*goal: ‹⋀g w. ⟦g ∈ carrier G; w ∈ A⇧⋆⟧ ⟹ (δ⇧⋆) (ψ g i) ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) i w)›*)
apply ((simp add: A2_1 (*‹∀x::'alpha∈set (w'::'alpha list). x ∈ (A::'alpha set)›*) in_lists_conv_set (*‹((?xs::?'a list) ∈ (?A::?'a set)⇧⋆) = (∀x::?'a∈set ?xs. x ∈ ?A)›*) H2_0 (*‹inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp) ∈ carrier G›*) is_aut.init_state_is_a_state (*‹(i::'states) ∈ (S::'states set)›*))+)
(*top goal: ‹⋀g w. ⟦g ∈ carrier G; w ∈ A⇧⋆⟧ ⟹ i ∈ S› and 3 goals remain*)
using is_aut.init_state_is_a_state (*‹i ∈ S›*) labels_a_G_set.element_image (*‹⟦?g ∈ carrier G; ?x ∈ A; φ ?g ?x = ?y⟧ ⟹ ?y ∈ A›*) states_a_G_set.element_image (*‹⟦?g ∈ carrier G; ?x ∈ S; ψ ?g ?x = ?y⟧ ⟹ ?y ∈ S›*) by blast
have H2_4: "ψ (inv ⇘G⇙ g) ((δ⇧⋆) i w') = s"
using A2_0 (*‹(δ⇧⋆) i w' = ψ g s›*) H2_0 (*‹inv⇘G⇙ g ∈ carrier G›*) by (simp add: A1_0 (*‹s ∈ S›*) A1_1 (*‹g ∈ carrier G›*) states_a_G_set.orbit_sym_aux (*‹⟦?g ∈ carrier G; ?x ∈ S; ψ ?g ?x = ?y⟧ ⟹ ψ (inv⇘G⇙ ?g) ?y = ?x›*))
have H2_5: "(δ⇧⋆) i ((φ⇧⋆) (inv ⇘G⇙ g) w') = s"
apply (rule meta_mp[of "w'∈ A⇧⋆"] (*‹⟦w' ∈ A⇧⋆ ⟹ PROP ?Q; w' ∈ A⇧⋆⟧ ⟹ PROP ?Q›*))
(*goal: ‹(δ⇧⋆) i ((φ⇧⋆) (inv⇘G⇙ g) w') = s›*)
using H2_0 (*‹inv⇘G⇙ g ∈ carrier G›*) H2_1 (*‹((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) (g::'grp) ((φ⇧⋆) (inv⇘G::('grp, 'b) monoid_scheme⇙ g) (w'::'alpha list)) = w'›*) H2_4 (*‹ψ (inv⇘G⇙ g) ((δ⇧⋆) i w') = s›*) A2_1 (*‹∀x∈set w'. x ∈ A›*) H2_2 (*‹⟦(?g1::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); (?w1::'alpha list) ∈ (A::'alpha set)⇧⋆⟧ ⟹ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) ?g1 ?w1) = (δ⇧⋆) ((ψ::'grp ⇒ 'states ⇒ 'states) ?g1 i) ((φ⇧⋆) ?g1 ?w1)›*) H2_3 (*‹⟦?g1 ∈ carrier G; ?w1 ∈ A⇧⋆⟧ ⟹ (δ⇧⋆) (ψ ?g1 i) ((φ⇧⋆) ?g1 ?w1) = ψ ?g1 ((δ⇧⋆) i ?w1)›*) apply presburger
(*top goal: ‹w' ∈ A⇧⋆ ⟹ (δ⇧⋆) i ((φ⇧⋆) (inv⇘G⇙ g) w') = s› and 1 goal remains*)
using A2_1 (*‹∀x∈set w'. x ∈ A›*) by auto
have H2_6: "(φ⇧⋆) (inv⇘G⇙ g) w' ∈ A⇧⋆"
using H2_0 (*‹inv⇘G⇙ g ∈ carrier G›*) A2_1 (*‹∀x∈set w'. x ∈ A›*) by (metis alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) group_action.element_image (*‹⟦group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c set) (?φ::?'a ⇒ ?'c ⇒ ?'c); (?g::?'a) ∈ carrier ?G; (?x::?'c) ∈ ?E; ?φ ?g ?x = (?y::?'c)⟧ ⟹ ?y ∈ ?E›*) in_listsI (*‹∀x::?'a∈set (?xs::?'a list). x ∈ (?A::?'a set) ⟹ ?xs ∈ ?A⇧⋆›*) labels_a_G_set.lists_a_Gset (*‹alt_grp_act (G::('grp, 'b) monoid_scheme) ((A::'alpha set)⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆)›*))
thus "∃w∈A⇧⋆. (φ⇧⋆) g w = w' ∧ (δ⇧⋆) i w = s"
using H2_1 (*‹(φ⇧⋆) g ((φ⇧⋆) (inv⇘G⇙ g) w') = w'›*) H2_5 (*‹(δ⇧⋆) i ((φ⇧⋆) (inv⇘G⇙ g) w') = s›*) H2_6 (*‹(φ⇧⋆) (inv⇘G⇙ g) w' ∈ A⇧⋆›*) by blast
next
(*goal: ‹⋀x w. ⟦∀x∈set w. x ∈ A; s = (δ⇧⋆) i w⟧ ⟹ (φ⇧⋆) g w ∈ A⇧⋆ ∧ (δ⇧⋆) i ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) i w)›*)
fix x and w
assume A2_0: "∀x∈set w. x ∈ A" and A2_1: "s = (δ⇧⋆) i w" (*‹∀x::'alpha∈set (w::'alpha list). x ∈ (A::'alpha set)› ‹(s::'states) = ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w::'alpha list)›*)
show "(φ⇧⋆) g w ∈ A⇧⋆ ∧ (δ⇧⋆) i ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) i w) "
apply (rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹(φ⇧⋆) g w ∈ A⇧⋆ ∧ (δ⇧⋆) i ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) i w)›*)
apply (rule meta_mp[of "(inv ⇘G⇙ g) ∈ carrier G"] (*‹⟦inv⇘G⇙ g ∈ carrier G ⟹ PROP ?Q; inv⇘G⇙ g ∈ carrier G⟧ ⟹ PROP ?Q›*))
(*top goal: ‹((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) (g::'grp) (w::'alpha list) ∈ (A::'alpha set)⇧⋆› and 1 goal remains*)
using alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) group_action.element_image (*‹⟦group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c set) (?φ::?'a ⇒ ?'c ⇒ ?'c); (?g::?'a) ∈ carrier ?G; (?x::?'c) ∈ ?E; ?φ ?g ?x = (?y::?'c)⟧ ⟹ ?y ∈ ?E›*) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) labels_a_G_set.lists_a_Gset (*‹alt_grp_act (G::('grp, 'b) monoid_scheme) ((A::'alpha set)⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆)›*) apply (metis A1_1 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A2_0 (*‹∀x::'alpha∈set (w::'alpha list). x ∈ (A::'alpha set)›*))
(*top goal: ‹inv⇘G⇙ g ∈ carrier G ⟹ (φ⇧⋆) g w ∈ A⇧⋆› and 2 goals remain*)
apply (meson A1_1 (*‹g ∈ carrier G›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group_hom.axioms( (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) 1) states_a_G_set.group_hom (*‹group_hom G (BijGroup S) ψ›*))
(*top goal: ‹inv⇘G⇙ g ∈ carrier G› and 1 goal remains*)
apply (rule meta_mp[of "ψ g i = i"] (*‹⟦ψ g i = i ⟹ PROP ?Q; ψ g i = i⟧ ⟹ PROP ?Q›*))
(*goal: ‹(δ⇧⋆) i ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) i w)›*)
using H1_1[where s'1 = i and g1 = "g"] (*‹⟦i ∈ S; ?w'1 ∈ A⇧⋆; g ∈ carrier G; (φ⇧⋆) g ?w'1 ∈ A⇧⋆ ∧ ψ g i ∈ S⟧ ⟹ (δ⇧⋆) (ψ g i) ((φ⇧⋆) g ?w'1) = ψ g ((δ⇧⋆) i ?w'1)›*) apply (metis A1_1 (*‹g ∈ carrier G›*) A2_0 (*‹∀x∈set w. x ∈ A›*) action_on_input (*‹⟦?g ∈ carrier G; ?w ∈ A⇧⋆⟧ ⟹ ψ ?g ((δ⇧⋆) i ?w) = (δ⇧⋆) i ((φ⇧⋆) ?g ?w)›*) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*))
(*top goal: ‹ψ g i = i ⟹ (δ⇧⋆) i ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) i w)› and 1 goal remains*)
using init_is_eq_var.eq_var_subset_axioms (*‹eq_var_subset G S ψ {i}›*) init_is_eq_var.is_equivar (*‹∀g∈carrier G. ψ g ` {i} = {i}›*) by (simp add: A1_1 (*‹g ∈ carrier G›*))
qed
have H1_3: "∃w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s"
using A1_0 (*‹s ∈ S›*) is_reachable (*‹?s ∈ S ⟹ ∃input∈A⇧⋆. (δ⇧⋆) i input = ?s›*) by auto
have H1_4: "∃w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s"
using A1_2 (*‹ψ g s ∈ S›*) induced_epi_wd1 (*‹(?s::'states) ∈ (S::'states set) ⟹ ∃w::'alpha list. w ∈ (A::'alpha set)⇧⋆ ∧ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = ?s›*) by auto
have H1_5: "[(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N = [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N"
proof (rule subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*); clarify)
(*goals:
1. ‹⋀x. x ∈ [(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N ⟹ x ∈ [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N›
2. ‹⋀x. x ∈ [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N ⟹ x ∈ [(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N›*)
fix w'
assume A2_0: "w' ∈ [(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N" (*‹(w'::'alpha list) ∈ [((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) (g::'grp) (SOME w::'alpha list. w ∈ (A::'alpha set)⇧⋆ ∧ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = (s::'states))]⇩M⇩N›*)
have H2_0: "⋀w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s ⟹ w' ∈ [(φ⇧⋆) g w]⇩M⇩N"
using A2_0 (*‹w' ∈ [(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N›*) H1_3 (*‹∃w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s›*) H1_2 (*‹{w ∈ A⇧⋆. (δ⇧⋆) i w = ψ g s} = {w'. ∃w∈A⇧⋆. (φ⇧⋆) g w = w' ∧ (δ⇧⋆) i w = s}›*) H1_4 (*‹∃w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s›*) induced_epi_wd2 (*‹⟦?w ∈ A⇧⋆; ?w' ∈ A⇧⋆; (δ⇧⋆) i ?w = (δ⇧⋆) i ?w'⟧ ⟹ [?w]⇩M⇩N = [?w']⇩M⇩N›*) mem_Collect_eq (*‹((?a::?'a) ∈ Collect (?P::?'a ⇒ bool)) = ?P ?a›*) tfl_some (*‹∀P x. P x ⟶ P (Eps P)›*) by (smt (verit, best))
obtain w'' where H2_w'': "w' ∈ [(φ⇧⋆) g w'']⇩M⇩N ∧ w'' ∈ A⇧⋆ ∧ (δ⇧⋆) i w'' = s"
(*goal: ‹(⋀w''::'alpha list. (w'::'alpha list) ∈ [((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) (g::'grp) w'']⇩M⇩N ∧ w'' ∈ (A::'alpha set)⇧⋆ ∧ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w'' = (s::'states) ⟹ thesis::bool) ⟹ thesis›*)
using A2_0 (*‹(w'::'alpha list) ∈ [((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) (g::'grp) (SOME w::'alpha list. w ∈ (A::'alpha set)⇧⋆ ∧ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = (s::'states))]⇩M⇩N›*) H1_3 (*‹∃w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s›*) tfl_some (*‹∀P x. P x ⟶ P (Eps P)›*) by (metis (mono_tags, lifting))
from H1_2 (*‹{w::'alpha list ∈ (A::'alpha set)⇧⋆. ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = (ψ::'grp ⇒ 'states ⇒ 'states) (g::'grp) (s::'states)} = {w'::'alpha list. ∃w::'alpha list∈A⇧⋆. ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) g w = w' ∧ (δ⇧⋆) i w = s}›*) H2_w'' (*‹w' ∈ [(φ⇧⋆) g w'']⇩M⇩N ∧ w'' ∈ A⇧⋆ ∧ (δ⇧⋆) i w'' = s›*) have H2_1: "(δ⇧⋆) i ((φ⇧⋆) g w'') = ψ g s"
by blast
have H2_2: "⋀w. w ∈ A⇧⋆ ⟹ (δ⇧⋆) i w = ψ g s ⟹ w' ∈ [w]⇩M⇩N"
proof (-)
(*goal: ‹⋀w. ⟦w ∈ A⇧⋆; (δ⇧⋆) i w = ψ g s⟧ ⟹ w' ∈ [w]⇩M⇩N›*)
fix w''
assume A3_0: "w'' ∈ A⇧⋆" and A3_1: "(δ⇧⋆) i w'' = ψ g s" (*‹(w''::'alpha list) ∈ (A::'alpha set)⇧⋆› ‹((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w''::'alpha list) = (ψ::'grp ⇒ 'states ⇒ 'states) (g::'grp) (s::'states)›*)
have H3_0: "(inv ⇘G⇙g) ∈ carrier G"
by (metis A1_1 (*‹g ∈ carrier G›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group_hom.axioms( (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) 1) states_a_G_set.group_hom (*‹group_hom G (BijGroup S) ψ›*))
from A3_0 (*‹w'' ∈ A⇧⋆›*) H3_0 (*‹inv⇘G⇙ g ∈ carrier G›*) have H3_1: "(φ⇧⋆) (inv ⇘G⇙ g) w'' ∈ A⇧⋆"
by (metis alt_grp_act.axioms (*‹alt_grp_act (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) ⟹ group_action ?G ?X ?φ›*) group_action.element_image (*‹⟦group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c set) (?φ::?'a ⇒ ?'c ⇒ ?'c); (?g::?'a) ∈ carrier ?G; (?x::?'c) ∈ ?E; ?φ ?g ?x = (?y::?'c)⟧ ⟹ ?y ∈ ?E›*) labels_a_G_set.lists_a_Gset (*‹alt_grp_act (G::('grp, 'b) monoid_scheme) ((A::'alpha set)⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆)›*))
have H3_2: "⋀g w. g ∈ carrier G ⟹ w ∈ A⇧⋆ ⟹ (δ⇧⋆) i ((φ⇧⋆) g w) = (δ⇧⋆) (ψ g i) ((φ⇧⋆) g w)"
using init_is_eq_var.eq_var_subset_axioms (*‹eq_var_subset G S ψ {i}›*) init_is_eq_var.is_equivar (*‹∀g∈carrier G. ψ g ` {i} = {i}›*) by auto
have H3_3: "⋀g w. g ∈ carrier G ⟹ w ∈ A⇧⋆ ⟹ (δ⇧⋆) (ψ g i) ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) i w)"
apply (rule H1_1[where s'1 = i] (*‹⟦(i::'states) ∈ (S::'states set); (?w'1::'alpha list) ∈ (A::'alpha set)⇧⋆; (?g1::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) ?g1 ?w'1 ∈ A⇧⋆ ∧ (ψ::'grp ⇒ 'states ⇒ 'states) ?g1 i ∈ S⟧ ⟹ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (ψ ?g1 i) ((φ⇧⋆) ?g1 ?w'1) = ψ ?g1 ((δ⇧⋆) i ?w'1)›*))
(*goal: ‹⋀(g::'grp) w::'alpha list. ⟦g ∈ carrier (G::('grp, 'b) monoid_scheme); w ∈ (A::'alpha set)⇧⋆⟧ ⟹ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) ((ψ::'grp ⇒ 'states ⇒ 'states) g (i::'states)) (((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) g w) = ψ g ((δ⇧⋆) i w)›*)
apply ((simp add: A3_1 (*‹(δ⇧⋆) i w'' = ψ g s›*) in_lists_conv_set (*‹(?xs ∈ ?A⇧⋆) = (∀x∈set ?xs. x ∈ ?A)›*) H2_1 (*‹(δ⇧⋆) i ((φ⇧⋆) g w''__) = ψ g s›*) is_aut.init_state_is_a_state (*‹i ∈ S›*))+)
(*top goal: ‹⋀g w. ⟦g ∈ carrier G; w ∈ A⇧⋆⟧ ⟹ i ∈ S› and 3 goals remain*)
using is_aut.init_state_is_a_state (*‹i ∈ S›*) labels_a_G_set.element_image (*‹⟦(?g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme); (?x::'alpha::type) ∈ (A::'alpha::type set); (φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type) ?g ?x = (?y::'alpha::type)⟧ ⟹ ?y ∈ A›*) states_a_G_set.element_image (*‹⟦?g ∈ carrier G; ?x ∈ S; ψ ?g ?x = ?y⟧ ⟹ ?y ∈ S›*) by blast
have H3_4: "s = (δ⇧⋆) i ((φ⇧⋆) (inv ⇘G⇙ g) w'')"
using A3_0 (*‹w'' ∈ A⇧⋆›*) A3_1 (*‹((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w''::'alpha list) = (ψ::'grp ⇒ 'states ⇒ 'states) (g::'grp) (s::'states)›*) H3_0 (*‹inv⇘G⇙ g ∈ carrier G›*) H3_2 (*‹⟦?g1 ∈ carrier G; ?w1 ∈ A⇧⋆⟧ ⟹ (δ⇧⋆) i ((φ⇧⋆) ?g1 ?w1) = (δ⇧⋆) (ψ ?g1 i) ((φ⇧⋆) ?g1 ?w1)›*) H3_3 (*‹⟦?g1 ∈ carrier G; ?w1 ∈ A⇧⋆⟧ ⟹ (δ⇧⋆) (ψ ?g1 i) ((φ⇧⋆) ?g1 ?w1) = ψ ?g1 ((δ⇧⋆) i ?w1)›*) A1_0 (*‹s ∈ S›*) A1_1 (*‹g ∈ carrier G›*) states_a_G_set.orbit_sym_aux (*‹⟦(?g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); (?x::'states) ∈ (S::'states set); (ψ::'grp ⇒ 'states ⇒ 'states) ?g ?x = (?y::'states)⟧ ⟹ ψ (inv⇘G⇙ ?g) ?y = ?x›*) by auto
from H3_4 (*‹s = (δ⇧⋆) i ((φ⇧⋆) (inv⇘G⇙ g) w'')›*) show " w' ∈ [w'']⇩M⇩N"
by (metis (mono_tags, lifting) A1_1 (*‹g ∈ carrier G›*) G_set_equiv (*‹alt_grp_act ?G ?A ?φ ⟹ eq_var_subset ?G ?A ?φ ?A›*) H2_1 (*‹(δ⇧⋆) i ((φ⇧⋆) g w''__) = ψ g s›*) H2_w'' (*‹w' ∈ [(φ⇧⋆) g w''__]⇩M⇩N ∧ w''__ ∈ A⇧⋆ ∧ (δ⇧⋆) i w''__ = s›*) ‹(δ⇧⋆) i w'' = ψ g s› A3_0 (*‹w'' ∈ A⇧⋆›*) eq_var_subset.is_equivar (*‹eq_var_subset ?G ?X ?φ ?Y ⟹ ∀g∈carrier ?G. ?φ g ` ?Y = ?Y›*) image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*) induced_epi_wd2 (*‹⟦?w ∈ A⇧⋆; ?w' ∈ A⇧⋆; (δ⇧⋆) i ?w = (δ⇧⋆) i ?w'⟧ ⟹ [?w]⇩M⇩N = [?w']⇩M⇩N›*) labels_a_G_set.lists_a_Gset (*‹alt_grp_act G (A⇧⋆) (φ⇧⋆)›*))
qed
from H2_2 (*‹⟦(?w1::'alpha list) ∈ (A::'alpha set)⇧⋆; ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) ?w1 = (ψ::'grp ⇒ 'states ⇒ 'states) (g::'grp) (s::'states)⟧ ⟹ (w'::'alpha list) ∈ [?w1]⇩M⇩N›*) show "w' ∈ [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N"
by (smt (verit) H1_4 (*‹∃w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s›*) some_eq_ex (*‹?P (SOME x. ?P x) = (∃x. ?P x)›*))
next
(*goal: ‹⋀x. x ∈ [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N ⟹ x ∈ [(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N›*)
fix w'
assume A2_0: "w' ∈ [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N" (*‹(w'::'alpha list) ∈ [SOME w::'alpha list. w ∈ (A::'alpha set)⇧⋆ ∧ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = (ψ::'grp ⇒ 'states ⇒ 'states) (g::'grp) (s::'states)]⇩M⇩N›*)
obtain w'' where H2_w'': "w' ∈ [(φ⇧⋆) g w'']⇩M⇩N ∧ w'' ∈ A⇧⋆ ∧ (δ⇧⋆) i w'' = s"
(*goal: ‹(⋀w''::'alpha list. (w'::'alpha list) ∈ [((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) (g::'grp) w'']⇩M⇩N ∧ w'' ∈ (A::'alpha set)⇧⋆ ∧ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w'' = (s::'states) ⟹ thesis::bool) ⟹ thesis›*)
using A2_0 (*‹(w'::'alpha list) ∈ [SOME w::'alpha list. w ∈ (A::'alpha set)⇧⋆ ∧ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = (ψ::'grp ⇒ 'states ⇒ 'states) (g::'grp) (s::'states)]⇩M⇩N›*) H1_3 (*‹∃w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s›*) tfl_some (*‹∀P x. P x ⟶ P (Eps P)›*) by (smt (verit) H1_2 (*‹{w ∈ A⇧⋆. (δ⇧⋆) i w = ψ g s} = {w'. ∃w∈A⇧⋆. (φ⇧⋆) g w = w' ∧ (δ⇧⋆) i w = s}›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*))
from H1_2 (*‹{w ∈ A⇧⋆. (δ⇧⋆) i w = ψ g s} = {w'. ∃w∈A⇧⋆. (φ⇧⋆) g w = w' ∧ (δ⇧⋆) i w = s}›*) H2_w'' (*‹w' ∈ [(φ⇧⋆) g w'']⇩M⇩N ∧ w'' ∈ A⇧⋆ ∧ (δ⇧⋆) i w'' = s›*) have H2_0: "(δ⇧⋆) i ((φ⇧⋆) g w'') = ψ g s"
by blast
have H2_1: "⋀w. w ∈ A⇧⋆ ⟹ (δ⇧⋆) i w = s ⟹ w' ∈ [(φ⇧⋆) g w]⇩M⇩N"
proof (-)
(*goal: ‹⋀w. ⟦w ∈ A⇧⋆; (δ⇧⋆) i w = s⟧ ⟹ w' ∈ [(φ⇧⋆) g w]⇩M⇩N›*)
fix w''
assume A3_0: "w'' ∈ A⇧⋆" and A3_1: "(δ⇧⋆) i w'' = s" (*‹(w''::'alpha list) ∈ (A::'alpha set)⇧⋆› ‹((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (w''::'alpha list) = (s::'states)›*)
have H3_0: "(inv ⇘G⇙g) ∈ carrier G"
by (metis A1_1 (*‹g ∈ carrier G›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group_hom.axioms( (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) 1) states_a_G_set.group_hom (*‹group_hom G (BijGroup S) ψ›*))
have H3_1: "(φ⇧⋆) (inv ⇘G⇙ g) w'' ∈ A⇧⋆"
using A3_0 (*‹w'' ∈ A⇧⋆›*) H3_0 (*‹inv⇘G⇙ g ∈ carrier G›*) by (metis alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) group_action.element_image (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?y ∈ ?E›*) labels_a_G_set.lists_a_Gset (*‹alt_grp_act G (A⇧⋆) (φ⇧⋆)›*))
have H3_2: "⋀g w. g ∈ carrier G ⟹ w ∈ A⇧⋆ ⟹ (δ⇧⋆) i ((φ⇧⋆) g w) =
(δ⇧⋆) (ψ g i) ((φ⇧⋆) g w)"
using init_is_eq_var.eq_var_subset_axioms (*‹eq_var_subset G S ψ {i}›*) init_is_eq_var.is_equivar (*‹∀g∈carrier G. ψ g ` {i} = {i}›*) by auto
have H3_3: "⋀g w. g ∈ carrier G ⟹ w ∈ A⇧⋆ ⟹ (δ⇧⋆) (ψ g i) ((φ⇧⋆) g w) =
ψ g ((δ⇧⋆) i w)"
apply (rule H1_1[where s'1 = i] (*‹⟦i ∈ S; ?w'1 ∈ A⇧⋆; ?g1 ∈ carrier G; (φ⇧⋆) ?g1 ?w'1 ∈ A⇧⋆ ∧ ψ ?g1 i ∈ S⟧ ⟹ (δ⇧⋆) (ψ ?g1 i) ((φ⇧⋆) ?g1 ?w'1) = ψ ?g1 ((δ⇧⋆) i ?w'1)›*))
(*goal: ‹⋀g w. ⟦g ∈ carrier G; w ∈ A⇧⋆⟧ ⟹ (δ⇧⋆) (ψ g i) ((φ⇧⋆) g w) = ψ g ((δ⇧⋆) i w)›*)
apply ((simp add: A3_1 (*‹(δ⇧⋆) i w'' = s›*) in_lists_conv_set (*‹(?xs ∈ ?A⇧⋆) = (∀x∈set ?xs. x ∈ ?A)›*) H2_0 (*‹(δ⇧⋆) i ((φ⇧⋆) g w''__) = ψ g s›*) is_aut.init_state_is_a_state (*‹i ∈ S›*))+)
(*top goal: ‹⋀(g::'grp) w::'alpha list. ⟦g ∈ carrier (G::('grp, 'b) monoid_scheme); w ∈ (A::'alpha set)⇧⋆⟧ ⟹ (i::'states) ∈ (S::'states set)› and 3 goals remain*)
using is_aut.init_state_is_a_state (*‹(i::'states::type) ∈ (S::'states::type set)›*) labels_a_G_set.element_image (*‹⟦?g ∈ carrier G; ?x ∈ A; φ ?g ?x = ?y⟧ ⟹ ?y ∈ A›*) states_a_G_set.element_image (*‹⟦(?g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); (?x::'states) ∈ (S::'states set); (ψ::'grp ⇒ 'states ⇒ 'states) ?g ?x = (?y::'states)⟧ ⟹ ?y ∈ S›*) by blast
have H3_4: "ψ (inv ⇘G⇙ g) s = (δ⇧⋆) i ((φ⇧⋆) (inv ⇘G⇙ g) w'')"
using A3_0 (*‹w'' ∈ A⇧⋆›*) A3_1 (*‹(δ⇧⋆) i w'' = s›*) H3_0 (*‹inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp::type) ∈ carrier G›*) H3_2 (*‹⟦?g1 ∈ carrier G; ?w1 ∈ A⇧⋆⟧ ⟹ (δ⇧⋆) i ((φ⇧⋆) ?g1 ?w1) = (δ⇧⋆) (ψ ?g1 i) ((φ⇧⋆) ?g1 ?w1)›*) H3_3 (*‹⟦?g1 ∈ carrier G; ?w1 ∈ A⇧⋆⟧ ⟹ (δ⇧⋆) (ψ ?g1 i) ((φ⇧⋆) ?g1 ?w1) = ψ ?g1 ((δ⇧⋆) i ?w1)›*) by auto
show "w' ∈ [(φ⇧⋆) g w'']⇩M⇩N "
using H3_4 (*‹ψ (inv⇘G⇙ g) s = (δ⇧⋆) i ((φ⇧⋆) (inv⇘G⇙ g) w'')›*) H3_1 (*‹((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) (inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp)) (w''::'alpha list) ∈ (A::'alpha set)⇧⋆›*) by (smt (verit, del_insts) A1_1 (*‹g ∈ carrier G›*) A3_0 (*‹w'' ∈ A⇧⋆›*) A3_1 (*‹(δ⇧⋆) i w'' = s›*) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) H3_2 (*‹⟦?g1 ∈ carrier G; ?w1 ∈ A⇧⋆⟧ ⟹ (δ⇧⋆) i ((φ⇧⋆) ?g1 ?w1) = (δ⇧⋆) (ψ ?g1 i) ((φ⇧⋆) ?g1 ?w1)›*) H3_3 (*‹⟦?g1 ∈ carrier G; ?w1 ∈ A⇧⋆⟧ ⟹ (δ⇧⋆) (ψ ?g1 i) ((φ⇧⋆) ?g1 ?w1) = ψ ?g1 ((δ⇧⋆) i ?w1)›*) ‹⋀thesis. (⋀w''. w' ∈ [(φ⇧⋆) g w'']⇩M⇩N ∧ w'' ∈ A⇧⋆ ∧
(δ⇧⋆) i w'' = s ⟹ thesis) ⟹ thesis› alt_group_act_is_grp_act (*‹alt_grp_act = group_action›*) group_action.surj_prop (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G⟧ ⟹ ?φ ?g ` ?E = ?E›*) image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*) induced_epi_wd2 (*‹⟦?w ∈ A⇧⋆; ?w' ∈ A⇧⋆; (δ⇧⋆) i ?w = (δ⇧⋆) i ?w'⟧ ⟹ [?w]⇩M⇩N = [?w']⇩M⇩N›*) labels_a_G_set.lists_a_Gset (*‹alt_grp_act G (A⇧⋆) (φ⇧⋆)›*))
qed
show "w' ∈ [(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N"
using H2_1 (*‹⟦?w1 ∈ A⇧⋆; (δ⇧⋆) i ?w1 = s⟧ ⟹ w' ∈ [(φ⇧⋆) g ?w1]⇩M⇩N›*) H1_3 (*‹∃w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s›*) by (metis (mono_tags, lifting) someI (*‹(?P::?'a ⇒ bool) (?x::?'a) ⟹ ?P (Eps ?P)›*))
qed
show "words_to_syth_states (states_to_words (ψ g s)) =
([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙) g (words_to_syth_states (states_to_words s))"
using H1_5 (*‹[(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N = [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N›*) apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: words_to_syth_states_def (*‹words_to_syth_states ?w = [?w]⇩M⇩N›*) states_to_words_def (*‹states_to_words = (λs∈S. SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)›*))
(*goal: ‹words_to_syth_states (states_to_words (ψ g s)) = trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g (words_to_syth_states (states_to_words s))›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); clarify; rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹[(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N = [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N ⟹ (s ∈ S ⟶ (ψ g s ∈ S ⟶ [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N = trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s]⇩M⇩N) ∧ (ψ g s ∉ S ⟶ [undefined]⇩M⇩N = trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s]⇩M⇩N)) ∧ (s ∉ S ⟶ (ψ g s ∈ S ⟶ [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N = trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g [undefined]⇩M⇩N) ∧ (ψ g s ∉ S ⟶ [undefined]⇩M⇩N = trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g [undefined]⇩M⇩N))›*)
using H1_0 (*‹trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g (words_to_syth_states (states_to_words s)) = [(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N›*) apply ((auto del: subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: words_to_syth_states_def (*‹words_to_syth_states ?w = [?w]⇩M⇩N›*) states_to_words_def (*‹states_to_words = (λs∈S. SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)›*))[1])
(*top goal: ‹⟦[(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N = [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N; s ∈ S⟧ ⟹ ψ g s ∈ S ⟶ [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N = trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s]⇩M⇩N› and 3 goals remain*)
using A1_2 (*‹ψ g s ∈ S›*) apply blast
(*top goal: ‹⟦[(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N = [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N; s ∈ S⟧ ⟹ ψ g s ∉ S ⟶ [undefined]⇩M⇩N = trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s]⇩M⇩N› and 2 goals remain*)
using A1_0 (*‹s ∈ S›*) apply blast
(*top goal: ‹⟦[(φ⇧⋆) g (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)]⇩M⇩N = [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N; s ∉ S⟧ ⟹ ψ g s ∈ S ⟶ [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ψ g s]⇩M⇩N = trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g [undefined]⇩M⇩N› and 1 goal remains*)
using A1_0 (*‹s ∈ S›*) by blast
qed
show "?thesis"
(*goal: ‹eq_var_func G S ψ (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) induced_epi›*)
apply (clarsimp del: subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: eq_var_func_def (*‹eq_var_func ?G ?X ?φ ?Y ?ψ ?f ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*) eq_var_func_axioms_def (*‹eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀a g. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*))
(*goal: ‹eq_var_func (G::('grp, 'b) monoid_scheme) (S::'states::type set) (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) ((A::'alpha::type set)⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) ((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type)⇧⋆) ≡⇩M⇩N) induced_epi›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹alt_grp_act G S ψ ∧ alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) ∧ induced_epi ∈ S →⇩E A⇧⋆ // ≡⇩M⇩N ∧ (∀a. a ∈ S ⟶ (∀g. g ∈ carrier G ⟶ induced_epi (g ⊙⇘ψ⇙ a) = g ⊙⇘trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N⇙ induced_epi a))›*)
subgoal for
using states_a_G_set.alt_grp_act_axioms (*‹alt_grp_act G S ψ›*) by auto
apply (metis MN_rel_eq_var (*‹eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N›*) MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*) eq_var_rel.quot_act_is_grp_act (*‹⟦eq_var_rel ?G ?X ?φ ?R; equiv ?X ?R⟧ ⟹ alt_grp_act ?G (?X // ?R) (alt_grp_act.induced_quot_map ?G ?X ?φ ?R)›*))
(*top goal: ‹alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N)› and 2 goals remain*)
apply (clarsimp simp add: FuncSet.extensional_funcset_def (*‹(?S::?'a set) →⇩E (?T::?'b set) = (?S → ?T) ∩ extensional ?S›*) Pi_def (*‹Pi (?A::?'a set) (?B::?'a ⇒ ?'b set) = {f::?'a ⇒ ?'b. ∀x::?'a. x ∈ ?A ⟶ f x ∈ ?B x}›*))
(*top goal: ‹induced_epi ∈ S →⇩E A⇧⋆ // ≡⇩M⇩N› and 1 goal remains*)
apply (rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*top goal: ‹(∀x. x ∈ S ⟶ induced_epi x ∈ A⇧⋆ // ≡⇩M⇩N) ∧ induced_epi ∈ extensional S› and 1 goal remains*)
apply clarify
(*top goal: ‹∀x. x ∈ S ⟶ induced_epi x ∈ A⇧⋆ // ≡⇩M⇩N› and 2 goals remain*)
subgoal for s
using is_reachable[where s = s] (*‹s ∈ S ⟹ ∃input∈A⇧⋆. (δ⇧⋆) i input = s›*) apply (clarsimp simp add: induced_epi_def (*‹induced_epi = compose S words_to_syth_states states_to_words›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*) states_to_words_def (*‹states_to_words = (λs∈S. SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)›*) words_to_syth_states_def (*‹words_to_syth_states ?w = [?w]⇩M⇩N›*))
(*goal: ‹s ∈ S ⟹ induced_epi s ∈ A⇧⋆ // ≡⇩M⇩N›*)
by (smt (verit) ‹s ∈ S ⟹ ∃input∈A⇧⋆. (δ⇧⋆) i input = s› alt_natural_map_MN_def (*‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}›*) lists_eq_set (*‹?A⇧⋆ = {xs. set xs ⊆ ?A}›*) quotientI (*‹?x ∈ ?A ⟹ ?r `` {?x} ∈ ?A // ?r›*) rel_MN_def (*‹≡⇩M⇩N = {(w, w'). (w, w') ∈ A⇧⋆ × A⇧⋆ ∧ (∀v∈A⇧⋆. (w @ v ∈ L) = (w' @ v ∈ L))}›*) singleton_conv (*‹{x. x = ?a} = {?a}›*) someI (*‹?P ?x ⟹ ?P (Eps ?P)›*))
apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: induced_epi_def (*‹induced_epi = compose S words_to_syth_states states_to_words›*) make_op_def (*‹(⊙⇘?φ⇙) ≡ ?φ›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*))
(*top goal: ‹induced_epi ∈ extensional S› and 1 goal remains*)
apply clarify
(*goal: ‹∀a. a ∈ S ⟶ (∀g. g ∈ carrier G ⟶ induced_epi (g ⊙⇘ψ⇙ a) = g ⊙⇘trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N⇙ induced_epi a)›*)
apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ::?'grp ⇒ ?'X ⇒ ?'X⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹(?func::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆ = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) ((A::'alpha set)⇧⋆))› ‹states_a_G_set.induced_star_map (?func::'grp ⇒ 'states ⇒ 'states) = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) ((S::'states set)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map (?func::'grp ⇒ 'states × 'alpha ⇒ 'states × 'alpha) = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) (((S::'states set) × (A::'alpha set))⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map (?S::?'Y set) (?func::'grp ⇒ ?'Y ⇒ ?'Y) (?R::(?'Y × ?'Y) set) = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). λx::?'Y set∈?S // ?R. ?R `` {?func g (SOME z::?'Y. z ∈ x)})› ‹[?w::'alpha list]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N (?W'::'alpha list set) (?a'::'alpha) = (λ(W::'alpha list set, a::'alpha)∈(A::'alpha set)⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w::'alpha list. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: induced_epi_def (*‹induced_epi = compose (S::'states set) words_to_syth_states states_to_words›*) compose_def (*‹compose (?A::?'a set) (?g::?'b ⇒ ?'c) (?f::?'a ⇒ ?'b) = (λx::?'a∈?A. ?g (?f x))›*) make_op_def (*‹(⊙⇘?φ::?'grp ⇒ ?'X ⇒ ?'X⇙) ≡ ?φ›*))
(*goal: ‹⋀a g. ⟦a ∈ S; g ∈ carrier G⟧ ⟹ induced_epi (g ⊙⇘ψ⇙ a) = g ⊙⇘trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N⇙ induced_epi a›*)
apply (rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*); rule impI (*‹(?P::bool ⟹ ?Q::bool) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀a g. ⟦a ∈ S; g ∈ carrier G⟧ ⟹ (ψ g a ∈ S ⟶ words_to_syth_states (states_to_words (ψ g a)) = trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g (words_to_syth_states (states_to_words a))) ∧ (ψ g a ∉ S ⟶ undefined = trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g (words_to_syth_states (states_to_words a)))›*)
apply (simp add: H_0 (*‹⟦?s1 ∈ S; ?g1 ∈ carrier G; ψ ?g1 ?s1 ∈ S⟧ ⟹ words_to_syth_states (states_to_words (ψ ?g1 ?s1)) = trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N ?g1 (words_to_syth_states (states_to_words ?s1))›*))
(*top goal: ‹⋀(a::'states) g::'grp. ⟦a ∈ (S::'states set); g ∈ carrier (G::('grp, 'b) monoid_scheme); (ψ::'grp ⇒ 'states ⇒ 'states) g a ∈ S⟧ ⟹ words_to_syth_states (states_to_words (ψ g a)) = trans_is_eq_var.GA_0.induced_quot_map ((A::'alpha set)⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) ≡⇩M⇩N g (words_to_syth_states (states_to_words a))› and 1 goal remains*)
using states_a_G_set.element_image (*‹⟦?g ∈ carrier G; ?x ∈ S; ψ ?g ?x = ?y⟧ ⟹ ?y ∈ S›*) by blast
qed
text ‹
The following lemma corresponds to lemma 3.7 from \cite{bojanczyk2014automata}:
›
lemma reach_det_G_aut_rec_lang:
"G_aut_epi A S i F δ MN_equiv MN_init_state MN_fin_states δ⇩M⇩N G φ ψ ([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙) induced_epi"
proof (-)
(*goal: ‹G_aut_epi A S i F δ (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N G φ ψ (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) induced_epi›*)
have H_0: "⋀s. s ∈ MN_equiv ⟹ ∃input∈ A⇧⋆. (δ⇩M⇩N⇧⋆) MN_init_state input = s"
proof (-)
(*goal: ‹⋀s. s ∈ A⇧⋆ // ≡⇩M⇩N ⟹ ∃input∈A⇧⋆. (δ⇩M⇩N⇧⋆) MN_init_state input = s›*)
fix s
assume A_0: "s ∈ MN_equiv" (*‹(s::'alpha list set) ∈ (A::'alpha set)⇧⋆ // ≡⇩M⇩N›*)
from A_0 (*‹(s::'alpha list set) ∈ (A::'alpha set)⇧⋆ // ≡⇩M⇩N›*) have H_0: "∃w. w ∈ A⇧⋆ ∧ s = [w]⇩M⇩N"
by (auto simp add: quotient_def (*‹(?A::?'a set) // (?r::(?'a × ?'a) set) = (⋃x::?'a∈?A. {?r `` {x}})›*))
show "∃input∈A⇧⋆. (δ⇩M⇩N⇧⋆) MN_init_state input = s"
using H_0 (*‹∃w::'alpha list. w ∈ (A::'alpha set)⇧⋆ ∧ (s::'alpha list set) = [w]⇩M⇩N›*) by (metis MN_unique_init_state (*‹?w ∈ A⇧⋆ ⟹ [?w]⇩M⇩N = (δ⇩M⇩N⇧⋆) MN_init_state ?w›*))
qed
have H_1: "⋀s₀ a. s₀ ∈ S ⟹ a ∈ A ⟹ induced_epi (δ s₀ a) = δ⇩M⇩N (induced_epi s₀) a"
proof (-)
(*goal: ‹⋀s₀ a. ⟦s₀ ∈ S; a ∈ A⟧ ⟹ induced_epi (δ s₀ a) = δ⇩M⇩N (induced_epi s₀) a›*)
fix s₀ and a
assume A1_0: "s₀ ∈ S" and A1_1: "a ∈ A" (*‹(s₀::'states) ∈ (S::'states set)› ‹(a::'alpha) ∈ (A::'alpha set)›*)
obtain w where H1_w: "w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s₀"
(*goal: ‹(⋀w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s₀ ⟹ thesis) ⟹ thesis›*)
using A1_0 (*‹s₀ ∈ S›*) induced_epi_wd1 (*‹?s ∈ S ⟹ ∃w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ?s›*) by auto
have H1_0: "[SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s₀]⇩M⇩N = [w]⇩M⇩N"
by (metis (mono_tags, lifting) H1_w (*‹(w::'alpha list) ∈ (A::'alpha set)⇧⋆ ∧ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = (s₀::'states)›*) induced_epi_wd2 (*‹⟦(?w::'alpha list) ∈ (A::'alpha set)⇧⋆; (?w'::'alpha list) ∈ A⇧⋆; ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) ?w = (δ⇧⋆) i ?w'⟧ ⟹ [?w]⇩M⇩N = [?w']⇩M⇩N›*) some_eq_imp (*‹⟦Eps (?P::?'a ⇒ bool) = (?a::?'a); ?P (?b::?'a)⟧ ⟹ ?P ?a›*))
have H1_1: "(δ⇧⋆) i (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = δ s₀ a) = (δ⇧⋆) i (w @ [a])"
using A1_0 (*‹s₀ ∈ S›*) A1_1 (*‹a ∈ A›*) H1_w (*‹w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s₀›*) is_aut.trans_to_charact[where s = s₀ and a = a and w = w] (*‹⟦(s₀::'states) ∈ (S::'states set); (a::'alpha) ∈ (A::'alpha set); (w::'alpha list) ∈ A⇧⋆; s₀ = ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (?i::'states) w⟧ ⟹ (δ⇧⋆) ?i (w @ [a]) = δ s₀ a›*) by (smt (verit, del_insts) induced_epi_wd1 (*‹?s ∈ S ⟹ ∃w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ?s›*) is_aut.trans_func_well_def (*‹⟦?state ∈ S; ?label ∈ A⟧ ⟹ δ ?state ?label ∈ S›*) tfl_some (*‹∀P x. P x ⟶ P (Eps P)›*))
have H1_2: "w @ [a] ∈ A⇧⋆"
using H1_w (*‹w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s₀›*) A1_1 (*‹a ∈ A›*) by auto
have H1_3: "[(SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s₀) @ [a]]⇩M⇩N = [w @ [a]]⇩M⇩N"
by (metis (mono_tags, lifting) A1_1 (*‹a ∈ A›*) H1_0 (*‹[SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s₀]⇩M⇩N = [w]⇩M⇩N›*) H1_w (*‹w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s₀›*) MN_trans_func_characterization (*‹⟦?v ∈ A⇧⋆; ?a ∈ A⟧ ⟹ δ⇩M⇩N [?v]⇩M⇩N ?a = [?v @ [?a]]⇩M⇩N›*) someI (*‹?P ?x ⟹ ?P (Eps ?P)›*))
have H1_4: "... = [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = δ s₀ a]⇩M⇩N"
apply (rule sym (*‹?s = ?t ⟹ ?t = ?s›*))
(*goal: ‹[w @ [a]]⇩M⇩N = [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = δ s₀ a]⇩M⇩N›*)
apply (rule induced_epi_wd2[where w = "SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = δ s₀ a" and w'= "w @ [a]"] (*‹⟦(SOME w::'alpha list. w ∈ (A::'alpha set)⇧⋆ ∧ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = δ (s₀::'states) (a::'alpha)) ∈ A⇧⋆; (w::'alpha list) @ [a] ∈ A⇧⋆; (δ⇧⋆) i (SOME w::'alpha list. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = δ s₀ a) = (δ⇧⋆) i (w @ [a])⟧ ⟹ [SOME w::'alpha list. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = δ s₀ a]⇩M⇩N = [w @ [a]]⇩M⇩N›*))
(*goal: ‹[SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = δ s₀ a]⇩M⇩N = [w @ [a]]⇩M⇩N›*)
apply (metis (mono_tags, lifting) A1_0 (*‹(s₀::'states) ∈ (S::'states set)›*) A1_1 (*‹(a::'alpha) ∈ (A::'alpha set)›*) H1_w (*‹(w::'alpha list) ∈ (A::'alpha set)⇧⋆ ∧ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = (s₀::'states)›*) some_eq_imp (*‹⟦Eps (?P::?'a ⇒ bool) = (?a::?'a); ?P (?b::?'a)⟧ ⟹ ?P ?a›*) H1_2 (*‹(w::'alpha list) @ [a::'alpha] ∈ (A::'alpha set)⇧⋆›*) is_aut.trans_to_charact (*‹⟦(?s::'states) ∈ (S::'states set); (?a::'alpha) ∈ (A::'alpha set); (?w::'alpha list) ∈ A⇧⋆; ?s = ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (?i::'states) ?w⟧ ⟹ (δ⇧⋆) ?i (?w @ [?a]) = δ ?s ?a›*))
(*top goal: ‹(SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = δ s₀ a) ∈ A⇧⋆› and 2 goals remain*)
apply (rule H1_2 (*‹w @ [a] ∈ A⇧⋆›*))
(*top goal: ‹w @ [a] ∈ A⇧⋆› and 1 goal remains*)
using H1_1 (*‹((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (SOME w::'alpha list. w ∈ (A::'alpha set)⇧⋆ ∧ (δ⇧⋆) i w = δ (s₀::'states) (a::'alpha)) = (δ⇧⋆) i ((w::'alpha list) @ [a])›*) by simp
show "induced_epi (δ s₀ a) = δ⇩M⇩N (induced_epi s₀) a"
apply (clarsimp del: subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: induced_epi_def (*‹induced_epi = compose S words_to_syth_states states_to_words›*) words_to_syth_states_def (*‹words_to_syth_states ?w = [?w]⇩M⇩N›*) states_to_words_def (*‹states_to_words = (λs∈S. SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*) is_aut.trans_func_well_def (*‹⟦?state ∈ S; ?label ∈ A⟧ ⟹ δ ?state ?label ∈ S›*))
(*goal: ‹induced_epi (δ s₀ a) = δ⇩M⇩N (induced_epi s₀) a›*)
using A1_1 (*‹(a::'alpha) ∈ (A::'alpha set)›*) H1_w (*‹w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s₀›*) H1_0 (*‹[SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s₀]⇩M⇩N = [w]⇩M⇩N›*) H1_3 (*‹[(SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s₀) @ [a]]⇩M⇩N = [w @ [a]]⇩M⇩N›*) H1_4 (*‹[w @ [a]]⇩M⇩N = [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = δ s₀ a]⇩M⇩N›*) MN_trans_func_characterization (*‹⟦?v ∈ A⇧⋆; ?a ∈ A⟧ ⟹ δ⇩M⇩N [?v]⇩M⇩N ?a = [?v @ [?a]]⇩M⇩N›*) A1_0 (*‹(s₀::'states) ∈ (S::'states set)›*) is_aut.trans_func_well_def (*‹⟦?state ∈ S; ?label ∈ A⟧ ⟹ δ ?state ?label ∈ S›*) by presburger
qed
have H_2: "induced_epi ` S = MN_equiv"
proof (-)
(*goal: ‹induced_epi ` S = A⇧⋆ // ≡⇩M⇩N›*)
have H1_0: "∀s ∈ S. ∃v∈ A⇧⋆. (δ⇧⋆) i v = s ∧ [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s]⇩M⇩N = [v]⇩M⇩N"
by (smt (verit) is_reachable (*‹?s ∈ S ⟹ ∃input∈A⇧⋆. (δ⇧⋆) i input = ?s›*) tfl_some (*‹∀P x. P x ⟶ P (Eps P)›*))
have H1_1: "⋀v. v∈ A⇧⋆ ⟹ (δ⇧⋆) i v ∈ S"
using is_aut.give_input_closed (*‹⟦?input ∈ A⇧⋆; ?s ∈ S⟧ ⟹ (δ⇧⋆) ?s ?input ∈ S›*) by (auto simp add: is_aut.init_state_is_a_state (*‹i ∈ S›*))
show "?thesis"
(*goal: ‹induced_epi ` S = A⇧⋆ // ≡⇩M⇩N›*)
apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: induced_epi_def (*‹induced_epi = compose S words_to_syth_states states_to_words›*) words_to_syth_states_def (*‹words_to_syth_states ?w = [?w]⇩M⇩N›*) states_to_words_def (*‹states_to_words = (λs∈S. SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*goal: ‹induced_epi ` S = A⇧⋆ // ≡⇩M⇩N›*)
using H1_0 (*‹∀s∈S. ∃v∈A⇧⋆. (δ⇧⋆) i v = s ∧ [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s]⇩M⇩N = [v]⇩M⇩N›*) H1_1 (*‹?v1 ∈ A⇧⋆ ⟹ (δ⇧⋆) i ?v1 ∈ S›*) apply clarsimp
(*goal: ‹{y. ∃x∈S. y = [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = x]⇩M⇩N} = A⇧⋆ // ≡⇩M⇩N›*)
apply (rule subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*))
(*goals:
1. ‹⟦∀s∈S. ∃v∈A⇧⋆. (δ⇧⋆) i v = s ∧ ≡⇩M⇩N `` {SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s} = ≡⇩M⇩N `` {v}; ⋀v. v ∈ A⇧⋆ ⟹ (δ⇧⋆) i v ∈ S⟧ ⟹ {y. ∃x∈S. y = ≡⇩M⇩N `` {SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = x}} ⊆ A⇧⋆ // ≡⇩M⇩N›
2. ‹⟦∀s∈S. ∃v∈A⇧⋆. (δ⇧⋆) i v = s ∧ ≡⇩M⇩N `` {SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s} = ≡⇩M⇩N `` {v}; ⋀v. v ∈ A⇧⋆ ⟹ (δ⇧⋆) i v ∈ S⟧ ⟹ A⇧⋆ // ≡⇩M⇩N ⊆ {y. ∃x∈S. y = ≡⇩M⇩N `` {SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = x}}›
discuss goal 1*)
apply (simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) add: Set.subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*))
(*top goal: ‹⟦∀s∈S. ∃v∈A⇧⋆. (δ⇧⋆) i v = s ∧ ≡⇩M⇩N `` {SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s} = ≡⇩M⇩N `` {v}; ⋀v. v ∈ A⇧⋆ ⟹ (δ⇧⋆) i v ∈ S⟧ ⟹ {y. ∃x∈S. y = ≡⇩M⇩N `` {SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = x}} ⊆ A⇧⋆ // ≡⇩M⇩N› and 1 goal remains*)
apply (metis (no_types, lifting) quotientI (*‹?x ∈ ?A ⟹ ?r `` {?x} ∈ ?A // ?r›*))
(*discuss goal 2*)
apply (simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) add: Set.subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*))
(*goal: ‹⟦∀s∈S. ∃v∈A⇧⋆. (δ⇧⋆) i v = s ∧ ≡⇩M⇩N `` {SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s} = ≡⇩M⇩N `` {v}; ⋀v. v ∈ A⇧⋆ ⟹ (δ⇧⋆) i v ∈ S⟧ ⟹ A⇧⋆ // ≡⇩M⇩N ⊆ {y. ∃x∈S. y = ≡⇩M⇩N `` {SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = x}}›*)
apply (metis (no_types, lifting) alt_natural_map_MN_def (*‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}›*) induced_epi_wd2 (*‹⟦?w ∈ A⇧⋆; ?w' ∈ A⇧⋆; (δ⇧⋆) i ?w = (δ⇧⋆) i ?w'⟧ ⟹ [?w]⇩M⇩N = [?w']⇩M⇩N›*) quotientE (*‹⟦?X ∈ ?A // ?r; ⋀x. ⟦?X = ?r `` {x}; x ∈ ?A⟧ ⟹ ?P⟧ ⟹ ?P›*))
(*proven 2 subgoals*) .
qed
show "?thesis"
(*goal: ‹G_aut_epi A S i F δ (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N G φ ψ (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) induced_epi›*)
apply (simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) add: G_aut_epi_def (*‹G_aut_epi ?A ?S₀ ?i₀ ?F₀ ?δ₀ ?S₁ ?i₁ ?F₁ ?δ₁ ?G ?φ ?ψ₀ ?ψ₁ ?f ≡ G_aut_hom ?A ?S₀ ?i₀ ?F₀ ?δ₀ ?S₁ ?i₁ ?F₁ ?δ₁ ?G ?φ ?ψ₀ ?ψ₁ ?f ∧ G_aut_epi_axioms ?S₀ ?S₁ ?f›*) G_aut_epi_axioms_def (*‹G_aut_epi_axioms ?S₀ ?S₁ ?f ≡ ?f ` ?S₀ = ?S₁›*))
(*goal: ‹G_aut_epi A S i F δ (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N G φ ψ (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) induced_epi›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹G_aut_hom A S i F δ (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N G φ ψ (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) induced_epi ∧ induced_epi ` S = A⇧⋆ // ≡⇩M⇩N›*)
subgoal for
apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: G_aut_hom_def (*‹G_aut_hom ?A ?S₀ ?i₀ ?F₀ ?δ₀ ?S₁ ?i₁ ?F₁ ?δ₁ ?G ?φ ?ψ₀ ?ψ₁ ?f ≡ (reach_det_G_aut ?A ?S₀ ?i₀ ?F₀ ?δ₀ ?G ?φ ?ψ₀ ∧ reach_det_G_aut ?A ?S₁ ?i₁ ?F₁ ?δ₁ ?G ?φ ?ψ₁) ∧ aut_hom ?A ?S₀ ?i₀ ?F₀ ?δ₀ ?S₁ ?i₁ ?F₁ ?δ₁ ?f ∧ eq_var_func ?G ?S₀ ?ψ₀ ?S₁ ?ψ₁ ?f›*) aut_hom_def (*‹aut_hom ?A ?S₀ ?i₀ ?F₀ ?δ₀ ?S₁ ?i₁ ?F₁ ?δ₁ ?f ≡ det_aut ?A ?S₀ ?i₀ ?F₀ ?δ₀ ∧ det_aut ?A ?S₁ ?i₁ ?F₁ ?δ₁ ∧ aut_hom_axioms ?A ?S₀ ?i₀ ?F₀ ?δ₀ ?S₁ ?i₁ ?F₁ ?δ₁ ?f›*) reach_det_G_aut_def (*‹reach_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ reach_det_aut ?A ?S ?i ?F ?δ›*) is_reachable (*‹?s ∈ S ⟹ ∃input∈A⇧⋆. (δ⇧⋆) i input = ?s›*) det_G_aut_def (*‹det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ (det_aut ?A ?S ?i ?F ?δ ∧ alt_grp_act ?G ?A ?φ ∧ alt_grp_act ?G ?S ?ψ) ∧ eq_var_subset ?G ?S ?ψ ?F ∧ eq_var_subset ?G ?S ?ψ {?i} ∧ eq_var_func ?G (?S × ?A) (λg∈carrier ?G. λ(s, a)∈?S × ?A. (?ψ g s, ?φ g a)) ?S ?ψ (λ(s, a)∈?S × ?A. ?δ s a)›*) reach_det_aut_def (*‹reach_det_aut ?A ?S ?i ?F ?δ ≡ det_aut ?A ?S ?i ?F ?δ ∧ reach_det_aut_axioms ?A ?S ?i ?δ›*) reach_det_aut_axioms_def (*‹reach_det_aut_axioms ?A ?S ?i ?δ ≡ ∀s. s ∈ ?S ⟶ (∃input∈?A⇧⋆. (?δ⇧⋆) ?i input = s)›*))
(*goal: ‹G_aut_hom A S i F δ (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N G φ ψ (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) induced_epi›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹det_aut A S i F δ ∧ alt_grp_act G A φ ∧ alt_grp_act G S ψ ∧ eq_var_subset G S ψ F ∧ eq_var_subset G S ψ {i} ∧ eq_var_func G (S × A) (λg∈carrier G. λ(s, a)∈S × A. (ψ g s, φ g a)) S ψ (λ(x, y)∈S × A. δ x y) ∧ det_aut A S i F δ ∧ det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N ∧ alt_grp_act G A φ ∧ alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) ∧ eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) MN_fin_states ∧ eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) {MN_init_state} ∧ eq_var_func G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(s, a)∈A⇧⋆ // ≡⇩M⇩N × A. (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g s, φ g a)) (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y) ∧ det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N ∧ (∀s. s ∈ A⇧⋆ // ≡⇩M⇩N ⟶ (∃input∈A⇧⋆. (δ⇩M⇩N⇧⋆) MN_init_state input = s)) ∧ det_aut A S i F δ ∧ det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N ∧ aut_hom_axioms A S i F δ (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N induced_epi ∧ eq_var_func G S ψ (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) induced_epi›*)
apply (simp add: is_aut.det_aut_axioms (*‹det_aut A S i F δ›*))
(*top goal: ‹det_aut A S i F δ› and 18 goals remain*)
using labels_a_G_set.alt_grp_act_axioms (*‹alt_grp_act G A φ›*) apply ((auto)[1])
(*top goal: ‹alt_grp_act G A φ› and 17 goals remain*)
using states_a_G_set.alt_grp_act_axioms (*‹alt_grp_act G S ψ›*) apply blast
(*top goal: ‹alt_grp_act G S ψ› and 16 goals remain*)
apply (simp add: accepting_is_eq_var.eq_var_subset_axioms (*‹eq_var_subset G S ψ F›*))
(*top goal: ‹eq_var_subset G S ψ F› and 15 goals remain*)
using init_is_eq_var.eq_var_subset_axioms (*‹eq_var_subset G S ψ {i}›*) apply ((auto)[1])
(*top goal: ‹eq_var_subset (G::('grp, 'b) monoid_scheme) (S::'states::type set) (ψ::'grp::type ⇒ 'states::type ⇒ 'states::type) {i::'states::type}› and 14 goals remain*)
apply (simp add: trans_is_eq_var.eq_var_func_axioms (*‹eq_var_func G (S × A) (λg∈carrier G. λ(s, a)∈S × A. (ψ g s, φ g a)) S ψ (λ(s, a)∈S × A. δ s a)›*))
(*top goal: ‹eq_var_func G (S × A) (λg∈carrier G. λ(s, a)∈S × A. (ψ g s, φ g a)) S ψ (λ(x, y)∈S × A. δ x y)› and 13 goals remain*)
apply (simp add: is_aut.det_aut_axioms (*‹det_aut A S i F δ›*))
(*top goal: ‹det_aut A S i F δ› and 12 goals remain*)
using syth_aut_is_det_aut (*‹det_aut (A::'alpha set) (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N›*) apply simp
(*top goal: ‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N› and 11 goals remain*)
using labels_a_G_set.alt_grp_act_axioms (*‹alt_grp_act G A φ›*) apply ((auto)[1])
(*top goal: ‹alt_grp_act G A φ› and 10 goals remain*)
apply (metis MN_rel_eq_var (*‹eq_var_rel G (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N›*) MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*) eq_var_rel.quot_act_is_grp_act (*‹⟦eq_var_rel ?G ?X ?φ ?R; equiv ?X ?R⟧ ⟹ alt_grp_act ?G (?X // ?R) (alt_grp_act.induced_quot_map ?G ?X ?φ ?R)›*))
(*top goal: ‹alt_grp_act G (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N)› and 9 goals remain*)
using MN_final_state_equiv (*‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) MN_fin_states›*) apply presburger
(*top goal: ‹eq_var_subset (G::('grp, 'b) monoid_scheme) ((A::'alpha set)⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) ≡⇩M⇩N) MN_fin_states› and 8 goals remain*)
using MN_init_state_equivar_v2 (*‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) {MN_init_state}›*) apply presburger
(*top goal: ‹eq_var_subset G (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) {MN_init_state}› and 7 goals remain*)
using MN_trans_eq_var_func (*‹eq_var_func G (A⇧⋆ // ≡⇩M⇩N × A) (λg∈carrier G. λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g W, φ g a)) (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) (λ(x, y)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y)›*) apply blast
(*top goal: ‹eq_var_func (G::('grp, 'b) monoid_scheme) ((A::'alpha set)⇧⋆ // ≡⇩M⇩N × A) (λg::'grp∈carrier G. λ(s::'alpha list set, a::'alpha)∈A⇧⋆ // ≡⇩M⇩N × A. (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) ((φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆) ≡⇩M⇩N g s, φ g a)) (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) (λ(x::'alpha list set, y::'alpha)∈A⇧⋆ // ≡⇩M⇩N × A. δ⇩M⇩N x y)› and 6 goals remain*)
using syth_aut_is_det_aut (*‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N›*) apply ((auto)[1])
(*top goal: ‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N› and 5 goals remain*)
apply clarify
(*top goal: ‹∀s::'alpha list set. s ∈ (A::'alpha set)⇧⋆ // ≡⇩M⇩N ⟶ (∃input::'alpha list∈A⇧⋆. (δ⇩M⇩N⇧⋆) MN_init_state input = s)› and 4 goals remain*)
apply (simp add: H_0 (*‹?s1 ∈ A⇧⋆ // ≡⇩M⇩N ⟹ ∃input∈A⇧⋆. (δ⇩M⇩N⇧⋆) MN_init_state input = ?s1›*) del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*))
(*top goal: ‹⋀s. s ∈ A⇧⋆ // ≡⇩M⇩N ⟹ ∃input∈A⇧⋆. (δ⇩M⇩N⇧⋆) MN_init_state input = s› and 4 goals remain*)
apply (simp add: is_aut.det_aut_axioms (*‹det_aut A S i F δ›*))
(*top goal: ‹det_aut A S i F δ› and 3 goals remain*)
using syth_aut_is_det_aut (*‹det_aut A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N›*) apply blast
(*top goal: ‹det_aut (A::'alpha set) (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N› and 2 goals remain*)
apply ((clarsimp del: subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: aut_hom_axioms_def (*‹aut_hom_axioms ?A ?S₀ ?i₀ ?F₀ ?δ₀ ?S₁ ?i₁ ?F₁ ?δ₁ ?f ≡ (?f ∈ ?S₀ →⇩E ?S₁ ∧ ?f ?i₀ = ?i₁) ∧ (∀s. (s ∈ ?F₀) = (?f s ∈ ?F₁ ∧ s ∈ ?S₀)) ∧ (∀s₀ a. s₀ ∈ ?S₀ ⟶ a ∈ ?A ⟶ ?f (?δ₀ s₀ a) = ?δ₁ (?f s₀) a)›*) FuncSet.extensional_funcset_def (*‹?S →⇩E ?T = (?S → ?T) ∩ extensional ?S›*) Pi_def (*‹Pi ?A ?B = {f. ∀x. x ∈ ?A ⟶ f x ∈ ?B x}›*) extensional_def (*‹extensional ?A = {f. ∀x. x ∉ ?A ⟶ f x = undefined}›*))[1])
(*top goal: ‹aut_hom_axioms A S i F δ (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N induced_epi› and 1 goal remains*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*top goal: ‹(∀x. x ∈ S ⟶ induced_epi x ∈ A⇧⋆ // ≡⇩M⇩N) ∧ (∀x. x ∉ S ⟶ induced_epi x = undefined) ∧ induced_epi i = MN_init_state ∧ (∀s. (s ∈ F) = ((∃w∈L. induced_epi s = [w]⇩M⇩N) ∧ s ∈ S)) ∧ (∀s₀. s₀ ∈ S ⟶ (∀a. a ∈ A ⟶ induced_epi (δ s₀ a) = δ⇩M⇩N (induced_epi s₀) a))› and 1 goal remains*)
apply clarify
(*top goal: ‹∀x::'states. x ∈ (S::'states set) ⟶ induced_epi x ∈ (A::'alpha set)⇧⋆ // ≡⇩M⇩N› and 5 goals remain*)
apply (simp add: induced_epi_def (*‹induced_epi = compose S words_to_syth_states states_to_words›*))
(*top goal: ‹⋀x::'states::type. x ∈ (S::'states::type set) ⟹ induced_epi x ∈ (A::'alpha::type set)⇧⋆ // ≡⇩M⇩N› and 5 goals remain*)
apply (simp add: induced_epi_def (*‹induced_epi = compose S words_to_syth_states states_to_words›*) words_to_syth_states_def (*‹words_to_syth_states ?w = [?w]⇩M⇩N›*) states_to_words_def (*‹states_to_words = (λs∈S. SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*))
(*top goal: ‹⋀x. x ∈ S ⟹ compose S words_to_syth_states states_to_words x ∈ A⇧⋆ // ≡⇩M⇩N› and 5 goals remain*)
apply (rule meta_mp[of "(δ⇧⋆) i Nil = i"] (*‹⟦((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) [] = i ⟹ PROP ?Q::prop; (δ⇧⋆) i [] = i⟧ ⟹ PROP ?Q›*))
(*top goal: ‹⋀x. x ∈ S ⟹ ≡⇩M⇩N `` {SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = x} ∈ A⇧⋆ // ≡⇩M⇩N› and 5 goals remain*)
using induced_epi_wd2[where w = "Nil"] (*‹⟦[] ∈ A⇧⋆; ?w' ∈ A⇧⋆; (δ⇧⋆) i [] = (δ⇧⋆) i ?w'⟧ ⟹ MN_init_state = [?w']⇩M⇩N›*) apply ((auto simp add: is_aut.init_state_is_a_state (*‹i ∈ S›*) del: subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*))[2])
(*top goal: ‹⋀x::'states::type. ⟦x ∈ (S::'states::type set); ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) [] = i⟧ ⟹ ≡⇩M⇩N `` {SOME w::'alpha::type list. w ∈ (A::'alpha::type set)⇧⋆ ∧ (δ⇧⋆) i w = x} ∈ A⇧⋆ // ≡⇩M⇩N› and 6 goals remain*)
subgoal for x
apply (rule quotientI (*‹?x ∈ ?A ⟹ ?r `` {?x} ∈ ?A // ?r›*))
(*goal: ‹⟦x ∈ S; ⋀w'. ⟦w' ∈ A⇧⋆; i = (δ⇧⋆) i w'⟧ ⟹ ≡⇩M⇩N `` {[]} = ≡⇩M⇩N `` {w'}⟧ ⟹ ≡⇩M⇩N `` {SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = x} ∈ A⇧⋆ // ≡⇩M⇩N›*)
using is_reachable[where s = x] (*‹(x::'states) ∈ (S::'states set) ⟹ ∃input::'alpha list∈(A::'alpha set)⇧⋆. ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) input = x›*) someI[where P = "λw. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = x"] (*‹?x ∈ A⇧⋆ ∧ (δ⇧⋆) i ?x = x ⟹ (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = x) ∈ A⇧⋆ ∧ (δ⇧⋆) i (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = x) = x›*) by blast
apply ((auto simp add: induced_epi_def (*‹induced_epi = compose S words_to_syth_states states_to_words›*) words_to_syth_states_def (*‹words_to_syth_states ?w = [?w]⇩M⇩N›*) states_to_words_def (*‹states_to_words = (λs∈S. SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*))[1])
(*top goal: ‹∀x. x ∉ S ⟶ induced_epi x = undefined› and 4 goals remain*)
apply (simp add: induced_epi_def (*‹induced_epi = compose S words_to_syth_states states_to_words›*) states_to_words_def (*‹states_to_words = (λs∈S. SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*) is_aut.init_state_is_a_state (*‹i ∈ S›*))
(*top goal: ‹induced_epi i = MN_init_state› and 3 goals remain*)
apply (metis (mono_tags, lifting) ‹⋀w'. ⟦[] ∈ A⇧⋆; w' ∈ A⇧⋆;
(δ⇧⋆) i [] = (δ⇧⋆) i w'⟧ ⟹ MN_init_state = [w']⇩M⇩N› alt_natural_map_MN_def (*‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}›*) give_input.simps( (*‹(?trans_func⇧⋆) ?s [] = ?s›*) 1) lists.Nil (*‹[] ∈ ?A⇧⋆›*) some_eq_imp (*‹⟦Eps ?P = ?a; ?P ?b⟧ ⟹ ?P ?a›*) words_to_syth_states_def (*‹words_to_syth_states ?w = [?w]⇩M⇩N›*))
(*top goal: ‹words_to_syth_states (SOME w::'alpha::type list. w ∈ (A::'alpha::type set)⇧⋆ ∧ ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) w = i) = ≡⇩M⇩N `` {[]}› and 3 goals remain*)
apply clarify
(*top goal: ‹∀s. (s ∈ F) = ((∃w∈L. induced_epi s = [w]⇩M⇩N) ∧ s ∈ S)› and 2 goals remain*)
subgoal for s
apply (rule iffI (*‹⟦?P::bool ⟹ ?Q::bool; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))
(*goal: ‹((s::'states) ∈ (F::'states set)) = ((∃w::'alpha list∈L::'alpha list set. induced_epi s = [w]⇩M⇩N) ∧ s ∈ (S::'states set))›*)
apply (smt (verit) Pi_iff (*‹(?f ∈ Pi ?I ?X) = (∀i∈?I. ?f i ∈ ?X i)›*) compose_eq (*‹?x ∈ ?A ⟹ compose ?A ?g ?f ?x = ?g (?f ?x)›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*) induced_epi_def (*‹induced_epi = compose S words_to_syth_states states_to_words›*) is_aut.fin_states_are_states (*‹F ⊆ S›*) states_to_words_on_final (*‹states_to_words ∈ F → L›*) words_to_syth_states_def (*‹words_to_syth_states ?w = [?w]⇩M⇩N›*))
(*top goal: ‹(s::'states::type) ∈ (F::'states::type set) ⟹ (∃w::'alpha::type list∈L::'alpha::type list set. induced_epi s = [w]⇩M⇩N) ∧ s ∈ (S::'states::type set)› and 1 goal remains*)
apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: induced_epi_def (*‹induced_epi = compose S words_to_syth_states states_to_words›*) words_to_syth_states_def (*‹words_to_syth_states ?w = [?w]⇩M⇩N›*) states_to_words_def (*‹states_to_words = (λs∈S. SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s)›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*))
(*goal: ‹(∃w∈L. induced_epi s = [w]⇩M⇩N) ∧ s ∈ S ⟹ s ∈ F›*)
apply (rule meta_mp[of "(SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s) ∈ L"] (*‹⟦(SOME w::'alpha list. w ∈ (A::'alpha set)⇧⋆ ∧ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) w = (s::'states)) ∈ (L::'alpha list set) ⟹ PROP ?Q::prop; (SOME w::'alpha list. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s) ∈ L⟧ ⟹ PROP ?Q›*))
(*goal: ‹⋀w::'alpha::type list. ⟦(s::'states::type) ∈ (S::'states::type set); w ∈ (L::'alpha::type list set); [SOME w::'alpha::type list. w ∈ (A::'alpha::type set)⇧⋆ ∧ ((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) w = s]⇩M⇩N = [w]⇩M⇩N⟧ ⟹ s ∈ (F::'states::type set)›*)
apply (smt (verit) induced_epi_wd1 (*‹?s ∈ S ⟹ ∃w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = ?s›*) is_recognised (*‹(?w ∈ L) = (?w ∈ A⇧⋆ ∧ (δ⇧⋆) i ?w ∈ F)›*) someI (*‹?P ?x ⟹ ?P (Eps ?P)›*))
(*top goal: ‹⋀w. ⟦s ∈ S; w ∈ L; [SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s]⇩M⇩N = [w]⇩M⇩N; (SOME w. w ∈ A⇧⋆ ∧ (δ⇧⋆) i w = s) ∈ L⟧ ⟹ s ∈ F› and 1 goal remains*)
using fin_states_rep_by_lang (*‹⟦?w ∈ A⇧⋆; [?w]⇩M⇩N ∈ MN_fin_states⟧ ⟹ ?w ∈ L›*) is_reachable (*‹?s ∈ S ⟹ ∃input∈A⇧⋆. (δ⇧⋆) i input = ?s›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) by (metis (mono_tags, lifting))
apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*))
(*top goal: ‹∀s₀. s₀ ∈ S ⟶ (∀a. a ∈ A ⟶ induced_epi (δ s₀ a) = δ⇩M⇩N (induced_epi s₀) a)› and 1 goal remains*)
apply (simp add: H_1 (*‹⟦?s₀1 ∈ S; ?a1 ∈ A⟧ ⟹ induced_epi (δ ?s₀1 ?a1) = δ⇩M⇩N (induced_epi ?s₀1) ?a1›*))
(*top goal: ‹⋀s₀ a. ⟦s₀ ∈ S; a ∈ A⟧ ⟹ induced_epi (δ s₀ a) = δ⇩M⇩N (induced_epi s₀) a› and 1 goal remains*)
using induced_epi_eq_var (*‹eq_var_func G S ψ (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) induced_epi›*) by blast
by (simp add: H_2 (*‹induced_epi ` S = A⇧⋆ // ≡⇩M⇩N›*))
qed
end
lemma (in det_G_aut) finite_reachable:
"finite (orbits G S ψ) ⟹ finite (orbits G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h)"
proof (-)
(*goal: ‹finite (orbits G S ψ) ⟹ finite (orbits G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h)›*)
assume A_0: "finite (orbits G S ψ)" (*‹finite (orbits (G::('grp, 'b) monoid_scheme) (S::'states set) (ψ::'grp ⇒ 'states ⇒ 'states))›*)
have H_0: "S⇩r⇩e⇩a⇩c⇩h ⊆ S"
apply (clarsimp simp add: reachable_states_def (*‹S⇩r⇩e⇩a⇩c⇩h = {s. ∃w∈A⇧⋆. (δ⇧⋆) i w = s}›*))
(*goal: ‹S⇩r⇩e⇩a⇩c⇩h ⊆ S›*)
by (simp add: in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) is_aut.give_input_closed (*‹⟦?input ∈ A⇧⋆; ?s ∈ S⟧ ⟹ (δ⇧⋆) ?s ?input ∈ S›*) is_aut.init_state_is_a_state (*‹i ∈ S›*))
have H_1: "{{ψ g x |g. g ∈ carrier G} |x. x ∈ S⇩r⇩e⇩a⇩c⇩h} ⊆
{{ψ g x |g. g ∈ carrier G} |x. x ∈ S}"
by (smt (verit, best) Collect_mono_iff (*‹(Collect ?P ⊆ Collect ?Q) = (∀x. ?P x ⟶ ?Q x)›*) H_0 (*‹S⇩r⇩e⇩a⇩c⇩h ⊆ S›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*))
have H_2: "⋀x. x ∈ S⇩r⇩e⇩a⇩c⇩h ⟹
{ψ g x |g. g ∈ carrier G} = {ψ⇩r⇩e⇩a⇩c⇩h g x |g. g ∈ carrier G}"
using reachable_action_is_restict (*‹⟦?g ∈ carrier G; ?s ∈ S⇩r⇩e⇩a⇩c⇩h⟧ ⟹ ψ⇩r⇩e⇩a⇩c⇩h ?g ?s = ψ ?g ?s›*) by metis
hence H_3: "{{ψ g x |g. g ∈ carrier G} |x. x ∈ S⇩r⇩e⇩a⇩c⇩h} =
{{ψ⇩r⇩e⇩a⇩c⇩h g x |g. g ∈ carrier G} |x. x ∈ S⇩r⇩e⇩a⇩c⇩h}"
by blast
show "finite (orbits G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h)"
using A_0 (*‹finite (orbits G S ψ)›*) apply (clarsimp simp add: orbits_def (*‹orbits (?G::(?'a, ?'c) partial_object_scheme) (?E::?'b::type set) (?φ::?'a::type ⇒ ?'b::type ⇒ ?'b::type) = {orbit ?G ?φ x |x::?'b::type. x ∈ ?E}›*) orbit_def (*‹orbit (?G::(?'a, ?'c) partial_object_scheme) (?φ::?'a::type ⇒ ?'b::type ⇒ ?'b::type) (?x::?'b::type) = {?φ g ?x |g::?'a::type. g ∈ carrier ?G}›*))
(*goal: ‹finite (orbits G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h)›*)
using Finite_Set.finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) H_1 (*‹{{ψ g x |g. g ∈ carrier G} |x. x ∈ S⇩r⇩e⇩a⇩c⇩h} ⊆ {{ψ g x |g. g ∈ carrier G} |x. x ∈ S}›*) H_3 (*‹{{(ψ::'grp ⇒ 'states ⇒ 'states) g x |g::'grp. g ∈ carrier (G::('grp, 'b) monoid_scheme)} |x::'states. x ∈ S⇩r⇩e⇩a⇩c⇩h} = {{ψ⇩r⇩e⇩a⇩c⇩h g x |g::'grp. g ∈ carrier G} |x::'states. x ∈ S⇩r⇩e⇩a⇩c⇩h}›*) by auto
qed
lemma (in det_G_aut)
orbs_pos_card: "finite (orbits G S ψ) ⟹ card (orbits G S ψ) > 0"
apply (clarsimp simp add: card_gt_0_iff (*‹(0 < card ?A) = (?A ≠ {} ∧ finite ?A)›*) orbits_def (*‹orbits ?G ?E ?φ = {orbit ?G ?φ x |x. x ∈ ?E}›*))
(*goal: ‹finite (orbits G S ψ) ⟹ 0 < card (orbits G S ψ)›*)
using is_aut.init_state_is_a_state (*‹(i::'states::type) ∈ (S::'states::type set)›*) by auto
lemma (in reach_det_G_aut_rec_lang) MN_B2T:
assumes
Fin: "finite (orbits G S ψ)"
shows
"finite (orbits G (language.MN_equiv A L) (([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙)))"
proof (-)
(*goal: ‹finite (orbits G (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N))›*)
have H_0: "finite {{ψ g x |g. g ∈ carrier G} |x. x ∈ S}"
using Fin (*‹finite (orbits G S ψ)›*) by (auto simp add: orbits_def (*‹orbits ?G ?E ?φ = {orbit ?G ?φ x |x. x ∈ ?E}›*) orbit_def (*‹orbit ?G ?φ ?x = {?φ g ?x |g. g ∈ carrier ?G}›*))
have H_1: "induced_epi ` S = MN_equiv"
using reach_det_G_aut_rec_lang (*‹G_aut_epi A S i F δ (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N G φ ψ (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) induced_epi›*) by (auto simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map ?S ?func ?R = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: G_aut_epi_def (*‹G_aut_epi ?A ?S₀ ?i₀ ?F₀ ?δ₀ ?S₁ ?i₁ ?F₁ ?δ₁ ?G ?φ ?ψ₀ ?ψ₁ ?f ≡ G_aut_hom ?A ?S₀ ?i₀ ?F₀ ?δ₀ ?S₁ ?i₁ ?F₁ ?δ₁ ?G ?φ ?ψ₀ ?ψ₁ ?f ∧ G_aut_epi_axioms ?S₀ ?S₁ ?f›*) G_aut_epi_axioms_def (*‹G_aut_epi_axioms ?S₀ ?S₁ ?f ≡ ?f ` ?S₀ = ?S₁›*))
have H_2: "⋀B f. finite B ⟹ finite {f b| b. b ∈ B} "
by auto
have H_3: "finite {{ψ g x |g. g ∈ carrier G} |x. x ∈ S} ⟹
finite {induced_epi ` b |b. b ∈ {{ψ g x |g. g ∈ carrier G} |x. x ∈ S}}"
using H_2[where f1 = "(λx. induced_epi ` x)" and B1 = "{{ψ g x |g. g ∈ carrier G} |x. x ∈ S}"] (*‹finite {{ψ g x |g. g ∈ carrier G} |x. x ∈ S} ⟹ finite {induced_epi ` b |b. b ∈ {{ψ g x |g. g ∈ carrier G} |x. x ∈ S}}›*) by auto
have H_4: "⋀s. s ∈ S ⟹ ∃b. {induced_epi (ψ g s) |g. g ∈ carrier G}
= {y. ∃x∈b. y = induced_epi x} ∧ (∃x. b = {ψ g x |g. g ∈ carrier G} ∧ x ∈ S)"
proof (-)
(*goal: ‹⋀s. s ∈ S ⟹ ∃b. {induced_epi (ψ g s) |g. g ∈ carrier G} = {y. ∃x∈b. y = induced_epi x} ∧ (∃x. b = {ψ g x |g. g ∈ carrier G} ∧ x ∈ S)›*)
fix s
assume A2_0: "s ∈ S" (*‹(s::'states) ∈ (S::'states set)›*)
have H2_0: "{induced_epi (ψ g s) |g. g ∈ carrier G} = {y. ∃x ∈ {ψ g s |g. g ∈ carrier G}. y =
induced_epi x}"
by blast
have H2_1: "(∃x. {ψ g s |g. g ∈ carrier G} = {ψ g x |g. g ∈ carrier G} ∧ x ∈ S)"
using A2_0 (*‹s ∈ S›*) by auto
show "∃b. {induced_epi (ψ g s) |g. g ∈ carrier G} =
{y. ∃x∈b. y = induced_epi x} ∧ (∃x. b = {ψ g x |g. g ∈ carrier G} ∧ x ∈ S)"
using A2_0 (*‹s ∈ S›*) H2_0 (*‹{induced_epi (ψ g s) |g. g ∈ carrier G} = {y. ∃x∈{ψ g s |g. g ∈ carrier G}. y = induced_epi x}›*) H2_1 (*‹∃x. {ψ g s |g. g ∈ carrier G} = {ψ g x |g. g ∈ carrier G} ∧ x ∈ S›*) by meson
qed
have H_5: "{induced_epi ` b |b. b ∈ {{ψ g x |g. g ∈ carrier G} |x. x ∈ S}} =
{{induced_epi (ψ g s) | g . g ∈ carrier G} |s. s ∈ S}"
apply ((clarsimp simp add: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1])
(*goal: ‹{induced_epi ` b |b. b ∈ {{ψ g x |g. g ∈ carrier G} |x. x ∈ S}} = {{induced_epi (ψ g s) |g. g ∈ carrier G} |s. s ∈ S}›*)
apply (rule subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*))
(*goals:
1. ‹{{y. ∃x∈b. y = induced_epi x} |b. ∃x. b = {ψ g x |g. g ∈ carrier G} ∧ x ∈ S} ⊆ {{induced_epi (ψ g s) |g. g ∈ carrier G} |s. s ∈ S}›
2. ‹{{induced_epi (ψ g s) |g. g ∈ carrier G} |s. s ∈ S} ⊆ {{y. ∃x∈b. y = induced_epi x} |b. ∃x. b = {ψ g x |g. g ∈ carrier G} ∧ x ∈ S}›
discuss goal 1*)
apply (simp add: Set.subset_eq (*‹((?A::?'a set) ⊆ (?B::?'a set)) = (∀x::?'a∈?A. x ∈ ?B)›*))
(*top goal: ‹{{y. ∃x∈b. y = induced_epi x} |b. ∃x. b = {ψ g x |g. g ∈ carrier G} ∧ x ∈ S} ⊆ {{induced_epi (ψ g s) |g. g ∈ carrier G} |s. s ∈ S}› and 1 goal remains*)
apply ((clarify)[1])
(*top goal: ‹∀x. (∃b. x = {y. ∃x∈b. y = induced_epi x} ∧ (∃x. b = {ψ g x |g. g ∈ carrier G} ∧ x ∈ S)) ⟶ (∃s. x = {induced_epi (ψ g s) |g. g ∈ carrier G} ∧ s ∈ S)› and 1 goal remains*)
apply ((auto)[1])
(*discuss goal 2*)
apply (simp add: Set.subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*))
(*goal: ‹{{induced_epi ((ψ::'grp ⇒ 'states ⇒ 'states) g s) |g::'grp. g ∈ carrier (G::('grp, 'b) monoid_scheme)} |s::'states. s ∈ (S::'states set)} ⊆ {{y::'alpha list set. ∃x::'states∈b. y = induced_epi x} |b::'states set. ∃x::'states. b = {ψ g x |g::'grp. g ∈ carrier G} ∧ x ∈ S}›*)
apply ((clarify)[1])
(*goal: ‹∀x. (∃s. x = {induced_epi (ψ g s) |g. g ∈ carrier G} ∧ s ∈ S) ⟶ (∃b. x = {y. ∃x∈b. y = induced_epi x} ∧ (∃x. b = {ψ g x |g. g ∈ carrier G} ∧ x ∈ S))›*)
apply simp
(*goal: ‹⋀x s. s ∈ S ⟹ ∃b. {induced_epi (ψ g s) |g. g ∈ carrier G} = {y. ∃x∈b. y = induced_epi x} ∧ (∃x. b = {ψ g x |g. g ∈ carrier G} ∧ x ∈ S)›*)
apply (simp add: H_4 (*‹?s2 ∈ S ⟹ ∃b. {induced_epi (ψ g ?s2) |g. g ∈ carrier G} = {y. ∃x∈b. y = induced_epi x} ∧ (∃x. b = {ψ g x |g. g ∈ carrier G} ∧ x ∈ S)›*))
(*proven 2 subgoals*) .
from H_3 (*‹finite {{(ψ::'grp ⇒ 'states ⇒ 'states) g x |g::'grp. g ∈ carrier (G::('grp, 'b) monoid_scheme)} |x::'states. x ∈ (S::'states set)} ⟹ finite {induced_epi ` b |b::'states set. b ∈ {{ψ g x |g::'grp. g ∈ carrier G} |x::'states. x ∈ S}}›*) H_5 (*‹{induced_epi ` b |b. b ∈ {{ψ g x |g. g ∈ carrier G} |x. x ∈ S}} = {{induced_epi (ψ g s) |g. g ∈ carrier G} |s. s ∈ S}›*) have H_6: "finite {{ψ g x |g. g ∈ carrier G} |x. x ∈ S} ⟹
finite {{induced_epi (ψ g s) | g . g ∈ carrier G} |s. s ∈ S}"
by metis
have H_7: "finite {{induced_epi (ψ g x) |g. g ∈ carrier G} |x. x ∈ S}"
apply (rule H_6 (*‹finite {{(ψ::'grp ⇒ 'states ⇒ 'states) g x |g::'grp. g ∈ carrier (G::('grp, 'b) monoid_scheme)} |x::'states. x ∈ (S::'states set)} ⟹ finite {{induced_epi (ψ g s) |g::'grp. g ∈ carrier G} |s::'states. s ∈ S}›*))
(*goal: ‹finite {{induced_epi (ψ g x) |g. g ∈ carrier G} |x. x ∈ S}›*)
by (simp add: H_0 (*‹finite {{ψ g x |g. g ∈ carrier G} |x. x ∈ S}›*))
have H_8: "⋀x. x ∈ S ⟹ {induced_epi (ψ g x) |g. g ∈ carrier G} =
{([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙) g (induced_epi x) |g. g ∈ carrier G}"
using induced_epi_eq_var (*‹eq_var_func G S ψ (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N) induced_epi›*) apply (simp del: GMN_simps (*‹(⊙⇘?φ::?'grp ⇒ ?'X ⇒ ?'X⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹(?func::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆ = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) ((A::'alpha set)⇧⋆))› ‹states_a_G_set.induced_star_map (?func::'grp ⇒ 'states ⇒ 'states) = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) ((S::'states set)⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map (?func::'grp ⇒ 'states × 'alpha ⇒ 'states × 'alpha) = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) (((S::'states set) × (A::'alpha set))⇧⋆))› ‹trans_is_eq_var.GA_0.induced_quot_map (?S::?'Y set) (?func::'grp ⇒ ?'Y ⇒ ?'Y) (?R::(?'Y × ?'Y) set) = (λg::'grp∈carrier (G::('grp, 'b) monoid_scheme). λx::?'Y set∈?S // ?R. ?R `` {?func g (SOME z::?'Y. z ∈ x)})› ‹[?w::'alpha list]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N (?W'::'alpha list set) (?a'::'alpha) = (λ(W::'alpha list set, a::'alpha)∈(A::'alpha set)⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w::'alpha list. w ∈ W) @ [a]}) (?W', ?a')›*) add: eq_var_func_def (*‹eq_var_func (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'Y set) (?ψ::?'grp ⇒ ?'Y ⇒ ?'Y) (?f::?'X ⇒ ?'Y) ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*) eq_var_func_axioms_def (*‹eq_var_func_axioms (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'Y set) (?ψ::?'grp ⇒ ?'Y ⇒ ?'Y) (?f::?'X ⇒ ?'Y) ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀(a::?'X) g::?'grp. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*) make_op_def (*‹(⊙⇘?φ::?'grp ⇒ ?'X ⇒ ?'X⇙) ≡ ?φ›*))
(*goal: ‹⋀x. x ∈ S ⟹ {induced_epi (ψ g x) |g. g ∈ carrier G} = {trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g (induced_epi x) |g. g ∈ carrier G}›*)
by blast
hence H_9: "{{induced_epi (ψ g x) |g. g ∈ carrier G} |x. x ∈ S} =
{{([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙) g (induced_epi x) |g. g ∈ carrier G} |x. x ∈ S}"
by blast
have H_10: "⋀f g X B C. g ` B = C ⟹
{{f x (g b)|x. x∈X}|b. b ∈ B} = {{f x c|x. x ∈ X}|c. c ∈ C}"
by auto
have H_11: "{{([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙) g (induced_epi x) |g. g ∈ carrier G} |x. x ∈ S} =
{{([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙) g W |g. g ∈ carrier G} |W. W ∈ MN_equiv}"
apply (rule H_10[where f2 = "([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙)" and X2 = "carrier G" and g2 = induced_epi and B2 = S and C2 = MN_equiv] (*‹induced_epi ` S = A⇧⋆ // ≡⇩M⇩N ⟹ {{trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N x (induced_epi b) |x. x ∈ carrier G} |b. b ∈ S} = {{trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N x c |x. x ∈ carrier G} |c. c ∈ A⇧⋆ // ≡⇩M⇩N}›*))
(*goal: ‹{{trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g (induced_epi x) |g. g ∈ carrier G} |x. x ∈ S} = {{trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g W |g. g ∈ carrier G} |W. W ∈ A⇧⋆ // ≡⇩M⇩N}›*)
using H_1 (*‹induced_epi ` S = A⇧⋆ // ≡⇩M⇩N›*) by simp
have H_12: "{{([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙) g W |g. g ∈ carrier G} |W. W ∈ MN_equiv} =
orbits G (language.MN_equiv A L) (([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙))"
by (auto simp add: orbits_def (*‹orbits ?G ?E ?φ = {orbit ?G ?φ x |x. x ∈ ?E}›*) orbit_def (*‹orbit ?G ?φ ?x = {?φ g ?x |g. g ∈ carrier ?G}›*))
show "finite (orbits G (language.MN_equiv A L) (([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙)))"
using H_9 (*‹{{induced_epi (ψ g x) |g. g ∈ carrier G} |x. x ∈ S} = {{trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g (induced_epi x) |g. g ∈ carrier G} |x. x ∈ S}›*) H_11 (*‹{{trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g (induced_epi x) |g. g ∈ carrier G} |x. x ∈ S} = {{trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g W |g. g ∈ carrier G} |W. W ∈ A⇧⋆ // ≡⇩M⇩N}›*) H_12 (*‹{{trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N g W |g. g ∈ carrier G} |W. W ∈ A⇧⋆ // ≡⇩M⇩N} = orbits G (A⇧⋆ // ≡⇩M⇩N) (trans_is_eq_var.GA_0.induced_quot_map (A⇧⋆) (φ⇧⋆) ≡⇩M⇩N)›*) H_7 (*‹finite {{induced_epi (ψ g x) |g. g ∈ carrier G} |x. x ∈ S}›*) by presburger
qed
context det_G_aut_rec_lang begin
text ‹
To avoid duplicate variant of "star":
›
no_adhoc_overloading
star labels_a_G_set.induced_star_map
end
context det_G_aut_rec_lang begin
adhoc_overloading
star labels_a_G_set.induced_star_map
end
lemma (in det_G_aut_rec_lang) MN_prep:
"∃S'. ∃δ'. ∃F'. ∃ψ'.
(reach_det_G_aut_rec_lang A S' i F' δ' G φ ψ' L ∧
(finite (orbits G S ψ) ⟶ finite (orbits G S' ψ')))"
by (meson G_lang_axioms (*‹G_lang G A φ L›*) finite_reachable (*‹finite (orbits G S ψ) ⟹ finite (orbits G S⇩r⇩e⇩a⇩c⇩h ψ⇩r⇩e⇩a⇩c⇩h)›*) reach_det_G_aut_rec_lang.intro (*‹⟦det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L; reach_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ⟧ ⟹ reach_det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L›*) reach_det_aut_is_det_aut_rec_L (*‹reach_det_G_aut_rec_lang A S⇩r⇩e⇩a⇩c⇩h i (F ∩ S⇩r⇩e⇩a⇩c⇩h) δ⇩r⇩e⇩a⇩c⇩h G φ ψ⇩r⇩e⇩a⇩c⇩h L›*))
lemma (in det_G_aut_rec_lang) MN_fin_orbs_imp_fin_states:
assumes
Fin: "finite (orbits G S ψ)"
shows
"finite (orbits G (language.MN_equiv A L) (([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙)))"
using MN_prep (*‹∃S' δ' F' ψ'. reach_det_G_aut_rec_lang A S' i F' δ' G φ ψ' L ∧ (finite (orbits G S ψ) ⟶ finite (orbits G S' ψ'))›*) by (metis assms (*‹finite (orbits (G::('grp, 'b) monoid_scheme) (S::'states set) (ψ::'grp ⇒ 'states ⇒ 'states))›*) reach_det_G_aut_rec_lang.MN_B2T (*‹⟦reach_det_G_aut_rec_lang (?A::?'alpha set) (?S::?'states set) (?i::?'states) (?F::?'states set) (?δ::?'states ⇒ ?'alpha ⇒ ?'states) (?G::(?'grp, ?'b) monoid_scheme) (?φ::?'grp ⇒ ?'alpha ⇒ ?'alpha) (?ψ::?'grp ⇒ ?'states ⇒ ?'states) (?L::?'alpha list set); finite (orbits ?G ?S ?ψ)⟧ ⟹ finite (orbits ?G (?A⇧⋆ // language.rel_MN ?A ?L) (alt_grp_act.induced_quot_map ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) (language.rel_MN ?A ?L)))›*))
text ‹
The following theorem corresponds to theorem 3.8 from \cite{bojanczyk2014automata}, i.e. the
Myhill-Nerode theorem for G-automata.
The left to right direction (see statement below) of the typical Myhill-Nerode theorem would
qantify over types (if some condition holds, then there exists some automaton accepting the
language). As it is not possible to qantify over types in this way, the equivalence is spit into
two directions. In the left to right direction, the explicit type of the syntactic automaton is
used. In the right to left direction some type, 's, is fixed.
As the two directions are split, the opertunity was taken to strengthen the right to left direction:
We do not assume the given automaton is reachable.
This splitting of the directions will be present in all other Myhill-Nerode theorems that will be
proved in this document.
›
theorem (in G_lang) G_Myhill_Nerode :
assumes
"finite (orbits G A φ)"
shows
G_Myhill_Nerode_LR: "finite (orbits G MN_equiv ([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙)) ⟹
(∃S F :: 'alpha list set set. ∃i :: 'alpha list set. ∃δ. ∃ψ.
reach_det_G_aut_rec_lang A S i F δ G φ ψ L ∧ finite (orbits G S ψ))" and
G_Myhill_Nerode_RL: "(∃S F :: 's set. ∃i :: 's. ∃δ. ∃ψ.
det_G_aut_rec_lang A S i F δ G φ ψ L ∧ finite (orbits G S ψ))
⟹ finite (orbits G MN_equiv ([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙))"
subgoal for
using syntact_aut_is_reach_aut_rec_lang (*‹reach_det_G_aut_rec_lang A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N G φ ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙) L›*) by blast
by (metis det_G_aut_rec_lang.MN_fin_orbs_imp_fin_states (*‹⟦det_G_aut_rec_lang (?A::?'alpha set) (?S::?'states set) (?i::?'states) (?F::?'states set) (?δ::?'states ⇒ ?'alpha ⇒ ?'states) (?G::(?'grp, ?'b) monoid_scheme) (?φ::?'grp ⇒ ?'alpha ⇒ ?'alpha) (?ψ::?'grp ⇒ ?'states ⇒ ?'states) (?L::?'alpha list set); finite (orbits ?G ?S ?ψ)⟧ ⟹ finite (orbits ?G (?A⇧⋆ // language.rel_MN ?A ?L) (alt_grp_act.induced_quot_map ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) (language.rel_MN ?A ?L)))›*))
subsection ‹
Proving the standard Myhill-Nerode Theorem
›
text ‹
Any automaton is a $G$-automaton with respect to the trivial group and action,
hence the standard Myhill-Nerode theorem is a special case of the $G$-Myhill-Nerode theorem.
›
interpretation triv_act:
alt_grp_act "singleton_group (undefined)" X "(λx ∈ {undefined}. one (BijGroup X))"
apply (simp add: group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*))
(*goal: ‹alt_grp_act (singleton_group undefined) X (λx∈{undefined}. 𝟭⇘BijGroup X⇙)›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹Group.group (BijGroup X) ∧ (λx∈{undefined}. 𝟭⇘BijGroup X⇙) ∈ hom (singleton_group undefined) (BijGroup X)›*)
apply (simp add: group_BijGroup (*‹Group.group (BijGroup ?S)›*))
(*top goal: ‹Group.group (BijGroup X)› and 1 goal remains*)
using trivial_hom (*‹Group.group ?H ⟹ (λx. 𝟭⇘?H⇙) ∈ hom ?G ?H›*) by (smt (verit) carrier_singleton_group (*‹carrier (singleton_group ?a) = {?a}›*) group.hom_restrict (*‹⟦Group.group ?G; ?h ∈ hom ?G ?H; ⋀g. g ∈ carrier ?G ⟹ ?h g = ?t g⟧ ⟹ ?t ∈ hom ?G ?H›*) group_BijGroup (*‹Group.group (BijGroup ?S)›*) restrict_apply (*‹restrict ?f ?A ?x = (if ?x ∈ ?A then ?f ?x else undefined)›*) singleton_group (*‹Group.group (singleton_group ?a)›*))
lemma (in det_aut) triv_G_aut:
fixes triv_G
assumes H_triv_G: "triv_G = (singleton_group (undefined))"
shows "det_G_aut labels states init_state fin_states δ
triv_G (λx ∈ {undefined}. one (BijGroup labels)) (λx ∈ {undefined}. one (BijGroup states))"
apply (simp add: det_G_aut_def (*‹det_G_aut (?A::?'alpha set) (?S::?'states set) (?i::?'states) (?F::?'states set) (?δ::?'states ⇒ ?'alpha ⇒ ?'states) (?G::(?'grp, ?'b) monoid_scheme) (?φ::?'grp ⇒ ?'alpha ⇒ ?'alpha) (?ψ::?'grp ⇒ ?'states ⇒ ?'states) ≡ (det_aut ?A ?S ?i ?F ?δ ∧ alt_grp_act ?G ?A ?φ ∧ alt_grp_act ?G ?S ?ψ) ∧ eq_var_subset ?G ?S ?ψ ?F ∧ eq_var_subset ?G ?S ?ψ {?i} ∧ eq_var_func ?G (?S × ?A) (λg::?'grp∈carrier ?G. λ(s::?'states, a::?'alpha)∈?S × ?A. (?ψ g s, ?φ g a)) ?S ?ψ (λ(s::?'states, a::?'alpha)∈?S × ?A. ?δ s a)›*) group_hom_def (*‹group_hom (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ≡ ?h ∈ hom ?G ?H›*) eq_var_subset_def (*‹eq_var_subset (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'X set) ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'X set) ≡ ?Y ⊆ ?X ∧ (∀g::?'grp∈carrier ?G. ?φ g ` ?Y = ?Y)›*) eq_var_func_def (*‹eq_var_func (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'Y set) (?ψ::?'grp ⇒ ?'Y ⇒ ?'Y) (?f::?'X ⇒ ?'Y) ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*) eq_var_func_axioms_def (*‹eq_var_func_axioms (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'Y set) (?ψ::?'grp ⇒ ?'Y ⇒ ?'Y) (?f::?'X ⇒ ?'Y) ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀(a::?'X) g::?'grp. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*))
(*goal: ‹det_G_aut labels states init_state fin_states δ triv_G (λx∈{undefined}. 𝟭⇘BijGroup labels⇙) (λx∈{undefined}. 𝟭⇘BijGroup states⇙)›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹det_aut labels states init_state fin_states δ ∧ group_action triv_G labels (λx∈{undefined}. 𝟭⇘BijGroup labels⇙) ∧ group_action triv_G states (λx∈{undefined}. 𝟭⇘BijGroup states⇙) ∧ fin_states ⊆ states ∧ (∀g∈carrier triv_G. (g = undefined ⟶ 𝟭⇘BijGroup states⇙ ` fin_states = fin_states) ∧ (g ≠ undefined ⟶ undefined ` fin_states = fin_states)) ∧ group_action triv_G states (λx∈{undefined}. 𝟭⇘BijGroup states⇙) ∧ init_state ∈ states ∧ (∀g∈carrier triv_G. (g = undefined ⟶ 𝟭⇘BijGroup states⇙ init_state = init_state) ∧ (g ≠ undefined ⟶ undefined init_state = init_state)) ∧ group_action triv_G (states × labels) (λg∈carrier triv_G. λ(s, a)∈states × labels. ((if g = undefined then 𝟭⇘BijGroup states⇙ else undefined) s, (if g = undefined then 𝟭⇘BijGroup labels⇙ else undefined) a)) ∧ group_action triv_G states (λx∈{undefined}. 𝟭⇘BijGroup states⇙) ∧ (λ(x, y). δ x y) ∈ states × labels → states ∧ (∀a b. a ∈ states ∧ b ∈ labels ⟶ (∀g. (𝟭⇘BijGroup states⇙ a ∈ states ∧ 𝟭⇘BijGroup labels⇙ b ∈ labels ⟶ (undefined a ∈ states ∧ undefined b ∈ labels ⟶ (g = undefined ⟶ undefined ∈ carrier triv_G ⟶ δ (𝟭⇘BijGroup states⇙ a) (𝟭⇘BijGroup labels⇙ b) = 𝟭⇘BijGroup states⇙ (δ a b)) ∧ (g ≠ undefined ⟶ g ∈ carrier triv_G ⟶ δ (undefined a) (undefined b) = undefined (δ a b))) ∧ ((undefined a ∈ states ⟶ undefined b ∉ labels) ⟶ (g = undefined ⟶ undefined ∈ carrier triv_G ⟶ δ (𝟭⇘BijGroup states⇙ a) (𝟭⇘BijGroup labels⇙ b) = 𝟭⇘BijGroup states⇙ (δ a b)) ∧ (g ≠ undefined ⟶ g ∈ carrier triv_G ⟶ undefined = undefined (δ a b)))) ∧ ((𝟭⇘BijGroup states⇙ a ∈ states ⟶ 𝟭⇘BijGroup labels⇙ b ∉ labels) ⟶ (undefined a ∈ states ∧ undefined b ∈ labels ⟶ (g = undefined ⟶ undefined ∈ carrier triv_G ⟶ undefined = 𝟭⇘BijGroup states⇙ (δ a b)) ∧ (g ≠ undefined ⟶ g ∈ carrier triv_G ⟶ δ (undefined a) (undefined b) = undefined (δ a b))) ∧ ((undefined a ∈ states ⟶ undefined b ∉ labels) ⟶ (g = undefined ⟶ undefined ∈ carrier triv_G ⟶ undefined = 𝟭⇘BijGroup states⇙ (δ a b)) ∧ (g ≠ undefined ⟶ g ∈ carrier triv_G ⟶ undefined = undefined (δ a b))))))›*)
apply (rule det_aut_axioms (*‹det_aut labels states init_state fin_states δ›*))
(*top goal: ‹det_aut labels states init_state fin_states δ› and 11 goals remain*)
apply ((simp add: assms (*‹triv_G = singleton_group undefined›*) triv_act.group_action_axioms (*‹group_action (singleton_group undefined) ?X (λx∈{undefined}. 𝟭⇘BijGroup ?X⇙)›*))+)
(*top goal: ‹group_action triv_G labels (λx∈{undefined}. 𝟭⇘BijGroup labels⇙)› and 10 goals remain*)
using fin_states_are_states (*‹fin_states ⊆ states›*) apply ((auto)[1])
(*top goal: ‹fin_states ⊆ states› and 8 goals remain*)
apply (clarify; rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*top goal: ‹∀g∈carrier triv_G. (g = undefined ⟶ 𝟭⇘BijGroup states⇙ ` fin_states = fin_states) ∧ (g ≠ undefined ⟶ undefined ` fin_states = fin_states)› and 7 goals remain*)
apply (simp add: H_triv_G (*‹triv_G = singleton_group undefined›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*top goal: ‹⋀g::'a. ⟦g ∈ carrier (triv_G::'a monoid); g = undefined⟧ ⟹ 𝟭⇘BijGroup (states::'state set)⇙ ` (fin_states::'state set) = fin_states› and 8 goals remain*)
using fin_states_are_states (*‹fin_states ⊆ states›*)
(*goals:
1. ‹(fin_states::'state set) ∩ (states::'state set) ∪ {y::'state. y = undefined ∧ (∃x::'state. x ∈ fin_states ∧ x ∉ states)} = fin_states›
2. ‹⋀g::'a. ⟦g ∈ carrier (triv_G::'a monoid); g ≠ undefined⟧ ⟹ undefined ` (fin_states::'state set) = fin_states›
3. ‹group_action (triv_G::'a monoid) (states::'state set) (λx::'a∈{undefined}. 𝟭⇘BijGroup states⇙)›
4. ‹(init_state::'state) ∈ (states::'state set)›
5. ‹∀g::'a∈carrier (triv_G::'a monoid). (g = undefined ⟶ 𝟭⇘BijGroup (states::'state set)⇙ (init_state::'state) = init_state) ∧ (g ≠ undefined ⟶ undefined init_state = init_state)›
6. ‹group_action (triv_G::'a monoid) ((states::'state set) × (labels::'alpha set)) (λg::'a∈carrier triv_G. λ(s::'state, a::'alpha)∈states × labels. ((if g = undefined then 𝟭⇘BijGroup states⇙ else undefined) s, (if g = undefined then 𝟭⇘BijGroup labels⇙ else undefined) a))›
7. ‹group_action (triv_G::'a monoid) (states::'state set) (λx::'a∈{undefined}. 𝟭⇘BijGroup states⇙)›
8. ‹(λ(x::'state, y::'alpha). δ x y) ∈ (states::'state set) × (labels::'alpha set) → states›
9. ‹∀(a::'state) b::'alpha. a ∈ (states::'state set) ∧ b ∈ (labels::'alpha set) ⟶ (∀g::'a. (𝟭⇘BijGroup states⇙ a ∈ states ∧ 𝟭⇘BijGroup labels⇙ b ∈ labels ⟶ (undefined a ∈ states ∧ undefined b ∈ labels ⟶ (g = undefined ⟶ undefined ∈ carrier (triv_G::'a monoid) ⟶ δ (𝟭⇘BijGroup states⇙ a) (𝟭⇘BijGroup labels⇙ b) = 𝟭⇘BijGroup states⇙ (δ a b)) ∧ (g ≠ undefined ⟶ g ∈ carrier triv_G ⟶ δ (undefined a) (undefined b) = undefined (δ a b))) ∧ ((undefined a ∈ states ⟶ undefined b ∉ labels) ⟶ (g = undefined ⟶ undefined ∈ carrier triv_G ⟶ δ (𝟭⇘BijGroup states⇙ a) (𝟭⇘BijGroup labels⇙ b) = 𝟭⇘BijGroup states⇙ (δ a b)) ∧ (g ≠ undefined ⟶ g ∈ carrier triv_G ⟶ undefined = undefined (δ a b)))) ∧ ((𝟭⇘BijGroup states⇙ a ∈ states ⟶ 𝟭⇘BijGroup labels⇙ b ∉ labels) ⟶ (undefined a ∈ states ∧ undefined b ∈ labels ⟶ (g = undefined ⟶ undefined ∈ carrier triv_G ⟶ undefined = 𝟭⇘BijGroup states⇙ (δ a b)) ∧ (g ≠ undefined ⟶ g ∈ carrier triv_G ⟶ δ (undefined a) (undefined b) = undefined (δ a b))) ∧ ((undefined a ∈ states ⟶ undefined b ∉ labels) ⟶ (g = undefined ⟶ undefined ∈ carrier triv_G ⟶ undefined = 𝟭⇘BijGroup states⇙ (δ a b)) ∧ (g ≠ undefined ⟶ g ∈ carrier triv_G ⟶ undefined = undefined (δ a b)))))›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply (simp add: H_triv_G (*‹triv_G = singleton_group undefined›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*discuss goal 3*)
apply (simp add: assms (*‹triv_G = singleton_group undefined›*) triv_act.group_action_axioms (*‹group_action (singleton_group undefined) ?X (λx∈{undefined}. 𝟭⇘BijGroup ?X⇙)›*))
(*discuss goal 4*)
apply (simp add: init_state_is_a_state (*‹init_state ∈ states›*))
(*discuss goal 5*)
apply ((clarify)[1])
(*top goal: ‹∀g∈carrier triv_G. (g = undefined ⟶ 𝟭⇘BijGroup states⇙ init_state = init_state) ∧ (g ≠ undefined ⟶ undefined init_state = init_state)› and 4 goals remain*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹⋀g. g ∈ carrier triv_G ⟹ g = undefined ⟶ 𝟭⇘BijGroup states⇙ init_state = init_state›
2. ‹⋀g. g ∈ carrier triv_G ⟹ g ≠ undefined ⟶ undefined init_state = init_state›
discuss goal 1*)
apply (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*top goal: ‹⋀g::'a. g ∈ carrier (triv_G::'a monoid) ⟹ g = undefined ⟶ 𝟭⇘BijGroup (states::'state set)⇙ (init_state::'state) = init_state› and 5 goals remain*)
apply (simp add: H_triv_G (*‹triv_G = singleton_group undefined›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*) init_state_is_a_state (*‹init_state ∈ states›*))
(*discuss goal 2*)
apply (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*top goal: ‹⋀g. g ∈ carrier triv_G ⟹ g ≠ undefined ⟶ undefined init_state = init_state› and 4 goals remain*)
apply (simp add: H_triv_G (*‹triv_G = singleton_group undefined›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*) init_state_is_a_state (*‹init_state ∈ states›*))
(*proven 2 subgoals*)
(*discuss goal 6*)
apply (simp add: H_triv_G (*‹triv_G = singleton_group undefined›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*) init_state_is_a_state (*‹init_state ∈ states›*))
(*top goal: ‹group_action triv_G (states × labels) (λg∈carrier triv_G. λ(s, a)∈states × labels. ((if g = undefined then 𝟭⇘BijGroup states⇙ else undefined) s, (if g = undefined then 𝟭⇘BijGroup labels⇙ else undefined) a))› and 3 goals remain*)
apply ((clarsimp simp add: group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*))[1])
(*top goal: ‹group_action (singleton_group undefined) (states × labels) (λg∈{undefined}. λ(s, a)∈states × labels. ((if g = undefined then 𝟭⇘BijGroup states⇙ else undefined) s, (if g = undefined then 𝟭⇘BijGroup labels⇙ else undefined) a))› and 3 goals remain*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goals:
1. ‹undefined ⊗⇘singleton_group undefined⇙ undefined = undefined ⟶ ((λ(s, a)∈states × labels. (if s ∈ states then s else undefined, if a ∈ labels then a else undefined)) ∈ Bij (states × labels) ⟶ Group.group ⦇carrier = Bij (states × labels), mult = λg∈Bij (states × labels). restrict (compose (states × labels) g) (Bij (states × labels)), one = λx∈states × labels. x⦈ ∧ (λ(s, a)∈states × labels. (if s ∈ states then s else undefined, if a ∈ labels then a else undefined)) = compose (states × labels) (λ(s, a)∈states × labels. (if s ∈ states then s else undefined, if a ∈ labels then a else undefined)) (λ(s, a)∈states × labels. (if s ∈ states then s else undefined, if a ∈ labels then a else undefined))) ∧ (λ(s, a)∈states × labels. (if s ∈ states then s else undefined, if a ∈ labels then a else undefined)) ∈ Bij (states × labels)›
2. ‹undefined ⊗⇘singleton_group undefined⇙ undefined ≠ undefined ⟶ ((λ(s, a)∈states × labels. (if s ∈ states then s else undefined, if a ∈ labels then a else undefined)) ∈ Bij (states × labels) ⟶ Group.group ⦇carrier = Bij (states × labels), mult = λg∈Bij (states × labels). restrict (compose (states × labels) g) (Bij (states × labels)), one = λx∈states × labels. x⦈ ∧ undefined = compose (states × labels) (λ(s, a)∈states × labels. (if s ∈ states then s else undefined, if a ∈ labels then a else undefined)) (λ(s, a)∈states × labels. (if s ∈ states then s else undefined, if a ∈ labels then a else undefined))) ∧ (λ(s, a)∈states × labels. (if s ∈ states then s else undefined, if a ∈ labels then a else undefined)) ∈ Bij (states × labels)›
discuss goal 1*)
apply ((smt (verit) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) Bij_imp_funcset (*‹?f ∈ Bij ?S ⟹ ?f ∈ ?S → ?S›*) Id_compose (*‹⟦?f ∈ ?A → ?B; ?f ∈ extensional ?A⟧ ⟹ compose ?A (λy∈?B. y) ?f = ?f›*) SigmaE (*‹⟦?c ∈ Sigma ?A ?B; ⋀x y. ⟦x ∈ ?A; y ∈ ?B x; ?c = (x, y)⟧ ⟹ ?P⟧ ⟹ ?P›*) case_prod_conv (*‹(case (?a, ?b) of (c, d) ⇒ ?f c d) = ?f ?a ?b›*) group_BijGroup (*‹Group.group (BijGroup ?S)›*) id_Bij (*‹(λx∈?S. x) ∈ Bij ?S›*) restrict_ext (*‹(⋀x. x ∈ ?A ⟹ ?f x = ?g x) ⟹ restrict ?f ?A = restrict ?g ?A›*) restrict_extensional (*‹restrict ?f ?A ∈ extensional ?A›*))[1])
(*discuss goal 2*)
apply (rule meta_mp[of "undefined ⊗⇘singleton_group undefined⇙ undefined = undefined"] (*‹⟦undefined ⊗⇘singleton_group undefined⇙ undefined = undefined ⟹ PROP ?Q; undefined ⊗⇘singleton_group undefined⇙ undefined = undefined⟧ ⟹ PROP ?Q›*))
(*goals:
1. ‹undefined ⊗⇘singleton_group undefined⇙ undefined = undefined ⟹ undefined ⊗⇘singleton_group undefined⇙ undefined ≠ undefined ⟶ ((λ(s, a)∈states × labels. (if s ∈ states then s else undefined, if a ∈ labels then a else undefined)) ∈ Bij (states × labels) ⟶ Group.group ⦇carrier = Bij (states × labels), mult = λg∈Bij (states × labels). restrict (compose (states × labels) g) (Bij (states × labels)), one = λx∈states × labels. x⦈ ∧ undefined = compose (states × labels) (λ(s, a)∈states × labels. (if s ∈ states then s else undefined, if a ∈ labels then a else undefined)) (λ(s, a)∈states × labels. (if s ∈ states then s else undefined, if a ∈ labels then a else undefined))) ∧ (λ(s, a)∈states × labels. (if s ∈ states then s else undefined, if a ∈ labels then a else undefined)) ∈ Bij (states × labels)›
2. ‹undefined ⊗⇘singleton_group undefined⇙ undefined = undefined›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((metis carrier_singleton_group (*‹carrier (singleton_group (?a::?'a::type)) = {?a}›*) comm_groupE( (*‹⟦comm_group (?G::(?'a, ?'b) monoid_scheme); (?x::?'a::type) ∈ carrier ?G; (?y::?'a::type) ∈ carrier ?G⟧ ⟹ ?x ⊗⇘?G⇙ ?y ∈ carrier ?G›*) 1) singletonD (*‹(?b::?'a::type) ∈ {?a::?'a::type} ⟹ ?b = ?a›*) singletonI (*‹(?a::?'a::type) ∈ {?a}›*) singleton_abelian_group (*‹comm_group (singleton_group (?a::?'a::type))›*))[1])
(*proven 2 subgoals*)
(*proven 2 subgoals*)
(*discuss goal 7*)
apply (simp add: assms (*‹triv_G = singleton_group undefined›*) triv_act.group_action_axioms (*‹group_action (singleton_group undefined) ?X (λx∈{undefined}. 𝟭⇘BijGroup ?X⇙)›*))
(*discuss goal 8*)
apply ((auto simp add: trans_func_well_def (*‹⟦(?state::'state) ∈ (states::'state set); (?label::'alpha) ∈ (labels::'alpha set)⟧ ⟹ δ ?state ?label ∈ states›*))[1])
(*discuss goal 9*)
apply ((clarsimp simp add: BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) trans_func_well_def (*‹⟦?state ∈ states; ?label ∈ labels⟧ ⟹ δ ?state ?label ∈ states›*) H_triv_G (*‹triv_G = singleton_group undefined›*))[1])
(*proven 9 subgoals*) .
lemma triv_orbits:
"orbits (singleton_group (undefined)) S (λx ∈ {undefined}. one (BijGroup S)) =
{{s} |s. s ∈ S}"
apply (simp add: BijGroup_def (*‹BijGroup (?S::?'a set) = ⦇carrier = Bij ?S, mult = λg::?'a ⇒ ?'a∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx::?'a∈?S. x⦈›*) singleton_group_def (*‹singleton_group (?a::?'a) = ⦇carrier = {?a}, mult = λ(x::?'a) y::?'a. ?a, one = ?a⦈›*) orbits_def (*‹orbits (?G::(?'a, ?'c) partial_object_scheme) (?E::?'b set) (?φ::?'a ⇒ ?'b ⇒ ?'b) = {orbit ?G ?φ x |x::?'b. x ∈ ?E}›*) orbit_def (*‹orbit (?G::(?'a, ?'c) partial_object_scheme) (?φ::?'a ⇒ ?'b ⇒ ?'b) (?x::?'b) = {?φ g ?x |g::?'a. g ∈ carrier ?G}›*))
(*goal: ‹orbits (singleton_group undefined) S (λx∈{undefined}. 𝟭⇘BijGroup S⇙) = {{s} |s. s ∈ S}›*)
by auto
lemma fin_triv_orbs:
"finite (orbits (singleton_group (undefined)) S (λx ∈ {undefined}. one (BijGroup S))) = finite S"
apply (subst triv_orbits (*‹orbits (singleton_group undefined) ?S (λx∈{undefined}. 𝟭⇘BijGroup ?S⇙) = {{s} |s. s ∈ ?S}›*))
(*goal: ‹finite (orbits (singleton_group undefined) S (λx∈{undefined}. 𝟭⇘BijGroup S⇙)) = finite S›*)
apply (rule meta_mp[of "bij_betw (λs ∈ S. {s}) S {{s} |s. s ∈ S}"] (*‹⟦bij_betw (λs∈S. {s}) S {{s} |s. s ∈ S} ⟹ PROP ?Q; bij_betw (λs∈S. {s}) S {{s} |s. s ∈ S}⟧ ⟹ PROP ?Q›*))
(*goal: ‹finite {{s} |s. s ∈ S} = finite S›*)
using bij_betw_finite (*‹bij_betw ?f ?A ?B ⟹ finite ?A = finite ?B›*)
(*goals:
1. ‹bij_betw (λs∈S. {s}) S {{s} |s. s ∈ S} ⟹ finite {{s} |s. s ∈ S} = finite S›
2. ‹bij_betw (λs∈S. {s}) S {{s} |s. s ∈ S}›
discuss goal 1*)
apply auto
(*discuss goal 2*)
apply (auto simp add: bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*proven 2 subgoals*) .
context language begin
interpretation triv_G_lang:
G_lang "singleton_group (undefined)" A "(λx ∈ {undefined}. one (BijGroup A))" L
apply (simp add: G_lang_def (*‹G_lang ?G ?A ?φ ?L ≡ alt_grp_act ?G ?A ?φ ∧ language ?A ?L ∧ G_lang_axioms ?G ?A ?φ ?L›*) G_lang_axioms_def (*‹G_lang_axioms ?G ?A ?φ ?L ≡ eq_var_subset ?G (?A⇧⋆) (alt_grp_act.induced_star_map ?G ?A ?φ) ?L›*) eq_var_subset_def (*‹eq_var_subset ?G ?X ?φ ?Y ≡ alt_grp_act ?G ?X ?φ ∧ eq_var_subset_axioms ?G ?X ?φ ?Y›*) eq_var_subset_axioms_def (*‹eq_var_subset_axioms ?G ?X ?φ ?Y ≡ ?Y ⊆ ?X ∧ (∀g∈carrier ?G. ?φ g ` ?Y = ?Y)›*))
(*goal: ‹G_lang (singleton_group undefined) (A::'alpha set) (λx::'a∈{undefined}. 𝟭⇘BijGroup A⇙) (L::'alpha list set)›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹group_action (singleton_group undefined) A (λx∈{undefined}. 𝟭⇘BijGroup A⇙) ∧ language A L ∧ group_action (singleton_group undefined) (A⇧⋆) (λg∈{undefined}. restrict (map (if g = undefined then 𝟭⇘BijGroup A⇙ else undefined)) (A⇧⋆)) ∧ L ⊆ A⇧⋆ ∧ map 𝟭⇘BijGroup A⇙ ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L›*)
apply (simp add: triv_act.group_action_axioms (*‹group_action (singleton_group undefined) ?X (λx∈{undefined}. 𝟭⇘BijGroup ?X⇙)›*))
(*top goal: ‹group_action (singleton_group undefined) (A::'alpha set) (λx::'a∈{undefined}. 𝟭⇘BijGroup A⇙)› and 4 goals remain*)
apply (simp add: language_axioms (*‹language A L›*))
(*top goal: ‹language A L› and 3 goals remain*)
using triv_act.lists_a_Gset (*‹alt_grp_act (singleton_group undefined) (?X⇧⋆) (triv_act.induced_star_map ?X (λx∈{undefined}. 𝟭⇘BijGroup ?X⇙))›*) apply fastforce
(*top goal: ‹group_action (singleton_group undefined) (A⇧⋆) (λg∈{undefined}. restrict (map (if g = undefined then 𝟭⇘BijGroup A⇙ else undefined)) (A⇧⋆))› and 2 goals remain*)
apply (rule is_lang (*‹L ⊆ A⇧⋆›*))
(*top goal: ‹(L::'alpha list set) ⊆ (A::'alpha set)⇧⋆› and 1 goal remains*)
apply (clarsimp simp add: BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*goal: ‹map 𝟭⇘BijGroup A⇙ ` (L ∩ A⇧⋆) ∪ (λx. undefined) ` (L ∩ {x. x ∉ A⇧⋆}) = L›*)
apply (rule subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*); simp add: Set.subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*); clarify)
(*goal: ‹{y. ∃x∈L ∩ A⇧⋆. y = map (λx∈A. x) x} ∪ {y. y = undefined ∧ (∃x. x ∈ L ∧ x ∉ A⇧⋆)} = L›*)
using is_lang (*‹L ⊆ A⇧⋆›*) apply ((auto simp add: map_idI (*‹(⋀x. x ∈ set ?xs ⟹ ?f x = x) ⟹ map ?f ?xs = ?xs›*))[1])
(*top goal: ‹⋀x. x ∈ {y. ∃x∈L ∩ A⇧⋆. y = map (λx∈A. x) x} ∪ {y. y = undefined ∧ (∃x. x ∈ L ∧ x ∉ A⇧⋆)} ⟹ x ∈ L› and 1 goal remains*)
using is_lang (*‹L ⊆ A⇧⋆›*) map_idI (*‹(⋀x. x ∈ set ?xs ⟹ ?f x = x) ⟹ map ?f ?xs = ?xs›*) by (metis in_listsD (*‹?xs ∈ ?A⇧⋆ ⟹ ∀x∈set ?xs. x ∈ ?A›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*) inf.absorb_iff1 (*‹(?a ≤ ?b) = (inf ?a ?b = ?a)›*) restrict_apply (*‹restrict ?f ?A ?x = (if ?x ∈ ?A then ?f ?x else undefined)›*))
definition triv_G :: "'grp monoid"
where "triv_G = (singleton_group (undefined))"
definition triv_act :: "'grp ⇒ 'alpha ⇒ 'alpha"
where "triv_act = (λx ∈ {undefined}. 𝟭⇘BijGroup A⇙)"
corollary standard_Myhill_Nerode:
assumes
H_fin_alph: "finite A"
shows
standard_Myhill_Nerode_LR: "finite MN_equiv ⟹
(∃S F :: 'alpha list set set. ∃i :: 'alpha list set. ∃δ.
reach_det_aut_rec_lang A S i F δ L ∧ finite S)" and
standard_Myhill_Nerode_RL: "(∃S F :: 's set. ∃i :: 's. ∃δ.
det_aut_rec_lang A S i F δ L ∧ finite S) ⟹ finite MN_equiv"
proof (-)
(*goals:
1. ‹finite (A⇧⋆ // ≡⇩M⇩N) ⟹ ∃S F i δ. reach_det_aut_rec_lang A S i F δ L ∧ finite S›
2. ‹∃S F i δ. det_aut_rec_lang A S i F δ L ∧ finite S ⟹ finite (A⇧⋆ // ≡⇩M⇩N)›*)
assume A_0: "finite MN_equiv" (*‹finite ((A::'alpha set)⇧⋆ // ≡⇩M⇩N)›*)
have H_0: "reach_det_aut_rec_lang A MN_equiv MN_init_state MN_fin_states δ⇩M⇩N L"
using triv_G_lang.syntact_aut_is_reach_aut_rec_lang (*‹reach_det_G_aut_rec_lang (A::'alpha set) (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N (singleton_group undefined) (λx::?'a∈{undefined}. 𝟭⇘BijGroup A⇙) (triv_act.induced_quot_map (A⇧⋆) (triv_act.induced_star_map A (λx::?'a∈{undefined}. 𝟭⇘BijGroup A⇙)) ≡⇩M⇩N) (L::'alpha list set)›*) apply (clarsimp simp add: reach_det_G_aut_rec_lang_def (*‹reach_det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ∧ reach_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ›*) det_G_aut_rec_lang_def (*‹det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ det_aut_rec_lang ?A ?S ?i ?F ?δ ?L›*) reach_det_aut_rec_lang_def (*‹reach_det_aut_rec_lang ?A ?S ?i ?F ?δ ?L ≡ reach_det_aut ?A ?S ?i ?F ?δ ∧ det_aut_rec_lang ?A ?S ?i ?F ?δ ?L›*) reach_det_aut_def (*‹reach_det_aut ?A ?S ?i ?F ?δ ≡ det_aut ?A ?S ?i ?F ?δ ∧ reach_det_aut_axioms ?A ?S ?i ?δ›*) reach_det_aut_axioms_def (*‹reach_det_aut_axioms ?A ?S ?i ?δ ≡ ∀s. s ∈ ?S ⟶ (∃input∈?A⇧⋆. (?δ⇧⋆) ?i input = s)›*) det_G_aut_def (*‹det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ (det_aut ?A ?S ?i ?F ?δ ∧ alt_grp_act ?G ?A ?φ ∧ alt_grp_act ?G ?S ?ψ) ∧ eq_var_subset ?G ?S ?ψ ?F ∧ eq_var_subset ?G ?S ?ψ {?i} ∧ eq_var_func ?G (?S × ?A) (λg∈carrier ?G. λ(s, a)∈?S × ?A. (?ψ g s, ?φ g a)) ?S ?ψ (λ(s, a)∈?S × ?A. ?δ s a)›*))
(*goal: ‹reach_det_aut_rec_lang A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N L›*)
by (smt (z3) alt_natural_map_MN_def (*‹[?w::'alpha::type list]⇩M⇩N = ≡⇩M⇩N `` {?w}›*) quotientE (*‹⟦(?X::?'a::type set) ∈ (?A::?'a::type set) // (?r::(?'a::type × ?'a::type) set); ⋀x::?'a::type. ⟦?X = ?r `` {x}; x ∈ ?A⟧ ⟹ ?P::bool⟧ ⟹ ?P›*) triv_G_lang.MN_unique_init_state (*‹(?w::'alpha::type list) ∈ (A::'alpha::type set)⇧⋆ ⟹ [?w]⇩M⇩N = (δ⇩M⇩N⇧⋆) MN_init_state ?w›*))
show "∃S F:: 'alpha list set set. ∃i :: 'alpha list set. ∃δ.
reach_det_aut_rec_lang A S i F δ L ∧ finite S"
using A_0 (*‹finite (A⇧⋆ // ≡⇩M⇩N)›*) H_0 (*‹reach_det_aut_rec_lang A (A⇧⋆ // ≡⇩M⇩N) MN_init_state MN_fin_states δ⇩M⇩N L›*) by auto
next
(*goal: ‹∃S F i δ. det_aut_rec_lang A S i F δ L ∧ finite S ⟹ finite (A⇧⋆ // ≡⇩M⇩N)›*)
assume A_0: "∃S F:: 's set. ∃i :: 's. ∃δ. det_aut_rec_lang A S i F δ L ∧ finite S" (*‹∃(S::'s set) (F::'s set) (i::'s) δ::'s ⇒ 'alpha ⇒ 's. det_aut_rec_lang (A::'alpha set) S i F δ (L::'alpha list set) ∧ finite S›*)
obtain S :: "'s set" and F :: "'s set" and i :: 's and δ where H_MN: "det_aut_rec_lang A S i F δ L ∧ finite S"
(*goal: ‹(⋀(S::'s::type set) (i::'s::type) (F::'s::type set) δ::'s::type ⇒ 'alpha::type ⇒ 's::type. det_aut_rec_lang (A::'alpha::type set) S i F δ (L::'alpha::type list set) ∧ finite S ⟹ thesis::bool) ⟹ thesis›*)
using A_0 (*‹∃(S::'s set) (F::'s set) (i::'s) δ::'s ⇒ 'alpha ⇒ 's. det_aut_rec_lang (A::'alpha set) S i F δ (L::'alpha list set) ∧ finite S›*) by auto
have H_0: "det_G_aut A S i F δ triv_G (λx∈{undefined}. 𝟭⇘BijGroup A⇙)
(λx∈{undefined}. 𝟭⇘BijGroup S⇙)"
apply (rule det_aut.triv_G_aut[of A S i F δ triv_G] (*‹⟦det_aut (A::'alpha set) (S::'s set) (i::'s) (F::'s set) (δ::'s ⇒ 'alpha ⇒ 's); triv_G = singleton_group undefined⟧ ⟹ det_G_aut A S i F δ triv_G (λx::?'b1∈{undefined}. 𝟭⇘BijGroup A⇙) (λx::?'b1∈{undefined}. 𝟭⇘BijGroup S⇙)›*))
(*goal: ‹det_G_aut A S i F δ triv_G (λx∈{undefined}. 𝟭⇘BijGroup A⇙) (λx∈{undefined}. 𝟭⇘BijGroup S⇙)›*)
using H_MN (*‹det_aut_rec_lang A S i F δ L ∧ finite S›*)
(*goals:
1. ‹det_aut A S i F δ›
2. ‹triv_G = singleton_group undefined›
discuss goal 1*)
apply (simp add: det_aut_rec_lang_def (*‹det_aut_rec_lang ?A ?S ?i ?F ?δ ?L ≡ det_aut ?A ?S ?i ?F ?δ ∧ language ?A ?L ∧ det_aut_rec_lang_axioms ?A ?i ?F ?δ ?L›*))
(*discuss goal 2*)
apply (rule triv_G_def (*‹triv_G = singleton_group undefined›*))
(*proven 2 subgoals*) .
have H_1: "det_G_aut_rec_lang A S i F δ triv_G (λx∈{undefined}. 𝟭⇘BijGroup A⇙)
(λx∈{undefined}. 𝟭⇘BijGroup S⇙) L"
by (auto simp add: det_G_aut_rec_lang_def (*‹det_G_aut_rec_lang (?A::?'alpha::type set) (?S::?'states::type set) (?i::?'states::type) (?F::?'states::type set) (?δ::?'states::type ⇒ ?'alpha::type ⇒ ?'states::type) (?G::(?'grp, ?'b) monoid_scheme) (?φ::?'grp::type ⇒ ?'alpha::type ⇒ ?'alpha::type) (?ψ::?'grp::type ⇒ ?'states::type ⇒ ?'states::type) (?L::?'alpha::type list set) ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ det_aut_rec_lang ?A ?S ?i ?F ?δ ?L›*) H_0 (*‹det_G_aut (A::'alpha::type set) (S::'s::type set) (i::'s::type) (F::'s::type set) (δ::'s::type ⇒ 'alpha::type ⇒ 's::type) triv_G (λx::?'a2::type∈{undefined}. 𝟭⇘BijGroup A⇙) (λx::?'a2::type∈{undefined}. 𝟭⇘BijGroup S⇙)›*) H_MN (*‹det_aut_rec_lang (A::'alpha::type set) (S::'s::type set) (i::'s::type) (F::'s::type set) (δ::'s::type ⇒ 'alpha::type ⇒ 's::type) (L::'alpha::type list set) ∧ finite S›*))
have H_2: "(∃S F:: 's set. ∃i :: 's. ∃δ ψ.
det_G_aut_rec_lang A S i F δ (singleton_group undefined) (λx∈{undefined}. 𝟭⇘BijGroup A⇙)
ψ L ∧ finite (orbits (singleton_group undefined) S ψ))"
using H_1 (*‹det_G_aut_rec_lang A S i F δ triv_G (λx∈{undefined}. 𝟭⇘BijGroup A⇙) (λx∈{undefined}. 𝟭⇘BijGroup S⇙) L›*) by (metis H_MN (*‹det_aut_rec_lang A S i F δ L ∧ finite S›*) fin_triv_orbs (*‹finite (orbits (singleton_group undefined) ?S (λx∈{undefined}. 𝟭⇘BijGroup ?S⇙)) = finite ?S›*) triv_G_def (*‹triv_G = singleton_group undefined›*))
have H_3: "finite (orbits triv_G A triv_act)"
apply (subst triv_G_def (*‹triv_G = singleton_group undefined›*))
(*goal: ‹finite (orbits triv_G A triv_act)›*)
apply (subst triv_act_def (*‹triv_act = (λx∈{undefined}. 𝟭⇘BijGroup A⇙)›*))
(*goal: ‹finite (orbits (singleton_group undefined) A triv_act)›*)
apply (subst fin_triv_orbs[of A] (*‹finite (orbits (singleton_group undefined) A (λx∈{undefined}. 𝟭⇘BijGroup A⇙)) = finite A›*))
(*goal: ‹finite (orbits (singleton_group undefined) (A::'alpha::type set) (λx::'a::type∈{undefined}. 𝟭⇘BijGroup A⇙))›*)
by (rule H_fin_alph (*‹finite (A::'alpha::type set)›*))
have H_4: "finite (orbits triv_G MN_equiv (triv_act.induced_quot_map (A⇧⋆)
(triv_act.induced_star_map A triv_act) ≡⇩M⇩N))"
using H_3 (*‹finite (orbits triv_G A triv_act)›*) apply (simp add: triv_G_def (*‹triv_G = singleton_group undefined›*) triv_act_def (*‹triv_act = (λx∈{undefined}. 𝟭⇘BijGroup A⇙)›*) del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹triv_act.induced_star_map ?X ?func = (λg∈carrier (singleton_group undefined). restrict (map (?func g)) (?X⇧⋆))› ‹triv_act.induced_quot_map ?S ?func ?R = (λg∈carrier (singleton_group undefined). λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*))
(*goal: ‹finite (orbits triv_G ((A::'alpha set)⇧⋆ // ≡⇩M⇩N) (triv_act.induced_quot_map (A⇧⋆) (triv_act.induced_star_map A triv_act) ≡⇩M⇩N))›*)
using triv_G_lang.G_Myhill_Nerode (*‹⟦finite (orbits (singleton_group undefined) A (λx∈{undefined}. 𝟭⇘BijGroup A⇙)); finite (orbits (singleton_group undefined) (A⇧⋆ // ≡⇩M⇩N) (triv_act.induced_quot_map (A⇧⋆) (triv_act.induced_star_map A (λx∈{undefined}. 𝟭⇘BijGroup A⇙)) ≡⇩M⇩N))⟧ ⟹ ∃S F i δ ψ. reach_det_G_aut_rec_lang A S i F δ (singleton_group undefined) (λx∈{undefined}. 𝟭⇘BijGroup A⇙) ψ L ∧ finite (orbits (singleton_group undefined) S ψ)› ‹⟦finite (orbits (singleton_group undefined) A (λx∈{undefined}. 𝟭⇘BijGroup A⇙)); ∃S F i δ ψ. det_G_aut_rec_lang A S i F δ (singleton_group undefined) (λx∈{undefined}. 𝟭⇘BijGroup A⇙) ψ L ∧ finite (orbits (singleton_group undefined) S ψ)⟧ ⟹ finite (orbits (singleton_group undefined) (A⇧⋆ // ≡⇩M⇩N) (triv_act.induced_quot_map (A⇧⋆) (triv_act.induced_star_map A (λx∈{undefined}. 𝟭⇘BijGroup A⇙)) ≡⇩M⇩N))›*) H_2 (*‹∃(S::'s set) (F::'s set) (i::'s) (δ::'s ⇒ 'alpha ⇒ 's) ψ::?'a4 ⇒ 's ⇒ 's. det_G_aut_rec_lang (A::'alpha set) S i F δ (singleton_group undefined) (λx::?'a4∈{undefined}. 𝟭⇘BijGroup A⇙) ψ (L::'alpha list set) ∧ finite (orbits (singleton_group undefined) S ψ)›*) by blast
have H_5: "triv_act.induced_star_map A triv_act = (λx ∈ {undefined}. 𝟭⇘BijGroup (A⇧⋆)⇙)"
apply (simp add: BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) triv_act_def (*‹triv_act = (λx∈{undefined}. 𝟭⇘BijGroup A⇙)›*))
(*goal: ‹triv_act.induced_star_map A triv_act = (λx∈{undefined}. 𝟭⇘BijGroup (A⇧⋆)⇙)›*)
by (clarsimp simp add: list.map_ident_strong (*‹(⋀z. z ∈ set ?t ⟹ ?f z = z) ⟹ map ?f ?t = ?t›*))
have H_6: "(triv_act.induced_quot_map (A⇧⋆) (triv_act.induced_star_map A
triv_act) ≡⇩M⇩N) = (λx ∈ {undefined}. 𝟭⇘BijGroup MN_equiv⇙)"
apply (subst H_5 (*‹triv_act.induced_star_map A triv_act = (λx∈{undefined}. 𝟭⇘BijGroup (A⇧⋆)⇙)›*))
(*goal: ‹triv_act.induced_quot_map (A⇧⋆) (triv_act.induced_star_map A triv_act) ≡⇩M⇩N = (λx∈{undefined}. 𝟭⇘BijGroup (A⇧⋆ // ≡⇩M⇩N)⇙)›*)
apply (simp add: BijGroup_def (*‹BijGroup (?S::?'a set) = ⦇carrier = Bij ?S, mult = λg::?'a ⇒ ?'a∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx::?'a∈?S. x⦈›*) fun_eq_iff (*‹((?f::?'a ⇒ ?'b) = (?g::?'a ⇒ ?'b)) = (∀x::?'a. ?f x = ?g x)›*) Image_def (*‹(?r::(?'a × ?'b) set) `` (?s::?'a set) = {y::?'b. ∃x::?'a∈?s. (x, y) ∈ ?r}›*))
(*goal: ‹triv_act.induced_quot_map (A⇧⋆) (λx∈{undefined}. 𝟭⇘BijGroup (A⇧⋆)⇙) ≡⇩M⇩N = (λx∈{undefined}. 𝟭⇘BijGroup (A⇧⋆ // ≡⇩M⇩N)⇙)›*)
apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*); rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*); intro impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹∀x::'alpha list set. ((SOME z::'alpha list. z ∈ x) ∈ (A::'alpha set)⇧⋆ ⟶ x ∈ A⇧⋆ // ≡⇩M⇩N ⟶ {y::'alpha list. (SOME z::'alpha list. z ∈ x, y) ∈ ≡⇩M⇩N} = x) ∧ ((SOME z::'alpha list. z ∈ x) ∉ A⇧⋆ ⟶ x ∈ A⇧⋆ // ≡⇩M⇩N ⟶ {y::'alpha list. (undefined, y) ∈ ≡⇩M⇩N} = x)›*)
apply (smt (verit) Collect_cong (*‹(⋀x. ?P x = ?Q x) ⟹ {x. ?P x} = {x. ?Q x}›*) Collect_mem_eq (*‹{x. x ∈ ?A} = ?A›*) Eps_cong (*‹(⋀x. ?P x = ?Q x) ⟹ Eps ?P = Eps ?Q›*) MN_rel_equival (*‹equiv (A⇧⋆) ≡⇩M⇩N›*) equiv_Eps_in (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ (SOME x. x ∈ ?X) ∈ ?X›*) in_quotient_imp_closed (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r; ?x ∈ ?X; (?x, ?y) ∈ ?r⟧ ⟹ ?y ∈ ?X›*) quotient_eq_iff (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r; ?Y ∈ ?A // ?r; ?x ∈ ?X; ?y ∈ ?Y⟧ ⟹ (?X = ?Y) = ((?x, ?y) ∈ ?r)›*))
(*top goal: ‹⋀x. ⟦(SOME z. z ∈ x) ∈ A⇧⋆; x ∈ A⇧⋆ // ≡⇩M⇩N⟧ ⟹ {y. (SOME z. z ∈ x, y) ∈ ≡⇩M⇩N} = x› and 1 goal remains*)
using MN_rel_equival (*‹equiv ((A::'alpha set)⇧⋆) ≡⇩M⇩N›*) equiv_Eps_preserves (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ (SOME x. x ∈ ?X) ∈ ?A›*) by auto
show "finite MN_equiv"
apply (subst fin_triv_orbs [symmetric] (*‹finite ?S = finite (orbits (singleton_group undefined) ?S (λx∈{undefined}. 𝟭⇘BijGroup ?S⇙))›*))
(*goal: ‹finite (A⇧⋆ // ≡⇩M⇩N)›*)
apply (subst H_6 [symmetric] (*‹(λx∈{undefined}. 𝟭⇘BijGroup (A⇧⋆ // ≡⇩M⇩N)⇙) = triv_act.induced_quot_map (A⇧⋆) (triv_act.induced_star_map A triv_act) ≡⇩M⇩N›*))
(*goal: ‹finite (orbits (singleton_group undefined) (A⇧⋆ // ≡⇩M⇩N) (λx∈{undefined}. 𝟭⇘BijGroup (A⇧⋆ // ≡⇩M⇩N)⇙))›*)
apply (subst triv_G_def [symmetric] (*‹singleton_group undefined = triv_G›*))
(*goal: ‹finite (orbits (singleton_group undefined) ((A::'alpha set)⇧⋆ // ≡⇩M⇩N) (triv_act.induced_quot_map (A⇧⋆) (triv_act.induced_star_map A triv_act) ≡⇩M⇩N))›*)
by (rule H_4 (*‹finite (orbits triv_G (A⇧⋆ // ≡⇩M⇩N) (triv_act.induced_quot_map (A⇧⋆) (triv_act.induced_star_map A triv_act) ≡⇩M⇩N))›*))
qed
end
section ‹
Myhill-Nerode Theorem for Nominal $G$-Automata
›
subsection ‹
Data Symmetries, Supports and Nominal Actions
›
text ‹
The following locale corresponds to the definition 2.2 from \cite{bojanczyk2014automata}.
Note that we let $G$ be an arbitrary group instead of a subgroup of \texttt{BijGroup} $D$,
but assume there is a homomoprhism $\pi: G \to \texttt{BijGroup} D$.
By \texttt{group\_hom.img\_is\_subgroup} this is an equivalent definition:
›
locale data_symm = group_action G D π
for
G :: "('grp, 'b) monoid_scheme" and
D :: "'D set" ("𝔻") and
π
text ‹
The following locales corresponds to definition 4.3 from \cite{bojanczyk2014automata}:
›
locale supports = data_symm G D π + alt_grp_act G X φ
for
G :: "('grp, 'b) monoid_scheme" and
D :: "'D set" ("𝔻") and
π and
X :: "'X set" (structure) and
φ +
fixes
C :: "'D set" and
x :: "'X"
assumes
is_in_set:
"x ∈ X" and
is_subset:
"C ⊆ 𝔻" and
supports:
"g ∈ carrier G ⟹ (∀c. c ∈ C ⟶ π g c = c) ⟹ g ⊙⇘φ⇙ x = x"
begin
text ‹
The following lemma corresponds to lemma 4.9 from \cite{bojanczyk2014automata}:
›
lemma image_supports:
"⋀g. g ∈ carrier G ⟹ supports G D π X φ (π g ` C) (g ⊙⇘φ⇙ x)"
proof (-)
(*goal: ‹⋀g. g ∈ carrier G ⟹ supports G 𝔻 π X φ (π g ` C) (g ⊙⇘φ⇙ x)›*)
fix g
assume A_0: "g ∈ carrier G" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*)
have H_0: "⋀h. data_symm G 𝔻 π ⟹
group_action G X φ ⟹
x ∈ X ⟹
C ⊆ 𝔻 ⟹
∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x ⟹
h ∈ carrier G ⟹ ∀c. c ∈ π g ` C ⟶ π h c = c ⟹
φ h (φ g x) = φ g x"
proof (-)
(*goal: ‹⋀h. ⟦data_symm G 𝔻 π; group_action G X φ; x ∈ X; C ⊆ 𝔻; ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x; h ∈ carrier G; ∀c. c ∈ π g ` C ⟶ π h c = c⟧ ⟹ φ h (φ g x) = φ g x›*)
fix h
assume A1_0: "data_symm G 𝔻 π" and A1_1: "group_action G X φ" and A1_2: "∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x" and A1_3: "h ∈ carrier G" and A1_4: "∀c. c ∈ π g ` C ⟶ π h c = c" (*‹data_symm (G::('grp, 'b) monoid_scheme) 𝔻 (π::'grp ⇒ 'D ⇒ 'D)› ‹group_action (G::('grp, 'b) monoid_scheme) X (φ::'grp ⇒ 'X ⇒ 'X)› ‹∀g::'grp. g ∈ carrier (G::('grp, 'b) monoid_scheme) ⟶ (∀c::'D. c ∈ (C::'D set) ⟶ (π::'grp ⇒ 'D ⇒ 'D) g c = c) ⟶ (φ::'grp ⇒ 'X ⇒ 'X) g (x::'X) = x› ‹(h::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹∀c::'D. c ∈ (π::'grp ⇒ 'D ⇒ 'D) (g::'grp) ` (C::'D set) ⟶ π (h::'grp) c = c›*)
have H1_0: "⋀g. g ∈ carrier G ⟹ (∀c. c ∈ C ⟶ π g c = c) ⟹ φ g x = x"
using A1_2 (*‹∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x›*) by auto
have H1_1: "∀c. c ∈ C ⟶ π ((inv⇘G⇙ g) ⊗⇘G⇙ h ⊗⇘G⇙ g) c = c ⟹
φ ((inv⇘G⇙ g) ⊗⇘G⇙ h ⊗⇘G⇙ g) x = x"
apply (rule H1_0[of "((inv⇘G⇙ g) ⊗⇘G⇙ h ⊗⇘G⇙ g)"] (*‹⟦inv⇘G⇙ (g::'grp::type) ⊗⇘G⇙ (h::'grp::type) ⊗⇘G::('grp, 'b) monoid_scheme⇙ g ∈ carrier G; ∀c::'D::type. c ∈ (C::'D::type set) ⟶ (π::'grp::type ⇒ 'D::type ⇒ 'D::type) (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) c = c⟧ ⟹ (φ::'grp::type ⇒ 'X::type ⇒ 'X::type) (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) (x::'X::type) = x›*))
(*goals:
1. ‹∀c. c ∈ C ⟶ π (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) c = c ⟹ inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g ∈ carrier G›
2. ‹∀c. c ∈ C ⟶ π (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) c = c ⟹ ∀c. c ∈ C ⟶ π (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) c = c›
discuss goal 1*)
apply (meson A_0 (*‹(g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A1_3 (*‹(h::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) group.subgroupE( (*‹⟦Group.group (?G::(?'a, ?'b) monoid_scheme); subgroup (?H::?'a::type set) ?G; (?a::?'a::type) ∈ ?H⟧ ⟹ inv⇘?G⇙ ?a ∈ ?H›*) 3) group.subgroup_self (*‹Group.group (?G::(?'a, ?'b) monoid_scheme) ⟹ subgroup (carrier ?G) ?G›*) group_hom (*‹group_hom (G::('grp, 'b) monoid_scheme) (BijGroup X) (φ::'grp::type ⇒ 'X::type ⇒ 'X::type)›*) group_hom.axioms( (*‹group_hom (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a::type ⇒ ?'c::type) ⟹ Group.group ?G›*) 1) subgroup.m_closed (*‹⟦subgroup (?H::?'a::type set) (?G::(?'a, ?'b) monoid_scheme); (?x::?'a::type) ∈ ?H; (?y::?'a::type) ∈ ?H⟧ ⟹ ?x ⊗⇘?G⇙ ?y ∈ ?H›*))
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
have H2: "π (((inv⇘G⇙ g) ⊗⇘G⇙ h) ⊗⇘G⇙ g) = compose 𝔻 (π ((inv⇘G⇙ g) ⊗⇘G⇙ h)) (π g)"
using A1_0 (*‹data_symm G 𝔻 π›*) apply (clarsimp simp add: data_symm_def (*‹data_symm ?G ?D ?π ≡ group_action ?G ?D ?π›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*))
(*goal: ‹π (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) = compose 𝔻 (π (inv⇘G⇙ g ⊗⇘G⇙ h)) (π g)›*)
apply (rule meta_mp[of "π g ∈ Bij 𝔻 ∧ π ((inv⇘G⇙ g) ⊗⇘G⇙ h) ∈ Bij 𝔻"] (*‹⟦π g ∈ Bij 𝔻 ∧ π (inv⇘G⇙ g ⊗⇘G⇙ h) ∈ Bij 𝔻 ⟹ PROP ?Q; π g ∈ Bij 𝔻 ∧ π (inv⇘G⇙ g ⊗⇘G⇙ h) ∈ Bij 𝔻⟧ ⟹ PROP ?Q›*))
(*goal: ‹⟦Group.group G; Group.group ⦇carrier = Bij 𝔻, mult = λx. if x ∈ Bij 𝔻 then λxa. if xa ∈ Bij 𝔻 then compose 𝔻 x xa else undefined else undefined, one = λx. if x ∈ 𝔻 then x else undefined⦈; π ∈ carrier G → Bij 𝔻; ∀x∈carrier G. ∀y∈carrier G. π (x ⊗⇘G⇙ y) = (if π x ∈ Bij 𝔻 then λxa. if xa ∈ Bij 𝔻 then compose 𝔻 (π x) xa else undefined else undefined) (π y)⟧ ⟹ π (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) = compose 𝔻 (π (inv⇘G⇙ g ⊗⇘G⇙ h)) (π g)›*)
apply (smt (verit) A_0 (*‹g ∈ carrier G›*) A1_3 (*‹h ∈ carrier G›*) data_symm.axioms (*‹data_symm ?G ?D ?π ⟹ group_action ?G ?D ?π›*) data_symm_axioms (*‹data_symm G 𝔻 π›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group.surj_const_mult (*‹⟦Group.group ?G; ?a ∈ carrier ?G⟧ ⟹ (⊗⇘?G⇙) ?a ` carrier ?G = carrier ?G›*) group_action.bij_prop0 (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G⟧ ⟹ ?φ ?g ∈ Bij ?E›*) image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*))
(*top goal: ‹⟦Group.group (G::('grp, 'b) monoid_scheme); Group.group ⦇carrier = Bij 𝔻, mult = λx::'D::type ⇒ 'D::type. if x ∈ Bij 𝔻 then λxa::'D::type ⇒ 'D::type. if xa ∈ Bij 𝔻 then compose 𝔻 x xa else undefined else undefined, one = λx::'D::type. if x ∈ 𝔻 then x else undefined⦈; (π::'grp::type ⇒ 'D::type ⇒ 'D::type) ∈ carrier G → Bij 𝔻; ∀x::'grp::type∈carrier G. ∀y::'grp::type∈carrier G. π (x ⊗⇘G⇙ y) = (if π x ∈ Bij 𝔻 then λxa::'D::type ⇒ 'D::type. if xa ∈ Bij 𝔻 then compose 𝔻 (π x) xa else undefined else undefined) (π y); π (g::'grp::type) ∈ Bij 𝔻 ∧ π (inv⇘G⇙ g ⊗⇘G⇙ (h::'grp::type)) ∈ Bij 𝔻⟧ ⟹ π (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) = compose 𝔻 (π (inv⇘G⇙ g ⊗⇘G⇙ h)) (π g)› and 1 goal remains*)
apply (rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹⟦Group.group G; Group.group ⦇carrier = Bij 𝔻, mult = λx. if x ∈ Bij 𝔻 then λxa. if xa ∈ Bij 𝔻 then compose 𝔻 x xa else undefined else undefined, one = λx. if x ∈ 𝔻 then x else undefined⦈; π ∈ carrier G → Bij 𝔻; ∀x∈carrier G. ∀y∈carrier G. π (x ⊗⇘G⇙ y) = (if π x ∈ Bij 𝔻 then λxa. if xa ∈ Bij 𝔻 then compose 𝔻 (π x) xa else undefined else undefined) (π y)⟧ ⟹ π g ∈ Bij 𝔻 ∧ π (inv⇘G⇙ g ⊗⇘G⇙ h) ∈ Bij 𝔻›*)
using A_0 (*‹g ∈ carrier G›*)
(*goals:
1. ‹⟦Group.group G; Group.group ⦇carrier = Bij 𝔻, mult = λx. if x ∈ Bij 𝔻 then λxa. if xa ∈ Bij 𝔻 then compose 𝔻 x xa else undefined else undefined, one = λx. if x ∈ 𝔻 then x else undefined⦈; π ∈ carrier G → Bij 𝔻; ∀x∈carrier G. ∀y∈carrier G. π (x ⊗⇘G⇙ y) = (if π x ∈ Bij 𝔻 then λxa. if xa ∈ Bij 𝔻 then compose 𝔻 (π x) xa else undefined else undefined) (π y)⟧ ⟹ π g ∈ Bij 𝔻›
2. ‹⟦Group.group G; Group.group ⦇carrier = Bij 𝔻, mult = λx. if x ∈ Bij 𝔻 then λxa. if xa ∈ Bij 𝔻 then compose 𝔻 x xa else undefined else undefined, one = λx. if x ∈ 𝔻 then x else undefined⦈; π ∈ carrier G → Bij 𝔻; ∀x∈carrier G. ∀y∈carrier G. π (x ⊗⇘G⇙ y) = (if π x ∈ Bij 𝔻 then λxa. if xa ∈ Bij 𝔻 then compose 𝔻 (π x) xa else undefined else undefined) (π y)⟧ ⟹ π (inv⇘G⇙ g ⊗⇘G⇙ h) ∈ Bij 𝔻›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply (meson A_0 (*‹g ∈ carrier G›*) A1_3 (*‹h ∈ carrier G›*) data_symm.axioms (*‹data_symm ?G ?D ?π ⟹ group_action ?G ?D ?π›*) data_symm_axioms (*‹data_symm G 𝔻 π›*) group.subgroupE( (*‹⟦Group.group ?G; subgroup ?H ?G; ?a ∈ ?H⟧ ⟹ inv⇘?G⇙ ?a ∈ ?H›*) 3) group.subgroupE( (*‹⟦Group.group ?G; subgroup ?H ?G; ?a ∈ ?H; ?b ∈ ?H⟧ ⟹ ?a ⊗⇘?G⇙ ?b ∈ ?H›*) 4) group.subgroup_self (*‹Group.group ?G ⟹ subgroup (carrier ?G) ?G›*) group_action.bij_prop0 (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G⟧ ⟹ ?φ ?g ∈ Bij ?E›*))
(*proven 2 subgoals*) .
also (*calculation: ‹π (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) = compose 𝔻 (π (inv⇘G⇙ g ⊗⇘G⇙ h)) (π g)›*) have H1_3: "... = compose 𝔻 (compose 𝔻 (π (inv⇘G⇙ g) ) (π h)) (π g)"
using A1_0 (*‹data_symm G 𝔻 π›*) apply (clarsimp simp add: data_symm_def (*‹data_symm ?G ?D ?π ≡ group_action ?G ?D ?π›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*))
(*goal: ‹compose 𝔻 (π (inv⇘G⇙ g ⊗⇘G⇙ h)) (π g) = compose 𝔻 (compose 𝔻 (π (inv⇘G⇙ g)) (π h)) (π g)›*)
apply (rule meta_mp[of "π (inv⇘G⇙ g) ∈ Bij 𝔻 ∧ π h ∈ Bij 𝔻"] (*‹⟦(π::'grp ⇒ 'D ⇒ 'D) (inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp)) ∈ Bij 𝔻 ∧ π (h::'grp) ∈ Bij 𝔻 ⟹ PROP ?Q::prop; π (inv⇘G⇙ g) ∈ Bij 𝔻 ∧ π h ∈ Bij 𝔻⟧ ⟹ PROP ?Q›*))
(*goal: ‹⟦Group.group G; Group.group ⦇carrier = Bij 𝔻, mult = λx. if x ∈ Bij 𝔻 then λxa. if xa ∈ Bij 𝔻 then compose 𝔻 x xa else undefined else undefined, one = λx. if x ∈ 𝔻 then x else undefined⦈; π ∈ carrier G → Bij 𝔻; ∀x∈carrier G. ∀y∈carrier G. π (x ⊗⇘G⇙ y) = (if π x ∈ Bij 𝔻 then λxa. if xa ∈ Bij 𝔻 then compose 𝔻 (π x) xa else undefined else undefined) (π y)⟧ ⟹ compose 𝔻 (π (inv⇘G⇙ g ⊗⇘G⇙ h)) (π g) = compose 𝔻 (compose 𝔻 (π (inv⇘G⇙ g)) (π h)) (π g)›*)
apply (simp add: A_0 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A1_3 (*‹(h::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*))
(*top goal: ‹⟦Group.group (G::('grp, 'b) monoid_scheme); Group.group ⦇carrier = Bij 𝔻, mult = λx::'D ⇒ 'D. if x ∈ Bij 𝔻 then λxa::'D ⇒ 'D. if xa ∈ Bij 𝔻 then compose 𝔻 x xa else undefined else undefined, one = λx::'D. if x ∈ 𝔻 then x else undefined⦈; (π::'grp ⇒ 'D ⇒ 'D) ∈ carrier G → Bij 𝔻; ∀x::'grp∈carrier G. ∀y::'grp∈carrier G. π (x ⊗⇘G⇙ y) = (if π x ∈ Bij 𝔻 then λxa::'D ⇒ 'D. if xa ∈ Bij 𝔻 then compose 𝔻 (π x) xa else undefined else undefined) (π y); π (inv⇘G⇙ (g::'grp)) ∈ Bij 𝔻 ∧ π (h::'grp) ∈ Bij 𝔻⟧ ⟹ compose 𝔻 (π (inv⇘G⇙ g ⊗⇘G⇙ h)) (π g) = compose 𝔻 (compose 𝔻 (π (inv⇘G⇙ g)) (π h)) (π g)› and 1 goal remains*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹⟦Group.group G; Group.group ⦇carrier = Bij 𝔻, mult = λx. if x ∈ Bij 𝔻 then λxa. if xa ∈ Bij 𝔻 then compose 𝔻 x xa else undefined else undefined, one = λx. if x ∈ 𝔻 then x else undefined⦈; π ∈ carrier G → Bij 𝔻; ∀x∈carrier G. ∀y∈carrier G. π (x ⊗⇘G⇙ y) = (if π x ∈ Bij 𝔻 then λxa. if xa ∈ Bij 𝔻 then compose 𝔻 (π x) xa else undefined else undefined) (π y)⟧ ⟹ π (inv⇘G⇙ g) ∈ Bij 𝔻 ∧ π h ∈ Bij 𝔻›*)
apply (simp add: A_0 (*‹g ∈ carrier G›*) Pi_iff (*‹(?f ∈ Pi ?I ?X) = (∀i∈?I. ?f i ∈ ?X i)›*))
(*top goal: ‹⟦Group.group (G::('grp, 'b) monoid_scheme); Group.group ⦇carrier = Bij 𝔻, mult = λx::'D::type ⇒ 'D::type. if x ∈ Bij 𝔻 then λxa::'D::type ⇒ 'D::type. if xa ∈ Bij 𝔻 then compose 𝔻 x xa else undefined else undefined, one = λx::'D::type. if x ∈ 𝔻 then x else undefined⦈; (π::'grp::type ⇒ 'D::type ⇒ 'D::type) ∈ carrier G → Bij 𝔻; ∀x::'grp::type∈carrier G. ∀y::'grp::type∈carrier G. π (x ⊗⇘G⇙ y) = (if π x ∈ Bij 𝔻 then λxa::'D::type ⇒ 'D::type. if xa ∈ Bij 𝔻 then compose 𝔻 (π x) xa else undefined else undefined) (π y)⟧ ⟹ π (inv⇘G⇙ (g::'grp::type)) ∈ Bij 𝔻› and 1 goal remains*)
using A1_3 (*‹h ∈ carrier G›*) by blast
also (*calculation: ‹π (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) = compose 𝔻 (compose 𝔻 (π (inv⇘G⇙ g)) (π h)) (π g)›*) have H1_4: "... = compose 𝔻 ((π (inv⇘G⇙ g)) ∘ (π h)) (π g)"
using A1_0 (*‹data_symm G 𝔻 π›*) apply (clarsimp simp add: data_symm_def (*‹data_symm ?G ?D ?π ≡ group_action ?G ?D ?π›*) group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*) BijGroup_def (*‹BijGroup ?S = ⦇carrier = Bij ?S, mult = λg∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx∈?S. x⦈›*) comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) group_hom_def (*‹group_hom ?G ?H ?h ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms ?G ?H ?h ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom ?G ?H = {h ∈ carrier ?G → carrier ?H. ∀x∈carrier ?G. ∀y∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*) restrict_def (*‹restrict ?f ?A = (λx. if x ∈ ?A then ?f x else undefined)›*) compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*))
(*goal: ‹compose 𝔻 (compose 𝔻 (π (inv⇘G⇙ g)) (π h)) (π g) = compose 𝔻 (π (inv⇘G⇙ g) ∘ π h) (π g)›*)
using A_0 (*‹g ∈ carrier G›*) A1_3 (*‹h ∈ carrier G›*) by (meson data_symm.axioms (*‹data_symm ?G ?D ?π ⟹ group_action ?G ?D ?π›*) data_symm_axioms (*‹data_symm G 𝔻 π›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group_action.element_image (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?y ∈ ?E›*))
also (*calculation: ‹π (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) = compose 𝔻 (π (inv⇘G⇙ g) ∘ π h) (π g)›*) have H1_5: "... = (λd ∈ 𝔻. ((π (inv⇘G⇙ g)) ∘ (π h) ∘ (π g)) d)"
by (simp add: compose_def (*‹compose ?A ?g ?f = (λx∈?A. ?g (?f x))›*))
have H1_6: "⋀c. c ∈ C ⟹ ((π h) ∘ (π g)) c = (π g) c"
using A1_4 (*‹∀c::'D. c ∈ (π::'grp ⇒ 'D ⇒ 'D) (g::'grp) ` (C::'D set) ⟶ π (h::'grp) c = c›*) by auto
have H1_7: "⋀c. c ∈ C ⟹ ((π (inv⇘G⇙ g)) ∘ (π h) ∘ (π g)) c = c"
using H1_6 (*‹?c1 ∈ C ⟹ (π h ∘ π g) ?c1 = π g ?c1›*) A1_0 (*‹data_symm G 𝔻 π›*) apply (simp add: data_symm_def (*‹data_symm (?G::(?'grp, ?'b) monoid_scheme) (?D::?'D set) (?π::?'grp ⇒ ?'D ⇒ ?'D) ≡ group_action ?G ?D ?π›*) group_action_def (*‹group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c set) (?φ::?'a ⇒ ?'c ⇒ ?'c) ≡ group_hom ?G (BijGroup ?E) ?φ›*) BijGroup_def (*‹BijGroup (?S::?'a set) = ⦇carrier = Bij ?S, mult = λg::?'a ⇒ ?'a∈Bij ?S. restrict (compose ?S g) (Bij ?S), one = λx::?'a∈?S. x⦈›*) compose_def (*‹compose (?A::?'a set) (?g::?'b ⇒ ?'c) (?f::?'a ⇒ ?'b) = (λx::?'a∈?A. ?g (?f x))›*) group_hom_def (*‹group_hom (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ≡ Group.group ?G ∧ Group.group ?H ∧ group_hom_axioms ?G ?H ?h›*) group_hom_axioms_def (*‹group_hom_axioms (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ≡ ?h ∈ hom ?G ?H›*) hom_def (*‹hom (?G::(?'a, ?'c) monoid_scheme) (?H::(?'b, ?'d) monoid_scheme) = {h::?'a ⇒ ?'b ∈ carrier ?G → carrier ?H. ∀x::?'a∈carrier ?G. ∀y::?'a∈carrier ?G. h (x ⊗⇘?G⇙ y) = h x ⊗⇘?H⇙ h y}›*))
(*goal: ‹⋀c. c ∈ C ⟹ (π (inv⇘G⇙ g) ∘ π h ∘ π g) c = c›*)
by (meson A_0 (*‹g ∈ carrier G›*) data_symm.axioms (*‹data_symm ?G ?D ?π ⟹ group_action ?G ?D ?π›*) data_symm_axioms (*‹data_symm G 𝔻 π›*) group_action.orbit_sym_aux (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?φ (inv⇘?G⇙ ?g) ?y = ?x›*) is_subset (*‹C ⊆ 𝔻›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*))
have H1_8: "∀c. c ∈ C ⟶ π ((inv⇘G⇙ g) ⊗⇘G⇙ h ⊗⇘G⇙ g) c = c"
using H1_7 (*‹(?c1::'D::type) ∈ (C::'D::type set) ⟹ ((π::'grp::type ⇒ 'D::type ⇒ 'D::type) (inv⇘G::('grp, 'b) monoid_scheme⇙ (g::'grp::type)) ∘ π (h::'grp::type) ∘ π g) ?c1 = ?c1›*) H1_5 (*‹compose 𝔻 (π (inv⇘G⇙ g) ∘ π h) (π g) = restrict (π (inv⇘G⇙ g) ∘ π h ∘ π g) 𝔻›*) by (metis calculation (*‹π (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) = compose 𝔻 (π (inv⇘G⇙ g) ∘ π h) (π g)›*) is_subset (*‹C ⊆ 𝔻›*) restrict_apply' (*‹?x ∈ ?A ⟹ restrict ?f ?A ?x = ?f ?x›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*))
have H1_9: "φ ((inv⇘G⇙ g) ⊗⇘G⇙ h ⊗⇘G⇙ g) x = x"
using H1_8 (*‹∀c. c ∈ C ⟶ π (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) c = c›*) by (simp add: H1_1 (*‹∀c. c ∈ C ⟶ π (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) c = c ⟹ φ (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) x = x›*))
hence H1_10: "φ ((inv⇘G⇙ g) ⊗⇘G⇙ h ⊗⇘G⇙ g) x = φ ((inv⇘G⇙ g) ⊗⇘G⇙ (h ⊗⇘G⇙ g)) x"
by (smt (verit, ccfv_SIG) A_0 (*‹g ∈ carrier G›*) A1_3 (*‹h ∈ carrier G›*) group.inv_closed (*‹⟦Group.group ?G; ?x ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group.subgroupE( (*‹⟦Group.group ?G; subgroup ?H ?G; ?a ∈ ?H; ?b ∈ ?H⟧ ⟹ ?a ⊗⇘?G⇙ ?b ∈ ?H›*) 4) group.subgroup_self (*‹Group.group ?G ⟹ subgroup (carrier ?G) ?G›*) group_action.composition_rule (*‹⟦group_action ?G ?E ?φ; ?x ∈ ?E; ?g1.0 ∈ carrier ?G; ?g2.0 ∈ carrier ?G⟧ ⟹ ?φ (?g1.0 ⊗⇘?G⇙ ?g2.0) ?x = ?φ ?g1.0 (?φ ?g2.0 ?x)›*) group_action.element_image (*‹⟦group_action ?G ?E ?φ; ?g ∈ carrier ?G; ?x ∈ ?E; ?φ ?g ?x = ?y⟧ ⟹ ?y ∈ ?E›*) group_action_axioms (*‹group_action G X φ›*) group_hom (*‹group_hom G (BijGroup X) φ›*) group_hom.axioms( (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) 1) is_in_set (*‹x ∈ X›*))
have H1_11: "... = ((φ (inv⇘G⇙ g)) ∘ (φ (h ⊗⇘G⇙ g))) x"
using A_0 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A1_3 (*‹h ∈ carrier G›*) group.subgroupE(4) (*‹⟦Group.group ?G; subgroup ?H ?G; ?a ∈ ?H; ?b ∈ ?H⟧ ⟹ ?a ⊗⇘?G⇙ ?b ∈ ?H›*) group.subgroup_self (*‹Group.group ?G ⟹ subgroup (carrier ?G) ?G›*) group_action.composition_rule (*‹⟦group_action ?G ?E ?φ; ?x ∈ ?E; ?g1.0 ∈ carrier ?G; ?g2.0 ∈ carrier ?G⟧ ⟹ ?φ (?g1.0 ⊗⇘?G⇙ ?g2.0) ?x = ?φ ?g1.0 (?φ ?g2.0 ?x)›*) group_action_axioms (*‹group_action G X φ›*) group_hom (*‹group_hom G (BijGroup X) φ›*) group_hom.axioms(1) (*‹group_hom ?G ?H ?h ⟹ Group.group ?G›*) is_in_set (*‹x ∈ X›*) by fastforce
have H1_12: "... = ((the_inv_into X (φ g)) ∘ (φ (h ⊗⇘G⇙ g))) x"
using A1_1 (*‹group_action G X φ›*) apply (simp add: group_action_def (*‹group_action ?G ?E ?φ ≡ group_hom ?G (BijGroup ?E) ?φ›*))
(*goal: ‹(φ (inv⇘G⇙ g) ∘ φ (h ⊗⇘G⇙ g)) x = (the_inv_into X (φ g) ∘ φ (h ⊗⇘G⇙ g)) x›*)
by (smt (verit) A_0 (*‹(g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) A1_3 (*‹(h::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) group.inv_closed (*‹⟦Group.group (?G::(?'a, ?'b) monoid_scheme); (?x::?'a::type) ∈ carrier ?G⟧ ⟹ inv⇘?G⇙ ?x ∈ carrier ?G›*) group.subgroupE( (*‹⟦Group.group (?G::(?'a, ?'b) monoid_scheme); subgroup (?H::?'a::type set) ?G; (?a::?'a::type) ∈ ?H; (?b::?'a::type) ∈ ?H⟧ ⟹ ?a ⊗⇘?G⇙ ?b ∈ ?H›*) 4) group.subgroup_self (*‹Group.group (?G::(?'a, ?'b) monoid_scheme) ⟹ subgroup (carrier ?G) ?G›*) group_action.element_image (*‹⟦group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c::type set) (?φ::?'a::type ⇒ ?'c::type ⇒ ?'c::type); (?g::?'a::type) ∈ carrier ?G; (?x::?'c::type) ∈ ?E; ?φ ?g ?x = (?y::?'c::type)⟧ ⟹ ?y ∈ ?E›*) group_action.inj_prop (*‹⟦group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c::type set) (?φ::?'a::type ⇒ ?'c::type ⇒ ?'c::type); (?g::?'a::type) ∈ carrier ?G⟧ ⟹ inj_on (?φ ?g) ?E›*) group_action.orbit_sym_aux (*‹⟦group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c::type set) (?φ::?'a::type ⇒ ?'c::type ⇒ ?'c::type); (?g::?'a::type) ∈ carrier ?G; (?x::?'c::type) ∈ ?E; ?φ ?g ?x = (?y::?'c::type)⟧ ⟹ ?φ (inv⇘?G⇙ ?g) ?y = ?x›*) group_action_axioms (*‹group_action (G::('grp, 'b) monoid_scheme) X (φ::'grp::type ⇒ 'X::type ⇒ 'X::type)›*) group_hom.axioms( (*‹group_hom (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a::type ⇒ ?'c::type) ⟹ Group.group ?G›*) 1) is_in_set (*‹(x::'X::type) ∈ X›*) the_inv_into_f_f (*‹⟦inj_on (?f::?'a::type ⇒ ?'b::type) (?A::?'a::type set); (?x::?'a::type) ∈ ?A⟧ ⟹ the_inv_into ?A ?f (?f ?x) = ?x›*))
have H1_13: "((the_inv_into X (φ g)) ∘ (φ (h ⊗⇘G⇙ g))) x = x"
using H1_9 (*‹φ (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) x = x›*) H1_10 (*‹φ (inv⇘G⇙ g ⊗⇘G⇙ h ⊗⇘G⇙ g) x = φ (inv⇘G⇙ g ⊗⇘G⇙ (h ⊗⇘G⇙ g)) x›*) H1_11 (*‹φ (inv⇘G⇙ g ⊗⇘G⇙ (h ⊗⇘G⇙ g)) x = (φ (inv⇘G⇙ g) ∘ φ (h ⊗⇘G⇙ g)) x›*) H1_12 (*‹(φ (inv⇘G⇙ g) ∘ φ (h ⊗⇘G⇙ g)) x = (the_inv_into X (φ g) ∘ φ (h ⊗⇘G⇙ g)) x›*) by auto
hence H1_14: "(φ (h ⊗⇘G⇙ g)) x = φ g x"
using H1_13 (*‹(the_inv_into X (φ g) ∘ φ (h ⊗⇘G⇙ g)) x = x›*) by (metis A_0 (*‹g ∈ carrier G›*) A1_3 (*‹h ∈ carrier G›*) comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) composition_rule (*‹⟦?x ∈ X; ?g1.0 ∈ carrier G; ?g2.0 ∈ carrier G⟧ ⟹ φ (?g1.0 ⊗⇘G⇙ ?g2.0) ?x = φ ?g1.0 (φ ?g2.0 ?x)›*) element_image (*‹⟦?g ∈ carrier G; ?x ∈ X; φ ?g ?x = ?y⟧ ⟹ ?y ∈ X›*) f_the_inv_into_f (*‹⟦inj_on ?f ?A; ?y ∈ ?f ` ?A⟧ ⟹ ?f (the_inv_into ?A ?f ?y) = ?y›*) inj_prop (*‹?g ∈ carrier G ⟹ inj_on (φ ?g) X›*) is_in_set (*‹x ∈ X›*) surj_prop (*‹?g ∈ carrier G ⟹ φ ?g ` X = X›*))
show "φ h (φ g x) = φ g x"
using A1_3 (*‹h ∈ carrier G›*) A1_2 (*‹∀g::'grp. g ∈ carrier (G::('grp, 'b) monoid_scheme) ⟶ (∀c::'D. c ∈ (C::'D set) ⟶ (π::'grp ⇒ 'D ⇒ 'D) g c = c) ⟶ (φ::'grp ⇒ 'X ⇒ 'X) g (x::'X) = x›*) A_0 (*‹g ∈ carrier G›*) H1_14 (*‹φ (h ⊗⇘G⇙ g) x = φ g x›*) composition_rule (*‹⟦?x ∈ X; ?g1.0 ∈ carrier G; ?g2.0 ∈ carrier G⟧ ⟹ φ (?g1.0 ⊗⇘G⇙ ?g2.0) ?x = φ ?g1.0 (φ ?g2.0 ?x)›*) by (simp add: is_in_set (*‹x ∈ X›*))
qed
show "supports G D π X φ (π g ` C) (g ⊙⇘φ⇙ x)"
using supports_axioms (*‹supports G 𝔻 π X φ C x›*) apply (clarsimp simp add: supports_def (*‹supports ?G ?D ?π ?X ?φ ?C ?x ≡ data_symm ?G ?D ?π ∧ alt_grp_act ?G ?X ?φ ∧ supports_axioms ?G ?D ?π ?X ?φ ?C ?x›*) supports_axioms_def (*‹supports_axioms ?G ?D ?π ?X ?φ ?C ?x ≡ ?x ∈ ?X ∧ ?C ⊆ ?D ∧ (∀g. g ∈ carrier ?G ⟶ (∀c. c ∈ ?C ⟶ ?π g c = c) ⟶ g ⊙⇘?φ⇙ ?x = ?x)›*))
(*goal: ‹supports G 𝔻 π X φ (π g ` C) (g ⊙⇘φ⇙ x)›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹⟦data_symm G 𝔻 π; group_action G X φ; x ∈ X; C ⊆ 𝔻; ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x⟧ ⟹ φ g x ∈ X ∧ π g ` C ⊆ 𝔻 ∧ (∀ga. ga ∈ carrier G ⟶ (∀c. c ∈ π g ` C ⟶ π ga c = c) ⟶ φ ga (φ g x) = φ g x)›*)
using element_image (*‹⟦?g ∈ carrier G; ?x ∈ X; φ ?g ?x = ?y⟧ ⟹ ?y ∈ X›*) is_in_set (*‹(x::'X) ∈ X›*) A_0 (*‹g ∈ carrier G›*)
(*goals:
1. ‹⟦data_symm G 𝔻 π; group_action G X φ; x ∈ X; C ⊆ 𝔻; ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x⟧ ⟹ φ g x ∈ X›
2. ‹⟦data_symm G 𝔻 π; group_action G X φ; x ∈ X; C ⊆ 𝔻; ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x⟧ ⟹ π g ` C ⊆ 𝔻›
3. ‹⟦data_symm G 𝔻 π; group_action G X φ; x ∈ X; C ⊆ 𝔻; ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x⟧ ⟹ ∀ga. ga ∈ carrier G ⟶ (∀c. c ∈ π g ` C ⟶ π ga c = c) ⟶ φ ga (φ g x) = φ g x›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply (metis A_0 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) data_symm_def (*‹data_symm (?G::(?'grp, ?'b) monoid_scheme) (?D::?'D set) (?π::?'grp ⇒ ?'D ⇒ ?'D) ≡ group_action ?G ?D ?π›*) group_action.surj_prop (*‹⟦group_action (?G::(?'a, ?'b) monoid_scheme) (?E::?'c set) (?φ::?'a ⇒ ?'c ⇒ ?'c); (?g::?'a) ∈ carrier ?G⟧ ⟹ ?φ ?g ` ?E = ?E›*) image_mono (*‹(?A::?'a set) ⊆ (?B::?'a set) ⟹ (?f::?'a ⇒ ?'b) ` ?A ⊆ ?f ` ?B›*) is_subset (*‹(C::'D set) ⊆ 𝔻›*))
(*discuss goal 3*)
apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*))
(*goal: ‹⟦data_symm G 𝔻 π; group_action G X φ; x ∈ X; C ⊆ 𝔻; ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x⟧ ⟹ ∀ga. ga ∈ carrier G ⟶ (∀c. c ∈ π g ` C ⟶ π ga c = c) ⟶ φ ga (φ g x) = φ g x›*)
apply (intro impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀ga. ⟦data_symm G 𝔻 π; group_action G X φ; x ∈ X; C ⊆ 𝔻; ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x⟧ ⟹ ga ∈ carrier G ⟶ (∀c. c ∈ π g ` C ⟶ π ga c = c) ⟶ φ ga (φ g x) = φ g x›*)
apply (rename_tac h)
(*goal: ‹⋀ga. ⟦data_symm G 𝔻 π; group_action G X φ; x ∈ X; C ⊆ 𝔻; ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x; ga ∈ carrier G; ∀c. c ∈ π g ` C ⟶ π ga c = c⟧ ⟹ φ ga (φ g x) = φ g x›*)
apply (simp add: H_0 (*‹⟦data_symm G 𝔻 π; group_action G X φ; x ∈ X; C ⊆ 𝔻; ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x; ?h1 ∈ carrier G; ∀c. c ∈ π g ` C ⟶ π ?h1 c = c⟧ ⟹ φ ?h1 (φ g x) = φ g x›*))
(*proven 3 subgoals*) .
qed
end
locale nominal = data_symm G D π + alt_grp_act G X φ
for
G :: "('grp, 'b) monoid_scheme" and
D :: "'D set" ("𝔻") and
π and
X :: "'X set" (structure) and
φ +
assumes
is_nominal:
"⋀g x. g ∈ carrier G ⟹ x ∈ X ⟹ ∃C. C ⊆ 𝔻 ∧ finite C ∧ supports G 𝔻 π X φ C x"
locale nominal_det_G_aut = det_G_aut +
nominal G D π A φ + nominal G D π S ψ
for
D :: "'D set" ("𝔻") and
π
text ‹
The following lemma corresponds to lemma 4.8 from \cite{bojanczyk2014automata}:
›
lemma (in eq_var_func) supp_el_pres:
"supports G D π X φ C x ⟹ supports G D π Y ψ C (f x)"
apply (clarsimp simp add: supports_def (*‹supports ?G ?D ?π ?X ?φ ?C ?x ≡ data_symm ?G ?D ?π ∧ alt_grp_act ?G ?X ?φ ∧ supports_axioms ?G ?D ?π ?X ?φ ?C ?x›*) supports_axioms_def (*‹supports_axioms ?G ?D ?π ?X ?φ ?C ?x ≡ ?x ∈ ?X ∧ ?C ⊆ ?D ∧ (∀g. g ∈ carrier ?G ⟶ (∀c. c ∈ ?C ⟶ ?π g c = c) ⟶ g ⊙⇘?φ⇙ ?x = ?x)›*))
(*goal: ‹supports G D π X φ C x ⟹ supports G D π Y ψ C (f x)›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹⟦data_symm G D π; group_action G X φ; x ∈ X; C ⊆ D; ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x⟧ ⟹ group_action G Y ψ ∧ f x ∈ Y ∧ (∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ ψ g (f x) = f x)›*)
using eq_var_func_axioms (*‹eq_var_func G X φ Y ψ f›*) apply (simp add: eq_var_func_def (*‹eq_var_func (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'Y set) (?ψ::?'grp ⇒ ?'Y ⇒ ?'Y) (?f::?'X ⇒ ?'Y) ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*) eq_var_func_axioms_def (*‹eq_var_func_axioms (?G::(?'grp, ?'b) monoid_scheme) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?Y::?'Y set) (?ψ::?'grp ⇒ ?'Y ⇒ ?'Y) (?f::?'X ⇒ ?'Y) ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀(a::?'X) g::?'grp. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*))
(*top goal: ‹⟦data_symm G D π; group_action G X φ; x ∈ X; C ⊆ D; ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x⟧ ⟹ group_action G Y ψ› and 1 goal remains*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹⟦data_symm (G::('grp, 'b) monoid_scheme) (D::'a::type set) (π::'grp::type ⇒ 'a::type ⇒ 'a::type); group_action G (X::'X::type set) (φ::'grp::type ⇒ 'X::type ⇒ 'X::type); (x::'X::type) ∈ X; (C::'a::type set) ⊆ D; ∀g::'grp::type. g ∈ carrier G ⟶ (∀c::'a::type. c ∈ C ⟶ π g c = c) ⟶ φ g x = x⟧ ⟹ (f::'X::type ⇒ 'Y::type) x ∈ (Y::'Y::type set) ∧ (∀g::'grp::type. g ∈ carrier G ⟶ (∀c::'a::type. c ∈ C ⟶ π g c = c) ⟶ (ψ::'grp::type ⇒ 'Y::type ⇒ 'Y::type) g (f x) = f x)›*)
using is_ext_func_bet (*‹f ∈ X →⇩E Y›*)
(*goals:
1. ‹⟦data_symm G D π; group_action G X φ; x ∈ X; C ⊆ D; ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x⟧ ⟹ f x ∈ Y›
2. ‹⟦data_symm G D π; group_action G X φ; x ∈ X; C ⊆ D; ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x⟧ ⟹ ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ ψ g (f x) = f x›
discuss goal 1*)
apply blast
(*discuss goal 2*)
apply clarify
(*goal: ‹⟦data_symm G D π; group_action G X φ; x ∈ X; C ⊆ D; ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ φ g x = x⟧ ⟹ ∀g. g ∈ carrier G ⟶ (∀c. c ∈ C ⟶ π g c = c) ⟶ ψ g (f x) = f x›*)
apply (metis is_eq_var_func' (*‹⟦?a ∈ X; ?g ∈ carrier G⟧ ⟹ f (φ ?g ?a) = ψ ?g (f ?a)›*))
(*proven 2 subgoals*) .
lemma (in nominal) support_union_lem:
fixes f sup_C col
assumes H_f: "f = (λx. (SOME C. C ⊆ 𝔻 ∧ finite C ∧ supports G 𝔻 π X φ C x))"
and H_col: "col ⊆ X ∧ finite col"
and H_sup_C: "sup_C = ⋃{Cx. Cx ∈ f ` col}"
shows "⋀x. x ∈ col ⟹ sup_C ⊆ 𝔻 ∧ finite sup_C ∧ supports G 𝔻 π X φ sup_C x"
proof (-)
(*goal: ‹⋀x::'X. x ∈ (col::'X set) ⟹ (sup_C::'D set) ⊆ 𝔻 ∧ finite sup_C ∧ supports (G::('grp, 'b) monoid_scheme) 𝔻 (π::'grp ⇒ 'D ⇒ 'D) X (φ::'grp ⇒ 'X ⇒ 'X) sup_C x›*)
fix x
assume A_0: "x ∈ col" (*‹(x::'X) ∈ (col::'X set)›*)
have H_0: "⋀x. x ∈ X ⟹ ∃C. C ⊆ 𝔻 ∧ finite C ∧ supports G 𝔻 π X φ C x"
using nominal_axioms (*‹nominal G 𝔻 π X φ›*) apply (clarsimp simp add: nominal_def (*‹nominal (?G::(?'grp, ?'b) monoid_scheme) (?D::?'D set) (?π::?'grp ⇒ ?'D ⇒ ?'D) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) ≡ data_symm ?G ?D ?π ∧ alt_grp_act ?G ?X ?φ ∧ nominal_axioms ?G ?D ?π ?X ?φ›*) nominal_axioms_def (*‹nominal_axioms (?G::(?'grp, ?'b) monoid_scheme) (?D::?'D set) (?π::?'grp ⇒ ?'D ⇒ ?'D) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) ≡ ∀(g::?'grp) x::?'X. g ∈ carrier ?G ⟶ x ∈ ?X ⟶ (∃C⊆?D. finite C ∧ supports ?G ?D ?π ?X ?φ C x)›*))
(*goal: ‹⋀x. x ∈ X ⟹ ∃C⊆𝔻. finite C ∧ supports G 𝔻 π X φ C x›*)
using stabilizer_one_closed (*‹(?x::'X) ∈ X ⟹ 𝟭⇘G::('grp, 'b) monoid_scheme⇙ ∈ stabilizer G (φ::'grp ⇒ 'X ⇒ 'X) ?x›*) stabilizer_subset (*‹stabilizer G φ ?x ⊆ carrier G›*) by blast
have H_1: "⋀x. x ∈ col ⟹ f x ⊆ 𝔻 ∧ finite (f x) ∧ supports G 𝔻 π X φ (f x) x"
apply (subst H_f (*‹f = (λx. SOME C. C ⊆ 𝔻 ∧ finite C ∧ supports G 𝔻 π X φ C x)›*))
(*goal: ‹⋀x. x ∈ col ⟹ f x ⊆ 𝔻 ∧ finite (f x) ∧ supports G 𝔻 π X φ (f x) x›*)
using someI_ex (*‹∃x. ?P x ⟹ ?P (SOME x. ?P x)›*) H_col (*‹col ⊆ X ∧ finite col›*) H_f (*‹f = (λx. SOME C. C ⊆ 𝔻 ∧ finite C ∧ supports G 𝔻 π X φ C x)›*) H_0 (*‹?x1 ∈ X ⟹ ∃C⊆𝔻. finite C ∧ supports G 𝔻 π X φ C ?x1›*) by (metis (no_types, lifting) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*))
have H_2: "sup_C ⊆ 𝔻"
using H_1 (*‹?x1 ∈ col ⟹ f ?x1 ⊆ 𝔻 ∧ finite (f ?x1) ∧ supports G 𝔻 π X φ (f ?x1) ?x1›*) by (simp add: H_sup_C (*‹sup_C = ⋃ {Cx. Cx ∈ f ` col}›*) UN_least (*‹(⋀x. x ∈ ?A ⟹ ?B x ⊆ ?C) ⟹ ⋃ (?B ` ?A) ⊆ ?C›*))
have H_3: "finite sup_C"
using H_1 (*‹?x1 ∈ col ⟹ f ?x1 ⊆ 𝔻 ∧ finite (f ?x1) ∧ supports G 𝔻 π X φ (f ?x1) ?x1›*) H_col (*‹col ⊆ X ∧ finite col›*) H_sup_C (*‹sup_C = ⋃ {Cx. Cx ∈ f ` col}›*) by simp
have H_4: "f x ⊆ sup_C"
using H_1 (*‹?x1 ∈ col ⟹ f ?x1 ⊆ 𝔻 ∧ finite (f ?x1) ∧ supports G 𝔻 π X φ (f ?x1) ?x1›*) H_sup_C (*‹sup_C = ⋃ {Cx. Cx ∈ f ` col}›*) A_0 (*‹x ∈ col›*) by blast
have H_5: "⋀g c. ⟦g ∈ carrier G; (c ∈ sup_C ⟶ π g c = c); c ∈ (f x)⟧ ⟹ π g c = c"
using H_4 (*‹f x ⊆ sup_C›*) H_1 (*‹?x1 ∈ col ⟹ f ?x1 ⊆ 𝔻 ∧ finite (f ?x1) ∧ supports G 𝔻 π X φ (f ?x1) ?x1›*) A_0 (*‹(x::'X) ∈ (col::'X set)›*) by (auto simp add: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*) supports_def (*‹supports ?G ?D ?π ?X ?φ ?C ?x ≡ data_symm ?G ?D ?π ∧ alt_grp_act ?G ?X ?φ ∧ supports_axioms ?G ?D ?π ?X ?φ ?C ?x›*) supports_axioms_def (*‹supports_axioms ?G ?D ?π ?X ?φ ?C ?x ≡ ?x ∈ ?X ∧ ?C ⊆ ?D ∧ (∀g. g ∈ carrier ?G ⟶ (∀c. c ∈ ?C ⟶ ?π g c = c) ⟶ g ⊙⇘?φ⇙ ?x = ?x)›*))
have H_6: "supports G 𝔻 π X φ sup_C x"
apply (simp add: supports_def (*‹supports ?G ?D ?π ?X ?φ ?C ?x ≡ data_symm ?G ?D ?π ∧ alt_grp_act ?G ?X ?φ ∧ supports_axioms ?G ?D ?π ?X ?φ ?C ?x›*) supports_axioms_def (*‹supports_axioms ?G ?D ?π ?X ?φ ?C ?x ≡ ?x ∈ ?X ∧ ?C ⊆ ?D ∧ (∀g. g ∈ carrier ?G ⟶ (∀c. c ∈ ?C ⟶ ?π g c = c) ⟶ g ⊙⇘?φ⇙ ?x = ?x)›*))
(*goal: ‹supports G 𝔻 π X φ sup_C x›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹data_symm G 𝔻 π ∧ group_action G X φ ∧ x ∈ X ∧ sup_C ⊆ 𝔻 ∧ (∀g. g ∈ carrier G ⟶ (∀c. c ∈ sup_C ⟶ π g c = c) ⟶ φ g x = x)›*)
apply (simp add: data_symm_axioms (*‹data_symm G 𝔻 π›*))
(*top goal: ‹data_symm G 𝔻 π› and 4 goals remain*)
using A_0 (*‹x ∈ col›*) H_1 (*‹?x1 ∈ col ⟹ f ?x1 ⊆ 𝔻 ∧ finite (f ?x1) ∧ supports G 𝔻 π X φ (f ?x1) ?x1›*) supports.axioms(2) (*‹supports ?G ?D ?π ?X ?φ ?C ?x ⟹ alt_grp_act ?G ?X ?φ›*) apply fastforce
(*top goal: ‹group_action G X φ› and 3 goals remain*)
using H_col (*‹col ⊆ X ∧ finite col›*) A_0 (*‹x ∈ col›*) apply blast
(*top goal: ‹x ∈ X› and 2 goals remain*)
apply (rule H_2 (*‹(sup_C::'D set) ⊆ 𝔻›*))
(*top goal: ‹(sup_C::'D set) ⊆ 𝔻› and 1 goal remains*)
apply clarify
(*goal: ‹∀g. g ∈ carrier G ⟶ (∀c. c ∈ sup_C ⟶ π g c = c) ⟶ φ g x = x›*)
using supports_axioms_def[of G D π X φ sup_C] (*‹supports_axioms (G::('grp, 'b) monoid_scheme) 𝔻 (π::'grp ⇒ 'D ⇒ 'D) X (φ::'grp ⇒ 'X ⇒ 'X) (sup_C::'D set) (?x::'X) ≡ ?x ∈ X ∧ sup_C ⊆ 𝔻 ∧ (∀g::'grp. g ∈ carrier G ⟶ (∀c::'D. c ∈ sup_C ⟶ π g c = c) ⟶ g ⊙⇘φ⇙ ?x = ?x)›*) apply clarsimp
(*goal: ‹⋀g. ⟦g ∈ carrier G; ∀c. c ∈ sup_C ⟶ π g c = c⟧ ⟹ φ g x = x›*)
using H_1 (*‹?x1 ∈ col ⟹ f ?x1 ⊆ 𝔻 ∧ finite (f ?x1) ∧ supports G 𝔻 π X φ (f ?x1) ?x1›*) A_0 (*‹x ∈ col›*) apply (clarsimp simp add: supports_def (*‹supports ?G ?D ?π ?X ?φ ?C ?x ≡ data_symm ?G ?D ?π ∧ alt_grp_act ?G ?X ?φ ∧ supports_axioms ?G ?D ?π ?X ?φ ?C ?x›*) supports_axioms_def (*‹supports_axioms ?G ?D ?π ?X ?φ ?C ?x ≡ ?x ∈ ?X ∧ ?C ⊆ ?D ∧ (∀g. g ∈ carrier ?G ⟶ (∀c. c ∈ ?C ⟶ ?π g c = c) ⟶ g ⊙⇘?φ⇙ ?x = ?x)›*))
(*goal: ‹⋀g. ⟦g ∈ carrier G; ∀c. c ∈ sup_C ⟶ π g c = c; ⋀x. supports_axioms G 𝔻 π X φ sup_C x ≡ x ∈ X ∧ sup_C ⊆ 𝔻 ∧ (∀g. g ∈ carrier G ⟶ (∀c. c ∈ sup_C ⟶ π g c = c) ⟶ φ g x = x)⟧ ⟹ φ g x = x›*)
using A_0 (*‹x ∈ col›*) H_5 (*‹⟦?g1 ∈ carrier G; ?c1 ∈ sup_C ⟶ π ?g1 ?c1 = ?c1; ?c1 ∈ f x⟧ ⟹ π ?g1 ?c1 = ?c1›*) by presburger
show "sup_C ⊆ 𝔻 ∧ finite sup_C ∧ supports G 𝔻 π X φ sup_C x"
using H_2 (*‹(sup_C::'D set) ⊆ 𝔻›*) H_3 (*‹finite sup_C›*) H_6 (*‹supports (G::('grp, 'b) monoid_scheme) 𝔻 (π::'grp::type ⇒ 'D::type ⇒ 'D::type) X (φ::'grp::type ⇒ 'X::type ⇒ 'X::type) (sup_C::'D::type set) (x::'X::type)›*) by auto
qed
lemma (in nominal) set_of_list_nom:
"nominal G D π (X⇧⋆) (φ⇧⋆)"
proof (-)
(*goal: ‹nominal G 𝔻 π (X⇧⋆) (φ⇧⋆)›*)
have H_0: "⋀g x. g ∈ carrier G ⟹ ∀x∈set x. x ∈ X ⟹
∃C⊆𝔻. finite C ∧ supports G 𝔻 π (X⇧⋆) (φ⇧⋆) C x"
proof (-)
(*goal: ‹⋀g x. ⟦g ∈ carrier G; ∀x∈set x. x ∈ X⟧ ⟹ ∃C⊆𝔻. finite C ∧ supports G 𝔻 π (X⇧⋆) (φ⇧⋆) C x›*)
fix g and w
assume A1_0: "g ∈ carrier G" and A1_1: "∀x∈set w. x ∈ X" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹∀x::'X∈set (w::'X list). x ∈ X›*)
have H1_0: "⋀x. x ∈ X ⟹ ∃C⊆𝔻. finite C ∧ supports G 𝔻 π X φ C x"
using A1_0 (*‹g ∈ carrier G›*) is_nominal (*‹⟦?g ∈ carrier G; ?x ∈ X⟧ ⟹ ∃C⊆𝔻. finite C ∧ supports G 𝔻 π X φ C ?x›*) by force
define f where H1_f: "f = (λx. (SOME C. C ⊆ 𝔻 ∧ finite C ∧ supports G 𝔻 π X φ C x))"
define sup_C :: "'D set " where H1_sup_C: "sup_C = ⋃{Cx. Cx ∈ f ` set w}"
have H1_1: "⋀x. x ∈ set w ⟹ sup_C ⊆ 𝔻 ∧ finite sup_C ∧ supports G 𝔻 π X φ sup_C x"
apply (rule support_union_lem[where f = f and col = "set w"] (*‹⟦f = (λx. SOME C. C ⊆ 𝔻 ∧ finite C ∧ supports G 𝔻 π X φ C x); set w ⊆ X ∧ finite (set w); ?sup_C = ⋃ {Cx. Cx ∈ f ` set w}; ?x ∈ set w⟧ ⟹ ?sup_C ⊆ 𝔻 ∧ finite ?sup_C ∧ supports G 𝔻 π X φ ?sup_C ?x›*))
(*goal: ‹⋀x::'X. x ∈ set (w::'X list) ⟹ (sup_C::'D set) ⊆ 𝔻 ∧ finite sup_C ∧ supports (G::('grp, 'b) monoid_scheme) 𝔻 (π::'grp ⇒ 'D ⇒ 'D) X (φ::'grp ⇒ 'X ⇒ 'X) sup_C x›*)
apply (rule H1_f (*‹f = (λx. SOME C. C ⊆ 𝔻 ∧ finite C ∧ supports G 𝔻 π X φ C x)›*))
(*top goal: ‹⋀x. x ∈ set w ⟹ f = (λx. SOME C. C ⊆ 𝔻 ∧ finite C ∧ supports G 𝔻 π X φ C x)› and 3 goals remain*)
using A1_0 (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*)
(*goals:
1. ‹⋀x. x ∈ set w ⟹ set w ⊆ X ∧ finite (set w)›
2. ‹⋀x. x ∈ set w ⟹ sup_C = ⋃ {Cx. Cx ∈ f ` set w}›
3. ‹⋀x. x ∈ set w ⟹ x ∈ set w›
discuss goal 1*)
apply (simp add: A1_1 (*‹∀x∈set w. x ∈ X›*) subset_code( (*‹(set ?xs ⊆ ?B) = (∀x∈set ?xs. x ∈ ?B)›*) 1))
(*discuss goal 2*)
apply (rule H1_sup_C (*‹sup_C = ⋃ {Cx. Cx ∈ f ` set w}›*))
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*) .
have H1_2: "supports G 𝔻 π (X⇧⋆) (φ⇧⋆) sup_C w"
apply (clarsimp simp add: supports_def (*‹supports ?G ?D ?π ?X ?φ ?C ?x ≡ data_symm ?G ?D ?π ∧ alt_grp_act ?G ?X ?φ ∧ supports_axioms ?G ?D ?π ?X ?φ ?C ?x›*) supports_axioms_def (*‹supports_axioms ?G ?D ?π ?X ?φ ?C ?x ≡ ?x ∈ ?X ∧ ?C ⊆ ?D ∧ (∀g. g ∈ carrier ?G ⟶ (∀c. c ∈ ?C ⟶ ?π g c = c) ⟶ g ⊙⇘?φ⇙ ?x = ?x)›*) simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹triv_act.induced_star_map ?X ?func = (λg∈carrier (singleton_group undefined). restrict (map (?func g)) (?X⇧⋆))› ‹triv_act.induced_quot_map ?S ?func ?R = (λg∈carrier (singleton_group undefined). λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (X⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})›*))
(*goal: ‹supports G 𝔻 π (X⇧⋆) (φ⇧⋆) sup_C w›*)
apply (intro conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹data_symm (G::('grp, 'b) monoid_scheme) 𝔻 (π::'grp ⇒ 'D ⇒ 'D) ∧ alt_grp_act G (X⇧⋆) ((φ::'grp ⇒ 'X ⇒ 'X)⇧⋆) ∧ (w::'X list) ∈ X⇧⋆ ∧ (sup_C::'D set) ⊆ 𝔻 ∧ (∀g::'grp. g ∈ carrier G ⟶ (∀c::'D. c ∈ sup_C ⟶ π g c = c) ⟶ g ⊙⇘φ⇧⋆⇙ w = w)›*)
apply (simp add: data_symm_axioms (*‹data_symm G 𝔻 π›*))
(*top goal: ‹data_symm G 𝔻 π› and 4 goals remain*)
using lists_a_Gset (*‹alt_grp_act G (X⇧⋆) (φ⇧⋆)›*) apply ((auto)[1])
(*top goal: ‹alt_grp_act G (X⇧⋆) (φ⇧⋆)› and 3 goals remain*)
apply (simp add: A1_1 (*‹∀x∈set w. x ∈ X›*) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*))
(*top goal: ‹w ∈ X⇧⋆› and 2 goals remain*)
using H1_1 (*‹?x1 ∈ set w ⟹ sup_C ⊆ 𝔻 ∧ finite sup_C ∧ supports G 𝔻 π X φ sup_C ?x1›*) H1_sup_C (*‹sup_C = ⋃ {Cx. Cx ∈ f ` set w}›*) apply blast
(*top goal: ‹sup_C ⊆ 𝔻› and 1 goal remains*)
apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*); intro impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹∀g. g ∈ carrier G ⟶ (∀c. c ∈ sup_C ⟶ π g c = c) ⟶ g ⊙⇘φ⇧⋆⇙ w = w›*)
apply clarsimp
(*goal: ‹⋀g. ⟦g ∈ carrier G; ∀c. c ∈ sup_C ⟶ π g c = c⟧ ⟹ g ⊙⇘φ⇧⋆⇙ w = w›*)
apply (rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹⋀g. ⟦g ∈ carrier G; ∀c. c ∈ sup_C ⟶ π g c = c⟧ ⟹ (w ∈ X⇧⋆ ⟶ map (φ g) w = w) ∧ (w ∉ X⇧⋆ ⟶ undefined = w)›*)
using H1_1 (*‹?x1 ∈ set w ⟹ sup_C ⊆ 𝔻 ∧ finite sup_C ∧ supports G 𝔻 π X φ sup_C ?x1›*) apply -
(*goals:
1. ‹⋀g::'grp. ⟦g ∈ carrier (G::('grp, 'b) monoid_scheme); ∀c::'D. c ∈ (sup_C::'D set) ⟶ (π::'grp ⇒ 'D ⇒ 'D) g c = c; ⋀x::'X. x ∈ set (w::'X list) ⟹ sup_C ⊆ 𝔻 ∧ finite sup_C ∧ supports G 𝔻 π X (φ::'grp ⇒ 'X ⇒ 'X) sup_C x⟧ ⟹ w ∈ X⇧⋆ ⟶ map (φ g) w = w›
2. ‹⋀g::'grp. ⟦g ∈ carrier (G::('grp, 'b) monoid_scheme); ∀c::'D. c ∈ (sup_C::'D set) ⟶ (π::'grp ⇒ 'D ⇒ 'D) g c = c; ⋀x::'X. x ∈ set (w::'X list) ⟹ sup_C ⊆ 𝔻 ∧ finite sup_C ∧ supports G 𝔻 π X (φ::'grp ⇒ 'X ⇒ 'X) sup_C x⟧ ⟹ w ∉ X⇧⋆ ⟶ undefined = w›
discuss goal 1*)
apply ((auto simp add: supports_def (*‹supports ?G ?D ?π ?X ?φ ?C ?x ≡ data_symm ?G ?D ?π ∧ alt_grp_act ?G ?X ?φ ∧ supports_axioms ?G ?D ?π ?X ?φ ?C ?x›*) supports_axioms_def (*‹supports_axioms ?G ?D ?π ?X ?φ ?C ?x ≡ ?x ∈ ?X ∧ ?C ⊆ ?D ∧ (∀g. g ∈ carrier ?G ⟶ (∀c. c ∈ ?C ⟶ ?π g c = c) ⟶ g ⊙⇘?φ⇙ ?x = ?x)›*) map_idI (*‹(⋀x. x ∈ set ?xs ⟹ ?f x = x) ⟹ map ?f ?xs = ?xs›*))[1])
(*discuss goal 2*)
apply ((auto simp add: supports_def (*‹supports ?G ?D ?π ?X ?φ ?C ?x ≡ data_symm ?G ?D ?π ∧ alt_grp_act ?G ?X ?φ ∧ supports_axioms ?G ?D ?π ?X ?φ ?C ?x›*) supports_axioms_def (*‹supports_axioms ?G ?D ?π ?X ?φ ?C ?x ≡ ?x ∈ ?X ∧ ?C ⊆ ?D ∧ (∀g. g ∈ carrier ?G ⟶ (∀c. c ∈ ?C ⟶ ?π g c = c) ⟶ g ⊙⇘?φ⇙ ?x = ?x)›*) map_idI (*‹(⋀x. x ∈ set ?xs ⟹ ?f x = x) ⟹ map ?f ?xs = ?xs›*))[1])
(*proven 2 subgoals*) .
show "∃C⊆𝔻. finite C ∧ supports G 𝔻 π (X⇧⋆) (φ⇧⋆) C w"
using nominal_axioms_def (*‹nominal_axioms ?G ?D ?π ?X ?φ ≡ ∀g x. g ∈ carrier ?G ⟶ x ∈ ?X ⟶ (∃C⊆?D. finite C ∧ supports ?G ?D ?π ?X ?φ C x)›*) apply (clarsimp simp add: nominal_def (*‹nominal ?G ?D ?π ?X ?φ ≡ data_symm ?G ?D ?π ∧ alt_grp_act ?G ?X ?φ ∧ nominal_axioms ?G ?D ?π ?X ?φ›*) simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹triv_act.induced_star_map ?X ?func = (λg∈carrier (singleton_group undefined). restrict (map (?func g)) (?X⇧⋆))› ‹triv_act.induced_quot_map ?S ?func ?R = (λg∈carrier (singleton_group undefined). λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (X⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})›*))
(*goal: ‹∃C⊆𝔻. finite C ∧ supports G 𝔻 π (X⇧⋆) (φ⇧⋆) C w›*)
using H1_1 (*‹?x1 ∈ set w ⟹ sup_C ⊆ 𝔻 ∧ finite sup_C ∧ supports G 𝔻 π X φ sup_C ?x1›*) H1_2 (*‹supports G 𝔻 π (X⇧⋆) (φ⇧⋆) sup_C w›*) by (metis Collect_empty_eq (*‹(Collect (?P::?'a ⇒ bool) = {}) = (∀x::?'a. ¬ ?P x)›*) H1_sup_C (*‹(sup_C::'D set) = ⋃ {Cx::'D set. Cx ∈ (f::'X ⇒ 'D set) ` set (w::'X list)}›*) Union_empty (*‹⋃ {} = {}›*) empty_iff (*‹((?c::?'a) ∈ {}) = False›*) image_empty (*‹(?f::?'b ⇒ ?'a) ` {} = {}›*) infinite_imp_nonempty (*‹infinite (?S::?'a set) ⟹ ?S ≠ {}›*) subset_empty (*‹((?A::?'a set) ⊆ {}) = (?A = {})›*) subset_emptyI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ False) ⟹ ?A ⊆ {}›*) supports.is_subset (*‹supports (?G::(?'grp, ?'b) monoid_scheme) (?D::?'D set) (?π::?'grp ⇒ ?'D ⇒ ?'D) (?X::?'X set) (?φ::?'grp ⇒ ?'X ⇒ ?'X) (?C::?'D set) (?x::?'X) ⟹ ?C ⊆ ?D›*))
qed
show "?thesis"
(*goal: ‹nominal (G::('grp, 'b) monoid_scheme) 𝔻 (π::'grp ⇒ 'D ⇒ 'D) (X⇧⋆) ((φ::'grp ⇒ 'X ⇒ 'X)⇧⋆)›*)
apply (clarsimp simp add: nominal_def (*‹nominal (?G::(?'grp, ?'b) monoid_scheme) (?D::?'D::type set) (?π::?'grp::type ⇒ ?'D::type ⇒ ?'D::type) (?X::?'X::type set) (?φ::?'grp::type ⇒ ?'X::type ⇒ ?'X::type) ≡ data_symm ?G ?D ?π ∧ alt_grp_act ?G ?X ?φ ∧ nominal_axioms ?G ?D ?π ?X ?φ›*) nominal_axioms_def (*‹nominal_axioms (?G::(?'grp, ?'b) monoid_scheme) (?D::?'D::type set) (?π::?'grp::type ⇒ ?'D::type ⇒ ?'D::type) (?X::?'X::type set) (?φ::?'grp::type ⇒ ?'X::type ⇒ ?'X::type) ≡ ∀(g::?'grp::type) x::?'X::type. g ∈ carrier ?G ⟶ x ∈ ?X ⟶ (∃C⊆?D. finite C ∧ supports ?G ?D ?π ?X ?φ C x)›*) simp del: GMN_simps (*‹(⊙⇘?φ::?'grp::type ⇒ ?'X::type ⇒ ?'X::type⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹triv_act.induced_star_map (?X::?'b::type set) (?func::?'a::type ⇒ ?'b::type ⇒ ?'b::type) = (λg::?'a::type∈carrier (singleton_group undefined). restrict (map (?func g)) (?X⇧⋆))› ‹triv_act.induced_quot_map (?S::?'Y::type set) (?func::?'a::type ⇒ ?'Y::type ⇒ ?'Y::type) (?R::(?'Y::type × ?'Y::type) set) = (λg::?'a::type∈carrier (singleton_group undefined). λx::?'Y::type set∈?S // ?R. ?R `` {?func g (SOME z::?'Y::type. z ∈ x)})› ‹(?func::'grp::type ⇒ 'X::type ⇒ 'X::type)⇧⋆ = (λg::'grp::type∈carrier (G::('grp, 'b) monoid_scheme). restrict (map (?func g)) (X⇧⋆))› ‹[?func::'grp::type ⇒ ?'Y::type ⇒ ?'Y::type]⇩?R::(?'Y::type × ?'Y::type) set⇘?S::?'Y::type set⇙ = (λg::'grp::type∈carrier (G::('grp, 'b) monoid_scheme). λx::?'Y::type set∈?S // ?R. ?R `` {?func g (SOME z::?'Y::type. z ∈ x)})›*))
(*goal: ‹nominal (G::('grp, 'b) monoid_scheme) 𝔻 (π::'grp ⇒ 'D ⇒ 'D) (X⇧⋆) ((φ::'grp ⇒ 'X ⇒ 'X)⇧⋆)›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹data_symm (G::('grp, 'b) monoid_scheme) 𝔻 (π::'grp ⇒ 'D ⇒ 'D) ∧ alt_grp_act G (X⇧⋆) ((φ::'grp ⇒ 'X ⇒ 'X)⇧⋆) ∧ ((∃g::'grp. g ∈ carrier G) ⟶ (∀x::'X list. x ∈ X⇧⋆ ⟶ (∃C⊆𝔻. finite C ∧ supports G 𝔻 π (X⇧⋆) (φ⇧⋆) C x)))›*)
using group.subgroupE(2) (*‹⟦Group.group ?G; subgroup ?H ?G⟧ ⟹ ?H ≠ {}›*) group.subgroup_self (*‹Group.group ?G ⟹ subgroup (carrier ?G) ?G›*) group_hom (*‹group_hom G (BijGroup X) φ›*) group_hom.axioms(1) (*‹group_hom (?G::(?'a, ?'b) monoid_scheme) (?H::(?'c, ?'d) monoid_scheme) (?h::?'a ⇒ ?'c) ⟹ Group.group ?G›*)
(*goals:
1. ‹data_symm G 𝔻 π›
2. ‹alt_grp_act G (X⇧⋆) (φ⇧⋆)›
3. ‹(∃g. g ∈ carrier G) ⟶ (∀x. x ∈ X⇧⋆ ⟶ (∃C⊆𝔻. finite C ∧ supports G 𝔻 π (X⇧⋆) (φ⇧⋆) C x))›
discuss goal 1*)
apply (simp add: data_symm_axioms (*‹data_symm G 𝔻 π›*))
(*discuss goal 2*)
apply (rule lists_a_Gset (*‹alt_grp_act (G::('grp, 'b) monoid_scheme) (X⇧⋆) ((φ::'grp ⇒ 'X ⇒ 'X)⇧⋆)›*))
(*discuss goal 3*)
apply clarify
(*goal: ‹(∃g. g ∈ carrier G) ⟶ (∀x. x ∈ X⇧⋆ ⟶ (∃C⊆𝔻. finite C ∧ supports G 𝔻 π (X⇧⋆) (φ⇧⋆) C x))›*)
apply (simp add: H_0 (*‹⟦?g1 ∈ carrier G; ∀x∈set ?x1. x ∈ X⟧ ⟹ ∃C⊆𝔻. finite C ∧ supports G 𝔻 π (X⇧⋆) (φ⇧⋆) C ?x1›*) del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹triv_act.induced_star_map ?X ?func = (λg∈carrier (singleton_group undefined). restrict (map (?func g)) (?X⇧⋆))› ‹triv_act.induced_quot_map ?S ?func ?R = (λg∈carrier (singleton_group undefined). λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (X⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})›*))
(*proven 3 subgoals*) .
qed
subsection ‹
Proving the Myhill-Nerode Theorem for Nominal $G$-Automata
›
context det_G_aut begin
adhoc_overloading
star labels_a_G_set.induced_star_map
end
lemma (in det_G_aut) input_to_init_eqvar:
"eq_var_func G (A⇧⋆) (φ⇧⋆) S ψ (λw∈A⇧⋆. (δ⇧⋆) i w)"
proof (-)
(*goal: ‹eq_var_func G (A⇧⋆) (φ⇧⋆) S ψ (restrict ((δ⇧⋆) i) (A⇧⋆))›*)
have H_0: "⋀a g. ⟦∀x∈set a. x ∈ A; map (φ g) a ∈ A⇧⋆; g ∈ carrier G⟧ ⟹
(δ⇧⋆) i (map (φ g) a) = ψ g ((δ⇧⋆) i a)"
proof (-)
(*goal: ‹⋀(a::'alpha list) g::'grp. ⟦∀x::'alpha∈set a. x ∈ A; map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) g) a ∈ A⇧⋆; g ∈ carrier (G::('grp, 'b) monoid_scheme)⟧ ⟹ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (map (φ g) a) = (ψ::'grp ⇒ 'states ⇒ 'states) g ((δ⇧⋆) i a)›*)
fix w and g
assume A1_0: "∀x∈set w. x ∈ A" and A1_1: "map (φ g) w ∈ A⇧⋆" and A1_2: "g ∈ carrier G" (*‹∀x::'alpha∈set (w::'alpha list). x ∈ A› ‹map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) (g::'grp)) (w::'alpha list) ∈ A⇧⋆› ‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)›*)
have H1_0: "(δ⇧⋆) (ψ g i) (map (φ g) w) = ψ g ((δ⇧⋆) i w)"
using give_input_eq_var (*‹eq_var_func G (A⇧⋆ × S) (λg∈carrier G. λ(w, s)∈A⇧⋆ × S. ((φ⇧⋆) g w, ψ g s)) S ψ (λ(w, s)∈A⇧⋆ × S. (δ⇧⋆) s w)›*) apply (clarsimp simp add: eq_var_func_axioms_def (*‹eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀a g. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*) eq_var_func_def (*‹eq_var_func ?G ?X ?φ ?Y ?ψ ?f ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*))
(*goal: ‹(δ⇧⋆) (ψ g i) (map (φ g) w) = ψ g ((δ⇧⋆) i w)›*)
using A1_0 (*‹∀x∈set w. x ∈ A›*) A1_1 (*‹map (φ g) w ∈ A⇧⋆›*) A1_2 (*‹(g::'grp::type) ∈ carrier (G::('grp, 'b) monoid_scheme)›*) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) is_aut.init_state_is_a_state (*‹i ∈ S›*) states_a_G_set.element_image (*‹⟦?g ∈ carrier G; ?x ∈ S; ψ ?g ?x = ?y⟧ ⟹ ?y ∈ S›*) by (smt (verit, del_insts))
have H1_1: "(ψ g i) = i"
using A1_2 (*‹g ∈ carrier G›*) is_aut.init_state_is_a_state (*‹i ∈ S›*) init_is_eq_var.is_equivar (*‹∀g∈carrier G. ψ g ` {i} = {i}›*) by force
show "(δ⇧⋆) i (map (φ g) w) = ψ g ((δ⇧⋆) i w)"
using H1_0 (*‹(δ⇧⋆) (ψ g i) (map (φ g) w) = ψ g ((δ⇧⋆) i w)›*) H1_1 (*‹ψ g i = i›*) by simp
qed
show "?thesis"
(*goal: ‹eq_var_func G (A⇧⋆) (φ⇧⋆) S ψ (restrict ((δ⇧⋆) i) (A⇧⋆))›*)
apply (clarsimp simp add: eq_var_func_def (*‹eq_var_func ?G ?X ?φ ?Y ?ψ ?f ≡ alt_grp_act ?G ?X ?φ ∧ alt_grp_act ?G ?Y ?ψ ∧ eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f›*) eq_var_func_axioms_def (*‹eq_var_func_axioms ?G ?X ?φ ?Y ?ψ ?f ≡ ?f ∈ ?X →⇩E ?Y ∧ (∀a g. a ∈ ?X ⟶ g ∈ carrier ?G ⟶ ?f (g ⊙⇘?φ⇙ a) = g ⊙⇘?ψ⇙ ?f a)›*))
(*goal: ‹eq_var_func G (A⇧⋆) (φ⇧⋆) S ψ (restrict ((δ⇧⋆) i) (A⇧⋆))›*)
apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹group_action G (A⇧⋆) (λg∈carrier G. restrict (map (φ g)) (A⇧⋆)) ∧ group_action G S ψ ∧ (δ⇧⋆) i ∈ A⇧⋆ → S ∧ (∀a. a ∈ A⇧⋆ ⟶ (∀g. (map (φ g) a ∈ A⇧⋆ ⟶ g ∈ carrier G ⟶ (δ⇧⋆) i (map (φ g) a) = ψ g ((δ⇧⋆) i a)) ∧ (map (φ g) a ∉ A⇧⋆ ⟶ g ∈ carrier G ⟶ undefined = ψ g ((δ⇧⋆) i a))))›*)
using labels_a_G_set.lists_a_Gset (*‹alt_grp_act G (A⇧⋆) (φ⇧⋆)›*) apply fastforce
(*top goal: ‹group_action (G::('grp, 'b) monoid_scheme) (A⇧⋆) (λg::'grp::type∈carrier G. restrict (map ((φ::'grp::type ⇒ 'alpha::type ⇒ 'alpha::type) g)) (A⇧⋆))› and 3 goals remain*)
apply (simp add: states_a_G_set.group_action_axioms (*‹group_action G S ψ›*) del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹triv_act.induced_star_map ?X ?func = (λg∈carrier (singleton_group undefined). restrict (map (?func g)) (?X⇧⋆))› ‹triv_act.induced_quot_map ?S ?func ?R = (λg∈carrier (singleton_group undefined). λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹states_a_G_set.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) (S⇧⋆))› ‹trans_is_eq_var.GA_0.induced_star_map ?func = (λg∈carrier G. restrict (map (?func g)) ((S × A)⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})›*))
(*top goal: ‹group_action G S ψ› and 2 goals remain*)
apply (simp add: in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) is_aut.give_input_closed (*‹⟦?input ∈ A⇧⋆; ?s ∈ S⟧ ⟹ (δ⇧⋆) ?s ?input ∈ S›*) is_aut.init_state_is_a_state (*‹i ∈ S›*))
(*top goal: ‹((δ::'states::type ⇒ 'alpha::type ⇒ 'states::type)⇧⋆) (i::'states::type) ∈ A⇧⋆ → (S::'states::type set)› and 1 goal remains*)
apply clarify
(*goal: ‹∀a. a ∈ A⇧⋆ ⟶ (∀g. (map (φ g) a ∈ A⇧⋆ ⟶ g ∈ carrier G ⟶ (δ⇧⋆) i (map (φ g) a) = ψ g ((δ⇧⋆) i a)) ∧ (map (φ g) a ∉ A⇧⋆ ⟶ g ∈ carrier G ⟶ undefined = ψ g ((δ⇧⋆) i a)))›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); intro impI (*‹(?P::bool ⟹ ?Q::bool) ⟹ ?P ⟶ ?Q›*))
(*goal: ‹⋀(a::'alpha list) g::'grp. ∀x::'alpha∈set a. x ∈ A ⟹ (map ((φ::'grp ⇒ 'alpha ⇒ 'alpha) g) a ∈ A⇧⋆ ⟶ g ∈ carrier (G::('grp, 'b) monoid_scheme) ⟶ ((δ::'states ⇒ 'alpha ⇒ 'states)⇧⋆) (i::'states) (map (φ g) a) = (ψ::'grp ⇒ 'states ⇒ 'states) g ((δ⇧⋆) i a)) ∧ (map (φ g) a ∉ A⇧⋆ ⟶ g ∈ carrier G ⟶ undefined = ψ g ((δ⇧⋆) i a))›*)
apply (simp add: H_0 (*‹⟦∀x∈set ?a1. x ∈ A; map (φ ?g1) ?a1 ∈ A⇧⋆; ?g1 ∈ carrier G⟧ ⟹ (δ⇧⋆) i (map (φ ?g1) ?a1) = ψ ?g1 ((δ⇧⋆) i ?a1)›*))
(*top goal: ‹⋀a g. ⟦∀x∈set a. x ∈ A; map (φ g) a ∈ A⇧⋆; g ∈ carrier G⟧ ⟹ (δ⇧⋆) i (map (φ g) a) = ψ g ((δ⇧⋆) i a)› and 1 goal remains*)
using labels_a_G_set.surj_prop (*‹?g ∈ carrier G ⟹ φ ?g ` A = A›*) by fastforce
qed
lemma (in reach_det_G_aut) input_to_init_surj:
"(λw∈A⇧⋆. (δ⇧⋆) i w) ` (A⇧⋆) = S"
using reach_det_G_aut_axioms (*‹reach_det_G_aut A (S::'states set) (i::'states) (F::'states set) (δ::'states ⇒ 'alpha ⇒ 'states) (G::('grp, 'b) monoid_scheme) (φ::'grp ⇒ 'alpha ⇒ 'alpha) (ψ::'grp ⇒ 'states ⇒ 'states)›*) apply (clarsimp simp add: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*) reach_det_G_aut_def (*‹reach_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ reach_det_aut ?A ?S ?i ?F ?δ›*) reach_det_aut_def (*‹reach_det_aut ?A ?S ?i ?F ?δ ≡ det_aut ?A ?S ?i ?F ?δ ∧ reach_det_aut_axioms ?A ?S ?i ?δ›*) reach_det_aut_axioms_def (*‹reach_det_aut_axioms ?A ?S ?i ?δ ≡ ∀s. s ∈ ?S ⟶ (∃input∈?A⇧⋆. (?δ⇧⋆) ?i input = s)›*))
(*goal: ‹restrict ((δ⇧⋆) i) (A⇧⋆) ` A⇧⋆ = S›*)
using is_aut.give_input_closed (*‹⟦?input ∈ A⇧⋆; ?s ∈ S⟧ ⟹ (δ⇧⋆) ?s ?input ∈ S›*) is_aut.init_state_is_a_state (*‹i ∈ S›*) by blast
context reach_det_G_aut begin
adhoc_overloading
star labels_a_G_set.induced_star_map
end
text ‹
The following lemma corresponds to proposition 5.1 from \cite{bojanczyk2014automata}:
›
proposition (in reach_det_G_aut) alpha_nom_imp_states_nom:
"nominal G D π A φ ⟹ nominal G D π S ψ"
proof (-)
(*goal: ‹nominal G D π A φ ⟹ nominal G D π S ψ›*)
assume A_0: "nominal G D π A φ" (*‹nominal (G::('grp, 'b) monoid_scheme) (D::'a set) (π::'grp ⇒ 'a ⇒ 'a) A (φ::'grp ⇒ 'alpha ⇒ 'alpha)›*)
have H_0: "⋀g x. ⟦g ∈ carrier G; data_symm G D π; group_action G A φ;
∀x. x ∈ A ⟶ (∃C⊆D. finite C ∧ supports G D π A φ C x); x ∈ S⟧
⟹ ∃C⊆D. finite C ∧ supports G D π S ψ C x"
proof (-)
(*goal: ‹⋀g x. ⟦g ∈ carrier G; data_symm G D π; group_action G A φ; ∀x. x ∈ A ⟶ (∃C⊆D. finite C ∧ supports G D π A φ C x); x ∈ S⟧ ⟹ ∃C⊆D. finite C ∧ supports G D π S ψ C x›*)
fix g and s
assume A1_0: "g ∈ carrier G" and A1_1: "data_symm G D π" and A1_2: "group_action G A φ" and A1_3: "∀x. x ∈ A ⟶ (∃C⊆D. finite C ∧ supports G D π A φ C x)" and A1_4: "s ∈ S" (*‹(g::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme)› ‹data_symm (G::('grp, 'b) monoid_scheme) (D::'a set) (π::'grp ⇒ 'a ⇒ 'a)› ‹group_action (G::('grp, 'b) monoid_scheme) A (φ::'grp ⇒ 'alpha ⇒ 'alpha)› ‹∀x::'alpha. x ∈ A ⟶ (∃C⊆D::'a set. finite C ∧ supports (G::('grp, 'b) monoid_scheme) D (π::'grp ⇒ 'a ⇒ 'a) A (φ::'grp ⇒ 'alpha ⇒ 'alpha) C x)› ‹(s::'states) ∈ (S::'states set)›*)
have H1_0: "⋀x. x ∈ (A⇧⋆) ⟹ ∃C⊆D. finite C ∧ supports G D π (A⇧⋆) (φ⇧⋆) C x"
using nominal.set_of_list_nom[of G D π A φ] (*‹nominal G D π A φ ⟹ nominal G D π (A⇧⋆) (φ⇧⋆)›*) A1_2 (*‹group_action G A φ›*) apply (clarsimp simp add: nominal_def (*‹nominal ?G ?D ?π ?X ?φ ≡ data_symm ?G ?D ?π ∧ alt_grp_act ?G ?X ?φ ∧ nominal_axioms ?G ?D ?π ?X ?φ›*))
(*goal: ‹⋀x. x ∈ A⇧⋆ ⟹ ∃C⊆D. finite C ∧ supports G D π (A⇧⋆) (φ⇧⋆) C x›*)
by (metis A1_0 (*‹g ∈ carrier G›*) A1_1 (*‹data_symm G D π›*) A1_3 (*‹∀x. x ∈ A ⟶ (∃C⊆D. finite C ∧ supports G D π A φ C x)›*) in_listsI (*‹∀x∈set ?xs. x ∈ ?A ⟹ ?xs ∈ ?A⇧⋆›*) labels_a_G_set.induced_star_map_def (*‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))›*) nominal_axioms_def (*‹nominal_axioms ?G ?D ?π ?X ?φ ≡ ∀g x. g ∈ carrier ?G ⟶ x ∈ ?X ⟶ (∃C⊆?D. finite C ∧ supports ?G ?D ?π ?X ?φ C x)›*))
define f where H1_f: "f = (λw∈A⇧⋆. (δ⇧⋆) i w)"
obtain w where H1_w0: "s = f w" and H1_w1: "w ∈ (A⇧⋆)"
(*goal: ‹(⋀w. ⟦s = f w; w ∈ A⇧⋆⟧ ⟹ thesis) ⟹ thesis›*)
using input_to_init_surj (*‹restrict ((δ⇧⋆) i) (A⇧⋆) ` A⇧⋆ = S›*) A1_4 (*‹s ∈ S›*) apply (simp add: H1_f (*‹f = restrict ((δ⇧⋆) i) (A⇧⋆)›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))
(*goal: ‹(⋀w. ⟦s = f w; w ∈ A⇧⋆⟧ ⟹ thesis) ⟹ thesis›*)
by (metis is_reachable (*‹?s ∈ S ⟹ ∃input∈A⇧⋆. (δ⇧⋆) i input = ?s›*))
obtain C where H1_C: "finite C ∧ supports G D π (A⇧⋆) (labels_a_G_set.induced_star_map φ) C w"
(*goal: ‹(⋀C. finite C ∧ supports G D π (A⇧⋆) (φ⇧⋆) C w ⟹ thesis) ⟹ thesis›*)
by (meson H1_0 (*‹?x1 ∈ A⇧⋆ ⟹ ∃C⊆D. finite C ∧ supports G D π (A⇧⋆) (φ⇧⋆) C ?x1›*) H1_w0 (*‹s = f w›*) H1_w1 (*‹w ∈ A⇧⋆›*))
have H1_2: "supports G D π S ψ C s"
apply (subst H1_w0 (*‹s = f w›*))
(*goal: ‹supports (G::('grp, 'b) monoid_scheme) (D::'a set) (π::'grp ⇒ 'a ⇒ 'a) (S::'states set) (ψ::'grp ⇒ 'states ⇒ 'states) (C::'a set) (s::'states)›*)
apply (rule eq_var_func.supp_el_pres[where X = "A⇧⋆" and φ = "φ⇧⋆"] (*‹⟦eq_var_func ?G (A⇧⋆) (φ⇧⋆) ?Y ?ψ ?f; supports ?G ?D ?π (A⇧⋆) (φ⇧⋆) ?C ?x⟧ ⟹ supports ?G ?D ?π ?Y ?ψ ?C (?f ?x)›*))
(*goal: ‹supports G D π S ψ C (f w)›*)
apply (subst H1_f (*‹f = restrict ((δ⇧⋆) i) (A⇧⋆)›*))
(*top goal: ‹eq_var_func G (A⇧⋆) (φ⇧⋆) S ψ f› and 1 goal remains*)
apply (rule det_G_aut.input_to_init_eqvar[of A S i F δ G φ ψ] (*‹det_G_aut A S i F δ G φ ψ ⟹ eq_var_func G (A⇧⋆) (φ⇧⋆) S ψ (restrict ((δ⇧⋆) i) (A⇧⋆))›*))
(*top goal: ‹eq_var_func G (A⇧⋆) (φ⇧⋆) S ψ (restrict ((δ⇧⋆) i) (A⇧⋆))› and 1 goal remains*)
using reach_det_G_aut_axioms (*‹reach_det_G_aut A S i F δ G φ ψ›*) apply (simp add: reach_det_G_aut_def (*‹reach_det_G_aut (?A::?'alpha::type set) (?S::?'states::type set) (?i::?'states::type) (?F::?'states::type set) (?δ::?'states::type ⇒ ?'alpha::type ⇒ ?'states::type) (?G::(?'grp, ?'b) monoid_scheme) (?φ::?'grp::type ⇒ ?'alpha::type ⇒ ?'alpha::type) (?ψ::?'grp::type ⇒ ?'states::type ⇒ ?'states::type) ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ reach_det_aut ?A ?S ?i ?F ?δ›*))
(*top goal: ‹det_G_aut A S i F δ G φ ψ› and 1 goal remains*)
using H1_C (*‹finite C ∧ supports G D π (A⇧⋆) (φ⇧⋆) C w›*) by simp
show "∃C⊆D. finite C ∧ supports G D π S ψ C s"
using H1_2 (*‹supports G D π S ψ C s›*) H1_C (*‹finite C ∧ supports G D π (A⇧⋆) (φ⇧⋆) C w›*) by (meson supports.is_subset (*‹supports ?G ?D ?π ?X ?φ ?C ?x ⟹ ?C ⊆ ?D›*))
qed
show "?thesis"
(*goal: ‹nominal G D π S ψ›*)
apply (rule meta_mp[of "(∃g. g ∈ carrier G)"] (*‹⟦∃g. g ∈ carrier G ⟹ PROP ?Q; ∃g. g ∈ carrier G⟧ ⟹ PROP ?Q›*))
(*goal: ‹nominal G D π S ψ›*)
subgoal for
using A_0 (*‹nominal G D π A φ›*) apply (clarsimp simp add: nominal_def (*‹nominal ?G ?D ?π ?X ?φ ≡ data_symm ?G ?D ?π ∧ alt_grp_act ?G ?X ?φ ∧ nominal_axioms ?G ?D ?π ?X ?φ›*) nominal_axioms_def (*‹nominal_axioms ?G ?D ?π ?X ?φ ≡ ∀g x. g ∈ carrier ?G ⟶ x ∈ ?X ⟶ (∃C⊆?D. finite C ∧ supports ?G ?D ?π ?X ?φ C x)›*))
(*goal: ‹∃g::'grp. g ∈ carrier (G::('grp, 'b) monoid_scheme) ⟹ nominal G (D::'a set) (π::'grp ⇒ 'a ⇒ 'a) (S::'states set) (ψ::'grp ⇒ 'states ⇒ 'states)›*)
apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))
(*goal: ‹⋀g. ⟦g ∈ carrier G; data_symm G D π; group_action G A φ; ∀x. x ∈ A ⟶ (∃C⊆D. finite C ∧ supports G D π A φ C x)⟧ ⟹ group_action G S ψ ∧ (∀x. x ∈ S ⟶ (∃C⊆D. finite C ∧ supports G D π S ψ C x))›*)
subgoal for g
by (clarsimp simp add: states_a_G_set.group_action_axioms (*‹group_action G S ψ›*))
apply clarify
(*goal: ‹⋀g. ⟦g ∈ carrier G; data_symm G D π; group_action G A φ; ∀x. x ∈ A ⟶ (∃C⊆D. finite C ∧ supports G D π A φ C x)⟧ ⟹ ∀x. x ∈ S ⟶ (∃C⊆D. finite C ∧ supports G D π S ψ C x)›*)
by (simp add: H_0 (*‹⟦(?g1::'grp) ∈ carrier (G::('grp, 'b) monoid_scheme); data_symm G (D::'a set) (π::'grp ⇒ 'a ⇒ 'a); group_action G A (φ::'grp ⇒ 'alpha ⇒ 'alpha); ∀x::'alpha. x ∈ A ⟶ (∃C⊆D. finite C ∧ supports G D π A φ C x); (?x1::'states) ∈ (S::'states set)⟧ ⟹ ∃C⊆D. finite C ∧ supports G D π S (ψ::'grp ⇒ 'states ⇒ 'states) C ?x1›*))
by (metis bot.extremum_unique (*‹(?a ≤ bot) = (?a = bot)›*) ex_in_conv (*‹(∃x. x ∈ ?A) = (?A ≠ {})›*) is_aut.init_state_is_a_state (*‹i ∈ S›*) states_a_G_set.stabilizer_one_closed (*‹?x ∈ S ⟹ 𝟭⇘G⇙ ∈ stabilizer G ψ ?x›*) states_a_G_set.stabilizer_subset (*‹stabilizer G ψ ?x ⊆ carrier G›*))
qed
text ‹
The following theorem corresponds to theorem 5.2 from \cite{bojanczyk2014automata}:
›
theorem (in G_lang) Nom_G_Myhill_Nerode:
assumes
orb_fin: "finite (orbits G A φ)" and
nom: "nominal G D π A φ"
shows
Nom_G_Myhill_Nerode_LR: "finite (orbits G MN_equiv ([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙)) ⟹
(∃S F :: 'alpha list set set. ∃i :: 'alpha list set. ∃δ. ∃ψ.
reach_det_G_aut_rec_lang A S i F δ G φ ψ L ∧ finite (orbits G S ψ)
∧ nominal_det_G_aut A S i F δ G φ ψ D π)" and
Nom_G_Myhill_Nerode_RL: "(∃S F :: 's set. ∃i :: 's. ∃δ. ∃ψ.
det_G_aut_rec_lang A S i F δ G φ ψ L ∧ finite (orbits G S ψ)
∧ nominal_det_G_aut A S i F δ G φ ψ D π)
⟹ finite (orbits G MN_equiv ([(φ⇧⋆)]⇩≡⇩M⇩N ⇘A⇧⋆⇙))"
proof (-)
(*goals:
1. ‹finite (orbits G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙)) ⟹ ∃S F i δ ψ. reach_det_G_aut_rec_lang A S i F δ G φ ψ L ∧ finite (orbits G S ψ) ∧ nominal_det_G_aut A S i F δ G φ ψ D π›
2. ‹∃S F i δ ψ. det_G_aut_rec_lang A S i F δ G φ ψ L ∧ finite (orbits G S ψ) ∧ nominal_det_G_aut A S i F δ G φ ψ D π ⟹ finite (orbits G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙))›*)
assume A_0: "finite (orbits G MN_equiv ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙))" (*‹finite (orbits (G::('grp, 'b) monoid_scheme) (A⇧⋆ // ≡⇩M⇩N) ([(φ::'grp ⇒ 'alpha ⇒ 'alpha)⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙))›*)
obtain S :: "'alpha list set set" and F :: "'alpha list set set" and i :: "'alpha list set" and δ and ψ where H_MN: "reach_det_G_aut_rec_lang A S i F δ G φ ψ L ∧ finite (orbits G S ψ)"
(*goal: ‹(⋀S i F δ ψ. reach_det_G_aut_rec_lang A S i F δ G φ ψ L ∧ finite (orbits G S ψ) ⟹ thesis) ⟹ thesis›*)
using A_0 (*‹finite (orbits G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙))›*) orb_fin (*‹finite (orbits G A φ)›*) G_Myhill_Nerode_LR (*‹⟦finite (orbits (G::('grp, 'b) monoid_scheme) A (φ::'grp ⇒ 'alpha ⇒ 'alpha)); finite (orbits G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙))⟧ ⟹ ∃(S::'alpha list set set) (F::'alpha list set set) (i::'alpha list set) (δ::'alpha list set ⇒ 'alpha ⇒ 'alpha list set) ψ::'grp ⇒ 'alpha list set ⇒ 'alpha list set. reach_det_G_aut_rec_lang A S i F δ G φ ψ (L::'alpha list set) ∧ finite (orbits G S ψ)›*) by blast
have H_0: "nominal G D π S ψ"
using H_MN (*‹reach_det_G_aut_rec_lang A S i F δ G φ ψ L ∧ finite (orbits G S ψ)›*) apply (clarsimp simp del: GMN_simps (*‹(⊙⇘?φ⇙) ≡ ?φ› ‹alt_grp_act = group_action› ‹triv_act.induced_star_map ?X ?func = (λg∈carrier (singleton_group undefined). restrict (map (?func g)) (?X⇧⋆))› ‹triv_act.induced_quot_map ?S ?func ?R = (λg∈carrier (singleton_group undefined). λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹?func⇧⋆ = (λg∈carrier G. restrict (map (?func g)) (A⇧⋆))› ‹[?func]⇩?R⇘?S⇙ = (λg∈carrier G. λx∈?S // ?R. ?R `` {?func g (SOME z. z ∈ x)})› ‹[?w]⇩M⇩N = ≡⇩M⇩N `` {?w}› ‹δ⇩M⇩N ?W' ?a' = (λ(W, a)∈A⇧⋆ // ≡⇩M⇩N × A. ≡⇩M⇩N `` {(SOME w. w ∈ W) @ [a]}) (?W', ?a')›*) simp add: reach_det_G_aut_rec_lang_def (*‹reach_det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ∧ reach_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ›*))
(*goal: ‹nominal (G::('grp, 'b) monoid_scheme) (D::'a set) (π::'grp ⇒ 'a ⇒ 'a) (S::'alpha list set set) (ψ::'grp ⇒ 'alpha list set ⇒ 'alpha list set)›*)
using nom (*‹nominal G D π A φ›*) reach_det_G_aut.alpha_nom_imp_states_nom (*‹⟦reach_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ; nominal ?G ?D ?π ?A ?φ⟧ ⟹ nominal ?G ?D ?π ?S ?ψ›*) by metis
show "∃S F :: 'alpha list set set. ∃i :: 'alpha list set. ∃δ. ∃ψ.
reach_det_G_aut_rec_lang A S i F δ G φ ψ L ∧
finite (orbits G S ψ) ∧ nominal_det_G_aut A S i F δ G φ ψ D π"
apply (simp add: nominal_det_G_aut_def (*‹nominal_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?D ?π ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ nominal ?G ?D ?π ?A ?φ ∧ nominal ?G ?D ?π ?S ?ψ›*) reach_det_G_aut_rec_lang_def (*‹reach_det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ∧ reach_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ›*))
(*goal: ‹∃S F i δ ψ. reach_det_G_aut_rec_lang A S i F δ G φ ψ L ∧ finite (orbits G S ψ) ∧ nominal_det_G_aut A S i F δ G φ ψ D π›*)
using nom (*‹nominal G D π A φ›*) H_MN (*‹reach_det_G_aut_rec_lang A S i F δ G φ ψ L ∧ finite (orbits G S ψ)›*) H_0 (*‹nominal G D π S ψ›*) apply (clarsimp simp add: reach_det_G_aut_rec_lang_def (*‹reach_det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ≡ det_G_aut_rec_lang ?A ?S ?i ?F ?δ ?G ?φ ?ψ ?L ∧ reach_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ›*) reach_det_G_aut_def (*‹reach_det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ≡ det_G_aut ?A ?S ?i ?F ?δ ?G ?φ ?ψ ∧ reach_det_aut ?A ?S ?i ?F ?δ›*) reach_det_aut_axioms_def (*‹reach_det_aut_axioms ?A ?S ?i ?δ ≡ ∀s. s ∈ ?S ⟶ (∃input∈?A⇧⋆. (?δ⇧⋆) ?i input = s)›*))
(*goal: ‹∃(S::'alpha list set set) (F::'alpha list set set) (i::'alpha list set) (δ::'alpha list set ⇒ 'alpha ⇒ 'alpha list set) ψ::'grp ⇒ 'alpha list set ⇒ 'alpha list set. det_G_aut_rec_lang A S i F δ (G::('grp, 'b) monoid_scheme) (φ::'grp ⇒ 'alpha ⇒ 'alpha) ψ (L::'alpha list set) ∧ reach_det_G_aut A S i F δ G φ ψ ∧ finite (orbits G S ψ) ∧ det_G_aut A S i F δ G φ ψ ∧ nominal G (D::'a set) (π::'grp ⇒ 'a ⇒ 'a) A φ ∧ nominal G D π S ψ›*)
by blast
next
(*goal: ‹∃(S::'s set) (F::'s set) (i::'s) (δ::'s ⇒ 'alpha ⇒ 's) ψ::'grp ⇒ 's ⇒ 's. det_G_aut_rec_lang A S i F δ (G::('grp, 'b) monoid_scheme) (φ::'grp ⇒ 'alpha ⇒ 'alpha) ψ (L::'alpha list set) ∧ finite (orbits G S ψ) ∧ nominal_det_G_aut A S i F δ G φ ψ (D::'a set) (π::'grp ⇒ 'a ⇒ 'a) ⟹ finite (orbits G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙))›*)
assume A0: "∃S F i δ ψ. det_G_aut_rec_lang A S i F δ G φ ψ L ∧ finite (orbits G S ψ)
∧ nominal_det_G_aut A S i F δ G φ ψ D π" (*‹∃(S::'c set) (F::'c set) (i::'c) (δ::'c ⇒ 'alpha ⇒ 'c) ψ::'grp ⇒ 'c ⇒ 'c. det_G_aut_rec_lang A S i F δ (G::('grp, 'b) monoid_scheme) (φ::'grp ⇒ 'alpha ⇒ 'alpha) ψ (L::'alpha list set) ∧ finite (orbits G S ψ) ∧ nominal_det_G_aut A S i F δ G φ ψ (D::'a set) (π::'grp ⇒ 'a ⇒ 'a)›*)
show "finite (orbits G MN_equiv ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙))"
using A0 (*‹∃(S::'c set) (F::'c set) (i::'c) (δ::'c ⇒ 'alpha ⇒ 'c) ψ::'grp ⇒ 'c ⇒ 'c. det_G_aut_rec_lang A S i F δ (G::('grp, 'b) monoid_scheme) (φ::'grp ⇒ 'alpha ⇒ 'alpha) ψ (L::'alpha list set) ∧ finite (orbits G S ψ) ∧ nominal_det_G_aut A S i F δ G φ ψ (D::'a set) (π::'grp ⇒ 'a ⇒ 'a)›*) orb_fin (*‹finite (orbits G A φ)›*) by (meson G_Myhill_Nerode_RL (*‹⟦finite (orbits G A φ); ∃S F i δ ψ. det_G_aut_rec_lang A S i F δ G φ ψ L ∧ finite (orbits G S ψ)⟧ ⟹ finite (orbits G (A⇧⋆ // ≡⇩M⇩N) ([φ⇧⋆]⇩≡⇩M⇩N⇘A⇧⋆⇙))›*))
qed
end | {
"path": "afp-2025-02-12/thys/Nominal_Myhill_Nerode/Nominal_Myhill_Nerode.thy",
"repo": "afp-2025-02-12",
"sha": "7bfc6024b0d5427e02c3ae664fe4bc821257186a36d4d06cce070ba260782d2c"
} |
subsection ‹Monotone Convergence \label{sec:monconv}›
theory MonConv
imports Complex_Main
begin
text ‹A sensible requirement for an integral operator is that it be
``well-behaved'' with respect to limit functions. To become just a
little more
precise, it is expected that the limit operator may be interchanged
with the integral operator under conditions that are as weak as
possible. To this
end, the notion of monotone convergence is introduced and later
applied in the definition of the integral.
In fact, we distinguish three types of monotone convergence here:
There are converging sequences of real numbers, real functions and
sets. Monotone convergence could even be defined more generally for
any type in the axiomatic type class\footnote{For the concept of axiomatic type
classes, see \<^cite>‹"Nipkow93" and "wenzelax"›} ‹ord› of ordered
types like this.
@{prop "mon_conv u f ≡ (∀n. u n ≤ u (Suc n)) ∧ Sup (range u) = f"}
However, this employs the general concept of a least upper bound.
For the special types we have in mind, the more specific
limit --- respective union --- operators are available, combined with many theorems
about their properties. For the type of real- (or rather ordered-) valued functions,
the less-or-equal relation is defined pointwise.
@{thm le_fun_def [no_vars]}
›
(*monotone convergence*)
text ‹Now the foundations are laid for the definition of monotone
convergence. To express the similarity of the different types of
convergence, a single overloaded operator is used.›
consts
mon_conv:: "(nat ⇒ 'a) ⇒ 'a::ord ⇒ bool" ("_↑_" [60,61] 60)
overloading
mon_conv_real ≡ "mon_conv :: _ ⇒ real ⇒ bool"
mon_conv_real_fun ≡ "mon_conv :: _ ⇒ ('a ⇒ real) ⇒ bool"
mon_conv_set ≡ "mon_conv :: _ ⇒ 'a set ⇒ bool"
begin
definition "x↑(y::real) ≡ (∀n. x n ≤ x (Suc n)) ∧ x ⇢ y"
definition "u↑(f::'a ⇒ real) ≡ (∀n. u n ≤ u (Suc n)) ∧ (∀w. (λn. u n w) ⇢ f w)"
definition "A↑(B::'a set) ≡ (∀n. A n ≤ A (Suc n)) ∧ B = (⋃n. A n)"
end
theorem realfun_mon_conv_iff: "(u↑f) = (∀w. (λn. u n w)↑((f w)::real))"
by (auto simp add: mon_conv_real_def (*‹?x↑?y ≡ (∀n. ?x n ≤ ?x (Suc n)) ∧ ?x ⇢ ?y›*) mon_conv_real_fun_def (*‹?u↑?f ≡ (∀n. ?u n ≤ ?u (Suc n)) ∧ (∀w. (λn. ?u n w) ⇢ ?f w)›*) le_fun_def (*‹(?f ≤ ?g) = (∀x. ?f x ≤ ?g x)›*))
text ‹The long arrow signifies convergence of real sequences as
defined in the theory ‹SEQ› \<^cite>‹"Fleuriot:2000:MNR"›. Monotone convergence
for real functions is simply pointwise monotone convergence.
Quite a few properties of these definitions will be necessary later,
and they are listed now, giving only few select proofs.›
(*This theorem, too, could be proved just the same for any ord
Type!*)
lemma assumes mon_conv: "x↑(y::real)"
shows mon_conv_mon: "(x i) ≤ (x (m+i))"
(*<*)proof (induct m)
(*goals:
1. ‹(x::nat ⇒ real) (i::nat) ≤ x ((0::nat) + i)›
2. ‹⋀m::nat. (x::nat ⇒ real) (i::nat) ≤ x (m + i) ⟹ x i ≤ x (Suc m + i)›*)
case 0 (*no hyothesis introduced yet*)
show "?case"
(*goal: ‹x i ≤ x (0 + i)›*)
by simp
next
(*goal: ‹⋀m. x i ≤ x (m + i) ⟹ x i ≤ x (Suc m + i)›*)
case (Suc n) (*‹x i ≤ x (n + i)›*)
also (*calculation: ‹x i ≤ x (n + i)›*) from mon_conv (*‹x↑y›*) have "x (n+i) ≤ x (Suc n+i)"
by (simp add: mon_conv_real_def (*‹?x↑?y ≡ (∀n. ?x n ≤ ?x (Suc n)) ∧ ?x ⇢ ?y›*))
finally (*calculation: ‹x i ≤ x (Suc n + i)›*) show "?case"
(*goal: ‹x i ≤ x (Suc n + i)›*) .
qed(*>*)
lemma limseq_shift_iff: "(λm. x (m+i)) ⇢ y = x ⇢ y"
(*<*)proof (induct i)
(*goals:
1. ‹(λm::nat. (x::nat ⇒ 'a) (m + (0::nat))) ⇢ (y::'a) = x ⇢ y›
2. ‹⋀i::nat. (λm::nat. (x::nat ⇒ 'a) (m + i)) ⇢ (y::'a) = x ⇢ y ⟹ (λm::nat. x (m + Suc i)) ⇢ y = x ⇢ y›*)
case 0 (*no hyothesis introduced yet*)
show "?case"
(*goal: ‹(λm. x (m + 0)) ⇢ y = x ⇢ y›*)
by simp
next
(*goal: ‹⋀i::nat. (λm::nat. (x::nat ⇒ 'a::topological_space) (m + i)) ⇢ (y::'a::topological_space) = x ⇢ y ⟹ (λm::nat. x (m + Suc i)) ⇢ y = x ⇢ y›*)
case (Suc n) (*‹(λm. x (m + n)) ⇢ y = x ⇢ y›*)
also (*calculation: ‹(λm. x (m + n)) ⇢ y = x ⇢ y›*) have "(λm. x (m + n)) ⇢ y = (λm. x (Suc m + n)) ⇢ y"
by (rule filterlim_sequentially_Suc[THEN sym] (*‹filterlim ?f1 ?F1 sequentially = (LIM x sequentially. ?f1 (Suc x) :> ?F1)›*))
also (*calculation: ‹(λm. x (Suc m + n)) ⇢ y = x ⇢ y›*) have "… = (λm. x (m + Suc n)) ⇢ y"
by simp
finally (*calculation: ‹(λm. x (m + Suc n)) ⇢ y = x ⇢ y›*) show "?case"
(*goal: ‹(λm. x (m + Suc n)) ⇢ y = x ⇢ y›*) .
qed(*>*)
(*This, too, could be established in general*)
theorem assumes mon_conv: "x↑(y::real)"
shows real_mon_conv_le: "x i ≤ y"
proof (-)
(*goal: ‹(x::nat ⇒ real) (i::nat) ≤ (y::real)›*)
from mon_conv (*‹x↑y›*) have "(λm. x (m+i)) ⇢ y"
by (simp add: mon_conv_real_def (*‹?x↑?y ≡ (∀n. ?x n ≤ ?x (Suc n)) ∧ ?x ⇢ ?y›*) limseq_shift_iff (*‹(λm. ?x (m + ?i)) ⇢ ?y = ?x ⇢ ?y›*))
also (*calculation: ‹(λm. x (m + i)) ⇢ y›*) from mon_conv (*‹x↑y›*) have "∀m≥0. x i ≤ x (m+i)"
by (simp add: mon_conv_mon (*‹?x↑?y ⟹ ?x ?i ≤ ?x (?m + ?i)›*))
ultimately show "?thesis"
(*goal: ‹(x::nat ⇒ real) (i::nat) ≤ (y::real)›*)
by (rule LIMSEQ_le_const[OF _ exI[where x=0]] (*‹⟦?X ⇢ ?x; ∀n≥0. ?a ≤ ?X n⟧ ⟹ ?a ≤ ?x›*))
qed
theorem assumes mon_conv: "x↑(y::('a ⇒ real))"
shows realfun_mon_conv_le: "x i ≤ y"
proof (-)
(*goal: ‹x i ≤ y›*)
{
fix w
from mon_conv (*‹(x::nat ⇒ 'a::type ⇒ real)↑(y::'a::type ⇒ real)›*) have "(λi. x i w)↑(y w)"
by (simp add: realfun_mon_conv_iff (*‹?u↑?f = (∀w. (λn. ?u n w)↑?f w)›*))
hence "x i w ≤ y w"
by (rule real_mon_conv_le (*‹?x↑?y ⟹ ?x ?i ≤ ?y›*))
}
thus "?thesis"
(*goal: ‹x i ≤ y›*)
by (simp add: le_fun_def (*‹(?f ≤ ?g) = (∀x. ?f x ≤ ?g x)›*))
qed
lemma assumes mon_conv: "x↑(y::real)"
and less: "z < y"
shows real_mon_conv_outgrow: "∃n. ∀m. n ≤ m ⟶ z < x m"
proof (-)
(*goal: ‹∃n. ∀m≥n. z < x m›*)
from less (*‹z < y›*) have less': "0 < y-z"
by simp
have "∃n.∀m. n ≤ m ⟶ ¦x m - y¦ < y - z"
proof (-)
(*goal: ‹∃n. ∀m≥n. ¦x m - y¦ < y - z›*)
from mon_conv (*‹x↑y›*) have aux: "⋀r. r > 0 ⟹ ∃n. ∀m. n ≤ m ⟶ ¦x m - y¦ < r"
unfolding mon_conv_real_def lim_sequentially dist_real_def
(*goal: ‹⋀r. 0 < r ⟹ ∃n. ∀m≥n. ¦x m - y¦ < r›*)
by auto
with less' (*‹0 < y - z›*) show "∃n. ∀m. n ≤ m ⟶ ¦x m - y¦ < y - z"
by auto
qed
also (*calculation: ‹∃n. ∀m≥n. ¦x m - y¦ < y - z›*) {
fix m
from mon_conv (*‹x↑y›*) have "x m ≤ y"
by (rule real_mon_conv_le (*‹?x↑?y ⟹ ?x ?i ≤ ?y›*))
hence "¦x m - y¦ = y - x m"
by arith
also (*calculation: ‹¦x m - y¦ = y - x m›*) assume "¦x m - y¦ < y - z" (*‹¦(x::nat ⇒ real) (m::nat) - (y::real)¦ < y - (z::real)›*)
ultimately have "z < x m"
by arith
}
ultimately show "?thesis"
(*goal: ‹∃n. ∀m≥n. z < x m›*)
by blast
qed
theorem real_mon_conv_times:
assumes xy: "x↑(y::real)" and nn: "0≤z"
shows "(λm. z*x m)↑(z*y)"
(*<*)proof (-)
(*goal: ‹(λm. z * x m)↑z * y›*)
from assms (*‹x↑y› ‹(0::real) ≤ (z::real)›*) have "⋀n. z*x n ≤ z*x (Suc n)"
by (simp add: mon_conv_real_def (*‹?x↑?y ≡ (∀n. ?x n ≤ ?x (Suc n)) ∧ ?x ⇢ ?y›*) mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*))
also (*calculation: ‹z * x ?n ≤ z * x (Suc ?n)›*) from xy (*‹x↑y›*) have "(λm. z*x m)⇢(z*y)"
by (simp add: mon_conv_real_def (*‹?x↑?y ≡ (∀n. ?x n ≤ ?x (Suc n)) ∧ ?x ⇢ ?y›*) tendsto_const (*‹((λx. ?k) ⤏ ?k) ?F›*) tendsto_mult (*‹⟦(?f ⤏ ?a) ?F; (?g ⤏ ?b) ?F⟧ ⟹ ((λx. ?f x * ?g x) ⤏ ?a * ?b) ?F›*))
ultimately show "?thesis"
(*goal: ‹(λm. z * x m)↑z * y›*)
by (simp add: mon_conv_real_def (*‹?x↑?y ≡ (∀n. ?x n ≤ ?x (Suc n)) ∧ ?x ⇢ ?y›*))
qed(*>*)
theorem realfun_mon_conv_times:
assumes xy: "x↑(y::'a⇒real)" and nn: "0≤z"
shows "(λm w. z*x m w)↑(λw. z*y w)"
(*<*)proof (-)
(*goal: ‹(λm w. z * x m w)↑(λw. z * y w)›*)
from assms (*‹x↑y› ‹0 ≤ z›*) have "⋀w. (λm. z*x m w)↑(z*y w)"
by (simp add: realfun_mon_conv_iff (*‹?u↑?f = (∀w. (λn. ?u n w)↑?f w)›*) real_mon_conv_times (*‹⟦?x↑?y; 0 ≤ ?z⟧ ⟹ (λm. ?z * ?x m)↑?z * ?y›*))
thus "?thesis"
(*goal: ‹(λm w. z * x m w)↑(λw. z * y w)›*)
by (auto simp add: realfun_mon_conv_iff (*‹?u↑?f = (∀w. (λn. ?u n w)↑?f w)›*))
qed(*>*)
theorem real_mon_conv_add:
assumes xy: "x↑(y::real)" and ab: "a↑(b::real)"
shows "(λm. x m + a m)↑(y + b)"
(*<*)proof (-)
(*goal: ‹(λm::nat. (x::nat ⇒ real) m + (a::nat ⇒ real) m)↑(y::real) + (b::real)›*)
{
fix n
from assms (*‹x↑y› ‹(a::nat ⇒ real)↑(b::real)›*) have "x n ≤ x (Suc n)" and "a n ≤ a (Suc n)"
apply -
(*goals:
1. ‹⟦(x::nat ⇒ real)↑(y::real); (a::nat ⇒ real)↑(b::real)⟧ ⟹ x (n::nat) ≤ x (Suc n)›
2. ‹⟦(x::nat ⇒ real)↑(y::real); (a::nat ⇒ real)↑(b::real)⟧ ⟹ a (n::nat) ≤ a (Suc n)›
discuss goal 1*)
apply (simp add: mon_conv_real_def (*‹?x↑?y ≡ (∀n. ?x n ≤ ?x (Suc n)) ∧ ?x ⇢ ?y›*))
(*discuss goal 2*)
apply (simp add: mon_conv_real_def (*‹(?x::nat ⇒ real)↑(?y::real) ≡ (∀n::nat. ?x n ≤ ?x (Suc n)) ∧ ?x ⇢ ?y›*))
(*proven 2 subgoals*) .
hence "x n + a n ≤ x (Suc n) + a (Suc n)"
by simp
}
also (*calculation: ‹x ?n2 + a ?n2 ≤ x (Suc ?n2) + a (Suc ?n2)›*) from assms (*‹x↑y› ‹a↑b›*) have "(λm. x m + a m)⇢(y + b)"
by (simp add: mon_conv_real_def (*‹?x↑?y ≡ (∀n. ?x n ≤ ?x (Suc n)) ∧ ?x ⇢ ?y›*) tendsto_add (*‹⟦(?f ⤏ ?a) ?F; (?g ⤏ ?b) ?F⟧ ⟹ ((λx. ?f x + ?g x) ⤏ ?a + ?b) ?F›*))
ultimately show "?thesis"
(*goal: ‹(λm. x m + a m)↑y + b›*)
by (simp add: mon_conv_real_def (*‹(?x::nat ⇒ real)↑(?y::real) ≡ (∀n::nat. ?x n ≤ ?x (Suc n)) ∧ ?x ⇢ ?y›*))
qed(*>*)
theorem realfun_mon_conv_add:
assumes xy: "x↑(y::'a⇒real)" and ab: "a↑(b::'a ⇒ real)"
shows "(λm w. x m w + a m w)↑(λw. y w + b w)"
(*<*)proof (-)
(*goal: ‹(λm w. x m w + a m w)↑(λw. y w + b w)›*)
from assms (*‹x↑y› ‹a↑b›*) have "⋀w. (λm. x m w + a m w)↑(y w + b w)"
by (simp add: realfun_mon_conv_iff (*‹?u↑?f = (∀w. (λn. ?u n w)↑?f w)›*) real_mon_conv_add (*‹⟦?x↑?y; ?a↑?b⟧ ⟹ (λm. ?x m + ?a m)↑?y + ?b›*))
thus "?thesis"
(*goal: ‹(λ(m::nat) w::'a. (x::nat ⇒ 'a ⇒ real) m w + (a::nat ⇒ 'a ⇒ real) m w)↑(λw::'a. (y::'a ⇒ real) w + (b::'a ⇒ real) w)›*)
by (auto simp add: realfun_mon_conv_iff (*‹?u↑?f = (∀w. (λn. ?u n w)↑?f w)›*))
qed(*>*)
theorem real_mon_conv_bound:
assumes mon: "⋀n. c n ≤ c (Suc n)"
and bound: "⋀n. c n ≤ (x::real)"
shows "∃l. c↑l ∧ l≤x"
proof (-)
(*goal: ‹∃l. c↑l ∧ l ≤ x›*)
from incseq_convergent[of c x] (*‹⟦incseq c; ∀i. c i ≤ x; ⋀L. ⟦c ⇢ L; ∀i. c i ≤ L⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) mon (*‹(c::nat ⇒ real) (?n::nat) ≤ c (Suc ?n)›*) bound (*‹c ?n ≤ x›*) obtain l where "c ⇢ l" "∀i. c i ≤ l"
(*goal: ‹(⋀l::real. ⟦(c::nat ⇒ real) ⇢ l; ∀i::nat. c i ≤ l⟧ ⟹ thesis::bool) ⟹ thesis›*)
by (auto simp: incseq_Suc_iff (*‹incseq ?f = (∀n. ?f n ≤ ?f (Suc n))›*))
moreover with bound (*‹c ?n ≤ x›*) have "l ≤ x"
apply (intro LIMSEQ_le_const2 (*‹⟦?X ⇢ ?x; ∃N. ∀n≥N. ?X n ≤ ?a⟧ ⟹ ?x ≤ ?a›*))
(*goal: ‹(l::real) ≤ (x::real)›*)
by auto
ultimately show "?thesis"
(*goal: ‹∃l::real. (c::nat ⇒ real)↑l ∧ l ≤ (x::real)›*)
by (auto simp: mon_conv_real_def (*‹(?x::nat ⇒ real)↑(?y::real) ≡ (∀n::nat. ?x n ≤ ?x (Suc n)) ∧ ?x ⇢ ?y›*) mon (*‹(c::nat ⇒ real) (?n::nat) ≤ c (Suc ?n)›*))
qed
theorem real_mon_conv_dom:
assumes xy: "x↑(y::real)" and mon: "⋀n. c n ≤ c (Suc n)"
and dom: "c ≤ x"
shows "∃l. c↑l ∧ l≤y"
proof (-)
(*goal: ‹∃l. c↑l ∧ l ≤ y›*)
from dom (*‹c ≤ x›*) have "⋀n. c n ≤ x n"
by (simp add: le_fun_def (*‹(?f ≤ ?g) = (∀x. ?f x ≤ ?g x)›*))
also (*calculation: ‹c ?n ≤ x ?n›*) from xy (*‹x↑y›*) have "⋀n. x n ≤ y"
by (simp add: real_mon_conv_le (*‹?x↑?y ⟹ ?x ?i ≤ ?y›*))
also (*calculation: ‹c ?n1 ≤ y›*) note mon (*‹c ?n ≤ c (Suc ?n)›*)
ultimately show "?thesis"
(*goal: ‹∃l. c↑l ∧ l ≤ y›*)
by (simp add: real_mon_conv_bound (*‹⟦⋀n::nat. (?c::nat ⇒ real) n ≤ ?c (Suc n); ⋀n::nat. ?c n ≤ (?x::real)⟧ ⟹ ∃l::real. ?c↑l ∧ l ≤ ?x›*))
qed
text‹\newpage›
theorem realfun_mon_conv_bound:
assumes mon: "⋀n. c n ≤ c (Suc n)"
and bound: "⋀n. c n ≤ (x::'a ⇒ real)"
shows "∃l. c↑l ∧ l≤x"
(*<*)proof (standard)
(*goal: ‹c↑?l ∧ ?l ≤ x›*)
define r where "r t = (SOME l. (λn. c n t)↑l ∧ l≤x t)" for t
{
fix t
from mon (*‹(c::nat ⇒ 'a ⇒ real) (?n::nat) ≤ c (Suc ?n)›*) have m2: "⋀n. c n t ≤ c (Suc n) t"
by (simp add: le_fun_def (*‹(?f ≤ ?g) = (∀x. ?f x ≤ ?g x)›*))
also (*calculation: ‹c ?n t ≤ c (Suc ?n) t›*) from bound (*‹c ?n ≤ x›*) have "⋀n. c n t ≤ x t"
by (simp add: le_fun_def (*‹(?f ≤ ?g) = (∀x. ?f x ≤ ?g x)›*))
ultimately have "∃l. (λn. c n t)↑l ∧ l≤x t" (is "∃l. ?P l")
by (rule real_mon_conv_bound (*‹⟦⋀n. ?c n ≤ ?c (Suc n); ⋀n. ?c n ≤ ?x⟧ ⟹ ∃l. ?c↑l ∧ l ≤ ?x›*))
hence "?P (SOME l. ?P l)"
by (rule someI_ex (*‹∃x. ?P x ⟹ ?P (SOME x. ?P x)›*))
hence "(λn. c n t)↑r t ∧ r t≤x t"
by (simp add: r_def (*‹r ?t = (SOME l. (λn. c n ?t)↑l ∧ l ≤ x ?t)›*))
}
thus "c↑r ∧ r ≤ x"
by (simp add: realfun_mon_conv_iff (*‹?u↑?f = (∀w. (λn. ?u n w)↑?f w)›*) le_fun_def (*‹(?f ≤ ?g) = (∀x. ?f x ≤ ?g x)›*))
qed (*>*)
text ‹This brings the theory to an end. Notice how the definition of the limit of a
real sequence is visible in the proof to ‹real_mon_conv_outgrow›, a lemma that will be used for a
monotonicity proof of the integral of simple functions later on.›(*<*)
(*Another set construction. Needed in ImportPredSet, but Set is shadowed beyond
reconstruction there.
Before making disjoint, we first need an ascending series of sets*)
primrec mk_mon::"(nat ⇒ 'a set) ⇒ nat ⇒ 'a set"
where
"mk_mon A 0 = A 0"
| "mk_mon A (Suc n) = A (Suc n) ∪ mk_mon A n"
lemma "mk_mon A ↑ (⋃i. A i)"
proof (unfold mon_conv_set_def (*‹?A↑?B ≡ (∀n. ?A n ⊆ ?A (Suc n)) ∧ ?B = ⋃ (range ?A)›*))
(*goal: ‹(∀n::nat. mk_mon (A::nat ⇒ 'a::type set) n ⊆ mk_mon A (Suc n)) ∧ ⋃ (range A) = ⋃ (range (mk_mon A))›*)
{
fix n
have "mk_mon A n ⊆ mk_mon A (Suc n)"
by auto
}
also (*calculation: ‹mk_mon A ?n2 ⊆ mk_mon A (Suc ?n2)›*) have "(⋃i. mk_mon A i) = (⋃i. A i)"
proof (standard)
(*goals:
1. ‹⋃ (range (mk_mon A)) ⊆ ⋃ (range A)›
2. ‹⋃ (range A) ⊆ ⋃ (range (mk_mon A))›*)
{
fix i and x
assume "x ∈ mk_mon A i" (*‹(x::'a) ∈ mk_mon (A::nat ⇒ 'a set) (i::nat)›*)
hence "∃j. x ∈ A j"
apply (induct i)
(*goals:
1. ‹x ∈ mk_mon A 0 ⟹ ∃j. x ∈ A j›
2. ‹⋀i. ⟦x ∈ mk_mon A i ⟹ ∃j. x ∈ A j; x ∈ mk_mon A (Suc i)⟧ ⟹ ∃j. x ∈ A j›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
hence "x ∈ (⋃i. A i)"
by simp
}
thus "(⋃i. mk_mon A i) ⊆ (⋃i. A i)"
by auto
{
fix i
have "A i ⊆ mk_mon A i"
apply (induct i)
(*goals:
1. ‹A 0 ⊆ mk_mon A 0›
2. ‹⋀i. A i ⊆ mk_mon A i ⟹ A (Suc i) ⊆ mk_mon A (Suc i)›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
}
thus "(⋃i. A i) ⊆ (⋃i. mk_mon A i)"
by auto
qed
ultimately show "(∀n. mk_mon A n ⊆ mk_mon A (Suc n)) ∧ ⋃(A ` UNIV) = (⋃n. mk_mon A n)"
by simp
qed(*>*)
end
| {
"path": "afp-2025-02-12/thys/Integration/MonConv.thy",
"repo": "afp-2025-02-12",
"sha": "feac20bb5b701a5d4037e26cf55c6dca7e57ca059b24a8c1d29bd8be7cf9def7"
} |
section ‹Static data dependence›
theory DataDependence imports "../Basic/DynDataDependence" begin
context CFG_wf begin
definition data_dependence :: "'node ⇒ 'var ⇒ 'node ⇒ bool"
("_ influences _ in _" [51,0])
where data_dependences_eq:"n influences V in n' ≡ ∃as. n influences V in n' via as"
lemma data_dependence_def: "n influences V in n' =
(∃a' as'. (V ∈ Def n) ∧ (V ∈ Use n') ∧
(n -a'#as'→* n') ∧ (∀n'' ∈ set (sourcenodes as'). V ∉ Def n''))"
by (auto simp:data_dependences_eq (*‹?n influences ?V in ?n' ≡ ∃as. ?n influences ?V in ?n' via as›*) dyn_data_dependence_def (*‹?n influences ?V in ?n' via ?as ≡ ?V ∈ Def ?n ∧ ?V ∈ Use ?n' ∧ ?n -?as→* ?n' ∧ (∃a' as'. ?as = a' # as' ∧ (∀n''∈set (sourcenodes as'). ?V ∉ Def n''))›*))
end
end
| {
"path": "afp-2025-02-12/thys/Slicing/StaticIntra/DataDependence.thy",
"repo": "afp-2025-02-12",
"sha": "ceb817c2a681602a1a85737d1b549f7157ce23726380cd5a4935f872216b9cd4"
} |
(* Title: JinjaDCI/J/DefAss.thy
Author: Tobias Nipkow, Susannah Mansky
Copyright 2003 Technische Universitaet Muenchen, 2019-20 UIUC
Based on the Jinja theory J/DefAss.thy by Tobias Nipkow
*)
section ‹ Definite assignment ›
theory DefAss imports BigStep begin
subsection "Hypersets"
type_synonym 'a hyperset = "'a set option"
definition hyperUn :: "'a hyperset ⇒ 'a hyperset ⇒ 'a hyperset" (infixl "⊔" 65)
where
"A ⊔ B ≡ case A of None ⇒ None
| ⌊A⌋ ⇒ (case B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋)"
definition hyperInt :: "'a hyperset ⇒ 'a hyperset ⇒ 'a hyperset" (infixl "⊓" 70)
where
"A ⊓ B ≡ case A of None ⇒ B
| ⌊A⌋ ⇒ (case B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋)"
definition hyperDiff1 :: "'a hyperset ⇒ 'a ⇒ 'a hyperset" (infixl "⊖" 65)
where
"A ⊖ a ≡ case A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {a}⌋"
definition hyper_isin :: "'a ⇒ 'a hyperset ⇒ bool" (infix "∈∈" 50)
where
"a ∈∈ A ≡ case A of None ⇒ True | ⌊A⌋ ⇒ a ∈ A"
definition hyper_subset :: "'a hyperset ⇒ 'a hyperset ⇒ bool" (infix "⊑" 50)
where
"A ⊑ B ≡ case B of None ⇒ True
| ⌊B⌋ ⇒ (case A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B)"
lemmas hyperset_defs =
hyperUn_def hyperInt_def hyperDiff1_def hyper_isin_def hyper_subset_def
lemma [simp]: "⌊{}⌋ ⊔ A = A ∧ A ⊔ ⌊{}⌋ = A"
(*<*)by (simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))(*>*)
lemma [simp]: "⌊A⌋ ⊔ ⌊B⌋ = ⌊A ∪ B⌋ ∧ ⌊A⌋ ⊖ a = ⌊A - {a}⌋"
(*<*)by (simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))(*>*)
lemma [simp]: "None ⊔ A = None ∧ A ⊔ None = None"
(*<*)by (simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))(*>*)
lemma [simp]: "a ∈∈ None ∧ None ⊖ a = None"
(*<*)by (simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))(*>*)
lemma hyper_isin_union: "x ∈∈ ⌊A⌋ ⟹ x ∈∈ ⌊A⌋ ⊔ B"
apply (case_tac B)
(*goals:
1. ‹⟦x ∈∈ ⌊A⌋; B = None⟧ ⟹ x ∈∈ ⌊A⌋ ⊔ B›
2. ‹⋀a. ⟦x ∈∈ ⌊A⌋; B = ⌊a⌋⟧ ⟹ x ∈∈ ⌊A⌋ ⊔ B›
discuss goal 1*)
apply ((auto simp: hyper_isin_def (*‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A›*))[1])
(*discuss goal 2*)
apply ((auto simp: hyper_isin_def (*‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A›*))[1])
(*proven 2 subgoals*) .
lemma hyperUn_assoc: "(A ⊔ B) ⊔ C = A ⊔ (B ⊔ C)"
(*<*)by (simp add:hyperset_defs (*‹(?A::?'a set option) ⊔ (?B::?'a set option) ≡ case ?A of None ⇒ None | ⌊A::?'a set⌋ ⇒ case ?B of None ⇒ None | ⌊B::?'a set⌋ ⇒ ⌊A ∪ B⌋› ‹(?A::?'a set option) ⊓ (?B::?'a set option) ≡ case ?A of None ⇒ ?B | ⌊A::?'a set⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B::?'a set⌋ ⇒ ⌊A ∩ B⌋› ‹(?A::?'a set option) ⊖ (?a::?'a) ≡ case ?A of None ⇒ None | ⌊A::?'a set⌋ ⇒ ⌊A - {?a}⌋› ‹(?a::?'a) ∈∈ (?A::?'a set option) ≡ case ?A of None ⇒ True | ⌊A::?'a set⌋ ⇒ ?a ∈ A› ‹(?A::?'a set option) ⊑ (?B::?'a set option) ≡ case ?B of None ⇒ True | ⌊B::?'a set⌋ ⇒ case ?A of None ⇒ False | ⌊A::?'a set⌋ ⇒ A ⊆ B›*) Un_assoc (*‹(?A::?'a set) ∪ (?B::?'a set) ∪ (?C::?'a set) = ?A ∪ (?B ∪ ?C)›*))(*>*)
lemma hyper_insert_comm: "A ⊔ ⌊{a}⌋ = ⌊{a}⌋ ⊔ A ∧ A ⊔ (⌊{a}⌋ ⊔ B) = ⌊{a}⌋ ⊔ (A ⊔ B)"
(*<*)by (simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))(*>*)
lemma hyper_comm: "A ⊔ B = B ⊔ A ∧ A ⊔ B ⊔ C = B ⊔ A ⊔ C"
(*<*)
proof (cases A)
(*goals:
1. ‹A = None ⟹ A ⊔ B = B ⊔ A ∧ A ⊔ B ⊔ C = B ⊔ A ⊔ C›
2. ‹⋀a. A = ⌊a⌋ ⟹ A ⊔ B = B ⊔ A ∧ A ⊔ B ⊔ C = B ⊔ A ⊔ C›*)
case SomeA: Some (*‹A = ⌊a_⌋›*)
then show "?thesis"
(*goal: ‹A ⊔ B = B ⊔ A ∧ A ⊔ B ⊔ C = B ⊔ A ⊔ C›*)
proof (cases B)
(*goals:
1. ‹⟦A = ⌊a_⌋; B = None⟧ ⟹ A ⊔ B = B ⊔ A ∧ A ⊔ B ⊔ C = B ⊔ A ⊔ C›
2. ‹⋀aa. ⟦A = ⌊a_⌋; B = ⌊aa⌋⟧ ⟹ A ⊔ B = B ⊔ A ∧ A ⊔ B ⊔ C = B ⊔ A ⊔ C›*)
case SomeB: Some (*‹B = ⌊a_⌋›*)
with SomeA (*‹A = ⌊a___⌋›*) show "?thesis"
(*goal: ‹A ⊔ B = B ⊔ A ∧ A ⊔ B ⊔ C = B ⊔ A ⊔ C›*)
proof (cases C)
(*goals:
1. ‹⟦A = ⌊a___⌋; B = ⌊a_⌋; C = None⟧ ⟹ A ⊔ B = B ⊔ A ∧ A ⊔ B ⊔ C = B ⊔ A ⊔ C›
2. ‹⋀ab. ⟦A = ⌊a___⌋; B = ⌊a_⌋; C = ⌊ab⌋⟧ ⟹ A ⊔ B = B ⊔ A ∧ A ⊔ B ⊔ C = B ⊔ A ⊔ C›*)
case SomeC: Some (*‹C = ⌊a_⌋›*)
with SomeA (*‹A = ⌊a___⌋›*) SomeB (*‹B = ⌊aa___⌋›*) show "?thesis"
(*goal: ‹A ⊔ B = B ⊔ A ∧ A ⊔ B ⊔ C = B ⊔ A ⊔ C›*)
by (simp add: Un_left_commute (*‹?A ∪ (?B ∪ ?C) = ?B ∪ (?A ∪ ?C)›*) Un_commute (*‹?A ∪ ?B = ?B ∪ ?A›*))
qed (simp add: Un_commute (*‹?A ∪ ?B = ?B ∪ ?A›*))
(*solved the remaining goal: ‹⟦A = ⌊a___⌋; B = ⌊aa___⌋; C = None⟧ ⟹ A ⊔ B = B ⊔ A ∧ A ⊔ B ⊔ C = B ⊔ A ⊔ C›*)
qed (simp)
(*solved the remaining goal: ‹⟦A = ⌊a___⌋; B = None⟧ ⟹ A ⊔ B = B ⊔ A ∧ A ⊔ B ⊔ C = B ⊔ A ⊔ C›*)
qed (simp)
(*solved the remaining goal: ‹A = None ⟹ A ⊔ B = B ⊔ A ∧ A ⊔ B ⊔ C = B ⊔ A ⊔ C›*)
(*>*)
subsection "Definite assignment"
primrec
𝒜 :: "'a exp ⇒ 'a hyperset"
and 𝒜s :: "'a exp list ⇒ 'a hyperset"
where
"𝒜 (new C) = ⌊{}⌋"
| "𝒜 (Cast C e) = 𝒜 e"
| "𝒜 (Val v) = ⌊{}⌋"
| "𝒜 (e₁ «bop» e₂) = 𝒜 e₁ ⊔ 𝒜 e₂"
| "𝒜 (Var V) = ⌊{}⌋"
| "𝒜 (LAss V e) = ⌊{V}⌋ ⊔ 𝒜 e"
| "𝒜 (e∙F{D}) = 𝒜 e"
| "𝒜 (C∙⇩sF{D}) = ⌊{}⌋"
| "𝒜 (e₁∙F{D}:=e₂) = 𝒜 e₁ ⊔ 𝒜 e₂"
| "𝒜 (C∙⇩sF{D}:=e₂) = 𝒜 e₂"
| "𝒜 (e∙M(es)) = 𝒜 e ⊔ 𝒜s es"
| "𝒜 (C∙⇩sM(es)) = 𝒜s es"
| "𝒜 ({V:T; e}) = 𝒜 e ⊖ V"
| "𝒜 (e₁;;e₂) = 𝒜 e₁ ⊔ 𝒜 e₂"
| "𝒜 (if (e) e₁ else e₂) = 𝒜 e ⊔ (𝒜 e₁ ⊓ 𝒜 e₂)"
| "𝒜 (while (b) e) = 𝒜 b"
| "𝒜 (throw e) = None"
| "𝒜 (try e₁ catch(C V) e₂) = 𝒜 e₁ ⊓ (𝒜 e₂ ⊖ V)"
| "𝒜 (INIT C (Cs,b) ← e) = ⌊{}⌋"
| "𝒜 (RI (C,e);Cs ← e') = 𝒜 e"
| "𝒜s ([]) = ⌊{}⌋"
| "𝒜s (e#es) = 𝒜 e ⊔ 𝒜s es"
primrec
𝒟 :: "'a exp ⇒ 'a hyperset ⇒ bool"
and 𝒟s :: "'a exp list ⇒ 'a hyperset ⇒ bool"
where
"𝒟 (new C) A = True"
| "𝒟 (Cast C e) A = 𝒟 e A"
| "𝒟 (Val v) A = True"
| "𝒟 (e₁ «bop» e₂) A = (𝒟 e₁ A ∧ 𝒟 e₂ (A ⊔ 𝒜 e₁))"
| "𝒟 (Var V) A = (V ∈∈ A)"
| "𝒟 (LAss V e) A = 𝒟 e A"
| "𝒟 (e∙F{D}) A = 𝒟 e A"
| "𝒟 (C∙⇩sF{D}) A = True"
| "𝒟 (e₁∙F{D}:=e₂) A = (𝒟 e₁ A ∧ 𝒟 e₂ (A ⊔ 𝒜 e₁))"
| "𝒟 (C∙⇩sF{D}:=e₂) A = 𝒟 e₂ A"
| "𝒟 (e∙M(es)) A = (𝒟 e A ∧ 𝒟s es (A ⊔ 𝒜 e))"
| "𝒟 (C∙⇩sM(es)) A = 𝒟s es A"
| "𝒟 ({V:T; e}) A = 𝒟 e (A ⊖ V)"
| "𝒟 (e₁;;e₂) A = (𝒟 e₁ A ∧ 𝒟 e₂ (A ⊔ 𝒜 e₁))"
| "𝒟 (if (e) e₁ else e₂) A =
(𝒟 e A ∧ 𝒟 e₁ (A ⊔ 𝒜 e) ∧ 𝒟 e₂ (A ⊔ 𝒜 e))"
| "𝒟 (while (e) c) A = (𝒟 e A ∧ 𝒟 c (A ⊔ 𝒜 e))"
| "𝒟 (throw e) A = 𝒟 e A"
| "𝒟 (try e₁ catch(C V) e₂) A = (𝒟 e₁ A ∧ 𝒟 e₂ (A ⊔ ⌊{V}⌋))"
| "𝒟 (INIT C (Cs,b) ← e) A = 𝒟 e A"
| "𝒟 (RI (C,e);Cs ← e') A = (𝒟 e A ∧ 𝒟 e' A)"
| "𝒟s ([]) A = True"
| "𝒟s (e#es) A = (𝒟 e A ∧ 𝒟s es (A ⊔ 𝒜 e))"
lemma As_map_Val[simp]: "𝒜s (map Val vs) = ⌊{}⌋"
(*<*)apply (induct vs)
(*goals:
1. ‹𝒜s (map Val []) = ⌊{}⌋›
2. ‹⋀a vs. 𝒜s (map Val vs) = ⌊{}⌋ ⟹ 𝒜s (map Val (a # vs)) = ⌊{}⌋›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .(*>*)
lemma D_append[iff]: "⋀A. 𝒟s (es @ es') A = (𝒟s es A ∧ 𝒟s es' (A ⊔ 𝒜s es))"
(*<*)apply (induct es type:list)
(*goals:
1. ‹⋀A::'a set option. 𝒟s ([] @ (es'::'a exp list)) A = (𝒟s [] A ∧ 𝒟s es' (A ⊔ 𝒜s []))›
2. ‹⋀(a::'a exp) (list::'a exp list) A::'a set option. (⋀A::'a set option. 𝒟s (list @ (es'::'a exp list)) A = (𝒟s list A ∧ 𝒟s es' (A ⊔ 𝒜s list))) ⟹ 𝒟s ((a # list) @ es') A = (𝒟s (a # list) A ∧ 𝒟s es' (A ⊔ 𝒜s (a # list)))›
discuss goal 1*)
apply ((auto simp:hyperUn_assoc (*‹(?A::?'a set option) ⊔ (?B::?'a set option) ⊔ (?C::?'a set option) = ?A ⊔ (?B ⊔ ?C)›*))[1])
(*discuss goal 2*)
apply ((auto simp:hyperUn_assoc (*‹?A ⊔ ?B ⊔ ?C = ?A ⊔ (?B ⊔ ?C)›*))[1])
(*proven 2 subgoals*) .(*>*)
lemma A_fv: "⋀A. 𝒜 e = ⌊A⌋ ⟹ A ⊆ fv e"
and "⋀A. 𝒜s es = ⌊A⌋ ⟹ A ⊆ fvs es"
(*<*)
apply (induct e and es rule: 𝒜.induct 𝒜s.induct)
(*goals:
1. ‹⋀(x::char list) A::char list set. 𝒜 (new x) = ⌊A⌋ ⟹ A ⊆ fv (new x)›
2. ‹⋀(x1::char list) (x2::char list exp) A::char list set. ⟦⋀A::char list set. 𝒜 x2 = ⌊A⌋ ⟹ A ⊆ fv x2; 𝒜 (Cast x1 x2) = ⌊A⌋⟧ ⟹ A ⊆ fv (Cast x1 x2)›
3. ‹⋀(x::val) A::char list set. 𝒜 (Val x) = ⌊A⌋ ⟹ A ⊆ fv (Val x)›
4. ‹⋀(x1::char list exp) (x2::bop) (x3::char list exp) A::char list set. ⟦⋀A::char list set. 𝒜 x1 = ⌊A⌋ ⟹ A ⊆ fv x1; ⋀A::char list set. 𝒜 x3 = ⌊A⌋ ⟹ A ⊆ fv x3; 𝒜 (x1 «x2» x3) = ⌊A⌋⟧ ⟹ A ⊆ fv (x1 «x2» x3)›
5. ‹⋀(x::char list) A::char list set. 𝒜 (Var x) = ⌊A⌋ ⟹ A ⊆ fv (Var x)›
6. ‹⋀(x1::char list) (x2::char list exp) A::char list set. ⟦⋀A::char list set. 𝒜 x2 = ⌊A⌋ ⟹ A ⊆ fv x2; 𝒜 (x1:=x2) = ⌊A⌋⟧ ⟹ A ⊆ fv (x1:=x2)›
7. ‹⋀(x1::char list exp) (x2::char list) (x3::char list) A::char list set. ⟦⋀A::char list set. 𝒜 x1 = ⌊A⌋ ⟹ A ⊆ fv x1; 𝒜 (x1∙x2{x3}) = ⌊A⌋⟧ ⟹ A ⊆ fv (x1∙x2{x3})›
8. ‹⋀(x1::char list) (x2::char list) (x3::char list) A::char list set. 𝒜 (x1∙⇩sx2{x3}) = ⌊A⌋ ⟹ A ⊆ fv (x1∙⇩sx2{x3})›
9. ‹⋀(x1::char list exp) (x2::char list) (x3::char list) (x4::char list exp) A::char list set. ⟦⋀A::char list set. 𝒜 x1 = ⌊A⌋ ⟹ A ⊆ fv x1; ⋀A::char list set. 𝒜 x4 = ⌊A⌋ ⟹ A ⊆ fv x4; 𝒜 (x1∙x2{x3} := x4) = ⌊A⌋⟧ ⟹ A ⊆ fv (x1∙x2{x3} := x4)›
10. ‹⋀(x1::char list) (x2::char list) (x3::char list) (x4::char list exp) A::char list set. ⟦⋀A::char list set. 𝒜 x4 = ⌊A⌋ ⟹ A ⊆ fv x4; 𝒜 (x1∙⇩sx2{x3} := x4) = ⌊A⌋⟧ ⟹ A ⊆ fv (x1∙⇩sx2{x3} := x4)›
11. ‹⋀(x1::char list exp) (x2::char list) (x3::char list exp list) A::char list set. ⟦⋀A::char list set. 𝒜 x1 = ⌊A⌋ ⟹ A ⊆ fv x1; ⋀A::char list set. 𝒜s x3 = ⌊A⌋ ⟹ A ⊆ fvs x3; 𝒜 (x1∙x2(x3)) = ⌊A⌋⟧ ⟹ A ⊆ fv (x1∙x2(x3))›
12. ‹⋀(x1::char list) (x2::char list) (x3::char list exp list) A::char list set. ⟦⋀A::char list set. 𝒜s x3 = ⌊A⌋ ⟹ A ⊆ fvs x3; 𝒜 (x1∙⇩sx2(x3)) = ⌊A⌋⟧ ⟹ A ⊆ fv (x1∙⇩sx2(x3))›
13. ‹⋀(x1::char list) (x2::ty) (x3::char list exp) A::char list set. ⟦⋀A::char list set. 𝒜 x3 = ⌊A⌋ ⟹ A ⊆ fv x3; 𝒜 {x1:x2; x3} = ⌊A⌋⟧ ⟹ A ⊆ fv {x1:x2; x3}›
14. ‹⋀(x1::char list exp) (x2::char list exp) A::char list set. ⟦⋀A::char list set. 𝒜 x1 = ⌊A⌋ ⟹ A ⊆ fv x1; ⋀A::char list set. 𝒜 x2 = ⌊A⌋ ⟹ A ⊆ fv x2; 𝒜 (x1;; x2) = ⌊A⌋⟧ ⟹ A ⊆ fv (x1;; x2)›
15. ‹⋀(x1::char list exp) (x2::char list exp) (x3::char list exp) A::char list set. ⟦⋀A::char list set. 𝒜 x1 = ⌊A⌋ ⟹ A ⊆ fv x1; ⋀A::char list set. 𝒜 x2 = ⌊A⌋ ⟹ A ⊆ fv x2; ⋀A::char list set. 𝒜 x3 = ⌊A⌋ ⟹ A ⊆ fv x3; 𝒜 (if (x1) x2 else x3) = ⌊A⌋⟧ ⟹ A ⊆ fv (if (x1) x2 else x3)›
16. ‹⋀(x1::char list exp) (x2::char list exp) A::char list set. ⟦⋀A::char list set. 𝒜 x1 = ⌊A⌋ ⟹ A ⊆ fv x1; ⋀A::char list set. 𝒜 x2 = ⌊A⌋ ⟹ A ⊆ fv x2; 𝒜 (while (x1) x2) = ⌊A⌋⟧ ⟹ A ⊆ fv (while (x1) x2)›
17. ‹⋀(x::char list exp) A::char list set. ⟦⋀A::char list set. 𝒜 x = ⌊A⌋ ⟹ A ⊆ fv x; 𝒜 (throw x) = ⌊A⌋⟧ ⟹ A ⊆ fv (throw x)›
18. ‹⋀(x1::char list exp) (x2::char list) (x3::char list) (x4::char list exp) A::char list set. ⟦⋀A::char list set. 𝒜 x1 = ⌊A⌋ ⟹ A ⊆ fv x1; ⋀A::char list set. 𝒜 x4 = ⌊A⌋ ⟹ A ⊆ fv x4; 𝒜 (try x1 catch(x2 x3) x4) = ⌊A⌋⟧ ⟹ A ⊆ fv (try x1 catch(x2 x3) x4)›
19. ‹⋀(x1::char list) (x2::char list list) (x3::bool) (x4::char list exp) A::char list set. ⟦⋀A::char list set. 𝒜 x4 = ⌊A⌋ ⟹ A ⊆ fv x4; 𝒜 (INIT x1 (x2,x3) ← x4) = ⌊A⌋⟧ ⟹ A ⊆ fv (INIT x1 (x2,x3) ← x4)›
20. ‹⋀(x1::char list) (x2::char list exp) (x3::char list list) (x4::char list exp) A::char list set. ⟦⋀A::char list set. 𝒜 x2 = ⌊A⌋ ⟹ A ⊆ fv x2; ⋀A::char list set. 𝒜 x4 = ⌊A⌋ ⟹ A ⊆ fv x4; 𝒜 (RI (x1,x2) ; x3 ← x4) = ⌊A⌋⟧ ⟹ A ⊆ fv (RI (x1,x2) ; x3 ← x4)›
21. ‹⋀A::char list set. 𝒜s [] = ⌊A⌋ ⟹ A ⊆ fvs []›
22. ‹⋀(x1::char list exp) (x2::char list exp list) A::char list set. ⟦⋀A::char list set. 𝒜 x1 = ⌊A⌋ ⟹ A ⊆ fv x1; ⋀A::char list set. 𝒜s x2 = ⌊A⌋ ⟹ A ⊆ fvs x2; 𝒜s (x1 # x2) = ⌊A⌋⟧ ⟹ A ⊆ fvs (x1 # x2)›
discuss goal 1*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 2*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 3*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 4*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 5*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 6*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 7*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 8*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 9*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 10*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 11*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 12*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 13*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 14*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 15*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 16*)
apply (fastforce simp add:hyperset_defs (*‹(?A::?'a set option) ⊔ (?B::?'a set option) ≡ case ?A of None ⇒ None | ⌊A::?'a set⌋ ⇒ case ?B of None ⇒ None | ⌊B::?'a set⌋ ⇒ ⌊A ∪ B⌋› ‹(?A::?'a set option) ⊓ (?B::?'a set option) ≡ case ?A of None ⇒ ?B | ⌊A::?'a set⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B::?'a set⌋ ⇒ ⌊A ∩ B⌋› ‹(?A::?'a set option) ⊖ (?a::?'a) ≡ case ?A of None ⇒ None | ⌊A::?'a set⌋ ⇒ ⌊A - {?a}⌋› ‹(?a::?'a) ∈∈ (?A::?'a set option) ≡ case ?A of None ⇒ True | ⌊A::?'a set⌋ ⇒ ?a ∈ A› ‹(?A::?'a set option) ⊑ (?B::?'a set option) ≡ case ?B of None ⇒ True | ⌊B::?'a set⌋ ⇒ case ?A of None ⇒ False | ⌊A::?'a set⌋ ⇒ A ⊆ B›*))
(*discuss goal 17*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 18*)
apply (fastforce simp add:hyperset_defs (*‹(?A::?'a set option) ⊔ (?B::?'a set option) ≡ case ?A of None ⇒ None | ⌊A::?'a set⌋ ⇒ case ?B of None ⇒ None | ⌊B::?'a set⌋ ⇒ ⌊A ∪ B⌋› ‹(?A::?'a set option) ⊓ (?B::?'a set option) ≡ case ?A of None ⇒ ?B | ⌊A::?'a set⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B::?'a set⌋ ⇒ ⌊A ∩ B⌋› ‹(?A::?'a set option) ⊖ (?a::?'a) ≡ case ?A of None ⇒ None | ⌊A::?'a set⌋ ⇒ ⌊A - {?a}⌋› ‹(?a::?'a) ∈∈ (?A::?'a set option) ≡ case ?A of None ⇒ True | ⌊A::?'a set⌋ ⇒ ?a ∈ A› ‹(?A::?'a set option) ⊑ (?B::?'a set option) ≡ case ?B of None ⇒ True | ⌊B::?'a set⌋ ⇒ case ?A of None ⇒ False | ⌊A::?'a set⌋ ⇒ A ⊆ B›*))
(*discuss goal 19*)
apply (fastforce simp add:hyperset_defs (*‹(?A::?'a set option) ⊔ (?B::?'a set option) ≡ case ?A of None ⇒ None | ⌊A::?'a set⌋ ⇒ case ?B of None ⇒ None | ⌊B::?'a set⌋ ⇒ ⌊A ∪ B⌋› ‹(?A::?'a set option) ⊓ (?B::?'a set option) ≡ case ?A of None ⇒ ?B | ⌊A::?'a set⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B::?'a set⌋ ⇒ ⌊A ∩ B⌋› ‹(?A::?'a set option) ⊖ (?a::?'a) ≡ case ?A of None ⇒ None | ⌊A::?'a set⌋ ⇒ ⌊A - {?a}⌋› ‹(?a::?'a) ∈∈ (?A::?'a set option) ≡ case ?A of None ⇒ True | ⌊A::?'a set⌋ ⇒ ?a ∈ A› ‹(?A::?'a set option) ⊑ (?B::?'a set option) ≡ case ?B of None ⇒ True | ⌊B::?'a set⌋ ⇒ case ?A of None ⇒ False | ⌊A::?'a set⌋ ⇒ A ⊆ B›*))
(*discuss goal 20*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 21*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*discuss goal 22*)
apply (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*proven 22 subgoals*) .
(*>*)
lemma sqUn_lem: "A ⊑ A' ⟹ A ⊔ B ⊑ A' ⊔ B"
(*<*)apply (simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*goal: ‹A ⊑ A' ⟹ A ⊔ B ⊑ A' ⊔ B›*)
by blast(*>*)
lemma diff_lem: "A ⊑ A' ⟹ A ⊖ b ⊑ A' ⊖ b"
(*<*)apply (simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
(*goal: ‹A ⊑ A' ⟹ A ⊖ b ⊑ A' ⊖ b›*)
by blast(*>*)
(* This order of the premises avoids looping of the simplifier *)
lemma D_mono: "⋀A A'. A ⊑ A' ⟹ 𝒟 e A ⟹ 𝒟 (e::'a exp) A'"
and Ds_mono: "⋀A A'. A ⊑ A' ⟹ 𝒟s es A ⟹ 𝒟s (es::'a exp list) A'"
(*<*)
proof (induct e and es rule: 𝒟.induct 𝒟s.induct)
(*goals:
1. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (new x) A⟧ ⟹ 𝒟 (new x) A'›
2. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (Cast x1 x2) A⟧ ⟹ 𝒟 (Cast x1 x2) A'›
3. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (Val x) A⟧ ⟹ 𝒟 (Val x) A'›
4. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x3 A⟧ ⟹ 𝒟 x3 A'; A ⊑ A'; 𝒟 (x1 «x2» x3) A⟧ ⟹ 𝒟 (x1 «x2» x3) A'›
5. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (Var x) A⟧ ⟹ 𝒟 (Var x) A'›
6. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1:=x2) A⟧ ⟹ 𝒟 (x1:=x2) A'›
7. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; A ⊑ A'; 𝒟 (x1∙x2{x3}) A⟧ ⟹ 𝒟 (x1∙x2{x3}) A'›
8. ‹⋀x1 x2 x3 A A'. ⟦A ⊑ A'; 𝒟 (x1∙⇩sx2{x3}) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3}) A'›
9. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (x1∙x2{x3} := x4) A⟧ ⟹ 𝒟 (x1∙x2{x3} := x4) A'›
10. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2{x3} := x4) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3} := x4) A'›
11. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙x2(x3)) A⟧ ⟹ 𝒟 (x1∙x2(x3)) A'›
12. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2(x3)) A⟧ ⟹ 𝒟 (x1∙⇩sx2(x3)) A'›
13. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x3 A⟧ ⟹ 𝒟 x3 A'; A ⊑ A'; 𝒟 {x1:x2; x3} A⟧ ⟹ 𝒟 {x1:x2; x3} A'›
14. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1;; x2) A⟧ ⟹ 𝒟 (x1;; x2) A'›
15. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x3 A⟧ ⟹ 𝒟 x3 A'; A ⊑ A'; 𝒟 (if (x1) x2 else x3) A⟧ ⟹ 𝒟 (if (x1) x2 else x3) A'›
16. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (while (x1) x2) A⟧ ⟹ 𝒟 (while (x1) x2) A'›
17. ‹⋀x A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x A⟧ ⟹ 𝒟 x A'; A ⊑ A'; 𝒟 (throw x) A⟧ ⟹ 𝒟 (throw x) A'›
18. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (try x1 catch(x2 x3) x4) A⟧ ⟹ 𝒟 (try x1 catch(x2 x3) x4) A'›
19. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (INIT x1 (x2,x3) ← x4) A⟧ ⟹ 𝒟 (INIT x1 (x2,x3) ← x4) A'›
20. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (RI (x1,x2) ; x3 ← x4) A⟧ ⟹ 𝒟 (RI (x1,x2) ; x3 ← x4) A'›
21. ‹⋀A A'. ⟦A ⊑ A'; 𝒟s [] A⟧ ⟹ 𝒟s [] A'›
22. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟s x2 A⟧ ⟹ 𝒟s x2 A'; A ⊑ A'; 𝒟s (x1 # x2) A⟧ ⟹ 𝒟s (x1 # x2) A'›*)
case BinOp (*‹⟦?A ⊑ ?A'; 𝒟 x1_ ?A⟧ ⟹ 𝒟 x1_ ?A'› ‹⟦(?A::'a set option) ⊑ (?A'::'a set option); 𝒟 (x3_::'a exp) ?A⟧ ⟹ 𝒟 x3_ ?A'› ‹A ⊑ A'› ‹𝒟 (x1_ «x2_» x3_) A›*)
then show "?case"
(*goal: ‹𝒟 ((x1_::'a::type exp) «x2_::bop» (x3_::'a::type exp)) (A'::'a::type set option)›*)
apply simp
(*goal: ‹𝒟 (x1_ «x2_» x3_) A'›*)
by (iprover dest:sqUn_lem)
next
(*goals:
1. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (new x) A⟧ ⟹ 𝒟 (new x) A'›
2. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (Cast x1 x2) A⟧ ⟹ 𝒟 (Cast x1 x2) A'›
3. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (Val x) A⟧ ⟹ 𝒟 (Val x) A'›
4. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (Var x) A⟧ ⟹ 𝒟 (Var x) A'›
5. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1:=x2) A⟧ ⟹ 𝒟 (x1:=x2) A'›
6. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; A ⊑ A'; 𝒟 (x1∙x2{x3}) A⟧ ⟹ 𝒟 (x1∙x2{x3}) A'›
7. ‹⋀x1 x2 x3 A A'. ⟦A ⊑ A'; 𝒟 (x1∙⇩sx2{x3}) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3}) A'›
8. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (x1∙x2{x3} := x4) A⟧ ⟹ 𝒟 (x1∙x2{x3} := x4) A'›
9. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2{x3} := x4) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3} := x4) A'›
10. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙x2(x3)) A⟧ ⟹ 𝒟 (x1∙x2(x3)) A'›
11. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2(x3)) A⟧ ⟹ 𝒟 (x1∙⇩sx2(x3)) A'›
12. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x3 A⟧ ⟹ 𝒟 x3 A'; A ⊑ A'; 𝒟 {x1:x2; x3} A⟧ ⟹ 𝒟 {x1:x2; x3} A'›
13. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1;; x2) A⟧ ⟹ 𝒟 (x1;; x2) A'›
14. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x3 A⟧ ⟹ 𝒟 x3 A'; A ⊑ A'; 𝒟 (if (x1) x2 else x3) A⟧ ⟹ 𝒟 (if (x1) x2 else x3) A'›
15. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (while (x1) x2) A⟧ ⟹ 𝒟 (while (x1) x2) A'›
16. ‹⋀x A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x A⟧ ⟹ 𝒟 x A'; A ⊑ A'; 𝒟 (throw x) A⟧ ⟹ 𝒟 (throw x) A'›
17. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (try x1 catch(x2 x3) x4) A⟧ ⟹ 𝒟 (try x1 catch(x2 x3) x4) A'›
18. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (INIT x1 (x2,x3) ← x4) A⟧ ⟹ 𝒟 (INIT x1 (x2,x3) ← x4) A'›
19. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (RI (x1,x2) ; x3 ← x4) A⟧ ⟹ 𝒟 (RI (x1,x2) ; x3 ← x4) A'›
20. ‹⋀A A'. ⟦A ⊑ A'; 𝒟s [] A⟧ ⟹ 𝒟s [] A'›
21. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟s x2 A⟧ ⟹ 𝒟s x2 A'; A ⊑ A'; 𝒟s (x1 # x2) A⟧ ⟹ 𝒟s (x1 # x2) A'›*)
case Var (*‹(A::'a set option) ⊑ (A'::'a set option)› ‹𝒟 (Var x_) A›*)
then show "?case"
(*goal: ‹𝒟 (Var x_) A'›*)
by (fastforce simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))
next
(*goals:
1. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (new x) A⟧ ⟹ 𝒟 (new x) A'›
2. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (Cast x1 x2) A⟧ ⟹ 𝒟 (Cast x1 x2) A'›
3. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (Val x) A⟧ ⟹ 𝒟 (Val x) A'›
4. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1:=x2) A⟧ ⟹ 𝒟 (x1:=x2) A'›
5. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; A ⊑ A'; 𝒟 (x1∙x2{x3}) A⟧ ⟹ 𝒟 (x1∙x2{x3}) A'›
6. ‹⋀x1 x2 x3 A A'. ⟦A ⊑ A'; 𝒟 (x1∙⇩sx2{x3}) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3}) A'›
7. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (x1∙x2{x3} := x4) A⟧ ⟹ 𝒟 (x1∙x2{x3} := x4) A'›
8. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2{x3} := x4) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3} := x4) A'›
9. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙x2(x3)) A⟧ ⟹ 𝒟 (x1∙x2(x3)) A'›
10. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2(x3)) A⟧ ⟹ 𝒟 (x1∙⇩sx2(x3)) A'›
11. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x3 A⟧ ⟹ 𝒟 x3 A'; A ⊑ A'; 𝒟 {x1:x2; x3} A⟧ ⟹ 𝒟 {x1:x2; x3} A'›
12. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1;; x2) A⟧ ⟹ 𝒟 (x1;; x2) A'›
13. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x3 A⟧ ⟹ 𝒟 x3 A'; A ⊑ A'; 𝒟 (if (x1) x2 else x3) A⟧ ⟹ 𝒟 (if (x1) x2 else x3) A'›
14. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (while (x1) x2) A⟧ ⟹ 𝒟 (while (x1) x2) A'›
15. ‹⋀x A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x A⟧ ⟹ 𝒟 x A'; A ⊑ A'; 𝒟 (throw x) A⟧ ⟹ 𝒟 (throw x) A'›
16. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (try x1 catch(x2 x3) x4) A⟧ ⟹ 𝒟 (try x1 catch(x2 x3) x4) A'›
17. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (INIT x1 (x2,x3) ← x4) A⟧ ⟹ 𝒟 (INIT x1 (x2,x3) ← x4) A'›
18. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (RI (x1,x2) ; x3 ← x4) A⟧ ⟹ 𝒟 (RI (x1,x2) ; x3 ← x4) A'›
19. ‹⋀A A'. ⟦A ⊑ A'; 𝒟s [] A⟧ ⟹ 𝒟s [] A'›
20. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟s x2 A⟧ ⟹ 𝒟s x2 A'; A ⊑ A'; 𝒟s (x1 # x2) A⟧ ⟹ 𝒟s (x1 # x2) A'›*)
case FAss (*‹⟦?A ⊑ ?A'; 𝒟 x1_ ?A⟧ ⟹ 𝒟 x1_ ?A'› ‹⟦?A ⊑ ?A'; 𝒟 x4_ ?A⟧ ⟹ 𝒟 x4_ ?A'› ‹A ⊑ A'› ‹𝒟 (x1_∙x2_{x3_} := x4_) A›*)
then show "?case"
(*goal: ‹𝒟 (x1_∙x2_{x3_} := x4_) A'›*)
apply simp
(*goal: ‹𝒟 ((x1_::'a::type exp)∙(x2_::char list){(x3_::char list)} := (x4_::'a::type exp)) (A'::'a::type set option)›*)
by (iprover dest:sqUn_lem)
next
(*goals:
1. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (new x) A⟧ ⟹ 𝒟 (new x) A'›
2. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (Cast x1 x2) A⟧ ⟹ 𝒟 (Cast x1 x2) A'›
3. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (Val x) A⟧ ⟹ 𝒟 (Val x) A'›
4. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1:=x2) A⟧ ⟹ 𝒟 (x1:=x2) A'›
5. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; A ⊑ A'; 𝒟 (x1∙x2{x3}) A⟧ ⟹ 𝒟 (x1∙x2{x3}) A'›
6. ‹⋀x1 x2 x3 A A'. ⟦A ⊑ A'; 𝒟 (x1∙⇩sx2{x3}) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3}) A'›
7. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2{x3} := x4) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3} := x4) A'›
8. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙x2(x3)) A⟧ ⟹ 𝒟 (x1∙x2(x3)) A'›
9. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2(x3)) A⟧ ⟹ 𝒟 (x1∙⇩sx2(x3)) A'›
10. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x3 A⟧ ⟹ 𝒟 x3 A'; A ⊑ A'; 𝒟 {x1:x2; x3} A⟧ ⟹ 𝒟 {x1:x2; x3} A'›
11. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1;; x2) A⟧ ⟹ 𝒟 (x1;; x2) A'›
12. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x3 A⟧ ⟹ 𝒟 x3 A'; A ⊑ A'; 𝒟 (if (x1) x2 else x3) A⟧ ⟹ 𝒟 (if (x1) x2 else x3) A'›
13. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (while (x1) x2) A⟧ ⟹ 𝒟 (while (x1) x2) A'›
14. ‹⋀x A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x A⟧ ⟹ 𝒟 x A'; A ⊑ A'; 𝒟 (throw x) A⟧ ⟹ 𝒟 (throw x) A'›
15. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (try x1 catch(x2 x3) x4) A⟧ ⟹ 𝒟 (try x1 catch(x2 x3) x4) A'›
16. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (INIT x1 (x2,x3) ← x4) A⟧ ⟹ 𝒟 (INIT x1 (x2,x3) ← x4) A'›
17. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (RI (x1,x2) ; x3 ← x4) A⟧ ⟹ 𝒟 (RI (x1,x2) ; x3 ← x4) A'›
18. ‹⋀A A'. ⟦A ⊑ A'; 𝒟s [] A⟧ ⟹ 𝒟s [] A'›
19. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟s x2 A⟧ ⟹ 𝒟s x2 A'; A ⊑ A'; 𝒟s (x1 # x2) A⟧ ⟹ 𝒟s (x1 # x2) A'›*)
case Call (*‹⟦?A ⊑ ?A'; 𝒟 x1_ ?A⟧ ⟹ 𝒟 x1_ ?A'› ‹⟦?A ⊑ ?A'; 𝒟s x3_ ?A⟧ ⟹ 𝒟s x3_ ?A'› ‹A ⊑ A'› ‹𝒟 (x1_∙x2_(x3_)) A›*)
then show "?case"
(*goal: ‹𝒟 ((x1_::'a::type exp)∙(x2_::char list)(x3_::'a::type exp list)) (A'::'a::type set option)›*)
apply simp
(*goal: ‹𝒟 (x1_∙x2_(x3_)) A'›*)
by (iprover dest:sqUn_lem)
next
(*goals:
1. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (new x) A⟧ ⟹ 𝒟 (new x) A'›
2. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (Cast x1 x2) A⟧ ⟹ 𝒟 (Cast x1 x2) A'›
3. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (Val x) A⟧ ⟹ 𝒟 (Val x) A'›
4. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1:=x2) A⟧ ⟹ 𝒟 (x1:=x2) A'›
5. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; A ⊑ A'; 𝒟 (x1∙x2{x3}) A⟧ ⟹ 𝒟 (x1∙x2{x3}) A'›
6. ‹⋀x1 x2 x3 A A'. ⟦A ⊑ A'; 𝒟 (x1∙⇩sx2{x3}) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3}) A'›
7. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2{x3} := x4) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3} := x4) A'›
8. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2(x3)) A⟧ ⟹ 𝒟 (x1∙⇩sx2(x3)) A'›
9. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x3 A⟧ ⟹ 𝒟 x3 A'; A ⊑ A'; 𝒟 {x1:x2; x3} A⟧ ⟹ 𝒟 {x1:x2; x3} A'›
10. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1;; x2) A⟧ ⟹ 𝒟 (x1;; x2) A'›
11. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x3 A⟧ ⟹ 𝒟 x3 A'; A ⊑ A'; 𝒟 (if (x1) x2 else x3) A⟧ ⟹ 𝒟 (if (x1) x2 else x3) A'›
12. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (while (x1) x2) A⟧ ⟹ 𝒟 (while (x1) x2) A'›
13. ‹⋀x A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x A⟧ ⟹ 𝒟 x A'; A ⊑ A'; 𝒟 (throw x) A⟧ ⟹ 𝒟 (throw x) A'›
14. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (try x1 catch(x2 x3) x4) A⟧ ⟹ 𝒟 (try x1 catch(x2 x3) x4) A'›
15. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (INIT x1 (x2,x3) ← x4) A⟧ ⟹ 𝒟 (INIT x1 (x2,x3) ← x4) A'›
16. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (RI (x1,x2) ; x3 ← x4) A⟧ ⟹ 𝒟 (RI (x1,x2) ; x3 ← x4) A'›
17. ‹⋀A A'. ⟦A ⊑ A'; 𝒟s [] A⟧ ⟹ 𝒟s [] A'›
18. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟s x2 A⟧ ⟹ 𝒟s x2 A'; A ⊑ A'; 𝒟s (x1 # x2) A⟧ ⟹ 𝒟s (x1 # x2) A'›*)
case Block (*‹⟦(?A::'a set option) ⊑ (?A'::'a set option); 𝒟 (x3_::'a exp) ?A⟧ ⟹ 𝒟 x3_ ?A'› ‹(A::'a set option) ⊑ (A'::'a set option)› ‹𝒟 {x1_:x2_; x3_} A›*)
then show "?case"
(*goal: ‹𝒟 {x1_:x2_; x3_} A'›*)
apply simp
(*goal: ‹𝒟 {x1_:x2_; x3_} A'›*)
by (iprover dest:diff_lem)
next
(*goals:
1. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (new x) A⟧ ⟹ 𝒟 (new x) A'›
2. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (Cast x1 x2) A⟧ ⟹ 𝒟 (Cast x1 x2) A'›
3. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (Val x) A⟧ ⟹ 𝒟 (Val x) A'›
4. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1:=x2) A⟧ ⟹ 𝒟 (x1:=x2) A'›
5. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; A ⊑ A'; 𝒟 (x1∙x2{x3}) A⟧ ⟹ 𝒟 (x1∙x2{x3}) A'›
6. ‹⋀x1 x2 x3 A A'. ⟦A ⊑ A'; 𝒟 (x1∙⇩sx2{x3}) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3}) A'›
7. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2{x3} := x4) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3} := x4) A'›
8. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2(x3)) A⟧ ⟹ 𝒟 (x1∙⇩sx2(x3)) A'›
9. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1;; x2) A⟧ ⟹ 𝒟 (x1;; x2) A'›
10. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x3 A⟧ ⟹ 𝒟 x3 A'; A ⊑ A'; 𝒟 (if (x1) x2 else x3) A⟧ ⟹ 𝒟 (if (x1) x2 else x3) A'›
11. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (while (x1) x2) A⟧ ⟹ 𝒟 (while (x1) x2) A'›
12. ‹⋀x A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x A⟧ ⟹ 𝒟 x A'; A ⊑ A'; 𝒟 (throw x) A⟧ ⟹ 𝒟 (throw x) A'›
13. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (try x1 catch(x2 x3) x4) A⟧ ⟹ 𝒟 (try x1 catch(x2 x3) x4) A'›
14. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (INIT x1 (x2,x3) ← x4) A⟧ ⟹ 𝒟 (INIT x1 (x2,x3) ← x4) A'›
15. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (RI (x1,x2) ; x3 ← x4) A⟧ ⟹ 𝒟 (RI (x1,x2) ; x3 ← x4) A'›
16. ‹⋀A A'. ⟦A ⊑ A'; 𝒟s [] A⟧ ⟹ 𝒟s [] A'›
17. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟s x2 A⟧ ⟹ 𝒟s x2 A'; A ⊑ A'; 𝒟s (x1 # x2) A⟧ ⟹ 𝒟s (x1 # x2) A'›*)
case Seq (*‹⟦?A ⊑ ?A'; 𝒟 x1_ ?A⟧ ⟹ 𝒟 x1_ ?A'› ‹⟦?A ⊑ ?A'; 𝒟 x2_ ?A⟧ ⟹ 𝒟 x2_ ?A'› ‹A ⊑ A'› ‹𝒟 ((x1_::'a exp);; (x2_::'a exp)) (A::'a set option)›*)
then show "?case"
(*goal: ‹𝒟 ((x1_::'a::type exp);; (x2_::'a::type exp)) (A'::'a::type set option)›*)
apply simp
(*goal: ‹𝒟 (x1_;; x2_) A'›*)
by (iprover dest:sqUn_lem)
next
(*goals:
1. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (new x) A⟧ ⟹ 𝒟 (new x) A'›
2. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (Cast x1 x2) A⟧ ⟹ 𝒟 (Cast x1 x2) A'›
3. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (Val x) A⟧ ⟹ 𝒟 (Val x) A'›
4. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1:=x2) A⟧ ⟹ 𝒟 (x1:=x2) A'›
5. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; A ⊑ A'; 𝒟 (x1∙x2{x3}) A⟧ ⟹ 𝒟 (x1∙x2{x3}) A'›
6. ‹⋀x1 x2 x3 A A'. ⟦A ⊑ A'; 𝒟 (x1∙⇩sx2{x3}) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3}) A'›
7. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2{x3} := x4) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3} := x4) A'›
8. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2(x3)) A⟧ ⟹ 𝒟 (x1∙⇩sx2(x3)) A'›
9. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x3 A⟧ ⟹ 𝒟 x3 A'; A ⊑ A'; 𝒟 (if (x1) x2 else x3) A⟧ ⟹ 𝒟 (if (x1) x2 else x3) A'›
10. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (while (x1) x2) A⟧ ⟹ 𝒟 (while (x1) x2) A'›
11. ‹⋀x A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x A⟧ ⟹ 𝒟 x A'; A ⊑ A'; 𝒟 (throw x) A⟧ ⟹ 𝒟 (throw x) A'›
12. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (try x1 catch(x2 x3) x4) A⟧ ⟹ 𝒟 (try x1 catch(x2 x3) x4) A'›
13. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (INIT x1 (x2,x3) ← x4) A⟧ ⟹ 𝒟 (INIT x1 (x2,x3) ← x4) A'›
14. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (RI (x1,x2) ; x3 ← x4) A⟧ ⟹ 𝒟 (RI (x1,x2) ; x3 ← x4) A'›
15. ‹⋀A A'. ⟦A ⊑ A'; 𝒟s [] A⟧ ⟹ 𝒟s [] A'›
16. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟s x2 A⟧ ⟹ 𝒟s x2 A'; A ⊑ A'; 𝒟s (x1 # x2) A⟧ ⟹ 𝒟s (x1 # x2) A'›*)
case Cond (*‹⟦?A ⊑ ?A'; 𝒟 x1_ ?A⟧ ⟹ 𝒟 x1_ ?A'› ‹⟦?A ⊑ ?A'; 𝒟 x2_ ?A⟧ ⟹ 𝒟 x2_ ?A'› ‹⟦?A ⊑ ?A'; 𝒟 x3_ ?A⟧ ⟹ 𝒟 x3_ ?A'› ‹A ⊑ A'› ‹𝒟 (if (x1_) x2_ else x3_) A›*)
then show "?case"
(*goal: ‹𝒟 (if (x1_) x2_ else x3_) A'›*)
apply simp
(*goal: ‹𝒟 (if (x1_) x2_ else x3_) A'›*)
by (iprover dest:sqUn_lem)
next
(*goals:
1. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (new x) A⟧ ⟹ 𝒟 (new x) A'›
2. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (Cast x1 x2) A⟧ ⟹ 𝒟 (Cast x1 x2) A'›
3. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (Val x) A⟧ ⟹ 𝒟 (Val x) A'›
4. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1:=x2) A⟧ ⟹ 𝒟 (x1:=x2) A'›
5. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; A ⊑ A'; 𝒟 (x1∙x2{x3}) A⟧ ⟹ 𝒟 (x1∙x2{x3}) A'›
6. ‹⋀x1 x2 x3 A A'. ⟦A ⊑ A'; 𝒟 (x1∙⇩sx2{x3}) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3}) A'›
7. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2{x3} := x4) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3} := x4) A'›
8. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2(x3)) A⟧ ⟹ 𝒟 (x1∙⇩sx2(x3)) A'›
9. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (while (x1) x2) A⟧ ⟹ 𝒟 (while (x1) x2) A'›
10. ‹⋀x A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x A⟧ ⟹ 𝒟 x A'; A ⊑ A'; 𝒟 (throw x) A⟧ ⟹ 𝒟 (throw x) A'›
11. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (try x1 catch(x2 x3) x4) A⟧ ⟹ 𝒟 (try x1 catch(x2 x3) x4) A'›
12. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (INIT x1 (x2,x3) ← x4) A⟧ ⟹ 𝒟 (INIT x1 (x2,x3) ← x4) A'›
13. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (RI (x1,x2) ; x3 ← x4) A⟧ ⟹ 𝒟 (RI (x1,x2) ; x3 ← x4) A'›
14. ‹⋀A A'. ⟦A ⊑ A'; 𝒟s [] A⟧ ⟹ 𝒟s [] A'›
15. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟s x2 A⟧ ⟹ 𝒟s x2 A'; A ⊑ A'; 𝒟s (x1 # x2) A⟧ ⟹ 𝒟s (x1 # x2) A'›*)
case While (*‹⟦?A ⊑ ?A'; 𝒟 x1_ ?A⟧ ⟹ 𝒟 x1_ ?A'› ‹⟦(?A::'a::type set option) ⊑ (?A'::'a::type set option); 𝒟 (x2_::'a::type exp) ?A⟧ ⟹ 𝒟 x2_ ?A'› ‹A ⊑ A'› ‹𝒟 (while (x1_) x2_) A›*)
then show "?case"
(*goal: ‹𝒟 (while (x1_) x2_) A'›*)
apply simp
(*goal: ‹𝒟 (while (x1_) x2_) A'›*)
by (iprover dest:sqUn_lem)
next
(*goals:
1. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (new x) A⟧ ⟹ 𝒟 (new x) A'›
2. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (Cast x1 x2) A⟧ ⟹ 𝒟 (Cast x1 x2) A'›
3. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (Val x) A⟧ ⟹ 𝒟 (Val x) A'›
4. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1:=x2) A⟧ ⟹ 𝒟 (x1:=x2) A'›
5. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; A ⊑ A'; 𝒟 (x1∙x2{x3}) A⟧ ⟹ 𝒟 (x1∙x2{x3}) A'›
6. ‹⋀x1 x2 x3 A A'. ⟦A ⊑ A'; 𝒟 (x1∙⇩sx2{x3}) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3}) A'›
7. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2{x3} := x4) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3} := x4) A'›
8. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2(x3)) A⟧ ⟹ 𝒟 (x1∙⇩sx2(x3)) A'›
9. ‹⋀x A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x A⟧ ⟹ 𝒟 x A'; A ⊑ A'; 𝒟 (throw x) A⟧ ⟹ 𝒟 (throw x) A'›
10. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (try x1 catch(x2 x3) x4) A⟧ ⟹ 𝒟 (try x1 catch(x2 x3) x4) A'›
11. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (INIT x1 (x2,x3) ← x4) A⟧ ⟹ 𝒟 (INIT x1 (x2,x3) ← x4) A'›
12. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (RI (x1,x2) ; x3 ← x4) A⟧ ⟹ 𝒟 (RI (x1,x2) ; x3 ← x4) A'›
13. ‹⋀A A'. ⟦A ⊑ A'; 𝒟s [] A⟧ ⟹ 𝒟s [] A'›
14. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟s x2 A⟧ ⟹ 𝒟s x2 A'; A ⊑ A'; 𝒟s (x1 # x2) A⟧ ⟹ 𝒟s (x1 # x2) A'›*)
case TryCatch (*‹⟦(?A::'a set option) ⊑ (?A'::'a set option); 𝒟 (x1_::'a exp) ?A⟧ ⟹ 𝒟 x1_ ?A'› ‹⟦?A ⊑ ?A'; 𝒟 x4_ ?A⟧ ⟹ 𝒟 x4_ ?A'› ‹A ⊑ A'› ‹𝒟 (try x1_ catch(x2_ x3_) x4_) A›*)
then show "?case"
(*goal: ‹𝒟 (try x1_ catch(x2_ x3_) x4_) A'›*)
apply simp
(*goal: ‹𝒟 (try x1_ catch(x2_ x3_) x4_) A'›*)
by (iprover dest:sqUn_lem)
next
(*goals:
1. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (new x) A⟧ ⟹ 𝒟 (new x) A'›
2. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (Cast x1 x2) A⟧ ⟹ 𝒟 (Cast x1 x2) A'›
3. ‹⋀x A A'. ⟦A ⊑ A'; 𝒟 (Val x) A⟧ ⟹ 𝒟 (Val x) A'›
4. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1:=x2) A⟧ ⟹ 𝒟 (x1:=x2) A'›
5. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; A ⊑ A'; 𝒟 (x1∙x2{x3}) A⟧ ⟹ 𝒟 (x1∙x2{x3}) A'›
6. ‹⋀x1 x2 x3 A A'. ⟦A ⊑ A'; 𝒟 (x1∙⇩sx2{x3}) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3}) A'›
7. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2{x3} := x4) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3} := x4) A'›
8. ‹⋀x1 x2 x3 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2(x3)) A⟧ ⟹ 𝒟 (x1∙⇩sx2(x3)) A'›
9. ‹⋀x A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x A⟧ ⟹ 𝒟 x A'; A ⊑ A'; 𝒟 (throw x) A⟧ ⟹ 𝒟 (throw x) A'›
10. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (INIT x1 (x2,x3) ← x4) A⟧ ⟹ 𝒟 (INIT x1 (x2,x3) ← x4) A'›
11. ‹⋀x1 x2 x3 x4 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (RI (x1,x2) ; x3 ← x4) A⟧ ⟹ 𝒟 (RI (x1,x2) ; x3 ← x4) A'›
12. ‹⋀A A'. ⟦A ⊑ A'; 𝒟s [] A⟧ ⟹ 𝒟s [] A'›
13. ‹⋀x1 x2 A A'. ⟦⋀A A'. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; ⋀A A'. ⟦A ⊑ A'; 𝒟s x2 A⟧ ⟹ 𝒟s x2 A'; A ⊑ A'; 𝒟s (x1 # x2) A⟧ ⟹ 𝒟s (x1 # x2) A'›*)
case Cons_exp (*‹⟦?A ⊑ ?A'; 𝒟 x1_ ?A⟧ ⟹ 𝒟 x1_ ?A'› ‹⟦?A ⊑ ?A'; 𝒟s x2_ ?A⟧ ⟹ 𝒟s x2_ ?A'› ‹A ⊑ A'› ‹𝒟s (x1_ # x2_) A›*)
then show "?case"
(*goal: ‹𝒟s (x1_ # x2_) A'›*)
apply simp
(*goal: ‹𝒟s (x1_ # x2_) A'›*)
by (iprover dest:sqUn_lem)
qed (simp_all)
(*solves the remaining goals:
1. ‹⋀(x::char list) (A::'a set option) A'::'a set option. ⟦A ⊑ A'; 𝒟 (new x) A⟧ ⟹ 𝒟 (new x) A'›
2. ‹⋀(x1::char list) (x2::'a exp) (A::'a set option) A'::'a set option. ⟦⋀(A::'a set option) A'::'a set option. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (Cast x1 x2) A⟧ ⟹ 𝒟 (Cast x1 x2) A'›
3. ‹⋀(x::val) (A::'a set option) A'::'a set option. ⟦A ⊑ A'; 𝒟 (Val x) A⟧ ⟹ 𝒟 (Val x) A'›
4. ‹⋀(x1::'a) (x2::'a exp) (A::'a set option) A'::'a set option. ⟦⋀(A::'a set option) A'::'a set option. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; A ⊑ A'; 𝒟 (x1:=x2) A⟧ ⟹ 𝒟 (x1:=x2) A'›
5. ‹⋀(x1::'a exp) (x2::char list) (x3::char list) (A::'a set option) A'::'a set option. ⟦⋀(A::'a set option) A'::'a set option. ⟦A ⊑ A'; 𝒟 x1 A⟧ ⟹ 𝒟 x1 A'; A ⊑ A'; 𝒟 (x1∙x2{x3}) A⟧ ⟹ 𝒟 (x1∙x2{x3}) A'›
6. ‹⋀(x1::char list) (x2::char list) (x3::char list) (A::'a set option) A'::'a set option. ⟦A ⊑ A'; 𝒟 (x1∙⇩sx2{x3}) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3}) A'›
7. ‹⋀(x1::char list) (x2::char list) (x3::char list) (x4::'a exp) (A::'a set option) A'::'a set option. ⟦⋀(A::'a set option) A'::'a set option. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2{x3} := x4) A⟧ ⟹ 𝒟 (x1∙⇩sx2{x3} := x4) A'›
8. ‹⋀(x1::char list) (x2::char list) (x3::'a exp list) (A::'a set option) A'::'a set option. ⟦⋀(A::'a set option) A'::'a set option. ⟦A ⊑ A'; 𝒟s x3 A⟧ ⟹ 𝒟s x3 A'; A ⊑ A'; 𝒟 (x1∙⇩sx2(x3)) A⟧ ⟹ 𝒟 (x1∙⇩sx2(x3)) A'›
9. ‹⋀(x::'a exp) (A::'a set option) A'::'a set option. ⟦⋀(A::'a set option) A'::'a set option. ⟦A ⊑ A'; 𝒟 x A⟧ ⟹ 𝒟 x A'; A ⊑ A'; 𝒟 (throw x) A⟧ ⟹ 𝒟 (throw x) A'›
10. ‹⋀(x1::char list) (x2::char list list) (x3::bool) (x4::'a exp) (A::'a set option) A'::'a set option. ⟦⋀(A::'a set option) A'::'a set option. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (INIT x1 (x2,x3) ← x4) A⟧ ⟹ 𝒟 (INIT x1 (x2,x3) ← x4) A'›
11. ‹⋀(x1::char list) (x2::'a exp) (x3::char list list) (x4::'a exp) (A::'a set option) A'::'a set option. ⟦⋀(A::'a set option) A'::'a set option. ⟦A ⊑ A'; 𝒟 x2 A⟧ ⟹ 𝒟 x2 A'; ⋀(A::'a set option) A'::'a set option. ⟦A ⊑ A'; 𝒟 x4 A⟧ ⟹ 𝒟 x4 A'; A ⊑ A'; 𝒟 (RI (x1,x2) ; x3 ← x4) A⟧ ⟹ 𝒟 (RI (x1,x2) ; x3 ← x4) A'›
12. ‹⋀(A::'a set option) A'::'a set option. ⟦A ⊑ A'; 𝒟s [] A⟧ ⟹ 𝒟s [] A'›*)
(*>*)
(* And this is the order of premises preferred during application: *)
lemma D_mono': "𝒟 e A ⟹ A ⊑ A' ⟹ 𝒟 e A'"
and Ds_mono': "𝒟s es A ⟹ A ⊑ A' ⟹ 𝒟s es A'"
(*<*)
(*goals:
1. ‹⟦𝒟 e A; A ⊑ A'⟧ ⟹ 𝒟 e A'›
2. ‹⟦𝒟s es A; A ⊑ A'⟧ ⟹ 𝒟s es A'›
discuss goal 1*)
apply (blast intro:D_mono (*‹⟦?A ⊑ ?A'; 𝒟 ?e ?A⟧ ⟹ 𝒟 ?e ?A'›*))
(*discuss goal 2*)
apply (blast intro:Ds_mono (*‹⟦?A ⊑ ?A'; 𝒟s ?es ?A⟧ ⟹ 𝒟s ?es ?A'›*))
(*proven 2 subgoals*) .(*>*)
lemma Ds_Vals: "𝒟s (map Val vs) A" apply (induct vs)
(*goals:
1. ‹𝒟s (map Val []) A›
2. ‹⋀a vs. 𝒟s (map Val vs) A ⟹ 𝒟s (map Val (a # vs)) A›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*proven 2 subgoals*) .
end
| {
"path": "afp-2025-02-12/thys/JinjaDCI/J/DefAss.thy",
"repo": "afp-2025-02-12",
"sha": "7855f00146a1cf401480cde1fbf066807b5cf4e8702f93a51f3be507aa6d9a08"
} |
theory Interfaces_Normalize
imports Common_Primitive_Lemmas
begin
subsection‹Optimizing interfaces in match expressions›
(*returns: (list of positive interfaces × a list of negated interfaces)
it matches the conjunction of both
None if the expression cannot match*)
definition compress_interfaces :: "iface negation_type list ⇒ (iface list × iface list) option" where
"compress_interfaces ifces ≡ case (compress_pos_interfaces (getPos ifces))
of None ⇒ None
| Some i ⇒ if
∃negated_ifce ∈ set (getNeg ifces). iface_subset i negated_ifce
then
None
else if
¬ iface_is_wildcard i
then
Some ([i], [])
else
Some ((if i = ifaceAny then [] else [i]), getNeg ifces)"
context
begin
private lemma compress_interfaces_None:
assumes generic: "primitive_matcher_generic β"
shows
"compress_interfaces ifces = None ⟹ ¬ matches (β, α) (alist_and (NegPos_map IIface ifces)) a p"
"compress_interfaces ifces = None ⟹ ¬ matches (β, α) (alist_and (NegPos_map OIface ifces)) a p"
apply (simp_all add: compress_interfaces_def)
(*top goal: ‹compress_interfaces ifces = None ⟹ ¬ matches (β, α) (alist_and (NegPos_map IIface ifces)) a p› and 1 goal remains*)
apply (simp_all add: nt_match_list_matches[symmetric] nt_match_list_simp)
(*top goal: ‹(case compress_pos_interfaces (getPos ifces) of None ⇒ None | Some i ⇒ if ∃negated_ifce∈set (getNeg ifces). iface_subset i negated_ifce then None else if ¬ iface_is_wildcard i then Some ([i], []) else Some (if i = ifaceAny then [] else [i], getNeg ifces)) = None ⟹ ¬ matches (β, α) (alist_and (NegPos_map IIface ifces)) a p› and 1 goal remains*)
apply (simp_all add: NegPos_map_simps primitive_matcher_generic.Iface_single[OF generic] primitive_matcher_generic.Iface_single_not[OF generic])
(*top goal: ‹(case compress_pos_interfaces (getPos ifces) of None ⇒ None | Some i ⇒ if ∃negated_ifce∈set (getNeg ifces). iface_subset i negated_ifce then None else if ¬ iface_is_wildcard i then Some ([i], []) else Some (if i = ifaceAny then [] else [i], getNeg ifces)) = None ⟹ (∃m∈set (getPos (NegPos_map IIface ifces)). ¬ matches (β, α) (Match m) a p) ∨ (∃m∈set (getNeg (NegPos_map IIface ifces)). ¬ matches (β, α) (MatchNot (Match m)) a p)› and 1 goal remains*)
apply (case_tac [!] "compress_pos_interfaces (getPos ifces)")
(*top goal: ‹(case compress_pos_interfaces (getPos (ifces::iface negation_type list)) of None ⇒ None | Some (i::iface) ⇒ if ∃negated_ifce::iface∈set (getNeg ifces). iface_subset i negated_ifce then None else if ¬ iface_is_wildcard i then Some ([i], []) else Some (if i = ifaceAny then [] else [i], getNeg ifces)) = None ⟹ (∃m::iface∈set (getPos ifces). ¬ match_iface m (p_iiface (p::('a, 'b) tagged_packet_scheme))) ∨ (∃m::iface∈set (getNeg ifces). match_iface m (p_iiface p))› and 1 goal remains*)
apply simp_all
(*top goal: ‹⟦(case compress_pos_interfaces (getPos ifces) of None ⇒ None | Some i ⇒ if ∃negated_ifce∈set (getNeg ifces). iface_subset i negated_ifce then None else if ¬ iface_is_wildcard i then Some ([i], []) else Some (if i = ifaceAny then [] else [i], getNeg ifces)) = None; compress_pos_interfaces (getPos ifces) = None⟧ ⟹ (∃m∈set (getPos ifces). ¬ match_iface m (p_iiface p)) ∨ (∃m∈set (getNeg ifces). match_iface m (p_iiface p))› and 3 goals remain*)
apply (drule_tac p_i="p_iiface p" in compress_pos_interfaces_None (*‹compress_pos_interfaces ?ifces = None ⟹ ¬ (∀i∈set ?ifces. match_iface i ?p_i)›*))
(*top goal: ‹compress_pos_interfaces (getPos ifces) = None ⟹ (∃m∈set (getPos ifces). ¬ match_iface m (p_iiface p)) ∨ (∃m∈set (getNeg ifces). match_iface m (p_iiface p))› and 3 goals remain*)
apply (simp; fail)
(*top goal: ‹¬ (∀i∈set (getPos ifces). match_iface i (p_iiface p)) ⟹ (∃m∈set (getPos ifces). ¬ match_iface m (p_iiface p)) ∨ (∃m∈set (getNeg ifces). match_iface m (p_iiface p))› and 3 goals remain*)
apply (drule_tac p_i="p_iiface p" in compress_pos_interfaces_Some (*‹compress_pos_interfaces ?ifces = Some ?ifce ⟹ match_iface ?ifce ?p_i = (∀i∈set ?ifces. match_iface i ?p_i)›*))
(*top goal: ‹⋀a. ⟦(if ∃x∈set (getNeg ifces). iface_subset a x then None else if ¬ iface_is_wildcard a then Some ([a], []) else Some (if a = ifaceAny then [] else [a], getNeg ifces)) = None; compress_pos_interfaces (getPos ifces) = Some a⟧ ⟹ (∃m∈set (getPos ifces). ¬ match_iface m (p_iiface p)) ∨ (∃m∈set (getNeg ifces). match_iface m (p_iiface p))› and 2 goals remain*)
apply (simp split:if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
(*top goal: ‹⋀a. ⟦(if ∃x∈set (getNeg ifces). iface_subset a x then None else if ¬ iface_is_wildcard a then Some ([a], []) else Some (if a = ifaceAny then [] else [a], getNeg ifces)) = None; match_iface a (p_iiface p) = (∀i∈set (getPos ifces). match_iface i (p_iiface p))⟧ ⟹ (∃m∈set (getPos ifces). ¬ match_iface m (p_iiface p)) ∨ (∃m∈set (getNeg ifces). match_iface m (p_iiface p))› and 2 goals remain*)
using iface_subset (*‹iface_subset ?i1.0 ?i2.0 = ({i. match_iface ?i1.0 i} ⊆ {i. match_iface ?i2.0 i})›*) apply blast
(*top goal: ‹⋀a. ⟦match_iface a (p_iiface p) = (∀i∈set (getPos ifces). match_iface i (p_iiface p)); ∃x∈set (getNeg ifces). iface_subset a x⟧ ⟹ (∃m∈set (getPos ifces). ¬ match_iface m (p_iiface p)) ∨ (∃m∈set (getNeg ifces). match_iface m (p_iiface p))› and 2 goals remain*)
apply (drule_tac p_i="p_oiface p" in compress_pos_interfaces_None (*‹compress_pos_interfaces ?ifces = None ⟹ ¬ (∀i∈set ?ifces. match_iface i ?p_i)›*))
(*top goal: ‹compress_pos_interfaces (getPos ifces) = None ⟹ (∃m∈set (getPos ifces). ¬ match_iface m (p_oiface p)) ∨ (∃m∈set (getNeg ifces). match_iface m (p_oiface p))› and 1 goal remains*)
apply (simp; fail)
(*top goal: ‹¬ (∀i∈set (getPos ifces). match_iface i (p_oiface p)) ⟹ (∃m∈set (getPos ifces). ¬ match_iface m (p_oiface p)) ∨ (∃m∈set (getNeg ifces). match_iface m (p_oiface p))› and 1 goal remains*)
apply (drule_tac p_i="p_oiface p" in compress_pos_interfaces_Some (*‹compress_pos_interfaces ?ifces = Some ?ifce ⟹ match_iface ?ifce ?p_i = (∀i∈set ?ifces. match_iface i ?p_i)›*))
(*goal: ‹⋀a::iface. ⟦(if ∃x::iface∈set (getNeg (ifces::iface negation_type list)). iface_subset a x then None else if ¬ iface_is_wildcard a then Some ([a], []) else Some (if a = ifaceAny then [] else [a], getNeg ifces)) = None; compress_pos_interfaces (getPos ifces) = Some a⟧ ⟹ (∃m::iface∈set (getPos ifces). ¬ match_iface m (p_oiface (p::('a, 'b) tagged_packet_scheme))) ∨ (∃m::iface∈set (getNeg ifces). match_iface m (p_oiface p))›*)
apply (simp split:if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
(*goal: ‹⋀a. ⟦(if ∃x∈set (getNeg ifces). iface_subset a x then None else if ¬ iface_is_wildcard a then Some ([a], []) else Some (if a = ifaceAny then [] else [a], getNeg ifces)) = None; match_iface a (p_oiface p) = (∀i∈set (getPos ifces). match_iface i (p_oiface p))⟧ ⟹ (∃m∈set (getPos ifces). ¬ match_iface m (p_oiface p)) ∨ (∃m∈set (getNeg ifces). match_iface m (p_oiface p))›*)
using iface_subset (*‹iface_subset ?i1.0 ?i2.0 = ({i. match_iface ?i1.0 i} ⊆ {i. match_iface ?i2.0 i})›*) by blast
private lemma compress_interfaces_Some:
assumes generic: "primitive_matcher_generic β"
shows
"compress_interfaces ifces = Some (i_pos, i_neg) ⟹
matches (β, α) (alist_and (NegPos_map IIface ((map Pos i_pos)@(map Neg i_neg)))) a p ⟷
matches (β, α) (alist_and (NegPos_map IIface ifces)) a p"
"compress_interfaces ifces = Some (i_pos, i_neg) ⟹
matches (β, α) (alist_and (NegPos_map OIface ((map Pos i_pos)@(map Neg i_neg)))) a p ⟷
matches (β, α) (alist_and (NegPos_map OIface ifces)) a p"
apply (simp_all add: compress_interfaces_def)
(*top goal: ‹compress_interfaces ifces = Some (i_pos, i_neg) ⟹ matches (β, α) (alist_and (NegPos_map IIface (map Pos i_pos @ map Neg i_neg))) a p = matches (β, α) (alist_and (NegPos_map IIface ifces)) a p› and 1 goal remains*)
apply (simp_all add: bunch_of_lemmata_about_matches(1) alist_and_append NegPos_map_append)
(*top goal: ‹(case compress_pos_interfaces (getPos ifces) of None ⇒ None | Some i ⇒ if ∃negated_ifce∈set (getNeg ifces). iface_subset i negated_ifce then None else if ¬ iface_is_wildcard i then Some ([i], []) else Some (if i = ifaceAny then [] else [i], getNeg ifces)) = Some (i_pos, i_neg) ⟹ matches (β, α) (alist_and (NegPos_map IIface (map Pos i_pos @ map Neg i_neg))) a p = matches (β, α) (alist_and (NegPos_map IIface ifces)) a p› and 1 goal remains*)
apply (simp_all add: nt_match_list_matches[symmetric] nt_match_list_simp)
(*top goal: ‹(case compress_pos_interfaces (getPos ifces) of None ⇒ None | Some i ⇒ if ∃negated_ifce∈set (getNeg ifces). iface_subset i negated_ifce then None else if ¬ iface_is_wildcard i then Some ([i], []) else Some (if i = ifaceAny then [] else [i], getNeg ifces)) = Some (i_pos, i_neg) ⟹ (matches (β, α) (alist_and (NegPos_map IIface (map Pos i_pos))) a p ∧ matches (β, α) (alist_and (NegPos_map IIface (map Neg i_neg))) a p) = matches (β, α) (alist_and (NegPos_map IIface ifces)) a p› and 1 goal remains*)
apply (simp_all add: NegPos_map_simps primitive_matcher_generic.Iface_single[OF generic] primitive_matcher_generic.Iface_single_not[OF generic])
(*top goal: ‹(case compress_pos_interfaces (getPos ifces) of None ⇒ None | Some i ⇒ if ∃negated_ifce∈set (getNeg ifces). iface_subset i negated_ifce then None else if ¬ iface_is_wildcard i then Some ([i], []) else Some (if i = ifaceAny then [] else [i], getNeg ifces)) = Some (i_pos, i_neg) ⟹ ((∀m∈set (getPos (NegPos_map IIface (map Pos i_pos))). matches (β, α) (Match m) a p) ∧ (∀m∈set (getNeg (NegPos_map IIface (map Pos i_pos))). matches (β, α) (MatchNot (Match m)) a p) ∧ (∀m∈set (getPos (NegPos_map IIface (map Neg i_neg))). matches (β, α) (Match m) a p) ∧ (∀m∈set (getNeg (NegPos_map IIface (map Neg i_neg))). matches (β, α) (MatchNot (Match m)) a p)) = ((∀m∈set (getPos (NegPos_map IIface ifces)). matches (β, α) (Match m) a p) ∧ (∀m∈set (getNeg (NegPos_map IIface ifces)). matches (β, α) (MatchNot (Match m)) a p))› and 1 goal remains*)
apply (case_tac [!] "compress_pos_interfaces (getPos ifces)")
(*top goal: ‹(case compress_pos_interfaces (getPos ifces) of None ⇒ None | Some i ⇒ if ∃negated_ifce∈set (getNeg ifces). iface_subset i negated_ifce then None else if ¬ iface_is_wildcard i then Some ([i], []) else Some (if i = ifaceAny then [] else [i], getNeg ifces)) = Some (i_pos, i_neg) ⟹ ((∀m∈set i_pos. match_iface m (p_iiface p)) ∧ (∀m∈set i_neg. ¬ match_iface m (p_iiface p))) = ((∀m∈set (getPos ifces). match_iface m (p_iiface p)) ∧ (∀m∈set (getNeg ifces). ¬ match_iface m (p_iiface p)))› and 1 goal remains*)
apply simp_all
(*top goal: ‹⟦(case compress_pos_interfaces (getPos (ifces::iface negation_type list)) of None ⇒ None | Some (i::iface) ⇒ if ∃negated_ifce::iface∈set (getNeg ifces). iface_subset i negated_ifce then None else if ¬ iface_is_wildcard i then Some ([i], []) else Some (if i = ifaceAny then [] else [i], getNeg ifces)) = Some (i_pos::iface list, i_neg::iface list); compress_pos_interfaces (getPos ifces) = None⟧ ⟹ ((∀m::iface∈set i_pos. match_iface m (p_iiface (p::('a, 'b) tagged_packet_scheme))) ∧ (∀m::iface∈set i_neg. ¬ match_iface m (p_iiface p))) = ((∀m::iface∈set (getPos ifces). match_iface m (p_iiface p)) ∧ (∀m::iface∈set (getNeg ifces). ¬ match_iface m (p_iiface p)))› and 3 goals remain*)
apply (drule_tac p_i="p_iiface p" in compress_pos_interfaces_Some (*‹compress_pos_interfaces ?ifces = Some ?ifce ⟹ match_iface ?ifce ?p_i = (∀i∈set ?ifces. match_iface i ?p_i)›*))
(*top goal: ‹⋀a. ⟦(if ∃x∈set (getNeg ifces). iface_subset a x then None else if ¬ iface_is_wildcard a then Some ([a], []) else Some (if a = ifaceAny then [] else [a], getNeg ifces)) = Some (i_pos, i_neg); compress_pos_interfaces (getPos ifces) = Some a⟧ ⟹ ((∀m∈set i_pos. match_iface m (p_iiface p)) ∧ (∀m∈set i_neg. ¬ match_iface m (p_iiface p))) = ((∀m∈set (getPos ifces). match_iface m (p_iiface p)) ∧ (∀m∈set (getNeg ifces). ¬ match_iface m (p_iiface p)))› and 1 goal remains*)
apply (simp split:if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) add: match_ifaceAny (*‹match_iface ifaceAny (?i::char list)›*))
(*top goal: ‹⋀a. ⟦(if ∃x∈set (getNeg ifces). iface_subset a x then None else if ¬ iface_is_wildcard a then Some ([a], []) else Some (if a = ifaceAny then [] else [a], getNeg ifces)) = Some (i_pos, i_neg); match_iface a (p_iiface p) = (∀i∈set (getPos ifces). match_iface i (p_iiface p))⟧ ⟹ ((∀m∈set i_pos. match_iface m (p_iiface p)) ∧ (∀m∈set i_neg. ¬ match_iface m (p_iiface p))) = ((∀m∈set (getPos ifces). match_iface m (p_iiface p)) ∧ (∀m∈set (getNeg ifces). ¬ match_iface m (p_iiface p)))› and 1 goal remains*)
unfolding iface_is_wildcard_def
(*goals:
1. ‹⋀a. ⟦match_iface a (p_iiface p) = (∀i∈set (getPos ifces). match_iface i (p_iiface p)); ∀x∈set (getNeg ifces). ¬ iface_subset a x; ¬ iface_name_is_wildcard (iface_sel a); [a] = i_pos ∧ [] = i_neg⟧ ⟹ (∀m∈set i_pos. match_iface m (p_iiface p)) = ((∀m∈set (getPos ifces). match_iface m (p_iiface p)) ∧ (∀m∈set (getNeg ifces). ¬ match_iface m (p_iiface p)))›
2. ‹⋀a. ⟦match_iface a (p_iiface p) = (∀i∈set (getPos ifces). match_iface i (p_iiface p)); ∀x∈set i_neg. ¬ iface_subset a x; iface_name_is_wildcard (iface_sel a); a ≠ ifaceAny; [a] = i_pos ∧ getNeg ifces = i_neg⟧ ⟹ ((∀m∈set i_pos. match_iface m (p_iiface p)) ∧ (∀m∈set i_neg. ¬ match_iface m (p_iiface p))) = ((∀m∈set (getPos ifces). match_iface m (p_iiface p)) ∧ (∀m∈set i_neg. ¬ match_iface m (p_iiface p)))›
3. ‹⋀a. ⟦(if ∃x∈set (getNeg ifces). iface_subset a x then None else if ¬ iface_name_is_wildcard (iface_sel a) then Some ([a], []) else Some (if a = ifaceAny then [] else [a], getNeg ifces)) = Some (i_pos, i_neg); compress_pos_interfaces (getPos ifces) = Some a⟧ ⟹ ((∀m∈set i_pos. match_iface m (p_oiface p)) ∧ (∀m∈set i_neg. ¬ match_iface m (p_oiface p))) = ((∀m∈set (getPos ifces). match_iface m (p_oiface p)) ∧ (∀m∈set (getNeg ifces). ¬ match_iface m (p_oiface p)))›*)
using iface_subset (*‹iface_subset ?i1.0 ?i2.0 = ({i. match_iface ?i1.0 i} ⊆ {i. match_iface ?i2.0 i})›*) match_iface_case_nowildcard (*‹¬ iface_name_is_wildcard (?i::char list) ⟹ match_iface (Iface ?i) (?p_i::char list) = (?i = ?p_i)›*) apply (metis (no_types, lifting) Collect_mono_iff (*‹(Collect ?P ⊆ Collect ?Q) = (∀x. ?P x ⟶ ?Q x)›*) iface.collapse (*‹Iface (iface_sel ?iface) = ?iface›*) list.distinct( (*‹[] ≠ ?x21.0 # ?x22.0›*) 1) list.set_cases (*‹⟦?e ∈ set ?a; ⋀z2. ?a = ?e # z2 ⟹ ?thesis; ⋀z1 z2. ⟦?a = z1 # z2; ?e ∈ set z2⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) list.set_intros( (*‹?x21.0 ∈ set (?x21.0 # ?x22.0)›*) 1) set_ConsD (*‹?y ∈ set (?x # ?xs) ⟹ ?y = ?x ∨ ?y ∈ set ?xs›*))
(*top goal: ‹⋀a. ⟦match_iface a (p_iiface p) = (∀i∈set (getPos ifces). match_iface i (p_iiface p)); ∀x∈set (getNeg ifces). ¬ iface_subset a x; ¬ iface_name_is_wildcard (iface_sel a); [a] = i_pos ∧ [] = i_neg⟧ ⟹ (∀m∈set i_pos. match_iface m (p_iiface p)) = ((∀m∈set (getPos ifces). match_iface m (p_iiface p)) ∧ (∀m∈set (getNeg ifces). ¬ match_iface m (p_iiface p)))› and 2 goals remain*)
apply force
(*top goal: ‹⋀a::iface. ⟦match_iface a (p_iiface (p::('a, 'b) tagged_packet_scheme)) = (∀i::iface∈set (getPos (ifces::iface negation_type list)). match_iface i (p_iiface p)); ∀x::iface∈set (i_neg::iface list). ¬ iface_subset a x; iface_name_is_wildcard (iface_sel a); a ≠ ifaceAny; [a] = (i_pos::iface list) ∧ getNeg ifces = i_neg⟧ ⟹ ((∀m::iface∈set i_pos. match_iface m (p_iiface p)) ∧ (∀m::iface∈set i_neg. ¬ match_iface m (p_iiface p))) = ((∀m::iface∈set (getPos ifces). match_iface m (p_iiface p)) ∧ (∀m::iface∈set i_neg. ¬ match_iface m (p_iiface p)))› and 1 goal remains*)
apply (drule_tac p_i="p_oiface p" in compress_pos_interfaces_Some (*‹compress_pos_interfaces ?ifces = Some ?ifce ⟹ match_iface ?ifce ?p_i = (∀i∈set ?ifces. match_iface i ?p_i)›*))
(*goal: ‹⋀a. ⟦(if ∃x∈set (getNeg ifces). iface_subset a x then None else if ¬ iface_name_is_wildcard (iface_sel a) then Some ([a], []) else Some (if a = ifaceAny then [] else [a], getNeg ifces)) = Some (i_pos, i_neg); compress_pos_interfaces (getPos ifces) = Some a⟧ ⟹ ((∀m∈set i_pos. match_iface m (p_oiface p)) ∧ (∀m∈set i_neg. ¬ match_iface m (p_oiface p))) = ((∀m∈set (getPos ifces). match_iface m (p_oiface p)) ∧ (∀m∈set (getNeg ifces). ¬ match_iface m (p_oiface p)))›*)
apply (simp split:if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) add: match_ifaceAny (*‹match_iface ifaceAny ?i›*))
(*goal: ‹⋀a. ⟦(if ∃x∈set (getNeg ifces). iface_subset a x then None else if ¬ iface_name_is_wildcard (iface_sel a) then Some ([a], []) else Some (if a = ifaceAny then [] else [a], getNeg ifces)) = Some (i_pos, i_neg); match_iface a (p_oiface p) = (∀i∈set (getPos ifces). match_iface i (p_oiface p))⟧ ⟹ ((∀m∈set i_pos. match_iface m (p_oiface p)) ∧ (∀m∈set i_neg. ¬ match_iface m (p_oiface p))) = ((∀m∈set (getPos ifces). match_iface m (p_oiface p)) ∧ (∀m∈set (getNeg ifces). ¬ match_iface m (p_oiface p)))›*)
unfolding iface_is_wildcard_def iface_subset
(*goals:
1. ‹⋀a::iface. ⟦match_iface a (p_oiface (p::('a, 'b) tagged_packet_scheme)) = (∀i::iface∈set (getPos (ifces::iface negation_type list)). match_iface i (p_oiface p)); ∀x::iface∈set (getNeg ifces). ¬ Collect (match_iface a) ⊆ Collect (match_iface x); ¬ iface_name_is_wildcard (iface_sel a); [a] = (i_pos::iface list) ∧ [] = (i_neg::iface list)⟧ ⟹ (∀m::iface∈set i_pos. match_iface m (p_oiface p)) = ((∀m::iface∈set (getPos ifces). match_iface m (p_oiface p)) ∧ (∀m::iface∈set (getNeg ifces). ¬ match_iface m (p_oiface p)))›
2. ‹⋀a::iface. ⟦match_iface a (p_oiface (p::('a, 'b) tagged_packet_scheme)) = (∀i::iface∈set (getPos (ifces::iface negation_type list)). match_iface i (p_oiface p)); ∀x::iface∈set (i_neg::iface list). ¬ Collect (match_iface a) ⊆ Collect (match_iface x); iface_name_is_wildcard (iface_sel a); a ≠ ifaceAny; [a] = (i_pos::iface list) ∧ getNeg ifces = i_neg⟧ ⟹ ((∀m::iface∈set i_pos. match_iface m (p_oiface p)) ∧ (∀m::iface∈set i_neg. ¬ match_iface m (p_oiface p))) = ((∀m::iface∈set (getPos ifces). match_iface m (p_oiface p)) ∧ (∀m::iface∈set i_neg. ¬ match_iface m (p_oiface p)))›*)
using match_iface_case_nowildcard (*‹¬ iface_name_is_wildcard ?i ⟹ match_iface (Iface ?i) ?p_i = (?i = ?p_i)›*)
(*goals:
1. ‹⋀a::iface. ⟦match_iface a (p_oiface (p::('a, 'b) tagged_packet_scheme)) = (∀i::iface∈set (getPos (ifces::iface negation_type list)). match_iface i (p_oiface p)); ∀x::iface∈set (getNeg ifces). ¬ Collect (match_iface a) ⊆ Collect (match_iface x); ¬ iface_name_is_wildcard (iface_sel a); [a] = (i_pos::iface list) ∧ [] = (i_neg::iface list)⟧ ⟹ (∀m::iface∈set i_pos. match_iface m (p_oiface p)) = ((∀m::iface∈set (getPos ifces). match_iface m (p_oiface p)) ∧ (∀m::iface∈set (getNeg ifces). ¬ match_iface m (p_oiface p)))›
2. ‹⋀a::iface. ⟦match_iface a (p_oiface (p::('a, 'b) tagged_packet_scheme)) = (∀i::iface∈set (getPos (ifces::iface negation_type list)). match_iface i (p_oiface p)); ∀x::iface∈set (i_neg::iface list). ¬ Collect (match_iface a) ⊆ Collect (match_iface x); iface_name_is_wildcard (iface_sel a); a ≠ ifaceAny; [a] = (i_pos::iface list) ∧ getNeg ifces = i_neg⟧ ⟹ ((∀m::iface∈set i_pos. match_iface m (p_oiface p)) ∧ (∀m::iface∈set i_neg. ¬ match_iface m (p_oiface p))) = ((∀m::iface∈set (getPos ifces). match_iface m (p_oiface p)) ∧ (∀m::iface∈set i_neg. ¬ match_iface m (p_oiface p)))›
discuss goal 1*)
apply (metis iface.collapse (*‹Iface (iface_sel (?iface::iface)) = ?iface›*) list.distinct( (*‹[] ≠ (?x21.0::?'a) # (?x22.0::?'a list)›*) 1) list.inject (*‹((?x21.0::?'a) # (?x22.0::?'a list) = (?y21.0::?'a) # (?y22.0::?'a list)) = (?x21.0 = ?y21.0 ∧ ?x22.0 = ?y22.0)›*) list.set_cases (*‹⟦(?e::?'a) ∈ set (?a::?'a list); ⋀z2::?'a list. ?a = ?e # z2 ⟹ ?thesis::bool; ⋀(z1::?'a) z2::?'a list. ⟦?a = z1 # z2; ?e ∈ set z2⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) list.set_intros( (*‹(?x21.0::?'a) ∈ set (?x21.0 # (?x22.0::?'a list))›*) 1) mem_Collect_eq (*‹((?a::?'a) ∈ Collect (?P::?'a ⇒ bool)) = ?P ?a›*) subsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ∈ (?B::?'a set)) ⟹ ?A ⊆ ?B›*))
(*discuss goal 2*)
apply force
(*proven 2 subgoals*) .
definition compress_normalize_input_interfaces :: "'i::len common_primitive match_expr ⇒ 'i common_primitive match_expr option" where
"compress_normalize_input_interfaces m ≡ compress_normalize_primitive (is_Iiface, iiface_sel) IIface compress_interfaces m"
lemma compress_normalize_input_interfaces_Some:
assumes generic: "primitive_matcher_generic β"
and "normalized_nnf_match m" and "compress_normalize_input_interfaces m = Some m'"
shows "matches (β, α) m' a p ⟷ matches (β, α) m a p"
apply (rule compress_normalize_primitive_Some[OF assms(2) wf_disc_sel_common_primitive(5)] (*‹⟦compress_normalize_primitive (is_Iiface, iiface_sel) IIface ?f m = Some ?m'; ⋀as as_pos as_neg. ?f as = Some (as_pos, as_neg) ⟹ matches ?γ (alist_and (NegPos_map IIface (map Pos as_pos @ map Neg as_neg))) ?a ?p = matches ?γ (alist_and (NegPos_map IIface as)) ?a ?p⟧ ⟹ matches ?γ ?m' ?a ?p = matches ?γ m ?a ?p›*))
(*goal: ‹matches (β, α) m' a p = matches (β, α) m a p›*)
using assms(3) (*‹compress_normalize_input_interfaces m = Some m'›*) apply (simp add: compress_normalize_input_interfaces_def (*‹compress_normalize_input_interfaces (?m::?'i common_primitive match_expr) ≡ compress_normalize_primitive (is_Iiface, iiface_sel) IIface compress_interfaces ?m›*); fail)
(*top goal: ‹compress_normalize_primitive (is_Iiface, iiface_sel) IIface (?f::iface negation_type list ⇒ (iface list × iface list) option) (m::'a common_primitive match_expr) = Some (m'::'a common_primitive match_expr)› and 1 goal remains*)
using compress_interfaces_Some[OF generic] (*‹compress_interfaces ?ifces = Some (?i_pos, ?i_neg) ⟹ matches (β, ?α) (alist_and (NegPos_map IIface (map Pos ?i_pos @ map Neg ?i_neg))) ?a ?p = matches (β, ?α) (alist_and (NegPos_map IIface ?ifces)) ?a ?p› ‹compress_interfaces (?ifces::iface negation_type list) = Some (?i_pos::iface list, ?i_neg::iface list) ⟹ matches (β::'a::len common_primitive ⇒ ('a, 'b) tagged_packet_scheme ⇒ ternaryvalue, ?α::action ⇒ ('a, 'b) tagged_packet_scheme ⇒ bool) (alist_and (NegPos_map OIface (map Pos ?i_pos @ map Neg ?i_neg))) (?a::action) (?p::('a, 'b) tagged_packet_scheme) = matches (β, ?α) (alist_and (NegPos_map OIface ?ifces)) ?a ?p›*) by simp
lemma compress_normalize_input_interfaces_None:
assumes generic: "primitive_matcher_generic β"
and "normalized_nnf_match m" and "compress_normalize_input_interfaces m = None"
shows "¬ matches (β, α) m a p"
apply (rule compress_normalize_primitive_None[OF assms(2) wf_disc_sel_common_primitive(5)] (*‹⟦compress_normalize_primitive (is_Iiface, iiface_sel) IIface ?f m = None; ⋀as. ?f as = None ⟹ ¬ matches ?γ (alist_and (NegPos_map IIface as)) ?a ?p⟧ ⟹ ¬ matches ?γ m ?a ?p›*))
(*goal: ‹¬ matches (β::'a common_primitive ⇒ ('a, 'b) tagged_packet_scheme ⇒ ternaryvalue, α::action ⇒ ('a, 'b) tagged_packet_scheme ⇒ bool) (m::'a common_primitive match_expr) (a::action) (p::('a, 'b) tagged_packet_scheme)›*)
using assms(3) (*‹compress_normalize_input_interfaces (m::'a common_primitive match_expr) = None›*) apply (simp add: compress_normalize_input_interfaces_def (*‹compress_normalize_input_interfaces ?m ≡ compress_normalize_primitive (is_Iiface, iiface_sel) IIface compress_interfaces ?m›*); fail)
(*top goal: ‹compress_normalize_primitive (is_Iiface, iiface_sel) IIface ?f m = None› and 1 goal remains*)
using compress_interfaces_None[OF generic] (*‹compress_interfaces (?ifces::iface negation_type list) = None ⟹ ¬ matches (β::'a common_primitive ⇒ ('a, 'b) tagged_packet_scheme ⇒ ternaryvalue, ?α::action ⇒ ('a, 'b) tagged_packet_scheme ⇒ bool) (alist_and (NegPos_map IIface ?ifces)) (?a::action) (?p::('a, 'b) tagged_packet_scheme)› ‹compress_interfaces ?ifces = None ⟹ ¬ matches (β, ?α) (alist_and (NegPos_map OIface ?ifces)) ?a ?p›*) by simp
lemma compress_normalize_input_interfaces_nnf: "normalized_nnf_match m ⟹ compress_normalize_input_interfaces m = Some m' ⟹
normalized_nnf_match m'"
unfolding compress_normalize_input_interfaces_def
(*goal: ‹⟦normalized_nnf_match m; compress_normalize_primitive (is_Iiface, iiface_sel) IIface compress_interfaces m = Some m'⟧ ⟹ normalized_nnf_match m'›*)
using compress_normalize_primitive_nnf[OF wf_disc_sel_common_primitive ( 5 )] (*‹⟦normalized_nnf_match ?m; compress_normalize_primitive (is_Iiface, iiface_sel) IIface ?f ?m = Some ?m'⟧ ⟹ normalized_nnf_match ?m'›*) by blast
lemma compress_normalize_input_interfaces_not_introduces_Iiface:
"¬ has_disc is_Iiface m ⟹ normalized_nnf_match m ⟹ compress_normalize_input_interfaces m = Some m' ⟹
¬ has_disc is_Iiface m'"
apply (simp add: compress_normalize_input_interfaces_def (*‹compress_normalize_input_interfaces (?m::?'i::len common_primitive match_expr) ≡ compress_normalize_primitive (is_Iiface, iiface_sel) IIface compress_interfaces ?m›*))
(*goal: ‹⟦¬ has_disc is_Iiface m; normalized_nnf_match m; compress_normalize_input_interfaces m = Some m'⟧ ⟹ ¬ has_disc is_Iiface m'›*)
apply (drule compress_normalize_primitive_not_introduces_C[where m=m and C'=IIface] (*‹⟦¬ has_disc ?disc m; wf_disc_sel (?disc, ?sel) IIface; normalized_nnf_match m; compress_normalize_primitive (?disc, ?sel) ?C ?f m = Some ?m'; ⋀as_pos as_neg. ?f [] = Some (as_pos, as_neg) ⟹ as_pos = [] ∧ as_neg = []⟧ ⟹ ¬ has_disc ?disc ?m'›*))
(*goal: ‹⟦¬ has_disc is_Iiface m; normalized_nnf_match m; compress_normalize_primitive (is_Iiface, iiface_sel) IIface compress_interfaces m = Some m'⟧ ⟹ ¬ has_disc is_Iiface m'›*)
apply (simp_all add: wf_disc_sel_common_primitive(5))
(*top goal: ‹⟦normalized_nnf_match m; compress_normalize_primitive (is_Iiface, iiface_sel) IIface compress_interfaces m = Some m'⟧ ⟹ wf_disc_sel (is_Iiface, ?sel) IIface› and 4 goals remain*)
by (simp add: compress_interfaces_def (*‹compress_interfaces (?ifces::iface negation_type list) ≡ case compress_pos_interfaces (getPos ?ifces) of None ⇒ None | Some (i::iface) ⇒ if ∃negated_ifce::iface∈set (getNeg ?ifces). iface_subset i negated_ifce then None else if ¬ iface_is_wildcard i then Some ([i], []) else Some (if i = ifaceAny then [] else [i], getNeg ?ifces)›*) iface_is_wildcard_ifaceAny (*‹iface_is_wildcard ifaceAny›*))
lemma compress_normalize_input_interfaces_not_introduces_Iiface_negated:
assumes notdisc: "¬ has_disc_negated is_Iiface False m"
and nm: "normalized_nnf_match m"
and some: "compress_normalize_input_interfaces m = Some m'"
shows "¬ has_disc_negated is_Iiface False m'"
apply (rule compress_normalize_primitive_not_introduces_C_negated[OF notdisc wf_disc_sel_common_primitive(5) nm] (*‹⟦compress_normalize_primitive (is_Iiface, iiface_sel) IIface (?f::iface negation_type list ⇒ (iface list × iface list) option) (m::'a common_primitive match_expr) = Some (?m'::'a common_primitive match_expr); ⋀(as::iface negation_type list) (as_pos::iface list) as_neg::iface list. ⟦?f as = Some (as_pos, as_neg); getNeg as = []⟧ ⟹ as_neg = []⟧ ⟹ ¬ has_disc_negated is_Iiface False ?m'›*))
(*goal: ‹¬ has_disc_negated is_Iiface False m'›*)
using some (*‹compress_normalize_input_interfaces (m::'a common_primitive match_expr) = Some (m'::'a common_primitive match_expr)›*)
(*goals:
1. ‹compress_normalize_primitive (is_Iiface, iiface_sel) IIface ?f m = Some m'›
2. ‹⋀as as_pos as_neg. ⟦?f as = Some (as_pos, as_neg); getNeg as = []⟧ ⟹ as_neg = []›
discuss goal 1*)
apply (simp add: compress_normalize_input_interfaces_def (*‹compress_normalize_input_interfaces ?m ≡ compress_normalize_primitive (is_Iiface, iiface_sel) IIface compress_interfaces ?m›*))
(*discuss goal 2*)
apply (simp add: compress_interfaces_def (*‹compress_interfaces ?ifces ≡ case compress_pos_interfaces (getPos ?ifces) of None ⇒ None | Some i ⇒ if ∃negated_ifce∈set (getNeg ?ifces). iface_subset i negated_ifce then None else if ¬ iface_is_wildcard i then Some ([i], []) else Some (if i = ifaceAny then [] else [i], getNeg ?ifces)›*) split: option.split_asm (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
(*proven 2 subgoals*) .
(* only for arbitrary discs that do not match Iiface*)
lemma compress_normalize_input_interfaces_hasdisc:
"¬ has_disc disc m ⟹ (∀a. ¬ disc (IIface a)) ⟹ normalized_nnf_match m ⟹ compress_normalize_input_interfaces m = Some m' ⟹
normalized_nnf_match m' ∧ ¬ has_disc disc m'"
unfolding compress_normalize_input_interfaces_def
(*goal: ‹⟦¬ has_disc disc m; ∀a. ¬ disc (IIface a); normalized_nnf_match m; compress_normalize_primitive (is_Iiface, iiface_sel) IIface compress_interfaces m = Some m'⟧ ⟹ normalized_nnf_match m' ∧ ¬ has_disc disc m'›*)
using compress_normalize_primitive_hasdisc[OF _ wf_disc_sel_common_primitive ( 5 )] (*‹⟦¬ has_disc ?disc2.0 ?m; ∀a. ¬ ?disc2.0 (IIface a); normalized_nnf_match ?m; compress_normalize_primitive (is_Iiface, iiface_sel) IIface ?f ?m = Some ?m'⟧ ⟹ normalized_nnf_match ?m' ∧ ¬ has_disc ?disc2.0 ?m'›*) by blast
(* only for arbitrary discs that do not match Iiface*)
lemma compress_normalize_input_interfaces_hasdisc_negated:
"¬ has_disc_negated disc neg m ⟹ (∀a. ¬ disc (IIface a)) ⟹ normalized_nnf_match m ⟹ compress_normalize_input_interfaces m = Some m' ⟹
normalized_nnf_match m' ∧ ¬ has_disc_negated disc neg m'"
unfolding compress_normalize_input_interfaces_def
(*goal: ‹⟦¬ has_disc_negated disc neg m; ∀a. ¬ disc (IIface a); normalized_nnf_match m; compress_normalize_primitive (is_Iiface, iiface_sel) IIface compress_interfaces m = Some m'⟧ ⟹ normalized_nnf_match m' ∧ ¬ has_disc_negated disc neg m'›*)
using compress_normalize_primitive_hasdisc_negated[OF _ wf_disc_sel_common_primitive ( 5 )] (*‹⟦¬ has_disc_negated ?disc2.0 ?neg ?m; ∀a. ¬ ?disc2.0 (IIface a); normalized_nnf_match ?m; compress_normalize_primitive (is_Iiface, iiface_sel) IIface ?f ?m = Some ?m'⟧ ⟹ normalized_nnf_match ?m' ∧ ¬ has_disc_negated ?disc2.0 ?neg ?m'›*) by blast
lemma compress_normalize_input_interfaces_preserves_normalized_n_primitive:
"normalized_n_primitive (disc, sel) P m ⟹ (∀a. ¬ disc (IIface a)) ⟹ normalized_nnf_match m ⟹ compress_normalize_input_interfaces m = Some m' ⟹
normalized_nnf_match m' ∧ normalized_n_primitive (disc, sel) P m'"
unfolding compress_normalize_input_interfaces_def
(*goal: ‹⟦normalized_n_primitive (disc, sel) P m; ∀a. ¬ disc (IIface a); normalized_nnf_match m; compress_normalize_primitive (is_Iiface, iiface_sel) IIface compress_interfaces m = Some m'⟧ ⟹ normalized_nnf_match m' ∧ normalized_n_primitive (disc, sel) P m'›*)
using compress_normalize_primitve_preserves_normalized_n_primitive[OF _ wf_disc_sel_common_primitive ( 5 )] (*‹⟦normalized_n_primitive (?disc2.0, ?sel2.0) ?P ?m; ∀a. ¬ ?disc2.0 (IIface a); normalized_nnf_match ?m; compress_normalize_primitive (is_Iiface, iiface_sel) IIface ?f ?m = Some ?m'⟧ ⟹ normalized_nnf_match ?m' ∧ normalized_n_primitive (?disc2.0, ?sel2.0) ?P ?m'›*) by blast
value[code] "compress_normalize_input_interfaces
(MatchAnd (MatchAnd (MatchAnd (Match ((IIface (Iface ''eth+'')::32 common_primitive))) (MatchNot (Match (IIface (Iface ''eth4''))))) (Match (IIface (Iface ''eth1''))))
(Match (Prot (Proto TCP))))"
value[code] "compress_normalize_input_interfaces (MatchAny:: 32 common_primitive match_expr)"
definition compress_normalize_output_interfaces :: "'i::len common_primitive match_expr ⇒ 'i common_primitive match_expr option" where
"compress_normalize_output_interfaces m ≡ compress_normalize_primitive (is_Oiface, oiface_sel) OIface compress_interfaces m"
lemma compress_normalize_output_interfaces_Some:
assumes generic: "primitive_matcher_generic β"
and "normalized_nnf_match m" and "compress_normalize_output_interfaces m = Some m'"
shows "matches (β, α) m' a p ⟷ matches (β, α) m a p"
apply (rule compress_normalize_primitive_Some[OF assms(2) wf_disc_sel_common_primitive(6)] (*‹⟦compress_normalize_primitive (is_Oiface, oiface_sel) OIface ?f m = Some ?m'; ⋀as as_pos as_neg. ?f as = Some (as_pos, as_neg) ⟹ matches ?γ (alist_and (NegPos_map OIface (map Pos as_pos @ map Neg as_neg))) ?a ?p = matches ?γ (alist_and (NegPos_map OIface as)) ?a ?p⟧ ⟹ matches ?γ ?m' ?a ?p = matches ?γ m ?a ?p›*))
(*goal: ‹matches (β, α) m' a p = matches (β, α) m a p›*)
using assms(3) (*‹compress_normalize_output_interfaces m = Some m'›*) apply (simp add: compress_normalize_output_interfaces_def (*‹compress_normalize_output_interfaces ?m ≡ compress_normalize_primitive (is_Oiface, oiface_sel) OIface compress_interfaces ?m›*); fail)
(*top goal: ‹compress_normalize_primitive (is_Oiface, oiface_sel) OIface ?f m = Some m'› and 1 goal remains*)
using compress_interfaces_Some[OF generic] (*‹compress_interfaces ?ifces = Some (?i_pos, ?i_neg) ⟹ matches (β, ?α) (alist_and (NegPos_map IIface (map Pos ?i_pos @ map Neg ?i_neg))) ?a ?p = matches (β, ?α) (alist_and (NegPos_map IIface ?ifces)) ?a ?p› ‹compress_interfaces ?ifces = Some (?i_pos, ?i_neg) ⟹ matches (β, ?α) (alist_and (NegPos_map OIface (map Pos ?i_pos @ map Neg ?i_neg))) ?a ?p = matches (β, ?α) (alist_and (NegPos_map OIface ?ifces)) ?a ?p›*) by simp
lemma compress_normalize_output_interfaces_None:
assumes generic: "primitive_matcher_generic β"
and "normalized_nnf_match m" and "compress_normalize_output_interfaces m = None"
shows "¬ matches (β, α) m a p"
apply (rule compress_normalize_primitive_None[OF assms(2) wf_disc_sel_common_primitive(6)] (*‹⟦compress_normalize_primitive (is_Oiface, oiface_sel) OIface ?f m = None; ⋀as. ?f as = None ⟹ ¬ matches ?γ (alist_and (NegPos_map OIface as)) ?a ?p⟧ ⟹ ¬ matches ?γ m ?a ?p›*))
(*goal: ‹¬ matches (β::'a common_primitive ⇒ ('a, 'b) tagged_packet_scheme ⇒ ternaryvalue, α::action ⇒ ('a, 'b) tagged_packet_scheme ⇒ bool) (m::'a common_primitive match_expr) (a::action) (p::('a, 'b) tagged_packet_scheme)›*)
using assms(3) (*‹compress_normalize_output_interfaces m = None›*) apply (simp add: compress_normalize_output_interfaces_def (*‹compress_normalize_output_interfaces ?m ≡ compress_normalize_primitive (is_Oiface, oiface_sel) OIface compress_interfaces ?m›*); fail)
(*top goal: ‹compress_normalize_primitive (is_Oiface, oiface_sel) OIface ?f m = None› and 1 goal remains*)
using compress_interfaces_None[OF generic] (*‹compress_interfaces ?ifces = None ⟹ ¬ matches (β, ?α) (alist_and (NegPos_map IIface ?ifces)) ?a ?p› ‹compress_interfaces ?ifces = None ⟹ ¬ matches (β, ?α) (alist_and (NegPos_map OIface ?ifces)) ?a ?p›*) by simp
lemma compress_normalize_output_interfaces_nnf: "normalized_nnf_match m ⟹ compress_normalize_output_interfaces m = Some m' ⟹
normalized_nnf_match m'"
unfolding compress_normalize_output_interfaces_def
(*goal: ‹⟦normalized_nnf_match m; compress_normalize_primitive (is_Oiface, oiface_sel) OIface compress_interfaces m = Some m'⟧ ⟹ normalized_nnf_match m'›*)
using compress_normalize_primitive_nnf[OF wf_disc_sel_common_primitive ( 6 )] (*‹⟦normalized_nnf_match ?m; compress_normalize_primitive (is_Oiface, oiface_sel) OIface ?f ?m = Some ?m'⟧ ⟹ normalized_nnf_match ?m'›*) by blast
lemma compress_normalize_output_interfaces_not_introduces_Oiface:
"¬ has_disc is_Oiface m ⟹ normalized_nnf_match m ⟹ compress_normalize_output_interfaces m = Some m' ⟹
¬ has_disc is_Oiface m'"
apply (simp add: compress_normalize_output_interfaces_def (*‹compress_normalize_output_interfaces ?m ≡ compress_normalize_primitive (is_Oiface, oiface_sel) OIface compress_interfaces ?m›*))
(*goal: ‹⟦¬ has_disc is_Oiface m; normalized_nnf_match m; compress_normalize_output_interfaces m = Some m'⟧ ⟹ ¬ has_disc is_Oiface m'›*)
apply (drule compress_normalize_primitive_not_introduces_C[where m=m and C'=OIface] (*‹⟦¬ has_disc ?disc m; wf_disc_sel (?disc, ?sel) OIface; normalized_nnf_match m; compress_normalize_primitive (?disc, ?sel) ?C ?f m = Some ?m'; ⋀as_pos as_neg. ?f [] = Some (as_pos, as_neg) ⟹ as_pos = [] ∧ as_neg = []⟧ ⟹ ¬ has_disc ?disc ?m'›*))
(*goal: ‹⟦¬ has_disc is_Oiface m; normalized_nnf_match m; compress_normalize_primitive (is_Oiface, oiface_sel) OIface compress_interfaces m = Some m'⟧ ⟹ ¬ has_disc is_Oiface m'›*)
apply (simp_all add: wf_disc_sel_common_primitive(6))
(*top goal: ‹⟦normalized_nnf_match m; compress_normalize_primitive (is_Oiface, oiface_sel) OIface compress_interfaces m = Some m'⟧ ⟹ wf_disc_sel (is_Oiface, ?sel) OIface› and 4 goals remain*)
by (simp add: compress_interfaces_def (*‹compress_interfaces (?ifces::iface negation_type list) ≡ case compress_pos_interfaces (getPos ?ifces) of None ⇒ None | Some (i::iface) ⇒ if ∃negated_ifce::iface∈set (getNeg ?ifces). iface_subset i negated_ifce then None else if ¬ iface_is_wildcard i then Some ([i], []) else Some (if i = ifaceAny then [] else [i], getNeg ?ifces)›*) iface_is_wildcard_ifaceAny (*‹iface_is_wildcard ifaceAny›*))
lemma compress_normalize_output_interfaces_not_introduces_Oiface_negated:
assumes notdisc: "¬ has_disc_negated is_Oiface False m"
and nm: "normalized_nnf_match m"
and some: "compress_normalize_output_interfaces m = Some m'"
shows "¬ has_disc_negated is_Oiface False m'"
apply (rule compress_normalize_primitive_not_introduces_C_negated[OF notdisc wf_disc_sel_common_primitive(6) nm] (*‹⟦compress_normalize_primitive (is_Oiface, oiface_sel) OIface ?f m = Some ?m'; ⋀as as_pos as_neg. ⟦?f as = Some (as_pos, as_neg); getNeg as = []⟧ ⟹ as_neg = []⟧ ⟹ ¬ has_disc_negated is_Oiface False ?m'›*))
(*goal: ‹¬ has_disc_negated is_Oiface False m'›*)
using some (*‹compress_normalize_output_interfaces m = Some m'›*)
(*goals:
1. ‹compress_normalize_primitive (is_Oiface, oiface_sel) OIface ?f m = Some m'›
2. ‹⋀as as_pos as_neg. ⟦?f as = Some (as_pos, as_neg); getNeg as = []⟧ ⟹ as_neg = []›
discuss goal 1*)
apply (simp add: compress_normalize_output_interfaces_def (*‹compress_normalize_output_interfaces ?m ≡ compress_normalize_primitive (is_Oiface, oiface_sel) OIface compress_interfaces ?m›*))
(*discuss goal 2*)
apply (simp add: compress_interfaces_def (*‹compress_interfaces ?ifces ≡ case compress_pos_interfaces (getPos ?ifces) of None ⇒ None | Some i ⇒ if ∃negated_ifce∈set (getNeg ?ifces). iface_subset i negated_ifce then None else if ¬ iface_is_wildcard i then Some ([i], []) else Some (if i = ifaceAny then [] else [i], getNeg ?ifces)›*) split: option.split_asm (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
(*proven 2 subgoals*) .
(* only for arbitrary discs that do not match Oiface*)
lemma compress_normalize_output_interfaces_hasdisc:
"¬ has_disc disc m ⟹ (∀a. ¬ disc (OIface a)) ⟹ normalized_nnf_match m ⟹ compress_normalize_output_interfaces m = Some m' ⟹
normalized_nnf_match m' ∧ ¬ has_disc disc m'"
unfolding compress_normalize_output_interfaces_def
(*goal: ‹⟦¬ has_disc disc m; ∀a. ¬ disc (OIface a); normalized_nnf_match m; compress_normalize_primitive (is_Oiface, oiface_sel) OIface compress_interfaces m = Some m'⟧ ⟹ normalized_nnf_match m' ∧ ¬ has_disc disc m'›*)
using compress_normalize_primitive_hasdisc[OF _ wf_disc_sel_common_primitive ( 6 )] (*‹⟦¬ has_disc ?disc2.0 ?m; ∀a. ¬ ?disc2.0 (OIface a); normalized_nnf_match ?m; compress_normalize_primitive (is_Oiface, oiface_sel) OIface ?f ?m = Some ?m'⟧ ⟹ normalized_nnf_match ?m' ∧ ¬ has_disc ?disc2.0 ?m'›*) by blast
(* only for arbitrary discs that do not match Oiface*)
lemma compress_normalize_output_interfaces_hasdisc_negated:
"¬ has_disc_negated disc neg m ⟹ (∀a. ¬ disc (OIface a)) ⟹ normalized_nnf_match m ⟹ compress_normalize_output_interfaces m = Some m' ⟹
normalized_nnf_match m' ∧ ¬ has_disc_negated disc neg m'"
unfolding compress_normalize_output_interfaces_def
(*goal: ‹⟦¬ has_disc_negated disc neg m; ∀a. ¬ disc (OIface a); normalized_nnf_match m; compress_normalize_primitive (is_Oiface, oiface_sel) OIface compress_interfaces m = Some m'⟧ ⟹ normalized_nnf_match m' ∧ ¬ has_disc_negated disc neg m'›*)
using compress_normalize_primitive_hasdisc_negated[OF _ wf_disc_sel_common_primitive ( 6 )] (*‹⟦¬ has_disc_negated ?disc2.0 ?neg ?m; ∀a. ¬ ?disc2.0 (OIface a); normalized_nnf_match ?m; compress_normalize_primitive (is_Oiface, oiface_sel) OIface ?f ?m = Some ?m'⟧ ⟹ normalized_nnf_match ?m' ∧ ¬ has_disc_negated ?disc2.0 ?neg ?m'›*) by blast
lemma compress_normalize_output_interfaces_preserves_normalized_n_primitive:
"normalized_n_primitive (disc, sel) P m ⟹ (∀a. ¬ disc (OIface a)) ⟹ normalized_nnf_match m ⟹ compress_normalize_output_interfaces m = Some m' ⟹
normalized_nnf_match m' ∧ normalized_n_primitive (disc, sel) P m'"
sorry
end
end
| {
"path": "afp-2025-02-12/thys/Iptables_Semantics/Primitive_Matchers/Interfaces_Normalize.thy",
"repo": "afp-2025-02-12",
"sha": "655aa6ce68b7cd94be7b5fd915381b9d5de011b36ff6f9954e54625d4c902ca8"
} |
(* Title: Isabelle Collections Library
Author: Peter Lammich <peter dot lammich at uni-muenster.de>
Maintainer: Peter Lammich <peter dot lammich at uni-muenster.de>
*)
section ‹\isaheader{Specification of Maps}›
theory MapSpec
imports ICF_Spec_Base
begin
text_raw‹\label{thy:MapSpec}›
(*@intf Map
@abstype 'k⇀'v
This interface specifies maps from keys to values.
*)
text ‹
This theory specifies map operations by means of mapping to
HOL's map type, i.e. @{typ "'k ⇀ 'v"}.
›
type_synonym ('k,'v,'s) map_α = "'s ⇒ 'k ⇀ 'v"
type_synonym ('k,'v,'s) map_invar = "'s ⇒ bool"
locale map =
fixes α :: "'s ⇒ 'u ⇀ 'v" ― ‹Abstraction to map datatype›
fixes invar :: "'s ⇒ bool" ― ‹Invariant›
locale map_no_invar = map +
assumes invar[simp, intro!]: "⋀s. invar s"
subsection "Basic Map Functions"
subsubsection "Empty Map"
type_synonym ('k,'v,'s) map_empty = "unit ⇒ 's"
locale map_empty = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes empty :: "unit ⇒ 's"
assumes empty_correct:
"α (empty ()) = Map.empty"
"invar (empty ())"
subsubsection "Lookup"
type_synonym ('k,'v,'s) map_lookup = "'k ⇒ 's ⇒ 'v option"
locale map_lookup = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes lookup :: "'u ⇒ 's ⇒ 'v option"
assumes lookup_correct:
"invar m ⟹ lookup k m = α m k"
subsubsection "Update"
type_synonym ('k,'v,'s) map_update = "'k ⇒ 'v ⇒ 's ⇒ 's"
locale map_update = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes update :: "'u ⇒ 'v ⇒ 's ⇒ 's"
assumes update_correct:
"invar m ⟹ α (update k v m) = (α m)(k ↦ v)"
"invar m ⟹ invar (update k v m)"
subsubsection "Disjoint Update"
type_synonym ('k,'v,'s) map_update_dj = "'k ⇒ 'v ⇒ 's ⇒ 's"
locale map_update_dj = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes update_dj :: "'u ⇒ 'v ⇒ 's ⇒ 's"
assumes update_dj_correct:
"⟦invar m; k∉dom (α m)⟧ ⟹ α (update_dj k v m) = (α m)(k ↦ v)"
"⟦invar m; k∉dom (α m)⟧ ⟹ invar (update_dj k v m)"
subsubsection "Delete"
type_synonym ('k,'v,'s) map_delete = "'k ⇒ 's ⇒ 's"
locale map_delete = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes delete :: "'u ⇒ 's ⇒ 's"
assumes delete_correct:
"invar m ⟹ α (delete k m) = (α m) |` (-{k})"
"invar m ⟹ invar (delete k m)"
subsubsection "Add"
type_synonym ('k,'v,'s) map_add = "'s ⇒ 's ⇒ 's"
locale map_add = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes add :: "'s ⇒ 's ⇒ 's"
assumes add_correct:
"invar m1 ⟹ invar m2 ⟹ α (add m1 m2) = α m1 ++ α m2"
"invar m1 ⟹ invar m2 ⟹ invar (add m1 m2)"
type_synonym ('k,'v,'s) map_add_dj = "'s ⇒ 's ⇒ 's"
locale map_add_dj = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes add_dj :: "'s ⇒ 's ⇒ 's"
assumes add_dj_correct:
"⟦invar m1; invar m2; dom (α m1) ∩ dom (α m2) = {}⟧ ⟹ α (add_dj m1 m2) = α m1 ++ α m2"
"⟦invar m1; invar m2; dom (α m1) ∩ dom (α m2) = {} ⟧ ⟹ invar (add_dj m1 m2)"
subsubsection "Emptiness Check"
type_synonym ('k,'v,'s) map_isEmpty = "'s ⇒ bool"
locale map_isEmpty = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes isEmpty :: "'s ⇒ bool"
assumes isEmpty_correct : "invar m ⟹ isEmpty m ⟷ α m = Map.empty"
subsubsection "Singleton Maps"
type_synonym ('k,'v,'s) map_sng = "'k ⇒ 'v ⇒ 's"
locale map_sng = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes sng :: "'u ⇒ 'v ⇒ 's"
assumes sng_correct :
"α (sng k v) = [k ↦ v]"
"invar (sng k v)"
type_synonym ('k,'v,'s) map_isSng = "'s ⇒ bool"
locale map_isSng = map +
constrains α :: "'s ⇒ 'k ⇀ 'v"
fixes isSng :: "'s ⇒ bool"
assumes isSng_correct:
"invar s ⟹ isSng s ⟷ (∃k v. α s = [k ↦ v])"
begin
lemma isSng_correct_exists1 :
"invar s ⟹ (isSng s ⟷ (∃!k. ∃v. (α s k = Some v)))"
apply (auto simp add: isSng_correct (*‹invar ?s ⟹ isSng ?s = (∃k v. α ?s = [k ↦ v])›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))
(*goal: ‹invar s ⟹ isSng s = (∃!k. ∃v. α s k = Some v)›*)
apply (rule_tac x=k in exI (*‹?P ?x ⟹ ∃x. ?P x›*))
(*goal: ‹⋀k v. ⟦invar s; ∀y y'. (∃v. α s y = Some v) ∧ (∃v. α s y' = Some v) ⟶ y = y'; α s k = Some v⟧ ⟹ ∃k v. α s = [k ↦ v]›*)
apply (rule_tac x=v in exI (*‹?P ?x ⟹ ∃x. ?P x›*))
(*goal: ‹⋀k v. ⟦invar s; ∀y y'. (∃v. α s y = Some v) ∧ (∃v. α s y' = Some v) ⟶ y = y'; α s k = Some v⟧ ⟹ ∃v. α s = [k ↦ v]›*)
apply (rule ext (*‹(⋀x::?'a::type. (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x) ⟹ ?f = ?g›*))
(*goal: ‹⋀k v. ⟦invar s; ∀y y'. (∃v. α s y = Some v) ∧ (∃v. α s y' = Some v) ⟶ y = y'; α s k = Some v⟧ ⟹ α s = [k ↦ v]›*)
apply (case_tac "α s x")
(*goals:
1. ‹⋀k v x. ⟦invar s; ∀y y'. (∃v. α s y = Some v) ∧ (∃v. α s y' = Some v) ⟶ y = y'; α s k = Some v; α s x = None⟧ ⟹ α s x = [k ↦ v] x›
2. ‹⋀k v x a. ⟦invar s; ∀y y'. (∃v. α s y = Some v) ∧ (∃v. α s y' = Some v) ⟶ y = y'; α s k = Some v; α s x = Some a⟧ ⟹ α s x = [k ↦ v] x›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*goal: ‹⋀k v x a. ⟦invar s; ∀y y'. (∃v. α s y = Some v) ∧ (∃v. α s y' = Some v) ⟶ y = y'; α s k = Some v; α s x = Some a⟧ ⟹ α s x = [k ↦ v] x›*)
apply force
(*proven 2 subgoals*) .
lemma isSng_correct_card :
"invar s ⟹ (isSng s ⟷ (card (dom (α s)) = 1))"
by (auto simp add: isSng_correct (*‹(invar::'s::type ⇒ bool) (?s::'s::type) ⟹ (isSng::'s::type ⇒ bool) ?s = (∃(k::'k::type) v::'v::type. (α::'s::type ⇒ 'k::type ⇒ 'v::type option) ?s = [k ↦ v])›*) card_Suc_eq (*‹(card (?A::?'a::type set) = Suc (?k::nat)) = (∃(b::?'a::type) B::?'a::type set. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = (0::nat) ⟶ B = {}))›*) dom_eq_singleton_conv (*‹(dom (?f::?'a::type ⇒ ?'b::type option) = {?x::?'a::type}) = (∃v::?'b::type. ?f = [?x ↦ v])›*))
end
subsubsection "Finite Maps"
locale finite_map = map +
assumes finite[simp, intro!]: "invar m ⟹ finite (dom (α m))"
subsubsection "Size"
type_synonym ('k,'v,'s) map_size = "'s ⇒ nat"
locale map_size = finite_map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes size :: "'s ⇒ nat"
assumes size_correct: "invar s ⟹ size s = card (dom (α s))"
type_synonym ('k,'v,'s) map_size_abort = "nat ⇒ 's ⇒ nat"
locale map_size_abort = finite_map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes size_abort :: "nat ⇒ 's ⇒ nat"
assumes size_abort_correct: "invar s ⟹ size_abort m s = min m (card (dom (α s)))"
subsubsection "Iterators"
text ‹
An iteration combinator over a map applies a function to a state for each
map entry, in arbitrary order.
Proving of properties is done by invariant reasoning.
An iterator can also contain a continuation condition. Iteration is
interrupted if the condition becomes false.
›
(* Deprecated *)
(*locale map_iteratei = finite_map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes iteratei :: "'s ⇒ ('u × 'v,'σ) set_iterator"
assumes iteratei_rule: "invar m ⟹ map_iterator (iteratei m) (α m)"
begin
lemma iteratei_rule_P:
assumes "invar m"
and I0: "I (dom (α m)) σ0"
and IP: "!!k v it σ. ⟦ c σ; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ ⟧
⟹ I (it - {k}) (f (k, v) σ)"
and IF: "!!σ. I {} σ ⟹ P σ"
and II: "!!σ it. ⟦ it ⊆ dom (α m); it ≠ {}; ¬ c σ; I it σ ⟧ ⟹ P σ"
shows "P (iteratei m c f σ0)"
using map_iterator_rule_P [OF iteratei_rule, of m I σ0 c f P]
by (simp_all add: assms)
lemma iteratei_rule_insert_P:
assumes
"invar m"
"I {} σ0"
"!!k v it σ. ⟦ c σ; k ∈ (dom (α m) - it); α m k = Some v; it ⊆ dom (α m); I it σ ⟧
⟹ I (insert k it) (f (k, v) σ)"
"!!σ. I (dom (α m)) σ ⟹ P σ"
"!!σ it. ⟦ it ⊆ dom (α m); it ≠ dom (α m);
¬ (c σ);
I it σ ⟧ ⟹ P σ"
shows "P (iteratei m c f σ0)"
using map_iterator_rule_insert_P [OF iteratei_rule, of m I σ0 c f P]
by (simp_all add: assms)
lemma iterate_rule_P:
"⟦
invar m;
I (dom (α m)) σ0;
!!k v it σ. ⟦ k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ ⟧
⟹ I (it - {k}) (f (k, v) σ);
!!σ. I {} σ ⟹ P σ
⟧ ⟹ P (iteratei m (λ_. True) f σ0)"
using iteratei_rule_P [of m I σ0 "λ_. True" f P]
by fast
lemma iterate_rule_insert_P:
"⟦
invar m;
I {} σ0;
!!k v it σ. ⟦ k ∈ (dom (α m) - it); α m k = Some v; it ⊆ dom (α m); I it σ ⟧
⟹ I (insert k it) (f (k, v) σ);
!!σ. I (dom (α m)) σ ⟹ P σ
⟧ ⟹ P (iteratei m (λ_. True) f σ0)"
using iteratei_rule_insert_P [of m I σ0 "λ_. True" f P]
by fast
end
lemma map_iteratei_I :
assumes "⋀m. invar m ⟹ map_iterator (iti m) (α m)"
shows "map_iteratei α invar iti"
proof
fix m
assume invar_m: "invar m"
from assms(1)[OF invar_m] show it_OK: "map_iterator (iti m) (α m)" .
from set_iterator_genord.finite_S0 [OF it_OK[unfolded set_iterator_def]]
show "finite (dom (α m))" by (simp add: finite_map_to_set)
qed
*)
type_synonym ('k,'v,'s) map_list_it
= "'s ⇒ ('k×'v,('k×'v) list) set_iterator"
locale poly_map_iteratei_defs =
fixes list_it :: "'s ⇒ ('u×'v,('u×'v) list) set_iterator"
begin
definition iteratei :: "'s ⇒ ('u×'v,'σ) set_iterator"
where "iteratei S ≡ it_to_it (list_it S)"
abbreviation "iterate m ≡ iteratei m (λ_. True)"
end
locale poly_map_iteratei =
finite_map + poly_map_iteratei_defs list_it
for list_it :: "'s ⇒ ('u×'v,('u×'v) list) set_iterator" +
constrains α :: "'s ⇒ 'u ⇀ 'v"
assumes list_it_correct: "invar m ⟹ map_iterator (list_it m) (α m)"
begin
lemma iteratei_correct: "invar S ⟹ map_iterator (iteratei S) (α S)"
unfolding iteratei_def
(*goal: ‹invar S ⟹ map_iterator (it_to_it (list_it S)) (α S)›*)
apply (rule it_to_it_correct (*‹set_iterator ?it ?S ⟹ set_iterator (it_to_it ?it) ?S›*))
(*goal: ‹invar S ⟹ map_iterator (it_to_it (list_it S)) (α S)›*)
by (rule list_it_correct (*‹invar ?m ⟹ map_iterator (list_it ?m) (α ?m)›*))
lemma pi_iteratei[icf_proper_iteratorI]:
"proper_it (iteratei S) (iteratei S)"
unfolding iteratei_def
(*goal: ‹proper_it (it_to_it (list_it S)) (it_to_it (list_it S))›*)
by (intro icf_proper_iteratorI (*‹proper_it' ?it ?it' ⟹ proper_it' (map_iterator_dom ∘ ?it) (map_iterator_dom ∘ ?it')› ‹proper_it (it_to_it ?I) (it_to_it ?I)› ‹proper_it ?it ?it' ⟹ proper_it (map_iterator_dom ?it) (map_iterator_dom ?it')› ‹proper_it ?it ?it' ⟹ proper_it (set_iterator_image ?g ?it) (set_iterator_image ?g ?it')› ‹proper_it ?it ?it' ⟹ proper_it (set_iterator_filter ?P ?it) (set_iterator_filter ?P ?it')› ‹proper_it ?it ?it' ⟹ proper_it (set_iterator_image_filter ?g ?it) (set_iterator_image_filter ?g ?it')› ‹⟦proper_it ?it_a ?it_a'; ⋀x. proper_it (?it_b x) (?it_b' x)⟧ ⟹ proper_it (set_iterator_product ?it_a ?it_b) (set_iterator_product ?it_a' ?it_b')› ‹⟦proper_it ?it_a ?it_a'; proper_it ?it_b ?it_b'⟧ ⟹ proper_it (set_iterator_union ?it_a ?it_b) (set_iterator_union ?it_a' ?it_b')› ‹proper_it (set_iterator_sng ?x) (set_iterator_sng ?x)› ‹proper_it set_iterator_emp set_iterator_emp› ‹proper_it' (foldri ∘ ?tsl) (foldri ∘ ?tsl)› ‹proper_it' (foldli ∘ ?tsl) (foldli ∘ ?tsl)› and more 2 facts*))
lemma iteratei_rule_P:
assumes "invar m"
and I0: "I (map_to_set (α m)) σ0"
and IP: "!!k v it σ. ⟦ c σ; (k,v) ∈ it; it ⊆ map_to_set (α m); I it σ ⟧
⟹ I (it - {(k,v)}) (f (k, v) σ)"
and IF: "!!σ. I {} σ ⟹ P σ"
and II: "!!σ it. ⟦ it ⊆ map_to_set (α m); it ≠ {}; ¬ c σ; I it σ ⟧ ⟹ P σ"
shows "P (iteratei m c f σ0)"
apply (rule set_iterator_rule_P[OF iteratei_correct] (*‹⟦invar ?S1; ?I (map_to_set (α ?S1)) ?σ0.0; ⋀S σ x. ⟦?c σ; x ∈ S; ?I S σ; S ⊆ map_to_set (α ?S1)⟧ ⟹ ?I (S - {x}) (?f x σ); ⋀σ. ?I {} σ ⟹ ?P σ; ⋀σ S. ⟦S ⊆ map_to_set (α ?S1); S ≠ {}; ¬ ?c σ; ?I S σ⟧ ⟹ ?P σ⟧ ⟹ ?P (iteratei ?S1 ?c ?f ?σ0.0)›*))
(*goals:
1. ‹invar m›
2. ‹?I (map_to_set (α m)) σ0›
3. ‹⋀S σ x. ⟦c σ; x ∈ S; ?I S σ; S ⊆ map_to_set (α m)⟧ ⟹ ?I (S - {x}) (f x σ)›
4. ‹⋀σ. ?I {} σ ⟹ P σ›
5. ‹⋀σ S. ⟦S ⊆ map_to_set (α m); S ≠ {}; ¬ c σ; ?I S σ⟧ ⟹ P σ›
discuss goal 1*)
apply fact
(*discuss goal 2*)
apply fact
(*discuss goal 3*)
apply (case_tac x)
(*top goal: ‹⋀S σ x. ⟦c σ; x ∈ S; I S σ; S ⊆ map_to_set (α m)⟧ ⟹ I (S - {x}) (f x σ)› and 2 goals remain*)
apply (simp add: IP (*‹⟦c ?σ2; (?k2, ?v2) ∈ ?it2; ?it2 ⊆ map_to_set (α m); I ?it2 ?σ2⟧ ⟹ I (?it2 - {(?k2, ?v2)}) (f (?k2, ?v2) ?σ2)›*))
(*discuss goal 4*)
apply fact
(*discuss goal 5*)
apply fact
(*proven 5 subgoals*) .
lemma iteratei_rule_insert_P:
assumes "invar m"
and "I {} σ0"
and "!!k v it σ. ⟦ c σ; (k,v) ∈ (map_to_set (α m) - it);
it ⊆ map_to_set (α m); I it σ ⟧
⟹ I (insert (k,v) it) (f (k, v) σ)"
and "!!σ. I (map_to_set (α m)) σ ⟹ P σ"
and "!!σ it. ⟦ it ⊆ map_to_set (α m); it ≠ map_to_set (α m);
¬ (c σ);
I it σ ⟧ ⟹ P σ"
shows "P (iteratei m c f σ0)"
apply (rule set_iterator_rule_insert_P[OF iteratei_correct] (*‹⟦(invar::'s ⇒ bool) (?S1::'s); (?I::('u × 'v) set ⇒ ?'a ⇒ bool) {} (?σ0.0::?'a); ⋀(S::('u × 'v) set) (σ::?'a) x::'u × 'v. ⟦(?c::?'a ⇒ bool) σ; x ∈ map_to_set ((α::'s ⇒ 'u ⇒ 'v option) ?S1) - S; ?I S σ; S ⊆ map_to_set (α ?S1)⟧ ⟹ ?I (insert x S) ((?f::'u × 'v ⇒ ?'a ⇒ ?'a) x σ); ⋀σ::?'a. ?I (map_to_set (α ?S1)) σ ⟹ (?P::?'a ⇒ bool) σ; ⋀(σ::?'a) S::('u × 'v) set. ⟦S ⊆ map_to_set (α ?S1); S ≠ map_to_set (α ?S1); ¬ ?c σ; ?I S σ⟧ ⟹ ?P σ⟧ ⟹ ?P (iteratei ?S1 ?c ?f ?σ0.0)›*))
(*goals:
1. ‹(invar::'s ⇒ bool) (m::'s)›
2. ‹(?I::('u × 'v) set ⇒ 'a ⇒ bool) {} (σ0::'a)›
3. ‹⋀(S::('u × 'v) set) (σ::'a) x::'u × 'v. ⟦(c::'a ⇒ bool) σ; x ∈ map_to_set ((α::'s ⇒ 'u ⇒ 'v option) (m::'s)) - S; (?I::('u × 'v) set ⇒ 'a ⇒ bool) S σ; S ⊆ map_to_set (α m)⟧ ⟹ ?I (insert x S) ((f::'u × 'v ⇒ 'a ⇒ 'a) x σ)›
4. ‹⋀σ::'a. (?I::('u × 'v) set ⇒ 'a ⇒ bool) (map_to_set ((α::'s ⇒ 'u ⇒ 'v option) (m::'s))) σ ⟹ (P::'a ⇒ bool) σ›
5. ‹⋀(σ::'a) S::('u × 'v) set. ⟦S ⊆ map_to_set ((α::'s ⇒ 'u ⇒ 'v option) (m::'s)); S ≠ map_to_set (α m); ¬ (c::'a ⇒ bool) σ; (?I::('u × 'v) set ⇒ 'a ⇒ bool) S σ⟧ ⟹ (P::'a ⇒ bool) σ›
discuss goal 1*)
apply fact
(*discuss goal 2*)
apply fact
(*discuss goal 3*)
apply (case_tac x)
(*top goal: ‹⋀S σ x. ⟦c σ; x ∈ map_to_set (α m) - S; I S σ; S ⊆ map_to_set (α m)⟧ ⟹ I (insert x S) (f x σ)› and 2 goals remain*)
apply (simp add: assms (*‹invar m› ‹I {} σ0› ‹⟦c ?σ2; (?k2, ?v2) ∈ map_to_set (α m) - ?it2; ?it2 ⊆ map_to_set (α m); I ?it2 ?σ2⟧ ⟹ I (insert (?k2, ?v2) ?it2) (f (?k2, ?v2) ?σ2)› ‹I (map_to_set (α m)) ?σ2 ⟹ P ?σ2› ‹⟦?it2 ⊆ map_to_set (α m); ?it2 ≠ map_to_set (α m); ¬ c ?σ2; I ?it2 ?σ2⟧ ⟹ P ?σ2›*))
(*discuss goal 4*)
apply fact
(*discuss goal 5*)
apply fact
(*proven 5 subgoals*) .
lemma iterate_rule_P:
assumes "invar m"
and I0: "I (map_to_set (α m)) σ0"
and IP: "!!k v it σ. ⟦ (k,v) ∈ it; it ⊆ map_to_set (α m); I it σ ⟧
⟹ I (it - {(k,v)}) (f (k, v) σ)"
and IF: "!!σ. I {} σ ⟹ P σ"
shows "P (iterate m f σ0)"
apply (rule iteratei_rule_P (*‹⟦invar ?m; ?I (map_to_set (α ?m)) ?σ0.0; ⋀k v it σ. ⟦?c σ; (k, v) ∈ it; it ⊆ map_to_set (α ?m); ?I it σ⟧ ⟹ ?I (it - {(k, v)}) (?f (k, v) σ); ⋀σ. ?I {} σ ⟹ ?P σ; ⋀σ it. ⟦it ⊆ map_to_set (α ?m); it ≠ {}; ¬ ?c σ; ?I it σ⟧ ⟹ ?P σ⟧ ⟹ ?P (iteratei ?m ?c ?f ?σ0.0)›*))
(*goals:
1. ‹invar m›
2. ‹?I (map_to_set (α m)) σ0›
3. ‹⋀k v it σ. ⟦True; (k, v) ∈ it; it ⊆ map_to_set (α m); ?I it σ⟧ ⟹ ?I (it - {(k, v)}) (f (k, v) σ)›
4. ‹⋀σ. ?I {} σ ⟹ P σ›
5. ‹⋀σ it. ⟦it ⊆ map_to_set (α m); it ≠ {}; ¬ True; ?I it σ⟧ ⟹ P σ›
discuss goal 1*)
apply fact
(*discuss goal 2*)
apply (rule I0 (*‹I (map_to_set (α m)) σ0›*))
(*discuss goal 3*)
apply (rule IP (*‹⟦(?k2, ?v2) ∈ ?it2; ?it2 ⊆ map_to_set (α m); I ?it2 ?σ2⟧ ⟹ I (?it2 - {(?k2, ?v2)}) (f (?k2, ?v2) ?σ2)›*))
(*goals:
1. ‹⋀k v it σ. ⟦True; (k, v) ∈ it; it ⊆ map_to_set (α m); I it σ⟧ ⟹ (k, v) ∈ it›
2. ‹⋀k v it σ. ⟦True; (k, v) ∈ it; it ⊆ map_to_set (α m); I it σ⟧ ⟹ it ⊆ map_to_set (α m)›
3. ‹⋀k v it σ. ⟦True; (k, v) ∈ it; it ⊆ map_to_set (α m); I it σ⟧ ⟹ I it σ›
discuss goal 1*)
apply assumption
(*discuss goal 2*)
apply assumption
(*discuss goal 3*)
apply assumption
(*proven 3 subgoals*)
(*discuss goal 4*)
apply (rule IF (*‹I {} ?σ2 ⟹ P ?σ2›*))
(*top goal: ‹⋀σ::'a. (I::('u × 'v) set ⇒ 'a ⇒ bool) {} σ ⟹ (P::'a ⇒ bool) σ› and 1 goal remains*)
apply assumption
(*discuss goal 5*)
apply simp
(*proven 5 subgoals*) .
lemma iterate_rule_insert_P:
assumes "invar m"
and I0: "I {} σ0"
and "!!k v it σ. ⟦ (k,v) ∈ (map_to_set (α m) - it);
it ⊆ map_to_set (α m); I it σ ⟧
⟹ I (insert (k,v) it) (f (k, v) σ)"
and "!!σ. I (map_to_set (α m)) σ ⟹ P σ"
shows "P (iterate m f σ0)"
apply (rule iteratei_rule_insert_P (*‹⟦invar ?m; ?I {} ?σ0.0; ⋀k v it σ. ⟦?c σ; (k, v) ∈ map_to_set (α ?m) - it; it ⊆ map_to_set (α ?m); ?I it σ⟧ ⟹ ?I (insert (k, v) it) (?f (k, v) σ); ⋀σ. ?I (map_to_set (α ?m)) σ ⟹ ?P σ; ⋀σ it. ⟦it ⊆ map_to_set (α ?m); it ≠ map_to_set (α ?m); ¬ ?c σ; ?I it σ⟧ ⟹ ?P σ⟧ ⟹ ?P (iteratei ?m ?c ?f ?σ0.0)›*))
(*goals:
1. ‹invar m›
2. ‹?I {} σ0›
3. ‹⋀k v it σ. ⟦True; (k, v) ∈ map_to_set (α m) - it; it ⊆ map_to_set (α m); ?I it σ⟧ ⟹ ?I (insert (k, v) it) (f (k, v) σ)›
4. ‹⋀σ. ?I (map_to_set (α m)) σ ⟹ P σ›
5. ‹⋀σ it. ⟦it ⊆ map_to_set (α m); it ≠ map_to_set (α m); ¬ True; ?I it σ⟧ ⟹ P σ›
discuss goal 1*)
apply fact
(*discuss goal 2*)
apply (rule I0 (*‹I {} σ0›*))
(*discuss goal 3*)
apply (rule assms (*‹invar m› ‹I {} σ0› ‹⟦(?k2, ?v2) ∈ map_to_set (α m) - ?it2; ?it2 ⊆ map_to_set (α m); I ?it2 ?σ2⟧ ⟹ I (insert (?k2, ?v2) ?it2) (f (?k2, ?v2) ?σ2)› ‹I (map_to_set (α m)) ?σ2 ⟹ P ?σ2›*))
(*goals:
1. ‹⋀k v it σ. ⟦True; (k, v) ∈ map_to_set (α m) - it; it ⊆ map_to_set (α m); I it σ⟧ ⟹ (k, v) ∈ map_to_set (α m) - it›
2. ‹⋀k v it σ. ⟦True; (k, v) ∈ map_to_set (α m) - it; it ⊆ map_to_set (α m); I it σ⟧ ⟹ it ⊆ map_to_set (α m)›
3. ‹⋀k v it σ. ⟦True; (k, v) ∈ map_to_set (α m) - it; it ⊆ map_to_set (α m); I it σ⟧ ⟹ I it σ›
discuss goal 1*)
apply assumption
(*discuss goal 2*)
apply assumption
(*discuss goal 3*)
apply assumption
(*proven 3 subgoals*)
(*discuss goal 4*)
apply (rule assms (*‹(invar::'s ⇒ bool) (m::'s)› ‹(I::('u × 'v) set ⇒ 'a ⇒ bool) {} (σ0::'a)› ‹⟦(?k2::'u, ?v2::'v) ∈ map_to_set ((α::'s ⇒ 'u ⇒ 'v option) (m::'s)) - (?it2::('u × 'v) set); ?it2 ⊆ map_to_set (α m); (I::('u × 'v) set ⇒ 'a ⇒ bool) ?it2 (?σ2::'a)⟧ ⟹ I (insert (?k2, ?v2) ?it2) ((f::'u × 'v ⇒ 'a ⇒ 'a) (?k2, ?v2) ?σ2)› ‹(I::('u × 'v) set ⇒ 'a ⇒ bool) (map_to_set ((α::'s ⇒ 'u ⇒ 'v option) (m::'s))) (?σ2::'a) ⟹ (P::'a ⇒ bool) ?σ2›*))
(*top goal: ‹⋀σ::'a. (I::('u × 'v) set ⇒ 'a ⇒ bool) (map_to_set ((α::'s ⇒ 'u ⇒ 'v option) (m::'s))) σ ⟹ (P::'a ⇒ bool) σ› and 1 goal remains*)
apply assumption
(*discuss goal 5*)
apply simp
(*proven 5 subgoals*) .
lemma old_iteratei_rule_P:
assumes "invar m"
and I0: "I (dom (α m)) σ0"
and IP: "!!k v it σ. ⟦ c σ; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ ⟧
⟹ I (it - {k}) (f (k, v) σ)"
and IF: "!!σ. I {} σ ⟹ P σ"
and II: "!!σ it. ⟦ it ⊆ dom (α m); it ≠ {}; ¬ c σ; I it σ ⟧ ⟹ P σ"
shows "P (iteratei m c f σ0)"
using assms (*‹invar m› ‹I (dom (α m)) σ0› ‹⟦(c::'a ⇒ bool) (?σ2::'a); (?k2::'u) ∈ (?it2::'u set); (α::'s ⇒ 'u ⇒ 'v option) (m::'s) ?k2 = Some (?v2::'v); ?it2 ⊆ dom (α m); (I::'u set ⇒ 'a ⇒ bool) ?it2 ?σ2⟧ ⟹ I (?it2 - {?k2}) ((f::'u × 'v ⇒ 'a ⇒ 'a) (?k2, ?v2) ?σ2)› ‹I {} ?σ2 ⟹ P ?σ2› ‹⟦?it2 ⊆ dom (α m); ?it2 ≠ {}; ¬ c ?σ2; I ?it2 ?σ2⟧ ⟹ P ?σ2›*) apply (rule map_iterator_rule_P[OF iteratei_correct] (*‹⟦invar ?S1; ?I (dom (α ?S1)) ?σ0.0; ⋀k v it σ. ⟦?c σ; k ∈ it; α ?S1 k = Some v; it ⊆ dom (α ?S1); ?I it σ⟧ ⟹ ?I (it - {k}) (?f (k, v) σ); ⋀σ. ?I {} σ ⟹ ?P σ; ⋀σ it. ⟦it ⊆ dom (α ?S1); it ≠ {}; ¬ ?c σ; ?I it σ⟧ ⟹ ?P σ⟧ ⟹ ?P (iteratei ?S1 ?c ?f ?σ0.0)›*))
(*goal: ‹P (iteratei m c f σ0)›*)
by (msorry)
lemma old_iteratei_rule_insert_P:
assumes "invar m"
and "I {} σ0"
and "!!k v it σ. ⟦ c σ; k ∈ (dom (α m) - it); α m k = Some v;
it ⊆ dom (α m); I it σ ⟧
⟹ I (insert k it) (f (k, v) σ)"
and "!!σ. I (dom (α m)) σ ⟹ P σ"
and "!!σ it. ⟦ it ⊆ dom (α m); it ≠ dom (α m);
¬ (c σ);
I it σ ⟧ ⟹ P σ"
shows "P (iteratei m c f σ0)"
using assms (*‹invar m› ‹I {} σ0› ‹⟦c ?σ2; ?k2 ∈ dom (α m) - ?it2; α m ?k2 = Some ?v2; ?it2 ⊆ dom (α m); I ?it2 ?σ2⟧ ⟹ I (insert ?k2 ?it2) (f (?k2, ?v2) ?σ2)› ‹I (dom (α m)) ?σ2 ⟹ P ?σ2› ‹⟦?it2 ⊆ dom (α m); ?it2 ≠ dom (α m); ¬ c ?σ2; I ?it2 ?σ2⟧ ⟹ P ?σ2›*) apply (rule map_iterator_rule_insert_P[OF iteratei_correct] (*‹⟦invar ?S1; ?I {} ?σ0.0; ⋀k v it σ. ⟦?c σ; k ∈ dom (α ?S1) - it; α ?S1 k = Some v; it ⊆ dom (α ?S1); ?I it σ⟧ ⟹ ?I (insert k it) (?f (k, v) σ); ⋀σ. ?I (dom (α ?S1)) σ ⟹ ?P σ; ⋀σ it. ⟦it ⊆ dom (α ?S1); it ≠ dom (α ?S1); ¬ ?c σ; ?I it σ⟧ ⟹ ?P σ⟧ ⟹ ?P (iteratei ?S1 ?c ?f ?σ0.0)›*))
(*goal: ‹P (iteratei m c f σ0)›*)
by (msorry)
lemma old_iterate_rule_P:
"⟦
invar m;
I (dom (α m)) σ0;
!!k v it σ. ⟦ k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ ⟧
⟹ I (it - {k}) (f (k, v) σ);
!!σ. I {} σ ⟹ P σ
⟧ ⟹ P (iterate m f σ0)"
using old_iteratei_rule_P[of m I σ0 "λ_. True" f P] (*‹⟦invar m; I (dom (α m)) σ0; ⋀k v it σ. ⟦True; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ⟧ ⟹ I (it - {k}) (f (k, v) σ); ⋀σ. I {} σ ⟹ P σ; ⋀σ it. ⟦it ⊆ dom (α m); it ≠ {}; ¬ True; I it σ⟧ ⟹ P σ⟧ ⟹ P (iterate m f σ0)›*) by blast
lemma old_iterate_rule_insert_P:
"⟦
invar m;
I {} σ0;
!!k v it σ. ⟦ k ∈ (dom (α m) - it); α m k = Some v;
it ⊆ dom (α m); I it σ ⟧
⟹ I (insert k it) (f (k, v) σ);
!!σ. I (dom (α m)) σ ⟹ P σ
⟧ ⟹ P (iteratei m (λ_. True) f σ0)"
using old_iteratei_rule_insert_P[of m I σ0 "λ_. True" f P] (*‹⟦(invar::'s ⇒ bool) (m::'s); (I::'u set ⇒ 'a ⇒ bool) {} (σ0::'a); ⋀(k::'u) (v::'v) (it::'u set) σ::'a. ⟦True; k ∈ dom ((α::'s ⇒ 'u ⇒ 'v option) m) - it; α m k = Some v; it ⊆ dom (α m); I it σ⟧ ⟹ I (insert k it) ((f::'u × 'v ⇒ 'a ⇒ 'a) (k, v) σ); ⋀σ::'a. I (dom (α m)) σ ⟹ (P::'a ⇒ bool) σ; ⋀(σ::'a) it::'u set. ⟦it ⊆ dom (α m); it ≠ dom (α m); ¬ True; I it σ⟧ ⟹ P σ⟧ ⟹ P (iterate m f σ0)›*) by blast
end
subsubsection "Bounded Quantification"
type_synonym ('k,'v,'s) map_ball = "'s ⇒ ('k × 'v ⇒ bool) ⇒ bool"
locale map_ball = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes ball :: "'s ⇒ ('u × 'v ⇒ bool) ⇒ bool"
assumes ball_correct: "invar m ⟹ ball m P ⟷ (∀u v. α m u = Some v ⟶ P (u, v))"
type_synonym ('k,'v,'s) map_bex = "'s ⇒ ('k × 'v ⇒ bool) ⇒ bool"
locale map_bex = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes bex :: "'s ⇒ ('u × 'v ⇒ bool) ⇒ bool"
assumes bex_correct:
"invar m ⟹ bex m P ⟷ (∃u v. α m u = Some v ∧ P (u, v))"
subsubsection "Selection of Entry"
type_synonym ('k,'v,'s,'r) map_sel = "'s ⇒ ('k × 'v ⇒ 'r option) ⇒ 'r option"
locale map_sel = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes sel :: "'s ⇒ ('u × 'v ⇒ 'r option) ⇒ 'r option"
assumes selE:
"⟦ invar m; α m u = Some v; f (u, v) = Some r;
!!u v r. ⟦ sel m f = Some r; α m u = Some v; f (u, v) = Some r ⟧ ⟹ Q
⟧ ⟹ Q"
assumes selI:
"⟦ invar m; ∀u v. α m u = Some v ⟶ f (u, v) = None ⟧ ⟹ sel m f = None"
begin
lemma sel_someE:
"⟦ invar m; sel m f = Some r;
!!u v. ⟦ α m u = Some v; f (u, v) = Some r ⟧ ⟹ P
⟧ ⟹ P"
apply (cases "∃u v r. α m u = Some v ∧ f (u, v) = Some r")
(*goals:
1. ‹⟦invar m; sel m f = Some r; ⋀u v. ⟦α m u = Some v; f (u, v) = Some r⟧ ⟹ P; ∃u v r. α m u = Some v ∧ f (u, v) = Some r⟧ ⟹ P›
2. ‹⟦invar m; sel m f = Some r; ⋀u v. ⟦α m u = Some v; f (u, v) = Some r⟧ ⟹ P; ∄u v r. α m u = Some v ∧ f (u, v) = Some r⟧ ⟹ P›
discuss goal 1*)
apply safe
(*top goal: ‹⟦invar m; sel m f = Some r; ⋀u v. ⟦α m u = Some v; f (u, v) = Some r⟧ ⟹ P; ∃u v r. α m u = Some v ∧ f (u, v) = Some r⟧ ⟹ P› and 1 goal remains*)
apply (erule_tac u=u and v=v and r=ra in selE (*‹⟦invar ?m; α ?m ?u = Some ?v; ?f (?u, ?v) = Some ?r; ⋀u v r. ⟦sel ?m ?f = Some r; α ?m u = Some v; ?f (u, v) = Some r⟧ ⟹ ?Q⟧ ⟹ ?Q›*))
(*goals:
1. ‹⋀u v ra. ⟦sel m f = Some r; ⋀u v. ⟦α m u = Some v; f (u, v) = Some r⟧ ⟹ P; α m u = Some v; f (u, v) = Some ra⟧ ⟹ α m u = Some v›
2. ‹⋀u v ra. ⟦sel m f = Some r; ⋀u v. ⟦α m u = Some v; f (u, v) = Some r⟧ ⟹ P; α m u = Some v; f (u, v) = Some ra⟧ ⟹ ?f5 u v ra (u, v) = Some ra›
3. ‹⋀u v ra ua va raa. ⟦sel m f = Some r; ⋀u v. ⟦α m u = Some v; f (u, v) = Some r⟧ ⟹ P; α m u = Some v; f (u, v) = Some ra; sel m (?f5 u v ra) = Some raa; α m ua = Some va; ?f5 u v ra (ua, va) = Some raa⟧ ⟹ P›
discuss goal 1*)
apply assumption
(*discuss goal 2*)
apply assumption
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*)
(*discuss goal 2*)
apply auto
(*goal: ‹⟦invar m; sel m f = Some r; ⋀u v. ⟦α m u = Some v; f (u, v) = Some r⟧ ⟹ P; ∄u v r. α m u = Some v ∧ f (u, v) = Some r⟧ ⟹ P›*)
apply (drule (1) selI (*‹⟦invar ?m; ∀u v. α ?m u = Some v ⟶ ?f (u, v) = None⟧ ⟹ sel ?m ?f = None›*))
(*goal: ‹⟦(invar::'s::type ⇒ bool) (m::'s::type); (sel::'s::type ⇒ ('u::type × 'v::type ⇒ 'r::type option) ⇒ 'r::type option) m (f::'u::type × 'v::type ⇒ 'r::type option) = Some (r::'r::type); ∀(u::'u::type) v::'v::type. (α::'s::type ⇒ 'u::type ⇒ 'v::type option) m u = Some v ⟶ f (u, v) = None⟧ ⟹ P::bool›*)
apply simp
(*proven 2 subgoals*) .
lemma sel_noneD: "⟦invar m; sel m f = None; α m u = Some v⟧ ⟹ f (u, v) = None"
apply (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*))
(*goal: ‹⟦invar m; sel m f = None; α m u = Some v⟧ ⟹ f (u, v) = None›*)
apply simp
(*goal: ‹⟦invar m; sel m f = None; α m u = Some v; f (u, v) ≠ None⟧ ⟹ False›*)
apply (erule exE (*‹⟦∃x. ?P x; ⋀x. ?P x ⟹ ?Q⟧ ⟹ ?Q›*))
(*goal: ‹⟦(invar::'s ⇒ bool) (m::'s); (sel::'s ⇒ ('u × 'v ⇒ 'r option) ⇒ 'r option) m (f::'u × 'v ⇒ 'r option) = None; (α::'s ⇒ 'u ⇒ 'v option) m (u::'u) = Some (v::'v); ∃y::'r. f (u, v) = Some y⟧ ⟹ False›*)
apply (erule_tac f=f and u=u and v=v and r=y in selE (*‹⟦invar ?m; α ?m ?u = Some ?v; ?f (?u, ?v) = Some ?r; ⋀u v r. ⟦sel ?m ?f = Some r; α ?m u = Some v; ?f (u, v) = Some r⟧ ⟹ ?Q⟧ ⟹ ?Q›*))
(*goals:
1. ‹⋀y::'r::type. ⟦(sel::'s::type ⇒ ('u::type × 'v::type ⇒ 'r::type option) ⇒ 'r::type option) (m::'s::type) (f::'u::type × 'v::type ⇒ 'r::type option) = None; (α::'s::type ⇒ 'u::type ⇒ 'v::type option) m (u::'u::type) = Some (v::'v::type); f (u, v) = Some y⟧ ⟹ α m u = Some v›
2. ‹⋀y::'r::type. ⟦(sel::'s::type ⇒ ('u::type × 'v::type ⇒ 'r::type option) ⇒ 'r::type option) (m::'s::type) (f::'u::type × 'v::type ⇒ 'r::type option) = None; (α::'s::type ⇒ 'u::type ⇒ 'v::type option) m (u::'u::type) = Some (v::'v::type); f (u, v) = Some y⟧ ⟹ f (u, v) = Some y›
3. ‹⋀(y::'r::type) (ua::'u::type) (va::'v::type) r::'r::type. ⟦(sel::'s::type ⇒ ('u::type × 'v::type ⇒ 'r::type option) ⇒ 'r::type option) (m::'s::type) (f::'u::type × 'v::type ⇒ 'r::type option) = None; (α::'s::type ⇒ 'u::type ⇒ 'v::type option) m (u::'u::type) = Some (v::'v::type); f (u, v) = Some y; sel m f = Some r; α m ua = Some va; f (ua, va) = Some r⟧ ⟹ False›
discuss goal 1*)
apply ((auto)[1])
(*discuss goal 2*)
apply ((auto)[1])
(*discuss goal 3*)
apply ((auto)[1])
(*proven 3 subgoals*) .
end
― ‹Equivalent description of sel-map properties›
lemma map_sel_altI:
assumes S1:
"!!s f r P. ⟦ invar s; sel s f = Some r;
!!u v. ⟦α s u = Some v; f (u, v) = Some r⟧ ⟹ P
⟧ ⟹ P"
assumes S2:
"!!s f u v. ⟦invar s; sel s f = None; α s u = Some v⟧ ⟹ f (u, v) = None"
shows "map_sel α invar sel"
proof (-)
(*goal: ‹map_sel α invar sel›*)
show "?thesis"
(*goal: ‹map_sel α invar sel›*)
apply unfold_locales
(*goals:
1. ‹⋀m u v f r Q. ⟦invar m; α m u = Some v; f (u, v) = Some r; ⋀u v r. ⟦sel m f = Some r; α m u = Some v; f (u, v) = Some r⟧ ⟹ Q⟧ ⟹ Q›
2. ‹⋀m f. ⟦invar m; ∀u v. α m u = Some v ⟶ f (u, v) = None⟧ ⟹ sel m f = None›
discuss goal 1*)
apply (case_tac "sel m f")
(*goals:
1. ‹⋀m u v f r Q. ⟦invar m; α m u = Some v; f (u, v) = Some r; ⋀u v r. ⟦sel m f = Some r; α m u = Some v; f (u, v) = Some r⟧ ⟹ Q; sel m f = None⟧ ⟹ Q›
2. ‹⋀m u v f r Q a. ⟦invar m; α m u = Some v; f (u, v) = Some r; ⋀u v r. ⟦sel m f = Some r; α m u = Some v; f (u, v) = Some r⟧ ⟹ Q; sel m f = Some a⟧ ⟹ Q›
discuss goal 1*)
apply (force dest: S2 (*‹⟦invar ?s; sel ?s ?f = None; α ?s ?u = Some ?v⟧ ⟹ ?f (?u, ?v) = None›*))
(*discuss goal 2*)
apply (force elim: S1 (*‹⟦(invar::'a ⇒ bool) (?s::'a); (sel::'a ⇒ ('b × 'c ⇒ 'd option) ⇒ 'd option) ?s (?f::'b × 'c ⇒ 'd option) = Some (?r::'d); ⋀(u::'b) v::'c. ⟦(α::'a ⇒ 'b ⇒ 'c option) ?s u = Some v; ?f (u, v) = Some ?r⟧ ⟹ ?P::bool⟧ ⟹ ?P›*))
(*proven 2 subgoals*)
(*discuss goal 2*)
apply (case_tac "sel m f")
(*goals:
1. ‹⋀m f. ⟦invar m; ∀u v. α m u = Some v ⟶ f (u, v) = None; sel m f = None⟧ ⟹ sel m f = None›
2. ‹⋀m f a. ⟦invar m; ∀u v. α m u = Some v ⟶ f (u, v) = None; sel m f = Some a⟧ ⟹ sel m f = None›
discuss goal 1*)
apply assumption
(*discuss goal 2*)
apply (force elim: S1 (*‹⟦invar ?s; sel ?s ?f = Some ?r; ⋀u v. ⟦α ?s u = Some v; ?f (u, v) = Some ?r⟧ ⟹ ?P⟧ ⟹ ?P›*))
(*proven 2 subgoals*)
(*proven 2 subgoals*) .
qed
subsubsection "Selection of Entry (without mapping)"
type_synonym ('k,'v,'s) map_sel' = "'s ⇒ ('k × 'v ⇒ bool) ⇒ ('k×'v) option"
locale map_sel' = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes sel' :: "'s ⇒ ('u × 'v ⇒ bool) ⇒ ('u×'v) option"
assumes sel'E:
"⟦ invar m; α m u = Some v; P (u, v);
!!u v. ⟦ sel' m P = Some (u,v); α m u = Some v; P (u, v)⟧ ⟹ Q
⟧ ⟹ Q"
assumes sel'I:
"⟦ invar m; ∀u v. α m u = Some v ⟶ ¬ P (u, v) ⟧ ⟹ sel' m P = None"
begin
lemma sel'_someE:
"⟦ invar m; sel' m P = Some (u,v);
!!u v. ⟦ α m u = Some v; P (u, v) ⟧ ⟹ thesis
⟧ ⟹ thesis"
apply (cases "∃u v. α m u = Some v ∧ P (u, v)")
(*goals:
1. ‹⟦invar m; sel' m P = Some (u, v); ⋀u v. ⟦α m u = Some v; P (u, v)⟧ ⟹ thesis; ∃u v. α m u = Some v ∧ P (u, v)⟧ ⟹ thesis›
2. ‹⟦invar m; sel' m P = Some (u, v); ⋀u v. ⟦α m u = Some v; P (u, v)⟧ ⟹ thesis; ∄u v. α m u = Some v ∧ P (u, v)⟧ ⟹ thesis›
discuss goal 1*)
apply safe
(*top goal: ‹⟦invar m; sel' m P = Some (u, v); ⋀u v. ⟦α m u = Some v; P (u, v)⟧ ⟹ thesis; ∃u v. α m u = Some v ∧ P (u, v)⟧ ⟹ thesis› and 1 goal remains*)
apply (erule_tac u=ua and v=va in sel'E (*‹⟦invar ?m; α ?m ?u = Some ?v; ?P (?u, ?v); ⋀u v. ⟦sel' ?m ?P = Some (u, v); α ?m u = Some v; ?P (u, v)⟧ ⟹ ?Q⟧ ⟹ ?Q›*))
(*goals:
1. ‹⋀ua va. ⟦sel' m P = Some (u, v); ⋀u v. ⟦α m u = Some v; P (u, v)⟧ ⟹ thesis; α m ua = Some va; P (ua, va)⟧ ⟹ α m ua = Some va›
2. ‹⋀ua va. ⟦sel' m P = Some (u, v); ⋀u v. ⟦α m u = Some v; P (u, v)⟧ ⟹ thesis; α m ua = Some va; P (ua, va)⟧ ⟹ ?P4 ua va (ua, va)›
3. ‹⋀ua va uaa vaa. ⟦sel' m P = Some (u, v); ⋀u v. ⟦α m u = Some v; P (u, v)⟧ ⟹ thesis; α m ua = Some va; P (ua, va); sel' m (?P4 ua va) = Some (uaa, vaa); α m uaa = Some vaa; ?P4 ua va (uaa, vaa)⟧ ⟹ thesis›
discuss goal 1*)
apply assumption
(*discuss goal 2*)
apply assumption
(*discuss goal 3*)
apply simp
(*proven 3 subgoals*)
(*discuss goal 2*)
apply auto
(*goal: ‹⟦invar m; sel' m P = Some (u, v); ⋀u v. ⟦α m u = Some v; P (u, v)⟧ ⟹ thesis; ∄u v. α m u = Some v ∧ P (u, v)⟧ ⟹ thesis›*)
apply (drule (1) sel'I (*‹⟦invar ?m; ∀u v. α ?m u = Some v ⟶ ¬ ?P (u, v)⟧ ⟹ sel' ?m ?P = None›*))
(*goal: ‹⟦invar m; sel' m P = Some (u, v); ∀u v. α m u = Some v ⟶ ¬ P (u, v)⟧ ⟹ thesis›*)
apply simp
(*proven 2 subgoals*) .
lemma sel'_noneD: "⟦invar m; sel' m P = None; α m u = Some v⟧ ⟹ ¬ P (u, v)"
apply (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*))
(*goal: ‹⟦(invar::'s ⇒ bool) (m::'s); (sel'::'s ⇒ ('u × 'v ⇒ bool) ⇒ ('u × 'v) option) m (P::'u × 'v ⇒ bool) = None; (α::'s ⇒ 'u ⇒ 'v option) m (u::'u) = Some (v::'v)⟧ ⟹ ¬ P (u, v)›*)
apply simp
(*goal: ‹⟦invar m; sel' m P = None; α m u = Some v; ¬ ¬ P (u, v)⟧ ⟹ False›*)
apply (erule (2) sel'E[where P=P] (*‹⟦(invar::'s::type ⇒ bool) (?m::'s::type); (α::'s::type ⇒ 'u::type ⇒ 'v::type option) ?m (?u::'u::type) = Some (?v::'v::type); (P::'u::type × 'v::type ⇒ bool) (?u, ?v); ⋀(u::'u::type) v::'v::type. ⟦(sel'::'s::type ⇒ ('u::type × 'v::type ⇒ bool) ⇒ ('u::type × 'v::type) option) ?m P = Some (u, v); α ?m u = Some v; P (u, v)⟧ ⟹ ?Q::bool⟧ ⟹ ?Q›*))
(*goal: ‹⟦invar m; sel' m P = None; α m u = Some v; P (u, v)⟧ ⟹ False›*)
by auto
lemma sel'_SomeD:
"⟦ sel' m P = Some (u, v); invar m ⟧ ⟹ α m u = Some v ∧ P (u, v)"
apply (cases "∃u' v'. α m u' = Some v' ∧ P (u', v')")
(*goals:
1. ‹⟦sel' m P = Some (u, v); invar m; ∃u' v'. α m u' = Some v' ∧ P (u', v')⟧ ⟹ α m u = Some v ∧ P (u, v)›
2. ‹⟦sel' m P = Some (u, v); invar m; ∄u' v'. α m u' = Some v' ∧ P (u', v')⟧ ⟹ α m u = Some v ∧ P (u, v)›
discuss goal 1*)
apply clarsimp
(*top goal: ‹⟦sel' m P = Some (u, v); invar m; ∃u' v'. α m u' = Some v' ∧ P (u', v')⟧ ⟹ α m u = Some v ∧ P (u, v)› and 1 goal remains*)
apply (erule (2) sel'E[where P=P] (*‹⟦invar ?m; α ?m ?u = Some ?v; P (?u, ?v); ⋀u v. ⟦sel' ?m P = Some (u, v); α ?m u = Some v; P (u, v)⟧ ⟹ ?Q⟧ ⟹ ?Q›*))
(*top goal: ‹⋀(u'::'u) v'::'v. ⟦(sel'::'s ⇒ ('u × 'v ⇒ bool) ⇒ ('u × 'v) option) (m::'s) (P::'u × 'v ⇒ bool) = Some (u::'u, v::'v); (invar::'s ⇒ bool) m; (α::'s ⇒ 'u ⇒ 'v option) m u' = Some v'; P (u', v')⟧ ⟹ α m u = Some v ∧ P (u, v)› and 1 goal remains*)
apply simp
(*discuss goal 2*)
apply clarsimp
(*goal: ‹⟦(sel'::'s::type ⇒ ('u::type × 'v::type ⇒ bool) ⇒ ('u::type × 'v::type) option) (m::'s::type) (P::'u::type × 'v::type ⇒ bool) = Some (u::'u::type, v::'v::type); (invar::'s::type ⇒ bool) m; ∄(u'::'u::type) v'::'v::type. (α::'s::type ⇒ 'u::type ⇒ 'v::type option) m u' = Some v' ∧ P (u', v')⟧ ⟹ α m u = Some v ∧ P (u, v)›*)
apply (drule (1) sel'I (*‹⟦(invar::'s::type ⇒ bool) (?m::'s::type); ∀(u::'u::type) v::'v::type. (α::'s::type ⇒ 'u::type ⇒ 'v::type option) ?m u = Some v ⟶ ¬ (?P::'u::type × 'v::type ⇒ bool) (u, v)⟧ ⟹ (sel'::'s::type ⇒ ('u::type × 'v::type ⇒ bool) ⇒ ('u::type × 'v::type) option) ?m ?P = None›*))
(*goal: ‹⟦sel' m P = Some (u, v); invar m; ∀u' v'. α m u' = Some v' ⟶ ¬ P (u', v')⟧ ⟹ α m u = Some v ∧ P (u, v)›*)
apply simp
(*proven 2 subgoals*) .
end
subsubsection "Map to List Conversion"
type_synonym ('k,'v,'s) map_to_list = "'s ⇒ ('k×'v) list"
locale map_to_list = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes to_list :: "'s ⇒ ('u×'v) list"
assumes to_list_correct:
"invar m ⟹ map_of (to_list m) = α m"
"invar m ⟹ distinct (map fst (to_list m))"
subsubsection "List to Map Conversion"
type_synonym ('k,'v,'s) list_to_map = "('k×'v) list ⇒ 's"
locale list_to_map = map +
constrains α :: "'s ⇒ 'u ⇀ 'v"
fixes to_map :: "('u×'v) list ⇒ 's"
assumes to_map_correct:
"α (to_map l) = map_of l"
"invar (to_map l)"
subsubsection "Image of a Map"
text ‹This locale allows to apply a function to both the keys and
the values of a map while at the same time filtering entries.›
definition transforms_to_unique_keys ::
"('u1 ⇀ 'v1) ⇒ ('u1 × 'v1 ⇀ ('u2 × 'v2)) ⇒ bool"
where
"transforms_to_unique_keys m f ≡ (∀k1 k2 v1 v2 k' v1' v2'. (
m k1 = Some v1 ∧
m k2 = Some v2 ∧
f (k1, v1) = Some (k', v1') ∧
f (k2, v2) = Some (k', v2')) -->
(k1 = k2))"
type_synonym ('k1,'v1,'m1,'k2,'v2,'m2) map_image_filter
= "('k1 × 'v1 ⇒ ('k2 × 'v2) option) ⇒ 'm1 ⇒ 'm2"
locale map_image_filter = m1: map α1 invar1 + m2: map α2 invar2
for α1 :: "'m1 ⇒ 'u1 ⇀ 'v1" and invar1
and α2 :: "'m2 ⇒ 'u2 ⇀ 'v2" and invar2
+
fixes map_image_filter :: "('u1 × 'v1 ⇒ ('u2 × 'v2) option) ⇒ 'm1 ⇒ 'm2"
assumes map_image_filter_correct_aux1:
"⋀k' v'.
⟦invar1 m; transforms_to_unique_keys (α1 m) f⟧ ⟹
(invar2 (map_image_filter f m) ∧
((α2 (map_image_filter f m) k' = Some v') ⟷
(∃k v. (α1 m k = Some v) ∧ f (k, v) = Some (k', v'))))"
begin
(*Let's use a definition for the precondition *)
lemma map_image_filter_correct_aux2 :
assumes "invar1 m"
and "transforms_to_unique_keys (α1 m) f"
shows "(α2 (map_image_filter f m) k' = None) ⟷
(∀k v v'. α1 m k = Some v ⟶ f (k, v) ≠ Some (k', v'))"
proof (-)
(*goal: ‹(α2 (map_image_filter f m) k' = None) = (∀k v v'. α1 m k = Some v ⟶ f (k, v) ≠ Some (k', v'))›*)
note map_image_filter_correct_aux1[OF assms] (*‹invar2 (map_image_filter f m) ∧ (α2 (map_image_filter f m) ?k' = Some ?v') = (∃k v. α1 m k = Some v ∧ f (k, v) = Some (?k', ?v'))›*)
have Some_eq: "⋀v'. (α2 (map_image_filter f m) k' = Some v') =
(∃k v. α1 m k = Some v ∧ f (k, v) = Some (k', v'))"
by (simp add: map_image_filter_correct_aux1 [OF assms] (*‹invar2 (map_image_filter f m) ∧ (α2 (map_image_filter f m) ?k' = Some ?v') = (∃k v. α1 m k = Some v ∧ f (k, v) = Some (?k', ?v'))›*))
have intro_some: "(α2 (map_image_filter f m) k' = None) ⟷
(∀v'. α2 (map_image_filter f m) k' ≠ Some v')"
by auto
from intro_some (*‹(α2 (map_image_filter f m) k' = None) = (∀v'. α2 (map_image_filter f m) k' ≠ Some v')›*) Some_eq (*‹(α2 (map_image_filter f m) k' = Some ?v') = (∃k v. α1 m k = Some v ∧ f (k, v) = Some (k', ?v'))›*) show "?thesis"
(*goal: ‹(α2 (map_image_filter f m) k' = None) = (∀k v v'. α1 m k = Some v ⟶ f (k, v) ≠ Some (k', v'))›*)
by auto
qed
lemmas map_image_filter_correct =
conjunct1 [OF map_image_filter_correct_aux1]
conjunct2 [OF map_image_filter_correct_aux1]
map_image_filter_correct_aux2
end
text ‹Most of the time the mapping function is only applied to values. Then,
the precondition disapears.›
type_synonym ('k,'v1,'m1,'k2,'v2,'m2) map_value_image_filter
= "('k ⇒ 'v1 ⇒ 'v2 option) ⇒ 'm1 ⇒ 'm2"
locale map_value_image_filter = m1: map α1 invar1 + m2: map α2 invar2
for α1 :: "'m1 ⇒ 'u ⇀ 'v1" and invar1
and α2 :: "'m2 ⇒ 'u ⇀ 'v2" and invar2
+
fixes map_value_image_filter :: "('u ⇒ 'v1 ⇒ 'v2 option) ⇒ 'm1 ⇒ 'm2"
assumes map_value_image_filter_correct_aux:
"invar1 m ⟹
invar2 (map_value_image_filter f m) ∧
(α2 (map_value_image_filter f m) =
(λk. Option.bind (α1 m k) (f k)))"
begin
lemmas map_value_image_filter_correct =
conjunct1[OF map_value_image_filter_correct_aux]
conjunct2[OF map_value_image_filter_correct_aux]
lemma map_value_image_filter_correct_alt :
"invar1 m ⟹
invar2 (map_value_image_filter f m)"
"invar1 m ⟹
(α2 (map_value_image_filter f m) k = Some v') ⟷
(∃v. (α1 m k = Some v) ∧ f k v = Some v')"
"invar1 m ⟹
(α2 (map_value_image_filter f m) k = None) ⟷
(∀v. (α1 m k = Some v) --> f k v = None)"
proof (-)
(*goals:
1. ‹invar1 m ⟹ invar2 (map_value_image_filter f m)›
2. ‹invar1 m ⟹ (α2 (map_value_image_filter f m) k = Some v') = (∃v. α1 m k = Some v ∧ f k v = Some v')›
3. ‹invar1 m ⟹ (α2 (map_value_image_filter f m) k = None) = (∀v. α1 m k = Some v ⟶ f k v = None)›*)
assume invar_m: "invar1 m" (*‹(invar1::'m1 ⇒ bool) (m::'m1)›*)
note aux = map_value_image_filter_correct_aux[OF invar_m] (*‹(invar2::'m2 ⇒ bool) ((map_value_image_filter::('u ⇒ 'v1 ⇒ 'v2 option) ⇒ 'm1 ⇒ 'm2) (?f::'u ⇒ 'v1 ⇒ 'v2 option) (m::'m1)) ∧ (α2::'m2 ⇒ 'u ⇒ 'v2 option) (map_value_image_filter ?f m) = (λk::'u. (α1::'m1 ⇒ 'u ⇒ 'v1 option) m k ⤜ ?f k)›*)
from aux (*‹invar2 (map_value_image_filter ?f m) ∧ α2 (map_value_image_filter ?f m) = (λk. α1 m k ⤜ ?f k)›*) show "invar2 (map_value_image_filter f m)"
by simp
from aux (*‹invar2 (map_value_image_filter ?f m) ∧ α2 (map_value_image_filter ?f m) = (λk. α1 m k ⤜ ?f k)›*) show "(α2 (map_value_image_filter f m) k = Some v') ⟷
(∃v. (α1 m k = Some v) ∧ f k v = Some v')"
apply (cases "α1 m k")
(*goals:
1. ‹⟦⋀f::'u ⇒ 'v1 ⇒ 'v2 option. (invar2::'m2 ⇒ bool) ((map_value_image_filter::('u ⇒ 'v1 ⇒ 'v2 option) ⇒ 'm1 ⇒ 'm2) f (m::'m1)) ∧ (α2::'m2 ⇒ 'u ⇒ 'v2 option) (map_value_image_filter f m) = (λk::'u. (α1::'m1 ⇒ 'u ⇒ 'v1 option) m k ⤜ f k); α1 m (k::'u) = None⟧ ⟹ (α2 (map_value_image_filter (f::'u ⇒ 'v1 ⇒ 'v2 option) m) k = Some (v'::'v2)) = (∃v::'v1. α1 m k = Some v ∧ f k v = Some v')›
2. ‹⋀a::'v1. ⟦⋀f::'u ⇒ 'v1 ⇒ 'v2 option. (invar2::'m2 ⇒ bool) ((map_value_image_filter::('u ⇒ 'v1 ⇒ 'v2 option) ⇒ 'm1 ⇒ 'm2) f (m::'m1)) ∧ (α2::'m2 ⇒ 'u ⇒ 'v2 option) (map_value_image_filter f m) = (λk::'u. (α1::'m1 ⇒ 'u ⇒ 'v1 option) m k ⤜ f k); α1 m (k::'u) = Some a⟧ ⟹ (α2 (map_value_image_filter (f::'u ⇒ 'v1 ⇒ 'v2 option) m) k = Some (v'::'v2)) = (∃v::'v1. α1 m k = Some v ∧ f k v = Some v')›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
from aux (*‹invar2 (map_value_image_filter ?f m) ∧ α2 (map_value_image_filter ?f m) = (λk. α1 m k ⤜ ?f k)›*) show "(α2 (map_value_image_filter f m) k = None) ⟷
(∀v. (α1 m k = Some v) --> f k v = None)"
apply (cases "α1 m k")
(*goals:
1. ‹⟦⋀f::'u ⇒ 'v1 ⇒ 'v2 option. (invar2::'m2 ⇒ bool) ((map_value_image_filter::('u ⇒ 'v1 ⇒ 'v2 option) ⇒ 'm1 ⇒ 'm2) f (m::'m1)) ∧ (α2::'m2 ⇒ 'u ⇒ 'v2 option) (map_value_image_filter f m) = (λk::'u. (α1::'m1 ⇒ 'u ⇒ 'v1 option) m k ⤜ f k); α1 m (k::'u) = None⟧ ⟹ (α2 (map_value_image_filter (f::'u ⇒ 'v1 ⇒ 'v2 option) m) k = None) = (∀v::'v1. α1 m k = Some v ⟶ f k v = None)›
2. ‹⋀a::'v1. ⟦⋀f::'u ⇒ 'v1 ⇒ 'v2 option. (invar2::'m2 ⇒ bool) ((map_value_image_filter::('u ⇒ 'v1 ⇒ 'v2 option) ⇒ 'm1 ⇒ 'm2) f (m::'m1)) ∧ (α2::'m2 ⇒ 'u ⇒ 'v2 option) (map_value_image_filter f m) = (λk::'u. (α1::'m1 ⇒ 'u ⇒ 'v1 option) m k ⤜ f k); α1 m (k::'u) = Some a⟧ ⟹ (α2 (map_value_image_filter (f::'u ⇒ 'v1 ⇒ 'v2 option) m) k = None) = (∀v::'v1. α1 m k = Some v ⟶ f k v = None)›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply simp
(*proven 2 subgoals*) .
qed
end
type_synonym ('k,'v,'m1,'m2) map_restrict = "('k × 'v ⇒ bool) ⇒ 'm1 ⇒ 'm2"
locale map_restrict = m1: map α1 invar1 + m2: map α2 invar2
for α1 :: "'m1 ⇒ 'u ⇀ 'v" and invar1
and α2 :: "'m2 ⇒ 'u ⇀ 'v" and invar2
+
fixes restrict :: "('u × 'v ⇒ bool) ⇒ 'm1 ⇒ 'm2"
assumes restrict_correct_aux1 :
"invar1 m ⟹ α2 (restrict P m) = α1 m |` {k. ∃v. α1 m k = Some v ∧ P (k, v)}"
"invar1 m ⟹ invar2 (restrict P m)"
begin
lemma restrict_correct_aux2 :
"invar1 m ⟹ α2 (restrict (λ(k,_). P k) m) = α1 m |` {k. P k}"
proof (-)
(*goal: ‹invar1 m ⟹ α2 (restrict (λ(k, uu_). P k) m) = α1 m |` {k. P k}›*)
assume invar_m: "invar1 m" (*‹(invar1::'m1 ⇒ bool) (m::'m1)›*)
have "α1 m |` {k. (∃v. α1 m k = Some v) ∧ P k} = α1 m |` {k. P k}" (is "α1 m |` ?A1 = α1 m |` ?A2")
proof (standard)
(*goal: ‹⋀x. (α1 m |` {k. (∃v. α1 m k = Some v) ∧ P k}) x = (α1 m |` {k. P k}) x›*)
fix k
show "(α1 m |` ?A1) k = (α1 m |` ?A2) k"
proof (cases "k ∈ ?A2")
(*goals:
1. ‹k ∈ {k. P k} ⟹ (α1 m |` {k. (∃v. α1 m k = Some v) ∧ P k}) k = (α1 m |` {k. P k}) k›
2. ‹k ∉ {k. P k} ⟹ (α1 m |` {k. (∃v. α1 m k = Some v) ∧ P k}) k = (α1 m |` {k. P k}) k›*)
case False (*‹(k::'u) ∉ {k::'u. (P::'u ⇒ bool) k}›*)
thus "?thesis"
(*goal: ‹(α1 m |` {k. (∃v. α1 m k = Some v) ∧ P k}) k = (α1 m |` {k. P k}) k›*)
by simp
next
(*goal: ‹k ∈ {k. P k} ⟹ (α1 m |` {k. (∃v. α1 m k = Some v) ∧ P k}) k = (α1 m |` {k. P k}) k›*)
case True (*‹k ∈ {k. P k}›*)
hence P_k: "P k"
by simp
show "?thesis"
(*goal: ‹(α1 m |` {k. (∃v. α1 m k = Some v) ∧ P k}) k = (α1 m |` {k. P k}) k›*)
apply (cases "α1 m k")
(*goals:
1. ‹(α1::'m1 ⇒ 'u ⇒ 'v option) (m::'m1) (k::'u) = None ⟹ (α1 m |` {k::'u. (∃v::'v. α1 m k = Some v) ∧ (P::'u ⇒ bool) k}) k = (α1 m |` {k::'u. P k}) k›
2. ‹⋀a::'v. (α1::'m1 ⇒ 'u ⇒ 'v option) (m::'m1) (k::'u) = Some a ⟹ (α1 m |` {k::'u. (∃v::'v. α1 m k = Some v) ∧ (P::'u ⇒ bool) k}) k = (α1 m |` {k::'u. P k}) k›
discuss goal 1*)
apply (simp add: P_k (*‹P k›*))
(*discuss goal 2*)
apply (simp add: P_k (*‹P k›*))
(*proven 2 subgoals*) .
qed
qed
with invar_m (*‹invar1 m›*) show "α2 (restrict (λ(k, _). P k) m) = α1 m |` {k. P k}"
by (simp add: restrict_correct_aux1 (*‹invar1 ?m ⟹ α2 (restrict ?P ?m) = α1 ?m |` {k. ∃v. α1 ?m k = Some v ∧ ?P (k, v)}› ‹invar1 ?m ⟹ invar2 (restrict ?P ?m)›*))
qed
lemmas restrict_correct =
restrict_correct_aux1
restrict_correct_aux2
end
subsection "Ordered Maps"
locale ordered_map = map α invar
for α :: "'s ⇒ ('u::linorder) ⇀ 'v" and invar
locale ordered_finite_map = finite_map α invar + ordered_map α invar
for α :: "'s ⇒ ('u::linorder) ⇀ 'v" and invar
subsubsection ‹Ordered Iteration›
(* Deprecated *)
(*
locale map_iterateoi = ordered_finite_map α invar
for α :: "'s ⇒ ('u::linorder) ⇀ 'v" and invar
+
fixes iterateoi :: "'s ⇒ ('u × 'v,'σ) set_iterator"
assumes iterateoi_rule: "
invar m ⟹ map_iterator_linord (iterateoi m) (α m)"
begin
lemma iterateoi_rule_P[case_names minv inv0 inv_pres i_complete i_inter]:
assumes MINV: "invar m"
assumes I0: "I (dom (α m)) σ0"
assumes IP: "!!k v it σ. ⟦
c σ;
k ∈ it;
∀j∈it. k≤j;
∀j∈dom (α m) - it. j≤k;
α m k = Some v;
it ⊆ dom (α m);
I it σ
⟧ ⟹ I (it - {k}) (f (k, v) σ)"
assumes IF: "!!σ. I {} σ ⟹ P σ"
assumes II: "!!σ it. ⟦
it ⊆ dom (α m);
it ≠ {};
¬ c σ;
I it σ;
∀k∈it. ∀j∈dom (α m) - it. j≤k
⟧ ⟹ P σ"
shows "P (iterateoi m c f σ0)"
using map_iterator_linord_rule_P [OF iterateoi_rule, of m I σ0 c f P] assms
by simp
lemma iterateo_rule_P[case_names minv inv0 inv_pres i_complete]:
assumes MINV: "invar m"
assumes I0: "I (dom (α m)) σ0"
assumes IP: "!!k v it σ. ⟦ k ∈ it; ∀j∈it. k≤j; ∀j∈dom (α m) - it. j≤k; α m k = Some v; it ⊆ dom (α m); I it σ ⟧
⟹ I (it - {k}) (f (k, v) σ)"
assumes IF: "!!σ. I {} σ ⟹ P σ"
shows "P (iterateoi m (λ_. True) f σ0)"
using map_iterator_linord_rule_P [OF iterateoi_rule, of m I σ0 "λ_. True" f P] assms
by simp
end
lemma map_iterateoi_I :
assumes "⋀m. invar m ⟹ map_iterator_linord (itoi m) (α m)"
shows "map_iterateoi α invar itoi"
proof
fix m
assume invar_m: "invar m"
from assms(1)[OF invar_m] show it_OK: "map_iterator_linord (itoi m) (α m)" .
from set_iterator_genord.finite_S0 [OF it_OK[unfolded set_iterator_map_linord_def]]
show "finite (dom (α m))" by (simp add: finite_map_to_set)
qed
locale map_reverse_iterateoi = ordered_finite_map α invar
for α :: "'s ⇒ ('u::linorder) ⇀ 'v" and invar
+
fixes reverse_iterateoi :: "'s ⇒ ('u × 'v,'σ) set_iterator"
assumes reverse_iterateoi_rule: "
invar m ⟹ map_iterator_rev_linord (reverse_iterateoi m) (α m)"
begin
lemma reverse_iterateoi_rule_P[case_names minv inv0 inv_pres i_complete i_inter]:
assumes MINV: "invar m"
assumes I0: "I (dom (α m)) σ0"
assumes IP: "!!k v it σ. ⟦
c σ;
k ∈ it;
∀j∈it. k≥j;
∀j∈dom (α m) - it. j≥k;
α m k = Some v;
it ⊆ dom (α m);
I it σ
⟧ ⟹ I (it - {k}) (f (k, v) σ)"
assumes IF: "!!σ. I {} σ ⟹ P σ"
assumes II: "!!σ it. ⟦
it ⊆ dom (α m);
it ≠ {};
¬ c σ;
I it σ;
∀k∈it. ∀j∈dom (α m) - it. j≥k
⟧ ⟹ P σ"
shows "P (reverse_iterateoi m c f σ0)"
using map_iterator_rev_linord_rule_P [OF reverse_iterateoi_rule, of m I σ0 c f P] assms
by simp
lemma reverse_iterateo_rule_P[case_names minv inv0 inv_pres i_complete]:
assumes MINV: "invar m"
assumes I0: "I (dom (α m)) σ0"
assumes IP: "!!k v it σ. ⟦
k ∈ it;
∀j∈it. k≥j;
∀j∈dom (α m) - it. j≥k;
α m k = Some v;
it ⊆ dom (α m);
I it σ
⟧ ⟹ I (it - {k}) (f (k, v) σ)"
assumes IF: "!!σ. I {} σ ⟹ P σ"
shows "P (reverse_iterateoi m (λ_. True) f σ0)"
using map_iterator_rev_linord_rule_P[OF reverse_iterateoi_rule, of m I σ0 "λ_. True" f P] assms
by simp
end
lemma map_reverse_iterateoi_I :
assumes "⋀m. invar m ⟹ map_iterator_rev_linord (ritoi m) (α m)"
shows "map_reverse_iterateoi α invar ritoi"
proof
fix m
assume invar_m: "invar m"
from assms(1)[OF invar_m] show it_OK: "map_iterator_rev_linord (ritoi m) (α m)" .
from set_iterator_genord.finite_S0 [OF it_OK[unfolded set_iterator_map_rev_linord_def]]
show "finite (dom (α m))" by (simp add: finite_map_to_set)
qed
*)
locale poly_map_iterateoi_defs =
fixes olist_it :: "'s ⇒ ('u×'v,('u×'v) list) set_iterator"
begin
definition iterateoi :: "'s ⇒ ('u×'v,'σ) set_iterator"
where "iterateoi S ≡ it_to_it (olist_it S)"
abbreviation "iterateo m ≡ iterateoi m (λ_. True)"
end
locale poly_map_iterateoi =
finite_map α invar + poly_map_iterateoi_defs list_ordered_it
for α :: "'s ⇒ ('u::linorder) ⇀ 'v"
and invar
and list_ordered_it :: "'s ⇒ ('u×'v,('u×'v) list) set_iterator" +
assumes list_ordered_it_correct: "invar m
⟹ map_iterator_linord (list_ordered_it m) (α m)"
begin
lemma iterateoi_correct: "invar S ⟹ map_iterator_linord (iterateoi S) (α S)"
unfolding iterateoi_def
(*goal: ‹invar S ⟹ map_iterator_linord (it_to_it (list_ordered_it S)) (α S)›*)
apply (rule it_to_it_map_linord_correct (*‹map_iterator_linord ?it ?S ⟹ map_iterator_linord (it_to_it ?it) ?S›*))
(*goal: ‹invar S ⟹ map_iterator_linord (it_to_it (list_ordered_it S)) (α S)›*)
by (rule list_ordered_it_correct (*‹invar ?m ⟹ map_iterator_linord (list_ordered_it ?m) (α ?m)›*))
lemma pi_iterateoi[icf_proper_iteratorI]:
"proper_it (iterateoi S) (iterateoi S)"
unfolding iterateoi_def
(*goal: ‹proper_it (it_to_it (list_ordered_it S)) (it_to_it (list_ordered_it S))›*)
by (intro icf_proper_iteratorI (*‹proper_it' ?it ?it' ⟹ proper_it' (map_iterator_dom ∘ ?it) (map_iterator_dom ∘ ?it')› ‹proper_it (it_to_it ?I) (it_to_it ?I)› ‹proper_it ?it ?it' ⟹ proper_it (map_iterator_dom ?it) (map_iterator_dom ?it')› ‹proper_it ?it ?it' ⟹ proper_it (set_iterator_image ?g ?it) (set_iterator_image ?g ?it')› ‹proper_it ?it ?it' ⟹ proper_it (set_iterator_filter ?P ?it) (set_iterator_filter ?P ?it')› ‹proper_it ?it ?it' ⟹ proper_it (set_iterator_image_filter ?g ?it) (set_iterator_image_filter ?g ?it')› ‹⟦proper_it ?it_a ?it_a'; ⋀x. proper_it (?it_b x) (?it_b' x)⟧ ⟹ proper_it (set_iterator_product ?it_a ?it_b) (set_iterator_product ?it_a' ?it_b')› ‹⟦proper_it ?it_a ?it_a'; proper_it ?it_b ?it_b'⟧ ⟹ proper_it (set_iterator_union ?it_a ?it_b) (set_iterator_union ?it_a' ?it_b')› ‹proper_it (set_iterator_sng ?x) (set_iterator_sng ?x)› ‹proper_it set_iterator_emp set_iterator_emp› ‹proper_it' (foldri ∘ ?tsl) (foldri ∘ ?tsl)› ‹proper_it' (foldli ∘ ?tsl) (foldli ∘ ?tsl)› and more 2 facts*))
lemma iterateoi_rule_P[case_names minv inv0 inv_pres i_complete i_inter]:
assumes MINV: "invar m"
assumes I0: "I (dom (α m)) σ0"
assumes IP: "!!k v it σ. ⟦
c σ;
k ∈ it;
α m k = Some v;
it ⊆ dom (α m);
I it σ;
⋀j. j∈it ⟹ k≤j;
⋀j. j∈dom (α m) - it ⟹ j≤k
⟧ ⟹ I (it - {k}) (f (k, v) σ)"
assumes IF: "!!σ. I {} σ ⟹ P σ"
assumes II: "!!σ it. ⟦
it ⊆ dom (α m);
it ≠ {};
¬ c σ;
I it σ;
⋀k j. ⟦k∈it; j∈dom (α m) - it⟧ ⟹ j≤k
⟧ ⟹ P σ"
shows "P (iterateoi m c f σ0)"
using assms (*‹invar m› ‹I (dom (α m)) σ0› ‹⟦c ?σ2; ?k2 ∈ ?it2; α m ?k2 = Some ?v2; ?it2 ⊆ dom (α m); I ?it2 ?σ2; ⋀j. j ∈ ?it2 ⟹ ?k2 ≤ j; ⋀j. j ∈ dom (α m) - ?it2 ⟹ j ≤ ?k2⟧ ⟹ I (?it2 - {?k2}) (f (?k2, ?v2) ?σ2)› ‹I {} ?σ2 ⟹ P ?σ2› ‹⟦?it2 ⊆ dom (α m); ?it2 ≠ {}; ¬ c ?σ2; I ?it2 ?σ2; ⋀k j. ⟦k ∈ ?it2; j ∈ dom (α m) - ?it2⟧ ⟹ j ≤ k⟧ ⟹ P ?σ2›*) apply -
(*goal: ‹(P::'a ⇒ bool) (iterateoi (m::'s) (c::'a ⇒ bool) (f::'u × 'v ⇒ 'a ⇒ 'a) (σ0::'a))›*)
apply (rule map_iterator_linord_rule_P[OF iterateoi_correct] (*‹⟦invar ?S1; ?I (dom (α ?S1)) ?σ0.0; ⋀k v it σ. ⟦?c σ; k ∈ it; α ?S1 k = Some v; it ⊆ dom (α ?S1); ?I it σ; ⋀k'. k' ∈ it ⟹ k ≤ k'; ⋀k'. k' ∈ dom (α ?S1) - it ⟹ k' ≤ k⟧ ⟹ ?I (it - {k}) (?f (k, v) σ); ⋀σ. ?I {} σ ⟹ ?P σ; ⋀σ it. ⟦it ⊆ dom (α ?S1); it ≠ {}; ¬ ?c σ; ?I it σ; ⋀k k'. ⟦k ∈ dom (α ?S1) - it; k' ∈ it⟧ ⟹ k ≤ k'⟧ ⟹ ?P σ⟧ ⟹ ?P (iterateoi ?S1 ?c ?f ?σ0.0)›*))
(*goals:
1. ‹⟦invar m; I (dom (α m)) σ0; ⋀σ k it v. ⟦c σ; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ; ⋀j. j ∈ it ⟹ k ≤ j; ⋀j. j ∈ dom (α m) - it ⟹ j ≤ k⟧ ⟹ I (it - {k}) (f (k, v) σ); ⋀σ. I {} σ ⟹ P σ; ⋀it σ. ⟦it ⊆ dom (α m); it ≠ {}; ¬ c σ; I it σ; ⋀k j. ⟦k ∈ it; j ∈ dom (α m) - it⟧ ⟹ j ≤ k⟧ ⟹ P σ⟧ ⟹ invar m›
2. ‹⟦invar m; I (dom (α m)) σ0; ⋀σ k it v. ⟦c σ; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ; ⋀j. j ∈ it ⟹ k ≤ j; ⋀j. j ∈ dom (α m) - it ⟹ j ≤ k⟧ ⟹ I (it - {k}) (f (k, v) σ); ⋀σ. I {} σ ⟹ P σ; ⋀it σ. ⟦it ⊆ dom (α m); it ≠ {}; ¬ c σ; I it σ; ⋀k j. ⟦k ∈ it; j ∈ dom (α m) - it⟧ ⟹ j ≤ k⟧ ⟹ P σ⟧ ⟹ ?I14 (dom (α m)) σ0›
3. ‹⋀k v it σ. ⟦invar m; I (dom (α m)) σ0; ⋀σ k it v. ⟦c σ; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ; ⋀j. j ∈ it ⟹ k ≤ j; ⋀j. j ∈ dom (α m) - it ⟹ j ≤ k⟧ ⟹ I (it - {k}) (f (k, v) σ); ⋀σ. I {} σ ⟹ P σ; ⋀it σ. ⟦it ⊆ dom (α m); it ≠ {}; ¬ c σ; I it σ; ⋀k j. ⟦k ∈ it; j ∈ dom (α m) - it⟧ ⟹ j ≤ k⟧ ⟹ P σ; c σ; k ∈ it; α m k = Some v; it ⊆ dom (α m); ?I14 it σ; ⋀k'. k' ∈ it ⟹ k ≤ k'; ⋀k'. k' ∈ dom (α m) - it ⟹ k' ≤ k⟧ ⟹ ?I14 (it - {k}) (f (k, v) σ)›
4. ‹⋀σ. ⟦invar m; I (dom (α m)) σ0; ⋀σ k it v. ⟦c σ; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ; ⋀j. j ∈ it ⟹ k ≤ j; ⋀j. j ∈ dom (α m) - it ⟹ j ≤ k⟧ ⟹ I (it - {k}) (f (k, v) σ); ⋀σ. I {} σ ⟹ P σ; ⋀it σ. ⟦it ⊆ dom (α m); it ≠ {}; ¬ c σ; I it σ; ⋀k j. ⟦k ∈ it; j ∈ dom (α m) - it⟧ ⟹ j ≤ k⟧ ⟹ P σ; ?I14 {} σ⟧ ⟹ P σ›
5. ‹⋀σ it. ⟦invar m; I (dom (α m)) σ0; ⋀σ k it v. ⟦c σ; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ; ⋀j. j ∈ it ⟹ k ≤ j; ⋀j. j ∈ dom (α m) - it ⟹ j ≤ k⟧ ⟹ I (it - {k}) (f (k, v) σ); ⋀σ. I {} σ ⟹ P σ; ⋀it σ. ⟦it ⊆ dom (α m); it ≠ {}; ¬ c σ; I it σ; ⋀k j. ⟦k ∈ it; j ∈ dom (α m) - it⟧ ⟹ j ≤ k⟧ ⟹ P σ; it ⊆ dom (α m); it ≠ {}; ¬ c σ; ?I14 it σ; ⋀k k'. ⟦k ∈ dom (α m) - it; k' ∈ it⟧ ⟹ k ≤ k'⟧ ⟹ P σ›
discuss goal 1*)
apply ((msorry)[1])
(*discuss goal 2*)
apply ((msorry)[1])
(*discuss goal 3*)
apply ((msorry)[1])
(*discuss goal 4*)
apply ((msorry)[1])
(*discuss goal 5*)
apply ((msorry)[1])
(*proven 5 subgoals*) .
lemma iterateo_rule_P[case_names minv inv0 inv_pres i_complete]:
assumes MINV: "invar m"
assumes I0: "I (dom (α m)) σ0"
assumes IP: "!!k v it σ. ⟦
k ∈ it;
α m k = Some v;
it ⊆ dom (α m);
I it σ;
⋀j. j∈it ⟹ k≤j;
⋀j. j∈dom (α m) - it ⟹ j≤k
⟧ ⟹ I (it - {k}) (f (k, v) σ)"
assumes IF: "!!σ. I {} σ ⟹ P σ"
shows "P (iterateo m f σ0)"
using assms (*‹invar m› ‹(I::'u set ⇒ 'a ⇒ bool) (dom ((α::'s ⇒ 'u ⇒ 'v option) (m::'s))) (σ0::'a)› ‹⟦?k2 ∈ ?it2; α m ?k2 = Some ?v2; ?it2 ⊆ dom (α m); I ?it2 ?σ2; ⋀j. j ∈ ?it2 ⟹ ?k2 ≤ j; ⋀j. j ∈ dom (α m) - ?it2 ⟹ j ≤ ?k2⟧ ⟹ I (?it2 - {?k2}) (f (?k2, ?v2) ?σ2)› ‹I {} ?σ2 ⟹ P ?σ2›*) map_iterator_linord_rule_P[OF iterateoi_correct, of m I σ0 "λ_. True" f P] (*‹⟦invar m; I (dom (α m)) σ0; ⋀k v it σ. ⟦True; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ; ⋀k'. k' ∈ it ⟹ k ≤ k'; ⋀k'. k' ∈ dom (α m) - it ⟹ k' ≤ k⟧ ⟹ I (it - {k}) (f (k, v) σ); ⋀σ. I {} σ ⟹ P σ; ⋀σ it. ⟦it ⊆ dom (α m); it ≠ {}; ¬ True; I it σ; ⋀k k'. ⟦k ∈ dom (α m) - it; k' ∈ it⟧ ⟹ k ≤ k'⟧ ⟹ P σ⟧ ⟹ P (iterateo m f σ0)›*) by blast
end
type_synonym ('k,'v,'s) map_list_rev_it
= "'s ⇒ ('k×'v,('k×'v) list) set_iterator"
locale poly_map_rev_iterateoi_defs =
fixes list_rev_it :: "'s ⇒ ('u×'v,('u×'v) list) set_iterator"
begin
definition rev_iterateoi :: "'s ⇒ ('u×'v,'σ) set_iterator"
where "rev_iterateoi S ≡ it_to_it (list_rev_it S)"
abbreviation "rev_iterateo m ≡ rev_iterateoi m (λ_. True)"
abbreviation "reverse_iterateoi ≡ rev_iterateoi"
abbreviation "reverse_iterateo ≡ rev_iterateo"
end
locale poly_map_rev_iterateoi =
finite_map α invar + poly_map_rev_iterateoi_defs list_rev_it
for α :: "'s ⇒ ('u::linorder) ⇀ 'v"
and invar
and list_rev_it :: "'s ⇒ ('u×'v,('u×'v) list) set_iterator" +
assumes list_rev_it_correct:
"invar m ⟹ map_iterator_rev_linord (list_rev_it m) (α m)"
begin
lemma rev_iterateoi_correct:
"invar S ⟹ map_iterator_rev_linord (rev_iterateoi S) (α S)"
unfolding rev_iterateoi_def
(*goal: ‹(invar::'s::type ⇒ bool) (S::'s::type) ⟹ map_iterator_rev_linord (it_to_it ((list_rev_it::'s::type ⇒ (('u::linorder × 'v::type) list ⇒ bool) ⇒ ('u::linorder × 'v::type ⇒ ('u::linorder × 'v::type) list ⇒ ('u::linorder × 'v::type) list) ⇒ ('u::linorder × 'v::type) list ⇒ ('u::linorder × 'v::type) list) S)) ((α::'s::type ⇒ 'u::linorder ⇒ 'v::type option) S)›*)
apply (rule it_to_it_map_rev_linord_correct (*‹map_iterator_rev_linord (?it::((?'u::linorder × ?'v::type) list ⇒ bool) ⇒ (?'u::linorder × ?'v::type ⇒ (?'u::linorder × ?'v::type) list ⇒ (?'u::linorder × ?'v::type) list) ⇒ (?'u::linorder × ?'v::type) list ⇒ (?'u::linorder × ?'v::type) list) (?S::?'u::linorder ⇒ ?'v::type option) ⟹ map_iterator_rev_linord (it_to_it ?it) ?S›*))
(*goal: ‹invar S ⟹ map_iterator_rev_linord (it_to_it (list_rev_it S)) (α S)›*)
by (rule list_rev_it_correct (*‹invar ?m ⟹ map_iterator_rev_linord (list_rev_it ?m) (α ?m)›*))
lemma pi_rev_iterateoi[icf_proper_iteratorI]:
"proper_it (rev_iterateoi S) (rev_iterateoi S)"
unfolding rev_iterateoi_def
(*goal: ‹proper_it (it_to_it (list_rev_it S)) (it_to_it (list_rev_it S))›*)
by (intro icf_proper_iteratorI (*‹proper_it' ?it ?it' ⟹ proper_it' (map_iterator_dom ∘ ?it) (map_iterator_dom ∘ ?it')› ‹proper_it (it_to_it ?I) (it_to_it ?I)› ‹proper_it ?it ?it' ⟹ proper_it (map_iterator_dom ?it) (map_iterator_dom ?it')› ‹proper_it ?it ?it' ⟹ proper_it (set_iterator_image ?g ?it) (set_iterator_image ?g ?it')› ‹proper_it ?it ?it' ⟹ proper_it (set_iterator_filter ?P ?it) (set_iterator_filter ?P ?it')› ‹proper_it ?it ?it' ⟹ proper_it (set_iterator_image_filter ?g ?it) (set_iterator_image_filter ?g ?it')› ‹⟦proper_it ?it_a ?it_a'; ⋀x. proper_it (?it_b x) (?it_b' x)⟧ ⟹ proper_it (set_iterator_product ?it_a ?it_b) (set_iterator_product ?it_a' ?it_b')› ‹⟦proper_it ?it_a ?it_a'; proper_it ?it_b ?it_b'⟧ ⟹ proper_it (set_iterator_union ?it_a ?it_b) (set_iterator_union ?it_a' ?it_b')› ‹proper_it (set_iterator_sng ?x) (set_iterator_sng ?x)› ‹proper_it set_iterator_emp set_iterator_emp› ‹proper_it' (foldri ∘ ?tsl) (foldri ∘ ?tsl)› ‹proper_it' (foldli ∘ ?tsl) (foldli ∘ ?tsl)› and more 2 facts*))
lemma rev_iterateoi_rule_P[case_names minv inv0 inv_pres i_complete i_inter]:
assumes MINV: "invar m"
assumes I0: "I (dom (α m)) σ0"
assumes IP: "!!k v it σ. ⟦
c σ;
k ∈ it;
α m k = Some v;
it ⊆ dom (α m);
I it σ;
⋀j. j∈it ⟹ k≥j;
⋀j. j∈dom (α m) - it ⟹ j≥k
⟧ ⟹ I (it - {k}) (f (k, v) σ)"
assumes IF: "!!σ. I {} σ ⟹ P σ"
assumes II: "!!σ it. ⟦
it ⊆ dom (α m);
it ≠ {};
¬ c σ;
I it σ;
⋀k j. ⟦k∈it; j∈dom (α m) - it⟧ ⟹ j≥k
⟧ ⟹ P σ"
shows "P (rev_iterateoi m c f σ0)"
using assms (*‹invar m› ‹I (dom (α m)) σ0› ‹⟦c ?σ4; ?k4 ∈ ?it4; α m ?k4 = Some ?v4; ?it4 ⊆ dom (α m); I ?it4 ?σ4; ⋀j. j ∈ ?it4 ⟹ j ≤ ?k4; ⋀j. j ∈ dom (α m) - ?it4 ⟹ ?k4 ≤ j⟧ ⟹ I (?it4 - {?k4}) (f (?k4, ?v4) ?σ4)› ‹I {} ?σ4 ⟹ P ?σ4› ‹⟦?it4 ⊆ dom (α m); ?it4 ≠ {}; ¬ c ?σ4; I ?it4 ?σ4; ⋀k j. ⟦k ∈ ?it4; j ∈ dom (α m) - ?it4⟧ ⟹ k ≤ j⟧ ⟹ P ?σ4›*) apply -
(*goal: ‹P (reverse_iterateoi m c f σ0)›*)
apply (rule map_iterator_rev_linord_rule_P[OF rev_iterateoi_correct] (*‹⟦invar ?S1; ?I (dom (α ?S1)) ?σ0.0; ⋀k v it σ. ⟦?c σ; k ∈ it; α ?S1 k = Some v; it ⊆ dom (α ?S1); ?I it σ; ⋀k'. k' ∈ it ⟹ k' ≤ k; ⋀k'. k' ∈ dom (α ?S1) - it ⟹ k ≤ k'⟧ ⟹ ?I (it - {k}) (?f (k, v) σ); ⋀σ. ?I {} σ ⟹ ?P σ; ⋀σ it. ⟦it ⊆ dom (α ?S1); it ≠ {}; ¬ ?c σ; ?I it σ; ⋀k k'. ⟦k ∈ dom (α ?S1) - it; k' ∈ it⟧ ⟹ k' ≤ k⟧ ⟹ ?P σ⟧ ⟹ ?P (reverse_iterateoi ?S1 ?c ?f ?σ0.0)›*))
(*goals:
1. ‹⟦invar m; I (dom (α m)) σ0; ⋀σ k it v. ⟦c σ; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ; ⋀j. j ∈ it ⟹ j ≤ k; ⋀j. j ∈ dom (α m) - it ⟹ k ≤ j⟧ ⟹ I (it - {k}) (f (k, v) σ); ⋀σ. I {} σ ⟹ P σ; ⋀it σ. ⟦it ⊆ dom (α m); it ≠ {}; ¬ c σ; I it σ; ⋀k j. ⟦k ∈ it; j ∈ dom (α m) - it⟧ ⟹ k ≤ j⟧ ⟹ P σ⟧ ⟹ invar m›
2. ‹⟦invar m; I (dom (α m)) σ0; ⋀σ k it v. ⟦c σ; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ; ⋀j. j ∈ it ⟹ j ≤ k; ⋀j. j ∈ dom (α m) - it ⟹ k ≤ j⟧ ⟹ I (it - {k}) (f (k, v) σ); ⋀σ. I {} σ ⟹ P σ; ⋀it σ. ⟦it ⊆ dom (α m); it ≠ {}; ¬ c σ; I it σ; ⋀k j. ⟦k ∈ it; j ∈ dom (α m) - it⟧ ⟹ k ≤ j⟧ ⟹ P σ⟧ ⟹ ?I20 (dom (α m)) σ0›
3. ‹⋀k v it σ. ⟦invar m; I (dom (α m)) σ0; ⋀σ k it v. ⟦c σ; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ; ⋀j. j ∈ it ⟹ j ≤ k; ⋀j. j ∈ dom (α m) - it ⟹ k ≤ j⟧ ⟹ I (it - {k}) (f (k, v) σ); ⋀σ. I {} σ ⟹ P σ; ⋀it σ. ⟦it ⊆ dom (α m); it ≠ {}; ¬ c σ; I it σ; ⋀k j. ⟦k ∈ it; j ∈ dom (α m) - it⟧ ⟹ k ≤ j⟧ ⟹ P σ; c σ; k ∈ it; α m k = Some v; it ⊆ dom (α m); ?I20 it σ; ⋀k'. k' ∈ it ⟹ k' ≤ k; ⋀k'. k' ∈ dom (α m) - it ⟹ k ≤ k'⟧ ⟹ ?I20 (it - {k}) (f (k, v) σ)›
4. ‹⋀σ. ⟦invar m; I (dom (α m)) σ0; ⋀σ k it v. ⟦c σ; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ; ⋀j. j ∈ it ⟹ j ≤ k; ⋀j. j ∈ dom (α m) - it ⟹ k ≤ j⟧ ⟹ I (it - {k}) (f (k, v) σ); ⋀σ. I {} σ ⟹ P σ; ⋀it σ. ⟦it ⊆ dom (α m); it ≠ {}; ¬ c σ; I it σ; ⋀k j. ⟦k ∈ it; j ∈ dom (α m) - it⟧ ⟹ k ≤ j⟧ ⟹ P σ; ?I20 {} σ⟧ ⟹ P σ›
5. ‹⋀σ it. ⟦invar m; I (dom (α m)) σ0; ⋀σ k it v. ⟦c σ; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ; ⋀j. j ∈ it ⟹ j ≤ k; ⋀j. j ∈ dom (α m) - it ⟹ k ≤ j⟧ ⟹ I (it - {k}) (f (k, v) σ); ⋀σ. I {} σ ⟹ P σ; ⋀it σ. ⟦it ⊆ dom (α m); it ≠ {}; ¬ c σ; I it σ; ⋀k j. ⟦k ∈ it; j ∈ dom (α m) - it⟧ ⟹ k ≤ j⟧ ⟹ P σ; it ⊆ dom (α m); it ≠ {}; ¬ c σ; ?I20 it σ; ⋀k k'. ⟦k ∈ dom (α m) - it; k' ∈ it⟧ ⟹ k' ≤ k⟧ ⟹ P σ›
discuss goal 1*)
apply ((msorry)[1])
(*discuss goal 2*)
apply ((msorry)[1])
(*discuss goal 3*)
apply ((msorry)[1])
(*discuss goal 4*)
apply ((msorry)[1])
(*discuss goal 5*)
apply ((msorry)[1])
(*proven 5 subgoals*) .
lemma rev_iterateo_rule_P[case_names minv inv0 inv_pres i_complete]:
assumes MINV: "invar m"
assumes I0: "I (dom (α m)) σ0"
assumes IP: "!!k v it σ. ⟦
k ∈ it;
α m k = Some v;
it ⊆ dom (α m);
I it σ;
⋀j. j∈it ⟹ k≥j;
⋀j. j∈dom (α m) - it ⟹ j≥k
⟧ ⟹ I (it - {k}) (f (k, v) σ)"
assumes IF: "!!σ. I {} σ ⟹ P σ"
shows "P (rev_iterateo m f σ0)"
using assms (*‹invar m› ‹I (dom (α m)) σ0› ‹⟦(?k4::'u) ∈ (?it4::'u set); (α::'s ⇒ 'u ⇒ 'v option) (m::'s) ?k4 = Some (?v4::'v); ?it4 ⊆ dom (α m); (I::'u set ⇒ 'a ⇒ bool) ?it4 (?σ4::'a); ⋀j::'u. j ∈ ?it4 ⟹ j ≤ ?k4; ⋀j::'u. j ∈ dom (α m) - ?it4 ⟹ ?k4 ≤ j⟧ ⟹ I (?it4 - {?k4}) ((f::'u × 'v ⇒ 'a ⇒ 'a) (?k4, ?v4) ?σ4)› ‹I {} ?σ4 ⟹ P ?σ4›*) map_iterator_rev_linord_rule_P[OF rev_iterateoi_correct, of m I σ0 "λ_. True" f P] (*‹⟦invar m; I (dom (α m)) σ0; ⋀k v it σ. ⟦True; k ∈ it; α m k = Some v; it ⊆ dom (α m); I it σ; ⋀k'. k' ∈ it ⟹ k' ≤ k; ⋀k'. k' ∈ dom (α m) - it ⟹ k ≤ k'⟧ ⟹ I (it - {k}) (f (k, v) σ); ⋀σ. I {} σ ⟹ P σ; ⋀σ it. ⟦it ⊆ dom (α m); it ≠ {}; ¬ True; I it σ; ⋀k k'. ⟦k ∈ dom (α m) - it; k' ∈ it⟧ ⟹ k' ≤ k⟧ ⟹ P σ⟧ ⟹ P (reverse_iterateo m f σ0)›*) by blast
end
subsubsection ‹Minimal and Maximal Elements›
type_synonym ('k,'v,'s) map_min
= "'s ⇒ ('k × 'v ⇒ bool) ⇒ ('k × 'v) option"
locale map_min = ordered_map +
constrains α :: "'s ⇒ 'u::linorder ⇀ 'v"
fixes min :: "'s ⇒ ('u × 'v ⇒ bool) ⇒ ('u × 'v) option"
assumes min_correct:
"⟦ invar s; rel_of (α s) P ≠ {} ⟧ ⟹ min s P ∈ Some ` rel_of (α s) P"
"⟦ invar s; (k,v) ∈ rel_of (α s) P ⟧ ⟹ fst (the (min s P)) ≤ k"
"⟦ invar s; rel_of (α s) P = {} ⟧ ⟹ min s P = None"
begin
lemma minE:
assumes A: "invar s" "rel_of (α s) P ≠ {}"
obtains k v where
"min s P = Some (k,v)" "(k,v)∈rel_of (α s) P" "∀(k',v')∈rel_of (α s) P. k ≤ k'"
proof (-)
(*goal: ‹(⋀(k::'u) v::'v. ⟦(min::'s ⇒ ('u × 'v ⇒ bool) ⇒ ('u × 'v) option) (s::'s) (P::'u × 'v ⇒ bool) = Some (k, v); (k, v) ∈ rel_of ((α::'s ⇒ 'u ⇒ 'v option) s) P; ∀(k'::'u, v'::'v)∈rel_of (α s) P. k ≤ k'⟧ ⟹ thesis::bool) ⟹ thesis›*)
from min_correct(1)[OF A] (*‹min s P ∈ Some ` rel_of (α s) P›*) have MIS: "min s P ∈ Some ` rel_of (α s) P" .
then obtain k and v where KV: "min s P = Some (k,v)" "(k,v)∈rel_of (α s) P"
(*goal: ‹(⋀k v. ⟦min s P = Some (k, v); (k, v) ∈ rel_of (α s) P⟧ ⟹ thesis) ⟹ thesis›*)
by auto
show thesis
apply (rule that[OF KV] (*‹∀(k', v')∈rel_of (α s) P. k ≤ k' ⟹ thesis›*))
(*goal: ‹thesis›*)
apply clarify
(*goal: ‹∀(k'::'u::linorder, v'::'v::type)∈rel_of ((α::'s::type ⇒ 'u::linorder ⇒ 'v::type option) (s::'s::type)) (P::'u::linorder × 'v::type ⇒ bool). (k::'u::linorder) ≤ k'›*)
apply (drule min_correct(2)[OF ‹invar s›] (*‹(?k, ?v) ∈ rel_of (α s) ?P ⟹ fst (the (min s ?P)) ≤ ?k›*))
(*goal: ‹⋀a b. (a, b) ∈ rel_of (α s) P ⟹ k ≤ a›*)
by (simp add: KV( (*‹min s P = Some (k, v)›*) 1))
qed
lemmas minI = min_correct(3)
lemma min_Some:
"⟦ invar s; min s P = Some (k,v) ⟧ ⟹ (k,v)∈rel_of (α s) P"
"⟦ invar s; min s P = Some (k,v); (k',v')∈rel_of (α s) P ⟧ ⟹ k≤k'"
(*goals:
1. ‹⟦invar s; min s P = Some (k, v)⟧ ⟹ (k, v) ∈ rel_of (α s) P›
2. ‹⟦invar s; min s P = Some (k, v); (k', v') ∈ rel_of (α s) P⟧ ⟹ k ≤ k'›
discuss goal 1*)
apply -
(*top goal: ‹⟦invar s; min s P = Some (k, v)⟧ ⟹ (k, v) ∈ rel_of (α s) P› and 1 goal remains*)
apply (cases "rel_of (α s) P = {}")
(*goals:
1. ‹⟦invar s; min s P = Some (k, v); rel_of (α s) P = {}⟧ ⟹ (k, v) ∈ rel_of (α s) P›
2. ‹⟦invar s; min s P = Some (k, v); rel_of (α s) P ≠ {}⟧ ⟹ (k, v) ∈ rel_of (α s) P›
discuss goal 1*)
apply (drule (1) min_correct( (*‹⟦invar ?s; rel_of (α ?s) ?P = {}⟧ ⟹ min ?s ?P = None›*) 3))
(*top goal: ‹⟦invar s; min s P = Some (k, v); rel_of (α s) P = {}⟧ ⟹ (k, v) ∈ rel_of (α s) P› and 2 goals remain*)
apply simp
(*discuss goal 2*)
apply (erule (1) minE (*‹⟦invar ?s; rel_of (α ?s) ?P ≠ {}; ⋀k v. ⟦min ?s ?P = Some (k, v); (k, v) ∈ rel_of (α ?s) ?P; ∀(k', v')∈rel_of (α ?s) ?P. k ≤ k'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))
(*top goal: ‹⟦invar s; min s P = Some (k, v); rel_of (α s) P ≠ {}⟧ ⟹ (k, v) ∈ rel_of (α s) P› and 1 goal remains*)
apply auto
(*proven 2 subgoals*)
(*discuss goal 2*)
apply (drule (1) min_correct( (*‹⟦(invar::'s ⇒ bool) (?s::'s); (?k::'u, ?v::'v) ∈ rel_of ((α::'s ⇒ 'u ⇒ 'v option) ?s) (?P::'u × 'v ⇒ bool)⟧ ⟹ fst (the ((min::'s ⇒ ('u × 'v ⇒ bool) ⇒ ('u × 'v) option) ?s ?P)) ≤ ?k›*) 2))
(*goal: ‹⟦invar s; min s P = Some (k, v); (k', v') ∈ rel_of (α s) P⟧ ⟹ k ≤ k'›*)
apply auto
(*proven 2 subgoals*) .
lemma min_None:
"⟦ invar s; min s P = None ⟧ ⟹ rel_of (α s) P = {}"
apply (cases "rel_of (α s) P = {}")
(*goals:
1. ‹⟦invar s; min s P = None; rel_of (α s) P = {}⟧ ⟹ rel_of (α s) P = {}›
2. ‹⟦invar s; min s P = None; rel_of (α s) P ≠ {}⟧ ⟹ rel_of (α s) P = {}›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (drule (1) min_correct( (*‹⟦(invar::'s ⇒ bool) (?s::'s); rel_of ((α::'s ⇒ 'u ⇒ 'v option) ?s) (?P::'u × 'v ⇒ bool) ≠ {}⟧ ⟹ (min::'s ⇒ ('u × 'v ⇒ bool) ⇒ ('u × 'v) option) ?s ?P ∈ Some ` rel_of (α ?s) ?P›*) 1))
(*goal: ‹⟦invar s; min s P = None; rel_of (α s) P ≠ {}⟧ ⟹ rel_of (α s) P = {}›*)
apply auto
(*proven 2 subgoals*) .
end
type_synonym ('k,'v,'s) map_max
= "'s ⇒ ('k × 'v ⇒ bool) ⇒ ('k × 'v) option"
locale map_max = ordered_map +
constrains α :: "'s ⇒ 'u::linorder ⇀ 'v"
fixes max :: "'s ⇒ ('u × 'v ⇒ bool) ⇒ ('u × 'v) option"
assumes max_correct:
"⟦ invar s; rel_of (α s) P ≠ {} ⟧ ⟹ max s P ∈ Some ` rel_of (α s) P"
"⟦ invar s; (k,v) ∈ rel_of (α s) P ⟧ ⟹ fst (the (max s P)) ≥ k"
"⟦ invar s; rel_of (α s) P = {} ⟧ ⟹ max s P = None"
begin
lemma maxE:
assumes A: "invar s" "rel_of (α s) P ≠ {}"
obtains k v where
"max s P = Some (k,v)" "(k,v)∈rel_of (α s) P" "∀(k',v')∈rel_of (α s) P. k ≥ k'"
proof (-)
(*goal: ‹(⋀k v. ⟦max s P = Some (k, v); (k, v) ∈ rel_of (α s) P; ∀(k', v')∈rel_of (α s) P. k' ≤ k⟧ ⟹ thesis) ⟹ thesis›*)
from max_correct(1)[OF A] (*‹max s P ∈ Some ` rel_of (α s) P›*) have MIS: "max s P ∈ Some ` rel_of (α s) P" .
then obtain k and v where KV: "max s P = Some (k,v)" "(k,v)∈rel_of (α s) P"
(*goal: ‹(⋀(k::'u) v::'v. ⟦(max::'s ⇒ ('u × 'v ⇒ bool) ⇒ ('u × 'v) option) (s::'s) (P::'u × 'v ⇒ bool) = Some (k, v); (k, v) ∈ rel_of ((α::'s ⇒ 'u ⇒ 'v option) s) P⟧ ⟹ thesis::bool) ⟹ thesis›*)
by auto
show thesis
apply (rule that[OF KV] (*‹∀(k', v')∈rel_of (α s) P. k' ≤ k ⟹ thesis›*))
(*goal: ‹thesis›*)
apply clarify
(*goal: ‹∀(k', v')∈rel_of (α s) P. k' ≤ k›*)
apply (drule max_correct(2)[OF ‹invar s›] (*‹(?k::'u, ?v::'v) ∈ rel_of ((α::'s ⇒ 'u ⇒ 'v option) (s::'s)) (?P::'u × 'v ⇒ bool) ⟹ ?k ≤ fst (the ((max::'s ⇒ ('u × 'v ⇒ bool) ⇒ ('u × 'v) option) s ?P))›*))
(*goal: ‹⋀(a::'u::linorder) b::'v::type. (a, b) ∈ rel_of ((α::'s::type ⇒ 'u::linorder ⇒ 'v::type option) (s::'s::type)) (P::'u::linorder × 'v::type ⇒ bool) ⟹ a ≤ (k::'u::linorder)›*)
by (simp add: KV( (*‹max s P = Some (k, v)›*) 1))
qed
lemmas maxI = max_correct(3)
lemma max_Some:
"⟦ invar s; max s P = Some (k,v) ⟧ ⟹ (k,v)∈rel_of (α s) P"
"⟦ invar s; max s P = Some (k,v); (k',v')∈rel_of (α s) P ⟧ ⟹ k≥k'"
sorry
lemma max_None:
"⟦ invar s; max s P = None ⟧ ⟹ rel_of (α s) P = {}"
apply (cases "rel_of (α s) P = {}")
(*goals:
1. ‹⟦invar s; max s P = None; rel_of (α s) P = {}⟧ ⟹ rel_of (α s) P = {}›
2. ‹⟦invar s; max s P = None; rel_of (α s) P ≠ {}⟧ ⟹ rel_of (α s) P = {}›
discuss goal 1*)
apply simp
(*discuss goal 2*)
apply (drule (1) max_correct( (*‹⟦invar ?s; rel_of (α ?s) ?P ≠ {}⟧ ⟹ max ?s ?P ∈ Some ` rel_of (α ?s) ?P›*) 1))
(*goal: ‹⟦(invar::'s ⇒ bool) (s::'s); (max::'s ⇒ ('u × 'v ⇒ bool) ⇒ ('u × 'v) option) s (P::'u × 'v ⇒ bool) = None; rel_of ((α::'s ⇒ 'u ⇒ 'v option) s) P ≠ {}⟧ ⟹ rel_of (α s) P = {}›*)
apply auto
(*proven 2 subgoals*) .
end
subsubsection "Conversion to List"
type_synonym ('k,'v,'s) map_to_sorted_list
= "'s ⇒ ('k × 'v) list"
locale map_to_sorted_list = ordered_map +
constrains α :: "'s ⇒ 'u::linorder ⇀ 'v"
fixes to_sorted_list :: "'s ⇒ ('u×'v) list"
assumes to_sorted_list_correct:
"invar m ⟹ map_of (to_sorted_list m) = α m"
"invar m ⟹ distinct (map fst (to_sorted_list m))"
"invar m ⟹ sorted (map fst (to_sorted_list m))"
type_synonym ('k,'v,'s) map_to_rev_list
= "'s ⇒ ('k × 'v) list"
locale map_to_rev_list = ordered_map +
constrains α :: "'s ⇒ 'u::linorder ⇀ 'v"
fixes to_rev_list :: "'s ⇒ ('u×'v) list"
assumes to_rev_list_correct:
"invar m ⟹ map_of (to_rev_list m) = α m"
"invar m ⟹ distinct (map fst (to_rev_list m))"
"invar m ⟹ sorted (rev (map fst (to_rev_list m)))"
subsection "Record Based Interface"
record ('k,'v,'s) map_ops =
map_op_α :: "('k,'v,'s) map_α"
map_op_invar :: "('k,'v,'s) map_invar"
map_op_empty :: "('k,'v,'s) map_empty"
map_op_lookup :: "('k,'v,'s) map_lookup"
map_op_update :: "('k,'v,'s) map_update"
map_op_update_dj :: "('k,'v,'s) map_update_dj"
map_op_delete :: "('k,'v,'s) map_delete"
map_op_list_it :: "('k,'v,'s) map_list_it"
map_op_sng :: "('k,'v,'s) map_sng"
map_op_restrict :: "('k,'v,'s,'s) map_restrict"
map_op_add :: "('k,'v,'s) map_add"
map_op_add_dj :: "('k,'v,'s) map_add_dj"
map_op_isEmpty :: "('k,'v,'s) map_isEmpty"
map_op_isSng :: "('k,'v,'s) map_isSng"
map_op_ball :: "('k,'v,'s) map_ball"
map_op_bex :: "('k,'v,'s) map_bex"
map_op_size :: "('k,'v,'s) map_size"
map_op_size_abort :: "('k,'v,'s) map_size_abort"
map_op_sel :: "('k,'v,'s) map_sel'"
map_op_to_list :: "('k,'v,'s) map_to_list"
map_op_to_map :: "('k,'v,'s) list_to_map"
locale StdMapDefs = poly_map_iteratei_defs "map_op_list_it ops"
for ops :: "('k,'v,'s,'more) map_ops_scheme"
begin
abbreviation α where "α == map_op_α ops"
abbreviation invar where "invar == map_op_invar ops"
abbreviation empty where "empty == map_op_empty ops"
abbreviation lookup where "lookup == map_op_lookup ops"
abbreviation update where "update == map_op_update ops"
abbreviation update_dj where "update_dj == map_op_update_dj ops"
abbreviation delete where "delete == map_op_delete ops"
abbreviation list_it where "list_it == map_op_list_it ops"
abbreviation sng where "sng == map_op_sng ops"
abbreviation restrict where "restrict == map_op_restrict ops"
abbreviation add where "add == map_op_add ops"
abbreviation add_dj where "add_dj == map_op_add_dj ops"
abbreviation isEmpty where "isEmpty == map_op_isEmpty ops"
abbreviation isSng where "isSng == map_op_isSng ops"
abbreviation ball where "ball == map_op_ball ops"
abbreviation bex where "bex == map_op_bex ops"
abbreviation size where "size == map_op_size ops"
abbreviation size_abort where "size_abort == map_op_size_abort ops"
abbreviation sel where "sel == map_op_sel ops"
abbreviation to_list where "to_list == map_op_to_list ops"
abbreviation to_map where "to_map == map_op_to_map ops"
end
locale StdMap = StdMapDefs ops +
map α invar +
map_empty α invar empty +
map_lookup α invar lookup +
map_update α invar update +
map_update_dj α invar update_dj +
map_delete α invar delete +
poly_map_iteratei α invar list_it +
map_sng α invar sng +
map_restrict α invar α invar restrict +
map_add α invar add +
map_add_dj α invar add_dj +
map_isEmpty α invar isEmpty +
map_isSng α invar isSng +
map_ball α invar ball +
map_bex α invar bex +
map_size α invar size +
map_size_abort α invar size_abort +
map_sel' α invar sel +
map_to_list α invar to_list +
list_to_map α invar to_map
for ops :: "('k,'v,'s,'more) map_ops_scheme"
begin
lemmas correct =
empty_correct
sng_correct
lookup_correct
update_correct
update_dj_correct
delete_correct
restrict_correct
add_correct
add_dj_correct
isEmpty_correct
isSng_correct
ball_correct
bex_correct
size_correct
size_abort_correct
to_list_correct
to_map_correct
end
lemmas StdMap_intro = StdMap.intro[rem_dup_prems]
locale StdMap_no_invar = StdMap + map_no_invar α invar
record ('k,'v,'s) omap_ops = "('k,'v,'s) map_ops" +
map_op_ordered_list_it :: "'s ⇒ ('k,'v,('k×'v) list) map_iterator"
map_op_rev_list_it :: "'s ⇒ ('k,'v,('k×'v) list) map_iterator"
map_op_min :: "'s ⇒ ('k × 'v ⇒ bool) ⇒ ('k × 'v) option"
map_op_max :: "'s ⇒ ('k × 'v ⇒ bool) ⇒ ('k × 'v) option"
map_op_to_sorted_list :: "'s ⇒ ('k × 'v) list"
map_op_to_rev_list :: "'s ⇒ ('k × 'v) list"
locale StdOMapDefs = StdMapDefs ops
+ poly_map_iterateoi_defs "map_op_ordered_list_it ops"
+ poly_map_rev_iterateoi_defs "map_op_rev_list_it ops"
for ops :: "('k::linorder,'v,'s,'more) omap_ops_scheme"
begin
abbreviation ordered_list_it where "ordered_list_it
≡ map_op_ordered_list_it ops"
abbreviation rev_list_it where "rev_list_it
≡ map_op_rev_list_it ops"
abbreviation min where "min == map_op_min ops"
abbreviation max where "max == map_op_max ops"
abbreviation to_sorted_list where
"to_sorted_list ≡ map_op_to_sorted_list ops"
abbreviation to_rev_list where "to_rev_list ≡ map_op_to_rev_list ops"
end
locale StdOMap =
StdOMapDefs ops +
StdMap ops +
poly_map_iterateoi α invar ordered_list_it +
poly_map_rev_iterateoi α invar rev_list_it +
map_min α invar min +
map_max α invar max +
map_to_sorted_list α invar to_sorted_list +
map_to_rev_list α invar to_rev_list
for ops :: "('k::linorder,'v,'s,'more) omap_ops_scheme"
begin
end
lemmas StdOMap_intro =
StdOMap.intro[OF StdMap_intro, rem_dup_prems]
end
| {
"path": "afp-2025-02-12/thys/Collections/ICF/spec/MapSpec.thy",
"repo": "afp-2025-02-12",
"sha": "6568d5afacc0128c56e5fc6ca68e165b78186a8c64bd5a2ec7bbdbf839bcbc6b"
} |
(* Title: A locale for and a characterization of maximal normal subgroups
Author: Jakob von Raumer, Karlsruhe Institute of Technology
Maintainer: Jakob von Raumer <jakob.raumer@student.kit.edu>
*)
theory MaximalNormalSubgroups
imports "HOL-Algebra.Algebra"
begin
section ‹Facts about maximal normal subgroups›
text ‹A maximal normal subgroup of $G$ is a normal subgroup which is not contained in other any proper
normal subgroup of $G$.›
locale max_normal_subgroup = normal +
assumes proper: "H ≠ carrier G"
assumes max_normal: "⋀J. J ⊲ G ⟹ J ≠ H ⟹ J ≠ carrier G ⟹ ¬ (H ⊆ J)"
text ‹Another characterization of maximal normal subgroups: The factor group is simple.›
theorem (in normal) max_normal_simple_quotient:
assumes finite: "finite (carrier G)"
shows "max_normal_subgroup H G = simple_group (G Mod H)"
proof (standard)
(*goals:
1. ‹max_normal_subgroup H G ⟹ simple_group (G Mod H)›
2. ‹simple_group (G Mod H) ⟹ max_normal_subgroup H G›*)
assume "max_normal_subgroup H G" (*‹max_normal_subgroup (H::'a set) G›*)
then interpret maxH: max_normal_subgroup H G .
show "simple_group (G Mod H)"
unfolding simple_group_def simple_group_axioms_def
(*goal: ‹Group.group (G Mod H) ∧ 1 < order (G Mod H) ∧ (∀Ha. Ha ⊲ G Mod H ⟶ Ha = carrier (G Mod H) ∨ Ha = {𝟭⇘G Mod H⇙})›*)
proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) factorgroup_is_group (*‹Group.group (G Mod H)›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) disjCI (*‹(¬ ?Q ⟹ ?P) ⟹ ?P ∨ ?Q›*))
(*goals:
1. ‹(1::nat) < order (G Mod (H::'a set))›
2. ‹⋀Ha::'a set set. ⟦Ha ⊲ G Mod (H::'a set); Ha ≠ {𝟭⇘G Mod H⇙}⟧ ⟹ Ha = carrier (G Mod H)›*)
have gt0: "0 < card (rcosets H)"
by (metis gr_zeroI (*‹((?n::?'a) = (0::?'a) ⟹ False) ⟹ (0::?'a) < ?n›*) lagrange_finite (*‹⟦finite (carrier G); subgroup (?H::'a set) G⟧ ⟹ card (rcosets ?H) * card ?H = order G›*) assms (*‹finite (carrier G)›*) mult_is_0 (*‹((?m::nat) * (?n::nat) = (0::nat)) = (?m = (0::nat) ∨ ?n = (0::nat))›*) order_gt_0_iff_finite (*‹((0::nat) < order G) = finite (carrier G)›*) subgroup_axioms (*‹subgroup (H::'a set) G›*))
from maxH.proper (*‹(H::'a::type set) ≠ carrier G›*) finite (*‹finite (carrier G)›*) have "carrier (G Mod H) ≠ {𝟭⇘G Mod H⇙}"
using fact_group_trivial_iff (*‹finite (carrier G) ⟹ (carrier (G Mod H) = {𝟭⇘G Mod H⇙}) = (H = carrier G)›*) by auto
hence "1 ≠ order (G Mod H)"
using factorgroup_is_group (*‹Group.group (G Mod H)›*) group.order_one_triv_iff (*‹Group.group ?G ⟹ (order ?G = 1) = (carrier ?G = {𝟭⇘?G⇙})›*) by metis
with gt0 (*‹0 < card (rcosets H)›*) show "1 < order (G Mod H)"
unfolding order_def FactGroup_def
(*goal: ‹(1::nat) < card (carrier ⦇carrier = rcosets (H::'a::type set), monoid.mult = (<#>), one = H⦈)›*)
by auto
next
(*goal: ‹⋀Ha. ⟦Ha ⊲ G Mod H; Ha ≠ {𝟭⇘G Mod H⇙}⟧ ⟹ Ha = carrier (G Mod H)›*)
fix A'
assume A'normal: "A' ⊲ G Mod H" and A'nottriv: "A' ≠ {𝟭⇘G Mod H⇙}" (*‹(A'::'a set set) ⊲ G Mod (H::'a set)› ‹(A'::'a set set) ≠ {𝟭⇘G Mod (H::'a set)⇙}›*)
define A where "A = ⋃A'"
have A2: "A ⊲ G"
using A'normal (*‹(A'::'a set set) ⊲ G Mod (H::'a set)›*) unfolding A_def
(*goal: ‹⋃ A' ⊲ G›*)
by (rule factgroup_subgroup_union_normal (*‹?A ⊲ G Mod H ⟹ ⋃ ?A ⊲ G›*))
have "H ∈ A'"
using A'normal (*‹(A'::'a set set) ⊲ G Mod (H::'a set)›*) normal_imp_subgroup (*‹(?H::?'a::type set) ⊲ (?G::(?'a, ?'b) monoid_scheme) ⟹ subgroup ?H ?G›*) subgroup.one_closed (*‹subgroup ?H ?G ⟹ 𝟭⇘?G⇙ ∈ ?H›*) unfolding FactGroup_def
(*goal: ‹H ∈ A'›*)
by force
hence "H ⊆ A"
unfolding A_def
(*goal: ‹H ⊆ ⋃ A'›*)
by auto
hence A1: "H ⊲ (G⦇carrier := A⦈)"
by (simp add: A2 (*‹A ⊲ G›*) normal_axioms (*‹H ⊲ G›*) normal_invE( (*‹?N ⊲ G ⟹ subgroup ?N G›*) 1) normal_restrict_supergroup (*‹⟦subgroup ?S G; ?N ⊲ G; ?N ⊆ ?S⟧ ⟹ ?N ⊲ G⦇carrier := ?S⦈›*))
have A3: "A' = rcosets⇘G⦇carrier := A⦈⇙ H"
unfolding A_def
(*goal: ‹A' = rcosets⇘G⦇carrier := ⋃ A'⦈⇙ H›*)
using factgroup_subgroup_union_factor (*‹subgroup ?A (G Mod H) ⟹ ?A = rcosets⇘G⦇carrier := ⋃ ?A⦈⇙ H›*) A'normal (*‹A' ⊲ G Mod H›*) normal_imp_subgroup (*‹?H ⊲ ?G ⟹ subgroup ?H ?G›*) by auto
from A1 (*‹H ⊲ G⦇carrier := A⦈›*) interpret normalHA: normal H "(G⦇carrier := A⦈)"
by metis
have "H ⊆ A"
using normalHA.is_subgroup (*‹subgroup (H::'a set) (G⦇carrier := A::'a set⦈)›*) subgroup.subset (*‹subgroup ?H ?G ⟹ ?H ⊆ carrier ?G›*) by force
with A2 (*‹(A::'a set) ⊲ G›*) have "A = H ∨ A = carrier G"
using maxH.max_normal (*‹⟦?J ⊲ G; ?J ≠ H; ?J ≠ carrier G⟧ ⟹ ¬ H ⊆ ?J›*) by auto
thus "A' = carrier (G Mod H)"
proof (standard)
(*goals:
1. ‹A = H ⟹ A' = carrier (G Mod H)›
2. ‹A = carrier G ⟹ A' = carrier (G Mod H)›*)
assume "A = H" (*‹(A::'a set) = (H::'a set)›*)
hence "carrier (G⦇carrier := A⦈ Mod H) = {𝟭⇘(G⦇carrier := A⦈ Mod H)⇙}"
using cosets_finite (*‹⟦?c ∈ rcosets ?H; ?H ⊆ carrier G; finite (carrier G)⟧ ⟹ finite ?c›*) subgroup_in_rcosets (*‹Group.group G ⟹ (H::'a set) ∈ rcosets H›*) subset (*‹(H::'a set) ⊆ carrier G›*) assms (*‹finite (carrier G)›*) normalHA.fact_group_trivial_iff (*‹finite (carrier (G⦇carrier := A⦈)) ⟹ (carrier (G⦇carrier := A⦈ Mod H) = {𝟭⇘G⦇carrier := A⦈ Mod H⇙}) = (H = carrier (G⦇carrier := A⦈))›*) by force
then have "A' = {𝟭⇘G Mod H⇙}"
using A3 (*‹(A'::'a::type set set) = rcosets⇘G⦇carrier := A::'a::type set⦈⇙ (H::'a::type set)›*) unfolding FactGroup_def
(*goal: ‹(A'::'a set set) = {𝟭⇘⦇carrier = rcosets (H::'a set), monoid.mult = (<#>), one = H⦈⇙}›*)
by simp
with A'nottriv (*‹A' ≠ {𝟭⇘G Mod H⇙}›*) show "?thesis"
(*goal: ‹A' = carrier (G Mod H)›*)
by standard
next
(*goal: ‹A = carrier G ⟹ A' = carrier (G Mod H)›*)
assume "A = carrier G" (*‹(A::'a set) = carrier G›*)
thus "A' = carrier (G Mod H)"
using A3 (*‹A' = rcosets⇘G⦇carrier := A⦈⇙ H›*) unfolding FactGroup_def
(*goal: ‹(A'::'a set set) = carrier ⦇carrier = rcosets (H::'a set), monoid.mult = (<#>), one = H⦈›*)
by simp
qed
qed
next
(*goal: ‹simple_group (G Mod (H::'a set)) ⟹ max_normal_subgroup H G›*)
assume simple: "simple_group (G Mod H)" (*‹simple_group (G Mod (H::'a set))›*)
show "max_normal_subgroup H G"
proof (standard)
(*goals:
1. ‹H ≠ carrier G›
2. ‹⋀J. ⟦J ⊲ G; J ≠ H; J ≠ carrier G⟧ ⟹ ¬ H ⊆ J›*)
from simple (*‹simple_group (G Mod H)›*) have "carrier (G Mod H) ≠ {𝟭⇘G Mod H⇙}"
unfolding simple_group_def simple_group_axioms_def order_def
(*goal: ‹carrier (G Mod H) ≠ {𝟭⇘G Mod H⇙}›*)
by auto
with finite (*‹finite (carrier G)›*) fact_group_trivial_iff (*‹finite (carrier G) ⟹ (carrier (G Mod H) = {𝟭⇘G Mod H⇙}) = (H = carrier G)›*) show "H ≠ carrier G"
by auto
next
(*goal: ‹⋀J. ⟦J ⊲ G; J ≠ H; J ≠ carrier G⟧ ⟹ ¬ H ⊆ J›*)
fix A
assume A: "A ⊲ G" "A ≠ H" "A ≠ carrier G" (*‹(A::'a set) ⊲ G› ‹(A::'a set) ≠ (H::'a set)› ‹(A::'a set) ≠ carrier G›*)
show "¬ H ⊆ A"
proof (standard)
(*goal: ‹H ⊆ A ⟹ False›*)
assume HA: "H ⊆ A" (*‹(H::'a set) ⊆ (A::'a set)›*)
hence "H ⊲ (G⦇carrier := A⦈)"
by (metis A( (*‹A ⊲ G›*) 1) inv_op_closed2 (*‹⟦?x ∈ carrier G; ?h ∈ H⟧ ⟹ ?x ⊗ ?h ⊗ inv ?x ∈ H›*) is_subgroup (*‹subgroup H G›*) normal_inv_iff (*‹?N ⊲ G = (subgroup ?N G ∧ (∀x∈carrier G. ∀h∈?N. x ⊗ h ⊗ inv x ∈ ?N))›*) normal_restrict_supergroup (*‹⟦subgroup ?S G; ?N ⊲ G; ?N ⊆ ?S⟧ ⟹ ?N ⊲ G⦇carrier := ?S⦈›*))
then interpret normalHA: normal H "(G⦇carrier := A⦈)"
by simp
from finite (*‹finite (carrier G)›*) have finiteA: "finite A"
by (meson A( (*‹A ⊲ G›*) 1) normal_inv_iff (*‹?N ⊲ G = (subgroup ?N G ∧ (∀x∈carrier G. ∀h∈?N. x ⊗ h ⊗ inv x ∈ ?N))›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) subgroup.subset (*‹subgroup ?H ?G ⟹ ?H ⊆ carrier ?G›*))
have "rcosets⇘(G⦇carrier := A⦈)⇙ H ⊲ G Mod H"
by (simp add: A( (*‹A ⊲ G›*) 1) HA (*‹H ⊆ A›*) normal_axioms (*‹H ⊲ G›*) normality_factorization (*‹⟦?N ⊲ G; ?N ⊆ ?H; ?H ⊲ G⟧ ⟹ rcosets⇘G⦇carrier := ?H⦈⇙ ?N ⊲ G Mod ?N›*))
with simple (*‹simple_group (G Mod H)›*) have "rcosets⇘(G⦇carrier := A⦈)⇙ H = {𝟭⇘G Mod H⇙} ∨ rcosets⇘(G⦇carrier := A⦈)⇙ H = carrier (G Mod H)"
unfolding simple_group_def simple_group_axioms_def
(*goal: ‹rcosets⇘G⦇carrier := A::'a set⦈⇙ (H::'a set) = {𝟭⇘G Mod H⇙} ∨ rcosets⇘G⦇carrier := A⦈⇙ H = carrier (G Mod H)›*)
by auto
thus False
proof (standard)
(*goals:
1. ‹rcosets⇘G⦇carrier := A⦈⇙ H = {𝟭⇘G Mod H⇙} ⟹ False›
2. ‹rcosets⇘G⦇carrier := A⦈⇙ H = carrier (G Mod H) ⟹ False›*)
assume "rcosets⇘G⦇carrier := A⦈⇙ H = {𝟭⇘G Mod H⇙}" (*‹rcosets⇘G⦇carrier := A::'a set⦈⇙ (H::'a set) = {𝟭⇘G Mod H⇙}›*)
with finiteA (*‹finite A›*) have "H = A"
using normalHA.fact_group_trivial_iff (*‹finite (carrier (G⦇carrier := A⦈)) ⟹ (carrier (G⦇carrier := A⦈ Mod H) = {𝟭⇘G⦇carrier := A⦈ Mod H⇙}) = (H = carrier (G⦇carrier := A⦈))›*) unfolding FactGroup_def
(*goal: ‹(H::'a set) = (A::'a set)›*)
by auto
with A(2) (*‹A ≠ H›*) show "?thesis"
(*goal: ‹False›*)
by simp
next
(*goal: ‹rcosets⇘G⦇carrier := A⦈⇙ H = carrier (G Mod H) ⟹ False›*)
assume AHGH: "rcosets⇘G⦇carrier := A⦈⇙ H = carrier (G Mod H)" (*‹rcosets⇘G⦇carrier := A::'a set⦈⇙ (H::'a set) = carrier (G Mod H)›*)
have "A = carrier G"
unfolding FactGroup_def RCOSETS_def
(*goal: ‹A = carrier G›*)
proof (standard)
(*goals:
1. ‹A ⊆ carrier G›
2. ‹carrier G ⊆ A›*)
show "A ⊆ carrier G"
using A(1) (*‹(A::'a set) ⊲ G›*) normal_imp_subgroup (*‹?H ⊲ ?G ⟹ subgroup ?H ?G›*) subgroup.subset (*‹subgroup ?H ?G ⟹ ?H ⊆ carrier ?G›*) by metis
next
(*goal: ‹carrier G ⊆ A›*)
show "carrier G ⊆ A"
proof (standard)
(*goal: ‹⋀x. x ∈ carrier G ⟹ x ∈ A›*)
fix x
assume x: "x ∈ carrier G" (*‹(x::'a) ∈ carrier G›*)
hence "H #> x ∈ rcosets H"
unfolding RCOSETS_def
(*goal: ‹H #> x ∈ (⋃a∈carrier G. {H #> a})›*)
by auto
with AHGH (*‹rcosets⇘G⦇carrier := A⦈⇙ H = carrier (G Mod H)›*) have "H #> x ∈ rcosets⇘G⦇carrier := A⦈⇙ H"
unfolding FactGroup_def
(*goal: ‹H #> x ∈ rcosets⇘G⦇carrier := A⦈⇙ H›*)
by simp
then obtain x' where x': "x' ∈ A" "H #>x = H #>⇘G⦇carrier := A⦈⇙ x'"
(*goal: ‹(⋀x'. ⟦x' ∈ A; H #> x = H #>⇘G⦇carrier := A⦈⇙ x'⟧ ⟹ thesis) ⟹ thesis›*)
unfolding RCOSETS_def
(*goal: ‹(⋀x'::'a. ⟦x' ∈ (A::'a set); (H::'a set) #> (x::'a) = H #>⇘G⦇carrier := A⦈⇙ x'⟧ ⟹ thesis::bool) ⟹ thesis›*)
by auto
hence "H #> x = H #> x'"
unfolding r_coset_def
(*goal: ‹(⋃h∈H. {h ⊗ x}) = (⋃h∈H. {h ⊗ x'})›*)
by auto
hence "x ∈ H #> x'"
by (metis is_subgroup (*‹subgroup H G›*) rcos_self (*‹⟦?x ∈ carrier G; subgroup ?H G⟧ ⟹ ?x ∈ ?H #> ?x›*) x (*‹x ∈ carrier G›*))
hence "x ∈ A #> x'"
using HA (*‹H ⊆ A›*) unfolding r_coset_def
(*goal: ‹x ∈ (⋃h∈A. {h ⊗ x'})›*)
by auto
thus "x ∈ A"
using x'(1) (*‹x' ∈ A›*) unfolding r_coset_def
(*goal: ‹x ∈ A›*)
using subgroup.m_closed (*‹⟦subgroup ?H ?G; ?x ∈ ?H; ?y ∈ ?H⟧ ⟹ ?x ⊗⇘?G⇙ ?y ∈ ?H›*) A(1) (*‹A ⊲ G›*) normal_imp_subgroup (*‹?H ⊲ ?G ⟹ subgroup ?H ?G›*) by force
qed
qed
with A(3) (*‹A ≠ carrier G›*) show "?thesis"
(*goal: ‹False›*)
by simp
qed
qed
qed
qed
end
| {
"path": "afp-2025-02-12/thys/Jordan_Hoelder/MaximalNormalSubgroups.thy",
"repo": "afp-2025-02-12",
"sha": "bd293331c18b54ddbe4d03192ff6ba3dcde4346905f9bf30211cc1d39c606117"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.