text
stringlengths 0
3.34M
|
---|
State Before: 𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.219286
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.219381
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
hf : HasFDerivAt f f' x
v : E
α : Type u_4
c : α → 𝕜
l : Filter α
hc : Tendsto (fun n => ‖c n‖) l atTop
⊢ Tendsto (fun n => c n • (f (x + (c n)⁻¹ • v) - f x)) l (𝓝 (↑f' v)) State After: 𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.219286
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.219381
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
hf : HasFDerivAt f f' x
v : E
α : Type u_4
c : α → 𝕜
l : Filter α
hc : Tendsto (fun n => ‖c n‖) l atTop
⊢ Tendsto (fun n => c n • (c n)⁻¹ • v) l (𝓝 v) Tactic: refine' (hasFDerivWithinAt_univ.2 hf).lim _ univ_mem hc _ State Before: 𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.219286
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.219381
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
hf : HasFDerivAt f f' x
v : E
α : Type u_4
c : α → 𝕜
l : Filter α
hc : Tendsto (fun n => ‖c n‖) l atTop
⊢ Tendsto (fun n => c n • (c n)⁻¹ • v) l (𝓝 v) State After: 𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.219286
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.219381
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
hf : HasFDerivAt f f' x
v : E
α : Type u_4
c : α → 𝕜
l : Filter α
hc : Tendsto (fun n => ‖c n‖) l atTop
U : Set E
hU : U ∈ 𝓝 v
⊢ U ∈ map (fun n => c n • (c n)⁻¹ • v) l Tactic: intro U hU State Before: 𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.219286
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.219381
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
hf : HasFDerivAt f f' x
v : E
α : Type u_4
c : α → 𝕜
l : Filter α
hc : Tendsto (fun n => ‖c n‖) l atTop
U : Set E
hU : U ∈ 𝓝 v
⊢ U ∈ map (fun n => c n • (c n)⁻¹ • v) l State After: 𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.219286
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.219381
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
hf : HasFDerivAt f f' x
v : E
α : Type u_4
c : α → 𝕜
l : Filter α
hc : Tendsto (fun n => ‖c n‖) l atTop
U : Set E
hU : U ∈ 𝓝 v
y : α
hy : c y ≠ 0
⊢ (fun n => c n • (c n)⁻¹ • v) y ∈ U Tactic: refine' (eventually_ne_of_tendsto_norm_atTop hc (0 : 𝕜)).mono fun y hy => _ State Before: 𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.219286
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.219381
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
hf : HasFDerivAt f f' x
v : E
α : Type u_4
c : α → 𝕜
l : Filter α
hc : Tendsto (fun n => ‖c n‖) l atTop
U : Set E
hU : U ∈ 𝓝 v
y : α
hy : c y ≠ 0
⊢ (fun n => c n • (c n)⁻¹ • v) y ∈ U State After: case h.e'_4
𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.219286
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.219381
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
hf : HasFDerivAt f f' x
v : E
α : Type u_4
c : α → 𝕜
l : Filter α
hc : Tendsto (fun n => ‖c n‖) l atTop
U : Set E
hU : U ∈ 𝓝 v
y : α
hy : c y ≠ 0
⊢ (fun n => c n • (c n)⁻¹ • v) y = v Tactic: convert mem_of_mem_nhds hU State Before: case h.e'_4
𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.219286
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.219381
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
hf : HasFDerivAt f f' x
v : E
α : Type u_4
c : α → 𝕜
l : Filter α
hc : Tendsto (fun n => ‖c n‖) l atTop
U : Set E
hU : U ∈ 𝓝 v
y : α
hy : c y ≠ 0
⊢ (fun n => c n • (c n)⁻¹ • v) y = v State After: case h.e'_4
𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.219286
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.219381
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
hf : HasFDerivAt f f' x
v : E
α : Type u_4
c : α → 𝕜
l : Filter α
hc : Tendsto (fun n => ‖c n‖) l atTop
U : Set E
hU : U ∈ 𝓝 v
y : α
hy : c y ≠ 0
⊢ c y • (c y)⁻¹ • v = v Tactic: dsimp only State Before: case h.e'_4
𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.219286
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.219381
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
hf : HasFDerivAt f f' x
v : E
α : Type u_4
c : α → 𝕜
l : Filter α
hc : Tendsto (fun n => ‖c n‖) l atTop
U : Set E
hU : U ∈ 𝓝 v
y : α
hy : c y ≠ 0
⊢ c y • (c y)⁻¹ • v = v State After: no goals Tactic: rw [← mul_smul, mul_inv_cancel hy, one_smul] |
close all; clear all
% pde = HodgeLaplacianEdata1;
pde = HodgeLaplacianFdata1;
[node,elem] = squaremesh([0,1,0,1],1/32);
% bdFlag = setboundary(node,elem,'Neumann');
% Pure Neumann boundary condition doesn't work.
% bdFlag = setboundary(node,elem,'Dirichlet');
bdFlag = setboundary(node,elem,'Dirichlet','x==0','Neumann','~(x==0)');
err = zeros(4,1); N = zeros(4,1);
option = [];
for i = 1:4
% [sigma,u] = HodgeLaplacianE(node,elem,pde,bdFlag,option);
[sigma,u,AD] = HodgeLaplacianF(node,elem,pde,bdFlag,option);
err(i) = getL2error(node,elem,pde.exactsigma,sigma);
N(i) = size(u,1);
[node,elem,bdFlag] = uniformrefine(node,elem,bdFlag);
end
showrate(N,err,2); |
[STATEMENT]
lemma "Inl \<equiv> \<lambda>a. Abs_sum (Inl_Rep a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Inl \<equiv> \<lambda>a. Abs_sum (Inl_Rep a)
[PROOF STEP]
nitpick [card = 1, expect = none]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Inl \<equiv> \<lambda>a. Abs_sum (Inl_Rep a)
[PROOF STEP]
by (simp add: Inl_def o_def) |
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#if defined(ONLY_V2)
# define NO_BV
# define NO_SV
#endif
#if defined(ONLY_BV)
# define NO_V2
# define NO_SV
#endif
#if defined(ONLY_SV)
# define NO_V2
# define NO_BV
#endif
#if !defined(NO_V2)
#include <boost/variant2/variant.hpp>
#endif
#if !defined(NO_BV)
#include <boost/variant.hpp>
#endif
#if !defined(NO_SV)
#include <variant>
#endif
#include <type_traits>
#include <chrono>
#include <iostream>
#include <iomanip>
#include <vector>
struct prefix
{
int v_;
};
struct X1: prefix {};
struct X2: prefix {};
struct X3: prefix {};
struct X4: prefix {};
struct X5: prefix {};
struct X6: prefix {};
struct X7: prefix {};
struct X8: prefix {};
struct X9: prefix {};
struct X10: prefix {};
struct X11: prefix {};
struct X12: prefix {};
inline int get_value( prefix const& v )
{
return v.v_;
}
#if !defined(NO_V2)
template<class... T> int get_value( boost::variant2::variant<T...> const& v )
{
return visit( []( prefix const& x ) { return x.v_; }, v );
}
#endif
#if !defined(NO_BV)
template<class... T> int get_value( boost::variant<T...> const& v )
{
return boost::apply_visitor( []( prefix const& x ) { return x.v_; }, v );
}
#endif
#if !defined(NO_SV)
template<class... T> int get_value( std::variant<T...> const& v )
{
return visit( []( prefix const& x ) { return x.v_; }, v );
}
#endif
template<class V> void test_( int N )
{
std::vector<V> w;
// lack of reserve is deliberate
auto tp1 = std::chrono::high_resolution_clock::now();
for( int i = 0; i < N / 12; ++i )
{
w.push_back( X1{ i } );
w.push_back( X2{ i } );
w.push_back( X3{ i } );
w.push_back( X4{ i } );
w.push_back( X5{ i } );
w.push_back( X6{ i } );
w.push_back( X7{ i } );
w.push_back( X8{ i } );
w.push_back( X9{ i } );
w.push_back( X10{ i } );
w.push_back( X11{ i } );
w.push_back( X12{ i } );
}
unsigned long long s = 0;
for( std::size_t i = 0, n = w.size(); i < n; ++i )
{
s = s + get_value( w[ i ] );
}
auto tp2 = std::chrono::high_resolution_clock::now();
std::cout << std::setw( 6 ) << std::chrono::duration_cast<std::chrono::milliseconds>( tp2 - tp1 ).count() << " ms; S=" << s << "\n";
}
template<class... T> void test( int N )
{
std::cout << "N=" << N << ":\n";
std::cout << " prefix: "; test_<prefix>( N );
#if !defined(NO_V2)
std::cout << " variant2: "; test_<boost::variant2::variant<T...>>( N );
#endif
#if !defined(NO_BV)
std::cout << "boost::variant: "; test_<boost::variant<T...>>( N );
#endif
#if !defined(NO_SV)
std::cout << " std::variant: "; test_<std::variant<T...>>( N );
#endif
std::cout << '\n';
}
int main()
{
int const N = 100'000'000;
test<X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12>( N );
}
|
/-
2. Prove the following identities, replacing the “sorry” placeholders with actual proofs. These require classical reasoning.
-/
open classical
variables p q r s : Prop
example : (p → r ∨ s) → ((p → r) ∨ (p → s)) :=
assume h : p → r ∨ s,
(em p).elim
(
assume hp : p,
have hrs : r ∨ s, from h hp,
hrs.elim
(
assume hr : r,
show (p → r) ∨ (p → s),
from or.inl (assume hp : p, hr)
)
(
assume hs : s,
show (p → r) ∨ (p → s),
from or.inr (assume hp : p, hs)
)
)
(
assume hnp : ¬p,
suffices hpr : p → r, from or.inl hpr,
show p → r, from
assume hp : p,
show r, from false.elim (hnp hp)
)
-- short version
example : (p → r ∨ s) → ((p → r) ∨ (p → s)) :=
λ h,
(em p).elim
(
λ hp,
(h hp).elim
(λ hr, or.inl (λ hp : p, hr))
(λ hs, or.inr (λ hp : p, hs))
)
(λ hnp, or.inl (λ hp, absurd hp hnp))
example : ¬(p ∧ q) → ¬p ∨ ¬q :=
assume h : ¬(p ∧ q),
or.elim (em p)
(
assume hp : p,
have hnq : ¬q, from
assume hq : q,
h ⟨hp, hq⟩,
or.inr hnq
)
(
assume hnp : ¬p,
or.inl hnp
)
-- short version
example : ¬(p ∧ q) → ¬p ∨ ¬q :=
λ h,
or.elim (em p)
(λ hp, or.inr (λ hq, h ⟨hp, hq⟩))
(λ hnp, or.inl hnp)
example : ¬(p → q) → p ∧ ¬q :=
assume h : ¬(p → q),
(em p).elim
(
assume hp : p,
(em q).elim
(
assume hq : q,
have hpimplq : p → q, from
assume hp' : p,
hq,
show p ∧ ¬q, from false.elim (h hpimplq)
)
(
assume hnq : ¬q,
show p ∧ ¬q, from ⟨hp, hnq⟩
)
)
(
assume hnp : ¬p,
have hpimplq : p → q, from
assume hp : p,
false.elim (hnp hp),
false.elim (h hpimplq)
)
-- short version
example : ¬(p → q) → p ∧ ¬q :=
λ h,
(em p).elim
(
λ hp : p,
(em q).elim
(λ hq, absurd (λ hp', hq) h)
(λ hnq, ⟨hp, hnq⟩)
)
(
λ hnp,
false.elim (h (λ hp, absurd hp hnp))
)
example : (p → q) → (¬p ∨ q) :=
assume h : p → q,
(em p).elim
(
assume hp : p,
or.inr (h hp)
)
(
assume hnp : ¬p,
or.inl hnp
)
-- short version
example : (p → q) → (¬p ∨ q) :=
λ h,
(em p).elim
(λ hp, or.inr (h hp))
(λ hnp, or.inl hnp)
example : (¬q → ¬p) → (p → q) :=
assume h : ¬q → ¬p,
assume hp : p,
(em q).elim
(
assume hq : q,
hq
)
(
assume hnq : ¬q,
absurd hp (h hnq)
)
-- short version
example : (¬q → ¬p) → (p → q) :=
λ h,
λ hp,
(em q).elim
id
(λ hnq, absurd hp (h hnq))
example : p ∨ ¬p :=
em p
example : (((p → q) → p) → p) :=
assume h : (p → q) → p,
(em p).elim
(
assume hp : p,
hp
)
(
assume hnp : ¬p,
have hpimplq : p → q, from
assume hp : p,
absurd hp hnp,
absurd (h hpimplq) hnp
)
-- short version
example : (((p → q) → p) → p) :=
λ h,
(em p).elim
id
(λ hnp, absurd (h (λ hp : p, absurd hp hnp)) hnp)
|
(* Title: HOL/Auth/n_flash_nodata_cub_lemma_on_inv__60.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 n_flash_nodata_cub Protocol Case Study*}
theory n_flash_nodata_cub_lemma_on_inv__60 imports n_flash_nodata_cub_base
begin
section{*All lemmas on causal relation between inv__60 and some rule r*}
lemma n_PI_Remote_GetVsinv__60:
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__60 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__60 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_Remote_GetXVsinv__60:
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__60 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__60 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_NakVsinv__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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_Get_Get__part__1Vsinv__60:
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__60 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__60 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_Get_Put_HeadVsinv__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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_GetX__part__1Vsinv__60:
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__60 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__60 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_1Vsinv__60:
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__60 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__60 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_2Vsinv__60:
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__60 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__60 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_3Vsinv__60:
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__60 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__60 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_4Vsinv__60:
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__60 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__60 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_5Vsinv__60:
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__60 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__60 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_6Vsinv__60:
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__60 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__60 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_7__part__0Vsinv__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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__60:
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__60 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__60 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_GetX_NakVsinv__60:
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__60 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__60 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__60:
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__60 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__60 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_PutVsinv__60:
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__60 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__60 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_Remote_PutXVsinv__60:
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__60 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__60 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__60:
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__60 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__60 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 "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_Get)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''InvSet'') p__Inv4)) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_Get)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''InvSet'') src)) (Const true))))" in exI, auto) done
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_2Vsinv__60:
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__60 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_2 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__60 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 "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_Get)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''InvSet'') p__Inv4)) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_Get)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''InvSet'') src)) (Const true))))" in exI, auto) done
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_3Vsinv__60:
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__60 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_3 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__60 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 "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_Get)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''InvSet'') p__Inv4)) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_Get)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''InvSet'') src)) (Const true))))" in exI, auto) done
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_GetVsinv__60:
assumes a1: "(r=n_PI_Local_Get_Get )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 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__60 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_PI_Local_GetX_GetX__part__0Vsinv__60:
assumes a1: "(r=n_PI_Local_GetX_GetX__part__0 )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 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__60 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_PI_Local_GetX_GetX__part__1Vsinv__60:
assumes a1: "(r=n_PI_Local_GetX_GetX__part__1 )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 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__60 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_PI_Local_GetX_PutX_HeadVld__part__0Vsinv__60:
assumes a1: "(r=n_PI_Local_GetX_PutX_HeadVld__part__0 N )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 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__60 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_PI_Local_GetX_PutX_HeadVld__part__1Vsinv__60:
assumes a1: "(r=n_PI_Local_GetX_PutX_HeadVld__part__1 N )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 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__60 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_Nak_ClearVsinv__60:
assumes a1: "(r=n_NI_Nak_Clear )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 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__60 p__Inv4" apply fastforce done
have "?P3 s"
apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_Get)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))) (eqn (IVar (Field (Field (Ident ''Sta'') ''NakcMsg'') ''Cmd'')) (Const NAKC_Nakc))))" in exI, auto) done
then show "invHoldForRule s f r (invariants N)" by auto
qed
lemma n_NI_Local_PutVsinv__60:
assumes a1: "(r=n_NI_Local_Put )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 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__60 p__Inv4" apply fastforce done
have "?P3 s"
apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_Get)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))) (eqn (IVar (Field (Field (Ident ''Sta'') ''HomeUniMsg'') ''Cmd'')) (Const UNI_Put))))" in exI, auto) done
then show "invHoldForRule s f r (invariants N)" by auto
qed
lemma n_NI_Local_PutXAcksDoneVsinv__60:
assumes a1: "(r=n_NI_Local_PutXAcksDone )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 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__60 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_Get))) (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_FAckVsinv__60:
assumes a1: "(r=n_NI_FAck )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 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__60 p__Inv4" apply fastforce done
have "?P3 s"
apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_Get)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))) (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck))))" in exI, auto) done
then show "invHoldForRule s f r (invariants N)" by auto
qed
lemma n_NI_ShWbVsinv__60:
assumes a1: "(r=n_NI_ShWb N )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 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__60 p__Inv4" apply fastforce done
have "?P3 s"
apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''Cmd'')) (Const UNI_Get)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') p__Inv4) ''HomeProc'')) (Const false))) (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_ShWb))))" in exI, auto) done
then show "invHoldForRule s f r (invariants N)" by auto
qed
lemma n_NI_Remote_GetX_PutX_HomeVsinv__60:
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__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Local_GetX_PutX__part__0Vsinv__60:
assumes a1: "r=n_PI_Local_GetX_PutX__part__0 " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_WbVsinv__60:
assumes a1: "r=n_NI_Wb " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Remote_ReplaceVsinv__60:
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__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Local_ReplaceVsinv__60:
assumes a1: "r=n_PI_Local_Replace " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_InvAck_existsVsinv__60:
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__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Remote_PutXVsinv__60:
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__60 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__60:
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__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_InvVsinv__60:
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__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Local_PutXVsinv__60:
assumes a1: "r=n_PI_Local_PutX " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Local_Get_PutVsinv__60:
assumes a1: "r=n_PI_Local_Get_Put " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_ReplaceVsinv__60:
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__60 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__60:
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__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Local_GetX_PutX__part__1Vsinv__60:
assumes a1: "r=n_PI_Local_GetX_PutX__part__1 " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 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__60:
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__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_InvAck_exists_HomeVsinv__60:
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__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Replace_HomeVsinv__60:
assumes a1: "r=n_NI_Replace_Home " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Nak_HomeVsinv__60:
assumes a1: "r=n_NI_Nak_Home " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__60 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
end
|
#Objetivo: introducir concepto de curva ROC
#limpio la memoria
rm(list=ls())
gc()
library("data.table")
setwd("E:/UBA/2019-II/DM en Finanzas/Dropbox Prof/datasets")
#cargo los datos
dataset <- fread("201902.txt")
#creo una clase que se 1 cuando es BAJA+2 , y 0 en caso contrario
#esto me simplifica las cuentas
dataset[ , clase01:= as.numeric(clase_ternaria=="BAJA+2") ]
#calculos basicos
universo <- nrow(dataset )
pos_total <- sum(dataset$clase01 )
neg_total <- universo - pos_total
#tambien podria hacer
neg_total <- sum( 1 - dataset$clase01 )
#----------------
#Dibujo la curva ROC del predicado mcuentas_saldo<= -120000
#positivos del predicado
pos_pred <- sum( dataset[ (mcuentas_saldo<= -120000) , clase01] )
#negativos del predicado
neg_pred <- sum( dataset[ (mcuentas_saldo<= -120000) , 1 - clase01] )
#Tener en cuenta que los NA's no se estan contando en este predicado !
#la diagonal de la Curva Roc
azar_neg <- c( 0, neg_total )
azar_pos <- c( 0, pos_total )
#grafico
plot( azar_neg,
azar_pos,
type="n",
main=paste( "ROC Curve", "(mcuentas_saldo<= -120000)" ),
xlab="neg",
ylab="pos",
pch=19)
#dibujo la diagonal
lines( azar_neg, azar_pos, type="l" , col="black", lwd=2)
#para el predicado creo el vector con los tres puntos
vneg <- c( 0, neg_pred, neg_total )
vpos <- c( 0, pos_pred, pos_total )
#dibujo la linea
lines( vneg, vpos, type="l" , col="green", lwd=2)
#Calculo AUC Area Under Curve
triangulo_area <- pos_pred*neg_pred/2
trapecio_area <- (pos_pred + pos_total)*(neg_total-neg_pred) / 2
AUC <- (triangulo_area + trapecio_area ) / (pos_total*neg_total)
#----------------------
# Creo una funcion para automatizar
pred_graficar = function(dataset, pcolumna, pvalor )
{
#calculos basicos
universo <- nrow(dataset )
pos_total <- sum(dataset$clase01 )
neg_total <- universo - pos_total
pos_pred <- sum( dataset[ get(pcolumna) <= pvalor , clase01] )
neg_pred <- sum( 1 - dataset[ get(pcolumna) <= pvalor, clase01] )
AUC <- (pos_pred*neg_pred + (pos_pred + pos_total)*(neg_total-neg_pred) ) / (2*pos_total*neg_total)
#la diagonal
azar_neg <- c( 0, neg_total )
azar_pos <- c( 0, pos_total )
#grafico
plot( azar_neg,
azar_pos,
type="n",
main=paste( "ROC Curve", "(", pcolumna, "<=", pvalor, ")", "AUC=", AUC ),
xlab="neg",
ylab="pos",
pch=19)
#dibujo la linea del azar
lines( azar_neg, azar_pos, type="l" , col="black", lwd=2)
#creo el vector con los tres puntos
vneg <- c( 0, neg_pred, neg_total )
vpos <- c( 0, pos_pred, pos_total )
#dibujo la curva del predicado
lines( vneg, vpos, type="l" , col="green", lwd=2)
return( AUC )
}
#----------------------
#algunos cortes de la variable mcuentas_saldo
pred_graficar( dataset, "mcuentas_saldo", -120000 )
pred_graficar( dataset, "mcuentas_saldo", 0 )
pred_graficar( dataset, "mcuentas_saldo", 10000 )
#algunos cortes de la variable Visa_mconsumototal
pred_graficar( dataset, "Visa_mconsumototal", 200000 )
#una variable que no esta correlacionada con la clase
pred_graficar( dataset, "cliente_edad", 40 )
#una vieja conocida variable
pred_graficar( dataset, "Visa_cuenta_estado", 10 )
#por que esta por debajo de la linea de azar ?
|
#failif
#...
.* found at index >= .dynsym's sh_info value .*
#...
|
function [res, bytesReq] = hlp_haveSufficientMemory(numelts,datatype)
% Check if we have sufficient memory to allocate an array.
%
% Inputs:
% numelts: The number of elements in the array.
% If the array is sparse, then numelts is the number of non-zero elements
% datatype: The class of the array.
% This can be any of the following: logical,int*,uint*,single,double,char
%
% Output:
% res: true if we have sufficient memory, else false
% bytesReq: the number of bytesRequired to allocate the array
%
% Author: Tim Mullen, SCCN/INC/UCSD, Jan, 2014
switch datatype
case {'logical','int8','uint8'} , N=1;
case {'char','int16','uint16'} , N=2;
case {'double','int64','uint64'}, N=8;
case {'single','int32','uint32'}, N=4;
otherwise
error('unsupported datatype %s',datatype);
end
bytesReq = numelts*N;
res = (bytesReq <= hlp_getAvailableMemory('Bytes')); |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Instance.StrictGroupoids where
-- The 'strict' category of groupoids.
-- The difference here is that _≈_ is not |NaturalIsomorphism| but |_≡F_|
open import Level
open import Relation.Binary.PropositionalEquality using (refl)
open import Categories.Category using (Category)
open import Categories.Category.Groupoid using (Groupoid)
open import Categories.Category.Instance.Groupoids using (F-resp-⁻¹)
open import Categories.Functor using (Functor; id; _∘F_)
open import Categories.Functor.Equivalence
private
variable
o ℓ e : Level
open Groupoid using (category)
Groupoids : ∀ o ℓ e → Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e)
Groupoids o ℓ e = record
{ Obj = Groupoid o ℓ e
; _⇒_ = λ G H → Functor (category G) (category H)
; _≈_ = _≡F_
; id = id
; _∘_ = _∘F_
; assoc = λ {_ _ _ _ F G H} → ≡F-assoc {F = F} {G} {H}
; sym-assoc = λ {_ _ _ _ F G H} → ≡F-sym-assoc {F = F} {G} {H}
; identityˡ = ≡F-identityˡ
; identityʳ = ≡F-identityʳ
; identity² = ≡F-identity²
; equiv = ≡F-equiv
; ∘-resp-≈ = ∘F-resp-≡F
}
|
Formal statement is: lemma rational_cboxes: fixes x :: "'a::euclidean_space" assumes "e > 0" shows "\<exists>a b. (\<forall>i\<in>Basis. a \<bullet> i \<in> \<rat> \<and> b \<bullet> i \<in> \<rat>) \<and> x \<in> cbox a b \<and> cbox a b \<subseteq> ball x e" Informal statement is: For every $x \in \mathbb{R}^n$ and every $\epsilon > 0$, there exists a box $B$ with rational coordinates such that $x \in B$ and $B \subseteq B(x, \epsilon)$. |
#ifndef FUSED_LASSO_B_H
#define FUSED_LASSO_B_H
#include "ALM_Katyusha.h"
#include <string>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include <stdio.h> /* printf */
#include <time.h>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <ctime>
#include <math.h>
//This class solves problem: min_{x} sum_i 0.5*(Ax- b)^2+ sum_i |x^i- x^{i+1}|+ P(x) by IPALM_Katyusha
// where P(x)=frac{sig2}{2}|x|_2^2 +sig1|x|_1.
// f^i(x)= 0.5*(x- b_i)^2, h^i(x)= |x|, Mx= (x^1- x^2, ..., x_n- x_1)
template<typename L, typename D>
class Fused_lasso_b: public ALM_Katyusha<L, D>
{
private:
D lambda3;
Matrix<L,D> my_M;
Matrix<L,D> my_A;
D val_lambda_f;
protected:
public:
D sig1;
D sig2;
Fused_lasso_b(const char* Matrix_file, D val_lambda1, D val_lambda2, D val_lambda3)
:ALM_Katyusha<L,D>(),my_A(Matrix_file)
{
my_M.construct_fused_matrix(my_A);
this->matrix_merge(my_M,my_A);
sig1=val_lambda1;
sig2=val_lambda2;
lambda3=val_lambda3;
this->L_h= val_lambda3;
this->mu_g= sig2;
}
L get_n(){return my_A.nfeatures;}
L get_m(){return my_A.nfeatures+ my_A.nsamples;}
inline void set_matrix_A(){
this->data_A= my_A;
}
inline void set_matrix_M(){
this->data_M= my_M;
}
inline D value_of_f_j(D x, L i){
return 0.5*(x- my_A.b[i])*(x- my_A.b[i]);
}
inline D gradient_of_f_j(D x, L i){
return x- my_A.b[i];
}
inline D value_of_f_star_j(D x, L i){
return 0.5*x*x+ my_A.b[i]*x;
}
inline void rescale(){
this->lambda1= sig1;
this->lambda2= sig2+ this->tau_s*this->beta_s;
}
inline D value_of_P_j(D x, L j){
return sig1*fabs(x)+ sig2/2*x*x;
}
inline D prox_of_P_j(D x1, D x2, L j){
if (x1*x2- sig1> 0){
return (x1*x2- sig1)/(sig2+ x2);
}
else if(x1*x2+ sig1< 0){
return (x1*x2+ sig1)/(sig2+ x2);
}
else{
return 0;
}
}
inline D value_of_h_j(D x, L i){
return lambda3*fabs(x);
}
inline D value_of_h_star_j(D x, L j){
if (x<= 2*lambda3 && x>= -2*lambda3){
return 0;
}
else{
cout<< "error in h*(x)"<< endl;
cout<< "lambda3= "<< lambda3<< "; x= "<< x<< endl;
system("pause");
return std::numeric_limits<double>::max();
}
}
inline D compute_one_step(D tau, D u, D x){
D new_x;
if(x>tau*(this->lambda1+u))
new_x=(x-tau*(this->lambda1+u))/(1+this->lambda2*tau);
else if(x<tau*(u-this->lambda1))
new_x=(x-tau*(u-this->lambda1))/(1+this->lambda2*tau);
else
new_x=0;
return new_x;
}
inline D prox_of_h_star_j(D x1, D x2, L j){
if (x1> lambda3){
return lambda3;
}
else if (x1< -lambda3){
return -lambda3;
}
else{
return x1;
}
}
inline D feasible_dual(vector<D> & x){
if(this->lambda2>0)
{
return 1;
}
else
{
D scal=1;
L l=x.size();
for(L i=0;i<l;i++)
if(fabs(x[i])>this->lambda1)
scal=min(this->lambda1/fabs(x[i]),scal);
return scal;
}
}
//We implement Section 6.2 of SPDC paper for 'just-in-time' update
//t0 is t0+1 in the paper SPDC ; x is the z vector in Katyusha
inline void compute_just_in_time_prox_grad_without_x_s(D tau, D u, D &x, L t0,L t1, D w, D &y, L j){
if(t0==t1)
return;
else{
if(this->lambda2>0)
{
D theta=1./(1+this->lambda2*tau);
D hplus=(u+this->lambda1)/this->lambda2;
D hminus=(u-this->lambda1)/this->lambda2;
D p=pow(theta,t1-t0);
if(this->lambda1==0){
y=compute_aid_2(p,theta, hplus, t1-t0, x, y, w);
x=p*(x)-(1-p)*u/this->lambda2;
}else{
if(x==0){
if(this->lambda1+u<0){
y=compute_aid_2(p,theta, hplus, t1-t0, x, y, w);
x=p*x-(1-p)*hplus;
}
else if(u-this->lambda1>0){
y=compute_aid_2(p,theta, hminus, t1-t0, x, y, w);
x=p*x-(1-p)*hminus;
}else{
x=0;
D p2=pow(this->theta3,t1-t0);
D tmp2=(1-p2)/(this->theta1+this->theta2);
y=(this->theta2*w)*tmp2+p2*y;
}
}else if(x>0){
if(this->lambda1+u<=0){
y=compute_aid_2(p,theta, hplus, t1-t0, x, y, w);
x=p*x-(1-p)*hplus;
}else{
D t=t0-log(1+this->lambda2*x/(this->lambda1+u))/log(theta);
if(t<t1){
L t_tmp=floor(t);
p=pow(theta,t_tmp-t0);
y=compute_aid_2(p,theta, hplus, t_tmp-t0, x, y, w);
x=p*x-(1-p)*hplus;
x=compute_one_step(tau,u,x);
y=this->theta1*x+this->theta2*w+this->theta3*y;
compute_just_in_time_prox_grad_without_x_s(tau, u, x, t_tmp+1, t1, w, y, j);
}
else{
y=compute_aid_2(p,theta, hplus, t1-t0, x, y, w);
x=p*x-(1-p)*hplus;
}
}
}else if(x<0){
D minusw=-w;
D minusx=-x;
D minusy=-y;
compute_just_in_time_prox_grad_without_x_s(tau, -u, minusx, t0, t1,minusw, minusy, j);
x=-minusx;
y=-minusy;
}
}
}
else{
if(this->lambda1==0){
y=compute_aid(tau*u, t1-t0, x, y, w);
x=x-(t1-t0)*tau*u;
}
else{
if(x==0){
if(this->lambda1+u<0){
y=compute_aid(tau*(this->lambda1+u), t1-t0, x, y, w);
x=x-(t1-t0)*tau*(this->lambda1+u);
}
else if(u-this->lambda1>0){
y=compute_aid(tau*(-this->lambda1+u), t1-t0, x, y, w);
x=x-(t1-t0)*tau*(u-this->lambda1);
}else{
D p2=pow(this->theta3,t1-t0);
D tmp2=(1-p2)/(this->theta1+this->theta2);
y=(this->theta2*w)*tmp2+p2*y;
x=0;
}
}else if(x>0){
if(this->lambda1+u<=0){
y=compute_aid(tau*(this->lambda1+u), t1-t0, x, y, w);
x=x-(t1-t0)*tau*(this->lambda1+u);
}else{
D t=t0+x/(this->lambda1+u);
if(t<t1){
L t_tmp=floor(t);
y=compute_aid(tau*(this->lambda1+u), t_tmp-t0, x, y, w);
x=x-(t_tmp-t0)*tau*(this->lambda1+u);
x=compute_one_step(tau,u,x);
y=this->theta1*x+this->theta2*w+this->theta3*y;
compute_just_in_time_prox_grad_without_x_s(tau, u, x, t_tmp+1, t1, w, y, j);
}
else{
y=compute_aid(tau*(this->lambda1+u), t1-t0, x, y, w);
x=x-(t1-t0)*tau*(this->lambda1+u);
}
}
}else if(x<0){
D minusw=-w;
D minusx=-x;
D minusy=-y;
compute_just_in_time_prox_grad_without_x_s(tau, -u, minusx, t0, t1,minusw, minusy, j);
x=-minusx;
y=-minusy;
}
}
}
}
};
// compute_aid returns the value of y_{k+s} given by: y_{k+1}=theta1*z_{k+1}+theta2*w+(1-theta1-theta2)*y_k; z_{k+i}=z_k-i*h
D compute_aid(D h, D s, D x, D y, D w){
D p2=pow(this->theta3,s);
D tmp2=(1-p2)/(this->theta1+this->theta2);
D tmp3=(tmp2*this->theta3-p2*s)/(this->theta1+this->theta2);
y=this->theta1*(tmp2*(x-s*h)+h*tmp3)+this->theta2*w*tmp2+p2*y;
return y;
}
// compute_aid_2 returns the value of y_{k+s} given by: y_{k+1}=theta1*z_{k+1}+theta2*w+(1-theta1-theta2)*y_k; z_{k+i}=q^i(z_k+h)-h
//p=q^s;
D compute_aid_2(D p, D q, D h, D s, D x, D y, D w){
D theta3overq=this->theta3/q;
D p2=pow(this->theta3,s);
D p3=pow(theta3overq,s);
D tmp=(1-p3)/(1-theta3overq);
D tmp2=(1-p2)/(this->theta1+this->theta2);
y=this->theta1*p*(x+h)*tmp+(this->theta2*w-this->theta1*h)*tmp2+p2*y;
return y;
}
void Katyusha_solver(D beta_0, D epsilon_0, D eta , D rho, vector<D> & x0,vector<D> & y0,L val_tau, L max_nb_outer, L p_N_1, L p_N_2,string filename1, string filename2, D time){
this->ALM_solve_with_L_Katyusha(beta_0, epsilon_0, eta, rho, x0,y0, val_tau, max_nb_outer, p_N_1, p_N_2, filename1, filename2, time);
}
};
#endif
|
If a sequence of real numbers is summable, then the sequence is bounded. |
{-# OPTIONS --safe #-}
module Cubical.Data.SumFin.Properties where
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Univalence
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Unit
import Cubical.Data.Fin as Fin
open import Cubical.Data.Nat
open import Cubical.Data.SumFin.Base as SumFin
open import Cubical.Data.Sum
open import Cubical.Data.Sigma
open import Cubical.HITs.PropositionalTruncation
private
variable
ℓ : Level
k : ℕ
SumFin→Fin : Fin k → Fin.Fin k
SumFin→Fin = SumFin.elim (λ {k} _ → Fin.Fin k) Fin.fzero Fin.fsuc
Fin→SumFin : Fin.Fin k → Fin k
Fin→SumFin = Fin.elim (λ {k} _ → Fin k) fzero fsuc
Fin→SumFin-fsuc : (fk : Fin.Fin k) → Fin→SumFin (Fin.fsuc fk) ≡ fsuc (Fin→SumFin fk)
Fin→SumFin-fsuc = Fin.elim-fsuc (λ {k} _ → Fin k) fzero fsuc
SumFin→Fin→SumFin : (fk : Fin k) → Fin→SumFin (SumFin→Fin fk) ≡ fk
SumFin→Fin→SumFin = SumFin.elim (λ fk → Fin→SumFin (SumFin→Fin fk) ≡ fk)
refl λ {k} {fk} eq →
Fin→SumFin (Fin.fsuc (SumFin→Fin fk)) ≡⟨ Fin→SumFin-fsuc (SumFin→Fin fk) ⟩
fsuc (Fin→SumFin (SumFin→Fin fk)) ≡⟨ cong fsuc eq ⟩
fsuc fk ∎
Fin→SumFin→Fin : (fk : Fin.Fin k) → SumFin→Fin (Fin→SumFin fk) ≡ fk
Fin→SumFin→Fin = Fin.elim (λ fk → SumFin→Fin (Fin→SumFin fk) ≡ fk)
refl λ {k} {fk} eq →
SumFin→Fin (Fin→SumFin (Fin.fsuc fk)) ≡⟨ cong SumFin→Fin (Fin→SumFin-fsuc fk) ⟩
Fin.fsuc (SumFin→Fin (Fin→SumFin fk)) ≡⟨ cong Fin.fsuc eq ⟩
Fin.fsuc fk ∎
SumFin≃Fin : ∀ k → Fin k ≃ Fin.Fin k
SumFin≃Fin _ =
isoToEquiv (iso SumFin→Fin Fin→SumFin Fin→SumFin→Fin SumFin→Fin→SumFin)
SumFin≡Fin : ∀ k → Fin k ≡ Fin.Fin k
SumFin≡Fin k = ua (SumFin≃Fin k)
-- Closure properties of SumFin under type constructors
private
_⋆_ = compEquiv
infixr 30 _⋆_
SumFin⊎≃ : (m n : ℕ) → (Fin m ⊎ Fin n) ≃ (Fin (m + n))
SumFin⊎≃ 0 n = ⊎-swap-≃ ⋆ ⊎-⊥-≃
SumFin⊎≃ (suc m) n = ⊎-assoc-≃ ⋆ ⊎-equiv (idEquiv ⊤) (SumFin⊎≃ m n)
SumFinΣ≃ : (n : ℕ)(f : Fin n → ℕ) → (Σ (Fin n) (λ x → Fin (f x))) ≃ (Fin (totalSum f))
SumFinΣ≃ 0 f = ΣEmpty _
SumFinΣ≃ (suc n) f =
Σ⊎≃
⋆ ⊎-equiv (ΣUnit (λ tt → Fin (f (inl tt)))) (SumFinΣ≃ n (λ x → f (inr x)))
⋆ SumFin⊎≃ (f (inl tt)) (totalSum (λ x → f (inr x)))
SumFin×≃ : (m n : ℕ) → (Fin m × Fin n) ≃ (Fin (m · n))
SumFin×≃ m n = SumFinΣ≃ m (λ _ → n) ⋆ pathToEquiv (λ i → Fin (totalSumConst {m = m} n i))
SumFinΠ≃ : (n : ℕ)(f : Fin n → ℕ) → ((x : Fin n) → Fin (f x)) ≃ (Fin (totalProd f))
SumFinΠ≃ 0 f = isContr→≃Unit (isContrΠ⊥) ⋆ invEquiv (⊎-⊥-≃)
SumFinΠ≃ (suc n) f =
Π⊎≃
⋆ Σ-cong-equiv (ΠUnit (λ tt → Fin (f (inl tt)))) (λ _ → SumFinΠ≃ n (λ x → f (inr x)))
⋆ SumFin×≃ (f (inl tt)) (totalProd (λ x → f (inr x)))
isNotZero : ℕ → ℕ
isNotZero 0 = 0
isNotZero (suc n) = 1
SumFin∥∥≃ : (n : ℕ) → ∥ Fin n ∥ ≃ Fin (isNotZero n)
SumFin∥∥≃ 0 = propTruncIdempotent≃ (isProp⊥)
SumFin∥∥≃ (suc n) =
isContr→≃Unit (inhProp→isContr ∣ inl tt ∣ isPropPropTrunc)
⋆ isContr→≃Unit (isContrUnit) ⋆ invEquiv (⊎-⊥-≃)
|
[STATEMENT]
lemma pure_pure:
assumes "h \<turnstile> ok f" and "pure f h"
shows "h \<turnstile> f \<rightarrow>\<^sub>h h"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. h \<turnstile> f \<rightarrow>\<^sub>h h
[PROOF STEP]
using assms returns_heap_eq
[PROOF STATE]
proof (prove)
using this:
h \<turnstile> ok f
pure f h
\<lbrakk>?h \<turnstile> ?f \<rightarrow>\<^sub>h ?h'; ?h \<turnstile> ?f \<rightarrow>\<^sub>h ?h''\<rbrakk> \<Longrightarrow> ?h' = ?h''
goal (1 subgoal):
1. h \<turnstile> f \<rightarrow>\<^sub>h h
[PROOF STEP]
unfolding pure_def
[PROOF STATE]
proof (prove)
using this:
h \<turnstile> ok f
h \<turnstile> ok f \<longrightarrow> h \<turnstile> f \<rightarrow>\<^sub>h h
\<lbrakk>?h \<turnstile> ?f \<rightarrow>\<^sub>h ?h'; ?h \<turnstile> ?f \<rightarrow>\<^sub>h ?h''\<rbrakk> \<Longrightarrow> ?h' = ?h''
goal (1 subgoal):
1. h \<turnstile> f \<rightarrow>\<^sub>h h
[PROOF STEP]
by auto |
lemma complex_add_cnj: "z + cnj z = complex_of_real (2 * Re z)" |
Require Import Crypto.Arithmetic.PrimeFieldTheorems.
Require Import Crypto.Specific.solinas64_2e213m3_5limbs.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.
|
{-# OPTIONS --without-K --safe #-}
open import Algebra.Structures.Bundles.Field
module Algebra.Linear.Structures.VectorSpace
{k ℓᵏ} (K : Field k ℓᵏ)
where
open import Algebra.FunctionProperties
open import Relation.Binary using (Rel)
open import Level using (_⊔_)
open import Data.Nat using (ℕ)
module VectorSpaceField where
open Field K public
using ()
renaming
( Carrier to K'
; _≈_ to _≈ᵏ_
; refl to ≈ᵏ-refl
; sym to ≈ᵏ-sym
; trans to ≈ᵏ-trans
; reflexive to ≈ᵏ-reflexive
; isEquivalence to ≈ᵏ-isEquiv
; setoid to K-setoid
; _+_ to _+ᵏ_
; _*_ to _*ᵏ_
; _-_ to _-ᵏ_
; 0# to 0ᵏ
; 1# to 1ᵏ
; -_ to -ᵏ_
; _⁻¹ to _⁻¹ᵏ
; +-cong to +ᵏ-cong
; +-identity to +ᵏ-identity
; +-identityˡ to +ᵏ-identityˡ
; +-identityʳ to +ᵏ-identityʳ
; +-assoc to +ᵏ-assoc
; +-comm to +ᵏ-comm
; *-cong to *ᵏ-cong
; *-identity to *ᵏ-identity
; *-identityˡ to *ᵏ-identityˡ
; *-identityʳ to *ᵏ-identityʳ
; *-assoc to *ᵏ-assoc
; *-comm to *ᵏ-comm
; zero to *ᵏ-zero
; zeroˡ to *ᵏ-zeroˡ
; zeroʳ to *ᵏ-zeroʳ
; distrib to *ᵏ-+ᵏ-distrib
; distribˡ to *ᵏ-+ᵏ-distribˡ
; distribʳ to *ᵏ-+ᵏ-distribʳ
; -‿distribˡ-* to -ᵏ‿distribˡ-*ᵏ
; -‿distribʳ-* to -ᵏ‿distribʳ-*ᵏ
; -‿cong to -ᵏ‿cong
; -‿inverse to -ᵏ‿inverse
; -‿inverseˡ to -ᵏ‿inverseˡ
; -‿inverseʳ to -ᵏ‿inverseʳ
; uniqueˡ-⁻¹ to uniqueˡ-⁻¹ᵏ
; uniqueʳ-⁻¹ to uniqueʳ-⁻¹ᵏ
; _⁻¹-inverse to _⁻¹ᵏ-inverse
; _⁻¹-involutive to _⁻¹ᵏ-involutive
; 0#-not-1# to 0ᵏ-not-1ᵏ
)
module _
{v ℓ} {V : Set v}
(_≈_ : Rel V ℓ)
where
open VectorSpaceField
open import Algebra.Structures _≈_
record IsVectorSpace (_+_ : Op₂ V) (_∙_ : K' → V → V) (-_ : Op₁ V) (0# : V) : Set (v ⊔ k ⊔ ℓ ⊔ ℓᵏ) where
field
isAbelianGroup : IsAbelianGroup _+_ 0# -_
*ᵏ-∙-compat : ∀ (a b : K') (u : V) -> ((a *ᵏ b) ∙ u) ≈ (a ∙ (b ∙ u))
∙-+-distrib : ∀ (a : K') (u v : V) -> (a ∙ (u + v)) ≈ ((a ∙ u) + (a ∙ v))
∙-+ᵏ-distrib : ∀ (a b : K') (u : V) -> ((a +ᵏ b) ∙ u) ≈ ((a ∙ u) + (b ∙ u))
∙-cong : ∀ {a b : K'} {u v : V} -> a ≈ᵏ b -> u ≈ v -> (a ∙ u) ≈ (b ∙ v)
∙-identity : ∀ (x : V) → (1ᵏ ∙ x) ≈ x
∙-absorbˡ : ∀ (x : V) → (0ᵏ ∙ x) ≈ 0#
open IsAbelianGroup isAbelianGroup public
renaming
( assoc to +-assoc
; ∙-cong to +-cong
; identity to +-identity
; identityˡ to +-identityˡ
; identityʳ to +-identityʳ
; comm to +-comm
; inverse to -‿inverse
; inverseˡ to -‿inverseˡ
; inverseʳ to -‿inverseʳ
; ⁻¹-cong to -‿cong
)
open import Algebra.Properties.AbelianGroup (record { isAbelianGroup = isAbelianGroup }) public
renaming
( ε⁻¹≈ε to -0≈0
; ∙-cancelˡ to +-cancelˡ
; ∙-cancelʳ to +-cancelʳ
; ∙-cancel to +-cancel
; identityˡ-unique to +-identityˡ-unique
; identityʳ-unique to +-identityʳ-unique
; identity-unique to +-identity-unique
; inverseˡ-unique to +-inverseˡ-unique
; inverseʳ-unique to +-inverseʳ-unique
; xyx⁻¹≈y to x+y-x≈y
; ⁻¹-∙-comm to -‿+-comm
)
open import Relation.Binary.EqReasoning setoid
∙-absorbʳ : ∀ (a : K') -> (a ∙ 0#) ≈ 0#
∙-absorbʳ a =
begin
a ∙ 0#
≈⟨ trans (∙-cong ≈ᵏ-refl (sym (∙-absorbˡ 0#))) (sym (*ᵏ-∙-compat a 0ᵏ 0#)) ⟩
(a *ᵏ 0ᵏ) ∙ 0#
≈⟨ ∙-cong (*ᵏ-zeroʳ a) refl ⟩
0ᵏ ∙ 0#
≈⟨ ∙-absorbˡ 0# ⟩
0#
∎
∙-∙-comm : ∀ (a b : K') (u : V) -> (a ∙ (b ∙ u)) ≈ (b ∙ (a ∙ u))
∙-∙-comm a b u =
begin
a ∙ (b ∙ u)
≈⟨ sym (*ᵏ-∙-compat a b u) ⟩
(a *ᵏ b) ∙ u
≈⟨ ∙-cong (*ᵏ-comm a b) refl ⟩
(b *ᵏ a) ∙ u
≈⟨ *ᵏ-∙-compat b a u ⟩
b ∙ (a ∙ u)
∎
private
lemma-inverseʳ : ∀ (u : V) -> (u + ((-ᵏ 1ᵏ) ∙ u)) ≈ 0#
lemma-inverseʳ u =
begin
u + ((-ᵏ 1ᵏ) ∙ u)
≈⟨ +-cong (sym (∙-identity u)) refl ⟩
(1ᵏ ∙ u) + ((-ᵏ 1ᵏ) ∙ u)
≈⟨ sym (∙-+ᵏ-distrib 1ᵏ (-ᵏ 1ᵏ) u) ⟩
(1ᵏ +ᵏ (-ᵏ 1ᵏ)) ∙ u
≈⟨ ∙-cong (-ᵏ‿inverseʳ 1ᵏ) refl ⟩
0ᵏ ∙ u
≈⟨ ∙-absorbˡ u ⟩
0#
∎
-1∙u≈-u : ∀ (u : V) -> ((-ᵏ 1ᵏ) ∙ u) ≈ (- u)
-1∙u≈-u u =
begin
((-ᵏ 1ᵏ) ∙ u)
≈⟨ +-inverseʳ-unique u ((-ᵏ 1ᵏ) ∙ u) (lemma-inverseʳ u) ⟩
- u
∎
|
#! /usr/bin/julia
#
# csv_read.jl
#
# Jul/05/2018
# --------------------------------------------------------------------
include("text_manipulate.jl")
#
# --------------------------------------------------------------------
println("*** 開始 ***")
fname_in = ARGS[1]
println(fname_in)
#
dict_aa = csv_to_dict_proc(fname_in)
dict_display_proc(dict_aa)
#
println("*** 終了 ***")
# --------------------------------------------------------------------
|
\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[]{book}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provides euro and other symbols
\else % if luatex or xelatex
\usepackage{unicode-math}
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
\usepackage{hyperref}
\hypersetup{
pdftitle={Outstanding User Interfaces with Shiny},
pdfauthor={David Granjon},
pdfborder={0 0 0},
breaklinks=true}
\urlstyle{same} % don't use monospace font for urls
\usepackage{longtable,booktabs}
% Fix footnotes in tables (requires footnote package)
\IfFileExists{footnote.sty}{\usepackage{footnote}\makesavenoteenv{longtable}}{}
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{5}
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
% set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\usepackage{booktabs}
\usepackage{amsthm}
\makeatletter
\def\thm@space@setup{%
\thm@preskip=8pt plus 2pt minus 4pt
\thm@postskip=\thm@preskip
}
\makeatother
\usepackage[]{natbib}
\bibliographystyle{apalike}
\title{Outstanding User Interfaces with Shiny}
\author{David Granjon}
\date{2020-04-12}
\begin{document}
\maketitle
{
\setcounter{tocdepth}{1}
\tableofcontents
}
\hypertarget{prerequisites}{%
\chapter{Prerequisites}\label{prerequisites}}
This book requires to be familiar with the R Shiny framework. We recommand reading \ldots{}
\hypertarget{intro}{%
\chapter{Introduction}\label{intro}}
To DO
\hypertarget{part-survival-kit}{%
\part*{Survival Kit}\label{part-survival-kit}}
\addcontentsline{toc}{part}{Survival Kit}
\hypertarget{introduction}{%
\chapter*{Introduction}\label{introduction}}
\addcontentsline{toc}{chapter}{Introduction}
This part will give you basis in HTML, JavaScript to get started\ldots{}
\hypertarget{part-htmltools}{%
\part*{htmltools}\label{part-htmltools}}
\addcontentsline{toc}{part}{htmltools}
While building a custom html template, you will need to know more about the wonderful \href{https://github.com/rstudio/htmltools}{htmltools} developed by Winston Chang, member of the shiny core team. It has the same spirit as devtools, that is, making your web developer life easier. What follows does not have the pretention to be an exhaustive guide about this package. Yet, it will provide you yith the main tools to be more efficient.
\hypertarget{practice}{%
\chapter{Practice}\label{practice}}
In this chapter, you will learn how to build your own html templates taken from the web
and package them, so that they can be re-used at any time by anybody.
\hypertarget{selecting-a-good-template}{%
\section{Selecting a good template}\label{selecting-a-good-template}}
There exists tons of HTML templates over the web. However, only a few part will be suitable
for shiny, mainly because of what follows:
\begin{itemize}
\tightlist
\item
shiny is built on top of \href{https://getbootstrap.com/docs/3.3/}{bootstrap 3} (HTML, CSS and Javascript framework), meaning that going for another framework might
not be straightforward. However, shinymaterial and shiny.semantic are examples showing
this can be possible.
\item
shiny relies on \href{https://jquery.com}{jQuery} (currently v 1.12.4 for shiny, whereas the latest version is 3.3.1). Consequently, all templates based upon React, Vue and other Javascript framework will not be natively supported. Again, there exist some \href{https://github.com/alandipert/react-widget-demo/blob/master/app.R}{examples} for React with shiny and more generally,
the \href{https://react-r.github.io/reactR/}{reactR} package developed by Kent Russell (\citet{timelyportfolio} on Twitter) and Alan Dipert from RStudio.
\end{itemize}
See \href{https://github.com/rstudio/shiny/tree/master/inst/www/shared}{the github repository} for more details about all dependencies related to the shiny package.
Therefore in the following, we will restict ourself to Bootstrap (3 and 4) together with jQuery. Don't be disapointed since there is still a lot to say.
\begin{quote}
Notes: As shiny depends on Bootstrap 3.3.7, we recommand the user who would like to
experiment Boostrap 4 features to be particularly careful about potential incompatibilies.
See a working example here with \href{https://github.com/RinteRface/bs4Dash}{bs4Dash}.
\end{quote}
A good source of \textbf{open source} HTML templates is \href{https://colorlib.com}{Colorlib} and \href{https://www.creative-tim.com/bootstrap-themes/free}{Creative Tim}. You might also buy your template, but forget about the packaging option, which would be illegal in this particular case, unless you have a legal agreement with the author (very unlikely however).
\bibliography{book.bib,packages.bib}
\end{document}
|
\section{Introduction}
In connectomics, neuroscientists annotate neurons and their connectivity within
3D volumes to gain insight into the functional structure of the brain. Rapid
progress in automatic sample preparation and electron microscopy (EM)
acquisition techniques has made it possible to image large volumes of brain
tissue at nanometer resolution. With a voxel size of
$4\times4\times40~\text{nm}^3$, a cubic millimeter volume is one petabyte of
data. With so much data, manual annotation is not feasible, and automatic
annotation methods are needed~\cite{jain2010,Liu2014,GALA2014,kaynig2015large}.
Automatic annotation by segmentation and classification of brain tissue is
challenging~\cite{isbi_challenge} and all available methods make errors, so
the results must be \emph{proofread} by humans. This crucial
task serves two purposes: 1) to correct errors in the segmentation, and 2) to
increase the body of labeled data from which to train better automatic
segmentation methods. Recent proofreading tools provide intuitive user
interfaces to browse segmentation data in 2D and 3D and to identify and manually
correct errors~\cite{markus_proofreading,raveler,mojo2,haehn_dojo_2014}. Many
kinds of errors exist, such as inaccurate boundaries, but the most common are
\emph{split errors}, where a single segment is labeled as two, and \emph{merge
errors}, where two segments are labeled as one
(Fig.~\ref{fig:merge_and_slit_errors}). With user interaction, split errors can
be joined, and the missing boundary in a merge error can be defined with
manually-seeded watersheds~\cite{haehn_dojo_2014}. However, the visual
inspection to find errors takes the majority of the time, even with
semi-automatic correction tools~\cite{proofreading_bottleneck}.
\begin{figure}[t]
\begin{center}
\includegraphics[width=\linewidth]{merge_and_split_errors.pdf}
\end{center}
\vspace{-4mm}
\caption{The most common proofreading corrections are fixing split errors (red arrows) and merge errors (yellow arrow). A fixed segmentation matches the cell borders.}
\label{fig:merge_and_slit_errors}
\end{figure}
Our goal is to automatically detect potential split and merge errors to reduce visual
inspection time. Further, to reduce correction time, we propose
corrections to the user to accept or reject. We call this process \textit{guided
proofreading}.
We train a classifier for split error detection with a convolutional neural network
(CNN). This takes as input patches of membrane segmentation probabilities, cell
segmentation masks, and boundary masks, and outputs a split-probability score. As we
must process large data, this classifier only operates on cell boundaries, which
reduces computation over methods that analyze every pixel. For merge errors, we
invert and reuse the split classification network, and ask it to rate a
set of generated boundaries that hypothesize a split.
Possible erroneous regions are sorted by their score, and a candidate correction is generated for each
region. Then, a user works through this list of regions and corrections. In a
forced choice setting, the user either selects a correction or skips it to
advance to the next region. In an automatic setting, errors with a high probability are automatically corrected first, given an appropriate
probability threshold, after which the user would take over. Finally, to test
the limits of performance, we create an oracle which only accepts corrections
that improve the segmentation, based on knowledge of the ground truth. This is
guided proofreading with a perfect user.
We evaluate these methods on multiple connectomics datasets. For the forced
choice setting, we perform a quantitative user study with 20 novice users who
have no previous experience of proofreading EM data. We ask participants to
proofread a small segmentation volume in a fixed time frame. In a
between-subjects design, we compare guided proofreading to the semi-automatic
\textit{focused proofreading} approach by Plaza~\cite{focused_proofreading}. In
addition, we compare against the manual interactive proofreading tool
\textit{Dojo} by Haehn~\etal~\cite{haehn_dojo_2014}. We also asked four domain
experts to use guided proofreading and focused proofreading for comparison.
This paper makes the following contributions.
%
First, we present a CNN-based boundary classifier for split errors, plus a merge
error classifier that inverts the split error classifier. This is used to
propose merge error corrections, removing the need to manually draw the missing
edge. These classifiers perform well without much training data, which is
expensive to collect for connectomics data.
%
Second, we developed a guided proofreading approach to correcting segmentation
volumes, and an assessment scenario comparing forced-choice interaction with
automatic and oracle proofreading.
%
Third, we present the results of a quantitative user study assessing
guided proofreading. Our method is able to reduce segmentation
error faster than state-of-the-art semi-automatic tools for both novice and
expert users.
Guided proofreading is applicable to all existing automatic segmentation methods that
produce a label map. As such, we believe that our approach is a promising
direction to proofread segmentations more efficiently and better tackle large
volumes of connectomics imagery. |
section \<open>Recoverable Data Types\<close>
theory RDR
imports Main Sequences
begin
subsection \<open>The pre-RDR locale contains definitions later used in the RDR locale
to state the properties of RDRs\<close>
locale pre_RDR = Sequences +
fixes \<delta>::"'a \<Rightarrow> ('b \<times> 'c) \<Rightarrow> 'a" (infix "\<bullet>" 65)
and \<gamma>::"'a \<Rightarrow> ('b \<times> 'c) \<Rightarrow> 'd"
and bot::'a ("\<bottom>")
begin
fun exec::"'a \<Rightarrow> ('b\<times>'c)list \<Rightarrow> 'a" (infix "\<star>" 65) where
"exec s Nil = s"
| "exec s (rs#r) = (exec s rs) \<bullet> r"
definition less_eq (infix "\<preceq>" 50) where
"less_eq s s' \<equiv> \<exists> rs . s' = (s\<star>rs)"
definition less (infix "\<prec>" 50) where
"less s s' \<equiv> less_eq s s' \<and> s \<noteq> s'"
definition is_lb where
"is_lb s s1 s2 \<equiv> s \<preceq> s2 \<and> s \<preceq> s1"
definition is_glb where
"is_glb s s1 s2 \<equiv> is_lb s s1 s2 \<and> (\<forall> s' . is_lb s' s1 s2 \<longrightarrow> s' \<preceq> s)"
definition contains where
"contains s r \<equiv> \<exists> rs . r \<in> set rs \<and> s = (\<bottom> \<star> rs)"
definition inf (infix "\<sqinter>" 65) where
"inf s1 s2 \<equiv> THE s . is_glb s s1 s2"
subsection \<open>Useful Lemmas in the pre-RDR locale\<close>
lemma exec_cons:
"s \<star> (rs # r)= (s \<star> rs) \<bullet> r" by simp
lemma exec_append:
"(s \<star> rs) \<star> rs' = s \<star> (rs@rs')"
proof (induct rs')
show "(s \<star> rs) \<star> [] = s \<star> (rs@[])" by simp
next
fix rs' r
assume ih:"(s \<star> rs) \<star> rs' = s \<star> (rs@rs')"
thus "(s \<star> rs) \<star> (rs'#r) = s \<star> (rs @ (rs'#r))"
by (metis append_Cons exec_cons)
qed
lemma trans:
assumes "s1 \<preceq> s2" and "s2 \<preceq> s3"
shows "s1 \<preceq> s3" using assms
by (auto simp add:less_eq_def, metis exec_append)
lemma contains_star:
fixes s r rs
assumes "contains s r"
shows "contains (s \<star> rs) r"
proof (induct rs)
case Nil
show "contains (s \<star> []) r" using assms by auto
next
case (Cons r' rs)
with this obtain rs' where 1:"s \<star> rs = \<bottom> \<star> rs'" and 2:"r \<in> set rs'"
by (auto simp add:contains_def)
have 3:"s \<star> (rs#r') = \<bottom>\<star>(rs'#r')" using 1 by fastforce
show "contains (s \<star> (rs#r')) r" using 2 3
by (auto simp add:contains_def) (metis exec_cons rev_subsetD set_subset_Cons)
qed
lemma preceq_star: "s \<star> (rs#r) \<preceq> s' \<Longrightarrow> s \<star> rs \<preceq> s'"
by (metis pre_RDR.exec.simps(1) pre_RDR.exec.simps(2) pre_RDR.less_eq_def trans)
end
subsection \<open>The RDR locale\<close>
locale RDR = pre_RDR +
assumes idem1:"contains s r \<Longrightarrow> s \<bullet> r = s"
and idem2:"\<And> s r r' . fst r \<noteq> fst r' \<Longrightarrow> \<gamma> s r = \<gamma> ((s \<bullet> r) \<bullet> r') r"
and antisym:"\<And> s1 s2 . s1 \<preceq> s2 \<and> s2 \<preceq> s1 \<Longrightarrow> s1 = s2"
and glb_exists:"\<And> s1 s2 . \<exists> s . is_glb s s1 s2"
and consistency:"\<And>s1 s2 s3 rs . s1 \<preceq> s2 \<Longrightarrow> s2 \<preceq> s3 \<Longrightarrow> s3 = s1 \<star> rs
\<Longrightarrow> \<exists> rs' rs'' . s2 = s1 \<star> rs' \<and> s3 = s2 \<star> rs''
\<and> set rs' \<subseteq> set rs \<and> set rs'' \<subseteq> set rs"
and bot:"\<And> s . \<bottom> \<preceq> s"
begin
lemma inf_glb:"is_glb (s1 \<sqinter> s2) s1 s2"
proof -
{ fix s s'
assume "is_glb s s1 s2" and "is_glb s' s1 s2"
hence "s = s'" using antisym by (auto simp add:is_glb_def is_lb_def) }
from this and glb_exists show ?thesis
by (auto simp add:inf_def, metis (lifting) theI')
qed
sublocale ordering less_eq less
proof
fix s
show "s \<preceq> s"
by (metis exec.simps(1) less_eq_def)
next
fix s s'
show "s \<prec> s' = (s \<preceq> s' \<and> s \<noteq> s')"
by (auto simp add:less_def)
next
fix s s'
assume "s \<preceq> s'" and "s' \<preceq> s"
thus "s = s'"
using antisym by auto
next
fix s1 s2 s3
assume "s1 \<preceq> s2" and "s2 \<preceq> s3"
thus "s1 \<preceq> s3"
using trans by blast
qed
sublocale semilattice_set inf
proof
fix s
show "s \<sqinter> s = s"
using inf_glb
by (metis antisym is_glb_def is_lb_def refl)
next
fix s1 s2
show "s1 \<sqinter> s2 = (s2 \<sqinter> s1)"
using inf_glb
by (smt antisym is_glb_def pre_RDR.is_lb_def)
next
fix s1 s2 s3
show "(s1 \<sqinter> s2) \<sqinter> s3 = (s1 \<sqinter> (s2 \<sqinter> s3))"
using inf_glb
by(auto simp add:is_glb_def is_lb_def, smt antisym trans)
qed
sublocale semilattice_order_set inf less_eq less
proof
fix s s'
show "s \<preceq> s' = (s = s \<sqinter> s')"
by (metis antisym idem inf_glb pre_RDR.is_glb_def pre_RDR.is_lb_def)
next
fix s s'
show "s \<prec> s' = (s = s \<sqinter> s' \<and> s \<noteq> s')"
by (metis inf_glb local.antisym local.refl pre_RDR.is_glb_def pre_RDR.is_lb_def pre_RDR.less_def)
qed
notation F ("\<Sqinter> _" [99])
subsection \<open>Some useful lemmas\<close>
lemma idem_star:
fixes r s rs
assumes "contains s r"
shows "s \<star> rs = s \<star> (filter (\<lambda> x . x \<noteq> r) rs)"
proof (induct rs)
case Nil
show "s \<star> [] = s \<star> (filter (\<lambda> x . x \<noteq> r) [])"
using assms by auto
next
case (Cons r' rs)
have 1:"contains (s \<star> rs) r" using assms and contains_star by auto
show "s \<star> (rs#r') = s \<star> (filter (\<lambda> x . x \<noteq> r) (rs#r'))"
proof (cases "r' = r")
case True
hence "s \<star> (rs#r') = s \<star> rs" using idem1 1 by auto
thus ?thesis using Cons by simp
next
case False
thus ?thesis using Cons by auto
qed
qed
lemma idem_star2:
fixes s rs'
shows "\<exists> rs' . s \<star> rs = s \<star> rs' \<and> set rs' \<subseteq> set rs
\<and> (\<forall> r \<in> set rs' . \<not> contains s r)"
proof (induct rs)
case Nil
thus "\<exists> rs' . s \<star> [] = s \<star> rs' \<and> set rs' \<subseteq> set []
\<and> (\<forall> r \<in> set rs' . \<not> contains s r)" by force
next
case (Cons r rs)
obtain rs' where 1:"s \<star> rs = s \<star> rs'" and 2:"set rs' \<subseteq> set rs"
and 3:"\<forall> r \<in> set rs' . \<not> contains s r" using Cons(1) by blast
show "\<exists> rs' . s \<star> (rs#r) = s \<star> rs' \<and> set rs' \<subseteq> set (rs#r)
\<and> (\<forall> r \<in> set rs' . \<not> contains s r)"
proof (cases "contains s r")
case True
have "s\<star>(rs#r) = s\<star>rs'"
proof -
have "s \<star> (rs#r) = s\<star>rs" using True
by (metis contains_star exec_cons idem1)
moreover
have "s \<star> (rs'#r) = s\<star>rs'" using True
by (metis contains_star exec_cons idem1)
ultimately show ?thesis using 1 by simp
qed
moreover have "set rs' \<subseteq> set (rs#r)" using 2
by (simp, metis subset_insertI2)
moreover have "\<forall> r \<in> set rs' . \<not> contains s r"
using 3 by assumption
ultimately show ?thesis by blast
next
case False
have "s\<star>(rs#r) = s\<star>(rs'#r)" using 1 by simp
moreover
have "set (rs'#r) \<subseteq> set (rs#r)" using 2 by auto
moreover have "\<forall> r \<in> set (rs'#r) . \<not> contains s r"
using 3 False by auto
ultimately show ?thesis by blast
qed
qed
lemma idem2_star:
assumes "contains s r"
and "\<And> r' . r' \<in> set rs \<Longrightarrow> fst r' \<noteq> fst r"
shows "\<gamma> s r = \<gamma> (s \<star> rs) r" using assms
proof (induct rs)
case Nil
show "\<gamma> s r = \<gamma> (s \<star> []) r" by simp
next
case (Cons r' rs)
thus "\<gamma> s r = \<gamma> (s \<star> (rs#r')) r"
using assms by auto
(metis contains_star fst_conv idem1 idem2 prod.exhaust)
qed
lemma glb_common:
fixes s1 s2 s rs1 rs2
assumes "s1 = s \<star> rs1" and "s2 = s \<star> rs2"
shows "\<exists> rs . s1 \<sqinter> s2 = s \<star> rs \<and> set rs \<subseteq> set rs1 \<union> set rs2"
proof -
have 1:"s \<preceq> s1" and 2:"s \<preceq> s2" using assms by (auto simp add:less_eq_def)
hence 3:"s \<preceq> s1 \<sqinter> s2" by (metis inf_glb is_lb_def pre_RDR.is_glb_def)
have 4:"s1 \<sqinter> s2 \<preceq> s1" by (metis cobounded1)
show ?thesis using 3 4 assms(1) and consistency by blast
qed
lemma glb_common_set:
fixes ss s0 rset
assumes "finite ss" and "ss \<noteq> {}"
and "\<And> s . s \<in> ss \<Longrightarrow> \<exists> rs . s = s0 \<star> rs \<and> set rs \<subseteq> rset"
shows "\<exists> rs . \<Sqinter> ss = s0 \<star> rs \<and> set rs \<subseteq> rset"
using assms
proof (induct ss rule:finite_ne_induct)
case (singleton s)
obtain rs where "s = s0 \<star> rs \<and> set rs \<subseteq> rset" using singleton by force
moreover have "\<Sqinter> {s} = s" using singleton by auto
ultimately show "\<exists> rs . \<Sqinter> {s} = s0 \<star> rs \<and> set rs \<subseteq> rset" by blast
next
case (insert s ss)
have 1:"\<And> s' . s' \<in> ss \<Longrightarrow> \<exists> rs . s' = s0 \<star> rs \<and> set rs \<subseteq> rset"
using insert(5) by force
obtain rs where 2:"\<Sqinter> ss = s0 \<star> rs" and 3:"set rs \<subseteq> rset"
using insert(4) 1 by blast
obtain rs' where 4:"s = s0 \<star> rs'"and 5:"set rs' \<subseteq> rset"
using insert(5) by blast
have 6:"\<Sqinter> (insert s ss) = s \<sqinter> (\<Sqinter> ss)"
by (metis insert.hyps(1-3) insert_not_elem)
obtain rs'' where 7:"\<Sqinter> (insert s ss) = s0 \<star> rs''"
and 8:"set rs'' \<subseteq> set rs' \<union> set rs"
using glb_common 2 4 6 by force
have 9:"set rs'' \<subseteq> rset" using 3 5 8 by blast
show "\<exists> rs . \<Sqinter> (insert s ss) = s0 \<star> rs \<and> set rs \<subseteq> rset"
using 7 9 by blast
qed
end
end
|
"""
Author : Abdullah Al Masud\n
email : [email protected]\n
LICENSE : MIT License
"""
import torch
from torch import nn
import pandas as pd
import matplotlib.pyplot as plt
from msdlib import msd
import numpy as np
import os
import joblib
import time
plt.rcParams['figure.facecolor'] = 'white'
class NNmodel(nn.Module):
"""
This class constructs a deep neural network model upon providing the layers we intend to build the model with.
Inputs:
:layer_funcs: list, contains sequential layer classes (nn.Module).
For example-\n
[nn.Linear(50), nn.ReLU(), nn.Linear(3), nn.Softmax(dim=-1)]
:seed_value: float/int, random seed for reproducibility, default is 1216
"""
def __init__(self, layer_funcs, seed_value=1216):
super(NNmodel, self).__init__()
# reproducibility parameters
np.random.seed(seed_value)
torch.manual_seed(seed_value)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
self.layers = nn.ModuleList(layer_funcs)
def forward(self, x):
"""
pytorch forward function for forward propagation
"""
for layer in self.layers:
x = layer(x)
return x
# The class can be used for auto-encoder architecture
class AutoEncoderModel(nn.Module):
"""
This class creates an auto-encoder model.
Inputs:
:enc_layers: python list, containing the encoder layers (torch.nn.Module class objects) sequentially
:dec_layers: python list, containing the decoder layers (torch.nn.Module class objects) sequentially
:seed_value: float/int, random seed for reproducibility
"""
def __init__(self, enc_layers, dec_layers, seed_value=1216):
super(AutoEncoderModel, self).__init__()
# reproducibility parameters
np.random.seed(seed_value)
torch.manual_seed(seed_value)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
self.encode_layers = nn.ModuleList(enc_layers)
self.decode_layers = nn.ModuleList(dec_layers)
self.enc_len = len(self.encode_layers)
self.dec_len = len(self.decode_layers)
def encode(self, x):
"""
Encoder part in Autoencoder model
Inputs:
:x: input tensor for encoder part
Outputs:
encoder output
"""
for layer in self.encode_layers:
x = layer(x)
return x
def decode(self, x):
"""
Decoder part in Autoencoder model
Inputs:
:x: input tensor for decoder part
Outputs:
decoder output
"""
for layer in self.decode_layers:
x = layer(x)
return x
def forward(self, x):
"""
pytorch forward function for forward propagation, applies encoder and then decoder sequentially on the input data
Inputs:
:x: input tensor for autoencoder model
Outputs:
:x: final output of the whole auto-encoder model
"""
x = self.encode(x)
x = self.decode(x)
return x
# torchModel is a scikit like wrapper for pytorch which enables us to use the model for
# training, predicting and evaluating performance using simple fit, predict and evaluate methods
class torchModel():
"""
This class controls the deep neural network model training, inference, prediction and evaluation.
It can provide the training loss curves and evaluation results very nicely. It is capable of using multiple GPUs.
Note: For classification problems (both binary and multi-class), there is no need to convert labels into one hot encoded format.
In stead, the class label values should be indices like 0, 1, 2...
Inputs:
:layers: a list of torch.nn.Module objects indicating layers/activation functions. The list should contain all elements sequentially.
Default is []. Each element of this list must be callable function object.
For Sigmoid function, we can use torch.nn.Sigmoid() or torch.sigmoid (use the brackets this way).
:loss_func: loss function for the ML model. default is torch.nn.MSELoss. It can also be a custom loss function, but should be equivalent to the default
:optimizer: optimizer for the ML model. default is torch.optim.Adam
:learning_rate: learning rate of the training steps, default is .0001
:epoch: number of epoch for training, default is 2
:batch_size: mini-batch size for trianing, default is 32
:lr_reduce: learning rate reduction base for lambda reduction scheduler from pytorch (follows torch.optim.lr_scheduler.LambdaLR).
Must be 0 ~ 1. Default is 1 (No reduction of learning rate during training)
:loss_reduction: loss reduction parameter for loss calculation, default is 'mean'
:model_type: type of the model depending on the objective, should be any of {'regressor', 'binary-classifier', 'multi-classifier'}, default is 'regressor'.
- 'binary-classifier' indicates binary classifier with 1 output unit. The output values must be 0 ~ 1 (sigmoid like activations should be used at model output).
- 'multi-classifier' indicates classifier with more than one output unit
:use_gpu: bool, whether to use gpu or not, default is True.
:gpu_devices: list, a list of cuda ids starting from 0. Default is None which will try to use all available gpus. If you have 4 gpus in your machine, and want to use first 3 of them, the list should be [0, 1, 2]
:model_name: str, name of the model, default is 'pytorch'
:dtype: dtype of processing inside the model, default is torch.float32
:plot_loss: bool, whether to plot loss curves after training or not, default is True
:quant_perc: float, quantile value to limit the loss values for loss curves, default is .98
:plot_evaluation: bool, whether to plot evaluation tables/figures or not, default is True
- For model_type={binary-classifier, multi-classifier}, it will be score matrix and confusion matrix plot
- For model_type=regressor, it will be a true vs prediction scatter plot
:loss_roll_preiod: int, rolling/moving average period for loss curve
:model: torch.nn.Module class (ML model class), so that we are able to write the model ourselves and use fit, predict etc methods from here.
:savepath: str, path to store the learning curve and evaluation results
"""
def __init__(self, layers=[], loss_func=None, optimizer=None, learning_rate=.0001, epoch=2, batch_size=32, lr_reduce=1,
loss_reduction='mean', model_type='regressor', use_gpu=True, gpu_devices=None, model_name='pytorch', dtype=torch.float32,
plot_loss=True, quant_perc=.98, plot_evaluation=True, loss_roll_period=1, model=None, savepath=None):
# defining model architecture
self.model = NNmodel(layers) if model is None else model
# defining training formation parameters
self.learning_rate = learning_rate
self.epoch = epoch
self.batch_size = batch_size
self.lr_reduce = lr_reduce
self.loss_reduction = loss_reduction
self.model_type = model_type
self.use_gpu = use_gpu
self.model_name = model_name
self.dtype = dtype
self.savepath = savepath
self.gpu_devices = gpu_devices
# evaluation parameters
self.plot_loss = plot_loss
self.quant_perc = quant_perc
self.plot_evaluation = plot_evaluation
self.loss_roll_period = loss_roll_period
# setting up gpu usage
self.gpu_string = "cuda" if self.use_gpu and torch.cuda.is_available() else "cpu"
self.device = torch.device(self.gpu_string)
self.model = self.model.to(device=self.device, dtype=self.dtype)
# setting up loss and optimizer
if loss_func is None:
if model_type.lower() == 'regressor':
self.loss_func = nn.MSELoss
elif model_type.lower() == 'binary-classifier':
self.loss_func = nn.BCELoss
elif model_type.lower() == 'multi-classifier':
self.loss_func = nn.CrossEntropyLoss
else:
raise ValueError('model_type %s is not valid !' % model_type)
else:
self.loss_func = loss_func
self.optimizer = optimizer if optimizer is not None else torch.optim.Adam
self.loss_func = self.loss_func(reduction=self.loss_reduction).to(
device=self.device, dtype=self.dtype)
self.optimizer = self.optimizer(
self.model.parameters(), lr=self.learning_rate)
# learning rate scheduler
def lr_lambda(ep): return self.lr_reduce ** ep
self.scheduler = torch.optim.lr_scheduler.LambdaLR(
self.optimizer, lr_lambda)
self.parallel = False # whether DataParallel will be used or not
def set_parallel(self,):
"""
This method sets multiple GPUs to use for training depending on the machine's cuda availability and use_gpu parameter.
"""
if self.gpu_string == 'cuda':
print('Cuda is available and will be used for training')
if self.gpu_devices is None:
self.gpu_devices = [i for i in range(
torch.cuda.device_count())]
if isinstance(self.gpu_devices, list):
if len(self.gpu_devices) > 1:
self.model = nn.DataParallel(
self.model, device_ids=self.gpu_devices)
self.parallel = True
print('Training will be done on these cuda devices:',
self.gpu_devices)
else:
print('Cuda/GPU isnt detected, training will be done in CPU')
def relieve_parallel(self):
"""
This function reverts the DataParallel model to simple torch.nn.Module model
"""
if self.parallel:
self.model = self.model.module
def fit(self, data, label, val_data=None, val_label=None, validation_ratio=.15, evaluate=True, figsize=(18, 4)):
"""
scikit like wrapper for training DNN pytorch model
Inputs:
:data: input train data, must be torch tensor, numpy ndarray or pandas DataFrame/Series
:label: supervised labels for data, must be torch tensor, numpy ndarray or pandas DataFrame/Series
:val_data: validation data, must be torch tensor, numpy ndarray or pandas DataFrame/Series, default is None
:val_label: supervised labels for val_data, must be torch tensor, numpy ndarray or pandas DataFrame/Series, default is None
:validation_ratio: ratio of 'data' that will be used for validation during training. It will be used only when val_data or val_label or both are None. Default is 0.15
:evaluate: bool, whether to evaluate model performance after training ends or not. evaluate performance if set True. Default is True.
:figsize: tuple of (width, height) of the figure, size of the figure for loss curve plot and evaluation plots. Default is (18, 4)
Outputs:
doesnt return anything. The trained model is stored inside the attribute torchModel.model
"""
# allowing pandas dataframe or series input
if isinstance(data, pd.DataFrame):
data = data.values
elif isinstance(data, pd.Series):
data = data.to_frame().values
if isinstance(label, pd.DataFrame):
label = label.values
elif isinstance(label, pd.Series):
label = label.values
if isinstance(val_data, pd.DataFrame):
val_data = val_data.values
elif isinstance(val_data, pd.Series):
val_data = val_data.to_frame().values
if isinstance(val_label, pd.DataFrame):
val_label = val_label.values
elif isinstance(val_label, pd.Series):
val_label = val_label.values
data = data.squeeze()
label = label.squeeze()
val_data = val_data.squeeze()
val_label = val_label.squeeze()
if val_data is None or val_label is None:
# splitting data set
train_ratio = 1 - validation_ratio
idx = np.arange(label.shape[0])
np.random.shuffle(idx)
train_idx = idx[:int(train_ratio * label.shape[0])]
val_idx = idx[int(train_ratio * label.shape[0]):]
train_data = data[train_idx]
train_label = label[train_idx]
val_data = data[val_idx]
val_label = label[val_idx]
else:
train_data = data
train_label = label
# getting the model and data ready
total_batch = train_data.shape[0] // self.batch_size + \
int(bool(train_data.shape[0] % self.batch_size))
# handling data sets and labels
if not isinstance(train_data, torch.Tensor):
train_data = torch.from_numpy(train_data)
if not isinstance(val_data, torch.Tensor):
val_data = torch.from_numpy(val_data)
if not isinstance(train_label, torch.Tensor):
train_label = torch.from_numpy(train_label)
if not isinstance(val_label, torch.Tensor):
val_label = torch.from_numpy(val_label)
# data type conversion
train_data = train_data.to(device=self.device, dtype=self.dtype)
train_label = train_label.to(device=self.device, dtype=torch.long) if self.model_type.lower(
) == 'multi-classifier' else train_label.to(device=self.device, dtype=self.dtype)
val_data = val_data.to(device=self.device, dtype=self.dtype)
val_label = val_label.to(device=self.device, dtype=torch.long) if self.model_type.lower(
) == 'multi-classifier' else val_label.to(device=self.device, dtype=self.dtype)
# running through epoch
loss_curves = [[], []]
val_loss = torch.tensor(np.nan)
total_train = train_data.shape[0]
t1 = time.time()
self.set_parallel()
for ep in range(self.epoch):
tr_mean_loss = []
idx = torch.randperm(total_train)
train_data = train_data[idx]
train_label = train_label[idx]
self.model.train()
for i in range(total_batch):
# preparing data set
if i != total_batch - 1:
batch_data = train_data[i *
self.batch_size: (i + 1) * self.batch_size]
batch_label = train_label[i *
self.batch_size: (i + 1) * self.batch_size]
else:
batch_data = train_data[-self.batch_size:]
batch_label = train_label[-self.batch_size:]
# loss calculation
self.model.zero_grad()
label_hat = self.model(batch_data).squeeze()
tr_loss = self.loss_func(label_hat, batch_label)
# back-propagation
tr_loss.backward()
# model parameter update
self.optimizer.step()
# stacking and printing losses
tr_mean_loss.append(tr_loss.item())
time_string = msd.get_time_estimation(
time_st=t1, current_ep=ep, current_batch=i, total_ep=self.epoch, total_batch=total_batch)
print('\repoch : %04d/%04d, batch : %03d, train_loss : %.4f, validation_loss : %.4f, %s'
% (ep + 1, self.epoch, i + 1, tr_loss.item(), val_loss.item(), time_string)+' '*20, end='', flush=True)
# loss scheduler step
self.scheduler.step()
# storing losses
loss_curves[0].append(np.mean(tr_mean_loss))
if val_data.shape[0] > 0:
# run evaluation to get validation score
out = self.predict(val_data).squeeze()
val_loss = self.loss_func(out, val_label)
# storing losses
loss_curves[1].append(val_loss.item())
print('...training complete !!')
losses = pd.DataFrame(loss_curves, index=['train_loss', 'validation_loss'], columns=np.arange(
1, self.epoch + 1)).T.rolling(self.loss_roll_period).mean()
# plotting loss curve
if self.plot_loss and self.epoch > 1:
ylim_upper = losses.quantile(self.quant_perc).max()
ylim_lower = losses.min().min()
fig, ax = plt.subplots(figsize=(25, 4))
losses.plot(ax=ax, color=['darkcyan', 'crimson'])
ax.set_ylim(ylim_lower, ylim_upper)
fig.suptitle('Learning curves', y=1,
fontsize=15, fontweight='bold')
fig.tight_layout()
if self.savepath is not None:
os.makedirs(self.savepath, exist_ok=True)
fig.savefig('%s/Learning_curves.png' %
(self.savepath), bbox_inches='tight')
plt.close()
else:
plt.show()
self.relieve_parallel()
# model training evaluation
if evaluate:
self.evaluate([train_data, val_data], [train_label, val_label], set_names=[
'Train_set (from training data)', 'Validation_set (from training data)'], figsize=figsize, savepath=self.savepath)
def predict(self, data):
"""
A wrapper function that generates prediction from pytorch model
Inputs:
:data: input data to predict on, must be a torch tensor or numpy ndarray
Outputs:
returns predictions
"""
# evaluation mode set up
self.model.eval()
# checking data type
if isinstance(data, pd.DataFrame) or isinstance(data, pd.Series):
data = data.values
if isinstance(data, np.ndarray):
data = torch.from_numpy(data)
data = data.to(device=self.device, dtype=self.dtype)
# estimating number of mini-batch
n_batch = data.shape[0] // self.batch_size + \
int(bool(data.shape[0] % self.batch_size))
with torch.no_grad():
# generates prediction
preds = []
for i in range(n_batch):
if i != n_batch - 1:
pred = self.model(
data[i * self.batch_size: (i + 1) * self.batch_size])
else:
pred = self.model(data[i * self.batch_size:])
preds.append(pred.detach())
preds = torch.cat(preds)
return preds
def evaluate(self, data_sets, label_sets, set_names=[], figsize=(18, 4), savepath=None):
"""
This is a customized function to evaluate model performance in regression and classification type tasks
Inputs:
:data_sets: list of data, data must be numpy ndarray, torch tensor or Pandas DataFrame/Series
:label_sets: list of labels corresponding to each data, label must be numpy ndarray, torch tensor or Pandas DataFrame/Series
:set_names: names of the data sets, default is []
:figsize: figure size for the evaluation plots, default is (18, 4)
:savepath: path where the evaluation tables/figures will be stored, default is None
Outputs:
:summary_result: pandas DataFrame, result summary accumulated in a variable
:all_results: dict, complete results for all datasets
"""
results, all_results = None, None
# plotting true vs prediction curve (regression) or confusion matrix (classification)
if self.plot_evaluation and self.model_type.lower() in ['regressor', 'binary-classifier', 'multi-classifier'] and len(data_sets) > 0:
set_names = set_names if len(set_names) > 0 else [
'data-%d' % (i+1) for i in range(len(data_sets))]
all_results = {}
results = []
for i, (preddata, predlabel) in enumerate(zip(data_sets, label_sets)):
test_pred = self.predict(
preddata).detach().cpu().squeeze().numpy()
if isinstance(predlabel, torch.Tensor):
label = predlabel.detach().cpu().squeeze().numpy()
elif isinstance(predlabel, pd.DataFrame) or isinstance(predlabel, pd.Series):
label = predlabel.values.copy()
else:
label = predlabel.copy()
if self.model_type.lower() == 'regressor':
true_pred = pd.DataFrame([label, test_pred], index=[
'true_label', 'prediction']).T
corr_val = true_pred.corr().iloc[0, 1]
rsquare, rmse = msd.rsquare_rmse(
true_pred['true_label'].values, true_pred['prediction'].values)
fig, ax = plt.subplots(figsize=figsize)
ax.scatter(
true_pred['true_label'], true_pred['prediction'], color='darkcyan', s=8)
_min = np.min([true_pred['true_label'].min(),
true_pred['prediction'].min()])
_max = np.max([true_pred['true_label'].max(),
true_pred['prediction'].max()])
ax.plot([_min, _max], [_min, _max], color='k', lw=2)
ax.set_xlabel('true-label')
ax.set_ylabel('prediction')
title = 'True-Label VS Prediction Scatter plot for %s from %s\nRSquare : %.3f, RMSE : %.3f, Correlation : %.3f' % (
set_names[i], self.model_name, rsquare, rmse, corr_val)
ax.set_title(title, fontweight='bold')
all_results[set_names[i]] = [rsquare, rmse]
results.append(pd.Series([rsquare, rmse], index=[
'r_square', 'rmse'], name='%s_%s' % (self.model_name, set_names[i])))
elif self.model_type.lower() in ['multi-classifier', 'binary-classifier']:
if self.model_type.lower() == 'multi-classifier':
test_pred = np.argmax(test_pred, axis=1)
else:
test_pred = np.round(test_pred).astype(int)
result, confus = msd.class_result(
label, test_pred, out_confus=True)
fig, ax = plt.subplots(figsize=figsize, ncols=2)
ax[0] = msd.plot_heatmap(result, annotate=True, fmt='.3f', xrot=0,
vmax=1, axobj=ax[0], cmap='summer', fig_title='Score Matrix')
ax[1] = msd.plot_heatmap(
confus, annotate=True, fmt='d', xrot=0, axobj=ax[1], cmap='Blues', fig_title='Confusion Matrix')
title = 'Classification result for %s from %s' % (
set_names[i], self.model_name)
fig.suptitle(title, fontsize=15, fontweight='bold')
all_results[set_names[i]] = [result, confus]
results.append(pd.Series(result.mean().drop('average').to_list() + [result['average'].loc['accuracy']], index=result.drop('average', axis=1).columns.to_list() + ['average'],
name='%s_%s' % (self.model_name, set_names[i])))
fig.tight_layout()
if savepath is not None:
os.makedirs(savepath, exist_ok=True)
fig.savefig(
'%s/%s.png' % (savepath, title.split('\n')[0].replace(' ', '_')), bbox_inches='tight')
plt.close()
else:
plt.show()
results = pd.concat(results, axis=1, sort=False).T
return results, all_results
def get_factors(n_layers, base_factor=5, max_factor=10, offset_factor=2):
"""
This function calculates factors/multipliers to calculate number of units inside define_layers() function
Inputs:
:n_layers: number of hidden layers
:max_factor: multiplier for mid layer (largest layer)
:base_factor: multiplier for first layer
:offset_factor: makes assymetric structure in output with factor (base - offset). For symmetric model (size in first and last hidden layer is same), offset will be 0.
Outputs:
:factors: multipliers to calculate number of units in each layers based on input shape
"""
base_factor = max_factor - base_factor
return [max_factor - abs(x) for x in np.linspace(-base_factor, base_factor + offset_factor, n_layers) if max_factor - abs(x) > 0]
def define_layers(input_units, output_units, unit_factors, dropout_rate=None, model_type='regressor', actual_units=False,
apply_bn=False, activation=None, final_activation=None):
"""
This function takes a common formation/sequence of functions to construct one hidden layer and then replicates this sequence for multiple hidden layers.
Hidden layer units are decided based on 'unit_factors' paramter.
The common formation of one hidden layer is this-
-Linear
-BatchNorm1d
-ReLU
-Dropout
Dropout ratio is same in all layers
Finally the output layer is constructed depending on 'output_units' and 'model_type' parameter including final activation function.
Output activation function is provided
Inputs:
:input_units: int, number of units in input layer / number of features (not first hidden layer)
:output_units: int, number of units in output layer / number of output nodes / number of classes (not last hidden layer)
:unit_factors: array of ints or floats, multipliers to calculate number of units in each hidden layer from input_units, or actual number of units for each hidden layer
:dropout_rate: dropout ratio, must be 0 ~ 1. Default is None (no dropout layer)
:model_type: {'binary-classifier', 'multi-classifier, 'regressor'}, controls use of softmax/sigmoid at the output layer. Use 'regressor' if you dont intend to use any activation at output. Default is 'regressor'
:actual_units: bool, whether actual units are placed in unit_factors or not, default is False (not actual units, instead unit_factos is containing ratios)
:apply_bn: bool, whether to use batch normalization or not, default is False (does not use batch normalization)
:activation: nn.Module object or None. Pytorch activation layer that will be used as activation function after each hidden layer. Default is None (No activation)
:final_activation: torch.sigmoid / torch.Softmax(dim=1) / torch.tanh etc. for output layer, default is None. If None, the final activation will be below:
- modey_type == 'regressor' --> No activation
- model_type == 'binary-classifier' --> torch.sigmoid
- model_type == 'multi-clussifier' --> torch.Softmax(dim=1)
Outputs:
:layers: list of Deep Learning model layers which can be fed as NNModel layer_funcs input or torchModel layers input to build DNN model
"""
if actual_units:
hidden_units = unit_factors.copy()
else:
hidden_units = [input_units * factor for factor in unit_factors]
units = [input_units] + hidden_units + [output_units]
units = [int(i) for i in units]
layers = []
for i in range(len(unit_factors)):
layers.append(nn.Linear(units[i], units[i + 1]))
if apply_bn:
layers.append(nn.BatchNorm1d(units[i + 1]))
if activation is not None:
layers.append(activation)
if dropout_rate is not None:
layers.append(nn.Dropout(dropout_rate))
layers.append(nn.Linear(units[-2], units[-1]))
if final_activation is None:
if model_type.lower() == 'multi-classifier':
layers.append(nn.Softmax(dim=1))
elif model_type.lower() == 'binary-classifier':
layers.append(torch.sigmoid)
else:
layers.append(final_activation)
return layers
# storing the models and loading them
def store_models(models, folder_path):
"""
This function stores different types of scikit-learn models in .pickle format and also Pytorch model in .pt format
Inputs:
:models: dict, containing only trained model class; {<model name>: <model class>}
For pytorch models, the key must contain 'pytorch' phrase (Case insensitive).
Note: Pytorch model must not be a DataParallel model.\n
If its a DataParallel model, then take module attribute of your model like this- {'pytorch': <your_model>.module}
:folder_path: str, the folder path where the models will be stores, if doesnt exist, it will be created
"""
if not os.path.exists(folder_path):
os.makedirs(folder_path)
for modelname in models:
print('storing models... %s_model...' % modelname, end='')
if 'pytorch' in modelname.lower():
torch.save(models[modelname].state_dict(),
folder_path + '/%s_model.pt' % modelname)
else:
with open(folder_path + '/%s_model.pickle' % modelname, 'wb') as f:
joblib.dump(models[modelname], f)
print(' ...storing completed !!')
def load_models(models, folder_path):
"""
This function loads different scikit-learn models from .pickle format and Pytorch model from .pt formatted state_dict (only weights)
Inputs:
:models: dict, containing model classes or None (for torch model, torch.nn.Module object is necessary as trained model
to load the state variables. For other types of models like xgboost etc. None is fine.);
For pytorch models, the key must contain 'pytorch' phrase (Case insensitive)
key name must be like this :\n
stored model file name: xgboost_model.pickle\n
corresponding key for the dict: 'xgboost'\n
stored model file name: pytorch-1_model.pickle\n
corresponding key for the dict: 'pytorch-1'\n
for pytorch model, the model must not be a DataParallel model. You can add parallelism after loading the weights
:folder_path: str, directory path from where the stored models will be loaded
Outputs:
:models: dict, containing model classes like {<model_name> : <model_class>}
"""
for modelname in models:
print('\rloading models... %s_model...' % modelname, end='')
if 'pytorch' in modelname.lower():
models[modelname].load_state_dict(
torch.load(folder_path + '/%s_model.pt' % modelname))
else:
with open(folder_path + '%s_model.pickle' % modelname, 'rb') as f:
models[modelname] = joblib.load(f)
print(' ...loading completed !!')
return models
|
import numpy as np
import os
import sqlite3
import warnings
class Database():
# init operations
def __init__(self, path):
self.connection = None
self.c = None
self.path = path
def __enter__(self):
self.connection = sqlite3.connect(os.path.join(self.path, 'options.db'))
self.c = self.connection.cursor()
return self
def __exit__(self, type, value, traceback):
self.connection.close()
# BASIC OPERATIONS
def _exec(self, *args):
self.c.execute(*args)
def _new_row(self, table, id):
self._exec("INSERT INTO %s (id) VALUES (?)" % table, (id,))
def _update(self, id, col, value):
self._exec("UPDATE options SET %s = ? WHERE id = ?" % col, (value, id))
def init_tables(self):
self.c.executescript("""
CREATE TABLE IF NOT EXISTS options (
id INTEGER PRIMARY KEY,
dataroot TEXT,
adambeta1 REAL,
adambeta2 REAL,
batchSize INTEGER,
beta REAL,
checkpoints_dir TEXT,
criterion TEXT,
dataset_mode TEXT,
fineSize INTEGER,
input_nc INTEGER,
loadSize INTEGER,
lr REAL,
lr_policy TEXT,
lr_decay_iters INTEGER,
lstm_hidden_size INTEGER,
max_dataset_size INTEGER,
model TEXT,
name TEXT,
no_dropout INTEGER,
no_flip INTEGER,
n_points INTEGER,
output_nc INTEGER,
resize_or_crop INTEGER,
sampling TEXT,
serial_batches INTEGER,
split REAL
);
CREATE TABLE IF NOT EXISTS last_epochs (
id INTEGER,
epoch INTEGER DEFAULT 0
);
CREATE TABLE IF NOT EXISTS branches (
id INTEGER,
branch TEXT DEFAULT 'master'
);
CREATE TABLE IF NOT EXISTS test (
id INTEGER,
epoch INTEGER,
pos_err REAL,
ori_err REAL,
phase TEXT
);
CREATE TABLE IF NOT EXISTS tmp (
id INTEGER,
epoch INTEGER,
phase TEXT
);
""")
def drop_tables(self, *args):
print('This action will definitely delete the following tables: %s' % ', '.join(args))
if input('Continue? [y/n]').lower() in 'yes':
for table in args:
self._exec("DROP TABLE IF EXISTS %s" % table)
def commit(self):
self.connection.commit()
def new_experiment(self, **kwargs):
self._exec("SELECT id FROM options ORDER BY id")
ids = self.c.fetchall()
id = 0
while id < len(ids) and (id,) == ids[id]:
id += 1
self._new_row('options', id)
for k, v in kwargs.items():
try:
self._update(id, k, v)
except sqlite3.OperationalError:
continue
# self._exec('SELECT * FROM opts WHERE id = ?', (id,))
self._new_row('last_epochs', id)
self._new_row('branches', id)
head = os.path.join('.git', 'HEAD')
if os.path.isfile(head):
with open(head) as f:
branch = f.read().split('/')[-1]
self._exec("UPDATE branches SET branch = ? WHERE id = ?", (branch,id))
return id
def find_experiment(self, **kwargs):
query = "SELECT id FROM options WHERE "
keys = []
vals = []
for k, v in kwargs.items():
keys.append('%s = ?' % k)
vals.append(v)
query += ' AND '.join(keys)
self._exec(query, tuple(vals))
# print(query, vals)
id_list = self.c.fetchall()
if len(id_list) == 0:
return None
if len(id_list) > 1:
warnings.warn("There are multiple experiments with such options. The most recent one has been loaded.")
return max(id_list)[0]
def find_info(self, id, cols, get_col_names=False):
self._exec("SELECT %s FROM options WHERE id = ?" % cols, (id,))
if get_col_names:
description = []
for d in self.c.description:
description.append(d[0])
return self.c.fetchone(), description
return self.c.fetchone()
def update_last_epoch(self, id, epoch):
self._exec("UPDATE last_epochs SET epoch = ? WHERE id = ?", (epoch,id))
def get_last_epoch(self, id):
self._exec("SELECT epoch FROM last_epochs WHERE id = ?", (id,))
return self.c.fetchone()[0]
## TEST METHODS
def test_results(self, id, phase=None, epoch=None):
query = "SELECT epoch, pos_err, ori_err FROM test WHERE id = ?"
if phase is None:
if epoch is None:
self._exec(query + " ORDER BY epoch", (id,))
else:
self._exec(query + " AND epoch = ? ORDER BY epoch", (id,epoch))
else:
if epoch is None:
self._exec(query + " AND phase = ? ORDER BY epoch", (id,phase))
else:
self._exec(query + " AND phase = ? AND epoch = ? ORDER BY epoch", (id, phase, epoch))
res = self.c.fetchall()
if res is None or len(res) == 0:
return None
return np.array(res)
def new_test(self, id, epoch, phase):
self._exec("INSERT INTO tmp (id, epoch, phase) VALUES (?,?,?)", (id, epoch, phase))
def add_test_result(self, id, epoch, phase, pos_err, ori_err):
self._exec("INSERT INTO test (id, epoch, phase, pos_err, ori_err) VALUES (?,?,?,?,?)", (id, epoch, phase, pos_err, ori_err))
def remove_tmp_test(self, id, epoch, phase):
self._exec("DELETE FROM tmp WHERE id = ? AND epoch = ? AND phase = ?", (id, epoch, phase))
def is_test(self, id, epoch, phase):
self._exec("SELECT id FROM test WHERE id = ? AND epoch = ? AND phase = ?", (id, epoch, phase))
if self.c.fetchone() is not None:
return True
self._exec("SELECT id FROM tmp WHERE id = ? AND epoch = ? AND phase = ?", (id, epoch, phase))
return self.c.fetchone() is not None
|
(* Title: HOL/Auth/n_german_lemma_on_inv__41.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 n_german Protocol Case Study*}*)
theory n_german_lemma_on_inv__41 imports n_german_base
begin
section{*All lemmas on causal relation between inv__41 and some rule r*}
lemma n_SendInv__part__0Vsinv__41:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendInv__part__0 i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__41 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendInv__part__0 i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__41 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Para (Ident ''Chan3'') p__Inv2) ''Cmd'')) (Const InvAck)) (eqn (IVar (Para (Ident ''InvSet'') p__Inv2)) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
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_SendInv__part__1Vsinv__41:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendInv__part__1 i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__41 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendInv__part__1 i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__41 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Para (Ident ''Chan3'') p__Inv2) ''Cmd'')) (Const InvAck)) (eqn (IVar (Para (Ident ''InvSet'') p__Inv2)) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
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_SendInvAckVsinv__41:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendInvAck i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__41 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendInvAck i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__41 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
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_RecvInvAckVsinv__41:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_RecvInvAck i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__41 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_RecvInvAck i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__41 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
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_SendGntSVsinv__41:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendGntS i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__41 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendGntS i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__41 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
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_SendGntEVsinv__41:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendGntE N i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__41 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendGntE N i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__41 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
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_RecvGntSVsinv__41:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_RecvGntS i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__41 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_RecvGntS i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__41 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
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_RecvGntEVsinv__41:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_RecvGntE i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__41 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_RecvGntE i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__41 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
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_SendReqE__part__1Vsinv__41:
assumes a1: "\<exists> i. i\<le>N\<and>r=n_SendReqE__part__1 i" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__41 p__Inv2)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_StoreVsinv__41:
assumes a1: "\<exists> i d. i\<le>N\<and>d\<le>N\<and>r=n_Store i d" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__41 p__Inv2)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_RecvReqEVsinv__41:
assumes a1: "\<exists> i. i\<le>N\<and>r=n_RecvReqE N i" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__41 p__Inv2)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_SendReqE__part__0Vsinv__41:
assumes a1: "\<exists> i. i\<le>N\<and>r=n_SendReqE__part__0 i" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__41 p__Inv2)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_SendReqSVsinv__41:
assumes a1: "\<exists> i. i\<le>N\<and>r=n_SendReqS i" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__41 p__Inv2)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_RecvReqSVsinv__41:
assumes a1: "\<exists> i. i\<le>N\<and>r=n_RecvReqS N i" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__41 p__Inv2)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
end
|
function [] = rotation(st);
if nargin < 1,
st= 1;
end;
fig = gcf;
ax = gca;
vv = get(ax,'view');
az = vv(1);
el = vv(2);
for azi = az:-abs(st):az-360,
set(ax,'view',[azi el]);
figure(fig);
drawnow;
end;
|
[STATEMENT]
lemma (in Module) unique_expression6:"\<lbrakk>free_generator R M H;
f \<in> {j. j \<le> (n::nat)} \<rightarrow> H; inj_on f {j. j \<le> n};
s \<in> {j. j \<le> n} \<rightarrow> carrier R;
g \<in> {j. j \<le> (m::nat)} \<rightarrow> H; inj_on g {j. j \<le> m};
t \<in> {j. j \<le> m} \<rightarrow> carrier R;
l_comb R M n s f = l_comb R M m t g;
\<forall>j\<in>{j. j \<le> n}. s j \<noteq> \<zero>\<^bsub>R\<^esub>; \<forall>k\<in> {j. j \<le> m}. t k \<noteq> \<zero>\<^bsub>R\<^esub>\<rbrakk> \<Longrightarrow>
f `{j. j \<le> n} = g ` {j. j \<le> m}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>free_generator R M H; f \<in> {j. j \<le> n} \<rightarrow> H; inj_on f {j. j \<le> n}; s \<in> {j. j \<le> n} \<rightarrow> carrier R; g \<in> {j. j \<le> m} \<rightarrow> H; inj_on g {j. j \<le> m}; t \<in> {j. j \<le> m} \<rightarrow> carrier R; l_comb R M n s f = l_comb R M m t g; \<forall>j\<in>{j. j \<le> n}. s j \<noteq> \<zero>\<^bsub>R\<^esub>; \<forall>k\<in>{j. j \<le> m}. t k \<noteq> \<zero>\<^bsub>R\<^esub>\<rbrakk> \<Longrightarrow> f ` {j. j \<le> n} = g ` {j. j \<le> m}
[PROOF STEP]
apply (rule equalityI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
1. \<lbrakk>free_generator R M H; f \<in> {j. j \<le> n} \<rightarrow> H; inj_on f {j. j \<le> n}; s \<in> {j. j \<le> n} \<rightarrow> carrier R; g \<in> {j. j \<le> m} \<rightarrow> H; inj_on g {j. j \<le> m}; t \<in> {j. j \<le> m} \<rightarrow> carrier R; l_comb R M n s f = l_comb R M m t g; \<forall>j\<in>{j. j \<le> n}. s j \<noteq> \<zero>\<^bsub>R\<^esub>; \<forall>k\<in>{j. j \<le> m}. t k \<noteq> \<zero>\<^bsub>R\<^esub>\<rbrakk> \<Longrightarrow> f ` {j. j \<le> n} \<subseteq> g ` {j. j \<le> m}
2. \<lbrakk>free_generator R M H; f \<in> {j. j \<le> n} \<rightarrow> H; inj_on f {j. j \<le> n}; s \<in> {j. j \<le> n} \<rightarrow> carrier R; g \<in> {j. j \<le> m} \<rightarrow> H; inj_on g {j. j \<le> m}; t \<in> {j. j \<le> m} \<rightarrow> carrier R; l_comb R M n s f = l_comb R M m t g; \<forall>j\<in>{j. j \<le> n}. s j \<noteq> \<zero>\<^bsub>R\<^esub>; \<forall>k\<in>{j. j \<le> m}. t k \<noteq> \<zero>\<^bsub>R\<^esub>\<rbrakk> \<Longrightarrow> g ` {j. j \<le> m} \<subseteq> f ` {j. j \<le> n}
[PROOF STEP]
apply (rule_tac H = H and f = f and n = n and s = s and g = g and m = m and
t = t in unique_expression5, assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>free_generator R M H; f \<in> {j. j \<le> n} \<rightarrow> H; inj_on f {j. j \<le> n}; s \<in> {j. j \<le> n} \<rightarrow> carrier R; g \<in> {j. j \<le> m} \<rightarrow> H; inj_on g {j. j \<le> m}; t \<in> {j. j \<le> m} \<rightarrow> carrier R; l_comb R M n s f = l_comb R M m t g; \<forall>j\<in>{j. j \<le> n}. s j \<noteq> \<zero>\<^bsub>R\<^esub>; \<forall>k\<in>{j. j \<le> m}. t k \<noteq> \<zero>\<^bsub>R\<^esub>\<rbrakk> \<Longrightarrow> g ` {j. j \<le> m} \<subseteq> f ` {j. j \<le> n}
[PROOF STEP]
apply (rule_tac H = H and f = g and n = m and s = t and g = f and m = n and
t = s in unique_expression5, assumption+)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
1. \<lbrakk>free_generator R M H; f \<in> {j. j \<le> n} \<rightarrow> H; inj_on f {j. j \<le> n}; s \<in> {j. j \<le> n} \<rightarrow> carrier R; g \<in> {j. j \<le> m} \<rightarrow> H; inj_on g {j. j \<le> m}; t \<in> {j. j \<le> m} \<rightarrow> carrier R; l_comb R M n s f = l_comb R M m t g; \<forall>j\<in>{j. j \<le> n}. s j \<noteq> \<zero>\<^bsub>R\<^esub>; \<forall>k\<in>{j. j \<le> m}. t k \<noteq> \<zero>\<^bsub>R\<^esub>\<rbrakk> \<Longrightarrow> l_comb R M m t g = l_comb R M n s f
2. \<lbrakk>free_generator R M H; f \<in> {j. j \<le> n} \<rightarrow> H; inj_on f {j. j \<le> n}; s \<in> {j. j \<le> n} \<rightarrow> carrier R; g \<in> {j. j \<le> m} \<rightarrow> H; inj_on g {j. j \<le> m}; t \<in> {j. j \<le> m} \<rightarrow> carrier R; l_comb R M n s f = l_comb R M m t g; \<forall>j\<in>{j. j \<le> n}. s j \<noteq> \<zero>\<^bsub>R\<^esub>; \<forall>k\<in>{j. j \<le> m}. t k \<noteq> \<zero>\<^bsub>R\<^esub>\<rbrakk> \<Longrightarrow> \<forall>j\<in>{j. j \<le> m}. t j \<noteq> \<zero>\<^bsub>R\<^esub>
3. \<lbrakk>free_generator R M H; f \<in> {j. j \<le> n} \<rightarrow> H; inj_on f {j. j \<le> n}; s \<in> {j. j \<le> n} \<rightarrow> carrier R; g \<in> {j. j \<le> m} \<rightarrow> H; inj_on g {j. j \<le> m}; t \<in> {j. j \<le> m} \<rightarrow> carrier R; l_comb R M n s f = l_comb R M m t g; \<forall>j\<in>{j. j \<le> n}. s j \<noteq> \<zero>\<^bsub>R\<^esub>; \<forall>k\<in>{j. j \<le> m}. t k \<noteq> \<zero>\<^bsub>R\<^esub>\<rbrakk> \<Longrightarrow> \<forall>k\<in>{j. j \<le> n}. s k \<noteq> \<zero>\<^bsub>R\<^esub>
[PROOF STEP]
apply (rule sym, assumption, blast, blast)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done |
(* Title: Deriving class instances for datatypes
Author: Christian Sternagel and René Thiemann <christian.sternagel|[email protected]>
Maintainer: Christian Sternagel and René Thiemann
License: LGPL
*)
section \<open>Generating Hash-Functions\<close>
theory Hash_Generator
imports
"../Generator_Aux"
"../Derive_Manager"
"../../Collections/Lib/HashCode"
begin
text \<open>As usual, in the generator we use a dedicated function to combine the results
from evaluating the hash-function of the arguments of a constructor, to deliver
the global hash-value.\<close>
fun hash_combine :: "hashcode list \<Rightarrow> hashcode list \<Rightarrow> hashcode" where
"hash_combine [] [x] = x"
| "hash_combine (y # ys) (z # zs) = y * z + hash_combine ys zs"
| "hash_combine _ _ = 0"
text \<open>The first argument of @{const hash_combine} originates from evaluating the hash-function
on the arguments of a constructor, and the second argument of @{const hash_combine} will be static \emph{magic} numbers
which are generated within the generator.\<close>
subsection \<open>Improved Code for Non-Lazy Languages\<close>
lemma hash_combine_unfold:
"hash_combine [] [x] = x"
"hash_combine (y # ys) (z # zs) = y * z + hash_combine ys zs"
by auto
subsection \<open>The Generator\<close>
ML_file "hash_generator.ML"
end |
[STATEMENT]
lemma lepoll_imp_Card_le:
assumes "elts a \<lesssim> elts b" shows "vcard a \<le> vcard b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. vcard a \<le> vcard b
[PROOF STEP]
using assms lepoll_imp_gcard_le
[PROOF STATE]
proof (prove)
using this:
elts a \<lesssim> elts b
\<lbrakk>?A \<lesssim> ?B; small ?B\<rbrakk> \<Longrightarrow> gcard ?A \<le> gcard ?B
goal (1 subgoal):
1. vcard a \<le> vcard b
[PROOF STEP]
by fastforce |
{-# OPTIONS --without-K #-}
module Main where
open import Data.List
open import Midi
open import Note
open import Frog
open import Piston
main : IO Unit
main =
let channel = 0
ticksPerBeat = 4 -- 16th notes
file = "/tmp/test.mid"
-- counterpoint
song = cfcpTracks1
-- song = cfcpTracks2
-- harmony
-- song = testHTracks
in exportTracks file ticksPerBeat (map track→htrack song)
|
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# 'License'); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""Script for model comparison between TF and Gluon."""
# pylint: disable=wrong-import-position, wrong-import-order, wildcard-import
import sys
import os
import argparse
import numpy as np
import mxnet as mx
import gluonnlp as nlp
sys.path.insert(0, os.path.abspath(os.path.join(__file__, os.pardir, os.pardir)))
parser = argparse.ArgumentParser(description='Comparison script for BERT model in Tensorflow'
'and that in Gluon. This script works with '
'google/bert@f39e881b',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--input_file', type=str, default='input.txt',
help='sample input file for testing')
parser.add_argument('--tf_bert_repo_dir', type=str,
default='~/bert/',
help='path to the original Tensorflow bert repository. '
'The repo should be at f39e881b.')
parser.add_argument('--tf_model_dir', type=str,
default='~/uncased_L-12_H-768_A-12/',
help='path to the original Tensorflow bert checkpoint directory.')
parser.add_argument('--tf_model_prefix', type=str,
default='bert_model.ckpt',
help='name of bert checkpoint file.')
parser.add_argument('--tf_config_name', type=str,
default='bert_config.json',
help='Name of Bert config file')
parser.add_argument('--cased', action='store_true',
help='if not set, inputs are converted to lower case')
parser.add_argument('--gluon_dataset', type=str, default='book_corpus_wiki_en_uncased',
help='gluon dataset name')
parser.add_argument('--gluon_model', type=str, default='bert_12_768_12',
help='gluon model name')
parser.add_argument('--gluon_parameter_file', type=str, default=None,
help='gluon parameter file name.')
parser.add_argument('--gluon_vocab_file', type=str, default=None,
help='gluon vocab file corresponding to --gluon_parameter_file.')
args = parser.parse_args()
input_file = os.path.expanduser(args.input_file)
tf_bert_repo_dir = os.path.expanduser(args.tf_bert_repo_dir)
tf_model_dir = os.path.expanduser(args.tf_model_dir)
vocab_file = os.path.join(tf_model_dir, 'vocab.txt')
bert_config_file = os.path.join(tf_model_dir, args.tf_config_name)
init_checkpoint = os.path.join(tf_model_dir, args.tf_model_prefix)
do_lower_case = not args.cased
max_length = 128
###############################################################################
# Tensorflow MODEL #
###############################################################################
# import tensorflow modules
sys.path.insert(0, tf_bert_repo_dir)
# tensorflow model inference
import modeling
import tokenization
from extract_features import *
# data
num_layers = int(args.gluon_model.split('_')[1])
layer_indexes = list(range(num_layers))
bert_config = modeling.BertConfig.from_json_file(bert_config_file)
tokenizer = tokenization.FullTokenizer(vocab_file=vocab_file, do_lower_case=do_lower_case)
examples = read_examples(input_file)
features = convert_examples_to_features(
examples=examples, seq_length=max_length, tokenizer=tokenizer)
is_per_host = tf.contrib.tpu.InputPipelineConfig.PER_HOST_V2
run_config = tf.contrib.tpu.RunConfig(
master=None,
tpu_config=tf.contrib.tpu.TPUConfig(
num_shards=1,
per_host_input_for_training=is_per_host))
# model
model_fn = model_fn_builder(
bert_config=bert_config,
init_checkpoint=init_checkpoint,
layer_indexes=layer_indexes,
use_tpu=False,
use_one_hot_embeddings=False)
estimator = tf.contrib.tpu.TPUEstimator(
use_tpu=False,
model_fn=model_fn,
config=run_config,
predict_batch_size=1)
input_fn = input_fn_builder(
features=features, seq_length=max_length)
tensorflow_all_out = []
for result in estimator.predict(input_fn, yield_single_examples=True):
output_json = collections.OrderedDict()
tensorflow_all_out_features = []
all_layers = []
for (j, layer_index) in enumerate(layer_indexes):
layer_output = result['layer_output_%d' % j]
layers = collections.OrderedDict()
layers['index'] = layer_index
layers['values'] = layer_output
all_layers.append(layers)
tensorflow_out_features = collections.OrderedDict()
tensorflow_out_features['layers'] = all_layers
tensorflow_all_out_features.append(tensorflow_out_features)
output_json['features'] = tensorflow_all_out_features
tensorflow_all_out.append(output_json)
tf_outputs = [tensorflow_all_out[0]['features'][0]['layers'][t]['values'] for t in layer_indexes]
###############################################################################
# Gluon MODEL #
###############################################################################
if args.gluon_parameter_file:
assert args.gluon_vocab_file, \
'Must specify --gluon_vocab_file when specifying --gluon_parameter_file'
with open(args.gluon_vocab_file, 'r') as f:
vocabulary = nlp.Vocab.from_json(f.read())
bert, vocabulary = nlp.model.get_model(args.gluon_model,
dataset_name=None,
vocab=vocabulary,
pretrained=not args.gluon_parameter_file,
use_pooler=False,
use_decoder=False,
use_classifier=False)
try:
bert.cast('float16')
bert.load_parameters(args.gluon_parameter_file, ignore_extra=True)
bert.cast('float32')
except AssertionError:
bert.cast('float32')
bert.load_parameters(args.gluon_parameter_file, ignore_extra=True)
else:
assert not args.gluon_vocab_file, \
'Cannot specify --gluon_vocab_file without specifying --gluon_parameter_file'
bert, vocabulary = nlp.model.get_model(args.gluon_model,
dataset_name=args.gluon_dataset,
pretrained=not args.gluon_parameter_file,
use_pooler=False,
use_decoder=False,
use_classifier=False)
print(bert)
tokenizer = nlp.data.BERTTokenizer(vocabulary, lower=do_lower_case)
dataset = nlp.data.TSVDataset(input_file, field_separator=nlp.data.Splitter(' ||| '))
trans = nlp.data.BERTSentenceTransform(tokenizer, max_length)
dataset = dataset.transform(trans)
bert_dataloader = mx.gluon.data.DataLoader(dataset, batch_size=1,
shuffle=True, last_batch='rollover')
# verify the output of the first sample
for i, seq in enumerate(bert_dataloader):
input_ids, valid_length, type_ids = seq
out = bert(input_ids, type_ids,
valid_length.astype('float32'))
length = valid_length.asscalar()
a = tf_outputs[-1][:length]
b = out[0][:length].asnumpy()
print('stdev = %s' % (np.std(a - b)))
mx.test_utils.assert_almost_equal(a, b, atol=5e-6, rtol=5e-6)
break
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.LoopSpaceCircle
-- This file is temporarily put in the cw/ directory for
-- development, but it actually belongs to somewhere else.
module homotopy.SphereEndomorphism where
⊙SphereS-endo-out : ∀ n
→ Trunc 0 (⊙Sphere (S n) ⊙→ ⊙Sphere (S n))
→ Trunc 0 ( Sphere (S n) → Sphere (S n))
⊙SphereS-endo-out n = Trunc-rec Trunc-level ([_] ∘ fst)
-- For [S¹], the pointedness is free because of the commutativity of its loop space.
-- favonia: maybe one can simplify the proofs through
-- an intermediate type [Σ S¹ (λ x → x == x)]?
private
⊙S¹-endo-in'' : (base* : S¹) (loop* : base* == base*) → (⊙S¹ ⊙→ ⊙S¹)
⊙S¹-endo-in'' = S¹-elim
(λ loop* → S¹-rec base loop* , idp)
(↓-app→cst-in λ r → ap (λ loop* → (S¹-rec base loop* , idp)) (lemma₀ r)) where
abstract
lemma₀ : ∀ {loop₁ loop₂}
→ loop₁ == loop₂ [ (λ x → x == x) ↓ loop ]
→ loop₁ == loop₂
lemma₀ {loop₁} {loop₂} p = anti-whisker-right loop $
loop₁ ∙ loop
=⟨ ↓-idf=idf-out' p ⟩
loop ∙' loop₂
=⟨ ∙'=∙ loop loop₂ ⟩
loop ∙ loop₂
=⟨ ΩS¹-is-abelian loop loop₂ ⟩
loop₂ ∙ loop
=∎
⊙S¹-endo-in' : (S¹ → S¹) → (⊙S¹ ⊙→ ⊙S¹)
⊙S¹-endo-in' f = ⊙S¹-endo-in'' (f base) (ap f loop)
⊙S¹-endo-in : Trunc 0 (S¹ → S¹) → Trunc 0 (⊙S¹ ⊙→ ⊙S¹)
⊙S¹-endo-in = Trunc-fmap ⊙S¹-endo-in'
abstract
⊙S¹-endo-in-η : ∀ f → ⊙S¹-endo-in (⊙SphereS-endo-out 0 f) == f
⊙S¹-endo-in-η = Trunc-elim (λ _ → =-preserves-set Trunc-level)
λ{(f , pt) → ap [_] $
⊙S¹-endo-in''-shifted pt (ap f loop) ∙ ⊙λ= (S¹-rec-η f) idp}
where
-- free one end to apply identification elimination
⊙S¹-endo-in''-shifted : {base* : S¹}
(shift : base* == base) (loop* : base* == base*)
→ ⊙S¹-endo-in'' base* loop* == (S¹-rec base* loop* , shift)
⊙S¹-endo-in''-shifted idp _ = idp
⊙S¹-endo-out-β : ∀ f → ⊙SphereS-endo-out 0 (⊙S¹-endo-in f) == f
⊙S¹-endo-out-β = Trunc-elim (λ _ → =-preserves-level Trunc-level)
λ f → ! (ap (λ f → [ fst (⊙S¹-endo-in' f) ]) (λ= $ S¹-rec-η f))
∙ ⊙S¹-endo-out'-β (f base) (ap f loop)
∙ ap [_] (λ= $ S¹-rec-η f)
where
-- free [base*] to apply circle elimination
⊙S¹-endo-out'-β : (base* : S¹) (loop* : base* == base*)
→ [ fst (⊙S¹-endo-in' (S¹-rec base* loop*)) ]
== [ S¹-rec base* loop* ] :> Trunc 0 (S¹ → S¹)
⊙S¹-endo-out'-β = S¹-elim
(λ loop* → ap (λ loop* → [ S¹-rec base loop* ]) (S¹Rec.loop-β base loop*))
(prop-has-all-paths-↓ $ Π-is-prop λ loop* → Trunc-level {n = 0} _ _)
⊙S¹-endo-out-is-equiv : is-equiv (⊙SphereS-endo-out 0)
⊙S¹-endo-out-is-equiv = is-eq _ ⊙S¹-endo-in ⊙S¹-endo-out-β ⊙S¹-endo-in-η
-- For [Sphere (S (S n))], the pointedness is free because of its connectivity.
private
SphereSS-conn : ∀ n → is-connected 1 (Sphere (S (S n)))
SphereSS-conn n = connected-≤T (≤T-+2+-l 1 (-2≤T ⟨ n ⟩₋₂)) (Sphere-conn (S (S n)))
SphereSS-conn-path : ∀ n (x y : Sphere (S (S n))) → is-connected 0 (x == y)
SphereSS-conn-path n x y = path-conn (SphereSS-conn n)
SphereSS-has-all-trunc-paths : ∀ n (x y : Sphere (S (S n))) → Trunc 0 (x == y)
SphereSS-has-all-trunc-paths n x y = –> (Trunc=-equiv [ x ] [ y ])
(contr-has-all-paths (SphereSS-conn n) [ x ] [ y ])
⊙SphereSS-endo-in : ∀ n
→ Trunc 0 ( Sphere (S (S n)) → Sphere (S (S n)))
→ Trunc 0 (⊙Sphere (S (S n)) ⊙→ ⊙Sphere (S (S n)))
⊙SphereSS-endo-in n = Trunc-rec Trunc-level λ f →
Trunc-rec Trunc-level (λ pt → [ f , pt ])
(SphereSS-has-all-trunc-paths n (f north) north)
abstract
⊙SphereSS-endo-in-η : ∀ n f → ⊙SphereSS-endo-in n (⊙SphereS-endo-out (S n) f) == f
⊙SphereSS-endo-in-η n = Trunc-elim (λ _ → =-preserves-set Trunc-level)
λ{(f , pt) → ap (Trunc-rec Trunc-level (λ pt → [ f , pt ]))
(contr-has-all-paths (SphereSS-conn-path n (f north) north)
(SphereSS-has-all-trunc-paths n (f north) north) [ pt ])}
⊙SphereSS-endo-out-β : ∀ n f → ⊙SphereS-endo-out (S n) (⊙SphereSS-endo-in n f) == f
⊙SphereSS-endo-out-β n = Trunc-elim (λ _ → =-preserves-set Trunc-level)
λ f → Trunc-elim
{P = λ pt → ⊙SphereS-endo-out (S n) (Trunc-rec Trunc-level (λ pt → [ f , pt ]) pt) == [ f ]}
(λ _ → =-preserves-set Trunc-level)
(λ pt → idp) (SphereSS-has-all-trunc-paths n (f north) north)
⊙SphereSS-endo-out-is-equiv : ∀ n → is-equiv (⊙SphereS-endo-out (S n))
⊙SphereSS-endo-out-is-equiv n = is-eq
(⊙SphereS-endo-out (S n)) (⊙SphereSS-endo-in n)
(⊙SphereSS-endo-out-β n) (⊙SphereSS-endo-in-η n)
-- the unified interface
⊙SphereS-endo-out-is-equiv : ∀ n → is-equiv (⊙SphereS-endo-out n)
⊙SphereS-endo-out-is-equiv 0 = ⊙S¹-endo-out-is-equiv
⊙SphereS-endo-out-is-equiv (S n) = ⊙SphereSS-endo-out-is-equiv n
⊙SphereS-endo-in : ∀ n
→ Trunc 0 ( Sphere (S n) → Sphere (S n))
→ Trunc 0 (⊙Sphere (S n) ⊙→ ⊙Sphere (S n))
⊙SphereS-endo-in n = is-equiv.g (⊙SphereS-endo-out-is-equiv n)
|
For the 30th Grammy Awards ( 1988 ) , Best Concept Music Video nominees <unk> David Bowie for " Day @-@ In Day @-@ Out " , Kate Bush for The Whole Story , the English rock band Genesis for " Land of Confusion " , David Lee Roth for David Lee Roth , and Janet Jackson for Control – The Videos Part II . The music video for Bowie 's " Day @-@ In Day @-@ Out " , directed by Julien Temple , included " offending " scenes such as a man urinating on Ronald Reagan 's Hollywood Walk of Fame star , which was edited out for television broadcast . Bush 's " imaginative " video sampler accompanies her greatest hits album of the same name and includes music videos for songs throughout her career to that point . The music video for " Land of Confusion " , a song included on the band 's 1986 album Invisible Touch , contained Spitting Image puppets of Ronald Reagan , Margaret Thatcher and other notable individuals . David Lee Roth 's self @-@ titled video consisted of promotional clips created for his debut solo EP Crazy from the Heat and album Eat ' Em and Smile . Jackson 's video collection , which was certified gold in the United States , contained six promotional videos recorded for singles from her album Control . Awards were presented to members of Genesis ( Tony Banks , Phil Collins , and Mike Rutherford ) as the performing artists , Jim Yukich and John Lloyd as the video directors , and Jon Blair as the video producer .
|
State Before: R : Type u
S : Type v
ι : Type w
a✝ b : R
m n : ℕ
inst✝ : Semiring R
p q r f : R[X]
a : R
⊢ natDegree f + natDegree (↑C a) = natDegree f + 0 State After: no goals Tactic: rw [natDegree_C a] |
(* This file is an automatic translation, the licence of the source can be found here: *)
(* https://github.com/herd/herdtools7/blob/master/LICENSE.txt *)
(* Translation of model TSO *)
From Coq Require Import Relations Ensembles String.
From RelationAlgebra Require Import lattice prop monoid rel kat.
From Catincoq.lib Require Import Cat proprel.
Section Model.
Variable c : candidate.
Definition events := events c.
Definition R := R c.
Definition W := W c.
Definition IW := IW c.
Definition FW := FW c.
Definition B := B c.
Definition RMW := RMW c.
Definition F := F c.
Definition rf := rf c.
Definition po := po c.
Definition int := int c.
Definition ext := ext c.
Definition loc := loc c.
Definition addr := addr c.
Definition data := data c.
Definition ctrl := ctrl c.
Definition amo := amo c.
Definition rmw := rmw c.
Definition unknown_set := unknown_set c.
Definition unknown_relation := unknown_relation c.
Definition M := R ⊔ W.
Definition emptyset : set events := empty.
Definition classes_loc : set events -> Ensemble (Ensemble events) := partition loc.
Definition MFENCE := unknown_set "MFENCE".
Definition sm := unknown_relation "sm".
Definition tag2events := unknown_relation "tag2events".
Definition emptyset_0 : set events := domain 0.
Definition partition := classes_loc.
Definition tag2instrs := tag2events.
Definition po_loc := po ⊓ loc.
Definition rfe := rf ⊓ ext.
Definition rfi := rf ⊓ int.
Definition co0 := loc ⊓ ([IW] ⋅ top ⋅ [(W ⊓ !IW)] ⊔ [(W ⊓ !FW)] ⋅ top ⋅ [FW]).
Definition toid (s : set events) : relation events := [s].
Definition fencerel (B : set events) := (po ⊓ [top] ⋅ top ⋅ [B]) ⋅ po.
Definition ctrlcfence (CFENCE : set events) := (ctrl ⊓ [top] ⋅ top ⋅ [CFENCE]) ⋅ po.
Definition imply (A : relation events) (B : relation events) := !A ⊔ B.
Definition nodetour (R1 : relation events) (R2 : relation events) (R3 : relation events) := R1 ⊓ !(R2 ⋅ R3).
Definition singlestep (R : relation events) := nodetour R R R.
(* Definition of map already included in the prelude *)
Definition LKW := (*failed: try LKW with emptyset_0*) emptyset_0.
Definition mfence := (*successful: try fencerel MFENCE with 0*) fencerel MFENCE.
Definition lfence : relation events := (*failed: try fencerel LFENCE with 0*) 0.
Definition sfence : relation events := (*failed: try fencerel SFENCE with 0*) 0.
Definition A := ((*failed: try X with emptyset_0*) emptyset_0) ⊔ ((*failed: try A with emptyset_0*) emptyset_0).
Definition P := M ⊓ !A.
Definition WW r := r ⊓ [W] ⋅ top ⋅ [W].
Definition WR r := r ⊓ [W] ⋅ top ⋅ [R].
Definition RW r := r ⊓ [R] ⋅ top ⋅ [W].
Definition RR r := r ⊓ [R] ⋅ top ⋅ [R].
Definition RM r := r ⊓ [R] ⋅ top ⋅ [M].
Definition MR r := r ⊓ [M] ⋅ top ⋅ [R].
Definition WM r := r ⊓ [W] ⋅ top ⋅ [M].
Definition MW r := r ⊓ [M] ⋅ top ⋅ [W].
Definition MM r := r ⊓ [M] ⋅ top ⋅ [M].
Definition AA r := r ⊓ [A] ⋅ top ⋅ [A].
Definition AP r := r ⊓ [A] ⋅ top ⋅ [P].
Definition PA r := r ⊓ [P] ⋅ top ⋅ [A].
Definition PP r := r ⊓ [P] ⋅ top ⋅ [P].
Definition AM r := r ⊓ [A] ⋅ top ⋅ [M].
Definition MA r := r ⊓ [M] ⋅ top ⋅ [A].
Definition noid r : relation events := r ⊓ !id.
Definition atom := [A].
(* Definition of co_locs already included in the prelude *)
(* Definition of cross already included in the prelude *)
Definition generate_orders s pco := cross (co_locs pco (partition s)).
Definition generate_cos pco := generate_orders W pco.
Definition cobase := co0.
Variable co : relation events.
Definition coi := co ⊓ int.
Definition coe := co ⊓ !coi.
Definition fr := rf° ⋅ co ⊓ !id.
Definition fri := fr ⊓ int.
Definition fre := fr ⊓ !fri.
Definition test := acyclic (po_loc ⊔ (rf ⊔ (fr ⊔ co))).
Definition test_0 := is_empty (rmw ⊓ fre ⋅ coe).
Definition poWR := [W] ⋅ (po ⋅ [R]).
Definition i1 := poWR ⋅ [A].
Definition i2 := [A] ⋅ poWR.
Definition implied := i1 ⊔ i2.
Definition ppo := [R] ⋅ (po ⋅ [R]) ⊔ ([M] ⋅ (po ⋅ [W]) ⊔ ([M] ⋅ (po ⋅ ([MFENCE] ⋅ (po ⋅ [M]))) ⊔ implied)).
Definition ghb := ppo ⊔ (rfe ⊔ (fr ⊔ co)) ⋅ sm.
Definition tso := acyclic ghb.
Definition witness_conditions := generate_cos cobase co.
Definition model_conditions := test /\ (test_0 /\ tso).
End Model.
Hint Unfold events R W IW FW B RMW F rf po int ext loc addr data ctrl amo rmw unknown_set unknown_relation M emptyset classes_loc MFENCE sm tag2events emptyset_0 partition tag2instrs po_loc rfe rfi co0 toid fencerel ctrlcfence imply nodetour singlestep LKW mfence lfence sfence A P WW WR RW RR RM MR WM MW MM AA AP PA PP AM MA noid atom generate_orders generate_cos cobase coi coe fr fri fre test test_0 poWR i1 i2 implied ppo ghb tso witness_conditions model_conditions : cat.
Definition valid (c : candidate) :=
exists co : relation (events c),
witness_conditions c co /\
model_conditions c co.
(* End of translation of model TSO *)
|
module School.Utils.Debug
( compareDoubleMatrixTrace
, db
, printConduit
, printConduitP
, printVar
, showIO
, sl
, trace
) where
import Conduit (ConduitM, mapC, peekC)
import Control.Monad.IO.Class (MonadIO, liftIO)
import Debug.Trace (trace, traceIO)
import Numeric.LinearAlgebra (Matrix, R, toLists)
import School.Types.FloatEq (compareDouble)
sl :: (Show a) => a -> String
sl a = show a ++ " "
showIO :: (MonadIO m) => String -> m ()
showIO = liftIO . traceIO
printConduitP :: (Monad m, Show a)
=> String
-> ConduitM a a m ()
printConduitP str = do
next <- peekC
mapC (db id (str ++ ": " ++ show next))
printConduit :: (MonadIO m, Show a)
=> String
-> ConduitM a a m ()
printConduit str = do
next <- peekC
liftIO $ putStrLn (str ++ ": " ++ show next)
mapC id
printVar :: (Show a) => String -> a -> a
printVar str x = trace (str ++ ": " ++ show x) x
db :: a -> String -> a
db = flip trace
compareDoubleMatrixTrace :: Double
-> Matrix R
-> Matrix R
-> Bool
compareDoubleMatrixTrace prec m1 m2 =
and $ zipWith (traceCompare prec) l1 l2
where traceMsg c msg v = if c
then trace msg v
else v
traceCompare p d1 d2 =
let equal = compareDouble p d1 d2
in traceMsg (not equal) ("UNEQ " ++ show d1 ++ " " ++ show d2) equal
l1 = concat . toLists $ m1
l2 = concat . toLists $ m2
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
module Categories.Functor.Hom.Properties {o ℓ e} (C : Category o ℓ e) where
open import Categories.Functor.Hom.Properties.Covariant C public
open import Categories.Functor.Hom.Properties.Contra C public
|
Fitwatch ( formed in early 2007 ) campaign against FITs by actively obstructing their operations , and by passively opposing their operations by photographing units ( a form of sousveillance ) .
|
-- Andreas, 2015-07-16
-- For printing lambda-bound names, name _ should behave as no name.
-- {-# OPTIONS -v tc.term.lambda:60 #-}
module _ where
Test = (A : Set) {A : Set} → A → A
works : Test
works = λ C x → {!!}
-- the goal should be displayed as ?0 : .A
g : Test
g = λ C {_} x → {!!}
-- the goal should be displayed as ?1 : .A
-- not ?1 : _ or ?1 : A
h : Test
h = λ C {_} → λ x → {!!}
-- the goal should be displayed as ?1 : .A
-- not ?1 : _ or ?1 : A
|
(*
Copyright 2018
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
theory Simplified_Semantics
imports reassembly_all_execution_debug.Leviathan_Setup
begin
(* TODO: the following theorems should be moved up to theor respective theories. They are duplicated in pow2. *)
lemma bv_NOT_bool_to_bv[simp]:
shows "bv_NOT (bool_to_bv b) = bool_to_bv (\<not>b)"
by (cases b, auto simp add: max_word_def)
lemma bool_to_bv_eq[simp]:
shows "bool_to_bv b = (x, Suc 0) \<longleftrightarrow> (x \<in> {0,1} \<and> ((x = 1) \<longleftrightarrow> b))"
by (cases b,auto)
lemma bv_slice_nth_bit[simp]:
assumes "h < \<M>"
shows "bv_slice h h a = bool_to_bv (fst a !! h)"
proof-
{
fix i :: nat
assume "i < \<M>"
hence "((\<langle>h,h\<rangle>(fst a))::longword) !! i = (if fst a !! h then 1::longword else 0) !! i"
using assms
by (auto simp add: test_bit_of_take_bits)
}
hence "((\<langle>h,h\<rangle>(fst a))::longword) = (if fst a !! h then 1::longword else 0)"
apply (intro word_eqI)
by (auto simp add: word_size)
thus ?thesis
by (cases a;auto simp add: bv_slice.simps)
qed
lemma msb_is_gt_2p:
fixes a :: "'a::len word"
shows "msb a \<longleftrightarrow> a \<ge> 2 ^ (LENGTH('a) - 1)"
proof-
{
assume 1: "a !! (LENGTH('a) - 1)"
hence "a \<ge> 2 ^ (LENGTH('a) - 1)"
using bang_is_le
by (auto simp add: word_size)
}
moreover
{
assume 1: "\<not>a!! (LENGTH('a) - 1)"
{
fix i :: nat
assume "i < LENGTH('a)"
hence "(a AND mask (LENGTH('a) - 1)) !! i = a !! i"
using 1
by (cases "i=LENGTH('a) - 1",auto simp add: word_ao_nth word_size)
}
hence "a AND mask (LENGTH('a) - 1) = a"
apply (intro word_eqI)
by (auto simp add: word_size)
hence "a < 2 ^ (LENGTH('a) - 1)"
using mask_eq_iff_w2p[of "LENGTH('a) - 1" a]
by (auto simp add: word_size)
}
ultimately
show ?thesis
unfolding msb_nth
using linorder_not_le
by blast
qed
lemma test_bit_of_add_2p:
fixes a :: "'a::len word"
assumes "i < n"
and "n < LENGTH('a)"
and "\<langle>n-1,0\<rangle>a = a"
shows "(2^n + a) !! i = a !! i"
proof-
{
fix j :: nat
assume "j < LENGTH('a) - n"
hence "take (LENGTH('a) - n) (to_bl a) ! j = replicate (LENGTH('a) - n) False ! j"
apply (auto)
apply (subst (asm) assms(3)[symmetric])
apply (subst (asm) to_bl_nth)
using assms
by (auto simp add: word_size test_bit_of_take_bits split: if_split_asm)
}
hence "take (LENGTH('a) - n) (to_bl a) = replicate (LENGTH('a) - n) False"
apply (intro nth_equalityI)
by (auto)
hence "rev (to_bl (2^n + a)) ! i = a !! i"
using assms
apply (subst aligned_bl_add_size[where n=n])
apply (simp add: word_size)
apply (subst shiftl_1[symmetric])+
apply (simp only: word_size bl_shiftl)
apply (simp del: to_bl_one)
apply (subst shiftl_1[symmetric])+
apply (simp only: word_size bl_shiftl) defer
by (auto simp add: rev_nth nth_append word_size test_bit_bl)
thus ?thesis
by (auto simp add: test_bit_bl word_size)
qed
lemma bitNOT_nth:
"(NOT x) !! n \<longleftrightarrow> n < LENGTH('a) \<and> \<not>x !! n"
for x :: "'a::len0 word"
using test_bit_size[of "NOT x" n]
by (auto simp add: word_size word_ops_nth_size)
lemma zero_le_2p:
assumes "n < LENGTH('a)"
shows "(0::'a::len word) < 2 ^ n"
using assms
proof(induct n)
case 0
thus ?case
by auto
next
case (Suc n)
thus ?case
using shiftl_1[symmetric,of "n+1",where 'a='a]
using is_zero_shiftl[of "1::'a word" "n+1"]
apply (auto simp del: shiftl_1)
by fastforce
qed
lemma ucast_bitNOT:
fixes a :: "'a ::len word"
assumes "LENGTH('b) = LENGTH('a) + 1"
shows "((ucast (NOT a))::'b::len word) = NOT (2 ^ LENGTH('a) + ucast a)"
proof-
have "uint a < 2^LENGTH('a)"
by (auto)
hence 0: "(2 ^ LENGTH('a) + ucast a :: 'b word) \<ge> 2 ^ LENGTH('a)"
using assms
apply uint_arith
apply (auto simp add: is_up uint_up_ucast)
apply (subst (asm) uint_2p)
by (simp add: zero_le_2p)+
{
fix i :: nat
assume i: "i < LENGTH('b)"
have "(2 ^ LENGTH('a) + ucast a :: 'b word) !! LENGTH('a)"
using 0 msb_is_gt_2p[unfolded msb_nth,where 'a='b] assms
by auto
moreover
have "i < LENGTH('a) \<Longrightarrow> ((2 ^ LENGTH('a) + ucast a)::'b word) !! i = a !! i"
using assms
apply (subst test_bit_of_add_2p)
by (auto simp add: nth_ucast)
ultimately
have "((ucast (NOT a))::'b word) !! i = (NOT (2 ^ LENGTH('a) + ucast a :: 'b word)) !! i"
using assms
by (cases "i = LENGTH('a)",auto simp add: bitNOT_nth word_size nth_ucast)
}
thus ?thesis
apply (intro word_eqI)
by (auto simp add: word_size)
qed
lemma take_bits_le_bit32:
fixes a b :: "'b::len0 word"
assumes "32 < LENGTH('a)"
and "32 \<le> LENGTH('b)"
shows "(((\<langle>31,0\<rangle>a)::'a::len0 word) \<le> ((\<langle>31,0\<rangle>b)::'a::len0 word)) = (((\<langle>31,0\<rangle>a)::32 word) \<le> ((\<langle>31,0\<rangle>b)::32 word))"
proof-
have "(((\<langle>31,0\<rangle>a)::'a::len0 word) = ((\<langle>31,0\<rangle>b)::'a::len0 word)) = (((\<langle>31,0\<rangle>a)::32 word) = ((\<langle>31,0\<rangle>b)::32 word))"
proof-
{
assume "(((\<langle>31,0\<rangle>a)::'a::len0 word) = ((\<langle>31,0\<rangle>b)::'a::len0 word))"
hence "\<forall> i < 32 . (((\<langle>31,0\<rangle>a)::'a::len0 word) !! i = (((\<langle>31,0\<rangle>b)::'a::len0 word)) !! i)"
using assms
by (auto simp add: test_bit_of_take_bits)
hence "\<forall> i < 32 . (((\<langle>31,0\<rangle>a)::32 word) !! i = (((\<langle>31,0\<rangle>b)::32 word)) !! i)"
using assms
by (auto simp add: test_bit_of_take_bits)
hence "(((\<langle>31,0\<rangle>a)::32 word) = ((\<langle>31,0\<rangle>b)::32 word))"
apply (intro word_eqI)
by (auto simp add: word_size)
}
moreover
{
assume "(((\<langle>31,0\<rangle>a)::32 word) = ((\<langle>31,0\<rangle>b)::32 word))"
hence "\<forall> i < 32 . (((\<langle>31,0\<rangle>a)::32 word) !! i = (((\<langle>31,0\<rangle>b)::32 word)) !! i)"
using assms
by (auto simp add: test_bit_of_take_bits)
hence "\<forall> i < LENGTH('a) . (((\<langle>31,0\<rangle>a)::'a::len0 word) !! i = (((\<langle>31,0\<rangle>b)::'a::len0 word)) !! i)"
using assms
by (auto simp add: test_bit_of_take_bits)
hence "(((\<langle>31,0\<rangle>a)::'a::len0 word) = ((\<langle>31,0\<rangle>b)::'a::len0 word))"
using assms
apply (intro word_eqI)
by (auto simp add: word_size)
}
ultimately
show ?thesis
by auto
qed
thus ?thesis
using assms
apply (cases "(((\<langle>31,0\<rangle>a)::'a::len0 word) = ((\<langle>31,0\<rangle>b)::'a::len0 word))"; cases "(((\<langle>31,0\<rangle>a)::32 word) = ((\<langle>31,0\<rangle>b)::32 word))";auto)
by (meson less_imp_le_nat linorder_not_le take_bits_lt_bit32)+
qed
lemma overflow_sub_bit32[simp]:
fixes a b:: "'a :: len0 word"
assumes "31 < LENGTH('a)"
shows "((1::33 word) + (((\<langle>31,0\<rangle>a)::33 word) + ucast (NOT ((\<langle>31,0\<rangle>b):: 32 word)))) !! 32 = (((\<langle>31,0\<rangle>a)::32 word) \<ge> \<langle>31,0\<rangle>b)"
proof-
have 3: "(((\<langle>31,0\<rangle>a)::33 word) \<ge> \<langle>31,0\<rangle>b) = (((\<langle>31,0\<rangle>a)::32 word) \<ge> \<langle>31,0\<rangle>b)"
using assms
by (subst take_bits_le_bit32,simp,simp,simp)
have 1: "\<not> ((\<langle>31,0\<rangle>a)::33 word) !! 32"
and 2: "\<not> ((\<langle>31,0\<rangle>b)::33 word) !! 32"
using assms
by (auto simp add: test_bit_of_take_bits)
have "uint ((\<langle>31,0\<rangle>a)::33 word) < 4294967296"
and "uint ((\<langle>31,0\<rangle>b)::33 word) < 4294967296"
using msb_is_gt_2p[unfolded msb_nth,where 'a=33,simplified] 1
apply (uint_arith)
using msb_is_gt_2p[unfolded msb_nth,where 'a=33,simplified] 2
by (uint_arith)
hence "((1::33 word) + (((\<langle>31,0\<rangle>a)::33 word) + ucast (NOT ((\<langle>31,0\<rangle>b):: 32 word)))) !! 32 = (((\<langle>31,0\<rangle>a)::33 word) \<ge> \<langle>31,0\<rangle>b)"
apply (subst ucast_bitNOT)
apply simp
apply (subst twos_complement_subtraction)
apply simp
apply (subst msb_is_gt_2p[unfolded msb_nth,where 'a=33,simplified])
apply auto
apply uint_arith
using assms
apply (auto simp add: is_up)
apply uint_arith
using assms
by (auto simp add: is_up)
thus ?thesis
using 3
by auto
qed
lemma sign_sub_bit32[simp]:
fixes a b:: "'a :: len0 word"
assumes "31 < LENGTH('a)"
shows "((1::33 word) + (((\<langle>31,0\<rangle>a)::33 word) + ucast (NOT ((\<langle>31,0\<rangle>b):: 32 word)))) !! 31 \<longleftrightarrow> sint (((\<langle>31,0\<rangle>a):: 32 word) - \<langle>31,0\<rangle>b) < 0"
proof-
have 1: "\<And> a :: 33 word . a !! 31 = ((\<langle>31,0\<rangle>a):: 32 word) !! 31"
using assms
by (auto simp add: test_bit_of_take_bits nth_ucast)
have 2: "\<langle>31,0\<rangle>((1::33 word) + (((\<langle>31,0\<rangle>a)::33 word) + ucast (NOT ((\<langle>31,0\<rangle>b):: 32 word)))) = (((\<langle>31,0\<rangle>a)::32 word) - \<langle>31,0\<rangle>b)"
using assms
apply (subst ucast_bitNOT)
apply simp
apply (subst twos_complement_subtraction)
apply (subst take_bits_minus)
apply (simp)
apply (simp)
by (simp)
have 3: "... !! 31 \<longleftrightarrow> sint (((\<langle>31,0\<rangle>a):: 32 word) - \<langle>31,0\<rangle>b) < 0"
using msb_nth[symmetric, where 'a=32]
by (simp add: word_msb_sint)
show ?thesis
apply (subst 1)
apply (subst 2)
apply (subst 3)
by simp
qed
lemma twos_complement_subtraction_r[simp]:
fixes a b :: "'a::len0 word"
shows "1 + (NOT b + a) = a - b"
by (auto simp add: word_succ_p1 twos_complement)
(* TODO: here we can build a locale with semantics for each instruction *)
definition xor :: "bool \<Rightarrow> bool \<Rightarrow> bool" (infixr "\<otimes>" 36)
where "a \<otimes> b \<equiv> (a \<and> \<not>b) \<or> (\<not>a \<and> b)"
definition parity :: "'a::len0 word \<Rightarrow> bool"
where "parity a \<equiv> fold (\<otimes>) (drop (LENGTH('a) - 8) (to_bl a)) True"
(*5 flags generation CF,SF,OF,ZF,PF *)
instruction_semantics_parser "../InstructionSemantics/strata_rules_5flags"
lemmas strata_rules_5flags.semantics_def [code]
locale execution_plus_strata_rules_5flags = execution_context + strata_rules_5flags
begin
fun get_OP1 :: "bitvector_formula list \<Rightarrow> BV_var"
where
"get_OP1 [] = undefined"
| "get_OP1 ((BV_Assignment v bvf)#_) = v"
| "get_OP1 (_#bfs) = get_OP1 bfs"
fun writes_pflag :: "bitvector_formula list \<Rightarrow> bool"
where
"writes_pflag [] = False"
| "writes_pflag ((BV_Assignment v bvf)#bfs) = writes_pflag bfs"
| "writes_pflag ((BV_Flag_Assignment flag_pf bvf)#bfs) = True"
| "writes_pflag ((BV_Flag_Assignment _ bvf)#bfs) = writes_pflag bfs"
| "writes_pflag _ = undefined"
fun exec_learned_instr' :: "bitvector_formula list \<Rightarrow> instr \<Rightarrow> state \<Rightarrow> state"
where
"exec_learned_instr' [] i \<sigma> = \<sigma>"
| "exec_learned_instr' ((BV_Assignment v bvf)#bfs) i \<sigma> =
(let' bv = ((exec_chum_bvf bvf i \<sigma>));
od = operand_src_to_operand_dest (resolve_BV_Var i v);
\<sigma>' = exec_learned_instr' bfs i \<sigma> in
bv_put od bv \<sigma>')"
| "exec_learned_instr' ((BV_Flag_Assignment flag_pf bvf)#bfs) i \<sigma> = \<comment> \<open>TODO\<close>
(let' \<sigma>' = exec_learned_instr' bfs i \<sigma> in
\<sigma>')"
| "exec_learned_instr' ((BV_Flag_Assignment flg bvf)#bfs) i \<sigma> =
(let' \<sigma>' = exec_learned_instr' bfs i \<sigma>;
e = exec_chum_bvf bvf i \<sigma>;
f = bv_to_bool e;
\<sigma>'' = write_flg flg f \<sigma>' in
\<sigma>'')"
| "exec_learned_instr' _ i \<sigma> = undefined"
definition write_pflag :: "instr \<Rightarrow> BV_var \<Rightarrow> state \<Rightarrow> state"
where "write_pflag i op1 \<sigma> \<equiv>
let' op1 = resolve_BV_Var i op1 ;
(a,s) = exec_chum_bv_get \<sigma> i op1 in
write_flg flag_pf (parity a) \<sigma>"
lemma parity_ucast[simp]:
fixes a :: "'b::len0 word"
assumes "LENGTH('a) > LENGTH('b)"
and "LENGTH('b) \<ge> 8"
shows "parity (ucast a :: 'a::len0 word) = parity a"
using assms
unfolding parity_def
by (auto simp add: to_bl_ucast)
definition get_semantics :: "instr \<Rightarrow> state \<Rightarrow> state"
where
"get_semantics insr \<equiv>
let' (fam,n,o_sig) = Get_Instr_Sig insr;
family_list = instr_semantics semantics fam;
manual = (family_list = None);
variant_list = (if manual then None else the family_list n);
manual = (variant_list = None);
bv_formula = (if manual then None else the variant_list o_sig);
manual = (bv_formula = None);
exec = (if manual then manual_exec_instr insr else exec_learned_instr' (the bv_formula) insr);
exec' = (if writes_pflag (the bv_formula) then (write_pflag insr (get_OP1 (the bv_formula)) o exec) else exec) in
exec'"
abbreviation "read_mem \<sigma> s a \<equiv> fst (read_memory l \<alpha> \<sigma> s a)"
lemma temp[simp]:
fixes \<sigma> :: state
shows "get_semantics (Binary (IS_8088 Sub) (Reg (General ThirtyTwo r32)) (Storage (Memory 32 a))) \<sigma> =
\<sigma>\<lparr>regs := (regs \<sigma>)(r32 := ucast (\<langle>31,0\<rangle>regs \<sigma> r32 - \<langle>31,0\<rangle>(read_mem \<sigma> 32 a):: 32 word)),
flags := (flags \<sigma>)
(flag_pf := parity (\<langle>31,0\<rangle>regs \<sigma> r32 - \<langle>31,0\<rangle>(read_mem \<sigma> 32 a) :: 32 word),
flag_cf := \<not> \<langle>31,0\<rangle>(read_mem \<sigma> 32 a) \<le> (\<langle>31,0\<rangle>regs \<sigma> r32 :: 32 word),
flag_zf := \<langle>31,0\<rangle>regs \<sigma> r32 = (\<langle>31,0\<rangle>(read_mem \<sigma> 32 a) :: 32 word),
flag_sf := sint (\<langle>31,0\<rangle>regs \<sigma> r32 - \<langle>31,0\<rangle>(read_mem \<sigma> 32 a) :: 32 word) < 0,
flag_of := (\<not> read_mem \<sigma> 32 a !! 31) = regs \<sigma> r32 !! 31 \<and> read_mem \<sigma> 32 a !! 31 = (sint (\<langle>31,0\<rangle>regs \<sigma> r32 - \<langle>31,0\<rangle>(read_mem \<sigma> 32 a) :: 32 word) < 0))\<rparr>"
apply (subst get_semantics_def)
apply (rewrite_one_let')
apply (rewrite_one_let')
apply (rewrite_one_let')
apply (rewrite_one_let' add: semantics_def)
apply (rewrite_one_let')
apply (rewrite_one_let')
apply (rewrite_one_let')
apply (rewrite_one_let')
apply (rewrite_one_let')+
apply (rewrite_one_let' add: write_pflag_def)+
by (simp add: write_pflag_def simp_rules nth_ucast test_bit_of_take_bits)
end
end
|
#Objetivo1: resolver el tema de los NAs y si se debe ordenar ascendente o descendente
#Objetivo2: aplicar a todas las variables
#limpio la memoria
rm(list=ls())
gc()
library("data.table")
#cargo los datos
dataset <- fread("201902.txt")
#creo una clase que se 1 cuando es BAJA+2 , y 0 en caso contrario
#esto me simplifica las cuentas
dataset[ , clase01:= as.numeric(clase_ternaria=="BAJA+2") ]
#creo una variable azar que me va a ser util
#inicializo el generador de numeros aleatorios
set.seed( 102191 )
dataset[ , azar := runif(nrow(dataset)) ]
#calculos basicos
universo <- nrow(dataset )
pos_total <- sum(dataset$clase01 )
neg_total <- universo - pos_total
#-------------------------------------------------------------
# Creo una funcion para automatizar
graficar_init = function()
{
#calculos basicos
universo <- nrow(dataset )
pos_total <- sum(dataset$clase01 )
neg_total <- universo - pos_total
#la diagonal
azar_neg <- c( 0, neg_total )
azar_pos <- c( 0, pos_total )
#grafico
plot( azar_neg,
azar_pos,
type="n",
main=paste( "ROC Curve" ),
xlab="neg",
ylab="pos",
pch=19)
lines( azar_neg, azar_pos, type="l" , col="black", lwd=2)
}
#----------------------
columna_graficar = function(dataset, pcolumna )
{
#calculos basicos
universo <- nrow(dataset )
pos_total <- sum(dataset$clase01 )
neg_total <- universo - pos_total
#ordeno por <pcolumna, azar>
univar <- dataset[ order(get(pcolumna), na.last=FALSE, azar), c("clase01", pcolumna), with=FALSE]
neg_acum <- cumsum( 1- univar$clase01 )
pos_acum <- cumsum( univar$clase01 )
lines( neg_acum, pos_acum, type="l" , col="red", lwd=2)
AUC_vector <- ( pos_acum*neg_acum + (pos_acum+pos_total)*(neg_total-neg_acum) ) / (2*pos_total*neg_total)
return( list( "variable"= pcolumna,
"valor" = univar[ which.max( AUC_vector ), get(pcolumna)],
"AUC_max" = max( AUC_vector)
) )
}
#----------------------
graficar_init()
columna_graficar( dataset, "Visa_cuenta_estado" )
#Los primeros son los = Na's
#La gran linea que luego cruza el azar es = 10
#La ultima peque?a linea que sube hasta el (1,1) son los { 11, 12, 19 }
columna_metricas = function(pcolumna, dataset)
{
#calculos basicos
universo <- nrow(dataset )
pos_total <- sum(dataset$clase01 )
neg_total <- universo - pos_total
pos_na <- sum( dataset[ is.na( get(pcolumna) ), clase01 ], na.rm=TRUE )
neg_na <- sum( 1- dataset[ is.na( get(pcolumna) ), clase01 ], na.rm=TRUE )
va_ultimo <- pos_na/( pos_na + neg_na + 1 ) < pos_total/neg_total
#ordeno creciente por <pcolumna, azar>
univar <- dataset[ order(get(pcolumna), na.last=va_ultimo, azar), c("clase01", pcolumna), with=FALSE]
neg_acum <- cumsum( 1- univar$clase01 )
pos_acum <- cumsum( univar$clase01 )
gan_acum <- 19500*pos_acum - 500*neg_acum
AUC_vector <- ( pos_acum*neg_acum + (pos_acum+pos_total)*(neg_total-neg_acum) ) / (2*pos_total*neg_total)
AUC_creciente_max <- max( AUC_vector)
gan_creciente_max <- max( gan_acum )
#ordeno DEcreciente por <pcolumna, azar>
univar <- dataset[ order(-get(pcolumna), na.last=va_ultimo, azar), c("clase01", pcolumna), with=FALSE]
neg_acum <- cumsum( 1- univar$clase01 )
pos_acum <- cumsum( univar$clase01 )
gan_acum <- 19500*pos_acum - 500*neg_acum
AUC_vector <- ( pos_acum*neg_acum + (pos_acum+pos_total)*(neg_total-neg_acum) ) / (2*pos_total*neg_total)
AUC_decreciente_max <- max( AUC_vector)
gan_decreciente_max <- max( gan_acum )
return( list( "columna" = pcolumna,
"AUC_max" = pmax( AUC_creciente_max, AUC_decreciente_max) ,
"gan_max" = pmax( gan_creciente_max, gan_decreciente_max)
)
)
}
#----------------------
columna_metricas( "mcuentas_saldo", dataset )
metricas <- lapply( colnames( dataset) , columna_metricas, dataset )
metricas <- rbindlist( metricas )
metricas <- metricas[ order( -AUC_max ), ]
metricas[ 1:10, ]
metricas <- metricas[ order( -gan_max ), ]
metricas[ 1:10, ]
columna_metricas( "ttarjeta_visa", dataset )
#------------------------------------------
columna_graficar_ganancia_n = function(dataset, pcolumna, pcantidad )
{
#calculos basicos
universo <- nrow(dataset )
pos_total <- sum(dataset$clase01 )
neg_total <- universo - pos_total
#ordeno por <pcolumna, azar>
univar <- dataset[ order(get(pcolumna), na.last=FALSE, azar), c("clase01", pcolumna), with=FALSE]
#acumulo positivos y negativos, operacion vectorial
neg_acum <- cumsum( 1- univar$clase01 )
pos_acum <- cumsum( univar$clase01 )
gan_acum <- 19500*pos_acum - 500*neg_acum
#grafico
plot( seq(pcantidad),
gan_acum[1:pcantidad],
type="n",
main=paste( "Ganancia ordenado por", pcolumna ),
xlab="registros",
ylab="Ganancia",
pch=19)
lines( seq(pcantidad), gan_acum[1:pcantidad], type="l" , col="blue", lwd=2)
return( list( "variable"= pcolumna,
"valor" = univar[ which.max( gan_acum ), get(pcolumna)],
"gan_max" = max( gan_acum),
"regis" = which.max( gan_acum )
)
)
}
#---------------------
columna_graficar_ganancia_n( dataset, "tmovimientos_ultimos90dias", 35000 )
columna_graficar_ganancia_n( dataset, "mcuentas_saldo", 1275.59 )
#Y ahora la tabla de contingencia
ftable(dataset[ tmovimientos_ultimos90dias <= 20, clase_ternaria])
ftable(dataset[ tmovimientos_ultimos90dias > 20, clase_ternaria])
|
State Before: 𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p₁ p₂ : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
⊢ ContinuousMultilinearMap.prod (p₁ + p₂).fst (p₁ + p₂).snd =
ContinuousMultilinearMap.prod p₁.fst p₁.snd + ContinuousMultilinearMap.prod p₂.fst p₂.snd State After: case H
𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p₁ p₂ : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
m : (i : ι) → E i
⊢ ↑(ContinuousMultilinearMap.prod (p₁ + p₂).fst (p₁ + p₂).snd) m =
↑(ContinuousMultilinearMap.prod p₁.fst p₁.snd + ContinuousMultilinearMap.prod p₂.fst p₂.snd) m Tactic: ext1 m State Before: case H
𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p₁ p₂ : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
m : (i : ι) → E i
⊢ ↑(ContinuousMultilinearMap.prod (p₁ + p₂).fst (p₁ + p₂).snd) m =
↑(ContinuousMultilinearMap.prod p₁.fst p₁.snd + ContinuousMultilinearMap.prod p₂.fst p₂.snd) m State After: no goals Tactic: rfl State Before: 𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
c : 𝕜
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
⊢ ContinuousMultilinearMap.prod (c • p).fst (c • p).snd = c • ContinuousMultilinearMap.prod p.fst p.snd State After: case H
𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
c : 𝕜
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
m : (i : ι) → E i
⊢ ↑(ContinuousMultilinearMap.prod (c • p).fst (c • p).snd) m = ↑(c • ContinuousMultilinearMap.prod p.fst p.snd) m Tactic: ext1 m State Before: case H
𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
c : 𝕜
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
m : (i : ι) → E i
⊢ ↑(ContinuousMultilinearMap.prod (c • p).fst (c • p).snd) m = ↑(c • ContinuousMultilinearMap.prod p.fst p.snd) m State After: no goals Tactic: rfl State Before: 𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
⊢ ‖ContinuousMultilinearMap.prod p.fst p.snd‖ ≤ 1 * ‖p‖ State After: 𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
⊢ ‖ContinuousMultilinearMap.prod p.fst p.snd‖ ≤ ‖p‖ Tactic: rw [one_mul] State Before: 𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
⊢ ‖ContinuousMultilinearMap.prod p.fst p.snd‖ ≤ ‖p‖ State After: 𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
⊢ ∀ (m : (i : ι) → E i), ‖↑(ContinuousMultilinearMap.prod p.fst p.snd) m‖ ≤ ‖p‖ * ∏ i : ι, ‖m i‖ Tactic: apply ContinuousMultilinearMap.op_norm_le_bound _ (norm_nonneg _) _ State Before: 𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
⊢ ∀ (m : (i : ι) → E i), ‖↑(ContinuousMultilinearMap.prod p.fst p.snd) m‖ ≤ ‖p‖ * ∏ i : ι, ‖m i‖ State After: 𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
m : (i : ι) → E i
⊢ ‖↑(ContinuousMultilinearMap.prod p.fst p.snd) m‖ ≤ ‖p‖ * ∏ i : ι, ‖m i‖ Tactic: intro m State Before: 𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
m : (i : ι) → E i
⊢ ‖↑(ContinuousMultilinearMap.prod p.fst p.snd) m‖ ≤ ‖p‖ * ∏ i : ι, ‖m i‖ State After: 𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
m : (i : ι) → E i
⊢ ‖(↑p.fst m, ↑p.snd m).fst‖ ≤ ‖p‖ * ∏ i : ι, ‖m i‖ ∧ ‖(↑p.fst m, ↑p.snd m).snd‖ ≤ ‖p‖ * ∏ i : ι, ‖m i‖ Tactic: rw [ContinuousMultilinearMap.prod_apply, norm_prod_le_iff] State Before: 𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
m : (i : ι) → E i
⊢ ‖(↑p.fst m, ↑p.snd m).fst‖ ≤ ‖p‖ * ∏ i : ι, ‖m i‖ ∧ ‖(↑p.fst m, ↑p.snd m).snd‖ ≤ ‖p‖ * ∏ i : ι, ‖m i‖ State After: case left
𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
m : (i : ι) → E i
⊢ ‖(↑p.fst m, ↑p.snd m).fst‖ ≤ ‖p‖ * ∏ i : ι, ‖m i‖
case right
𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
m : (i : ι) → E i
⊢ ‖(↑p.fst m, ↑p.snd m).snd‖ ≤ ‖p‖ * ∏ i : ι, ‖m i‖ Tactic: constructor State Before: case left
𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
m : (i : ι) → E i
⊢ ‖(↑p.fst m, ↑p.snd m).fst‖ ≤ ‖p‖ * ∏ i : ι, ‖m i‖ State After: no goals Tactic: exact (p.1.le_op_norm m).trans (mul_le_mul_of_nonneg_right (norm_fst_le p)
(Finset.prod_nonneg fun i _ => norm_nonneg _)) State Before: case right
𝕜 : Type u_2
inst✝⁹ : NontriviallyNormedField 𝕜
E✝ : Type ?u.71705
inst✝⁸ : NormedAddCommGroup E✝
inst✝⁷ : NormedSpace 𝕜 E✝
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
ι : Type u_5
inst✝² : Fintype ι
E : ι → Type u_1
inst✝¹ : (i : ι) → NormedAddCommGroup (E i)
inst✝ : (i : ι) → NormedSpace 𝕜 (E i)
p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G
m : (i : ι) → E i
⊢ ‖(↑p.fst m, ↑p.snd m).snd‖ ≤ ‖p‖ * ∏ i : ι, ‖m i‖ State After: no goals Tactic: exact (p.2.le_op_norm m).trans (mul_le_mul_of_nonneg_right (norm_snd_le p)
(Finset.prod_nonneg fun i _ => norm_nonneg _)) |
import tactic
import data.real.basic
example: ∀ x : ℝ, ∃ y : ℝ, x + y > 0 :=
begin
intro x,
use 64-x,
simp,
norm_num,
end
-- ∃ y : ℝ, ∀ x : ℝ, x + y > 0 :=
-- Is not true, as we can prove the opposite.
example: ¬ (∃ y : ℝ, ∀ x : ℝ, x + y > 0) :=
begin
push_neg,
intro y,
use -73 - y,
simp,
norm_num,
end
variable (α : Type)
-- P is a predicate of α so it is a function that assigns a true-false for each x : alpha.
example : (α → Prop) ≃ set α :=
{ to_fun := λ P, {x : α | P x},
inv_fun := λ X, λ a, a ∈ X,
left_inv:= begin
intro P,
dsimp,
refl,
end
,
right_inv := begin
intro P,
dsimp,
refl,
end
} |
[STATEMENT]
lemma exists_no_Fvars: "\<exists> \<phi>. \<phi> \<in> fmla \<and> prv \<phi> \<and> Fvars \<phi> = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<exists>\<phi>. \<phi> \<in> fmla \<and> prv \<phi> \<and> Fvars \<phi> = {}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<exists>\<phi>. \<phi> \<in> fmla \<and> prv \<phi> \<and> Fvars \<phi> = {}
[PROOF STEP]
obtain n where [simp]: "n \<in> num"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<And>n. n \<in> num \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using numNE
[PROOF STATE]
proof (prove)
using this:
num \<noteq> {}
goal (1 subgoal):
1. (\<And>n. n \<in> num \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n \<in> num
goal (1 subgoal):
1. \<exists>\<phi>. \<phi> \<in> fmla \<and> prv \<phi> \<and> Fvars \<phi> = {}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<exists>\<phi>. \<phi> \<in> fmla \<and> prv \<phi> \<and> Fvars \<phi> = {}
[PROOF STEP]
by (intro exI[of _ "imp (eql n n) (eql n n)"]) (simp add: prv_imp_refl)
[PROOF STATE]
proof (state)
this:
\<exists>\<phi>. \<phi> \<in> fmla \<and> prv \<phi> \<and> Fvars \<phi> = {}
goal:
No subgoals!
[PROOF STEP]
qed |
module Computability.Enumeration.Diagonal where
open import Computability.Prelude
open import Computability.Function
open import Computability.Data.Fin.Opposite
open import Computability.Data.Nat.Iteration
open import Computability.Enumeration.Base
open import Data.Nat using (_∸_; pred; ⌊_/2⌋; _≤_; _<_; s≤s; z≤n)
open import Data.Nat.Properties using (+-suc; +-assoc; +-comm; +-identityʳ)
open import Data.Nat.Properties using (*-suc; *-assoc; *-comm; *-zeroʳ)
open import Data.Nat.Properties using (≤-step)
open import Data.Fin using (Fin; zero; suc; inject₁; fromℕ; fromℕ<; toℕ; opposite)
open import Data.Fin.Properties using (toℕ<n; toℕ-fromℕ; toℕ-inject₁; fromℕ<-toℕ)
open import Relation.Binary.PropositionalEquality using (_≢_; cong; sym)
open Relation.Binary.PropositionalEquality.≡-Reasoning
Diagonal : Set
Diagonal = Σ[ k ∈ ℕ ] Fin (suc k)
step-Diag : Diagonal → Diagonal
step-Diag (k , zero) = suc k , fromℕ (suc k)
step-Diag (k , suc i) = k , inject₁ i
triangle : ℕ → ℕ
triangle k = ⌊ suc k * k /2⌋
enum-Diag : ℕ → Diagonal
enum-Diag n = iterate step-Diag n (zero , zero)
code-Diag : Diagonal → ℕ
code-Diag (k , i) = toℕ (opposite i) + triangle k
module TriangleProperties where
elim-⌊/2⌋ : ∀ k i → ⌊ i * 2 + k /2⌋ ≡ i + ⌊ k /2⌋
elim-⌊/2⌋ k zero = refl
elim-⌊/2⌋ k (suc i) rewrite elim-⌊/2⌋ k i = refl
rewrite-triangle : (k : ℕ) → suc (k + suc (k + k * suc k)) ≡ suc k * 2 + (k + k * k)
rewrite-triangle k
rewrite *-comm k (suc k)
| +-suc k (k + (k + k * k))
| *-comm k 2
| +-identityʳ k
| +-assoc k k (k + k * k) = refl
triangle-relation : ∀ k → triangle (suc k) ≡ suc k + triangle k
triangle-relation k =
begin
⌊ suc (suc k) * suc k /2⌋
≡⟨ cong ⌊_/2⌋ (rewrite-triangle k) ⟩
⌊ suc k * 2 + suc k * k /2⌋
≡⟨ elim-⌊/2⌋ (suc k * k) (suc k) ⟩
suc k + ⌊ suc k * k /2⌋
∎
open TriangleProperties
step-Diag-suc : ∀ d → code-Diag (step-Diag d) ≡ suc (code-Diag d)
step-Diag-suc (k , zero)
rewrite opposite-fromℕ k
| toℕ-fromℕ k
| triangle-relation k = refl
step-Diag-suc (k , suc i)
rewrite opposite-inject₁-suc i
| toℕ-inject₁ (opposite i) = refl
code-Diag-LInv : ∀ n → code-Diag (enum-Diag n) ≡ n
code-Diag-LInv zero = refl
code-Diag-LInv (suc n) =
begin
code-Diag (step-Diag (enum-Diag n))
≡⟨ step-Diag-suc (enum-Diag n) ⟩
suc (code-Diag (enum-Diag n))
≡⟨ cong suc (code-Diag-LInv n) ⟩
suc n
∎
enum-Diag-Fin-Order : ∀ k i → (lt : i < suc k) → iterate step-Diag i (k , fromℕ k) ≡ (k , opposite (fromℕ< lt))
enum-Diag-Fin-Order k zero lt = refl
enum-Diag-Fin-Order k (suc i) (s≤s lt)
rewrite enum-Diag-Fin-Order k i (≤-step lt)
| opposite-fromℕ< i k lt = refl
enum-Diag-Fin : ∀ k (i : Fin (suc k)) → iterate step-Diag (toℕ i) (k , fromℕ k) ≡ (k , opposite i)
enum-Diag-Fin k i =
begin
iterate step-Diag (toℕ i) (k , fromℕ k)
≡⟨ enum-Diag-Fin-Order k (toℕ i) (toℕ<n i)⟩
(k , opposite (fromℕ< (toℕ<n i)))
≡⟨ cong (λ e → k , opposite e) (fromℕ<-toℕ i (toℕ<n i)) ⟩
(k , opposite i)
∎
enum-Diag-triangle : ∀ k → enum-Diag (triangle k) ≡ (k , fromℕ k)
enum-Diag-triangle zero = refl
enum-Diag-triangle (suc k) =
begin
enum-Diag (triangle (suc k))
≡⟨ cong enum-Diag (triangle-relation k) ⟩
enum-Diag (suc k + triangle k)
≡⟨ split-iterate step-Diag (zero , zero) (suc k) (triangle k) ⟩
iterate step-Diag (suc k) (enum-Diag (triangle k))
≡⟨ cong (iterate step-Diag (suc k)) (enum-Diag-triangle k) ⟩
iterate step-Diag (suc k) (k , fromℕ k)
≡⟨ sym (cong (λ e → iterate step-Diag (suc e) (k , fromℕ k)) (toℕ-fromℕ k)) ⟩
iterate step-Diag (suc (toℕ (fromℕ k))) (k , fromℕ k)
≡⟨ cong step-Diag (enum-Diag-Fin k (fromℕ k)) ⟩
step-Diag (k , opposite (fromℕ k))
≡⟨ cong (λ e → step-Diag (k , e)) (opposite-fromℕ k) ⟩
step-Diag (k , zero)
∎
code-Diag-RInv : ∀ d → enum-Diag (code-Diag d) ≡ d
code-Diag-RInv (k , i) =
begin
enum-Diag (toℕ (opposite i) + triangle k)
≡⟨ split-iterate step-Diag (zero , zero) (toℕ (opposite i)) (triangle k) ⟩
iterate step-Diag (toℕ (opposite i)) (enum-Diag (triangle k))
≡⟨ cong (iterate step-Diag (toℕ (opposite i))) (enum-Diag-triangle k) ⟩
iterate step-Diag (toℕ (opposite i)) (k , fromℕ k)
≡⟨ enum-Diag-Fin k (opposite i) ⟩
k , opposite (opposite i)
≡⟨ cong (λ e → k , e) (opposite-opposite i) ⟩
k , i
∎
open Enumerable
Diag-Enumerable : Enumerable Diagonal
enum Diag-Enumerable = enum-Diag
proj₁ (bijective Diag-Enumerable) {x = n₀} {y = n₁} eq =
begin
n₀
≡⟨ sym (code-Diag-LInv n₀) ⟩
code-Diag (enum-Diag n₀)
≡⟨ cong code-Diag eq ⟩
code-Diag (enum-Diag n₁)
≡⟨ code-Diag-LInv n₁ ⟩
n₁
∎
proj₁ (proj₂ (bijective Diag-Enumerable) d) = code-Diag d
proj₂ (proj₂ (bijective Diag-Enumerable) d) = code-Diag-RInv d
|
export POP!, PUSH!, COPYPUSH!, COPYPOP!, GLOBAL_STACK
const GLOBAL_STACK = []
############# global stack operations ##########
@inline function PUSH!(x)
push!(GLOBAL_STACK, x)
_zero(x)
end
@inline function POP!(x::T) where T
NiLangCore.deanc(x, _zero(x))
loaddata(T, pop!(GLOBAL_STACK))
end
UNSAFE_PUSH!(args...) = PUSH!(args...)
@inline function UNSAFE_POP!(x::T) where T
loaddata(T, pop!(GLOBAL_STACK))
end
############# local stack operations ##########
@inline function PUSH!(stack, x::T) where T
push!(stack, x)
stack, _zero(T)
end
@inline function POP!(stack, x::T) where T
NiLangCore.deanc(x, _zero(T))
stack, loaddata(T, pop!(stack))
end
@inline function UNSAFE_POP!(stack, x::T) where T
stack, loaddata(T, pop!(stack))
end
loaddata(::Type{T}, x::T) where T = x
@dual POP! PUSH!
@dual UNSAFE_POP! UNSAFE_PUSH!
############# copied push/pop stack operations ##########
@inline function COPYPUSH!(stack, x)
push!(stack, copy(x))
stack, x
end
@inline function COPYPOP!(stack, x)
y = pop!(stack)
NiLangCore.deanc(x, y)
stack, y
end
UNSAFE_COPYPUSH!(args...) = COPYPUSH!(args...)
@inline function UNSAFE_COPYPOP!(stack, x::XT) where XT
y = pop!(stack)
stack, convert(XT, y)
end
@inline function COPYPUSH!(x)
push!(GLOBAL_STACK, x)
x
end
@inline function COPYPOP!(x::XT) where XT
y = pop!(GLOBAL_STACK)
NiLangCore.deanc(x, y)
convert(XT, y)
end
@inline function UNSAFE_COPYPOP!(x)
y = pop!(GLOBAL_STACK)
y
end
@dual COPYPOP! COPYPUSH!
@dual UNSAFE_COPYPOP! UNSAFE_COPYPUSH!
loaddata(::Type{T}, x::TX) where {T<:NullType, TX} = T(x)
|
theorem split_inside_simple_closed_curve: fixes c :: "real \<Rightarrow> complex" assumes "simple_path c1" and c1: "pathstart c1 = a" "pathfinish c1 = b" and "simple_path c2" and c2: "pathstart c2 = a" "pathfinish c2 = b" and "simple_path c" and c: "pathstart c = a" "pathfinish c = b" and "a \<noteq> b" and c1c2: "path_image c1 \<inter> path_image c2 = {a,b}" and c1c: "path_image c1 \<inter> path_image c = {a,b}" and c2c: "path_image c2 \<inter> path_image c = {a,b}" and ne_12: "path_image c \<inter> inside(path_image c1 \<union> path_image c2) \<noteq> {}" obtains "inside(path_image c1 \<union> path_image c) \<inter> inside(path_image c2 \<union> path_image c) = {}" "inside(path_image c1 \<union> path_image c) \<union> inside(path_image c2 \<union> path_image c) \<union> (path_image c - {a,b}) = inside(path_image c1 \<union> path_image c2)" |
A = rand(3, 3)
B = ones(4, 4)
C = randn(5, 6)
K = A ⊗ B
X = collect(K)
v = rand(12)
K3 = A ⊗ B ⊗ C
@testset "vectrick" begin
@testset "Vec trick" begin
@test K * v ≈ X * v
V = rand(4, 3)
@test K * vec(V) ≈ X * vec(V)
@test_throws DimensionMismatch K * V
@test_throws DimensionMismatch K * reshape(V, 2, 6)
v3 = randn(size(K3, 2))
@test K3 * v3 ≈ collect(K3) * v3
u = similar(v)
@test mul!(u, K, v) ≈ X * v
end
@testset "Reshaped vec trick" begin
@test K * v ≈ X * v
V = sprand(4, 3, 1.0)
@test K * vec(V) ≈ X * vec(V)
@test_throws DimensionMismatch K * V
@test_throws DimensionMismatch K * reshape(V, 2, 6)
K3 = A ⊗ B ⊗ C
v3 = sprand(size(K3, 2),1.0)
@test K3 * vec(v3) ≈ collect(K3) * v3
u = similar(v)
@test mul!(u, K, v) ≈ X * v
end
@testset "AbstractKroneckerProduct * AbstractMatrix" begin
rng = MersenneTwister(123456)
a, b, x = randn(rng, 30, 20), randn(rng, 40, 50), randn(rng, 1000, 1100)
@test kron(a, Diagonal(ones(50))) * x ≈ Kronecker.kron_a_id(a, x)
@test kron(Diagonal(ones(20)), b) * x ≈ Kronecker.kron_id_a(b, x)
@test kron(a, b) * x ≈ Kronecker.kron_a_b(a, b, x)
@test kron(a, b) * x ≈ (a ⊗ b) * x
@test kron(a, Eye(50)) * x ≈ (a ⊗ Eye(50)) * x
@test kron(Eye(20), b) * x ≈ (Eye(20) ⊗ b) * x
end
@testset "sum" begin
@test sum(K) ≈ sum(X)
@test sum(K3) ≈ sum(collect(K3))
@test sum(K, dims=1) ≈ sum(X, dims=1)
@test sum(K3, dims=2) ≈ sum(collect(K3), dims=2)
@test sum(K3, dims=2) isa AbstractKroneckerProduct
@test sum(kronecker(A, 3)) ≈ sum(kron(A, A, A))
end
end
|
function sout = cvx_profile( flag )
% CVX_PROFILE CVX-specific profiler control.
% This is a function used for internal CVX development to help determine
% performance limits within the CVX code itself, by turning off the profiler
% when the solver is being called. End users will likely not find this
% function to be useful.
global cvx___
cvx_global
s = cvx___.profile;
if nargin == 1,
if isnumeric(flag) || islogical(flag),
ns = double(flag) ~= 0;
elseif ischar(flag) && size(flag,1) == 1,
switch lower(flag),
case 'true',
ns = true;
case 'false',
ns = false;
otherwise,
error( 'String arugment must be ''true'' or ''false''.' );
end
else
error( 'Argument must be a numeric scalar or a string.' );
end
if cvx___.profile ~= ns,
cvx___.profile = ns;
stat = profile('status');
if ns && ~isempty( cvx___.problems ) && ~isequal( stat.ProfilerStatus, 'on' ),
profile on
elseif ~ns && isequal( stat.ProfilerStatus, 'on' ),
profile off
end
end
end
if nargin == 0 || nargout > 0,
sout = s;
end
% Copyright 2010 Michael C. Grant and Stephen P. Boyd.
% See the file COPYING.txt for full copyright information.
% The command 'cvx_where' will show where this file is located.
|
State Before: 𝕜 : Type u_3
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_1
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_2
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.1385368
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.1385463
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
c : F
⊢ (fderiv 𝕜 fun x => c) = 0 State After: case h.h
𝕜 : Type u_3
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_1
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_2
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.1385368
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.1385463
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
c : F
m x✝ : E
⊢ ↑(fderiv 𝕜 (fun x => c) m) x✝ = ↑(OfNat.ofNat 0 m) x✝ Tactic: ext m State Before: case h.h
𝕜 : Type u_3
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_1
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_2
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.1385368
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.1385463
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
c : F
m x✝ : E
⊢ ↑(fderiv 𝕜 (fun x => c) m) x✝ = ↑(OfNat.ofNat 0 m) x✝ State After: case h.h
𝕜 : Type u_3
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_1
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_2
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.1385368
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.1385463
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
c : F
m x✝ : E
⊢ ↑0 x✝ = ↑(OfNat.ofNat 0 m) x✝ Tactic: rw [fderiv_const_apply] State Before: case h.h
𝕜 : Type u_3
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_1
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_2
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type ?u.1385368
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type ?u.1385463
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
c : F
m x✝ : E
⊢ ↑0 x✝ = ↑(OfNat.ofNat 0 m) x✝ State After: no goals Tactic: rfl |
.fp \np mr
.lg 0
.tr `'
|
module EqTest where
import Common.Level
open import Common.Maybe
open import Common.Equality
data ℕ : Set where
zero : ℕ
suc : ℕ -> ℕ
_≟_ : (x y : ℕ) -> Maybe (x ≡ y)
suc m ≟ suc n with m ≟ n
suc .n ≟ suc n | just refl = just refl
suc m ≟ suc n | nothing = nothing
zero ≟ suc _ = nothing
suc m ≟ zero = nothing
zero ≟ zero = just refl
|
module Esterel.Variable.Sequential where
open import Data.Nat
using (ℕ) renaming (_≟_ to _≟ℕ_)
open import Function
using (_∘_)
open import Relation.Nullary
using (Dec ; yes ; no ; ¬_)
open import Relation.Binary
using (Decidable)
open import Relation.Binary.PropositionalEquality
using (_≡_ ; refl ; cong ; trans ; sym)
data SeqVar : Set where
_ᵥ : ℕ → SeqVar
unwrap : SeqVar → ℕ
unwrap (n ᵥ) = n
unwrap-inverse : ∀ {s} → (unwrap s) ᵥ ≡ s
unwrap-inverse {_ ᵥ} = refl
unwrap-injective : ∀ {s t} → unwrap s ≡ unwrap t → s ≡ t
unwrap-injective s'≡t' = trans (sym unwrap-inverse) (trans (cong _ᵥ s'≡t') unwrap-inverse)
-- for backward compatibility
unwrap-neq : ∀{k1 : SeqVar} → ∀{k2 : SeqVar} → ¬ k1 ≡ k2 → ¬ (unwrap k1) ≡ (unwrap k2)
unwrap-neq = (_∘ unwrap-injective)
wrap : ℕ → SeqVar
wrap = _ᵥ
bijective : ∀{x} → unwrap (wrap x) ≡ x
bijective = refl
_≟_ : Decidable {A = SeqVar} _≡_
(s ᵥ) ≟ (t ᵥ) with s ≟ℕ t
... | yes p = yes (cong _ᵥ p)
... | no ¬p = no (¬p ∘ cong unwrap)
|
------------------------------------------------------------------------
-- The torus, defined as a HIT
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --safe #-}
-- This module is based on the discussion of the torus in the HoTT
-- book.
-- The module is parametrised by a notion of equality. The higher
-- constructors of the HIT defining the torus use path equality, but
-- the supplied notion of equality is used for many other things.
import Equality.Path as P
module Torus
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
open P.Derived-definitions-and-properties eq hiding (elim)
open import Prelude
open import Bijection equality-with-J using (_↔_)
open import Equality.Path.Isomorphisms eq
open import Circle eq as Circle using (𝕊¹; base; loopᴾ)
private
variable
a p : Level
A : Type a
P : A → Type p
------------------------------------------------------------------------
-- The torus
mutual
-- The torus.
data T² : Type where
base hub : T²
loop₁ᴾ loop₂ᴾ : base P.≡ base
spokeᴾ : (x : 𝕊¹) → rimᴾ x P.≡ hub
private
-- A synonym used to work around an Agda restriction.
base′ = base
-- A function used to define the spoke constructor.
--
-- Note that this function is defined using Circle.recᴾ, not
-- Circle.rec.
rimᴾ : 𝕊¹ → T²
rimᴾ = Circle.recᴾ base loop₁₂₋₁₋₂ᴾ
-- A loop.
loop₁₂₋₁₋₂ᴾ : base′ P.≡ base′
loop₁₂₋₁₋₂ᴾ =
base P.≡⟨ loop₁ᴾ ⟩
base P.≡⟨ loop₂ᴾ ⟩
base P.≡⟨ P.sym loop₁ᴾ ⟩
base P.≡⟨ P.sym loop₂ᴾ ⟩∎
base ∎
-- The constructors (and loop₁₂₋₁₋₂ᴾ) expressed using _≡_ instead of
-- paths.
loop₁ : base ≡ base
loop₁ = _↔_.from ≡↔≡ loop₁ᴾ
loop₂ : base ≡ base
loop₂ = _↔_.from ≡↔≡ loop₂ᴾ
loop₁₂₋₁₋₂ : base ≡ base
loop₁₂₋₁₋₂ = _↔_.from ≡↔≡ loop₁₂₋₁₋₂ᴾ
spoke : (x : 𝕊¹) → rimᴾ x ≡ hub
spoke = _↔_.from ≡↔≡ ∘ spokeᴾ
-- A variant of rimᴾ, defined using Circle.rec and loop₁₂₋₁₋₂.
rim : 𝕊¹ → T²
rim = Circle.rec base loop₁₂₋₁₋₂
-- The functions rim and rimᴾ are pointwise equal.
rim≡rimᴾ : ∀ x → rim x ≡ rimᴾ x
rim≡rimᴾ = Circle.elim
_
(refl _)
(subst (λ x → rim x ≡ rimᴾ x) Circle.loop (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩
trans (sym (cong rim Circle.loop))
(trans (refl _) (cong rimᴾ Circle.loop)) ≡⟨ cong (trans _) $ trans-reflˡ _ ⟩
trans (sym (cong rim Circle.loop)) (cong rimᴾ Circle.loop) ≡⟨ cong₂ (trans ∘ sym) Circle.rec-loop lemma ⟩
trans (sym loop₁₂₋₁₋₂) loop₁₂₋₁₋₂ ≡⟨ trans-symˡ _ ⟩∎
refl _ ∎)
where
lemma =
cong rimᴾ Circle.loop ≡⟨ cong≡cong ⟩
_↔_.from ≡↔≡ (P.cong rimᴾ loopᴾ) ≡⟨⟩
_↔_.from ≡↔≡ loop₁₂₋₁₋₂ᴾ ≡⟨⟩
loop₁₂₋₁₋₂ ∎
------------------------------------------------------------------------
-- Eliminators expressed using paths
-- A dependent eliminator, expressed using paths.
record Elimᴾ₀ (P : T² → Type p) : Type p where
no-eta-equality
field
baseʳ : P base
loop₁ʳ : P.[ (λ i → P (loop₁ᴾ i)) ] baseʳ ≡ baseʳ
loop₂ʳ : P.[ (λ i → P (loop₂ᴾ i)) ] baseʳ ≡ baseʳ
-- A dependent path.
loop₁₂₋₁₋₂ʳ : P.[ (λ i → P (loop₁₂₋₁₋₂ᴾ i)) ] baseʳ ≡ baseʳ
loop₁₂₋₁₋₂ʳ =
baseʳ P.≡⟨ loop₁ʳ ⟩[ P ]
baseʳ P.≡⟨ loop₂ʳ ⟩[ P ]
baseʳ P.≡⟨ P.hsym loop₁ʳ ⟩[ P ]
baseʳ P.≡⟨ P.hsym loop₂ʳ ⟩∎h
baseʳ ∎
-- A special case of elimᴾ, used in the type of elimᴾ.
elimᴾ-rimᴾ : (x : 𝕊¹) → P (rimᴾ x)
elimᴾ-rimᴾ = Circle.elimᴾ (P ∘ rimᴾ) baseʳ loop₁₂₋₁₋₂ʳ
record Elimᴾ (P : T² → Type p) : Type p where
no-eta-equality
field
elimᴾ₀ : Elimᴾ₀ P
open Elimᴾ₀ elimᴾ₀ public
field
hubʳ : P hub
spokeʳ : (x : 𝕊¹) → P.[ (λ i → P (spokeᴾ x i)) ] elimᴾ-rimᴾ x ≡ hubʳ
elimᴾ : Elimᴾ P → (x : T²) → P x
elimᴾ {P = P} e = helper
where
module E = Elimᴾ e
helper : (x : T²) → P x
helper = λ where
base → E.baseʳ
hub → E.hubʳ
(loop₁ᴾ i) → E.loop₁ʳ i
(loop₂ᴾ i) → E.loop₂ʳ i
(spokeᴾ base i) → E.spokeʳ base i
(spokeᴾ (loopᴾ j) i) → E.spokeʳ (loopᴾ j) i
-- The special case is a special case.
elimᴾ-rimᴾ≡elimᴾ-rimᴾ :
(e : Elimᴾ P) (x : 𝕊¹) → elimᴾ e (rimᴾ x) ≡ Elimᴾ.elimᴾ-rimᴾ e x
elimᴾ-rimᴾ≡elimᴾ-rimᴾ _ = Circle.elimᴾ _ (refl _) (λ _ → refl _)
-- A non-dependent eliminator, expressed using paths.
Recᴾ : Type a → Type a
Recᴾ A = Elimᴾ (λ _ → A)
recᴾ : Recᴾ A → T² → A
recᴾ = elimᴾ
------------------------------------------------------------------------
-- Eliminators
-- A dependent eliminator.
record Elim (P : T² → Type p) : Type p where
no-eta-equality
field
baseʳ : P base
loop₁ʳ : subst P loop₁ baseʳ ≡ baseʳ
loop₂ʳ : subst P loop₂ baseʳ ≡ baseʳ
-- An instance of Elimᴾ₀ P.
elimᴾ₀ : Elimᴾ₀ P
elimᴾ₀ = λ where
.Elimᴾ₀.baseʳ → baseʳ
.Elimᴾ₀.loop₁ʳ → subst≡→[]≡ loop₁ʳ
.Elimᴾ₀.loop₂ʳ → subst≡→[]≡ loop₂ʳ
-- A special case of elim, used in the type of elim.
elim-rimᴾ : (x : 𝕊¹) → P (rimᴾ x)
elim-rimᴾ = Elimᴾ₀.elimᴾ-rimᴾ elimᴾ₀
field
hubʳ : P hub
spokeʳ : (x : 𝕊¹) → subst P (spoke x) (elim-rimᴾ x) ≡ hubʳ
-- The eliminator.
elim : (x : T²) → P x
elim = elimᴾ λ where
.Elimᴾ.elimᴾ₀ → elimᴾ₀
.Elimᴾ.hubʳ → hubʳ
.Elimᴾ.spokeʳ → subst≡→[]≡ ∘ spokeʳ
-- The special case is a special case.
elim-rimᴾ≡elim-rimᴾ : (x : 𝕊¹) → elim (rimᴾ x) ≡ elim-rimᴾ x
elim-rimᴾ≡elim-rimᴾ = elimᴾ-rimᴾ≡elimᴾ-rimᴾ _
-- A variant of spokeʳ with a slightly different type.
spokeʳ′ : (x : 𝕊¹) → subst P (spoke x) (elim (rimᴾ x)) ≡ hubʳ
spokeʳ′ = Circle.elimᴾ _ (spokeʳ base) (λ i → spokeʳ (loopᴾ i))
-- Computation rules.
elim-loop₁ : dcong elim loop₁ ≡ loop₁ʳ
elim-loop₁ = dcong-subst≡→[]≡ (refl _)
elim-loop₂ : dcong elim loop₂ ≡ loop₂ʳ
elim-loop₂ = dcong-subst≡→[]≡ (refl _)
elim-spoke : (x : 𝕊¹) → dcong elim (spoke x) ≡ spokeʳ′ x
elim-spoke = Circle.elimᴾ _
(dcong-subst≡→[]≡ (refl _))
(λ _ → dcong-subst≡→[]≡ (refl _))
-- A non-dependent eliminator.
record Rec (A : Type a) : Type a where
no-eta-equality
field
baseʳ : A
loop₁ʳ : baseʳ ≡ baseʳ
loop₂ʳ : baseʳ ≡ baseʳ
-- An instance of Elimᴾ₀ P.
elimᴾ₀ : Elimᴾ₀ (λ _ → A)
elimᴾ₀ = λ where
.Elimᴾ₀.baseʳ → baseʳ
.Elimᴾ₀.loop₁ʳ → _↔_.to ≡↔≡ loop₁ʳ
.Elimᴾ₀.loop₂ʳ → _↔_.to ≡↔≡ loop₂ʳ
-- A special case of recᴾ, used in the type of rec.
rec-rimᴾ : 𝕊¹ → A
rec-rimᴾ = Elimᴾ₀.elimᴾ-rimᴾ elimᴾ₀
field
hubʳ : A
spokeʳ : (x : 𝕊¹) → rec-rimᴾ x ≡ hubʳ
-- The eliminator.
rec : T² → A
rec = recᴾ λ where
.Elimᴾ.elimᴾ₀ → elimᴾ₀
.Elimᴾ.hubʳ → hubʳ
.Elimᴾ.spokeʳ → _↔_.to ≡↔≡ ∘ spokeʳ
-- The special case is a special case.
rec-rimᴾ≡rec-rimᴾ : (x : 𝕊¹) → rec (rimᴾ x) ≡ rec-rimᴾ x
rec-rimᴾ≡rec-rimᴾ = elimᴾ-rimᴾ≡elimᴾ-rimᴾ _
-- A variant of spokeʳ with a slightly different type.
spokeʳ′ : (x : 𝕊¹) → rec (rimᴾ x) ≡ hubʳ
spokeʳ′ = Circle.elimᴾ _ (spokeʳ base) (λ i → spokeʳ (loopᴾ i))
-- Computation rules.
rec-loop₁ : cong rec loop₁ ≡ loop₁ʳ
rec-loop₁ = cong-≡↔≡ (refl _)
rec-loop₂ : cong rec loop₂ ≡ loop₂ʳ
rec-loop₂ = cong-≡↔≡ (refl _)
rec-spoke : (x : 𝕊¹) → cong rec (spoke x) ≡ spokeʳ′ x
rec-spoke = Circle.elimᴾ _
(cong-≡↔≡ (refl _))
(λ _ → cong-≡↔≡ (refl _))
------------------------------------------------------------------------
-- Some lemmas
-- The remaining results are not taken from the HoTT book.
-- One can express loop₁₂₋₁₋₂ using loop₁ and loop₂.
loop₁₂₋₁₋₂≡ :
loop₁₂₋₁₋₂ ≡ trans (trans loop₁ loop₂) (sym (trans loop₂ loop₁))
loop₁₂₋₁₋₂≡ =
_↔_.from ≡↔≡ loop₁₂₋₁₋₂ᴾ ≡⟨⟩
_↔_.from ≡↔≡
(P.trans loop₁ᴾ (P.trans loop₂ᴾ
(P.trans (P.sym loop₁ᴾ) (P.sym loop₂ᴾ)))) ≡⟨ sym trans≡trans ⟩
trans loop₁
(_↔_.from ≡↔≡ (P.trans loop₂ᴾ
(P.trans (P.sym loop₁ᴾ) (P.sym loop₂ᴾ)))) ≡⟨ cong (trans _) $ sym trans≡trans ⟩
trans loop₁
(trans loop₂
(_↔_.from ≡↔≡ (P.trans (P.sym loop₁ᴾ) (P.sym loop₂ᴾ)))) ≡⟨ cong (λ eq → trans loop₁ (trans loop₂ eq)) $ sym trans≡trans ⟩
trans loop₁
(trans loop₂
(trans (_↔_.from ≡↔≡ (P.sym loop₁ᴾ))
(_↔_.from ≡↔≡ (P.sym loop₂ᴾ)))) ≡⟨ cong₂ (λ p q → trans loop₁ (trans loop₂ (trans p q)))
(sym sym≡sym)
(sym sym≡sym) ⟩
trans loop₁ (trans loop₂ (trans (sym loop₁) (sym loop₂))) ≡⟨ sym $ trans-assoc _ _ _ ⟩
trans (trans loop₁ loop₂) (trans (sym loop₁) (sym loop₂)) ≡⟨ cong (trans _) $ sym $ sym-trans _ _ ⟩∎
trans (trans loop₁ loop₂) (sym (trans loop₂ loop₁)) ∎
|
__version__ = "0.0.12"
import matplotlib as mpl, pkgutil
from fastai.vision.all import *
from pandas.api.types import CategoricalDtype
from scipy.cluster import hierarchy as hc
from io import StringIO, BytesIO
try: from ipywidgets import widgets
except ModuleNotFoundError: warn("Missing `ipywidgets` - please install it")
try: import sentencepiece
except ModuleNotFoundError: warn("Missing `sentencepiece` - please run `pip install 'sentencepiece<0.1.90'`")
try:
from azure.cognitiveservices.search.imagesearch import ImageSearchClient as api
from msrest.authentication import CognitiveServicesCredentials as auth
except ModuleNotFoundError:
warn("Missing Azure SDK - please run `pip install azure-cognitiveservices-search-imagesearch`")
try: from nbdev.showdoc import *
except ModuleNotFoundError: warn("Missing `nbdev` - please install it")
try:
import graphviz
from sklearn.tree import export_graphviz
except ModuleNotFoundError: warn("Missing `graphviz` - please run `conda install fastbook`")
mpl.rcParams['savefig.dpi']= 200
mpl.rcParams['font.size']=12
set_seed(42)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
pd.set_option('display.max_columns',999)
np.set_printoptions(linewidth=200)
torch.set_printoptions(linewidth=200)
def setup_colab():
"Sets up Colab. First run `!pip install -Uqq fastbook` in a cell"
assert IN_COLAB, "You do not appear to be running in Colab"
global gdrive
gdrive = Path('/content/gdrive/My Drive')
from google.colab import drive
if not gdrive.exists(): drive.mount(str(gdrive.parent))
def setup_book():
if IN_COLAB: return setup_colab()
def gv(s): return graphviz.Source('digraph G{ rankdir="LR"' + s + '; }')
def get_image_files_sorted(path, recurse=True, folders=None):
return get_image_files(path, recurse, folders).sorted()
def search_images_bing(key, term, min_sz=128):
client = api('https://api.cognitive.microsoft.com', auth(key))
return L(client.images.search(query=term, count=150, min_height=min_sz, min_width=min_sz).value)
def plot_function(f, tx=None, ty=None, title=None, min=-2, max=2, figsize=(6,4)):
x = torch.linspace(min,max)
fig,ax = plt.subplots(figsize=figsize)
ax.plot(x,f(x))
if tx is not None: ax.set_xlabel(tx)
if ty is not None: ax.set_ylabel(ty)
if title is not None: ax.set_title(title)
def draw_tree(t, df, size=10, ratio=0.6, precision=0, **kwargs):
s=export_graphviz(t, out_file=None, feature_names=df.columns, filled=True, rounded=True,
special_characters=True, rotate=False, precision=precision, **kwargs)
return graphviz.Source(re.sub('Tree {', f'Tree {{ size={size}; ratio={ratio}', s))
def cluster_columns(df, figsize=(10,6), font_size=12):
corr = np.round(scipy.stats.spearmanr(df).correlation, 4)
corr_condensed = hc.distance.squareform(1-corr)
z = hc.linkage(corr_condensed, method='average')
fig = plt.figure(figsize=figsize)
hc.dendrogram(z, labels=df.columns, orientation='left', leaf_font_size=font_size)
plt.show()
def image_cat (): return BytesIO(pkgutil.get_data('fastbook', 'images/cat.jpg'))
def image_bear(): return BytesIO(pkgutil.get_data('fastbook', 'images/grizzly.jpg'))
|
(*
Copyright (C) 2017 M.A.L. Marques
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)
(* type: mgga_exc *)
(* prefix:
mgga_c_m06l_params *params;
assert(p->params != NULL);
params = (mgga_c_m06l_params * )(p->params);
*)
$include "mgga_c_vsxc.mpl"
$include "mgga_c_m05.mpl"
m06l_f := (rs, z, xs0, xs1, ts0, ts1) ->
+ m05_f(rs, z, xs0, xs1, ts0, ts1)
+ vsxc_f(rs, z, xs0, xs1, ts0, ts1):
f := (rs, z, xt, xs0, xs1, us0, us1, ts0, ts1) ->
m06l_f(rs, z, xs0, xs1, ts0, ts1):
|
[STATEMENT]
lemma subsumeseq_term_size_emv:
assumes "s \<cdot>\<ge> t" and "num_syms s = num_syms t" and "num_funs s = num_funs t"
shows "emv s t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. emv s t
[PROOF STEP]
using assms(1) and subst_size_emv [OF _ assms(2-)]
[PROOF STATE]
proof (prove)
using this:
t \<le>\<cdot> s
s = t \<cdot> ?\<tau> \<Longrightarrow> emv s t
goal (1 subgoal):
1. emv s t
[PROOF STEP]
by (cases) simp |
State Before: P : Type u_1
inst✝¹ : BooleanAlgebra P
x : P
I : Ideal P
inst✝ : IsProper I
h : ∀ {x : P}, x ∈ I ∨ xᶜ ∈ I
⊢ IsPrime I State After: P : Type u_1
inst✝¹ : BooleanAlgebra P
x : P
I : Ideal P
inst✝ : IsProper I
h : ∀ {x : P}, x ∈ I ∨ xᶜ ∈ I
⊢ ∀ {x y : P}, x ⊓ y ∈ I → ¬x ∈ I → y ∈ I Tactic: simp only [isPrime_iff_mem_or_mem, or_iff_not_imp_left] State Before: P : Type u_1
inst✝¹ : BooleanAlgebra P
x : P
I : Ideal P
inst✝ : IsProper I
h : ∀ {x : P}, x ∈ I ∨ xᶜ ∈ I
⊢ ∀ {x y : P}, x ⊓ y ∈ I → ¬x ∈ I → y ∈ I State After: P : Type u_1
inst✝¹ : BooleanAlgebra P
x✝ : P
I : Ideal P
inst✝ : IsProper I
h : ∀ {x : P}, x ∈ I ∨ xᶜ ∈ I
x y : P
hxy : x ⊓ y ∈ I
hxI : ¬x ∈ I
⊢ y ∈ I Tactic: intro x y hxy hxI State Before: P : Type u_1
inst✝¹ : BooleanAlgebra P
x✝ : P
I : Ideal P
inst✝ : IsProper I
h : ∀ {x : P}, x ∈ I ∨ xᶜ ∈ I
x y : P
hxy : x ⊓ y ∈ I
hxI : ¬x ∈ I
⊢ y ∈ I State After: P : Type u_1
inst✝¹ : BooleanAlgebra P
x✝ : P
I : Ideal P
inst✝ : IsProper I
h : ∀ {x : P}, x ∈ I ∨ xᶜ ∈ I
x y : P
hxy : x ⊓ y ∈ I
hxI : ¬x ∈ I
hxcI : xᶜ ∈ I
⊢ y ∈ I Tactic: have hxcI : xᶜ ∈ I := h.resolve_left hxI State Before: P : Type u_1
inst✝¹ : BooleanAlgebra P
x✝ : P
I : Ideal P
inst✝ : IsProper I
h : ∀ {x : P}, x ∈ I ∨ xᶜ ∈ I
x y : P
hxy : x ⊓ y ∈ I
hxI : ¬x ∈ I
hxcI : xᶜ ∈ I
⊢ y ∈ I State After: P : Type u_1
inst✝¹ : BooleanAlgebra P
x✝ : P
I : Ideal P
inst✝ : IsProper I
h : ∀ {x : P}, x ∈ I ∨ xᶜ ∈ I
x y : P
hxy : x ⊓ y ∈ I
hxI : ¬x ∈ I
hxcI : xᶜ ∈ I
ass : x ⊓ y ⊔ y ⊓ xᶜ ∈ I
⊢ y ∈ I Tactic: have ass : x ⊓ y ⊔ y ⊓ xᶜ ∈ I := sup_mem hxy (I.lower inf_le_right hxcI) State Before: P : Type u_1
inst✝¹ : BooleanAlgebra P
x✝ : P
I : Ideal P
inst✝ : IsProper I
h : ∀ {x : P}, x ∈ I ∨ xᶜ ∈ I
x y : P
hxy : x ⊓ y ∈ I
hxI : ¬x ∈ I
hxcI : xᶜ ∈ I
ass : x ⊓ y ⊔ y ⊓ xᶜ ∈ I
⊢ y ∈ I State After: no goals Tactic: rwa [inf_comm, sup_inf_inf_compl] at ass |
From Test Require Import tactic.
Section FOFProblem.
Variable Universe : Set.
Variable UniverseElement : Universe.
Variable wd_ : Universe -> Universe -> Prop.
Variable col_ : Universe -> Universe -> Universe -> Prop.
Variable col_swap1_1 : (forall A B C : Universe, (col_ A B C -> col_ B A C)).
Variable col_swap2_2 : (forall A B C : Universe, (col_ A B C -> col_ B C A)).
Variable col_triv_3 : (forall A B : Universe, col_ A B B).
Variable wd_swap_4 : (forall A B : Universe, (wd_ A B -> wd_ B A)).
Variable col_trans_5 : (forall P Q A B C : Universe, ((wd_ P Q /\ (col_ P Q A /\ (col_ P Q B /\ col_ P Q C))) -> col_ A B C)).
Theorem pipo_6 : (forall O E Eprime A B C Oprime Aprime Bprime Cprime Eprimeprime Bprimeprime C2 C3 : Universe, ((wd_ O E /\ (wd_ Oprime Eprime /\ (wd_ A O /\ (wd_ B O /\ (wd_ C O /\ (wd_ A E /\ (wd_ Eprimeprime O /\ (wd_ O Oprime /\ (wd_ Bprimeprime O /\ (wd_ Bprime Oprime /\ (wd_ Eprimeprime A /\ (wd_ E Eprimeprime /\ (wd_ E Eprime /\ (wd_ O Eprime /\ (wd_ Oprime Eprimeprime /\ (wd_ E Oprime /\ (wd_ C Bprimeprime /\ (wd_ Cprime C3 /\ (wd_ B Bprimeprime /\ (wd_ Bprime C3 /\ (wd_ Eprime C2 /\ (wd_ Aprime C2 /\ (wd_ Oprime Aprime /\ (wd_ A Aprime /\ (wd_ C Cprime /\ (wd_ B Bprime /\ (col_ O E A /\ (col_ O E B /\ (col_ O E C /\ (col_ Oprime Eprime Aprime /\ (col_ Oprime Eprime Bprime /\ (col_ Oprime Eprime Cprime /\ (col_ O Eprimeprime Bprimeprime /\ (col_ O Eprimeprime Oprime /\ (col_ O Eprimeprime C2 /\ (col_ O Eprimeprime C3 /\ col_ O A C)))))))))))))))))))))))))))))))))))) -> col_ Oprime C2 C3)).
Proof.
time tac.
Qed.
End FOFProblem.
|
{-# OPTIONS --universe-polymorphism #-}
module Categories.Bicategory.Helpers where
-- quite a bit of the code below is taken from Categories.2-Category
open import Data.Nat using (_+_)
open import Function using (flip)
open import Data.Product using (_,_; curry)
open import Categories.Category
open import Categories.Categories using (Categories)
import Categories.Functor
open import Categories.Terminal using (OneC; One; unit)
open import Categories.Object.Terminal using (module Terminal)
open import Categories.Bifunctor hiding (identityˡ; identityʳ; assoc) renaming (id to idF; _≡_ to _≡F_; _∘_ to _∘F_)
open import Categories.NaturalIsomorphism
open import Categories.NaturalTransformation using (NaturalTransformation) renaming (_≡_ to _≡ⁿ_; id to idⁿ)
open import Categories.Product using (Product; assocʳ; πˡ; πʳ)
module BicategoryHelperFunctors {o ℓ t e} (Obj : Set o) (_⇒_ : (A B : Obj) → Category ℓ t e)
(—⊗— : {A B C : Obj} → Bifunctor (B ⇒ C) (A ⇒ B) (A ⇒ C))
(id : {A : Obj} → Functor {ℓ} {t} {e} OneC (A ⇒ A)) where
open Terminal (One {ℓ} {t} {e})
_∘_ : {A B C : Obj} {L R : Category ℓ t e} → Functor L (B ⇒ C) → Functor R (A ⇒ B) → Bifunctor L R (A ⇒ C)
_∘_ {A} {B} {C} F G = reduce-× {D₁ = B ⇒ C} {D₂ = A ⇒ B} —⊗— F G
-- convenience!
module _⇒_ (A B : Obj) = Category (A ⇒ B)
open _⇒_ public using () renaming (Obj to _⇒₁_)
private module imp⇒ {X Y : Obj} = Category (X ⇒ Y)
open imp⇒ public using () renaming (_⇒_ to _⇒₂_; id to id₂; _∘_ to _•_; _≡_ to _≡₂_)
id₁ : ∀ {A} → A ⇒₁ A
id₁ {A} = Functor.F₀ (id {A}) unit
id₁₂ : ∀ {A} → id₁ {A} ⇒₂ id₁ {A}
id₁₂ {A} = id₂ {A = id₁ {A}}
infixr 9 _∘₁_
_∘₁_ : ∀ {A B C} → B ⇒₁ C → A ⇒₁ B → A ⇒₁ C
_∘₁_ = curry (Functor.F₀ —⊗—)
-- horizontal composition
infixr 9 _∘₂_
_∘₂_ : ∀ {A B C} {g g′ : B ⇒₁ C} {f f′ : A ⇒₁ B} (β : g ⇒₂ g′) (α : f ⇒₂ f′) → (g ∘₁ f) ⇒₂ (g′ ∘₁ f′)
_∘₂_ = curry (Functor.F₁ —⊗—)
-- left whiskering
infixl 9 _◃_
_◃_ : ∀ {A B C} {g g′ : B ⇒₁ C} → g ⇒₂ g′ → (f : A ⇒₁ B) → (g ∘₁ f) ⇒₂ (g′ ∘₁ f)
β ◃ f = β ∘₂ id₂
-- right whiskering
infixr 9 _▹_
_▹_ : ∀ {A B C} (g : B ⇒₁ C) → {f f′ : A ⇒₁ B} → f ⇒₂ f′ → (g ∘₁ f) ⇒₂ (g ∘₁ f′)
g ▹ α = id₂ ∘₂ α
module Coherence
(identityˡ : {A B : Obj} → NaturalIsomorphism (id ∘ idF {C = A ⇒ B}) (πʳ {C = ⊤} {A ⇒ B}))
(identityʳ : {A B : Obj} → NaturalIsomorphism (idF {C = A ⇒ B} ∘ id) (πˡ {C = A ⇒ B}))
(assoc : {A B C D : Obj} → NaturalIsomorphism (idF ∘ —⊗—) ((—⊗— ∘ idF) ∘F assocʳ (C ⇒ D) (B ⇒ C) (A ⇒ B)) ) where
open Categories.NaturalTransformation.NaturalTransformation
-- left/right are inverted between in certain situations!
-- private so as to not clash with the ones in Bicategory itself
private
ρᵤ : {A B : Obj} (f : A ⇒₁ B) → (id₁ ∘₁ f) ⇒₂ f
ρᵤ f = η (NaturalIsomorphism.F⇒G identityˡ) (unit , f)
λᵤ : {A B : Obj} (f : A ⇒₁ B) → (f ∘₁ id₁) ⇒₂ f
λᵤ f = η (NaturalIsomorphism.F⇒G identityʳ) (f , unit)
α : {A B C D : Obj} (f : A ⇒₁ B) (g : B ⇒₁ C) (h : C ⇒₁ D) →
(h ∘₁ (g ∘₁ f)) ⇒₂ ((h ∘₁ g) ∘₁ f)
α f g h = η (NaturalIsomorphism.F⇒G assoc) (h , g , f)
-- Triangle identity. Look how closely it matches with the one on
-- http://ncatlab.org/nlab/show/bicategory
Triangle : {A B C : Obj} (f : A ⇒₁ B) (g : B ⇒₁ C) → Set e
Triangle f g = (g ▹ ρᵤ f) ≡₂ ((λᵤ g ◃ f) • (α f id₁ g))
-- Pentagon identity. Ditto.
Pentagon : {A B C D E : Obj} (f : A ⇒₁ B) (g : B ⇒₁ C) (h : C ⇒₁ D) (i : D ⇒₁ E) → Set e
Pentagon f g h i = ((α g h i ◃ f) • (α f (h ∘₁ g) i)) • (i ▹ α f g h) ≡₂ (α f g (i ∘₁ h) • α (g ∘₁ f) h i)
|
Require Export ct08.
Conjecture HdRel_merge_snd_cons : forall (a a0 : nat) (l1 l2 : list nat),
sorted (a :: l1) -> sorted (a0 :: l2) -> a <= a0
-> HdRel le a (merge l1 (a0 :: l2)).
Conjecture sorted_merge_cons : forall (a a0 : nat) (l1 l2 : list nat),
(sorted (a :: l1) -> sorted l2 -> sorted (merge (a :: l1) l2))
-> sorted (a :: l1) -> sorted (a0 :: l2)
-> sorted (merge (a :: l1) l2).
Conjecture HdRel_merge_fst_cons : forall (a a0 : nat) (l1 l2 : list nat),
(sorted (a :: l1) -> sorted l2 -> sorted (merge (a :: l1) l2))
-> sorted (a :: l1) -> sorted (a0 :: l2) -> a0 < a
-> HdRel le a0 (merge (a :: l1) l2).
Lemma merge_sorted : forall (l1 l2 : list nat),
sorted l1 -> sorted l2 -> sorted (merge l1 l2).
Proof.
induction l1; induction l2; intros; simpl; auto.
destruct (le_lt_dec a a0).
- constructor. apply IHl1; inversion H; auto. apply HdRel_merge_snd_cons; auto.
- constructor. eapply sorted_merge_cons; eassumption.
apply HdRel_merge_fst_cons; auto.
Qed. |
module Verified.Algebra.Nat
import Classes.Verified
%default total
fromAdditive : Additive -> Nat
fromAdditive (getAdditive n) = n
natAndAdditive1 : fromAdditive (getAdditive n) = n
natAndAdditive1 = Refl
natAndAdditive2 : getAdditive (fromAdditive n) = n
natAndAdditive2 {n=getAdditive n'}= Refl
natAndAdditiveOp1 : fromAdditive (getAdditive n <+> getAdditive m) = n + m
natAndAdditiveOp1 = Refl
natAndAdditiveOp2 : getAdditive (fromAdditive n + fromAdditive m) = n <+> m
natAndAdditiveOp2 {n=getAdditive n'} {m=getAdditive m'} = Refl
fromMultiplicative : Multiplicative -> Nat
fromMultiplicative (getMultiplicative n) = n
natAndMultiplicative1 : fromMultiplicative (getMultiplicative n) = n
natAndMultiplicative1 = Refl
natAndMultiplicative2 : getMultiplicative (fromMultiplicative n) = n
natAndMultiplicative2 {n=getMultiplicative n'} = Refl
natAndMultiplicativeOp1 : fromMultiplicative (getMultiplicative n <+> getMultiplicative m) = n * m
natAndMultiplicativeOp1 = Refl
natAndMultiplicativeOp2 : getMultiplicative (fromMultiplicative n * fromMultiplicative m) = n <+> m
natAndMultiplicativeOp2 {n=getMultiplicative n'} {m=getMultiplicative m'} = Refl
instance VerifiedSemigroup Additive where
semigroupOpIsAssociative (getAdditive l) (getAdditive c) (getAdditive r) =
?lemmaAdditiveAssoc
instance VerifiedMonoid Additive where
monoidNeutralIsNeutralL (getAdditive l) = ?lemmaAdditiveNeutralL
monoidNeutralIsNeutralR (getAdditive r) = ?lemmaAdditiveNeutralR
instance VerifiedSemigroup Multiplicative where
semigroupOpIsAssociative (getMultiplicative l) (getMultiplicative c) (getMultiplicative r) =
?lemmaMultiplicativeAssoc
instance VerifiedMonoid Multiplicative where
monoidNeutralIsNeutralL (getMultiplicative l) = ?lemmaMultiplicativeNeutralL
monoidNeutralIsNeutralR (getMultiplicative r) = ?lemmaMultiplicativeNeutralR
---------- Proofs ----------
Verified.Algebra.Nat.lemmaMultiplicativeNeutralL = proof
intros
rewrite multOneRightNeutral l
exact Refl
Verified.Algebra.Nat.lemmaMultiplicativeNeutralR = proof
intros
rewrite multOneLeftNeutral r
exact Refl
Verified.Algebra.Nat.lemmaMultiplicativeAssoc = proof
intros
rewrite multAssociative l c r
exact Refl
Verified.Algebra.Nat.lemmaAdditiveNeutralL = proof
intros
rewrite (plusZeroRightNeutral l)
exact Refl
Verified.Algebra.Nat.lemmaAdditiveNeutralR = proof
intros
exact Refl
Verified.Algebra.Nat.lemmaAdditiveAssoc = proof
intros
rewrite (plusAssociative l c r)
exact Refl
|
(*
Copyright (C) 2017 M.A.L. Marques
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)
(* type: work_gga_c *)
$include "gga_c_tca.mpl"
msinc := x -> piecewise(x = 0, 1, sin(x)/x):
aa := Pi*(9*Pi/4)^(1/3):
fD := (rs, z, s) -> 1 - z^4*(1 - msinc(aa*s/rs)^2):
f := (rs, z, xt, xs0, xs1) ->
f_tcs(rs, z, xt)*fD(rs, z, X2S*2^(1/3)*xt): |
State Before: R : Type u
A₁ : Type v
A₂ : Type w
A₃ : Type u₁
inst✝¹⁰ : CommSemiring R
inst✝⁹ : Semiring A₁
inst✝⁸ : Semiring A₂
inst✝⁷ : Semiring A₃
inst✝⁶ : Algebra R A₁
inst✝⁵ : Algebra R A₂
inst✝⁴ : Algebra R A₃
e : A₁ ≃ₐ[R] A₂
A₁' : Type u_1
A₂' : Type u_2
inst✝³ : Semiring A₁'
inst✝² : Semiring A₂'
inst✝¹ : Algebra R A₁'
inst✝ : Algebra R A₂'
e₁ : A₁ ≃ₐ[R] A₁'
e₂ : A₂ ≃ₐ[R] A₂'
⊢ (arrowCongr e₁ e₂).symm = arrowCongr (symm e₁) (symm e₂) State After: case H.H
R : Type u
A₁ : Type v
A₂ : Type w
A₃ : Type u₁
inst✝¹⁰ : CommSemiring R
inst✝⁹ : Semiring A₁
inst✝⁸ : Semiring A₂
inst✝⁷ : Semiring A₃
inst✝⁶ : Algebra R A₁
inst✝⁵ : Algebra R A₂
inst✝⁴ : Algebra R A₃
e : A₁ ≃ₐ[R] A₂
A₁' : Type u_1
A₂' : Type u_2
inst✝³ : Semiring A₁'
inst✝² : Semiring A₂'
inst✝¹ : Algebra R A₁'
inst✝ : Algebra R A₂'
e₁ : A₁ ≃ₐ[R] A₁'
e₂ : A₂ ≃ₐ[R] A₂'
x✝¹ : A₁' →ₐ[R] A₂'
x✝ : A₁
⊢ ↑(↑(arrowCongr e₁ e₂).symm x✝¹) x✝ = ↑(↑(arrowCongr (symm e₁) (symm e₂)) x✝¹) x✝ Tactic: ext State Before: case H.H
R : Type u
A₁ : Type v
A₂ : Type w
A₃ : Type u₁
inst✝¹⁰ : CommSemiring R
inst✝⁹ : Semiring A₁
inst✝⁸ : Semiring A₂
inst✝⁷ : Semiring A₃
inst✝⁶ : Algebra R A₁
inst✝⁵ : Algebra R A₂
inst✝⁴ : Algebra R A₃
e : A₁ ≃ₐ[R] A₂
A₁' : Type u_1
A₂' : Type u_2
inst✝³ : Semiring A₁'
inst✝² : Semiring A₂'
inst✝¹ : Algebra R A₁'
inst✝ : Algebra R A₂'
e₁ : A₁ ≃ₐ[R] A₁'
e₂ : A₂ ≃ₐ[R] A₂'
x✝¹ : A₁' →ₐ[R] A₂'
x✝ : A₁
⊢ ↑(↑(arrowCongr e₁ e₂).symm x✝¹) x✝ = ↑(↑(arrowCongr (symm e₁) (symm e₂)) x✝¹) x✝ State After: no goals Tactic: rfl |
```python
import numpy as np
import matplotlib.pyplot as plt
import math
import scipy.integrate as inte
from numpy import matmul as mm
from control import lqr
import scipy.linalg
import slycot
```
```python
from sympy import *
th,phi,dth,dphi,u = symbols('th phi dth dphi u')
```
def lqr(A,B,Q,R):
X = np.matrix(scipy.linalg.solve_continuous_are(A, B, Q, R))
K = np.matrix(scipy.linalg.inv(R)*(B.T*X))
eigVals, eigVecs = scipy.linalg.eig(A-B*K)
return K, X, eigVals
def dlqr(A,B,Q,R):
X = np.matrix(scipy.linalg.solve_discrete_are(A, B, Q, R))
K = np.matrix(scipy.linalg.inv(B.T*X*B+R)*(B.T*X*A))
eigVals, eigVecs = scipy.linalg.eig(A-B*K)
return K, X, eigVals
```python
def eomsym(params,th,phi,dth,dphi,u):
A = params['mr']*params['r']*params['d']*cos(phi)
B = params['ir']+params['mr']*(params['d']**2)
C = params['mr']*params['g']*params['d']
D = params['mr']*(params['r']**2)
E = params['r']*params['mr']*params['d']*cos(phi)
F = params['mr']*params['r']*params['d']
tau = u
tmp1 = A*F*sin(phi)*dphi**2-C*D*sin(phi)+(A+D)*tau
tmp2 = A*E-B*D; phidd = tmp1/tmp2
thdd = -((A+B)*phidd-C*sin(phi)+tau)/A
qdd = Matrix([thdd,phidd])
return qdd
```
```python
def eom(params,th,phi,dth,dphi,u):
A = params['mr']*params['r']*params['d']*np.cos(phi)
B = params['ir']+params['mr']*(params['d']**2)
C = params['mr']*params['g']*params['d']
D = params['mr']*(params['r']**2)
E = params['r']*params['mr']*params['d']*np.cos(phi)
F = params['mr']*params['r']*params['d']
tau = u
tmp1 = A*F*np.sin(phi)*dphi**2-C*D*np.sin(phi)+(A+D)*tau
tmp2 = A*E-B*D; phidd = tmp1/tmp2
thdd = -((A+B)*phidd-C*np.sin(phi)+tau)/A
qdd = np.array([thdd,phidd])
return qdd
```
```python
params = {}; params['g'] = 9.81
params['mr'] = .25; params['ir'] = .0001
params['d'] = .1; params['r'] = .02
qdd = eomsym(params,th,phi,dth,dphi,u)
f = Matrix([dth,dphi])
g = Matrix([qdd])
der = Matrix([th,phi,dth,dphi])
A = f.jacobian(der)
A2= g.jacobian(der)
b = f.jacobian(Matrix([u]))
b2= g.jacobian(Matrix([u]))
```
```python
A
```
$\displaystyle \left[\begin{matrix}0 & 0 & 1 & 0\\0 & 0 & 0 & 1\end{matrix}\right]$
```python
A2
```
$\displaystyle \left[\begin{matrix}0 & \frac{2000.0 \left(- u - \frac{\left(0.0005 \cos{\left(\phi \right)} + 0.0026\right) \left(2.5 \cdot 10^{-7} dphi^{2} \sin{\left(\phi \right)} \cos{\left(\phi \right)} + u \left(0.0005 \cos{\left(\phi \right)} + 0.0001\right) - 2.4525 \cdot 10^{-5} \sin{\left(\phi \right)}\right)}{2.5 \cdot 10^{-7} \cos^{2}{\left(\phi \right)} - 2.6 \cdot 10^{-7}} + 0.24525 \sin{\left(\phi \right)}\right) \sin{\left(\phi \right)}}{\cos^{2}{\left(\phi \right)}} + \frac{2000.0 \left(- \frac{\left(0.0005 \cos{\left(\phi \right)} + 0.0026\right) \left(- 2.5 \cdot 10^{-7} dphi^{2} \sin^{2}{\left(\phi \right)} + 2.5 \cdot 10^{-7} dphi^{2} \cos^{2}{\left(\phi \right)} - 0.0005 u \sin{\left(\phi \right)} - 2.4525 \cdot 10^{-5} \cos{\left(\phi \right)}\right)}{2.5 \cdot 10^{-7} \cos^{2}{\left(\phi \right)} - 2.6 \cdot 10^{-7}} - \frac{5.0 \cdot 10^{-7} \left(0.0005 \cos{\left(\phi \right)} + 0.0026\right) \left(2.5 \cdot 10^{-7} dphi^{2} \sin{\left(\phi \right)} \cos{\left(\phi \right)} + u \left(0.0005 \cos{\left(\phi \right)} + 0.0001\right) - 2.4525 \cdot 10^{-5} \sin{\left(\phi \right)}\right) \sin{\left(\phi \right)} \cos{\left(\phi \right)}}{\left(2.5 \cdot 10^{-7} \cos^{2}{\left(\phi \right)} - 2.6 \cdot 10^{-7}\right)^{2}} + 0.24525 \cos{\left(\phi \right)} + \frac{0.0005 \left(2.5 \cdot 10^{-7} dphi^{2} \sin{\left(\phi \right)} \cos{\left(\phi \right)} + u \left(0.0005 \cos{\left(\phi \right)} + 0.0001\right) - 2.4525 \cdot 10^{-5} \sin{\left(\phi \right)}\right) \sin{\left(\phi \right)}}{2.5 \cdot 10^{-7} \cos^{2}{\left(\phi \right)} - 2.6 \cdot 10^{-7}}\right)}{\cos{\left(\phi \right)}} & 0 & - \frac{0.001 dphi \left(0.0005 \cos{\left(\phi \right)} + 0.0026\right) \sin{\left(\phi \right)}}{2.5 \cdot 10^{-7} \cos^{2}{\left(\phi \right)} - 2.6 \cdot 10^{-7}}\\0 & \frac{- 2.5 \cdot 10^{-7} dphi^{2} \sin^{2}{\left(\phi \right)} + 2.5 \cdot 10^{-7} dphi^{2} \cos^{2}{\left(\phi \right)} - 0.0005 u \sin{\left(\phi \right)} - 2.4525 \cdot 10^{-5} \cos{\left(\phi \right)}}{2.5 \cdot 10^{-7} \cos^{2}{\left(\phi \right)} - 2.6 \cdot 10^{-7}} + \frac{5.0 \cdot 10^{-7} \left(2.5 \cdot 10^{-7} dphi^{2} \sin{\left(\phi \right)} \cos{\left(\phi \right)} + u \left(0.0005 \cos{\left(\phi \right)} + 0.0001\right) - 2.4525 \cdot 10^{-5} \sin{\left(\phi \right)}\right) \sin{\left(\phi \right)} \cos{\left(\phi \right)}}{\left(2.5 \cdot 10^{-7} \cos^{2}{\left(\phi \right)} - 2.6 \cdot 10^{-7}\right)^{2}} & 0 & \frac{5.0 \cdot 10^{-7} dphi \sin{\left(\phi \right)} \cos{\left(\phi \right)}}{2.5 \cdot 10^{-7} \cos^{2}{\left(\phi \right)} - 2.6 \cdot 10^{-7}}\end{matrix}\right]$
```python
b
```
$\displaystyle \left[\begin{matrix}0\\0\end{matrix}\right]$
```python
b2
```
$\displaystyle \left[\begin{matrix}\frac{2000.0 \left(- \frac{\left(0.0005 \cos{\left(\phi \right)} + 0.0001\right) \left(0.0005 \cos{\left(\phi \right)} + 0.0026\right)}{2.5 \cdot 10^{-7} \cos^{2}{\left(\phi \right)} - 2.6 \cdot 10^{-7}} - 1\right)}{\cos{\left(\phi \right)}}\\\frac{0.0005 \cos{\left(\phi \right)} + 0.0001}{2.5 \cdot 10^{-7} \cos^{2}{\left(\phi \right)} - 2.6 \cdot 10^{-7}}\end{matrix}\right]$
```python
A.subs([(th,0),(phi,0),(dth,0),(dphi,0),(u,0)])
```
$\displaystyle \left[\begin{matrix}0 & 0 & 1 & 0\\0 & 0 & 0 & 1\end{matrix}\right]$
```python
A2.subs([(th,0),(phi,0),(dth,0),(dphi,0),(u,0)])
```
$\displaystyle \left[\begin{matrix}0 & -14714.9999999999 & 0 & 0\\0 & 2452.49999999998 & 0 & 0\end{matrix}\right]$
```python
A_1 = np.vstack((np.array(A.subs([(th,0),(phi,1),(dth,0),(dphi,0),(u,0)])),
np.array(A2.subs([(th,0),(phi,1),(dth,0),(dphi,0),(u,0)])))).astype(float)
b_1 = np.vstack((np.array(b.subs([(th,0),(phi,1),(dth,0),(dphi,0),(u,0)])),
np.array(b2.subs([(th,0),(phi,1),(dth,0),(dphi,0),(u,0)])))).astype(float)
A_1 = np.matrix(A_1)
b_1 = np.matrix(b_1)
print(A_1)
print(b_1)
```
[[ 0. 0. 1. 0. ]
[ 0. 0. 0. 1. ]
[ 0. 698.49085038 0. 0. ]
[ 0. -63.27637257 0. 0. ]]
[[ 0. ]
[ 0. ]
[17326.11921085]
[-1979.22366384]]
```python
b_1.shape
```
(4, 1)
```python
K,S,E = lqr(A_1,b_1,10000*np.eye(4),1000)
```
```python
def circle(x,y,r):
ang = np.arange(0,2*np.pi,0.01)
xp = r*np.cos(ang)
yp = r*np.sin(ang)
plt.plot(x+xp,y+yp,color='k',linewidth=2)
```
```python
def controller(params,t,X):
k = -np.array([.0089,1.0553,.0112,.125])
u = -mm(k,X)
return u
```
```python
def dynamics(params,t,X):
Xd = np.zeros(X.shape);
th,phi,dth,dphi = X[0],X[1],X[2],X[3]
u = controller(params,t,X)
Xd[:2] = X[2:]
Xd[2:] = eom(params,th,phi,dth,dphi,u)
return Xd
def robotSim():
params = {}; params['g'] = 9.81
params['mr'] = .25; params['ir'] = .0001
params['d'] = .1; params['r'] = .02
t0,t1 = 0,2; y0 = np.array([0,1,0,0])
t = np.linspace(t0,t1,445)
y = np.zeros((len(t),len(y0))); y[0,:] = y0
r = inte.ode(lambda t,y:dynamics(params,t,y)).set_integrator("dopri5")
r.set_initial_value(y0, t0) # initial values
for i in range(1, t.size):
y[i, :] = r.integrate(t[i]) # get one more value, add it to the array
if not r.successful():
raise RuntimeError("Could not integrate")
return t,y
```
```python
t,y = robotSim()
plt.figure(figsize=(20,10))
plt.subplot(4,1,1)
plt.plot(t,y[:,1])
plt.subplot(4,1,2)
plt.plot(t,y[:,3])
plt.subplot(4,1,3)
plt.plot(t,y[:,0])
plt.subplot(4,1,4)
plt.plot(t,y[:,2])
```
```python
fig = plt.figure(figsize=(15,5))
plt.ylim([-.3,.3]); plt.xlim([-2,2])
j=0
for i in np.array([0,20,40,60,80,100]):
ax = plt.subplot(3,2,j+1)
th,phi,dth,dphi = y[i,0],y[i,1],y[i,2],y[i,3]
x = th*.02
plt.ylim([-.3,.3]); plt.xlim([-2,2])
plt.gca().set_aspect('equal', adjustable='box')
ax.plot(np.array([x,x+.1*2*np.sin(phi)]),
np.array([0,2*.1*np.cos(phi)]),
color=.5*np.array([1,1,1]),linewidth=12)
circle(x,0,.02)
ax.plot(np.array([-2,2]),
np.array([-.02,-.02]),
color=.3*np.array([1,1,1]))
j+=1
```
```python
%matplotlib inline
%load_ext autoreload
%autoreload 2
%matplotlib notebook
fig = plt.figure(figsize=(10,10))
plt.ylim([-.3,.3]); plt.xlim([-2,2])
ax = plt.gca()
plt.ion()
fig.show()
fig.canvas.draw()
for i in range(len(t)):
th,phi,dth,dphi = y[i,0],y[i,1],y[i,2],y[i,3]
x = th*.02
ax.clear()
plt.ylim([-.3,.3]); plt.xlim([-2,2])
plt.gca().set_aspect('equal', adjustable='box')
ax.plot(np.array([x,x+.1*2*np.sin(phi)]),
np.array([0,2*.1*np.cos(phi)]),
color=.5*np.array([1,1,1]),linewidth=12)
circle(x,0,.02)
ax.plot(np.array([-2,2]),
np.array([-.02,-.02]),
color=.3*np.array([1,1,1]))
fig.canvas.draw()
```
```python
```
|
Require Import Crypto.Arithmetic.PrimeFieldTheorems.
Require Import Crypto.Specific.solinas32_2e285m9_11limbs.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.
|
"""
CustomImplants.py
MIT License
Copyright (c) 2020 Alexandros Benetatos
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.
"""
"""
DESCRIPTION
A pulse2percept.implants.ProsthesisSystem subclass for pulse2percept to create a custom
square retinal implant with circular electrodes (Disk Electrodes) and the desired
* number of electrodes in each side - e_num_side
* radius of each electrode - e_radius
* and spacing between them - spacing
* or total area of implant - total_area
"""
import warnings
import numpy as np
from skimage.transform import resize
from pulse2percept.models import AxonMapModel
from pulse2percept.implants import ProsthesisSystem, ElectrodeGrid, DiskElectrode
class SquareImplant(ProsthesisSystem):
def __init__(self, e_num_side, e_radius, spacing=None, side_size=None, stim=None, eye='RE', name=None):
"""
e_num_side : the number of electrodes in the squares implant's side
e_radius : the radius of each electrode in the square implant [microns]
spacing : the spacing between to electrodes in the squares implant's [microns]
side_size : the size of the squares implant's side in [microns]
stim : stimuli signal for each electrode [one dimensional array]
eye : the eye where it is implanted ['RE', 'LE']
name : name of the implant [string]
"""
# if there is no name assigned the derive it from the desired characteristics of the implant
if name is None:
self.name = f"e_num_side={e_num_side}-e_radius={e_radius}-spacing={spacing}-side_size={side_size}"
else:
self.name = name
# if side size is set the derive the spacing between each electrod from it
if side_size is not None:
spacing = (side_size - 2*e_radius)/(e_num_side - 1)
elif spacing is None:
raise Exception("Provide a 'spacing' or 'side_size' parameter in microns")
if spacing < 2*e_radius:
warnings.warn('Either the electrode radius (e_radius) is too big or the side size (side_size) ' +
'is too small and there is electrode overlap', stacklevel=2)
self.earray = ElectrodeGrid((e_num_side, e_num_side), x=0, y=0, z=0, rot=0,
r=e_radius, spacing=spacing, etype=DiskElectrode,
names=('A', '1'))
self.stim = stim
self.eye = eye
# plot implant on an axon map
def plot_on_axon_map(self, annotate_implant=False, annotate_quadrants=True, ax=None):
if ax is None:
_, ax = plt.subplots(figsize=(10, 10))
AxonMapModel().plot(annotate=annotate_quadrants, ax=ax)
self.earray.plot(annotate=annotate_implant, ax=ax)
# # take the flattened stimuli (from img2stim) and return an 2-D array representing and image
# def img2implant_img(self, img):
# return np.reshape(self.img2stim(img), self.earray.shape) |
# NBA Team Ratings, Pt. 3
In NBA Team Ratings, Pt. 1, I built a simple model that applyied shrinkage while taking matchups and home-court into account. In part 2, I extended that model to provide more explanation for how each team achieves its results on each side of the floor, looking at the results of a possession on a more granular level by modeling individual outcomes instead of the average one.
Unfortunately, that model doesn't really speak the "language of basketball"; no one refers to a team's probability of scoring 0 points on a possession for example.
Instead, basketball analysts focus on the process of scoring with statistics like shooting percentage, rebounds, and turnovers.
What we'd really like to model is the relationship between these process metrics, and scoring outcomes.
To do that, I've modified Dean Oliver's "Four Factors of Basketball Success," replacing them with seven:
1. $ \frac{\text{3pt att}}{\text{shot}} $: percentage of shots that were attempted from three point range
2. $ \text{2pt}\% $: percentage of two point shot attempts made
3. $ \text{3pt}\% $: percentage of three point shot attempts made
4. $ \text{reb}\% $: percentage of rebounds grabbed
5. $ \text{to}\% $: percentage of possessions that end in a turnover
6. $ \frac{\text{ft att}}{\text{poss}} $: free throws attempted per possession
7. $ \text{ft}\% $: percentage of free throw attempts made
The math is a bit complicated, but with these seven factors, we can accurately estimate the points scored per possession.
\begin{align}
\frac{\text{points}}{\text{poss}} &= \frac{\text{shots}}{\text{poss}} \times \frac{\text{points}}{\text{shot}} + \frac{\text{ft att}}{\text{poss}} \times \text{ft}\% \notag \\
\text{where } \frac{\text{points}}{\text{shot}} &= 3 \times \frac{\text{3pt att}}{\text{shot}} \times \text{3pt}\% + 2 \times \left(1 - \frac{\text{3pt att}}{\text{shot}} \right) \times \text{2pt}\% \notag
\end{align}
These equations have one undefined term which must be estimated: $ \frac{\text{shots}}{\text{poss}} $.
A possession can have any number of shots thanks to the resetting nature of a missed shot attempt combined with an offensive rebound.
To clarify this, we'll need a new term: a shot opportunity. Every possession starts with a shot opportunity, and has additional shot opportunities for each offensive rebound, which acts to reset the possession.
\begin{align}
\frac{\text{shots}}{\text{poss}} &= 0 \times \mathbb{P}(0) + 1 \times \mathbb{P}(1) + 2 \times \mathbb{P}(2) + \cdots \notag \\
\text{where } \mathbb{P}(k) &\cong p_\text{last shot} \times p_\text{reset}^{k - 1} \notag \\
p_\text{last shot} &\equiv p_\text{shot} \times \left( p_\text{make} + p_\text{miss} \times \left(p_\text{def reb} + p_\text{off reb} \times \left(1 - p_\text{shot} \right) \right) \right) \notag \\
p_\text{reset} &\equiv p_\text{shot} \times p_\text{miss} \times p_\text{off reb} \notag \\
p_\text{make} &\equiv \frac{\text{3pt att}}{\text{shot}} \times \text{3pt}\% + \left(1 - \frac{\text{3pt att}}{\text{shot}} \right) \times \text{2pt}\% \notag \\
p_\text{miss} &\equiv 1 - p_\text{make} \notag
\end{align}
Note that I've labeled that $ \mathbb{P}(k) $ here is approximate. We're assuming that the events in a possession are independent, i.e. when a possession resets with a missed shot \& offensive rebound, this is the same state as the beginning of a possession.
Of course, this isn't true, since an offensive rebound can often lead to an immediate "putback" attempt, the shot clock is usually set to 14 instead of the usual 24, there aren't fast breaks, and so on. Still, empirically, this assumption seems to work.
That set aside, we're again left with one undefined: $ p_\text{shot} $, the probability of attempting a shot given a shot opportunity.
Turnovers prevent shots, but less obviously, so do shooting fouls, since they don't count as a shot attempt if the shot is missed.
Thus, to estimate this factor, I ran a simple linear regression to estimate it:
\begin{align}
p_\text{shot} &\cong k_\text{1} \times 1 + k_\text{to} \times \text{to}\% + k_\text{fta} \times \frac{\text{ft att}}{\text{poss}} \notag \\
&= 1 - 0.85 \times \text{to}\% - 0.4 \times \frac{\text{ft att}}{\text{poss}} \notag
\end{align}
With all these terms defined, we can reformulate $ \frac{\text{shots}}{\text{poss}} $ as the sum of an infinite series:
\begin{align}
\frac{\text{shots}}{\text{poss}} &= \sum_{k=0}^{\infty}{ k \times p_\text{last shot} \times p_\text{reset}^{k - 1}} \notag \\
&= p_\text{last shot} \sum_{k=1}^{\infty}{ k \times p_\text{reset}^{k - 1}} \notag \\
&= \frac{p_\text{last shot}}{p_\text{reset}} \sum_{k=1}^{\infty}{ k \times p_\text{reset}^k} \notag \\
&= \frac{p_\text{last shot}}{p_\text{reset}} \times \frac{p_\text{reset}}{(1 - p_\text{reset})^2} \notag \\
&= \frac{p_\text{last shot}}{(1 - p_\text{reset})^2} \notag
\end{align}
All that work done, we're left with an almost exact method of calculating a team's points per possession given the seven factors.
So how did I model those seven factors?
Well conveniently, they can be each modeled independently of one another.
As well, six of the seven are simple binary probabilities, allowing me to fit the data using a simple Binomial distribution and Beta priors, much easier than the Multinomial distribution and Dirichlet priors from before.
For the one continuous variable ($ \frac{\text{ft att}}{\text{poss}} $), I used a simple Normal distribution with Gamma priors.
As well, I modeled the pace of each game (seconds per possession) using a similar approach, a Gamma distribution for both the observations and priors.
Most of these parameters depend on the offense, defense, and home court, with the following exceptions:
1. $ \frac{\text{3pt att}}{\text{shot}} $ didn't depend on home court
2. pace didn't depend on home court
3. $ \text{ft}\% $ didn't depend on the defense
Running this final model on the 2019 NBA Regular Season, we see similar patterns of shrinkage of extreme values, but with more variation, due to the model factoring in more inputs:
```python
from matplotlib import pyplot as plt
from pynba import halfgames_from_file, teams_from_file, team_id_to_abb, plot_ratings, plot_paces, use_blackontrans_style
league = "nba"
year = 2019
season_type = "Regular Season"
```
```python
halfgames = halfgames_from_file(league, year, season_type)
team_stats = teams_from_file(league, year, season_type)
team_stats
```
```python
team_id_to_team_abb = team_id_to_abb(league, year)
team_abb_to_team_id = {
team_abb: team_id
for team_id, team_abb in team_id_to_team_abb.items()
}
points_mu = halfgames["points_scored"].sum() / halfgames["possession_num"].sum() * 100
pace_mu = halfgames["possession_num"].sum() / halfgames["duration"].sum() * 12 * 4 * 60
```
```python
use_blackontrans_style()
fig = plt.figure(figsize=(8, 8))
ax = fig.add_subplot(1, 1, 1)
for team, off_aa, def_aa in zip(team_stats["team"], team_stats["off_scoring_above_average"], team_stats["def_scoring_above_average"]):
team_id = team_abb_to_team_id[team]
filt = halfgames["off_team_id"] == team_id
raw_off = halfgames.loc[filt, "points_scored"].sum() / halfgames.loc[filt, "possession_num"].sum() * 100 - points_mu
filt = halfgames["def_team_id"] == team_id
raw_def = points_mu - halfgames.loc[filt, "points_scored"].sum() / halfgames.loc[filt, "possession_num"].sum() * 100
ax.annotate("", xy=(off_aa, def_aa), xytext=(raw_off, raw_def), arrowprops={"arrowstyle": "->", "color": "white"})
plot_ratings(team_stats, ax)
```
Finally, we also get a nice new plot, showing the pace for each team. Here we see that the model is doing very little in comparison to the raw values:
```python
fig = plt.figure(figsize=(8, 8))
ax = fig.add_subplot(1, 1, 1)
for team, off_aa, def_aa in zip(team_stats["team"], team_stats["off_pace_above_average"], team_stats["def_pace_above_average"]):
team_id = team_abb_to_team_id[team]
filt = halfgames["off_team_id"] == team_id
raw_off = (halfgames.loc[filt, "possession_num"].sum() / halfgames.loc[filt, "duration"].sum() * 12 * 4 * 60 - pace_mu) / 2
filt = halfgames["def_team_id"] == team_id
raw_def = (halfgames.loc[filt, "possession_num"].sum() / halfgames.loc[filt, "duration"].sum() * 12 * 4 * 60 - pace_mu) / 2
ax.annotate("", xy=(off_aa, def_aa), xytext=(raw_off, raw_def), arrowprops={"arrowstyle": "->", "color": "white"})
plot_paces(team_stats, ax)
```
|
Click on the first alphabet and have a go on this exclusive adventure by enhancing your knowledge with our casino & gambling dictionary!
Ever came across a group of friends and they were talking about betting, poker, craps, and other gambling terms and you just sat there not understanding a single thing uttered by them? Well, it happens but you certainly don’t have to worry about it! NewCasinos.org has got your back and through our enlisted casino and gambling glossary, every terminology affiliated with the gambling realm has been elaborated in such a simple way. A simple and common way that it will allow you to now know and understand the lingo better than ever.
We have gone out of our way to ensure those who are new potential and established online gamblers can become accustomed to the jargon’s and also look upon our gambling dictionary as a quick reference point. From our official website you can look up every term in our casino glossary and its meaning for you to have a better understanding about various words and phrases used in the various gaming activities, the context in which they are used and who uses the words – either the casino dealers or those who enjoy playing casino games.
Our casino and gambling glossary is very useful, you will find every term used so that the next time when you are sitting among friends playing cards, craps or any other table game; you will certainly be well-aware and versed with all the different casino terms. Make our gambling dictionary your companion and watch as you build your vocabulary and knowledge in no time.
If you come across any terms that you can’t find, please do not hesitate to contact us and we will look into adding it to our comprehensive list. We are always looking to improve our gambling glossary so we can keep all our readers well informed and educated on the latest casino and gambling terms. So we appreciate it when you, the reader, take the time to interact with us and provide us with your valued input – honest!
Build your proficiency with our gambling dictionary and start playing online casino games like any other pro player! |
static char help[] = "Solve the p-Laplacian equation in 2D using Q^1 FEM.\n"
"Implements an objective function and a residual (gradient) function, but\n"
"no Jacobian. Defaults to p=4 and quadrature degree n=2. Run as one of:\n"
" ./plap -snes_fd_color [default]\n"
" ./plap -snes_mf\n"
" ./plap -snes_fd [does not scale]\n"
" ./plap -snes_fd_function -snes_fd [does not scale]\n"
"Uses a manufactured solution.\n"
"This is NOT a recommended example for further work because of the weird way\n"
"it handles the Dirichlet boundary values.\n\n";
#include <petsc.h>
#include "../../quadrature.h"
#define COMM PETSC_COMM_WORLD
/* cool dendritic failure:
./plap -snes_fd_color -snes_converged_reason -ksp_converged_reason -pc_type mg -plap_p 10.0 -da_refine 6 -snes_monitor_solution draw
succeeds in 11 snes iterations (on fine grid) with grid sequencing:
./plap -snes_fd_color -snes_converged_reason -ksp_converged_reason -pc_type mg -plap_p 10.0 -snes_grid_sequence 6 -snes_monitor_solution draw
*/
//STARTCTX
typedef struct {
double p, eps, alpha;
int quaddegree;
PetscBool no_residual;
} PLapCtx;
//ENDCTX
PetscErrorCode ConfigureCtx(PLapCtx *user) {
PetscErrorCode ierr;
user->p = 4.0;
user->eps = 0.0;
user->alpha = 1.0;
user->quaddegree = 2;
user->no_residual = PETSC_FALSE;
ierr = PetscOptionsBegin(COMM,"plap_","p-laplacian solver options",""); CHKERRQ(ierr);
ierr = PetscOptionsReal("-p","exponent p with 1 <= p < infty",
"plap.c",user->p,&(user->p),NULL); CHKERRQ(ierr);
if (user->p < 1.0) { SETERRQ(COMM,1,"p >= 1 required"); }
ierr = PetscOptionsReal("-eps","regularization parameter eps",
"plap.c",user->eps,&(user->eps),NULL); CHKERRQ(ierr);
ierr = PetscOptionsReal("-alpha","parameter alpha in exact solution",
"plap.c",user->alpha,&(user->alpha),NULL); CHKERRQ(ierr);
ierr = PetscOptionsInt("-quaddegree","quadrature degree n (= 1,2,3 only)",
"plap.c",user->quaddegree,&(user->quaddegree),NULL); CHKERRQ(ierr);
if ((user->quaddegree < 1) || (user->quaddegree > 3)) {
SETERRQ(COMM,2,"quadrature degree n=1,2,3 only"); }
ierr = PetscOptionsBool("-no_residual","do not set the residual evaluation function",
"plap.c",user->no_residual,&(user->no_residual),NULL);CHKERRQ(ierr);
ierr = PetscOptionsEnd(); CHKERRQ(ierr);
return 0;
}
//STARTEXACT
double Uexact(double x, double y, double alpha) {
return 0.5 * (x+alpha)*(x+alpha) * (y+alpha)*(y+alpha);
}
double Frhs(double x, double y, PLapCtx *user) {
const double alf = user->alpha,
XX = (x+alf)*(x+alf),
YY = (y+alf)*(y+alf),
D2 = XX + YY,
C = PetscPowScalar(XX * YY * D2, (user->p - 2.0) / 2.0),
gamma1 = 1.0/(x+alf) + (x+alf)/D2,
gamma2 = 1.0/(y+alf) + (y+alf)/D2;
return - (user->p - 2.0) * C * (gamma1*(x+alf)*YY + gamma2*XX*(y+alf))
- C * D2;
}
//ENDEXACT
//STARTINITIALITERATE
PetscErrorCode InitialIterateLocal(DMDALocalInfo *info, Vec u, PLapCtx *user) {
PetscErrorCode ierr;
const double hx = 1.0 / (info->mx+1), hy = 1.0 / (info->my+1);
double x, y, **au;
int i, j;
ierr = DMDAVecGetArray(info->da,u,&au); CHKERRQ(ierr);
for (j = info->ys; j < info->ys + info->ym; j++) {
y = hy * (j + 1);
for (i = info->xs; i < info->xs + info->xm; i++) {
x = hx * (i + 1);
au[j][i] = (1.0 - x) * Uexact(0.0,y,user->alpha)
+ x * Uexact(1.0,y,user->alpha);
}
}
ierr = DMDAVecRestoreArray(info->da,u,&au); CHKERRQ(ierr);
return 0;
}
//ENDINITIALITERATE
PetscErrorCode GetUexactLocal(DMDALocalInfo *info, Vec uex, PLapCtx *user) {
PetscErrorCode ierr;
const double hx = 1.0 / (info->mx+1), hy = 1.0 / (info->my+1);
double x, y, **auex;
int i, j;
ierr = DMDAVecGetArray(info->da,uex,&auex); CHKERRQ(ierr);
for (j = info->ys; j < info->ys + info->ym; j++) {
y = hy * (j + 1);
for (i = info->xs; i < info->xs + info->xm; i++) {
x = hx * (i + 1);
auex[j][i] = Uexact(x,y,user->alpha);
}
}
ierr = DMDAVecRestoreArray(info->da,uex,&auex); CHKERRQ(ierr);
return 0;
}
//STARTFEM
static double xiL[4] = { 1.0, -1.0, -1.0, 1.0},
etaL[4] = { 1.0, 1.0, -1.0, -1.0};
double chi(int L, double xi, double eta) {
return 0.25 * (1.0 + xiL[L] * xi) * (1.0 + etaL[L] * eta);
}
// evaluate v(xi,eta) on reference element using local node numbering
double eval(const double v[4], double xi, double eta) {
double sum = 0.0;
int L;
for (L=0; L<4; L++)
sum += v[L] * chi(L,xi,eta);
return sum;
}
typedef struct {
double xi, eta;
} gradRef;
gradRef dchi(int L, double xi, double eta) {
const gradRef result = {0.25 * xiL[L] * (1.0 + etaL[L] * eta),
0.25 * etaL[L] * (1.0 + xiL[L] * xi)};
return result;
}
// evaluate partial derivs of v(xi,eta) on reference element
gradRef deval(const double v[4], double xi, double eta) {
gradRef sum = {0.0,0.0}, tmp;
int L;
for (L=0; L<4; L++) {
tmp = dchi(L,xi,eta);
sum.xi += v[L] * tmp.xi; sum.eta += v[L] * tmp.eta;
}
return sum;
}
//ENDFEM
//STARTTOOLS
void GetUorG(DMDALocalInfo *info, int i, int j, double **au, double *u,
PLapCtx *user) {
const double hx = 1.0 / (info->mx+1), hy = 1.0 / (info->my+1),
x = hx * (i + 1), y = hy * (j + 1);
u[0] = ((i == info->mx) || (j == info->my))
? Uexact(x, y, user->alpha) : au[j][i];
u[1] = ((i == 0) || (j == info->my))
? Uexact(x-hx,y, user->alpha) : au[j][i-1];
u[2] = ((i == 0) || (j == 0))
? Uexact(x-hx,y-hy,user->alpha) : au[j-1][i-1];
u[3] = ((i == info->mx) || (j == 0))
? Uexact(x, y-hy,user->alpha) : au[j-1][i];
}
double GradInnerProd(DMDALocalInfo *info, gradRef du, gradRef dv) {
const double hx = 1.0 / (info->mx+1), hy = 1.0 / (info->my+1),
cx = 4.0 / (hx * hx), cy = 4.0 / (hy * hy);
return cx * du.xi * dv.xi + cy * du.eta * dv.eta;
}
double GradPow(DMDALocalInfo *info, gradRef du, double P, double eps) {
return PetscPowScalar(GradInnerProd(info,du,du) + eps * eps, P / 2.0);
}
//ENDTOOLS
//STARTOBJECTIVE
double ObjIntegrandRef(DMDALocalInfo *info,
const double f[4], const double u[4],
double xi, double eta, double p, double eps) {
const gradRef du = deval(u,xi,eta);
return GradPow(info,du,p,eps) / p - eval(f,xi,eta) * eval(u,xi,eta);
}
PetscErrorCode FormObjectiveLocal(DMDALocalInfo *info, double **au,
double *obj, PLapCtx *user) {
PetscErrorCode ierr;
const double hx = 1.0 / (info->mx+1), hy = 1.0 / (info->my+1);
const Quad1D q = gausslegendre[user->quaddegree-1];
const int XE = info->xs + info->xm, YE = info->ys + info->ym;
double x, y, lobj = 0.0, u[4];
int i,j,r,s;
MPI_Comm com;
// loop over all elements
for (j = info->ys; j <= YE; j++) {
y = hy * (j + 1);
for (i = info->xs; i <= XE; i++) {
x = hx * (i + 1);
// owned elements include "right" and "top" edges of grid
if (i < XE || j < YE || i == info->mx || j == info->my) {
const double f[4] = {Frhs(x, y, user),
Frhs(x-hx,y, user),
Frhs(x-hx,y-hy,user),
Frhs(x, y-hy,user)};
GetUorG(info,i,j,au,u,user);
// loop over quadrature points
for (r = 0; r < q.n; r++) {
for (s = 0; s < q.n; s++) {
lobj += q.w[r] * q.w[s]
* ObjIntegrandRef(info,f,u,q.xi[r],q.xi[s],
user->p,user->eps);
}
}
}
}
}
lobj *= 0.25 * hx * hy;
ierr = PetscObjectGetComm((PetscObject)(info->da),&com); CHKERRQ(ierr);
ierr = MPI_Allreduce(&lobj,obj,1,MPI_DOUBLE,MPI_SUM,com); CHKERRQ(ierr);
return 0;
}
//ENDOBJECTIVE
//STARTFUNCTION
double FunIntegrandRef(DMDALocalInfo *info, int L,
const double f[4], const double u[4],
double xi, double eta, double p, double eps) {
const gradRef du = deval(u,xi,eta),
dchiL = dchi(L,xi,eta);
return GradPow(info,du,p - 2.0,eps) * GradInnerProd(info,du,dchiL)
- eval(f,xi,eta) * chi(L,xi,eta);
}
PetscErrorCode FormFunctionLocal(DMDALocalInfo *info, double **au,
double **FF, PLapCtx *user) {
const double hx = 1.0 / (info->mx+1), hy = 1.0 / (info->my+1);
const Quad1D q = gausslegendre[user->quaddegree-1];
const int XE = info->xs + info->xm, YE = info->ys + info->ym,
li[4] = {0,-1,-1,0}, lj[4] = {0,0,-1,-1};
double x, y, u[4];
int i,j,l,r,s,PP,QQ;
// clear residuals
for (j = info->ys; j < YE; j++)
for (i = info->xs; i < XE; i++)
FF[j][i] = 0.0;
// loop over all elements
for (j = info->ys; j <= YE; j++) {
y = hy * (j + 1);
for (i = info->xs; i <= XE; i++) {
x = hx * (i + 1);
const double f[4] = {Frhs(x, y, user),
Frhs(x-hx,y, user),
Frhs(x-hx,y-hy,user),
Frhs(x, y-hy,user)};
GetUorG(info,i,j,au,u,user);
// loop over corners of element i,j
for (l = 0; l < 4; l++) {
PP = i + li[l];
QQ = j + lj[l];
// only update residual if we own node
if (PP >= info->xs && PP < XE
&& QQ >= info->ys && QQ < YE) {
// loop over quadrature points
for (r = 0; r < q.n; r++) {
for (s = 0; s < q.n; s++) {
FF[QQ][PP]
+= 0.25 * hx * hy * q.w[r] * q.w[s]
* FunIntegrandRef(info,l,f,u,
q.xi[r],q.xi[s],
user->p,user->eps);
}
}
}
}
}
}
return 0;
}
//ENDFUNCTION
int main(int argc,char **argv) {
PetscErrorCode ierr;
DM da, da_after;
SNES snes;
Vec u_initial, u, u_exact;
PLapCtx user;
DMDALocalInfo info;
double err, hx, hy;
PetscInitialize(&argc,&argv,NULL,help);
ierr = ConfigureCtx(&user); CHKERRQ(ierr);
ierr = DMDACreate2d(COMM,
DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DMDA_STENCIL_BOX,
3,3,PETSC_DECIDE,PETSC_DECIDE,1,1,NULL,NULL,&da); CHKERRQ(ierr);
ierr = DMSetFromOptions(da); CHKERRQ(ierr);
ierr = DMSetUp(da); CHKERRQ(ierr);
ierr = DMSetApplicationContext(da,&user);CHKERRQ(ierr);
ierr = DMDAGetLocalInfo(da,&info); CHKERRQ(ierr);
hx = 1.0 / (info.mx+1);
hy = 1.0 / (info.my+1);
ierr = DMDASetUniformCoordinates(da,hx,1.0-hx,hy,1.0-hy,0.0,1.0); CHKERRQ(ierr);
ierr = SNESCreate(COMM,&snes); CHKERRQ(ierr);
ierr = SNESSetDM(snes,da); CHKERRQ(ierr);
ierr = DMDASNESSetObjectiveLocal(da,
(DMDASNESObjective)FormObjectiveLocal,&user); CHKERRQ(ierr);
if (!user.no_residual) {
ierr = DMDASNESSetFunctionLocal(da,INSERT_VALUES,
(DMDASNESFunction)FormFunctionLocal,&user); CHKERRQ(ierr);
}
ierr = SNESSetFromOptions(snes); CHKERRQ(ierr);
ierr = DMCreateGlobalVector(da,&u_initial);CHKERRQ(ierr);
ierr = InitialIterateLocal(&info,u_initial,&user); CHKERRQ(ierr);
ierr = SNESSolve(snes,NULL,u_initial); CHKERRQ(ierr);
ierr = VecDestroy(&u_initial); CHKERRQ(ierr);
ierr = DMDestroy(&da); CHKERRQ(ierr);
ierr = SNESGetSolution(snes,&u); CHKERRQ(ierr);
ierr = VecDuplicate(u,&u_exact); CHKERRQ(ierr);
ierr = SNESGetDM(snes,&da_after); CHKERRQ(ierr);
ierr = DMDAGetLocalInfo(da_after,&info); CHKERRQ(ierr);
ierr = PetscPrintf(COMM,
"grid of %d x %d = %d interior nodes\n",
info.mx,info.my,info.mx*info.my); CHKERRQ(ierr);
ierr = GetUexactLocal(&info,u_exact,&user); CHKERRQ(ierr);
ierr = VecAXPY(u,-1.0,u_exact); CHKERRQ(ierr); // u <- u + (-1.0) uexact
ierr = VecNorm(u,NORM_INFINITY,&err); CHKERRQ(ierr);
ierr = PetscPrintf(COMM,"numerical error: |u-u_exact|_inf = %.3e\n",
err); CHKERRQ(ierr);
VecDestroy(&u_exact); SNESDestroy(&snes);
return PetscFinalize();
}
|
A continuous map from the sphere of radius $r$ centered at $a$ to a topological space $S$ is nullhomotopic if and only if it extends to a continuous map from the closed ball of radius $r$ centered at $a$ to $S$. |
/**
* @file localization.h
* @brief source localization
* @author Ulrich Klee
*/
#ifndef LOCALIZATION_H
#define LOCALIZATION_H
#include <stdio.h>
#include <assert.h>
#include <gsl/gsl_block.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_complex.h>
#include <gsl/gsl_complex_math.h>
#include <gsl/gsl_fit.h>
#include "common/jexception.h"
gsl_vector* getSrpPhat(double delta_f, gsl_matrix_complex *mFramePerChannel, gsl_vector *searchRangeX, gsl_vector *searchRangeY, gsl_matrix *arrgeom, int zPos);
void calcDelays(int x, int y, int z, const gsl_matrix* mpos, gsl_vector* delays);
void calcDelaysOfLinearMicrophoneArray(float azimuth, const gsl_matrix* mpos, gsl_vector* delays);
void calcDelaysOfCircularMicrophoneArray(float azimuth, float elevation, const gsl_matrix* mpos, gsl_vector* delays);
gsl_vector* getDelays(double delta_f, gsl_matrix_complex* mFramePerChannel, gsl_vector* searchRange);
double getAzimuth(double delta_f, gsl_matrix_complex *mFramePerChannel, gsl_matrix *arrgeom, gsl_vector *delays);
double getPlaneWaveSrp(double delta_f, gsl_matrix_complex *mFramePerChannel, gsl_vector *searchRangeY, gsl_matrix *arrgeom);
//void halfComplexPack(double* tgt, const gsl_vector_complex* src);
void getGCCRaw(const gsl_matrix_complex* spectralSample, double sampleRate, gsl_vector* gcc);
const gsl_vector* getGCC(gsl_matrix_complex *spectralSample, double sampleRate);
const gsl_vector* getWindowedGCC(gsl_matrix_complex *spectralSample, double sampleRate, double minDelay, double maxDelay);
const gsl_vector* getWindowedGCCratio(gsl_matrix_complex *spectralSample, double sampleRate, double minDelay, double maxDelay);
const gsl_vector* getWindowedGCCdirect(gsl_matrix_complex *spectralSample, double sampleRate, double minDelay, double maxDelay);
const gsl_vector* getWindowedGCCabs(gsl_matrix_complex *spectralSample, double sampleRate, double minDelay, double maxDelay);
const gsl_vector* getDynWindowedGCC(gsl_matrix_complex *spectralSample, double sampleRate, double minDelay, double maxDelay, double wMinDelay, double wMaxDelay, double threshold);
double getInterpolation(gsl_matrix *crossResult, int delayPos);
gsl_vector* get3DPosition(gsl_vector *yCoord, gsl_vector *azimuth1, gsl_vector *azimuth2, double xPos, double zPos);
gsl_vector* get3DPosition_T_shape(gsl_matrix *arrgeom1, int arrayNr1, gsl_matrix *arrgeom2, int arrayNr2, gsl_matrix *arrgeom3, double azimuth1, double azimuth2, double azimuth3);
gsl_vector* getGCC_old(gsl_matrix_complex *spectralSample, double delta_f, gsl_vector *delays);
gsl_matrix* getLowerTriangMatrix(gsl_matrix* fullMatrix);
gsl_vector* getXi(gsl_matrix* D1_2);
class PhaseTransform {
public:
PhaseTransform(unsigned sz);
~PhaseTransform();
private:
gsl_vector_complex* _crossSpectrum;
double* _crossCorrelation;
};
class NoisePowerSpectrum
{
public:
NoisePowerSpectrum(double alpha = 0.95);
~NoisePowerSpectrum() {
if (powerSpectrum != NULL)
gsl_vector_free(powerSpectrum);
}
void setAlpha(double alpha) {
this->alpha = alpha;
alpha1 = 1 - alpha;
}
double getAlpha() { return alpha; }
void add(const gsl_vector_complex *noiseSpectrum, double timestamp);
const gsl_vector *get() {
return powerSpectrum;
}
private:
gsl_vector *powerSpectrum;
double alpha, alpha1;
double timestamp;
};
class NoiseCrossSpectrum
{
public:
NoiseCrossSpectrum(double alpha = 0.95);
~NoiseCrossSpectrum() {
if (crossSpectrum != NULL)
gsl_vector_complex_free(crossSpectrum);
}
void setAlpha(double alpha) {
this->alpha = alpha;
alpha1 = 1 - alpha;
}
double getAlpha() { return alpha; }
const gsl_vector_complex *get() {
return crossSpectrum;
}
void add(const gsl_vector_complex *noiseSpectrum1, const gsl_vector_complex *noiseSpectrum2);
private:
gsl_vector_complex *crossSpectrum;
double alpha, alpha1;
};
class GCC
{
public:
GCC(double sampleRate = 44100.0 , unsigned fftLen = 2048, unsigned nChan = 16, unsigned pairs = 6, double alpha = 0.95, double beta = 0.5, double q = 0.3, bool interpolate = true, bool noisereduction = true);
~GCC();
void calculate(const gsl_vector_complex *spectralSample1, unsigned chan1, const gsl_vector_complex *spectralSample2, unsigned chan2, unsigned pair, double timestamp, bool sad = false, bool smooth = true);
const gsl_vector* findMaximum(double minDelay = -HUGE_VAL, double maxDelay = HUGE_VAL);
double getPeakDelay() { return delay; }
double getPeakCorr() { return maxCorr; }
double getRatio() { return ratio; }
const gsl_vector* getNoisePowerSpectrum(unsigned chan) { return noisePowerSpectrum[chan].get(); }
const gsl_vector_complex* getNoiseCrossSpectrum(unsigned pair) { return noiseCrossSpectrum[pair].get(); }
const gsl_vector_complex* getCrossSpectrum() { return crossSpectrum; }
const gsl_vector* getCrossCorrelation() { return crossCorrelation; }
void setAlpha(double alpha) {
for(unsigned i=0; i < pairs; i++)
noiseCrossSpectrum[i].setAlpha(alpha);
for(unsigned i=0; i < nChan; i++)
noisePowerSpectrum[i].setAlpha(alpha);
}
double getAlpha() { return noiseCrossSpectrum[0].getAlpha(); }
protected:
virtual gsl_complex calcCrossSpectrumValue(gsl_complex x1, gsl_complex x2, const gsl_vector_complex* Gn1n2, const gsl_vector* N1, const gsl_vector* N2, unsigned i) { throw jdimension_error("Not implemented!!!\n"); };
//auxiliary variables
gsl_complex x1, x2, Gx1x2, Gs1s2, G;
double W1, W2, X1, X12, X2, X22;
double sampleRate;
unsigned fftLen;
unsigned fftLen2;
unsigned len;
unsigned nChan;
unsigned pairs;
unsigned delayPos;
double q, q1, q2, beta, beta1;
double ratio;
double delay;
double maxCorr;
double maxCorr2;
gsl_vector *crossCorrelation;
gsl_matrix *interpolValues;
gsl_vector* retValues;
gsl_vector *powerSpectrum1, *powerSpectrum2;
gsl_vector_complex *cSpectrum;
gsl_vector_complex *crossSpectrum;
NoisePowerSpectrum* noisePowerSpectrum;
NoiseCrossSpectrum* noiseCrossSpectrum;
bool noisereduction;
bool sad;
bool interpolate;
};
class GCCRaw : public GCC
{
public:
GCCRaw(double sampleRate = 44100.0 , unsigned fftLen = 2048, unsigned nChan = 16, unsigned pairs = 6, double alpha = 0.95, double beta = 0.5, double q = 0.3, bool interpolate = true, bool noisereduction = true) : GCC(sampleRate, fftLen, nChan, pairs, alpha, beta, q, interpolate, noisereduction) {};
protected:
gsl_complex calcCrossSpectrumValue(gsl_complex x1, gsl_complex x2, const gsl_vector_complex* Gn1n2, const gsl_vector* N1, const gsl_vector* N2, unsigned i);
};
class GCCGnnSub : public GCC
{
public:
GCCGnnSub(double sampleRate = 44100.0 , unsigned fftLen = 2048, unsigned nChan = 16, unsigned pairs = 6, double alpha = 0.95, double beta = 0.5, double q = 0.3, bool interpolate = true, bool noisereduction = true) : GCC(sampleRate, fftLen, nChan, pairs, alpha, beta, q, interpolate, noisereduction) {};
protected:
gsl_complex calcCrossSpectrumValue(gsl_complex x1, gsl_complex x2, const gsl_vector_complex* Gn1n2, const gsl_vector* N1, const gsl_vector* N2, unsigned i);
};
class GCCPhat : public GCC
{
public:
GCCPhat(double sampleRate = 44100.0 , unsigned fftLen = 2048, unsigned nChan = 16, unsigned pairs = 6, double alpha = 0.95, double beta = 0.5, double q = 0.3, bool interpolate = true, bool noisereduction = true) : GCC(sampleRate, fftLen, nChan, pairs, alpha, beta, q, interpolate, noisereduction) {};
protected:
gsl_complex calcCrossSpectrumValue(gsl_complex x1, gsl_complex x2, const gsl_vector_complex* Gn1n2, const gsl_vector* N1, const gsl_vector* N2, unsigned i);
};
class GCCGnnSubPhat : public GCC
{
public:
GCCGnnSubPhat(double sampleRate = 44100.0 , unsigned fftLen = 2048, unsigned nChan = 16, unsigned pairs = 6, double alpha = 0.95, double beta = 0.5, double q = 0.3, bool interpolate = true, bool noisereduction = true) : GCC(sampleRate, fftLen, nChan, pairs, alpha, beta, q, interpolate, noisereduction) {};
protected:
gsl_complex calcCrossSpectrumValue(gsl_complex x1, gsl_complex x2, const gsl_vector_complex* Gn1n2, const gsl_vector* N1, const gsl_vector* N2, unsigned i);
};
class GCCMLRRaw : public GCC
{
public:
GCCMLRRaw(double sampleRate = 44100.0 , unsigned fftLen = 2048, unsigned nChan = 16, unsigned pairs = 6, double alpha = 0.95, double beta = 0.5, double q = 0.3, bool interpolate = true, bool noisereduction = true) : GCC(sampleRate, fftLen, nChan, pairs, alpha, beta, q, interpolate, noisereduction) {};
protected:
gsl_complex calcCrossSpectrumValue(gsl_complex x1, gsl_complex x2, const gsl_vector_complex* Gn1n2, const gsl_vector* N1, const gsl_vector* N2, unsigned i);
};
class GCCMLRGnnSub : public GCC
{
public:
GCCMLRGnnSub(double sampleRate = 44100.0 , unsigned fftLen = 2048, unsigned nChan = 16, unsigned pairs = 6, double alpha = 0.95, double beta = 0.5, double q = 0.3, bool interpolate = true, bool noisereduction = true) : GCC(sampleRate, fftLen, nChan, pairs, alpha, beta, q, interpolate, noisereduction) {};
protected:
gsl_complex calcCrossSpectrumValue(gsl_complex x1, gsl_complex x2, const gsl_vector_complex* Gn1n2, const gsl_vector* N1, const gsl_vector* N2, unsigned i);
};
#endif
|
(* Title: HOL/Auth/n_flash_lemma_on_inv__116.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 n_flash Protocol Case Study*}
theory n_flash_lemma_on_inv__116 imports n_flash_base
begin
section{*All lemmas on causal relation between inv__116 and some rule r*}
lemma n_NI_Local_Get_Put_HeadVsinv__116:
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__116 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__116 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 "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Pending'')) (Const false))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck))))" in exI, auto) done
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__116:
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__116 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__116 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 "?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 "?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_1Vsinv__116:
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__116 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__116 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__116:
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__116 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__116 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__116:
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__116 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__116 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__116:
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__116 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__116 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__116:
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__116 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__116 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__116:
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__116 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__116 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__116:
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__116 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__116 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 "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_7__part__1Vsinv__116:
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__116 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__116 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 "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Local'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_7_NODE_Get__part__0Vsinv__116:
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__116 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__116 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 "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_7_NODE_Get__part__1Vsinv__116:
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__116 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__116 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 "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Local'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_8_HomeVsinv__116:
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__116 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__116 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 "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeShrSet'')) (Const true)))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_8_Home_NODE_GetVsinv__116:
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__116 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__116 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 "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeShrSet'')) (Const true)))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_8Vsinv__116:
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__116 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__116 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 "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
moreover {
assume b1: "(src~=p__Inv4\<and>pp~=p__Inv4)"
have "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_8_NODE_GetVsinv__116:
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__116 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__116 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 "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
moreover {
assume b1: "(src~=p__Inv4\<and>pp~=p__Inv4)"
have "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_9__part__0Vsinv__116:
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__116 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__116 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 "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_9__part__1Vsinv__116:
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__116 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__116 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 "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Pending'')) (Const false))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_10_HomeVsinv__116:
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__116 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__116 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 "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeShrSet'')) (Const true)))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_10Vsinv__116:
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__116 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__116 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 "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
moreover {
assume b1: "(src~=p__Inv4\<and>pp~=p__Inv4)"
have "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4)))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadVld'')) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_NI_Local_GetX_PutX_11Vsinv__116:
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__116 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__116 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_PutXVsinv__116:
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__116 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__116 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 "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''InvSet'') p__Inv4)) (Const true)) (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 have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>dst=p__Inv4)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''InvSet'') p__Inv4)) (Const true)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''Proc'') p__Inv4) ''CacheState'')) (Const CACHE_E))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(src~=p__Inv4\<and>dst~=p__Inv4)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''InvSet'') p__Inv4)) (Const true)) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') src) ''Cmd'')) (Const UNI_GetX))) (eqn (IVar (Field (Para (Field (Ident ''Sta'') ''UniMsg'') src) ''HomeProc'')) (Const false))))" in exI, auto) done
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_exists_HomeVsinv__116:
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__116 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_exists_Home src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__116 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_InvAck_existsVsinv__116:
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__116 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_InvAck_exists src pp" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__116 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 "?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>pp~=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__116:
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__116 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__116 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_InvAck_2Vsinv__116:
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__116 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_2 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__116 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_InvAck_3Vsinv__116:
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__116 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_3 N src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__116 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_ReplaceVsinv__116:
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__116 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_Replace src" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__116 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 "((formEval (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) s))\<or>((formEval (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) s))" by auto
moreover {
assume c1: "((formEval (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) s))"
have "?P1 s"
proof(cut_tac a1 a2 b1 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'') ''ShrVld'')) (Const true))) s))"
have "?P2 s"
proof(cut_tac a1 a2 b1 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately have "invHoldForRule s f r (invariants N)" by satx
}
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__116:
assumes a1: "(r=n_PI_Local_GetX_PutX_HeadVld__part__0 N )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 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__116 p__Inv4" apply fastforce done
have "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P3 s"
apply (cut_tac a1 a2 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Pending'')) (Const false))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) 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_GetX_PutX_HeadVld__part__1Vsinv__116:
assumes a1: "(r=n_PI_Local_GetX_PutX_HeadVld__part__1 N )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 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__116 p__Inv4" apply fastforce done
have "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))\<or>((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true)) (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) s))"
have "?P3 s"
apply (cut_tac a1 a2 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false))) s))"
have "?P3 s"
apply (cut_tac a1 a2 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Cmd'')) (Const SHWB_FAck)) (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''Pending'')) (Const false))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HeadPtr'')) (Const (index p__Inv4))))) s))"
have "?P1 s"
proof(cut_tac a1 a2 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''ShrVld'')) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true))) (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''Dir'') ''HomeHeadPtr'')) (Const false)))) 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_NI_FAckVsinv__116:
assumes a1: "(r=n_NI_FAck )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 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__116 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_ShWbVsinv__116:
assumes a1: "(r=n_NI_ShWb N )" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 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__116 p__Inv4" apply fastforce done
have "((formEval (andForm (eqn (Const (index p__Inv4)) (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Proc''))) (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''HomeProc'')) (Const false))) s))\<or>((formEval (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true)) s))\<or>((formEval (andForm (neg (eqn (Const (index p__Inv4)) (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Proc'')))) (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true)))) s))\<or>((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''HomeProc'')) (Const false))) (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true)))) s))" by auto
moreover {
assume c1: "((formEval (andForm (eqn (Const (index p__Inv4)) (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Proc''))) (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''HomeProc'')) (Const false))) s))"
have "?P1 s"
proof(cut_tac a1 a2 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true)) s))"
have "?P1 s"
proof(cut_tac a1 a2 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (Const (index p__Inv4)) (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''Proc'')))) (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (Const true)))) s))"
have "?P1 s"
proof(cut_tac a1 a2 c1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume c1: "((formEval (andForm (neg (eqn (IVar (Field (Field (Ident ''Sta'') ''ShWbMsg'') ''HomeProc'')) (Const false))) (neg (eqn (IVar (Para (Field (Field (Ident ''Sta'') ''Dir'') ''ShrSet'') p__Inv4)) (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_NI_Local_Get_Get__part__1Vsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Remote_GetX_PutX_HomeVsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Remote_GetVsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Local_GetX_PutX__part__0Vsinv__116:
assumes a1: "r=n_PI_Local_GetX_PutX__part__0 " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_WbVsinv__116:
assumes a1: "r=n_NI_Wb " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_StoreVsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Local_GetX_GetX__part__1Vsinv__116:
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__116 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__116:
assumes a1: "r=n_PI_Local_GetX_GetX__part__1 " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 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__116:
assumes a1: "r=n_PI_Local_GetX_GetX__part__0 " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Remote_ReplaceVsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_Store_HomeVsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Local_ReplaceVsinv__116:
assumes a1: "r=n_PI_Local_Replace " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Local_GetX_Nak__part__1Vsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Local_Get_Nak__part__1Vsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Local_Get_Get__part__0Vsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Local_GetX_Nak__part__2Vsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Remote_PutXVsinv__116:
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__116 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__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_InvVsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Local_PutXVsinv__116:
assumes a1: "r=n_PI_Local_PutX " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Local_Get_Nak__part__2Vsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Local_GetX_GetX__part__0Vsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Local_Get_PutVsinv__116:
assumes a1: "r=n_PI_Local_Get_Put " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 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__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Local_PutXAcksDoneVsinv__116:
assumes a1: "r=n_NI_Local_PutXAcksDone " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Remote_GetX_NakVsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_NakVsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Remote_GetXVsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Local_GetX_PutX__part__1Vsinv__116:
assumes a1: "r=n_PI_Local_GetX_PutX__part__1 " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 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__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Remote_PutXVsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Remote_PutVsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Local_Get_PutVsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Local_GetX_Nak__part__0Vsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Replace_HomeVsinv__116:
assumes a1: "r=n_NI_Replace_Home " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Local_PutVsinv__116:
assumes a1: "r=n_NI_Local_Put " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Remote_Get_NakVsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Nak_ClearVsinv__116:
assumes a1: "r=n_NI_Nak_Clear " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Local_Get_Put_DirtyVsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Local_Get_Nak__part__0Vsinv__116:
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__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_PI_Local_Get_GetVsinv__116:
assumes a1: "r=n_PI_Local_Get_Get " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_NI_Nak_HomeVsinv__116:
assumes a1: "r=n_NI_Nak_Home " and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__116 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
end
|
module KRLS
using LinearAlgebra
include("kernel.jl")
include("filter.jl")
include("sim_env.jl")
end # module
|
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Instance.LawvereTheories where
-- Category of Lawvere Theories
open import Level
open import Categories.Category.Core using (Category)
open import Categories.Functor.Cartesian using (CartesianF)
open import Categories.NaturalTransformation.NaturalIsomorphism
using (_≃_; associator; sym-associator; unitorˡ; unitorʳ; unitor²; refl; sym; trans; _ⓘₕ_)
open import Categories.Theory.Lawvere using (LawvereTheory; LT-Hom; LT-id; LT-∘)
LawvereTheories : (ℓ e : Level) → Category (suc (ℓ ⊔ e)) (ℓ ⊔ e) (ℓ ⊔ e)
LawvereTheories ℓ e = record
{ Obj = LawvereTheory ℓ e
; _⇒_ = LT-Hom
; _≈_ = λ H₁ H₂ → cartF.F H₁ ≃ cartF.F H₂
; id = LT-id
; _∘_ = LT-∘
; assoc = λ { {f = f} {g} {h} → associator (cartF.F f) (cartF.F g) (cartF.F h) }
; sym-assoc = λ { {f = f} {g} {h} → sym-associator (cartF.F f) (cartF.F g) (cartF.F h) }
; identityˡ = unitorˡ
; identityʳ = unitorʳ
; identity² = unitor²
; equiv = record { refl = refl ; sym = sym ; trans = trans }
; ∘-resp-≈ = _ⓘₕ_
}
where open LT-Hom
|
[STATEMENT]
lemma inv1_rbt_baliL: "inv1l l \<Longrightarrow> inv1 r \<Longrightarrow> inv1 (rbt_baliL l a b r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>inv1l l; inv1 r\<rbrakk> \<Longrightarrow> inv1 (rbt_baliL l a b r)
[PROOF STEP]
by (induct l a b r rule: rbt_baliL.induct) auto |
If $h$ is a bilinear function, then there exists a constant $B$ such that for all $x$ and $y$, we have $|h(x,y)| \leq B|x| |y|$. |
/*
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#include <boost/algorithm/string/trim.hpp>
#include <osquery/filesystem.h>
#include <osquery/tables.h>
#include "osquery/tables/system/sysctl_utils.h"
namespace osquery {
namespace tables {
const std::vector<std::string> kControlSettingsFiles = {"/etc/sysctl.conf"};
const std::vector<std::string> kControlSettingsDirs = {
"/run/sysctl.d/%.conf",
"/etc/sysctl.d/%.conf",
"/usr/local/lib/sysctl.d/%.conf",
"/usr/lib/sysctl.d/%.conf",
"/lib/sysctl.d/%.conf",
};
std::string stringFromMIB(const int* oid, size_t oid_size) {
std::string result;
for (size_t i = 0; i < oid_size; ++i) {
// Walk an int-encoded MIB and return the string representation, '.'.
if (result.size() > 0) {
result += ".";
}
result += std::to_string(oid[i]);
}
return result;
}
void genControlInfoFromOIDString(
const std::string& oid_string,
QueryData& results,
const std::map<std::string, std::string>& config) {
int request[CTL_DEBUG_MAXID + 2] = {0};
auto tokens = osquery::split(oid_string, ".");
if (tokens.size() > CTL_DEBUG_MAXID) {
// OID input string was too large.
return;
}
// Convert the string into an int array.
for (size_t i = 0; i < tokens.size(); ++i) {
request[i] = atol(tokens.at(i).c_str());
}
genControlInfo((int*)request, tokens.size(), results, config);
}
void genControlConfigFromPath(const std::string& path,
std::map<std::string, std::string>& config) {
std::string content;
if (!osquery::readFile(path, content).ok()) {
return;
}
for (auto& line : split(content, "\n")) {
boost::trim(line);
if (line[0] == '#' || line[0] == ';') {
continue;
}
// Try to tokenize the config line using '='.
auto detail = split(line, "=");
if (detail.size() == 2) {
boost::trim(detail[0]);
boost::trim(detail[1]);
config[detail[0]] = detail[1];
}
}
}
QueryData genSystemControls(QueryContext& context) {
QueryData results;
// Read the sysctl.conf values.
std::map<std::string, std::string> config;
for (const auto& path : kControlSettingsFiles) {
genControlConfigFromPath(path, config);
}
for (const auto& dirs : kControlSettingsDirs) {
std::vector<std::string> configs;
if (resolveFilePattern(dirs, configs).ok()) {
for (const auto& path : configs) {
genControlConfigFromPath(path, config);
}
}
}
// Iterate through the sysctl-defined macro of control types.
if (context.constraints["name"].exists(EQUALS)) {
// Request MIB information by the description (name).
auto names = context.constraints["name"].getAll(EQUALS);
for (const auto& name : names) {
genControlInfoFromName(name, results, config);
}
} else if (context.constraints["oid"].exists(EQUALS)) {
// Request MIB by OID as a string, parse into set of INTs.
auto oids = context.constraints["oid"].getAll(EQUALS);
for (const auto& oid_string : oids) {
genControlInfoFromOIDString(oid_string, results, config);
}
} else if (context.constraints["subsystem"].exists(EQUALS)) {
// Limit the MIB search to a subsystem name (first find the INT).
auto subsystems = context.constraints["subsystem"].getAll(EQUALS);
for (const auto& subsystem : subsystems) {
genAllControls(results, config, subsystem);
}
} else {
genAllControls(results, config, "");
}
return results;
}
}
}
|
/- Lemmas for tail, and a total tail function. -/
import data.vector
import ..list.tail
universe variables u
namespace vector
variable {α : Type u}
variable {n : ℕ}
@[simp]
theorem to_list_tail (v : vector α (nat.succ n)) : to_list (tail v) = list.tail (to_list v) :=
begin
cases v,
cases val,
contradiction,
simp [ tail ],
end
-- Extends tail to work over total functions
def total_tail : vector α n → vector α (n - 1)
| ⟨ v, h ⟩ := ⟨ list.tail v, eq.trans (list.length_tail v) (congr_arg (λ x, x - 1) h) ⟩
@[simp]
theorem to_list_total_tail (v : vector α n) : to_list (total_tail v) = list.tail (to_list v) :=
begin
cases v,
simp [ total_tail ],
end
end vector
|
% time varying Rayleigh flat fading channel with Clark's model
% using filter method
% Ns number of channel samples
% fDTs: fD*Ts doppler spread fD*Ts
% fdTs= .001 slow, .01 medioum, .03 fast
function out=flat_filter(Ns,fD,fDTs)
% parameters
Ts=fDTs/fD;
% filter window length at least three side lobs
Ng=ceil(2/fDTs);
% Complex Gaussian input
x=cxn(Ns,1);
% compute g(t) and g_hat(t)
t=(-Ng:Ng)*Ts;
g=besselj(1/4,2*pi*fD*abs(t))./((abs(t)).^(1/4));
g(Ng+1)=((pi*fD)^(1/4))/gamma(5/4);
%verify filter
%plot(abs(g));
% compute K such that ...
g_hat=g./sqrt(sum(g.^2));
% verify K
%sum_g_hat=sum(g_hat.^2);
% channel impulse response
cn=conv(x,g_hat)*Ts;
% reject transient
cn=cn(2*Ng+1:length(cn)-2*Ng);
out=cn/sqrt(var(cn));
end |
import data.pnat.prime
import tactic.linarith
open nat
/-
This code outlines formalizes the proofs in Chapter 1 of Hardy and Wright's "An Introduction to the Theory of Numbers".
Where availible, the theorems are proven using tools directly availible in mathlib.
-/
/-
Theorem 1: Every positive integer, except 1, is a product of primes.
-/
theorem product_of_primes {n : ℕ} (hn : nat.prime n) : n.factors = [n] :=
begin
exact nat.factors_prime hn,
end
/-
Theorem 2: (The Fundamental Theorem of Arithmetic) The standard form of n is unique;
apart from rearrangement of factors, n can be expressed as a product of primes in only
one way.
-/
theorem fundamental_theorem_aritihmetic {n : ℕ} {l : list ℕ} (h₁ : l.prod = n) (h₂ : ∀ (p : ℕ), p ∈ l → nat.prime p) : l ~ n.factors :=
begin
exact nat.factors_unique h₁ h₂,
end
/-
Theorem 3: (Euclid's First Theorem) If p is prime, and p|ab, then p|a or p|b.
-/
theorem euclid_first {p a b : ℕ} (q : nat.prime p) : p ∣ a * b → p ∣ a ∨ p ∣ b :=
begin
exact (nat.prime.dvd_mul q).mp,
end
/-
Theorem 4: (Euclid's Second Theorem) The number of primes is infinite.
-/
theorem euclid_second : ∀ N, ∃ p ≥ N, prime p :=
begin
intro N,
let M := factorial N + 1,
let p := min_fac M,
have pp : prime p :=
begin
refine min_fac_prime _,
have : factorial N > 0 := factorial_pos N,
linarith,
end,
use p,
split,
{
by_contradiction,
have h1 : p ∣ factorial N + 1 := min_fac_dvd M,
have h2 : p ∣ factorial N :=
begin
refine pp.dvd_factorial.mpr _,
exact le_of_not_ge h,
end,
have h : p ∣ 1 := (nat.dvd_add_right h2).mp h1,
exact prime.not_dvd_one pp h,
},
{
exact pp,
},
end -- This proof follows from the Lean Prover Demo (https://youtu.be/b59fpAJ8Mfs)
/-
Theorem 5: There are blocks of consecutive composite numbers whose length exceeds any given number N.
This theorem is stated without proof in Chapter 1.
Theorem 6: (The Prime Number Theorem) The number of primes not exceeding x is asymptotic to x/log(x).
This theorem is stated without proof in Chapter 1. We formalize the proof in Chapter 22.
Theorem 7: (Tchebychef's Theorem) The order of magnitude of n(x) is x/log(x).
This theorem is stated without proof in Chapter 1.
Theorem 8: p_n is asymptotic to n log(n).
This theorem is stated without proof in Chapter 1.
Theorem 9: The order of magnitude of p_n is n log(n).
This theorem is stated without proof in Chapter 1.
-/
|
open import Oscar.Prelude
open import Oscar.Class.IsPrefunctor
open import Oscar.Class.Smap
open import Oscar.Class.Surjection
open import Oscar.Class.Transitivity
module Oscar.Class.Prefunctor where
record Prefunctor 𝔬₁ 𝔯₁ ℓ₁ 𝔬₂ 𝔯₂ ℓ₂ : Ø ↑̂ (𝔬₁ ∙̂ 𝔯₁ ∙̂ ℓ₁ ∙̂ 𝔬₂ ∙̂ 𝔯₂ ∙̂ ℓ₂) where
constructor ∁
field
{𝔒₁} : Ø 𝔬₁
_∼₁_ : 𝔒₁ → 𝔒₁ → Ø 𝔯₁
_∼̇₁_ : ∀ {x y} → x ∼₁ y → x ∼₁ y → Ø ℓ₁
_↦₁_ : Transitivity.type _∼₁_
{𝔒₂} : Ø 𝔬₂
_∼₂_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂
_∼̇₂_ : ∀ {x y} → x ∼₂ y → x ∼₂ y → Ø ℓ₂
_↦₂_ : Transitivity.type _∼₂_
{μ} : Surjection.type 𝔒₁ 𝔒₂
prefunctor-smap : Smap.type _∼₁_ _∼₂_ μ μ
⦃ `IsPrefunctor ⦄ : IsPrefunctor _∼₁_ _∼̇₁_ _↦₁_ _∼₂_ _∼̇₂_ _↦₂_ prefunctor-smap
|
------------------------------------------------------------------------
-- Some algebraic structures (not packed up with sets, operations,
-- etc.)
------------------------------------------------------------------------
open import Relation.Binary
module Algebra.Structures where
import Algebra.FunctionProperties as FunctionProperties
open FunctionProperties using (Op₁; Op₂)
import Relation.Binary.EqReasoning as EqR
open import Data.Function
open import Data.Product
------------------------------------------------------------------------
-- One binary operation
record IsSemigroup {A} (≈ : Rel A) (∙ : Op₂ A) : Set where
open FunctionProperties ≈
field
isEquivalence : IsEquivalence ≈
assoc : Associative ∙
∙-pres-≈ : ∙ Preserves₂ ≈ ⟶ ≈ ⟶ ≈
open IsEquivalence isEquivalence public
record IsMonoid {A} (≈ : Rel A) (∙ : Op₂ A) (ε : A) : Set where
open FunctionProperties ≈
field
isSemigroup : IsSemigroup ≈ ∙
identity : Identity ε ∙
open IsSemigroup isSemigroup public
record IsCommutativeMonoid
{A} (≈ : Rel A) (∙ : Op₂ A) (ε : A) : Set where
open FunctionProperties ≈
field
isMonoid : IsMonoid ≈ ∙ ε
comm : Commutative ∙
open IsMonoid isMonoid public
record IsGroup
{A} (≈ : Rel A) (_∙_ : Op₂ A) (ε : A) (_⁻¹ : Op₁ A) : Set where
open FunctionProperties ≈
infixl 7 _-_
field
isMonoid : IsMonoid ≈ _∙_ ε
inverse : Inverse ε _⁻¹ _∙_
⁻¹-pres-≈ : _⁻¹ Preserves ≈ ⟶ ≈
open IsMonoid isMonoid public
_-_ : Op₂ A
x - y = x ∙ (y ⁻¹)
record IsAbelianGroup
{A} (≈ : Rel A) (∙ : Op₂ A) (ε : A) (⁻¹ : Op₁ A) : Set where
open FunctionProperties ≈
field
isGroup : IsGroup ≈ ∙ ε ⁻¹
comm : Commutative ∙
open IsGroup isGroup public
isCommutativeMonoid : IsCommutativeMonoid ≈ ∙ ε
isCommutativeMonoid = record
{ isMonoid = isMonoid
; comm = comm
}
------------------------------------------------------------------------
-- Two binary operations
record IsNearSemiring {A} (≈ : Rel A) (+ * : Op₂ A) (0# : A) : Set where
open FunctionProperties ≈
field
+-isMonoid : IsMonoid ≈ + 0#
*-isSemigroup : IsSemigroup ≈ *
distribʳ : * DistributesOverʳ +
zeroˡ : LeftZero 0# *
open IsMonoid +-isMonoid public
renaming ( assoc to +-assoc
; ∙-pres-≈ to +-pres-≈
; isSemigroup to +-isSemigroup
; identity to +-identity
)
open IsSemigroup *-isSemigroup public
using ()
renaming ( assoc to *-assoc
; ∙-pres-≈ to *-pres-≈
)
record IsSemiringWithoutOne
{A} (≈ : Rel A) (+ * : Op₂ A) (0# : A) : Set where
open FunctionProperties ≈
field
+-isCommutativeMonoid : IsCommutativeMonoid ≈ + 0#
*-isSemigroup : IsSemigroup ≈ *
distrib : * DistributesOver +
zero : Zero 0# *
open IsCommutativeMonoid +-isCommutativeMonoid public
renaming ( assoc to +-assoc
; ∙-pres-≈ to +-pres-≈
; isSemigroup to +-isSemigroup
; identity to +-identity
; isMonoid to +-isMonoid
; comm to +-comm
)
open IsSemigroup *-isSemigroup public
using ()
renaming ( assoc to *-assoc
; ∙-pres-≈ to *-pres-≈
)
isNearSemiring : IsNearSemiring ≈ + * 0#
isNearSemiring = record
{ +-isMonoid = +-isMonoid
; *-isSemigroup = *-isSemigroup
; distribʳ = proj₂ distrib
; zeroˡ = proj₁ zero
}
record IsSemiringWithoutAnnihilatingZero
{A} (≈ : Rel A) (+ * : Op₂ A) (0# 1# : A) : Set where
open FunctionProperties ≈
field
-- Note that these structures do have an additive unit, but this
-- unit does not necessarily annihilate multiplication.
+-isCommutativeMonoid : IsCommutativeMonoid ≈ + 0#
*-isMonoid : IsMonoid ≈ * 1#
distrib : * DistributesOver +
open IsCommutativeMonoid +-isCommutativeMonoid public
renaming ( assoc to +-assoc
; ∙-pres-≈ to +-pres-≈
; isSemigroup to +-isSemigroup
; identity to +-identity
; isMonoid to +-isMonoid
; comm to +-comm
)
open IsMonoid *-isMonoid public
using ()
renaming ( assoc to *-assoc
; ∙-pres-≈ to *-pres-≈
; isSemigroup to *-isSemigroup
; identity to *-identity
)
record IsSemiring {A} (≈ : Rel A) (+ * : Op₂ A) (0# 1# : A) : Set where
open FunctionProperties ≈
field
isSemiringWithoutAnnihilatingZero :
IsSemiringWithoutAnnihilatingZero ≈ + * 0# 1#
zero : Zero 0# *
open IsSemiringWithoutAnnihilatingZero
isSemiringWithoutAnnihilatingZero public
isSemiringWithoutOne : IsSemiringWithoutOne ≈ + * 0#
isSemiringWithoutOne = record
{ +-isCommutativeMonoid = +-isCommutativeMonoid
; *-isSemigroup = *-isSemigroup
; distrib = distrib
; zero = zero
}
open IsSemiringWithoutOne isSemiringWithoutOne public
using (isNearSemiring)
record IsCommutativeSemiringWithoutOne
{A} (≈ : Rel A) (+ * : Op₂ A) (0# : A) : Set where
open FunctionProperties ≈
field
isSemiringWithoutOne : IsSemiringWithoutOne ≈ + * 0#
*-comm : Commutative *
open IsSemiringWithoutOne isSemiringWithoutOne public
record IsCommutativeSemiring
{A} (≈ : Rel A) (+ * : Op₂ A) (0# 1# : A) : Set where
open FunctionProperties ≈
field
isSemiring : IsSemiring ≈ + * 0# 1#
*-comm : Commutative *
open IsSemiring isSemiring public
*-isCommutativeMonoid : IsCommutativeMonoid ≈ * 1#
*-isCommutativeMonoid = record
{ isMonoid = *-isMonoid
; comm = *-comm
}
isCommutativeSemiringWithoutOne :
IsCommutativeSemiringWithoutOne ≈ + * 0#
isCommutativeSemiringWithoutOne = record
{ isSemiringWithoutOne = isSemiringWithoutOne
; *-comm = *-comm
}
record IsRing {A} (≈ : Rel A)
(_+_ _*_ : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set where
open FunctionProperties ≈
field
+-isAbelianGroup : IsAbelianGroup ≈ _+_ 0# -_
*-isMonoid : IsMonoid ≈ _*_ 1#
distrib : _*_ DistributesOver _+_
open IsAbelianGroup +-isAbelianGroup public
renaming ( assoc to +-assoc
; ∙-pres-≈ to +-pres-≈
; isSemigroup to +-isSemigroup
; identity to +-identity
; isMonoid to +-isMonoid
; inverse to -‿inverse
; ⁻¹-pres-≈ to -‿pres-≈
; isGroup to +-isGroup
; comm to +-comm
; isCommutativeMonoid to +-isCommutativeMonoid
)
open IsMonoid *-isMonoid public
using ()
renaming ( assoc to *-assoc
; ∙-pres-≈ to *-pres-≈
; isSemigroup to *-isSemigroup
; identity to *-identity
)
zero : Zero 0# _*_
zero = (zeroˡ , zeroʳ)
where
open EqR (record { isEquivalence = isEquivalence })
zeroˡ : LeftZero 0# _*_
zeroˡ x = begin
0# * x ≈⟨ sym $ proj₂ +-identity _ ⟩
(0# * x) + 0# ≈⟨ refl ⟨ +-pres-≈ ⟩ sym (proj₂ -‿inverse _) ⟩
(0# * x) + ((0# * x) + - (0# * x)) ≈⟨ sym $ +-assoc _ _ _ ⟩
((0# * x) + (0# * x)) + - (0# * x) ≈⟨ sym (proj₂ distrib _ _ _) ⟨ +-pres-≈ ⟩ refl ⟩
((0# + 0#) * x) + - (0# * x) ≈⟨ (proj₂ +-identity _ ⟨ *-pres-≈ ⟩ refl)
⟨ +-pres-≈ ⟩
refl ⟩
(0# * x) + - (0# * x) ≈⟨ proj₂ -‿inverse _ ⟩
0# ∎
zeroʳ : RightZero 0# _*_
zeroʳ x = begin
x * 0# ≈⟨ sym $ proj₂ +-identity _ ⟩
(x * 0#) + 0# ≈⟨ refl ⟨ +-pres-≈ ⟩ sym (proj₂ -‿inverse _) ⟩
(x * 0#) + ((x * 0#) + - (x * 0#)) ≈⟨ sym $ +-assoc _ _ _ ⟩
((x * 0#) + (x * 0#)) + - (x * 0#) ≈⟨ sym (proj₁ distrib _ _ _) ⟨ +-pres-≈ ⟩ refl ⟩
(x * (0# + 0#)) + - (x * 0#) ≈⟨ (refl ⟨ *-pres-≈ ⟩ proj₂ +-identity _)
⟨ +-pres-≈ ⟩
refl ⟩
(x * 0#) + - (x * 0#) ≈⟨ proj₂ -‿inverse _ ⟩
0# ∎
isSemiringWithoutAnnihilatingZero
: IsSemiringWithoutAnnihilatingZero ≈ _+_ _*_ 0# 1#
isSemiringWithoutAnnihilatingZero = record
{ +-isCommutativeMonoid = +-isCommutativeMonoid
; *-isMonoid = *-isMonoid
; distrib = distrib
}
isSemiring : IsSemiring ≈ _+_ _*_ 0# 1#
isSemiring = record
{ isSemiringWithoutAnnihilatingZero =
isSemiringWithoutAnnihilatingZero
; zero = zero
}
open IsSemiring isSemiring public
using (isNearSemiring; isSemiringWithoutOne)
record IsCommutativeRing {A}
(≈ : Rel A) (+ * : Op₂ A) (- : Op₁ A) (0# 1# : A) : Set where
open FunctionProperties ≈
field
isRing : IsRing ≈ + * - 0# 1#
*-comm : Commutative *
open IsRing isRing public
isCommutativeSemiring : IsCommutativeSemiring ≈ + * 0# 1#
isCommutativeSemiring = record
{ isSemiring = isSemiring
; *-comm = *-comm
}
open IsCommutativeSemiring isCommutativeSemiring public
using (isCommutativeSemiringWithoutOne)
record IsLattice {A} (≈ : Rel A) (∨ ∧ : Op₂ A) : Set where
open FunctionProperties ≈
field
isEquivalence : IsEquivalence ≈
∨-comm : Commutative ∨
∨-assoc : Associative ∨
∨-pres-≈ : ∨ Preserves₂ ≈ ⟶ ≈ ⟶ ≈
∧-comm : Commutative ∧
∧-assoc : Associative ∧
∧-pres-≈ : ∧ Preserves₂ ≈ ⟶ ≈ ⟶ ≈
absorptive : Absorptive ∨ ∧
open IsEquivalence isEquivalence public
record IsDistributiveLattice {A} (≈ : Rel A) (∨ ∧ : Op₂ A) : Set where
open FunctionProperties ≈
field
isLattice : IsLattice ≈ ∨ ∧
∨-∧-distribʳ : ∨ DistributesOverʳ ∧
open IsLattice isLattice public
record IsBooleanAlgebra
{A} (≈ : Rel A) (∨ ∧ : Op₂ A) (¬ : Op₁ A) (⊤ ⊥ : A) : Set where
open FunctionProperties ≈
field
isDistributiveLattice : IsDistributiveLattice ≈ ∨ ∧
∨-complementʳ : RightInverse ⊤ ¬ ∨
∧-complementʳ : RightInverse ⊥ ¬ ∧
¬-pres-≈ : ¬ Preserves ≈ ⟶ ≈
open IsDistributiveLattice isDistributiveLattice public
|
(* This program is free software; you can redistribute it and/or *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1 *)
(* 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 Lesser General Public *)
(* License along with this program; if not, write to the Free *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA *)
(*****************************************************************************)
(* Projet Formel - Calculus of Inductive Constructions V5.10 *)
(*****************************************************************************)
(* *)
(* CoUniversal Arrows *)
(* *)
(*****************************************************************************)
(* *)
(* A.SAIBI May 95 *)
(* *)
(*****************************************************************************)
Require Export UniversalArrow.
Require Export Dual_Functor.
Set Implicit Arguments.
Unset Strict Implicit.
(* coUA *)
Section coua_def.
Variables (A B : Category) (b : B) (F : Functor A B).
Section iscoua_def.
Variables (a : A) (u : F a --> b).
Section coua_laws.
Variable co_diese : forall a' : A, (F a' --> b) -> (a' --> a).
Definition CoUA_eq (a' : A) (f : F a' --> b) (g : a' --> a) :=
FMor F g o u =_S f.
Definition CoUA_law1 :=
forall (a' : A) (f : F a' --> b), CoUA_eq f (co_diese f).
Definition CoUA_law2 :=
forall (a' : A) (f : F a' --> b) (g : a' --> a),
CoUA_eq f g -> g =_S co_diese f.
End coua_laws.
Structure IsCoUA : Type :=
{CoUA_diese : forall a' : A, (F a' --> b) -> (a' --> a);
Prf_isCoUA_law1 : CoUA_law1 CoUA_diese;
Prf_isCoUA_law2 : CoUA_law2 CoUA_diese}.
Variable t : IsCoUA.
(* f=g => f# = g# *)
Lemma Codiese_map : forall a' : A, Map_law (CoUA_diese t (a':=a')).
Proof.
intros a'.
unfold Map_law in |- *; intros f g H.
apply (Prf_isCoUA_law2 t (f:=g) (g:=CoUA_diese t f)).
unfold CoUA_eq in |- *.
(* *) apply Trans with f.
apply (Prf_isCoUA_law1 t f).
assumption.
Qed.
End iscoua_def.
Structure > CoUA : Type :=
{CoUA_ob : A; CoUA_mor : F CoUA_ob --> b; Prf_IsCoUA :> IsCoUA CoUA_mor}.
(*** rewrite rules ***)
Lemma CoUA_diag :
forall (u : CoUA) (a' : A) (f : F a' --> b),
FMor F (CoUA_diese u f) o CoUA_mor u =_S f.
Proof.
intros u a' f; exact (Prf_isCoUA_law1 (u:=CoUA_mor u) u f).
Qed.
Lemma CoUA_diag1 :
forall (u : CoUA) (a' : A) (f : F a' --> b),
f =_S FMor F (CoUA_diese u f) o CoUA_mor u.
Proof.
intros u a' f; apply Sym; apply CoUA_diag.
Qed.
Lemma CoUA_unic :
forall (u : CoUA) (a' : A) (f : F a' --> b) (g : a' --> CoUA_ob u),
FMor F g o CoUA_mor u =_S f -> g =_S CoUA_diese u f.
Proof.
intros u a' f g; exact (Prf_isCoUA_law2 u (f:=f) (g:=g)).
Qed.
Lemma CoUA_unic1 :
forall (u : CoUA) (a' : A) (f : F a' --> b) (g : a' --> CoUA_ob u),
FMor F g o CoUA_mor u =_S f -> CoUA_diese u f =_S g.
Proof.
intros u a' f g H; apply Sym; apply CoUA_unic; exact H.
Qed.
(* *)
End coua_def.
(* 2nd def : par dualite' *)
Section coua_def1.
Variables (A B : Category) (b : B) (F : Functor A B).
Section iscoua_def1.
Variables (a : A) (u : F a --> b).
Definition IsCoUA1 := IsUA (G:=Dfunctor F) u.
Variable u1 : IsCoUA1.
Definition CoUA1_diese (a' : A) (f : F a' --> b) := UA_diese u1 f.
Lemma Prf_isCoUA1_law1 : CoUA_law1 u CoUA1_diese.
Proof.
unfold CoUA_law1, CoUA_eq in |- *; intros a' f.
unfold CoUA1_diese in |- *.
exact (Prf_isUA_law1 u1 f).
Qed.
Lemma Prf_isCoUA1_law2 : CoUA_law2 u CoUA1_diese.
Proof.
unfold CoUA_law2, CoUA_eq in |- *; intros a' f g H.
unfold CoUA1_diese in |- *.
apply (Prf_isUA_law2 u1 H).
Qed.
Lemma IsCoUA1_to_IsCoUA : IsCoUA u.
Proof.
exact (Build_IsCoUA Prf_isCoUA1_law1 Prf_isCoUA1_law2).
Defined.
End iscoua_def1.
Coercion IsCoUA1_to_IsCoUA : IsCoUA1 >-> IsCoUA.
Definition CoUA1 := UA (b:Ob (Dual B)) (Dfunctor F).
Variable u1 : CoUA1.
Definition CoUA1_to_CoUA := Build_CoUA (IsCoUA1_to_IsCoUA (Prf_IsUA u1)).
End coua_def1.
Coercion CoUA1_to_CoUA : CoUA1 >-> CoUA.
|
State Before: α : Type u_1
β : Type ?u.11
L : List (List α)
f : List α
⊢ f ∈ sections L ↔ Forall₂ (fun x x_1 => x ∈ x_1) f L State After: case refine'_1
α : Type u_1
β : Type ?u.11
L : List (List α)
f : List α
h : f ∈ sections L
⊢ Forall₂ (fun x x_1 => x ∈ x_1) f L
case refine'_2
α : Type u_1
β : Type ?u.11
L : List (List α)
f : List α
h : Forall₂ (fun x x_1 => x ∈ x_1) f L
⊢ f ∈ sections L Tactic: refine' ⟨fun h => _, fun h => _⟩ State Before: case refine'_1
α : Type u_1
β : Type ?u.11
L : List (List α)
f : List α
h : f ∈ sections L
⊢ Forall₂ (fun x x_1 => x ∈ x_1) f L State After: case refine'_1.nil
α : Type u_1
β : Type ?u.11
f : List α
h : f ∈ sections []
⊢ Forall₂ (fun x x_1 => x ∈ x_1) f []
case refine'_1.cons
α : Type u_1
β : Type ?u.11
head✝ : List α
tail✝ : List (List α)
tail_ih✝ : ∀ {f : List α}, f ∈ sections tail✝ → Forall₂ (fun x x_1 => x ∈ x_1) f tail✝
f : List α
h : f ∈ sections (head✝ :: tail✝)
⊢ Forall₂ (fun x x_1 => x ∈ x_1) f (head✝ :: tail✝) Tactic: induction L generalizing f State Before: case refine'_1.cons
α : Type u_1
β : Type ?u.11
head✝ : List α
tail✝ : List (List α)
tail_ih✝ : ∀ {f : List α}, f ∈ sections tail✝ → Forall₂ (fun x x_1 => x ∈ x_1) f tail✝
f : List α
h : f ∈ sections (head✝ :: tail✝)
⊢ Forall₂ (fun x x_1 => x ∈ x_1) f (head✝ :: tail✝) State After: case refine'_1.cons
α : Type u_1
β : Type ?u.11
head✝ : List α
tail✝ : List (List α)
tail_ih✝ : ∀ {f : List α}, f ∈ sections tail✝ → Forall₂ (fun x x_1 => x ∈ x_1) f tail✝
f : List α
h : ∃ a, a ∈ sections tail✝ ∧ ∃ a_1, a_1 ∈ head✝ ∧ a_1 :: a = f
⊢ Forall₂ (fun x x_1 => x ∈ x_1) f (head✝ :: tail✝) Tactic: simp only [sections, bind_eq_bind, mem_bind, mem_map] at h State Before: case refine'_1.cons
α : Type u_1
β : Type ?u.11
head✝ : List α
tail✝ : List (List α)
tail_ih✝ : ∀ {f : List α}, f ∈ sections tail✝ → Forall₂ (fun x x_1 => x ∈ x_1) f tail✝
f : List α
h : ∃ a, a ∈ sections tail✝ ∧ ∃ a_1, a_1 ∈ head✝ ∧ a_1 :: a = f
⊢ Forall₂ (fun x x_1 => x ∈ x_1) f (head✝ :: tail✝) State After: case refine'_1.cons.intro.intro.intro.intro
α : Type u_1
β : Type ?u.11
head✝ : List α
tail✝ : List (List α)
tail_ih✝ : ∀ {f : List α}, f ∈ sections tail✝ → Forall₂ (fun x x_1 => x ∈ x_1) f tail✝
w✝¹ : List α
left✝¹ : w✝¹ ∈ sections tail✝
w✝ : α
left✝ : w✝ ∈ head✝
⊢ Forall₂ (fun x x_1 => x ∈ x_1) (w✝ :: w✝¹) (head✝ :: tail✝) Tactic: rcases h with ⟨_, _, _, _, rfl⟩ State Before: case refine'_1.cons.intro.intro.intro.intro
α : Type u_1
β : Type ?u.11
head✝ : List α
tail✝ : List (List α)
tail_ih✝ : ∀ {f : List α}, f ∈ sections tail✝ → Forall₂ (fun x x_1 => x ∈ x_1) f tail✝
w✝¹ : List α
left✝¹ : w✝¹ ∈ sections tail✝
w✝ : α
left✝ : w✝ ∈ head✝
⊢ Forall₂ (fun x x_1 => x ∈ x_1) (w✝ :: w✝¹) (head✝ :: tail✝) State After: no goals Tactic: simp only [*, forall₂_cons, true_and_iff] State Before: case refine'_1.nil
α : Type u_1
β : Type ?u.11
f : List α
h : f ∈ sections []
⊢ Forall₂ (fun x x_1 => x ∈ x_1) f [] State After: case refine'_1.nil.refl
α : Type u_1
β : Type ?u.11
h : [] ∈ sections []
⊢ Forall₂ (fun x x_1 => x ∈ x_1) [] [] Tactic: cases mem_singleton.1 h State Before: case refine'_1.nil.refl
α : Type u_1
β : Type ?u.11
h : [] ∈ sections []
⊢ Forall₂ (fun x x_1 => x ∈ x_1) [] [] State After: no goals Tactic: exact Forall₂.nil State Before: case refine'_2
α : Type u_1
β : Type ?u.11
L : List (List α)
f : List α
h : Forall₂ (fun x x_1 => x ∈ x_1) f L
⊢ f ∈ sections L State After: case refine'_2.nil
α : Type u_1
β : Type ?u.11
L : List (List α)
f : List α
⊢ [] ∈ sections []
case refine'_2.cons
α : Type u_1
β : Type ?u.11
L✝ : List (List α)
f✝ : List α
a : α
l f : List α
L : List (List α)
al : a ∈ l
fL : Forall₂ (fun x x_1 => x ∈ x_1) f L
fs : f ∈ sections L
⊢ a :: f ∈ sections (l :: L) Tactic: induction' h with a l f L al fL fs State Before: case refine'_2.cons
α : Type u_1
β : Type ?u.11
L✝ : List (List α)
f✝ : List α
a : α
l f : List α
L : List (List α)
al : a ∈ l
fL : Forall₂ (fun x x_1 => x ∈ x_1) f L
fs : f ∈ sections L
⊢ a :: f ∈ sections (l :: L) State After: case refine'_2.cons
α : Type u_1
β : Type ?u.11
L✝ : List (List α)
f✝ : List α
a : α
l f : List α
L : List (List α)
al : a ∈ l
fL : Forall₂ (fun x x_1 => x ∈ x_1) f L
fs : f ∈ sections L
⊢ ∃ a_1, a_1 ∈ sections L ∧ ∃ a_2, a_2 ∈ l ∧ a_2 :: a_1 = a :: f Tactic: simp only [sections, bind_eq_bind, mem_bind, mem_map] State Before: case refine'_2.cons
α : Type u_1
β : Type ?u.11
L✝ : List (List α)
f✝ : List α
a : α
l f : List α
L : List (List α)
al : a ∈ l
fL : Forall₂ (fun x x_1 => x ∈ x_1) f L
fs : f ∈ sections L
⊢ ∃ a_1, a_1 ∈ sections L ∧ ∃ a_2, a_2 ∈ l ∧ a_2 :: a_1 = a :: f State After: no goals Tactic: exact ⟨f, fs, a, al, rfl⟩ State Before: case refine'_2.nil
α : Type u_1
β : Type ?u.11
L : List (List α)
f : List α
⊢ [] ∈ sections [] State After: no goals Tactic: simp only [sections, mem_singleton] |
\section{Work Timeline}
\label{sec:concrete strategy}
\subsection{Overview}
The work of adding a feature to a codebase is a fairly concrete process. In theory writing some code for VST is just a type-heavy type of programming. The issue is that there was a decent learning curve to trying to understand the Coq language, and how separation logic would work with a type based proof system. This was also a contribution to an existing project in a way that could not be separated into an individual module in an obvious way. In Coq, variables are immutable. So it was not possible to change the variable for the syntax tree without figuring out what function in the code base wrote it. And syntax transformations always seem to require many intermediate steps. I eventually decided to break the problem into stages that could be implemented and tested without covering the entire learning curve in one semester.
\subsection{Stage 1}
Stage 1 is to get syntax transformations working in any form. VST uses Clightgen to generate an abstract syntax tree of the C code in Coq, and the proof code needed to handle trivial and routine parts of the proof. I could attach the compiler on the front of the build process and have C compiler to C that VST can digest more easily. This would still be a useful tool in itself. The downside of this code is that it would not have been proven in any sort of proof system, and would be fairly unrelated to the various types of separation logic that are in VST. But,implimenting this process I used standard tests of the C syntax before and after being transformed. I also got a copy of the C17 standard and set out to work on this. C has significant amounts of undefined behavior for the sake of compiler writer freedom to make compilers portable and fast. But this also has the consequence that few programmers know what a canonical C bug is versus a quirk of an implementation. It was probably pedantic to be precise about a naturally vague if not imprecise language, versus something like Ada or Zig which are designed to not have undefined behavior. Ada in particular being a more natural choice for government software that needs this level of fault tolerance. But VST and Compcert are designed for standard C. So that is what I attempted to do too.
I originally started with C++ as the compiler language, but this turned out to be a poorly thought out language choice. It seemed natural at the time, as C++ is one of the most common languages to write compilers in, due to LLVM, Bison, Yacc, and other nice tools. Coq is more ML-like, and python as of 3.9 has types and homoiconicity needed for quicker manual testing. Coding in Python now is easier for a one person project, and porting from Python to Coq is also easier. I finished this stage. But there is a need for a lot more tests. And C, small as it is, still has a 500 page standard.
So, at the very least, I managed to create a tool to solve the problem of not being able to prove it is safe to copy structures in VST.
\subsection{Stage 2}
Stage 2 is to port the python code into working Coq code. I did not finish this stage. I wrote some Coq code to move simple trees around. But I am still working on getting more complex constructs to work. I liked that instead of conditional branching Coq primarily uses pattern matching. So the program is more like a search space definition. This is very aesthetically appealing from a computability point of view, where reasoning with search spaces instead of loops is common. With inductive types many data structures are also infinite in effective size. The downside was that Coq is kind of particular on what the pattern matching code is supposed to look like. So it was not as if I could give a before-and-after of the syntax tree and expect it to figure out the intermediate transformations. Translating all of the Python compiler to Coq may not really needed, as scanning and parsing are already done well enough by clightgen.
\subsection{Stage 3}
Stage 3 is to integrate the working Coq code into the project properly, and then do a full proof with the new feature. While testing VST, I found that clightgen will take C code with the transformation from the python compiler. I am not sure how to complete a proof yet though. As I will go into in the conclusions section, VST is not as well documented as I personally wanted. And this slows down my ability to understand what the system code is actually doing.
|
module ProofColDivSeqPostuProof
import ProofColDivSeqBase
import ProofColDivSeqPostulate
%default total
-- %language ElabReflection
%access export
%hide Language.Reflection.P
-- from ProofColDivSeqBase
-- ########################################
base0 : P Z
base0 = rewrite definiP Z in
rewrite definiDivSeq0 in IsLimited00 (Z ** definiLimited0)
-- ########################################
-- from ProofColDivSeqMain
-- ########################################
-- ########################################
-- from sub0xxxxx
-- ########################################
-- 01 3(6x+1) --B[1,-2]--> 3x
b18x3To3x : (k : Nat)
-> (Not . P) (S (plus (plus (plus k k) (plus k k)) (plus k k))) -> (Not . P) k
b18x3To3x k = rewrite definiP (S (plus (plus (plus k k) (plus k k)) (plus k k))) in
rewrite definiP k in \prfF, prf => (prfF . IsLimited01 k) prf
-- 02 3(18x+4) --A[6,-4]--> 3(24x+3) -->E[2,-4]--> 3(2x)
ae54x12To6x : (l : Nat)
-> (Not . P) (S (S (plus (plus (plus (plus (plus l l) l) (plus (plus l l) l))
(S (plus (plus (plus l l) l) (plus (plus l l) l))))
(S (plus (plus (plus l l) l) (plus (plus l l) l))))))
-> (Not . P) (plus l l)
ae54x12To6x l = rewrite definiP (S (S (plus (plus (plus (plus (plus l l) l) (plus (plus l l) l))
(S (plus (plus (plus l l) l) (plus (plus l l) l))))
(S (plus (plus (plus l l) l) (plus (plus l l) l)))))) in
rewrite definiP (plus l l) in \prfF, prf => (prfF . IsLimited02 l) prf
-- 03 3(18x+10) --A[6,-4]->C[4,-4]--> 3(8x+3)
ac54x30To24x9 : (l : Nat)
-> (Not . P) (S (S (S (plus (plus (plus (plus (plus l l) l) (S (plus (plus l l) l)))
(S (S (plus (plus (plus l l) l) (S (plus (plus l l) l))))))
(S (S (plus (plus (plus l l) l) (S (plus (plus l l) l)))))))))
-> (Not . P) (S (S (S (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l))))))
ac54x30To24x9 l = rewrite definiP (S (S (S (plus (plus (plus (plus (plus l l) l) (S (plus (plus l l) l)))
(S (S (plus (plus (plus l l) l) (S (plus (plus l l) l))))))
(S (S (plus (plus (plus l l) l) (S (plus (plus l l) l))))))))) in
rewrite definiP (S (S (S (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l)))))) in \prfF, prf => (prfF . IsLimited03 l) prf
-- 04 3(18x+16) --A[6,-4]->B[1,-2]--> 3(4x+3)
ab54x30To12x9 : (l : Nat)
-> (Not . P) (S (S (S (S (plus (plus (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))
(S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))
(S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))))))
-> (Not . P) (S (S (S (plus (plus l l) (plus l l)))))
ab54x30To12x9 l = rewrite definiP (S (S (S (S (plus (plus (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))
(S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))
(S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l)))))))))))) in
rewrite definiP (S (S (S (plus (plus l l) (plus l l))))) in \prfF, prf => (prfF . IsLimited04 l) prf
-- 05 3(3x+2) --C[4,-4]--> 3x
c9x6To3x : (j : Nat)
-> (Not . P) (S (S (plus (plus j j) j))) -> (Not . P) j
c9x6To3x j = rewrite definiP (S (S (plus (plus j j) j))) in
rewrite definiP j in \prfF, prf => (prfF . IsLimited05 j) prf
-- 06 3(12x+3) --E[2,-4]--> 3x
e36x9To3x : (l : Nat)
-> (Not . P) (S (S (S (plus (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l))) (plus (plus l l) (plus l l))))))
-> (Not . P) l
e36x9To3x l = rewrite definiP (S (S (S (plus (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l))) (plus (plus l l) (plus l l)))))) in
rewrite definiP l in \prfF, prf => (prfF . IsLimited06 l) prf
-- 07 3(36x+9) --F[5,-2]->C[4,-4]--> 3(32x+7)
fc108x27To96x21 :
(o:Nat) -> (Not . P) (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (plus (plus o o) o))
(S (plus (plus (plus o o) o) (plus (plus o o) o))))
(S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (S (plus (plus (plus o o) o) (plus (plus o o) o))))))
(S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (S (plus (plus (plus o o) o) (plus (plus o o) o))))))))))
-> (Not . P) (S (S (S (S (S (S (S (plus (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))
(plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))))))))))
fc108x27To96x21 o =
rewrite definiP (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (plus (plus o o) o))
(S (plus (plus (plus o o) o) (plus (plus o o) o))))
(S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (S (plus (plus (plus o o) o) (plus (plus o o) o))))))
(S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (S (plus (plus (plus o o) o) (plus (plus o o) o)))))))))) in
rewrite definiP (S (S (S (S (S (S (S (plus (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))
(plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))))))))))
in \prfF, prf => (prfF . IsLimited07 o) prf
-- 08 3(36x+21) --F[5,-2]->B[1,-2]--> 3(16x+9)
fb108x63To48x27 :
(o:Nat) -> (Not . P) (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))
(S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))
(S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o))) (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))))))
(S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o))) (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))))))))
-> (Not . P) (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))))))))))))
fb108x63To48x27 o =
rewrite definiP (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))
(S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))
(S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o))) (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))))))
(S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o))) (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))))))))))) in
rewrite definiP (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))))))))))))
in \prfF, prf => (prfF . IsLimited08 o) prf
-- 09 3(36x+33) --F[5,-2]->E[2,-4]--> 3(8x+7)
fe108x99To24x21 :
(o:Nat) -> (Not . P) (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))
(S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))
(S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))) (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))))))
(S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))) (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))))))))))))
-> (Not . P) (S (S (S (S (S (S (S (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))))))))
fe108x99To24x21 o = rewrite definiP (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))
(S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))
(S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))) (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))))))
(S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))) (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))))))))))))) in
rewrite definiP (S (S (S (S (S (S (S (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))))))))
in \prfF, prf => (prfF . IsLimited09 o) prf
-- 10 3(36x+6) --F[5,-2]->E[2,-4]--> 3(8x+1)
fe108x18To24x3 :
(o:Nat) -> (Not . P) (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (plus (plus o o) o))
(plus (plus (plus o o) o) (plus (plus o o) o)))
(S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (plus (plus (plus o o) o) (plus (plus o o) o)))))
(S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (plus (plus (plus o o) o) (plus (plus o o) o)))))))))
-> (Not . P) (S (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))
fe108x18To24x3 o = rewrite definiP (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (plus (plus o o) o))
(plus (plus (plus o o) o) (plus (plus o o) o)))
(S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (plus (plus (plus o o) o) (plus (plus o o) o)))))
(S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (plus (plus (plus o o) o) (plus (plus o o) o))))))))) in
rewrite definiP (S (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))
in \prfF, prf => (prfF . IsLimited10 o) prf
-- 11 3(36x+18) --F[5,-2]->C[4,-4]--> 3(32x+15)
fc108x54To96x45 :
(o:Nat) -> (Not . P) (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))
(S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))
(S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o))) (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))
(S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o))) (S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))))))))))
-> (Not . P) (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))
(plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))))))))))))))))))
fc108x54To96x45 o = rewrite definiP (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))
(S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))
(S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o))) (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))
(S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o))) (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))))))) in
rewrite definiP (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))
(plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))))))))))))))))))
in \prfF, prf => (prfF . IsLimited11 o) prf
-- 12 3(36x+30) --F[5,-2]->B[1,-2]--> 3(16x+13)
fb108x90To48x39 :
(o:Nat) -> (Not . P) (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))
(S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))
(S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))) (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))))))
(S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))) (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))))))))))))
-> (Not . P) (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))))))))))))))))
fb108x90To48x39 o = rewrite definiP (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))
(S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))
(S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))) (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))))))
(S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))) (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))))))))))) in
rewrite definiP (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))))))))))))))))
in \prfF, prf => (prfF . IsLimited12 o) prf
-- 13 3(36x+12) --F[5,-2]->B[1,-2]--> 3(16x+5)
fb108x36To48x15 :
(o:Nat) -> (Not . P) (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (plus (plus o o) o))
(S (plus (plus (plus o o) o) (plus (plus o o) o))))
(S (S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (S (plus (plus (plus o o) o) (plus (plus o o) o)))))))
(S (S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (S (plus (plus (plus o o) o) (plus (plus o o) o))))))))))))
-> (Not . P) (S (S (S (S (S (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))))))))
fb108x36To48x15 o = rewrite definiP (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (plus (plus o o) o))
(S (plus (plus (plus o o) o) (plus (plus o o) o))))
(S (S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (S (plus (plus (plus o o) o) (plus (plus o o) o)))))))
(S (S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (S (plus (plus (plus o o) o) (plus (plus o o) o)))))))))))) in
rewrite definiP (S (S (S (S (S (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))))))))
in \prfF, prf => (prfF . IsLimited13 o) prf
-- 14 3(36x+24) --F[5,-2]->E[2,-4]--> 3(8x+5)
fe108x72To24x15 :
(o:Nat) -> (Not . P) (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))
(S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))
(S (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o))) (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))))
(S (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o))) (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))))))))))
-> (Not . P) (S (S (S (S (S (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))))))
fe108x72To24x15 o = rewrite definiP (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))
(S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))
(S (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o))) (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))))
(S (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o))) (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))))))))))))) in
rewrite definiP (S (S (S (S (S (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))))))
in \prfF, prf => (prfF . IsLimited14 o) prf
-- 15 3(36x+36) --F[5,-2]->C[4,-4]--> 3(32x+31)
fc108x108To96x93 :
(o:Nat) -> (Not . P) (S (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))
(S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))
(S (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))) (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))))))))
(S (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))) (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))))))))))))))
-> (Not . P) (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))
(plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))))))))))))))))))))))))))))))))))
fc108x108To96x93 o = rewrite definiP (S (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))
(S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))
(S (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))) (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))))))))
(S (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))) (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))))))))))))))) in
rewrite definiP (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))
(plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))))))))))))))))))))))))))))))))))
in \prfF, prf => (prfF . IsLimited15 o) prf
-- ########################################
|
-- @@stderr --
dtrace: failed to compile script test/unittest/speculation/err.D_PRAGMA_MALFORM.NspecExpr.d: [D_PRAGMA_MALFORM] line 20: superfluous arguments specified for #pragma option
|
-- This file contains several ways to define localisation
-- and proves them all to be equivalent
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Experiments.LocalisationDefs where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Powerset
open import Cubical.Foundations.Transport
open import Cubical.Functions.FunExtEquiv
import Cubical.Data.Empty as ⊥
open import Cubical.Data.Bool
open import Cubical.Data.Vec
open import Cubical.Data.Sigma.Base
open import Cubical.Data.Sigma.Properties
open import Cubical.Data.FinData
open import Cubical.Relation.Nullary
open import Cubical.Relation.Binary
open import Cubical.Algebra.Group
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
open import Cubical.HITs.SetQuotients as SQ
open import Cubical.HITs.PropositionalTruncation as PT
open Iso
private
variable
ℓ ℓ' : Level
A : Type ℓ
record isMultClosedSubset (R' : CommRing {ℓ}) (S' : ℙ (R' .fst)) : Type ℓ where
constructor
multclosedsubset
field
containsOne : (R' .snd .CommRingStr.1r) ∈ S'
multClosed : ∀ {s t} → s ∈ S' → t ∈ S' → (R' .snd .CommRingStr._·_ s t) ∈ S'
module _ (R' : CommRing {ℓ}) (S' : ℙ (R' .fst)) (SMultClosedSubset : isMultClosedSubset R' S') where
open isMultClosedSubset
private R = R' .fst
open CommRingStr (R' .snd)
open Theory (CommRing→Ring R')
S = Σ[ s ∈ R ] (s ∈ S')
-- HIT definition
data S⁻¹R : Type ℓ where
_/ₗ_ : R → S → S⁻¹R
zd : (r₁ r₂ : R) (s s₁ s₂ : S)
→ fst s · r₁ · fst s₂ ≡ fst s · r₂ · fst s₁
→ r₁ /ₗ s₁ ≡ r₂ /ₗ s₂
trunc : isSet S⁻¹R
infixr 5 _/ₗ_
module Elim {ℓ'} {B : S⁻¹R → Type ℓ'}
(_/*_ : (r : R) (s : S) → B (r /ₗ s))
(zd* : (r₁ r₂ : R) (s s₁ s₂ : S)
→ (p : fst s · r₁ · fst s₂ ≡ fst s · r₂ · fst s₁)
→ PathP (λ i → B (zd r₁ r₂ s s₁ s₂ p i)) (r₁ /* s₁) (r₂ /* s₂))
(trunc* : (q : S⁻¹R) → isSet (B q)) where
f : (q : S⁻¹R) → B q
f (r /ₗ s) = r /* s
f (zd r₁ r₂ s s₁ s₂ p i) = zd* r₁ r₂ s s₁ s₂ p i
f (trunc q₁ q₂ x y i j) = isOfHLevel→isOfHLevelDep 2 trunc* (f q₁) (f q₂) (cong f x) (cong f y)
(trunc q₁ q₂ x y) i j
module ElimProp {ℓ'} {B : S⁻¹R → Type ℓ'} (Bprop : {q : S⁻¹R} → isProp (B q))
(_/*_ : (r : R) → (s : S) → B (r /ₗ s)) where
f : (q : S⁻¹R) → B q
f = Elim.f _/*_ (λ r₁ r₂ s s₁ s₂ p
→ toPathP (Bprop (transp (λ i → B (zd r₁ r₂ s s₁ s₂ p i)) i0 (r₁ /* s₁))
(r₂ /* s₂)))
λ q → isProp→isSet Bprop
module Rec {ℓ'} {B : Type ℓ'} (BType : isSet B)
(_/*_ : R → S → B)
(zd* : (r₁ r₂ : R) (s s₁ s₂ : S)
→ (p : fst s · r₁ · fst s₂ ≡ fst s · r₂ · fst s₁)
→ r₁ /* s₁ ≡ r₂ /* s₂)
where
f : S⁻¹R → B
f = Elim.f _/*_ zd* (λ _ → BType)
-- approach using set quotients
_≈_ : R × S → R × S → Type ℓ
(r₁ , s₁) ≈ (r₂ , s₂) = ∃[ s ∈ S ] (fst s · r₁ · fst s₂ ≡ fst s · r₂ · fst s₁)
S⁻¹R/ = (R × S) / _≈_
-- proving equivalence of the two types
φ : S⁻¹R/ → S⁻¹R
φ = SQ.rec trunc (λ (r , s) → r /ₗ s) β
where
α : ((r₁ , s₁) (r₂ , s₂) : R × S) → Σ[ s ∈ S ] (fst s · r₁ · fst s₂ ≡ fst s · r₂ · fst s₁)
→ r₁ /ₗ s₁ ≡ r₂ /ₗ s₂
α _ _ (s , p) = zd _ _ s _ _ p
β : ((r₁ , s₁) (r₂ , s₂) : R × S) → ∃[ s ∈ S ] (fst s · r₁ · fst s₂ ≡ fst s · r₂ · fst s₁)
→ r₁ /ₗ s₁ ≡ r₂ /ₗ s₂
β _ _ = PT.rec (trunc _ _) (α _ _)
ψ : S⁻¹R → S⁻¹R/
ψ (r /ₗ s) = [ r , s ]
ψ (zd r₁ r₂ s s₁ s₂ p i) = eq/ (r₁ , s₁) (r₂ , s₂) ∣ s , p ∣ i
ψ (trunc x y p q i j) = squash/ (ψ x) (ψ y) (cong ψ p) (cong ψ q) i j
η : section φ ψ
η = ElimProp.f (trunc _ _) λ _ _ → refl
ε : retract φ ψ
ε = elimProp (λ _ → squash/ _ _) λ _ → refl
S⁻¹R/≃S⁻¹R : S⁻¹R/ ≃ S⁻¹R
S⁻¹R/≃S⁻¹R = isoToEquiv (iso φ ψ η ε)
-- Set quotients but with Σ, this is the type used in Algebra.Localisation.Base
-- as this is easiest to use
_≈'_ : R × S → R × S → Type ℓ
(r₁ , s₁) ≈' (r₂ , s₂) = Σ[ s ∈ S ] (fst s · r₁ · fst s₂ ≡ fst s · r₂ · fst s₁)
S⁻¹R/' = (R × S) / _≈'_
S⁻¹R/'≃S⁻¹R/ : S⁻¹R/' ≃ S⁻¹R/
S⁻¹R/'≃S⁻¹R/ = SQ.truncRelEquiv
|
\epigraph{``It is our choices, Harry, that show what we truly are, far more than our abilities."}{Albus Dumbledore}
The previous chapters have discussed the development of an open source implementation to simulating atmospheric dynamics both in the troposphere and the stratosphere on a synoptic scale. Although extremely time consuming, and with a few approximations made along the way, the importance of an open source implementation cannot be understated. It could potentially open up a field to a wider group, and often doesn't receive the media attention it rightfully deserves.
Future applications of this work are extremely wide ranging, from usage in numerical weather prediction schemes that take in observational data collected from satellites, and ground stations in order to provide a picture of future weather events; to forming at starting point in future research of atmospheric phenomena, ideally reducing the overall research time. While, at the moment, it definitely would be inaccurate to say the software is ready for such usage, with future enhancements which I will touch on in a minute, it most certainly will.
\section{Looking Back}
To prove the hypothesis that `it is possible to create open source software implementation to simulating atmospheric dynamics, with a recurrent neural network and ensemble prediction system being used in combination with a physical model, that such a software implementation has a reasonable execution time to forecast length ratio, and to determine if such an implementation has a statistically significant accuracy improvement over a traditional deterministic physical model', a number of different bechmarking experiments were carried out in the areas of: performance, and accuracy.
\subsection{Performance Benchmark}\label{results_performance}
It is clearly possible to create open source software implementation to simulating atmospheric dynamics, as evident by this report. In regards to performance benchmarking, the ratio between the runtime of the forecast and the fixed length of the forecast was determined. For the physical model, the ratio between the two parameters was $0.0076$; for the physical model with the recurrent neural network enabled, the ratio was $0.0799$; and for the physical model with the ensemble forecast system enabled, the ratio was $0.1147$. This correlates to a usable forecast length of 119 hours (99\%), 110 hours (92\%), and 106 hours (89\%) respectively. Hence, the forecast would be regarded as highly usable, under the assumption that the accuracy of said forecast is also high and also assuming that the forecast is generated on a machine of similar specifications. A reasonably fast internet connection is also assumed due to the large amount of data required for the training of the recurrent neural network. Another point to note is that the runtime of the physical model with the recurrent neural network enabled per time step is rather high. This is could be a potential issue if the recurrent neural network is used in combination with the ensemble forecast system.
\subsection{Accuracy Benchmark}
In regards to accuracy benchmarking, three distinct benchmarks were carried out. The purpose of the first benchmark was to determine whether the forecast produced by a given scheme of the software was more accurate than the naive forecasting model by using the mean absolute scaled error. Three parameters, geopotential height, zonal wind, and meridional wind, were consistently more accurate than the naive forecasting model across the board. The mean absolute scaled error across the entire forecasting period was $0.9399$, $0.9192$, and $0.9933$ respectively. In regards to the virtual temperature, the physical model and the physical model with the ensemble forecast system under-performed in comparison to the naive forecasting model. The physical model with the RNN enabled, however, performed better than the naive forecasting model with a mean absolute scaled error of $0.9511$. In regards to air temperature, a similar story applies, however, the physical model with the RNN in this case was unable to beat the naive forecasting model, with a mean absolute scaled error of $1.51$. In regards to relative humidity, the physical model with the RNN enabled, and the physical model with the EPS enabled performed dramatically worse than the physical model. The physical model was also unable to match the accuracy of the naive forecasting model with a mean absolute scaled error of $1.17$. That being said, the majority of the forecast schemes within the software had a higher accuracy than the naive forecasting model, hence, the software as a whole has a reasonable level of accuracy.
The purpose of the second benchmark was to determine whether a particular scheme had a statistically significant increase in accuracy over the physical model. In regards to the physical models with the RNN enabled, a statistically significant increase in accuracy was seen in two out of the six atmospheric parameters benchmarked, with a significance level of $0.1$. These were air temperature, and virtual temperature; and had a p-value of approximately $0.0543$ and $0.0115$ respectively. In regards to relative humidity, a statistically significant decrease in performance was observed. In regards to geopotential height and as mentioned previously, a RNN was not developed due to the restrictions created by the COVID-19 pandemic. Hence, a statistically significant increase or decrease in accuracy was not observed. As zonal wind, and meridional wind are determined using geopotential height, an increase or decrease in accuracy was not observed for the aforementioned parameters. Overall, using a recurrent neural network in combination with a physical model, shows significant promise. In regards to the physical models with the EPS enabled, a statistically significant increase or decrease in accuracy was not observed in any of the six atmospheric parameters benchmarked. While an increase in performance was observed across the board, expect in the case of relative humidity, it was not statistically significant. It must be noted, however, that this benchmark doesn't full capture the advantages of using an EPS. An EPS provides a forecast provider with an estimation of the uncertainty in a weather forecast, which is an extremely valuable metric.
The purpose of the third benchmark was to compare the accuracy of the software's most accurate scheme against a proprietary implementation, with the proprietary implementation, OpenWeatherAPI, ultimately being selected. The results shows that there is a statistically significant increase across all of the five atmospheric parameters benchmarked in this scenario. Hence, against a proprietary implementation, the software significantly under-performs. A few key points of information should be noted, however. OpenWeatherAPI does not provide data which changes in the vertical co-ordinate. Secondly, OpenWeatherAPI, as a proprietary implementation, has a significant amount of undesirable properties, as discussed in chapter \ref{5}. Whilst presently, the software does not compete in terms of accuracy, its open source nature will allow for rapid advancements, and improvements in modelling and accuracy.
\subsection{Sources of Error}
Hence, the hypothesis that was proposed has partially been proven, however, there are a few areas which could have hindered the performance of the software or lead to a possible source of error:
\begin{itemize}
\item Due to the ongoing nature of the COVID-19 pandemic, schools were required to close in line with guidance from public health experts. This had unintended consequences on my ability to arrange appropriate computational resources. I originally planned on organising said computational resources through the school, however, due to the aforementioned school closures, this was no longer a feasible option to pursue. This limited me to virtual machines provided by Google, Microsoft, and Amazon. While these are viable options if finances support it, they are impractical if said finances are not available. My school, in their eternal generosity, is also the main source of financial support for this project, and as a result of school closures, this limited available finances.
\item As noted in section \ref{results_performance}, the runtime of the physical model with the recurrent neural network enabled per time step is rather high. This is possibly due to the fact that a GPU was not used in combination with a CPU. Generally speaking, GPUs are fast because they have high-bandwidth memories and hardware that performs floating-point arithmetic at significantly higher rates than conventional CPUs. The GPUs' main task is to perform the calculations needed to render 3D computer graphics. But in 2007 NVIDIA created CUDA. CUDA is a parallel computing platform that provides an API for developers, allowing them to build tools that can make use of GPUs for general-purpose processing. Processing large blocks of data is basically what machine learning is, so GPUs come in handy for machine learning tasks\cite{gpus}. A GPU was ultimately not utilised for financial reasons (it would have cost approximately \$300 a month for the baseline GPU).
\item The benchmarking process for this particular project began on the 20th of April. It was originally planned to perform the benchmarks on approximately thirty days worth of data, however, due to the combination of restrictions imposed by a lack of computational resources and bugs within the benchmarking code, lead to a reduction in the amount of available benchmarking time. This ultimately lead to the benchmarking process being cut back in order to meet the submission deadline of the 14th of May.
\end{itemize}
\section{Looking Ahead}
The software is currently in an alpha release state. An alpha version of any software is a very early version of the software that may not contain all of the features that are planned for the final version\cite{alpha}. In this section, I will briefly outline the enhancements and features that will be released in the beta version of the software, which is planned for release in Fall 2020:
\begin{itemize}
\item In order to ensure that a sufficient amount of computational resources are available for the benchmarking process in the Fall of 2020, I have contacted the Irish Centre for High-End Computing for assistance in this endeavour. They have said they are willing to provide their assistance and expertise to help with this project, including guidance in relation to climate modelling from their climate experts and with assistance in the benchmarking process from one of their computational scientists. A meeting is planned to take place virtually sometime in the next few weeks.
\item As mentioned in section \ref{implement_rnn}, it is necessary to flatten the 3-dimensional vector that represents the state of the atmosphere in order for it to match the shape of the LSTM cell. While this is an effective approach, a new approach has been shown to be more effective. By combining a convolutional neural network with a neural network, it will result in a more accurate ouput for spatial-temporal type data. A convolutional neural network is a class of deep neural networks. They are also known as shift invariant or space invariant artificial neural networks, based on their shared-weights architecture and translation invariance characteristics.
\item In order to improve the simulation of the evolution of temperature and virtual temperature, I would add a diabatic term to the advection equation. The diabatic term, would however, violate quasi-geostrophic considerations. However, diabatic effects can have substantial effects on local atmospheric temperature. For example, the melting of snow falling from a cold layer above into a warm layer below will cause cooling of the warm layer. Diurnal heating plays a major role in temperature changes near the surface. Also, strong ascent can result in significant latent heat release due to condensation of moisture. This warming will oppose the adiabatic cooling due to lift, but net cooling should still occur due to ascent. The less moisture there is in the atmosphere, the more the net cooling will be\cite{describe_quasi}.
\end{itemize} |
Born in London in 1934, Anthony Gilbert took up composition seriously in the early 1960s after five years of study with Alexander Goehr. For ten years he was closely involved in the promotion and publication of new music in London and then moved to the North West of England, first as Granada Arts Fellow at the University of Lancaster and then to establish a new composition department at the Royal Northern College of Music, where he was Director of Composition Studies until his retirement in 1999. He has a close association with the musical life of Australia. Much of his later music owes its origin to the birdsong of this land and much, too, has its technical roots in the classical music of the Indian subcontinent, in which he has been interested for three decades.
His compositions cover a wide range of forces and forms. He has written for most of the major ensembles and soloists, including the Arditti Quartet, London Sinfonietta, Manchester Camerata, Hallé Orchestra and Lindsay Quartet, and received major commissions from the BBC and from the Cheltenham Festival and Staatstheater Kassel, to mention just a few. |
Require Export Iron.Language.SimpleData.ExpBase.
(* Get the data constructor of an alternative. *)
Fixpoint dcOfAlt (aa: alt) : datacon :=
match aa with
| AAlt dc _ _ => dc
end.
Hint Unfold dcOfAlt.
(* Get the alternative body that matches a given constructor. *)
Fixpoint getAlt (dc: datacon) (alts: list alt) {struct alts}
: option alt :=
match alts with
| nil => None
| AAlt dc' tsArgs x :: alts'
=> if datacon_beq dc dc'
then Some (AAlt dc' tsArgs x)
else getAlt dc alts'
end.
(* If we get a single alternative from a list,
then that alternative was in the list. *)
Lemma getAlt_in
: forall dc alt alts
, getAlt dc alts = Some alt
-> In alt alts.
Proof.
intros.
induction alts.
false.
destruct a as [dc' tsArgs x].
simpl in H.
breaka (datacon_beq dc dc').
inverts H.
apply datacon_beq_eq in HeqX; auto.
Qed.
(* Given a data constructor, if one of the alternatives in a
list matches that data constructor then we can get the other
information about the alternative from the list. *)
Lemma getAlt_exists
: forall d alts
, In d (map dcOfAlt alts)
-> (exists tsArgs x, getAlt d alts = Some (AAlt d tsArgs x)).
Proof.
intros.
induction alts.
simpl in H. false.
simpl in H. inverts H.
destruct a. simpl.
breaka (datacon_beq d d).
exists l. exists e. auto.
apply datacon_beq_false in HeqX. false.
lets D: IHalts H0.
destruct a. simpl.
breaka (datacon_beq d d0).
apply datacon_beq_eq in HeqX. subst. auto.
exists l. exists e. auto.
Qed.
|
import matplotlib.pyplot as plt
import numpy as np
#_____________________________________
def make_power_plot(teams, year, week):
'''Make plot of power ranking versus
average score'''
scores = []
owners = []
powers = []
colors = []
# Tier colors
c = [(133/255.,205/255.,242/255.),
(122/255.,201/255.,96/255.),
(224/255.,183/255.,0/255.),
(255/255.,106/255.,43/255.),
(168/255.,106/255.,156/255.)]
tiers = [1,2,3,4,5]
my_dpi = 96
minx=200
maxx=0
# Save scores, tiers, names
for t in teams:
t_scores = []
for s in t.stats.scores[:week]:
t_scores.append(s)
scores.append(t_scores)
owners.append(t.owner.split()[0].title())
powers.append(float(t.rank.power))
colors.append(c[t.rank.tier-1])
t_min = min(t_scores)
t_max = max(t_scores)
if t_min < minx:
minx = t_min
if t_max > maxx:
maxx = t_max
# Set up plot
f = plt.figure()
f.set_size_inches(992./my_dpi,558./my_dpi)
ax = f.add_subplot(111)
ax.set_xlim(minx-10, maxx+30)
plt.xlabel('Weekly Score')
plt.ylabel('Power Rank')
# create list of boxplots for each player
bp_dict = plt.boxplot(scores, vert=False, showfliers=False, showmeans=False, showcaps=False)
# change color
for i,w in enumerate(bp_dict['whiskers']):
j= int(i/2) if i%2 else int((i+1)/2)
w.set(color=colors[j],linestyle="solid")
for i,b in enumerate(bp_dict['boxes']):
b.set(color=colors[i])
# show each score as red dot
for i in range(len(teams)):
x = scores[i]
y = np.random.normal(i+1, 0.04, size=len(x))
ax.plot(x, y, 'r.', alpha=0.4)
# put name to left of boxplot
for i,line in enumerate(bp_dict['whiskers']):
x, y = line.get_xydata()[1] # bottom of line (1 is top)
if(i%2):
ax.text(x+5,y, '%s'%owners[int(i/2)], horizontalalignment='left', verticalalignment='center')
# Add a legend
ax.legend(loc=2,title='Tier',labels=tiers)
for i,leg_item in enumerate(ax.get_legend().legendHandles):
leg_item.set_color(c[i])
plt.ylim(len(teams)+1,0)
f.savefig('output/%s/week%d/power_plot.png'%(year, week),dpi=my_dpi*2,bbox_inches='tight')
|
/-
Copyright (c) 2021 Julian Kuelshammer. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Julian Kuelshammer
-/
import group_theory.order_of_element
import algebra.punit_instances
import algebra.gcd_monoid.finset
import tactic.by_contra
import number_theory.padics.padic_val
/-!
# Exponent of a group
This file defines the exponent of a group, or more generally a monoid. For a group `G` it is defined
to be the minimal `n≥1` such that `g ^ n = 1` for all `g ∈ G`. For a finite group `G`,
it is equal to the lowest common multiple of the order of all elements of the group `G`.
## Main definitions
* `monoid.exponent_exists` is a predicate on a monoid `G` saying that there is some positive `n`
such that `g ^ n = 1` for all `g ∈ G`.
* `monoid.exponent` defines the exponent of a monoid `G` as the minimal positive `n` such that
`g ^ n = 1` for all `g ∈ G`, by convention it is `0` if no such `n` exists.
* `add_monoid.exponent_exists` the additive version of `monoid.exponent_exists`.
* `add_monoid.exponent` the additive version of `monoid.exponent`.
## Main results
* `monoid.lcm_order_eq_exponent`: For a finite left cancel monoid `G`, the exponent is equal to the
`finset.lcm` of the order of its elements.
* `monoid.exponent_eq_supr_order_of(')`: For a commutative cancel monoid, the exponent is
equal to `⨆ g : G, order_of g` (or zero if it has any order-zero elements).
## TODO
* Refactor the characteristic of a ring to be the exponent of its underlying additive group.
-/
universe u
variable {G : Type u}
open_locale classical
namespace monoid
section monoid
variables (G) [monoid G]
/--A predicate on a monoid saying that there is a positive integer `n` such that `g ^ n = 1`
for all `g`.-/
@[to_additive "A predicate on an additive monoid saying that there is a positive integer `n` such
that `n • g = 0` for all `g`."]
def exponent_exists := ∃ n, 0 < n ∧ ∀ g : G, g ^ n = 1
/--The exponent of a group is the smallest positive integer `n` such that `g ^ n = 1` for all
`g ∈ G` if it exists, otherwise it is zero by convention.-/
@[to_additive "The exponent of an additive group is the smallest positive integer `n` such that
`n • g = 0` for all `g ∈ G` if it exists, otherwise it is zero by convention."]
noncomputable def exponent :=
if h : exponent_exists G then nat.find h else 0
variable {G}
@[to_additive]
lemma exponent_exists_iff_ne_zero : exponent_exists G ↔ exponent G ≠ 0 :=
begin
rw [exponent],
split_ifs,
{ simp [h, @not_lt_zero' ℕ] }, --if this isn't done this way, `to_additive` freaks
{ tauto },
end
@[to_additive]
lemma exponent_eq_zero_iff : exponent G = 0 ↔ ¬ exponent_exists G :=
by simp only [exponent_exists_iff_ne_zero, not_not]
@[to_additive]
lemma exponent_eq_zero_of_order_zero {g : G} (hg : order_of g = 0) : exponent G = 0 :=
exponent_eq_zero_iff.mpr $ λ ⟨n, hn, hgn⟩, order_of_eq_zero_iff'.mp hg n hn $ hgn g
@[to_additive exponent_nsmul_eq_zero]
lemma pow_exponent_eq_one (g : G) : g ^ exponent G = 1 :=
begin
by_cases exponent_exists G,
{ simp_rw [exponent, dif_pos h],
exact (nat.find_spec h).2 g },
{ simp_rw [exponent, dif_neg h, pow_zero] }
end
@[to_additive]
lemma pow_eq_mod_exponent {n : ℕ} (g : G): g ^ n = g ^ (n % exponent G) :=
calc g ^ n = g ^ (n % exponent G + exponent G * (n / exponent G)) : by rw [nat.mod_add_div]
... = g ^ (n % exponent G) : by simp [pow_add, pow_mul, pow_exponent_eq_one]
@[to_additive]
lemma exponent_pos_of_exists (n : ℕ) (hpos : 0 < n) (hG : ∀ g : G, g ^ n = 1) :
0 < exponent G :=
begin
have h : ∃ n, 0 < n ∧ ∀ g : G, g ^ n = 1 := ⟨n, hpos, hG⟩,
rw [exponent, dif_pos],
exact (nat.find_spec h).1,
end
@[to_additive]
@[to_additive]
lemma exponent_min (m : ℕ) (hpos : 0 < m) (hm : m < exponent G) : ∃ g : G, g ^ m ≠ 1 :=
begin
by_contra' h,
have hcon : exponent G ≤ m := exponent_min' m hpos h,
linarith,
end
@[simp, to_additive]
lemma exp_eq_one_of_subsingleton [subsingleton G] : exponent G = 1 :=
begin
apply le_antisymm,
{ apply exponent_min' _ nat.one_pos,
simp },
{ apply nat.succ_le_of_lt,
apply exponent_pos_of_exists 1 (nat.one_pos),
simp },
end
@[to_additive add_order_dvd_exponent]
lemma order_dvd_exponent (g : G) : (order_of g) ∣ exponent G :=
order_of_dvd_of_pow_eq_one $ pow_exponent_eq_one g
variable (G)
@[to_additive]
lemma exponent_dvd_of_forall_pow_eq_one (G) [monoid G] (n : ℕ) (hG : ∀ g : G, g ^ n = 1) :
exponent G ∣ n :=
begin
rcases n.eq_zero_or_pos with rfl | hpos,
{ exact dvd_zero _ },
apply nat.dvd_of_mod_eq_zero,
by_contradiction h,
have h₁ := nat.pos_of_ne_zero h,
have h₂ : n % exponent G < exponent G := nat.mod_lt _ (exponent_pos_of_exists n hpos hG),
have h₃ : exponent G ≤ n % exponent G,
{ apply exponent_min' _ h₁,
simp_rw ←pow_eq_mod_exponent,
exact hG },
linarith,
end
@[to_additive lcm_add_order_of_dvd_exponent]
lemma lcm_order_of_dvd_exponent [fintype G] : (finset.univ : finset G).lcm order_of ∣ exponent G :=
begin
apply finset.lcm_dvd,
intros g hg,
exact order_dvd_exponent g
end
@[to_additive exists_order_of_eq_pow_padic_val_nat_add_exponent]
lemma _root_.nat.prime.exists_order_of_eq_pow_factorization_exponent {p : ℕ} (hp : p.prime) :
∃ g : G, order_of g = p ^ (exponent G).factorization p :=
begin
haveI := fact.mk hp,
rcases eq_or_ne ((exponent G).factorization p) 0 with h | h,
{ refine ⟨1, by rw [h, pow_zero, order_of_one]⟩ },
have he : 0 < exponent G := ne.bot_lt (λ ht,
by {rw ht at h, apply h, rw [bot_eq_zero, nat.factorization_zero, finsupp.zero_apply] }),
rw ← finsupp.mem_support_iff at h,
obtain ⟨g, hg⟩ : ∃ (g : G), g ^ (exponent G / p) ≠ 1,
{ suffices key : ¬ exponent G ∣ exponent G / p,
{ simpa using mt (exponent_dvd_of_forall_pow_eq_one G (exponent G / p)) key },
exact λ hd, hp.one_lt.not_le ((mul_le_iff_le_one_left he).mp $
nat.le_of_dvd he $ nat.mul_dvd_of_dvd_div (nat.dvd_of_mem_factorization h) hd) },
obtain ⟨k, hk : exponent G = p ^ _ * k⟩ := nat.pow_factorization_dvd _ _,
obtain ⟨t, ht⟩ := nat.exists_eq_succ_of_ne_zero (finsupp.mem_support_iff.mp h),
refine ⟨g ^ k, _⟩,
rw ht,
apply order_of_eq_prime_pow,
{ rwa [hk, mul_comm, ht, pow_succ', ←mul_assoc, nat.mul_div_cancel _ hp.pos, pow_mul] at hg },
{ rw [←nat.succ_eq_add_one, ←ht, ←pow_mul, mul_comm, ←hk],
exact pow_exponent_eq_one g },
end
variable {G}
@[to_additive] lemma exponent_ne_zero_iff_range_order_of_finite (h : ∀ g : G, 0 < order_of g) :
exponent G ≠ 0 ↔ (set.range (order_of : G → ℕ)).finite :=
begin
refine ⟨λ he, _, λ he, _⟩,
{ by_contra h,
obtain ⟨m, ⟨t, rfl⟩, het⟩ := set.infinite.exists_nat_lt h (exponent G),
exact pow_ne_one_of_lt_order_of' he het (pow_exponent_eq_one t) },
{ lift (set.range order_of) to finset ℕ using he with t ht,
have htpos : 0 < t.prod id,
{ refine finset.prod_pos (λ a ha, _),
rw [←finset.mem_coe, ht] at ha,
obtain ⟨k, rfl⟩ := ha,
exact h k },
suffices : exponent G ∣ t.prod id,
{ intro h,
rw [h, zero_dvd_iff] at this,
exact htpos.ne' this },
refine exponent_dvd_of_forall_pow_eq_one _ _ (λ g, _),
rw [pow_eq_mod_order_of, nat.mod_eq_zero_of_dvd, pow_zero g],
apply finset.dvd_prod_of_mem,
rw [←finset.mem_coe, ht],
exact set.mem_range_self g },
end
@[to_additive] lemma exponent_eq_zero_iff_range_order_of_infinite (h : ∀ g : G, 0 < order_of g) :
exponent G = 0 ↔ (set.range (order_of : G → ℕ)).infinite :=
have _ := exponent_ne_zero_iff_range_order_of_finite h,
by rwa [ne.def, not_iff_comm, iff.comm] at this
@[to_additive lcm_add_order_eq_exponent]
lemma lcm_order_eq_exponent [fintype G] : (finset.univ : finset G).lcm order_of = exponent G :=
begin
apply nat.dvd_antisymm (lcm_order_of_dvd_exponent G),
refine exponent_dvd_of_forall_pow_eq_one G _ (λ g, _),
obtain ⟨m, hm⟩ : order_of g ∣ finset.univ.lcm order_of := finset.dvd_lcm (finset.mem_univ g),
rw [hm, pow_mul, pow_order_of_eq_one, one_pow]
end
end monoid
section left_cancel_monoid
variable [left_cancel_monoid G]
@[to_additive]
lemma exponent_ne_zero_of_fintype [fintype G] : exponent G ≠ 0 :=
by simpa [←lcm_order_eq_exponent, finset.lcm_eq_zero_iff] using λ x, (order_of_pos x).ne'
end left_cancel_monoid
section comm_monoid
variable [comm_monoid G]
@[to_additive] lemma exponent_eq_supr_order_of (h : ∀ g : G, 0 < order_of g) :
exponent G = ⨆ g : G, order_of g :=
begin
rw supr,
rcases eq_or_ne (exponent G) 0 with he | he,
{ rw [he, set.infinite.nat.Sup_eq_zero $ (exponent_eq_zero_iff_range_order_of_infinite h).1 he] },
have hne : (set.range (order_of : G → ℕ)).nonempty := ⟨1, 1, order_of_one⟩,
have hfin : (set.range (order_of : G → ℕ)).finite,
{ rwa [← exponent_ne_zero_iff_range_order_of_finite h] },
obtain ⟨t, ht⟩ := hne.cSup_mem hfin,
apply nat.dvd_antisymm _,
{ rw ←ht,
apply order_dvd_exponent },
refine nat.dvd_of_factors_subperm he _,
rw list.subperm_ext_iff,
by_contra' h,
obtain ⟨p, hp, hpe⟩ := h,
replace hp := nat.prime_of_mem_factors hp,
simp only [nat.factors_count_eq] at hpe,
set k := (order_of t).factorization p with hk,
obtain ⟨g, hg⟩ := hp.exists_order_of_eq_pow_factorization_exponent G,
suffices : order_of t < order_of (t ^ (p ^ k) * g),
{ rw ht at this,
exact this.not_le (le_cSup hfin.bdd_above $ set.mem_range_self _) },
have hpk : p ^ k ∣ order_of t := nat.pow_factorization_dvd _ _,
have hpk' : order_of (t ^ p ^ k) = order_of t / p ^ k,
{ rw [order_of_pow' t (pow_ne_zero k hp.ne_zero), nat.gcd_eq_right hpk] },
obtain ⟨a, ha⟩ := nat.exists_eq_add_of_lt hpe,
have hcoprime : (order_of (t ^ p ^ k)).coprime (order_of g),
{ rw [hg, nat.coprime_pow_right_iff (pos_of_gt hpe), nat.coprime_comm],
apply or.resolve_right (nat.coprime_or_dvd_of_prime hp _),
nth_rewrite 0 ←pow_one p,
convert nat.pow_succ_factorization_not_dvd (h $ t ^ p ^ k).ne' hp,
rw [hpk', nat.factorization_div hpk],
simp [hp] },
rw [(commute.all _ g).order_of_mul_eq_mul_order_of_of_coprime hcoprime, hpk', hg, ha, ←ht, ←hk,
pow_add, pow_add, pow_one, ←mul_assoc, ←mul_assoc, nat.div_mul_cancel, mul_assoc,
lt_mul_iff_one_lt_right $ h t, ←pow_succ'],
exact one_lt_pow hp.one_lt a.succ_ne_zero,
exact hpk
end
@[to_additive] lemma exponent_eq_supr_order_of' :
exponent G = if ∃ g : G, order_of g = 0 then 0 else ⨆ g : G, order_of g :=
begin
split_ifs,
{ obtain ⟨g, hg⟩ := h,
exact exponent_eq_zero_of_order_zero hg },
{ have := not_exists.mp h,
exact exponent_eq_supr_order_of (λ g, ne.bot_lt $ this g) }
end
end comm_monoid
section cancel_comm_monoid
variables [cancel_comm_monoid G]
@[to_additive] lemma exponent_eq_max'_order_of [fintype G] :
exponent G = ((@finset.univ G _).image order_of).max' ⟨1, by simp⟩ :=
begin
rw [←finset.nonempty.cSup_eq_max', finset.coe_image, finset.coe_univ, set.image_univ, ← supr],
exact exponent_eq_supr_order_of order_of_pos
end
end cancel_comm_monoid
end monoid
|
module ShouldBeEmpty where
data Zero : Set where
data One : Set where
one : One
ok : Zero -> One
ok ()
bad : One -> One
bad ()
|
/* spio.c
*
* Copyright (C) 2016 Patrick Alken
* Copyright (C) 2016 Alexis Tantet
*
* 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 <config.h>
#include <stdlib.h>
#include <math.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_spmatrix.h>
/*
gsl_spmatrix_fprintf()
Print sparse matrix to file in MatrixMarket format:
M N NNZ
I1 J1 A(I1,J1)
...
Note that indices start at 1 and not 0
*/
int
gsl_spmatrix_fprintf(FILE *stream, const gsl_spmatrix *m,
const char *format)
{
int status;
/* print header */
status = fprintf(stream, "%%%%MatrixMarket matrix coordinate real general\n");
if (status < 0)
{
GSL_ERROR("fprintf failed for header", GSL_EFAILED);
}
/* print rows,columns,nnz */
status = fprintf(stream, "%u\t%u\t%u\n",
(unsigned int) m->size1,
(unsigned int) m->size2,
(unsigned int) m->nz);
if (status < 0)
{
GSL_ERROR("fprintf failed for dimension header", GSL_EFAILED);
}
if (GSL_SPMATRIX_ISTRIPLET(m))
{
size_t n;
for (n = 0; n < m->nz; ++n)
{
status = fprintf(stream, "%u\t%u\t", (unsigned int) m->i[n] + 1, (unsigned int) m->p[n] + 1);
if (status < 0)
{
GSL_ERROR("fprintf failed", GSL_EFAILED);
}
status = fprintf(stream, format, m->data[n]);
if (status < 0)
{
GSL_ERROR("fprintf failed", GSL_EFAILED);
}
status = putc('\n', stream);
if (status == EOF)
{
GSL_ERROR("putc failed", GSL_EFAILED);
}
}
}
else if (GSL_SPMATRIX_ISCCS(m))
{
size_t j, p;
for (j = 0; j < m->size2; ++j)
{
for (p = m->p[j]; p < m->p[j + 1]; ++p)
{
status = fprintf(stream, "%u\t%u\t", (unsigned int) m->i[p] + 1, (unsigned int) j + 1);
if (status < 0)
{
GSL_ERROR("fprintf failed", GSL_EFAILED);
}
status = fprintf(stream, format, m->data[p]);
if (status < 0)
{
GSL_ERROR("fprintf failed", GSL_EFAILED);
}
status = putc('\n', stream);
if (status == EOF)
{
GSL_ERROR("putc failed", GSL_EFAILED);
}
}
}
}
else if (GSL_SPMATRIX_ISCRS(m))
{
size_t i, p;
for (i = 0; i < m->size1; ++i)
{
for (p = m->p[i]; p < m->p[i + 1]; ++p)
{
status = fprintf(stream, "%u\t%u\t", (unsigned int) i + 1, (unsigned int) m->i[p] + 1);
if (status < 0)
{
GSL_ERROR("fprintf failed", GSL_EFAILED);
}
status = fprintf(stream, format, m->data[p]);
if (status < 0)
{
GSL_ERROR("fprintf failed", GSL_EFAILED);
}
status = putc('\n', stream);
if (status == EOF)
{
GSL_ERROR("putc failed", GSL_EFAILED);
}
}
}
}
else
{
GSL_ERROR("unknown sparse matrix type", GSL_EINVAL);
}
return GSL_SUCCESS;
}
gsl_spmatrix *
gsl_spmatrix_fscanf(FILE *stream)
{
gsl_spmatrix *m;
unsigned int size1, size2, nz;
char buf[1024];
int found_header = 0;
/* read file until we find rows,cols,nz header */
while (fgets(buf, 1024, stream) != NULL)
{
int c;
/* skip comments */
if (*buf == '%')
continue;
c = sscanf(buf, "%u %u %u",
&size1, &size2, &nz);
if (c == 3)
{
found_header = 1;
break;
}
}
if (!found_header)
{
GSL_ERROR_NULL ("fscanf failed reading header", GSL_EFAILED);
}
m = gsl_spmatrix_alloc_nzmax((size_t) size1, (size_t) size2, (size_t) nz, GSL_SPMATRIX_TRIPLET);
if (!m)
{
GSL_ERROR_NULL ("error allocating m", GSL_ENOMEM);
}
{
unsigned int i, j;
double val;
while (fgets(buf, 1024, stream) != NULL)
{
int c = sscanf(buf, "%u %u %lg", &i, &j, &val);
if (c < 3 || (i == 0) || (j == 0))
{
GSL_ERROR_NULL ("error in input file format", GSL_EFAILED);
}
else if ((i > size1) || (j > size2))
{
GSL_ERROR_NULL ("element exceeds matrix dimensions", GSL_EBADLEN);
}
else
{
/* subtract 1 from (i,j) since indexing starts at 1 */
gsl_spmatrix_set(m, i - 1, j - 1, val);
}
}
}
return m;
}
int
gsl_spmatrix_fwrite(FILE *stream, const gsl_spmatrix *m)
{
size_t items;
/* write header: size1, size2, nz */
items = fwrite(&(m->size1), sizeof(size_t), 1, stream);
if (items != 1)
{
GSL_ERROR("fwrite failed on size1", GSL_EFAILED);
}
items = fwrite(&(m->size2), sizeof(size_t), 1, stream);
if (items != 1)
{
GSL_ERROR("fwrite failed on size2", GSL_EFAILED);
}
items = fwrite(&(m->nz), sizeof(size_t), 1, stream);
if (items != 1)
{
GSL_ERROR("fwrite failed on nz", GSL_EFAILED);
}
/* write m->i and m->data which are size nz in all storage formats */
items = fwrite(m->i, sizeof(size_t), m->nz, stream);
if (items != m->nz)
{
GSL_ERROR("fwrite failed on row indices", GSL_EFAILED);
}
items = fwrite(m->data, sizeof(double), m->nz, stream);
if (items != m->nz)
{
GSL_ERROR("fwrite failed on data", GSL_EFAILED);
}
if (GSL_SPMATRIX_ISTRIPLET(m))
{
items = fwrite(m->p, sizeof(size_t), m->nz, stream);
if (items != m->nz)
{
GSL_ERROR("fwrite failed on column indices", GSL_EFAILED);
}
}
else if (GSL_SPMATRIX_ISCCS(m))
{
items = fwrite(m->p, sizeof(size_t), m->size2 + 1, stream);
if (items != m->size2 + 1)
{
GSL_ERROR("fwrite failed on column indices", GSL_EFAILED);
}
}
else if (GSL_SPMATRIX_ISCRS(m))
{
items = fwrite(m->p, sizeof(size_t), m->size1 + 1, stream);
if (items != m->size1 + 1)
{
GSL_ERROR("fwrite failed on column indices", GSL_EFAILED);
}
}
return GSL_SUCCESS;
}
int
gsl_spmatrix_fread(FILE *stream, gsl_spmatrix *m)
{
size_t size1, size2, nz;
size_t items;
/* read header: size1, size2, nz */
items = fread(&size1, sizeof(size_t), 1, stream);
if (items != 1)
{
GSL_ERROR("fread failed on size1", GSL_EFAILED);
}
items = fread(&size2, sizeof(size_t), 1, stream);
if (items != 1)
{
GSL_ERROR("fread failed on size2", GSL_EFAILED);
}
items = fread(&nz, sizeof(size_t), 1, stream);
if (items != 1)
{
GSL_ERROR("fread failed on nz", GSL_EFAILED);
}
if (m->size1 != size1)
{
GSL_ERROR("matrix has wrong size1", GSL_EBADLEN);
}
else if (m->size2 != size2)
{
GSL_ERROR("matrix has wrong size2", GSL_EBADLEN);
}
else if (nz > m->nzmax)
{
GSL_ERROR("matrix nzmax is too small", GSL_EBADLEN);
}
else
{
/* read m->i and m->data arrays, which are size nz for all formats */
items = fread(m->i, sizeof(size_t), nz, stream);
if (items != nz)
{
GSL_ERROR("fread failed on row indices", GSL_EFAILED);
}
items = fread(m->data, sizeof(double), nz, stream);
if (items != nz)
{
GSL_ERROR("fread failed on data", GSL_EFAILED);
}
m->nz = nz;
if (GSL_SPMATRIX_ISTRIPLET(m))
{
items = fread(m->p, sizeof(size_t), nz, stream);
if (items != nz)
{
GSL_ERROR("fread failed on column indices", GSL_EFAILED);
}
/* build binary search tree for m */
gsl_spmatrix_tree_rebuild(m);
}
else if (GSL_SPMATRIX_ISCCS(m))
{
items = fread(m->p, sizeof(size_t), size2 + 1, stream);
if (items != size2 + 1)
{
GSL_ERROR("fread failed on row pointers", GSL_EFAILED);
}
}
else if (GSL_SPMATRIX_ISCRS(m))
{
items = fread(m->p, sizeof(size_t), size1 + 1, stream);
if (items != size1 + 1)
{
GSL_ERROR("fread failed on column pointers", GSL_EFAILED);
}
}
}
return GSL_SUCCESS;
}
|
import Common
-- the `many` isomorphism: roughly List a <-> List b, constructed with
-- a retraction Maybe a < List b which satisfies a couple of simple
-- and necessary additional restrictions:
-- 1. (x:a) -> (all (isNothing . r) $ prefixes $ f (Just x) = True)
-- 2. (l:List b) -> isJust (r l) = True -> (f (r l)) = l
snoc : (x : a) -> List a -> List a
snoc x [] = [x]
snoc x (y :: xs) = (y :: snoc x xs)
reverse' : List a -> List a
reverse' [] = []
reverse' (x :: xs) = (snoc x (reverse' xs))
suffixes : List a -> List (List a)
suffixes [] = []
suffixes (x::xs) = xs :: suffixes xs
prefixes : List a -> List (List a)
prefixes = (map reverse') . suffixes . reverse'
all' : (a -> Bool) -> List a -> Bool
all' p [] = True
all' p (x::xs) = p x && all' p xs
data MRetraction : (a : Type) -> (b : Type) -> (f : Maybe a -> List b) -> (r : List b -> Maybe a) -> Type where
MkMRetraction : (f : Maybe a -> List b) ->
(r : List b -> Maybe a) ->
(v : (x : Maybe a) -> r (f x) = x) ->
(np: (x:a) -> (all' (isNothing . r) $ prefixes $ f (Just x) = True)) ->
(ji: (l:List b) -> isJust (r l) = True -> (f (r l)) = l) ->
(en: isNothing . r $ [] = True) ->
MRetraction a b f r
data Many : Type -> Type -> Type where
Nil : MRetraction a b f r ->
(l: List b) ->
(all' (isNothing . r) $ l :: prefixes l = True) ->
Many a b
Cons : MRetraction a b f r ->
a ->
Many a b ->
Many a b
-- ^ this should be isomorphic to regular lists. informal proof:
-- Firstly, there is a retraction (Maybe a) < (List b), such that for
-- any l:List b = f x:a, there's no prefixes (counting Nil) of l that
-- could be read as other `a` values, and hence no ambiguity after
-- concatenation.
-- Secondly, input that can't be parsed goes into Many's Nil, and any
-- data that goes into Cons could be restored (another requirement on
-- the retraction), hence no data from List gets lost.
-- Obviously, no ambiguity in Maybe a -> List a translation, and no
-- data gets lost on translation into the list. Except for retraction
-- and proofs, maybe, so not that obviously, but they are kinda fixed.
manyExtractFirst' : (r : b -> Maybe a) -> (l: List b) -> all' (isNothing . r) l = False -> a
manyExtractFirst' r [] prf = void $ trueNotFalse prf
manyExtractFirst' r (x :: xs) prf with (r x)
| Nothing = manyExtractFirst' r xs prf
| Just x = x
manyExtractFirst : (r : List b -> Maybe a) ->
(l: List b) ->
(all' (isNothing . r) $ l :: prefixes l = False) ->
(isNothing . r $ [] = True) ->
a
manyExtractFirst r l p n = manyExtractFirst' r (l :: prefixes l) p
many : MRetraction a b f r ->
Iso (Many a b) (List b)
many {a=a} {b=b} (MkMRetraction f r v np ji en) = MkIso to from tf ft
where
to : Many a b -> List b
to (Nil r l s) = l
to (Cons (MkMRetraction f _ _ _ _ _) x s) = f (Just x) ++ to s
from : List b -> Many a b
from l = case (inspect $ all' (isNothing . r) $ l :: prefixes l) of
(match True {eq=eq}) => Nil (MkMRetraction f r v np ji en) l eq
(match False {eq=eq}) =>
Cons (MkMRetraction f r v np ji en)
(manyExtractFirst r l eq en)
(from (assert_smaller l (drop (length (f (Just (manyExtractFirst r l eq en)))) l)))
tf x = ?manytf
ft x = ?manyft
-- `Many` without a tail
data Many' : Type -> Type -> Type where
Nil' : MRetraction a b f r ->
Many' a b
Cons' : MRetraction a b f r ->
a ->
Many' a b ->
Many' a b
isNil : Many a b -> Bool
isNil (Nil _ _ _) = True
isNil (Cons _ _ _) = False
mto' : Many a b -> Many' a b
mto' (Nil r l s) = Nil' r
mto' (Cons r x m) = Cons' r x (mto' m)
mfrom' : Many' a b -> Many a b
mfrom' (Nil' (MkMRetraction f r v np ji en)) = Nil (MkMRetraction f r v np ji en) [] (rewrite en in Refl)
mfrom' (Cons' r x m) = Cons r x (mfrom' m)
mtail : Many a b -> List b
mtail (Cons _ _ m) = mtail m
mtail (Nil _ l _) = l
manyAnd : (mi: Iso (Many a b) (List b)) ->
(cr: Retraction c (List b) cto cfrom) ->
((x:c) -> (isNil (unappIso mi (cto x)) = True)) ->
((l:List b) -> (isNil (unappIso mi l) = True) -> (cto (cfrom l) = l)) ->
Iso (Many' a b, c) (List b)
manyAnd {a=a} {b=b} (MkIso mto mfrom mtf mft) (MkRetraction cto cfrom cft) p p2 = MkIso to from tf ft
where
to : (Many' a b, c) -> List b
to (x, y) = mto (mfrom' x) ++ cto y
from : List b -> (Many' a b, c)
from l = case (mfrom l) of
m => (mto' m, cfrom (mtail m))
tf x = ?mvtf -- rewrite (ctf (mtail (mfrom x))) in ?mvtf
ft x = ?mvft
-- examples
data Foo = Zero | One | End
bcto' : List Bool -> List Foo
bcto' [] = [End]
bcto' (False::xs) = Zero :: bcto' xs
bcto' (True::xs) = One :: bcto' xs
bcto : Maybe (List Bool) -> List Foo
bcto Nothing = []
bcto (Just l) = bcto' l
bcfrom : List Foo -> Maybe (List Bool)
bcfrom (Zero::xs) = do
rest <- bcfrom xs
Just (False :: rest)
bcfrom (One::xs) = do
rest <- bcfrom xs
Just (True :: rest)
bcfrom [End] = Just []
bcfrom _ = Nothing
boolFoo : MRetraction (List Bool) Foo bcto bcfrom
boolFoo = MkMRetraction bcto bcfrom v np ji en
where
v' : (l: List Bool) -> bcfrom (bcto' l) = Just l
v' [] = Refl
v' (False :: xs) = rewrite (v' xs) in Refl
v' (True :: xs) = rewrite (v' xs) in Refl
v : (l: Maybe (List Bool)) -> bcfrom (bcto l) = l
v Nothing = Refl
v (Just l) = v' l
np x = believe_me ()
ji l p = believe_me ()
en = Refl
bsto : Bool -> Foo
bsto True = One
bsto False = Zero
bsfrom : Foo -> Bool
bsfrom End = False
bsfrom Zero = False
bsfrom One = True
boolFooS : Retraction (List Bool) (List Foo) (map bsto) (map bsfrom)
boolFooS = MkRetraction (map bsto) (map bsfrom) v
where
v [] = Refl
v (False :: xs) = cong (v xs)
v (True :: xs) = cong (v xs)
bfnbf : Iso (Many' (List Bool) Foo, List Bool) (List Foo)
bfnbf = manyAnd (many boolFoo) boolFooS p1 p2
where
-- ((x:List Bool) -> (isNil (unappIso (many boolFoo) (bsto x)) = True))
-- there's never `End` in `bsto`, so it's `Nil`
p1 = believe_me ()
-- ((l:List b) -> (isNil (unappIso (many boolFoo) l) = True) -> (bsto (bsfrom l) = l))
-- `Nil` happens only if there's no `End`, and in that case `bsto (bsfrom l) = l`
p2 = believe_me ()
lfNil : Many (List Bool) Foo
lfNil = Nil boolFoo [] Refl
lfCons : List Bool -> Many (List Bool) Foo -> Many (List Bool) Foo
lfCons l m = Cons boolFoo l m
lfTest : Many (List Bool) Foo
lfTest =
lfCons [True, False, True, True] $
lfCons [True, True] $
lfCons [False, False] $
lfNil
-- λΠ> appIso (many boolFoo) lfTest
-- [One, Zero, One, One, End, One, One, End, Zero, Zero, End] : List Foo
-- λΠ> appIso (many boolFoo) $ unappIso (many boolFoo) [One, Zero, One, One, End, One, One, End, Zero, Zero]
-- [One, Zero, One, One, End, One, One, End, Zero, Zero] : List Foo
-- λΠ> appIso bfnbf ((mto' lfTest), [True, False])
-- [One, Zero, One, One, End, One, One, End, Zero, Zero, End, One, Zero] : List Foo
|
The FINANCIAL (AD) -- ProCredit Bank has donated a unique ex libris collection to the National Centre of Manuscripts. This donation was part of a project jointly initiated by the National Centre of Manuscripts and ProCredit Bank, in which the Bank bought a unique collection of ex librises from a private individual living in Thessaloniki, Greece.
Many of the graphic images on the ex librises were the work of Georgian painters, so their donation to the National Centre of Manuscripts is a very important contribution to preserving the heritage of Georgian manuscripts. They carry additional information about the life and creative work of Georgia’s artists and important public figures.
“From ProCredit Bank’s side we are extremely delighted to have had the chance to support Georgia’s culture and inheritance of manuscripts. It’s extremely rewarding to have had the chance to hand over this unique and interesting collection of ex librises to the National Centre of Manuscripts; that we had the opportunity to obtain these very interesting examples of Georgian culture and history. By handing this collection today to the National Centre of Manuscripts we also, one more time, want to demonstrate our support for the development of Georgian culture. All in all I think it’s a very promising beginning for a hopefully fruitful and long-lasting relationship with the National Centre of Manuscripts,” said Sascha Ternes, General Director of JSC ProCredit Bank.
“In the National Centre of Manuscripts there are manuscripts, historical documents, archival materials and library collections. This is one of the largest collections across the country. It has been gathering material and growing since the 19th century; this process is still ongoing and will never be finished. The collection has mainly grown from people’s donations, except for a few exceptions. Over the years we received donations from individuals, families, from private companies, public and private organizations. And the result is a unique collection which is now protected by the National Centre of Manuscripts,” he added.
“Today, one of the priorities for us is searching for new materials and continuing the pursuit of our great ancestors, who began collecting such materials in the 19th century. We also have another sub-priority, as just like this material was found in a foreign country, great care is needed not to lose Georgia-related materials that may be located abroad. They shouldn’t fall into someone else’s hands, in some cases private collectors. Then the trace will be lost,” Buba Kudava said.
“We were searching over the internet with our colleagues for information of this sort, and we managed to connect with an individual in Thessaloniki, Greece. We asked them to send us information on a regular basis about Georgia-related materials. And indeed they sent us the ex libris collection and when we showed this material to experts, it turned out to be very interesting. There are many famous figures associated with these ex librises. On the one hand, one part of this collection was designed by well-known artists. The second part is known because it is created for famous statesmen, but by a lesser-known Georgian painter. The first is the Elene Akhvlediani ex libris, the second is the Sergo Kobuladze ex libris. We did not have a separate collection of ex librises until now. Of course there are such materials in archives and in books, but so far we have not had such an amount of ex librises,” he said.
“Ex librises were invented along with book printing and were an integral part of a book through the ages. Today, some of them are considered works of art. That is why participation in such a project is very important for ProCredit Bank, and we are very pleased that this unique ex libris collection has been added to the heritage of Georgian manuscripts,” said Sascha Ternes, General Director of JSC ProCredit Bank.
The term “ex libris” is Latin for “from the library of”, and is used to describe a printed label on the inside front cover of a book indicating the name of the owner. In the past, ex librises often took the form of a drawing, an emblem or an illustration of some famous event, sometimes by a famous artist. |
lemma convergent_eq_Cauchy: fixes S :: "nat \<Rightarrow> 'a::complete_space" shows "(\<exists>l. (S \<longlongrightarrow> l) sequentially) \<longleftrightarrow> Cauchy S" |
------------------------------------------------------------------------
-- A virtual machine
------------------------------------------------------------------------
open import Prelude
import Lambda.Virtual-machine.Instructions
module Lambda.Virtual-machine
{Name : Type}
(open Lambda.Virtual-machine.Instructions Name)
(def : Name → Code 1)
where
open import Equality.Propositional
open import Colist equality-with-J as Colist using (Colist)
open import List equality-with-J using (_++_; length)
open import Monad equality-with-J
open import Vec.Data equality-with-J
open import Lambda.Delay-crash using (Delay-crash)
open import Lambda.Delay-crash-trace
open import Lambda.Syntax Name
open Closure Code
-- A single step of the computation.
step : State → Result
step ⟨ var x ∷ c , s , ρ ⟩ = continue ⟨ c , val (index ρ x) ∷ s , ρ ⟩
step ⟨ clo c′ ∷ c , s , ρ ⟩ = continue ⟨ c , val (lam c′ ρ) ∷ s , ρ ⟩
step ⟨ app ∷ c , val v ∷ val (lam c′ ρ′) ∷ s , ρ ⟩ = continue ⟨ c′ , ret c ρ ∷ s , v ∷ ρ′ ⟩
step ⟨ ret ∷ c , val v ∷ ret c′ ρ′ ∷ s , ρ ⟩ = continue ⟨ c′ , val v ∷ s , ρ′ ⟩
step ⟨ cal f ∷ c , val v ∷ s , ρ ⟩ = continue ⟨ def f , ret c ρ ∷ s , v ∷ [] ⟩
step ⟨ tcl f ∷ c , val v ∷ s , ρ ⟩ = continue ⟨ def f , s , v ∷ [] ⟩
step ⟨ con b ∷ c , s , ρ ⟩ = continue ⟨ c , val (con b) ∷ s , ρ ⟩
step ⟨ bra c₁ c₂ ∷ c , val (con true) ∷ s , ρ ⟩ = continue ⟨ c₁ ++ c , s , ρ ⟩
step ⟨ bra c₁ c₂ ∷ c , val (con false) ∷ s , ρ ⟩ = continue ⟨ c₂ ++ c , s , ρ ⟩
step ⟨ [] , val v ∷ [] , [] ⟩ = done v
step _ = crash
-- A functional semantics for the VM. The result includes a trace of
-- all the encountered states.
mutual
exec⁺ : ∀ {i} → State → Delay-crash-trace State Value i
exec⁺ s = later s λ { .force → exec⁺′ (step s) }
exec⁺′ : ∀ {i} → Result → Delay-crash-trace State Value i
exec⁺′ (continue s) = exec⁺ s
exec⁺′ (done v) = now v
exec⁺′ crash = crash
-- The semantics without the trace of states.
exec : ∀ {i} → State → Delay-crash Value i
exec = delay-crash ∘ exec⁺
-- The stack sizes of all the encountered states.
stack-sizes : ∀ {i} → State → Colist ℕ i
stack-sizes =
Colist.map (λ { ⟨ _ , s , _ ⟩ → length s }) ∘ trace ∘ exec⁺
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.