text
stringlengths 0
3.34M
|
---|
#!/bin/python
from collections import deque
import numpy as np
import torch
def mini_batch_train(env, agent, max_episodes, max_steps, batch_size, eps_start=1.0, eps_end=0.1, eps_decay=0.995):
episode_rewards = []
rewards_mean = [] # list the mean of the window scores
rewards_window = deque(maxlen=100)
eps = eps_start
for episode in range(max_episodes):
state = env.reset()
episode_reward = 0
for step in range(max_steps):
action = agent.act(state, eps)
next_state, reward, done, _ = env.step(action)
agent.step(state, action, reward, next_state, done)
episode_reward += reward
state = next_state
if done:
break
episode_rewards.append(episode_reward)
rewards_window.append(episode_reward)
average_score = np.mean(rewards_window)
rewards_mean.append(average_score)
eps = max(eps_end, eps*eps_decay)
print('\rEpisode {}\tAverage Score: {:.2f}\teps: {:.4f}\tLR: {}'
.format(episode, average_score, eps, agent.lr_scheduler.get_lr()), end="")
if episode % 100 == 0:
print('\rEpisode {}\tAverage Score: {:.2f}\teps: {:.4f}\tLR: {}'
.format(episode, average_score, eps, agent.lr_scheduler.get_lr()))
if average_score >= 13: # check if environment is solved
print('\nEnvironment solved in {: d} episodes!\tAverage Score: {: .2f}'.format(episode - 100, average_score))
torch.save(agent.qnetwork_local.state_dict(), '{}.pth'.format(agent.name))
break
return episode_rewards, rewards_mean
|
\documentclass[IN,11pt,twoside,openright,english]{article}
\begin{document}
\title{%
\Huge \textbf{Initial Report} \\
\vspace{1.5cm} \large \textbf{Peer-to-Peer Systems and Security} \\
\vspace{0.5cm} \textbf{Network Size Estimation} \vspace{1cm} }
\author{%
\large Group 37 \\
\large Dominik Winter \\
\large Stefan Armbruster}
\date{}
\maketitle
\newpage
\section{Group Structure}
\begin{itemize}
\item \textbf{Teamnumber:} 37
\item \textbf{Teammembers:} Dominik Winter, Stefan Armbruster
\item \textbf{Subproject:} Network Size Estimation
\end{itemize}
\section{Operating System and Programming Language}
As we both are familiar with Linux we will utilize Ubuntu as OS for our project. In addition, one of us is using MacOS on his laptop.
\newline
\newline
In addition we intend to choose Python 3.6 as programming language for this project, as it comes with many benefits for network related programs and has a lot of libraries that can help us in this specific field.
\section{Build System}
For build system, we will use \texttt{make}. With \texttt{make} we can automatically build executable programs and libraries from source code by reading files called \textit{Makefiles} which specify how to derive the target program.
\section{Quality Assurance}
A popular testing framework for Python programs is \texttt{PyUnit}. In addition, we will consider \texttt{PyTest} as testing framework for our project.
\section{Libraries}
As we cannot estimate required libraries for the project yet, we will update this section later during the project. However, libraries such as \texttt{pyp2p}, \texttt{pycrypto} and \texttt{twisted} might be helpful at a first glance.
\section{Licensing}
For licensing we choose the MIT license. As a permissive license, it puts only very limited restriction on reuse. It grants the freedom to modify and distribute the code as long as one includes the original copyright.
\section{Programming Experience}
Dominik has worked as a quality assurance engineer during his bachelor studies at the company \textit{genua gmbh} and is experienced in programming languages such as Ruby, Perl, Python and JavaScript. In addition, he wrote his bachelor thesis at the chair of Network Architectures and Services in the field of network function virtualization (NFV).\newline
\newline
Stefan has good or rather basic programming language skills in Java, Python, Matlab, JavaScript and Ocaml. He could gain fundamental experiences in the field of networks within the practical course Systemadministration and he was part of the network administration team of the student dormitory.
\section{Workload}
As both of us have basic coding experience in network related projects we will split the design and coding work equally. In addition, we will meet every week during different lectures, where we can manage project related tasks and futher steps.
\begin{itemize}
\item \textbf{Design/Logic:} Dominik (40\%), Stefan (60\%)
\item \textbf{Implementation} Dominik (50\%), Stefan (50\%)
\item \textbf{Documentation:} Dominik (70\%), Stefan (30\%)
\end{itemize}
\section{Issues}
No issues for the moment.
\end{document}
|
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
⊢ ContinuousWithinAt (toIcoMod hp a) (Ici x) x
[PROOFSTEP]
intro s h
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
h : s ∈ 𝓝 (toIcoMod hp a x)
⊢ s ∈ Filter.map (toIcoMod hp a) (𝓝[Ici x] x)
[PROOFSTEP]
rw [Filter.mem_map, mem_nhdsWithin_iff_exists_mem_nhds_inter]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
h : s ∈ 𝓝 (toIcoMod hp a x)
⊢ ∃ u, u ∈ 𝓝 x ∧ u ∩ Ici x ⊆ toIcoMod hp a ⁻¹' s
[PROOFSTEP]
haveI : Nontrivial 𝕜 := ⟨⟨0, p, hp.ne⟩⟩
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
h : s ∈ 𝓝 (toIcoMod hp a x)
this : Nontrivial 𝕜
⊢ ∃ u, u ∈ 𝓝 x ∧ u ∩ Ici x ⊆ toIcoMod hp a ⁻¹' s
[PROOFSTEP]
simp_rw [mem_nhds_iff_exists_Ioo_subset] at h ⊢
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
h : ∃ l u, toIcoMod hp a x ∈ Ioo l u ∧ Ioo l u ⊆ s
⊢ ∃ u, (∃ l u_1, x ∈ Ioo l u_1 ∧ Ioo l u_1 ⊆ u) ∧ u ∩ Ici x ⊆ toIcoMod hp a ⁻¹' s
[PROOFSTEP]
obtain ⟨l, u, hxI, hIs⟩ := h
[GOAL]
case intro.intro.intro
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
l u : 𝕜
hxI : toIcoMod hp a x ∈ Ioo l u
hIs : Ioo l u ⊆ s
⊢ ∃ u, (∃ l u_1, x ∈ Ioo l u_1 ∧ Ioo l u_1 ⊆ u) ∧ u ∩ Ici x ⊆ toIcoMod hp a ⁻¹' s
[PROOFSTEP]
let d := toIcoDiv hp a x • p
[GOAL]
case intro.intro.intro
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
l u : 𝕜
hxI : toIcoMod hp a x ∈ Ioo l u
hIs : Ioo l u ⊆ s
d : 𝕜 := toIcoDiv hp a x • p
⊢ ∃ u, (∃ l u_1, x ∈ Ioo l u_1 ∧ Ioo l u_1 ⊆ u) ∧ u ∩ Ici x ⊆ toIcoMod hp a ⁻¹' s
[PROOFSTEP]
have hd := toIcoMod_mem_Ico hp a x
[GOAL]
case intro.intro.intro
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
l u : 𝕜
hxI : toIcoMod hp a x ∈ Ioo l u
hIs : Ioo l u ⊆ s
d : 𝕜 := toIcoDiv hp a x • p
hd : toIcoMod hp a x ∈ Ico a (a + p)
⊢ ∃ u, (∃ l u_1, x ∈ Ioo l u_1 ∧ Ioo l u_1 ⊆ u) ∧ u ∩ Ici x ⊆ toIcoMod hp a ⁻¹' s
[PROOFSTEP]
simp_rw [subset_def, mem_inter_iff]
[GOAL]
case intro.intro.intro
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
l u : 𝕜
hxI : toIcoMod hp a x ∈ Ioo l u
hIs : Ioo l u ⊆ s
d : 𝕜 := toIcoDiv hp a x • p
hd : toIcoMod hp a x ∈ Ico a (a + p)
⊢ ∃ u,
(∃ l u_1, x ∈ Ioo l u_1 ∧ ∀ (x : 𝕜), x ∈ Ioo l u_1 → x ∈ u) ∧
∀ (x_1 : 𝕜), x_1 ∈ u ∧ x_1 ∈ Ici x → x_1 ∈ toIcoMod hp a ⁻¹' s
[PROOFSTEP]
refine' ⟨_, ⟨l + d, min (a + p) u + d, _, fun x => id⟩, fun y => _⟩
[GOAL]
case intro.intro.intro.refine'_1
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
l u : 𝕜
hxI : toIcoMod hp a x ∈ Ioo l u
hIs : Ioo l u ⊆ s
d : 𝕜 := toIcoDiv hp a x • p
hd : toIcoMod hp a x ∈ Ico a (a + p)
⊢ x ∈ Ioo (l + d) (min (a + p) u + d)
[PROOFSTEP]
simp_rw [← sub_mem_Ioo_iff_left, mem_Ioo, lt_min_iff]
[GOAL]
case intro.intro.intro.refine'_2
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
l u : 𝕜
hxI : toIcoMod hp a x ∈ Ioo l u
hIs : Ioo l u ⊆ s
d : 𝕜 := toIcoDiv hp a x • p
hd : toIcoMod hp a x ∈ Ico a (a + p)
y : 𝕜
⊢ y ∈ Ioo (l + d) (min (a + p) u + d) ∧ y ∈ Ici x → y ∈ toIcoMod hp a ⁻¹' s
[PROOFSTEP]
simp_rw [← sub_mem_Ioo_iff_left, mem_Ioo, lt_min_iff]
[GOAL]
case intro.intro.intro.refine'_1
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
l u : 𝕜
hxI : toIcoMod hp a x ∈ Ioo l u
hIs : Ioo l u ⊆ s
d : 𝕜 := toIcoDiv hp a x • p
hd : toIcoMod hp a x ∈ Ico a (a + p)
⊢ l < x - toIcoDiv hp a x • p ∧ x - toIcoDiv hp a x • p < a + p ∧ x - toIcoDiv hp a x • p < u
[PROOFSTEP]
exact ⟨hxI.1, hd.2, hxI.2⟩
[GOAL]
case intro.intro.intro.refine'_2
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
l u : 𝕜
hxI : toIcoMod hp a x ∈ Ioo l u
hIs : Ioo l u ⊆ s
d : 𝕜 := toIcoDiv hp a x • p
hd : toIcoMod hp a x ∈ Ico a (a + p)
y : 𝕜
⊢ (l < y - toIcoDiv hp a x • p ∧ y - toIcoDiv hp a x • p < a + p ∧ y - toIcoDiv hp a x • p < u) ∧ y ∈ Ici x →
y ∈ toIcoMod hp a ⁻¹' s
[PROOFSTEP]
rintro ⟨h, h'⟩
[GOAL]
case intro.intro.intro.refine'_2.intro
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
l u : 𝕜
hxI : toIcoMod hp a x ∈ Ioo l u
hIs : Ioo l u ⊆ s
d : 𝕜 := toIcoDiv hp a x • p
hd : toIcoMod hp a x ∈ Ico a (a + p)
y : 𝕜
h : l < y - toIcoDiv hp a x • p ∧ y - toIcoDiv hp a x • p < a + p ∧ y - toIcoDiv hp a x • p < u
h' : y ∈ Ici x
⊢ y ∈ toIcoMod hp a ⁻¹' s
[PROOFSTEP]
apply hIs
[GOAL]
case intro.intro.intro.refine'_2.intro.a
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
l u : 𝕜
hxI : toIcoMod hp a x ∈ Ioo l u
hIs : Ioo l u ⊆ s
d : 𝕜 := toIcoDiv hp a x • p
hd : toIcoMod hp a x ∈ Ico a (a + p)
y : 𝕜
h : l < y - toIcoDiv hp a x • p ∧ y - toIcoDiv hp a x • p < a + p ∧ y - toIcoDiv hp a x • p < u
h' : y ∈ Ici x
⊢ toIcoMod hp a y ∈ Ioo l u
[PROOFSTEP]
rw [← toIcoMod_sub_zsmul, (toIcoMod_eq_self _).2]
[GOAL]
case intro.intro.intro.refine'_2.intro.a
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
l u : 𝕜
hxI : toIcoMod hp a x ∈ Ioo l u
hIs : Ioo l u ⊆ s
d : 𝕜 := toIcoDiv hp a x • p
hd : toIcoMod hp a x ∈ Ico a (a + p)
y : 𝕜
h : l < y - toIcoDiv hp a x • p ∧ y - toIcoDiv hp a x • p < a + p ∧ y - toIcoDiv hp a x • p < u
h' : y ∈ Ici x
⊢ y - ?intro.intro.intro.refine'_2.intro.a.m • p ∈ Ioo l u
case intro.intro.intro.refine'_2.intro.a
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
l u : 𝕜
hxI : toIcoMod hp a x ∈ Ioo l u
hIs : Ioo l u ⊆ s
d : 𝕜 := toIcoDiv hp a x • p
hd : toIcoMod hp a x ∈ Ico a (a + p)
y : 𝕜
h : l < y - toIcoDiv hp a x • p ∧ y - toIcoDiv hp a x • p < a + p ∧ y - toIcoDiv hp a x • p < u
h' : y ∈ Ici x
⊢ y - ?intro.intro.intro.refine'_2.intro.a.m • p ∈ Ico a (a + p)
case intro.intro.intro.refine'_2.intro.a.m
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
l u : 𝕜
hxI : toIcoMod hp a x ∈ Ioo l u
hIs : Ioo l u ⊆ s
d : 𝕜 := toIcoDiv hp a x • p
hd : toIcoMod hp a x ∈ Ico a (a + p)
y : 𝕜
h : l < y - toIcoDiv hp a x • p ∧ y - toIcoDiv hp a x • p < a + p ∧ y - toIcoDiv hp a x • p < u
h' : y ∈ Ici x
⊢ ℤ
case intro.intro.intro.refine'_2.intro.a.m
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
this : Nontrivial 𝕜
l u : 𝕜
hxI : toIcoMod hp a x ∈ Ioo l u
hIs : Ioo l u ⊆ s
d : 𝕜 := toIcoDiv hp a x • p
hd : toIcoMod hp a x ∈ Ico a (a + p)
y : 𝕜
h : l < y - toIcoDiv hp a x • p ∧ y - toIcoDiv hp a x • p < a + p ∧ y - toIcoDiv hp a x • p < u
h' : y ∈ Ici x
⊢ ℤ
[PROOFSTEP]
exacts [⟨h.1, h.2.2⟩, ⟨hd.1.trans (sub_le_sub_right h' _), h.2.1⟩]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
⊢ ContinuousWithinAt (toIocMod hp a) (Iic x) x
[PROOFSTEP]
rw [(funext fun y => Eq.trans (by rw [neg_neg]) <| toIocMod_neg _ _ _ :
toIocMod hp a = (fun x => p - x) ∘ toIcoMod hp (-a) ∘ Neg.neg)]
-- Porting note: added
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x y : 𝕜
⊢ toIocMod hp a y = toIocMod hp a (- -y)
[PROOFSTEP]
rw [neg_neg]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
⊢ ContinuousWithinAt ((fun x => p - x) ∘ toIcoMod hp (-a) ∘ Neg.neg) (Iic x) x
[PROOFSTEP]
have : ContinuousNeg 𝕜 := TopologicalAddGroup.toContinuousNeg
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
this : ContinuousNeg 𝕜
⊢ ContinuousWithinAt ((fun x => p - x) ∘ toIcoMod hp (-a) ∘ Neg.neg) (Iic x) x
[PROOFSTEP]
exact
(continuous_sub_left _).continuousAt.comp_continuousWithinAt <|
(continuous_right_toIcoMod _ _ _).comp continuous_neg.continuousWithinAt fun y => neg_le_neg
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
hx : ↑x ≠ ↑a
⊢ IsOpen {x | (fun x => toIcoMod hp a x = toIocMod hp a x) x}
[PROOFSTEP]
rw [Ico_eq_locus_Ioc_eq_iUnion_Ioo]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
hx : ↑x ≠ ↑a
⊢ IsOpen (⋃ (z : ℤ), Ioo (a + z • p) (a + p + z • p))
[PROOFSTEP]
exact isOpen_iUnion fun i => isOpen_Ioo
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedAddCommGroup 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p x : 𝕜
⊢ ↑x = 0 ↔ ∃ n, n • p = x
[PROOFSTEP]
simp [AddSubgroup.mem_zmultiples_iff]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedAddCommGroup 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
x : 𝕜
hx : 0 < x
⊢ ↑x = 0 ↔ ∃ n, n • p = x
[PROOFSTEP]
rw [coe_eq_zero_iff]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedAddCommGroup 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
x : 𝕜
hx : 0 < x
⊢ (∃ n, n • p = x) ↔ ∃ n, n • p = x
[PROOFSTEP]
constructor
[GOAL]
case mp
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedAddCommGroup 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
x : 𝕜
hx : 0 < x
⊢ (∃ n, n • p = x) → ∃ n, n • p = x
[PROOFSTEP]
rintro ⟨n, rfl⟩
[GOAL]
case mpr
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedAddCommGroup 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
x : 𝕜
hx : 0 < x
⊢ (∃ n, n • p = x) → ∃ n, n • p = x
[PROOFSTEP]
rintro ⟨n, rfl⟩
[GOAL]
case mp.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedAddCommGroup 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
n : ℤ
hx : 0 < n • p
⊢ ∃ n_1, n_1 • p = n • p
[PROOFSTEP]
replace hx : 0 < n
[GOAL]
case hx
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedAddCommGroup 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
n : ℤ
hx : 0 < n • p
⊢ 0 < n
[PROOFSTEP]
contrapose! hx
[GOAL]
case hx
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedAddCommGroup 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
n : ℤ
hx : n ≤ 0
⊢ n • p ≤ 0
[PROOFSTEP]
simpa only [← neg_nonneg, ← zsmul_neg, zsmul_neg'] using zsmul_nonneg hp.le (neg_nonneg.2 hx)
[GOAL]
case mp.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedAddCommGroup 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
n : ℤ
hx : 0 < n
⊢ ∃ n_1, n_1 • p = n • p
[PROOFSTEP]
exact ⟨n.toNat, by rw [← coe_nat_zsmul, Int.toNat_of_nonneg hx.le]⟩
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedAddCommGroup 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
n : ℤ
hx : 0 < n
⊢ Int.toNat n • p = n • p
[PROOFSTEP]
rw [← coe_nat_zsmul, Int.toNat_of_nonneg hx.le]
[GOAL]
case mpr.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedAddCommGroup 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
n : ℕ
hx : 0 < n • p
⊢ ∃ n_1, n_1 • p = n • p
[PROOFSTEP]
exact ⟨(n : ℤ), by simp⟩
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedAddCommGroup 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
n : ℕ
hx : 0 < n • p
⊢ ↑n • p = n • p
[PROOFSTEP]
simp
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedAddCommGroup 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p x : 𝕜
⊢ ↑(x + p) = ↑x
[PROOFSTEP]
rw [coe_add, ← eq_sub_iff_add_eq', sub_self, coe_period]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
x y : 𝕜
hx : x ∈ Ico a (a + p)
hy : y ∈ Ico a (a + p)
⊢ ↑x = ↑y ↔ x = y
[PROOFSTEP]
refine' ⟨fun h => _, by tauto⟩
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
x y : 𝕜
hx : x ∈ Ico a (a + p)
hy : y ∈ Ico a (a + p)
⊢ x = y → ↑x = ↑y
[PROOFSTEP]
tauto
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
x y : 𝕜
hx : x ∈ Ico a (a + p)
hy : y ∈ Ico a (a + p)
h : ↑x = ↑y
⊢ x = y
[PROOFSTEP]
suffices (⟨x, hx⟩ : Ico a (a + p)) = ⟨y, hy⟩ by exact Subtype.mk.inj this
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
x y : 𝕜
hx : x ∈ Ico a (a + p)
hy : y ∈ Ico a (a + p)
h : ↑x = ↑y
this : { val := x, property := hx } = { val := y, property := hy }
⊢ x = y
[PROOFSTEP]
exact Subtype.mk.inj this
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
x y : 𝕜
hx : x ∈ Ico a (a + p)
hy : y ∈ Ico a (a + p)
h : ↑x = ↑y
⊢ { val := x, property := hx } = { val := y, property := hy }
[PROOFSTEP]
apply_fun equivIco p a at h
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
x y : 𝕜
hx : x ∈ Ico a (a + p)
hy : y ∈ Ico a (a + p)
h : ↑(equivIco p a) ↑x = ↑(equivIco p a) ↑y
⊢ { val := x, property := hx } = { val := y, property := hy }
[PROOFSTEP]
rw [← (equivIco p a).right_inv ⟨x, hx⟩, ← (equivIco p a).right_inv ⟨y, hy⟩]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
x y : 𝕜
hx : x ∈ Ico a (a + p)
hy : y ∈ Ico a (a + p)
h : ↑(equivIco p a) ↑x = ↑(equivIco p a) ↑y
⊢ Equiv.toFun (equivIco p a) (Equiv.invFun (equivIco p a) { val := x, property := hx }) =
Equiv.toFun (equivIco p a) (Equiv.invFun (equivIco p a) { val := y, property := hy })
[PROOFSTEP]
exact h
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
f : 𝕜 → B
x : 𝕜
hx : x ∈ Ico a (a + p)
⊢ liftIco p a f ↑x = f x
[PROOFSTEP]
have : (equivIco p a) x = ⟨x, hx⟩ := by
rw [Equiv.apply_eq_iff_eq_symm_apply]
rfl
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
f : 𝕜 → B
x : 𝕜
hx : x ∈ Ico a (a + p)
⊢ ↑(equivIco p a) ↑x = { val := x, property := hx }
[PROOFSTEP]
rw [Equiv.apply_eq_iff_eq_symm_apply]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
f : 𝕜 → B
x : 𝕜
hx : x ∈ Ico a (a + p)
⊢ ↑x = ↑(equivIco p a).symm { val := x, property := hx }
[PROOFSTEP]
rfl
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
f : 𝕜 → B
x : 𝕜
hx : x ∈ Ico a (a + p)
this : ↑(equivIco p a) ↑x = { val := x, property := hx }
⊢ liftIco p a f ↑x = f x
[PROOFSTEP]
rw [liftIco, comp_apply, this]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
f : 𝕜 → B
x : 𝕜
hx : x ∈ Ico a (a + p)
this : ↑(equivIco p a) ↑x = { val := x, property := hx }
⊢ restrict (Ico a (a + p)) f { val := x, property := hx } = f x
[PROOFSTEP]
rfl
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
f : 𝕜 → B
x : 𝕜
hx : x ∈ Ioc a (a + p)
⊢ liftIoc p a f ↑x = f x
[PROOFSTEP]
have : (equivIoc p a) x = ⟨x, hx⟩ := by
rw [Equiv.apply_eq_iff_eq_symm_apply]
rfl
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
f : 𝕜 → B
x : 𝕜
hx : x ∈ Ioc a (a + p)
⊢ ↑(equivIoc p a) ↑x = { val := x, property := hx }
[PROOFSTEP]
rw [Equiv.apply_eq_iff_eq_symm_apply]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
f : 𝕜 → B
x : 𝕜
hx : x ∈ Ioc a (a + p)
⊢ ↑x = ↑(equivIoc p a).symm { val := x, property := hx }
[PROOFSTEP]
rfl
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
f : 𝕜 → B
x : 𝕜
hx : x ∈ Ioc a (a + p)
this : ↑(equivIoc p a) ↑x = { val := x, property := hx }
⊢ liftIoc p a f ↑x = f x
[PROOFSTEP]
rw [liftIoc, comp_apply, this]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
f : 𝕜 → B
x : 𝕜
hx : x ∈ Ioc a (a + p)
this : ↑(equivIoc p a) ↑x = { val := x, property := hx }
⊢ restrict (Ioc a (a + p)) f { val := x, property := hx } = f x
[PROOFSTEP]
rfl
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
x : AddCircle p
hx : x ≠ ↑a
⊢ ContinuousAt (↑(equivIco p a)) x
[PROOFSTEP]
induction x using QuotientAddGroup.induction_on'
[GOAL]
case H
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
x : AddCircle p
z✝ : 𝕜
hx : ↑z✝ ≠ ↑a
⊢ ContinuousAt ↑(equivIco p a) ↑z✝
[PROOFSTEP]
rw [ContinuousAt, Filter.Tendsto, QuotientAddGroup.nhds_eq, Filter.map_map]
[GOAL]
case H
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
x : AddCircle p
z✝ : 𝕜
hx : ↑z✝ ≠ ↑a
⊢ Filter.map (↑(equivIco p a) ∘ QuotientAddGroup.mk) (𝓝 z✝) ≤ 𝓝 (↑(equivIco p a) ↑z✝)
[PROOFSTEP]
exact (continuousAt_toIcoMod hp.out a hx).codRestrict _
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
x : AddCircle p
hx : x ≠ ↑a
⊢ ContinuousAt (↑(equivIoc p a)) x
[PROOFSTEP]
induction x using QuotientAddGroup.induction_on'
[GOAL]
case H
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
x : AddCircle p
z✝ : 𝕜
hx : ↑z✝ ≠ ↑a
⊢ ContinuousAt ↑(equivIoc p a) ↑z✝
[PROOFSTEP]
rw [ContinuousAt, Filter.Tendsto, QuotientAddGroup.nhds_eq, Filter.map_map]
[GOAL]
case H
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
x : AddCircle p
z✝ : 𝕜
hx : ↑z✝ ≠ ↑a
⊢ Filter.map (↑(equivIoc p a) ∘ QuotientAddGroup.mk) (𝓝 z✝) ≤ 𝓝 (↑(equivIoc p a) ↑z✝)
[PROOFSTEP]
exact (continuousAt_toIocMod hp.out a hx).codRestrict _
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
⊢ QuotientAddGroup.mk '' Ico a (a + p) = univ
[PROOFSTEP]
rw [image_eq_range]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
⊢ (range fun x => ↑↑x) = univ
[PROOFSTEP]
exact (equivIco p a).symm.range_eq_univ
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
⊢ QuotientAddGroup.mk '' Ioc a (a + p) = univ
[PROOFSTEP]
rw [image_eq_range]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p : 𝕜
hp : Fact (0 < p)
a : 𝕜
inst✝ : Archimedean 𝕜
⊢ (range fun x => ↑↑x) = univ
[PROOFSTEP]
exact (equivIoc p a).symm.range_eq_univ
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : p ≠ 0
hq : q ≠ 0
⊢ map (↑(AddAut.mulRight ((Units.mk0 p hp)⁻¹ * Units.mk0 q hq))) (zmultiples p) = zmultiples q
[PROOFSTEP]
rw [AddMonoidHom.map_zmultiples, AddMonoidHom.coe_coe, AddAut.mulRight_apply, Units.val_mul, Units.val_mk0,
Units.val_inv_eq_inv_val, Units.val_mk0, mul_inv_cancel_left₀ hp]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedField 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
inst✝ : FloorRing 𝕜
x : AddCircle p
⊢ (fun x n => ↑((↑n)⁻¹ * ↑(↑(equivIco p 0) x))) x 0 = 0
[PROOFSTEP]
simp only [algebraMap.coe_zero, Int.cast_zero, inv_zero, zero_mul, QuotientAddGroup.mk_zero]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedField 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
inst✝ : FloorRing 𝕜
n : ℤ
x : AddCircle p
hn : n ≠ 0
⊢ n • (fun x n => ↑((↑n)⁻¹ * ↑(↑(equivIco p 0) x))) x n = x
[PROOFSTEP]
replace hn : (n : 𝕜) ≠ 0
[GOAL]
case hn
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedField 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
inst✝ : FloorRing 𝕜
n : ℤ
x : AddCircle p
hn : n ≠ 0
⊢ ↑n ≠ 0
[PROOFSTEP]
norm_cast
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedField 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
inst✝ : FloorRing 𝕜
n : ℤ
x : AddCircle p
hn : ↑n ≠ 0
⊢ n • (fun x n => ↑((↑n)⁻¹ * ↑(↑(equivIco p 0) x))) x n = x
[PROOFSTEP]
change n • QuotientAddGroup.mk' _ ((n : 𝕜)⁻¹ * ↑(equivIco p 0 x)) = x
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedField 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
inst✝ : FloorRing 𝕜
n : ℤ
x : AddCircle p
hn : ↑n ≠ 0
⊢ n • ↑(QuotientAddGroup.mk' (zmultiples p)) ((↑n)⁻¹ * ↑(↑(equivIco p 0) x)) = x
[PROOFSTEP]
rw [← map_zsmul, ← smul_mul_assoc, zsmul_eq_mul, mul_inv_cancel hn, one_mul]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedField 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
inst✝ : FloorRing 𝕜
n : ℤ
x : AddCircle p
hn : ↑n ≠ 0
⊢ ↑(QuotientAddGroup.mk' (zmultiples p)) ↑(↑(equivIco p 0) x) = x
[PROOFSTEP]
exact (equivIco p 0).symm_apply_apply x
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
h : 0 < n
⊢ addOrderOf ↑(p / ↑n) = n
[PROOFSTEP]
rw [addOrderOf_eq_iff h]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
h : 0 < n
⊢ n • ↑(p / ↑n) = 0 ∧ ∀ (m : ℕ), m < n → 0 < m → m • ↑(p / ↑n) ≠ 0
[PROOFSTEP]
replace h : 0 < (n : 𝕜) := Nat.cast_pos.2 h
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
h : 0 < ↑n
⊢ n • ↑(p / ↑n) = 0 ∧ ∀ (m : ℕ), m < n → 0 < m → m • ↑(p / ↑n) ≠ 0
[PROOFSTEP]
refine' ⟨_, fun m hn h0 => _⟩
[GOAL]
case refine'_1
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
h : 0 < ↑n
⊢ n • ↑(p / ↑n) = 0
[PROOFSTEP]
simp only [Ne, ← coe_nsmul, nsmul_eq_mul]
[GOAL]
case refine'_2
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
h : 0 < ↑n
m : ℕ
hn : m < n
h0 : 0 < m
⊢ m • ↑(p / ↑n) ≠ 0
[PROOFSTEP]
simp only [Ne, ← coe_nsmul, nsmul_eq_mul]
[GOAL]
case refine'_1
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
h : 0 < ↑n
⊢ ↑(↑n * (p / ↑n)) = 0
[PROOFSTEP]
rw [mul_div_cancel' _ h.ne', coe_period]
[GOAL]
case refine'_2
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
h : 0 < ↑n
m : ℕ
hn : m < n
h0 : 0 < m
⊢ ¬↑(↑m * (p / ↑n)) = 0
[PROOFSTEP]
rw [coe_eq_zero_of_pos_iff p hp.out (mul_pos (Nat.cast_pos.2 h0) <| div_pos hp.out h)]
[GOAL]
case refine'_2
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
h : 0 < ↑n
m : ℕ
hn : m < n
h0 : 0 < m
⊢ ¬∃ n_1, n_1 • p = ↑m * (p / ↑n)
[PROOFSTEP]
rintro ⟨k, hk⟩
[GOAL]
case refine'_2.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
h : 0 < ↑n
m : ℕ
hn : m < n
h0 : 0 < m
k : ℕ
hk : k • p = ↑m * (p / ↑n)
⊢ False
[PROOFSTEP]
rw [mul_div, eq_div_iff h.ne', nsmul_eq_mul, mul_right_comm, ← Nat.cast_mul, (mul_left_injective₀ hp.out.ne').eq_iff,
Nat.cast_inj, mul_comm] at hk
[GOAL]
case refine'_2.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
h : 0 < ↑n
m : ℕ
hn : m < n
h0 : 0 < m
k : ℕ
hk : n * k = m
⊢ False
[PROOFSTEP]
exact (Nat.le_of_dvd h0 ⟨_, hk.symm⟩).not_lt hn
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n m : ℕ
hn : 0 < n
⊢ Nat.gcd m n * addOrderOf ↑(↑m / ↑n * p) = n
[PROOFSTEP]
rw [mul_comm_div, ← nsmul_eq_mul, coe_nsmul, addOrderOf_nsmul'']
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n m : ℕ
hn : 0 < n
⊢ Nat.gcd m n * (addOrderOf ↑(p / ↑n) / Nat.gcd (addOrderOf ↑(p / ↑n)) m) = n
[PROOFSTEP]
rw [addOrderOf_period_div hn, Nat.gcd_comm, Nat.mul_div_cancel']
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n m : ℕ
hn : 0 < n
⊢ Nat.gcd n m ∣ n
[PROOFSTEP]
exact n.gcd_dvd_left m
[GOAL]
case h
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n m : ℕ
hn : 0 < n
⊢ IsOfFinAddOrder ↑(p / ↑n)
[PROOFSTEP]
rw [← addOrderOf_pos_iff, addOrderOf_period_div hn]
[GOAL]
case h
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n m : ℕ
hn : 0 < n
⊢ 0 < n
[PROOFSTEP]
exact hn
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
m n : ℕ
hn : 0 < n
h : Nat.gcd m n = 1
⊢ addOrderOf ↑(↑m / ↑n * p) = n
[PROOFSTEP]
convert gcd_mul_addOrderOf_div_eq p m hn
[GOAL]
case h.e'_2
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
m n : ℕ
hn : 0 < n
h : Nat.gcd m n = 1
⊢ addOrderOf ↑(↑m / ↑n * p) = Nat.gcd m n * addOrderOf ↑(↑m / ↑n * p)
[PROOFSTEP]
rw [h, one_mul]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
m : ℤ
n : ℕ
hn : 0 < n
h : Nat.gcd (Int.natAbs m) n = 1
⊢ addOrderOf ↑(↑m / ↑n * p) = n
[PROOFSTEP]
induction m
[GOAL]
case ofNat
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
a✝ : ℕ
h : Nat.gcd (Int.natAbs (Int.ofNat a✝)) n = 1
⊢ addOrderOf ↑(↑(Int.ofNat a✝) / ↑n * p) = n
[PROOFSTEP]
simp only [Int.ofNat_eq_coe, Int.cast_ofNat, Int.natAbs_ofNat] at h ⊢
[GOAL]
case ofNat
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
a✝ : ℕ
h : Nat.gcd a✝ n = 1
⊢ addOrderOf ↑(↑a✝ / ↑n * p) = n
[PROOFSTEP]
exact addOrderOf_div_of_gcd_eq_one hn h
[GOAL]
case negSucc
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
a✝ : ℕ
h : Nat.gcd (Int.natAbs (Int.negSucc a✝)) n = 1
⊢ addOrderOf ↑(↑(Int.negSucc a✝) / ↑n * p) = n
[PROOFSTEP]
simp only [Int.cast_negSucc, neg_div, neg_mul, coe_neg, addOrderOf_neg]
[GOAL]
case negSucc
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
a✝ : ℕ
h : Nat.gcd (Int.natAbs (Int.negSucc a✝)) n = 1
⊢ addOrderOf ↑(↑(a✝ + 1) / ↑n * p) = n
[PROOFSTEP]
exact addOrderOf_div_of_gcd_eq_one hn h
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q✝ : 𝕜
hp : Fact (0 < p)
q : ℚ
⊢ addOrderOf ↑(↑q * p) = q.den
[PROOFSTEP]
have : (↑(q.den : ℤ) : 𝕜) ≠ 0 := by
norm_cast
exact q.pos.ne.symm
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q✝ : 𝕜
hp : Fact (0 < p)
q : ℚ
⊢ ↑↑q.den ≠ 0
[PROOFSTEP]
norm_cast
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q✝ : 𝕜
hp : Fact (0 < p)
q : ℚ
⊢ ¬q.den = 0
[PROOFSTEP]
exact q.pos.ne.symm
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q✝ : 𝕜
hp : Fact (0 < p)
q : ℚ
this : ↑↑q.den ≠ 0
⊢ addOrderOf ↑(↑q * p) = q.den
[PROOFSTEP]
rw [← @Rat.num_den q, Rat.cast_mk_of_ne_zero _ _ this, Int.cast_ofNat, Rat.num_den,
addOrderOf_div_of_gcd_eq_one' q.pos q.reduced]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
⊢ addOrderOf u = n ↔ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = u
[PROOFSTEP]
refine' ⟨QuotientAddGroup.induction_on' u fun k hk => _, _⟩
[GOAL]
case refine'_1
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
⊢ (∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = u) → addOrderOf u = n
[PROOFSTEP]
rintro ⟨m, _, h₁, rfl⟩
[GOAL]
case refine'_1.intro.intro.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
h : 0 < n
m : ℕ
left✝ : m < n
h₁ : Nat.gcd m n = 1
⊢ addOrderOf ↑(↑m / ↑n * p) = n
[PROOFSTEP]
exact addOrderOf_div_of_gcd_eq_one h h₁
[GOAL]
case refine'_2
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k
[PROOFSTEP]
have h0 := addOrderOf_nsmul_eq_zero (k : AddCircle p)
[GOAL]
case refine'_2
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
h0 : addOrderOf ↑k • ↑k = 0
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k
[PROOFSTEP]
rw [hk, ← coe_nsmul, coe_eq_zero_iff] at h0
[GOAL]
case refine'_2
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
h0 : ∃ n_1, n_1 • p = n • k
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k
[PROOFSTEP]
obtain ⟨a, ha⟩ := h0
[GOAL]
case refine'_2.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : a • p = n • k
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k
[PROOFSTEP]
have h0 : (_ : 𝕜) ≠ 0 := Nat.cast_ne_zero.2 h.ne'
[GOAL]
case refine'_2.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : a • p = n • k
h0 : ↑n ≠ 0
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k
[PROOFSTEP]
rw [nsmul_eq_mul, mul_comm, ← div_eq_iff h0, ← a.ediv_add_emod' n, add_smul, add_div, zsmul_eq_mul, Int.cast_mul,
Int.cast_ofNat, mul_assoc, ← mul_div, mul_comm _ p, mul_div_cancel p h0] at ha
[GOAL]
case refine'_2.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k
[PROOFSTEP]
have han : _ = a % n := Int.toNat_of_nonneg (Int.emod_nonneg _ <| by exact_mod_cast h.ne')
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
⊢ ↑n ≠ 0
[PROOFSTEP]
exact_mod_cast h.ne'
[GOAL]
case refine'_2.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k
[PROOFSTEP]
have he : (↑(↑((a % n).toNat) / ↑n * p) : AddCircle p) = k
[GOAL]
case he
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
⊢ ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
[PROOFSTEP]
convert congr_arg (QuotientAddGroup.mk : 𝕜 → (AddCircle p)) ha using 1
[GOAL]
case h.e'_2
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
⊢ ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑(↑(a / ↑n) * p + (a % ↑n) • p / ↑n)
[PROOFSTEP]
rw [coe_add, ← Int.cast_ofNat, han, zsmul_eq_mul, mul_div_right_comm, eq_comm, add_left_eq_self, ← zsmul_eq_mul,
coe_zsmul, coe_period, smul_zero]
[GOAL]
case refine'_2.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
he : ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k
[PROOFSTEP]
refine' ⟨(a % n).toNat, _, _, he⟩
[GOAL]
case refine'_2.intro.refine'_1
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
he : ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
⊢ Int.toNat (a % ↑n) < n
[PROOFSTEP]
rw [← Int.ofNat_lt, han]
[GOAL]
case refine'_2.intro.refine'_1
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
he : ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
⊢ a % ↑n < ↑n
[PROOFSTEP]
exact Int.emod_lt_of_pos _ (Int.ofNat_lt.2 h)
[GOAL]
case refine'_2.intro.refine'_2
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
he : ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
⊢ Nat.gcd (Int.toNat (a % ↑n)) n = 1
[PROOFSTEP]
have := (gcd_mul_addOrderOf_div_eq p (Int.toNat (a % ↑n)) h).trans ((congr_arg addOrderOf he).trans hk).symm
[GOAL]
case refine'_2.intro.refine'_2
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
he : ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
this :
Nat.gcd (Int.toNat (a % ↑n)) n * addOrderOf ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) =
addOrderOf ↑(↑(Int.toNat (a % ↑n)) / ↑n * p)
⊢ Nat.gcd (Int.toNat (a % ↑n)) n = 1
[PROOFSTEP]
rw [he, Nat.mul_left_eq_self_iff] at this
[GOAL]
case refine'_2.intro.refine'_2
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
he : ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
this : Nat.gcd (Int.toNat (a % ↑n)) n = 1
⊢ Nat.gcd (Int.toNat (a % ↑n)) n = 1
[PROOFSTEP]
exact this
[GOAL]
case refine'_2.intro.refine'_2
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
he : ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
this : Nat.gcd (Int.toNat (a % ↑n)) n * addOrderOf ↑k = addOrderOf ↑k
⊢ 0 < addOrderOf ↑k
[PROOFSTEP]
rwa [hk]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
⊢ Bijective fun m => { val := ↑(↑↑m / ↑n * p), property := (_ : addOrderOf ↑(↑↑m / ↑n * p) = n) }
[PROOFSTEP]
refine' ⟨fun m₁ m₂ h => Subtype.ext _, fun u => _⟩
[GOAL]
case refine'_1
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
m₁ m₂ : ↑{m | m < n ∧ Nat.gcd m n = 1}
h :
(fun m => { val := ↑(↑↑m / ↑n * p), property := (_ : addOrderOf ↑(↑↑m / ↑n * p) = n) }) m₁ =
(fun m => { val := ↑(↑↑m / ↑n * p), property := (_ : addOrderOf ↑(↑↑m / ↑n * p) = n) }) m₂
⊢ ↑m₁ = ↑m₂
[PROOFSTEP]
simp_rw [Subtype.ext_iff] at h
[GOAL]
case refine'_1
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
m₁ m₂ : ↑{m | m < n ∧ Nat.gcd m n = 1}
h : ↑(↑↑m₁ / ↑n * p) = ↑(↑↑m₂ / ↑n * p)
⊢ ↑m₁ = ↑m₂
[PROOFSTEP]
rw [← sub_eq_zero, ← coe_sub, ← sub_mul, ← sub_div, ← Int.cast_ofNat m₁, ← Int.cast_ofNat m₂, ← Int.cast_sub,
coe_eq_zero_iff] at h
[GOAL]
case refine'_1
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
m₁ m₂ : ↑{m | m < n ∧ Nat.gcd m n = 1}
h✝ : ↑(↑↑m₁ / ↑n * p) = ↑(↑↑m₂ / ↑n * p)
h : ∃ n_1, n_1 • p = ↑(↑↑m₁ - ↑↑m₂) / ↑n * p
⊢ ↑m₁ = ↑m₂
[PROOFSTEP]
obtain ⟨m, hm⟩ := h
[GOAL]
case refine'_1.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
m₁ m₂ : ↑{m | m < n ∧ Nat.gcd m n = 1}
h : ↑(↑↑m₁ / ↑n * p) = ↑(↑↑m₂ / ↑n * p)
m : ℤ
hm : m • p = ↑(↑↑m₁ - ↑↑m₂) / ↑n * p
⊢ ↑m₁ = ↑m₂
[PROOFSTEP]
rw [← mul_div_right_comm, eq_div_iff, mul_comm, ← zsmul_eq_mul, mul_smul_comm, ← nsmul_eq_mul, ← coe_nat_zsmul,
smul_smul, (zsmul_strictMono_left hp.out).injective.eq_iff, mul_comm] at hm
[GOAL]
case refine'_1.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
m₁ m₂ : ↑{m | m < n ∧ Nat.gcd m n = 1}
h : ↑(↑↑m₁ / ↑n * p) = ↑(↑↑m₂ / ↑n * p)
m : ℤ
hm : ↑n * m = ↑↑m₁ - ↑↑m₂
⊢ ↑m₁ = ↑m₂
case refine'_1.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
m₁ m₂ : ↑{m | m < n ∧ Nat.gcd m n = 1}
h : ↑(↑↑m₁ / ↑n * p) = ↑(↑↑m₂ / ↑n * p)
m : ℤ
hm : m • p = ↑(↑↑m₁ - ↑↑m₂) * p / ↑n
⊢ ↑n ≠ 0
[PROOFSTEP]
swap
[GOAL]
case refine'_1.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
m₁ m₂ : ↑{m | m < n ∧ Nat.gcd m n = 1}
h : ↑(↑↑m₁ / ↑n * p) = ↑(↑↑m₂ / ↑n * p)
m : ℤ
hm : m • p = ↑(↑↑m₁ - ↑↑m₂) * p / ↑n
⊢ ↑n ≠ 0
[PROOFSTEP]
exact Nat.cast_ne_zero.2 hn.ne'
[GOAL]
case refine'_1.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
m₁ m₂ : ↑{m | m < n ∧ Nat.gcd m n = 1}
h : ↑(↑↑m₁ / ↑n * p) = ↑(↑↑m₂ / ↑n * p)
m : ℤ
hm : ↑n * m = ↑↑m₁ - ↑↑m₂
⊢ ↑m₁ = ↑m₂
[PROOFSTEP]
rw [← @Nat.cast_inj ℤ, ← sub_eq_zero]
[GOAL]
case refine'_1.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
m₁ m₂ : ↑{m | m < n ∧ Nat.gcd m n = 1}
h : ↑(↑↑m₁ / ↑n * p) = ↑(↑↑m₂ / ↑n * p)
m : ℤ
hm : ↑n * m = ↑↑m₁ - ↑↑m₂
⊢ ↑↑m₁ - ↑↑m₂ = 0
[PROOFSTEP]
refine' Int.eq_zero_of_abs_lt_dvd ⟨_, hm.symm⟩ (abs_sub_lt_iff.2 ⟨_, _⟩)
[GOAL]
case refine'_1.intro.refine'_1
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
m₁ m₂ : ↑{m | m < n ∧ Nat.gcd m n = 1}
h : ↑(↑↑m₁ / ↑n * p) = ↑(↑↑m₂ / ↑n * p)
m : ℤ
hm : ↑n * m = ↑↑m₁ - ↑↑m₂
⊢ ↑↑m₁ - ↑↑m₂ < ↑n
[PROOFSTEP]
apply (Int.sub_le_self _ <| Nat.cast_nonneg _).trans_lt (Nat.cast_lt.2 _)
[GOAL]
case refine'_1.intro.refine'_2
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
m₁ m₂ : ↑{m | m < n ∧ Nat.gcd m n = 1}
h : ↑(↑↑m₁ / ↑n * p) = ↑(↑↑m₂ / ↑n * p)
m : ℤ
hm : ↑n * m = ↑↑m₁ - ↑↑m₂
⊢ ↑↑m₂ - ↑↑m₁ < ↑n
[PROOFSTEP]
apply (Int.sub_le_self _ <| Nat.cast_nonneg _).trans_lt (Nat.cast_lt.2 _)
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
m₁ m₂ : ↑{m | m < n ∧ Nat.gcd m n = 1}
h : ↑(↑↑m₁ / ↑n * p) = ↑(↑↑m₂ / ↑n * p)
m : ℤ
hm : ↑n * m = ↑↑m₁ - ↑↑m₂
⊢ ↑m₁ < n
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
m₁ m₂ : ↑{m | m < n ∧ Nat.gcd m n = 1}
h : ↑(↑↑m₁ / ↑n * p) = ↑(↑↑m₂ / ↑n * p)
m : ℤ
hm : ↑n * m = ↑↑m₁ - ↑↑m₂
⊢ ↑m₂ < n
[PROOFSTEP]
exacts [m₁.2.1, m₂.2.1]
[GOAL]
case refine'_2
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
u : ↑{u | addOrderOf u = n}
⊢ ∃ a, (fun m => { val := ↑(↑↑m / ↑n * p), property := (_ : addOrderOf ↑(↑↑m / ↑n * p) = n) }) a = u
[PROOFSTEP]
obtain ⟨m, hmn, hg, he⟩ := (addOrderOf_eq_pos_iff hn).mp u.2
[GOAL]
case refine'_2.intro.intro.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
u : ↑{u | addOrderOf u = n}
m : ℕ
hmn : m < n
hg : Nat.gcd m n = 1
he : ↑(↑m / ↑n * p) = ↑u
⊢ ∃ a, (fun m => { val := ↑(↑↑m / ↑n * p), property := (_ : addOrderOf ↑(↑↑m / ↑n * p) = n) }) a = u
[PROOFSTEP]
exact ⟨⟨m, hmn, hg⟩, Subtype.ext he⟩
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
⊢ Nat.card { u // addOrderOf u = n } = Nat.totient n
[PROOFSTEP]
rcases n.eq_zero_or_pos with (rfl | hn)
[GOAL]
case inl
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
⊢ Nat.card { u // addOrderOf u = 0 } = Nat.totient 0
[PROOFSTEP]
simp only [Nat.totient_zero, addOrderOf_eq_zero_iff]
[GOAL]
case inl
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
⊢ Nat.card { u // ¬IsOfFinAddOrder u } = 0
[PROOFSTEP]
rcases em (∃ u : AddCircle p, ¬IsOfFinAddOrder u) with (⟨u, hu⟩ | h)
[GOAL]
case inl.inl.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
hu : ¬IsOfFinAddOrder u
⊢ Nat.card { u // ¬IsOfFinAddOrder u } = 0
[PROOFSTEP]
have : Infinite { u : AddCircle p // ¬IsOfFinAddOrder u } :=
by
erw [infinite_coe_iff]
exact infinite_not_isOfFinAddOrder hu
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
hu : ¬IsOfFinAddOrder u
⊢ Infinite { u // ¬IsOfFinAddOrder u }
[PROOFSTEP]
erw [infinite_coe_iff]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
hu : ¬IsOfFinAddOrder u
⊢ Set.Infinite fun u => IsOfFinAddOrder u → False
[PROOFSTEP]
exact infinite_not_isOfFinAddOrder hu
[GOAL]
case inl.inl.intro
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
hu : ¬IsOfFinAddOrder u
this : Infinite { u // ¬IsOfFinAddOrder u }
⊢ Nat.card { u // ¬IsOfFinAddOrder u } = 0
[PROOFSTEP]
exact Nat.card_eq_zero_of_infinite
[GOAL]
case inl.inr
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
h : ¬∃ u, ¬IsOfFinAddOrder u
⊢ Nat.card { u // ¬IsOfFinAddOrder u } = 0
[PROOFSTEP]
have : IsEmpty { u : AddCircle p // ¬IsOfFinAddOrder u } := by simpa using h
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
h : ¬∃ u, ¬IsOfFinAddOrder u
⊢ IsEmpty { u // ¬IsOfFinAddOrder u }
[PROOFSTEP]
simpa using h
[GOAL]
case inl.inr
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
h : ¬∃ u, ¬IsOfFinAddOrder u
this : IsEmpty { u // ¬IsOfFinAddOrder u }
⊢ Nat.card { u // ¬IsOfFinAddOrder u } = 0
[PROOFSTEP]
exact Nat.card_of_isEmpty
[GOAL]
case inr
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : n > 0
⊢ Nat.card { u // addOrderOf u = n } = Nat.totient n
[PROOFSTEP]
rw [← coe_setOf, Nat.card_congr (setAddOrderOfEquiv p hn), n.totient_eq_card_lt_and_coprime]
[GOAL]
case inr
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : n > 0
⊢ Nat.card ↑{m | m < n ∧ Nat.gcd m n = 1} = Nat.card ↑{m | m < n ∧ Nat.coprime n m}
[PROOFSTEP]
simp only [Nat.gcd_comm]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
hn : 0 < n
⊢ Nat.card ↑{u | addOrderOf u = n} ≠ 0
[PROOFSTEP]
simpa only [coe_setOf, card_addOrderOf_eq_totient p] using (Nat.totient_pos hn).ne'
[GOAL]
𝕜 : Type u_1
B : Type u_2
p : ℝ
inst✝ : Fact (0 < p)
⊢ CompactSpace (AddCircle p)
[PROOFSTEP]
rw [← isCompact_univ_iff, ← coe_image_Icc_eq p 0]
[GOAL]
𝕜 : Type u_1
B : Type u_2
p : ℝ
inst✝ : Fact (0 < p)
⊢ IsCompact (QuotientAddGroup.mk '' Icc 0 (0 + p))
[PROOFSTEP]
exact isCompact_Icc.image (AddCircle.continuous_mk' p)
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : Quot (EndpointIdent p a)
⊢ ∀ (a_1 b : ↑(Icc a (a + p))), EndpointIdent p a a_1 b → (fun x => ↑↑x) a_1 = (fun x => ↑↑x) b
[PROOFSTEP]
rintro _ _ ⟨_⟩
[GOAL]
case mk
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : Quot (EndpointIdent p a)
⊢ (fun x => ↑↑x) { val := a, property := (_ : a ∈ Icc a (a + p)) } =
(fun x => ↑↑x) { val := a + p, property := (_ : a + p ∈ Icc a (a + p)) }
[PROOFSTEP]
exact (coe_add_period p a).symm
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
⊢ ∀ (a_1 : ↑(Icc a (a + p))),
(fun x => Quot.mk (EndpointIdent p a) (Set.inclusion (_ : Ico a (a + p) ⊆ Icc a (a + p)) (↑(equivIco p a) x)))
((fun x =>
Quot.liftOn x (fun x => ↑↑x)
(_ : ∀ (a_2 b : ↑(Icc a (a + p))), EndpointIdent p a a_2 b → (fun x => ↑↑x) a_2 = (fun x => ↑↑x) b))
(Quot.mk (EndpointIdent p a) a_1)) =
Quot.mk (EndpointIdent p a) a_1
[PROOFSTEP]
rintro ⟨x, hx⟩
[GOAL]
case mk
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
hx : x ∈ Icc a (a + p)
⊢ (fun x => Quot.mk (EndpointIdent p a) (Set.inclusion (_ : Ico a (a + p) ⊆ Icc a (a + p)) (↑(equivIco p a) x)))
((fun x =>
Quot.liftOn x (fun x => ↑↑x)
(_ : ∀ (a_1 b : ↑(Icc a (a + p))), EndpointIdent p a a_1 b → (fun x => ↑↑x) a_1 = (fun x => ↑↑x) b))
(Quot.mk (EndpointIdent p a) { val := x, property := hx })) =
Quot.mk (EndpointIdent p a) { val := x, property := hx }
[PROOFSTEP]
rcases ne_or_eq x (a + p) with (h | rfl)
[GOAL]
case mk.inl
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
hx : x ∈ Icc a (a + p)
h : x ≠ a + p
⊢ (fun x => Quot.mk (EndpointIdent p a) (Set.inclusion (_ : Ico a (a + p) ⊆ Icc a (a + p)) (↑(equivIco p a) x)))
((fun x =>
Quot.liftOn x (fun x => ↑↑x)
(_ : ∀ (a_1 b : ↑(Icc a (a + p))), EndpointIdent p a a_1 b → (fun x => ↑↑x) a_1 = (fun x => ↑↑x) b))
(Quot.mk (EndpointIdent p a) { val := x, property := hx })) =
Quot.mk (EndpointIdent p a) { val := x, property := hx }
[PROOFSTEP]
revert x
[GOAL]
case mk.inl
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
⊢ ∀ (x : 𝕜) (hx : x ∈ Icc a (a + p)),
x ≠ a + p →
(fun x => Quot.mk (EndpointIdent p a) (Set.inclusion (_ : Ico a (a + p) ⊆ Icc a (a + p)) (↑(equivIco p a) x)))
((fun x =>
Quot.liftOn x (fun x => ↑↑x)
(_ : ∀ (a_1 b : ↑(Icc a (a + p))), EndpointIdent p a a_1 b → (fun x => ↑↑x) a_1 = (fun x => ↑↑x) b))
(Quot.mk (EndpointIdent p a) { val := x, property := hx })) =
Quot.mk (EndpointIdent p a) { val := x, property := hx }
[PROOFSTEP]
dsimp only
[GOAL]
case mk.inl
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
⊢ ∀ (x : 𝕜) (hx : x ∈ Icc a (a + p)),
x ≠ a + p →
Quot.mk (EndpointIdent p a)
(Set.inclusion (_ : Ico a (a + p) ⊆ Icc a (a + p))
(↑(equivIco p a)
(Quot.liftOn (Quot.mk (EndpointIdent p a) { val := x, property := hx }) (fun x => ↑↑x)
(_ : ∀ (a_1 b : ↑(Icc a (a + p))), EndpointIdent p a a_1 b → ↑↑a_1 = ↑↑b)))) =
Quot.mk (EndpointIdent p a) { val := x, property := hx }
[PROOFSTEP]
intro x hx h
[GOAL]
case mk.inl
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
hx : x ∈ Icc a (a + p)
h : x ≠ a + p
⊢ Quot.mk (EndpointIdent p a)
(Set.inclusion (_ : Ico a (a + p) ⊆ Icc a (a + p))
(↑(equivIco p a)
(Quot.liftOn (Quot.mk (EndpointIdent p a) { val := x, property := hx }) (fun x => ↑↑x)
(_ : ∀ (a_1 b : ↑(Icc a (a + p))), EndpointIdent p a a_1 b → ↑↑a_1 = ↑↑b)))) =
Quot.mk (EndpointIdent p a) { val := x, property := hx }
[PROOFSTEP]
congr
[GOAL]
case mk.inl.e_a
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
hx : x ∈ Icc a (a + p)
h : x ≠ a + p
⊢ Set.inclusion (_ : Ico a (a + p) ⊆ Icc a (a + p))
(↑(equivIco p a)
(Quot.liftOn (Quot.mk (EndpointIdent p a) { val := x, property := hx }) (fun x => ↑↑x)
(_ : ∀ (a_1 b : ↑(Icc a (a + p))), EndpointIdent p a a_1 b → ↑↑a_1 = ↑↑b))) =
{ val := x, property := hx }
[PROOFSTEP]
ext1
[GOAL]
case mk.inl.e_a.a
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
hx : x ∈ Icc a (a + p)
h : x ≠ a + p
⊢ ↑(Set.inclusion (_ : Ico a (a + p) ⊆ Icc a (a + p))
(↑(equivIco p a)
(Quot.liftOn (Quot.mk (EndpointIdent p a) { val := x, property := hx }) (fun x => ↑↑x)
(_ : ∀ (a_1 b : ↑(Icc a (a + p))), EndpointIdent p a a_1 b → ↑↑a_1 = ↑↑b)))) =
↑{ val := x, property := hx }
[PROOFSTEP]
apply congr_arg Subtype.val ((equivIco p a).right_inv ⟨x, hx.1, hx.2.lt_of_ne h⟩)
[GOAL]
case mk.inr
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
hx : a + p ∈ Icc a (a + p)
⊢ (fun x => Quot.mk (EndpointIdent p a) (Set.inclusion (_ : Ico a (a + p) ⊆ Icc a (a + p)) (↑(equivIco p a) x)))
((fun x =>
Quot.liftOn x (fun x => ↑↑x)
(_ : ∀ (a_1 b : ↑(Icc a (a + p))), EndpointIdent p a a_1 b → (fun x => ↑↑x) a_1 = (fun x => ↑↑x) b))
(Quot.mk (EndpointIdent p a) { val := a + p, property := hx })) =
Quot.mk (EndpointIdent p a) { val := a + p, property := hx }
[PROOFSTEP]
rw [← Quot.sound EndpointIdent.mk]
[GOAL]
case mk.inr
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
hx : a + p ∈ Icc a (a + p)
⊢ (fun x => Quot.mk (EndpointIdent p a) (Set.inclusion (_ : Ico a (a + p) ⊆ Icc a (a + p)) (↑(equivIco p a) x)))
((fun x =>
Quot.liftOn x (fun x => ↑↑x)
(_ : ∀ (a_1 b : ↑(Icc a (a + p))), EndpointIdent p a a_1 b → (fun x => ↑↑x) a_1 = (fun x => ↑↑x) b))
(Quot.mk (EndpointIdent p a) { val := a, property := (_ : a ∈ Icc a (a + p)) })) =
Quot.mk (EndpointIdent p a) { val := a, property := (_ : a ∈ Icc a (a + p)) }
[PROOFSTEP]
dsimp only
[GOAL]
case mk.inr
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
hx : a + p ∈ Icc a (a + p)
⊢ Quot.mk (EndpointIdent p a)
(Set.inclusion (_ : Ico a (a + p) ⊆ Icc a (a + p))
(↑(equivIco p a)
(Quot.liftOn (Quot.mk (EndpointIdent p a) { val := a, property := (_ : a ∈ Icc a (a + p)) }) (fun x => ↑↑x)
(_ : ∀ (a_1 b : ↑(Icc a (a + p))), EndpointIdent p a a_1 b → ↑↑a_1 = ↑↑b)))) =
Quot.mk (EndpointIdent p a) { val := a, property := (_ : a ∈ Icc a (a + p)) }
[PROOFSTEP]
congr
[GOAL]
case mk.inr.e_a
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
hx : a + p ∈ Icc a (a + p)
⊢ Set.inclusion (_ : Ico a (a + p) ⊆ Icc a (a + p))
(↑(equivIco p a)
(Quot.liftOn (Quot.mk (EndpointIdent p a) { val := a, property := (_ : a ∈ Icc a (a + p)) }) (fun x => ↑↑x)
(_ : ∀ (a_1 b : ↑(Icc a (a + p))), EndpointIdent p a a_1 b → ↑↑a_1 = ↑↑b))) =
{ val := a, property := (_ : a ∈ Icc a (a + p)) }
[PROOFSTEP]
ext1
[GOAL]
case mk.inr.e_a.a
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
hx : a + p ∈ Icc a (a + p)
⊢ ↑(Set.inclusion (_ : Ico a (a + p) ⊆ Icc a (a + p))
(↑(equivIco p a)
(Quot.liftOn (Quot.mk (EndpointIdent p a) { val := a, property := (_ : a ∈ Icc a (a + p)) }) (fun x => ↑↑x)
(_ : ∀ (a_1 b : ↑(Icc a (a + p))), EndpointIdent p a a_1 b → ↑↑a_1 = ↑↑b)))) =
↑{ val := a, property := (_ : a ∈ Icc a (a + p)) }
[PROOFSTEP]
apply congr_arg Subtype.val ((equivIco p a).right_inv ⟨a, le_refl a, lt_add_of_pos_right a hp.out⟩)
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
⊢ ↑(equivIccQuot p a) ∘ Quotient.mk'' = fun x =>
Quot.mk (EndpointIdent p a)
{ val := toIocMod (_ : 0 < p) a x, property := (_ : toIocMod (_ : 0 < p) a x ∈ Icc a (a + p)) }
[PROOFSTEP]
rw [equivIccQuot_comp_mk_eq_toIcoMod]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
⊢ (fun x =>
Quot.mk (EndpointIdent p a)
{ val := toIcoMod (_ : 0 < p) a x, property := (_ : toIcoMod (_ : 0 < p) a x ∈ Icc a (a + p)) }) =
fun x =>
Quot.mk (EndpointIdent p a)
{ val := toIocMod (_ : 0 < p) a x, property := (_ : toIocMod (_ : 0 < p) a x ∈ Icc a (a + p)) }
[PROOFSTEP]
funext x
[GOAL]
case h
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ Quot.mk (EndpointIdent p a)
{ val := toIcoMod (_ : 0 < p) a x, property := (_ : toIcoMod (_ : 0 < p) a x ∈ Icc a (a + p)) } =
Quot.mk (EndpointIdent p a)
{ val := toIocMod (_ : 0 < p) a x, property := (_ : toIocMod (_ : 0 < p) a x ∈ Icc a (a + p)) }
[PROOFSTEP]
by_cases a ≡ x [PMOD p]
[GOAL]
case h
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ Quot.mk (EndpointIdent p a)
{ val := toIcoMod (_ : 0 < p) a x, property := (_ : toIcoMod (_ : 0 < p) a x ∈ Icc a (a + p)) } =
Quot.mk (EndpointIdent p a)
{ val := toIocMod (_ : 0 < p) a x, property := (_ : toIocMod (_ : 0 < p) a x ∈ Icc a (a + p)) }
[PROOFSTEP]
by_cases a ≡ x [PMOD p]
[GOAL]
case pos
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
h : a ≡ x [PMOD p]
⊢ Quot.mk (EndpointIdent p a)
{ val := toIcoMod (_ : 0 < p) a x, property := (_ : toIcoMod (_ : 0 < p) a x ∈ Icc a (a + p)) } =
Quot.mk (EndpointIdent p a)
{ val := toIocMod (_ : 0 < p) a x, property := (_ : toIocMod (_ : 0 < p) a x ∈ Icc a (a + p)) }
[PROOFSTEP]
simp_rw [(modEq_iff_toIcoMod_eq_left hp.out).1 h, (modEq_iff_toIocMod_eq_right hp.out).1 h]
[GOAL]
case pos
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
h : a ≡ x [PMOD p]
⊢ Quot.mk (EndpointIdent p a) { val := a, property := (_ : (fun x => x ∈ Icc a (a + p)) a) } =
Quot.mk (EndpointIdent p a) { val := a + p, property := (_ : (fun x => x ∈ Icc a (a + p)) (a + p)) }
[PROOFSTEP]
exact Quot.sound EndpointIdent.mk
[GOAL]
case neg
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
h : ¬a ≡ x [PMOD p]
⊢ Quot.mk (EndpointIdent p a)
{ val := toIcoMod (_ : 0 < p) a x, property := (_ : toIcoMod (_ : 0 < p) a x ∈ Icc a (a + p)) } =
Quot.mk (EndpointIdent p a)
{ val := toIocMod (_ : 0 < p) a x, property := (_ : toIocMod (_ : 0 < p) a x ∈ Icc a (a + p)) }
[PROOFSTEP]
simp_rw [(not_modEq_iff_toIcoMod_eq_toIocMod hp.out).1 h]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
⊢ Continuous (equivIccQuot p a).toFun
[PROOFSTEP]
rw [quotientMap_quotient_mk'.continuous_iff]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
⊢ Continuous ((equivIccQuot p a).toFun ∘ Quotient.mk')
[PROOFSTEP]
simp_rw [continuous_iff_continuousAt, continuousAt_iff_continuous_left_right]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
⊢ ∀ (x : 𝕜),
ContinuousWithinAt ((equivIccQuot p a).toFun ∘ Quotient.mk') (Iic x) x ∧
ContinuousWithinAt ((equivIccQuot p a).toFun ∘ Quotient.mk') (Ici x) x
[PROOFSTEP]
intro x
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt ((equivIccQuot p a).toFun ∘ Quotient.mk') (Iic x) x ∧
ContinuousWithinAt ((equivIccQuot p a).toFun ∘ Quotient.mk') (Ici x) x
[PROOFSTEP]
constructor
[GOAL]
case left
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt ((equivIccQuot p a).toFun ∘ Quotient.mk') (Iic x) x
case right
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt ((equivIccQuot p a).toFun ∘ Quotient.mk') (Ici x) x
[PROOFSTEP]
on_goal 1 => erw [equivIccQuot_comp_mk_eq_toIocMod]
[GOAL]
case left
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt ((equivIccQuot p a).toFun ∘ Quotient.mk') (Iic x) x
case right
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt ((equivIccQuot p a).toFun ∘ Quotient.mk') (Ici x) x
[PROOFSTEP]
on_goal 1 => erw [equivIccQuot_comp_mk_eq_toIocMod]
[GOAL]
case left
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt ((equivIccQuot p a).toFun ∘ Quotient.mk') (Iic x) x
[PROOFSTEP]
erw [equivIccQuot_comp_mk_eq_toIocMod]
[GOAL]
case left
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt
(fun x =>
Quot.mk (EndpointIdent p a)
{ val := toIocMod (_ : 0 < p) a x, property := (_ : toIocMod (_ : 0 < p) a x ∈ Icc a (a + p)) })
(Iic x) x
case right
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt ((equivIccQuot p a).toFun ∘ Quotient.mk') (Ici x) x
[PROOFSTEP]
on_goal 2 => erw [equivIccQuot_comp_mk_eq_toIcoMod]
[GOAL]
case left
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt
(fun x =>
Quot.mk (EndpointIdent p a)
{ val := toIocMod (_ : 0 < p) a x, property := (_ : toIocMod (_ : 0 < p) a x ∈ Icc a (a + p)) })
(Iic x) x
case right
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt ((equivIccQuot p a).toFun ∘ Quotient.mk') (Ici x) x
[PROOFSTEP]
on_goal 2 => erw [equivIccQuot_comp_mk_eq_toIcoMod]
[GOAL]
case right
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt ((equivIccQuot p a).toFun ∘ Quotient.mk') (Ici x) x
[PROOFSTEP]
erw [equivIccQuot_comp_mk_eq_toIcoMod]
[GOAL]
case left
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt
(fun x =>
Quot.mk (EndpointIdent p a)
{ val := toIocMod (_ : 0 < p) a x, property := (_ : toIocMod (_ : 0 < p) a x ∈ Icc a (a + p)) })
(Iic x) x
case right
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt
(fun x =>
Quot.mk (EndpointIdent p a)
{ val := toIcoMod (_ : 0 < p) a x, property := (_ : toIcoMod (_ : 0 < p) a x ∈ Icc a (a + p)) })
(Ici x) x
[PROOFSTEP]
all_goals
apply continuous_quot_mk.continuousAt.comp_continuousWithinAt
rw [inducing_subtype_val.continuousWithinAt_iff]
[GOAL]
case left
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt
(fun x =>
Quot.mk (EndpointIdent p a)
{ val := toIocMod (_ : 0 < p) a x, property := (_ : toIocMod (_ : 0 < p) a x ∈ Icc a (a + p)) })
(Iic x) x
[PROOFSTEP]
apply continuous_quot_mk.continuousAt.comp_continuousWithinAt
[GOAL]
case left
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt
(fun x => { val := toIocMod (_ : 0 < p) a x, property := (_ : toIocMod (_ : 0 < p) a x ∈ Icc a (a + p)) }) (Iic x) x
[PROOFSTEP]
rw [inducing_subtype_val.continuousWithinAt_iff]
[GOAL]
case right
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt
(fun x =>
Quot.mk (EndpointIdent p a)
{ val := toIcoMod (_ : 0 < p) a x, property := (_ : toIcoMod (_ : 0 < p) a x ∈ Icc a (a + p)) })
(Ici x) x
[PROOFSTEP]
apply continuous_quot_mk.continuousAt.comp_continuousWithinAt
[GOAL]
case right
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt
(fun x => { val := toIcoMod (_ : 0 < p) a x, property := (_ : toIcoMod (_ : 0 < p) a x ∈ Icc a (a + p)) }) (Ici x) x
[PROOFSTEP]
rw [inducing_subtype_val.continuousWithinAt_iff]
[GOAL]
case left
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt
(Subtype.val ∘ fun x =>
{ val := toIocMod (_ : 0 < p) a x, property := (_ : toIocMod (_ : 0 < p) a x ∈ Icc a (a + p)) })
(Iic x) x
[PROOFSTEP]
apply continuous_left_toIocMod
[GOAL]
case right
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
x : 𝕜
⊢ ContinuousWithinAt
(Subtype.val ∘ fun x =>
{ val := toIcoMod (_ : 0 < p) a x, property := (_ : toIcoMod (_ : 0 < p) a x ∈ Icc a (a + p)) })
(Ici x) x
[PROOFSTEP]
apply continuous_right_toIcoMod
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
f : 𝕜 → B
h : f a = f (a + p)
⊢ ∀ (a_1 b : ↑(Icc a (a + p))), EndpointIdent p a a_1 b → restrict (Icc a (a + p)) f a_1 = restrict (Icc a (a + p)) f b
[PROOFSTEP]
rintro _ _ ⟨_⟩
[GOAL]
case mk
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
f : 𝕜 → B
h : f a = f (a + p)
⊢ restrict (Icc a (a + p)) f { val := a, property := (_ : a ∈ Icc a (a + p)) } =
restrict (Icc a (a + p)) f { val := a + p, property := (_ : a + p ∈ Icc a (a + p)) }
[PROOFSTEP]
exact h
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝⁴ : LinearOrderedAddCommGroup 𝕜
inst✝³ : TopologicalSpace 𝕜
inst✝² : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝¹ : Archimedean 𝕜
inst✝ : TopologicalSpace B
f : 𝕜 → B
hf : f a = f (a + p)
hc : ContinuousOn f (Icc a (a + p))
⊢ Continuous (liftIco p a f)
[PROOFSTEP]
rw [liftIco_eq_lift_Icc hf]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝⁴ : LinearOrderedAddCommGroup 𝕜
inst✝³ : TopologicalSpace 𝕜
inst✝² : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝¹ : Archimedean 𝕜
inst✝ : TopologicalSpace B
f : 𝕜 → B
hf : f a = f (a + p)
hc : ContinuousOn f (Icc a (a + p))
⊢ Continuous
(Quot.lift (restrict (Icc a (a + p)) f)
(_ :
∀ (a_1 b : ↑(Icc a (a + p))),
EndpointIdent p a a_1 b → restrict (Icc a (a + p)) f a_1 = restrict (Icc a (a + p)) f b) ∘
↑(equivIccQuot p a))
[PROOFSTEP]
refine' Continuous.comp _ (homeoIccQuot p a).continuous_toFun
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝⁴ : LinearOrderedAddCommGroup 𝕜
inst✝³ : TopologicalSpace 𝕜
inst✝² : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝¹ : Archimedean 𝕜
inst✝ : TopologicalSpace B
f : 𝕜 → B
hf : f a = f (a + p)
hc : ContinuousOn f (Icc a (a + p))
⊢ Continuous
(Quot.lift (restrict (Icc a (a + p)) f)
(_ :
∀ (a_1 b : ↑(Icc a (a + p))),
EndpointIdent p a a_1 b → restrict (Icc a (a + p)) f a_1 = restrict (Icc a (a + p)) f b))
[PROOFSTEP]
exact continuous_coinduced_dom.mpr (continuousOn_iff_continuous_restrict.mp hc)
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : TopologicalSpace 𝕜
inst✝¹ : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝ : Archimedean 𝕜
f : 𝕜 → B
x : 𝕜
hx : x ∈ Ico 0 p
⊢ x ∈ Ico 0 (0 + p)
[PROOFSTEP]
rwa [zero_add]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝⁴ : LinearOrderedAddCommGroup 𝕜
inst✝³ : TopologicalSpace 𝕜
inst✝² : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝¹ : Archimedean 𝕜
inst✝ : TopologicalSpace B
f : 𝕜 → B
hf : f 0 = f p
hc : ContinuousOn f (Icc 0 p)
⊢ f 0 = f (0 + p)
[PROOFSTEP]
rwa [zero_add]
[GOAL]
𝕜 : Type u_1
B : Type u_2
inst✝⁴ : LinearOrderedAddCommGroup 𝕜
inst✝³ : TopologicalSpace 𝕜
inst✝² : OrderTopology 𝕜
p a : 𝕜
hp : Fact (0 < p)
inst✝¹ : Archimedean 𝕜
inst✝ : TopologicalSpace B
f : 𝕜 → B
hf : f 0 = f p
hc : ContinuousOn f (Icc 0 p)
⊢ ContinuousOn f (Icc 0 (0 + p))
[PROOFSTEP]
rwa [zero_add]
|
# Sommerfeld Boundary Conditions
<font color='green'><b> Validated for all coordinate systems available in NRPy+ </b></font>
## Authors: Terrence Pierre Jacques & Zach Etienne
## Abstract
The aim of this notebook is to describe the mathematical motivation behind the Sommerfeld boundary condition, document how it is implemented within the NRPy+ infrastructure in Cartesian coordinates, and record ongoing validation tests against the [Einstein Toolkit's NewRad boundary condition driver](https://www.einsteintoolkit.org/thornguide/EinsteinEvolve/NewRad/documentation.html#XEinsteinEvolve_NewRad_Alcubierre:2002kk).
**Notebook Status:** <font color='green'><b> Validated against the Einstein Toolkit </b></font>
**Validation Notes:** The Sommerfeld boundary condition as implemented in NRPy+ has been validated against [Einstein Toolkit's NewRad boundary condition driver](https://www.einsteintoolkit.org/thornguide/EinsteinEvolve/NewRad/documentation.html#XEinsteinEvolve_NewRad_Alcubierre:2002kk)(ETK) for the case of a scalar wave propagating across a 3D Cartesian grid. We have agreement to roundoff error with the Einstein Toolkit. Specifically, we have achieved:
1. Roundoff level agreement for the wave propagating toward each of the individual faces
1. Roundoff level agreement using any combination of input parameters available in the [Einstein Toolkit's NewRad boundary condition driver](https://www.einsteintoolkit.org/thornguide/EinsteinEvolve/NewRad/documentation.html#XEinsteinEvolve_NewRad_Alcubierre:2002kk) (variable value at infinity, radial power, and wave speed)
[comment]: <> (Introduction: TODO)
<a id='toc'></a>
# Table of Contents
$$\label{toc}$$
This notebook is organized as follows
1. [Step 1](#initializenrpy): Set core NRPy+ parameters for numerical grids
1. [Step 2](#sbc): Definition and mathematical motivation
1. [Step 2.a](#intro): Introduction & background mathematics
1. [Step 2.b](#sbc_prelims): Preliminaries - The scalar wave equation in curvilinear coordinates
1. [Step 2.c](#sbc_ansatz): Sommerfeld boundary condition ansatz
1. [Step 2.d](#sbc_ansatz_dtf): Applying the ansatz to $\partial_t f$
1. [Step 2.e](#curvicoords): Implementation in generic curvilinear coordinates
1. [Step 2.e.i](#cartcoords_byhand): Sommerfeld boundary conditions implementation in Cartesian coordinates, derived by hand
1. [Step 2.e.ii](#cartcoords_bynrpysympy): Sommerfeld boundary conditions implementation in Cartesian coordinates, derived by NRPy+/SymPy
1. [Step 3](#numalg): Numerical algorithm overview
1. [Step 3.a](#class): Sommerfeld python class and parameters
1. [Step 3.b](#partial_rf): Calculate $\partial_r f$
1. [Step 3.c](#cfunc): `apply_bcs_sommerfeld()` C function
1. [Step 3.d](#k): Solving for the subdominant radial falloff proportionality constant $k$
1. [Step 3.e](#innerbcs): Inner Boundary Conditions
1. [Step 4](#py_validate): Python file validation
1. [Step 5](#interface): NRPy+ Interface for Applying Sommerfeld Boundary Conditions
1. [Step 6](#etk_validation): Validation against the [Einstein Toolkit's NewRad boundary condition driver](https://www.einsteintoolkit.org/thornguide/EinsteinEvolve/NewRad/documentation.html#XEinsteinEvolve_NewRad_Alcubierre:2002kk)
1. [Latex Output](#latex_pdf_output): Output this notebook to $\LaTeX$-formatted PDF file
<a id='initializenrpy'></a>
# Step 1: Set core NRPy+ parameters for numerical grids \[Back to [top](#toc)\]
$$\label{initializenrpy}$$
Import needed NRPy+ core modules and set working directories.
```python
# Step P1: Import needed NRPy+ core modules:
import NRPy_param_funcs as par # NRPy+: Parameter interface
import reference_metric as rfm # NRPy+: Reference metric support
import grid as gri # NRPy+: Functions having to do with numerical grids
import cmdline_helper as cmd # NRPy+: Multi-platform Python command-line interface
import shutil, os, sys # Standard Python modules for multiplatform OS-level functions
# Create C code output directory:
Ccodesdir = os.path.join("SommerfeldBoundaryCondition_Validate")
# First remove C code output directory if it exists
# Courtesy https://stackoverflow.com/questions/303200/how-do-i-remove-delete-a-folder-that-is-not-empty
shutil.rmtree(Ccodesdir, ignore_errors=True)
# Then create a fresh directory
cmd.mkdir(Ccodesdir)
par.set_parval_from_str("grid::DIM",3)
DIM = par.parval_from_str("grid::DIM")
```
<a id='sbc'></a>
# Step 2: Sommerfeld Boundary Conditions \[Back to [top](#toc)\]
$$\label{sbc}$$
<a id='intro'></a>
## Step 2.a: Introduction & background mathematics \[Back to [top](#toc)\]
$$\label{intro}$$
When we numerically solve an initial value problem, appropriate initial data must be provided, coupled to a technique for evolving the initial data forward in time (to construct the solution at $t>0$), and we must impose boundary conditions.
The subject of this notebook is implementation of Sommerfeld boundary conditions, which are often used when solving hyperbolic systems of partial differential equations (PDEs). Sommerfeld boundary conditions are also referred to as a radiation or transparent boundary conditions.
The essential idea of a transparent boundary is creating a boundary in which wave fronts can pass through with minimal reflections. In other words, the boundary condition acts to map our numerical solution to outside our numerical domain in a smooth fashion. Because this mapping is assumed to be linear, this treatment occurs at the same time-level as calculations within our numerical domain. This point will be revisited later.
Suppose we have a dynamical variable $f$; i.e., a variable in our hyperbolic system of PDEs that satisfies the equation
$$
\partial_t f = \text{something},
$$
where generally we refer to "something" as the "right-hand side" or "RHS" of the hyperbolic PDE, where we formulate the PDE such that the RHS contains no explicit time derivatives, but generally does contain spatial derivatives (typically computed in NRPy+ using finite differencing, though may in general be computed using other, e.g., pseudospectral techniques).
To construct the solution at times after the initial data, we adopt the [Method of Lines (MoL)](Tutorial-ScalarWave.ipynb) approach, which integrates the equations forward *in time* using standard explicit techniques typically used when solving *ordinary* differential equations. In doing so, MoL evaluates the RHS of the PDE at all points in our numerical domain (typically using finite difference derivatives), except the ghost zones (i.e., the gridpoints neighboring the precise point needed to evaluate a derivative using e.g., a finite difference derivative).
After each RHS evaluation we must fill in the data on the boundaries (i.e., the ghost zones), so that data exist at all gridpoints (including the boundaries) at the next MoL substep. In doing so, we have two options:
1. Perform an MoL substep to push the *interior* solution $f$ forward in time one substep, and then update the boundary values of $f$.
1. During the MoL substep, immediately after evaluating the RHS of the $\partial t f$ equation, update the boundary values of the RHS of the $\partial t f$ equation. Then push the solution $f$ forward in time *at all gridpoints, including ghost zones* by one substep.
Our implementation of the Sommerfeld boundary condition implements the second option, filling in the data for $\partial_t f$ (cf., our [extrapolation boundary condition implementation](Tutorial-Start_to_Finish-Curvilinear_BCs.ipynb)) on the boundaries (i.e., ghost zones).
<a id='sbc_prelims'></a>
## Step 2.b: Preliminaries - The scalar wave equation in curvilinear coordinates \[Back to [top](#toc)\]
$$\label{sbc_prelims}$$
Our Sommerfeld boundary condition implementation assumes $f$ behaves as a spherically symmetric, outgoing wave at the boundaries. Under these assumptions, the waves satisfy the wave equation in spherical coordinates with angular parts set to zero. I.e., under these assumptions the wavefunction $u(r,t)$ will satisfy:
\begin{align}
0 = \Box\, u &= \hat{D}^{\nu} \hat{D}_{\nu} u \\
&= \hat{g}^{\mu\nu} \hat{D}_{\mu} \hat{D}_{\nu} u \\
&= \hat{g}^{\mu\nu} \hat{D}_{\mu} \partial_{\nu} u \\
&= \hat{g}^{\mu\nu} \left[\partial_{\mu} (\partial_{\nu} u) - \hat{\Gamma}^\alpha_{\mu\nu} (\partial_{\alpha} u) \right],
\end{align}
here the hatted metric is defined as $\hat{g}^{tt} = -1/v^2$ (where $v$ is the wavespeed), $\hat{g}^{rr}=1$, $\hat{g}^{\theta\theta}=1/r^2$, and $\hat{g}^{\phi\phi}=1/(r^2\sin^2\theta)$ are the only nonzero metric terms for the spherical (contravariant) metric. However, the fact that $u=u(r,t)$ does not depend on the angular pieces greatly simplifies the expression:
\begin{align}
\Box\, u
&= \hat{g}^{\mu\nu} \left[\partial_{\mu} (\partial_{\nu} u) - \hat{\Gamma}^\alpha_{\mu\nu} (\partial_{\alpha} u) \right] \\
&= \left(-\frac{1}{v^2}\partial_t^2 + \partial_r^2\right)u - \hat{\Gamma}^\alpha_{\mu\nu} (\partial_{\alpha} u) \\
&= \left(-\frac{1}{v^2}\partial_t^2 + \partial_r^2\right)u - \hat{g}^{\mu\nu} \left[\hat{\Gamma}^t_{\mu\nu} \partial_{t} + \hat{\Gamma}^r_{\mu\nu} \partial_{r}\right]u.
\end{align}
We will now refer the reader to the [scalar wave in curvilinear coordinates notebook](Tutorial-ScalarWaveCurvilinear.ipynb) for the remainder of the derivation. The bottom line is, after removing terms implying angular variation in $u$, one obtains the wave equation for spherically symmetric waves:
$$
\frac{1}{v^2} \partial_t^2 u = \partial_r^2 u + \frac{2}{r} \partial_r u,
$$
which has the general solution
$$
u(r,t) = A \frac{u(r + vt)}{r} + B \frac{u(r - vt)}{r},
$$
where the (left) right term represents an (ingoing) outgoing wave.
<a id='sbc_ansatz'></a>
## Step 2.c: Sommerfeld boundary condition ansatz \[Back to [top](#toc)\]
$$\label{sbc_ansatz}$$
Inspired by the solution to the scalar wave equation, our Sommerfeld boundary condition will assume the solution $f(r,t)$ acts as an *outgoing* spherical wave ($A=0$), with an asymptotic value $f_0$ at $r\to\infty$ and a correction term for incoming waves or transient non-wavelike behavior at the boundaries, with $r^n$ falloff (ignoring higher-order radial falloffs):
$$
f = f_0 + \frac{u(r-vt)}{r} + \frac{c}{r^n},
$$
where $c$ is a constant.
<a id='sbc_ansatz_dtf'></a>
## Step 2.d: Applying the ansatz to $\partial_t f$ \[Back to [top](#toc)\]
$$\label{sbc_ansatz_dtf}$$
As described in the above section, we will not apply Sommerfeld boundary conditions to $f$ but $\partial_t f$ instead:
$$
\partial_t f = -v \frac{u'(r-vt)}{r}.
$$
To get a better understanding of the $u'(r-vt)$ term, let's compute the radial partial derivative as well:
\begin{align}
\partial_r f &= \frac{u'(r-vt)}{r} - \frac{u(r-vt)}{r^2} - n \frac{c}{r^{n+1}} \\
\implies \frac{u'(r-vt)}{r} &= \partial_r f + \frac{u(r-vt)}{r^2} + n \frac{c}{r^{n+1}}
\end{align}
Thus we get
\begin{align}
\partial_t f &= -v \frac{u'(r-vt)}{r} \\
&= -v \left[\partial_r f + \frac{u(r-vt)}{r^2} + n \frac{c}{r^{n+1}} \right]
\end{align}
To take care of the (as-yet) unknown $\frac{u(r-vt)}{r^2}$ term, notice our ansatz
$$
f = f_0 + \frac{u(r-vt)}{r} + \frac{c}{r^n}
$$
implies that
\begin{align}
\frac{f - f_0}{r} &= \frac{u(r-vt)}{r^2} + \frac{c}{r^{n+1}} \\
\implies \frac{u(r-vt)}{r^2} &= \frac{f - f_0}{r} - \frac{c}{r^{n+1}}
\end{align}
so we have
\begin{align}
\partial_t f &= -v \left[\partial_r f + \frac{u(r-vt)}{r^2} + n \frac{c}{r^{n+1}} \right]\\
&= -v \left[\partial_r f + \frac{f - f_0}{r} - \frac{c}{r^{n+1}} + n \frac{c}{r^{n+1}} \right] \\
&= -v \left[\partial_r f + \frac{f - f_0}{r}\right] + \frac{k}{r^{n+1}},
\end{align}
where $k=-v c(n-1)$ is just another constant.
Thus we have derived our boundary condition:
$$
\boxed{
\partial_t f = -\frac{v}{r} \left[r \partial_r f + (f - f_0)\right] + \frac{k}{r^{n+1}}.
}
$$
<a id='curvicoords'></a>
## Step 2.e: Implementation in generic curvilinear coordinates \[Back to [top](#toc)\]
$$\label{curvicoords}$$
The core equation
$$
\boxed{
\partial_t f = -\frac{v}{r} \left[r \partial_r f + (f - f_0)\right] + \frac{k}{r^{n+1}}.
}
$$
is implemented in NRPy+ using its `reference_metric.py` module ([Tutorial notebook](Tutorial-Reference_Metric.ipynb)), as this module requires *all* coordinate systems to define the spherical coordinate $r$ in terms of input quantities `(xx0,xx1,xx2)`. Thus we need only rewrite the above equation in terms of `(xx0,xx1,xx2)`. Defining $x^i$=`(xx0,xx1,xx2)`, we have, using the chain rule:
\begin{align}
\partial_t f &= -\frac{v}{r} \left[r \partial_r f + (f - f_0)\right] + \frac{k}{r^{n+1}} \\
&= -\frac{v}{r(x^i)} \left[r \frac{\partial x^i}{\partial r} \partial_i f + (f - f_0)\right] + \frac{k}{r^{n+1}}.
\end{align}
$\frac{\partial x^i}{\partial r}$ can be impossible to compute directly, as we are given $r(x^i)$ but not necessarily $x^i(r)$. The key here is to note that we are actually given $x^j_{\rm Sph} = (r(x^i),\theta(x^i),\phi(x^i))$ for all coordinate systems, so we can define the Jacobian
$$\frac{\partial x^j_{\rm Sph}(x^i)}{\partial x^i},$$
and NRPy+ can invert this matrix to give us
$$\frac{\partial x^i}{\partial x^j_{\rm Sph}},$$
In summary, the implementation of Sommerfeld boundary conditions in arbitrary curvilinear coordinates $x^i=$`(xx0,xx1,xx2)` is given by
$$
\boxed{
\partial_t f = -\frac{v}{r(x^i)} \left[r(x^i) \frac{\partial x^i}{\partial r} \partial_i f + (f - f_0)\right] + \frac{k}{r^{n+1}}.
}
$$
In the next subsections, we'll work through implementation of this general equation in the special case of Cartesian coordinates, first by hand, and then *automatically*, for Cartesian *or other curvilinear coordinate systems supported by NRPy+* using `reference_metric.py`.
<a id='cartcoords_byhand'></a>
### Step 2.e.i: Sommerfeld boundary conditions implementation in Cartesian coordinates, derived by hand \[Back to [top](#toc)\]
$$\label{cartcoords_byhand}$$
Let's now work this out for Cartesian coordinates in NRPy+, first by hand, and then using `reference_metric.py`:
In Cartesian coordinates $\frac{\partial f}{\partial r}$ may be expanded as
$$
\frac{\partial f}{\partial r} = \frac{\partial x}{\partial r} \partial_x f + \frac{\partial y}{\partial r}\partial_y f + \frac{\partial z}{\partial r}\partial_z f.
$$
Defining $x^i$ to the the $i$th component of the Cartesian reference metric, we have
\begin{align}
x^0 = x &= r\sin\theta \cos\phi \implies \frac{\partial x}{\partial r}=\frac{x}{r}, \\
x^1 = y &= r\sin\theta \sin\phi \implies \frac{\partial y}{\partial r}=\frac{y}{r}, \\
x^2 = z &= r\cos\theta \implies \frac{\partial z}{\partial r}=\frac{z}{r}.
\end{align}
Based on this, we can rewrite the above as
\begin{align}
\frac{\partial f}{\partial r}
&= \frac{x}{r} \partial_x f +\frac{y}{r} \partial_y f +\frac{z}{r} \partial_z f \\
&= \frac{x^0}{r} \partial_0 f +\frac{x^1}{r} \partial_1 f +\frac{x^2}{r} \partial_2 f \\
&= \frac{x^i}{r} \partial_i f,
\end{align}
yielding the Sommerfeld boundary condition in *Cartesian coordinates*
$$
\partial_t f = -\frac{v}{r} \left[x^i \partial_i f + \left( f - f_0 \right) \right] + \frac{k}{r^{n+1}}.
$$
<a id='cartcoords_bynrpysympy'></a>
### Step 2.e.ii: Sommerfeld boundary conditions implementation in Cartesian coordinates, derived automatically by NRPy+/SymPy \[Back to [top](#toc)\]
$$\label{cartcoords_bynrpysympy}$$
Now let's use NRPy+'s `reference_metric.py` to obtain the same expression for $\frac{\partial f}{\partial r}$ in Cartesian coordinates; i.e.,
$$
\frac{\partial f}{\partial r} = \frac{x^i}{r} \partial_i f,
$$
but using the generic coordinate system interface (`CoordSystem=Cartesian`; feel free to change it to another coordinate system of your choice). Note in the above that me we must also know the functional form of $r(x^i)$, so we use NRPy's `outputC` module to output the C code to calculate $r(x^i)$ and $\frac{\partial x^i}{\partial r} \partial_i f$, as shown below.
<a id='numalg'></a>
# Step 3: Numerical algorithm overview \[Back to [top](#toc)\]
$$\label{numalg}$$
To implement the above Sommerfeld boundary condition, we must specify for each dynamical variable:
* its wave speed at the boundary,
* its asymptotic value at infinity, and
* its $r^{n+1}$ power that must be applied for the non-wavelike behavior at the boundary.
Note in our ansatz
$$
f = f_0 + \frac{u(r-vt)}{r} + \frac{c}{r^n},
$$
in this expansion it would be natural to have $n = 2$, but in the boundary condition we have
$$
\partial_t f = -\frac{v}{r(x^i)} \left[r(x^i) \frac{\partial x^i}{\partial r} \partial_i f + (f - f_0)\right] + \frac{k}{r^{n+1}}.
$$
Thus, the exponent in the $k$ term should be 3. And indeed, in our own implementations we have found that $n=2$ exhibits the best results for minimal reflections. The [Einstein Toolkit's NewRad boundary condition driver](https://www.einsteintoolkit.org/thornguide/EinsteinEvolve/NewRad/documentation.html#XEinsteinEvolve_NewRad_Alcubierre:2002kk) documentation page also states similar results, writing "empirically, we have found that taking (exponent $ = 3$) almost completely eliminates the bad transient caused by the radiative boundary condition on its own". The following set of code cells implement the above equation, excluding the $\frac{k}{r^{n+1}}$ term, for a Cartesian grid.
Our procedure in implementing this boundary condition is as follows:
0) Define data for $f$ at **all** points in our numerical domain
1) Evaluate $\frac{df}{dt}$ at points in the **interior** only, using the prescribed equations to evaluate the RHS and ghost zones for the finite differences at the outer boundaries
2) For points in the ghost zones, apply the Sommerfeld condition to obtain $\frac{df}{dt}$ in the ghost zones, assuming advection and radial fall off behavior. When evaluating the spatial derivatives, use forward or backward finite differences for directions perpendicular to the outer boundary face being considered, and centered derivatives for the directions which lie in the plane of the outer boundary face. Furthermore, to minimize error we loop through inner boundary points and work outwards, so that the forward or backward stencils never include untreated points.
3) Account for non-wavelike evolution of our numerical solution at the boundary
4) Perform RK-update for all points (interior + ghost zones). Since the mapping to outside our numerical domain is linear, treatment of points in the interior and points on the boundary must be at the same time level.
<a id='class'></a>
## Step 3.a: Sommerfeld python class and parameters \[Back to [top](#toc)\]
$$\label{class}$$
First we define the python class __sommerfeld_boundary_condition_class__, where we store all variables and functions related to the our impementation of the Sommerfeld boundary condition. When calling the class, users can set default values for each dynamical variable's value at infinity, radial fall-off power, and wave speed at the boundary.
Next we define the function _sommerfeld_params_ which writes these parameters to lists in C, which will be used by the main C code.
```python
%%writefile $Ccodesdir/Sommerfeld.py
class sommerfeld_boundary_condition_class():
"""
Class for generating C code to apply Sommerfeld boundary conditions
"""
# class variables should be the resulting dicts
# Set class variable default values
# radial falloff power n = 3 has been found to yield the best results
# - see Tutorial-SommerfeldBoundaryCondition.ipynb Step 2 for details
def __init__(self, fd_order=2, vars_at_inf_default = 0., vars_radial_falloff_power_default = 3., vars_speed_default = 1.):
evolved_variables_list, _, _ = gri.gridfunction_lists()
# set class finite differencing order
self.fd_order = fd_order
NRPy_FD_order = par.parval_from_str("finite_difference::FD_CENTDERIVS_ORDER")
if NRPy_FD_order < fd_order:
print("ERROR: The global central finite differencing order within NRPy+ must be greater than or equal to the Sommerfeld boundary condition's finite differencing order")
sys.exit(1)
# Define class dictionaries to store sommerfeld parameters for each EVOL gridfunction
# EVOL gridfunction asymptotic value at infinity
self.vars_at_infinity = {}
# EVOL gridfunction wave speed at outer boundaries
self.vars_speed = {}
# EVOL gridfunction radial falloff power
self.vars_radial_falloff_power = {}
# Set default values for each specific EVOL gridfunction
for gf in evolved_variables_list:
self.vars_at_infinity[gf.upper() + 'GF'] = vars_at_inf_default
self.vars_radial_falloff_power[gf.upper() + 'GF'] = vars_radial_falloff_power_default
self.vars_speed[gf.upper() + 'GF'] = vars_speed_default
def sommerfeld_params(self):
# Write parameters to C file
# Creating array for EVOL gridfunction values at infinity
var_at_inf_string = "{"
for _gf,val in self.vars_at_infinity.items():
var_at_inf_string += str(val) + ", "
var_at_inf_string = var_at_inf_string[:-2] + "};"
# Creating array for EVOL gridfunction values of radial falloff power
vars_radial_falloff_power_string = "{"
for _gf,val in self.vars_radial_falloff_power.items():
vars_radial_falloff_power_string += str(val) + ", "
vars_radial_falloff_power_string = vars_radial_falloff_power_string[:-2] + "};"
# Creating array for EVOL gridfunction values of wave speed at outer boundaries
var_speed_string = "{"
for _gf,val in self.vars_speed.items():
var_speed_string += str(val) + ", "
var_speed_string = var_speed_string[:-2] + "};"
# Writing to values to sommerfeld_params.h file
out_str = """
// Sommerfeld EVOL grid function parameters
const REAL evolgf_at_inf[NUM_EVOL_GFS] = """+var_at_inf_string+"""
const REAL evolgf_radial_falloff_power[NUM_EVOL_GFS] = """+vars_radial_falloff_power_string+"""
const REAL evolgf_speed[NUM_EVOL_GFS] = """+var_speed_string+"""
"""
return out_str
```
Writing SommerfeldBoundaryCondition_Validate/Sommerfeld.py
<a id='partial_rf'></a>
## Step 3.b: Calculate $\partial_r f$ \[Back to [top](#toc)\]
$$\label{partial_rf}$$
Next we generate the C code for calculating $\partial_r f$ for each dynamical variable $f$ in our coordinate system of choice.
```python
%%writefile -a $Ccodesdir/Sommerfeld.py
@staticmethod
def dfdr_function(fd_order):
# function to write c code to calculate dfdr term in Sommerfeld boundary condition
# Read what # of dimensions being usded
DIM = par.parval_from_str("grid::DIM")
# Set up the chosen reference metric from chosen coordinate system, set within NRPy+
CoordSystem = par.parval_from_str("reference_metric::CoordSystem")
rfm.reference_metric()
# Simplifying the results make them easier to interpret.
do_simplify = True
if "Sinh" in CoordSystem:
# Simplification takes too long on Sinh* coordinate systems
do_simplify = False
# Construct Jacobian matrix, output Jac_dUSph_dDrfmUD[i][j] = \partial x_{Sph}^i / \partial x^j:
Jac_dUSph_dDrfmUD = ixp.zerorank2()
for i in range(3):
for j in range(3):
Jac_dUSph_dDrfmUD[i][j] = sp.diff(rfm.xxSph[i],rfm.xx[j])
# Invert Jacobian matrix, output to Jac_dUrfm_dDSphUD.
Jac_dUrfm_dDSphUD, dummyDET = ixp.generic_matrix_inverter3x3(Jac_dUSph_dDrfmUD)
# Jac_dUrfm_dDSphUD[i][0] stores \partial x^i / \partial r
if do_simplify:
for i in range(3):
Jac_dUrfm_dDSphUD[i][0] = sp.simplify(Jac_dUrfm_dDSphUD[i][0])
# Declare \partial_i f, which is actually computed later on
fdD = ixp.declarerank1("fdD") # = [fdD0, fdD1, fdD2]
contraction = sp.sympify(0)
for i in range(3):
contraction += fdD[i]*Jac_dUrfm_dDSphUD[i][0]
if do_simplify:
contraction = sp.simplify(contraction)
r_str_and_contraction_str = outputC([rfm.xxSph[0],contraction],
["*_r","*_partial_i_f"],filename="returnstring",params="includebraces=False")
```
Appending to SommerfeldBoundaryCondition_Validate/Sommerfeld.py
Here we generate the C code used to calculate all relevant spatial derivatives $\partial_i f$, using second order accurate finite differences. Specifically, if our ghost zone point lies on one of the faces, on an edge or corner, we use forward or backward differences depending on the specific direction, and centered differences otherwise. Note that all derivatives along the normal of the boundary faces are forward or backward, to minimize using non-updated points in the derivative calculations.
For example, consider some point with Cartesian coordinates $(i,j,k)$ on our grid, the derivative of $f$ along the $x$ direction will be the forward (backward with change of signs on coefficients)
$$
\frac{\partial f_{ijk}}{\partial x} \approx \frac{1}{2\Delta x} \left( -3f_{i,j,k} + 4f_{i+1,j,k} - f_{i+2,j,k} \right),
$$
or the ceneterd difference approximation
$$
\frac{\partial f_{ijk}}{\partial x} \approx \frac{1}{2\Delta x} \left( f_{i+1,j,k} - f_{i-1,j,k} \right).
$$
We determine the signs of the coefficents (corresponding to using either a foward or backward difference) by determining what face the point lies within. The above is applied for all three Cartesian directions. Note the use if the `SHIFTSTENCIL` variable, which helps determine when to use forward/backward difference to take derivatives along normals to boundary faces, or when to use central differences to either take derivatives parallel to the faces or at points on edges and corners.
```python
%%writefile -a $Ccodesdir/Sommerfeld.py
def gen_central_2oFD_stencil_str(intdirn):
if intdirn == 0:
return "(gfs[IDX4S(which_gf,i0+1,i1,i2)]-gfs[IDX4S(which_gf,i0-1,i1,i2)])*0.5" # Does not include the 1/dx multiplication
if intdirn == 1:
return "(gfs[IDX4S(which_gf,i0,i1+1,i2)]-gfs[IDX4S(which_gf,i0,i1-1,i2)])*0.5" # Does not include the 1/dy multiplication
return "(gfs[IDX4S(which_gf,i0,i1,i2+1)]-gfs[IDX4S(which_gf,i0,i1,i2-1)])*0.5" # Does not include the 1/dz multiplication
def gen_central_4oFD_stencil_str(intdirn):
if intdirn == 0:
return """(-c2*gfs[IDX4S(which_gf,i0+2,i1,i2)]
+c1*gfs[IDX4S(which_gf,i0+1,i1,i2)]
-c1*gfs[IDX4S(which_gf,i0-1,i1,i2)]
+c2*gfs[IDX4S(which_gf,i0-2,i1,i2)])""" # Does not include the 1/dx multiplication
if intdirn == 1:
return """(-c2*gfs[IDX4S(which_gf,i0,i1+2,i2)]
+c1*gfs[IDX4S(which_gf,i0,i1+1,i2)]
-c1*gfs[IDX4S(which_gf,i0,i1-1,i2)]
+c2*gfs[IDX4S(which_gf,i0,i1-2,i2)])""" # Does not include the 1/dy multiplication
return """(-c2*gfs[IDX4S(which_gf,i0,i1,i2+2)]
+c1*gfs[IDX4S(which_gf,i0,i1,i2+1)]
-c1*gfs[IDX4S(which_gf,i0,i1,i2-1)]
+c2*gfs[IDX4S(which_gf,i0,i1,i2-2)])""" # Does not include the 1/dz multiplication
def gen_central_6oFD_stencil_str(intdirn):
if intdirn == 0:
return """( c3*gfs[IDX4S(which_gf,i0+3,i1,i2)]
-c2*gfs[IDX4S(which_gf,i0+2,i1,i2)]
+c1*gfs[IDX4S(which_gf,i0+1,i1,i2)]
-c1*gfs[IDX4S(which_gf,i0-1,i1,i2)]
+c2*gfs[IDX4S(which_gf,i0-2,i1,i2)]
-c3*gfs[IDX4S(which_gf,i0-3,i1,i2)])""" # Does not include the 1/dx multiplication
if intdirn == 1:
return """( c3*gfs[IDX4S(which_gf,i0,i1+3,i2)]
-c2*gfs[IDX4S(which_gf,i0,i1+2,i2)]
+c1*gfs[IDX4S(which_gf,i0,i1+1,i2)]
-c1*gfs[IDX4S(which_gf,i0,i1-1,i2)]
+c2*gfs[IDX4S(which_gf,i0,i1-2,i2)]
-c3*gfs[IDX4S(which_gf,i0,i1-3,i2)])""" # Does not include the 1/dy multiplication
return """( c3*gfs[IDX4S(which_gf,i0,i1,i2+3)]
-c2*gfs[IDX4S(which_gf,i0,i1,i2+2)]
+c1*gfs[IDX4S(which_gf,i0,i1,i2+1)]
-c1*gfs[IDX4S(which_gf,i0,i1,i2-1)]
+c2*gfs[IDX4S(which_gf,i0,i1,i2-2)]
-c3*gfs[IDX4S(which_gf,i0,i1,i2-3)])""" # Does not include the 1/dz multiplication
def gen_central_fd_stencil_str(intdirn, fd_order):
if fd_order==2:
return gen_central_2oFD_stencil_str(intdirn)
if fd_order==4:
return gen_central_4oFD_stencil_str(intdirn)
return gen_central_6oFD_stencil_str(intdirn)
def output_dfdx(intdirn, fd_order):
dirn = str(intdirn)
dirnp1 = str((intdirn+1)%3) # if dirn='0', then we want this to be '1'; '1' then '2'; and '2' then '0'
dirnp2 = str((intdirn+2)%3) # if dirn='0', then we want this to be '2'; '1' then '0'; and '2' then '1'
preface = """
// On a +x"""+dirn+""" or -x"""+dirn+""" face, do up/down winding as appropriate:
if(abs(FACEXi["""+dirn+"""])==1 || i"""+dirn+"""+NGHOSTS >= Nxx_plus_2NGHOSTS"""+dirn+""" || i"""+dirn+"""-NGHOSTS <= 0) {
int8_t SHIFTSTENCIL"""+dirn+""" = FACEXi["""+dirn+"""];
if(i"""+dirn+"""+NGHOSTS >= Nxx_plus_2NGHOSTS"""+dirn+""") SHIFTSTENCIL"""+dirn+""" = -1;
if(i"""+dirn+"""-NGHOSTS <= 0) SHIFTSTENCIL"""+dirn+""" = +1;
SHIFTSTENCIL"""+dirnp1+""" = 0;
SHIFTSTENCIL"""+dirnp2+""" = 0;
"""
if fd_order == 2:
return preface + """
fdD"""+dirn+"""
= SHIFTSTENCIL"""+dirn+"""*(-1.5*gfs[IDX4S(which_gf,i0+0*SHIFTSTENCIL0,i1+0*SHIFTSTENCIL1,i2+0*SHIFTSTENCIL2)]
+2.*gfs[IDX4S(which_gf,i0+1*SHIFTSTENCIL0,i1+1*SHIFTSTENCIL1,i2+1*SHIFTSTENCIL2)]
-0.5*gfs[IDX4S(which_gf,i0+2*SHIFTSTENCIL0,i1+2*SHIFTSTENCIL1,i2+2*SHIFTSTENCIL2)]
)*invdx"""+dirn+""";
// Not on a +x"""+dirn+""" or -x"""+dirn+""" face, using centered difference:
} else {
fdD"""+dirn+""" = """+gen_central_fd_stencil_str(intdirn, 2)+"""*invdx"""+dirn+""";
}
"""
if fd_order == 4:
return preface + """
fdD"""+dirn+"""
= SHIFTSTENCIL"""+dirn+"""*(u0*gfs[IDX4S(which_gf,i0+0*SHIFTSTENCIL0,i1+0*SHIFTSTENCIL1,i2+0*SHIFTSTENCIL2)]
+u1*gfs[IDX4S(which_gf,i0+1*SHIFTSTENCIL0,i1+1*SHIFTSTENCIL1,i2+1*SHIFTSTENCIL2)]
+u2*gfs[IDX4S(which_gf,i0+2*SHIFTSTENCIL0,i1+2*SHIFTSTENCIL1,i2+2*SHIFTSTENCIL2)]
+u3*gfs[IDX4S(which_gf,i0+3*SHIFTSTENCIL0,i1+3*SHIFTSTENCIL1,i2+3*SHIFTSTENCIL2)]
+u4*gfs[IDX4S(which_gf,i0+4*SHIFTSTENCIL0,i1+4*SHIFTSTENCIL1,i2+4*SHIFTSTENCIL2)]
)*invdx"""+dirn+""";
// Not on a +x"""+dirn+""" or -x"""+dirn+""" face, using centered difference:
} else {
fdD"""+dirn+""" = """+gen_central_fd_stencil_str(intdirn, 4)+"""*invdx"""+dirn+""";
}
"""
if fd_order == 6:
return preface + """
fdD"""+dirn+"""
= SHIFTSTENCIL"""+dirn+"""*(u0*gfs[IDX4S(which_gf,i0+0*SHIFTSTENCIL0,i1+0*SHIFTSTENCIL1,i2+0*SHIFTSTENCIL2)]
+u1*gfs[IDX4S(which_gf,i0+1*SHIFTSTENCIL0,i1+1*SHIFTSTENCIL1,i2+1*SHIFTSTENCIL2)]
+u2*gfs[IDX4S(which_gf,i0+2*SHIFTSTENCIL0,i1+2*SHIFTSTENCIL1,i2+2*SHIFTSTENCIL2)]
+u3*gfs[IDX4S(which_gf,i0+3*SHIFTSTENCIL0,i1+3*SHIFTSTENCIL1,i2+3*SHIFTSTENCIL2)]
+u4*gfs[IDX4S(which_gf,i0+4*SHIFTSTENCIL0,i1+4*SHIFTSTENCIL1,i2+4*SHIFTSTENCIL2)]
+u5*gfs[IDX4S(which_gf,i0+5*SHIFTSTENCIL0,i1+5*SHIFTSTENCIL1,i2+5*SHIFTSTENCIL2)]
+u6*gfs[IDX4S(which_gf,i0+6*SHIFTSTENCIL0,i1+6*SHIFTSTENCIL1,i2+6*SHIFTSTENCIL2)]
)*invdx"""+dirn+""";
// Not on a +x"""+dirn+""" or -x"""+dirn+""" face, using centered difference:
} else {
fdD"""+dirn+""" = """+gen_central_fd_stencil_str(intdirn, 6)+"""*invdx"""+dirn+""";
}
"""
print("Error: fd_order = "+str(fd_order)+" currently unsupported.")
sys.exit(1)
contraction_term_func = """
// Function to calculate the radial derivative of a grid function
void contraction_term(const paramstruct *restrict params, const int which_gf, const REAL *restrict gfs, REAL *restrict xx[3],
const int8_t FACEXi[3], const int i0, const int i1, const int i2, REAL *restrict _r, REAL *restrict _partial_i_f) {
#include "RELATIVE_PATH__set_Cparameters.h" /* Header file containing correct #include for set_Cparameters.h;
* accounting for the relative path */
// Initialize derivatives to crazy values, to ensure that
// we will notice in case they aren't set properly.
REAL fdD0=1e100;
REAL fdD1=1e100;
REAL fdD2=1e100;
REAL xx0 = xx[0][i0];
REAL xx1 = xx[1][i1];
REAL xx2 = xx[2][i2];
int8_t SHIFTSTENCIL0;
int8_t SHIFTSTENCIL1;
int8_t SHIFTSTENCIL2;
"""
if fd_order == 4:
contraction_term_func +="""
// foward/backward finite difference coefficients
const REAL u0 =-25./12.;
const REAL u1 = 4.;
const REAL u2 = -3.;
const REAL u3 = 4./3.;
const REAL u4 = -1./4.;
// central finite difference coefficients
const REAL c1 = 2./3.;
const REAL c2 = 1./12.;
"""
if fd_order == 6:
contraction_term_func +="""
// foward/backward finite difference coefficients
const REAL u0 = -49./20.;
const REAL u1 = 6.;
const REAL u2 = -15./2.;
const REAL u3 = 20./3.;
const REAL u4 = -15./4.;
const REAL u5 = 6./5.;
const REAL u6 = -1./6.;
// central finite difference coefficients
const REAL c1 = 3./4.;
const REAL c2 = 3./20.;
const REAL c3 = 1./60;
"""
for i in range(DIM):
if "fdD"+str(i) in r_str_and_contraction_str:
contraction_term_func += output_dfdx(i, fd_order)
contraction_term_func += "\n" + r_str_and_contraction_str
contraction_term_func +="""
} // END contraction_term function
"""
return contraction_term_func
```
Appending to SommerfeldBoundaryCondition_Validate/Sommerfeld.py
<a id='cfunc'></a>
## Step 3.c: `apply_bcs_sommerfeld()` C function \[Back to [top](#toc)\]
$$\label{cfunc}$$
Here, we build up the main C code and define the function `apply_bcs_sommerfeld()` to be used by NRPy's MoL time stepping algorithm.
```python
%%writefile -a $Ccodesdir/Sommerfeld.py
def write_sommerfeld_main_Ccode(self, Ccodesdir):
main_Ccode = """
// Boundary condtion driver routine: Apply BCs to all
// boundary faces of the 3D numerical domain, filling in the
// outer boundary ghost zone layers, starting with the innermost
// layer and working outward.
"""
main_Ccode += self.sommerfeld_params()
main_Ccode += self.dfdr_function(self.fd_order)
main_Ccode += """
void apply_bcs_sommerfeld(const paramstruct *restrict params, REAL *restrict xx[3],
const bc_struct *restrict bcstruct, const int NUM_GFS,
const int8_t *restrict gfs_parity, REAL *restrict gfs,
REAL *restrict rhs_gfs) {
#pragma omp parallel for
for(int which_gf=0;which_gf<NUM_GFS;which_gf++) {
const REAL char_speed = evolgf_speed[which_gf];
const REAL var_at_infinity = evolgf_at_inf[which_gf];
const REAL radial_falloff_power = evolgf_radial_falloff_power[which_gf];
#include "RELATIVE_PATH__set_Cparameters.h" /* Header file containing correct #include for set_Cparameters.h;
* accounting for the relative path */
for(int which_gz = 0; which_gz < NGHOSTS; which_gz++) {
for(int pt=0;pt<bcstruct->num_ob_gz_pts[which_gz];pt++) {
const int i0 = bcstruct->outer[which_gz][pt].outer_bc_dest_pt.i0;
const int i1 = bcstruct->outer[which_gz][pt].outer_bc_dest_pt.i1;
const int i2 = bcstruct->outer[which_gz][pt].outer_bc_dest_pt.i2;
const int8_t FACEX0 = bcstruct->outer[which_gz][pt].FACEi0;
const int8_t FACEX1 = bcstruct->outer[which_gz][pt].FACEi1;
const int8_t FACEX2 = bcstruct->outer[which_gz][pt].FACEi2;
const int8_t FACEXi[3] = {FACEX0, FACEX1, FACEX2};
// Initialize derivatives to crazy values, to ensure that
// we will notice in case they aren't set properly.
REAL r = 1e100;
REAL partial_i_f = 1e100;
```
Appending to SommerfeldBoundaryCondition_Validate/Sommerfeld.py
Finally, we calculate $\frac{df}{dt}$ without the $\frac{k}{r^{n+1}}$ term;
$$
\frac{\partial f}{\partial t} = -\frac{v}{r} \left( x^i \partial_i f + \left( f - f_0 \right) \right).
$$
```python
%%writefile -a $Ccodesdir/Sommerfeld.py
contraction_term(params, which_gf, gfs, xx, FACEXi, i0, i1, i2, &r, &partial_i_f);
const REAL invr = 1./r;
const REAL source_rhs = -char_speed*(partial_i_f + invr*(gfs[IDX4S(which_gf,i0,i1,i2)] - var_at_infinity));
rhs_gfs[IDX4S(which_gf,i0,i1,i2)] = source_rhs;
```
Appending to SommerfeldBoundaryCondition_Validate/Sommerfeld.py
<a id='k'></a>
## Step 3.d: Solving for $k$ \[Back to [top](#toc)\]
$$\label{k}$$
Here we formulate a way to approximate $k$. If our solution satisfies the advection equation both at the ghost zones and at interior points close to the boundaries, then we may find $k$ by determining the portion of $f$ that is not accounted for by the equation
$$
\frac{\partial f}{\partial t} = \left[\frac{\partial f}{\partial t} \right]_{adv}= -\frac{v}{r} \left( x^i \partial_i f + \left( f - f_0 \right) \right).
$$
The above is the advection equation we arrive at assuming $f$ behaves purely as an outgoing spherical wave. For an interior point directly adjacent to a ghost zone point, $f$ must satisfy **both** the time evolution equation for prescribed points within the interior, $\left[\frac{\partial f}{\partial t} \right]_{evol}$, and the advection equation $\left[\frac{\partial f}{\partial t} \right]_{adv}$. We then find the difference as
$$
\delta = \left[\frac{\partial f}{\partial t} \right]_{evol} - \left[\frac{\partial f}{\partial t} \right]_{adv} = \frac{k}{r^{n+1}},
$$
i.e. $\delta$ represents the numerical departure from the expected purely wave-like behavior at that point. We solve for $\delta$ at this interior point and express $k$ as
$$
k = \delta r^{n+1}_{int}.
$$
Thus, the $\frac{k}{r^{n+1}}$ term for the associated ghost zone point may be expressed as
$$
\frac{k}{r^{n+1}_{gz}} = \delta \left( \frac{r_{int}}{r_{gz}} \right) ^{n+1}.
$$
We approximate $k$ in this fashion using the code below. Note that we activate this term only when *radial_falloff_power* > 0, which set to 3 by default.
```python
%%writefile -a $Ccodesdir/Sommerfeld.py
/************* For radial falloff and the extrapolated k term *************/
if (radial_falloff_power > 0) {
// Move one point away from gz point to compare pure advection to df/dt|interior
const int i0_offset = i0+FACEX0;
const int i1_offset = i1+FACEX1;
const int i2_offset = i2+FACEX2;
// Initialize derivatives to crazy values, to ensure that
// we will notice in case they aren't set properly.
REAL r_offset = 1e100;
REAL partial_i_f_offset = 1e100;
contraction_term(params, which_gf, gfs, xx, FACEXi, i0_offset, i1_offset, i2_offset, &r_offset, &partial_i_f_offset);
const REAL invr_offset = 1./r_offset;
// Pure advection: [FIXME: Add equation (appearing in Jupyter notebook documentation)]
const REAL extrap_rhs = char_speed*(partial_i_f_offset + invr_offset*(gfs[IDX4S(which_gf,i0_offset,i1_offset,i2_offset)] - var_at_infinity));
// Take difference between pure advection and df/dt|interior
const REAL diff_between_advection_and_f_rhs =
rhs_gfs[IDX4S(which_gf,i0_offset,i1_offset,i2_offset)] + extrap_rhs;
// Solve for k/(r_gz)^n+1 term
rhs_gfs[IDX4S(which_gf,i0,i1,i2)] += diff_between_advection_and_f_rhs*pow(r_offset*invr,radial_falloff_power);
}
} // END for(int pt=0;pt<num_ob_gz_pts[which_gz];pt++)
```
Appending to SommerfeldBoundaryCondition_Validate/Sommerfeld.py
<a id='innerbcs'></a>
## Step 3.e: Inner Boundary Conditions \[Back to [top](#toc)\]
$$\label{innerbcs}$$
Finally, we apply parity conditions for inner boundary conditions. Since the Sommerfeld boundary condition treats the right hand sides, these data are thus copied over to the right hand sides of points in the inner boundaries, according to appropriate parity conditions. For a detailed disussion on inner boundaries and parity conditions, see [Tutorial-Start_to_Finish-Curvilinear_BCs](Tutorial-Start_to_Finish-Curvilinear_BCs.ipynb).
```python
%%writefile -a $Ccodesdir/Sommerfeld.py
// Apply INNER (parity) boundary conditions:
for(int pt=0;pt<bcstruct->num_ib_gz_pts[which_gz];pt++) {
const int i0dest = bcstruct->inner[which_gz][pt].inner_bc_dest_pt.i0;
const int i1dest = bcstruct->inner[which_gz][pt].inner_bc_dest_pt.i1;
const int i2dest = bcstruct->inner[which_gz][pt].inner_bc_dest_pt.i2;
const int i0src = bcstruct->inner[which_gz][pt].inner_bc_src_pt.i0;
const int i1src = bcstruct->inner[which_gz][pt].inner_bc_src_pt.i1;
const int i2src = bcstruct->inner[which_gz][pt].inner_bc_src_pt.i2;
rhs_gfs[IDX4S(which_gf,i0dest,i1dest,i2dest)] =
bcstruct->inner[which_gz][pt].parity[gfs_parity[which_gf]] * rhs_gfs[IDX4S(which_gf, i0src,i1src,i2src)];
} // END for(int pt=0;pt<num_ib_gz_pts[which_gz];pt++)
} // END for(int which_gz = 0; which_gz < NGHOSTS; which_gz++)
} // END for(int which_gf=0;which_gf<NUM_GFS;which_gf++)
} // END function
"""
```
Appending to SommerfeldBoundaryCondition_Validate/Sommerfeld.py
Here we write the entire function to a C file.
```python
%%writefile -a $Ccodesdir/Sommerfeld.py
with open(os.path.join(Ccodesdir,"boundary_conditions/apply_bcs_sommerfeld.h"),"w") as file:
file.write(main_Ccode)
def write_sommerfeld_file(self, Ccodesdir):
self.write_sommerfeld_main_Ccode(Ccodesdir)
print("""\nSuccessfully generated Sommerfeld boundary condition C code""")
```
Appending to SommerfeldBoundaryCondition_Validate/Sommerfeld.py
<a id='py_validate'></a>
# Step 4: Python file validation \[Back to [top](#toc)\]
$$\label{py_validate}$$
Here we validate the python code generated by this notebook, [SommerfeldBoundaryCondition_Validate/Sommerfeld.py](../edit/SommerfeldBoundaryCondition_Validate/Sommerfeld.py), against the trusted code in [CurviBoundaryConditions/CurviBoundaryConditions.py](../edit/CurviBoundaryConditions/CurviBoundaryConditions.py) line by line. Passing corresponds to complete agreement between the files.
Note that there is more content [CurviBoundaryConditions/CurviBoundaryConditions.py](../edit/CurviBoundaryConditions/CurviBoundaryConditions.py) relating to more than just the Sommerfeld boundary condition, so we start the comparison where the Sommerfeld code begins.
```python
# Then compare all files generated by this notebook
# (output moved in previous code cell to validate/)
# and the separate Python module (output to Baikal
# and BaikalVacuum).
import difflib
def compare_two_files(filepath1,filepath2, file1_idx1=None):
with open(filepath1) as file1, open(filepath2) as file2:
# Read the lines of each file
file1_lines = file1.readlines()
file2_lines = file2.readlines()
if file1_idx1!=None:
file1_lines = file1_lines[file1_idx1:]
# print(file1_lines)
num_diffs = 0
file1_lines_noleadingwhitespace = []
for line in file1_lines:
if line.strip() == "": # If the line contains only whitespace, remove all leading whitespace
file1_lines_noleadingwhitespace.append(line.lstrip())
else:
file1_lines_noleadingwhitespace.append(line)
file2_lines_noleadingwhitespace = []
for line in file2_lines:
if line.strip() == "": # If the line contains only whitespace, remove all leading whitespace
file2_lines_noleadingwhitespace.append(line.lstrip())
else:
file2_lines_noleadingwhitespace.append(line)
for line in difflib.unified_diff(file1_lines_noleadingwhitespace, file2_lines_noleadingwhitespace,
fromfile=filepath1,
tofile =filepath2):
sys.stdout.writelines(line)
num_diffs = num_diffs + 1
if num_diffs == 0:
print("PASSED: "+filepath2+" matches trusted version")
else:
print("FAILED (see diff above): "+filepath2+" does NOT match trusted version")
import os
notebook_cfile = 'SommerfeldBoundaryCondition_Validate/Sommerfeld.py'
nrpy_cfile = 'CurviBoundaryConditions/CurviBoundaryConditions.py'
idx1=258
compare_two_files(nrpy_cfile, notebook_cfile, idx1)
```
PASSED: SommerfeldBoundaryCondition_Validate/Sommerfeld.py matches trusted version
<a id='interface'></a>
# Step 5: NRPy+ Interface for Applying Sommerfeld Boundary Conditions \[Back to [top](#toc)\]
$$\label{interface}$$
To apply the Sommerfled boundary condition to any given grid function, its wave speed at the boundaries, asymptotic value at infinity, and radial exponent of the k term (*radial_falloff_power*) must be specified. In general, a (*radial_falloff_power*) of 3 has been found to yield the best results, i.e. minimal initial transients and reflections.
Here we showcase the features of the NRPy+ interface for implementing this boundary condition and defining these values. The interface is a python class structure that allows the user to specify default values for each grid function, which may then be changed. This may be useful when the user wants to define the default values for several grid functions but wishes to specifically alter few others.
To begin, we define our global NRPy finite differencing order and our coordinate system of choice. Our Sommerfeld boundary condition driver check that the finite differencing chosen for the driver is less than or equal to the global finite differencing order.
```python
import finite_difference as fin # NRPy+: Finite difference C code generation module
FD_order = 6
par.set_parval_from_str("finite_difference::FD_CENTDERIVS_ORDER",FD_order)
# Set the coordinate system for the numerical grid
# Choices are: Spherical, SinhSpherical, SinhSphericalv2, Cylindrical, SinhCylindrical,
# SymTP, SinhSymTP
CoordSystem = "Spherical"
par.set_parval_from_str("reference_metric::CoordSystem",CoordSystem)
```
Next, let's define a few grid functions. Note that the boundary condition should be used only for variables defined in three spatial dimensions.
```python
# Step P3: Defining a couple of grid functions
uu, vv, ww, xx, yy, zz, = gri.register_gridfunctions("EVOL",["uu","vv","ww","xx","yy","zz"])
```
NRPy+ can now access these grid function names, and will store default values for the boundary condition. First we import `CurviBoundaryConditions.CurviBoundaryConditions`, and define a class instance _bcs_ using `sommerfeld_boundary_condition_class`.
```python
import CurviBoundaryConditions.CurviBoundaryConditions as cbcs
cbcs.Set_up_CurviBoundaryConditions(os.path.join(Ccodesdir,"boundary_conditions/"),
Cparamspath=os.path.join("../"), BoundaryCondition='Sommerfeld')
bcs = cbcs.sommerfeld_boundary_condition_class(fd_order=4,
vars_radial_falloff_power_default=3,
vars_speed_default=1.,
vars_at_inf_default=1.)
# bcs.vars_radpower.items()
bcs.vars_at_infinity['VVGF'] = 0.0
bcs.write_sommerfeld_file(Ccodesdir)
```
Wrote to file "SommerfeldBoundaryCondition_Validate/boundary_conditions/parity_conditions_symbolic_dot_products.h"
Evolved parity: ( uu:0, vv:0, ww:0, xx:0, yy:0, zz:0 )
Wrote to file "SommerfeldBoundaryCondition_Validate/boundary_conditions/EigenCoord_Cart_to_xx.h"
Successfully generated Sommerfeld boundary condition C code
Using the instance _bcs_ we may change these default values using the grid function names, since NRPy+ stores these values in python dictionaries. We then print out the contents of the dictionaries.
```python
# Changing values for uu
bcs.vars_at_infinity['UUGF'] = 5.
bcs.vars_speed['UUGF'] = 0.5
# Changing values for zz
bcs.vars_at_infinity['ZZGF'] = 4.
bcs.vars_speed['ZZGF'] = 2.**0.5
print('GF values at infinity =', bcs.vars_at_infinity.items())
print('GF speeds = ', bcs.vars_speed.items())
print('GF radial powers = ' ,bcs.vars_radial_falloff_power.items())
```
GF values at infinity = dict_items([('UUGF', 5.0), ('VVGF', 0.0), ('WWGF', 1.0), ('XXGF', 1.0), ('YYGF', 1.0), ('ZZGF', 4.0)])
GF speeds = dict_items([('UUGF', 0.5), ('VVGF', 1.0), ('WWGF', 1.0), ('XXGF', 1.0), ('YYGF', 1.0), ('ZZGF', 1.4142135623730951)])
GF radial powers = dict_items([('UUGF', 3), ('VVGF', 3), ('WWGF', 3), ('XXGF', 3), ('YYGF', 3), ('ZZGF', 3)])
Finally, we write these values into the `sommerfeld_params.h` file, and generate the `radial_derivative.h` file, which defines the function used to calculate the $\partial_r f$ term, which our C code may read from later, using the function write_sommerfeld_files(), which takes the C codes directory path and finite differencing order as inputs. __Only second and fourth order finite differences are supported at this time.__
<a id='etk_validation'></a>
# Step 6: Validation against the [Einstein Toolkit's NewRad boundary condition driver](https://www.einsteintoolkit.org/EinsteinEvolve/thornguide/NewRad/documentation.html#XEinsteinEvolve_NewRad_Alcubierre:2002kk) \[Back to [top](#toc)\]
$$\label{etk_validation}$$
Here we showcase some validation results of our Sommerfeld boundary condition as implemented in NRPy+ against [ETK's NewRad boundary condition driver](https://www.einsteintoolkit.org/thornguide/EinsteinEvolve/NewRad/documentation.html#XEinsteinEvolve_NewRad_Alcubierre:2002kk), storing the ETK data and subsequent plots in the [SommerfeldBoundaryCondition folder](SommerfeldBoundaryCondition). Specifically, we do so by
1. Generating plane wave initial data for ETK using the [ETK_thorn-IDScalarWaveNRPy notebook](Tutorial-ETK_thorn-IDScalarWaveNRPy.ipynb), with the NRPy+ code generation documented [here](Tutorial-ScalarWave.ipynb)
2. Generating the ETK evolution C codes using the [ETK_thorn-WaveToyNRPy notebook](Tutorial-ETK_thorn-WaveToyNRPy.ipynb), with the NRPy+ code generation generation also documented [here](Tutorial-ScalarWave.ipynb)
3. Compare results to [Tutorial-Start_to_Finish-ScalarWaveCurvilinear](Tutorial-Start_to_Finish-ScalarWaveCurvilinear.ipynb), adding 1e-16 to the log$_{10}$(relative error) plots to avoid taking the log$_{10}$ of zero where we have perfect agreement. $t$=0.3 represents 6 time steps into the systems
For both the evolution thorn and NRPy+ code we define the gridfunctions __UUGF__ and __VVGF__, use RK4 time stepping, and fourth order finite differencing. For the boundary condition parameters, we set uu_at_infinity = 2.0, vv_at_infinity = 0.0, and char_speed = 1.0, and var_radial_falloff_power = 3.0 for both evolution variables.
First we show validation results for the case of a scalar wave propagating in the +x direction (initial data, documented [here](Tutorial-ScalarWave.ipynb), with kk0 = 1, kk1 = kk2 = 0), overlaying $u\left(x, y=0,z=0,t=0.3\right)$ from the ETK thorn and from NRPy+, and plotting the relative difference between the two.
```python
from IPython.display import Image
from IPython.display import display
x_axis_plot = Image("SommerfeldBoundaryCondition/NRPy_vs_ETK_x-axis.png", width=400, height=400)
E_relx_axis_plot = Image("SommerfeldBoundaryCondition/E_rel_x-axis.png", width=400, height=400)
display(x_axis_plot,E_relx_axis_plot)
```
Lastly we show validation results for the case of a scalar wave propagating along the -x, -y, +z diagonal, and taking a slice along the y-axis at x=z=0 (initial data, documented [here](Tutorial-ScalarWave.ipynb), with kk0 = -1, kk1 = -1, kk2 = 1), overlaying $u\left(x=0, y,z=0,t=0.3\right)$ from the ETK thorn and from NRPy+, and plotting the relative difference between the two.
```python
diagonal = Image("SommerfeldBoundaryCondition/NRPy_vs_ETK_diagonal.png", width=400, height=400)
E_rel_diagonal = Image("SommerfeldBoundaryCondition/E_rel_diagonal.png", width=400, height=400)
display(diagonal, E_rel_diagonal)
```
<a id='latex_pdf_output'></a>
# Step 7: Output this notebook to $\LaTeX$-formatted PDF file \[Back to [top](#toc)\]
$$\label{latex_pdf_output}$$
The following code cell converts this Jupyter notebook into a proper, clickable $\LaTeX$-formatted PDF file. After the cell is successfully run, the generated PDF may be found in the root NRPy+ tutorial directory, with filename
[Tutorial-SommerfeldBoundaryCondition.pdf](Tutorial-SommerfeldBoundaryCondition.pdf) (Note that clicking on this link may not work; you may need to open the PDF file through another means.)
```python
cmd.output_Jupyter_notebook_to_LaTeXed_PDF("Tutorial-SommerfeldBoundaryCondition")
```
Created Tutorial-SommerfeldBoundaryCondition.tex, and compiled LaTeX file
to PDF file Tutorial-SommerfeldBoundaryCondition.pdf
|
module Issue62 where
module A where
data A : Set where
a : A
module B where
open A
data B : Set where
a : B
open B
-- Note that a : A.A is not in scope here, so the following should not
-- type check.
foo : A.A -> A.A
foo a = a
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.AssocList.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Data.Nat using (ℕ; _+_)
private
variable
ℓ : Level
A : Type ℓ
infixr 5 ⟨_,_⟩∷_
data AssocList (A : Type ℓ) : Type ℓ where
⟨⟩ : AssocList A
⟨_,_⟩∷_ : (a : A) (n : ℕ) (xs : AssocList A) → AssocList A
per : ∀ a b xs → ⟨ a , 1 ⟩∷ ⟨ b , 1 ⟩∷ xs
≡ ⟨ b , 1 ⟩∷ ⟨ a , 1 ⟩∷ xs
agg : ∀ a m n xs → ⟨ a , m ⟩∷ ⟨ a , n ⟩∷ xs
≡ ⟨ a , m + n ⟩∷ xs
del : ∀ a xs → ⟨ a , 0 ⟩∷ xs ≡ xs
trunc : isSet (AssocList A)
pattern ⟨_⟩ a = ⟨ a , 1 ⟩∷ ⟨⟩
-- Elimination and recursion principle for association lists
module Elim {ℓ'} {B : AssocList A → Type ℓ'}
(⟨⟩* : B ⟨⟩) (⟨_,_⟩∷*_ : (x : A) (n : ℕ) {xs : AssocList A} → B xs → B (⟨ x , n ⟩∷ xs))
(per* : (x y : A) {xs : AssocList A} (b : B xs)
→ PathP (λ i → B (per x y xs i)) (⟨ x , 1 ⟩∷* ⟨ y , 1 ⟩∷* b) (⟨ y , 1 ⟩∷* ⟨ x , 1 ⟩∷* b))
(agg* : (x : A) (m n : ℕ) {xs : AssocList A} (b : B xs)
→ PathP (λ i → B (agg x m n xs i)) (⟨ x , m ⟩∷* ⟨ x , n ⟩∷* b) (⟨ x , m + n ⟩∷* b))
(del* : (x : A) {xs : AssocList A} (b : B xs)
→ PathP (λ i → B (del x xs i)) (⟨ x , 0 ⟩∷* b) b)
(trunc* : (xs : AssocList A) → isSet (B xs)) where
f : (xs : AssocList A) → B xs
f ⟨⟩ = ⟨⟩*
f (⟨ a , n ⟩∷ xs) = ⟨ a , n ⟩∷* f xs
f (per a b xs i) = per* a b (f xs) i
f (agg a m n xs i) = agg* a m n (f xs) i
f (del a xs i) = del* a (f xs) i
f (trunc xs ys p q i j) = isOfHLevel→isOfHLevelDep 2 trunc* (f xs) (f ys) (cong f p) (cong f q) (trunc xs ys p q) i j
module ElimProp {ℓ'} {B : AssocList A → Type ℓ'} (BProp : {xs : AssocList A} → isProp (B xs))
(⟨⟩* : B ⟨⟩) (⟨_,_⟩∷*_ : (x : A) (n : ℕ) {xs : AssocList A} → B xs → B (⟨ x , n ⟩∷ xs)) where
f : (xs : AssocList A) → B xs
f = Elim.f ⟨⟩* ⟨_,_⟩∷*_
(λ x y {xs} b → toPathP (BProp (transp (λ i → B (per x y xs i)) i0 (⟨ x , 1 ⟩∷* ⟨ y , 1 ⟩∷* b)) (⟨ y , 1 ⟩∷* ⟨ x , 1 ⟩∷* b)))
(λ x m n {xs} b → toPathP (BProp (transp (λ i → B (agg x m n xs i)) i0 (⟨ x , m ⟩∷* ⟨ x , n ⟩∷* b)) (⟨ x , m + n ⟩∷* b)))
(λ x {xs} b → toPathP (BProp (transp (λ i → B (del x xs i)) i0 (⟨ x , 0 ⟩∷* b)) b))
(λ xs → isProp→isSet BProp)
module Rec {ℓ'} {B : Type ℓ'} (BType : isSet B)
(⟨⟩* : B) (⟨_,_⟩∷*_ : (x : A) (n : ℕ) → B → B)
(per* : (x y : A) (b : B) → (⟨ x , 1 ⟩∷* ⟨ y , 1 ⟩∷* b) ≡ (⟨ y , 1 ⟩∷* ⟨ x , 1 ⟩∷* b))
(agg* : (x : A) (m n : ℕ) (b : B) → (⟨ x , m ⟩∷* ⟨ x , n ⟩∷* b) ≡ (⟨ x , m + n ⟩∷* b))
(del* : (x : A) (b : B) → (⟨ x , 0 ⟩∷* b) ≡ b) where
f : AssocList A → B
f = Elim.f ⟨⟩* (λ x n b → ⟨ x , n ⟩∷* b) (λ x y b → per* x y b) (λ x m n b → agg* x m n b) (λ x b → del* x b) (λ _ → BType)
|
% !TEX root = altosaar-2020-thesis.tex
\chapter{Background}
\label{ch:background}
\lettrine[image=true,lines=3]{design/T}{his} chapter describes probabilistic models and probabilistic inference, taking as examples models from statistical physics and recommender systems.
\input{fig/fig_graphical_model_ising}
\section{Probabilistic Models}
Probability models assign probability to configurations of random variables. The random variables in a probability model might correspond to observed variables in a physical system, or to latent properties representing patterns in data collected from the world, or a combination of both. To define a probability model, it is necessary to specify the density $p$ of a collection of random variables $\mbz$. We focus on probabilistic models $p(\mbz)$ where relationships between random variables can be encoded as edges in a graph, or probabilistic graphical models~\citep{jordan2004graphical}.
\subsection{Example: Ising Model}
\label{sec:ising}
For example, consider a model used in statistical physics: the Ising model. The Ising model can be used to model interactions between atoms in a material~\citep{henelius2016refrustration} to study how the material behaves in different conditions, paving the way toward material design. This probabilistic model has binary random variables $z_n$ with density
\begin{equation}
p(\mbz; \beta) = \frac{\exp(-\beta E(\mbz))}{\cZ}\, .
\label{eq:boltzmann}
\end{equation}
The semicolon in \Cref{eq:boltzmann} denotes that the model has a parameter $\beta$, representing the reciprocal temperature of the system of random variables (a physical quantity). The energy function $E(\mbz)$ encodes the relationships between random variables, and $\cZ$, the normalizing constant, ensures that this probability distribution sums to one over all configurations of random variables~\citep{chandler1987introduction}. The energy function of the Ising model is\footnote{Bold letters can denote collections of random variables $\mbz = \{z_1, z_2,...,z_N\}$, or vectors, depending on the context.}
\begin{equation}
\label{eq:ising-energy}
E(\mbz) = -\frac{1}{2}\sum_{i, j} J_{ij}z_i z_j - H\sum_i z_i\, .
\end{equation}
The interaction strength $J_{ij}$ defines the interactions between random variables. In a simple Ising model, only nearest neighbors interact, so $J_{ij}$ is nonzero if the random variables $z_i$ and $z_j$ are neighbors. The parameter $H$ increases or decreases the energy in proportion to the values of the random variables $z_i$; we give its physical interpretation later.
The Ising model can be represented as a probabilistic graphical model, shown in \Cref{fig:graphical-model-ising}. Two variables $z_i$ and $z_j$ interact (changing the value of one leads to a change in probability of the other) only if they share an edge in the graph. This representation works in conjuction with the density in \Cref{eq:boltzmann}, as the presence of an edge in the graph corresponds to two variables interacting in the energy function $E$. In this model, the energy function (and hence graph) is such that only neighboring random variables interact.
The Ising model can be used to study physical systems such as magnetic materials, where interactions between atoms can be encoded into the interaction strength $J_{ij}$. The interactions between random variables encoded in this manner contain the necessary information to model the properties of a material. In modeling a material, the random variables $\mbz$ can be referred to as spins. Spin is a type of angular momentum carried by particles comprising atoms, and such angular momentum causes a magnetic field. Although the random variables $\mbz$ are binary, taking on values of $-1$ and $+1$, they can be re-scaled to the magnetic strength of the atoms in a particular material of interest if comparison to experimental data is required. The parameter $H$ can be interpreted as the magnitude of an external magnetic field that interacts with the magnetic strength and orientation of every atom~\citep{chandler1987introduction}.
To see how well an Ising model mirrors a physical material, a property such as magnetization can be measured in the material, and calculated using the model. Magnetization is the average orientation of the magnetic strength of every atom or random variable in the material,
\begin{equation}
M(\mbz) = \frac{1}{N}\sum_{i=1}^N z_i\, .
\end{equation}
By measuring the magnetization $M$ and computing its value in the Ising model, a practitioner can deduce how accurately the model reproduces experimental data. For example, if an Ising model with nearest neighbors ($J_{ij} \neq 0$ if $i$ neighbors $j$) does not accurately reproduce the magnetization of a physical material, it may be necessary to include second-nearest neighbor effects ($J_{ij}\neq 0$ if $i$ and $j$ are connected by a path of length at most two).
Another example of a quantity that can be measured experimentally and computed in a probabilistic model is the thermodynamic free energy $F$,
\begin{equation}
\label{eq:free-energy}
F = -\frac{1}{\beta} \log \cZ\, .
\end{equation}
The free energy of a system relates to the amount of energy that can be extracted from a system by its surroundings. For example, the free energy of a protein is used to understand its stability, and can be measured by the amount of energy needed to destroy its structure by denaturing it~\citep{stone2013the-theory}. In modeling a magnetic material or biological material, the free energy can be derived from the normalizing constant $\cZ$~\citep{chandler1987introduction}.
\input{fig/tab_example_meals_regression}
\subsection{Example: Binary Classification}
\input{fig/fig_graphical_model_regression}
Another example of a probabilistic model is a binary classifier~\citep{bishop2006pattern}, represented as a graphical model in \Cref{fig:graphical-model-regression}. Consider $N$ datapoints of the form $(x_n, y_n)$ consisting of covariates $x_n$ and binary responses $y_n$. As illustrated in \Cref{tab:example-binary}, the covariates $x_n$ might represent information about items such as foods in a meal, and $y_n$ may indicate whether a single user ate a meal with those foods. A binary classifier would then classify whether the user would eat a new meal $\hat{x}_n$ based on its constituent foods.
A binary classifier is defined using a regression function $f$ with parameters $\mbtheta$. The logistic function $\sigma$ applied to the regression function defines the probability model for a binary classifier,
\begin{equation}
p(y_n \mid x_n; \mbtheta) = \frac{\exp\left( \sigma(f(x_n; \mbtheta)) \cdot y_n\right)}{\cZ}\, .
\label{eq:binary-classification}
\end{equation}
The logistic function constrains the output of $f$ to the unit interval, and $\cZ$ is again the normalizing constant. The regression function $f$ uses information about a datapoint to classify whether the response $y_n$ is positive. An example of a regression function is an inner product, defined by
\begin{equation}
f(x_n; \mbtheta) = \mbtheta^\top x_n\, ,
\end{equation}
which corresponds to logistic regression~\citep{bishop2006pattern}. Alternatively, a more flexible model can be built using a deep neural network~\citep{lecun2015deep}.
%A binary classifier can form the basis of a recommender system as we study in \Cref{ch:rfs}.
\section{Inference}
In a probability model, computing---or, inferring---properties of the probability distribution is a central task. One inference problem is to ascertain likely configurations of random variables. Another is to compute the sum of a probability distribution over a set of random variables, for example, to compute the normalizing constant~\citep{jordan2004graphical}.
\subsection{Computing Likely Configurations of Random Variables}
In the study of a probability model such as a binary classifier in \Cref{eq:binary-classification}, one question of interest is: for a set of observations $(x_n, y_n)$, what is a likely value of $\theta$? Maximum likelihood estimation is one way to answer this question~\citep{bishop2006pattern}.
A probability distribution like $p(\mby \mid \mbx; \mbtheta)$ is also known as a likelihood function. It defines the likelihood of a random variable $\mby$ conditional on the value of data $\mbx$, with the current setting of the parameters $\mbtheta$. The maximum likelihood estimate of the parameters of this probability model for the data $(\mbx, \mby)$ is given by
\begin{equation}
\mbtheta^* = \argmax_{\mbtheta} p(\mby \mid \mbx; \mbtheta)\, .
\end{equation}
This maximum likelihood estimate of the parameters $\mbtheta^*$ can be computed using stochastic optimization if the data is large~\citep{robbins1951a-stochastic}. % what if the argmax is intractable, or an integral? #todo details
\subsection{Computing the Normalizing Constant}
The second central inference task in probabilistic modeling is summing a probability model over a set of random variables. One example of this is computing the normalizing constant $\cZ$. This inference problem requires computing a sum: the normalizing constant ensures a probability distribution sums to $1$ over values the random variables can take.
Consider computing the normalizing constant for the binary classifier in \Cref{eq:binary-classification}. To compute the normalizing constant $\cZ$ for this probability model, we can sum over the binary values the random variable $y_n$ can take,
\begin{align}
1 &= \sum_{y_n \in \{0, 1\}} \frac{\exp\left( \sigma(f(x_n; \mbtheta)) \cdot y_n\right)}{\cZ} \\
\Rightarrow \cZ &= \sum_{y_n \in \{0, 1\}} \exp\left( \sigma(f(x_n; \mbtheta) \cdot y_n)\right)\\
\cZ &= 1 + \exp\left( \sigma(f(x_n; \mbtheta))\right)\, .
\end{align}
Inference of the normalizing constant $\cZ$ is straightforward in this probability model. The random variable $y_n$ is binary, so there are only two terms in the sum needed to compute the normalizing constant.
Next, consider computing the normalizing constant or partition function for the Ising model in \Cref{eq:boltzmann}. The random variables $z_n$ in this model also take on binary values. The partition function is computed by summing over all the values associated with all random variables in the system, $\mbz = \{z_1, \ldots, z_N\}$:
\begin{align}
1 &= \sum_{z_1 \in \{-1, +1\}} \ldots \sum_{z_N \in \{-1, +1\}} \frac{\exp(-\beta E(\mbz))}{\cZ}\\
\Rightarrow \cZ &= \sum_{z_1 \in \{-1, +1\}} \ldots \sum_{z_N \in \{-1, +1\}} \exp(-\beta E(\mbz))\, .
\label{eq:intractable-partition}
\end{align}
There are $N$ binary-valued random variables and $2^N$ terms in the sum required to compute the partition function, so inference in the Ising model is difficult. For Ising models used to study materials, the partition function is intractable to compute for most model sizes practitioners want to study and compare to physical realizations.
One way to address the issue of an intractable partition function is with sampling methods, such as Markov chain Monte Carlo~\citep{metropolis1953equation}. These algorithms enable inference by simulating likely configurations of random variables. These samples of likely configurations are used to approximate quantities of interest such as the partition function. But, Markov chain Monte Carlo methods are difficult to scale to probabilistic models with large numbers of correlated random variables. In this thesis, we instead use variational inference, an approximate inference algorithm that relies on optimization instead of sampling.
% Calculating the partition function can be difficult, and there are many ways around computing the partition function. For example, sampling methods and variational methods can be used to approximate properties of distributions such as properties derived from the partition function. Markov chain Monte Carlo~\citep{metropolis1953equation} allows sampling system configurations from the Boltzmann distribution of a model; these samples can be used to approximate physical quantities. Variational inference relies on optimizing (varying) functionals to derive approximations of distributions of interest, these approximations can be used to compute properties of a model. Variational inference has roots in mean field methods in physics~\citep{saul1996mean,hoffman2013stochastic,blei2017variational} as described in \Cref{ch:background}.
\section{Variational Inference}
\input{fig/fig_vi_cartoon}
Instead of working with a probability model $p(\mbz)$ directly, \acrfull{vi} posits a family of distributions $q(\mbz; \mblambda)$ indexed by parameters $\mblambda$~\citep{blei2017variational}. The goal of \gls{vi} is to find the closest member of the variational family $q$ to the target distribution $p$. The algorithm consists of varying the parameters $\mblambda$ to improve the quality of the approximation, as illustrated in \Cref{fig:vi-cartoon}. One way to measure the distance between the variational approximation and the target distribution is with the \acrfull{kl} divergence, or relative entropy~\citep{mackay2003information,ranganath2018black}.
The intractable partition function in $p(\mbz)$ appears in the \gls{kl} divergence \gls{vi} uses to assess distance,
\begin{equation}
\label{eq:kl}
\KL{q(\mbz; \mblambda)}{p(\mbz)} = \E_q[\log q(\mbz ; \mblambda)] -\E_q[\log p(\mbz)] \\
\end{equation}
But it is possible to derive an objective function that does not depend on the partition function, starting from the \gls{kl} divergence. Taking the Ising model in \Cref{eq:boltzmann} as an example,
\begin{align}
\KL{q(\mbz; \mblambda)}{p(\mbz)} &= \E_q[\log q(\mbz ; \mblambda)] -\E_q[\log p(\mbz)] \\
\KL{q(\mbz; \mblambda)}{p(\mbz)} &= \E_q[\log q(\mbz ; \mblambda)] -\E_q[-\beta E(\mbz) - \log \cZ] \\
\log \cZ &= \E_q[-\beta E(\mbz)] - \E_q[\log q(\mbz ; \mblambda)] + \KL{q(\mbz; \mblambda)}{p(\mbz)} \label{eq:second-last} \\
\Rightarrow \log \cZ \geq \cL(\mblambda) &\coloneq \E_q[-\beta E(\mbz)] - \E_q[\log q(\mbz ; \mblambda)]\, .
\label{eq:llbo}
\end{align}
This lower bound $\cL$ on the log normalizing constant is also called the \acrfull{elbo}, and serves as the objective function for \gls{vi}. In deriving this lower bound from \Cref{eq:second-last} to \Cref{eq:llbo}, we used the fact that the \gls{kl} is greater than or equal to zero. To show this fact, we start from Jensen's inequality for a convex function $f$, or
\begin{equation}
f(\E[\mbz]) \leq \E[f(\mbz)]\, .
\end{equation}
The logarithm in the \gls{kl} is concave, so its negative is convex. We apply Jensen's inequality to the negative \gls{kl} in \Cref{eq:kl}:
\begin{align}
-\KL{q(\mbz)}{p(\mbz)} &= \E_q\left[\log \frac{p(\mbz)}{q(\mbz )}\right] \\
&\leq \log \E_q\left[\frac{p(\mbz)}{q(\mbz )}\right]\\
&= \log \int q(\mbz) \frac{p(\mbz)}{q(\mbz )}d\mbz \\
&= \log \int p(\mbz)d\mbz \\
&= 0 \, .
\end{align}
This shows that the \gls{kl} is greater than or equal to zero~\citep{cover2012elements}.
The left-hand-side in \Cref{eq:llbo} does not change as the variational parameters $\mblambda$ are varied in $\cL(\mblambda)$. In words, maximizing the lower bound $\cL(\mblambda)$ is equivalent to minimizing the \gls{kl} divergence between the variational approximation and target probability model.
\subsection{Example: Mean Field Variational Inference in the Ising model}
\label{sec:ising-mean-field}
To demonstrate \gls{vi}, we use the Ising model described in \Cref{sec:ising} with probability distribution $p(\mbz)$ defined in \Cref{eq:boltzmann} and energy function $E(\mbz)$ in \Cref{eq:ising-energy}. Inspecting the intractable partition function of the Ising model can help construct a variational family $q(\mbz; \mblambda)$ to approximate the Ising model.
The Ising model partition function in \Cref{eq:intractable-partition} is intractable because the sums do not decompose by random variables: every sum must be carried out in order, because the result of the $N$th sum over the random variable $z_N$ depends on the results of the sums over the previous $N-1$ random variables. This is because of interactions between dependent random variables. The first term in the energy function of the Ising model represents nearest neighbor interactions, $z_iz_j$, and is graphically equivalent to the links between nearest neighbors in \Cref{fig:graphical-model-ising}.
However, the second term in the Ising energy function in \Cref{eq:ising-energy}, $H\sum_i z_i$, does decompose by random variable. Physically, this corresponds to a magnetic field applied to the system as a whole, so every random variable is subject to the same force. Mathematically, there is an outer sum over every configuration of random variables, and in this term the results of the summation over a variable $z_i$ do not affect the summation over another variable $z_j$. So this magnetic field term can be evaluated for systems with many random variables.
\input{fig/fig-ising-markov-blanket}
The structure of the Ising model energy function and corresponding graphical model can be used to build a variational approximation $q(\mbz; \mblambda)$ as follows. If the second term of the Ising model energy function does not lead to an intractable partition function due to every random variable being subject to a magnetic field, one can construct a variational approximation by extending this physical intuition and developing the concept of a `mean field'. Consider the central random variable $z_i$ in \Cref{fig:graphical-model-ising}. Fixing the values of its nearest neighbors renders this random variable independent of the rest of the graph as shown in \Cref{fig:markov-blanket-ising}. The nearest neighbors of the central random variable can then be interpreted as giving rise to a magnetic field. The strength of this magnetic field is unknown, so we can define this unknown strength as a variational parameter $\delta H$ that we will infer using \gls{vi}. This mean field is additive to the external magnetic field $H$ applied to the system as a whole, so the energy function for the central random variable $z_i$ under this mean field assumption can be written
\begin{equation}
E_{\mf}(z_i; \delta H) = \delta H z_i + H z_i\, .
\end{equation}
Note that we have replaced the interaction term $J_{ij} z_iz_j$ in the Ising model energy function in \Cref{eq:ising-energy} by the mean field $\delta H$. The mean field assumption is that term can approximate the effects of neighboring nodes~\citep{chandler1987introduction}. If we repeat this argument for every node in the graph, we arrive at the mean field energy function
\begin{equation}
E_{\mf}(\mbz; \delta H) = -(H + \delta H)\sum_{i = 1}^N z_i\, .
\label{eq:mean-field-energy}
\end{equation}
The above construction starting from the mean field assumption corresponds to the variational approximation with density
\begin{equation}
q(\mbz; \beta, \delta H) = \prod_{i=1}^N\frac{\exp(- \beta E_\mf(z_i; \delta H))}{\cZ_\mf} \, ,
\label{eq:mean-field-distribution}
\end{equation}
and we see that the variational parameter $\mblambda$ is simply the mean field strength $\delta H$. The mean field variational approximation corresponds to a fully factorized probability distribution where every random variable is independent~\citep{wainwright2008graphical}. This is a useful property, as the partition function is tractable in this mean field variational approximation: we can compute the partition function for every random variable by itself. The partition function for a single random variable $z_i$ under the mean field assumption is straightforward,
\begin{align}
\cZ_\textrm{\mf, i} &= \sum_{z_i \in \{-1, +1\}} \exp(- \beta (H + \delta H) z_i) \\
&= 2 \cosh (\beta (H + \delta H)) \, ,
\label{eq:partition-function-i}
\end{align}
and the partition function for the variational approximation for all variables is simply $\cZ_\mf = \cZ_\textrm{\mf, i}^N$. Similarly, the average of a random variable under the variational distribution is readily computed as
\begin{align}
\begin{split}
\E_{q(z_i)}[z_i] &= \sum_{z_i \in \{-1, +1\}} \frac{z_i \exp(- \beta E_\mf(z_i; \delta H))}{\cZ_\textrm{\mf, i}} \\
&= \sum_{z_i \in \{-1, +1\}} \frac{z_i \exp(- \beta (H + \delta H) z_i)}{2 \cosh(\beta (H + \delta H))} \\
&= -\tanh(\beta (H + \delta H))\, .
\label{eq:mf-mean}
\end{split}
\end{align}
Now that we have constructed a variational family for the Ising model, we can proceed with the \gls{vi} algorithm. The next step is writing down and maximizing the lower bound on the log partition function to minimize the \gls{kl} between our approximating distribution and model.
The lower bound on the log partition function $\cL(\delta H)$ in \Cref{eq:llbo} becomes
\begin{align}
\cL(\delta H) &= \E_q[-\beta E(\mbz)] - \E_q[\log q(\mbz; \delta H)] \\
&= \E_q\left[-\frac{1}{2}\beta\sum_{i, j} J_{ij}z_i z_j - \beta H\sum_i z_i\right] - \E_q\left[ -\beta (H + \delta H)\sum z_i\right] + \log \cZ_{\mf} \\
&= \E_q\left[-\frac{1}{2}\beta\sum_{i, j} J_{ij}z_i z_j + \beta\delta H\sum_i z_i\right] + \log \cZ_{\mf}\, ,
\intertext{and we can take the expectation inside the sum using the fact that the mean field variational distribution is fully factorized, so }
\cL(\delta H) &= -\frac{1}{2}\beta \sum_{i, j}J_{ij}\E_{q(z_i)}[z_i]\E_{q(z_j)}[z_j] + \beta \delta H \sum_i \E_{q(z_i)} [z_i] + \log \cZ_{\mf}\, .\\
\end{align}
In the first term, recall that two random variables $z_i$ and $z_j$ have the same distribution under the mean field assumption, and that every variable interacts with its four nearest neighbors in the Ising model. The lower bound on the log partition function then becomes
\begin{align}
\cL(\delta H) &= -\frac{1} {2} \beta 4JN \E_{q(z_i)}[z_i]^2 + \beta N \delta H \E_{q(z_i)} [z_i] + \log \cZ_{\mf}\, .
\end{align}
The next step in the \gls{vi} algorithm is maximizing this lower bound, to minimize the \gls{kl} divergence between the variational approximation and the model. Taking the derivative with respect to $\delta H$ and suppressing the subscript of the expectation operator, we get
\begin{align}
\frac{\partial\cL(\delta H)}{\partial \delta H} &= N\beta(-4J\E[z_i]\partial_{\delta H}\E[z_i] + \E[z_i] + \delta H \partial_{\delta H} \E[z_i]) + N\beta \tanh(\beta (H + \delta H))\, .
\end{align}
Next, setting this derivative to zero and cancelling out terms (and using \Cref{eq:mf-mean}) leads to
\begin{align}
0 &= -4J\E[z_i]\partial_{\delta H}\E[z_i] + \delta H \partial_{\delta H} \E[z_i]) \\
\Rightarrow \delta H \partial_{\delta H} \E[z_i]) &= 4J\E[z_i]\partial_{\delta H}\E[z_i] \\
\Rightarrow \delta H^* &= 4J\E[z_i]\, .
\end{align}
This shows that under a mean field assumption, the variational parameter that maximizes the lower bound on the log partition function---and hence minimizes the \gls{kl} divergence between the approximation and model---is proportional to the mean field around any node in the system. The structure of the model informs our choice of variational approximation.
The quality of the variational approximation $q(\mbz; \beta, \delta H^*)$ from \gls{vi} can be assessed in several ways. For example, the magnetization $M$ or the free energy $F$ can be calculated using the variational approximation, and these values can be compared to Markov Chain Monte Carlo simulations in small systems. This can be viewed as a type of predictive check for a \gls{vi} algorithm~\citep{blei2014build}. However, the development of theoretical guarantees to assess the quality of variational approximations found with \gls{vi} is an open area of research~\citep{wang2019frequentist}. Practitioners must currently empirically evaluate the quality of variational approximations according to the task at hand, as we do in \Cref{ch:hvm,ch:pvi}.
\subsection{Variational Inference Originated in Statistical Physics}
Previously, we derived a variational approximation to the Ising model by making a mean field assumption. That the language of physics is used in machine learning algorithms such as \gls{vi} is no coincidence. In fact, \citet{feynman1972statistical,feynman2018statistical} derives the \gls{gbf} inequality for use in a variational principle for approximating intractable partition functions using mean field assumptions. Consider a model with energy function $E$ and partition function $\cZ$, and a mean field variational approximation with energy function $E_\mf$ (and corresponding partition function $\cZ_\mf$). Then the \gls{gbf} inequality reads~\citep{feynman1972statistical,feynman2018statistical}
\begin{equation}
\cZ \geq \cZ_\mf\exp\left(-\beta \braket{E - E_\mf}_\mf\right) \, .
\label{eq:gbf-inequality}
\end{equation}
In physics, bra-ket notation is used to denote expectations. For example, expectations with respect to \Cref{eq:mean-field-distribution} are written $\braket{\; \cdot \;}_\mf$. Rewriting the \gls{gbf} with statistics notation for the expectation $\E_q[\;\cdot\;]$ yields
\begin{align}
\cZ &\geq \cZ_\mf\exp\left(-\beta \E_q[E - E_\mf]\right) \, .
\end{align}
Taking the logarithm, we recover the lower bound on the log partition function
\begin{align}
\log \cZ &\geq \E_q[-\beta E] - \E_q[-\beta E_\mf] + \log \cZ_\mf\\
&= \E_q[-\beta E] - \E_q[\log q_\mf(\mbz; \mblambda)] \\
&= \cL(\mblambda)\, .
\end{align}
This is identical to the log partition function lower bound in \Cref{eq:llbo}. \citet{hoffman2013stochastic} review the historical roots of the variational principle in its machine learning incarnation.
To complete the connection to machine learning, we relate this log partition function lower bound to the evidence lower bound studied in the \gls{vi} literature~\citep{blei2017variational}. A probabilistic model of data might have the following process for generating data $\mbx$ using prior information in latent variables $\mbz$:
\begin{align*}
\mbz &\sim p(\mbz)\\
\mbx &\sim p(\mbx \mid \mbz)
\end{align*}
The posterior distribution of this model is computed using Bayes' rule,
\begin{equation*}
p(\mbz \mid \mbx) = \frac{p(\mbx \mid \mbz) p(\mbz)}{p(\mbx)} \, .
\end{equation*}
The model evidence $p(\mbx)$ is the partition function of the posterior. Calculating the partition function is what makes posterior inference difficult, as it requires integration over the latent variables $\mbz$,
\begin{equation*}
p(\mbx) = \int p(\mbx, \mbz) d\mbz \, ,
\end{equation*}
and the latent variables $\mbz$ are typically high-dimensional, such as the number of random variables in an Ising model. But \gls{vi} can be used to approximate this intractable integral. The lower bound on the log partition function becomes the \gls{elbo}:
\begin{align}
\log p(\mbx) &\geq \cL(\mblambda) \\
\cL(\mblambda) &= \E_q[\log p(\mbx, \mbz)] - \E_q[\log q(\mbz ; \mblambda)] \, .
\end{align}
An example of a latent variable model without data is the Ising model---in this case, the data is an empty set, $\mbx = \{\}$. In this case $\cL(\mblambda)$ is a lower bound on the log partition function as we derived in \Cref{eq:llbo} and identical to the \gls{gbf} inequality.
% \gls{vi} is an algorithm to find a good approximation to a target probability distribution that has an intractable integral, such as the sum needed to compute a partition function. We now turn to the second inference problem of computing likely configurations of variables in a probability model.
\section{Conclusion}
We reviewed probability models and gave examples of their use in statistical physics and recommender systems. The task of inference is central to working with probability models; we described variational inference and maximum likelihood estimation. The following chapters address the issue of building the structure of a problem into a performant probability model, whether that structure concerns the connectivity in a statistical physics model, the structure of datapoints in a recommender system, or information about a variational approximation useful in an optimization algorithm for this approximation. |
section \<open>\<open>Extra_General\<close> -- General missing things\<close>
theory Extra_General
imports
"HOL-Library.Cardinality"
"HOL-Analysis.Elementary_Topology"
"HOL-Analysis.Uniform_Limit"
"HOL-Library.Set_Algebras"
"HOL-Types_To_Sets.Types_To_Sets"
"HOL-Library.Complex_Order"
"HOL-Analysis.Infinite_Sum"
begin
subsection \<open>Misc\<close>
lemma reals_zero_comparable:
fixes x::complex
assumes "x\<in>\<real>"
shows "x \<le> 0 \<or> x \<ge> 0"
using assms unfolding complex_is_real_iff_compare0 by assumption
lemma unique_choice: "\<forall>x. \<exists>!y. Q x y \<Longrightarrow> \<exists>!f. \<forall>x. Q x (f x)"
apply (auto intro!: choice ext) by metis
lemma sum_single:
assumes "finite A"
assumes "\<And>j. j \<noteq> i \<Longrightarrow> j\<in>A \<Longrightarrow> f j = 0"
shows "sum f A = (if i\<in>A then f i else 0)"
apply (subst sum.mono_neutral_cong_right[where S=\<open>A \<inter> {i}\<close> and h=f])
using assms by auto
lemma image_set_plus:
assumes \<open>linear U\<close>
shows \<open>U ` (A + B) = U ` A + U ` B\<close>
unfolding image_def set_plus_def
using assms by (force simp: linear_add)
consts heterogenous_identity :: \<open>'a \<Rightarrow> 'b\<close>
overloading heterogenous_identity_id \<equiv> "heterogenous_identity :: 'a \<Rightarrow> 'a" begin
definition heterogenous_identity_def[simp]: \<open>heterogenous_identity_id = id\<close>
end
lemma L2_set_mono2:
assumes a1: "finite L" and a2: "K \<le> L"
shows "L2_set f K \<le> L2_set f L"
proof-
have "(\<Sum>i\<in>K. (f i)\<^sup>2) \<le> (\<Sum>i\<in>L. (f i)\<^sup>2)"
proof (rule sum_mono2)
show "finite L"
using a1.
show "K \<subseteq> L"
using a2.
show "0 \<le> (f b)\<^sup>2"
if "b \<in> L - K"
for b :: 'a
using that
by simp
qed
hence "sqrt (\<Sum>i\<in>K. (f i)\<^sup>2) \<le> sqrt (\<Sum>i\<in>L. (f i)\<^sup>2)"
by (rule real_sqrt_le_mono)
thus ?thesis
unfolding L2_set_def.
qed
lemma Sup_real_close:
fixes e :: real
assumes "0 < e"
and S: "bdd_above S" "S \<noteq> {}"
shows "\<exists>x\<in>S. Sup S - e < x"
proof -
have \<open>Sup (ereal ` S) \<noteq> \<infinity>\<close>
by (metis assms(2) bdd_above_def ereal_less_eq(3) less_SUP_iff less_ereal.simps(4) not_le)
moreover have \<open>Sup (ereal ` S) \<noteq> -\<infinity>\<close>
by (simp add: SUP_eq_iff assms(3))
ultimately have Sup_bdd: \<open>\<bar>Sup (ereal ` S)\<bar> \<noteq> \<infinity>\<close>
by auto
then have \<open>\<exists>x'\<in>ereal ` S. Sup (ereal ` S) - ereal e < x'\<close>
apply (rule_tac Sup_ereal_close)
using assms by auto
then obtain x where \<open>x \<in> S\<close> and Sup_x: \<open>Sup (ereal ` S) - ereal e < ereal x\<close>
by auto
have \<open>Sup (ereal ` S) = ereal (Sup S)\<close>
using Sup_bdd by (rule ereal_Sup[symmetric])
with Sup_x have \<open>ereal (Sup S - e) < ereal x\<close>
by auto
then have \<open>Sup S - e < x\<close>
by auto
with \<open>x \<in> S\<close> show ?thesis
by auto
qed
text \<open>Improved version of @{attribute internalize_sort}: It is not necessary to specify the sort of the type variable.\<close>
attribute_setup internalize_sort' = \<open>let
fun find_tvar thm v = let
val tvars = Term.add_tvars (Thm.prop_of thm) []
val tv = case find_first (fn (n,sort) => n=v) tvars of
SOME tv => tv | NONE => raise THM ("Type variable " ^ string_of_indexname v ^ " not found", 0, [thm])
in
TVar tv
end
fun internalize_sort_attr (tvar:indexname) =
Thm.rule_attribute [] (fn context => fn thm =>
(snd (Internalize_Sort.internalize_sort (Thm.ctyp_of (Context.proof_of context) (find_tvar thm tvar)) thm)));
in
Scan.lift Args.var >> internalize_sort_attr
end\<close>
"internalize a sort"
subsection \<open>Not singleton\<close>
class not_singleton =
assumes not_singleton_card: "\<exists>x y. x \<noteq> y"
lemma not_singleton_existence[simp]:
\<open>\<exists> x::('a::not_singleton). x \<noteq> t\<close>
using not_singleton_card[where ?'a = 'a] by (metis (full_types))
lemma UNIV_not_singleton[simp]: "(UNIV::_::not_singleton set) \<noteq> {x}"
using not_singleton_existence[of x] by blast
lemma UNIV_not_singleton_converse:
assumes"\<And>x::'a. UNIV \<noteq> {x}"
shows "\<exists>x::'a. \<exists>y. x \<noteq> y"
using assms
by fastforce
subclass (in card2) not_singleton
apply standard using two_le_card
by (meson card_2_iff' obtain_subset_with_card_n)
subclass (in perfect_space) not_singleton
apply intro_classes
by (metis (mono_tags) Collect_cong Collect_mem_eq UNIV_I local.UNIV_not_singleton local.not_open_singleton local.open_subopen)
lemma class_not_singletonI_monoid_add:
assumes "(UNIV::'a set) \<noteq> {0}"
shows "class.not_singleton TYPE('a::monoid_add)"
proof intro_classes
let ?univ = "UNIV :: 'a set"
from assms obtain x::'a where "x \<noteq> 0"
by auto
thus "\<exists>x y :: 'a. x \<noteq> y"
by auto
qed
lemma not_singleton_vs_CARD_1:
assumes \<open>\<not> class.not_singleton TYPE('a)\<close>
shows \<open>class.CARD_1 TYPE('a)\<close>
using assms unfolding class.not_singleton_def class.CARD_1_def
by (metis (full_types) One_nat_def UNIV_I card.empty card.insert empty_iff equalityI finite.intros(1) insert_iff subsetI)
subsection \<open>\<^class>\<open>CARD_1\<close>\<close>
context CARD_1 begin
lemma everything_the_same[simp]: "(x::'a)=y"
by (metis (full_types) UNIV_I card_1_singletonE empty_iff insert_iff local.CARD_1)
lemma CARD_1_UNIV: "UNIV = {x::'a}"
by (metis (full_types) UNIV_I card_1_singletonE local.CARD_1 singletonD)
lemma CARD_1_ext: "x (a::'a) = y b \<Longrightarrow> x = y"
proof (rule ext)
show "x t = y t"
if "x a = y b"
for t :: 'a
using that apply (subst (asm) everything_the_same[where x=a])
apply (subst (asm) everything_the_same[where x=b])
by simp
qed
end
instance unit :: CARD_1
apply standard by auto
instance prod :: (CARD_1, CARD_1) CARD_1
apply intro_classes
by (simp add: CARD_1)
instance "fun" :: (CARD_1, CARD_1) CARD_1
apply intro_classes
by (auto simp add: card_fun CARD_1)
lemma enum_CARD_1: "(Enum.enum :: 'a::{CARD_1,enum} list) = [a]"
proof -
let ?enum = "Enum.enum :: 'a::{CARD_1,enum} list"
have "length ?enum = 1"
apply (subst card_UNIV_length_enum[symmetric])
by (rule CARD_1)
then obtain b where "?enum = [b]"
apply atomize_elim
apply (cases ?enum, auto)
by (metis length_0_conv length_Cons nat.inject)
thus "?enum = [a]"
by (subst everything_the_same[of _ b], simp)
qed
subsection \<open>Topology\<close>
lemma cauchy_filter_metricI:
fixes F :: "'a::metric_space filter"
assumes "\<And>e. e>0 \<Longrightarrow> \<exists>P. eventually P F \<and> (\<forall>x y. P x \<and> P y \<longrightarrow> dist x y < e)"
shows "cauchy_filter F"
proof (unfold cauchy_filter_def le_filter_def, auto)
fix P :: "'a \<times> 'a \<Rightarrow> bool"
assume "eventually P uniformity"
then obtain e where e: "e > 0" and P: "dist x y < e \<Longrightarrow> P (x, y)" for x y
unfolding eventually_uniformity_metric by auto
obtain P' where evP': "eventually P' F" and P'_dist: "P' x \<and> P' y \<Longrightarrow> dist x y < e" for x y
apply atomize_elim using assms e by auto
from evP' P'_dist P
show "eventually P (F \<times>\<^sub>F F)"
unfolding eventually_uniformity_metric eventually_prod_filter eventually_filtermap by metis
qed
lemma cauchy_filter_metric_filtermapI:
fixes F :: "'a filter" and f :: "'a\<Rightarrow>'b::metric_space"
assumes "\<And>e. e>0 \<Longrightarrow> \<exists>P. eventually P F \<and> (\<forall>x y. P x \<and> P y \<longrightarrow> dist (f x) (f y) < e)"
shows "cauchy_filter (filtermap f F)"
proof (rule cauchy_filter_metricI)
fix e :: real assume e: "e > 0"
with assms obtain P where evP: "eventually P F" and dist: "P x \<and> P y \<Longrightarrow> dist (f x) (f y) < e" for x y
by atomize_elim auto
define P' where "P' y = (\<exists>x. P x \<and> y = f x)" for y
have "eventually P' (filtermap f F)"
unfolding eventually_filtermap P'_def
using evP
by (smt eventually_mono)
moreover have "P' x \<and> P' y \<longrightarrow> dist x y < e" for x y
unfolding P'_def using dist by metis
ultimately show "\<exists>P. eventually P (filtermap f F) \<and> (\<forall>x y. P x \<and> P y \<longrightarrow> dist x y < e)"
by auto
qed
lemma tendsto_add_const_iff:
\<comment> \<open>This is a generalization of \<open>Limits.tendsto_add_const_iff\<close>,
the only difference is that the sort here is more general.\<close>
"((\<lambda>x. c + f x :: 'a::topological_group_add) \<longlongrightarrow> c + d) F \<longleftrightarrow> (f \<longlongrightarrow> d) F"
using tendsto_add[OF tendsto_const[of c], of f d]
and tendsto_add[OF tendsto_const[of "-c"], of "\<lambda>x. c + f x" "c + d"] by auto
lemma finite_subsets_at_top_minus:
assumes "A\<subseteq>B"
shows "finite_subsets_at_top (B - A) \<le> filtermap (\<lambda>F. F - A) (finite_subsets_at_top B)"
proof (rule filter_leI)
fix P assume "eventually P (filtermap (\<lambda>F. F - A) (finite_subsets_at_top B))"
then obtain X where "finite X" and "X \<subseteq> B"
and P: "finite Y \<and> X \<subseteq> Y \<and> Y \<subseteq> B \<longrightarrow> P (Y - A)" for Y
unfolding eventually_filtermap eventually_finite_subsets_at_top by auto
hence "finite (X-A)" and "X-A \<subseteq> B - A"
by auto
moreover have "finite Y \<and> X-A \<subseteq> Y \<and> Y \<subseteq> B - A \<longrightarrow> P Y" for Y
using P[where Y="Y\<union>X"] \<open>finite X\<close> \<open>X \<subseteq> B\<close>
by (metis Diff_subset Int_Diff Un_Diff finite_Un inf.orderE le_sup_iff sup.orderE sup_ge2)
ultimately show "eventually P (finite_subsets_at_top (B - A))"
unfolding eventually_finite_subsets_at_top by meson
qed
lemma finite_subsets_at_top_inter:
assumes "A\<subseteq>B"
shows "filtermap (\<lambda>F. F \<inter> A) (finite_subsets_at_top B) \<le> finite_subsets_at_top A"
proof (rule filter_leI)
show "eventually P (filtermap (\<lambda>F. F \<inter> A) (finite_subsets_at_top B))"
if "eventually P (finite_subsets_at_top A)"
for P :: "'a set \<Rightarrow> bool"
using that unfolding eventually_filtermap
unfolding eventually_finite_subsets_at_top
by (metis Int_subset_iff assms finite_Int inf_le2 subset_trans)
qed
lemma tendsto_principal_singleton:
shows "(f \<longlongrightarrow> f x) (principal {x})"
unfolding tendsto_def eventually_principal by simp
lemma complete_singleton:
"complete {s::'a::uniform_space}"
proof-
have "F \<le> principal {s} \<Longrightarrow>
F \<noteq> bot \<Longrightarrow> cauchy_filter F \<Longrightarrow> F \<le> nhds s" for F
by (metis eventually_nhds eventually_principal le_filter_def singletonD)
thus ?thesis
unfolding complete_uniform
by simp
qed
subsection \<open>Complex numbers\<close>
lemma cmod_Re:
assumes "x \<ge> 0"
shows "cmod x = Re x"
using assms unfolding less_eq_complex_def cmod_def
by auto
lemma abs_complex_real[simp]: "abs x \<in> \<real>" for x :: complex
by (simp add: abs_complex_def)
lemma Im_abs[simp]: "Im (abs x) = 0"
using abs_complex_real complex_is_Real_iff by blast
lemma cnj_x_x: "cnj x * x = (abs x)\<^sup>2"
proof (cases x)
show "cnj x * x = \<bar>x\<bar>\<^sup>2"
if "x = Complex x1 x2"
for x1 :: real
and x2 :: real
using that
by (auto simp: complex_cnj complex_mult abs_complex_def
complex_norm power2_eq_square complex_of_real_def)
qed
lemma cnj_x_x_geq0[simp]: \<open>cnj x * x \<ge> 0\<close>
by (simp add: less_eq_complex_def)
subsection \<open>List indices and enum\<close>
fun index_of where
"index_of x [] = (0::nat)"
| "index_of x (y#ys) = (if x=y then 0 else (index_of x ys + 1))"
definition "enum_idx (x::'a::enum) = index_of x (enum_class.enum :: 'a list)"
lemma index_of_length: "index_of x y \<le> length y"
apply (induction y) by auto
lemma index_of_correct:
assumes "x \<in> set y"
shows "y ! index_of x y = x"
using assms apply (induction y arbitrary: x)
by auto
lemma enum_idx_correct:
"Enum.enum ! enum_idx i = i"
proof-
have "i \<in> set enum_class.enum"
using UNIV_enum by blast
thus ?thesis
unfolding enum_idx_def
using index_of_correct by metis
qed
lemma index_of_bound:
assumes "y \<noteq> []" and "x \<in> set y"
shows "index_of x y < length y"
using assms proof(induction y arbitrary: x)
case Nil
thus ?case by auto
next
case (Cons a y)
show ?case
proof(cases "a = x")
case True
thus ?thesis by auto
next
case False
moreover have "a \<noteq> x \<Longrightarrow> index_of x y < length y"
using Cons.IH Cons.prems(2) by fastforce
ultimately show ?thesis by auto
qed
qed
lemma enum_idx_bound: "enum_idx x < length (Enum.enum :: 'a list)" for x :: "'a::enum"
proof-
have p1: "False"
if "(Enum.enum :: 'a list) = []"
proof-
have "(UNIV::'a set) = set ([]::'a list)"
using that UNIV_enum by metis
also have "\<dots> = {}"
by blast
finally have "(UNIV::'a set) = {}".
thus ?thesis by simp
qed
have p2: "x \<in> set (Enum.enum :: 'a list)"
using UNIV_enum by auto
moreover have "(enum_class.enum::'a list) \<noteq> []"
using p2 by auto
ultimately show ?thesis
unfolding enum_idx_def
using index_of_bound [where x = x and y = "(Enum.enum :: 'a list)"]
by auto
qed
lemma index_of_nth:
assumes "distinct xs"
assumes "i < length xs"
shows "index_of (xs ! i) xs = i"
using assms
by (metis gr_implies_not_zero index_of_bound index_of_correct length_0_conv nth_eq_iff_index_eq nth_mem)
lemma enum_idx_enum:
assumes \<open>i < CARD('a::enum)\<close>
shows \<open>enum_idx (enum_class.enum ! i :: 'a) = i\<close>
unfolding enum_idx_def apply (rule index_of_nth)
using assms by (simp_all add: card_UNIV_length_enum enum_distinct)
subsection \<open>Filtering lists/sets\<close>
lemma map_filter_map: "List.map_filter f (map g l) = List.map_filter (f o g) l"
proof (induction l)
show "List.map_filter f (map g []) = List.map_filter (f \<circ> g) []"
by (simp add: map_filter_simps)
show "List.map_filter f (map g (a # l)) = List.map_filter (f \<circ> g) (a # l)"
if "List.map_filter f (map g l) = List.map_filter (f \<circ> g) l"
for a :: 'c
and l :: "'c list"
using that map_filter_simps(1)
by (metis comp_eq_dest_lhs list.simps(9))
qed
lemma map_filter_Some[simp]: "List.map_filter (\<lambda>x. Some (f x)) l = map f l"
proof (induction l)
show "List.map_filter (\<lambda>x. Some (f x)) [] = map f []"
by (simp add: map_filter_simps)
show "List.map_filter (\<lambda>x. Some (f x)) (a # l) = map f (a # l)"
if "List.map_filter (\<lambda>x. Some (f x)) l = map f l"
for a :: 'b
and l :: "'b list"
using that by (simp add: map_filter_simps(1))
qed
lemma filter_Un: "Set.filter f (x \<union> y) = Set.filter f x \<union> Set.filter f y"
unfolding Set.filter_def by auto
lemma Set_filter_unchanged: "Set.filter P X = X" if "\<And>x. x\<in>X \<Longrightarrow> P x" for P and X :: "'z set"
using that unfolding Set.filter_def by auto
subsection \<open>Maps\<close>
definition "inj_map \<pi> = (\<forall>x y. \<pi> x = \<pi> y \<and> \<pi> x \<noteq> None \<longrightarrow> x = y)"
definition "inv_map \<pi> = (\<lambda>y. if Some y \<in> range \<pi> then Some (inv \<pi> (Some y)) else None)"
lemma inj_map_total[simp]: "inj_map (Some o \<pi>) = inj \<pi>"
unfolding inj_map_def inj_def by simp
lemma inj_map_Some[simp]: "inj_map Some"
by (simp add: inj_map_def)
lemma inv_map_total:
assumes "surj \<pi>"
shows "inv_map (Some o \<pi>) = Some o inv \<pi>"
proof-
have "(if Some y \<in> range (\<lambda>x. Some (\<pi> x))
then Some (SOME x. Some (\<pi> x) = Some y)
else None) =
Some (SOME b. \<pi> b = y)"
if "surj \<pi>"
for y
using that by auto
hence "surj \<pi> \<Longrightarrow>
(\<lambda>y. if Some y \<in> range (\<lambda>x. Some (\<pi> x))
then Some (SOME x. Some (\<pi> x) = Some y) else None) =
(\<lambda>x. Some (SOME xa. \<pi> xa = x))"
by (rule ext)
thus ?thesis
unfolding inv_map_def o_def inv_def
using assms by linarith
qed
lemma inj_map_map_comp[simp]:
assumes a1: "inj_map f" and a2: "inj_map g"
shows "inj_map (f \<circ>\<^sub>m g)"
using a1 a2
unfolding inj_map_def
by (metis (mono_tags, lifting) map_comp_def option.case_eq_if option.expand)
lemma inj_map_inv_map[simp]: "inj_map (inv_map \<pi>)"
proof (unfold inj_map_def, rule allI, rule allI, rule impI, erule conjE)
fix x y
assume same: "inv_map \<pi> x = inv_map \<pi> y"
and pix_not_None: "inv_map \<pi> x \<noteq> None"
have x_pi: "Some x \<in> range \<pi>"
using pix_not_None unfolding inv_map_def apply auto
by (meson option.distinct(1))
have y_pi: "Some y \<in> range \<pi>"
using pix_not_None unfolding same unfolding inv_map_def apply auto
by (meson option.distinct(1))
have "inv_map \<pi> x = Some (Hilbert_Choice.inv \<pi> (Some x))"
unfolding inv_map_def using x_pi by simp
moreover have "inv_map \<pi> y = Some (Hilbert_Choice.inv \<pi> (Some y))"
unfolding inv_map_def using y_pi by simp
ultimately have "Hilbert_Choice.inv \<pi> (Some x) = Hilbert_Choice.inv \<pi> (Some y)"
using same by simp
thus "x = y"
by (meson inv_into_injective option.inject x_pi y_pi)
qed
lemma abs_summable_bdd_above:
fixes f :: \<open>'a \<Rightarrow> 'b::real_normed_vector\<close>
shows \<open>f abs_summable_on A \<longleftrightarrow> bdd_above (sum (\<lambda>x. norm (f x)) ` {F. F\<subseteq>A \<and> finite F})\<close>
proof (rule iffI)
assume \<open>f abs_summable_on A\<close>
have \<open>(\<Sum>x\<in>F. norm (f x)) = (\<Sum>\<^sub>\<infinity>x\<in>F. norm (f x))\<close> if \<open>finite F\<close> for F
by (simp add: that)
also have \<open>(\<Sum>\<^sub>\<infinity>x\<in>F. norm (f x)) \<le> (\<Sum>\<^sub>\<infinity>x\<in>A. norm (f x))\<close> if \<open>F \<subseteq> A\<close> for F
by (smt (verit) Diff_subset \<open>f abs_summable_on A\<close> infsum_Diff infsum_nonneg norm_ge_zero summable_on_subset_banach that)
finally show \<open>bdd_above (sum (\<lambda>x. norm (f x)) ` {F. F \<subseteq> A \<and> finite F})\<close>
by (auto intro!: bdd_aboveI)
next
assume \<open>bdd_above (sum (\<lambda>x. norm (f x)) ` {F. F\<subseteq>A \<and> finite F})\<close>
then show \<open>f abs_summable_on A\<close>
by (simp add: pos_summable_on)
qed
lemma infsum_nonneg:
fixes f :: "'a \<Rightarrow> 'b::{ordered_comm_monoid_add,linorder_topology}"
assumes "\<And>x. x \<in> M \<Longrightarrow> 0 \<le> f x"
shows "infsum f M \<ge> 0" (is "?lhs \<ge> _")
apply (cases \<open>f summable_on M\<close>)
apply (rule infsum_nonneg)
using assms by (auto simp add: infsum_not_exists)
lemma abs_summable_product:
fixes x :: "'a \<Rightarrow> 'b::{real_normed_div_algebra,banach,second_countable_topology}"
assumes x2_sum: "(\<lambda>i. (x i) * (x i)) abs_summable_on A"
and y2_sum: "(\<lambda>i. (y i) * (y i)) abs_summable_on A"
shows "(\<lambda>i. x i * y i) abs_summable_on A"
proof (rule pos_summable_on, simp, rule bdd_aboveI2, rename_tac F)
fix F assume \<open>F \<in> {F. F \<subseteq> A \<and> finite F}\<close>
then have r1: "finite F" and b4: "F \<subseteq> A"
by auto
have a1: "(\<Sum>\<^sub>\<infinity>i\<in>F. norm (x i * x i)) \<le> (\<Sum>\<^sub>\<infinity>i\<in>A. norm (x i * x i))"
apply (rule infsum_mono_neutral)
using b4 r1 x2_sum by auto
have "norm (x i * y i) \<le> norm (x i * x i) + norm (y i * y i)" for i
unfolding norm_mult
by (smt mult_left_mono mult_nonneg_nonneg mult_right_mono norm_ge_zero)
hence "(\<Sum>i\<in>F. norm (x i * y i)) \<le> (\<Sum>i\<in>F. norm (x i * x i) + norm (y i * y i))"
by (simp add: sum_mono)
also have "\<dots> = (\<Sum>i\<in>F. norm (x i * x i)) + (\<Sum>i\<in>F. norm (y i * y i))"
by (simp add: sum.distrib)
also have "\<dots> = (\<Sum>\<^sub>\<infinity>i\<in>F. norm (x i * x i)) + (\<Sum>\<^sub>\<infinity>i\<in>F. norm (y i * y i))"
by (simp add: \<open>finite F\<close>)
also have "\<dots> \<le> (\<Sum>\<^sub>\<infinity>i\<in>A. norm (x i * x i)) + (\<Sum>\<^sub>\<infinity>i\<in>A. norm (y i * y i))"
by (smt (verit, del_insts) a1 Diff_iff Infinite_Sum.infsum_nonneg assms(2) b4 infsum_def infsum_mono_neutral norm_ge_zero subset_eq)
finally show \<open>(\<Sum>xa\<in>F. norm (x xa * y xa)) \<le> (\<Sum>\<^sub>\<infinity>i\<in>A. norm (x i * x i)) + (\<Sum>\<^sub>\<infinity>i\<in>A. norm (y i * y i))\<close>
by simp
qed
end
|
\documentclass{myres}
\newcommand{\myfname}{Steven}
\newcommand{\mylname}{Malins}
\newcommand{\myemail}{[email protected]}
\newcommand{\myweb}{twilighteve.com}
\newcommand{\myphone}{(505) 750-1238}
\newcommand{\myaddressA}{5901-J Wyoming Blvd NE \#274}
\newcommand{\myaddressB}{Albuquerque, NM 87109}
\begin{document}
\pagestyle{empty}
\mktop
{\myfname}
{\mylname}
{\myemail}
{\myphone}
{\myweb}
{\myaddressA}
{\myaddressB}
\myendsec
\section{Executive Summary}
\vspace{-.5em}
Acupuncturist physician with more than 5 years of clinical experience including: over 5,000 treatments, launching 3 websites, teaching two CEU classes on regulatory compliance, and deploying one custom EHR solution.
\myendsec
\section{Education}
\vspace{-1em}
\begin{tabularx}{\textwidth}{@{} l l R}
\mydegree{M.S. Acupuncture \& OM} & Southwest Acupuncture College & Albuquerque, NM\\
\mydegree{B.S. Biology} $\bullet$ Minor in Computer Science & University of New Mexico & Albuquerque, NM\\
\end{tabularx}
\vspace{-1em}
\subsection{Graduate Coursework}
\vspace{-.8em}
450+ hours biomedicine $\bullet$ 1000+ Clinical Hours $\bullet$ Sports Medicine $\bullet$ Microcurrent Therapy $\bullet$ Hari Acupuncture
\myendsec
\section{Employment History}
\myworkplace{Nov2015 to Oct2019}
{Acupuncturist}
{Community Acupuncture Albuquerque}
{(505) 266-2606}
{
Planned and treated during winter special to increase patient load.\\
Maintained \%70 return rate.\\
Implemented accounting system to decrease missed deposits.
}
\myworkplace{Jan2014 to Dec2014}
{Acupuncturist and Billing Specialist}
{Longevity Acupuncture}
{(505) 243-3042}
{
Trained two office managers including MS Office, QuickBooks, and
Coding and Billing.\\
Launched community acupuncture clinic\\
Implemented Custom onsite EHR system
}
\myendsec
\section{Experience}
\vspace{-.5em}
\subsection{Programming}
\vspace{-.5em}
{\latog\selectfont More than 5,000 lines of code:} LISP $\bullet$ Java
{\latog\selectfont More than 1,000 lines of code:} C $\bullet$ HTML $\bullet$ Python $\bullet$ PHP
\subsection{Leadership}
\vspace{-.5em}
\begin{tabularx}{\textwidth}{@{} l X}
12 months summers 2005-2008 & \textbf{YMCA Camp Shaver Leadership Staff}\\
2013 to 2015 & \textbf{ASA National Organization Founding Representative}\\
\end{tabularx}
\subsection{Teaching}
\vspace{-.5em}
All classes approved for PDA points by national certification organization (NCCAOM)\\
\begin{tabularx}{\textwidth}{@{} l X R}
Sept2019 & \textbf{Bloodborne Pathogens and Clean Needle} & NMSAAM\\
May2019 & \textbf{Data Security for the Acupuncturist} & PHANM\\
\end{tabularx}
\myendsec
\section{Professional Associations}
\begin{tabular}{@{} l l c c}
Jan2019 & Current & Treasurer & New Mexico Society for Acupuncture and Asian Medicine\\
Sept2015 & Sept2018 & President & New Mexico Society for Acupuncture and Asian Medicine\\
March2014 & Sept2017 & Nominating Committee & American Society of Acupuncturists\\
2010 & Current & Founding Member & Order of the Raven (YMCA Camp Shaver)\\
\end{tabular}
\end{document}
|
Formal statement is: lemma continuous_on_inverse[continuous_intros]: fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_div_algebra" assumes "continuous_on s f" and "\<forall>x\<in>s. f x \<noteq> 0" shows "continuous_on s (\<lambda>x. inverse (f x))" Informal statement is: If $f$ is a continuous function from a set $S$ to a real normed division algebra, and $f(x) \neq 0$ for all $x \in S$, then the function $x \mapsto \frac{1}{f(x)}$ is continuous on $S$. |
lemma Schwarz1: assumes holf: "f holomorphic_on S" and contf: "continuous_on (closure S) f" and S: "open S" "connected S" and boS: "bounded S" and "S \<noteq> {}" obtains w where "w \<in> frontier S" "\<And>z. z \<in> closure S \<Longrightarrow> norm (f z) \<le> norm (f w)" |
Wang 's tale portrays Zhou as an aging itinerant swordmaster with " a fame reverberating like thunder " throughout the underworld society of <unk> . He is made the sworn brother of the outlaw " Flowery Monk " Lu Zhishen , a military officer @-@ turned @-@ fighting monk , who is , according to Hsia , first among the most popular protagonists of the Water Margin . He is also given the nickname " Iron Arm " ( <unk> ) , which carried over into the title of his fictional biography Iron Arm , Golden Sabre . While the tale fails to explain the reason for the moniker , it does mention Zhou 's ability to direct his qi to any part of his body to make it hard enough to overpower the " Iron shirt " technique of another martial artist . Furthermore , Zhou shares the same nickname with Cai Fu , an executioner @-@ turned @-@ outlaw known for his ease in wielding a heavy sword .
|
-- @@stderr --
dtrace: failed to compile script test/unittest/funcs/err.D_PROTO_LEN.motoomany.d: [D_SYNTAX] line 18: syntax error near ")"
|
!**************************************************************
!* AceGen 6.702 Windows (4 May 16) *
!* Co. J. Korelc 2013 19 Mar 17 15:35:50 *
!**************************************************************
! User : Full professional version
! Notebook : JacobianFunction
! Evaluation time : 188 s Mode : Optimal
! Number of formulae : 1954 Method: Automatic
! Subroutine : dRdX2 size: 40752
! Total size of Mathematica code : 40752 subexpressions
! Total size of Fortran code : 106959 bytes
!******************* S U B R O U T I N E **********************
SUBROUTINE dRdX2(v,x,props,statev,Fnew,dRdX)
USE SMSUtility
IMPLICIT NONE
LOGICAL b173
DOUBLE PRECISION v(2812),x(28),props(12),statev(28),Fnew(9),dRdX(28,28)
v(2587)=props(4)*x(1)
v(2441)=x(21)*x(22)-x(24)*x(28)
v(2797)=-(statev(27)*v(2441))
v(2783)=-(statev(25)*v(2441))
v(2748)=-(statev(20)*v(2441))
v(2440)=x(23)*x(25)-x(20)*x(28)
v(2806)=-(statev(22)*v(2440))
v(2771)=-(statev(26)*v(2440))
v(2757)=-(statev(24)*v(2440))
v(2439)=-(x(21)*x(25))+x(27)*x(28)
v(2799)=-(statev(24)*v(2439))
v(2795)=v(2797)+v(2799)
v(2785)=-(statev(22)*v(2439))
v(2781)=v(2783)+v(2785)
v(2750)=-(statev(26)*v(2439))
v(2746)=v(2748)+v(2750)
v(2567)=v(2439)*v(2440)
v(2438)=-(x(22)*x(23))+x(26)*x(28)
v(2804)=-(statev(25)*v(2438))
v(2807)=v(2804)+v(2806)
v(2769)=-(statev(20)*v(2438))
v(2772)=v(2769)+v(2771)
v(2755)=-(statev(27)*v(2438))
v(2758)=v(2755)+v(2757)
v(2568)=v(2438)*v(2441)
v(2569)=v(2567)+v(2568)
v(2437)=x(24)*x(25)-x(22)*x(27)
v(2796)=-(statev(21)*v(2437))
v(2800)=v(2796)+v(2799)
v(2798)=v(2796)+v(2797)
v(2794)=v(2795)+v(2796)
v(2782)=-(statev(28)*v(2437))
v(2786)=v(2782)+v(2785)
v(2784)=v(2782)+v(2783)
v(2780)=v(2781)+v(2782)
v(2747)=-(statev(23)*v(2437))
v(2751)=v(2747)+v(2750)
v(2749)=v(2747)+v(2748)
v(2745)=v(2746)+v(2747)
v(2436)=-(x(20)*x(24))+x(26)*x(27)
v(2790)=-(statev(23)*v(2436))
v(2776)=-(statev(21)*v(2436))
v(2762)=-(statev(28)*v(2436))
v(2579)=v(2436)*v(2437)
v(2435)=x(20)*x(21)-x(23)*x(27)
v(2788)=-(statev(26)*v(2435))
v(2787)=v(2788)+v(2790)
v(2774)=-(statev(24)*v(2435))
v(2773)=v(2774)+v(2776)
v(2760)=-(statev(22)*v(2435))
v(2759)=v(2760)+v(2762)
v(2580)=v(2435)*v(2439)
v(2582)=v(2579)+v(2580)
v(2574)=v(2435)*v(2440)
v(2434)=x(20)*x(22)-x(25)*x(26)
v(2803)=-(statev(28)*v(2434))
v(2805)=v(2803)+v(2804)
v(2801)=v(2803)+v(2806)
v(2802)=v(2801)+v(2804)
v(2768)=-(statev(23)*v(2434))
v(2770)=v(2768)+v(2769)
v(2766)=v(2768)+v(2771)
v(2767)=v(2766)+v(2769)
v(2754)=-(statev(21)*v(2434))
v(2756)=v(2754)+v(2755)
v(2752)=v(2754)+v(2757)
v(2753)=v(2752)+v(2755)
v(2573)=v(2434)*v(2436)
v(2576)=v(2573)+v(2574)
v(2566)=v(2434)*v(2437)
v(2571)=v(2566)+v(2568)
v(2570)=v(2566)+v(2567)
v(2433)=x(23)*x(24)-x(21)*x(26)
v(2792)=-(statev(20)*v(2433))
v(2793)=v(2790)+v(2792)
v(2789)=v(2788)+v(2792)
v(2791)=v(2789)+v(2790)
v(2778)=-(statev(27)*v(2433))
v(2779)=v(2776)+v(2778)
v(2775)=v(2774)+v(2778)
v(2777)=v(2775)+v(2776)
v(2764)=-(statev(25)*v(2433))
v(2765)=v(2762)+v(2764)
v(2761)=v(2760)+v(2764)
v(2763)=v(2761)+v(2762)
v(2581)=v(2433)*v(2441)
v(2583)=v(2579)+v(2581)
v(2578)=v(2580)+v(2581)
v(2575)=v(2433)*v(2438)
v(2577)=v(2573)+v(2575)
v(2572)=v(2574)+v(2575)
v(2405)=x(12)*x(13)-x(15)*x(19)
v(2734)=-(statev(18)*v(2405))
v(2720)=-(statev(16)*v(2405))
v(2685)=-(statev(11)*v(2405))
v(2404)=x(14)*x(16)-x(11)*x(19)
v(2743)=-(statev(13)*v(2404))
v(2708)=-(statev(17)*v(2404))
v(2694)=-(statev(15)*v(2404))
v(2403)=-(x(12)*x(16))+x(18)*x(19)
v(2736)=-(statev(15)*v(2403))
v(2732)=v(2734)+v(2736)
v(2722)=-(statev(13)*v(2403))
v(2718)=v(2720)+v(2722)
v(2687)=-(statev(17)*v(2403))
v(2683)=v(2685)+v(2687)
v(2537)=v(2403)*v(2404)
v(2402)=-(x(13)*x(14))+x(17)*x(19)
v(2741)=-(statev(16)*v(2402))
v(2744)=v(2741)+v(2743)
v(2706)=-(statev(11)*v(2402))
v(2709)=v(2706)+v(2708)
v(2692)=-(statev(18)*v(2402))
v(2695)=v(2692)+v(2694)
v(2538)=v(2402)*v(2405)
v(2539)=v(2537)+v(2538)
v(2401)=x(15)*x(16)-x(13)*x(18)
v(2733)=-(statev(12)*v(2401))
v(2737)=v(2733)+v(2736)
v(2735)=v(2733)+v(2734)
v(2731)=v(2732)+v(2733)
v(2719)=-(statev(19)*v(2401))
v(2723)=v(2719)+v(2722)
v(2721)=v(2719)+v(2720)
v(2717)=v(2718)+v(2719)
v(2684)=-(statev(14)*v(2401))
v(2688)=v(2684)+v(2687)
v(2686)=v(2684)+v(2685)
v(2682)=v(2683)+v(2684)
v(2400)=-(x(11)*x(15))+x(17)*x(18)
v(2727)=-(statev(14)*v(2400))
v(2713)=-(statev(12)*v(2400))
v(2699)=-(statev(19)*v(2400))
v(2549)=v(2400)*v(2401)
v(2399)=x(11)*x(12)-x(14)*x(18)
v(2725)=-(statev(17)*v(2399))
v(2724)=v(2725)+v(2727)
v(2711)=-(statev(15)*v(2399))
v(2710)=v(2711)+v(2713)
v(2697)=-(statev(13)*v(2399))
v(2696)=v(2697)+v(2699)
v(2550)=v(2399)*v(2403)
v(2552)=v(2549)+v(2550)
v(2544)=v(2399)*v(2404)
v(2398)=x(11)*x(13)-x(16)*x(17)
v(2740)=-(statev(19)*v(2398))
v(2742)=v(2740)+v(2741)
v(2738)=v(2740)+v(2743)
v(2739)=v(2738)+v(2741)
v(2705)=-(statev(14)*v(2398))
v(2707)=v(2705)+v(2706)
v(2703)=v(2705)+v(2708)
v(2704)=v(2703)+v(2706)
v(2691)=-(statev(12)*v(2398))
v(2693)=v(2691)+v(2692)
v(2689)=v(2691)+v(2694)
v(2690)=v(2689)+v(2692)
v(2543)=v(2398)*v(2400)
v(2546)=v(2543)+v(2544)
v(2536)=v(2398)*v(2401)
v(2541)=v(2536)+v(2538)
v(2540)=v(2536)+v(2537)
v(2397)=x(14)*x(15)-x(12)*x(17)
v(2729)=-(statev(11)*v(2397))
v(2730)=v(2727)+v(2729)
v(2726)=v(2725)+v(2729)
v(2728)=v(2726)+v(2727)
v(2715)=-(statev(18)*v(2397))
v(2716)=v(2713)+v(2715)
v(2712)=v(2711)+v(2715)
v(2714)=v(2712)+v(2713)
v(2701)=-(statev(16)*v(2397))
v(2702)=v(2699)+v(2701)
v(2698)=v(2697)+v(2701)
v(2700)=v(2698)+v(2699)
v(2551)=v(2397)*v(2405)
v(2553)=v(2549)+v(2551)
v(2548)=v(2550)+v(2551)
v(2545)=v(2397)*v(2402)
v(2547)=v(2543)+v(2545)
v(2542)=v(2544)+v(2545)
v(2385)=x(3)*x(4)-x(10)*x(6)
v(2671)=-(statev(9)*v(2385))
v(2657)=-(statev(7)*v(2385))
v(2620)=-(statev(2)*v(2385))
v(2382)=-(x(3)*x(7))+x(10)*x(9)
v(2673)=-(statev(6)*v(2382))
v(2669)=v(2671)+v(2673)
v(2659)=-(statev(4)*v(2382))
v(2655)=v(2657)+v(2659)
v(2622)=-(statev(8)*v(2382))
v(2618)=v(2620)+v(2622)
v(2380)=-(x(10)*x(2))+x(5)*x(7)
v(2680)=-(statev(4)*v(2380))
v(2645)=-(statev(8)*v(2380))
v(2630)=-(statev(6)*v(2380))
v(2378)=-(x(4)*x(5))+x(10)*x(8)
v(2678)=-(statev(7)*v(2378))
v(2681)=v(2678)+v(2680)
v(2643)=-(statev(2)*v(2378))
v(2646)=v(2643)+v(2645)
v(2628)=-(statev(9)*v(2378))
v(2631)=v(2628)+v(2630)
v(2374)=x(6)*x(7)-x(4)*x(9)
v(2670)=-(statev(3)*v(2374))
v(2674)=v(2670)+v(2673)
v(2672)=v(2670)+v(2671)
v(2668)=v(2669)+v(2670)
v(2656)=-(statev(10)*v(2374))
v(2660)=v(2656)+v(2659)
v(2658)=v(2656)+v(2657)
v(2654)=v(2655)+v(2656)
v(2619)=-(statev(5)*v(2374))
v(2623)=v(2619)+v(2622)
v(2621)=v(2619)+v(2620)
v(2617)=v(2618)+v(2619)
v(2373)=x(2)*x(3)-x(5)*x(9)
v(2662)=-(statev(8)*v(2373))
v(2648)=-(statev(6)*v(2373))
v(2634)=-(statev(4)*v(2373))
v(2372)=-(x(2)*x(6))+x(8)*x(9)
v(2664)=-(statev(5)*v(2372))
v(2661)=v(2662)+v(2664)
v(2650)=-(statev(3)*v(2372))
v(2647)=v(2648)+v(2650)
v(2636)=-(statev(10)*v(2372))
v(2633)=v(2634)+v(2636)
v(2371)=x(2)*x(4)-x(7)*x(8)
v(2677)=-(statev(10)*v(2371))
v(2679)=v(2677)+v(2678)
v(2675)=v(2677)+v(2680)
v(2676)=v(2675)+v(2678)
v(2642)=-(statev(5)*v(2371))
v(2644)=v(2642)+v(2643)
v(2640)=v(2642)+v(2645)
v(2641)=v(2640)+v(2643)
v(2627)=-(statev(3)*v(2371))
v(2629)=v(2627)+v(2628)
v(2625)=v(2627)+v(2630)
v(2626)=v(2625)+v(2628)
v(2370)=x(5)*x(6)-x(3)*x(8)
v(2666)=-(statev(2)*v(2370))
v(2667)=v(2664)+v(2666)
v(2663)=v(2662)+v(2666)
v(2665)=v(2663)+v(2664)
v(2652)=-(statev(9)*v(2370))
v(2653)=v(2650)+v(2652)
v(2649)=v(2648)+v(2652)
v(2651)=v(2649)+v(2650)
v(2638)=-(statev(7)*v(2370))
v(2639)=v(2636)+v(2638)
v(2635)=v(2634)+v(2638)
v(2637)=v(2635)+v(2636)
v(2369)=-statev(1)+x(1)
v(2368)=0.15d1*props(6)
v(2367)=props(8)*v(2368)
v(2366)=1d0-props(6)
v(2595)=props(11)*v(2366)
v(2591)=props(8)*v(2366)
v(235)=props(11)*v(2368)
v(249)=v(2372)*x(10)+v(2373)*x(4)+v(2370)*x(7)
v(2396)=-(x(7)/v(249))
v(2395)=-(x(3)/v(249))
v(2394)=-(x(5)/v(249))
v(2393)=-(x(4)/v(249))
v(2392)=x(10)/v(249)
v(2391)=-(x(2)/v(249))
v(2390)=x(8)/v(249)
v(2389)=-(x(6)/v(249))
v(2388)=x(9)/v(249)
v(251)=1d0/v(249)**2
v(259)=-(v(2372)*v(251))
v(322)=v(2372)*v(259)
v(311)=v(2373)*v(259)
v(304)=v(2371)*v(259)
v(256)=-(v(2370)*v(251))
v(2379)=-(v(2378)*v(256))
v(329)=v(2370)*v(256)
v(320)=v(2372)*v(256)
v(317)=v(2371)*v(256)
v(308)=v(2373)*v(256)
v(254)=-(v(2374)*v(251))
v(2375)=-(v(2372)*v(254))
v(1921)=statev(3)*v(2375)
v(1916)=statev(10)*v(2375)
v(1902)=statev(5)*v(2375)
v(330)=v(2374)*v(254)
v(321)=v(2373)*v(254)
v(299)=v(2371)*v(254)
v(253)=-(v(2373)*v(251))
v(2383)=-(v(2382)*v(253))
v(2381)=-(v(2380)*v(253))
v(319)=v(2371)*v(253)
v(305)=v(2373)*v(253)
v(252)=-(v(2371)*v(251))
v(2377)=-(v(2374)*v(252))
v(2376)=-(v(2372)*v(252))
v(1925)=statev(10)*v(2376)
v(1911)=statev(5)*v(2376)
v(1906)=statev(3)*v(2376)
v(1778)=statev(10)*v(2377)
v(1770)=statev(5)*v(2377)
v(1765)=statev(3)*v(2377)
v(297)=v(2371)*v(252)
v(1887)=statev(2)*v(2379)
v(1879)=statev(9)*v(2379)
v(1874)=statev(7)*v(2379)
v(258)=-(v(2378)*v(251))
v(328)=v(2373)*v(258)
v(316)=v(2378)*v(258)
v(303)=v(2371)*v(258)
v(1800)=statev(8)*v(2381)
v(1795)=statev(6)*v(2381)
v(1790)=statev(4)*v(2381)
v(255)=-(v(2380)*v(251))
v(2384)=-(v(2382)*v(255))
v(332)=v(2380)*v(255)
v(313)=v(2378)*v(255)
v(300)=v(2371)*v(255)
v(1859)=statev(4)*v(2384)
v(1854)=statev(8)*v(2383)
v(1849)=statev(6)*v(2383)
v(1845)=statev(8)*v(2384)
v(1841)=statev(4)*v(2383)
v(1837)=statev(6)*v(2384)
v(323)=v(2382)*v(254)
v(257)=-(v(2382)*v(251))
v(331)=v(2371)*v(257)
v(326)=v(2382)*v(257)
v(327)=v(2385)*v(259)
v(325)=v(2385)*v(253)
v(315)=v(2385)*v(255)
v(312)=v(2385)*v(252)
v(295)=v(2385)*v(258)
v(294)=v(2385)*v(257)
v(293)=v(2385)*v(256)
v(291)=v(2385)*v(254)
v(250)=-(v(2385)*v(251))
v(2387)=-(v(2370)*v(250))
v(2386)=-(v(2378)*v(250))
v(1891)=statev(9)*v(2386)
v(1883)=statev(7)*v(2386)
v(1869)=statev(2)*v(2386)
v(1825)=statev(9)*v(2387)
v(1820)=statev(7)*v(2387)
v(1812)=statev(2)*v(2387)
v(288)=v(2385)*v(250)
v(1924)=statev(7)*v(2390)
v(1923)=statev(4)*v(2391)
v(1920)=statev(6)*v(2388)
v(1919)=statev(9)*v(2389)
v(1915)=statev(4)*v(2388)
v(1914)=statev(7)*v(2389)
v(1910)=statev(2)*v(2390)
v(1909)=statev(8)*v(2391)
v(1905)=statev(9)*v(2390)
v(1904)=statev(6)*v(2391)
v(1901)=statev(8)*v(2388)
v(1900)=statev(2)*v(2389)
v(1890)=statev(6)*v(2392)
v(1889)=statev(3)*v(2393)
v(1886)=statev(5)*v(2390)
v(1885)=statev(8)*v(2394)
v(1882)=statev(4)*v(2392)
v(1881)=statev(10)*v(2393)
v(1878)=statev(3)*v(2390)
v(1877)=statev(6)*v(2394)
v(1873)=statev(10)*v(2390)
v(1872)=statev(4)*v(2394)
v(1868)=statev(8)*v(2392)
v(1867)=statev(5)*v(2393)
v(1858)=statev(7)*v(2392)
v(1857)=statev(10)*v(2396)
v(1853)=statev(5)*v(2388)
v(1852)=statev(2)*v(2395)
v(1848)=statev(3)*v(2388)
v(1847)=statev(9)*v(2395)
v(1844)=statev(2)*v(2392)
v(1843)=statev(5)*v(2396)
v(1840)=statev(10)*v(2388)
v(1839)=statev(7)*v(2395)
v(1836)=statev(9)*v(2392)
v(1835)=statev(3)*v(2396)
v(1824)=-(statev(3)*v(2389))
v(1823)=statev(6)*v(2395)
v(1819)=-(statev(10)*v(2389))
v(1818)=statev(4)*v(2395)
v(1811)=-(statev(5)*v(2389))
v(1810)=statev(8)*v(2395)
v(1799)=-(statev(2)*v(2394))
v(1798)=statev(5)*v(2391)
v(1794)=-(statev(9)*v(2394))
v(1793)=statev(3)*v(2391)
v(1789)=-(statev(7)*v(2394))
v(1788)=statev(10)*v(2391)
v(1777)=-(statev(4)*v(2396))
v(1776)=statev(7)*v(2393)
v(1769)=-(statev(8)*v(2396))
v(1768)=statev(2)*v(2393)
v(1764)=-(statev(6)*v(2396))
v(1763)=statev(9)*v(2393)
v(310)=v(2394)+v(328)
v(306)=-v(2388)+v(321)
v(302)=v(2396)+v(331)
v(301)=-v(2390)+v(317)
v(298)=-v(2391)+v(319)
v(296)=v(2389)+v(327)
v(292)=-v(2392)+v(315)
v(290)=-v(2395)+v(325)
v(289)=-v(2393)+v(312)
v(586)=(v(2397)*v(2397))
v(609)=(v(2398)*v(2398))
v(585)=(v(2399)*v(2399))
v(2532)=v(585)+v(586)
v(584)=(v(2400)*v(2400))
v(2533)=v(584)+v(585)
v(2529)=v(584)+v(586)
v(2407)=v(584)+v(585)+v(586)
v(633)=(v(2401)*v(2401))
v(212)=v(2399)*x(13)+v(2397)*x(16)+v(2400)*x(19)
v(2425)=statev(18)/v(212)
v(2424)=-(x(16)/v(212))
v(2423)=-(x(12)/v(212))
v(2422)=x(18)/v(212)
v(2421)=-(x(13)/v(212))
v(2420)=statev(17)/v(212)
v(2419)=x(17)/v(212)
v(2418)=-(x(11)/v(212))
v(2417)=statev(13)/v(212)
v(2416)=x(15)/v(212)
v(2415)=statev(14)/v(212)
v(2414)=statev(15)/v(212)
v(2413)=statev(11)/v(212)
v(2412)=statev(16)/v(212)
v(565)=1d0/v(212)**3
v(2406)=(-2d0)*v(565)
v(573)=v(2400)*v(2406)
v(757)=v(573)*v(633)
v(725)=v(2536)*v(573)
v(717)=v(573)*v(609)
v(599)=v(2407)*v(573)
v(608)=-v(599)/3d0
v(572)=v(2402)*v(2406)
v(731)=v(572)*v(586)
v(571)=v(2403)*v(2406)
v(754)=v(571)*v(585)
v(570)=v(2397)*v(2406)
v(595)=v(2407)*v(570)
v(605)=-v(595)/3d0
v(569)=v(2404)*v(2406)
v(720)=v(569)*v(585)
v(568)=v(2401)*v(2406)
v(778)=v(568)*v(584)
v(691)=v(568)*v(609)
v(567)=v(2399)*v(2406)
v(590)=v(2407)*v(567)
v(602)=-v(590)/3d0
v(566)=v(2398)*v(2406)
v(742)=v(566)*v(584)
v(696)=v(566)*v(633)
v(564)=v(2405)*v(2406)
v(766)=v(564)*v(586)
v(264)=1d0/v(212)**2
v(2524)=2d0*v(264)
v(273)=-(v(2400)*v(264))
v(272)=-(v(2402)*v(264))
v(271)=-(v(2403)*v(264))
v(270)=-(v(2397)*v(264))
v(2430)=-(v(2402)*v(270))
v(269)=-(v(2404)*v(264))
v(2427)=-(v(2403)*v(269))
v(268)=-(v(2401)*v(264))
v(2408)=-(v(2400)*v(268))
v(2140)=statev(12)*v(2408)
v(2135)=statev(19)*v(2408)
v(2121)=statev(14)*v(2408)
v(267)=-(v(2399)*v(264))
v(2428)=-(v(2404)*v(267))
v(2426)=-(v(2403)*v(267))
v(266)=-(v(2398)*v(264))
v(2410)=-(v(2401)*v(266))
v(2409)=-(v(2400)*v(266))
v(2144)=statev(19)*v(2409)
v(2130)=statev(14)*v(2409)
v(2125)=statev(12)*v(2409)
v(1997)=statev(19)*v(2410)
v(1989)=statev(14)*v(2410)
v(1984)=statev(12)*v(2410)
v(265)=-(v(2405)*v(264))
v(2429)=-(v(2402)*v(265))
v(2411)=-(v(2397)*v(265))
v(2044)=statev(18)*v(2411)
v(2039)=statev(16)*v(2411)
v(2031)=statev(11)*v(2411)
v(2143)=v(2412)*x(17)
v(2133)=-(v(2412)*x(15))
v(2071)=-(v(2413)*x(12))
v(2063)=v(2413)*x(19)
v(2038)=statev(19)*v(2416)
v(1987)=-(v(2413)*x(13))
v(2109)=v(2414)*x(19)
v(2096)=-(v(2414)*x(14))
v(2072)=v(2415)*x(18)
v(2062)=-(v(2415)*x(16))
v(2142)=-(v(2417)*x(11))
v(2139)=v(2414)*x(18)
v(2138)=-(statev(18)*v(2416))
v(2134)=v(2417)*x(18)
v(2129)=v(2413)*x(17)
v(2128)=statev(17)*v(2418)
v(2124)=statev(15)*v(2418)
v(2123)=statev(18)*v(2419)
v(2120)=-(v(2413)*x(15))
v(2119)=v(2420)*x(18)
v(2108)=statev(12)*v(2421)
v(2105)=statev(14)*v(2419)
v(2104)=-(v(2420)*x(14))
v(2101)=v(2417)*x(19)
v(2100)=statev(19)*v(2421)
v(2097)=statev(12)*v(2419)
v(2092)=statev(19)*v(2419)
v(2091)=-(v(2417)*x(14))
v(2087)=-(v(2415)*x(13))
v(2086)=v(2420)*x(19)
v(2077)=v(2412)*x(19)
v(2076)=statev(19)*v(2424)
v(2067)=statev(12)*v(2422)
v(2066)=statev(18)*v(2423)
v(2059)=statev(19)*v(2422)
v(2058)=statev(16)*v(2423)
v(2055)=v(2425)*x(19)
v(2054)=statev(12)*v(2424)
v(2043)=statev(12)*v(2416)
v(2042)=-(v(2414)*x(12))
v(2037)=-(v(2417)*x(12))
v(2030)=v(2415)*x(15)
v(2029)=-(v(2420)*x(12))
v(2018)=v(2413)*x(14)
v(2017)=-(v(2415)*x(11))
v(2013)=v(2425)*x(14)
v(2012)=statev(12)*v(2418)
v(2008)=v(2412)*x(14)
v(2007)=statev(19)*v(2418)
v(1996)=v(2417)*x(16)
v(1995)=-(v(2412)*x(13))
v(1988)=v(2420)*x(16)
v(1983)=v(2414)*x(16)
v(1982)=statev(18)*v(2421)
v(2078)=statev(13)*v(2427)
v(2073)=statev(17)*v(2426)
v(2068)=statev(15)*v(2426)
v(2064)=statev(17)*v(2427)
v(2060)=statev(13)*v(2426)
v(2056)=statev(15)*v(2427)
v(635)=(v(2403)*v(2403))
v(2531)=v(633)+v(635)
v(769)=v(567)*v(635)
v(704)=v(569)*v(635)
v(2019)=statev(17)*v(2428)
v(2014)=statev(15)*v(2428)
v(2009)=statev(13)*v(2428)
v(736)=v(2537)*v(567)
v(611)=(v(2404)*v(2404))
v(2528)=v(609)+v(611)
v(728)=v(567)*v(611)
v(699)=v(571)*v(611)
v(2110)=statev(18)*v(2429)
v(2106)=statev(11)*v(2430)
v(2102)=statev(16)*v(2429)
v(2098)=statev(18)*v(2430)
v(2093)=statev(16)*v(2430)
v(2088)=statev(11)*v(2429)
v(610)=(v(2402)*v(2402))
v(2527)=v(609)+v(610)
v(2526)=v(610)+v(611)
v(2431)=v(609)+v(610)+v(611)
v(739)=v(570)*v(610)
v(707)=v(564)*v(610)
v(622)=v(2431)*v(572)
v(631)=-v(622)/3d0
v(619)=v(2431)*v(569)
v(628)=-v(619)/3d0
v(613)=v(2431)*v(566)
v(625)=-v(613)/3d0
v(714)=v(2538)*v(570)
v(634)=(v(2405)*v(2405))
v(2530)=v(634)+v(635)
v(2525)=v(633)+v(634)
v(2432)=v(633)+v(634)+v(635)
v(745)=v(570)*v(634)
v(688)=v(572)*v(634)
v(644)=v(2432)*v(571)
v(655)=-v(644)/3d0
v(640)=v(2432)*v(568)
v(652)=-v(640)/3d0
v(636)=v(2432)*v(564)
v(649)=-v(636)/3d0
v(803)=(v(2433)*v(2433))
v(826)=(v(2434)*v(2434))
v(802)=(v(2435)*v(2435))
v(2562)=v(802)+v(803)
v(801)=(v(2436)*v(2436))
v(2563)=v(801)+v(802)
v(2559)=v(801)+v(803)
v(2443)=v(801)+v(802)+v(803)
v(850)=(v(2437)*v(2437))
v(230)=v(2435)*x(22)+v(2433)*x(25)+v(2436)*x(28)
v(2461)=statev(27)/v(230)
v(2460)=-(x(25)/v(230))
v(2459)=-(x(21)/v(230))
v(2458)=x(27)/v(230)
v(2457)=-(x(22)/v(230))
v(2456)=statev(26)/v(230)
v(2455)=x(26)/v(230)
v(2454)=-(x(20)/v(230))
v(2453)=statev(22)/v(230)
v(2452)=x(24)/v(230)
v(2451)=statev(23)/v(230)
v(2450)=statev(24)/v(230)
v(2449)=statev(20)/v(230)
v(2448)=statev(25)/v(230)
v(782)=1d0/v(230)**3
v(2442)=(-2d0)*v(782)
v(790)=v(2436)*v(2442)
v(974)=v(790)*v(850)
v(942)=v(2566)*v(790)
v(934)=v(790)*v(826)
v(816)=v(2443)*v(790)
v(825)=-v(816)/3d0
v(789)=v(2438)*v(2442)
v(948)=v(789)*v(803)
v(788)=v(2439)*v(2442)
v(971)=v(788)*v(802)
v(787)=v(2433)*v(2442)
v(812)=v(2443)*v(787)
v(822)=-v(812)/3d0
v(786)=v(2440)*v(2442)
v(937)=v(786)*v(802)
v(785)=v(2437)*v(2442)
v(995)=v(785)*v(801)
v(908)=v(785)*v(826)
v(784)=v(2435)*v(2442)
v(807)=v(2443)*v(784)
v(819)=-v(807)/3d0
v(783)=v(2434)*v(2442)
v(959)=v(783)*v(801)
v(913)=v(783)*v(850)
v(781)=v(2441)*v(2442)
v(983)=v(781)*v(803)
v(278)=1d0/v(230)**2
v(2554)=2d0*v(278)
v(287)=-(v(2436)*v(278))
v(286)=-(v(2438)*v(278))
v(285)=-(v(2439)*v(278))
v(284)=-(v(2433)*v(278))
v(2466)=-(v(2438)*v(284))
v(283)=-(v(2440)*v(278))
v(2463)=-(v(2439)*v(283))
v(282)=-(v(2437)*v(278))
v(2444)=-(v(2436)*v(282))
v(2359)=statev(21)*v(2444)
v(2354)=statev(28)*v(2444)
v(2340)=statev(23)*v(2444)
v(281)=-(v(2435)*v(278))
v(2464)=-(v(2440)*v(281))
v(2462)=-(v(2439)*v(281))
v(280)=-(v(2434)*v(278))
v(2446)=-(v(2437)*v(280))
v(2445)=-(v(2436)*v(280))
v(2363)=statev(28)*v(2445)
v(2349)=statev(23)*v(2445)
v(2344)=statev(21)*v(2445)
v(2216)=statev(28)*v(2446)
v(2208)=statev(23)*v(2446)
v(2203)=statev(21)*v(2446)
v(279)=-(v(2441)*v(278))
v(2465)=-(v(2438)*v(279))
v(2447)=-(v(2433)*v(279))
v(2263)=statev(27)*v(2447)
v(2258)=statev(25)*v(2447)
v(2250)=statev(20)*v(2447)
v(2362)=v(2448)*x(26)
v(2352)=-(v(2448)*x(24))
v(2290)=-(v(2449)*x(21))
v(2282)=v(2449)*x(28)
v(2257)=statev(28)*v(2452)
v(2206)=-(v(2449)*x(22))
v(2328)=v(2450)*x(28)
v(2315)=-(v(2450)*x(23))
v(2291)=v(2451)*x(27)
v(2281)=-(v(2451)*x(25))
v(2361)=-(v(2453)*x(20))
v(2358)=v(2450)*x(27)
v(2357)=-(statev(27)*v(2452))
v(2353)=v(2453)*x(27)
v(2348)=v(2449)*x(26)
v(2347)=statev(26)*v(2454)
v(2343)=statev(24)*v(2454)
v(2342)=statev(27)*v(2455)
v(2339)=-(v(2449)*x(24))
v(2338)=v(2456)*x(27)
v(2327)=statev(21)*v(2457)
v(2324)=statev(23)*v(2455)
v(2323)=-(v(2456)*x(23))
v(2320)=v(2453)*x(28)
v(2319)=statev(28)*v(2457)
v(2316)=statev(21)*v(2455)
v(2311)=statev(28)*v(2455)
v(2310)=-(v(2453)*x(23))
v(2306)=-(v(2451)*x(22))
v(2305)=v(2456)*x(28)
v(2296)=v(2448)*x(28)
v(2295)=statev(28)*v(2460)
v(2286)=statev(21)*v(2458)
v(2285)=statev(27)*v(2459)
v(2278)=statev(28)*v(2458)
v(2277)=statev(25)*v(2459)
v(2274)=v(2461)*x(28)
v(2273)=statev(21)*v(2460)
v(2262)=statev(21)*v(2452)
v(2261)=-(v(2450)*x(21))
v(2256)=-(v(2453)*x(21))
v(2249)=v(2451)*x(24)
v(2248)=-(v(2456)*x(21))
v(2237)=v(2449)*x(23)
v(2236)=-(v(2451)*x(20))
v(2232)=v(2461)*x(23)
v(2231)=statev(21)*v(2454)
v(2227)=v(2448)*x(23)
v(2226)=statev(28)*v(2454)
v(2215)=v(2453)*x(25)
v(2214)=-(v(2448)*x(22))
v(2207)=v(2456)*x(25)
v(2202)=v(2450)*x(25)
v(2201)=statev(27)*v(2457)
v(2297)=statev(22)*v(2463)
v(2292)=statev(26)*v(2462)
v(2287)=statev(24)*v(2462)
v(2283)=statev(26)*v(2463)
v(2279)=statev(22)*v(2462)
v(2275)=statev(24)*v(2463)
v(852)=(v(2439)*v(2439))
v(2561)=v(850)+v(852)
v(986)=v(784)*v(852)
v(921)=v(786)*v(852)
v(2238)=statev(26)*v(2464)
v(2233)=statev(24)*v(2464)
v(2228)=statev(22)*v(2464)
v(953)=v(2567)*v(784)
v(828)=(v(2440)*v(2440))
v(2558)=v(826)+v(828)
v(945)=v(784)*v(828)
v(916)=v(788)*v(828)
v(2329)=statev(27)*v(2465)
v(2325)=statev(20)*v(2466)
v(2321)=statev(25)*v(2465)
v(2317)=statev(27)*v(2466)
v(2312)=statev(25)*v(2466)
v(2307)=statev(20)*v(2465)
v(827)=(v(2438)*v(2438))
v(2557)=v(826)+v(827)
v(2556)=v(827)+v(828)
v(2467)=v(826)+v(827)+v(828)
v(956)=v(787)*v(827)
v(924)=v(781)*v(827)
v(839)=v(2467)*v(789)
v(848)=-v(839)/3d0
v(836)=v(2467)*v(786)
v(845)=-v(836)/3d0
v(830)=v(2467)*v(783)
v(842)=-v(830)/3d0
v(931)=v(2568)*v(787)
v(851)=(v(2441)*v(2441))
v(2560)=v(851)+v(852)
v(2555)=v(850)+v(851)
v(2468)=v(850)+v(851)+v(852)
v(962)=v(787)*v(851)
v(905)=v(789)*v(851)
v(861)=v(2468)*v(788)
v(872)=-v(861)/3d0
v(857)=v(2468)*v(785)
v(869)=-v(857)/3d0
v(853)=v(2468)*v(781)
v(866)=-v(853)/3d0
v(408)=-(Fnew(1)*v(2379))
v(396)=Fnew(1)*v(293)
v(360)=Fnew(1)*v(295)
v(424)=-(Fnew(2)*v(2375))
v(412)=Fnew(2)*v(299)
v(373)=Fnew(2)*v(304)
v(436)=-(Fnew(3)*v(2384))
v(429)=-(Fnew(3)*v(2381))
v(386)=-(Fnew(3)*v(2383))
v(401)=-(Fnew(4)*v(2375))
v(398)=Fnew(4)*v(304)
v(364)=Fnew(4)*v(299)
v(417)=-(Fnew(5)*v(2384))
v(414)=-(Fnew(5)*v(2383))
v(377)=-(Fnew(5)*v(2381))
v(434)=-(Fnew(6)*v(2379))
v(426)=Fnew(6)*v(295)
v(390)=Fnew(6)*v(293)
v(410)=Fnew(7)*v(311)+Fnew(1)*v(320)+Fnew(4)*v(322)
v(409)=Fnew(7)*v(310)+Fnew(4)*v(317)+v(408)
v(406)=-(Fnew(7)*v(2383))
v(407)=Fnew(4)*v(321)+Fnew(1)*v(325)+v(406)
v(405)=Fnew(7)*v(308)+Fnew(4)*v(320)+Fnew(1)*v(329)
v(403)=-(Fnew(7)*v(2381))
v(404)=Fnew(4)*v(319)+Fnew(1)*v(328)+v(403)
v(402)=Fnew(7)*v(306)+Fnew(1)*v(327)+v(401)
v(400)=Fnew(7)*v(305)+Fnew(1)*v(308)+Fnew(4)*v(311)
v(399)=Fnew(7)*v(298)+Fnew(1)*v(301)+v(398)
v(397)=Fnew(7)*v(290)+Fnew(4)*v(296)+v(396)
v(371)=Fnew(1)*v(317)+Fnew(7)*v(319)+v(398)
v(370)=Fnew(4)*v(303)+Fnew(7)*v(313)+Fnew(1)*v(316)
v(368)=-(Fnew(7)*v(2384))
v(369)=Fnew(4)*v(302)+Fnew(1)*v(315)+v(368)
v(367)=Fnew(4)*v(301)+Fnew(7)*v(328)+v(408)
v(366)=Fnew(4)*v(300)+Fnew(1)*v(313)+Fnew(7)*v(332)
v(365)=Fnew(1)*v(312)+Fnew(7)*v(331)+v(364)
v(363)=Fnew(4)*v(298)+Fnew(1)*v(310)+v(403)
v(362)=Fnew(4)*v(297)+Fnew(7)*v(300)+Fnew(1)*v(303)
v(361)=Fnew(4)*v(289)+Fnew(7)*v(292)+v(360)
v(341)=Fnew(1)*v(296)+Fnew(7)*v(321)+v(401)
v(340)=Fnew(4)*v(312)+Fnew(7)*v(315)+v(360)
v(339)=Fnew(1)*v(294)+Fnew(4)*v(323)+Fnew(7)*v(326)
v(338)=Fnew(7)*v(325)+Fnew(4)*v(327)+v(396)
v(337)=Fnew(1)*v(292)+Fnew(4)*v(331)+v(368)
v(336)=Fnew(1)*v(291)+Fnew(7)*v(323)+Fnew(4)*v(330)
v(335)=Fnew(1)*v(290)+Fnew(4)*v(306)+v(406)
v(334)=Fnew(1)*v(289)+Fnew(7)*v(302)+v(364)
v(333)=Fnew(1)*v(288)+Fnew(4)*v(291)+Fnew(7)*v(294)
v(425)=Fnew(8)*v(296)+Fnew(5)*v(321)+v(424)
v(422)=Fnew(8)*v(295)
v(423)=Fnew(2)*v(312)+Fnew(5)*v(315)+v(422)
v(421)=Fnew(8)*v(294)+Fnew(2)*v(323)+Fnew(5)*v(326)
v(419)=Fnew(8)*v(293)
v(420)=Fnew(5)*v(325)+Fnew(2)*v(327)+v(419)
v(418)=Fnew(8)*v(292)+Fnew(2)*v(331)+v(417)
v(416)=Fnew(8)*v(291)+Fnew(5)*v(323)+Fnew(2)*v(330)
v(415)=Fnew(8)*v(290)+Fnew(2)*v(306)+v(414)
v(413)=Fnew(8)*v(289)+Fnew(5)*v(302)+v(412)
v(411)=Fnew(8)*v(288)+Fnew(2)*v(291)+Fnew(5)*v(294)
v(383)=Fnew(5)*v(311)+Fnew(8)*v(320)+Fnew(2)*v(322)
v(381)=-(Fnew(8)*v(2379))
v(382)=Fnew(5)*v(310)+Fnew(2)*v(317)+v(381)
v(380)=Fnew(2)*v(321)+Fnew(8)*v(325)+v(414)
v(379)=Fnew(5)*v(308)+Fnew(2)*v(320)+Fnew(8)*v(329)
v(378)=Fnew(2)*v(319)+Fnew(8)*v(328)+v(377)
v(376)=Fnew(5)*v(306)+Fnew(8)*v(327)+v(424)
v(375)=Fnew(5)*v(305)+Fnew(8)*v(308)+Fnew(2)*v(311)
v(374)=Fnew(5)*v(298)+Fnew(8)*v(301)+v(373)
v(372)=Fnew(5)*v(290)+Fnew(2)*v(296)+v(419)
v(350)=Fnew(8)*v(317)+Fnew(5)*v(319)+v(373)
v(349)=Fnew(2)*v(303)+Fnew(5)*v(313)+Fnew(8)*v(316)
v(348)=Fnew(2)*v(302)+Fnew(8)*v(315)+v(417)
v(347)=Fnew(2)*v(301)+Fnew(5)*v(328)+v(381)
v(346)=Fnew(2)*v(300)+Fnew(8)*v(313)+Fnew(5)*v(332)
v(345)=Fnew(8)*v(312)+Fnew(5)*v(331)+v(412)
v(344)=Fnew(2)*v(298)+Fnew(8)*v(310)+v(377)
v(343)=Fnew(2)*v(297)+Fnew(5)*v(300)+Fnew(8)*v(303)
v(342)=Fnew(2)*v(289)+Fnew(5)*v(292)+v(422)
v(439)=Fnew(9)*v(304)
v(440)=Fnew(6)*v(317)+Fnew(3)*v(319)+v(439)
v(438)=Fnew(9)*v(303)+Fnew(3)*v(313)+Fnew(6)*v(316)
v(437)=Fnew(9)*v(302)+Fnew(6)*v(315)+v(436)
v(435)=Fnew(9)*v(301)+Fnew(3)*v(328)+v(434)
v(433)=Fnew(9)*v(300)+Fnew(6)*v(313)+Fnew(3)*v(332)
v(431)=Fnew(9)*v(299)
v(432)=Fnew(6)*v(312)+Fnew(3)*v(331)+v(431)
v(430)=Fnew(9)*v(298)+Fnew(6)*v(310)+v(429)
v(428)=Fnew(9)*v(297)+Fnew(3)*v(300)+Fnew(6)*v(303)
v(427)=Fnew(9)*v(289)+Fnew(3)*v(292)+v(426)
v(394)=-(Fnew(9)*v(2375))
v(395)=Fnew(6)*v(296)+Fnew(3)*v(321)+v(394)
v(393)=Fnew(9)*v(312)+Fnew(3)*v(315)+v(426)
v(392)=Fnew(6)*v(294)+Fnew(9)*v(323)+Fnew(3)*v(326)
v(391)=Fnew(3)*v(325)+Fnew(9)*v(327)+v(390)
v(389)=Fnew(6)*v(292)+Fnew(9)*v(331)+v(436)
v(388)=Fnew(6)*v(291)+Fnew(3)*v(323)+Fnew(9)*v(330)
v(387)=Fnew(6)*v(290)+Fnew(9)*v(306)+v(386)
v(385)=Fnew(6)*v(289)+Fnew(3)*v(302)+v(431)
v(384)=Fnew(6)*v(288)+Fnew(9)*v(291)+Fnew(3)*v(294)
v(359)=Fnew(3)*v(311)+Fnew(6)*v(320)+Fnew(9)*v(322)
v(358)=Fnew(3)*v(310)+Fnew(9)*v(317)+v(434)
v(357)=Fnew(9)*v(321)+Fnew(6)*v(325)+v(386)
v(356)=Fnew(3)*v(308)+Fnew(9)*v(320)+Fnew(6)*v(329)
v(355)=Fnew(9)*v(319)+Fnew(6)*v(328)+v(429)
v(354)=Fnew(3)*v(306)+Fnew(6)*v(327)+v(394)
v(353)=Fnew(3)*v(305)+Fnew(6)*v(308)+Fnew(9)*v(311)
v(352)=Fnew(3)*v(298)+Fnew(6)*v(301)+v(439)
v(351)=Fnew(3)*v(290)+Fnew(9)*v(296)+v(390)
v(78)=v(2385)/v(249)
v(80)=v(2371)/v(249)
v(81)=v(2373)/v(249)
v(82)=v(2378)/v(249)
v(83)=v(2372)/v(249)
v(84)=v(2382)/v(249)
v(85)=v(2370)/v(249)
v(86)=v(2374)/v(249)
v(87)=v(2380)/v(249)
v(88)=Fnew(1)*v(78)+Fnew(7)*v(84)+Fnew(4)*v(86)
v(89)=Fnew(2)*v(80)+Fnew(8)*v(82)+Fnew(5)*v(87)
v(90)=Fnew(3)*v(81)+Fnew(9)*v(83)+Fnew(6)*v(85)
v(91)=Fnew(4)*v(80)+Fnew(1)*v(82)+Fnew(7)*v(87)
v(92)=Fnew(5)*v(81)+Fnew(2)*v(83)+Fnew(8)*v(85)
v(93)=Fnew(6)*v(78)+Fnew(3)*v(84)+Fnew(9)*v(86)
v(94)=Fnew(7)*v(81)+Fnew(4)*v(83)+Fnew(1)*v(85)
v(2485)=v(433)*v(90)+v(346)*v(92)+v(366)*v(94)
v(2483)=v(438)*v(90)+v(349)*v(92)+v(370)*v(94)
v(2481)=v(428)*v(90)+v(343)*v(92)+v(362)*v(94)
v(2477)=v(355)*v(90)+v(378)*v(92)+v(404)*v(94)
v(2476)=v(358)*v(90)+v(382)*v(92)+v(409)*v(94)
v(2475)=v(352)*v(90)+v(374)*v(92)+v(399)*v(94)
v(2474)=v(392)*v(90)+v(421)*v(92)+v(339)*v(94)
v(2473)=v(384)*v(90)+v(411)*v(92)+v(333)*v(94)
v(2472)=v(388)*v(90)+v(416)*v(92)+v(336)*v(94)
v(2471)=v(357)*v(90)+v(380)*v(92)+v(407)*v(94)
v(2470)=v(351)*v(90)+v(372)*v(92)+v(397)*v(94)
v(2469)=v(354)*v(90)+v(376)*v(92)+v(402)*v(94)
v(485)=2d0*(v(359)*v(90)+v(383)*v(92)+v(410)*v(94))
v(494)=-v(485)/3d0
v(484)=2d0*v(2476)
v(493)=-v(484)/3d0
v(483)=2d0*v(2471)
v(492)=-v(483)/3d0
v(482)=2d0*(v(356)*v(90)+v(379)*v(92)+v(405)*v(94))
v(491)=-v(482)/3d0
v(481)=2d0*v(2477)
v(490)=-v(481)/3d0
v(480)=2d0*v(2469)
v(489)=-v(480)/3d0
v(479)=2d0*(v(353)*v(90)+v(375)*v(92)+v(400)*v(94))
v(488)=-v(479)/3d0
v(478)=2d0*v(2475)
v(487)=-v(478)/3d0
v(477)=2d0*v(2470)
v(486)=-v(477)/3d0
v(95)=Fnew(8)*v(78)+Fnew(5)*v(84)+Fnew(2)*v(86)
v(2486)=v(370)*v(88)+v(438)*v(93)+v(349)*v(95)
v(2484)=v(362)*v(88)+v(428)*v(93)+v(343)*v(95)
v(2482)=v(366)*v(88)+v(433)*v(93)+v(346)*v(95)
v(2480)=v(340)*v(88)+v(393)*v(93)+v(423)*v(95)
v(2479)=v(334)*v(88)+v(385)*v(93)+v(413)*v(95)
v(2478)=v(337)*v(88)+v(389)*v(93)+v(418)*v(95)
v(524)=v(2469)+v(395)*v(90)+v(425)*v(92)+v(341)*v(94)
v(522)=v(2474)+v(407)*v(88)+v(357)*v(93)+v(380)*v(95)
v(521)=v(2470)+v(391)*v(90)+v(420)*v(92)+v(338)*v(94)
v(519)=v(2472)+v(402)*v(88)+v(354)*v(93)+v(376)*v(95)
v(518)=v(2471)+v(387)*v(90)+v(415)*v(92)+v(335)*v(94)
v(516)=v(2473)+v(397)*v(88)+v(351)*v(93)+v(372)*v(95)
v(512)=v(363)*v(88)+v(430)*v(93)+v(344)*v(95)
v(508)=v(371)*v(88)+v(440)*v(93)+v(350)*v(95)
v(504)=v(367)*v(88)+v(435)*v(93)+v(347)*v(95)
v(449)=2d0*v(2472)
v(458)=-v(449)/3d0
v(448)=2d0*v(2480)
v(457)=-v(448)/3d0
v(447)=2d0*(v(339)*v(88)+v(392)*v(93)+v(421)*v(95))
v(456)=-v(447)/3d0
v(446)=2d0*v(2473)
v(455)=-v(446)/3d0
v(445)=2d0*v(2478)
v(454)=-v(445)/3d0
v(444)=2d0*(v(336)*v(88)+v(388)*v(93)+v(416)*v(95))
v(453)=-v(444)/3d0
v(443)=2d0*v(2474)
v(452)=-v(443)/3d0
v(442)=2d0*v(2479)
v(451)=-v(442)/3d0
v(441)=2d0*(v(333)*v(88)+v(384)*v(93)+v(411)*v(95))
v(450)=-v(441)/3d0
v(96)=Fnew(9)*v(80)+Fnew(6)*v(82)+Fnew(3)*v(87)
v(515)=v(2475)+v(440)*v(90)+v(350)*v(92)+v(371)*v(94)
v(514)=v(2483)+v(382)*v(89)+v(409)*v(91)+v(358)*v(96)
v(513)=v(512)+v(380)*v(89)+v(407)*v(91)+v(357)*v(96)
v(511)=v(2476)+v(435)*v(90)+v(347)*v(92)+v(367)*v(94)
v(510)=v(2485)+v(378)*v(89)+v(404)*v(91)+v(355)*v(96)
v(509)=v(508)+v(376)*v(89)+v(402)*v(91)+v(354)*v(96)
v(507)=v(2477)+v(430)*v(90)+v(344)*v(92)+v(363)*v(94)
v(506)=v(2481)+v(374)*v(89)+v(399)*v(91)+v(352)*v(96)
v(505)=v(504)+v(372)*v(89)+v(397)*v(91)+v(351)*v(96)
v(503)=v(508)+v(425)*v(89)+v(341)*v(91)+v(395)*v(96)
v(517)=v(503)-2d0*v(508)+v(509)
v(502)=v(2486)+v(423)*v(89)+v(340)*v(91)+v(393)*v(96)
v(501)=v(2478)+v(369)*v(88)+v(437)*v(93)+v(348)*v(95)
v(500)=v(504)+v(420)*v(89)+v(338)*v(91)+v(391)*v(96)
v(523)=v(500)-2d0*v(504)+v(505)
v(499)=v(2482)+v(418)*v(89)+v(337)*v(91)+v(389)*v(96)
v(498)=v(2479)+v(365)*v(88)+v(432)*v(93)+v(345)*v(95)
v(497)=v(512)+v(415)*v(89)+v(335)*v(91)+v(387)*v(96)
v(520)=v(497)-2d0*v(512)+v(513)
v(496)=v(2484)+v(413)*v(89)+v(334)*v(91)+v(385)*v(96)
v(495)=v(2480)+v(361)*v(88)+v(427)*v(93)+v(342)*v(95)
v(467)=2d0*v(2481)
v(476)=-v(467)/3d0
v(466)=2d0*(v(349)*v(89)+v(370)*v(91)+v(438)*v(96))
v(475)=-v(466)/3d0
v(465)=2d0*v(2482)
v(474)=-v(465)/3d0
v(464)=2d0*v(2483)
v(473)=-v(464)/3d0
v(463)=2d0*(v(346)*v(89)+v(366)*v(91)+v(433)*v(96))
v(472)=-v(463)/3d0
v(462)=2d0*v(2484)
v(471)=-v(462)/3d0
v(461)=2d0*v(2485)
v(470)=-v(461)/3d0
v(460)=2d0*(v(343)*v(89)+v(362)*v(91)+v(428)*v(96))
v(469)=-v(460)/3d0
v(459)=2d0*v(2486)
v(468)=-v(459)/3d0
v(97)=(v(88)*v(88))+(v(93)*v(93))+(v(95)*v(95))
v(109)=-v(97)/3d0
v(98)=(v(89)*v(89))+(v(91)*v(91))+(v(96)*v(96))
v(110)=-v(98)/3d0
v(99)=(v(90)*v(90))+(v(92)*v(92))+(v(94)*v(94))
v(1018)=v(109)+v(110)+(2d0/3d0)*v(99)
v(105)=-v(99)/3d0
v(1008)=v(105)+v(109)+(2d0/3d0)*v(98)
v(998)=v(105)+v(110)+(2d0/3d0)*v(97)
v(100)=v(88)*v(91)+v(89)*v(95)+v(93)*v(96)
v(2487)=2d0*v(100)
v(530)=-(v(2487)*v(99))
v(527)=(v(100)*v(100))
v(2491)=-v(527)+v(97)*v(98)
v(101)=v(89)*v(92)+v(91)*v(94)+v(90)*v(96)
v(533)=v(101)*v(2487)
v(531)=(-2d0)*v(101)*v(97)
v(525)=(v(101)*v(101))
v(2489)=-v(525)+v(98)*v(99)
v(102)=v(90)*v(93)+v(88)*v(94)+v(92)*v(95)
v(2488)=2d0*v(102)
v(534)=-(v(2488)*v(98))
v(2494)=v(533)+v(534)
v(532)=v(100)*v(2488)
v(2493)=v(531)+v(532)
v(528)=v(101)*v(2488)
v(2492)=v(528)+v(530)
v(526)=(v(102)*v(102))
v(2490)=-v(526)+v(97)*v(99)
v(542)=v(2489)*v(449)+v(2490)*v(467)+v(2491)*v(485)+v(2492)*v(503)+v(2493)*v(515)+v(2494)*v(524)
v(541)=v(2489)*v(448)+v(2490)*v(466)+v(2491)*v(484)+v(2492)*v(502)+v(2493)*v(514)+v(2494)*v(523)
v(540)=v(2489)*v(447)+v(2490)*v(465)+v(2491)*v(483)+v(2492)*v(501)+v(2493)*v(513)+v(2494)*v(522)
v(539)=v(2489)*v(446)+v(2490)*v(464)+v(2491)*v(482)+v(2492)*v(500)+v(2493)*v(511)+v(2494)*v(521)
v(538)=v(2489)*v(445)+v(2490)*v(463)+v(2491)*v(481)+v(2492)*v(499)+v(2493)*v(510)+v(2494)*v(520)
v(537)=v(2489)*v(444)+v(2490)*v(462)+v(2491)*v(480)+v(2492)*v(498)+v(2493)*v(509)+v(2494)*v(519)
v(536)=v(2489)*v(443)+v(2490)*v(461)+v(2491)*v(479)+v(2492)*v(497)+v(2493)*v(507)+v(2494)*v(518)
v(535)=v(2489)*v(442)+v(2490)*v(460)+v(2491)*v(478)+v(2492)*v(496)+v(2493)*v(506)+v(2494)*v(517)
v(529)=v(2489)*v(441)+v(2490)*v(459)+v(2491)*v(477)+v(2492)*v(495)+v(2493)*v(505)+v(2494)*v(516)
v(103)=v(100)*v(528)-v(525)*v(97)-v(526)*v(98)+v(2491)*v(99)
v(555)=1d0/v(103)**0.13333333333333333d1
v(2495)=-v(555)/3d0
v(563)=v(2495)*v(542)
v(562)=v(2495)*v(541)
v(561)=v(2495)*v(540)
v(560)=v(2495)*v(539)
v(559)=v(2495)*v(538)
v(558)=v(2495)*v(537)
v(557)=v(2495)*v(536)
v(556)=v(2495)*v(535)
v(554)=v(2495)*v(529)
v(543)=sqrt(v(103))
v(107)=props(2)*(v(103)-v(543))
v(106)=1d0/v(103)**0.3333333333333333d0
v(2584)=props(1)*v(106)
v(2523)=props(1)*(v(106)*((2d0/3d0)*v(441)+v(468)+v(486))+v(554)*v(998))
v(2522)=props(1)*(v(106)*(v(450)+v(468)+(2d0/3d0)*v(477))+v(1018)*v(554))
v(2521)=props(1)*(v(106)*(v(450)+(2d0/3d0)*v(459)+v(486))+v(1008)*v(554))
v(2520)=props(1)*(v(106)*((2d0/3d0)*v(442)+v(469)+v(487))+v(556)*v(998))
v(2519)=props(1)*(v(106)*(v(451)+v(469)+(2d0/3d0)*v(478))+v(1018)*v(556))
v(2518)=props(1)*(v(106)*(v(451)+(2d0/3d0)*v(460)+v(487))+v(1008)*v(556))
v(2517)=props(1)*(v(106)*((2d0/3d0)*v(443)+v(470)+v(488))+v(557)*v(998))
v(2516)=props(1)*(v(106)*(v(452)+v(470)+(2d0/3d0)*v(479))+v(1018)*v(557))
v(2515)=props(1)*(v(106)*(v(452)+(2d0/3d0)*v(461)+v(488))+v(1008)*v(557))
v(2514)=props(1)*(v(106)*((2d0/3d0)*v(444)+v(471)+v(489))+v(558)*v(998))
v(2513)=props(1)*(v(106)*(v(453)+v(471)+(2d0/3d0)*v(480))+v(1018)*v(558))
v(2512)=props(1)*(v(106)*(v(453)+(2d0/3d0)*v(462)+v(489))+v(1008)*v(558))
v(2511)=props(1)*(v(106)*((2d0/3d0)*v(445)+v(472)+v(490))+v(559)*v(998))
v(2510)=props(1)*(v(106)*(v(454)+v(472)+(2d0/3d0)*v(481))+v(1018)*v(559))
v(2509)=props(1)*(v(106)*(v(454)+(2d0/3d0)*v(463)+v(490))+v(1008)*v(559))
v(2508)=props(1)*(v(106)*((2d0/3d0)*v(446)+v(473)+v(491))+v(560)*v(998))
v(2507)=props(1)*(v(106)*(v(455)+v(473)+(2d0/3d0)*v(482))+v(1018)*v(560))
v(2506)=props(1)*(v(106)*(v(455)+(2d0/3d0)*v(464)+v(491))+v(1008)*v(560))
v(2505)=props(1)*(v(106)*((2d0/3d0)*v(447)+v(474)+v(492))+v(561)*v(998))
v(2504)=props(1)*(v(106)*(v(456)+v(474)+(2d0/3d0)*v(483))+v(1018)*v(561))
v(2503)=props(1)*(v(106)*(v(456)+(2d0/3d0)*v(465)+v(492))+v(1008)*v(561))
v(2502)=props(1)*(v(106)*((2d0/3d0)*v(448)+v(475)+v(493))+v(562)*v(998))
v(2501)=props(1)*(v(106)*(v(457)+v(475)+(2d0/3d0)*v(484))+v(1018)*v(562))
v(2500)=props(1)*(v(106)*(v(457)+(2d0/3d0)*v(466)+v(493))+v(1008)*v(562))
v(2499)=props(1)*(v(106)*((2d0/3d0)*v(449)+v(476)+v(494))+v(563)*v(998))
v(2498)=props(1)*(v(106)*(v(458)+v(476)+(2d0/3d0)*v(485))+v(1018)*v(563))
v(2497)=props(1)*(v(106)*(v(458)+(2d0/3d0)*v(467)+v(494))+v(1008)*v(563))
v(1054)=props(1)*(v(106)*v(524)+v(102)*v(563))
v(1053)=props(1)*(v(106)*v(523)+v(102)*v(562))
v(1052)=props(1)*(v(106)*v(522)+v(102)*v(561))
v(1051)=props(1)*(v(106)*v(521)+v(102)*v(560))
v(1050)=props(1)*(v(106)*v(520)+v(102)*v(559))
v(1049)=props(1)*(v(106)*v(519)+v(102)*v(558))
v(1048)=props(1)*(v(106)*v(518)+v(102)*v(557))
v(1047)=props(1)*(v(106)*v(517)+v(102)*v(556))
v(1046)=props(1)*(v(106)*v(516)+v(102)*v(554))
v(1045)=props(1)*(v(106)*v(515)+v(101)*v(563))
v(1044)=props(1)*(v(106)*v(514)+v(101)*v(562))
v(1043)=props(1)*(v(106)*v(513)+v(101)*v(561))
v(1042)=props(1)*(v(106)*v(511)+v(101)*v(560))
v(1041)=props(1)*(v(106)*v(510)+v(101)*v(559))
v(1040)=props(1)*(v(106)*v(509)+v(101)*v(558))
v(1039)=props(1)*(v(106)*v(507)+v(101)*v(557))
v(1038)=props(1)*(v(106)*v(506)+v(101)*v(556))
v(1037)=props(1)*(v(106)*v(505)+v(101)*v(554))
v(1036)=props(1)*(v(106)*v(503)+v(100)*v(563))
v(1035)=props(1)*(v(106)*v(502)+v(100)*v(562))
v(1034)=props(1)*(v(106)*v(501)+v(100)*v(561))
v(1033)=props(1)*(v(106)*v(500)+v(100)*v(560))
v(1032)=props(1)*(v(106)*v(499)+v(100)*v(559))
v(1031)=props(1)*(v(106)*v(498)+v(100)*v(558))
v(1030)=props(1)*(v(106)*v(497)+v(100)*v(557))
v(1029)=props(1)*(v(106)*v(496)+v(100)*v(556))
v(1028)=props(1)*(v(106)*v(495)+v(100)*v(554))
v(775)=v(267)*x(19)
v(774)=-(v(273)*x(13))
v(773)=-(v(271)*x(14))
v(772)=v(268)*x(17)
v(763)=-(v(270)*x(19))
v(762)=v(273)*x(16)
v(761)=v(265)*x(14)
v(760)=-(v(268)*x(11))
v(751)=v(270)*x(13)
v(750)=-(v(267)*x(16))
v(749)=v(271)*x(11)
v(748)=-(v(265)*x(17))
v(735)=-(v(272)*x(12))
v(734)=v(266)*x(18)
v(724)=-(v(269)*x(18))
v(723)=v(272)*x(15)
v(713)=v(269)*x(12)
v(712)=-(v(266)*x(15))
v(646)=(-2d0)*v(271)
v(645)=2d0*v(268)
v(647)=v(2531)*v(572)+v(688)+v(645)*x(13)+v(646)*x(19)
v(656)=-v(647)/3d0
v(641)=v(2524)*x(16)
v(638)=v(2405)*v(2524)
v(642)=v(2525)*v(569)+v(2401)*v(641)+v(704)-v(638)*x(19)
v(653)=-v(642)/3d0
v(639)=v(2525)*v(567)+v(769)+v(638)*x(12)+v(645)*x(18)
v(651)=-v(639)/3d0
v(637)=v(2530)*v(566)-v(2403)*v(641)+v(696)+v(638)*x(13)
v(650)=-v(637)/3d0
v(617)=(-2d0)*v(269)
v(616)=2d0*v(272)
v(623)=v(2526)*v(573)+v(717)-v(617)*x(11)-v(616)*x(17)
v(632)=-v(623)/3d0
v(618)=v(2526)*v(568)+v(691)+v(616)*x(13)+v(617)*x(16)
v(627)=-v(618)/3d0
v(614)=(-2d0)*v(266)
v(621)=v(2527)*v(571)+v(699)-v(614)*x(16)-v(616)*x(19)
v(630)=-v(621)/3d0
v(620)=v(2528)*v(570)+v(739)+v(617)*x(14)-v(614)*x(17)
v(629)=-v(620)/3d0
v(615)=v(2527)*v(567)+v(728)+v(614)*x(11)+v(616)*x(14)
v(626)=-v(615)/3d0
v(612)=v(2528)*v(564)+v(707)+v(614)*x(13)-v(617)*x(19)
v(624)=-v(612)/3d0
v(596)=(-2d0)*v(273)
v(593)=(-2d0)*v(270)
v(597)=v(2529)*v(571)+v(754)-v(593)*x(12)+v(596)*x(18)
v(606)=-v(597)/3d0
v(594)=v(2529)*v(569)+v(720)-v(596)*x(11)+v(593)*x(14)
v(604)=-v(594)/3d0
v(591)=v(2524)*x(15)
v(648)=v(2530)*v(573)-v(2405)*v(591)+v(757)+v(646)*x(18)
v(657)=-v(648)/3d0
v(643)=v(2531)*v(570)+v(2401)*v(591)+v(745)-v(646)*x(12)
v(654)=-v(643)/3d0
v(588)=(-2d0)*v(267)
v(598)=v(2533)*v(572)+v(731)-v(588)*x(14)+v(596)*x(17)
v(607)=-v(598)/3d0
v(592)=v(2532)*v(568)+v(2397)*v(591)+v(778)-v(588)*x(18)
v(603)=-v(592)/3d0
v(589)=v(2532)*v(566)+v(742)+v(588)*x(11)-v(593)*x(17)
v(601)=-v(589)/3d0
v(587)=v(2533)*v(564)-v(2400)*v(591)+v(766)+v(588)*x(12)
v(600)=-v(587)/3d0
v(575)=1d0/v(264)**0.13333333333333333d1
v(2534)=-v(575)/3d0
v(583)=v(2534)*v(573)
v(582)=v(2534)*v(572)
v(581)=v(2534)*v(571)
v(580)=v(2534)*v(570)
v(579)=v(2534)*v(569)
v(578)=v(2534)*v(568)
v(577)=v(2534)*v(567)
v(576)=v(2534)*v(566)
v(574)=v(2534)*v(564)
v(121)=1d0/v(264)**0.3333333333333333d0
v(2535)=props(7)*v(121)
v(116)=v(2407)*v(264)
v(120)=-v(116)/3d0
v(117)=v(2431)*v(264)
v(123)=-v(117)/3d0
v(118)=v(2432)*v(264)
v(658)=(2d0/3d0)*v(118)+v(120)+v(123)
v(667)=props(7)*(v(121)*(v(608)+v(632)+(2d0/3d0)*v(648))+v(583)*v(658))
v(666)=props(7)*(v(121)*(v(607)+v(631)+(2d0/3d0)*v(647))+v(582)*v(658))
v(665)=props(7)*(v(121)*(v(606)+v(630)+(2d0/3d0)*v(644))+v(581)*v(658))
v(664)=props(7)*(v(121)*(v(605)+v(629)+(2d0/3d0)*v(643))+v(580)*v(658))
v(663)=props(7)*(v(121)*(v(604)+v(628)+(2d0/3d0)*v(642))+v(579)*v(658))
v(662)=props(7)*(v(121)*(v(603)+v(627)+(2d0/3d0)*v(640))+v(578)*v(658))
v(661)=props(7)*(v(121)*(v(602)+v(626)+(2d0/3d0)*v(639))+v(577)*v(658))
v(660)=props(7)*(v(121)*(v(601)+v(625)+(2d0/3d0)*v(637))+v(576)*v(658))
v(659)=props(7)*(v(121)*(v(600)+v(624)+(2d0/3d0)*v(636))+v(574)*v(658))
v(124)=-v(118)/3d0
v(678)=(2d0/3d0)*v(116)+v(123)+v(124)
v(687)=props(7)*(v(121)*((2d0/3d0)*v(599)+v(632)+v(657))+v(583)*v(678))
v(686)=props(7)*(v(121)*((2d0/3d0)*v(598)+v(631)+v(656))+v(582)*v(678))
v(685)=props(7)*(v(121)*((2d0/3d0)*v(597)+v(630)+v(655))+v(581)*v(678))
v(684)=props(7)*(v(121)*((2d0/3d0)*v(595)+v(629)+v(654))+v(580)*v(678))
v(683)=props(7)*(v(121)*((2d0/3d0)*v(594)+v(628)+v(653))+v(579)*v(678))
v(682)=props(7)*(v(121)*((2d0/3d0)*v(592)+v(627)+v(652))+v(578)*v(678))
v(681)=props(7)*(v(121)*((2d0/3d0)*v(590)+v(626)+v(651))+v(577)*v(678))
v(680)=props(7)*(v(121)*((2d0/3d0)*v(589)+v(625)+v(650))+v(576)*v(678))
v(679)=props(7)*(v(121)*((2d0/3d0)*v(587)+v(624)+v(649))+v(574)*v(678))
v(668)=(2d0/3d0)*v(117)+v(120)+v(124)
v(677)=props(7)*(v(121)*(v(608)+(2d0/3d0)*v(623)+v(657))+v(583)*v(668))
v(676)=props(7)*(v(121)*(v(607)+(2d0/3d0)*v(622)+v(656))+v(582)*v(668))
v(675)=props(7)*(v(121)*(v(606)+(2d0/3d0)*v(621)+v(655))+v(581)*v(668))
v(674)=props(7)*(v(121)*(v(605)+(2d0/3d0)*v(620)+v(654))+v(580)*v(668))
v(673)=props(7)*(v(121)*(v(604)+(2d0/3d0)*v(619)+v(653))+v(579)*v(668))
v(672)=props(7)*(v(121)*(v(603)+(2d0/3d0)*v(618)+v(652))+v(578)*v(668))
v(671)=props(7)*(v(121)*(v(602)+(2d0/3d0)*v(615)+v(651))+v(577)*v(668))
v(670)=props(7)*(v(121)*(v(601)+(2d0/3d0)*v(613)+v(650))+v(576)*v(668))
v(669)=props(7)*(v(121)*(v(600)+(2d0/3d0)*v(612)+v(649))+v(574)*v(668))
v(119)=v(2535)*v(658)
v(122)=v(2535)*v(668)
v(125)=v(2535)*v(678)
v(132)=(v(2536)+v(2539))*v(264)
v(711)=props(7)*(v(132)*v(583)+v(121)*(v(2539)*v(573)+v(723)+v(724)+v(725)+v(748)+v(749)))
v(709)=props(7)*(v(132)*v(582)+v(121)*(v(2540)*v(572)+v(707)+v(264)*(-(v(2398)*x(13))+v(2404)*x(19))))
v(706)=props(7)*(v(132)*v(581)+v(121)*(v(2541)*v(571)+v(704)+v(264)*(-(v(2401)*x(16))+v(2405)*x(19))))
v(703)=props(7)*(v(132)*v(580)+v(121)*(v(2540)*v(570)+v(712)+v(713)+v(714)+v(772)+v(773)))
v(701)=props(7)*(v(132)*v(579)+v(121)*(v(2541)*v(569)+v(699)+v(264)*(v(2398)*x(16)-v(2402)*x(19))))
v(698)=props(7)*(v(132)*v(578)+v(121)*(v(2539)*v(568)+v(696)+v(264)*(-(v(2405)*x(13))+v(2403)*x(16))))
v(695)=props(7)*(v(132)*v(577)+v(121)*(v(2541)*v(567)+v(734)+v(735)+v(736)+v(760)+v(761)))
v(693)=props(7)*(v(132)*v(576)+v(121)*(v(2539)*v(566)+v(691)+v(264)*(v(2402)*x(13)-v(2404)*x(16))))
v(690)=props(7)*(v(132)*v(574)+v(121)*(v(2540)*v(564)+v(688)+v(264)*(v(2401)*x(13)-v(2403)*x(19))))
v(133)=v(132)*v(2535)
v(2592)=2d0*v(133)
v(137)=(v(2542)+v(2543))*v(264)
v(744)=props(7)*(v(137)*v(583)+v(121)*(v(2542)*v(573)+v(742)+v(264)*(-(v(2399)*x(11))+v(2397)*x(17))))
v(741)=props(7)*(v(137)*v(582)+v(121)*(v(2546)*v(572)+v(739)+v(264)*(-(v(2404)*x(14))+v(2398)*x(17))))
v(738)=props(7)*(v(137)*v(581)+v(121)*(v(2547)*v(571)-v(734)-v(735)+v(736)+v(762)+v(763)))
v(733)=props(7)*(v(137)*v(580)+v(121)*(v(2546)*v(570)+v(731)+v(264)*(v(2399)*x(14)-v(2400)*x(17))))
v(730)=props(7)*(v(137)*v(579)+v(121)*(v(2547)*v(569)+v(728)+v(264)*(-(v(2398)*x(11))+v(2402)*x(14))))
v(727)=props(7)*(v(137)*v(578)+v(121)*(v(2542)*v(568)-v(723)-v(724)+v(725)+v(750)+v(751)))
v(722)=props(7)*(v(137)*v(577)+v(121)*(v(2547)*v(567)+v(720)+v(264)*(v(2400)*x(11)-v(2397)*x(14))))
v(719)=props(7)*(v(137)*v(576)+v(121)*(v(2542)*v(566)+v(717)+v(264)*(v(2404)*x(11)-v(2402)*x(17))))
v(716)=props(7)*(v(137)*v(574)+v(121)*(v(2546)*v(564)-v(712)-v(713)+v(714)+v(774)+v(775)))
v(138)=v(137)*v(2535)
v(2593)=2d0*v(138)
v(139)=(v(2548)+v(2549))*v(264)
v(780)=props(7)*(v(139)*v(583)+v(121)*(v(2548)*v(573)+v(778)+v(264)*(-(v(2397)*x(15))+v(2399)*x(18))))
v(777)=props(7)*(v(139)*v(582)+v(121)*(v(2552)*v(572)+v(714)-v(772)-v(773)-v(774)-v(775)))
v(771)=props(7)*(v(139)*v(581)+v(121)*(v(2553)*v(571)+v(769)+v(264)*(-(v(2405)*x(12))+v(2401)*x(18))))
v(768)=props(7)*(v(139)*v(580)+v(121)*(v(2552)*v(570)+v(766)+v(264)*(-(v(2399)*x(12))+v(2400)*x(15))))
v(765)=props(7)*(v(139)*v(579)+v(121)*(v(2553)*v(569)+v(736)-v(760)-v(761)-v(762)-v(763)))
v(759)=props(7)*(v(139)*v(578)+v(121)*(v(2548)*v(568)+v(757)+v(264)*(v(2405)*x(15)-v(2403)*x(18))))
v(756)=props(7)*(v(139)*v(577)+v(121)*(v(2553)*v(567)+v(754)+v(264)*(v(2397)*x(12)-v(2400)*x(18))))
v(753)=props(7)*(v(139)*v(576)+v(121)*(v(2548)*v(566)+v(725)-v(748)-v(749)-v(750)-v(751)))
v(747)=props(7)*(v(139)*v(574)+v(121)*(v(2552)*v(564)+v(745)+v(264)*(v(2403)*x(12)-v(2401)*x(15))))
v(140)=v(139)*v(2535)
v(2594)=2d0*v(140)
v(992)=v(281)*x(28)
v(991)=-(v(287)*x(22))
v(990)=-(v(285)*x(23))
v(989)=v(282)*x(26)
v(980)=-(v(284)*x(28))
v(979)=v(287)*x(25)
v(978)=v(279)*x(23)
v(977)=-(v(282)*x(20))
v(968)=v(284)*x(22)
v(967)=-(v(281)*x(25))
v(966)=v(285)*x(20)
v(965)=-(v(279)*x(26))
v(952)=-(v(286)*x(21))
v(951)=v(280)*x(27)
v(941)=-(v(283)*x(27))
v(940)=v(286)*x(24)
v(930)=v(283)*x(21)
v(929)=-(v(280)*x(24))
v(863)=(-2d0)*v(285)
v(862)=2d0*v(282)
v(864)=v(2561)*v(789)+v(905)+v(862)*x(22)+v(863)*x(28)
v(873)=-v(864)/3d0
v(858)=v(2554)*x(25)
v(855)=v(2441)*v(2554)
v(859)=v(2555)*v(786)+v(2437)*v(858)+v(921)-v(855)*x(28)
v(870)=-v(859)/3d0
v(856)=v(2555)*v(784)+v(986)+v(855)*x(21)+v(862)*x(27)
v(868)=-v(856)/3d0
v(854)=v(2560)*v(783)-v(2439)*v(858)+v(913)+v(855)*x(22)
v(867)=-v(854)/3d0
v(834)=(-2d0)*v(283)
v(833)=2d0*v(286)
v(840)=v(2556)*v(790)+v(934)-v(834)*x(20)-v(833)*x(26)
v(849)=-v(840)/3d0
v(835)=v(2556)*v(785)+v(908)+v(833)*x(22)+v(834)*x(25)
v(844)=-v(835)/3d0
v(831)=(-2d0)*v(280)
v(838)=v(2557)*v(788)+v(916)-v(831)*x(25)-v(833)*x(28)
v(847)=-v(838)/3d0
v(837)=v(2558)*v(787)+v(956)+v(834)*x(23)-v(831)*x(26)
v(846)=-v(837)/3d0
v(832)=v(2557)*v(784)+v(945)+v(831)*x(20)+v(833)*x(23)
v(843)=-v(832)/3d0
v(829)=v(2558)*v(781)+v(924)+v(831)*x(22)-v(834)*x(28)
v(841)=-v(829)/3d0
v(813)=(-2d0)*v(287)
v(810)=(-2d0)*v(284)
v(814)=v(2559)*v(788)+v(971)-v(810)*x(21)+v(813)*x(27)
v(823)=-v(814)/3d0
v(811)=v(2559)*v(786)+v(937)-v(813)*x(20)+v(810)*x(23)
v(821)=-v(811)/3d0
v(808)=v(2554)*x(24)
v(865)=v(2560)*v(790)-v(2441)*v(808)+v(974)+v(863)*x(27)
v(874)=-v(865)/3d0
v(860)=v(2561)*v(787)+v(2437)*v(808)+v(962)-v(863)*x(21)
v(871)=-v(860)/3d0
v(805)=(-2d0)*v(281)
v(815)=v(2563)*v(789)+v(948)-v(805)*x(23)+v(813)*x(26)
v(824)=-v(815)/3d0
v(809)=v(2562)*v(785)+v(2433)*v(808)+v(995)-v(805)*x(27)
v(820)=-v(809)/3d0
v(806)=v(2562)*v(783)+v(959)+v(805)*x(20)-v(810)*x(26)
v(818)=-v(806)/3d0
v(804)=v(2563)*v(781)-v(2436)*v(808)+v(983)+v(805)*x(21)
v(817)=-v(804)/3d0
v(792)=1d0/v(278)**0.13333333333333333d1
v(2564)=-v(792)/3d0
v(800)=v(2564)*v(790)
v(799)=v(2564)*v(789)
v(798)=v(2564)*v(788)
v(797)=v(2564)*v(787)
v(796)=v(2564)*v(786)
v(795)=v(2564)*v(785)
v(794)=v(2564)*v(784)
v(793)=v(2564)*v(783)
v(791)=v(2564)*v(781)
v(147)=1d0/v(278)**0.3333333333333333d0
v(2565)=props(10)*v(147)
v(142)=v(2443)*v(278)
v(146)=-v(142)/3d0
v(143)=v(2467)*v(278)
v(149)=-v(143)/3d0
v(144)=v(2468)*v(278)
v(875)=(2d0/3d0)*v(144)+v(146)+v(149)
v(884)=props(10)*(v(147)*(v(825)+v(849)+(2d0/3d0)*v(865))+v(800)*v(875))
v(883)=props(10)*(v(147)*(v(824)+v(848)+(2d0/3d0)*v(864))+v(799)*v(875))
v(882)=props(10)*(v(147)*(v(823)+v(847)+(2d0/3d0)*v(861))+v(798)*v(875))
v(881)=props(10)*(v(147)*(v(822)+v(846)+(2d0/3d0)*v(860))+v(797)*v(875))
v(880)=props(10)*(v(147)*(v(821)+v(845)+(2d0/3d0)*v(859))+v(796)*v(875))
v(879)=props(10)*(v(147)*(v(820)+v(844)+(2d0/3d0)*v(857))+v(795)*v(875))
v(878)=props(10)*(v(147)*(v(819)+v(843)+(2d0/3d0)*v(856))+v(794)*v(875))
v(877)=props(10)*(v(147)*(v(818)+v(842)+(2d0/3d0)*v(854))+v(793)*v(875))
v(876)=props(10)*(v(147)*(v(817)+v(841)+(2d0/3d0)*v(853))+v(791)*v(875))
v(150)=-v(144)/3d0
v(895)=(2d0/3d0)*v(142)+v(149)+v(150)
v(904)=props(10)*(v(147)*((2d0/3d0)*v(816)+v(849)+v(874))+v(800)*v(895))
v(903)=props(10)*(v(147)*((2d0/3d0)*v(815)+v(848)+v(873))+v(799)*v(895))
v(902)=props(10)*(v(147)*((2d0/3d0)*v(814)+v(847)+v(872))+v(798)*v(895))
v(901)=props(10)*(v(147)*((2d0/3d0)*v(812)+v(846)+v(871))+v(797)*v(895))
v(900)=props(10)*(v(147)*((2d0/3d0)*v(811)+v(845)+v(870))+v(796)*v(895))
v(899)=props(10)*(v(147)*((2d0/3d0)*v(809)+v(844)+v(869))+v(795)*v(895))
v(898)=props(10)*(v(147)*((2d0/3d0)*v(807)+v(843)+v(868))+v(794)*v(895))
v(897)=props(10)*(v(147)*((2d0/3d0)*v(806)+v(842)+v(867))+v(793)*v(895))
v(896)=props(10)*(v(147)*((2d0/3d0)*v(804)+v(841)+v(866))+v(791)*v(895))
v(885)=(2d0/3d0)*v(143)+v(146)+v(150)
v(894)=props(10)*(v(147)*(v(825)+(2d0/3d0)*v(840)+v(874))+v(800)*v(885))
v(893)=props(10)*(v(147)*(v(824)+(2d0/3d0)*v(839)+v(873))+v(799)*v(885))
v(892)=props(10)*(v(147)*(v(823)+(2d0/3d0)*v(838)+v(872))+v(798)*v(885))
v(891)=props(10)*(v(147)*(v(822)+(2d0/3d0)*v(837)+v(871))+v(797)*v(885))
v(890)=props(10)*(v(147)*(v(821)+(2d0/3d0)*v(836)+v(870))+v(796)*v(885))
v(889)=props(10)*(v(147)*(v(820)+(2d0/3d0)*v(835)+v(869))+v(795)*v(885))
v(888)=props(10)*(v(147)*(v(819)+(2d0/3d0)*v(832)+v(868))+v(794)*v(885))
v(887)=props(10)*(v(147)*(v(818)+(2d0/3d0)*v(830)+v(867))+v(793)*v(885))
v(886)=props(10)*(v(147)*(v(817)+(2d0/3d0)*v(829)+v(866))+v(791)*v(885))
v(145)=v(2565)*v(875)
v(148)=v(2565)*v(885)
v(151)=v(2565)*v(895)
v(158)=(v(2566)+v(2569))*v(278)
v(928)=props(10)*(v(158)*v(800)+v(147)*(v(2569)*v(790)+v(940)+v(941)+v(942)+v(965)+v(966)))
v(926)=props(10)*(v(158)*v(799)+v(147)*(v(2570)*v(789)+v(924)+v(278)*(-(v(2434)*x(22))+v(2440)*x(28))))
v(923)=props(10)*(v(158)*v(798)+v(147)*(v(2571)*v(788)+v(921)+v(278)*(-(v(2437)*x(25))+v(2441)*x(28))))
v(920)=props(10)*(v(158)*v(797)+v(147)*(v(2570)*v(787)+v(929)+v(930)+v(931)+v(989)+v(990)))
v(918)=props(10)*(v(158)*v(796)+v(147)*(v(2571)*v(786)+v(916)+v(278)*(v(2434)*x(25)-v(2438)*x(28))))
v(915)=props(10)*(v(158)*v(795)+v(147)*(v(2569)*v(785)+v(913)+v(278)*(-(v(2441)*x(22))+v(2439)*x(25))))
v(912)=props(10)*(v(158)*v(794)+v(147)*(v(2571)*v(784)+v(951)+v(952)+v(953)+v(977)+v(978)))
v(910)=props(10)*(v(158)*v(793)+v(147)*(v(2569)*v(783)+v(908)+v(278)*(v(2438)*x(22)-v(2440)*x(25))))
v(907)=props(10)*(v(158)*v(791)+v(147)*(v(2570)*v(781)+v(905)+v(278)*(v(2437)*x(22)-v(2439)*x(28))))
v(159)=v(158)*v(2565)
v(2596)=2d0*v(159)
v(163)=(v(2572)+v(2573))*v(278)
v(961)=props(10)*(v(163)*v(800)+v(147)*(v(2572)*v(790)+v(959)+v(278)*(-(v(2435)*x(20))+v(2433)*x(26))))
v(958)=props(10)*(v(163)*v(799)+v(147)*(v(2576)*v(789)+v(956)+v(278)*(-(v(2440)*x(23))+v(2434)*x(26))))
v(955)=props(10)*(v(163)*v(798)+v(147)*(v(2577)*v(788)-v(951)-v(952)+v(953)+v(979)+v(980)))
v(950)=props(10)*(v(163)*v(797)+v(147)*(v(2576)*v(787)+v(948)+v(278)*(v(2435)*x(23)-v(2436)*x(26))))
v(947)=props(10)*(v(163)*v(796)+v(147)*(v(2577)*v(786)+v(945)+v(278)*(-(v(2434)*x(20))+v(2438)*x(23))))
v(944)=props(10)*(v(163)*v(795)+v(147)*(v(2572)*v(785)-v(940)-v(941)+v(942)+v(967)+v(968)))
v(939)=props(10)*(v(163)*v(794)+v(147)*(v(2577)*v(784)+v(937)+v(278)*(v(2436)*x(20)-v(2433)*x(23))))
v(936)=props(10)*(v(163)*v(793)+v(147)*(v(2572)*v(783)+v(934)+v(278)*(v(2440)*x(20)-v(2438)*x(26))))
v(933)=props(10)*(v(163)*v(791)+v(147)*(v(2576)*v(781)-v(929)-v(930)+v(931)+v(991)+v(992)))
v(164)=v(163)*v(2565)
v(2597)=2d0*v(164)
v(165)=(v(2578)+v(2579))*v(278)
v(997)=props(10)*(v(165)*v(800)+v(147)*(v(2578)*v(790)+v(995)+v(278)*(-(v(2433)*x(24))+v(2435)*x(27))))
v(994)=props(10)*(v(165)*v(799)+v(147)*(v(2582)*v(789)+v(931)-v(989)-v(990)-v(991)-v(992)))
v(988)=props(10)*(v(165)*v(798)+v(147)*(v(2583)*v(788)+v(986)+v(278)*(-(v(2441)*x(21))+v(2437)*x(27))))
v(985)=props(10)*(v(165)*v(797)+v(147)*(v(2582)*v(787)+v(983)+v(278)*(-(v(2435)*x(21))+v(2436)*x(24))))
v(982)=props(10)*(v(165)*v(796)+v(147)*(v(2583)*v(786)+v(953)-v(977)-v(978)-v(979)-v(980)))
v(976)=props(10)*(v(165)*v(795)+v(147)*(v(2578)*v(785)+v(974)+v(278)*(v(2441)*x(24)-v(2439)*x(27))))
v(973)=props(10)*(v(165)*v(794)+v(147)*(v(2583)*v(784)+v(971)+v(278)*(v(2433)*x(21)-v(2436)*x(27))))
v(970)=props(10)*(v(165)*v(793)+v(147)*(v(2578)*v(783)+v(942)-v(965)-v(966)-v(967)-v(968)))
v(964)=props(10)*(v(165)*v(791)+v(147)*(v(2582)*v(781)+v(962)+v(278)*(v(2439)*x(21)-v(2437)*x(24))))
v(166)=v(165)*v(2565)
v(2598)=2d0*v(166)
v(167)=v(107)-v(119)-v(145)+v(2584)*v(998)
v(168)=v(107)-v(122)-v(148)+v(1008)*v(2584)
v(169)=v(107)-v(125)-v(151)+v(1018)*v(2584)
v(170)=-v(133)-v(159)+v(100)*v(2584)
v(2610)=4d0*v(170)
v(171)=-v(138)-v(164)+v(101)*v(2584)
v(2611)=4d0*v(171)
v(172)=-v(140)-v(166)+v(102)*v(2584)
v(2612)=4d0*v(172)
IF(dabs(props(5)).lt.0.1d-11) THEN
v(2586)=v(2587)
v(2585)=props(4)
v(1055)=v(2585)
v(174)=v(2586)
ELSE
v(2588)=1d0/props(5)
v(1056)=dexp(-(props(5)*v(2587)))
v(1055)=props(4)*v(1056)
v(174)=(1d0-v(1056))*v(2588)
ENDIF
v(1057)=props(3)+v(174)
v(2590)=(-0.15d1)/v(1057)
v(1058)=-(v(1055)/v(1057)**2)
v(2589)=0.15d1*v(1058)
v(1363)=v(172)*v(2589)
v(2603)=v(1363)*v(2369)
v(1307)=v(171)*v(2589)
v(2606)=v(1307)*v(2369)
v(1251)=v(170)*v(2589)
v(2604)=v(1251)*v(2369)
v(1390)=v(2590)*v(997)
v(1660)=-(v(1390)*v(2369))
v(1389)=v(2590)*v(994)
v(1659)=-(v(1389)*v(2369))
v(1388)=v(2590)*v(988)
v(1658)=-(v(1388)*v(2369))
v(1387)=v(2590)*v(985)
v(1657)=-(v(1387)*v(2369))
v(1386)=v(2590)*v(982)
v(1656)=-(v(1386)*v(2369))
v(1385)=v(2590)*v(976)
v(1655)=-(v(1385)*v(2369))
v(1384)=v(2590)*v(973)
v(1654)=-(v(1384)*v(2369))
v(1383)=v(2590)*v(970)
v(1653)=-(v(1383)*v(2369))
v(1382)=v(2590)*v(964)
v(1652)=-(v(1382)*v(2369))
v(1381)=v(2590)*v(780)
v(1651)=-(v(1381)*v(2369))
v(1380)=v(2590)*v(777)
v(1650)=-(v(1380)*v(2369))
v(1379)=v(2590)*v(771)
v(1649)=-(v(1379)*v(2369))
v(1378)=v(2590)*v(768)
v(1648)=-(v(1378)*v(2369))
v(1377)=v(2590)*v(765)
v(1647)=-(v(1377)*v(2369))
v(1376)=v(2590)*v(759)
v(1646)=-(v(1376)*v(2369))
v(1375)=v(2590)*v(756)
v(1645)=-(v(1375)*v(2369))
v(1374)=v(2590)*v(753)
v(1644)=-(v(1374)*v(2369))
v(1373)=v(2590)*v(747)
v(1643)=-(v(1373)*v(2369))
v(1372)=-(v(1054)*v(2590))
v(1642)=-(v(1372)*v(2369))
v(1371)=-(v(1053)*v(2590))
v(1641)=-(v(1371)*v(2369))
v(1370)=-(v(1052)*v(2590))
v(1640)=-(v(1370)*v(2369))
v(1369)=-(v(1051)*v(2590))
v(1639)=-(v(1369)*v(2369))
v(1368)=-(v(1050)*v(2590))
v(1638)=-(v(1368)*v(2369))
v(1367)=-(v(1049)*v(2590))
v(1637)=-(v(1367)*v(2369))
v(1366)=-(v(1048)*v(2590))
v(1636)=-(v(1366)*v(2369))
v(1365)=-(v(1047)*v(2590))
v(1635)=-(v(1365)*v(2369))
v(1364)=-(v(1046)*v(2590))
v(1634)=-(v(1364)*v(2369))
v(1334)=v(2590)*v(961)
v(1362)=-(v(1334)*v(2369))
v(1333)=v(2590)*v(958)
v(1361)=-(v(1333)*v(2369))
v(1332)=v(2590)*v(955)
v(1360)=-(v(1332)*v(2369))
v(1331)=v(2590)*v(950)
v(1359)=-(v(1331)*v(2369))
v(1330)=v(2590)*v(947)
v(1358)=-(v(1330)*v(2369))
v(1329)=v(2590)*v(944)
v(1357)=-(v(1329)*v(2369))
v(1328)=v(2590)*v(939)
v(1356)=-(v(1328)*v(2369))
v(1327)=v(2590)*v(936)
v(1355)=-(v(1327)*v(2369))
v(1326)=v(2590)*v(933)
v(1354)=-(v(1326)*v(2369))
v(1325)=v(2590)*v(744)
v(1353)=-(v(1325)*v(2369))
v(1324)=v(2590)*v(741)
v(1352)=-(v(1324)*v(2369))
v(1323)=v(2590)*v(738)
v(1351)=-(v(1323)*v(2369))
v(1322)=v(2590)*v(733)
v(1350)=-(v(1322)*v(2369))
v(1321)=v(2590)*v(730)
v(1349)=-(v(1321)*v(2369))
v(1320)=v(2590)*v(727)
v(1348)=-(v(1320)*v(2369))
v(1319)=v(2590)*v(722)
v(1347)=-(v(1319)*v(2369))
v(1318)=v(2590)*v(719)
v(1346)=-(v(1318)*v(2369))
v(1317)=v(2590)*v(716)
v(1345)=-(v(1317)*v(2369))
v(1316)=-(v(1045)*v(2590))
v(1344)=-(v(1316)*v(2369))
v(1315)=-(v(1044)*v(2590))
v(1343)=-(v(1315)*v(2369))
v(1314)=-(v(1043)*v(2590))
v(1342)=-(v(1314)*v(2369))
v(1313)=-(v(1042)*v(2590))
v(1341)=-(v(1313)*v(2369))
v(1312)=-(v(1041)*v(2590))
v(1340)=-(v(1312)*v(2369))
v(1311)=-(v(1040)*v(2590))
v(1339)=-(v(1311)*v(2369))
v(1310)=-(v(1039)*v(2590))
v(1338)=-(v(1310)*v(2369))
v(1309)=-(v(1038)*v(2590))
v(1337)=-(v(1309)*v(2369))
v(1308)=-(v(1037)*v(2590))
v(1336)=-(v(1308)*v(2369))
v(1278)=v(2590)*v(928)
v(1306)=-(v(1278)*v(2369))
v(1277)=v(2590)*v(926)
v(1305)=-(v(1277)*v(2369))
v(1276)=v(2590)*v(923)
v(1304)=-(v(1276)*v(2369))
v(1275)=v(2590)*v(920)
v(1303)=-(v(1275)*v(2369))
v(1274)=v(2590)*v(918)
v(1302)=-(v(1274)*v(2369))
v(1273)=v(2590)*v(915)
v(1301)=-(v(1273)*v(2369))
v(1272)=v(2590)*v(912)
v(1300)=-(v(1272)*v(2369))
v(1271)=v(2590)*v(910)
v(1299)=-(v(1271)*v(2369))
v(1270)=v(2590)*v(907)
v(1298)=-(v(1270)*v(2369))
v(1269)=v(2590)*v(711)
v(1297)=-(v(1269)*v(2369))
v(1268)=v(2590)*v(709)
v(1296)=-(v(1268)*v(2369))
v(1267)=v(2590)*v(706)
v(1295)=-(v(1267)*v(2369))
v(1266)=v(2590)*v(703)
v(1294)=-(v(1266)*v(2369))
v(1265)=v(2590)*v(701)
v(1293)=-(v(1265)*v(2369))
v(1264)=v(2590)*v(698)
v(1292)=-(v(1264)*v(2369))
v(1263)=v(2590)*v(695)
v(1291)=-(v(1263)*v(2369))
v(1262)=v(2590)*v(693)
v(1290)=-(v(1262)*v(2369))
v(1261)=v(2590)*v(690)
v(1289)=-(v(1261)*v(2369))
v(1260)=-(v(1036)*v(2590))
v(1288)=-(v(1260)*v(2369))
v(1259)=-(v(1035)*v(2590))
v(1287)=-(v(1259)*v(2369))
v(1258)=-(v(1034)*v(2590))
v(1286)=-(v(1258)*v(2369))
v(1257)=-(v(1033)*v(2590))
v(1285)=-(v(1257)*v(2369))
v(1256)=-(v(1032)*v(2590))
v(1284)=-(v(1256)*v(2369))
v(1255)=-(v(1031)*v(2590))
v(1283)=-(v(1255)*v(2369))
v(1254)=-(v(1030)*v(2590))
v(1282)=-(v(1254)*v(2369))
v(1253)=-(v(1029)*v(2590))
v(1281)=-(v(1253)*v(2369))
v(1252)=-(v(1028)*v(2590))
v(1280)=-(v(1252)*v(2369))
v(1250)=v(2590)*v(904)
v(1249)=v(2590)*v(903)
v(1248)=v(2590)*v(902)
v(1247)=v(2590)*v(901)
v(1246)=v(2590)*v(900)
v(1245)=v(2590)*v(899)
v(1244)=v(2590)*v(898)
v(1243)=v(2590)*v(897)
v(1242)=v(2590)*v(896)
v(1241)=v(2590)*v(687)
v(1240)=v(2590)*v(686)
v(1239)=v(2590)*v(685)
v(1238)=v(2590)*v(684)
v(1237)=v(2590)*v(683)
v(1236)=v(2590)*v(682)
v(1235)=v(2590)*v(681)
v(1234)=v(2590)*v(680)
v(1233)=v(2590)*v(679)
v(1232)=-(v(2498)*v(2590))
v(1231)=-(v(2501)*v(2590))
v(1230)=-(v(2504)*v(2590))
v(1229)=-(v(2507)*v(2590))
v(1228)=-(v(2510)*v(2590))
v(1227)=-(v(2513)*v(2590))
v(1226)=-(v(2516)*v(2590))
v(1225)=-(v(2519)*v(2590))
v(1224)=-(v(2522)*v(2590))
v(1222)=v(2590)*v(894)
v(1221)=v(2590)*v(893)
v(1220)=v(2590)*v(892)
v(1219)=v(2590)*v(891)
v(1218)=v(2590)*v(890)
v(1217)=v(2590)*v(889)
v(1216)=v(2590)*v(888)
v(1215)=v(2590)*v(887)
v(1214)=v(2590)*v(886)
v(1213)=v(2590)*v(677)
v(1212)=v(2590)*v(676)
v(1211)=v(2590)*v(675)
v(1210)=v(2590)*v(674)
v(1209)=v(2590)*v(673)
v(1208)=v(2590)*v(672)
v(1207)=v(2590)*v(671)
v(1206)=v(2590)*v(670)
v(1205)=v(2590)*v(669)
v(1204)=-(v(2497)*v(2590))
v(1203)=-(v(2500)*v(2590))
v(1202)=-(v(2503)*v(2590))
v(1201)=-(v(2506)*v(2590))
v(1200)=-(v(2509)*v(2590))
v(1199)=-(v(2512)*v(2590))
v(1198)=-(v(2515)*v(2590))
v(1197)=-(v(2518)*v(2590))
v(1196)=-(v(2521)*v(2590))
v(1194)=v(2590)*v(884)
v(1539)=v(2591)*(v(119)*v(1194)+v(122)*v(1222)+v(125)*v(1250)+v(1278)*v(2592)+v(1334)*v(2593)+v(1390)*v(2594))
v(1193)=v(2590)*v(883)
v(1538)=v(2591)*(v(119)*v(1193)+v(122)*v(1221)+v(1249)*v(125)+v(1277)*v(2592)+v(1333)*v(2593)+v(1389)*v(2594))
v(1192)=v(2590)*v(882)
v(1537)=v(2591)*(v(119)*v(1192)+v(122)*v(1220)+v(1248)*v(125)+v(1276)*v(2592)+v(1332)*v(2593)+v(1388)*v(2594))
v(1191)=v(2590)*v(881)
v(1536)=v(2591)*(v(119)*v(1191)+v(1219)*v(122)+v(1247)*v(125)+v(1275)*v(2592)+v(1331)*v(2593)+v(1387)*v(2594))
v(1190)=v(2590)*v(880)
v(1535)=v(2591)*(v(119)*v(1190)+v(1218)*v(122)+v(1246)*v(125)+v(1274)*v(2592)+v(1330)*v(2593)+v(1386)*v(2594))
v(1189)=v(2590)*v(879)
v(1534)=v(2591)*(v(1189)*v(119)+v(1217)*v(122)+v(1245)*v(125)+v(1273)*v(2592)+v(1329)*v(2593)+v(1385)*v(2594))
v(1188)=v(2590)*v(878)
v(1533)=v(2591)*(v(1188)*v(119)+v(1216)*v(122)+v(1244)*v(125)+v(1272)*v(2592)+v(1328)*v(2593)+v(1384)*v(2594))
v(1187)=v(2590)*v(877)
v(1532)=v(2591)*(v(1187)*v(119)+v(1215)*v(122)+v(1243)*v(125)+v(1271)*v(2592)+v(1327)*v(2593)+v(1383)*v(2594))
v(1186)=v(2590)*v(876)
v(1531)=v(2591)*(v(1186)*v(119)+v(1214)*v(122)+v(1242)*v(125)+v(1270)*v(2592)+v(1326)*v(2593)+v(1382)*v(2594))
v(1185)=v(2590)*v(667)
v(1409)=v(2595)*(v(1185)*v(145)+v(1213)*v(148)+v(1241)*v(151)+v(1269)*v(2596)+v(1325)*v(2597)+v(1381)*v(2598))
v(1184)=v(2590)*v(666)
v(1408)=v(2595)*(v(1184)*v(145)+v(1212)*v(148)+v(1240)*v(151)+v(1268)*v(2596)+v(1324)*v(2597)+v(1380)*v(2598))
v(1183)=v(2590)*v(665)
v(1407)=v(2595)*(v(1183)*v(145)+v(1211)*v(148)+v(1239)*v(151)+v(1267)*v(2596)+v(1323)*v(2597)+v(1379)*v(2598))
v(1182)=v(2590)*v(664)
v(1406)=v(2595)*(v(1182)*v(145)+v(1210)*v(148)+v(1238)*v(151)+v(1266)*v(2596)+v(1322)*v(2597)+v(1378)*v(2598))
v(1181)=v(2590)*v(663)
v(1405)=v(2595)*(v(1181)*v(145)+v(1209)*v(148)+v(1237)*v(151)+v(1265)*v(2596)+v(1321)*v(2597)+v(1377)*v(2598))
v(1180)=v(2590)*v(662)
v(1404)=v(2595)*(v(1180)*v(145)+v(1208)*v(148)+v(1236)*v(151)+v(1264)*v(2596)+v(1320)*v(2597)+v(1376)*v(2598))
v(1179)=v(2590)*v(661)
v(1403)=v(2595)*(v(1179)*v(145)+v(1207)*v(148)+v(1235)*v(151)+v(1263)*v(2596)+v(1319)*v(2597)+v(1375)*v(2598))
v(1178)=v(2590)*v(660)
v(1402)=v(2595)*(v(1178)*v(145)+v(1206)*v(148)+v(1234)*v(151)+v(1262)*v(2596)+v(1318)*v(2597)+v(1374)*v(2598))
v(1177)=v(2590)*v(659)
v(1401)=v(2595)*(v(1177)*v(145)+v(1205)*v(148)+v(1233)*v(151)+v(1261)*v(2596)+v(1317)*v(2597)+v(1373)*v(2598))
v(1176)=-(v(2499)*v(2590))
v(1521)=v(2591)*(v(1176)*v(119)+v(1204)*v(122)+v(1232)*v(125)+v(1260)*v(2592)+v(1316)*v(2593)+v(1372)*v(2594))
v(1400)=v(2595)*(v(1176)*v(145)+v(1204)*v(148)+v(1232)*v(151)+v(1260)*v(2596)+v(1316)*v(2597)+v(1372)*v(2598))
v(1175)=-(v(2502)*v(2590))
v(1520)=v(2591)*(v(1175)*v(119)+v(1203)*v(122)+v(1231)*v(125)+v(1259)*v(2592)+v(1315)*v(2593)+v(1371)*v(2594))
v(1399)=v(2595)*(v(1175)*v(145)+v(1203)*v(148)+v(1231)*v(151)+v(1259)*v(2596)+v(1315)*v(2597)+v(1371)*v(2598))
v(1174)=-(v(2505)*v(2590))
v(1519)=v(2591)*(v(1174)*v(119)+v(1202)*v(122)+v(1230)*v(125)+v(1258)*v(2592)+v(1314)*v(2593)+v(1370)*v(2594))
v(1398)=v(2595)*(v(1174)*v(145)+v(1202)*v(148)+v(1230)*v(151)+v(1258)*v(2596)+v(1314)*v(2597)+v(1370)*v(2598))
v(1173)=-(v(2508)*v(2590))
v(1518)=v(2591)*(v(1173)*v(119)+v(1201)*v(122)+v(1229)*v(125)+v(1257)*v(2592)+v(1313)*v(2593)+v(1369)*v(2594))
v(1397)=v(2595)*(v(1173)*v(145)+v(1201)*v(148)+v(1229)*v(151)+v(1257)*v(2596)+v(1313)*v(2597)+v(1369)*v(2598))
v(1172)=-(v(2511)*v(2590))
v(1517)=v(2591)*(v(1172)*v(119)+v(1200)*v(122)+v(1228)*v(125)+v(1256)*v(2592)+v(1312)*v(2593)+v(1368)*v(2594))
v(1396)=v(2595)*(v(1172)*v(145)+v(1200)*v(148)+v(1228)*v(151)+v(1256)*v(2596)+v(1312)*v(2597)+v(1368)*v(2598))
v(1171)=-(v(2514)*v(2590))
v(1516)=v(2591)*(v(1171)*v(119)+v(1199)*v(122)+v(1227)*v(125)+v(1255)*v(2592)+v(1311)*v(2593)+v(1367)*v(2594))
v(1395)=v(2595)*(v(1171)*v(145)+v(1199)*v(148)+v(1227)*v(151)+v(1255)*v(2596)+v(1311)*v(2597)+v(1367)*v(2598))
v(1170)=-(v(2517)*v(2590))
v(1515)=v(2591)*(v(1170)*v(119)+v(1198)*v(122)+v(1226)*v(125)+v(1254)*v(2592)+v(1310)*v(2593)+v(1366)*v(2594))
v(1394)=v(2595)*(v(1170)*v(145)+v(1198)*v(148)+v(1226)*v(151)+v(1254)*v(2596)+v(1310)*v(2597)+v(1366)*v(2598))
v(1169)=-(v(2520)*v(2590))
v(1514)=v(2591)*(v(1169)*v(119)+v(1197)*v(122)+v(1225)*v(125)+v(1253)*v(2592)+v(1309)*v(2593)+v(1365)*v(2594))
v(1393)=v(2595)*(v(1169)*v(145)+v(1197)*v(148)+v(1225)*v(151)+v(1253)*v(2596)+v(1309)*v(2597)+v(1365)*v(2598))
v(1168)=-(v(2523)*v(2590))
v(1513)=v(2591)*(v(1168)*v(119)+v(1196)*v(122)+v(1224)*v(125)+v(1252)*v(2592)+v(1308)*v(2593)+v(1364)*v(2594))
v(1392)=v(2595)*(v(1168)*v(145)+v(1196)*v(148)+v(1224)*v(151)+v(1252)*v(2596)+v(1308)*v(2597)+v(1364)*v(2598))
v(175)=-v(168)/3d0
v(176)=-v(169)/3d0
v(179)=(2d0/3d0)*v(167)+v(175)+v(176)
v(2615)=2d0*v(179)
v(1167)=v(179)*v(2589)
v(2616)=v(1167)*v(2369)
v(177)=-v(167)/3d0
v(184)=(2d0/3d0)*v(169)+v(175)+v(177)
v(2614)=2d0*v(184)
v(1223)=v(184)*v(2589)
v(2632)=v(1223)*v(2369)
v(181)=(2d0/3d0)*v(168)+v(176)+v(177)
v(2613)=2d0*v(181)
v(1663)=1d0/sqrt(0.15d1*(2d0*v(170)**2+2d0*v(171)**2+2d0*v(172)**2+v(179)**2+v(181)**2+v(184)**2))
v(2609)=0.75d0*v(1663)
v(1195)=v(181)*v(2589)
v(2624)=v(1195)*v(2369)
v(180)=-(v(179)*v(2590))
v(183)=-(v(181)*v(2590))
v(185)=-(v(184)*v(2590))
v(186)=-(v(170)*v(2590))
v(2599)=2d0*v(186)
v(1279)=-v(186)-v(2604)
v(187)=-(v(171)*v(2590))
v(2600)=2d0*v(187)
v(1335)=-v(187)-v(2606)
v(188)=-(v(172)*v(2590))
v(2601)=2d0*v(188)
v(1633)=-v(188)-v(2603)
v(1530)=v(2591)*(v(1185)*v(119)+v(1213)*v(122)+v(1241)*v(125)+v(1269)*v(2592)+v(1325)*v(2593)+v(1381)*v(2594)+v(180)*v&
&(667)+v(183)*v(677)+v(185)*v(687)+v(2599)*v(711)+v(2600)*v(744)+v(2601)*v(780))
v(1529)=v(2591)*(v(1184)*v(119)+v(1212)*v(122)+v(1240)*v(125)+v(1268)*v(2592)+v(1324)*v(2593)+v(1380)*v(2594)+v(180)*v&
&(666)+v(183)*v(676)+v(185)*v(686)+v(2599)*v(709)+v(2600)*v(741)+v(2601)*v(777))
v(1528)=v(2591)*(v(1183)*v(119)+v(1211)*v(122)+v(1239)*v(125)+v(1267)*v(2592)+v(1323)*v(2593)+v(1379)*v(2594)+v(180)*v&
&(665)+v(183)*v(675)+v(185)*v(685)+v(2599)*v(706)+v(2600)*v(738)+v(2601)*v(771))
v(1527)=v(2591)*(v(1182)*v(119)+v(1210)*v(122)+v(1238)*v(125)+v(1266)*v(2592)+v(1322)*v(2593)+v(1378)*v(2594)+v(180)*v&
&(664)+v(183)*v(674)+v(185)*v(684)+v(2599)*v(703)+v(2600)*v(733)+v(2601)*v(768))
v(1526)=v(2591)*(v(1181)*v(119)+v(1209)*v(122)+v(1237)*v(125)+v(1265)*v(2592)+v(1321)*v(2593)+v(1377)*v(2594)+v(180)*v&
&(663)+v(183)*v(673)+v(185)*v(683)+v(2599)*v(701)+v(2600)*v(730)+v(2601)*v(765))
v(1525)=v(2591)*(v(1180)*v(119)+v(1208)*v(122)+v(1236)*v(125)+v(1264)*v(2592)+v(1320)*v(2593)+v(1376)*v(2594)+v(180)*v&
&(662)+v(183)*v(672)+v(185)*v(682)+v(2599)*v(698)+v(2600)*v(727)+v(2601)*v(759))
v(1524)=v(2591)*(v(1179)*v(119)+v(1207)*v(122)+v(1235)*v(125)+v(1263)*v(2592)+v(1319)*v(2593)+v(1375)*v(2594)+v(180)*v&
&(661)+v(183)*v(671)+v(185)*v(681)+v(2599)*v(695)+v(2600)*v(722)+v(2601)*v(756))
v(1523)=v(2591)*(v(1178)*v(119)+v(1206)*v(122)+v(1234)*v(125)+v(1262)*v(2592)+v(1318)*v(2593)+v(1374)*v(2594)+v(180)*v&
&(660)+v(183)*v(670)+v(185)*v(680)+v(2599)*v(693)+v(2600)*v(719)+v(2601)*v(753))
v(1522)=v(2591)*(v(1177)*v(119)+v(1205)*v(122)+v(1233)*v(125)+v(1261)*v(2592)+v(1317)*v(2593)+v(1373)*v(2594)+v(180)*v&
&(659)+v(183)*v(669)+v(185)*v(679)+v(2599)*v(690)+v(2600)*v(716)+v(2601)*v(747))
v(1418)=v(2595)*(v(1194)*v(145)+v(1222)*v(148)+v(1250)*v(151)+v(1278)*v(2596)+v(1334)*v(2597)+v(1390)*v(2598)+v(180)*v&
&(884)+v(183)*v(894)+v(185)*v(904)+v(2599)*v(928)+v(2600)*v(961)+v(2601)*v(997))
v(1417)=v(2595)*(v(1193)*v(145)+v(1221)*v(148)+v(1249)*v(151)+v(1277)*v(2596)+v(1333)*v(2597)+v(1389)*v(2598)+v(180)*v&
&(883)+v(183)*v(893)+v(185)*v(903)+v(2599)*v(926)+v(2600)*v(958)+v(2601)*v(994))
v(1416)=v(2595)*(v(1192)*v(145)+v(1220)*v(148)+v(1248)*v(151)+v(1276)*v(2596)+v(1332)*v(2597)+v(1388)*v(2598)+v(180)*v&
&(882)+v(183)*v(892)+v(185)*v(902)+v(2599)*v(923)+v(2600)*v(955)+v(2601)*v(988))
v(1415)=v(2595)*(v(1191)*v(145)+v(1219)*v(148)+v(1247)*v(151)+v(1275)*v(2596)+v(1331)*v(2597)+v(1387)*v(2598)+v(180)*v&
&(881)+v(183)*v(891)+v(185)*v(901)+v(2599)*v(920)+v(2600)*v(950)+v(2601)*v(985))
v(1414)=v(2595)*(v(1190)*v(145)+v(1218)*v(148)+v(1246)*v(151)+v(1274)*v(2596)+v(1330)*v(2597)+v(1386)*v(2598)+v(180)*v&
&(880)+v(183)*v(890)+v(185)*v(900)+v(2599)*v(918)+v(2600)*v(947)+v(2601)*v(982))
v(1413)=v(2595)*(v(1189)*v(145)+v(1217)*v(148)+v(1245)*v(151)+v(1273)*v(2596)+v(1329)*v(2597)+v(1385)*v(2598)+v(180)*v&
&(879)+v(183)*v(889)+v(185)*v(899)+v(2599)*v(915)+v(2600)*v(944)+v(2601)*v(976))
v(1412)=v(2595)*(v(1188)*v(145)+v(1216)*v(148)+v(1244)*v(151)+v(1272)*v(2596)+v(1328)*v(2597)+v(1384)*v(2598)+v(180)*v&
&(878)+v(183)*v(888)+v(185)*v(898)+v(2599)*v(912)+v(2600)*v(939)+v(2601)*v(973))
v(1411)=v(2595)*(v(1187)*v(145)+v(1215)*v(148)+v(1243)*v(151)+v(1271)*v(2596)+v(1327)*v(2597)+v(1383)*v(2598)+v(180)*v&
&(877)+v(183)*v(887)+v(185)*v(897)+v(2599)*v(910)+v(2600)*v(936)+v(2601)*v(970))
v(1410)=v(2595)*(v(1186)*v(145)+v(1214)*v(148)+v(1242)*v(151)+v(1270)*v(2596)+v(1326)*v(2597)+v(1382)*v(2598)+v(180)*v&
&(876)+v(183)*v(886)+v(185)*v(896)+v(2599)*v(907)+v(2600)*v(933)+v(2601)*v(964))
v(236)=v(2595)*(v(145)*v(180)+v(148)*v(183)+v(151)*v(185)+v(159)*v(2599)+v(164)*v(2600)+v(166)*v(2601))
v(2605)=1d0-2d0*v(236)
v(2602)=(-1d0)+v(236)
v(1511)=-(v(2369)*(v(1418)*v(188)+v(1390)*v(2602)+v(235)*v(997)))
v(1510)=-(v(2369)*(v(1417)*v(188)+v(1389)*v(2602)+v(235)*v(994)))
v(1509)=-(v(2369)*(v(1416)*v(188)+v(1388)*v(2602)+v(235)*v(988)))
v(1508)=-(v(2369)*(v(1415)*v(188)+v(1387)*v(2602)+v(235)*v(985)))
v(1507)=-(v(2369)*(v(1414)*v(188)+v(1386)*v(2602)+v(235)*v(982)))
v(1506)=-(v(2369)*(v(1413)*v(188)+v(1385)*v(2602)+v(235)*v(976)))
v(1505)=-(v(2369)*(v(1412)*v(188)+v(1384)*v(2602)+v(235)*v(973)))
v(1504)=-(v(2369)*(v(1411)*v(188)+v(1383)*v(2602)+v(235)*v(970)))
v(1503)=-(v(2369)*(v(1410)*v(188)+v(1382)*v(2602)+v(235)*v(964)))
v(1502)=-(v(2369)*(v(1409)*v(188)+v(1381)*v(2602)))
v(1501)=-(v(2369)*(v(1408)*v(188)+v(1380)*v(2602)))
v(1500)=-(v(2369)*(v(1407)*v(188)+v(1379)*v(2602)))
v(1499)=-(v(2369)*(v(1406)*v(188)+v(1378)*v(2602)))
v(1498)=-(v(2369)*(v(1405)*v(188)+v(1377)*v(2602)))
v(1497)=-(v(2369)*(v(1404)*v(188)+v(1376)*v(2602)))
v(1496)=-(v(2369)*(v(1403)*v(188)+v(1375)*v(2602)))
v(1495)=-(v(2369)*(v(1402)*v(188)+v(1374)*v(2602)))
v(1494)=-(v(2369)*(v(1401)*v(188)+v(1373)*v(2602)))
v(1493)=-(v(2369)*(v(1400)*v(188)+v(1372)*v(2602)))
v(1492)=-(v(2369)*(v(1399)*v(188)+v(1371)*v(2602)))
v(1491)=-(v(2369)*(v(1398)*v(188)+v(1370)*v(2602)))
v(1490)=-(v(2369)*(v(1397)*v(188)+v(1369)*v(2602)))
v(1489)=-(v(2369)*(v(1396)*v(188)+v(1368)*v(2602)))
v(1488)=-(v(2369)*(v(1395)*v(188)+v(1367)*v(2602)))
v(1487)=-(v(2369)*(v(1394)*v(188)+v(1366)*v(2602)))
v(1486)=-(v(2369)*(v(1393)*v(188)+v(1365)*v(2602)))
v(1485)=-(v(2369)*(v(1392)*v(188)+v(1364)*v(2602)))
v(1484)=-(v(166)*v(235))-v(188)*v(2602)+v(2603)*v(2605)
v(1480)=-(v(2369)*(v(1418)*v(186)+v(1278)*v(2602)+v(235)*v(928)))
v(1479)=-(v(2369)*(v(1417)*v(186)+v(1277)*v(2602)+v(235)*v(926)))
v(1478)=-(v(2369)*(v(1416)*v(186)+v(1276)*v(2602)+v(235)*v(923)))
v(1477)=-(v(2369)*(v(1415)*v(186)+v(1275)*v(2602)+v(235)*v(920)))
v(1476)=-(v(2369)*(v(1414)*v(186)+v(1274)*v(2602)+v(235)*v(918)))
v(1475)=-(v(2369)*(v(1413)*v(186)+v(1273)*v(2602)+v(235)*v(915)))
v(1474)=-(v(2369)*(v(1412)*v(186)+v(1272)*v(2602)+v(235)*v(912)))
v(1473)=-(v(2369)*(v(1411)*v(186)+v(1271)*v(2602)+v(235)*v(910)))
v(1472)=-(v(2369)*(v(1410)*v(186)+v(1270)*v(2602)+v(235)*v(907)))
v(1471)=-(v(2369)*(v(1409)*v(186)+v(1269)*v(2602)))
v(1470)=-(v(2369)*(v(1408)*v(186)+v(1268)*v(2602)))
v(1469)=-(v(2369)*(v(1407)*v(186)+v(1267)*v(2602)))
v(1468)=-(v(2369)*(v(1406)*v(186)+v(1266)*v(2602)))
v(1467)=-(v(2369)*(v(1405)*v(186)+v(1265)*v(2602)))
v(1466)=-(v(2369)*(v(1404)*v(186)+v(1264)*v(2602)))
v(1465)=-(v(2369)*(v(1403)*v(186)+v(1263)*v(2602)))
v(1464)=-(v(2369)*(v(1402)*v(186)+v(1262)*v(2602)))
v(1463)=-(v(2369)*(v(1401)*v(186)+v(1261)*v(2602)))
v(1462)=-(v(2369)*(v(1400)*v(186)+v(1260)*v(2602)))
v(1461)=-(v(2369)*(v(1399)*v(186)+v(1259)*v(2602)))
v(1460)=-(v(2369)*(v(1398)*v(186)+v(1258)*v(2602)))
v(1459)=-(v(2369)*(v(1397)*v(186)+v(1257)*v(2602)))
v(1458)=-(v(2369)*(v(1396)*v(186)+v(1256)*v(2602)))
v(1457)=-(v(2369)*(v(1395)*v(186)+v(1255)*v(2602)))
v(1456)=-(v(2369)*(v(1394)*v(186)+v(1254)*v(2602)))
v(1455)=-(v(2369)*(v(1393)*v(186)+v(1253)*v(2602)))
v(1454)=-(v(2369)*(v(1392)*v(186)+v(1252)*v(2602)))
v(1453)=-(v(159)*v(235))-v(186)*v(2602)+v(2604)*v(2605)
v(1449)=-(v(2369)*(v(1418)*v(187)+v(1334)*v(2602)+v(235)*v(961)))
v(1448)=-(v(2369)*(v(1417)*v(187)+v(1333)*v(2602)+v(235)*v(958)))
v(1447)=-(v(2369)*(v(1416)*v(187)+v(1332)*v(2602)+v(235)*v(955)))
v(1446)=-(v(2369)*(v(1415)*v(187)+v(1331)*v(2602)+v(235)*v(950)))
v(1445)=-(v(2369)*(v(1414)*v(187)+v(1330)*v(2602)+v(235)*v(947)))
v(1444)=-(v(2369)*(v(1413)*v(187)+v(1329)*v(2602)+v(235)*v(944)))
v(1443)=-(v(2369)*(v(1412)*v(187)+v(1328)*v(2602)+v(235)*v(939)))
v(1442)=-(v(2369)*(v(1411)*v(187)+v(1327)*v(2602)+v(235)*v(936)))
v(1441)=-(v(2369)*(v(1410)*v(187)+v(1326)*v(2602)+v(235)*v(933)))
v(1440)=-(v(2369)*(v(1409)*v(187)+v(1325)*v(2602)))
v(1439)=-(v(2369)*(v(1408)*v(187)+v(1324)*v(2602)))
v(1438)=-(v(2369)*(v(1407)*v(187)+v(1323)*v(2602)))
v(1437)=-(v(2369)*(v(1406)*v(187)+v(1322)*v(2602)))
v(1436)=-(v(2369)*(v(1405)*v(187)+v(1321)*v(2602)))
v(1435)=-(v(2369)*(v(1404)*v(187)+v(1320)*v(2602)))
v(1434)=-(v(2369)*(v(1403)*v(187)+v(1319)*v(2602)))
v(1433)=-(v(2369)*(v(1402)*v(187)+v(1318)*v(2602)))
v(1432)=-(v(2369)*(v(1401)*v(187)+v(1317)*v(2602)))
v(1431)=-(v(2369)*(v(1400)*v(187)+v(1316)*v(2602)))
v(1430)=-(v(2369)*(v(1399)*v(187)+v(1315)*v(2602)))
v(1429)=-(v(2369)*(v(1398)*v(187)+v(1314)*v(2602)))
v(1428)=-(v(2369)*(v(1397)*v(187)+v(1313)*v(2602)))
v(1427)=-(v(2369)*(v(1396)*v(187)+v(1312)*v(2602)))
v(1426)=-(v(2369)*(v(1395)*v(187)+v(1311)*v(2602)))
v(1425)=-(v(2369)*(v(1394)*v(187)+v(1310)*v(2602)))
v(1424)=-(v(2369)*(v(1393)*v(187)+v(1309)*v(2602)))
v(1423)=-(v(2369)*(v(1392)*v(187)+v(1308)*v(2602)))
v(1422)=-(v(164)*v(235))-v(187)*v(2602)+v(2605)*v(2606)
v(217)=v(2591)*(v(119)*v(180)+v(122)*v(183)+v(125)*v(185)+v(133)*v(2599)+v(138)*v(2600)+v(140)*v(2601))
v(2608)=1d0-2d0*v(217)
v(2607)=(-1d0)+v(217)
v(1632)=-(v(2369)*(v(1539)*v(188)+v(1390)*v(2607)))
v(1631)=-(v(2369)*(v(1538)*v(188)+v(1389)*v(2607)))
v(1630)=-(v(2369)*(v(1537)*v(188)+v(1388)*v(2607)))
v(1629)=-(v(2369)*(v(1536)*v(188)+v(1387)*v(2607)))
v(1628)=-(v(2369)*(v(1535)*v(188)+v(1386)*v(2607)))
v(1627)=-(v(2369)*(v(1534)*v(188)+v(1385)*v(2607)))
v(1626)=-(v(2369)*(v(1533)*v(188)+v(1384)*v(2607)))
v(1625)=-(v(2369)*(v(1532)*v(188)+v(1383)*v(2607)))
v(1624)=-(v(2369)*(v(1531)*v(188)+v(1382)*v(2607)))
v(1623)=-(v(2369)*(v(1530)*v(188)+v(1381)*v(2607)+v(2367)*v(780)))
v(1622)=-(v(2369)*(v(1529)*v(188)+v(1380)*v(2607)+v(2367)*v(777)))
v(1621)=-(v(2369)*(v(1528)*v(188)+v(1379)*v(2607)+v(2367)*v(771)))
v(1620)=-(v(2369)*(v(1527)*v(188)+v(1378)*v(2607)+v(2367)*v(768)))
v(1619)=-(v(2369)*(v(1526)*v(188)+v(1377)*v(2607)+v(2367)*v(765)))
v(1618)=-(v(2369)*(v(1525)*v(188)+v(1376)*v(2607)+v(2367)*v(759)))
v(1617)=-(v(2369)*(v(1524)*v(188)+v(1375)*v(2607)+v(2367)*v(756)))
v(1616)=-(v(2369)*(v(1523)*v(188)+v(1374)*v(2607)+v(2367)*v(753)))
v(1615)=-(v(2369)*(v(1522)*v(188)+v(1373)*v(2607)+v(2367)*v(747)))
v(1614)=-(v(2369)*(v(1521)*v(188)+v(1372)*v(2607)))
v(1613)=-(v(2369)*(v(1520)*v(188)+v(1371)*v(2607)))
v(1612)=-(v(2369)*(v(1519)*v(188)+v(1370)*v(2607)))
v(1611)=-(v(2369)*(v(1518)*v(188)+v(1369)*v(2607)))
v(1610)=-(v(2369)*(v(1517)*v(188)+v(1368)*v(2607)))
v(1609)=-(v(2369)*(v(1516)*v(188)+v(1367)*v(2607)))
v(1608)=-(v(2369)*(v(1515)*v(188)+v(1366)*v(2607)))
v(1607)=-(v(2369)*(v(1514)*v(188)+v(1365)*v(2607)))
v(1606)=-(v(2369)*(v(1513)*v(188)+v(1364)*v(2607)))
v(1605)=-(v(140)*v(2367))-v(188)*v(2607)+v(2603)*v(2608)
v(1601)=-(v(2369)*(v(1539)*v(186)+v(1278)*v(2607)))
v(1600)=-(v(2369)*(v(1538)*v(186)+v(1277)*v(2607)))
v(1599)=-(v(2369)*(v(1537)*v(186)+v(1276)*v(2607)))
v(1598)=-(v(2369)*(v(1536)*v(186)+v(1275)*v(2607)))
v(1597)=-(v(2369)*(v(1535)*v(186)+v(1274)*v(2607)))
v(1596)=-(v(2369)*(v(1534)*v(186)+v(1273)*v(2607)))
v(1595)=-(v(2369)*(v(1533)*v(186)+v(1272)*v(2607)))
v(1594)=-(v(2369)*(v(1532)*v(186)+v(1271)*v(2607)))
v(1593)=-(v(2369)*(v(1531)*v(186)+v(1270)*v(2607)))
v(1592)=-(v(2369)*(v(1530)*v(186)+v(1269)*v(2607)+v(2367)*v(711)))
v(1591)=-(v(2369)*(v(1529)*v(186)+v(1268)*v(2607)+v(2367)*v(709)))
v(1590)=-(v(2369)*(v(1528)*v(186)+v(1267)*v(2607)+v(2367)*v(706)))
v(1589)=-(v(2369)*(v(1527)*v(186)+v(1266)*v(2607)+v(2367)*v(703)))
v(1588)=-(v(2369)*(v(1526)*v(186)+v(1265)*v(2607)+v(2367)*v(701)))
v(1587)=-(v(2369)*(v(1525)*v(186)+v(1264)*v(2607)+v(2367)*v(698)))
v(1586)=-(v(2369)*(v(1524)*v(186)+v(1263)*v(2607)+v(2367)*v(695)))
v(1585)=-(v(2369)*(v(1523)*v(186)+v(1262)*v(2607)+v(2367)*v(693)))
v(1584)=-(v(2369)*(v(1522)*v(186)+v(1261)*v(2607)+v(2367)*v(690)))
v(1583)=-(v(2369)*(v(1521)*v(186)+v(1260)*v(2607)))
v(1582)=-(v(2369)*(v(1520)*v(186)+v(1259)*v(2607)))
v(1581)=-(v(2369)*(v(1519)*v(186)+v(1258)*v(2607)))
v(1580)=-(v(2369)*(v(1518)*v(186)+v(1257)*v(2607)))
v(1579)=-(v(2369)*(v(1517)*v(186)+v(1256)*v(2607)))
v(1578)=-(v(2369)*(v(1516)*v(186)+v(1255)*v(2607)))
v(1577)=-(v(2369)*(v(1515)*v(186)+v(1254)*v(2607)))
v(1576)=-(v(2369)*(v(1514)*v(186)+v(1253)*v(2607)))
v(1575)=-(v(2369)*(v(1513)*v(186)+v(1252)*v(2607)))
v(1574)=-(v(133)*v(2367))-v(186)*v(2607)+v(2604)*v(2608)
v(1570)=-(v(2369)*(v(1539)*v(187)+v(1334)*v(2607)))
v(1569)=-(v(2369)*(v(1538)*v(187)+v(1333)*v(2607)))
v(1568)=-(v(2369)*(v(1537)*v(187)+v(1332)*v(2607)))
v(1567)=-(v(2369)*(v(1536)*v(187)+v(1331)*v(2607)))
v(1566)=-(v(2369)*(v(1535)*v(187)+v(1330)*v(2607)))
v(1565)=-(v(2369)*(v(1534)*v(187)+v(1329)*v(2607)))
v(1564)=-(v(2369)*(v(1533)*v(187)+v(1328)*v(2607)))
v(1563)=-(v(2369)*(v(1532)*v(187)+v(1327)*v(2607)))
v(1562)=-(v(2369)*(v(1531)*v(187)+v(1326)*v(2607)))
v(1561)=-(v(2369)*(v(1530)*v(187)+v(1325)*v(2607)+v(2367)*v(744)))
v(1560)=-(v(2369)*(v(1529)*v(187)+v(1324)*v(2607)+v(2367)*v(741)))
v(1559)=-(v(2369)*(v(1528)*v(187)+v(1323)*v(2607)+v(2367)*v(738)))
v(1558)=-(v(2369)*(v(1527)*v(187)+v(1322)*v(2607)+v(2367)*v(733)))
v(1557)=-(v(2369)*(v(1526)*v(187)+v(1321)*v(2607)+v(2367)*v(730)))
v(1556)=-(v(2369)*(v(1525)*v(187)+v(1320)*v(2607)+v(2367)*v(727)))
v(1555)=-(v(2369)*(v(1524)*v(187)+v(1319)*v(2607)+v(2367)*v(722)))
v(1554)=-(v(2369)*(v(1523)*v(187)+v(1318)*v(2607)+v(2367)*v(719)))
v(1553)=-(v(2369)*(v(1522)*v(187)+v(1317)*v(2607)+v(2367)*v(716)))
v(1552)=-(v(2369)*(v(1521)*v(187)+v(1316)*v(2607)))
v(1551)=-(v(2369)*(v(1520)*v(187)+v(1315)*v(2607)))
v(1550)=-(v(2369)*(v(1519)*v(187)+v(1314)*v(2607)))
v(1549)=-(v(2369)*(v(1518)*v(187)+v(1313)*v(2607)))
v(1548)=-(v(2369)*(v(1517)*v(187)+v(1312)*v(2607)))
v(1547)=-(v(2369)*(v(1516)*v(187)+v(1311)*v(2607)))
v(1546)=-(v(2369)*(v(1515)*v(187)+v(1310)*v(2607)))
v(1545)=-(v(2369)*(v(1514)*v(187)+v(1309)*v(2607)))
v(1544)=-(v(2369)*(v(1513)*v(187)+v(1308)*v(2607)))
v(1543)=-(v(138)*v(2367))-v(187)*v(2607)+v(2606)*v(2608)
dRdX(1,1)=-v(1055)
dRdX(1,2)=v(2609)*(v(1028)*v(2610)+v(1037)*v(2611)+v(1046)*v(2612)+v(2521)*v(2613)+v(2522)*v(2614)+v(2523)*v(2615))
dRdX(1,3)=v(2609)*(v(1029)*v(2610)+v(1038)*v(2611)+v(1047)*v(2612)+v(2518)*v(2613)+v(2519)*v(2614)+v(2520)*v(2615))
dRdX(1,4)=v(2609)*(v(1030)*v(2610)+v(1039)*v(2611)+v(1048)*v(2612)+v(2515)*v(2613)+v(2516)*v(2614)+v(2517)*v(2615))
dRdX(1,5)=v(2609)*(v(1031)*v(2610)+v(1040)*v(2611)+v(1049)*v(2612)+v(2512)*v(2613)+v(2513)*v(2614)+v(2514)*v(2615))
dRdX(1,6)=v(2609)*(v(1032)*v(2610)+v(1041)*v(2611)+v(1050)*v(2612)+v(2509)*v(2613)+v(2510)*v(2614)+v(2511)*v(2615))
dRdX(1,7)=v(2609)*(v(1033)*v(2610)+v(1042)*v(2611)+v(1051)*v(2612)+v(2506)*v(2613)+v(2507)*v(2614)+v(2508)*v(2615))
dRdX(1,8)=v(2609)*(v(1034)*v(2610)+v(1043)*v(2611)+v(1052)*v(2612)+v(2503)*v(2613)+v(2504)*v(2614)+v(2505)*v(2615))
dRdX(1,9)=v(2609)*(v(1035)*v(2610)+v(1044)*v(2611)+v(1053)*v(2612)+v(2500)*v(2613)+v(2501)*v(2614)+v(2502)*v(2615))
dRdX(1,10)=v(2609)*(v(1036)*v(2610)+v(1045)*v(2611)+v(1054)*v(2612)+v(2497)*v(2613)+v(2498)*v(2614)+v(2499)*v(2615))
dRdX(1,11)=v(2609)*(-(v(2615)*v(659))-v(2613)*v(669)-v(2614)*v(679)-v(2610)*v(690)-v(2611)*v(716)-v(2612)*v(747))
dRdX(1,12)=v(2609)*(-(v(2615)*v(660))-v(2613)*v(670)-v(2614)*v(680)-v(2610)*v(693)-v(2611)*v(719)-v(2612)*v(753))
dRdX(1,13)=v(2609)*(-(v(2615)*v(661))-v(2613)*v(671)-v(2614)*v(681)-v(2610)*v(695)-v(2611)*v(722)-v(2612)*v(756))
dRdX(1,14)=v(2609)*(-(v(2615)*v(662))-v(2613)*v(672)-v(2614)*v(682)-v(2610)*v(698)-v(2611)*v(727)-v(2612)*v(759))
dRdX(1,15)=v(2609)*(-(v(2615)*v(663))-v(2613)*v(673)-v(2614)*v(683)-v(2610)*v(701)-v(2611)*v(730)-v(2612)*v(765))
dRdX(1,16)=v(2609)*(-(v(2615)*v(664))-v(2613)*v(674)-v(2614)*v(684)-v(2610)*v(703)-v(2611)*v(733)-v(2612)*v(768))
dRdX(1,17)=v(2609)*(-(v(2615)*v(665))-v(2613)*v(675)-v(2614)*v(685)-v(2610)*v(706)-v(2611)*v(738)-v(2612)*v(771))
dRdX(1,18)=v(2609)*(-(v(2615)*v(666))-v(2613)*v(676)-v(2614)*v(686)-v(2610)*v(709)-v(2611)*v(741)-v(2612)*v(777))
dRdX(1,19)=v(2609)*(-(v(2615)*v(667))-v(2613)*v(677)-v(2614)*v(687)-v(2610)*v(711)-v(2611)*v(744)-v(2612)*v(780))
dRdX(1,20)=v(2609)*(-(v(2615)*v(876))-v(2613)*v(886)-v(2614)*v(896)-v(2610)*v(907)-v(2611)*v(933)-v(2612)*v(964))
dRdX(1,21)=v(2609)*(-(v(2615)*v(877))-v(2613)*v(887)-v(2614)*v(897)-v(2610)*v(910)-v(2611)*v(936)-v(2612)*v(970))
dRdX(1,22)=v(2609)*(-(v(2615)*v(878))-v(2613)*v(888)-v(2614)*v(898)-v(2610)*v(912)-v(2611)*v(939)-v(2612)*v(973))
dRdX(1,23)=v(2609)*(-(v(2615)*v(879))-v(2613)*v(889)-v(2614)*v(899)-v(2610)*v(915)-v(2611)*v(944)-v(2612)*v(976))
dRdX(1,24)=v(2609)*(-(v(2615)*v(880))-v(2613)*v(890)-v(2614)*v(900)-v(2610)*v(918)-v(2611)*v(947)-v(2612)*v(982))
dRdX(1,25)=v(2609)*(-(v(2615)*v(881))-v(2613)*v(891)-v(2614)*v(901)-v(2610)*v(920)-v(2611)*v(950)-v(2612)*v(985))
dRdX(1,26)=v(2609)*(-(v(2615)*v(882))-v(2613)*v(892)-v(2614)*v(902)-v(2610)*v(923)-v(2611)*v(955)-v(2612)*v(988))
dRdX(1,27)=v(2609)*(-(v(2615)*v(883))-v(2613)*v(893)-v(2614)*v(903)-v(2610)*v(926)-v(2611)*v(958)-v(2612)*v(994))
dRdX(1,28)=v(2609)*(-(v(2615)*v(884))-v(2613)*v(894)-v(2614)*v(904)-v(2610)*v(928)-v(2611)*v(961)-v(2612)*v(997))
dRdX(2,1)=-v(180)-v(2616)
dRdX(2,2)=-(v(1168)*v(2369))+v(250)*v(2617)
dRdX(2,3)=v(1768)+v(1769)+v(1770)-v(1169)*v(2369)+v(252)*v(2618)
dRdX(2,4)=v(1852)+v(1853)+v(1854)-v(1170)*v(2369)+v(253)*v(2621)
dRdX(2,5)=-(v(1171)*v(2369))+v(254)*v(2617)
dRdX(2,6)=v(1843)+v(1844)+v(1845)-v(1172)*v(2369)+v(255)*v(2621)
dRdX(2,7)=-v(1810)-v(1811)+v(1812)-v(1173)*v(2369)+v(256)*v(2623)
dRdX(2,8)=-(v(1174)*v(2369))+v(257)*v(2617)
dRdX(2,9)=-v(1867)-v(1868)+v(1869)-v(1175)*v(2369)+v(258)*v(2623)
dRdX(2,10)=-v(1900)-v(1901)+v(1902)-v(1176)*v(2369)+v(259)*v(2618)
dRdX(2,11)=-(v(1177)*v(2369))
dRdX(2,12)=-(v(1178)*v(2369))
dRdX(2,13)=-(v(1179)*v(2369))
dRdX(2,14)=-(v(1180)*v(2369))
dRdX(2,15)=-(v(1181)*v(2369))
dRdX(2,16)=-(v(1182)*v(2369))
dRdX(2,17)=-(v(1183)*v(2369))
dRdX(2,18)=-(v(1184)*v(2369))
dRdX(2,19)=-(v(1185)*v(2369))
dRdX(2,20)=-(v(1186)*v(2369))
dRdX(2,21)=-(v(1187)*v(2369))
dRdX(2,22)=-(v(1188)*v(2369))
dRdX(2,23)=-(v(1189)*v(2369))
dRdX(2,24)=-(v(1190)*v(2369))
dRdX(2,25)=-(v(1191)*v(2369))
dRdX(2,26)=-(v(1192)*v(2369))
dRdX(2,27)=-(v(1193)*v(2369))
dRdX(2,28)=-(v(1194)*v(2369))
dRdX(3,1)=-v(183)-v(2624)
dRdX(3,2)=v(1889)+v(1890)+v(1891)-v(1196)*v(2369)+v(250)*v(2625)
dRdX(3,3)=-(v(1197)*v(2369))+v(252)*v(2626)
dRdX(3,4)=v(1793)+v(1794)+v(1795)-v(1198)*v(2369)+v(253)*v(2629)
dRdX(3,5)=-v(1763)-v(1764)+v(1765)-v(1199)*v(2369)+v(254)*v(2631)
dRdX(3,6)=-(v(1200)*v(2369))+v(255)*v(2626)
dRdX(3,7)=v(1877)+v(1878)+v(1879)-v(1201)*v(2369)+v(256)*v(2625)
dRdX(3,8)=-v(1835)-v(1836)+v(1837)-v(1202)*v(2369)+v(257)*v(2629)
dRdX(3,9)=-(v(1203)*v(2369))+v(258)*v(2626)
dRdX(3,10)=-v(1904)-v(1905)+v(1906)-v(1204)*v(2369)+v(259)*v(2631)
dRdX(3,11)=-(v(1205)*v(2369))
dRdX(3,12)=-(v(1206)*v(2369))
dRdX(3,13)=-(v(1207)*v(2369))
dRdX(3,14)=-(v(1208)*v(2369))
dRdX(3,15)=-(v(1209)*v(2369))
dRdX(3,16)=-(v(1210)*v(2369))
dRdX(3,17)=-(v(1211)*v(2369))
dRdX(3,18)=-(v(1212)*v(2369))
dRdX(3,19)=-(v(1213)*v(2369))
dRdX(3,20)=-(v(1214)*v(2369))
dRdX(3,21)=-(v(1215)*v(2369))
dRdX(3,22)=-(v(1216)*v(2369))
dRdX(3,23)=-(v(1217)*v(2369))
dRdX(3,24)=-(v(1218)*v(2369))
dRdX(3,25)=-(v(1219)*v(2369))
dRdX(3,26)=-(v(1220)*v(2369))
dRdX(3,27)=-(v(1221)*v(2369))
dRdX(3,28)=-(v(1222)*v(2369))
dRdX(4,1)=-v(185)-v(2632)
dRdX(4,2)=v(1818)+v(1819)+v(1820)-v(1224)*v(2369)+v(250)*v(2633)
dRdX(4,3)=v(1923)+v(1924)+v(1925)-v(1225)*v(2369)+v(252)*v(2635)
dRdX(4,4)=-(v(1226)*v(2369))+v(253)*v(2637)
dRdX(4,5)=v(1914)+v(1915)+v(1916)-v(1227)*v(2369)+v(254)*v(2635)
dRdX(4,6)=-v(1788)-v(1789)+v(1790)-v(1228)*v(2369)+v(255)*v(2639)
dRdX(4,7)=-(v(1229)*v(2369))+v(256)*v(2637)
dRdX(4,8)=-v(1839)-v(1840)+v(1841)-v(1230)*v(2369)+v(257)*v(2639)
dRdX(4,9)=-v(1872)-v(1873)+v(1874)-v(1231)*v(2369)+v(258)*v(2633)
dRdX(4,10)=-(v(1232)*v(2369))+v(259)*v(2637)
dRdX(4,11)=-(v(1233)*v(2369))
dRdX(4,12)=-(v(1234)*v(2369))
dRdX(4,13)=-(v(1235)*v(2369))
dRdX(4,14)=-(v(1236)*v(2369))
dRdX(4,15)=-(v(1237)*v(2369))
dRdX(4,16)=-(v(1238)*v(2369))
dRdX(4,17)=-(v(1239)*v(2369))
dRdX(4,18)=-(v(1240)*v(2369))
dRdX(4,19)=-(v(1241)*v(2369))
dRdX(4,20)=-(v(1242)*v(2369))
dRdX(4,21)=-(v(1243)*v(2369))
dRdX(4,22)=-(v(1244)*v(2369))
dRdX(4,23)=-(v(1245)*v(2369))
dRdX(4,24)=-(v(1246)*v(2369))
dRdX(4,25)=-(v(1247)*v(2369))
dRdX(4,26)=-(v(1248)*v(2369))
dRdX(4,27)=-(v(1249)*v(2369))
dRdX(4,28)=-(v(1250)*v(2369))
dRdX(5,1)=v(1279)
dRdX(5,2)=v(1280)+v(1867)+v(1868)+v(1869)+v(250)*v(2640)
dRdX(5,3)=v(1281)+v(252)*v(2641)
dRdX(5,4)=v(1282)+v(1798)+v(1799)+v(1800)+v(253)*v(2644)
dRdX(5,5)=v(1283)-v(1768)-v(1769)+v(1770)+v(254)*v(2646)
dRdX(5,6)=v(1284)+v(255)*v(2641)
dRdX(5,7)=v(1285)+v(1885)+v(1886)+v(1887)+v(256)*v(2640)
dRdX(5,8)=v(1286)-v(1843)-v(1844)+v(1845)+v(257)*v(2644)
dRdX(5,9)=v(1287)+v(258)*v(2641)
dRdX(5,10)=v(1288)-v(1909)-v(1910)+v(1911)+v(259)*v(2646)
dRdX(5,11)=v(1289)
dRdX(5,12)=v(1290)
dRdX(5,13)=v(1291)
dRdX(5,14)=v(1292)
dRdX(5,15)=v(1293)
dRdX(5,16)=v(1294)
dRdX(5,17)=v(1295)
dRdX(5,18)=v(1296)
dRdX(5,19)=v(1297)
dRdX(5,20)=v(1298)
dRdX(5,21)=v(1299)
dRdX(5,22)=v(1300)
dRdX(5,23)=v(1301)
dRdX(5,24)=v(1302)
dRdX(5,25)=v(1303)
dRdX(5,26)=v(1304)
dRdX(5,27)=v(1305)
dRdX(5,28)=v(1306)
dRdX(6,1)=v(1335)
dRdX(6,2)=v(1336)+v(1823)+v(1824)+v(1825)+v(250)*v(2647)
dRdX(6,3)=v(1337)+v(1904)+v(1905)+v(1906)+v(252)*v(2649)
dRdX(6,4)=v(1338)+v(253)*v(2651)
dRdX(6,5)=v(1339)+v(1919)+v(1920)+v(1921)+v(254)*v(2649)
dRdX(6,6)=v(1340)-v(1793)-v(1794)+v(1795)+v(255)*v(2653)
dRdX(6,7)=v(1341)+v(256)*v(2651)
dRdX(6,8)=v(1342)-v(1847)-v(1848)+v(1849)+v(257)*v(2653)
dRdX(6,9)=v(1343)-v(1877)-v(1878)+v(1879)+v(258)*v(2647)
dRdX(6,10)=v(1344)+v(259)*v(2651)
dRdX(6,11)=v(1345)
dRdX(6,12)=v(1346)
dRdX(6,13)=v(1347)
dRdX(6,14)=v(1348)
dRdX(6,15)=v(1349)
dRdX(6,16)=v(1350)
dRdX(6,17)=v(1351)
dRdX(6,18)=v(1352)
dRdX(6,19)=v(1353)
dRdX(6,20)=v(1354)
dRdX(6,21)=v(1355)
dRdX(6,22)=v(1356)
dRdX(6,23)=v(1357)
dRdX(6,24)=v(1358)
dRdX(6,25)=v(1359)
dRdX(6,26)=v(1360)
dRdX(6,27)=v(1361)
dRdX(6,28)=v(1362)
dRdX(7,1)=v(1633)
dRdX(7,2)=v(1634)+v(250)*v(2654)
dRdX(7,3)=v(1635)+v(1776)+v(1777)+v(1778)+v(252)*v(2655)
dRdX(7,4)=v(1636)+v(1839)+v(1840)+v(1841)+v(253)*v(2658)
dRdX(7,5)=v(1637)+v(254)*v(2654)
dRdX(7,6)=v(1638)+v(1857)+v(1858)+v(1859)+v(255)*v(2658)
dRdX(7,7)=v(1639)-v(1818)-v(1819)+v(1820)+v(256)*v(2660)
dRdX(7,8)=v(1640)+v(257)*v(2654)
dRdX(7,9)=v(1641)-v(1881)-v(1882)+v(1883)+v(258)*v(2660)
dRdX(7,10)=v(1642)-v(1914)-v(1915)+v(1916)+v(259)*v(2655)
dRdX(7,11)=v(1643)
dRdX(7,12)=v(1644)
dRdX(7,13)=v(1645)
dRdX(7,14)=v(1646)
dRdX(7,15)=v(1647)
dRdX(7,16)=v(1648)
dRdX(7,17)=v(1649)
dRdX(7,18)=v(1650)
dRdX(7,19)=v(1651)
dRdX(7,20)=v(1652)
dRdX(7,21)=v(1653)
dRdX(7,22)=v(1654)
dRdX(7,23)=v(1655)
dRdX(7,24)=v(1656)
dRdX(7,25)=v(1657)
dRdX(7,26)=v(1658)
dRdX(7,27)=v(1659)
dRdX(7,28)=v(1660)
dRdX(8,1)=v(1633)
dRdX(8,2)=v(1634)+v(1810)+v(1811)+v(1812)+v(250)*v(2661)
dRdX(8,3)=v(1635)+v(1909)+v(1910)+v(1911)+v(252)*v(2663)
dRdX(8,4)=v(1636)+v(253)*v(2665)
dRdX(8,5)=v(1637)+v(1900)+v(1901)+v(1902)+v(254)*v(2663)
dRdX(8,6)=v(1638)-v(1798)-v(1799)+v(1800)+v(255)*v(2667)
dRdX(8,7)=v(1639)+v(256)*v(2665)
dRdX(8,8)=v(1640)-v(1852)-v(1853)+v(1854)+v(257)*v(2667)
dRdX(8,9)=v(1641)-v(1885)-v(1886)+v(1887)+v(258)*v(2661)
dRdX(8,10)=v(1642)+v(259)*v(2665)
dRdX(8,11)=v(1643)
dRdX(8,12)=v(1644)
dRdX(8,13)=v(1645)
dRdX(8,14)=v(1646)
dRdX(8,15)=v(1647)
dRdX(8,16)=v(1648)
dRdX(8,17)=v(1649)
dRdX(8,18)=v(1650)
dRdX(8,19)=v(1651)
dRdX(8,20)=v(1652)
dRdX(8,21)=v(1653)
dRdX(8,22)=v(1654)
dRdX(8,23)=v(1655)
dRdX(8,24)=v(1656)
dRdX(8,25)=v(1657)
dRdX(8,26)=v(1658)
dRdX(8,27)=v(1659)
dRdX(8,28)=v(1660)
dRdX(9,1)=v(1279)
dRdX(9,2)=v(1280)+v(250)*v(2668)
dRdX(9,3)=v(1281)+v(1763)+v(1764)+v(1765)+v(252)*v(2669)
dRdX(9,4)=v(1282)+v(1847)+v(1848)+v(1849)+v(253)*v(2672)
dRdX(9,5)=v(1283)+v(254)*v(2668)
dRdX(9,6)=v(1284)+v(1835)+v(1836)+v(1837)+v(255)*v(2672)
dRdX(9,7)=v(1285)-v(1823)-v(1824)+v(1825)+v(256)*v(2674)
dRdX(9,8)=v(1286)+v(257)*v(2668)
dRdX(9,9)=v(1287)-v(1889)-v(1890)+v(1891)+v(258)*v(2674)
dRdX(9,10)=v(1288)-v(1919)-v(1920)+v(1921)+v(259)*v(2669)
dRdX(9,11)=v(1289)
dRdX(9,12)=v(1290)
dRdX(9,13)=v(1291)
dRdX(9,14)=v(1292)
dRdX(9,15)=v(1293)
dRdX(9,16)=v(1294)
dRdX(9,17)=v(1295)
dRdX(9,18)=v(1296)
dRdX(9,19)=v(1297)
dRdX(9,20)=v(1298)
dRdX(9,21)=v(1299)
dRdX(9,22)=v(1300)
dRdX(9,23)=v(1301)
dRdX(9,24)=v(1302)
dRdX(9,25)=v(1303)
dRdX(9,26)=v(1304)
dRdX(9,27)=v(1305)
dRdX(9,28)=v(1306)
dRdX(10,1)=v(1335)
dRdX(10,2)=v(1336)+v(1881)+v(1882)+v(1883)+v(250)*v(2675)
dRdX(10,3)=v(1337)+v(252)*v(2676)
dRdX(10,4)=v(1338)+v(1788)+v(1789)+v(1790)+v(253)*v(2679)
dRdX(10,5)=v(1339)-v(1776)-v(1777)+v(1778)+v(254)*v(2681)
dRdX(10,6)=v(1340)+v(255)*v(2676)
dRdX(10,7)=v(1341)+v(1872)+v(1873)+v(1874)+v(256)*v(2675)
dRdX(10,8)=v(1342)-v(1857)-v(1858)+v(1859)+v(257)*v(2679)
dRdX(10,9)=v(1343)+v(258)*v(2676)
dRdX(10,10)=v(1344)-v(1923)-v(1924)+v(1925)+v(259)*v(2681)
dRdX(10,11)=v(1345)
dRdX(10,12)=v(1346)
dRdX(10,13)=v(1347)
dRdX(10,14)=v(1348)
dRdX(10,15)=v(1349)
dRdX(10,16)=v(1350)
dRdX(10,17)=v(1351)
dRdX(10,18)=v(1352)
dRdX(10,19)=v(1353)
dRdX(10,20)=v(1354)
dRdX(10,21)=v(1355)
dRdX(10,22)=v(1356)
dRdX(10,23)=v(1357)
dRdX(10,24)=v(1358)
dRdX(10,25)=v(1359)
dRdX(10,26)=v(1360)
dRdX(10,27)=v(1361)
dRdX(10,28)=v(1362)
dRdX(11,1)=-(v(119)*v(2367))-v(180)*v(2607)+v(2608)*v(2616)
dRdX(11,2)=-(v(2369)*(v(1513)*v(180)+v(1168)*v(2607)))
dRdX(11,3)=-(v(2369)*(v(1514)*v(180)+v(1169)*v(2607)))
dRdX(11,4)=-(v(2369)*(v(1515)*v(180)+v(1170)*v(2607)))
dRdX(11,5)=-(v(2369)*(v(1516)*v(180)+v(1171)*v(2607)))
dRdX(11,6)=-(v(2369)*(v(1517)*v(180)+v(1172)*v(2607)))
dRdX(11,7)=-(v(2369)*(v(1518)*v(180)+v(1173)*v(2607)))
dRdX(11,8)=-(v(2369)*(v(1519)*v(180)+v(1174)*v(2607)))
dRdX(11,9)=-(v(2369)*(v(1520)*v(180)+v(1175)*v(2607)))
dRdX(11,10)=-(v(2369)*(v(1521)*v(180)+v(1176)*v(2607)))
dRdX(11,11)=v(265)*v(2682)-v(2369)*(v(1522)*v(180)+v(1177)*v(2607)+v(2367)*v(659))
dRdX(11,12)=v(1987)+v(1988)+v(1989)+v(266)*v(2683)-v(2369)*(v(1523)*v(180)+v(1178)*v(2607)+v(2367)*v(660))
dRdX(11,13)=v(2071)+v(2072)+v(2073)+v(267)*v(2686)-v(2369)*(v(1524)*v(180)+v(1179)*v(2607)+v(2367)*v(661))
dRdX(11,14)=v(268)*v(2682)-v(2369)*(v(1525)*v(180)+v(1180)*v(2607)+v(2367)*v(662))
dRdX(11,15)=v(2062)+v(2063)+v(2064)+v(2686)*v(269)-v(2369)*(v(1526)*v(180)+v(1181)*v(2607)+v(2367)*v(663))
dRdX(11,16)=-v(2029)-v(2030)+v(2031)+v(2688)*v(270)-v(2369)*(v(1527)*v(180)+v(1182)*v(2607)+v(2367)*v(664))
dRdX(11,17)=v(2682)*v(271)-v(2369)*(v(1528)*v(180)+v(1183)*v(2607)+v(2367)*v(665))
dRdX(11,18)=-v(2086)-v(2087)+v(2088)+v(2688)*v(272)-v(2369)*(v(1529)*v(180)+v(1184)*v(2607)+v(2367)*v(666))
dRdX(11,19)=-v(2119)-v(2120)+v(2121)+v(2683)*v(273)-v(2369)*(v(1530)*v(180)+v(1185)*v(2607)+v(2367)*v(667))
dRdX(11,20)=-(v(2369)*(v(1531)*v(180)+v(1186)*v(2607)))
dRdX(11,21)=-(v(2369)*(v(1532)*v(180)+v(1187)*v(2607)))
dRdX(11,22)=-(v(2369)*(v(1533)*v(180)+v(1188)*v(2607)))
dRdX(11,23)=-(v(2369)*(v(1534)*v(180)+v(1189)*v(2607)))
dRdX(11,24)=-(v(2369)*(v(1535)*v(180)+v(1190)*v(2607)))
dRdX(11,25)=-(v(2369)*(v(1536)*v(180)+v(1191)*v(2607)))
dRdX(11,26)=-(v(2369)*(v(1537)*v(180)+v(1192)*v(2607)))
dRdX(11,27)=-(v(2369)*(v(1538)*v(180)+v(1193)*v(2607)))
dRdX(11,28)=-(v(2369)*(v(1539)*v(180)+v(1194)*v(2607)))
dRdX(12,1)=-(v(122)*v(2367))-v(183)*v(2607)+v(2608)*v(2624)
dRdX(12,2)=-(v(2369)*(v(1513)*v(183)+v(1196)*v(2607)))
dRdX(12,3)=-(v(2369)*(v(1514)*v(183)+v(1197)*v(2607)))
dRdX(12,4)=-(v(2369)*(v(1515)*v(183)+v(1198)*v(2607)))
dRdX(12,5)=-(v(2369)*(v(1516)*v(183)+v(1199)*v(2607)))
dRdX(12,6)=-(v(2369)*(v(1517)*v(183)+v(1200)*v(2607)))
dRdX(12,7)=-(v(2369)*(v(1518)*v(183)+v(1201)*v(2607)))
dRdX(12,8)=-(v(2369)*(v(1519)*v(183)+v(1202)*v(2607)))
dRdX(12,9)=-(v(2369)*(v(1520)*v(183)+v(1203)*v(2607)))
dRdX(12,10)=-(v(2369)*(v(1521)*v(183)+v(1204)*v(2607)))
dRdX(12,11)=v(2108)+v(2109)+v(2110)+v(265)*v(2689)-v(2369)*(v(1522)*v(183)+v(1205)*v(2607)+v(2367)*v(669))
dRdX(12,12)=v(266)*v(2690)-v(2369)*(v(1523)*v(183)+v(1206)*v(2607)+v(2367)*v(670))
dRdX(12,13)=v(2012)+v(2013)+v(2014)+v(267)*v(2693)-v(2369)*(v(1524)*v(183)+v(1207)*v(2607)+v(2367)*v(671))
dRdX(12,14)=-v(1982)-v(1983)+v(1984)+v(268)*v(2695)-v(2369)*(v(1525)*v(183)+v(1208)*v(2607)+v(2367)*v(672))
dRdX(12,15)=v(269)*v(2690)-v(2369)*(v(1526)*v(183)+v(1209)*v(2607)+v(2367)*v(673))
dRdX(12,16)=v(2096)+v(2097)+v(2098)+v(2689)*v(270)-v(2369)*(v(1527)*v(183)+v(1210)*v(2607)+v(2367)*v(674))
dRdX(12,17)=-v(2054)-v(2055)+v(2056)+v(2693)*v(271)-v(2369)*(v(1528)*v(183)+v(1211)*v(2607)+v(2367)*v(675))
dRdX(12,18)=v(2690)*v(272)-v(2369)*(v(1529)*v(183)+v(1212)*v(2607)+v(2367)*v(676))
dRdX(12,19)=-v(2123)-v(2124)+v(2125)+v(2695)*v(273)-v(2369)*(v(1530)*v(183)+v(1213)*v(2607)+v(2367)*v(677))
dRdX(12,20)=-(v(2369)*(v(1531)*v(183)+v(1214)*v(2607)))
dRdX(12,21)=-(v(2369)*(v(1532)*v(183)+v(1215)*v(2607)))
dRdX(12,22)=-(v(2369)*(v(1533)*v(183)+v(1216)*v(2607)))
dRdX(12,23)=-(v(2369)*(v(1534)*v(183)+v(1217)*v(2607)))
dRdX(12,24)=-(v(2369)*(v(1535)*v(183)+v(1218)*v(2607)))
dRdX(12,25)=-(v(2369)*(v(1536)*v(183)+v(1219)*v(2607)))
dRdX(12,26)=-(v(2369)*(v(1537)*v(183)+v(1220)*v(2607)))
dRdX(12,27)=-(v(2369)*(v(1538)*v(183)+v(1221)*v(2607)))
dRdX(12,28)=-(v(2369)*(v(1539)*v(183)+v(1222)*v(2607)))
dRdX(13,1)=-(v(125)*v(2367))-v(185)*v(2607)+v(2608)*v(2632)
dRdX(13,2)=-(v(2369)*(v(1513)*v(185)+v(1224)*v(2607)))
dRdX(13,3)=-(v(2369)*(v(1514)*v(185)+v(1225)*v(2607)))
dRdX(13,4)=-(v(2369)*(v(1515)*v(185)+v(1226)*v(2607)))
dRdX(13,5)=-(v(2369)*(v(1516)*v(185)+v(1227)*v(2607)))
dRdX(13,6)=-(v(2369)*(v(1517)*v(185)+v(1228)*v(2607)))
dRdX(13,7)=-(v(2369)*(v(1518)*v(185)+v(1229)*v(2607)))
dRdX(13,8)=-(v(2369)*(v(1519)*v(185)+v(1230)*v(2607)))
dRdX(13,9)=-(v(2369)*(v(1520)*v(185)+v(1231)*v(2607)))
dRdX(13,10)=-(v(2369)*(v(1521)*v(185)+v(1232)*v(2607)))
dRdX(13,11)=v(2037)+v(2038)+v(2039)+v(265)*v(2696)-v(2369)*(v(1522)*v(185)+v(1233)*v(2607)+v(2367)*v(679))
dRdX(13,12)=v(2142)+v(2143)+v(2144)+v(266)*v(2698)-v(2369)*(v(1523)*v(185)+v(1234)*v(2607)+v(2367)*v(680))
dRdX(13,13)=v(267)*v(2700)-v(2369)*(v(1524)*v(185)+v(1235)*v(2607)+v(2367)*v(681))
dRdX(13,14)=v(2133)+v(2134)+v(2135)+v(268)*v(2698)-v(2369)*(v(1525)*v(185)+v(1236)*v(2607)+v(2367)*v(682))
dRdX(13,15)=-v(2007)-v(2008)+v(2009)+v(269)*v(2702)-v(2369)*(v(1526)*v(185)+v(1237)*v(2607)+v(2367)*v(683))
dRdX(13,16)=v(270)*v(2700)-v(2369)*(v(1527)*v(185)+v(1238)*v(2607)+v(2367)*v(684))
dRdX(13,17)=-v(2058)-v(2059)+v(2060)+v(2702)*v(271)-v(2369)*(v(1528)*v(185)+v(1239)*v(2607)+v(2367)*v(685))
dRdX(13,18)=-v(2091)-v(2092)+v(2093)+v(2696)*v(272)-v(2369)*(v(1529)*v(185)+v(1240)*v(2607)+v(2367)*v(686))
dRdX(13,19)=v(2700)*v(273)-v(2369)*(v(1530)*v(185)+v(1241)*v(2607)+v(2367)*v(687))
dRdX(13,20)=-(v(2369)*(v(1531)*v(185)+v(1242)*v(2607)))
dRdX(13,21)=-(v(2369)*(v(1532)*v(185)+v(1243)*v(2607)))
dRdX(13,22)=-(v(2369)*(v(1533)*v(185)+v(1244)*v(2607)))
dRdX(13,23)=-(v(2369)*(v(1534)*v(185)+v(1245)*v(2607)))
dRdX(13,24)=-(v(2369)*(v(1535)*v(185)+v(1246)*v(2607)))
dRdX(13,25)=-(v(2369)*(v(1536)*v(185)+v(1247)*v(2607)))
dRdX(13,26)=-(v(2369)*(v(1537)*v(185)+v(1248)*v(2607)))
dRdX(13,27)=-(v(2369)*(v(1538)*v(185)+v(1249)*v(2607)))
dRdX(13,28)=-(v(2369)*(v(1539)*v(185)+v(1250)*v(2607)))
dRdX(14,1)=v(1574)
dRdX(14,2)=v(1575)
dRdX(14,3)=v(1576)
dRdX(14,4)=v(1577)
dRdX(14,5)=v(1578)
dRdX(14,6)=v(1579)
dRdX(14,7)=v(1580)
dRdX(14,8)=v(1581)
dRdX(14,9)=v(1582)
dRdX(14,10)=v(1583)
dRdX(14,11)=v(1584)+v(2086)+v(2087)+v(2088)+v(265)*v(2703)
dRdX(14,12)=v(1585)+v(266)*v(2704)
dRdX(14,13)=v(1586)+v(2017)+v(2018)+v(2019)+v(267)*v(2707)
dRdX(14,14)=v(1587)-v(1987)-v(1988)+v(1989)+v(268)*v(2709)
dRdX(14,15)=v(1588)+v(269)*v(2704)
dRdX(14,16)=v(1589)+v(2104)+v(2105)+v(2106)+v(270)*v(2703)
dRdX(14,17)=v(1590)-v(2062)-v(2063)+v(2064)+v(2707)*v(271)
dRdX(14,18)=v(1591)+v(2704)*v(272)
dRdX(14,19)=v(1592)-v(2128)-v(2129)+v(2130)+v(2709)*v(273)
dRdX(14,20)=v(1593)
dRdX(14,21)=v(1594)
dRdX(14,22)=v(1595)
dRdX(14,23)=v(1596)
dRdX(14,24)=v(1597)
dRdX(14,25)=v(1598)
dRdX(14,26)=v(1599)
dRdX(14,27)=v(1600)
dRdX(14,28)=v(1601)
dRdX(15,1)=v(1543)
dRdX(15,2)=v(1544)
dRdX(15,3)=v(1545)
dRdX(15,4)=v(1546)
dRdX(15,5)=v(1547)
dRdX(15,6)=v(1548)
dRdX(15,7)=v(1549)
dRdX(15,8)=v(1550)
dRdX(15,9)=v(1551)
dRdX(15,10)=v(1552)
dRdX(15,11)=v(1553)+v(2042)+v(2043)+v(2044)+v(265)*v(2710)
dRdX(15,12)=v(1554)+v(2123)+v(2124)+v(2125)+v(266)*v(2712)
dRdX(15,13)=v(1555)+v(267)*v(2714)
dRdX(15,14)=v(1556)+v(2138)+v(2139)+v(2140)+v(268)*v(2712)
dRdX(15,15)=v(1557)-v(2012)-v(2013)+v(2014)+v(269)*v(2716)
dRdX(15,16)=v(1558)+v(270)*v(2714)
dRdX(15,17)=v(1559)-v(2066)-v(2067)+v(2068)+v(271)*v(2716)
dRdX(15,18)=v(1560)-v(2096)-v(2097)+v(2098)+v(2710)*v(272)
dRdX(15,19)=v(1561)+v(2714)*v(273)
dRdX(15,20)=v(1562)
dRdX(15,21)=v(1563)
dRdX(15,22)=v(1564)
dRdX(15,23)=v(1565)
dRdX(15,24)=v(1566)
dRdX(15,25)=v(1567)
dRdX(15,26)=v(1568)
dRdX(15,27)=v(1569)
dRdX(15,28)=v(1570)
dRdX(16,1)=v(1605)
dRdX(16,2)=v(1606)
dRdX(16,3)=v(1607)
dRdX(16,4)=v(1608)
dRdX(16,5)=v(1609)
dRdX(16,6)=v(1610)
dRdX(16,7)=v(1611)
dRdX(16,8)=v(1612)
dRdX(16,9)=v(1613)
dRdX(16,10)=v(1614)
dRdX(16,11)=v(1615)+v(265)*v(2717)
dRdX(16,12)=v(1616)+v(1995)+v(1996)+v(1997)+v(266)*v(2718)
dRdX(16,13)=v(1617)+v(2058)+v(2059)+v(2060)+v(267)*v(2721)
dRdX(16,14)=v(1618)+v(268)*v(2717)
dRdX(16,15)=v(1619)+v(2076)+v(2077)+v(2078)+v(269)*v(2721)
dRdX(16,16)=v(1620)-v(2037)-v(2038)+v(2039)+v(270)*v(2723)
dRdX(16,17)=v(1621)+v(271)*v(2717)
dRdX(16,18)=v(1622)-v(2100)-v(2101)+v(2102)+v(272)*v(2723)
dRdX(16,19)=v(1623)-v(2133)-v(2134)+v(2135)+v(2718)*v(273)
dRdX(16,20)=v(1624)
dRdX(16,21)=v(1625)
dRdX(16,22)=v(1626)
dRdX(16,23)=v(1627)
dRdX(16,24)=v(1628)
dRdX(16,25)=v(1629)
dRdX(16,26)=v(1630)
dRdX(16,27)=v(1631)
dRdX(16,28)=v(1632)
dRdX(17,1)=v(1605)
dRdX(17,2)=v(1606)
dRdX(17,3)=v(1607)
dRdX(17,4)=v(1608)
dRdX(17,5)=v(1609)
dRdX(17,6)=v(1610)
dRdX(17,7)=v(1611)
dRdX(17,8)=v(1612)
dRdX(17,9)=v(1613)
dRdX(17,10)=v(1614)
dRdX(17,11)=v(1615)+v(2029)+v(2030)+v(2031)+v(265)*v(2724)
dRdX(17,12)=v(1616)+v(2128)+v(2129)+v(2130)+v(266)*v(2726)
dRdX(17,13)=v(1617)+v(267)*v(2728)
dRdX(17,14)=v(1618)+v(2119)+v(2120)+v(2121)+v(268)*v(2726)
dRdX(17,15)=v(1619)-v(2017)-v(2018)+v(2019)+v(269)*v(2730)
dRdX(17,16)=v(1620)+v(270)*v(2728)
dRdX(17,17)=v(1621)-v(2071)-v(2072)+v(2073)+v(271)*v(2730)
dRdX(17,18)=v(1622)-v(2104)-v(2105)+v(2106)+v(272)*v(2724)
dRdX(17,19)=v(1623)+v(2728)*v(273)
dRdX(17,20)=v(1624)
dRdX(17,21)=v(1625)
dRdX(17,22)=v(1626)
dRdX(17,23)=v(1627)
dRdX(17,24)=v(1628)
dRdX(17,25)=v(1629)
dRdX(17,26)=v(1630)
dRdX(17,27)=v(1631)
dRdX(17,28)=v(1632)
dRdX(18,1)=v(1574)
dRdX(18,2)=v(1575)
dRdX(18,3)=v(1576)
dRdX(18,4)=v(1577)
dRdX(18,5)=v(1578)
dRdX(18,6)=v(1579)
dRdX(18,7)=v(1580)
dRdX(18,8)=v(1581)
dRdX(18,9)=v(1582)
dRdX(18,10)=v(1583)
dRdX(18,11)=v(1584)+v(265)*v(2731)
dRdX(18,12)=v(1585)+v(1982)+v(1983)+v(1984)+v(266)*v(2732)
dRdX(18,13)=v(1586)+v(2066)+v(2067)+v(2068)+v(267)*v(2735)
dRdX(18,14)=v(1587)+v(268)*v(2731)
dRdX(18,15)=v(1588)+v(2054)+v(2055)+v(2056)+v(269)*v(2735)
dRdX(18,16)=v(1589)-v(2042)-v(2043)+v(2044)+v(270)*v(2737)
dRdX(18,17)=v(1590)+v(271)*v(2731)
dRdX(18,18)=v(1591)-v(2108)-v(2109)+v(2110)+v(272)*v(2737)
dRdX(18,19)=v(1592)-v(2138)-v(2139)+v(2140)+v(273)*v(2732)
dRdX(18,20)=v(1593)
dRdX(18,21)=v(1594)
dRdX(18,22)=v(1595)
dRdX(18,23)=v(1596)
dRdX(18,24)=v(1597)
dRdX(18,25)=v(1598)
dRdX(18,26)=v(1599)
dRdX(18,27)=v(1600)
dRdX(18,28)=v(1601)
dRdX(19,1)=v(1543)
dRdX(19,2)=v(1544)
dRdX(19,3)=v(1545)
dRdX(19,4)=v(1546)
dRdX(19,5)=v(1547)
dRdX(19,6)=v(1548)
dRdX(19,7)=v(1549)
dRdX(19,8)=v(1550)
dRdX(19,9)=v(1551)
dRdX(19,10)=v(1552)
dRdX(19,11)=v(1553)+v(2100)+v(2101)+v(2102)+v(265)*v(2738)
dRdX(19,12)=v(1554)+v(266)*v(2739)
dRdX(19,13)=v(1555)+v(2007)+v(2008)+v(2009)+v(267)*v(2742)
dRdX(19,14)=v(1556)-v(1995)-v(1996)+v(1997)+v(268)*v(2744)
dRdX(19,15)=v(1557)+v(269)*v(2739)
dRdX(19,16)=v(1558)+v(2091)+v(2092)+v(2093)+v(270)*v(2738)
dRdX(19,17)=v(1559)-v(2076)-v(2077)+v(2078)+v(271)*v(2742)
dRdX(19,18)=v(1560)+v(272)*v(2739)
dRdX(19,19)=v(1561)-v(2142)-v(2143)+v(2144)+v(273)*v(2744)
dRdX(19,20)=v(1562)
dRdX(19,21)=v(1563)
dRdX(19,22)=v(1564)
dRdX(19,23)=v(1565)
dRdX(19,24)=v(1566)
dRdX(19,25)=v(1567)
dRdX(19,26)=v(1568)
dRdX(19,27)=v(1569)
dRdX(19,28)=v(1570)
dRdX(20,1)=-(v(145)*v(235))-v(180)*v(2602)+v(2605)*v(2616)
dRdX(20,2)=-(v(2369)*(v(1392)*v(180)+v(1168)*v(2602)))
dRdX(20,3)=-(v(2369)*(v(1393)*v(180)+v(1169)*v(2602)))
dRdX(20,4)=-(v(2369)*(v(1394)*v(180)+v(1170)*v(2602)))
dRdX(20,5)=-(v(2369)*(v(1395)*v(180)+v(1171)*v(2602)))
dRdX(20,6)=-(v(2369)*(v(1396)*v(180)+v(1172)*v(2602)))
dRdX(20,7)=-(v(2369)*(v(1397)*v(180)+v(1173)*v(2602)))
dRdX(20,8)=-(v(2369)*(v(1398)*v(180)+v(1174)*v(2602)))
dRdX(20,9)=-(v(2369)*(v(1399)*v(180)+v(1175)*v(2602)))
dRdX(20,10)=-(v(2369)*(v(1400)*v(180)+v(1176)*v(2602)))
dRdX(20,11)=-(v(2369)*(v(1401)*v(180)+v(1177)*v(2602)))
dRdX(20,12)=-(v(2369)*(v(1402)*v(180)+v(1178)*v(2602)))
dRdX(20,13)=-(v(2369)*(v(1403)*v(180)+v(1179)*v(2602)))
dRdX(20,14)=-(v(2369)*(v(1404)*v(180)+v(1180)*v(2602)))
dRdX(20,15)=-(v(2369)*(v(1405)*v(180)+v(1181)*v(2602)))
dRdX(20,16)=-(v(2369)*(v(1406)*v(180)+v(1182)*v(2602)))
dRdX(20,17)=-(v(2369)*(v(1407)*v(180)+v(1183)*v(2602)))
dRdX(20,18)=-(v(2369)*(v(1408)*v(180)+v(1184)*v(2602)))
dRdX(20,19)=-(v(2369)*(v(1409)*v(180)+v(1185)*v(2602)))
dRdX(20,20)=v(2745)*v(279)-v(2369)*(v(1410)*v(180)+v(1186)*v(2602)+v(235)*v(876))
dRdX(20,21)=v(2206)+v(2207)+v(2208)+v(2746)*v(280)-v(2369)*(v(1411)*v(180)+v(1187)*v(2602)+v(235)*v(877))
dRdX(20,22)=v(2290)+v(2291)+v(2292)+v(2749)*v(281)-v(2369)*(v(1412)*v(180)+v(1188)*v(2602)+v(235)*v(878))
dRdX(20,23)=v(2745)*v(282)-v(2369)*(v(1413)*v(180)+v(1189)*v(2602)+v(235)*v(879))
dRdX(20,24)=v(2281)+v(2282)+v(2283)+v(2749)*v(283)-v(2369)*(v(1414)*v(180)+v(1190)*v(2602)+v(235)*v(880))
dRdX(20,25)=-v(2248)-v(2249)+v(2250)+v(2751)*v(284)-v(2369)*(v(1415)*v(180)+v(1191)*v(2602)+v(235)*v(881))
dRdX(20,26)=v(2745)*v(285)-v(2369)*(v(1416)*v(180)+v(1192)*v(2602)+v(235)*v(882))
dRdX(20,27)=-v(2305)-v(2306)+v(2307)+v(2751)*v(286)-v(2369)*(v(1417)*v(180)+v(1193)*v(2602)+v(235)*v(883))
dRdX(20,28)=-v(2338)-v(2339)+v(2340)+v(2746)*v(287)-v(2369)*(v(1418)*v(180)+v(1194)*v(2602)+v(235)*v(884))
dRdX(21,1)=-(v(148)*v(235))-v(183)*v(2602)+v(2605)*v(2624)
dRdX(21,2)=-(v(2369)*(v(1392)*v(183)+v(1196)*v(2602)))
dRdX(21,3)=-(v(2369)*(v(1393)*v(183)+v(1197)*v(2602)))
dRdX(21,4)=-(v(2369)*(v(1394)*v(183)+v(1198)*v(2602)))
dRdX(21,5)=-(v(2369)*(v(1395)*v(183)+v(1199)*v(2602)))
dRdX(21,6)=-(v(2369)*(v(1396)*v(183)+v(1200)*v(2602)))
dRdX(21,7)=-(v(2369)*(v(1397)*v(183)+v(1201)*v(2602)))
dRdX(21,8)=-(v(2369)*(v(1398)*v(183)+v(1202)*v(2602)))
dRdX(21,9)=-(v(2369)*(v(1399)*v(183)+v(1203)*v(2602)))
dRdX(21,10)=-(v(2369)*(v(1400)*v(183)+v(1204)*v(2602)))
dRdX(21,11)=-(v(2369)*(v(1401)*v(183)+v(1205)*v(2602)))
dRdX(21,12)=-(v(2369)*(v(1402)*v(183)+v(1206)*v(2602)))
dRdX(21,13)=-(v(2369)*(v(1403)*v(183)+v(1207)*v(2602)))
dRdX(21,14)=-(v(2369)*(v(1404)*v(183)+v(1208)*v(2602)))
dRdX(21,15)=-(v(2369)*(v(1405)*v(183)+v(1209)*v(2602)))
dRdX(21,16)=-(v(2369)*(v(1406)*v(183)+v(1210)*v(2602)))
dRdX(21,17)=-(v(2369)*(v(1407)*v(183)+v(1211)*v(2602)))
dRdX(21,18)=-(v(2369)*(v(1408)*v(183)+v(1212)*v(2602)))
dRdX(21,19)=-(v(2369)*(v(1409)*v(183)+v(1213)*v(2602)))
dRdX(21,20)=v(2327)+v(2328)+v(2329)+v(2752)*v(279)-v(2369)*(v(1410)*v(183)+v(1214)*v(2602)+v(235)*v(886))
dRdX(21,21)=v(2753)*v(280)-v(2369)*(v(1411)*v(183)+v(1215)*v(2602)+v(235)*v(887))
dRdX(21,22)=v(2231)+v(2232)+v(2233)+v(2756)*v(281)-v(2369)*(v(1412)*v(183)+v(1216)*v(2602)+v(235)*v(888))
dRdX(21,23)=-v(2201)-v(2202)+v(2203)+v(2758)*v(282)-v(2369)*(v(1413)*v(183)+v(1217)*v(2602)+v(235)*v(889))
dRdX(21,24)=v(2753)*v(283)-v(2369)*(v(1414)*v(183)+v(1218)*v(2602)+v(235)*v(890))
dRdX(21,25)=v(2315)+v(2316)+v(2317)+v(2752)*v(284)-v(2369)*(v(1415)*v(183)+v(1219)*v(2602)+v(235)*v(891))
dRdX(21,26)=-v(2273)-v(2274)+v(2275)+v(2756)*v(285)-v(2369)*(v(1416)*v(183)+v(1220)*v(2602)+v(235)*v(892))
dRdX(21,27)=v(2753)*v(286)-v(2369)*(v(1417)*v(183)+v(1221)*v(2602)+v(235)*v(893))
dRdX(21,28)=-v(2342)-v(2343)+v(2344)+v(2758)*v(287)-v(2369)*(v(1418)*v(183)+v(1222)*v(2602)+v(235)*v(894))
dRdX(22,1)=-(v(151)*v(235))-v(185)*v(2602)+v(2605)*v(2632)
dRdX(22,2)=-(v(2369)*(v(1392)*v(185)+v(1224)*v(2602)))
dRdX(22,3)=-(v(2369)*(v(1393)*v(185)+v(1225)*v(2602)))
dRdX(22,4)=-(v(2369)*(v(1394)*v(185)+v(1226)*v(2602)))
dRdX(22,5)=-(v(2369)*(v(1395)*v(185)+v(1227)*v(2602)))
dRdX(22,6)=-(v(2369)*(v(1396)*v(185)+v(1228)*v(2602)))
dRdX(22,7)=-(v(2369)*(v(1397)*v(185)+v(1229)*v(2602)))
dRdX(22,8)=-(v(2369)*(v(1398)*v(185)+v(1230)*v(2602)))
dRdX(22,9)=-(v(2369)*(v(1399)*v(185)+v(1231)*v(2602)))
dRdX(22,10)=-(v(2369)*(v(1400)*v(185)+v(1232)*v(2602)))
dRdX(22,11)=-(v(2369)*(v(1401)*v(185)+v(1233)*v(2602)))
dRdX(22,12)=-(v(2369)*(v(1402)*v(185)+v(1234)*v(2602)))
dRdX(22,13)=-(v(2369)*(v(1403)*v(185)+v(1235)*v(2602)))
dRdX(22,14)=-(v(2369)*(v(1404)*v(185)+v(1236)*v(2602)))
dRdX(22,15)=-(v(2369)*(v(1405)*v(185)+v(1237)*v(2602)))
dRdX(22,16)=-(v(2369)*(v(1406)*v(185)+v(1238)*v(2602)))
dRdX(22,17)=-(v(2369)*(v(1407)*v(185)+v(1239)*v(2602)))
dRdX(22,18)=-(v(2369)*(v(1408)*v(185)+v(1240)*v(2602)))
dRdX(22,19)=-(v(2369)*(v(1409)*v(185)+v(1241)*v(2602)))
dRdX(22,20)=v(2256)+v(2257)+v(2258)+v(2759)*v(279)-v(2369)*(v(1410)*v(185)+v(1242)*v(2602)+v(235)*v(896))
dRdX(22,21)=v(2361)+v(2362)+v(2363)+v(2761)*v(280)-v(2369)*(v(1411)*v(185)+v(1243)*v(2602)+v(235)*v(897))
dRdX(22,22)=v(2763)*v(281)-v(2369)*(v(1412)*v(185)+v(1244)*v(2602)+v(235)*v(898))
dRdX(22,23)=v(2352)+v(2353)+v(2354)+v(2761)*v(282)-v(2369)*(v(1413)*v(185)+v(1245)*v(2602)+v(235)*v(899))
dRdX(22,24)=-v(2226)-v(2227)+v(2228)+v(2765)*v(283)-v(2369)*(v(1414)*v(185)+v(1246)*v(2602)+v(235)*v(900))
dRdX(22,25)=v(2763)*v(284)-v(2369)*(v(1415)*v(185)+v(1247)*v(2602)+v(235)*v(901))
dRdX(22,26)=-v(2277)-v(2278)+v(2279)+v(2765)*v(285)-v(2369)*(v(1416)*v(185)+v(1248)*v(2602)+v(235)*v(902))
dRdX(22,27)=-v(2310)-v(2311)+v(2312)+v(2759)*v(286)-v(2369)*(v(1417)*v(185)+v(1249)*v(2602)+v(235)*v(903))
dRdX(22,28)=v(2763)*v(287)-v(2369)*(v(1418)*v(185)+v(1250)*v(2602)+v(235)*v(904))
dRdX(23,1)=v(1453)
dRdX(23,2)=v(1454)
dRdX(23,3)=v(1455)
dRdX(23,4)=v(1456)
dRdX(23,5)=v(1457)
dRdX(23,6)=v(1458)
dRdX(23,7)=v(1459)
dRdX(23,8)=v(1460)
dRdX(23,9)=v(1461)
dRdX(23,10)=v(1462)
dRdX(23,11)=v(1463)
dRdX(23,12)=v(1464)
dRdX(23,13)=v(1465)
dRdX(23,14)=v(1466)
dRdX(23,15)=v(1467)
dRdX(23,16)=v(1468)
dRdX(23,17)=v(1469)
dRdX(23,18)=v(1470)
dRdX(23,19)=v(1471)
dRdX(23,20)=v(1472)+v(2305)+v(2306)+v(2307)+v(2766)*v(279)
dRdX(23,21)=v(1473)+v(2767)*v(280)
dRdX(23,22)=v(1474)+v(2236)+v(2237)+v(2238)+v(2770)*v(281)
dRdX(23,23)=v(1475)-v(2206)-v(2207)+v(2208)+v(2772)*v(282)
dRdX(23,24)=v(1476)+v(2767)*v(283)
dRdX(23,25)=v(1477)+v(2323)+v(2324)+v(2325)+v(2766)*v(284)
dRdX(23,26)=v(1478)-v(2281)-v(2282)+v(2283)+v(2770)*v(285)
dRdX(23,27)=v(1479)+v(2767)*v(286)
dRdX(23,28)=v(1480)-v(2347)-v(2348)+v(2349)+v(2772)*v(287)
dRdX(24,1)=v(1422)
dRdX(24,2)=v(1423)
dRdX(24,3)=v(1424)
dRdX(24,4)=v(1425)
dRdX(24,5)=v(1426)
dRdX(24,6)=v(1427)
dRdX(24,7)=v(1428)
dRdX(24,8)=v(1429)
dRdX(24,9)=v(1430)
dRdX(24,10)=v(1431)
dRdX(24,11)=v(1432)
dRdX(24,12)=v(1433)
dRdX(24,13)=v(1434)
dRdX(24,14)=v(1435)
dRdX(24,15)=v(1436)
dRdX(24,16)=v(1437)
dRdX(24,17)=v(1438)
dRdX(24,18)=v(1439)
dRdX(24,19)=v(1440)
dRdX(24,20)=v(1441)+v(2261)+v(2262)+v(2263)+v(2773)*v(279)
dRdX(24,21)=v(1442)+v(2342)+v(2343)+v(2344)+v(2775)*v(280)
dRdX(24,22)=v(1443)+v(2777)*v(281)
dRdX(24,23)=v(1444)+v(2357)+v(2358)+v(2359)+v(2775)*v(282)
dRdX(24,24)=v(1445)-v(2231)-v(2232)+v(2233)+v(2779)*v(283)
dRdX(24,25)=v(1446)+v(2777)*v(284)
dRdX(24,26)=v(1447)-v(2285)-v(2286)+v(2287)+v(2779)*v(285)
dRdX(24,27)=v(1448)-v(2315)-v(2316)+v(2317)+v(2773)*v(286)
dRdX(24,28)=v(1449)+v(2777)*v(287)
dRdX(25,1)=v(1484)
dRdX(25,2)=v(1485)
dRdX(25,3)=v(1486)
dRdX(25,4)=v(1487)
dRdX(25,5)=v(1488)
dRdX(25,6)=v(1489)
dRdX(25,7)=v(1490)
dRdX(25,8)=v(1491)
dRdX(25,9)=v(1492)
dRdX(25,10)=v(1493)
dRdX(25,11)=v(1494)
dRdX(25,12)=v(1495)
dRdX(25,13)=v(1496)
dRdX(25,14)=v(1497)
dRdX(25,15)=v(1498)
dRdX(25,16)=v(1499)
dRdX(25,17)=v(1500)
dRdX(25,18)=v(1501)
dRdX(25,19)=v(1502)
dRdX(25,20)=v(1503)+v(2780)*v(279)
dRdX(25,21)=v(1504)+v(2214)+v(2215)+v(2216)+v(2781)*v(280)
dRdX(25,22)=v(1505)+v(2277)+v(2278)+v(2279)+v(2784)*v(281)
dRdX(25,23)=v(1506)+v(2780)*v(282)
dRdX(25,24)=v(1507)+v(2295)+v(2296)+v(2297)+v(2784)*v(283)
dRdX(25,25)=v(1508)-v(2256)-v(2257)+v(2258)+v(2786)*v(284)
dRdX(25,26)=v(1509)+v(2780)*v(285)
dRdX(25,27)=v(1510)-v(2319)-v(2320)+v(2321)+v(2786)*v(286)
dRdX(25,28)=v(1511)-v(2352)-v(2353)+v(2354)+v(2781)*v(287)
dRdX(26,1)=v(1484)
dRdX(26,2)=v(1485)
dRdX(26,3)=v(1486)
dRdX(26,4)=v(1487)
dRdX(26,5)=v(1488)
dRdX(26,6)=v(1489)
dRdX(26,7)=v(1490)
dRdX(26,8)=v(1491)
dRdX(26,9)=v(1492)
dRdX(26,10)=v(1493)
dRdX(26,11)=v(1494)
dRdX(26,12)=v(1495)
dRdX(26,13)=v(1496)
dRdX(26,14)=v(1497)
dRdX(26,15)=v(1498)
dRdX(26,16)=v(1499)
dRdX(26,17)=v(1500)
dRdX(26,18)=v(1501)
dRdX(26,19)=v(1502)
dRdX(26,20)=v(1503)+v(2248)+v(2249)+v(2250)+v(2787)*v(279)
dRdX(26,21)=v(1504)+v(2347)+v(2348)+v(2349)+v(2789)*v(280)
dRdX(26,22)=v(1505)+v(2791)*v(281)
dRdX(26,23)=v(1506)+v(2338)+v(2339)+v(2340)+v(2789)*v(282)
dRdX(26,24)=v(1507)-v(2236)-v(2237)+v(2238)+v(2793)*v(283)
dRdX(26,25)=v(1508)+v(2791)*v(284)
dRdX(26,26)=v(1509)-v(2290)-v(2291)+v(2292)+v(2793)*v(285)
dRdX(26,27)=v(1510)-v(2323)-v(2324)+v(2325)+v(2787)*v(286)
dRdX(26,28)=v(1511)+v(2791)*v(287)
dRdX(27,1)=v(1453)
dRdX(27,2)=v(1454)
dRdX(27,3)=v(1455)
dRdX(27,4)=v(1456)
dRdX(27,5)=v(1457)
dRdX(27,6)=v(1458)
dRdX(27,7)=v(1459)
dRdX(27,8)=v(1460)
dRdX(27,9)=v(1461)
dRdX(27,10)=v(1462)
dRdX(27,11)=v(1463)
dRdX(27,12)=v(1464)
dRdX(27,13)=v(1465)
dRdX(27,14)=v(1466)
dRdX(27,15)=v(1467)
dRdX(27,16)=v(1468)
dRdX(27,17)=v(1469)
dRdX(27,18)=v(1470)
dRdX(27,19)=v(1471)
dRdX(27,20)=v(1472)+v(279)*v(2794)
dRdX(27,21)=v(1473)+v(2201)+v(2202)+v(2203)+v(2795)*v(280)
dRdX(27,22)=v(1474)+v(2285)+v(2286)+v(2287)+v(2798)*v(281)
dRdX(27,23)=v(1475)+v(2794)*v(282)
dRdX(27,24)=v(1476)+v(2273)+v(2274)+v(2275)+v(2798)*v(283)
dRdX(27,25)=v(1477)-v(2261)-v(2262)+v(2263)+v(2800)*v(284)
dRdX(27,26)=v(1478)+v(2794)*v(285)
dRdX(27,27)=v(1479)-v(2327)-v(2328)+v(2329)+v(2800)*v(286)
dRdX(27,28)=v(1480)-v(2357)-v(2358)+v(2359)+v(2795)*v(287)
dRdX(28,1)=v(1422)
dRdX(28,2)=v(1423)
dRdX(28,3)=v(1424)
dRdX(28,4)=v(1425)
dRdX(28,5)=v(1426)
dRdX(28,6)=v(1427)
dRdX(28,7)=v(1428)
dRdX(28,8)=v(1429)
dRdX(28,9)=v(1430)
dRdX(28,10)=v(1431)
dRdX(28,11)=v(1432)
dRdX(28,12)=v(1433)
dRdX(28,13)=v(1434)
dRdX(28,14)=v(1435)
dRdX(28,15)=v(1436)
dRdX(28,16)=v(1437)
dRdX(28,17)=v(1438)
dRdX(28,18)=v(1439)
dRdX(28,19)=v(1440)
dRdX(28,20)=v(1441)+v(2319)+v(2320)+v(2321)+v(279)*v(2801)
dRdX(28,21)=v(1442)+v(280)*v(2802)
dRdX(28,22)=v(1443)+v(2226)+v(2227)+v(2228)+v(2805)*v(281)
dRdX(28,23)=v(1444)-v(2214)-v(2215)+v(2216)+v(2807)*v(282)
dRdX(28,24)=v(1445)+v(2802)*v(283)
dRdX(28,25)=v(1446)+v(2310)+v(2311)+v(2312)+v(2801)*v(284)
dRdX(28,26)=v(1447)-v(2295)-v(2296)+v(2297)+v(2805)*v(285)
dRdX(28,27)=v(1448)+v(2802)*v(286)
dRdX(28,28)=v(1449)-v(2361)-v(2362)+v(2363)+v(2807)*v(287)
END
|
Require Import FcEtt.sigs.
Require Import FcEtt.imports.
Require Import FcEtt.tactics.
Require Import FcEtt.ett_ott.
Require Import FcEtt.ett_inf.
Require Import FcEtt.ett_inf_cs.
Require Import FcEtt.ett_ind.
Require Import FcEtt.ett_par.
Require Import FcEtt.ext_invert.
Require Import FcEtt.ext_red.
Require Import FcEtt.ext_red_one.
Require Import FcEtt.erase_syntax.
Require Import FcEtt.fc_invert FcEtt.fc_unique.
Module fc_preservation (wf : fc_wf_sig) (weak : fc_weak_sig) (subst : fc_subst_sig)
(e_subst : ext_subst_sig).
Import subst weak wf.
Module e_invert := ext_invert e_subst.
Import e_invert.
Module red := ext_red e_invert.
Import red.
Module red_one := ext_red_one e_invert.
Import red_one.
Module invert := fc_invert wf weak subst.
Module unique := fc_unique wf subst.
Import invert unique.
Set Bullet Behavior "Strict Subproofs".
Set Implicit Arguments.
(* This version is just for "head reduction."
*)
Lemma open_a_Conv : forall a b g,
open_tm_wrt_tm (a_Conv a g) b =
a_Conv (open_tm_wrt_tm a b) (open_co_wrt_tm g b).
intros.
unfold open_tm_wrt_tm. simpl. auto.
Qed.
Lemma open_a_Conv_co : forall a b g,
open_tm_wrt_co (a_Conv a g) b =
a_Conv (open_tm_wrt_co a b) (open_co_wrt_co g b).
intros.
unfold open_tm_wrt_co. simpl. auto.
Qed.
(* Helper tactic for below. Solves lc_tm goals using hypotheses from
the annotated language. Perhaps it is useful elsewhere? *)
Ltac lc_erase_hyp :=
match goal with
| H : AnnTyping ?G ?a ?A0 |- lc_tm (erase_tm ?a) => eapply lc_erase; apply (AnnTyping_lc H)
| H : AnnTyping ?G ?a ?A0 |- lc_tm ?a => apply (AnnTyping_lc1 H)
| H : lc_tm ?a |- lc_tm (erase ?a) => eapply lc_erase; eauto
| H : lc_tm (a_Abs ?r ?a ?b) |- lc_tm ?c => apply lc_erase in H; simpl in H; auto
| H : lc_tm (a_CAbs ?a ?b) |- lc_tm ?c => apply lc_erase in H; simpl in H; auto
end.
Lemma binds_toplevel: forall F a A,
binds F (Ax a A) an_toplevel ->
binds F (Ax (erase a) (erase A)) toplevel.
Proof.
intros.
unfold toplevel. unfold erase_sig.
eapply binds_map with (f:= erase_csort) in H.
auto.
Qed.
Ltac do_rho :=
match goal with
H : ∀ x : atom, x `notin` ?L → RhoCheck Irrel x (erase_tm (open_tm_wrt_tm ?b (a_Var_f x))) |-
?x `notin` fv_tm_tm_tm (open_tm_wrt_tm (erase ?b) (a_Var_f ?x)) =>
let h := fresh in
let F := fresh in
assert (F : x `notin` L); auto;
move: (H x F) => h; inversion h; subst;
replace (a_Var_f x) with (erase (a_Var_f x)); auto;
rewrite open_tm_erase_tm; auto
end.
(* A specialized version of eauto that only uses the most common
lc lemmas to cut down the search space. *)
Ltac eauto_lc := simpl; eauto using AnnTyping_lc1, Value_lc,
AnnDefEq_lc3, AnnPropWff_lc.
(* We need to know that the term type checks. But if it does, our annotated
operational semantics corresponds with reduction_in_one. *)
Lemma head_reduction_in_one : forall G a b,
head_reduction G a b -> forall A, AnnTyping G a A ->
reduction_in_one (erase a) (erase b) \/ erase a = erase b.
Proof.
move: lc_erase => [lc_er_tm _] G a b H.
induction H; intros AA TT ; inversion TT; try (simpl; eauto).
- destruct rho.
destruct (IHhead_reduction _ H6); subst; simpl.
left. eauto. simpl in H8. rewrite H8. eauto.
destruct (IHhead_reduction _ H6); subst; simpl.
left. eauto. simpl in H8. rewrite H8. eauto.
- subst. destruct rho; left; simpl_erase.
++ eapply E_AppAbs; eauto using lc_er_tm.
eapply Value_lc in H0. lc_erase_hyp.
++ inversion H6; clear H6; subst.
pose EB := erase w.
pick fresh x.
rewrite (tm_subst_tm_tm_intro x); auto using fv_tm_erase_tm.
rewrite tm_subst_tm_tm_fresh_eq.
rewrite -(tm_subst_tm_tm_fresh_eq (open_tm_wrt_tm (erase w) (a_Var_f x)) a_Bullet x).
rewrite -tm_subst_tm_tm_intro; eauto.
econstructor. auto.
eapply Value_erase in H0. auto.
do_rho.
do_rho.
- subst.
destruct (IHhead_reduction _ H4); simpl.
eauto.
simpl in H1. rewrite H1.
eauto.
- subst. left. autorewcs.
erewrite <- open_co_erase_tm2.
econstructor. apply lc_er_tm in H0. eauto.
- subst.
pick fresh x.
edestruct (H1 x); eauto.
left. apply E_AbsTerm_exists with (x:=x).
eauto using fv_tm_erase_tm.
rewrite <- open_tm_erase_tm in H2.
rewrite <- open_tm_erase_tm in H2.
simpl in H2. eauto.
right. f_equal.
move: (H9 x ltac:(auto)) => h0. inversion h0. subst.
rewrite <- open_tm_erase_tm in H2.
rewrite <- open_tm_erase_tm in H2.
simpl in H2.
apply open_tm_wrt_tm_inj in H2.
auto.
eauto using fv_tm_erase_tm.
eauto using fv_tm_erase_tm.
- left.
assert (Ax a A = Ax a0 AA).
{ eapply binds_unique; eauto. apply uniq_an_toplevel. } inversion H6. subst.
apply binds_toplevel in H.
eauto.
- subst. destruct rho.
simpl. eauto.
simpl. eauto.
Qed.
(* We need to know that the term type checks. But if it does, our annotated
operational semantics corresponds with parallel reduction. *)
Lemma head_reduction_erased : forall G a b, head_reduction G a b ->
forall A, AnnTyping G a A -> Par G (dom G) (erase a) (erase b).
Proof.
intros G a b H.
induction H; intros AA TT ; inversion TT; try (simpl; econstructor; eauto).
+ destruct rho; simpl. econstructor; eauto. econstructor.
eapply lc_erase. eapply AnnTyping_lc with (A := A). eauto.
econstructor; eauto.
+ destruct rho; simpl_erase.
econstructor.
econstructor. apply Value_lc in H0. lc_erase_hyp.
econstructor. apply Value_lc in H0. lc_erase_hyp.
match goal with
H : AnnTyping ?G (a_Abs Irrel ?A ?b) (a_Pi Irrel ?A0 ?B) |- _ => inversion H; clear H end. subst.
pose EB := (erase w).
pick fresh x.
rewrite (tm_subst_tm_tm_intro x); auto using fv_tm_erase_tm.
rewrite tm_subst_tm_tm_fresh_eq.
rewrite -(tm_subst_tm_tm_fresh_eq (open_tm_wrt_tm (erase w) (a_Var_f x)) a_Bullet x).
rewrite -tm_subst_tm_tm_intro; eauto.
econstructor. econstructor. apply Value_lc in H0.
match goal with H : lc_tm (a_Abs Irrel ?A0 ?b) |-
lc_tm (a_UAbs Irrel (erase ?b)) => eapply lc_erase in H; simpl in H; auto end.
do_rho.
do_rho.
+ subst. simpl.
autorewcs. rewrite -(open_co_erase_tm2 _ _ g_Triv).
econstructor. econstructor. lc_erase_hyp.
+ intros.
assert (x `notin` L \u L0). eapply H10.
replace (a_Var_f x) with (erase (a_Var_f x)); auto.
rewrite open_tm_erase_tm.
rewrite open_tm_erase_tm.
eapply context_Par_irrelevance; eauto.
+ unfold toplevel. unfold erase_sig.
apply binds_map with (f := erase_csort) in H.
simpl in H.
eauto.
+ simpl. eauto.
+ match goal with
H : AnnTyping ?G (a_Conv ?v ?g1) ?A |- lc_tm (erase_tm ?v) =>
inversion H end.
lc_erase_hyp.
+ destruct rho; subst; simpl; eauto using lc_erase.
econstructor. eapply AnnTyping_lc1 in TT. eapply lc_tm_erase in TT. eauto.
econstructor. eapply AnnTyping_lc1 in TT. eapply lc_tm_erase in TT. eauto.
+ eapply AnnTyping_lc1 in TT. eapply lc_tm_erase in TT. eauto.
Qed.
Lemma preservation : forall G a A, AnnTyping G a A -> forall a', head_reduction G a a' -> AnnTyping G a' A.
Proof.
intros G a A H. induction H.
- intros. inversion H0.
- intros. inversion H1.
- intros. inversion H2; subst.
- intros. inversion H3. subst.
pick fresh x and apply An_Abs; eauto 3.
have RC: RhoCheck Irrel x (erase_tm (open_tm_wrt_tm a (a_Var_f x))); eauto.
inversion RC. subst.
have HR: head_reduction ([(x, Tm A)] ++ G) (open_tm_wrt_tm a (a_Var_f x))
(open_tm_wrt_tm b' (a_Var_f x)); eauto.
have Ta: AnnTyping ([(x, Tm A)] ++ G) (open_tm_wrt_tm b' (a_Var_f x))
(open_tm_wrt_tm B (a_Var_f x)); eauto.
constructor.
eapply Par_fv_preservation; eauto.
eapply head_reduction_erased; eauto.
- (* application case *)
intros. inversion H1; subst.
+ eauto.
+ inversion H. subst.
pick fresh x.
rewrite (tm_subst_tm_tm_intro x); auto.
rewrite (tm_subst_tm_tm_intro x B); auto.
eapply AnnTyping_tm_subst; eauto.
+ (* Push case *)
inversion H. subst. resolve_unique_subst.
move: (AnnDefEq_regularity H7) => [C1 [C2 [g' hyps]]]. split_hyp.
invert_syntactic_equality.
inversion H2. inversion H6. subst.
eapply An_Conv; eauto.
eapply An_PiSnd; eauto.
eapply An_EraseEq; eauto.
eapply AnnTyping_tm_subst_nondep; eauto.
- intros. inversion H2; subst.
+ eauto.
+ inversion H. subst.
econstructor; eauto 2.
eapply An_Trans with (a1 := A); eauto 2 using AnnTyping_regularity.
eapply An_Refl; eauto with ctx_wff.
- intros. inversion H2.
- intros. inversion H2.
- intros. inversion H1; subst.
+ eauto.
+ inversion H; subst.
pick fresh c.
rewrite (co_subst_co_tm_intro c); auto.
rewrite (co_subst_co_tm_intro c B); auto.
eapply AnnTyping_co_subst; eauto.
+ (* CPush case *)
inversion H. subst. resolve_unique_subst.
move: (AnnDefEq_regularity H5) => [C1 [C2 [g' hyps]]]. split_hyp.
invert_syntactic_equality.
inversion H2. inversion H7. subst. destruct phi1.
eapply An_Conv; eauto.
eapply AnnTyping_co_subst_nondep; eauto.
- move=> a' hr.
inversion hr.
- move=> a' hr.
inversion hr. subst.
assert (Ax a A = Ax a' A0).
{ eapply binds_unique; eauto. apply uniq_an_toplevel. }
inversion H2. subst. clear H2. clear H0.
apply an_toplevel_closed in H4.
eapply AnnTyping_weakening with (F:=nil)(G:=nil)(E:=G) in H4; eauto.
simpl in H4.
rewrite app_nil_r in H4.
auto.
rewrite app_nil_r. simpl. auto.
Qed. (* preservation *)
End fc_preservation.
|
\vssub
\subsubsection{~Second-order scheme (UNO)}
\opthead{UNO}{Met Office}{J.-G. Li}
\noindent
The UNO scheme for the directional $\theta$-space is identical to the regular
grid one assuming that the directional bins are regularly spaced. For the
\emph{k}-space, however, the UNO scheme uses its irregular version, which
uses local gradients instead of differences to estimate wave action value at
the mid-flux point for the cell face between spectral bin \emph{i}-1 and
\emph{i}, that is:
\begin{equation}
N_{i-}^{*}=N_{c}+sign\left(N_{d}-N_{c}\right)\frac{\left(\Delta
k_{c}-|\dot{k}_{i-}|\Delta
t\right)}{2}\min\left(|\frac{N_{u}-N_{c}}{k_{u}-k_{c}}|,|\frac{N_{c}-N_{d}}{k_{c}-k_{d}}|\right)
\:\:\:,
\label{eq:UNO2irregular}
\end{equation}
\noindent
where \emph{i}- is the wave number \emph{k} bin index; the subscripts
\emph{u}, \emph{c} and \emph{d} indicate the \emph{upstream, central} and
\emph{downstream} cells, respectively, relative to the given \emph{i}- face
velocity $\dot{k}_{i-}$; $k_{c}$ is the central bin wave number and $\Delta
k_{c}$ is the central bin widith. Details of the irregular grid UNO scheme are
given in \cite{art:Li08}.
Boundary conditions for the $\theta$-space is the natural periodic
condition. For the \emph{k}-space, two more zero spectral bins are added to
each end of the wave spectral domain as the UNO scheme is 2nd order in
accuracy.
|
/* movstat/test_minmax.c
*
* Copyright (C) 2018 Patrick Alken
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <gsl/gsl_math.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_test.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_movstat.h>
/* compute filtered data by explicitely constructing window and finding min/max */
int
slow_minmax(const gsl_movstat_end_t etype, const gsl_vector * x, gsl_vector * y_min, gsl_vector * y_max,
const int H, const int J)
{
const size_t n = x->size;
const int K = H + J + 1;
double *window = malloc(K * sizeof(double));
size_t i;
for (i = 0; i < n; ++i)
{
size_t wsize = gsl_movstat_fill(etype, x, i, H, J, window);
gsl_vector_view v = gsl_vector_view_array(window, wsize);
double min, max;
gsl_vector_minmax(&v.vector, &min, &max);
gsl_vector_set(y_min, i, min);
gsl_vector_set(y_max, i, max);
}
free(window);
return GSL_SUCCESS;
}
static double
func_min(const size_t n, double x[], void * params)
{
gsl_vector_view v = gsl_vector_view_array(x, n);
(void) params;
return gsl_vector_min(&v.vector);
}
static double
func_max(const size_t n, double x[], void * params)
{
gsl_vector_view v = gsl_vector_view_array(x, n);
(void) params;
return gsl_vector_max(&v.vector);
}
static void
test_minmax_x(const double tol, const gsl_vector * x, const int H, const int J,
const gsl_movstat_end_t endtype, const char * desc)
{
const size_t n = x->size;
gsl_vector * u_min = gsl_vector_alloc(n);
gsl_vector * y_min = gsl_vector_alloc(n);
gsl_vector * z_min = gsl_vector_alloc(n);
gsl_vector * u_max = gsl_vector_alloc(n);
gsl_vector * y_max = gsl_vector_alloc(n);
gsl_vector * z_max = gsl_vector_alloc(n);
gsl_movstat_workspace * w = gsl_movstat_alloc2(H, J);
gsl_movstat_function F1, F2;
char buf[2048];
F1.function = func_min;
F1.params = NULL;
F2.function = func_max;
F2.params = NULL;
/* compute moving min/max */
gsl_movstat_min(endtype, x, u_min, w);
gsl_movstat_max(endtype, x, u_max, w);
gsl_movstat_minmax(endtype, x, y_min, y_max, w);
/* compute moving min/max with slow brute force method */
slow_minmax(endtype, x, z_min, z_max, H, J);
sprintf(buf, "test_minmax: %s min endtype=%d n=%zu H=%d J=%d", desc, endtype, n, H, J);
compare_vectors(tol, u_min, z_min, buf);
sprintf(buf, "test_minmax: %s max endtype=%d n=%zu H=%d J=%d", desc, endtype, n, H, J);
compare_vectors(tol, u_max, z_max, buf);
sprintf(buf, "test_minmax: %s minmax(minimum) endtype=%d n=%zu H=%d J=%d", desc, endtype, n, H, J);
compare_vectors(tol, y_min, z_min, buf);
sprintf(buf, "test_minmax: %s minmax(maximum) endtype=%d n=%zu H=%d J=%d", desc, endtype, n, H, J);
compare_vectors(tol, y_max, z_max, buf);
/* in-place tests */
gsl_vector_memcpy(u_min, x);
gsl_vector_memcpy(u_max, x);
gsl_movstat_min(endtype, u_min, u_min, w);
gsl_movstat_max(endtype, u_max, u_max, w);
sprintf(buf, "test_minmax: %s in-place min endtype=%d n=%zu H=%d J=%d", desc, endtype, n, H, J);
compare_vectors(tol, u_min, z_min, buf);
sprintf(buf, "test_minmax: %s in-place max endtype=%d n=%zu H=%d J=%d", desc, endtype, n, H, J);
compare_vectors(tol, u_max, z_max, buf);
/* user-defined function tests */
gsl_movstat_apply(endtype, &F1, x, z_min, w);
sprintf(buf, "n=%zu H=%d J=%d endtype=%u min user", n, H, J, endtype);
compare_vectors(tol, z_min, y_min, buf);
gsl_movstat_apply(endtype, &F2, x, z_max, w);
sprintf(buf, "n=%zu H=%d J=%d endtype=%u max user", n, H, J, endtype);
compare_vectors(tol, z_max, y_max, buf);
gsl_vector_free(u_min);
gsl_vector_free(y_min);
gsl_vector_free(z_min);
gsl_vector_free(u_max);
gsl_vector_free(y_max);
gsl_vector_free(z_max);
gsl_movstat_free(w);
}
/* test alternating sequence [a,b,a,b,...] input */
static void
test_minmax_alt(const double tol, const size_t n, const int H, const int J,
const gsl_movstat_end_t endtype)
{
const double a = 5.0;
const double b = -5.0;
gsl_vector * x = gsl_vector_alloc(n);
size_t i;
for (i = 0; i < n; ++i)
{
if (i % 2 == 0)
gsl_vector_set(x, i, a);
else
gsl_vector_set(x, i, b);
}
test_minmax_x(tol, x, H, J, endtype, "alternating");
gsl_vector_free(x);
}
/* test noisy sine wave input */
static void
test_minmax_sine(const double tol, const size_t n, const int H, const int J,
const gsl_movstat_end_t endtype, gsl_rng * rng_p)
{
gsl_vector * x = gsl_vector_alloc(n);
/* construct noisy sine signal */
test_noisy_sine(0.5, x, rng_p);
test_minmax_x(tol, x, H, J, endtype, "noisy_sine");
gsl_vector_free(x);
}
/* test random input */
static void
test_minmax_random(const double tol, const size_t n, const int H, const int J,
const gsl_movstat_end_t endtype, gsl_rng * rng_p)
{
gsl_vector * x = gsl_vector_alloc(n);
/* construct random input signal */
random_vector(x, rng_p);
test_minmax_x(tol, x, H, J, endtype, "random");
gsl_vector_free(x);
}
static void
test_minmax(gsl_rng * rng_p)
{
/* alternating input */
test_minmax_alt(GSL_DBL_EPSILON, 1000, 7, 7, GSL_MOVSTAT_END_PADZERO);
test_minmax_alt(GSL_DBL_EPSILON, 1000, 5, 2, GSL_MOVSTAT_END_PADZERO);
test_minmax_alt(GSL_DBL_EPSILON, 500, 1, 3, GSL_MOVSTAT_END_PADZERO);
test_minmax_alt(GSL_DBL_EPSILON, 20, 50, 10, GSL_MOVSTAT_END_PADZERO);
test_minmax_alt(GSL_DBL_EPSILON, 20, 10, 50, GSL_MOVSTAT_END_PADZERO);
/* noisy sine wave input */
test_minmax_sine(GSL_DBL_EPSILON, 1000, 5, 7, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 2000, 0, 2, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 500, 3, 0, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 20, 50, 50, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 20, 10, 50, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 20, 50, 10, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 500, 5, 7, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 1000, 10, 20, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 1000, 3, 3, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 20, 50, 50, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 20, 10, 50, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 20, 50, 10, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 500, 5, 7, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 1000, 10, 20, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 1000, 3, 3, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 1000, 30, 5, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 1000, 5, 30, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 20, 50, 50, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 20, 10, 50, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_sine(GSL_DBL_EPSILON, 20, 50, 10, GSL_MOVSTAT_END_TRUNCATE, rng_p);
/* random input */
test_minmax_random(GSL_DBL_EPSILON, 1000, 0, 0, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 1000, 5, 7, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 2000, 0, 2, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 500, 3, 0, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 500, 10, 5, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 500, 5, 10, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 20, 50, 50, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 20, 10, 50, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 20, 50, 10, GSL_MOVSTAT_END_PADZERO, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 1000, 0, 0, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 1000, 5, 7, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 2000, 0, 2, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 500, 3, 0, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 500, 10, 5, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 500, 5, 10, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 20, 50, 50, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 20, 10, 50, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 20, 50, 10, GSL_MOVSTAT_END_PADVALUE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 1000, 0, 0, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 1000, 5, 7, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 2000, 0, 2, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 500, 3, 0, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 500, 10, 5, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 500, 5, 10, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 20, 50, 50, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 20, 10, 50, GSL_MOVSTAT_END_TRUNCATE, rng_p);
test_minmax_random(GSL_DBL_EPSILON, 20, 50, 10, GSL_MOVSTAT_END_TRUNCATE, rng_p);
}
|
(* Title: HOL/Auth/flash_data_cub_lemma_on_inv__156.thy
Author: Yongjian Li and Kaiqiang Duan, State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences
Copyright 2016 State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences
*)
header{*The flash_data_cub Protocol Case Study*}
theory flash_data_cub_lemma_on_inv__156 imports flash_data_cub_base
begin
section{*All lemmas on causal relation between inv__156 and some rule r*}
lemma n_PI_Remote_GetVsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_PI_Remote_Get src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_PI_Remote_Get src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_PI_Local_Get_PutVsinv__156:
assumes a1: "(r=n_PI_Local_Get_Put )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "?P3 s"
apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Pending'')) (Const false)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_GetX))) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))))" in exI, auto) done
then show "invHoldForRule s f r (invariants N)" by auto
qed
lemma n_PI_Remote_GetXVsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_PI_Remote_GetX src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_PI_Remote_GetX src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_PI_Local_GetX_PutX_HeadVld__part__0Vsinv__156:
assumes a1: "(r=n_PI_Local_GetX_PutX_HeadVld__part__0 N )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "?P3 s"
apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Pending'')) (Const false)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_GetX))) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))))" in exI, auto) done
then show "invHoldForRule s f r (invariants N)" by auto
qed
lemma n_PI_Local_GetX_PutX_HeadVld__part__1Vsinv__156:
assumes a1: "(r=n_PI_Local_GetX_PutX_HeadVld__part__1 N )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "?P3 s"
apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Pending'')) (Const false)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_GetX))) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))))" in exI, auto) done
then show "invHoldForRule s f r (invariants N)" by auto
qed
lemma n_PI_Local_GetX_PutX__part__0Vsinv__156:
assumes a1: "(r=n_PI_Local_GetX_PutX__part__0 )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "?P3 s"
apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Pending'')) (Const false)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_GetX))) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))))" in exI, auto) done
then show "invHoldForRule s f r (invariants N)" by auto
qed
lemma n_PI_Local_GetX_PutX__part__1Vsinv__156:
assumes a1: "(r=n_PI_Local_GetX_PutX__part__1 )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "?P3 s"
apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Pending'')) (Const false)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_GetX))) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))))" in exI, auto) done
then show "invHoldForRule s f r (invariants N)" by auto
qed
lemma n_PI_Local_PutXVsinv__156:
assumes a1: "(r=n_PI_Local_PutX )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "((formEval (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Pending'')) (Const true)) s))\<or>((formEval (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Pending'')) (Const true))) s))" by auto
moreover {
assume c1: "((formEval (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Pending'')) (Const true)) s))"
have "?P2 s"
proof(cut_tac a1 a2 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Pending'')) (Const true))) s))"
have "?P1 s"
proof(cut_tac a1 a2 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_PI_Local_ReplaceVsinv__156:
assumes a1: "(r=n_PI_Local_Replace )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "?P1 s"
proof(cut_tac a1 a2 , auto) qed
then show "invHoldForRule s f r (invariants N)" by auto
qed
lemma n_NI_NakVsinv__156:
assumes a1: "(\<exists> dst. dst\<le>N\<and>r=n_NI_Nak dst)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain dst where a1:"dst\<le>N\<and>r=n_NI_Nak dst" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(dst=p__Inv4)\<or>(dst~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(dst=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(dst~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_Get_Nak__part__0Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_Get_Nak__part__0 src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_Get_Nak__part__0 src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_Get_Nak__part__1Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_Get_Nak__part__1 src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_Get_Nak__part__1 src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_Get_Nak__part__2Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_Get_Nak__part__2 src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_Get_Nak__part__2 src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_Get_Get__part__0Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_Get_Get__part__0 src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_Get_Get__part__0 src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_Get_Get__part__1Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_Get_Get__part__1 src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_Get_Get__part__1 src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_Get_Put_HeadVsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_Get_Put_Head N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_Get_Put_Head N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_Get_PutVsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_Get_Put src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_Get_Put src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_Get_Put_DirtyVsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_Get_Put_Dirty src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_Get_Put_Dirty src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Remote_Get_NakVsinv__156:
assumes a1: "(\<exists> src dst. src\<le>N\<and>dst\<le>N\<and>src~=dst\<and>r=n_NI_Remote_Get_Nak src dst)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src dst where a1:"src\<le>N\<and>dst\<le>N\<and>src~=dst\<and>r=n_NI_Remote_Get_Nak src dst" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4\<and>dst~=p__Inv4)\<or>(src~=p__Inv4\<and>dst=p__Inv4)\<or>(src~=p__Inv4\<and>dst~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4\<and>dst~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>dst=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>dst~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Remote_Get_PutVsinv__156:
assumes a1: "(\<exists> src dst. src\<le>N\<and>dst\<le>N\<and>src~=dst\<and>r=n_NI_Remote_Get_Put src dst)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src dst where a1:"src\<le>N\<and>dst\<le>N\<and>src~=dst\<and>r=n_NI_Remote_Get_Put src dst" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4\<and>dst~=p__Inv4)\<or>(src~=p__Inv4\<and>dst=p__Inv4)\<or>(src~=p__Inv4\<and>dst~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4\<and>dst~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>dst=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>dst~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_Nak__part__0Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_Nak__part__0 src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_Nak__part__0 src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_Nak__part__1Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_Nak__part__1 src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_Nak__part__1 src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_Nak__part__2Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_Nak__part__2 src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_Nak__part__2 src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_GetX__part__0Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_GetX__part__0 src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_GetX__part__0 src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_GetX__part__1Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_GetX__part__1 src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_GetX__part__1 src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_1Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_1 N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_1 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_2Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_2 N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_2 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_3Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_3 N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_3 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_4Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_4 N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_4 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_5Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_5 N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_5 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_6Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_6 N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_6 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_7__part__0Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_7__part__0 N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_7__part__0 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_7__part__1Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_7__part__1 N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_7__part__1 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_7_NODE_Get__part__0Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_7_NODE_Get__part__0 N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_7_NODE_Get__part__0 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_7_NODE_Get__part__1Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_7_NODE_Get__part__1 N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_7_NODE_Get__part__1 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_8_HomeVsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_8_Home N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_8_Home N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_8_Home_NODE_GetVsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_8_Home_NODE_Get N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_8_Home_NODE_Get N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_8Vsinv__156:
assumes a1: "(\<exists> src pp. src\<le>N\<and>pp\<le>N\<and>src~=pp\<and>r=n_NI_Local_GetX_PutX_8 N src pp)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src pp where a1:"src\<le>N\<and>pp\<le>N\<and>src~=pp\<and>r=n_NI_Local_GetX_PutX_8 N src pp" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4\<and>pp~=p__Inv4)\<or>(src~=p__Inv4\<and>pp=p__Inv4)\<or>(src~=p__Inv4\<and>pp~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4\<and>pp~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>pp=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>pp~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_8_NODE_GetVsinv__156:
assumes a1: "(\<exists> src pp. src\<le>N\<and>pp\<le>N\<and>src~=pp\<and>r=n_NI_Local_GetX_PutX_8_NODE_Get N src pp)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src pp where a1:"src\<le>N\<and>pp\<le>N\<and>src~=pp\<and>r=n_NI_Local_GetX_PutX_8_NODE_Get N src pp" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4\<and>pp~=p__Inv4)\<or>(src~=p__Inv4\<and>pp=p__Inv4)\<or>(src~=p__Inv4\<and>pp~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4\<and>pp~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>pp=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>pp~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_9__part__0Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_9__part__0 N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_9__part__0 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_9__part__1Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_9__part__1 N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_9__part__1 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_10_HomeVsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_10_Home N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_10_Home N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_10Vsinv__156:
assumes a1: "(\<exists> src pp. src\<le>N\<and>pp\<le>N\<and>src~=pp\<and>r=n_NI_Local_GetX_PutX_10 N src pp)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src pp where a1:"src\<le>N\<and>pp\<le>N\<and>src~=pp\<and>r=n_NI_Local_GetX_PutX_10 N src pp" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4\<and>pp~=p__Inv4)\<or>(src~=p__Inv4\<and>pp=p__Inv4)\<or>(src~=p__Inv4\<and>pp~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4\<and>pp~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>pp=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>pp~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_11Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_Local_GetX_PutX_11 N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_Local_GetX_PutX_11 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Remote_GetX_NakVsinv__156:
assumes a1: "(\<exists> src dst. src\<le>N\<and>dst\<le>N\<and>src~=dst\<and>r=n_NI_Remote_GetX_Nak src dst)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src dst where a1:"src\<le>N\<and>dst\<le>N\<and>src~=dst\<and>r=n_NI_Remote_GetX_Nak src dst" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4\<and>dst~=p__Inv4)\<or>(src~=p__Inv4\<and>dst=p__Inv4)\<or>(src~=p__Inv4\<and>dst~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4\<and>dst~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>dst=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>dst~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Remote_GetX_PutXVsinv__156:
assumes a1: "(\<exists> src dst. src\<le>N\<and>dst\<le>N\<and>src~=dst\<and>r=n_NI_Remote_GetX_PutX src dst)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src dst where a1:"src\<le>N\<and>dst\<le>N\<and>src~=dst\<and>r=n_NI_Remote_GetX_PutX src dst" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4\<and>dst~=p__Inv4)\<or>(src~=p__Inv4\<and>dst=p__Inv4)\<or>(src~=p__Inv4\<and>dst~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4\<and>dst~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>dst=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>dst~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_PutVsinv__156:
assumes a1: "(r=n_NI_Local_Put )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "?P3 s"
apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''HomeUniMsg'') ''Cmd'')) (Const UNI_Put)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_GetX))) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))))" in exI, auto) done
then show "invHoldForRule s f r (invariants N)" by auto
qed
lemma n_NI_Remote_PutVsinv__156:
assumes a1: "(\<exists> dst. dst\<le>N\<and>r=n_NI_Remote_Put dst)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain dst where a1:"dst\<le>N\<and>r=n_NI_Remote_Put dst" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(dst=p__Inv4)\<or>(dst~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(dst=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(dst~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_PutXAcksDoneVsinv__156:
assumes a1: "(r=n_NI_Local_PutXAcksDone )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "?P3 s"
apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''HomeUniMsg'') ''Cmd'')) (Const UNI_PutX)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_GetX))) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))))" in exI, auto) done
then show "invHoldForRule s f r (invariants N)" by auto
qed
lemma n_NI_Remote_PutXVsinv__156:
assumes a1: "(\<exists> dst. dst\<le>N\<and>r=n_NI_Remote_PutX dst)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain dst where a1:"dst\<le>N\<and>r=n_NI_Remote_PutX dst" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(dst=p__Inv4)\<or>(dst~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(dst=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(dst~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_InvAck_1Vsinv__156:
assumes a1: "(\<exists> src. src\<le>N\<and>r=n_NI_InvAck_1 N src)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain src where a1:"src\<le>N\<and>r=n_NI_InvAck_1 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__156 p__Inv4" apply fastforce done
have "(src=p__Inv4)\<or>(src~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(src=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Remote_GetX_PutX_HomeVsinv__156:
assumes a1: "\<exists> dst. dst\<le>N\<and>r=n_NI_Remote_GetX_PutX_Home dst" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_WbVsinv__156:
assumes a1: "r=n_NI_Wb " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_StoreVsinv__156:
assumes a1: "\<exists> src data. src\<le>N\<and>data\<le>N\<and>r=n_Store src data" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_InvAck_3Vsinv__156:
assumes a1: "\<exists> src. src\<le>N\<and>r=n_NI_InvAck_3 N src" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Local_GetX_GetX__part__1Vsinv__156:
assumes a1: "r=n_PI_Local_GetX_GetX__part__1 " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Local_GetX_GetX__part__0Vsinv__156:
assumes a1: "r=n_PI_Local_GetX_GetX__part__0 " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Remote_ReplaceVsinv__156:
assumes a1: "\<exists> src. src\<le>N\<and>r=n_PI_Remote_Replace src" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_Store_HomeVsinv__156:
assumes a1: "\<exists> data. data\<le>N\<and>r=n_Store_Home data" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_InvAck_existsVsinv__156:
assumes a1: "\<exists> src pp. src\<le>N\<and>pp\<le>N\<and>src~=pp\<and>r=n_NI_InvAck_exists src pp" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Remote_PutXVsinv__156:
assumes a1: "\<exists> dst. dst\<le>N\<and>r=n_PI_Remote_PutX dst" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Remote_Get_Put_HomeVsinv__156:
assumes a1: "\<exists> dst. dst\<le>N\<and>r=n_NI_Remote_Get_Put_Home dst" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_InvVsinv__156:
assumes a1: "\<exists> dst. dst\<le>N\<and>r=n_NI_Inv dst" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_ShWbVsinv__156:
assumes a1: "r=n_NI_ShWb N " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_ReplaceVsinv__156:
assumes a1: "\<exists> src. src\<le>N\<and>r=n_NI_Replace src" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Remote_GetX_Nak_HomeVsinv__156:
assumes a1: "\<exists> dst. dst\<le>N\<and>r=n_NI_Remote_GetX_Nak_Home dst" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Remote_Get_Nak_HomeVsinv__156:
assumes a1: "\<exists> dst. dst\<le>N\<and>r=n_NI_Remote_Get_Nak_Home dst" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_InvAck_exists_HomeVsinv__156:
assumes a1: "\<exists> src. src\<le>N\<and>r=n_NI_InvAck_exists_Home src" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Replace_HomeVsinv__156:
assumes a1: "r=n_NI_Replace_Home " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Nak_ClearVsinv__156:
assumes a1: "r=n_NI_Nak_Clear " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Local_Get_GetVsinv__156:
assumes a1: "r=n_PI_Local_Get_Get " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Nak_HomeVsinv__156:
assumes a1: "r=n_NI_Nak_Home " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_InvAck_2Vsinv__156:
assumes a1: "\<exists> src. src\<le>N\<and>r=n_NI_InvAck_2 N src" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_FAckVsinv__156:
assumes a1: "r=n_NI_FAck " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__156 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
end
|
module Optimisation.StaticProcessing.StaticTransformer
import Core.Context
import CairoCode.CairoCode
import CairoCode.CairoCodeUtils
import Data.List
import Data.SortedSet
import Data.SortedMap
import Primitives.Primitives
import Primitives.Externals
import Primitives.Common
import Optimisation.StaticProcessing.InstructionDeduplication
import CairoCode.Traversal.Base
import CairoCode.Traversal.ValueTracker
import CairoCode.Traversal.Composition
import Optimisation.StaticProcessing.StaticTracker
import Utils.Helpers
import Utils.Lens
import Debug.Trace
%hide Prelude.toList
record LocalStaticOptimState where
constructor MkLocalStaticOptimState
dedupState : TrackerState
bindings : ScopedBindings StaticInfo
elimDepth : Int
-- Lenses for leaner and more readable main definitions
dedupStateLens : Lens LocalStaticOptimState TrackerState
dedupStateLens = MkLens dedupState (\ts,fn => {dedupState $= fn} ts)
elimDepthLens : Lens LocalStaticOptimState Int
elimDepthLens = MkLens elimDepth (\ts,fn => {elimDepth $= fn} ts)
bindingsLens : Lens LocalStaticOptimState (ScopedBindings StaticInfo)
bindingsLens = MkLens bindings (\ts,fn => {bindings $= fn} ts)
inlineError : List StaticInfo -> List CairoReg -> Lazy (List (InstVisit CairoReg)) -> Traversal LocalStaticOptimState (List (InstVisit CairoReg))
inlineError args res noErrorTrav = if isCons errors
then pure $ map (\r => VisitError r consolidateErrors) res
else pure noErrorTrav
where extractError : StaticInfo -> List String
extractError (MKStaticInfo _ (Error err)) = [err]
extractError _ = []
errors : List String
errors = args >>= extractError
consolidateErrors : String
consolidateErrors = foldl (\acc,err => acc ++ " " ++ err) "" errors
-- Because of assigns, repackings etc.. we may end up with multiple registers storing the same value
-- This function chooses one. It tries to choose the one least likely to be eliminated (or one that does not cost Insts if not eliminated)
-- Note: This assumes that list is sorted according to lifetime (which is default for CairoReg in CairoCode)
chooseBestReg : List CairoReg -> CairoReg
chooseBestReg (x::Nil) = x -- This is the case most likely to happen (only one candidate)
-- Note: If sort changes implement this differently (that is why we treated this case seperately)
chooseBestReg (x::xs) = x
-- Note: This case is only used in Projection, everywhere else this would mean a mistake in the tracker
chooseBestReg Nil = Eliminated
export
resolveInfToReg : StaticInfo -> CairoReg
resolveInfToReg inf = result $ extractSingleConstant inf
where result : Maybe CairoConst -> CairoReg
result Nothing = chooseBestReg $ toList (inf.sources)
result (Just c) = Const c
manifestRegister : CairoReg -> CairoReg -> InstVisit CairoReg
manifestRegister res (Const c) = VisitMkConstant res c
manifestRegister res Eliminated = VisitError res "CanNotManifestEliminatedRegister"
manifestRegister res reg = VisitAssign res reg
manifestConstant : CairoReg -> Maybe CairoConst -> InstVisit CairoReg
manifestConstant res Nothing = VisitError res "UndefinedConstantOperation"
manifestConstant res (Just c) = VisitMkConstant res c
canManifestEvalRes : EvalRes -> Bool
canManifestEvalRes (Failure _) = True
canManifestEvalRes (NewValue val) = isJust $ extractSingleConstant $ fromValueInfo val
canManifestEvalRes (ArgValue _) = True
manifestEvalRes : CairoReg -> EvalRes -> List StaticInfo -> InstVisit CairoReg
manifestEvalRes reg (Failure s) _ = VisitError reg "UndefinedPrimitiveOperation"
manifestEvalRes reg (NewValue val) _ = (manifestConstant reg) $ extractSingleConstant $ fromValueInfo val
manifestEvalRes reg (ArgValue Z) (x::xs) = VisitAssign reg (resolveInfToReg x)
manifestEvalRes reg (ArgValue (S rem)) (x::xs) = manifestEvalRes reg (ArgValue rem) xs
manifestEvalRes _ _ _ = assert_total $ idris_crash "can not process eval res"
reassignUnusedLinearImplicits : SortedSet LinearImplicit -> SortedMap LinearImplicit (StaticInfo, CairoReg) -> List (InstVisit CairoReg)
reassignUnusedLinearImplicits usedLinearImplicits availableLinearImplicits = map (\(_,(f,t)) => VisitAssign t (resolveInfToReg f)) unusedLinearImplicits
where unusedLinearImplicits : List (LinearImplicit, (StaticInfo, CairoReg))
unusedLinearImplicits = filter (\(i,_) => not (contains i usedLinearImplicits)) (toList availableLinearImplicits)
export
resolveLinearImplicits : SortedMap LinearImplicit (StaticInfo, CairoReg) -> SortedMap LinearImplicit (CairoReg, CairoReg)
resolveLinearImplicits linImpls = mapValueMap (\(f,t) => (resolveInfToReg f,t)) linImpls
canEliminate : Traversal LocalStaticOptimState Bool
canEliminate = map (/=0) (readStateL elimDepthLens)
eliminateBranch : Traversal LocalStaticOptimState (Maybe (List (InstVisit CairoReg)))
eliminateBranch = map (\_ => Just []) (updateStateL elimDepthLens (+1))
keepBranch : InstVisit CairoReg -> Traversal LocalStaticOptimState (Maybe (List (InstVisit CairoReg)))
keepBranch inst = pure $ Just [inst]
forwardBranchInst : Traversal LocalStaticOptimState (Maybe (List (InstVisit CairoReg)))
forwardBranchInst = pure Nothing
caseBindings : Traversal LocalStaticOptimState (Maybe StaticInfo)
caseBindings = composeState bindingsLens resolveCaseBinding
where resolveCaseBinding : Traversal (ScopedBindings StaticInfo) (Maybe StaticInfo)
resolveCaseBinding = case !getCaseReg of
Nothing => pure Nothing
(Just (Const c)) => pure $ Just $ MKStaticInfo (singleton $ Const c) (Const $ singleton c)
(Just reg) => getBinding reg
branchFilter : InstVisit CairoReg -> Traversal LocalStaticOptimState (Maybe (List (InstVisit CairoReg)))
branchFilter (VisitConBranch reg) = canEliminate >>= process
where process : Bool -> Traversal LocalStaticOptimState (Maybe (List (InstVisit CairoReg)))
process True = eliminateBranch
process False = forwardBranchInst
branchFilter (VisitConstBranch reg) = canEliminate >>= process
where process : Bool -> Traversal LocalStaticOptimState (Maybe (List (InstVisit CairoReg)))
process True = eliminateBranch
process False = forwardBranchInst
branchFilter VisitBranchEnd = canEliminate >>= process
where process : Bool -> Traversal LocalStaticOptimState (Maybe (List (InstVisit CairoReg)))
process True = map (\_ => Just []) (updateStateL elimDepthLens (\a => a-1))
process False = forwardBranchInst
branchFilter _ = canEliminate >>= process
where process : Bool -> Traversal LocalStaticOptimState (Maybe (List (InstVisit CairoReg)))
process True = pure $ Just []
process False = forwardBranchInst
branchEliminationDetection : InstVisit StaticInfo -> Traversal LocalStaticOptimState (Maybe (List (InstVisit CairoReg)))
branchEliminationDetection (VisitConBranch (Just t)) = case !caseBindings of
(Just (MKStaticInfo _ (Constructed ctrs))) => if isJust (lookup t ctrs) then keepBranch (VisitConBranch (Just t)) else eliminateBranch
_ => keepBranch (VisitConBranch (Just t))
branchEliminationDetection (VisitConstBranch (Just c)) = case !caseBindings of
(Just (MKStaticInfo _ (Const vals))) => if contains c vals then keepBranch (VisitConstBranch (Just c)) else eliminateBranch
_ => keepBranch (VisitConstBranch (Just c))
branchEliminationDetection (VisitConBranch Nothing) = keepBranch (VisitConBranch Nothing)
branchEliminationDetection (VisitConstBranch Nothing) = keepBranch (VisitConstBranch Nothing)
branchEliminationDetection VisitBranchEnd = keepBranch VisitBranchEnd
branchEliminationDetection _ = forwardBranchInst
constantFoldTransform : SortedMap Name CairoDef -> InstVisit StaticInfo -> Traversal LocalStaticOptimState (List (InstVisit CairoReg))
constantFoldTransform defs inst = transformer inst
where extractLinearImplicits : CairoDef -> SortedSet LinearImplicit
extractLinearImplicits (FunDef _ linImpls _ _) = fromList $ keys linImpls
extractLinearImplicits (ForeignDef info _ _) = fromList $ implicits info
implicitLookup : SortedMap Name (SortedSet LinearImplicit)
implicitLookup = mapValueMap extractLinearImplicits defs
transformer : InstVisit StaticInfo -> Traversal LocalStaticOptimState (List (InstVisit CairoReg))
transformer (VisitFunction name params impls rets) = pure [VisitFunction name params impls rets]
transformer (VisitForeignFunction name info args rets) = pure [VisitForeignFunction name info args rets]
transformer (VisitAssign res from) = inlineError [from] [res] [manifestRegister res (resolveInfToReg from)]
transformer (VisitMkCon res tag args) = inlineError args [res] inst
where repackedSrcs : List CairoReg
repackedSrcs = toList (findRepackedSrcs (resolveTag tag) args)
inst : List (InstVisit CairoReg)
inst = if isNil repackedSrcs
then [VisitMkCon res tag (map resolveInfToReg args)]
else [manifestRegister res (chooseBestReg repackedSrcs)]
transformer (VisitMkClosure res name miss args) = inlineError args [res] [VisitMkClosure res name miss (map resolveInfToReg args)]
transformer (VisitApply res linImpls (MKStaticInfo _ (Closure (Just (name, 1)) args)) arg) = inlineError allArgs [res] ((VisitCall [res] callLinearImplicits name (map resolveInfToReg allArgs))::implicitReassigns)
where allArgs : List StaticInfo
allArgs = args ++ [arg]
usedLinearImplicits : SortedSet LinearImplicit
usedLinearImplicits = fromMaybe empty (lookup name implicitLookup)
callLinearImplicits : SortedMap LinearImplicit (CairoReg, CairoReg)
callLinearImplicits = resolveLinearImplicits $ fromList $ filter (\(i,_) => contains i usedLinearImplicits) (toList $ linImpls)
implicitReassigns : List (InstVisit CairoReg)
implicitReassigns = reassignUnusedLinearImplicits usedLinearImplicits linImpls
transformer (VisitApply res linImpls (MKStaticInfo _ (Closure (Just (name, (S rem))) args)) arg) = inlineError allArgs [res] ((VisitMkClosure res name rem (map resolveInfToReg allArgs))::implicitReassigns)
where allArgs : List StaticInfo
allArgs = args ++ [arg]
implicitReassigns : List (InstVisit CairoReg)
implicitReassigns = reassignUnusedLinearImplicits empty linImpls
transformer (VisitApply res linImpls clo arg) = inlineError [clo,arg] [res] [VisitApply res (resolveLinearImplicits linImpls) (resolveInfToReg clo) (resolveInfToReg arg)]
transformer (VisitOp res linImpls fn args) = inlineError args [res] (result (evaluateConstantOp fn (map toValueInfo args)))
where result : Maybe EvalRes -> List (InstVisit CairoReg)
result (Just nRes) = if canManifestEvalRes nRes
then (manifestEvalRes res nRes args)::(reassignUnusedLinearImplicits empty linImpls)
else [VisitOp res (resolveLinearImplicits linImpls) fn (map resolveInfToReg args)]
result _ = [VisitOp res (resolveLinearImplicits linImpls) fn (map resolveInfToReg args)]
transformer (VisitCall res linImpls name args) = inlineError args res [VisitCall res (resolveLinearImplicits linImpls) name (map resolveInfToReg args)]
transformer (VisitExtprim res linImpls name args) = inlineError args res (result (externalEval name (length res) (map toValueInfo args)))
where result : Maybe (List EvalRes) -> List (InstVisit CairoReg)
result (Just nRes) = if all canManifestEvalRes nRes
then (zipWith (\reg,res => manifestEvalRes reg res args) res nRes) ++ (reassignUnusedLinearImplicits empty linImpls)
else [VisitExtprim res (resolveLinearImplicits linImpls) name (map resolveInfToReg args)]
result _ = [VisitExtprim res (resolveLinearImplicits linImpls) name (map resolveInfToReg args)]
transformer (VisitReturn res linImpls) = pure [VisitReturn (map resolveInfToReg res) (mapValueMap resolveInfToReg linImpls)]
transformer (VisitProject res arg@(MKStaticInfo _ (Constructed ctrs)) pos) = inlineError [arg] [res] (result (resolveInfToReg (extractField ctrs pos)))
where result : CairoReg -> List (InstVisit CairoReg)
result Eliminated = [VisitProject res (resolveInfToReg arg) pos]
result reg = [manifestRegister res reg]
transformer (VisitProject res arg pos) = inlineError [arg] [res] [VisitProject res (resolveInfToReg arg) pos]
transformer (VisitCase reg) = pure [VisitCase (resolveInfToReg reg)]
-- Untouched ones
transformer VisitCaseEnd = pure $ [VisitCaseEnd]
transformer (VisitNull reg) = pure $ [VisitNull reg]
transformer (VisitError reg err) = pure $ [VisitError reg err]
transformer (VisitMkConstant reg c) = pure $ [VisitMkConstant reg c]
transformer VisitEndFunction = pure $ [VisitEndFunction]
-- Covered by Branch Eliminator --
transformer (VisitConBranch t) = assert_total $ idris_crash "constantFoldTransform must be coupled with a branch hanlder"
transformer (VisitConstBranch c) = assert_total $ idris_crash "constantFoldTransform must be coupled with a branch hanlder"
transformer VisitBranchEnd = assert_total $ idris_crash "constantFoldTransform must be coupled with a branch hanlder"
{-
1. skips the instruction if it lies in an eliminated branch
2. it substitutes registers for their statically known value
3. if a branch instruction it decides if the branch is needed or not (used in 1.)
for unneeded branches the branching instruction is skipped
4. it replaces or eliminates instructions based on the static value of the used registers where possible
5. it eliminates duplicated instructions (instructions already executed earlier on the same registers)
6. for the remaining transformed instructions it statically executes them where possible to find the static values of its returns based on the static values of the inputs (for 2.)
start - value (Reg) & state -> branchFilter | case Just: - value (Reg) & state ------------------------------------------------------------------------------v
| case Nothing: - state -> valueTransformer ( staticValueTracker, transformerPipeline) - value (Reg) & state -> end
transformPipeline: start - value (StaticInfo) & state -> branchAwareFolder - state & [value (Reg)] -> for each value : instructionDeduplication - state & [value (Reg)] -> end
branchAwareFolder: start - value (StaticInfo) & state -> branchEliminationDetection | case Just: - value (Reg) & state -----------------------------------------v
| | case Nothing: - state -> constantFoldTransform - [value (Reg)] & state -> end
| - value (StaticInfo) ---------------------------------------------------------------------^
branchFilter : Skippes unused branches
instructionDeduplication : Removes duplicated instructions (same regs as inputs)
constantFoldTransform : Simplifies instruction based on static input
-}
export
localStaticOptimizeDef : List (Name, CairoDef) -> (Name, CairoDef) -> (Name, CairoDef)
localStaticOptimizeDef defs def = snd $ runVisitTransformCairoDef (transformerPipeline, initialState) def
where liftedStaticValueTracker: (v:InstVisit StaticInfo) -> Traversal LocalStaticOptimState (ValBindType v StaticInfo)
liftedStaticValueTracker inst = composeState bindingsLens (staticValueTracker inst)
branchAwareFolder : InstVisit StaticInfo -> Traversal LocalStaticOptimState (List (InstVisit CairoReg))
branchAwareFolder = fallbackTraversal branchEliminationDetection (constantFoldTransform (fromList defs))
transformPipeline : InstVisit StaticInfo -> Traversal LocalStaticOptimState (List (InstVisit CairoReg))
transformPipeline = chainedTraversal branchAwareFolder (lensTraversal dedupStateLens instructionDeduplication)
dbgDef : (Name, CairoDef) -> CairoReg -> StaticInfo
dbgDef (name, def) reg = trace "Register not bound in \{show name}: \{show reg}" (MKStaticInfo (singleton reg) Unknown)
activeBranchPipeline : InstVisit CairoReg -> Traversal LocalStaticOptimState (List (InstVisit CairoReg))
activeBranchPipeline = valueTransformer bindingsLens (dbgDef def) liftedStaticValueTracker transformPipeline
transformerPipeline : InstVisit CairoReg -> Traversal LocalStaticOptimState (List (InstVisit CairoReg))
transformerPipeline = fallbackTraversal branchFilter activeBranchPipeline
initialState : LocalStaticOptimState
initialState = MkLocalStaticOptimState initialDedupState initialTrackerState 0
public export
localStaticOptimizeDefs : List (Name, CairoDef) -> List (Name, CairoDef)
localStaticOptimizeDefs defs = map (localStaticOptimizeDef defs) defs
-- A version witch allows generified call handling --
public export
record GlobalStaticOptimState s where
constructor MkGlobalStaticOptimState
folderState : LocalStaticOptimState
globalState : s
-- Lenses for leaner and more readable main definitions
folderStateLens : Lens (GlobalStaticOptimState s) LocalStaticOptimState
folderStateLens = MkLens folderState (\ts,fn => {folderState $= fn} ts)
globalStateLens : Lens (GlobalStaticOptimState s) s
globalStateLens = MkLens globalState (\ts,fn => {globalState $= fn} ts)
public export
interface CallHandler s where
-- Binds values of function value
context : (List CairoReg, SortedMap LinearImplicit CairoReg) -> Traversal s (List StaticInfo, SortedMap LinearImplicit StaticInfo)
-- Binds returns of a function
return : List StaticInfo -> SortedMap LinearImplicit StaticInfo -> Traversal s ()
-- Extract tracked values from processed function
track : CallData -> Traversal s (List StaticInfo, SortedMap LinearImplicit StaticInfo)
-- Replace tracked function with inlined code
transform : CallData -> Traversal s (List (InstVisit CairoReg))
-- defaults (same as unmodified value Tracker)
context (params, impls) = pure (map paramInit params, mapValueMap paramInit impls)
where paramInit : CairoReg -> StaticInfo
paramInit reg = MKStaticInfo (singleton reg) Unknown
return _ _ = pure ()
track (MKCallData _ impls _ rs) = pure (map (\r => MKStaticInfo (singleton r) Unknown) rs, staticImplTracker impls)
-- todo: make a more advanced inline error based one here as default -- needs to factor out traversal
transform (MKCallData name impls args rs) = pure [VisitCall rs (resolveLinearImplicits impls) name (map resolveInfToReg args)]
callTracking : CallHandler s => CallData -> Traversal (GlobalStaticOptimState s) (List StaticInfo, SortedMap LinearImplicit StaticInfo)
callTracking callData = composeState globalStateLens (track callData)
callTransform: CallHandler s => CallData -> Traversal (GlobalStaticOptimState s) (List (InstVisit CairoReg))
callTransform callData = composeState globalStateLens (transform callData)
-- The actual generified folder (usable for global folding, inlining, specialisation, ...)
{-
Works the same as localStaticOptimizeDef. However it can customize how call instructions are treated over a CallHandler
Further it allows to collect the static values produced by return instructions over CallHandler
It introduces an additional state for the functions used in CallHandler
This allows to define recursive algorithms that follow the call graph (thus global instead of local)
-}
public export
globalStaticOptimizeDef : CallHandler s => SortedMap Name CairoDef -> s -> (Name, CairoDef) -> ((Name, CairoDef), s)
globalStaticOptimizeDef defs globalState def = extract $ runVisitTransformCairoDef (transformerPipeline, initialState) def
where bindLens : Lens (GlobalStaticOptimState s) (ScopedBindings StaticInfo)
bindLens = join folderStateLens bindingsLens
-- these just lift traversals defined on LocalStaticOptimState to work with (GlobalStaticOptimState s) by using a lense to point to the LocalStaticOptimState
liftedStaticValueTracker: (v:InstVisit StaticInfo) -> Traversal (GlobalStaticOptimState s) (ValBindType v StaticInfo)
liftedStaticValueTracker inst = composeState bindLens (staticValueTracker inst)
liftedBranchEliminatorTransform : InstVisit StaticInfo -> Traversal (GlobalStaticOptimState s) (Maybe (List (InstVisit CairoReg)))
liftedBranchEliminatorTransform inst = composeState folderStateLens (branchEliminationDetection inst)
liftedBranchFilter : InstVisit CairoReg -> Traversal (GlobalStaticOptimState s) (Maybe (List (InstVisit CairoReg)))
liftedBranchFilter inst = composeState folderStateLens (branchFilter inst)
liftedConstantFoldTransform : InstVisit StaticInfo -> Traversal (GlobalStaticOptimState s) (List (InstVisit CairoReg))
liftedConstantFoldTransform inst = composeState folderStateLens (constantFoldTransform defs inst)
-- These use the CallHandler to customize the value Tracker
-- we use explicit branching for 'customizedStaticValueTracker' because 'fallbackTraversal' has problems handling dependent type 'ValBindType v StaticInfo'
customizedStaticValueTracker : (v:InstVisit StaticInfo) -> Traversal (GlobalStaticOptimState s) (ValBindType v StaticInfo)
customizedStaticValueTracker (VisitCall rs impls name args) = callTracking (MKCallData name impls args rs)
customizedStaticValueTracker (VisitFunction _ params impls _) = composeState globalStateLens (context (params, impls))
-- Note: Putting this here is suboptimal as it requires the tracker to handle it
-- but putting it in the transform prevents transformations of returns
-- thats why its here and why we added a forwarding in the return case of the tracker
customizedStaticValueTracker (VisitReturn res impls) = composeState globalStateLens (return res impls)
customizedStaticValueTracker inst = liftedStaticValueTracker inst
-- These use the CallHandler to customize the constant Folder
-- we use explicit branching for 'customizedConstantFoldTransform' to be congruent with 'customizedStaticValueTracker'
customizedConstantFoldTransform : InstVisit StaticInfo -> Traversal (GlobalStaticOptimState s) (List (InstVisit CairoReg))
customizedConstantFoldTransform (VisitCall rs impls name args) = callTransform (MKCallData name impls args rs)
customizedConstantFoldTransform inst = liftedConstantFoldTransform inst
-- These are the same as in the local variant
branchAwareFolder : InstVisit StaticInfo -> Traversal (GlobalStaticOptimState s) (List (InstVisit CairoReg))
branchAwareFolder = fallbackTraversal liftedBranchEliminatorTransform customizedConstantFoldTransform
transformPipeline : InstVisit StaticInfo -> Traversal (GlobalStaticOptimState s) (List (InstVisit CairoReg))
transformPipeline = chainedTraversal branchAwareFolder (lensTraversal (join folderStateLens dedupStateLens) instructionDeduplication)
dbgDef : (Name, CairoDef) -> CairoReg -> StaticInfo
dbgDef (name, def) reg = trace "Register not bound in \{show name}: \{show reg}" (MKStaticInfo (singleton reg) Unknown)
activeBranchPipeline : InstVisit CairoReg -> Traversal (GlobalStaticOptimState s) (List (InstVisit CairoReg))
activeBranchPipeline = valueTransformer bindLens (dbgDef def) customizedStaticValueTracker transformPipeline
transformerPipeline : InstVisit CairoReg -> Traversal (GlobalStaticOptimState s) (List (InstVisit CairoReg))
transformerPipeline = fallbackTraversal liftedBranchFilter activeBranchPipeline
initialState : GlobalStaticOptimState s
initialState = MkGlobalStaticOptimState (MkLocalStaticOptimState initialDedupState initialTrackerState 0) globalState
-- this does extract the CallHandler state from the GlobalStaticOptimState
extract : (GlobalStaticOptimState s, (Name, CairoDef)) -> ((Name, CairoDef), s)
extract (MkGlobalStaticOptimState _ globalState, def) = (def, globalState)
|
= = = Recording and production = = =
|
#include <boost/interprocess/managed_mapped_file.hpp>
|
% JuliaCon proceedings template
\documentclass{juliacon}
\usepackage[ruled,vlined]{algorithm2e}
\setcounter{page}{1}
\keywords{landscape ecology , computational ecology, julia programming language}
\makeatletter
\newcommand{\removelatexerror}{\let\@latex@error\@gobble}
\makeatother
\begin{document}
\input{header}
\maketitle
\begin{abstract}
Connectivity across landscapes influences a wide range of conservation-relevant ecological processes, including species movements, gene flow, and the spread of wildfire, pests, and diseases. The computational demands of the next generation of connectivity models and the availability of increasingly fine grained remote sensing data drive the need for faster software for connectivity modelling. To address this, we upgraded the widely-used Circuitscape connectivity package to the Julia programming language. The Julia package, Circuitscape.jl, can now solve much larger problems up to an order of magnitude faster, with improved solvers and parallel computing features. We demonstrate scaling up to problems of size 437 million grid cells, with speedups of up to 1800\% over the previous version. These improvements increase the pace of interaction between scientists and key stakeholders, facilitating faster policy decisions.
\end{abstract}
\section{Introduction}
Connectivity models provide important insights into ecological processes that involve variation in movement or flow patterns across heterogeneous environments \cite{crooks2006}. In applied conservation, connectivity maps are incorporated into a wide range of resource evaluations and risk assessments, informing decisions on how to sustain population dynamics and genetic diversity in plant and animal populations \cite{kareiva1995connecting}, how to most effectively prevent infectious disease spread or reduce risks from wildfire \cite{gray2016applying}, and choices of where to invest in land protection or restoration to help support species range shifts under a changing climate \cite{heller2009biodiversity, littlefield2017connecting, keeley2017habitat}.
A common requirement for modeling connectivity is a gridded depiction of the landscape in which values for each cell represent some relative value of “resistance” to movement. These resistance grids are developed through several different methods, often involving iterative processes for categorizing resistance weights for different types of barriers based on expert opinion and information on species’ life histories and movement behaviors \cite{spear2010use, zeller2012estimating}. This grid can then be abstracted as a graph \cite{urban2001landscape}, providing a way to quantify ecological distance measures via graph-theoretic metrics.
The range of mathematical approaches and software tools used for modeling connectivity reflect differences in theoretical approaches, and in the underlying assumptions about how movement proceeds. The classical isolation by distance model (IBD) posits that the least cost distance across the landscape graph acts as a good proxy for ecological distance \cite{wright1943isolation}. Tools based on this approach typically identify a single “best” route between focal locations, an important result, but one that is highly dependent upon the choice of start and end points, and has limited application if one’s goal is to compare potential options for restoration or protection across a landscape with multiple habitat patches and pathways. As reviewed in \cite{dickson2019circuit}, from 2006-08, three seminal papers by the late Brad McRae built upon earlier work by \cite{doyle1984random} to demonstrate that isolation by resistance (IBR)\cite{mcrae2006isolation}, which operationalizes the potential for genes and individuals to follow “random walks” across multiple pathways in the same way that electrical current can spread across multiple resistors, can provide an effective tool for considering connectivity potential across landscapes. These insights and McRae’s interest in informing conservation applications inspired the Circuitscape software package \cite{mcrae2008using}, which calculates effective resistance and “current flow,” a measure of net movement probability, across heterogeneous landscapes \cite{dickson2019circuit}. This approach has evolved into a very flexible set of tools that allow users to vary the resistance grid and identification of what can be connected, enabling modelers to address a wide range of questions related to structural (ability of a landscape to support movement) and functional (modeling that is tailored to species-specific traits) connectivity.
Over the past decade Circuitscape has emerged as the most cited landscape connectivity tool in the world \cite{dickson2019circuit}. In the last year alone, Circuitscape has been cited 129 times, and in the past three years, 480 times. Dickson et al. (2019) reviews 277 applications of the software, in fields ranging from gene flow and animal movement to fire, water, and disease spread, and also describes how outputs are being used to inform conservation decisions.
\begin{figure*}
\centering
\includegraphics[width=\textwidth]{res.pdf}
\caption{\textbf{An illustration of the impact of coarsening the resistance grid to address computational limitations.} For this agricultural area along the border of Illinois and Indiana, USA, we show current flow derived from a resistance grid coarsened to 900m (left), compared to a higher-resolution map (180m cells, right). Both resistance grids were derived from the 2011 NLCD (30m), and run with a “wall-to-wall” application of Circuitscape to evaluate landscape structural connectivity. All “natural” terrestrial land cover types in the NLCD were assigned low resistance values, with pasture, roads, row crops, etc., assigned higher resistances. The 900m resolution map misses many narrow bands of natural land cover with high current flow (dark blue) indicating high connectivity value along streams and rivers. Analyses and maps by Melissa Clark, to support work in \cite{baldwin2018future}.
}
\label{fig:my_label}
\end{figure*}
\section{Circuitscape in Julia}
\label{sec:documentclass}
%
The goal of increasing the computational power of Circuitscape has been addressed multiple times by developers Brad McRae and Viral Shah. McRae’s first version was written in Java, before being ported to MATLAB, to improve ease of development. Then, in collaboration with Tanmay Mohapatra, it was translated to Python for flexible scripting, platform independence and release under an open source license. This package makes heavy use of the numpy \cite{van2011numpy}, scipy \cite{jones2014scipy} and pyamg \cite{bell2015pyamg} numerical libraries and solves problems of up to tens of millions of nodes, but connectivity analysis increasingly finer resolution databases often scaled to hundreds of millions of nodes and dozens of focal node pairs, a workload size well beyond its capacity. Circuitscape needed to be upgraded to support the newer demands of user community.
To address these demands, McRae and Shah collaborated on a project called GFLOW \cite{leonard2017gflow}, a software tool for conducting circuit-theory based analyses on supercomputers. Written in the C programmming language and making use of solver libraries such as PetSc \cite{balay2004petsc} and BoomerAMG \cite{yang2002boomeramg}, GFLOW yields state of the art performance on large clusters and supercomputers. However, this performance comes at the cost of accessibility (does not work on the Windows operating system, which the majority of Circuitscape users use), composability (ability to integrate with other software libraries) as well as a tangible difficulty in shipping binaries because of their complicated build processes. For many practitioners and researchers, these constraints are a key barrier, as they prevent GFLOW from being supported on the Windows operating system, and limit integration into a decision support tool or workflow with other tools.
As the maintainers of the Circuitscape, we saw the need for an open-source implementation that is easy to maintain, is high performance, is accessible to our user base and works well on every platform. We decided to use the Julia programming language \cite{bezanson2017julia}. Julia is an open source dynamic programming language which combines the readability of scripting languages such as R or Python, with the performance of a statically compiled language such as C or Fortran. With relatively little development effort via a straight reimplementation of the algorithm, Julia allowed us to not only significantly improve the package's computational capacity, but provide new user-facing features for free. For example, Julia's first class sparse matrix library and factorization support allowed us to support multiple solvers. Its modern Just in Time (JIT) compiler enables programmers to write generic code, and then generate specialized code for desired precision, index types and hardware platform. This makes maintenance of the code base simple. Our upgrade, "Circuitscape.jl", is a registered Julia package and is already being used by the community to solve the next generation of connectivity problems.
The rest of this paper is organized as follows: we present an overview of the algorithm in Section 3, before describing the numerical methods and software packages in Section 4. Section 5 then briefly describe the new features introduced in the upgrade and then present benchmarks both on synthetic problems as well as real user data. We then round off this work with a discussion on how speed improvements enable increased collaboration between computer scientists and ecologists enable improved collaboration between ecologists and conservation managers and other stakeholders.
\section{The Algorithm}
\begin{figure}
\removelatexerror
\centering
\begin{algorithm}[H]
\SetAlgoLined
\LinesNumbered
\KwResult{Current (probability) maps $C$, nodal voltages $V$, pairwise resistances}
Read input raster grid \;
Read focal nodes \;
Construct undirected, weighted graph connecting neighboring cells\;
Compute graph Laplacian $G$ \;
\For{all pairs of focal nodes}{
Set up $I$\;
Solve linear system $GV = I$ \;
Compute effective resistance $r$\;
Write nodal voltages $V$ to disk\;
Compute nodal currents from $I$ and write current map C to disk\
}
\caption{Circuitscape - Pairwise Mode }
\end{algorithm}
\end{figure}
\begin{figure*}
\centering
\includegraphics[width=0.5\textwidth]{flow.png}
\caption{\textbf{Stages of computation and inputs/outputs}. The input raster grid to is usually assembled and produced using a GIS software package, and the output current maps are often exported to a GIS software package for postprocessing.}
\label{fig:flow}
\end{figure*}
Circuitscape takes as input a raster grid, and a list of points which are potential starting and ending points for animal migration. Selecting these points (or focal nodes) on the landscape is often context dependent. For example, they could be two different national parks, or points on the landscape which share important climate properties. The raster grid is a spatial discretization of a heterogeneous landscape where each cell is assigned a value. Each value represents varying qualities of habitat, dispersal routes, or movement barriers. These “resistance” values are often problem specific, and are either empirically derived based on movement or genetic data, or derived via expert opinion. The following content has been summarized in Figure \ref{fig:flow}. This grid can then be represented as a graph, with nodes representing grid cells and edge weights proportional to the movement probabilities or number of migrants exchanged. Other inputs include a list of focal points, which represent points on the landscape of interest to the practitioner. These include habitat patches, protected areas, or populations to connect. These can be specified either through a raster grid with numerical labels for each focal point, or a text file with a list of coordinates. Once the graph is constructed, we then compute its laplacian, which is an alternate representation of the landscape. We then solve for Ohm’s law using the computed graph laplacian as the conductance matrix and the node locations of the focal points as current sources and sinks. On solving the system, we obtain a list of nodal voltages, which are then used to compute branch currents, which represent movement probabilities along branches of the graph. The ecological significance of these various quantities are summarized in related works \cite{mcrae2008using}. The branch currents are then accumulated on each node as nodal currents, which are then written to disk as a raster ASCII grid, for easy import into a geographic information system (GIS).
\section{Numerical Methods}
The vast majority of the computation in Circuitscape is applying Ohm’s law and Kirchoff’s law over very large resistive grids, and solving a large sparse linear system:
$$
GV = I
$$
where $G$ is the graph laplacian representation of the landscape is stored as a large sparse matrix, $I$ are the current sources, and $V$ are the nodal voltages. We provide two solver options to the user: one based on the choleksy factorization and a preconditioned iterative method. The Cholesky factorization \cite{higham2009cholesky} is efficient for applications with smaller study areas and a large number of focal nodes. The sparse matrix is factored once and the solution to multiple pairs is computed via back substitution. Since the cost for backsubstitution is polynomially smaller than the cost of factorization, problems with a large number of focal pairs scale efficiently. The solver that scales to large problems is a preconditioned conjugate gradient (PCG) \cite{trefethen1997numerical}, with an algebraic multigrid preconditioner (AMG) \cite{vanvek1996algebraic}. We leverage Julia implementations of these methods from open source packages IterativeSolvers.jl and AlgebraicMultigrid.jl.
\subsection{Preconditioner Implementation}
Multigrid preconditioners are often used in problems solved across large spatial domains. In general, they take the original grid and generate a hierarchy of coarser grids, via predefined or algebraically derived restriction and interpolation operators. Large problems are solved by restricting quantities down to the coarsest level, obtaining a fast solution, and then interpolating the solution back to the original size. This procedure is often referred to as a “V” cycle. The efficacy of a good multigrid preconditioner is to with obtaining good restriction and interpolation operators. Usually, these operators are derived from the structure of the underlying problem. However, one can also estimate these operators algebraically, from the numerical values at each grid cell. This procedure is often referred to as Algebraic Multigrid (AMG). There are several variants of AMG, which are summarized in \cite{stuben2001review}. We use a variant called the Smoothed Aggregation AMG, which is known to work well for solving matrices generated by elliptic partial differential equations, such as Laplace’s equation. Laplacian matrices are structurally identical to the laplacians of planar graphs that are generated in Circuitscape.
\section{New Features}
\subsection{New Solver Mode}
Circuitscape now supports a new solver based on the Cholesky factorization of the graph laplacian representation of the landscape. We use the SuperNodal sparse cholesky factorization implemented in the CHOLMOD library \cite{chen2008algorithm}. The Julia programming language has first class sparse matrix library and matrix factorization support, which makes it easy to use this solver with a single function call.This solver mode also enables new approaches that divide the landscape into tiles and process them independently \cite{pelletier2014applying}or analyses that move sliding windows across the landscape \cite{mcrae2016conserving}, both of which yield fine scale and localized results. The obvious limitation of this solver, as is of most sparse direct solvers, is that they work very well for relatively small matrices and run out of memory for larger ones. This exponential growth in memory is a by product of the factorization itself, as factors are often less sparse than the original matrix.
\subsection{Generic Programming}
Julia supports the development of generic code while relying on the compiler to generate specialized code for different platforms and precision required. Generic programs are powerful tools for our users, and can be made to adapt to their requirements. For example, the python package had a 32-bit integer type for indexing matrices hardcoded throughout the package, which limited the size of the computation the package ran. This led to crashes when running simulations for hundreds of millions of nodes. One such dataset studying the Mojave desert tortoise \cite{gray2019} used a resistance surface of 437 million pixels. This crashed the old version of Circuitscape, while the upgrade ran smoothly to completion. Circuitscape.jl defaults to a 32-bit integer type for cache efficiency, but provide users with a runtime flag to switch to 64-bit integer to index sparse matrices on the order of hundreds of millions. Since our Julia code was written generically, and this feature came for free without any additional programming effort. Upgrading the python package to support this feature would require significant effort.
\subsection{Improved Parallel Computations}
%Circuitscape.jl introduces support for parallelism on the Windows operating system. This was not possible with the Python package.
Parallel computing in Circuitscape.jl is inherently faster, because the preconditioner can be serialized as a byte stream and sent over the network to other processes. This is not possible in the python code, as the python multiprocessing module internally uses the package pickle to serialize objects, and pyamg objects, implemented in C++, are not “pickle-able” \cite{pydoc}. The ability to serialize native Julia objects significantly reduced the amount of effort to parallelize Circuitscape.
In addition to faster parallel processing, we also extend parallelism support for more problem types in Circuitscape. In the benchmarks section, a dataset which received speed improvements from these new features. The Julia version also lets the user call Circuitscape itself in parallel. As users aim to run Circuitscape over entire countries or continents, landscape are often divided into multiple tiles \cite{pelletier2014applying}. This feature allows users to process (a batch of) these tiles by running different Circuitscape problem instances on each tile in parallel. These parallel features work on all platforms: Linux, MacOS and Windows.
\section{Benchmarks}
\subsection{Experimental Setup}
We conducted our experiments on an Intel(R) Xeon(R) Silver 4114 CPU @ 2.20GHz with 384 GB of RAM. We used Julia v1.1.0 and Circuitscape v5.5.0, and compared against Circuitscape v4.0.5
\subsection{Standard Benchmarks}
We benchmarked Circuitscape on standard synthetic problems. These benchmarks represent the most commonly used configuration and mode (Raster Pairwise) but with different problem sizes. These datasets can be found at \url{https://github.com/Circuitscape/BigTests/}. The benchmark results are summarized in Figure \ref{fig:csbench}.
\begin{figure*}
\centering
\includegraphics[width=0.5\textwidth]{bench.pdf}
\caption{\textbf{Results on the standard Circuitscape benchmark suite (smaller is better)}. The red column standards for the Julia package run under the AMG solver and green column stands for the Julia package run with the Cholesky-based CHOLMOD solver. Note that we benchmark only up to size 24M because at higher sizes the CHOLMOD solver runs out of memory and the Python version takes much, much longer. In summary, this chart demonstrates that Julia-CHOLMOD is the right choice for smaller problem sizes and Julia-CGAMG is the right choice for large problem sizes.}
\label{fig:csbench}
\end{figure*}
\subsection{Benchmarks on Data from Existing Studies}
We ran the Python and Julia version of Circuitscape on a dataset used to model connectivity in the Sonoran desert \cite{drake2017using} (SONORAN). We used to all-to-one scenario \cite{mcrae2009circuitscape}, which models species migrating across the landscape from many different areas to one area. When the researcher used the old version of Circuitscape, this mode did not support parallelism, and the entire computation took over 2 days to run. Parallelism was trivial to support in the Julia version, which reduced execution time to less than 3 hours, resulting in a speedup of nearly 18x. We also benchmarked against a new range-wide model of connectivity for the endangered Mojave desert tortoise \cite{gray2019}(MOJAVE). We found that the Python version crashed, but the Julia package was able to scale effectively. The benchmark results are summarized in Figure \ref{table:bench}.
\begin{figure*}
%\begin{table*}[]
\begin{tabular}{|l|l|l|l|l|}
\hline
\textbf{Benchmark} & \textbf{Size} & \textbf{Number of Solves} & \textbf{Time (Python)} & \textbf{Time (Julia)} \\ \hline
SONORAN & 3339832 & 6002 & 56.62 hrs & 2.838 hrs \\ \hline
MOJAVE & 437 million & 1 & Crashed & 3.385 hrs \\ \hline
\end{tabular}
\centering
%\end{table*}
\caption{\textbf{Benchmarks on data from two conservation studies}. Two metrics determine the execution time of a Circuitscape run: the size of the problem and the number of linear system solves. Our package scales desirably in both directions. }
\label{table:bench}
\end{figure*}
\section{Discussion}
The growth in popularity of circuit theory to model ecological processes has to lead to widespread adoption of the Circuitscape software package. \cite{mcrae_shah_mohapatra_anantharaman}. The Circuitscape project has always evolved with the demands of the users and this upgrade to the Julia programming language seeks to drive the next generation of compute-intensive connectivity models, by shortening execution time from weeks to days and from days to hours. Users no longer have to coarsen their analysis due to computational limitations \cite{drake2017using}. Faster results often enhance stakeholder engagement, improve the feedback loop with policy makers and result in faster turnaround time for conservation decisions. Julia is already being used by ecologists to model ecological networks \cite{timothee_poisot_2018_1438428} and bioenergetic food webs \cite{delmas_eva_2019_2584373} and we see a strong role for it in other areas of computational ecology and conservation science. Its high level mathematical syntax is accessible to scientists while its speed allows them to simulate large, intricate models that capture complexity. We hope to see more ecologists and practitioners use and adopt Julia.
% While connectivity tools typically focus in variation across space, questions related to temporal variability in connectivity, and simulations of how connectivity might change through habitat loss or restoration, would be of great interest as well.
\section{Conclusion}
We present an upgrade to the Circuitscape package, which will allow researchers to analyze ecological processes over large landscapes at fine resolutions. Our upgrade in the high performance Julia programming language presents upto a 1800\% improvement in computation time and the ability to solve landscapes with hundreds of millions (and potentially billions) of grid cells. Julia’s sophisticated compiler allows for faster parallelism, generic programming and composability with other software packages. Circuitscape.jl is open source and is available at \url{https://github.com/Circuitscape/Circuitscape.jl} under the MIT license. Binaries are available on \url{https://circuitscape.org/downloads/}. It can also be installed using the Julia package manager by starting Julia, and entering \texttt{using Pkg; Pkg.add("Circuitscape")}.
\section{Acknowledgement}
The work to update Circuitscape to the Julia computing language was funded through a grant from NASA’s Ecological Forecasting Program (16-ECO4CAST0018), and a grant from the Wilburforce Foundation. The authors also wish to acknowledge the Wilburforce Foundation’s long-term investment in Circuitscape and related tools through several previous awards to Dr. Brad McRae. We thank all of the Circuitsape users who have shared datasets, reported issues, and provided feedback on various versions of these tools, and look forward to continued collaboration with the user community.
\input{bib.tex}
%\bibliography{ref} %%% Remove comment to use the external .bib file (using bibtex).
\end{document}
% Inspired by the International Journal of Computer Applications template
|
theory RingBuffer
imports Main HOL.List
begin
datatype PCW =
A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8
| Enqueue | idleW | OOM | FinishedW | Write | BTS
datatype PCR =
Release | idleR | Read
datatype F = W | R | Q | B
datatype Pointer = Head | Tail
consts N :: nat (*size of buffer, input*)
consts n :: nat (*number of Arr\<^sub>W entries*)
definition "F1_set={W,B,Q,R}"
definition "W_pre_acquire_set={A1,A2,A3,A4,A5,A6,A7,A8,idleW,FinishedW,OOM,BTS}"
definition "W_post_acquire_set={Write,Enqueue}"
definition "R_pre_dequeue_set={idleR}"
definition "R_post_dequeue_set={Read, Release}"
lemmas sets [simp]= F1_set_def W_pre_acquire_set_def W_post_acquire_set_def
R_pre_dequeue_set_def R_post_dequeue_set_def
(*Recorded variables*)
record rb_state =
H :: nat
T :: nat
hW :: nat (*local copy of W*)
tW :: nat (*local copy of W*)
offset :: nat
q :: "(nat \<times> nat) list"
tempR :: "(nat \<times> nat)" (*local copy of word by R*)
data_index :: "(nat \<times> nat) \<Rightarrow> nat" (*state of the buffer contents*)
pcW :: PCW (*records program counter of W*)
pcR :: PCR (*records program counter of W*)
Data:: "nat \<Rightarrow> nat" (*returns a word Data_i*)
tR :: nat
numReads :: nat (* how many words the reader has read *)
numWrites :: nat (* how many words the writer has written *)
numEnqs :: nat (* how many words from Data the writer has enqueued *)
numDeqs :: nat (* how many words from Data the reader has retrieved *)
ownT :: F
ownD :: "nat \<Rightarrow> F" (* ownership of Data indices *)
ownB :: "nat \<Rightarrow> F" (* ownership of bytes in buffer *)
definition "con_assms s \<equiv> 0 < N \<and> 0<n \<and> N>n \<and> numEnqs s\<le>n \<and> (numDeqs s\<le>numEnqs s)
\<and> (\<forall>i.(i<n)\<longrightarrow>Data s i\<le>N \<and> Data s i>0 )"
definition push_H :: "nat \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`H := _" [200])
where
"push_H v \<equiv> \<lambda>s. s \<lparr>H := v\<rparr>"
definition push_T :: "nat \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`T := _" [200])
where
"push_T v \<equiv> \<lambda>s. s \<lparr>T := v\<rparr>"
definition write_data_index :: "nat \<times> nat \<Rightarrow> nat \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`B.write _ := _" [200]) where
"write_data_index a v \<equiv>
\<lambda>s. s \<lparr> data_index := \<lambda> x. if a = x then v else data_index s x \<rparr>"
definition change_writes :: "nat \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`numWrites := _" [200])
where
"change_writes v \<equiv> \<lambda>s. s \<lparr>numWrites := v\<rparr>"
definition change_reads :: "nat \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`numReads := _" [200])
where
"change_reads v \<equiv> \<lambda>s. s \<lparr>numReads := v\<rparr>"
definition push_offset :: "nat \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`offset := _" [200])
where
"push_offset v \<equiv> \<lambda>s. s \<lparr>offset := v\<rparr>"
definition trans_ownT :: "F \<Rightarrow> F \<Rightarrow> rb_state \<Rightarrow> rb_state \<Rightarrow> rb_state" ("transownT [_ _ _]" [200]) where
"trans_ownT a b s \<equiv> if ownT s = a then (\<lambda>s. s \<lparr> ownT := b \<rparr>)
else (\<lambda>s. s \<lparr> ownT := ownT s\<rparr>)"
definition transfer_ownB :: "F \<Rightarrow> F \<Rightarrow> rb_state \<Rightarrow> rb_state" ("transownB [_ _]" [200]) where
"transfer_ownB a b \<equiv> (\<lambda>s. s \<lparr> ownB := \<lambda> i. if (ownB s i = a) then b else (ownB s) i\<rparr>)"
definition set_ownB :: "nat\<times>nat\<Rightarrow> F \<Rightarrow> rb_state \<Rightarrow> rb_state" ("setownB [_ _]" [200]) where
"set_ownB x a \<equiv> (\<lambda>s. s \<lparr> ownB := \<lambda> i. if ((i\<ge>fst(x)) \<and> (i<snd(x))) then a else (ownB s) i\<rparr>)"
definition transfer_ownD :: "nat\<Rightarrow> F \<Rightarrow> rb_state \<Rightarrow> rb_state" ("transownD [_ _]" [200]) where
"transfer_ownD x a \<equiv> (\<lambda>s. s \<lparr> ownD := \<lambda> i. if i=x then a else (ownD s) i\<rparr>)"
(*-----------------------*)
definition set_hW :: "nat \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`hW := _" [200]) where
"set_hW v \<equiv> \<lambda>s. s \<lparr> hW := v\<rparr>"
definition set_tW :: "nat \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`tW := _" [200]) where
"set_tW v \<equiv> \<lambda>s. s \<lparr> tW := v\<rparr>"
definition set_tR :: "nat \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`tR := _" [200]) where
"set_tR v \<equiv> \<lambda>s. s \<lparr> tR := v\<rparr>"
definition set_tempR :: "(nat \<times> nat) \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`tempR := _" [200]) where
"set_tempR v \<equiv> \<lambda>s. s \<lparr> tempR := v\<rparr>"
definition update_numEnqs :: "nat \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`numEnqs := _" [200]) where
"update_numEnqs v\<equiv> \<lambda>s. s \<lparr> numEnqs := v\<rparr>"
definition update_numDeqs :: "nat \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`numDeqs := _" [200]) where
"update_numDeqs v\<equiv> \<lambda>s. s \<lparr> numDeqs := v\<rparr>"
definition update_pcW :: "PCW \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`pcW := _" [200]) where
"update_pcW v \<equiv> \<lambda>s. s \<lparr> pcW := v\<rparr>"
definition update_pcR :: "PCR \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`pcR := _" [200]) where
"update_pcR v \<equiv> \<lambda>s. s \<lparr> pcR := v\<rparr>"
abbreviation update_b_err :: "rb_state \<Rightarrow> rb_state" ("ERROOM") where
"update_b_err \<equiv> \<lambda>s. s \<lparr> pcW := OOM \<rparr>"
abbreviation update_bts_err :: "rb_state \<Rightarrow> rb_state" ("ERRBTS") where
"update_bts_err \<equiv> \<lambda>s. s \<lparr> pcW := BTS \<rparr>"
definition update_q :: "(nat \<times> nat) list \<Rightarrow> rb_state \<Rightarrow> rb_state" ("`q := _" [200])
where
"update_q v \<equiv> \<lambda>s. s \<lparr>q := v\<rparr>"
lemmas functs [simp] = push_H_def push_T_def set_hW_def set_tW_def
update_numEnqs_def update_numDeqs_def
set_tempR_def
update_pcW_def update_pcR_def
transfer_ownB_def transfer_ownD_def trans_ownT_def
update_q_def
push_offset_def write_data_index_def
change_writes_def change_reads_def
set_tR_def set_ownB_def
(* Define the if statement "guards" *)
definition "off bo \<equiv> fst bo"
definition "len bo \<equiv> snd bo"
definition "grd1 s \<equiv> (tW s = hW s) \<and> (Data s (numEnqs s) \<le> N)"
definition "grd2 s \<equiv> (tW s > hW s) \<and> (Data s (numEnqs s) < (tW s - hW s))"
definition "grd3 s \<equiv> tW s < hW s"
definition "grd4 s \<equiv> Data s (numEnqs s) \<le> N - hW s"
definition "grd5 s \<equiv> Data s (numEnqs s) < tW s"
definition "no_space_for_word s \<equiv> (grd1 s \<longrightarrow> \<not>(Data s (numEnqs s) \<le> N))\<and>
(grd2 s \<longrightarrow> \<not>(Data s (numEnqs s) < (tW s - hW s)))\<and>
(grd3 s \<longrightarrow> \<not>(Data s (numEnqs s) \<le> N - hW s \<or> Data s (numEnqs s) < tW s))"
lemmas grd_simps [simp] = off_def len_def grd1_def grd2_def grd3_def grd4_def grd5_def no_space_for_word_def
(***********************************************************************)
(* Initial State *)
definition "init s \<equiv> (H s = 0) \<and> (T s = 0) \<and> (offset s = 0) \<and> q s = [] \<and> (hW s = 0) \<and> (tW s = 0) \<and> (tR s = 0)
\<and> numReads s = 0 \<and> numWrites s = 0 \<and> (numEnqs s = 0) \<and> (numDeqs s = 0)
\<and> ( pcW s = idleW)
\<and> ( pcR s = idleR)
\<and> (\<forall>l. (l<n) \<longrightarrow> ((Data s l > 0)\<and>(Data s l \<le> N)))
\<and> (\<forall>i. (i<n) \<longrightarrow> ownD s i = W)
\<and> (\<forall>i. (i\<le>N) \<longrightarrow> ownB s i = B)
\<and> (ownT s = Q)
\<and> (tempR s = (0,0))
\<and> (\<forall>i. (i\<le>N)\<longrightarrow>(\<forall>j.(j\<le>N)\<longrightarrow>data_index s (i,j) <n))"
(***********************************************************************)
(* State of the queue *)
(* What Q should look like *)
definition "end x \<equiv> fst x + snd x"
lemmas end_simp [simp] = end_def
definition "Q_boundness s \<equiv> (\<forall>x. (x \<in> set (q s)) \<longrightarrow> end x \<le> N)"
definition "Q_offsets_differ s \<equiv> (\<forall>i j.(i<length(q s)\<and> j<length(q s)\<and> i\<noteq>j)\<longrightarrow>(fst(q s!i)\<noteq>fst(q s!j)))"
definition "Q_gap_structure s \<equiv>
(\<forall>i. (i < length(q s) \<and> i > 0) \<longrightarrow>((end(q s!(i-1)) = fst(q s!i))\<or> (fst(q s!i) =0)))"
definition "Q_has_no_uroboros s \<equiv>
(\<forall>x. x \<in> set (butlast (q s)) \<longrightarrow> fst x \<noteq> end (last (q s)))"
definition "Q_has_no_overlaps s \<equiv>
(\<forall> x y. (x \<in> set (q s) \<and> y \<in> set (q s)) \<longrightarrow> (fst(x) < fst(y) \<longrightarrow> end x \<le> fst y))"
definition "Q_basic_struct s \<equiv> Q_boundness s \<and> Q_gap_structure s \<and> Q_offsets_differ s
\<and> Q_has_no_overlaps s \<and> Q_has_no_uroboros s "
lemmas Q_basic_lemmas = Q_basic_struct_def Q_has_no_overlaps_def
Q_gap_structure_def Q_has_no_uroboros_def
Q_boundness_def Q_offsets_differ_def
lemma proof_no_overlaps:
assumes "Q_gap_structure s"
and "Q_offsets_differ s"
and "\<forall>i.(i<length(q s))\<longrightarrow> snd(q s!i)>0"
and "length(q s)>1"
and "Q_has_no_overlaps s"
shows "\<forall>x y.(x\<in>set(q s)\<and>y\<in>set(q s)\<and>length(q s)>1\<and>fst(x)\<noteq>fst(y))\<longrightarrow>
(\<forall>j.(fst(x)\<le>j \<and> j<end(x))\<longrightarrow>(j<fst(y)\<or>j\<ge>end(y)))"
using assms apply (simp add:Q_basic_lemmas)
apply safe
by (smt (verit, best) bot_nat_0.not_eq_extremum diff_is_0_eq le_trans linorder_neqE_nat zero_less_diff)
lemma tail_preserves_Q_boundness:
assumes "Q_boundness s"
and "tl(q s)\<noteq>[]"
shows "(\<forall>x. (x \<in> set (tl(q s))) \<longrightarrow> end x \<le> N)"
using assms apply (simp add:Q_boundness_def)
by (simp add: list.set_sel(2) tl_Nil)
lemma tail_preserves_Q_offsets_differ:
assumes "Q_offsets_differ s"
and "tl(q s)\<noteq>[]"
shows "(\<forall>i j.(i<length(tl(q s))\<and> j<length(tl(q s))\<and> i\<noteq>j)\<longrightarrow>(fst((tl(q s))!i)\<noteq>fst((tl(q s))!j)))"
using assms apply (simp add:Q_offsets_differ_def)
by (simp add: Nitpick.size_list_simp(2) nth_tl tl_Nil)
lemma tail_preserves_Q_gap_structure:
assumes "Q_gap_structure s"
and "tl(q s)\<noteq>[]"
shows "(\<forall>i. (i < length(tl(q s)) \<and> i > 0) \<longrightarrow>((end((tl(q s))!(i-1)) = fst((tl(q s))!i))\<or> (fst((tl(q s))!i) =0)))"
using assms apply (simp add:Q_gap_structure_def)
by (smt (verit) One_nat_def Suc_pred add_diff_cancel_left' length_tl less_Suc_eq less_diff_conv not_less_eq nth_tl plus_1_eq_Suc)
lemma tail_preserves_Q_has_no_uroboros:
assumes "Q_has_no_uroboros s"
and "tl(q s)\<noteq>[]"
shows "(\<forall>x. x \<in> set (butlast (tl(q s))) \<longrightarrow> fst x \<noteq> end (last (tl(q s))))"
using assms apply (simp add:Q_has_no_uroboros_def)
by (metis butlast_tl last_tl list.sel(2) list.set_sel(2))
lemma tail_preserves_Q_has_no_overlaps:
assumes "Q_has_no_overlaps s"
and "tl(q s)\<noteq>[]"
shows "(\<forall> x y. (fst(x) < fst(y) \<and> x \<in> set (tl(q s)) \<and> y \<in> set (tl(q s))) \<longrightarrow> (end x \<le> fst y))"
using assms apply (simp add:Q_has_no_overlaps_def)
by (metis list.sel(2) list.set_sel(2))
lemma tail_preserves_Q_basic_struct:
assumes "Q_basic_struct s"
and "tl(q s)\<noteq>[]"
shows "(\<forall>x. (x \<in> set (tl(q s))) \<longrightarrow> end x \<le> N) \<and>
(\<forall>i j.(i<length(tl(q s))\<and> j<length(tl(q s))\<and> i\<noteq>j)\<longrightarrow>(fst((tl(q s))!i)\<noteq>fst((tl(q s))!j))) \<and>
(\<forall>i. (i < length(tl(q s)) \<and> i > 0) \<longrightarrow>((end((tl(q s))!(i-1)) = fst((tl(q s))!i))\<or> (fst((tl(q s))!i) =0)))\<and>
(\<forall>x. x \<in> set (butlast (tl(q s))) \<longrightarrow> fst x \<noteq> end (last (tl(q s)))) \<and>
(\<forall> x y. (fst(x) < fst(y) \<and> x \<in> set (tl(q s)) \<and> y \<in> set (tl(q s))) \<longrightarrow> (end x \<le> fst y))"
using assms apply (simp add:Q_basic_lemmas)
apply(intro conjI impI)
apply (metis list.sel(2) list.set_sel(2))
using tail_preserves_Q_offsets_differ apply (metis One_nat_def Q_basic_struct_def assms(1) length_tl)
using tail_preserves_Q_gap_structure apply (metis One_nat_def Q_basic_struct_def assms(1) end_simp length_tl)
using tail_preserves_Q_has_no_uroboros apply (metis Q_basic_struct_def assms(1) end_simp old.prod.inject prod.collapse)
by (metis list.sel(2) list.set_sel(2))
(*have the idea of "can fit between H-N or not"*)
definition "pos_of_H_pre_acq s \<equiv>
((q s=[] \<and> pcR s\<in>R_pre_dequeue_set \<and> H s=T s)
\<or>(q s=[] \<and> pcR s\<in>R_post_dequeue_set \<and> H s=end(tempR s) \<and> H s\<noteq> T s)
\<or>(q s\<noteq>[] \<and> H s=end(last(q s)) \<and> H s\<noteq> T s))
\<and> (numEnqs s=0\<longrightarrow>H s=offset s)
\<and> (numEnqs s>0\<longrightarrow>H s=offset s+Data s(numEnqs s-1))"
definition "pos_of_H_post_acq s \<equiv> H s=offset s+Data s(numEnqs s)"
(*have the idea of "can fit between T-N or not"*)
definition "T_is_outside_Q s \<equiv> (\<forall>i.(i<length(q s) \<and> q s\<noteq>[])\<longrightarrow>(end(q s!i)<T s))"
definition "tempR_describes_T s \<equiv> ((fst(tempR s) =0) \<longrightarrow> (T s=0 \<or> T_is_outside_Q s))
\<and>((fst(tempR s) >0) \<longrightarrow> (T s=fst(tempR s)))"
definition "Q_describes_T s \<equiv> ((fst(hd(q s)) =0) \<longrightarrow> (T s=0 \<or> T_is_outside_Q s))
\<and>((fst(hd(q s)) >0) \<longrightarrow> (T s=fst(hd(q s))))"
(*have the idea of "can we describe ownB s i=R"*)
definition "R_owns_no_bytes s \<equiv> (\<forall>i.(i\<ge>0)\<longrightarrow>ownB s i\<noteq>R)"
definition "tempR_describes_ownB s \<equiv> (\<forall>i.(i<fst(tempR s))\<longrightarrow>ownB s i\<noteq>R)
\<and>(\<forall>i.(i\<ge>end(tempR s))\<longrightarrow>ownB s i\<noteq>R)
\<and>(\<forall>i.(fst(tempR s)\<le>i \<and> i<end(tempR s))\<longrightarrow>ownB s i=R)"
definition "tempR_bounded s \<equiv> end(tempR s)\<le>N"
definition "Q_no_overlap_tempR s\<equiv> (\<forall>x. (x \<in> set (q s))\<longrightarrow>
((fst(tempR s)<fst(x)\<and>end(tempR s)\<le> fst(x))
\<or>(fst(x)<fst(tempR s)\<and>end(x)<fst(tempR s))))"
definition "Q_relates_tempR s \<equiv> (end(tempR s) = fst(hd (q s))) \<or> (fst(hd(q s)) = 0)"
lemmas tmepR_extra_lemmas [simp] = tempR_bounded_def Q_no_overlap_tempR_def Q_relates_tempR_def
(* Relating Q to other variables *)
definition "Q_holds_bytes s \<equiv> q s\<noteq>[]\<longrightarrow>(\<forall>i.(i\<in>set(q s))\<longrightarrow>(\<forall>j.(fst(i)\<le>j \<and> j<end(i))\<longrightarrow>ownB s j=Q))"
definition "Q_reflects_writes s \<equiv> (\<forall>i.(i<length(q s))\<longrightarrow>data_index s (q s!i) = ((numDeqs s) +i))"
definition "Q_elem_size s \<equiv> (\<forall>i.(i<length(q s))\<longrightarrow>snd(q s!i) =Data s ((numDeqs s) +i))"
definition "Q_reflects_ownD s \<equiv> (\<forall>i.(i<length(q s))\<longrightarrow>ownD s (i+(numDeqs s)) =B)"
lemma tail_preserves_Q_holds_bytes:
assumes "Q_holds_bytes s"
and "(tl(q s))\<noteq>[]"
shows "(tl(q s))\<noteq>[]\<longrightarrow>(\<forall>i.(i\<in>set(tl(q s)))\<longrightarrow>(\<forall>j.(fst(i)\<le>j \<and> j<end(i))\<longrightarrow>ownB s j=Q))"
using assms apply (simp add:Q_holds_bytes_def)
by (metis list.sel(2) list.set_sel(2))
lemma tail_preserves_Q_reflects_writes:
assumes "Q_reflects_writes s"
and "(tl(q s))\<noteq>[]"
shows "(\<forall>i.(i<length(tl(q s)))\<longrightarrow>data_index s ((tl(q s))!i) = ((numDeqs s) +i +1))"
using assms apply (simp add:Q_reflects_writes_def)
by (simp add: nth_tl)
lemma tail_preserves_Q_elem_size:
assumes "Q_elem_size s"
and "(tl(q s))\<noteq>[]"
shows "(\<forall>i.(i<length(tl(q s)))\<longrightarrow>snd((tl(q s))!i) =Data s ((numDeqs s) +i +1))"
using assms apply (simp add:Q_elem_size_def)
by (simp add: nth_tl)
lemma tail_preserves_Q_reflects_ownD:
assumes "Q_reflects_ownD s"
and "(tl(q s))\<noteq>[]"
shows "(\<forall>i.(i<length(tl(q s)))\<longrightarrow>ownD s (i+(numDeqs s) +1) =B)"
using assms apply (simp add:Q_reflects_ownD_def)
by (metis One_nat_def Suc_eq_plus1 add.assoc less_diff_conv plus_1_eq_Suc)
lemma Q_offsets_imply_tail_offsets:
assumes "Q_offsets_differ s"
shows "(\<forall>i j.(i<length(tl(q s))\<and> j<length(tl(q s))\<and> i\<noteq>j)\<longrightarrow>(fst(tl(q s)!i)\<noteq>fst(tl(q s)!j)))"
using assms apply (simp add:Q_offsets_differ_def)
by (metis (no_types, lifting) Nat.lessE One_nat_def Suc_pred length_tl less_Suc_eq_0_disj nth_tl old.nat.inject zero_less_diff)
lemma Q_head_relates_tail:
assumes "Q_offsets_differ s"
shows "\<forall>i.(i<length(tl(q s)))\<longrightarrow>fst(q s!0)\<noteq> fst(tl(q s)!i)"
using assms apply (simp add:Q_offsets_differ_def)
by (metis One_nat_def Suc_pred length_tl less_Suc_eq_0_disj not_less_eq nth_tl zero_less_diff)
lemma Exists_one_implies_exist_no_more:
assumes "Q_offsets_differ s"
and "Q_gap_structure s"
shows "if \<exists>j.(fst(q s!j) =0 \<and> j<length(q s)) then (\<exists>j.(\<forall>i.(i<length(q s) \<and> i\<noteq>j \<and> i>0)\<longrightarrow>(end(q s!(i-1)) =fst(q s!i))))
else (\<forall>i.(i>0 \<and> i<length(q s))\<longrightarrow>end(q s!(i-1)) = fst(q s!i))"
using assms apply (simp add:Q_basic_lemmas)
apply (case_tac "\<exists>j.(fst(q s!j) =0 \<and> j<length(q s))", simp_all)
apply (metis gr_implies_not0)
by (metis less_nat_zero_code)
lemma Q_hd_zero_implies_structure:
assumes "Q_offsets_differ s"
and "Q_gap_structure s"
and "fst(hd(q s)) =0"
shows "\<forall>i.(i>0 \<and> i<length(q s))\<longrightarrow>end(q s!(i-1)) =fst(q s!i)"
using assms apply(simp add:Q_basic_lemmas)
by (metis drop0 hd_drop_conv_nth less_Suc_eq_0_disj less_imp_Suc_add not_gr_zero)
lemma head_q0:
assumes "length(q s)>0"
shows "hd(q s) = (q s!0)"
using assms apply (simp add:Q_reflects_writes_def)
by (simp add: hd_conv_nth)
lemma data_index_preserved_lemma:
assumes "Q_reflects_writes s"
and "length(q s)>0"
shows "data_index s(q s!0) = numDeqs s"
using assms by (simp add:Q_reflects_writes_def)
definition "Q_structure s \<equiv>q s\<noteq>[]\<longrightarrow>(Q_basic_struct s \<and>
Q_holds_bytes s \<and> Q_reflects_writes s \<and> Q_elem_size s \<and>
Q_reflects_ownD s )"
lemmas Q_lemmas = Q_holds_bytes_def Q_reflects_writes_def Q_reflects_ownD_def
Q_structure_def Q_relates_tempR_def
Q_elem_size_def Q_no_overlap_tempR_def
lemma overlap:
assumes "Q_structure s \<and> length(q s)>1"
shows "\<nexists>k.(\<forall>i j.(i<length(q s)\<and> j<length(q s)\<and> i\<noteq>j)\<longrightarrow>(k\<ge>fst(q s!i)\<and> k<end(q s!i)\<and>k\<ge>fst(q s!j)\<and>k<end(q s!j)))"
using assms apply simp
apply(simp add:Q_lemmas Q_basic_lemmas)
apply(elim conjE impE) apply clarify
apply simp
by (smt One_nat_def Suc_lessD add_diff_cancel_left' le_0_eq le_less_trans less_numeral_extra(1) not_less nth_mem plus_1_eq_Suc prod.collapse)
lemma Q_has_0_elem:
assumes "Q_gap_structure s"
and "Q_offsets_differ s"
and "hd(q s) =(0,a)"
shows "fst(hd(q s)) =0\<longrightarrow>(\<forall>i.(i<length(q s)\<and> i>0)\<longrightarrow>end(q s!(i-1)) =fst(q s!i))"
using assms apply auto
apply (simp add:Q_gap_structure_def Q_offsets_differ_def)
by (metis gr_implies_not_zero head_q0 not_gr_zero old.prod.inject prod.collapse)
(**********)
lemma ownB_lemma:
assumes "length(q s) =2"
and "Q_holds_bytes s"
and "Q_has_no_overlaps s"
and "Q_offsets_differ s"
and "s' = (`q:= (tl(q s)) \<circ> (setownB [(fst(hd(q s)),(end(hd(q s)))) R])) s"
shows "Q_holds_bytes s' "
using assms apply (simp add:Q_lemmas Q_basic_lemmas)
apply (intro conjI impI) apply clarify apply safe
apply simp
apply simp
apply auto[1]
apply(case_tac "a<fst(hd(q s))", simp_all)
defer
apply(case_tac "fst(hd(q s))<a", simp_all)
apply (smt Suc_1 head_q0 le_less_trans length_greater_0_conv list.set_sel(2) not_less nth_mem plus_1_eq_Suc prod.collapse zero_less_two)
apply(case_tac "fst(hd(q s)) =fst(a,b)")
apply (metis (mono_tags, hide_lams) One_nat_def Suc_1 Suc_leI diff_Suc_1 diff_is_0_eq' hd_conv_nth in_set_conv_nth length_tl lessI list.sel(2) nat.simps(3) nth_tl zero_less_Suc)
apply(simp add:fst_def)
apply (metis (no_types, lifting) One_nat_def Suc_1 add_diff_cancel_left' in_set_conv_nth length_tl less_one nat_neq_iff nth_tl plus_1_eq_Suc zero_less_two)
apply (metis list.sel(2) list.set_sel(2))
by (metis (no_types, lifting) hd_in_set le_add_diff_inverse2 length_0_conv list.set_sel(2) prod.collapse trans_le_add2 verit_comp_simplify1(3) zero_neq_numeral)
lemma ownB_lemma2:
assumes "Q_holds_bytes s"
and "Q_structure s"
and "\<forall>i.(i<n)\<longrightarrow>Data s i>0"
and "q s\<noteq>[]"
and "s' = (`q:= (tl(q s)) \<circ> (setownB [(fst(hd(q s)),(end(hd(q s)))) R]) \<circ> (`tempR := (hd(q s)))
\<circ> (transownT [Q R s])
\<circ> (`numDeqs :=(numDeqs s+1))) s"
shows "Q_holds_bytes s'"
using assms apply (simp add:Q_lemmas Q_basic_lemmas)
apply(elim conjE impE)
apply(case_tac "ownT s=Q", simp_all)
apply(case_tac "length(q s) =1", simp_all)
apply (metis diff_Suc_1 length_pos_if_in_set length_tl less_numeral_extra(3))
apply(case_tac "length(q s) =2", simp_all)
apply (smt Suc_1 add_diff_cancel_left' fst_conv fst_def hd_conv_nth in_set_conv_nth le_less_trans length_tl less_2_cases_iff less_Suc0 nat_arith.rule0 not_less nth_tl plus_1_eq_Suc prod.collapse)
apply clarify apply safe
apply(case_tac "fst(hd(q s)) >a", simp add:fst_def snd_def)
apply (smt fst_def hd_in_set le_imp_less_Suc le_less_trans list.set_sel(2) not_less_eq prod.collapse)
defer
apply(case_tac "fst(hd(q s))<a", simp add:fst_def snd_def)
apply (meson list.set_sel(2))
apply (meson list.set_sel(2))
apply(case_tac "fst(hd(q s)) =fst(a,b)", simp add:fst_def snd_def)
apply (smt One_nat_def Suc_mono Suc_pred fst_conv fst_def hd_conv_nth in_set_conv_nth length_greater_0_conv length_tl less_antisym not_less_zero nth_tl zero_induct)
apply(simp add:fst_def snd_def)
apply (smt Suc_leI fst_def hd_in_set le_trans linorder_neqE_nat list.set_sel(2) not_less_eq_eq prod.collapse snd_def)
apply(simp add:fst_def snd_def)
apply (meson list.set_sel(2))
apply (meson list.set_sel(2))
apply clarsimp
apply (case_tac "a<fst(hd(q s))", simp_all add:fst_def snd_def)
apply (case_tac "a>fst(hd(q s))", simp_all add:fst_def snd_def)
apply (smt fst_def hd_in_set le_less_trans list.set_sel(2) not_less prod.collapse snd_def)
by (smt One_nat_def Suc_mono Suc_pred fst_conv fst_def hd_conv_nth in_set_conv_nth length_greater_0_conv length_tl less_antisym not_less_zero nth_tl zero_induct)
lemma Q_type_1:
assumes "q s=[(3,2),(5,2),(0,1)] \<and> N=10"
shows "Q_basic_struct s"
using assms apply(simp add:Q_basic_struct_def)
apply(intro conjI impI)
apply(simp add:Q_boundness_def)
apply(simp add:Q_gap_structure_def)
using less_Suc_eq apply force
apply(simp add:Q_offsets_differ_def)
using less_Suc_eq apply fastforce
apply(simp add:Q_has_no_overlaps_def)
using less_Suc_eq apply force
by(simp add:Q_has_no_uroboros_def)
lemma Q_tail_props:
shows "\<forall>i.(i<length(q s) \<and> i>0)\<longrightarrow>(((q s)!i) = (tl(q s)!(i-1)))"
apply simp
by (simp add: diff_less_mono nth_tl)
lemma Q_basic_preserved:
assumes "Q_basic_struct s"
and "s' = (`q:= (tl(q s))) s"
shows "Q_basic_struct s'"
using assms apply(simp add:Q_basic_struct_def)
apply(intro conjI impI)
apply(simp add:Q_basic_struct_def Q_boundness_def)
apply (metis list.sel(2) list.set_sel(2))
apply(simp add:Q_basic_struct_def Q_gap_structure_def)
defer
apply(simp add:Q_offsets_differ_def)
apply (metis One_nat_def Suc_eq_plus1 diff_Suc_1 length_tl less_diff_conv nth_tl)
apply(simp add:Q_has_no_overlaps_def)
proof -
assume a1: "Q_boundness s \<and> (\<forall>i. i < length (q s) \<and> 0 < i \<longrightarrow> fst (q s ! (i - Suc 0)) + snd (q s ! (i - Suc 0)) = fst (q s ! i) \<or> fst (q s ! i) = 0) \<and> Q_offsets_differ s \<and> Q_has_no_overlaps s \<and> Q_has_no_uroboros s"
{ fix nn :: nat
have "Suc nn < length (q s) \<longrightarrow> fst (q s ! nn) + snd (q s ! nn) = fst (q s ! Suc nn) \<or> fst (q s ! Suc nn) = 0"
using a1 by force
then have "(\<not> nn < length (q s) - Suc 0 \<or> \<not> 0 < nn) \<or> fst (tl (q s) ! (nn - Suc 0)) + snd (tl (q s) ! (nn - Suc 0)) = fst (tl (q s) ! nn) \<or> fst (tl (q s) ! nn) = 0"
by (metis (no_types) One_nat_def Q_tail_props Suc_eq_plus1 length_tl less_diff_conv less_imp_le_nat not_less not_less_eq nth_tl) }
then show "\<forall>n. n < length (q s) - Suc 0 \<and> 0 < n \<longrightarrow> fst (tl (q s) ! (n - Suc 0)) + snd (tl (q s) ! (n - Suc 0)) = fst (tl (q s) ! n) \<or> fst (tl (q s) ! n) = 0"
by presburger
next
show "Q_boundness s \<and>
Q_gap_structure s \<and>
Q_offsets_differ s \<and>
Q_has_no_overlaps s \<and> Q_has_no_uroboros s \<Longrightarrow>
s' = s\<lparr>q := tl (q s)\<rparr> \<Longrightarrow>
Q_has_no_uroboros (s\<lparr>q := tl (q s)\<rparr>)"
using assms Q_tail_props apply (simp add:Q_has_no_uroboros_def Q_basic_struct_def)
by (smt butlast_tl last_tl length_0_conv length_butlast length_pos_if_in_set length_tl less_numeral_extra(3) list.sel(2) list.set_sel(2))
next
show "Q_boundness s \<and>
Q_gap_structure s \<and>
Q_offsets_differ s \<and>
(\<forall>a b aa.
(a, b) \<in> set (q s) \<and> (\<exists>b. (aa, b) \<in> set (q s)) \<longrightarrow> a < aa \<longrightarrow> a + b \<le> aa) \<and>
Q_has_no_uroboros s \<Longrightarrow>
s' = s\<lparr>q := tl (q s)\<rparr> \<Longrightarrow>
\<forall>a b aa.
(a, b) \<in> set (tl (q s)) \<and> (\<exists>b. (aa, b) \<in> set (tl (q s))) \<longrightarrow>
a < aa \<longrightarrow> a + b \<le> aa"
by (metis list.sel(2) list.set_sel(2))
qed
lemma Q_basic_preserved2:
assumes "Q_structure s"
and "ownT s=Q"
and "s' =((`q:= (tl(q s)))
\<circ> (`pcR := Read)
\<circ> (`tempR := (hd(q s)))
\<circ> (transownT [Q R s])
\<circ> (`numDeqs :=(numDeqs s+1))
\<circ> (setownB [(fst(hd(q s)),(end(hd(q s)))) R])) s"
shows "Q_structure s'"
using assms apply simp
apply(simp add:Q_structure_def)
apply(intro conjI impI)
apply(simp add:Q_basic_struct_def)
apply(intro conjI impI)
apply(simp add:Q_boundness_def)
apply (metis list.sel(2) list.set_sel(2))
apply(simp add:Q_gap_structure_def)
apply (smt One_nat_def Q_tail_props Suc_diff_le Suc_leI Suc_mono Suc_pred length_greater_0_conv less_SucI list.sel(2))
apply(simp add:Q_offsets_differ_def)
apply (metis (no_types, lifting) Nitpick.size_list_simp(2) One_nat_def Suc_mono length_tl list.sel(2) nat.inject nth_tl)
apply(simp add:Q_has_no_overlaps_def)
apply (metis (no_types, lifting) list.sel(2) list.set_sel(2))
apply(simp add:Q_has_no_uroboros_def)
apply (metis butlast_tl last_tl list.sel(2) list.set_sel(2))
using ownB_lemma2 apply (simp add:Q_holds_bytes_def)
apply clarify
apply safe
apply simp_all apply(case_tac "fst(hd(q s))>a", simp_all)
apply(simp add:Q_lemmas Q_basic_lemmas fst_def snd_def)
apply (smt fst_def hd_in_set le_imp_less_Suc le_less_trans list.sel(2) list.set_sel(2) not_less_eq prod.collapse)
defer
apply(case_tac "fst(hd(q s))<a", simp_all)
apply (metis list.sel(2) list.set_sel(2))
apply (metis list.sel(2) list.set_sel(2))
defer defer defer
apply(case_tac "fst(hd(q s)) =fst(a,b)", simp add:fst_def snd_def Q_lemmas Q_basic_lemmas)
apply (smt One_nat_def Suc_mono Suc_pred fst_conv fst_def hd_conv_nth in_set_conv_nth length_greater_0_conv length_tl less_antisym list.sel(2) not_less_zero nth_tl zero_induct)
apply(simp add:Q_basic_struct_def Q_has_no_overlaps_def fst_def snd_def)
apply clarify
apply(simp add:Q_lemmas Q_basic_lemmas fst_def snd_def butlast_def)
apply (smt fst_def hd_in_set le_less_trans linorder_neqE_nat list.sel(2) list.set_sel(2) not_less prod.collapse snd_def)
(*finally Q_holds_bytes done*)
apply(simp add:Q_reflects_writes_def)
apply (simp add: nth_tl)
apply(simp add:Q_elem_size_def)
apply (simp add: nth_tl)
apply(simp add:Q_reflects_ownD_def)
using less_diff_conv by auto
(*tempR used to be part of Q so:.....*)
definition "tempR_boundness s \<equiv> (end (tempR s) \<le> N)"
definition "tempR_offsets_differ s \<equiv> (\<forall>i.(i<length(q s))\<longrightarrow>(fst(q s!i)\<noteq>fst(tempR s)))"
definition "tempR_gap_structure s \<equiv> (end(tempR s) = fst(hd(q s)))\<or> (fst(hd(q s)) =0)"
definition "tempR_has_no_uroboros s \<equiv> (fst (tempR s) \<noteq> end (last (q s)))"
definition "tempR_has_no_overlaps s \<equiv>(\<forall>i.(i<length(q s))\<longrightarrow>((fst(tempR s)<fst(q s!i)\<longrightarrow>end(tempR s)\<le>fst(q s!i))
\<and>(fst(tempR s)>fst(q s!i)\<longrightarrow>end(q s!i)\<le>fst(tempR s))))"
definition "tempR_basic_struct s \<equiv> tempR_boundness s \<and> (q s\<noteq>[]\<longrightarrow> (tempR_gap_structure s \<and> tempR_offsets_differ s
\<and> tempR_has_no_overlaps s \<and> tempR_has_no_uroboros s)) "
lemmas tempR_basic_lemmas = tempR_basic_struct_def tempR_has_no_overlaps_def
tempR_gap_structure_def tempR_has_no_uroboros_def
tempR_boundness_def tempR_offsets_differ_def
definition "tempR_holds_bytes s \<equiv> (\<forall>j.(fst(tempR s)\<le>j \<and> j<end(tempR s))\<longrightarrow>ownB s j=R)"
definition "tempR_reflects_writes s \<equiv> (data_index s (tempR s) = ((numDeqs s) -1))"
definition "tempR_elem_size s \<equiv> (snd(tempR s) =Data s ((numDeqs s) -1))"
definition "tempR_structure s \<equiv>(tempR_basic_struct s \<and>
tempR_holds_bytes s \<and> tempR_reflects_writes s \<and> tempR_elem_size s)"
lemmas tempR_lemmas = tempR_holds_bytes_def tempR_reflects_writes_def
tempR_elem_size_def tempR_structure_def
(*OwnB wrt Tail, Q, Reader pcR*)
definition "Tail_and_ownB_idleR s \<equiv> (q s\<noteq>[]\<and>end(q s!(length(q s)-1))<T s \<and> T s>0)\<longrightarrow>(\<forall>i.(T s\<le>i \<and> i<N)\<longrightarrow>ownB s i=Q)"
definition "Tail_and_ownB_not_idleR_1 s \<equiv> (T s\<noteq>fst(tempR s))\<longrightarrow>(\<forall>i.(T s\<le>i \<and> i<N)\<longrightarrow>ownB s i=Q)"
definition "Tail_and_ownB_not_idleR_2 s \<equiv> (T s=fst(tempR s)\<and>q s\<noteq>[]\<and>end(last(q s))<T s)\<longrightarrow>
(\<forall>i.(end(tempR s)\<le>i \<and> i<N)\<longrightarrow>ownB s i=Q)"
lemmas Tail_ownB_rel = Tail_and_ownB_idleR_def Tail_and_ownB_not_idleR_1_def Tail_and_ownB_not_idleR_2_def
(*Writer Thread Behaviour*)
fun rbW_step :: "PCW \<Rightarrow> rb_state \<Rightarrow> rb_state" where
"rbW_step A1 s = ((`hW := (H s)) \<circ> (`tW := (T s)) \<circ> (`pcW := A2)) s "
| "rbW_step A2 s = (if grd1 s then ((`pcW := A3) \<circ> (transownT [Q W s]))
else if grd2 s then (`pcW := A4)
else if grd3 s then (`pcW := A5)
else (`pcW :=A8)) s"
| "rbW_step A3 s = ((`T := 0) \<circ> (`H := (Data s (numEnqs s))) \<circ> (`offset := 0) \<circ> (`pcW := Write)
\<circ> setownB [(0,(Data s (numEnqs s))) W]) s"
| "rbW_step A4 s = ((`H := ((hW s) + (Data s (numEnqs s)))) \<circ> (`offset := (hW s)) \<circ> (`pcW := Write)
\<circ> setownB [(hW s,hW s+Data s (numEnqs s)) W]) s"
| "rbW_step A5 s = (if grd4 s then (`pcW := A6)
else if grd5 s then (`pcW := A7)
else (`pcW := A8)) s"
| "rbW_step A6 s = (`H := ((hW s) + (Data s (numEnqs s))) \<circ> (`offset := (hW s)) \<circ> (`pcW := Write)
\<circ> setownB [(hW s,hW s+Data s (numEnqs s)) W]) s"
| "rbW_step A7 s = ((`H := (Data s (numEnqs s))) \<circ> (`offset := 0) \<circ> (`pcW := Write)
\<circ> (setownB [(hW s,N) W])
\<circ> (setownB [(0,Data s (numEnqs s)) W])) s"
| "rbW_step A8 s = (if ((Data s (numEnqs s))>N) then ERRBTS s
else (ERROOM \<circ> (`tW := (T s))) s)"
| "rbW_step Write s = s"
| "rbW_step Enqueue s = s"| "rbW_step idleW s = s" | "rbW_step FinishedW s = s"| "rbW_step BTS s = s"| "rbW_step OOM s = s"
definition "B_acquire s s' \<equiv> ((pcW s \<in> {idleW})
\<and> (Data s (numEnqs s)) > 0
\<and> s' = (`pcW := A1) s)"
definition "Q_enqueue s s' \<equiv> s' = (`q:=(append (q s) [(offset s,Data s (numEnqs s))])
\<circ> `pcW := idleW
\<circ> transownB [W Q]
\<circ> `numEnqs := (numEnqs s + 1)
\<circ> transownT [W Q s]) s"
definition "B_write s s' \<equiv> s' = ((`B.write ((offset s), (Data s (numEnqs s))):= (numEnqs s))
\<circ> (transownD [(numWrites s) B]) \<circ> `pcW := Enqueue \<circ> (`numWrites := ((numWrites s )+1))) s"
definition cW_step :: "PCW \<Rightarrow> rb_state \<Rightarrow> rb_state \<Rightarrow> bool" where
"cW_step pcw s s' \<equiv>
case pcw of
idleW \<Rightarrow> if ((numEnqs s) < n) then B_acquire s s'
else s' = (`pcW := FinishedW ) s
| Write \<Rightarrow> B_write s s'
| Enqueue \<Rightarrow> Q_enqueue s s'
| OOM \<Rightarrow> if tW s \<noteq> T s then s' = (`pcW := idleW ) s else s = s'
| FinishedW \<Rightarrow> s = s'
| BTS \<Rightarrow> s = s'
| _ \<Rightarrow> s' = rbW_step pcw s "
(*lemma
"(a \<and> b \<longrightarrow> c) = a \<and> (b \<longrightarrow> c)"
nitpick
*)
lemmas W_functs [simp] = B_acquire_def B_write_def Q_enqueue_def
(*---------Tailored assertions to Writer-------*)
definition "pre_acquire_inv s \<equiv> (\<forall>j.(j\<ge>0\<and> j\<le>N)\<longrightarrow>ownB s j\<noteq>W)
\<and> (ownT s \<noteq> W)
\<and> (T s=H s \<longrightarrow> (\<forall>i.(i\<ge>0 \<and> i\<le>N)\<longrightarrow>ownB s i=B) \<and> ownT s = Q \<and> q s= [] \<and> numDeqs s = numEnqs s)
\<and> (T s>H s \<longrightarrow> (\<forall>i.(i\<ge>H s \<and> i<T s)\<longrightarrow>ownB s i=B))
\<and> (T s<H s \<longrightarrow> (\<forall>i.((i\<ge>H s \<and> i\<le>N) \<or> i<T s)\<longrightarrow>ownB s i=B))
\<and> (numWrites s=numEnqs s)
\<and> (numEnqs s=0\<longrightarrow>q s=[])
\<and> (numEnqs s\<le>n)
\<and> (pos_of_H_pre_acq s)
"
definition "pre_A1_inv s \<equiv> (T s=H s\<longrightarrow>((\<forall>i.(i\<ge>0 \<and> i\<le>N)\<longrightarrow>ownB s i=B) \<and> ownT s =Q))
\<and> (\<forall>j.(j\<ge>0\<and> j\<le>N)\<longrightarrow>ownB s j\<noteq>W)
\<and> (ownT s \<noteq>W)
\<and> (T s>H s \<longrightarrow> (\<forall>i.(i\<ge>H s \<and> i<T s)\<longrightarrow>ownB s i=B))
\<and> (T s<H s \<longrightarrow> (\<forall>i.((i\<ge>H s \<and> i\<le>N) \<or> i<T s)\<longrightarrow>ownB s i=B))
\<and> (numWrites s=numEnqs s)
\<and> (numEnqs s<n)
\<and> (pos_of_H_pre_acq s)
"
definition "pre_A2_inv s \<equiv> (tW s=hW s\<longrightarrow>((\<forall>i.(i\<ge>0 \<and> i\<le>N)\<longrightarrow>ownB s i=B) \<and> ownT s =Q))
\<and> (tW s>hW s \<longrightarrow> (\<forall>i.(i\<ge>hW s \<and> i<tW s)\<longrightarrow>ownB s i=B))
\<and> (tW s<hW s \<longrightarrow> (\<forall>i.((i\<ge>hW s \<and> i\<le>N) \<or> i<tW s)\<longrightarrow>ownB s i=B))
\<and> (\<forall>j.(j\<ge>0\<and> j\<le>N)\<longrightarrow>ownB s j\<noteq>W)
\<and> (ownT s \<noteq>W)
\<and> (numWrites s=numEnqs s)
\<and> (numEnqs s<n)
\<and> (pos_of_H_pre_acq s)
"
definition "pre_A3_inv s \<equiv> ((\<forall>i.(i\<ge>0 \<and> i\<le>N)\<longrightarrow>ownB s i=B) \<and> ownT s =Q)
\<and> (grd1 s)
\<and> (ownT s =W)
\<and> (numWrites s=numEnqs s)
\<and> (numEnqs s<n)
\<and> (pos_of_H_pre_acq s)
"
definition "pre_A4_inv s \<equiv> (\<forall>i.(i\<ge>hW s \<and> i<tW s)\<longrightarrow>ownB s i=B)
\<and> (grd2 s) \<and> (\<not>grd1 s)
\<and> (\<forall>j.(j\<ge>0\<and> j\<le>N)\<longrightarrow>ownB s j\<noteq>W)
\<and> (ownT s \<noteq>W)
\<and> (numWrites s=numEnqs s) \<and> (numEnqs s<n)
\<and> (pos_of_H_pre_acq s) "
definition "pre_A5_inv s \<equiv> (\<forall>i.((i\<ge>hW s \<and> i<N) \<or> i<tW s)\<longrightarrow>ownB s i=B)
\<and> (grd3 s) \<and> (\<not>grd1 s) \<and> (\<not>grd2 s)
\<and> (\<forall>j.(j\<ge>0\<and> j\<le>N)\<longrightarrow>ownB s j\<noteq>W)
\<and> (ownT s \<noteq>W)
\<and> (numWrites s=numEnqs s \<and> numEnqs s<n)
\<and> (pos_of_H_pre_acq s)
"
definition "pre_A6_inv s \<equiv> (\<forall>i.((i\<ge>hW s \<and> i<N) \<or> i<tW s)\<longrightarrow>ownB s i=B)
\<and> (grd4 s) \<and> (grd3 s) \<and> (\<not>grd1 s) \<and> (\<not>grd2 s)
\<and> (\<forall>j.(j\<ge>0\<and> j\<le>N)\<longrightarrow>ownB s j\<noteq>W)
\<and> (ownT s \<noteq>W)
\<and> (numWrites s=numEnqs s)
\<and> (numEnqs s<n)
\<and> (pos_of_H_pre_acq s)
"
definition "pre_A7_inv s \<equiv> (\<forall>i.((i\<ge>hW s \<and> i<N) \<or> i<tW s)\<longrightarrow>ownB s i=B)
\<and> (grd5 s) \<and> (grd3 s) \<and> (\<not>grd1 s) \<and> (\<not>grd2 s) \<and> (\<not>grd4 s)
\<and> (\<forall>j.(j\<ge>0\<and> j\<le>N)\<longrightarrow>ownB s j\<noteq>W)
\<and> (ownT s \<noteq>W)
\<and> (numWrites s=numEnqs s)
\<and> (numEnqs s<n)
\<and> (pos_of_H_pre_acq s) "
definition "pre_A8_inv s \<equiv> (\<forall>i.((i\<ge>hW s \<and> i<N) \<or> i<tW s)\<longrightarrow>ownB s i=B)
\<and> (\<forall>j.(j\<ge>0\<and> j\<le>N)\<longrightarrow>ownB s j\<noteq>W)
\<and> (ownT s \<noteq>W)
\<and> (numWrites s=numEnqs s)
\<and> (no_space_for_word s) \<and> (numEnqs s<n)
\<and> (pos_of_H_pre_acq s)
"
definition "pre_write_inv s \<equiv> (\<forall>i.(i\<ge>offset s \<and> i< ((offset s)+(Data s (numEnqs s))))\<longrightarrow>ownB s i=W)
\<and> ((tW s>hW s)\<longrightarrow>(\<forall>i.(i\<ge>((offset s)+(Data s (numEnqs s)))\<and>i<tW s)\<longrightarrow>ownB s i =B))
\<and> ((tW s<hW s \<and> offset s\<noteq>0)\<longrightarrow>(\<forall>i.((i\<ge>((offset s)+(Data s (numEnqs s))) \<and> i\<le>N)\<or>i<tW s)\<longrightarrow>ownB s i =B))
\<and> ((tW s<hW s \<and> offset s=0)\<longrightarrow>((\<forall>i.(i\<ge>((offset s)+(Data s (numEnqs s))) \<and> i<tW s)\<longrightarrow>ownB s i =B) \<and> (\<forall>i.(i\<ge>hW s \<and> i<N)\<longrightarrow>ownB s i=W)))
\<and> (tW s=hW s\<longrightarrow>ownT s=W)
\<and> (numWrites s=numEnqs s)
\<and> (numEnqs s<n)
\<and> (H s>0)
\<and> (pos_of_H_post_acq s)
"
definition "pre_enqueue_inv s \<equiv> (\<forall>i.(i\<ge>offset s \<and> i< ((offset s)+(Data s (numEnqs s))))\<longrightarrow>ownB s i=W)
\<and> ((tW s>hW s)\<longrightarrow>(\<forall>i.(i\<ge>((offset s)+(Data s (numEnqs s)))\<and>i<tW s)\<longrightarrow>ownB s i =B))
\<and> ((tW s<hW s \<and> offset s\<noteq>0)\<longrightarrow>(\<forall>i.((i\<ge>((offset s)+(Data s (numEnqs s))) \<and> i\<le>N)\<or>i<tW s)\<longrightarrow>ownB s i =B))
\<and> ((tW s<hW s \<and> offset s=0)\<longrightarrow>((\<forall>i.(i\<ge>((offset s)+(Data s (numEnqs s))) \<and> i<tW s)\<longrightarrow>ownB s i =B) \<and> (\<forall>i.(i\<ge>hW s \<and> i<N)\<longrightarrow>ownB s i=W)))
\<and> (tW s=hW s\<longrightarrow>ownT s=W)
\<and> (numWrites s=numEnqs s +1)
\<and> (numEnqs s<n)
\<and> (pos_of_H_post_acq s)
"
definition "pre_OOM_inv s \<equiv> (\<forall>j.(j\<ge>0\<and> j\<le>N)\<longrightarrow>ownB s j\<noteq>W)
\<and> (ownT s \<noteq>W)
\<and> (tW s>hW s \<longrightarrow> (\<forall>i.(i\<ge>tW s \<and> i<hW s)\<longrightarrow>ownB s i=B))
\<and> (tW s<hW s \<longrightarrow> (\<forall>i.((i\<ge>hW s \<and> i\<le>N) \<or> i<tW s)\<longrightarrow>ownB s i=B))
\<and> (numWrites s=numEnqs s)
\<and> (numEnqs s<n)
\<and> (pos_of_H_pre_acq s)
"
definition "pre_finished_inv s \<equiv> (\<forall>j.(j\<ge>0\<and> j\<le>N)\<longrightarrow>ownB s j\<noteq>W)
\<and> (ownT s \<noteq>W)
\<and> (numWrites s=numEnqs s)
\<and> (numEnqs s=n)
\<and> (pos_of_H_pre_acq s)
"
definition "pre_BTS_inv s \<equiv> (\<forall>j.(j\<ge>0\<and> j\<le>N)\<longrightarrow>ownB s j\<noteq>W)
\<and> (ownT s \<noteq>W)
\<and> (numWrites s=numEnqs s)
\<and> (numEnqs s<n)
\<and> (pos_of_H_pre_acq s)
"
lemmas writer_lemmas = pre_A1_inv_def pre_A2_inv_def pre_A3_inv_def pre_A4_inv_def
pre_A5_inv_def pre_A6_inv_def pre_A7_inv_def pre_A8_inv_def
pre_BTS_inv_def pre_OOM_inv_def pre_acquire_inv_def
pre_finished_inv_def pre_enqueue_inv_def pre_write_inv_def
(***********************************************************************)
(*Reader Thread Behaviour*)
definition "B_release s s' \<equiv> s' = (`T := (off(tempR s) +len(tempR s))
\<circ> (`pcR := idleR)
\<circ> (`tempR := (0,0))
\<circ> (transownB [R B])
\<circ> (if tR s\<noteq> fst(tempR s) then setownB [(tR s,N) B] else id)
\<circ> transownT [R Q s]) s"
definition "B_read s s' \<equiv> s' = (((transownD [(data_index s (tempR s)) R])
\<circ> (`pcR := Release))
\<circ> (`numReads := ((numReads s)+1))
\<circ> (`tR := (T s))) s"
definition "Q_dequeue s s' \<equiv> s' = ((`q:= (tl(q s)))
\<circ> (`pcR := Read)
\<circ> (`tempR := (hd(q s)))
\<circ> (transownT [Q R s])
\<circ> (`numDeqs :=(numDeqs s+1))
\<circ> (setownB [(off(hd(q s)),(end(hd(q s)))) R])) s"
definition cR_step :: "PCR \<Rightarrow> rb_state \<Rightarrow> rb_state \<Rightarrow> bool" where
"cR_step pcr s s' \<equiv>
case pcr of
idleR \<Rightarrow> if (q s=[]) then (s=s') else (Q_dequeue s s')
| Read \<Rightarrow> B_read s s'
| Release \<Rightarrow> B_release s s'"
lemmas R_functs [simp] = B_release_def B_read_def Q_dequeue_def
(*---------Tailored assertions to Reader-------*)
definition "pre_dequeue_inv s \<equiv> (tempR s = (0,0))
\<and> (numDeqs s \<le> n)
\<and> (numDeqs s \<ge> 0)
\<and> (numDeqs s = numReads s)
\<and> (numDeqs s \<le> numEnqs s)
\<and> (pcR s = idleR)
\<and> (q s\<noteq>[] \<longrightarrow> ownT s=Q)
\<and> (q s\<noteq>[] \<longrightarrow> H s>0)
\<and> ((T s\<noteq>fst(hd(q s))\<and>q s\<noteq>[])\<longrightarrow>(\<forall>x j.(x\<in>set(q s) \<and> j<N \<and> j\<ge>T s)\<longrightarrow>end(x)<j))
\<and> (q s\<noteq>[] \<longrightarrow>Q_describes_T s)
\<and> (R_owns_no_bytes s)
\<and> (Tail_and_ownB_idleR s)
"
definition "pre_Read_inv s \<equiv> (snd(tempR s) = Data s (numReads s))
\<and> (numReads s=data_index s (tempR s))
\<and> (numDeqs s\<le>n)
\<and> (numDeqs s\<ge>0)
\<and> (numReads s+1=numDeqs s)
\<and> (numDeqs s\<ge>1)
\<and> (numEnqs s\<ge>numDeqs s)
\<and> (pcR s=Read)
\<and> (ownT s = R)
\<and> (ownD s (numReads s) = B)
\<and> (tempR s\<noteq>(0,0))
\<and> (tempR_structure s)
\<and> (tempR_describes_T s)
\<and> (tempR_describes_ownB s)
\<and> (H s>0)
\<and> (Tail_and_ownB_not_idleR_1 s)
\<and> (Tail_and_ownB_not_idleR_2 s)
\<and> (T s\<noteq>fst(tempR s)\<longrightarrow>(\<forall>x j.(x\<in>set(q s) \<and> j<N \<and> j\<ge>T s)\<longrightarrow>end(x)<j))
"
definition "pre_Release_inv s \<equiv> (snd(tempR s) = Data s (numReads s -1))
\<and> (data_index s (tempR s) = numReads s -1)
\<and> (q s\<noteq>[]\<longrightarrow>(numReads s=data_index s (hd(q s))))
\<and> (ownT s = R)
\<and> (numEnqs s\<ge>numDeqs s)
\<and> (ownD s (numReads s -1) = R)
\<and> (numDeqs s\<le>n \<and> numDeqs s\<ge>1)
\<and> (numDeqs s = numReads s)
\<and> (pcR s=Release)
\<and> (tR s=T s)
\<and> (tempR s\<noteq>(0,0))
\<and> (tempR_structure s)
\<and> (tempR_describes_T s)
\<and> (tempR_describes_ownB s)
\<and> (H s>0)
\<and> (Tail_and_ownB_not_idleR_1 s)
\<and> (Tail_and_ownB_not_idleR_2 s)
\<and> (tR s\<noteq>fst(tempR s)\<longrightarrow>(\<forall>x j.(x\<in>set(q s) \<and> j<N \<and> j\<ge>tR s)\<longrightarrow>end(x)<j))
"
lemmas reader_lemmas = pre_Release_inv_def pre_Read_inv_def pre_dequeue_inv_def
(***********************************************************************)
lemma Q_structure_preserved1:
assumes "Q_structure s"
and "pre_dequeue_inv s"
and "q s\<noteq>[]"
and "Q_dequeue s s'"
shows "Q_structure s'"
using assms apply(simp add:Q_structure_def pre_dequeue_inv_def)
apply (intro conjI impI)
apply(simp add:Q_basic_struct_def)
apply(intro conjI impI)
apply(simp add:Q_boundness_def Q_describes_T_def)
apply (metis list.set_sel(2))
apply(simp add:Q_gap_structure_def)
using Q_basic_preserved2 Q_tail_props
apply (smt (verit, ccfv_SIG) One_nat_def Suc_less_eq2 diff_Suc_1 diff_commute gr_implies_not0 not_less_less_Suc_eq zero_less_Suc zero_less_diff)
apply(simp add:Q_offsets_differ_def)
apply (metis (no_types, lifting) One_nat_def add.commute add_right_cancel length_tl less_diff_conv nth_tl plus_1_eq_Suc)
apply(simp add:Q_has_no_overlaps_def)
using Q_basic_preserved2
apply (metis (no_types, lifting) list.set_sel(2))
apply(simp add:Q_has_no_uroboros_def)
apply (metis butlast_tl last_tl list.sel(2) list.set_sel(2))
using ownB_lemma2
apply (smt (z3) Q_basic_preserved2 Q_dequeue_def Q_holds_bytes_def Q_structure_def assms(4) end_simp len_def off_def)
apply(simp add:Q_reflects_writes_def)
using Q_basic_preserved2
apply (metis (no_types, lifting) One_nat_def Suc_eq_plus1 add_Suc_right length_tl less_diff_conv nth_tl)
apply(simp add:Q_elem_size_def)
using Q_basic_preserved2
apply (metis One_nat_def Suc_eq_plus1 add_Suc_right length_tl less_diff_conv nth_tl)
apply(simp add:Q_reflects_ownD_def)
by (metis Nat.add_0_right add_Suc add_Suc_right less_diff_conv)
lemma Q_structure_preserved2:
assumes "Q_structure s"
and "ownT s=R"
and "pre_Read_inv s"
and "B_read s s'"
shows "Q_structure s'"
using assms apply(simp add:Q_structure_def)
apply(intro conjI impI) apply(simp add:Q_basic_struct_def) apply(intro conjI impI)
apply(simp add:Q_boundness_def)
apply(simp add:Q_gap_structure_def)
apply(simp add:Q_offsets_differ_def)
apply(simp add:Q_has_no_overlaps_def)
apply(simp add:Q_has_no_uroboros_def)
apply(simp add:Q_holds_bytes_def)
apply(simp add:Q_reflects_writes_def)
apply(simp add:Q_elem_size_def)
apply(simp add:Q_reflects_ownD_def)
by(simp add:Q_structure_def pre_Read_inv_def)
lemma Q_structure_preserved3:
assumes "Q_structure s"
and "pre_Release_inv s"
and "s' = (`T := (off(tempR s) +len(tempR s))
\<circ> (`pcR := idleR)
\<circ> (`tempR := (0,0))
\<circ> (transownB [R B])
\<circ> (if tR s\<noteq> fst(tempR s) then setownB [(tR s,N) B] else id)
\<circ> transownT [R Q s]) s"
shows "Q_structure s'"
using assms
apply (simp add:Q_structure_def)
apply(intro conjI impI)
apply(simp add:Q_basic_struct_def)
apply(intro conjI impI)
apply(simp add:pre_Release_inv_def Q_boundness_def)
apply(simp add:pre_Release_inv_def Q_gap_structure_def)
apply(simp add:pre_Release_inv_def Q_offsets_differ_def)
apply(simp add:pre_Release_inv_def Q_has_no_overlaps_def)
apply(simp add:pre_Release_inv_def Q_has_no_uroboros_def)
apply(simp add:pre_Release_inv_def Q_holds_bytes_def tempR_lemmas tempR_basic_lemmas)
apply (metis (no_types, lifting) F.distinct(7) less_Suc_eq not_less_eq)
apply(simp add:pre_Release_inv_def Q_reflects_writes_def)
apply(simp add:pre_Release_inv_def Q_elem_size_def)
apply(simp add:pre_Release_inv_def Q_reflects_ownD_def)
apply(simp add:pre_Release_inv_def Q_basic_lemmas)
apply(simp add:pre_Release_inv_def Q_holds_bytes_def)
apply(simp add:pre_Release_inv_def Q_reflects_writes_def)
apply(simp add:pre_Release_inv_def Q_elem_size_def)
apply(simp add:pre_Release_inv_def Q_reflects_ownD_def)
apply(simp add:pre_Release_inv_def Q_basic_lemmas)
apply(simp add:pre_Release_inv_def Q_holds_bytes_def)
apply(simp add:pre_Release_inv_def Q_reflects_writes_def)
apply(simp add:pre_Release_inv_def Q_elem_size_def)
apply(simp add:pre_Release_inv_def Q_reflects_ownD_def)
apply(simp add:pre_Release_inv_def Q_basic_lemmas)
apply(simp add:pre_Release_inv_def Q_holds_bytes_def)
apply(simp add:pre_Release_inv_def Q_reflects_writes_def)
apply(simp add:pre_Release_inv_def Q_elem_size_def)
by(simp add:pre_Release_inv_def Q_reflects_ownD_def)
definition "inRange v \<equiv> 0 \<le> v \<and> v \<le> N"
definition "inRangeHT s \<equiv> inRange (H s) \<and> inRange (T s)"
definition "H0_T0 s \<equiv> H s = 0 \<longrightarrow> T s = 0"
definition "inRangeht s \<equiv> inRange (hW s) \<and> inRange (tW s)"
definition "basic_pointer_movement s \<equiv> inRangeHT s \<and> inRangeht s \<and> H0_T0 s "
lemmas basic_pointer_movement_lemmas [simp] = basic_pointer_movement_def inRangeHT_def inRangeht_def H0_T0_def inRange_def
definition "mainInv s \<equiv> \<forall> i. (i<numReads s \<longrightarrow> ownD s i=R) \<and> (numReads s \<le> i \<and> i < numWrites s \<longrightarrow> ownD s i = B) \<and> (numWrites s \<le> i \<and> i < n \<longrightarrow> ownD s i = W) "
definition "counter_bounds s \<equiv> numReads s \<le>n \<and> numWrites s\<le>n \<and> numEnqs s\<le>n \<and> numDeqs s \<le> n"
definition "counter_q_rel s \<equiv> (numEnqs s-numDeqs s=length(q s))\<and> numWrites s\<ge>numReads s"
(*new lemmas, take 2*)
definition "data_index_bouded s \<equiv> \<forall>i. (i\<le>N)\<longrightarrow>(\<forall>j.(j\<le>N)\<longrightarrow>data_index s (i,j)<n)"
lemmas invariant_lemmas [simp] = con_assms_def mainInv_def
counter_q_rel_def
counter_bounds_def data_index_bouded_def
(*------------------------ Invariant ------------------------------------*)
definition inv where
"inv s \<equiv> basic_pointer_movement s
\<and> mainInv s
\<and> counter_q_rel s
\<and> counter_bounds s
\<and> Q_structure s
\<and> data_index_bouded s
"
definition pre_W where
"pre_W pcw s \<equiv> (case pcw of
idleW \<Rightarrow> pre_acquire_inv s
| A1 \<Rightarrow> pre_A1_inv s
| A2 \<Rightarrow> pre_A2_inv s
| A3 \<Rightarrow> pre_A3_inv s
| A4 \<Rightarrow> pre_A4_inv s
| A5 \<Rightarrow> pre_A5_inv s
| A6 \<Rightarrow> pre_A6_inv s
| A7 \<Rightarrow> pre_A7_inv s
| A8 \<Rightarrow> pre_A8_inv s
| Write \<Rightarrow> pre_write_inv s
| OOM \<Rightarrow> pre_OOM_inv s
| BTS \<Rightarrow> pre_BTS_inv s
| Enqueue \<Rightarrow> pre_enqueue_inv s
| FinishedW \<Rightarrow> pre_finished_inv s)"
definition pre_R where
"pre_R pcr s \<equiv>
(case pcr of
idleR \<Rightarrow> pre_dequeue_inv s
| Read \<Rightarrow> pre_Read_inv s
| Release \<Rightarrow> pre_Release_inv s)"
lemmas inv_simps = inv_def cW_step_def cR_step_def init_def
lemma tail_preserves_struct:
"Q_gap_structure s \<Longrightarrow> fst (q s ! 0) = 0 \<Longrightarrow>\<forall> i . i<length (q s) \<longrightarrow> snd(q s ! i) > 0 \<Longrightarrow>
Q_offsets_differ s \<Longrightarrow> length(q s)>0 \<Longrightarrow>
\<forall> i . (i<length (q s) \<and> i>0)\<longrightarrow> fst(q s ! i) > fst (q s ! 0)"
apply(simp add:Q_gap_structure_def Q_offsets_differ_def)
by (metis gr_implies_not_zero not_gr_zero)
lemma peculiar_1:
assumes "Q_gap_structure s"
and "Q_offsets_differ s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "fst(q s!1) = end(q s!0) \<or> fst(q s!1) =0"
using assms apply(simp add:Q_gap_structure_def Q_offsets_differ_def Q_structure_def)
by (metis One_nat_def diff_add_zero length_greater_0_conv length_tl less_numeral_extra(1) plus_1_eq_Suc zero_less_diff)
lemma peculiar_2:
assumes "Q_gap_structure s"
and "Q_offsets_differ s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "(end(hd(q s)) = fst(hd(tl(q s)))\<and> fst(hd(tl(q s)))\<noteq>0) \<or> fst(hd(tl(q s))) =0"
using assms apply(simp add:Q_gap_structure_def Q_offsets_differ_def Q_structure_def)
by (metis Nitpick.size_list_simp(2) One_nat_def diff_add_zero hd_conv_nth less_Suc_eq_0_disj not_gr_zero nth_tl plus_1_eq_Suc)
lemma peculiar_3:
assumes "Q_structure s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "(end(hd(q s)) = fst(hd(tl(q s)))\<and> fst(hd(tl(q s)))\<noteq>0) \<or> fst(hd(tl(q s))) =0"
using peculiar_1 peculiar_2 Q_structure_def Q_basic_struct_def
proof -
have "Q_basic_struct s"
by (metis (no_types) Nil_tl Q_structure_def assms(1) assms(3))
then show ?thesis
by (metis Nil_tl Q_basic_struct_def assms(3) peculiar_2)
qed
lemma peculiar_4:
assumes "Q_offsets_differ s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "\<forall>i.(i<length(q s) \<and> i>0)\<longrightarrow>fst(q s!0) \<noteq> fst(q s!i)"
using assms by (simp add:Q_offsets_differ_def)
lemma peculiar_5:
assumes "Q_offsets_differ s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "\<forall>i.(i<length(q s) \<and> i>0)\<longrightarrow>fst(hd(q s)) \<noteq> fst(q s!i)"
using assms peculiar_4
by (simp add: peculiar_4 hd_conv_nth)
lemma peculiar_6:
assumes "Q_offsets_differ s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "\<forall>i.(i<length(tl(q s)))\<longrightarrow>fst(hd(q s)) \<noteq> fst(tl(q s)!i)"
using peculiar_4 peculiar_5
by (simp add: Q_head_relates_tail assms(1) assms(2) hd_conv_nth)
lemma peculiar_7:
assumes "Q_offsets_differ s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "\<forall>i.(i<(length((q s))-1))\<longrightarrow>fst(hd(q s)) \<noteq> fst(tl(q s)!i)"
using assms peculiar_6
by (simp add: peculiar_6)
lemma peculiar_8:
assumes "Q_has_no_overlaps s"
and "Q_has_no_uroboros s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "\<forall>x.(x\<in>set(q s) \<and> x\<noteq>hd(q s) \<and> fst(hd(q s))<fst(x))\<longrightarrow>end(hd(q s))\<le>fst(x)"
using assms Q_has_no_overlaps_def Q_has_no_uroboros_def
using hd_in_set by blast
lemma peculiar_9:
assumes "Q_has_no_overlaps s"
and "Q_has_no_uroboros s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "\<forall>x.(x\<in>set(tl(q s)) \<and> fst(hd(q s))<fst(x))\<longrightarrow>end(hd(q s))\<le>fst(x)"
using peculiar_8
by (metis assms(1) assms(2) assms(3) assms(4) dual_order.irrefl list.set_sel(2))
lemma peculiar_10:
assumes "Q_has_no_overlaps s"
and "Q_has_no_uroboros s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "\<forall>i.(i<(length(q s)-1) \<and> fst(hd(q s))<fst(tl(q s)!i))\<longrightarrow>end(hd(q s))\<le>fst(tl(q s)!i)"
by (metis assms(1) assms(2) assms(3) assms(4) length_tl nth_mem peculiar_9)
lemma peculiar_11:
assumes "Q_has_no_overlaps s"
and "Q_has_no_uroboros s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "\<forall>x.(x\<in>set(q s) \<and> x\<noteq>hd(q s) \<and> fst(hd(q s))>fst(x))\<longrightarrow>fst(hd(q s))\<ge>end(x)"
using assms Q_has_no_overlaps_def Q_has_no_uroboros_def
using hd_in_set by blast
lemma peculiar_12:
assumes "Q_has_no_overlaps s"
and "Q_has_no_uroboros s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "\<forall>x.(x\<in>set(tl(q s)) \<and> fst(hd(q s))>fst(x))\<longrightarrow>fst(hd(q s))\<ge>end(x)"
using assms Q_has_no_overlaps_def peculiar_11
by (metis list.set_sel(2))
lemma peculiar_13:
assumes "Q_has_no_overlaps s"
and "Q_has_no_uroboros s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "\<forall>i.(i<(length(q s)-1) \<and> fst(hd(q s))>fst(tl(q s)!i))\<longrightarrow>fst(hd(q s))\<ge>end(tl(q s)!i)"
using assms peculiar_12
by (metis length_tl nth_mem)
lemma peculiar_14:
assumes "Q_has_no_overlaps s"
and "Q_has_no_uroboros s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "(\<forall>i.(i<(length(q s)-1) \<and> fst(hd(q s))>fst(tl(q s)!i))\<longrightarrow>fst(hd(q s))\<ge>end(tl(q s)!i))
\<and>(\<forall>i.(i<(length(q s)-1) \<and> fst(hd(q s))<fst(tl(q s)!i))\<longrightarrow>end(hd(q s))\<le>fst(tl(q s)!i))"
using peculiar_13 peculiar_10
using assms(1) assms(2) assms(3) assms(4) by blast
lemma peculiar_15:
assumes "Q_has_no_overlaps s"
and "Q_has_no_uroboros s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "\<forall>i<length (q s) - Suc 0.
(fst (hd (q s)) < fst (tl (q s) ! i) \<longrightarrow>
fst (hd (q s)) + snd (hd (q s)) \<le> fst (tl (q s) ! i)) \<and>
(fst (tl (q s) ! i) < fst (hd (q s)) \<longrightarrow>
fst (tl (q s) ! i) + snd (tl (q s) ! i) \<le> fst (hd (q s)))"
using peculiar_14
by (metis One_nat_def assms(1) assms(2) assms(3) assms(4) end_simp)
lemma peculiar_16:
assumes "Q_structure s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "\<forall>i<length (q s) - Suc 0.
(fst (hd (q s)) < fst (tl (q s) ! i) \<longrightarrow>
fst (hd (q s)) + snd (hd (q s)) \<le> fst (tl (q s) ! i)) \<and>
(fst (tl (q s) ! i) < fst (hd (q s)) \<longrightarrow>
fst (tl (q s) ! i) + snd (tl (q s) ! i) \<le> fst (hd (q s)))"
using peculiar_15 Q_structure_def
using Q_basic_struct_def assms(1) assms(2) assms(3) by auto
lemma peculiar_17 :
assumes "inv s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "\<forall>i<length (q s) - Suc 0.
(fst (hd (q s)) < fst (tl (q s) ! i) \<longrightarrow>
fst (hd (q s)) + snd (hd (q s)) \<le> fst (tl (q s) ! i)) \<and>
(fst (tl (q s) ! i) < fst (hd (q s)) \<longrightarrow>
fst (tl (q s) ! i) + snd (tl (q s) ! i) \<le> fst (hd (q s)))"
using peculiar_16 inv_def Q_structure_def
using assms(1) assms(2) assms(3) by blast
lemma peculiar_18:
assumes "Q_has_no_uroboros s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "fst (q s!0) \<noteq> end (last (q s))"
using Q_has_no_uroboros_def
by (metis assms(1) assms(2) assms(3) butlast.simps(2) list.exhaust_sel list.set_intros(1) nth_Cons_0)
lemma peculiar_19:
assumes "Q_structure s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "fst (q s!0) \<noteq> end (last (q s))"
using Q_has_no_uroboros_def Q_structure_def peculiar_18
using Q_basic_struct_def assms(1) assms(2) assms(3) by blast
lemma peculiar_20:
assumes "Q_structure s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "fst (hd(q s)) \<noteq> end (last (q s))"
using peculiar_19
by (metis assms(1) assms(2) assms(3) hd_conv_nth)
lemma peculiar_21:
assumes "Q_structure s"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "fst (hd(q s)) \<noteq> end (last (tl(q s)))"
using peculiar_20
by (metis assms(1) assms(2) assms(3) last_tl)
lemma peculiar_22:
assumes "Q_structure s"
and "tempR_structure s"
and "fst(tempR s) =0"
shows "\<forall>i.(i<length(q s)\<and> i>0)\<longrightarrow>fst(q s!i) = end(q s!(i-1))"
using assms apply (simp add:Q_lemmas Q_basic_lemmas tempR_lemmas tempR_basic_lemmas)
by (metis length_0_conv less_nat_zero_code)
lemma peculiar_23:
assumes "Q_structure s"
and "tempR_structure s"
and "fst(tempR s) =0"
shows "\<forall>i.(i<length(q s))\<longrightarrow>fst(q s!i) >0"
using assms apply (simp add:Q_lemmas Q_basic_lemmas tempR_lemmas tempR_basic_lemmas)
by (metis length_0_conv less_nat_zero_code)
lemma peculiar_24:
assumes "Q_structure s"
and "tempR_structure s"
and "fst(tempR s) =0"
and "q s\<noteq>[]" and "tl(q s)\<noteq>[]"
shows "fst(q s!0) =end(tempR s)"
using assms apply (simp add:Q_lemmas Q_basic_lemmas tempR_lemmas tempR_basic_lemmas)
by (metis hd_conv_nth length_greater_0_conv zero_less_iff_neq_zero)
lemma peculiar_25:
assumes "Q_offsets_differ s"
and "Q_gap_structure s"
and "fst(hd(q s)) =0"
and "tl(q s)\<noteq>[]"
shows "\<forall>i.(i<length(q s)\<and>i>0)\<longrightarrow>fst(q s!i) = end(q s!(i-1))"
using assms
by (metis Q_hd_zero_implies_structure)
lemma peculiar_26:
assumes "Q_offsets_differ s"
and "Q_gap_structure s"
and "fst(hd(q s)) =0"
and "tl(q s)\<noteq>[]"
shows "\<forall>i.(i<length(q s)\<and>i>0)\<longrightarrow>(q s!i) = (tl(q s)!(i-1))"
using assms
by (simp add: Q_tail_props)
lemma peculiar_27:
assumes "Q_offsets_differ s"
and "Q_gap_structure s"
and "fst(hd(q s)) =0"
and "tl(q s)\<noteq>[]"
shows "\<forall>i.(i<length(q s)\<and>i>1)\<longrightarrow>fst(tl(q s)!(i-1)) = end(tl(q s)!(i-2))"
using assms
by (smt (z3) Q_tail_props diff_diff_left diff_is_0_eq' le_numeral_extra(4) less_imp_diff_less one_add_one peculiar_25 zero_less_diff)
lemma peculiar_28:
assumes "Q_offsets_differ s"
and "Q_gap_structure s"
and "Q_has_no_uroboros s"
and "fst(hd(q s)) =0"
and "tl(q s)\<noteq>[]"
and "butlast(tl(q s))\<noteq>[]"
shows "last(tl(q s)) =last(q s)"
using assms
by (simp add: last_tl)
lemma peculiar_29:
assumes "Q_offsets_differ s"
and "Q_gap_structure s"
and "Q_has_no_uroboros s"
and "fst(hd(q s)) =0"
and "tl(q s)\<noteq>[]"
and "butlast(tl(q s))\<noteq>[]"
shows "\<forall>i.(i<length(butlast(tl(q s))))\<longrightarrow>(tl(q s)!i) = (q s!(i+1))"
using assms
by (simp add: peculiar_26)
lemma peculiar_30:
assumes "Q_offsets_differ s"
and "Q_gap_structure s"
and "Q_has_no_uroboros s"
and "fst(hd(q s)) =0"
and "tl(q s)\<noteq>[]"
and "butlast(tl(q s))\<noteq>[]"
shows "end(last(q s)) = end(last(tl(q s)))"
using assms
by (simp add: last_tl)
lemma peculiar_31:
assumes "Q_offsets_differ s"
and "Q_gap_structure s"
and "Q_has_no_uroboros s"
and "fst(hd(q s)) =0"
and "tl(q s)\<noteq>[]"
and "butlast(tl(q s))\<noteq>[]"
shows "\<forall>i.(i<(length(tl(q s))-1))\<longrightarrow>fst(tl(q s)!i) \<noteq>end(last(tl(q s)))"
using assms peculiar_30 peculiar_29 apply simp
unfolding Q_lemmas Q_basic_lemmas apply safe apply(subgoal_tac "last(tl(q s)) =(tl(q s)!(length(tl(q s))-1))")
prefer 2
apply (simp add: last_conv_nth) apply simp
by (metis One_nat_def Suc_eq_plus1 Suc_lessD assms(5) diff_Suc_eq_diff_pred in_set_conv_nth last_tl length_butlast length_tl less_diff_conv nth_butlast nth_tl prod.exhaust_sel)
lemma more_peculiar_1:
assumes "con_assms s"
and "(T s\<noteq>fst(tempR s))\<longrightarrow>(\<forall>i.(T s\<le>i \<and> i<N)\<longrightarrow>ownB s i=Q)"
and "tempR_structure s"
and "Q_structure s"
and "B_release s s'"
and "tempR_describes_T s"
and "q s\<noteq>[]"
and "(T s\<noteq>fst(tempR s))"
shows "T s'=fst(hd(q s'))"
using assms apply simp
apply(simp add:Q_lemmas Q_basic_lemmas tempR_lemmas tempR_basic_lemmas)
apply(case_tac "tR s \<noteq> fst (tempR s)", simp_all)
apply(case_tac "ownT s = R", simp_all)
apply(subgoal_tac "fst(tempR s) =0")
apply (metis hd_conv_nth length_greater_0_conv)
apply(simp add:tempR_describes_T_def)
apply(simp add:tempR_describes_T_def T_is_outside_Q_def)
apply (metis hd_conv_nth length_greater_0_conv list.size(3))
apply(simp add:tempR_describes_T_def T_is_outside_Q_def)
by (metis hd_conv_nth length_greater_0_conv list.size(3))
lemma Release_doesnt_affect_outskirts:
assumes "con_assms s"
and "q s\<noteq>[]"
and "fst(hd(q s)) =0"
and "fst(tempR s) =T s"
and "pre_Release_inv s"
and "Q_structure s"
and "tempR_structure s"
and "B_release s s'"
shows "\<forall>i.(i\<ge>end(tempR s) \<and> i<N)\<longrightarrow>ownB s i=ownB s' i"
using assms apply simp
apply(case_tac "tR s \<noteq> T s", simp_all) apply(case_tac "ownT s = R", simp_all) apply(simp_all add:pre_Release_inv_def)
by (metis end_simp tempR_describes_ownB_def)
lemma local_pre_R:
assumes "con_assms s"
and "pcr = pcR s"
and "pre_R pcr s"
and "inv s"
and "cR_step pcr s s'"
shows "pre_R (pcR s') s'"
using assms apply(simp add:RingBuffer.inv_def pre_R_def)
apply(case_tac "pcR s", simp_all add:cR_step_def)
apply(case_tac "tR s\<noteq>fst(tempR s)", simp_all)
apply(case_tac "ownT s = R", simp_all)
apply(simp add:pre_dequeue_inv_def)
apply (intro conjI impI)
apply(simp add:pre_Release_inv_def Q_lemmas Q_basic_lemmas Q_describes_T_def T_is_outside_Q_def R_owns_no_bytes_def pre_dequeue_inv_def)
apply(simp add:pre_Release_inv_def Q_lemmas Q_basic_lemmas pre_dequeue_inv_def)
apply(simp add:pre_Release_inv_def Q_lemmas Q_basic_lemmas pre_dequeue_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def tempR_describes_ownB_def)
apply (metis hd_conv_nth length_pos_if_in_set)
apply(simp add:pre_Release_inv_def Q_lemmas Q_basic_lemmas pre_dequeue_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def tempR_describes_ownB_def)
apply(simp add:Q_describes_T_def T_is_outside_Q_def)
apply (metis add_cancel_left_left hd_conv_nth length_greater_0_conv)
apply(simp add:pre_Release_inv_def Q_lemmas Q_basic_lemmas R_owns_no_bytes_def pre_dequeue_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def tempR_describes_ownB_def)
defer
apply(simp add:pre_Release_inv_def Q_lemmas Q_basic_lemmas Tail_and_ownB_idleR_def R_owns_no_bytes_def pre_dequeue_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def tempR_describes_ownB_def)
defer
apply(case_tac "q s=[]", simp_all) apply(case_tac "ownT s = Q", simp_all)
apply(simp add:pre_Read_inv_def Q_lemmas Q_basic_lemmas Tail_and_ownB_idleR_def R_owns_no_bytes_def pre_dequeue_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def tempR_describes_ownB_def)
apply(intro conjI impI)
apply (metis Nat.add_0_right hd_conv_nth length_greater_0_conv)
apply (metis Nat.add_0_right hd_conv_nth length_greater_0_conv)
apply (metis diff_is_0_eq' le_trans length_0_conv not_less_eq_eq)
apply (metis diff_is_0_eq' le_trans length_0_conv not_less_eq_eq)
apply (metis length_greater_0_conv plus_nat.add_0)
apply (metis bot_nat_0.extremum hd_conv_nth length_greater_0_conv list.size(3) snd_conv)
apply clarify
apply(subgoal_tac "fst(hd(q s)) =fst(q s!0) \<and> fst(hd(tl(q s))) =fst(q s!1)")
apply (metis (no_types, lifting) One_nat_def bot_nat_0.not_eq_extremum hd_conv_nth length_0_conv length_tl less_one zero_less_diff)
apply (metis (no_types, lifting) One_nat_def bot_nat_0.not_eq_extremum hd_conv_nth length_0_conv nth_tl)
apply clarify
apply(subgoal_tac "\<forall>i.(i<(length(q s) -1))\<longrightarrow> fst(tl(q s)!i) = fst(q s!(i+1))") prefer 2
apply (metis Suc_eq_plus1 length_tl nth_tl) apply(subgoal_tac "fst(hd(q s)) = fst(q s!0)") prefer 2
apply (metis hd_conv_nth)
apply simp
apply (simp add: assms(4) peculiar_17)
defer
apply (metis Nat.add_0_right hd_conv_nth length_greater_0_conv)
apply (metis Nat.add_0_right hd_conv_nth length_greater_0_conv)
apply(simp add:Q_describes_T_def T_is_outside_Q_def)
apply clarify
apply(subgoal_tac "\<forall>i.(i<length(q s) \<and> i>0)\<longrightarrow>(q s!i) = (tl(q s)!(i-1))") prefer 2
apply (meson Q_tail_props)
apply(subgoal_tac "fst(hd(q s)) =0 \<longrightarrow> (\<forall>i.(i<(length(q s)-1) \<and> i>0)\<longrightarrow>fst(q s!i) = end(q s!(i-1)))") prefer 2
apply (metis (no_types, lifting) One_nat_def Suc_less_eq bot_nat_0.not_eq_extremum diff_less_Suc end_simp hd_conv_nth length_greater_0_conv less_trans_Suc)
apply(subgoal_tac "(\<forall>i<length (q s). fst (q s ! i) + Data s (numReads s + i) < T s)") prefer 2
apply (metis (no_types, lifting) less_numeral_extra(3)) apply clarify
apply (metis (no_types, lifting) One_nat_def Suc_eq_plus1 length_tl less_diff_conv nth_tl)
apply (meson Q_describes_T_def)
apply(simp add:Tail_and_ownB_not_idleR_1_def Q_describes_T_def T_is_outside_Q_def)
apply clarify apply(intro conjI impI)
apply (metis (no_types, lifting) hd_in_set less_Suc_eq not_less_eq prod.collapse)
apply (metis (no_types, lifting) bot_nat_0.not_eq_extremum diff_less length_greater_0_conv lessI)
defer
apply (meson list.set_sel(2))
apply(simp add:pre_Read_inv_def Q_lemmas Q_basic_lemmas Tail_and_ownB_idleR_def R_owns_no_bytes_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def tempR_describes_ownB_def)
apply (simp add: pre_dequeue_inv_def)
apply(simp add:pre_Read_inv_def Q_lemmas Q_basic_lemmas Tail_and_ownB_idleR_def R_owns_no_bytes_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def tempR_describes_ownB_def)
apply (intro conjI impI)
apply(simp add:pre_Release_inv_def Q_lemmas Q_basic_lemmas Q_describes_T_def T_is_outside_Q_def R_owns_no_bytes_def pre_Read_inv_def)
apply (metis Nat.add_0_right hd_conv_nth length_greater_0_conv)
apply metis
apply (metis (no_types, hide_lams))
apply(simp add:T_is_outside_Q_def Tail_and_ownB_not_idleR_1_def)
apply(simp add:T_is_outside_Q_def Tail_and_ownB_not_idleR_1_def Tail_and_ownB_not_idleR_2_def)
apply(simp add:T_is_outside_Q_def Tail_and_ownB_not_idleR_1_def Tail_and_ownB_not_idleR_2_def)
(*expands it*)
apply(simp add:pre_Release_inv_def Tail_and_ownB_not_idleR_1_def Tail_and_ownB_idleR_def)
apply clarify apply(intro conjI impI)
apply (simp add:tempR_describes_T_def T_is_outside_Q_def) apply clarify
sledgehammer
apply(subgoal_tac "T s=fst(tempR s)")
apply blast apply(simp add:tempR_describes_T_def)
apply(subgoal_tac "fst(tempR s) =0") prefer 2
apply blast
apply(subgoal_tac "T s=fst(tempR s)\<longrightarrow>(\<not>T_is_outside_Q s)") prefer 2
apply (metis zero_less_iff_neq_zero)
apply(simp add:T_is_outside_Q_def)
sledgehammer
defer
apply(simp add:pre_Release_inv_def)
apply(simp add:pre_dequeue_inv_def)
apply(intro conjI impI)
sledgehammer
oops
lemma inv_holds_for_R:
assumes "con_assms s"
and "pcr = pcR s"
and "pre_R pcr s"
and "inv s"
and "cR_step pcr s s'"
shows "inv s'"
using assms apply(simp add:inv_def Q_structure_def cR_step_def)
apply(case_tac "pcR s", simp_all)
apply(case_tac "tR s \<noteq> fst (tempR s)", simp_all)
apply(case_tac "ownT s = R", simp_all)
apply(intro conjI impI)
apply(simp add:pre_R_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_basic_lemmas pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_holds_bytes_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply clarify apply(intro conjI impI)
apply (metis (no_types, lifting) less_Suc_eq not_less_eq)
apply (metis F.distinct(7))
apply(simp add:pre_R_def Q_reflects_writes_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_elem_size_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_reflects_ownD_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_basic_lemmas pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(case_tac "ownT s = R", simp_all)
apply(simp add:pre_R_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(intro conjI impI)
apply(simp add:pre_R_def Q_basic_lemmas pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_holds_bytes_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_reflects_writes_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_elem_size_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_reflects_ownD_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(intro conjI impI)
apply(simp add:Q_basic_struct_def Q_boundness_def pre_R_def pre_Release_inv_def)
apply(simp add:Q_basic_struct_def Q_boundness_def pre_R_def pre_Release_inv_def)
apply(simp add:Q_basic_struct_def Q_boundness_def pre_R_def pre_Release_inv_def)
apply(simp add:pre_R_def Q_basic_lemmas pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_holds_bytes_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_reflects_writes_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_elem_size_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_reflects_ownD_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(case_tac " q s = []", simp_all) apply(case_tac "ownT s = Q", simp_all)
apply(intro conjI impI)
apply (metis Suc_diff_Suc Suc_pred length_greater_0_conv old.nat.inject zero_less_diff)
apply (metis diff_is_0_eq' le_trans length_0_conv not_less_eq_eq)
apply(simp add:Q_basic_struct_def Q_boundness_def pre_R_def pre_dequeue_inv_def)
apply(intro conjI impI)
apply (metis list.set_sel(2)) defer
apply(simp add:pre_R_def Q_offsets_differ_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(subgoal_tac "\<forall>i.(i<length(q s)\<and>i>0)\<longrightarrow>(tl(q s)!(i-1)) =(q s!i)") prefer 2
apply (simp add: Q_tail_props)
apply(subgoal_tac "\<forall>j.(j<length(q s)\<and>j>0)\<longrightarrow>fst(tl(q s)!(j-1)) =fst(q s!j)") prefer 2
apply (simp add: Q_tail_props) apply simp apply clarify
apply(subgoal_tac "fst(q s!i) =fst(q s!j)")
apply (smt (z3) Suc_less_eq diff_less_Suc less_trans_Suc)
using Q_offsets_differ_def
apply (smt (z3) add_diff_cancel_right' add_gr_0 less_diff_conv zero_less_Suc)
apply(simp add:pre_R_def Q_has_no_overlaps_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply (meson list.set_sel(2))
apply(simp add:pre_R_def Q_has_no_uroboros_def Q_has_no_overlaps_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(subgoal_tac "fst (last (tl (q s))) = fst(last(q s))") prefer 2
apply (metis last_tl)
apply(simp add:R_owns_no_bytes_def Q_offsets_differ_def Q_describes_T_def)
apply clarify using tail_preserves_Q_has_no_uroboros apply (simp add:Q_lemmas Q_basic_lemmas)
apply (metis (no_types, hide_lams) Zero_not_Suc add_Suc_right add_eq_self_zero butlast_tl last_tl length_pos_if_in_set less_natE list.sel(2) list.set_sel(2) list.size(3))
apply(simp add:pre_R_def)
apply(subgoal_tac "Q_structure s \<and>
pre_dequeue_inv s \<and>
q s\<noteq>[] \<and>
Q_dequeue s s' ") apply(unfold Q_dequeue_def) using Q_structure_preserved1
apply (smt (verit, ccfv_SIG) Q_basic_preserved2 Q_holds_bytes_def Q_structure_def off_def)
apply(intro conjI impI)
apply (metis Q_structure_def)
apply blast
apply blast
apply simp
apply(simp add:pre_R_def)
apply(subgoal_tac "Q_structure s \<and>
pre_dequeue_inv s \<and>
q s\<noteq>[] \<and>
Q_dequeue s s' ") apply(unfold Q_dequeue_def) using Q_structure_preserved1
apply (metis (no_types, lifting) Q_basic_preserved2 Q_reflects_writes_def Q_structure_def length_0_conv less_nat_zero_code off_def)
apply(intro conjI impI)
apply (metis Q_structure_def)
apply blast
apply blast apply simp
apply(simp add:pre_R_def)
apply(subgoal_tac "Q_structure s \<and>
pre_dequeue_inv s \<and>
q s\<noteq>[] \<and>
Q_dequeue s s' ") apply(unfold Q_dequeue_def) using Q_structure_preserved1
apply (metis (no_types, lifting) Q_basic_preserved2 Q_elem_size_def Q_structure_def length_0_conv less_nat_zero_code off_def)
apply(intro conjI impI)
apply (metis Q_structure_def)
apply blast
apply blast apply simp
apply(simp add:pre_R_def)
apply(subgoal_tac "Q_structure s \<and>
pre_dequeue_inv s \<and>
q s\<noteq>[] \<and>
Q_dequeue s s' ") apply(unfold Q_dequeue_def) using Q_structure_preserved1
apply (metis (no_types, lifting) Q_basic_preserved2 Q_reflects_ownD_def Q_structure_def end_simp length_0_conv less_nat_zero_code off_def)
apply(intro conjI impI)
apply (metis Q_structure_def)
apply blast
apply blast apply simp
apply(intro conjI impI) apply(simp add:pre_R_def)
apply (metis add.right_neutral add_Suc_right diff_diff_left)
apply (metis diff_is_0_eq' le_trans length_0_conv not_less_eq_eq)
apply(simp add:Q_basic_struct_def)
apply(intro conjI impI)
apply(simp add:pre_R_def Q_boundness_def)
apply (meson list.set_sel(2))
apply(simp add:pre_R_def)
apply(subgoal_tac "Q_structure s \<and>
pre_dequeue_inv s \<and>
q s\<noteq>[] \<and>
Q_dequeue s s' ")apply(unfold Q_dequeue_def) using Q_structure_preserved1
apply (smt (verit, ccfv_SIG) Q_basic_struct_def Q_dequeue_def Q_gap_structure_def Q_structure_def less_nat_zero_code list.size(3))
apply(intro conjI impI)
apply (meson Q_basic_struct_def Q_structure_def)
apply blast
apply blast apply simp
apply(simp add:pre_R_def)
apply(subgoal_tac "Q_structure s \<and>
pre_dequeue_inv s \<and>
q s\<noteq>[] \<and>
Q_dequeue s s' ")apply(unfold Q_dequeue_def) using Q_structure_preserved1
apply (metis (no_types, lifting) Q_basic_struct_def Q_dequeue_def Q_offsets_differ_def Q_structure_def length_0_conv less_nat_zero_code)
apply(intro conjI impI)
apply (meson Q_basic_struct_def Q_structure_def)
apply blast
apply blast apply simp
apply(simp add:pre_R_def Q_has_no_overlaps_def)
apply (meson list.set_sel(2))
apply(simp add:pre_R_def Q_has_no_uroboros_def pre_dequeue_inv_def)
apply(simp add:pre_R_def pre_dequeue_inv_def Q_holds_bytes_def)
apply(simp add:pre_R_def pre_dequeue_inv_def Q_reflects_writes_def)
apply(simp add:pre_R_def pre_dequeue_inv_def Q_elem_size_def)
apply(simp add:pre_R_def pre_dequeue_inv_def Q_reflects_ownD_def)
prefer 2
defer
apply(simp add:pre_R_def pre_Read_inv_def)
apply(intro conjI impI)
apply (metis F.distinct(5) Suc_le_eq le_Suc_ex trans_less_add1)
apply (metis F.distinct(5) Suc_leI le_neq_implies_less not_less_eq_eq)
apply(simp add:Q_basic_lemmas)
apply(simp add:Q_lemmas)
apply(simp add:Q_lemmas)
apply(simp add:Q_lemmas)
apply(simp add:Q_lemmas)
apply(subgoal_tac "Q_structure s \<and>
pre_dequeue_inv s \<and>
q s\<noteq>[] \<and>
Q_dequeue s s' ")apply(unfold Q_dequeue_def) using Q_structure_preserved1
apply (smt (verit, ccfv_SIG) Q_basic_struct_def Q_dequeue_def Q_gap_structure_def Q_structure_def less_nat_zero_code list.size(3))
apply(intro conjI impI)
apply (meson Q_basic_struct_def Q_structure_def)
apply (meson RingBuffer.inv_def assms(4))
apply (meson RingBuffer.inv_def assms(4))
apply (meson RingBuffer.inv_def assms(4))
apply(simp add:pre_dequeue_inv_def)
apply(simp add:pre_dequeue_inv_def)
apply blast
apply(clarify)
apply(subgoal_tac "fst(q s!0) =0\<longrightarrow>(\<forall>i.(i<length(q s)\<and>i>0 \<and> length(q s)>1)\<longrightarrow>
fst(q s!i)\<noteq>0)") prefer 2
apply (metis (no_types, hide_lams) peculiar_4)
by simp
lemma local_pre_W:
assumes "con_assms s"
and "pcw = pcW s"
and "pre_W pcw s"
and "inv s"
and "cW_step pcw s s'"
shows "pre_W (pcW s') s'"
sorry
lemma inv_holds_for_R:
assumes "con_assms s"
and "pcr = pcR s"
and "pre_R pcr s"
and "inv s"
and "cR_step pcr s s'"
shows "inv s'"
using assms apply(simp add:inv_def Q_structure_def cR_step_def)
apply(case_tac "pcR s", simp_all)
apply(case_tac "tR s \<noteq> fst (tempR s)", simp_all)
apply(case_tac "ownT s = R", simp_all)
apply(intro conjI impI)
apply(simp add:pre_R_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_basic_lemmas pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_holds_bytes_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply clarify apply(intro conjI impI)
apply (metis (no_types, lifting) less_Suc_eq not_less_eq)
apply (metis F.distinct(7))
apply(simp add:pre_R_def Q_reflects_writes_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_elem_size_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_reflects_ownD_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_basic_lemmas pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(case_tac "ownT s = R", simp_all)
apply(simp add:pre_R_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(intro conjI impI)
apply(simp add:pre_R_def Q_basic_lemmas pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_holds_bytes_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_reflects_writes_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_elem_size_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_reflects_ownD_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(intro conjI impI)
apply(simp add:Q_basic_struct_def Q_boundness_def pre_R_def pre_Release_inv_def)
apply(simp add:Q_basic_struct_def Q_boundness_def pre_R_def pre_Release_inv_def)
apply(simp add:Q_basic_struct_def Q_boundness_def pre_R_def pre_Release_inv_def)
apply(simp add:pre_R_def Q_basic_lemmas pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_holds_bytes_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_reflects_writes_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_elem_size_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(simp add:pre_R_def Q_reflects_ownD_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(case_tac " q s = []", simp_all) apply(case_tac "ownT s = Q", simp_all)
apply(intro conjI impI)
apply (metis Suc_diff_Suc Suc_pred length_greater_0_conv old.nat.inject zero_less_diff)
apply (metis diff_is_0_eq' le_trans length_0_conv not_less_eq_eq)
apply(simp add:Q_basic_struct_def Q_boundness_def pre_R_def pre_dequeue_inv_def)
apply(intro conjI impI)
apply (metis list.set_sel(2)) defer
apply(simp add:pre_R_def Q_offsets_differ_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(subgoal_tac "\<forall>i.(i<length(q s)\<and>i>0)\<longrightarrow>(tl(q s)!(i-1)) =(q s!i)") prefer 2
apply (simp add: Q_tail_props)
apply(subgoal_tac "\<forall>j.(j<length(q s)\<and>j>0)\<longrightarrow>fst(tl(q s)!(j-1)) =fst(q s!j)") prefer 2
apply (simp add: Q_tail_props) apply simp apply clarify
apply(subgoal_tac "fst(q s!i) =fst(q s!j)")
apply (smt (z3) Suc_less_eq diff_less_Suc less_trans_Suc)
using Q_offsets_differ_def
apply (smt (z3) add_diff_cancel_right' add_gr_0 less_diff_conv zero_less_Suc)
apply(simp add:pre_R_def Q_has_no_overlaps_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply (meson list.set_sel(2))
apply(simp add:pre_R_def Q_has_no_uroboros_def Q_has_no_overlaps_def tempR_describes_ownB_def pre_Release_inv_def tempR_lemmas tempR_basic_lemmas tempR_describes_T_def T_is_outside_Q_def)
apply(subgoal_tac "fst (last (tl (q s))) = fst(last(q s))") prefer 2
apply (metis last_tl)
apply(simp add:R_owns_no_bytes_def Q_offsets_differ_def Q_describes_T_def)
apply clarify using tail_preserves_Q_has_no_uroboros apply (simp add:Q_lemmas Q_basic_lemmas)
apply (metis (no_types, hide_lams) Zero_not_Suc add_Suc_right add_eq_self_zero butlast_tl last_tl length_pos_if_in_set less_natE list.sel(2) list.set_sel(2) list.size(3))
apply(simp add:pre_R_def)
apply(subgoal_tac "Q_structure s \<and>
pre_dequeue_inv s \<and>
q s\<noteq>[] \<and>
Q_dequeue s s' ") apply(unfold Q_dequeue_def) using Q_structure_preserved1
apply (smt (verit, ccfv_SIG) Q_basic_preserved2 Q_holds_bytes_def Q_structure_def off_def)
apply(intro conjI impI)
apply (metis Q_structure_def)
apply blast
apply blast
apply simp
apply(simp add:pre_R_def)
apply(subgoal_tac "Q_structure s \<and>
pre_dequeue_inv s \<and>
q s\<noteq>[] \<and>
Q_dequeue s s' ") apply(unfold Q_dequeue_def) using Q_structure_preserved1
apply (metis (no_types, lifting) Q_basic_preserved2 Q_reflects_writes_def Q_structure_def length_0_conv less_nat_zero_code off_def)
apply(intro conjI impI)
apply (metis Q_structure_def)
apply blast
apply blast apply simp
apply(simp add:pre_R_def)
apply(subgoal_tac "Q_structure s \<and>
pre_dequeue_inv s \<and>
q s\<noteq>[] \<and>
Q_dequeue s s' ") apply(unfold Q_dequeue_def) using Q_structure_preserved1
apply (metis (no_types, lifting) Q_basic_preserved2 Q_elem_size_def Q_structure_def length_0_conv less_nat_zero_code off_def)
apply(intro conjI impI)
apply (metis Q_structure_def)
apply blast
apply blast apply simp
apply(simp add:pre_R_def)
apply(subgoal_tac "Q_structure s \<and>
pre_dequeue_inv s \<and>
q s\<noteq>[] \<and>
Q_dequeue s s' ") apply(unfold Q_dequeue_def) using Q_structure_preserved1
apply (metis (no_types, lifting) Q_basic_preserved2 Q_reflects_ownD_def Q_structure_def end_simp length_0_conv less_nat_zero_code off_def)
apply(intro conjI impI)
apply (metis Q_structure_def)
apply blast
apply blast apply simp
apply(intro conjI impI) apply(simp add:pre_R_def)
apply (metis add.right_neutral add_Suc_right diff_diff_left)
apply (metis diff_is_0_eq' le_trans length_0_conv not_less_eq_eq)
apply(simp add:Q_basic_struct_def)
apply(intro conjI impI)
apply(simp add:pre_R_def Q_boundness_def)
apply (meson list.set_sel(2))
apply(simp add:pre_R_def)
apply(subgoal_tac "Q_structure s \<and>
pre_dequeue_inv s \<and>
q s\<noteq>[] \<and>
Q_dequeue s s' ")apply(unfold Q_dequeue_def) using Q_structure_preserved1
apply (smt (verit, ccfv_SIG) Q_basic_struct_def Q_dequeue_def Q_gap_structure_def Q_structure_def less_nat_zero_code list.size(3))
apply(intro conjI impI)
apply (meson Q_basic_struct_def Q_structure_def)
apply blast
apply blast apply simp
apply(simp add:pre_R_def)
apply(subgoal_tac "Q_structure s \<and>
pre_dequeue_inv s \<and>
q s\<noteq>[] \<and>
Q_dequeue s s' ")apply(unfold Q_dequeue_def) using Q_structure_preserved1
apply (metis (no_types, lifting) Q_basic_struct_def Q_dequeue_def Q_offsets_differ_def Q_structure_def length_0_conv less_nat_zero_code)
apply(intro conjI impI)
apply (meson Q_basic_struct_def Q_structure_def)
apply blast
apply blast apply simp
apply(simp add:pre_R_def Q_has_no_overlaps_def)
apply (meson list.set_sel(2))
apply(simp add:pre_R_def Q_has_no_uroboros_def pre_dequeue_inv_def)
apply(simp add:pre_R_def pre_dequeue_inv_def Q_holds_bytes_def)
apply(simp add:pre_R_def pre_dequeue_inv_def Q_reflects_writes_def)
apply(simp add:pre_R_def pre_dequeue_inv_def Q_elem_size_def)
apply(simp add:pre_R_def pre_dequeue_inv_def Q_reflects_ownD_def)
prefer 2
defer
apply(simp add:pre_R_def pre_Read_inv_def)
apply(intro conjI impI)
apply (metis F.distinct(5) Suc_le_eq le_Suc_ex trans_less_add1)
apply (metis F.distinct(5) Suc_leI le_neq_implies_less not_less_eq_eq)
apply(simp add:Q_basic_lemmas)
apply(simp add:Q_lemmas)
apply(simp add:Q_lemmas)
apply(simp add:Q_lemmas)
apply(simp add:Q_lemmas)
apply(subgoal_tac "Q_structure s \<and>
pre_dequeue_inv s \<and>
q s\<noteq>[] \<and>
Q_dequeue s s' ")apply(unfold Q_dequeue_def) using Q_structure_preserved1
apply (smt (verit, ccfv_SIG) Q_basic_struct_def Q_dequeue_def Q_gap_structure_def Q_structure_def less_nat_zero_code list.size(3))
apply(intro conjI impI)
apply (meson Q_basic_struct_def Q_structure_def)
apply (meson RingBuffer.inv_def assms(4))
apply (meson RingBuffer.inv_def assms(4))
apply (meson RingBuffer.inv_def assms(4))
apply (meson RingBuffer.inv_def assms(4))
apply(simp add:pre_dequeue_inv_def)
apply blast
apply(clarify)
apply(subgoal_tac "fst(q s!0) =0\<longrightarrow>(\<forall>i.(i<length(q s)\<and>i>0 \<and> length(q s)>1)\<longrightarrow>
fst(q s!i)\<noteq>0)") prefer 2
apply (metis (no_types, hide_lams) peculiar_4)
by simp
lemma global_pre_R:
assumes "con_assms s"
and "pcr = pcR s"
and "pcw = pcW s"
and "pre_R pcr s"
and "pre_W pcw s"
and "inv s"
and "cW_step pcw s s'"
shows "pre_R (pcR s') s'"
sorry
lemma inv_holds_for_W:
assumes "con_assms s"
and "pcw = pcW s"
and "pre_W pcw s"
and "inv s"
and "cW_step pcw s s'"
shows "inv s'"
apply(simp add:inv_def Q_structure_def)
sorry
lemma global_pre_W:
assumes "con_assms s"
and "pcr = pcR s"
and "pcw = pcW s"
and "pre_R pcr s"
and "pre_W pcw s"
and "inv s"
and "cR_step pcr s s'"
shows "pre_W (pcW s') s'"
sorry
(*
preP \<and> preQ preP \<and> inv
P P
preQ inv
preP \<and> preQ preQ \<and> inv
Q Q
preP inv
preP
p
postP
preQ
Q
postQ
*)
lemma inv_init:
assumes "init s"
and "con_assms s"
shows "inv \<and> preR \<and> preW"
using assms
apply simp_all
apply (simp_all add: inv_def Q_lemmas)
apply(intro conjI impI)
oops
(*(*
(*------------------------showing progress----------------------*)
(*
lemma tries_are_bounded:
assumes "con_assms s"
and "cW_step pcw s s'"
and "inv pcw pcr s"
shows "tries s'\<le>N"
using assms
apply (simp_all add:cW_step_def)
using less_le_trans apply auto[1]
apply (case_tac "pcw", simp_all)
using less_imp_le_nat apply blast
using less_imp_le_nat apply blast
using less_imp_le_nat apply blast
using less_imp_le_nat apply blast
using less_imp_le_nat apply blast
using less_imp_le_nat apply blast
using less_imp_le_nat apply blast
using less_imp_le_nat apply blast
apply(case_tac "numEnqs s < n", simp_all add:less_imp_le)
apply(case_tac "tW s \<noteq> T s", simp_all)
using Suc_leI apply blast
by (meson less_imp_le_nat)
lemma when_W_moves_prog_less:
assumes "con_assms s"
and "inv (pcW s) (pcR s) s"
and "cW_step (pcW s) s s'"
shows "lex_prog s s'"
proof -
from assms(1) have sp1: "numEnqs s \<le> n \<and> numDeqs s \<le> n"
using con_assms_def by auto
from assms show ?thesis
apply (simp_all add:cW_step_def inv_def progress_lemmas tries_left_def)
apply(case_tac "pcW s", simp_all)
apply(case_tac[!] "pcR s", simp_all)
apply (simp_all add: diff_less_mono2)
apply (case_tac[!] "tW s = T s", simp_all add:cW_step_def)
apply(case_tac[1-6] "numEnqs s < n", simp_all)
using diff_less_mono2 by auto
qed
lemma W_counter_implies_notown:
assumes "con_assms s"
and "mainInv s"
shows "\<forall>i.(i<numEnqs s)\<longrightarrow>ownD s i \<in> {R,B}"
using assms
apply (simp_all add:inv_def)
by (meson le_less_linear)
lemma least_prog_W_implies:
assumes "con_assms s"
and "inv (pcW s) pcr s"
and "cW_step (pcW s) s s'"
and "inv (pcW s') pcr s'"
and "lex_prog s s'"
shows "end_W_prog s'=True\<longrightarrow>end_W_prog s \<or> ((\<forall>i.(i<n)\<longrightarrow>ownD s' i\<noteq>W) \<and> (pcW s=idleW) \<and> numEnqs s=n)"
using assms W_counter_implies_notown
apply (simp_all add: end_W_prog_def progress_lemmas tries_left_def cW_step_def inv_def)
apply (case_tac "pcW s", simp_all)
apply(case_tac "numEnqs s < n", simp_all)
apply(case_tac "pcr", simp_all)
apply (metis F.distinct(1) F.distinct(5) le_less_linear)
apply (metis F.distinct(1) F.distinct(5) le_less_linear)
apply (metis F.distinct(1) F.distinct(5) le_less_linear)
by(case_tac "tW s \<noteq> T s", simp_all)
lemma when_R_moves_prog_less:
assumes "con_assms s"
and "inv (pcW s) (pcR s) s"
and "cR_step (pcR s) s s'"
shows "lex_prog s s'"
using assms apply (simp_all add:inv_def cR_step_def progress_lemmas)
apply(case_tac "pcR s", simp_all add:tries_left_def)
apply(case_tac[!] "pcW s", simp_all)
apply(case_tac[!] "q s=[]", simp_all add: Let_def)
apply clarify
oops
apply(case_tac " T s < fst (hd (q s)) + snd (hd (q s))", simp_all)
apply(case_tac " T s < fst (hd (q s)) + snd (hd (q s))", simp_all)
apply (metis (no_types, lifting) add_less_mono diff_less_mono2 diff_self_eq_0 length_greater_0_conv lessI less_le_trans mult_2 nat_add_left_cancel_less nat_less_le)
apply (metis (no_types, lifting) add_less_mono diff_less_mono2 diff_self_eq_0 length_greater_0_conv lessI less_le_trans mult_2 nat_add_left_cancel_less nat_less_le)
apply(case_tac " T s < fst (hd (q s)) + snd (hd (q s))", simp_all)
apply (metis diff_less_mono2 length_greater_0_conv lessI zero_less_diff)
apply (metis diff_less_mono2 diff_self_eq_0 le_eq_less_or_eq length_0_conv lessI)
sorry
lemma least_prog_R_implies:
assumes "con_assms s"
and "inv (pcW s) (pcR s) s"
and "cR_step (pcR s) s s'"
and "inv (pcW s) (pcR s) s'"
and "lex_prog s s'"
shows "end_R_prog s'=True\<longrightarrow>(end_R_prog s \<or> ((\<forall>i.(i<n)\<longrightarrow>ownD s' i=R) \<and> pcR s=Release))\<and>end_W_prog s"
using assms apply (simp_all add: end_R_prog_def end_W_prog_def tries_left_def cR_step_def inv_def)
apply(case_tac "pcR s", simp_all)
by(case_tac "q s=[]", simp_all add:Let_def)
lemma initial_progress:
assumes "cR_step (pcR s) s s' \<or> cW_step (pcW s) s s'"
and "inv (pcW s) (pcR s) s"
and "init s'"
and "con_assms s"
shows "lex_prog s s'\<longrightarrow>s=s'"
using assms apply(simp_all add:cR_step_def cW_step_def init_def progress_lemmas tries_left_def inv_def)
apply(case_tac "pcR s", simp_all)
apply(case_tac "pcW s", simp_all)
apply (metis add.commute add_less_mono diff_less less_le_trans less_nat_zero_code mult.commute mult_2_right nat_le_iff_add order_less_irrefl zero_less_iff_neq_zero)
apply (metis add.commute add_cancel_right_left add_cancel_right_right add_is_0 diff_less diff_zero le_iff_add length_0_conv length_greater_0_conv less_add_eq_less less_irrefl_nat less_le_trans mult.commute mult_2_right nat_diff_split zero_less_iff_neq_zero)
apply (metis (no_types, hide_lams) add.commute diff_less le_iff_add le_less_trans less_eq_nat.simps(1) less_le_trans mult.commute mult_2_right order_less_irrefl trans_less_add2)
apply (metis add.commute add_strict_mono diff_less le_iff_add less_le_trans less_nat_zero_code less_not_refl mult.commute mult_2_right zero_less_iff_neq_zero)
apply (metis add_is_0 diff_diff_cancel diff_le_self nat_0_less_mult_iff nat_less_le not_le zero_less_diff zero_less_numeral)
apply (metis add.commute diff_less le0 le_less_trans less_le_trans mult.commute mult_2_right nat_le_iff_add order_less_irrefl trans_less_add2)
apply (metis add.commute diff_less le_iff_add le_less_trans less_eq_nat.simps(1) less_le_trans less_not_refl mult.commute mult_2_right trans_less_add2)
apply (metis add.commute diff_less le0 le_less_trans less_le_trans less_not_refl mult.commute mult_2_right nat_le_iff_add trans_less_add1)
apply (metis add.commute add_cancel_right_right diff_less gr_implies_not0 le0 le_iff_add le_less_trans le_neq_implies_less less_add_eq_less less_le_trans mult.commute mult_2_right order_less_irrefl zero_le)
apply (metis add_is_0 diff_diff_cancel diff_self_eq_0 nat_0_less_mult_iff nat_less_le zero_less_diff zero_less_numeral)
apply (metis add.commute diff_less le_iff_add le_less_trans less_le_trans mult.commute mult_2_right order_less_irrefl trans_less_add2 zero_le)
apply (metis diff_add_zero diff_diff_cancel less_numeral_extra(3) mult_2)
apply (metis add.commute diff_less le_iff_add less_le_trans mult.commute mult_2_right order_less_irrefl)
apply (metis add.commute diff_less le_iff_add less_le_trans less_not_refl mult.commute mult_2_right)
apply (simp add: leD)
by (simp add: leD)
(*--------------------------------------------------------------*)
(*--------------lexicographical progress------------------------------*)
definition "ltpcW i j \<equiv>
(i \<noteq> j \<and>
(i=FinishedW)
\<or>(i \<in> {Enqueue, OOM, BTS} \<and> j\<noteq>FinishedW)
\<or> (i \<in> {A8, Write} \<and> j \<notin> {Enqueue, OOM, BTS, FinishedW})
\<or> (i \<in> {A6, A7} \<and> j \<in> {idleW, A1, A2, A3, A4, A5})
\<or> (i \<in> {A3, A4, A5} \<and> j \<in> {idleW, A1, A2})
\<or> (i = A2 \<and> j \<in> {idleW, A1})
\<or> (i = A1 \<and> j = idleW))
"
definition "ltpcR i j \<equiv>
i = idleR \<and> j =Release \<or> i=Release \<and> j=Read \<or> i=Read \<and> j=idleR"
definition "state_pv s \<equiv> (2*n - numEnqs s - numDeqs s)"
definition "tries_left s \<equiv> N-tries s"
definition "lex_prog s s' \<equiv> s = s' \<or>
(state_pv s' < state_pv s
\<or> (state_pv s' = state_pv s \<and> tries_left s' < tries_left s)
\<or> (state_pv s' = state_pv s \<and> tries_left s' = tries_left s \<and> ltpcR (pcR s') (pcR s))
\<or> (state_pv s' = state_pv s \<and> tries_left s' = tries_left s \<and> ltpcW (pcW s') (pcW s)))"
lemmas progress_lemmas = ltpcW_def ltpcR_def state_pv_def lex_prog_def
definition "end_W_prog s \<equiv> ((n-numEnqs s)=0) \<and> tries_left s=N \<and> pcW s=FinishedW"
definition "end_R_prog s \<equiv> end_W_prog s\<and> pcR s=idleR \<and> numDeqs s=numEnqs s"
definition "start_state_prog s\<equiv> state_pv s=2*n \<and> pcR s=idleR \<and> pcW s=idleW \<and> tries_left s=N"
*)
(*
\<and> right_to_addresses s
\<and> no_ownB s
\<and> H_T_ownB s
\<and> Buff_entries_transfer_numDeqs s*)*)*)
(*
definition "last_q s \<equiv> (q s!(length(q s)-1))"
definition "last_q_sum s \<equiv> fst(last_q s)+snd(last_q s)"
definition "tempR_sum s \<equiv> fst(tempR s)+snd(tempR s)"
definition "case_1 s \<equiv> (H s=T s \<and> pcR s=idleR \<and> pcW s\<in>W_pre_acquire_set \<and> q s=[]
\<and> (\<forall>j.(j\<ge>0\<and>j<N)\<longrightarrow>ownB s j=B))"
definition "case_2 s \<equiv> (H s>T s \<and> pcR s=idleR \<and> pcW s\<in>W_post_acquire_set \<and> q s\<noteq>[]
\<and>(\<forall>j.(j\<ge>H s\<and>j<N\<or>j<T s)\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.(j\<ge>hW s\<and>j<H s)\<longrightarrow>ownB s j=W)
\<and>(\<forall>j.(j\<ge>T s\<and>j<last_q_sum s)\<longrightarrow>ownB s j=Q)
\<and>(last_q_sum s =hW s))"
definition "case_3 s \<equiv> (H s>T s \<and> pcR s\<noteq>idleR \<and> pcW s\<in>W_post_acquire_set \<and> q s\<noteq>[]
\<and>(\<forall>j.((j\<ge>H s\<and> j<N)\<or>(j\<ge>0\<and>j<T s))\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.(j\<ge>hW s\<and> j<H s)\<longrightarrow>ownB s j=W)
\<and>(\<forall>j.(j\<ge>tempR_sum s\<and> j<last_q_sum s)\<longrightarrow>ownB s j=Q)
\<and>(\<forall>j.(j\<ge>T s\<and>j<tempR_sum s)\<longrightarrow>ownB s j=R)
\<and>(last_q_sum s =hW s)
\<and>(tempR_sum s = fst(q s!0))
\<and>(T s=fst(tempR s)))"
definition "case_4 s \<equiv> (H s>T s \<and> pcR s\<noteq>idleR \<and> pcW s\<in>W_pre_acquire_set \<and> q s\<noteq>[]
\<and>(\<forall>j.((j\<ge>H s\<and>j<N)\<or>(j\<ge>0\<and>j<T s))\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.(j\<ge>tempR_sum s\<and> j<last_q_sum s)\<longrightarrow>ownB s j=Q)
\<and>(\<forall>j.(j\<ge>T s\<and>j<tempR_sum s)\<longrightarrow>ownB s j=R)
\<and>(tempR_sum s = fst(q s!0))
\<and>(T s=fst(tempR s)))"
definition "case_5 s \<equiv> (H s<T s \<and> pcR s=idleR \<and> pcW s\<in>W_pre_acquire_set \<and> q s\<noteq>[]
\<and>(\<forall>j.(j\<ge>H s\<and>j<T s)\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.((j\<ge>T s\<and> j<N)\<or>(j\<ge>0\<and>j<H s))\<longrightarrow>ownB s j=Q)
\<and> H s=last_q_sum s)"
definition "case_6 s \<equiv>(H s<T s \<and> pcR s\<noteq>idleR \<and> pcW s\<in>W_pre_acquire_set \<and> q s\<noteq>[]
\<and>(\<forall>j.(j\<ge>H s\<and> j<T s)\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.((j\<ge>tempR_sum s \<and> j<N)\<or>(j\<ge>0 \<and> j<H s))\<longrightarrow>ownB s j=Q)
\<and>(\<forall>j.(j\<ge>T s\<and> j<tempR_sum s)\<longrightarrow>ownB s j=R)
\<and>(T s=fst(tempR s))
\<and>H s = last_q_sum s)"
definition "case_7 s \<equiv>(H s<T s \<and> pcR s\<noteq>idleR \<and> pcW s\<in>W_pre_acquire_set
\<and>(\<forall>j.(j\<ge>H s\<and> j<T s)\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.((j\<ge>tempR_sum s\<and> j<H s)\<or>(j\<ge>T s\<and> j<N))\<longrightarrow>ownB s j=Q)
\<and>(\<forall>j.(j\<ge>0 \<and> j<tempR_sum s)\<longrightarrow>ownB s j=R)
\<and>fst(tempR s) =0
\<and>T s\<noteq>fst(tempR s)
\<and>(q s\<noteq>[]\<longrightarrow>fst(q s!0) = tempR_sum s \<and> H s=last_q_sum s)
\<and>(q s=[]\<longrightarrow>H s =tempR_sum s))"
definition "case_8 s \<equiv>(H s<T s \<and> pcR s=idleR \<and> pcW s\<in>W_post_acquire_set \<and> q s\<noteq>[]
\<and>(\<forall>j.(j\<ge>H s\<and> j<T s)\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.(j\<ge>hW s\<and>j<H s)\<longrightarrow>ownB s j=W)
\<and>(\<forall>j.((j\<ge>T s\<and> j<N)\<or>(j\<ge>0\<and>j<last_q_sum s))\<longrightarrow>ownB s j=Q)
\<and>(hW s=last_q_sum s)
\<and>offset s=hW s)"
definition "case_9 s \<equiv>(H s<T s \<and> pcR s=idleR \<and> pcW s\<in>W_post_acquire_set \<and> q s\<noteq>[]
\<and>(\<forall>j.(j\<ge>H s\<and> j<T s)\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.((j\<ge>hW s\<and>j<N)\<or>(j\<ge>0 \<and>j<H s))\<longrightarrow>ownB s j=W)
\<and>(\<forall>j.(j\<ge>T s\<and> j<last_q_sum s)\<longrightarrow>ownB s j=Q)
\<and>offset s=0
\<and>last_q_sum s=hW s
\<and>T s=fst(q s!0))"
definition "case_10 s \<equiv>(H s<T s \<and> pcR s\<noteq>idleR \<and> pcW s\<in>W_post_acquire_set \<and> q s\<noteq>[]
\<and>(\<forall>j.(j\<ge>H s\<and> j<T s)\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.(j\<ge>hW s\<and>j<H s)\<longrightarrow>ownB s j=W)
\<and>(\<forall>j.((j\<ge>0\<and>j<last_q_sum s)\<or>(j\<ge>tempR_sum s\<and>j<N))\<longrightarrow>ownB s j=Q)
\<and>(\<forall>j.(j\<ge>T s\<and>j<tempR_sum s)\<longrightarrow>ownB s j=R)
\<and>T s=fst(tempR s)
\<and>last_q_sum s=hW s)"
definition "case_11 s \<equiv>(H s<T s \<and> pcR s\<noteq>idleR \<and> pcW s\<in>W_post_acquire_set \<and> q s\<noteq>[]
\<and>(\<forall>j.(j\<ge>H s\<and> j<T s)\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.(j\<ge>hW s\<and>j<H s)\<longrightarrow>ownB s j=W)
\<and>(\<forall>j.((j\<ge>tempR_sum s \<and>j<last_q_sum s)\<or>(j\<ge>T s\<and>j<N))\<longrightarrow>ownB s j=Q)
\<and>(\<forall>j.(j\<ge>0 \<and>j<tempR_sum s)\<longrightarrow>ownB s j=R)
\<and>fst(tempR s) =0
\<and>tempR_sum s=fst(q s!0)
\<and>last_q_sum s=hW s
\<and>T s\<noteq>fst(tempR s))"
definition "case_12 s \<equiv>(H s<T s \<and> pcR s\<noteq>idleR \<and> pcW s\<in>W_post_acquire_set \<and> q s\<noteq>[]
\<and>(\<forall>j.(j\<ge>H s\<and> j<T s)\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.(j\<ge>hW s\<and>j<H s)\<longrightarrow>ownB s j=W)
\<and>(\<forall>j.((j\<ge>tempR_sum s \<and>j<last_q_sum s)\<or>(j\<ge>T s\<and>j<N))\<longrightarrow>ownB s j=Q)
\<and>(\<forall>j.(j\<ge>0 \<and>j<tempR_sum s)\<longrightarrow>ownB s j=R)
\<and>fst(tempR s) =0
\<and>tempR_sum s=fst(q s!0)
\<and>last_q_sum s=hW s
\<and>T s\<noteq>fst(tempR s))"
definition "ownB_cases s \<equiv>
case_1 s
\<or>case_2 s
\<or>case_3 s
\<or>case_4 s
\<or>case_5 s
\<or>case_6 s
\<or>case_7 s
\<or>case_8 s
\<or>case_9 s
\<or>case_10 s
\<or>case_11 s
\<or>case_12 s"
definition "case_2_qempty s \<equiv>(H s>T s \<and> pcR s=idleR \<and> pcW s\<in>W_post_acquire_set \<and> q s=[]
\<and>(\<forall>j.(j\<ge>H s\<and>j<N\<or>j<T s)\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.(j\<ge>T s\<and>j<H s)\<longrightarrow>ownB s j=W)
\<and> offset s=T s
\<and>(hW s\<noteq>tW s \<longrightarrow>offset s=hW s)
\<and>(hW s=tW s\<longrightarrow>offset s=0))"
definition "case_3_qempty s \<equiv>(H s>T s \<and> pcR s\<noteq>idleR \<and> pcW s\<in>W_post_acquire_set \<and> q s=[]
\<and>(\<forall>j.((j\<ge>H s\<and> j<N)\<or>(j\<ge>0\<and>j<T s))\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.(j\<ge>hW s\<and> j<H s)\<longrightarrow>ownB s j=W)
\<and>(\<forall>j.(j\<ge>T s\<and>j<tempR_sum s)\<longrightarrow>ownB s j=R)
\<and>(tempR_sum s = hW s)
\<and>(T s=fst(tempR s)))"
definition "case_4_qempty s \<equiv>(H s>T s \<and> pcR s\<noteq>idleR \<and> pcW s\<in>W_pre_acquire_set \<and> q s=[]
\<and>(\<forall>j.((j\<ge>H s\<and>j<N)\<or>(j\<ge>0\<and>j<T s))\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.(j\<ge>T s\<and>j<tempR_sum s)\<longrightarrow>ownB s j=R)
\<and>H s=tempR_sum s
\<and>(T s=fst(tempR s)))"
definition "case_7_qempty s \<equiv>(H s<T s \<and> pcR s\<noteq>idleR \<and> pcW s\<in>W_pre_acquire_set \<and> q s=[]
\<and>(\<forall>j.(j\<ge>H s\<and> j<T s)\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.(j\<ge>T s\<and>j<N)\<longrightarrow>ownB s j=Q)
\<and>(\<forall>j.(j\<ge>0\<and> j<tempR_sum s)\<longrightarrow>ownB s j=R)
\<and>(T s\<noteq>fst(tempR s))
\<and>H s=tempR_sum s)"
definition "case_9_qempty s \<equiv>(H s<T s \<and> pcR s=idleR \<and> pcW s\<in>W_post_acquire_set \<and> q s=[]
\<and>(\<forall>j.(j\<ge>H s\<and> j<T s)\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.((j\<ge>T s\<and>j<N)\<or>(j\<ge>0 \<and>j<H s))\<longrightarrow>ownB s j=W)
\<and>offset s=0
\<and>T s=hW s)"
definition "case_11_qempty s \<equiv>(H s<T s \<and> pcR s=idleR \<and> pcW s\<in>W_post_acquire_set \<and> q s=[]
\<and>(\<forall>j.(j\<ge>H s\<and> j<T s)\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.((j\<ge>T s\<and>j<N)\<or>(j\<ge>0 \<and>j<H s))\<longrightarrow>ownB s j=W)
\<and>offset s=0
\<and>T s=hW s)"
definition "case_12_qempty s \<equiv>(H s<T s \<and> pcR s=idleR \<and> pcW s\<in>W_post_acquire_set \<and> q s=[]
\<and>(\<forall>j.(j\<ge>H s\<and> j<T s)\<longrightarrow>ownB s j=B)
\<and>(\<forall>j.((j\<ge>T s\<and>j<N)\<or>(j\<ge>0 \<and>j<H s))\<longrightarrow>ownB s j=W)
\<and>offset s=0
\<and>T s=hW s)"
definition "ownB_cases_qempty s \<equiv>
case_2_qempty s
\<or>case_3_qempty s
\<or>case_4_qempty s
\<or>case_7_qempty s
\<or>case_9_qempty s
\<or>case_11_qempty s
\<or>case_12_qempty s"
definition "pre_acq_cases s \<equiv> case_1 s \<or> case_4 s \<or> case_5 s \<or> case_6 s \<or> case_7 s
\<or> case_4_qempty s \<or>case_7_qempty s"
lemmas pre_acq_case_lemmas = pre_acq_cases_def case_1_def case_4_def case_5_def case_6_def
case_7_def case_4_qempty_def case_7_qempty_def
definition "post_acq_cases s \<equiv> case_2 s \<or> case_3 s \<or> case_8 s \<or> case_9 s \<or> case_10 s
\<or> case_11 s \<or> case_12 s \<or> case_2_qempty s
\<or> case_3_qempty s \<or> case_9_qempty s \<or> case_11_qempty s
\<or> case_12_qempty s"
lemmas post_acq_case_lemmas = post_acq_cases_def case_2_def case_3_def case_8_def case_9_def
case_10_def case_11_def case_12_def case_2_qempty_def
case_3_qempty_def case_9_qempty_def case_11_qempty_def
case_12_qempty_def
definition "pre_deq_cases s \<equiv> case_1 s \<or>case_2 s \<or>case_5 s \<or>case_8 s \<or>case_9 s
\<or>case_2_qempty s \<or>case_9_qempty s \<or>case_11_qempty s \<or>case_12_qempty s"
lemmas pre_deq_case_lemmas = pre_deq_cases_def case_1_def case_2_def case_5_def case_8_def
case_9_def case_2_qempty_def case_9_qempty_def
case_11_qempty_def case_12_qempty_def
definition "post_deq_cases s \<equiv> case_3 s \<or>case_4 s \<or>case_6 s \<or>case_7 s \<or>case_10 s \<or>case_11 s \<or>case_12 s
\<or>case_3_qempty s \<or>case_4_qempty s \<or>case_7_qempty s"
lemmas post_deq_case_lemmas = post_deq_cases_def case_3_def case_4_def case_6_def case_7_def case_11_def
case_10_def case_12_def case_3_qempty_def
case_4_qempty_def case_7_qempty_def
definition "all_cases s \<equiv>ownB_cases_qempty s \<or> ownB_cases s"
lemmas all_cases_lemmas = all_cases_def last_q_def last_q_sum_def tempR_sum_def
ownB_cases_qempty_def ownB_cases_def case_1_def
case_1_def case_2_def case_3_def case_4_def
case_5_def case_6_def case_7_def case_8_def
case_9_def case_10_def case_11_def case_12_def
case_2_qempty_def case_3_qempty_def case_4_qempty_def
case_7_qempty_def case_9_qempty_def case_11_qempty_def
case_12_qempty_def
*) |
lemma Lim_transform_within_set: fixes a :: "'a::metric_space" and l :: "'b::metric_space" shows "\<lbrakk>(f \<longlongrightarrow> l) (at a within S); eventually (\<lambda>x. x \<in> S \<longleftrightarrow> x \<in> T) (at a)\<rbrakk> \<Longrightarrow> (f \<longlongrightarrow> l) (at a within T)" |
function lambda = chow_eigenvalues ( alpha, beta, n )
%*****************************************************************************80
%
%% CHOW_EIGENVALUES returns the eigenvalues of the CHOW matrix.
%
% Example:
%
% ALPHA = 2, BETA = 3, N = 5
%
% 9.49395943
% 6.10991621
% 3.0
% 3.0
% 3.0
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 28 September 2007
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, real ALPHA, the ALPHA value. A typical value is 1.0.
%
% Input, real BETA, the BETA value. A typical value is 0.0.
%
% Input, integer N, the order of A.
%
% Output, real LAMBDA(N,1), the eigenvalues of A.
%
lambda = zeros ( n, 1 );
k = n - round ( ( n + 1 ) / 2 );
for i = 1 : k
angle = i * pi / ( n + 2 );
lambda(i,1) = beta + 4.0 * alpha * ( cos ( angle ) )^2;
end
lambda(k+1:n,1) = beta;
return
end
|
This chapter has been adapted from the paper in preparation titled \textit{The GALAH survey: Characterization of emission-line stars with spectral modelling using autoencoders} \cite{2020arXiv200603062C} whose first author is author of this Doctoral thesis. The used computer code is published on GitHub platform \footnote{\url{https://github.com/kcotar/GALAH-suervey-Emission-lines-and-autoencoders}} and results of the analysis as a catalogue on the VizieR service \footnote{\href{http://vizier.u-strasbg.fr/viz-bin/}{exact link will be available after the paper is published}}.
Among all machine learning approaches, neural network structures are receiving the highest interest in all fields of big data analysis in recent years. Astronomy is no exception in this regard. In previous Chapter \ref{chap:peculiars_chem} we saw that peculiar stars are commonly detected by comparing observed spectra with reference spectra of stars that do not show any peculiarities in them. In this chapter we explore the autoencoder structure that provides us with the reference spectra for the comparison. Whenever we are interested in the precise elemental abundances (as used in Chapter \ref{chap:clusters}), the first step in their determination of stellar physical parameters that could be based on the strongest hydrogen Balmer lines in stellar spectra. As any deviations in their shape might endanger the analysis, we tried to identify all stars whose spectrum shows emission-lines in the Balmer region. The chapter begins with Section \ref{sec:intro_emis} that gives a detailed description of the problem and presents multiple scenarios of why and how emission-lines can be used and identified. In Section \ref{sec:det_chart} we explain our analysis pipeline whose main components are the generation of reference spectra (Section \ref{sec:ref_modeling}) and identification of multiple emission features (Sections \ref{sec:hahbemis} and \ref{sec:nebularemis}). The temporal variability of detected emissions is analysed in Section \ref{sec:temporal}. The results are summarised and discussed in Section \ref{sec:discussion_emis}.
\section{Introduction}
\label{sec:intro_emis}
The identification of peculiar stars, whose spectra contain emission lines, is of interest to a wide field of stellar research. Spectral complexity of such stars brings insight into the ongoing physical processes on and around the star. Presence of emission lines hints to an optically thin material that surrounds a star. Such optically thin structures can be present at different evolutionary stages of the star. As those stages are temporally short compared to the stellar life span, they are regarded as peculiar at that time.
Emission features in stellar spectra might adversely impacted the quality of stellar parameters and abundances determined by automatic data analysis pipelines that are only configured to produce the best results for most common stellar types. Examples of how these features might compromise spectroscopic measurements when we assume that a star is not peculiar include the determination of effective temperature \cite{2011A&A...531A..83C, 2018A&A...615A.139A, 2019A&A...624A..10G}, computation of stellar mass \cite{2016ApJ...823..114N, 2016A&A...594A.120B}, and the effects of self broadening on line wing formation \cite{2000A&A...363.1091B, 2008A&A...480..581A}. Highly accurate measurement of the hydrogen absorption profiles are needed in those cases. Any deviations in the line shapes from model predictions would produce misleading results. We would therefore like to know if the investigated line is modified by additional, unmodelled physical process or spectral reduction process.
Stars with evident emission lines populate a wide variety of regions on the HR diagram. Because of possible overlaps between different stellar types, detailed photometric (especially in the infrared region where warm circumstellar dust disc can be identified) and spectroscopic observations are needed for an accurate physical explanation of the observed features. An examples of such work is presented in \citet{2019MNRAS.488.5536M}, who performed detailed a multi-band photometric study of an emission-line star, originally discovered on objective prism plates. The detailed photometric time-series study described in that work, together with observations of the star's infrared excess, led to the star VES~263 being identified as a massive pre-main-sequence star and not a semi-regular AGB cool giant as classified previously. In a similar way, \citet{2020arXiv200207852L} performed an analysis of the stellar object V* CN Cha, which had previously been identified as an emission star. By studying a long photometric time-series of the star, they concluded that the object was most likely a symbiotic binary star system whose emission was lined to a long-duration, low-luminosity nova phase.
Numerous different physical processes that can contribute to the complex shapes of the H$\alpha$ emission profile are discussed by \citet{1996A&AS..120..229R, 2011AJ....141..150J, 2014ApJ...795...82S, 2018AJ....156...97I}, who compare observations with expected physical models. Following the classification scheme introduced by \citet{2007ASSL..342.....K}, emission-line stars are predominately observed in close binaries, earliest-type, latest-type, and pre-main sequence stars. For systems in which mass accretion is occurring, the examination of emission lines can allow the mass accretion rate onto the central star to be estimated \cite{2003ApJ...582.1109W, 2004A&A...424..603N}. The procedure involves measuring simple indices (such as the equivalent width and broadening velocity) of the emission lines in the stars's spectrum.
In recent years, multiple dedicated photometric and spectroscopic surveys (e.g. \cite{2008MNRAS.384.1277W, 2008MNRAS.388.1879M, 2012ApJS..200...14M, 2012AJ....143...61N, 2014MNRAS.440.2036D, 2016MNRAS.456.1424A, 2016ASPC..505...66N}), and exploratory spectral classifications of large unbiased all-sky spectroscopic observational datasets (e.g. \cite{1999A&AS..134..255K, 2012MNRAS.425..355R, 2015A&A...581A..52T, 2016ASPC..505...66N, 2016RAA....16..138H, 2017ApJS..228...24T}) have been performed, each finding from hundreds to tens of thousands of interesting emission-line stars. Some of these surveys provide a basic physical classification in addition to an emission detection. Therefore they can be used as source lists for further in-depth studies of individual stars.
If a star is engulfed in a hot rarefied interstellar medium or stellar envelope, emission features of the forbidden lines (the most commonly studied of which are the [NII] and [SII] lines) could be observed in its spectrum, providing an insight into the temperature, density, intrinsic movement, and structure of its surrounding interstellar environment \cite{1973ApJ...184...93B, 1993Ap&SS.204..205R, 2005MNRAS.361..813E, 2016A&A...591A..74D, 2017A&A...604A.135D}.
Focusing on spectroscopic data, procedures for the detection of emission lines can roughly be separated into two categories. Simpler procedures searching for obvious emitters above the global continuum \cite{2015A&A...581A..52T, 2016ASPC..505...66N, 2016RAA....16..138H, 2016ASPC..505...66N} and more complex procedures, where the observed spectrum is compared to an expected stellar spectrum of a normal star \cite{2013ApJ...776..127Z}. The reference spectra in the latter case can be generated using exact physics-based stellar modelling or data-driven approaches. Of these, the data-driven approaches can be separated into supervised and unsupervised generative models, where, for the later, it is not required to provide an estimate of the stellar parameters for a given spectrum in advance. To predict a reliable model using supervised models, we must determine the correct stellar labels of an emission star in advance. This can pose a serious limitation if the strongest lines in the acquired spectrum can be populated by an emission feature, which happens for \G\ and RAVE spectra \cite{2013ApJ...776..127Z}. In light of the future publication of Gaia RVS spectra as part of Gaia DR3 for several million of stars, it is thus important to develop tools to identify emission-line stars, as we aim to do in this study via GALAH spectra.
% kak odstavek: poudariš da boš tukaj delal to for in zakaj so autoencoderji kul, recimo
\section{Detection and characterization}
\label{sec:det_chart}
The first attempts to discover H$\alpha$/H$\beta$ emission spectra in GALAH survey observations were performed by \citet{2017ApJS..228...24T}, who also detected emission line stars in the Gaia-ESO \cite{2012Msngr.147...25G} dataset using the Gaussian fitting and arbitrary thresholding \cite{2015A&A...581A..52T}. \citet{2017ApJS..228...24T} used the unsupervised dimensionality reduction technique t-SNE \cite{2013arXiv1301.3342V} to group morphologically similar spectra. As the amplitude and shape of the observed emission can vary substantially depending on the astrophysical source, \citet{2017ApJS..228...24T} presumably detected only a portion of the strongest emitters. One of the reasons for this is the manual classification of data clumps determined by the clustering algorithm. In the case of weak emissions in an investigated clump (performed manually by the operator), an expressed emission feature must be strong enough to be visually perceived when looking at a spectrum. To broaden the range of detectability to include spectra with marginal levels of emission as well, a more sophisticated and partially supervised procedure must be employed.
To expand the search, our methodology uses additional prior knowledge about the expected wavelength locations of interesting emission spectral lines. The prior wavelengths are used to narrow down the interesting wavelength regions during the comparison between the spectrum of a possibly peculiar star and an expected (reference) spectrum of a star with similar physical parameters and composition.
\subsection{Spectral modelling using autoencoders}
\label{sec:ref_modeling}
A reference or a synthetic spectrum of a normal star without emission lines can be produced by a multitude of physics-based computational stellar models \cite{1993sssp.book.....K, 2005A&A...442.1127M, 2012ASInC...6...53D} or supervised generative data-driven approaches \cite{2015AAS...22530207N, 2019ApJ...879...69T}, whose common weakness is the need for prior knowledge of at least an approximate stellar parameters of an analysed stars used by the data-driven algorithm.
As some of our spectra do not have determined stellar parameters or they are flagged with warning signs that indicate different reduction and analysis problems (missing infrared arm, various reduction issues, bad astrometric solutions, \SME\ did not converge etc.), we focused on an unsupervised spectral modelling to produce our set of reference spectra. Given the large size of available training data set, we chose to use an autoencoder type of an artificial neural network (ANN) that is rarely used to analyse astronomical data. Its current use ranges from data denoising \cite{2017ChA&A..41..282Q, 2019arXiv190303105S, 2019MNRAS.485.2628L} to unsupervised feature extraction and feature based classification \cite{2015MNRAS.452..158Y, 2017RAA....17...36L, 2017ChA&A..41..318P, 2018arXiv180901434K, 2019arXiv191104320C, 2019ApJS..240...34M, 2019PASP..131j8011R}.
An autoencoder is a special kind of ANN, shaped like an hourglass, that takes input data (a stellar spectrum in our case), reduces it to a selected number of latent features (a procedure known as encoding) and tries to recover the original data from the extracted latent features (decoding process). Our dense, fully connected autoencoder consists of the data input layer, four encoding layers, a middle feature layer, four decoding layers and the output layer. The number of nodes (or latent spectral features) in the encoding part slowly decreases in the following arbitrary selected order: $75\%$, $50\%$, $25\%$, and $10\%$ of input spectral wavelength samples (4500 in the case of the red spectral arm). The exact numbers of nodes at each layer are shown in Figure \ref{fig:autoann}. At the middle feature layer, the autoencoder structure reduces to only $5$ relevant extracted features. Selecting a higher number of extracted features would also mean that the ANN structure could extract more uncommon spectral peculiarities which is not what we want. In our case, the goal is the reconstruction of a normal non-peculiar spectrum by extraction of a few relevant spectral features. Additionally, because of the low number of extracted features, our decoded output spectrum is a smoothed and denoised version of an input spectrum.
\begin{figure}
\centering
\includegraphics[width=0.6\textwidth]{ann_network_structure_a.png}
\caption{Visual representation of an encoder part of the used autoencoder structure for the red spectral arm. After the input spectra are encoded, they are passed through the same inverted architecture to produce modeled low-noise spectra. The value in the right most column indicates a number of input and output connections to neighboring layers. The number of nodes in a layer is equal to the output value. The input spectrum length is given as the number of wavelength bins in a spectrum.}
\label{fig:autoann}
\end{figure}
A visual representation of the described architecture is shown in Figure \ref{fig:autoann}. The shape of the decoding structure of the autoencoder is the same, except in a reverse order. The Parametric Rectified Linear Unit (PReLU, \cite{2015arXiv150201852H}) activation function defined as
\begin{equation}
f(x) = \begin{cases}
x, & \mathrm{if} x > 0 \\
ax, & \mathrm{if} x \le 0
\end{cases}
\label{equ:prleu}
\end{equation}
is used for all nodes of the network, with the exception of the final output layer that uses a linear (i.e. identity) activation function. The $x$ denotes one spectrum flux value in the first layer and one latent feature in the remaining layers. The free parameter $a$ in Equation \ref{equ:prleu} is optimised during the training phase.
If the network learns a physics-based generative model of a stellar spectrum, information contained in the extracted features should be related to real physical parameters, such as \Teff, \Logg, \Feh, and \vsin, or their mathematical combinations.
To train our autoencoder, we created a set of presumably normal spectra (with no emission features), resampled to a common wavelength grid ($\delta \lambda$ equal to $0.04$ and $0.06$~\AA\ for the blue and red arm). Coverage of the grid is slightly wider than the range of an individual HERMES arm to account for variations in wavelength span because of stellar radial velocity and field curvature which slightly shifts wavelength span of every fiber on a CCD. Observations that did not completely fill the selected range were padded with continuum value of 1. To be classified as normal, spectra must suffice the following selection rules: signal to noise ratio (SNR) in the green arm must be greater than $30$, a spectrum must not contain any known reduction issues (\texttt{red\_flag}~=~0 in \citet{2017MNRAS.464.1259K}) and have valid spectral parameters (\texttt{flag\_sp}~<~16 in \citet{buder2020}). Although choosing \texttt{flag\_sp}~=~0 returns the spectra with the most trustworthy parameters, we choose to use this higher cutoff in \texttt{flag\_sp} to filter out only the strangest spectra and not to produce a set of spectra with well defined parameters. Spectra with 0~<~\texttt{flag\_sp}~<~16 include objects with bad astrometric solution, unreliable broadening, and low SNR that are still useful for our training process. From \citet{2017ApJS..228...24T, buder2018} and \citet{2019MNRAS.483.3196C}, we know that some GALAH spectra display peculiar chemical composition or consist of multiple stellar components. Therefore we removed all identified classes of peculiar spectra with the exception of stars classified as hot or cold that are actually treated as normal spectra in our case. Even such a rigorous filtering approach can miss some strange spectra.
After we applied these quality cuts, we were left with $482,900$ spectra, of which last $10\%$ were used as an independent validation set during the training process. Before the training, normalised spectra were inverted ($1$~$-$~normalised flux), which sets the continuum level to a value of $0$. The inversion improved the model stability and decreased the required number of training epochs.
The described autoencoder was trained with the Adam optimisation algorithm \cite{2014arXiv1412.6980K} for $350$ epochs. At every epoch all training spectra were divided into multiple batches of $40,000$ spectra, whose content is randomised at every epoch. A batch is a subset of data that is independently used during a training process. Such splitting and randomisation of training spectra into batches decreases the probability of model over-fitting. To enable the selection of the best network model, it was saved after the end of every training epoch.
The loss score minimised by the Adam optimiser, shown in Figure \ref{fig:trainann}, was computed as a mean absolute error (MAE) between the input observed and decoded spectra defined as:
\begin{equation}
\label{equ_mae}
loss_\mathrm{MAE} = \frac{1}{N n_\lambda} \sum_{n=1}^{N}\sum_{i=1}^{n_\lambda}\left|f_{\mathrm{ae}, n, i} - f_{\mathrm{obs}, n, i}\right|,
\end{equation}
where N is the number of all spectra, $n_\lambda$ the number of wavelength bins in each spectrum, $f_{\mathrm{ae}, n, i}$ the flux value of a decoded spectrum at one of the training epochs, and $f_{\mathrm{obs}, n, i}$ the flux value of a normalised observed spectrum. Such a loss function gives lower weight to gross outliers in comparison to the mean squared error (MSE). At the same time, outputs are closer to a median spectrum of spectra with a similar appearance and less affected by remaining peculiar spectra in the training set.
\begin{figure}
\centering
\includegraphics[width=0.6\textwidth]{ann_network_loss_ccd13.pdf}
\caption{Prediction accuracy of the blue and red arm autoencoders at different training epochs. The prediction error is computed as a sum of all absolute differences between the input and output data set (see Equation \ref{equ_mae}). Shown are training (solid line) and validation curves (dashed line) which do not show any strong model over-fitting on the training set. The curves indicate that both autoencoders learned in a similar way because the same optimiser was used. The blue arm model has a bit higher loss and shows slower learning because of a greater spectral complexity and lower signal to noise ratio in that wavelength region.}
\label{fig:trainann}
\end{figure}
After examining the decoded outputs at different epochs in comparison with known normal and peculiar spectra, we decided to use the model produced after $150$ training epochs. After that, overall improvements of the model are minor, which increases the model opportunity to over-fit on a low number of peculiar spectra. After closer inspection of the last epoch, we found indications of over-fitting on known emission stars, which further confirms the validity of choosing a model with shorter training period (with greater prediction loss) and rejects the need for a longer model training.
To decrease the complexity of a dense neural network and reduce the required training time, two independent autoencoders were trained, separately for the blue and red HERMES spectral arms.
After the training and model selection were completed, all available $669,845$ spectra were run through the same autoencoder to produce their high SNR reference spectra. An example of four such spectra is shown in Figures \ref{fig:refann} and \ref{fig:refann2}.
\begin{figure}
\centering
\includegraphics[width=\textwidth]{sample_spectra_spectra_ccd3.pdf}
\caption{The diversity of spectra that must be processed by our reference spectrum generation scheme. Panels show spectra of the following normal and peculiar stars: cool, hot fast-rotating, spectroscopic binary, and H$\alpha$/H$\beta$ emission star. All examples show that the autoencoder network did reproduce the observed shapes of the normal spectra (first two) and not the peculiar spectra (last two) as desired from the reference spectrum generator. The original spectra are shown in black and reconstructed in blue.}
\label{fig:refann}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{sample_spectra_spectra_ccd1.pdf}
\caption{Same plots and objects as in Figure \ref{fig:refann} but for the blue spectral arm.}
\label{fig:refann2}
\end{figure}
\subsection{Latent features}
To test the idea of extracted scalar latent features being connected to physical parameters, and to inspect how an autoencoder structure actually orders spectra, we colour coded values of latent features by unflagged physical parameters of input the GALAH spectra. Latent feature scatter plots, colour coded by a different combination of stellar parameters, are presented in Figures \ref{fig:latent_ccd3_1} (with \Teff\ and \Logg\ for the red arm) as well as \ref{fig:latent_ccd1_1} (with \Teff\ and \Logg\ for the blue arm) and \ref{fig:latent_ccd1_2} (with \Teff\ and \Feh\ for the blue arm).
As expected, all plots show continuous colour changes induced by the changing value of investigated physical parameter. This gives us a confirmation that the derived stellar physical parameters are spectroscopically meaningful and have the strongest influence on the appearance of acquired spectra. Rough physical parameters of previously unanalysed or peculiar spectra can therefore be acquired by averaging the parameter values of their neighborhood in the latent space. Similar procedures for parameter estimation have already been successfully explored by \citet{2015MNRAS.452..158Y, 2017ChA&A..41..318P, 2017RAA....17...36L}.
\begin{figure}
\centering
\includegraphics[width=\textwidth]{encoded_features_scatter_teff_logg_ccd3.png}
\caption{Correlation between extracted latent features and physical parameters. Scatter plots between different features are colored by the GALAH physical parameters of original spectra. Points in the lower triangle are colored by their \Teff\ and in upper triangle by their \Logg. Associated colour mappings are given below the figure (for the lower triangle) and on its right side (for the upper triangle). Presented are results for the red arm autoencoder.}
\label{fig:latent_ccd3_1}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{encoded_features_scatter_teff_logg_ccd1.png}
\caption{Same plots as shown in Figure \ref{fig:latent_ccd3_1}, but for the latent features of the blue HERMES band, coloured by parameter \Teff\ on lower triangle and by \Logg\ on the upper triangle.}
\label{fig:latent_ccd1_1}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{encoded_features_scatter_teff_fe_h_ccd1.png}
\caption{Same plots as shown in Figure \ref{fig:latent_ccd3_1}, but for the latent features of the blue HERMES band, coloured by parameter \Teff\ on lower triangle and by \Feh\ on the upper triangle.}
\label{fig:latent_ccd1_2}
\end{figure}
\subsection{H$\alpha$ and H$\beta$ emission characterization}
\label{sec:hahbemis}
The detection of emission components in spectra is based on a spectral difference $f_\mathrm{diff}$, computed as:
\begin{equation}
\label{equ:spec_diff}
f_\mathrm{diff} = f_\mathrm{obs} - f_\mathrm{ref},
\end{equation}
where $f_\mathrm{obs}$ and $f_\mathrm{ref}$ are the observed spectrum and the generated reference spectrum respectively. The result of a computed difference $f_\mathrm{diff}$ for an emission spectrum is shown in the top panel of Figure \ref{fig:emissfit}. Ideally, this computation would enhance only mismatch between both spectra, with inclusion of spectral noise, if both represent a star with the same physical stellar parameters. During the initial processing, we found out that some observed spectra have slight normalisation problems, therefore we re-normalised them prior to difference computation. As the reference spectrum $f_\mathrm{ref}$ is known and has a continuum level close to a median value of similar stars in the training set, we first compute a spectral ratio $f_\mathrm{div}$, defined as:
\begin{equation}
\label{equ:spec_div}
f_\mathrm{div} = \frac{f_\mathrm{obs}}{f_\mathrm{ref}}.
\end{equation}
The resulting ratio can be viewed as a proxy for a renormalisation curve that would bring $f_\mathrm{obs}$ to the same continuum level as $f_\mathrm{ref}$, but would at the same time cancel out any spectral differences between them. To avoid the latter, we fitted $f_\mathrm{div}$ with a $3^{rd}$ degree polynomial with a symmetrical $2$-sigma clipping, ran for five iterations. We used the polynomial fit to renormalise $f_\mathrm{obs}$.
\begin{figure}
\centering
\includegraphics[width=0.6\textwidth]{paper_180131002701292_1.pdf}
\caption{Panels show two different wavelength regions of $f_\mathrm{diff}$ for the same star. The top panel is focused on the H$\alpha$ and [NII] nebular lines, while the second panel focuses on [SII] lines. Rest wavelengths of both nebular doublets are given by the green dash-dotted vertical lines. Their fitted locations, affected by a gas cloud movement, are given by the red dashed vertical lines that both have the same radial velocity. The constant integration range around EW(H$\alpha$) is bounded by the left and right black dashed vertical lines on the top panel. The middle black dashed vertical line represents H$\alpha$ rest wavelength. All wavelengths are given in the stellar rest frame.}
\label{fig:emissfit}
\end{figure}
To get the first identification of an emission features, we calculate the equivalent width (EW) of the spectral difference in a $\pm3.5$ \AA\ range around the investigated Balmer H$\alpha$ and H$\beta$ lines. The selected range (shown in Figure \ref{fig:emissfit}) is wide enough to encompass emission profile of all spectra, with the exception of a few, which have very broad and structured profiles. We kept the width narrow to reduce the effect of spectral noise and nearby sky emission lines (see Section \ref{sec:skyemis}). The correlation between measurements of both equivalent widths is shown in Figure \ref{fig:hab_EW} from which it is evident that the H$\beta$ emission feature is weaker than the H$\alpha$ feature. This gradual intensity reduction is a well known relation also known as the Balmer decrement. As the decrement depends on many physical parameters of stars, absorbing medium, and type of the observed object, \citet{bloom1969balmer} collected multitude of known measurements. In our case the measured ratio EW(H$\alpha$)/EW(H$\beta$) has a value close to 3/2. The ratio seems to be independent of the Balmer line strength if the emission was detected. Low EW values in Figure \ref{fig:hab_EW} should not be taken in this approximation as they are burdened by the reference model uncertainty, spectral noise, and precise continuum levels of both spectra.
\begin{figure}
\centering
\includegraphics[width=0.6\textwidth]{H_emission_EW_dist_all.png}
\caption{Correlation between equivalent widths of the H$\alpha$ and H$\beta$ emission components for our set of detected stars (defined as having \texttt{Ha\_EW}~>~$0.25$~\AA) as black points. The remaining set of objects is shown with gray dots. All flagged objects and possible spectroscopic binaries are taken out for this plot. The green dashed linear line represent the one-to-one relation and the orange dash-dotted line identicates cases where the equivalent width of the H$\beta$ is half of the H$\alpha$ line.}
\label{fig:hab_EW}
\end{figure}
Alongside the equivalent widths of the residual components (EW(H$\alpha$) and EW(H$\beta$)), we also measured two additional properties of these lines, which give some insight into physical understanding of emission source. The broadening velocity of a line is described by its width at the $10$\% of the line peak (W10\%(H$\alpha$) and W10\%(H$\beta$)) expressed in \kms. The automatic measurement procedure first finds the highest point inside the integration wavelength range and then slides down on both sides of the peak until the flux drops below 10\% of the peak value. The broadening velocity is defined as a width between those two limiting cuts. As the computation is done for every object in an unsupervised way, the results are meaningful only for the spectra with evident emission lines. In the case when a low broadening velocity is estimated (equivalent to a very narrow peak), the highest peak could be a residual sky emission line or a cosmic ray streak. By combining EW(H$\alpha$) and W10\%(H$\alpha$), mass accretion could be estimated if emission is of a chromospheric origin \cite{2015A&A...575A...4F}.
The second emission line index measured in the $f_\mathrm{diff}$ spectrum, that roughly describes the shape and location of an emission feature, is the asymmetry index defined as:
\begin{equation}
\label{equ:hab_asym}
Asymmetry = \frac{|EW_\mathrm{red}| - |EW_\mathrm{blue}|}{|EW_\mathrm{red}| + |EW_\mathrm{blue}|},
\end{equation}
where $|EW_x|$ is the equivalent width of the absolute difference $|f_\mathrm{diff}|$ on the red and blue side of the rest wavelength of the investigated Balmer line. By this definition, a line that is, as a whole, moved to the redward side would have this index equal to $1$, whilst if it was moved to the blueward side, the index would instead equal $-1$. The distribution of the asymmetry index values for the most prominent and unflagged (see Section \ref{sec:flagging}) emitters is shown in Figure \ref{fig:hab_asym}, where a strong correlation between the asymmetry of H$\alpha$ and H$\beta$ lines is evident. As the H$\beta$ line in most cases produces a much weaker or even no emission feature, its asymmetry is much harder to measure. That is evident in Figure \ref{fig:hab_asym} where its index is scattered a around $0$, except for the most asymmetric cases. The distribution of the H$\alpha$ asymmetry is much more uniform outside the central symmetric region. From this index, we can roughly classify the source of the emitting component as a chromospheric origin would produce a centered component with an asymmetry index close to $0$. Everything outside the central region in Figure \ref{fig:hab_asym}, defined by the circle with a radius of $0.25$, could be thought to be of an extra-stellar origin as lines are not perfectly aligned. The used thresholding radius value of $0.25$ was defined by observing Figure \ref{fig:hab_asym} to encircle the main over-density of almost symmetric emission profiles.
\begin{figure}
\centering
\includegraphics[width=0.6\textwidth]{H_emission_asymmetry.png}
\caption{Asymmetry index of objects with prominent emission lines in the integration range around investigated Hydrogen Balmer lines. Objects with index inside the green dashed circle are considered to have a symmetric emission contribution, which can be attributed to a chromospheric activity. Central circular region has a radius of asymmetric index $0.25$.}
\label{fig:hab_asym}
\end{figure}
% Like with figures 6 and 7, do we have expectations for how the data should look in figures 8 and 9?
\begin{figure}
\centering
\includegraphics[width=0.6\textwidth]{sii_nii_ew_corr.png}
\caption{Correlation between the strengths of the nebular contributions from both elements. Shown are only cases with a small difference in the determined radial velocities as shown in Figure \ref{fig:sii_nii_rv}.}
\label{fig:sii_nii_ew}
\end{figure}
\subsection{Detection of nebular contributions}
\label{sec:nebularemis}
Due to the multiple possible origins of H emission lines \cite{2007ASSL..342.....K}, we also attempted to detect the extra-stellar nebular contributions of nearby optically thin gas. Its presence is expressed as forbidden emission lines in addition to the H emission. The spectral coverage of the HERMES red arm enables us to observe doublets of [SII] ($6548.03$ and $6583.41$ \AA), and [NII] ($6716.47$ and $6730.85$ \AA). Having usually a weak emission contribution that could possibly be blended with nearby absorption lines, they are most easily detected when we remove the expected reference spectrum from the observed one (resulting in $f_\mathrm{diff}$). To automatically detect the emission strength and position of both doublets, we independently fitted two Gaussian functions with the same radial velocity shift for each element to $f_\mathrm{diff}$. Because the contributing medium is not necessarily physically related to the observed object, its radial velocity could be different, therefore it was treated as a free parameter in our fit. Two independent velocities, one for each of the two doublets, give us an indication of a spurious or unreliable fit component if their difference is large. To filter out outliers, we adopted a threshold of $15$~\kms\ on their velocity difference. Some of the discarded outliers might be correct detections because few of the spectra show two or more peaks for each nebular line which might point to a contribution of multiple clouds with different radial velocities. Such cases are not fully accounted for by the fitting algorithm that only identifies the strongest emission.
\begin{figure}
\centering
\includegraphics[width=0.6\textwidth]{sii_nii_rv.png}
\caption{Correlation between radial velocity of both assessed nebular contributions that are observable in the red arm of the HERMES spectrum. Shown are only cases with at least three detected forbidden lines. The grey dots were further discarded as their absolute difference between velocities is more than $15$~\kms. The limiting thresholds are visualized by dashed linear lines. Plotted velocities are measured in the stellar rest frame and therefore grouped towards zero velocity, meaning they are moving together with the star. Velocity distributions of selected measurements are presented around the main scatter plot.}
\label{fig:sii_nii_rv}
\end{figure}
In the absence of additional fitting constraints, the routine might also find two noise peaks and lock onto them. Therefore, we put an arbitrarily selected detection threshold ($0.05$ of relative flux) on a minimum amplitude of the fitted forbidden lines to be counted as detected. The result from this fitting and analysis procedure is a number of successfully detected peaks per element and their combined equivalent widths (EW([NII]) and EW([SII])), reported in the final published table (Table \ref{tab:results}). To filter out some possible miss-detection, we count a spectrum as having nebular lines when at least three nebular lines above the threshold were detected. The correlations for measured radial velocities and equivalent widths of identified objects with nebular emission are given in Figure \ref{fig:sii_nii_ew} and \ref{fig:sii_nii_rv} respectively.
The radial velocities of both doublets shown in Figure \ref{fig:sii_nii_rv} give us a first impression that the gas dynamics of the elements in all observed clouds is nearly coincident, but elements are moving at slightly different velocities. This velocity offset, but in the opposite direction, was also observed by \citet{2016A&A...591A..74D, 2017A&A...604A.135D} who attributed it to the uncertainties in their adopted line wavelengths, that are slightly different to ours (less than $0.05$~\AA), causing the velocity points to be located either above or under the identity line in Figure \ref{fig:sii_nii_rv}. Additionally, the plot reveals that the majority of the gas clouds have a different radial velocity than stars behind or inside a cloud.
As we are working with fully reduced normalised spectra, with inclusion of sky background removal, the detection procedure would, in the case of an ideal background removal, not detect emission due to nebular clouds. As the measured flux of the nebular contribution is very unlikely the same for object and because of the physical separation of the sky fibres (see next Section \ref{sec:skyemis} and \citet{2017MNRAS.464.1259K}), the ideal cases are very rare. Similarly, the densities and the temperatures of such nebular clouds, extracted from corrected spectra could be influenced by the extraction pipeline and were therefore not performed in our case.
\begin{figure}
\centering
\includegraphics[width=0.6\textwidth]{paper_170509002201287_2.pdf}
\caption{Sky emission lines are most evident after spectra subtraction in $f_\mathrm{diff}$. Green vertical dashed lines represent expected locations of emission lines in the rest frame of an observed star. The middle sky line in this plot falls inside the actual H$\alpha$ emission feature and changes its shape from single- to double-peaked and consequently modifies the measured equivalent width. Upper and lower thresholds for detection are given by the bold horizontal dashed lines. The number of detected under- and over-corrected sky lines in this order is given above the plot.}
\label{fig:skyemiss}
\end{figure}
The strength of the identified lines, measured by their equivalent widths, is shown in Figure \ref{fig:sii_nii_ew}. This shows a high degree of correlation, where on average [SII] lines have lower strength than [NII] lines. Rough estimation of ratio between their measured equivalent widths EW([NII])/EW([SII]) is close to the value of 4/3.
\subsection{Identification of sky emission lines}
\label{sec:skyemis}
Attributing a limited and relatively low number of the HERMES fibres to monitor the sky in hopefully star and galaxy free regions, imposes limitations to a quality of the sky background removal in the GALAH reduction pipeline \cite{2017MNRAS.464.1259K}. As the sky spectrum is sampled at $25$ distinct locations over the whole $2^\circ$ diameter field, it must be interpolated for all other fibre locations that are pointing towards stellar sources. Depending on the temporal and spatial variability of weather conditions, and possible nebular contributions, interpolation may produce an incorrect sky spectrum that is thereafter removed from the observed stellar spectra.
In most cases, this does not influence the spectral analysis, unless one of the strongest sky emission lines falls in a range of the analysed stellar line. For us, the most problematic sky emission line, which can alter the shape of the H$\alpha$ profile, is located at $6562.7598$~\AA\ (used list of sky emission lines was taken from \citet{2003A&A...407.1157H}). Being close to the adopted wavelength of the H$\alpha$ ($6562.8518$~\AA), it can get blended with a real emission feature or simulate its presence. We tried to estimate the impact of the sky residual in the spectrum from multiple nearby emission lines. First, we select only the strongest sky emitters (with parameter \texttt{Flux}~$\ge$~$0.9$ in \citet{2003A&A...407.1157H}) and shift their reference wavelength into a stellar rest frame. After that, we use a simple thresholding (see Figure \ref{fig:skyemiss}) to estimate their number. By the thresholding procedure, we want to simultaneously catch over- and under-corrected stellar spectra.
When a sufficient number ($\ge$~$4$) of strong residual sky lines with a normalised flux above $10$\% is detected, a quality flag (see Section \ref{sec:flagging}) is raised, warning a user that the equivalent width of the H$\alpha$ emission could be affected by uncorrected sky emission. As this potential contamination is present only in the red HERMES arm, we do not check for spurious strong emitters in the region around the H$\beta$ line.
\begin{figure}
\centering
\includegraphics[width=0.6\textwidth]{paper_140812003801021_3.pdf}
\caption{Detection of a spectroscopic binary candidate by cross-correlating observed spectrum with its reference spectrum. Three Gaussian functions that are fitted to the resulting CCF (black solid curve) are depicted by their means (dashed vertical lines) and their best fitting sum in red. Presented are CCFs for the red arm in the top panel and for the blue arm in the bottom panel. Number of detected peaks for both arms is given above the figure. The middle marked peak in the bottom plot was not detected due to its low fitted amplitude that could hint to a feature caused by a spectral noise. Peaks of similar amplitude, that could cause wrong binarity determination, are seen left and right of central CCF region.}
\label{fig:sb2ccf}
\end{figure}
\subsection{Determination of spectral binarity}
During the inspection of our initial results, we noticed that the spectra of spectroscopically resolved binary stars (SB2) produce a mismatch between observed and reference spectra whose $f_\mathrm{diff}$ have a profile similar to the P Cygni or inverted P Cygni profile \cite{1979ApJS...39..481C} that is often observed in emission-line objects. To detect SB2 candidates, we performed cross-correlation between the reference and the observed spectra, disregarding the wavelength range of $\pm10$\AA\ around the centre of the Balmer lines to avoid broadening of the cross-correlation function (CCF) peak. Cross-correlation was performed independently for both (the blue and red) HERMES spectral arms. The resulting CCF, shown as the black curve in Figure \ref{fig:sb2ccf}, was fitted by three Gaussian functions, centred at three strongest peaks, to describe its shape. The location, amplitude and width of those peaks were assessed to determine the number of stellar components in the spectrum. When fitting three peaks, there is a possibility of finding triple stars and distinguishing them from binaries. Every spectral arm with more than one prominent peak was marked as potential SB2 detection in the final results (see Table \ref{tab:results}), where binarity indication is given independently for both arms. Nevertheless, the results of the blue arm (column \texttt{SB2\_c1}) are more trustworthy because of the higher number of absorption lines in the red arm (column \texttt{SB2\_c3}). For even greater completeness of detected SB2 candidates, a list of analyzed binaries, compiled by \citet{2020arXiv200500014T} can be used. They combined unsupervised spectral dimensionality reduction algorithm t-SNE and semi-supervised CCF analysis \cite{2017A&A...608A..95M} to compile their list of SB2 binaries. After their analysis, they discarded spectra that were falsely identified as SB2 by their detection procedures.
An unexpected result of this binarity search was the realization that some reduced spectra show duplicated lines only in the red arm or even stranger, only in a smaller subsection of it. After a thorough investigation, we uncovered that this effect is caused by improper treatment of fibre cross-talk while extracting spectra from the original 2D image \cite{2017MNRAS.464.1259K}. A partial culprit of this is also a poorer focus in the red arm. Therefore if only flag \texttt{SB2\_c3} is set, and not \texttt{SB2\_c1}, this can be used as an indication of the above reduction effect.
Additionally, the highest peak of our CCF function is used to determine the correctness of the wavelength calibration during the reduction of the spectra \cite{2017MNRAS.464.1259K}. If the peak is shifted by more than five correlation steps (maximum shift equals to about 13~\kms) from the rest wavelength of the reference spectrum, the quality flag (see Section \ref{sec:flagging}) is raised, warning the user that the derived radial velocity, equivalent width, and asymmetry index might be wrong in the respective arm as both spectra were not aligned ideally.
\subsection{Resulting table}
\label{sec:results}
The emission indices and other computed parameters are collected in Table \ref{tab:results}. The complete table is available in electronic form at the CDS. An excerpt of the published results, containing a subset of 30 rows and 11 most interesting columns for the strongest unflagged emitters is given in Table \ref{tab:results_values}.
\begin{table}
\centering
\caption{List and description of the fields in the published catalogue of analysed the GALAH spectra.}
\label{tab:results}
\begin{tabular}{l c l}
\hline
Column & Unit & Description \\
\hline \hline
\texttt{source\_id} & & \G\ DR2 star identifier \\
\texttt{sobject\_id} & & GALAH internal per-spectrum unique id \\
\texttt{ra} & deg & Right ascension coordinate from Two Micron All-Sky Survey (2MASS, \cite{2006AJ....131.1163S})\\
\texttt{dec} & deg & Declination coordinate from 2MASS\\
\texttt{Ha\_EW} & \AA & Equivalent width of a difference between observed \\
& & and template spectrum in the range of $\pm3.5$~\AA\ \\
& & around the H$\alpha$ line \\
\texttt{Hb\_EW} & \AA & Same as the \texttt{Ha\_EW}, but for the H$\beta$ line \\
\texttt{Ha\_EW\_abs} & \AA & Equivalent width of an absolute difference between \\
& & observed and template spectrum in the range of \\
& & $\pm3.5$~\AA\ around the H$\alpha$ line \\
\texttt{Hb\_EW\_abs} & \AA & Same as the \texttt{Ha\_EW\_abs}, but for the H$\beta$ line\\
\texttt{Ha\_W10} & \kms & Width (in \kms) of the H$\alpha$ emission feature at \\
& & $10$\% of its peak flux amplitude \\
\texttt{Ha\_EW\_asym} & & Value of asymmetry index for the H$\alpha$ line \\
\texttt{Hb\_EW\_asym} & & Value of asymmetry index for the H$\beta$ line \\
\texttt{SB2\_c3} & & Was binarity detected in the red arm \\
\texttt{SB2\_c1} & & Was binarity detected in the blue arm \\
\texttt{NII} & & Number of detected [NII] peaks in the doublet \\
\texttt{SII} & & Number of detected [SII] peaks in the doublet \\
\texttt{NII\_EW} & \AA & Combined equivalent width of a fitted Gaussian profiles \\
& & to both studied [NII] emission features \\
\texttt{SII\_EW} & \AA & Same as the \texttt{NII\_EW}, but for the [SII] doublet \\
\texttt{rv\_NII} & \kms & Intrinsic radial velocity of the [NII] doublet, \\
& & corrected for the barycentric and stellar velocity \\
\texttt{rv\_SII} & \kms & Same as \texttt{rv\_NII}, but for the [SII] doublet \\
\texttt{nebular} & & Is spectrum considered to have an additional \\
& & nebular component \\
\texttt{emiss} & & Is spectrum considered to have an additional H$\alpha$ \\
& & emission component \\
\texttt{flag} & & Sum of all bitwise flags raised for a spectrum \\
\hline
\end{tabular}
\end{table}
As we do not perform any quality cuts on our results, a suggested set of limiting parameter thresholds and quality flags is provided in Section \ref{sec:flagging}. Their use depends on user-specific requirements and the analysed science case.
\begin{sidewaystable}
\centering
\caption{Excerpt of 30 strongest unflagged emitters from the published table presented in detail by Table \ref{tab:results}. The rest of the table can be downloaded in electronic form CDS service and publishers' website.}
\label{tab:results_values}
\begin{tabular}{c c c c c c c c c c c}
\hline
source\_id & Ha\_EW & Ha\_EW\_abs & Ha\_W10 & Ha\_EW\_asym & NII & SII & NII\_EW & rv\_NII & rv\_SII & flag \\
\hline \hline
3337923100687567872 & 5.37 & 5.37 & 373.63 & 0.36 & 1 & 0 & 0.05 & -30.22 & 23.54 & 0 \\
3217769470732793856 & 5.06 & 5.06 & 252.48 & 0.07 & 0 & 1 & 0.01 & -11.32 & 35.71 & 0 \\
4660266122976778240 & 4.51 & 4.51 & 199.66 & 0.15 & 0 & 0 & 0.02 & -310.50 & -231.18 & 0 \\
3340892714091577856 & 4.35 & 4.35 & 205.94 & -0.06 & 2 & 2 & 0.20 & -24.73 & -27.14 & 0 \\
3336365097008009216 & 4.14 & 4.14 & 188.62 & -0.08 & 0 & 0 & 0.07 & -76.99 & -43.80 & 0 \\
3217804483306125824 & 4.02 & 4.02 & 152.24 & -0.03 & 0 & 1 & 0.01 & -85.06 & 28.70 & 0 \\
3214742618300312064 & 3.97 & 3.98 & 277.85 & -0.08 & 0 & 0 & 0.01 & -63.06 & -32.82 & 0 \\
6243142063220661248 & 3.87 & 3.87 & 120.97 & -0.07 & 2 & 1 & 0.08 & 7.21 & 15.98 & 0 \\
2967553747040825856 & 3.80 & 3.80 & 330.27 & 0.07 & 0 & 1 & -0.00 & -66.11 & -10.92 & 0 \\
5948023586013872128 & 3.72 & 3.72 & 277.77 & 0.17 & 0 & 0 & 0.00 & -72.55 & -127.22 & 0 \\
5416221633076680704 & 3.65 & 3.65 & 126.59 & -0.08 & 0 & 0 & -0.01 & 69.68 & 19.93 & 0 \\
3222267297922229248 & 3.64 & 3.64 & 265.38 & -0.07 & 0 & 0 & 0.04 & -60.66 & 13.30 & 0 \\
6245775565362814976 & 3.59 & 3.59 & 133.82 & -0.08 & 0 & 0 & -0.07 & 194.28 & 59.86 & 0 \\
3235905365276381696 & 3.52 & 3.82 & 211.08 & -0.43 & 1 & 0 & 0.05 & -4.52 & 57.50 & 0 \\
3236272877038986240 & 3.47 & 3.47 & 141.67 & -0.06 & 0 & 0 & 0.06 & -50.01 & 10.89 & 0 \\
5200035927402217472 & 3.46 & 3.46 & 148.65 & -0.03 & 1 & 0 & 0.04 & -89.98 & 15.81 & 0 \\
5820283738165246976 & 3.45 & 3.45 & 380.58 & -0.08 & 0 & 0 & -0.02 & 55.83 & 78.12 & 0 \\
3222024374573501952 & 3.37 & 3.37 & 224.71 & -0.11 & 0 & 1 & 0.00 & -0.04 & 17.76 & 0 \\
3221019798902558720 & 3.37 & 3.37 & 142.94 & -0.07 & 0 & 0 & 0.03 & -64.74 & 48.73 & 0 \\
6235172592479759360 & 3.32 & 3.32 & 147.53 & 0.02 & 0 & 0 & 0.01 & -2.29 & 46.61 & 0 \\
\hline
\end{tabular}
\end{sidewaystable}
\subsection{Flagging, quality control and results selection}
\label{sec:flagging}
The above described pipeline runs blindly on every successfully reduced spectrum (\texttt{guess\_flag} = 0, for details see \citet{2017MNRAS.464.1259K}), and could therefore produce wrong or misleading results for some spectra. To have the ability to filter out such possible occurrences, we created a set of warning flags for different pipeline steps that are listed and described in detail in Table \ref{tab:flags}. An interested user can base their selection of results according to the desired confidence level and a physical question of interest. The cleanest set of $10,364$ H$\alpha$ emission stars can be produced by selecting unflagged stars that do not show any signs of possible binarity, defined such that parameter \texttt{emiss} in the published Table \ref{tab:results} is set to one (the equivalent of true). To be included among the cleanest set of detections, we considered only spectra whose \texttt{Ha\_EW}~>~$0.25$~\AA. Below this limit, we are less confident in marking an object as having an emission feature because visual inspection showed that this strength could be mimicked by spectral noise, the uncertainty of the reference spectrum, or induced by the reduction pipeline. This selection criteria at the same time discards the weakest chromospheric components, which might be of great interest for specific studies. If the user is interested only in stronger emitters, the threshold should be raised to \texttt{Ha\_EW}~>~$0.5$~\AA\ or above.
\begin{table}
\centering
\caption{Quality binary flags produced during different steps of our detection and analysis pipeline. Lower value of the flag represents lower significance to the quality of detection and classification. The final reported \texttt{flag} value in Table \ref{tab:results} is a sum of all raised binary quality flags.}
\label{tab:flags}
\begin{tabular}{r l}
\hline
Flag & Description \\
\hline \hline
128 & Reference spectrum for the H$\alpha$ range does not exist.\\
64 & Reference spectrum for the H$\beta$ range does not exist.\\
32 & Large difference between reference and observed spectrum in the red arm\\
& of a spectrum. Median squared error (MSE) between them was $\ge 0.002$\\
16 & Large difference between reference and observed spectrum in the blue \\
& arm of a spectrum. MSE was $\ge 0.008$.\\
8 & The spectrum most likely contains duplicated spectral absorption lines \\
& of a resolved SB2 binary. Binarity was detected in both arms.\\
4 & Possible strong contamination by sky emission features. 4 or more \\
& residual sky lines were detected. Could be a result of an \\
& under- or over-correction.\\
2 & Wavelength solution (or determined radial velocity) might be wrong in \\
& the red arm of the spectrum. Determined from cross-correlation peak \\
& between observed and reference spectra.\\
1 & Wavelength solution (or determined radial velocity)\\
& might be wrong in the blue arm of the spectrum.\\
\hline
\end{tabular}
\end{table}
The published Table \ref{tab:results} also contains a flag that describes whether the spectrum is considered to contain an additional nebular contribution. Such spectra can be filtered out by choosing the parameter \texttt{nebular} to be equal to $1$. To compile this less restrictive list of $4004$ spectra, we selected entries with at least three prominent forbidden emission lines (\texttt{NII}~$+$~\texttt{SII}~$\ge$~$3$) and a small difference in their measured radial velocities ($|$\texttt{rv\_NII}~$-$~\texttt{rv\_SII}$|$~$\le$~$15$~\kms).
\section{Temporal variability}
\label{sec:temporal}
The strategy of the GALAH survey is to observe as many objects as possible, and as a result, not many repeated observations were made. The repeated fields were mostly observed to assess the stability of the instrument. Time spans between observations are therefor on the orders of days or years. This greatly limits the possibility of finding a variable object, but still enables us to discover potential interesting objects and diagnose analysis issues.
To find possible emission stars with repeated observations, we selected stars with repeats, among which at least one spectrum was identified to harbour a stronger (\texttt{Ha\_EW}~>~$0.5$~\AA) unflagged emission feature. This selection produced $621$ stars, having between $2$ and $9$ observations. To be confident about the observed variability, we visually inspected the observed and the reference spectra of $208$ stars with at least three observations. A subset of these spectra are shown in Figure \ref{fig:temporal_variab}, where we present typical types of variability discovered by visual inspection. The types can roughly be described as shape transformation (e.g. change from single- to double-peak or P Cygni emission profile), peak location shift, intensity change, and possible reduction issue.
In the sample of 208 stars, whose spectra were visually inspected, we found that $\sim20$\% of the inspected spectra display a stable H$\alpha$ profile. Noticeable profile shape transformation was observed in $\sim10$\% of the cases, and peak location change in $\sim5$\% of the cases. Some degree of emission intensity change was noticed for $\sim40$\% of the cases. Visually similar is reduction induced variability (see the rightmost panel in Figure \ref{fig:temporal_variab}), observed for $\sim25$\% of all inspected repeated observations. In the case of multiple observations of the same star, we can distinguish between the last two profile changes (intrinsic and reduction induced intensity change) by looking at the whole spectrum to inspect whether variability is also exhibited in other absorption lines as shown by the last example in Figure \ref{fig:temporal_variab}. That kind of reduction induced variability is limited to a few observed fields.
\begin{figure}
\centering
\includegraphics[width=\textwidth]{repetas_spectra_spectra_ccd3.pdf}
\caption{A sample of objects with repeated observations, where at least one of the normalised spectra (top row) contains strong H$\alpha$ emission detected by comparison towards reference spectrum (bottom row). The first two objects (or columns) show shifting location of an additional emission component peak, and the last two varying degree of its strength. The last example is most likely a result of a miss-reduction as not only H$\alpha$, but also other absorption lines show reduced strength. The existence of this problem is confirmed by other objects in the same field as majority of them show the same tendency of having weaker absorption lines across the spectrum.} % TODO datum te noci
\label{fig:temporal_variab}
\end{figure}
\section{Discussion and conclusions}
\label{sec:discussion_emis}
In this chapter, we describe the development and application of a neural network autoencoder structure that is able to extract the most relevant latent features from the spectrum. Low feature dimensionality contains only the most basic spectral informations that are used to reconstruct a non-peculiar spectrum with the same physical parameters as the input spectrum.
\begin{figure}
\centering
\includegraphics[width=\textwidth]{reddening_d2000_n720_cont_wemisions.png}
\caption{Spatial distribution of stars with detected Balmer emission profiles. Grey areas represent regions that were observed and analysed in this chapter. The green lines represent location of equal reddening in steps of $0.1$ magnitude at the distance of $2$~kpc. Reddening data were taken from results published by \citet{2017A&A...606A..65C}. For readability, no isoline is shown above the reddening of 1~magnitude. Constellation boundaries were taken from \citet{const_data}. Locations of their designations are defined by median values of constellation polygon vertices.}
\label{fig:spatialemission}
\end{figure}
% TODO Morda bi bralca spomnil, koliko je teh emisijskih zvezd in da so s črnimi simboli (neemisijske pa s sivimi, če prav razumem). Je pa sliko relativno težko brat - morda ima tu (in pri naslednji) za pozitivne detekcije bolje izbrat drugo barvo (recimo rdečo ali modro). A bi se dalo kaj tudi rečt o deležu objektov z emisijami predvsem glede na parametre (če recimo vzameš mediano parametrov, kot jih imajo zvezde z bližnjimi vrednostmi tvojih latent features). To je dodatno delo, torej premisli, koliko gre. Lažje kot ukvarjanje z latent parametri je pogledat, ali se kaj vidi glede lokacij objektov v HR diagramu (iz reddeninga na določeni razdalji (recimo Green et al.) dobiš absolutno G magnitudo in dereddened Bp-Rp barvo - takopotem lahko vsaj okvirno rečeš, za kakšne emisijske objekte gre. S pozicijami si že utemeljil, da gre za mlade objekte. Sedaj pa bo ven prišlo še kaj okrog mas: so to masivne modre zvezde ali mlade nizkomasivne, ki se šele usedajo na glavno vejo? V tekstu potem dodaš kak odstavek komentarjev na to temo.
Our method of differential spectroscopy is one of the most widely used approaches to find peculiar spectral features that are not found in normal stars. As a part of this chapter, we showed that a dense autoencoder neural network structure can be reliably used for generation of non-peculiar reference spectra if trained on a large set of normal spectra. With the additional exclusion of our detected emission-line stars, the training set could iteratively be further cleaned of peculiar stars before training the network. As all the information about the spectral look is contained in the real flux values, there is no need to add additional convolutional layers for the extraction of more complex spectral shapes.
By identifying significant residuals after subtracting the generated reference spectra from the observed spectra, we detected emission star candidates in the GALAH fields all over the sky. Figure \ref{fig:spatialemission} shows that we can identify few locations with a higher density of detected emission-line objects. The position of emission-line objects coincides with regions of young stars such as the Orion complex, Blanco 1, Pleiades, and other possibly random over-densities of interstellar gas and dust. Detected nebular emission in stellar spectra, shown in Figure \ref{fig:spatialnebular}, coincide with large visually-identified nebular clouds (by comparing detected locations with the red all-sky photographic composite of The Second Digitized Sky Survey, described by \citet{2000ASPC..216..145M}) such as the Antares Emission nebulae, clouds around $\pi$ Sco and $\delta$ Sco, Barnard's loop, Carina Nebula, nebulae around $\lambda$ Ori, nebular veils in the constellations of Puppis, Pyxis and Antlia, and other less prominent features.
\begin{figure}
\centering
\includegraphics[width=\textwidth]{reddening_d2000_n720_cont_wnebular.png}
\caption{Same as Figure \ref{fig:spatialnebular} but showing stars with at least three detected nebula emission lines, shown with black dots.}
\label{fig:spatialnebular}
\end{figure}
By combining our detections with additional auxiliary data sets, we can start exploring more detailed physical explanations of the observed emissions and their structure. Among them are two specific photometric surveys, VPHAS \cite{2014MNRAS.440.2036D} and IPHAS \cite{2008MNRAS.384.1277W} which were designed to detect and study emission-line sources close to the Galactic plane. Because of their positional selection function, their combined photometric data are available only for $4431$ GALAH spectra. Of these, the spectroscopically confirmed emission stars are shown in Figure \ref{fig:iphas_vphas}, whose color-color diagram can be used to infer accreting objects.
% TODO A se da tu na nivoju enega stavka dodat, zakaj so akrecijski objekti levo zgoraj od tiste črte. In morda, kaj bi znali biti vsi ti ostali objekti (glej komentar o Gabs vs. Bp-Rp pri prejšnjem grafu).
\begin{figure}
\centering
\includegraphics[width=0.6\textwidth]{mag_iphas_vphas_sep.png}
\caption{r - H$\alpha$ versus r - i color-color diagram using combined IPHAS and VPHAS photometry for detected emission stars. The dashed green line represents the unreddened main-sequence track tabulated by \citet{2014MNRAS.440.2036D}. An empirical threshold, shown by dash-dotted blue line, can be used to distinguish non-accreting and accreting objects above the line \cite{2018A&A...609A..10V}.}
\label{fig:iphas_vphas}
\end{figure}
Our detected emission spectra have a broad range of emission components - these range from very strong to barely detectable chromospheric emission component whose identification can be mimicked or masked at multiple steps of the analysis and data preparation. To limit the number of false-positive classifications due to reduction and analysis limitations, we focused on stronger components (\texttt{Ha\_EW}~>~$0.25$~\AA) whose existence can be confirmed visually. Because that kind of process would be slow for the whole sample, we introduced quality flags that can be used to filter out unwanted or specific cases. Additionally, the stability of the spectra and emission features was investigated by repeated observations of the same objects. Among them, we observed different variability types, of which one could be attributed to the data reduction pipeline, limiting the confidence of finding weak emission profiles in the spectra.
To reliably detect even the weakest chromospheric emissions, uncertainty of the used reference spectra must be well known as well. By showing that the proposed neural network structure can be used as intended, we are looking into possibilities to improve our methodology using variational autoencoder. Its advantage lies in the possibility of simultaneous determination of a reference spectrum and its uncertainty which would enable uncertainty estimation of the measured emission-line indices.
% TODO Nekam v te conclusions bi dodal povzetek, približno koliko emisijskih objektov si našel, približno za kakšen tip emisije gre (morfološko - npr. koliko je (a)simetričnih, koliko močnih/šibkih emisij - in tudi fizikalno (imaš že nekaj o starosti, dodaš še kaj o barvah in izsevih)).
|
from __future__ import division
import argparse
import rospy
import intera_interface
import intera_external_devices
import time
import record_data #file to record data.
import numpy as np
from math import *
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scipy
from intera_core_msgs.msg import JointCommand
from scipy import interpolate
from scipy.interpolate import InterpolatedUnivariateSpline
from scipy.interpolate import interp1d
from geometry_msgs.msg import (
PoseStamped,
Pose,
Point,
Quaternion,
)
from std_msgs.msg import Header
from sensor_msgs.msg import JointState
from intera_core_msgs.srv import (
SolvePositionIK,
SolvePositionIKRequest,
)
def save_matrix(_j,_name,_f):
file2write=open("files/"+_name,'w')
l=len(_j[0][:])
time=np.linspace(0, (l-1)/float(_f), num=l)
for n in range(l):
file2write.write(str(time[n])+' , '+str(_j[0][n])+' , '+str(_j[1][n])+' , '+str(_j[2][n])+' , '+str(_j[3][n])+' , '+ str(_j[4][n])+' , '+str(_j[5][n])+' , '+str(_j[6][n])+'\n')
file2write.close()
print "save data en",_name
return True
def generate_jerk(_a,_f):
ext = len(_a[0])
jk0=np.zeros(ext)
jk1=np.zeros(ext)
jk2=np.zeros(ext)
jk3=np.zeros(ext)
jk4=np.zeros(ext)
jk5=np.zeros(ext)
jk6=np.zeros(ext)
for n in range(ext-3):
jk0[n]=((_a[0][n+1]-_a[0][n])*_f)
jk1[n]=((_a[1][n+1]-_a[1][n])*_f)
jk2[n]=((_a[2][n+1]-_a[2][n])*_f)
jk3[n]=((_a[3][n+1]-_a[3][n])*_f)
jk4[n]=((_a[4][n+1]-_a[4][n])*_f)
jk5[n]=((_a[5][n+1]-_a[5][n])*_f)
jk6[n]=((_a[6][n+1]-_a[6][n])*_f)
for i in range(3):
jk0[-3+i]=(jk0[-4+i])
jk1[-3+i]=(jk1[-4+i])
jk2[-3+i]=(jk2[-4+i])
jk3[-3+i]=(jk3[-4+i])
jk4[-3+i]=(jk4[-4+i])
jk5[-3+i]=(jk5[-4+i])
jk6[-3+i]=(jk6[-4+i])
ext= len(jk0)
a_jk0=get_area(jk0,_f)
a_jk1=get_area(jk1,_f)
a_jk2=get_area(jk2,_f)
a_jk3=get_area(jk3,_f)
a_jk4=get_area(jk4,_f)
a_jk5=get_area(jk5,_f)
a_jk6=get_area(jk6,_f)
a=a_jk0+a_jk1+a_jk2+a_jk3+a_jk4+a_jk5+a_jk6
ind=sqrt(a)
jk= [jk0,jk1,jk2,jk3,jk4,jk5,jk6]
print "Knots en jerk generados.",ext
return jk, ind,ext
def generate_acel(_v,_f):
ext = len(_v[0])
a0=np.zeros(ext)
a1=np.zeros(ext)
a2=np.zeros(ext)
a3=np.zeros(ext)
a4=np.zeros(ext)
a5=np.zeros(ext)
a6=np.zeros(ext)
for n in range(ext-2):
a0[n]=(_v[0][n+1]-_v[0][n])*_f
a1[n]=(_v[1][n+1]-_v[1][n])*_f
a2[n]=(_v[2][n+1]-_v[2][n])*_f
a3[n]=(_v[3][n+1]-_v[3][n])*_f
a4[n]=(_v[4][n+1]-_v[4][n])*_f
a5[n]=(_v[5][n+1]-_v[5][n])*_f
a6[n]=(_v[6][n+1]-_v[6][n])*_f
for i in range(2):
a0[i-2]=a0[i-3]
a1[i-2]=a1[i-3]
a2[i-2]=a2[i-3]
a3[i-2]=a3[i-3]
a4[i-2]=a4[i-3]
a5[i-2]=a5[i-3]
a6[i-2]=a6[i-3]
a= np.array([a0,a1,a2,a3,a4,a5,a6])
print "Knots en aceleracion generados: ",ext
return a,ext
def generate_vel(_j,_f):
print "j:",_j
ext = len(_j[0,:])
print "vel_len",ext
v0=np.zeros(ext)
v1=np.zeros(ext)
v2=np.zeros(ext)
v3=np.zeros(ext)
v4=np.zeros(ext)
v5=np.zeros(ext)
v6=np.zeros(ext)
for n in range(ext-1):
v0[n]=((_j[0][n+1]-_j[0][n])*_f)
v1[n]=((_j[1][n+1]-_j[1][n])*_f)
v2[n]=((_j[2][n+1]-_j[2][n])*_f)
v3[n]=((_j[3][n+1]-_j[3][n])*_f)
v4[n]=((_j[4][n+1]-_j[4][n])*_f)
v5[n]=((_j[5][n+1]-_j[5][n])*_f)
v6[n]=((_j[6][n+1]-_j[6][n])*_f)
v0[-1]=v0[-2]
v1[-1]=v1[-2]
v2[-1]=v2[-2]
v3[-1]=v3[-2]
v4[-1]=v4[-2]
v5[-1]=v5[-2]
v6[-1]=v6[-2]
v= np.array([v0,v1,v2,v3,v4,v5,v6])
print "Knots en velocidad generados: ",ext
return v,ext
def generate_path_cub(_points,_time,_f):
q0=path_simple_cub_v0(_points[:,0],_time,_f)
q1=path_simple_cub_v0(_points[:,1],_time,_f)
q2=path_simple_cub_v0(_points[:,2],_time,_f)
q3=path_simple_cub_v0(_points[:,3],_time,_f)
q4=path_simple_cub_v0(_points[:,4],_time,_f)
q5=path_simple_cub_v0(_points[:,5],_time,_f)
q6=path_simple_cub_v0(_points[:,6],_time,_f)
q= np.array([q0,q1,q2,q3,q4,q5,q6])
ext = len(q0)
print "Knots en posicion generados.",ext
return q, ext
def path_simple_cub_v0(_point,_time,_f):
x=_time
a=_point
f=_f
FPO=0.0
FPN=0.0
n=len(a)-1;
l=np.zeros(n+1, dtype=np.float_)
u=np.zeros(n, dtype=np.float_)
z=np.zeros(n+1, dtype=np.float_)
h=np.zeros(n, dtype=np.float_)
alfa=np.zeros(n+1, dtype=np.float_)
c=np.zeros(n+1, dtype=np.float_)
b=np.zeros(n, dtype=np.float_)
d=np.zeros(n, dtype=np.float_)
for i in range(n):
h[i]=x[i+1]-x[i]
sA = np.zeros(shape=(n+1,n+1), dtype=np.float_)
for i in range(n-1) :
for j in range(n-1) :
if i is j:
sA[i+1][i+1]=2*(h[i]+h[i+1])
sA[i+1][i]=h[i]
sA[i][i+1]=h[i]
sA[0][0]=2*h[0]
sA[-1][-1]=2*h[-1]
sA[-1][-2]=h[-1]
sA[-2][-1]=h[-1]
sb = np.zeros(shape=(n+1,1), dtype=np.float_)
for i in range(1,n) :
sb[i]=(3.0*(a[i+1]-a[i])/h[i]) - (3.0*(a[i]-a[i-1])/h[i-1])
sb[0]=((3.0*(a[1]-a[0]))/h[0])-3.0*FPO
sb[-1]=3.0*FPN-(3.0*(a[n]-a[n-1])/h[n-1])
_b=np.arange(n, dtype=np.float_)
_c=np.linalg.solve(sA, sb)
_d=np.arange(n, dtype=np.float_)
for j in reversed(range(n)):
_b[j]=((a[j+1]-a[j])/h[j] )-(h[j]*(_c[j+1]+2*_c[j])/3.0)
_d[j]=(_c[j+1]-_c[j])/(3.0*h[j])
# Graphic
t_out=np.linspace(x[0], x[-1], int((x[-1]-x[0])*f)+1)
tl=len(t_out)
s =np.zeros(tl, dtype=np.float_)
for i in range(n):
for j in range(tl):
if(t_out[j]>=x[i] and t_out[j]<x[i+1]):
s[j]=( a[i]+_b[i]*(t_out[j]-x[i])+_c[i]*(t_out[j]-x[i])**2+_d[i]*(t_out[j]-x[i])**3)
s[-1]=a[-1]+_b[-1]*(t_out[-1]-x[-1]+_c[-1]*(t_out[-1]-x[-1])**2+_d[-1]*(t_out[-1]-x[-1])**3)
return s
def ik_service_client(_x,_y,_z):
p=np.array([_x,_y,_z,1.0,0.0,0.0,0.0])
[succes,position]=ik_service_client_full(p)
return succes,position
def ik_service_client_full(_p):
_limb = intera_interface.Limb('right')
ns = "ExternalTools/right/PositionKinematicsNode/IKService"
iksvc = rospy.ServiceProxy(ns, SolvePositionIK)
ikreq = SolvePositionIKRequest()
hdr = Header(stamp=rospy.Time.now(), frame_id='base')
poses = {
'right': PoseStamped(
header=hdr,
pose=Pose(
position=Point(
x=_p[0],
y=_p[1],
z=_p[2],
),
orientation=Quaternion(
x=_p[3],
y=_p[4],
z=_p[5],
w=_p[6],
),
),
),
}
# Add desired pose for inverse kinematics
ikreq.pose_stamp.append(poses["right"])
# Request inverse kinematics from base to "right_hand" link
ikreq.tip_names.append('right_hand')
try:
rospy.wait_for_service(ns, 5.0)
resp = iksvc(ikreq)
except (rospy.ServiceException, rospy.ROSException), e:
rospy.logerr("Service call failed: %s" % (e,))
return False
# Check if result valid, and type of seed ultimately used to get solution
if (resp.result_type[0] > 0):
# Format solution into Limb API-compatible dictionary
limb_joints = dict(zip(resp.joints[0].name, resp.joints[0].position))
rospy.loginfo("Solucion IK ok.")
_limb.move_to_joint_positions(limb_joints)
q=np.array([resp.joints[0].position[0],resp.joints[0].position[1],resp.joints[0].position[2],resp.joints[0].position[3],resp.joints[0].position[4],resp.joints[0].position[5],resp.joints[0].position[6]])
return True , q
else:
rospy.logerr("INVALID POSE - No Valid Joint Solution Found.")
rospy.logerr("Result Error %d", resp.result_type[0])
q=np.array([0,0,0,0,0,0,0])
return False, q
def get_area(_vector,_f):
h=1.0/float(_f)
_v=np.power(_vector,2)
k=np.sum(_v)
k=k-0.5*(_v[0]+_v[-1])
area=k*h
return area
# Se determina el minimo tiempo para ejecutar el movimiento
def min_time(_q,_f):
vel_lim=[1.74, 1.328, 1.957, 1.957, 3.485, 3.485, 4.545]
# Luego de pruebas es el valor minimo para las pruebas. Es un concepto de seguridad para las pruebas.
v_factor=0.75
N=len(vel_lim)
k=len(_q)
t_min=np.zeros(k, dtype=np.float_)
t_tmp=np.zeros(N, dtype=np.float_)
for i in range (k-1):
for j in range (N):
t_tmp[j]= abs((_q[i+1,j]-_q[i,j])/((v_factor)*vel_lim[j]))
w=np.amax(t_tmp)# Se asume t[0]=0
t_min[i+1]=w+t_min[i]
return t_min, sum(t_min)
class Data():
def __init__(self):
self.write=False
rospy.Subscriber("/robot/joint_states", JointState, self.talker)
print("Init bridge")
rate = rospy.Rate(100) # 10hz
def talker(self,data):
if(data.name[0]=="head_pan"):
self.position=data.position[1:7]# extrae solo 7
if(self.write):
_file=open(self.file,"a")
_file.write(str(data.position[1])+","+str(data.position[2])+","+str(data.position[3])+","\
+str(data.position[4])+","+str(data.position[5])+","+str(data.position[6])+","+str(data.position[7])+\
","+str(data.velocity[1])+","+str(data.velocity[2])+","+str(data.velocity[3])+","\
+str(data.velocity[4])+","+str(data.velocity[5])+","+str(data.velocity[6])+","+str(data.velocity[7])+"\n")
_file.close()
def actual_joint_position(self):
return self.position
def writeon(self,_text):
self.write=True
self.file=_text
file=open(_text,"w")
file.close()
return True
def writeoff(self):
self.write=False
return True
|
# Vigenere cipher cryptoanalysis
This notebook studies the cryptoanalysis of the [Vigenere][wiki] cipher, which is polyalphabetic, namely two occurrences $a_{1}, a_{2}$ of character $a$ belonging to the plaintext are associated with occurrences $c_{1}, c_{2}$ in the ciphertext, such that $c_{1}\neq c_{2}$ with very high probability.
Our implementation closely follows a class lecture given by Prof. [Orazio Puglisi][puglisi] within Cryptography course at the University of Florence. In order to fully understand the last part, where the concept of *mutual coincidence index* is crucial, we rest on the explanation at pag. 20 of [this notes][notes].
[wiki]:https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher
[puglisi]:http://web.math.unifi.it/users/puglisi/
[notes]:http://iml.univ-mrs.fr/~ritzenth/cours/crypto.general.pdf
```python
import itertools
from itertools import *
from copy import copy, deepcopy
from heapq import *
from random import *
import matplotlib.pyplot as plt
from collections import Counter
from sympy import *
init_printing()
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 10.0)
```
---
### alphabet
Let $\mathcal{A}$ be our alphabet composed of standard English characters plus the `space` character. It will be sufficient to encode simple and (not so quite) short messages. To define it as a group $\frac{\mathbb{Z}}{n\mathbb{Z}}$ in the Python language we use a `dict` object, which can be reversed because it is a bijection.
```python
def make_alphabet_entry(i):
alpha = i + ord('a')
return chr(alpha),i
A = dict(map(make_alphabet_entry, range(26)))
A.update({' ':26})
inverse_A = {v:k for k,v in A.items()}
A
```
{'a': 0,
'b': 1,
'c': 2,
'd': 3,
'e': 4,
'f': 5,
'g': 6,
'h': 7,
'i': 8,
'j': 9,
'k': 10,
'l': 11,
'm': 12,
'n': 13,
'o': 14,
'p': 15,
'q': 16,
'r': 17,
's': 18,
't': 19,
'u': 20,
'v': 21,
'w': 22,
'x': 23,
'y': 24,
'z': 25,
' ': 26}
### string encoding and the *plaintext*
We define a function `encode` that consumes a string and produces a list of integer in our field. In parallel, function `decode` goes backwards, it consumes a list of integers and return a string. Such functions are useful in order to use the cipher and analyze it using `str` objects instead of the coded version using lists of integers.
```python
def encode(s, alphabet=A): return list(map(lambda i: alphabet[i], s))
def decode(e, inverse_alphabet=inverse_A): return "".join(map(lambda i: inverse_alphabet[i], e))
```
The following plaintext is a prose taken from [here]; before using it we have to swipe out punctuation marks:
[here]:http://www.bartleby.com/209/2.html
```python
def clean_text(text):
remove_chars = [',', '.', ';', ':', '-', '(', ')', "'", '"']
for rc in remove_chars: text = text.replace(rc, '')
text = text.replace('\n', ' ')
return "".join(filter(lambda c: not c.isdigit(), text))
with open('rest_plain_text.txt', 'r') as f:
plain_text = clean_text(f.read().lower())
encoded_plain_text = encode(plain_text)
chunk = 500
"{}...".format(plain_text[:chunk])
```
'the attraction of medieval literature comes perhaps more strongly from some other countries than from england in france and provence in germany and iceland there were literary adventurers more daring and achievements more distinguished it was not in england that the most wonderful things were produced there is nothing in old english that takes hold of the mind with that masterful and subduing power which still belongs to the lyrical stanzas of the troubadours and minnesingers to welsh romance or...'
With the following assert we ensure that function `decode` is the inverse of function `encode`:
```python
assert decode(encode(plain_text)) == plain_text
```
### key
Let $\textbf{k}=(k_{0},\ldots,k_{m-1}) \in \left(\frac{\mathbb{Z}}{n\mathbb{Z}}\right)^{m}$ be a *key* of length $m\in\mathbb{N}$. In order to have a meaningful analysis we build a function `generate_random_key` which generate a random key of random length, keeping it safe...we will uncover it only at the end to check our work:
```python
def generate_random_key(given_key=None, required_length=None, max_length=None, alphabet=A):
if given_key is not None: return given_key
if required_length is None and max_length is None: max_length = len(alphabet)
# the minimum length of the key is 3 to build interesting cases
length = required_length if required_length else randint(3, max_length)
key = [0] * length
# -1 in the following max limit because it is inclusive in the sense of `randint`.
for i in range(length):
key[i] = randint(0, len(alphabet)-1)
return key
#key = encode("ericsmullyan")
secret_key = generate_random_key(required_length=17)
```
### encryption and the *ciphertext*
Now we are in the position to define `encrypt` and `decrypt` functions, both of them consumes an *encoded* message, namely a list of integers, and a key. The encryption work by repeating the key as long as necessary to match the same length of the input $\textbf{x}=(x_{0},\ldots,x_{h})$, where $h > m-1$ otherwise the cipher is a *OneTimePad* which is unbreakable,
$$(\underbrace{x_{0},\ldots,x_{m-1}}_{k_{0},\ldots,k_{m-1}}
\underbrace{x_{m},\ldots,x_{m-1}}_{k_{0},\ldots,k_{m-1}}
\ldots
\underbrace{x_{lm},\ldots,x_{h}}_{k_{0},\ldots,k_{h \mod m}}) =
(y_{0},\ldots,y_{h}) = \textbf{y}$$
truncating the very right block to match plaintext suffix. At last, the ciphertext $\textbf{y}$ is obtained by addition modulo $n$ of corresponding symbols, where $n$ is the length of the alphabet. Decryption follows the same scheme, using modular subtraction.
```python
def encrypt(message, key, alphabet=A):
n = len(alphabet)
return [(p+v)%n for p,v in zip(message, cycle(key))]
def decrypt(cipher, key, alphabet=A):
n = len(alphabet)
return [(c-v)%n for c,v in zip(cipher, cycle(key))]
```
the following is the *ciphertext* produced by the application of function `encrypt` to the plaintext:
```python
cipher_text = encrypt(encoded_plain_text, secret_key)
'{}...'.format(decode(cipher_text)[:chunk])
```
' ksy cnzajpnqxqupgpsbhopilghnvohgcausybygmsgljtrrvbgpbpdjmarvjlnhqlavpnqnwzho djtjtuduwegdbuahhjehaesjlquj xyhiuwktkdiogdabzzlwvljhgjztjnhek xshau ekmvrkugnrgolm cawgjbocluopxjvlvljywavxbgpbpdjyirpjlbkdjjhfvgdezueupxbwexoggwqsshoupomgnqocgzoqzxia pjegxxrkugnrgknhtoaeoyizjcrabda blgpmkxxyjcheczzlwdazjfjjnoyhngrjhwtoesijztjvorydxatizdevrrzj dycrjbwlkwthjjnogpwlcjqqtowyjkjfwhvgcqpot hjibbkhnalaezzideywajstnjzwwjkjwmlvjlujjuj ksykhlqchheucrtihvnmejnpegpwqdsgnvxeqzkhl tespoioxnheqzcihwlhxjjhuwhqqczyl...'
Assuming to know the `secret_key`, we ensure that function `decrypt` is the inverse of function `encrypt`:
```python
assert decode(decrypt(cipher_text, secret_key)) == plain_text
```
### coincidence index
Let $I_{c}$ be the *coincidence index* of a sequence $\alpha$, over an alphabet $A$, defined as
$$ I_{c}(\alpha) = \sum_{i=0}^{n}{\frac{f_{a_{i}}^{(\alpha)}(f_{a_{i}}^{(\alpha)}-1)}{m(m-1)}} $$ where $n$ is the length of the alphabet, $m$ is the length of $\alpha$ and $f_{a_{i}}^{^{(\alpha)}}$ is the frequency of symbol $a_{i}\in A$, namely the number of occurrences of $a_{i}$, in $\alpha$. In other words, $I_{c}$ is the probability to sample two occurrences of the same symbol $a$, forall $a\in A$, from the sequence $\alpha$.
Index $I_{c}$ is invariant to shifting by the same constant $v$. Let $\alpha,\beta$ be two sequences of integers of length $l$ such that $\beta_{i} \equiv_{n} \alpha_{i} + v$, forall $i\in\lbrace0,\ldots,l\rbrace$; moreover, let $q_{\gamma_{i}}^{(\gamma)}$ be the probability to sample *two* occurrences of $\gamma_{i}$ from a sequence $\gamma$, we can state the relations
$$
I_{c}(\beta) = \sum_{a_{i}\in\frac{\mathbb{Z}}{n\mathbb{Z}}}{q_{a_{i}}^{(\beta)}}
= \sum_{a_{i}\in\frac{\mathbb{Z}}{n\mathbb{Z}}}{q_{a_{i}-v}^{(\alpha)}}
= \sum_{\hat{a}_{i}\in\frac{\mathbb{Z}}{n\mathbb{Z}}}{q_{\hat{a}_{i}}^{(\alpha)}}
= I_{c}(\alpha)
$$
where $\hat{a}_{i}\equiv_{n}a_{i}-v$, proving the invariance of $I_{c}$ when a sequence is produced by another one shifted by a constant $v\in\frac{\mathbb{Z}}{n\mathbb{Z}}$.
```python
def frequencies(lst, alphabet=A, inverse_alphabet=inverse_A):
""" Produces a `dict` counting occcurrences of each object of the alphabet within the iterable.
`frequencies` consumes an iterable $lst$ and an alphabet $A$,
produces a dictionary of entries $(k,v)$ where $k$ is a character
in $A$ and $v$ is the number of occurrences of $k$ in $lst$
"""
counter = Counter(lst)
return {k:counter[v] for k,v in alphabet.items()} # Counter handles the case of missing key returning 0
def length_from_frequencies(freqs):
""" Returns the length of the original sequence by summation of symbols frequencies. """
return sum(freqs.values())
def coincidence_index(freqs, alphabet=A):
""" Produces the I_{c} relative to frequencies matched against an alphabet. """
denom = length_from_frequencies(freqs)
if denom in range(2): return None
def mapper(a):
v = freqs[a] if a in freqs else 0
return v*(v-1)
return sum(map(mapper, alphabet.keys()))/(denom*(denom-1))
def draw_frequencies_histogram(seq, alphabet=A, y_maxlimit=None, normed=None):
#plaintext_length = len(plain_text)
#freqs = [plaintext_frequencies[inverse_A[ia]] for ia in sorted(inverse_A.keys())]
n, bins, patches = plt.hist(seq, len(alphabet),facecolor='green', alpha=0.5)
plt.xlabel('alphabet symbols')
plt.ylabel('frequencies' + (', normed respect: {}'.format(str(normed)) if normed else ''))
#plt.xticks(range(-1, len(alphabet)), sorted(alphabet.keys()))
if y_maxlimit: plt.ylim([0, y_maxlimit])
plt.grid(True)
plt.show()
return None
```
### frequencies comparison
The following are frequencies of alphabet symbols in the *plaintext*: in the analysis they are used as a `dict` produced by function `frequencies`, moreover it is possible to draw an histogram with the relative function.
```python
plaintext_frequencies = frequencies(encoded_plain_text)
draw_frequencies_histogram(encoded_plain_text, y_maxlimit=1800)
```
```python
plaintext_frequencies
```
{'a': 571,
'b': 90,
'c': 207,
'd': 272,
'e': 1001,
'f': 208,
'g': 162,
'h': 422,
'i': 594,
'j': 2,
'k': 46,
'l': 312,
'm': 184,
'n': 624,
'o': 633,
'p': 131,
'q': 8,
'r': 529,
's': 490,
't': 800,
'u': 158,
'v': 71,
'w': 129,
'x': 13,
'y': 129,
'z': 2,
' ': 1620}
The following histogram shows frequencies in the *ciphertext*: using the same `y_maxlimit` value, we see that they are spread "uniformly" over symbols.
```python
draw_frequencies_histogram(cipher_text, y_maxlimit=1800)
```
A first approach to encryption finishes computing the coincidence indexes of both *plaintext* and *ciphertext*:
```python
print("coincidence index of *plaintext*: {}\ncoincidence index of *ciphertext*: {}".format(
coincidence_index(plaintext_frequencies), coincidence_index(frequencies(cipher_text))))
```
coincidence index of *plaintext*: 0.07720140650073147
coincidence index of *ciphertext*: 0.03876412502919739
### finding the key *length* by spreading
The following set of functions allows us to probe the key *length* by repeatedly fixing a candidate length $l$, then spreading the *ciphertext* in a matrix with $l$ columns, then computing $I_{c}$ of each column and, finally, report $l$ if the majority of $I_{c}$ scores is greater than a threshold (.06 for English).
```python
def spread(message, block_length):
return [message[i:i+block_length] for i in range(0, len(message), block_length)]
def col(spreaded, c, join=False, joiner=lambda c: ''.join(decode(c))):
column = [lst[c] if c < len(lst) else None for lst in spreaded]
ready = list(filter(lambda i: i is not None, column))
return joiner(ready) if join else ready
def decode_spreaded(spreaded, join_as_str=False):
decoded_spread = list(map(decode, spreaded))
return '\n'.join(decoded_spread) if join_as_str else decoded_spread
def analyze(cipher_text, max_key_length=None):
res = {}
# we discard the case where the key length equals the
# length of the cipher text, since it is the case of
# OneTimePad cipher, which is unbreakable!
for d in range(2, len(cipher_text) if max_key_length is None else max_key_length + 1):
spreaded = spread(cipher_text, d)
res[d] = []
for c in range(d):
ci = coincidence_index(frequencies(col(spreaded, c)))
if ci: res[d].append(ci)
return res
def guess_key_length(analysis, threshold=0.06):
candidates = {}
for k,v in analysis.items():
cs = list(filter(lambda i: i > threshold, v))
if cs and len(cs) > ceiling(k/2): candidates[k] = cs
return candidates
```
here are $I_{c}$ scores witnesses for the candidate key length after spreading the *ciphertext* by columns:
```python
analysis = analyze(cipher_text, max_key_length=20)
guess = guess_key_length(analysis)
guess
```
```python
probing_key_length = 17
```
The following is the *ciphertext* spread over a matrix with a number of column equals the candidate length found in the previous cell.
```python
spreaded = decode_spreaded(spread(cipher_text, probing_key_length))
print("{}\n...\n{}".format("\n".join(spreaded[:10]), "\n".join(spreaded[-3:])))
```
ksy cnzajpnqxqup
gpsbhopilghnvohgc
ausybygmsgljtrrvb
gpbpdjmarvjlnhqla
vpnqnwzho djtjtud
uwegdbuahhjehaesj
lquj xyhiuwktkdio
gdabzzlwvljhgjztj
nhek xshau ekmvrk
ugnrgolm cawgjboc
...
kolzmiuezwscckxk
solyhxuxrpinvslkj
lvfzxbu
### mutual coincidence index
Once the length $m$ of key $\textbf{k}$ has been "established", we're left with finding actual key symbols $k_{i}$, for $i\in\{0,\ldots,m-1\}$. In order to fullfil this step, we need another object, which resembles the index of mutual coincidence $I_{c}$ but it is more general, in the sense that sampling occurs on two given sequences instead of the same one. Formally, let $I_{mc}(\alpha, \beta)$ be the *index of mutual coincidence* of sequences $\alpha$ and $\beta$, defined as
$$
I_{mc}(\alpha,\beta) = \sum_{a_{i}\in\frac{\mathbb{Z}}{n\mathbb{Z}}}{q_{a_{i}}^{(\alpha)}q_{a_{i}}^{(\beta)}}
$$
where $q_{a_{i}}^{(\nu)}$ is the probability to draw an occurrence of symbol $a_{i}$ in sequence $\nu$.
Let $\eta$ and $\gamma$ be two sequences of length $l$, produced by adding shifts $v_{\alpha}$ and $v_{\beta}$ to sequences $\alpha$ and $\beta$, respectively (formally, $\eta_{i} \equiv_{n} \alpha_{i} + v_{\alpha}$ and $\gamma_{i} \equiv_{n} \beta_{i} + v_{\beta}$, forall $i\in\lbrace0,\ldots,l-1\rbrace$). The inequality
$$
I_{mc}(\eta,\gamma)
= \sum_{a_{i}\in\frac{\mathbb{Z}}{n\mathbb{Z}}}{q_{a_{i}}^{(\eta)}q_{a_{i}}^{(\gamma)}}
= \sum_{a_{i}\in\frac{\mathbb{Z}}{n\mathbb{Z}}}{q_{a_{i}-v_{\alpha}}^{(\alpha)}q_{a_{i}-v_{\beta}}^{(\beta)}}
= \sum_{a_{i}\in\frac{\mathbb{Z}}{n\mathbb{Z}}}{q_{a_{i}}^{(\alpha)}q_{a_{i}+v_{\alpha}-v_{\beta}}^{(\beta)}}
\neq \sum_{a_{i}\in\frac{\mathbb{Z}}{n\mathbb{Z}}}{q_{a_{i}}^{(\alpha)}q_{a_{i}}^{(\beta)}}
= I_{mc}(\alpha,\beta)
$$
holds unless factor $v_{\alpha}-v_{\beta}$ in each subscript. We can define an even more general version of $I_{mc}$ as
$$
I_{mc}(\eta,\gamma,g)
= \sum_{a_{i}\in\frac{\mathbb{Z}}{n\mathbb{Z}}}{q_{a_{i}-g}^{(\eta)}q_{a_{i}}^{(\gamma)}}
= \sum_{a_{i}\in\frac{\mathbb{Z}}{n\mathbb{Z}}}{q_{a_{i}}^{(\alpha)}q_{a_{i}+v_{\alpha}-v_{\beta}+g}^{(\beta)}}
$$
where sequence $\eta$ is shifted back by $g\in\mathbb{N}$. Therefore we can state the equality with the usual definition according to
$$
I_{mc}(\eta,\gamma,g) = I_{mc}(\alpha,\beta) \leftrightarrow v_{\beta}-v_{\alpha}=g
$$
proving the invariance of $I_{mc}$ when two sequences are produced by shifting two other ones by constant values $q,w$ respectively, providing that $g = w-q$.
```python
def mutual_coincidence_index(fst_freqs, snd_freqs, offset=0,
alphabet=A, inverse_alphabet=inverse_A):
fst_len = length_from_frequencies(fst_freqs)
snd_len = length_from_frequencies(snd_freqs)
n = len(alphabet)
return sum(fst_freqs[k] * snd_freqs[inverse_alphabet[(v+offset) % n]]
for k,v in alphabet.items())/(fst_len * snd_len)
```
Previous generalization allows us to set the basis to break the cipher. It works as follows: for each pair $(\eta,\gamma)$ of different columns in the spread-matrix form of the *ciphertext*, fix a $g\in\frac{\mathbb{Z}}{n\mathbb{Z}}$ to compute $I_{mc}(\eta,\gamma,g)$: if such index value is close to $I_{c}(\nu)$, where $\nu$ is a structured sequence using the English language, namely close to $0.065$, then collect equation $k_{i(\beta)}-k_{i(\alpha)}=g$, where function $i(\nu)$ return the zero-based index of column $\nu$ in the matrix spread. Such equations are important since state difference relations over symbols of the key.
```python
def build_offsets_eqs(cipher_text, key_length, indexed_sym, threshold=.06, alphabet=A):
n = len(alphabet)
eqs = {c:{} for c in range(key_length)}
spreaded = spread(cipher_text, key_length)
for c,a in itertools.product(range(key_length), repeat=2):
if a == c: continue
eqs[c][a]=[]
for g in range(1,n):
column_freqs = frequencies(col(spreaded, c))
another_freqs = frequencies(col(spreaded, a))
mci = mutual_coincidence_index(column_freqs, another_freqs, g)
if mci > threshold:
eqs[c][a].append(tuple([Eq(indexed_sym[a]-indexed_sym[c],g,evaluate=True), mci]))
return eqs
```
```python
k_sym=IndexedBase('k')
eqs_dict = build_offsets_eqs(cipher_text, key_length=probing_key_length, indexed_sym=k_sym)
```
The following cell report the set of difference equation collected respect the *first* column of the spread matrix: we observe that such set fails to instantiate $k_{6}$ because no likely equation gives a relation for it. On the contrary, it can be the case that collecting equations for a pair of columns with indexes $(c,a)$ yields one or more equations, namely $\{k_{a}-k_{c}=g_{u_{0}},\ldots,k_{a}-k_{c}=g_{u_{v}}\}$, for some $v\in\mathbb{N}$: to properly explore all keys space, we have to consider the product of each list of "equally-likely" equations.
```python
eqs_dict[0]
```
The following function implements the last observation, namely it produces the complete keys space where we've to look for the good one.
```python
def explode_key_space(eqs_dict):
res = {}
for c, eq_dict in eqs_dict.items():
eqs_list = []
for a, eqs in eq_dict.items():
if not eqs:
res[c] = [] # no equations in `eqs` causes the product to be empty as well
break
eqs_list.append([[a] + list(eq_pair) for eq_pair in eqs])
else: # if no empty eqs was found then it is meaningful to cross product them
res[c] = list(itertools.product(*eqs_list))
return res
```
```python
eqs_dict_pure = explode_key_space(eqs_dict)
eqs_dict_pure
```
```python
print(eqs_dict_pure)
```
{0: [], 1: [([0, Eq(k[0] - k[1], 4), 0.07966023276727183], [2, Eq(-k[1] + k[2], 11), 0.07773136623701599], [3, Eq(-k[1] + k[3], 22), 0.08098632850682272], [4, Eq(-k[1] + k[4], 23), 0.07777698132388015], [5, Eq(-k[1] + k[5], 7), 0.07751632368465639], [6, Eq(-k[1] + k[6], 18), 0.08160213217948885], [7, Eq(-k[1] + k[7], 5), 0.07663483069049033], [8, Eq(-k[1] + k[8], 24), 0.07533571395930305], [9, Eq(-k[1] + k[9], 4), 0.08045710629908409], [10, Eq(k[10] - k[1], 20), 0.08440341817849473], [11, Eq(k[11] - k[1], 2), 0.07514313132829789], [12, Eq(k[12] - k[1], 26), 0.07765649786853461], [13, Eq(k[13] - k[1], 7), 0.07829952800934842], [14, Eq(k[14] - k[1], 14), 0.07823750987393997], [15, Eq(k[15] - k[1], 3), 0.07887727590236387], [16, Eq(k[16] - k[1], 7), 0.079944640653867])], 2: [([0, Eq(k[0] - k[2], 20), 0.07727521536837441], [1, Eq(k[1] - k[2], 16), 0.07773136623701599], [3, Eq(-k[2] + k[3], 11), 0.07670176856208213], [4, Eq(-k[2] + k[4], 12), 0.07599473471568768], [5, Eq(-k[2] + k[5], 23), 0.07530725019223501], [6, Eq(-k[2] + k[6], 7), 0.07744790105436015], [7, Eq(-k[2] + k[7], 21), 0.07558052238854689], [8, Eq(-k[2] + k[8], 13), 0.07440544192817647], [9, Eq(-k[2] + k[9], 20), 0.07780991115086075], [10, Eq(k[10] - k[2], 9), 0.08161586619750491], [11, Eq(k[11] - k[2], 18), 0.07366122430327521], [12, Eq(k[12] - k[2], 15), 0.07579921791867138], [13, Eq(k[13] - k[2], 23), 0.07608645980898414], [14, Eq(k[14] - k[2], 3), 0.07650100208250371], [15, Eq(k[15] - k[2], 19), 0.07666747181438952], [16, Eq(k[16] - k[2], 23), 0.0756392764115654])], 3: [([0, Eq(k[0] - k[3], 9), 0.07921711478059143], [1, Eq(k[1] - k[3], 5), 0.08098632850682272], [2, Eq(k[2] - k[3], 16), 0.07670176856208213], [4, Eq(-k[3] + k[4], 1), 0.07748374147975341], [5, Eq(-k[3] + k[5], 12), 0.07601428403862946], [6, Eq(-k[3] + k[6], 23), 0.08063769891436093], [7, Eq(-k[3] + k[7], 10), 0.0768502621082249], [8, Eq(-k[3] + k[8], 2), 0.07454906287333285], [9, Eq(-k[3] + k[9], 9), 0.07961822941487522], [10, Eq(k[10] - k[3], 25), 0.08357759774384552], [11, Eq(k[11] - k[3], 7), 0.07412146415025363], [12, Eq(k[12] - k[3], 4), 0.07712771166136792], [13, Eq(k[13] - k[3], 12), 0.07806777602966425], [14, Eq(k[14] - k[3], 19), 0.07739536887734118], [15, Eq(k[15] - k[3], 8), 0.07830932034651818], [16, Eq(k[16] - k[3], 12), 0.07879893720500585])], 4: [([0, Eq(k[0] - k[4], 8), 0.07754238944857876], [1, Eq(k[1] - k[4], 4), 0.07777698132388015], [2, Eq(k[2] - k[4], 15), 0.07599473471568768], [3, Eq(k[3] - k[4], 26), 0.07748374147975341], [5, Eq(-k[4] + k[5], 11), 0.07458066702289877], [6, Eq(-k[4] + k[6], 22), 0.0781581931212449], [7, Eq(-k[4] + k[7], 9), 0.07591999007709833], [8, Eq(-k[4] + k[8], 1), 0.07368407309000463], [9, Eq(-k[4] + k[9], 8), 0.0778360240499801], [10, Eq(k[10] - k[4], 24), 0.08226216045070864], [11, Eq(k[11] - k[4], 6), 0.07356982915635751], [12, Eq(k[12] - k[4], 3), 0.07617785495590185], [13, Eq(k[13] - k[4], 11), 0.07654669965596256], [14, Eq(k[14] - k[4], 18), 0.0761517420567825], [15, Eq(k[15] - k[4], 7), 0.07650100208250371], [16, Eq(k[16] - k[4], 11), 0.07624640131609012])], 5: [], 6: [([0, Eq(k[0] - k[6], 13), 0.07994369794992767], [1, Eq(k[1] - k[6], 9), 0.08160213217948885], [2, Eq(k[2] - k[6], 20), 0.07744790105436015], [3, Eq(k[3] - k[6], 4), 0.08063769891436093], [4, Eq(k[4] - k[6], 5), 0.0781581931212449], [5, Eq(k[5] - k[6], 16), 0.07685164670463579], [7, Eq(-k[6] + k[7], 14), 0.0780579836924945], [8, Eq(-k[6] + k[8], 6), 0.07515618777785757], [9, Eq(-k[6] + k[9], 13), 0.08055502967078162], [10, Eq(k[10] - k[6], 2), 0.08512478701666656], [11, Eq(k[11] - k[6], 11), 0.0747971354149666], [12, Eq(k[12] - k[6], 8), 0.07855086466337209], [13, Eq(k[13] - k[6], 16), 0.07891644525104288], [14, Eq(k[14] - k[6], 23), 0.078315848571298], [15, Eq(k[15] - k[6], 12), 0.07935057219890196], [16, Eq(k[16] - k[6], 16), 0.0800752051494637])], 7: [([0, Eq(k[0] - k[7], 26), 0.07737252009061175], [1, Eq(k[1] - k[7], 22), 0.07663483069049033], [2, Eq(k[2] - k[7], 6), 0.07558052238854689], [3, Eq(k[3] - k[7], 17), 0.0768502621082249], [4, Eq(k[4] - k[7], 18), 0.07591999007709833], [5, Eq(k[5] - k[7], 2), 0.07397457909270733], [6, Eq(k[6] - k[7], 13), 0.0780579836924945], [8, Eq(-k[7] + k[8], 19), 0.07368324673243756], [9, Eq(-k[7] + k[9], 26), 0.07728353318574666], [10, Eq(k[10] - k[7], 15), 0.08146261228413813], [11, Eq(k[11] - k[7], 24), 0.07246026114339342], [12, Eq(k[12] - k[7], 21), 0.07591993695411188], [13, Eq(k[13] - k[7], 2), 0.07610632780591807], [14, Eq(k[14] - k[7], 9), 0.07572700607241775], [15, Eq(k[15] - k[7], 25), 0.07659683004751332], [16, Eq(k[16] - k[7], 2), 0.07579240637129711])], 8: [([0, Eq(k[0] - k[8], 7), 0.07471226849282875], [1, Eq(k[1] - k[8], 3), 0.07533571395930305], [2, Eq(k[2] - k[8], 14), 0.07440544192817647], [3, Eq(k[3] - k[8], 25), 0.07454906287333285], [4, Eq(k[4] - k[8], 26), 0.07368407309000463], [5, Eq(k[5] - k[8], 10), 0.07298881715095214], [6, Eq(k[6] - k[8], 21), 0.07515618777785757], [7, Eq(k[7] - k[8], 8), 0.07368324673243756], [9, Eq(-k[8] + k[9], 7), 0.075082813128456], [10, Eq(k[10] - k[8], 23), 0.07829396780343287], [11, Eq(k[11] - k[8], 5), 0.07217576984326818], [12, Eq(k[12] - k[8], 2), 0.0736799767174936], [13, Eq(k[13] - k[8], 10), 0.07407564852571376], [14, Eq(k[14] - k[8], 17), 0.07396446801761884], [15, Eq(k[15] - k[8], 6), 0.07445824027415805], [16, Eq(k[16] - k[8], 10), 0.07409526861537757])], 9: [], 10: [([0, Eq(k[0] - k[10], 11), 0.08352537194560683], [1, Eq(-k[10] + k[1], 7), 0.08440341817849473], [2, Eq(-k[10] + k[2], 18), 0.08161586619750491], [3, Eq(-k[10] + k[3], 2), 0.08357759774384552], [4, Eq(-k[10] + k[4], 3), 0.08226216045070864], [5, Eq(-k[10] + k[5], 14), 0.08020576964506042], [6, Eq(-k[10] + k[6], 25), 0.08512478701666656], [7, Eq(-k[10] + k[7], 12), 0.08146261228413813], [8, Eq(-k[10] + k[8], 4), 0.07829396780343287], [9, Eq(-k[10] + k[9], 11), 0.0840753542243688], [11, Eq(-k[10] + k[11], 9), 0.07843130843107952], [12, Eq(-k[10] + k[12], 6), 0.0816424631060564], [13, Eq(-k[10] + k[13], 14), 0.08213296534765163], [14, Eq(-k[10] + k[14], 21), 0.0820544849889964], [15, Eq(-k[10] + k[15], 10), 0.08242072666272085], [16, Eq(-k[10] + k[16], 14), 0.08236840642361735])], 11: [([0, Eq(k[0] - k[11], 2), 0.07398110731748715], [1, Eq(-k[11] + k[1], 25), 0.07514313132829789], [2, Eq(-k[11] + k[2], 9), 0.07366122430327521], [3, Eq(-k[11] + k[3], 20), 0.07412146415025363], [4, Eq(-k[11] + k[4], 21), 0.07356982915635751], [5, Eq(-k[11] + k[5], 5), 0.07258080310221242], [6, Eq(-k[11] + k[6], 16), 0.0747971354149666], [7, Eq(-k[11] + k[7], 3), 0.07246026114339342], [8, Eq(-k[11] + k[8], 22), 0.07217576984326818], [9, Eq(-k[11] + k[9], 2), 0.07506973306868013], [10, Eq(k[10] - k[11], 18), 0.07843130843107952], [12, Eq(-k[11] + k[12], 24), 0.07358514628411852], [13, Eq(-k[11] + k[13], 5), 0.07363092649333408], [14, Eq(-k[11] + k[14], 12), 0.07316985438623455], [15, Eq(-k[11] + k[15], 1), 0.0734641557311917], [16, Eq(-k[11] + k[16], 5), 0.07346742574613566])], 12: [([0, Eq(k[0] - k[12], 5), 0.07752919748532781], [1, Eq(-k[12] + k[1], 1), 0.07765649786853461], [2, Eq(-k[12] + k[2], 12), 0.07579921791867138], [3, Eq(-k[12] + k[3], 23), 0.07712771166136792], [4, Eq(-k[12] + k[4], 24), 0.07617785495590185], [5, Eq(-k[12] + k[5], 8), 0.07488526644949439], [6, Eq(-k[12] + k[6], 19), 0.07855086466337209], [7, Eq(-k[12] + k[7], 6), 0.07591993695411188], [8, Eq(-k[12] + k[8], 25), 0.0736799767174936], [9, Eq(-k[12] + k[9], 5), 0.07802582657802747], [10, Eq(k[10] - k[12], 21), 0.0816424631060564], [11, Eq(k[11] - k[12], 3), 0.07358514628411852], [13, Eq(-k[12] + k[13], 8), 0.07700231190056539], [14, Eq(-k[12] + k[14], 15), 0.07575316619196949], [15, Eq(-k[12] + k[15], 4), 0.07659683004751332], [16, Eq(-k[12] + k[16], 8), 0.07626001850828458])], 13: [], 14: [([0, Eq(k[0] - k[14], 17), 0.07743127411363028], [1, Eq(-k[14] + k[1], 13), 0.07823750987393997], [2, Eq(-k[14] + k[2], 24), 0.07650100208250371], [3, Eq(-k[14] + k[3], 8), 0.07739536887734118], [4, Eq(-k[14] + k[4], 9), 0.0761517420567825], [5, Eq(-k[14] + k[5], 20), 0.07529654461062403], [6, Eq(-k[14] + k[6], 4), 0.078315848571298], [7, Eq(-k[14] + k[7], 18), 0.07572700607241775], [8, Eq(-k[14] + k[8], 10), 0.07396446801761884], [9, Eq(-k[14] + k[9], 17), 0.07796369629409207], [10, Eq(k[10] - k[14], 6), 0.0820544849889964], [11, Eq(k[11] - k[14], 15), 0.07316985438623455], [12, Eq(k[12] - k[14], 12), 0.07575316619196949], [13, Eq(k[13] - k[14], 20), 0.0762992586876122], [15, Eq(-k[14] + k[15], 16), 0.07664915028661681], [16, Eq(-k[14] + k[16], 20), 0.07643659931525887])], 15: [([0, Eq(k[0] - k[15], 1), 0.07849211064035357], [1, Eq(-k[15] + k[1], 24), 0.07887727590236387], [2, Eq(-k[15] + k[2], 8), 0.07666747181438952], [3, Eq(-k[15] + k[3], 19), 0.07830932034651818], [4, Eq(-k[15] + k[4], 20), 0.07650100208250371], [5, Eq(-k[15] + k[5], 4), 0.07550544780357878], [6, Eq(-k[15] + k[6], 15), 0.07935057219890196], [7, Eq(-k[15] + k[7], 2), 0.07659683004751332], [8, Eq(-k[15] + k[8], 21), 0.07445824027415805], [9, Eq(-k[15] + k[9], 1), 0.07841168834141572], [10, Eq(k[10] - k[15], 17), 0.08242072666272085], [11, Eq(k[11] - k[15], 26), 0.0734641557311917], [12, Eq(k[12] - k[15], 23), 0.07659683004751332], [13, Eq(k[13] - k[15], 4), 0.07712984248338015], [14, Eq(k[14] - k[15], 11), 0.07664915028661681], [16, Eq(-k[15] + k[16], 4), 0.07720178281214746])], 16: []}
In order to instantiate candidates keys, for each index column $c$ we use the set of equations $\{k_{a}-k_{c}=g_{u}\}$, for some $u\in\mathbb{N}$ and $a\in\{0,\ldots,m-1\}\setminus\{c\}$ as follows: for each equation $k_{a}-k_{c}=g_{u}$, instantiate $k_{c} = s$, for $s\in\frac{\mathbb{Z}}{n\mathbb{Z}}$, and solve it respect $k_{a}$. Therefore for each column index $c$ we have a candidate key if each symbol $k_{i}$ has been instantiated.
```python
def candidate_keys(eqs_dict, indexed_sym, alphabet=A):
key_length = len(eqs_dict)
n = len(alphabet)
candidates=set()
for c, eqs_tuples in eqs_dict.items():
for d in range(len(alphabet)):
for eq_tuple in eqs_tuples:
key = [indexed_sym[i] for i in range(key_length)]
key[c] = d
for a, eq, mci in eq_tuple:
subs_eq = eq.subs(indexed_sym[c],d)
key[a] = solve(subs_eq, indexed_sym[a])[0]
key[a] = key[a] % n
for k in key:
if isinstance(k, Indexed): break
else:
candidates.add(tuple(key)) # `tuple` application to make `key` hashable
return candidates
```
```python
possible_keys = candidate_keys(eqs_dict_pure, k_sym)
```
The last step to filter out mistaken keys, we use each candidate key to perform a decryption, checking it against frequencies of an arbitrary English prose:
```python
def arbitrary_frequencies(length, filename='rest_plain_text.txt'):
with open(filename, 'r') as f:
text = clean_text(f.read().lower())
text = text[:length]
return frequencies(encode(text))
def attempt_keys(candidate_keys, cipher_text, threshold=.06, arbitrary_freqs=None):
sols = set()
for key in candidate_keys:
decrypted = decrypt(cipher_text, key)
freqs = frequencies(decrypted)
if arbitrary_freqs:
good = True
for k,v in arbitrary_freqs.items():
if 1-abs((freqs[k]-v)/v) < .6: good = False
if good: sols.add(decode(key))
else:
ci = coincidence_index(freqs)
if ci > threshold: sols.add(decode(key))#sols.add((ci, decode(key)))
return sols
```
```python
sols = attempt_keys(possible_keys, cipher_text, arbitrary_freqs=arbitrary_frequencies(len(cipher_text)))
```
```python
len(sols), sols
```
(1, {'hdoz kviahxfckrgk'})
```python
for sol in sols:
key = sol
print("key:({})\nplaintext:\n{}\n\n".format(
key, decode(decrypt(cipher_text, encode(key)))[:chunk]))
```
key:(hdoz kviahxfckrgk)
plaintext:
the attraction of medieval literature comes perhaps more strongly from some other countries than from england in france and provence in germany and iceland there were literary adventurers more daring and achievements more distinguished it was not in england that the most wonderful things were produced there is nothing in old english that takes hold of the mind with that masterful and subduing power which still belongs to the lyrical stanzas of the troubadours and minnesingers to welsh romance or
```python
decode(secret_key)
```
'hdoz kviahxfckrgk'
**:)**
<!-- -->
<center>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
</a>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
</a>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
</a>
<br />
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.</center>
|
Require Import Crypto.Specific.Framework.RawCurveParameters.
Require Import Crypto.Util.LetIn.
(***
Modulus : 2^165 - 25
Base: 64
***)
Definition curve : CurveParameters :=
{|
sz := 3%nat;
base := 64;
bitwidth := 64;
s := 2^165;
c := [(1, 25)];
carry_chains := None;
a24 := None;
coef_div_modulus := None;
goldilocks := None;
karatsuba := None;
montgomery := true;
freeze := Some false;
ladderstep := false;
mul_code := None;
square_code := None;
upper_bound_of_exponent_loose := None;
upper_bound_of_exponent_tight := None;
allowable_bit_widths := None;
freeze_extra_allowable_bit_widths := None;
modinv_fuel := None
|}.
Ltac extra_prove_mul_eq _ := idtac.
Ltac extra_prove_square_eq _ := idtac.
|
!> Module file case_config.mod
!
!> @details Provides concrete types and bases of extensible types.
module case_config
use kinds, only : ccs_int, ccs_real
use parallel_types, only: parallel_environment
implicit none
private
integer(ccs_int), public :: num_steps = huge(0)
real(ccs_real), public :: velocity_relax = huge(0.0)
real(ccs_real), public :: pressure_relax = huge(0.0)
end module case_config |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import numpy as np
import pandas as pd
import scipy.stats as sp
import statsmodels.stats.api as sms
import mct.Constants as Constants
# t-test
def get_t_test_result(a, b):
# Run t-test on control and treatment.
(mean_diff, control_diff, stat, p_value) = __two_sample_t_test(a, b)
(lower, upper) = __t_test_conf_interval(a, b)
mean_rel = mean_diff / control_diff
lower = lower
upper = upper
return mean_diff, mean_rel, lower, upper, stat, p_value
def __two_sample_t_test(a, b):
# Run t-test on control and treatment.
(stat, p_value) = sp.ttest_ind(a, b, equal_var=False)
control_mean = np.mean(a)
mean_diff = control_mean - np.mean(b)
return mean_diff, control_mean, stat, p_value
def __t_test_conf_interval(a, b):
cm = sms.CompareMeans(sms.DescrStatsW(a), sms.DescrStatsW(b))
return cm.tconfint_diff(usevar='pooled')
# bernoulli test - Test of Proportions
def chi_squared_results(a, b):
# Run Chi-Squared Test on control and treatment.
mean_control = np.mean(a)
mean_treatment = np.mean(b)
mean_diff = mean_treatment - mean_control
df = pd.concat([
pd.DataFrame(data={'metric': a, 'label': Constants.control_group}),
pd.DataFrame(data={'metric': b, 'label': Constants.treatment_group})
])
cont_table = pd.crosstab(df['label'], df['metric'])
chi2, p_val, dof, expected = sp.chi2_contingency(cont_table)
return mean_diff, mean_control, mean_treatment, chi2, p_val
def ci_proportion_bounds(p, n):
err = __ci_proportion(p, n)
return (p - err), (p + err)
def __se_proportion(p, n):
return np.sqrt((p * (1 - p)) / n)
def __ci_proportion(p, n):
return 1.96 * __se_proportion(p, n)
"""
Created on Fri Apr 8 09:48:53 2016
Python utility to perform if data is biased between two groups.
NOTE: This only performs a bias check for categorical values.
It does not perform a bias check for numeric variables.
See examples in https://onlinecourses.science.psu.edu/stat414/node/311
@author: jayagup
"""
def chi_square_bias_test(control, treatment, groups, group_column_name, other_threshold, p_value):
"""
Compute the chi square test of homogeneity between two
groups.
See details in https://onlinecourses.science.psu.edu/stat414/node/311
:input data_1: The first data frame.
:input data_2: The second data frame.
:input groups: The name of the groups.
:input p_value: The p-value with which to evaluate univariate table.
:returns is_biased: True if biased else False
:returns table_biased: A table of results with differences..
"""
contingency_table_c = __get_contingency_table(control)
contingency_table_t = __get_contingency_table(treatment)
# Add group information to the dataframes.
contingency_table_c[group_column_name] = groups[0]
contingency_table_t[group_column_name] = groups[1]
# Create a single contingency table including both groups.
contingency_table = contingency_table_c.append(contingency_table_t)
# Run the bias check.
return chi_square_bias_test_contingency(contingency_table, other_threshold, p_value)
def chi_square_bias_test_contingency(df_cont_table, other_threshold, p_value):
"""
Chi square test of homogeneity over all features.
"""
# Perform the bias check for all features, one feature at a time.
bias_results = []
deviation = pd.DataFrame()
for feature in df_cont_table[Constants.feature].unique():
chi2, p_val, dof, perc_dev, feature_deviation = bias_check_covariate(
df_cont_table, feature, other_threshold)
feature_deviation[Constants.feature] = feature
deviation = deviation.append(feature_deviation)
bias_results.append({
Constants.feature: feature,
"chi_square": chi2,
"p_value": p_val,
Constants.degree_of_freedom: dof,
Constants.percentage_deviation: perc_dev})
df_bias_results = pd.DataFrame(bias_results)
# Test whether each feature meets the p-value criterion.
p_value_check = (np.sum(df_bias_results.p_value < p_value) > 0)
return df_bias_results, deviation, p_value_check
def bias_check_covariate(df_cont_table, feature, other_threshold=1.0):
"""
Chi square test of homogeneity for single feature.
:input df_cont_table: Counts for the feature.
:input feature: The name of the feature.
:return outcome of the chi square bias check.
"""
# Filter the feature.
df_cont_feature = df_cont_table[df_cont_table.feature == feature]
# Pivot the counts to create R X C format.
df_cont_pivot = pd.pivot_table(
df_cont_feature,
values='count',
columns=Constants.group_column_name,
index=Constants.bin_column)
df_cont_pivot, grps = __combine_small_bins(df_cont_pivot, other_threshold)
# Feed the contingency table to chi square test.
chi2, p_val, dof, expected = sp.chi2_contingency(df_cont_pivot)
# Compute the probability deviation from expected.
diff_percent = np.abs(expected - df_cont_pivot) / sum(expected) * 100.0
# Compute percentage for each bin.
grp_percent = list(map(lambda x: x + "_percent", grps)) # control_percent, treatment_percent
diff_percent[grp_percent] = df_cont_pivot[grps] / df_cont_pivot[grps].sum() * 100.0
diff_percent.reset_index(inplace=True)
# Sum of differences of expected probability and observed probability
# Note that the sum should be the same for the two columns.
perc_dev = np.max(diff_percent[grps.tolist()].max())
return chi2, p_val, dof, perc_dev, diff_percent
def __combine_small_bins(df_cont_pivot, other_threshold):
"""
Combine bins that are too small in both control and treatment group into Constants.other_feature_cluster_name
:input df_cont_pivot: contingency pivot table.
"""
# if there are bins which are too small in both groups
# then set them to the other group.
grps = df_cont_pivot.columns
df_cont_pivot.reset_index(inplace=True)
df_cont_pivot.fillna(0, inplace=True)
other_grp_1 = df_cont_pivot[grps[0]] / df_cont_pivot[grps[0]].sum() * 100.0 < other_threshold
other_grp_2 = df_cont_pivot[grps[1]] / df_cont_pivot[grps[1]].sum() * 100.0 < other_threshold
other_grp = other_grp_1 & other_grp_2
df_cont_pivot.loc[other_grp, Constants.bin_column] = Constants.other_feature_cluster_name
# Combine all the others by grouping by bin again
df_cont_pivot = df_cont_pivot.groupby(Constants.bin_column).sum()
df_cont_pivot.fillna(0, inplace=True)
return df_cont_pivot, grps
def __get_contingency_table(data: pd.DataFrame) -> pd.DataFrame:
"""
Create a contingency table for the dataframe.
:input df: The dataframe.
:returns The contingency table data frame with [Constants.bin_column ,'count', Constants.feature] columns
"""
contingency_data_frame = pd.DataFrame()
for c in data.columns:
contingency_data_frame = contingency_data_frame.append(_get_feature_values_distribution(data[c]))
return contingency_data_frame
def _get_feature_values_distribution(feature):
"""
Get the count for each feature value.
"""
# TODO: this would perform poorly when we have a numerical feature.
distribution = pd.DataFrame(feature
.groupby(feature.values)
.agg('count')
.reset_index()
.rename(columns={"index": Constants.bin_column, feature.name: 'count'})
)
distribution[Constants.feature] = feature.name
return distribution
|
function [randomizedCatalog, okPressed] = syn_invoke_random_dialog(catalog)
% permutes/generates a catalog based on interactive choices
%
% [randCatalog, ok] = SYN_INVOKE_RANDOM_DIALOG(catalog) allows permutation of longitude,
% latitude, depth, dates, and magnitudes. randCatalog contains the permutated catalog
%
% if user cancels, then ok is false and no catalog is returend.
randomizedCatalog=[];
% Open figure
zdlg = ZmapDialog();
zdlg.AddHeader('Spatio-temporal permutations');
zdlg.AddCheckbox('bTimes', 'Permute Times', false, [], 'tooltip');
zdlg.AddCheckbox('bLon', 'Permute Longitudes', false, [], 'tooltip');
zdlg.AddCheckbox('bLat', 'Permute Latitudes', false, [], 'tooltip');
zdlg.AddCheckbox('bDepth', 'Permute Depths', false, [], 'tooltip');
zdlg.AddHeader('Magnitude Options')
zdlg.AddCheckbox('bMags', 'Permute Magnitudes', false, [], 'has no effect if new magnitudes are created');
zdlg.AddCheckbox('createMags', 'Create New magnitudes', false, {'fBValue', 'fMc', 'fInc'}, 'tooltip');
zdlg.AddEdit('fBValue', 'b-value', 1, 'tooltip');
zdlg.AddEdit('fMc', 'Magnitude of completeness', 1, 'tooltip');
zdlg.AddEdit('fInc', 'Bin spacing', 0.1, 'bins into which magnitudes will fall');
passes = false;
while ~passes
[res, okPressed] = zdlg.Create('Name', 'Synthetic Catalog Choices');
if ~okPressed
return
end
passes = validate_choices(res);
end
if res.createMags
randomizedCatalog = syn_randomize_catalog(catalog, res.bLon, res.bLat,...
res.bDepth, res.bTimes, 'create', res.fBValue, res.fMc, res.fInc);
else
randomizedCatalog = syn_randomize_catalog(catalog, res.bLon, res.bLat,...
res.bDepth, res.bTimes, 'perturb');
end
msg.infodisp(randomizedCatalog, 'permutated catalog')
end
function ok = validate_choices(res)
ttl = 'permuted catalog';
ok = true;
wasChanged = res.bLon || res.bMags || res.bLat || res.bTimes || res.bDepth || res.createMags;
if ~wasChanged
msgtxt = 'No changes were specified';
ok = false;
elseif res.createMags
if res.fInc <= 0.1
msgtxt = 'bin spacing must be greater than 0';
ok = false;
end
if res.fInc <= 0
msgtxt = 'b-value must be positive';
ok = false;
end
end
if ~ok
msg.errordisp(msgtxt, ttl);
mdlg = errordlg(msgtxt, ttl);
waitfor(mdlg);
end
end
|
Nissan GTR 2020 Interior is free HD wallpaper. This wallpaper was upload at March 25, 2019 upload by Tamar Th in GTR.
Nissan GTR 2020 Interior in your computer by clicking resolution image in Download by size:. Don't forget to rate and comment if you interest with this wallpaper. |
\documentclass[a4paper,12pt]{article}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=20mm,
top=20mm,
}
\usepackage[export]{adjustbox}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{multicol}
\pagestyle{fancy}
\fancyhf{}
\rhead{\textit{LAB -2}}
\lhead{\textit{Pul074BEX004}}
\rfoot{\thepage}
\usepackage{mathpazo} % Palatino font
\usepackage{graphicx}
\usepackage{float}
\input{./AnsENV.tex} %% Answer environment
\input{./QueENV.tex} %% Question Environment
\input{./CoverPage.tex} %%% cover page
\include{./CMD output.tex} %%% Cmd OUTPUT blue background
\newcommand{\SYN}[1]{\quad Command used:-$\textbf{#1}$}
\begin{document}
%%%% COver page
\CP{Computer Network}{Lab \#2}{Study of Basic Networking Commands}
{SHARAD KUMAR GHIMIRE}
%%%%%%%%%%%%%%%%%%%%
\pagenumbering{gobble}
\renewcommand{\contentsname}{Table of Contents}
\tableofcontents
%\pagebreak
%\listoffigures
%\pagebreak
%\listoftables
\pagebreak
\lstlistoflistings
\pagebreak
\pagenumbering{arabic}
\section{Title} \textbf{Study of Basic Networking Commands}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Objective}
\begin{itemize}
\item To be familiar with basic networking commands and their uses
\end{itemize}
%%%%%%%%%%%%%%%%%%%%%
\section{Requirement}
\begin{itemize}
\item Computer with Internet Connectivity
\end{itemize}
%%%%%%%%%%%%%%%%%%%
\section {Procedure}
This lab session is code along so , we coded along with the instructor and
noted the output of some useful network command . Command line interface "CMD" for windows and for Linux "Terminal" is used .
Some code used are same and some differ as per the platforms. We study different command and their varient/parameters
some of them are :-
\begin{itemize}
\item ipconfig
\item ping
\item getmac
\item tracert
\item arp
\item hostname
\item netstat
\item route
\end{itemize}
\pagebreak
\section{Exercises}
%%%%%%%%%%%%%%%11111111111111
\begin{Q}
{Explain the following commands briefly with their functions and few syntaxes.}
\end{Q}
\begin{enumerate}
\item \textsc {\bfseries{ipconfig:}}
As per the Documentation provided in Microsoft website it displays all TCP/IP current setup and refreshes
DHCP and DNS settings. with the help of command prompt help statement all syntaxes and some of the function
are listed below.
\SYN{ipconfig /?}
\CMD{Ipconfighelp.txt}{ipconfig Syntaxes and Uses}
\pagebreak
\item \textsc {\bfseries{ping:}}
It is used along with url or Ip address. Source device will send packets,Internet Control Message Protocol (ICMP),
to destination and waits for response.
If the destination device responds it shows the round trip time in ms.Ping has various uses in troubleshoot Connectivity and name resolution.
generally used to test whether the targeted domain or Ip has access to internet and if it loose any packet during transfer.
All ping syntaxes ,parameters and its uses are listed below:
\SYN{ping /?}
\CMD{pinghelp.txt}{ping Syntaxes and Uses}
\item \textsc {\bfseries{getmac:}}
This command retrieves the MAC (Media Access Control) Address or Physical Address of connected adapters .
This command can also obtain the MAC address of Remote device/computer too.
All getmac syntaxes ,parameters and its uses are listed below:
\SYN{getmac /?}
\CMD{./getmachelp.txt}{getmac Syntaxes and Uses}
\item \textsc {\bfseries{tracert:}}
It shows different information about the path taken by packets to reach the destination.
Each packets has TTL which decreases as it passes the Routers.
All tracert syntaxes ,parameters and its uses are listed below:
\SYN{tracert /?}
\CMD{tracerthelp.txt}{tracert Syntaxes and Uses}
\item \textsc {\bfseries {arp:}}
ARP{Address Resolution Protocol} is used to pair MAC address with Ip address and save for future uses.
This command has ability to display and modify the Cache of Address translation table if needed.
All arp syntaxes ,parameters and its uses are listed below:
\SYN{arp /?}
\CMD{arphelp.txt}{arp Syntaxes and Uses}
\item \textsc {\bfseries {hostname:}}
Hostname is the device name in the network so this command displays the hostname of the device.
it doesn't have any other parameter other than help.
\SYN{hostname /?}
\CMD{hostnamehelp.txt}{hostname Syntaxes and Uses}
\item \textsc {\bfseries {netstat:}}
It shows the statistics about the connected network and devices.
It informs about the current Working TCP/Ip Connection including ports and addresses.
It displays the open ports or ports listening (can establish connection).
All netstat syntaxes ,parameters and its uses are listed below:
\SYN{netstat /?}
\CMD{netstathelp.txt}{netstat Syntaxes and Uses}
\item \textsc {\bfseries{route:}}
It has ability to print the content in IP routing tables and modify it if needed.
All route syntaxes ,parameters and its uses are listed below:\\
\SYN{route /?}
\CMD{routehelp.txt}{route Syntaxes and Uses}
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%222222222222222222222
\begin{Q}
{Note down the observation of each steps with necessary commands specified in activities B
mentioned above and comment on it.}
\end{Q}
\begin{enumerate}
\item \textbf{Using ipconfig:}
\begin{enumerate}
\item \textbf{ipconfig:}
Displays Windows ip configuration including IPv6/v4 address ,Subnet mask ,default gateway etc.
\CMD{ipconfig.txt}{ipconfig}
\item \textbf{ipconfig/all:} Similar to $ipconfig$ but with additional information like Description, DHCP, Physical Address, Dns server etc.
\CMD{ipconfigall.txt}{ipconfig/all}
\end{enumerate}
\item \textbf{Using ping:}
\begin{enumerate}
\item \textbf{Obtain the IP address of your default gateway (refer qu. 1) and ping to that IP address.:}
My default gateway Ip address is 192.168.10.1 so command is $ ping 192.168.10.1$.
It display the round trip time to and from my default gateway (Router). It also displays
no of data sent and received along with loss.
\CMD{pinggateway.txt}{ping Default Gateway}
\item \textbf{ping “your ISP”:}
My ISP is Vianet so I should use $ ping$ $vianet.com.np $
\CMD{pingvianet.txt}{ping vianet.com.np}
\item \textbf{ping google.com:}
\CMD{pinggoogle.txt}{ping google.com}
\item \textbf{ping 103.5.150.3:}
\CMD {pingip.txt}{ ping 103.5.150.3}
\end{enumerate}
\item \textbf{Using getmac:}
\begin{enumerate}
\item \textbf{getmac:}
It displays MAC address (physical address) for all the available Network Adapters in the system .
It also display the mac address assigned for virtual adapter created by Virtual machine and VPN's in the system.
\CMD{getmac.txt}{getmac}
\end{enumerate}
\item \textbf{Using tracert:}
\begin{enumerate}
\item \textbf{Obtain the IP address of your default gateway (refer qu. 1) and use tracert to that IP
address.:} \\
My default gateway ip(Router) is 192.168.10.1 so below is the output of the tracert command on Router.
\CMD{tracert.txt}{tracert Deafault Gateway}
\item \textbf{tracert “your ISP”:}
\CMD{traceisp.txt}{tracert ISP}
\item \textbf{tracert google.com:}
\CMD{tracegoogle.txt}{tracert google.com}
\item \textbf{tracert 103.5.150.3:}
\CMD{traceip.txt}{tracert 103.5.150.3 }
\end{enumerate}
\item \textbf{Using arp:}
\begin{enumerate}
\item \textbf{arp -a:} Display ARP table
\CMD{arpa.txt}{arp -a}
\item \textbf{Use ping to any another device within your network such as another computer or laptop
or mobile phone or tablet etc. and again use arp –a (if there are multiple devices in your
network you can ping one by one by observing the output of arp -a after each ping)}\\
I am pinging my phone with Ip asssigned 192.168.10.102 and physical address d8:0b:9a:3a:37:f4.
I also pinged another device with 192.168.10.104 and MAC address ec:35:86:7e:4e:30.
In ARP table both the devices are visible with their corresponding MAC address
just after my default gateway 192.168.10.1 with type Dynanic\\
**** Only changes from arp -a are included in output
\CMD{arpaping.txt}{arp -a after pinging another device}
\end{enumerate}
\item \textbf{Using hostname:}
\begin{enumerate}
\item \textbf{hostname:} Displays my System Hostname.
\CMD{hostname.txt}{hostname}
\end{enumerate}
\item \textbf{Using netstat:}
\begin{enumerate}
\item \textbf{netstat -a:} Display all connection and listening Ports\\
**** some entries are deleted to meet the memory requirement for TEX.
\CMD{netstata.txt}{netstat -a}
\item \textbf{netstat -e:}
Display ethernet statistics like Size of packet received and send in Bytes,
errors uni and non- unicast packets etc.
\CMD{netstate.txt}{netstat -e}
\item \textbf{netstat -r:}
Display Interface list along with IPv6 and IPv4 Routing table.
\CMD{netstatr.txt}{netstat -r}
\end{enumerate}
\item \textbf{Using route:}
\begin{enumerate}
\item \textbf{route print:}
Dispaly interface list along with IPv4 and IPv6 Routing Table.
\CMD{routep.txt}{route print}
\item \textbf{route print -4:}
Display only IPv4 Routing Table
\CMD{routep4.txt}{route print -4}
\item \textbf{route print -6:}
Display only IPv6 Routing Table
\CMD{routep6.txt}{route print -6}
\end{enumerate}
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%
\pagebreak
%%%%%%%%%%%%%%%333333333333333333333333
\begin{Q}
{What is the actual IP address of your computer? Also find the Public IP address that is being
used for your computer’s Internet connectivity. Note down both the IP addresses.}
\end{Q}
\begin{A}
{
My actual ip of my computer is provided in ipconfig output i.e 192.168.10.106
\CMD{pcip.txt}{IP address of my PC}
There are different methods and sites to find Public IP used for internet connectivity .\\
I choose nslookup command and used \textit{nslookup myip.opendns.com resolver1.opendns.com}
to generate following output . So, my public ip is 43.245.87.194 and confirmed with external sites too.
\CMD{pubip.txt}{Public IP address}
}
\end{A}
%%%%%%%%%%%%%%%%%%%%%
\section{Conclusion}
In this LAB -2 we get familiar with different network commands and their uses in Linux and windows platform.
We learned 8 commands with majority of them having some additional argument.
We learned to ping the computer or device in and outside the network. We learned to extract IP and MAC addresses of connected adapters .
We also learned about ping , trace routing,ip configuration and many other tools useful for troubleshooting and connectivity.
We familiarized ourself with public and private ip and methods to find them.
\end{document} |
[STATEMENT]
lemma skip_res_as_ra:
"\<lbrakk> vwb_lens y; x +\<^sub>L y \<approx>\<^sub>L 1\<^sub>L; x \<bowtie> y \<rbrakk> \<Longrightarrow> II\<restriction>\<^sub>\<alpha>x = II\<^bsub>y\<^esub>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>vwb_lens y; x +\<^sub>L y \<approx>\<^sub>L \<Sigma>; x \<bowtie> y\<rbrakk> \<Longrightarrow> II \<restriction>\<^sub>\<alpha> x = II\<^bsub>y\<^esub>
[PROOF STEP]
apply (rel_auto)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
1. \<And>a b Z Za v va. \<lbrakk>vwb_lens y; x \<bowtie> y; vwb_lens Z; vwb_lens Za; \<forall>xa. (get\<^bsub>x\<^esub> xa, get\<^bsub>y\<^esub> xa) = get\<^bsub>Z\<^esub> xa; \<forall>xa a b. put\<^bsub>x\<^esub> (put\<^bsub>y\<^esub> xa b) a = put\<^bsub>Z\<^esub> xa (a, b); \<forall>x. x = get\<^bsub>Za\<^esub> (get\<^bsub>Z\<^esub> x); \<forall>x xa. xa = put\<^bsub>Z\<^esub> x (put\<^bsub>Za\<^esub> (get\<^bsub>Z\<^esub> x) xa); put\<^bsub>x\<^esub> b va = put\<^bsub>x\<^esub> a v\<rbrakk> \<Longrightarrow> get\<^bsub>y\<^esub> b = get\<^bsub>y\<^esub> a
2. \<And>a b Z Za. \<lbrakk>vwb_lens y; x \<bowtie> y; vwb_lens Z; vwb_lens Za; \<forall>xa. (get\<^bsub>x\<^esub> xa, get\<^bsub>y\<^esub> xa) = get\<^bsub>Z\<^esub> xa; \<forall>xa a b. put\<^bsub>x\<^esub> (put\<^bsub>y\<^esub> xa b) a = put\<^bsub>Z\<^esub> xa (a, b); \<forall>x. x = get\<^bsub>Za\<^esub> (get\<^bsub>Z\<^esub> x); \<forall>x xa. xa = put\<^bsub>Z\<^esub> x (put\<^bsub>Za\<^esub> (get\<^bsub>Z\<^esub> x) xa); get\<^bsub>y\<^esub> b = get\<^bsub>y\<^esub> a\<rbrakk> \<Longrightarrow> \<exists>v va. put\<^bsub>x\<^esub> b va = put\<^bsub>x\<^esub> a v
[PROOF STEP]
apply (metis (no_types, lifting) lens_indep_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<And>a b Z Za. \<lbrakk>vwb_lens y; x \<bowtie> y; vwb_lens Z; vwb_lens Za; \<forall>xa. (get\<^bsub>x\<^esub> xa, get\<^bsub>y\<^esub> xa) = get\<^bsub>Z\<^esub> xa; \<forall>xa a b. put\<^bsub>x\<^esub> (put\<^bsub>y\<^esub> xa b) a = put\<^bsub>Z\<^esub> xa (a, b); \<forall>x. x = get\<^bsub>Za\<^esub> (get\<^bsub>Z\<^esub> x); \<forall>x xa. xa = put\<^bsub>Z\<^esub> x (put\<^bsub>Za\<^esub> (get\<^bsub>Z\<^esub> x) xa); get\<^bsub>y\<^esub> b = get\<^bsub>y\<^esub> a\<rbrakk> \<Longrightarrow> \<exists>v va. put\<^bsub>x\<^esub> b va = put\<^bsub>x\<^esub> a v
[PROOF STEP]
apply (metis vwb_lens.put_eq)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done |
\setvariables[article][shortauthor={Dawson, Thompson}, date={July 2017}, issue={1}, DOI={doi:10.7916/D84T6WRF}]
\setupinteraction[title={Ramble Bahamas},author={Jessica Dawson, Tracey Thompson}, date={July 2017}, subtitle={Ramble Bahamas}]
\environment env_journal
\starttext
\startchapter[title={Ramble Bahamas}
, marking={Ramble Bahamas}
, bookmark={Ramble Bahamas}]
\startlines
{\bf
Jessica Dawson
Tracey Thompson
}
\stoplines
A Project by \quotation{From Dat Time}: The Oral and Public History Institute of the University of The Bahamas
\subsection[reference={sx-archipelagos-introduction},
bookmark={*sx archipelagos* Introduction},
title={{\em sx archipelagos} Introduction}]
\useURL[url1][http://ramblebahamas.org][][Ramble Bahamas]\from[url1] is the publication engine for \quotation{From Dat Time}: The Oral and Public History Institute at the University of The Bahamas. Developed~by project director~Tracey Thompson and research and technology fellow Jessica Dawson, the site aims not only to promote the work of academic and independent researchers but also to affirm the contributions of community elders and to provide easily accessible resources for primary- and secondary-school teachers and, ultimately, for~the wider Bahamian community. Hewing close to the concept of rambling and all it connotes of meandering, discovery, and unhurriedness, the site invites multiple paths for exploration---through individual stories, curated wanderings, and interactions with a map of the island. The platform's primary thematic focus covers four areas:~Bahamian participation in World War II; national politics in the postwar era; the evolution of the nursing profession; and the development of the sportfishing industry. The site combines scholarly research with audio clips of oral history, archival images and documents, and contemporary photographs. Through this collage of source materials and insistence on place as historical frame, {\em Ramble Bahamas} promises users a gently guided but largely self-determined encounter with fascinating elements of Bahamian national history.
\subsection[reference={creators-introduction},
bookmark={Creators' Introduction},
title={Creators' Introduction}]
The digital humanities offer a unique vehicle for bridging the past and present. Interactive media formats encourage user engagement while maintaining the integrity of historical methodologies. Digital platforms enable audiences located far and wide to access information that is not easily available in print format. All these advantages carry special value for students, educators, and scholars who are investigating twentieth-century Bahamian history. Such audiences are met with a grave shortage of resources, whether in physical format or web-based format, that illuminate the Bahamian experience. The challenge of accessing resources confronts, in particular, audiences located within the Bahamian archipelago yet outside the central island of New Providence as well audiences located abroad. {\em Ramble Bahamas} seeks to remedy this deficit by providing a curated collection of easily accessible place-based exhibits in an innovative medium. Each geo-tagged exhibit includes a cohesive narrative that centers on the story of an historically significant site or object. Additional context is built through the inclusion of historical images, newspapers, other documents, and contemporary photographs. Select audio clips taken from oral history interviews with authoritative narrators are also featured within each exhibit to deepen the sense of place, further stimulate the sensory experience of the visitor, and extend each visitor's knowledge about events associated with the location and about circumstances prevailing during the era. Techniques for constructing the product include carrying out oral history interviews, conducting documentary and archival research, and performing audio-visual digitization and editing, as well as deploying and customizing the Omeka content management system powered by Curatescape. At the time of its launch in January 2017, Ramble Bahamas contained ten exhibits on subjects such as sociopolitical history, the maritime industry, and the history of nursing in The Bahamas. Site statistics attest to the local and international impact of the website. Such statistical data can be used to direct the site's growth, goals, and other characteristics of its future development.
\thinrule
\subsection[reference={sx-archipelagos-review},
bookmark={*sx archipelagos* review},
title={{\em sx archipelagos} review}]
\startblockquote
\quotation{to combine the best of oral history, Caribbean cultural heritage, and walking.}
\stopblockquote
First,\footnote{Editors' note: Because several updates have been made to the {\em Ramble Bahamas} website, prompted in part by the reading of this review, some content covered here is no longer available on the site. See Jessica Dawson and Tracey Thompson's \quotation{Review Response from the Creators of {\em Ramble Bahamas}} below for a discussion of changes made, not made, and anticipated.} we want to congratulate the creators on making such promising headway with such an ambitious agenda: to combine the best of oral history, Caribbean cultural heritage, and walking. It is there, in the last instance, where the project seems to want to make its major contribution: to ramble through the history of The Bahamas. It is also there where perhaps this review can help the most. {\em Ramble}, a word that can mean both a walk taken for pleasure or confusing speech, is fitting to describe the dilemmas and room for improvement of the project as it stands.
We trust that the intention of the creators is to provide a relatively random encounter with \quotation{Bahamian participation in World War II, national politics in the postwar era, the evolution of the nursing profession, and the development of the sportfishing industry,}\footnote{\quotation{About} (under \quotation{FDT}), {\em Ramble Bahamas}, \useURL[url2][http://web.archive.org/web/20170904035235/http://www.ramblebahamas.org/about][][www.ramblebahamas.org/about]\from[url2].} yet visitors are guided by the voices of the researchers, their interlocutors in the recordings, the images, and the site's navigation scheme (including its maps). In a very real sense, the current navigation scheme and web design can create a sense of disorientation, which falls outside the pleasures of rambling. What we hope to do in this review is suggest a series of minor tweaks that in the aggregate may allow the project to be both rambling and guided without necessarily being disorienting.
Let us clarify what we mean by \quotation{disorienting.} When we arrive at the site, the first thing that catches our attention is the small paragraph that invites us to explore. We have several options at this point: we can scroll down and click on the \quotation{Read more {\em About Us}} button or dive straight into the map on the right. The map is too appealing to ignore, so we click on it. It expands to replace the welcome message. We click again on the yellow circle over The Bahamas. A pin and a green circle appear as the viewport zooms in closer to the ground. We click again on the green circle. After a similar effect, we can now see the streets of Nassau. We finally click on a pin: we get an image and \quotation{The Contract.} Hovering the mouse over it, out of curiosity, we notice there is a link, so we click on that too and arrive at an article page. After reading a few sentences of the article, we realize we are already deep in history. How did we get here? Where are we? Scared we did something wrong, we return to the homepage.
Once we begin to get a sense of how the site works, everything starts making sense, but it takes a while to get there, and even then it takes a bit more time to see the site's conceptual coherence. Perhaps the few minor changes suggested below could help.
\subsubsection[the-homepage]{The Homepage}
Much can be solved by doing most of the revision work on the homepage. Any good ramble needs a good preamble. Instead of the existing welcome message, which is too open an invitation, the user would be well served by some brief instructions to navigating the rest of the homepage, reconstructed for clarity. While the map is fun, it is currently positioned in too tempting a place to avoid disorientation. We recommend placing it at the bottom, with the preamble above helping site visitors understand what it is doing and perhaps even allowing the map to be the unguided place.
With a strong enough narrative preamble, there could be three sections below it: Trails, Recent Stories, and Maps.
Trails: \quotation{Ramble on} as an imperative is very catchy, but it needs clarification. {\em Ramble} is being used in too many senses here for it to imply simply \quotation{visit this trail.} We can think of two solutions to this problem: substitute {\em Trails} throughout with {\em Rambles} or simply add a \quotation{Visit This Trail} link at the button. We prefer the former, since it already starts giving a more precise meaning to capital-letter {\em Ramble} without interfering in the general sense of rambling, which the site authors want to hold on to, while also opening the door for them to provide some critical reflections on the act of rambling, through voices and streets, performed as a transmedia digital project---something we would ask for as reviewers, but more of that in our review of the \quotation{About} page.
Recent Stories: If the preamble above briefly explains what a story is, this can be left as is.
Maps: There is much to say about the three kinds of maps----the general one here; the one with individual pins, at the tops of the articles; and the one for Trails. The general one can stay as is, if placed at the bottom and preambled by a warning that the user must find landmarks without guidance in order to arrive at a more in-depth look at a given landmark.
\subsubsection[the-about-page]{The \quotation{About} Page}
There is a great, but missed, opportunity here, since this page is expected to be straightforward prose. The site already does a fantastic job of packing much information into a few paragraphs. Our two suggestions for revisions are simple.
First, add a section reflecting on the design/structure of the site as founded in the idea of rambling and on the importance of rambling/walking in the Caribbean. We are thinking, for example, of Garnette Cadogan's \quotation{Walking while Black} (\useURL[url3][http://web.archive.org/web/20170904035212/http://lithub.com/walking-while-black/][][{\em lithub.com/walking-while-black}]\from[url3]), which the site authors would do well to consult. There are also other historians who have tried to reflect critically on walking and history. This would help mitigate the notion that the site is simply \quotation{where {[}the{]} research team publishes historical and cultural knowledge that {[}it{]} assemble{[}s{]} about Bahamians and about The Bahamas.}\footnote{\quotation{About,} {\em Ramble Bahamas} (as accessed March 2017).} To \quotation{publish} in such a formalized structure as a website/exhibit---different from a journal or a book---needs justification, especially when the form informs the ambitions of the project to this extent.
Second, break down the credits at the bottom into a list in which everyone's contributions and roles are noted, rather than simply their titles within the academic hierarchy.
\subsubsection[browse-items]{Browse Items}
This page is almost perfect. One small confusion between {\em items} and {\em stories} can be clarified. As far as we can see, an item is a story. However, this is very different from the conception of {\em item} native to Omeka and familiar to Omeka users.\footnote{Omeka is the open-source web publishing platform used by {\em Ramble Bahamas}; see \useURL[url4][http://web.archive.org/web/20170904035248/http://omeka.org/about/][][omeka.org/about]\from[url4].} We would simply rebrand the headings to \quotation{Browse Stories} or \quotation{Stories.} This would go a long way to making this page clearer. To seal the deal, we would have a brief blurb above or below the map explaining what a {\em story} is.
{\em Tags:} Site authors should make the tags consistent and use them throughout (perhaps around the historical themes).
\subsubsection[trails]{Trails}
As we suggested above, this is the place to do a lot of conceptual work around {\em Rambling}. The Trails, and this is crucial, are simply subcollections, in the Omeka sense of the word---selections from all the stories. In the future, site authors might encounter problems with Omeka's nonoverlapping collections, but maybe not. Currently, {\em Ramble Bahamas} makes very smart use of the collections feature. The site authors should be explicit, though, about the fact that these Rambles are coming from the general collection. More important, they should note that this is a specific, guided form of experiencing the project.
{\em The map:} As it stands, the map seems incomplete at some zoom levels (one of the pins overlaps on the other, depending on zoom), and it does not present itself as a Trail immediately. One simple tweak to show numbers instead of pins might help here. Although the numbers are visible on clicking, that is not immediately helpful. It would also help to clarify whether the numbers represent suggested paths on a walking tour or simply serve as indexes to the ordering below.
{\em The blurb:} \quotation{Making use of multimedia tools so as to interest audiences of all ages} is not enough. Those tools must be used in specific ways for different audiences. This is where prose helps enormously. The introduction to this section, and to all future Rambles/Trails, could help synthesize the selections and provide the necessary preamble for audiences of all ages to enjoy the individual stories more fruitfully.
\subsubsection[individual-stories]{Individual Stories}
These are great, and they provide the substance for the site. A few small tweaks to the design can go a long way in making these pages even richer than they already are:
\startitemize[a,packed][stopper=)]
\item
On the map pin, make the zoom be at the street level;
\item
separate image from audio visually (different background color, dividing line, etc.), and place audio above images, since audio is richer; and
\item
use a more legible font for the audio caption to make sure the user understands what they are about to listen to.
\stopitemize
In general, it is always best to err on the side of more narrative framework for multimedia content. We understand the delicate balance between letting documents speak for themselves and taking on the role of curator and guide, but we think a bit more framing can vastly improve the user experience here without detracting from the primary sources.
\subsection[reference={review-response-from-the-creators-of-ramble-bahamas},
bookmark={Review Response from the Creators of *Ramble Bahamas*},
title={Review Response from the Creators of {\em Ramble Bahamas}}]
We would like to thank the reviewers for the constructive and insightful feedback that they have provided in their comprehensive review of \useURL[url5][http://www.ramblebahamas.org/][][{\em Ramble Bahamas}]\from[url5].\footnote{See \quotation{A Review of {\em Ramble Bahamas},} this issue of {\em sx archipelagos}. See also \useURL[url6][http://www.ramblebahamas.org][][www.ramblebahamas.org]\from[url6].} We are thrilled that the reviewers see potential in our ambitious undertaking to provide a platform combining oral history, active learning, and an exploration of Bahamian cultural heritage. We found the reviewers' detailed narration of their first encounter with the home page to be a perceptive critique that will help guide us to build a more user-friendly experience with {\em Ramble Bahamas}.
The reviewers provided a series of recommendations to enhance the ease of site navigation and relieve any disorientation that may be felt by a new user. The most substantial revisions concern the addition of explanatory prose and the utilization of consistent labels. We appreciate and have heeded the recommendation to revise the home page welcome message to include explanatory instructions for site navigation. In this space, we now provide definitions for our terms {\em stories} and {\em rambles}. We have also added explanatory prose to \quotation{The Majority Rule Heritage Trail} preamble to address how specific audiences, such as students and tourists, can engage with each of the stories as well as to provide a recommendation on how to interact with the walking trail. The suggestion to rebrand \quotation{Trails} as \quotation{Rambles} to both simplify navigation and nominalize the act of rambling was an excellent one. For the sake of clarity and ease, the reviewers keenly suggested the rebranding of \quotation{Browse Items} to \quotation{Stories.} We have made these recommended edits to the navigation bar.
The review offered a number of prudent suggestions related to the embedded maps. The placement of the map on the home page is a subject we have debated internally. The reviewers noted the placement as \quotation{too tempting a place to avoid disorientation.} While our site targets a broad audience, our primary users are Bahamian secondary school students. The placement of the map has resonated in a positive way with this younger audience, and for this reason we have chosen to leave it parallel to the welcome message. We hope that the balance between detailed welcoming instructions and an interactive map will prove to be user-friendly for all audiences. For individual stories, the suggestion to automatically default the map zoom to street level was a sensible one and has been implemented sitewide. For Trails (now Rambles), the reviewers offered some ideas to provide a more visually complete trail, including the utilization of numbered marker icons rather than the current marker icons. While we considered this suggestion, it is not an option available with the current geolocation plug-in utilized by the site. As the reviewers noted, the numbers are available when clicking on each marker icon. To make this clear, we have included notes in \quotation{The Majority Rule Heritage Trail} text explaining how the numbers can be activated. The reviewers also noted the overlap of two marker icons visible at more distant zoom levels. The proximity of these two icons is unfortunate and unavoidable, since two stories took place at the same locale. In future Rambles, we will be mindful of marker icon placement when selecting and mapping our locations to avoid this kind of overlap.
The review notes a missed opportunity on our \quotation{About} page and offers several suggestions to better explain the process behind the work we undertake as public historians and the importance of \quotation{rambling} to the site creators. Moreover, the reviewers suggested how this space could be utilized as an opportunity to reflect on how {\em rambling}, in Bahamian parlance, means both to speak at length on a topic and to wander in an unhurried and enjoyable fashion. Interestingly, when we present {\em Ramble Bahamas} to outside stakeholders and audiences, we are commonly asked questions regarding the meaning of the word {\em ramble} and why the site's name was chosen. Therefore, the reviewers had underscored a real and pressing opportunity to better explain a concept possibly foreign to non-Bahamians as well as to remind younger Bahamians of a pastime cherished by their elders. Per recommendation, we have taken Garnette Cadogan's powerful \quotation{\useURL[url7][http://web.archive.org/web/20170904035212/http://lithub.com/walking-while-black/][][Walking while Black]\from[url7]} essay to heart.\footnote{Garnette Cadogan, \quotation{Walking while Black,} 8 July 2016, \useURL[url8][http://web.archive.org/web/20170904035212/http://lithub.com/walking-while-black/][][lithub.com/walking-while-black]\from[url8].} This work and the reviewers' recommendation have inspired us to expand our \quotation{About} page to include a reflection on the meaning of \quotation{rambling} which illustrates why this is an appropriate term to employ throughout the site as it conveys the kind of intellectual experience the site has to offer.
Also concerning the \quotation{About} page, the reviewers encouraged us to break down the site credits by expanding on our team members' individual contributions and roles rather than focusing solely on their academic hierarchy. We appreciate this opportunity to elaborate on and recognize individual contributions. When finished, these personal details, along with the reflection on \quotation{rambling,} will provide an introspective look into the modus operandi that guides the work of our team. Over the coming months we will further flesh out the personal details and this reflection.
The recommendation to consistently use tags based on our research themes (national politics, nursing, education, sportfishing, and World War II and the postwar era) is welcomed and solves a problem relating to the overuse of this feature, which we have debated for some time. To effectively and consistently utilize the tags feature, we have decided to implement only tags related to our formal research foci. Commenting on the multimedia captions, the reviewers astutely pointed out the fine balance between \quotation{letting documents speak for themselves and taking on the role of {[}a{]} curator.} The recommendation to provide more framing to improve the user experience will be effective for upcoming stories. Finally, the reviewers suggested several changes to improve the design of the individual story pages. These edits (placement of the oral history audio clips, visual separation of the audio and image sections, and a more legible audio caption font) are sensible and will be integrated in future site updates.
\thinrule
\page
\subsection{Jessica Dawson}
Jessica Dawson has served most recently as Public History Fellow in Research & Technology for \quotation{From Dat Time}: The Oral & Public History Institute of the University of The Bahamas. In this role she acted as webmaster and curator for {\em Ramble Bahamas}. Prior to this, she has taught in the field of cultural anthropology and worked in historic preservation in Ohio state. She holds a B.A. in Anthropology from Washington State University and an M.A.~in American Studies & Public History from Youngstown State University.
\subsection{Tracey Thompson}
Tracey Thompson is the director of \quotation{From Dat Time}: The Oral and Public History Institute of the University of The Bahamas. She oversees the research program and administrative processes of the institute and has been involved in research, teaching, and administration at the University of The Bahamas for more than twenty-five years. Her research focuses principally on African and African diaspora history, the philosophy of history, oral history, and public history.
\stopchapter
\stoptext |
(** * Kan Extensions *)
Require Import Category.Core Functor.Core.
Require Import FunctorCategory.Core.
Require Import Functor.Composition.Functorial.Core.
Require Import UniversalProperties.
Set Universe Polymorphism.
Set Implicit Arguments.
Generalizable All Variables.
Set Asymmetric Patterns.
Local Open Scope category_scope.
(** Quoting nCatLab on Kan Exensions:
** Idea
The Kan extension of a functor [F : C → D] with respect to a
functor
<<
C
|
| p
↓
C'
>>
is, if it exists, a kind of best approximation to the problem of
finding a functor [C' → D] such that
<<
F
C -----> D
| ↗
| p /
| /
↓ /
C'
>>
hence to extending the domain of [F] through [p] from [C] to [C'].
More generally, this makes sense not only in Cat but in any
2-category.
Similarly, a Kan lift is the best approximation to lifting a
morphism [F : C → D] through a morphism
<<
D'
|
↓
D
>>
to a morphism [F̂]
<<
D'
↗ |
/ |
F̂ / |
/ |
/ F ↓
C --------> D
>>
Kan extensions are ubiquitous. See the discussion at Examples
below.
** Definitions
There are various slight variants of the definition of Kan
extension. In good cases they all exist and all coincide, but in
some cases only some of these will actually exist.
We (have to) distinguish the following cases:
- “ordinary” or “weak” Kan extensions
These define the extension of an entire functor, by an
adjointness relation.
Here we (have to) distinguish further between
- global Kan extensions,
which define extensions of all possible functors of given
domain and codomain (if all of them indeed exist);
- local Kan extensions,
which define extensions of single functors only, which may
exist even if not every functor has an extension.
- “pointwise” or “strong” Kan extensions
These define the value of an extended functor on each object
(each “point”) by a weighted (co)limit.
Furthermore, a pointwise Kan extension can be “absolute”.
If the pointwise version exists, then it coincides with the
“ordinary” or “weak” version, but the former may exist without the
pointwise version existing. See below for more.
Some authors (such as Kelly) assert that only pointwise Kan
extensions deserve the name “Kan extension,” and use the term as
“weak Kan extension” for a functor equipped with a universal
natural transformation. It is certainly true that most Kan
extensions which arise in practice are pointwise. This distinction
is even more important in enriched category theory. *)
Section kan_extensions.
(** ** Ordinary or weak Kan extensions
*** Global Kan extensions
Let [p : C → C'] be a functor. For [D] any other category, write
[p* : (C' → D) → (C → D)] for the induced functor on the functor
categories: this sends a functor [h : C' → D] to the composite functor
<<
p h
p* h : C --> C' --> D
>>
*)
(** *** Pullback-along functor *)
Context `{Funext}.
Variables C C' D : PreCategory.
Section pullback_along.
Definition pullback_along_functor
: object ((C -> C') -> (C' -> D) -> (C -> D))
:= Functor.Composition.Functorial.Core.compose_functor _ _ _.
Definition pullback_along (p : Functor C C')
: object ((C' -> D) -> (C -> D))
:= Eval hnf in pullback_along_functor p.
End pullback_along.
(** Definition. If [p*] has a left adjoint, typically denoted [p_! :
(C → D) → (C' → D)] or [Lan_p : (C → D) → (C' → D)] then this
left adjoint is called the (ordinary or weak) left Kan extension
operation along [p]. For [h ∈ (C -> D)] we call [p_! h] the left
Kan extension of [h] along [p].
Similarly, if [p*] has a right adjoint, this right adjoint is
called the right Kan extension operation along [p]. It is
typically denoted [p_* : (C → D) → (C' → D)] or [Ran = Ran_p :
(C → D) → (C' → D)].
The analogous definition clearly makes sense as stated in other
contexts, such as in enriched category theory.
Observation. If [C' = 1] is the terminal category, then
- the left Kan extension operation forms the colimit of a functor;
- the right Kan extension operation forms the limit of a functor. *)
(** *** Left Kan extensions *)
(** Colimits are initial morphisms. *)
Definition IsLeftKanExtensionAlong (p : Functor C C') (h : Functor C D)
:= @IsInitialMorphism (_ -> _) _ h (pullback_along p).
(** *** Right Kan extensions *)
(** Limits are terminal morphisms *)
Definition IsRightKanExtensionAlong (p : Functor C C') (h : Functor C D)
:= @IsTerminalMorphism _ (_ -> _) (pullback_along p) h.
End kan_extensions.
|
function [X_norm, mu, sigma] = featureNormalize(X)
%FEATURENORMALIZE Normalizes the features in X
% FEATURENORMALIZE(X) returns a normalized version of X where
% the mean value of each feature is 0 and the standard deviation
% is 1. This is often a good preprocessing step to do when
% working with learning algorithms.
% You need to set these values correctly
X_norm = X;
mu = zeros(1, size(X, 2));
sigma = zeros(1, size(X, 2));
% ====================== YOUR CODE HERE ======================
% Instructions: First, for each feature dimension, compute the mean
% of the feature and subtract it from the dataset,
% storing the mean value in mu. Next, compute the
% standard deviation of each feature and divide
% each feature by it's standard deviation, storing
% the standard deviation in sigma.
%
% Note that X is a matrix where each column is a
% feature and each row is an example. You need
% to perform the normalization separately for
% each feature.
%
% Hint: You might find the 'mean' and 'std' functions useful.
%
for i = 1:size(X, 2)
mu(:,i) = mean(X_norm(:,i));
sigma(:,i) = std(X_norm(:,i));
X_norm(:,i) = (X_norm(:,i) - mu(:,i)) / sigma(:,i);
end
% ============================================================
end
|
Formal statement is: lemma infdist_triangle: "infdist x A \<le> infdist y A + dist x y" Informal statement is: The infimum distance from a point $x$ to a set $A$ is less than or equal to the sum of the infimum distance from $y$ to $A$ and the distance from $x$ to $y$. |
Require Import Coq.Logic.Classical_Prop.
Require Import CompCert.Events.
Require Import CompCert.Smallstep.
Require Import CompCert.Behaviors.
Require Import Common.Definitions.
Require Import Common.Util.
Require Import Common.Linking.
Require Import Common.Memory.
Require Import Common.Reachability.
Require Import Common.RenamingOption.
Require Import Common.Values.
(** From Renaming, only addr_shared_so_far and some tactics (like find_nil_rcons,
and find_rcons_rcons) are used. Consider refactoring them out
(into a file called Sharing.v, and into Common.Util)
to get rid of the dependency on Renaming.
Keep CSInvariants for only unary invariants; hence, do not depend on "renaming".
*)
Require Import Common.Traces.
Require Import Common.TracesInform.
Require Import Common.CompCertExtensions.
Require Import Source.Language.
Require Import Source.GlobalEnv.
Require Import Source.CS.
Require Import Lib.Extra.
Require Import Lib.Monads.
From mathcomp Require Import ssreflect eqtype ssrfun seq.
From mathcomp Require ssrbool ssrnat.
From extructures Require Import fmap fset.
Require Import Lia.
Set Bullet Behavior "Strict Subproofs".
Section Util.
Lemma starR_rcons:
forall (sem: semantics event) s1 s2 t1 e1,
single_events sem ->
starR (step sem) (globalenv sem) s1 (rcons t1 e1) s2 ->
exists st1 se1,
starR (step sem) (globalenv sem) s1 t1 st1 /\
Step sem st1 [:: e1] se1 /\
starR (step sem) (globalenv sem) se1 E0 s2.
intros ? ? ? ? ? Hsingle Hstar.
remember (rcons t1 e1) as t1_.
revert e1 t1 Heqt1_.
induction Hstar; intros; subst; unfold E0 in *; first by find_nil_rcons.
induction t1 using last_ind.
- unfold Eapp in *. rewrite app_nil_l in Heqt1_; subst.
pose proof (Hsingle _ _ _ H) as Hlength.
destruct t0; auto; simpl in *; auto.
+ exists s2, s3; intuition. constructor.
+ (** TODO: Use a "length_size" lemma. Get a contra in Hlength. *)
assert (forall (A: Type) l, size l = @length A l) as size_length.
{
induction l; auto.
}
rewrite <- size_length, size_rcons in Hlength. lia.
- specialize (IHHstar x t1 Logic.eq_refl) as [st1 [se1 [Ht2 [He1 Hnil]]]].
pose proof (Hsingle _ _ _ H) as Hlength.
destruct t2; auto; simpl in *.
+ unfold Eapp in *. rewrite app_nil_r in Heqt1_. find_rcons_rcons.
do 2 eexists; intuition; eauto.
eapply starR_step; eauto.
+ destruct t2; simpl in *; auto.
* unfold Eapp in *.
assert (e1 = e /\ t0 = rcons t1 x) as [rewr1 rewr2]; subst.
{
rewrite <- cats1, <- catA, cats1, <- rcons_cat in Heqt1_.
find_rcons_rcons.
by rewrite cats1.
}
exists s2, s3; intuition. constructor.
* lia.
Qed.
End Util.
Module CSInvariants.
(** Unary invariants about the source semantics *)
Import Source.
Definition is_prefix (s: CS.state) (p: Source.program) t : Prop :=
Star (CS.sem p) (CS.initial_machine_state p) t s.
Inductive wf_ptr_wrt_cid_t (cid: Component.id) (t: trace event) : Pointer.t -> Prop
:=
| wf_ptr_own:
forall p b o,
wf_ptr_wrt_cid_t cid t (p, cid, b, o)
| wf_ptr_shared:
forall p c_other b o,
addr_shared_so_far (c_other, b) t -> wf_ptr_wrt_cid_t cid t (p, c_other, b, o)
.
Inductive wf_load (pc_comp: Component.id) (t: trace event)
: Pointer.t -> Pointer.t -> Prop
:=
| private_stuff_from_corresp_private_addr:
forall load_at ptr,
~ addr_shared_so_far (Pointer.component ptr, Pointer.block ptr) t ->
~ addr_shared_so_far (Pointer.component load_at, Pointer.block load_at) t ->
Pointer.component ptr = Pointer.component load_at ->
wf_load pc_comp t load_at ptr
| shared_stuff_from_anywhere:
forall load_at ptr,
addr_shared_so_far (Pointer.component ptr, Pointer.block ptr) t ->
wf_load pc_comp t load_at ptr
| private_stuff_of_current_pc_from_shared_addr:
forall load_at ptr,
~ addr_shared_so_far (Pointer.component ptr, Pointer.block ptr) t ->
Pointer.component ptr = pc_comp ->
addr_shared_so_far (Pointer.component load_at, Pointer.block load_at) t ->
wf_load pc_comp t load_at ptr.
Definition wf_mem_wrt_t_pc (mem: Memory.t) (t: trace event)
(pc_comp: Component.id) : Prop :=
forall load_at ptr,
Memory.load mem load_at = Some (Ptr ptr) ->
Pointer.permission ptr = Permission.data ->
wf_load pc_comp t load_at ptr.
Fixpoint runtime_expr_struct_invariant
(e: expr) (val_test: value -> Prop) : Prop :=
match e with
| E_val v => val_test v
| E_binop _ e1 e2 =>
runtime_expr_struct_invariant e1 val_test /\
runtime_expr_struct_invariant e2 val_test
| E_seq e1 e2 =>
runtime_expr_struct_invariant e1 val_test /\
runtime_expr_struct_invariant e2 val_test
| E_if e1 e2 e3 =>
runtime_expr_struct_invariant e1 val_test /\
runtime_expr_struct_invariant e2 val_test /\
runtime_expr_struct_invariant e3 val_test
| E_alloc e =>
runtime_expr_struct_invariant e val_test
| E_deref e =>
runtime_expr_struct_invariant e val_test
| E_assign e1 e2 =>
runtime_expr_struct_invariant e1 val_test /\
runtime_expr_struct_invariant e2 val_test
| E_call _ _ e =>
runtime_expr_struct_invariant e val_test
| E_callptr e1 e2 =>
runtime_expr_struct_invariant e1 val_test /\
runtime_expr_struct_invariant e2 val_test
| E_funptr _
| E_arg
| E_local
| E_exit => true
end.
Fixpoint cont_struct_invariant (k: cont) (val_test: value -> Prop) : Prop :=
match k with
| Kbinop1 _ e k2 =>
runtime_expr_struct_invariant e val_test /\
cont_struct_invariant k2 val_test
| Kbinop2 _ v k2 =>
val_test v /\
cont_struct_invariant k2 val_test
| Kseq e k2 =>
runtime_expr_struct_invariant e val_test /\
cont_struct_invariant k2 val_test
| Kif e1 e2 k3 =>
runtime_expr_struct_invariant e1 val_test /\
runtime_expr_struct_invariant e2 val_test /\
cont_struct_invariant k3 val_test
| Kalloc k2 =>
cont_struct_invariant k2 val_test
| Kderef k2 =>
cont_struct_invariant k2 val_test
| Kassign1 e k2 =>
runtime_expr_struct_invariant e val_test /\
cont_struct_invariant k2 val_test
| Kassign2 v k2 =>
val_test v /\
cont_struct_invariant k2 val_test
| Kcall _ _ k2 =>
cont_struct_invariant k2 val_test
| Kcallptr1 e k2 =>
runtime_expr_struct_invariant e val_test /\
cont_struct_invariant k2 val_test
| Kcallptr2 v k2 =>
val_test v /\
cont_struct_invariant k2 val_test
| Kstop => true
end.
Definition stack_struct_invariant (s: CS.stack) (frame_test: CS.frame -> Prop) : Prop :=
List.Forall (fun frm => frame_test frm) s.
Definition wf_expr_wrt_t_pc (e: expr) (t: trace event)
(pc_comp: Component.id): Prop :=
runtime_expr_struct_invariant
e
(fun v => forall ptr,
v = Ptr ptr ->
Pointer.permission ptr = Permission.data ->
wf_ptr_wrt_cid_t pc_comp t ptr).
Definition wf_cont_wrt_t_pc (k: cont) (t: trace event)
(pc_comp: Component.id): Prop :=
cont_struct_invariant
k
(fun v => forall ptr,
v = Ptr ptr ->
Pointer.permission ptr = Permission.data ->
wf_ptr_wrt_cid_t pc_comp t ptr).
Definition wf_frame_wrt_t t (frm: CS.frame) :=
let val_test :=
fun v =>
forall ptr,
v = Ptr ptr ->
Pointer.permission ptr = Permission.data ->
wf_ptr_wrt_cid_t (CS.f_component frm) t ptr
in
val_test (CS.f_arg frm)
/\
cont_struct_invariant (CS.f_cont frm) val_test.
Definition wf_stack_wrt_t_pc (stk: CS.stack) (t: trace event) : Prop :=
stack_struct_invariant stk (wf_frame_wrt_t t).
Definition wf_state_t (s: CS.state) (t: trace event) : Prop :=
wf_expr_wrt_t_pc (CS.s_expr s) t (CS.s_component s) /\
wf_mem_wrt_t_pc (CS.s_memory s) t (CS.s_component s) /\
wf_cont_wrt_t_pc (CS.s_cont s) t (CS.s_component s) /\
wf_stack_wrt_t_pc (CS.s_stack s) t /\
(forall ptr,
CS.s_arg s = Ptr ptr ->
Pointer.permission ptr = Permission.data ->
wf_ptr_wrt_cid_t (CS.s_component s) t ptr).
Lemma initial_wf_mem p:
well_formed_program p ->
wf_mem_wrt_t_pc (prepare_buffers p) E0 Component.main.
Proof.
intros Hwf. constructor.
- unfold E0. intros contra; inversion contra; by find_nil_rcons.
- unfold E0. intros contra; inversion contra; by find_nil_rcons.
- unfold prepare_buffers in *. unfold Memory.load in *.
find_if_inside_hyp H; [|discriminate].
rewrite mapmE in H.
destruct (prog_buffers p (Pointer.component load_at)) as [buf|] eqn:ebuf;
[|discriminate]; simpl in H.
rewrite ComponentMemory.load_prealloc in H.
find_if_inside_hyp H; [|discriminate].
rewrite setmE in H.
find_if_inside_hyp H; [|discriminate].
destruct buf as [sz|chunk] eqn:ebuf2.
+ find_if_inside_hyp H; discriminate.
+ inversion Hwf.
assert (exists x, prog_interface p (Pointer.component load_at) = Some x)
as [? Hintf'].
{
apply/dommP. rewrite wfprog_defined_buffers0. apply/dommP. by eauto.
}
assert (Hintf: prog_interface p (Pointer.component load_at)). by rewrite Hintf'.
specialize (wfprog_well_formed_buffers0 _ Hintf) as [Hbuf1 Hbuf2].
rewrite ebuf in Hbuf2. simpl in *.
move : Hbuf2 => /andP => [[? G]]. move : G => /allP => G.
apply nth_error_In, In_in in H. by apply G in H.
Qed.
Lemma values_are_integers_expr_wrt_t_pc cur_comp expr:
values_are_integers expr ->
forall t,
wf_expr_wrt_t_pc expr t cur_comp.
Proof.
induction expr; auto; intros Hvalues t; inversion Hvalues; simpl in *; auto.
- destruct v; discriminate.
- move : Hvalues => /andP => [[G1 G2]].
constructor.
+ apply IHexpr1; by auto.
+ apply IHexpr2; by auto.
- move : Hvalues => /andP => [[G1 G2]].
constructor.
+ apply IHexpr1; by auto.
+ apply IHexpr2; by auto.
- move : Hvalues => /andP => [[G1 G2]].
move : G2 => /andP => [[G21 G22]].
constructor.
+ apply IHexpr1; by auto.
+ split; [apply IHexpr2|apply IHexpr3]; by auto.
- move : Hvalues => /andP => [[G1 G2]].
constructor.
+ apply IHexpr1; by auto.
+ apply IHexpr2; by auto.
- move : Hvalues => /andP => [[G1 G2]].
constructor.
+ apply IHexpr1; by auto.
+ apply IHexpr2; by auto.
Qed.
(**Lemma wf_ptr_wrt_cid_t_rcons ptr t1 e,
Pointer.permission ptr = Permission.data -> wf_ptr_wrt_cid_t C t1 ptr
wf_ptr_wrt_cid_t C' (t1 ** [:: ECall C P v mem C']) ptr
*)
Lemma runtime_expr_struct_invariant_rcons re C t1 e:
runtime_expr_struct_invariant
re
(fun v : value =>
forall ptr : Pointer.t,
v = Ptr ptr ->
Pointer.permission ptr = Permission.data -> wf_ptr_wrt_cid_t C t1 ptr) ->
runtime_expr_struct_invariant
re
(fun v0 : value =>
forall ptr : Pointer.t,
v0 = Ptr ptr ->
Pointer.permission ptr = Permission.data ->
wf_ptr_wrt_cid_t C (t1 ** [:: e]) ptr).
Proof.
intros; induction re; simpl in *; auto; intuition.
(* 1 goal remains *)
setoid_rewrite cats1.
destruct ptr as [[[pptr cptr] bptr] optr]. simpl in *; subst.
destruct (classic (addr_shared_so_far
(cptr, bptr)
(rcons t1 e)
)) as [ptrshr | ptrnotshr].
** eapply wf_ptr_shared; by auto.
** specialize (H _ Logic.eq_refl Logic.eq_refl).
inversion H; [by constructor|subst].
exfalso.
eapply ptrnotshr, reachable_from_previously_shared; [eassumption|].
constructor. by rewrite in_fset1.
Qed.
Lemma cont_struct_invariant_rcons k C t1 e:
cont_struct_invariant
k
(fun v : value =>
forall ptr : Pointer.t,
v = Ptr ptr -> Pointer.permission ptr = Permission.data ->
wf_ptr_wrt_cid_t C t1 ptr) ->
cont_struct_invariant
k
(fun v0 : value =>
forall ptr : Pointer.t,
v0 = Ptr ptr ->
Pointer.permission ptr = Permission.data ->
wf_ptr_wrt_cid_t C (t1 ** [:: e]) ptr).
Proof.
intros; induction k; simpl in *; auto; intuition;
try by apply runtime_expr_struct_invariant_rcons.
(** Refactor the "-" subgoal as a lemma on values *)
- setoid_rewrite cats1.
destruct ptr as [[[pptr cptr] bptr] optr]. simpl in *; subst.
destruct (classic (addr_shared_so_far
(cptr, bptr)
(rcons t1 e)
)) as [ptrshr | ptrnotshr].
** eapply wf_ptr_shared; by auto.
** specialize (H0 _ Logic.eq_refl Logic.eq_refl).
inversion H0; [by constructor|subst].
exfalso.
eapply ptrnotshr, reachable_from_previously_shared; [eassumption|].
constructor. by rewrite in_fset1.
- setoid_rewrite cats1.
destruct ptr as [[[pptr cptr] bptr] optr]. simpl in *; subst.
destruct (classic (addr_shared_so_far
(cptr, bptr)
(rcons t1 e)
)) as [ptrshr | ptrnotshr].
** eapply wf_ptr_shared; by auto.
** specialize (H0 _ Logic.eq_refl Logic.eq_refl).
inversion H0; [by constructor|subst].
exfalso.
eapply ptrnotshr, reachable_from_previously_shared; [eassumption|].
constructor. by rewrite in_fset1.
- setoid_rewrite cats1.
destruct ptr as [[[pptr cptr] bptr] optr]. simpl in *; subst.
destruct (classic (addr_shared_so_far
(cptr, bptr)
(rcons t1 e)
)) as [ptrshr | ptrnotshr].
** eapply wf_ptr_shared; by auto.
** specialize (H0 _ Logic.eq_refl Logic.eq_refl).
inversion H0; [by constructor|subst].
exfalso.
eapply ptrnotshr, reachable_from_previously_shared; [eassumption|].
constructor. by rewrite in_fset1.
Qed.
Lemma is_prefix_wf_state_t s p t:
closed_program p ->
well_formed_program p ->
is_prefix s p t ->
wf_state_t s t.
Proof.
unfold is_prefix. simpl.
intros Hclosed Hwf Hstar.
remember (prepare_global_env p) as G eqn:HG.
remember (CS.initial_machine_state p) as s0 eqn:Hs0.
revert HG Hs0.
apply star_iff_starR in Hstar.
induction Hstar as [| s0 t1 s1 t2 s2 t12 Hstar01 IHstar Hstep12 Ht12];
intros; subst.
- unfold CS.initial_machine_state.
inversion Hclosed. destruct (prog_main p) eqn:emain; [|discriminate].
constructor; simpl.
+ apply values_are_integers_expr_wrt_t_pc. inversion Hwf.
specialize (wfprog_well_formed_procedures0 _ _ _ emain).
inversion wfprog_well_formed_procedures0. by intuition.
+ split; [apply initial_wf_mem; assumption | split; by constructor].
- assert (IHstar_: wf_state_t s1 t1) by (apply IHstar; auto).
clear IHstar. unfold wf_state_t in IHstar_.
intuition. (** destructs IHstar_ recursively *)
inversion Hstep12; subst; (try rewrite E0_right);
unfold wf_state_t; simpl in *; try by intuition.
+ (** KS_Binop1 *)
intuition.
(** wf_cont remains *)
inversion H.
constructor; [assumption|by unfold wf_cont_wrt_t_pc in H0].
+ (** KS_Binop2 *)
intuition.
(** wf_cont remains *)
constructor; [by unfold wf_expr_wrt_t_pc in H |
unfold wf_cont_wrt_t_pc in H0; by intuition].
+ (** KS_BinopEval *)
intuition.
(** wf_expr remains *)
simpl in H.
unfold wf_cont_wrt_t_pc, wf_expr_wrt_t_pc in *. simpl in *.
destruct H0 as [Hv1 Hk].
clear -H Hv1.
(** TODO: Refactor as a lemma *)
intros ? Heval Hperm.
destruct op; simpl in *; auto.
* destruct v1 as [| [[[[] c1] b1] o1] |] eqn:ev1; try discriminate.
-- destruct v2 as [| [[[[] c2] b2] o2] |] eqn:ev2; simpl in *; inversion Heval;
simpl in *; subst; try discriminate.
specialize (H _ Logic.eq_refl Logic.eq_refl).
inversion H; subst; constructor; by auto.
-- destruct v2 as [| [[[[] c2] b2] o2] |] eqn:ev2; simpl in *; inversion Heval;
simpl in *; subst; discriminate.
-- destruct v2 as [| [[[[] c2] b2] o2] |] eqn:ev2; simpl in *; inversion Heval;
simpl in *; subst; try discriminate.
specialize (Hv1 _ Logic.eq_refl Logic.eq_refl).
inversion Hv1; subst; constructor; by auto.
* destruct v1 as [| [[[[] c1] b1] o1] |] eqn:ev1; try discriminate.
-- destruct v2 as [| [[[[] c2] b2] o2] |] eqn:ev2; simpl in *; inversion Heval;
simpl in *; subst; discriminate.
-- destruct v2 as [| [[[[] c2] b2] o2] |] eqn:ev2; simpl in *; inversion Heval;
simpl in *; subst; try discriminate.
find_if_inside_hyp Heval; discriminate.
-- destruct v2 as [| [[[[] c2] b2] o2] |] eqn:ev2; simpl in *; inversion Heval;
simpl in *; subst.
++ specialize (Hv1 _ Logic.eq_refl Logic.eq_refl).
inversion Hv1; subst; constructor; by auto.
++ find_if_inside_hyp Heval; discriminate.
* destruct v1 as [| [[[[] c1] b1] o1] |] eqn:ev1; try discriminate.
destruct v2 as [| [[[[] c1] b1] o1] |] eqn:ev2; discriminate.
* destruct v1 as [| [[[[] c1] b1] o1] |] eqn:ev1; try discriminate;
destruct v2 as [| [[[[] c2] b2] o2] |] eqn:ev2; discriminate.
* destruct v1 as [| [[[[] c1] b1] o1] |] eqn:ev1; try discriminate;
destruct v2 as [| [[[[] c2] b2] o2] |] eqn:ev2; try discriminate.
-- destruct (Pointer.leq (Permission.code, c1, b1, o1)
(Permission.code, c2, b2, o2)); discriminate.
-- destruct (Pointer.leq (Permission.data, c1, b1, o1)
(Permission.data, c2, b2, o2)); discriminate.
+ (** KS_Seq1 *)
intuition.
(** wf_cont remains *)
inversion H.
constructor; assumption.
+ (** KS_If1 *)
intuition.
(** wf_cont remains *)
inversion H. intuition.
constructor; intuition; assumption.
+ (** KS_If2 *)
intuition.
(** wf_expr remains *)
inversion H0. intuition.
find_if_inside_goal; assumption.
+ (** KS_Arg *)
intuition.
(** wf_expr remains *)
unfold wf_expr_wrt_t_pc. simpl. intros.
inversion H3. constructor.
+ (** KS_AllocEval *)
intuition.
* (** wf_expr *)
apply Memory.component_of_alloc_ptr in H5. subst.
unfold wf_expr_wrt_t_pc. simpl. intros.
inversion H5; subst.
destruct ptr0 as [[[ ?] ?] ?]; simpl.
by constructor.
* (** wf_mem *)
unfold wf_mem_wrt_t_pc in H1.
intros ? ? Hload.
destruct ((Pointer.component load_at, Pointer.block load_at) ==
(Pointer.component ptr, Pointer.block ptr)) eqn:e.
-- erewrite Memory.load_after_alloc_eq in Hload; eauto.
++ repeat (find_if_inside_hyp Hload; [|discriminate]).
discriminate.
++ by apply/eqP.
-- erewrite Memory.load_after_alloc in Hload; eauto.
apply/eqP. by rewrite e.
+ (** KS_DerefEval *)
intuition.
(** wf_expr *)
unfold wf_expr_wrt_t_pc. simpl. intros ? ? Hperm. subst.
destruct ptr as [[[[] cloaded] bloaded] oloaded]; [discriminate|].
clear Hperm.
specialize (H1 _ _ H3 Logic.eq_refl).
unfold wf_expr_wrt_t_pc in H. simpl in H.
assert (P' = Permission.data).
{ by apply Memory.load_some_permission in H3. }
subst.
specialize (H _ Logic.eq_refl Logic.eq_refl).
inversion H1; simpl in *; subst.
* inversion H; subst.
-- by constructor.
-- contradiction.
* by constructor.
* by constructor.
+ (** KS_FunPtr *)
intuition.
unfold wf_expr_wrt_t_pc. simpl. intros ? inv contra. inversion inv. subst.
simpl in *. discriminate.
+ (** KS_Assign1 *)
intuition.
(** wf_cont *)
constructor; simpl; inversion H; assumption.
+ (** KS_Assign2 *)
intuition. inversion H0. constructor; assumption.
+ (** KS_AssignEval *)
intuition.
* (** wf_expr *)
unfold wf_expr_wrt_t_pc. simpl. inversion H0; assumption.
* (** wf_mem *)
intros ? ? Hload Hperm.
destruct ptr as [[[[] cptr] bptr] optr]; [discriminate|]. clear Hperm.
erewrite Memory.load_after_store in Hload; [| by eauto].
assert (P' = Permission.data).
{ by apply Memory.store_some_permission in H3. }
subst. unfold wf_expr_wrt_t_pc in H. simpl in H.
specialize (H _ Logic.eq_refl Logic.eq_refl).
inversion H0 as [Hv ?].
find_if_inside_hyp Hload.
-- move : e => /Pointer.eqP => ?. inversion Hload. subst.
specialize (Hv _ Logic.eq_refl Logic.eq_refl).
inversion Hv; subst.
++ destruct (classic (addr_shared_so_far (cptr, bptr) t1))
as [ptrshr|ptrnotshr].
** apply shared_stuff_from_anywhere; assumption.
** destruct (classic (addr_shared_so_far (C', b') t1))
as [C'b'shr|C'b'notshr].
--- apply private_stuff_of_current_pc_from_shared_addr; by auto.
--- apply private_stuff_from_corresp_private_addr; auto.
inversion H; [by auto | contradiction].
++ apply shared_stuff_from_anywhere; assumption.
-- apply H1; by auto.
+ (** KS_InitCallPtr1 *)
intuition. inversion H.
constructor; assumption.
+ (** KS_InitCallPtr2 *)
intuition. unfold wf_expr_wrt_t_pc in H. simpl in *.
inversion H0.
constructor; assumption.
+ (** KS_InitCallPtr3 *)
intuition. inversion H0. assumption.
+ (** KS_InternalCall *)
intuition.
* (** wf_expr *)
apply values_are_integers_expr_wrt_t_pc.
destruct Hwf.
by specialize (wfprog_well_formed_procedures0 _ _ _ H5) as [_ [? _]].
* (** wf_cont *)
by constructor.
* constructor; simpl; by intuition.
+ (** KS_ExternalCall *)
intuition.
* (** wf_expr *)
apply values_are_integers_expr_wrt_t_pc.
destruct Hwf.
by specialize (wfprog_well_formed_procedures0 _ _ _ H6) as [_ [? _]].
* intros ? ? Hload Hperm.
destruct ptr as [[[[] cptr] bptr] optr]; [discriminate|]. clear Hperm.
destruct load_at as [[[ploadat cloadat] bloadat] oloadat].
assert (ploadat = Permission.data).
{ by apply Memory.load_some_permission in Hload. }
subst.
setoid_rewrite cats1.
destruct (classic (addr_shared_so_far (cptr, bptr)
(rcons t1 (ECall C P v mem C'))))
as [ptrshr|ptrnotshr].
-- apply shared_stuff_from_anywhere; by auto.
-- destruct (cptr == C') eqn:ecptr.
++ assert (cptr = C'). by apply/eqP. subst.
destruct (classic (addr_shared_so_far (cloadat, bloadat)
(rcons t1 (ECall C P v mem C'))))
as [loadatshr|loadatnotshr].
** apply private_stuff_of_current_pc_from_shared_addr; auto.
** apply private_stuff_from_corresp_private_addr; auto. simpl.
specialize (H1 _ _ Hload Logic.eq_refl). inversion H1; subst; auto.
--- exfalso. apply ptrnotshr.
eapply reachable_from_previously_shared; eauto. simpl.
constructor. by rewrite in_fset1.
--- exfalso. apply loadatnotshr.
eapply reachable_from_previously_shared; eauto. simpl.
constructor. by rewrite in_fset1.
++ apply private_stuff_from_corresp_private_addr; simpl in *; auto; subst.
** intros Hshraddr.
apply ptrnotshr.
eapply addr_shared_so_far_load_addr_shared_so_far; simpl; eauto.
** specialize (H1 _ _ Hload Logic.eq_refl). inversion H1; subst; auto.
--- exfalso. apply ptrnotshr.
eapply reachable_from_previously_shared; eauto. simpl.
constructor. by rewrite in_fset1.
--- exfalso. apply ptrnotshr.
eapply addr_shared_so_far_load_addr_shared_so_far; simpl; eauto.
+++
eapply reachable_from_previously_shared; eauto. simpl.
constructor. by rewrite in_fset1.
+++ eassumption.
* (** wf_cont *)
constructor.
* (** wf_stack *)
constructor; intuition.
-- constructor; simpl in *.
++ intros ? Hptr Hperm.
destruct ptr as [[[pptr cptr] bptr] optr].
simpl in *; subst.
specialize (H4 _ Logic.eq_refl Logic.eq_refl).
destruct (classic (addr_shared_so_far
(cptr, bptr)
(t1 ** [:: ECall C P v mem C'])
)) as [ptrshr | ptrnotshr].
** eapply wf_ptr_shared; by auto.
** inversion H4; [by constructor|subst].
setoid_rewrite cats1 in ptrnotshr.
exfalso.
eapply ptrnotshr, reachable_from_previously_shared; [eassumption|].
constructor. by rewrite in_fset1.
++ by apply cont_struct_invariant_rcons.
-- unfold wf_stack_wrt_t_pc, stack_struct_invariant in H2.
apply Forall_forall. erewrite Forall_forall in H2.
intros frm Hin. specialize (H2 frm Hin).
destruct H2 as [Hfrm1 Hfrm2].
split.
++ intros ? Harg Hperm.
specialize (Hfrm1 _ Harg Hperm).
setoid_rewrite cats1.
destruct ptr as [[[pptr cptr] bptr] optr]. simpl in *; subst.
destruct (classic (addr_shared_so_far
(cptr, bptr)
(rcons t1 (ECall C P v mem C'))
)) as [ptrshr | ptrnotshr].
** eapply wf_ptr_shared; by auto.
** inversion Hfrm1; [by constructor|subst].
exfalso.
eapply ptrnotshr, reachable_from_previously_shared; [eassumption|].
constructor. by rewrite in_fset1.
++ by apply cont_struct_invariant_rcons.
* (** wf_ptr *)
setoid_rewrite cats1.
destruct ptr as [[[pptr cptr] bptr] optr]. simpl in *; subst.
assert (G: addr_shared_so_far
(cptr, bptr)
(rcons t1
(ECall C P (Ptr (Permission.data, cptr, bptr, optr)) mem C'))
).
{
eapply reachable_from_args_is_shared; simpl.
constructor. by rewrite in_fset1.
}
constructor; by auto.
+ (** KS_InternalReturn *)
intuition.
* (** wf_cont *)
inversion H2; subst. unfold wf_frame_wrt_t in H6.
by intuition.
* (** wf_stack *)
inversion H2; subst. by intuition.
* inversion H2; subst. unfold wf_frame_wrt_t in H8.
by intuition.
+ (** KS_ExternalReturn *)
intuition.
* (** wf_expr *)
unfold wf_expr_wrt_t_pc. simpl. intros ? Hv Hperm.
setoid_rewrite cats1.
destruct ptr as [[[pptr cptr] bptr] optr]. simpl in *; subst.
assert (G: addr_shared_so_far
(cptr, bptr)
(rcons t1
(ERet C (Ptr (Permission.data, cptr, bptr, optr)) mem C'))
).
{
eapply reachable_from_args_is_shared; simpl.
constructor. by rewrite in_fset1.
}
constructor; by auto.
* intros ? ? Hload Hperm.
destruct ptr as [[[[] cptr] bptr] optr]; [discriminate|]. clear Hperm.
destruct load_at as [[[ploadat cloadat] bloadat] oloadat].
assert (ploadat = Permission.data).
{ by apply Memory.load_some_permission in Hload. }
subst.
setoid_rewrite cats1.
destruct (classic (addr_shared_so_far (cptr, bptr)
(rcons t1 (ERet C v mem C'))))
as [ptrshr|ptrnotshr].
-- apply shared_stuff_from_anywhere; by auto.
-- destruct (cptr == C') eqn:ecptr.
++ assert (cptr = C'). by apply/eqP. subst.
destruct (classic (addr_shared_so_far (cloadat, bloadat)
(rcons t1 (ERet C v mem C'))))
as [loadatshr|loadatnotshr].
** apply private_stuff_of_current_pc_from_shared_addr; auto.
** apply private_stuff_from_corresp_private_addr; auto. simpl.
specialize (H1 _ _ Hload Logic.eq_refl). inversion H1; subst; auto.
--- exfalso. apply ptrnotshr.
eapply reachable_from_previously_shared; eauto. simpl.
constructor. by rewrite in_fset1.
--- exfalso. apply loadatnotshr.
eapply reachable_from_previously_shared; eauto. simpl.
constructor. by rewrite in_fset1.
++ apply private_stuff_from_corresp_private_addr; simpl in *; auto; subst.
** intros Hshraddr.
apply ptrnotshr.
eapply addr_shared_so_far_load_addr_shared_so_far; simpl; eauto.
** specialize (H1 _ _ Hload Logic.eq_refl). inversion H1; subst; auto.
--- exfalso. apply ptrnotshr.
eapply reachable_from_previously_shared; eauto. simpl.
constructor. by rewrite in_fset1.
--- exfalso. apply ptrnotshr.
eapply addr_shared_so_far_load_addr_shared_so_far; simpl; eauto.
+++
eapply reachable_from_previously_shared; eauto. simpl.
constructor. by rewrite in_fset1.
+++ eassumption.
* (** wf_cont *)
inversion H2; subst. unfold wf_frame_wrt_t in H7.
intuition. simpl in *. unfold wf_cont_wrt_t_pc.
by apply cont_struct_invariant_rcons.
* (** w_stack *)
unfold wf_stack_wrt_t_pc, stack_struct_invariant, wf_frame_wrt_t in *.
apply Forall_forall. erewrite Forall_forall in H2.
intros frm Hin.
assert (Hin':
In frm
({| CS.f_component := C';
CS.f_arg := old_call_arg; CS.f_cont := k |} :: s)).
{
by apply List.in_cons.
}
specialize (H2 frm Hin').
destruct H2 as [Hfrm1 Hfrm2].
split.
++ intros ? Harg Hperm.
specialize (Hfrm1 _ Harg Hperm).
setoid_rewrite cats1.
destruct ptr as [[[pptr cptr] bptr] optr]. simpl in *; subst.
destruct (classic (addr_shared_so_far
(cptr, bptr)
(rcons t1 (ERet C v mem C'))
)) as [ptrshr | ptrnotshr].
** eapply wf_ptr_shared; by auto.
** inversion Hfrm1; [by constructor|subst].
exfalso.
eapply ptrnotshr, reachable_from_previously_shared; [eassumption|].
constructor. by rewrite in_fset1.
++ by apply cont_struct_invariant_rcons.
* (** wf_ptr *)
inversion H2; subst. unfold wf_frame_wrt_t in H9.
intuition.
simpl in *.
specialize (H5 _ Logic.eq_refl H6).
destruct ptr as [[[pptr cptr] bptr] optr]. simpl in *. subst.
setoid_rewrite cats1.
destruct (classic (addr_shared_so_far
(cptr, bptr)
(rcons t1 (ERet C v mem C'))
)) as [ptrshr | ptrnotshr].
** eapply wf_ptr_shared; by auto.
** inversion H5; [by constructor|].
subst. exfalso.
eapply ptrnotshr, reachable_from_previously_shared; [eassumption|].
constructor. by rewrite in_fset1.
Qed.
End CSInvariants.
|
#include "jacobiantest.hpp"
#include <kinfam_io.hpp>
#include <Eigen/Core>
CPPUNIT_TEST_SUITE_REGISTRATION(JacobianTest);
using namespace KDL;
void JacobianTest::setUp(){}
void JacobianTest::tearDown(){}
void JacobianTest::TestChangeRefPoint(){
//Create a random jacobian
Jacobian j1(5);
j1.data.setRandom();
//Create a random Vector
Vector p;
random(p);
Jacobian j2(5);
CPPUNIT_ASSERT(changeRefPoint(j1,p,j2));
CPPUNIT_ASSERT(j1!=j2);
Jacobian j3(4);
CPPUNIT_ASSERT(!changeRefPoint(j1,p,j3));
j3.resize(5);
CPPUNIT_ASSERT(changeRefPoint(j2,-p,j3));
CPPUNIT_ASSERT_EQUAL(j1,j3);
}
void JacobianTest::TestChangeRefFrame(){
//Create a random jacobian
Jacobian j1(5);
j1.data.setRandom();
//Create a random frame
Frame f;
random(f);
Jacobian j2(5);
CPPUNIT_ASSERT(changeRefFrame(j1,f,j2));
CPPUNIT_ASSERT(j1!=j2);
Jacobian j3(4);
CPPUNIT_ASSERT(!changeRefFrame(j1,f,j3));
j3.resize(5);
CPPUNIT_ASSERT(changeRefFrame(j2,f.Inverse(),j3));
CPPUNIT_ASSERT_EQUAL(j1,j3);
}
void JacobianTest::TestChangeBase(){
//Create a random jacobian
Jacobian j1(5);
j1.data.setRandom();
//Create a random rotation
Rotation r;
random(r);
Jacobian j2(5);
CPPUNIT_ASSERT(changeBase(j1,r,j2));
CPPUNIT_ASSERT(j1!=j2);
Jacobian j3(4);
CPPUNIT_ASSERT(!changeBase(j1,r,j3));
j3.resize(5);
CPPUNIT_ASSERT(changeBase(j2,r.Inverse(),j3));
CPPUNIT_ASSERT_EQUAL(j1,j3);
}
void JacobianTest::TestConstructor(){
//Create an empty Jacobian
Jacobian j1(2);
//Get size
CPPUNIT_ASSERT_EQUAL(j1.rows(),(unsigned int)6);
CPPUNIT_ASSERT_EQUAL(j1.columns(),(unsigned int)2);
//Create a second Jacobian from empty
Jacobian j2(j1);
//Get size
CPPUNIT_ASSERT_EQUAL(j2.rows(),(unsigned int)6);
CPPUNIT_ASSERT_EQUAL(j2.columns(),(unsigned int)2);
Jacobian j3=j1;
//Get size
CPPUNIT_ASSERT_EQUAL(j3.rows(),(unsigned int)6);
CPPUNIT_ASSERT_EQUAL(j3.columns(),(unsigned int)2);
//Test resize
j1.resize(5);
//Get size
CPPUNIT_ASSERT_EQUAL(j1.rows(),(unsigned int)6);
CPPUNIT_ASSERT_EQUAL(j1.columns(),(unsigned int)5);
j2=j1;
//Get size
CPPUNIT_ASSERT_EQUAL(j2.rows(),(unsigned int)6);
CPPUNIT_ASSERT_EQUAL(j2.columns(),(unsigned int)5);
}
void JacobianTest::TestGetSetColumn(){}
|
theory Pappus_Property
imports Main Projective_Plane_Axioms
begin
(* Author: Anthony Bordg, University of Cambridge, [email protected] .*)
text \<open>
Contents:
\<^item> We give two formulations of Pappus's property for a configuration of nine points
[is_pappus1] [is_pappus2].
\<^item> We prove the equivalence of these two formulations [pappus_equiv].
\<^item> We state Pappus property for a plane [is_pappus].
\<close>
section \<open>Pappus's Property\<close>
definition col :: "[Points, Points, Points] \<Rightarrow> bool" where
"col A B C \<equiv> \<exists>l. incid A l \<and> incid B l \<and> incid C l"
definition distinct6 ::
"[Points, Points, Points, Points, Points, Points] \<Rightarrow> bool" where
"distinct6 A B C D E F \<equiv> (A \<noteq> B) \<and> (A \<noteq> C) \<and> (A \<noteq> D) \<and> (A \<noteq> E) \<and> (A \<noteq> F) \<and>
(B \<noteq> C) \<and> (B \<noteq> D) \<and> (B \<noteq> E) \<and> (B \<noteq> F) \<and>
(C \<noteq> D) \<and> (C \<noteq> E) \<and> (C \<noteq> F) \<and>
(D \<noteq> E) \<and> (D \<noteq> F) \<and>
(E \<noteq> F)"
definition lines :: "Points \<Rightarrow> Points \<Rightarrow> Lines set" where
"lines P Q \<equiv> {l. incid P l \<and> incid Q l}"
lemma uniq_line:
assumes "P \<noteq> Q" and "l \<in> lines P Q" and "m \<in> lines P Q"
shows "l = m"
using assms lines_def ax_uniqueness
by blast
definition line :: "Points \<Rightarrow> Points \<Rightarrow> Lines" where
"line P Q \<equiv> @l. incid P l \<and> incid Q l"
(* The point P is the intersection of the lines AB and CD. For P to be well-defined,
A and B should be distinct, C and D should be distinct, and the lines AB and CD should
be distinct *)
definition is_a_proper_intersec :: "[Points, Points, Points, Points, Points] \<Rightarrow> bool" where
"is_a_proper_intersec P A B C D \<equiv> (A \<noteq> B) \<and> (C \<noteq> D) \<and> (line A B \<noteq> line C D)
\<and> col P A B \<and> col P C D"
(* We state a first form of Pappus's property *)
definition is_pappus1 ::
"[Points, Points, Points, Points, Points, Points, Points, Points, Points] => bool " where
"is_pappus1 A B C A' B' C' P Q R \<equiv>
distinct6 A B C A' B' C' \<longrightarrow> col A B C \<longrightarrow> col A' B' C'
\<longrightarrow> is_a_proper_intersec P A B' A' B \<longrightarrow> is_a_proper_intersec Q B C' B' C
\<longrightarrow> is_a_proper_intersec R A C' A' C
\<longrightarrow> col P Q R"
definition is_a_intersec :: "[Points, Points, Points, Points, Points] \<Rightarrow> bool" where
"is_a_intersec P A B C D \<equiv> col P A B \<and> col P C D"
(* We state a second form of Pappus's property *)
definition is_pappus2 ::
"[Points, Points, Points, Points, Points, Points, Points, Points, Points] \<Rightarrow> bool" where
"is_pappus2 A B C A' B' C' P Q R \<equiv>
(distinct6 A B C A' B' C' \<or> (A \<noteq> B' \<and> A'\<noteq> B \<and> line A B' \<noteq> line A' B \<and>
B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C \<and>
A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C))
\<longrightarrow> col A B C \<longrightarrow> col A' B' C' \<longrightarrow> is_a_intersec P A B' A' B
\<longrightarrow> is_a_intersec Q B C' B' C \<longrightarrow> is_a_intersec R A C' A' C
\<longrightarrow> col P Q R"
lemma is_a_proper_intersec_is_a_intersec:
assumes "is_a_proper_intersec P A B C D"
shows "is_a_intersec P A B C D"
using assms is_a_intersec_def is_a_proper_intersec_def
by auto
(* The first and the second forms of Pappus's property are equivalent *)
lemma pappus21:
assumes "is_pappus2 A B C A' B' C' P Q R"
shows "is_pappus1 A B C A' B' C' P Q R"
using assms is_pappus2_def is_pappus1_def is_a_proper_intersec_is_a_intersec
by auto
lemma col_AAB: "col A A B"
by (simp add: ax1 col_def)
lemma col_ABA: "col A B A"
using ax1 col_def
by blast
lemma col_ABB: "col A B B"
by (simp add: ax1 col_def)
lemma incidA_lAB: "incid A (line A B)"
by (metis (no_types, lifting) ax1 line_def someI_ex)
lemma incidB_lAB: "incid B (line A B)"
by (metis (no_types, lifting) ax1 line_def someI_ex)
lemma degenerate_hexagon_is_pappus:
assumes "distinct6 A B C A' B' C'" and "col A B C" and "col A' B' C'" and
"is_a_intersec P A B' A' B" and "is_a_intersec Q B C' B' C" and "is_a_intersec R A C' A' C"
and "line A B' = line A' B \<or> line B C' = line B' C \<or> line A C' = line A' C"
shows "col P Q R"
proof -
have "col P Q R" if "line A B' = line A' B"
by (smt assms(1) assms(3) assms(4) assms(5) assms(6) ax_uniqueness col_def distinct6_def
incidA_lAB incidB_lAB is_a_intersec_def that)
have "col P Q R" if "line B C' = line B' C"
by (smt \<open>line A B' = line A' B \<Longrightarrow> col P Q R\<close> assms(1) assms(2) assms(3) ax_uniqueness col_def
distinct6_def incidA_lAB incidB_lAB that)
have "col P Q R" if "line A C' = line A' C"
by (smt \<open>line B C' = line B' C \<Longrightarrow> col P Q R\<close> assms(1) assms(2) assms(3) assms(7) ax_uniqueness
col_def distinct6_def incidA_lAB incidB_lAB)
show "col P Q R"
using \<open>line A B' = line A' B \<Longrightarrow> col P Q R\<close> \<open>line A C' = line A' C \<Longrightarrow> col P Q R\<close>
\<open>line B C' = line B' C \<Longrightarrow> col P Q R\<close> assms(7)
by blast
qed
lemma pappus12:
assumes "is_pappus1 A B C A' B' C' P Q R"
shows "is_pappus2 A B C A' B' C' P Q R"
proof -
have "col P Q R" if "(A \<noteq> B' \<and> A'\<noteq> B \<and> line A B' \<noteq> line A' B \<and>
B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C \<and>
A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C)" and h1:"col A B C" and h2:"col A' B' C'"
and "is_a_intersec P A B' A' B" and "is_a_intersec Q B C' B' C"
and "is_a_intersec R A C' A' C"
proof -
have "col P Q R" if "A = B" (* in this case P = A = B and P, Q, R lie on AC' *)
proof -
have "P = A"
by (metis \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C
\<and> A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> \<open>is_a_intersec P A B' A' B\<close> ax_uniqueness col_def
incidA_lAB incidB_lAB is_a_intersec_def that)
have "col P A C' \<and> col Q A C' \<and> col R A C'"
using \<open>P = A\<close> \<open>is_a_intersec Q B C' B' C\<close> \<open>is_a_intersec R A C' A' C\<close> col_AAB
is_a_intersec_def that
by auto
then show "col P Q R"
by (smt \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C
\<and> A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> ax_uniqueness col_def)
qed
have "col P Q R" if "A = C" (* case where P = A = C = Q and P,Q,R belong to AB' *)
proof -
have "R = A"
by (metis \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C
\<and> A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> \<open>is_a_intersec R A C' A' C\<close> ax_uniqueness col_def incidA_lAB incidB_lAB is_a_intersec_def that)
have "col P A B' \<and> col Q A B' \<and> col R A B'"
using \<open>R = A\<close> \<open>is_a_intersec P A B' A' B\<close> \<open>is_a_intersec Q B C' B' C\<close> col_def
is_a_intersec_def that
by auto
then show "col P Q R"
by (smt \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C
\<and> A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> ax_uniqueness col_def)
qed
have "col P Q R" if "A = A'" (* very degenerate case, all the 9 points are collinear*)
by (smt \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C \<and>
A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> \<open>is_a_intersec P A B' A' B\<close> \<open>is_a_intersec R A C' A' C\<close>
ax_uniqueness col_ABA col_def incidA_lAB incidB_lAB is_a_intersec_def that)
have "col P Q R" if "B = C" (* case where B = C = Q and P,Q,R belong to A'B *)
by (smt \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C \<and>
A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> \<open>is_a_intersec P A B' A' B\<close> \<open>is_a_intersec Q B C' B' C\<close>
\<open>is_a_intersec R A C' A' C\<close> ax_uniqueness col_def incidA_lAB incidB_lAB is_a_intersec_def that)
have "col P Q R" if "B = B'" (* very degenerate case, the 9 points are collinear *)
by (smt \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C \<and>
A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> \<open>is_a_intersec P A B' A' B\<close> \<open>is_a_intersec Q B C' B' C\<close>
ax_uniqueness col_AAB col_def incidA_lAB incidB_lAB is_a_intersec_def that)
have "col P Q R" if "C = C'" (* again, very degenerate case, the 9 points are collinear *)
by (smt \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C \<and>
A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> \<open>is_a_intersec Q B C' B' C\<close> \<open>is_a_intersec R A C' A' C\<close>
ax_uniqueness col_ABB col_def incidA_lAB incidB_lAB is_a_intersec_def that)
have "col P Q R" if "A' = B'" (* case where P = A' = B', and P,Q,R belong to A'C *)
by (smt \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C \<and>
A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> \<open>is_a_intersec P A B' A' B\<close> \<open>is_a_intersec Q B C' B' C\<close>
\<open>is_a_intersec R A C' A' C\<close> ax_uniqueness col_def incidA_lAB incidB_lAB is_a_intersec_def that)
have "col P Q R" if "A' = C'" (* case where R = A' = B', the points P,Q,R belong to A'B *)
by (smt \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C \<and>
A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> \<open>is_a_intersec P A B' A' B\<close> \<open>is_a_intersec Q B C' B' C\<close>
\<open>is_a_intersec R A C' A' C\<close> ax_uniqueness col_def incidA_lAB incidB_lAB is_a_intersec_def that)
have "col P Q R" if "B' = C'" (* case where Q = B' = C', the points P,Q,R belong to AB' *)
by (smt \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C \<and>
A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> \<open>is_a_intersec P A B' A' B\<close> \<open>is_a_intersec Q B C' B' C\<close>
\<open>is_a_intersec R A C' A' C\<close> ax_uniqueness col_def incidA_lAB incidB_lAB is_a_intersec_def that)
have "col P Q R" if "A \<noteq> B \<and> A \<noteq> C \<and> A \<noteq> A' \<and> B \<noteq> C \<and> B \<noteq> B' \<and> C \<noteq> C' \<and> A'\<noteq> B'
\<and> A' \<noteq> C' \<and> B' \<noteq> C'"
proof -
have a1:"distinct6 A B C A' B' C'"
using \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C \<and>
A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> distinct6_def that
by auto
have "is_a_proper_intersec P A B' A' B"
using \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C \<and>
A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> \<open>is_a_intersec P A B' A' B\<close> is_a_intersec_def
is_a_proper_intersec_def
by auto
have "is_a_proper_intersec Q B C' B' C"
using \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C \<and>
A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> \<open>is_a_intersec Q B C' B' C\<close> is_a_intersec_def
is_a_proper_intersec_def
by auto
have "is_a_proper_intersec R A C' A' C"
using \<open>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C \<and>
A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C\<close> \<open>is_a_intersec R A C' A' C\<close> is_a_intersec_def
is_a_proper_intersec_def
by auto
show "col P Q R"
using \<open>is_a_proper_intersec P A B' A' B\<close> \<open>is_a_proper_intersec Q B C' B' C\<close>
\<open>is_a_proper_intersec R A C' A' C\<close> a1 assms h1 h2 is_pappus1_def
by blast
qed
show "col P Q R"
using \<open>A = A' \<Longrightarrow> col P Q R\<close> \<open>A = B \<Longrightarrow> col P Q R\<close> \<open>A = C \<Longrightarrow> col P Q R\<close>
\<open>A \<noteq> B \<and> A \<noteq> C \<and> A \<noteq> A' \<and> B \<noteq> C \<and> B \<noteq> B' \<and> C \<noteq> C' \<and> A' \<noteq> B' \<and> A' \<noteq> C' \<and> B' \<noteq> C' \<Longrightarrow> col P Q R\<close>
\<open>A' = B' \<Longrightarrow> col P Q R\<close> \<open>A' = C' \<Longrightarrow> col P Q R\<close> \<open>B = B' \<Longrightarrow> col P Q R\<close> \<open>B = C \<Longrightarrow> col P Q R\<close>
\<open>B' = C' \<Longrightarrow> col P Q R\<close> \<open>C = C' \<Longrightarrow> col P Q R\<close>
by blast
qed
have "col P Q R" if "distinct6 A B C A' B' C'" and "col A B C" and "col A' B' C'"
and "is_a_intersec P A B' A' B" and "is_a_intersec Q B C' B' C" and "is_a_intersec R A C' A' C"
proof -
have "col P Q R" if "line A B' = line A' B"
using \<open>col A B C\<close> \<open>col A' B' C'\<close> \<open>distinct6 A B C A' B' C'\<close> \<open>is_a_intersec P A B' A' B\<close>
\<open>is_a_intersec Q B C' B' C\<close> \<open>is_a_intersec R A C' A' C\<close> degenerate_hexagon_is_pappus that
by blast
have "col P Q R" if "line B C' = line B' C"
using \<open>col A B C\<close> \<open>col A' B' C'\<close> \<open>distinct6 A B C A' B' C'\<close> \<open>is_a_intersec P A B' A' B\<close>
\<open>is_a_intersec Q B C' B' C\<close> \<open>is_a_intersec R A C' A' C\<close> degenerate_hexagon_is_pappus that
by blast
have "col P Q R" if "line A' C = line A C'"
using \<open>col A B C\<close> \<open>col A' B' C'\<close> \<open>distinct6 A B C A' B' C'\<close> \<open>is_a_intersec P A B' A' B\<close>
\<open>is_a_intersec Q B C' B' C\<close> \<open>is_a_intersec R A C' A' C\<close> degenerate_hexagon_is_pappus that
by auto
have "col P Q R" if "line A B' \<noteq> line A' B" and "line B C' \<noteq> line B' C" and
"line A C' \<noteq> line A' C"
proof -
have "is_a_proper_intersec P A B' A' B"
using \<open>distinct6 A B C A' B' C'\<close> \<open>is_a_intersec P A B' A' B\<close> distinct6_def is_a_intersec_def
is_a_proper_intersec_def that(1)
by auto
have "is_a_proper_intersec Q B C' B' C"
using \<open>distinct6 A B C A' B' C'\<close> \<open>is_a_intersec Q B C' B' C\<close> distinct6_def is_a_intersec_def
is_a_proper_intersec_def that(2)
by auto
have "is_a_proper_intersec R A C' A' C"
using \<open>distinct6 A B C A' B' C'\<close> \<open>is_a_intersec R A C' A' C\<close> distinct6_def is_a_intersec_def
is_a_proper_intersec_def that(3)
by auto
show "col P Q R"
using \<open>col A B C\<close> \<open>col A' B' C'\<close> \<open>distinct6 A B C A' B' C'\<close> \<open>is_a_proper_intersec P A B' A' B\<close>
\<open>is_a_proper_intersec Q B C' B' C\<close> \<open>is_a_proper_intersec R A C' A' C\<close> assms is_pappus1_def
by blast
qed
show "col P Q R"
using \<open>\<lbrakk>line A B' \<noteq> line A' B; line B C' \<noteq> line B' C; line A C' \<noteq> line A' C\<rbrakk> \<Longrightarrow> col P Q R\<close>
\<open>line A B' = line A' B \<Longrightarrow> col P Q R\<close> \<open>line A' C = line A C' \<Longrightarrow> col P Q R\<close>
\<open>line B C' = line B' C \<Longrightarrow> col P Q R\<close>
by fastforce
qed
show "is_pappus2 A B C A' B' C' P Q R"
by (simp add: \<open>\<lbrakk>A \<noteq> B' \<and> A' \<noteq> B \<and> line A B' \<noteq> line A' B \<and> B \<noteq> C' \<and> B' \<noteq> C \<and> line B C' \<noteq> line B' C
\<and> A \<noteq> C' \<and> A' \<noteq> C \<and> line A C' \<noteq> line A' C; col A B C; col A' B' C'; is_a_intersec P A B' A' B; is_a_intersec Q B C' B' C; is_a_intersec R A C' A' C\<rbrakk> \<Longrightarrow> col P Q R\<close>
\<open>\<lbrakk>distinct6 A B C A' B' C'; col A B C; col A' B' C'; is_a_intersec P A B' A' B; is_a_intersec Q B C' B' C; is_a_intersec R A C' A' C\<rbrakk> \<Longrightarrow> col P Q R\<close>
is_pappus2_def)
qed
lemma pappus_equiv: "is_pappus1 A B C A' B' C' P Q R = is_pappus2 A B C A' B' C' P Q R"
using pappus12 pappus21
by blast
(* Finally, we give Pappus's property for a plane stating that the diagonal points
of any hexagon of that plane, whose vertices lie alternately on two lines, are collinear *)
definition is_pappus :: "bool" where
"is_pappus \<equiv> \<forall>A B C D E F P Q R. is_pappus2 A B C D E F P Q R"
end
|
Require Export SpecializedCategory Functor.
Require Import Common.
Set Implicit Arguments.
Generalizable All Variables.
Set Asymmetric Patterns.
Set Universe Polymorphism.
Section SumCategory.
Context `(C : @SpecializedCategory objC).
Context `(D : @SpecializedCategory objD).
Definition SumCategory_Morphism (s d : objC + objD) : Type
:= match (s, d) with
| (inl s, inl d) => C.(Morphism) s d
| (inr s, inr d) => D.(Morphism) s d
| _ => Empty_set
end.
Global Arguments SumCategory_Morphism _ _ /.
Definition SumCategory_Identity (x : C + D) : SumCategory_Morphism x x
:= match x with
| inl x => Identity x
| inr x => Identity x
end.
Global Arguments SumCategory_Identity _ /.
Definition SumCategory_Compose (s d d' : C + D) (m1 : SumCategory_Morphism d d') (m2 : SumCategory_Morphism s d) : SumCategory_Morphism s d'.
(* XXX NOTE: try to use typeclasses and work up to existance of morphisms here *)
case s, d, d'; simpl in *; try destruct_to_empty_set;
eapply Compose; eassumption.
Defined.
Global Arguments SumCategory_Compose [_ _ _] _ _ /.
Definition SumCategory : @SpecializedCategory (objC + objD)%type.
refine (@Build_SpecializedCategory _
SumCategory_Morphism
SumCategory_Identity
SumCategory_Compose
_
_
_);
abstract (
repeat match goal with
| [ H : Empty_set |- _ ] => case H
| _ => let H := fresh in intro H; try (case H; clear H); simpl in *
end;
auto with morphism
).
Defined.
End SumCategory.
Infix "+" := SumCategory : category_scope.
Section SumCategoryFunctors.
Context `(C : @SpecializedCategory objC).
Context `(D : @SpecializedCategory objD).
Definition inl_Functor : SpecializedFunctor C (C + D)
:= Build_SpecializedFunctor C (C + D)
(@inl _ _)
(fun _ _ m => m)
(fun _ _ _ _ _ => eq_refl)
(fun _ => eq_refl).
Definition inr_Functor : SpecializedFunctor D (C + D)
:= Build_SpecializedFunctor D (C + D)
(@inr _ _)
(fun _ _ m => m)
(fun _ _ _ _ _ => eq_refl)
(fun _ => eq_refl).
End SumCategoryFunctors.
|
Formal statement is: lemma lipschitz_on_cmult [lipschitz_intros]: fixes f::"'a::metric_space \<Rightarrow> 'b::real_normed_vector" assumes "C-lipschitz_on U f" shows "(abs(a) * C)-lipschitz_on U (\<lambda>x. a *\<^sub>R f x)" Informal statement is: If $f$ is $C$-Lipschitz on $U$, then $a f$ is $|a| C$-Lipschitz on $U$. |
/**
* Copyright (c) 2017 Melown Technologies SE
*
* 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.
*/
#include <cstdlib>
#include <utility>
#include <functional>
#include <map>
#include <boost/optional.hpp>
#include <boost/utility/in_place_factory.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/thread.hpp>
#include "utility/streams.hpp"
#include "utility/raise.hpp"
#include "utility/tcpendpoint-io.hpp"
#include "utility/buildsys.hpp"
#include "service/service.hpp"
#include "http/http.hpp"
#include "vts-libs/storage/fstreams.hpp"
#include "vts-libs/storage/error.hpp"
#include "vts-libs/registry/po.hpp"
#include "vts-libs/vts/options.hpp"
#include "vts-libs/vts/support.hpp"
#include "error.hpp"
#include "config.hpp"
#include "delivery/cache.hpp"
#include "delivery/vts/driver.hpp"
#include "delivery/vts0/driver.hpp"
#include "daemon.hpp"
namespace po = boost::program_options;
namespace fs = boost::filesystem;
namespace ba = boost::algorithm;
namespace vr = vtslibs::registry;
namespace vts = vtslibs::vts;
namespace {
LocationConfig defaultConfig()
{
LocationConfig dc;
dc.vars = vts::defaultSupportVars;
dc.vars.insert(vts2tdt::defaultSupportVars.begin()
, vts2tdt::defaultSupportVars.end());
// some file class defaults
auto &fcs(dc.fileClassSettings);
fcs.setMaxAge(FileClass::config, 60);
fcs.setMaxAge(FileClass::support, 3600);
fcs.setMaxAge(FileClass::registry, 3600);
fcs.setMaxAge(FileClass::data, 604800);
return dc;
}
} // namespace
class Vtsd : public Daemon
{
public:
Vtsd()
: Daemon("vtsd", BUILD_TARGET_VERSION, 3060, defaultConfig()
, Flags::needsHttpClient)
{}
private:
// service::Service
virtual void configuration(po::options_description &cmdline
, po::options_description &config
, po::positional_options_description &pd);
// service::Service
virtual service::UnrecognizedParser::optional
configure(const po::variables_map &vars
, const service::UnrecognizedOptions &unrecognized);
// service::Service
virtual void configure(const po::variables_map &vars);
// service::Service
virtual std::vector<std::string> listHelps() const;
// service::Service
virtual bool help(std::ostream &out, const std::string &what) const;
// Daemon
virtual void handleDataset(DeliveryCache &deliveryCache
, const fs::path &filePath
, const http::Request &request
, Sink sink, const LocationConfig &location);
// Daemon
virtual DeliveryCache::OpenDriver openDriver();
};
void Vtsd::configuration(po::options_description &cmdline
, po::options_description &config
, po::positional_options_description &pd)
{
vr::registryConfiguration(config, vr::defaultPath());
return Daemon::configurationImpl(cmdline, config, pd);
}
service::UnrecognizedParser::optional
Vtsd::configure(const po::variables_map &vars
, const service::UnrecognizedOptions &unrecognized)
{
return Daemon::configureImpl(vars, unrecognized);
}
void Vtsd::configure(const po::variables_map &vars)
{
vr::registryConfigure(vars);
return Daemon::configureImpl(vars);
}
std::vector<std::string> Vtsd::listHelps() const
{
return Daemon::listHelpsImpl();
}
bool Vtsd::help(std::ostream &out, const std::string &what) const
{
if (what.empty()) {
// program help
out << ("VTS delivery daemon\n"
"\n"
);
return true;
}
return Daemon::helpImpl(out, what);
}
DeliveryCache::OpenDriver Vtsd::openDriver()
{
return DeliveryCache::OpenDriver
([this](const std::string &path, const OpenOptions &openOptions
, DeliveryCache &cache
, const DeliveryCache::Callback &callback)
-> DeliveryCache::Driver
{
LOG(info2) << "Opening driver for \"" << path << "\".";
// try VTS
try {
return openVts(path, openOptions, cache, callback
, proxiesConfigured());
} catch (const vs::NoSuchTileSet&) {}
// finally try VTS0
return openVts0(path);
});
}
boost::optional<std::string>
getProxy(const LocationConfig &location, const http::Request &request)
{
if (!location.proxyHeader) { return boost::none; }
if (const auto *header = request.getHeader(*location.proxyHeader)) {
const auto proxy(ba::trim_copy(*header));
if (location.allowedProxies.find(proxy)
== location.allowedProxies.end())
{
LOG(warn2)
<< "Proxy <" << proxy << "> not allowed for location <"
<< request.path << ">.";
return boost::none;
}
return proxy;
}
return boost::none;
}
namespace {
class CacheErrorHandler
: public ErrorHandler
, public std::enable_shared_from_this<CacheErrorHandler>
{
public:
CacheErrorHandler(DeliveryCache &deliveryCache
, const fs::path &filePath
, Sink sink, const LocationConfig &location)
: deliveryCache_(deliveryCache), filePath_(filePath)
, sink_(sink), location_(location)
{}
private:
virtual void handle(const std::exception_ptr &exc);
DeliveryCache &deliveryCache_;
const fs::path filePath_;
Sink sink_;
const LocationConfig location_;
};
void CacheErrorHandler::handle(const std::exception_ptr &exc)
{
const auto parent(filePath_.parent_path());
const auto file(filePath_.filename());
try {
// rethrow current exception
std::rethrow_exception(exc);
} catch (const vs::NoSuchTileSet&) {
boost::system::error_code ec;
auto status(fs::status(filePath_, ec));
if (ec) {
// some error
if (!fs::exists(status)) {
LOG(err1) << "Path " << filePath_ << " doesn't exist.";
sink_.error(utility::makeError<NotFound>
("Path doesn't exist."));
return;
}
sink_.error(utility::makeError<InternalError>
("Cannot stat parent path."));
return;
}
// file exists
if (fs::is_directory(status)) {
if (file != ".") {
// directory redirect
sink_.redirect
(file.string() + "/", utility::HttpCode::Found);
return;
}
if (location_.enableListing) {
// directory and we have enabled browser -> directory
// listing
sink_.listing(parent);
return;
}
// listing not enabled -> forbidden
LOG(err1) << "Path " << filePath_ << " is unlistable.";
return sink_.error
(utility::makeError<Forbidden>("Unlistable"));
}
// not a directory, check if this is a file-based dataset
auto self(shared_from_this());
deliveryCache_.get
(filePath_.string()
, location_.enableDataset.value_or(Format::native)
, [self, this, file](const DeliveryCache::Expected &value)
mutable -> void
{
if (value) {
LOG(info1) << "Non-directory dataset.";
// non-directory dataset -> treat as a directory -> redirect
return sink_.redirect(file.string() + "/"
, utility::HttpCode::Found);
} else {
LOG(err1) << "No dataset found at " << filePath_ << ".";
return sink_.error
(utility::makeError<NotFound>("No such dataset"));
}
});
} catch (const ListContent &lc) {
if (location_.enableListing) {
// directory and we have enabled browser -> directory listing
sink_.listing(parent, lc.listingBootstrap);
return;
}
LOG(err1) << "Path " << filePath_ << " is unlistable.";
sink_.error
(utility::makeError<Forbidden>("Unbrowsable"));
} catch (const std::system_error &e) {
LOG(err1) << e.what();
if (e.code().category() == std::system_category()) {
switch (e.code().value()) {
case ENOENT: case ENOTDIR:
return sink_.error
(utility::makeError<NotFound>("No such file"));
}
}
} catch (const vs::NoSuchFile &e) {
LOG(err1) << e.what();
sink_.error
(utility::makeError<NotFound>("No such file"));
} catch (std::domain_error &e) {
LOG(err1) << e.what();
sink_.error
(utility::makeError<NotFound>("Domain error"));
} catch (const std::invalid_argument&) {
// pass error
sink_.error();
} catch (const utility::HttpError&) {
// pass error
sink_.error();
} catch (...) {
// pass everything else to sink
sink_.error();
}
}
} // namespace
void Vtsd::handleDataset(DeliveryCache &deliveryCache
, const fs::path &filePath
, const http::Request &request
, Sink sink, const LocationConfig &location)
{
deliveryCache.get
(filePath.parent_path().string()
, location.enableDataset.value_or(Format::native)
, [=, &deliveryCache](const DeliveryCache::Expected &value)
mutable -> void
{
auto errorHandler(std::make_shared<CacheErrorHandler>
(deliveryCache, filePath, sink, location));
// handle error or return pointer to value
if (auto driver = value.get(*errorHandler)) {
driver->handle
(sink
, Location(filePath.filename().string(), request.query
, getProxy(location, request))
, location
, errorHandler
);
}
});
}
int main(int argc, char *argv[])
{
return Vtsd()(argc, argv);
}
|
Require Import Arith List Bool.
(* EXAMPLES *)
(* The following function takes two arguments a and b
which are numbers of type nat and returns b + 2 * (a + b) *)
Definition f_ex (a b : nat) := b + 2 * (a + b).
(* When p is a pair, you can access its components by the "pattern-matching"
construct illustrated in the following function. *)
Definition add_pair_components (p : nat * nat) :=
match p with (a, b) => a + b end.
(* f_ex is a function with two arguments. add_pair_components is a
function with one argument, which is a pair. *)
(* END OF EXAMPLES *)
(* 1/ Define a function that takes two numbers as arguments and returns
the sum of the squares of these numbers. *)
Definition f1_1 (x y : nat) : nat := x * x + y * y.
(* 2/ Define a function that takes 5 arguments a b c d e, which are all
numbers and returns the sum of all these numbers. *)
Definition f1_2 (a b c d e : nat) := a + b + c + d + e.
(* 3/ Define a function named add5 that takes a number as argument and returns
this number plus 5. *)
Definition add5 (x : nat) := x + 5.
(* The following should return 8 *)
Compute add5 3.
(* The following commands make it possible to find pre-defined functions *)
(* 4/ Write a function swap of type list nat -> list nat such that
swap (a::b::l) = (b::a::l) and
swap l' = l' if l' has less than 2 elements. *)
Definition swap (l : list nat) : list nat :=
match l with
a::b::l => b::a::l
| _ => l
end.
(* 5/ Write a function proc2 of type list nat -> nat, such that
proc2 (a::b::l) = (b + 3) and
proc2 l' = 0 if l' has less than 2 elements.
In other words, proc2 only processes the 2nd argument of the list and
returns that number plus 3. If there is no second argument to the list,
proc2 returns 0. *)
Definition proc2 (l : list nat) : nat :=
match l with
a::b::l => b + 3
| _ => 0
end.
(* 6/ Write a function ms of type list nat -> list nat such that
ms (a::b::...::nil) = a+2::b+2::...::nil
For instance
ms (2::3::5::nil) = (4::5::7::nil) *)
Fixpoint ms (l : list nat) : list nat :=
match l with
a::l' => a + 2 :: ms l'
| nil => nil
end.
(* 7/ Write a function sorted of type list nat -> bool, such that
sorted l = true exactly when the natural numbers in
l are in increasing order. *)
Locate leb.
Fixpoint sorted (l : list nat) : bool :=
match l with
a::l' =>
match l' with b::_ =>
if Nat.leb a b then sorted l' else false | _ => true end
| nil => true
end.
(* 8/ Write a function p2 of type nat -> nat such that
p2 n = 2 ^ n *)
Fixpoint p2 (n : nat) :=
match n with 0 => 1 | S p => 2 * p2 p end.
(* 9/ Write a function salt of type nat -> nat -> nat such that
salt x n = x ^ n - x^ (n-1) + x^(n-2) .... + 1 or -1, if x <> 0,
depending on the parity of n, thus
salt x 3 = x^3 - x^2 + x - 1
salt x 4 = x^4 - x^3 + x^2 - x + 1
salt 2 3 = 5
You may have to define auxiliary functions. *)
Fixpoint even n :=
match n with 0 => true | 1 => false | S (S p) => even p end.
Fixpoint salt (x n : nat) :=
match n with
0 => 1
| S p => if even n then x * salt x p + 1 else x * salt x p - 1
end.
Fixpoint pow x n :=
match n with 0 => 1 | S p => x * pow x p end.
|
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *)
(* Distributed under the terms of CeCILL-B. *)
From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq div.
From mathcomp Require Import choice fintype bigop finset fingroup morphism.
From mathcomp Require Import quotient action.
(******************************************************************************)
(* Partial, semidirect, central, and direct products. *)
(* ++ Internal products, with A, B : {set gT}, are partial operations : *)
(* partial_product A B == A * B if A is a group normalised by the group B, *)
(* and the empty set otherwise. *)
(* A ><| B == A * B if this is a semi-direct product (i.e., if A *)
(* is normalised by B and intersects it trivially). *)
(* A \* B == A * B if this is a central product ([A, B] = 1). *)
(* A \x B == A * B if this is a direct product. *)
(* [complements to K in G] == set of groups H s.t. K * H = G and K :&: H = 1. *)
(* [splits G, over K] == [complements to K in G] is not empty. *)
(* remgr A B x == the right remainder in B of x mod A, i.e., *)
(* some element of (A :* x) :&: B. *)
(* divgr A B x == the "division" in B of x by A: for all x, *)
(* x = divgr A B x * remgr A B x. *)
(* ++ External products : *)
(* pairg1, pair1g == the isomorphisms aT1 -> aT1 * aT2, aT2 -> aT1 * aT2. *)
(* (aT1 * aT2 has a direct product group structure.) *)
(* sdprod_by to == the semidirect product defined by to : groupAction H K. *)
(* This is a finGroupType; the actual semidirect product is *)
(* the total set [set: sdprod_by to] on that type. *)
(* sdpair[12] to == the isomorphisms injecting K and H into *)
(* sdprod_by to = sdpair1 to @* K ><| sdpair2 to @* H. *)
(* External central products (with identified centers) will be defined later *)
(* in file center.v. *)
(* ++ Morphisms on product groups: *)
(* pprodm nAB fJ fAB == the morphism extending fA and fB on A <*> B when *)
(* nAB : B \subset 'N(A), *)
(* fJ : {in A & B, morph_act 'J 'J fA fB}, and *)
(* fAB : {in A :&: B, fA =1 fB}. *)
(* sdprodm defG fJ == the morphism extending fA and fB on G, given *)
(* defG : A ><| B = G and *)
(* fJ : {in A & B, morph_act 'J 'J fA fB}. *)
(* xsdprodm fHKact == the total morphism on sdprod_by to induced by *)
(* fH : {morphism H >-> rT}, fK : {morphism K >-> rT}, *)
(* with to : groupAction K H, *)
(* given fHKact : morph_act to 'J fH fK. *)
(* cprodm defG cAB fAB == the morphism extending fA and fB on G, when *)
(* defG : A \* B = G, *)
(* cAB : fB @* B \subset 'C(fB @* A), *)
(* and fAB : {in A :&: B, fA =1 fB}. *)
(* dprodm defG cAB == the morphism extending fA and fB on G, when *)
(* defG : A \x B = G and *)
(* cAB : fA @* B \subset 'C(fA @* A) *)
(* mulgm (x, y) == x * y; mulgm is an isomorphism from setX A B to G *)
(* iff A \x B = G . *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import GroupScope.
Section Defs.
Variables gT : finGroupType.
Implicit Types A B C : {set gT}.
Definition partial_product A B :=
if A == 1 then B else if B == 1 then A else
if [&& group_set A, group_set B & B \subset 'N(A)] then A * B else set0.
Definition semidirect_product A B :=
if A :&: B \subset 1%G then partial_product A B else set0.
Definition central_product A B :=
if B \subset 'C(A) then partial_product A B else set0.
Definition direct_product A B :=
if A :&: B \subset 1%G then central_product A B else set0.
Definition complements_to_in A B :=
[set K : {group gT} | A :&: K == 1 & A * K == B].
Definition splits_over B A := complements_to_in A B != set0.
(* Product remainder functions -- right variant only. *)
Definition remgr A B x := repr (A :* x :&: B).
Definition divgr A B x := x * (remgr A B x)^-1.
End Defs.
Arguments partial_product _ _%g _%g : clear implicits.
Arguments semidirect_product _ _%g _%g : clear implicits.
Arguments central_product _ _%g _%g : clear implicits.
Arguments complements_to_in _ _%g _%g.
Arguments splits_over _ _%g _%g.
Arguments remgr _ _%g _%g _%g.
Arguments divgr _ _%g _%g _%g.
Arguments direct_product : clear implicits.
Notation pprod := (partial_product _).
Notation sdprod := (semidirect_product _).
Notation cprod := (central_product _).
Notation dprod := (direct_product _).
Notation "G ><| H" := (sdprod G H)%g
(at level 40, left associativity) : group_scope.
Notation "G \* H" := (cprod G H)%g
(at level 40, left associativity) : group_scope.
Notation "G \x H" := (dprod G H)%g
(at level 40, left associativity) : group_scope.
Notation "[ 'complements' 'to' A 'in' B ]" := (complements_to_in A B)
(at level 0, format "[ 'complements' 'to' A 'in' B ]") : group_scope.
Notation "[ 'splits' B , 'over' A ]" := (splits_over B A)
(at level 0, format "[ 'splits' B , 'over' A ]") : group_scope.
(* Prenex Implicits remgl divgl. *)
Prenex Implicits remgr divgr.
Section InternalProd.
Variable gT : finGroupType.
Implicit Types A B C : {set gT}.
Implicit Types G H K L M : {group gT}.
Local Notation pprod := (partial_product gT).
Local Notation sdprod := (semidirect_product gT) (only parsing).
Local Notation cprod := (central_product gT) (only parsing).
Local Notation dprod := (direct_product gT) (only parsing).
Lemma pprod1g : left_id 1 pprod.
Proof. by move=> A; rewrite /pprod eqxx. Qed.
Lemma pprodg1 : right_id 1 pprod.
Proof. by move=> A; rewrite /pprod eqxx; case: eqP. Qed.
Variant are_groups A B : Prop := AreGroups K H of A = K & B = H.
Lemma group_not0 G : set0 <> G.
Proof. by move/setP/(_ 1); rewrite inE group1. Qed.
Lemma mulg0 : right_zero (@set0 gT) mulg.
Proof.
by move=> A; apply/setP=> x; rewrite inE; apply/imset2P=> [[y z]]; rewrite inE.
Qed.
Lemma mul0g : left_zero (@set0 gT) mulg.
Proof.
by move=> A; apply/setP=> x; rewrite inE; apply/imset2P=> [[y z]]; rewrite inE.
Qed.
Lemma pprodP A B G :
pprod A B = G -> [/\ are_groups A B, A * B = G & B \subset 'N(A)].
Proof.
have Gnot0 := @group_not0 G; rewrite /pprod; do 2?case: eqP => [-> ->| _].
- by rewrite mul1g norms1; split; first exists 1%G G.
- by rewrite mulg1 sub1G; split; first exists G 1%G.
by case: and3P => // [[gA gB ->]]; split; first exists (Group gA) (Group gB).
Qed.
Lemma pprodE K H : H \subset 'N(K) -> pprod K H = K * H.
Proof.
move=> nKH; rewrite /pprod nKH !groupP /=.
by do 2?case: eqP => [-> | _]; rewrite ?mulg1 ?mul1g.
Qed.
Lemma pprodEY K H : H \subset 'N(K) -> pprod K H = K <*> H.
Proof. by move=> nKH; rewrite pprodE ?norm_joinEr. Qed.
Lemma pprodW A B G : pprod A B = G -> A * B = G. Proof. by case/pprodP. Qed.
Lemma pprodWC A B G : pprod A B = G -> B * A = G.
Proof. by case/pprodP=> _ <- /normC. Qed.
Lemma pprodWY A B G : pprod A B = G -> A <*> B = G.
Proof. by case/pprodP=> [[K H -> ->] <- /norm_joinEr]. Qed.
Lemma pprodJ A B x : pprod A B :^ x = pprod (A :^ x) (B :^ x).
Proof.
rewrite /pprod !conjsg_eq1 !group_setJ normJ conjSg -conjsMg.
by do 3?case: ifP => // _; apply: conj0g.
Qed.
(* Properties of the remainders *)
Lemma remgrMl K B x y : y \in K -> remgr K B (y * x) = remgr K B x.
Proof. by move=> Ky; rewrite {1}/remgr rcosetM rcoset_id. Qed.
Lemma remgrP K B x : (remgr K B x \in K :* x :&: B) = (x \in K * B).
Proof.
set y := _ x; apply/idP/mulsgP=> [|[g b Kg Bb x_gb]].
rewrite inE rcoset_sym mem_rcoset => /andP[Kxy' By].
by exists (x * y^-1) y; rewrite ?mulgKV.
by apply: (mem_repr b); rewrite inE rcoset_sym mem_rcoset x_gb mulgK Kg.
Qed.
Lemma remgr1 K H x : x \in K -> remgr K H x = 1.
Proof. by move=> Kx; rewrite /remgr rcoset_id ?repr_group. Qed.
Lemma divgr_eq A B x : x = divgr A B x * remgr A B x.
Proof. by rewrite mulgKV. Qed.
Lemma divgrMl K B x y : x \in K -> divgr K B (x * y) = x * divgr K B y.
Proof. by move=> Hx; rewrite /divgr remgrMl ?mulgA. Qed.
Lemma divgr_id K H x : x \in K -> divgr K H x = x.
Proof. by move=> Kx; rewrite /divgr remgr1 // invg1 mulg1. Qed.
Lemma mem_remgr K B x : x \in K * B -> remgr K B x \in B.
Proof. by rewrite -remgrP => /setIP[]. Qed.
Lemma mem_divgr K B x : x \in K * B -> divgr K B x \in K.
Proof. by rewrite -remgrP inE rcoset_sym mem_rcoset => /andP[]. Qed.
Section DisjointRem.
Variables K H : {group gT}.
Hypothesis tiKH : K :&: H = 1.
Lemma remgr_id x : x \in H -> remgr K H x = x.
Proof.
move=> Hx; apply/eqP; rewrite eq_mulgV1 (sameP eqP set1gP) -tiKH inE.
rewrite -mem_rcoset groupMr ?groupV // -in_setI remgrP.
by apply: subsetP Hx; apply: mulG_subr.
Qed.
Lemma remgrMid x y : x \in K -> y \in H -> remgr K H (x * y) = y.
Proof. by move=> Kx Hy; rewrite remgrMl ?remgr_id. Qed.
Lemma divgrMid x y : x \in K -> y \in H -> divgr K H (x * y) = x.
Proof. by move=> Kx Hy; rewrite /divgr remgrMid ?mulgK. Qed.
End DisjointRem.
(* Intersection of a centraliser with a disjoint product. *)
Lemma subcent_TImulg K H A :
K :&: H = 1 -> A \subset 'N(K) :&: 'N(H) -> 'C_K(A) * 'C_H(A) = 'C_(K * H)(A).
Proof.
move=> tiKH /subsetIP[nKA nHA]; apply/eqP.
rewrite group_modl ?subsetIr // eqEsubset setSI ?mulSg ?subsetIl //=.
apply/subsetP=> _ /setIP[/mulsgP[x y Kx Hy ->] cAxy].
rewrite inE cAxy mem_mulg // inE Kx /=.
apply/centP=> z Az; apply/commgP/conjg_fixP.
move/commgP/conjg_fixP/(congr1 (divgr K H)): (centP cAxy z Az).
by rewrite conjMg !divgrMid ?memJ_norm // (subsetP nKA, subsetP nHA).
Qed.
(* Complements, and splitting. *)
Lemma complP H A B :
reflect (A :&: H = 1 /\ A * H = B) (H \in [complements to A in B]).
Proof. by apply: (iffP setIdP); case; split; apply/eqP. Qed.
Lemma splitsP B A :
reflect (exists H, H \in [complements to A in B]) [splits B, over A].
Proof. exact: set0Pn. Qed.
Lemma complgC H K G :
(H \in [complements to K in G]) = (K \in [complements to H in G]).
Proof.
rewrite !inE setIC; congr (_ && _).
by apply/eqP/eqP=> defG; rewrite -(comm_group_setP _) // defG groupP.
Qed.
Section NormalComplement.
Variables K H G : {group gT}.
Hypothesis complH_K : H \in [complements to K in G].
Lemma remgrM : K <| G -> {in G &, {morph remgr K H : x y / x * y}}.
Proof.
case/normalP=> _; case/complP: complH_K => tiKH <- nK_KH x y KHx KHy.
rewrite {1}(divgr_eq K H y) mulgA (conjgCV x) {2}(divgr_eq K H x) -2!mulgA.
rewrite mulgA remgrMid //; last by rewrite groupMl mem_remgr.
by rewrite groupMl !(=^~ mem_conjg, nK_KH, mem_divgr).
Qed.
Lemma divgrM : H \subset 'C(K) -> {in G &, {morph divgr K H : x y / x * y}}.
Proof.
move=> cKH; have /complP[_ defG] := complH_K.
have nsKG: K <| G by rewrite -defG -cent_joinEr // normalYl cents_norm.
move=> x y Gx Gy; rewrite {1}/divgr remgrM // invMg -!mulgA (mulgA y).
by congr (_ * _); rewrite -(centsP cKH) ?groupV ?(mem_remgr, mem_divgr, defG).
Qed.
End NormalComplement.
(* Semi-direct product *)
Lemma sdprod1g : left_id 1 sdprod.
Proof. by move=> A; rewrite /sdprod subsetIl pprod1g. Qed.
Lemma sdprodg1 : right_id 1 sdprod.
Proof. by move=> A; rewrite /sdprod subsetIr pprodg1. Qed.
Lemma sdprodP A B G :
A ><| B = G -> [/\ are_groups A B, A * B = G, B \subset 'N(A) & A :&: B = 1].
Proof.
rewrite /sdprod; case: ifP => [trAB | _ /group_not0[] //].
case/pprodP=> gAB defG nBA; split=> {defG nBA}//.
by case: gAB trAB => H K -> -> /trivgP.
Qed.
Lemma sdprodE K H : H \subset 'N(K) -> K :&: H = 1 -> K ><| H = K * H.
Proof. by move=> nKH tiKH; rewrite /sdprod tiKH subxx pprodE. Qed.
Lemma sdprodEY K H : H \subset 'N(K) -> K :&: H = 1 -> K ><| H = K <*> H.
Proof. by move=> nKH tiKH; rewrite sdprodE ?norm_joinEr. Qed.
Lemma sdprodWpp A B G : A ><| B = G -> pprod A B = G.
Proof. by case/sdprodP=> [[K H -> ->] <- /pprodE]. Qed.
Lemma sdprodW A B G : A ><| B = G -> A * B = G.
Proof. by move/sdprodWpp/pprodW. Qed.
Lemma sdprodWC A B G : A ><| B = G -> B * A = G.
Proof. by move/sdprodWpp/pprodWC. Qed.
Lemma sdprodWY A B G : A ><| B = G -> A <*> B = G.
Proof. by move/sdprodWpp/pprodWY. Qed.
Lemma sdprodJ A B x : (A ><| B) :^ x = A :^ x ><| B :^ x.
Proof.
rewrite /sdprod -conjIg sub_conjg conjs1g -pprodJ.
by case: ifP => _ //; apply: imset0.
Qed.
Lemma sdprod_context G K H : K ><| H = G ->
[/\ K <| G, H \subset G, K * H = G, H \subset 'N(K) & K :&: H = 1].
Proof.
case/sdprodP=> _ <- nKH tiKH.
by rewrite /normal mulG_subl mulG_subr mulG_subG normG.
Qed.
Lemma sdprod_compl G K H : K ><| H = G -> H \in [complements to K in G].
Proof. by case/sdprodP=> _ mulKH _ tiKH; apply/complP. Qed.
Lemma sdprod_normal_complP G K H :
K <| G -> reflect (K ><| H = G) (K \in [complements to H in G]).
Proof.
case/andP=> _ nKG; rewrite complgC.
apply: (iffP idP); [case/complP=> tiKH mulKH | exact: sdprod_compl].
by rewrite sdprodE ?(subset_trans _ nKG) // -mulKH mulG_subr.
Qed.
Lemma sdprod_card G A B : A ><| B = G -> (#|A| * #|B|)%N = #|G|.
Proof. by case/sdprodP=> [[H K -> ->] <- _ /TI_cardMg]. Qed.
Lemma sdprod_isom G A B :
A ><| B = G ->
{nAB : B \subset 'N(A) | isom B (G / A) (restrm nAB (coset A))}.
Proof.
case/sdprodP=> [[K H -> ->] <- nKH tiKH].
by exists nKH; rewrite quotientMidl quotient_isom.
Qed.
Lemma sdprod_isog G A B : A ><| B = G -> B \isog G / A.
Proof. by case/sdprod_isom=> nAB; apply: isom_isog. Qed.
Lemma sdprod_subr G A B M : A ><| B = G -> M \subset B -> A ><| M = A <*> M.
Proof.
case/sdprodP=> [[K H -> ->] _ nKH tiKH] sMH.
by rewrite sdprodEY ?(subset_trans sMH) //; apply/trivgP; rewrite -tiKH setIS.
Qed.
Lemma index_sdprod G A B : A ><| B = G -> #|B| = #|G : A|.
Proof.
case/sdprodP=> [[K H -> ->] <- _ tiHK].
by rewrite indexMg -indexgI setIC tiHK indexg1.
Qed.
Lemma index_sdprodr G A B M :
A ><| B = G -> M \subset B -> #|B : M| = #|G : A <*> M|.
Proof.
move=> defG; case/sdprodP: defG (defG) => [[K H -> ->] mulKH nKH _] defG sMH.
rewrite -!divgS //=; last by rewrite -genM_join gen_subG -mulKH mulgS.
by rewrite -(sdprod_card defG) -(sdprod_card (sdprod_subr defG sMH)) divnMl.
Qed.
Lemma quotient_sdprodr_isom G A B M :
A ><| B = G -> M <| B ->
{f : {morphism B / M >-> coset_of (A <*> M)} |
isom (B / M) (G / (A <*> M)) f
& forall L, L \subset B -> f @* (L / M) = A <*> L / (A <*> M)}.
Proof.
move=> defG nsMH; have [defA defB]: A = <<A>>%G /\ B = <<B>>%G.
by have [[K1 H1 -> ->] _ _ _] := sdprodP defG; rewrite /= !genGid.
do [rewrite {}defA {}defB; move: {A}<<A>>%G {B}<<B>>%G => K H] in defG nsMH *.
have [[nKH /isomP[injKH imKH]] sMH] := (sdprod_isom defG, normal_sub nsMH).
have [[nsKG sHG mulKH _ _] nKM] := (sdprod_context defG, subset_trans sMH nKH).
have nsKMG: K <*> M <| G.
by rewrite -quotientYK // -mulKH -quotientK ?cosetpre_normal ?quotient_normal.
have [/= f inj_f im_f] := third_isom (joing_subl K M) nsKG nsKMG.
rewrite quotientYidl //= -imKH -(restrm_quotientE nKH sMH) in f inj_f im_f.
have /domP[h [_ ker_h _ im_h]]: 'dom (f \o quotm _ nsMH) = H / M.
by rewrite ['dom _]morphpre_quotm injmK.
have{} im_h L: L \subset H -> h @* (L / M) = K <*> L / (K <*> M).
move=> sLH; have [sLG sKKM] := (subset_trans sLH sHG, joing_subl K M).
rewrite im_h morphim_comp morphim_quotm [_ @* L]restrm_quotientE ?im_f //.
rewrite quotientY ?(normsG sKKM) ?(subset_trans sLG) ?normal_norm //.
by rewrite (quotientS1 sKKM) joing1G.
exists h => //; apply/isomP; split; last by rewrite im_h //= (sdprodWY defG).
by rewrite ker_h injm_comp ?injm_quotm.
Qed.
Lemma quotient_sdprodr_isog G A B M :
A ><| B = G -> M <| B -> B / M \isog G / (A <*> M).
Proof.
move=> defG; case/sdprodP: defG (defG) => [[K H -> ->] _ _ _] => defG nsMH.
by have [h /isom_isog->] := quotient_sdprodr_isom defG nsMH.
Qed.
Lemma sdprod_modl A B G H :
A ><| B = G -> A \subset H -> A ><| (B :&: H) = G :&: H.
Proof.
case/sdprodP=> {A B} [[A B -> ->]] <- nAB tiAB sAH.
rewrite -group_modl ?sdprodE ?subIset ?nAB //.
by rewrite setIA tiAB (setIidPl _) ?sub1G.
Qed.
Lemma sdprod_modr A B G H :
A ><| B = G -> B \subset H -> (H :&: A) ><| B = H :&: G.
Proof.
case/sdprodP=> {A B}[[A B -> ->]] <- nAB tiAB sAH.
rewrite -group_modr ?sdprodE ?normsI // ?normsG //.
by rewrite -setIA tiAB (setIidPr _) ?sub1G.
Qed.
Lemma subcent_sdprod B C G A :
B ><| C = G -> A \subset 'N(B) :&: 'N(C) -> 'C_B(A) ><| 'C_C(A) = 'C_G(A).
Proof.
case/sdprodP=> [[H K -> ->] <- nHK tiHK] nHKA {B C G}.
rewrite sdprodE ?subcent_TImulg ?normsIG //.
by rewrite -setIIl tiHK (setIidPl (sub1G _)).
Qed.
Lemma sdprod_recl n G K H K1 :
#|G| <= n -> K ><| H = G -> K1 \proper K -> H \subset 'N(K1) ->
exists G1 : {group gT}, [/\ #|G1| < n, G1 \subset G & K1 ><| H = G1].
Proof.
move=> leGn; case/sdprodP=> _ defG nKH tiKH ltK1K nK1H.
have tiK1H: K1 :&: H = 1 by apply/trivgP; rewrite -tiKH setSI ?proper_sub.
exists (K1 <*> H)%G; rewrite /= -defG sdprodE // norm_joinEr //.
rewrite ?mulSg ?proper_sub ?(leq_trans _ leGn) //=.
by rewrite -defG ?TI_cardMg // ltn_pmul2r ?proper_card.
Qed.
Lemma sdprod_recr n G K H H1 :
#|G| <= n -> K ><| H = G -> H1 \proper H ->
exists G1 : {group gT}, [/\ #|G1| < n, G1 \subset G & K ><| H1 = G1].
Proof.
move=> leGn; case/sdprodP=> _ defG nKH tiKH ltH1H.
have [sH1H _] := andP ltH1H; have nKH1 := subset_trans sH1H nKH.
have tiKH1: K :&: H1 = 1 by apply/trivgP; rewrite -tiKH setIS.
exists (K <*> H1)%G; rewrite /= -defG sdprodE // norm_joinEr //.
rewrite ?mulgS // ?(leq_trans _ leGn) //=.
by rewrite -defG ?TI_cardMg // ltn_pmul2l ?proper_card.
Qed.
Lemma mem_sdprod G A B x : A ><| B = G -> x \in G ->
exists y, exists z,
[/\ y \in A, z \in B, x = y * z &
{in A & B, forall u t, x = u * t -> u = y /\ t = z}].
Proof.
case/sdprodP=> [[K H -> ->{A B}] <- _ tiKH] /mulsgP[y z Ky Hz ->{x}].
exists y; exists z; split=> // u t Ku Ht eqyzut.
move: (congr1 (divgr K H) eqyzut) (congr1 (remgr K H) eqyzut).
by rewrite !remgrMid // !divgrMid.
Qed.
(* Central product *)
Lemma cprod1g : left_id 1 cprod.
Proof. by move=> A; rewrite /cprod cents1 pprod1g. Qed.
Lemma cprodg1 : right_id 1 cprod.
Proof. by move=> A; rewrite /cprod sub1G pprodg1. Qed.
Lemma cprodP A B G :
A \* B = G -> [/\ are_groups A B, A * B = G & B \subset 'C(A)].
Proof. by rewrite /cprod; case: ifP => [cAB /pprodP[] | _ /group_not0[]]. Qed.
Lemma cprodE G H : H \subset 'C(G) -> G \* H = G * H.
Proof. by move=> cGH; rewrite /cprod cGH pprodE ?cents_norm. Qed.
Lemma cprodEY G H : H \subset 'C(G) -> G \* H = G <*> H.
Proof. by move=> cGH; rewrite cprodE ?cent_joinEr. Qed.
Lemma cprodWpp A B G : A \* B = G -> pprod A B = G.
Proof. by case/cprodP=> [[K H -> ->] <- /cents_norm/pprodE]. Qed.
Lemma cprodW A B G : A \* B = G -> A * B = G.
Proof. by move/cprodWpp/pprodW. Qed.
Lemma cprodWC A B G : A \* B = G -> B * A = G.
Proof. by move/cprodWpp/pprodWC. Qed.
Lemma cprodWY A B G : A \* B = G -> A <*> B = G.
Proof. by move/cprodWpp/pprodWY. Qed.
Lemma cprodJ A B x : (A \* B) :^ x = A :^ x \* B :^ x.
Proof.
by rewrite /cprod centJ conjSg -pprodJ; case: ifP => _ //; apply: imset0.
Qed.
Lemma cprod_normal2 A B G : A \* B = G -> A <| G /\ B <| G.
Proof.
case/cprodP=> [[K H -> ->] <- cKH]; rewrite -cent_joinEr //.
by rewrite normalYl normalYr !cents_norm // centsC.
Qed.
Lemma bigcprodW I (r : seq I) P F G :
\big[cprod/1]_(i <- r | P i) F i = G -> \prod_(i <- r | P i) F i = G.
Proof.
elim/big_rec2: _ G => // i A B _ IH G /cprodP[[_ H _ defB] <- _].
by rewrite (IH H) defB.
Qed.
Lemma bigcprodWY I (r : seq I) P F G :
\big[cprod/1]_(i <- r | P i) F i = G -> << \bigcup_(i <- r | P i) F i >> = G.
Proof.
elim/big_rec2: _ G => [|i A B _ IH G]; first by rewrite gen0.
case/cprodP => [[K H -> defB] <- cKH].
by rewrite -[<<_>>]joing_idr (IH H) ?cent_joinEr -?defB.
Qed.
Lemma triv_cprod A B : (A \* B == 1) = (A == 1) && (B == 1).
Proof.
case A1: (A == 1); first by rewrite (eqP A1) cprod1g.
apply/eqP=> /cprodP[[G H defA ->]] /eqP.
by rewrite defA trivMg -defA A1.
Qed.
Lemma cprod_ntriv A B : A != 1 -> B != 1 ->
A \* B =
if [&& group_set A, group_set B & B \subset 'C(A)] then A * B else set0.
Proof.
move=> A1 B1; rewrite /cprod; case: ifP => cAB; rewrite ?cAB ?andbF //=.
by rewrite /pprod -if_neg A1 -if_neg B1 cents_norm.
Qed.
Lemma trivg0 : (@set0 gT == 1) = false.
Proof. by rewrite eqEcard cards0 cards1 andbF. Qed.
Lemma group0 : group_set (@set0 gT) = false.
Proof. by rewrite /group_set inE. Qed.
Lemma cprod0g A : set0 \* A = set0.
Proof. by rewrite /cprod centsC sub0set /pprod group0 trivg0 !if_same. Qed.
Lemma cprodC : commutative cprod.
Proof.
rewrite /cprod => A B; case: ifP => cAB; rewrite centsC cAB // /pprod.
by rewrite andbCA normC !cents_norm // 1?centsC //; do 2!case: eqP => // ->.
Qed.
Lemma cprodA : associative cprod.
Proof.
move=> A B C; case A1: (A == 1); first by rewrite (eqP A1) !cprod1g.
case B1: (B == 1); first by rewrite (eqP B1) cprod1g cprodg1.
case C1: (C == 1); first by rewrite (eqP C1) !cprodg1.
rewrite !(triv_cprod, cprod_ntriv) ?{}A1 ?{}B1 ?{}C1 //.
case: isgroupP => [[G ->{A}] | _]; last by rewrite group0.
case: (isgroupP B) => [[H ->{B}] | _]; last by rewrite group0.
case: (isgroupP C) => [[K ->{C}] | _]; last by rewrite group0 !andbF.
case cGH: (H \subset 'C(G)); case cHK: (K \subset 'C(H)); last first.
- by rewrite group0.
- by rewrite group0 /= mulG_subG cGH andbF.
- by rewrite group0 /= centM subsetI cHK !andbF.
rewrite /= mulgA mulG_subG centM subsetI cGH cHK andbT -(cent_joinEr cHK).
by rewrite -(cent_joinEr cGH) !groupP.
Qed.
Canonical cprod_law := Monoid.Law cprodA cprod1g cprodg1.
Canonical cprod_abelaw := Monoid.ComLaw cprodC.
Lemma cprod_modl A B G H :
A \* B = G -> A \subset H -> A \* (B :&: H) = G :&: H.
Proof.
case/cprodP=> [[U V -> -> {A B}]] defG cUV sUH.
by rewrite cprodE; [rewrite group_modl ?defG | rewrite subIset ?cUV].
Qed.
Lemma cprod_modr A B G H :
A \* B = G -> B \subset H -> (H :&: A) \* B = H :&: G.
Proof. by rewrite -!(cprodC B) !(setIC H); apply: cprod_modl. Qed.
Lemma bigcprodYP (I : finType) (P : pred I) (H : I -> {group gT}) :
reflect (forall i j, P i -> P j -> i != j -> H i \subset 'C(H j))
(\big[cprod/1]_(i | P i) H i == (\prod_(i | P i) H i)%G).
Proof.
apply: (iffP eqP) => [defG i j Pi Pj neq_ij | cHH].
rewrite (bigD1 j) // (bigD1 i) /= ?cprodA in defG; last exact/andP.
by case/cprodP: defG => [[K _ /cprodP[//]]].
set Q := P; have sQP: subpred Q P by []; have [n leQn] := ubnP #|Q|.
elim: n => // n IHn in (Q) leQn sQP *.
have [i Qi | Q0] := pickP Q; last by rewrite !big_pred0.
rewrite (cardD1x Qi) add1n ltnS !(bigD1 i Qi) /= in leQn *.
rewrite {}IHn {n leQn}// => [|j /andP[/sQP //]].
rewrite bigprodGE cprodEY // gen_subG; apply/bigcupsP=> j /andP[neq_ji Qj].
by rewrite cHH ?sQP.
Qed.
Lemma bigcprodEY I r (P : pred I) (H : I -> {group gT}) G :
abelian G -> (forall i, P i -> H i \subset G) ->
\big[cprod/1]_(i <- r | P i) H i = (\prod_(i <- r | P i) H i)%G.
Proof.
move=> cGG sHG; apply/eqP; rewrite !(big_tnth _ _ r).
by apply/bigcprodYP=> i j Pi Pj _; rewrite (sub_abelian_cent2 cGG) ?sHG.
Qed.
Lemma perm_bigcprod (I : eqType) r1 r2 (A : I -> {set gT}) G x :
\big[cprod/1]_(i <- r1) A i = G -> {in r1, forall i, x i \in A i} ->
perm_eq r1 r2 ->
\prod_(i <- r1) x i = \prod_(i <- r2) x i.
Proof.
elim: r1 r2 G => [|i r1 IHr] r2 G defG Ax eq_r12.
by rewrite perm_sym in eq_r12; rewrite (perm_small_eq _ eq_r12) ?big_nil.
have /rot_to[n r3 Dr2]: i \in r2 by rewrite -(perm_mem eq_r12) mem_head.
transitivity (\prod_(j <- rot n r2) x j).
rewrite Dr2 !big_cons in defG Ax *; have [[_ G1 _ defG1] _ _] := cprodP defG.
rewrite (IHr r3 G1) //; first by case/allP/andP: Ax => _ /allP.
by rewrite -(perm_cons i) -Dr2 perm_sym perm_rot perm_sym.
rewrite -(cat_take_drop n r2) [in LHS]cat_take_drop in eq_r12 *.
rewrite (perm_big _ eq_r12) !big_cat /= !(big_nth i) !big_mkord in defG *.
have /cprodP[[G1 G2 defG1 defG2] _ /centsP-> //] := defG.
rewrite defG2 -(bigcprodW defG2) mem_prodg // => k _; apply: Ax.
by rewrite (perm_mem eq_r12) mem_cat orbC mem_nth.
rewrite defG1 -(bigcprodW defG1) mem_prodg // => k _; apply: Ax.
by rewrite (perm_mem eq_r12) mem_cat mem_nth.
Qed.
Lemma reindex_bigcprod (I J : finType) (h : J -> I) P (A : I -> {set gT}) G x :
{on SimplPred P, bijective h} -> \big[cprod/1]_(i | P i) A i = G ->
{in SimplPred P, forall i, x i \in A i} ->
\prod_(i | P i) x i = \prod_(j | P (h j)) x (h j).
Proof.
case=> h1 hK h1K defG Ax; have [e big_e [Ue mem_e] _] := big_enumP P.
rewrite -!big_e in defG *; rewrite -(big_map h P x) -[RHS]big_filter filter_map.
apply: perm_bigcprod defG _ _ => [i|]; first by rewrite mem_e => /Ax.
have [r _ [Ur /= mem_r] _] := big_enumP; apply: uniq_perm Ue _ _ => [|i].
by rewrite map_inj_in_uniq // => i j; rewrite !mem_r ; apply: (can_in_inj hK).
rewrite mem_e; apply/idP/mapP=> [Pi|[j r_j ->]]; last by rewrite -mem_r.
by exists (h1 i); rewrite ?mem_r h1K.
Qed.
(* Direct product *)
Lemma dprod1g : left_id 1 dprod.
Proof. by move=> A; rewrite /dprod subsetIl cprod1g. Qed.
Lemma dprodg1 : right_id 1 dprod.
Proof. by move=> A; rewrite /dprod subsetIr cprodg1. Qed.
Lemma dprodP A B G :
A \x B = G -> [/\ are_groups A B, A * B = G, B \subset 'C(A) & A :&: B = 1].
Proof.
rewrite /dprod; case: ifP => trAB; last by case/group_not0.
by case/cprodP=> gAB; split=> //; case: gAB trAB => ? ? -> -> /trivgP.
Qed.
Lemma dprodE G H : H \subset 'C(G) -> G :&: H = 1 -> G \x H = G * H.
Proof. by move=> cGH trGH; rewrite /dprod trGH sub1G cprodE. Qed.
Lemma dprodEY G H : H \subset 'C(G) -> G :&: H = 1 -> G \x H = G <*> H.
Proof. by move=> cGH trGH; rewrite /dprod trGH subxx cprodEY. Qed.
Lemma dprodEcp A B : A :&: B = 1 -> A \x B = A \* B.
Proof. by move=> trAB; rewrite /dprod trAB subxx. Qed.
Lemma dprodEsd A B : B \subset 'C(A) -> A \x B = A ><| B.
Proof. by rewrite /dprod /cprod => ->. Qed.
Lemma dprodWcp A B G : A \x B = G -> A \* B = G.
Proof. by move=> defG; have [_ _ _ /dprodEcp <-] := dprodP defG. Qed.
Lemma dprodWsd A B G : A \x B = G -> A ><| B = G.
Proof. by move=> defG; have [_ _ /dprodEsd <-] := dprodP defG. Qed.
Lemma dprodW A B G : A \x B = G -> A * B = G.
Proof. by move/dprodWsd/sdprodW. Qed.
Lemma dprodWC A B G : A \x B = G -> B * A = G.
Proof. by move/dprodWsd/sdprodWC. Qed.
Lemma dprodWY A B G : A \x B = G -> A <*> B = G.
Proof. by move/dprodWsd/sdprodWY. Qed.
Lemma cprod_card_dprod G A B :
A \* B = G -> #|A| * #|B| <= #|G| -> A \x B = G.
Proof. by case/cprodP=> [[K H -> ->] <- cKH] /cardMg_TI; apply: dprodE. Qed.
Lemma dprodJ A B x : (A \x B) :^ x = A :^ x \x B :^ x.
Proof.
rewrite /dprod -conjIg sub_conjg conjs1g -cprodJ.
by case: ifP => _ //; apply: imset0.
Qed.
Lemma dprod_normal2 A B G : A \x B = G -> A <| G /\ B <| G.
Proof. by move/dprodWcp/cprod_normal2. Qed.
Lemma dprodYP K H : reflect (K \x H = K <*> H) (H \subset 'C(K) :\: K^#).
Proof.
rewrite subsetD -setI_eq0 setIDA setD_eq0 setIC subG1 /=.
by apply: (iffP andP) => [[cKH /eqP/dprodEY->] | /dprodP[_ _ -> ->]].
Qed.
Lemma dprodC : commutative dprod.
Proof. by move=> A B; rewrite /dprod setIC cprodC. Qed.
Lemma dprodWsdC A B G : A \x B = G -> B ><| A = G.
Proof. by rewrite dprodC => /dprodWsd. Qed.
Lemma dprodA : associative dprod.
Proof.
move=> A B C; case A1: (A == 1); first by rewrite (eqP A1) !dprod1g.
case B1: (B == 1); first by rewrite (eqP B1) dprod1g dprodg1.
case C1: (C == 1); first by rewrite (eqP C1) !dprodg1.
rewrite /dprod (fun_if (cprod A)) (fun_if (cprod^~ C)) -cprodA.
rewrite -(cprodC set0) !cprod0g cprod_ntriv ?B1 ?{}C1 //.
case: and3P B1 => [[] | _ _]; last by rewrite cprodC cprod0g !if_same.
case/isgroupP=> H ->; case/isgroupP=> K -> {B C}; move/cent_joinEr=> eHK H1.
rewrite cprod_ntriv ?trivMg ?{}A1 ?{}H1 // mulG_subG.
case: and4P => [[] | _]; last by rewrite !if_same.
case/isgroupP=> G ->{A} _ cGH _; rewrite cprodEY // -eHK.
case trGH: (G :&: H \subset _); case trHK: (H :&: K \subset _); last first.
- by rewrite !if_same.
- rewrite if_same; case: ifP => // trG_HK; case/negP: trGH.
by apply: subset_trans trG_HK; rewrite setIS ?joing_subl.
- rewrite if_same; case: ifP => // trGH_K; case/negP: trHK.
by apply: subset_trans trGH_K; rewrite setSI ?joing_subr.
do 2![case: ifP] => // trGH_K trG_HK; [case/negP: trGH_K | case/negP: trG_HK].
apply: subset_trans trHK; rewrite subsetI subsetIr -{2}(mulg1 H) -mulGS.
rewrite setIC group_modl ?joing_subr //= cent_joinEr // -eHK.
by rewrite -group_modr ?joing_subl //= setIC -(normC (sub1G _)) mulSg.
apply: subset_trans trGH; rewrite subsetI subsetIl -{2}(mul1g H) -mulSG.
rewrite setIC group_modr ?joing_subl //= eHK -(cent_joinEr cGH).
by rewrite -group_modl ?joing_subr //= setIC (normC (sub1G _)) mulgS.
Qed.
Canonical dprod_law := Monoid.Law dprodA dprod1g dprodg1.
Canonical dprod_abelaw := Monoid.ComLaw dprodC.
Lemma bigdprodWcp I (r : seq I) P F G :
\big[dprod/1]_(i <- r | P i) F i = G -> \big[cprod/1]_(i <- r | P i) F i = G.
Proof.
elim/big_rec2: _ G => // i A B _ IH G /dprodP[[K H -> defB] <- cKH _].
by rewrite (IH H) // cprodE -defB.
Qed.
Lemma bigdprodW I (r : seq I) P F G :
\big[dprod/1]_(i <- r | P i) F i = G -> \prod_(i <- r | P i) F i = G.
Proof. by move/bigdprodWcp; apply: bigcprodW. Qed.
Lemma bigdprodWY I (r : seq I) P F G :
\big[dprod/1]_(i <- r | P i) F i = G -> << \bigcup_(i <- r | P i) F i >> = G.
Proof. by move/bigdprodWcp; apply: bigcprodWY. Qed.
Lemma bigdprodYP (I : finType) (P : pred I) (F : I -> {group gT}) :
reflect (forall i, P i ->
(\prod_(j | P j && (j != i)) F j)%G \subset 'C(F i) :\: (F i)^#)
(\big[dprod/1]_(i | P i) F i == (\prod_(i | P i) F i)%G).
Proof.
apply: (iffP eqP) => [defG i Pi | dxG].
rewrite !(bigD1 i Pi) /= in defG; have [[_ G' _ defG'] _ _ _] := dprodP defG.
by apply/dprodYP; rewrite -defG defG' bigprodGE (bigdprodWY defG').
set Q := P; have sQP: subpred Q P by []; have [n leQn] := ubnP #|Q|.
elim: n => // n IHn in (Q) leQn sQP *.
have [i Qi | Q0] := pickP Q; last by rewrite !big_pred0.
rewrite (cardD1x Qi) add1n ltnS !(bigD1 i Qi) /= in leQn *.
rewrite {}IHn {n leQn}// => [|j /andP[/sQP //]].
apply/dprodYP; apply: subset_trans (dxG i (sQP i Qi)); rewrite !bigprodGE.
by apply: genS; apply/bigcupsP=> j /andP[Qj ne_ji]; rewrite (bigcup_max j) ?sQP.
Qed.
Lemma dprod_modl A B G H :
A \x B = G -> A \subset H -> A \x (B :&: H) = G :&: H.
Proof.
case/dprodP=> [[U V -> -> {A B}]] defG cUV trUV sUH.
rewrite dprodEcp; first by apply: cprod_modl; rewrite ?cprodE.
by rewrite setIA trUV (setIidPl _) ?sub1G.
Qed.
Lemma dprod_modr A B G H :
A \x B = G -> B \subset H -> (H :&: A) \x B = H :&: G.
Proof. by rewrite -!(dprodC B) !(setIC H); apply: dprod_modl. Qed.
Lemma subcent_dprod B C G A :
B \x C = G -> A \subset 'N(B) :&: 'N(C) -> 'C_B(A) \x 'C_C(A) = 'C_G(A).
Proof.
move=> defG; have [_ _ cBC _] := dprodP defG; move: defG.
by rewrite !dprodEsd 1?(centSS _ _ cBC) ?subsetIl //; apply: subcent_sdprod.
Qed.
Lemma dprod_card A B G : A \x B = G -> (#|A| * #|B|)%N = #|G|.
Proof. by case/dprodP=> [[H K -> ->] <- _]; move/TI_cardMg. Qed.
Lemma bigdprod_card I r (P : pred I) E G :
\big[dprod/1]_(i <- r | P i) E i = G ->
(\prod_(i <- r | P i) #|E i|)%N = #|G|.
Proof.
elim/big_rec2: _ G => [G <- | i A B _ IH G defG]; first by rewrite cards1.
have [[_ H _ defH] _ _ _] := dprodP defG.
by rewrite -(dprod_card defG) (IH H) defH.
Qed.
Lemma bigcprod_card_dprod I r (P : pred I) (A : I -> {set gT}) G :
\big[cprod/1]_(i <- r | P i) A i = G ->
\prod_(i <- r | P i) #|A i| <= #|G| ->
\big[dprod/1]_(i <- r | P i) A i = G.
Proof.
elim: r G => [|i r IHr]; rewrite !(big_nil, big_cons) //; case: ifP => _ // G.
case/cprodP=> [[K H -> defH]]; rewrite defH => <- cKH leKH_G.
have /implyP := leq_trans leKH_G (dvdn_leq _ (dvdn_cardMg K H)).
rewrite muln_gt0 leq_pmul2l !cardG_gt0 //= => /(IHr H defH){}defH.
by rewrite defH dprodE // cardMg_TI // -(bigdprod_card defH).
Qed.
Lemma bigcprod_coprime_dprod (I : finType) (P : pred I) (A : I -> {set gT}) G :
\big[cprod/1]_(i | P i) A i = G ->
(forall i j, P i -> P j -> i != j -> coprime #|A i| #|A j|) ->
\big[dprod/1]_(i | P i) A i = G.
Proof.
move=> defG coA; set Q := P in defG *; have sQP: subpred Q P by [].
have [m leQm] := ubnP #|Q|; elim: m => // m IHm in (Q) leQm G defG sQP *.
have [i Qi | Q0] := pickP Q; last by rewrite !big_pred0 in defG *.
move: defG; rewrite !(bigD1 i Qi) /= => /cprodP[[Hi Gi defAi defGi] <-].
rewrite defAi defGi => cHGi.
have{} defGi: \big[dprod/1]_(j | Q j && (j != i)) A j = Gi.
by apply: IHm => [||j /andP[/sQP]] //; rewrite (cardD1x Qi) in leQm.
rewrite defGi dprodE // coprime_TIg // -defAi -(bigdprod_card defGi).
elim/big_rec: _ => [|j n /andP[neq_ji Qj] IHn]; first exact: coprimen1.
by rewrite coprimeMr coprime_sym coA ?sQP.
Qed.
Lemma mem_dprod G A B x : A \x B = G -> x \in G ->
exists y, exists z,
[/\ y \in A, z \in B, x = y * z &
{in A & B, forall u t, x = u * t -> u = y /\ t = z}].
Proof.
move=> defG; have [_ _ cBA _] := dprodP defG.
by apply: mem_sdprod; rewrite -dprodEsd.
Qed.
Lemma mem_bigdprod (I : finType) (P : pred I) F G x :
\big[dprod/1]_(i | P i) F i = G -> x \in G ->
exists c, [/\ forall i, P i -> c i \in F i, x = \prod_(i | P i) c i
& forall e, (forall i, P i -> e i \in F i) ->
x = \prod_(i | P i) e i ->
forall i, P i -> e i = c i].
Proof.
move=> defG; rewrite -(bigdprodW defG) => /prodsgP[c Fc ->].
have [r big_r [_ mem_r] _] := big_enumP P.
exists c; split=> // e Fe eq_ce i Pi; rewrite -!{}big_r in defG eq_ce.
have{Pi}: i \in r by rewrite mem_r.
have{mem_r}: all P r by apply/allP=> j; rewrite mem_r.
elim: r G defG eq_ce => // j r IHr G.
rewrite !big_cons inE /= => /dprodP[[K H defK defH] _ _].
rewrite defK defH => tiFjH eq_ce /andP[Pj Pr].
suffices{i IHr} eq_cej: c j = e j.
case/predU1P=> [-> //|]; apply: IHr defH _ Pr.
by apply: (mulgI (c j)); rewrite eq_ce eq_cej.
rewrite !(big_nth j) !big_mkord in defH eq_ce.
move/(congr1 (divgr K H)): eq_ce; move/bigdprodW: defH => defH.
move/(all_nthP j) in Pr.
by rewrite !divgrMid // -?defK -?defH ?mem_prodg // => *; rewrite ?Fc ?Fe ?Pr.
Qed.
End InternalProd.
Arguments complP {gT H A B}.
Arguments splitsP {gT B A}.
Arguments sdprod_normal_complP {gT G K H}.
Arguments dprodYP {gT K H}.
Arguments bigdprodYP {gT I P F}.
Section MorphimInternalProd.
Variables (gT rT : finGroupType) (D : {group gT}) (f : {morphism D >-> rT}).
Section OneProd.
Variables G H K : {group gT}.
Hypothesis sGD : G \subset D.
Lemma morphim_pprod : pprod K H = G -> pprod (f @* K) (f @* H) = f @* G.
Proof.
case/pprodP=> _ defG mKH; rewrite pprodE ?morphim_norms //.
by rewrite -morphimMl ?(subset_trans _ sGD) -?defG // mulG_subl.
Qed.
Lemma morphim_coprime_sdprod :
K ><| H = G -> coprime #|K| #|H| -> f @* K ><| f @* H = f @* G.
Proof.
rewrite /sdprod => defG coHK; move: defG.
by rewrite !coprime_TIg ?coprime_morph // !subxx; apply: morphim_pprod.
Qed.
Lemma injm_sdprod : 'injm f -> K ><| H = G -> f @* K ><| f @* H = f @* G.
Proof.
move=> inj_f; case/sdprodP=> _ defG nKH tiKH.
by rewrite /sdprod -injmI // tiKH morphim1 subxx morphim_pprod // pprodE.
Qed.
Lemma morphim_cprod : K \* H = G -> f @* K \* f @* H = f @* G.
Proof.
case/cprodP=> _ defG cKH; rewrite /cprod morphim_cents // morphim_pprod //.
by rewrite pprodE // cents_norm // centsC.
Qed.
Lemma injm_dprod : 'injm f -> K \x H = G -> f @* K \x f @* H = f @* G.
Proof.
move=> inj_f; case/dprodP=> _ defG cHK tiKH.
by rewrite /dprod -injmI // tiKH morphim1 subxx morphim_cprod // cprodE.
Qed.
Lemma morphim_coprime_dprod :
K \x H = G -> coprime #|K| #|H| -> f @* K \x f @* H = f @* G.
Proof.
rewrite /dprod => defG coHK; move: defG.
by rewrite !coprime_TIg ?coprime_morph // !subxx; apply: morphim_cprod.
Qed.
End OneProd.
Implicit Type G : {group gT}.
Lemma morphim_bigcprod I r (P : pred I) (H : I -> {group gT}) G :
G \subset D -> \big[cprod/1]_(i <- r | P i) H i = G ->
\big[cprod/1]_(i <- r | P i) f @* H i = f @* G.
Proof.
elim/big_rec2: _ G => [|i fB B Pi def_fB] G sGD defG.
by rewrite -defG morphim1.
case/cprodP: defG (defG) => [[Hi Gi -> defB] _ _]; rewrite defB => defG.
rewrite (def_fB Gi) //; first exact: morphim_cprod.
by apply: subset_trans sGD; case/cprod_normal2: defG => _ /andP[].
Qed.
Lemma injm_bigdprod I r (P : pred I) (H : I -> {group gT}) G :
G \subset D -> 'injm f -> \big[dprod/1]_(i <- r | P i) H i = G ->
\big[dprod/1]_(i <- r | P i) f @* H i = f @* G.
Proof.
move=> sGD injf; elim/big_rec2: _ G sGD => [|i fB B Pi def_fB] G sGD defG.
by rewrite -defG morphim1.
case/dprodP: defG (defG) => [[Hi Gi -> defB] _ _ _]; rewrite defB => defG.
rewrite (def_fB Gi) //; first exact: injm_dprod.
by apply: subset_trans sGD; case/dprod_normal2: defG => _ /andP[].
Qed.
Lemma morphim_coprime_bigdprod (I : finType) P (H : I -> {group gT}) G :
G \subset D -> \big[dprod/1]_(i | P i) H i = G ->
(forall i j, P i -> P j -> i != j -> coprime #|H i| #|H j|) ->
\big[dprod/1]_(i | P i) f @* H i = f @* G.
Proof.
move=> sGD /bigdprodWcp defG coH; have def_fG := morphim_bigcprod sGD defG.
by apply: bigcprod_coprime_dprod => // i j *; rewrite coprime_morph ?coH.
Qed.
End MorphimInternalProd.
Section QuotientInternalProd.
Variables (gT : finGroupType) (G K H M : {group gT}).
Hypothesis nMG: G \subset 'N(M).
Lemma quotient_pprod : pprod K H = G -> pprod (K / M) (H / M) = G / M.
Proof. exact: morphim_pprod. Qed.
Lemma quotient_coprime_sdprod :
K ><| H = G -> coprime #|K| #|H| -> (K / M) ><| (H / M) = G / M.
Proof. exact: morphim_coprime_sdprod. Qed.
Lemma quotient_cprod : K \* H = G -> (K / M) \* (H / M) = G / M.
Proof. exact: morphim_cprod. Qed.
Lemma quotient_coprime_dprod :
K \x H = G -> coprime #|K| #|H| -> (K / M) \x (H / M) = G / M.
Proof. exact: morphim_coprime_dprod. Qed.
End QuotientInternalProd.
Section ExternalDirProd.
Variables gT1 gT2 : finGroupType.
Definition extprod_mulg (x y : gT1 * gT2) := (x.1 * y.1, x.2 * y.2).
Definition extprod_invg (x : gT1 * gT2) := (x.1^-1, x.2^-1).
Lemma extprod_mul1g : left_id (1, 1) extprod_mulg.
Proof. by case=> x1 x2; congr (_, _); apply: mul1g. Qed.
Lemma extprod_mulVg : left_inverse (1, 1) extprod_invg extprod_mulg.
Proof. by move=> x; congr (_, _); apply: mulVg. Qed.
Lemma extprod_mulgA : associative extprod_mulg.
Proof. by move=> x y z; congr (_, _); apply: mulgA. Qed.
Definition extprod_groupMixin :=
Eval hnf in FinGroup.Mixin extprod_mulgA extprod_mul1g extprod_mulVg.
Canonical extprod_baseFinGroupType :=
Eval hnf in BaseFinGroupType (gT1 * gT2) extprod_groupMixin.
Canonical prod_group := FinGroupType extprod_mulVg.
Lemma group_setX (H1 : {group gT1}) (H2 : {group gT2}) : group_set (setX H1 H2).
Proof.
apply/group_setP; split; first by rewrite !inE !group1.
by case=> [x1 x2] [y1 y2] /[!inE] /andP[Hx1 Hx2] /andP[Hy1 Hy2] /[!groupM].
Qed.
Canonical setX_group H1 H2 := Group (group_setX H1 H2).
Definition pairg1 x : gT1 * gT2 := (x, 1).
Definition pair1g x : gT1 * gT2 := (1, x).
Lemma pairg1_morphM : {morph pairg1 : x y / x * y}.
Proof. by move=> x y /=; rewrite {2}/mulg /= /extprod_mulg /= mul1g. Qed.
Canonical pairg1_morphism := @Morphism _ _ setT _ (in2W pairg1_morphM).
Lemma pair1g_morphM : {morph pair1g : x y / x * y}.
Proof. by move=> x y /=; rewrite {2}/mulg /= /extprod_mulg /= mul1g. Qed.
Canonical pair1g_morphism := @Morphism _ _ setT _ (in2W pair1g_morphM).
Lemma fst_morphM : {morph (@fst gT1 gT2) : x y / x * y}.
Proof. by move=> x y. Qed.
Lemma snd_morphM : {morph (@snd gT1 gT2) : x y / x * y}.
Proof. by move=> x y. Qed.
Canonical fst_morphism := @Morphism _ _ setT _ (in2W fst_morphM).
Canonical snd_morphism := @Morphism _ _ setT _ (in2W snd_morphM).
Lemma injm_pair1g : 'injm pair1g.
Proof. by apply/subsetP=> x /morphpreP[_ /set1P[->]]; apply: set11. Qed.
Lemma injm_pairg1 : 'injm pairg1.
Proof. by apply/subsetP=> x /morphpreP[_ /set1P[->]]; apply: set11. Qed.
Lemma morphim_pairg1 (H1 : {set gT1}) : pairg1 @* H1 = setX H1 1.
Proof. by rewrite -imset2_pair imset2_set1r morphimEsub ?subsetT. Qed.
Lemma morphim_pair1g (H2 : {set gT2}) : pair1g @* H2 = setX 1 H2.
Proof. by rewrite -imset2_pair imset2_set1l morphimEsub ?subsetT. Qed.
Lemma morphim_fstX (H1: {set gT1}) (H2 : {group gT2}) :
[morphism of fun x => x.1] @* setX H1 H2 = H1.
Proof.
apply/eqP; rewrite eqEsubset morphimE setTI /=.
apply/andP; split; apply/subsetP=> x.
by case/imsetP=> x0 /[1!inE] /andP[Hx1 _] ->.
move=> Hx1; apply/imsetP; exists (x, 1); last by trivial.
by rewrite in_setX Hx1 /=.
Qed.
Lemma morphim_sndX (H1: {group gT1}) (H2 : {set gT2}) :
[morphism of fun x => x.2] @* setX H1 H2 = H2.
Proof.
apply/eqP; rewrite eqEsubset morphimE setTI /=.
apply/andP; split; apply/subsetP=> x.
by case/imsetP=> x0 /[1!inE] /andP[_ Hx2] ->.
move=> Hx2; apply/imsetP; exists (1, x); last by [].
by rewrite in_setX Hx2 andbT.
Qed.
Lemma setX_prod (H1 : {set gT1}) (H2 : {set gT2}) :
setX H1 1 * setX 1 H2 = setX H1 H2.
Proof.
apply/setP=> [[x y]]; rewrite !inE /=.
apply/imset2P/andP=> [[[x1 u1] [v1 y1]] | [Hx Hy]].
rewrite !inE /= => /andP[Hx1 /eqP->] /andP[/eqP-> Hx] [-> ->].
by rewrite mulg1 mul1g.
exists (x, 1 : gT2) (1 : gT1, y); rewrite ?inE ?Hx ?eqxx //.
by rewrite /mulg /= /extprod_mulg /= mulg1 mul1g.
Qed.
Lemma setX_dprod (H1 : {group gT1}) (H2 : {group gT2}) :
setX H1 1 \x setX 1 H2 = setX H1 H2.
Proof.
rewrite dprodE ?setX_prod //.
apply/centsP=> [[x u]] /[!inE]/= /andP[/eqP-> _] [v y].
by rewrite !inE /= => /andP[_ /eqP->]; congr (_, _); rewrite ?mul1g ?mulg1.
apply/trivgP; apply/subsetP=> [[x y]]; rewrite !inE /= -!andbA.
by case/and4P=> _ /eqP-> /eqP->; rewrite eqxx.
Qed.
Lemma isog_setX1 (H1 : {group gT1}) : isog H1 (setX H1 1).
Proof.
apply/isogP; exists [morphism of restrm (subsetT H1) pairg1].
by rewrite injm_restrm ?injm_pairg1.
by rewrite morphim_restrm morphim_pairg1 setIid.
Qed.
Lemma isog_set1X (H2 : {group gT2}) : isog H2 (setX 1 H2).
Proof.
apply/isogP; exists [morphism of restrm (subsetT H2) pair1g].
by rewrite injm_restrm ?injm_pair1g.
by rewrite morphim_restrm morphim_pair1g setIid.
Qed.
Lemma setX_gen (H1 : {set gT1}) (H2 : {set gT2}) :
1 \in H1 -> 1 \in H2 -> <<setX H1 H2>> = setX <<H1>> <<H2>>.
Proof.
move=> H1_1 H2_1; apply/eqP.
rewrite eqEsubset gen_subG setXS ?subset_gen //.
rewrite -setX_prod -morphim_pair1g -morphim_pairg1 !morphim_gen ?subsetT //.
by rewrite morphim_pair1g morphim_pairg1 mul_subG // genS // setXS ?sub1set.
Qed.
End ExternalDirProd.
Section ExternalSDirProd.
Variables (aT rT : finGroupType) (D : {group aT}) (R : {group rT}).
(* The pair (a, x) denotes the product sdpair2 a * sdpair1 x *)
Inductive sdprod_by (to : groupAction D R) : predArgType :=
SdPair (ax : aT * rT) of ax \in setX D R.
Coercion pair_of_sd to (u : sdprod_by to) := let: SdPair ax _ := u in ax.
Variable to : groupAction D R.
Notation sdT := (sdprod_by to).
Notation sdval := (@pair_of_sd to).
Canonical sdprod_subType := Eval hnf in [subType for sdval].
Definition sdprod_eqMixin := Eval hnf in [eqMixin of sdT by <:].
Canonical sdprod_eqType := Eval hnf in EqType sdT sdprod_eqMixin.
Definition sdprod_choiceMixin := [choiceMixin of sdT by <:].
Canonical sdprod_choiceType := ChoiceType sdT sdprod_choiceMixin.
Definition sdprod_countMixin := [countMixin of sdT by <:].
Canonical sdprod_countType := CountType sdT sdprod_countMixin.
Canonical sdprod_subCountType := Eval hnf in [subCountType of sdT].
Definition sdprod_finMixin := [finMixin of sdT by <:].
Canonical sdprod_finType := FinType sdT sdprod_finMixin.
Canonical sdprod_subFinType := Eval hnf in [subFinType of sdT].
Definition sdprod_one := SdPair to (group1 _).
Lemma sdprod_inv_proof (u : sdT) : (u.1^-1, to u.2^-1 u.1^-1) \in setX D R.
Proof.
by case: u => [[a x]] /= /setXP[Da Rx]; rewrite inE gact_stable !groupV ?Da.
Qed.
Definition sdprod_inv u := SdPair to (sdprod_inv_proof u).
Lemma sdprod_mul_proof (u v : sdT) :
(u.1 * v.1, to u.2 v.1 * v.2) \in setX D R.
Proof.
case: u v => [[a x] /= /setXP[Da Rx]] [[b y] /= /setXP[Db Ry]].
by rewrite inE !groupM //= gact_stable.
Qed.
Definition sdprod_mul u v := SdPair to (sdprod_mul_proof u v).
Lemma sdprod_mul1g : left_id sdprod_one sdprod_mul.
Proof.
move=> u; apply: val_inj; case: u => [[a x] /=]; case/setXP=> Da _.
by rewrite gact1 // !mul1g.
Qed.
Lemma sdprod_mulVg : left_inverse sdprod_one sdprod_inv sdprod_mul.
Proof.
move=> u; apply: val_inj; case: u => [[a x] /=]; case/setXP=> Da _.
by rewrite actKVin ?mulVg.
Qed.
Lemma sdprod_mulgA : associative sdprod_mul.
Proof.
move=> u v w; apply: val_inj; case: u => [[a x]] /=; case/setXP=> Da Rx.
case: v w => [[b y]] /=; case/setXP=> Db Ry [[c z]] /=; case/setXP=> Dc Rz.
by rewrite !(actMin to) // gactM ?gact_stable // !mulgA.
Qed.
Canonical sdprod_groupMixin :=
FinGroup.Mixin sdprod_mulgA sdprod_mul1g sdprod_mulVg.
Canonical sdprod_baseFinGroupType :=
Eval hnf in BaseFinGroupType sdT sdprod_groupMixin.
Canonical sdprod_groupType := FinGroupType sdprod_mulVg.
Definition sdpair1 x := insubd sdprod_one (1, x) : sdT.
Definition sdpair2 a := insubd sdprod_one (a, 1) : sdT.
Lemma sdpair1_morphM : {in R &, {morph sdpair1 : x y / x * y}}.
Proof.
move=> x y Rx Ry; apply: val_inj.
by rewrite /= !val_insubd !inE !group1 !groupM ?Rx ?Ry //= mulg1 act1.
Qed.
Lemma sdpair2_morphM : {in D &, {morph sdpair2 : a b / a * b}}.
Proof.
move=> a b Da Db; apply: val_inj.
by rewrite /= !val_insubd !inE !group1 !groupM ?Da ?Db //= mulg1 gact1.
Qed.
Canonical sdpair1_morphism := Morphism sdpair1_morphM.
Canonical sdpair2_morphism := Morphism sdpair2_morphM.
Lemma injm_sdpair1 : 'injm sdpair1.
Proof.
apply/subsetP=> x /setIP[Rx].
by rewrite !inE -val_eqE val_insubd inE Rx group1 /=; case/andP.
Qed.
Lemma injm_sdpair2 : 'injm sdpair2.
Proof.
apply/subsetP=> a /setIP[Da].
by rewrite !inE -val_eqE val_insubd inE Da group1 /=; case/andP.
Qed.
Lemma sdpairE (u : sdT) : u = sdpair2 u.1 * sdpair1 u.2.
Proof.
apply: val_inj; case: u => [[a x] /= /setXP[Da Rx]].
by rewrite !val_insubd !inE Da Rx !(group1, gact1) // mulg1 mul1g.
Qed.
Lemma sdpair_act : {in R & D,
forall x a, sdpair1 (to x a) = sdpair1 x ^ sdpair2 a}.
Proof.
move=> x a Rx Da; apply: val_inj.
rewrite /= !val_insubd !inE !group1 gact_stable ?Da ?Rx //=.
by rewrite !mul1g mulVg invg1 mulg1 actKVin ?mul1g.
Qed.
Lemma sdpair_setact (G : {set rT}) a : G \subset R -> a \in D ->
sdpair1 @* (to^~ a @: G) = (sdpair1 @* G) :^ sdpair2 a.
Proof.
move=> sGR Da; have GtoR := subsetP sGR; apply/eqP.
rewrite eqEcard cardJg !(card_injm injm_sdpair1) //; last first.
by apply/subsetP=> _ /imsetP[x Gx ->]; rewrite gact_stable ?GtoR.
rewrite (card_imset _ (act_inj _ _)) leqnn andbT.
apply/subsetP=> _ /morphimP[xa Rxa /imsetP[x Gx def_xa ->]].
rewrite mem_conjg -morphV // -sdpair_act ?groupV // def_xa actKin //.
by rewrite mem_morphim ?GtoR.
Qed.
Lemma im_sdpair_norm : sdpair2 @* D \subset 'N(sdpair1 @* R).
Proof.
apply/subsetP=> _ /morphimP[a _ Da ->].
rewrite inE -sdpair_setact // morphimS //.
by apply/subsetP=> _ /imsetP[x Rx ->]; rewrite gact_stable.
Qed.
Lemma im_sdpair_TI : (sdpair1 @* R) :&: (sdpair2 @* D) = 1.
Proof.
apply/trivgP; apply/subsetP=> _ /setIP[/morphimP[x _ Rx ->]].
case/morphimP=> a _ Da /eqP; rewrite inE -!val_eqE.
by rewrite !val_insubd !inE Da Rx !group1 /eq_op /= eqxx; case/andP.
Qed.
Lemma im_sdpair : (sdpair1 @* R) * (sdpair2 @* D) = setT.
Proof.
apply/eqP; rewrite -subTset -(normC im_sdpair_norm).
apply/subsetP=> /= u _; rewrite [u]sdpairE.
by case: u => [[a x] /= /setXP[Da Rx]]; rewrite mem_mulg ?mem_morphim.
Qed.
Lemma sdprod_sdpair : sdpair1 @* R ><| sdpair2 @* D = setT.
Proof. by rewrite sdprodE ?(im_sdpair_norm, im_sdpair, im_sdpair_TI). Qed.
Variables (A : {set aT}) (G : {set rT}).
Lemma gacentEsd : 'C_(|to)(A) = sdpair1 @*^-1 'C(sdpair2 @* A).
Proof.
apply/setP=> x; apply/idP/idP.
case/setIP=> Rx /afixP cDAx; rewrite mem_morphpre //.
apply/centP=> _ /morphimP[a Da Aa ->]; red.
by rewrite conjgC -sdpair_act // cDAx // inE Da.
case/morphpreP=> Rx cAx; rewrite inE Rx; apply/afixP=> a /setIP[Da Aa].
apply: (injmP injm_sdpair1); rewrite ?gact_stable /= ?sdpair_act //=.
by rewrite /conjg (centP cAx) ?mulKg ?mem_morphim.
Qed.
Hypotheses (sAD : A \subset D) (sGR : G \subset R).
Lemma astabEsd : 'C(G | to) = sdpair2 @*^-1 'C(sdpair1 @* G).
Proof.
have ssGR := subsetP sGR; apply/setP=> a; apply/idP/idP=> [cGa|].
rewrite mem_morphpre ?(astab_dom cGa) //.
apply/centP=> _ /morphimP[x Rx Gx ->]; symmetry.
by rewrite conjgC -sdpair_act ?(astab_act cGa) ?(astab_dom cGa).
case/morphpreP=> Da cGa; rewrite !inE Da; apply/subsetP=> x Gx; rewrite inE.
apply/eqP; apply: (injmP injm_sdpair1); rewrite ?gact_stable ?ssGR //=.
by rewrite sdpair_act ?ssGR // /conjg -(centP cGa) ?mulKg ?mem_morphim ?ssGR.
Qed.
Lemma astabsEsd : 'N(G | to) = sdpair2 @*^-1 'N(sdpair1 @* G).
Proof.
apply/setP=> a; apply/idP/idP=> [nGa|].
have Da := astabs_dom nGa; rewrite mem_morphpre // inE sub_conjg.
apply/subsetP=> _ /morphimP[x Rx Gx ->].
by rewrite mem_conjgV -sdpair_act // mem_morphim ?gact_stable ?astabs_act.
case/morphpreP=> Da nGa; rewrite !inE Da; apply/subsetP=> x Gx.
have Rx := subsetP sGR _ Gx; have Rxa: to x a \in R by rewrite gact_stable.
rewrite inE -sub1set -(injmSK injm_sdpair1) ?morphim_set1 ?sub1set //=.
by rewrite sdpair_act ?memJ_norm ?mem_morphim.
Qed.
Lemma actsEsd : [acts A, on G | to] = (sdpair2 @* A \subset 'N(sdpair1 @* G)).
Proof. by rewrite sub_morphim_pre -?astabsEsd. Qed.
End ExternalSDirProd.
Section ProdMorph.
Variables gT rT : finGroupType.
Implicit Types A B : {set gT}.
Implicit Types G H K : {group gT}.
Implicit Types C D : {set rT}.
Implicit Type L : {group rT}.
Section defs.
Variables (A B : {set gT}) (fA fB : gT -> FinGroup.sort rT).
Definition pprodm of B \subset 'N(A) & {in A & B, morph_act 'J 'J fA fB}
& {in A :&: B, fA =1 fB} :=
fun x => fA (divgr A B x) * fB (remgr A B x).
End defs.
Section Props.
Variables H K : {group gT}.
Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}).
Hypothesis nHK : K \subset 'N(H).
Hypothesis actf : {in H & K, morph_act 'J 'J fH fK}.
Hypothesis eqfHK : {in H :&: K, fH =1 fK}.
Local Notation f := (pprodm nHK actf eqfHK).
Lemma pprodmE x a : x \in H -> a \in K -> f (x * a) = fH x * fK a.
Proof.
move=> Hx Ka; have: x * a \in H * K by rewrite mem_mulg.
rewrite -remgrP inE /f rcoset_sym mem_rcoset /divgr -mulgA groupMl //.
case/andP; move: (remgr H K _) => b Hab Kb; rewrite morphM // -mulgA.
have Kab: a * b^-1 \in K by rewrite groupM ?groupV.
by congr (_ * _); rewrite eqfHK 1?inE ?Hab // -morphM // mulgKV.
Qed.
Lemma pprodmEl : {in H, f =1 fH}.
Proof. by move=> x Hx; rewrite -(mulg1 x) pprodmE // morph1 !mulg1. Qed.
Lemma pprodmEr : {in K, f =1 fK}.
Proof. by move=> a Ka; rewrite -(mul1g a) pprodmE // morph1 !mul1g. Qed.
Lemma pprodmM : {in H <*> K &, {morph f: x y / x * y}}.
Proof.
move=> xa yb; rewrite norm_joinEr //.
move=> /imset2P[x a Ha Ka ->{xa}] /imset2P[y b Hy Kb ->{yb}].
have Hya: y ^ a^-1 \in H by rewrite -mem_conjg (normsP nHK).
rewrite mulgA -(mulgA x) (conjgCV a y) (mulgA x) -mulgA !pprodmE 1?groupMl //.
by rewrite morphM // actf ?groupV ?morphV // morphM // !mulgA mulgKV invgK.
Qed.
Canonical pprodm_morphism := Morphism pprodmM.
Lemma morphim_pprodm A B :
A \subset H -> B \subset K -> f @* (A * B) = fH @* A * fK @* B.
Proof.
move=> sAH sBK; rewrite [f @* _]morphimEsub /=; last first.
by rewrite norm_joinEr // mulgSS.
apply/setP=> y; apply/imsetP/idP=> [[_ /mulsgP[x a Ax Ba ->] ->{y}] |].
have Hx := subsetP sAH x Ax; have Ka := subsetP sBK a Ba.
by rewrite pprodmE // imset2_f ?mem_morphim.
case/mulsgP=> _ _ /morphimP[x Hx Ax ->] /morphimP[a Ka Ba ->] ->{y}.
by exists (x * a); rewrite ?mem_mulg ?pprodmE.
Qed.
Lemma morphim_pprodml A : A \subset H -> f @* A = fH @* A.
Proof.
by move=> sAH; rewrite -{1}(mulg1 A) morphim_pprodm ?sub1G // morphim1 mulg1.
Qed.
Lemma morphim_pprodmr B : B \subset K -> f @* B = fK @* B.
Proof.
by move=> sBK; rewrite -{1}(mul1g B) morphim_pprodm ?sub1G // morphim1 mul1g.
Qed.
Lemma ker_pprodm : 'ker f = [set x * a^-1 | x in H, a in K & fH x == fK a].
Proof.
apply/setP=> y; rewrite 3!inE {1}norm_joinEr //=.
apply/andP/imset2P=> [[/mulsgP[x a Hx Ka ->{y}]]|[x a Hx]].
rewrite pprodmE // => fxa1.
by exists x a^-1; rewrite ?invgK // inE groupVr ?morphV // eq_mulgV1 invgK.
case/setIdP=> Kx /eqP fx ->{y}.
by rewrite imset2_f ?pprodmE ?groupV ?morphV // fx mulgV.
Qed.
Lemma injm_pprodm :
'injm f = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == fH @* K].
Proof.
apply/idP/and3P=> [injf | [injfH injfK]].
rewrite eq_sym -{1}morphimIdom -(morphim_pprodml (subsetIl _ _)) injmI //.
rewrite morphim_pprodml // morphim_pprodmr //=; split=> //.
apply/injmP=> x y Hx Hy /=; rewrite -!pprodmEl //.
by apply: (injmP injf); rewrite ?mem_gen ?inE ?Hx ?Hy.
apply/injmP=> a b Ka Kb /=; rewrite -!pprodmEr //.
by apply: (injmP injf); rewrite ?mem_gen //; apply/setUP; right.
move/eqP=> fHK; rewrite ker_pprodm; apply/subsetP=> y.
case/imset2P=> x a Hx /setIdP[Ka /eqP fxa] ->.
have: fH x \in fH @* K by rewrite -fHK inE {2}fxa !mem_morphim.
case/morphimP=> z Hz Kz /(injmP injfH) def_x.
rewrite def_x // eqfHK ?inE ?Hz // in fxa.
by rewrite def_x // (injmP injfK _ _ Kz Ka fxa) mulgV set11.
Qed.
End Props.
Section Sdprodm.
Variables H K G : {group gT}.
Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}).
Hypothesis eqHK_G : H ><| K = G.
Hypothesis actf : {in H & K, morph_act 'J 'J fH fK}.
Lemma sdprodm_norm : K \subset 'N(H).
Proof. by case/sdprodP: eqHK_G. Qed.
Lemma sdprodm_sub : G \subset H <*> K.
Proof. by case/sdprodP: eqHK_G => _ <- nHK _; rewrite norm_joinEr. Qed.
Lemma sdprodm_eqf : {in H :&: K, fH =1 fK}.
Proof.
by case/sdprodP: eqHK_G => _ _ _ -> _ /set1P->; rewrite !morph1.
Qed.
Definition sdprodm :=
restrm sdprodm_sub (pprodm sdprodm_norm actf sdprodm_eqf).
Canonical sdprodm_morphism := Eval hnf in [morphism of sdprodm].
Lemma sdprodmE a b : a \in H -> b \in K -> sdprodm (a * b) = fH a * fK b.
Proof. exact: pprodmE. Qed.
Lemma sdprodmEl a : a \in H -> sdprodm a = fH a.
Proof. exact: pprodmEl. Qed.
Lemma sdprodmEr b : b \in K -> sdprodm b = fK b.
Proof. exact: pprodmEr. Qed.
Lemma morphim_sdprodm A B :
A \subset H -> B \subset K -> sdprodm @* (A * B) = fH @* A * fK @* B.
Proof.
move=> sAH sBK; rewrite morphim_restrm /= (setIidPr _) ?morphim_pprodm //.
by case/sdprodP: eqHK_G => _ <- _ _; apply: mulgSS.
Qed.
Lemma im_sdprodm : sdprodm @* G = fH @* H * fK @* K.
Proof. by rewrite -morphim_sdprodm //; case/sdprodP: eqHK_G => _ ->. Qed.
Lemma morphim_sdprodml A : A \subset H -> sdprodm @* A = fH @* A.
Proof.
by move=> sHA; rewrite -{1}(mulg1 A) morphim_sdprodm ?sub1G // morphim1 mulg1.
Qed.
Lemma morphim_sdprodmr B : B \subset K -> sdprodm @* B = fK @* B.
Proof.
by move=> sBK; rewrite -{1}(mul1g B) morphim_sdprodm ?sub1G // morphim1 mul1g.
Qed.
Lemma ker_sdprodm :
'ker sdprodm = [set a * b^-1 | a in H, b in K & fH a == fK b].
Proof.
rewrite ker_restrm (setIidPr _) ?subIset ?ker_pprodm //; apply/orP; left.
by case/sdprodP: eqHK_G => _ <- nHK _; rewrite norm_joinEr.
Qed.
Lemma injm_sdprodm :
'injm sdprodm = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == 1].
Proof.
rewrite ker_sdprodm -(ker_pprodm sdprodm_norm actf sdprodm_eqf) injm_pprodm.
congr [&& _, _ & _ == _]; have [_ _ _ tiHK] := sdprodP eqHK_G.
by rewrite -morphimIdom tiHK morphim1.
Qed.
End Sdprodm.
Section Cprodm.
Variables H K G : {group gT}.
Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}).
Hypothesis eqHK_G : H \* K = G.
Hypothesis cfHK : fK @* K \subset 'C(fH @* H).
Hypothesis eqfHK : {in H :&: K, fH =1 fK}.
Lemma cprodm_norm : K \subset 'N(H).
Proof. by rewrite cents_norm //; case/cprodP: eqHK_G. Qed.
Lemma cprodm_sub : G \subset H <*> K.
Proof. by case/cprodP: eqHK_G => _ <- cHK; rewrite cent_joinEr. Qed.
Lemma cprodm_actf : {in H & K, morph_act 'J 'J fH fK}.
Proof.
case/cprodP: eqHK_G => _ _ cHK a b Ha Kb /=.
by rewrite /conjg -(centsP cHK b) // -(centsP cfHK (fK b)) ?mulKg ?mem_morphim.
Qed.
Definition cprodm := restrm cprodm_sub (pprodm cprodm_norm cprodm_actf eqfHK).
Canonical cprodm_morphism := Eval hnf in [morphism of cprodm].
Lemma cprodmE a b : a \in H -> b \in K -> cprodm (a * b) = fH a * fK b.
Proof. exact: pprodmE. Qed.
Lemma cprodmEl a : a \in H -> cprodm a = fH a.
Proof. exact: pprodmEl. Qed.
Lemma cprodmEr b : b \in K -> cprodm b = fK b.
Proof. exact: pprodmEr. Qed.
Lemma morphim_cprodm A B :
A \subset H -> B \subset K -> cprodm @* (A * B) = fH @* A * fK @* B.
Proof.
move=> sAH sBK; rewrite morphim_restrm /= (setIidPr _) ?morphim_pprodm //.
by case/cprodP: eqHK_G => _ <- _; apply: mulgSS.
Qed.
Lemma im_cprodm : cprodm @* G = fH @* H * fK @* K.
Proof.
by have [_ defHK _] := cprodP eqHK_G; rewrite -{2}defHK morphim_cprodm.
Qed.
Lemma morphim_cprodml A : A \subset H -> cprodm @* A = fH @* A.
Proof.
by move=> sHA; rewrite -{1}(mulg1 A) morphim_cprodm ?sub1G // morphim1 mulg1.
Qed.
Lemma morphim_cprodmr B : B \subset K -> cprodm @* B = fK @* B.
Proof.
by move=> sBK; rewrite -{1}(mul1g B) morphim_cprodm ?sub1G // morphim1 mul1g.
Qed.
Lemma ker_cprodm : 'ker cprodm = [set a * b^-1 | a in H, b in K & fH a == fK b].
Proof.
rewrite ker_restrm (setIidPr _) ?subIset ?ker_pprodm //; apply/orP; left.
by case/cprodP: eqHK_G => _ <- cHK; rewrite cent_joinEr.
Qed.
Lemma injm_cprodm :
'injm cprodm = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == fH @* K].
Proof.
by rewrite ker_cprodm -(ker_pprodm cprodm_norm cprodm_actf eqfHK) injm_pprodm.
Qed.
End Cprodm.
Section Dprodm.
Variables G H K : {group gT}.
Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}).
Hypothesis eqHK_G : H \x K = G.
Hypothesis cfHK : fK @* K \subset 'C(fH @* H).
Lemma dprodm_cprod : H \* K = G.
Proof.
by rewrite -eqHK_G /dprod; case/dprodP: eqHK_G => _ _ _ ->; rewrite subxx.
Qed.
Lemma dprodm_eqf : {in H :&: K, fH =1 fK}.
Proof. by case/dprodP: eqHK_G => _ _ _ -> _ /set1P->; rewrite !morph1. Qed.
Definition dprodm := cprodm dprodm_cprod cfHK dprodm_eqf.
Canonical dprodm_morphism := Eval hnf in [morphism of dprodm].
Lemma dprodmE a b : a \in H -> b \in K -> dprodm (a * b) = fH a * fK b.
Proof. exact: pprodmE. Qed.
Lemma dprodmEl a : a \in H -> dprodm a = fH a.
Proof. exact: pprodmEl. Qed.
Lemma dprodmEr b : b \in K -> dprodm b = fK b.
Proof. exact: pprodmEr. Qed.
Lemma morphim_dprodm A B :
A \subset H -> B \subset K -> dprodm @* (A * B) = fH @* A * fK @* B.
Proof. exact: morphim_cprodm. Qed.
Lemma im_dprodm : dprodm @* G = fH @* H * fK @* K.
Proof. exact: im_cprodm. Qed.
Lemma morphim_dprodml A : A \subset H -> dprodm @* A = fH @* A.
Proof. exact: morphim_cprodml. Qed.
Lemma morphim_dprodmr B : B \subset K -> dprodm @* B = fK @* B.
Proof. exact: morphim_cprodmr. Qed.
Lemma ker_dprodm : 'ker dprodm = [set a * b^-1 | a in H, b in K & fH a == fK b].
Proof. exact: ker_cprodm. Qed.
Lemma injm_dprodm :
'injm dprodm = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == 1].
Proof.
rewrite injm_cprodm -(morphimIdom fH K).
by case/dprodP: eqHK_G => _ _ _ ->; rewrite morphim1.
Qed.
End Dprodm.
Lemma isog_dprod A B G C D L :
A \x B = G -> C \x D = L -> isog A C -> isog B D -> isog G L.
Proof.
move=> defG {C D} /dprodP[[C D -> ->] defL cCD trCD].
case/dprodP: defG (defG) => {A B} [[A B -> ->] defG _ _] dG defC defD.
case/isogP: defC defL cCD trCD => fA injfA <-{C}.
case/isogP: defD => fB injfB <-{D} defL cCD trCD.
apply/isogP; exists (dprodm_morphism dG cCD).
by rewrite injm_dprodm injfA injfB trCD eqxx.
by rewrite /= -{2}defG morphim_dprodm.
Qed.
End ProdMorph.
Section ExtSdprodm.
Variables gT aT rT : finGroupType.
Variables (H : {group gT}) (K : {group aT}) (to : groupAction K H).
Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}).
Hypothesis actf : {in H & K, morph_act to 'J fH fK}.
Local Notation fsH := (fH \o invm (injm_sdpair1 to)).
Local Notation fsK := (fK \o invm (injm_sdpair2 to)).
Let DgH := sdpair1 to @* H.
Let DgK := sdpair2 to @* K.
Lemma xsdprodm_dom1 : DgH \subset 'dom fsH.
Proof. by rewrite ['dom _]morphpre_invm. Qed.
Local Notation gH := (restrm xsdprodm_dom1 fsH).
Lemma xsdprodm_dom2 : DgK \subset 'dom fsK.
Proof. by rewrite ['dom _]morphpre_invm. Qed.
Local Notation gK := (restrm xsdprodm_dom2 fsK).
Lemma im_sdprodm1 : gH @* DgH = fH @* H.
Proof. by rewrite morphim_restrm setIid morphim_comp im_invm. Qed.
Lemma im_sdprodm2 : gK @* DgK = fK @* K.
Proof. by rewrite morphim_restrm setIid morphim_comp im_invm. Qed.
Lemma xsdprodm_act : {in DgH & DgK, morph_act 'J 'J gH gK}.
Proof.
move=> fh fk; case/morphimP=> h _ Hh ->{fh}; case/morphimP=> k _ Kk ->{fk}.
by rewrite /= -sdpair_act // /restrm /= !invmE ?actf ?gact_stable.
Qed.
Definition xsdprodm := sdprodm (sdprod_sdpair to) xsdprodm_act.
Canonical xsdprod_morphism := [morphism of xsdprodm].
Lemma im_xsdprodm : xsdprodm @* setT = fH @* H * fK @* K.
Proof. by rewrite -im_sdpair morphim_sdprodm // im_sdprodm1 im_sdprodm2. Qed.
Lemma injm_xsdprodm :
'injm xsdprodm = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == 1].
Proof.
rewrite injm_sdprodm im_sdprodm1 im_sdprodm2 !subG1 /= !ker_restrm !ker_comp.
rewrite !morphpre_invm !morphimIim.
by rewrite !morphim_injm_eq1 ?subsetIl ?injm_sdpair1 ?injm_sdpair2.
Qed.
End ExtSdprodm.
Section DirprodIsom.
Variable gT : finGroupType.
Implicit Types G H : {group gT}.
Definition mulgm : gT * gT -> _ := uncurry mulg.
Lemma imset_mulgm (A B : {set gT}) : mulgm @: setX A B = A * B.
Proof. by rewrite -curry_imset2X. Qed.
Lemma mulgmP H1 H2 G : reflect (H1 \x H2 = G) (misom (setX H1 H2) G mulgm).
Proof.
apply: (iffP misomP) => [[pM /isomP[injf /= <-]] | ].
have /dprodP[_ /= defX cH12] := setX_dprod H1 H2.
rewrite -{4}defX {}defX => /(congr1 (fun A => morphm pM @* A)).
move/(morphimS (morphm_morphism pM)): cH12 => /=.
have sH1H: setX H1 1 \subset setX H1 H2 by rewrite setXS ?sub1G.
have sH2H: setX 1 H2 \subset setX H1 H2 by rewrite setXS ?sub1G.
rewrite morphim1 injm_cent ?injmI //= subsetI => /andP[_].
by rewrite !morphimEsub //= !imset_mulgm mulg1 mul1g; apply: dprodE.
case/dprodP=> _ defG cH12 trH12.
have fM: morphic (setX H1 H2) mulgm.
apply/morphicP=> [[x1 x2] [y1 y2] /setXP[_ Hx2] /setXP[Hy1 _]].
by rewrite /= mulgA -(mulgA x1) -(centsP cH12 x2) ?mulgA.
exists fM; apply/isomP; split; last by rewrite morphimEsub //= imset_mulgm.
apply/subsetP=> [[x1 x2]]; rewrite !inE /= andbC -eq_invg_mul.
case: eqP => //= <-; rewrite groupV -in_setI trH12 => /set1P->.
by rewrite invg1 eqxx.
Qed.
End DirprodIsom.
Arguments mulgmP {gT H1 H2 G}.
Prenex Implicits mulgm.
|
lemma (in metric_space) totally_bounded_metric: "totally_bounded S \<longleftrightarrow> (\<forall>e>0. \<exists>k. finite k \<and> S \<subseteq> (\<Union>x\<in>k. {y. dist x y < e}))" |
SUBROUTINE DR2GEO
C
C Convert a drizzle format distortion coefficients file
C to an image distortion file.
C
C This is a utility for tests.
C
C Richard Hook, ST-ECF/STScI, September 2003
C
C Converted to double precision,
C Richard Hook, ST-ECF/STScI, October 2003
C
IMPLICIT NONE
INTEGER IDD,ISTAT,NX,NY
INTEGER COTY,COMAX,CONUM,PXG,PYG,DIMS(7)
PARAMETER (COMAX=100)
DOUBLE PRECISION LAM,XCO(COMAX),YCO(COMAX)
CHARACTER*80 COEFFS
DOUBLE PRECISION WCSIN(8),WCSOUT(8)
C Geometrical parameters, the standard set
DOUBLE PRECISION SCALE,ROT,XSH,YSH,LAM
DOUBLE PRECISION XSH2,YSH2,ROT2,XSCALE,YSCALE
CHARACTER*80 XGEOIM,YGEOIM
INTEGER XGDIM,YGDIM
CHARACTER*8 SHFR2,ALIGN
INTEGER MAXLEN
PARAMETER (MAXLEN=100000)
INTEGER I,J,IXG,IYG
DOUBLE PRECISION XIN(MAXLEN),YIN(MAXLEN),XOUT(MAXLEN),YOUT(MAXLEN)
REAL MEMR(1)
COMMON /MEM/MEMR
LOGICAL DISIM,SECPAR,USEWCS,ROTFIR,ROTF2
XGEOIM=' '
YGEOIM=' '
PXG=0
PYG=0
XSH=0.0
YSH=0.0
ROT=0.0
SCALE=1.0
DISIM=.FALSE.
SECPAR=.FALSE.
USEWCS=.FALSE.
ROTFIR=.FALSE.
IDD=0
C Get the geometric flags
CALL UCLGST('align',ALIGN,ISTAT)
C Get the wavelength (Trauger only)
CALL UCLGSD('lambda',LAM,ISTAT)
C Get the geometric distortion file parameters:
CALL UCLGST('coeffs',COEFFS,ISTAT)
CALL GETGEO(COEFFS,IDD,LAM,
: COTY,COMAX,CONUM,XCO,YCO,ISTAT)
IF(ISTAT.NE.0) THEN
CALL UMSPUT(
: '! Error, failed to get geometric distortion coefficients',
: 1,0,ISTAT)
GO TO 99
ENDIF
C Read in any distortion image corrections, if specified
C PXG,PYG will default to 2x2 arrays when DISIM returns as FALSE.
C
CALL GGEOIM(XGEOIM,YGEOIM,PXG,PYG,XGDIM,YGDIM,DISIM)
C Get the name of the output images and create them
CALL UCLGST('xgeoim',XGEOIM,ISTAT)
CALL UCLGST('ygeoim',YGEOIM,ISTAT)
CALL UCLGSI('nxgeo',NX,ISTAT)
CALL UCLGSI('nygeo',NY,ISTAT)
DIMS(1)=NX
DIMS(2)=NY
CALL UIMCRE(XGEOIM,6,2,DIMS,IXG,ISTAT)
CALL UIMCRE(YGEOIM,6,2,DIMS,IYG,ISTAT)
DO I=1,NX
XIN(I)=DBLE(I)
ENDDO
C Loop through the output image
DO J=1,NY
DO I=1,NX
YIN(I)=DBLE(J)
ENDDO
C Convert the positions
CALL DRIVAL(XIN,YIN,NX,NX,NY,NX,NY,.FALSE.,
: XSH,YSH,ROT,SCALE,ALIGN,ROTFIR,
: SECPAR,XSH2,YSH2,ROT2,XSCALE,YSCALE,SHFR2,ROTF2,
: USEWCS,WCSIN,WCSOUT,
: COTY,CONUM,XCO,YCO,DISIM,
: MEMR(PXG),MEMR(PYG),XGDIM,YGDIM,XOUT,YOUT)
DO I=1,NX
XOUT(I)=XOUT(I)-XIN(I)
YOUT(I)=YOUT(I)-YIN(I)
ENDDO
C Write out the lines
CALL UIPL2R(IXG,J,XOUT,ISTAT)
CALL UIPL2R(IYG,J,YOUT,ISTAT)
ENDDO
CALL UIMCLO(IXG,ISTAT)
CALL UIMCLO(IYG,ISTAT)
99 CONTINUE
C If allocated, free the distortion image memory
IF(PXG.NE.0) CALL UDMFRE(PXG,6,ISTAT)
IF(PYG.NE.0) CALL UDMFRE(PYG,6,ISTAT)
END
|
//==================================================================================================
/**
Copyright 2016 NumScale SAS
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
**/
//==================================================================================================
#ifndef BOOST_SIMD_ARCH_COMMON_SIMD_FUNCTION_SPLIT_HIGH_HPP_INCLUDED
#define BOOST_SIMD_ARCH_COMMON_SIMD_FUNCTION_SPLIT_HIGH_HPP_INCLUDED
#include <boost/simd/detail/overload.hpp>
#include <boost/simd/function/extract.hpp>
#include <boost/simd/function/genmask.hpp>
#include <boost/simd/function/mask2logical.hpp>
#include <boost/simd/detail/dispatch/meta/upgrade.hpp>
namespace boost { namespace simd { namespace ext
{
namespace bd = boost::dispatch;
namespace bs = boost::simd;
BOOST_DISPATCH_OVERLOAD_IF( split_high_
, (typename A0, typename X)
, (bd::is_upgradable<A0>)
, bd::cpu_
, bs::pack_<bd::unspecified_<A0>, X>
)
{
using result_t = bd::upgrade_t<A0>;
template<typename... N>
static BOOST_FORCEINLINE result_t do_(A0 const& a, nsm::list<N...> const&) BOOST_NOEXCEPT
{
using type = typename result_t::value_type;
static int const list_size = sizeof...(N);
return result_t( static_cast<type>(bs::extract<list_size+N::value>(a))... );
}
BOOST_FORCEINLINE result_t operator()(A0 const& a) const BOOST_NOEXCEPT
{
return do_(a, typename result_t::traits::element_range{});
}
};
} } }
#endif
|
The norm of the product of a family of elements is less than or equal to the product of the norms of the elements. |
lemma neg_divideR_less_eq [field_simps]: "b /\<^sub>R c < a \<longleftrightarrow> c *\<^sub>R a < b" if "c < 0" for a b :: "'a :: ordered_real_vector" |
module Derive.Kit
import Data.Vect
import Language.Reflection.Elab
import Language.Reflection.Utils
import Pruviloj.Core
%default total
||| Run something for effects, throwing away the return value
ignore : Functor f => f a -> f ()
ignore x = map (const ()) x
||| Do nothing
skip : Applicative f => f ()
skip = pure ()
last : List a -> Elab a
last [] = fail [TextPart "Unexpected empty list"]
last [x] = pure x
last (_::x::xs) = last (x::xs)
getSigmaArgs : Raw -> Elab (Raw, Raw)
getSigmaArgs `(MkSigma {a=~_} {P=~_} ~rhsTy ~lhs) = pure (rhsTy, lhs)
getSigmaArgs arg = fail [TextPart "Not a sigma constructor"]
||| Ensure that all of a collection of holes was properly solved, to
||| sanity-check a use of `apply`
allSolved : List TTName -> Elab ()
allSolved ns = allSolved' ns !getHoles
where allSolved' : List TTName -> List TTName -> Elab ()
allSolved' [] hs = pure ()
allSolved' (n::ns) hs =
if elem n hs
then debugMessage [TextPart "Not all holes were solved! Remaining: ",
TextPart $ show n,
TextPart $ show hs]
else allSolved' ns hs
zipH : List a -> List b -> Elab (List (a, b))
zipH [] [] = pure []
zipH (x::xs) (y::ys) = ((x, y) ::) <$> zipH xs ys
zipH _ _ = fail [TextPart "length mismatch"]
assoc : Eq a => a -> List (a, b) -> Elab b
assoc x [] = fail [ TextPart "not found" ]
assoc x ((y, z)::ys) = if x == y then pure z else assoc x ys
doTimes : Applicative m => (n : Nat) -> m a -> m (Vect n a)
doTimes Z x = pure []
doTimes (S k) x = [| x :: (doTimes k x) |]
isRType : Raw -> Bool
isRType RType = True
isRType _ = False
unsafeNth : Nat -> List a -> Elab a
unsafeNth _ [] = fail [TextPart "Ran out of list elements"]
unsafeNth Z (x :: _) = pure x
unsafeNth (S k) (_ :: xs) = unsafeNth k xs
headVar : Raw -> Maybe TTName
headVar (RApp f _) = headVar f
headVar (Var n) = Just n
headVar x = Nothing
||| Generate holes suitable as arguments to a term of some type
argHoles : Raw -> Elab (List TTName)
argHoles (RBind n (Pi t _) body) = do n' <- nameFrom n
claim n t
unfocus n
(n ::) <$> argHoles body
argHoles _ = pure []
enumerate : List a -> List (Nat, a)
enumerate xs = enumerate' xs 0
where enumerate' : List a -> Nat -> List (Nat, a)
enumerate' [] _ = []
enumerate' (x::xs) n = (n, x) :: enumerate' xs (S n)
namespace Renamers
||| Cause a renamer to forget a renaming
restrict : (TTName -> Maybe TTName) -> TTName -> (TTName -> Maybe TTName)
restrict f n n' = if n == n' then Nothing else f n'
||| Extend a renamer with a new renaming
extend : (TTName -> Maybe TTName) -> TTName -> TTName -> (TTName -> Maybe TTName)
extend f n n' n'' = if n'' == n then Just n' else f n''
rename : TTName -> TTName -> TTName -> Maybe TTName
rename from to = extend (const Nothing) from to
||| Alpha-convert `Raw` terms
||| @ subst a partial name substitution function
partial
alphaRaw : (subst : TTName -> Maybe TTName) -> Raw -> Raw
alphaRaw subst (Var n) with (subst n)
alphaRaw subst (Var n) | Nothing = Var n
alphaRaw subst (Var n) | Just n' = Var n'
alphaRaw subst (RBind n b tm) =
let subst' = restrict subst n
b' = map (alphaRaw subst) b
in RBind n b' (alphaRaw subst' tm)
alphaRaw subst (RApp tm tm') = RApp (alphaRaw subst tm) (alphaRaw subst tm')
alphaRaw subst RType = RType
alphaRaw subst (RUType x) = RUType x
alphaRaw subst (RConstant c) = RConstant c
||| Grab the binders from around a term, alpha-converting to make their names unique
partial
stealBindings : Raw -> (nsubst : TTName -> Maybe TTName) -> Elab (List (TTName, Binder Raw), Raw)
stealBindings (RBind n b tm) nsubst =
do n' <- nameFrom n
(bindings, result) <- stealBindings tm (extend nsubst n n')
pure ((n', map (alphaRaw nsubst) b) :: bindings, result)
stealBindings tm nsubst = pure ([], alphaRaw nsubst tm)
||| Grab the binders from around a term, assuming that they have been previously uniquified
extractBinders : Raw -> (List (TTName, Binder Raw), Raw)
extractBinders (RBind n b tm) = let (bs, res) = extractBinders tm
in ((n, b) :: bs, res)
extractBinders tm = ([], tm)
||| Get the type annotation from a binder
getBinderTy : Binder t -> t
getBinderTy (Lam t) = t
getBinderTy (Pi t _) = t
getBinderTy (Let t _) = t
getBinderTy (Hole t) = t
getBinderTy (GHole t) = t
getBinderTy (Guess t _) = t
getBinderTy (PVar t) = t
getBinderTy (PVTy t) = t
mkDecl : TTName -> List (TTName, Erasure, Binder Raw) -> Raw -> TyDecl
mkDecl fn xs tm = Declare fn (map (\(n, e, b) => MkFunArg n (getBinderTy b) Implicit e) xs) tm
mkPairTy : Raw -> Raw -> Raw
mkPairTy a b = `((~a, ~b) : Type)
rebind : List (TTName, Binder Raw) -> Raw -> Raw
rebind [] tm = tm
rebind ((n, b) :: nbs) tm = RBind n b $ rebind nbs tm
bindPats : List (TTName, Binder Raw) -> Raw -> Raw
bindPats [] res = res
bindPats ((n, b)::bs) res = RBind n (PVar (getBinderTy b)) $ bindPats bs res
bindPatTys : List (TTName, Binder Raw) -> Raw -> Raw
bindPatTys [] res = res
bindPatTys ((n, b)::bs) res = RBind n (PVTy (getBinderTy b)) $ bindPatTys bs res
updateFunArgTy : (Raw -> Raw) -> FunArg -> FunArg
updateFunArgTy f arg = record {type = f (record {type} arg)} arg
tyConArgName : TyConArg -> TTName
tyConArgName (TyConParameter a) = name a
tyConArgName (TyConIndex a) = name a
setTyConArgName : TyConArg -> TTName -> TyConArg
setTyConArgName (TyConParameter a) n = TyConParameter (record {name = n} a)
setTyConArgName (TyConIndex a) n = TyConIndex (record {name = n} a)
updateTyConArgTy : (Raw -> Raw) -> TyConArg -> TyConArg
updateTyConArgTy f (TyConParameter a) = TyConParameter (record {type = f (type a) } a)
updateTyConArgTy f (TyConIndex a) = TyConIndex (record {type = f (type a) } a)
namespace Tactics
intro1 : Elab TTName
intro1 = do g <- snd <$> getGoal
case g of
Bind n (Pi _ _) _ => do n' <- nameFrom n
intro n'
pure n'
_ => fail [ TextPart "Can't intro1 because goal"
, TermPart g
, TextPart "isn't a function type."]
intros : Elab (List TTName)
intros = do g <- snd <$> getGoal
go g
where go : TT -> Elab (List TTName)
go (Bind n (Pi _ _) body) = do n' <- nameFrom n
intro n'
(n' ::) <$> go body
go _ = pure []
|
[STATEMENT]
lemma step_phi: "v \<in> allVars g \<Longrightarrow> v \<noteq> chooseNext g \<Longrightarrow> step.phi g v = map_option (map (substNext g)) (phi g v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>v \<in> allVars g; v \<noteq> chooseNext g\<rbrakk> \<Longrightarrow> step.phi g v = map_option (map (substNext g)) (phi g v)
[PROOF STEP]
by (auto simp: step.phi_def step_defNode phi_def) |
[STATEMENT]
lemma powr_sum_distrib_real_right:
assumes "a \<noteq> 0"
shows "(\<Prod>x\<in>X. a powr e x :: real) = a powr (\<Sum>x\<in>X. e x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<Prod>x\<in>X. a powr e x) = a powr sum e X
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
a \<noteq> 0
goal (1 subgoal):
1. (\<Prod>x\<in>X. a powr e x) = a powr sum e X
[PROOF STEP]
by (induction X rule: infinite_finite_induct) (auto simp: powr_add) |
constants p1 p2 : bool
def bool_to_nat : bool -> nat
| ff := 0
| tt := 1
def count (p1 p2 : bool) : nat := bool_to_nat p1 + bool_to_nat p2
inductive person : Type | a | b
def people : list person := [person.a, person.b]
constant color : person -> bool
constant beliefs (p : person) : nat -> set Prop
def is_rational (s : set Prop) : Prop := ∀ (p q : Prop), (p -> q) -> (p ∈ s) -> (q ∈ s)
axiom everyone_rational : ∀ p n, is_rational (beliefs p n)
--axiom initial_beliefs : ∀ p,
def all_believe (beliefs : set (set Prop)) (p : Prop) : Prop := forall b, b ∈ beliefs -> p ∈ b
def common_knowledge_core (beliefs : set (set Prop)) (p : Prop) : nat -> Prop
| 0 := all_believe beliefs p
| (nat.succ n) := all_believe beliefs (common_knowledge_core n)
def common_knowledge (beliefs : set (set Prop)) (p : Prop) : Prop := forall n, common_knowledge_core beliefs p n
def list_as_set {α : Type} (xs : list α) : set α := λ x, x ∈ xs
def get_beliefs (n : nat) : set (set Prop) := list_as_set (list.map (λ p, beliefs p n) people)
axiom initial_beliefs : common_knowledge (get_beliefs 0) (∃ p, color p)
def bool_ite {α : Type} (t f : α) : bool -> α
| ff := f
| tt := t
def see (p : person) : Prop := bool_ite (color p = tt) (color p = ff) (color p)
example : forall p, see p :=
begin
intro,
unfold see,
cases (color p),
unfold bool_ite,
unfold bool_ite,
end
def typeof {α : Sort _} (a : α) := α
axiom initial_beliefs' : forall (p q : person), p ≠ q -> see q ∈ beliefs p 0
axiom initial_beliefs'' : common_knowledge (get_beliefs 0) (typeof initial_beliefs')
namespace test
constants a a' : bool
constant beliefs : set Prop
axiom beliefs_rational : is_rational beliefs
axiom true_beliefs : true ∈ beliefs
example : (a = tt) -> ((a = tt) ∈ beliefs) :=
begin
intro,
apply beliefs_rational,
intro,
assumption,
apply true_beliefs,
end
end test |
function vObjRef=relVecAdd(vObsFrame,vObjInFrame)
%%RELVECADD Special relativistic addition of velocity vectors. In the
% inertial reference coordinate system, an observer moves with
% constant velocity vObsFrame. In the coordinate system of the
% observer, an object moves with constant velocity vObjInFrame.
% This computes the velocity of the observed object in the
% inertial reference frame. Under special relativity, it is not
% just vObsFrame+vObjInFrame as it is in Newtonian mechanics.
%
%INPUTS: vObsFrame The 3XN set of N velocity vectors in meters per second
% of the observer with respect to the inertial reference
% coordinate system. The magnitude of the velocity must
% be less than the speed of light.
% vObjInFrame The 3XN set of N velocity vectors in meters per second
% of the object with respect to the observer's coordinate
% system. The magnitude of the velocity must be less than
% or equal to the speed of light.
%
%OUTPUTS: vObjRef The 3XN set of velocity vectors in vObjInFrame
% transformed into the inertial reference coordinate
% system.
%
%The formulae for special relativistic velocity addition is derived in
%Chapter 1.4 of [1]. The magnitudes of vObsFrame and vObjInFrame must both
%be less than the speed of light (Constants.speedOfLight).
%
%REFERENCES:
%[1] G. Ludyk, Einstein in Matrix Form: Exact Derivation of the Theory of
% Special and General Relativity without Tensors. Heidelberg: Springer,
% 2013.
%
%March 2014 David F. Crouse, Naval Research Laboratory, Washington D.C.
%(UNCLASSIFIED) DISTRIBUTION STATEMENT A. Approved for public release.
c=Constants.speedOfLight;
v=vObsFrame;
u=vObjInFrame;
%The magnitudes of all of the v vectors.
vMag=sqrt(sum(v.*v,1));
gamma=1./sqrt(1-vMag.^2/c^2);
%v^T*u for each of the velocity vectors.
uv=sum(v.*u,1);
Num=v+u+bsxfun(@times,(1./gamma-1),(u-bsxfun(@times,(uv./vMag.^2),v)));
Denom=1+uv/c^2;
vObjRef=bsxfun(@rdivide,Num,Denom);
%If vMag=0 for any of the vectors, then NaNs will appear. In such an
%instance, the correct solution is vObjInFrame, because the frame is not
%moving.
colSel=any(~isfinite(vObjRef),1);
vObjRef(:,colSel)=u(:,colSel);
end
%LICENSE:
%
%The source code is in the public domain and not licensed or under
%copyright. The information and software may be used freely by the public.
%As required by 17 U.S.C. 403, third parties producing copyrighted works
%consisting predominantly of the material produced by U.S. government
%agencies must provide notice with such work(s) identifying the U.S.
%Government material incorporated and stating that such material is not
%subject to copyright protection.
%
%Derived works shall not identify themselves in a manner that implies an
%endorsement by or an affiliation with the Naval Research Laboratory.
%
%RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF THE
%SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY THE NAVAL
%RESEARCH LABORATORY FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE ACTIONS
%OF RECIPIENT IN THE USE OF THE SOFTWARE.
|
"""
__author__: Chao Zhang
__description__: Construct Full dataset and sub dataset objects.
Currently, the document hard clustering is written in the file
__latest_updates__: 09/25/2017
"""
import numpy as np
from collections import defaultdict
from math import log
from utils import ensure_directory_exist
# the complete data set
class DataSet:
def __init__(self, embedding_file, document_file):
self.documents = self.load_documents(document_file)
self.embeddings = self.load_embeddings(embedding_file)
# the initial complete set of keywords
# self.keywords = self.load_keywords(candidate_file)
# self.keyword_set = set(self.keywords)
# self.documents_trimmed = self.get_trimmed_documents(self.documents, self.keyword_set)
# assert len(self.documents) == len(self.documents_trimmed)
def load_embeddings(self, embedding_file):
if embedding_file is None:
return {}
word_to_vec = {}
with open(embedding_file, 'r') as fin:
for line in fin:
items = line.strip().split()
word = items[0]
vec = [float(v) for v in items[1:]]
word_to_vec[word] = vec
return word_to_vec
def load_documents(self, document_file):
documents = []
with open(document_file, 'r') as fin:
for line in fin:
keywords = line.strip().split()
documents.append(keywords)
return documents
# # trim the keywords that do not appear in the keyword set
# def get_trimmed_documents(self, documents, keyword_set):
# trimmed_documents = []
# for d in documents:
# trimmed_doc = [e for e in d if e in keyword_set]
# trimmed_documents.append(trimmed_doc)
# return trimmed_documents
# def load_keywords(self, seed_word_file):
# seed_words = []
# with open(seed_word_file, 'r') as fin:
# for line in fin:
# seed_words.append(line.strip())
# return seed_words
# sub data set for each cluster
class SubDataSet:
def __init__(self, full_data, doc_id_file, keyword_file):
"""
:param full_data:
full_data.documents: A list of the file input_dir + 'papers.txt'
full_data.embeddings: A dictionary of the file node_dir + 'embeddings.txt'
:param doc_id_file: node_dir + 'doc_ids.txt'
:param keyword_file: node_dir + 'seed_keywords.txt'
"""
self.keywords = self.load_keywords(keyword_file, full_data)
self.keyword_to_id = self.gen_keyword_id()
self.keyword_set = set(self.keywords)
self.embeddings = self.load_embeddings(full_data)
self.documents, self.original_doc_ids = self.load_documents(full_data, doc_id_file)
self.keyword_idf = self.build_keyword_idf()
def load_keywords(self, keyword_file, full_data):
"""
to make sure every keyword in the list has a embedding.
:param keyword_file:
:param full_data:
:return: A list of keywords.
"""
keywords = []
with open(keyword_file, 'r') as fin:
for line in fin:
keyword = line.strip()
if keyword in full_data.embeddings:
keywords.append(keyword)
else:
print(keyword, ' not in the embedding file')
return keywords
def gen_keyword_id(self):
"""
Generate a dictionary.
:return: A dictionary whose key is the keyword, and value is the index.
"""
keyword_to_id = {}
for idx, keyword in enumerate(self.keywords):
keyword_to_id[keyword] = idx
return keyword_to_id
def load_embeddings(self, full_data):
"""
Generate a list of embeddings followed by the order of keywords.
:param full_data:
:return: A list of embeddings.
"""
embeddings = full_data.embeddings
ret = []
for word in self.keywords:
vec = embeddings[word]
ret.append(vec)
return np.array(ret)
def load_documents(self, full_data, doc_id_file):
"""
:param full_data:
:param doc_id_file:
:return: trimmed documents along with its corresponding ids
"""
doc_ids = self.load_doc_ids(doc_id_file)
trimmed_doc_ids, trimmed_docs = [], []
for doc_id in doc_ids:
doc = full_data.documents[doc_id]
trimmed_doc = [e for e in doc if e in self.keyword_set]
if len(trimmed_doc) > 0:
trimmed_doc_ids.append(doc_id)
trimmed_docs.append(trimmed_doc)
return trimmed_docs, trimmed_doc_ids
def load_doc_ids(self, doc_id_file):
doc_ids = []
with open(doc_id_file, 'r') as fin:
for line in fin:
doc_id = int(line.strip())
doc_ids.append(doc_id)
return doc_ids
def build_keyword_idf(self):
keyword_idf = defaultdict(float)
for doc in self.documents:
word_set = set(doc)
for word in word_set:
if word in self.keyword_set:
keyword_idf[word] += 1.0
N = len(self.documents)
for w in keyword_idf:
keyword_idf[w] = log(1.0 + N / keyword_idf[w])
return keyword_idf
# output_file: one integrated file;
def write_cluster_members(self, clus, cluster_file, parent_dir):
n_cluster = clus.n_cluster
clusters = clus.clusters # a dict: cluster id -> keywords
with open(cluster_file, 'w') as fout:
for clus_id in range(n_cluster):
members = clusters[clus_id]
for keyword_id in members:
keyword = self.keywords[keyword_id]
fout.write(str(clus_id) + '\t' + keyword + '\n')
# write the cluster for each sub-folder
clus_centers = clus.center_ids
for clus_id, center_keyword_id in clus_centers:
center_keyword = self.keywords[center_keyword_id]
output_file = parent_dir + center_keyword + '/seed_keywords.txt'
ensure_directory_exist(output_file)
members = clusters[clus_id]
with open(output_file, 'w') as fout:
for keyword_id in members:
keyword = self.keywords[keyword_id]
fout.write(keyword + '\n')
def write_cluster_centers(self, clus, parent_description, output_file):
clus_centers = clus.center_ids
center_names = []
with open(output_file, 'w') as fout:
for cluster_id, keyword_idx in clus_centers:
keyword = self.keywords[keyword_idx]
center_names.append(keyword)
fout.write(keyword + ' ' + parent_description + '\n')
return center_names
def write_document_membership(self, clus, output_file, parent_dir):
n_cluster = clus.n_cluster
keyword_membership = clus.membership # an array containing the membership of the keywords
cluster_document_map = defaultdict(list) # key: cluster id, value: document list
with open(output_file, 'w') as fout:
for idx, doc in zip(self.original_doc_ids, self.documents):
doc_membership = self.get_doc_membership(n_cluster, doc, keyword_membership)
cluster_id = self.assign_document(doc_membership)
cluster_document_map[cluster_id].append(idx)
fout.write(str(idx) + '\t' + str(cluster_id) + '\n')
# write the document ids for each sub-folder
clus_centers = clus.center_ids
for clus_id, center_keyword_id in clus_centers:
center_keyword = self.keywords[center_keyword_id]
output_file = parent_dir + center_keyword + '/doc_ids.txt'
ensure_directory_exist(output_file)
doc_ids = cluster_document_map[clus_id]
with open(output_file, 'w') as fout:
for doc_id in doc_ids:
fout.write(str(doc_id) + '\n')
def get_doc_membership(self, n_cluster, document, keyword_membership):
ret = [0.0] * n_cluster
# Strength of each document on each cluster is the tf-idf score. The tf part is considered during the
# enumeration of document tokens.
for keyword in document:
keyword_id = self.keyword_to_id[keyword]
cluster_id = keyword_membership[keyword_id]
idf = self.keyword_idf[keyword]
ret[cluster_id] += idf
return ret
def assign_document(self, doc_membership):
# Currently document cluster is a hard partition.
best_idx, max_score = -1, 0
for idx, score in enumerate(doc_membership):
if score > max_score:
best_idx, max_score = idx, score
return best_idx
if __name__ == '__main__':
data_dir = '/Users/chao/data/projects/local-embedding/toy/'
document_file = data_dir + 'input/papers.txt'
keyword_file = data_dir + 'input/candidates.txt'
embedding_file = data_dir + 'input/embeddings.txt'
dataset = DataSet(embedding_file, document_file, keyword_file)
print(len(dataset.get_candidate_embeddings()))
|
###############################
### 2010, David Ellinghaus ###
###############################
rm(list=ls())
file.lmiss = commandArgs()[4]
fraction_miss.thresh = as.numeric(commandArgs()[5])
lmiss = read.table(file.lmiss, as.is=T, header=T)
png(file=paste(file.lmiss, ".2.png", sep=""), width=960, height=960)
hist(lmiss$F_MISS, xlim=c(0,fraction_miss.thresh+0.01), main="All SNPs", xlab="SNP missingness", ylab="Number of SNPs", col="grey", border="black", axes=F)
axis(1, at=seq(0,fraction_miss.thresh+0.01,0.01), tick=T)
axis(2, at=seq(0,2000000,20000), tick=T)
abline(v=fraction_miss.thresh, col="red", lty=2)
dev.off()
|
/-
Copyright (c) 2020 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
import Lean.Elab.Term
import Lean.Elab.BindersUtil
import Lean.Elab.PatternVar
import Lean.Elab.Quotation.Util
import Lean.Parser.Do
import Lean.Elab.Do
import Lean.Util.CollectLevelParams
import HBind.HBind
/-
`hdo (monad := IDENT)`
The identifier should be universe polymorphic.
-/
syntax (name := hdo) "hdo" doSeq: term
syntax (name := hdo_2) "hdo " atomic("(" &"monad" " := " term ")") doSeq: term
-- HACK: avoid code explosion until heuristics are improved
set_option compiler.reuse false
namespace Lean.Elab.Term
open Lean.Parser.Term
open Meta
open TSyntax.Compat
private def getDoSeqElems (doSeq : Syntax) : List Syntax :=
if doSeq.getKind == ``Lean.Parser.Term.doSeqBracketed then
doSeq[1].getArgs.toList.map fun arg => arg[0]
else if doSeq.getKind == ``Lean.Parser.Term.doSeqIndent then
doSeq[0].getArgs.toList.map fun arg => arg[0]
else
[]
private def getDoSeq (doStx : Syntax) : Syntax :=
doStx[1]
/-- Return true if we should not lift `(<- ...)` actions nested in the syntax nodes with the given kind. -/
private def liftMethodDelimiter (k : SyntaxNodeKind) : Bool :=
k == ``Lean.Parser.Term.do ||
k == ``Lean.Parser.Term.doSeqIndent ||
k == ``Lean.Parser.Term.doSeqBracketed ||
k == ``Lean.Parser.Term.termReturn ||
k == ``Lean.Parser.Term.termUnless ||
k == ``Lean.Parser.Term.termTry ||
k == ``Lean.Parser.Term.termFor
/-- Given `stx` which is a `letPatDecl`, `letEqnsDecl`, or `letIdDecl`, return true if it has binders. -/
private def letDeclArgHasBinders (letDeclArg : Syntax) : Bool :=
let k := letDeclArg.getKind
if k == ``Lean.Parser.Term.letPatDecl then
false
else if k == ``Lean.Parser.Term.letEqnsDecl then
true
else if k == ``Lean.Parser.Term.letIdDecl then
-- letIdLhs := ident >> checkWsBefore "expected space before binders" >> many (ppSpace >> letIdBinder)) >> optType
let binders := letDeclArg[1]
binders.getNumArgs > 0
else
false
/-- Return `true` if the given `letDecl` contains binders. -/
private def letDeclHasBinders (letDecl : Syntax) : Bool :=
letDeclArgHasBinders letDecl[0]
/-- Return true if we should generate an error message when lifting a method over this kind of syntax. -/
private def liftMethodForbiddenBinder (stx : Syntax) : Bool :=
let k := stx.getKind
if k == ``Lean.Parser.Term.fun || k == ``Lean.Parser.Term.matchAlts ||
k == ``Lean.Parser.Term.doLetRec || k == ``Lean.Parser.Term.letrec then
-- It is never ok to lift over this kind of binder
true
-- The following kinds of `let`-expressions require extra checks to decide whether they contain binders or not
else if k == ``Lean.Parser.Term.let then
letDeclHasBinders stx[1]
else if k == ``Lean.Parser.Term.doLet then
letDeclHasBinders stx[2]
else if k == ``Lean.Parser.Term.doLetArrow then
letDeclArgHasBinders stx[2]
else
false
private partial def hasLiftMethod : Syntax → Bool
| Syntax.node _ k args =>
if liftMethodDelimiter k then false
-- NOTE: We don't check for lifts in quotations here, which doesn't break anything but merely makes this rare case a
-- bit slower
else if k == ``Lean.Parser.Term.liftMethod then true
else args.any hasLiftMethod
| _ => false
private def mkUnknownMonadResult : MetaM ExtractMonadResult := do
let u ← mkFreshLevelMVar
let v ← mkFreshLevelMVar
let m ← mkFreshExprMVar (← mkArrow (mkSort (mkLevelSucc u)) (mkSort (mkLevelSucc v)))
let returnType ← mkFreshExprMVar (mkSort (mkLevelSucc u))
return { m, returnType, expectedType := mkApp m returnType }
private partial def extractBind (expectedType? : Option Expr) : TermElabM ExtractMonadResult := do
let some expectedType := expectedType? | mkUnknownMonadResult
let extractStep? (type : Expr) : MetaM (Option ExtractMonadResult) := do
let .app m returnType := type | return none
try
let bindInstType ← mkAppM ``Bind #[m]
discard <| Meta.synthInstance bindInstType
return some { m, returnType, expectedType }
catch _ =>
return none
let rec extract? (type : Expr) : MetaM (Option ExtractMonadResult) := do
match (← extractStep? type) with
| some r => return r
| none =>
let typeNew ← whnfCore type
if typeNew != type then
extract? typeNew
else
if typeNew.getAppFn.isMVar then
mkUnknownMonadResult
else match (← unfoldDefinition? typeNew) with
| some typeNew => extract? typeNew
| none => return none
match (← extract? expectedType) with
| some r => return r
| none => throwError "invalid 'do' notation, expected type is not a monad application{indentExpr expectedType}\nYou can use the `do` notation in pure code by writing `Id.run do` instead of `do`, where `Id` is the identity monad."
private def generalizeBindUniverse (bindInfo: ExtractMonadResult): TermElabM ExtractMonadResult := do
let rec genAppliedConst: Expr → TermElabM Expr
| .const name levels => do
trace[Elab.do] s!"Found monad constant {name} with levels {levels}"
let gm ← mkConstWithLevelParams name
trace[Elab.do] s!"Generalizing {name} into {gm}"
return gm
| .app func arg => do
-- TODO: Simply erasing the universe levels of the argument is fragile
let arg: TermElabM Expr :=
match arg with
| .const name _ => do
let e ← mkConstWithFreshMVarLevels name
trace[Elab.do] s!"Generalizing {arg} into {e}"
return e
| e => do
return e
mkAppM' (← genAppliedConst func) #[← arg]
| e => do
trace[Elab.do] s!"Failed to generalize levels for monad: {bindInfo.m}"
return e
let m ← genAppliedConst bindInfo.m
trace[Elab.do] s!"Final monad: {m}"
return { bindInfo with m := m }
namespace HDo
abbrev Var := Syntax -- TODO: should be `Ident`
/- A `doMatch` alternative. `vars` is the array of variables declared by `patterns`. -/
structure Alt (σ : Type) where
ref : Syntax
vars : Array Var
patterns : Syntax
rhs : σ
deriving Inhabited
/-
Auxiliary datastructure for representing a `do` code block, and compiling "reassignments" (e.g., `x := x + 1`).
We convert `Code` into a `Syntax` term representing the:
- `do`-block, or
- the visitor argument for the `forIn` combinator.
We say the following constructors are terminals:
- `break`: for interrupting a `for x in s`
- `continue`: for interrupting the current iteration of a `for x in s`
- `return e`: for returning `e` as the result for the whole `do` computation block
- `action a`: for executing action `a` as a terminal
- `ite`: if-then-else
- `match`: pattern matching
- `jmp` a goto to a join-point
We say the terminals `break`, `continue`, `action`, and `return` are "exit points"
Note that, `return e` is not equivalent to `action (pure e)`. Here is an example:
```
def f (x : Nat) : IO Unit := do
if x == 0 then
return ()
IO.println "hello"
```
Executing `#eval f 0` will not print "hello". Now, consider
```
def g (x : Nat) : IO Unit := do
if x == 0 then
pure ()
IO.println "hello"
```
The `if` statement is essentially a noop, and "hello" is printed when we execute `g 0`.
- `decl` represents all declaration-like `doElem`s (e.g., `let`, `have`, `let rec`).
The field `stx` is the actual `doElem`,
`vars` is the array of variables declared by it, and `cont` is the next instruction in the `do` code block.
`vars` is an array since we have declarations such as `let (a, b) := s`.
- `reassign` is an reassignment-like `doElem` (e.g., `x := x + 1`).
- `joinpoint` is a join point declaration: an auxiliary `let`-declaration used to represent the control-flow.
- `seq a k` executes action `a`, ignores its result, and then executes `k`.
We also store the do-elements `dbg_trace` and `assert!` as actions in a `seq`.
A code block `C` is well-formed if
- For every `jmp ref j as` in `C`, there is a `joinpoint j ps b k` and `jmp ref j as` is in `k`, and
`ps.size == as.size` -/
inductive Code where
| decl (xs : Array Var) (doElem : Syntax) (k : Code)
| reassign (xs : Array Var) (doElem : Syntax) (k : Code)
/- The Boolean value in `params` indicates whether we should use `(x : typeof! x)` when generating term Syntax or not -/
| joinpoint (name : Name) (params : Array (Var × Bool)) (body : Code) (k : Code)
| seq (action : Syntax) (k : Code)
| action (action : Syntax)
| «break» (ref : Syntax)
| «continue» (ref : Syntax)
| «return» (ref : Syntax) (val : Syntax)
/- Recall that an if-then-else may declare a variable using `optIdent` for the branches `thenBranch` and `elseBranch`. We store the variable name at `var?`. -/
| ite (ref : Syntax) (h? : Option Var) (optIdent : Syntax) (cond : Syntax) (thenBranch : Code) (elseBranch : Code)
| «match» (ref : Syntax) (gen : Syntax) (discrs : Syntax) (optMotive : Syntax) (alts : Array (Alt Code))
| jmp (ref : Syntax) (jpName : Name) (args : Array Syntax)
deriving Inhabited
abbrev VarSet := Std.RBMap Name Syntax Name.cmp
/- A code block, and the collection of variables updated by it. -/
structure CodeBlock where
code : Code
uvars : VarSet := {} -- set of variables updated by `code`
private def varSetToArray (s : VarSet) : Array Var :=
s.fold (fun xs _ x => xs.push x) #[]
private def varsToMessageData (vars : Array Var) : MessageData :=
MessageData.joinSep (vars.toList.map fun n => MessageData.ofName (n.getId.simpMacroScopes)) " "
partial def CodeBlocl.toMessageData (codeBlock : CodeBlock) : MessageData :=
let us := MessageData.ofList <| (varSetToArray codeBlock.uvars).toList.map MessageData.ofSyntax
let rec loop : Code → MessageData
| Code.decl xs _ k => m!"let {varsToMessageData xs} := ...\n{loop k}"
| Code.reassign xs _ k => m!"{varsToMessageData xs} := ...\n{loop k}"
| Code.joinpoint n ps body k => m!"let {n.simpMacroScopes} {varsToMessageData (ps.map Prod.fst)} := {indentD (loop body)}\n{loop k}"
| Code.seq e k => m!"{e}\n{loop k}"
| Code.action e => e
| Code.ite _ _ _ c t e => m!"if {c} then {indentD (loop t)}\nelse{loop e}"
| Code.jmp _ j xs => m!"jmp {j.simpMacroScopes} {xs.toList}"
| Code.«break» _ => m!"break {us}"
| Code.«continue» _ => m!"continue {us}"
| Code.«return» _ v => m!"return {v} {us}"
| Code.«match» _ _ ds _ alts =>
m!"match {ds} with"
++ alts.foldl (init := m!"") fun acc alt => acc ++ m!"\n| {alt.patterns} => {loop alt.rhs}"
loop codeBlock.code
/- Return true if the give code contains an exit point that satisfies `p` -/
partial def hasExitPointPred (c : Code) (p : Code → Bool) : Bool :=
let rec loop : Code → Bool
| Code.decl _ _ k => loop k
| Code.reassign _ _ k => loop k
| Code.joinpoint _ _ b k => loop b || loop k
| Code.seq _ k => loop k
| Code.ite _ _ _ _ t e => loop t || loop e
| Code.«match» _ _ _ _ alts => alts.any (loop ·.rhs)
| Code.jmp _ _ _ => false
| c => p c
loop c
def hasExitPoint (c : Code) : Bool :=
hasExitPointPred c fun _ => true
def hasReturn (c : Code) : Bool :=
hasExitPointPred c fun
| Code.«return» _ _ => true
| _ => false
def hasTerminalAction (c : Code) : Bool :=
hasExitPointPred c fun
| Code.«action» _ => true
| _ => false
def hasBreakContinue (c : Code) : Bool :=
hasExitPointPred c fun
| Code.«break» _ => true
| Code.«continue» _ => true
| _ => false
def hasBreakContinueReturn (c : Code) : Bool :=
hasExitPointPred c fun
| Code.«break» _ => true
| Code.«continue» _ => true
| Code.«return» _ _ => true
| _ => false
def mkAuxDeclFor {m} [Monad m] [MonadQuotation m] (e : Syntax) (mkCont : Syntax → m Code) : m Code := withRef e <| withFreshMacroScope do
let y ← `(y)
let doElem ← `(doElem| let y ← $e:term)
-- Add elaboration hint for producing sane error message
let y ← `(ensure_expected_type% "type mismatch, result value" $y)
let k ← mkCont y
return Code.decl #[y] doElem k
/- Convert `action _ e` instructions in `c` into `let y ← e; jmp _ jp (xs y)`. -/
partial def convertTerminalActionIntoJmp (code : Code) (jp : Name) (xs : Array Var) : MacroM Code :=
let rec loop : Code → MacroM Code
| Code.decl xs stx k => return Code.decl xs stx (← loop k)
| Code.reassign xs stx k => return Code.reassign xs stx (← loop k)
| Code.joinpoint n ps b k => return Code.joinpoint n ps (← loop b) (← loop k)
| Code.seq e k => return Code.seq e (← loop k)
| Code.ite ref x? h c t e => return Code.ite ref x? h c (← loop t) (← loop e)
| Code.«match» ref g ds t alts => return Code.«match» ref g ds t (← alts.mapM fun alt => do pure { alt with rhs := (← loop alt.rhs) })
| Code.action e => mkAuxDeclFor e fun y =>
let ref := e
-- We jump to `jp` with xs **and** y
let jmpArgs := xs.push y
return Code.jmp ref jp jmpArgs
| c => return c
loop code
structure JPDecl where
name : Name
params : Array (Var × Bool)
body : Code
def attachJP (jpDecl : JPDecl) (k : Code) : Code :=
Code.joinpoint jpDecl.name jpDecl.params jpDecl.body k
def attachJPs (jpDecls : Array JPDecl) (k : Code) : Code :=
jpDecls.foldr attachJP k
def mkFreshJP (ps : Array (Var × Bool)) (body : Code) : TermElabM JPDecl := do
let ps ← if ps.isEmpty then
let y ← `(y)
pure #[(y.raw, false)]
else
pure ps
-- Remark: the compiler frontend implemented in C++ currently detects jointpoints created by
-- the "do" notation by testing the name. See hack at method `visit_let` at `lcnf.cpp`
-- We will remove this hack when we re-implement the compiler frontend in Lean.
let name ← mkFreshUserName `_do_jp
pure { name := name, params := ps, body := body }
def addFreshJP (ps : Array (Var × Bool)) (body : Code) : StateRefT (Array JPDecl) TermElabM Name := do
let jp ← mkFreshJP ps body
modify fun (jps : Array JPDecl) => jps.push jp
pure jp.name
def insertVars (rs : VarSet) (xs : Array Var) : VarSet :=
xs.foldl (fun rs x => rs.insert x.getId x) rs
def eraseVars (rs : VarSet) (xs : Array Var) : VarSet :=
xs.foldl (·.erase ·.getId) rs
def eraseOptVar (rs : VarSet) (x? : Option Var) : VarSet :=
match x? with
| none => rs
| some x => rs.insert x.getId x
/- Create a new jointpoint for `c`, and jump to it with the variables `rs` -/
def mkSimpleJmp (ref : Syntax) (rs : VarSet) (c : Code) : StateRefT (Array JPDecl) TermElabM Code := do
let xs := varSetToArray rs
let jp ← addFreshJP (xs.map fun x => (x, true)) c
if xs.isEmpty then
let unit ← ``(Unit.unit)
return Code.jmp ref jp #[unit]
else
return Code.jmp ref jp xs
/- Create a new joinpoint that takes `rs` and `val` as arguments. `val` must be syntax representing a pure value.
The body of the joinpoint is created using `mkJPBody yFresh`, where `yFresh`
is a fresh variable created by this method. -/
def mkJmp (ref : Syntax) (rs : VarSet) (val : Syntax) (mkJPBody : Syntax → MacroM Code) : StateRefT (Array JPDecl) TermElabM Code := do
let xs := varSetToArray rs
let args := xs.push val
let yFresh ← withRef ref `(y)
let ps := xs.map fun x => (x, true)
let ps := ps.push (yFresh, false)
let jpBody ← liftMacroM <| mkJPBody yFresh
let jp ← addFreshJP ps jpBody
return Code.jmp ref jp args
/- `pullExitPointsAux rs c` auxiliary method for `pullExitPoints`, `rs` is the set of update variable in the current path. -/
partial def pullExitPointsAux : VarSet → Code → StateRefT (Array JPDecl) TermElabM Code
| rs, Code.decl xs stx k => return Code.decl xs stx (← pullExitPointsAux (eraseVars rs xs) k)
| rs, Code.reassign xs stx k => return Code.reassign xs stx (← pullExitPointsAux (insertVars rs xs) k)
| rs, Code.joinpoint j ps b k => return Code.joinpoint j ps (← pullExitPointsAux rs b) (← pullExitPointsAux rs k)
| rs, Code.seq e k => return Code.seq e (← pullExitPointsAux rs k)
| rs, Code.ite ref x? o c t e => return Code.ite ref x? o c (← pullExitPointsAux (eraseOptVar rs x?) t) (← pullExitPointsAux (eraseOptVar rs x?) e)
| rs, Code.«match» ref g ds t alts => return Code.«match» ref g ds t (← alts.mapM fun alt => do pure { alt with rhs := (← pullExitPointsAux (eraseVars rs alt.vars) alt.rhs) })
| _, c@(Code.jmp _ _ _) => return c
| rs, Code.«break» ref => mkSimpleJmp ref rs (Code.«break» ref)
| rs, Code.«continue» ref => mkSimpleJmp ref rs (Code.«continue» ref)
| rs, Code.«return» ref val => mkJmp ref rs val (fun y => return Code.«return» ref y)
| rs, Code.action e =>
-- We use `mkAuxDeclFor` because `e` is not pure.
mkAuxDeclFor e fun y =>
let ref := e
mkJmp ref rs y (fun yFresh => return Code.action (← ``(Pure.pure $yFresh)))
/-
Auxiliary operation for adding new variables to the collection of updated variables in a CodeBlock.
When a new variable is not already in the collection, but is shadowed by some declaration in `c`,
we create auxiliary join points to make sure we preserve the semantics of the code block.
Example: suppose we have the code block `print x; let x := 10; return x`. And we want to extend it
with the reassignment `x := x + 1`. We first use `pullExitPoints` to create
```
let jp (x!1) := return x!1;
print x;
let x := 10;
jmp jp x
```
and then we add the reassignment
```
x := x + 1
let jp (x!1) := return x!1;
print x;
let x := 10;
jmp jp x
```
Note that we created a fresh variable `x!1` to avoid accidental name capture.
As another example, consider
```
print x;
let x := 10
y := y + 1;
return x;
```
We transform it into
```
let jp (y x!1) := return x!1;
print x;
let x := 10
y := y + 1;
jmp jp y x
```
and then we add the reassignment as in the previous example.
We need to include `y` in the jump, because each exit point is implicitly returning the set of
update variables.
We implement the method as follows. Let `us` be `c.uvars`, then
1- for each `return _ y` in `c`, we create a join point
`let j (us y!1) := return y!1`
and replace the `return _ y` with `jmp us y`
2- for each `break`, we create a join point
`let j (us) := break`
and replace the `break` with `jmp us`.
3- Same as 2 for `continue`.
-/
def pullExitPoints (c : Code) : TermElabM Code := do
if hasExitPoint c then
let (c, jpDecls) ← (pullExitPointsAux {} c).run #[]
return attachJPs jpDecls c
else
return c
partial def extendUpdatedVarsAux (c : Code) (ws : VarSet) : TermElabM Code :=
let rec update : Code → TermElabM Code
| Code.joinpoint j ps b k => return Code.joinpoint j ps (← update b) (← update k)
| Code.seq e k => return Code.seq e (← update k)
| c@(Code.«match» ref g ds t alts) => do
if alts.any fun alt => alt.vars.any fun x => ws.contains x.getId then
-- If a pattern variable is shadowing a variable in ws, we `pullExitPoints`
pullExitPoints c
else
return Code.«match» ref g ds t (← alts.mapM fun alt => do pure { alt with rhs := (← update alt.rhs) })
| Code.ite ref none o c t e => return Code.ite ref none o c (← update t) (← update e)
| c@(Code.ite ref (some h) o cond t e) => do
if ws.contains h.getId then
-- if the `h` at `if h:c then t else e` shadows a variable in `ws`, we `pullExitPoints`
pullExitPoints c
else
return Code.ite ref (some h) o cond (← update t) (← update e)
| Code.reassign xs stx k => return Code.reassign xs stx (← update k)
| c@(Code.decl xs stx k) => do
if xs.any fun x => ws.contains x.getId then
-- One the declared variables is shadowing a variable in `ws`
pullExitPoints c
else
return Code.decl xs stx (← update k)
| c => return c
update c
/-
Extend the set of updated variables. It assumes `ws` is a super set of `c.uvars`.
We **cannot** simply update the field `c.uvars`, because `c` may have shadowed some variable in `ws`.
See discussion at `pullExitPoints`.
-/
partial def extendUpdatedVars (c : CodeBlock) (ws : VarSet) : TermElabM CodeBlock := do
if ws.any fun x _ => !c.uvars.contains x then
-- `ws` contains a variable that is not in `c.uvars`, but in `c.dvars` (i.e., it has been shadowed)
pure { code := (← extendUpdatedVarsAux c.code ws), uvars := ws }
else
pure { c with uvars := ws }
private def union (s₁ s₂ : VarSet) : VarSet :=
s₁.fold (·.insert ·) s₂
/-
Given two code blocks `c₁` and `c₂`, make sure they have the same set of updated variables.
Let `ws` the union of the updated variables in `c₁‵ and ‵c₂`.
We use `extendUpdatedVars c₁ ws` and `extendUpdatedVars c₂ ws`
-/
def homogenize (c₁ c₂ : CodeBlock) : TermElabM (CodeBlock × CodeBlock) := do
let ws := union c₁.uvars c₂.uvars
let c₁ ← extendUpdatedVars c₁ ws
let c₂ ← extendUpdatedVars c₂ ws
pure (c₁, c₂)
/-
Extending code blocks with variable declarations: `let x : t := v` and `let x : t ← v`.
We remove `x` from the collection of updated varibles.
Remark: `stx` is the syntax for the declaration (e.g., `letDecl`), and `xs` are the variables
declared by it. It is an array because we have let-declarations that declare multiple variables.
Example: `let (x, y) := t`
-/
def mkVarDeclCore (xs : Array Var) (stx : Syntax) (c : CodeBlock) : CodeBlock := {
code := Code.decl xs stx c.code,
uvars := eraseVars c.uvars xs
}
/-
Extending code blocks with reassignments: `x : t := v` and `x : t ← v`.
Remark: `stx` is the syntax for the declaration (e.g., `letDecl`), and `xs` are the variables
declared by it. It is an array because we have let-declarations that declare multiple variables.
Example: `(x, y) ← t`
-/
def mkReassignCore (xs : Array Var) (stx : Syntax) (c : CodeBlock) : TermElabM CodeBlock := do
let us := c.uvars
let ws := insertVars us xs
-- If `xs` contains a new updated variable, then we must use `extendUpdatedVars`.
-- See discussion at `pullExitPoints`
let code ← if xs.any fun x => !us.contains x.getId then extendUpdatedVarsAux c.code ws else pure c.code
pure { code := Code.reassign xs stx code, uvars := ws }
def mkSeq (action : Syntax) (c : CodeBlock) : CodeBlock :=
{ c with code := Code.seq action c.code }
def mkTerminalAction (action : Syntax) : CodeBlock :=
{ code := Code.action action }
def mkReturn (ref : Syntax) (val : Syntax) : CodeBlock :=
{ code := Code.«return» ref val }
def mkBreak (ref : Syntax) : CodeBlock :=
{ code := Code.«break» ref }
def mkContinue (ref : Syntax) : CodeBlock :=
{ code := Code.«continue» ref }
def mkIte (ref : Syntax) (optIdent : Syntax) (cond : Syntax) (thenBranch : CodeBlock) (elseBranch : CodeBlock) : TermElabM CodeBlock := do
let x? := optIdent.getOptional?
let (thenBranch, elseBranch) ← homogenize thenBranch elseBranch
pure {
code := Code.ite ref x? optIdent cond thenBranch.code elseBranch.code,
uvars := thenBranch.uvars,
}
private def mkUnit : MacroM Syntax :=
``((⟨⟩ : PUnit))
private def mkPureUnit : MacroM Syntax :=
``(pure PUnit.unit)
def mkPureUnitAction : MacroM CodeBlock := do
return mkTerminalAction (← mkPureUnit)
def mkUnless (cond : Syntax) (c : CodeBlock) : MacroM CodeBlock := do
let thenBranch ← mkPureUnitAction
pure { c with code := Code.ite (← getRef) none mkNullNode cond thenBranch.code c.code }
def mkMatch (ref : Syntax) (genParam : Syntax) (discrs : Syntax) (optMotive : Syntax) (alts : Array (Alt CodeBlock)) : TermElabM CodeBlock := do
-- nary version of homogenize
let ws := alts.foldl (union · ·.rhs.uvars) {}
let alts ← alts.mapM fun alt => do
let rhs ← extendUpdatedVars alt.rhs ws
return { ref := alt.ref, vars := alt.vars, patterns := alt.patterns, rhs := rhs.code : Alt Code }
return { code := Code.«match» ref genParam discrs optMotive alts, uvars := ws }
/- Return a code block that executes `terminal` and then `k` with the value produced by `terminal`.
This method assumes `terminal` is a terminal -/
def concat (terminal : CodeBlock) (kRef : Syntax) (y? : Option Var) (k : CodeBlock) : TermElabM CodeBlock := do
unless hasTerminalAction terminal.code do
throwErrorAt kRef "'do' element is unreachable"
let (terminal, k) ← homogenize terminal k
let xs := varSetToArray k.uvars
let y ← match y? with | some y => pure y | none => `(y)
let ps := xs.map fun x => (x, true)
let ps := ps.push (y, false)
let jpDecl ← mkFreshJP ps k.code
let jp := jpDecl.name
let terminal ← liftMacroM <| convertTerminalActionIntoJmp terminal.code jp xs
return { code := attachJP jpDecl terminal, uvars := k.uvars }
def getLetIdDeclVar (letIdDecl : Syntax) : Var :=
letIdDecl[0]
-- support both regular and syntax match
def getPatternVarsEx (pattern : Syntax) : TermElabM (Array Var) :=
getPatternVars pattern <|>
Quotation.getPatternVars pattern
def getPatternsVarsEx (patterns : Array Syntax) : TermElabM (Array Var) :=
getPatternsVars patterns <|>
Quotation.getPatternsVars patterns
def getLetPatDeclVars (letPatDecl : Syntax) : TermElabM (Array Var) := do
let pattern := letPatDecl[0]
getPatternVarsEx pattern
def getLetEqnsDeclVar (letEqnsDecl : Syntax) : Var :=
letEqnsDecl[0]
def getLetDeclVars (letDecl : Syntax) : TermElabM (Array Var) := do
let arg := letDecl[0]
if arg.getKind == ``Lean.Parser.Term.letIdDecl then
return #[getLetIdDeclVar arg]
else if arg.getKind == ``Lean.Parser.Term.letPatDecl then
getLetPatDeclVars arg
else if arg.getKind == ``Lean.Parser.Term.letEqnsDecl then
return #[getLetEqnsDeclVar arg]
else
throwError "unexpected kind of let declaration"
def getDoLetVars (doLet : Syntax) : TermElabM (Array Var) :=
-- leading_parser "let " >> optional "mut " >> letDecl
getLetDeclVars doLet[2]
def getHaveIdLhsVar (optIdent : Syntax) : TermElabM Var :=
if optIdent.isNone then
`(this)
else
pure optIdent[0]
def getDoHaveVars (doHave : Syntax) : TermElabM (Array Var) := do
-- doHave := leading_parser "have " >> Term.haveDecl
-- haveDecl := leading_parser haveIdDecl <|> letPatDecl <|> haveEqnsDecl
let arg := doHave[1][0]
if arg.getKind == ``Lean.Parser.Term.haveIdDecl then
-- haveIdDecl := leading_parser atomic (haveIdLhs >> " := ") >> termParser
-- haveIdLhs := optional (ident >> many (ppSpace >> letIdBinder)) >> optType
return #[← getHaveIdLhsVar arg[0]]
else if arg.getKind == ``Lean.Parser.Term.letPatDecl then
getLetPatDeclVars arg
else if arg.getKind == ``Lean.Parser.Term.haveEqnsDecl then
-- haveEqnsDecl := leading_parser haveIdLhs >> matchAlts
return #[← getHaveIdLhsVar arg[0]]
else
throwError "unexpected kind of have declaration"
def getDoLetRecVars (doLetRec : Syntax) : TermElabM (Array Var) := do
-- letRecDecls is an array of `(group (optional attributes >> letDecl))`
let letRecDecls := doLetRec[1][0].getSepArgs
let letDecls := letRecDecls.map fun p => p[2]
let mut allVars := #[]
for letDecl in letDecls do
let vars ← getLetDeclVars letDecl
allVars := allVars ++ vars
return allVars
-- ident >> optType >> leftArrow >> termParser
def getDoIdDeclVar (doIdDecl : Syntax) : Var :=
doIdDecl[0]
-- termParser >> leftArrow >> termParser >> optional (" | " >> termParser)
def getDoPatDeclVars (doPatDecl : Syntax) : TermElabM (Array Var) := do
let pattern := doPatDecl[0]
getPatternVarsEx pattern
-- leading_parser "let " >> optional "mut " >> (doIdDecl <|> doPatDecl)
def getDoLetArrowVars (doLetArrow : Syntax) : TermElabM (Array Var) := do
let decl := doLetArrow[2]
if decl.getKind == ``Lean.Parser.Term.doIdDecl then
return #[getDoIdDeclVar decl]
else if decl.getKind == ``Lean.Parser.Term.doPatDecl then
getDoPatDeclVars decl
else
throwError "unexpected kind of 'do' declaration"
def getDoReassignVars (doReassign : Syntax) : TermElabM (Array Var) := do
let arg := doReassign[0]
if arg.getKind == ``Lean.Parser.Term.letIdDecl then
return #[getLetIdDeclVar arg]
else if arg.getKind == ``Lean.Parser.Term.letPatDecl then
getLetPatDeclVars arg
else
throwError "unexpected kind of reassignment"
def mkDoSeq (doElems : Array Syntax) : Syntax :=
mkNode `Lean.Parser.Term.doSeqIndent #[mkNullNode <| doElems.map fun doElem => mkNullNode #[doElem, mkNullNode]]
def mkSingletonDoSeq (doElem : Syntax) : Syntax :=
mkDoSeq #[doElem]
/-
If the given syntax is a `doIf`, return an equivalente `doIf` that has an `else` but no `else if`s or `if let`s. -/
private def expandDoIf? (stx : Syntax) : MacroM (Option Syntax) := match stx with
| `(doElem|if $_:doIfProp then $_ else $_) => pure none
| `(doElem|if%$i $cond:doIfCond then $t $[else if%$is $conds:doIfCond then $ts]* $[else $e?]?) => withRef stx do
let mut e := e?.getD (← `(doSeq|pure PUnit.unit))
let mut eIsSeq := true
for (i, cond, t) in Array.zip (is.reverse.push i) (Array.zip (conds.reverse.push cond) (ts.reverse.push t)) do
e ← if eIsSeq then pure e else `(doSeq|$e:doElem)
e ← withRef cond <| match cond with
| `(doIfCond|let $pat := $d) => `(doElem| match%$i $d:term with | $pat:term => $t | _ => $e)
| `(doIfCond|let $pat ← $d) => `(doElem| match%$i ← $d with | $pat:term => $t | _ => $e)
| `(doIfCond|$cond:doIfProp) => `(doElem| if%$i $cond:doIfProp then $t else $e)
| _ => `(doElem| if%$i $(Syntax.missing) then $t else $e)
eIsSeq := false
return some e
| _ => pure none
structure DoIfView where
ref : Syntax
optIdent : Syntax
cond : Syntax
thenBranch : Syntax
elseBranch : Syntax
/- This method assumes `expandDoIf?` is not applicable. -/
private def mkDoIfView (doIf : Syntax) : MacroM DoIfView := do
pure {
ref := doIf,
optIdent := doIf[1][0],
cond := doIf[1][1],
thenBranch := doIf[3],
elseBranch := doIf[5][1]
}
private def mkTuple (elems : Array Syntax) : MacroM Syntax := do
if elems.size == 0 then
mkUnit
else if elems.size == 1 then
return elems[0]!
else
elems.extract 0 (elems.size - 1) |>.foldrM (init := elems.back) fun elem tuple =>
``(Prod.mk $elem $tuple)
/- Return `some action` if `doElem` is a `doExpr <action>`-/
def isDoExpr? (doElem : Syntax) : Option Syntax :=
if doElem.getKind == ``Lean.Parser.Term.doExpr then
some doElem[0]
else
none
/--
Given `uvars := #[a_1, ..., a_n, a_{n+1}]` construct term
```
let a_1 := x.1
let x := x.2
let a_2 := x.1
let x := x.2
...
let a_n := x.1
let a_{n+1} := x.2
body
```
Special cases
- `uvars := #[]` => `body`
- `uvars := #[a]` => `let a := x; body`
We use this method when expanding the `for-in` notation.
-/
private def destructTuple (uvars : Array Var) (x : Syntax) (body : Syntax) : MacroM Syntax := do
if uvars.size == 0 then
return body
else if uvars.size == 1 then
`(let $(uvars[0]!):ident := $x; $body)
else
destruct uvars.toList x body
where
destruct (as : List Var) (x : Syntax) (body : Syntax) : MacroM Syntax := do
match as with
| [a, b] => `(let $a:ident := $x.1; let $b:ident := $x.2; $body)
| a :: as => withFreshMacroScope do
let rest ← destruct as (← `(x)) body
`(let $a:ident := $x.1; let x := $x.2; $rest)
| _ => unreachable!
/-
The procedure `ToTerm.run` converts a `CodeBlock` into a `Syntax` term.
We use this method to convert
1- The `CodeBlock` for a root `do ...` term into a `Syntax` term. This kind of
`CodeBlock` never contains `break` nor `continue`. Moreover, the collection
of updated variables is not packed into the result.
Thus, we have two kinds of exit points
- `Code.action e` which is converted into `e`
- `Code.return _ e` which is converted into `pure e`
We use `Kind.regular` for this case.
2- The `CodeBlock` for `b` at `for x in xs do b`. In this case, we need to generate
a `Syntax` term representing a function for the `xs.forIn` combinator.
a) If `b` contain a `Code.return _ a` exit point. The generated `Syntax` term
has type `m (ForInStep (Option α × σ))`, where `a : α`, and the `σ` is the type
of the tuple of variables reassigned by `b`.
We use `Kind.forInWithReturn` for this case
b) If `b` does not contain a `Code.return _ a` exit point. Then, the generated
`Syntax` term has type `m (ForInStep σ)`.
We use `Kind.forIn` for this case.
3- The `CodeBlock` `c` for a `do` sequence nested in a monadic combinator (e.g., `MonadExcept.tryCatch`).
The generated `Syntax` term for `c` must inform whether `c` "exited" using `Code.action`, `Code.return`,
`Code.break` or `Code.continue`. We use the auxiliary types `DoResult`s for storing this information.
For example, the auxiliary type `DoResultPBC α σ` is used for a code block that exits with `Code.action`,
**and** `Code.break`/`Code.continue`, `α` is the type of values produced by the exit `action`, and
`σ` is the type of the tuple of reassigned variables.
The type `DoResult α β σ` is usedf for code blocks that exit with
`Code.action`, `Code.return`, **and** `Code.break`/`Code.continue`, `β` is the type of the returned values.
We don't use `DoResult α β σ` for all cases because:
a) The elaborator would not be able to infer all type parameters without extra annotations. For example,
if the code block does not contain `Code.return _ _`, the elaborator will not be able to infer `β`.
b) We need to pattern match on the result produced by the combinator (e.g., `MonadExcept.tryCatch`),
but we don't want to consider "unreachable" cases.
We do not distinguish between cases that contain `break`, but not `continue`, and vice versa.
When listing all cases, we use `a` to indicate the code block contains `Code.action _`, `r` for `Code.return _ _`,
and `b/c` for a code block that contains `Code.break _` or `Code.continue _`.
- `a`: `Kind.regular`, type `m (α × σ)`
- `r`: `Kind.regular`, type `m (α × σ)`
Note that the code that pattern matches on the result will behave differently in this case.
It produces `return a` for this case, and `pure a` for the previous one.
- `b/c`: `Kind.nestedBC`, type `m (DoResultBC σ)`
- `a` and `r`: `Kind.nestedPR`, type `m (DoResultPR α β σ)`
- `a` and `bc`: `Kind.nestedSBC`, type `m (DoResultSBC α σ)`
- `r` and `bc`: `Kind.nestedSBC`, type `m (DoResultSBC α σ)`
Again the code that pattern matches on the result will behave differently in this case and
the previous one. It produces `return a` for the constructor `DoResultSPR.pureReturn a u` for
this case, and `pure a` for the previous case.
- `a`, `r`, `b/c`: `Kind.nestedPRBC`, type type `m (DoResultPRBC α β σ)`
Here is the recipe for adding new combinators with nested `do`s.
Example: suppose we want to support `repeat doSeq`. Assuming we have `repeat : m α → m α`
1- Convert `doSeq` into `codeBlock : CodeBlock`
2- Create term `term` using `mkNestedTerm code m uvars a r bc` where
`code` is `codeBlock.code`, `uvars` is an array containing `codeBlock.uvars`,
`m` is a `Syntax` representing the Monad, and
`a` is true if `code` contains `Code.action _`,
`r` is true if `code` contains `Code.return _ _`,
`bc` is true if `code` contains `Code.break _` or `Code.continue _`.
Remark: for combinators such as `repeat` that take a single `doSeq`, all
arguments, but `m`, are extracted from `codeBlock`.
3- Create the term `repeat $term`
4- and then, convert it into a `doSeq` using `matchNestedTermResult ref (repeat $term) uvsar a r bc`
-/
namespace ToTerm
inductive Kind where
| regular
| forIn
| forInWithReturn
| nestedBC
| nestedPR
| nestedSBC
| nestedPRBC
instance : Inhabited Kind := ⟨Kind.regular⟩
def Kind.isRegular : Kind → Bool
| Kind.regular => true
| _ => false
structure Context where
/-- Syntax to reference the monad associated with the do notation. -/
m : Syntax
/-- Syntax to reference the result of the monadic computation performed by the do notation. -/
returnType : Syntax
uvars : Array Var
kind : Kind
abbrev M := ReaderT Context MacroM
def mkUVarTuple : M Syntax := do
let ctx ← read
mkTuple ctx.uvars
def returnToTerm (val : Syntax) : M Syntax := do
let ctx ← read
let u ← mkUVarTuple
match ctx.kind with
| Kind.regular => if ctx.uvars.isEmpty then ``(Pure.pure $val) else ``(Pure.pure (Prod.mk $val $u))
| Kind.forIn => ``(Pure.pure (ForInStep.done $u))
| Kind.forInWithReturn => ``(Pure.pure (ForInStep.done (Prod.mk (some $val) $u)))
| Kind.nestedBC => unreachable!
| Kind.nestedPR => ``(Pure.pure (DoResultPR.«return» $val $u))
| Kind.nestedSBC => ``(Pure.pure (DoResultSBC.«pureReturn» $val $u))
| Kind.nestedPRBC => ``(Pure.pure (DoResultPRBC.«return» $val $u))
def continueToTerm : M Syntax := do
let ctx ← read
let u ← mkUVarTuple
match ctx.kind with
| Kind.regular => unreachable!
| Kind.forIn => ``(Pure.pure (ForInStep.yield $u))
| Kind.forInWithReturn => ``(Pure.pure (ForInStep.yield (Prod.mk none $u)))
| Kind.nestedBC => ``(Pure.pure (DoResultBC.«continue» $u))
| Kind.nestedPR => unreachable!
| Kind.nestedSBC => ``(Pure.pure (DoResultSBC.«continue» $u))
| Kind.nestedPRBC => ``(Pure.pure (DoResultPRBC.«continue» $u))
def breakToTerm : M Syntax := do
let ctx ← read
let u ← mkUVarTuple
match ctx.kind with
| Kind.regular => unreachable!
| Kind.forIn => ``(Pure.pure (ForInStep.done $u))
| Kind.forInWithReturn => ``(Pure.pure (ForInStep.done (Prod.mk none $u)))
| Kind.nestedBC => ``(Pure.pure (DoResultBC.«break» $u))
| Kind.nestedPR => unreachable!
| Kind.nestedSBC => ``(Pure.pure (DoResultSBC.«break» $u))
| Kind.nestedPRBC => ``(Pure.pure (DoResultPRBC.«break» $u))
def actionTerminalToTerm (action : Syntax) : M Syntax := withRef action <| withFreshMacroScope do
let ctx ← read
let u ← mkUVarTuple
let m := ctx.m
match ctx.kind with
| Kind.regular => if ctx.uvars.isEmpty then pure action else ``(HBind.hBind (m := $m) (n := $m) $action fun y => Pure.pure (Prod.mk y $u))
| Kind.forIn => ``(HBind.hBind (m := $m) (n := $m) $action fun (_ : PUnit) => Pure.pure (ForInStep.yield $u))
| Kind.forInWithReturn => ``(HBind.hBind (m := $m) (n := $m) $action fun (_ : PUnit) => Pure.pure (ForInStep.yield (Prod.mk none $u)))
| Kind.nestedBC => unreachable!
| Kind.nestedPR => ``(HBind.hBind (m := $m) (n := $m) $action fun y => (Pure.pure (DoResultPR.«pure» y $u)))
| Kind.nestedSBC => ``(HBind.hBind (m := $m) (n := $m) $action fun y => (Pure.pure (DoResultSBC.«pureReturn» y $u)))
| Kind.nestedPRBC => ``(HBind.hBind (m := $m) (n := $m) $action fun y => (Pure.pure (DoResultPRBC.«pure» y $u)))
def seqToTerm (action : Syntax) (k : Syntax) : M Syntax := withRef action <| withFreshMacroScope do
if action.getKind == ``Lean.Parser.Term.doDbgTrace then
let msg := action[1]
`(dbg_trace $msg; $k)
else if action.getKind == ``Lean.Parser.Term.doAssert then
let cond := action[1]
`(assert! $cond; $k)
else
let m := (←read).m
let action ← withRef action ``(($action : $m PUnit))
``(HBind.hBind (m := $m) (n := $m) $action (fun (_ : PUnit) => $k))
def declToTerm (decl : Syntax) (k : Syntax) : M Syntax := withRef decl <| withFreshMacroScope do
let kind := decl.getKind
if kind == ``Lean.Parser.Term.doLet then
let letDecl := decl[2]
`(let $letDecl:letDecl; $k)
else if kind == ``Lean.Parser.Term.doLetRec then
let letRecToken := decl[0]
let letRecDecls := decl[1]
return mkNode ``Lean.Parser.Term.letrec #[letRecToken, letRecDecls, mkNullNode, k]
else if kind == ``Lean.Parser.Term.doLetArrow then
let arg := decl[2]
if arg.getKind == ``Lean.Parser.Term.doIdDecl then
let id := arg[0]
let type := expandOptType id arg[1]
let doElem := arg[3]
-- `doElem` must be a `doExpr action`. See `doLetArrowToCode`
match isDoExpr? doElem with
| some action =>
let m := (←read).m
let action ← withRef action `(($action : $m $type))
``(HBind.hBind (m := $m) (n := $m) $action (fun ($id:ident : $type) => $k))
| none => Macro.throwErrorAt decl "unexpected kind of 'do' declaration"
else
Macro.throwErrorAt decl "unexpected kind of 'do' declaration"
else if kind == ``Lean.Parser.Term.doHave then
-- The `have` term is of the form `"have " >> haveDecl >> optSemicolon termParser`
let args := decl.getArgs
let args := args ++ #[mkNullNode /- optional ';' -/, k]
return mkNode `Lean.Parser.Term.«have» args
else
Macro.throwErrorAt decl "unexpected kind of 'do' declaration"
def reassignToTerm (reassign : Syntax) (k : Syntax) : MacroM Syntax := withRef reassign <| withFreshMacroScope do
match reassign with
| `(doElem| $x:ident := $rhs) => `(let $x:ident := ensure_type_of% $x $(quote "invalid reassignment, value") $rhs; $k)
| `(doElem| $e:term := $rhs) => `(let $e:term := ensure_type_of% $e $(quote "invalid reassignment, value") $rhs; $k)
| _ =>
-- Note that `doReassignArrow` is expanded by `doReassignArrowToCode
Macro.throwErrorAt reassign "unexpected kind of 'do' reassignment"
def mkIte (optIdent : Syntax) (cond : Syntax) (thenBranch : Syntax) (elseBranch : Syntax) : MacroM Syntax := do
if optIdent.isNone then
``(if $cond then $thenBranch else $elseBranch)
else
let h := optIdent[0]
``(if $h:ident : $cond then $thenBranch else $elseBranch)
def mkJoinPoint (j : Name) (ps : Array (Syntax × Bool)) (body : Syntax) (k : Syntax) : M Syntax := withRef body <| withFreshMacroScope do
let pTypes ← ps.mapM fun ⟨id, useTypeOf⟩ => do if useTypeOf then `(type_of% $id) else `(_)
let ps := ps.map (·.1)
/-
We use `let_delayed` instead of `let` for joinpoints to make sure `$k` is elaborated before `$body`.
By elaborating `$k` first, we "learn" more about `$body`'s type.
For example, consider the following example `do` expression
```
def f (x : Nat) : IO Unit := do
if x > 0 then
IO.println "x is not zero" -- Error is here
IO.mkRef true
```
it is expanded into
```
def f (x : Nat) : IO Unit := do
let jp (u : Unit) : IO _ :=
IO.mkRef true;
if x > 0 then
IO.println "not zero"
jp ()
else
jp ()
```
If we use the regular `let` instead of `let_delayed`, the joinpoint `jp` will be elaborated and its type will be inferred to be `Unit → IO (IO.Ref Bool)`.
Then, we get a typing error at `jp ()`. By using `let_delayed`, we first elaborate `if x > 0 ...` and learn that `jp` has type `Unit → IO Unit`.
Then, we get the expected type mismatch error at `IO.mkRef true`. -/
`(let_delayed $(← mkIdentFromRef j):ident $[($ps : $pTypes)]* : $((← read).m) _ := $body; $k)
def mkJmp (ref : Syntax) (j : Name) (args : Array Syntax) : Syntax :=
Syntax.mkApp (mkIdentFrom ref j) args
partial def toTerm (c : Code) : M Syntax := do
match c with
| Code.return ref val => withRef ref <| returnToTerm val
| Code.continue ref => withRef ref continueToTerm
| Code.break ref => withRef ref breakToTerm
| Code.action e => actionTerminalToTerm e
| Code.joinpoint j ps b k => mkJoinPoint j ps (← toTerm b) (← toTerm k)
| Code.jmp ref j args => return mkJmp ref j args
| Code.decl _ stx k => declToTerm stx (← toTerm k)
| Code.reassign _ stx k => reassignToTerm stx (← toTerm k)
| Code.seq stx k => seqToTerm stx (← toTerm k)
| Code.ite ref _ o c t e => withRef ref <| do mkIte o c (← toTerm t) (← toTerm e)
| Code.«match» ref genParam discrs optMotive alts =>
let mut termAlts := #[]
for alt in alts do
let rhs ← toTerm alt.rhs
let termAlt := mkNode `Lean.Parser.Term.matchAlt #[mkAtomFrom alt.ref "|", mkNullNode #[alt.patterns], mkAtomFrom alt.ref "=>", rhs]
termAlts := termAlts.push termAlt
let termMatchAlts := mkNode `Lean.Parser.Term.matchAlts #[mkNullNode termAlts]
return mkNode `Lean.Parser.Term.«match» #[mkAtomFrom ref "match", genParam, optMotive, discrs, mkAtomFrom ref "with", termMatchAlts]
def run (code : Code) (m : Syntax) (returnType : Syntax) (uvars : Array Var := #[]) (kind := Kind.regular) : MacroM Syntax :=
toTerm code { m, returnType, kind, uvars }
/- Given
- `a` is true if the code block has a `Code.action _` exit point
- `r` is true if the code block has a `Code.return _ _` exit point
- `bc` is true if the code block has a `Code.break _` or `Code.continue _` exit point
generate Kind. See comment at the beginning of the `ToTerm` namespace. -/
def mkNestedKind (a r bc : Bool) : Kind :=
match a, r, bc with
| true, false, false => .regular
| false, true, false => .regular
| false, false, true => .nestedBC
| true, true, false => .nestedPR
| true, false, true => .nestedSBC
| false, true, true => .nestedSBC
| true, true, true => .nestedPRBC
| false, false, false => unreachable!
def mkNestedTerm (code : Code) (m : Syntax) (returnType : Syntax) (uvars : Array Var) (a r bc : Bool) : MacroM Syntax := do
ToTerm.run code m returnType uvars (mkNestedKind a r bc)
/- Given a term `term` produced by `ToTerm.run`, pattern match on its result.
See comment at the beginning of the `ToTerm` namespace.
- `a` is true if the code block has a `Code.action _` exit point
- `r` is true if the code block has a `Code.return _ _` exit point
- `bc` is true if the code block has a `Code.break _` or `Code.continue _` exit point
The result is a sequence of `doElem` -/
def matchNestedTermResult (term : Syntax) (uvars : Array Var) (a r bc : Bool) : MacroM (List Syntax) := do
let toDoElems (auxDo : Syntax) : List Syntax := getDoSeqElems (getDoSeq auxDo)
let u ← mkTuple uvars
match a, r, bc with
| true, false, false =>
if uvars.isEmpty then
return toDoElems (← `(do $term:term))
else
return toDoElems (← `(do let r ← $term:term; $u:term := r.2; pure r.1))
| false, true, false =>
if uvars.isEmpty then
return toDoElems (← `(do let r ← $term:term; return r))
else
return toDoElems (← `(do let r ← $term:term; $u:term := r.2; return r.1))
| false, false, true => toDoElems <$>
`(do let r ← $term:term;
match r with
| DoResultBC.«break» u => $u:term := u; break
| DoResultBC.«continue» u => $u:term := u; continue)
| true, true, false => toDoElems <$>
`(do let r ← $term:term;
match r with
| DoResultPR.«pure» a u => $u:term := u; pure a
| DoResultPR.«return» b u => $u:term := u; return b)
| true, false, true => toDoElems <$>
`(do let r ← $term:term;
match r with
| DoResultSBC.«pureReturn» a u => $u:term := u; pure a
| DoResultSBC.«break» u => $u:term := u; break
| DoResultSBC.«continue» u => $u:term := u; continue)
| false, true, true => toDoElems <$>
`(do let r ← $term:term;
match r with
| DoResultSBC.«pureReturn» a u => $u:term := u; return a
| DoResultSBC.«break» u => $u:term := u; break
| DoResultSBC.«continue» u => $u:term := u; continue)
| true, true, true => toDoElems <$>
`(do let r ← $term:term;
match r with
| DoResultPRBC.«pure» a u => $u:term := u; pure a
| DoResultPRBC.«return» a u => $u:term := u; return a
| DoResultPRBC.«break» u => $u:term := u; break
| DoResultPRBC.«continue» u => $u:term := u; continue)
| false, false, false => unreachable!
end ToTerm
def isMutableLet (doElem : Syntax) : Bool :=
let kind := doElem.getKind
(kind == `Lean.Parser.Term.doLetArrow || kind == `Lean.Parser.Term.doLet)
&&
!doElem[1].isNone
namespace ToCodeBlock
structure Context where
ref : Syntax
/-- Syntax representing the monad associated with the do notation. -/
m : Syntax
/-- Syntax to reference the result of the monadic computation performed by the do notation. -/
returnType : Syntax
mutableVars : VarSet := {}
insideFor : Bool := false
abbrev M := ReaderT Context TermElabM
def withNewMutableVars {α} (newVars : Array Var) (mutable : Bool) (x : M α) : M α :=
withReader (fun ctx => if mutable then { ctx with mutableVars := insertVars ctx.mutableVars newVars } else ctx) x
def checkReassignable (xs : Array Var) : M Unit := do
let throwInvalidReassignment (x : Name) : M Unit :=
throwError "'{x.simpMacroScopes}' cannot be reassigned"
let ctx ← read
for x in xs do
unless ctx.mutableVars.contains x.getId do
throwInvalidReassignment x.getId
def checkNotShadowingMutable (xs : Array Var) : M Unit := do
let throwInvalidShadowing (x : Name) : M Unit :=
throwError "mutable variable '{x.simpMacroScopes}' cannot be shadowed"
let ctx ← read
for x in xs do
if ctx.mutableVars.contains x.getId then
throwInvalidShadowing x.getId
def withFor {α} (x : M α) : M α :=
withReader (fun ctx => { ctx with insideFor := true }) x
structure ToForInTermResult where
uvars : Array Var
term : Syntax
def mkForInBody (_ : Syntax) (forInBody : CodeBlock) : M ToForInTermResult := do
let ctx ← read
let uvars := forInBody.uvars
let uvars := varSetToArray uvars
let term ← liftMacroM <| ToTerm.run forInBody.code ctx.m ctx.returnType uvars (if hasReturn forInBody.code then ToTerm.Kind.forInWithReturn else ToTerm.Kind.forIn)
return ⟨uvars, term⟩
def ensureInsideFor : M Unit :=
unless (← read).insideFor do
throwError "invalid 'do' element, it must be inside 'for'"
def ensureEOS (doElems : List Syntax) : M Unit :=
unless doElems.isEmpty do
throwError "must be last element in a 'do' sequence"
private partial def expandLiftMethodAux (inQuot : Bool) (inBinder : Bool) : Syntax → StateT (List Syntax) M Syntax
| stx@(Syntax.node i k args) =>
if liftMethodDelimiter k then
return stx
else if k == ``Lean.Parser.Term.liftMethod && !inQuot then withFreshMacroScope do
if inBinder then
throwErrorAt stx "cannot lift `(<- ...)` over a binder, this error usually happens when you are trying to lift a method nested in a `fun`, `let`, or `match`-alternative, and it can often be fixed by adding a missing `do`"
let term := args[1]!
let term ← expandLiftMethodAux inQuot inBinder term
let auxDoElem : Syntax ← `(doElem| let a ← $term:term)
modify fun s => s ++ [auxDoElem]
`(a)
else do
let inAntiquot := stx.isAntiquot && !stx.isEscapedAntiquot
let inBinder := inBinder || (!inQuot && liftMethodForbiddenBinder stx)
let args ← args.mapM (expandLiftMethodAux (inQuot && !inAntiquot || stx.isQuot) inBinder)
return Syntax.node i k args
| stx => return stx
def expandLiftMethod (doElem : Syntax) : M (List Syntax × Syntax) := do
if !hasLiftMethod doElem then
return ([], doElem)
else
let (doElem, doElemsNew) ← (expandLiftMethodAux false false doElem).run []
return (doElemsNew, doElem)
def checkLetArrowRHS (doElem : Syntax) : M Unit := do
let kind := doElem.getKind
if kind == ``Lean.Parser.Term.doLetArrow ||
kind == ``Lean.Parser.Term.doLet ||
kind == ``Lean.Parser.Term.doLetRec ||
kind == ``Lean.Parser.Term.doHave ||
kind == ``Lean.Parser.Term.doReassign ||
kind == ``Lean.Parser.Term.doReassignArrow then
throwErrorAt doElem "invalid kind of value '{kind}' in an assignment"
/- Generate `CodeBlock` for `doReturn` which is of the form
```
"return " >> optional termParser
```
`doElems` is only used for sanity checking. -/
def doReturnToCode (doReturn : Syntax) (doElems: List Syntax) : M CodeBlock := withRef doReturn do
ensureEOS doElems
let argOpt := doReturn[1]
let arg ← if argOpt.isNone then liftMacroM mkUnit else pure argOpt[0]
return mkReturn (← getRef) arg
structure Catch where
x : Syntax
optType : Syntax
codeBlock : CodeBlock
def getTryCatchUpdatedVars (tryCode : CodeBlock) (catches : Array Catch) (finallyCode? : Option CodeBlock) : VarSet :=
let ws := tryCode.uvars
let ws := catches.foldl (init := ws) fun ws alt => union alt.codeBlock.uvars ws
let ws := match finallyCode? with
| none => ws
| some c => union c.uvars ws
ws
def tryCatchPred (tryCode : CodeBlock) (catches : Array Catch) (finallyCode? : Option CodeBlock) (p : Code → Bool) : Bool :=
p tryCode.code ||
catches.any (fun «catch» => p «catch».codeBlock.code) ||
match finallyCode? with
| none => false
| some finallyCode => p finallyCode.code
mutual
/- "Concatenate" `c` with `doSeqToCode doElems` -/
partial def concatWith (c : CodeBlock) (doElems : List Syntax) : M CodeBlock :=
match doElems with
| [] => pure c
| nextDoElem :: _ => do
let k ← doSeqToCode doElems
let ref := nextDoElem
concat c ref none k
/- Generate `CodeBlock` for `doLetArrow; doElems`
`doLetArrow` is of the form
```
"let " >> optional "mut " >> (doIdDecl <|> doPatDecl)
```
where
```
def doIdDecl := leading_parser ident >> optType >> leftArrow >> doElemParser
def doPatDecl := leading_parser termParser >> leftArrow >> doElemParser >> optional (" | " >> doElemParser)
```
-/
partial def doLetArrowToCode (doLetArrow : Syntax) (doElems : List Syntax) : M CodeBlock := do
let decl := doLetArrow[2]
if decl.getKind == ``Lean.Parser.Term.doIdDecl then
let y := decl[0]
checkNotShadowingMutable #[y]
let doElem := decl[3]
let k ← withNewMutableVars #[y] (isMutableLet doLetArrow) (doSeqToCode doElems)
match isDoExpr? doElem with
| some _ => return mkVarDeclCore #[y] doLetArrow k
| none =>
checkLetArrowRHS doElem
let c ← doSeqToCode [doElem]
match doElems with
| [] => pure c
| kRef::_ => concat c kRef y k
else if decl.getKind == ``Lean.Parser.Term.doPatDecl then
let pattern := decl[0]
let doElem := decl[2]
let optElse := decl[3]
if optElse.isNone then withFreshMacroScope do
let auxDo ← if isMutableLet doLetArrow then
`(do let discr ← $doElem; let mut $pattern:term := discr)
else
`(do let discr ← $doElem; let $pattern:term := discr)
doSeqToCode <| getDoSeqElems (getDoSeq auxDo) ++ doElems
else
if isMutableLet doLetArrow then
throwError "'mut' is currently not supported in let-decls with 'else' case"
let contSeq := mkDoSeq doElems.toArray
let elseSeq := mkSingletonDoSeq optElse[1]
let auxDo ← `(do let discr ← $doElem; match discr with | $pattern:term => $contSeq | _ => $elseSeq)
doSeqToCode <| getDoSeqElems (getDoSeq auxDo)
else
throwError "unexpected kind of 'do' declaration"
partial def doLetElseToCode (doLetElse : Syntax) (doElems : List Syntax) : M CodeBlock := do
-- "let " >> termParser >> " := " >> termParser >> checkColGt >> " | " >> doElemParser
let pattern := doLetElse[1]
let val := doLetElse[3]
let elseSeq := mkSingletonDoSeq doLetElse[5]
let contSeq := mkDoSeq doElems.toArray
let auxDo ← `(do let discr := $val; match discr with | $pattern:term => $contSeq | _ => $elseSeq)
doSeqToCode <| getDoSeqElems (getDoSeq auxDo)
/- Generate `CodeBlock` for `doReassignArrow; doElems`
`doReassignArrow` is of the form
```
(doIdDecl <|> doPatDecl)
```
-/
partial def doReassignArrowToCode (doReassignArrow : Syntax) (doElems : List Syntax) : M CodeBlock := do
let decl := doReassignArrow[0]
if decl.getKind == ``Lean.Parser.Term.doIdDecl then
let doElem := decl[3]
let y := decl[0]
let auxDo ← `(do let r ← $doElem; $y:ident := r)
doSeqToCode <| getDoSeqElems (getDoSeq auxDo) ++ doElems
else if decl.getKind == ``Lean.Parser.Term.doPatDecl then
let pattern := decl[0]
let doElem := decl[2]
let optElse := decl[3]
if optElse.isNone then withFreshMacroScope do
let auxDo ← `(do let discr ← $doElem; $pattern:term := discr)
doSeqToCode <| getDoSeqElems (getDoSeq auxDo) ++ doElems
else
throwError "reassignment with `|` (i.e., \"else clause\") is not currently supported"
else
throwError "unexpected kind of 'do' reassignment"
/- Generate `CodeBlock` for `doIf; doElems`
`doIf` is of the form
```
"if " >> optIdent >> termParser >> " then " >> doSeq
>> many (group (try (group (" else " >> " if ")) >> optIdent >> termParser >> " then " >> doSeq))
>> optional (" else " >> doSeq)
``` -/
partial def doIfToCode (doIf : Syntax) (doElems : List Syntax) : M CodeBlock := do
let view ← liftMacroM $ mkDoIfView doIf
let thenBranch ← doSeqToCode (getDoSeqElems view.thenBranch)
let elseBranch ← doSeqToCode (getDoSeqElems view.elseBranch)
let ite ← mkIte view.ref view.optIdent view.cond thenBranch elseBranch
concatWith ite doElems
/- Generate `CodeBlock` for `doUnless; doElems`
`doUnless` is of the form
```
"unless " >> termParser >> "do " >> doSeq
``` -/
partial def doUnlessToCode (doUnless : Syntax) (doElems : List Syntax) : M CodeBlock := withRef doUnless do
let cond := doUnless[1]
let doSeq := doUnless[3]
let body ← doSeqToCode (getDoSeqElems doSeq)
let unlessCode ← liftMacroM <| mkUnless cond body
concatWith unlessCode doElems
/- Generate `CodeBlock` for `doFor; doElems`
`doFor` is of the form
```
def doForDecl := leading_parser termParser >> " in " >> withForbidden "do" termParser
def doFor := leading_parser "for " >> sepBy1 doForDecl ", " >> "do " >> doSeq
```
-/
partial def doForToCode (doFor : Syntax) (doElems : List Syntax) : M CodeBlock := do
let doForDecls := doFor[1].getSepArgs
if doForDecls.size > 1 then
/-
Expand
```
for x in xs, y in ys do
body
```
into
```
let s := toStream ys
for x in xs do
match Stream.next? s with
| none => break
| some (y, s') =>
s := s'
body
```
-/
-- Extract second element
let doForDecl := doForDecls[1]!
unless doForDecl[0].isNone do
throwErrorAt doForDecl[0] "the proof annotation here has not been implemented yet"
let y := doForDecl[1]
let ys := doForDecl[3]
let doForDecls := doForDecls.eraseIdx 1
let body := doFor[3]
withFreshMacroScope do
/- Recall that `@` (explicit) disables `coeAtOutParam`.
We used `@` at `Stream` functions to make sure `resultIsOutParamSupport` is not used. -/
let toStreamApp ← withRef ys `(@toStream _ _ _ $ys)
let auxDo ←
`(do let mut s := $toStreamApp:term
for $doForDecls:doForDecl,* do
match @Stream.next? _ _ _ s with
| none => break
| some ($y, s') =>
s := s'
do $body)
doSeqToCode (getDoSeqElems (getDoSeq auxDo) ++ doElems)
else withRef doFor do
let h? := if doForDecls[0]![0].isNone then none else some doForDecls[0]![0][0]
let x := doForDecls[0]![1]
withRef x <| checkNotShadowingMutable (← getPatternVarsEx x)
let xs := doForDecls[0]![3]
let forElems := getDoSeqElems doFor[3]
let forInBodyCodeBlock ← withFor (doSeqToCode forElems)
let ⟨uvars, forInBody⟩ ← mkForInBody x forInBodyCodeBlock
let ctx ← read
-- semantic no-op that replaces the `uvars`' position information (which all point inside the loop)
-- with that of the respective mutable declarations outside the loop, which allows the language
-- server to identify them as conceptually identical variables
let uvars := uvars.map fun v => ctx.mutableVars.findD v.getId v
let uvarsTuple ← liftMacroM do mkTuple uvars
if hasReturn forInBodyCodeBlock.code then
let forInBody ← liftMacroM <| destructTuple uvars (← `(r)) forInBody
let optType ← `(Option $((← read).returnType))
let forInTerm ← if let some h := h? then
`(for_in'% $(xs) (Prod.mk (none : $optType) $uvarsTuple) fun $x $h (r : MProd $optType _) => let r := r.2; $forInBody)
else
`(for_in% $(xs) (Prod.mk (none : $optType) $uvarsTuple) fun $x (r : MProd $optType _) => let r := r.2; $forInBody)
let auxDo ← `(do let r ← $forInTerm:term;
$uvarsTuple:term := r.2;
match r.1 with
| none => Pure.pure (ensure_expected_type% "type mismatch, 'for'" PUnit.unit)
| some a => return ensure_expected_type% "type mismatch, 'for'" a)
doSeqToCode (getDoSeqElems (getDoSeq auxDo) ++ doElems)
else
let forInBody ← liftMacroM <| destructTuple uvars (← `(r)) forInBody
let forInTerm ← if let some h := h? then
`(for_in'% $(xs) $uvarsTuple fun $x $h r => $forInBody)
else
`(for_in% $(xs) $uvarsTuple fun $x r => $forInBody)
if doElems.isEmpty then
let auxDo ← `(do let r ← $forInTerm:term;
$uvarsTuple:term := r;
Pure.pure (ensure_expected_type% "type mismatch, 'for'" PUnit.unit))
doSeqToCode <| getDoSeqElems (getDoSeq auxDo)
else
let auxDo ← `(do let r ← $forInTerm:term; $uvarsTuple:term := r)
doSeqToCode <| getDoSeqElems (getDoSeq auxDo) ++ doElems
/-- Generate `CodeBlock` for `doMatch; doElems` -/
partial def doMatchToCode (doMatch : Syntax) (doElems: List Syntax) : M CodeBlock := do
let ref := doMatch
let genParam := doMatch[1]
let optMotive := doMatch[2]
let discrs := doMatch[3]
let matchAlts := doMatch[5][0].getArgs -- Array of `doMatchAlt`
let matchAlts ← matchAlts.foldlM (init := #[]) fun result matchAlt => return result ++ (← liftMacroM <| expandMatchAlt matchAlt)
let alts ← matchAlts.mapM fun matchAlt => do
let patterns := matchAlt[1][0]
let vars ← getPatternsVarsEx patterns.getSepArgs
withRef patterns <| checkNotShadowingMutable vars
let rhs := matchAlt[3]
let rhs ← doSeqToCode (getDoSeqElems rhs)
pure { ref := matchAlt, vars := vars, patterns := patterns, rhs := rhs : Alt CodeBlock }
let matchCode ← mkMatch ref genParam discrs optMotive alts
concatWith matchCode doElems
/--
Generate `CodeBlock` for `doTry; doElems`
```
def doTry := leading_parser "try " >> doSeq >> many (doCatch <|> doCatchMatch) >> optional doFinally
def doCatch := leading_parser "catch " >> binderIdent >> optional (":" >> termParser) >> darrow >> doSeq
def doCatchMatch := leading_parser "catch " >> doMatchAlts
def doFinally := leading_parser "finally " >> doSeq
```
-/
partial def doTryToCode (doTry : Syntax) (doElems: List Syntax) : M CodeBlock := do
let tryCode ← doSeqToCode (getDoSeqElems doTry[1])
let optFinally := doTry[3]
let catches ← doTry[2].getArgs.mapM fun catchStx : Syntax => do
if catchStx.getKind == ``Lean.Parser.Term.doCatch then
let x := catchStx[1]
if x.isIdent then
withRef x <| checkNotShadowingMutable #[x]
let optType := catchStx[2]
let c ← doSeqToCode (getDoSeqElems catchStx[4])
return { x := x, optType := optType, codeBlock := c : Catch }
else if catchStx.getKind == ``Lean.Parser.Term.doCatchMatch then
let matchAlts := catchStx[1]
let x ← `(ex)
let auxDo ← `(do match ex with $matchAlts)
let c ← doSeqToCode (getDoSeqElems (getDoSeq auxDo))
return { x := x, codeBlock := c, optType := mkNullNode : Catch }
else
throwError "unexpected kind of 'catch'"
let finallyCode? ← if optFinally.isNone then pure none else some <$> doSeqToCode (getDoSeqElems optFinally[0][1])
if catches.isEmpty && finallyCode?.isNone then
throwError "invalid 'try', it must have a 'catch' or 'finally'"
let ctx ← read
let ws := getTryCatchUpdatedVars tryCode catches finallyCode?
let uvars := varSetToArray ws
let a := tryCatchPred tryCode catches finallyCode? hasTerminalAction
let r := tryCatchPred tryCode catches finallyCode? hasReturn
let bc := tryCatchPred tryCode catches finallyCode? hasBreakContinue
let toTerm (codeBlock : CodeBlock) : M Syntax := do
let codeBlock ← liftM $ extendUpdatedVars codeBlock ws
liftMacroM <| ToTerm.mkNestedTerm codeBlock.code ctx.m ctx.returnType uvars a r bc
let term ← toTerm tryCode
let term ← catches.foldlM (init := term) fun term «catch» => do
let catchTerm ← toTerm «catch».codeBlock
if catch.optType.isNone then
``(MonadExcept.tryCatch $term (fun $(«catch».x):ident => $catchTerm))
else
let type := «catch».optType[1]
``(tryCatchThe $type $term (fun $(«catch».x):ident => $catchTerm))
let term ← match finallyCode? with
| none => pure term
| some finallyCode => withRef optFinally do
unless finallyCode.uvars.isEmpty do
throwError "'finally' currently does not support reassignments"
if hasBreakContinueReturn finallyCode.code then
throwError "'finally' currently does 'return', 'break', nor 'continue'"
let finallyTerm ← liftMacroM <| ToTerm.run finallyCode.code ctx.m ctx.returnType {} ToTerm.Kind.regular
``(tryFinally $term $finallyTerm)
let doElemsNew ← liftMacroM <| ToTerm.matchNestedTermResult term uvars a r bc
doSeqToCode (doElemsNew ++ doElems)
partial def doSeqToCode : List Syntax → M CodeBlock
| [] => do liftMacroM mkPureUnitAction
| doElem::doElems => withIncRecDepth <| withRef doElem do
checkMaxHeartbeats "'do'-expander"
match (← liftMacroM <| expandMacro? doElem) with
| some doElem => doSeqToCode (doElem::doElems)
| none =>
match (← liftMacroM <| expandDoIf? doElem) with
| some doElem => doSeqToCode (doElem::doElems)
| none =>
let (liftedDoElems, doElem) ← expandLiftMethod doElem
if !liftedDoElems.isEmpty then
doSeqToCode (liftedDoElems ++ [doElem] ++ doElems)
else
let ref := doElem
let k := doElem.getKind
if k == ``Lean.Parser.Term.doLet then
let vars ← getDoLetVars doElem
checkNotShadowingMutable vars
mkVarDeclCore vars doElem <$> withNewMutableVars vars (isMutableLet doElem) (doSeqToCode doElems)
else if k == ``Lean.Parser.Term.doHave then
let vars ← getDoHaveVars doElem
checkNotShadowingMutable vars
mkVarDeclCore vars doElem <$> (doSeqToCode doElems)
else if k == ``Lean.Parser.Term.doLetRec then
let vars ← getDoLetRecVars doElem
checkNotShadowingMutable vars
mkVarDeclCore vars doElem <$> (doSeqToCode doElems)
else if k == ``Lean.Parser.Term.doReassign then
let vars ← getDoReassignVars doElem
checkReassignable vars
let k ← doSeqToCode doElems
mkReassignCore vars doElem k
else if k == ``Lean.Parser.Term.doLetArrow then
doLetArrowToCode doElem doElems
else if k == ``Lean.Parser.Term.doLetElse then
doLetElseToCode doElem doElems
else if k == ``Lean.Parser.Term.doReassignArrow then
doReassignArrowToCode doElem doElems
else if k == ``Lean.Parser.Term.doIf then
doIfToCode doElem doElems
else if k == ``Lean.Parser.Term.doUnless then
doUnlessToCode doElem doElems
else if k == ``Lean.Parser.Term.doFor then withFreshMacroScope do
doForToCode doElem doElems
else if k == ``Lean.Parser.Term.doMatch then
doMatchToCode doElem doElems
else if k == ``Lean.Parser.Term.doTry then
doTryToCode doElem doElems
else if k == ``Lean.Parser.Term.doBreak then
ensureInsideFor
ensureEOS doElems
return mkBreak ref
else if k == ``Lean.Parser.Term.doContinue then
ensureInsideFor
ensureEOS doElems
return mkContinue ref
else if k == ``Lean.Parser.Term.doReturn then
doReturnToCode doElem doElems
else if k == ``Lean.Parser.Term.doDbgTrace then
return mkSeq doElem (← doSeqToCode doElems)
else if k == ``Lean.Parser.Term.doAssert then
return mkSeq doElem (← doSeqToCode doElems)
else if k == ``Lean.Parser.Term.doNested then
let nestedDoSeq := doElem[1]
doSeqToCode (getDoSeqElems nestedDoSeq ++ doElems)
else if k == ``Lean.Parser.Term.doExpr then
let term := doElem[0]
if doElems.isEmpty then
return mkTerminalAction term
else
return mkSeq term (← doSeqToCode doElems)
else
throwError "unexpected do-element of kind {doElem.getKind}:\n{doElem}"
end
def run (doStx : Syntax) (m : Syntax) (returnType : Syntax) : TermElabM CodeBlock :=
(doSeqToCode <| getDoSeqElems <| getDoSeq doStx).run { ref := doStx, m, returnType }
end ToCodeBlock
/- HBind: The elaborator for `do` aliases the monad through a metavariable to
embed its `Term` into `Syntax`. But metavariables can't be universe
polymorphic, so we instead hack and create a quantified external definition,
then return the name of that definition. -/
private def mkMonadAlias (m : Expr) : TermElabM Syntax := do
let levelParams := collectLevelParams {} m |>.params
let mType ← inferType m
let name ← mkFreshUserName `hdoMonadAlias
let decl := Declaration.defnDecl {
name := name, levelParams := levelParams.toList, type := mType,
value := m, hints := ReducibilityHints.abbrev,
safety := DefinitionSafety.safe
}
ensureNoUnassignedMVars decl
addAndCompile decl
Term.applyAttributes name #[{ name := `inline }, { name := `reducible }]
return mkIdent name
-- HDO: This elaborates like the normal do command (but with Prod/HBind)
@[termElab «hdo»] def elabHDo : TermElab := fun stx expectedType? => do
tryPostponeIfNoneOrMVar expectedType?
let bindInfo ← extractBind expectedType?
let bindInfo ← generalizeBindUniverse bindInfo
let m ← mkMonadAlias bindInfo.m
let returnType ← Term.exprToSyntax bindInfo.returnType
let codeBlock ← ToCodeBlock.run stx m returnType
let stxNew ← liftMacroM <| ToTerm.run codeBlock.code m returnType
trace[Elab.do] stxNew
withMacroExpansion stx stxNew <| elabTermEnsuringType stxNew bindInfo.expectedType
-- HDO: Variation with additional information for testing
@[termElab «hdo_2»] def elabHDo2 : TermElab := fun stx expectedType? => do
match stx with
| `(hdo (monad := $stx_monad:term) $stx_seq) =>
let stx ← `(hdo $stx_seq)
let monad ← elabTerm stx_monad none
trace[Elab.do] s!"Manually-specified monad: {monad}: {← inferType monad}"
tryPostponeIfNoneOrMVar expectedType?
let bindInfo ← extractBind expectedType?
let m ← mkMonadAlias monad
let returnType ← Term.exprToSyntax bindInfo.returnType
let codeBlock ← ToCodeBlock.run stx m returnType
let stxNew ← liftMacroM <| ToTerm.run codeBlock.code m returnType
trace[Elab.do] stxNew
withMacroExpansion stx stxNew <| elabTermEnsuringType stxNew bindInfo.expectedType
| _ => throwError "unrecognized syntax for hdo_2"
end HDo
end Lean.Elab.Term
|
\chapter{Combination of Events}
\section{Important/Useful Theorems}
\subsection{}
\begin{equation}
P(A|B) = \frac{P(AB)}{P(B)}
\end{equation}
\subsection{}
If $A = \bigcup{}_k A_k$ where $A_k$ are all mutually exclusive
\begin{equation}
P(A|B) = \sum_k P(A_k|B)
\end{equation}
\subsection{}
The events $A_1, A_2, A_3, ..., A_n$ are said to be statistically independent if
\begin{eqnarray*}
P(A_i A_j) = P(A_i)P(A_j) \\
P(A_i A_j A_k) = P(A_i)P(A_j)P(A_k) \\
... \\
P(A_1 A_2 A_3...A_n) = P(A_1)P(A_2)P(A_3)...P(A_n)
\end{eqnarray*}
For all possible combinations of the indeces.
\subsection{Second Borel-Cantelli lemma}
If the events $A_1, A_2, A_3, ...$ are all statistically independent and $p_k = P(A_k$
\begin{equation}
\sum_{k=1}^\infty p_k = \infty
\end{equation}
\section{Answers to Problems}
%answer template
\subsection{}
%problem 3.1
We need to examine $A(\bar{A}B)$ , $A \overline{A \cup B}$ and $(\bar{A}B) \overline{A \cup B}$.
\begin{equation}
A(\bar{A}B) = A\bar{A}B = 0
\end{equation}
since $A$ will not overlap with its complement at all
\begin{equation}
A \overline{A \cup B} = A \bar{A}\bar{B} = 0
\end{equation}
for the same reason
\begin{equation}
(\bar{A}B) \overline{A \cup B} = \bar{A}B \bar{A}\bar{B} = 0
\end{equation}
again for the same reason.
Clearly, since none of the three proposed events intersect at all with any of the others, these events are mutually exclusive and cannot happen in concert.
\textbf{Answer not verified}
\subsection{}
%problem 3.2
To get $C$ to be mutually exclusive, its overlap with both $B$ and $A$ must be zero, giving a logical conclusion of:
\begin{equation}
C = \bar{A}\bar{B}
\label{answer3.2}
To put it in English, the mutually exclusive outcomes of a chess match are, white wins, black wins and neither wins (a draw).
\end{equation}
\textbf{Answer not verified}
\subsection{}
%problem 3.3
\begin{equation}
P(A|B) = \frac{P(AB)}{P(B)} = \frac{P(BA)}{P(B)} \frac{P(A)}{P(A)} = P(B|A) \frac{P(A)}{P(B)} > P(A)
\end{equation}
\begin{equation}
P(B|A) > P(B)
\label{answer3.3}
\end{equation}
\textbf{Answer not verified}
\subsection{}
%problem 3.4
\begin{equation}
P(A|B) = \frac{P(AB)}{P(B)} = \frac{3}{2} P(AB)
\end{equation}
We can come up for an expression for $P(AB)$ in terms of $P(A\cup B)$ with a little algebra.
\begin{equation}
P(A \cup B) = P(A) +P(B) - P(AB) = \frac{4}{3} - P(AB)
\end{equation}
clearly $P(A \cup B)$ must be between 0 and 1.
\begin{equation}
1 \geq \frac{4}{3} - P(AB) \geq 0
\end{equation}
\begin{equation}
-\frac{1}{3} \geq - P(AB) \geq -\frac{4}{3}
\end{equation}
\begin{equation}
\frac{1}{3} \leq P(AB) \leq \frac{4}{3}
\end{equation}
\begin{equation}
\frac{1}{3} \leq \frac{2}{3} P(A|B) \leq \frac{4}{3}
\end{equation}
\begin{equation}
\frac{1}{2} \leq P(A|B) \leq 2
\end{equation}
\begin{equation}
\frac{1}{2} \leq P(A|B)
\label{answer3.4}
\end{equation}
\textbf{Answer not verified}
\subsection{}
%problem 3.5
\begin{equation}
P(A)P(B|A)P(C|AB) = P(A)\frac{P(BA)}{P(A)} \frac{P(ABC)}{P(AB)} = P(ABC)
\end{equation}
Simple enough, but now we need a general theorem
\begin{equation}
P\left( \bigcap_{k=1}^n A_k \right) = P(A_1)P(A_2|A_1)P(A_3|A_1A_2)P(A_4|A_1A_2A_3) ... P\left(A_n| \bigcap_{k=1}^{n-1} A_k \right)
\end{equation}
\begin{equation}
P\left( \bigcap_{k=1}^n A_k \right) = P(A_1) \prod_{z=2}^n} P\left(A_z| \bigcap_{k=1}^{z-1} A_k \right)
\label{answer3.5}
\end{equation}
\textbf{Answer not verified}
\subsection{}
%problem 3.6
\begin{equation}
P(A) = P(A|B) + P(A|\bar{B}) = \frac{P(AB)}{P(B)} + \frac{P(A\bar{B})}{P(\bar{B})}
\end{equation}
\subsubsection{$A=0$}
\begin{equation}
P(0) = \frac{P(0)}{P(B)} + \frac{P(0)}{P(\bar{B})} = 0
\end{equation}
Because the intersection with nothing is nothing.
\subsubsection{$B=0$}
\begin{equation}
P(A) = \frac{P(0)}{P(0)} + \frac{P(A\Omega)}{P(\Omega)} = P(A)
\end{equation}
\subsubsection{$B=\Omega$}
\begin{equation}
P(A) = \frac{P(A\Omega)}{P(\Omega)} + \frac{P(0)}{P(0)} = P(A)
\end{equation}
\subsubsection{$B=A$}
\begin{equation}
P(A) = \frac{P(AA)}{P(A)} + \frac{P(A\bar{A})}{P(\bar{A})} = 1 ???
\end{equation}
I cannot prove this to be true
\subsubsection{$B=\bar{A}$}
\begin{equation}
P(A) = \frac{P(A\bar{A})}{P(\bar{A})} + \frac{P(AA)}{P(A)} = 1 ???
\end{equation}
I cannot prove this to be true
\textbf{Answer not verified}
\subsection{}
%problem 3.7
We start knowing:
\begin{equation}
P(AB) = P(A)P(B)
\end{equation}
But we want to prove:
\begin{equation}
P(\bar{A}\bar{B}) = P(\bar{A})P(\bar{B})
\end{equation}
as the problem suggests
\begin{equation}
P(B|A) + P(\bar{B}|A) = 1
\end{equation}
\begin{equation}
\frac{P(BA)}{P(A)} + \frac{P(A\bar{B})}{P(A)} = 1
\end{equation}
\begin{equation}
P(B) + \frac{P(A\bar{B})}{P(A)} = 1
\end{equation}
\begin{equation}
\frac{P(A\bar{B})}{P(A)} = 1 - P(B)
\end{equation}
\begin{equation}
P(A\bar{B}) = \left(1 - P(B)\right)P(A)
\end{equation}
\begin{equation}
P(A\bar{B}) = P(\bar{B})P(A)
\end{equation}
so clearly $A \text{ and } \bar{B}$ are independent. Since we have just proved that for two events that are independent, we can show that one of the events is independent of the others complement, without loss of generality, we can apply this logic recursively, thus proving that if two events are independent, so are their complements.
\textbf{Answer not verified}
\subsection{}
%problem 3.8
Given two mutually exclusive events, we wonder if they are dependent.
\begin{equation}
P(AB) = 0
\end{equation}
but in order for them to be independent, we need to be able to say
\begin{equation}
P(AB) = P(A)P(B)
\end{equation}
but we were told that $P(A)$ and $P(B)$ are positive, therefore they are \textbf{NOT} independent!
\textbf{Answer not verified}
\subsection{}
%problem 3.9
Let $A_i$ be the event of getting a white ball at the $i^{th}$ urn. Since there are 2 possibilities for each step, there are $2^n$ different ways to do this ``experiment''. Clearly
\begin{equation}
P(A_1) = \frac{w}{w+b}
\end{equation}
but things get more complicated as $i>1$. Here there are two mutually exclusive possibilities: we got a white one or we got a black one from the first urn.
\begin{equation}
P(A_2) = P(A_2|A_1)P(A_1) + P(A_2|\bar{A_1})P(\bar{A_1})
\end{equation}
\begin{equation}
P(A_2) = P(A_2A_1) + P(A_2\bar{A_1})
\end{equation}
For both denominators, there were $w+b$ possibilities to begin with and $w+b+1$ for the second. Then, there were $w$ ways to get white first and $b$ ways to get black first. Then, respectively, there would be $w+1$ ways and $w$ ways to get white for the second urn.
\begin{equation}
P(A_2) = \frac{1}{(w+b)(w+b+1)} \left( w(w+1) + bw \right)
\end{equation}
\begin{equation}
P(A_2) = \frac{w(w+b+1)}{(w+b)(w+b+1)} = \frac{w}{w+b}
\end{equation}
Since we started off with $\frac{w}{w+b}$ and then got the same answer for the second step, if we were to do it for a third step, a fourth step, etc. we would be starting with the same initial conditions and would get the same answer therefore this is true in general for $n$ urns.
\textbf{Answer not verified}
\subsection{}
%problem 3.10
Labelling the points starting from the left, we know that
\begin{eqnarray}
P(C_1|B_1) = \frac{1}{3} = P(C_2|B_1) \\
P(C_3|B_2) = \frac{1}{2} \\
P(C_4|B_4) = \frac{1}{5} = P(C_5|B_4) = P(C_6|B_4)
\end{eqnarray}
Since there's only one way to get to each of these specified end-points, the total probabilities are just the conditional probabilities times the probabilities of the conditions.
\begin{eqnarray}
P(C_1) = P(C_1|B_1)P(B_1) = \frac{1}{12} = P(C_2) \\
P(C_3) = P(C_3|B_2)P(B_2) = \frac{1}{8} \\
P(C_4) = P(C_4|B_4)P(B_4) = \frac{1}{20} = P(C_5) = P(C_6)
\end{eqnarray}
So when we combine all these possibilities with the probability of getting to $A$:
\begin{equation}
\frac{67}{120} + \frac{2}{12} + \frac{1}{8} + \frac{3}{20} = 1
\label{answer3.10}
\end{equation}
\textbf{Answer not verified}
\subsection{}
%problem 3.11
Let's go from 1 dollar stakes to $q$ dollar stakes; all the other variables stay the same.
\begin{equation}
p(x) = \frac{1}{2} \left[ p(x+q) + p(x-q) \right], q \leq x \leq m - q
\end{equation}
but the boundary conditions do not change. Therefore, there is no change here between the original linear equation and the new linear equation. Thus:
\begin{equation}
p(x) = 1 - \frac{x}{m}
\label{answer3.11}
\end{equation}
\textbf{Answer not verified}
\subsection{}
%problem 3.12
\begin{equation}
P(B|A) = P(B | \bar{A})
\end{equation}
but let's work on the assumption they are not independent
\begin{eqnarray*}
\frac{P(AB)}{P(A)} = \frac{P(\bar{A}B)}{\bar{A}} \\
\frac{P(AB)}{P(\bar{A}B)} = \frac{P(A)}{P(\bar{A})}
\end{eqnarray*}
but now let's factor out the expression for the intersection, leaving some error behind
\begin{eqnarray*}
\frac{P(A)P(B)\epsilon}{P(\bar{A})P(B)\epsilon{}'} = \frac{P(A)}{P(\bar{A})} \\
\frac{P(A)\epsilon}{P(\bar{A})\epsilon{}'} = \frac{P(A)}{P(\bar{A})}
\end{eqnarray*}
The only way for this to always be true is for both error terms to be the same and the only way for it to be true for arbitrary events is for them to both be one such that $A$ and $B$ are independent.
\textbf{Answer not verified}
\subsection{}
%problem 3.13
There are four mutually exclusive outcomes for the first step: getting two whites, one white and zero whites($A_2, A_1, A_0$). We'll call the last event we want to turn out white, $B$.
\begin{equation}
P(B) = P(B|A_2)P(A_2) + P(B|A_1)P(A_1) + P(B|A_0)P(A_0)
\end{equation}
\begin{eqnarray}
P(B|A_2)P(A_2) = 1 \frac{w_1 w_2}{(w_1 + b_1)(w_2 + b_2)}\\
P(B|A_1)P(A_1) = \frac{1}{2} \frac{w_1 b_2 + w_2 b_1}{(w_1 + b_1)(w_2 + b_2)} \\
P(B|A_0)P(A_0) = 0
\end{eqnarray}
putting it together
\begin{eqnarray}
P(B) = \frac{1}{2} \frac{w_1 b_2 + w_2 b_1 + 2 w_1 w_2}{(w_1 + b_1)(w_2 + b_2)} \\
P(B) = \frac{1}{2} \frac{(w_1 +b_1 )w_2 + (w_2 + b_2) w_1 }{(w_1 + b_1)(w_2 + b_2)} \\
P(B) = \frac{1}{2} \left( \frac{w_1}{w_1+b_1} + \frac{w_2}{w_2+b_2} \right)
\end{eqnarray}
\textbf{Answer not verified}
\subsection{}
%problem 3.14
As the hint suggests, we'll use Bayes' Rule. Our set of mutually exclusive events $\{ B_i\}$ are the getting of the ball from the $i^{th}$ urn and $A$ is the event of getting a white ball. So we want the probability of choosing the odd urn out (we'll call it $B_k$) given that we got a white ball.
\begin{equation}
P(B_k|A) = \frac{P(B_k)P(A|B_k)}{\sum_{i=1}^{10} P(B_i)P(A|B_i}
\end{equation}
For all $i$, $P(B_i) = \frac{1}{10}$ and for $i \neq k$ $P(A|B_i) = \frac{1}{2}$ but for $i=k$, $P(A|B_k) = \frac{5}{6}$
\begin{equation}
P(B_k|A) = \frac{\frac{5}{6 \cdot 10}}{9\frac{1}{20} + \frac{5}{6 \cdot 10}} = \frac{5}{32}
\end{equation}
\textbf{Answer verified}
\subsection{}
%problem 2.15
To do this problem, let's figure out what the chance is that we picked the all-white urn, the event $B_1$. $A$ is the event we pick a white ball and $B_@$ is the event of picking the other urn with $\frac{3}{4}$ white balls.
\begin{equation}
P(B_1|A) = \frac{P(B_1)P(A|B_1)}{P(B_1)P(A|B_1) + P(B_2)P(A|B_2)} = \frac{\frac{1}{2}}{\frac{1}{2} + \frac{1}{2} \frac{3}{4}} = \frac{4}{7}
\end{equation}
Thus, there is a $\frac{3}{7}$ chance we chose the urn that actually has black balls in it and a $\frac{1}{4}$ chance that from that urn once chooses a black ball giving an overall probability of picking a black ball given the information in the problem of $\frac{3}{28}$.
\textbf{Answer verified}
\subsection{}
%problem 2.16
\textbf{SKIPPED}: unsure of meaning of problem.
\subsection{}
%problem 2.17
Clearly $P(A) = \frac{1}{2} = P(B) = P(C)$ and $P(AB) = \frac{1}{4} = P(BC) = P(AC)$ because there is only one place out of four for the die to hit both letters. There is, however, still only one way to hit all three letters at once such that $P(ABC)=\frac{1}{4}$ therefore the events in question are pairwise independent since for all sets of letters $P(AB)=P(A)P(B)$ but not completely independent since $P(ABC) \neq P(A)P(B)P(C)$.
\textbf{Answer not verified}
\subsection{}
%problem 2.18
\textbf{SKIPPED}: didn't feel like doing the problem... so there.
%%answer template
%\subsection{}
%%problem n.n
%
%
%\begin{equation}
%
%\label{answern.n}
%\end{equation}
%\textbf{Answer [not] verified}
|
############################################################################
### Types
############################################################################
struct ImplyEmpty{V, V2} <: SemImply
start_val::V
identifier::V2
end
############################################################################
### Constructors
############################################################################
function ImplyEmpty(;
specification = nothing,
start_val = start_fabin3,
kwargs...)
if !isa(start_val, Vector)
if specification isa RAMMatrices
ram_matrices = specification
identifier = StructuralEquationModels.identifier(ram_matrices)
elseif specification isa ParameterTable
ram_matrices = RAMMatrices!(specification)
identifier = StructuralEquationModels.identifier(ram_matrices)
else
throw(ErrorException("The RAM constructor does not know how to handle your specification object.
\n Please specify your model as either a ParameterTable or RAMMatrices."))
end
start_val = start_val(;ram_matrices = ram_matrices, specification = specification, kwargs...)
end
return ImplyEmpty(start_val, identifier)
end
############################################################################
### functors
############################################################################
function (imply::ImplyEmpty)(par, F, G, H, model) end
############################################################################
### Recommended methods
############################################################################
identifier(imply::ImplyEmpty) = imply.identifier
n_par(imply::ImplyEmpty) = imply.n_par
update_observed(imply::ImplyEmpty, observed::SemObs; kwargs...) = imply
############################################################################
### Pretty Printing
############################################################################
function Base.show(io::IO, struct_inst::ImplyEmpty)
print_type_name(io, struct_inst)
print_field_types(io, struct_inst)
end |
(* Title: Sturm-Tarski Theorem
Author: Wenda Li <[email protected] / [email protected]>
*)
section "Sturm-Tarski Theorem"
theory Sturm_Tarski
imports Complex_Main PolyMisc "HOL-Computational_Algebra.Field_as_Ring"
begin
section\<open>Misc\<close>
lemma eventually_at_right:
fixes x::"'a::{archimedean_field,linorder_topology}"
shows "eventually P (at_right x) \<longleftrightarrow> (\<exists>b>x. \<forall>y>x. y < b \<longrightarrow> P y)"
proof -
obtain y where "y>x" using ex_less_of_int by auto
thus ?thesis using eventually_at_right[OF \<open>y>x\<close>] by auto
qed
lemma eventually_at_left:
fixes x::"'a::{archimedean_field,linorder_topology}"
shows "eventually P (at_left x) \<longleftrightarrow> (\<exists>b<x. \<forall>y>b. y < x \<longrightarrow> P y)"
proof -
obtain y where "y<x"
using linordered_field_no_lb by auto
thus ?thesis using eventually_at_left[OF \<open>y<x\<close>] by auto
qed
lemma eventually_neg:
assumes "F\<noteq>bot" and eve:"eventually (\<lambda>x. P x) F"
shows "\<not> eventually (\<lambda>x. \<not> P x) F"
proof (rule ccontr)
assume "\<not> \<not> eventually (\<lambda>x. \<not> P x) F"
hence "eventually (\<lambda>x. \<not> P x) F" by auto
hence "eventually (\<lambda>x. False) F" using eventually_conj[OF eve,of "(\<lambda>x. \<not> P x)"] by auto
thus False using \<open>F\<noteq>bot\<close> eventually_False by auto
qed
lemma poly_tendsto[simp]:
"(poly p \<longlongrightarrow> poly p x) (at (x::real))"
"(poly p \<longlongrightarrow> poly p x) (at_left (x::real))"
"(poly p \<longlongrightarrow> poly p x) (at_right (x::real))"
using isCont_def[where f="poly p"] by (auto simp add:filterlim_at_split)
lemma not_eq_pos_or_neg_iff_1:
fixes p::"real poly"
shows "(\<forall>z. lb<z\<and>z\<le>ub\<longrightarrow>poly p z\<noteq>0) \<longleftrightarrow>
(\<forall>z. lb<z\<and>z\<le>ub\<longrightarrow>poly p z>0)\<or>(\<forall>z. lb<z\<and>z\<le>ub\<longrightarrow>poly p z<0)" (is "?Q \<longleftrightarrow> ?P")
proof (rule,rule ccontr)
assume "?Q" "\<not>?P"
then obtain z1 z2 where z1:"lb<z1" "z1\<le>ub" "poly p z1\<le>0"
and z2:"lb<z2" "z2\<le>ub" "poly p z2\<ge>0"
by auto
hence "\<exists>z. lb<z\<and>z\<le>ub\<and>poly p z=0"
proof (cases "poly p z1 = 0 \<or> poly p z2 =0 \<or> z1=z2")
case True
thus ?thesis using z1 z2 by auto
next
case False
hence "poly p z1<0" and "poly p z2>0" and "z1\<noteq>z2" using z1(3) z2(3) by auto
hence "(\<exists>z>z1. z < z2 \<and> poly p z = 0) \<or> (\<exists>z>z2. z < z1 \<and> poly p z = 0)"
using poly_IVT_neg poly_IVT_pos by (subst (asm) linorder_class.neq_iff,auto)
thus ?thesis using z1(1,2) z2(1,2) by (metis less_eq_real_def order.strict_trans2)
qed
thus False using \<open>?Q\<close> by auto
next
assume "?P"
thus ?Q by auto
qed
lemma not_eq_pos_or_neg_iff_2:
fixes p::"real poly"
shows "(\<forall>z. lb\<le>z\<and>z<ub\<longrightarrow>poly p z\<noteq>0)
\<longleftrightarrow>(\<forall>z. lb\<le>z\<and>z<ub\<longrightarrow>poly p z>0)\<or>(\<forall>z. lb\<le>z\<and>z<ub\<longrightarrow>poly p z<0)" (is "?Q\<longleftrightarrow>?P")
proof (rule,rule ccontr)
assume "?Q" "\<not>?P"
then obtain z1 z2 where z1:"lb\<le>z1" "z1<ub" "poly p z1\<le>0"
and z2:"lb\<le>z2" "z2<ub" "poly p z2\<ge>0"
by auto
hence "\<exists>z. lb\<le>z\<and>z<ub\<and>poly p z=0"
proof (cases "poly p z1 = 0 \<or> poly p z2 =0 \<or> z1=z2")
case True
thus ?thesis using z1 z2 by auto
next
case False
hence "poly p z1<0" and "poly p z2>0" and "z1\<noteq>z2" using z1(3) z2(3) by auto
hence "(\<exists>z>z1. z < z2 \<and> poly p z = 0) \<or> (\<exists>z>z2. z < z1 \<and> poly p z = 0)"
using poly_IVT_neg poly_IVT_pos by (subst (asm) linorder_class.neq_iff,auto)
thus ?thesis using z1(1,2) z2(1,2) by (meson dual_order.strict_trans not_le)
qed
thus False using \<open>?Q\<close> by auto
next
assume "?P"
thus ?Q by auto
qed
lemma next_non_root_interval:
fixes p::"real poly"
assumes "p\<noteq>0"
obtains ub where "ub>lb" and "(\<forall>z. lb<z\<and>z\<le>ub\<longrightarrow>poly p z\<noteq>0)"
proof (cases "(\<exists> r. poly p r=0 \<and> r>lb)")
case False
thus ?thesis by (intro that[of "lb+1"],auto)
next
case True
define lr where "lr\<equiv>Min {r . poly p r=0 \<and> r>lb}"
have "\<forall>z. lb<z\<and>z<lr\<longrightarrow>poly p z\<noteq>0" and "lr>lb"
using True lr_def poly_roots_finite[OF \<open>p\<noteq>0\<close>] by auto
thus ?thesis using that[of "(lb+lr)/2"] by auto
qed
lemma last_non_root_interval:
fixes p::"real poly"
assumes "p\<noteq>0"
obtains lb where "lb<ub" and "(\<forall>z. lb\<le>z\<and>z<ub\<longrightarrow>poly p z\<noteq>0)"
proof (cases "(\<exists> r. poly p r=0 \<and> r<ub)")
case False
thus ?thesis by (intro that[of "ub - 1"]) auto
next
case True
define mr where "mr\<equiv>Max {r . poly p r=0 \<and> r<ub}"
have "\<forall>z. mr<z\<and>z<ub\<longrightarrow>poly p z\<noteq>0" and "mr<ub"
using True mr_def poly_roots_finite[OF \<open>p\<noteq>0\<close>] by auto
thus ?thesis using that[of "(mr+ub)/2"] \<open>mr<ub\<close> by auto
qed
section\<open>Bound of polynomials\<close>
definition sgn_pos_inf :: "('a ::linordered_idom) poly \<Rightarrow> 'a" where
"sgn_pos_inf p \<equiv> sgn (lead_coeff p)"
definition sgn_neg_inf :: "('a ::linordered_idom) poly \<Rightarrow> 'a" where
"sgn_neg_inf p \<equiv> if even (degree p) then sgn (lead_coeff p) else -sgn (lead_coeff p)"
lemma sgn_inf_sym:
fixes p::"real poly"
shows "sgn_pos_inf (pcompose p [:0,-1:]) = sgn_neg_inf p" (is "?L=?R")
proof -
have "?L= sgn (lead_coeff p * (- 1) ^ degree p)"
unfolding sgn_pos_inf_def by (subst lead_coeff_comp,auto)
thus ?thesis unfolding sgn_neg_inf_def
by (metis mult.right_neutral mult_minus1_right neg_one_even_power neg_one_odd_power sgn_minus)
qed
lemma poly_pinfty_gt_lc:
fixes p:: "real poly"
assumes "lead_coeff p > 0"
shows "\<exists> n. \<forall> x \<ge> n. poly p x \<ge> lead_coeff p" using assms
proof (induct p)
case 0
thus ?case by auto
next
case (pCons a p)
have "\<lbrakk>a\<noteq>0;p=0\<rbrakk> \<Longrightarrow> ?case" by auto
moreover have "p\<noteq>0 \<Longrightarrow> ?case"
proof -
assume "p\<noteq>0"
then obtain n1 where gte_lcoeff:"\<forall>x\<ge>n1. lead_coeff p \<le> poly p x" using that pCons by auto
have gt_0:"lead_coeff p >0" using pCons(3) \<open>p\<noteq>0\<close> by auto
define n where "n\<equiv>max n1 (1+ \<bar>a\<bar>/(lead_coeff p))"
show ?thesis
proof (rule_tac x=n in exI,rule,rule)
fix x assume "n \<le> x"
hence "lead_coeff p \<le> poly p x"
using gte_lcoeff unfolding n_def by auto
hence " \<bar>a\<bar>/(lead_coeff p) \<ge> \<bar>a\<bar>/(poly p x)" and "poly p x>0" using gt_0
by (intro frac_le,auto)
hence "x\<ge>1+ \<bar>a\<bar>/(poly p x)" using \<open>n\<le>x\<close>[unfolded n_def] by auto
thus "lead_coeff (pCons a p) \<le> poly (pCons a p) x"
using \<open>lead_coeff p \<le> poly p x\<close> \<open>poly p x>0\<close> \<open>p\<noteq>0\<close>
by (auto simp add:field_simps)
qed
qed
ultimately show ?case by fastforce
qed
lemma poly_sgn_eventually_at_top:
fixes p::"real poly"
shows "eventually (\<lambda>x. sgn (poly p x) = sgn_pos_inf p) at_top"
proof (cases "p=0")
case True
thus ?thesis unfolding sgn_pos_inf_def by auto
next
case False
obtain ub where ub:"\<forall>x\<ge>ub. sgn (poly p x) = sgn_pos_inf p"
proof (cases "lead_coeff p>0")
case True
thus ?thesis
using that poly_pinfty_gt_lc[of p] unfolding sgn_pos_inf_def by fastforce
next
case False
hence "lead_coeff (-p) > 0" and "lead_coeff p < 0" unfolding lead_coeff_minus
using leading_coeff_neq_0[OF \<open>p\<noteq>0\<close>]
by (auto simp add:not_less_iff_gr_or_eq)
then obtain n where "\<forall>x\<ge>n. lead_coeff p \<ge> poly p x"
using poly_pinfty_gt_lc[of "-p"] unfolding lead_coeff_minus by auto
thus ?thesis using \<open>lead_coeff p<0\<close> that[of n] unfolding sgn_pos_inf_def by fastforce
qed
thus ?thesis unfolding eventually_at_top_linorder by auto
qed
lemma poly_sgn_eventually_at_bot:
fixes p::"real poly"
shows "eventually (\<lambda>x. sgn (poly p x) = sgn_neg_inf p) at_bot"
using
poly_sgn_eventually_at_top[of "pcompose p [:0,-1:]",unfolded poly_pcompose sgn_inf_sym,simplified]
eventually_filtermap[of _ uminus "at_bot::real filter",folded at_top_mirror]
by auto
lemma root_ub:
fixes p:: "real poly"
assumes "p\<noteq>0"
obtains ub where "\<forall>x. poly p x=0 \<longrightarrow> x<ub"
and "\<forall>x\<ge>ub. sgn (poly p x) = sgn_pos_inf p"
proof -
obtain ub1 where ub1:"\<forall>x. poly p x=0 \<longrightarrow> x<ub1"
proof (cases "\<exists> r. poly p r=0")
case False
thus ?thesis using that by auto
next
case True
define max_r where "max_r\<equiv>Max {x . poly p x=0}"
hence "\<forall>x. poly p x=0 \<longrightarrow> x\<le>max_r"
using poly_roots_finite[OF \<open>p\<noteq>0\<close>] True by auto
thus ?thesis using that[of "max_r+1"]
by (metis add.commute add_strict_increasing zero_less_one)
qed
obtain ub2 where ub2:"\<forall>x\<ge>ub2. sgn (poly p x) = sgn_pos_inf p"
using poly_sgn_eventually_at_top[unfolded eventually_at_top_linorder] by auto
define ub where "ub\<equiv>max ub1 ub2"
have "\<forall>x. poly p x=0 \<longrightarrow> x<ub" using ub1 ub_def
by (metis eq_iff less_eq_real_def less_linear max.bounded_iff)
thus ?thesis using that[of ub] ub2 ub_def by auto
qed
lemma root_lb:
fixes p:: "real poly"
assumes "p\<noteq>0"
obtains lb where "\<forall>x. poly p x=0 \<longrightarrow> x>lb"
and "\<forall>x\<le>lb. sgn (poly p x) = sgn_neg_inf p"
proof -
obtain lb1 where lb1:"\<forall>x. poly p x=0 \<longrightarrow> x>lb1"
proof (cases "\<exists> r. poly p r=0")
case False
thus ?thesis using that by auto
next
case True
define min_r where "min_r\<equiv>Min {x . poly p x=0}"
hence "\<forall>x. poly p x=0 \<longrightarrow> x\<ge>min_r"
using poly_roots_finite[OF \<open>p\<noteq>0\<close>] True by auto
thus ?thesis using that[of "min_r - 1"] by (metis lt_ex order.strict_trans2 that)
qed
obtain lb2 where lb2:"\<forall>x\<le>lb2. sgn (poly p x) = sgn_neg_inf p"
using poly_sgn_eventually_at_bot[unfolded eventually_at_bot_linorder] by auto
define lb where "lb\<equiv>min lb1 lb2"
have "\<forall>x. poly p x=0 \<longrightarrow> x>lb" using lb1 lb_def
by (metis (poly_guards_query) less_not_sym min_less_iff_conj neq_iff)
thus ?thesis using that[of lb] lb2 lb_def by auto
qed
section\<open>Sign\<close>
definition sign:: "'a::{zero,linorder} \<Rightarrow> int" where
"sign x\<equiv>(if x>0 then 1 else if x=0 then 0 else -1)"
lemma sign_simps[simp]:
"x>0 \<Longrightarrow> sign x=1"
"x=0 \<Longrightarrow> sign x=0"
"x<0 \<Longrightarrow> sign x=-1"
unfolding sign_def by auto
lemma sign_cases [case_names neg zero pos]:
"(sign x = -1 \<Longrightarrow> P) \<Longrightarrow> (sign x = 0 \<Longrightarrow> P) \<Longrightarrow> (sign x =1 \<Longrightarrow> P) \<Longrightarrow> P"
unfolding Sturm_Tarski.sign_def by argo
lemma sign_times:
fixes x::"'a::linordered_ring_strict"
shows "sign (x*y) = sign x * sign y"
unfolding Sturm_Tarski.sign_def
by (auto simp add:zero_less_mult_iff)
lemma sign_power:
fixes x::"'a::linordered_idom"
shows "sign (x^n) = (if n=0 then 1 else if even n then \<bar>sign x\<bar> else sign x)"
by (simp add: Sturm_Tarski.sign_def zero_less_power_eq)
lemma sgn_sign_eq:
fixes x::"'a::{linordered_idom}"
shows "sgn x = of_int (sign x)"
unfolding sgn_if by auto
section \<open>Variation and cross\<close>
definition variation :: "real \<Rightarrow> real \<Rightarrow> int" where
"variation x y=(if x*y\<ge>0 then 0 else if x<y then 1 else -1)"
definition cross :: "real poly \<Rightarrow> real \<Rightarrow> real \<Rightarrow> int" where
"cross p a b=variation (poly p a) (poly p b)"
lemma variation_0[simp]: "variation 0 y=0" "variation x 0=0"
unfolding variation_def by auto
lemma variation_comm: "variation x y= - variation y x" unfolding variation_def
by (auto simp add: mult.commute)
lemma variation_cases:
"\<lbrakk>x>0;y>0\<rbrakk>\<Longrightarrow>variation x y = 0"
"\<lbrakk>x>0;y<0\<rbrakk>\<Longrightarrow>variation x y = -1"
"\<lbrakk>x<0;y>0\<rbrakk>\<Longrightarrow>variation x y = 1"
"\<lbrakk>x<0;y<0\<rbrakk>\<Longrightarrow>variation x y = 0"
proof -
show "\<lbrakk>x>0;y>0\<rbrakk>\<Longrightarrow>variation x y = 0" unfolding variation_def by auto
show "\<lbrakk>x>0;y<0\<rbrakk>\<Longrightarrow>variation x y = -1" unfolding variation_def
using mult_pos_neg by fastforce
show "\<lbrakk>x<0;y>0\<rbrakk>\<Longrightarrow>variation x y = 1" unfolding variation_def
using mult_neg_pos by fastforce
show "\<lbrakk>x<0;y<0\<rbrakk>\<Longrightarrow>variation x y = 0" unfolding variation_def
using mult_neg_neg by fastforce
qed
lemma variation_congr:
assumes "sgn x=sgn x'" "sgn y=sgn y'"
shows "variation x y=variation x' y'" using assms
proof -
have " 0 \<le> x * y = (0\<le> x' * y')" using assms by (metis Real_Vector_Spaces.sgn_mult zero_le_sgn_iff)
moreover hence "\<not> 0\<le>x * y \<Longrightarrow> x < y = (x' < y')" using assms
by (metis less_eq_real_def mult_nonneg_nonneg mult_nonpos_nonpos not_le order.strict_trans2
zero_le_sgn_iff)
ultimately show ?thesis unfolding variation_def by auto
qed
lemma variation_mult_pos:
assumes "c>0"
shows "variation (c*x) y =variation x y" and "variation x (c*y) =variation x y"
proof -
have "sgn (c*x) = sgn x" using \<open>c>0\<close>
by (simp add: Real_Vector_Spaces.sgn_mult)
thus "variation (c*x) y =variation x y" using variation_congr by blast
next
have "sgn (c*y) = sgn y" using \<open>c>0\<close>
by (simp add: Real_Vector_Spaces.sgn_mult)
thus "variation x (c*y) =variation x y" using variation_congr by blast
qed
lemma variation_mult_neg_1:
assumes "c<0"
shows "variation (c*x) y =variation x y + (if y=0 then 0 else sign x)"
apply (cases x rule:linorder_cases[of 0] )
apply (cases y rule:linorder_cases[of 0], auto simp add:
variation_cases mult_neg_pos[OF \<open>c<0\<close>,of x] mult_neg_neg[OF \<open>c<0\<close>,of x])+
done
lemma variation_mult_neg_2:
assumes "c<0"
shows "variation x (c*y) = variation x y + (if x=0 then 0 else - sign y)"
unfolding variation_comm[of x "c*y", unfolded variation_mult_neg_1[OF \<open>c<0\<close>, of y x] ]
by (auto,subst variation_comm,simp)
lemma cross_no_root:
assumes "a<b" and no_root:"\<forall>x. a<x\<and>x<b \<longrightarrow> poly p x\<noteq>0"
shows "cross p a b=0"
proof -
have "\<lbrakk>poly p a>0;poly p b<0\<rbrakk> \<Longrightarrow> False" using poly_IVT_neg[OF \<open>a<b\<close>] no_root by auto
moreover have "\<lbrakk>poly p a<0;poly p b>0\<rbrakk> \<Longrightarrow> False" using poly_IVT_pos[OF \<open>a<b\<close>] no_root by auto
ultimately have "0 \<le> poly p a * poly p b"
by (metis less_eq_real_def linorder_neqE_linordered_idom mult_less_0_iff)
thus ?thesis unfolding cross_def variation_def by simp
qed
section \<open>Tarski query\<close>
definition taq :: "'a::linordered_idom set \<Rightarrow> 'a poly \<Rightarrow> int" where
"taq s q \<equiv> \<Sum>x\<in>s. sign (poly q x)"
section \<open>Sign at the right\<close>
definition sign_r_pos :: "real poly \<Rightarrow> real \<Rightarrow> bool "
where
"sign_r_pos p x\<equiv> (eventually (\<lambda>x. poly p x>0) (at_right x))"
lemma sign_r_pos_rec:
fixes p:: "real poly"
assumes "p\<noteq>0"
shows "sign_r_pos p x= (if poly p x=0 then sign_r_pos (pderiv p) x else poly p x>0 )"
proof (cases "poly p x=0")
case True
have "sign_r_pos (pderiv p) x \<Longrightarrow> sign_r_pos p x"
proof (rule ccontr)
assume "sign_r_pos (pderiv p) x" "\<not> sign_r_pos p x"
obtain b where "b>x" and b:"\<forall>z. x < z \<and> z < b \<longrightarrow> 0 < poly (pderiv p) z"
using \<open>sign_r_pos (pderiv p) x\<close> unfolding sign_r_pos_def eventually_at_right by auto
have "\<forall>b>x. \<exists>z>x. z < b \<and> \<not> 0 < poly p z" using \<open>\<not> sign_r_pos p x\<close>
unfolding sign_r_pos_def eventually_at_right by auto
then obtain z where "z>x" and "z<b" and "poly p z\<le>0"
using \<open>b>x\<close> b by auto
hence "\<exists>z'>x. z' < z \<and> poly p z = (z - x) * poly (pderiv p) z'"
using poly_MVT[OF \<open>z>x\<close>] True by (metis diff_0_right)
hence "\<exists>z'>x. z' < z \<and> poly (pderiv p) z' \<le>0"
using \<open>poly p z\<le>0\<close>\<open>z>x\<close> by (metis leD le_iff_diff_le_0 mult_le_0_iff)
thus False using b by (metis \<open>z < b\<close> dual_order.strict_trans not_le)
qed
moreover have "sign_r_pos p x \<Longrightarrow> sign_r_pos (pderiv p) x"
proof -
assume "sign_r_pos p x"
have "pderiv p\<noteq>0" using \<open>poly p x=0\<close> \<open>p\<noteq>0\<close>
by (metis monoid_add_class.add.right_neutral monom_0 monom_eq_0 mult_zero_right
pderiv_iszero poly_0 poly_pCons)
obtain ub where "ub>x" and ub: "(\<forall>z. x<z\<and>z<ub\<longrightarrow>poly (pderiv p) z>0)
\<or> (\<forall>z. x<z\<and>z<ub\<longrightarrow>poly (pderiv p) z<0)"
using next_non_root_interval[OF \<open>pderiv p\<noteq>0\<close>, of x,unfolded not_eq_pos_or_neg_iff_1]
by (metis order.strict_implies_order)
have "\<forall>z. x<z\<and>z<ub\<longrightarrow>poly (pderiv p) z<0 \<Longrightarrow> False"
proof -
assume assm:"\<forall>z. x<z\<and>z<ub\<longrightarrow>poly (pderiv p) z<0"
obtain ub' where "ub'>x" and ub':"\<forall>z. x < z \<and> z < ub' \<longrightarrow> 0 < poly p z"
using \<open>sign_r_pos p x\<close> unfolding sign_r_pos_def eventually_at_right by auto
obtain z' where "x<z'" and "z' < (x+(min ub' ub))/2"
and z':"poly p ((x+min ub' ub)/2) = ((x+min ub' ub)/2 - x) * poly (pderiv p) z'"
using poly_MVT[of x "(x+min ub' ub)/2" p] \<open>ub'>x\<close> \<open>ub>x\<close> True by auto
moreover have "0 < poly p ((x+min ub' ub)/2)"
using ub'[THEN HOL.spec,of "(x+(min ub' ub))/2"] \<open>z' < (x+min ub' ub)/2\<close> \<open>x<z'\<close>
by auto
moreover have "(x+min ub' ub)/2 - x>0" using \<open>ub'>x\<close> \<open>ub>x\<close> by auto
ultimately have "poly (pderiv p) z'>0" by (metis zero_less_mult_pos)
thus False using assm[THEN spec,of z'] \<open>x<z'\<close> \<open>z' < (x+(min ub' ub))/2\<close> by auto
qed
hence "\<forall>z. x<z\<and>z<ub\<longrightarrow>poly (pderiv p) z>0" using ub by auto
thus "sign_r_pos (pderiv p) x" unfolding sign_r_pos_def eventually_at_right
using \<open>ub>x\<close> by auto
qed
ultimately show ?thesis using True by auto
next
case False
have "sign_r_pos p x \<Longrightarrow> poly p x>0"
proof (rule ccontr)
assume "sign_r_pos p x" "\<not> 0 < poly p x"
then obtain ub where "ub>x" and ub: "\<forall>z. x < z \<and> z < ub \<longrightarrow> 0 < poly p z"
unfolding sign_r_pos_def eventually_at_right by auto
hence "poly p ((ub+x)/2) > 0" by auto
moreover have "poly p x<0" using \<open>\<not> 0 < poly p x\<close> False by auto
ultimately have "\<exists>z>x. z < (ub + x) / 2 \<and> poly p z = 0"
using poly_IVT_pos[of x "((ub + x) / 2)" p] \<open>ub>x\<close> by auto
thus False using ub by auto
qed
moreover have "poly p x>0 \<Longrightarrow> sign_r_pos p x"
unfolding sign_r_pos_def
using order_tendstoD(1)[OF poly_tendsto(1),of 0 p x] eventually_at_split by auto
ultimately show ?thesis using False by auto
qed
lemma sign_r_pos_0[simp]:"\<not> sign_r_pos 0 (x::real)"
using eventually_False[of "at_right x"] unfolding sign_r_pos_def by auto
lemma sign_r_pos_smult:
fixes p :: "real poly"
assumes "c\<noteq>0" "p\<noteq>0"
shows "sign_r_pos (smult c p) x= (if c>0 then sign_r_pos p x else \<not> sign_r_pos p x)"
(is "?L=?R")
proof (cases "c>0")
assume "c>0"
hence "\<forall>x. (0 < poly (smult c p) x) = (0 < poly p x)"
by (subst poly_smult,metis mult_pos_pos zero_less_mult_pos)
thus ?thesis unfolding sign_r_pos_def using \<open>c>0\<close> by auto
next
assume "\<not>(c>0)"
hence "\<forall>x. (0 < poly (smult c p) x) = (0 < poly (-p) x)"
by (subst poly_smult, metis assms(1) linorder_neqE_linordered_idom mult_neg_neg mult_zero_right
neg_0_less_iff_less poly_minus zero_less_mult_pos2)
hence "sign_r_pos (smult c p) x=sign_r_pos (-p) x"
unfolding sign_r_pos_def using \<open>\<not> c>0\<close> by auto
thus ?thesis using sign_r_pos_minus[OF \<open>p\<noteq>0\<close>, of x] \<open>\<not> c>0\<close> by auto
qed
lemma sign_r_pos_mult:
fixes p q :: "real poly"
assumes "p\<noteq>0" "q\<noteq>0"
shows "sign_r_pos (p*q) x= (sign_r_pos p x \<longleftrightarrow> sign_r_pos q x)"
proof -
obtain ub where "ub>x"
and ub:"(\<forall>z. x < z \<and> z < ub \<longrightarrow> 0 < poly p z) \<or> (\<forall>z. x < z \<and> z < ub \<longrightarrow> poly p z < 0)"
using next_non_root_interval[OF \<open>p\<noteq>0\<close>,of x,unfolded not_eq_pos_or_neg_iff_1]
by (metis order.strict_implies_order)
obtain ub' where "ub'>x"
and ub':"(\<forall>z. x < z \<and> z < ub' \<longrightarrow> 0 < poly q z) \<or> (\<forall>z. x < z \<and> z < ub' \<longrightarrow> poly q z < 0)"
using next_non_root_interval[OF \<open>q\<noteq>0\<close>,unfolded not_eq_pos_or_neg_iff_1]
by (metis order.strict_implies_order)
have "(\<forall>z. x < z \<and> z < ub \<longrightarrow> 0 < poly p z) \<Longrightarrow> (\<forall>z. x < z \<and> z < ub' \<longrightarrow> 0 < poly q z) \<Longrightarrow> ?thesis"
proof -
assume "(\<forall>z. x < z \<and> z < ub \<longrightarrow> 0 < poly p z)" "(\<forall>z. x < z \<and> z < ub' \<longrightarrow> 0 < poly q z)"
hence "sign_r_pos p x" and "sign_r_pos q x" unfolding sign_r_pos_def eventually_at_right
using \<open>ub>x\<close> \<open>ub'>x\<close> by auto
moreover hence "eventually (\<lambda>z. poly p z>0 \<and> poly q z>0) (at_right x)"
unfolding sign_r_pos_def using eventually_conj_iff[of _ _ "at_right x"] by auto
hence "sign_r_pos (p*q) x"
unfolding sign_r_pos_def poly_mult
by (metis (lifting, mono_tags) eventually_mono mult_pos_pos)
ultimately show ?thesis by auto
qed
moreover have "(\<forall>z. x < z \<and> z < ub \<longrightarrow> 0 > poly p z) \<Longrightarrow> (\<forall>z. x < z \<and> z < ub' \<longrightarrow> 0 < poly q z)
\<Longrightarrow> ?thesis"
proof -
assume "(\<forall>z. x < z \<and> z < ub \<longrightarrow> 0 > poly p z)" "(\<forall>z. x < z \<and> z < ub' \<longrightarrow> 0 < poly q z)"
hence "sign_r_pos (-p) x" and "sign_r_pos q x" unfolding sign_r_pos_def eventually_at_right
using \<open>ub>x\<close> \<open>ub'>x\<close> by auto
moreover hence "eventually (\<lambda>z. poly (-p) z>0 \<and> poly q z>0) (at_right x)"
unfolding sign_r_pos_def using eventually_conj_iff[of _ _ "at_right x"] by auto
hence "sign_r_pos (- p*q) x"
unfolding sign_r_pos_def poly_mult
by (metis (lifting, mono_tags) eventually_mono mult_pos_pos)
ultimately show ?thesis
using sign_r_pos_minus \<open>p\<noteq>0\<close> \<open>q\<noteq>0\<close> by (metis minus_mult_left no_zero_divisors)
qed
moreover have "(\<forall>z. x < z \<and> z < ub \<longrightarrow> 0 < poly p z) \<Longrightarrow> (\<forall>z. x < z \<and> z < ub' \<longrightarrow> 0 > poly q z)
\<Longrightarrow> ?thesis"
proof -
assume "(\<forall>z. x < z \<and> z < ub \<longrightarrow> 0 < poly p z)" "(\<forall>z. x < z \<and> z < ub' \<longrightarrow> 0 > poly q z)"
hence "sign_r_pos p x" and "sign_r_pos (-q) x" unfolding sign_r_pos_def eventually_at_right
using \<open>ub>x\<close> \<open>ub'>x\<close> by auto
moreover hence "eventually (\<lambda>z. poly p z>0 \<and> poly (-q) z>0) (at_right x)"
unfolding sign_r_pos_def using eventually_conj_iff[of _ _ "at_right x"] by auto
hence "sign_r_pos ( p * (- q)) x"
unfolding sign_r_pos_def poly_mult
by (metis (lifting, mono_tags) eventually_mono mult_pos_pos)
ultimately show ?thesis
using sign_r_pos_minus \<open>p\<noteq>0\<close> \<open>q\<noteq>0\<close>
by (metis minus_mult_right no_zero_divisors)
qed
moreover have "(\<forall>z. x < z \<and> z < ub \<longrightarrow> 0 > poly p z) \<Longrightarrow> (\<forall>z. x < z \<and> z < ub' \<longrightarrow> 0 > poly q z)
\<Longrightarrow> ?thesis"
proof -
assume "(\<forall>z. x < z \<and> z < ub \<longrightarrow> 0 > poly p z)" "(\<forall>z. x < z \<and> z < ub' \<longrightarrow> 0 > poly q z)"
hence "sign_r_pos (-p) x" and "sign_r_pos (-q) x"
unfolding sign_r_pos_def eventually_at_right using \<open>ub>x\<close> \<open>ub'>x\<close> by auto
moreover hence "eventually (\<lambda>z. poly (-p) z>0 \<and> poly (-q) z>0) (at_right x)"
unfolding sign_r_pos_def using eventually_conj_iff[of _ _ "at_right x"] by auto
hence "sign_r_pos (p * q) x"
unfolding sign_r_pos_def poly_mult poly_minus
apply (elim eventually_mono[of _ "at_right x"])
by (auto intro:mult_neg_neg)
ultimately show ?thesis
using sign_r_pos_minus \<open>p\<noteq>0\<close> \<open>q\<noteq>0\<close> by metis
qed
ultimately show ?thesis using ub ub' by auto
qed
lemma sign_r_pos_add:
fixes p q :: "real poly"
assumes "poly p x=0" "poly q x\<noteq>0"
shows "sign_r_pos (p+q) x=sign_r_pos q x"
proof (cases "poly (p+q) x=0")
case False
hence "p+q\<noteq>0" by (metis poly_0)
have "sign_r_pos (p+q) x = (poly q x > 0)"
using sign_r_pos_rec[OF \<open>p+q\<noteq>0\<close>] False poly_add \<open>poly p x=0\<close> by auto
moreover have "sign_r_pos q x=(poly q x > 0)"
using sign_r_pos_rec[of q x] \<open>poly q x\<noteq>0\<close> poly_0 by force
ultimately show ?thesis by auto
next
case True
hence False using \<open>poly p x=0\<close> \<open>poly q x\<noteq>0\<close> poly_add by auto
thus ?thesis by auto
qed
lemma sign_r_pos_mod:
fixes p q :: "real poly"
assumes "poly p x=0" "poly q x\<noteq>0"
shows "sign_r_pos (q mod p) x=sign_r_pos q x"
proof -
have "poly (q div p * p) x=0" using \<open>poly p x=0\<close> poly_mult by auto
moreover hence "poly (q mod p) x \<noteq> 0" using \<open>poly q x\<noteq>0\<close>
by (simp add: assms(1) poly_mod)
ultimately show ?thesis
by (metis div_mult_mod_eq sign_r_pos_add)
qed
lemma sign_r_pos_pderiv:
fixes p:: "real poly"
assumes "poly p x=0" "p\<noteq>0"
shows "sign_r_pos (pderiv p * p) x"
proof -
have "pderiv p \<noteq>0"
by (metis assms(1) assms(2) monoid_add_class.add.right_neutral mult_zero_right pCons_0_0
pderiv_iszero poly_0 poly_pCons)
have "?thesis = (sign_r_pos (pderiv p) x \<longleftrightarrow> sign_r_pos p x)"
using sign_r_pos_mult[OF \<open>pderiv p \<noteq> 0\<close> \<open>p\<noteq>0\<close>] by auto
also have "...=((sign_r_pos (pderiv p) x \<longleftrightarrow> sign_r_pos (pderiv p) x))"
using sign_r_pos_rec[OF \<open>p\<noteq>0\<close>] \<open>poly p x=0\<close> by auto
finally show ?thesis by auto
qed
lemma sign_r_pos_power:
fixes p:: "real poly" and a::real
shows "sign_r_pos ([:-a,1:]^n) a"
proof (induct n)
case 0
thus ?case unfolding sign_r_pos_def eventually_at_right by (simp,metis gt_ex)
next
case (Suc n)
have "pderiv ([:-a,1:]^Suc n) = smult (Suc n) ([:-a,1:]^n)"
proof -
have "pderiv [:- a, 1::real:] = 1" by (simp add: pderiv.simps)
thus ?thesis unfolding pderiv_power_Suc by (metis mult_cancel_left1)
qed
moreover have " poly ([:- a, 1:] ^ Suc n) a=0" by (metis old.nat.distinct(2) poly_power_n_eq)
hence "sign_r_pos ([:- a, 1:] ^ Suc n) a = sign_r_pos (smult (Suc n) ([:-a,1:]^n)) a"
using sign_r_pos_rec by (metis (erased, hide_lams) calculation pderiv_0)
hence "sign_r_pos ([:- a, 1:] ^ Suc n) a = sign_r_pos ([:-a,1:]^n) a"
using sign_r_pos_smult by auto
ultimately show ?case using Suc.hyps by auto
qed
section\<open>Jump\<close>
definition jump_poly :: "real poly \<Rightarrow> real poly \<Rightarrow>real \<Rightarrow> int"
where
" jump_poly q p x\<equiv> (if p\<noteq>0 \<and> q\<noteq>0 \<and> odd((order x p) - (order x q) ) then
if sign_r_pos (q*p) x then 1 else -1
else 0 )"
lemma jump_poly_not_root:"poly p x\<noteq>0\<Longrightarrow> jump_poly q p x=0"
unfolding jump_poly_def by (metis even_zero order_root zero_diff)
lemma jump_poly0[simp]:
"jump_poly 0 p x = 0"
"jump_poly q 0 x = 0"
unfolding jump_poly_def by auto
lemma jump_poly_smult_1:
fixes p q::"real poly" and c::real
shows "jump_poly (smult c q) p x= sign c * jump_poly q p x" (is "?L=?R")
proof (cases "c=0\<or> q=0")
case True
thus ?thesis unfolding jump_poly_def by auto
next
case False
hence "c\<noteq>0" and "q\<noteq>0" by auto
thus ?thesis unfolding jump_poly_def
using order_smult[OF \<open>c\<noteq>0\<close>] sign_r_pos_smult[OF \<open>c\<noteq>0\<close>, of "q*p" x] \<open>q\<noteq>0\<close>
by auto
qed
lemma jump_poly_mult:
fixes p q p'::"real poly"
assumes "p'\<noteq>0"
shows "jump_poly (p'*q) (p'*p) x= jump_poly q p x"
proof (cases "q=0 \<or> p=0")
case True
thus ?thesis unfolding jump_poly_def by fastforce
next
case False
then have "q\<noteq>0" "p\<noteq>0" by auto
have "sign_r_pos (p' * q * (p' * p)) x=sign_r_pos (q * p) x"
proof (unfold sign_r_pos_def,rule eventually_subst,unfold eventually_at_right)
obtain b where "b>x" and b:"\<forall>z. x < z \<and> z < b \<longrightarrow> poly (p' * p') z >0"
proof (cases "\<exists>z. poly p' z=0 \<and> z>x")
case True
define lr where "lr\<equiv>Min {r . poly p' r=0 \<and> r>x}"
have "\<forall>z. x<z\<and>z<lr\<longrightarrow>poly p' z\<noteq>0" and "lr>x"
using True lr_def poly_roots_finite[OF \<open>p'\<noteq>0\<close>] by auto
hence "\<forall>z. x < z \<and> z < lr \<longrightarrow> 0 < poly (p' * p') z"
by (metis not_real_square_gt_zero poly_mult)
thus ?thesis using that[OF \<open>lr>x\<close>] by auto
next
case False
have "\<forall>z. x<z\<and>z<x+1\<longrightarrow>poly p' z\<noteq>0" and "x+1>x"
using False poly_roots_finite[OF \<open>p'\<noteq>0\<close>] by auto
hence "\<forall>z. x < z \<and> z < x+1 \<longrightarrow> 0 < poly (p' * p') z"
by (metis not_real_square_gt_zero poly_mult)
thus ?thesis using that[OF \<open>x+1>x\<close>] by auto
qed
show "\<exists>b>x. \<forall>z>x. z < b \<longrightarrow> (0 < poly (p' * q * (p' * p)) z) = (0 < poly (q * p) z)"
proof (rule_tac x="b" in exI, rule conjI[OF \<open>b>x\<close>],rule allI,rule impI,rule impI)
fix z assume "x < z" "z < b"
hence "0<poly (p'*p') z" using b by auto
have " (0 < poly (p' * q * (p' * p)) z)=(0<poly (p'*p') z * poly (q*p) z)"
by (simp add: mult.commute mult.left_commute)
also have "...=(0<poly (q*p) z)"
using \<open>0<poly (p'*p') z\<close> by (metis mult_pos_pos zero_less_mult_pos)
finally show "(0 < poly (p' * q * (p' * p)) z) = (0 < poly (q * p) z)" .
qed
qed
moreover have " odd (order x (p' * p) - order x (p' * q)) = odd (order x p - order x q)"
using False \<open>p'\<noteq>0\<close> \<open>p\<noteq>0\<close> mult_eq_0_iff order_mult
by (metis add_diff_cancel_left)
moreover have " p' * q \<noteq> 0 \<longleftrightarrow> q \<noteq> 0"
by (metis \<open>p'\<noteq>0\<close> mult_eq_0_iff)
ultimately show "jump_poly (p' * q) (p' * p) x = jump_poly q p x" unfolding jump_poly_def by auto
qed
lemma jump_poly_1_mult:
fixes p1 p2::"real poly"
assumes "poly p1 x\<noteq>0 \<or> poly p2 x\<noteq>0"
shows "jump_poly 1 (p1*p2) x= sign (poly p2 x) * jump_poly 1 p1 x
+ sign (poly p1 x) * jump_poly 1 p2 x" (is "?L=?R")
proof (cases "p1=0 \<or> p2 =0")
case True
then show ?thesis by auto
next
case False
then have "p1\<noteq>0" "p2\<noteq>0" "p1*p2\<noteq>0" by auto
have ?thesis when "poly p1 x\<noteq>0"
proof -
have [simp]:"order x p1 = 0" using that order_root by blast
define simpL where "simpL\<equiv>(if p2\<noteq>0 \<and> odd (order x p2) then if (poly p1 x>0)
\<longleftrightarrow> sign_r_pos p2 x then 1::int else -1 else 0)"
have "?L=simpL"
unfolding simpL_def jump_poly_def
using order_mult[OF \<open>p1*p2\<noteq>0\<close>]
sign_r_pos_mult[OF \<open>p1\<noteq>0\<close> \<open>p2\<noteq>0\<close>] sign_r_pos_rec[OF \<open>p1\<noteq>0\<close>] \<open>poly p1 x\<noteq>0\<close>
by auto
moreover have "poly p1 x>0 \<Longrightarrow> simpL =?R"
unfolding simpL_def jump_poly_def using jump_poly_not_root[OF \<open>poly p1 x\<noteq>0\<close>]
by auto
moreover have "poly p1 x<0 \<Longrightarrow> simpL =?R"
unfolding simpL_def jump_poly_def using jump_poly_not_root[OF \<open>poly p1 x\<noteq>0\<close>]
by auto
ultimately show "?L=?R" using \<open>poly p1 x\<noteq>0\<close> by (metis linorder_neqE_linordered_idom)
qed
moreover have ?thesis when "poly p2 x\<noteq>0"
proof -
have [simp]:"order x p2 = 0" using that order_root by blast
define simpL where "simpL\<equiv>(if p1\<noteq>0 \<and> odd (order x p1) then if (poly p2 x>0)
\<longleftrightarrow> sign_r_pos p1 x then 1::int else -1 else 0)"
have "?L=simpL"
unfolding simpL_def jump_poly_def
using order_mult[OF \<open>p1*p2\<noteq>0\<close>]
sign_r_pos_mult[OF \<open>p1\<noteq>0\<close> \<open>p2\<noteq>0\<close>] sign_r_pos_rec[OF \<open>p2\<noteq>0\<close>] \<open>poly p2 x\<noteq>0\<close>
by auto
moreover have "poly p2 x>0 \<Longrightarrow> simpL =?R"
unfolding simpL_def jump_poly_def using jump_poly_not_root[OF \<open>poly p2 x\<noteq>0\<close>]
by auto
moreover have "poly p2 x<0 \<Longrightarrow> simpL =?R"
unfolding simpL_def jump_poly_def using jump_poly_not_root[OF \<open>poly p2 x\<noteq>0\<close>]
by auto
ultimately show "?L=?R" using \<open>poly p2 x\<noteq>0\<close> by (metis linorder_neqE_linordered_idom)
qed
ultimately show ?thesis using assms by auto
qed
lemma jump_poly_mod:
fixes p q::"real poly"
shows "jump_poly q p x= jump_poly (q mod p) p x"
proof (cases "q=0 \<or> p=0")
case True
thus ?thesis by fastforce
next
case False
then have "p\<noteq>0" "q\<noteq>0" by auto
define n where "n\<equiv>min (order x q) (order x p)"
obtain q' where q':"q=[:-x,1:]^n * q'"
using n_def power_le_dvd[OF order_1[of x q], of n]
by (metis dvdE min.cobounded2 min.commute)
obtain p' where p':"p=[:-x,1:]^n * p'"
using n_def power_le_dvd[OF order_1[of x p], of n]
by (metis dvdE min.cobounded2)
have "q'\<noteq>0" and "p'\<noteq>0" using q' p' \<open>p\<noteq>0\<close> \<open>q\<noteq>0\<close> by auto
have "order x q'=0 \<or> order x p'=0"
proof (rule ccontr)
assume "\<not> (order x q' = 0 \<or> order x p' = 0)"
hence "order x q' > 0" and "order x p' > 0" by auto
hence "order x q>n" and "order x p>n" unfolding q' p'
using order_mult[OF \<open>q\<noteq>0\<close>[unfolded q'],of x] order_mult[OF \<open>p\<noteq>0\<close>[unfolded p'],of x]
order_power_n_n[of x n]
by auto
thus False using n_def by auto
qed
have cond:"q' \<noteq> 0 \<and> odd (order x p' - order x q')
= (q' mod p' \<noteq>0 \<and> odd(order x p' - order x (q' mod p')))"
proof (cases "order x p'=0")
case True
thus ?thesis by (metis \<open>q' \<noteq> 0\<close> even_zero zero_diff)
next
case False
hence "order x q'=0" using \<open>order x q'=0 \<or> order x p'=0\<close> by auto
hence "\<not> [:-x,1:] dvd q'"
by (metis \<open>q' \<noteq> 0\<close> order_root poly_eq_0_iff_dvd)
moreover have "[:-x,1:] dvd p'" using False
by (metis order_root poly_eq_0_iff_dvd)
ultimately have "\<not> [:-x,1:] dvd (q' mod p')"
by (metis dvd_mod_iff)
hence "order x (q' mod p') = 0" and "q' mod p' \<noteq>0"
apply (metis order_root poly_eq_0_iff_dvd)
by (metis \<open>\<not> [:- x, 1:] dvd q' mod p'\<close> dvd_0_right)
thus ?thesis using \<open>order x q'=0\<close> by auto
qed
moreover have "q' mod p'\<noteq>0 \<Longrightarrow> poly p' x = 0
\<Longrightarrow> sign_r_pos (q' * p') x= sign_r_pos (q' mod p' * p') x"
proof -
assume "q' mod p'\<noteq>0" "poly p' x = 0"
hence "poly q' x\<noteq>0" using \<open>order x q'=0 \<or> order x p'=0\<close>
by (metis \<open>p' \<noteq> 0\<close> \<open>q' \<noteq> 0\<close> order_root)
hence "sign_r_pos q' x= sign_r_pos (q' mod p') x"
using sign_r_pos_mod[OF \<open>poly p' x=0\<close>] by auto
thus ?thesis
unfolding sign_r_pos_mult[OF \<open>q'\<noteq>0\<close> \<open>p'\<noteq>0\<close>] sign_r_pos_mult[OF \<open>q' mod p'\<noteq>0\<close> \<open>p'\<noteq>0\<close>]
by auto
qed
moreover have "q' mod p' = 0 \<or> poly p' x \<noteq> 0 \<Longrightarrow> jump_poly q' p' x = jump_poly (q' mod p') p' x"
proof -
assume assm:"q' mod p' = 0 \<or> poly p' x \<noteq> 0"
have "q' mod p' = 0 \<Longrightarrow> ?thesis" unfolding jump_poly_def
using cond by auto
moreover have "poly p' x \<noteq> 0
\<Longrightarrow> \<not> odd (order x p' - order x q') \<and> \<not> odd(order x p' - order x (q' mod p'))"
by (metis even_zero order_root zero_diff)
hence "poly p' x \<noteq> 0 \<Longrightarrow> ?thesis" unfolding jump_poly_def by auto
ultimately show ?thesis using assm by auto
qed
ultimately have " jump_poly q' p' x = jump_poly (q' mod p') p' x" unfolding jump_poly_def by force
thus ?thesis using p' q' jump_poly_mult by auto
qed
lemma jump_poly_coprime:
fixes p q:: "real poly"
assumes "poly p x=0" "coprime p q"
shows "jump_poly q p x= jump_poly 1 (q*p) x"
proof (cases "p=0 \<or> q=0")
case True
then show ?thesis by auto
next
case False
then have "p\<noteq>0" "q\<noteq>0" by auto
then have "poly p x\<noteq>0 \<or> poly q x\<noteq>0" using coprime_poly_0[OF \<open>coprime p q\<close>] by auto
then have "poly q x\<noteq>0" using \<open>poly p x=0\<close> by auto
then have "order x q=0" using order_root by blast
then have "order x p - order x q = order x (q * p)"
using \<open>p\<noteq>0\<close> \<open>q\<noteq>0\<close> order_mult [of q p x] by auto
then show ?thesis unfolding jump_poly_def using \<open>q\<noteq>0\<close> by auto
qed
lemma jump_poly_sgn:
fixes p q:: "real poly"
assumes "p\<noteq>0" "poly p x=0"
shows "jump_poly (pderiv p * q) p x = sign (poly q x)"
proof (cases "q=0")
case True
thus ?thesis by auto
next
case False
have "pderiv p\<noteq>0" using \<open>p\<noteq>0\<close> \<open>poly p x=0\<close>
by (metis mult_poly_0_left sign_r_pos_0 sign_r_pos_pderiv)
have elim_p_order: "order x p - order x (pderiv p * q)=1 - order x q"
proof -
have "order x p - order x (pderiv p * q) = order x p - order x (pderiv p) - order x q"
using order_mult \<open>pderiv p\<noteq>0\<close> False by (metis diff_diff_left mult_eq_0_iff)
moreover have "order x p - order x (pderiv p) = 1"
using order_pderiv[OF \<open>pderiv p\<noteq>0\<close>, of x] \<open>poly p x=0\<close> order_root[of p x] \<open>p\<noteq>0\<close> by auto
ultimately show ?thesis by auto
qed
have elim_p_sign_r_pos:"sign_r_pos (pderiv p * q * p) x=sign_r_pos q x"
proof -
have "sign_r_pos (pderiv p * q * p) x = (sign_r_pos (pderiv p* p) x \<longleftrightarrow> sign_r_pos q x)"
by (metis \<open>q \<noteq> 0\<close> \<open>pderiv p \<noteq> 0\<close> assms(1) no_zero_divisors sign_r_pos_mult)
thus ?thesis using sign_r_pos_pderiv[OF \<open>poly p x=0\<close> \<open>p\<noteq>0\<close>] by auto
qed
define simpleL where "simpleL\<equiv>if pderiv p * q \<noteq> 0 \<and> odd (1 - order x q) then
if sign_r_pos q x then 1::int else - 1 else 0"
have " jump_poly (pderiv p * q) p x =simpleL"
unfolding simpleL_def jump_poly_def by (subst elim_p_order, subst elim_p_sign_r_pos,simp)
moreover have "poly q x=0 \<Longrightarrow> simpleL=sign (poly q x)"
proof -
assume "poly q x=0"
hence "1-order x q = 0" using \<open>q\<noteq>0\<close> by (metis less_one not_gr0 order_root zero_less_diff)
hence "simpleL=0" unfolding simpleL_def by auto
moreover have "sign (poly q x)=0" using \<open>poly q x=0\<close> by auto
ultimately show ?thesis by auto
qed
moreover have "poly q x\<noteq>0\<Longrightarrow> simpleL=sign (poly q x)"
proof -
assume "poly q x\<noteq>0"
hence "odd (1 - order x q)" by (simp add: order_root)
moreover have "pderiv p * q \<noteq> 0" by (metis False \<open>pderiv p \<noteq> 0\<close> no_zero_divisors)
moreover have "sign_r_pos q x = (poly q x > 0)"
using sign_r_pos_rec[OF False] \<open>poly q x\<noteq>0\<close> by auto
ultimately have "simpleL=(if poly q x>0 then 1 else - 1)" unfolding simpleL_def by auto
thus ?thesis using \<open>poly q x\<noteq>0\<close> by auto
qed
ultimately show ?thesis by force
qed
section \<open>Cauchy index\<close>
definition cindex_poly:: "real \<Rightarrow> real \<Rightarrow> real poly \<Rightarrow> real poly \<Rightarrow> int"
where
"cindex_poly a b q p\<equiv> (\<Sum>x\<in>{x. poly p x=0 \<and> a< x\<and> x< b}. jump_poly q p x)"
lemma cindex_poly_0[simp]: "cindex_poly a b 0 p = 0" "cindex_poly a b q 0 = 0"
unfolding cindex_poly_def by auto
lemma cindex_poly_cross:
fixes p::"real poly" and a b::real
assumes "a<b" "poly p a\<noteq>0" "poly p b\<noteq>0"
shows "cindex_poly a b 1 p = cross p a b"
using \<open>poly p a\<noteq>0\<close> \<open>poly p b\<noteq>0\<close>
proof (cases "{x. poly p x=0 \<and> a< x\<and> x< b}\<noteq>{}", induct "degree p" arbitrary:p rule:nat_less_induct)
case 1
then have "p\<noteq>0" by force
define roots where "roots\<equiv>{x. poly p x=0 \<and> a< x\<and> x< b}"
have "finite roots" unfolding roots_def using poly_roots_finite[OF \<open>p\<noteq>0\<close>] by auto
define max_r where "max_r\<equiv>Max roots"
hence "poly p max_r=0" and "a<max_r" and "max_r<b"
using Max_in[OF \<open>finite roots\<close>] "1.prems" unfolding roots_def by auto
define max_rp where "max_rp\<equiv>[:-max_r,1:]^order max_r p"
then obtain p' where p':"p=p'*max_rp" and not_dvd:"\<not> [:-max_r,1:] dvd p'"
by (metis \<open>p\<noteq>0\<close> mult.commute order_decomp)
hence "p'\<noteq>0" and "max_rp\<noteq>0" and "poly p' a\<noteq>0" and "poly p' b\<noteq>0"
and "poly max_rp a\<noteq>0" and "poly max_rp b\<noteq>0"
using \<open>p\<noteq>0\<close> \<open>poly p a\<noteq>0\<close> \<open>poly p b\<noteq>0\<close> by auto
define max_r_sign where "max_r_sign\<equiv>if odd(order max_r p) then -1 else 1::int"
define roots' where "roots'\<equiv>{x. a< x\<and> x< b \<and> poly p' x=0}"
have "(\<Sum>x\<in>roots. jump_poly 1 p x)= (\<Sum>x\<in>roots'. jump_poly 1 p x)+ jump_poly 1 p max_r"
proof -
have "roots=roots' \<union> {x. a< x\<and> x< b \<and> poly max_rp x=0 }"
unfolding roots_def roots'_def p' by auto
moreover have "{x. a < x \<and> x < b \<and> poly max_rp x = 0 }={max_r}"
unfolding max_rp_def using \<open>poly p max_r=0\<close>
by (auto simp add: \<open>a<max_r\<close> \<open>max_r<b\<close>,metis "1.prems"(1) neq0_conv order_root)
moreover hence "roots' \<inter> {x. a< x\<and> x< b \<and> poly max_rp x=0} ={}"
unfolding roots'_def using \<open>\<not> [:-max_r,1:] dvd p'\<close>
by (metis (mono_tags) Int_insert_right_if0 inf_bot_right mem_Collect_eq poly_eq_0_iff_dvd)
moreover have "finite roots'"
using p' \<open>p\<noteq>0\<close> by (metis \<open>finite roots\<close> calculation(1) calculation(2) finite_Un)
ultimately show ?thesis using sum.union_disjoint by auto
qed
moreover have "(\<Sum>x\<in>roots'. jump_poly 1 p x) = max_r_sign * cross p' a b"
proof -
have "(\<Sum>x\<in>roots'. jump_poly 1 p x) = (\<Sum>x\<in>roots'. max_r_sign * jump_poly 1 p' x)"
proof (rule sum.cong,rule refl)
fix x assume "x \<in> roots'"
hence "x\<noteq>max_r" using not_dvd unfolding roots'_def
by (metis (mono_tags, lifting) mem_Collect_eq poly_eq_0_iff_dvd )
hence "poly max_rp x\<noteq>0" using poly_power_n_eq unfolding max_rp_def by auto
hence "order x max_rp=0" by (metis order_root)
moreover have "jump_poly 1 max_rp x=0"
using \<open>poly max_rp x\<noteq>0\<close> by (metis jump_poly_not_root)
moreover have "x\<in>roots"
using \<open>x \<in> roots'\<close> unfolding roots_def roots'_def p' by auto
hence "x<max_r"
using Max_ge[OF \<open>finite roots\<close>,of x] \<open>x\<noteq>max_r\<close> by (fold max_r_def,auto)
hence "sign (poly max_rp x) = max_r_sign"
using \<open>poly max_rp x \<noteq> 0\<close> unfolding max_r_sign_def max_rp_def sign_def
by (subst poly_power,simp add:linorder_class.not_less zero_less_power_eq)
ultimately show "jump_poly 1 p x = max_r_sign * jump_poly 1 p' x"
using jump_poly_1_mult[of p' x max_rp] unfolding p'
by (simp add: \<open>poly max_rp x \<noteq> 0\<close>)
qed
also have "... = max_r_sign * (\<Sum>x\<in>roots'. jump_poly 1 p' x)"
by (simp add: sum_distrib_left)
also have "... = max_r_sign * cross p' a b"
proof (cases "roots'={}")
case True
hence "cross p' a b=0" unfolding roots'_def using cross_no_root[OF \<open>a<b\<close>] by auto
thus ?thesis using True by simp
next
case False
moreover have "degree max_rp\<noteq>0"
unfolding max_rp_def degree_linear_power
by (metis "1.prems"(1) \<open>poly p max_r = 0\<close> order_root)
hence "degree p' < degree p" unfolding p' degree_mult_eq[OF \<open>p'\<noteq>0\<close> \<open>max_rp\<noteq>0\<close>]
by auto
ultimately have "cindex_poly a b 1 p' = cross p' a b"
unfolding roots'_def
using "1.hyps"[rule_format,of "degree p'" p'] \<open>p'\<noteq>0\<close> \<open>poly p' a\<noteq>0\<close> \<open>poly p' b\<noteq>0\<close>
by auto
moreover have "cindex_poly a b 1 p' = sum (jump_poly 1 p') roots'"
unfolding cindex_poly_def roots'_def
apply simp
by (metis (no_types, lifting) )
ultimately show ?thesis by auto
qed
finally show ?thesis .
qed
moreover have "max_r_sign * cross p' a b + jump_poly 1 p max_r = cross p a b" (is "?L=?R")
proof (cases "odd (order max_r p)")
case True
have "poly max_rp a < 0"
using poly_power_n_odd[OF True,of max_r a] \<open>poly max_rp a\<noteq>0\<close> \<open>max_r>a\<close>
unfolding max_rp_def by linarith
moreover have "poly max_rp b>0 "
using poly_power_n_odd[OF True,of max_r b] \<open>max_r<b\<close>
unfolding max_rp_def by linarith
ultimately have "?R=cross p' a b + sign (poly p' a)"
unfolding p' cross_def poly_mult
using variation_mult_neg_1[of "poly max_rp a", simplified mult.commute]
variation_mult_pos(2)[of "poly max_rp b", simplified mult.commute] \<open>poly p' b\<noteq>0\<close>
by auto
moreover have "?L=- cross p' a b + sign (poly p' b)"
proof -
have " sign_r_pos p' max_r = (poly p' max_r >0)"
using sign_r_pos_rec[OF \<open>p'\<noteq>0\<close>] not_dvd by (metis poly_eq_0_iff_dvd)
moreover have "(poly p' max_r>0) = (poly p' b>0)"
proof (rule ccontr)
assume "(0 < poly p' max_r) \<noteq> (0 < poly p' b)"
hence "poly p' max_r * poly p' b <0"
using \<open>poly p' b\<noteq>0\<close> not_dvd[folded poly_eq_0_iff_dvd]
by (metis (poly_guards_query) linorder_neqE_linordered_idom mult_less_0_iff)
then obtain r where "r>max_r" and "r<b" and "poly p' r=0"
using poly_IVT[OF \<open>max_r<b\<close>] by auto
hence "r\<in>roots" unfolding roots_def p' using \<open>max_r>a\<close> by auto
thus False using \<open>r>max_r\<close> Max_ge[OF \<open>finite roots\<close>,of r] unfolding max_r_def by auto
qed
moreover have "sign_r_pos max_rp max_r"
using sign_r_pos_power unfolding max_rp_def by auto
ultimately show ?thesis
using True \<open>poly p' b\<noteq>0\<close> \<open>max_rp\<noteq>0\<close> \<open>p'\<noteq>0\<close> sign_r_pos_mult[OF \<open>p'\<noteq>0\<close> \<open>max_rp\<noteq>0\<close>]
unfolding max_r_sign_def p' jump_poly_def
by simp
qed
moreover have "variation (poly p' a) (poly p' b) + sign (poly p' a)
= - variation (poly p' a) (poly p' b) + sign (poly p' b)" unfolding cross_def
by (cases "poly p' b" rule:linorder_cases[of 0], (cases "poly p' a" rule:linorder_cases[of 0],
auto simp add:variation_cases \<open>poly p' a \<noteq> 0\<close> \<open>poly p' b \<noteq> 0\<close>)+)
ultimately show ?thesis unfolding cross_def by auto
next
case False
hence "poly max_rp a > 0" and "poly max_rp b > 0"
unfolding max_rp_def poly_power
using \<open>poly max_rp a\<noteq>0\<close> \<open>poly max_rp b \<noteq> 0\<close> "1.prems"(1-2) \<open>poly p max_r = 0\<close>
apply (unfold zero_less_power_eq)
by auto
moreover have "poly max_rp b > 0"
unfolding max_rp_def poly_power
using \<open>poly max_rp b \<noteq> 0\<close> False max_rp_def poly_power
zero_le_even_power[of "order max_r p" "b - max_r"]
by (auto simp add: le_less)
ultimately have "?R=cross p' a b"
apply (simp only: p' mult.commute cross_def) using variation_mult_pos
by auto
thus ?thesis unfolding max_r_sign_def jump_poly_def using False by auto
qed
ultimately have "sum (jump_poly 1 p) roots = cross p a b " by auto
then show ?case unfolding roots_def cindex_poly_def by simp
next
case False
hence "cross p a b=0" using cross_no_root[OF \<open>a<b\<close>] by auto
thus ?thesis using False unfolding cindex_poly_def by (metis sum.empty)
qed
lemma cindex_poly_mult:
fixes p q p'::"real poly"
assumes "p'\<noteq> 0"
shows "cindex_poly a b (p' * q ) (p' * p) = cindex_poly a b q p"
proof (cases "p=0")
case True
then show ?thesis by auto
next
case False
show ?thesis unfolding cindex_poly_def
apply (rule sum.mono_neutral_cong_right)
subgoal using \<open>p\<noteq>0\<close> \<open>p'\<noteq>0\<close> by (simp add: poly_roots_finite)
subgoal by auto
subgoal using jump_poly_mult jump_poly_not_root assms by fastforce
subgoal for x using jump_poly_mult[OF \<open>p'\<noteq>0\<close>] by auto
done
qed
lemma cindex_poly_smult_1:
fixes p q::"real poly" and c::real
shows "cindex_poly a b (smult c q) p = (sign c) * cindex_poly a b q p"
unfolding cindex_poly_def
using sum_distrib_left[THEN sym, of "sign c" "\<lambda>x. jump_poly q p x"
"{x. poly p x = (0::real) \<and> a < x \<and> x < b}"] jump_poly_smult_1
by auto
lemma cindex_poly_mod:
fixes p q::"real poly"
shows "cindex_poly a b q p = cindex_poly a b (q mod p) p"
unfolding cindex_poly_def using jump_poly_mod by auto
lemma cindex_poly_inverse_add:
fixes p q::"real poly"
assumes "coprime p q"
shows "cindex_poly a b q p + cindex_poly a b p q=cindex_poly a b 1 (q*p)"
(is "?L=?R")
proof (cases "p=0 \<or> q=0")
case True
then show ?thesis by auto
next
case False
then have "p\<noteq>0" "q\<noteq>0" by auto
define A where "A\<equiv>{x. poly p x = 0 \<and> a < x \<and> x < b}"
define B where "B\<equiv>{x. poly q x = 0 \<and> a < x \<and> x < b}"
have "?L = sum (\<lambda>x. jump_poly 1 (q*p) x) A + sum (\<lambda>x. jump_poly 1 (q*p) x) B"
proof -
have "cindex_poly a b q p = sum (\<lambda>x. jump_poly 1 (q*p) x) A" unfolding A_def cindex_poly_def
using jump_poly_coprime[OF _ \<open>coprime p q\<close>] by auto
moreover have "coprime q p" using \<open>coprime p q\<close>
by (simp add: ac_simps)
hence "cindex_poly a b p q = sum (\<lambda>x. jump_poly 1 (q*p) x) B" unfolding B_def cindex_poly_def
using jump_poly_coprime [of q _ p] by (auto simp add: ac_simps)
ultimately show ?thesis by auto
qed
moreover have "A \<union> B= {x. poly (q*p) x=0 \<and> a<x \<and> x<b }" unfolding poly_mult A_def B_def by auto
moreover have "A \<inter> B={}"
proof (rule ccontr)
assume "A \<inter> B\<noteq>{}"
then obtain x where "x\<in>A" and "x\<in>B" by auto
hence "poly p x=0" and "poly q x=0" unfolding A_def B_def by auto
hence "gcd p q\<noteq>1" by (metis poly_1 poly_eq_0_iff_dvd gcd_greatest zero_neq_one)
thus False using \<open>coprime p q\<close> by auto
qed
moreover have "finite A" and "finite B"
unfolding A_def B_def using poly_roots_finite \<open>p\<noteq>0\<close> \<open>q\<noteq>0\<close> by fast+
ultimately have "cindex_poly a b q p + cindex_poly a b p q
= sum (jump_poly 1 (q * p)) {x. poly (q*p) x=0 \<and> a<x \<and> x<b}"
using sum.union_disjoint by metis
then show ?thesis unfolding cindex_poly_def by auto
qed
lemma cindex_poly_inverse_add_cross:
fixes p q::"real poly"
assumes "a < b" "poly (p * q) a \<noteq>0" "poly (p * q) b \<noteq>0"
shows "cindex_poly a b q p + cindex_poly a b p q = cross (p * q) a b" (is "?L=?R")
proof -
have "p\<noteq>0" and "q\<noteq>0" using \<open>poly (p * q) a \<noteq>0\<close> by auto
define g where "g\<equiv>gcd p q"
obtain p' q' where p':"p= p'*g" and q':"q=q'*g"
using gcd_dvd1 gcd_dvd2 dvd_def[of "gcd p q", simplified mult.commute] g_def by metis
hence "coprime p' q'" using gcd_coprime \<open>p\<noteq>0\<close> unfolding g_def by auto
have "p'\<noteq>0" "q'\<noteq>0" "g \<noteq>0" using p' q' \<open>p\<noteq>0\<close> \<open>q\<noteq>0\<close> by auto
have "?L=cindex_poly a b q' p' + cindex_poly a b p' q'"
apply (simp only: p' q' mult.commute)
using cindex_poly_mult[OF \<open>g\<noteq>0\<close>] cindex_poly_mult[OF \<open>g\<noteq>0\<close>]
by auto
also have "... = cindex_poly a b 1 (q' * p')"
using cindex_poly_inverse_add[OF \<open>coprime p' q'\<close>, of a b] .
also have "... = cross (p' * q') a b"
using cindex_poly_cross[OF \<open>a<b\<close>, of "q'*p'"] \<open>p'\<noteq>0\<close> \<open>q'\<noteq>0\<close>
\<open>poly (p * q) a \<noteq>0\<close> \<open>poly (p * q) b \<noteq>0\<close>
unfolding p' q'
apply (subst (2) mult.commute)
by auto
also have "... = ?R"
proof -
have "poly (p * q) a = poly (g*g) a * poly (p' * q') a"
and "poly (p * q) b = poly (g*g) b * poly (p' * q') b"
unfolding p' q' by auto
moreover have "poly g a\<noteq>0" using \<open>poly (p * q) a \<noteq>0\<close>
unfolding p' by auto
hence "poly (g*g) a>0"
by (metis (poly_guards_query) not_real_square_gt_zero poly_mult)
moreover have "poly g b\<noteq>0" using \<open>poly (p * q) b \<noteq>0\<close>
unfolding p' by auto
hence "poly (g*g) b>0" by (metis (poly_guards_query) not_real_square_gt_zero poly_mult)
ultimately show ?thesis
unfolding cross_def using variation_mult_pos by auto
qed
finally show "?L = ?R" .
qed
lemma cindex_poly_rec:
fixes p q::"real poly"
assumes "a < b" "poly (p * q) a \<noteq>0" "poly (p * q) b \<noteq>0"
shows "cindex_poly a b q p = cross (p * q) a b + cindex_poly a b (- (p mod q)) q" (is "?L=?R")
proof -
have "q\<noteq>0" using \<open>poly (p * q) a \<noteq>0\<close> by auto
note cindex_poly_inverse_add_cross[OF assms]
moreover have "- cindex_poly a b p q = cindex_poly a b (- (p mod q)) q"
using cindex_poly_mod cindex_poly_smult_1[of a b "-1"]
by auto
ultimately show ?thesis by auto
qed
lemma cindex_poly_congr:
fixes p q:: "real poly"
assumes "a<a'" "a'<b'" "b'<b"
assumes "\<forall>x. ((a<x\<and>x\<le>a') \<or> (b'\<le>x \<and> x<b)) \<longrightarrow> poly p x \<noteq>0"
shows "cindex_poly a b q p=cindex_poly a' b' q p"
proof (cases "p=0")
case True
then show ?thesis by auto
next
case False
show ?thesis unfolding cindex_poly_def
apply (rule sum.mono_neutral_right)
subgoal using poly_roots_finite[OF \<open>p\<noteq>0\<close>] by auto
subgoal using assms by auto
subgoal using assms(4) by fastforce
done
qed
lemma greaterThanLessThan_unfold:"{a<..<b} = {x. a<x \<and> x<b}"
by fastforce
lemma cindex_poly_taq:
fixes p q::"real poly"
shows "taq {x. poly p x = 0 \<and> a < x \<and> x < b} q=cindex_poly a b (pderiv p * q) p"
proof (cases "p=0")
case True
define S where "S={x. poly p x = 0 \<and> a < x \<and> x < b}"
have ?thesis when "a\<ge>b"
proof -
have "S = {}" using that unfolding S_def by auto
then show ?thesis using True unfolding taq_def by (fold S_def,simp)
qed
moreover have ?thesis when "a<b"
proof -
have "infinite {x. a<x \<and> x<b}" using infinite_Ioo[OF \<open>a<b\<close>]
unfolding greaterThanLessThan_unfold by simp
then have "infinite S" unfolding S_def using True by auto
then show ?thesis using True unfolding taq_def by (fold S_def,simp)
qed
ultimately show ?thesis by fastforce
next
case False
show ?thesis
unfolding cindex_poly_def taq_def
by (rule sum.cong,auto simp add:jump_poly_sgn[OF \<open>p\<noteq>0\<close>])
qed
section\<open>Signed remainder sequence\<close>
function smods:: "real poly \<Rightarrow> real poly \<Rightarrow> (real poly) list" where
"smods p q= (if p=0 then [] else Cons p (smods q (-(p mod q))))"
by auto
termination
apply (relation "measure (\<lambda>(p,q).if p=0 then 0 else if q=0 then 1 else 2+degree q)")
apply simp_all
apply (metis degree_mod_less)
done
lemma smods_nil_eq:"smods p q = [] \<longleftrightarrow> (p=0)" by auto
lemma smods_singleton:"[x] = smods p q \<Longrightarrow> (p\<noteq>0 \<and> q=0 \<and> x=p)"
by (metis list.discI list.inject smods.elims)
lemma smods_0[simp]:
"smods 0 q = []"
"smods p 0 = (if p=0 then [] else [p])"
by auto
lemma no_0_in_smods: "0\<notin>set (smods p q)"
apply (induct "smods p q" arbitrary:p q)
by (simp,metis list.inject neq_Nil_conv set_ConsD smods.elims)
fun changes:: "('a ::linordered_idom) list \<Rightarrow> int" where
"changes [] = 0"|
"changes [_] = 0" |
"changes (x1#x2#xs) = (if x1*x2<0 then 1+changes (x2#xs)
else if x2=0 then changes (x1#xs)
else changes (x2#xs))"
lemma changes_map_sgn_eq:
"changes xs = changes (map sgn xs)"
proof (induct xs rule:changes.induct)
case 1
show ?case by simp
next
case 2
show ?case by simp
next
case (3 x1 x2 xs)
moreover have "x1*x2<0 \<longleftrightarrow> sgn x1 * sgn x2 < 0"
by (unfold mult_less_0_iff sgn_less sgn_greater,simp)
moreover have "x2=0 \<longleftrightarrow> sgn x2 =0" by (rule sgn_0_0[symmetric])
ultimately show ?case by auto
qed
definition changes_poly_at::"('a ::linordered_idom) poly list \<Rightarrow> 'a \<Rightarrow> int" where
"changes_poly_at ps a= changes (map (\<lambda>p. poly p a) ps)"
definition changes_poly_pos_inf:: "('a ::linordered_idom) poly list \<Rightarrow> int" where
"changes_poly_pos_inf ps = changes (map sgn_pos_inf ps)"
definition changes_poly_neg_inf:: "('a ::linordered_idom) poly list \<Rightarrow> int" where
"changes_poly_neg_inf ps = changes (map sgn_neg_inf ps)"
lemma changes_poly_at_0[simp]:
"changes_poly_at [] a =0"
"changes_poly_at [p] a=0"
unfolding changes_poly_at_def by auto
definition changes_itv_smods:: "real \<Rightarrow> real \<Rightarrow>real poly \<Rightarrow> real poly \<Rightarrow> int" where
"changes_itv_smods a b p q= (let ps= smods p q in changes_poly_at ps a - changes_poly_at ps b)"
definition changes_gt_smods:: "real \<Rightarrow>real poly \<Rightarrow> real poly \<Rightarrow> int" where
"changes_gt_smods a p q= (let ps= smods p q in changes_poly_at ps a - changes_poly_pos_inf ps)"
definition changes_le_smods:: "real \<Rightarrow>real poly \<Rightarrow> real poly \<Rightarrow> int" where
"changes_le_smods b p q= (let ps= smods p q in changes_poly_neg_inf ps - changes_poly_at ps b)"
definition changes_R_smods:: "real poly \<Rightarrow> real poly \<Rightarrow> int" where
"changes_R_smods p q= (let ps= smods p q in changes_poly_neg_inf ps - changes_poly_pos_inf ps)"
lemma changes_R_smods_0[simp]:
"changes_R_smods 0 q = 0"
"changes_R_smods p 0 = 0"
unfolding changes_R_smods_def changes_poly_neg_inf_def changes_poly_pos_inf_def
by auto
lemma changes_itv_smods_0[simp]:
"changes_itv_smods a b 0 q = 0"
"changes_itv_smods a b p 0 = 0"
unfolding changes_itv_smods_def
by auto
lemma changes_itv_smods_rec:
assumes "a<b" "poly (p*q) a\<noteq>0" "poly (p*q) b\<noteq>0"
shows "changes_itv_smods a b p q = cross (p*q) a b + changes_itv_smods a b q (-(p mod q))"
proof (cases "p=0 \<or> q=0 \<or> p mod q = 0")
case True
moreover have "p=0 \<or> q=0 \<Longrightarrow> ?thesis"
unfolding changes_itv_smods_def changes_poly_at_def by (erule HOL.disjE,auto)
moreover have "p mod q = 0 \<Longrightarrow> ?thesis"
unfolding changes_itv_smods_def changes_poly_at_def cross_def
apply (insert assms(2,3))
apply (subst (asm) (1 2) neq_iff)
by (auto simp add: variation_cases)
ultimately show ?thesis by auto
next
case False
hence "p\<noteq>0" "q\<noteq>0" "p mod q\<noteq>0" by auto
then obtain ps where ps:"smods p q=p#q#-(p mod q)#ps" "smods q (-(p mod q)) = q#-(p mod q)#ps"
by auto
define changes_diff where "changes_diff\<equiv>\<lambda>x. changes_poly_at (p#q#-(p mod q)#ps) x
- changes_poly_at (q#-(p mod q)#ps) x"
have "\<And>x. poly p x*poly q x<0 \<Longrightarrow> changes_diff x=1"
unfolding changes_diff_def changes_poly_at_def by auto
moreover have "\<And>x. poly p x*poly q x>0 \<Longrightarrow> changes_diff x=0"
unfolding changes_diff_def changes_poly_at_def by auto
ultimately have "changes_diff a - changes_diff b=cross (p*q) a b"
unfolding cross_def
apply (cases rule:neqE[OF \<open>poly (p*q) a\<noteq>0\<close>])
by (cases rule:neqE[OF \<open>poly (p*q) b\<noteq>0\<close>],auto simp add:variation_cases)+
thus ?thesis unfolding changes_itv_smods_def changes_diff_def changes_poly_at_def
using ps by auto
qed
lemma changes_smods_congr:
fixes p q:: "real poly"
assumes "a\<noteq>a'" "poly p a\<noteq>0"
assumes "\<forall>p\<in>set (smods p q). \<forall>x. ((a<x\<and>x\<le>a') \<or> (a'\<le>x \<and> x<a)) \<longrightarrow> poly p x \<noteq>0"
shows "changes_poly_at (smods p q) a = changes_poly_at (smods p q) a'"
using assms(2-3)
proof (induct "smods p q" arbitrary:p q rule:length_induct)
case 1
have "p\<noteq>0" using \<open>poly p a \<noteq>0\<close> by auto
define r1 where "r1\<equiv>- (p mod q)"
have a_a'_rel:"\<forall>pp\<in>set (smods p q). poly pp a * poly pp a' \<ge>0"
proof (rule ccontr)
assume "\<not> (\<forall>pp\<in>set (smods p q). 0 \<le> poly pp a * poly pp a')"
then obtain pp where pp:"pp\<in>set (smods p q)" " poly pp a * poly pp a'<0"
using \<open>p\<noteq>0\<close> by (metis less_eq_real_def linorder_neqE_linordered_idom)
hence "a<a' \<Longrightarrow> False" using "1.prems"(2) poly_IVT[of a a' pp] by auto
moreover have "a'<a\<Longrightarrow>False"
using pp[unfolded mult.commute[of "poly pp a"]] "1.prems"(2) poly_IVT[of a' a pp] by auto
ultimately show False using \<open>a\<noteq>a'\<close> by force
qed
have "q=0 \<Longrightarrow> ?case" by auto
moreover have "\<lbrakk>q\<noteq>0;poly q a=0\<rbrakk> \<Longrightarrow> ?case"
proof -
assume "q\<noteq>0" "poly q a=0"
define r2 where "r2\<equiv>- (q mod r1)"
have "- poly r1 a = poly p a "
by (metis \<open>poly q a = 0\<close> add.inverse_inverse add.left_neutral div_mult_mod_eq
mult_zero_right poly_add poly_minus poly_mult r1_def)
hence "r1\<noteq>0" and "poly r1 a\<noteq>0" and "poly p a*poly r1 a<0" using \<open>poly p a\<noteq>0\<close>
apply auto
using mult_less_0_iff by fastforce
then obtain ps where ps:"smods p q=p#q#r1#ps" "smods r1 r2=r1#ps"
by (metis \<open>p\<noteq>0\<close> \<open>q \<noteq> 0\<close> r1_def r2_def smods.simps)
hence "length (smods r1 r2)<length (smods p q)" by auto
moreover have "(\<forall>p\<in>set (smods r1 r2). \<forall>x. a < x \<and> x \<le> a' \<or> a' \<le> x \<and> x < a \<longrightarrow> poly p x \<noteq> 0)"
using "1.prems"(2) unfolding ps by auto
ultimately have "changes_poly_at (smods r1 r2) a = changes_poly_at (smods r1 r2) a'"
using "1.hyps" \<open>r1\<noteq>0\<close> \<open>poly r1 a\<noteq>0\<close> by metis
moreover have "changes_poly_at (smods p q) a = 1+changes_poly_at (smods r1 r2) a"
unfolding ps changes_poly_at_def using \<open>poly q a=0\<close> \<open>poly p a*poly r1 a<0\<close> by auto
moreover have "changes_poly_at (smods p q) a' = 1+changes_poly_at (smods r1 r2) a'"
proof -
have "poly p a * poly p a' \<ge>0" and "poly r1 a*poly r1 a'\<ge>0"
using a_a'_rel unfolding ps by auto
moreover have "poly p a'\<noteq>0" and "poly q a'\<noteq>0" and "poly r1 a'\<noteq>0"
using "1.prems"(2)[unfolded ps] \<open>a\<noteq>a'\<close> by auto
ultimately show ?thesis using \<open>poly p a*poly r1 a<0\<close> unfolding ps changes_poly_at_def
by (auto simp add: zero_le_mult_iff, auto simp add: mult_less_0_iff)
qed
ultimately show ?thesis by simp
qed
moreover have "\<lbrakk>q\<noteq>0;poly q a\<noteq>0\<rbrakk> \<Longrightarrow> ?case"
proof -
assume "q\<noteq>0" "poly q a\<noteq>0"
then obtain ps where ps:"smods p q=p#q#ps" "smods q r1=q#ps"
by (metis \<open>p\<noteq>0\<close> r1_def smods.simps)
hence "length (smods q r1) < length (smods p q)" by auto
moreover have "(\<forall>p\<in>set (smods q r1). \<forall>x. a < x \<and> x \<le> a' \<or> a' \<le> x \<and> x < a \<longrightarrow> poly p x \<noteq> 0)"
using "1.prems"(2) unfolding ps by auto
ultimately have "changes_poly_at (smods q r1) a = changes_poly_at (smods q r1) a'"
using "1.hyps" \<open>q\<noteq>0\<close> \<open>poly q a\<noteq>0\<close> by metis
moreover have "poly p a'\<noteq>0" and "poly q a'\<noteq>0"
using "1.prems"(2)[unfolded ps] \<open>a\<noteq>a'\<close> by auto
moreover have "poly p a * poly p a' \<ge>0" and "poly q a*poly q a'\<ge>0"
using a_a'_rel unfolding ps by auto
ultimately show ?thesis unfolding ps changes_poly_at_def using \<open>poly q a\<noteq>0\<close> \<open>poly p a\<noteq>0\<close>
by (auto simp add: zero_le_mult_iff,auto simp add: mult_less_0_iff)
qed
ultimately show ?case by blast
qed
lemma changes_itv_smods_congr:
fixes p q:: "real poly"
assumes "a<a'" "a'<b'" "b'<b" "poly p a\<noteq>0" "poly p b\<noteq>0"
assumes no_root:"\<forall>p\<in>set (smods p q). \<forall>x. ((a<x\<and>x\<le>a') \<or> (b'\<le>x \<and> x<b)) \<longrightarrow> poly p x \<noteq>0"
shows "changes_itv_smods a b p q=changes_itv_smods a' b' p q"
proof -
have "changes_poly_at (smods p q) a = changes_poly_at (smods p q) a'"
apply (rule changes_smods_congr[OF order.strict_implies_not_eq[OF \<open>a<a'\<close>] \<open>poly p a\<noteq>0\<close>])
by (metis assms(1) less_eq_real_def less_irrefl less_trans no_root)
moreover have "changes_poly_at (smods p q) b = changes_poly_at (smods p q) b'"
apply (rule changes_smods_congr[OF order.strict_implies_not_eq[OF \<open>b'<b\<close>,
symmetric] \<open>poly p b\<noteq>0\<close>])
by (metis assms(3) less_eq_real_def less_trans no_root)
ultimately show ?thesis unfolding changes_itv_smods_def Let_def by auto
qed
lemma cindex_poly_changes_itv_mods:
assumes "a<b" "poly p a\<noteq>0" "poly p b\<noteq>0"
shows "cindex_poly a b q p = changes_itv_smods a b p q" using assms
proof (induct "smods p q" arbitrary:p q a b)
case Nil
hence "p=0" by (metis smods_nil_eq)
thus ?case using \<open>poly p a \<noteq> 0\<close> by simp
next
case (Cons x1 xs)
have "p\<noteq>0" using \<open>poly p a \<noteq> 0\<close> by auto
obtain a' b' where "a<a'" "a'<b'" "b'<b"
and no_root:"\<forall>p\<in>set (smods p q). \<forall>x. ((a<x\<and>x\<le>a') \<or> (b'\<le>x \<and> x<b)) \<longrightarrow> poly p x \<noteq>0"
proof (induct "smods p q" arbitrary:p q thesis)
case Nil
define a' b' where "a'\<equiv>2/3 * a + 1/3 * b" and "b'\<equiv>1/3*a + 2/3*b"
have "a < a'" and "a' < b'" and "b' < b" unfolding a'_def b'_def using \<open>a<b\<close> by auto
moreover have "\<forall>p\<in>set (smods p q). \<forall>x. a < x \<and> x \<le> a' \<or> b' \<le> x \<and> x < b \<longrightarrow> poly p x \<noteq> 0"
unfolding \<open>[] = smods p q\<close>[symmetric] by auto
ultimately show ?case using Nil by auto
next
case (Cons x1 xs)
define r where "r\<equiv>- (p mod q)"
then have "smods p q = p # xs" and "smods q r = xs" and "p \<noteq> 0"
using \<open>x1 # xs = smods p q\<close>
by (auto simp del: smods.simps simp add: smods.simps [of p q] split: if_splits)
obtain a1 b1 where
"a < a1" "a1 < b1" "b1 < b" and
a1_b1_no_root:"\<forall>p\<in>set xs. \<forall>x. a < x \<and> x \<le> a1 \<or> b1 \<le> x \<and> x < b \<longrightarrow> poly p x \<noteq> 0"
using Cons(1)[OF \<open>smods q r=xs\<close>[symmetric]] \<open>smods q r=xs\<close> by auto
obtain a2 b2 where
"a<a2" and a2:"\<forall>x. a<x \<and> x\<le>a2 \<longrightarrow> poly p x \<noteq> 0"
"b2<b" and b2:"\<forall>x. b2\<le>x \<and> x<b \<longrightarrow> poly p x \<noteq> 0"
using next_non_root_interval[OF \<open>p\<noteq>0\<close>] last_non_root_interval[OF \<open>p\<noteq>0\<close>]
by (metis less_numeral_extra(3))
define a' b' where "a'\<equiv> if b2>a then Min{a1, b2, a2} else min a1 a2"
and "b'\<equiv>if a2 <b then Max{ b1, a2, b2} else max b1 b2"
have "a < a'" "a' < b'" "b' < b" unfolding a'_def b'_def
using \<open>a < a1\<close> \<open>a1 < b1\<close> \<open>b1 < b\<close> \<open>a<a2\<close> \<open>b2<b\<close> \<open>a<b\<close> by auto
moreover have "\<forall>p\<in>set xs. \<forall>x. a < x \<and> x \<le> a' \<or> b' \<le> x \<and> x < b \<longrightarrow> poly p x \<noteq> 0"
using a1_b1_no_root unfolding a'_def b'_def by auto
moreover have "\<forall>x. a < x \<and> x \<le> a' \<or> b' \<le> x \<and> x < b \<longrightarrow> poly p x \<noteq> 0"
using a2 b2 unfolding a'_def b'_def by auto
ultimately show ?case using Cons(3)[unfolded \<open>smods p q=p#xs\<close>] by auto
qed
have "q=0 \<Longrightarrow> ?case" by simp
moreover have "q\<noteq>0 \<Longrightarrow> ?case"
proof -
assume "q\<noteq>0"
define r where "r\<equiv>- (p mod q)"
obtain ps where ps:"smods p q=p#q#ps" "smods q r=q#ps" and "xs=q#ps"
unfolding r_def using \<open>q\<noteq>0\<close> \<open>p\<noteq>0\<close> \<open>x1 # xs = smods p q\<close>
by (metis list.inject smods.simps)
have "poly p a' \<noteq> 0" "poly p b' \<noteq> 0" "poly q a' \<noteq> 0" "poly q b' \<noteq> 0"
using no_root[unfolded ps] \<open>a'>a\<close> \<open>b'<b\<close> by auto
moreover hence
"changes_itv_smods a' b' p q = cross (p * q) a' b' + changes_itv_smods a' b' q r"
"cindex_poly a' b' q p = cross (p * q) a' b' + cindex_poly a' b' r q"
using changes_itv_smods_rec[OF \<open>a'<b'\<close>,of p q,folded r_def]
cindex_poly_rec[OF \<open>a'<b'\<close>,of p q,folded r_def] by auto
moreover have "changes_itv_smods a' b' q r = cindex_poly a' b' r q"
using Cons.hyps(1)[of q r a' b'] \<open>a' < b'\<close> \<open>q \<noteq> 0\<close> \<open>xs = q # ps\<close> ps(2)
\<open>poly q a' \<noteq> 0\<close> \<open>poly q b' \<noteq> 0\<close> by simp
ultimately have "changes_itv_smods a' b' p q = cindex_poly a' b' q p" by auto
thus ?thesis
using
changes_itv_smods_congr[OF \<open>a<a'\<close> \<open>a'<b'\<close> \<open>b'<b\<close> Cons(4,5),of q]
no_root cindex_poly_congr[OF \<open>a<a'\<close> \<open>a'<b'\<close> \<open>b'<b\<close> ] ps
by (metis insert_iff list.set(2))
qed
ultimately show ?case by metis
qed
lemma root_list_ub:
fixes ps:: "(real poly) list" and a::real
assumes "0\<notin>set ps"
obtains ub where "\<forall>p\<in>set ps. \<forall>x. poly p x=0 \<longrightarrow> x<ub"
and "\<forall>x\<ge>ub. \<forall>p\<in>set ps. sgn (poly p x) = sgn_pos_inf p" and "ub>a"
using assms
proof (induct ps arbitrary:thesis)
case Nil
show ?case using Nil(1)[of "a+1"] by auto
next
case (Cons p ps)
hence "p\<noteq>0" and "0\<notin>set ps" by auto
then obtain ub1 where ub1:"\<forall>p\<in>set ps. \<forall>x. poly p x = 0 \<longrightarrow> x < ub1" and
ub1_sgn:"\<forall>x\<ge>ub1. \<forall>p\<in>set ps. sgn (poly p x) = sgn_pos_inf p" and "ub1>a"
using Cons.hyps by auto
obtain ub2 where ub2:"\<forall>x. poly p x = 0 \<longrightarrow> x < ub2"
and ub2_sgn: "\<forall>x\<ge>ub2. sgn (poly p x) = sgn_pos_inf p"
using root_ub[OF \<open>p\<noteq>0\<close>] by auto
define ub where "ub\<equiv>max ub1 ub2"
have "\<forall>p\<in>set (p # ps). \<forall>x. poly p x = 0 \<longrightarrow> x < ub" using ub1 ub2 ub_def by force
moreover have "\<forall>x\<ge>ub. \<forall>p\<in>set (p # ps). sgn (poly p x) = sgn_pos_inf p"
using ub1_sgn ub2_sgn ub_def by auto
ultimately show ?case using Cons(2)[of ub] \<open>ub1>a\<close> ub_def by auto
qed
lemma root_list_lb:
fixes ps:: "(real poly) list" and b::real
assumes "0\<notin>set ps"
obtains lb where "\<forall>p\<in>set ps. \<forall>x. poly p x=0 \<longrightarrow> x>lb"
and "\<forall>x\<le>lb. \<forall>p\<in>set ps. sgn (poly p x) = sgn_neg_inf p" and "lb<b"
using assms
proof (induct ps arbitrary:thesis)
case Nil
show ?case using Nil(1)[of "b - 1"] by auto
next
case (Cons p ps)
hence "p\<noteq>0" and "0\<notin>set ps" by auto
then obtain lb1 where lb1:"\<forall>p\<in>set ps. \<forall>x. poly p x = 0 \<longrightarrow> x > lb1" and
lb1_sgn:"\<forall>x\<le>lb1. \<forall>p\<in>set ps. sgn (poly p x) = sgn_neg_inf p" and "lb1<b"
using Cons.hyps by auto
obtain lb2 where lb2:"\<forall>x. poly p x = 0 \<longrightarrow> x > lb2"
and lb2_sgn: "\<forall>x\<le>lb2. sgn (poly p x) = sgn_neg_inf p"
using root_lb[OF \<open>p\<noteq>0\<close>] by auto
define lb where "lb\<equiv>min lb1 lb2"
have "\<forall>p\<in>set (p # ps). \<forall>x. poly p x = 0 \<longrightarrow> x > lb" using lb1 lb2 lb_def by force
moreover have "\<forall>x\<le>lb. \<forall>p\<in>set (p # ps). sgn (poly p x) = sgn_neg_inf p"
using lb1_sgn lb2_sgn lb_def by auto
ultimately show ?case using Cons(2)[of lb] \<open>lb1<b\<close> lb_def by auto
qed
theorem sturm_tarski_interval:
assumes "a<b" "poly p a\<noteq>0" "poly p b\<noteq>0"
shows "taq {x. poly p x=0 \<and> a<x \<and> x<b} q = changes_itv_smods a b p (pderiv p * q)"
proof -
have "p\<noteq>0" using \<open>poly p a\<noteq>0\<close> by auto
thus ?thesis using cindex_poly_taq cindex_poly_changes_itv_mods[OF assms] by auto
qed
theorem sturm_tarski_above:
assumes "poly p a\<noteq>0"
shows "taq {x. poly p x=0 \<and> a<x} q = changes_gt_smods a p (pderiv p * q)"
proof -
define ps where "ps\<equiv>smods p (pderiv p * q)"
have "p\<noteq>0" and "p\<in>set ps" using \<open>poly p a\<noteq>0\<close> ps_def by auto
obtain ub where ub:"\<forall>p\<in>set ps. \<forall>x. poly p x=0 \<longrightarrow> x<ub"
and ub_sgn:"\<forall>x\<ge>ub. \<forall>p\<in>set ps. sgn (poly p x) = sgn_pos_inf p"
and "ub>a"
using root_list_ub[OF no_0_in_smods,of p "pderiv p * q",folded ps_def]
by auto
have "taq {x. poly p x=0 \<and> a<x} q = taq {x. poly p x=0 \<and> a<x \<and> x<ub} q"
unfolding taq_def by (rule sum.cong,insert ub \<open>p\<in>set ps\<close>,auto)
moreover have "changes_gt_smods a p (pderiv p * q) = changes_itv_smods a ub p (pderiv p * q)"
proof -
have "map (sgn \<circ> (\<lambda>p. poly p ub)) ps = map sgn_pos_inf ps"
using ub_sgn[THEN spec,of ub,simplified]
by (metis (mono_tags, lifting) comp_def list.map_cong0)
hence "changes_poly_at ps ub=changes_poly_pos_inf ps"
unfolding changes_poly_pos_inf_def changes_poly_at_def
by (subst changes_map_sgn_eq,metis map_map)
thus ?thesis unfolding changes_gt_smods_def changes_itv_smods_def ps_def
by metis
qed
moreover have "poly p ub\<noteq>0" using ub \<open>p\<in>set ps\<close> by auto
ultimately show ?thesis using sturm_tarski_interval[OF \<open>ub>a\<close> assms] by auto
qed
theorem sturm_tarski_below:
assumes "poly p b\<noteq>0"
shows "taq {x. poly p x=0 \<and> x<b} q = changes_le_smods b p (pderiv p * q)"
proof -
define ps where "ps\<equiv>smods p (pderiv p * q)"
have "p\<noteq>0" and "p\<in>set ps" using \<open>poly p b\<noteq>0\<close> ps_def by auto
obtain lb where lb:"\<forall>p\<in>set ps. \<forall>x. poly p x=0 \<longrightarrow> x>lb"
and lb_sgn:"\<forall>x\<le>lb. \<forall>p\<in>set ps. sgn (poly p x) = sgn_neg_inf p"
and "lb<b"
using root_list_lb[OF no_0_in_smods,of p "pderiv p * q",folded ps_def]
by auto
have "taq {x. poly p x=0 \<and> x<b} q = taq {x. poly p x=0 \<and> lb<x \<and> x<b} q"
unfolding taq_def by (rule sum.cong,insert lb \<open>p\<in>set ps\<close>,auto)
moreover have "changes_le_smods b p (pderiv p * q) = changes_itv_smods lb b p (pderiv p * q)"
proof -
have "map (sgn \<circ> (\<lambda>p. poly p lb)) ps = map sgn_neg_inf ps"
using lb_sgn[THEN spec,of lb,simplified]
by (metis (mono_tags, lifting) comp_def list.map_cong0)
hence "changes_poly_at ps lb=changes_poly_neg_inf ps"
unfolding changes_poly_neg_inf_def changes_poly_at_def
by (subst changes_map_sgn_eq,metis map_map)
thus ?thesis unfolding changes_le_smods_def changes_itv_smods_def ps_def
by metis
qed
moreover have "poly p lb\<noteq>0" using lb \<open>p\<in>set ps\<close> by auto
ultimately show ?thesis using sturm_tarski_interval[OF \<open>lb<b\<close> _ assms] by auto
qed
theorem sturm_tarski_R:
shows "taq {x. poly p x=0} q = changes_R_smods p (pderiv p * q)"
proof (cases "p=0")
case True
then show ?thesis
unfolding taq_def using infinite_UNIV_char_0 by (auto intro!:sum.infinite)
next
case False
define ps where "ps\<equiv>smods p (pderiv p * q)"
have "p\<in>set ps" using ps_def \<open>p\<noteq>0\<close> by auto
obtain lb where lb:"\<forall>p\<in>set ps. \<forall>x. poly p x=0 \<longrightarrow> x>lb"
and lb_sgn:"\<forall>x\<le>lb. \<forall>p\<in>set ps. sgn (poly p x) = sgn_neg_inf p"
and "lb<0"
using root_list_lb[OF no_0_in_smods,of p "pderiv p * q",folded ps_def]
by auto
obtain ub where ub:"\<forall>p\<in>set ps. \<forall>x. poly p x=0 \<longrightarrow> x<ub"
and ub_sgn:"\<forall>x\<ge>ub. \<forall>p\<in>set ps. sgn (poly p x) = sgn_pos_inf p"
and "ub>0"
using root_list_ub[OF no_0_in_smods,of p "pderiv p * q",folded ps_def]
by auto
have "taq {x. poly p x=0} q = taq {x. poly p x=0 \<and> lb<x \<and> x<ub} q"
unfolding taq_def by (rule sum.cong,insert lb ub \<open>p\<in>set ps\<close>,auto)
moreover have "changes_R_smods p (pderiv p * q) = changes_itv_smods lb ub p (pderiv p * q)"
proof -
have "map (sgn \<circ> (\<lambda>p. poly p lb)) ps = map sgn_neg_inf ps"
and "map (sgn \<circ> (\<lambda>p. poly p ub)) ps = map sgn_pos_inf ps"
using lb_sgn[THEN spec,of lb,simplified] ub_sgn[THEN spec,of ub,simplified]
by (metis (mono_tags, lifting) comp_def list.map_cong0)+
hence "changes_poly_at ps lb=changes_poly_neg_inf ps
\<and> changes_poly_at ps ub=changes_poly_pos_inf ps"
unfolding changes_poly_neg_inf_def changes_poly_at_def changes_poly_pos_inf_def
by (subst (1 3) changes_map_sgn_eq,metis map_map)
thus ?thesis unfolding changes_R_smods_def changes_itv_smods_def ps_def
by metis
qed
moreover have "poly p lb\<noteq>0" and "poly p ub\<noteq>0" using lb ub \<open>p\<in>set ps\<close> by auto
moreover have "lb<ub" using \<open>lb<0\<close> \<open>0<ub\<close> by auto
ultimately show ?thesis using sturm_tarski_interval by auto
qed
theorem sturm_interval:
assumes "a < b" "poly p a \<noteq> 0" "poly p b \<noteq> 0"
shows "card {x. poly p x = 0 \<and> a < x \<and> x < b} = changes_itv_smods a b p (pderiv p)"
using sturm_tarski_interval[OF assms, unfolded taq_def,of 1] by force
theorem sturm_above:
assumes "poly p a \<noteq> 0"
shows "card {x. poly p x = 0 \<and> a < x} = changes_gt_smods a p (pderiv p)"
using sturm_tarski_above[OF assms, unfolded taq_def,of 1] by force
theorem sturm_below:
assumes "poly p b \<noteq> 0"
shows "card {x. poly p x = 0 \<and> x < b} = changes_le_smods b p (pderiv p)"
using sturm_tarski_below[OF assms, unfolded taq_def,of 1] by force
theorem sturm_R:
shows "card {x. poly p x=0} = changes_R_smods p (pderiv p)"
using sturm_tarski_R[of _ 1,unfolded taq_def] by force
end
|
Require Import Crypto.Arithmetic.PrimeFieldTheorems.
Require Import Crypto.Specific.solinas32_2e230m27_9limbs.Synthesis.
(* TODO : change this to field once field isomorphism happens *)
Definition carry :
{ carry : feBW_loose -> feBW_tight
| forall a, phiBW_tight (carry a) = (phiBW_loose a) }.
Proof.
Set Ltac Profiling.
Time synthesize_carry ().
Show Ltac Profile.
Time Defined.
Print Assumptions carry.
|
REBOL [
System: "REBOL [R3] Language Interpreter and Run-time Environment"
Title: "Root context"
Rights: {
Copyright 2012 REBOL Technologies
REBOL is a trademark of REBOL Technologies
}
License: {
Licensed under the Apache License, Version 2.0.
See: http://www.apache.org/licenses/LICENSE-2.0
}
Purpose: {
Root system values. This context is hand-made very early at boot time
to allow it to hold key system values during boot up. Most of these
are put here to prevent them from being garbage collected.
}
Note: "See Task Context for per-task globals"
]
self ; (hand-built CONTEXT! value - but, has no WORD table!)
root ; the root context as a block (for GC protection)
system ; system object
errobj ; error object template
strings ; low-level strings accessed via Boot_Strs[] (GC protection)
typesets ; block of TYPESETs used by system; expandable
noneval ; NONE value
noname ; noname function word
boot ; boot block defined in boot.r (GC'd after boot is done)
script ; final boot script
|
[STATEMENT]
lemma fmrel_on_fset_acyclic':
"acyclicP_on (fmran' ym) R \<Longrightarrow>
fmrel_on_fset (fmdom ym) R\<^sup>+\<^sup>+ xm ym \<Longrightarrow>
fmrel_on_fset (fmdom xm) R ym xm \<Longrightarrow>
xm = ym"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>acyclicP_on (fmran' ym) R; fmrel_on_fset (fmdom ym) R\<^sup>+\<^sup>+ xm ym; fmrel_on_fset (fmdom xm) R ym xm\<rbrakk> \<Longrightarrow> xm = ym
[PROOF STEP]
unfolding fmrel_on_fset_fmrel_restrict
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>acyclicP_on (fmran' ym) R; fmrel R\<^sup>+\<^sup>+ (fmrestrict_fset (fmdom ym) xm) (fmrestrict_fset (fmdom ym) ym); fmrel R (fmrestrict_fset (fmdom xm) ym) (fmrestrict_fset (fmdom xm) xm)\<rbrakk> \<Longrightarrow> xm = ym
[PROOF STEP]
by (metis (no_types, lifting) ffmember_filter fmdom_filter
fmfilter_alt_defs(5) fmfilter_cong fmrel_acyclic'
fmrel_fmdom_eq fmrestrict_fset_dom) |
(* Title: Transcendence_Series.thy
Authors: Angeliki Koutsoukou-Argyraki and Wenda Li, University of Cambridge
*)
section \<open>The transcendence of certain infinite series\<close>
theory "Transcendence_Series" imports
"HOL-Analysis.Multivariate_Analysis"
"HOL-Computational_Algebra.Polynomial"
Prime_Number_Theorem.Prime_Number_Theorem_Library
begin
text \<open>
We formalise the proofs of two transcendence criteria by J. Han\v{c}l and P. Rucki that
assert the transcendence of the sums of certain infinite series built up by sequences that
fulfil certain properties (Theorems 2.1 and 2.2 in \cite{hancl2005}, HanclRucki1 and HanclRucki2
here respectively). Both proofs make use of Roth's celebrated theorem on diophantine approximations
to algebraic numbers from 1955 \cite{roth_1955} which we assume and implement within the locale
RothsTheorem.
A small mistake was detected in the original proof of Theorem 2.1, and the authors suggested
to us a fix for the problem (in communication by email).
Our formalised proof incorporates this correction (see the Remark in the proof of HanclRucki1).
\<close>
subsection \<open>Misc\<close>
lemma powr_less_inverse_iff:
fixes x y z::real
assumes "x>0""y>0""z>0"
shows "x powr y < z \<longleftrightarrow> x < z powr (inverse y)"
proof
assume "x powr y < z"
from powr_less_mono2[OF _ _ this,of "inverse y"]
show "x < z powr inverse y"
using assms by (auto simp:powr_powr)
next
assume *:"x < z powr inverse y"
from powr_less_mono2[OF _ _ *,of y] show "x powr y < z"
using assms by (auto simp:powr_powr)
qed
lemma powr_less_inverse_iff':
fixes x y z::real
assumes "x>0""y>0""z>0"
shows "z< x powr y \<longleftrightarrow> z powr (inverse y) < x"
using powr_less_inverse_iff[symmetric,of _ "inverse y"] assms by auto
lemma powr_less_eq_inverse_iff:
fixes x y z::real
assumes "x>0""y>0""z>0"
shows "x powr y \<le> z \<longleftrightarrow> x \<le> z powr (inverse y)"
by (meson assms(1) assms(2) assms(3) not_less powr_less_inverse_iff')
lemma powr_less_eq_inverse_iff':
fixes x y z::real
assumes "x>0""y>0""z>0"
shows "z\<le> x powr y \<longleftrightarrow> z powr (inverse y) \<le> x"
by (simp add: assms(1) assms(2) assms(3) powr_less_eq_inverse_iff)
lemma tendsto_PInfty_mono:
assumes "(ereal o f) \<longlonglongrightarrow> \<infinity>" "\<forall>\<^sub>F x in sequentially. f x \<le> g x"
shows "(ereal o g) \<longlonglongrightarrow> \<infinity>"
using assms unfolding comp_def tendsto_PInfty_eq_at_top
by (elim filterlim_at_top_mono, simp)
lemma limsup_infinity_imp_Inf_many:
assumes "limsup f = \<infinity>"
shows "(\<forall> m. (\<exists>\<^sub>\<infinity>i. f i > ereal m))" unfolding INFM_nat
proof (clarify,rule ccontr)
fix m k assume "\<not> (\<exists>n>k. ereal m < f n)"
then have "\<forall>n>k. f n \<le> ereal m" by auto
then have "\<forall>\<^sub>F n in sequentially. f n \<le> ereal m"
using eventually_at_top_dense by blast
then have "limsup f \<le> ereal m" using Limsup_bounded by auto
then show False using assms by simp
qed
lemma snd_quotient_plus_leq:
defines "de\<equiv>(snd o quotient_of)"
shows "de (x+y) \<le> de x * de y "
proof -
obtain x1 x2 y1 y2 where xy: "quotient_of x = (x1,x2)" "quotient_of y=(y1,y2)"
by (meson surj_pair)
have "x2>0" "y2>0" using xy quotient_of_denom_pos by blast+
then show ?thesis
unfolding de_def comp_def rat_plus_code xy
apply (auto split:prod.split simp:Rat.normalize_def Let_def)
by (smt div_by_1 gcd_pos_int int_div_less_self mult_eq_0_iff mult_sign_intros(1))
qed
lemma quotient_of_inj: "inj quotient_of"
unfolding inj_def by (simp add: quotient_of_inject)
lemma infinite_inj_imageE:
assumes "infinite A" "inj_on f A" "f ` A \<subseteq> B"
shows "infinite B"
using assms inj_on_finite by blast
lemma incseq_tendsto_limsup:
fixes f::"nat \<Rightarrow> 'a::{complete_linorder,linorder_topology}"
assumes "incseq f"
shows "f \<longlonglongrightarrow> limsup f"
using LIMSEQ_SUP assms convergent_def convergent_ereal tendsto_Limsup
trivial_limit_sequentially by blast
subsection \<open>Main proofs\<close>
text \<open>Since the proof of Roths theorem has not been formalized yet, we implement it into a locale
and used it as an assumption.\<close>
locale RothsTheorem =
assumes RothsTheorem:"\<forall>\<xi> \<kappa>. algebraic \<xi> \<and> \<xi> \<notin> \<rat> \<and> infinite {(p,q). q>0 \<and>
coprime p q \<and> \<bar>\<xi> - of_int p / of_int q\<bar> < 1 / q powr \<kappa>} \<longrightarrow> \<kappa> \<le> 2"
theorem (in RothsTheorem) HanclRucki1:
fixes a b ::"nat\<Rightarrow>int" and \<delta> ::real
defines "aa\<equiv>(\<lambda>n. real_of_int (a n))" and "bb\<equiv>(\<lambda>n. real_of_int (b n))"
assumes a_pos:"\<forall> k. a k >0" and b_pos:"\<forall> k. b k >0" and "\<delta> >0"
and limsup_infy:"limsup (\<lambda> k. aa (k+1)/(\<Prod>i = 0..k. aa i)powr(2+\<delta>)*(1/bb (k+1))) = \<infinity>"
and liminf_1:"liminf (\<lambda>k. aa (k+1) / aa k * bb k / bb (k+1)) > 1"
shows "\<not> algebraic(suminf (\<lambda> k. bb k / aa k))"
proof -
have summable:"summable (\<lambda> k. bb k / aa k)"
proof (rule ratio_test_convergence)
have [simp]:"aa k>0" "bb k>0" for k
unfolding aa_def bb_def using a_pos b_pos by auto
show "\<forall>\<^sub>F n in sequentially. 0 < bb n / aa n"
apply (rule eventuallyI)
by auto
show "1 < liminf (\<lambda>n. ereal (bb n / aa n / (bb (Suc n) / aa (Suc n))))"
using liminf_1 by (auto simp:algebra_simps)
qed
have [simp]: "aa k>0" "bb k>0" for k unfolding aa_def bb_def
by (auto simp add: a_pos b_pos)
have ab_1:"aa k\<ge>1" "bb k\<ge>1" for k
unfolding aa_def bb_def using a_pos b_pos
by (auto simp add: int_one_le_iff_zero_less)
define B where "B=liminf (\<lambda>x. ereal (aa (x + 1) / aa x * bb x / bb (x + 1)))"
define M where "M= (case B of ereal m \<Rightarrow> (m+1)/2 | _ \<Rightarrow> 2)"
have "M > 1" "M < B"
using liminf_1 unfolding M_def
apply (fold B_def)
by (cases B,auto)+
text \<open>
Remark:
In the original proof of Theorem 2.1 in \cite{hancl2005}
it was claimed in p.534 that from assumption (3) (i.e. @{thm liminf_1}),
we obtain that:
$\forall A>1~\exists k_0~ \forall k > k_0~ \frac{1}{A} \frac{b_k}{ a_k} > \frac{ b_{k+1}}{ a_{k+1}} $,
however note the counterexample where
$a_{k+1}= k (a_1 a_2 ... a_k)^{\lceil 2+ \delta \rceil}$ if k is odd, and
$a_{k+1} = 2 a_k$ otherwise, with $b_k =1$ for all $k$.
In commmunication by email the authors suggested to replace the claim
$\forall A>1~\exists k_0~ \forall k > k_0~ \frac{1}{A} \frac{b_k}{ a_k} > \frac{ b_{k+1}}{ a_{k+1}} $
with
$\exists A>1~\exists k_0~ \forall k > k_0~ \frac{1}{A} \frac{b_k}{ a_k} > \frac{ b_{k+1}}{ a_{k+1}} $
which solves the problem and the proof proceeds as in the paper.
The witness for $\exists A>1 $ is denoted by $M$ here.\<close>
have bb_aa_event:"\<forall>\<^sub>F k in sequentially. (1/M)*(bb k / aa k)> bb(k+1)/ aa (k+1)"
using less_LiminfD[OF \<open>M < B\<close>[unfolded B_def],simplified]
apply eventually_elim
using \<open>M > 1\<close> by (auto simp:divide_simps algebra_simps)
have bb_aa_p:"\<forall>\<^sub>F k in sequentially. \<forall>p. bb(k+p)/ aa (k+p) \<le> (1/M^p)*(bb k / aa k)"
proof -
obtain k0 where k0_ineq:
"\<forall>n\<ge>k0. bb (n + 1) / aa (n + 1) < 1 / M * (bb n / aa n)"
using bb_aa_event unfolding eventually_sequentially
by auto
have "bb(k+p)/ aa (k+p) \<le> (1/M^p)*(bb k / aa k)" when "k\<ge>k0" for p k
proof (induct p)
case 0
then show ?case by auto
next
case (Suc p)
have " bb (k + Suc p) / aa (k + Suc p) < 1 / M * (bb (k+p) / aa (k+p))"
using k0_ineq[rule_format,of "k+p"] that by auto
also have "... \<le> 1 / M ^(Suc p) * (bb k / aa k)"
using Suc \<open>M>1\<close> by (auto simp add:field_simps)
finally show ?case by auto
qed
then show ?thesis unfolding eventually_sequentially by auto
qed
define \<xi> where "\<xi> = suminf (\<lambda> k. bb k / aa k)"
have \<xi>_Inf_many:"\<exists>\<^sub>\<infinity> k. \<bar>\<xi> - (\<Sum>k = 0..k. bb k / aa k)\<bar> < 1 / prod aa {0..k} powr (2 + \<delta>)"
proof -
have "\<bar>\<xi> - (\<Sum>i = 0..k. bb i / aa i)\<bar> = \<bar>\<Sum>i. bb (i+(k+1)) / aa (i+(k+1))\<bar>"
for k
unfolding \<xi>_def
apply (subst suminf_minus_initial_segment[of _ "k+1",OF summable])
using atLeast0AtMost lessThan_Suc_atMost by auto
moreover have "\<exists>\<^sub>\<infinity> k. \<bar>\<Sum>i. bb(i+(k+1))/ aa (i+(k+1))\<bar>
< 1 / prod aa {0..k} powr (2 + \<delta>)"
proof -
define P where "P = (\<lambda> i. \<forall>p. bb (i + 1 + p) / aa (i + 1 + p)
\<le> 1 / M ^ p * (bb (i + 1) / aa (i + 1)))"
define Q where "Q= (\<lambda> i. ereal (M / (M - 1))
< ereal (aa (i + 1) / prod aa {0..i} powr (2 + \<delta>) * (1 / bb (i + 1))))"
have "\<forall>\<^sub>\<infinity> i. P i"
using bb_aa_p[THEN sequentially_offset, of 1] cofinite_eq_sequentially
unfolding P_def by auto
moreover have "\<exists>\<^sub>\<infinity>i. Q i"
using limsup_infy[THEN limsup_infinity_imp_Inf_many,rule_format,of "(M / (M -1))"]
unfolding Q_def .
moreover have "\<bar>\<Sum>i. bb(i+(k+1))/ aa (i+(k+1))\<bar>
< 1 / prod aa {0..k} powr (2 + \<delta>)"
when "P k" "Q k" for k
proof -
have summable_M:"summable (\<lambda>i. 1 / M ^ i)"
apply (rule summable_ratio_test[of "1/M"])
using \<open>M>1\<close> by auto
have "(\<Sum>i. bb (i + (k + 1)) / aa (i + (k + 1))) \<ge> 0"
apply (rule suminf_nonneg)
subgoal using summable_ignore_initial_segment[OF summable,of "k+1"] by auto
subgoal by (simp add: less_imp_le)
done
then have "\<bar>\<Sum>i. bb (i + (k + 1)) / aa (i + (k + 1))\<bar>
= (\<Sum>i. bb (i + (k + 1)) / aa (i + (k + 1)))"
by auto
also have "... \<le> (\<Sum>i. 1 / M ^ i * (bb (k + 1) / aa (k + 1)))"
apply (rule suminf_le)
subgoal using that(1) unfolding P_def by (auto simp add:algebra_simps)
subgoal using summable_ignore_initial_segment[OF summable,of "k+1"] by auto
subgoal using summable_mult2[OF summable_M,of " bb (k + 1) / aa (k + 1)"]
by auto
done
also have "... = (bb (k + 1) / aa (k + 1)) * (\<Sum>i. 1 / M ^ i)"
using suminf_mult2[OF summable_M,of " bb (k + 1) / aa (k + 1)"]
by (auto simp:algebra_simps)
also have "... = (bb (k + 1) / aa (k + 1)) * (\<Sum>i. (1 / M) ^ i)"
using \<open>M>1\<close> by (auto simp: field_simps)
also have "... = (bb (k + 1) / aa (k + 1)) * (M / (M -1))"
apply (subst suminf_geometric)
using \<open>M>1\<close> by (auto simp: field_simps)
also have "... < (bb (k + 1) / aa (k + 1)) * (aa (k + 1) /
prod aa {0..k} powr (2 + \<delta>) * (1 / bb (k + 1)))"
apply (subst mult_less_cancel_left_pos)
using that(2) unfolding Q_def by auto
also have "... = 1/ prod aa {0..k} powr (2 + \<delta>)"
using ab_1[of "Suc k"] by auto
finally show ?thesis .
qed
ultimately show ?thesis by (smt INFM_conjI INFM_mono)
qed
ultimately show ?thesis by auto
qed
define pq where "pq = (\<lambda>k. quotient_of (\<Sum>i=0..k. of_int (b i) / of_int (a i)))"
define p q where "p = fst \<circ> pq" and "q = snd \<circ> pq"
have coprime_pq:"coprime (p k) (q k)"
and q_pos:"q k > 0" and pq_sum:"p k / q k = (\<Sum>i=0..k. b i / a i)" for k
proof -
have eq: "quotient_of (\<Sum>i=0..k. of_int (b i) / of_int (a i)) = (p k, q k)"
by (simp add: p_def q_def pq_def)
from quotient_of_coprime[OF eq] show "coprime (p k) (q k)" .
from quotient_of_denom_pos[OF eq] show "q k > 0" .
have "(\<Sum>i=0..k. b i / a i) = of_rat (\<Sum>i=0..k. of_int (b i) / of_int (a i))"
by (simp add: of_rat_sum of_rat_divide)
also have "(\<Sum>i=0..k. rat_of_int (b i) / rat_of_int (a i)) =
rat_of_int (p k) / rat_of_int (q k)"
using quotient_of_div[OF eq] by simp
finally show "p k / q k = (\<Sum>i=0..k. b i / a i)" by (simp add:of_rat_divide)
qed
have \<xi>_Inf_many2:"\<exists>\<^sub>\<infinity> k. \<bar>\<xi> - p k / q k\<bar>
< 1 / q k powr (2 + \<delta>)"
using \<xi>_Inf_many
proof (elim INFM_mono)
fix k assume asm:"\<bar>\<xi> - (\<Sum>k = 0..k. bb k / aa k)\<bar> < 1 / prod aa {0..k} powr (2 + \<delta>)"
have "\<bar>\<xi> - real_of_int (p k) / real_of_int (q k)\<bar>
= \<bar>\<xi> - (\<Sum>k = 0..k. bb k / aa k)\<bar>"
using pq_sum unfolding aa_def bb_def by auto
also have "... < 1 / prod aa {0..k} powr (2 + \<delta>)"
using asm by auto
also have "... \<le> 1 / q k powr (2 + \<delta>)"
proof -
have "q k \<le> prod aa {0..k}"
proof (induct k)
case 0
then show ?case unfolding q_def pq_def aa_def
apply (simp add:rat_divide_code of_int_rat quotient_of_Fract)
using ab_1[of 0,unfolded aa_def bb_def] unfolding Let_def normalize_def
apply auto
by (metis div_by_1 gcd_pos_int less_imp_le less_trans nonneg1_imp_zdiv_pos_iff
not_less zdiv_mono2)
next
case (Suc k)
define de where "de=snd \<circ> quotient_of"
have "real_of_int (q (Suc k))
= de (\<Sum>i=0..Suc k. of_int (b i) / of_int (a i))"
unfolding q_def pq_def de_def by simp
also have "... = de ((\<Sum>i=0..k. of_int (b i) / of_int (a i))
+ of_int (b (Suc k)) / of_int (a (Suc k)))"
by simp
also have "... \<le> de (\<Sum>i=0..k. of_int (b i) / of_int (a i))
* de (of_int (b (Suc k)) / of_int (a (Suc k)))"
using snd_quotient_plus_leq[folded de_def] by presburger
also have "... = q k * de (of_int (b (Suc k)) / of_int (a (Suc k)))"
unfolding q_def pq_def de_def by auto
also have "... = q k * snd (Rat.normalize (b (Suc k), a (Suc k)))"
by (simp add:rat_divide_code of_int_rat quotient_of_Fract de_def)
also have "... \<le> q k * aa (Suc k)"
using ab_1[of "Suc k"] q_pos[of "k"]
unfolding normalize_def aa_def bb_def Let_def
apply auto
by (metis div_by_1 int_one_le_iff_zero_less less_trans
nonneg1_imp_zdiv_pos_iff not_less zdiv_mono2 zero_less_one)
also have "... \<le> prod aa {0..k} * aa (Suc k)"
using Suc ab_1[of "Suc k"] by auto
also have "... = prod aa {0..Suc k}"
by (simp add: prod.atLeast0_atMost_Suc)
finally show ?case .
qed
then show ?thesis
by (smt \<open>0 < \<delta>\<close> frac_le of_int_0 of_int_le_iff powr_gt_zero
powr_mono2 q_pos)
qed
finally show "\<bar>\<xi> - real_of_int (p k) / real_of_int (q k)\<bar> < 1 / real_of_int (q k) powr (2 + \<delta>)" .
qed
define pqs where "pqs={(p, q). q>0 \<and> coprime p q
\<and> \<bar>\<xi> - real_of_int p / real_of_int q\<bar> < 1 / q powr (2 + \<delta>)}"
have \<xi>_infinite:"infinite pqs"
proof -
define A where "A={k. \<bar>\<xi> - (p k) / (q k)\<bar> < 1 / (q k) powr (2 + \<delta>)}"
have "\<exists>\<^sub>\<infinity> k. \<bar>\<xi> - p k / q k\<bar> < 1 / q k powr (2 + \<delta>)"
using \<xi>_Inf_many2 .
then have "infinite A"
unfolding Inf_many_def A_def by auto
moreover have "inj_on (\<lambda>k. (p k, q k)) A"
proof -
define g where "g=(\<lambda>i. rat_of_int (b i) / rat_of_int (a i))"
define f where "f=(\<lambda>k. \<Sum>i = 0..k. g i)"
have g_pos:"g i>0" for i
unfolding g_def by (simp add: a_pos b_pos)
have "strict_mono f" unfolding strict_mono_def f_def
proof safe
fix x y::nat assume "x < y"
then have "sum g {0..y} - sum g {0..x} = sum g {x<..y}"
apply (subst Groups_Big.sum_diff[symmetric])
by (auto intro:arg_cong2[where f=sum])
also have "... > 0"
apply (rule ordered_comm_monoid_add_class.sum_pos)
using \<open>x<y\<close> g_pos by auto
finally have "sum g {0..y} - sum g {0..x} >0" .
then show "sum g {0..x} < sum g {0..y}" by auto
qed
then have "inj f" using strict_mono_imp_inj_on by auto
then have "inj (quotient_of o f)" by (simp add: inj_compose quotient_of_inj)
then have "inj (\<lambda>k. (p k, q k))"
unfolding f_def p_def q_def pq_def comp_def
apply (fold g_def)
by auto
then show ?thesis by (auto elim:subset_inj_on)
qed
moreover have "(\<lambda>k. (p k, q k)) ` A \<subseteq> pqs"
unfolding A_def pqs_def using coprime_pq q_pos by auto
ultimately show ?thesis
apply (elim infinite_inj_imageE)
by auto
qed
moreover have "finite pqs" if "\<xi> \<in> \<rat>"
proof -
obtain m n where \<xi>_mn:"\<xi> = (of_int m / of_int n)" and "coprime m n" "n>0"
proof -
obtain m n where mn:"\<bar>\<xi>\<bar> = (of_nat m / of_nat n)" "coprime m n" "n\<noteq>0"
using Rats_abs_nat_div_natE[OF \<open>\<xi> \<in> \<rat>\<close> Rats_abs_nat_div_natE]
by metis
define m' and n'::int
where "m'=(if \<xi> > 0 then nat m else -nat m)" and "n'=nat n"
then have "\<xi> = (of_int m' / of_int n')" "coprime m' n'" "n'>0"
using mn by auto
then show ?thesis using that by auto
qed
have "pqs \<subseteq> {(m,n)} \<union> {x. x \<in>pqs \<and> - \<bar>m\<bar> - 1 \<le>fst x \<and> fst x \<le> \<bar>m\<bar> + 1 \<and> 0<snd x \<and> snd x < n }"
proof (rule subsetI)
fix x assume "x \<in> pqs"
define p q where "p=fst x" and "q=snd x"
have "q>0" "coprime p q" and pq_less:"\<bar>\<xi> - p / q\<bar> < 1 / q powr (2 + \<delta>)"
using \<open>x\<in>pqs\<close> unfolding p_def q_def pqs_def by auto
have q_lt_n:"q<n" when "m\<noteq>p \<or> n\<noteq>q"
proof -
have "m * q \<noteq> n * p" using that \<open>coprime m n\<close> \<open>coprime p q\<close> \<open>q>0\<close> \<open>n>0\<close>
by (metis eq_rat(1) fst_conv int_one_le_iff_zero_less mult.commute normalize_stable
not_one_le_zero quotient_of_Fract snd_conv)
then have "1/(n*q) \<le> \<bar>m/n - p/q\<bar>"
using \<open>q>0\<close> \<open>n>0\<close>
apply (auto simp:field_simps)
by (metis add_diff_cancel_left' diff_diff_eq2 diff_zero less_irrefl not_le of_int_diff
of_int_lessD of_int_mult)
also have "... < 1 / q powr (2 + \<delta>)"
using pq_less unfolding \<xi>_mn by auto
also have "... \<le> 1 / q ^2"
proof -
have "real_of_int (q\<^sup>2) = q powr 2"
apply (subst powr_numeral)
unfolding power2_eq_square using \<open>q>0\<close> by auto
also have "... \<le> q powr (2 + \<delta>)"
apply (rule powr_mono)
using \<open>q>0\<close> \<open>\<delta>>0\<close> by auto
finally have "real_of_int (q\<^sup>2) \<le> real_of_int q powr (2 + \<delta>)" .
moreover have "real_of_int q powr (2 + \<delta>) > 0" using \<open>0 < q\<close> by auto
ultimately show ?thesis by (auto simp:field_simps)
qed
finally have " 1 / (n * q) < 1 / q\<^sup>2" .
then show ?thesis using \<open>q>0\<close> \<open>n>0\<close>
unfolding power2_eq_square by (auto simp:field_simps)
qed
moreover have "- \<bar>m\<bar> - 1 \<le> p \<and> p \<le> \<bar>m\<bar> + 1" when "m\<noteq>p \<or> n\<noteq>q"
proof -
define qn where "qn=q/n"
have "0<qn" "qn<1" unfolding qn_def using q_lt_n[OF \<open>m\<noteq>p \<or> n\<noteq>q\<close>] \<open>q>0\<close> by auto
have "\<bar>m/n - p / q\<bar> < 1 / q powr (2 + \<delta>)" using pq_less unfolding \<xi>_mn by simp
then have "\<bar>p / q - m/n\<bar> < 1 / q powr (2 + \<delta>)" by simp
then have " m/n- 1 / q powr (2 + \<delta>) < p/q \<and> p/q < m/n + 1 / q powr (2 + \<delta>)"
unfolding abs_diff_less_iff by auto
then have "qn*m- q / q powr (2 + \<delta>) < p \<and> p < qn*m + q / q powr (2 + \<delta>)"
unfolding qn_def using \<open>q>0\<close> by (auto simp:field_simps)
moreover have "- \<bar>m\<bar> - 1 \<le> qn*m- q / q powr (2 + \<delta>)"
proof -
have "- \<bar>m\<bar> \<le> qn*m" using \<open>0<qn\<close> \<open>qn<1\<close>
apply (cases "m\<ge>0")
subgoal
apply simp
by (meson less_eq_real_def mult_nonneg_nonneg neg_le_0_iff_le of_int_0_le_iff order_trans)
subgoal by simp
done
moreover have "- 1 \<le> - q / q powr (2 + \<delta>)"
proof -
have "q = q powr 1" using \<open>0 < q\<close> by auto
also have "... \<le>q powr (2 + \<delta>)"
apply (rule powr_mono)
using \<open>q>0\<close> \<open>\<delta>>0\<close> by auto
finally have "q \<le> q powr (2 + \<delta>)" .
then show ?thesis using \<open>0 < q\<close> by auto
qed
ultimately show ?thesis by auto
qed
moreover have "qn*m + q / q powr (2 + \<delta>) \<le> \<bar>m\<bar> + 1"
proof -
have "qn*m \<le> \<bar>m\<bar>" using \<open>0<qn\<close> \<open>qn<1\<close>
apply (cases "m\<ge>0")
subgoal by (simp add: mult_left_le_one_le)
subgoal by (smt of_int_0_le_iff zero_le_mult_iff)
done
moreover have "q / q powr (2 + \<delta>) \<le> 1"
proof -
have "q = q powr 1" using \<open>0 < q\<close> by auto
also have "... \<le>q powr (2 + \<delta>)"
apply (rule powr_mono)
using \<open>q>0\<close> \<open>\<delta>>0\<close> by auto
finally have "q \<le> q powr (2 + \<delta>)" .
then show ?thesis using \<open>0 < q\<close> by auto
qed
ultimately show ?thesis by auto
qed
ultimately show ?thesis by auto
qed
ultimately show "x \<in> {(m, n)} \<union> {x \<in> pqs. - \<bar>m\<bar> - 1 \<le> fst x \<and> fst x \<le> \<bar>m\<bar> + 1
\<and> 0 < snd x \<and> snd x < n}"
using \<open>x \<in> pqs\<close> \<open>q>0\<close> unfolding p_def q_def by force
qed
moreover have "finite {x. x \<in>pqs \<and> - \<bar>m\<bar> - 1 \<le>fst x \<and> fst x \<le> \<bar>m\<bar> + 1 \<and> 0<snd x \<and> snd x < n }"
proof -
have "finite ({- \<bar>m\<bar> - 1..\<bar>m\<bar> +1} \<times> {0<..<n})" by blast
moreover have "{x. x \<in>pqs \<and> - \<bar>m\<bar> - 1 \<le>fst x \<and> fst x \<le> \<bar>m\<bar> + 1 \<and> 0<snd x \<and> snd x < n } \<subseteq>
({- \<bar>m\<bar> - 1..\<bar>m\<bar> +1} \<times> {0<..<n})"
by auto
ultimately show ?thesis
apply (elim rev_finite_subset)
by blast
qed
ultimately show ?thesis using finite_subset by auto
qed
ultimately show ?thesis
apply (fold \<xi>_def)
using RothsTheorem[rule_format,of \<xi> "2 + \<delta>",folded pqs_def] \<open>\<delta> >0\<close> by auto
qed
theorem (in RothsTheorem) HanclRucki2:
fixes a b ::"nat\<Rightarrow>int" and \<delta> \<epsilon> ::real
defines "aa\<equiv>(\<lambda>n. real_of_int (a n))" and "bb\<equiv>(\<lambda>n. real_of_int (b n))"
assumes a_pos:"\<forall> k. a k >0" and b_pos:"\<forall> k. b k >0" and "\<delta> >0"
and "\<epsilon> >0"
and limsup_infi:"limsup (\<lambda> k.(aa (k+1)/(\<Prod>i = 0..k. aa i)powr(2+(2/\<epsilon>) + \<delta>))
* (1/(bb (k+1)))) = \<infinity>"
and ratio_large:"\<forall> k. ( k \<ge> t \<longrightarrow> (( aa(k+1)/bb( k+1)) ) powr(1/(1+\<epsilon>))
\<ge> (( aa k/bb k) powr(1/(1+\<epsilon>)))+1)"
shows "\<not> algebraic(suminf (\<lambda> k. bb k /aa k)) "
proof-
have aa_bb_pos[simp]:"aa k>0" "bb k>0" for k
unfolding aa_def bb_def using a_pos b_pos by auto
have summable:"summable (\<lambda> k. bb k / aa k)"
proof -
define c0 where "c0\<equiv>(aa t/bb t) powr(1/(1+\<epsilon>)) - t"
have ab_k:"(aa k / bb k) powr(1/(1+\<epsilon>)) \<ge> k + c0" when "k\<ge>t" for k
using that
proof (induct k)
case 0
then show ?case unfolding c0_def by simp
next
case (Suc k)
have ?case when "\<not> t\<le>k"
proof -
have "t = Suc k" using that Suc.prems by linarith
then show ?thesis unfolding c0_def by auto
qed
moreover have ?case when "t \<le> k"
proof -
have "(aa(k+1)/bb(k+1)) powr(1/(1+\<epsilon>))
\<ge> ( aa k/bb k) powr(1/(1+\<epsilon>))+1"
using ratio_large[rule_format,OF that] by blast
then show ?thesis using Suc(1)[OF that] by simp
qed
ultimately show ?case by auto
qed
have "summable (\<lambda>k. 1 / (k + c0) powr (1+\<epsilon>))"
proof -
have "c0 + t > 0" unfolding c0_def
using aa_bb_pos[of t] by (simp,linarith)
then have "summable (\<lambda>k. 1 / (k + (c0+t)) powr (1+\<epsilon>))"
using summable_hurwitz_zeta_real[of "1+\<epsilon>" "c0+t"]
apply (subst (asm) powr_minus_divide)
using \<open>\<epsilon>>0\<close> by auto
then show ?thesis
apply (rule_tac summable_offset[of _ t])
by (auto simp:algebra_simps)
qed
moreover have "bb k / aa k \<le> 1 / (k + c0) powr (1+\<epsilon>)" when "k\<ge>t" for k
proof -
have "(aa t / bb t) powr (1 / (1 + \<epsilon>)) > 0"
apply simp
by (metis \<open>\<And>k. 0 < aa k\<close> \<open>\<And>k. 0 < bb k\<close> less_numeral_extra(3))
then have "k + c0 >0" unfolding c0_def using that by linarith
then have "aa k / bb k \<ge> (k + c0) powr (1+\<epsilon>)"
using ab_k[OF that]
apply (subst (asm) powr_less_eq_inverse_iff')
using \<open>\<epsilon> >0\<close> by auto
then have "inverse (aa k / bb k) \<le> inverse ((k + c0) powr (1+\<epsilon>))"
apply (elim le_imp_inverse_le)
using \<open>k + c0 >0\<close> by auto
then show ?thesis by (simp add: inverse_eq_divide)
qed
ultimately show ?thesis
apply (elim summable_comparison_test'[where N=t])
using aa_bb_pos by (simp add: less_eq_real_def)
qed
have 7:"\<exists>\<^sub>\<infinity> k. 1 / (M powr (\<epsilon>/(1+\<epsilon>)) * (\<Prod>i = 0..k. aa i)
powr(2+ \<delta> * \<epsilon> / (1+\<epsilon>))) > (bb (k+1) / aa(k+1)) powr (\<epsilon> / (1+\<epsilon>))"
when "M > 0" for M
proof -
define tt where "tt= (\<lambda>i. prod aa {0..i} powr (2 + 2 / \<epsilon> + \<delta>))"
have tt_pos:"tt i > 0" for i
unfolding tt_def
apply(subst powr_gt_zero,induct i)
subgoal by (metis aa_bb_pos(1) order_less_irrefl prod_pos)
subgoal by (metis \<open>\<And>k. 0 < aa k\<close> order_less_irrefl prod_pos)
done
have "\<exists>\<^sub>\<infinity>i. M < (aa (i + 1) / tt i * (1 / bb (i + 1)))"
using limsup_infinity_imp_Inf_many[OF limsup_infi,rule_format,of M]
unfolding tt_def by auto
then have "\<exists>\<^sub>\<infinity>i. 1 / (M * tt i) > (bb (i+1) / aa (i+1))"
apply (elim INFM_mono)
using \<open>M>0\<close> tt_pos by (auto simp:divide_simps algebra_simps)
then have "\<exists>\<^sub>\<infinity>i. (1 / (M * tt i)) powr (\<epsilon>/(1+\<epsilon>))
> (bb (i+1) / aa (i+1)) powr (\<epsilon>/(1+\<epsilon>))"
apply (elim INFM_mono powr_less_mono2[rotated 2])
by (simp_all add: assms(6) pos_add_strict less_eq_real_def)
moreover have "tt i powr (\<epsilon>/(1+\<epsilon>)) = prod aa {0..i} powr (2 + \<delta> * \<epsilon> / (1+\<epsilon>))"
for i
unfolding tt_def
apply (auto simp:powr_powr)
using \<open>\<epsilon>>0\<close> by (simp add:divide_simps,simp add:algebra_simps)
ultimately show ?thesis
apply (elim INFM_mono)
by (smt nonzero_mult_div_cancel_left powr_divide powr_mult powr_one_eq_one
that tt_pos zero_less_divide_iff)
qed
have 8:"\<forall>\<^sub>F k in sequentially. \<forall>s. (( aa(k+s)/bb( k+s))) \<ge>
((( aa k/bb k) powr(1/(1+\<epsilon>))) +s)powr(1+\<epsilon>)"
using eventually_ge_at_top[of t]
proof eventually_elim
case (elim k)
define ff where "ff=(\<lambda>k. (aa k / bb k) powr (1 / (1 + \<epsilon>)))"
have 11:"ff k+s \<le> ff (k+s)" for s
proof (induct s)
case 0
then show ?case unfolding ff_def by auto
next
case (Suc s)
then have "ff k + Suc s \<le> ff (k+Suc s)"
using ratio_large[rule_format,of "k+s"] \<open> t \<le> k\<close> unfolding ff_def by auto
then show ?case by simp
qed
then have "(ff k+s) powr (1+\<epsilon>) \<le> ff (k+s) powr (1+\<epsilon>)" for s
apply (rule powr_mono2[of "1+\<epsilon>",rotated 2])
unfolding ff_def using \<open>\<epsilon>>0\<close> by auto
then show ?case unfolding ff_def using \<open>\<epsilon>>0\<close>
apply (auto simp add:powr_powr)
by (simp add: a_pos aa_def b_pos bb_def le_less)
qed
have 9: "(\<Sum>r. 1/((z+real r)powr(1+\<epsilon>))) \<le> 1/(\<epsilon> *(z-1) powr \<epsilon>)"
"summable (\<lambda>i. 1/((z+ real i)powr(1+\<epsilon>)))"
when "z>1" for z
proof -
define f where "f= (\<lambda>r. 1/((z+ r)powr(1+\<epsilon>)))"
have "((\<lambda>x. f (x - 1)) has_integral ((z-1) powr - \<epsilon>) / \<epsilon>) {0..}"
proof -
have "((\<lambda>x. (z-1 + x) powr (- 1 - \<epsilon>)) has_integral ((z-1) powr - \<epsilon>) / \<epsilon>) {0<..}"
using powr_has_integral_at_top[of 0 "z-1" "- 1 - \<epsilon>",simplified] \<open>z>1\<close> \<open>\<epsilon>>0\<close>
by auto
then have "((\<lambda>x. (z-1 + x) powr (- 1 - \<epsilon>)) has_integral ((z-1) powr - \<epsilon>) / \<epsilon>) {0..}"
apply (subst (asm) has_integral_closure[symmetric])
by (auto simp add: negligible_convex_frontier)
then show ?thesis
apply (rule has_integral_cong[THEN iffD1, rotated 1])
unfolding f_def by (smt powr_minus_divide)
qed
moreover have "\<And>x. 0 \<le> x \<Longrightarrow> 0 \<le> f (x - 1)" unfolding f_def by simp
moreover have "\<And>x y. 0 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> f (y - 1) \<le> f (x - 1)" unfolding f_def
by (smt assms(6) frac_le powr_mono2 powr_nonneg_iff that)
ultimately have "summable (\<lambda>i. f (real i))" "(\<Sum>i. f (real i)) \<le> (z - 1) powr - \<epsilon> / \<epsilon>"
using decreasing_sum_le_integral[of "\<lambda>x. f (x-1)" "((z-1) powr - \<epsilon>) / \<epsilon>",simplified]
by auto
moreover have "(z - 1) powr - \<epsilon> / \<epsilon> = 1/(\<epsilon> *(z-1) powr \<epsilon>)"
by (simp add: powr_minus_divide)
ultimately show "(\<Sum>i. f (real i)) \<le> 1/(\<epsilon> *(z-1) powr \<epsilon>)" by auto
show "summable (\<lambda>i. f (real i))" using \<open>summable (\<lambda>i. f (real i))\<close> .
qed
have u:"(\<lambda>k.( aa k / bb k)) \<longlonglongrightarrow> \<infinity>"
proof -
define ff where "ff\<equiv>(\<lambda>x. ereal (aa x / bb x))"
have "limsup ff = \<infinity>"
proof -
define tt where "tt= (\<lambda>i. prod aa {0..i} powr (2 + 2 / \<epsilon> + \<delta>))"
have "tt i \<ge> 1" for i
unfolding tt_def
apply (rule ge_one_powr_ge_zero)
subgoal
apply (rule linordered_nonzero_semiring_class.prod_ge_1)
by (simp add: a_pos aa_def int_one_le_iff_zero_less)
subgoal by (simp add: \<open>\<epsilon>>0\<close> \<open>\<delta>>0\<close> less_imp_le)
done
then have "limsup (\<lambda>x. (aa (x + 1) / tt x * (1 / bb (x + 1))))
\<le> limsup (\<lambda>x. aa (x + 1) / bb (x + 1))"
apply (intro Limsup_mono eventuallyI)
apply (auto simp add:field_simps order.order_iff_strict)
by (metis aa_bb_pos(1) div_by_1 frac_less2 less_irrefl less_numeral_extra(1)
not_le)
also have "... = limsup (\<lambda>x. aa x / bb x)"
by (subst limsup_shift,simp)
finally have "limsup (\<lambda>x. ereal (aa (x + 1) / tt x * (1 / bb (x + 1))))
\<le> limsup (\<lambda>x. ereal (aa x / bb x))" .
moreover have "limsup (\<lambda>x. ereal (aa (x + 1) / tt x * (1 / bb (x + 1))))
= \<infinity>" using limsup_infi unfolding tt_def by auto
ultimately show ?thesis
unfolding ff_def using ereal_infty_less_eq2(1) by blast
qed
then have "limsup (\<lambda>k. ff (k+t)) = \<infinity>"
by (simp add: limsup_shift_k)
moreover have "incseq (\<lambda>k. ff (k+t))"
proof (rule incseq_SucI)
fix k::nat
define gg where "gg\<equiv>(\<lambda>x. (aa x / bb x))"
have "(gg (k+t)) powr (1 / (1 + \<epsilon>)) + 1
\<le> (gg (Suc (k+t))) powr (1 / (1 + \<epsilon>))"
using ratio_large[rule_format, of "k+t",simplified] unfolding gg_def
by auto
then have "(gg (k+t)) powr (1 / (1 + \<epsilon>))
\<le> (gg (Suc (k+t))) powr (1 / (1 + \<epsilon>))"
by auto
then have "gg (k+t)\<le> gg (Suc (k+t))"
by (smt aa_bb_pos(1) aa_bb_pos(2) assms(6) divide_pos_pos gg_def
powr_less_mono2)
then show "ff (k + t) \<le> ff (Suc k + t)"
unfolding gg_def ff_def by auto
qed
ultimately have "(\<lambda>k. ff (k+t)) \<longlonglongrightarrow> \<infinity>" using incseq_tendsto_limsup
by fastforce
then show ?thesis unfolding ff_def
unfolding tendsto_def
apply (subst eventually_sequentially_seg[symmetric,of _ t])
by simp
qed
define \<xi> where "\<xi> = suminf (\<lambda> k. bb k / aa k)"
have 10:"\<forall>\<^sub>F k in sequentially. \<bar>\<xi> - (\<Sum>k = 0..k. bb k / aa k)\<bar>
< 2 / \<epsilon> * (bb (k+1) / aa (k+1)) powr (\<epsilon> / (1+\<epsilon>))"
using 8[THEN sequentially_offset,of 1] eventually_ge_at_top[of t]
u[unfolded tendsto_PInfty,rule_format,THEN sequentially_offset
,of "(2 powr (1/\<epsilon>) / (2 powr (1/\<epsilon>) - 1)) powr (1+\<epsilon>)" 1]
proof eventually_elim
case (elim k)
define tt where "tt=(aa (k + 1) / bb (k + 1)) powr (1 / (1 + \<epsilon>))"
have "tt>1"
proof -
have "(aa k / bb k) powr (1 / (1 + \<epsilon>)) > 0"
by (metis a_pos aa_def b_pos bb_def divide_eq_0_iff less_irrefl
of_int_eq_0_iff powr_gt_zero)
then show ?thesis using ratio_large[rule_format,OF \<open>k\<ge>t\<close>] unfolding tt_def by argo
qed
have "\<bar>\<xi> - (\<Sum>i = 0..k. bb i / aa i)\<bar> = \<bar>\<Sum>i. bb (i+(k+1)) / aa (i+(k+1))\<bar>"
unfolding \<xi>_def
apply (subst suminf_minus_initial_segment[of _ "k+1",OF summable])
using atLeast0AtMost lessThan_Suc_atMost by auto
also have "... = (\<Sum>i. bb (i+(k+1)) / aa (i+(k+1)))"
proof -
have "(\<Sum>i. bb (i+(k+1)) / aa (i+(k+1))) > 0"
apply (rule suminf_pos)
subgoal using summable[THEN summable_ignore_initial_segment,of "k+1"] .
subgoal by (simp add: a_pos aa_def b_pos bb_def)
done
then show ?thesis by auto
qed
also have "... \<le> (\<Sum>i. 1 / (tt + i) powr (1 + \<epsilon>))"
proof (rule suminf_le)
define ff where "ff=(\<lambda>k n. (aa (k+1) / bb (k+1)) powr (1 / (1 + \<epsilon>)) + real n)"
have "bb (n + (k + 1)) / aa (n + (k + 1)) \<le> 1 / (ff k n) powr (1 + \<epsilon>)" for n
proof -
have "ff k n powr (1 + \<epsilon>) \<le> aa (k + n +1 ) / bb (k + n+1 )"
using elim(1)[rule_format,of n] unfolding ff_def by auto
moreover have "ff k n powr (1 + \<epsilon>) > 0"
unfolding ff_def by (smt elim(2) of_nat_0_le_iff powr_gt_zero ratio_large)
ultimately have "1 / ff k n powr (1 + \<epsilon>) \<ge> bb (k + (n + 1)) / aa (k + (n + 1))"
apply (drule_tac le_imp_inverse_le)
by (auto simp add: inverse_eq_divide)
then show ?thesis by (auto simp:algebra_simps)
qed
then show " \<forall>n. bb (n + (k + 1)) / aa (n + (k + 1)) \<le> 1 / (tt + real n) powr (1 + \<epsilon>)"
unfolding ff_def tt_def by auto
show "summable (\<lambda>i. bb (i + (k + 1)) / aa (i + (k + 1)))"
using summable[THEN summable_ignore_initial_segment,of "k+1"] .
show "summable (\<lambda>x. 1 / (tt + real x) powr (1 + \<epsilon>))"
using 9(2)[OF \<open>tt>1\<close>] .
qed
also have "... \<le> 1/(\<epsilon> *(tt-1) powr \<epsilon>)"
using 9[OF \<open>tt>1\<close>] by simp
also have "... < 2 / (\<epsilon> *tt powr \<epsilon>)"
proof -
have "((2 powr (1/\<epsilon>) / (2 powr (1/\<epsilon>) - 1)) powr (1 + \<epsilon>)) < (aa (k+1) / bb (k+1))"
using elim(3) by auto
then have "2 powr (1/\<epsilon>) / (2 powr (1/\<epsilon>) - 1) < tt"
unfolding tt_def
apply (drule_tac powr_less_mono2[rotated 2,where a="1/ (1 + \<epsilon>)"])
using \<open>\<epsilon>>0\<close> apply (auto simp:powr_powr )
by (subst (asm) powr_one,auto simp add:field_simps)
then have " tt < (tt-1) * (2 powr (1/\<epsilon>))"
using \<open>\<epsilon>>0\<close> by (auto simp:divide_simps algebra_simps)
then have "tt powr \<epsilon> < 2 * (tt - 1) powr \<epsilon>"
apply (drule_tac powr_less_mono2[rotated 2,where a="\<epsilon>"])
using \<open>\<epsilon>>0\<close> \<open>tt>1\<close> by (auto simp:powr_powr powr_mult)
then show ?thesis
using \<open>\<epsilon>>0\<close> \<open>tt>1\<close> by (auto simp:divide_simps)
qed
also have "... = 2 / \<epsilon> * (bb (k + 1) / aa (k + 1)) powr (\<epsilon> / (1 + \<epsilon>))"
unfolding tt_def
using \<open>\<epsilon>>0\<close>
by (auto simp:powr_powr divide_simps algebra_simps powr_divide less_imp_le)
finally show ?case .
qed
define pq where "pq = (\<lambda>k. quotient_of (\<Sum>i=0..k. of_int (b i) / of_int (a i)))"
define p q where "p = fst \<circ> pq" and "q = snd \<circ> pq"
have coprime_pq:"coprime (p k) (q k)"
and q_pos:"q k > 0" and pq_sum:"p k / q k = (\<Sum>i=0..k. b i / a i)" for k
proof -
have eq: "quotient_of (\<Sum>i=0..k. of_int (b i) / of_int (a i)) = (p k, q k)"
by (simp add: p_def q_def pq_def)
from quotient_of_coprime[OF eq] show "coprime (p k) (q k)" .
from quotient_of_denom_pos[OF eq] show "q k > 0" .
have "(\<Sum>i=0..k. b i / a i) = of_rat (\<Sum>i=0..k. of_int (b i) / of_int (a i))"
by (simp add: of_rat_sum of_rat_divide)
also have "(\<Sum>i=0..k. rat_of_int (b i) / rat_of_int (a i)) =
rat_of_int (p k) / rat_of_int (q k)"
using quotient_of_div[OF eq] by simp
finally show "p k / q k = (\<Sum>i=0..k. b i / a i)" by (simp add:of_rat_divide)
qed
have \<xi>_Inf_many:"\<exists>\<^sub>\<infinity> k. \<bar>\<xi> - p k / q k\<bar> < 1 / q k powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))"
proof -
have *:"\<exists>\<^sub>\<infinity>k. (bb (Suc k) / aa (Suc k)) powr (\<epsilon> / (1 + \<epsilon>))
< \<epsilon> / (2 * prod aa {0..k} powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>)))"
using 7[of "(2 / \<epsilon>) powr ((1+\<epsilon>)/ \<epsilon>)"] \<open>\<epsilon>>0\<close>
by (auto simp:powr_powr)
have **:"\<forall>\<^sub>\<infinity>k. \<bar>\<xi> - (\<Sum>k = 0..k. bb k / aa k)\<bar>
< 2 / \<epsilon> * (bb (k + 1) / aa (k + 1)) powr (\<epsilon> / (1 + \<epsilon>))"
using 10[unfolded cofinite_eq_sequentially[symmetric]] .
from INFM_conjI[OF * **] show ?thesis
proof (elim INFM_mono)
fix k assume asm:"(bb (Suc k) / aa (Suc k)) powr (\<epsilon> / (1 + \<epsilon>))
< \<epsilon> / (2 * prod aa {0..k} powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))) \<and>
\<bar>\<xi> - (\<Sum>k = 0..k. bb k / aa k)\<bar>
< 2 / \<epsilon> * (bb (k + 1) / aa (k + 1)) powr (\<epsilon> / (1 + \<epsilon>))"
have "\<bar>\<xi> - real_of_int (p k) / real_of_int (q k)\<bar>
= \<bar>\<xi> - (\<Sum>k = 0..k. bb k / aa k)\<bar>"
using pq_sum unfolding aa_def bb_def by auto
also have "... < (2 / \<epsilon>) * (bb (k+1) / aa (k+1)) powr (\<epsilon> / (1+\<epsilon>))"
using asm by auto
also have "... < (2 / \<epsilon>) * (\<epsilon> / (2 * prod aa {0..k} powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))))"
apply (rule mult_strict_left_mono)
using asm \<open>\<epsilon>>0\<close> by auto
also have "... = 1/ prod aa {0..k} powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))"
using \<open>\<epsilon>>0\<close> by auto
also have "... \<le> 1 / q k powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))"
proof -
have "q k \<le> prod aa {0..k}"
proof (induct k)
case 0
then show ?case unfolding q_def pq_def aa_def
apply (simp add:rat_divide_code of_int_rat quotient_of_Fract)
using aa_bb_pos[of 0,unfolded aa_def bb_def] unfolding Let_def normalize_def
apply auto
by (metis div_by_1 less_imp_le less_trans nonneg1_imp_zdiv_pos_iff
not_less zdiv_mono2)
next
case (Suc k)
define de where "de=snd \<circ> quotient_of"
have "real_of_int (q (Suc k))
= de (\<Sum>i=0..Suc k. of_int (b i) / of_int (a i))"
unfolding q_def pq_def de_def by simp
also have "... = de ((\<Sum>i=0..k. of_int (b i) / of_int (a i))
+ of_int (b (Suc k)) / of_int (a (Suc k)))"
by simp
also have "... \<le> de (\<Sum>i=0..k. of_int (b i) / of_int (a i))
* de (of_int (b (Suc k)) / of_int (a (Suc k)))"
using snd_quotient_plus_leq[folded de_def] by presburger
also have "... = q k * de (of_int (b (Suc k)) / of_int (a (Suc k)))"
unfolding q_def pq_def de_def by auto
also have "... = q k * snd (Rat.normalize (b (Suc k), a (Suc k)))"
by (simp add:rat_divide_code of_int_rat quotient_of_Fract de_def)
also have "... \<le> q k * aa (Suc k)"
using aa_bb_pos[of "Suc k"] q_pos[of "k"]
unfolding normalize_def aa_def bb_def Let_def
apply auto
by (metis div_by_1 int_one_le_iff_zero_less less_trans
nonneg1_imp_zdiv_pos_iff not_less zdiv_mono2 zero_less_one)
also have "... \<le> prod aa {0..k} * aa (Suc k)"
using Suc aa_bb_pos[of "Suc k"] by auto
also have "... = prod aa {0..Suc k}"
by (simp add: prod.atLeast0_atMost_Suc)
finally show ?case .
qed
then show ?thesis
apply (rule_tac divide_left_mono)
apply (rule powr_mono2)
using \<open>\<delta>>0\<close> \<open>\<epsilon>>0\<close> q_pos[of k]
apply (auto simp:powr_mult[symmetric])
by (metis aa_bb_pos(1) less_irrefl)
qed
finally show "\<bar>\<xi> - p k / q k\<bar> < 1 / q k powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))" .
qed
qed
define pqs where "pqs={(p, q). q>0 \<and> coprime p q \<and> \<bar>\<xi> - real_of_int p / real_of_int q\<bar>
< 1 / q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))}"
have \<xi>_infinite:"infinite pqs"
proof -
define A where "A={k. \<bar>\<xi> - (p k) / (q k)\<bar> < 1 / (q k) powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))}"
note \<xi>_Inf_many
then have "infinite A"
unfolding Inf_many_def A_def by auto
moreover have "inj_on (\<lambda>k. (p k, q k)) A"
proof -
define g where "g=(\<lambda>i. rat_of_int (b i) / rat_of_int (a i))"
define f where "f=(\<lambda>k. \<Sum>i = 0..k. g i)"
have g_pos:"g i>0" for i
unfolding g_def by (simp add: a_pos b_pos)
have "strict_mono f" unfolding strict_mono_def f_def
proof safe
fix x y::nat assume "x < y"
then have "sum g {0..y} - sum g {0..x} = sum g {x<..y}"
apply (subst Groups_Big.sum_diff[symmetric])
by (auto intro:arg_cong2[where f=sum])
also have "... > 0"
apply (rule ordered_comm_monoid_add_class.sum_pos)
using \<open>x<y\<close> g_pos by auto
finally have "sum g {0..y} - sum g {0..x} >0" .
then show "sum g {0..x} < sum g {0..y}" by auto
qed
then have "inj f" using strict_mono_imp_inj_on by auto
then have "inj (quotient_of o f)" by (simp add: inj_compose quotient_of_inj)
then have "inj (\<lambda>k. (p k, q k))"
unfolding f_def p_def q_def pq_def comp_def
apply (fold g_def)
by auto
then show ?thesis by (auto elim:subset_inj_on)
qed
moreover have "(\<lambda>k. (p k, q k)) ` A \<subseteq> pqs"
unfolding A_def pqs_def using coprime_pq q_pos by auto
ultimately show ?thesis
apply (elim infinite_inj_imageE)
by auto
qed
moreover have "finite pqs" if "\<xi> \<in> \<rat>"
proof -
obtain m n where \<xi>_mn:"\<xi> = (of_int m / of_int n)" and "coprime m n" "n>0"
proof -
obtain m n where mn:"\<bar>\<xi>\<bar> = (of_nat m / of_nat n)" "coprime m n" "n\<noteq>0"
using Rats_abs_nat_div_natE[OF \<open>\<xi> \<in> \<rat>\<close> Rats_abs_nat_div_natE]
by metis
define m' and n'::int
where "m'=(if \<xi> > 0 then nat m else -nat m)" and "n'=nat n"
then have "\<xi> = (of_int m' / of_int n')" "coprime m' n'" "n'>0"
using mn by auto
then show ?thesis using that by auto
qed
have "pqs \<subseteq> {(m,n)} \<union> {x. x \<in>pqs \<and> - \<bar>m\<bar> - 1 \<le>fst x \<and> fst x \<le> \<bar>m\<bar> + 1 \<and> 0<snd x \<and> snd x < n }"
proof (rule subsetI)
fix x assume "x \<in> pqs"
define p q where "p=fst x" and "q=snd x"
have "q>0" "coprime p q" and pq_less:"\<bar>\<xi> - p / q\<bar>
< 1 / q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))"
using \<open>x\<in>pqs\<close> unfolding p_def q_def pqs_def by auto
have q_lt_n:"q<n" when "m\<noteq>p \<or> n\<noteq>q"
proof -
have "m * q \<noteq> n * p" using that \<open>coprime m n\<close> \<open>coprime p q\<close> \<open>q>0\<close> \<open>n>0\<close>
by (metis eq_rat(1) fst_conv int_one_le_iff_zero_less mult.commute normalize_stable
not_one_le_zero quotient_of_Fract snd_conv)
then have "1/(n*q) \<le> \<bar>m/n - p/q\<bar>"
using \<open>q>0\<close> \<open>n>0\<close>
apply (auto simp:field_simps)
by (metis add_diff_cancel_left' diff_diff_eq2 diff_zero less_irrefl not_le of_int_diff
of_int_lessD of_int_mult)
also have "... < 1 / q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))"
using pq_less unfolding \<xi>_mn by auto
also have "... \<le> 1 / q ^2"
proof -
have "real_of_int (q\<^sup>2) = q powr 2"
apply (subst powr_numeral)
unfolding power2_eq_square using \<open>q>0\<close> by auto
also have "... \<le> q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))"
apply (rule powr_mono)
using \<open>q>0\<close> \<open>\<delta>>0\<close> \<open>\<epsilon>>0\<close> by auto
finally have "real_of_int (q\<^sup>2)
\<le> real_of_int q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))" .
moreover have "real_of_int q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>)) > 0" using \<open>0 < q\<close> by auto
ultimately show ?thesis by (auto simp:field_simps)
qed
finally have " 1 / (n * q) < 1 / q\<^sup>2" .
then show ?thesis using \<open>q>0\<close> \<open>n>0\<close>
unfolding power2_eq_square by (auto simp:field_simps)
qed
moreover have "- \<bar>m\<bar> - 1 \<le> p \<and> p \<le> \<bar>m\<bar> + 1" when "m\<noteq>p \<or> n\<noteq>q"
proof -
define qn where "qn=q/n"
have "0<qn" "qn<1" unfolding qn_def using q_lt_n[OF \<open>m\<noteq>p \<or> n\<noteq>q\<close>] \<open>q>0\<close> by auto
have "\<bar>m/n - p / q\<bar> < 1 / q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))"
using pq_less unfolding \<xi>_mn by simp
then have "\<bar>p / q - m/n\<bar> < 1 / q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))" by simp
then have " m/n- 1 / q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))
< p/q \<and> p/q < m/n + 1 / q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))"
unfolding abs_diff_less_iff by auto
then have "qn*m- q / q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>)) < p
\<and> p < qn*m + q / q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))"
unfolding qn_def using \<open>q>0\<close> by (auto simp:field_simps)
moreover have "- \<bar>m\<bar> - 1 \<le> qn*m- q / q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))"
proof -
have "- \<bar>m\<bar> \<le> qn*m" using \<open>0<qn\<close> \<open>qn<1\<close>
apply (cases "m\<ge>0")
subgoal
apply simp
by (meson less_eq_real_def mult_nonneg_nonneg neg_le_0_iff_le of_int_0_le_iff
order_trans)
subgoal by simp
done
moreover have "- 1 \<le> - q / q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))"
proof -
have "q = q powr 1" using \<open>0 < q\<close> by auto
also have "... \<le>q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))"
apply (rule powr_mono)
using \<open>q>0\<close> \<open>\<delta>>0\<close> \<open>\<epsilon>>0\<close> by auto
finally have "q \<le> q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))" .
then show ?thesis using \<open>0 < q\<close> by auto
qed
ultimately show ?thesis by auto
qed
moreover have "qn*m + q / q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>)) \<le> \<bar>m\<bar> + 1"
proof -
have "qn*m \<le> \<bar>m\<bar>" using \<open>0<qn\<close> \<open>qn<1\<close>
apply (cases "m\<ge>0")
subgoal by (simp add: mult_left_le_one_le)
subgoal by (smt of_int_0_le_iff zero_le_mult_iff)
done
moreover have "q / q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>)) \<le> 1"
proof -
have "q = q powr 1" using \<open>0 < q\<close> by auto
also have "... \<le>q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))"
apply (rule powr_mono)
using \<open>q>0\<close> \<open>\<delta>>0\<close> \<open>\<epsilon>>0\<close> by auto
finally have "q \<le> q powr (2 + \<delta> * \<epsilon> / (1 + \<epsilon>))" .
then show ?thesis using \<open>0 < q\<close> by auto
qed
ultimately show ?thesis by auto
qed
ultimately show ?thesis by auto
qed
ultimately show "x \<in> {(m, n)} \<union> {x \<in> pqs. - \<bar>m\<bar> - 1 \<le> fst x \<and> fst x \<le> \<bar>m\<bar> + 1
\<and> 0 < snd x \<and> snd x < n}"
using \<open>x \<in> pqs\<close> \<open>q>0\<close> unfolding p_def q_def by force
qed
moreover have "finite {x. x \<in>pqs \<and> - \<bar>m\<bar> - 1 \<le>fst x \<and> fst x \<le> \<bar>m\<bar> + 1 \<and> 0<snd x \<and> snd x < n }"
proof -
have "finite ({- \<bar>m\<bar> - 1..\<bar>m\<bar> +1} \<times> {0<..<n})" by blast
moreover have "{x. x \<in>pqs \<and> - \<bar>m\<bar> - 1 \<le>fst x \<and> fst x \<le> \<bar>m\<bar> + 1 \<and> 0<snd x \<and> snd x < n } \<subseteq>
({- \<bar>m\<bar> - 1..\<bar>m\<bar> +1} \<times> {0<..<n})"
by auto
ultimately show ?thesis
apply (elim rev_finite_subset)
by blast
qed
ultimately show ?thesis using finite_subset by auto
qed
ultimately show ?thesis
apply (fold \<xi>_def)
using RothsTheorem[rule_format,of \<xi> "2 + \<delta> * \<epsilon> / (1 + \<epsilon>)",folded pqs_def]
\<open>\<delta> >0\<close> \<open>\<epsilon>>0\<close>
apply (auto simp:divide_simps )
by (meson mult_le_0_iff not_less)
qed
subsection\<open> Acknowledgements\<close>
text\<open>A.K.-A. and W.L. were supported by the ERC Advanced Grant ALEXANDRIA (Project 742178)
funded by the European Research Council and led by Professor Lawrence Paulson
at the University of Cambridge, UK. Thanks to Iosif Pinelis for his clarification on
MathOverflow regarding the summmability of the series in @{thm [source] RothsTheorem.HanclRucki2}
@{url "https://mathoverflow.net/questions/323069/why-is-this-series-summable"}
and to Manuel Eberl for his helpful comments.\<close>
end |
implicit none
include "read_ppm.h"
integer i, iv,im,ir
real flds, moms
allocatable flds(:,:,:,:)
allocatable moms(:,:,:,:)
call get_inputs()
call gen_geometry()
allocate(flds(nxfb,nyfb,nzfb,nReadVars))
call fill_fields(ix0f,iy0f,iz0f,nxf,nyf,nzf,flds)
if(cOutFile(1:5) .eq. "bofs:") then
call dump_bofs(flds)
else
call dump_fields(flds)
endif
stop
end
C=====================================================================72
subroutine dump_bofs(flds)
implicit none
include "read_ppm.h"
real flds(nxfb,nyfb,nzfb,nReadVars)
character*256 cfile
integer n, i, iv, m
c real xyzranges(6)
write (6,*) " "
write (6,901)
901 format(/, "Writing fields in real*4 Brick-Of-Float format.")
write (6,*) " Min Max Mesh"
c call get_xyzranges(xyzranges)
write (6,902) "X: ", xyzranges(1), xyzranges(4), nxfb
write (6,902) "Y: ", xyzranges(2), xyzranges(5), nxfb
write (6,902) "Z: ", xyzranges(3), xyzranges(6), nxfb
902 format(a3,2f10.5,i7)
write (6,*) " "
n = len(trim(cOutFile))
do i = 1,nReadVars
iv = iReadVars(i)
m = len(trim(cppmvars(iv)))
call set_str_blank(cfile)
cfile(1:n-5) = cOutFile(6:n)
cfile(n-4:n+m+1) = "-" // trim(cppmvars(iv)) // ".bof"
write (6,*) "Writing BOF file: ", trim(cfile)
call write_real_array(nxfb*nyfb*nzfb, flds(1,1,1,i), cfile)
enddo
return
end
C=====================================================================72
subroutine write_real_array(n, a, cfile)
implicit none
integer n
real a(n)
character*(*) cfile
#ifndef ISGFORTRAN
open(unit=12,file=cfile,form="binary")
#else
open(unit=12,file=cfile,form="unformatted",access="stream")
#endif
write (12) a
close(12)
return
end
C=====================================================================72
c subroutine get_xyzranges(xyzranges)
c implicit none
c include "read_ppm.h"
c real xyzranges(6)
c real xsize,ysize,zsize, dx, dy, dz, x0f,y0f,z0f
c
c dx = bsizex / float(ncpbx)
c dy = bsizey / float(ncpby)
c dz = bsizez / float(ncpbz)
c xsize = bsizex * nfilex * nbrkx
c ysize = bsizey * nfiley * nbrky
c zsize = bsizez * nfilez * nbrkz
c x0f = -0.5 * xsize
c y0f = -0.5 * ysize
c z0f = -0.5 * zsize
c xyzranges(1) = x0f + dx * float(ix0f-1)
c xyzranges(2) = y0f + dy * float(iy0f-1)
c xyzranges(3) = z0f + dz * float(iz0f-1)
c xyzranges(4) = xyzranges(1) + dx * float(nxf)
c xyzranges(5) = xyzranges(2) + dy * float(nyf)
c xyzranges(6) = xyzranges(3) + dz * float(nzf)
c
c return
c end
c
C=====================================================================72
subroutine gen_geometry()
implicit none
include "read_ppm.h"
dx = bsizex / float(ncpbx)
dy = bsizey / float(ncpby)
dz = bsizez / float(ncpbz)
xsize = bsizex * nfilex * nbrkx
ysize = bsizey * nfiley * nbrky
zsize = bsizez * nfilez * nbrkz
x0f = dx * float(ix0f-1) - 0.5 * xsize
y0f = dy * float(iy0f-1) - 0.5 * ysize
z0f = dz * float(iz0f-1) - 0.5 * zsize
xyzranges(1) = x0f
xyzranges(2) = y0f
xyzranges(3) = z0f
xyzranges(4) = xyzranges(1) + dx * float(nxf)
xyzranges(5) = xyzranges(2) + dy * float(nyf)
xyzranges(6) = xyzranges(3) + dz * float(nzf)
return
end
C=====================================================================72
subroutine dump_fields(flds)
implicit none
include "read_ppm.h"
real flds(nxfb,nyfb,nzfb,nReadVars)
integer NHEAD
parameter (NHEAD = 16*1024)
integer*2 abuf(NHEAD)
integer ndump, istep, itx,ity,itz, ntx,nty,ntz, i, iv, nbytes
real dtime
call remove_nan(99.0, nxfb,nyfb,nzfb,nReadVars, flds)
ndump = 0
dtime = time / float(ncycle)
istep = ncycle
itx = 1
ity = 1
itz = 1
ntx = 1
nty = 1
ntz = 1
! Set dump parameters, including a default list variable to dump & what they are called
call set_dump_parameters(ntx,nty,ntz)
do i=1,nReadVars
iv = iReadVars(i)
call set_dump_var(i,cppmvars(iv),cppmvars(iv),"real4",0.0,0.0)
enddo
! Format meta-data (header info) into a buffer (abuf).
! to customize for your 3D data array format.
nbytes = 2*NHEAD
call format_adump_header(abuf,ndump,time,dtime,istep,xyzranges,
1 nbytes,nReadVars,nxfb,nyfb,nzfb,
1 itx,ity,itz,ntx,nty,ntz)
! Write header buffer to a file
#ifndef ISGFORTRAN
open(unit=12,file=cOutFile,form="binary")
#else
open(unit=12,file=cOutFile,form="unformatted",access="stream")
#endif
write (12) abuf
write (12) flds
close(12)
return
end
C=====================================================================72
real function var_face(n1,n2,face)
integer n1, n2, i,j
real face(100,100), sum
sum = 0.0
do j = 1,n2-1
do i = 1,n1-1
sum = sum + (face(i+1,j)-face(i,j))**2
sum = sum + (face(i,j+1)-face(i,j))**2
enddo
enddo
var_face = sqrt(sum / float(2*(n1-1)*(n2-1)))
return
end
C=====================================================================72
real function diff_face(n1,n2,face1,face2)
integer n1, n2, i,j
real face1(100,100)
real face2(100,100), sum
sum = 0.0
do j = 1,n2
do i = 1,n1
sum = sum + (face1(i,j)-face2(i,j))**2
enddo
enddo
diff_face = sqrt(sum / float(n1*n2))
return
end
C=====================================================================72
subroutine fill_fields(ix0,iy0,iz0,nx,ny,nz,flds)
implicit none
include "read_ppm.h"
! Arguments
integer ix0,iy0,iz0,nx,ny,nz,ioff(3)
real flds(nxfb,nyfb,nzfb,nReadVars)
! scratch
integer i, iv, ifi, ifi_last, ib, ib1, limits(6), iloc, idel
character*256 cfile
real fld, samp(100)
character*1 cflds
allocatable cflds(:,:,:,:,:)
allocatable fld(:,:,:)
allocate (cflds(ncpbx,ncpby,ncpbz,nbpb,nvpc))
allocate (fld(ncpbx,ncpby,ncpbz))
ifi_last = -1
do ifi = 1, nfilex * nfiley * nfilez
do ib = 1, nbrkx * nbrky * nbrkz
call map_brick(ib, ib1)
call overlap(ifi,ib1,ix0,iy0,iz0,nx,ny,nz,cfile,limits,ioff)
if(cFile(1:4) .ne. "none") then
if(ifi .ne. ifi_last) then
write (6,*) trim(cFile)
ifi_last = ifi
endif
call read_a_brick(ifi, cfile, ib, cflds)
do iv=1,nReadVars
c >>>
i = iReadVars(iv)
iloc = ilocppmvars(i)
idel = idelppmvars(i)
if(nresppmvars(iloc) .eq. 1) then
call ppm_var_map(iloc,cflds, fld)
else
call ppm_var_map8(iloc,cflds(1,1,1,1,iloc), fld)
endif
c write (6,*) 'iv,fld(1,1,1) = ', iv,fld(1,1,1)
call copy_fld_subreg(ioff,limits,idel,fld,nx,ny,nz,iv,flds)
enddo
endif
enddo
enddo
call read_a_brick(-1, cfile, ib, cflds) ! close the last file
deallocate(cflds)
deallocate(fld)
return
end
C=====================================================================72
subroutine map_brick(ib, ib1)
implicit none
include "read_ppm.h"
integer ib, ib1, nnbx,nnby,nnbz,nnb, in0, ini
integer nndbx,nndby,nndbz, inx, iny, inz, ib0
integer inix, iniy, iniz, ibx, iby, ibz
nnbx = nbrkx / nodsx
nnby = nbrky / nodsy
nnbz = nbrkz / nodsz
nnb = nnbx * nnby * nnbz ! number of bricks in a node
ib1 = ib
if(nnb .eq. 1) return
! count from 0
ib0 = ib - 1
in0 = ib0 / nnb
! XYZ of the node
inx = mod(in0, nodsx)
iny = mod(in0/nodsx, nodsy )
inz = in0/(nodsx*nodsy)
! XYZ inside the node
ini = ib0 - in0 * nnb
inix = mod(ini , nnbx)
iniy = mod(ini/ nnbx , nnby)
iniz = ini/(nnbx*nnby)
! XYZ of brick
ibx = inix + inx*nnbx
iby = iniy + iny*nnby
ibz = iniz + inz*nnbz
ib1 = 1 + ibx + nbrkx*(iby + nbrky*ibz)
return
end
C=====================================================================72
subroutine copy_fld_subreg(ioff,limits,idel,fld,nx,ny,nz,iv,flds)
implicit none
include "read_ppm.h"
integer ioff(3), limits(6), idel, nx,ny,nz,iv
real fld(ncpbx,ncpby,ncpbz)
real flds(nxfb,nyfb,nzfb,nReadVars)
integer ix,iy,iz, ix1,iy1,iz1, ixd,iyd,izd
real factor, sum, delta, radav
factor = 1.0 / float(nblend**3)
do iz=limits(5),limits(6), nblend
do iy=limits(3),limits(4), nblend
do ix=limits(1),limits(2), nblend
sum = 0.0
do iz1 = iz, iz+nblend-1
do iy1 = iy, iy+nblend-1
do ix1 = ix, ix+nblend-1
sum = sum + fld(ix,iy,iz)
enddo
enddo
enddo
ixd = 1 + (ix+ioff(1)-1)/nblend
iyd = 1 + (iy+ioff(2)-1)/nblend
izd = 1 + (iz+ioff(3)-1)/nblend
c >>> if use radial profile (rrho or rprs) goes here
if(idel .le. 0) then
flds(ixd,iyd,izd,iv) = factor * sum
else
delta = factor * sum
if(idel .eq. 1) call gen_radav(ixd,iyd,izd,nrrho,rrho,radav)
if(idel .eq. 2) call gen_radav(ixd,iyd,izd,nrprs,rprs,radav)
flds(ixd,iyd,izd,iv) = radav * (1.0 + delta)
endif
enddo
enddo
enddo
return
end
C=====================================================================72
subroutine gen_radav(ixd,iyd,izd,n,rval,radav)
implicit none
include "read_ppm.h"
integer ixd,iyd,izd,n, ir0,ir1,ir2, nmomav, ix,iy,iz
real rval(maxrad,2), radav, dr,drinv,fnmax,x,y,z,ri,f1,f2
real fac, dx1,dy1,dz1,off, x0,y0,z0, asum
dr = (rval(n,1) - rval(1,1)) / float(n-1)
drinv = 1.0 / dr
fnmax = float(n-2)
nmomav = 4
fac = 1.0 / float(nmomav)
dx1 = dx * fac
dy1 = dy * fac
dz1 = dz * fac
off = 0.5 * float(nmomav+1)
x0 = x0f + dx * (float(ixd) - 0.5)
y0 = y0f + dy * (float(iyd) - 0.5)
z0 = z0f + dz * (float(izd) - 0.5)
asum = 0.0
do iz = 1, nmomav
z = z0 + dz1 * (float(iz) - off)
do iy = 1, nmomav
y = y0 + dy1 * (float(iy) - off)
do ix = 1, nmomav
x = x0 + dx1 * (float(ix) - off)
ri = min(fnmax, drinv*sqrt(x**2 + y**2 + z**2))
ir0 = int(ri)
ir1 = ir0 + 1
ir2 = ir0 + 2
f2 = ri - float(ir0)
f1 = 1.0 - f2
asum = asum + f1*rval(ir1,2) + f2*rval(ir2,2)
enddo
enddo
enddo
radav = asum *fac*fac*fac
return
end
C=====================================================================72
subroutine overlap(ifile,ib,ix0,iy0,iz0,nx,ny,nz,cfile,
1 limits,ioff)
implicit none
include "read_ppm.h"
integer ifile,ib,ix0,iy0,iz0,nx,ny,nz,limits(6)
character*256 cfile
integer ifx,ify,ifz, ibx,iby,ibz
integer mefirst, i, ilen, ioff(3), idebug
common /dgbover/ mefirst
data mefirst/1/
idebug = 0
! ib = 1 + (ibx-1)*ndbx + (iby-1)*ndby + (ibz-1)*ndbz
ifx = 1 + mod(ifile-1,nfilex)
ibx = 1 + mod(ib -1, nbrkx)
cccc ibx = 1 + mod((ib-1)/ndbx, nbrkx)
call overlap1d(ifx,ibx, nbrkx,ncpbx, ix0,nx, limits(1),ioff(1))
ify = 1 + mod((ifile-1)/nfilex, nfiley)
iby = 1 + mod((ib -1)/ nbrkx, nbrky)
cccc iby = 1 + mod(ib-1, nbrky)
call overlap1d(ify,iby, nbrky,ncpby, iy0,ny, limits(3),ioff(2))
ifz = 1 + (ifile-1) / (nfilex*nfiley)
ibz = 1 + (ib-1) / ndbz
call overlap1d(ifz,ibz, nbrkz,ncpbz, iz0,nz, limits(5),ioff(3))
if(limits(1).le.limits(2) .and. limits(3).le.limits(4) .and.
1 limits(5).le.limits(6)) then
! there is an overlap
cfile = cRootFile
ilen = len(trim(cRootFile))
cfile(ilen-2:ilen-2) = char(ichar('a')+ifx-1)
cfile(ilen-1:ilen-1) = char(ichar('a')+ify-1)
cfile(ilen :ilen ) = char(ichar('a')+ifz-1)
if(idebug .gt. 999) then
if(mefirst .eq. 1) then
mefirst = 0
write (6,*)
1 "File ibx iby ibz XYZ limits OFFSET"
endif
write (6,999) cfile(ilen-11:ilen),
1 ibx,iby,ibz,(limits(i),i=1,6), (ioff(i),i=1,3)
999 format(a12, " "3i4, 3(" ", 2i3), " ", 3i5)
endif
else
! there is no overlap
cFile(1:4) = "none"
endif
return
end
C=====================================================================72
subroutine overlap1d(ifd,ibd, nbrk,ncpb, irange0,nrange, lim,ioff)
implicit none
integer ifd,ibd, nfiled,ncpbd, id0,nd, lim(2)
integer nbrk,ncpb, nrange, irange0, irange1, ibrick0, ibrick1
integer ibrk, ioff
integer ioverlap0, ioverlap1
c integer mefirst
c common /dgbover/ mefirst
c data mefirst/1/
irange1 = irange0 + nrange-1
ibrk = ibd + nbrk*(ifd-1)
ibrick0 = 1 + ncpb * (ibrk - 1)
ibrick1 = ncpb * ibrk
ioverlap0 = max(irange0, ibrick0)
ioverlap1 = min(irange1, ibrick1)
lim(1) = 1 + ioverlap0 - ibrick0
lim(2) = 1 + ioverlap1 - ibrick0
ioff = ibrick0 - irange0
c if(mefirst .eq. 1) then
c write (6,*) "ibrk brick range ",
c 1 " overlap limits"
c mefirst = 0
c endif
c write (6,888) ibrk, ibrick0,ibrick1, irange0,irange1,
c 1 ioverlap0,ioverlap1, lim(1),lim(2)
c888 format(i5, 2i7," ",2i7," ",2i7, " ", 2i7)
return
end
C=====================================================================72
subroutine read_a_brick(ifi, cfile, ib, cflds)
implicit none
include "read_ppm.h"
! Arguments
character*256 cFile
integer ifi, ib
character*1 cflds(ncpbx,ncpby,ncpbz,nbpb,nvpc)
c real fld(ncpbx,ncpby,ncpbz)
! scratch
INTEGER SEEK_SET, SEEK_CUR, SEEK_END, ierr
integer ibrick, nb_brick
integer(8) i8a, i8b, nb_offset, ifi_last
common /rabdat/ ifi_last
data ifi_last/-1/
if(ifi .lt. 0) then
close(11)
ifi_last = -1
return
endif
SEEK_SET = 0 ! Other options: SEEK_CUR = 1 SEEK_END = 2
nb_brick = ncpbx * ncpby * ncpbz * nbpb * nvpc ! bytes per brick
i8a = ib - 1
i8b = nb_brick
nb_offset = i8a * i8b ! Offset into file to read the reques ted brick
if(ifi .ne .ifi_last) then
if(ifi_last .gt. 0) close(11)
#ifndef ISGFORTRAN
open(11,file=cfile,form='binary',status='old', err=200,
1 access="sequential", position='rewind')
#else
open(11,file=cfile,form='unformatted',status='old', err=200,
1 access="stream", position='rewind')
#endif
ifi_last = ifi
endif
CALL FSEEK(11, nb_offset, SEEK_SET, ierr)
read (11,err=111) cflds
return
111 write (6,*) 'hit end of cfile'
close(11)
stop
200 write (6,*) 'open failed'
stop
end
c call myopen(cfile)
c call myread(nb_offset, cflds, nb_brick)
c call myclose()
c write (6,*) "read: ", trim(cfile)
C=====================================================================72
c real axy(100,100)
c character*256 cVNMfile
c integer i,iv, ix, iy, iz, ib, ibrick,ival,ic,nny
c integer axy(100,100)
c real s1, s2, s10
c integer is1, is2
c write (6,*) "br,ix,iy,iz,ib,iv,cflds"
c do iv = 1,24
c do ib = 1,2
c
c ic = 0
c do iz = 1,ncpbz,ncpbz/4
c do iy = 1,ncpby,ncpby/4
c do ix = 1,ncpbx,ncpbx/4
c ival = iachar(cflds(ix,iy,iz,ib,iv))
c if(ival .ne. 222 .and. ic .lt. 100) then
c ic = ic + 1
c write (6,999) ibrick,ix,iy,iz,ib,iv,ival
c endif
c999 format(6i3, i5)
c enddo
c enddo
c enddo
c if(ic .gt. 0) write (6,*) '---------'
c
c enddo
c enddo
C=====================================================================72
subroutine ppm_var_map(iv,cflds,fld)
include "read_ppm.h"
integer iv
character*1 cflds(ncpbx*ncpby*ncpbz,nbpb,nvpc)
real fld(ncpbx*ncpby*ncpbz)
real offset, scale, s1, s2, y, p0, p1inv
integer ididmap, i1, i2, ixyz, ncxyz
real y1,y2,y3,y4
real*8 pp0, pp1inv, yy, yy1, yy2, e, c, t, a, d, g, xx
real fvmin, fvmax, ffvimg
real faclog10, fvscale, fvlgfc
c write (6,*) "Field: ", trim(cppmvars(iv))
ncxyz = ncpbx*ncpby*ncpbz
ididmap = 0
if(cppmmap(iv)(1:12) .eq. "ppm-posdef ") then
! map for positive deffinite fields
offset = pvar000(iv)
scale = 1.0 / pvar001inv(iv)
do ixyz = 1, ncxyz
s1 = float(iachar(cflds(ixyz,1,iv)))
s2 = 0.5 + float(iachar(cflds(ixyz,2,iv)))
y = (s1 + s2/250.499)/250.499
y1 = y
if(offset .gt. 0) y = 2.0*y - 1.0
y2 = y
y = sqrt((y+1.0)/(1.0-y))
y3 = y
y = (y*y - 1.0)/(2.0*y)
y4 = y
fld(ixyz) = offset + scale*y
enddo
ididmap = 1
endif
if(cppmmap(iv)(1:12) .eq. "ppm-signed ") then
! map for singed fields
scale = 1.0 / pvar001inv(iv)
do ixyz = 1, ncxyz
s1 = float(iachar(cflds(ixyz,1,iv)))
s2 = 0.5 + float(iachar(cflds(ixyz,2,iv)))
y = (s1 + s2/250.499)/250.499
y = sqrt(y/(1-y))
y = (y*y - 1.0)/(2.0*y) ! check
fld(ixyz) = scale*y
enddo
ididmap = 1
endif
if(cppmmap(iv)(1:12) .eq. "sak-posdef ") then
! map for positive deffinite fields for Sakurai's star model (4908)
pp0 = pvar000(iv)
pp1inv = pvar001inv(iv)
if (pp0 .le. 0.d0) then
do ixyz = 1, ncxyz
i1 = iachar(cflds(ixyz,1,iv))
i2 = iachar(cflds(ixyz,2,iv))
c call invposmapstar(p0, p1inv, i1,i2, fld(ixyz))
yy1 = dble(i1 - 2)
yy2 = 0.5d0 + dble(i2 - 2)
yy = yy1 + yy2 / 250.499d0
e = yy / 250.499d0
c = (1.0d0 + e) / (1.0d0 - e)
t = sqrt(c)
a = 0.5d0 * (t*t - 1.0d0) / t
fld(ixyz) = (pp0 + a / pp1inv)
enddo
else
do ixyz = 1, ncxyz
i1 = iachar(cflds(ixyz,1,iv))
i2 = iachar(cflds(ixyz,2,iv))
c call invposmapstar(p0, p1inv, i1,i2, fld(ixyz))
yy1 = dble(i1 - 2)
yy2 = 0.5d0 + dble(i2 - 2)
yy = yy1 + yy2 / 250.499d0
e = (2.0d0/250.499d0) * yy - 1.0d0
c = (1.0d0 + e) / (1.0d0 - e)
t = sqrt(c)
a = 0.5d0 * (t*t - 1.0d0) / t
fld(ixyz) = (pp0 + a / pp1inv)
enddo
endif
ididmap = 1
endif
if(cppmmap(iv)(1:12) .eq. "sak-signed ") then
! map for positive deffinite fields for Sakurai's star model (4908)
pp1inv = pvar001inv(iv)
do ixyz = 1, ncxyz
i1 = iachar(cflds(ixyz,1,iv))
i2 = iachar(cflds(ixyz,2,iv))
c call invsgnmapbb(p0, p1inv, i1,i2, fld(ixyz))
yy1 = dble(i1 - 2)
yy2 = 0.5d0 + dble(i2 - 2)
yy = yy1 + yy2 / 250.499d0
a = yy / 250.499d0
c = a / (1.0d0 - a)
d = sqrt(c)
g = 0.5d0*(d*d - 1)/d
fld(ixyz) = g / pp1inv
enddo
ididmap = 1
endif
if(cppmmap(iv)(1:12) .eq. "sak-logmap ") then
! map for positive deffinite fields for Sakurai's star model (4908)
fvmin = pvar000(iv)
fvmax = pvar001inv(iv)
faclog10 = 1. / log(10.)
fvscale = faclog10 * log(fvmax/fvmin)
fvlgfc = 250.499 / fvscale
do ixyz = 1, ncxyz
i1 = iachar(cflds(ixyz,1,iv))
i2 = iachar(cflds(ixyz,2,iv))
y1 = float(i1 - 2)
y2 = 0.5 + float(i2 - 2)
ffvimg = y1 + y2 / 250.499
fld(ixyz) = exp((ffvimg/fvlgfc - fvscale) / faclog10)
enddo
ididmap = 1
endif
if(ididmap .ne. 1) then
write (6,*) "This map is not supported:"
write (6,*) "-->", cppmmap(iv)(1:12), "<--- iv=",iv
stop
endif
return
end
C=====================================================================72
subroutine ppm_var_map8(iv,cflds,fld)
include "read_ppm.h"
integer iv
character*1 cflds(8*ncpbx*ncpby*ncpbz,nbpb)
real fld( ncpbx*ncpby*ncpbz)
real offset, scale, s1, s2, y, p0, p1inv
integer ididmap, i1, i2, ixyz, ncxyz
real y1,y2,y3,y4
real*8 pp0, pp1inv, yy, yy1, yy2, e, c, t, a, d, g, xx
real fvmin, fvmax, ffvimg
real faclog10, fvscale, fvlgfc
real fld8
allocatable fld8(:)
allocate(fld8(8*ncpbx*ncpby*ncpbz))
c write (6,*) "Field: ", trim(cppmvars(iv))
ncxyz = ncpbx*ncpby*ncpbz
ididmap = 0
if(cppmmap(iv)(1:12) .eq. "sak-logmap ") then
! map for positive deffinite fields for Sakurai's star model (4908)
fvmin = pvar000(iv)
fvmax = pvar001inv(iv)
faclog10 = 1. / log(10.)
fvscale = faclog10 * log(fvmax/fvmin)
fvlgfc = 250.499 / fvscale
do ixyz = 1, 8*ncxyz
i1 = iachar(cflds(ixyz,1))
i2 = iachar(cflds(ixyz,2))
y1 = float(i1 - 2)
y2 = 0.5 + float(i2 - 2)
ffvimg = y1 + y2 / 250.499
if(i1+i2 .gt. 4) then
fld8(ixyz) = exp((ffvimg/fvlgfc - fvscale) / faclog10)
else
fld8(ixyz) = 0.0
endif
enddo
ididmap = 1
endif
if(ididmap .ne. 1) then
write (6,*) "This map is not supported:"
write (6,*) "-->", cppmmap(iv)(1:12), "<--- iv=",iv
stop
endif
call blend8(ncpbx,ncpby,ncpbz, fld8, fld)
deallocate(fld8)
return
end
C=====================================================================72
subroutine blend8(nx,ny,nz,f8,f)
implicit none
integer nx, ny, nz, ix, iy, iz, ix1,iy1,iz1,ix2,iy2,iz2
real f8(2*nx,2*ny,2*nz), f(nx,ny,nz)
do iz = 1, nz
iz2 = 2*iz
iz1 = iz2 - 1
do iy = 1, ny
iy2 = 2*iy
iy1 = iy2 - 1
do ix = 1, nx
ix2 = 2*ix
ix1 = ix2 - 1
f(ix,iy,iz) = 0.125 * (f8(ix1,iy1,iz1) + f8(ix2,iy1,iz1) +
1 f8(ix1,iy2,iz1) + f8(ix2,iy2,iz1) +
1 f8(ix1,iy1,iz2) + f8(ix2,iy1,iz2) +
1 f8(ix1,iy2,iz2) + f8(ix2,iy2,iz2) )
enddo
enddo
enddo
return
end
C=====================================================================72
subroutine inv_fv_map(fvmin, fvmax, fv, ffvimg, imgffv1, imgffv2)
implicit none
real fvmin, fvmax, fv, ffvimg
real faclog10, fvscale, fvlgfc, y1, y2
integer imgffv1, imgffv2, ffvimg1, ffvimg2
y1 = float(imgffv1 - 2)
y2 = 0.5 + float(imgffv2 - 2)
ffvimg = y1 + y2 / 250.499
faclog10 = 1. / log(10.)
fvscale = faclog10 * log(fvmax/fvmin)
fvlgfc = 250.499 / fvscale
fv = exp((ffvimg/fvlgfc - fvscale) / faclog10)
return
end
C=====================================================================72
subroutine invsgnmapbb (s0, s1inv, i1,i2, x)
y1 = float(i1 - 2)
y2 = 0.5 + float(i2 - 2)
y = y1 + y2 / 250.499
a = y / 250.499
c = a / (1.0 - a)
d = sqrt(c)
g = 0.5*(d*d - 1)/d
x = g / s1inv
return
end
C=====================================================================72
subroutine invposmapstar(p0, p1inv, i1,i2, x)
implicit none
real p0, p1inv, x
integer i1,i2
real*8 pp0, pp1inv, yy, p1, p2, e, c, t, a, xx
pp0 = p0
pp1inv = p1inv
! im1 = y
! p1 = im1
! p2 = (y - p1) * 250.499
! im2 = p2
! i1 = im1 + 2
! i2 = im2 + 2
p1 = dble(i1 - 2)
p2 = 0.5d0 + dble(i2 - 2)
yy = p1 + p2 / 250.499d0
if (p0 .le. 0.) e = yy / 250.499d0
if (p0 .gt. 0.) e = (2.0d0/250.499d0) * yy - 1.0d0
c = (1.0d0 + e) / (1.0d0 - e)
t = sqrt(c)
a = 0.5d0 * (t*t - 1.0d0) / t
xx = p0 + a / p1inv
x = xx
return
end
C=====================================================================72
subroutine get_lines(nlines, clines)
implicit none
integer i, nlines
character*256 clines(256)
do nlines = 1, 256
do i = 1, 256
clines(nlines)(i:i) = ' '
enddo
enddo
open(17,file="read_ppm.in",form='formatted',status='old',err=230)
nlines = 1
100 read (17,999,end=200) clines(nlines)
999 format(a256)
nlines = nlines + 1
if(nlines .gt. 256) then
write (6,*) 'Subroutine setoutput:'
write (6,*) 'Number of line in input exceeds the limit'
write (6,*) 'Check input or increase the dims of clines'
stop
endif
go to 100
200 continue
close(17)
return
230 write (6,*) 'failed to open read_ppm.in'
stop
end
C=====================================================================72
subroutine set_defaults()
implicit none
include "read_ppm.h"
integer i
do i = 1, 256
cRootFile(i:i) = " "
cOutFile(i:i) = " "
cReadVars(i:i) = " "
enddo
! invalid values
nzf = -1
ix0f = -1
ncpbx = -1
ncpby = -1
ncpbz = -1
nvpc = 0
nblend = 1
nfmoms = 1
nfffvars = 0
nodsx = 1
nodsy = 1
nodsz = 1
time = 1.0
ncycle = 1
nrrho = -1
nrprs = -1
return
end
C=====================================================================72
subroutine gen_iloc_idel()
implicit none
include "read_ppm.h"
character*16 cVar
integer i, idel
nppmvars = nvpc
do i = 1, nvpc
ilocppmvars(i) = i
idelppmvars(i) = 0
cvar = cppmvars(i)
idel = 0
if(trim(cvar).eq."dRho" .and. nrrho.gt.0) idel = 1
if(trim(cvar).eq."dPrs" .and. nrprs.gt.0) idel = 2
if(idel .gt. 0) then
nppmvars = nppmvars + 1
nresppmvars(nppmvars) = nresppmvars(i)
ilocppmvars(nppmvars) = i
idelppmvars(nppmvars) = idel
cppmvars(nppmvars) = " "
cppmvars(nppmvars)(1:3) = cvar(2:4)
endif
enddo
c >>>
return
end
c write (6,*) "nppmvars = ", nppmvars
c do i = 1, nppmvars
c write (6,999) i,ilocppmvars(i),idelppmvars(i)
c999 format("i,iloc,idel = ", 3i5)
c enddo
C=====================================================================72
subroutine get_read_var_list()
implicit none
include "read_ppm.h"
character*16 cVar
integer i0, i, irv
call gen_iloc_idel()
nReadVars = 0
i0 = 1
10 continue
cVar = " "
read (cReadVars(i0:256),*, end=100) cVar
irv = -1
do i = 1, nppmvars ! nvpc
if(trim(cVar) .eq. trim(cppmvars(i))) irv = i
enddo
if(irv .lt. 0) then
write (6,*) "Requested variable: ==>", trim(cvar), "<=="
write (6,*) "is not available in:"
do i = 1, nppmvars ! nvpc
write (6,*) i, "==>", trim(cppmvars(i)), "<=="
enddo
stop
endif
nReadVars = nReadVars + 1
iReadVars(nReadVars) = irv
c >>>
i0 = i0 + len(trim(cVar)) + 1
if(nReadVars .lt. 100) go to 10
100 continue
write (6,*) "cReadVars = ", trim(cReadVars)
write (6,999) (iReadVars(i),i=1,nReadVars)
999 format(" Read Vars: ", 100i4)
return
end
C=====================================================================72
subroutine get_inputs()
implicit none
include "read_ppm.h"
integer i, j, nlines, ix1f, iy1f, iz1f, ispace
character*256 clines(256), str, ckey
character*16 cvar
call get_lines(nlines, clines)
call set_defaults()
do i = 1, nlines
str = clines(i)
if(str(1:8).eq."readvars") read (str,*) ckey,cReadVars
if(str(1:8).eq."ixyz0 ") read (str,*) ckey,ix0f,iy0f,iz0f
if(str(1:8).eq."nxyz ") read (str,*) ckey,nxf ,nyf ,nzf
if(str(1:8).eq."nblend ") read (str,*) ckey,nblend
if(str(1:8).eq."nfmoms ") read (str,*) ckey,nfmoms
if(str(1:8).eq."file ") read (str,*) ckey,cRootFile
if(str(1:8).eq."outfile ") read (str,*) ckey,cOutFile
if(str(1:8).eq."time ") read (str,*) ckey,time
if(str(1:8).eq."ncycle ") read (str,*) ckey,ncycle
if(str(1:8).eq."rho_rad ") call read_rad(str,maxrad,nrrho,rrho)
if(str(1:8).eq."prs_rad ") call read_rad(str,maxrad,nrprs,rprs)
if(str(1:8).eq."nbrkx ") read (str,*) ckey,nbrkx
if(str(1:8).eq."nbrky ") read (str,*) ckey,nbrky
if(str(1:8).eq."nbrkz ") read (str,*) ckey,nbrkz
if(str(1:8).eq."nodsx ") read (str,*) ckey,nodsx
if(str(1:8).eq."nodsy ") read (str,*) ckey,nodsy
if(str(1:8).eq."nodsz ") read (str,*) ckey,nodsz
if(str(1:8).eq."bsizex ") read (str,*) ckey,bsizex
if(str(1:8).eq."bsizey ") read (str,*) ckey,bsizey
if(str(1:8).eq."bsizez ") read (str,*) ckey,bsizez
if(str(1:8).eq."ndbx ") read (str,*) ckey,ndbx
if(str(1:8).eq."ndby ") read (str,*) ckey,ndby
if(str(1:8).eq."ndbz ") read (str,*) ckey,ndbz
if(str(1:8).eq."nfilex ") read (str,*) ckey,nfilex
if(str(1:8).eq."nfiley ") read (str,*) ckey,nfiley
if(str(1:8).eq."nfilez ") read (str,*) ckey,nfilez
if(str(1:8).eq."ncpbx ") read (str,*) ckey,ncpbx
if(str(1:8).eq."ncpby ") read (str,*) ckey,ncpby
if(str(1:8).eq."ncpbz ") read (str,*) ckey,ncpbz
if(str(1:8).eq."nbpb ") read (str,*) ckey,nbpb
if(str(1:8).eq."field ") then
nvpc = nvpc + 1
read (str,*) ckey,cppmvars(nvpc),cppmmap(nvpc),
1 pvar000(nvpc),pvar001inv(nvpc)
nresppmvars(nvpc) = 1
endif
if(str(1:8).eq."field8 ") then
nvpc = nvpc + 1
read (str,*) ckey,cppmvars(nvpc),cppmmap(nvpc),
1 pvar000(nvpc),pvar001inv(nvpc)
nresppmvars(nvpc) = 2
do ispace = 2, 8
nvpc = nvpc + 1
cppmvars(nvpc)(1:8) = "# "
enddo
endif
enddo
call get_read_var_list()
call validate_inputs()
nxfb = nxf / nblend
nyfb = nyf / nblend
nzfb = nzf / nblend
return
end
C=====================================================================72
subroutine read_rad(str, maxrad, nrad, rval)
implicit none
character*(*) str
character*256 ckey, cfile, cline
integer maxrad, nrad
real rval(maxrad,2)
read (str,*) ckey, cfile
open(unit=11,file=cfile,form="formatted",err=1001)
nrad = 0
100 read (11,999,end=200) cline
999 format(a256)
if(cline(1:1) .ne. '#') then
nrad = nrad + 1
read (cline,*,err=1002) rval(nrad, 1), rval(nrad,2)
go to 100
endif
200 continue
close(11)
write (6,*) "read_rad: ", trim(cfile), nrad
return
1001 write (6,*) "Problem in read_rad: can not open", trim(cfile)
stop
1002 write (6,*) "Problem in read_rad: can not read line", trim(cfile)
stop
end
C=====================================================================72
subroutine validate_inputs()
implicit none
include "read_ppm.h"
integer i
if(nzf.le.0 ) write (6,*) "need xyzoff"
if( ix0f.le.0) write (6,*) "need yxzsize"
if(nzf.le.0 .or. ix0f.le.0) stop
if(cOutFile(1:4) .eq. " ") then
write (6,*) 'outfile not set'
stop
endif
if(mod(nxf,nblend).ne.0 .or. mod(nyf,nblend).ne.0 .or.
1 mod(nyf,nblend).ne.0 .or. mod(ncpbx,nblend).ne.0 .or.
1 mod(ncpby,nblend).ne.0 .or. mod(ncpbz,nblend).ne.0) then
write (6,*) 'n?f and ncpb? must all be multiples of nblend'
stop
endif
! Debug
write (6,*) " "
write (6,*) "RootFile = ", trim(cRootFile)
write (6,*) "xyzoffset = ", ix0f,iy0f,iz0f
write (6,*) "xyzsize = ", nxf,nyf,nzf
write (6,*) "nfile[xyz] = ", nfilex,nfiley,nfilez
write (6,*) "nbrk[xyz] = ", nbrkx,nbrky,nbrkz
write (6,*) "nods[xyz] = ", nodsx,nodsy,nodsz
write (6,*) "ncpb[xyz] = ", ncpbx,ncpby,ncpbz
write (6,*) "nbpb,nvpc = ", nbpb,nvpc
write (6,*) " "
write (6,*) " i Name Map ",
1 " pvar000 pvar001inv"
do i = 1, nvpc
if(cppmvars(i)(1:1) .ne. "#")
1 write (6,901) i,cppmvars(i),cppmmap(i),pvar000(i),pvar001inv(i)
901 format(i4, " ", 2a15, 1p2e15.6)
enddo
write (6,*) " "
return
end
C=====================================================================72
subroutine set_ppm_scalings(cVNMfile)
implicit none
character*256 cVNMfile
character*5 cstr5
include "read_ppm.h"
integer i
write (6,*) trim(cVNMfile)
! Read in argsimg info
open(11,file=cVNMfile,form='formatted',status='old',err=230)
! Debug
read (11,801) cstr5, nvpc
801 format(a5,i5)
write (6,*) "nvpc = ", nvpc
do i = 1, nvpc
read (11,802) cppmvars(i),cppmmap(i),pvar000(i),pvar001inv(i)
802 format(2a16,1p2e16.6)
enddo
close(11)
write (6,*) " "
write (6,*) " i Name Map ",
1 " pvar000 pvar001inv"
do i = 1, nvpc
write (6,901) i,cppmvars(i),cppmmap(i),pvar000(i),pvar001inv(i)
901 format(i4, " ", 2a15, 1p2e15.6)
enddo
write (6,*) " "
return
230 write (6,*) 'failed to open ', trim(cVNMfile)
stop
end
c=====================================================================72
subroutine remove_nan(val, nx,ny,nz,nv, flds)
implicit none
integer nx,ny,nz,nv
real val, flds(nx,ny,nz,nv)
integer ix,iy,iz,iv
logical is_nan
do iv = 1, nv
do iz = 1, nz
do iy = 1, ny
do ix = 1, nx
if(is_nan(flds(ix,iy,iz,iv))) flds(ix,iy,iz,iv) = val
enddo
enddo
enddo
enddo
return
end
c=====================================================================72
logical function is_nan(v)
real v
logical is_not_real
is_not_real = .true.
if(v .gt. 0.0) is_not_real = .false.
if(v .lt. 1.0) is_not_real = .false.
is_nan = is_not_real
return
end
C=====================================================================72
subroutine set_str_blank(c)
implicit none
character*(*) c
integer i
do i=1,len(c)
c(i:i) = ' '
enddo
return
end
C=====================================================================72
|
After the success of Boogie Nights , New Line told Anderson that he could do whatever he wanted for his next film and granted him creative control . Though Anderson initially wanted to make a film that was " intimate and small @-@ scale " , the script " kept blossoming " . The resulting film was the ensemble piece Magnolia ( 1999 ) , which tells the story of the peculiar interaction of several individuals in the San Fernando Valley . Anderson used the music of Aimee Mann as a basis and inspiration for the film , commissioning her to write eight new songs . At the 72nd Academy Awards , Magnolia received three nominations , for Best Actor in a Supporting Role ( Tom Cruise ) , Best Original Song for " Save Me " by Aimee Mann and Best Original Screenplay . Anderson stated after the film 's release that " what I really feel is that Magnolia is , for better or worse , the best movie I 'll ever make . "
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.topology.tactic
import Mathlib.PostPort
universes u u_1 l v u_2 w u_3
namespace Mathlib
/-!
# Ordering on topologies and (co)induced topologies
Topologies on a fixed type `α` are ordered, by reverse inclusion.
That is, for topologies `t₁` and `t₂` on `α`, we write `t₁ ≤ t₂`
if every set open in `t₂` is also open in `t₁`.
(One also calls `t₁` finer than `t₂`, and `t₂` coarser than `t₁`.)
Any function `f : α → β` induces
`induced f : topological_space β → topological_space α`
and `coinduced f : topological_space α → topological_space β`.
Continuity, the ordering on topologies and (co)induced topologies are
related as follows:
* The identity map (α, t₁) → (α, t₂) is continuous iff t₁ ≤ t₂.
* A map f : (α, t) → (β, u) is continuous
iff t ≤ induced f u (`continuous_iff_le_induced`)
iff coinduced f t ≤ u (`continuous_iff_coinduced_le`).
Topologies on α form a complete lattice, with ⊥ the discrete topology
and ⊤ the indiscrete topology.
For a function f : α → β, (coinduced f, induced f) is a Galois connection
between topologies on α and topologies on β.
## Implementation notes
There is a Galois insertion between topologies on α (with the inclusion ordering)
and all collections of sets in α. The complete lattice structure on topologies
on α is defined as the reverse of the one obtained via this Galois insertion.
## Tags
finer, coarser, induced topology, coinduced topology
-/
namespace topological_space
/-- The open sets of the least topology containing a collection of basic sets. -/
inductive generate_open {α : Type u} (g : set (set α)) : set α → Prop
where
| basic : ∀ (s : set α), s ∈ g → generate_open g s
| univ : generate_open g set.univ
| inter : ∀ (s t : set α), generate_open g s → generate_open g t → generate_open g (s ∩ t)
| sUnion : ∀ (k : set (set α)), (∀ (s : set α), s ∈ k → generate_open g s) → generate_open g (⋃₀k)
/-- The smallest topological space containing the collection `g` of basic sets -/
def generate_from {α : Type u} (g : set (set α)) : topological_space α :=
mk (generate_open g) generate_open.univ generate_open.inter generate_open.sUnion
theorem nhds_generate_from {α : Type u} {g : set (set α)} {a : α} : nhds a = infi fun (s : set α) => infi fun (H : s ∈ set_of fun (s : set α) => a ∈ s ∧ s ∈ g) => filter.principal s := sorry
theorem tendsto_nhds_generate_from {α : Type u} {β : Type u_1} {m : α → β} {f : filter α} {g : set (set β)} {b : β} (h : ∀ (s : set β), s ∈ g → b ∈ s → m ⁻¹' s ∈ f) : filter.tendsto m f (nhds b) := sorry
/-- Construct a topology on α given the filter of neighborhoods of each point of α. -/
protected def mk_of_nhds {α : Type u} (n : α → filter α) : topological_space α :=
mk (fun (s : set α) => ∀ (a : α), a ∈ s → s ∈ n a) sorry sorry sorry
theorem nhds_mk_of_nhds {α : Type u} (n : α → filter α) (a : α) (h₀ : pure ≤ n) (h₁ : ∀ {a : α} {s : set α}, s ∈ n a → ∃ (t : set α), ∃ (H : t ∈ n a), t ⊆ s ∧ ∀ (a' : α), a' ∈ t → s ∈ n a') : nhds a = n a := sorry
end topological_space
/-- The inclusion ordering on topologies on α. We use it to get a complete
lattice instance via the Galois insertion method, but the partial order
that we will eventually impose on `topological_space α` is the reverse one. -/
def tmp_order {α : Type u} : partial_order (topological_space α) :=
partial_order.mk (fun (t s : topological_space α) => topological_space.is_open t ≤ topological_space.is_open s)
(preorder.lt._default fun (t s : topological_space α) => topological_space.is_open t ≤ topological_space.is_open s)
sorry sorry sorry
/- We'll later restate this lemma in terms of the correct order on `topological_space α`. -/
/-- If `s` equals the collection of open sets in the topology it generates,
then `s` defines a topology. -/
protected def mk_of_closure {α : Type u} (s : set (set α)) (hs : (set_of fun (u : set α) => topological_space.is_open (topological_space.generate_from s) u) = s) : topological_space α :=
topological_space.mk (fun (u : set α) => u ∈ s) sorry sorry sorry
theorem mk_of_closure_sets {α : Type u} {s : set (set α)} {hs : (set_of fun (u : set α) => topological_space.is_open (topological_space.generate_from s) u) = s} : Mathlib.mk_of_closure s hs = topological_space.generate_from s :=
topological_space_eq (Eq.symm hs)
/-- The Galois insertion between `set (set α)` and `topological_space α` whose lower part
sends a collection of subsets of α to the topology they generate, and whose upper part
sends a topology to its collection of open subsets. -/
def gi_generate_from (α : Type u_1) : galois_insertion topological_space.generate_from
fun (t : topological_space α) => set_of fun (s : set α) => topological_space.is_open t s :=
galois_insertion.mk
(fun (g : set (set α))
(hg : (set_of fun (s : set α) => topological_space.is_open (topological_space.generate_from g) s) ≤ g) =>
Mathlib.mk_of_closure g sorry)
sorry sorry sorry
theorem generate_from_mono {α : Type u_1} {g₁ : set (set α)} {g₂ : set (set α)} (h : g₁ ⊆ g₂) : topological_space.generate_from g₁ ≤ topological_space.generate_from g₂ :=
galois_connection.monotone_l (galois_insertion.gc (gi_generate_from α)) h
/-- The complete lattice of topological spaces, but built on the inclusion ordering. -/
def tmp_complete_lattice {α : Type u} : complete_lattice (topological_space α) :=
galois_insertion.lift_complete_lattice (gi_generate_from α)
/-- The ordering on topologies on the type `α`.
`t ≤ s` if every set open in `s` is also open in `t` (`t` is finer than `s`). -/
protected instance topological_space.partial_order {α : Type u} : partial_order (topological_space α) :=
partial_order.mk (fun (t s : topological_space α) => topological_space.is_open s ≤ topological_space.is_open t)
(preorder.lt._default fun (t s : topological_space α) => topological_space.is_open s ≤ topological_space.is_open t)
sorry sorry sorry
theorem le_generate_from_iff_subset_is_open {α : Type u} {g : set (set α)} {t : topological_space α} : t ≤ topological_space.generate_from g ↔ g ⊆ set_of fun (s : set α) => topological_space.is_open t s :=
generate_from_le_iff_subset_is_open
/-- Topologies on `α` form a complete lattice, with `⊥` the discrete topology
and `⊤` the indiscrete topology. The infimum of a collection of topologies
is the topology generated by all their open sets, while the supremem is the
topology whose open sets are those sets open in every member of the collection. -/
protected instance topological_space.complete_lattice {α : Type u} : complete_lattice (topological_space α) :=
order_dual.complete_lattice (topological_space α)
/-- A topological space is discrete if every set is open, that is,
its topology equals the discrete topology `⊥`. -/
class discrete_topology (α : Type u_1) [t : topological_space α]
where
eq_bot : t = ⊥
@[simp] theorem is_open_discrete {α : Type u} [topological_space α] [discrete_topology α] (s : set α) : is_open s :=
Eq.symm (discrete_topology.eq_bot α) ▸ trivial
@[simp] theorem is_closed_discrete {α : Type u} [topological_space α] [discrete_topology α] (s : set α) : is_closed s :=
Eq.symm (discrete_topology.eq_bot α) ▸ trivial
theorem continuous_of_discrete_topology {α : Type u} {β : Type v} [topological_space α] [discrete_topology α] [topological_space β] {f : α → β} : continuous f :=
iff.mpr continuous_def fun (s : set β) (hs : is_open s) => is_open_discrete (f ⁻¹' s)
theorem nhds_bot (α : Type u_1) : nhds = pure :=
le_antisymm (id fun (a : α) => id fun (s : set α) (hs : s ∈ pure a) => mem_nhds_sets trivial hs) pure_le_nhds
theorem nhds_discrete (α : Type u_1) [topological_space α] [discrete_topology α] : nhds = pure :=
Eq.symm (discrete_topology.eq_bot α) ▸ nhds_bot α
theorem le_of_nhds_le_nhds {α : Type u} {t₁ : topological_space α} {t₂ : topological_space α} (h : ∀ (x : α), nhds x ≤ nhds x) : t₁ ≤ t₂ := sorry
theorem eq_of_nhds_eq_nhds {α : Type u} {t₁ : topological_space α} {t₂ : topological_space α} (h : ∀ (x : α), nhds x = nhds x) : t₁ = t₂ :=
le_antisymm (le_of_nhds_le_nhds fun (x : α) => le_of_eq (h x))
(le_of_nhds_le_nhds fun (x : α) => le_of_eq (Eq.symm (h x)))
theorem eq_bot_of_singletons_open {α : Type u} {t : topological_space α} (h : ∀ (x : α), topological_space.is_open t (singleton x)) : t = ⊥ :=
bot_unique
fun (s : set α) (hs : topological_space.is_open ⊥ s) =>
set.bUnion_of_singleton s ▸ is_open_bUnion fun (x : α) (_x : x ∈ s) => h x
theorem forall_open_iff_discrete {X : Type u_1} [topological_space X] : (∀ (s : set X), is_open s) ↔ discrete_topology X := sorry
theorem singletons_open_iff_discrete {X : Type u_1} [topological_space X] : (∀ (a : X), is_open (singleton a)) ↔ discrete_topology X :=
{ mp := fun (h : ∀ (a : X), is_open (singleton a)) => discrete_topology.mk (eq_bot_of_singletons_open h),
mpr := fun (a : discrete_topology X) (_x : X) => is_open_discrete (singleton _x) }
/-- Given `f : α → β` and a topology on `β`, the induced topology on `α` is the collection of
sets that are preimages of some open set in `β`. This is the coarsest topology that
makes `f` continuous. -/
def topological_space.induced {α : Type u} {β : Type v} (f : α → β) (t : topological_space β) : topological_space α :=
topological_space.mk (fun (s : set α) => ∃ (s' : set β), topological_space.is_open t s' ∧ f ⁻¹' s' = s) sorry sorry
sorry
theorem is_open_induced_iff {α : Type u_1} {β : Type u_2} [t : topological_space β] {s : set α} {f : α → β} : is_open s ↔ ∃ (t_1 : set β), is_open t_1 ∧ f ⁻¹' t_1 = s :=
iff.rfl
theorem is_closed_induced_iff {α : Type u_1} {β : Type u_2} [t : topological_space β] {s : set α} {f : α → β} : is_closed s ↔ ∃ (t_1 : set β), is_closed t_1 ∧ s = f ⁻¹' t_1 := sorry
/-- Given `f : α → β` and a topology on `α`, the coinduced topology on `β` is defined
such that `s:set β` is open if the preimage of `s` is open. This is the finest topology that
makes `f` continuous. -/
def topological_space.coinduced {α : Type u} {β : Type v} (f : α → β) (t : topological_space α) : topological_space β :=
topological_space.mk (fun (s : set β) => topological_space.is_open t (f ⁻¹' s)) sorry sorry sorry
theorem is_open_coinduced {α : Type u_1} {β : Type u_2} {t : topological_space α} {s : set β} {f : α → β} : is_open s ↔ is_open (f ⁻¹' s) :=
iff.rfl
theorem continuous.coinduced_le {α : Type u_1} {β : Type u_2} {t : topological_space α} {t' : topological_space β} {f : α → β} (h : continuous f) : topological_space.coinduced f t ≤ t' :=
fun (s : set β) (hs : topological_space.is_open t' s) => iff.mp continuous_def h s hs
theorem coinduced_le_iff_le_induced {α : Type u_1} {β : Type u_2} {f : α → β} {tα : topological_space α} {tβ : topological_space β} : topological_space.coinduced f tα ≤ tβ ↔ tα ≤ topological_space.induced f tβ := sorry
theorem continuous.le_induced {α : Type u_1} {β : Type u_2} {t : topological_space α} {t' : topological_space β} {f : α → β} (h : continuous f) : t ≤ topological_space.induced f t' :=
iff.mp coinduced_le_iff_le_induced (continuous.coinduced_le h)
theorem gc_coinduced_induced {α : Type u_1} {β : Type u_2} (f : α → β) : galois_connection (topological_space.coinduced f) (topological_space.induced f) :=
fun (f_1 : topological_space α) (g : topological_space β) => coinduced_le_iff_le_induced
theorem induced_mono {α : Type u_1} {β : Type u_2} {t₁ : topological_space α} {t₂ : topological_space α} {g : β → α} (h : t₁ ≤ t₂) : topological_space.induced g t₁ ≤ topological_space.induced g t₂ :=
galois_connection.monotone_u (gc_coinduced_induced g) h
theorem coinduced_mono {α : Type u_1} {β : Type u_2} {t₁ : topological_space α} {t₂ : topological_space α} {f : α → β} (h : t₁ ≤ t₂) : topological_space.coinduced f t₁ ≤ topological_space.coinduced f t₂ :=
galois_connection.monotone_l (gc_coinduced_induced f) h
@[simp] theorem induced_top {α : Type u_1} {β : Type u_2} {g : β → α} : topological_space.induced g ⊤ = ⊤ :=
galois_connection.u_top (gc_coinduced_induced g)
@[simp] theorem induced_inf {α : Type u_1} {β : Type u_2} {t₁ : topological_space α} {t₂ : topological_space α} {g : β → α} : topological_space.induced g (t₁ ⊓ t₂) = topological_space.induced g t₁ ⊓ topological_space.induced g t₂ :=
galois_connection.u_inf (gc_coinduced_induced g)
@[simp] theorem induced_infi {α : Type u_1} {β : Type u_2} {g : β → α} {ι : Sort w} {t : ι → topological_space α} : topological_space.induced g (infi fun (i : ι) => t i) = infi fun (i : ι) => topological_space.induced g (t i) :=
galois_connection.u_infi (gc_coinduced_induced g)
@[simp] theorem coinduced_bot {α : Type u_1} {β : Type u_2} {f : α → β} : topological_space.coinduced f ⊥ = ⊥ :=
galois_connection.l_bot (gc_coinduced_induced f)
@[simp] theorem coinduced_sup {α : Type u_1} {β : Type u_2} {t₁ : topological_space α} {t₂ : topological_space α} {f : α → β} : topological_space.coinduced f (t₁ ⊔ t₂) = topological_space.coinduced f t₁ ⊔ topological_space.coinduced f t₂ :=
galois_connection.l_sup (gc_coinduced_induced f)
@[simp] theorem coinduced_supr {α : Type u_1} {β : Type u_2} {f : α → β} {ι : Sort w} {t : ι → topological_space α} : topological_space.coinduced f (supr fun (i : ι) => t i) = supr fun (i : ι) => topological_space.coinduced f (t i) :=
galois_connection.l_supr (gc_coinduced_induced f)
theorem induced_id {α : Type u_1} [t : topological_space α] : topological_space.induced id t = t := sorry
theorem induced_compose {α : Type u_1} {β : Type u_2} {γ : Type u_3} [tγ : topological_space γ] {f : α → β} {g : β → γ} : topological_space.induced f (topological_space.induced g tγ) = topological_space.induced (g ∘ f) tγ := sorry
theorem coinduced_id {α : Type u_1} [t : topological_space α] : topological_space.coinduced id t = t :=
topological_space_eq rfl
theorem coinduced_compose {α : Type u_1} {β : Type u_2} {γ : Type u_3} [tα : topological_space α] {f : α → β} {g : β → γ} : topological_space.coinduced g (topological_space.coinduced f tα) = topological_space.coinduced (g ∘ f) tα :=
topological_space_eq rfl
/- constructions using the complete lattice structure -/
protected instance inhabited_topological_space {α : Type u} : Inhabited (topological_space α) :=
{ default := ⊤ }
protected instance subsingleton.unique_topological_space {α : Type u} [subsingleton α] : unique (topological_space α) :=
unique.mk { default := ⊥ } sorry
protected instance subsingleton.discrete_topology {α : Type u} [t : topological_space α] [subsingleton α] : discrete_topology α :=
discrete_topology.mk (unique.eq_default t)
protected instance empty.topological_space : topological_space empty :=
⊥
protected instance empty.discrete_topology : discrete_topology empty :=
discrete_topology.mk rfl
protected instance pempty.topological_space : topological_space pempty :=
⊥
protected instance pempty.discrete_topology : discrete_topology pempty :=
discrete_topology.mk rfl
protected instance unit.topological_space : topological_space Unit :=
⊥
protected instance unit.discrete_topology : discrete_topology Unit :=
discrete_topology.mk rfl
protected instance bool.topological_space : topological_space Bool :=
⊥
protected instance bool.discrete_topology : discrete_topology Bool :=
discrete_topology.mk rfl
protected instance nat.topological_space : topological_space ℕ :=
⊥
protected instance nat.discrete_topology : discrete_topology ℕ :=
discrete_topology.mk rfl
protected instance int.topological_space : topological_space ℤ :=
⊥
protected instance int.discrete_topology : discrete_topology ℤ :=
discrete_topology.mk rfl
protected instance sierpinski_space : topological_space Prop :=
topological_space.generate_from (singleton (singleton True))
theorem le_generate_from {α : Type u} {t : topological_space α} {g : set (set α)} (h : ∀ (s : set α), s ∈ g → is_open s) : t ≤ topological_space.generate_from g :=
iff.mpr le_generate_from_iff_subset_is_open h
theorem induced_generate_from_eq {α : Type u_1} {β : Type u_2} {b : set (set β)} {f : α → β} : topological_space.induced f (topological_space.generate_from b) = topological_space.generate_from (set.preimage f '' b) := sorry
/-- This construction is left adjoint to the operation sending a topology on `α`
to its neighborhood filter at a fixed point `a : α`. -/
protected def topological_space.nhds_adjoint {α : Type u} (a : α) (f : filter α) : topological_space α :=
topological_space.mk (fun (s : set α) => a ∈ s → s ∈ f) sorry sorry sorry
theorem gc_nhds {α : Type u} (a : α) : galois_connection (topological_space.nhds_adjoint a) fun (t : topological_space α) => nhds a := sorry
theorem nhds_mono {α : Type u} {t₁ : topological_space α} {t₂ : topological_space α} {a : α} (h : t₁ ≤ t₂) : nhds a ≤ nhds a :=
galois_connection.monotone_u (gc_nhds a) h
theorem nhds_infi {α : Type u} {ι : Sort u_1} {t : ι → topological_space α} {a : α} : nhds a = infi fun (i : ι) => nhds a :=
galois_connection.u_infi (gc_nhds a)
theorem nhds_Inf {α : Type u} {s : set (topological_space α)} {a : α} : nhds a = infi fun (t : topological_space α) => infi fun (H : t ∈ s) => nhds a :=
galois_connection.u_Inf (gc_nhds a)
theorem nhds_inf {α : Type u} {t₁ : topological_space α} {t₂ : topological_space α} {a : α} : nhds a = nhds a ⊓ nhds a :=
galois_connection.u_inf (gc_nhds a)
theorem nhds_top {α : Type u} {a : α} : nhds a = ⊤ :=
galois_connection.u_top (gc_nhds a)
theorem continuous_iff_coinduced_le {α : Type u} {β : Type v} {f : α → β} {t₁ : topological_space α} {t₂ : topological_space β} : continuous f ↔ topological_space.coinduced f t₁ ≤ t₂ :=
iff.trans continuous_def iff.rfl
theorem continuous_iff_le_induced {α : Type u} {β : Type v} {f : α → β} {t₁ : topological_space α} {t₂ : topological_space β} : continuous f ↔ t₁ ≤ topological_space.induced f t₂ :=
iff.trans continuous_iff_coinduced_le (gc_coinduced_induced f t₁ t₂)
theorem continuous_generated_from {α : Type u} {β : Type v} {f : α → β} {t : topological_space α} {b : set (set β)} (h : ∀ (s : set β), s ∈ b → is_open (f ⁻¹' s)) : continuous f :=
iff.mpr continuous_iff_coinduced_le (le_generate_from h)
theorem continuous_induced_dom {α : Type u} {β : Type v} {f : α → β} {t : topological_space β} : continuous f :=
eq.mpr (id (Eq._oldrec (Eq.refl (continuous f)) (propext continuous_def)))
fun (s : set β) (h : is_open s) => Exists.intro s { left := h, right := rfl }
theorem continuous_induced_rng {α : Type u} {β : Type v} {γ : Type u_1} {f : α → β} {g : γ → α} {t₂ : topological_space β} {t₁ : topological_space γ} (h : continuous (f ∘ g)) : continuous g := sorry
theorem continuous_induced_rng' {α : Type u} {β : Type v} {γ : Type u_1} [topological_space α] [topological_space β] [topological_space γ] {g : γ → α} (f : α → β) (H : _inst_1 = topological_space.induced f _inst_2) (h : continuous (f ∘ g)) : continuous g :=
Eq.symm H ▸ continuous_induced_rng h
theorem continuous_coinduced_rng {α : Type u} {β : Type v} {f : α → β} {t : topological_space α} : continuous f :=
eq.mpr (id (Eq._oldrec (Eq.refl (continuous f)) (propext continuous_def))) fun (s : set β) (h : is_open s) => h
theorem continuous_coinduced_dom {α : Type u} {β : Type v} {γ : Type u_1} {f : α → β} {g : β → γ} {t₁ : topological_space α} {t₂ : topological_space γ} (h : continuous (g ∘ f)) : continuous g :=
eq.mpr (id (Eq._oldrec (Eq.refl (continuous g)) (propext continuous_def)))
fun (s : set γ) (hs : is_open s) => eq.mp (Eq._oldrec (Eq.refl (continuous (g ∘ f))) (propext continuous_def)) h s hs
theorem continuous_le_dom {α : Type u} {β : Type v} {f : α → β} {t₁ : topological_space α} {t₂ : topological_space α} {t₃ : topological_space β} (h₁ : t₂ ≤ t₁) (h₂ : continuous f) : continuous f :=
eq.mpr (id (Eq._oldrec (Eq.refl (continuous f)) (propext continuous_def)))
fun (s : set β) (h : is_open s) =>
h₁ (f ⁻¹' s) (eq.mp (Eq._oldrec (Eq.refl (continuous f)) (propext continuous_def)) h₂ s h)
theorem continuous_le_rng {α : Type u} {β : Type v} {f : α → β} {t₁ : topological_space α} {t₂ : topological_space β} {t₃ : topological_space β} (h₁ : t₂ ≤ t₃) (h₂ : continuous f) : continuous f :=
eq.mpr (id (Eq._oldrec (Eq.refl (continuous f)) (propext continuous_def)))
fun (s : set β) (h : is_open s) => eq.mp (Eq._oldrec (Eq.refl (continuous f)) (propext continuous_def)) h₂ s (h₁ s h)
theorem continuous_sup_dom {α : Type u} {β : Type v} {f : α → β} {t₁ : topological_space α} {t₂ : topological_space α} {t₃ : topological_space β} (h₁ : continuous f) (h₂ : continuous f) : continuous f := sorry
theorem continuous_sup_rng_left {α : Type u} {β : Type v} {f : α → β} {t₁ : topological_space α} {t₃ : topological_space β} {t₂ : topological_space β} : continuous f → continuous f :=
continuous_le_rng le_sup_left
theorem continuous_sup_rng_right {α : Type u} {β : Type v} {f : α → β} {t₁ : topological_space α} {t₃ : topological_space β} {t₂ : topological_space β} : continuous f → continuous f :=
continuous_le_rng le_sup_right
theorem continuous_Sup_dom {α : Type u} {β : Type v} {f : α → β} {t₁ : set (topological_space α)} {t₂ : topological_space β} (h : ∀ (t : topological_space α), t ∈ t₁ → continuous f) : continuous f :=
iff.mpr continuous_iff_le_induced
(Sup_le fun (t : topological_space α) (ht : t ∈ t₁) => iff.mp continuous_iff_le_induced (h t ht))
theorem continuous_Sup_rng {α : Type u} {β : Type v} {f : α → β} {t₁ : topological_space α} {t₂ : set (topological_space β)} {t : topological_space β} (h₁ : t ∈ t₂) (hf : continuous f) : continuous f :=
iff.mpr continuous_iff_coinduced_le (le_Sup_of_le h₁ (iff.mp continuous_iff_coinduced_le hf))
theorem continuous_supr_dom {α : Type u} {β : Type v} {f : α → β} {ι : Sort u_2} {t₁ : ι → topological_space α} {t₂ : topological_space β} (h : ι → continuous f) : continuous f := sorry
theorem continuous_supr_rng {α : Type u} {β : Type v} {f : α → β} {ι : Sort u_2} {t₁ : topological_space α} {t₂ : ι → topological_space β} {i : ι} (h : continuous f) : continuous f :=
continuous_Sup_rng (Exists.intro i rfl) h
theorem continuous_inf_rng {α : Type u} {β : Type v} {f : α → β} {t₁ : topological_space α} {t₂ : topological_space β} {t₃ : topological_space β} (h₁ : continuous f) (h₂ : continuous f) : continuous f :=
iff.mpr continuous_iff_coinduced_le
(le_inf (iff.mp continuous_iff_coinduced_le h₁) (iff.mp continuous_iff_coinduced_le h₂))
theorem continuous_inf_dom_left {α : Type u} {β : Type v} {f : α → β} {t₁ : topological_space α} {t₂ : topological_space α} {t₃ : topological_space β} : continuous f → continuous f :=
continuous_le_dom inf_le_left
theorem continuous_inf_dom_right {α : Type u} {β : Type v} {f : α → β} {t₁ : topological_space α} {t₂ : topological_space α} {t₃ : topological_space β} : continuous f → continuous f :=
continuous_le_dom inf_le_right
theorem continuous_Inf_dom {α : Type u} {β : Type v} {f : α → β} {t₁ : set (topological_space α)} {t₂ : topological_space β} {t : topological_space α} (h₁ : t ∈ t₁) : continuous f → continuous f :=
continuous_le_dom (Inf_le h₁)
theorem continuous_Inf_rng {α : Type u} {β : Type v} {f : α → β} {t₁ : topological_space α} {t₂ : set (topological_space β)} (h : ∀ (t : topological_space β), t ∈ t₂ → continuous f) : continuous f :=
iff.mpr continuous_iff_coinduced_le
(le_Inf fun (b : topological_space β) (hb : b ∈ t₂) => iff.mp continuous_iff_coinduced_le (h b hb))
theorem continuous_infi_dom {α : Type u} {β : Type v} {f : α → β} {ι : Sort u_2} {t₁ : ι → topological_space α} {t₂ : topological_space β} {i : ι} : continuous f → continuous f :=
continuous_le_dom (infi_le t₁ i)
theorem continuous_infi_rng {α : Type u} {β : Type v} {f : α → β} {ι : Sort u_2} {t₁ : topological_space α} {t₂ : ι → topological_space β} (h : ι → continuous f) : continuous f :=
iff.mpr continuous_iff_coinduced_le (le_infi fun (i : ι) => iff.mp continuous_iff_coinduced_le (h i))
theorem continuous_bot {α : Type u} {β : Type v} {f : α → β} {t : topological_space β} : continuous f :=
iff.mpr continuous_iff_le_induced bot_le
theorem continuous_top {α : Type u} {β : Type v} {f : α → β} {t : topological_space α} : continuous f :=
iff.mpr continuous_iff_coinduced_le le_top
/- 𝓝 in the induced topology -/
theorem mem_nhds_induced {α : Type u} {β : Type v} [T : topological_space α] (f : β → α) (a : β) (s : set β) : s ∈ nhds a ↔ ∃ (u : set α), ∃ (H : u ∈ nhds (f a)), f ⁻¹' u ⊆ s := sorry
theorem nhds_induced {α : Type u} {β : Type v} [T : topological_space α] (f : β → α) (a : β) : nhds a = filter.comap f (nhds (f a)) := sorry
theorem induced_iff_nhds_eq {α : Type u} {β : Type v} [tα : topological_space α] [tβ : topological_space β] (f : β → α) : tβ = topological_space.induced f tα ↔ ∀ (b : β), nhds b = filter.comap f (nhds (f b)) := sorry
theorem map_nhds_induced_of_surjective {α : Type u} {β : Type v} [T : topological_space α] {f : β → α} (hf : function.surjective f) (a : β) : filter.map f (nhds a) = nhds (f a) := sorry
theorem is_open_induced_eq {α : Type u_1} {β : Type u_2} [t : topological_space β] {f : α → β} {s : set α} : is_open s ↔ s ∈ set.preimage f '' set_of fun (s : set β) => is_open s :=
iff.rfl
theorem is_open_induced {α : Type u_1} {β : Type u_2} [t : topological_space β] {f : α → β} {s : set β} (h : is_open s) : topological_space.is_open (topological_space.induced f t) (f ⁻¹' s) :=
Exists.intro s { left := h, right := rfl }
theorem map_nhds_induced_eq {α : Type u_1} {β : Type u_2} [t : topological_space β] {f : α → β} {a : α} (h : set.range f ∈ nhds (f a)) : filter.map f (nhds a) = nhds (f a) :=
eq.mpr (id (Eq._oldrec (Eq.refl (filter.map f (nhds a) = nhds (f a))) (nhds_induced f a)))
(eq.mpr (id (Eq._oldrec (Eq.refl (filter.map f (filter.comap f (nhds (f a))) = nhds (f a))) (filter.map_comap h)))
(Eq.refl (nhds (f a))))
theorem closure_induced {α : Type u_1} {β : Type u_2} [t : topological_space β] {f : α → β} {a : α} {s : set α} (hf : ∀ (x y : α), f x = f y → x = y) : a ∈ closure s ↔ f a ∈ closure (f '' s) := sorry
@[simp] theorem is_open_singleton_true : is_open (singleton True) :=
topological_space.generate_open.basic (singleton True)
(eq.mpr (id (propext ((fun {α : Type} (a : α) => iff_true_intro (set.mem_singleton a)) (singleton True)))) trivial)
theorem continuous_Prop {α : Type u_1} [topological_space α] {p : α → Prop} : continuous p ↔ is_open (set_of fun (x : α) => p x) := sorry
theorem is_open_supr_iff {α : Type u} {ι : Type v} {t : ι → topological_space α} {s : set α} : is_open s ↔ ι → is_open s := sorry
theorem is_closed_infi_iff {α : Type u} {ι : Type v} {t : ι → topological_space α} {s : set α} : is_closed s ↔ ι → is_closed s :=
is_open_supr_iff
|
function isargmatrix(varargin)
%ISARGMATRIX throws an error if not a matrix
%
% Usage: isargmatrix(arg1,arg2,...)
%
% Input parameters:
% args - list of args
%
% See also: isargvector, isargscalar
%*****************************************************************************
% The MIT License (MIT) *
% *
% Copyright (c) 2010-2019 SFS Toolbox Developers *
% *
% Permission is hereby granted, free of charge, to any person obtaining a *
% copy of this software and associated documentation files (the "Software"), *
% to deal in the Software without restriction, including without limitation *
% the rights to use, copy, modify, merge, publish, distribute, sublicense, *
% and/or sell copies of the Software, and to permit persons to whom the *
% Software is furnished to do so, subject to the following conditions: *
% *
% The above copyright notice and this permission notice shall be included in *
% all copies or substantial portions of the Software. *
% *
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
% THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
% DEALINGS IN THE SOFTWARE. *
% *
% The SFS Toolbox allows to simulate and investigate sound field synthesis *
% methods like wave field synthesis or higher order ambisonics. *
% *
% https://sfs.readthedocs.io [email protected] *
%*****************************************************************************
%% ===== Checking for matrix =============================================
for ii = 1:nargin
if ~isnumeric(varargin{ii}) || ndims(varargin{ii})~=2
error('%s need to be a matrix.',inputname(ii));
end
end
|
Require Export DevCoq.Dev.lemmas_automation_gV2.
Lemma Desargues_plane : forall P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15,
rk(P1 :: P4 :: P7 :: nil) = 2 -> rk(P2 :: P5 :: P7 :: nil) = 2 -> rk(P3 :: P6 :: P7 :: nil) = 2 ->
rk(P1 :: P4 :: nil) = 2 -> rk(P2 :: P5 :: nil) = 2 -> rk(P3 :: P6 :: nil) = 2 ->
rk(P4 :: P7 :: nil) = 2 -> rk(P5 :: P7 :: nil) = 2 -> rk(P6 :: P7 :: nil) = 2 ->
rk(P1 :: P2 :: P3 :: nil) = 3 -> rk(P4 :: P5 :: P6 :: nil) = 3 ->
rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) = 3 ->
rk(P1 :: P2 :: P3 :: P11 :: nil) = 4 ->
rk(P1 :: P2 :: P3 :: P12 :: nil) = 4 ->
rk(P11 :: P12 :: nil) = 2 ->
rk(P7 :: P11 :: P12 :: nil) = 2 ->
rk(P1 :: P8 :: P12 :: nil) = 2 -> rk(P2 :: P9 :: P12 :: nil) = 2 -> rk(P3 :: P10 :: P12 :: nil) = 2 ->
rk(P4 :: P8 :: P11 :: nil) = 2 -> rk(P5 :: P9 :: P11 :: nil) = 2 -> rk(P6 :: P10 :: P11 :: nil) = 2 ->
rk(P8 :: P10 :: P14 :: nil) = 2 -> rk(P4 :: P6 :: P14 :: nil) = 2 ->
rk(P9 :: P10 :: P13 :: nil) = 2 -> rk(P5 :: P6 :: P13 :: nil) = 2 ->
rk(P8 :: P9 :: P15 :: nil) = 2 -> rk(P4 :: P5 :: P15 :: nil) = 2 -> rk(P13 :: P14 :: P15 :: nil) = 2.
Proof.
intros P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15
HP1P4P7eq HP2P5P7eq HP3P6P7eq HP1P4eq HP2P5eq HP3P6eq HP4P7eq HP5P7eq HP6P7eq
HP1P2P3eq HP4P5P6eq HP1P2P3P4P5P6P7eq HP1P2P3P11eq HP1P2P3P12eq HP11P12eq HP7P11P12eq
HP1P8P12eq HP2P9P12eq HP3P10P12eq HP4P8P11eq HP5P9P11eq HP6P10P11eq
HP8P10P14eq HP4P6P14eq HP9P10P13eq HP5P6P13eq HP8P9P15eq HP4P5P15eq.
try clear HP1P2m;assert(HP1P2m : rk(P1 :: P2 :: nil) >= 2).
{
try assert(HP3Mtmp : rk(P3 :: nil) <= 1) by (solve_hyps_max HP3eq HP3M).
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P1 :: P2 :: nil) (P3 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: nil) ((P1 :: P2 :: nil) ++ (P3 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3mtmp;try rewrite HT2 in HP1P2P3mtmp.
assert(HT := rule_2 (P1 :: P2 :: nil) (P3 :: nil) (nil) 3 0 1 HP1P2P3mtmp Hmtmp HP3Mtmp Hincl); apply HT.
}
try clear HP1P2P3P8P12m;assert(HP1P2P3P8P12m : rk(P1 :: P2 :: P3 :: P8 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P12m;assert(HP1P2P3P8P12m : rk(P1 :: P2 :: P3 :: P8 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P12 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P12m;assert(HP1P2P3P8P12m : rk(P1 :: P2 :: P3 :: P8 :: P12 :: nil) >= 4).
{
try assert(HP1P2P3P12mtmp : rk(P1 :: P2 :: P3 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P12eq HP1P2P3P12m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P12 :: nil) 4 4 HP1P2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P8P11m;assert(HP1P2P3P4P8P11m : rk(P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P8P11m;assert(HP1P2P3P4P8P11m : rk(P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P8P11m;assert(HP1P2P3P4P8P11m : rk(P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P5P6P11P13m;assert(HP1P2P3P4P5P6P11P13m : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P5P6P11P13m;assert(HP1P2P3P4P5P6P11P13m : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P5P6P11P13m;assert(HP1P2P3P4P5P6P11P13m : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5m;assert(HP4P5m : rk(P4 :: P5 :: nil) >= 2).
{
try assert(HP6Mtmp : rk(P6 :: nil) <= 1) by (solve_hyps_max HP6eq HP6M).
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P4 :: P5 :: nil) (P6 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P5 :: P6 :: nil) ((P4 :: P5 :: nil) ++ (P6 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP4P5P6mtmp;try rewrite HT2 in HP4P5P6mtmp.
assert(HT := rule_2 (P4 :: P5 :: nil) (P6 :: nil) (nil) 3 0 1 HP4P5P6mtmp Hmtmp HP6Mtmp Hincl); apply HT.
}
try clear HP3P4P5P6m;assert(HP3P4P5P6m : rk(P3 :: P4 :: P5 :: P6 :: nil) >= 2).
{
try assert(HP4P5mtmp : rk(P4 :: P5 :: nil) >= 2) by (solve_hyps_min HP4P5eq HP4P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: nil) (P3 :: P4 :: P5 :: P6 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: nil) (P3 :: P4 :: P5 :: P6 :: nil) 2 2 HP4P5mtmp Hcomp Hincl); apply HT.
}
try clear HP3P4P5P6m;assert(HP3P4P5P6m : rk(P3 :: P4 :: P5 :: P6 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P3 :: P4 :: P5 :: P6 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P3 :: P4 :: P5 :: P6 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP3P4P5P6M;assert(HP3P4P5P6M : rk(P3 :: P4 :: P5 :: P6 :: nil) <= 3).
{
try assert(HP1P2P3P4P5P6P7Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) <= 3) by (solve_hyps_max HP1P2P3P4P5P6P7eq HP1P2P3P4P5P6P7M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P3 :: P4 :: P5 :: P6 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P3 :: P4 :: P5 :: P6 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) 3 3 HP1P2P3P4P5P6P7Mtmp Hcomp Hincl); apply HT.
}
try clear HP2P4P5P6m;assert(HP2P4P5P6m : rk(P2 :: P4 :: P5 :: P6 :: nil) >= 2).
{
try assert(HP2P5mtmp : rk(P2 :: P5 :: nil) >= 2) by (solve_hyps_min HP2P5eq HP2P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P5 :: nil) (P2 :: P4 :: P5 :: P6 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P5 :: nil) (P2 :: P4 :: P5 :: P6 :: nil) 2 2 HP2P5mtmp Hcomp Hincl); apply HT.
}
try clear HP2P4P5P6m;assert(HP2P4P5P6m : rk(P2 :: P4 :: P5 :: P6 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P2 :: P4 :: P5 :: P6 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P2 :: P4 :: P5 :: P6 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP2P4P5P6M;assert(HP2P4P5P6M : rk(P2 :: P4 :: P5 :: P6 :: nil) <= 3).
{
try assert(HP1P2P3P4P5P6P7Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) <= 3) by (solve_hyps_max HP1P2P3P4P5P6P7eq HP1P2P3P4P5P6P7M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P2 :: P4 :: P5 :: P6 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P2 :: P4 :: P5 :: P6 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) 3 3 HP1P2P3P4P5P6P7Mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P5P6m;assert(HP1P4P5P6m : rk(P1 :: P4 :: P5 :: P6 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P5 :: P6 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P5 :: P6 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P5P6m;assert(HP1P4P5P6m : rk(P1 :: P4 :: P5 :: P6 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P1 :: P4 :: P5 :: P6 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P1 :: P4 :: P5 :: P6 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P5P6M;assert(HP1P4P5P6M : rk(P1 :: P4 :: P5 :: P6 :: nil) <= 3).
{
try assert(HP1P2P3P4P5P6P7Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) <= 3) by (solve_hyps_max HP1P2P3P4P5P6P7eq HP1P2P3P4P5P6P7M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: P5 :: P6 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P1 :: P4 :: P5 :: P6 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) 3 3 HP1P2P3P4P5P6P7Mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6m;assert(HP5P6m : rk(P5 :: P6 :: nil) >= 2).
{
try assert(HP4Mtmp : rk(P4 :: nil) <= 1) by (solve_hyps_max HP4eq HP4M).
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P4 :: nil) (P5 :: P6 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P5 :: P6 :: nil) ((P4 :: nil) ++ (P5 :: P6 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP4P5P6mtmp;try rewrite HT2 in HP4P5P6mtmp.
assert(HT := rule_4 (P4 :: nil) (P5 :: P6 :: nil) (nil) 3 0 1 HP4P5P6mtmp Hmtmp HP4Mtmp Hincl); apply HT.
}
try clear HP1P4P5P6P13m;assert(HP1P4P5P6P13m : rk(P1 :: P4 :: P5 :: P6 :: P13 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P5 :: P6 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P5 :: P6 :: P13 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P5P6P13m;assert(HP1P4P5P6P13m : rk(P1 :: P4 :: P5 :: P6 :: P13 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P1 :: P4 :: P5 :: P6 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P1 :: P4 :: P5 :: P6 :: P13 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P5P6P13M;assert(HP1P4P5P6P13M : rk(P1 :: P4 :: P5 :: P6 :: P13 :: nil) <= 3).
{
try assert(HP1P4P5P6Mtmp : rk(P1 :: P4 :: P5 :: P6 :: nil) <= 3) by (solve_hyps_max HP1P4P5P6eq HP1P4P5P6M).
try assert(HP5P6P13Mtmp : rk(P5 :: P6 :: P13 :: nil) <= 2) by (solve_hyps_max HP5P6P13eq HP5P6P13M).
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hincl : incl (P5 :: P6 :: nil) (list_inter (P1 :: P4 :: P5 :: P6 :: nil) (P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P5 :: P6 :: P13 :: nil) (P1 :: P4 :: P5 :: P6 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P4 :: P5 :: P6 :: P5 :: P6 :: P13 :: nil) ((P1 :: P4 :: P5 :: P6 :: nil) ++ (P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: P4 :: P5 :: P6 :: nil) (P5 :: P6 :: P13 :: nil) (P5 :: P6 :: nil) 3 2 2 HP1P4P5P6Mtmp HP5P6P13Mtmp HP5P6mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P2P4P5P6P13m;assert(HP1P2P4P5P6P13m : rk(P1 :: P2 :: P4 :: P5 :: P6 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P4 :: P5 :: P6 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P4 :: P5 :: P6 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P4P5P6P13m;assert(HP1P2P4P5P6P13m : rk(P1 :: P2 :: P4 :: P5 :: P6 :: P13 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P1 :: P2 :: P4 :: P5 :: P6 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P1 :: P2 :: P4 :: P5 :: P6 :: P13 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P4P5P6P13M;assert(HP1P2P4P5P6P13M : rk(P1 :: P2 :: P4 :: P5 :: P6 :: P13 :: nil) <= 3).
{
try assert(HP2P4P5P6Mtmp : rk(P2 :: P4 :: P5 :: P6 :: nil) <= 3) by (solve_hyps_max HP2P4P5P6eq HP2P4P5P6M).
try assert(HP1P4P5P6P13Mtmp : rk(P1 :: P4 :: P5 :: P6 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P4P5P6P13eq HP1P4P5P6P13M).
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (list_inter (P2 :: P4 :: P5 :: P6 :: nil) (P1 :: P4 :: P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P4 :: P5 :: P6 :: P13 :: nil) (P2 :: P4 :: P5 :: P6 :: P1 :: P4 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P4 :: P5 :: P6 :: P1 :: P4 :: P5 :: P6 :: P13 :: nil) ((P2 :: P4 :: P5 :: P6 :: nil) ++ (P1 :: P4 :: P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P2 :: P4 :: P5 :: P6 :: nil) (P1 :: P4 :: P5 :: P6 :: P13 :: nil) (P4 :: P5 :: P6 :: nil) 3 3 3 HP2P4P5P6Mtmp HP1P4P5P6P13Mtmp HP4P5P6mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P2P3P4P5P6P13m;assert(HP1P2P3P4P5P6P13m : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P5P6P13m;assert(HP1P2P3P4P5P6P13m : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P5P6P13M;assert(HP1P2P3P4P5P6P13M : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) <= 3).
{
try assert(HP3P4P5P6Mtmp : rk(P3 :: P4 :: P5 :: P6 :: nil) <= 3) by (solve_hyps_max HP3P4P5P6eq HP3P4P5P6M).
try assert(HP1P2P4P5P6P13Mtmp : rk(P1 :: P2 :: P4 :: P5 :: P6 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P4P5P6P13eq HP1P2P4P5P6P13M).
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (list_inter (P3 :: P4 :: P5 :: P6 :: nil) (P1 :: P2 :: P4 :: P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) (P3 :: P4 :: P5 :: P6 :: P1 :: P2 :: P4 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P4 :: P5 :: P6 :: P1 :: P2 :: P4 :: P5 :: P6 :: P13 :: nil) ((P3 :: P4 :: P5 :: P6 :: nil) ++ (P1 :: P2 :: P4 :: P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P3 :: P4 :: P5 :: P6 :: nil) (P1 :: P2 :: P4 :: P5 :: P6 :: P13 :: nil) (P4 :: P5 :: P6 :: nil) 3 3 3 HP3P4P5P6Mtmp HP1P2P4P5P6P13Mtmp HP4P5P6mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P4P11m;assert(HP1P4P11m : rk(P1 :: P4 :: P11 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P11 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P11m;assert(HP1P4P11m : rk(P1 :: P4 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3P4P5P6P13Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P4P5P6P13eq HP1P2P3P4P5P6P13M).
try assert(HP1P2P3P4P5P6P11P13mtmp : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P4P5P6P11P13eq HP1P2P3P4P5P6P11P13m).
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hincl : incl (P1 :: P4 :: nil) (list_inter (P1 :: P4 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil) (P1 :: P4 :: P11 :: P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P4 :: P11 :: P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) ((P1 :: P4 :: P11 :: nil) ++ (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P4P5P6P11P13mtmp;try rewrite HT2 in HP1P2P3P4P5P6P11P13mtmp.
assert(HT := rule_2 (P1 :: P4 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) (P1 :: P4 :: nil) 4 2 3 HP1P2P3P4P5P6P11P13mtmp HP1P4mtmp HP1P2P3P4P5P6P13Mtmp Hincl); apply HT.
}
try clear HP1P2P3P4P11m;assert(HP1P2P3P4P11m : rk(P1 :: P2 :: P3 :: P4 :: P11 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P11m;assert(HP1P2P3P4P11m : rk(P1 :: P2 :: P3 :: P4 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P11m;assert(HP1P2P3P4P11m : rk(P1 :: P2 :: P3 :: P4 :: P11 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P8P11M;assert(HP1P4P8P11M : rk(P1 :: P4 :: P8 :: P11 :: nil) <= 3).
{
try assert(HP1Mtmp : rk(P1 :: nil) <= 1) by (solve_hyps_max HP1eq HP1M).
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P1 :: nil) (P4 :: P8 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P8 :: P11 :: nil) (P1 :: P4 :: P8 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P4 :: P8 :: P11 :: nil) ((P1 :: nil) ++ (P4 :: P8 :: P11 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: nil) (P4 :: P8 :: P11 :: nil) (nil) 1 2 0 HP1Mtmp HP4P8P11Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P4P8P11m;assert(HP1P4P8P11m : rk(P1 :: P4 :: P8 :: P11 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P11 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P8P11m;assert(HP1P4P8P11m : rk(P1 :: P4 :: P8 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3P4P11Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P4P11eq HP1P2P3P4P11M).
try assert(HP1P2P3P4P8P11mtmp : rk(P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P4P8P11eq HP1P2P3P4P8P11m).
try assert(HP1P4P11mtmp : rk(P1 :: P4 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P4P11eq HP1P4P11m).
assert(Hincl : incl (P1 :: P4 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: P1 :: P4 :: P8 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P4 :: P11 :: P1 :: P4 :: P8 :: P11 :: nil) ((P1 :: P2 :: P3 :: P4 :: P11 :: nil) ++ (P1 :: P4 :: P8 :: P11 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P4P8P11mtmp;try rewrite HT2 in HP1P2P3P4P8P11mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P11 :: nil) (P1 :: P4 :: P11 :: nil) 4 3 4 HP1P2P3P4P8P11mtmp HP1P4P11mtmp HP1P2P3P4P11Mtmp Hincl); apply HT.
}
try clear HP1P8m;assert(HP1P8m : rk(P1 :: P8 :: nil) >= 2).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP1P4P8P11mtmp : rk(P1 :: P4 :: P8 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P4P8P11eq HP1P4P8P11m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P1 :: P8 :: nil) (P4 :: P8 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P4 :: P8 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P4 :: P8 :: P11 :: nil) ((P1 :: P8 :: nil) ++ (P4 :: P8 :: P11 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P4P8P11mtmp;try rewrite HT2 in HP1P4P8P11mtmp.
assert(HT := rule_2 (P1 :: P8 :: nil) (P4 :: P8 :: P11 :: nil) (P8 :: nil) 3 1 2 HP1P4P8P11mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP1P2P3P8m;assert(HP1P2P3P8m : rk(P1 :: P2 :: P3 :: P8 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8m;assert(HP1P2P3P8m : rk(P1 :: P2 :: P3 :: P8 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8m;assert(HP1P2P3P8m : rk(P1 :: P2 :: P3 :: P8 :: nil) >= 4).
{
try assert(HP1P8P12Mtmp : rk(P1 :: P8 :: P12 :: nil) <= 2) by (solve_hyps_max HP1P8P12eq HP1P8P12M).
try assert(HP1P2P3P8P12mtmp : rk(P1 :: P2 :: P3 :: P8 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8P12eq HP1P2P3P8P12m).
try assert(HP1P8mtmp : rk(P1 :: P8 :: nil) >= 2) by (solve_hyps_min HP1P8eq HP1P8m).
assert(Hincl : incl (P1 :: P8 :: nil) (list_inter (P1 :: P2 :: P3 :: P8 :: nil) (P1 :: P8 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P8 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P1 :: P8 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P8 :: P1 :: P8 :: P12 :: nil) ((P1 :: P2 :: P3 :: P8 :: nil) ++ (P1 :: P8 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P8P12mtmp;try rewrite HT2 in HP1P2P3P8P12mtmp.
assert(HT := rule_2 (P1 :: P2 :: P3 :: P8 :: nil) (P1 :: P8 :: P12 :: nil) (P1 :: P8 :: nil) 4 2 2 HP1P2P3P8P12mtmp HP1P8mtmp HP1P8P12Mtmp Hincl); apply HT.
}
try clear HP1P2P3P8P13P14P15m;assert(HP1P2P3P8P13P14P15m : rk(P1 :: P2 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P13P14P15m;assert(HP1P2P3P8P13P14P15m : rk(P1 :: P2 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P13P14P15m;assert(HP1P2P3P8P13P14P15m : rk(P1 :: P2 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) >= 4).
{
try assert(HP1P2P3P8mtmp : rk(P1 :: P2 :: P3 :: P8 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8eq HP1P2P3P8m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P8 :: nil) (P1 :: P2 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P8 :: nil) (P1 :: P2 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) 4 4 HP1P2P3P8mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P9P10P12P13m;assert(HP1P2P3P9P10P12P13m : rk(P1 :: P2 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P9P10P12P13m;assert(HP1P2P3P9P10P12P13m : rk(P1 :: P2 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P9P10P12P13m;assert(HP1P2P3P9P10P12P13m : rk(P1 :: P2 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) >= 4).
{
try assert(HP1P2P3P12mtmp : rk(P1 :: P2 :: P3 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P12eq HP1P2P3P12m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) 4 4 HP1P2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P7P11P12m;assert(HP1P2P3P5P7P11P12m : rk(P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P7P11P12m;assert(HP1P2P3P5P7P11P12m : rk(P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: P12 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P7P11P12m;assert(HP1P2P3P5P7P11P12m : rk(P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: P12 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: P12 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P6P11P13m;assert(HP1P2P3P5P6P11P13m : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P6P11P13m;assert(HP1P2P3P5P6P11P13m : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P6P11P13m;assert(HP1P2P3P5P6P11P13m : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P6m;assert(HP1P2P3P5P6m : rk(P1 :: P2 :: P3 :: P5 :: P6 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P6m;assert(HP1P2P3P5P6m : rk(P1 :: P2 :: P3 :: P5 :: P6 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P6M;assert(HP1P2P3P5P6M : rk(P1 :: P2 :: P3 :: P5 :: P6 :: nil) <= 3).
{
try assert(HP1P2P3P4P5P6P7Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) <= 3) by (solve_hyps_max HP1P2P3P4P5P6P7eq HP1P2P3P4P5P6P7M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P5 :: P6 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P1 :: P2 :: P3 :: P5 :: P6 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) 3 3 HP1P2P3P4P5P6P7Mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P6P13m;assert(HP1P2P3P5P6P13m : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P6P13m;assert(HP1P2P3P5P6P13m : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P6P13M;assert(HP1P2P3P5P6P13M : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) <= 3).
{
try assert(HP1P2P3P5P6Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: nil) <= 3) by (solve_hyps_max HP1P2P3P5P6eq HP1P2P3P5P6M).
try assert(HP5P6P13Mtmp : rk(P5 :: P6 :: P13 :: nil) <= 2) by (solve_hyps_max HP5P6P13eq HP5P6P13M).
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hincl : incl (P5 :: P6 :: nil) (list_inter (P1 :: P2 :: P3 :: P5 :: P6 :: nil) (P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P5 :: P6 :: P5 :: P6 :: P13 :: nil) ((P1 :: P2 :: P3 :: P5 :: P6 :: nil) ++ (P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: P2 :: P3 :: P5 :: P6 :: nil) (P5 :: P6 :: P13 :: nil) (P5 :: P6 :: nil) 3 2 2 HP1P2P3P5P6Mtmp HP5P6P13Mtmp HP5P6mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP2P5P11m;assert(HP2P5P11m : rk(P2 :: P5 :: P11 :: nil) >= 2).
{
try assert(HP2P5mtmp : rk(P2 :: P5 :: nil) >= 2) by (solve_hyps_min HP2P5eq HP2P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P5 :: nil) (P2 :: P5 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P5 :: nil) (P2 :: P5 :: P11 :: nil) 2 2 HP2P5mtmp Hcomp Hincl); apply HT.
}
try clear HP2P5P11m;assert(HP2P5P11m : rk(P2 :: P5 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3P5P6P13Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P5P6P13eq HP1P2P3P5P6P13M).
try assert(HP1P2P3P5P6P11P13mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P5P6P11P13eq HP1P2P3P5P6P11P13m).
try assert(HP2P5mtmp : rk(P2 :: P5 :: nil) >= 2) by (solve_hyps_min HP2P5eq HP2P5m).
assert(Hincl : incl (P2 :: P5 :: nil) (list_inter (P2 :: P5 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) (P2 :: P5 :: P11 :: P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P5 :: P11 :: P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) ((P2 :: P5 :: P11 :: nil) ++ (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P6P11P13mtmp;try rewrite HT2 in HP1P2P3P5P6P11P13mtmp.
assert(HT := rule_2 (P2 :: P5 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) (P2 :: P5 :: nil) 4 2 3 HP1P2P3P5P6P11P13mtmp HP2P5mtmp HP1P2P3P5P6P13Mtmp Hincl); apply HT.
}
try clear HP1P2P3P5P11m;assert(HP1P2P3P5P11m : rk(P1 :: P2 :: P3 :: P5 :: P11 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P11m;assert(HP1P2P3P5P11m : rk(P1 :: P2 :: P3 :: P5 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P11m;assert(HP1P2P3P5P11m : rk(P1 :: P2 :: P3 :: P5 :: P11 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP2P5P7P11P12m;assert(HP2P5P7P11P12m : rk(P2 :: P5 :: P7 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP2P5mtmp : rk(P2 :: P5 :: nil) >= 2) by (solve_hyps_min HP2P5eq HP2P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P5 :: nil) (P2 :: P5 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P5 :: nil) (P2 :: P5 :: P7 :: P11 :: P12 :: nil) 2 2 HP2P5mtmp Hcomp Hincl); apply HT.
}
try clear HP2P5P7P11P12M;assert(HP2P5P7P11P12M : rk(P2 :: P5 :: P7 :: P11 :: P12 :: nil) <= 3).
{
try assert(HP2P5P7Mtmp : rk(P2 :: P5 :: P7 :: nil) <= 2) by (solve_hyps_max HP2P5P7eq HP2P5P7M).
try assert(HP7P11P12Mtmp : rk(P7 :: P11 :: P12 :: nil) <= 2) by (solve_hyps_max HP7P11P12eq HP7P11P12M).
try assert(HP7mtmp : rk(P7 :: nil) >= 1) by (solve_hyps_min HP7eq HP7m).
assert(Hincl : incl (P7 :: nil) (list_inter (P2 :: P5 :: P7 :: nil) (P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P5 :: P7 :: P11 :: P12 :: nil) (P2 :: P5 :: P7 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P5 :: P7 :: P7 :: P11 :: P12 :: nil) ((P2 :: P5 :: P7 :: nil) ++ (P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P2 :: P5 :: P7 :: nil) (P7 :: P11 :: P12 :: nil) (P7 :: nil) 2 2 1 HP2P5P7Mtmp HP7P11P12Mtmp HP7mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP2P5P7P11P12m;assert(HP2P5P7P11P12m : rk(P2 :: P5 :: P7 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3P5P11Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P5P11eq HP1P2P3P5P11M).
try assert(HP1P2P3P5P7P11P12mtmp : rk(P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P5P7P11P12eq HP1P2P3P5P7P11P12m).
try assert(HP2P5P11mtmp : rk(P2 :: P5 :: P11 :: nil) >= 3) by (solve_hyps_min HP2P5P11eq HP2P5P11m).
assert(Hincl : incl (P2 :: P5 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P5 :: P11 :: nil) (P2 :: P5 :: P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: P12 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: P2 :: P5 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P5 :: P11 :: P2 :: P5 :: P7 :: P11 :: P12 :: nil) ((P1 :: P2 :: P3 :: P5 :: P11 :: nil) ++ (P2 :: P5 :: P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P7P11P12mtmp;try rewrite HT2 in HP1P2P3P5P7P11P12mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P5 :: P11 :: nil) (P2 :: P5 :: P7 :: P11 :: P12 :: nil) (P2 :: P5 :: P11 :: nil) 4 3 4 HP1P2P3P5P7P11P12mtmp HP2P5P11mtmp HP1P2P3P5P11Mtmp Hincl); apply HT.
}
try clear HP1P2P3P5P6P7P11P13m;assert(HP1P2P3P5P6P7P11P13m : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P6P7P11P13m;assert(HP1P2P3P5P6P7P11P13m : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P6P7P11P13m;assert(HP1P2P3P5P6P7P11P13m : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P7m;assert(HP1P2P3P7m : rk(P1 :: P2 :: P3 :: P7 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P7 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P7m;assert(HP1P2P3P7m : rk(P1 :: P2 :: P3 :: P7 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P7 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P7M;assert(HP1P2P3P7M : rk(P1 :: P2 :: P3 :: P7 :: nil) <= 3).
{
try assert(HP1P2P3P4P5P6P7Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) <= 3) by (solve_hyps_max HP1P2P3P4P5P6P7eq HP1P2P3P4P5P6P7M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P7 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P1 :: P2 :: P3 :: P7 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) 3 3 HP1P2P3P4P5P6P7Mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P6P7P13m;assert(HP1P2P3P5P6P7P13m : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P6P7P13m;assert(HP1P2P3P5P6P7P13m : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P6P7P13M;assert(HP1P2P3P5P6P7P13M : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) <= 3).
{
try assert(HP1P2P3P7Mtmp : rk(P1 :: P2 :: P3 :: P7 :: nil) <= 3) by (solve_hyps_max HP1P2P3P7eq HP1P2P3P7M).
try assert(HP1P2P3P5P6P13Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P5P6P13eq HP1P2P3P5P6P13M).
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (list_inter (P1 :: P2 :: P3 :: P7 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) (P1 :: P2 :: P3 :: P7 :: P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P7 :: P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) ((P1 :: P2 :: P3 :: P7 :: nil) ++ (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: P2 :: P3 :: P7 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) (P1 :: P2 :: P3 :: nil) 3 3 3 HP1P2P3P7Mtmp HP1P2P3P5P6P13Mtmp HP1P2P3mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP5P7P11m;assert(HP5P7P11m : rk(P5 :: P7 :: P11 :: nil) >= 2).
{
try assert(HP5P7mtmp : rk(P5 :: P7 :: nil) >= 2) by (solve_hyps_min HP5P7eq HP5P7m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P5 :: P7 :: nil) (P5 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P7 :: nil) (P5 :: P7 :: P11 :: nil) 2 2 HP5P7mtmp Hcomp Hincl); apply HT.
}
try clear HP5P7P11m;assert(HP5P7P11m : rk(P5 :: P7 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3P5P6P7P13Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P5P6P7P13eq HP1P2P3P5P6P7P13M).
try assert(HP1P2P3P5P6P7P11P13mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P5P6P7P11P13eq HP1P2P3P5P6P7P11P13m).
try assert(HP5P7mtmp : rk(P5 :: P7 :: nil) >= 2) by (solve_hyps_min HP5P7eq HP5P7m).
assert(Hincl : incl (P5 :: P7 :: nil) (list_inter (P5 :: P7 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) (P5 :: P7 :: P11 :: P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P7 :: P11 :: P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) ((P5 :: P7 :: P11 :: nil) ++ (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P6P7P11P13mtmp;try rewrite HT2 in HP1P2P3P5P6P7P11P13mtmp.
assert(HT := rule_2 (P5 :: P7 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) (P5 :: P7 :: nil) 4 2 3 HP1P2P3P5P6P7P11P13mtmp HP5P7mtmp HP1P2P3P5P6P7P13Mtmp Hincl); apply HT.
}
try clear HP1P2P3P5P7P11m;assert(HP1P2P3P5P7P11m : rk(P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P7P11m;assert(HP1P2P3P5P7P11m : rk(P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P7P11m;assert(HP1P2P3P5P7P11m : rk(P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP2P5P7P11m;assert(HP2P5P7P11m : rk(P2 :: P5 :: P7 :: P11 :: nil) >= 2).
{
try assert(HP2P5mtmp : rk(P2 :: P5 :: nil) >= 2) by (solve_hyps_min HP2P5eq HP2P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P5 :: nil) (P2 :: P5 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P5 :: nil) (P2 :: P5 :: P7 :: P11 :: nil) 2 2 HP2P5mtmp Hcomp Hincl); apply HT.
}
try clear HP2P5P7P11M;assert(HP2P5P7P11M : rk(P2 :: P5 :: P7 :: P11 :: nil) <= 3).
{
try assert(HP2P5P7Mtmp : rk(P2 :: P5 :: P7 :: nil) <= 2) by (solve_hyps_max HP2P5P7eq HP2P5P7M).
try assert(HP11Mtmp : rk(P11 :: nil) <= 1) by (solve_hyps_max HP11eq HP11M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P2 :: P5 :: P7 :: nil) (P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P5 :: P7 :: P11 :: nil) (P2 :: P5 :: P7 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P5 :: P7 :: P11 :: nil) ((P2 :: P5 :: P7 :: nil) ++ (P11 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P2 :: P5 :: P7 :: nil) (P11 :: nil) (nil) 2 1 0 HP2P5P7Mtmp HP11Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP2P5P7P11m;assert(HP2P5P7P11m : rk(P2 :: P5 :: P7 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3P5P11Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P5P11eq HP1P2P3P5P11M).
try assert(HP1P2P3P5P7P11mtmp : rk(P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P5P7P11eq HP1P2P3P5P7P11m).
try assert(HP2P5P11mtmp : rk(P2 :: P5 :: P11 :: nil) >= 3) by (solve_hyps_min HP2P5P11eq HP2P5P11m).
assert(Hincl : incl (P2 :: P5 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P5 :: P11 :: nil) (P2 :: P5 :: P7 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P7 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: P2 :: P5 :: P7 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P5 :: P11 :: P2 :: P5 :: P7 :: P11 :: nil) ((P1 :: P2 :: P3 :: P5 :: P11 :: nil) ++ (P2 :: P5 :: P7 :: P11 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P7P11mtmp;try rewrite HT2 in HP1P2P3P5P7P11mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P5 :: P11 :: nil) (P2 :: P5 :: P7 :: P11 :: nil) (P2 :: P5 :: P11 :: nil) 4 3 4 HP1P2P3P5P7P11mtmp HP2P5P11mtmp HP1P2P3P5P11Mtmp Hincl); apply HT.
}
try clear HP5P7P11P12M;assert(HP5P7P11P12M : rk(P5 :: P7 :: P11 :: P12 :: nil) <= 3).
{
try assert(HP5Mtmp : rk(P5 :: nil) <= 1) by (solve_hyps_max HP5eq HP5M).
try assert(HP7P11P12Mtmp : rk(P7 :: P11 :: P12 :: nil) <= 2) by (solve_hyps_max HP7P11P12eq HP7P11P12M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P5 :: nil) (P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P5 :: P7 :: P11 :: P12 :: nil) (P5 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P7 :: P11 :: P12 :: nil) ((P5 :: nil) ++ (P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P5 :: nil) (P7 :: P11 :: P12 :: nil) (nil) 1 2 0 HP5Mtmp HP7P11P12Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP5P7P11P12m;assert(HP5P7P11P12m : rk(P5 :: P7 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP5P7mtmp : rk(P5 :: P7 :: nil) >= 2) by (solve_hyps_min HP5P7eq HP5P7m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P5 :: P7 :: nil) (P5 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P7 :: nil) (P5 :: P7 :: P11 :: P12 :: nil) 2 2 HP5P7mtmp Hcomp Hincl); apply HT.
}
try clear HP5P7P11P12m;assert(HP5P7P11P12m : rk(P5 :: P7 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP2P5P7P11Mtmp : rk(P2 :: P5 :: P7 :: P11 :: nil) <= 3) by (solve_hyps_max HP2P5P7P11eq HP2P5P7P11M).
try assert(HP2P5P7P11P12mtmp : rk(P2 :: P5 :: P7 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP2P5P7P11P12eq HP2P5P7P11P12m).
try assert(HP5P7P11mtmp : rk(P5 :: P7 :: P11 :: nil) >= 3) by (solve_hyps_min HP5P7P11eq HP5P7P11m).
assert(Hincl : incl (P5 :: P7 :: P11 :: nil) (list_inter (P2 :: P5 :: P7 :: P11 :: nil) (P5 :: P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P5 :: P7 :: P11 :: P12 :: nil) (P2 :: P5 :: P7 :: P11 :: P5 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P5 :: P7 :: P11 :: P5 :: P7 :: P11 :: P12 :: nil) ((P2 :: P5 :: P7 :: P11 :: nil) ++ (P5 :: P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP2P5P7P11P12mtmp;try rewrite HT2 in HP2P5P7P11P12mtmp.
assert(HT := rule_4 (P2 :: P5 :: P7 :: P11 :: nil) (P5 :: P7 :: P11 :: P12 :: nil) (P5 :: P7 :: P11 :: nil) 3 3 3 HP2P5P7P11P12mtmp HP5P7P11mtmp HP2P5P7P11Mtmp Hincl); apply HT.
}
try clear HP1P2P3P5P11P12m;assert(HP1P2P3P5P11P12m : rk(P1 :: P2 :: P3 :: P5 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P11P12m;assert(HP1P2P3P5P11P12m : rk(P1 :: P2 :: P3 :: P5 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: P12 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P11P12m;assert(HP1P2P3P5P11P12m : rk(P1 :: P2 :: P3 :: P5 :: P11 :: P12 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: P12 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP5P11m;assert(HP5P11m : rk(P5 :: P11 :: nil) >= 2).
{
try assert(HP1P2P3P5P6P13Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P5P6P13eq HP1P2P3P5P6P13M).
try assert(HP1P2P3P5P6P11P13mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P5P6P11P13eq HP1P2P3P5P6P11P13m).
try assert(HP5mtmp : rk(P5 :: nil) >= 1) by (solve_hyps_min HP5eq HP5m).
assert(Hincl : incl (P5 :: nil) (list_inter (P5 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) (P5 :: P11 :: P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P11 :: P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) ((P5 :: P11 :: nil) ++ (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P6P11P13mtmp;try rewrite HT2 in HP1P2P3P5P6P11P13mtmp.
assert(HT := rule_2 (P5 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) (P5 :: nil) 4 1 3 HP1P2P3P5P6P11P13mtmp HP5mtmp HP1P2P3P5P6P13Mtmp Hincl); apply HT.
}
try clear HP5P11P12m;assert(HP5P11P12m : rk(P5 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2P3P5P11Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P5P11eq HP1P2P3P5P11M).
try assert(HP1P2P3P5P11P12mtmp : rk(P1 :: P2 :: P3 :: P5 :: P11 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P5P11P12eq HP1P2P3P5P11P12m).
try assert(HP5P11mtmp : rk(P5 :: P11 :: nil) >= 2) by (solve_hyps_min HP5P11eq HP5P11m).
assert(Hincl : incl (P5 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P5 :: P11 :: nil) (P5 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P11 :: P12 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: P5 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P5 :: P11 :: P5 :: P11 :: P12 :: nil) ((P1 :: P2 :: P3 :: P5 :: P11 :: nil) ++ (P5 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P11P12mtmp;try rewrite HT2 in HP1P2P3P5P11P12mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P5 :: P11 :: nil) (P5 :: P11 :: P12 :: nil) (P5 :: P11 :: nil) 4 2 4 HP1P2P3P5P11P12mtmp HP5P11mtmp HP1P2P3P5P11Mtmp Hincl); apply HT.
}
try clear HP5P11P12m;assert(HP5P11P12m : rk(P5 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP7P11P12Mtmp : rk(P7 :: P11 :: P12 :: nil) <= 2) by (solve_hyps_max HP7P11P12eq HP7P11P12M).
try assert(HP5P7P11P12mtmp : rk(P5 :: P7 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP5P7P11P12eq HP5P7P11P12m).
try assert(HP11P12mtmp : rk(P11 :: P12 :: nil) >= 2) by (solve_hyps_min HP11P12eq HP11P12m).
assert(Hincl : incl (P11 :: P12 :: nil) (list_inter (P5 :: P11 :: P12 :: nil) (P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P5 :: P7 :: P11 :: P12 :: nil) (P5 :: P11 :: P12 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P11 :: P12 :: P7 :: P11 :: P12 :: nil) ((P5 :: P11 :: P12 :: nil) ++ (P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP5P7P11P12mtmp;try rewrite HT2 in HP5P7P11P12mtmp.
assert(HT := rule_2 (P5 :: P11 :: P12 :: nil) (P7 :: P11 :: P12 :: nil) (P11 :: P12 :: nil) 3 2 2 HP5P7P11P12mtmp HP11P12mtmp HP7P11P12Mtmp Hincl); apply HT.
}
try clear HP1P2P3P5P9P11P12m;assert(HP1P2P3P5P9P11P12m : rk(P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P9P11P12m;assert(HP1P2P3P5P9P11P12m : rk(P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: P12 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P9P11P12m;assert(HP1P2P3P5P9P11P12m : rk(P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: P12 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: P12 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP5P9P11P12m;assert(HP5P9P11P12m : rk(P5 :: P9 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2P3P5P11Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P5P11eq HP1P2P3P5P11M).
try assert(HP1P2P3P5P9P11P12mtmp : rk(P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P5P9P11P12eq HP1P2P3P5P9P11P12m).
try assert(HP5P11mtmp : rk(P5 :: P11 :: nil) >= 2) by (solve_hyps_min HP5P11eq HP5P11m).
assert(Hincl : incl (P5 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P5 :: P11 :: nil) (P5 :: P9 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: P12 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: P5 :: P9 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P5 :: P11 :: P5 :: P9 :: P11 :: P12 :: nil) ((P1 :: P2 :: P3 :: P5 :: P11 :: nil) ++ (P5 :: P9 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P9P11P12mtmp;try rewrite HT2 in HP1P2P3P5P9P11P12mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P5 :: P11 :: nil) (P5 :: P9 :: P11 :: P12 :: nil) (P5 :: P11 :: nil) 4 2 4 HP1P2P3P5P9P11P12mtmp HP5P11mtmp HP1P2P3P5P11Mtmp Hincl); apply HT.
}
try clear HP5P9P11P12M;assert(HP5P9P11P12M : rk(P5 :: P9 :: P11 :: P12 :: nil) <= 3).
{
try assert(HP5P9P11Mtmp : rk(P5 :: P9 :: P11 :: nil) <= 2) by (solve_hyps_max HP5P9P11eq HP5P9P11M).
try assert(HP12Mtmp : rk(P12 :: nil) <= 1) by (solve_hyps_max HP12eq HP12M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P5 :: P9 :: P11 :: nil) (P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P5 :: P9 :: P11 :: P12 :: nil) (P5 :: P9 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P9 :: P11 :: P12 :: nil) ((P5 :: P9 :: P11 :: nil) ++ (P12 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P5 :: P9 :: P11 :: nil) (P12 :: nil) (nil) 2 1 0 HP5P9P11Mtmp HP12Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP5P9P11P12m;assert(HP5P9P11P12m : rk(P5 :: P9 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP5P11P12mtmp : rk(P5 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP5P11P12eq HP5P11P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P5 :: P11 :: P12 :: nil) (P5 :: P9 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P11 :: P12 :: nil) (P5 :: P9 :: P11 :: P12 :: nil) 3 3 HP5P11P12mtmp Hcomp Hincl); apply HT.
}
try clear HP9P12m;assert(HP9P12m : rk(P9 :: P12 :: nil) >= 2).
{
try assert(HP5P9P11Mtmp : rk(P5 :: P9 :: P11 :: nil) <= 2) by (solve_hyps_max HP5P9P11eq HP5P9P11M).
try assert(HP5P9P11P12mtmp : rk(P5 :: P9 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP5P9P11P12eq HP5P9P11P12m).
try assert(HP9mtmp : rk(P9 :: nil) >= 1) by (solve_hyps_min HP9eq HP9m).
assert(Hincl : incl (P9 :: nil) (list_inter (P5 :: P9 :: P11 :: nil) (P9 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P5 :: P9 :: P11 :: P12 :: nil) (P5 :: P9 :: P11 :: P9 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P9 :: P11 :: P9 :: P12 :: nil) ((P5 :: P9 :: P11 :: nil) ++ (P9 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP5P9P11P12mtmp;try rewrite HT2 in HP5P9P11P12mtmp.
assert(HT := rule_4 (P5 :: P9 :: P11 :: nil) (P9 :: P12 :: nil) (P9 :: nil) 3 1 2 HP5P9P11P12mtmp HP9mtmp HP5P9P11Mtmp Hincl); apply HT.
}
try clear HP1P3P12m;assert(HP1P3P12m : rk(P1 :: P3 :: P12 :: nil) >= 3).
{
try assert(HP2Mtmp : rk(P2 :: nil) <= 1) by (solve_hyps_max HP2eq HP2M).
try assert(HP1P2P3P12mtmp : rk(P1 :: P2 :: P3 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P12eq HP1P2P3P12m).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P2 :: nil) (P1 :: P3 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P12 :: nil) (P2 :: P1 :: P3 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P1 :: P3 :: P12 :: nil) ((P2 :: nil) ++ (P1 :: P3 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P12mtmp;try rewrite HT2 in HP1P2P3P12mtmp.
assert(HT := rule_4 (P2 :: nil) (P1 :: P3 :: P12 :: nil) (nil) 4 0 1 HP1P2P3P12mtmp Hmtmp HP2Mtmp Hincl); apply HT.
}
try clear HP1P3m;assert(HP1P3m : rk(P1 :: P3 :: nil) >= 2).
{
try assert(HP2Mtmp : rk(P2 :: nil) <= 1) by (solve_hyps_max HP2eq HP2M).
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P2 :: nil) (P1 :: P3 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: nil) (P2 :: P1 :: P3 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P1 :: P3 :: nil) ((P2 :: nil) ++ (P1 :: P3 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3mtmp;try rewrite HT2 in HP1P2P3mtmp.
assert(HT := rule_4 (P2 :: nil) (P1 :: P3 :: nil) (nil) 3 0 1 HP1P2P3mtmp Hmtmp HP2Mtmp Hincl); apply HT.
}
try clear HP1P3P9P10P12P13m;assert(HP1P3P9P10P12P13m : rk(P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P9P10P12P13m;assert(HP1P3P9P10P12P13m : rk(P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) >= 3).
{
try assert(HP1P3P12mtmp : rk(P1 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P3P12eq HP1P3P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: P12 :: nil) (P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: P12 :: nil) (P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) 3 3 HP1P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P9P10P12P13m;assert(HP1P3P9P10P12P13m : rk(P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) >= 4).
{
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(HP1P2P3P9P10P12P13mtmp : rk(P1 :: P2 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P9P10P12P13eq HP1P2P3P9P10P12P13m).
try assert(HP9P12mtmp : rk(P9 :: P12 :: nil) >= 2) by (solve_hyps_min HP9P12eq HP9P12m).
assert(Hincl : incl (P9 :: P12 :: nil) (list_inter (P2 :: P9 :: P12 :: nil) (P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) (P2 :: P9 :: P12 :: P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P9 :: P12 :: P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) ((P2 :: P9 :: P12 :: nil) ++ (P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P9P10P12P13mtmp;try rewrite HT2 in HP1P2P3P9P10P12P13mtmp.
assert(HT := rule_4 (P2 :: P9 :: P12 :: nil) (P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) (P9 :: P12 :: nil) 4 2 2 HP1P2P3P9P10P12P13mtmp HP9P12mtmp HP2P9P12Mtmp Hincl); apply HT.
}
try clear HP1P2P3P6P10P11m;assert(HP1P2P3P6P10P11m : rk(P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P6P10P11m;assert(HP1P2P3P6P10P11m : rk(P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P6P10P11m;assert(HP1P2P3P6P10P11m : rk(P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP3P6P11m;assert(HP3P6P11m : rk(P3 :: P6 :: P11 :: nil) >= 2).
{
try assert(HP3P6mtmp : rk(P3 :: P6 :: nil) >= 2) by (solve_hyps_min HP3P6eq HP3P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P3 :: P6 :: nil) (P3 :: P6 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P3 :: P6 :: nil) (P3 :: P6 :: P11 :: nil) 2 2 HP3P6mtmp Hcomp Hincl); apply HT.
}
try clear HP3P6P11m;assert(HP3P6P11m : rk(P3 :: P6 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3P5P6P13Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P5P6P13eq HP1P2P3P5P6P13M).
try assert(HP1P2P3P5P6P11P13mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P5P6P11P13eq HP1P2P3P5P6P11P13m).
try assert(HP3P6mtmp : rk(P3 :: P6 :: nil) >= 2) by (solve_hyps_min HP3P6eq HP3P6m).
assert(Hincl : incl (P3 :: P6 :: nil) (list_inter (P3 :: P6 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) (P3 :: P6 :: P11 :: P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P6 :: P11 :: P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) ((P3 :: P6 :: P11 :: nil) ++ (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P6P11P13mtmp;try rewrite HT2 in HP1P2P3P5P6P11P13mtmp.
assert(HT := rule_2 (P3 :: P6 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) (P3 :: P6 :: nil) 4 2 3 HP1P2P3P5P6P11P13mtmp HP3P6mtmp HP1P2P3P5P6P13Mtmp Hincl); apply HT.
}
try clear HP1P2P3P6P11m;assert(HP1P2P3P6P11m : rk(P1 :: P2 :: P3 :: P6 :: P11 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P6P11m;assert(HP1P2P3P6P11m : rk(P1 :: P2 :: P3 :: P6 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P6P11m;assert(HP1P2P3P6P11m : rk(P1 :: P2 :: P3 :: P6 :: P11 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP3P6P10P11M;assert(HP3P6P10P11M : rk(P3 :: P6 :: P10 :: P11 :: nil) <= 3).
{
try assert(HP3Mtmp : rk(P3 :: nil) <= 1) by (solve_hyps_max HP3eq HP3M).
try assert(HP6P10P11Mtmp : rk(P6 :: P10 :: P11 :: nil) <= 2) by (solve_hyps_max HP6P10P11eq HP6P10P11M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P3 :: nil) (P6 :: P10 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P3 :: P6 :: P10 :: P11 :: nil) (P3 :: P6 :: P10 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P6 :: P10 :: P11 :: nil) ((P3 :: nil) ++ (P6 :: P10 :: P11 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P3 :: nil) (P6 :: P10 :: P11 :: nil) (nil) 1 2 0 HP3Mtmp HP6P10P11Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP3P6P10P11m;assert(HP3P6P10P11m : rk(P3 :: P6 :: P10 :: P11 :: nil) >= 2).
{
try assert(HP3P6mtmp : rk(P3 :: P6 :: nil) >= 2) by (solve_hyps_min HP3P6eq HP3P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P3 :: P6 :: nil) (P3 :: P6 :: P10 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P3 :: P6 :: nil) (P3 :: P6 :: P10 :: P11 :: nil) 2 2 HP3P6mtmp Hcomp Hincl); apply HT.
}
try clear HP3P6P10P11m;assert(HP3P6P10P11m : rk(P3 :: P6 :: P10 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3P6P11Mtmp : rk(P1 :: P2 :: P3 :: P6 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P6P11eq HP1P2P3P6P11M).
try assert(HP1P2P3P6P10P11mtmp : rk(P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P6P10P11eq HP1P2P3P6P10P11m).
try assert(HP3P6P11mtmp : rk(P3 :: P6 :: P11 :: nil) >= 3) by (solve_hyps_min HP3P6P11eq HP3P6P11m).
assert(Hincl : incl (P3 :: P6 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P6 :: P11 :: nil) (P3 :: P6 :: P10 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: P3 :: P6 :: P10 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P6 :: P11 :: P3 :: P6 :: P10 :: P11 :: nil) ((P1 :: P2 :: P3 :: P6 :: P11 :: nil) ++ (P3 :: P6 :: P10 :: P11 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P6P10P11mtmp;try rewrite HT2 in HP1P2P3P6P10P11mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P6 :: P11 :: nil) (P3 :: P6 :: P10 :: P11 :: nil) (P3 :: P6 :: P11 :: nil) 4 3 4 HP1P2P3P6P10P11mtmp HP3P6P11mtmp HP1P2P3P6P11Mtmp Hincl); apply HT.
}
try clear HP3P10m;assert(HP3P10m : rk(P3 :: P10 :: nil) >= 2).
{
try assert(HP6P10P11Mtmp : rk(P6 :: P10 :: P11 :: nil) <= 2) by (solve_hyps_max HP6P10P11eq HP6P10P11M).
try assert(HP3P6P10P11mtmp : rk(P3 :: P6 :: P10 :: P11 :: nil) >= 3) by (solve_hyps_min HP3P6P10P11eq HP3P6P10P11m).
try assert(HP10mtmp : rk(P10 :: nil) >= 1) by (solve_hyps_min HP10eq HP10m).
assert(Hincl : incl (P10 :: nil) (list_inter (P3 :: P10 :: nil) (P6 :: P10 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P3 :: P6 :: P10 :: P11 :: nil) (P3 :: P10 :: P6 :: P10 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P10 :: P6 :: P10 :: P11 :: nil) ((P3 :: P10 :: nil) ++ (P6 :: P10 :: P11 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP3P6P10P11mtmp;try rewrite HT2 in HP3P6P10P11mtmp.
assert(HT := rule_2 (P3 :: P10 :: nil) (P6 :: P10 :: P11 :: nil) (P10 :: nil) 3 1 2 HP3P6P10P11mtmp HP10mtmp HP6P10P11Mtmp Hincl); apply HT.
}
try clear HP1P3P9P10P13m;assert(HP1P3P9P10P13m : rk(P1 :: P3 :: P9 :: P10 :: P13 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P9 :: P10 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P9 :: P10 :: P13 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P9P10P13m;assert(HP1P3P9P10P13m : rk(P1 :: P3 :: P9 :: P10 :: P13 :: nil) >= 3).
{
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(HP1P2P3P9P10P12P13mtmp : rk(P1 :: P2 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P9P10P12P13eq HP1P2P3P9P10P12P13m).
try assert(HP9mtmp : rk(P9 :: nil) >= 1) by (solve_hyps_min HP9eq HP9m).
assert(Hincl : incl (P9 :: nil) (list_inter (P2 :: P9 :: P12 :: nil) (P1 :: P3 :: P9 :: P10 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) (P2 :: P9 :: P12 :: P1 :: P3 :: P9 :: P10 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P9 :: P12 :: P1 :: P3 :: P9 :: P10 :: P13 :: nil) ((P2 :: P9 :: P12 :: nil) ++ (P1 :: P3 :: P9 :: P10 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P9P10P12P13mtmp;try rewrite HT2 in HP1P2P3P9P10P12P13mtmp.
assert(HT := rule_4 (P2 :: P9 :: P12 :: nil) (P1 :: P3 :: P9 :: P10 :: P13 :: nil) (P9 :: nil) 4 1 2 HP1P2P3P9P10P12P13mtmp HP9mtmp HP2P9P12Mtmp Hincl); apply HT.
}
try clear HP1P3P9P10P13m;assert(HP1P3P9P10P13m : rk(P1 :: P3 :: P9 :: P10 :: P13 :: nil) >= 4).
{
try assert(HP3P10P12Mtmp : rk(P3 :: P10 :: P12 :: nil) <= 2) by (solve_hyps_max HP3P10P12eq HP3P10P12M).
try assert(HP1P3P9P10P12P13mtmp : rk(P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P3P9P10P12P13eq HP1P3P9P10P12P13m).
try assert(HP3P10mtmp : rk(P3 :: P10 :: nil) >= 2) by (solve_hyps_min HP3P10eq HP3P10m).
assert(Hincl : incl (P3 :: P10 :: nil) (list_inter (P3 :: P10 :: P12 :: nil) (P1 :: P3 :: P9 :: P10 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) (P3 :: P10 :: P12 :: P1 :: P3 :: P9 :: P10 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P10 :: P12 :: P1 :: P3 :: P9 :: P10 :: P13 :: nil) ((P3 :: P10 :: P12 :: nil) ++ (P1 :: P3 :: P9 :: P10 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P3P9P10P12P13mtmp;try rewrite HT2 in HP1P3P9P10P12P13mtmp.
assert(HT := rule_4 (P3 :: P10 :: P12 :: nil) (P1 :: P3 :: P9 :: P10 :: P13 :: nil) (P3 :: P10 :: nil) 4 2 2 HP1P3P9P10P12P13mtmp HP3P10mtmp HP3P10P12Mtmp Hincl); apply HT.
}
try clear HP1P3P13m;assert(HP1P3P13m : rk(P1 :: P3 :: P13 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P13 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P13m;assert(HP1P3P13m : rk(P1 :: P3 :: P13 :: nil) >= 3).
{
try assert(HP9P10P13Mtmp : rk(P9 :: P10 :: P13 :: nil) <= 2) by (solve_hyps_max HP9P10P13eq HP9P10P13M).
try assert(HP1P3P9P10P13mtmp : rk(P1 :: P3 :: P9 :: P10 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P3P9P10P13eq HP1P3P9P10P13m).
try assert(HP13mtmp : rk(P13 :: nil) >= 1) by (solve_hyps_min HP13eq HP13m).
assert(Hincl : incl (P13 :: nil) (list_inter (P1 :: P3 :: P13 :: nil) (P9 :: P10 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P9 :: P10 :: P13 :: nil) (P1 :: P3 :: P13 :: P9 :: P10 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P3 :: P13 :: P9 :: P10 :: P13 :: nil) ((P1 :: P3 :: P13 :: nil) ++ (P9 :: P10 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P3P9P10P13mtmp;try rewrite HT2 in HP1P3P9P10P13mtmp.
assert(HT := rule_2 (P1 :: P3 :: P13 :: nil) (P9 :: P10 :: P13 :: nil) (P13 :: nil) 4 1 2 HP1P3P9P10P13mtmp HP13mtmp HP9P10P13Mtmp Hincl); apply HT.
}
try clear HP1P2P3P13m;assert(HP1P2P3P13m : rk(P1 :: P2 :: P3 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P13m;assert(HP1P2P3P13m : rk(P1 :: P2 :: P3 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P13 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P13M;assert(HP1P2P3P13M : rk(P1 :: P2 :: P3 :: P13 :: nil) <= 3).
{
try assert(HP1P2P3P5P6P13Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P5P6P13eq HP1P2P3P5P6P13M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P13 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P1 :: P2 :: P3 :: P13 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) 3 3 HP1P2P3P5P6P13Mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P12M;assert(HP1P3P8P12M : rk(P1 :: P3 :: P8 :: P12 :: nil) <= 3).
{
try assert(HP3Mtmp : rk(P3 :: nil) <= 1) by (solve_hyps_max HP3eq HP3M).
try assert(HP1P8P12Mtmp : rk(P1 :: P8 :: P12 :: nil) <= 2) by (solve_hyps_max HP1P8P12eq HP1P8P12M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P3 :: nil) (P1 :: P8 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P8 :: P12 :: nil) (P3 :: P1 :: P8 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P1 :: P8 :: P12 :: nil) ((P3 :: nil) ++ (P1 :: P8 :: P12 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P3 :: nil) (P1 :: P8 :: P12 :: nil) (nil) 1 2 0 HP3Mtmp HP1P8P12Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P3P8P12m;assert(HP1P3P8P12m : rk(P1 :: P3 :: P8 :: P12 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: P12 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P12m;assert(HP1P3P8P12m : rk(P1 :: P3 :: P8 :: P12 :: nil) >= 3).
{
try assert(HP1P3P12mtmp : rk(P1 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P3P12eq HP1P3P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: P12 :: nil) (P1 :: P3 :: P8 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: P12 :: nil) (P1 :: P3 :: P8 :: P12 :: nil) 3 3 HP1P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8m;assert(HP1P3P8m : rk(P1 :: P3 :: P8 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8m;assert(HP1P3P8m : rk(P1 :: P3 :: P8 :: nil) >= 3).
{
try assert(HP1P8P12Mtmp : rk(P1 :: P8 :: P12 :: nil) <= 2) by (solve_hyps_max HP1P8P12eq HP1P8P12M).
try assert(HP1P3P8P12mtmp : rk(P1 :: P3 :: P8 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P3P8P12eq HP1P3P8P12m).
try assert(HP1P8mtmp : rk(P1 :: P8 :: nil) >= 2) by (solve_hyps_min HP1P8eq HP1P8m).
assert(Hincl : incl (P1 :: P8 :: nil) (list_inter (P1 :: P3 :: P8 :: nil) (P1 :: P8 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P8 :: P12 :: nil) (P1 :: P3 :: P8 :: P1 :: P8 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P3 :: P8 :: P1 :: P8 :: P12 :: nil) ((P1 :: P3 :: P8 :: nil) ++ (P1 :: P8 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P3P8P12mtmp;try rewrite HT2 in HP1P3P8P12mtmp.
assert(HT := rule_2 (P1 :: P3 :: P8 :: nil) (P1 :: P8 :: P12 :: nil) (P1 :: P8 :: nil) 3 2 2 HP1P3P8P12mtmp HP1P8mtmp HP1P8P12Mtmp Hincl); apply HT.
}
try clear HP1P3P8P13P14P15m;assert(HP1P3P8P13P14P15m : rk(P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P13P14P15m;assert(HP1P3P8P13P14P15m : rk(P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP1P3P8mtmp : rk(P1 :: P3 :: P8 :: nil) >= 3) by (solve_hyps_min HP1P3P8eq HP1P3P8m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: P8 :: nil) (P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: P8 :: nil) (P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) 3 3 HP1P3P8mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P13P14P15m;assert(HP1P3P8P13P14P15m : rk(P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) >= 4).
{
try assert(HP1P2P3P13Mtmp : rk(P1 :: P2 :: P3 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P13eq HP1P2P3P13M).
try assert(HP1P2P3P8P13P14P15mtmp : rk(P1 :: P2 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8P13P14P15eq HP1P2P3P8P13P14P15m).
try assert(HP1P3P13mtmp : rk(P1 :: P3 :: P13 :: nil) >= 3) by (solve_hyps_min HP1P3P13eq HP1P3P13m).
assert(Hincl : incl (P1 :: P3 :: P13 :: nil) (list_inter (P1 :: P2 :: P3 :: P13 :: nil) (P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) (P1 :: P2 :: P3 :: P13 :: P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P13 :: P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) ((P1 :: P2 :: P3 :: P13 :: nil) ++ (P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P8P13P14P15mtmp;try rewrite HT2 in HP1P2P3P8P13P14P15mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P13 :: nil) (P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) (P1 :: P3 :: P13 :: nil) 4 3 3 HP1P2P3P8P13P14P15mtmp HP1P3P13mtmp HP1P2P3P13Mtmp Hincl); apply HT.
}
try clear HP1P2P3P8P9P10P12P13P14m;assert(HP1P2P3P8P9P10P12P13P14m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P9P10P12P13P14m;assert(HP1P2P3P8P9P10P12P13P14m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P9P10P12P13P14m;assert(HP1P2P3P8P9P10P12P13P14m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) >= 4).
{
try assert(HP1P2P3P12mtmp : rk(P1 :: P2 :: P3 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P12eq HP1P2P3P12m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) 4 4 HP1P2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P9P10P12P13P14m;assert(HP1P3P8P9P10P12P13P14m : rk(P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P9P10P12P13P14m;assert(HP1P3P8P9P10P12P13P14m : rk(P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP1P3P12mtmp : rk(P1 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P3P12eq HP1P3P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: P12 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: P12 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) 3 3 HP1P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P9P10P12P13P14m;assert(HP1P3P8P9P10P12P13P14m : rk(P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) >= 4).
{
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(HP1P2P3P8P9P10P12P13P14mtmp : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8P9P10P12P13P14eq HP1P2P3P8P9P10P12P13P14m).
try assert(HP9P12mtmp : rk(P9 :: P12 :: nil) >= 2) by (solve_hyps_min HP9P12eq HP9P12m).
assert(Hincl : incl (P9 :: P12 :: nil) (list_inter (P2 :: P9 :: P12 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) (P2 :: P9 :: P12 :: P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P9 :: P12 :: P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) ((P2 :: P9 :: P12 :: nil) ++ (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P8P9P10P12P13P14mtmp;try rewrite HT2 in HP1P2P3P8P9P10P12P13P14mtmp.
assert(HT := rule_4 (P2 :: P9 :: P12 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) (P9 :: P12 :: nil) 4 2 2 HP1P2P3P8P9P10P12P13P14mtmp HP9P12mtmp HP2P9P12Mtmp Hincl); apply HT.
}
try clear HP1P2P3P6P7P11P12m;assert(HP1P2P3P6P7P11P12m : rk(P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P6P7P11P12m;assert(HP1P2P3P6P7P11P12m : rk(P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: P12 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P6P7P11P12m;assert(HP1P2P3P6P7P11P12m : rk(P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: P12 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: P12 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP3P6P7P11P12m;assert(HP3P6P7P11P12m : rk(P3 :: P6 :: P7 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP3P6mtmp : rk(P3 :: P6 :: nil) >= 2) by (solve_hyps_min HP3P6eq HP3P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P3 :: P6 :: nil) (P3 :: P6 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P3 :: P6 :: nil) (P3 :: P6 :: P7 :: P11 :: P12 :: nil) 2 2 HP3P6mtmp Hcomp Hincl); apply HT.
}
try clear HP3P6P7P11P12M;assert(HP3P6P7P11P12M : rk(P3 :: P6 :: P7 :: P11 :: P12 :: nil) <= 3).
{
try assert(HP3P6P7Mtmp : rk(P3 :: P6 :: P7 :: nil) <= 2) by (solve_hyps_max HP3P6P7eq HP3P6P7M).
try assert(HP7P11P12Mtmp : rk(P7 :: P11 :: P12 :: nil) <= 2) by (solve_hyps_max HP7P11P12eq HP7P11P12M).
try assert(HP7mtmp : rk(P7 :: nil) >= 1) by (solve_hyps_min HP7eq HP7m).
assert(Hincl : incl (P7 :: nil) (list_inter (P3 :: P6 :: P7 :: nil) (P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P3 :: P6 :: P7 :: P11 :: P12 :: nil) (P3 :: P6 :: P7 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P6 :: P7 :: P7 :: P11 :: P12 :: nil) ((P3 :: P6 :: P7 :: nil) ++ (P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P3 :: P6 :: P7 :: nil) (P7 :: P11 :: P12 :: nil) (P7 :: nil) 2 2 1 HP3P6P7Mtmp HP7P11P12Mtmp HP7mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP3P6P7P11P12m;assert(HP3P6P7P11P12m : rk(P3 :: P6 :: P7 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3P6P11Mtmp : rk(P1 :: P2 :: P3 :: P6 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P6P11eq HP1P2P3P6P11M).
try assert(HP1P2P3P6P7P11P12mtmp : rk(P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P6P7P11P12eq HP1P2P3P6P7P11P12m).
try assert(HP3P6P11mtmp : rk(P3 :: P6 :: P11 :: nil) >= 3) by (solve_hyps_min HP3P6P11eq HP3P6P11m).
assert(Hincl : incl (P3 :: P6 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P6 :: P11 :: nil) (P3 :: P6 :: P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: P12 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: P3 :: P6 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P6 :: P11 :: P3 :: P6 :: P7 :: P11 :: P12 :: nil) ((P1 :: P2 :: P3 :: P6 :: P11 :: nil) ++ (P3 :: P6 :: P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P6P7P11P12mtmp;try rewrite HT2 in HP1P2P3P6P7P11P12mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P6 :: P11 :: nil) (P3 :: P6 :: P7 :: P11 :: P12 :: nil) (P3 :: P6 :: P11 :: nil) 4 3 4 HP1P2P3P6P7P11P12mtmp HP3P6P11mtmp HP1P2P3P6P11Mtmp Hincl); apply HT.
}
try clear HP1P3P5P6P7P11P13m;assert(HP1P3P5P6P7P11P13m : rk(P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P5P6P7P11P13m;assert(HP1P3P5P6P7P11P13m : rk(P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) >= 3).
{
try assert(HP2P5P7Mtmp : rk(P2 :: P5 :: P7 :: nil) <= 2) by (solve_hyps_max HP2P5P7eq HP2P5P7M).
try assert(HP1P2P3P5P6P7P11P13mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) >= 3) by (solve_hyps_min HP1P2P3P5P6P7P11P13eq HP1P2P3P5P6P7P11P13m).
try assert(HP5P7mtmp : rk(P5 :: P7 :: nil) >= 2) by (solve_hyps_min HP5P7eq HP5P7m).
assert(Hincl : incl (P5 :: P7 :: nil) (list_inter (P2 :: P5 :: P7 :: nil) (P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) (P2 :: P5 :: P7 :: P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P5 :: P7 :: P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) ((P2 :: P5 :: P7 :: nil) ++ (P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P6P7P11P13mtmp;try rewrite HT2 in HP1P2P3P5P6P7P11P13mtmp.
assert(HT := rule_4 (P2 :: P5 :: P7 :: nil) (P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) (P5 :: P7 :: nil) 3 2 2 HP1P2P3P5P6P7P11P13mtmp HP5P7mtmp HP2P5P7Mtmp Hincl); apply HT.
}
try clear HP1P3P5P6P7P11P13m;assert(HP1P3P5P6P7P11P13m : rk(P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) >= 4).
{
try assert(HP2P5P7P11Mtmp : rk(P2 :: P5 :: P7 :: P11 :: nil) <= 3) by (solve_hyps_max HP2P5P7P11eq HP2P5P7P11M).
try assert(HP1P2P3P5P6P7P11P13mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P5P6P7P11P13eq HP1P2P3P5P6P7P11P13m).
try assert(HP5P7P11mtmp : rk(P5 :: P7 :: P11 :: nil) >= 3) by (solve_hyps_min HP5P7P11eq HP5P7P11m).
assert(Hincl : incl (P5 :: P7 :: P11 :: nil) (list_inter (P2 :: P5 :: P7 :: P11 :: nil) (P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) (P2 :: P5 :: P7 :: P11 :: P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P5 :: P7 :: P11 :: P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) ((P2 :: P5 :: P7 :: P11 :: nil) ++ (P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P6P7P11P13mtmp;try rewrite HT2 in HP1P2P3P5P6P7P11P13mtmp.
assert(HT := rule_4 (P2 :: P5 :: P7 :: P11 :: nil) (P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) (P5 :: P7 :: P11 :: nil) 4 3 3 HP1P2P3P5P6P7P11P13mtmp HP5P7P11mtmp HP2P5P7P11Mtmp Hincl); apply HT.
}
try clear HP1P3P5P6m;assert(HP1P3P5P6m : rk(P1 :: P3 :: P5 :: P6 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P5 :: P6 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P5 :: P6 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P5P6M;assert(HP1P3P5P6M : rk(P1 :: P3 :: P5 :: P6 :: nil) <= 3).
{
try assert(HP1P2P3P4P5P6P7Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) <= 3) by (solve_hyps_max HP1P2P3P4P5P6P7eq HP1P2P3P4P5P6P7M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: P5 :: P6 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P1 :: P3 :: P5 :: P6 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) 3 3 HP1P2P3P4P5P6P7Mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P5P6P13m;assert(HP1P3P5P6P13m : rk(P1 :: P3 :: P5 :: P6 :: P13 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P5 :: P6 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P5 :: P6 :: P13 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P5P6P13M;assert(HP1P3P5P6P13M : rk(P1 :: P3 :: P5 :: P6 :: P13 :: nil) <= 3).
{
try assert(HP1P3P5P6Mtmp : rk(P1 :: P3 :: P5 :: P6 :: nil) <= 3) by (solve_hyps_max HP1P3P5P6eq HP1P3P5P6M).
try assert(HP5P6P13Mtmp : rk(P5 :: P6 :: P13 :: nil) <= 2) by (solve_hyps_max HP5P6P13eq HP5P6P13M).
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hincl : incl (P5 :: P6 :: nil) (list_inter (P1 :: P3 :: P5 :: P6 :: nil) (P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P5 :: P6 :: P13 :: nil) (P1 :: P3 :: P5 :: P6 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P3 :: P5 :: P6 :: P5 :: P6 :: P13 :: nil) ((P1 :: P3 :: P5 :: P6 :: nil) ++ (P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: P3 :: P5 :: P6 :: nil) (P5 :: P6 :: P13 :: nil) (P5 :: P6 :: nil) 3 2 2 HP1P3P5P6Mtmp HP5P6P13Mtmp HP5P6mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P3P5P6P7P13m;assert(HP1P3P5P6P7P13m : rk(P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P5P6P7P13m;assert(HP1P3P5P6P7P13m : rk(P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) >= 3).
{
try assert(HP2P5P7Mtmp : rk(P2 :: P5 :: P7 :: nil) <= 2) by (solve_hyps_max HP2P5P7eq HP2P5P7M).
try assert(HP1P2P3P5P6P7P13mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) >= 3) by (solve_hyps_min HP1P2P3P5P6P7P13eq HP1P2P3P5P6P7P13m).
try assert(HP5P7mtmp : rk(P5 :: P7 :: nil) >= 2) by (solve_hyps_min HP5P7eq HP5P7m).
assert(Hincl : incl (P5 :: P7 :: nil) (list_inter (P2 :: P5 :: P7 :: nil) (P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) (P2 :: P5 :: P7 :: P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P5 :: P7 :: P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) ((P2 :: P5 :: P7 :: nil) ++ (P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P6P7P13mtmp;try rewrite HT2 in HP1P2P3P5P6P7P13mtmp.
assert(HT := rule_4 (P2 :: P5 :: P7 :: nil) (P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) (P5 :: P7 :: nil) 3 2 2 HP1P2P3P5P6P7P13mtmp HP5P7mtmp HP2P5P7Mtmp Hincl); apply HT.
}
try clear HP1P3P5P6P7P13M;assert(HP1P3P5P6P7P13M : rk(P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) <= 3).
{
try assert(HP3P6P7Mtmp : rk(P3 :: P6 :: P7 :: nil) <= 2) by (solve_hyps_max HP3P6P7eq HP3P6P7M).
try assert(HP1P3P5P6P13Mtmp : rk(P1 :: P3 :: P5 :: P6 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P3P5P6P13eq HP1P3P5P6P13M).
try assert(HP3P6mtmp : rk(P3 :: P6 :: nil) >= 2) by (solve_hyps_min HP3P6eq HP3P6m).
assert(Hincl : incl (P3 :: P6 :: nil) (list_inter (P3 :: P6 :: P7 :: nil) (P1 :: P3 :: P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) (P3 :: P6 :: P7 :: P1 :: P3 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P6 :: P7 :: P1 :: P3 :: P5 :: P6 :: P13 :: nil) ((P3 :: P6 :: P7 :: nil) ++ (P1 :: P3 :: P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P3 :: P6 :: P7 :: nil) (P1 :: P3 :: P5 :: P6 :: P13 :: nil) (P3 :: P6 :: nil) 2 3 2 HP3P6P7Mtmp HP1P3P5P6P13Mtmp HP3P6mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP6P7P11m;assert(HP6P7P11m : rk(P6 :: P7 :: P11 :: nil) >= 2).
{
try assert(HP6P7mtmp : rk(P6 :: P7 :: nil) >= 2) by (solve_hyps_min HP6P7eq HP6P7m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P6 :: P7 :: nil) (P6 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P6 :: P7 :: nil) (P6 :: P7 :: P11 :: nil) 2 2 HP6P7mtmp Hcomp Hincl); apply HT.
}
try clear HP6P7P11m;assert(HP6P7P11m : rk(P6 :: P7 :: P11 :: nil) >= 3).
{
try assert(HP1P3P5P6P7P13Mtmp : rk(P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P3P5P6P7P13eq HP1P3P5P6P7P13M).
try assert(HP1P3P5P6P7P11P13mtmp : rk(P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P3P5P6P7P11P13eq HP1P3P5P6P7P11P13m).
try assert(HP6P7mtmp : rk(P6 :: P7 :: nil) >= 2) by (solve_hyps_min HP6P7eq HP6P7m).
assert(Hincl : incl (P6 :: P7 :: nil) (list_inter (P6 :: P7 :: P11 :: nil) (P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) (P6 :: P7 :: P11 :: P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P6 :: P7 :: P11 :: P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) ((P6 :: P7 :: P11 :: nil) ++ (P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P3P5P6P7P11P13mtmp;try rewrite HT2 in HP1P3P5P6P7P11P13mtmp.
assert(HT := rule_2 (P6 :: P7 :: P11 :: nil) (P1 :: P3 :: P5 :: P6 :: P7 :: P13 :: nil) (P6 :: P7 :: nil) 4 2 3 HP1P3P5P6P7P11P13mtmp HP6P7mtmp HP1P3P5P6P7P13Mtmp Hincl); apply HT.
}
try clear HP1P2P3P6P7P11m;assert(HP1P2P3P6P7P11m : rk(P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P6P7P11m;assert(HP1P2P3P6P7P11m : rk(P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P6P7P11m;assert(HP1P2P3P6P7P11m : rk(P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP3P6P7P11m;assert(HP3P6P7P11m : rk(P3 :: P6 :: P7 :: P11 :: nil) >= 2).
{
try assert(HP3P6mtmp : rk(P3 :: P6 :: nil) >= 2) by (solve_hyps_min HP3P6eq HP3P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P3 :: P6 :: nil) (P3 :: P6 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P3 :: P6 :: nil) (P3 :: P6 :: P7 :: P11 :: nil) 2 2 HP3P6mtmp Hcomp Hincl); apply HT.
}
try clear HP3P6P7P11M;assert(HP3P6P7P11M : rk(P3 :: P6 :: P7 :: P11 :: nil) <= 3).
{
try assert(HP3P6P7Mtmp : rk(P3 :: P6 :: P7 :: nil) <= 2) by (solve_hyps_max HP3P6P7eq HP3P6P7M).
try assert(HP11Mtmp : rk(P11 :: nil) <= 1) by (solve_hyps_max HP11eq HP11M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P3 :: P6 :: P7 :: nil) (P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P3 :: P6 :: P7 :: P11 :: nil) (P3 :: P6 :: P7 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P6 :: P7 :: P11 :: nil) ((P3 :: P6 :: P7 :: nil) ++ (P11 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P3 :: P6 :: P7 :: nil) (P11 :: nil) (nil) 2 1 0 HP3P6P7Mtmp HP11Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP3P6P7P11m;assert(HP3P6P7P11m : rk(P3 :: P6 :: P7 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3P6P11Mtmp : rk(P1 :: P2 :: P3 :: P6 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P6P11eq HP1P2P3P6P11M).
try assert(HP1P2P3P6P7P11mtmp : rk(P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P6P7P11eq HP1P2P3P6P7P11m).
try assert(HP3P6P11mtmp : rk(P3 :: P6 :: P11 :: nil) >= 3) by (solve_hyps_min HP3P6P11eq HP3P6P11m).
assert(Hincl : incl (P3 :: P6 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P6 :: P11 :: nil) (P3 :: P6 :: P7 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: P3 :: P6 :: P7 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P6 :: P11 :: P3 :: P6 :: P7 :: P11 :: nil) ((P1 :: P2 :: P3 :: P6 :: P11 :: nil) ++ (P3 :: P6 :: P7 :: P11 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P6P7P11mtmp;try rewrite HT2 in HP1P2P3P6P7P11mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P6 :: P11 :: nil) (P3 :: P6 :: P7 :: P11 :: nil) (P3 :: P6 :: P11 :: nil) 4 3 4 HP1P2P3P6P7P11mtmp HP3P6P11mtmp HP1P2P3P6P11Mtmp Hincl); apply HT.
}
try clear HP6P7P11P12M;assert(HP6P7P11P12M : rk(P6 :: P7 :: P11 :: P12 :: nil) <= 3).
{
try assert(HP6Mtmp : rk(P6 :: nil) <= 1) by (solve_hyps_max HP6eq HP6M).
try assert(HP7P11P12Mtmp : rk(P7 :: P11 :: P12 :: nil) <= 2) by (solve_hyps_max HP7P11P12eq HP7P11P12M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P6 :: nil) (P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P6 :: P7 :: P11 :: P12 :: nil) (P6 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P6 :: P7 :: P11 :: P12 :: nil) ((P6 :: nil) ++ (P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P6 :: nil) (P7 :: P11 :: P12 :: nil) (nil) 1 2 0 HP6Mtmp HP7P11P12Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP6P7P11P12m;assert(HP6P7P11P12m : rk(P6 :: P7 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP6P7mtmp : rk(P6 :: P7 :: nil) >= 2) by (solve_hyps_min HP6P7eq HP6P7m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P6 :: P7 :: nil) (P6 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P6 :: P7 :: nil) (P6 :: P7 :: P11 :: P12 :: nil) 2 2 HP6P7mtmp Hcomp Hincl); apply HT.
}
try clear HP6P7P11P12m;assert(HP6P7P11P12m : rk(P6 :: P7 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP3P6P7P11Mtmp : rk(P3 :: P6 :: P7 :: P11 :: nil) <= 3) by (solve_hyps_max HP3P6P7P11eq HP3P6P7P11M).
try assert(HP3P6P7P11P12mtmp : rk(P3 :: P6 :: P7 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP3P6P7P11P12eq HP3P6P7P11P12m).
try assert(HP6P7P11mtmp : rk(P6 :: P7 :: P11 :: nil) >= 3) by (solve_hyps_min HP6P7P11eq HP6P7P11m).
assert(Hincl : incl (P6 :: P7 :: P11 :: nil) (list_inter (P3 :: P6 :: P7 :: P11 :: nil) (P6 :: P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P3 :: P6 :: P7 :: P11 :: P12 :: nil) (P3 :: P6 :: P7 :: P11 :: P6 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P6 :: P7 :: P11 :: P6 :: P7 :: P11 :: P12 :: nil) ((P3 :: P6 :: P7 :: P11 :: nil) ++ (P6 :: P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP3P6P7P11P12mtmp;try rewrite HT2 in HP3P6P7P11P12mtmp.
assert(HT := rule_4 (P3 :: P6 :: P7 :: P11 :: nil) (P6 :: P7 :: P11 :: P12 :: nil) (P6 :: P7 :: P11 :: nil) 3 3 3 HP3P6P7P11P12mtmp HP6P7P11mtmp HP3P6P7P11Mtmp Hincl); apply HT.
}
try clear HP1P2P3P6P11P12m;assert(HP1P2P3P6P11P12m : rk(P1 :: P2 :: P3 :: P6 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P6P11P12m;assert(HP1P2P3P6P11P12m : rk(P1 :: P2 :: P3 :: P6 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: P12 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P6P11P12m;assert(HP1P2P3P6P11P12m : rk(P1 :: P2 :: P3 :: P6 :: P11 :: P12 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: P12 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP6P11m;assert(HP6P11m : rk(P6 :: P11 :: nil) >= 2).
{
try assert(HP1P2P3P5P6P13Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P5P6P13eq HP1P2P3P5P6P13M).
try assert(HP1P2P3P5P6P11P13mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P5P6P11P13eq HP1P2P3P5P6P11P13m).
try assert(HP6mtmp : rk(P6 :: nil) >= 1) by (solve_hyps_min HP6eq HP6m).
assert(Hincl : incl (P6 :: nil) (list_inter (P6 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) (P6 :: P11 :: P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P6 :: P11 :: P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) ((P6 :: P11 :: nil) ++ (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P6P11P13mtmp;try rewrite HT2 in HP1P2P3P5P6P11P13mtmp.
assert(HT := rule_2 (P6 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) (P6 :: nil) 4 1 3 HP1P2P3P5P6P11P13mtmp HP6mtmp HP1P2P3P5P6P13Mtmp Hincl); apply HT.
}
try clear HP6P11P12m;assert(HP6P11P12m : rk(P6 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2P3P6P11Mtmp : rk(P1 :: P2 :: P3 :: P6 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P6P11eq HP1P2P3P6P11M).
try assert(HP1P2P3P6P11P12mtmp : rk(P1 :: P2 :: P3 :: P6 :: P11 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P6P11P12eq HP1P2P3P6P11P12m).
try assert(HP6P11mtmp : rk(P6 :: P11 :: nil) >= 2) by (solve_hyps_min HP6P11eq HP6P11m).
assert(Hincl : incl (P6 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P6 :: P11 :: nil) (P6 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P6 :: P11 :: P12 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: P6 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P6 :: P11 :: P6 :: P11 :: P12 :: nil) ((P1 :: P2 :: P3 :: P6 :: P11 :: nil) ++ (P6 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P6P11P12mtmp;try rewrite HT2 in HP1P2P3P6P11P12mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P6 :: P11 :: nil) (P6 :: P11 :: P12 :: nil) (P6 :: P11 :: nil) 4 2 4 HP1P2P3P6P11P12mtmp HP6P11mtmp HP1P2P3P6P11Mtmp Hincl); apply HT.
}
try clear HP6P11P12m;assert(HP6P11P12m : rk(P6 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP7P11P12Mtmp : rk(P7 :: P11 :: P12 :: nil) <= 2) by (solve_hyps_max HP7P11P12eq HP7P11P12M).
try assert(HP6P7P11P12mtmp : rk(P6 :: P7 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP6P7P11P12eq HP6P7P11P12m).
try assert(HP11P12mtmp : rk(P11 :: P12 :: nil) >= 2) by (solve_hyps_min HP11P12eq HP11P12m).
assert(Hincl : incl (P11 :: P12 :: nil) (list_inter (P6 :: P11 :: P12 :: nil) (P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P6 :: P7 :: P11 :: P12 :: nil) (P6 :: P11 :: P12 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P6 :: P11 :: P12 :: P7 :: P11 :: P12 :: nil) ((P6 :: P11 :: P12 :: nil) ++ (P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP6P7P11P12mtmp;try rewrite HT2 in HP6P7P11P12mtmp.
assert(HT := rule_2 (P6 :: P11 :: P12 :: nil) (P7 :: P11 :: P12 :: nil) (P11 :: P12 :: nil) 3 2 2 HP6P7P11P12mtmp HP11P12mtmp HP7P11P12Mtmp Hincl); apply HT.
}
try clear HP1P2P3P6P10P11P12m;assert(HP1P2P3P6P10P11P12m : rk(P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P6P10P11P12m;assert(HP1P2P3P6P10P11P12m : rk(P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: P12 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P6P10P11P12m;assert(HP1P2P3P6P10P11P12m : rk(P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: P12 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: P12 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP6P10P11P12m;assert(HP6P10P11P12m : rk(P6 :: P10 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2P3P6P11Mtmp : rk(P1 :: P2 :: P3 :: P6 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P6P11eq HP1P2P3P6P11M).
try assert(HP1P2P3P6P10P11P12mtmp : rk(P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P6P10P11P12eq HP1P2P3P6P10P11P12m).
try assert(HP6P11mtmp : rk(P6 :: P11 :: nil) >= 2) by (solve_hyps_min HP6P11eq HP6P11m).
assert(Hincl : incl (P6 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P6 :: P11 :: nil) (P6 :: P10 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P6 :: P10 :: P11 :: P12 :: nil) (P1 :: P2 :: P3 :: P6 :: P11 :: P6 :: P10 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P6 :: P11 :: P6 :: P10 :: P11 :: P12 :: nil) ((P1 :: P2 :: P3 :: P6 :: P11 :: nil) ++ (P6 :: P10 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P6P10P11P12mtmp;try rewrite HT2 in HP1P2P3P6P10P11P12mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P6 :: P11 :: nil) (P6 :: P10 :: P11 :: P12 :: nil) (P6 :: P11 :: nil) 4 2 4 HP1P2P3P6P10P11P12mtmp HP6P11mtmp HP1P2P3P6P11Mtmp Hincl); apply HT.
}
try clear HP6P10P11P12M;assert(HP6P10P11P12M : rk(P6 :: P10 :: P11 :: P12 :: nil) <= 3).
{
try assert(HP6P10P11Mtmp : rk(P6 :: P10 :: P11 :: nil) <= 2) by (solve_hyps_max HP6P10P11eq HP6P10P11M).
try assert(HP12Mtmp : rk(P12 :: nil) <= 1) by (solve_hyps_max HP12eq HP12M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P6 :: P10 :: P11 :: nil) (P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P6 :: P10 :: P11 :: P12 :: nil) (P6 :: P10 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P6 :: P10 :: P11 :: P12 :: nil) ((P6 :: P10 :: P11 :: nil) ++ (P12 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P6 :: P10 :: P11 :: nil) (P12 :: nil) (nil) 2 1 0 HP6P10P11Mtmp HP12Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP6P10P11P12m;assert(HP6P10P11P12m : rk(P6 :: P10 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP6P11P12mtmp : rk(P6 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP6P11P12eq HP6P11P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P6 :: P11 :: P12 :: nil) (P6 :: P10 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P6 :: P11 :: P12 :: nil) (P6 :: P10 :: P11 :: P12 :: nil) 3 3 HP6P11P12mtmp Hcomp Hincl); apply HT.
}
try clear HP10P12m;assert(HP10P12m : rk(P10 :: P12 :: nil) >= 2).
{
try assert(HP6P10P11Mtmp : rk(P6 :: P10 :: P11 :: nil) <= 2) by (solve_hyps_max HP6P10P11eq HP6P10P11M).
try assert(HP6P10P11P12mtmp : rk(P6 :: P10 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP6P10P11P12eq HP6P10P11P12m).
try assert(HP10mtmp : rk(P10 :: nil) >= 1) by (solve_hyps_min HP10eq HP10m).
assert(Hincl : incl (P10 :: nil) (list_inter (P6 :: P10 :: P11 :: nil) (P10 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P6 :: P10 :: P11 :: P12 :: nil) (P6 :: P10 :: P11 :: P10 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P6 :: P10 :: P11 :: P10 :: P12 :: nil) ((P6 :: P10 :: P11 :: nil) ++ (P10 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP6P10P11P12mtmp;try rewrite HT2 in HP6P10P11P12mtmp.
assert(HT := rule_4 (P6 :: P10 :: P11 :: nil) (P10 :: P12 :: nil) (P10 :: nil) 3 1 2 HP6P10P11P12mtmp HP10mtmp HP6P10P11Mtmp Hincl); apply HT.
}
try clear HP1P2P3P6P7m;assert(HP1P2P3P6P7m : rk(P1 :: P2 :: P3 :: P6 :: P7 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P6P7m;assert(HP1P2P3P6P7m : rk(P1 :: P2 :: P3 :: P6 :: P7 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P6 :: P7 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P6P7m;assert(HP1P2P6P7m : rk(P1 :: P2 :: P6 :: P7 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P6 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P6 :: P7 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P6P7m;assert(HP1P2P6P7m : rk(P1 :: P2 :: P6 :: P7 :: nil) >= 3).
{
try assert(HP3P6P7Mtmp : rk(P3 :: P6 :: P7 :: nil) <= 2) by (solve_hyps_max HP3P6P7eq HP3P6P7M).
try assert(HP1P2P3P6P7mtmp : rk(P1 :: P2 :: P3 :: P6 :: P7 :: nil) >= 3) by (solve_hyps_min HP1P2P3P6P7eq HP1P2P3P6P7m).
try assert(HP6P7mtmp : rk(P6 :: P7 :: nil) >= 2) by (solve_hyps_min HP6P7eq HP6P7m).
assert(Hincl : incl (P6 :: P7 :: nil) (list_inter (P1 :: P2 :: P6 :: P7 :: nil) (P3 :: P6 :: P7 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P6 :: P7 :: nil) (P1 :: P2 :: P6 :: P7 :: P3 :: P6 :: P7 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P6 :: P7 :: P3 :: P6 :: P7 :: nil) ((P1 :: P2 :: P6 :: P7 :: nil) ++ (P3 :: P6 :: P7 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P6P7mtmp;try rewrite HT2 in HP1P2P3P6P7mtmp.
assert(HT := rule_2 (P1 :: P2 :: P6 :: P7 :: nil) (P3 :: P6 :: P7 :: nil) (P6 :: P7 :: nil) 3 2 2 HP1P2P3P6P7mtmp HP6P7mtmp HP3P6P7Mtmp Hincl); apply HT.
}
try clear HP1P2P6P7M;assert(HP1P2P6P7M : rk(P1 :: P2 :: P6 :: P7 :: nil) <= 3).
{
try assert(HP1P2P3P4P5P6P7Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) <= 3) by (solve_hyps_max HP1P2P3P4P5P6P7eq HP1P2P3P4P5P6P7M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P6 :: P7 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P1 :: P2 :: P6 :: P7 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) 3 3 HP1P2P3P4P5P6P7Mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P6P7P11m;assert(HP1P2P6P7P11m : rk(P1 :: P2 :: P6 :: P7 :: P11 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P6 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P6 :: P7 :: P11 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P6P7P11m;assert(HP1P2P6P7P11m : rk(P1 :: P2 :: P6 :: P7 :: P11 :: nil) >= 3).
{
try assert(HP1P2P6P7mtmp : rk(P1 :: P2 :: P6 :: P7 :: nil) >= 3) by (solve_hyps_min HP1P2P6P7eq HP1P2P6P7m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P6 :: P7 :: nil) (P1 :: P2 :: P6 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P6 :: P7 :: nil) (P1 :: P2 :: P6 :: P7 :: P11 :: nil) 3 3 HP1P2P6P7mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P6P7P11m;assert(HP1P2P6P7P11m : rk(P1 :: P2 :: P6 :: P7 :: P11 :: nil) >= 4).
{
try assert(HP3P6P7P11Mtmp : rk(P3 :: P6 :: P7 :: P11 :: nil) <= 3) by (solve_hyps_max HP3P6P7P11eq HP3P6P7P11M).
try assert(HP1P2P3P6P7P11mtmp : rk(P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P6P7P11eq HP1P2P3P6P7P11m).
try assert(HP6P7P11mtmp : rk(P6 :: P7 :: P11 :: nil) >= 3) by (solve_hyps_min HP6P7P11eq HP6P7P11m).
assert(Hincl : incl (P6 :: P7 :: P11 :: nil) (list_inter (P1 :: P2 :: P6 :: P7 :: P11 :: nil) (P3 :: P6 :: P7 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P6 :: P7 :: P11 :: nil) (P1 :: P2 :: P6 :: P7 :: P11 :: P3 :: P6 :: P7 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P6 :: P7 :: P11 :: P3 :: P6 :: P7 :: P11 :: nil) ((P1 :: P2 :: P6 :: P7 :: P11 :: nil) ++ (P3 :: P6 :: P7 :: P11 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P6P7P11mtmp;try rewrite HT2 in HP1P2P3P6P7P11mtmp.
assert(HT := rule_2 (P1 :: P2 :: P6 :: P7 :: P11 :: nil) (P3 :: P6 :: P7 :: P11 :: nil) (P6 :: P7 :: P11 :: nil) 4 3 3 HP1P2P3P6P7P11mtmp HP6P7P11mtmp HP3P6P7P11Mtmp Hincl); apply HT.
}
try clear HP1P2P5P6P7P8P9P11m;assert(HP1P2P5P6P7P8P9P11m : rk(P1 :: P2 :: P5 :: P6 :: P7 :: P8 :: P9 :: P11 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P5 :: P6 :: P7 :: P8 :: P9 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P5 :: P6 :: P7 :: P8 :: P9 :: P11 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P5P6P7P8P9P11m;assert(HP1P2P5P6P7P8P9P11m : rk(P1 :: P2 :: P5 :: P6 :: P7 :: P8 :: P9 :: P11 :: nil) >= 3).
{
try assert(HP1P2P6P7mtmp : rk(P1 :: P2 :: P6 :: P7 :: nil) >= 3) by (solve_hyps_min HP1P2P6P7eq HP1P2P6P7m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P6 :: P7 :: nil) (P1 :: P2 :: P5 :: P6 :: P7 :: P8 :: P9 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P6 :: P7 :: nil) (P1 :: P2 :: P5 :: P6 :: P7 :: P8 :: P9 :: P11 :: nil) 3 3 HP1P2P6P7mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P5P6P7P8P9P11m;assert(HP1P2P5P6P7P8P9P11m : rk(P1 :: P2 :: P5 :: P6 :: P7 :: P8 :: P9 :: P11 :: nil) >= 4).
{
try assert(HP1P2P6P7P11mtmp : rk(P1 :: P2 :: P6 :: P7 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P6P7P11eq HP1P2P6P7P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P6 :: P7 :: P11 :: nil) (P1 :: P2 :: P5 :: P6 :: P7 :: P8 :: P9 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P6 :: P7 :: P11 :: nil) (P1 :: P2 :: P5 :: P6 :: P7 :: P8 :: P9 :: P11 :: nil) 4 4 HP1P2P6P7P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P7P9P11m;assert(HP1P2P3P5P7P9P11m : rk(P1 :: P2 :: P3 :: P5 :: P7 :: P9 :: P11 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P9 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P9 :: P11 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P7P9P11m;assert(HP1P2P3P5P7P9P11m : rk(P1 :: P2 :: P3 :: P5 :: P7 :: P9 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P9 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P9 :: P11 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P7P9P11m;assert(HP1P2P3P5P7P9P11m : rk(P1 :: P2 :: P3 :: P5 :: P7 :: P9 :: P11 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P9 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P7 :: P9 :: P11 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP2P5P7P9P11m;assert(HP2P5P7P9P11m : rk(P2 :: P5 :: P7 :: P9 :: P11 :: nil) >= 2).
{
try assert(HP2P5mtmp : rk(P2 :: P5 :: nil) >= 2) by (solve_hyps_min HP2P5eq HP2P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P5 :: nil) (P2 :: P5 :: P7 :: P9 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P5 :: nil) (P2 :: P5 :: P7 :: P9 :: P11 :: nil) 2 2 HP2P5mtmp Hcomp Hincl); apply HT.
}
try clear HP2P5P7P9P11M;assert(HP2P5P7P9P11M : rk(P2 :: P5 :: P7 :: P9 :: P11 :: nil) <= 3).
{
try assert(HP2P5P7Mtmp : rk(P2 :: P5 :: P7 :: nil) <= 2) by (solve_hyps_max HP2P5P7eq HP2P5P7M).
try assert(HP5P9P11Mtmp : rk(P5 :: P9 :: P11 :: nil) <= 2) by (solve_hyps_max HP5P9P11eq HP5P9P11M).
try assert(HP5mtmp : rk(P5 :: nil) >= 1) by (solve_hyps_min HP5eq HP5m).
assert(Hincl : incl (P5 :: nil) (list_inter (P2 :: P5 :: P7 :: nil) (P5 :: P9 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P5 :: P7 :: P9 :: P11 :: nil) (P2 :: P5 :: P7 :: P5 :: P9 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P5 :: P7 :: P5 :: P9 :: P11 :: nil) ((P2 :: P5 :: P7 :: nil) ++ (P5 :: P9 :: P11 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P2 :: P5 :: P7 :: nil) (P5 :: P9 :: P11 :: nil) (P5 :: nil) 2 2 1 HP2P5P7Mtmp HP5P9P11Mtmp HP5mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP2P5P7P9P11m;assert(HP2P5P7P9P11m : rk(P2 :: P5 :: P7 :: P9 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3P5P11Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P5P11eq HP1P2P3P5P11M).
try assert(HP1P2P3P5P7P9P11mtmp : rk(P1 :: P2 :: P3 :: P5 :: P7 :: P9 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P5P7P9P11eq HP1P2P3P5P7P9P11m).
try assert(HP2P5P11mtmp : rk(P2 :: P5 :: P11 :: nil) >= 3) by (solve_hyps_min HP2P5P11eq HP2P5P11m).
assert(Hincl : incl (P2 :: P5 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P5 :: P11 :: nil) (P2 :: P5 :: P7 :: P9 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P7 :: P9 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: P2 :: P5 :: P7 :: P9 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P5 :: P11 :: P2 :: P5 :: P7 :: P9 :: P11 :: nil) ((P1 :: P2 :: P3 :: P5 :: P11 :: nil) ++ (P2 :: P5 :: P7 :: P9 :: P11 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P7P9P11mtmp;try rewrite HT2 in HP1P2P3P5P7P9P11mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P5 :: P11 :: nil) (P2 :: P5 :: P7 :: P9 :: P11 :: nil) (P2 :: P5 :: P11 :: nil) 4 3 4 HP1P2P3P5P7P9P11mtmp HP2P5P11mtmp HP1P2P3P5P11Mtmp Hincl); apply HT.
}
try clear HP1P2P11m;assert(HP1P2P11m : rk(P1 :: P2 :: P11 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P11 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P11m;assert(HP1P2P11m : rk(P1 :: P2 :: P11 :: nil) >= 3).
{
try assert(HP3Mtmp : rk(P3 :: nil) <= 1) by (solve_hyps_max HP3eq HP3M).
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P3 :: nil) (P1 :: P2 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P11 :: nil) (P3 :: P1 :: P2 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P1 :: P2 :: P11 :: nil) ((P3 :: nil) ++ (P1 :: P2 :: P11 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P11mtmp;try rewrite HT2 in HP1P2P3P11mtmp.
assert(HT := rule_4 (P3 :: nil) (P1 :: P2 :: P11 :: nil) (nil) 4 0 1 HP1P2P3P11mtmp Hmtmp HP3Mtmp Hincl); apply HT.
}
try clear HP1P2P5P6P8P11m;assert(HP1P2P5P6P8P11m : rk(P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P5P6P8P11m;assert(HP1P2P5P6P8P11m : rk(P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil) >= 3).
{
try assert(HP1P2P11mtmp : rk(P1 :: P2 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P2P11eq HP1P2P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P11 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P11 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil) 3 3 HP1P2P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P5P6P8P11m;assert(HP1P2P5P6P8P11m : rk(P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil) >= 4).
{
try assert(HP2P5P7P9P11Mtmp : rk(P2 :: P5 :: P7 :: P9 :: P11 :: nil) <= 3) by (solve_hyps_max HP2P5P7P9P11eq HP2P5P7P9P11M).
try assert(HP1P2P5P6P7P8P9P11mtmp : rk(P1 :: P2 :: P5 :: P6 :: P7 :: P8 :: P9 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P5P6P7P8P9P11eq HP1P2P5P6P7P8P9P11m).
try assert(HP2P5P11mtmp : rk(P2 :: P5 :: P11 :: nil) >= 3) by (solve_hyps_min HP2P5P11eq HP2P5P11m).
assert(Hincl : incl (P2 :: P5 :: P11 :: nil) (list_inter (P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil) (P2 :: P5 :: P7 :: P9 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P5 :: P6 :: P7 :: P8 :: P9 :: P11 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: P2 :: P5 :: P7 :: P9 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: P2 :: P5 :: P7 :: P9 :: P11 :: nil) ((P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil) ++ (P2 :: P5 :: P7 :: P9 :: P11 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P5P6P7P8P9P11mtmp;try rewrite HT2 in HP1P2P5P6P7P8P9P11mtmp.
assert(HT := rule_2 (P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil) (P2 :: P5 :: P7 :: P9 :: P11 :: nil) (P2 :: P5 :: P11 :: nil) 4 3 3 HP1P2P5P6P7P8P9P11mtmp HP2P5P11mtmp HP2P5P7P9P11Mtmp Hincl); apply HT.
}
try clear HP1P2P5P6P8P9P10P11P12P13P14m;assert(HP1P2P5P6P8P9P10P11P12P13P14m : rk(P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P5P6P8P9P10P11P12P13P14m;assert(HP1P2P5P6P8P9P10P11P12P13P14m : rk(P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP1P2P11mtmp : rk(P1 :: P2 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P2P11eq HP1P2P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P11 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P11 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) 3 3 HP1P2P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P5P6P8P9P10P11P12P13P14m;assert(HP1P2P5P6P8P9P10P11P12P13P14m : rk(P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) >= 4).
{
try assert(HP1P2P5P6P8P11mtmp : rk(P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P5P6P8P11eq HP1P2P5P6P8P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) 4 4 HP1P2P5P6P8P11mtmp Hcomp Hincl); apply HT.
}
try clear HP2P5P11P12m;assert(HP2P5P11P12m : rk(P2 :: P5 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP2P5mtmp : rk(P2 :: P5 :: nil) >= 2) by (solve_hyps_min HP2P5eq HP2P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P5 :: nil) (P2 :: P5 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P5 :: nil) (P2 :: P5 :: P11 :: P12 :: nil) 2 2 HP2P5mtmp Hcomp Hincl); apply HT.
}
try clear HP2P5P11P12m;assert(HP2P5P11P12m : rk(P2 :: P5 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3P5P11Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P5P11eq HP1P2P3P5P11M).
try assert(HP1P2P3P5P11P12mtmp : rk(P1 :: P2 :: P3 :: P5 :: P11 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P5P11P12eq HP1P2P3P5P11P12m).
try assert(HP2P5P11mtmp : rk(P2 :: P5 :: P11 :: nil) >= 3) by (solve_hyps_min HP2P5P11eq HP2P5P11m).
assert(Hincl : incl (P2 :: P5 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P5 :: P11 :: nil) (P2 :: P5 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P11 :: P12 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: P2 :: P5 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P5 :: P11 :: P2 :: P5 :: P11 :: P12 :: nil) ((P1 :: P2 :: P3 :: P5 :: P11 :: nil) ++ (P2 :: P5 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P11P12mtmp;try rewrite HT2 in HP1P2P3P5P11P12mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P5 :: P11 :: nil) (P2 :: P5 :: P11 :: P12 :: nil) (P2 :: P5 :: P11 :: nil) 4 3 4 HP1P2P3P5P11P12mtmp HP2P5P11mtmp HP1P2P3P5P11Mtmp Hincl); apply HT.
}
try clear HP2P5P11P12M;assert(HP2P5P11P12M : rk(P2 :: P5 :: P11 :: P12 :: nil) <= 3).
{
try assert(HP2P5P7P11P12Mtmp : rk(P2 :: P5 :: P7 :: P11 :: P12 :: nil) <= 3) by (solve_hyps_max HP2P5P7P11P12eq HP2P5P7P11P12M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P2 :: P5 :: P11 :: P12 :: nil) (P2 :: P5 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P2 :: P5 :: P11 :: P12 :: nil) (P2 :: P5 :: P7 :: P11 :: P12 :: nil) 3 3 HP2P5P7P11P12Mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P11m;assert(HP5P6P11m : rk(P5 :: P6 :: P11 :: nil) >= 2).
{
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: nil) (P5 :: P6 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: nil) (P5 :: P6 :: P11 :: nil) 2 2 HP5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P11m;assert(HP5P6P11m : rk(P5 :: P6 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3P5P6P13Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P5P6P13eq HP1P2P3P5P6P13M).
try assert(HP1P2P3P5P6P11P13mtmp : rk(P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P5P6P11P13eq HP1P2P3P5P6P11P13m).
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hincl : incl (P5 :: P6 :: nil) (list_inter (P5 :: P6 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P6 :: P11 :: P13 :: nil) (P5 :: P6 :: P11 :: P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P6 :: P11 :: P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) ((P5 :: P6 :: P11 :: nil) ++ (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P6P11P13mtmp;try rewrite HT2 in HP1P2P3P5P6P11P13mtmp.
assert(HT := rule_2 (P5 :: P6 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P6 :: P13 :: nil) (P5 :: P6 :: nil) 4 2 3 HP1P2P3P5P6P11P13mtmp HP5P6mtmp HP1P2P3P5P6P13Mtmp Hincl); apply HT.
}
try clear HP1P5P6P8P9P10P11P12P13P14m;assert(HP1P5P6P8P9P10P11P12P13P14m : rk(P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: nil) (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: nil) (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) 2 2 HP5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP1P5P6P8P9P10P11P12P13P14m;assert(HP1P5P6P8P9P10P11P12P13P14m : rk(P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP5P6P11mtmp : rk(P5 :: P6 :: P11 :: nil) >= 3) by (solve_hyps_min HP5P6P11eq HP5P6P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: P11 :: nil) (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: P11 :: nil) (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) 3 3 HP5P6P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P5P6P8P9P10P11P12P13P14m;assert(HP1P5P6P8P9P10P11P12P13P14m : rk(P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) >= 4).
{
try assert(HP2P5P11P12Mtmp : rk(P2 :: P5 :: P11 :: P12 :: nil) <= 3) by (solve_hyps_max HP2P5P11P12eq HP2P5P11P12M).
try assert(HP1P2P5P6P8P9P10P11P12P13P14mtmp : rk(P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) >= 4) by (solve_hyps_min HP1P2P5P6P8P9P10P11P12P13P14eq HP1P2P5P6P8P9P10P11P12P13P14m).
try assert(HP5P11P12mtmp : rk(P5 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP5P11P12eq HP5P11P12m).
assert(Hincl : incl (P5 :: P11 :: P12 :: nil) (list_inter (P2 :: P5 :: P11 :: P12 :: nil) (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) (P2 :: P5 :: P11 :: P12 :: P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P5 :: P11 :: P12 :: P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) ((P2 :: P5 :: P11 :: P12 :: nil) ++ (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P5P6P8P9P10P11P12P13P14mtmp;try rewrite HT2 in HP1P2P5P6P8P9P10P11P12P13P14mtmp.
assert(HT := rule_4 (P2 :: P5 :: P11 :: P12 :: nil) (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) (P5 :: P11 :: P12 :: nil) 4 3 3 HP1P2P5P6P8P9P10P11P12P13P14mtmp HP5P11P12mtmp HP2P5P11P12Mtmp Hincl); apply HT.
}
try clear HP5P6P9P11P13m;assert(HP5P6P9P11P13m : rk(P5 :: P6 :: P9 :: P11 :: P13 :: nil) >= 2).
{
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: nil) (P5 :: P6 :: P9 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: nil) (P5 :: P6 :: P9 :: P11 :: P13 :: nil) 2 2 HP5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P9P11P13m;assert(HP5P6P9P11P13m : rk(P5 :: P6 :: P9 :: P11 :: P13 :: nil) >= 3).
{
try assert(HP5P6P11mtmp : rk(P5 :: P6 :: P11 :: nil) >= 3) by (solve_hyps_min HP5P6P11eq HP5P6P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: P11 :: nil) (P5 :: P6 :: P9 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: P11 :: nil) (P5 :: P6 :: P9 :: P11 :: P13 :: nil) 3 3 HP5P6P11mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P9P11P13M;assert(HP5P6P9P11P13M : rk(P5 :: P6 :: P9 :: P11 :: P13 :: nil) <= 3).
{
try assert(HP5P9P11Mtmp : rk(P5 :: P9 :: P11 :: nil) <= 2) by (solve_hyps_max HP5P9P11eq HP5P9P11M).
try assert(HP5P6P13Mtmp : rk(P5 :: P6 :: P13 :: nil) <= 2) by (solve_hyps_max HP5P6P13eq HP5P6P13M).
try assert(HP5mtmp : rk(P5 :: nil) >= 1) by (solve_hyps_min HP5eq HP5m).
assert(Hincl : incl (P5 :: nil) (list_inter (P5 :: P9 :: P11 :: nil) (P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P5 :: P6 :: P9 :: P11 :: P13 :: nil) (P5 :: P9 :: P11 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P9 :: P11 :: P5 :: P6 :: P13 :: nil) ((P5 :: P9 :: P11 :: nil) ++ (P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P5 :: P9 :: P11 :: nil) (P5 :: P6 :: P13 :: nil) (P5 :: nil) 2 2 1 HP5P9P11Mtmp HP5P6P13Mtmp HP5mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP5P6P9P10P11P13m;assert(HP5P6P9P10P11P13m : rk(P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil) >= 2).
{
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: nil) (P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: nil) (P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil) 2 2 HP5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P9P10P11P13m;assert(HP5P6P9P10P11P13m : rk(P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil) >= 3).
{
try assert(HP5P6P11mtmp : rk(P5 :: P6 :: P11 :: nil) >= 3) by (solve_hyps_min HP5P6P11eq HP5P6P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: P11 :: nil) (P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: P11 :: nil) (P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil) 3 3 HP5P6P11mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P9P10P11P13M;assert(HP5P6P9P10P11P13M : rk(P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil) <= 3).
{
try assert(HP6P10P11Mtmp : rk(P6 :: P10 :: P11 :: nil) <= 2) by (solve_hyps_max HP6P10P11eq HP6P10P11M).
try assert(HP5P6P9P11P13Mtmp : rk(P5 :: P6 :: P9 :: P11 :: P13 :: nil) <= 3) by (solve_hyps_max HP5P6P9P11P13eq HP5P6P9P11P13M).
try assert(HP6P11mtmp : rk(P6 :: P11 :: nil) >= 2) by (solve_hyps_min HP6P11eq HP6P11m).
assert(Hincl : incl (P6 :: P11 :: nil) (list_inter (P6 :: P10 :: P11 :: nil) (P5 :: P6 :: P9 :: P11 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil) (P6 :: P10 :: P11 :: P5 :: P6 :: P9 :: P11 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P6 :: P10 :: P11 :: P5 :: P6 :: P9 :: P11 :: P13 :: nil) ((P6 :: P10 :: P11 :: nil) ++ (P5 :: P6 :: P9 :: P11 :: P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P6 :: P10 :: P11 :: nil) (P5 :: P6 :: P9 :: P11 :: P13 :: nil) (P6 :: P11 :: nil) 2 3 2 HP6P10P11Mtmp HP5P6P9P11P13Mtmp HP6P11mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P4P8P9P10P11P12P13P14m;assert(HP1P4P8P9P10P11P12P13P14m : rk(P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P8P9P10P11P12P13P14m;assert(HP1P4P8P9P10P11P12P13P14m : rk(P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP1P4P11mtmp : rk(P1 :: P4 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P4P11eq HP1P4P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) 3 3 HP1P4P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P8P9P10P12P13P14m;assert(HP1P8P9P10P12P13P14m : rk(P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP1P4P8P9P10P11P12P13P14mtmp : rk(P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) >= 3) by (solve_hyps_min HP1P4P8P9P10P11P12P13P14eq HP1P4P8P9P10P11P12P13P14m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) (P4 :: P8 :: P11 :: P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P4P8P9P10P11P12P13P14mtmp;try rewrite HT2 in HP1P4P8P9P10P11P12P13P14mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) (P8 :: nil) 3 1 2 HP1P4P8P9P10P11P12P13P14mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP1P8P9P10P12P13P14m;assert(HP1P8P9P10P12P13P14m : rk(P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP5P6P9P10P11P13Mtmp : rk(P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil) <= 3) by (solve_hyps_max HP5P6P9P10P11P13eq HP5P6P9P10P11P13M).
try assert(HP1P5P6P8P9P10P11P12P13P14mtmp : rk(P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) >= 4) by (solve_hyps_min HP1P5P6P8P9P10P11P12P13P14eq HP1P5P6P8P9P10P11P12P13P14m).
try assert(HP9P10P13mtmp : rk(P9 :: P10 :: P13 :: nil) >= 2) by (solve_hyps_min HP9P10P13eq HP9P10P13m).
assert(Hincl : incl (P9 :: P10 :: P13 :: nil) (list_inter (P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil) (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) (P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) ((P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil) ++ (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P5P6P8P9P10P11P12P13P14mtmp;try rewrite HT2 in HP1P5P6P8P9P10P11P12P13P14mtmp.
assert(HT := rule_4 (P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil) (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) (P9 :: P10 :: P13 :: nil) 4 2 3 HP1P5P6P8P9P10P11P12P13P14mtmp HP9P10P13mtmp HP5P6P9P10P11P13Mtmp Hincl); apply HT.
}
try clear HP1P8P9P10P12P13P14m;assert(HP1P8P9P10P12P13P14m : rk(P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) >= 4).
{
try assert(HP3P10P12Mtmp : rk(P3 :: P10 :: P12 :: nil) <= 2) by (solve_hyps_max HP3P10P12eq HP3P10P12M).
try assert(HP1P3P8P9P10P12P13P14mtmp : rk(P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) >= 4) by (solve_hyps_min HP1P3P8P9P10P12P13P14eq HP1P3P8P9P10P12P13P14m).
try assert(HP10P12mtmp : rk(P10 :: P12 :: nil) >= 2) by (solve_hyps_min HP10P12eq HP10P12m).
assert(Hincl : incl (P10 :: P12 :: nil) (list_inter (P3 :: P10 :: P12 :: nil) (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) (P3 :: P10 :: P12 :: P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P10 :: P12 :: P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) ((P3 :: P10 :: P12 :: nil) ++ (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P3P8P9P10P12P13P14mtmp;try rewrite HT2 in HP1P3P8P9P10P12P13P14mtmp.
assert(HT := rule_4 (P3 :: P10 :: P12 :: nil) (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) (P10 :: P12 :: nil) 4 2 2 HP1P3P8P9P10P12P13P14mtmp HP10P12mtmp HP3P10P12Mtmp Hincl); apply HT.
}
try clear HP1P2P3P10P12m;assert(HP1P2P3P10P12m : rk(P1 :: P2 :: P3 :: P10 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P10 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P10 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P10P12m;assert(HP1P2P3P10P12m : rk(P1 :: P2 :: P3 :: P10 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P10 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P10 :: P12 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P10P12m;assert(HP1P2P3P10P12m : rk(P1 :: P2 :: P3 :: P10 :: P12 :: nil) >= 4).
{
try assert(HP1P2P3P12mtmp : rk(P1 :: P2 :: P3 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P12eq HP1P2P3P12m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P10 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P10 :: P12 :: nil) 4 4 HP1P2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P10m;assert(HP1P2P3P10m : rk(P1 :: P2 :: P3 :: P10 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P10 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P10 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P10m;assert(HP1P2P3P10m : rk(P1 :: P2 :: P3 :: P10 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P10 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P10 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P10m;assert(HP1P2P3P10m : rk(P1 :: P2 :: P3 :: P10 :: nil) >= 4).
{
try assert(HP3P10P12Mtmp : rk(P3 :: P10 :: P12 :: nil) <= 2) by (solve_hyps_max HP3P10P12eq HP3P10P12M).
try assert(HP1P2P3P10P12mtmp : rk(P1 :: P2 :: P3 :: P10 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P10P12eq HP1P2P3P10P12m).
try assert(HP3P10mtmp : rk(P3 :: P10 :: nil) >= 2) by (solve_hyps_min HP3P10eq HP3P10m).
assert(Hincl : incl (P3 :: P10 :: nil) (list_inter (P1 :: P2 :: P3 :: P10 :: nil) (P3 :: P10 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P10 :: P12 :: nil) (P1 :: P2 :: P3 :: P10 :: P3 :: P10 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P10 :: P3 :: P10 :: P12 :: nil) ((P1 :: P2 :: P3 :: P10 :: nil) ++ (P3 :: P10 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P10P12mtmp;try rewrite HT2 in HP1P2P3P10P12mtmp.
assert(HT := rule_2 (P1 :: P2 :: P3 :: P10 :: nil) (P3 :: P10 :: P12 :: nil) (P3 :: P10 :: nil) 4 2 2 HP1P2P3P10P12mtmp HP3P10mtmp HP3P10P12Mtmp Hincl); apply HT.
}
try clear HP1P2P3P10P13m;assert(HP1P2P3P10P13m : rk(P1 :: P2 :: P3 :: P10 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P10 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P10 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P10P13m;assert(HP1P2P3P10P13m : rk(P1 :: P2 :: P3 :: P10 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P10 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P10 :: P13 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P10P13m;assert(HP1P2P3P10P13m : rk(P1 :: P2 :: P3 :: P10 :: P13 :: nil) >= 4).
{
try assert(HP1P2P3P10mtmp : rk(P1 :: P2 :: P3 :: P10 :: nil) >= 4) by (solve_hyps_min HP1P2P3P10eq HP1P2P3P10m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P10 :: nil) (P1 :: P2 :: P3 :: P10 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P10 :: nil) (P1 :: P2 :: P3 :: P10 :: P13 :: nil) 4 4 HP1P2P3P10mtmp Hcomp Hincl); apply HT.
}
try clear HP10P13m;assert(HP10P13m : rk(P10 :: P13 :: nil) >= 2).
{
try assert(HP1P2P3P13Mtmp : rk(P1 :: P2 :: P3 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P13eq HP1P2P3P13M).
try assert(HP1P2P3P10P13mtmp : rk(P1 :: P2 :: P3 :: P10 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P10P13eq HP1P2P3P10P13m).
try assert(HP13mtmp : rk(P13 :: nil) >= 1) by (solve_hyps_min HP13eq HP13m).
assert(Hincl : incl (P13 :: nil) (list_inter (P1 :: P2 :: P3 :: P13 :: nil) (P10 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P10 :: P13 :: nil) (P1 :: P2 :: P3 :: P13 :: P10 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P13 :: P10 :: P13 :: nil) ((P1 :: P2 :: P3 :: P13 :: nil) ++ (P10 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P10P13mtmp;try rewrite HT2 in HP1P2P3P10P13mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P13 :: nil) (P10 :: P13 :: nil) (P13 :: nil) 4 1 3 HP1P2P3P10P13mtmp HP13mtmp HP1P2P3P13Mtmp Hincl); apply HT.
}
try clear HP1P3P10P12M;assert(HP1P3P10P12M : rk(P1 :: P3 :: P10 :: P12 :: nil) <= 3).
{
try assert(HP1Mtmp : rk(P1 :: nil) <= 1) by (solve_hyps_max HP1eq HP1M).
try assert(HP3P10P12Mtmp : rk(P3 :: P10 :: P12 :: nil) <= 2) by (solve_hyps_max HP3P10P12eq HP3P10P12M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P1 :: nil) (P3 :: P10 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P10 :: P12 :: nil) (P1 :: P3 :: P10 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P3 :: P10 :: P12 :: nil) ((P1 :: nil) ++ (P3 :: P10 :: P12 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: nil) (P3 :: P10 :: P12 :: nil) (nil) 1 2 0 HP1Mtmp HP3P10P12Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P3P10P12m;assert(HP1P3P10P12m : rk(P1 :: P3 :: P10 :: P12 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P10 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P10 :: P12 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P10P12m;assert(HP1P3P10P12m : rk(P1 :: P3 :: P10 :: P12 :: nil) >= 3).
{
try assert(HP1P3P12mtmp : rk(P1 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P3P12eq HP1P3P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: P12 :: nil) (P1 :: P3 :: P10 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: P12 :: nil) (P1 :: P3 :: P10 :: P12 :: nil) 3 3 HP1P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P12m;assert(HP1P12m : rk(P1 :: P12 :: nil) >= 2).
{
try assert(HP3Mtmp : rk(P3 :: nil) <= 1) by (solve_hyps_max HP3eq HP3M).
try assert(HP1P3P12mtmp : rk(P1 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P3P12eq HP1P3P12m).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P3 :: nil) (P1 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P12 :: nil) (P3 :: P1 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P1 :: P12 :: nil) ((P3 :: nil) ++ (P1 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P3P12mtmp;try rewrite HT2 in HP1P3P12mtmp.
assert(HT := rule_4 (P3 :: nil) (P1 :: P12 :: nil) (nil) 3 0 1 HP1P3P12mtmp Hmtmp HP3Mtmp Hincl); apply HT.
}
try clear HP1P10P12m;assert(HP1P10P12m : rk(P1 :: P10 :: P12 :: nil) >= 2).
{
try assert(HP1P12mtmp : rk(P1 :: P12 :: nil) >= 2) by (solve_hyps_min HP1P12eq HP1P12m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P12 :: nil) (P1 :: P10 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P12 :: nil) (P1 :: P10 :: P12 :: nil) 2 2 HP1P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P10P12m;assert(HP1P10P12m : rk(P1 :: P10 :: P12 :: nil) >= 3).
{
try assert(HP3P10P12Mtmp : rk(P3 :: P10 :: P12 :: nil) <= 2) by (solve_hyps_max HP3P10P12eq HP3P10P12M).
try assert(HP1P3P10P12mtmp : rk(P1 :: P3 :: P10 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P3P10P12eq HP1P3P10P12m).
try assert(HP10P12mtmp : rk(P10 :: P12 :: nil) >= 2) by (solve_hyps_min HP10P12eq HP10P12m).
assert(Hincl : incl (P10 :: P12 :: nil) (list_inter (P1 :: P10 :: P12 :: nil) (P3 :: P10 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P10 :: P12 :: nil) (P1 :: P10 :: P12 :: P3 :: P10 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P10 :: P12 :: P3 :: P10 :: P12 :: nil) ((P1 :: P10 :: P12 :: nil) ++ (P3 :: P10 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P3P10P12mtmp;try rewrite HT2 in HP1P3P10P12mtmp.
assert(HT := rule_2 (P1 :: P10 :: P12 :: nil) (P3 :: P10 :: P12 :: nil) (P10 :: P12 :: nil) 3 2 2 HP1P3P10P12mtmp HP10P12mtmp HP3P10P12Mtmp Hincl); apply HT.
}
try clear HP1P4P8P10P11P12P13P14m;assert(HP1P4P8P10P11P12P13P14m : rk(P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P8P10P11P12P13P14m;assert(HP1P4P8P10P11P12P13P14m : rk(P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP1P4P11mtmp : rk(P1 :: P4 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P4P11eq HP1P4P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) 3 3 HP1P4P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P8P10P12P13P14m;assert(HP1P8P10P12P13P14m : rk(P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP1P4P8P10P11P12P13P14mtmp : rk(P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) >= 3) by (solve_hyps_min HP1P4P8P10P11P12P13P14eq HP1P4P8P10P11P12P13P14m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: P13 :: P14 :: nil) (P4 :: P8 :: P11 :: P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P4P8P10P11P12P13P14mtmp;try rewrite HT2 in HP1P4P8P10P11P12P13P14mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil) (P8 :: nil) 3 1 2 HP1P4P8P10P11P12P13P14mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP1P8P10P12P13P14m;assert(HP1P8P10P12P13P14m : rk(P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP1P10P12mtmp : rk(P1 :: P10 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P10P12eq HP1P10P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P10 :: P12 :: nil) (P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P10 :: P12 :: nil) (P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil) 3 3 HP1P10P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P8P10P12P13P14m;assert(HP1P8P10P12P13P14m : rk(P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil) >= 4).
{
try assert(HP9P10P13Mtmp : rk(P9 :: P10 :: P13 :: nil) <= 2) by (solve_hyps_max HP9P10P13eq HP9P10P13M).
try assert(HP1P8P9P10P12P13P14mtmp : rk(P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) >= 4) by (solve_hyps_min HP1P8P9P10P12P13P14eq HP1P8P9P10P12P13P14m).
try assert(HP10P13mtmp : rk(P10 :: P13 :: nil) >= 2) by (solve_hyps_min HP10P13eq HP10P13m).
assert(Hincl : incl (P10 :: P13 :: nil) (list_inter (P9 :: P10 :: P13 :: nil) (P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: nil) (P9 :: P10 :: P13 :: P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P9 :: P10 :: P13 :: P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil) ((P9 :: P10 :: P13 :: nil) ++ (P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P8P9P10P12P13P14mtmp;try rewrite HT2 in HP1P8P9P10P12P13P14mtmp.
assert(HT := rule_4 (P9 :: P10 :: P13 :: nil) (P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil) (P10 :: P13 :: nil) 4 2 2 HP1P8P9P10P12P13P14mtmp HP10P13mtmp HP9P10P13Mtmp Hincl); apply HT.
}
try clear HP1P2P3P8P12P13m;assert(HP1P2P3P8P12P13m : rk(P1 :: P2 :: P3 :: P8 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P12 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P12P13m;assert(HP1P2P3P8P12P13m : rk(P1 :: P2 :: P3 :: P8 :: P12 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P12 :: P13 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P12P13m;assert(HP1P2P3P8P12P13m : rk(P1 :: P2 :: P3 :: P8 :: P12 :: P13 :: nil) >= 4).
{
try assert(HP1P2P3P12mtmp : rk(P1 :: P2 :: P3 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P12eq HP1P2P3P12m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P12 :: P13 :: nil) 4 4 HP1P2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P12m;assert(HP1P2P12m : rk(P1 :: P2 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P12m;assert(HP1P2P12m : rk(P1 :: P2 :: P12 :: nil) >= 3).
{
try assert(HP3Mtmp : rk(P3 :: nil) <= 1) by (solve_hyps_max HP3eq HP3M).
try assert(HP1P2P3P12mtmp : rk(P1 :: P2 :: P3 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P12eq HP1P2P3P12m).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P3 :: nil) (P1 :: P2 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P12 :: nil) (P3 :: P1 :: P2 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P1 :: P2 :: P12 :: nil) ((P3 :: nil) ++ (P1 :: P2 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P12mtmp;try rewrite HT2 in HP1P2P3P12mtmp.
assert(HT := rule_4 (P3 :: nil) (P1 :: P2 :: P12 :: nil) (nil) 4 0 1 HP1P2P3P12mtmp Hmtmp HP3Mtmp Hincl); apply HT.
}
try clear HP1P2P9P10P12P13m;assert(HP1P2P9P10P12P13m : rk(P1 :: P2 :: P9 :: P10 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P9 :: P10 :: P12 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P9P10P12P13m;assert(HP1P2P9P10P12P13m : rk(P1 :: P2 :: P9 :: P10 :: P12 :: P13 :: nil) >= 3).
{
try assert(HP1P2P12mtmp : rk(P1 :: P2 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P2P12eq HP1P2P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P12 :: nil) (P1 :: P2 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P12 :: nil) (P1 :: P2 :: P9 :: P10 :: P12 :: P13 :: nil) 3 3 HP1P2P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P9P10P13M;assert(HP1P9P10P13M : rk(P1 :: P9 :: P10 :: P13 :: nil) <= 3).
{
try assert(HP1Mtmp : rk(P1 :: nil) <= 1) by (solve_hyps_max HP1eq HP1M).
try assert(HP9P10P13Mtmp : rk(P9 :: P10 :: P13 :: nil) <= 2) by (solve_hyps_max HP9P10P13eq HP9P10P13M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P1 :: nil) (P9 :: P10 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P9 :: P10 :: P13 :: nil) (P1 :: P9 :: P10 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P9 :: P10 :: P13 :: nil) ((P1 :: nil) ++ (P9 :: P10 :: P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: nil) (P9 :: P10 :: P13 :: nil) (nil) 1 2 0 HP1Mtmp HP9P10P13Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P9P10P13m;assert(HP1P9P10P13m : rk(P1 :: P9 :: P10 :: P13 :: nil) >= 2).
{
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(HP1P2P9P10P12P13mtmp : rk(P1 :: P2 :: P9 :: P10 :: P12 :: P13 :: nil) >= 3) by (solve_hyps_min HP1P2P9P10P12P13eq HP1P2P9P10P12P13m).
try assert(HP9mtmp : rk(P9 :: nil) >= 1) by (solve_hyps_min HP9eq HP9m).
assert(Hincl : incl (P9 :: nil) (list_inter (P2 :: P9 :: P12 :: nil) (P1 :: P9 :: P10 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P9 :: P10 :: P12 :: P13 :: nil) (P2 :: P9 :: P12 :: P1 :: P9 :: P10 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P9 :: P12 :: P1 :: P9 :: P10 :: P13 :: nil) ((P2 :: P9 :: P12 :: nil) ++ (P1 :: P9 :: P10 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P9P10P12P13mtmp;try rewrite HT2 in HP1P2P9P10P12P13mtmp.
assert(HT := rule_4 (P2 :: P9 :: P12 :: nil) (P1 :: P9 :: P10 :: P13 :: nil) (P9 :: nil) 3 1 2 HP1P2P9P10P12P13mtmp HP9mtmp HP2P9P12Mtmp Hincl); apply HT.
}
try clear HP1P9P10P13m;assert(HP1P9P10P13m : rk(P1 :: P9 :: P10 :: P13 :: nil) >= 3).
{
try assert(HP3P10P12Mtmp : rk(P3 :: P10 :: P12 :: nil) <= 2) by (solve_hyps_max HP3P10P12eq HP3P10P12M).
try assert(HP1P3P9P10P12P13mtmp : rk(P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P3P9P10P12P13eq HP1P3P9P10P12P13m).
try assert(HP10mtmp : rk(P10 :: nil) >= 1) by (solve_hyps_min HP10eq HP10m).
assert(Hincl : incl (P10 :: nil) (list_inter (P3 :: P10 :: P12 :: nil) (P1 :: P9 :: P10 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) (P3 :: P10 :: P12 :: P1 :: P9 :: P10 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P10 :: P12 :: P1 :: P9 :: P10 :: P13 :: nil) ((P3 :: P10 :: P12 :: nil) ++ (P1 :: P9 :: P10 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P3P9P10P12P13mtmp;try rewrite HT2 in HP1P3P9P10P12P13mtmp.
assert(HT := rule_4 (P3 :: P10 :: P12 :: nil) (P1 :: P9 :: P10 :: P13 :: nil) (P10 :: nil) 4 1 2 HP1P3P9P10P12P13mtmp HP10mtmp HP3P10P12Mtmp Hincl); apply HT.
}
try clear HP1P13m;assert(HP1P13m : rk(P1 :: P13 :: nil) >= 2).
{
try assert(HP9P10P13Mtmp : rk(P9 :: P10 :: P13 :: nil) <= 2) by (solve_hyps_max HP9P10P13eq HP9P10P13M).
try assert(HP1P9P10P13mtmp : rk(P1 :: P9 :: P10 :: P13 :: nil) >= 3) by (solve_hyps_min HP1P9P10P13eq HP1P9P10P13m).
try assert(HP13mtmp : rk(P13 :: nil) >= 1) by (solve_hyps_min HP13eq HP13m).
assert(Hincl : incl (P13 :: nil) (list_inter (P1 :: P13 :: nil) (P9 :: P10 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P9 :: P10 :: P13 :: nil) (P1 :: P13 :: P9 :: P10 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P13 :: P9 :: P10 :: P13 :: nil) ((P1 :: P13 :: nil) ++ (P9 :: P10 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P9P10P13mtmp;try rewrite HT2 in HP1P9P10P13mtmp.
assert(HT := rule_2 (P1 :: P13 :: nil) (P9 :: P10 :: P13 :: nil) (P13 :: nil) 3 1 2 HP1P9P10P13mtmp HP13mtmp HP9P10P13Mtmp Hincl); apply HT.
}
try clear HP1P4P8P11P12P13m;assert(HP1P4P8P11P12P13m : rk(P1 :: P4 :: P8 :: P11 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P11 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P11 :: P12 :: P13 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P8P11P12P13m;assert(HP1P4P8P11P12P13m : rk(P1 :: P4 :: P8 :: P11 :: P12 :: P13 :: nil) >= 3).
{
try assert(HP1P4P11mtmp : rk(P1 :: P4 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P4P11eq HP1P4P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P11 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P11 :: P12 :: P13 :: nil) 3 3 HP1P4P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P8P12P13m;assert(HP1P8P12P13m : rk(P1 :: P8 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP1P4P8P11P12P13mtmp : rk(P1 :: P4 :: P8 :: P11 :: P12 :: P13 :: nil) >= 3) by (solve_hyps_min HP1P4P8P11P12P13eq HP1P4P8P11P12P13m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P12 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P8 :: P11 :: P12 :: P13 :: nil) (P4 :: P8 :: P11 :: P1 :: P8 :: P12 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P1 :: P8 :: P12 :: P13 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P1 :: P8 :: P12 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P4P8P11P12P13mtmp;try rewrite HT2 in HP1P4P8P11P12P13mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P12 :: P13 :: nil) (P8 :: nil) 3 1 2 HP1P4P8P11P12P13mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP1P8P12P13M;assert(HP1P8P12P13M : rk(P1 :: P8 :: P12 :: P13 :: nil) <= 3).
{
try assert(HP1P8P12Mtmp : rk(P1 :: P8 :: P12 :: nil) <= 2) by (solve_hyps_max HP1P8P12eq HP1P8P12M).
try assert(HP13Mtmp : rk(P13 :: nil) <= 1) by (solve_hyps_max HP13eq HP13M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P1 :: P8 :: P12 :: nil) (P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P8 :: P12 :: P13 :: nil) (P1 :: P8 :: P12 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P12 :: P13 :: nil) ((P1 :: P8 :: P12 :: nil) ++ (P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: P8 :: P12 :: nil) (P13 :: nil) (nil) 2 1 0 HP1P8P12Mtmp HP13Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P8P12P13m;assert(HP1P8P12P13m : rk(P1 :: P8 :: P12 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3P13Mtmp : rk(P1 :: P2 :: P3 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P13eq HP1P2P3P13M).
try assert(HP1P2P3P8P12P13mtmp : rk(P1 :: P2 :: P3 :: P8 :: P12 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8P12P13eq HP1P2P3P8P12P13m).
try assert(HP1P13mtmp : rk(P1 :: P13 :: nil) >= 2) by (solve_hyps_min HP1P13eq HP1P13m).
assert(Hincl : incl (P1 :: P13 :: nil) (list_inter (P1 :: P2 :: P3 :: P13 :: nil) (P1 :: P8 :: P12 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P8 :: P12 :: P13 :: nil) (P1 :: P2 :: P3 :: P13 :: P1 :: P8 :: P12 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P13 :: P1 :: P8 :: P12 :: P13 :: nil) ((P1 :: P2 :: P3 :: P13 :: nil) ++ (P1 :: P8 :: P12 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P8P12P13mtmp;try rewrite HT2 in HP1P2P3P8P12P13mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P13 :: nil) (P1 :: P8 :: P12 :: P13 :: nil) (P1 :: P13 :: nil) 4 2 3 HP1P2P3P8P12P13mtmp HP1P13mtmp HP1P2P3P13Mtmp Hincl); apply HT.
}
try clear HP1P4P8P10P11P14m;assert(HP1P4P8P10P11P14m : rk(P1 :: P4 :: P8 :: P10 :: P11 :: P14 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P10 :: P11 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P10 :: P11 :: P14 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P8P10P11P14m;assert(HP1P4P8P10P11P14m : rk(P1 :: P4 :: P8 :: P10 :: P11 :: P14 :: nil) >= 3).
{
try assert(HP1P4P11mtmp : rk(P1 :: P4 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P4P11eq HP1P4P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P10 :: P11 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P10 :: P11 :: P14 :: nil) 3 3 HP1P4P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P8P10P14M;assert(HP1P8P10P14M : rk(P1 :: P8 :: P10 :: P14 :: nil) <= 3).
{
try assert(HP1Mtmp : rk(P1 :: nil) <= 1) by (solve_hyps_max HP1eq HP1M).
try assert(HP8P10P14Mtmp : rk(P8 :: P10 :: P14 :: nil) <= 2) by (solve_hyps_max HP8P10P14eq HP8P10P14M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P1 :: nil) (P8 :: P10 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P8 :: P10 :: P14 :: nil) (P1 :: P8 :: P10 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P10 :: P14 :: nil) ((P1 :: nil) ++ (P8 :: P10 :: P14 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: nil) (P8 :: P10 :: P14 :: nil) (nil) 1 2 0 HP1Mtmp HP8P10P14Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P8P10P14m;assert(HP1P8P10P14m : rk(P1 :: P8 :: P10 :: P14 :: nil) >= 2).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP1P4P8P10P11P14mtmp : rk(P1 :: P4 :: P8 :: P10 :: P11 :: P14 :: nil) >= 3) by (solve_hyps_min HP1P4P8P10P11P14eq HP1P4P8P10P11P14m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P10 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P8 :: P10 :: P11 :: P14 :: nil) (P4 :: P8 :: P11 :: P1 :: P8 :: P10 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P1 :: P8 :: P10 :: P14 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P1 :: P8 :: P10 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P4P8P10P11P14mtmp;try rewrite HT2 in HP1P4P8P10P11P14mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P10 :: P14 :: nil) (P8 :: nil) 3 1 2 HP1P4P8P10P11P14mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP1P8P10P14m;assert(HP1P8P10P14m : rk(P1 :: P8 :: P10 :: P14 :: nil) >= 3).
{
try assert(HP1P8P12P13Mtmp : rk(P1 :: P8 :: P12 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P8P12P13eq HP1P8P12P13M).
try assert(HP1P8P10P12P13P14mtmp : rk(P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil) >= 4) by (solve_hyps_min HP1P8P10P12P13P14eq HP1P8P10P12P13P14m).
try assert(HP1P8mtmp : rk(P1 :: P8 :: nil) >= 2) by (solve_hyps_min HP1P8eq HP1P8m).
assert(Hincl : incl (P1 :: P8 :: nil) (list_inter (P1 :: P8 :: P12 :: P13 :: nil) (P1 :: P8 :: P10 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P8 :: P10 :: P12 :: P13 :: P14 :: nil) (P1 :: P8 :: P12 :: P13 :: P1 :: P8 :: P10 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P12 :: P13 :: P1 :: P8 :: P10 :: P14 :: nil) ((P1 :: P8 :: P12 :: P13 :: nil) ++ (P1 :: P8 :: P10 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P8P10P12P13P14mtmp;try rewrite HT2 in HP1P8P10P12P13P14mtmp.
assert(HT := rule_4 (P1 :: P8 :: P12 :: P13 :: nil) (P1 :: P8 :: P10 :: P14 :: nil) (P1 :: P8 :: nil) 4 2 3 HP1P8P10P12P13P14mtmp HP1P8mtmp HP1P8P12P13Mtmp Hincl); apply HT.
}
try clear HP1P14m;assert(HP1P14m : rk(P1 :: P14 :: nil) >= 2).
{
try assert(HP8P10P14Mtmp : rk(P8 :: P10 :: P14 :: nil) <= 2) by (solve_hyps_max HP8P10P14eq HP8P10P14M).
try assert(HP1P8P10P14mtmp : rk(P1 :: P8 :: P10 :: P14 :: nil) >= 3) by (solve_hyps_min HP1P8P10P14eq HP1P8P10P14m).
try assert(HP14mtmp : rk(P14 :: nil) >= 1) by (solve_hyps_min HP14eq HP14m).
assert(Hincl : incl (P14 :: nil) (list_inter (P1 :: P14 :: nil) (P8 :: P10 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P8 :: P10 :: P14 :: nil) (P1 :: P14 :: P8 :: P10 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P14 :: P8 :: P10 :: P14 :: nil) ((P1 :: P14 :: nil) ++ (P8 :: P10 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P8P10P14mtmp;try rewrite HT2 in HP1P8P10P14mtmp.
assert(HT := rule_2 (P1 :: P14 :: nil) (P8 :: P10 :: P14 :: nil) (P14 :: nil) 3 1 2 HP1P8P10P14mtmp HP14mtmp HP8P10P14Mtmp Hincl); apply HT.
}
try clear HP3P6P8P10P11P12P14m;assert(HP3P6P8P10P11P12P14m : rk(P3 :: P6 :: P8 :: P10 :: P11 :: P12 :: P14 :: nil) >= 2).
{
try assert(HP3P6mtmp : rk(P3 :: P6 :: nil) >= 2) by (solve_hyps_min HP3P6eq HP3P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P3 :: P6 :: nil) (P3 :: P6 :: P8 :: P10 :: P11 :: P12 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P3 :: P6 :: nil) (P3 :: P6 :: P8 :: P10 :: P11 :: P12 :: P14 :: nil) 2 2 HP3P6mtmp Hcomp Hincl); apply HT.
}
try clear HP3P6P8P10P11P12P14m;assert(HP3P6P8P10P11P12P14m : rk(P3 :: P6 :: P8 :: P10 :: P11 :: P12 :: P14 :: nil) >= 3).
{
try assert(HP3P6P11mtmp : rk(P3 :: P6 :: P11 :: nil) >= 3) by (solve_hyps_min HP3P6P11eq HP3P6P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P3 :: P6 :: P11 :: nil) (P3 :: P6 :: P8 :: P10 :: P11 :: P12 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P3 :: P6 :: P11 :: nil) (P3 :: P6 :: P8 :: P10 :: P11 :: P12 :: P14 :: nil) 3 3 HP3P6P11mtmp Hcomp Hincl); apply HT.
}
try clear HP3P8P10P12P14m;assert(HP3P8P10P12P14m : rk(P3 :: P8 :: P10 :: P12 :: P14 :: nil) >= 2).
{
try assert(HP6P10P11Mtmp : rk(P6 :: P10 :: P11 :: nil) <= 2) by (solve_hyps_max HP6P10P11eq HP6P10P11M).
try assert(HP3P6P8P10P11P12P14mtmp : rk(P3 :: P6 :: P8 :: P10 :: P11 :: P12 :: P14 :: nil) >= 3) by (solve_hyps_min HP3P6P8P10P11P12P14eq HP3P6P8P10P11P12P14m).
try assert(HP10mtmp : rk(P10 :: nil) >= 1) by (solve_hyps_min HP10eq HP10m).
assert(Hincl : incl (P10 :: nil) (list_inter (P6 :: P10 :: P11 :: nil) (P3 :: P8 :: P10 :: P12 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P3 :: P6 :: P8 :: P10 :: P11 :: P12 :: P14 :: nil) (P6 :: P10 :: P11 :: P3 :: P8 :: P10 :: P12 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P6 :: P10 :: P11 :: P3 :: P8 :: P10 :: P12 :: P14 :: nil) ((P6 :: P10 :: P11 :: nil) ++ (P3 :: P8 :: P10 :: P12 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP3P6P8P10P11P12P14mtmp;try rewrite HT2 in HP3P6P8P10P11P12P14mtmp.
assert(HT := rule_4 (P6 :: P10 :: P11 :: nil) (P3 :: P8 :: P10 :: P12 :: P14 :: nil) (P10 :: nil) 3 1 2 HP3P6P8P10P11P12P14mtmp HP10mtmp HP6P10P11Mtmp Hincl); apply HT.
}
try clear HP3P8P10P12P14M;assert(HP3P8P10P12P14M : rk(P3 :: P8 :: P10 :: P12 :: P14 :: nil) <= 3).
{
try assert(HP3P10P12Mtmp : rk(P3 :: P10 :: P12 :: nil) <= 2) by (solve_hyps_max HP3P10P12eq HP3P10P12M).
try assert(HP8P10P14Mtmp : rk(P8 :: P10 :: P14 :: nil) <= 2) by (solve_hyps_max HP8P10P14eq HP8P10P14M).
try assert(HP10mtmp : rk(P10 :: nil) >= 1) by (solve_hyps_min HP10eq HP10m).
assert(Hincl : incl (P10 :: nil) (list_inter (P3 :: P10 :: P12 :: nil) (P8 :: P10 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P3 :: P8 :: P10 :: P12 :: P14 :: nil) (P3 :: P10 :: P12 :: P8 :: P10 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P10 :: P12 :: P8 :: P10 :: P14 :: nil) ((P3 :: P10 :: P12 :: nil) ++ (P8 :: P10 :: P14 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P3 :: P10 :: P12 :: nil) (P8 :: P10 :: P14 :: nil) (P10 :: nil) 2 2 1 HP3P10P12Mtmp HP8P10P14Mtmp HP10mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP2P3P12m;assert(HP2P3P12m : rk(P2 :: P3 :: P12 :: nil) >= 3).
{
try assert(HP1Mtmp : rk(P1 :: nil) <= 1) by (solve_hyps_max HP1eq HP1M).
try assert(HP1P2P3P12mtmp : rk(P1 :: P2 :: P3 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P12eq HP1P2P3P12m).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P1 :: nil) (P2 :: P3 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P12 :: nil) ((P1 :: nil) ++ (P2 :: P3 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P12mtmp;try rewrite HT2 in HP1P2P3P12mtmp.
assert(HT := rule_4 (P1 :: nil) (P2 :: P3 :: P12 :: nil) (nil) 4 0 1 HP1P2P3P12mtmp Hmtmp HP1Mtmp Hincl); apply HT.
}
try clear HP3P12m;assert(HP3P12m : rk(P3 :: P12 :: nil) >= 2).
{
try assert(HP2Mtmp : rk(P2 :: nil) <= 1) by (solve_hyps_max HP2eq HP2M).
try assert(HP2P3P12mtmp : rk(P2 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP2P3P12eq HP2P3P12m).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P2 :: nil) (P3 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P3 :: P12 :: nil) (P2 :: P3 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P3 :: P12 :: nil) ((P2 :: nil) ++ (P3 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP2P3P12mtmp;try rewrite HT2 in HP2P3P12mtmp.
assert(HT := rule_4 (P2 :: nil) (P3 :: P12 :: nil) (nil) 3 0 1 HP2P3P12mtmp Hmtmp HP2Mtmp Hincl); apply HT.
}
try clear HP3P8P12P14m;assert(HP3P8P12P14m : rk(P3 :: P8 :: P12 :: P14 :: nil) >= 2).
{
try assert(HP3P12mtmp : rk(P3 :: P12 :: nil) >= 2) by (solve_hyps_min HP3P12eq HP3P12m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P3 :: P12 :: nil) (P3 :: P8 :: P12 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P3 :: P12 :: nil) (P3 :: P8 :: P12 :: P14 :: nil) 2 2 HP3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP3P8P12P14M;assert(HP3P8P12P14M : rk(P3 :: P8 :: P12 :: P14 :: nil) <= 3).
{
try assert(HP3P8P10P12P14Mtmp : rk(P3 :: P8 :: P10 :: P12 :: P14 :: nil) <= 3) by (solve_hyps_max HP3P8P10P12P14eq HP3P8P10P12P14M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P3 :: P8 :: P12 :: P14 :: nil) (P3 :: P8 :: P10 :: P12 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P3 :: P8 :: P12 :: P14 :: nil) (P3 :: P8 :: P10 :: P12 :: P14 :: nil) 3 3 HP3P8P10P12P14Mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P7P11P12m;assert(HP1P2P3P4P7P11P12m : rk(P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P7P11P12m;assert(HP1P2P3P4P7P11P12m : rk(P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: P12 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P7P11P12m;assert(HP1P2P3P4P7P11P12m : rk(P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: P12 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: P12 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P7P11P12m;assert(HP1P4P7P11P12m : rk(P1 :: P4 :: P7 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P7 :: P11 :: P12 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P7P11P12M;assert(HP1P4P7P11P12M : rk(P1 :: P4 :: P7 :: P11 :: P12 :: nil) <= 3).
{
try assert(HP1P4P7Mtmp : rk(P1 :: P4 :: P7 :: nil) <= 2) by (solve_hyps_max HP1P4P7eq HP1P4P7M).
try assert(HP7P11P12Mtmp : rk(P7 :: P11 :: P12 :: nil) <= 2) by (solve_hyps_max HP7P11P12eq HP7P11P12M).
try assert(HP7mtmp : rk(P7 :: nil) >= 1) by (solve_hyps_min HP7eq HP7m).
assert(Hincl : incl (P7 :: nil) (list_inter (P1 :: P4 :: P7 :: nil) (P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P7 :: P11 :: P12 :: nil) (P1 :: P4 :: P7 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P4 :: P7 :: P7 :: P11 :: P12 :: nil) ((P1 :: P4 :: P7 :: nil) ++ (P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: P4 :: P7 :: nil) (P7 :: P11 :: P12 :: nil) (P7 :: nil) 2 2 1 HP1P4P7Mtmp HP7P11P12Mtmp HP7mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P4P7P11P12m;assert(HP1P4P7P11P12m : rk(P1 :: P4 :: P7 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3P4P11Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P4P11eq HP1P2P3P4P11M).
try assert(HP1P2P3P4P7P11P12mtmp : rk(P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P4P7P11P12eq HP1P2P3P4P7P11P12m).
try assert(HP1P4P11mtmp : rk(P1 :: P4 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P4P11eq HP1P4P11m).
assert(Hincl : incl (P1 :: P4 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P4 :: P11 :: nil) (P1 :: P4 :: P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: P12 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: P1 :: P4 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P4 :: P11 :: P1 :: P4 :: P7 :: P11 :: P12 :: nil) ((P1 :: P2 :: P3 :: P4 :: P11 :: nil) ++ (P1 :: P4 :: P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P4P7P11P12mtmp;try rewrite HT2 in HP1P2P3P4P7P11P12mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P4 :: P11 :: nil) (P1 :: P4 :: P7 :: P11 :: P12 :: nil) (P1 :: P4 :: P11 :: nil) 4 3 4 HP1P2P3P4P7P11P12mtmp HP1P4P11mtmp HP1P2P3P4P11Mtmp Hincl); apply HT.
}
try clear HP4P5P6P11m;assert(HP4P5P6P11m : rk(P4 :: P5 :: P6 :: P11 :: nil) >= 2).
{
try assert(HP4P5mtmp : rk(P4 :: P5 :: nil) >= 2) by (solve_hyps_min HP4P5eq HP4P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P11 :: nil) 2 2 HP4P5mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P11m;assert(HP4P5P6P11m : rk(P4 :: P5 :: P6 :: P11 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P11 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P11m;assert(HP4P5P6P11m : rk(P4 :: P5 :: P6 :: P11 :: nil) >= 4).
{
try assert(HP1P2P3P4P5P6P13Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P4P5P6P13eq HP1P2P3P4P5P6P13M).
try assert(HP1P2P3P4P5P6P11P13mtmp : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P4P5P6P11P13eq HP1P2P3P4P5P6P11P13m).
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (list_inter (P4 :: P5 :: P6 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil) (P4 :: P5 :: P6 :: P11 :: P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P5 :: P6 :: P11 :: P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) ((P4 :: P5 :: P6 :: P11 :: nil) ++ (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P4P5P6P11P13mtmp;try rewrite HT2 in HP1P2P3P4P5P6P11P13mtmp.
assert(HT := rule_2 (P4 :: P5 :: P6 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) (P4 :: P5 :: P6 :: nil) 4 3 3 HP1P2P3P4P5P6P11P13mtmp HP4P5P6mtmp HP1P2P3P4P5P6P13Mtmp Hincl); apply HT.
}
try clear HP4P5P6P7P11P13m;assert(HP4P5P6P7P11P13m : rk(P4 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) >= 2).
{
try assert(HP4P5mtmp : rk(P4 :: P5 :: nil) >= 2) by (solve_hyps_min HP4P5eq HP4P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) 2 2 HP4P5mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P7P11P13m;assert(HP4P5P6P7P11P13m : rk(P4 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P7P11P13m;assert(HP4P5P6P7P11P13m : rk(P4 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) >= 4).
{
try assert(HP4P5P6P11mtmp : rk(P4 :: P5 :: P6 :: P11 :: nil) >= 4) by (solve_hyps_min HP4P5P6P11eq HP4P5P6P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: P11 :: nil) (P4 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: P11 :: nil) (P4 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) 4 4 HP4P5P6P11mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P7m;assert(HP4P5P6P7m : rk(P4 :: P5 :: P6 :: P7 :: nil) >= 2).
{
try assert(HP4P5mtmp : rk(P4 :: P5 :: nil) >= 2) by (solve_hyps_min HP4P5eq HP4P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P7 :: nil) 2 2 HP4P5mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P7m;assert(HP4P5P6P7m : rk(P4 :: P5 :: P6 :: P7 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P7 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P7M;assert(HP4P5P6P7M : rk(P4 :: P5 :: P6 :: P7 :: nil) <= 3).
{
try assert(HP1P2P3P4P5P6P7Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) <= 3) by (solve_hyps_max HP1P2P3P4P5P6P7eq HP1P2P3P4P5P6P7M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: P7 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P4 :: P5 :: P6 :: P7 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P7 :: nil) 3 3 HP1P2P3P4P5P6P7Mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P7P13m;assert(HP4P5P6P7P13m : rk(P4 :: P5 :: P6 :: P7 :: P13 :: nil) >= 2).
{
try assert(HP4P5mtmp : rk(P4 :: P5 :: nil) >= 2) by (solve_hyps_min HP4P5eq HP4P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P7 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P7 :: P13 :: nil) 2 2 HP4P5mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P7P13m;assert(HP4P5P6P7P13m : rk(P4 :: P5 :: P6 :: P7 :: P13 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P7 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P7 :: P13 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P7P13M;assert(HP4P5P6P7P13M : rk(P4 :: P5 :: P6 :: P7 :: P13 :: nil) <= 3).
{
try assert(HP4P5P6P7Mtmp : rk(P4 :: P5 :: P6 :: P7 :: nil) <= 3) by (solve_hyps_max HP4P5P6P7eq HP4P5P6P7M).
try assert(HP5P6P13Mtmp : rk(P5 :: P6 :: P13 :: nil) <= 2) by (solve_hyps_max HP5P6P13eq HP5P6P13M).
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hincl : incl (P5 :: P6 :: nil) (list_inter (P4 :: P5 :: P6 :: P7 :: nil) (P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P5 :: P6 :: P7 :: P13 :: nil) (P4 :: P5 :: P6 :: P7 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P5 :: P6 :: P7 :: P5 :: P6 :: P13 :: nil) ((P4 :: P5 :: P6 :: P7 :: nil) ++ (P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P4 :: P5 :: P6 :: P7 :: nil) (P5 :: P6 :: P13 :: nil) (P5 :: P6 :: nil) 3 2 2 HP4P5P6P7Mtmp HP5P6P13Mtmp HP5P6mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP4P7P11m;assert(HP4P7P11m : rk(P4 :: P7 :: P11 :: nil) >= 2).
{
try assert(HP4P7mtmp : rk(P4 :: P7 :: nil) >= 2) by (solve_hyps_min HP4P7eq HP4P7m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P4 :: P7 :: nil) (P4 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P7 :: nil) (P4 :: P7 :: P11 :: nil) 2 2 HP4P7mtmp Hcomp Hincl); apply HT.
}
try clear HP4P7P11m;assert(HP4P7P11m : rk(P4 :: P7 :: P11 :: nil) >= 3).
{
try assert(HP4P5P6P7P13Mtmp : rk(P4 :: P5 :: P6 :: P7 :: P13 :: nil) <= 3) by (solve_hyps_max HP4P5P6P7P13eq HP4P5P6P7P13M).
try assert(HP4P5P6P7P11P13mtmp : rk(P4 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) >= 4) by (solve_hyps_min HP4P5P6P7P11P13eq HP4P5P6P7P11P13m).
try assert(HP4P7mtmp : rk(P4 :: P7 :: nil) >= 2) by (solve_hyps_min HP4P7eq HP4P7m).
assert(Hincl : incl (P4 :: P7 :: nil) (list_inter (P4 :: P7 :: P11 :: nil) (P4 :: P5 :: P6 :: P7 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P5 :: P6 :: P7 :: P11 :: P13 :: nil) (P4 :: P7 :: P11 :: P4 :: P5 :: P6 :: P7 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P7 :: P11 :: P4 :: P5 :: P6 :: P7 :: P13 :: nil) ((P4 :: P7 :: P11 :: nil) ++ (P4 :: P5 :: P6 :: P7 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP4P5P6P7P11P13mtmp;try rewrite HT2 in HP4P5P6P7P11P13mtmp.
assert(HT := rule_2 (P4 :: P7 :: P11 :: nil) (P4 :: P5 :: P6 :: P7 :: P13 :: nil) (P4 :: P7 :: nil) 4 2 3 HP4P5P6P7P11P13mtmp HP4P7mtmp HP4P5P6P7P13Mtmp Hincl); apply HT.
}
try clear HP1P2P3P4P7P11m;assert(HP1P2P3P4P7P11m : rk(P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P7P11m;assert(HP1P2P3P4P7P11m : rk(P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P7P11m;assert(HP1P2P3P4P7P11m : rk(P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P7P11m;assert(HP1P4P7P11m : rk(P1 :: P4 :: P7 :: P11 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P7 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P7 :: P11 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P7P11M;assert(HP1P4P7P11M : rk(P1 :: P4 :: P7 :: P11 :: nil) <= 3).
{
try assert(HP1P4P7Mtmp : rk(P1 :: P4 :: P7 :: nil) <= 2) by (solve_hyps_max HP1P4P7eq HP1P4P7M).
try assert(HP11Mtmp : rk(P11 :: nil) <= 1) by (solve_hyps_max HP11eq HP11M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P1 :: P4 :: P7 :: nil) (P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P7 :: P11 :: nil) (P1 :: P4 :: P7 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P4 :: P7 :: P11 :: nil) ((P1 :: P4 :: P7 :: nil) ++ (P11 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: P4 :: P7 :: nil) (P11 :: nil) (nil) 2 1 0 HP1P4P7Mtmp HP11Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P4P7P11m;assert(HP1P4P7P11m : rk(P1 :: P4 :: P7 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3P4P11Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P4P11eq HP1P2P3P4P11M).
try assert(HP1P2P3P4P7P11mtmp : rk(P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P4P7P11eq HP1P2P3P4P7P11m).
try assert(HP1P4P11mtmp : rk(P1 :: P4 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P4P11eq HP1P4P11m).
assert(Hincl : incl (P1 :: P4 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P4 :: P11 :: nil) (P1 :: P4 :: P7 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P4 :: P7 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: P1 :: P4 :: P7 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P4 :: P11 :: P1 :: P4 :: P7 :: P11 :: nil) ((P1 :: P2 :: P3 :: P4 :: P11 :: nil) ++ (P1 :: P4 :: P7 :: P11 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P4P7P11mtmp;try rewrite HT2 in HP1P2P3P4P7P11mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P4 :: P11 :: nil) (P1 :: P4 :: P7 :: P11 :: nil) (P1 :: P4 :: P11 :: nil) 4 3 4 HP1P2P3P4P7P11mtmp HP1P4P11mtmp HP1P2P3P4P11Mtmp Hincl); apply HT.
}
try clear HP4P7P11P12M;assert(HP4P7P11P12M : rk(P4 :: P7 :: P11 :: P12 :: nil) <= 3).
{
try assert(HP4Mtmp : rk(P4 :: nil) <= 1) by (solve_hyps_max HP4eq HP4M).
try assert(HP7P11P12Mtmp : rk(P7 :: P11 :: P12 :: nil) <= 2) by (solve_hyps_max HP7P11P12eq HP7P11P12M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P4 :: nil) (P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P7 :: P11 :: P12 :: nil) (P4 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P7 :: P11 :: P12 :: nil) ((P4 :: nil) ++ (P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P4 :: nil) (P7 :: P11 :: P12 :: nil) (nil) 1 2 0 HP4Mtmp HP7P11P12Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP4P7P11P12m;assert(HP4P7P11P12m : rk(P4 :: P7 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP4P7mtmp : rk(P4 :: P7 :: nil) >= 2) by (solve_hyps_min HP4P7eq HP4P7m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P4 :: P7 :: nil) (P4 :: P7 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P7 :: nil) (P4 :: P7 :: P11 :: P12 :: nil) 2 2 HP4P7mtmp Hcomp Hincl); apply HT.
}
try clear HP4P7P11P12m;assert(HP4P7P11P12m : rk(P4 :: P7 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P4P7P11Mtmp : rk(P1 :: P4 :: P7 :: P11 :: nil) <= 3) by (solve_hyps_max HP1P4P7P11eq HP1P4P7P11M).
try assert(HP1P4P7P11P12mtmp : rk(P1 :: P4 :: P7 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P4P7P11P12eq HP1P4P7P11P12m).
try assert(HP4P7P11mtmp : rk(P4 :: P7 :: P11 :: nil) >= 3) by (solve_hyps_min HP4P7P11eq HP4P7P11m).
assert(Hincl : incl (P4 :: P7 :: P11 :: nil) (list_inter (P1 :: P4 :: P7 :: P11 :: nil) (P4 :: P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P7 :: P11 :: P12 :: nil) (P1 :: P4 :: P7 :: P11 :: P4 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P4 :: P7 :: P11 :: P4 :: P7 :: P11 :: P12 :: nil) ((P1 :: P4 :: P7 :: P11 :: nil) ++ (P4 :: P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P4P7P11P12mtmp;try rewrite HT2 in HP1P4P7P11P12mtmp.
assert(HT := rule_4 (P1 :: P4 :: P7 :: P11 :: nil) (P4 :: P7 :: P11 :: P12 :: nil) (P4 :: P7 :: P11 :: nil) 3 3 3 HP1P4P7P11P12mtmp HP4P7P11mtmp HP1P4P7P11Mtmp Hincl); apply HT.
}
try clear HP1P2P3P4P11P12m;assert(HP1P2P3P4P11P12m : rk(P1 :: P2 :: P3 :: P4 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P11P12m;assert(HP1P2P3P4P11P12m : rk(P1 :: P2 :: P3 :: P4 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: P12 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P11P12m;assert(HP1P2P3P4P11P12m : rk(P1 :: P2 :: P3 :: P4 :: P11 :: P12 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: P12 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP4P11m;assert(HP4P11m : rk(P4 :: P11 :: nil) >= 2).
{
try assert(HP1P2P3P4P5P6P13Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P4P5P6P13eq HP1P2P3P4P5P6P13M).
try assert(HP1P2P3P4P5P6P11P13mtmp : rk(P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P4P5P6P11P13eq HP1P2P3P4P5P6P11P13m).
try assert(HP4mtmp : rk(P4 :: nil) >= 1) by (solve_hyps_min HP4eq HP4m).
assert(Hincl : incl (P4 :: nil) (list_inter (P4 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P11 :: P13 :: nil) (P4 :: P11 :: P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P11 :: P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) ((P4 :: P11 :: nil) ++ (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P4P5P6P11P13mtmp;try rewrite HT2 in HP1P2P3P4P5P6P11P13mtmp.
assert(HT := rule_2 (P4 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P5 :: P6 :: P13 :: nil) (P4 :: nil) 4 1 3 HP1P2P3P4P5P6P11P13mtmp HP4mtmp HP1P2P3P4P5P6P13Mtmp Hincl); apply HT.
}
try clear HP4P11P12m;assert(HP4P11P12m : rk(P4 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2P3P4P11Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P4P11eq HP1P2P3P4P11M).
try assert(HP1P2P3P4P11P12mtmp : rk(P1 :: P2 :: P3 :: P4 :: P11 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P4P11P12eq HP1P2P3P4P11P12m).
try assert(HP4P11mtmp : rk(P4 :: P11 :: nil) >= 2) by (solve_hyps_min HP4P11eq HP4P11m).
assert(Hincl : incl (P4 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P4 :: P11 :: nil) (P4 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P4 :: P11 :: P12 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: P4 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P4 :: P11 :: P4 :: P11 :: P12 :: nil) ((P1 :: P2 :: P3 :: P4 :: P11 :: nil) ++ (P4 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P4P11P12mtmp;try rewrite HT2 in HP1P2P3P4P11P12mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P4 :: P11 :: nil) (P4 :: P11 :: P12 :: nil) (P4 :: P11 :: nil) 4 2 4 HP1P2P3P4P11P12mtmp HP4P11mtmp HP1P2P3P4P11Mtmp Hincl); apply HT.
}
try clear HP4P11P12m;assert(HP4P11P12m : rk(P4 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP7P11P12Mtmp : rk(P7 :: P11 :: P12 :: nil) <= 2) by (solve_hyps_max HP7P11P12eq HP7P11P12M).
try assert(HP4P7P11P12mtmp : rk(P4 :: P7 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP4P7P11P12eq HP4P7P11P12m).
try assert(HP11P12mtmp : rk(P11 :: P12 :: nil) >= 2) by (solve_hyps_min HP11P12eq HP11P12m).
assert(Hincl : incl (P11 :: P12 :: nil) (list_inter (P4 :: P11 :: P12 :: nil) (P7 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P7 :: P11 :: P12 :: nil) (P4 :: P11 :: P12 :: P7 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P11 :: P12 :: P7 :: P11 :: P12 :: nil) ((P4 :: P11 :: P12 :: nil) ++ (P7 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP4P7P11P12mtmp;try rewrite HT2 in HP4P7P11P12mtmp.
assert(HT := rule_2 (P4 :: P11 :: P12 :: nil) (P7 :: P11 :: P12 :: nil) (P11 :: P12 :: nil) 3 2 2 HP4P7P11P12mtmp HP11P12mtmp HP7P11P12Mtmp Hincl); apply HT.
}
try clear HP1P2P3P4P8P11P12m;assert(HP1P2P3P4P8P11P12m : rk(P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P8P11P12m;assert(HP1P2P3P4P8P11P12m : rk(P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: P12 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P8P11P12m;assert(HP1P2P3P4P8P11P12m : rk(P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: P12 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: P12 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP4P8P11P12m;assert(HP4P8P11P12m : rk(P4 :: P8 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2P3P4P11Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P4P11eq HP1P2P3P4P11M).
try assert(HP1P2P3P4P8P11P12mtmp : rk(P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P4P8P11P12eq HP1P2P3P4P8P11P12m).
try assert(HP4P11mtmp : rk(P4 :: P11 :: nil) >= 2) by (solve_hyps_min HP4P11eq HP4P11m).
assert(Hincl : incl (P4 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P4 :: P11 :: nil) (P4 :: P8 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P4 :: P8 :: P11 :: P12 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: P4 :: P8 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P4 :: P11 :: P4 :: P8 :: P11 :: P12 :: nil) ((P1 :: P2 :: P3 :: P4 :: P11 :: nil) ++ (P4 :: P8 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P4P8P11P12mtmp;try rewrite HT2 in HP1P2P3P4P8P11P12mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P4 :: P11 :: nil) (P4 :: P8 :: P11 :: P12 :: nil) (P4 :: P11 :: nil) 4 2 4 HP1P2P3P4P8P11P12mtmp HP4P11mtmp HP1P2P3P4P11Mtmp Hincl); apply HT.
}
try clear HP4P8P11P12M;assert(HP4P8P11P12M : rk(P4 :: P8 :: P11 :: P12 :: nil) <= 3).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP12Mtmp : rk(P12 :: nil) <= 1) by (solve_hyps_max HP12eq HP12M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P4 :: P8 :: P11 :: nil) (P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P8 :: P11 :: P12 :: nil) (P4 :: P8 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P12 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P12 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P4 :: P8 :: P11 :: nil) (P12 :: nil) (nil) 2 1 0 HP4P8P11Mtmp HP12Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP4P8P11P12m;assert(HP4P8P11P12m : rk(P4 :: P8 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP4P11P12mtmp : rk(P4 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP4P11P12eq HP4P11P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P11 :: P12 :: nil) (P4 :: P8 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P11 :: P12 :: nil) (P4 :: P8 :: P11 :: P12 :: nil) 3 3 HP4P11P12mtmp Hcomp Hincl); apply HT.
}
try clear HP8P12m;assert(HP8P12m : rk(P8 :: P12 :: nil) >= 2).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP4P8P11P12mtmp : rk(P4 :: P8 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP4P8P11P12eq HP4P8P11P12m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P8 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P8 :: P11 :: P12 :: nil) (P4 :: P8 :: P11 :: P8 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P8 :: P12 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P8 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP4P8P11P12mtmp;try rewrite HT2 in HP4P8P11P12mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P8 :: P12 :: nil) (P8 :: nil) 3 1 2 HP4P8P11P12mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP1P3P8P12P14m;assert(HP1P3P8P12P14m : rk(P1 :: P3 :: P8 :: P12 :: P14 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: P12 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: P12 :: P14 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P12P14m;assert(HP1P3P8P12P14m : rk(P1 :: P3 :: P8 :: P12 :: P14 :: nil) >= 3).
{
try assert(HP1P3P12mtmp : rk(P1 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P3P12eq HP1P3P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: P12 :: nil) (P1 :: P3 :: P8 :: P12 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: P12 :: nil) (P1 :: P3 :: P8 :: P12 :: P14 :: nil) 3 3 HP1P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P12P14M;assert(HP1P3P8P12P14M : rk(P1 :: P3 :: P8 :: P12 :: P14 :: nil) <= 3).
{
try assert(HP1P8P12Mtmp : rk(P1 :: P8 :: P12 :: nil) <= 2) by (solve_hyps_max HP1P8P12eq HP1P8P12M).
try assert(HP3P8P12P14Mtmp : rk(P3 :: P8 :: P12 :: P14 :: nil) <= 3) by (solve_hyps_max HP3P8P12P14eq HP3P8P12P14M).
try assert(HP8P12mtmp : rk(P8 :: P12 :: nil) >= 2) by (solve_hyps_min HP8P12eq HP8P12m).
assert(Hincl : incl (P8 :: P12 :: nil) (list_inter (P1 :: P8 :: P12 :: nil) (P3 :: P8 :: P12 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P8 :: P12 :: P14 :: nil) (P1 :: P8 :: P12 :: P3 :: P8 :: P12 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P12 :: P3 :: P8 :: P12 :: P14 :: nil) ((P1 :: P8 :: P12 :: nil) ++ (P3 :: P8 :: P12 :: P14 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: P8 :: P12 :: nil) (P3 :: P8 :: P12 :: P14 :: nil) (P8 :: P12 :: nil) 2 3 2 HP1P8P12Mtmp HP3P8P12P14Mtmp HP8P12mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P3P8P14m;assert(HP1P3P8P14m : rk(P1 :: P3 :: P8 :: P14 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: P14 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P14m;assert(HP1P3P8P14m : rk(P1 :: P3 :: P8 :: P14 :: nil) >= 3).
{
try assert(HP1P3P8mtmp : rk(P1 :: P3 :: P8 :: nil) >= 3) by (solve_hyps_min HP1P3P8eq HP1P3P8m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: P8 :: nil) (P1 :: P3 :: P8 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: P8 :: nil) (P1 :: P3 :: P8 :: P14 :: nil) 3 3 HP1P3P8mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P14M;assert(HP1P3P8P14M : rk(P1 :: P3 :: P8 :: P14 :: nil) <= 3).
{
try assert(HP1P3P8P12P14Mtmp : rk(P1 :: P3 :: P8 :: P12 :: P14 :: nil) <= 3) by (solve_hyps_max HP1P3P8P12P14eq HP1P3P8P12P14M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: P8 :: P14 :: nil) (P1 :: P3 :: P8 :: P12 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P1 :: P3 :: P8 :: P14 :: nil) (P1 :: P3 :: P8 :: P12 :: P14 :: nil) 3 3 HP1P3P8P12P14Mtmp Hcomp Hincl); apply HT.
}
try clear HP4P6m;assert(HP4P6m : rk(P4 :: P6 :: nil) >= 2).
{
try assert(HP5Mtmp : rk(P5 :: nil) <= 1) by (solve_hyps_max HP5eq HP5M).
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P5 :: nil) (P4 :: P6 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P5 :: P6 :: nil) (P5 :: P4 :: P6 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P4 :: P6 :: nil) ((P5 :: nil) ++ (P4 :: P6 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP4P5P6mtmp;try rewrite HT2 in HP4P5P6mtmp.
assert(HT := rule_4 (P5 :: nil) (P4 :: P6 :: nil) (nil) 3 0 1 HP4P5P6mtmp Hmtmp HP5Mtmp Hincl); apply HT.
}
try clear HP1P4P5P6P14m;assert(HP1P4P5P6P14m : rk(P1 :: P4 :: P5 :: P6 :: P14 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P5 :: P6 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P5 :: P6 :: P14 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P5P6P14m;assert(HP1P4P5P6P14m : rk(P1 :: P4 :: P5 :: P6 :: P14 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P1 :: P4 :: P5 :: P6 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P1 :: P4 :: P5 :: P6 :: P14 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P5P6P14M;assert(HP1P4P5P6P14M : rk(P1 :: P4 :: P5 :: P6 :: P14 :: nil) <= 3).
{
try assert(HP1P4P5P6Mtmp : rk(P1 :: P4 :: P5 :: P6 :: nil) <= 3) by (solve_hyps_max HP1P4P5P6eq HP1P4P5P6M).
try assert(HP4P6P14Mtmp : rk(P4 :: P6 :: P14 :: nil) <= 2) by (solve_hyps_max HP4P6P14eq HP4P6P14M).
try assert(HP4P6mtmp : rk(P4 :: P6 :: nil) >= 2) by (solve_hyps_min HP4P6eq HP4P6m).
assert(Hincl : incl (P4 :: P6 :: nil) (list_inter (P1 :: P4 :: P5 :: P6 :: nil) (P4 :: P6 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P5 :: P6 :: P14 :: nil) (P1 :: P4 :: P5 :: P6 :: P4 :: P6 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P4 :: P5 :: P6 :: P4 :: P6 :: P14 :: nil) ((P1 :: P4 :: P5 :: P6 :: nil) ++ (P4 :: P6 :: P14 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: P4 :: P5 :: P6 :: nil) (P4 :: P6 :: P14 :: nil) (P4 :: P6 :: nil) 3 2 2 HP1P4P5P6Mtmp HP4P6P14Mtmp HP4P6mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P4P5P6P13P14m;assert(HP1P4P5P6P13P14m : rk(P1 :: P4 :: P5 :: P6 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P5 :: P6 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P5 :: P6 :: P13 :: P14 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P5P6P13P14m;assert(HP1P4P5P6P13P14m : rk(P1 :: P4 :: P5 :: P6 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P1 :: P4 :: P5 :: P6 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P1 :: P4 :: P5 :: P6 :: P13 :: P14 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P5P6P13P14M;assert(HP1P4P5P6P13P14M : rk(P1 :: P4 :: P5 :: P6 :: P13 :: P14 :: nil) <= 3).
{
try assert(HP5P6P13Mtmp : rk(P5 :: P6 :: P13 :: nil) <= 2) by (solve_hyps_max HP5P6P13eq HP5P6P13M).
try assert(HP1P4P5P6P14Mtmp : rk(P1 :: P4 :: P5 :: P6 :: P14 :: nil) <= 3) by (solve_hyps_max HP1P4P5P6P14eq HP1P4P5P6P14M).
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hincl : incl (P5 :: P6 :: nil) (list_inter (P5 :: P6 :: P13 :: nil) (P1 :: P4 :: P5 :: P6 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P5 :: P6 :: P13 :: P14 :: nil) (P5 :: P6 :: P13 :: P1 :: P4 :: P5 :: P6 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P6 :: P13 :: P1 :: P4 :: P5 :: P6 :: P14 :: nil) ((P5 :: P6 :: P13 :: nil) ++ (P1 :: P4 :: P5 :: P6 :: P14 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P5 :: P6 :: P13 :: nil) (P1 :: P4 :: P5 :: P6 :: P14 :: nil) (P5 :: P6 :: nil) 2 3 2 HP5P6P13Mtmp HP1P4P5P6P14Mtmp HP5P6mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P4P5P13P14m;assert(HP1P4P5P13P14m : rk(P1 :: P4 :: P5 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P5 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P5 :: P13 :: P14 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P5P13P14M;assert(HP1P4P5P13P14M : rk(P1 :: P4 :: P5 :: P13 :: P14 :: nil) <= 3).
{
try assert(HP1P4P5P6P13P14Mtmp : rk(P1 :: P4 :: P5 :: P6 :: P13 :: P14 :: nil) <= 3) by (solve_hyps_max HP1P4P5P6P13P14eq HP1P4P5P6P13P14M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: P5 :: P13 :: P14 :: nil) (P1 :: P4 :: P5 :: P6 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P1 :: P4 :: P5 :: P13 :: P14 :: nil) (P1 :: P4 :: P5 :: P6 :: P13 :: P14 :: nil) 3 3 HP1P4P5P6P13P14Mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P5P13P14P15m;assert(HP1P4P5P13P14P15m : rk(P1 :: P4 :: P5 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P5 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P5 :: P13 :: P14 :: P15 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P5P13P14P15M;assert(HP1P4P5P13P14P15M : rk(P1 :: P4 :: P5 :: P13 :: P14 :: P15 :: nil) <= 3).
{
try assert(HP1P4P5P13P14Mtmp : rk(P1 :: P4 :: P5 :: P13 :: P14 :: nil) <= 3) by (solve_hyps_max HP1P4P5P13P14eq HP1P4P5P13P14M).
try assert(HP4P5P15Mtmp : rk(P4 :: P5 :: P15 :: nil) <= 2) by (solve_hyps_max HP4P5P15eq HP4P5P15M).
try assert(HP4P5mtmp : rk(P4 :: P5 :: nil) >= 2) by (solve_hyps_min HP4P5eq HP4P5m).
assert(Hincl : incl (P4 :: P5 :: nil) (list_inter (P1 :: P4 :: P5 :: P13 :: P14 :: nil) (P4 :: P5 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P5 :: P13 :: P14 :: P15 :: nil) (P1 :: P4 :: P5 :: P13 :: P14 :: P4 :: P5 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P4 :: P5 :: P13 :: P14 :: P4 :: P5 :: P15 :: nil) ((P1 :: P4 :: P5 :: P13 :: P14 :: nil) ++ (P4 :: P5 :: P15 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: P4 :: P5 :: P13 :: P14 :: nil) (P4 :: P5 :: P15 :: nil) (P4 :: P5 :: nil) 3 2 2 HP1P4P5P13P14Mtmp HP4P5P15Mtmp HP4P5mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P13P14P15M;assert(HP1P13P14P15M : rk(P1 :: P13 :: P14 :: P15 :: nil) <= 3).
{
try assert(HP1P4P5P13P14P15Mtmp : rk(P1 :: P4 :: P5 :: P13 :: P14 :: P15 :: nil) <= 3) by (solve_hyps_max HP1P4P5P13P14P15eq HP1P4P5P13P14P15M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P13 :: P14 :: P15 :: nil) (P1 :: P4 :: P5 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P1 :: P13 :: P14 :: P15 :: nil) (P1 :: P4 :: P5 :: P13 :: P14 :: P15 :: nil) 3 3 HP1P4P5P13P14P15Mtmp Hcomp Hincl); apply HT.
}
try clear HP1P13P14P15m;assert(HP1P13P14P15m : rk(P1 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP1P13mtmp : rk(P1 :: P13 :: nil) >= 2) by (solve_hyps_min HP1P13eq HP1P13m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P13 :: nil) (P1 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P13 :: nil) (P1 :: P13 :: P14 :: P15 :: nil) 2 2 HP1P13mtmp Hcomp Hincl); apply HT.
}
try clear HP1P13P14P15m;assert(HP1P13P14P15m : rk(P1 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP1P3P8P14Mtmp : rk(P1 :: P3 :: P8 :: P14 :: nil) <= 3) by (solve_hyps_max HP1P3P8P14eq HP1P3P8P14M).
try assert(HP1P3P8P13P14P15mtmp : rk(P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P3P8P13P14P15eq HP1P3P8P13P14P15m).
try assert(HP1P14mtmp : rk(P1 :: P14 :: nil) >= 2) by (solve_hyps_min HP1P14eq HP1P14m).
assert(Hincl : incl (P1 :: P14 :: nil) (list_inter (P1 :: P3 :: P8 :: P14 :: nil) (P1 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) (P1 :: P3 :: P8 :: P14 :: P1 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P3 :: P8 :: P14 :: P1 :: P13 :: P14 :: P15 :: nil) ((P1 :: P3 :: P8 :: P14 :: nil) ++ (P1 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P3P8P13P14P15mtmp;try rewrite HT2 in HP1P3P8P13P14P15mtmp.
assert(HT := rule_4 (P1 :: P3 :: P8 :: P14 :: nil) (P1 :: P13 :: P14 :: P15 :: nil) (P1 :: P14 :: nil) 4 2 3 HP1P3P8P13P14P15mtmp HP1P14mtmp HP1P3P8P14Mtmp Hincl); apply HT.
}
try clear HP1P2P3P8P9P12P13P14m;assert(HP1P2P3P8P9P12P13P14m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P9P12P13P14m;assert(HP1P2P3P8P9P12P13P14m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P9P12P13P14m;assert(HP1P2P3P8P9P12P13P14m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) >= 4).
{
try assert(HP1P2P3P12mtmp : rk(P1 :: P2 :: P3 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P12eq HP1P2P3P12m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) 4 4 HP1P2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3m;assert(HP2P3m : rk(P2 :: P3 :: nil) >= 2).
{
try assert(HP1Mtmp : rk(P1 :: nil) <= 1) by (solve_hyps_max HP1eq HP1M).
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P1 :: nil) (P2 :: P3 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: nil) ((P1 :: nil) ++ (P2 :: P3 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3mtmp;try rewrite HT2 in HP1P2P3mtmp.
assert(HT := rule_4 (P1 :: nil) (P2 :: P3 :: nil) (nil) 3 0 1 HP1P2P3mtmp Hmtmp HP1Mtmp Hincl); apply HT.
}
try clear HP2P3P8P9P12P13P14m;assert(HP2P3P8P9P12P13P14m : rk(P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP2P3mtmp : rk(P2 :: P3 :: nil) >= 2) by (solve_hyps_min HP2P3eq HP2P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) 2 2 HP2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P8P9P12P13P14m;assert(HP2P3P8P9P12P13P14m : rk(P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP2P3P12mtmp : rk(P2 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP2P3P12eq HP2P3P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) 3 3 HP2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P8P9P12P13P14m;assert(HP2P3P8P9P12P13P14m : rk(P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) >= 4).
{
try assert(HP1P8P12Mtmp : rk(P1 :: P8 :: P12 :: nil) <= 2) by (solve_hyps_max HP1P8P12eq HP1P8P12M).
try assert(HP1P2P3P8P9P12P13P14mtmp : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8P9P12P13P14eq HP1P2P3P8P9P12P13P14m).
try assert(HP8P12mtmp : rk(P8 :: P12 :: nil) >= 2) by (solve_hyps_min HP8P12eq HP8P12m).
assert(Hincl : incl (P8 :: P12 :: nil) (list_inter (P1 :: P8 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) (P1 :: P8 :: P12 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P12 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) ((P1 :: P8 :: P12 :: nil) ++ (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P8P9P12P13P14mtmp;try rewrite HT2 in HP1P2P3P8P9P12P13P14mtmp.
assert(HT := rule_4 (P1 :: P8 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) (P8 :: P12 :: nil) 4 2 2 HP1P2P3P8P9P12P13P14mtmp HP8P12mtmp HP1P8P12Mtmp Hincl); apply HT.
}
try clear HP1P2P3P5P9P11m;assert(HP1P2P3P5P9P11m : rk(P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P9P11m;assert(HP1P2P3P5P9P11m : rk(P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P5P9P11m;assert(HP1P2P3P5P9P11m : rk(P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP2P5P9P11M;assert(HP2P5P9P11M : rk(P2 :: P5 :: P9 :: P11 :: nil) <= 3).
{
try assert(HP2Mtmp : rk(P2 :: nil) <= 1) by (solve_hyps_max HP2eq HP2M).
try assert(HP5P9P11Mtmp : rk(P5 :: P9 :: P11 :: nil) <= 2) by (solve_hyps_max HP5P9P11eq HP5P9P11M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P2 :: nil) (P5 :: P9 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P5 :: P9 :: P11 :: nil) (P2 :: P5 :: P9 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P5 :: P9 :: P11 :: nil) ((P2 :: nil) ++ (P5 :: P9 :: P11 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P2 :: nil) (P5 :: P9 :: P11 :: nil) (nil) 1 2 0 HP2Mtmp HP5P9P11Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP2P5P9P11m;assert(HP2P5P9P11m : rk(P2 :: P5 :: P9 :: P11 :: nil) >= 2).
{
try assert(HP2P5mtmp : rk(P2 :: P5 :: nil) >= 2) by (solve_hyps_min HP2P5eq HP2P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P5 :: nil) (P2 :: P5 :: P9 :: P11 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P5 :: nil) (P2 :: P5 :: P9 :: P11 :: nil) 2 2 HP2P5mtmp Hcomp Hincl); apply HT.
}
try clear HP2P5P9P11m;assert(HP2P5P9P11m : rk(P2 :: P5 :: P9 :: P11 :: nil) >= 3).
{
try assert(HP1P2P3P5P11Mtmp : rk(P1 :: P2 :: P3 :: P5 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P5P11eq HP1P2P3P5P11M).
try assert(HP1P2P3P5P9P11mtmp : rk(P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P5P9P11eq HP1P2P3P5P9P11m).
try assert(HP2P5P11mtmp : rk(P2 :: P5 :: P11 :: nil) >= 3) by (solve_hyps_min HP2P5P11eq HP2P5P11m).
assert(Hincl : incl (P2 :: P5 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P5 :: P11 :: nil) (P2 :: P5 :: P9 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P5 :: P9 :: P11 :: nil) (P1 :: P2 :: P3 :: P5 :: P11 :: P2 :: P5 :: P9 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P5 :: P11 :: P2 :: P5 :: P9 :: P11 :: nil) ((P1 :: P2 :: P3 :: P5 :: P11 :: nil) ++ (P2 :: P5 :: P9 :: P11 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P5P9P11mtmp;try rewrite HT2 in HP1P2P3P5P9P11mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P5 :: P11 :: nil) (P2 :: P5 :: P9 :: P11 :: nil) (P2 :: P5 :: P11 :: nil) 4 3 4 HP1P2P3P5P9P11mtmp HP2P5P11mtmp HP1P2P3P5P11Mtmp Hincl); apply HT.
}
try clear HP2P9m;assert(HP2P9m : rk(P2 :: P9 :: nil) >= 2).
{
try assert(HP5P9P11Mtmp : rk(P5 :: P9 :: P11 :: nil) <= 2) by (solve_hyps_max HP5P9P11eq HP5P9P11M).
try assert(HP2P5P9P11mtmp : rk(P2 :: P5 :: P9 :: P11 :: nil) >= 3) by (solve_hyps_min HP2P5P9P11eq HP2P5P9P11m).
try assert(HP9mtmp : rk(P9 :: nil) >= 1) by (solve_hyps_min HP9eq HP9m).
assert(Hincl : incl (P9 :: nil) (list_inter (P2 :: P9 :: nil) (P5 :: P9 :: P11 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P5 :: P9 :: P11 :: nil) (P2 :: P9 :: P5 :: P9 :: P11 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P9 :: P5 :: P9 :: P11 :: nil) ((P2 :: P9 :: nil) ++ (P5 :: P9 :: P11 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP2P5P9P11mtmp;try rewrite HT2 in HP2P5P9P11mtmp.
assert(HT := rule_2 (P2 :: P9 :: nil) (P5 :: P9 :: P11 :: nil) (P9 :: nil) 3 1 2 HP2P5P9P11mtmp HP9mtmp HP5P9P11Mtmp Hincl); apply HT.
}
try clear HP2P3P8P9P13P14m;assert(HP2P3P8P9P13P14m : rk(P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP2P3mtmp : rk(P2 :: P3 :: nil) >= 2) by (solve_hyps_min HP2P3eq HP2P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil) 2 2 HP2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P8P9P13P14m;assert(HP2P3P8P9P13P14m : rk(P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP1P8P12Mtmp : rk(P1 :: P8 :: P12 :: nil) <= 2) by (solve_hyps_max HP1P8P12eq HP1P8P12M).
try assert(HP1P2P3P8P9P12P13P14mtmp : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8P9P12P13P14eq HP1P2P3P8P9P12P13P14m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P1 :: P8 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) (P1 :: P8 :: P12 :: P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P12 :: P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil) ((P1 :: P8 :: P12 :: nil) ++ (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P8P9P12P13P14mtmp;try rewrite HT2 in HP1P2P3P8P9P12P13P14mtmp.
assert(HT := rule_4 (P1 :: P8 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil) (P8 :: nil) 4 1 2 HP1P2P3P8P9P12P13P14mtmp HP8mtmp HP1P8P12Mtmp Hincl); apply HT.
}
try clear HP2P3P8P9P13P14m;assert(HP2P3P8P9P13P14m : rk(P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil) >= 4).
{
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(HP2P3P8P9P12P13P14mtmp : rk(P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) >= 4) by (solve_hyps_min HP2P3P8P9P12P13P14eq HP2P3P8P9P12P13P14m).
try assert(HP2P9mtmp : rk(P2 :: P9 :: nil) >= 2) by (solve_hyps_min HP2P9eq HP2P9m).
assert(Hincl : incl (P2 :: P9 :: nil) (list_inter (P2 :: P9 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: nil) (P2 :: P9 :: P12 :: P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P9 :: P12 :: P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil) ((P2 :: P9 :: P12 :: nil) ++ (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP2P3P8P9P12P13P14mtmp;try rewrite HT2 in HP2P3P8P9P12P13P14mtmp.
assert(HT := rule_4 (P2 :: P9 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil) (P2 :: P9 :: nil) 4 2 2 HP2P3P8P9P12P13P14mtmp HP2P9mtmp HP2P9P12Mtmp Hincl); apply HT.
}
try clear HP1P2P3P9P12m;assert(HP1P2P3P9P12m : rk(P1 :: P2 :: P3 :: P9 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P9 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P9 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P9P12m;assert(HP1P2P3P9P12m : rk(P1 :: P2 :: P3 :: P9 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P9 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P9 :: P12 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P9P12m;assert(HP1P2P3P9P12m : rk(P1 :: P2 :: P3 :: P9 :: P12 :: nil) >= 4).
{
try assert(HP1P2P3P12mtmp : rk(P1 :: P2 :: P3 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P12eq HP1P2P3P12m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P9 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P9 :: P12 :: nil) 4 4 HP1P2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P9m;assert(HP1P2P3P9m : rk(P1 :: P2 :: P3 :: P9 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P9 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P9 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P9m;assert(HP1P2P3P9m : rk(P1 :: P2 :: P3 :: P9 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P9 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P9 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P9m;assert(HP1P2P3P9m : rk(P1 :: P2 :: P3 :: P9 :: nil) >= 4).
{
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(HP1P2P3P9P12mtmp : rk(P1 :: P2 :: P3 :: P9 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P9P12eq HP1P2P3P9P12m).
try assert(HP2P9mtmp : rk(P2 :: P9 :: nil) >= 2) by (solve_hyps_min HP2P9eq HP2P9m).
assert(Hincl : incl (P2 :: P9 :: nil) (list_inter (P1 :: P2 :: P3 :: P9 :: nil) (P2 :: P9 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P9 :: P12 :: nil) (P1 :: P2 :: P3 :: P9 :: P2 :: P9 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P9 :: P2 :: P9 :: P12 :: nil) ((P1 :: P2 :: P3 :: P9 :: nil) ++ (P2 :: P9 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P9P12mtmp;try rewrite HT2 in HP1P2P3P9P12mtmp.
assert(HT := rule_2 (P1 :: P2 :: P3 :: P9 :: nil) (P2 :: P9 :: P12 :: nil) (P2 :: P9 :: nil) 4 2 2 HP1P2P3P9P12mtmp HP2P9mtmp HP2P9P12Mtmp Hincl); apply HT.
}
try clear HP1P2P3P9P13m;assert(HP1P2P3P9P13m : rk(P1 :: P2 :: P3 :: P9 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P9 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P9 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P9P13m;assert(HP1P2P3P9P13m : rk(P1 :: P2 :: P3 :: P9 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P9 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P9 :: P13 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P9P13m;assert(HP1P2P3P9P13m : rk(P1 :: P2 :: P3 :: P9 :: P13 :: nil) >= 4).
{
try assert(HP1P2P3P9mtmp : rk(P1 :: P2 :: P3 :: P9 :: nil) >= 4) by (solve_hyps_min HP1P2P3P9eq HP1P2P3P9m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P9 :: nil) (P1 :: P2 :: P3 :: P9 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P9 :: nil) (P1 :: P2 :: P3 :: P9 :: P13 :: nil) 4 4 HP1P2P3P9mtmp Hcomp Hincl); apply HT.
}
try clear HP9P13m;assert(HP9P13m : rk(P9 :: P13 :: nil) >= 2).
{
try assert(HP1P2P3P13Mtmp : rk(P1 :: P2 :: P3 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P13eq HP1P2P3P13M).
try assert(HP1P2P3P9P13mtmp : rk(P1 :: P2 :: P3 :: P9 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P9P13eq HP1P2P3P9P13m).
try assert(HP13mtmp : rk(P13 :: nil) >= 1) by (solve_hyps_min HP13eq HP13m).
assert(Hincl : incl (P13 :: nil) (list_inter (P1 :: P2 :: P3 :: P13 :: nil) (P9 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P9 :: P13 :: nil) (P1 :: P2 :: P3 :: P13 :: P9 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P13 :: P9 :: P13 :: nil) ((P1 :: P2 :: P3 :: P13 :: nil) ++ (P9 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P9P13mtmp;try rewrite HT2 in HP1P2P3P9P13mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P13 :: nil) (P9 :: P13 :: nil) (P13 :: nil) 4 1 3 HP1P2P3P9P13mtmp HP13mtmp HP1P2P3P13Mtmp Hincl); apply HT.
}
try clear HP3P6P9P10P11P12P13m;assert(HP3P6P9P10P11P12P13m : rk(P3 :: P6 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP3P6mtmp : rk(P3 :: P6 :: nil) >= 2) by (solve_hyps_min HP3P6eq HP3P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P3 :: P6 :: nil) (P3 :: P6 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P3 :: P6 :: nil) (P3 :: P6 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil) 2 2 HP3P6mtmp Hcomp Hincl); apply HT.
}
try clear HP3P6P9P10P11P12P13m;assert(HP3P6P9P10P11P12P13m : rk(P3 :: P6 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil) >= 3).
{
try assert(HP3P6P11mtmp : rk(P3 :: P6 :: P11 :: nil) >= 3) by (solve_hyps_min HP3P6P11eq HP3P6P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P3 :: P6 :: P11 :: nil) (P3 :: P6 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P3 :: P6 :: P11 :: nil) (P3 :: P6 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil) 3 3 HP3P6P11mtmp Hcomp Hincl); apply HT.
}
try clear HP3P9P10P12P13m;assert(HP3P9P10P12P13m : rk(P3 :: P9 :: P10 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP6P10P11Mtmp : rk(P6 :: P10 :: P11 :: nil) <= 2) by (solve_hyps_max HP6P10P11eq HP6P10P11M).
try assert(HP3P6P9P10P11P12P13mtmp : rk(P3 :: P6 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil) >= 3) by (solve_hyps_min HP3P6P9P10P11P12P13eq HP3P6P9P10P11P12P13m).
try assert(HP10mtmp : rk(P10 :: nil) >= 1) by (solve_hyps_min HP10eq HP10m).
assert(Hincl : incl (P10 :: nil) (list_inter (P6 :: P10 :: P11 :: nil) (P3 :: P9 :: P10 :: P12 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P3 :: P6 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil) (P6 :: P10 :: P11 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P6 :: P10 :: P11 :: P3 :: P9 :: P10 :: P12 :: P13 :: nil) ((P6 :: P10 :: P11 :: nil) ++ (P3 :: P9 :: P10 :: P12 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP3P6P9P10P11P12P13mtmp;try rewrite HT2 in HP3P6P9P10P11P12P13mtmp.
assert(HT := rule_4 (P6 :: P10 :: P11 :: nil) (P3 :: P9 :: P10 :: P12 :: P13 :: nil) (P10 :: nil) 3 1 2 HP3P6P9P10P11P12P13mtmp HP10mtmp HP6P10P11Mtmp Hincl); apply HT.
}
try clear HP3P9P10P12P13M;assert(HP3P9P10P12P13M : rk(P3 :: P9 :: P10 :: P12 :: P13 :: nil) <= 3).
{
try assert(HP3P10P12Mtmp : rk(P3 :: P10 :: P12 :: nil) <= 2) by (solve_hyps_max HP3P10P12eq HP3P10P12M).
try assert(HP9P10P13Mtmp : rk(P9 :: P10 :: P13 :: nil) <= 2) by (solve_hyps_max HP9P10P13eq HP9P10P13M).
try assert(HP10mtmp : rk(P10 :: nil) >= 1) by (solve_hyps_min HP10eq HP10m).
assert(Hincl : incl (P10 :: nil) (list_inter (P3 :: P10 :: P12 :: nil) (P9 :: P10 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P3 :: P9 :: P10 :: P12 :: P13 :: nil) (P3 :: P10 :: P12 :: P9 :: P10 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P10 :: P12 :: P9 :: P10 :: P13 :: nil) ((P3 :: P10 :: P12 :: nil) ++ (P9 :: P10 :: P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P3 :: P10 :: P12 :: nil) (P9 :: P10 :: P13 :: nil) (P10 :: nil) 2 2 1 HP3P10P12Mtmp HP9P10P13Mtmp HP10mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP3P9P12P13m;assert(HP3P9P12P13m : rk(P3 :: P9 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP3P12mtmp : rk(P3 :: P12 :: nil) >= 2) by (solve_hyps_min HP3P12eq HP3P12m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P3 :: P12 :: nil) (P3 :: P9 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P3 :: P12 :: nil) (P3 :: P9 :: P12 :: P13 :: nil) 2 2 HP3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP3P9P12P13M;assert(HP3P9P12P13M : rk(P3 :: P9 :: P12 :: P13 :: nil) <= 3).
{
try assert(HP3P9P10P12P13Mtmp : rk(P3 :: P9 :: P10 :: P12 :: P13 :: nil) <= 3) by (solve_hyps_max HP3P9P10P12P13eq HP3P9P10P12P13M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P3 :: P9 :: P12 :: P13 :: nil) (P3 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P3 :: P9 :: P12 :: P13 :: nil) (P3 :: P9 :: P10 :: P12 :: P13 :: nil) 3 3 HP3P9P10P12P13Mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P9P12P13m;assert(HP2P3P9P12P13m : rk(P2 :: P3 :: P9 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP2P3mtmp : rk(P2 :: P3 :: nil) >= 2) by (solve_hyps_min HP2P3eq HP2P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: nil) (P2 :: P3 :: P9 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: nil) (P2 :: P3 :: P9 :: P12 :: P13 :: nil) 2 2 HP2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P9P12P13m;assert(HP2P3P9P12P13m : rk(P2 :: P3 :: P9 :: P12 :: P13 :: nil) >= 3).
{
try assert(HP2P3P12mtmp : rk(P2 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP2P3P12eq HP2P3P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: P12 :: nil) (P2 :: P3 :: P9 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: P12 :: nil) (P2 :: P3 :: P9 :: P12 :: P13 :: nil) 3 3 HP2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P9P12P13M;assert(HP2P3P9P12P13M : rk(P2 :: P3 :: P9 :: P12 :: P13 :: nil) <= 3).
{
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(HP3P9P12P13Mtmp : rk(P3 :: P9 :: P12 :: P13 :: nil) <= 3) by (solve_hyps_max HP3P9P12P13eq HP3P9P12P13M).
try assert(HP9P12mtmp : rk(P9 :: P12 :: nil) >= 2) by (solve_hyps_min HP9P12eq HP9P12m).
assert(Hincl : incl (P9 :: P12 :: nil) (list_inter (P2 :: P9 :: P12 :: nil) (P3 :: P9 :: P12 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P3 :: P9 :: P12 :: P13 :: nil) (P2 :: P9 :: P12 :: P3 :: P9 :: P12 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P9 :: P12 :: P3 :: P9 :: P12 :: P13 :: nil) ((P2 :: P9 :: P12 :: nil) ++ (P3 :: P9 :: P12 :: P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P2 :: P9 :: P12 :: nil) (P3 :: P9 :: P12 :: P13 :: nil) (P9 :: P12 :: nil) 2 3 2 HP2P9P12Mtmp HP3P9P12P13Mtmp HP9P12mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP2P3P9P12M;assert(HP2P3P9P12M : rk(P2 :: P3 :: P9 :: P12 :: nil) <= 3).
{
try assert(HP3Mtmp : rk(P3 :: nil) <= 1) by (solve_hyps_max HP3eq HP3M).
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P3 :: nil) (P2 :: P9 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P3 :: P9 :: P12 :: nil) (P3 :: P2 :: P9 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P2 :: P9 :: P12 :: nil) ((P3 :: nil) ++ (P2 :: P9 :: P12 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P3 :: nil) (P2 :: P9 :: P12 :: nil) (nil) 1 2 0 HP3Mtmp HP2P9P12Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP2P3P9P12m;assert(HP2P3P9P12m : rk(P2 :: P3 :: P9 :: P12 :: nil) >= 2).
{
try assert(HP2P3mtmp : rk(P2 :: P3 :: nil) >= 2) by (solve_hyps_min HP2P3eq HP2P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: nil) (P2 :: P3 :: P9 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: nil) (P2 :: P3 :: P9 :: P12 :: nil) 2 2 HP2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P9P12m;assert(HP2P3P9P12m : rk(P2 :: P3 :: P9 :: P12 :: nil) >= 3).
{
try assert(HP2P3P12mtmp : rk(P2 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP2P3P12eq HP2P3P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: P12 :: nil) (P2 :: P3 :: P9 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: P12 :: nil) (P2 :: P3 :: P9 :: P12 :: nil) 3 3 HP2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P9m;assert(HP2P3P9m : rk(P2 :: P3 :: P9 :: nil) >= 2).
{
try assert(HP2P3mtmp : rk(P2 :: P3 :: nil) >= 2) by (solve_hyps_min HP2P3eq HP2P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: nil) (P2 :: P3 :: P9 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: nil) (P2 :: P3 :: P9 :: nil) 2 2 HP2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P9m;assert(HP2P3P9m : rk(P2 :: P3 :: P9 :: nil) >= 3).
{
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(HP2P3P9P12mtmp : rk(P2 :: P3 :: P9 :: P12 :: nil) >= 3) by (solve_hyps_min HP2P3P9P12eq HP2P3P9P12m).
try assert(HP2P9mtmp : rk(P2 :: P9 :: nil) >= 2) by (solve_hyps_min HP2P9eq HP2P9m).
assert(Hincl : incl (P2 :: P9 :: nil) (list_inter (P2 :: P3 :: P9 :: nil) (P2 :: P9 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P3 :: P9 :: P12 :: nil) (P2 :: P3 :: P9 :: P2 :: P9 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P3 :: P9 :: P2 :: P9 :: P12 :: nil) ((P2 :: P3 :: P9 :: nil) ++ (P2 :: P9 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP2P3P9P12mtmp;try rewrite HT2 in HP2P3P9P12mtmp.
assert(HT := rule_2 (P2 :: P3 :: P9 :: nil) (P2 :: P9 :: P12 :: nil) (P2 :: P9 :: nil) 3 2 2 HP2P3P9P12mtmp HP2P9mtmp HP2P9P12Mtmp Hincl); apply HT.
}
try clear HP2P3P9P13m;assert(HP2P3P9P13m : rk(P2 :: P3 :: P9 :: P13 :: nil) >= 2).
{
try assert(HP2P3mtmp : rk(P2 :: P3 :: nil) >= 2) by (solve_hyps_min HP2P3eq HP2P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: nil) (P2 :: P3 :: P9 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: nil) (P2 :: P3 :: P9 :: P13 :: nil) 2 2 HP2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P9P13m;assert(HP2P3P9P13m : rk(P2 :: P3 :: P9 :: P13 :: nil) >= 3).
{
try assert(HP2P3P9mtmp : rk(P2 :: P3 :: P9 :: nil) >= 3) by (solve_hyps_min HP2P3P9eq HP2P3P9m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: P9 :: nil) (P2 :: P3 :: P9 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: P9 :: nil) (P2 :: P3 :: P9 :: P13 :: nil) 3 3 HP2P3P9mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P9P13M;assert(HP2P3P9P13M : rk(P2 :: P3 :: P9 :: P13 :: nil) <= 3).
{
try assert(HP2P3P9P12P13Mtmp : rk(P2 :: P3 :: P9 :: P12 :: P13 :: nil) <= 3) by (solve_hyps_max HP2P3P9P12P13eq HP2P3P9P12P13M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: P9 :: P13 :: nil) (P2 :: P3 :: P9 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P2 :: P3 :: P9 :: P13 :: nil) (P2 :: P3 :: P9 :: P12 :: P13 :: nil) 3 3 HP2P3P9P12P13Mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P8P9P10P11P13P14m;assert(HP4P5P6P8P9P10P11P13P14m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP4P5mtmp : rk(P4 :: P5 :: nil) >= 2) by (solve_hyps_min HP4P5eq HP4P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: P14 :: nil) 2 2 HP4P5mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P8P9P10P11P13P14m;assert(HP4P5P6P8P9P10P11P13P14m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: P14 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P8P9P10P11P13P14m;assert(HP4P5P6P8P9P10P11P13P14m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: P14 :: nil) >= 4).
{
try assert(HP4P5P6P11mtmp : rk(P4 :: P5 :: P6 :: P11 :: nil) >= 4) by (solve_hyps_min HP4P5P6P11eq HP4P5P6P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: P11 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: P11 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: P14 :: nil) 4 4 HP4P5P6P11mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P8P9P10P13P14m;assert(HP5P6P8P9P10P13P14m : rk(P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: nil) (P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: nil) (P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: P14 :: nil) 2 2 HP5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P8P9P10P13P14m;assert(HP5P6P8P9P10P13P14m : rk(P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP4P5P6P8P9P10P11P13P14mtmp : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: P14 :: nil) >= 4) by (solve_hyps_min HP4P5P6P8P9P10P11P13P14eq HP4P5P6P8P9P10P11P13P14m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: P14 :: nil) (P4 :: P8 :: P11 :: P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: P14 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP4P5P6P8P9P10P11P13P14mtmp;try rewrite HT2 in HP4P5P6P8P9P10P11P13P14mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: P14 :: nil) (P8 :: nil) 4 1 2 HP4P5P6P8P9P10P11P13P14mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP8P9P10P13P14m;assert(HP8P9P10P13P14m : rk(P8 :: P9 :: P10 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP5P6P13Mtmp : rk(P5 :: P6 :: P13 :: nil) <= 2) by (solve_hyps_max HP5P6P13eq HP5P6P13M).
try assert(HP5P6P8P9P10P13P14mtmp : rk(P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: P14 :: nil) >= 3) by (solve_hyps_min HP5P6P8P9P10P13P14eq HP5P6P8P9P10P13P14m).
try assert(HP13mtmp : rk(P13 :: nil) >= 1) by (solve_hyps_min HP13eq HP13m).
assert(Hincl : incl (P13 :: nil) (list_inter (P5 :: P6 :: P13 :: nil) (P8 :: P9 :: P10 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: P14 :: nil) (P5 :: P6 :: P13 :: P8 :: P9 :: P10 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P6 :: P13 :: P8 :: P9 :: P10 :: P13 :: P14 :: nil) ((P5 :: P6 :: P13 :: nil) ++ (P8 :: P9 :: P10 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP5P6P8P9P10P13P14mtmp;try rewrite HT2 in HP5P6P8P9P10P13P14mtmp.
assert(HT := rule_4 (P5 :: P6 :: P13 :: nil) (P8 :: P9 :: P10 :: P13 :: P14 :: nil) (P13 :: nil) 3 1 2 HP5P6P8P9P10P13P14mtmp HP13mtmp HP5P6P13Mtmp Hincl); apply HT.
}
try clear HP8P9P10P13P14M;assert(HP8P9P10P13P14M : rk(P8 :: P9 :: P10 :: P13 :: P14 :: nil) <= 3).
{
try assert(HP9P10P13Mtmp : rk(P9 :: P10 :: P13 :: nil) <= 2) by (solve_hyps_max HP9P10P13eq HP9P10P13M).
try assert(HP8P10P14Mtmp : rk(P8 :: P10 :: P14 :: nil) <= 2) by (solve_hyps_max HP8P10P14eq HP8P10P14M).
try assert(HP10mtmp : rk(P10 :: nil) >= 1) by (solve_hyps_min HP10eq HP10m).
assert(Hincl : incl (P10 :: nil) (list_inter (P9 :: P10 :: P13 :: nil) (P8 :: P10 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P8 :: P9 :: P10 :: P13 :: P14 :: nil) (P9 :: P10 :: P13 :: P8 :: P10 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P9 :: P10 :: P13 :: P8 :: P10 :: P14 :: nil) ((P9 :: P10 :: P13 :: nil) ++ (P8 :: P10 :: P14 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P9 :: P10 :: P13 :: nil) (P8 :: P10 :: P14 :: nil) (P10 :: nil) 2 2 1 HP9P10P13Mtmp HP8P10P14Mtmp HP10mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP4P5P6P8P9P11P13P14m;assert(HP4P5P6P8P9P11P13P14m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP4P5mtmp : rk(P4 :: P5 :: nil) >= 2) by (solve_hyps_min HP4P5eq HP4P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: nil) 2 2 HP4P5mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P8P9P11P13P14m;assert(HP4P5P6P8P9P11P13P14m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P8P9P11P13P14m;assert(HP4P5P6P8P9P11P13P14m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: nil) >= 4).
{
try assert(HP4P5P6P11mtmp : rk(P4 :: P5 :: P6 :: P11 :: nil) >= 4) by (solve_hyps_min HP4P5P6P11eq HP4P5P6P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: P11 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: P11 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: nil) 4 4 HP4P5P6P11mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P8P9P13P14m;assert(HP5P6P8P9P13P14m : rk(P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: nil) 2 2 HP5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P8P9P13P14m;assert(HP5P6P8P9P13P14m : rk(P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP4P5P6P8P9P11P13P14mtmp : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: nil) >= 4) by (solve_hyps_min HP4P5P6P8P9P11P13P14eq HP4P5P6P8P9P11P13P14m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: nil) (P4 :: P8 :: P11 :: P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP4P5P6P8P9P11P13P14mtmp;try rewrite HT2 in HP4P5P6P8P9P11P13P14mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: nil) (P8 :: nil) 4 1 2 HP4P5P6P8P9P11P13P14mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP8P9P13P14m;assert(HP8P9P13P14m : rk(P8 :: P9 :: P13 :: P14 :: nil) >= 2).
{
try assert(HP5P6P13Mtmp : rk(P5 :: P6 :: P13 :: nil) <= 2) by (solve_hyps_max HP5P6P13eq HP5P6P13M).
try assert(HP5P6P8P9P13P14mtmp : rk(P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: nil) >= 3) by (solve_hyps_min HP5P6P8P9P13P14eq HP5P6P8P9P13P14m).
try assert(HP13mtmp : rk(P13 :: nil) >= 1) by (solve_hyps_min HP13eq HP13m).
assert(Hincl : incl (P13 :: nil) (list_inter (P5 :: P6 :: P13 :: nil) (P8 :: P9 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: nil) (P5 :: P6 :: P13 :: P8 :: P9 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P6 :: P13 :: P8 :: P9 :: P13 :: P14 :: nil) ((P5 :: P6 :: P13 :: nil) ++ (P8 :: P9 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP5P6P8P9P13P14mtmp;try rewrite HT2 in HP5P6P8P9P13P14mtmp.
assert(HT := rule_4 (P5 :: P6 :: P13 :: nil) (P8 :: P9 :: P13 :: P14 :: nil) (P13 :: nil) 3 1 2 HP5P6P8P9P13P14mtmp HP13mtmp HP5P6P13Mtmp Hincl); apply HT.
}
try clear HP8P9P13P14M;assert(HP8P9P13P14M : rk(P8 :: P9 :: P13 :: P14 :: nil) <= 3).
{
try assert(HP8P9P10P13P14Mtmp : rk(P8 :: P9 :: P10 :: P13 :: P14 :: nil) <= 3) by (solve_hyps_max HP8P9P10P13P14eq HP8P9P10P13P14M).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P8 :: P9 :: P13 :: P14 :: nil) (P8 :: P9 :: P10 :: P13 :: P14 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_6 (P8 :: P9 :: P13 :: P14 :: nil) (P8 :: P9 :: P10 :: P13 :: P14 :: nil) 3 3 HP8P9P10P13P14Mtmp Hcomp Hincl); apply HT.
}
try clear HP8P9P13P14m;assert(HP8P9P13P14m : rk(P8 :: P9 :: P13 :: P14 :: nil) >= 3).
{
try assert(HP2P3P9P13Mtmp : rk(P2 :: P3 :: P9 :: P13 :: nil) <= 3) by (solve_hyps_max HP2P3P9P13eq HP2P3P9P13M).
try assert(HP2P3P8P9P13P14mtmp : rk(P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil) >= 4) by (solve_hyps_min HP2P3P8P9P13P14eq HP2P3P8P9P13P14m).
try assert(HP9P13mtmp : rk(P9 :: P13 :: nil) >= 2) by (solve_hyps_min HP9P13eq HP9P13m).
assert(Hincl : incl (P9 :: P13 :: nil) (list_inter (P2 :: P3 :: P9 :: P13 :: nil) (P8 :: P9 :: P13 :: P14 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: nil) (P2 :: P3 :: P9 :: P13 :: P8 :: P9 :: P13 :: P14 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P3 :: P9 :: P13 :: P8 :: P9 :: P13 :: P14 :: nil) ((P2 :: P3 :: P9 :: P13 :: nil) ++ (P8 :: P9 :: P13 :: P14 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP2P3P8P9P13P14mtmp;try rewrite HT2 in HP2P3P8P9P13P14mtmp.
assert(HT := rule_4 (P2 :: P3 :: P9 :: P13 :: nil) (P8 :: P9 :: P13 :: P14 :: nil) (P9 :: P13 :: nil) 4 2 3 HP2P3P8P9P13P14mtmp HP9P13mtmp HP2P3P9P13Mtmp Hincl); apply HT.
}
try clear HP1P2P3P8P9P12P13P15m;assert(HP1P2P3P8P9P12P13P15m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P9P12P13P15m;assert(HP1P2P3P8P9P12P13P15m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P9P12P13P15m;assert(HP1P2P3P8P9P12P13P15m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) >= 4).
{
try assert(HP1P2P3P12mtmp : rk(P1 :: P2 :: P3 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P12eq HP1P2P3P12m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) 4 4 HP1P2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P8P9P12P13P15m;assert(HP2P3P8P9P12P13P15m : rk(P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) >= 2).
{
try assert(HP2P3mtmp : rk(P2 :: P3 :: nil) >= 2) by (solve_hyps_min HP2P3eq HP2P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) 2 2 HP2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P8P9P12P13P15m;assert(HP2P3P8P9P12P13P15m : rk(P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) >= 3).
{
try assert(HP2P3P12mtmp : rk(P2 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP2P3P12eq HP2P3P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) 3 3 HP2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P8P9P12P13P15m;assert(HP2P3P8P9P12P13P15m : rk(P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) >= 4).
{
try assert(HP1P8P12Mtmp : rk(P1 :: P8 :: P12 :: nil) <= 2) by (solve_hyps_max HP1P8P12eq HP1P8P12M).
try assert(HP1P2P3P8P9P12P13P15mtmp : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8P9P12P13P15eq HP1P2P3P8P9P12P13P15m).
try assert(HP8P12mtmp : rk(P8 :: P12 :: nil) >= 2) by (solve_hyps_min HP8P12eq HP8P12m).
assert(Hincl : incl (P8 :: P12 :: nil) (list_inter (P1 :: P8 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) (P1 :: P8 :: P12 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P12 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) ((P1 :: P8 :: P12 :: nil) ++ (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P8P9P12P13P15mtmp;try rewrite HT2 in HP1P2P3P8P9P12P13P15mtmp.
assert(HT := rule_4 (P1 :: P8 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) (P8 :: P12 :: nil) 4 2 2 HP1P2P3P8P9P12P13P15mtmp HP8P12mtmp HP1P8P12Mtmp Hincl); apply HT.
}
try clear HP2P3P8P9P13P15m;assert(HP2P3P8P9P13P15m : rk(P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil) >= 2).
{
try assert(HP2P3mtmp : rk(P2 :: P3 :: nil) >= 2) by (solve_hyps_min HP2P3eq HP2P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil) 2 2 HP2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P8P9P13P15m;assert(HP2P3P8P9P13P15m : rk(P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil) >= 3).
{
try assert(HP1P8P12Mtmp : rk(P1 :: P8 :: P12 :: nil) <= 2) by (solve_hyps_max HP1P8P12eq HP1P8P12M).
try assert(HP1P2P3P8P9P12P13P15mtmp : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8P9P12P13P15eq HP1P2P3P8P9P12P13P15m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P1 :: P8 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) (P1 :: P8 :: P12 :: P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P12 :: P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil) ((P1 :: P8 :: P12 :: nil) ++ (P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P8P9P12P13P15mtmp;try rewrite HT2 in HP1P2P3P8P9P12P13P15mtmp.
assert(HT := rule_4 (P1 :: P8 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil) (P8 :: nil) 4 1 2 HP1P2P3P8P9P12P13P15mtmp HP8mtmp HP1P8P12Mtmp Hincl); apply HT.
}
try clear HP2P3P8P9P13P15m;assert(HP2P3P8P9P13P15m : rk(P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil) >= 4).
{
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(HP2P3P8P9P12P13P15mtmp : rk(P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) >= 4) by (solve_hyps_min HP2P3P8P9P12P13P15eq HP2P3P8P9P12P13P15m).
try assert(HP2P9mtmp : rk(P2 :: P9 :: nil) >= 2) by (solve_hyps_min HP2P9eq HP2P9m).
assert(Hincl : incl (P2 :: P9 :: nil) (list_inter (P2 :: P9 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P15 :: nil) (P2 :: P9 :: P12 :: P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P9 :: P12 :: P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil) ((P2 :: P9 :: P12 :: nil) ++ (P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP2P3P8P9P12P13P15mtmp;try rewrite HT2 in HP2P3P8P9P12P13P15mtmp.
assert(HT := rule_4 (P2 :: P9 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil) (P2 :: P9 :: nil) 4 2 2 HP2P3P8P9P12P13P15mtmp HP2P9mtmp HP2P9P12Mtmp Hincl); apply HT.
}
try clear HP4P5P6P8P9P11P13P15m;assert(HP4P5P6P8P9P11P13P15m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P15 :: nil) >= 2).
{
try assert(HP4P5mtmp : rk(P4 :: P5 :: nil) >= 2) by (solve_hyps_min HP4P5eq HP4P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P15 :: nil) 2 2 HP4P5mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P8P9P11P13P15m;assert(HP4P5P6P8P9P11P13P15m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P15 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P15 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P8P9P11P13P15m;assert(HP4P5P6P8P9P11P13P15m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P15 :: nil) >= 4).
{
try assert(HP4P5P6P11mtmp : rk(P4 :: P5 :: P6 :: P11 :: nil) >= 4) by (solve_hyps_min HP4P5P6P11eq HP4P5P6P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: P11 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: P11 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P15 :: nil) 4 4 HP4P5P6P11mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P8P9P13P15m;assert(HP5P6P8P9P13P15m : rk(P5 :: P6 :: P8 :: P9 :: P13 :: P15 :: nil) >= 2).
{
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: P15 :: nil) 2 2 HP5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P8P9P13P15m;assert(HP5P6P8P9P13P15m : rk(P5 :: P6 :: P8 :: P9 :: P13 :: P15 :: nil) >= 3).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP4P5P6P8P9P11P13P15mtmp : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P15 :: nil) >= 4) by (solve_hyps_min HP4P5P6P8P9P11P13P15eq HP4P5P6P8P9P11P13P15m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P15 :: nil) (P4 :: P8 :: P11 :: P5 :: P6 :: P8 :: P9 :: P13 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P5 :: P6 :: P8 :: P9 :: P13 :: P15 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P5 :: P6 :: P8 :: P9 :: P13 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP4P5P6P8P9P11P13P15mtmp;try rewrite HT2 in HP4P5P6P8P9P11P13P15mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: P15 :: nil) (P8 :: nil) 4 1 2 HP4P5P6P8P9P11P13P15mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP8P9P13P15M;assert(HP8P9P13P15M : rk(P8 :: P9 :: P13 :: P15 :: nil) <= 3).
{
try assert(HP13Mtmp : rk(P13 :: nil) <= 1) by (solve_hyps_max HP13eq HP13M).
try assert(HP8P9P15Mtmp : rk(P8 :: P9 :: P15 :: nil) <= 2) by (solve_hyps_max HP8P9P15eq HP8P9P15M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P13 :: nil) (P8 :: P9 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P8 :: P9 :: P13 :: P15 :: nil) (P13 :: P8 :: P9 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P13 :: P8 :: P9 :: P15 :: nil) ((P13 :: nil) ++ (P8 :: P9 :: P15 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P13 :: nil) (P8 :: P9 :: P15 :: nil) (nil) 1 2 0 HP13Mtmp HP8P9P15Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP8P9P13P15m;assert(HP8P9P13P15m : rk(P8 :: P9 :: P13 :: P15 :: nil) >= 2).
{
try assert(HP5P6P13Mtmp : rk(P5 :: P6 :: P13 :: nil) <= 2) by (solve_hyps_max HP5P6P13eq HP5P6P13M).
try assert(HP5P6P8P9P13P15mtmp : rk(P5 :: P6 :: P8 :: P9 :: P13 :: P15 :: nil) >= 3) by (solve_hyps_min HP5P6P8P9P13P15eq HP5P6P8P9P13P15m).
try assert(HP13mtmp : rk(P13 :: nil) >= 1) by (solve_hyps_min HP13eq HP13m).
assert(Hincl : incl (P13 :: nil) (list_inter (P5 :: P6 :: P13 :: nil) (P8 :: P9 :: P13 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P5 :: P6 :: P8 :: P9 :: P13 :: P15 :: nil) (P5 :: P6 :: P13 :: P8 :: P9 :: P13 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P6 :: P13 :: P8 :: P9 :: P13 :: P15 :: nil) ((P5 :: P6 :: P13 :: nil) ++ (P8 :: P9 :: P13 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP5P6P8P9P13P15mtmp;try rewrite HT2 in HP5P6P8P9P13P15mtmp.
assert(HT := rule_4 (P5 :: P6 :: P13 :: nil) (P8 :: P9 :: P13 :: P15 :: nil) (P13 :: nil) 3 1 2 HP5P6P8P9P13P15mtmp HP13mtmp HP5P6P13Mtmp Hincl); apply HT.
}
try clear HP8P9P13P15m;assert(HP8P9P13P15m : rk(P8 :: P9 :: P13 :: P15 :: nil) >= 3).
{
try assert(HP2P3P9P13Mtmp : rk(P2 :: P3 :: P9 :: P13 :: nil) <= 3) by (solve_hyps_max HP2P3P9P13eq HP2P3P9P13M).
try assert(HP2P3P8P9P13P15mtmp : rk(P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil) >= 4) by (solve_hyps_min HP2P3P8P9P13P15eq HP2P3P8P9P13P15m).
try assert(HP9P13mtmp : rk(P9 :: P13 :: nil) >= 2) by (solve_hyps_min HP9P13eq HP9P13m).
assert(Hincl : incl (P9 :: P13 :: nil) (list_inter (P2 :: P3 :: P9 :: P13 :: nil) (P8 :: P9 :: P13 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P3 :: P8 :: P9 :: P13 :: P15 :: nil) (P2 :: P3 :: P9 :: P13 :: P8 :: P9 :: P13 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P3 :: P9 :: P13 :: P8 :: P9 :: P13 :: P15 :: nil) ((P2 :: P3 :: P9 :: P13 :: nil) ++ (P8 :: P9 :: P13 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP2P3P8P9P13P15mtmp;try rewrite HT2 in HP2P3P8P9P13P15mtmp.
assert(HT := rule_4 (P2 :: P3 :: P9 :: P13 :: nil) (P8 :: P9 :: P13 :: P15 :: nil) (P9 :: P13 :: nil) 4 2 3 HP2P3P8P9P13P15mtmp HP9P13mtmp HP2P3P9P13Mtmp Hincl); apply HT.
}
try clear HP1P2P3P8P9P10P12P13m;assert(HP1P2P3P8P9P10P12P13m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P9P10P12P13m;assert(HP1P2P3P8P9P10P12P13m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P9P10P12P13m;assert(HP1P2P3P8P9P10P12P13m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 4).
{
try assert(HP1P2P3P12mtmp : rk(P1 :: P2 :: P3 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P12eq HP1P2P3P12m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) 4 4 HP1P2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P8P9P10P12P13m;assert(HP2P3P8P9P10P12P13m : rk(P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP2P3mtmp : rk(P2 :: P3 :: nil) >= 2) by (solve_hyps_min HP2P3eq HP2P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: nil) (P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: nil) (P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) 2 2 HP2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P8P9P10P12P13m;assert(HP2P3P8P9P10P12P13m : rk(P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 3).
{
try assert(HP2P3P12mtmp : rk(P2 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP2P3P12eq HP2P3P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) 3 3 HP2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P8P9P10P12P13m;assert(HP2P3P8P9P10P12P13m : rk(P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 4).
{
try assert(HP1P8P12Mtmp : rk(P1 :: P8 :: P12 :: nil) <= 2) by (solve_hyps_max HP1P8P12eq HP1P8P12M).
try assert(HP1P2P3P8P9P10P12P13mtmp : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8P9P10P12P13eq HP1P2P3P8P9P10P12P13m).
try assert(HP8P12mtmp : rk(P8 :: P12 :: nil) >= 2) by (solve_hyps_min HP8P12eq HP8P12m).
assert(Hincl : incl (P8 :: P12 :: nil) (list_inter (P1 :: P8 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) (P1 :: P8 :: P12 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P12 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) ((P1 :: P8 :: P12 :: nil) ++ (P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P8P9P10P12P13mtmp;try rewrite HT2 in HP1P2P3P8P9P10P12P13mtmp.
assert(HT := rule_4 (P1 :: P8 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) (P8 :: P12 :: nil) 4 2 2 HP1P2P3P8P9P10P12P13mtmp HP8P12mtmp HP1P8P12Mtmp Hincl); apply HT.
}
try clear HP1P3P8P9P10P12P13m;assert(HP1P3P8P9P10P12P13m : rk(P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P9P10P12P13m;assert(HP1P3P8P9P10P12P13m : rk(P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 3).
{
try assert(HP1P3P12mtmp : rk(P1 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P3P12eq HP1P3P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: P12 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: P12 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) 3 3 HP1P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP3P6P8P9P10P11P12P13m;assert(HP3P6P8P9P10P11P12P13m : rk(P3 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP3P6mtmp : rk(P3 :: P6 :: nil) >= 2) by (solve_hyps_min HP3P6eq HP3P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P3 :: P6 :: nil) (P3 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P3 :: P6 :: nil) (P3 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil) 2 2 HP3P6mtmp Hcomp Hincl); apply HT.
}
try clear HP3P6P8P9P10P11P12P13m;assert(HP3P6P8P9P10P11P12P13m : rk(P3 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil) >= 3).
{
try assert(HP3P6P11mtmp : rk(P3 :: P6 :: P11 :: nil) >= 3) by (solve_hyps_min HP3P6P11eq HP3P6P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P3 :: P6 :: P11 :: nil) (P3 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P3 :: P6 :: P11 :: nil) (P3 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil) 3 3 HP3P6P11mtmp Hcomp Hincl); apply HT.
}
try clear HP3P8P9P10P12P13m;assert(HP3P8P9P10P12P13m : rk(P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 2).
{
try assert(HP6P10P11Mtmp : rk(P6 :: P10 :: P11 :: nil) <= 2) by (solve_hyps_max HP6P10P11eq HP6P10P11M).
try assert(HP3P6P8P9P10P11P12P13mtmp : rk(P3 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil) >= 3) by (solve_hyps_min HP3P6P8P9P10P11P12P13eq HP3P6P8P9P10P11P12P13m).
try assert(HP10mtmp : rk(P10 :: nil) >= 1) by (solve_hyps_min HP10eq HP10m).
assert(Hincl : incl (P10 :: nil) (list_inter (P6 :: P10 :: P11 :: nil) (P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P3 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: nil) (P6 :: P10 :: P11 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P6 :: P10 :: P11 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) ((P6 :: P10 :: P11 :: nil) ++ (P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP3P6P8P9P10P11P12P13mtmp;try rewrite HT2 in HP3P6P8P9P10P11P12P13mtmp.
assert(HT := rule_4 (P6 :: P10 :: P11 :: nil) (P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) (P10 :: nil) 3 1 2 HP3P6P8P9P10P11P12P13mtmp HP10mtmp HP6P10P11Mtmp Hincl); apply HT.
}
try clear HP3P8P9P10P12P13m;assert(HP3P8P9P10P12P13m : rk(P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 3).
{
try assert(HP1P8P12Mtmp : rk(P1 :: P8 :: P12 :: nil) <= 2) by (solve_hyps_max HP1P8P12eq HP1P8P12M).
try assert(HP1P3P8P9P10P12P13mtmp : rk(P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 3) by (solve_hyps_min HP1P3P8P9P10P12P13eq HP1P3P8P9P10P12P13m).
try assert(HP8P12mtmp : rk(P8 :: P12 :: nil) >= 2) by (solve_hyps_min HP8P12eq HP8P12m).
assert(Hincl : incl (P8 :: P12 :: nil) (list_inter (P1 :: P8 :: P12 :: nil) (P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) (P1 :: P8 :: P12 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P12 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) ((P1 :: P8 :: P12 :: nil) ++ (P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P3P8P9P10P12P13mtmp;try rewrite HT2 in HP1P3P8P9P10P12P13mtmp.
assert(HT := rule_4 (P1 :: P8 :: P12 :: nil) (P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) (P8 :: P12 :: nil) 3 2 2 HP1P3P8P9P10P12P13mtmp HP8P12mtmp HP1P8P12Mtmp Hincl); apply HT.
}
try clear HP3P8P9P10P12P13m;assert(HP3P8P9P10P12P13m : rk(P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 4).
{
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(HP2P3P8P9P10P12P13mtmp : rk(P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 4) by (solve_hyps_min HP2P3P8P9P10P12P13eq HP2P3P8P9P10P12P13m).
try assert(HP9P12mtmp : rk(P9 :: P12 :: nil) >= 2) by (solve_hyps_min HP9P12eq HP9P12m).
assert(Hincl : incl (P9 :: P12 :: nil) (list_inter (P2 :: P9 :: P12 :: nil) (P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) (P2 :: P9 :: P12 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P9 :: P12 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) ((P2 :: P9 :: P12 :: nil) ++ (P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP2P3P8P9P10P12P13mtmp;try rewrite HT2 in HP2P3P8P9P10P12P13mtmp.
assert(HT := rule_4 (P2 :: P9 :: P12 :: nil) (P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) (P9 :: P12 :: nil) 4 2 2 HP2P3P8P9P10P12P13mtmp HP9P12mtmp HP2P9P12Mtmp Hincl); apply HT.
}
try clear HP4P5P6P8P9P10P11P13m;assert(HP4P5P6P8P9P10P11P13m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: nil) >= 2).
{
try assert(HP4P5mtmp : rk(P4 :: P5 :: nil) >= 2) by (solve_hyps_min HP4P5eq HP4P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: nil) 2 2 HP4P5mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P8P9P10P11P13m;assert(HP4P5P6P8P9P10P11P13m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P8P9P10P11P13m;assert(HP4P5P6P8P9P10P11P13m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: nil) >= 4).
{
try assert(HP4P5P6P11mtmp : rk(P4 :: P5 :: P6 :: P11 :: nil) >= 4) by (solve_hyps_min HP4P5P6P11eq HP4P5P6P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: P11 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: P11 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: nil) 4 4 HP4P5P6P11mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P8P9P10P13m;assert(HP5P6P8P9P10P13m : rk(P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: nil) >= 2).
{
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: nil) (P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: nil) (P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: nil) 2 2 HP5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P8P9P10P13m;assert(HP5P6P8P9P10P13m : rk(P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: nil) >= 3).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP4P5P6P8P9P10P11P13mtmp : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: nil) >= 4) by (solve_hyps_min HP4P5P6P8P9P10P11P13eq HP4P5P6P8P9P10P11P13m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P13 :: nil) (P4 :: P8 :: P11 :: P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP4P5P6P8P9P10P11P13mtmp;try rewrite HT2 in HP4P5P6P8P9P10P11P13mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: nil) (P8 :: nil) 4 1 2 HP4P5P6P8P9P10P11P13mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP8P9P10P13M;assert(HP8P9P10P13M : rk(P8 :: P9 :: P10 :: P13 :: nil) <= 3).
{
try assert(HP8Mtmp : rk(P8 :: nil) <= 1) by (solve_hyps_max HP8eq HP8M).
try assert(HP9P10P13Mtmp : rk(P9 :: P10 :: P13 :: nil) <= 2) by (solve_hyps_max HP9P10P13eq HP9P10P13M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P8 :: nil) (P9 :: P10 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P8 :: P9 :: P10 :: P13 :: nil) (P8 :: P9 :: P10 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P8 :: P9 :: P10 :: P13 :: nil) ((P8 :: nil) ++ (P9 :: P10 :: P13 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P8 :: nil) (P9 :: P10 :: P13 :: nil) (nil) 1 2 0 HP8Mtmp HP9P10P13Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP8P9P10P13m;assert(HP8P9P10P13m : rk(P8 :: P9 :: P10 :: P13 :: nil) >= 2).
{
try assert(HP5P6P13Mtmp : rk(P5 :: P6 :: P13 :: nil) <= 2) by (solve_hyps_max HP5P6P13eq HP5P6P13M).
try assert(HP5P6P8P9P10P13mtmp : rk(P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: nil) >= 3) by (solve_hyps_min HP5P6P8P9P10P13eq HP5P6P8P9P10P13m).
try assert(HP13mtmp : rk(P13 :: nil) >= 1) by (solve_hyps_min HP13eq HP13m).
assert(Hincl : incl (P13 :: nil) (list_inter (P5 :: P6 :: P13 :: nil) (P8 :: P9 :: P10 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P5 :: P6 :: P8 :: P9 :: P10 :: P13 :: nil) (P5 :: P6 :: P13 :: P8 :: P9 :: P10 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P6 :: P13 :: P8 :: P9 :: P10 :: P13 :: nil) ((P5 :: P6 :: P13 :: nil) ++ (P8 :: P9 :: P10 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP5P6P8P9P10P13mtmp;try rewrite HT2 in HP5P6P8P9P10P13mtmp.
assert(HT := rule_4 (P5 :: P6 :: P13 :: nil) (P8 :: P9 :: P10 :: P13 :: nil) (P13 :: nil) 3 1 2 HP5P6P8P9P10P13mtmp HP13mtmp HP5P6P13Mtmp Hincl); apply HT.
}
try clear HP8P9P10P13m;assert(HP8P9P10P13m : rk(P8 :: P9 :: P10 :: P13 :: nil) >= 3).
{
try assert(HP3P10P12Mtmp : rk(P3 :: P10 :: P12 :: nil) <= 2) by (solve_hyps_max HP3P10P12eq HP3P10P12M).
try assert(HP3P8P9P10P12P13mtmp : rk(P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) >= 4) by (solve_hyps_min HP3P8P9P10P12P13eq HP3P8P9P10P12P13m).
try assert(HP10mtmp : rk(P10 :: nil) >= 1) by (solve_hyps_min HP10eq HP10m).
assert(Hincl : incl (P10 :: nil) (list_inter (P3 :: P10 :: P12 :: nil) (P8 :: P9 :: P10 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: nil) (P3 :: P10 :: P12 :: P8 :: P9 :: P10 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P10 :: P12 :: P8 :: P9 :: P10 :: P13 :: nil) ((P3 :: P10 :: P12 :: nil) ++ (P8 :: P9 :: P10 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP3P8P9P10P12P13mtmp;try rewrite HT2 in HP3P8P9P10P12P13mtmp.
assert(HT := rule_4 (P3 :: P10 :: P12 :: nil) (P8 :: P9 :: P10 :: P13 :: nil) (P10 :: nil) 4 1 2 HP3P8P9P10P12P13mtmp HP10mtmp HP3P10P12Mtmp Hincl); apply HT.
}
try clear HP4P5P6P8P9P11P13m;assert(HP4P5P6P8P9P11P13m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: nil) >= 2).
{
try assert(HP4P5mtmp : rk(P4 :: P5 :: nil) >= 2) by (solve_hyps_min HP4P5eq HP4P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: nil) 2 2 HP4P5mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P8P9P11P13m;assert(HP4P5P6P8P9P11P13m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P8P9P11P13m;assert(HP4P5P6P8P9P11P13m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: nil) >= 4).
{
try assert(HP4P5P6P11mtmp : rk(P4 :: P5 :: P6 :: P11 :: nil) >= 4) by (solve_hyps_min HP4P5P6P11eq HP4P5P6P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: P11 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: P11 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: nil) 4 4 HP4P5P6P11mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P8P9P13m;assert(HP5P6P8P9P13m : rk(P5 :: P6 :: P8 :: P9 :: P13 :: nil) >= 2).
{
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: nil) 2 2 HP5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P8P9P13m;assert(HP5P6P8P9P13m : rk(P5 :: P6 :: P8 :: P9 :: P13 :: nil) >= 3).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP4P5P6P8P9P11P13mtmp : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: nil) >= 4) by (solve_hyps_min HP4P5P6P8P9P11P13eq HP4P5P6P8P9P11P13m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: nil) (P4 :: P8 :: P11 :: P5 :: P6 :: P8 :: P9 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P5 :: P6 :: P8 :: P9 :: P13 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P5 :: P6 :: P8 :: P9 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP4P5P6P8P9P11P13mtmp;try rewrite HT2 in HP4P5P6P8P9P11P13mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: nil) (P8 :: nil) 4 1 2 HP4P5P6P8P9P11P13mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP8P9P13m;assert(HP8P9P13m : rk(P8 :: P9 :: P13 :: nil) >= 2).
{
try assert(HP5P6P13Mtmp : rk(P5 :: P6 :: P13 :: nil) <= 2) by (solve_hyps_max HP5P6P13eq HP5P6P13M).
try assert(HP5P6P8P9P13mtmp : rk(P5 :: P6 :: P8 :: P9 :: P13 :: nil) >= 3) by (solve_hyps_min HP5P6P8P9P13eq HP5P6P8P9P13m).
try assert(HP13mtmp : rk(P13 :: nil) >= 1) by (solve_hyps_min HP13eq HP13m).
assert(Hincl : incl (P13 :: nil) (list_inter (P5 :: P6 :: P13 :: nil) (P8 :: P9 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P5 :: P6 :: P8 :: P9 :: P13 :: nil) (P5 :: P6 :: P13 :: P8 :: P9 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P6 :: P13 :: P8 :: P9 :: P13 :: nil) ((P5 :: P6 :: P13 :: nil) ++ (P8 :: P9 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP5P6P8P9P13mtmp;try rewrite HT2 in HP5P6P8P9P13mtmp.
assert(HT := rule_4 (P5 :: P6 :: P13 :: nil) (P8 :: P9 :: P13 :: nil) (P13 :: nil) 3 1 2 HP5P6P8P9P13mtmp HP13mtmp HP5P6P13Mtmp Hincl); apply HT.
}
try clear HP8P9P13m;assert(HP8P9P13m : rk(P8 :: P9 :: P13 :: nil) >= 3).
{
try assert(HP9P10P13Mtmp : rk(P9 :: P10 :: P13 :: nil) <= 2) by (solve_hyps_max HP9P10P13eq HP9P10P13M).
try assert(HP8P9P10P13mtmp : rk(P8 :: P9 :: P10 :: P13 :: nil) >= 3) by (solve_hyps_min HP8P9P10P13eq HP8P9P10P13m).
try assert(HP9P13mtmp : rk(P9 :: P13 :: nil) >= 2) by (solve_hyps_min HP9P13eq HP9P13m).
assert(Hincl : incl (P9 :: P13 :: nil) (list_inter (P8 :: P9 :: P13 :: nil) (P9 :: P10 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P8 :: P9 :: P10 :: P13 :: nil) (P8 :: P9 :: P13 :: P9 :: P10 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P8 :: P9 :: P13 :: P9 :: P10 :: P13 :: nil) ((P8 :: P9 :: P13 :: nil) ++ (P9 :: P10 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP8P9P10P13mtmp;try rewrite HT2 in HP8P9P10P13mtmp.
assert(HT := rule_2 (P8 :: P9 :: P13 :: nil) (P9 :: P10 :: P13 :: nil) (P9 :: P13 :: nil) 3 2 2 HP8P9P10P13mtmp HP9P13mtmp HP9P10P13Mtmp Hincl); apply HT.
}
try clear HP1P2P3P8P9P12P13P14P15m;assert(HP1P2P3P8P9P12P13P14P15m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P9P12P13P14P15m;assert(HP1P2P3P8P9P12P13P14P15m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P9P12P13P14P15m;assert(HP1P2P3P8P9P12P13P14P15m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4).
{
try assert(HP1P2P3P12mtmp : rk(P1 :: P2 :: P3 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P12eq HP1P2P3P12m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) 4 4 HP1P2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P8P9P12P13P14P15m;assert(HP2P3P8P9P12P13P14P15m : rk(P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP2P3mtmp : rk(P2 :: P3 :: nil) >= 2) by (solve_hyps_min HP2P3eq HP2P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) 2 2 HP2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P8P9P12P13P14P15m;assert(HP2P3P8P9P12P13P14P15m : rk(P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP2P3P12mtmp : rk(P2 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP2P3P12eq HP2P3P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) 3 3 HP2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P8P9P12P13P14P15m;assert(HP2P3P8P9P12P13P14P15m : rk(P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4).
{
try assert(HP1P8P12Mtmp : rk(P1 :: P8 :: P12 :: nil) <= 2) by (solve_hyps_max HP1P8P12eq HP1P8P12M).
try assert(HP1P2P3P8P9P12P13P14P15mtmp : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8P9P12P13P14P15eq HP1P2P3P8P9P12P13P14P15m).
try assert(HP8P12mtmp : rk(P8 :: P12 :: nil) >= 2) by (solve_hyps_min HP8P12eq HP8P12m).
assert(Hincl : incl (P8 :: P12 :: nil) (list_inter (P1 :: P8 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) (P1 :: P8 :: P12 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P12 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) ((P1 :: P8 :: P12 :: nil) ++ (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P8P9P12P13P14P15mtmp;try rewrite HT2 in HP1P2P3P8P9P12P13P14P15mtmp.
assert(HT := rule_4 (P1 :: P8 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) (P8 :: P12 :: nil) 4 2 2 HP1P2P3P8P9P12P13P14P15mtmp HP8P12mtmp HP1P8P12Mtmp Hincl); apply HT.
}
try clear HP2P3P8P9P13P14P15m;assert(HP2P3P8P9P13P14P15m : rk(P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP2P3mtmp : rk(P2 :: P3 :: nil) >= 2) by (solve_hyps_min HP2P3eq HP2P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P2 :: P3 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P2 :: P3 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) 2 2 HP2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP2P3P8P9P13P14P15m;assert(HP2P3P8P9P13P14P15m : rk(P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP1P8P12Mtmp : rk(P1 :: P8 :: P12 :: nil) <= 2) by (solve_hyps_max HP1P8P12eq HP1P8P12M).
try assert(HP1P2P3P8P9P12P13P14P15mtmp : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8P9P12P13P14P15eq HP1P2P3P8P9P12P13P14P15m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P1 :: P8 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) (P1 :: P8 :: P12 :: P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P12 :: P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) ((P1 :: P8 :: P12 :: nil) ++ (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P8P9P12P13P14P15mtmp;try rewrite HT2 in HP1P2P3P8P9P12P13P14P15mtmp.
assert(HT := rule_4 (P1 :: P8 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) (P8 :: nil) 4 1 2 HP1P2P3P8P9P12P13P14P15mtmp HP8mtmp HP1P8P12Mtmp Hincl); apply HT.
}
try clear HP2P3P8P9P13P14P15m;assert(HP2P3P8P9P13P14P15m : rk(P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) >= 4).
{
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(HP2P3P8P9P12P13P14P15mtmp : rk(P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP2P3P8P9P12P13P14P15eq HP2P3P8P9P12P13P14P15m).
try assert(HP2P9mtmp : rk(P2 :: P9 :: nil) >= 2) by (solve_hyps_min HP2P9eq HP2P9m).
assert(Hincl : incl (P2 :: P9 :: nil) (list_inter (P2 :: P9 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P3 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) (P2 :: P9 :: P12 :: P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P9 :: P12 :: P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) ((P2 :: P9 :: P12 :: nil) ++ (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP2P3P8P9P12P13P14P15mtmp;try rewrite HT2 in HP2P3P8P9P12P13P14P15mtmp.
assert(HT := rule_4 (P2 :: P9 :: P12 :: nil) (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) (P2 :: P9 :: nil) 4 2 2 HP2P3P8P9P12P13P14P15mtmp HP2P9mtmp HP2P9P12Mtmp Hincl); apply HT.
}
try clear HP4P5P6P8P9P11P13P14P15m;assert(HP4P5P6P8P9P11P13P14P15m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP4P5mtmp : rk(P4 :: P5 :: nil) >= 2) by (solve_hyps_min HP4P5eq HP4P5m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil) 2 2 HP4P5mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P8P9P11P13P14P15m;assert(HP4P5P6P8P9P11P13P14P15m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP4P5P6mtmp : rk(P4 :: P5 :: P6 :: nil) >= 3) by (solve_hyps_min HP4P5P6eq HP4P5P6m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil) 3 3 HP4P5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP4P5P6P8P9P11P13P14P15m;assert(HP4P5P6P8P9P11P13P14P15m : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil) >= 4).
{
try assert(HP4P5P6P11mtmp : rk(P4 :: P5 :: P6 :: P11 :: nil) >= 4) by (solve_hyps_min HP4P5P6P11eq HP4P5P6P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P4 :: P5 :: P6 :: P11 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P4 :: P5 :: P6 :: P11 :: nil) (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil) 4 4 HP4P5P6P11mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P8P9P13P14P15m;assert(HP5P6P8P9P13P14P15m : rk(P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) 2 2 HP5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP5P6P8P9P13P14P15m;assert(HP5P6P8P9P13P14P15m : rk(P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP4P5P6P8P9P11P13P14P15mtmp : rk(P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP4P5P6P8P9P11P13P14P15eq HP4P5P6P8P9P11P13P14P15m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P4 :: P5 :: P6 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil) (P4 :: P8 :: P11 :: P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP4P5P6P8P9P11P13P14P15mtmp;try rewrite HT2 in HP4P5P6P8P9P11P13P14P15mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) (P8 :: nil) 4 1 2 HP4P5P6P8P9P11P13P14P15mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP8P9P13P14P15m;assert(HP8P9P13P14P15m : rk(P8 :: P9 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP5P6P13Mtmp : rk(P5 :: P6 :: P13 :: nil) <= 2) by (solve_hyps_max HP5P6P13eq HP5P6P13M).
try assert(HP5P6P8P9P13P14P15mtmp : rk(P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) >= 3) by (solve_hyps_min HP5P6P8P9P13P14P15eq HP5P6P8P9P13P14P15m).
try assert(HP13mtmp : rk(P13 :: nil) >= 1) by (solve_hyps_min HP13eq HP13m).
assert(Hincl : incl (P13 :: nil) (list_inter (P5 :: P6 :: P13 :: nil) (P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P5 :: P6 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) (P5 :: P6 :: P13 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P6 :: P13 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) ((P5 :: P6 :: P13 :: nil) ++ (P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP5P6P8P9P13P14P15mtmp;try rewrite HT2 in HP5P6P8P9P13P14P15mtmp.
assert(HT := rule_4 (P5 :: P6 :: P13 :: nil) (P8 :: P9 :: P13 :: P14 :: P15 :: nil) (P13 :: nil) 3 1 2 HP5P6P8P9P13P14P15mtmp HP13mtmp HP5P6P13Mtmp Hincl); apply HT.
}
try clear HP8P9P13P14P15m;assert(HP8P9P13P14P15m : rk(P8 :: P9 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP2P3P9P13Mtmp : rk(P2 :: P3 :: P9 :: P13 :: nil) <= 3) by (solve_hyps_max HP2P3P9P13eq HP2P3P9P13M).
try assert(HP2P3P8P9P13P14P15mtmp : rk(P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP2P3P8P9P13P14P15eq HP2P3P8P9P13P14P15m).
try assert(HP9P13mtmp : rk(P9 :: P13 :: nil) >= 2) by (solve_hyps_min HP9P13eq HP9P13m).
assert(Hincl : incl (P9 :: P13 :: nil) (list_inter (P2 :: P3 :: P9 :: P13 :: nil) (P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P2 :: P3 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) (P2 :: P3 :: P9 :: P13 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P3 :: P9 :: P13 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) ((P2 :: P3 :: P9 :: P13 :: nil) ++ (P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP2P3P8P9P13P14P15mtmp;try rewrite HT2 in HP2P3P8P9P13P14P15mtmp.
assert(HT := rule_4 (P2 :: P3 :: P9 :: P13 :: nil) (P8 :: P9 :: P13 :: P14 :: P15 :: nil) (P9 :: P13 :: nil) 4 2 3 HP2P3P8P9P13P14P15mtmp HP9P13mtmp HP2P3P9P13Mtmp Hincl); apply HT.
}
try clear HP8P9P13P14P15M;assert(HP8P9P13P14P15M : rk(P8 :: P9 :: P13 :: P14 :: P15 :: nil) <= 3).
{
try assert(HP8P9P13P14Mtmp : rk(P8 :: P9 :: P13 :: P14 :: nil) <= 3) by (solve_hyps_max HP8P9P13P14eq HP8P9P13P14M).
try assert(HP8P9P13P15Mtmp : rk(P8 :: P9 :: P13 :: P15 :: nil) <= 3) by (solve_hyps_max HP8P9P13P15eq HP8P9P13P15M).
try assert(HP8P9P13mtmp : rk(P8 :: P9 :: P13 :: nil) >= 3) by (solve_hyps_min HP8P9P13eq HP8P9P13m).
assert(Hincl : incl (P8 :: P9 :: P13 :: nil) (list_inter (P8 :: P9 :: P13 :: P14 :: nil) (P8 :: P9 :: P13 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P8 :: P9 :: P13 :: P14 :: P15 :: nil) (P8 :: P9 :: P13 :: P14 :: P8 :: P9 :: P13 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P8 :: P9 :: P13 :: P14 :: P8 :: P9 :: P13 :: P15 :: nil) ((P8 :: P9 :: P13 :: P14 :: nil) ++ (P8 :: P9 :: P13 :: P15 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P8 :: P9 :: P13 :: P14 :: nil) (P8 :: P9 :: P13 :: P15 :: nil) (P8 :: P9 :: P13 :: nil) 3 3 3 HP8P9P13P14Mtmp HP8P9P13P15Mtmp HP8P9P13mtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P2P3P8P9P10P12P13P14P15m;assert(HP1P2P3P8P9P10P12P13P14P15m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P9P10P12P13P14P15m;assert(HP1P2P3P8P9P10P12P13P14P15m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P9P10P12P13P14P15m;assert(HP1P2P3P8P9P10P12P13P14P15m : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4).
{
try assert(HP1P2P3P12mtmp : rk(P1 :: P2 :: P3 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P12eq HP1P2P3P12m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P12 :: nil) (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) 4 4 HP1P2P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P9P10P12P13P14P15m;assert(HP1P3P8P9P10P12P13P14P15m : rk(P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP1P3mtmp : rk(P1 :: P3 :: nil) >= 2) by (solve_hyps_min HP1P3eq HP1P3m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) 2 2 HP1P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P9P10P12P13P14P15m;assert(HP1P3P8P9P10P12P13P14P15m : rk(P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP1P3P12mtmp : rk(P1 :: P3 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P3P12eq HP1P3P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P3 :: P12 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P3 :: P12 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) 3 3 HP1P3P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P3P8P9P10P12P13P14P15m;assert(HP1P3P8P9P10P12P13P14P15m : rk(P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4).
{
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(HP1P2P3P8P9P10P12P13P14P15mtmp : rk(P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8P9P10P12P13P14P15eq HP1P2P3P8P9P10P12P13P14P15m).
try assert(HP9P12mtmp : rk(P9 :: P12 :: nil) >= 2) by (solve_hyps_min HP9P12eq HP9P12m).
assert(Hincl : incl (P9 :: P12 :: nil) (list_inter (P2 :: P9 :: P12 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) (P2 :: P9 :: P12 :: P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P9 :: P12 :: P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) ((P2 :: P9 :: P12 :: nil) ++ (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P8P9P10P12P13P14P15mtmp;try rewrite HT2 in HP1P2P3P8P9P10P12P13P14P15mtmp.
assert(HT := rule_4 (P2 :: P9 :: P12 :: nil) (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) (P9 :: P12 :: nil) 4 2 2 HP1P2P3P8P9P10P12P13P14P15mtmp HP9P12mtmp HP2P9P12Mtmp Hincl); apply HT.
}
try clear HP1P2P5P6P8P9P10P11P12P13P14P15m;assert(HP1P2P5P6P8P9P10P11P12P13P14P15m : rk(P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P5P6P8P9P10P11P12P13P14P15m;assert(HP1P2P5P6P8P9P10P11P12P13P14P15m : rk(P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP1P2P11mtmp : rk(P1 :: P2 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P2P11eq HP1P2P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P11 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P11 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) 3 3 HP1P2P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P5P6P8P9P10P11P12P13P14P15m;assert(HP1P2P5P6P8P9P10P11P12P13P14P15m : rk(P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4).
{
try assert(HP1P2P5P6P8P11mtmp : rk(P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P5P6P8P11eq HP1P2P5P6P8P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P5 :: P6 :: P8 :: P11 :: nil) (P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) 4 4 HP1P2P5P6P8P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P5P6P8P9P10P11P12P13P14P15m;assert(HP1P5P6P8P9P10P11P12P13P14P15m : rk(P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP5P6mtmp : rk(P5 :: P6 :: nil) >= 2) by (solve_hyps_min HP5P6eq HP5P6m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: nil) (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: nil) (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) 2 2 HP5P6mtmp Hcomp Hincl); apply HT.
}
try clear HP1P5P6P8P9P10P11P12P13P14P15m;assert(HP1P5P6P8P9P10P11P12P13P14P15m : rk(P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP5P6P11mtmp : rk(P5 :: P6 :: P11 :: nil) >= 3) by (solve_hyps_min HP5P6P11eq HP5P6P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P5 :: P6 :: P11 :: nil) (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P5 :: P6 :: P11 :: nil) (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) 3 3 HP5P6P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P5P6P8P9P10P11P12P13P14P15m;assert(HP1P5P6P8P9P10P11P12P13P14P15m : rk(P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4).
{
try assert(HP2P5P11P12Mtmp : rk(P2 :: P5 :: P11 :: P12 :: nil) <= 3) by (solve_hyps_max HP2P5P11P12eq HP2P5P11P12M).
try assert(HP1P2P5P6P8P9P10P11P12P13P14P15mtmp : rk(P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P2P5P6P8P9P10P11P12P13P14P15eq HP1P2P5P6P8P9P10P11P12P13P14P15m).
try assert(HP5P11P12mtmp : rk(P5 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP5P11P12eq HP5P11P12m).
assert(Hincl : incl (P5 :: P11 :: P12 :: nil) (list_inter (P2 :: P5 :: P11 :: P12 :: nil) (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) (P2 :: P5 :: P11 :: P12 :: P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P2 :: P5 :: P11 :: P12 :: P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) ((P2 :: P5 :: P11 :: P12 :: nil) ++ (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P5P6P8P9P10P11P12P13P14P15mtmp;try rewrite HT2 in HP1P2P5P6P8P9P10P11P12P13P14P15mtmp.
assert(HT := rule_4 (P2 :: P5 :: P11 :: P12 :: nil) (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) (P5 :: P11 :: P12 :: nil) 4 3 3 HP1P2P5P6P8P9P10P11P12P13P14P15mtmp HP5P11P12mtmp HP2P5P11P12Mtmp Hincl); apply HT.
}
try clear HP1P4P8P9P10P11P12P13P14P15m;assert(HP1P4P8P9P10P11P12P13P14P15m : rk(P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P8P9P10P11P12P13P14P15m;assert(HP1P4P8P9P10P11P12P13P14P15m : rk(P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP1P4P11mtmp : rk(P1 :: P4 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P4P11eq HP1P4P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) 3 3 HP1P4P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P8P9P10P12P13P14P15m;assert(HP1P8P9P10P12P13P14P15m : rk(P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP1P4P8P9P10P11P12P13P14P15mtmp : rk(P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) >= 3) by (solve_hyps_min HP1P4P8P9P10P11P12P13P14P15eq HP1P4P8P9P10P11P12P13P14P15m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) (P4 :: P8 :: P11 :: P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P4P8P9P10P11P12P13P14P15mtmp;try rewrite HT2 in HP1P4P8P9P10P11P12P13P14P15mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) (P8 :: nil) 3 1 2 HP1P4P8P9P10P11P12P13P14P15mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP1P8P9P10P12P13P14P15m;assert(HP1P8P9P10P12P13P14P15m : rk(P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP5P6P9P10P11P13Mtmp : rk(P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil) <= 3) by (solve_hyps_max HP5P6P9P10P11P13eq HP5P6P9P10P11P13M).
try assert(HP1P5P6P8P9P10P11P12P13P14P15mtmp : rk(P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P5P6P8P9P10P11P12P13P14P15eq HP1P5P6P8P9P10P11P12P13P14P15m).
try assert(HP9P10P13mtmp : rk(P9 :: P10 :: P13 :: nil) >= 2) by (solve_hyps_min HP9P10P13eq HP9P10P13m).
assert(Hincl : incl (P9 :: P10 :: P13 :: nil) (list_inter (P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil) (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P5 :: P6 :: P8 :: P9 :: P10 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) (P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) ((P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil) ++ (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P5P6P8P9P10P11P12P13P14P15mtmp;try rewrite HT2 in HP1P5P6P8P9P10P11P12P13P14P15mtmp.
assert(HT := rule_4 (P5 :: P6 :: P9 :: P10 :: P11 :: P13 :: nil) (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) (P9 :: P10 :: P13 :: nil) 4 2 3 HP1P5P6P8P9P10P11P12P13P14P15mtmp HP9P10P13mtmp HP5P6P9P10P11P13Mtmp Hincl); apply HT.
}
try clear HP1P8P9P10P12P13P14P15m;assert(HP1P8P9P10P12P13P14P15m : rk(P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4).
{
try assert(HP3P10P12Mtmp : rk(P3 :: P10 :: P12 :: nil) <= 2) by (solve_hyps_max HP3P10P12eq HP3P10P12M).
try assert(HP1P3P8P9P10P12P13P14P15mtmp : rk(P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P3P8P9P10P12P13P14P15eq HP1P3P8P9P10P12P13P14P15m).
try assert(HP10P12mtmp : rk(P10 :: P12 :: nil) >= 2) by (solve_hyps_min HP10P12eq HP10P12m).
assert(Hincl : incl (P10 :: P12 :: nil) (list_inter (P3 :: P10 :: P12 :: nil) (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) (P3 :: P10 :: P12 :: P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P3 :: P10 :: P12 :: P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) ((P3 :: P10 :: P12 :: nil) ++ (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P3P8P9P10P12P13P14P15mtmp;try rewrite HT2 in HP1P3P8P9P10P12P13P14P15mtmp.
assert(HT := rule_4 (P3 :: P10 :: P12 :: nil) (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) (P10 :: P12 :: nil) 4 2 2 HP1P3P8P9P10P12P13P14P15mtmp HP10P12mtmp HP3P10P12Mtmp Hincl); apply HT.
}
try clear HP1P2P9P12M;assert(HP1P2P9P12M : rk(P1 :: P2 :: P9 :: P12 :: nil) <= 3).
{
try assert(HP1Mtmp : rk(P1 :: nil) <= 1) by (solve_hyps_max HP1eq HP1M).
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P1 :: nil) (P2 :: P9 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P9 :: P12 :: nil) (P1 :: P2 :: P9 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P9 :: P12 :: nil) ((P1 :: nil) ++ (P2 :: P9 :: P12 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P1 :: nil) (P2 :: P9 :: P12 :: nil) (nil) 1 2 0 HP1Mtmp HP2P9P12Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P2P9P12m;assert(HP1P2P9P12m : rk(P1 :: P2 :: P9 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P9 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P9 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P9P12m;assert(HP1P2P9P12m : rk(P1 :: P2 :: P9 :: P12 :: nil) >= 3).
{
try assert(HP1P2P12mtmp : rk(P1 :: P2 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P2P12eq HP1P2P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P12 :: nil) (P1 :: P2 :: P9 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P12 :: nil) (P1 :: P2 :: P9 :: P12 :: nil) 3 3 HP1P2P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P9P12m;assert(HP1P9P12m : rk(P1 :: P9 :: P12 :: nil) >= 2).
{
try assert(HP1P12mtmp : rk(P1 :: P12 :: nil) >= 2) by (solve_hyps_min HP1P12eq HP1P12m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P12 :: nil) (P1 :: P9 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P12 :: nil) (P1 :: P9 :: P12 :: nil) 2 2 HP1P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P9P12m;assert(HP1P9P12m : rk(P1 :: P9 :: P12 :: nil) >= 3).
{
try assert(HP2P9P12Mtmp : rk(P2 :: P9 :: P12 :: nil) <= 2) by (solve_hyps_max HP2P9P12eq HP2P9P12M).
try assert(HP1P2P9P12mtmp : rk(P1 :: P2 :: P9 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P2P9P12eq HP1P2P9P12m).
try assert(HP9P12mtmp : rk(P9 :: P12 :: nil) >= 2) by (solve_hyps_min HP9P12eq HP9P12m).
assert(Hincl : incl (P9 :: P12 :: nil) (list_inter (P1 :: P9 :: P12 :: nil) (P2 :: P9 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P9 :: P12 :: nil) (P1 :: P9 :: P12 :: P2 :: P9 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P9 :: P12 :: P2 :: P9 :: P12 :: nil) ((P1 :: P9 :: P12 :: nil) ++ (P2 :: P9 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P9P12mtmp;try rewrite HT2 in HP1P2P9P12mtmp.
assert(HT := rule_2 (P1 :: P9 :: P12 :: nil) (P2 :: P9 :: P12 :: nil) (P9 :: P12 :: nil) 3 2 2 HP1P2P9P12mtmp HP9P12mtmp HP2P9P12Mtmp Hincl); apply HT.
}
try clear HP1P4P8P9P11P12P13P14P15m;assert(HP1P4P8P9P11P12P13P14P15m : rk(P1 :: P4 :: P8 :: P9 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P9 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P9 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P8P9P11P12P13P14P15m;assert(HP1P4P8P9P11P12P13P14P15m : rk(P1 :: P4 :: P8 :: P9 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP1P4P11mtmp : rk(P1 :: P4 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P4P11eq HP1P4P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P9 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P9 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) 3 3 HP1P4P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P8P9P12P13P14P15m;assert(HP1P8P9P12P13P14P15m : rk(P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP1P4P8P9P11P12P13P14P15mtmp : rk(P1 :: P4 :: P8 :: P9 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) >= 3) by (solve_hyps_min HP1P4P8P9P11P12P13P14P15eq HP1P4P8P9P11P12P13P14P15m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P8 :: P9 :: P11 :: P12 :: P13 :: P14 :: P15 :: nil) (P4 :: P8 :: P11 :: P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P4P8P9P11P12P13P14P15mtmp;try rewrite HT2 in HP1P4P8P9P11P12P13P14P15mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) (P8 :: nil) 3 1 2 HP1P4P8P9P11P12P13P14P15mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP1P8P9P12P13P14P15m;assert(HP1P8P9P12P13P14P15m : rk(P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP1P9P12mtmp : rk(P1 :: P9 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P9P12eq HP1P9P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P9 :: P12 :: nil) (P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P9 :: P12 :: nil) (P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) 3 3 HP1P9P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P8P9P12P13P14P15m;assert(HP1P8P9P12P13P14P15m : rk(P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4).
{
try assert(HP9P10P13Mtmp : rk(P9 :: P10 :: P13 :: nil) <= 2) by (solve_hyps_max HP9P10P13eq HP9P10P13M).
try assert(HP1P8P9P10P12P13P14P15mtmp : rk(P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P8P9P10P12P13P14P15eq HP1P8P9P10P12P13P14P15m).
try assert(HP9P13mtmp : rk(P9 :: P13 :: nil) >= 2) by (solve_hyps_min HP9P13eq HP9P13m).
assert(Hincl : incl (P9 :: P13 :: nil) (list_inter (P9 :: P10 :: P13 :: nil) (P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) (P9 :: P10 :: P13 :: P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P9 :: P10 :: P13 :: P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) ((P9 :: P10 :: P13 :: nil) ++ (P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P8P9P10P12P13P14P15mtmp;try rewrite HT2 in HP1P8P9P10P12P13P14P15mtmp.
assert(HT := rule_4 (P9 :: P10 :: P13 :: nil) (P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) (P9 :: P13 :: nil) 4 2 2 HP1P8P9P10P12P13P14P15mtmp HP9P13mtmp HP9P10P13Mtmp Hincl); apply HT.
}
try clear HP1P2P3P8P13m;assert(HP1P2P3P8P13m : rk(P1 :: P2 :: P3 :: P8 :: P13 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P8 :: P13 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P13m;assert(HP1P2P3P8P13m : rk(P1 :: P2 :: P3 :: P8 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P8 :: P13 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P8P13m;assert(HP1P2P3P8P13m : rk(P1 :: P2 :: P3 :: P8 :: P13 :: nil) >= 4).
{
try assert(HP1P2P3P8mtmp : rk(P1 :: P2 :: P3 :: P8 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8eq HP1P2P3P8m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P8 :: nil) (P1 :: P2 :: P3 :: P8 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P8 :: nil) (P1 :: P2 :: P3 :: P8 :: P13 :: nil) 4 4 HP1P2P3P8mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P8P11P13m;assert(HP1P4P8P11P13m : rk(P1 :: P4 :: P8 :: P11 :: P13 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P11 :: P13 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P8P11P13m;assert(HP1P4P8P11P13m : rk(P1 :: P4 :: P8 :: P11 :: P13 :: nil) >= 3).
{
try assert(HP1P4P11mtmp : rk(P1 :: P4 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P4P11eq HP1P4P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P11 :: P13 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P11 :: P13 :: nil) 3 3 HP1P4P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P8P13m;assert(HP1P8P13m : rk(P1 :: P8 :: P13 :: nil) >= 2).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP1P4P8P11P13mtmp : rk(P1 :: P4 :: P8 :: P11 :: P13 :: nil) >= 3) by (solve_hyps_min HP1P4P8P11P13eq HP1P4P8P11P13m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P8 :: P11 :: P13 :: nil) (P4 :: P8 :: P11 :: P1 :: P8 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P1 :: P8 :: P13 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P1 :: P8 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P4P8P11P13mtmp;try rewrite HT2 in HP1P4P8P11P13mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P13 :: nil) (P8 :: nil) 3 1 2 HP1P4P8P11P13mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP1P8P13m;assert(HP1P8P13m : rk(P1 :: P8 :: P13 :: nil) >= 3).
{
try assert(HP1P2P3P13Mtmp : rk(P1 :: P2 :: P3 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P2P3P13eq HP1P2P3P13M).
try assert(HP1P2P3P8P13mtmp : rk(P1 :: P2 :: P3 :: P8 :: P13 :: nil) >= 4) by (solve_hyps_min HP1P2P3P8P13eq HP1P2P3P8P13m).
try assert(HP1P13mtmp : rk(P1 :: P13 :: nil) >= 2) by (solve_hyps_min HP1P13eq HP1P13m).
assert(Hincl : incl (P1 :: P13 :: nil) (list_inter (P1 :: P2 :: P3 :: P13 :: nil) (P1 :: P8 :: P13 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P8 :: P13 :: nil) (P1 :: P2 :: P3 :: P13 :: P1 :: P8 :: P13 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P13 :: P1 :: P8 :: P13 :: nil) ((P1 :: P2 :: P3 :: P13 :: nil) ++ (P1 :: P8 :: P13 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P8P13mtmp;try rewrite HT2 in HP1P2P3P8P13mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P13 :: nil) (P1 :: P8 :: P13 :: nil) (P1 :: P13 :: nil) 4 2 3 HP1P2P3P8P13mtmp HP1P13mtmp HP1P2P3P13Mtmp Hincl); apply HT.
}
try clear HP1P2P3P4P8P10P11P12m;assert(HP1P2P3P4P8P10P11P12m : rk(P1 :: P2 :: P3 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P2mtmp : rk(P1 :: P2 :: nil) >= 2) by (solve_hyps_min HP1P2eq HP1P2m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) 2 2 HP1P2mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P8P10P11P12m;assert(HP1P2P3P4P8P10P11P12m : rk(P1 :: P2 :: P3 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3mtmp : rk(P1 :: P2 :: P3 :: nil) >= 3) by (solve_hyps_min HP1P2P3eq HP1P2P3m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) 3 3 HP1P2P3mtmp Hcomp Hincl); apply HT.
}
try clear HP1P2P3P4P8P10P11P12m;assert(HP1P2P3P4P8P10P11P12m : rk(P1 :: P2 :: P3 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) >= 4).
{
try assert(HP1P2P3P11mtmp : rk(P1 :: P2 :: P3 :: P11 :: nil) >= 4) by (solve_hyps_min HP1P2P3P11eq HP1P2P3P11m).
assert(Hcomp : 4 <= 4) by (repeat constructor).
assert(Hincl : incl (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P2 :: P3 :: P11 :: nil) (P1 :: P2 :: P3 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) 4 4 HP1P2P3P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P8P10P11P12m;assert(HP1P4P8P10P11P12m : rk(P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P8P10P11P12m;assert(HP1P4P8P10P11P12m : rk(P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) >= 3).
{
try assert(HP1P2P3P4P11Mtmp : rk(P1 :: P2 :: P3 :: P4 :: P11 :: nil) <= 4) by (solve_hyps_max HP1P2P3P4P11eq HP1P2P3P4P11M).
try assert(HP1P2P3P4P8P10P11P12mtmp : rk(P1 :: P2 :: P3 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) >= 4) by (solve_hyps_min HP1P2P3P4P8P10P11P12eq HP1P2P3P4P8P10P11P12m).
try assert(HP1P4P11mtmp : rk(P1 :: P4 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P4P11eq HP1P4P11m).
assert(Hincl : incl (P1 :: P4 :: P11 :: nil) (list_inter (P1 :: P2 :: P3 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P2 :: P3 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) (P1 :: P2 :: P3 :: P4 :: P11 :: P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P2 :: P3 :: P4 :: P11 :: P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) ((P1 :: P2 :: P3 :: P4 :: P11 :: nil) ++ (P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P2P3P4P8P10P11P12mtmp;try rewrite HT2 in HP1P2P3P4P8P10P11P12mtmp.
assert(HT := rule_4 (P1 :: P2 :: P3 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) (P1 :: P4 :: P11 :: nil) 4 3 4 HP1P2P3P4P8P10P11P12mtmp HP1P4P11mtmp HP1P2P3P4P11Mtmp Hincl); apply HT.
}
try clear HP1P8P10P12M;assert(HP1P8P10P12M : rk(P1 :: P8 :: P10 :: P12 :: nil) <= 3).
{
try assert(HP10Mtmp : rk(P10 :: nil) <= 1) by (solve_hyps_max HP10eq HP10M).
try assert(HP1P8P12Mtmp : rk(P1 :: P8 :: P12 :: nil) <= 2) by (solve_hyps_max HP1P8P12eq HP1P8P12M).
try assert(Hmtmp : rk(nil) >= 0) by (solve_hyps_min Hnuleq Hm).
assert(Hincl : incl (nil) (list_inter (P10 :: nil) (P1 :: P8 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P8 :: P10 :: P12 :: nil) (P10 :: P1 :: P8 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P10 :: P1 :: P8 :: P12 :: nil) ((P10 :: nil) ++ (P1 :: P8 :: P12 :: nil))) by (clear_all_rk;my_inO).
assert(HT := rule_1 (P10 :: nil) (P1 :: P8 :: P12 :: nil) (nil) 1 2 0 HP10Mtmp HP1P8P12Mtmp Hmtmp Hincl);
rewrite <-HT2 in HT;try rewrite <-HT1 in HT;apply HT.
}
try clear HP1P8P10P12m;assert(HP1P8P10P12m : rk(P1 :: P8 :: P10 :: P12 :: nil) >= 2).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP1P4P8P10P11P12mtmp : rk(P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P4P8P10P11P12eq HP1P4P8P10P11P12m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P10 :: P12 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P8 :: P10 :: P11 :: P12 :: nil) (P4 :: P8 :: P11 :: P1 :: P8 :: P10 :: P12 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P1 :: P8 :: P10 :: P12 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P1 :: P8 :: P10 :: P12 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P4P8P10P11P12mtmp;try rewrite HT2 in HP1P4P8P10P11P12mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P10 :: P12 :: nil) (P8 :: nil) 3 1 2 HP1P4P8P10P11P12mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP1P8P10P12m;assert(HP1P8P10P12m : rk(P1 :: P8 :: P10 :: P12 :: nil) >= 3).
{
try assert(HP1P10P12mtmp : rk(P1 :: P10 :: P12 :: nil) >= 3) by (solve_hyps_min HP1P10P12eq HP1P10P12m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P10 :: P12 :: nil) (P1 :: P8 :: P10 :: P12 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P10 :: P12 :: nil) (P1 :: P8 :: P10 :: P12 :: nil) 3 3 HP1P10P12mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P8P9P11P13P14P15m;assert(HP1P4P8P9P11P13P14P15m : rk(P1 :: P4 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP1P4mtmp : rk(P1 :: P4 :: nil) >= 2) by (solve_hyps_min HP1P4eq HP1P4m).
assert(Hcomp : 2 <= 2) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: nil) (P1 :: P4 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil) 2 2 HP1P4mtmp Hcomp Hincl); apply HT.
}
try clear HP1P4P8P9P11P13P14P15m;assert(HP1P4P8P9P11P13P14P15m : rk(P1 :: P4 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP1P4P11mtmp : rk(P1 :: P4 :: P11 :: nil) >= 3) by (solve_hyps_min HP1P4P11eq HP1P4P11m).
assert(Hcomp : 3 <= 3) by (repeat constructor).
assert(Hincl : incl (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil)) by (repeat clear_all_rk;my_inO).
assert(HT := rule_5 (P1 :: P4 :: P11 :: nil) (P1 :: P4 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil) 3 3 HP1P4P11mtmp Hcomp Hincl); apply HT.
}
try clear HP1P8P9P13P14P15m;assert(HP1P8P9P13P14P15m : rk(P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP4P8P11Mtmp : rk(P4 :: P8 :: P11 :: nil) <= 2) by (solve_hyps_max HP4P8P11eq HP4P8P11M).
try assert(HP1P4P8P9P11P13P14P15mtmp : rk(P1 :: P4 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil) >= 3) by (solve_hyps_min HP1P4P8P9P11P13P14P15eq HP1P4P8P9P11P13P14P15m).
try assert(HP8mtmp : rk(P8 :: nil) >= 1) by (solve_hyps_min HP8eq HP8m).
assert(Hincl : incl (P8 :: nil) (list_inter (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P4 :: P8 :: P9 :: P11 :: P13 :: P14 :: P15 :: nil) (P4 :: P8 :: P11 :: P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P4 :: P8 :: P11 :: P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) ((P4 :: P8 :: P11 :: nil) ++ (P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P4P8P9P11P13P14P15mtmp;try rewrite HT2 in HP1P4P8P9P11P13P14P15mtmp.
assert(HT := rule_4 (P4 :: P8 :: P11 :: nil) (P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) (P8 :: nil) 3 1 2 HP1P4P8P9P11P13P14P15mtmp HP8mtmp HP4P8P11Mtmp Hincl); apply HT.
}
try clear HP1P8P9P13P14P15m;assert(HP1P8P9P13P14P15m : rk(P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) >= 3).
{
try assert(HP1P8P10P12Mtmp : rk(P1 :: P8 :: P10 :: P12 :: nil) <= 3) by (solve_hyps_max HP1P8P10P12eq HP1P8P10P12M).
try assert(HP1P8P9P10P12P13P14P15mtmp : rk(P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P8P9P10P12P13P14P15eq HP1P8P9P10P12P13P14P15m).
try assert(HP1P8mtmp : rk(P1 :: P8 :: nil) >= 2) by (solve_hyps_min HP1P8eq HP1P8m).
assert(Hincl : incl (P1 :: P8 :: nil) (list_inter (P1 :: P8 :: P10 :: P12 :: nil) (P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P8 :: P9 :: P10 :: P12 :: P13 :: P14 :: P15 :: nil) (P1 :: P8 :: P10 :: P12 :: P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P10 :: P12 :: P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) ((P1 :: P8 :: P10 :: P12 :: nil) ++ (P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P8P9P10P12P13P14P15mtmp;try rewrite HT2 in HP1P8P9P10P12P13P14P15mtmp.
assert(HT := rule_4 (P1 :: P8 :: P10 :: P12 :: nil) (P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) (P1 :: P8 :: nil) 4 2 3 HP1P8P9P10P12P13P14P15mtmp HP1P8mtmp HP1P8P10P12Mtmp Hincl); apply HT.
}
try clear HP1P8P9P13P14P15m;assert(HP1P8P9P13P14P15m : rk(P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) >= 4).
{
try assert(HP1P8P12P13Mtmp : rk(P1 :: P8 :: P12 :: P13 :: nil) <= 3) by (solve_hyps_max HP1P8P12P13eq HP1P8P12P13M).
try assert(HP1P8P9P12P13P14P15mtmp : rk(P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P8P9P12P13P14P15eq HP1P8P9P12P13P14P15m).
try assert(HP1P8P13mtmp : rk(P1 :: P8 :: P13 :: nil) >= 3) by (solve_hyps_min HP1P8P13eq HP1P8P13m).
assert(Hincl : incl (P1 :: P8 :: P13 :: nil) (list_inter (P1 :: P8 :: P12 :: P13 :: nil) (P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P8 :: P9 :: P12 :: P13 :: P14 :: P15 :: nil) (P1 :: P8 :: P12 :: P13 :: P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P8 :: P12 :: P13 :: P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) ((P1 :: P8 :: P12 :: P13 :: nil) ++ (P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P8P9P12P13P14P15mtmp;try rewrite HT2 in HP1P8P9P12P13P14P15mtmp.
assert(HT := rule_4 (P1 :: P8 :: P12 :: P13 :: nil) (P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) (P1 :: P8 :: P13 :: nil) 4 3 3 HP1P8P9P12P13P14P15mtmp HP1P8P13mtmp HP1P8P12P13Mtmp Hincl); apply HT.
}
try clear HP13P14P15m;assert(HP13P14P15m : rk(P13 :: P14 :: P15 :: nil) >= 2).
{
try assert(HP1P3P8P14Mtmp : rk(P1 :: P3 :: P8 :: P14 :: nil) <= 3) by (solve_hyps_max HP1P3P8P14eq HP1P3P8P14M).
try assert(HP1P3P8P13P14P15mtmp : rk(P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P3P8P13P14P15eq HP1P3P8P13P14P15m).
try assert(HP14mtmp : rk(P14 :: nil) >= 1) by (solve_hyps_min HP14eq HP14m).
assert(Hincl : incl (P14 :: nil) (list_inter (P1 :: P3 :: P8 :: P14 :: nil) (P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P3 :: P8 :: P13 :: P14 :: P15 :: nil) (P1 :: P3 :: P8 :: P14 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P3 :: P8 :: P14 :: P13 :: P14 :: P15 :: nil) ((P1 :: P3 :: P8 :: P14 :: nil) ++ (P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P3P8P13P14P15mtmp;try rewrite HT2 in HP1P3P8P13P14P15mtmp.
assert(HT := rule_4 (P1 :: P3 :: P8 :: P14 :: nil) (P13 :: P14 :: P15 :: nil) (P14 :: nil) 4 1 3 HP1P3P8P13P14P15mtmp HP14mtmp HP1P3P8P14Mtmp Hincl); apply HT.
}
try clear HP13P14P15M;assert(HP13P14P15M : rk(P13 :: P14 :: P15 :: nil) <= 2).
{
try assert(HP1P13P14P15Mtmp : rk(P1 :: P13 :: P14 :: P15 :: nil) <= 3) by (solve_hyps_max HP1P13P14P15eq HP1P13P14P15M).
try assert(HP8P9P13P14P15Mtmp : rk(P8 :: P9 :: P13 :: P14 :: P15 :: nil) <= 3) by (solve_hyps_max HP8P9P13P14P15eq HP8P9P13P14P15M).
try assert(HP1P8P9P13P14P15mtmp : rk(P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) >= 4) by (solve_hyps_min HP1P8P9P13P14P15eq HP1P8P9P13P14P15m).
assert(Hincl : incl (P13 :: P14 :: P15 :: nil) (list_inter (P1 :: P13 :: P14 :: P15 :: nil) (P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (repeat clear_all_rk;my_inO).
assert(HT1 : equivlist (P1 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) (P1 :: P13 :: P14 :: P15 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil)) by (clear_all_rk;my_inO).
assert(HT2 : equivlist (P1 :: P13 :: P14 :: P15 :: P8 :: P9 :: P13 :: P14 :: P15 :: nil) ((P1 :: P13 :: P14 :: P15 :: nil) ++ (P8 :: P9 :: P13 :: P14 :: P15 :: nil))) by (clear_all_rk;my_inO).
try rewrite HT1 in HP1P8P9P13P14P15mtmp;try rewrite HT2 in HP1P8P9P13P14P15mtmp.
assert(HT := rule_3 (P1 :: P13 :: P14 :: P15 :: nil) (P8 :: P9 :: P13 :: P14 :: P15 :: nil) (P13 :: P14 :: P15 :: nil) 3 3 4 HP1P13P14P15Mtmp HP8P9P13P14P15Mtmp HP1P8P9P13P14P15mtmp Hincl); apply HT.
}
assert(rk(P13 :: P14 :: P15 :: nil) <= 3) by (clear_ineg_rk;try omega;try apply rk_upper_dim;try solve[apply matroid1_b_useful;simpl;intuition]).
assert(rk(P13 :: P14 :: P15 :: nil) >= 1) by (clear_ineg_rk;try omega;try solve[apply matroid1_b_useful2;simpl;intuition]).
omega.
Qed.
|
The coalition of more than 85 groups cautions that providing government the surveillance software will exacerbate bias against minorities.
"This practice is illegal throughout the country."
"We fully intend to make sure that Arizona voters learn about the record and stances of the real Joe Arpaio."
The US Customs and Border Patrol said it nabbed someone traveling on a fake passport using newly installed facial-recognition technology.
ICE officers were reportedly notified of appointments scheduled with U.S. Citizenship and Immigration Services. |
[STATEMENT]
lemma admits_SNF_JNF_alt_def:
"(\<forall>A::'a::comm_ring_1 mat. admits_SNF_JNF A)
= (\<forall>A n. (A::'a mat) \<in> carrier_mat n n \<and> isDiagonal_mat A
\<longrightarrow> (\<exists>P Q. P \<in> carrier_mat n n \<and> Q \<in> carrier_mat n n \<and> invertible_mat P \<and> invertible_mat Q
\<and> Smith_normal_form_mat (P*A*Q)))" (is "?a = ?b")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<forall>A. admits_SNF_JNF A) = (\<forall>A n. A \<in> carrier_mat n n \<and> isDiagonal_mat A \<longrightarrow> (\<exists>P Q. P \<in> carrier_mat n n \<and> Q \<in> carrier_mat n n \<and> invertible_mat P \<and> invertible_mat Q \<and> Smith_normal_form_mat (P * A * Q)))
[PROOF STEP]
by (auto simp add: admits_SNF_JNF_def, metis carrier_matD(1) carrier_matD(2), blast) |
lemma homotopic_with_subset_right: "\<lbrakk>homotopic_with_canon P X Y f g; Y \<subseteq> Z\<rbrakk> \<Longrightarrow> homotopic_with_canon P X Z f g" |
/-
Copyright (c) 2019 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Patrick Massot, Casper Putz, Anne Baanen
-/
import linear_algebra.multilinear.basis
import linear_algebra.matrix.reindex
import ring_theory.algebra_tower
import tactic.field_simp
import linear_algebra.matrix.nonsingular_inverse
import linear_algebra.matrix.basis
/-!
# Determinant of families of vectors
This file defines the determinant of an endomorphism, and of a family of vectors
with respect to some basis. For the determinant of a matrix, see the file
`linear_algebra.matrix.determinant`.
## Main definitions
In the list below, and in all this file, `R` is a commutative ring (semiring
is sometimes enough), `M` and its variations are `R`-modules, `ι`, `κ`, `n` and `m` are finite
types used for indexing.
* `basis.det`: the determinant of a family of vectors with respect to a basis,
as a multilinear map
* `linear_map.det`: the determinant of an endomorphism `f : End R M` as a
multiplicative homomorphism (if `M` does not have a finite `R`-basis, the
result is `1` instead)
* `linear_equiv.det`: the determinant of an isomorphism `f : M ≃ₗ[R] M` as a
multiplicative homomorphism (if `M` does not have a finite `R`-basis, the
result is `1` instead)
## Tags
basis, det, determinant
-/
noncomputable theory
open_locale big_operators
open_locale matrix
open linear_map
open submodule
universes u v w
open linear_map matrix set function
variables {R : Type*} [comm_ring R]
variables {M : Type*} [add_comm_group M] [module R M]
variables {M' : Type*} [add_comm_group M'] [module R M']
variables {ι : Type*} [decidable_eq ι] [fintype ι]
variables (e : basis ι R M)
section conjugate
variables {A : Type*} [comm_ring A]
variables {m n : Type*} [fintype m] [fintype n]
/-- If `R^m` and `R^n` are linearly equivalent, then `m` and `n` are also equivalent. -/
def equiv_of_pi_lequiv_pi {R : Type*} [comm_ring R] [is_domain R]
(e : (m → R) ≃ₗ[R] (n → R)) : m ≃ n :=
basis.index_equiv (basis.of_equiv_fun e.symm) (pi.basis_fun _ _)
namespace matrix
/-- If `M` and `M'` are each other's inverse matrices, they are square matrices up to
equivalence of types. -/
def index_equiv_of_inv [is_domain A] [decidable_eq m] [decidable_eq n]
{M : matrix m n A} {M' : matrix n m A}
(hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :
m ≃ n :=
equiv_of_pi_lequiv_pi (to_lin'_of_inv hMM' hM'M)
lemma det_comm [decidable_eq n] (M N : matrix n n A) : det (M ⬝ N) = det (N ⬝ M) :=
by rw [det_mul, det_mul, mul_comm]
/-- If there exists a two-sided inverse `M'` for `M` (indexed differently),
then `det (N ⬝ M) = det (M ⬝ N)`. -/
lemma det_comm' [is_domain A] [decidable_eq m] [decidable_eq n]
{M : matrix n m A} {N : matrix m n A} {M' : matrix m n A}
(hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :
det (M ⬝ N) = det (N ⬝ M) :=
-- Although `m` and `n` are different a priori, we will show they have the same cardinality.
-- This turns the problem into one for square matrices, which is easy.
let e := index_equiv_of_inv hMM' hM'M in
by rw [← det_minor_equiv_self e, ← minor_mul_equiv _ _ _ (equiv.refl n) _, det_comm,
minor_mul_equiv, equiv.coe_refl, minor_id_id]
/-- If `M'` is a two-sided inverse for `M` (indexed differently), `det (M ⬝ N ⬝ M') = det N`. -/
lemma det_conj [is_domain A] [decidable_eq m] [decidable_eq n]
{M : matrix m n A} {M' : matrix n m A} {N : matrix n n A}
(hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :
det (M ⬝ N ⬝ M') = det N :=
by rw [← det_comm' hM'M hMM', ← matrix.mul_assoc, hM'M, matrix.one_mul]
end matrix
end conjugate
namespace linear_map
/-! ### Determinant of a linear map -/
variables {A : Type*} [comm_ring A] [is_domain A] [module A M]
variables {κ : Type*} [fintype κ]
/-- The determinant of `linear_map.to_matrix` does not depend on the choice of basis. -/
lemma det_to_matrix_eq_det_to_matrix [decidable_eq κ]
(b : basis ι A M) (c : basis κ A M) (f : M →ₗ[A] M) :
det (linear_map.to_matrix b b f) = det (linear_map.to_matrix c c f) :=
by rw [← linear_map_to_matrix_mul_basis_to_matrix c b c,
← basis_to_matrix_mul_linear_map_to_matrix b c b,
matrix.det_conj]; rw [basis.to_matrix_mul_to_matrix, basis.to_matrix_self]
/-- The determinant of an endomorphism given a basis.
See `linear_map.det` for a version that populates the basis non-computably.
Although the `trunc (basis ι A M)` parameter makes it slightly more convenient to switch bases,
there is no good way to generalize over universe parameters, so we can't fully state in `det_aux`'s
type that it does not depend on the choice of basis. Instead you can use the `det_aux_def'` lemma,
or avoid mentioning a basis at all using `linear_map.det`.
-/
def det_aux : trunc (basis ι A M) → (M →ₗ[A] M) →* A :=
trunc.lift
(λ b : basis ι A M,
(det_monoid_hom).comp (to_matrix_alg_equiv b : (M →ₗ[A] M) →* matrix ι ι A))
(λ b c, monoid_hom.ext $ det_to_matrix_eq_det_to_matrix b c)
/-- Unfold lemma for `det_aux`.
See also `det_aux_def'` which allows you to vary the basis.
-/
lemma det_aux_def (b : basis ι A M) (f : M →ₗ[A] M) :
linear_map.det_aux (trunc.mk b) f = matrix.det (linear_map.to_matrix b b f) :=
rfl
-- Discourage the elaborator from unfolding `det_aux` and producing a huge term.
attribute [irreducible] linear_map.det_aux
lemma det_aux_def' {ι' : Type*} [fintype ι'] [decidable_eq ι']
(tb : trunc $ basis ι A M) (b' : basis ι' A M) (f : M →ₗ[A] M) :
linear_map.det_aux tb f = matrix.det (linear_map.to_matrix b' b' f) :=
by { apply trunc.induction_on tb, intro b, rw [det_aux_def, det_to_matrix_eq_det_to_matrix b b'] }
@[simp]
lemma det_aux_id (b : trunc $ basis ι A M) : linear_map.det_aux b (linear_map.id) = 1 :=
(linear_map.det_aux b).map_one
@[simp]
lemma det_aux_comp (b : trunc $ basis ι A M) (f g : M →ₗ[A] M) :
linear_map.det_aux b (f.comp g) = linear_map.det_aux b f * linear_map.det_aux b g :=
(linear_map.det_aux b).map_mul f g
section
open_locale classical
-- Discourage the elaborator from unfolding `det` and producing a huge term by marking it
-- as irreducible.
/-- The determinant of an endomorphism independent of basis.
If there is no finite basis on `M`, the result is `1` instead.
-/
@[irreducible] protected def det : (M →ₗ[A] M) →* A :=
if H : ∃ (s : finset M), nonempty (basis s A M)
then linear_map.det_aux (trunc.mk H.some_spec.some)
else 1
lemma coe_det [decidable_eq M] : ⇑(linear_map.det : (M →ₗ[A] M) →* A) =
if H : ∃ (s : finset M), nonempty (basis s A M)
then linear_map.det_aux (trunc.mk H.some_spec.some)
else 1 :=
by { ext, unfold linear_map.det,
split_ifs,
{ congr }, -- use the correct `decidable_eq` instance
refl }
end
-- Auxiliary lemma, the `simp` normal form goes in the other direction
-- (using `linear_map.det_to_matrix`)
lemma det_eq_det_to_matrix_of_finset [decidable_eq M]
{s : finset M} (b : basis s A M) (f : M →ₗ[A] M) :
f.det = matrix.det (linear_map.to_matrix b b f) :=
have ∃ (s : finset M), nonempty (basis s A M),
from ⟨s, ⟨b⟩⟩,
by rw [linear_map.coe_det, dif_pos, det_aux_def' _ b]; assumption
@[simp] lemma det_to_matrix
(b : basis ι A M) (f : M →ₗ[A] M) :
matrix.det (to_matrix b b f) = f.det :=
by { haveI := classical.dec_eq M,
rw [det_eq_det_to_matrix_of_finset b.reindex_finset_range, det_to_matrix_eq_det_to_matrix b] }
@[simp] lemma det_to_matrix' {ι : Type*} [fintype ι] [decidable_eq ι]
(f : (ι → A) →ₗ[A] (ι → A)) :
det f.to_matrix' = f.det :=
by simp [← to_matrix_eq_to_matrix']
/-- To show `P f.det` it suffices to consider `P (to_matrix _ _ f).det` and `P 1`. -/
@[elab_as_eliminator]
lemma det_cases [decidable_eq M] {P : A → Prop} (f : M →ₗ[A] M)
(hb : ∀ (s : finset M) (b : basis s A M), P (to_matrix b b f).det) (h1 : P 1) :
P f.det :=
begin
unfold linear_map.det,
split_ifs with h,
{ convert hb _ h.some_spec.some,
apply det_aux_def' },
{ exact h1 }
end
@[simp]
lemma det_comp (f g : M →ₗ[A] M) : (f.comp g).det = f.det * g.det :=
linear_map.det.map_mul f g
@[simp]
lemma det_id : (linear_map.id : M →ₗ[A] M).det = 1 :=
linear_map.det.map_one
/-- Multiplying a map by a scalar `c` multiplies its determinant by `c ^ dim M`. -/
@[simp] lemma det_smul {𝕜 : Type*} [field 𝕜] {M : Type*} [add_comm_group M] [module 𝕜 M]
(c : 𝕜) (f : M →ₗ[𝕜] M) :
linear_map.det (c • f) = c ^ (finite_dimensional.finrank 𝕜 M) * linear_map.det f :=
begin
by_cases H : ∃ (s : finset M), nonempty (basis s 𝕜 M),
{ haveI : finite_dimensional 𝕜 M,
{ rcases H with ⟨s, ⟨hs⟩⟩, exact finite_dimensional.of_finset_basis hs },
simp only [← det_to_matrix (finite_dimensional.fin_basis 𝕜 M), linear_equiv.map_smul,
fintype.card_fin, det_smul] },
{ classical,
have : finite_dimensional.finrank 𝕜 M = 0 := finrank_eq_zero_of_not_exists_basis H,
simp [coe_det, H, this] }
end
lemma det_zero' {ι : Type*} [fintype ι] [nonempty ι] (b : basis ι A M) :
linear_map.det (0 : M →ₗ[A] M) = 0 :=
by { haveI := classical.dec_eq ι,
rw [← det_to_matrix b, linear_equiv.map_zero, det_zero],
assumption }
/-- In a finite-dimensional vector space, the zero map has determinant `1` in dimension `0`,
and `0` otherwise. We give a formula that also works in infinite dimension, where we define
the determinant to be `1`. -/
@[simp] lemma det_zero {𝕜 : Type*} [field 𝕜] {M : Type*} [add_comm_group M] [module 𝕜 M] :
linear_map.det (0 : M →ₗ[𝕜] M) = (0 : 𝕜) ^ (finite_dimensional.finrank 𝕜 M) :=
by simp only [← zero_smul 𝕜 (1 : M →ₗ[𝕜] M), det_smul, mul_one, monoid_hom.map_one]
/-- Conjugating a linear map by a linear equiv does not change its determinant. -/
@[simp] lemma det_conj {N : Type*} [add_comm_group N] [module A N]
(f : M →ₗ[A] M) (e : M ≃ₗ[A] N) :
linear_map.det ((e : M →ₗ[A] N) ∘ₗ (f ∘ₗ (e.symm : N →ₗ[A] M))) = linear_map.det f :=
begin
classical,
by_cases H : ∃ (s : finset M), nonempty (basis s A M),
{ rcases H with ⟨s, ⟨b⟩⟩,
rw [← det_to_matrix b f, ← det_to_matrix (b.map e), to_matrix_comp (b.map e) b (b.map e),
to_matrix_comp (b.map e) b b, ← matrix.mul_assoc, matrix.det_conj],
{ rw [← to_matrix_comp, linear_equiv.comp_coe, e.symm_trans_self,
linear_equiv.refl_to_linear_map, to_matrix_id] },
{ rw [← to_matrix_comp, linear_equiv.comp_coe, e.self_trans_symm,
linear_equiv.refl_to_linear_map, to_matrix_id] } },
{ have H' : ¬ (∃ (t : finset N), nonempty (basis t A N)),
{ contrapose! H,
rcases H with ⟨s, ⟨b⟩⟩,
exact ⟨_, ⟨(b.map e.symm).reindex_finset_range⟩⟩ },
simp only [coe_det, H, H', pi.one_apply, dif_neg, not_false_iff] }
end
/-- If a linear map is invertible, so is its determinant. -/
lemma is_unit_det {A : Type*} [comm_ring A] [is_domain A] [module A M]
(f : M →ₗ[A] M) (hf : is_unit f) : is_unit f.det :=
begin
obtain ⟨g, hg⟩ : ∃ g, f.comp g = 1 := hf.exists_right_inv,
have : linear_map.det f * linear_map.det g = 1,
by simp only [← linear_map.det_comp, hg, monoid_hom.map_one],
exact is_unit_of_mul_eq_one _ _ this,
end
/-- If a linear map has determinant different from `1`, then the space is finite-dimensional. -/
/-- If the determinant of a map vanishes, then the map is not onto. -/
lemma range_lt_top_of_det_eq_zero {𝕜 : Type*} [field 𝕜] [module 𝕜 M]
{f : M →ₗ[𝕜] M} (hf : f.det = 0) : f.range < ⊤ :=
begin
haveI : finite_dimensional 𝕜 M, by simp [f.finite_dimensional_of_det_ne_one, hf],
contrapose hf,
simp only [lt_top_iff_ne_top, not_not, ← is_unit_iff_range_eq_top] at hf,
exact is_unit_iff_ne_zero.1 (f.is_unit_det hf)
end
/-- If the determinant of a map vanishes, then the map is not injective. -/
lemma bot_lt_ker_of_det_eq_zero {𝕜 : Type*} [field 𝕜] [module 𝕜 M]
{f : M →ₗ[𝕜] M} (hf : f.det = 0) : ⊥ < f.ker :=
begin
haveI : finite_dimensional 𝕜 M, by simp [f.finite_dimensional_of_det_ne_one, hf],
contrapose hf,
simp only [bot_lt_iff_ne_bot, not_not, ← is_unit_iff_ker_eq_bot] at hf,
exact is_unit_iff_ne_zero.1 (f.is_unit_det hf)
end
end linear_map
namespace linear_equiv
variables [is_domain R]
/-- On a `linear_equiv`, the domain of `linear_map.det` can be promoted to `Rˣ`. -/
protected def det : (M ≃ₗ[R] M) →* Rˣ :=
(units.map (linear_map.det : (M →ₗ[R] M) →* R)).comp
(linear_map.general_linear_group.general_linear_equiv R M).symm.to_monoid_hom
@[simp] lemma coe_det (f : M ≃ₗ[R] M) : ↑f.det = linear_map.det (f : M →ₗ[R] M) := rfl
@[simp] lemma coe_inv_det (f : M ≃ₗ[R] M) : ↑(f.det⁻¹) = linear_map.det (f.symm : M →ₗ[R] M) := rfl
@[simp] lemma det_refl : (linear_equiv.refl R M).det = 1 := units.ext $ linear_map.det_id
@[simp] lemma det_trans (f g : M ≃ₗ[R] M) : (f.trans g).det = g.det * f.det := map_mul _ g f
@[simp] lemma det_symm (f : M ≃ₗ[R] M) : f.symm.det = f.det⁻¹ := map_inv _ f
/-- Conjugating a linear equiv by a linear equiv does not change its determinant. -/
@[simp] lemma det_conj (f : M ≃ₗ[R] M) (e : M ≃ₗ[R] M') :
((e.symm.trans f).trans e).det = f.det :=
by rw [←units.eq_iff, coe_det, coe_det, ←comp_coe, ←comp_coe, linear_map.det_conj]
end linear_equiv
/-- The determinants of a `linear_equiv` and its inverse multiply to 1. -/
@[simp] lemma linear_equiv.det_mul_det_symm {A : Type*} [comm_ring A] [is_domain A] [module A M]
(f : M ≃ₗ[A] M) : (f : M →ₗ[A] M).det * (f.symm : M →ₗ[A] M).det = 1 :=
by simp [←linear_map.det_comp]
/-- The determinants of a `linear_equiv` and its inverse multiply to 1. -/
@[simp] lemma linear_equiv.det_symm_mul_det {A : Type*} [comm_ring A] [is_domain A] [module A M]
(f : M ≃ₗ[A] M) : (f.symm : M →ₗ[A] M).det * (f : M →ₗ[A] M).det = 1 :=
by simp [←linear_map.det_comp]
-- Cannot be stated using `linear_map.det` because `f` is not an endomorphism.
lemma linear_equiv.is_unit_det (f : M ≃ₗ[R] M') (v : basis ι R M) (v' : basis ι R M') :
is_unit (linear_map.to_matrix v v' f).det :=
begin
apply is_unit_det_of_left_inverse,
simpa using (linear_map.to_matrix_comp v v' v f.symm f).symm
end
/-- Specialization of `linear_equiv.is_unit_det` -/
lemma linear_equiv.is_unit_det' {A : Type*} [comm_ring A] [is_domain A] [module A M]
(f : M ≃ₗ[A] M) : is_unit (linear_map.det (f : M →ₗ[A] M)) :=
is_unit_of_mul_eq_one _ _ f.det_mul_det_symm
/-- The determinant of `f.symm` is the inverse of that of `f` when `f` is a linear equiv. -/
lemma linear_equiv.det_coe_symm {𝕜 : Type*} [field 𝕜] [module 𝕜 M]
(f : M ≃ₗ[𝕜] M) : (f.symm : M →ₗ[𝕜] M).det = (f : M →ₗ[𝕜] M).det ⁻¹ :=
by field_simp [is_unit.ne_zero f.is_unit_det']
/-- Builds a linear equivalence from a linear map whose determinant in some bases is a unit. -/
@[simps]
def linear_equiv.of_is_unit_det {f : M →ₗ[R] M'} {v : basis ι R M} {v' : basis ι R M'}
(h : is_unit (linear_map.to_matrix v v' f).det) : M ≃ₗ[R] M' :=
{ to_fun := f,
map_add' := f.map_add,
map_smul' := f.map_smul,
inv_fun := to_lin v' v (to_matrix v v' f)⁻¹,
left_inv := λ x,
calc to_lin v' v (to_matrix v v' f)⁻¹ (f x)
= to_lin v v ((to_matrix v v' f)⁻¹ ⬝ to_matrix v v' f) x :
by { rw [to_lin_mul v v' v, to_lin_to_matrix, linear_map.comp_apply] }
... = x : by simp [h],
right_inv := λ x,
calc f (to_lin v' v (to_matrix v v' f)⁻¹ x)
= to_lin v' v' (to_matrix v v' f ⬝ (to_matrix v v' f)⁻¹) x :
by { rw [to_lin_mul v' v v', linear_map.comp_apply, to_lin_to_matrix v v'] }
... = x : by simp [h] }
@[simp] lemma linear_equiv.coe_of_is_unit_det {f : M →ₗ[R] M'} {v : basis ι R M} {v' : basis ι R M'}
(h : is_unit (linear_map.to_matrix v v' f).det) :
(linear_equiv.of_is_unit_det h : M →ₗ[R] M') = f :=
by { ext x, refl }
/-- Builds a linear equivalence from a linear map on a finite-dimensional vector space whose
determinant is nonzero. -/
@[reducible] def linear_map.equiv_of_det_ne_zero
{𝕜 : Type*} [field 𝕜] {M : Type*} [add_comm_group M] [module 𝕜 M]
[finite_dimensional 𝕜 M] (f : M →ₗ[𝕜] M) (hf : linear_map.det f ≠ 0) :
M ≃ₗ[𝕜] M :=
have is_unit (linear_map.to_matrix (finite_dimensional.fin_basis 𝕜 M)
(finite_dimensional.fin_basis 𝕜 M) f).det :=
by simp only [linear_map.det_to_matrix, is_unit_iff_ne_zero.2 hf],
linear_equiv.of_is_unit_det this
/-- The determinant of a family of vectors with respect to some basis, as an alternating
multilinear map. -/
def basis.det : alternating_map R M R ι :=
{ to_fun := λ v, det (e.to_matrix v),
map_add' := begin
intros v i x y,
simp only [e.to_matrix_update, linear_equiv.map_add],
apply det_update_column_add
end,
map_smul' := begin
intros u i c x,
simp only [e.to_matrix_update, algebra.id.smul_eq_mul, linear_equiv.map_smul],
apply det_update_column_smul
end,
map_eq_zero_of_eq' := begin
intros v i j h hij,
rw [←function.update_eq_self i v, h, ←det_transpose, e.to_matrix_update,
←update_row_transpose, ←e.to_matrix_transpose_apply],
apply det_zero_of_row_eq hij,
rw [update_row_ne hij.symm, update_row_self],
end }
lemma basis.det_apply (v : ι → M) : e.det v = det (e.to_matrix v) := rfl
lemma basis.det_self : e.det e = 1 :=
by simp [e.det_apply]
/-- `basis.det` is not the zero map. -/
lemma basis.det_ne_zero [nontrivial R] : e.det ≠ 0 :=
λ h, by simpa [h] using e.det_self
lemma is_basis_iff_det {v : ι → M} :
linear_independent R v ∧ span R (set.range v) = ⊤ ↔ is_unit (e.det v) :=
begin
split,
{ rintro ⟨hli, hspan⟩,
set v' := basis.mk hli hspan with v'_eq,
rw e.det_apply,
convert linear_equiv.is_unit_det (linear_equiv.refl _ _) v' e using 2,
ext i j,
simp },
{ intro h,
rw [basis.det_apply, basis.to_matrix_eq_to_matrix_constr] at h,
set v' := basis.map e (linear_equiv.of_is_unit_det h) with v'_def,
have : ⇑ v' = v,
{ ext i, rw [v'_def, basis.map_apply, linear_equiv.of_is_unit_det_apply, e.constr_basis] },
rw ← this,
exact ⟨v'.linear_independent, v'.span_eq⟩ },
end
lemma basis.is_unit_det (e' : basis ι R M) : is_unit (e.det e') :=
(is_basis_iff_det e).mp ⟨e'.linear_independent, e'.span_eq⟩
/-- Any alternating map to `R` where `ι` has the cardinality of a basis equals the determinant
map with respect to that basis, multiplied by the value of that alternating map on that basis. -/
lemma alternating_map.eq_smul_basis_det (f : alternating_map R M R ι) : f = f e • e.det :=
begin
refine basis.ext_alternating e (λ i h, _),
let σ : equiv.perm ι := equiv.of_bijective i (fintype.injective_iff_bijective.1 h),
change f (e ∘ σ) = (f e • e.det) (e ∘ σ),
simp [alternating_map.map_perm, basis.det_self]
end
@[simp] lemma alternating_map.map_basis_eq_zero_iff (f : alternating_map R M R ι) :
f e = 0 ↔ f = 0 :=
⟨λ h, by simpa [h] using f.eq_smul_basis_det e, λ h, h.symm ▸ alternating_map.zero_apply _⟩
lemma alternating_map.map_basis_ne_zero_iff (f : alternating_map R M R ι) :
f e ≠ 0 ↔ f ≠ 0 :=
not_congr $ f.map_basis_eq_zero_iff e
variables {A : Type*} [comm_ring A] [is_domain A] [module A M]
@[simp] lemma basis.det_comp (e : basis ι A M) (f : M →ₗ[A] M) (v : ι → M) :
e.det (f ∘ v) = f.det * e.det v :=
by { rw [basis.det_apply, basis.det_apply, ← f.det_to_matrix e, ← matrix.det_mul,
e.to_matrix_eq_to_matrix_constr (f ∘ v), e.to_matrix_eq_to_matrix_constr v,
← to_matrix_comp, e.constr_comp] }
lemma basis.det_reindex {ι' : Type*} [fintype ι'] [decidable_eq ι']
(b : basis ι R M) (v : ι' → M) (e : ι ≃ ι') :
(b.reindex e).det v = b.det (v ∘ e) :=
by rw [basis.det_apply, basis.to_matrix_reindex', det_reindex_alg_equiv, basis.det_apply]
lemma basis.det_reindex_symm {ι' : Type*} [fintype ι'] [decidable_eq ι']
(b : basis ι R M) (v : ι → M) (e : ι' ≃ ι) :
(b.reindex e.symm).det (v ∘ e) = b.det v :=
by rw [basis.det_reindex, function.comp.assoc, e.self_comp_symm, function.comp.right_id]
@[simp]
lemma basis.det_map (b : basis ι R M) (f : M ≃ₗ[R] M') (v : ι → M') :
(b.map f).det v = b.det (f.symm ∘ v) :=
by { rw [basis.det_apply, basis.to_matrix_map, basis.det_apply] }
lemma basis.det_map' (b : basis ι R M) (f : M ≃ₗ[R] M') :
(b.map f).det = b.det.comp_linear_map f.symm :=
alternating_map.ext $ b.det_map f
@[simp] lemma pi.basis_fun_det : (pi.basis_fun R ι).det = matrix.det_row_alternating :=
begin
ext M,
rw [basis.det_apply, basis.coe_pi_basis_fun.to_matrix_eq_transpose, det_transpose],
end
/-- If we fix a background basis `e`, then for any other basis `v`, we can characterise the
coordinates provided by `v` in terms of determinants relative to `e`. -/
lemma basis.det_smul_mk_coord_eq_det_update {v : ι → M}
(hli : linear_independent R v) (hsp : span R (range v) = ⊤) (i : ι) :
(e.det v) • (basis.mk hli hsp).coord i = e.det.to_multilinear_map.to_linear_map v i :=
begin
apply (basis.mk hli hsp).ext,
intros k,
rcases eq_or_ne k i with rfl | hik;
simp only [algebra.id.smul_eq_mul, basis.coe_mk, linear_map.smul_apply, linear_map.coe_mk,
multilinear_map.to_linear_map_apply],
{ rw [basis.mk_coord_apply_eq, mul_one, update_eq_self], congr, },
{ rw [basis.mk_coord_apply_ne hik, mul_zero, eq_comm],
exact e.det.map_eq_zero_of_eq _ (by simp [hik, function.update_apply]) hik, },
end
/-- The determinant of a basis constructed by `units_smul` is the product of the given units. -/
@[simp] lemma basis.det_units_smul (w : ι → Rˣ) : e.det (e.units_smul w) = ∏ i, w i :=
by simp [basis.det_apply]
/-- The determinant of a basis constructed by `is_unit_smul` is the product of the given units. -/
@[simp] lemma basis.det_is_unit_smul {w : ι → R} (hw : ∀ i, is_unit (w i)) :
e.det (e.is_unit_smul hw) = ∏ i, w i :=
e.det_units_smul _
|
#+-----------------------------------------------------------------+
#| maiorElementoVetor.r |
#| Copyright 2020, Carlos Bezerra Vilela. |
#| https://github.com/carlosvilela/exemplosR |
#+------------------------------------------------------------------+
# definindo a estrutura dos dados
setClass(
"vetorN",
slots = list(
tamanhoN = "numeric",
vetor = "numeric",
valorMaximo = "numeric"
)
)
# Criando uma constante que definirá o range dos possíveis valores do vetor
rangeVetor = 1:10
# obtendo o tamanho do vetor
tamanhoVetor = as.integer(readline(prompt="Insira o tamanho do vetor: "))
# Gerando o vetor
gerarVetor<- sample(rangeVetor, tamanhoVetor, replace=TRUE, prob=NULL)
# obtendo o numero máximo que foi registrado no vetor
numeroMaximo = as.integer(max(gerarVetor))
# registrando e estruturando os dados
vetor <- new("vetorN",
tamanhoN = tamanhoVetor,
vetor = gerarVetor,
valorMaximo = numeroMaximo)
# exibindo resultado
print(str(vetor))
print(vetor@tamanhoN)
print(vetor@vetor)
print(vetor@valorMaximo)
|
module Interior where
open import Basics
open import Ix
open import All
open import Cutting
module INTERIOR {I}(C : I |> I) where
open _|>_ C
data Interior (P : I -> Set)(i : I) : Set where
tile : P i -> Interior P i
<_> : Cutting C (Interior P) i -> Interior P i
ifold : forall {P Q} ->
[ P -:> Q ] ->
[ Cutting C Q -:> Q ] ->
[ Interior P -:> Q ]
ifolds : forall {P Q} ->
[ P -:> Q ] ->
[ Cutting C Q -:> Q ] ->
[ All (Interior P) -:> All Q ]
ifold pq cq i (tile p) = pq i p
ifold pq cq i < c 8>< ps > = cq i (c 8>< ifolds pq cq _ ps)
ifolds pq cq [] <> = <>
ifolds pq cq (i ,- is) (x , xs) = ifold pq cq i x , ifolds pq cq is xs
-- tile : [ P -:> Interior P ]
extend : forall {P Q} ->
[ P -:> Interior Q ] ->
[ Interior P -:> Interior Q ]
extend k = ifold k (\ i x -> < x >)
-- and we have a monad, not in Set, but in I -> Set
open INTERIOR NatCut
{-
foo : Interior (\ n -> n == 3) 12
foo = < ((3 , 9 , refl _)) 8>< (tile (refl _) , {!!} , <>) >
-}
|
/*
* Copyright (c) 2013, Prevas A/S
* 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.
* * Neither the name of Prevas A/S nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* 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 OWNER 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.
*/
/**
* \author Morten Kjaergaard
*/
#pragma once
#include <map>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/make_shared.hpp>
#include <boost/signal.hpp>
#include <darc/id.hpp>
#include <darc/network/outbound_data.hpp>
#include <darc/network/service_header_packet.hpp>
#include <darc/buffer/shared_buffer.hpp>
namespace darc
{
class peer_service;
class peer
{
public:
typedef uint32_t service_type;
protected:
typedef std::map<service_type, peer_service*> service_list_type;
typedef boost::function<void(const darc::ID&, darc::buffer::shared_buffer)> send_to_function_type;
typedef boost::signal<void(const ID&)> peer_connected_signal_type;
typedef boost::signal<void(const ID&)> peer_disconnected_signal_type;
send_to_function_type send_to_function_;
ID id_;
service_list_type service_list_;
peer_connected_signal_type peer_connected_signal_;
peer_disconnected_signal_type peer_disconnected_signal_;
public:
peer() :
id_(ID::create())
{}
void send_to(const ID& peer_id, service_type service, const outbound_data_base& data);
void recv(const ID& src_peer_id, buffer::shared_buffer data);
void attach(service_type service_index, peer_service * service_instance);
void peer_connected(const ID& peer_id);
void peer_disconnected(const ID& peer_id);
virtual void set_send_to_function(send_to_function_type send_to_function)
{
send_to_function_ = send_to_function;
}
const ID& id()
{
return id_;
}
peer_connected_signal_type& peer_connected_signal()
{
return peer_connected_signal_;
}
peer_disconnected_signal_type& peer_disconnected_signal()
{
return peer_disconnected_signal_;
}
};
}
|
Formal statement is: lemma (in linorder_topology) open_left: assumes "open S" "x \<in> S" and lt_ex: "y < x" shows "\<exists>b<x. {b <.. x} \<subseteq> S" Informal statement is: If $S$ is an open set in a linearly ordered topology, and $x \in S$, then there exists a point $b < x$ such that the interval $(b, x)$ is contained in $S$. |
-- Union_con_su_diferencia.lean
-- Unión con su diferencia
-- José A. Alonso Jiménez
-- Sevilla, 27 de mayo de 2021
-- ---------------------------------------------------------------------
-- ---------------------------------------------------------------------
-- Demostrar que
-- (s \ t) ∪ t = s ∪ t
-- ----------------------------------------------------------------------
import data.set.basic
open set
variable {α : Type}
variables s t : set α
-- 1ª definición
-- =============
example : (s \ t) ∪ t = s ∪ t :=
begin
ext x,
split,
{ intro hx,
cases hx with xst xt,
{ left,
exact xst.1, },
{ right,
exact xt }},
{ by_cases h : x ∈ t,
{ intro _,
right,
exact h },
{ intro hx,
cases hx with xs xt,
{ left,
split,
{ exact xs, },
{ exact h, }},
{ right,
exact xt, }}},
end
-- 2ª definición
-- =============
example : (s \ t) ∪ t = s ∪ t :=
begin
ext x,
split,
{ rintros (⟨xs, nxt⟩ | xt),
{ left,
exact xs},
{ right,
exact xt }},
{ by_cases h : x ∈ t,
{ intro _,
right,
exact h },
{ rintros (xs | xt),
{ left,
use [xs, h] },
{ right,
use xt }}},
end
-- 3ª definición
-- =============
example : (s \ t) ∪ t = s ∪ t :=
begin
rw ext_iff,
intro,
rw iff_def,
finish,
end
-- 4ª definición
-- =============
example : (s \ t) ∪ t = s ∪ t :=
by finish [ext_iff, iff_def]
-- 5ª definición
-- =============
example : (s \ t) ∪ t = s ∪ t :=
diff_union_self
-- 6ª definición
-- =============
example : (s \ t) ∪ t = s ∪ t :=
begin
ext,
simp,
end
-- 7ª definición
-- =============
example : (s \ t) ∪ t = s ∪ t :=
by simp
|
#! /usr/bin/env python2
# This file is part of pyunicorn.
# Copyright (C) 2008--2017 Jonathan F. Donges and pyunicorn authors
# URL: <http://www.pik-potsdam.de/members/donges/software>
# License: BSD (3-clause)
"""
Configure `py.test` fixtures.
"""
import numpy as np
import pytest
def _i():
"""
Match preceding stdout (e.g. from `weave`) on '#'.
Otherwise default doctest.ELLIPSIS = '...' is indistinguishable from line
continuation in doctest.
"""
import doctest
doctest.ELLIPSIS_MARKER = '#'
def r(obj, decimals=4):
"""
Round numbers, arrays or iterables thereof for doctests.
"""
if isinstance(obj, (np.ndarray, np.matrix)):
if obj.dtype.kind == 'f':
rounded = np.around(obj.astype(np.float128),
decimals=decimals).astype(np.float)
elif obj.dtype.kind == 'i':
rounded = obj.astype(np.int)
elif isinstance(obj, list):
rounded = map(r, obj)
elif isinstance(obj, tuple):
rounded = tuple(map(r, obj))
elif isinstance(obj, (float, np.float32, np.float64, np.float128)):
rounded = np.float(np.around(np.float128(obj), decimals=decimals))
elif isinstance(obj, (int, np.int8, np.int16)):
rounded = int(obj)
else:
rounded = obj
return rounded
def rr(obj, decimals=4):
"""
Force arrays in stubborn scientific notation into a few digits.
"""
print np.vectorize('%.4g'.__mod__)(r(obj, decimals=decimals))
@pytest.fixture(autouse=True)
def add_round(doctest_namespace):
"""
Inject rounding helpers into doctest namespace.
"""
doctest_namespace['_i'] = _i
doctest_namespace['r'] = r
doctest_namespace['rr'] = rr
|
[STATEMENT]
lemma ovalid_pre_imp:
"\<lbrakk> \<And>s. P' s \<Longrightarrow> P s; ovalid P f Q \<rbrakk> \<Longrightarrow> ovalid P' f Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>\<And>s. P' s \<Longrightarrow> P s; ovalid P f Q\<rbrakk> \<Longrightarrow> ovalid P' f Q
[PROOF STEP]
by (simp add: ovalid_def) |
#ifndef BOOST_UTILITY_NULL_DELETER_HPP
#define BOOST_UTILITY_NULL_DELETER_HPP
// The header file at this path is deprecated;
// use boost/core/null_deleter.hpp instead.
#include <boost/core/null_deleter.hpp>
#endif
|
If a sequence of real numbers is Cauchy, then it converges. |
Formal statement is: lemma connected_component_eq_eq: "connected_component_set S x = connected_component_set S y \<longleftrightarrow> x \<notin> S \<and> y \<notin> S \<or> x \<in> S \<and> y \<in> S \<and> connected_component S x y" Informal statement is: The connected component of $x$ is equal to the connected component of $y$ if and only if $x$ and $y$ are either both not in $S$ or both in $S$ and $x$ and $y$ are in the same connected component of $S$. |
lemma has_contour_integral_eqpath: "\<lbrakk>(f has_contour_integral y) p; f contour_integrable_on \<gamma>; contour_integral p f = contour_integral \<gamma> f\<rbrakk> \<Longrightarrow> (f has_contour_integral y) \<gamma>" |
export dimension
mutable struct ModAlgAss{S, T, V}
base_ring::S
action::Vector{T}
dimension::Int
M::AbstractAlgebra.FPModule{V}
isirreducible::Int
dimension_splitting_field::Int
algebra::AlgAss{V}
action_of_gens::Vector{T}
action_of_basis::Vector{T}
function ModAlgAss{S, T}(action::Vector{T}) where {S, T}
z = new{S, T, elem_type(S)}()
z.action = action
z.dimension = ncols(action[1])
z.base_ring = base_ring(action[1])
if z.dimension == 1
z.isirreducible = 1
z.dimension_splitting_field = 1
else
z.isirreducible = 0
z.dimension_splitting_field = 0
end
return z
end
end
mutable struct Lat{S, T}
mod::S
order::AlgAssAbsOrd
basis_matrix::T
function Lat{S, T}(mod::S, order::AlgAssAbsOrd, basis_matrix::T) where {S, T}
z = new{S, T}(mod, order, basis_matrix)
return z
end
end
function vector_space(M::ModAlgAss)
return M.M
end
function algebra(M::ModAlgAss)
if isdefined(M :algebra)
return M.algebra
else
A = algebra(M.action)
M.algebra = A
M.action_of_gens = M.action
return A
end
end
function action(a::AlgAssElem, M::ModAlgAss)
parent(a) == algebra(M)
end
function basis_matrix(L::Lat)
return L.basis_matrix
end
function action(a::AlgAssAbsOrdElem, L::Lat)
end
function ModAlgAss(action::Vector{T}) where {T}
@assert length(action) > 0
S = typeof(base_ring(action[1]))
return ModAlgAss{S, T}(action)
end
function ModAlgAss(M::AbstractAlgebra.FPModule{T}, action::Vector{<:Generic.ModuleHomomorphism{T}}) where {T <: FieldElem}
all(x->domain(x) == codomain(x) == M, action) || error("module and maps do not match")
V = ModAlgAss([x.matrix for x = action])
V.M = M
return V
end
function isirreducible_known(M::ModAlgAss)
return M.isirreducible != 0
end
function isirreducible(M::ModAlgAss)
if M.isirreducible != 0
return M.isirreducible == 1
else
fl, N = meataxe(M)
return fl
end
end
function dimension(M::ModAlgAss)
return M.dimension
end
function base_ring(M::ModAlgAss)
return M.base_ring
end
# Compute the algebra generated by M and images
# of the elements in M
function algebra(M::Vector{T}) where {T <: MatElem}
@assert length(M) > 0
A = M[1]
n = nrows(A)
n2 = n^2
@assert n == ncols(A)
K = base_ring(A)
Mprod = M
Morig = copy(M)
current_dim = -1
B = zero_matrix(K, length(Mprod) + 1, n2)
l = 0
while true
if l != 0
B = zero_matrix(K, length(Mprod), n2)
end
for k in 1:length(Mprod)
for i in 1:n
for j in 1:n
B[k, (i - 1)* n + j] = Mprod[k][i, j]
end
end
end
# Add the identity
if l == 0
for i in 1:n
B[length(M) + 1, (i - 1)*n + i] = one(K)
end
end
new_dim = rref!(B)
if new_dim == current_dim
break
end
current_dim = new_dim
M = [ matrix(K, n, n, [B[k, (i - 1)*n + j] for i in 1:n for j in 1:n]) for k in 1:new_dim]
Mprod = [ M[i] * M[j] for i in 1:length(M) for j in 1:length(M) ]
l = l + 1
end
dim = current_dim
B = sub(B, 1:dim, 1:ncols(B))
basis = [ matrix(K, n, n, [B[k, (i - 1)*n + j] for i in 1:n for j in 1:n]) for k in 1:dim]
@assert isone(basis[1])
v = zero_matrix(K, 1, n2)
structure = Array{elem_type(K), 3}(dim, dim, dim)
for k in 1:dim
for l in 1:dim
N = basis[k] * basis[l]
for i in 1:n
for j in 1:n
v[1, (i - 1)* n + j] = N[i, j]
end
end
b, u = can_solve_with_solution(B, v, side = :left)
error("NOT HERE!")
@assert b
@assert N == sum(u[i]*basis[i] for i in 1:dim)
for m in 1:dim
structure[k, l, m] = u[m, 1]
end
end
end
A = AlgAss(K, structure)
gens = Vector{AlgAssElem{elem_type(K)}}(length(Morig))
for l in 1:length(Morig)
N = Morig[l]
for i in 1:n
for j in 1:n
v[1, (i - 1)* n + j] = N[i, j]
end
end
b, u = can_solve_with_solution(B, v, side = :left)
gens[l] = A([u[1, m] for m in 1:dim])
end
A.gens = gens
return A
end
#function gens(A::AlgAss{T}) where {T}
# #return A.gens::Vector{AlgAssElem{T}}
#end
|
Formal statement is: lemma degree_monom_eq: "a \<noteq> 0 \<Longrightarrow> degree (monom a n) = n" Informal statement is: If $a \neq 0$, then the degree of the monomial $a x^n$ is $n$. |
theory Assertion imports
"State"
begin
(*evalF defines the semantics of assertions written in first-order logic*)
primrec evalF :: "state => fform => bool" where
"evalF (f,WTrue) = (True)" |
"evalF (f,WFalse) = (False)" |
"evalF (f,e1 [=] e2) = (case (evalE (f,e1), evalE (f,e2)) of
(RR (r1),RR (r2)) => ((r1::real) = r2) |
(SS (r1),SS (r2)) => ((r1::string) = r2) |
(BB (r1),BB (r2)) => ((r1::bool) = r2) |
(_,_) => False)" |
"evalF (f,e1 [<] e2) = (case (evalE (f,e1), evalE (f,e2)) of
(RR (r1),RR (r2)) => ((r1::real) < r2) |
(_,_) => False)" |
"evalF (f,e1 [>] e2) = (case (evalE (f,e1), evalE (f,e2)) of
(RR (r1),RR (r2)) => (r1::real) > r2 |
(_,_) => False)" |
"evalF (f,[~] form1) = (~ (evalF (f,form1)))" |
"evalF (f,form1 [&] form2) = ((evalF (f,form1)) & (evalF (f,form2)))" |
"evalF (f,form1 [|] form2) = ((evalF (f,form1)) | (evalF (f,form2)))" |
"evalF (f,form1 [-->] form2) = ((evalF (f,form1)) --> (evalF (f,form2)))" |
"evalF (f,form1 [<->] form2) = ((evalF (f,form1)) <-> (evalF (f,form2)))" |
"evalF (f,WALL x form1)= (ALL (v::real). (evalF((%a. %i. (if (a=x) then (RR (v)) else (f(a, i)))), form1)))" |
"evalF (f,WEX x form1)= (EX (v::real). evalF((%a. %i. (if (a=x) then (RR (v)) else f(a, i))), form1))"
definition evalFP :: "cstate => fform => now => bool" where
"evalFP(f,P,c) == ALL s. inList(s,f(c)) --> evalF(s,P)"
(*ievalF defines the semantics of assertions written in interval logic and duration calculus*)
consts ievalF :: "cstate => fform => now => now => bool"
axiomatization where
chop_eval: "ievalF (f, P[^]Q, c, d) = (EX k s1 s2. s1@s2=f(k) & ievalF (%t. if t=k then s1 else f(t), P, c, k)
& ievalF (%t. if t=k then s2 else f(t), Q, k, d))" and
chop_sep: "ievalF (f, P, c, d) = (ALL k s1 s2. s1@s2=f(k) --> ievalF (%t. if t=k then s1 else f(t), P, c, k)
& ievalF (%t. if t=k then s2 else f(t), P, k, d))" and
pf_eval: "ievalF (f, pf (P), c, d) = (c=d & (EX s. inList(s, f(c))) & evalF (s, P))" and
high_eval: "ievalF (f, high P, c, d) = ((ALL (k::real). (c<k & k<d) --> evalFP (f, P, k)))" and
chop_interval: "(ALL t. (c=d --> f(c)=g(c)) & (c<=t & t<=d --> f(t)=g(t))) ==> ievalF(f,P,c,d)=ievalF(g,P,c,d)"
lemma chop_eval1: "(EX k. ievalF (f, P, c, k) & ievalF (f, Q, k, d)) ==> ievalF (f, P[^]Q, c, d)"
apply (simp add: chop_eval,auto)
apply (cut_tac x=k in exI,auto)
apply (cut_tac x="f(k)" in exI,auto)
apply (subgoal_tac "f = (%t. if t = k then f(k) else f(t))",auto)
apply (subgoal_tac "(ALL ka s1 s2. s1@s2=f(ka) --> ievalF (%t. if t=ka then s1 else f(t), Q, k, ka)
& ievalF (%t. if t=ka then s2 else f(t), Q, ka, d))")
apply (subgoal_tac "ievalF(%t. if t = k then f(k) else f(t), Q, k, k) &
ievalF(%t. if t = k then [] else f(t), Q, k, d)")
apply blast
apply (erule allE)+
apply blast
apply (cut_tac f=f and P=Q and c=k and d=d in chop_sep,auto)
done
(*The following axioms define the evaluation of formulas of part of first-order interval logic.*)
axiomatization where
True_eval : "ievalF (f,WTrue, c, d) = (True)" and
False_eval : "ievalF (f,WFalse,c,d) = (False)" and
L_eval : "ievalF (f, (l [=] Real L), c, d) = (d-c = L)" and
(*Equal_eval : "ievalF (f,e1 [=] e2,c,d) = evalFP(f,e1 [=] e2,c)" and
Less_eval : "ievalF (f,e1 [<] e2,c,d) = evalFP(f,e1 [<] e2,c)" and
Great_eval: "ievalF (f,e1 [>] e2,c,d) = evalFP(f,e1 [>] e2,c)" and*)
Not_eval: "ievalF (f,[~] form1,c,d) = (~ (ievalF (f,form1,c,d)))" and
And_eval: "ievalF (f,form1 [&] form2,c,d) = ((ievalF (f,form1,c,d)) & (ievalF (f,form2,c,d)))" and
Or_eval: "ievalF (f,F [|] G,c,d) = ((ievalF (f,F,c,d)) | (ievalF (f,G,c,d)))" and
Imply_eval: "ievalF (f,form1 [-->] form2,c,d) = ((ievalF (f,form1,c,d)) --> (ievalF (f,form2,c,d)))" and
Equiv_eval: "ievalF (f,form1 [<->] form2,c,d) = ((ievalF (f,form1,c,d)) <-> (ievalF (f,form2,c,d)))" and
ALL_eval: "ievalF (f,WALL x form1,c,d)= (ALL (v::real). ievalF((%t. List.map(%s. %y i. if y=x & i=R then RR(v) else s(y,i),f(t))), form1, c, d))" and
EX_eval: "ievalF (f,WEX x form1,c,d)= (EX (v::real). ievalF((%t. List.map(%s. %y i. if y=x & i=R then RR(v) else s(y,i),f(t))), form1, c, d))"
(*The following axioms define the semantic meanings of closure of formulas.*)
axiomatization where
close_fact1: "ALL t. (t>=b & t<c --> evalF (f, p)) --> (evalF (f, close(p)))" and
close_fact2: "ALL t. (t>=b & t<c --> evalF (f, p)) --> (evalF (f, close([~]p)))" and
close_fact3: "evalF (s,p) ==> evalF (s,close(p))"
end
|
module Main
import Control.Comonad
import Control.Comonad.Store.Representable
import Conway
import Conway.Parse
import Data.Fuel
import Data.Functor.Representable
import Data.Vect
import System.File.ReadWrite
import System.File.Virtual
%default total
fRead : HasIO io => File -> Fuel -> io String
fRead file fuel = foldMap id <$> go file fuel
where
go : File -> Fuel -> io (List String)
go file Dry = pure []
go file (More fuel) = do
False <- fEOF file | _ => pure []
Right str <- fGetLine file | _ => pure []
(str ::) <$> go file fuel
covering
main : IO ()
main = do
text <- fRead stdin forever
case parseGrid text of
Nothing => putStrLn "Invalid starting position"
Just ((n, m) ** grid) => runLife conway grid forever
|
import Data.Vect
%default total
data Info = String
data Term = TmVar Info Nat Nat
| TmAbs Info String Term
| TmApp Info Term Term
%name Term t, t1, t2, t3
data Binding = NameBind
Context : Nat -> Type
Context k = Vect k (String, Binding)
%name Context context, context1, context2, context3
data Command = Eval Info Term
| Bind Info String Binding
Show Binding where
show NameBind = ""
emptyContext : Context 0
emptyContext = []
contextLength : Context n -> Nat
contextLength x {n} = n
addBinding : Context n -> String -> Binding -> Context (S n)
addBinding context name binding = (name, binding) :: context
addName : Context n -> String -> Context (S n)
addName context name = addBinding context name NameBind
isNameBound : Context n -> String -> Bool
isNameBound context name = case context of
[] => False
((bound_name, _) :: xs) =>
if bound_name == name
then True
else isNameBound xs name
pickFreshName : (context : Context n) ->
(name : String) ->
{auto prf : Elem (name, _) context} ->
Context (S n)
pickFreshName context name = (name ++ "'", NameBind) :: context
contextIndex : (a : Nat) -> {auto prf : LT 0 a} -> Nat
contextIndex (S a) {prf = (LTESucc x)} = a
indexToName : (context : Context n) -> Fin n -> String
indexToName ((name, _) :: xs) FZ = name
indexToName (x :: xs) (FS k) = indexToName xs k
nameToIndex : (context : Context n) ->
(name : String) ->
{auto prf : Elem (name, _) context} ->
Nat
nameToIndex ((name, b) :: _) name {prf = Here} = 0
nameToIndex (_ :: xs) name {prf = (There later)} = 1 + nameToIndex xs name
getBinding : (context : Context n) -> Fin n -> Binding
getBinding ((_, b) :: _) FZ = b
getBinding (_ :: xs) (FS k) = getBinding xs k
termMap : (f : (modifier : Nat) -> (cutoff : Nat) -> (t : Term) -> Term) ->
(modifier : Nat) ->
(cutoff : Nat) ->
(t : Term) -> Term
termMap f modifier cutoff term = f modifier cutoff term
termMap f modifier cutoff (TmAbs fileInfo nameHint term)
= TmAbs fileInfo nameHint (termMap f modifier (cutoff + 1) term)
termMap f modifier cutoff (TmApp fileInfo term1 term2)
= TmApp fileInfo
(termMap f modifier cutoff term1)
(termMap f modifier cutoff term2)
shiftAbove : (modifier : Nat) -> (cutoff : Nat) -> Term -> Term
shiftAbove modifier cutoff t = termMap shiftAboveHelper modifier cutoff t where
shiftAboveHelper : (modifier : Nat) -> (cutoff : Nat) -> (t : Term) -> Term
shiftAboveHelper modifier cutoff (TmVar fileInfo index check)
= if index >= cutoff
then TmVar fileInfo
(index + modifier)
(check + modifier)
else TmVar fileInfo index (check + modifier)
shiftAboveHelper _ _ t = t
shift : (modifier : Nat) -> Term -> Term
shift modifier t = shiftAbove modifier 1 t
termSubstitution : (sub_index : Nat) -> (s : Term) -> (t: Term) -> Term
termSubstitution sub_index s t = substitutionHelper sub_index 0 t where
substitutionHelper : (sub_index : Nat) ->
(cutoff : Nat) ->
(t : Term) ->
Term
substitutionHelper sub_index cutoff (TmVar fileInfo index check)
= if index == sub_index + cutoff
then shift cutoff (TmVar fileInfo index check)
else TmVar fileInfo index check
substitutionHelper _ _ t= t
substitute : (s : Term) -> (t : Term) -> Term
substitute s t = shift 0 (termSubstitution 0 (shift 1 s) t)
checkContextLength : (t : Term) -> (context : Context n) -> Bool
checkContextLength (TmVar _ _ check) _ {n} = check == n
checkContextLength _ _ = False
getNameFromIndex : Context n -> Nat -> Either String String
getNameFromIndex context Z {n} = Left ("Error: bad index 0/" ++ (show n) ++
" in " ++ (show context))
getNameFromIndex context (S k) {n}
= let fin = (natToFin (contextIndex (S k)) n) in
(case fin of
Nothing => Left ("Error: " ++ (show (S k)) ++ "/" ++ (show n) ++
" in " ++ (show context))
(Just idx) => Right (show (indexToName context idx)))
termInfo : Term -> Info
termInfo (TmVar fileInfo _ _) = fileInfo
termInfo (TmAbs fileInfo _ _) = fileInfo
termInfo (TmApp fileInfo _ _) = fileInfo
printTerm : Term -> Context n -> String
printTerm (TmVar _ index check) context {n}
= case (compare check n) of
GT => ("Error: bad check " ++ (show check) ++ "/" ++ (show n) ++
" in " ++ (show context))
_ => (case getNameFromIndex context index of
(Left err) => err
(Right res) => res)
printTerm (TmAbs _ nameHint t) context = "lambda" ++ nameHint ++ ".(\n\t" ++
(printTerm t context) ++ ")"
printTerm (TmApp _ t1 t2) context = (printTerm t1 context) ++ " " ++
(printTerm t2 context)
|
If $f$ is a nonnegative real-valued function, then $f$ tends to infinity if and only if for every $r > c$, there exists an $x$ such that $r \leq f(x)$. |
If you have accepted Christ into your life, your past is forgiven. There is nothing left for you to do but leave it there – in the past. I want to be clear that this does not mean that you will not have to endure the consequences of your choices, but instead, mean that your past does not possess the power to rule your life. Let me give you an example of what I mean. I grew up in church, but when I got older, I decided to do my own thing. As a result, I was a single mother making $12,000 a year. I was at an all time low, and there was only one person who could help me out of the hole I created. Jesus forgave me of my sin, but I still had to be a mother. I still had to endure making huge sacrifices for my child to be okay. I had to go from thinking about what to wear out on a Friday night with my friends, to staying up all night with my sick, asthmatic baby.
My sins were forgiven, but the consequences were mine. There were days harder than others, but I had the confidence of knowing Christ was with me. Some days were extremely hard but I never truly felt alone. I had made some huge mistakes and suffered at the hands of others, but none of that determined my future. Soon I met and married a wonderful man who loved both my daughter and I. There are still times in my life where I am reminded of whom I used to be, the people I hurt out of my selfishness and the pain I endured because of someone else’s selfishness. If allowed some days have the power to pull me into a dark place.
But today, once again, I was reminded that “It is finished,” and my debt has been “paid in full.” I am healed of the abuse of others. I am left only with the scars that remind me of God’s power.
Hold your head up Grace Girl! Yes you made poor decisions, or maybe horrible things have been done to you, but no matter what, you are so much more than those mistakes or hurts forced on you without your permission. You have been given the gift of grace. If you take the time to unwrap this undeserved gift, you will discover the strength you need to move forward on your journey. You see, grace was not created so you cannot buy it; it is not a merit so you cannot earn it; and it is not conditional so you cannot lose it. It is a gift from God!
That you will find the strength to let your past go.
That your faith will increase to trust the ONE who paid your debt.
That you will bask in the magnitude of Christ’s love for you.
You receive the strength it takes to forgive and move forward.
And finally, that you will truly come to understand what it means to be Remade by Grace! |
# Tensorflow implementation of temporal parallelisation of Kalman filter and smoother
This notebook implements the algorithms in the paper by S. Särkkä and Á. García-Fernández by leveraging the [Tensorflow](https://www.tensorflow.org/) framework.
## Author: Adrien Corenflos
## Reference:
Simo Särkkä and Ángel F. García-Fernández (2021). Temporal Parallelization of Bayesian Smoothers.
IEEE Transactions on Automatic Control, Volume: 66, Issue: 1, Pages 299-306.
arXiv: https://arxiv.org/abs/1905.13002
DOI: https://doi.org/10.1109/TAC.2020.2976316
- If you are on Colab don't forget to switch the Runtime (in the tab with the same name) type to GPU.
- If you are using a personal machine, to install tensorflow with GPU support please read TensorFlow [user guide](https://www.tensorflow.org/install).
### Imports
```
# Python specific imports that will make our job easier and our code prettier
from collections import namedtuple
from functools import partial
import math
import time
from tqdm.auto import trange, tqdm
# TF specific imports that we will use to code the logic
from tensorflow import function
import tensorflow as tf
import tensorflow_probability as tfp
# Auxiliary libraries that we will use to report results and create the data
import matplotlib.pyplot as plt
import numpy as np
import scipy as sc
```
### Utilities
We define some utilities that will make the code more readable
```
mm = tf.linalg.matmul
mv = tf.linalg.matvec
```
### Model
In the vein of Example 3.6 in the book Bayesian Filtering and Smoothing (S. Särkkä) we consider a simple car tracking model where the car is characterised by its coordinates and directional speeds $\mathbf{z} = [x, y, \dot{x}, \dot{y}]^\top$ for which only the positional components are observed with some uncertainty. Formally this corresponds to the following state-space model:
\begin{equation}
\begin{split}
x_k &= F \, x_{k-1} + q_{k-1},\\
y_k &= H \, x_k + r_k,
\end{split}
\end{equation}
where $q_k \sim \mathrm{N}(0,Q)$, $r_k \sim \mathrm{N}(0,R)$, and
\begin{equation}
F = \begin{pmatrix}
1 & 0 & \Delta t & 0 \\
0 & 1 & 0 & \Delta t \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1
\end{pmatrix}
,\quad
Q = q \, \begin{pmatrix}
\frac{\Delta t^3}{3} & 0 & \frac{\Delta t^2}{2} & 0 \\
0 & \frac{\Delta t^3}{3} & 0 & \frac{\Delta t^2}{2} \\
\frac{\Delta t^2}{2} & 0 & \Delta t & 0 \\
0 & \frac{\Delta t^2}{2} & 0 & \Delta t
\end{pmatrix},
\end{equation}
along with
\begin{equation}
H = \begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0
\end{pmatrix}, \qquad
R = \begin{pmatrix}
\sigma^2 & 0 \\
0 & \sigma^2
\end{pmatrix}.
\end{equation}
which translates into the following code:
```
StateSpaceModel = namedtuple("StateSpaceModel", ["F", "H", "Q", "R", "m0", "P0", "xdim", "ydim"])
```
```
def make_car_tracking_model(q: float, dt: float, r: float, m0: np.ndarray, P0: np.ndarray):
F = np.eye(4) + dt * np.eye(4, k=2)
H = np.eye(2, 4)
Q = np.kron(np.array([[dt**3/3, dt**2/2],
[dt**2/2, dt]]),
np.eye(2))
R = r ** 2 * np.eye(2)
return StateSpaceModel(F, H, q * Q, R, m0, P0, m0.shape[0], H.shape[0])
```
```
car_tracking_model = make_car_tracking_model(q=1., dt=0.1, r=0.5,
m0=np.array([0., 0., 1., -1.]),
P0=np.eye(4))
```
So that we can now write some generic code to sample from a SSM:
```
def get_data(model: StateSpaceModel, T:float, seed:int=0):
# We first generate the normals we will be using to simulate the SSM:
rng = np.random.RandomState(seed)
normals = rng.randn(1 + T, model.xdim + model.ydim)
# Then we allocate the arrays where the simulated path and observations will
# be stored:
xs = np.empty((T, model.xdim))
ys = np.empty((T, model.ydim))
# So that we can now run the sampling routine:
Q_chol = sc.linalg.cholesky(model.Q, lower=True)
R_chol = sc.linalg.cholesky(model.R, lower=True)
P0_chol = sc.linalg.cholesky(model.P0, lower=True)
x = model.m0 + P0_chol @ normals[0, :model.xdim]
for i, norm in enumerate(normals[1:]):
x = model.F @ x + Q_chol @ norm[:model.xdim]
y = model.H @ x + R_chol @ norm[model.xdim:]
xs[i] = x
ys[i] = y
return xs, ys
```
```
log10T = 4
```
```
true_xs, ys = get_data(car_tracking_model, 10 ** log10T, 0)
```
This corresponds to the following car positions in space (truncated at 100 timesteps):
```
fig, ax = plt.subplots(figsize=(7, 7))
ax.plot(true_xs[:100, 0], true_xs[:100, 1], label="True State", color="b")
ax.scatter(*ys[:100].T, label="Observations", color="r")
_ = plt.legend()
```
### Sequential Kalman filter and smoother
We can now write the Kalman filter and smoother sequential routines in a TensorFlow fashion. For more information on these algorithms, we refer the reader to the book:
Särkkä, S. (2013). Bayesian filtering and smoothing. Cambridge University Press.
For which an online version is also available on his [webpage](https://users.aalto.fi/~ssarkka/).
#### Filter:
```
@partial(tf.function, experimental_relax_shapes=True)
def kf(model, observations):
def body(carry, y):
m, P = carry
m = mv(model.F, m)
P = model.F @ mm(P, model.F, transpose_b=True)+ model.Q
S = model.H @ mm(P, model.H, transpose_b=True) + model.R
chol = tf.linalg.cholesky(S)
Kt = tf.linalg.cholesky_solve(chol, model.H @ P)
m = m + mv(Kt, y - mv(model.H, m), transpose_a=True)
P = P - mm(Kt, S, transpose_a=True) @ Kt
return m, P
fms, fPs = tf.scan(body, observations, (model.m0, model.P0))
return fms, fPs
```
```
with tf.device('/CPU:0'):
fms, fPs = kf(car_tracking_model, ys[:100])
```
#### Smoother:
```
@partial(tf.function, experimental_relax_shapes=True)
def ks(model, ms, Ps):
def body(carry, inp):
m, P = inp
sm, sP = carry
pm = mv(model.F, m)
pP = model.F @ mm(P, model.F, transpose_b=True) + model.Q
chol = tf.linalg.cholesky(pP)
Ct = tf.linalg.cholesky_solve(chol, model.F @ P)
sm = m + mv(Ct, (sm - pm), transpose_a=True)
sP = P + mm(Ct, sP - pP, transpose_a=True) @ Ct
return sm, sP
(sms, sPs) = tf.scan(body, (ms[:-1], Ps[:-1]), (ms[-1], Ps[-1]), reverse=True)
sms = tf.concat([sms, tf.expand_dims(ms[-1], 0)], 0)
sPs = tf.concat([sPs, tf.expand_dims(Ps[-1], 0)], 0)
return sms, sPs
```
```
with tf.device('/CPU:0'):
sms, sPs = ks(car_tracking_model, fms, fPs)
```
So that we can now plot the result agains the true state and the observations:
```
fig, ax = plt.subplots(figsize=(7, 7))
ax.plot(true_xs[:100, 0], true_xs[:100, 1], label="True State", color="b")
ax.plot(fms[:100, 0], fms[:100, 1], label="Filtered", color="g", linestyle="--")
ax.plot(sms[:100, 0], sms[:100, 1], label="Smoothed", color="k", linestyle="--")
ax.scatter(*ys[:100].T, label="Observations", color="r")
_ = plt.legend()
```
#### Filter-Smoother
We can finally combine the filter and the smoother into a single filter-smoother routine:
```
@partial(tf.function, experimental_relax_shapes=True)
def kfs(model, observations):
return ks(model, *kf(model, observations))
```
### Parallel Kalman filter and smoother
Now that we have a baseline for the sequential model, we can go on and implement the parallel version of the routine, leveraging the associative_scan function already offered by TensorFlow Probability ([see this](https://www.tensorflow.org/probability/api_docs/python/tfp/math/scan_associative)). To do this we will need to do a bit more work, but before this let us offer some intuition around what exactly is happening.
#### Prefix-Sum / Associative Scan
Consider the simple problem of computing the cumulative sum of a given array of floats:
```
array_of_floats = np.arange(2 ** 4, dtype=np.float32)
```
A simple way to do this would be to iterate (scan) through the array from left to right and accumulate the result as we go:
```
def cumulative_sum(arr):
# obviously numpy implements cumulative sums already, but this is for illustrative purposes.
res = np.empty_like(arr)
temp = 0.
for i, val in enumerate(arr):
temp += val
res[i] = temp
return res
```
```
cumulative_sum(array_of_floats)
```
array([ 0., 1., 3., 6., 10., 15., 21., 28., 36., 45., 55.,
66., 78., 91., 105., 120.], dtype=float32)
However, the addition operation has the fundamental property to be associative: $(a+b) + c = a + (b + c)$, under which accumulative scans have been proven to be parallelizable (Blelloch, 1990, see the paper for a reference) up to a span complexity of $O(log(N))$ in the context where many processors are available. If we were to write the algorithm in pure python, it would look like the below:
```
def prefix_sum(arr):
# This is for illustration purposes only, and for instance doesn't take into
# account the case when the array size is not a pure power of 2
res = np.copy(arr)
n = res.shape[0]
log_n = np.log2(n).astype(int)
# Up pass
for d in range(log_n):
# this loop can't be done in parallel so it defines the span complexity under
# parallelization
for i in range(0, n, 2 ** (d + 1)):
# this should be done in parallel, therefore would not be taken
# into account in the span complexity provided we have at least
# n / 2^{d+1} cores on our GPU
i1 = i + 2 ** d - 1
i2 = i + 2 ** (d + 1) - 1
res[i2] += res[i1]
res[-1] = 0
# Down pass
for d in range(log_n-1, -1, -1):
# this loop can't be done in parallel so it defines the span complexity under
# parallelization
for i in range(0, n, 2 ** (d + 1)):
# this should be done in parallel, therefore would not be taken
# into account in the span complexity provided we have at least
# n / 2^{d+1} cores on our GPU
i1 = i + 2 ** d - 1
i2 = i + 2 ** (d + 1) - 1
res[i1], res[i2] = res[i2], res[i1] + res[i2]
# Extra pass
res += arr
return res
```
```
prefix_sum(array_of_floats)
```
array([ 0., 1., 3., 6., 10., 15., 21., 28., 36., 45., 55.,
66., 78., 91., 105., 120.], dtype=float32)
#### Filter:
In the case of Kalman filters, one can think of the addition as being the bayesian map operator coming from the fact of "adding" one observation to the model:
\begin{equation}
p(x_k \mid y_{1:k-1})
= \int p(x_k \mid x_{k-1})
\, p(x_{k-1} \mid y_{1:k-1}) \, \mathrm{d}x_{k-1},
\end{equation}
\begin{equation}
p(x_k \mid y_{1:k})
= \frac{p(y_k \mid x_k)
\, p(x_k \mid y_{1:k-1})}
{\int p(y_k \mid x_k)
\, p(x_k \mid y_{1:k-1}) \, \mathrm{d}x_k}.
\end{equation}
As it is, this operation on the random variables $x_k$'s is not associative as switching around the observations will result in a completely different result. However S. Särkkä and Á. García-Fernández showed that these could be rewritten in terms of the associative operator given by:
\begin{align*}
\left(f_{i},g_{i}\right)\otimes\left(f_{j},g_{j}\right) & =\left(f_{ij},g_{ij}\right),
\end{align*}
\begin{align*}
f_{ij}\left(x\mid z\right) & =\frac{\int g_{j}\left(y\right)f_{j}\left(x\mid y\right)f_{i}\left(y\mid z\right)\mathrm{d}y}{\int g_{j}\left(y\right)f_{i}\left(y\mid z\right)\mathrm{d}y}, \\
g_{ij}\left(z\right) & =g_{i}\left(z\right)\int g_{j}\left(y\right)f_{i}\left(y\mid z\right)\mathrm{d}y.
\end{align*}
This could in turn be rewritten in terms of the linear equations of the state parameters, which leads to the below algorithm:
##### Initialisation of the associative elements:
We write the function that will initialise them (in parallel) based on the data and the observations:
```
@partial(tf.function, experimental_relax_shapes=True)
def first_filtering_element(model, y):
m1 = mv(model.F, model.m0)
P1 = model.F @ mm(model.P0, model.F, transpose_b=True) + model.Q
S1 = model.H @ mm(P1, model.H, transpose_b=True) + model.R
S1_chol = tf.linalg.cholesky(S1)
K1t = tf.linalg.cholesky_solve(S1_chol, model.H @ P1)
A = tf.zeros_like(model.F)
b = m1 + mv(K1t, y - mv(model.H, m1), transpose_a=True)
C = P1 - mm(K1t, S1, transpose_a=True) @ K1t
S = model.H @ mm(model.Q, model.H, transpose_b=True) + model.R
chol = tf.linalg.cholesky(S)
HF = model.H @ model.F
eta = mv(HF,
tf.squeeze(tf.linalg.cholesky_solve(chol, tf.expand_dims(y, 1)), 1),
transpose_a=True)
J = mm(HF, tf.linalg.cholesky_solve(chol, model.H @ model.F), transpose_a=True)
return A, b, C, J, eta
@partial(tf.function, experimental_relax_shapes=True)
def generic_filtering_element(model, y):
S = model.H @ mm(model.Q, model.H, transpose_b=True) + model.R
chol = tf.linalg.cholesky(S)
Kt = tf.linalg.cholesky_solve(chol, model.H @ model.Q)
A = model.F - mm(Kt, model.H, transpose_a=True) @ model.F
b = mv(Kt, y, transpose_a=True)
C = model.Q - mm(Kt, model.H, transpose_a=True) @ model.Q
HF = model.H @ model.F
eta = mv(HF,
tf.squeeze(tf.linalg.cholesky_solve(chol, tf.expand_dims(y, 1)), 1),
transpose_a=True)
J = mm(HF, tf.linalg.cholesky_solve(chol, HF), transpose_a=True)
return A, b, C, J, eta
```
And we can combine them properly:
```
@partial(tf.function, experimental_relax_shapes=True)
def make_associative_filtering_elements(model, observations):
first_elems = first_filtering_element(model, observations[0])
generic_elems = tf.vectorized_map(lambda o: generic_filtering_element(model, o),
observations[1:], fallback_to_while_loop=False)
return tuple(tf.concat([tf.expand_dims(first_e, 0), gen_es], 0)
for first_e, gen_es in zip(first_elems, generic_elems))
```
##### Associative filtering operator
We now define the associative filtering operator
```
@partial(tf.function, experimental_relax_shapes=True)
def filtering_operator(elems):
elem1, elem2 = elems
A1, b1, C1, J1, eta1 = elem1
A2, b2, C2, J2, eta2 = elem2
dim = A1.shape[0]
I = tf.eye(dim, dtype=A1.dtype, )
temp = tf.linalg.solve(I + C1 @ J2, tf.transpose(A2), adjoint=True)
A = mm(temp, A1, transpose_a=True)
b = mv(temp, b1 + mv(C1, eta2), transpose_a=True) + b2
C = mm(temp, mm(C1, A2, transpose_b=True), transpose_a=True) + C2
temp = tf.linalg.solve(I + J2 @ C1, A1, adjoint=True)
eta = mv(temp, eta2 - mv(J2, b1), transpose_a=True) + eta1
J = mm(temp, J2 @ A1, transpose_a=True) + J1
return A, b, C, J, eta
```
##### Parallel routine
And we can now combine all these to compute the filtering result in parallel:
```
@partial(tf.function, experimental_relax_shapes=True)
def pkf(model, observations, max_parallel=10000):
initial_elements = make_associative_filtering_elements(model, observations)
def vectorized_operator(a, b):
return tf.vectorized_map(filtering_operator, (a, b), fallback_to_while_loop=False)
final_elements = tfp.math.scan_associative(vectorized_operator,
initial_elements,
max_num_levels=math.ceil(math.log2(max_parallel)))
return final_elements[1], final_elements[2]
```
That we can compare with the sequential one:
```
with tf.device('/GPU:0'):
pfms, pfPs = pkf(car_tracking_model, ys[:100])
```
and we get a maximum absolute difference between the two methods of
```
np.abs(pfms - fms).max()
```
5.861977570020827e-14
#### Smoother:
The parallel implementation of the smoother follows similar principles and we refer the reader to the paper for more details about the associative formulation.
##### Initialisation of the associative elements:
We now write the function that will initialise them (in parallel) based on the data and the observations:
```
@partial(tf.function, experimental_relax_shapes=True)
def last_smoothing_element(m, P):
return tf.zeros_like(P), m, P
@partial(tf.function, experimental_relax_shapes=True)
def generic_smoothing_element(model, m, P):
Pp = model.F @ mm(P, model.F, transpose_b=True) + model.Q
chol = tf.linalg.cholesky(Pp)
E = tf.transpose(tf.linalg.cholesky_solve(chol, model.F @ P))
g = m - mv(E @ model.F, m)
L = P - E @ mm(Pp, E, transpose_b=True)
return E, g, L
```
And we can combine them properly:
```
@partial(tf.function, experimental_relax_shapes=True)
def make_associative_smoothing_elements(model, filtering_means, filtering_covariances):
last_elems = last_smoothing_element(filtering_means[-1], filtering_covariances[-1])
generic_elems = tf.vectorized_map(lambda o: generic_smoothing_element(model, o[0], o[1]),
(filtering_means[:-1], filtering_covariances[:-1]),
fallback_to_while_loop=False)
return tuple(tf.concat([gen_es, tf.expand_dims(last_e, 0)], axis=0)
for gen_es, last_e in zip(generic_elems, last_elems))
```
##### Associative smoothing operator
We now define the associative smoothing operator
```
@partial(tf.function, experimental_relax_shapes=True)
def smoothing_operator(elems):
elem1, elem2 = elems
E1, g1, L1 = elem1
E2, g2, L2 = elem2
E = E2 @ E1
g = mv(E2, g1) + g2
L = E2 @ mm(L1, E2, transpose_b=True) + L2
return E, g, L
```
##### Parallel routine
And we can now combine all these to compute the smoothing result in parallel:
```
@partial(tf.function, experimental_relax_shapes=True)
def pks(model, filtered_means, filtered_covariances, max_parallel=10000):
initial_elements = make_associative_smoothing_elements(model, filtered_means, filtered_covariances)
reversed_elements = tuple(tf.reverse(elem, axis=[0]) for elem in initial_elements)
def vectorized_operator(a, b):
return tf.vectorized_map(smoothing_operator, (a, b), fallback_to_while_loop=False)
final_elements = tfp.math.scan_associative(vectorized_operator,
reversed_elements,
max_num_levels=math.ceil(math.log2(max_parallel)))
return tf.reverse(final_elements[1], axis=[0]), tf.reverse(final_elements[2], axis=[0])
```
That we can compare with the sequential one:
```
with tf.device('/GPU:0'):
psms, psPs = pks(car_tracking_model, pfms, pfPs)
```
```
np.abs(psms - sms).max()
```
5.861977570020827e-14
#### Filter-Smoother:
Finally we can combine all these functions into one filter-smoother routine.
```
@partial(tf.function, experimental_relax_shapes=True)
def pkfs(model, observations, max_parallel=10000):
return pks(model, *pkf(model, observations, max_parallel), max_parallel)
```
### Runtime comparison
To compare the runtime of both methods we will compile the routines on GPU and CPU and modify the size of the observation input fed to the routines. It is noteworthy that the parallel version compilation time will depend on the "max_parallel" parameter which defines the depth of the recursion tree compiled (see the [docstring of the method](https://github.com/tensorflow/probability/blob/bf84eb67f342e332b7c09b8f435ba534cd91725e/tensorflow_probability/python/math/scan_associative.py#L210) for more details). A good rule of thumb would be to set it to the number of cores of your GPU (check it with !nvidia-smi in a code cell).
```
input_sizes = np.logspace(2, log10T, num=10, base=10).astype(int)
```
```
n_iter = 5
```
```
def get_average_runtimes(func, n_iter, car_model, observations):
runtimes = np.empty(input_sizes.shape)
for i, input_size in tqdm(enumerate(input_sizes), total=runtimes.shape[0]):
observation_slice = observations[:input_size]
_ = func(car_model, observation_slice) # compilation run
tic = time.time()
for _ in trange(n_iter, leave=False):
res = func(car_model, observation_slice)
runtimes[i] = (time.time() - tic) / n_iter
return runtimes
```
```
with tf.device('/CPU:0'):
cpu_ys = tf.constant(ys)
cpu_car_tracking_model = StateSpaceModel(*(tf.constant(v) for v in car_tracking_model))
cpu_sequential_runtimes = get_average_runtimes(kfs, n_iter, cpu_car_tracking_model, cpu_ys)
cpu_parallel_runtimes = get_average_runtimes(lambda *args :pkfs(*args, max_parallel=int(input_sizes[-1])),
n_iter, cpu_car_tracking_model, cpu_ys)
with tf.device('/GPU:0'):
gpu_ys = tf.constant(ys)
gpu_car_tracking_model = StateSpaceModel(*(tf.constant(v) for v in car_tracking_model))
gpu_sequential_runtimes = get_average_runtimes(kfs, n_iter, gpu_car_tracking_model, gpu_ys)
gpu_parallel_runtimes = get_average_runtimes(lambda *args :pkfs(*args, max_parallel=int(input_sizes[-1])),
n_iter, gpu_car_tracking_model, gpu_ys)
```
HBox(children=(FloatProgress(value=0.0, max=10.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=10.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=10.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=10.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=5.0), HTML(value='')))
```
pkfs.pretty_printed_concrete_signatures()
```
```
kfs.pretty_printed_concrete_signatures()
```
And we can plot these:
```
fig, axes = plt.subplots(ncols=2, figsize=(15, 6), sharex=True, sharey=True)
axes[0].loglog(input_sizes, cpu_sequential_runtimes, label="Sequential-CPU", linestyle="-.", linewidth=3)
axes[0].loglog(input_sizes, cpu_parallel_runtimes, label="Parallel-CPU", linewidth=3)
axes[0].legend()
axes[1].loglog(input_sizes, gpu_sequential_runtimes, label="Sequential-GPU", linestyle="-.", linewidth=3)
axes[1].loglog(input_sizes, gpu_parallel_runtimes, label="Parallel-GPU", linewidth=3)
_ = axes[0].set_ylabel("Average run time (seconds)")
for ax in axes:
_ = ax.set_xlabel("Number of data points")
_ = fig.suptitle("Runtime comparison on CPU and GPU", size=15)
_ = axes[1].legend()
```
It is noteworthy that tensorflow has some multi-threading happening in the background, which is probably why we get a better performance for the parallel algorithm on CPU.
```
tf.__version__
```
'2.4.0'
```
```
|
{-|
Module : MachineLearning.TIR
Description : TIR expression data structures
Copyright : (c) Fabricio Olivetti de Franca, 2022
License : GPL-3
Maintainer : [email protected]
Stability : experimental
Portability : POSIX
The TIR expression represents a function of the form:
\[
f(x) = g(\sum_{i}{w_i \cdot t_i(\prod_{j}{x_j^{k_{ij}})}} / (1 + \sum_{i}{w_i \cdot t_i(\prod_{j}{x_j^{k_{ij}})}})
\]
with \(t_i\) being a transformation function, \(g\) an invertible function, \(w_i\) a linear coefficient, \(k_{ij}\)
the interaction strength.
Any given expression can be represented by two lists of terms, with each term
being composed of a transformatioon function and an interaction.
The transformation function is represented by a `Function` sum type.
The interaction is represented as a list of tuple of ints where the key is the
predictor index and the value is the strength of the predictor in this
term. Strengths with a value of zero are omitted.
-}
module MachineLearning.TIR where
import Control.Evolution
import Control.Monad.State.Strict
import Data.List.Split
import Data.SRTree
import System.Random
import Control.DeepSeq (NFData, rnf)
import Data.List (delete)
import Data.SRTree.Print (showDefault)
import Data.Vector (Vector)
import qualified Data.Vector as V
import qualified Data.Vector.Storable as VS
import qualified Numeric.LinearAlgebra as LA
import MachineLearning.Utils.Config
-- | `TIR` is a record type composed of the external
-- function `_funY` of type `Function`, numerator `_p`
-- and denominator `_q` of type `Sigma`
data TIR = TIR { _funY :: Function
, _p :: Sigma
, _q :: Sigma
} deriving Show
instance NFData TIR where
rnf _ = ()
-- | `Sigma` is just a list of terms `Pi`
type Sigma = [Pi]
-- | `Pi` is a triple composed of a coefficient, a `Function`
-- and a list of tuples where `(ix, k)` represents `x ! ix ^ k`.
type Pi = (Double, Function, [(Int, Int)])
-- | generates a random integer within the specified range.
randomRng :: (Int, Int) -> Rnd Int
randomRng rng = state $ randomR rng
{-# INLINE randomRng #-}
-- | generates a random integer within the specified range excluding zero.
randomRngNZ :: (Int, Int) -> Rnd Int
randomRngNZ rng = do
x <- randomRng rng
if x == 0
then randomRngNZ rng
else pure x
{-# INLINE randomRngNZ #-}
-- | picks a random element from a list.
randomFrom :: [a] -> Rnd a
randomFrom xs = do
ix <- randomRng (0, length xs - 1)
pure (xs !! ix)
{-# INLINE randomFrom #-}
-- | returns a random index of variables provided by the mutation configuration.
randomVar :: MutationCfg -> Rnd (Maybe Int, MutationCfg)
randomVar params = do
let vars = _vars params
n = length vars
ix <- randomRng (0, n)
if ix == n
then pure (Nothing, params)
else do let x = vars !! ix
pure (Just x, params{ _vars=delete x vars })
-- | returns a list of random interactions (tuples of variables indeces and exponentes)
-- with parameters provided by the mutation configuration.
randomVars :: MutationCfg -> Rnd [(Int, Int)]
randomVars params = do
(v, params') <- randomVar params
k <- randomRngNZ $ _kRange params
case v of
Nothing -> pure []
Just var -> do vs <- randomVars params'
pure $ (var, k) : vs
-- | returns a random `Pi`
randomPi :: MutationCfg -> Rnd (Maybe Pi)
randomPi params = do
pis <- randomVars params
f <- randomFrom $ _funs params
if null pis
then pure Nothing
else pure $ Just (1.0, f, pis)
-- | returns a random `Sigma`
randomSigma :: MutationCfg -> Int -> Rnd (Sigma, Int)
randomSigma params budget | budget <= 0 = pure ([], budget)
randomSigma params budget = do
n <- randomRng (0, budget)
if n == budget
then pure ([], budget)
else do term <- randomPi params
(terms, budget') <- randomSigma params (budget - spentBudget term)
case term of
Nothing -> pure (terms, budget')
Just t -> pure (t:terms, budget')
where
spentBudget Nothing = 0
spentBudget (Just (_, _, ps)) = 1 -- length ps
-- | returns a random `TIR` expression
randomTIR :: MutationCfg -> Rnd TIR
randomTIR params = do
yf <- randomFrom $ _yfuns params
(p, budget') <- randomSigma params $ _budget params
(q, _) <- randomSigma params budget'
if null p
then randomTIR params
else pure (TIR yf p q)
-- | We store thee dataset as a vector of columns.
-- Each vector is stored a `Storable`-based vector.
type Column a = LA.Vector a
-- | A dataset is a `Vector` of `Column`
type Dataset a = Vector (Column a)
-- | A constraint is a function that gets a symbolic tree
-- as an input and returns non negative `Double` representing
-- how much a constraint was violated.
type Constraint = SRTree Int Double -> Double
-- | An individual in the population is composed of
-- the chromossome, a vector of fitness, a list of
-- coefficients (for multiclass problems it stores
-- one vector of coefficient per class),
-- the constraint violation, the size of the expression,
-- and the penalty value.
data Individual = Individual { _chromo :: TIR
, _fit :: [Double]
, _weights :: [LA.Vector Double]
, _constr :: Double
, _len :: Int
, _penalty :: Double
}
-- | creates an unevaluated individual.
createIndividual :: TIR -> Individual
createIndividual tir = Individual tir [] [] 0.0 0 0.0
-- | calculates the penalized fitness.
penalizedFit :: Individual -> Double
penalizedFit t = (head . _fit) t + _penalty t
{-# INLINE penalizedFit #-}
-- | replaces the coefficients of a TIR expression
replaceConsts :: TIR -> V.Vector Double -> TIR
replaceConsts (TIR g p q) ws = TIR g p' q'
where
(p', ws1) = runState (traverse replaceWeight p) (V.toList ws)
(q', ws2) = runState (traverse replaceWeight q) ws1
replaceWeight :: Pi -> State [Double] Pi
replaceWeight (w, g, h) = state $ \ws -> case ws of
(wi:ws') -> ((wi, g, h), ws')
[] -> error $ show h -- ((w, g, h), [])
instance Eq Individual where
t1 == t2 = penalizedFit t1 == penalizedFit t2
instance Ord Individual where
t1 <= t2 = penalizedFit t1 <= penalizedFit t2
instance NFData Individual where
rnf _ = ()
instance Solution Individual where
_getFitness = head . _fit
_isFeasible = (<1e-12) . _constr
-- | creates a symbolic tree from a TIR expression.
assembleTree :: Double -> TIR -> SRTree Int Double
assembleTree bias (TIR f p q) = Fun f ((Const bias + assemble p) / (1 + assemble q))
where
-- assemble :: Sigma ix val -> SRTree ix val
assemble [] = 0
assemble [p'] = mk p'
assemble (p':ps) = mk p' + assemble ps
-- mk :: Pi ix val -> SRTree ix val
mk (v, g, ts) = Const v * Fun g (foldr (\(ix, k) acc -> acc * Pow (Var ix) k) 1 ts)
-- | pretty print a solution.
prettyPrintsolution :: Individual -> String
prettyPrintsolution sol | Prelude.null (_fit sol) = error "unevaluated solution"
prettyPrintsolution sol = concat [ "Expression:\n", (showDefault . assembleTree bias . _chromo) sol, "\n"
, "Fitness: ", (show . head . _fit) sol, "\n"
, "Constraints: ", (show . _constr) sol, "\n"
, "Length: ", (show . _len) sol, "\n"
, "Penalty: ", (show . _penalty) sol, "\n"
]
where bias = V.head $ VS.convert $ head $ _weights sol
|
```python
from IPython.display import Image
from IPython.core.display import HTML
from sympy import *; x,h,t,y,z = symbols("x h t y z", real=True)
Image(url= "https://i.imgur.com/bZFVJ2p.png")
```
```python
f = 3*x**2 + 4*x + x*y -4
f
```
$\displaystyle 3 x^{2} + x y + 4 x - 4$
```python
solve(f,y)
```
[{y: -3*x - 4 + 4/x}]
```python
diff(-3*x - 4 + 4/x).subs(x,4)
```
$\displaystyle - \frac{13}{4}$
```python
Image(url= "https://i.imgur.com/sAS2idS.png")
```
|
SUBROUTINE DSICMN ( iret )
C************************************************************************
C* DSICMN *
C* *
C* This subroutine sets image common information in the device driver *
C* *
C* DSICMN ( IRET ) *
C* *
C* *
C* Output parameters: *
C* IRET INTEGER Return code *
C** *
C* Log: *
C* J. Cowie/COMET 2/95 *
C************************************************************************
INCLUDE 'ERROR.PRM'
INCLUDE 'FUNCCODE.PRM'
INCLUDE 'IMGDEF.CMN'
C*
INTEGER isend (2)
C------------------------------------------------------------------------
C
C* Load input parameters into buffer and write them to the mailbox.
C
isend (1) = 2 + NIMCMN
isend (2) = CSICMN
C
CALL GPUT ( isend, 2, iret )
IF ( iret .ne. NORMAL ) RETURN
C
CALL GPUT ( imftyp, NIMCMN, iret )
IF ( iret .ne. NORMAL ) RETURN
C
C* Get the return code.
C
CALL GGET ( iret, 1, ier )
IF ( ier .ne. NORMAL ) iret = ier
C
RETURN
END
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Functor.Bifunctor
module Categories.Diagram.Wedge {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
(F : Bifunctor (Category.op C) C D) where
private
module C = Category C
module D = Category D
open D
open HomReasoning
variable
A : Obj
open import Level
open import Categories.Functor hiding (id)
open import Categories.Functor.Construction.Constant
open import Categories.NaturalTransformation.Dinatural
open Functor F
record Wedge : Set (levelOfTerm F) where
field
E : Obj
dinatural : DinaturalTransformation (const E) F
module dinatural = DinaturalTransformation dinatural
Wedge-∘ : (W : Wedge) → A ⇒ Wedge.E W → Wedge
Wedge-∘ {A = A} W f = record
{ E = A
; dinatural = extranaturalʳ (λ X → dinatural.α X ∘ f)
(sym-assoc ○ ∘-resp-≈ˡ (extranatural-commʳ dinatural) ○ assoc)
}
where open Wedge W
record Wedge-Morphism (W₁ W₂ : Wedge) : Set (levelOfTerm F) where
private
module W₁ = Wedge W₁
module W₂ = Wedge W₂
open DinaturalTransformation
field
u : W₁.E ⇒ W₂.E
commute : ∀ {C} → W₂.dinatural.α C ∘ u ≈ W₁.dinatural.α C
Wedge-id : ∀ {W} → Wedge-Morphism W W
Wedge-id {W} = record { u = D.id ; commute = D.identityʳ }
Wedge-Morphism-∘ : {A B C : Wedge} → Wedge-Morphism B C → Wedge-Morphism A B → Wedge-Morphism A C
Wedge-Morphism-∘ M N = record { u = u M ∘ u N ; commute = sym-assoc ○ (∘-resp-≈ˡ (commute M) ○ commute N) }
where
open Wedge-Morphism
open HomReasoning
|
# Symbolic Mathematics in Python
There are times when you need to solve a difficult problem symbollically or analytically. If you have ever used Wolfram Alpha, then you have already done this. Sympy is a python library that allows you to do symbolic mathematics in python.
```python
import sympy as sym
```
## 1. Introduction
### Example 1.1
If you try to write the follwing in python by itself, you will get an error telling you x is undefined:
$$x-x$$
```python
x-x
```
(The error above is on purpose). Variables in python need to be defined before you can say something specific about them
```python
x=102
x-x
```
0
If you are trying to show that $x-x=0$ is true for any $x$, the above answer would not be valid. Instead you can use a symbolic expression to show that it is true
**First we define the variable as a symmbolic expression**
```python
x = sym.symbols('x')
```
**Now we can use the variable in a symbolic expression**
```python
x-x
```
0
### Example 1.2
Sympy can be used to perform algebreic operations (among other things). Consider the following expression: $$(3a-4b)^3$$
We can use symppy to expand the expression algebraically.
**First we need to define the variables as symbolic expressions**
```python
a,b = sym.symbols('a,b')
```
**Side note** Notice that the left hand side of the epression has two variables being defined. Python can define more than one variable at a time:
```python
x1,y1 =10,20
print(x1)
print(y1)
```
10
20
**Back to the expression** We can define an expression using the variables $a$ and $b$.
```python
expr = (3*a-4*b)**3
print(expr)
```
(3*a - 4*b)**3
We can also make it look nicer in our notebook. This doesn't affect the math, but it makes our notebook more readable.
```python
sym.init_printing()
```
```python
expr
```
**Now we expand the function algebreically**
```python
expr.expand()
```
Sympy can also factor the equation
```python
sym.factor(26*a**3-108*a**2*b+144*a*b**2-64*b**3)
```
If you want to copy and paste a result, you print the result.
```python
print(sym.factor(26*a**3-108*a**2*b+144*a*b**2-64*b**3))
```
2*(a - 2*b)*(13*a**2 - 28*a*b + 16*b**2)
You can also chain together functions
```python
expr.expand().factor()
```
### Exercise 1.1
Show that the following two expressions are true.
$$(2w-3z)(2w+3z)=4w^2-9z^2$$
$$(2w-3z)^2\ne4w^2-9z^2$$
```python
# Your code here
```
## 2. Solving Equations
Sympy can be used to symbolilically solve equations. As before, you need to define which variables are symbols
### Example 2.1
Use sympy to solve the following equation
$$ax^3+bx^2+cx+d=0$$
```python
# Define the variables
a,b,c,d,x = sym.symbols('a,b,c,d,x')
```
```python
# Define the expression
expr=a*x**3+b*x**2+c*x+d
expr
```
We can use the `solvset` function to solve this equation
```python
solutions=sym.solveset(expr,x)
```
```python
print(solutions)
```
{-(-3*c/a + b**2/a**2)/(3*(sqrt(-4*(-3*c/a + b**2/a**2)**3 + (27*d/a - 9*b*c/a**2 + 2*b**3/a**3)**2)/2 + 27*d/(2*a) - 9*b*c/(2*a**2) + b**3/a**3)**(1/3)) - (sqrt(-4*(-3*c/a + b**2/a**2)**3 + (27*d/a - 9*b*c/a**2 + 2*b**3/a**3)**2)/2 + 27*d/(2*a) - 9*b*c/(2*a**2) + b**3/a**3)**(1/3)/3 - b/(3*a), -(-3*c/a + b**2/a**2)/(3*(-1/2 - sqrt(3)*I/2)*(sqrt(-4*(-3*c/a + b**2/a**2)**3 + (27*d/a - 9*b*c/a**2 + 2*b**3/a**3)**2)/2 + 27*d/(2*a) - 9*b*c/(2*a**2) + b**3/a**3)**(1/3)) - (-1/2 - sqrt(3)*I/2)*(sqrt(-4*(-3*c/a + b**2/a**2)**3 + (27*d/a - 9*b*c/a**2 + 2*b**3/a**3)**2)/2 + 27*d/(2*a) - 9*b*c/(2*a**2) + b**3/a**3)**(1/3)/3 - b/(3*a), -(-3*c/a + b**2/a**2)/(3*(-1/2 + sqrt(3)*I/2)*(sqrt(-4*(-3*c/a + b**2/a**2)**3 + (27*d/a - 9*b*c/a**2 + 2*b**3/a**3)**2)/2 + 27*d/(2*a) - 9*b*c/(2*a**2) + b**3/a**3)**(1/3)) - (-1/2 + sqrt(3)*I/2)*(sqrt(-4*(-3*c/a + b**2/a**2)**3 + (27*d/a - 9*b*c/a**2 + 2*b**3/a**3)**2)/2 + 27*d/(2*a) - 9*b*c/(2*a**2) + b**3/a**3)**(1/3)/3 - b/(3*a)}
```python
solutions
```
What if I need help. You can do this with any python function. `function?`
```python
# Run this command to see a help box
sym.solveset?
```
### Exercise 2.1
Use the `solveset` function to solve the following chemical problem.
Phosgene gas, $\text{COCl}_2$, dissociates at high temperatures according to the following equilibrium:
$$ \text{COCl}_2 \rightleftharpoons \text{CO} + \text{Cl}_2 $$
At $\text{400 C}$, the equilibrium constant $K_c=8.05$.
If you start with a $\text{0.250 M}$ phosgene sample at $\text{400 C}$, determine the concentrations of all species at equilibrium.
```python
# Your code here
```
Why did you pick your answer?
## 3. Calculus
We can use also Sympy to differentiate and integrate. Let us experiment with differentiating the following expression:
$$x ^ 2 - \cos(x)$$
```python
sym.diff(x ** 2 - sym.cos(x), x)
```
Similarly we can integrate:
```python
sym.integrate(x ** 2 - sym.cos(x), x)
```
We can also carry out definite integrals:
```python
sym.integrate(x ** 2 - sym.cos(x), (x, 0, 5))
```
### Exercise 3.1
Use Sympy to calculate the following:
1. $\frac{d(x ^2 + xy - \ln(y))}{dy}$
1. $\int_0^5 e^{2x}\;dx$
### Exercise 3.2
Solve the following definate integral
$$\int\limits_{ - \infty }^\infty {\frac{1}{{\sigma \sqrt {2\pi } }}{e^{ - \frac{1}{2}{{\left( {\frac{{x - \mu }}{\sigma }} \right)}^2}}}}$$
Hint, the sympy symbol for infinity is `oo`
```python
# Your code here
```
Lookup Gaussian functions: https://en.wikipedia.org/wiki/Gaussian_function
Does your answer maake sense?
## 4. Plotting with Sympy
Finally Sympy can be used to plot functions. Note that this makes use of [matplotlib](http://matplotlib.org/).
Let us plot $x^2$:
```python
expr = x ** 2
p = sym.plot(expr)
```
### Exercise 4.1 Plot the following function:
1. $y=x + cos(x)$
1. ${\frac{1}{{ \sqrt {2\pi } }}{e^{ - \frac{x^2}{2}}}}$
```python
# Your code here
```
# Lecture
## L1. Hydrogen Atom
Sympy has built in modules for the eigenfunctions of the hydrogen atom.
```python
import sympy.physics.hydrogen
import numpy as np
```
You can caluclate the eigenvalues ($E$) in Hartrees
`sym.physics.hydrogen.E_nl(n,Z)`
```python
sym.physics.hydrogen.E_nl(1,1)
```
-1/2
We can use a loop to print out many energies
```python
for n in range(1,5):
print(sym.physics.hydrogen.E_nl(n,1))
```
-1/2
-1/8
-1/18
-1/32
We can plot the hydrogen radial wavefunction (1s orbital)
```python
sympy.symbols('r')
sympy.physics.hydrogen.R_nl(1, 0, r, 1)
```
2*exp(-r)
```python
sym.plot(sympy.physics.hydrogen.R_nl(1, 0, r, 1),(r,0,10.50))
```
And the probablity distribution function
```python
sympy.symbols('r')
prob_1s=sympy.physics.hydrogen.R_nl(1, 0, r, 1)*sympy.physics.hydrogen.R_nl(1, 0, r, 1)
prob_1s
```
4*exp(-2*r)
```python
sym.plot(prob_1s,(r,0,10))
```
Plot a 2s orbital
```python
sympy.symbols('r')
prob_2s=sympy.physics.hydrogen.R_nl(2, 0, r, 1)*sympy.physics.hydrogen.R_nl(2, 0, r, 1)
prob_2s
```
(-r + 2)**2*exp(-r)/8
```python
sym.plot(prob_2s,(r,0,10))
```
We can change the range to see the node better.
```python
sym.plot(prob_2s,(r,1,8))
```
Notice the node!
### Exercise L1.1
Plot the radial distriubution function for a 2p, 3s, 4s, and 3d orbital.
```python
# Your code here
```
```python
```
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.