text
stringlengths 0
3.34M
|
---|
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Mario Carneiro
-/
import data.finset.basic
/-!
# The powerset of a finset
-/
namespace finset
open multiset
variables {α : Type*}
/-! ### powerset -/
section powerset
/-- When `s` is a finset, `s.powerset` is the finset of all subsets of `s` (seen as finsets). -/
def powerset (s : finset α) : finset (finset α) :=
⟨s.1.powerset.pmap finset.mk
(λ t h, nodup_of_le (mem_powerset.1 h) s.2),
nodup_pmap (λ a ha b hb, congr_arg finset.val)
(nodup_powerset.2 s.2)⟩
@[simp] theorem mem_powerset {s t : finset α} : s ∈ powerset t ↔ s ⊆ t :=
by cases s; simp only [powerset, mem_mk, mem_pmap, mem_powerset, exists_prop, exists_eq_right];
rw ← val_le_iff
@[simp] theorem empty_mem_powerset (s : finset α) : ∅ ∈ powerset s :=
mem_powerset.2 (empty_subset _)
@[simp] theorem mem_powerset_self (s : finset α) : s ∈ powerset s :=
mem_powerset.2 (subset.refl _)
@[simp] lemma powerset_empty : finset.powerset (∅ : finset α) = {∅} := rfl
@[simp] theorem powerset_mono {s t : finset α} : powerset s ⊆ powerset t ↔ s ⊆ t :=
⟨λ h, (mem_powerset.1 $ h $ mem_powerset_self _),
λ st u h, mem_powerset.2 $ subset.trans (mem_powerset.1 h) st⟩
@[simp] theorem card_powerset (s : finset α) :
card (powerset s) = 2 ^ card s :=
(card_pmap _ _ _).trans (card_powerset s.1)
lemma not_mem_of_mem_powerset_of_not_mem {s t : finset α} {a : α}
(ht : t ∈ s.powerset) (h : a ∉ s) : a ∉ t :=
by { apply mt _ h, apply mem_powerset.1 ht }
lemma powerset_insert [decidable_eq α] (s : finset α) (a : α) :
powerset (insert a s) = s.powerset ∪ s.powerset.image (insert a) :=
begin
ext t,
simp only [exists_prop, mem_powerset, mem_image, mem_union, subset_insert_iff],
by_cases h : a ∈ t,
{ split,
{ exact λH, or.inr ⟨_, H, insert_erase h⟩ },
{ intros H,
cases H,
{ exact subset.trans (erase_subset a t) H },
{ rcases H with ⟨u, hu⟩,
rw ← hu.2,
exact subset.trans (erase_insert_subset a u) hu.1 } } },
{ have : ¬ ∃ (u : finset α), u ⊆ s ∧ insert a u = t,
by simp [ne.symm (ne_insert_of_not_mem _ _ h)],
simp [finset.erase_eq_of_not_mem h, this] }
end
end powerset
section powerset_len
/-- Given an integer `n` and a finset `s`, then `powerset_len n s` is the finset of subsets of `s`
of cardinality `n`.-/
def powerset_len (n : ℕ) (s : finset α) : finset (finset α) :=
⟨(s.1.powerset_len n).pmap finset.mk
(λ t h, nodup_of_le (mem_powerset_len.1 h).1 s.2),
nodup_pmap (λ a ha b hb, congr_arg finset.val)
(nodup_powerset_len s.2)⟩
theorem mem_powerset_len {n} {s t : finset α} :
s ∈ powerset_len n t ↔ s ⊆ t ∧ card s = n :=
by cases s; simp [powerset_len, val_le_iff.symm]; refl
@[simp] theorem powerset_len_mono {n} {s t : finset α} (h : s ⊆ t) :
powerset_len n s ⊆ powerset_len n t :=
λ u h', mem_powerset_len.2 $
and.imp (λ h₂, subset.trans h₂ h) id (mem_powerset_len.1 h')
@[simp] theorem card_powerset_len (n : ℕ) (s : finset α) :
card (powerset_len n s) = nat.choose (card s) n :=
(card_pmap _ _ _).trans (card_powerset_len n s.1)
theorem powerset_len_eq_filter {n} {s : finset α} :
powerset_len n s = (powerset s).filter (λ x, x.card = n) :=
by { ext, simp [mem_powerset_len] }
end powerset_len
end finset |
{-# OPTIONS --cubical --safe #-}
open import Algebra
open import Prelude
open import HITs.PropositionalTruncation
open import HITs.PropositionalTruncation.Sugar
module Algebra.Construct.Cayley {a} (mon : Monoid a) where
open Monoid mon
𝒞 : Type a
𝒞 = Σ[ f ⦂ (𝑆 → 𝑆) ] × ∀ x → ∥ f ε ∙ x ≡ f x ∥
⟦_⇓⟧ : 𝒞 → 𝑆
⟦ x ⇓⟧ = x .fst ε
⟦_⇑⟧ : 𝑆 → 𝒞
⟦ x ⇑⟧ .fst y = x ∙ y
⟦ x ⇑⟧ .snd y = ∣ cong (_∙ y) (∙ε x) ∣
ⓔ : 𝒞
ⓔ .fst x = x
ⓔ .snd x = ∣ ε∙ x ∣
open import Relation.Binary
open import HITs.PropositionalTruncation.Equivalence
open import Relation.Binary.Equivalence.Reasoning (trunc-equivalence (≡-equivalence {A = 𝑆}))
_⊙_ : 𝒞 → 𝒞 → 𝒞
(x ⊙ y) .fst z = x .fst (y .fst z)
(x ⊙ y) .snd z =
x .fst (y .fst ε) ∙ z ≋˘⟨ cong (_∙ z) ∥$∥ (x .snd (y .fst ε)) ⟩
x .fst ε ∙ y .fst ε ∙ z ≡⟨ assoc (x .fst ε) (y .fst ε) z ⟩
x .fst ε ∙ (y .fst ε ∙ z) ≋⟨ cong (x .fst ε ∙_) ∥$∥ (y .snd z) ⟩
x .fst ε ∙ y .fst z ≋⟨ x .snd (y .fst z) ⟩
x .fst (y .fst z) ∎
⊙-assoc : Associative _⊙_
⊙-assoc x y z i .fst k = x .fst (y .fst (z .fst k))
⊙-assoc x y z i .snd k = squash (((x ⊙ y) ⊙ z) .snd k) ((x ⊙ (y ⊙ z)) .snd k) i
ⓔ⊙ : ∀ x → ⓔ ⊙ x ≡ x
ⓔ⊙ x i .fst y = x .fst y
ⓔ⊙ x i .snd y = squash ((ⓔ ⊙ x) .snd y) (x .snd y) i
⊙ⓔ : ∀ x → x ⊙ ⓔ ≡ x
⊙ⓔ x i .fst y = x .fst y
⊙ⓔ x i .snd y = squash ((x ⊙ ⓔ) .snd y) (x .snd y) i
cayleyMonoid : Monoid a
Monoid.𝑆 cayleyMonoid = 𝒞
Monoid._∙_ cayleyMonoid = _⊙_
Monoid.ε cayleyMonoid = ⓔ
Monoid.assoc cayleyMonoid = ⊙-assoc
Monoid.ε∙ cayleyMonoid = ⓔ⊙
Monoid.∙ε cayleyMonoid = ⊙ⓔ
open import Data.Sigma.Properties
module _ (sIsSet : isSet 𝑆) where
𝒞-leftInv-fst : ∀ x y → ⟦ ⟦ x ⇓⟧ ⇑⟧ .fst y ≡ x .fst y
𝒞-leftInv-fst x y = rec (sIsSet (x .fst ε ∙ y) (x .fst y)) id (x .snd y)
𝒞-leftInv : ∀ x → ⟦ ⟦ x ⇓⟧ ⇑⟧ ≡ x
𝒞-leftInv x = Σ≡Prop (λ f xs ys → funExt λ x → squash (xs x) (ys x)) (funExt (𝒞-leftInv-fst x))
𝒞-iso : 𝒞 ⇔ 𝑆
fun 𝒞-iso = ⟦_⇓⟧
inv 𝒞-iso = ⟦_⇑⟧
rightInv 𝒞-iso = ∙ε
leftInv 𝒞-iso = 𝒞-leftInv
|
Formal statement is: lemma kuhn_counting_lemma: fixes bnd compo compo' face S F defines "nF s == card {f\<in>F. face f s \<and> compo' f}" assumes [simp, intro]: "finite F" \<comment> \<open>faces\<close> and [simp, intro]: "finite S" \<comment> \<open>simplices\<close> and "\<And>f. f \<in> F \<Longrightarrow> bnd f \<Longrightarrow> card {s\<in>S. face f s} = 1" and "\<And>f. f \<in> F \<Longrightarrow> \<not> bnd f \<Longrightarrow> card {s\<in>S. face f s} = 2" and "\<And>s. s \<in> S \<Longrightarrow> compo s \<Longrightarrow> nF s = 1" and "\<And>s. s \<in> S \<Longrightarrow> \<not> compo s \<Longrightarrow> nF s = 0 \<or> nF s = 2" and "odd (card {f\<in>F. compo' f \<and> bnd f})" shows "odd (card {s\<in>S. compo s})" Informal statement is: If $F$ is a finite set of faces of a simplicial complex $S$, and if $F$ satisfies certain conditions, then the number of simplices in $S$ is odd. |
I am currently an animal science student at UC Davis.
I live to eatnot the other way around.
Welcome to the Wiki! Have a link! Users/TomGarberson
20110802 12:19:07 nbsp Hey, its easier than you might think to add an include macro. To flag something as departed, just put either {{{Include(Departed Business)}}} or {{{Include(NoLongerExists)}}} at the top. It automatically includes the text and icon. No cutting and pasting needed and dont worry, youre not the first to copy and paste it (and Im sure you wont be the last).
Users/JabberWokky
20120930 21:30:24 nbsp Hi there, Its the Bike People....really glad you found the part you needed! Users/mikestarchild
|
Formal statement is: lemma contour_integral_rmul: shows "f contour_integrable_on g \<Longrightarrow> contour_integral g (\<lambda>x. f x * c) = contour_integral g f * c" Informal statement is: If $f$ is integrable on a contour $g$, then $f(x)c$ is integrable on $g$ and $\int_g f(x)c = \int_g f(x)c$. |
import os
import sys
import numpy as np
import pandas as pd
import openmc.data
def get_temp(path):
_temp_key = path[-3]
temp_dict = {
'0': '294K', # filename: 89225.800nc
'1': '600K',
'2': '900K',
'3': '1200K',
'4': '2500K',
'5': '0K',
'6': '250K',
'a': '294K', # filename: Co_058m1_293.6K.ace
}
return temp_dict[_temp_key]
def export_xs_data(path):
ace = openmc.data.IncidentNeutron.from_ace(path, metastable_scheme='mcnp')
temp = get_temp(path)
# df1 = pd.DataFrame()
df = pd.DataFrame()
_energy = ace.energy[temp]
_total_xs = ace[1].xs[temp](_energy)
# df[ace.atomic_symbol] = ['E_eV']
# df[ace.mass_number] = ['Sig_b']
# df1[ace.atomic_symbol] = _energy
# df1[ace.mass_number] = _total_xs
# df = df.append(df1)
df['E_eV'] = _energy
df['Sig_b'] = _total_xs
name = ace.name
if '_' in name:
fname = ace.atomic_symbol + '-' + str(ace.mass_number) + '_' + name.split('_')[-1] + '.csv'
else:
fname = ace.atomic_symbol + '-' + str(ace.mass_number) + '.csv'
sub_dir = temp
if not os.path.exists(sub_dir):
os.makedirs(sub_dir)
df.to_csv(temp + '/' + fname, index=False, float_format='%g')
loc = pd.read_csv('/Users/y9z/Documents/database/ENDF_B_VII_RT/xsdir', '/t', header=None)
cwd = '/Users/y9z/Documents/database/ENDF_B_VII_RT/'
print(loc)
# for each in loc[0]:
# sp = each.split(' ')
# path = cwd + sp[2]
# print(path)
# export_xs_data(path)
|
[STATEMENT]
lemma wt_arg_le: "wt (arg s) \<le> wt s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. wt (arg s) \<le> wt s
[PROOF STEP]
by (cases s) auto |
The Hamlin Lake Preservation Society has two web sites.
To see current topics, go to HamlinLake.us web site.
To see historical topics, use the HamlinLakePreservation.org web site.
The Hamlin Lake Preservation Society is a non-profit, educational organization that represents riparian owners and interested friends of Hamlin Lake. Our organization does this in a variety of ways from monitoring water quality and weed distribution, producing a newsletter, to sponsoring activities on the lake such as fireworks, and sailboat races. |
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <gsl/gsl_permutation.h>
#include <gsl/gsl_sf_gamma.h>
int
main(int argc, char *argv[]){
gsl_permutation *P;
size_t l;
if(2!=argc){
return 1;
}
l=strlen(argv[1]);
if(GSL_SF_FACT_NMAX<l){
printf("String too long\n");
return 1;
}
P=gsl_permutation_calloc(l);
assert(NULL!=P);
do{
size_t *d=gsl_permutation_data(P),i;
for(i=0;i<l;i++)
printf("%c",argv[1][d[i]]);
printf("\n");
}while(GSL_SUCCESS==gsl_permutation_next(P));
return 0;
}
|
[STATEMENT]
lemma bind_count_space_singleton:
assumes "subprob_space (f x)"
shows "count_space {x} \<bind> f = f x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. count_space {x} \<bind> f = f x
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. count_space {x} \<bind> f = f x
[PROOF STEP]
have A: "\<And>A. A \<subseteq> {x} \<Longrightarrow> A = {} \<or> A = {x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<And>A. A \<subseteq> {x} \<Longrightarrow> A = {} \<or> A = {x}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?A \<subseteq> {x} \<Longrightarrow> ?A = {} \<or> ?A = {x}
goal (1 subgoal):
1. count_space {x} \<bind> f = f x
[PROOF STEP]
have "count_space {x} = return (count_space {x}) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. count_space {x} = return (count_space {x}) x
[PROOF STEP]
by (intro measure_eqI) (auto dest: A)
[PROOF STATE]
proof (state)
this:
count_space {x} = return (count_space {x}) x
goal (1 subgoal):
1. count_space {x} \<bind> f = f x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
count_space {x} = return (count_space {x}) x
goal (1 subgoal):
1. count_space {x} \<bind> f = f x
[PROOF STEP]
have "... \<bind> f = f x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. return (count_space {x}) x \<bind> f = f x
[PROOF STEP]
by (subst bind_return[of _ _ "f x"]) (auto simp: space_subprob_algebra assms)
[PROOF STATE]
proof (state)
this:
return (count_space {x}) x \<bind> f = f x
goal (1 subgoal):
1. count_space {x} \<bind> f = f x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
count_space {x} \<bind> f = f x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
count_space {x} \<bind> f = f x
goal (1 subgoal):
1. count_space {x} \<bind> f = f x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
count_space {x} \<bind> f = f x
goal:
No subgoals!
[PROOF STEP]
qed |
(* Title: HOL/Auth/n_germanSimp_lemma_on_inv__58.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_germanSimp Protocol Case Study*}
theory n_germanSimp_lemma_on_inv__58 imports n_germanSimp_base
begin
section{*All lemmas on causal relation between inv__58 and some rule r*}
lemma n_RecvReqSVsinv__58:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_RecvReqS N i)" and
a2: "(\<exists> p__Inv3 p__Inv4. p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4)"
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_RecvReqS N i" apply fastforce done
from a2 obtain p__Inv3 p__Inv4 where a2:"p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i=p__Inv3)\<or>(i~=p__Inv3\<and>i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv4)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Para (Ident ''Chan2'') p__Inv4) ''Cmd'')) (Const Inv)) (eqn (IVar (Field (Para (Ident ''Cache'') p__Inv4) ''State'')) (Const I))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i=p__Inv3)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (eqn (IVar (Ident ''CurCmd'')) (Const Empty)) (eqn (IVar (Field (Para (Ident ''Chan2'') p__Inv4) ''Cmd'')) (Const Inv))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv3\<and>i~=p__Inv4)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (eqn (IVar (Ident ''CurCmd'')) (Const Empty)) (eqn (IVar (Field (Para (Ident ''Chan2'') p__Inv4) ''Cmd'')) (Const Inv))))" 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_RecvReqE__part__0Vsinv__58:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_RecvReqE__part__0 N i)" and
a2: "(\<exists> p__Inv3 p__Inv4. p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4)"
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_RecvReqE__part__0 N i" apply fastforce done
from a2 obtain p__Inv3 p__Inv4 where a2:"p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i=p__Inv3)\<or>(i~=p__Inv3\<and>i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=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: "(i=p__Inv3)"
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__Inv3\<and>i~=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_RecvReqE__part__1Vsinv__58:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_RecvReqE__part__1 N i)" and
a2: "(\<exists> p__Inv3 p__Inv4. p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4)"
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_RecvReqE__part__1 N i" apply fastforce done
from a2 obtain p__Inv3 p__Inv4 where a2:"p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i=p__Inv3)\<or>(i~=p__Inv3\<and>i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=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: "(i=p__Inv3)"
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__Inv3\<and>i~=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_SendInv__part__0Vsinv__58:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendInv__part__0 i)" and
a2: "(\<exists> p__Inv3 p__Inv4. p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4)"
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__Inv3 p__Inv4 where a2:"p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i=p__Inv3)\<or>(i~=p__Inv3\<and>i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=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: "(i=p__Inv3)"
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__Inv3\<and>i~=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_SendInv__part__1Vsinv__58:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendInv__part__1 i)" and
a2: "(\<exists> p__Inv3 p__Inv4. p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4)"
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__Inv3 p__Inv4 where a2:"p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i=p__Inv3)\<or>(i~=p__Inv3\<and>i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv4)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (andForm (eqn (IVar (Para (Ident ''InvSet'') p__Inv3)) (Const true)) (eqn (IVar (Ident ''ExGntd'')) (Const true))) (eqn (IVar (Para (Ident ''InvSet'') p__Inv4)) (Const true))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i=p__Inv3)"
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__Inv3\<and>i~=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_SendInvAckVsinv__58:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendInvAck i)" and
a2: "(\<exists> p__Inv3 p__Inv4. p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4)"
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__Inv3 p__Inv4 where a2:"p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i=p__Inv3)\<or>(i~=p__Inv3\<and>i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=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: "(i=p__Inv3)"
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__Inv3\<and>i~=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_SendGntSVsinv__58:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendGntS i)" and
a2: "(\<exists> p__Inv3 p__Inv4. p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4)"
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__Inv3 p__Inv4 where a2:"p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i=p__Inv3)\<or>(i~=p__Inv3\<and>i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=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: "(i=p__Inv3)"
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__Inv3\<and>i~=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_SendGntEVsinv__58:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendGntE N i)" and
a2: "(\<exists> p__Inv3 p__Inv4. p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4)"
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__Inv3 p__Inv4 where a2:"p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i=p__Inv3)\<or>(i~=p__Inv3\<and>i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=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: "(i=p__Inv3)"
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__Inv3\<and>i~=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_RecvGntSVsinv__58:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_RecvGntS i)" and
a2: "(\<exists> p__Inv3 p__Inv4. p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4)"
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__Inv3 p__Inv4 where a2:"p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i=p__Inv3)\<or>(i~=p__Inv3\<and>i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=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: "(i=p__Inv3)"
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__Inv3\<and>i~=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_RecvGntEVsinv__58:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_RecvGntE i)" and
a2: "(\<exists> p__Inv3 p__Inv4. p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4)"
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__Inv3 p__Inv4 where a2:"p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i=p__Inv3)\<or>(i~=p__Inv3\<and>i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=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: "(i=p__Inv3)"
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__Inv3\<and>i~=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_StoreVsinv__58:
assumes a1: "\<exists> i d. i\<le>N\<and>d\<le>N\<and>r=n_Store i d" and
a2: "(\<exists> p__Inv3 p__Inv4. p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_RecvInvAckVsinv__58:
assumes a1: "\<exists> i. i\<le>N\<and>r=n_RecvInvAck i" and
a2: "(\<exists> p__Inv3 p__Inv4. p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__58 p__Inv3 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
end
|
(* Author: Tobias Nipkow
Copyright 1998 TUM
*)
header "Deterministic automata"
theory DA
imports AutoProj
begin
type_synonym ('a,'s)da = "'s * ('a => 's => 's) * ('s => bool)"
definition
foldl2 :: "('a => 'b => 'b) => 'a list => 'b => 'b" where
"foldl2 f xs a = foldl (%a b. f b a) a xs"
definition
delta :: "('a,'s)da => 'a list => 's => 's" where
"delta A = foldl2 (next A)"
definition
accepts :: "('a,'s)da => 'a list => bool" where
"accepts A = (%w. fin A (delta A w (start A)))"
lemma delta_Nil[simp]: "delta A [] s = s"
by(simp add:delta_def)
lemma delta_Cons[simp]: "delta A (a#w) s = delta A w (next A a s)"
by(simp add:delta_def)
lemma delta_append[simp]:
"!!q ys. delta A (xs@ys) q = delta A ys (delta A xs q)"
by(induct xs) simp_all
end
|
State Before: α : Type u_1
l : List α
inst✝ : DecidableEq α
a : α
⊢ count a [a] = 1 State After: α : Type u_1
l : List α
inst✝ : DecidableEq α
a : α
⊢ (if a = a then succ (count a []) else count a []) = 1 Tactic: rw [count_cons] State Before: α : Type u_1
l : List α
inst✝ : DecidableEq α
a : α
⊢ (if a = a then succ (count a []) else count a []) = 1 State After: no goals Tactic: simp |
Formal statement is: lemma locally_connected_components: "\<lbrakk>locally connected S; c \<in> components S\<rbrakk> \<Longrightarrow> locally connected c" Informal statement is: If $S$ is a locally connected space and $c$ is a component of $S$, then $c$ is locally connected. |
#nens landings pre may 15
p = bio.snowcrab::load.environment()
a = logbook.db('logbook')
a = a[which(a$cfa=='cfanorth'),]
b = aggregate(landings~yr,data=a,FUN=sum)
y=2005:2015
x=data.frame(yr=NA,tot.l=NA,ear.l=NA)
for(i in 1:length(y)){
r = a[which(a$yr==y[i]),]
dd = paste(y[i],'05','16',sep="-")
r = r[which(r$date.fished<dd),]
g=0
if(nrow(r)>0) {g = aggregate(landings~yr,data=r,FUN=sum)[2]}
x[i,] = c(y[i],b[which(b$yr==y[i]),'landings'],g)
}
table.view(x)
|
(*
* Copyright 2014, General Dynamics C4 Systems
*
* SPDX-License-Identifier: GPL-2.0-only
*)
(*
Results about CNode Invocations, particularly the
recursive revoke and delete operations.
*)
theory CNodeInv_AI
imports "./$L4V_ARCH/ArchIpc_AI"
begin
context begin interpretation Arch .
requalify_facts
set_cap_arch
cte_at_length_limit
arch_derive_cap_untyped
valid_arch_mdb_cap_swap
end
declare set_cap_arch[wp]
primrec
valid_cnode_inv :: "cnode_invocation \<Rightarrow> 'z::state_ext state \<Rightarrow> bool"
where
"valid_cnode_inv (InsertCall cap ptr ptr') =
(valid_cap cap and real_cte_at ptr and real_cte_at ptr' and
(\<lambda>s. cte_wp_at (is_derived (cdt s) ptr cap) ptr s) and
cte_wp_at (\<lambda>c. c = NullCap) ptr' and
ex_cte_cap_wp_to is_cnode_cap ptr' and K (ptr \<noteq> ptr') and
(\<lambda>s. \<forall>r\<in>obj_refs cap. \<forall>p'.
ptr' \<noteq> p' \<and> cte_wp_at (\<lambda>cap'. r \<in> obj_refs cap') p' s \<longrightarrow>
cte_wp_at (Not \<circ> is_zombie) p' s \<and> \<not> is_zombie cap))"
| "valid_cnode_inv (MoveCall cap ptr ptr') =
(valid_cap cap and cte_wp_at ((=) cap.NullCap) ptr' and
cte_wp_at ((\<noteq>) NullCap) ptr and cte_wp_at (weak_derived cap) ptr and
cte_wp_at (\<lambda>c. is_untyped_cap c \<longrightarrow> c = cap) ptr and
ex_cte_cap_wp_to is_cnode_cap ptr' and
real_cte_at ptr and real_cte_at ptr')"
| "valid_cnode_inv (RevokeCall ptr) = cte_at ptr"
| "valid_cnode_inv (DeleteCall ptr) = real_cte_at ptr"
| "valid_cnode_inv (RotateCall s_cap p_cap src pivot dest) =
(valid_cap s_cap and valid_cap p_cap and
real_cte_at src and real_cte_at dest and real_cte_at pivot and
cte_wp_at (weak_derived s_cap) src and
cte_wp_at (\<lambda>c. is_untyped_cap c \<longrightarrow> c = s_cap) src and
cte_wp_at ((\<noteq>) NullCap) src and
cte_wp_at (weak_derived p_cap) pivot and
cte_wp_at (\<lambda>c. is_untyped_cap c \<longrightarrow> c = p_cap) pivot and
cte_wp_at ((\<noteq>) NullCap) pivot and K (src \<noteq> pivot \<and> pivot \<noteq> dest) and
(\<lambda>s. src \<noteq> dest \<longrightarrow> cte_wp_at (\<lambda>c. c = NullCap) dest s) and
ex_cte_cap_wp_to is_cnode_cap pivot and ex_cte_cap_wp_to is_cnode_cap dest)"
| "valid_cnode_inv (SaveCall ptr) =
(ex_cte_cap_wp_to is_cnode_cap ptr and
cte_wp_at (\<lambda>c. c = NullCap) ptr and real_cte_at ptr)"
| "valid_cnode_inv (CancelBadgedSendsCall cap) =
(valid_cap cap and K (has_cancel_send_rights cap))"
primrec
valid_rec_del_call :: "rec_del_call \<Rightarrow> 'z::state_ext state \<Rightarrow> bool"
where
"valid_rec_del_call (CTEDeleteCall slot _) = \<top>"
| "valid_rec_del_call (FinaliseSlotCall slot _) = \<top>"
| "valid_rec_del_call (ReduceZombieCall cap slot _) =
(cte_wp_at ((=) cap) slot and is_final_cap' cap
and K (is_zombie cap))"
locale CNodeInv_AI =
fixes state_ext_t :: "'state_ext::state_ext itself"
assumes derive_cap_objrefs:
"\<And>P cap slot.
\<lbrace>\<lambda>s::'state_ext state. P (obj_refs cap)\<rbrace>
derive_cap slot cap
\<lbrace>\<lambda>rv s. rv \<noteq> NullCap \<longrightarrow> P (obj_refs rv)\<rbrace>,-"
assumes derive_cap_zobjrefs:
"\<And>P cap slot.
\<lbrace>\<lambda>s::'state_ext state. P (zobj_refs cap)\<rbrace>
derive_cap slot cap
\<lbrace>\<lambda>rv s. rv \<noteq> NullCap \<longrightarrow> P (zobj_refs rv)\<rbrace>,-"
assumes update_cap_objrefs:
"\<And>P dt cap. \<lbrakk> update_cap_data P dt cap \<noteq> NullCap \<rbrakk> \<Longrightarrow>
obj_refs (update_cap_data P dt cap) = obj_refs cap"
assumes update_cap_zobjrefs:
"\<And>P dt cap. \<lbrakk> update_cap_data P dt cap \<noteq> cap.NullCap \<rbrakk> \<Longrightarrow>
zobj_refs (update_cap_data P dt cap) = zobj_refs cap"
assumes copy_mask [simp]:
"\<And>R c. copy_of (mask_cap R c) = copy_of c"
assumes update_cap_data_mask_Null [simp]:
"\<And>P x m c. (update_cap_data P x (mask_cap m c) = NullCap) = (update_cap_data P x c = NullCap)"
assumes cap_master_update_cap_data:
"\<And>P x c. \<lbrakk> update_cap_data P x c \<noteq> NullCap \<rbrakk> \<Longrightarrow>
cap_master_cap (update_cap_data P x c) = cap_master_cap c"
assumes same_object_as_cap_master:
"\<And>cap cap'. same_object_as cap cap' \<Longrightarrow> cap_master_cap cap = cap_master_cap cap'"
assumes cap_asid_update_cap_data:
"\<And>P x c. update_cap_data P x c \<noteq> NullCap \<Longrightarrow> cap_asid (update_cap_data P x c) = cap_asid c"
assumes cap_vptr_update_cap_data:
"\<And>P x c. update_cap_data P x c \<noteq> NullCap \<Longrightarrow> cap_vptr (update_cap_data P x c) = cap_vptr c"
assumes cap_asid_base_update_cap_data:
"\<And>P x c. update_cap_data P x c \<noteq> NullCap \<Longrightarrow>
cap_asid_base (update_cap_data P x c) = cap_asid_base c"
assumes same_object_as_update_cap_data:
"\<And>P x c c'. \<lbrakk> update_cap_data P x c \<noteq> NullCap; same_object_as c' c \<rbrakk> \<Longrightarrow>
same_object_as c' (update_cap_data P x c)"
assumes weak_derived_update_cap_data:
"\<And>P x c c'. \<lbrakk>update_cap_data P x c \<noteq> NullCap; weak_derived c c'\<rbrakk> \<Longrightarrow>
weak_derived (update_cap_data P x c) c'"
assumes cap_badge_update_cap_data:
"\<And>x c bdg. update_cap_data False x c \<noteq> NullCap \<and> (bdg, cap_badge c) \<in> capBadge_ordering False
\<longrightarrow> (bdg, cap_badge (update_cap_data False x c)) \<in> capBadge_ordering False"
assumes cap_vptr_rights_update[simp]:
"\<And>f c. cap_vptr (cap_rights_update f c) = cap_vptr c"
assumes cap_vptr_mask[simp]:
"\<And>m c. cap_vptr (mask_cap m c) = cap_vptr c"
assumes cap_asid_base_rights [simp]:
"\<And>R c. cap_asid_base (cap_rights_update R c) = cap_asid_base c"
assumes cap_asid_base_mask[simp]:
"\<And>m c. cap_asid_base (mask_cap m c) = cap_asid_base c"
assumes weak_derived_mask:
"\<And>c c' m. \<lbrakk> weak_derived c c'; cap_aligned c \<rbrakk> \<Longrightarrow> weak_derived (mask_cap m c) c'"
assumes vs_cap_ref_update_cap_data[simp]:
"\<And>P d cap. vs_cap_ref (update_cap_data P d cap) = vs_cap_ref cap"
assumes weak_derived_cap_is_device:
"\<And>c c'. \<lbrakk>weak_derived c' c\<rbrakk> \<Longrightarrow> cap_is_device c = cap_is_device c'"
assumes in_preempt[simp,intro]:
"\<And>rv s' (s::'state_ext state).
(Inr rv, s') \<in> fst (preemption_point s) \<Longrightarrow>
(\<exists>f es. s' = s \<lparr> machine_state := machine_state s
\<lparr> irq_state := f (irq_state (machine_state s)) \<rparr>, exst := es\<rparr>)"
assumes invs_irq_state_independent[intro!, simp]:
"\<And>(s::'state_ext state) f.
invs (s\<lparr>machine_state := machine_state s\<lparr>irq_state := f (irq_state (machine_state s))\<rparr>\<rparr>)
= invs s"
assumes cte_at_nat_to_cref_zbits:
"\<And>(s::'state_ext state) oref zb n m.
\<lbrakk> s \<turnstile> Zombie oref zb n; m < n \<rbrakk> \<Longrightarrow> cte_at (oref, nat_to_cref (zombie_cte_bits zb) m) s"
assumes copy_of_cap_range:
"\<And>cap cap'. copy_of cap cap' \<Longrightarrow> cap_range cap = cap_range cap'"
assumes copy_of_zobj_refs:
"\<And>cap cap'. copy_of cap cap' \<Longrightarrow> zobj_refs cap = zobj_refs cap'"
assumes vs_cap_ref_master:
"\<And> cap cap'.
\<lbrakk> cap_master_cap cap = cap_master_cap cap';
cap_asid cap = cap_asid cap';
cap_asid_base cap = cap_asid_base cap';
cap_vptr cap = cap_vptr cap' \<rbrakk>
\<Longrightarrow> vs_cap_ref cap = vs_cap_ref cap'"
assumes weak_derived_vs_cap_ref:
"\<And>c c'. weak_derived c c' \<Longrightarrow> vs_cap_ref c = vs_cap_ref c'"
assumes weak_derived_table_cap_ref:
"\<And>c c'. weak_derived c c' \<Longrightarrow> table_cap_ref c = table_cap_ref c'"
assumes swap_of_caps_valid_arch_caps:
"\<And>c a c' b.
\<lbrace>valid_arch_caps and cte_wp_at (weak_derived c) a and cte_wp_at (weak_derived c') b\<rbrace>
do
y \<leftarrow> set_cap c b;
set_cap c' a
od
\<lbrace>\<lambda>rv. valid_arch_caps :: 'state_ext state \<Rightarrow> bool\<rbrace>"
assumes cap_swap_asid_map[wp]:
"\<And>c a c' b.
\<lbrace>valid_asid_map and cte_wp_at (weak_derived c) a and cte_wp_at (weak_derived c') b\<rbrace>
cap_swap c a c' b
\<lbrace>\<lambda>rv. valid_asid_map :: 'state_ext state \<Rightarrow> bool\<rbrace>"
assumes cap_swap_cap_refs_in_kernel_window[wp]:
"\<And>c a c' b.
\<lbrace>cap_refs_in_kernel_window and cte_wp_at (weak_derived c) a and cte_wp_at (weak_derived c') b\<rbrace>
cap_swap c a c' b
\<lbrace>\<lambda>rv. cap_refs_in_kernel_window :: 'state_ext state \<Rightarrow> bool\<rbrace>"
assumes cap_swap_ioports[wp]:
"\<lbrace>valid_ioports and cte_wp_at (weak_derived c) a and cte_wp_at (weak_derived c') b\<rbrace>
cap_swap c a c' b
\<lbrace>\<lambda>rv (s::'state_ext state). valid_ioports s\<rbrace>"
assumes cap_swap_vms[wp]:
"\<And>c a c' b.
\<lbrace>valid_machine_state :: 'state_ext state \<Rightarrow> bool\<rbrace>
cap_swap c a c' b
\<lbrace>\<lambda>rv. valid_machine_state\<rbrace>"
assumes unat_of_bl_nat_to_cref:
"\<And>n ln. \<lbrakk> n < 2 ^ ln; ln < word_bits \<rbrakk>
\<Longrightarrow> unat (of_bl (nat_to_cref ln n) :: machine_word) = n"
assumes zombie_is_cap_toE_pre:
"\<And>(s::'state_ext state) ptr zbits n m irqn.
\<lbrakk> s \<turnstile> Zombie ptr zbits n; invs s; m < n \<rbrakk>
\<Longrightarrow> (ptr, nat_to_cref (zombie_cte_bits zbits) m) \<in> cte_refs (Zombie ptr zbits n) irqn"
assumes finalise_cap_emptyable[wp]:
"\<And>sl c f.
\<lbrace>emptyable sl and (invs and valid_mdb)\<rbrace>
finalise_cap c f
\<lbrace>\<lambda>_. emptyable sl :: 'state_ext state \<Rightarrow> bool\<rbrace>"
assumes deleting_irq_handler_emptyable[wp]:
"\<And>sl irq.
\<lbrace>emptyable sl and invs :: 'state_ext state \<Rightarrow> bool\<rbrace>
deleting_irq_handler irq
\<lbrace>\<lambda>_. emptyable sl\<rbrace>"
assumes arch_finalise_cap_emptyable[wp]:
"\<And>sl c f.
\<lbrace>emptyable sl :: 'state_ext state \<Rightarrow> bool\<rbrace>
arch_finalise_cap c f
\<lbrace>\<lambda>_. emptyable sl\<rbrace>"
assumes finalise_cap_not_reply_master_unlifted:
"\<And>rv s' cap sl (s::'state_ext state).
(rv, s') \<in> fst (finalise_cap cap sl s) \<Longrightarrow>
\<not> is_master_reply_cap (fst rv)"
assumes nat_to_cref_0_replicate:
"\<And>n. n < word_bits \<Longrightarrow> nat_to_cref n 0 = replicate n False"
assumes prepare_thread_delete_thread_cap:
"\<And>x p t. \<lbrace>\<lambda>(s::'state_ext state). caps_of_state s x = Some (cap.ThreadCap p)\<rbrace>
prepare_thread_delete t
\<lbrace>\<lambda>rv s. caps_of_state s x = Some (cap.ThreadCap p)\<rbrace>"
locale CNodeInv_AI_2 = CNodeInv_AI state_ext_t
for state_ext_t :: "'state_ext::state_ext itself" +
assumes rec_del_invs':
"\<And>(s::'state_ext state) call.
s \<turnstile> \<lbrace>\<lambda>x. invs x \<and> valid_rec_del_call call x \<and>
(\<not> exposed_rdcall call \<longrightarrow> ex_cte_cap_wp_to (\<lambda>cp. cap_irqs cp = {}) (slot_rdcall call) x) \<and>
emptyable (slot_rdcall call) x \<and>
(case call of ReduceZombieCall cap sl ex \<Rightarrow> \<not> cap_removeable cap sl \<and>
(\<forall>t\<in>obj_refs cap. halted_if_tcb t x)
| _ \<Rightarrow> True)\<rbrace>
rec_del call
\<lbrace>\<lambda>rv s. invs s \<and>
(case call of CTEDeleteCall _ bool \<Rightarrow> True
| FinaliseSlotCall sl x \<Rightarrow> (fst rv \<or> x \<longrightarrow> cte_wp_at (replaceable s sl NullCap) sl s) \<and>
(snd rv \<noteq> NullCap \<longrightarrow> post_cap_delete_pre (snd rv) ((caps_of_state s) (sl \<mapsto> cap.NullCap)))
| ReduceZombieCall cap sl x \<Rightarrow> \<not> x \<longrightarrow> ex_cte_cap_wp_to (\<lambda>cp. cap_irqs cp = {}) sl s) \<and>
emptyable (slot_rdcall call) s\<rbrace>,
\<lbrace>\<lambda>rv. invs\<rbrace>"
lemma mask_cap_all:
"mask_cap (all_rights \<inter> r) c = mask_cap r c"
unfolding all_rights_def by simp
lemma decode_cnode_cases2:
assumes mvins: "\<And>index bits src_index src_depth args' src_root_cap exs'.
\<lbrakk> args = index # bits # src_index # src_depth # args';
exs = src_root_cap # exs';
gen_invocation_type label \<in> set [CNodeCopy .e. CNodeMutate];
gen_invocation_type label \<in> set [CNodeRevoke .e. CNodeSaveCaller];
gen_invocation_type label \<notin> {CNodeRevoke, CNodeDelete,
CNodeCancelBadgedSends, CNodeRotate, CNodeSaveCaller} \<rbrakk> \<Longrightarrow> P"
assumes rvk: "\<And>index bits args'. \<lbrakk> args = index # bits # args';
gen_invocation_type label \<notin> set [CNodeCopy .e. CNodeMutate];
gen_invocation_type label \<in> set [CNodeRevoke .e. CNodeSaveCaller];
gen_invocation_type label = CNodeRevoke \<rbrakk> \<Longrightarrow> P"
assumes dlt: "\<And>index bits args'. \<lbrakk> args = index # bits # args';
gen_invocation_type label \<notin> set [CNodeCopy .e. CNodeMutate];
gen_invocation_type label \<in> set [CNodeRevoke .e. CNodeSaveCaller];
gen_invocation_type label = CNodeDelete \<rbrakk> \<Longrightarrow> P"
assumes svc: "\<And>index bits args'. \<lbrakk> args = index # bits # args';
gen_invocation_type label \<notin> set [CNodeCopy .e. CNodeMutate];
gen_invocation_type label \<in> set [CNodeRevoke .e. CNodeSaveCaller];
gen_invocation_type label = CNodeSaveCaller \<rbrakk> \<Longrightarrow> P"
assumes rcy: "\<And>index bits args'. \<lbrakk> args = index # bits # args';
gen_invocation_type label \<notin> set [CNodeCopy .e. CNodeMutate];
gen_invocation_type label \<in> set [CNodeRevoke .e. CNodeSaveCaller];
gen_invocation_type label = CNodeCancelBadgedSends \<rbrakk> \<Longrightarrow> P"
assumes rot: "\<And>index bits pivot_new_data pivot_index pivot_depth src_new_data
src_index src_depth args' pivot_root_cap src_root_cap exs'.
\<lbrakk> args = index # bits # pivot_new_data # pivot_index # pivot_depth
# src_new_data # src_index # src_depth # args';
exs = pivot_root_cap # src_root_cap # exs';
gen_invocation_type label \<notin> set [CNodeCopy .e. CNodeMutate];
gen_invocation_type label \<in> set [CNodeRevoke .e. CNodeSaveCaller];
gen_invocation_type label = CNodeRotate \<rbrakk> \<Longrightarrow> P"
assumes errs:
"\<lbrakk> gen_invocation_type label \<notin> set [CNodeRevoke .e. CNodeSaveCaller] \<or>
args = [] \<or> (\<exists>x. args = [x]) \<or> (\<exists>index bits args'. args = index # bits # args' \<and>
gen_invocation_type label \<in> set [CNodeRevoke .e. CNodeSaveCaller] \<and>
(gen_invocation_type label \<in> set [CNodeCopy .e. CNodeMutate]
\<and> gen_invocation_type label \<notin> {CNodeRevoke, CNodeDelete,
CNodeCancelBadgedSends, CNodeRotate, CNodeSaveCaller}
\<and> (case (args', exs) of (src_index # src_depth # args'',
src_root_cap # exs') \<Rightarrow> False | _ \<Rightarrow> True) \<or>
gen_invocation_type label \<notin> set [CNodeCopy .e. CNodeMutate] \<and>
gen_invocation_type label = CNodeRotate \<and> (case (args', exs) of
(pivot_new_data # pivot_index # pivot_depth
# src_new_data # src_index # src_depth # args'',
pivot_root_cap # src_root_cap # exs') \<Rightarrow> False
| _ \<Rightarrow> True))) \<rbrakk> \<Longrightarrow> P"
shows "P"
proof -
have simps: "[CNodeRevoke .e. CNodeSaveCaller]
= [CNodeRevoke, CNodeDelete, CNodeCancelBadgedSends, CNodeCopy, CNodeMint,
CNodeMove, CNodeMutate, CNodeRotate, CNodeSaveCaller]"
"[CNodeCopy .e. CNodeMutate] = [CNodeCopy, CNodeMint,
CNodeMove, CNodeMutate]"
by (simp_all add: upto_enum_def fromEnum_def toEnum_def enum_invocation_label enum_gen_invocation_labels)
show ?thesis
apply (cases args)
apply (simp add: errs)
apply (case_tac list)
apply (simp add: errs)
apply (case_tac "gen_invocation_type label \<in> set [CNodeCopy .e. CNodeMutate]")
apply (case_tac "case (lista, exs) of (src_index # src_depth # args'',
src_root_cap # exs'') \<Rightarrow> False | _ \<Rightarrow> True")
apply (rule errs)
apply (simp add: simps)
apply (rule disjI2)
apply auto[1]
apply (simp split: prod.split_asm list.split_asm)
apply (erule(2) mvins, auto simp: simps)[1]
apply (case_tac "gen_invocation_type label \<in> set [CNodeRevoke .e. CNodeSaveCaller]")
apply (simp_all add: errs)
apply (insert rvk dlt svc rcy rot)
apply (simp add: simps)
apply atomize
apply (elim disjE, simp_all)
apply (case_tac "case (lista, exs) of
(pivot_new_data # pivot_index # pivot_depth
# src_new_data # src_index # src_depth # args'',
pivot_root_cap # src_root_cap # exs') \<Rightarrow> False
| _ \<Rightarrow> True")
apply (rule errs)
apply (simp add: simps)
apply (simp split: prod.split_asm list.split_asm)
done
qed
lemma Suc_length_not_empty:
"length xs = length xs' \<Longrightarrow> Suc 0 \<le> length xs' = (xs \<noteq> [])"
by (fastforce simp: le_simps)
lemma update_cap_hoare_helper:
"\<lbrace>P\<rbrace> f \<lbrace>\<lambda>rv s. valid_cap (C rv s) s\<rbrace> \<Longrightarrow>
\<lbrace>P\<rbrace> f \<lbrace>\<lambda>rv s. valid_cap (update_cap_data prs n (C rv s)) s\<rbrace>"
apply (erule hoare_strengthen_post)
apply (erule update_cap_data_validI)
done
lemma mask_cap_hoare_helper:
"\<lbrace>P\<rbrace> f \<lbrace>\<lambda>rv s. valid_cap (C rv s) s\<rbrace> \<Longrightarrow>
\<lbrace>P\<rbrace> f \<lbrace>\<lambda>rv s. valid_cap (mask_cap (M rv s) (C rv s)) s\<rbrace>"
by (fastforce simp add: valid_def)
lemma derive_cap_untyped:
"\<lbrace>\<lambda>s. P (untyped_range cap)\<rbrace> derive_cap slot cap \<lbrace>\<lambda>rv s. rv \<noteq> cap.NullCap \<longrightarrow> P (untyped_range rv)\<rbrace>,-"
unfolding derive_cap_def is_zombie_def
by (cases cap; (wp ensure_no_children_inv arch_derive_cap_untyped | simp add: o_def)+)
lemma zombies_final_helper:
"\<lbrakk> cte_wp_at (\<lambda>c. c = cap) p s; \<not> is_zombie cap; zombies_final s \<rbrakk>
\<Longrightarrow> (\<forall>r\<in>obj_refs cap. \<forall>a b.
cte_wp_at (\<lambda>cap'. r \<in> obj_refs cap') (a, b) s \<longrightarrow> cte_wp_at (Not \<circ> is_zombie) (a, b) s)"
apply (clarsimp simp: cte_wp_at_def)
apply (case_tac "p = (a, b)")
apply simp
apply (drule(2) zombies_finalD2)
apply clarsimp
apply blast
apply simp
done
lemma cap_asid_mask[simp]:
"cap_asid (mask_cap m c) = cap_asid c"
by (simp add: mask_cap_def)
lemma cap_master_mask[simp]:
"cap_master_cap (mask_cap rs cap) = cap_master_cap cap"
by (simp add: mask_cap_def)
lemma cap_badge_mask[simp]:
"cap_badge (mask_cap rs cap) = cap_badge cap"
by (simp add: mask_cap_def)
lemma ensure_empty_cte_wp_at:
"\<lbrace>\<top>\<rbrace> ensure_empty c \<lbrace>\<lambda>rv s. cte_wp_at ((=) cap.NullCap) c s\<rbrace>, -"
unfolding ensure_empty_def
apply (wp whenE_throwError_wp get_cap_wp)
apply simp
done
lemmas get_cap_cte_caps_to_no_wp[wp]
= get_cap_cte_caps_to[where P="\<top>", simplified]
lemma lookup_cap_ex[wp]:
"\<lbrace>\<top>\<rbrace> lookup_cap t c \<lbrace>\<lambda>rv s. \<forall>r\<in>cte_refs rv (interrupt_irq_node s). ex_cte_cap_to r s\<rbrace>, -"
by (simp add: split_def lookup_cap_def) wp
lemmas cap_aligned_valid[elim!] = valid_cap_aligned
lemma cap_derive_not_null_helper2:
"\<lbrace>P\<rbrace> derive_cap slot cap \<lbrace>\<lambda>rv s. rv \<noteq> cap.NullCap \<longrightarrow> Q rv s\<rbrace>, -
\<Longrightarrow>
\<lbrace>\<lambda>s. cap \<noteq> cap.NullCap \<and> \<not> is_zombie cap \<and> cap \<noteq> cap.IRQControlCap \<longrightarrow> P s\<rbrace>
derive_cap slot cap
\<lbrace>\<lambda>rv s. rv \<noteq> cap.NullCap \<longrightarrow> Q rv s\<rbrace>, -"
apply (drule cap_derive_not_null_helper)
apply (erule hoare_post_imp_R)
apply simp
done
lemma has_cancel_send_rights_ep_cap:
"has_cancel_send_rights cap \<Longrightarrow> is_ep_cap cap"
by (clarsimp simp: has_cancel_send_rights_def split: cap.splits)
lemma is_untyped_update_cap_data[intro]:
"is_untyped_cap r \<Longrightarrow> update_cap_data c x r = r"
by (cases r; clarsimp simp: update_cap_data_def is_arch_cap_def)
context CNodeInv_AI begin
lemma decode_cnode_inv_wf[wp]:
"\<And>cap.
\<lbrace>invs and valid_cap cap
and (\<lambda>s. \<forall>r\<in>zobj_refs cap. ex_nonz_cap_to r s)
and (\<lambda>s. is_cnode_cap cap \<longrightarrow> (\<forall>r\<in>cte_refs cap (interrupt_irq_node s).
ex_cte_cap_wp_to is_cnode_cap r s))
and (\<lambda>s. \<forall>cap \<in> set cs. s \<turnstile> cap)
and (\<lambda>s. \<forall>cap \<in> set cs. is_cnode_cap cap \<longrightarrow>
(\<forall>r\<in>cte_refs cap (interrupt_irq_node s). ex_cte_cap_wp_to is_cnode_cap r s)) \<rbrace>
decode_cnode_invocation mi args cap cs
\<lbrace>valid_cnode_inv\<rbrace>,-"
apply (rule decode_cnode_cases2[where args=args and exs=cs and label=mi])
\<comment> \<open>Move/Insert\<close>
apply (simp add: decode_cnode_invocation_def unlessE_whenE
split del: if_split)
apply (wp lsfco_cte_at ensure_no_children_wp whenE_throwError_wp
| simp add: split_beta split del: if_split
| (fold validE_R_def)[1])+
apply (rule cap_derive_not_null_helper2)
apply (simp only: imp_conjR)
apply ((wp derive_cap_is_derived
derive_cap_valid_cap
derive_cap_zobjrefs derive_cap_objrefs_iszombie
| wp (once) hoare_drop_imps)+ )[1]
apply (wp whenE_throwError_wp | wpcw)+
apply simp
apply (rule_tac Q="\<lambda>src_cap. valid_cap src_cap and ex_cte_cap_wp_to is_cnode_cap x
and zombies_final and valid_objs
and real_cte_at src_slot and real_cte_at x
and cte_wp_at (\<lambda>c. c = src_cap) src_slot
and cte_wp_at ((=) cap.NullCap) x"
in hoare_post_imp)
apply (clarsimp simp: cte_wp_at_caps_of_state all_rights_def)
apply (simp add: cap_master_update_cap_data weak_derived_update_cap_data
cap_asid_update_cap_data
update_cap_data_validI update_cap_objrefs)
apply (strengthen cap_badge_update_cap_data)
apply simp
apply (frule (1) caps_of_state_valid_cap)
apply (case_tac "is_zombie r")
apply (clarsimp simp add: valid_cap_def2 update_cap_data_def
is_cap_simps
split: if_split_asm)
apply (frule(2) zombies_final_helper [OF caps_of_state_cteD[simplified cte_wp_at_eq_simp]])
apply (clarsimp simp: valid_cap_def2 cte_wp_at_caps_of_state)
apply (rule conjI, clarsimp+)+
apply (fastforce simp: is_untyped_update_cap_data
weak_derived_update_cap_data[OF _ weak_derived_refl])
apply (wp get_cap_cte_wp_at ensure_empty_cte_wp_at)+
apply simp
apply (clarsimp simp: invs_def valid_state_def valid_pspace_def)
\<comment> \<open>Revoke\<close>
apply (simp add: decode_cnode_invocation_def unlessE_whenE cong: if_cong)
apply (wp lsfco_cte_at hoare_drop_imps whenE_throwError_wp
| simp add: split_beta validE_R_def[symmetric])+
apply clarsimp
\<comment> \<open>Delete\<close>
apply (simp add: decode_cnode_invocation_def unlessE_whenE cong: if_cong)
apply (wp lsfco_cte_at hoare_drop_imps whenE_throwError_wp
| simp add: split_beta validE_R_def[symmetric])+
apply clarsimp
\<comment> \<open>Save\<close>
apply (simp add: decode_cnode_invocation_def unlessE_whenE cong: if_cong)
apply (rule hoare_pre)
apply (wp ensure_empty_stronger whenE_throwError_wp
lsfco_cte_at lookup_slot_for_cnode_op_cap_to
hoare_vcg_const_imp_lift
| simp add: split_beta
| wp (once) hoare_drop_imps)+
apply clarsimp
\<comment> \<open>CancelBadgedSends\<close>
apply (simp add: decode_cnode_invocation_def
unlessE_def whenE_def
split del: if_split)
apply (wp get_cap_wp hoare_vcg_all_lift_R | simp add: )+
apply (rule_tac Q'="\<lambda>rv. invs and cte_wp_at (\<lambda>_. True) rv" in hoare_post_imp_R)
apply (wp lsfco_cte_at)
apply (clarsimp simp: cte_wp_valid_cap invs_valid_objs has_cancel_send_rights_ep_cap)+
\<comment> \<open>Rotate\<close>
apply (simp add: decode_cnode_invocation_def split_def
whenE_def unlessE_def)
apply (rule hoare_pre)
apply (wp get_cap_wp ensure_empty_stronger | simp)+
apply (rule_tac Q'="\<lambda>rv s. real_cte_at rv s \<and> real_cte_at x s
\<and> real_cte_at src_slot s
\<and> ex_cte_cap_wp_to is_cnode_cap rv s
\<and> ex_cte_cap_wp_to is_cnode_cap x s
\<and> invs s" in hoare_post_imp_R)
apply wp+
apply (clarsimp simp: cte_wp_at_caps_of_state
dest!: real_cte_at_cte del: impI)
apply (frule invs_valid_objs)
apply (simp add: update_cap_data_validI weak_derived_update_cap_data
caps_of_state_valid_cap)
subgoal by (auto,(clarsimp simp:is_cap_simps update_cap_data_def)+)[1](* Bad practise *)
apply wp+
apply clarsimp
apply (elim disjE exE conjE,
simp_all add: decode_cnode_invocation_def validE_R_def
split_def unlessE_whenE
split: list.split_asm
split del: if_split)
apply (wp | simp)+
done
end
lemma decode_cnode_inv_inv[wp]:
"\<lbrace>P\<rbrace> decode_cnode_invocation mi args cap cs \<lbrace>\<lambda>rv. P\<rbrace>"
unfolding decode_cnode_invocation_def
apply (simp add: split_def unlessE_def whenE_def
cong: if_cong split del: if_split)
apply (rule hoare_pre)
apply (wp hoare_drop_imps | simp | wpcw)+
done
definition
not_recursive_cspaces :: "'z::state_ext state \<Rightarrow> cslot_ptr set"
where
"not_recursive_cspaces s \<equiv> {ptr. cte_wp_at (\<lambda>cap. ptr \<notin> fst_cte_ptrs cap) ptr s}"
definition
state_cte_ptrs :: "'z::state_ext state \<Rightarrow> cslot_ptr set"
where
"state_cte_ptrs s \<equiv> {ptr. cte_at ptr s}"
lemma fixed_length_finite:
"finite (UNIV :: 'a set) \<Longrightarrow> finite {x :: 'a list. length x = n}"
apply (induct n)
apply simp
apply (subgoal_tac "{x :: 'a list. length x = Suc n} = image (split Cons) (UNIV \<times> {x. length x = n})")
apply clarsimp
apply safe
apply (case_tac x, simp_all add: image_def)
done
lemma state_cte_ptrs_finite:
"finite (state_cte_ptrs s)"
apply (clarsimp simp add: state_cte_ptrs_def cte_at_cases Collect_disj_eq
Collect_conj_eq set_pair_UN tcb_cap_cases_def)
apply (clarsimp simp: well_formed_cnode_n_def fixed_length_finite)
done
lemma cte_wp_at_set_finite:
"finite {p. cte_wp_at (P p) p s}"
apply (rule finite_subset [OF _ state_cte_ptrs_finite[where s=s]])
apply (clarsimp simp: state_cte_ptrs_def elim!: cte_wp_at_weakenE)
done
lemma not_recursive_cspaces_finite:
"finite (not_recursive_cspaces s)"
unfolding not_recursive_cspaces_def
by (rule cte_wp_at_set_finite)
lemma set_cdt_not_recursive[wp]:
"\<lbrace>\<lambda>s. P (not_recursive_cspaces s)\<rbrace> set_cdt f \<lbrace>\<lambda>rv s. P (not_recursive_cspaces s)\<rbrace>"
apply (simp add: set_cdt_def, wp)
apply (simp add: not_recursive_cspaces_def)
done
lemma not_recursive_mdb[simp]:
"not_recursive_cspaces (is_original_cap_update f s) =
not_recursive_cspaces s"
"not_recursive_cspaces (cdt_update f' s) =
not_recursive_cspaces s"
by (simp add: not_recursive_cspaces_def)+
lemma set_cap_no_new_recursive:
"\<lbrace>\<lambda>s. x \<notin> not_recursive_cspaces s
\<and> cte_wp_at (\<lambda>cap. ptr \<notin> fst_cte_ptrs cap) ptr s\<rbrace>
set_cap cap ptr
\<lbrace>\<lambda>rv s. x \<notin> not_recursive_cspaces s\<rbrace>"
apply (simp add: not_recursive_cspaces_def)
apply (wp set_cap_cte_wp_at_neg)
apply (clarsimp simp: cte_wp_at_neg split: if_split)
done
lemma not_recursive_set_cap_shrinks:
"\<lbrace>\<lambda>s. card (not_recursive_cspaces s) \<le> n
\<and> cte_wp_at (\<lambda>cap. ptr \<notin> fst_cte_ptrs cap) ptr s
\<and> ptr \<in> fst_cte_ptrs cap\<rbrace>
set_cap cap ptr
\<lbrace>\<lambda>rv s. card (not_recursive_cspaces s) < n\<rbrace>"
apply (rule shrinks_proof[where x=ptr])
apply (rule not_recursive_cspaces_finite)
apply (wp set_cap_no_new_recursive)
apply simp
apply (simp add: not_recursive_cspaces_def)
apply (wp set_cap_cte_wp_at_neg)
apply (clarsimp elim!: cte_wp_at_weakenE)
apply (simp add: not_recursive_cspaces_def)
done
lemma not_recursive_set_cap_doesn't_grow:
"\<lbrace>\<lambda>s. card (not_recursive_cspaces s) < n
\<and> cte_wp_at (\<lambda>cap. ptr \<notin> fst_cte_ptrs cap) ptr s\<rbrace>
set_cap cap ptr
\<lbrace>\<lambda>rv s. card (not_recursive_cspaces s) < n\<rbrace>"
apply (rule doesn't_grow_proof)
apply (rule not_recursive_cspaces_finite)
apply (rule set_cap_no_new_recursive)
done
lemma final_cap_duplicate_obj_ref:
"\<lbrakk> fst (get_cap p1 s) = {(cap1, s)}; fst (get_cap p2 s) = {(cap2, s)}; is_final_cap' cap1 s;
x \<in> obj_refs cap1; p1 \<noteq> p2 \<rbrakk> \<Longrightarrow> x \<notin> obj_refs cap2"
apply (clarsimp simp: is_final_cap'_def gen_obj_refs_def)
apply (subgoal_tac "{p1, p2} \<subseteq> {(a, b)}")
apply simp
apply (drule sym[where s="Collect p" for p], simp)
apply blast
done
lemma final_cap_duplicate_irq:
"\<lbrakk> fst (get_cap p1 s) = {(cap1, s)}; fst (get_cap p2 s) = {(cap2, s)}; is_final_cap' cap1 s;
x \<in> cap_irqs cap1; p1 \<noteq> p2 \<rbrakk> \<Longrightarrow> x \<notin> cap_irqs cap2"
apply (clarsimp simp: is_final_cap'_def gen_obj_refs_def)
apply (subgoal_tac "{p1, p2} \<subseteq> {(a, b)}")
apply simp
apply (drule sym[where s="Collect p" for p], simp)
apply blast
done
lemma final_cap_duplicate_arch_refs:
"\<lbrakk> fst (get_cap p1 s) = {(cap1, s)}; fst (get_cap p2 s) = {(cap2, s)}; is_final_cap' cap1 s;
x \<in> arch_gen_refs cap1; p1 \<noteq> p2 \<rbrakk> \<Longrightarrow> x \<notin> arch_gen_refs cap2"
apply (clarsimp simp: is_final_cap'_def gen_obj_refs_def)
apply (subgoal_tac "{p1, p2} \<subseteq> {(a, b)}")
apply simp
apply (drule sym[where s="Collect p" for p], simp)
apply blast
done
lemma fst_cte_ptrs_link_obj_refs:
"x \<in> fst_cte_ptrs cap \<Longrightarrow> fst x \<in> obj_refs cap"
by (case_tac cap, simp_all add: fst_cte_ptrs_def)
lemma final_cap_duplicate_cte_ptr:
"\<lbrakk> fst (get_cap p s) = {(cap, s)}; fst (get_cap p' s) = {(cap', s)}; is_final_cap' cap s;
x \<in> fst_cte_ptrs cap; p \<noteq> p' \<rbrakk> \<Longrightarrow> x \<notin> fst_cte_ptrs cap'"
apply (drule(2) final_cap_duplicate_obj_ref)
apply (erule fst_cte_ptrs_link_obj_refs)
apply assumption
apply (clarsimp simp: fst_cte_ptrs_link_obj_refs)
done
lemma not_recursive_cspaces_more_update[iff]:
"not_recursive_cspaces (trans_state f s) = not_recursive_cspaces s"
by (simp add: not_recursive_cspaces_def)
lemma cap_swap_not_recursive:
"\<lbrace>\<lambda>s. card (not_recursive_cspaces s) \<le> n
\<and> cte_wp_at (\<lambda>cap. is_final_cap' cap s
\<and> p1 \<in> fst_cte_ptrs cap) p2 s
\<and> cte_wp_at ((=) c1) p1 s
\<and> cte_wp_at ((=) c2) p2 s
\<and> p1 \<noteq> p2\<rbrace>
cap_swap c1 p1 c2 p2
\<lbrace>\<lambda>rv s. card (not_recursive_cspaces s) < n\<rbrace>"
apply (cases "p1 = p2", simp_all)
apply (simp add: cap_swap_def set_cdt_def when_def)
apply (rule hoare_vcg_precond_imp)
apply (wp | simp)+
apply (rule not_recursive_set_cap_doesn't_grow)
apply (wp not_recursive_set_cap_shrinks set_cap_cte_wp_at' get_cap_wp hoare_vcg_disj_lift)
apply (clarsimp simp: cte_wp_at_def)
apply (frule(3) final_cap_duplicate_cte_ptr)
apply simp
apply (case_tac c2, simp_all add: fst_cte_ptrs_def)
done
lemma cap_swap_fd_not_recursive:
"\<lbrace>\<lambda>s. card (not_recursive_cspaces s) \<le> n
\<and> cte_wp_at (\<lambda>cap. is_final_cap' cap s
\<and> p1 \<in> fst_cte_ptrs cap) p2 s
\<and> p1 \<noteq> p2\<rbrace>
cap_swap_for_delete p1 p2
\<lbrace>\<lambda>rv s. card (not_recursive_cspaces s) < n\<rbrace>"
unfolding cap_swap_for_delete_def
by (wpsimp wp: cap_swap_not_recursive get_cap_wp)
lemma set_mrs_typ_at [wp]:
"\<lbrace>\<lambda>s. P (typ_at T p s)\<rbrace> set_mrs p' b m \<lbrace>\<lambda>rv s. P (typ_at T p s)\<rbrace>"
apply (simp add: set_mrs_def bind_assoc set_object_def get_object_def)
apply (cases b)
apply simp
apply wp
apply clarsimp
apply (drule get_tcb_SomeD)
apply (clarsimp simp: obj_at_def)
apply (clarsimp simp: zipWithM_x_mapM split_def
split del: if_split)
apply (wp mapM_wp')
apply clarsimp
apply (drule get_tcb_SomeD)
apply (clarsimp simp: obj_at_def)
done
lemma cte_wp_and:
"cte_wp_at (P and Q) c s = (cte_wp_at P c s \<and> cte_wp_at Q c s)"
by (auto simp: cte_wp_at_def)
crunch cte_wp_at[wp]: get_mrs "cte_wp_at P c"
(wp: crunch_wps simp: crunch_simps)
lemmas cte_wp_and' = cte_wp_and [unfolded pred_conj_def]
lemma in_pspace_typ_at:
"r \<notin> dom (kheap s) = (\<forall>T. \<not> typ_at T r s)"
apply (simp add: dom_def)
apply (subst simp_thms(2)[symmetric])
apply (fastforce simp: obj_at_def)
done
lemma prepare_thread_delete_not_recursive:
"\<lbrace>\<lambda>s. P (not_recursive_cspaces s)\<rbrace>
prepare_thread_delete t
\<lbrace>\<lambda>rv s. P (not_recursive_cspaces s)\<rbrace>"
apply (simp add: not_recursive_cspaces_def cte_wp_at_caps_of_state)
apply (wp prepare_thread_delete_caps_of_state)
done
lemma suspend_not_recursive:
"\<lbrace>\<lambda>s. P (not_recursive_cspaces s)\<rbrace>
IpcCancel_A.suspend t
\<lbrace>\<lambda>rv s. P (not_recursive_cspaces s)\<rbrace>"
apply (simp add: not_recursive_cspaces_def cte_wp_at_caps_of_state)
apply (wp suspend_caps_of_state)
apply (clarsimp simp: cte_wp_at_caps_of_state)
apply (erule rsubst[where P=P])
apply (intro set_eqI iffI)
apply (clarsimp simp: fst_cte_ptrs_def)
apply clarsimp
apply (clarsimp simp: fst_cte_ptrs_def can_fast_finalise_def
split: cap.split_asm)
done
lemma unbind_notification_not_recursive:
"\<lbrace>\<lambda>s. P (not_recursive_cspaces s)\<rbrace>
unbind_notification tcb
\<lbrace>\<lambda>rv s. P (not_recursive_cspaces s)\<rbrace>"
apply (simp add: not_recursive_cspaces_def cte_wp_at_caps_of_state)
apply (wp unbind_notification_caps_of_state)
done
lemma get_cap_det2:
"(r, s') \<in> fst (get_cap p s) \<Longrightarrow> get_cap p s = ({(r, s)}, False) \<and> s' = s"
apply (rule conjI)
apply (erule get_cap_det)
apply (erule use_valid [OF _ get_cap_inv])
apply simp
done
lemma set_zombie_not_recursive:
"\<lbrace>\<lambda>s. cte_wp_at (\<lambda>c. fst_cte_ptrs c = fst_cte_ptrs (cap.Zombie p zb n)) slot s
\<and> P (not_recursive_cspaces s)\<rbrace>
set_cap (cap.Zombie p zb n) slot
\<lbrace>\<lambda>rv s. P (not_recursive_cspaces s)\<rbrace>"
apply (simp add: not_recursive_cspaces_def)
apply (rule set_preserved_proof[where P=P])
apply simp_all
apply (wp hoare_vcg_all_lift hoare_vcg_disj_lift set_cap_cte_wp_at)
apply (fastforce simp: cte_wp_at_def fst_cte_ptrs_def)
apply (simp only: cte_wp_at_neg imp_conv_disj de_Morgan_conj simp_thms)
apply (wp hoare_vcg_ex_lift valid_cte_at_neg_typ[OF set_cap_typ_at]
hoare_vcg_disj_lift set_cap_cte_wp_at)
apply (fastforce simp: fst_cte_ptrs_def cte_wp_at_def)
done
definition
rdcall_finalise_ord_lift :: "((cslot_ptr \<times> 'z state) \<times> (cslot_ptr \<times> 'z state)) set
\<Rightarrow> ((rec_del_call \<times> 'z state) \<times> (rec_del_call \<times> 'z state)) set"
where
"rdcall_finalise_ord_lift S \<equiv>
(\<lambda>(x, s). case x of CTEDeleteCall a b \<Rightarrow> 3 | FinaliseSlotCall a b \<Rightarrow> 2
| ReduceZombieCall cap a b \<Rightarrow> 1)
<*mlex*>
((map_prod (\<lambda>(x, s). (FinaliseSlotCall x True, s)) (\<lambda>(x, s). (FinaliseSlotCall x True, s)) ` S)
\<union> (map_prod (\<lambda>(x, s). (FinaliseSlotCall x False, s)) (\<lambda>(x, s). (FinaliseSlotCall x False, s)) ` S))"
lemma wf_rdcall_finalise_ord_lift:
"wf S \<Longrightarrow> wf (rdcall_finalise_ord_lift S)"
unfolding rdcall_finalise_ord_lift_def
by (auto intro!: wf_mlex wf_Un wf_map_prod_image inj_onI)
definition
rec_del_recset :: "((rec_del_call \<times> 'z::state_ext state) \<times> (rec_del_call \<times> 'z::state_ext state)) set"
where
"rec_del_recset \<equiv>
wf_sum (exposed_rdcall \<circ> fst)
(rdcall_finalise_ord_lift (inv_image
(less_than <*lex*> less_than)
(\<lambda>(x, s). case caps_of_state s x of
Some cap.NullCap \<Rightarrow> (0, 0)
| Some (cap.Zombie p zb n) \<Rightarrow>
(if fst_cte_ptrs (cap.Zombie p zb n) = {x} then 1 else 2, n)
| _ \<Rightarrow> (3, 0))))
(rdcall_finalise_ord_lift (measure (\<lambda>(x, s). card (not_recursive_cspaces s))))"
lemma rec_del_recset_wf: "wf rec_del_recset"
unfolding rec_del_recset_def
by (intro wf_sum_wf wf_rdcall_finalise_ord_lift wf_measure
wf_inv_image wf_lex_prod wf_less_than)
lemma in_get_cap_cte_wp_at:
"(rv, s') \<in> fst (get_cap p s) = (s = s' \<and> cte_wp_at ((=) rv) p s)"
apply (rule iffI)
apply (clarsimp dest!: get_cap_det2 simp: cte_wp_at_def)
apply (clarsimp simp: cte_wp_at_def)
done
lemma fst_cte_ptrs_first_cte_of:
"fst_cte_ptrs (cap.Zombie ptr zb n) = {first_cslot_of (cap.Zombie ptr zb n)}"
by (simp add: fst_cte_ptrs_def tcb_cnode_index_def)
lemma final_cap_still_at:
"\<lbrace>\<lambda>s. cte_wp_at (\<lambda>c. gen_obj_refs cap = gen_obj_refs c
\<and> P cap (is_final_cap' c s)) ptr s\<rbrace>
set_cap cap ptr
\<lbrace>\<lambda>rv s. cte_wp_at (\<lambda>c. P c (is_final_cap' c s)) ptr s\<rbrace>"
apply (simp add: is_final_cap'_def2 cte_wp_at_caps_of_state)
apply wp
apply (clarsimp elim!: rsubst[where P="P cap"])
apply (intro ext arg_cong[where f=Ex] arg_cong[where f=All])
apply (case_tac "(aa, ba) = ptr", simp_all add: gen_obj_refs_def)
done
lemma suspend_thread_cap:
"\<lbrace>\<lambda>s. caps_of_state s x = Some (cap.ThreadCap p)\<rbrace>
IpcCancel_A.suspend t
\<lbrace>\<lambda>rv s. caps_of_state s x = Some (cap.ThreadCap p)\<rbrace>"
apply (rule hoare_chain)
apply (rule suspend_cte_wp_at_preserved
[where p=x and P="(=) (cap.ThreadCap p)"])
apply (clarsimp simp add: can_fast_finalise_def)
apply (simp add: cte_wp_at_caps_of_state)+
done
lemma emptyable_irq_state_independent[intro!, simp]:
"emptyable x (s\<lparr>machine_state := machine_state s\<lparr>irq_state := f (irq_state (machine_state s))\<rparr>\<rparr>)
= emptyable x s"
by (auto simp: emptyable_def)
lemma not_recursive_cspaces_irq_state_independent[intro!, simp]:
"not_recursive_cspaces (s \<lparr> machine_state := machine_state s \<lparr> irq_state := f (irq_state (machine_state s)) \<rparr> \<rparr>)
= not_recursive_cspaces s"
by (simp add: not_recursive_cspaces_def)
context CNodeInv_AI begin
lemma rec_del_termination:
"All (rec_del_dom :: rec_del_call \<times> 'state_ext state \<Rightarrow> bool)"
apply (rule rec_del.termination,
rule rec_del_recset_wf,
simp_all add: rec_del_recset_def wf_sum_def
in_monad is_final_cap_def
is_zombie_def rdcall_finalise_ord_lift_def
mlex_prod_def,
drule in_preempt)
apply (case_tac exposed, simp_all)
apply (rule disjI1, rule map_prod_split_imageI)
apply (simp only: trans_state_update'[symmetric])
apply (clarsimp)
apply (case_tac aa, simp_all add: fail_def rec_del.psimps)[1]
apply (rename_tac word option nat)
apply (case_tac nat, simp_all)[1]
apply (clarsimp simp: in_monad rec_del.psimps)
apply (clarsimp simp: in_monad in_get_cap_cte_wp_at
cte_wp_at_caps_of_state rec_del.psimps
split: if_split_asm)
apply (erule use_valid [OF _ set_cap_caps_of_state])+
apply (simp add: fst_cte_ptrs_first_cte_of cong: if_cong)
apply (case_tac rv, simp_all)[1]
apply (clarsimp simp: in_monad fst_cte_ptrs_first_cte_of)
apply (case_tac new_cap, simp_all add: is_cap_simps)[1]
apply (case_tac rv, simp_all)[1]
apply (clarsimp simp: fst_cte_ptrs_first_cte_of)
apply (case_tac rv, simp_all)[1]
apply (clarsimp simp: fst_cte_ptrs_first_cte_of in_monad)
apply (rule disjI2, rule map_prod_split_imageI)
apply clarsimp
apply (case_tac aa, simp_all add: fail_def rec_del.psimps)[1]
apply (rename_tac word option nat)
apply (case_tac nat, simp_all)
apply (simp only: trans_state_update'[symmetric] not_recursive_cspaces_more_update)
apply (clarsimp simp: in_monad prod_eqI rec_del.psimps)
apply (erule use_valid [OF _ cap_swap_fd_not_recursive])
apply (frule use_valid [OF _ get_cap_cte_wp_at], simp)
apply (drule in_inv_by_hoareD [OF get_cap_inv])
apply clarsimp
apply (erule use_valid [OF _ hoare_vcg_conj_lift [OF set_zombie_not_recursive
final_cap_still_at]])
apply (frule use_valid [OF _ finalise_cap_cases])
apply (fastforce simp add: cte_wp_at_eq_simp)
apply clarsimp
apply (case_tac rv, simp_all add: fst_cte_ptrs_def)
apply (clarsimp simp: in_monad cte_wp_at_caps_of_state
fst_cte_ptrs_def
split: if_split_asm)
apply (clarsimp simp: in_monad cte_wp_at_caps_of_state
fst_cte_ptrs_def
split: if_split_asm)
apply (frule(1) use_valid [OF _ unbind_notification_caps_of_state],
frule(1) use_valid [OF _ suspend_thread_cap],
frule(1) use_valid [OF _ prepare_thread_delete_thread_cap])
apply clarsimp
apply (erule use_valid [OF _ prepare_thread_delete_not_recursive])
apply (erule use_valid [OF _ suspend_not_recursive])
apply (erule use_valid [OF _ unbind_notification_not_recursive])
apply simp
apply (clarsimp simp: in_monad cte_wp_at_caps_of_state
fst_cte_ptrs_def zombie_cte_bits_def
tcb_cnode_index_def
split: option.split_asm)
done
lemma rec_del_dom: "\<And> (p :: rec_del_call \<times> 'state_ext state). rec_del_dom p"
using rec_del_termination by blast
lemmas rec_del_simps = rec_del.psimps[OF rec_del_dom]
lemmas rec_del_simps_ext =
rec_del_simps [THEN ext[where f="rec_del args" for args]]
lemmas rec_del_fails = spec_validE_fail rec_del_simps_ext(5-)
declare assertE_wp[wp]
declare unlessE_wp[wp_split]
lemma without_preemption_wp [wp_split]:
"\<lbrace>P\<rbrace> f \<lbrace>Q\<rbrace> \<Longrightarrow> \<lbrace>P\<rbrace> without_preemption f \<lbrace>Q\<rbrace>,\<lbrace>E\<rbrace>"
by simp
lemmas rec_del_induct = rec_del.pinduct[OF rec_del_dom]
lemma rec_del_preservation':
fixes s :: "'state_ext state"
fixes P :: "'state_ext state \<Rightarrow> bool"
assumes wp:
"\<And>sl1 sl2. \<lbrace>P\<rbrace> cap_swap_for_delete sl1 sl2 \<lbrace>\<lambda>rv. P\<rbrace>"
"\<And>sl cap. \<lbrace>P\<rbrace> set_cap sl cap \<lbrace>\<lambda>rv. P\<rbrace>"
"\<And>sl opt. \<lbrace>P\<rbrace> empty_slot sl opt \<lbrace>\<lambda>rv. P\<rbrace>"
"\<And>cap fin. \<lbrace>P\<rbrace> finalise_cap cap fin \<lbrace>\<lambda>rv. P\<rbrace>"
"\<And>cap fin. \<lbrace>P\<rbrace> preemption_point \<lbrace>\<lambda>rv. P\<rbrace>"
shows
"s \<turnstile> \<lbrace>P\<rbrace> rec_del call \<lbrace>\<lambda>_. P\<rbrace>, \<lbrace>\<lambda>_. P\<rbrace>"
proof (induct rule: rec_del_induct)
case (1 slot exposed s)
show ?case
apply (subst rec_del_simps)
apply (simp only: split_def)
apply wp
apply (wp wp)[1]
apply (rule spec_strengthen_postE)
apply (rule "1.hyps")
apply simp
done
next
case (2 slot exposed s)
show ?case
apply (subst rec_del_simps)
apply (simp only: split_def)
apply (wp wp "2.hyps")
apply (wp wp)[1]
apply (simp only: simp_thms)
apply (rule "2.hyps", assumption+)
apply (wp wp hoare_drop_imps | simp add: is_final_cap_def)+
done
next
case 3
show ?case
apply (simp add: rec_del_simps | wp wp)+
done
next
case (4 ptr bits n slot s)
show ?case
apply (subst rec_del_simps)
apply (wp wp)
apply (wp hoare_drop_imps)[1]
apply (simp only: simp_thms)
apply (rule "4.hyps", assumption+)
apply wp
done
qed (auto simp: rec_del_dom rec_del_fails)
lemmas rec_del_preservation[crunch_rules] =
validE_valid [OF use_spec(2) [OF rec_del_preservation']]
end
crunch typ_at: cap_swap_for_delete "\<lambda>s. P (typ_at T p s)"
lemma cap_swap_valid_cap:
"\<lbrace>valid_cap c\<rbrace> cap_swap_for_delete x y \<lbrace>\<lambda>_. valid_cap c\<rbrace>"
apply(simp add: cap_swap_for_delete_def)
apply(wp cap_swap_valid_cap)
apply(simp)
done
lemma cap_swap_cte_at:
"\<lbrace>cte_at p\<rbrace> cap_swap_for_delete x y \<lbrace>\<lambda>_. cte_at p\<rbrace>"
apply(simp add: cap_swap_for_delete_def)
apply(wp cap_swap_cte_at)
apply(simp)
done
context CNodeInv_AI begin
crunch typ_at: rec_del "\<lambda>s::'state_ext state. P (typ_at T p s)"
(ignore: preemption_point wp: preemption_point_inv)
lemma rec_del_cte_at:
"\<And>c call. \<lbrace>cte_at c :: 'state_ext state \<Rightarrow> bool\<rbrace> rec_del call \<lbrace>\<lambda>_. cte_at c\<rbrace>"
by (wp valid_cte_at_typ rec_del_typ_at)
end
lemma dom_valid_cap[wp]:
"\<lbrace>valid_cap c\<rbrace> do_machine_op f \<lbrace>\<lambda>_. valid_cap c\<rbrace>"
apply (simp add: do_machine_op_def split_def)
apply (wp select_wp)
apply simp
done
lemma dom_cte_at:
"\<lbrace>cte_at c\<rbrace> do_machine_op f \<lbrace>\<lambda>_. cte_at c\<rbrace>"
apply (simp add: do_machine_op_def split_def)
apply (wp select_wp)
apply (simp add: cte_at_cases)
done
lemma cnode_to_zombie_valid:
"\<lbrakk> s \<turnstile> cap.CNodeCap oref bits guard \<rbrakk>
\<Longrightarrow> s \<turnstile> cap.Zombie oref (Some bits) (2 ^ bits)"
by (clarsimp simp: valid_cap_def cap_table_at_cte_at
word_unat_power cap_aligned_def)
lemma tcb_to_zombie_valid:
"\<lbrakk> s \<turnstile> cap.ThreadCap t \<rbrakk>
\<Longrightarrow> s \<turnstile> cap.Zombie t None 5"
apply (simp add: valid_cap_def)
apply (simp add: cap_aligned_def)
done
lemmas do_machine_op_cte_at [wp] = dom_cte_at
declare set_cap_cte_at[wp]
set_cap_valid_cap [wp]
lemma set_original_valid_pspace:
"\<lbrace>valid_pspace\<rbrace> set_original p v \<lbrace>\<lambda>rv. valid_pspace\<rbrace>"
apply wp
apply (erule valid_pspace_eqI)
apply simp
done
locale mdb_swap_abs_invs = mdb_swap_abs +
fixes cs cs' cap cap' scap dcap
defines "cs \<equiv> caps_of_state s"
defines "cs' \<equiv> cs (src \<mapsto> dcap, dest \<mapsto> scap)"
assumes cap: "cs src = Some cap"
assumes cap': "cs dest = Some cap'"
assumes sder: "weak_derived scap cap"
assumes dder: "weak_derived dcap cap'"
lemma obj_ref_untyped_empty [simp]:
"obj_refs c \<inter> untyped_range c = {}"
by (cases c, auto)
lemma weak_derived_Reply_eq:
"\<lbrakk> weak_derived c c'; c = ReplyCap t m R \<rbrakk> \<Longrightarrow> (\<exists> R'. (c' = cap.ReplyCap t m R'))"
"\<lbrakk> weak_derived c c'; c' = ReplyCap t m R\<rbrakk> \<Longrightarrow> (\<exists> R'. (c = cap.ReplyCap t m R' ))"
by (auto simp: weak_derived_def copy_of_def
same_object_as_def is_cap_simps
split: if_split_asm cap.split_asm)
context mdb_swap_abs_invs begin
lemmas src_ranges [simp] = weak_derived_ranges [OF sder]
lemmas dest_ranges [simp] = weak_derived_ranges [OF dder]
lemma no_mloop_n:
"no_mloop n"
by (simp add: no_mloop_def parency)
lemma mdb_cte_n:
"mdb_cte_at (\<lambda>p. \<exists>c. cs' p = Some c \<and> cap.NullCap \<noteq> c) n"
proof -
from valid_mdb
have "mdb_cte_at (\<lambda>p. \<exists>c. cs p = Some c \<and> cap.NullCap \<noteq> c) m"
by (simp add: cs_def m valid_mdb_def2)
thus ?thesis using cap cap' sder dder
apply (clarsimp simp add: mdb_cte_at_def)
apply (cases src, cases dest)
apply (simp add: n_def n'_def cs'_def split: if_split_asm)
apply fastforce
apply fastforce
apply fastforce
apply fastforce
apply fastforce
apply fastforce
apply fastforce
done
qed
lemma descendants_no_loop [simp]:
"x \<notin> descendants_of x m"
by (simp add: descendants_of_def)
lemma untyped_mdb_n:
"untyped_mdb n cs'"
proof -
from valid_mdb
have "untyped_mdb m cs"
by (simp add: cs_def m valid_mdb_def2)
thus ?thesis using cap cap'
by (simp add: untyped_mdb_def cs'_def descendants_of_def parency
s_d_swap_def
del: split_paired_All)
qed
lemma descendants_inc_n:
shows "descendants_inc n cs'"
proof -
from valid_mdb
have "descendants_inc m cs"
by (simp add:cs_def m valid_mdb_def2)
thus ?thesis using cap cap' sder dder
apply (simp add:descendants_inc_def descendants_of_def del: split_paired_All)
apply (intro impI allI)
apply (simp add:parency cs'_def del:split_paired_All)
apply (drule spec)+
apply (erule(1) impE)
apply (simp add: weak_derived_cap_range)
apply (intro conjI impI)
apply (simp add:s_d_swap_other)+
done
qed
lemma untyped_inc_n:
assumes untyped_eq:"(is_untyped_cap cap \<Longrightarrow> scap = cap)" "(is_untyped_cap cap' \<Longrightarrow> dcap = cap')"
shows "untyped_inc n cs'"
proof -
from valid_mdb
have "untyped_inc m cs"
by (simp add: cs_def m valid_mdb_def2)
thus ?thesis using cap cap'
apply (simp add: untyped_inc_def cs'_def descendants_of_def parency s_d_swap_def
del: split_paired_All)
apply (intro allI)
apply (intro conjI)
apply (intro impI allI)
apply (intro conjI)
apply (drule_tac x = p in spec)
apply (drule_tac x = p' in spec)
apply (clarsimp simp:untyped_eq)
apply (intro impI allI)
apply (drule_tac x = p' in spec)
apply (drule_tac x = dest in spec)
apply (clarsimp simp:untyped_eq)
apply (intro impI)
apply (intro conjI)
apply (intro impI allI)
apply (drule_tac x = src in spec)
apply (intro conjI)
apply (drule_tac x = dest in spec)
apply (clarsimp simp:untyped_eq)
apply (drule_tac x = p' in spec)
apply (clarsimp simp:untyped_eq)
apply (intro impI allI)
apply (intro conjI)
apply (drule_tac x = dest in spec)
apply (drule_tac x = p in spec)
apply (clarsimp simp:untyped_eq)
apply (drule_tac x = src in spec)
apply (drule_tac x = p in spec)
apply (clarsimp simp:untyped_eq)
done
qed
lemmas src_replies[simp] = weak_derived_replies [OF sder]
lemmas dest_replies[simp] = weak_derived_replies [OF dder]
lemma reply_caps_mdb_n:
"reply_caps_mdb n cs'"
proof -
from valid_mdb
have "reply_caps_mdb m cs"
by (simp add: cs_def m valid_mdb_def2 reply_mdb_def)
thus ?thesis using cap cap' unfolding reply_caps_mdb_def cs'_def n_def n'_def
apply (intro allI impI)
apply (simp split: if_split_asm del: split_paired_All split_paired_Ex)
apply (elim allE)
apply (drule weak_derived_Reply_eq(1) [OF sder], simp del: split_paired_Ex)
apply (erule impE, fastforce)
apply (intro conjI impI)
apply (clarsimp elim!: weak_derived_Reply_eq(2) [OF dder])
apply (erule exEI, clarsimp)
apply (elim allE)
apply (drule weak_derived_Reply_eq(1) [OF dder], simp del: split_paired_Ex)
apply (erule impE, fastforce)
apply (intro conjI impI)
apply (clarsimp elim!: weak_derived_Reply_eq(2) [OF sder])
apply (erule exEI, clarsimp)
apply (erule_tac x=ptr in allE, erule_tac x=t in allE)
apply (erule impE, fastforce)
apply (intro conjI impI)
apply (clarsimp elim!: weak_derived_Reply_eq(2) [OF dder])
apply (clarsimp elim!: weak_derived_Reply_eq(2) [OF sder])
apply fastforce
done
qed
lemma reply_masters_mdb_n:
"reply_masters_mdb n cs'"
proof -
from valid_mdb
have r: "reply_masters_mdb m cs"
by (simp add: cs_def m valid_mdb_def2 reply_mdb_def)
have n_None:
"\<And>t R. scap = cap.ReplyCap t True R \<Longrightarrow> n dest = None"
"\<And>t R. dcap = cap.ReplyCap t True R \<Longrightarrow> n src = None"
using r cap cap' unfolding reply_masters_mdb_def n_def
by (drule_tac weak_derived_Reply_eq(1) [OF sder]
weak_derived_Reply_eq(1) [OF dder],
fastforce simp: n'_def simp del: split_paired_All)+
show ?thesis unfolding reply_masters_mdb_def cs'_def using cap cap' r
apply (intro allI impI)
apply (simp add: n_None descendants s_d_swap_def
split: if_split_asm del: split_paired_All)
apply (unfold reply_masters_mdb_def)[1]
apply (drule weak_derived_Reply_eq(1) [OF sder], simp del: split_paired_All)
apply (elim allE, erule impE, fastforce, elim conjE)
apply (intro impI conjI)
apply (drule(1) bspec)
apply clarsimp
apply (rule weak_derived_Reply_eq(2) [OF dder])
apply simp
apply fastforce
apply fastforce
apply (unfold reply_masters_mdb_def)[1]
apply (drule weak_derived_Reply_eq(1) [OF dder], simp del: split_paired_All)
apply (elim allE, erule impE, fastforce, elim conjE)
apply (intro impI conjI)
apply (drule(1) bspec, clarsimp, rule weak_derived_Reply_eq(2) [OF sder], simp)
apply fastforce+
apply (unfold reply_masters_mdb_def)[1]
apply (erule_tac x=ptr in allE, erule_tac x=t in allE)
apply (elim allE impE, fastforce)
apply (erule conjE, simp add: n_def n'_def)
apply (fastforce intro:weak_derived_Reply_eq(2)[OF dder] weak_derived_Reply_eq(2)[OF sder])+
done
qed
lemma reply_mdb_n:
"reply_mdb n cs'"
by (simp add: reply_mdb_def reply_masters_mdb_n reply_caps_mdb_n)
end
definition
"swap_mdb m src dest \<equiv>
let n' = (\<lambda>n. if m n = Some src then Some dest
else if m n = Some dest then Some src
else m n) in
n' (src := n' dest, dest := n' src)"
lemma cap_swap_mdb [wp]:
"\<lbrace>valid_mdb and
cte_wp_at (weak_derived c) a and
cte_wp_at (\<lambda>cc. is_untyped_cap cc \<longrightarrow> cc = c) a and
cte_wp_at (weak_derived c') b and K (a \<noteq> b) and cte_wp_at (\<lambda>cc. is_untyped_cap cc \<longrightarrow> cc = c') b\<rbrace>
cap_swap c a c' b
\<lbrace>\<lambda>_. valid_mdb\<rbrace>"
apply (simp add: valid_mdb_def2 cap_swap_def set_cdt_def bind_assoc set_original_def)
apply (wp | simp del: fun_upd_apply split del: if_split)+
apply (fold swap_mdb_def [simplified Let_def])
apply (wp set_cap_caps_of_state2 get_cap_wp)+
apply (clarsimp simp: cte_wp_at_caps_of_state simp del: fun_upd_apply)
apply (subgoal_tac "mdb_swap_abs_invs (cdt s) a b s cap capb c c'")
prefer 2
apply (rule mdb_swap_abs_invs.intro)
apply (rule mdb_swap_abs.intro)
apply (simp add: valid_mdb_def2)
apply (fastforce simp: cte_wp_at_caps_of_state)
apply (fastforce simp: cte_wp_at_caps_of_state)
apply (rule refl)
apply assumption
apply (erule (3) mdb_swap_abs_invs_axioms.intro)
apply (unfold swap_mdb_def Let_def)
apply (simp add: mdb_swap_abs_invs.no_mloop_n
mdb_swap_abs_invs.untyped_mdb_n
mdb_swap_abs_invs.mdb_cte_n
mdb_swap_abs_invs.reply_mdb_n
del: fun_upd_apply
split del: if_split)
apply (rule conjI)
apply (erule mdb_swap_abs_invs.descendants_inc_n)
apply (rule conjI)
apply (erule mdb_swap_abs_invs.untyped_inc_n)
apply (clarsimp simp:cte_wp_at_caps_of_state)+
apply (rule conjI)
apply (simp add: ut_revocable_def weak_derived_ranges del: split_paired_All)
apply (rule conjI)
apply (simp add: irq_revocable_def del: split_paired_All)
apply (intro conjI impI allI)
apply (simp del: split_paired_All)
apply (simp del: split_paired_All)
apply (simp add: reply_master_revocable_def weak_derived_replies
del: split_paired_All)
apply (clarsimp simp: valid_arch_mdb_cap_swap)
done
lemma set_cdt_valid_objs[wp]:
"\<lbrace>valid_objs\<rbrace> set_cdt m \<lbrace>\<lambda>rv. valid_objs\<rbrace>"
by (simp add: set_cdt_def | wp)+
lemma cap_swap_valid_objs[wp]:
"\<lbrace>valid_objs and valid_cap c and valid_cap c'
and tcb_cap_valid c b and tcb_cap_valid c' a\<rbrace>
cap_swap c a c' b
\<lbrace>\<lambda>rv. valid_objs\<rbrace>"
apply (simp add: cap_swap_def)
apply (wp set_cap_valid_objs
| simp split del: if_split)+
done
crunch aligned[wp]: cap_swap "pspace_aligned"
crunch disctinct[wp]: cap_swap "pspace_distinct"
lemma cap_swap_iflive[wp]:
"\<lbrace>if_live_then_nonz_cap and cte_wp_at (\<lambda>x. zobj_refs x = zobj_refs c) a
and cte_wp_at (\<lambda>x. zobj_refs x = zobj_refs c') b\<rbrace>
cap_swap c a c' b
\<lbrace>\<lambda>rv. if_live_then_nonz_cap\<rbrace>"
apply (simp add: cap_swap_def)
apply (wp | simp split del: if_split)+
apply (rule hoare_post_imp)
apply (simp only: if_live_then_nonz_cap_def ex_nonz_cap_to_def
cte_wp_at_caps_of_state imp_conv_disj)
apply (wp hoare_vcg_all_lift hoare_vcg_disj_lift hoare_vcg_ex_lift
get_cap_wp)+
apply (clarsimp simp add: cte_wp_at_caps_of_state)
apply (frule(1) if_live_then_nonz_capD)
apply assumption
apply (clarsimp simp: ex_nonz_cap_to_def cte_wp_at_caps_of_state)
apply (subst split_paired_Ex[symmetric])
apply (rule_tac x="if (aa, ba) = a then b else if (aa, ba) = b then a else (aa, ba)"
in exI)
apply (clarsimp | rule conjI)+
done
lemma cap_swap_fd_iflive[wp]:
"\<lbrace>if_live_then_nonz_cap\<rbrace>
cap_swap_for_delete a b
\<lbrace>\<lambda>rv. if_live_then_nonz_cap\<rbrace>"
apply (simp add: cap_swap_for_delete_def)
apply (wp get_cap_wp)
apply (clarsimp simp: cte_wp_at_caps_of_state)
done
lemma set_cdt_caps_of[wp]:
"\<lbrace>\<lambda>s. P (caps_of_state s)\<rbrace> set_cdt m \<lbrace>\<lambda>rv s. P (caps_of_state s)\<rbrace>"
by wp
lemma cap_swap_ex_cte_cap[wp]:
"\<lbrace>ex_cte_cap_wp_to P p
and cte_wp_at (\<lambda>x. cte_refs x = cte_refs c
\<and> ((\<exists>y. cte_refs x y \<noteq> {}) \<longrightarrow> P x = P c)) a
and cte_wp_at (\<lambda>x. cte_refs x = cte_refs c'
\<and> ((\<exists>y. cte_refs x y \<noteq> {}) \<longrightarrow> P x = P c')) b\<rbrace>
cap_swap c a c' b
\<lbrace>\<lambda>rv. ex_cte_cap_wp_to P p\<rbrace>"
apply (simp add: cap_swap_def ex_cte_cap_wp_to_def
cte_wp_at_caps_of_state
del: split_paired_Ex)
apply (wp get_cap_wp | simp split del: if_split del: split_paired_Ex)+
apply (simp del: split_paired_Ex | intro allI impI | erule conjE)+
apply (erule exfEI [where f="id ( a := b, b := a )"])
apply (clarsimp simp: cte_wp_at_caps_of_state | rule conjI)+
done
lemma cap_swap_fd_ex_cte_cap[wp]:
"\<lbrace>ex_cte_cap_wp_to P p\<rbrace> cap_swap_for_delete a b \<lbrace>\<lambda>rv. ex_cte_cap_wp_to P p\<rbrace>"
apply (simp add: cap_swap_for_delete_def)
apply (wp get_cap_wp)
apply (clarsimp simp: cte_wp_at_caps_of_state)
done
lemma cap_swap_caps_of_state[wp]:
"\<lbrace>\<lambda>s. P ((caps_of_state s) ( a := Some c', b := Some c ))\<rbrace>
cap_swap c a c' b
\<lbrace>\<lambda>rv s. P (caps_of_state s)\<rbrace>"
apply (simp add: cap_swap_def)
apply (wp get_cap_wp | simp del: fun_upd_apply split del: if_split)+
done
lemma cap_swap_fd_caps_of_state[wp]:
"\<lbrace>\<lambda>s. P ((caps_of_state s) \<circ> (id ( a := b, b := a )))\<rbrace>
cap_swap_for_delete a b
\<lbrace>\<lambda>rv s. P (caps_of_state s)\<rbrace>"
apply (simp add: cap_swap_for_delete_def)
apply (wp get_cap_wp)
apply (cases "a = b")
apply (simp add: fun_upd_def id_def[symmetric] cong: if_cong)
apply (clarsimp simp: cte_wp_at_caps_of_state)
apply (erule rsubst[where P=P])
apply (clarsimp intro!: ext)
done
lemma cap_irqs_appropriateness:
"cap_irqs cap = cap_irqs cap'
\<Longrightarrow> \<forall>cp. appropriate_cte_cap cp cap = appropriate_cte_cap cp cap'"
by (simp add: appropriate_cte_cap_irqs)
lemma cap_swap_ifunsafe[wp]:
"\<lbrace>if_unsafe_then_cap
and ex_cte_cap_wp_to (appropriate_cte_cap c') a
and ex_cte_cap_wp_to (appropriate_cte_cap c) b
and cte_wp_at (\<lambda>x. cte_refs x = cte_refs c
\<and> ((\<exists>y. cte_refs x y \<noteq> {}) \<longrightarrow> cap_irqs x = cap_irqs c)) a
and cte_wp_at (\<lambda>x. cte_refs x = cte_refs c'
\<and> ((\<exists>y. cte_refs x y \<noteq> {}) \<longrightarrow> cap_irqs x = cap_irqs c')) b\<rbrace>
cap_swap c a c' b
\<lbrace>\<lambda>rv s. if_unsafe_then_cap s\<rbrace>"
apply (simp only: if_unsafe_then_cap_def cte_wp_at_caps_of_state
imp_conv_disj not_ex)
apply (wp hoare_vcg_all_lift hoare_vcg_disj_lift)
apply (clarsimp split del: if_split del: disjCI intro!: disjCI2)
apply (intro conjI)
apply (clarsimp split: if_split_asm)
apply (drule(1) if_unsafe_then_capD[OF caps_of_state_cteD])
apply clarsimp
apply (erule ex_cte_cap_wp_to_weakenE)
apply clarsimp
apply (auto dest!: cap_irqs_appropriateness elim!: cte_wp_at_weakenE)
done
lemma cap_irqs_appropriate_strengthen:
"ex_cte_cap_wp_to (\<lambda>cp. cap_irqs cp = {}) x s
\<longrightarrow> ex_cte_cap_wp_to (appropriate_cte_cap cap) x s"
by (auto simp: appropriate_cte_cap_def
elim!: ex_cte_cap_wp_to_weakenE
split: cap.split)
lemma cap_swap_fd_ifunsafe[wp]:
"\<lbrace>if_unsafe_then_cap
and ex_cte_cap_wp_to (\<lambda>cp. cap_irqs cp = {}) a
and ex_cte_cap_wp_to (\<lambda>cp. cap_irqs cp = {}) b\<rbrace>
cap_swap_for_delete a b
\<lbrace>\<lambda>rv s. if_unsafe_then_cap s\<rbrace>"
apply (simp add: cap_swap_for_delete_def)
apply (wp get_cap_wp)
apply (clarsimp simp: cte_wp_at_caps_of_state
| strengthen cap_irqs_appropriate_strengthen)+
done
lemma cap_swap_zombies[wp]:
"\<lbrace>zombies_final and cte_wp_at (\<lambda>x. is_zombie x = is_zombie c
\<and> gen_obj_refs x = gen_obj_refs c) a
and cte_wp_at (\<lambda>x. is_zombie x = is_zombie c' \<and> gen_obj_refs x = gen_obj_refs c') b\<rbrace>
cap_swap c a c' b
\<lbrace>\<lambda>rv. zombies_final\<rbrace>"
apply (simp only: zombies_final_def final_cap_at_eq
cte_wp_at_caps_of_state simp_thms pred_conj_def)
apply wp
apply (elim conjE)
apply (erule allfEI[where f="id ( a := b, b := a )"])
apply (intro impI)
apply (drule mp)
apply (clarsimp split: if_split_asm)
apply (elim exE conjE, simp only: simp_thms option.simps)
apply (rule conjI)
apply (clarsimp simp: is_cap_simps gen_obj_refs_def)
apply (erule allfEI[where f="id ( a := b, b := a )"])
apply (intro impI, elim exE conjE, simp only: simp_thms option.simps gen_obj_refs_eq)
apply (clarsimp simp: gen_obj_refs_Int split: if_split_asm)
done
lemma cap_swap_fd_zombies[wp]:
"\<lbrace>zombies_final\<rbrace>
cap_swap_for_delete p p'
\<lbrace>\<lambda>rv. zombies_final\<rbrace>"
apply (simp add: cap_swap_for_delete_def)
apply (wp get_cap_wp)
apply (clarsimp simp: cte_wp_at_caps_of_state)
done
lemma cap_swap_pred_tcb_at[wp]:
"\<lbrace>pred_tcb_at proj P t\<rbrace> cap_swap c sl c' sl' \<lbrace>\<lambda>rv. pred_tcb_at proj P t\<rbrace>"
unfolding cap_swap_def by (wp | simp)+
lemma unique_reply_caps_cap_swap:
assumes u: "unique_reply_caps cs"
and c: "cs p = Some cap"
and c': "cs p' = Some cap'"
and wd: "weak_derived c cap"
and wd': "weak_derived c' cap'"
and pneq: "p \<noteq> p'"
shows "unique_reply_caps (cs (p \<mapsto> c', p' \<mapsto> c))"
proof -
have new_cap_is_unique[elim]:
"\<And> p'' t R R'.\<lbrakk>p'' \<noteq> p; p'' \<noteq> p'; cs p'' = Some (ReplyCap t False R);
c = ReplyCap t False R' \<or> c' = ReplyCap t False R' \<rbrakk>
\<Longrightarrow> False"
using u unfolding unique_reply_caps_def
apply (erule_tac disjE)
apply simp
apply (frule weak_derived_Reply_eq[OF wd])
apply (fastforce simp add:c)
apply simp
apply (frule weak_derived_Reply_eq[OF wd'])
apply (fastforce simp add:c' is_cap_simps)
done
have old_caps_differ:
"\<And>t R R'.
\<lbrakk> cap= ReplyCap t False R; cap' = ReplyCap t False R' \<rbrakk>
\<Longrightarrow> False"
using u c c' is_cap_simps pneq unfolding unique_reply_caps_def by fastforce
have new_cap_objs_differ[elim]:
"\<And>t R R'. \<lbrakk> c= ReplyCap t False R; c' = ReplyCap t False R'\<rbrakk> \<Longrightarrow> False"
apply (drule weak_derived_Reply_eq [OF wd])
apply (drule weak_derived_Reply_eq [OF wd'])
using old_caps_differ by fastforce
show ?thesis
using u unfolding unique_reply_caps_def
apply (intro allI impI)
apply (simp split: if_split_asm del: split_paired_All)
apply fastforce+
done
qed
lemma cap_swap_no_reply_caps:
assumes cap: "cs p = Some cap"
and cap': "cs p' = Some cap'"
and wd: "weak_derived c cap"
and wd': "weak_derived c' cap'"
and nr: "\<forall>sl R. cs sl \<noteq> Some (cap.ReplyCap t False R)"
shows "\<forall>sl R. (cs(p \<mapsto> c', p' \<mapsto> c)) sl \<noteq> Some (cap.ReplyCap t False R)"
proof -
have
"\<forall> R. cap \<noteq> cap.ReplyCap t False R"
"\<forall> R. cap' \<noteq> cap.ReplyCap t False R"
using cap cap' nr by clarsimp+
hence
"\<forall> R. c \<noteq> cap.ReplyCap t False R"
"\<forall> R. c' \<noteq> cap.ReplyCap t False R"
by (clarsimp,drule_tac weak_derived_Reply_eq [OF wd]
weak_derived_Reply_eq [OF wd'],fastforce)+
thus ?thesis
using nr unfolding fun_upd_def
by (clarsimp split: if_split_asm)
qed
lemma cap_swap_has_reply_cap_neg:
"\<lbrace>\<lambda>s. \<not> has_reply_cap t s \<and>
cte_wp_at (weak_derived c) p s \<and>
cte_wp_at (weak_derived c') p' s \<and>
p \<noteq> p'\<rbrace>
cap_swap c p c' p' \<lbrace>\<lambda>rv s. \<not> has_reply_cap t s\<rbrace>"
apply (simp add: has_reply_cap_def is_reply_cap_to_def cte_wp_at_caps_of_state
del: split_paired_All split_paired_Ex)
apply (wp cap_swap_caps_of_state)
apply (elim conjE exE)
apply (drule(3) cap_swap_no_reply_caps[where cs="caps_of_state _"])
apply fastforce+
done
lemma cap_swap_replies:
"\<lbrace>\<lambda>s. valid_reply_caps s
\<and> cte_wp_at (weak_derived c) p s
\<and> cte_wp_at (weak_derived c') p' s
\<and> p \<noteq> p'\<rbrace>
cap_swap c p c' p'
\<lbrace>\<lambda>rv s. valid_reply_caps s\<rbrace>"
apply (simp add: valid_reply_caps_def)
apply (rule hoare_pre)
apply (simp only: imp_conv_disj)
apply (wp hoare_vcg_all_lift hoare_vcg_disj_lift cap_swap_has_reply_cap_neg)
apply (clarsimp simp: fun_upd_def cte_wp_at_caps_of_state
unique_reply_caps_cap_swap [simplified fun_upd_def])
done
lemma cap_swap_fd_replies[wp]:
"\<lbrace>\<lambda>s. valid_reply_caps s\<rbrace>
cap_swap_for_delete p p'
\<lbrace>\<lambda>rv s. valid_reply_caps s\<rbrace>"
apply (simp add: cap_swap_for_delete_def)
apply (wp cap_swap_replies get_cap_wp)
apply (fastforce elim: cte_wp_at_weakenE)
done
lemma cap_swap_reply_masters:
"\<lbrace>valid_reply_masters and K(\<not> is_master_reply_cap c \<and> \<not> is_master_reply_cap c')\<rbrace>
cap_swap c p c' p' \<lbrace>\<lambda>_. valid_reply_masters\<rbrace>"
apply (simp add: valid_reply_masters_def is_master_reply_cap_to_def cte_wp_at_caps_of_state)
apply (rule hoare_pre)
apply (simp only: imp_conv_disj)
apply (wp hoare_vcg_all_lift hoare_vcg_disj_lift cap_swap_caps_of_state
cap_swap_typ_at tcb_at_typ_at)
apply (simp add: is_cap_simps)
apply fastforce
done
lemma cap_swap_fd_reply_masters[wp]:
"\<lbrace>valid_reply_masters and
cte_wp_at (\<lambda>c. \<not> is_master_reply_cap c) p and
cte_wp_at (\<lambda>c. \<not> is_master_reply_cap c) p'\<rbrace>
cap_swap_for_delete p p'
\<lbrace>\<lambda>rv. valid_reply_masters\<rbrace>"
apply (simp add: cap_swap_for_delete_def)
apply (wp cap_swap_reply_masters get_cap_wp)
apply (clarsimp simp: cte_wp_at_def)
done
crunch refs_of[wp]: cap_swap "\<lambda>s. P (state_refs_of s)"
(ignore: set_cap simp: state_refs_of_pspaceI)
crunch hyp_refs_of[wp]: cap_swap "\<lambda>s. P (state_hyp_refs_of s)"
(ignore: set_cap simp: state_refs_of_pspaceI)
crunch cur_tcb[wp]: cap_swap "cur_tcb"
lemma copy_of_cte_refs:
"copy_of cap cap' \<Longrightarrow> cte_refs cap = cte_refs cap'"
apply (rule ext, clarsimp simp: copy_of_def split: if_split_asm)
apply (cases cap', simp_all add: same_object_as_def)
apply (clarsimp simp: is_cap_simps bits_of_def
split: cap.split_asm)+
done
lemma copy_of_is_zombie:
"copy_of cap cap' \<Longrightarrow> is_zombie cap = is_zombie cap'"
apply (clarsimp simp: copy_of_def split: if_split_asm)
apply (cases cap', simp_all add: same_object_as_def)
apply (clarsimp simp: is_cap_simps bits_of_def
split: cap.split_asm)+
done
lemma copy_of_reply_cap:
"copy_of (ReplyCap t False R) cap \<Longrightarrow> \<exists> R'. cap = ReplyCap t False R'"
apply (clarsimp simp: copy_of_def is_cap_simps)
by (cases cap, simp_all add: same_object_as_def)
lemma copy_of_cap_irqs:
"copy_of cap cap' \<Longrightarrow> cap_irqs cap = cap_irqs cap'"
apply (clarsimp simp: copy_of_def cap_irqs_def split: if_split_asm)
apply (cases cap', simp_all add: same_object_as_def)
by (clarsimp simp: is_cap_simps bits_of_def cap_range_def
split: cap.split_asm)+
lemma copy_of_arch_gen_obj_refs:
"copy_of cap cap' \<Longrightarrow> arch_gen_refs cap = arch_gen_refs cap'"
apply (clarsimp simp: copy_of_def split: if_split_asm)
by (cases cap'; clarsimp simp: same_object_as_def is_cap_simps same_aobject_same_arch_gen_refs
split: cap.split_asm)
lemma cap_swap_valid_idle[wp]:
"\<lbrace>valid_idle\<rbrace>
cap_swap c a c' b \<lbrace>\<lambda>_. valid_idle\<rbrace>"
apply (simp add: cap_swap_def set_cdt_def)
apply (wp set_cap_idle set_cap_it|simp)+
done
lemma cap_swap_global_refs[wp]:
"\<lbrace>valid_global_refs and
(\<lambda>s. global_refs s \<inter> cap_range c = {}) and
(\<lambda>s. global_refs s \<inter> cap_range c' = {})\<rbrace>
cap_swap c a c' b \<lbrace>\<lambda>_. valid_global_refs\<rbrace>"
apply (simp add: cap_swap_def set_cdt_def)
apply (wp set_cap_globals | simp)+
done
crunch arch[wp]: cap_swap "\<lambda>s. P (arch_state s)"
crunch irq_node[wp]: cap_swap "\<lambda>s. P (interrupt_irq_node s)"
lemma valid_reply_caps_of_stateD:
"\<And>p t s R. \<lbrakk> valid_reply_caps s; caps_of_state s p = Some (cap.ReplyCap t False R) \<rbrakk>
\<Longrightarrow> st_tcb_at awaiting_reply t s"
by (fastforce simp: valid_reply_caps_def has_reply_cap_def
is_reply_cap_to_def cte_wp_at_caps_of_state)
lemma valid_reply_caps_of_stateD':
"\<And>p t s R. \<lbrakk> valid_reply_caps s; cte_wp_at (is_reply_cap_to t) p s \<rbrakk>
\<Longrightarrow> st_tcb_at awaiting_reply t s"
by (fastforce simp: valid_reply_caps_def has_reply_cap_def
is_reply_cap_to_def cte_wp_at_caps_of_state)
crunch interrupt_states[wp]: cap_swap "\<lambda>s. P (interrupt_states s)"
lemma weak_derived_cap_irqs:
"weak_derived c c' \<Longrightarrow> cap_irqs c = cap_irqs c'"
by (auto simp add: weak_derived_def copy_of_cap_irqs)
lemma cap_swap_irq_handlers[wp]:
"\<lbrace>valid_irq_handlers and
cte_wp_at (weak_derived c) a and
cte_wp_at (weak_derived c') b\<rbrace>
cap_swap c a c' b \<lbrace>\<lambda>rv. valid_irq_handlers\<rbrace>"
apply (simp add: valid_irq_handlers_def irq_issued_def)
apply (rule hoare_pre)
apply (wp hoare_use_eq [where f=interrupt_states,
OF cap_swap_interrupt_states cap_swap_caps_of_state])
apply (clarsimp simp: cte_wp_at_caps_of_state
elim!: ranE split: if_split_asm
dest!: weak_derived_cap_irqs)
apply auto
done
crunch vspace_objs [wp]: cap_swap "valid_vspace_objs"
crunch valid_global_objs [wp]: cap_swap "valid_global_objs"
crunch valid_global_vspace_mappings [wp]: cap_swap "valid_global_vspace_mappings"
context CNodeInv_AI begin
lemma cap_swap_valid_arch_caps[wp]:
"\<And>c a c' b.
\<lbrace>valid_arch_caps and cte_wp_at (weak_derived c) a and cte_wp_at (weak_derived c') b\<rbrace>
cap_swap c a c' b
\<lbrace>\<lambda>rv. valid_arch_caps :: 'state_ext state \<Rightarrow> bool\<rbrace>"
apply (simp add: cap_swap_def)
apply (rule hoare_pre)
apply (subst bind_assoc[symmetric],
rule hoare_seq_ext [rotated],
rule swap_of_caps_valid_arch_caps)
apply (wp | simp split del: if_split)+
done
end
crunch v_ker_map[wp]: cap_swap "valid_kernel_mappings"
crunch eq_ker_map[wp]: cap_swap "equal_kernel_mappings"
crunch only_idle [wp]: cap_swap only_idle
crunch pspace_in_kernel_window[wp]: cap_swap "pspace_in_kernel_window"
lemma cap_swap_valid_ioc[wp]:
"\<lbrace>\<lambda>s. valid_ioc s \<and>
cte_wp_at (weak_derived c) p s \<and>
cte_wp_at (weak_derived c') p' s\<rbrace>
cap_swap c p c' p'
\<lbrace>\<lambda>_ s. valid_ioc s\<rbrace>"
apply (simp add: cap_swap_def valid_ioc_def cte_wp_at_caps_of_state)
apply (wp set_cdt_cos_ioc set_cap_caps_of_state2 | simp split del: if_split)+
apply (cases p, cases p')
apply fastforce
done
crunch machine_state[wp]: cap_swap "\<lambda>s. P(machine_state s)"
crunch valid_irq_states[wp]: cap_swap "valid_irq_states"
crunch pspace_respects_device_region[wp]: cap_swap pspace_respects_device_region
lemma cap_refs_respects_device_region_original_cap[wp]:
"cap_refs_respects_device_region
(s\<lparr>is_original_cap := ocp\<rparr>) = cap_refs_respects_device_region s"
by (simp add:cap_refs_respects_device_region_def)
context CNodeInv_AI begin
lemma cap_swap_cap_refs_respects_device_region[wp]:
"\<lbrace>cap_refs_respects_device_region and cte_wp_at (weak_derived c) a and cte_wp_at (weak_derived c') b\<rbrace>
cap_swap c a c' b \<lbrace>\<lambda>rv. cap_refs_respects_device_region\<rbrace>"
apply (simp add:cap_swap_def)
apply wp
apply (simp add: cap_refs_respects_device_region_def)
apply (rule hoare_strengthen_post[OF CSpace_AI.set_cdt_cap_refs_respects_device_region])
apply simp
apply wp+
apply (clarsimp simp add: cap_refs_respects_device_region_def cte_wp_at_caps_of_state
cap_range_respects_device_region_def
simp del: split_paired_All split_paired_Ex
| (wp hoare_vcg_all_lift hoare_vcg_imp_lift)+)+
apply (frule_tac x = a in spec)
apply (frule_tac x = b in spec)
apply (clarsimp simp: weak_derived_cap_range)
apply (intro conjI impI allI)
apply (simp add: weak_derived_cap_range weak_derived_cap_is_device)+
apply (rule ccontr)
apply simp
apply (rule disjI2)
apply (intro conjI impI)
apply (simp add: weak_derived_cap_range weak_derived_cap_is_device)+
apply (rule ccontr)
apply simp
apply (simp add: weak_derived_cap_range weak_derived_cap_is_device)+
apply (rule ccontr)
apply simp
apply (rule disjI2)
apply (rule ccontr)
apply (clarsimp simp add: weak_derived_cap_range weak_derived_cap_is_device)+
apply fastforce
done
lemma cap_swap_aobj_at:
"arch_obj_pred P' \<Longrightarrow>
\<lbrace>\<lambda>s. P (obj_at P' pd s)\<rbrace> cap_swap c (a, b) c' (aa, ba) \<lbrace>\<lambda>r s. P (obj_at P' pd s)\<rbrace>"
unfolding cap_swap_def set_cdt_def by (wpsimp wp: set_cap.aobj_at)
lemma cap_swap_invs[wp]:
"\<And>c' a c b.
\<lbrace>invs and ex_cte_cap_wp_to (appropriate_cte_cap c') a
and ex_cte_cap_wp_to (appropriate_cte_cap c) b and
valid_cap c and valid_cap c' and
tcb_cap_valid c b and tcb_cap_valid c' a and
cte_wp_at (weak_derived c) a and
cte_wp_at (\<lambda>cc. is_untyped_cap cc \<longrightarrow> cc = c) a and
cte_wp_at (weak_derived c') b and
cte_wp_at (\<lambda>cc. is_untyped_cap cc \<longrightarrow> cc = c') b and
K (a \<noteq> b \<and> \<not> is_master_reply_cap c \<and> \<not> is_master_reply_cap c')\<rbrace>
cap_swap c a c' b \<lbrace>\<lambda>rv. invs :: 'state_ext state \<Rightarrow> bool\<rbrace>"
unfolding invs_def valid_state_def valid_pspace_def
apply (wp cap_swap_replies cap_swap_reply_masters valid_arch_state_lift_aobj_at
cap_swap_typ_at valid_irq_node_typ cap_swap_aobj_at
| simp
| erule disjE
| clarsimp simp: cte_wp_at_caps_of_state copy_of_cte_refs weak_derived_def
copy_obj_refs copy_of_zobj_refs copy_of_is_zombie
copy_of_cap_irqs gen_obj_refs_eq copy_of_arch_gen_obj_refs
| clarsimp simp: valid_global_refs_def valid_refs_def copy_of_cap_range
cte_wp_at_caps_of_state
simp del: split_paired_Ex split_paired_All
| rule conjI
| clarsimp dest!: valid_reply_caps_of_stateD)+
done
lemma cap_swap_fd_invs[wp]:
"\<And>a b.
\<lbrace>invs and ex_cte_cap_wp_to (\<lambda>cp. cap_irqs cp = {}) a
and ex_cte_cap_wp_to (\<lambda>cp. cap_irqs cp = {}) b
and (\<lambda>s. \<forall>c. tcb_cap_valid c a s)
and (\<lambda>s. \<forall>c. tcb_cap_valid c b s)
and cte_wp_at (\<lambda>c. \<not> is_master_reply_cap c) a
and cte_wp_at (\<lambda>c. \<not> is_master_reply_cap c) b\<rbrace>
cap_swap_for_delete a b \<lbrace>\<lambda>rv. invs :: 'state_ext state \<Rightarrow> bool\<rbrace>"
apply (simp add: cap_swap_for_delete_def)
apply (wp get_cap_wp)
apply (clarsimp)
apply (strengthen cap_irqs_appropriate_strengthen, simp)
apply (rule conjI, fastforce dest: cte_wp_at_valid_objs_valid_cap)
apply (rule conjI, fastforce dest: cte_wp_at_valid_objs_valid_cap)
apply (clarsimp simp: cte_wp_at_caps_of_state weak_derived_def)
done
end
lemma final_cap_unchanged:
assumes x: "\<And>P p. \<lbrace>cte_wp_at P p\<rbrace> f \<lbrace>\<lambda>rv. cte_wp_at P p\<rbrace>"
assumes y: "\<And>P T p. \<lbrace>\<lambda>s. P (typ_at T p s)\<rbrace> f \<lbrace>\<lambda>rv s. P (typ_at T p s)\<rbrace>"
shows "\<lbrace>is_final_cap' cap\<rbrace> f \<lbrace>\<lambda>rv. is_final_cap' cap\<rbrace>"
apply (simp only: is_final_cap'_def3 imp_conv_disj de_Morgan_conj)
apply (wp hoare_vcg_ex_lift hoare_vcg_all_lift x hoare_vcg_disj_lift
valid_cte_at_neg_typ [OF y])
done
lemmas set_cap_cte_wp_at_cases = set_cap_cte_wp_at[simplified if_bool_eq_conj pred_conj_def conj_comms]
lemma cyclic_zombieD[dest!]:
"cap_cyclic_zombie cap sl
\<Longrightarrow> \<exists>p zb n. cap = cap.Zombie p zb n
\<and> sl = (p, replicate (zombie_cte_bits zb) False)"
by (cases cap, simp_all add: cap_cyclic_zombie_def)
context CNodeInv_AI begin
lemma rec_del_abort_cases:
"\<And>args (s::'state_ext state).
case args of FinaliseSlotCall sl ex \<Rightarrow> s \<turnstile> \<lbrace>\<top>\<rbrace>
rec_del (FinaliseSlotCall sl ex)
\<lbrace>\<lambda>rv s. (fst rv) \<or> (\<not> ex \<and> cte_wp_at (\<lambda>c. is_zombie c \<and> sl \<in> fst_cte_ptrs c) sl s)\<rbrace>,\<lbrace>\<top>\<top>\<rbrace>
| _ \<Rightarrow> True"
subgoal for args s
proof (induct rule: rec_del_induct)
case (2 slot exposed)
note wp = "2.hyps"[simplified rec_del_call.simps]
show ?case
apply (subst rec_del_simps_ext)
apply (simp only: rec_del_call.simps split_def)
apply wp
apply (simp add: cte_wp_at_caps_of_state)
apply (wp wp)+
apply (wp irq_state_independent_AI | simp)+
apply (rule hoare_strengthen_post)
apply (rule finalise_cap_cases[where slot=slot])
apply clarsimp
apply (fastforce simp: fst_cte_ptrs_def)
apply (simp add: is_final_cap_def | wp get_cap_wp)+
done
qed (simp_all add: rec_del_fails)
done
lemma rec_del_delete_cases:
"\<And>sl ex.
\<lbrace>\<top> :: 'state_ext state \<Rightarrow> bool\<rbrace>
rec_del (CTEDeleteCall sl ex)
\<lbrace>\<lambda>rv s. cte_wp_at (\<lambda>c. c = cap.NullCap \<or> \<not> ex \<and> is_zombie c \<and> sl \<in> fst_cte_ptrs c) sl s\<rbrace>,-"
subgoal for sl ex
using rec_del_abort_cases [where args="FinaliseSlotCall sl ex"]
apply (subst rec_del_simps_ext, simp add: split_def)
apply wp
apply (rule hoare_strengthen_post [OF empty_slot_deletes])
apply (clarsimp simp: cte_wp_at_caps_of_state)
apply (rule use_spec, rule spec_strengthen_postE, assumption)
apply (clarsimp simp: cte_wp_at_caps_of_state)
apply assumption
done
done
lemma cap_delete_deletes:
notes hoare_pre [wp_pre del]
shows
"\<And>p.
\<lbrace>\<top> :: 'state_ext state \<Rightarrow> bool\<rbrace>
cap_delete p
\<lbrace>\<lambda>rv. cte_wp_at (\<lambda>c. c = cap.NullCap) p\<rbrace>,-"
subgoal for p
unfolding cap_delete_def
using rec_del_delete_cases[where sl=p and ex=True]
apply (simp add: validE_R_def)
apply wp
apply simp
done
done
end
lemma final_cap_same_objrefs:
"\<lbrace>is_final_cap' cap and
cte_wp_at (\<lambda>c. obj_refs cap \<inter> obj_refs c \<noteq> {}
\<or> cap_irqs cap \<inter> cap_irqs c \<noteq> {}
\<or> arch_gen_refs cap \<inter>
arch_gen_refs c \<noteq> {}) ptr\<rbrace>
set_cap cap ptr \<lbrace>\<lambda>rv. is_final_cap' cap\<rbrace>"
apply (simp only: is_final_cap'_def3 pred_conj_def
cte_wp_at_caps_of_state)
apply wp
apply (clarsimp simp del: split_paired_Ex split_paired_All)
apply (rule_tac x=ptr in exI)
apply (subgoal_tac "(a, b) = ptr")
apply clarsimp
apply (erule_tac x="ptr" in allE)
apply (fastforce simp: gen_obj_refs_Int)
done
lemma cte_wp_at_weakenE_customised:
"\<lbrakk>cte_wp_at P t s; \<And>c. \<lbrakk> P c; cte_wp_at ((=) c) t s \<rbrakk> \<Longrightarrow> P' c\<rbrakk> \<Longrightarrow> cte_wp_at P' t s"
by (clarsimp simp: cte_wp_at_def)
lemma final_cap_at_same_objrefs:
"\<lbrace>\<lambda>s. cte_wp_at (\<lambda>c. obj_refs c \<noteq> {} \<and> is_final_cap' c s) p s
\<and> cte_wp_at (\<lambda>c. gen_obj_refs cap = gen_obj_refs c) ptr s \<and> p \<noteq> ptr\<rbrace>
set_cap cap ptr \<lbrace>\<lambda>rv s. cte_wp_at (\<lambda>c. is_final_cap' c s) p s\<rbrace>"
apply (simp only: final_cap_at_eq cte_wp_at_conj)
apply (simp add: cte_wp_at_caps_of_state)
apply wp
apply (clarsimp simp del: split_paired_All split_paired_Ex
simp: gen_obj_refs_Int gen_obj_refs_empty gen_obj_refs_eq)
apply fastforce
done
lemma cap_swap_fd_final_cap_at_one_case:
"\<lbrace>\<lambda>s. p \<noteq> p'' \<and> ((p = p') \<longrightarrow> cte_wp_at (\<lambda>c. is_final_cap' c s) p'' s)
\<and> ((p \<noteq> p') \<longrightarrow> cte_wp_at (\<lambda>c. is_final_cap' c s) p s)\<rbrace>
cap_swap_for_delete p' p''
\<lbrace>\<lambda>rv s. cte_wp_at (\<lambda>c. is_final_cap' c s) p s\<rbrace>"
apply (simp only: final_cap_at_eq cte_wp_at_conj)
apply (simp add: cte_wp_at_caps_of_state)
apply wp
apply (cases "p = p'")
apply (cases p', clarsimp)
apply clarsimp
apply (cases p', cases p'', clarsimp)
done
lemma cap_swap_fd_cte_wp_at_one_case:
"\<lbrace>\<lambda>s. p \<noteq> p'' \<and> ((p = p') \<longrightarrow> cte_wp_at P p'' s) \<and> ((p \<noteq> p') \<longrightarrow> cte_wp_at P p s)\<rbrace>
cap_swap_for_delete p' p''
\<lbrace>\<lambda>rv s. cte_wp_at P p s\<rbrace>"
apply (simp add: cte_wp_at_caps_of_state)
apply wp
apply clarsimp
done
lemma valid_cte_wp_at_prop:
assumes x: "\<And>P p. \<lbrace>cte_wp_at P p\<rbrace> f \<lbrace>\<lambda>rv. cte_wp_at P p\<rbrace>"
assumes y: "\<And>P T p. \<lbrace>\<lambda>s. P (typ_at T p s)\<rbrace> f \<lbrace>\<lambda>rv s. P (typ_at T p s)\<rbrace>"
shows "\<lbrace>\<lambda>s. P' (cte_wp_at P p s)\<rbrace> f \<lbrace>\<lambda>rv s. P' (cte_wp_at P p s)\<rbrace>"
proof -
have cte_wp_at_neg2:
"\<And>P p s. (\<not> cte_wp_at P p s) = (\<not> cte_at p s \<or> cte_wp_at (\<lambda>c. \<not> P c) p s)"
by (fastforce simp: cte_wp_at_def)
have rev_iffI:
"\<And>P Q. \<lbrakk> P \<Longrightarrow> Q; \<not> P \<Longrightarrow> \<not> Q \<rbrakk> \<Longrightarrow> P = Q"
by fastforce
show ?thesis
apply (clarsimp simp: valid_def elim!: rsubst[where P=P'])
apply (rule rev_iffI)
apply (erule(1) use_valid [OF _ x])
apply (subst cte_wp_at_neg2)
apply (erule use_valid)
apply (wp hoare_vcg_disj_lift x y valid_cte_at_neg_typ)
apply (simp only: cte_wp_at_neg2[symmetric] simp_thms)
done
qed
lemma final_cap_at_unchanged:
assumes x: "\<And>P p. \<lbrace>cte_wp_at (\<lambda>c. P (gen_obj_refs c)) p\<rbrace> f
\<lbrace>\<lambda>rv. cte_wp_at (\<lambda>c. P (gen_obj_refs c)) p\<rbrace>"
assumes y: "\<And>P T p. \<lbrace>\<lambda>s. P (typ_at T p s)\<rbrace> f \<lbrace>\<lambda>rv s. P (typ_at T p s)\<rbrace>"
shows "\<lbrace>\<lambda>s. cte_wp_at (\<lambda>c. is_final_cap' c s) p s\<rbrace> f
\<lbrace>\<lambda>rv s. cte_wp_at (\<lambda>c. is_final_cap' c s) p s\<rbrace>"
proof -
have final_cap_at_eq':
"\<And>p s. cte_wp_at (\<lambda>c. is_final_cap' c s) p s =
(\<exists>cp. cte_wp_at (\<lambda>c. gen_obj_refs c = gen_obj_refs cp) p s
\<and> (obj_refs cp \<noteq> {} \<or> cap_irqs cp \<noteq> {} \<or> arch_gen_refs cp \<noteq> {})
\<and> (\<forall>p'. (cte_at p' s \<and> p' \<noteq> p) \<longrightarrow>
cte_wp_at (\<lambda>c. gen_obj_refs cp \<inter> gen_obj_refs c = {}) p' s))"
apply (simp add: final_cap_at_eq cte_wp_at_def)
apply (rule iffI)
apply (clarsimp simp: gen_obj_refs_Int gen_obj_refs_empty gen_obj_refs_eq)
apply (rule exI, rule conjI, rule refl)
apply clarsimp
apply (clarsimp simp: gen_obj_refs_Int gen_obj_refs_empty gen_obj_refs_eq)
done
show ?thesis
apply (simp only: final_cap_at_eq' imp_conv_disj de_Morgan_conj)
apply (wp hoare_vcg_ex_lift hoare_vcg_all_lift x hoare_vcg_disj_lift
valid_cte_at_neg_typ y)
done
qed
lemma zombie_has_objrefs:
"is_zombie c \<Longrightarrow> obj_refs c \<noteq> {}"
by (case_tac c, simp_all add: is_zombie_def)
lemma word_same_bl_memo_unify_word_type:
"\<lbrakk> of_bl xs = (of_bl ys :: ('a :: len) word); length xs = length ys;
length xs \<le> len_of TYPE('a) \<rbrakk> \<Longrightarrow> xs = ys"
apply (subst same_append_eq[symmetric])
apply (rule word_bl.Abs_eqD)
apply (subst of_bl_rep_False)+
apply simp
apply simp
apply (erule le_add_diff_inverse2)
apply simp
done
lemma word_and_bl_proof:
"\<lbrakk> invs s; kheap s x = Some (CNode sz cs);
unat (of_bl y :: machine_word) = 0; unat (of_bl z :: machine_word) = 0;
y \<in> dom cs; z \<in> dom cs \<rbrakk> \<Longrightarrow> y = z"
apply (simp add: unat_eq_0)
apply (frule invs_valid_objs, erule(1) valid_objsE)
apply (clarsimp simp: valid_obj_def valid_cs_def
valid_cs_size_def well_formed_cnode_n_def)
apply (rule word_same_bl_memo_unify_word_type[where 'a=machine_word_len])
apply simp
apply simp
apply (simp add: word_bits_def)
done
lemma final_zombie_not_live:
"\<lbrakk> is_final_cap' (cap.Zombie ptr b n) s; cte_wp_at ((=) (cap.Zombie ptr b n)) p s;
if_live_then_nonz_cap s \<rbrakk>
\<Longrightarrow> \<not> obj_at live ptr s"
apply clarsimp
apply (drule(1) if_live_then_nonz_capD, simp)
apply (clarsimp simp: ex_nonz_cap_to_def zobj_refs_to_obj_refs)
apply (subgoal_tac "(a, ba) \<noteq> p")
apply (clarsimp simp: is_final_cap'_def)
apply (erule(1) obvious)
apply (clarsimp simp: cte_wp_at_def is_zombie_def gen_obj_refs_Int)+
done
lemma suspend_ex_cte_cap[wp]:
"\<lbrace>ex_cte_cap_wp_to P p\<rbrace> IpcCancel_A.suspend t \<lbrace>\<lambda>rv. ex_cte_cap_wp_to P p\<rbrace>"
apply (simp add: ex_cte_cap_wp_to_def cte_wp_at_caps_of_state
del: split_paired_Ex)
apply (wp hoare_use_eq_irq_node [OF suspend_irq_node suspend_caps_of_state])
apply (simp del: split_paired_Ex split_paired_All)
apply (intro allI impI, erule exEI)
apply (clarsimp simp: cte_wp_at_caps_of_state)
apply (clarsimp simp: can_fast_finalise_def
split: cap.split_asm)
done
lemma of_bl_eq_0:
"\<lbrakk> of_bl xs = (0 :: ('a :: len) word); length xs \<le> len_of TYPE('a) \<rbrakk>
\<Longrightarrow> \<exists>n. xs = replicate n False"
apply (rule exI)
apply (rule word_same_bl_memo_unify_word_type[where 'a='a]; simp)
done
context CNodeInv_AI begin
lemma zombie_is_cap_toE:
"\<And>ptr zbits n p (s::'state_ext state) m P.
\<lbrakk> cte_wp_at ((=) (Zombie ptr zbits n)) p s; invs s; m < n; P (Zombie ptr zbits n) \<rbrakk>
\<Longrightarrow> ex_cte_cap_wp_to P (ptr, nat_to_cref (zombie_cte_bits zbits) m) s"
unfolding ex_cte_cap_wp_to_def
apply (frule cte_wp_at_valid_objs_valid_cap, clarsimp)
apply (intro exI, erule cte_wp_at_weakenE)
apply clarsimp
apply (drule(2) zombie_is_cap_toE_pre, simp)
done
end
lemma zombie_is_cap_toE2:
"\<lbrakk> cte_wp_at ((=) (cap.Zombie ptr zbits n)) p s; 0 < n;
P (cap.Zombie ptr zbits n) \<rbrakk>
\<Longrightarrow> ex_cte_cap_wp_to P (ptr, replicate (zombie_cte_bits zbits) False) s"
unfolding ex_cte_cap_wp_to_def
apply (rule exI, erule cte_wp_at_weakenE)
apply clarsimp
done
lemma set_cap_emptyable[wp]:
"\<not> is_master_reply_cap cap \<Longrightarrow>
\<lbrace>emptyable sl and cte_at p\<rbrace> set_cap cap p \<lbrace>\<lambda>rv. emptyable sl\<rbrace>"
apply (simp add: emptyable_def)
apply (subst imp_conv_disj)+
apply (wp hoare_vcg_disj_lift set_cap_typ_at set_cap_cte_wp_at
| simp add: tcb_at_typ)+
done
lemma set_cap_halted_if_tcb[wp]:
"\<lbrace>halted_if_tcb t\<rbrace> set_cap cap p \<lbrace>\<lambda>rv. halted_if_tcb t\<rbrace>"
apply (simp add: halted_if_tcb_def)
apply (subst imp_conv_disj)+
apply (wp hoare_vcg_disj_lift set_cap_typ_at | simp add: tcb_at_typ)+
done
lemma valid_Zombie_n_less_cte_bits:
"s \<turnstile> cap.Zombie p zb n \<Longrightarrow> n \<le> 2 ^ zombie_cte_bits zb"
by (clarsimp simp: valid_cap_def split: option.split_asm)
lemma zombie_cte_bits_less:
"s \<turnstile> cap.Zombie p zb m \<Longrightarrow> zombie_cte_bits zb < word_bits"
by (clarsimp simp: valid_cap_def cap_aligned_def
split: option.split_asm)
context CNodeInv_AI begin
lemma nat_to_cref_replicate_Zombie:
"\<And>zb n (s::'state_ext state) p m.
\<lbrakk> nat_to_cref (zombie_cte_bits zb) n = replicate (zombie_cte_bits zb) False;
s \<turnstile> cap.Zombie p zb m; n < m \<rbrakk>
\<Longrightarrow> n = 0"
apply (subgoal_tac "unat (of_bl (nat_to_cref (zombie_cte_bits zb) n)) = 0")
apply (subst(asm) unat_of_bl_nat_to_cref)
apply (drule valid_Zombie_n_less_cte_bits, simp)
apply (erule zombie_cte_bits_less)
apply simp
apply simp
done
end
lemma replicate_False_tcb_valid[simp]:
"tcb_cap_valid cap (p, replicate n False) s"
apply (clarsimp simp: tcb_cap_valid_def st_tcb_def2 tcb_at_def)
apply (rule conjI)
apply (clarsimp split: option.split)
apply (frule tcb_cap_cases_length[OF domI])
apply (clarsimp simp add: tcb_cap_cases_def tcb_cnode_index_def to_bl_1)
apply (cases n, simp_all add: tcb_cnode_index_def)
done
lemma tcb_valid_nonspecial_cap:
"\<lbrakk> caps_of_state s p = Some cap; valid_objs s;
\<forall>ptr st. \<forall>(getF, setF, restr) \<in> ran tcb_cap_cases.
\<not> restr ptr st cap \<or> (\<forall>cap. restr ptr st cap);
\<forall>ptr. (is_nondevice_page_cap cap \<or> cap = cap.NullCap) \<and>
valid_ipc_buffer_cap cap ptr
\<longrightarrow> valid_ipc_buffer_cap cap' ptr \<rbrakk>
\<Longrightarrow> tcb_cap_valid cap' p s"
apply (drule cte_wp_tcb_cap_valid[rotated])
apply (erule caps_of_state_cteD)
apply (clarsimp simp: tcb_cap_valid_def st_tcb_def2)
apply (clarsimp split: option.split_asm)
apply (rule conjI)
apply (drule spec, drule spec, drule bspec, erule ranI)
apply fastforce
apply (clarsimp simp: eq_commute)
done
lemma suspend_makes_halted[wp]:
"\<lbrace>valid_objs\<rbrace> IpcCancel_A.suspend thread \<lbrace>\<lambda>_. st_tcb_at halted thread\<rbrace>"
unfolding IpcCancel_A.suspend_def
by (wp hoare_strengthen_post [OF sts_st_tcb_at]
| clarsimp elim!: pred_tcb_weakenE)+
lemma empty_slot_emptyable[wp]:
"\<lbrace>emptyable sl and cte_at slot'\<rbrace> empty_slot slot' opt \<lbrace>\<lambda>rv. emptyable sl\<rbrace>"
apply (rule hoare_assume_pre)
apply (rule hoare_weaken_pre)
apply (simp add: emptyable_def)
apply (subst imp_conv_disj)+
apply (wp hoare_vcg_disj_lift | simp add: tcb_at_typ)+
apply (simp add: is_cap_simps emptyable_def tcb_at_typ)
done
crunch emptyable[wp]: blocked_cancel_ipc "emptyable sl"
(ignore: set_thread_state wp: emptyable_lift sts_st_tcb_at_cases static_imp_wp)
crunch emptyable[wp]: cancel_signal "emptyable sl"
(ignore: set_thread_state wp: emptyable_lift sts_st_tcb_at_cases static_imp_wp)
lemma cap_delete_one_emptyable[wp]:
"\<lbrace>invs and emptyable sl and cte_at sl'\<rbrace> cap_delete_one sl' \<lbrace>\<lambda>_. emptyable sl\<rbrace>"
apply (simp add: cap_delete_one_def unless_def is_final_cap_def)
apply (wpsimp wp: get_cap_wp)
done
lemmas tcb_at_cte_at_2 = tcb_at_cte_at [where ref="tcb_cnode_index 2",
simplified dom_tcb_cap_cases]
declare thread_set_Pmdb [wp]
lemma reply_cancel_ipc_emptyable[wp]:
"\<lbrace>invs and emptyable sl and valid_mdb\<rbrace> reply_cancel_ipc ptr \<lbrace>\<lambda>_. emptyable sl\<rbrace>"
apply (simp add: reply_cancel_ipc_def)
apply (wp select_wp select_inv hoare_drop_imps | simp add: Ball_def)+
apply (wp hoare_vcg_all_lift hoare_convert_imp thread_set_Pmdb
thread_set_invs_trivial thread_set_emptyable thread_set_cte_at
| simp add: tcb_cap_cases_def descendants_of_cte_at)+
done
crunch emptyable[wp]: cancel_ipc "emptyable sl"
crunch emptyable[wp]: update_restart_pc "emptyable sl"
(rule: emptyable_lift)
lemma suspend_emptyable[wp]:
"\<lbrace>invs and emptyable sl and valid_mdb\<rbrace> suspend l \<lbrace>\<lambda>_. emptyable sl\<rbrace>"
apply (simp add: IpcCancel_A.suspend_def)
apply (wp|simp)+
apply (wp emptyable_lift sts_st_tcb_at_cases)+
apply (wpsimp wp: set_thread_state_cte_wp_at)+
done
crunch emptyable[wp]: do_machine_op "emptyable sl"
(rule: emptyable_lift)
crunch emptyable[wp]: set_irq_state "emptyable sl"
(rule: emptyable_lift)
declare get_irq_slot_real_cte [wp]
lemma cap_swap_for_delete_emptyable[wp]:
"\<lbrace>emptyable sl and emptyable sl'\<rbrace> cap_swap_for_delete sl' sl \<lbrace>\<lambda>rv. emptyable sl\<rbrace>"
apply (simp add: emptyable_def cap_swap_for_delete_def cap_swap_def tcb_at_typ)
apply (rule hoare_pre)
apply (subst imp_conv_disj)+
apply (wp hoare_vcg_disj_lift set_cdt_typ_at set_cap_typ_at | simp split del: if_split)+
done
context CNodeInv_AI begin
lemma finalise_cap_not_reply_master:
"\<And>rv s' cap sl (s::'state_ext state).
(Inr rv, s') \<in> fst (liftE (finalise_cap cap sl) s) \<Longrightarrow> \<not> is_master_reply_cap (fst rv)"
by (simp add: Inr_in_liftE_simp finalise_cap_not_reply_master_unlifted)
end
crunch cte_at_pres[wp]: empty_slot "cte_at sl"
lemma cte_wp_at_emptyableD:
"\<And>P. \<lbrakk> cte_wp_at (\<lambda>c. c = cap) p s; valid_objs s; \<And>cap. P cap \<Longrightarrow> \<not> is_master_reply_cap cap \<rbrakk> \<Longrightarrow>
P cap \<longrightarrow> emptyable p s"
apply (simp add: emptyable_def)
apply (clarsimp simp add: obj_at_def is_tcb)
apply (erule(1) valid_objsE)
apply (clarsimp simp: cte_wp_at_cases valid_obj_def valid_tcb_def
tcb_cap_cases_def pred_tcb_at_def obj_at_def
split: Structures_A.thread_state.splits)
done
lemma cte_wp_at_not_reply_master:
"\<And>a b s. \<lbrakk> tcb_at a s \<longrightarrow> b \<noteq> tcb_cnode_index 2; cte_at (a, b) s;
valid_objs s; valid_reply_masters s \<rbrakk>
\<Longrightarrow> cte_wp_at (\<lambda>c. \<not> is_master_reply_cap c) (a, b) s"
by (fastforce simp: valid_reply_masters_def cte_wp_at_caps_of_state
is_cap_simps valid_cap_def is_master_reply_cap_to_def
dest: caps_of_state_valid_cap)
declare finalise_cap_cte_cap_to [wp]
lemma appropriate_Zombie:
"\<And>ptr zbits n. appropriate_cte_cap (cap.Zombie ptr zbits n)
= (\<lambda>cap. cap_irqs cap = {})"
by (rule ext, simp add: appropriate_cte_cap_def)
lemma no_cap_to_obj_with_diff_ref_eqE:
"\<lbrakk> no_cap_to_obj_with_diff_ref cap S s;
obj_refs cap' = obj_refs cap; table_cap_ref cap' = table_cap_ref cap;
S \<subseteq> S' \<rbrakk>
\<Longrightarrow> no_cap_to_obj_with_diff_ref cap' S' s"
by (auto simp add: no_cap_to_obj_with_diff_ref_def Ball_def)
lemma context_conjI': "\<lbrakk>P; P \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q \<and> P"
apply simp
done
lemma real_cte_at_not_tcb:
"real_cte_at sl s \<Longrightarrow> \<not> tcb_at (fst sl) s"
apply (simp add: tcb_at_typ obj_at_def)
apply (clarsimp simp: is_cap_table_def)
done
context CNodeInv_AI_2 begin
lemma rec_del_invs:
"\<And>args.
\<lbrace>invs and valid_rec_del_call args
and (\<lambda>s. \<not> exposed_rdcall args
\<longrightarrow> ex_cte_cap_wp_to (\<lambda>cp. cap_irqs cp = {}) (slot_rdcall args) s)
and emptyable (slot_rdcall args)
and (\<lambda>s. case args of ReduceZombieCall cap sl ex \<Rightarrow>
\<not> cap_removeable cap sl
\<and> (\<forall>t\<in>obj_refs cap. halted_if_tcb t s)
| _ \<Rightarrow> True)\<rbrace>
rec_del args
\<lbrace>\<lambda>rv. invs :: 'state_ext state \<Rightarrow> bool\<rbrace>"
apply (rule validE_valid)
apply (rule hoare_post_impErr)
apply (rule hoare_pre)
apply (rule use_spec)
apply (rule rec_del_invs')
apply simp+
done
lemma cap_delete_invs[wp]:
"\<And>ptr.
\<lbrace>invs and emptyable ptr :: 'state_ext state \<Rightarrow> bool\<rbrace>
cap_delete ptr
\<lbrace>\<lambda>rv. invs\<rbrace>"
unfolding cap_delete_def
apply (rule hoare_pre, wp rec_del_invs)
apply simp
done
lemma cap_delete_tcb[wp]:
"\<And>t ptr. \<lbrace>tcb_at t :: 'state_ext state \<Rightarrow> bool\<rbrace> cap_delete ptr \<lbrace>\<lambda>rv. tcb_at t\<rbrace>"
unfolding cap_delete_def
by (simp add: tcb_at_typ | wp rec_del_typ_at)+
lemma cap_delete_valid_cap:
"\<And>c p. \<lbrace>valid_cap c :: 'state_ext state \<Rightarrow> bool\<rbrace> cap_delete p \<lbrace>\<lambda>_. valid_cap c\<rbrace>"
unfolding cap_delete_def
by (wp valid_cap_typ rec_del_typ_at | simp)+
lemma cap_delete_cte_at:
"\<And>c p. \<lbrace>cte_at c :: 'state_ext state \<Rightarrow> bool\<rbrace> cap_delete p \<lbrace>\<lambda>_. cte_at c\<rbrace>"
unfolding cap_delete_def by (wp rec_del_cte_at | simp)+
lemma cap_delete_typ_at:
"\<And>P T p cref. \<lbrace>\<lambda>s::'state_ext state. P (typ_at T p s)\<rbrace> cap_delete cref \<lbrace>\<lambda>rv s. P (typ_at T p s)\<rbrace>"
unfolding cap_delete_def by (wp rec_del_typ_at | simp)+
end
lemma cap_swap_fd_st_tcb_at[wp]:
"\<lbrace>pred_tcb_at proj P t\<rbrace> cap_swap_for_delete sl sl' \<lbrace>\<lambda>rv. pred_tcb_at proj P t\<rbrace>"
unfolding cap_swap_for_delete_def
by (wp, simp)
declare if_cong[cong]
lemma cases2 [case_names pos_pos neg_pos pos_neg neg_neg]:
"\<lbrakk> \<lbrakk>p; q\<rbrakk> \<Longrightarrow> R; \<lbrakk>\<not> p; q\<rbrakk> \<Longrightarrow> R; \<lbrakk>p; \<not> q\<rbrakk> \<Longrightarrow> R; \<lbrakk>\<not> p; \<not> q\<rbrakk> \<Longrightarrow> R \<rbrakk> \<Longrightarrow> R"
by auto
definition
rpo_measure :: "'a \<Rightarrow> ('a option \<times> nat) option \<Rightarrow> nat"
where
"rpo_measure x v \<equiv> case v of Some (y, n) \<Rightarrow> (if y = Some x then n - 1 else n)"
lemma rpo_measure_simps[simp]:
"rpo_measure x (Some (y, n)) = (if y = Some x then n - 1 else n)"
by (simp add: rpo_measure_def)
definition
revoke_progress_ord :: "('a \<rightharpoonup> 'a option \<times> nat) \<Rightarrow> ('a \<rightharpoonup> 'a option \<times> nat) \<Rightarrow> bool"
where
"revoke_progress_ord mapa mapb \<equiv> (mapa = mapb)
\<or> (mapb, mapa) \<in> measure (\<lambda>mp. \<Sum>x\<in>dom mp. rpo_measure x (mp x))"
lemma rpo_trans:
"\<lbrakk> revoke_progress_ord mapa mapb; revoke_progress_ord mapb mapc \<rbrakk>
\<Longrightarrow> revoke_progress_ord mapa mapc"
apply (simp add: revoke_progress_ord_def)
apply (elim disjE, simp_all)
done
interpretation mult_is_add: comm_monoid_mult "(+)" "0::'a::comm_monoid_add"
by (unfold_locales) (auto simp: field_simps)
lemma fold_Int_sub:
assumes "finite S" "finite T"
shows "(\<Sum>x \<in> (S \<inter> T). (f x :: nat)) = (\<Sum>x \<in> T. f x) - (\<Sum>x \<in> (T - S). f x)"
proof -
from assms sum.union_disjoint[where A="S \<inter> T" and B="T - S" and g=f]
show ?thesis
apply simp
apply (drule meta_mp)
apply blast
apply (subgoal_tac "S \<inter> T \<union> (T - S) = T")
apply simp
apply blast
done
qed
lemma rpo_delta:
assumes x: "\<And>x. x \<notin> S \<Longrightarrow> mapa x = mapb x"
assumes F: "finite S" "finite (dom mapa)" "finite (dom mapb)"
assumes y:
"(mapb, mapa) \<in> measure (\<lambda>mp. \<Sum>x \<in> S \<inter> dom mp. rpo_measure x (mp x))"
shows "revoke_progress_ord mapa mapb"
proof -
have P: "(dom mapa - S) = (dom mapb - S)"
by (fastforce simp: x)
have Q: "(\<Sum>x \<in> dom mapa - S. rpo_measure x (mapa x))
= (\<Sum>x \<in> dom mapb - S. rpo_measure x (mapb x))"
apply (rule sum.cong)
apply (simp add: P)
apply (simp add: x)
done
show ?thesis using y
apply (simp add: revoke_progress_ord_def)
apply (rule disjI2)
apply (fastforce simp: fold_Int_sub F Q)
done
qed
definition
cap_to_rpo :: "cap \<Rightarrow> cslot_ptr option \<times> nat"
where
"cap_to_rpo cap \<equiv> case cap of
cap.NullCap \<Rightarrow> (None, 0)
| cap.Zombie p zb n \<Rightarrow> (Some (p, replicate (zombie_cte_bits zb) False), 2)
| _ \<Rightarrow> (None, 3)"
lemmas caps_of_state_set_finite'
= cte_wp_at_set_finite[simplified cte_wp_at_caps_of_state]
lemmas caps_of_state_set_finite
= caps_of_state_set_finite'
caps_of_state_set_finite'[where P="\<top>\<top>", simplified]
lemma empty_slot_rvk_prog:
"\<lbrace>\<lambda>s. revoke_progress_ord m (option_map cap_to_rpo \<circ> caps_of_state s)\<rbrace>
empty_slot sl opt
\<lbrace>\<lambda>rv s. revoke_progress_ord m (option_map cap_to_rpo \<circ> caps_of_state s)\<rbrace>"
apply (simp add: empty_slot_def)
apply (rule hoare_pre)
apply (wp opt_return_pres_lift | simp split del: if_split)+
apply (wp get_cap_wp)
apply (clarsimp simp: cte_wp_at_caps_of_state)
apply (erule rpo_trans)
apply (rule rpo_delta[where S="{sl}"],
simp_all add: dom_def caps_of_state_set_finite exception_set_finite)
apply (case_tac cap, simp_all add: cap_to_rpo_def)
done
lemma rvk_prog_update_strg:
"revoke_progress_ord m (option_map cap_to_rpo \<circ> caps_of_state s)
\<and> cte_wp_at (\<lambda>cp. cap_to_rpo cp = cap_to_rpo cap
\<or> rpo_measure p (Some (cap_to_rpo cp))
> rpo_measure p (Some (cap_to_rpo cap))) p s
\<longrightarrow> revoke_progress_ord m (option_map cap_to_rpo \<circ> ((caps_of_state s) (p \<mapsto> cap)))"
apply (clarsimp simp: cte_wp_at_caps_of_state)
apply (erule disjE)
apply (erule rsubst[where P="\<lambda>mp. revoke_progress_ord m mp"])
apply (rule ext, simp)
apply (erule rpo_trans)
apply (rule rpo_delta[where S="{p}"],
simp_all add: dom_def caps_of_state_set_finite)
apply (rule exception_set_finite)
apply (rule finite_subset [OF _ caps_of_state_set_finite(2)[where s=s]])
apply clarsimp
done
lemma cap_swap_fd_rvk_prog:
"\<lbrace>\<lambda>s. revoke_progress_ord m (option_map cap_to_rpo \<circ> caps_of_state s)
\<and> cte_wp_at (\<lambda>cp. cap_to_rpo cp = (Some p1, 2) \<and> is_final_cap' cp s) p2 s\<rbrace>
cap_swap_for_delete p1 p2
\<lbrace>\<lambda>rv s. revoke_progress_ord m (option_map cap_to_rpo \<circ> caps_of_state s)\<rbrace>"
apply (simp add: cap_swap_for_delete_def cap_swap_def)
apply (wp get_cap_wp | simp split del: if_split)+
apply (clarsimp simp: cte_wp_at_caps_of_state)
apply (erule rpo_trans)
apply (rule rpo_delta[where S="{p1, p2}"],
simp_all add: caps_of_state_set_finite exception_set_finite
dom_def)
apply (clarsimp simp: is_final_cap'_def2)
apply (frule spec[where x="fst p1"], drule spec[where x="snd p1"])
apply (drule spec[where x="fst p2"], drule spec[where x="snd p2"])
apply (clarsimp simp: cap_to_rpo_def split: cap.split_asm)
apply (simp split: cap.split)
apply (clarsimp simp: cte_wp_at_caps_of_state gen_obj_refs_empty)
apply (drule iffD1)
apply (simp add: gen_obj_refs_Int)
apply (simp only:)
apply simp
done
lemmas empty_slot_rvk_prog' = empty_slot_rvk_prog[unfolded o_def]
crunch rvk_prog: cancel_ipc "\<lambda>s. revoke_progress_ord m (\<lambda>x. option_map cap_to_rpo (caps_of_state s x))"
(simp: crunch_simps o_def unless_def is_final_cap_def tcb_cap_cases_def
wp: hoare_drop_imps empty_slot_rvk_prog' select_wp
thread_set_caps_of_state_trivial)
crunch rvk_prog: cancel_all_ipc "\<lambda>s. revoke_progress_ord m (\<lambda>x. option_map cap_to_rpo (caps_of_state s x))"
(simp: crunch_simps o_def unless_def is_final_cap_def
wp: crunch_wps empty_slot_rvk_prog' select_wp)
crunch rvk_prog: cancel_all_signals "\<lambda>s. revoke_progress_ord m (\<lambda>x. option_map cap_to_rpo (caps_of_state s x))"
(simp: crunch_simps o_def unless_def is_final_cap_def
wp: crunch_wps empty_slot_rvk_prog' select_wp)
crunch rvk_prog: suspend "\<lambda>s. revoke_progress_ord m (\<lambda>x. option_map cap_to_rpo (caps_of_state s x))"
(simp: crunch_simps o_def unless_def is_final_cap_def
wp: crunch_wps empty_slot_rvk_prog' select_wp)
crunch rvk_prog: deleting_irq_handler "\<lambda>s. revoke_progress_ord m (\<lambda>x. option_map cap_to_rpo (caps_of_state s x))"
(simp: crunch_simps o_def unless_def is_final_cap_def
wp: crunch_wps empty_slot_rvk_prog' select_wp)
locale CNodeInv_AI_3 = CNodeInv_AI_2 state_ext_t
for state_ext_t :: "'state_ext::state_ext itself" +
assumes finalise_cap_rvk_prog:
"\<And>a b.
\<lbrace>\<lambda>s::'state_ext state. revoke_progress_ord m (\<lambda>x. map_option cap_to_rpo (caps_of_state s x))\<rbrace>
finalise_cap a b
\<lbrace>\<lambda>_ s. revoke_progress_ord m (\<lambda>x. map_option cap_to_rpo (caps_of_state s x))\<rbrace>"
assumes rec_del_rvk_prog:
"\<And>(st::'state_ext state) args.
st \<turnstile> \<lbrace>\<lambda>s. revoke_progress_ord m (option_map cap_to_rpo \<circ> caps_of_state s)
\<and> (case args of ReduceZombieCall cap sl ex \<Rightarrow>
cte_wp_at (\<lambda>c. c = cap) sl s \<and> is_final_cap' cap s
| _ \<Rightarrow> True)\<rbrace>
rec_del args
\<lbrace>\<lambda>rv s. revoke_progress_ord m (option_map cap_to_rpo \<circ> caps_of_state s)\<rbrace>,\<lbrace>\<top>\<top>\<rbrace>"
lemmas rdcall_simps = rec_del_call.simps exposed_rdcall.simps slot_rdcall.simps
context CNodeInv_AI_3 begin
lemma cap_delete_rvk_prog:
"\<And>m ptr.
\<lbrace>\<lambda>s::'state_ext state. revoke_progress_ord m (option_map cap_to_rpo \<circ> caps_of_state s)\<rbrace>
cap_delete ptr
\<lbrace>\<lambda>rv s. revoke_progress_ord m (option_map cap_to_rpo \<circ> caps_of_state s)\<rbrace>,-"
unfolding cap_delete_def validE_R_def
apply wpsimp
apply (unfold validE_R_def)
apply (rule use_spec)
apply (rule rec_del_rvk_prog rec_del_rvk_prog[unfolded o_def])
apply (simp add: o_def)
done
end
lemma get_object_some: "kheap s ptr = Some ko \<Longrightarrow> get_object ptr s = ({(ko, s)}, False)"
by (clarsimp simp: get_object_def gets_def get_def bind_def assert_def return_def)
lemma set_cap_id:
"cte_wp_at ((=) c) p s \<Longrightarrow> set_cap c p s = ({((),s)}, False)"
apply (clarsimp simp: cte_wp_at_cases)
apply (cases p)
apply (erule disjE)
apply clarsimp
apply (simp add: set_cap_def get_object_def bind_assoc exec_gets)
apply (rule conjI)
apply (clarsimp simp: set_object_def)
apply (frule get_object_some)
apply (drule_tac t="fun" in map_upd_triv)
apply (clarsimp simp: bind_def get_def return_def put_def a_type_def)
apply (cases s)
apply simp
apply (rule ext, simp)
apply (clarsimp simp: get_object_def gets_def get_def bind_def assert_def return_def)
apply clarsimp
apply (simp add: set_cap_def get_object_def bind_assoc
exec_gets set_object_def exec_get put_def)
apply (clarsimp simp: tcb_cap_cases_def
split: if_split_asm,
simp_all add: map_upd_triv)
done
declare Inr_in_liftE_simp[simp]
lemma get_cap_fail_or_not:
"fst (get_cap slot s) \<noteq> {} \<Longrightarrow> snd (get_cap slot s) = False"
by (clarsimp elim!: nonemptyE dest!: get_cap_det)
function(sequential) red_zombie_will_fail :: "cap \<Rightarrow> bool"
where
"red_zombie_will_fail (cap.Zombie ptr zb 0) = True"
| "red_zombie_will_fail (cap.Zombie ptr zb (Suc n)) = False"
| "red_zombie_will_fail cap = True"
apply simp_all
apply (case_tac x)
prefer 11
apply (rename_tac nat)
apply (case_tac nat, simp_all)[1]
apply fastforce+
done
termination red_zombie_will_fail
by (rule red_zombie_will_fail.termination [OF Wellfounded.wf_empty])
context CNodeInv_AI_3 begin
lemma rec_del_emptyable:
"\<And>args.
\<lbrace>invs and valid_rec_del_call args
and (\<lambda>s. \<not> exposed_rdcall args
\<longrightarrow> ex_cte_cap_wp_to (\<lambda>cp. cap_irqs cp = {}) (slot_rdcall args) s)
and emptyable (slot_rdcall args)
and (\<lambda>s. case args of ReduceZombieCall cap sl ex \<Rightarrow>
\<not> cap_removeable cap sl
\<and> (\<forall>t\<in>obj_refs cap. halted_if_tcb t s)
| _ \<Rightarrow> True)\<rbrace>
rec_del args
\<lbrace>\<lambda>rv. emptyable (slot_rdcall args) :: 'state_ext state \<Rightarrow> bool\<rbrace>, -"
apply (rule validE_validE_R)
apply (rule hoare_post_impErr)
apply (rule hoare_pre)
apply (rule use_spec)
apply (rule rec_del_invs')
apply simp+
done
lemma reduce_zombie_cap_to:
"\<And>cap slot exp.
\<lbrace>invs and valid_rec_del_call (ReduceZombieCall cap slot exp) and
emptyable slot and
(\<lambda>s. \<not> exp \<longrightarrow> ex_cte_cap_wp_to (\<lambda>cp. cap_irqs cp = {}) slot s) and
K (\<not> cap_removeable cap slot) and
(\<lambda>s. \<forall>t\<in>obj_refs cap. halted_if_tcb t s)\<rbrace>
rec_del (ReduceZombieCall cap slot exp)
\<lbrace>\<lambda>rv (s::'state_ext state). \<not> exp \<longrightarrow> ex_cte_cap_wp_to (\<lambda>cp. cap_irqs cp = {}) slot s\<rbrace>, -"
apply (rule validE_validE_R)
apply (rule hoare_post_impErr)
apply (rule hoare_pre)
apply (rule use_spec)
apply (rule rec_del_invs')
apply simp+
done
lemma cte_at_replicate_zbits:
"\<And>(s::'state_ext state) oref zb n.
\<lbrakk> s \<turnstile> cap.Zombie oref zb n \<rbrakk> \<Longrightarrow> cte_at (oref, replicate (zombie_cte_bits zb) False) s"
apply (clarsimp simp: valid_cap_def obj_at_def is_tcb is_cap_table
split: option.split_asm)
apply (rule cte_wp_at_tcbI, simp)
apply (fastforce simp add: tcb_cap_cases_def tcb_cnode_index_def to_bl_1)
apply simp
apply (subgoal_tac "replicate x2 False \<in> dom cs")
apply safe[1]
apply (rule cte_wp_at_cteI, fastforce)
apply (simp add: well_formed_cnode_n_def length_set_helper)
apply simp
apply simp
apply (clarsimp simp: well_formed_cnode_n_def)
done
lemma reduce_zombie_cap_somewhere:
"\<And>exp cap slot.
\<lbrace>\<lambda>s::'state_ext state. \<not> exp \<longrightarrow> (\<exists>oref cref. cte_wp_at P (oref, cref) s)\<rbrace>
rec_del (ReduceZombieCall cap slot exp)
\<lbrace>\<lambda>rv s. \<not> exp \<longrightarrow> (\<exists>oref cref. cte_wp_at P (oref, cref) s)\<rbrace>"
subgoal for exp cap slot
apply (cases exp, simp_all, wp)
apply (cases cap, simp_all add: rec_del_fails)
apply (rename_tac word option nat)
apply (case_tac nat, simp_all add: rec_del_simps_ext)
apply (simp add: cte_wp_at_caps_of_state)
apply wp
apply safe
apply (rule_tac x="fst ((id ((word, replicate (zombie_cte_bits option) False) := slot,
slot := (word, replicate (zombie_cte_bits option) False))) (oref, cref))"
in exI)
apply (rule_tac x="snd ((id ((word, replicate (zombie_cte_bits option) False) := slot,
slot := (word, replicate (zombie_cte_bits option) False))) (oref, cref))"
in exI)
apply fastforce
done
done
end
lemma set_cap_cap_somewhere:
"\<lbrace>\<lambda>s. cte_wp_at (\<lambda>cp. P (fst slot) (snd slot) cp \<longrightarrow> P (fst slot) (snd slot) cap) slot s
\<and> (\<exists>oref cref. cte_wp_at (P oref cref) (oref, cref) s)\<rbrace>
set_cap cap slot
\<lbrace>\<lambda>rv s. \<exists>oref cref. cte_wp_at (P oref cref) (oref, cref) s\<rbrace>"
apply (simp add: cte_wp_at_caps_of_state)
apply wp
apply clarsimp
apply (rule_tac x=oref in exI)
apply (rule_tac x=cref in exI)
apply fastforce
done
context CNodeInv_AI_3 begin
lemma rec_del_ReduceZombie_emptyable:
"\<And>cap slot ex.
\<lbrace>invs and (cte_wp_at ((=) cap) slot and is_final_cap' cap
and (\<lambda>y. is_zombie cap))
and (\<lambda>s. \<not> ex \<longrightarrow> ex_cte_cap_wp_to (\<lambda>cp. cap_irqs cp = {}) slot s)
and emptyable slot
and (\<lambda>s. \<not> cap_removeable cap slot \<and> (\<forall>t\<in>obj_refs cap. halted_if_tcb t s))\<rbrace>
rec_del (ReduceZombieCall cap slot ex)
\<lbrace>\<lambda>rv. emptyable slot :: 'state_ext state \<Rightarrow> bool\<rbrace>, -"
subgoal for cap slot ex
by (rule rec_del_emptyable [where args="ReduceZombieCall cap slot ex", simplified])
done
end
text \<open>The revoke function and its properties are
slightly easier to deal with than the delete
function. However, its termination argument
is complex, requiring that the delete function
reduces the number of non-null capabilities.\<close>
definition
cap_revoke_recset :: "((cslot_ptr \<times> 'z::state_ext state) \<times> (cslot_ptr \<times> 'z::state_ext state)) set"
where
"cap_revoke_recset \<equiv> measure (\<lambda>(sl, s). (\<lambda>mp. \<Sum>x \<in> dom mp. rpo_measure x (mp x))
(option_map cap_to_rpo \<circ> caps_of_state s))"
lemma wf_cap_revoke_recset:
"wf cap_revoke_recset"
by (simp add: cap_revoke_recset_def)
lemma rpo_sym:
"revoke_progress_ord m m"
by (simp add: revoke_progress_ord_def)
lemma in_select_ext_weak: "(a,b) \<in> fst (select_ext f S s) \<Longrightarrow>
(a,b) \<in> fst (select S s)"
apply (drule_tac Q="\<lambda>r s'. r \<in> S \<and> s' =s" in use_valid[OF _ select_ext_weak_wp])
apply (simp add: select_def)+
done
context CNodeInv_AI_3 begin
lemma cap_revoke_termination:
"All (cap_revoke_dom :: (machine_word \<times> bool list) \<times> 'state_ext state \<Rightarrow> bool)"
apply (rule cap_revoke.termination)
apply (rule wf_cap_revoke_recset)
apply (clarsimp simp add: cap_revoke_recset_def in_monad select_def
dest!: iffD1[OF in_get_cap_cte_wp_at] in_select_ext_weak)
apply (frule use_validE_R [OF _ cap_delete_rvk_prog])
apply (rule rpo_sym)
apply (frule use_validE_R [OF _ cap_delete_deletes])
apply simp
apply (simp add: revoke_progress_ord_def)
apply (erule disjE)
apply (drule_tac f="\<lambda>f. f (aa, ba)" in arg_cong)
apply (clarsimp simp: cte_wp_at_caps_of_state cap_to_rpo_def)
apply (simp split: cap.split_asm)
apply (drule in_preempt, clarsimp simp: trans_state_update'[symmetric])
done
lemma cap_revoke_dom: "\<And> (p :: (machine_word \<times> bool list) \<times> 'state_ext state). cap_revoke_dom p"
using cap_revoke_termination by blast
lemmas cap_revoke_simps = cap_revoke.psimps[OF cap_revoke_dom]
lemmas cap_revoke_induct = cap_revoke.pinduct[OF cap_revoke_dom]
lemma cap_revoke_preservation':
fixes P and s :: "'state_ext state" and ptr
assumes x: "\<And>p. \<lbrace>P\<rbrace> cap_delete p \<lbrace>\<lambda>rv. P\<rbrace>"
assumes p: "\<lbrace>P\<rbrace> preemption_point \<lbrace>\<lambda>rv. P\<rbrace>"
shows "s \<turnstile> \<lbrace>P\<rbrace> cap_revoke ptr \<lbrace>\<lambda>rv. P\<rbrace>, \<lbrace>\<lambda>rv. P\<rbrace>"
proof (induct rule: cap_revoke_induct)
case (1 slot)
show ?case
apply (subst cap_revoke_simps)
apply (wp "1.hyps")
apply (wp x p hoare_drop_imps select_wp)+
apply simp_all
done
qed
lemmas cap_revoke_preservation = use_spec(2) [OF cap_revoke_preservation']
lemmas cap_revoke_preservation2 = cap_revoke_preservation[THEN validE_valid]
lemma ball_subset: "\<forall>x\<in>A. Q x \<Longrightarrow> B \<subseteq> A \<Longrightarrow> \<forall>x\<in>B. Q x"
apply blast
done
lemma cap_revoke_preservation_desc_of':
fixes P Q and s :: "'state_ext state"
assumes x: "\<And>p. \<lbrace>P and Q p\<rbrace> cap_delete p \<lbrace>\<lambda>rv. P\<rbrace>"
and y: "\<And>sl s. P s \<Longrightarrow> \<forall>sl' \<in> descendants_of sl (cdt s). Q sl' s"
assumes p: "\<lbrace>P\<rbrace> preemption_point \<lbrace>\<lambda>rv. P\<rbrace>"
shows "s \<turnstile> \<lbrace>P\<rbrace> cap_revoke ptr \<lbrace>\<lambda>rv. P\<rbrace>, \<lbrace>\<lambda>rv. P\<rbrace>"
proof (induct rule: cap_revoke_induct)
case (1 slot)
show ?case
apply (subst cap_revoke_simps)
apply (wp "1.hyps")
apply (wp x p hoare_drop_imps select_wp)+
apply (simp_all add: y)
done
qed
lemmas cap_revoke_preservation_desc_of =
use_spec(2) [OF cap_revoke_preservation_desc_of']
lemma cap_revoke_typ_at:
"\<And>P T p. \<lbrace>\<lambda>s::'state_ext state. P (typ_at T p s)\<rbrace> cap_revoke ptr \<lbrace>\<lambda>rv s. P (typ_at T p s)\<rbrace>"
by (wp cap_delete_typ_at cap_revoke_preservation irq_state_independent_AI preemption_point_inv, simp+)
lemma cap_revoke_invs:
"\<And>ptr. \<lbrace>\<lambda>s::'state_ext state. invs s\<rbrace> cap_revoke ptr \<lbrace>\<lambda>rv. invs\<rbrace>"
apply (wp cap_revoke_preservation_desc_of)
apply (fastforce simp: emptyable_def dest: reply_slot_not_descendant)
apply (wp preemption_point_inv)
apply simp+
done
end
lemma descendants_of_cdt_parent:
"\<lbrakk> p' \<in> descendants_of p (cdt s) \<rbrakk> \<Longrightarrow> \<exists>p''. cdt s \<Turnstile> p'' \<leadsto> p'"
apply (simp add: descendants_of_def del: split_paired_Ex)
apply (erule tranclE)
apply (erule exI)
apply (erule exI)
done
lemma cap_revoke_mdb_stuff3:
"\<lbrakk> p' \<in> descendants_of p (cdt s); valid_mdb s \<rbrakk>
\<Longrightarrow> cte_wp_at ((\<noteq>) cap.NullCap) p' s"
apply (clarsimp simp add: valid_mdb_def
dest!: descendants_of_cdt_parent)
apply (simp add: cdt_parent_of_def)
apply (drule(1) mdb_cte_atD)
apply simp
done
crunch typ_at[wp]: cancel_badged_sends "\<lambda>s. P (typ_at T p s)"
(wp: crunch_wps simp: crunch_simps filterM_mapM unless_def
ignore: without_preemption filterM set_object clearMemory)
locale CNodeInv_AI_4 = CNodeInv_AI_3 state_ext_t
for state_ext_t :: "'state_ext::state_ext itself" +
assumes finalise_slot_typ_at [wp]:
"\<And>P T p. \<lbrace>\<lambda>s::'state_ext state. P (typ_at T p s)\<rbrace> finalise_slot a b \<lbrace>\<lambda>_ s. P (typ_at T p s)\<rbrace>"
assumes weak_derived_appropriate:
"\<And>cap cap'. weak_derived cap cap' \<Longrightarrow> appropriate_cte_cap cap = appropriate_cte_cap cap'"
context CNodeInv_AI_4 begin
lemma inv_cnode_typ_at:
"\<And>P T p ci. \<lbrace>\<lambda>s::'state_ext state. P (typ_at T p s)\<rbrace> invoke_cnode ci \<lbrace>\<lambda>rv s. P (typ_at T p s)\<rbrace>"
apply (case_tac ci, simp_all add: invoke_cnode_def split del: if_split)
apply (wp cap_insert_typ_at cap_move_typ_at cap_swap_typ_at hoare_drop_imps
cap_delete_typ_at cap_revoke_typ_at hoare_vcg_all_lift | wpc |
simp | rule conjI impI | rule hoare_pre)+
done
lemma invoke_cnode_tcb[wp]:
"\<And>tptr ci. \<lbrace>tcb_at tptr::'state_ext state \<Rightarrow> bool\<rbrace> invoke_cnode ci \<lbrace>\<lambda>rv. tcb_at tptr\<rbrace>"
by (simp add: tcb_at_typ, wp inv_cnode_typ_at)
end
lemma duplicate_creation:
"\<lbrace>cte_wp_at (\<lambda>c. gen_obj_refs c = gen_obj_refs cap) p
and cte_at p' and K (p \<noteq> p')\<rbrace>
set_cap cap p'
\<lbrace>\<lambda>rv s. cte_wp_at (\<lambda>cap. \<not> is_final_cap' cap s) p s\<rbrace>"
apply (rule hoare_gen_asm)
apply (rule hoare_post_imp [where Q="\<lambda>rv. cte_wp_at (\<lambda>c. gen_obj_refs c = gen_obj_refs cap) p
and cte_wp_at ((=) cap) p'"])
apply (clarsimp simp: cte_wp_at_def)
apply (case_tac "\<exists>x. x \<in> obj_refs cap \<and> x \<in> obj_refs capa")
apply (elim exE conjE)
apply (frule (4) final_cap_duplicate_obj_ref)
apply simp
apply (case_tac "\<exists>x. x \<in> cap_irqs cap \<and> x \<in> cap_irqs capa")
apply (elim exE conjE)
apply (frule (4) final_cap_duplicate_irq, simp)
apply (case_tac "\<exists>x. x \<in> arch_gen_refs cap \<and> x \<in> arch_gen_refs capa")
apply (elim exE conjE)
apply (frule (4) final_cap_duplicate_arch_refs, simp)
apply (simp add: is_final_cap'_def gen_obj_refs_eq gen_obj_refs_Int)
apply (wp set_cap_cte_wp_at)
apply simp_all
done
definition
zombies_final_caps :: "(cslot_ptr \<rightharpoonup> cap) \<Rightarrow> bool"
where
"zombies_final_caps \<equiv> \<lambda>cps. \<forall>p p' cap cap'.
cps p = Some cap \<and> cps p' = Some cap'
\<and> obj_refs cap \<inter> obj_refs cap' \<noteq> {} \<and> p \<noteq> p'
\<longrightarrow> \<not> is_zombie cap \<and> \<not> is_zombie cap'"
lemma zombies_final_caps_of_state:
"zombies_final = zombies_final_caps \<circ> caps_of_state"
by (rule ext,
simp add: zombies_final_def2 zombies_final_caps_def
cte_wp_at_caps_of_state)
lemma zombies_final_injective:
"\<lbrakk> zombies_final_caps (caps_of_state s); inj f \<rbrakk>
\<Longrightarrow> zombies_final_caps (caps_of_state s \<circ> f)"
apply (simp only: zombies_final_caps_def o_def)
apply (intro allI impI)
apply (elim conjE allE, erule mp)
apply (erule conjI)+
apply (simp add: inj_eq)
done
lemma set_cdt_caps_of_state[wp]:
"\<lbrace>\<lambda>s. P (caps_of_state s)\<rbrace> set_cdt p \<lbrace>\<lambda>rv s. P (caps_of_state s)\<rbrace>"
apply (simp add: set_cdt_def)
apply wp
apply (simp add: caps_of_state_cte_wp_at)
done
lemma cap_move_caps_of_state:
notes fun_upd_apply [simp del]
shows "\<lbrace>\<lambda>s. P ((caps_of_state s) (ptr' \<mapsto> cap, ptr \<mapsto> cap.NullCap ))\<rbrace>
cap_move cap ptr ptr'
\<lbrace>\<lambda>rv s. P (caps_of_state s)\<rbrace>"
by (wpsimp simp: cap_move_def)
lemma zombies_duplicate_creation:
"\<lbrace>\<lambda>s. zombies_final s \<and> \<not> is_zombie cap
\<and> (\<exists>p'. cte_wp_at (\<lambda>c. obj_refs c = obj_refs cap \<and> \<not> is_zombie c) p' s)
\<and> cte_wp_at ((=) cap.NullCap) p s\<rbrace>
set_cap cap p
\<lbrace>\<lambda>rv. zombies_final\<rbrace>"
apply (wp set_cap_zombies)
apply (clarsimp simp: cte_wp_at_def)
apply (thin_tac "x \<noteq> y" for x y)
apply (case_tac "(a, b) = (aa, ba)")
apply clarsimp
apply (drule(3) zombies_finalD2)
apply blast
apply simp
done
lemma state_refs_of_rvk[simp]:
"state_refs_of (is_original_cap_update f s) = state_refs_of s"
by (simp add: state_refs_of_def)
lemma weak_derived_is_zombie:
"weak_derived cap cap' \<Longrightarrow> is_zombie cap = is_zombie cap'"
by (auto simp: weak_derived_def copy_of_def is_cap_simps same_object_as_def
split: if_split_asm cap.splits)
lemma cap_move_zombies_final[wp]:
"\<lbrace>zombies_final and cte_wp_at ((=) cap.NullCap) ptr'
and cte_wp_at (weak_derived cap) ptr
and K (ptr \<noteq> ptr')\<rbrace>
cap_move cap ptr ptr'
\<lbrace>\<lambda>rv. zombies_final\<rbrace>"
unfolding cap_move_def zombies_final_caps_of_state o_def set_cdt_def
apply (rule hoare_pre)
apply (wp|simp)+
apply (simp add: cte_wp_at_caps_of_state zombies_final_caps_def del: split_paired_All)
apply (elim conjE exE)
apply (intro impI allI)
apply (simp add: weak_derived_obj_refs weak_derived_is_zombie del: split_paired_All)
apply blast
done
lemma cap_move_if_live[wp]:
"\<lbrace>cte_wp_at ((=) cap.NullCap) ptr'
and cte_wp_at (weak_derived cap) ptr
and K (ptr \<noteq> ptr')
and if_live_then_nonz_cap\<rbrace>
cap_move cap ptr ptr'
\<lbrace>\<lambda>rv s. if_live_then_nonz_cap s\<rbrace>"
unfolding cap_move_def
apply (rule hoare_pre)
apply (wp|simp)+
apply (rule hoare_post_imp, simp only: if_live_then_nonz_cap_def)
apply (simp only: ex_nonz_cap_to_def cte_wp_at_caps_of_state
imp_conv_disj)
apply (wp hoare_vcg_disj_lift hoare_vcg_all_lift)+
apply (clarsimp simp: if_live_then_nonz_cap_def
ex_nonz_cap_to_def cte_wp_at_caps_of_state
del: allI
simp del: split_paired_Ex)
apply (erule allEI, rule impI, drule(1) mp)
apply (erule exfEI[where f="id (ptr := ptr', ptr' := ptr)"])
apply (clarsimp simp: weak_derived_obj_refs zobj_refs_to_obj_refs)
apply (rule conjI)
apply (clarsimp simp: weak_derived_is_zombie)
apply clarsimp
done
lemma weak_derived_cte_refs':
"weak_derived cap cap' \<Longrightarrow> cte_refs cap = cte_refs cap'"
by (fastforce simp: copy_of_cte_refs weak_derived_def)
lemma appropriate_cte_master:
"appropriate_cte_cap (cap_master_cap cap) = appropriate_cte_cap cap"
apply (rule ext)
apply (simp add: cap_master_cap_def appropriate_cte_cap_def
split: cap.split)
done
context CNodeInv_AI_4 begin
lemma cap_move_if_unsafe [wp]:
"\<And>ptr' cap ptr.
\<lbrace>cte_wp_at ((=) cap.NullCap) ptr'
and cte_wp_at (weak_derived cap) ptr
and K (ptr \<noteq> ptr')
and if_unsafe_then_cap
and ex_cte_cap_wp_to (appropriate_cte_cap cap) ptr'\<rbrace>
cap_move cap ptr ptr'
\<lbrace>\<lambda>rv. if_unsafe_then_cap :: 'state_ext state \<Rightarrow> bool\<rbrace>"
subgoal for ptr' cap ptr
apply (simp add: cap_move_def)
apply (wp | simp)+
apply (rule hoare_post_imp, simp only: if_unsafe_then_cap_def)
apply (simp only: ex_cte_cap_wp_to_def cte_wp_at_caps_of_state)
apply wp+
apply (clarsimp simp: if_unsafe_then_cap_def
ex_cte_cap_wp_to_def cte_wp_at_caps_of_state
simp del: split_paired_All split_paired_Ex
del: allI
split del: if_split)
apply (frule weak_derived_Null)
apply (frule weak_derived_cte_refs')
apply (frule cap_irqs_appropriateness [OF weak_derived_cap_irqs])
apply (frule weak_derived_appropriate)
apply (erule allfEI[where f="id (ptr := ptr', ptr' := ptr)"])
apply (case_tac "cref = ptr'")
apply (intro allI impI,
rule_tac x="(id (ptr := ptr', ptr' := ptr)) (a, b)" in exI)
apply fastforce
apply (clarsimp split: if_split_asm split del: if_split del: exE
simp del: split_paired_All split_paired_Ex)
apply (erule exfEI[where f="id (ptr := ptr', ptr' := ptr)"])
apply (clarsimp split: if_split_asm)
apply fastforce
done
done
end
crunch arch[wp]: cap_move "\<lambda>s. P (arch_state s)"
crunch irq_node[wp]: cap_move "\<lambda>s. P (interrupt_irq_node s)"
lemma cap_range_NullCap:
"cap_range cap.NullCap = {}"
by (simp add: cap_range_def)
crunch interrupt_states[wp]: cap_move "\<lambda>s. P (interrupt_states s)"
lemma cap_move_irq_handlers[wp]:
"\<lbrace>valid_irq_handlers and cte_wp_at ((=) cap.NullCap) ptr'
and cte_wp_at (weak_derived cap) ptr\<rbrace>
cap_move cap ptr ptr'
\<lbrace>\<lambda>rv. valid_irq_handlers\<rbrace>"
apply (simp add: valid_irq_handlers_def irq_issued_def)
apply (rule hoare_pre)
apply (rule hoare_use_eq [where f=interrupt_states, OF cap_move_interrupt_states])
apply (simp add: cap_move_def set_cdt_def)
apply (wp | simp)+
apply (clarsimp simp: cte_wp_at_caps_of_state
elim!: ranE split: if_split_asm
dest!: weak_derived_cap_irqs)
apply auto
done
lemma cap_move_has_reply_cap_neg:
"\<lbrace>\<lambda>s. \<not> has_reply_cap t s \<and>
cte_wp_at (weak_derived c) p s \<and>
cte_wp_at ((=) cap.NullCap) p' s \<and>
p \<noteq> p'\<rbrace>
cap_move c p p' \<lbrace>\<lambda>rv s. \<not> has_reply_cap t s\<rbrace>"
apply (simp add: has_reply_cap_def is_reply_cap_to_def cte_wp_at_caps_of_state
del: split_paired_All split_paired_Ex)
apply (wp cap_move_caps_of_state)
apply (elim conjE exE)
apply (drule(1) cap_swap_no_reply_caps[where cs="caps_of_state _"])
apply fastforce+
done
lemma cap_move_replies:
"\<lbrace>\<lambda>s. valid_reply_caps s
\<and> cte_wp_at (weak_derived c) p s
\<and> cte_wp_at ((=) cap.NullCap) p' s
\<and> p \<noteq> p'\<rbrace>
cap_move c p p'
\<lbrace>\<lambda>rv s. valid_reply_caps s\<rbrace>"
apply (simp add: valid_reply_caps_def)
apply (rule hoare_pre)
apply (simp only: imp_conv_disj)
apply (wp hoare_vcg_all_lift hoare_vcg_disj_lift cap_move_has_reply_cap_neg)
apply (simp add: cap_move_def, (wp|simp)+)
apply (rule cap_move_caps_of_state)
apply (clarsimp simp: fun_upd_def cte_wp_at_caps_of_state
unique_reply_caps_cap_swap [simplified fun_upd_def])
done
lemma copy_of_reply_master:
"copy_of cap cap' \<Longrightarrow> is_master_reply_cap cap = is_master_reply_cap cap'"
apply (clarsimp simp: copy_of_def is_cap_simps)
apply (clarsimp simp: same_object_as_def split: cap.splits)
done
context CNodeInv_AI_4 begin
lemma cap_move_valid_arch_caps[wp]:
"\<And>cap ptr.
\<lbrace>valid_arch_caps
and cte_wp_at (weak_derived cap) ptr
and cte_wp_at ((=) cap.NullCap) ptr'\<rbrace>
cap_move cap ptr ptr'
\<lbrace>\<lambda>rv. valid_arch_caps :: 'state_ext state \<Rightarrow> bool\<rbrace>"
apply (simp add: cap_move_def)
apply (rule hoare_pre)
apply (subst bind_assoc[symmetric],
rule hoare_seq_ext [rotated],
rule swap_of_caps_valid_arch_caps)
apply (wp | simp)+
apply (clarsimp elim!: cte_wp_at_weakenE)
done
end
lemma cap_move_valid_ioc[wp]:
"\<lbrace>valid_ioc and
cte_wp_at (weak_derived cap) ptr and cte_wp_at ((=) cap.NullCap) ptr'\<rbrace>
cap_move cap ptr ptr'
\<lbrace>\<lambda>rv. valid_ioc\<rbrace>"
apply (simp add: cap_move_def valid_ioc_def[abs_def] cte_wp_at_caps_of_state
pred_conj_def)
apply (wp set_cdt_cos_ioc set_cap_caps_of_state2 | simp)+
apply (cases ptr, clarsimp simp add: cte_wp_at_caps_of_state valid_ioc_def)
apply (drule spec, drule spec, erule impE, assumption)
apply clarsimp
done
declare cdt_update.state_refs_update [simp]
locale CNodeInv_AI_5 = CNodeInv_AI_4 state_ext_t
for state_ext_t :: "'state_ext::state_ext itself" +
assumes cap_move_invs[wp]:
"\<And>cap ptr' ptr.
\<lbrace>invs and valid_cap cap and cte_wp_at ((=) cap.NullCap) ptr'
and tcb_cap_valid cap ptr'
and cte_wp_at (weak_derived cap) ptr
and cte_wp_at (\<lambda>c. c \<noteq> cap.NullCap) ptr
and ex_cte_cap_wp_to (appropriate_cte_cap cap) ptr' and K (ptr \<noteq> ptr')
and K (\<not> is_master_reply_cap cap)\<rbrace>
cap_move cap ptr ptr'
\<lbrace>\<lambda>rv. invs::'state_ext state \<Rightarrow> bool\<rbrace>"
lemma cte_wp_at_use2:
"\<lbrakk>cte_wp_at P p s; cte_wp_at P' p s; \<And>c. \<lbrakk>cte_wp_at ((=) c) p s; P c; P' c\<rbrakk> \<Longrightarrow> Q \<rbrakk> \<Longrightarrow> Q"
by (auto simp: cte_wp_at_caps_of_state)
lemma cte_wp_at_use3:
"\<lbrakk>cte_wp_at P p s; cte_wp_at P' p s; cte_wp_at P'' p s; \<And>c. \<lbrakk>cte_wp_at ((=) c) p s; P c; P' c; P'' c\<rbrakk> \<Longrightarrow> Q \<rbrakk> \<Longrightarrow> Q"
by (auto simp: cte_wp_at_caps_of_state)
lemma cap_move_valid_cap[wp]:
"\<lbrace>\<lambda>s. s \<turnstile> cap'\<rbrace> cap_move cap p p' \<lbrace>\<lambda>_ s. s \<turnstile> cap'\<rbrace>"
unfolding cap_move_def
by (wp set_cdt_valid_cap | simp)+
lemma weak_derived_cte_refs_abs:
"weak_derived c c' \<Longrightarrow> cte_refs c' = cte_refs c"
apply (clarsimp simp: weak_derived_def copy_of_def)
apply (auto simp: same_object_as_def is_cap_simps bits_of_def
split: if_split_asm cap.splits)
done
lemma cap_move_ex_cap_cte:
"\<lbrace>ex_cte_cap_wp_to P ptr and
cte_wp_at (weak_derived cap) p and
cte_wp_at ((=) cap.NullCap) p' and
K (p \<noteq> p') and K (\<forall>cap'. weak_derived cap cap' \<longrightarrow> P cap = P cap')\<rbrace>
cap_move cap p p'
\<lbrace>\<lambda>_. ex_cte_cap_wp_to P ptr\<rbrace>"
unfolding cap_move_def ex_cte_cap_wp_to_def cte_wp_at_caps_of_state set_cdt_def
apply (rule hoare_pre)
apply wp
apply (simp del: split_paired_Ex)
apply (wp set_cap_caps_of_state | simp del: split_paired_Ex add: cte_wp_at_caps_of_state)+
apply (elim conjE exE)
apply (case_tac "cref = p")
apply (rule_tac x=p' in exI)
apply clarsimp
apply (drule weak_derived_cte_refs_abs)
apply simp
apply (rule_tac x=cref in exI)
apply clarsimp
done
lemma cap_move_src_slot_Null:
"\<lbrace>cte_at src and K(src \<noteq> dest)\<rbrace> cap_move cap src dest \<lbrace>\<lambda>_ s. cte_wp_at ((=) cap.NullCap) src s\<rbrace>"
unfolding cap_move_def
by (wp set_cdt_cte_wp_at set_cap_cte_wp_at' | simp)+
crunch pred_tcb_at[wp]: cap_move "pred_tcb_at proj P t"
lemmas (in CNodeInv_AI_5) cap_revoke_cap_table[wp]
= cap_table_at_lift_valid [OF cap_revoke_typ_at]
lemmas appropriate_cte_cap_simps = appropriate_cte_cap_def [split_simps cap.split]
context CNodeInv_AI_5 begin
crunch inv [wp]: is_final_cap "P"
lemma is_final_cap_is_final[wp]:
"\<lbrace>\<top>\<rbrace> is_final_cap cap \<lbrace>\<lambda>rv s. rv = is_final_cap' cap s\<rbrace>"
unfolding is_final_cap_def
by wp simp
end
lemma real_cte_not_reply_masterD:
"\<And>P ptr.
\<lbrakk> real_cte_at ptr s; valid_reply_masters s; valid_objs s \<rbrakk> \<Longrightarrow>
cte_wp_at (\<lambda>cap. \<not> is_master_reply_cap cap) ptr s"
apply clarsimp
apply (subgoal_tac "\<not> tcb_at a s")
apply (clarsimp simp: cap_table_at_cte_at cte_wp_at_not_reply_master)
apply (clarsimp simp: obj_at_def is_tcb is_cap_table)
done
lemma real_cte_weak_derived_not_reply_masterD:
"\<And>cap ptr.
\<lbrakk> cte_wp_at (weak_derived cap) ptr s; real_cte_at ptr s;
valid_reply_masters s; valid_objs s \<rbrakk> \<Longrightarrow>
\<not> is_master_reply_cap cap"
by (fastforce simp: cte_wp_at_caps_of_state weak_derived_replies
dest!: real_cte_not_reply_masterD)
lemma real_cte_is_derived_not_replyD:
"\<And>m p cap ptr.
\<lbrakk> cte_wp_at (is_derived m p cap) ptr s; real_cte_at ptr s;
valid_reply_masters s; valid_objs s \<rbrakk> \<Longrightarrow>
\<not> is_reply_cap cap"
by (fastforce simp: cte_wp_at_caps_of_state is_derived_def
dest!: real_cte_not_reply_masterD)
lemma cap_irqs_is_derived:
"is_derived m ptr cap cap' \<Longrightarrow> cap_irqs cap = cap_irqs cap'"
by (clarsimp simp: is_derived_def cap_master_cap_irqs split: if_split_asm)
lemma tcb_cap_valid_mdb[simp]:
"tcb_cap_valid cap p (cdt_update mfn s) = tcb_cap_valid cap p s"
by (simp add: tcb_cap_valid_def)
lemma tcb_cap_valid_is_original_cap[simp]:
"tcb_cap_valid cap p (is_original_cap_update mfn s) = tcb_cap_valid cap p s"
by (simp add: tcb_cap_valid_def)
crunch tcb_cap_valid[wp]: cap_move "tcb_cap_valid cap p"
context CNodeInv_AI_5 begin
lemma invoke_cnode_invs[wp]:
fixes i shows
"\<lbrace>invs and valid_cnode_inv i\<rbrace> invoke_cnode i \<lbrace>\<lambda>rv. invs::'state_ext state \<Rightarrow> bool\<rbrace>"
unfolding invoke_cnode_def
apply (cases i)
apply simp
apply wp
apply (simp add: ex_cte_cap_to_cnode_always_appropriate_strg
real_cte_tcb_valid)
apply (rule conjI)
apply (clarsimp simp: cte_wp_at_caps_of_state dest!: cap_irqs_is_derived)
apply (rule conjI)
apply (elim conjE)
apply (drule real_cte_is_derived_not_replyD)
apply (simp add:invs_valid_objs invs_valid_reply_masters)+
apply (clarsimp simp:is_cap_simps)
apply (elim conjE)
apply (drule real_cte_not_reply_masterD)
apply (simp add:invs_valid_objs invs_valid_reply_masters)+
apply (clarsimp simp: cte_wp_at_caps_of_state is_derived_def)
apply simp
apply wp
apply (fastforce simp: real_cte_tcb_valid cte_wp_at_caps_of_state
ex_cte_cap_to_cnode_always_appropriate_strg
dest: real_cte_weak_derived_not_reply_masterD)
apply simp
apply (wp cap_revoke_invs)
apply simp
apply simp
apply wp
apply (clarsimp simp: emptyable_def obj_at_def is_tcb is_cap_table)
apply simp
apply (rule conjI)
apply (rule impI)
apply wp
apply (fastforce simp: real_cte_tcb_valid
ex_cte_cap_to_cnode_always_appropriate_strg
dest: real_cte_weak_derived_not_reply_masterD)
apply (rule impI)
apply (rule hoare_pre)
apply wp
apply (simp add: cte_wp_at_caps_of_state)
apply (wp cap_move_caps_of_state cap_move_ex_cap_cte)
apply (simp add: pred_conj_def)
apply (elim conjE exE)
apply (simp add: real_cte_tcb_valid ex_cte_cap_to_cnode_always_appropriate_strg
cap_irqs_appropriateness [OF weak_derived_cap_irqs])
apply (intro conjI,
(fastforce simp: cte_wp_at_caps_of_state
dest: real_cte_weak_derived_not_reply_masterD)+)[1]
apply (wpsimp wp: hoare_drop_imps get_cap_wp)+
apply (rule conjI)
apply (clarsimp elim!: cte_wp_valid_cap)
apply (clarsimp simp: real_cte_tcb_valid cte_wp_at_caps_of_state
is_cap_simps ex_cte_cap_to_cnode_always_appropriate_strg)
apply (wpsimp)
done
end
crunch pred_tcb_at[wp]: cap_move "pred_tcb_at proj P t"
(* FIXME: rename, move *)
lemma omgwtfbbq[simp]:
"(\<forall>x. y \<noteq> x) = False"
by clarsimp
lemma corres_underlying_lift_ex1:
assumes c: "\<And>v. corres_underlying sr nf nf' r (P v and Q) P' a c"
shows "corres_underlying sr nf nf' r ((\<lambda>s. \<exists>v. P v s) and Q) P' a c"
unfolding corres_underlying_def
apply clarsimp
apply (cut_tac v = v in c)
apply (auto simp: corres_underlying_def)
done
lemmas corres_underlying_lift_ex1' = corres_underlying_lift_ex1 [where Q = \<top>, simplified]
lemma corres_underlying_lift_ex2:
assumes c: "\<And>v. corres_underlying sr nf nf' r P (P' v and Q) a c"
shows "corres_underlying sr nf nf' r P ((\<lambda>s. \<exists>v. P' v s) and Q) a c"
unfolding corres_underlying_def
apply clarsimp
apply (cut_tac v = v in c)
apply (auto simp: corres_underlying_def)
done
lemmas corres_underlying_lift_ex2' = corres_underlying_lift_ex2 [where Q = \<top>, simplified]
lemma real_cte_halted_if_tcb[simp]:
"real_cte_at (a, b) s \<Longrightarrow> halted_if_tcb a s"
by (clarsimp simp: halted_if_tcb_def obj_at_def is_cap_table is_tcb)
lemma descendants_of_empty:
"x \<notin> descendants_of cref Map.empty"
by (simp add: descendants_of_def cdt_parent_rel_def is_cdt_parent_def)
lemma has_parent_cte_at:"valid_mdb s \<Longrightarrow> (cdt s) c = Some p \<Longrightarrow> cte_at c s"
apply (rule cte_wp_cte_at)
apply (simp add: valid_mdb_def mdb_cte_at_def del: split_paired_All)
apply blast
done
end
|
lemma Lim_transform_within_open: assumes "(f \<longlongrightarrow> l) (at a within T)" and "open s" and "a \<in> s" and "\<And>x. x\<in>s \<Longrightarrow> x \<noteq> a \<Longrightarrow> f x = g x" shows "(g \<longlongrightarrow> l) (at a within T)" |
theory T90
imports Main
begin
lemma "(
(\<forall> x::nat. \<forall> y::nat. meet(x, y) = meet(y, x)) &
(\<forall> x::nat. \<forall> y::nat. join(x, y) = join(y, x)) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(x, meet(y, z)) = meet(meet(x, y), z)) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(x, join(y, z)) = join(join(x, y), z)) &
(\<forall> x::nat. \<forall> y::nat. meet(x, join(x, y)) = x) &
(\<forall> x::nat. \<forall> y::nat. join(x, meet(x, y)) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(x, join(y, z)) = join(mult(x, y), mult(x, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(join(x, y), z) = join(mult(x, z), mult(y, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(x, over(join(mult(x, y), z), y)) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(y, undr(x, join(mult(x, y), z))) = y) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(mult(over(x, y), y), x) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(mult(y, undr(y, x)), x) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(x, meet(y, z)) = meet(mult(x, y), mult(x, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. over(join(x, y), z) = join(over(x, z), over(y, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. over(x, meet(y, z)) = join(over(x, y), over(x, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. undr(meet(x, y), z) = join(undr(x, z), undr(y, z))) &
(\<forall> x::nat. \<forall> y::nat. invo(join(x, y)) = meet(invo(x), invo(y))) &
(\<forall> x::nat. \<forall> y::nat. invo(meet(x, y)) = join(invo(x), invo(y))) &
(\<forall> x::nat. invo(invo(x)) = x)
) \<longrightarrow>
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. undr(x, join(y, z)) = join(undr(x, y), undr(x, z)))
"
nitpick[card nat=4,timeout=86400]
oops
end |
Fly your team pride high on game day with the Rico® Atlanta Falcons Banner Flag. Featuring a screen-printed team graphic on one side in vibrant team colors, this banner flag lets any passerby know you are a die-hard Falcons fan. The durable fabric and two brass grommet holes ensure that your team pride will be on display in any weather when you have the Rico® Banner Flag. |
using ABM
using Random
using Distributions
mutable struct BoidData
name::String
pos::Real2D
orientation::Real2D
end
function fstep(state::SimState, agent::Agent)
end
pos = Real2D(rand(Uniform(0, 100)), rand(Uniform(0, 100)))
d = BoidData("Boid", pos, Real2D(rand(Uniform(0, 100)),rand(Uniform(0, 100))))
a = Agent(fstep,d)
dict1 = Dict{Int64,Int64}()
array1 = Array{Int64,1}()
dict2 = Dict{Agent,Int64}()
array2 = Array{Agent,1}()
set1 = Set{Int64}()
set2 = Set{Agent}()
println("------------------------------")
@time for i in 1:1000000
pos = Real2D(rand(Uniform(0, 100)), rand(Uniform(0, 100)))
d = BoidData("Boid", pos, Real2D(rand(Uniform(0, 100)),rand(Uniform(0, 100))))
a = Agent(fstep,d)
push!(array2, a)
end
@time for i in 1:1000000
pos = Real2D(rand(Uniform(0, 100)), rand(Uniform(0, 100)))
d = BoidData("Boid", pos, Real2D(rand(Uniform(0, 100)),rand(Uniform(0, 100))))
a = Agent(fstep,d)
push!(dict2, a=>i)
end
@time for i in 1:1000000
pos = Real2D(rand(Uniform(0, 100)), rand(Uniform(0, 100)))
d = BoidData("Boid", pos, Real2D(rand(Uniform(0, 100)),rand(Uniform(0, 100))))
a = Agent(fstep,d)
push!(set2, a)
end
@time for x in values(dict2)
end
@time for x in values(set2)
end
@time for x in array2
end
|
open import parse-tree
open import string
module run (ptr : ParseTreeRec) where
open import lib
open import datatypes
open ParseTreeRec ptr
module deriv where
data RunElement : 𝕃 char → Set where
Id : string → RunElement []
InputChar : (c : char) → RunElement (c :: [])
ParseTree : {l : 𝕃 char}{s : string}{pt : ParseTreeT} → isParseTree pt l s → RunElement l
infixr 6 _::'_
data Run : (ls : 𝕃 char) → Set where
[]' : Run []
_::'_ : {lc elc : 𝕃 char} → RunElement elc → Run lc → Run (elc ++ lc)
length-run : {lc : 𝕃 char} → Run lc → ℕ
length-run []' = 0
length-run (x ::' xs) = suc (length-run xs)
RunElement-to-string : {lc : 𝕃 char} → RunElement lc → string
RunElement-to-string (Id s) = ("id:" ^ s)
RunElement-to-string (InputChar c) = "#" ^ (char-to-string c)
RunElement-to-string (ParseTree{pt = pt} ipt) = (ParseTreeToString pt)
Run-to-string : {lc : 𝕃 char} → Run lc → string
Run-to-string []' = "\n"
Run-to-string (e ::' r) = (RunElement-to-string e) ^ " " ^ (Run-to-string r)
assocRun : (ls : 𝕃 (𝕃 char))(lc : 𝕃 char) → Run ((concat ls) ++ lc) × ℕ → Run (foldr _++_ lc ls) × ℕ
assocRun ls lc (r , n) rewrite concat-foldr ls lc = r , n
record rewriteRules : Set where
field
len-dec-rewrite : {lc : 𝕃 char} → (r : Run lc) → maybe (Run lc × ℕ) --(λ r' → length-run r' < length-run r ≡ tt))
module noderiv where
data RunElement : Set where
Id : string → RunElement
InputChar : (c : char) → RunElement
ParseTree : ParseTreeT → RunElement
Posinfo : ℕ → RunElement
Run : Set
Run = 𝕃 RunElement
_::'_ : RunElement → Run → Run
_::'_ = _::_
[]' : Run
[]' = []
length-run : Run → ℕ
length-run = length
RunElement-to-string : RunElement → string
RunElement-to-string (Id s) = ("id:" ^ s)
RunElement-to-string (InputChar c) = "#" ^ (char-to-string c)
RunElement-to-string (ParseTree pt) = (ParseTreeToString pt)
RunElement-to-string (Posinfo n) = "pos:" ^ ℕ-to-string n
Run-to-string : Run → string
Run-to-string [] = "\n"
Run-to-string (e :: r) = (RunElement-to-string e) ^ " " ^ (Run-to-string r)
record rewriteRules : Set where
field
len-dec-rewrite : Run → maybe (Run × ℕ)
empty-string : string
empty-string = ""
|
/-
Copyright (c) 2020 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn, Yaël Dillies
-/
import topology.sets.opens
/-!
# Closed sets
We define a few types of closed sets in a topological space.
## Main Definitions
For a topological space `α`,
* `closeds α`: The type of closed sets.
* `clopens α`: The type of clopen sets.
-/
open set
variables {α β : Type*} [topological_space α] [topological_space β]
namespace topological_space
/-! ### Closed sets -/
/-- The type of closed subsets of a topological space. -/
structure closeds (α : Type*) [topological_space α] :=
(carrier : set α)
(closed' : is_closed carrier)
namespace closeds
variables {α}
instance : set_like (closeds α) α :=
{ coe := closeds.carrier,
coe_injective' := λ s t h, by { cases s, cases t, congr' } }
lemma closed (s : closeds α) : is_closed (s : set α) := s.closed'
@[ext] protected lemma ext {s t : closeds α} (h : (s : set α) = t) : s = t := set_like.ext' h
@[simp]
instance : has_sup (closeds α) := ⟨λ s t, ⟨s ∪ t, s.closed.union t.closed⟩⟩
instance : has_inf (closeds α) := ⟨λ s t, ⟨s ∩ t, s.closed.inter t.closed⟩⟩
instance : has_top (closeds α) := ⟨⟨univ, is_closed_univ⟩⟩
instance : has_bot (closeds α) := ⟨⟨∅, is_closed_empty⟩⟩
instance : distrib_lattice (closeds α) :=
set_like.coe_injective.distrib_lattice _ (λ _ _, rfl) (λ _ _, rfl)
instance : bounded_order (closeds α) := bounded_order.lift (coe : _ → set α) (λ _ _, id) rfl rfl
/-- The type of closed sets is inhabited, with default element the empty set. -/
instance : inhabited (closeds α) := ⟨⊥⟩
@[simp] lemma coe_sup (s t : closeds α) : (↑(s ⊔ t) : set α) = s ∪ t := rfl
@[simp] lemma coe_inf (s t : closeds α) : (↑(s ⊓ t) : set α) = s ∩ t := rfl
@[simp] lemma coe_top : (↑(⊤ : closeds α) : set α) = univ := rfl
@[simp] lemma coe_bot : (↑(⊥ : closeds α) : set α) = ∅ := rfl
end closeds
/-! ### Clopen sets -/
/-- The type of clopen sets of a topological space. -/
structure clopens (α : Type*) [topological_space α] :=
(carrier : set α)
(clopen' : is_clopen carrier)
namespace clopens
instance : set_like (clopens α) α :=
{ coe := λ s, s.carrier,
coe_injective' := λ s t h, by { cases s, cases t, congr' } }
lemma clopen (s : clopens α) : is_clopen (s : set α) := s.clopen'
/-- Reinterpret a compact open as an open. -/
@[simps] def to_opens (s : clopens α) : opens α := ⟨s, s.clopen.is_open⟩
@[ext] protected lemma ext {s t : clopens α} (h : (s : set α) = t) : s = t := set_like.ext' h
@[simp] lemma coe_mk (s : set α) (h) : (mk s h : set α) = s := rfl
instance : has_sup (clopens α) := ⟨λ s t, ⟨s ∪ t, s.clopen.union t.clopen⟩⟩
instance : has_inf (clopens α) := ⟨λ s t, ⟨s ∩ t, s.clopen.inter t.clopen⟩⟩
instance : has_top (clopens α) := ⟨⟨⊤, is_clopen_univ⟩⟩
instance : has_bot (clopens α) := ⟨⟨⊥, is_clopen_empty⟩⟩
instance : has_sdiff (clopens α) := ⟨λ s t, ⟨s \ t, s.clopen.diff t.clopen⟩⟩
instance : has_compl (clopens α) := ⟨λ s, ⟨sᶜ, s.clopen.compl⟩⟩
instance : boolean_algebra (clopens α) :=
set_like.coe_injective.boolean_algebra _ (λ _ _, rfl) (λ _ _, rfl) rfl rfl (λ _, rfl) (λ _ _, rfl)
@[simp] lemma coe_sup (s t : clopens α) : (↑(s ⊔ t) : set α) = s ∪ t := rfl
@[simp] lemma coe_inf (s t : clopens α) : (↑(s ⊓ t) : set α) = s ∩ t := rfl
@[simp] lemma coe_top : (↑(⊤ : clopens α) : set α) = univ := rfl
@[simp] lemma coe_bot : (↑(⊥ : clopens α) : set α) = ∅ := rfl
@[simp] lemma coe_sdiff (s t : clopens α) : (↑(s \ t) : set α) = s \ t := rfl
@[simp] lemma coe_compl (s : clopens α) : (↑sᶜ : set α) = sᶜ := rfl
instance : inhabited (clopens α) := ⟨⊥⟩
end clopens
end topological_space
|
/-
Copyright (c) 2018 Johan Commelin All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Chris Hughes, Kevin Buzzard
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.algebra.group.hom
import Mathlib.PostPort
universes u v w u_1 u_2
namespace Mathlib
/-!
# Lift monoid homomorphisms to group homomorphisms of their units subgroups.
-/
namespace units
/-- The group homomorphism on units induced by a `monoid_hom`. -/
def map {M : Type u} {N : Type v} [monoid M] [monoid N] (f : M →* N) : units M →* units N :=
monoid_hom.mk' (fun (u : units M) => mk (coe_fn f (val u)) (coe_fn f (inv u)) sorry sorry) sorry
@[simp] theorem coe_map {M : Type u} {N : Type v} [monoid M] [monoid N] (f : M →* N) (x : units M) :
↑(coe_fn (map f) x) = coe_fn f ↑x :=
rfl
@[simp] theorem Mathlib.add_units.coe_map_neg {M : Type u} {N : Type v} [add_monoid M]
[add_monoid N] (f : M →+ N) (u : add_units M) :
↑(-coe_fn (add_units.map f) u) = coe_fn f ↑(-u) :=
rfl
@[simp] theorem map_comp {M : Type u} {N : Type v} {P : Type w} [monoid M] [monoid N] [monoid P]
(f : M →* N) (g : N →* P) : map (monoid_hom.comp g f) = monoid_hom.comp (map g) (map f) :=
rfl
@[simp] theorem map_id (M : Type u) [monoid M] : map (monoid_hom.id M) = monoid_hom.id (units M) :=
monoid_hom.ext fun (x : units M) => ext (Eq.refl ↑(coe_fn (map (monoid_hom.id M)) x))
/-- Coercion `units M → M` as a monoid homomorphism. -/
def coe_hom (M : Type u) [monoid M] : units M →* M := monoid_hom.mk coe coe_one coe_mul
@[simp] theorem coe_hom_apply {M : Type u} [monoid M] (x : units M) : coe_fn (coe_hom M) x = ↑x :=
rfl
/-- If a map `g : M → units N` agrees with a homomorphism `f : M →* N`, then
this map is a monoid homomorphism too. -/
def lift_right {M : Type u} {N : Type v} [monoid M] [monoid N] (f : M →* N) (g : M → units N)
(h : ∀ (x : M), ↑(g x) = coe_fn f x) : M →* units N :=
monoid_hom.mk g sorry sorry
@[simp] theorem coe_lift_right {M : Type u} {N : Type v} [monoid M] [monoid N] {f : M →* N}
{g : M → units N} (h : ∀ (x : M), ↑(g x) = coe_fn f x) (x : M) :
↑(coe_fn (lift_right f g h) x) = coe_fn f x :=
h x
@[simp] theorem mul_lift_right_inv {M : Type u} {N : Type v} [monoid M] [monoid N] {f : M →* N}
{g : M → units N} (h : ∀ (x : M), ↑(g x) = coe_fn f x) (x : M) :
coe_fn f x * ↑(coe_fn (lift_right f g h) x⁻¹) = 1 :=
sorry
@[simp] theorem lift_right_inv_mul {M : Type u} {N : Type v} [monoid M] [monoid N] {f : M →* N}
{g : M → units N} (h : ∀ (x : M), ↑(g x) = coe_fn f x) (x : M) :
↑(coe_fn (lift_right f g h) x⁻¹) * coe_fn f x = 1 :=
sorry
end units
namespace monoid_hom
/-- If `f` is a homomorphism from a group `G` to a monoid `M`,
then its image lies in the units of `M`,
and `f.to_hom_units` is the corresponding monoid homomorphism from `G` to `units M`. -/
def Mathlib.add_monoid_hom.to_hom_units {G : Type u_1} {M : Type u_2} [add_group G] [add_monoid M]
(f : G →+ M) : G →+ add_units M :=
add_monoid_hom.mk (fun (g : G) => add_units.mk (coe_fn f g) (coe_fn f (-g)) sorry sorry) sorry
sorry
@[simp] theorem coe_to_hom_units {G : Type u_1} {M : Type u_2} [group G] [monoid M] (f : G →* M)
(g : G) : ↑(coe_fn (to_hom_units f) g) = coe_fn f g :=
rfl
end monoid_hom
theorem is_unit.map {M : Type u_1} {N : Type u_2} [monoid M] [monoid N] (f : M →* N) {x : M}
(h : is_unit x) : is_unit (coe_fn f x) :=
Exists.dcases_on h
fun (y : units M) (h_h : ↑y = x) => Eq._oldrec (is_unit_unit (coe_fn (units.map f) y)) h_h
/-- If a homomorphism `f : M →* N` sends each element to an `is_unit`, then it can be lifted
to `f : M →* units N`. See also `units.lift_right` for a computable version. -/
def is_unit.lift_right {M : Type u_1} {N : Type u_2} [monoid M] [monoid N] (f : M →* N)
(hf : ∀ (x : M), is_unit (coe_fn f x)) : M →* units N :=
units.lift_right f (fun (x : M) => classical.some (hf x)) sorry
theorem is_add_unit.coe_lift_right {M : Type u_1} {N : Type u_2} [add_monoid M] [add_monoid N]
(f : M →+ N) (hf : ∀ (x : M), is_add_unit (coe_fn f x)) (x : M) :
↑(coe_fn (is_add_unit.lift_right f hf) x) = coe_fn f x :=
add_units.coe_lift_right (is_add_unit.lift_right._proof_1 f hf) x
@[simp] theorem is_add_unit.add_lift_right_neg {M : Type u_1} {N : Type u_2} [add_monoid M]
[add_monoid N] (f : M →+ N) (h : ∀ (x : M), is_add_unit (coe_fn f x)) (x : M) :
coe_fn f x + ↑(-coe_fn (is_add_unit.lift_right f h) x) = 0 :=
add_units.add_lift_right_neg (fun (y : M) => classical.some_spec (h y)) x
@[simp] theorem is_add_unit.lift_right_neg_add {M : Type u_1} {N : Type u_2} [add_monoid M]
[add_monoid N] (f : M →+ N) (h : ∀ (x : M), is_add_unit (coe_fn f x)) (x : M) :
↑(-coe_fn (is_add_unit.lift_right f h) x) + coe_fn f x = 0 :=
add_units.lift_right_neg_add (fun (y : M) => classical.some_spec (h y)) x
end Mathlib |
[STATEMENT]
lemma extended_distance_set_basepoint:
"basepoint x \<in> extended_distance_set"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. basepoint x \<in> extended_distance_set
[PROOF STEP]
unfolding extended_distance_set_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. basepoint x \<in> {z. extended_distance z z = 0}
[PROOF STEP]
using extended_distance_basepoint
[PROOF STATE]
proof (prove)
using this:
extended_distance (basepoint ?x) (basepoint ?y) = dist ?x ?y
goal (1 subgoal):
1. basepoint x \<in> {z. extended_distance z z = 0}
[PROOF STEP]
by auto |
Require Import Coq.Lists.List.
Import ListNotations.
Require Import Tactics.
Require Import Sequence.
Require Import Syntax.
Require Import Subst.
Require Import SimpSub.
Require Import Promote.
Require Import Hygiene.
Require Import Rules.
Require Import DerivedRules.
Require Defs.
Require Import Obligations.
Require Import Morphism.
Require Import DefsEquiv.
Require Import Equivalence.
Require Import Dots.
Require Import ValidationUtil.
Lemma ofForm_valid : ofForm_obligation.
Proof.
prepare.
intros G a m ext0 H.
eapply tr_equal_formation; eauto.
eapply tr_inhabitation_formation; eauto.
Qed.
Lemma ofEq_valid : ofEq_obligation.
Proof.
prepare.
intros G a b m n ext1 ext0 Hab Hmn.
eapply tr_equal_formation; eauto.
Qed.
Lemma ofFormUniv_valid : ofFormUniv_obligation.
Proof.
prepare.
intros G a i m ext1 ext0 Ha Hm.
apply tr_equal_formation_univ; eauto.
Qed.
Lemma ofEqUniv_valid : ofEqUniv_obligation.
Proof.
prepare.
intros G a b i m n ext1 ext0 Hab Hmn.
apply tr_equal_formation_univ; eauto.
Qed.
Lemma ofIntro_valid : ofIntro_obligation.
Proof.
prepare.
intros G a m ext0 H.
auto.
Qed.
Lemma ofElim_valid : ofElim_obligation.
Proof.
prepare.
intros G a m p ext0 H.
auto.
Qed.
Lemma ofTrivialize_valid : ofTrivialize_obligation.
Proof.
prepare.
intros G a m ext0 H.
auto.
Qed.
Lemma ofExt_valid : ofExt_obligation.
Proof.
unfoldtop.
unfold Defs.dof.
intros G a m p q ext1 ext0 Hp Hq.
autorewrite with prepare in * |- *.
unfold Defs.triv.
apply tr_equal_intro.
apply (tr_transitivity _ _ triv).
{
apply tr_equal_eta.
apply tr_equal_elim; auto.
eapply tr_equal_eta2; eauto.
}
{
apply tr_symmetry.
apply tr_equal_eta.
apply tr_equal_elim; auto.
eapply tr_equal_eta2; eauto.
}
Qed.
Lemma ofLeft_valid : ofLeft_obligation.
Proof.
prepare.
intros G1 G2 a b p m H.
apply tr_equal_eta_hyp; auto.
Qed.
Lemma ofEquand1_valid : ofEquand1_obligation.
Proof.
prepare.
intros G a m n ext0 H.
apply (tr_transitivity _ _ n); auto.
apply tr_symmetry; auto.
Qed.
Lemma ofEquand2_valid : ofEquand2_obligation.
Proof.
prepare.
intros G a m n ext0 H.
apply (tr_transitivity _ _ m); auto.
apply tr_symmetry; auto.
Qed.
|
rebol []
resize-image: func[src trg percent /name fname][
src-size: get-image-size src
if 0 <> call/wait probe ajoin [
to-local-file dir_imagemagick "\convert"
{ "} to-local-file src {"}
;" -resize " form (100 * percent/1) "%x" form (100 * percent/2) "%!"
" -resize " form (round/ceiling(percent/1 * src-size/x)) "x" form (round/ceiling(percent/2 * src-size/y)) "!"
" -unsharp 1x2.0+.3+0.05" ;-----original
;" -unsharp 1x2.0+.8+0.1" ;-na pozadi prilis
" -strip"
{ png32:"} to-local-file trg {"}
][
ask "!!! problem with resize !!!"
]
]
resize-image-android: func[src trg percent /name fname /local filename tmp src-size][
filename: last parse/all fname "/\"
src-size: get-image-size src
either tmp: select images filename [
src: tmp/1
;src-size: tmp/2
print ["*************>" filename]
][
print src
]
if 0 <> call/wait probe ajoin [
to-local-file dir_imagemagick "\convert"
{ "} to-local-file src {"}
;" -resize " form (100 * percent/1) "%x" form (100 * percent/2) "%!"
" -resize " form (round/ceiling(percent/1 * src-size/x)) "x" form (round/ceiling(percent/2 * src-size/y)) "!"
" -unsharp 1x2.0+.3+0.05" ;-----original
;" -unsharp 1x2.0+.8+0.1" ;-na pozadi prilis
" -strip"
{ png32:"} to-local-file trg {"}
][
ask "!!! problem with resize !!!"
]
]
resize-image: :resize-image-android
resize-point: func[data /to scale /local x y s e][
;print ["RSZP<--" data]
unless scale [scale: .000005]
parse data [
some [
SP
s:
[copy x rl_edgNumber (x: load x) | rl_hexNum (x: n)]
e: (s: change/part s (round/to scale-x * x scale) e) :s
SP "," SP
s:
[copy y rl_edgNumber (y: load y) | rl_hexNum (y: n)]
e: (s: change/part s (round/to scale-y * y scale) e) :s
]
]
;print ["RSZP-->" data]
;ask ""
]
append XFL-action-rules [
DOMDocument-rsz [
[
"DOMDocument" (
either tmp: select atts "width" [
atts/("width"): round scale-x * to-integer tmp
][
repend atts ["width" round scale-x * 550]
]
either tmp: select atts "height" [
atts/("height"): round scale-y * to-integer tmp
][
repend atts ["height" round scale-y * 400]
]
)|
"symbols" |
"media" |
"timelines"
](
parse-xfl content
) |
"DOMTimeline" (
parse-xfl/act content 'DOMTimeline-rsz
) |
"DOMBitmapItem" (
probe atts
print "------------------"
tmp: atts/("name")
parse tmp [".\LIBRARY\" copy tmp to end]
ext: last parse tmp "."
unless select atts "sourceExternalFilepath" [append atts ["sourceExternalFilepath" none]]
originalName: copy atts/("sourceExternalFilepath"): join "./LIBRARY/" [tmp either find ["png" "jpg"] ext [""][".png"]]
error? try [atts/("href"): atts/("sourceExternalFilepath") ]
if tmp: select atts "sourceLastImported" [change clear tmp to-timestamp now]
ext: last parse atts/("sourceExternalFilepath") "."
;probe atts ask "exporting..."
;export-media-item/overwrite atts
temp-file: rejoin [enbase/base checksum/secure join tmp now 16 "." ext]
export-media-item/into-file atts temp-file
;ask "resizing..."
resize-image/name
tmp: join xfl-folder-new temp-file ;to-rebol-file as-string utf8/decode atts/("sourceExternalFilepath")
tmp ;head insert find/last tmp "." "_sc"
reduce [scale-x scale-y]
originalName
;ask ""
import-media-img/as tmp select atts "bitmapDataHRef"
delete tmp
) |
"DOMCompiledClipItem" |
"Include" (
append files-to-parse atts/("href")
)|
"DOMSoundItem" |
"folders" |
"fonts" |
"swatchLists" |
"extendedSwatchLists" |
"PrinterSettings" |
"publishHistory" |
"swcCache"
]
DOMSymbolItem-rsz [
"DOMSymbolItem" (
if tmp: select atts "lastModified" [change clear tmp to-timestamp now]
if tmp: select atts "sourceLastModified" [change clear tmp to-timestamp now]
parse-xfl content
) |
"timeline" (
parse-xfl/act content 'DOMTimeline-rsz
)
]
DOMTimeline-rsz [
[
"DOMTimeline" |
"layers" |
"frames" |
"DOMFrame" |
"elements" |
"DOMGroup" |
"members" |
"Actionscript" |
"transformationPoint" |
"filters" |
"MorphShape" |
"morphHintsList" |
"morphSegments" |
"textRuns" |
"DOMTextRun" |
"textAttrs" |
"motionObjectXML"
] (
parse-xfl content
) |
"DOMLayer" (
parse-xfl content
) |
"DOMShape" (
;remove-atts atts ["selected"]
parse-xfl/act content 'DOMShape-rsz
) |
[
"DOMStaticText" |
"DOMInputText"
] (
if atts [
if find atts "width" [atts/("width"): round/to scale-x * to decimal! atts/("width") .05]
if find atts "height" [atts/("height"): round/to scale-y * to decimal! atts/("height") .05]
]
parse-xfl content
) |
"DOMSymbolInstance" (
if find atts "centerPoint3DX" [atts/("centerPoint3DX"): scale-x * to decimal! atts/("centerPoint3DX")]
if find atts "centerPoint3DY" [atts/("centerPoint3DY"): scale-y * to decimal! atts/("centerPoint3DY")]
parse-xfl content
) |
"DOMBitmapInstance" (
parse-xfl content
) |
"matrix" (
parse-xfl content
) |
"Matrix" (
if atts [
if find atts "tx" [atts/("tx"): round/to scale-x * to decimal! atts/("tx") .05]
if find atts "ty" [atts/("ty"): round/to scale-y * to decimal! atts/("ty") .05]
]
) |
"Point" (
if atts [
if find atts "x" [atts/("x"): round/to scale-x * to decimal! atts/("x") .05]
if find atts "y" [atts/("y"): round/to scale-y * to decimal! atts/("y") .05]
]
) |
"script" (
comment {
either all [
block? content
string? content/1
1 = length? content
][
insert content/1 "<![CDATA["
append content/1 "]]>"
][
;ask ["SCRIPT???" mold current-node]
]}
) |
[
"BlurFilter" |
"GlowFilter"
] (
unless atts [current-node/2: atts: copy []]
unless tmp: select atts "blurX" [tmp: 5 append atts ["blurX" none]] atts/("blurX"): round/to scale-x * to decimal! tmp .05
unless tmp: select atts "blurY" [tmp: 5 append atts ["blurY" none]] atts/("blurY"): round/to scale-y * to decimal! tmp .05
) |
["DropShadowFilter" | "BevelFilter" | "GradientGlowFilter" | "GradientBevelFilter"](
unless atts [current-node/2: atts: copy []]
unless tmp: select atts "blurX" [tmp: 5 append atts ["blurX" none]] atts/("blurX"): round/to scale-x * to decimal! tmp .05
unless tmp: select atts "blurY" [tmp: 5 append atts ["blurY" none]] atts/("blurY"): round/to scale-y * to decimal! tmp .05
unless tmp: select atts "distance" [tmp: 5 append atts ["distance" none]] atts/("distance"): round/to scale-xy * to decimal! tmp .05
) |
"MorphSegment" (
if tmp: select atts "startPointA" [resize-point tmp]
if tmp: select atts "startPointB" [resize-point tmp]
parse-xfl content
) |
"MorphCurves" (
if tmp: select atts "controlPointA" [resize-point tmp]
if tmp: select atts "controlPointB" [resize-point tmp]
if tmp: select atts "anchorPointA" [resize-point tmp]
if tmp: select atts "anchorPointB" [resize-point tmp]
parse-xfl content
) |
"MorphHint" (
if tmp: select atts "startPoint" [resize-point tmp]
if tmp: select atts "endPoint" [resize-point tmp]
parse-xfl content
) |
"DOMDynamicText" (
if atts [
if tmp: select atts "width" [atts/("width"): round/to scale-x * to decimal! tmp .05]
if tmp: select atts "height" [atts/("height"): round/to scale-y * to decimal! tmp .05]
]
parse-xfl content
) |
"DOMTextAttrs" (
if atts [
if tmp: select atts "letterSpacing" [atts/("letterSpacing"): round/to scale-xy * to decimal! tmp .05]
if tmp: select atts "indent" [atts/("indent"): round/to scale-xy * to decimal! tmp .05]
if tmp: select atts "leftMargin" [atts/("leftMargin"): round/to scale-xy * to decimal! tmp .05]
if tmp: select atts "rightMargin" [atts/("rightMargin"): round/to scale-xy * to decimal! tmp .05]
unless tmp: select atts "lineSpacing" [tmp: 2 append atts ["lineSpacing" none]]
atts/("lineSpacing"): round/to scale-xy * to decimal! tmp .05
unless tmp: select atts "size" [tmp: 12 append atts ["size" none]]
atts/("size"): tmp: round/to scale-xy * to decimal! tmp .05
unless find atts "bitmapSize" [append atts ["bitmapSize" none]]
atts/("bitmapSize"): to-integer 20 * tmp
]
) |
"SoundEnvelope" |
"tweens" |
"color" |
"AdjustColorFilter" |
"characters" (
probe content
if content [replace/all content/1 "^M" "
"]
)
]
DOMShape-rsz [
[
"transformationPoint" |
"matrix" |
"strokes" |
"fills" |
"edges" |
"fill" |
"FillStyle" |
"RadialGradient" |
"LinearGradient" |
"BitmapFill" |
["SolidStroke" | "StippleStroke" | "RaggedStroke"] (
either tmp: select atts "weight" [
atts/("weight"): max .5 round/to scale-xy * to decimal! tmp .01
][
repend atts ["weight" max .5 round/to scale-xy * 1.0 .01]
]
if all [1 > atts/("weight") tmp: select atts "solidStyle" tmp = "hairline"][
atts/("solidStyle"): "solid"
]
)|
"StrokeStyle"
] (
parse-xfl content
) |
"Edge" (
case [
tmp: select atts "cubics" [
comment {
ch_cubics_marks: charset "![]/|();,Qq ^-"
use [s e x y][
parse/all tmp [
some [
any ch_cubics_marks
s:
[copy x rl_edgNumber (x: load x) | rl_hexNum (x: n)]
e: (s: change/part s (round scale-x * x) e) :s
any ch_cubics_marks
s:
[copy y rl_edgNumber (y: load y) | rl_hexNum (y: n)]
e: (s: change/part s (round scale-y * y) e) :s
]
]
]}
clear current-node
]
all [
;false
tmp: select atts "edges"
] [
use [s e x y][
parse/all tmp [
some [
SP [
[#"!" | #"[" | #"]" | #"/" | #"|"]
some [
SP
s:
[copy x rl_edgNumber (x: load x) | rl_hexNum (x: n)]
e: (s: change/part s (form-float round/to scale-x * x .5) e) :s
SP
s:
[copy y rl_edgNumber (y: load y) | rl_hexNum (y: n)]
e: (s: change/part s (form-float round/to scale-y * y .5) e) :s
opt [#"S" ch_digits]
;opt [s: #"S" ch_digits e: (e: remove/part s e) :e]
]
;remove optional "select" information
]
]
]
]
]
]
) |
"Matrix" (
if atts [
if find ["RadialGradient" "LinearGradient"] nodes-stack/(-3)/1 [
if find atts "a" [atts/("a"): scale-x * to decimal! atts/("a")]
if find atts "b" [atts/("b"): scale-y * to decimal! atts/("b")]
if find atts "c" [atts/("c"): scale-x * to decimal! atts/("c")]
if find atts "d" [atts/("d"): scale-y * to decimal! atts/("d")]
]
if find atts "tx" [atts/("tx"): round/to scale-x * to decimal! atts/("tx") .05]
if find atts "ty" [atts/("ty"): round/to scale-y * to decimal! atts/("ty") .05]
]
) |
"Point" (
if atts [
if find atts "x" [atts/("x"): round/to scale-x * to decimal! atts/("x") .05]
if find atts "y" [atts/("y"): round/to scale-y * to decimal! atts/("y") .05]
]
) |
"GradientEntry" |
"SolidColor" |
"DottedStroke"
]
] |
"""
euclidean_graph(points::Matrix, G; L=1., p=2., cutoff=Inf, bc=:periodic)
Given the `d×N` matrix `points` builds an Euclidean graph of `N` vertices
according to the following procedure.
Defining the `d`-dimensional vectors `x[i] = points[:,i]`, an edge between
vertices `i` and `j` is inserted if `norm(x[i]-x[j], p) < cutoff`.
In case of negative `cutoff` instead every edge is inserted.
For `p=2` we have the standard Euclidean distance.
Set `bc=:periodic` to impose periodic boundary conditions in the box ``[0,L]^d``.
Set `bc=:open` for open boundary condition. In this case the keyword argument `L`
will be ignored.
Returns a graph and Dict containing the distance on each edge.
"""
function euclidean_graph(points::Matrix, ::Type{G} = Graph;
L=1., p=2., cutoff=Inf, bc=:open) where G<:AGraph
d, N = size(points)
g = G(N)
weights = Dict{Edge,Float64}()
bc ∉ [:periodic,:open] && error("Not a valid boundary condition.")
if bc == :periodic
maximum(points) > L && error("Some points are outside the box of size $L.")
end
for i=1:N
for j=i+1:N
if bc == :open
Δ = points[:,i] .- points[:,j]
elseif bc == :periodic
Δ = abs.(points[:,i] .- points[:,j])
Δ = min.(L .- Δ, Δ)
end
dist = norm(Δ, p)
if dist < cutoff
e = Edge(i,j)
add_edge!(g, e)
weights[e] = dist
end
end
end
return g, weights
end
|
#!/usr/bin/env Rscript
# Parse command-line args
library(argparser, quietly = TRUE)
library(readr)
p <- arg_parser("Merge BamInfo files")
p <- add_argument(p, 'out_prefix', type = "character",
help = 'Output prefix')
p <- add_argument(p, '--bam_info_files', type = "character",
nargs = Inf, help = 'BamInfo files')
argv <- parse_args(p)
# Load all the input BAM info files and merge them
# These were all written with `write.table`
input_paths <- argv$bam_info_files
print(input_paths)
merged.df <- read_tsv(input_paths[1])
for (i in seq(2, length(input_paths))) {
print(i)
new.df <- read_tsv(input_paths[i])
merged.df <- rbind(merged.df, new.df)
rm(new.df)
}
# Export
output_file_name <- paste0(argv$out_prefix, '.bam_info.tsv')
write_tsv(merged.df, path = output_file_name)
|
import hanoi
import hanoiinteractive
open hanoi hanoi.tower
open hanoitactics
namespace testGames
/-
md a b = move disk from tower a to tower b
finish_game = check if you're done!
-/
example : game' 1 :=
begin [hanoi_tactic]
md a b,
md b c,
finish_game,
end
example : game' 3 :=
begin [hanoi_tactic]
md a c,
md a b,
md c b,
md a c,
md b a,
md b c,
md a c,
finish_game,
end
example : game' 3 :=
begin [hanoi_tactic]
sorry
end
end testGames |
module Js.DOM.Document
import Control.Monad.Syntax
import Js
import Js.Object
import Js.DOM.Element
%default total
%access export
getElement : (id : String) -> JS_IO Element
getElement = js "document.getElementById(%0)" (String -> JS_IO Ptr) >=> pure . MkElement
write : String -> JS_IO ()
write = js "document.write(%0)" (String -> JS_IO ())
|
context("name_usage")
test_that("name_usage return parameter works", {
vcr::use_cassette("name_usage_return_param", {
meta <- name_usage(return = "meta")
dat <- name_usage(return = "data")
all <- name_usage(return = "all")
})
# meta
expect_is(meta, "data.frame")
expect_is(meta, "tbl_df")
expect_is(meta, "tbl")
expect_named(meta, c('offset', 'limit', 'endOfRecords'))
expect_equal(meta$limit, 100)
# data
expect_is(dat, "data.frame")
expect_is(dat, "tbl_df")
expect_is(dat, "tbl")
expect_is(dat, "gbif")
expect_true(any(grepl("datasetKey", names(dat))))
expect_equal(NROW(dat), 100)
# both meta and data
expect_is(all, "gbif")
expect_named(all, c('meta', 'data'))
expect_is(all$meta, "data.frame")
expect_is(all$meta, "tbl_df")
expect_is(all$meta, "tbl")
expect_named(all$meta, c('offset', 'limit', 'endOfRecords'))
expect_equal(all$meta$limit, 100)
expect_is(all$data, "data.frame")
expect_is(all$data, "tbl_df")
expect_is(all$data, "tbl")
expect_true(any(grepl("datasetKey", names(all$data))))
expect_equal(NROW(all$data), 100)
})
test_that("name_usage works", {
vcr::use_cassette("name_usage", {
tt <- name_usage(key = 1)
uu <- name_usage(key = 5231190, data = 'references')
}, preserve_exact_body_bytes = TRUE)
expect_is(tt, "gbif")
expect_is(tt$data$key, "integer")
expect_is(tt$data$kingdom, "character")
expect_is(uu, "gbif")
expect_is(uu$data, "data.frame")
expect_is(uu$data$sourceTaxonKey, "integer")
expect_is(uu$data$citation, "character")
# name_usage returns the correct value
expect_equal(tt$data$kingdom, "Animalia")
# name_usage returns the correct dimensions
expect_equal(length(tt), 2)
expect_equal(NROW(tt$data), 1)
expect_equal(length(uu), 2)
expect_equal(NCOL(uu$meta), 3)
expect_equal(NCOL(uu$data), 5)
})
test_that("name_usage with single taxon key and return='data': returns issues correctly", {
vcr::use_cassette("name_usage_return_data", {
x <- name_usage(key = 100037505, return = "data")
}, preserve_exact_body_bytes = TRUE)
expect_is(x, "data.frame")
expect_is(x, "tbl_df")
expect_is(x$key, "integer")
expect_is(x$issues, "character")
expect_is(x$issues[[1]], "character")
})
test_that("name_usage name route works", {
vcr::use_cassette("name_usage_data_name", {
rte1 <- name_usage(key = 5231190, data = 'name')
rte1a <- name_usage(key = 5127291, data = 'name')
})
expect_is(rte1, "gbif")
expect_is(rte1a, "gbif")
expect_true(NROW(rte1$meta) == 0)
expect_true(NROW(rte1a$meta) == 0)
expect_is(rte1$data, "data.frame")
expect_is(rte1a$data, "data.frame")
})
test_that("name_usage parents route works", {
vcr::use_cassette("name_usage_data_parents", {
rte2 <- name_usage(key = 5231190, data = 'parents')
rte2a <- name_usage(key = 5135783, data = 'parents')
}, preserve_exact_body_bytes = TRUE)
expect_is(rte2, "gbif")
expect_is(rte2a, "gbif")
expect_true(NROW(rte2$meta) == 0)
expect_true(NROW(rte2a$meta) == 0)
expect_is(rte2$data, "data.frame")
expect_is(rte2a$data, "data.frame")
})
test_that("name_usage children route works", {
vcr::use_cassette("name_usage_data_children", {
rte3 <- name_usage(key = 5231190, data = 'children')
rte3a <- name_usage(key = 5135790, data = 'children')
}, preserve_exact_body_bytes = TRUE)
expect_is(rte3, "gbif")
expect_is(rte3a, "gbif")
expect_is(rte3$meta, "data.frame")
expect_is(rte3a$meta, "data.frame")
expect_is(rte3$data, "data.frame")
expect_is(rte3a$data, "data.frame")
})
test_that("name_usage related route works", {
vcr::use_cassette("name_usage_data_related", {
rte4 <- name_usage(key = 5231190, data = 'related')
rte4a <- name_usage(key = 5135787, data = 'related')
}, preserve_exact_body_bytes = TRUE)
expect_is(rte4, "gbif")
expect_is(rte4a, "gbif")
expect_is(rte4$meta, "data.frame")
expect_is(rte4a$meta, "data.frame")
expect_is(rte4$data, "data.frame")
expect_is(rte4a$data, "data.frame")
})
test_that("name_usage synonyms route works", {
vcr::use_cassette("name_usage_data_synonyms", {
rte5 <- name_usage(key = 5231190, data = 'synonyms')
rte5a <- name_usage(key = 5135790, data = 'synonyms')
})
expect_is(rte5, "gbif")
expect_is(rte5a, "gbif")
expect_is(rte5$meta, "data.frame")
expect_is(rte5a$meta, "data.frame")
expect_equal(NROW(rte5$data), 1)
expect_is(rte5a$data, "data.frame")
})
test_that("name_usage descriptions route works", {
vcr::use_cassette("name_usage_data_descriptions", {
rte6 <- name_usage(key = 5231190, data = 'descriptions')
rte6a <- name_usage(key = 5127299, data = 'descriptions')
}, preserve_exact_body_bytes = TRUE)
expect_is(rte6, "gbif")
expect_is(rte6a, "gbif")
expect_is(rte6$meta, "data.frame")
expect_is(rte6a$meta, "data.frame")
expect_is(rte6$data, "data.frame")
expect_is(rte6a$data, "data.frame")
})
test_that("name_usage distributions route works", {
vcr::use_cassette("name_usage_data_distributions", {
rte7 <- name_usage(key = 5231190, data = 'distributions')
rte7a <- name_usage(key = 5231190, data = 'distributions')
}, preserve_exact_body_bytes = TRUE)
expect_is(rte7, "gbif")
expect_is(rte7a, "gbif")
expect_is(rte7$meta, "data.frame")
expect_is(rte7a$meta, "data.frame")
expect_is(rte7$data, "data.frame")
expect_is(rte7a$data, "data.frame")
})
test_that("name_usage media route works", {
vcr::use_cassette("name_usage_data_media", {
rte8 <- name_usage(key = 5231190, data = 'media')
rte8a <- name_usage(key = 5231190, data = 'media')
})
expect_is(rte8, "gbif")
expect_is(rte8a, "gbif")
expect_is(rte8$meta, "data.frame")
expect_is(rte8a$meta, "data.frame")
expect_is(rte8$data, "data.frame")
expect_is(rte8a$data, "data.frame")
})
test_that("name_usage references route works", {
vcr::use_cassette("name_usage_data_references", {
rte9 <- name_usage(key = 5231190, data = 'references')
rte9a <- name_usage(key = 5231190, data = 'references')
}, preserve_exact_body_bytes = TRUE)
expect_is(rte9, "gbif")
expect_is(rte9a, "gbif")
expect_is(rte9$meta, "data.frame")
expect_is(rte9a$meta, "data.frame")
expect_is(rte9$data, "data.frame")
expect_is(rte9a$data, "data.frame")
})
test_that("name_usage speciesProfiles route works", {
vcr::use_cassette("name_usage_data_speciesProfiles", {
rte10 <- name_usage(key = 5231190, data = 'speciesProfiles')
rte10a <- name_usage(key = 5136020, data = 'speciesProfiles')
})
expect_is(rte10, "gbif")
expect_is(rte10a, "gbif")
expect_is(rte10$meta, "data.frame")
expect_is(rte10a$meta, "data.frame")
expect_is(rte10$data, "data.frame")
expect_is(rte10a$data, "data.frame")
})
test_that("name_usage vernacularNames route works", {
vcr::use_cassette("name_usage_data_vernacularNames", {
rte11 <- name_usage(key = 5231190, data = 'vernacularNames')
rte11a <- name_usage(key = 5136034, data = 'vernacularNames')
}, preserve_exact_body_bytes = TRUE)
expect_is(rte11, "gbif")
expect_is(rte11a, "gbif")
expect_is(rte11$meta, "data.frame")
expect_is(rte11a$meta, "data.frame")
expect_is(rte11$data, "data.frame")
expect_is(rte11a$data, "data.frame")
})
test_that("name_usage typeSpecimens route works", {
vcr::use_cassette("name_usage_data_typeSpecimens", {
rte12 <- name_usage(key = 5231190, data = 'typeSpecimens')
rte12a <- name_usage(key = 5097652, data = 'typeSpecimens')
})
expect_is(rte12, "gbif")
expect_is(rte12a, "gbif")
expect_is(rte12$meta, "data.frame")
expect_is(rte12a$meta, "data.frame")
expect_equal(NROW(rte12$data), 0)
# this used to be up, seems to be down now, comment on 2015-12-04
expect_equal(NROW(rte12a$data), 0)
})
test_that("name_usage fails correctly", {
vcr::use_cassette("name_usage_fails_well", {
### verbatim not working right now for some unknown reason
expect_error(name_usage(key = 3119195, data = 'verbatim'))
# Select many options, doesn't work
expect_error(name_usage(key = 3119195, data = c('media', 'synonyms')))
# fails with more than 1 value
keys <- c("73605f3a-af85-4ade-bbc5-522bfb90d847",
"d7c60346-44b6-400d-ba27-8d3fbeffc8a5")
expect_error(name_usage(datasetKey = keys),
"length\\(datasetKey\\) == 1 is not TRUE")
expect_error(name_usage(language = c('spanish', 'german')),
"length\\(language\\) == 1 is not TRUE")
expect_error(name_usage(name = c('Quercus', 'Puma')),
"length\\(name\\) == 1 is not TRUE")
expect_error(name_usage(rank = c('GENUS', 'SPECIES')),
"length\\(rank\\) == 1 is not TRUE")
})
})
# paging
# Commented:it takes too much time.
# Uncomment after introducing test caching with vcr package)
# test_that("paging: class data and meta not modified by paging", {
# skip_on_cran()
#
# bb1 <- name_usage(datasetKey = "9ff7d317-609b-4c08-bd86-3bc404b77c42",
# limit = 1)
# bb2 <- name_usage(datasetKey = "9ff7d317-609b-4c08-bd86-3bc404b77c42",
# limit = 1789)
# expect_true(all(class(bb1) == class(bb2)))
# expect_true(all(class(bb1$meta) == class(bb2$meta)))
# expect_true(all(class(bb1$data) == class(bb2$data)))
# })
#
# test_that("paging: name_usage returns all records from dataset: limit > n_records", {
# skip_on_cran()
#
# cc <- name_usage(datasetKey = "9ff7d317-609b-4c08-bd86-3bc404b77c42",
# limit = 5000)
# expect_equal(cc$meta$offset, 2000)
# expect_lt(cc$meta$limit, 1000)
# expect_gt(nrow(cc$data), 2000)
# })
#
# test_that("paging: name_usage returns as many records as asked via limit", {
# skip_on_cran()
#
# dd <- name_usage(datasetKey = "9ff7d317-609b-4c08-bd86-3bc404b77c42",
# limit = 1329)
# expect_equal(dd$meta$offset, 1000)
# expect_equal(dd$meta$limit, 329)
# expect_equal(nrow(dd$data), 1329)
#
# ee <- name_usage(datasetKey = "9ff7d317-609b-4c08-bd86-3bc404b77c42",
# limit = 1001)
# expect_equal(ee$meta$offset, 1000)
# expect_equal(ee$meta$limit, 1)
# expect_equal(nrow(ee$data), 1001)
# })
|
using JuLIP: decode_dict
using SHIPs.JacobiPolys: Jacobi
import Base: Dict, convert, ==
import JuLIP: cutoff
export PolyTransform, rbasis, PolyCutoff1s, PolyCutoff2s,
PolyTransformCut
abstract type DistanceTransform end
abstract type DistanceTransformCut <: DistanceTransform end
poly_trans(p, r0, r) = @fastmath(((1+r0)/(1+r))^p)
poly_trans_d(p, r0, r) = @fastmath((-p/(1+r0)) * ((1+r0)/(1+r))^(p+1))
poly_trans_inv(p, r0, x) = ( (1+r0)/(x^(1/p)) - 1 )
"""
Implements the distance transform
```
r -> ( (1+r0)/(1+r))^p
```
Constructor:
```
PolyTransform(p, r0)
```
"""
struct PolyTransform{TP, T} <: DistanceTransform
p::TP
r0::T
end
Dict(T::PolyTransform) =
Dict("__id__" => "SHIPs_PolyTransform", "p" => T.p, "r0" => T.r0)
PolyTransform(D::Dict) = PolyTransform(D["p"], D["r0"])
convert(::Val{:SHIPs_PolyTransform}, D::Dict) = PolyTransform(D)
transform(t::PolyTransform, r::Number) = poly_trans(t.p, t.r0, r)
transform_d(t::PolyTransform, r::Number) = poly_trans_d(t.p, t.r0, r)
inv_transform(t::PolyTransform, x::Number) = poly_trans_inv(t.p, t.r0, x)
"""
Implements the distance transform
```
r -> ( (1+r0)/(1+r))^p - c0 - c1 (r - rcut)
```
Constructor:
```
PolyTransformCut(p, r0)
```
"""
struct PolyTransformCut{TP, T} <: DistanceTransformCut
p::TP
r0::T
c0::T
c1::T
rcut::T
end
Dict(T::PolyTransformCut) =
Dict("__id__" => "SHIPs_PolyTransform",
"p" => T.p, "r0" => T.r0, "rcut" => rcut)
PolyTransformCut(D::Dict) = PolyTransformCut(D["p"], D["r0"], D["rcut"])
convert(::Val{:SHIPs_PolyTransformCut}, D::Dict) = PolyTransformCut(D)
transform(t::PolyTransformCut, r::Number) =
(poly_trans(t.p, t.r0, r) + t.c0 + t.c1 * (r - t.rcut)) * (r < t.rcut)
transform_d(t::PolyTransformCut, r::Number) =
(poly_trans_d(t.p, t.r0, r) + t.c1) * (r < t.rcut)
function PolyTransformCut(p, r0, rcut)
c0 = - poly_trans(p, r0, rcut)
c1 = - poly_trans_d(p, r0, rcut)
return PolyTransformCut(p, r0, c0, c1, rcut)
end
cutoff(trans::PolyTransformCut) = trans.rcut
abstract type PolyCutoff end
"""
Implements the one-sided cutoff
```
r -> (x - xu)^p
```
Constructor:
```
PolyCutoff1s(p, rcut)
```
"""
struct PolyCutoff1s{P} <: PolyCutoff
valP::Val{P}
rl::Float64
ru::Float64
PolyCutoff1s(valP::Val{P}, rl::Real, ru::Real) where {P} = (
((P isa Integer) && (P > 0)) ? new{P}(valP, Float64(rl), Float64(ru))
: error("P must be a positive integer") )
end
PolyCutoff1s(p::Integer, ru) = PolyCutoff1s(Val(Int(p)), 0.0, ru)
PolyCutoff1s(p::Integer, rl, ru) = PolyCutoff1s(Val(Int(p)), rl, ru)
Dict(C::PolyCutoff1s{P}) where {P} =
Dict("__id__" => "SHIPs_PolyCutoff1s",
"P" => P, "rl" => C.rl, "ru" => C.ru)
PolyCutoff1s(D::Dict) = PolyCutoff1s(D["P"], D["rl"], D["ru"])
convert(::Val{:SHIPs_PolyCutoff1s}, D::Dict) = PolyCutoff1s(D)
# what happened to @pure ??? => not exported anymore
fcut(C::PolyCutoff1s{P}, r::T, x::T) where {P, T} =
r < C.ru ? @fastmath( (1 - x)^P ) : zero(T)
fcut_d(C::PolyCutoff1s{P}, r::T, x::T) where {P, T} =
r < C.ru ? @fastmath( - P * (1 - x)^(P-1) ) : zero(T)
"""
Implements the two-sided cutoff
```
r -> (x - xu)^p (x-xl)^p
```
Constructor:
```
PolyCutoff2s(p, rl, ru)
```
where `rl` is the inner cutoff and `ru` the outer cutoff.
"""
struct PolyCutoff2s{P} <: PolyCutoff
valP::Val{P}
rl::Float64
ru::Float64
PolyCutoff2s(valP::Val{P}, rl::Real, ru::Real) where {P} = (
((P isa Integer) && (P > 0)) ? new{P}(valP, Float64(rl), Float64(ru))
: error("P must be a positive integer") )
end
PolyCutoff2s(p::Integer, rl, ru) = PolyCutoff2s(Val(Int(p)), rl, ru)
Dict(C::PolyCutoff2s{P}) where {P} =
Dict("__id__" => "SHIPs_PolyCutoff2s", "P" => P,
"rl" => C.rl, "ru" => C.ru)
PolyCutoff2s(D::Dict) = PolyCutoff2s(D["P"], D["rl"], D["ru"])
convert(::Val{:SHIPs_PolyCutoff2s}, D::Dict) = PolyCutoff2s(D)
fcut(C::PolyCutoff2s{P}, r::T, x) where {P, T} =
C.rl < r < C.ru ? @fastmath( (1 - x^2)^P ) : zero(T)
fcut_d(C::PolyCutoff2s{P}, r::T, x) where {P, T} =
C.rl < r < C.ru ? @fastmath( -2*P * x * (1 - x^2)^(P-1) ) : zero(T)
struct OneCutoff
rcut::Float64
end
fcut(C::OneCutoff, r, x) = r < rcut ? one(r) : zero(r)
fcut_d(C::OneCutoff, r, x) = zero(r)
# Transformed Jacobi Polynomials
# ------------------------------
# these define the radial components of the polynomials
struct TransformedJacobi{T, TT, TM}
J::Jacobi{T}
trans::TT # coordinate transform
mult::TM # a multiplier function (cutoff)
rl::T # lower bound r
ru::T # upper bound r
tl::T # bound t(ru)
tu::T # bound t(rl)
end
==(J1::TransformedJacobi, J2::TransformedJacobi) = (
(J1.J == J2.J) &&
(J1.trans == J2.trans) &&
(J1.mult == J2.mult) &&
(J1.rl == J2.rl) &&
(J1.ru == J2.ru) )
TransformedJacobi(J, trans, mult, rl, ru) =
TransformedJacobi(J, trans, mult, rl, ru,
transform(trans, rl), transform(trans, ru) )
Dict(J::TransformedJacobi) = Dict(
"__id__" => "SHIPs_TransformedJacobi",
"a" => J.J.α,
"b" => J.J.β,
"deg" => length(J.J) - 1,
"rl" => J.rl,
"ru" => J.ru,
"trans" => Dict(J.trans),
"cutoff" => Dict(J.mult),
"skip0" => J.J.skip0
)
TransformedJacobi(D::Dict) =
TransformedJacobi(
Jacobi(D["a"], D["b"], D["deg"],
skip0 = haskey(D, "skip0") ? D["skip0"] : false),
decode_dict(D["trans"]),
decode_dict(D["cutoff"]),
D["rl"],
D["ru"]
)
convert(::Val{:SHIPs_TransformedJacobi}, D::Dict) = TransformedJacobi(D)
Base.length(J::TransformedJacobi) = length(J.J)
cutoff(J::TransformedJacobi) = J.ru
transform(J::TransformedJacobi, r) = transform(J.trans, r)
transform_d(J::TransformedJacobi, r) = transform_d(J.trans, r)
fcut(J::TransformedJacobi, r, x) = fcut(J.mult, r, x)
fcut_d(J::TransformedJacobi, r, x) = fcut_d(J.mult, r, x)
SHIPs.alloc_B( J::TransformedJacobi{T}, args...) where {T} =
Vector{T}(undef, length(J))
SHIPs.alloc_dB(J::TransformedJacobi{T}, args...) where {T} =
Vector{T}(undef, length(J))
function eval_basis!(P, tmp, J::TransformedJacobi, r)
N = length(J)-1
@assert length(P) >= N+1
# transform coordinates
t = transform(J.trans, r)
x = -1 + 2 * (t - J.tl) / (J.tu-J.tl)
# evaluate the cutoff multiplier
# the (J.tu-J.tl) / 2 factor makes the basis orthonormal
# (just for the kick of it...)
fc = fcut(J, r, x) * sqrt(abs(2 / (J.tu-J.tl)))
if fc == 0
fill!(P, 0.0)
else
# evaluate the actual Jacobi polynomials
eval_basis!(P, nothing, J.J, x)
for n = 1:N+1
@inbounds P[n] *= fc
end
end
return P
end
function eval_basis_d!(P, dP, tmp, J::TransformedJacobi, r)
N = length(J)-1
@assert length(P) >= N+1
# transform coordinates
t = transform(J.trans, r)
x = -1 + 2 * (t - J.tl) / (J.tu-J.tl)
dx = (2/(J.tu-J.tl)) * transform_d(J.trans, r)
# evaluate the cutoff multiplier and chain rule
fc = fcut(J, r, x) * sqrt(abs(2 / (J.tu-J.tl)))
if fc == 0
fill!(P, 0.0)
fill!(dP, 0.0)
else
fc_d = fcut_d(J, r, x) * sqrt(abs(2 / (J.tu-J.tl)))
# evaluate the actual Jacobi polynomials + derivatives w.r.t. x
eval_basis_d!(P, dP, nothing, J.J, x)
for n = 1:N+1
@inbounds p = P[n]
@inbounds dp = dP[n]
@inbounds P[n] = p * fc
@inbounds dP[n] = (dp * fc + p * fc_d) * dx
end
end
return dP
end
TransformedJacobi(maxdeg::Integer,
trans::DistanceTransform,
cut::PolyCutoff1s{P}) where {P} =
TransformedJacobi( Jacobi(2*P, 0, maxdeg), trans, cut, cut.rl, cut.ru)
TransformedJacobi(maxdeg::Integer,
trans::DistanceTransform,
cut::PolyCutoff2s{P}) where {P} =
TransformedJacobi( Jacobi(2*P, 2*P, maxdeg), trans, cut, cut.rl, cut.ru)
TransformedJacobi(maxdeg::Integer,
trans::DistanceTransformCut,
rl = 0.0) =
TransformedJacobi( Jacobi(0, 0, maxdeg, skip0=true), trans,
OneCutoff(cutoff(trans)),
rl, cutoff(trans))
|
lemma eventually_nhds_ball: "d > 0 \<Longrightarrow> eventually (\<lambda>x. x \<in> ball z d) (nhds z)" |
library(broom)
library(cowplot)
library(crayon)
library(data.table)
library(dendextend)
library(DEoptimR)
library(directlabels)
library(dplyr)
library(extrafont)
library(extrafontdb)
library(flexmix)
library(fontcm)
library(fontLiberation)
library(fontquiver)
library(fpc)
library(ggfortify)
library(ggimage)
library(ggplot2)
library(ggplotgui)
library(ggplotify)
library(ggpubr)
library(ggrepel)
library(ggridges)
library(ggsci)
library(git2r)
library(GlobalOptions)
library(graphics)
library(grDevices)
library(grid)
library(gridExtra)
library(gridGraphics)
library(gtable)
library(highr)
library(kernlab)
library(labeling)
library(lattice)
library(latticeExtra)
library(lubridate)
library(magick)
library(magrittr)
library(Matrix)
library(mclust)
library(methods)
library(modelr)
library(permute)
library(pillar)
library(plotfunctions)
#library(plotly)
library(prabclus)
library(psych)
library(pvclust)
library(qqplotr)
library(quadprog)
library(RColorBrewer)
library(readr)
library(reshape2)
library(robustbase)
library(stats)
library(tibble)
library(tidyverse)
library(trimcluster)
#library(violinmplot)
library(utf8)
library(vegan)
library(viridis)
library(viridisLite)
library(wesanderson)
|
(* Property from Case-Analysis for Rippling and Inductive Proof,
Moa Johansson, Lucas Dixon and Alan Bundy, ITP 2010.
This Isabelle theory is produced using the TIP tool offered at the following website:
https://github.com/tip-org/tools
This file was originally provided as part of TIP benchmark at the following website:
https://github.com/tip-org/benchmarks
Yutaka Nagashima at CIIRC, CTU changed the TIP output theory file slightly
to make it compatible with Isabelle2017.*)
theory TIP_prop_52
imports "../../Test_Base"
begin
datatype 'a list = nil2 | cons2 "'a" "'a list"
datatype Nat = Z | S "Nat"
fun y :: "'a list => 'a list => 'a list" where
"y (nil2) y2 = y2"
| "y (cons2 z2 xs) y2 = cons2 z2 (y xs y2)"
fun x :: "Nat => Nat => bool" where
"x (Z) (Z) = True"
| "x (Z) (S z2) = False"
| "x (S x2) (Z) = False"
| "x (S x2) (S y22) = x x2 y22"
fun rev :: "'a list => 'a list" where
"rev (nil2) = nil2"
| "rev (cons2 y2 xs) = y (rev xs) (cons2 y2 (nil2))"
fun count :: "Nat => Nat list => Nat" where
"count z (nil2) = Z"
| "count z (cons2 z2 ys) =
(if x z z2 then S (count z ys) else count z ys)"
theorem property0 :
"((count n xs) = (count n (rev xs)))"
oops
end
|
#include <boost/python.hpp>
#include <boost/cstdint.hpp>
#include <Magick++/Drawable.h>
#include <Magick++.h>
using namespace boost::python;
void __PathQuadraticCurvetoArgs()
{
class_< Magick::PathQuadraticCurvetoArgs >("PathQuadraticCurvetoArgs", init< >())
.def(init< double, double, double, double >())
.def(init< const Magick::PathQuadraticCurvetoArgs& >())
.def("x1", (void (Magick::PathQuadraticCurvetoArgs::*)(double) )&Magick::PathQuadraticCurvetoArgs::x1)
.def("x1", (double (Magick::PathQuadraticCurvetoArgs::*)() const)&Magick::PathQuadraticCurvetoArgs::x1)
.def("y1", (void (Magick::PathQuadraticCurvetoArgs::*)(double) )&Magick::PathQuadraticCurvetoArgs::y1)
.def("y1", (double (Magick::PathQuadraticCurvetoArgs::*)() const)&Magick::PathQuadraticCurvetoArgs::y1)
.def("x", (void (Magick::PathQuadraticCurvetoArgs::*)(double) )&Magick::PathQuadraticCurvetoArgs::x)
.def("x", (double (Magick::PathQuadraticCurvetoArgs::*)() const)&Magick::PathQuadraticCurvetoArgs::x)
.def("y", (void (Magick::PathQuadraticCurvetoArgs::*)(double) )&Magick::PathQuadraticCurvetoArgs::y)
.def("y", (double (Magick::PathQuadraticCurvetoArgs::*)() const)&Magick::PathQuadraticCurvetoArgs::y)
.def( self < self )
.def( self > self )
.def( self != self )
.def( self == self )
.def( self <= self )
.def( self >= self )
;
}
|
The re @-@ recorded version of " West End Girls " was released in the United Kingdom in October 1985 , debuting on the UK Singles Chart at number 80 , and within eight weeks of its release it had reached the top of the chart . It maintained the number one position for two weeks and received a gold certification by the British Phonographic Industry ( BPI ) in January 1986 . Across Europe , " West End Girls " also topped the singles chart in Norway , as well as peaking in the top three in Belgium , Germany , Ireland , the Netherlands , Sweden , and Switzerland .
|
#本文需要用到的 R 包
library(vegan) #用于计算 Shannon 熵指数、Simpson 指数、Chao1 指数、ACE 指数等,同时用于抽样
library(picante) #用于计算 PD_whole_tree,若不计算它就无需加载。事实上,picante 包加载时默认同时加载 vegan
library(ggplot2) #用于 ggplot2 作图
library(doBy) #用于分组统计(第 97 行使用到)
library(ggalt) #用于绘制拟合曲线(第 138 行使用到)
library(BiodiversityR) #用于绘制 Rank-abundance 曲线(第 160 行使用到)
##定义函数
#计算多种 Alpha 多样性指数,结果返回至向量
#各子函数的用法详见 http://blog.sciencenet.cn/blog-3406804-1179983.html
alpha_index <- function(x, method = 'richness', tree = NULL, base = exp(1)) {
if (method == 'richness') result <- rowSums(x > 0) #丰富度指数
else if (method == 'chao1') result <- estimateR(x)[3, ] #Chao1 指数
else if (method == 'ace') result <- estimateR(x)[5, ] #ACE 指数
else if (method == 'shannon') result <- diversity(x, index = 'shannon', base = base) #Shannon 指数
else if (method == 'simpson') result <- diversity(x, index = 'simpson') #Gini-Simpson 指数
else if (method == 'pielou') result <- diversity(x, index = 'shannon', base = base) / log(estimateR(x)[1, ], base) #Pielou 均匀度
else if (method == 'gc') result <- 1 - rowSums(x == 1) / rowSums(x) #goods_coverage
else if (method == 'pd' & !is.null(tree)) { #PD_whole_tree
pd <- pd(x, tree, include.root = FALSE)
result <- pd[ ,1]
names(result) <- rownames(pd)
}
result
}
#根据抽样步长(step),统计每个稀释梯度下的 Alpha 多样性指数,结果返回至列表
alpha_curves <- function(x, step, method = 'richness', rare = NULL, tree = NULL, base = exp(1)) {
x_nrow <- nrow(x)
if (is.null(rare)) rare <- rowSums(x) else rare <- rep(rare, x_nrow)
alpha_rare <- list()
for (i in 1:x_nrow) {
step_num <- seq(0, rare[i], step)
if (max(step_num) < rare[i]) step_num <- c(step_num, rare[i])
alpha_rare_i <- NULL
for (step_num_n in step_num) alpha_rare_i <- c(alpha_rare_i, alpha_index(x = rrarefy(x[i, ], step_num_n), method = method, tree = tree, base = base))
names(alpha_rare_i) <- step_num
alpha_rare <- c(alpha_rare, list(alpha_rare_i))
}
names(alpha_rare) <- rownames(x)
alpha_rare
}
##测试
#统计 OTU 丰度表中各样本的 Shannon 指数,对数底数使用 e
# shannon_index <- alpha_index(otu, method = 'shannon', base = exp(1))
#以 1000 条序列为抽样步长,依次对 OTU 表稀释抽样,直到最大序列深度;并统计各抽样梯度下的 OTU 丰度表中各样本的 Shannon 指数,对数底数使用 e
# shannon_curves <- alpha_curves(otu, step = 1000, method = 'shannon', base = exp(1))
##以下以物种丰富度指数为例绘制 Alpha 多样性曲线(当为丰富度指数时,另一个名称即为常说的稀释曲线,或物种累计曲线)
#读取 OTU 丰度表
if(1) {
setwd('~/Documents/R/Numerical_Ecology/Hong/')
otu <- read.delim('Tomato.txt', row.names = 1, sep = '\t', stringsAsFactors = FALSE, check.names = FALSE)
otu <- t(otu)
}
#以 2000 步长(step=2000)为例统计
richness_curves <- alpha_curves(otu, step = 2000, method = 'richness')
#获得 ggplot2 作图文件
plot_richness <- data.frame()
for (i in names(richness_curves)) {
richness_curves_i <- (richness_curves[[i]])
richness_curves_i <- data.frame(rare = names(richness_curves_i), alpha = richness_curves_i, sample = i, stringsAsFactors = FALSE)
plot_richness <- rbind(plot_richness, richness_curves_i)
}
rownames(plot_richness) <- NULL
plot_richness$rare <- as.numeric(plot_richness$rare)
plot_richness$alpha <- as.numeric(plot_richness$alpha)
#ggplot2 作图
ggplot(plot_richness, aes(rare, alpha, color = sample)) +
geom_line() +
labs(x = 'Number of sequences', y = 'Richness', color = NULL) +
theme(panel.grid = element_blank(), panel.background = element_rect(fill = 'transparent', color = 'black'), legend.key = element_rect(fill = 'transparent')) +
geom_vline(xintercept = min(rowSums(otu)), linetype = 2) +
scale_x_continuous(breaks = seq(0, 30000, 5000), labels = as.character(seq(0, 30000, 5000)))
##多计算几次以获取均值 ± 标准差,然后再展示出也是一个不错的选择
#重复抽样 5 次
plot_richness <- data.frame()
for (n in 1:5) {
richness_curves <- alpha_curves(otu, step = 2000, method = 'richness')
for (i in names(richness_curves)) {
richness_curves_i <- (richness_curves[[i]])
richness_curves_i <- data.frame(rare = names(richness_curves_i), alpha = richness_curves_i, sample = i, stringsAsFactors = FALSE)
plot_richness <- rbind(plot_richness, richness_curves_i)
}
}
#计算均值 ± 标准差(doBy 包中的 summaryBy() 函数)
plot_richness_stat <- summaryBy(alpha~sample+rare, plot_richness, FUN = c(mean, sd))
plot_richness_stat$rare <- as.numeric(plot_richness_stat$rare)
plot_richness_stat[which(plot_richness_stat$rare == 0),'alpha.sd'] <- NA
#ggplot2 作图
ggplot(plot_richness_stat, aes(rare, alpha.mean, color = sample)) +
geom_line() +
geom_point() +
geom_errorbar(aes(ymin = alpha.mean - alpha.sd, ymax = alpha.mean + alpha.sd), width = 500) +
labs(x = 'Number of sequences', y = 'Richness', color = NULL) +
theme(panel.grid = element_blank(), panel.background = element_rect(fill = 'transparent', color = 'black'), legend.key = element_rect(fill = 'transparent')) +
geom_vline(xintercept = min(rowSums(otu)), linetype = 2) +
scale_x_continuous(breaks = seq(0, 30000, 5000), labels = as.character(seq(0, 30000, 5000)))
##对于 Shannon 指数等,方法类似
#以 2000 步长(step=2000)为例统计每个稀释梯度下的 Shannon 指数,Shannon 公式的对数底数默认为 e,若有需要可更改(例如 2)
shannon_curves <- alpha_curves(otu, step = 2000, method = 'shannon', base = 2)
#获得 ggplot2 作图文件(略,参见上述)
#ggplot2 作图(略,参见上述)
##若简单的“geom_line()”样式波动幅度过大,不平滑等,可以尝试拟合曲线的样式
#获得作图数据。前面多生成一个点,使得 Shannon 拟合曲线更加平滑(你把 shannon_curves1 注释掉就知道我说的啥了)
shannon_curves1 <- alpha_curves(otu, step = 200, rare = 200, method = 'shannon')
shannon_curves2 <- alpha_curves(otu, step = 2000, method = 'shannon')
shannon_curves <- c(shannon_curves1, shannon_curves2)
plot_shannon <- data.frame()
for (i in 1:length(shannon_curves)) {
shannon_curves_i <- shannon_curves[[i]]
shannon_curves_i <- data.frame(rare = names(shannon_curves_i), alpha = shannon_curves_i, sample = names(shannon_curves)[i], stringsAsFactors = FALSE)
plot_shannon <- rbind(plot_shannon, shannon_curves_i)
}
rownames(plot_shannon) <- NULL
plot_shannon$rare <- as.numeric(plot_shannon$rare)
plot_shannon$alpha <- as.numeric(plot_shannon$alpha)
plot_shannon <- plot_shannon[order(plot_shannon$sample, plot_shannon$rare), ]
#ggplot2 作图(使用到 ggalt 包的 geom_xspline() 绘制平滑拟合线)
ggplot(plot_shannon, aes(rare, alpha, color = sample)) +
geom_xspline() +
labs(x = 'Number of sequences', y = 'Shannon', color = NULL) +
theme(panel.grid = element_blank(), panel.background = element_rect(fill = 'transparent', color = 'black'), legend.key = element_rect(fill = 'transparent')) +
geom_vline(xintercept = min(rowSums(otu)), linetype = 2) +
scale_x_continuous(breaks = seq(0, 30000, 5000), labels = as.character(seq(0, 30000, 5000)))
# Above -------------------------------------------------------------------
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# ##对于 PD_whole_tree,除了 OTU 丰度表,还使用到进化树文件
# #加载 OTU 丰度表和进化树文件
# otu <- read.delim('otu_table.txt', row.names = 1, sep = '\t', stringsAsFactors = FALSE, check.names = FALSE)
# otu <- t(otu)
# # tree <- read.tree('otu_tree.tre')
#
# #以 2000 步长(step=2000)为例统计
# pd_curves <- alpha_curves(otu, tree = tree, step = 2000, method = 'pd')
#
# #统计及做图方法同上述
#
# ##Rank-abundance 曲线
# #统计(BiodiversityR 包 rankabundance() 实现 OTU 排序)
# otu_relative <- otu / rowSums(otu)
# rank_dat <- data.frame()
# for (i in rownames(otu_relative)) {
# rank_dat_i <- data.frame(rankabundance(subset(otu_relative, rownames(otu_relative) == i), digits = 6))[1:2]
# rank_dat_i$sample <- i
# rank_dat <- rbind(rank_dat, rank_dat_i)
# }
# rank_dat <- subset(rank_dat, rank_dat$abundance != 0)
#
# #ggplot2 作图
# ggplot(rank_dat, aes(rank, log(abundance, 10), color = sample)) +
# geom_line() +
# labs(x = 'OTUs rank', y = 'Relative adundance (%)', color = NULL) +
# theme(panel.grid = element_blank(), panel.background = element_rect(fill = 'transparent', color = 'black'), legend.key = element_rect(fill = 'transparent')) +
# scale_y_continuous(breaks = 0:-5, labels = c('100', '10', '1', '0.1', '0.01', '0.001'), limits = c(-5, 0))
|
If $h$ is eventually nonzero, then $f/h$ is in $L^1$ if and only if $g/h$ is in $L^1$. |
module Issue1078.A where
open import Common.Level using (Level)
|
function z = geoatan2(x, y)
%-------------------------------------------------------
% z = geoatan2(x, y);
% Yudan Yi, May 26, 2005
%-------------------------------------------------------
% return -pi~pi of y/x
z = 0.0;
if (abs(x)<1e-12) if (y>0) z = pi/2.0; else z =-pi/2.0; end; return; end;
z = atan(abs(y/x));
if (x>0)
if (y<0) z =-z; end; return;
else
if (y>0) z = pi-z; else z =-pi+z; end;
end
return;
|
[STATEMENT]
lemma set_tag_name_ok:
"type_wf h \<Longrightarrow> element_ptr |\<in>| element_ptr_kinds h \<Longrightarrow> h \<turnstile> ok (set_tag_name element_ptr tag)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>type_wf h; element_ptr |\<in>| element_ptr_kinds h\<rbrakk> \<Longrightarrow> h \<turnstile> ok set_tag_name element_ptr tag
[PROOF STEP]
apply(unfold type_wf_impl)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>ShadowRootClass.type_wf h; element_ptr |\<in>| element_ptr_kinds h\<rbrakk> \<Longrightarrow> h \<turnstile> ok set_tag_name element_ptr tag
[PROOF STEP]
unfolding set_tag_name_impl[unfolded a_set_tag_name_def]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>ShadowRootClass.type_wf h; element_ptr |\<in>| element_ptr_kinds h\<rbrakk> \<Longrightarrow> h \<turnstile> ok set_tag_name element_ptr tag
[PROOF STEP]
using get_M\<^sub>E\<^sub>l\<^sub>e\<^sub>m\<^sub>e\<^sub>n\<^sub>t_ok put_M\<^sub>E\<^sub>l\<^sub>e\<^sub>m\<^sub>e\<^sub>n\<^sub>t_ok
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>ShadowRootClass.type_wf ?h; ?ptr |\<in>| element_ptr_kinds ?h\<rbrakk> \<Longrightarrow> ?h \<turnstile> ok get_M\<^sub>E\<^sub>l\<^sub>e\<^sub>m\<^sub>e\<^sub>n\<^sub>t ?ptr ?getter
\<lbrakk>ShadowRootClass.type_wf ?h; ?ptr |\<in>| element_ptr_kinds ?h\<rbrakk> \<Longrightarrow> ?h \<turnstile> ok put_M\<^sub>E\<^sub>l\<^sub>e\<^sub>m\<^sub>e\<^sub>n\<^sub>t ?ptr ?setter ?v
goal (1 subgoal):
1. \<lbrakk>ShadowRootClass.type_wf h; element_ptr |\<in>| element_ptr_kinds h\<rbrakk> \<Longrightarrow> h \<turnstile> ok set_tag_name element_ptr tag
[PROOF STEP]
using CD.set_tag_name_ok CD.type_wf_impl ShadowRootClass.type_wf\<^sub>D\<^sub>o\<^sub>c\<^sub>u\<^sub>m\<^sub>e\<^sub>n\<^sub>t
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>ShadowRootClass.type_wf ?h; ?ptr |\<in>| element_ptr_kinds ?h\<rbrakk> \<Longrightarrow> ?h \<turnstile> ok get_M\<^sub>E\<^sub>l\<^sub>e\<^sub>m\<^sub>e\<^sub>n\<^sub>t ?ptr ?getter
\<lbrakk>ShadowRootClass.type_wf ?h; ?ptr |\<in>| element_ptr_kinds ?h\<rbrakk> \<Longrightarrow> ?h \<turnstile> ok put_M\<^sub>E\<^sub>l\<^sub>e\<^sub>m\<^sub>e\<^sub>n\<^sub>t ?ptr ?setter ?v
\<lbrakk>type_wf\<^sub>C\<^sub>o\<^sub>r\<^sub>e\<^sub>_\<^sub>D\<^sub>O\<^sub>M ?h; ?element_ptr |\<in>| element_ptr_kinds ?h\<rbrakk> \<Longrightarrow> ?h \<turnstile> ok set_tag_name ?element_ptr ?tag
type_wf\<^sub>C\<^sub>o\<^sub>r\<^sub>e\<^sub>_\<^sub>D\<^sub>O\<^sub>M = DocumentClass.type_wf
ShadowRootClass.type_wf ?h \<Longrightarrow> DocumentClass.type_wf ?h
goal (1 subgoal):
1. \<lbrakk>ShadowRootClass.type_wf h; element_ptr |\<in>| element_ptr_kinds h\<rbrakk> \<Longrightarrow> h \<turnstile> ok set_tag_name element_ptr tag
[PROOF STEP]
by blast |
{-# OPTIONS --no-positivity-check #-}
module STLC.Coquand.Normalisation where
open import STLC.Coquand.Substitution public
--------------------------------------------------------------------------------
record 𝔐 : Set₁ where
field
𝒲 : Set
𝒢 : 𝒲 → Set
_⊒_ : 𝒲 → 𝒲 → Set
idₐ : ∀ {w} → w ⊒ w
_◇_ : ∀ {w w′ w″} → w″ ⊒ w′ → w′ ⊒ w → w″ ⊒ w
lid◇ : ∀ {w w′} → (ξ : w′ ⊒ w)
→ idₐ ◇ ξ ≡ ξ
rid◇ : ∀ {w w′} → (ξ : w′ ⊒ w)
→ ξ ◇ idₐ ≡ ξ
assoc◇ : ∀ {w w′ w″ w‴} → (ξ₁ : w‴ ⊒ w″) (ξ₂ : w″ ⊒ w′) (ξ₃ : w′ ⊒ w)
→ ξ₁ ◇ (ξ₂ ◇ ξ₃) ≡ (ξ₁ ◇ ξ₂) ◇ ξ₃
module _ {{𝔪 : 𝔐}} where
open 𝔐 𝔪
infix 3 _⊩_
data _⊩_ : 𝒲 → 𝒯 → Set
where
⟦G⟧ : ∀ {w} → (h : ∀ {w′} → (ξ : w′ ⊒ w)
→ 𝒢 w′)
→ w ⊩ ⎵
⟦ƛ⟧ : ∀ {A B w} → (h : ∀ {w′} → (ξ : w′ ⊒ w) (a : w′ ⊩ A)
→ w′ ⊩ B)
→ w ⊩ A ⇒ B
⟦g⟧⟨_⟩ : ∀ {w w′} → w′ ⊒ w → w ⊩ ⎵ → 𝒢 w′
⟦g⟧⟨ ξ ⟩ (⟦G⟧ f) = f ξ
_⟦∙⟧⟨_⟩_ : ∀ {A B w w′} → w ⊩ A ⇒ B → w′ ⊒ w → w′ ⊩ A → w′ ⊩ B
(⟦ƛ⟧ f) ⟦∙⟧⟨ ξ ⟩ a = f ξ a
-- ⟦putᵣ⟧ can’t be stated here
-- ⟦getᵣ⟧ can’t be stated here
-- ⟦wkᵣ⟧ can’t be stated here
-- ⟦liftᵣ⟧ can’t be stated here
-- idₐ = ⟦idᵣ⟧
-- acc = ⟦ren⟧
acc : ∀ {A w w′} → w′ ⊒ w → w ⊩ A → w′ ⊩ A
acc {⎵} ξ f = ⟦G⟧ (λ ξ′ → ⟦g⟧⟨ ξ′ ◇ ξ ⟩ f)
acc {A ⇒ B} ξ f = ⟦ƛ⟧ (λ ξ′ a → f ⟦∙⟧⟨ ξ′ ◇ ξ ⟩ a)
-- ⟦wk⟧ can’t be stated here
-- _◇_ = _⟦○⟧_
--------------------------------------------------------------------------------
module _ {{𝔪 : 𝔐}} where
open 𝔐 𝔪
mutual
data Eq : ∀ {A w} → w ⊩ A → w ⊩ A → Set
where
eq⎵ : ∀ {w} → {f₁ f₂ : w ⊩ ⎵}
→ (h : ∀ {w′} → (ξ : w′ ⊒ w)
→ ⟦g⟧⟨ ξ ⟩ f₁ ≡ ⟦g⟧⟨ ξ ⟩ f₂)
→ Eq f₁ f₂
eq⊃ : ∀ {A B w} → {f₁ f₂ : w ⊩ A ⇒ B}
→ (h : ∀ {w′} → (ξ : w′ ⊒ w) {a : w′ ⊩ A} (u : Un a)
→ Eq (f₁ ⟦∙⟧⟨ ξ ⟩ a) (f₂ ⟦∙⟧⟨ ξ ⟩ a))
→ Eq f₁ f₂
data Un : ∀ {A w} → w ⊩ A → Set
where
un⎵ : ∀ {w} → {f : w ⊩ ⎵}
→ Un f
un⊃ : ∀ {A B w} → {f : w ⊩ A ⇒ B}
→ (h₁ : ∀ {w′} → (ξ : w′ ⊒ w)
{a : w′ ⊩ A}
(u : Un a)
→ Un (f ⟦∙⟧⟨ ξ ⟩ a))
→ (h₂ : ∀ {w′} → (ξ : w′ ⊒ w)
{a₁ a₂ : w′ ⊩ A}
(p : Eq a₁ a₂)
(u₁ : Un a₁)
(u₂ : Un a₂)
→ Eq (f ⟦∙⟧⟨ ξ ⟩ a₁) (f ⟦∙⟧⟨ ξ ⟩ a₂))
→ (h₃ : ∀ {w′ w″} → (ξ₁ : w″ ⊒ w′)
(ξ₂ : w′ ⊒ w)
{a : w′ ⊩ A}
(u : Un a)
→ Eq (acc ξ₁ (f ⟦∙⟧⟨ ξ₂ ⟩ a))
(f ⟦∙⟧⟨ ξ₁ ◇ ξ₂ ⟩ (acc ξ₁ a)))
→ Un f
reflEq : ∀ {A w} → {a : w ⊩ A}
→ Un a
→ Eq a a
reflEq un⎵ = eq⎵ (λ ξ → refl)
reflEq (un⊃ h₁ h₂ h₃) = eq⊃ (λ ξ u → reflEq (h₁ ξ u))
_⁻¹Eq : ∀ {A w} → {a₁ a₂ : w ⊩ A}
→ Eq a₁ a₂
→ Eq a₂ a₁
_⁻¹Eq {⎵} (eq⎵ h) = eq⎵ (λ ξ → h ξ ⁻¹)
_⁻¹Eq {A ⇒ B} (eq⊃ h) = eq⊃ (λ ξ u → h ξ u ⁻¹Eq)
_⦙Eq_ : ∀ {A w} → {a₁ a₂ a₃ : w ⊩ A}
→ Eq a₁ a₂ → Eq a₂ a₃
→ Eq a₁ a₃
_⦙Eq_ {⎵} (eq⎵ h₁) (eq⎵ h₂) = eq⎵ (λ ξ → h₁ ξ ⦙ h₂ ξ)
_⦙Eq_ {A ⇒ B} (eq⊃ h₁) (eq⊃ h₂) = eq⊃ (λ ξ u → h₁ ξ u ⦙Eq h₂ ξ u)
≡→Eq : ∀ {A w} → {a₁ a₂ : w ⊩ A}
→ a₁ ≡ a₂ → Un a₁
→ Eq a₁ a₂
≡→Eq refl u = reflEq u
instance
perEq : ∀ {A w} → PER (w ⊩ A) Eq
perEq =
record
{ _⁻¹ = _⁻¹Eq
; _⦙_ = _⦙Eq_
}
--------------------------------------------------------------------------------
module _ {{𝔪 : 𝔐}} where
open 𝔐 𝔪
-- (cong⟦∙⟧⟨_⟩Eq)
postulate
cong⟦∙⟧Eq : ∀ {A B w w′} → {f₁ f₂ : w ⊩ A ⇒ B} {a₁ a₂ : w′ ⊩ A}
→ (ξ : w′ ⊒ w)
→ Eq f₁ f₂ → Un f₁ → Un f₂
→ Eq a₁ a₂ → Un a₁ → Un a₂
→ Eq (f₁ ⟦∙⟧⟨ ξ ⟩ a₁)
(f₂ ⟦∙⟧⟨ ξ ⟩ a₂)
cong⟦∙⟧Un : ∀ {A B w w′} → {f : w ⊩ A ⇒ B} {a : w′ ⊩ A}
→ (ξ : w′ ⊒ w) → Un f → Un a
→ Un (f ⟦∙⟧⟨ ξ ⟩ a)
cong⟦∙⟧Un ξ (un⊃ h₁ h₂ h₃) u = h₁ ξ u
-- (cong↑⟨_⟩Eq)
postulate
congaccEq : ∀ {A w w′} → {a₁ a₂ : w ⊩ A}
→ (ξ : w′ ⊒ w) → Eq a₁ a₂
→ Eq (acc ξ a₁) (acc ξ a₂)
-- (cong↑⟨_⟩𝒰)
postulate
congaccUn : ∀ {A w w′} → {a : w ⊩ A}
→ (ξ : w′ ⊒ w) → Un a
→ Un (acc ξ a)
-- (aux₄₁₁)
postulate
lidaccEq : ∀ {A w} → {a : w ⊩ A}
→ Un a
→ Eq (acc idₐ a) a
-- (aux₄₁₂)
postulate
acc◇Eq : ∀ {A w w′ w″} → {a : w ⊩ A}
→ (ξ₁ : w″ ⊒ w′) (ξ₂ : w′ ⊒ w) → Un a
→ Eq (acc (ξ₁ ◇ ξ₂) a)
((acc ξ₁ ∘ acc ξ₂) a)
-- (aux₄₁₃)
postulate
acc⟦∙⟧idEq : ∀ {A B w w′} → {f : w ⊩ A ⇒ B} {a : w′ ⊩ A}
→ (ξ : w′ ⊒ w) → Un f → Un a
→ Eq (acc ξ f ⟦∙⟧⟨ idₐ ⟩ a)
(f ⟦∙⟧⟨ ξ ⟩ a)
acc⟦∙⟧Eq : ∀ {A B w w′ w″} → {f : w ⊩ A ⇒ B} {a : w′ ⊩ A}
→ (ξ₁ : w′ ⊒ w) (ξ₂ : w″ ⊒ w′) → Un f → Un a
→ Eq (acc ξ₁ f ⟦∙⟧⟨ ξ₂ ⟩ acc ξ₂ a)
(acc ξ₂ (f ⟦∙⟧⟨ ξ₁ ⟩ a))
acc⟦∙⟧Eq ξ₁ ξ₂ (un⊃ h₁ h₂ h₃) u = h₃ ξ₂ ξ₁ u ⁻¹
--------------------------------------------------------------------------------
module _ {{𝔪 : 𝔐}} where
open 𝔐 𝔪
infix 3 _⊩⋆_
data _⊩⋆_ : 𝒲 → 𝒞 → Set
where
∅ : ∀ {w} → w ⊩⋆ ∅
_,_ : ∀ {Ξ A w} → (ρ : w ⊩⋆ Ξ) (a : w ⊩ A) →
w ⊩⋆ Ξ , A
-- ⟦putₛ⟧ can’t be stated here
-- getᵥ = ⟦getₛ⟧ (lookup)
getᵥ : ∀ {Ξ A w} → w ⊩⋆ Ξ → Ξ ∋ A → w ⊩ A
getᵥ (ρ , a) zero = a
getᵥ (ρ , a) (suc i) = getᵥ ρ i
-- unwkᵥ ≡ ⟦unwkₛ⟧
unwkᵥ : ∀ {Ξ A w} → w ⊩⋆ Ξ , A → w ⊩⋆ Ξ
unwkᵥ (ρ , a) = ρ
-- ⟦wkₛ⟧ can’t be stated here
-- ⟦liftₛ⟧ can’t be stated here
-- ⟦idₛ⟧ can’t be stated here
-- ⟦sub⟧ can’t be stated here
-- ⟦cut⟧ can’t be stated here
-- _◆_ can’t be stated here
--------------------------------------------------------------------------------
module _ {{𝔪 : 𝔐}} where
open 𝔐 𝔪
-- (⟦_◑_⟧ / ↑⟨_⟩⊩⋆)
_⬗_ : ∀ {Ξ w w′} → w′ ⊒ w → w ⊩⋆ Ξ → w′ ⊩⋆ Ξ
ξ ⬗ ∅ = ∅
ξ ⬗ (ρ , a) = ξ ⬗ ρ , acc ξ a
-- (⟦_◐_⟧ / ↓⟨_⟩⊩⋆)
_⬖_ : ∀ {Ξ Ξ′ w} → w ⊩⋆ Ξ′ → Ξ′ ∋⋆ Ξ → w ⊩⋆ Ξ
ρ ⬖ ∅ = ∅
ρ ⬖ (η , i) = ρ ⬖ η , getᵥ ρ i
--------------------------------------------------------------------------------
module _ {{𝔪 : 𝔐}} where
open 𝔐 𝔪
zap⬖ : ∀ {Ξ Ξ′ A w} → (ρ : w ⊩⋆ Ξ′) (η : Ξ′ ∋⋆ Ξ) (a : w ⊩ A)
→ (ρ , a) ⬖ wkᵣ η ≡ ρ ⬖ η
zap⬖ ρ ∅ a = refl
zap⬖ ρ (η , i) a = (_, getᵥ ρ i) & zap⬖ ρ η a
rid⬖ : ∀ {Ξ w} → (ρ : w ⊩⋆ Ξ)
→ ρ ⬖ idᵣ ≡ ρ
rid⬖ ∅ = refl
rid⬖ (ρ , a) = (_, a) & ( zap⬖ ρ idᵣ a
⦙ rid⬖ ρ
)
--------------------------------------------------------------------------------
module _ {{𝔪 : 𝔐}} where
open 𝔐 𝔪
get⬖ : ∀ {Ξ Ξ′ A w} → (ρ : w ⊩⋆ Ξ′) (η : Ξ′ ∋⋆ Ξ) (i : Ξ ∋ A)
→ getᵥ (ρ ⬖ η) i ≡ (getᵥ ρ ∘ getᵣ η) i
get⬖ ρ (η , j) zero = refl
get⬖ ρ (η , j) (suc i) = get⬖ ρ η i
comp⬖○ : ∀ {Ξ Ξ′ Ξ″ w} → (ρ : w ⊩⋆ Ξ″) (η₁ : Ξ″ ∋⋆ Ξ′) (η₂ : Ξ′ ∋⋆ Ξ)
→ ρ ⬖ (η₁ ○ η₂) ≡ (ρ ⬖ η₁) ⬖ η₂
comp⬖○ σ η₁ ∅ = refl
comp⬖○ σ η₁ (η₂ , i) = _,_ & comp⬖○ σ η₁ η₂
⊗ (get⬖ σ η₁ i ⁻¹)
-- wk⬖ can’t be stated here
-- lift⬖ can’t be stated here
-- wkrid⬖ can’t be stated here
-- liftwkrid⬖ can’t be stated here
-- sub⬖ can’t be stated here
-- subwk⬖ can’t be stated here
-- sublift⬖ can’t be stated here
-- subliftwk⬖ can’t be stated here
--------------------------------------------------------------------------------
module _ {{𝔪 : 𝔐}} where
open 𝔐 𝔪
data Eq⋆ : ∀ {Ξ w} → w ⊩⋆ Ξ → w ⊩⋆ Ξ → Set
where
∅ : ∀ {w} → Eq⋆ (∅ {w}) ∅
_,_ : ∀ {Ξ A w} → {ρ₁ ρ₂ : w ⊩⋆ Ξ} {a₁ a₂ : w ⊩ A}
→ (χ : Eq⋆ ρ₁ ρ₂) (p : Eq a₁ a₂)
→ Eq⋆ (ρ₁ , a₁) (ρ₂ , a₂)
data Un⋆ : ∀ {Ξ w} → w ⊩⋆ Ξ → Set
where
∅ : ∀ {w} → Un⋆ (∅ {w})
_,_ : ∀ {Ξ A w} → {ρ : w ⊩⋆ Ξ} {a : w ⊩ A}
→ (υ : Un⋆ ρ) (u : Un a)
→ Un⋆ (ρ , a)
reflEq⋆ : ∀ {Ξ w} → {ρ : w ⊩⋆ Ξ}
→ Un⋆ ρ
→ Eq⋆ ρ ρ
reflEq⋆ ∅ = ∅
reflEq⋆ (υ , u) = reflEq⋆ υ , reflEq u
_⁻¹Eq⋆ : ∀ {Ξ w} → {ρ₁ ρ₂ : w ⊩⋆ Ξ}
→ Eq⋆ ρ₁ ρ₂
→ Eq⋆ ρ₂ ρ₁
∅ ⁻¹Eq⋆ = ∅
(χ , p) ⁻¹Eq⋆ = χ ⁻¹Eq⋆ , p ⁻¹Eq
_⦙Eq⋆_ : ∀ {Ξ w} → {ρ₁ ρ₂ ρ₃ : w ⊩⋆ Ξ}
→ Eq⋆ ρ₁ ρ₂ → Eq⋆ ρ₂ ρ₃
→ Eq⋆ ρ₁ ρ₃
∅ ⦙Eq⋆ ∅ = ∅
(χ₁ , p) ⦙Eq⋆ (χ₂ , q) = χ₁ ⦙Eq⋆ χ₂ , p ⦙Eq q
≡→Eq⋆ : ∀ {Ξ w} → {ρ₁ ρ₂ : w ⊩⋆ Ξ}
→ ρ₁ ≡ ρ₂ → Un⋆ ρ₁
→ Eq⋆ ρ₁ ρ₂
≡→Eq⋆ refl υ = reflEq⋆ υ
instance
perEq⋆ : ∀ {Ξ w} → PER (w ⊩⋆ Ξ) Eq⋆
perEq⋆ =
record
{ _⁻¹ = _⁻¹Eq⋆
; _⦙_ = _⦙Eq⋆_
}
--------------------------------------------------------------------------------
module _ {{𝔪 : 𝔐}} where
open 𝔐 𝔪
-- (conglookupEq)
postulate
conggetEq : ∀ {Ξ A w} → {ρ₁ ρ₂ : w ⊩⋆ Ξ}
→ (i : Ξ ∋ A) → Eq⋆ ρ₁ ρ₂
→ Eq (getᵥ ρ₁ i) (getᵥ ρ₂ i)
-- (cong↑⟨_⟩Eq⋆)
postulate
cong⬗Eq⋆ : ∀ {Ξ w w′} → {ρ₁ ρ₂ : w ⊩⋆ Ξ}
→ (ξ : w′ ⊒ w) → Eq⋆ ρ₁ ρ₂
→ Eq⋆ (ξ ⬗ ρ₁) (ξ ⬗ ρ₂)
-- (cong↓⟨_⟩Eq⋆)
postulate
cong⬖Eq⋆ : ∀ {Ξ Ξ′ w} → {ρ₁ ρ₂ : w ⊩⋆ Ξ′}
→ Eq⋆ ρ₁ ρ₂ → (η : Ξ′ ∋⋆ Ξ)
→ Eq⋆ (ρ₁ ⬖ η) (ρ₂ ⬖ η)
-- (conglookup𝒰)
postulate
conggetUn : ∀ {Ξ A w} → {ρ : w ⊩⋆ Ξ}
→ (i : Ξ ∋ A) → Un⋆ ρ
→ Un (getᵥ ρ i)
-- (cong↑⟨_⟩𝒰⋆)
postulate
cong⬗Un⋆ : ∀ {Ξ w w′} → {ρ : w ⊩⋆ Ξ}
→ (ξ : w′ ⊒ w) → Un⋆ ρ
→ Un⋆ (ξ ⬗ ρ)
-- (cong↓⟨_⟩𝒰⋆)
postulate
cong⬖Un⋆ : ∀ {Ξ Ξ′ w} → {ρ : w ⊩⋆ Ξ′}
→ (η : Ξ′ ∋⋆ Ξ) → Un⋆ ρ
→ Un⋆ (ρ ⬖ η)
--------------------------------------------------------------------------------
module _ {{𝔪 : 𝔐}} where
open 𝔐 𝔪
-- (aux₄₂₁)
postulate
get⬖Eq : ∀ {Ξ Ξ′ A w} → {ρ : w ⊩⋆ Ξ′}
→ (η : Ξ′ ∋⋆ Ξ) (i : Ξ′ ∋ A) (j : Ξ ∋ A) → Un⋆ ρ
→ Eq (getᵥ (ρ ⬖ η) j)
(getᵥ ρ i)
-- (conglookup↑⟨_⟩Eq)
postulate
get⬗Eq : ∀ {Ξ A w w′} → {ρ : w ⊩⋆ Ξ}
→ (ξ : w′ ⊒ w) (i : Ξ ∋ A) → Un⋆ ρ
→ Eq (getᵥ (ξ ⬗ ρ) i)
(acc ξ (getᵥ ρ i))
-- (aux₄₂₃)
postulate
zap⬖Eq⋆ : ∀ {Ξ Ξ′ A w} → {ρ : w ⊩⋆ Ξ′} {a : w ⊩ A}
→ (η₁ : Ξ′ , A ∋⋆ Ξ) (η₂ : Ξ′ ∋⋆ Ξ) → Un⋆ ρ
→ Eq⋆ ((ρ , a) ⬖ η₁)
(ρ ⬖ η₂)
-- (aux₄₂₄)
postulate
rid⬖Eq⋆ : ∀ {Ξ w} → {ρ : w ⊩⋆ Ξ}
→ Un⋆ ρ
→ Eq⋆ (ρ ⬖ idᵣ) ρ
-- (aux₄₂₅)
postulate
lid⬗Eq⋆ : ∀ {Ξ w} → {ρ : w ⊩⋆ Ξ}
→ Un⋆ ρ
→ Eq⋆ (idₐ ⬗ ρ) ρ
-- (aux₄₂₆)
postulate
comp⬖○Eq⋆ : ∀ {Ξ Ξ′ Ξ″ w} → {ρ : w ⊩⋆ Ξ″}
→ (η₁ : Ξ″ ∋⋆ Ξ′) (η₂ : Ξ′ ∋⋆ Ξ) → Un⋆ ρ
→ Eq⋆ (ρ ⬖ (η₁ ○ η₂))
((ρ ⬖ η₁) ⬖ η₂)
-- (aux₄₂₇)
postulate
comp⬗◇Eq⋆ : ∀ {Ξ w w′ w″} → {ρ : w ⊩⋆ Ξ}
→ (ξ₁ : w″ ⊒ w′) (ξ₂ : w′ ⊒ w) → Un⋆ ρ
→ Eq⋆ (ξ₁ ⬗ (ξ₂ ⬗ ρ))
((ξ₁ ◇ ξ₂) ⬗ ρ)
-- (aux₄₂₈)
postulate
comp⬗⬖Eq⋆ : ∀ {Ξ Ξ′ w w′} → {ρ : w ⊩⋆ Ξ′}
→ (ξ : w′ ⊒ w) (η : Ξ′ ∋⋆ Ξ) → Un⋆ ρ
→ Eq⋆ (ξ ⬗ (ρ ⬖ η))
((ξ ⬗ ρ) ⬖ η)
--------------------------------------------------------------------------------
module _ {{𝔪 : 𝔐}} where
open 𝔐 𝔪
⟦_⟧ : ∀ {Ξ A w} → Ξ ⊢ A → w ⊩⋆ Ξ → w ⊩ A
⟦ 𝓋 i ⟧ ρ = getᵥ ρ i
⟦ ƛ M ⟧ ρ = ⟦ƛ⟧ (λ ξ a → ⟦ M ⟧ (ξ ⬗ ρ , a))
⟦ M ∙ N ⟧ ρ = ⟦ M ⟧ ρ ⟦∙⟧⟨ idₐ ⟩ ⟦ N ⟧ ρ
⟦_⟧⋆ : ∀ {Ξ Φ w} → Ξ ⊢⋆ Φ → w ⊩⋆ Ξ → w ⊩⋆ Φ
⟦ ∅ ⟧⋆ ρ = ∅
⟦ σ , M ⟧⋆ ρ = ⟦ σ ⟧⋆ ρ , ⟦ M ⟧ ρ
--------------------------------------------------------------------------------
instance
canon : 𝔐
canon = record
{ 𝒲 = 𝒞
; 𝒢 = _⊢ ⎵
; _⊒_ = _∋⋆_
; idₐ = idᵣ
; _◇_ = _○_
; lid◇ = lid○
; rid◇ = rid○
; assoc◇ = assoc○
}
mutual
reify : ∀ {A Γ} → Γ ⊩ A → Γ ⊢ A
reify {⎵} f = ⟦g⟧⟨ idᵣ ⟩ f
reify {A ⇒ B} f = ƛ (reify (f ⟦∙⟧⟨ wkᵣ idᵣ ⟩ ⟪𝓋 0 ⟫))
⟪_⟫ : ∀ {A Γ} → (∀ {Γ′} → Γ′ ∋⋆ Γ → Γ′ ⊢ A) → Γ ⊩ A
⟪_⟫ {⎵} f = ⟦G⟧ (λ η → f η)
⟪_⟫ {A ⇒ B} f = ⟦ƛ⟧ (λ η a → ⟪ (λ η′ → f (η′ ○ η) ∙ reify (acc η′ a)) ⟫)
⟪𝓋_⟫ : ∀ {Γ A} → Γ ∋ A → Γ ⊩ A
⟪𝓋 i ⟫ = ⟪ (λ η → ren η (𝓋 i)) ⟫
aux₄₄₁ : ∀ {A Γ} → (f₁ f₂ : ∀ {Γ′} → Γ′ ∋⋆ Γ → Γ′ ⊢ A)
→ (∀ {Γ′} → (η : Γ′ ∋⋆ Γ) → f₁ η ≡ f₂ η)
→ Eq (⟪ f₁ ⟫) (⟪ f₂ ⟫)
aux₄₄₁ {⎵} f₁ f₂ h = eq⎵ (λ η → h η)
aux₄₄₁ {A ⇒ B} f₁ f₂ h =
eq⊃ (λ η′ {a} u →
aux₄₄₁ (λ η″ → f₁ (η″ ○ η′) ∙ reify (acc η″ a))
(λ η″ → f₂ (η″ ○ η′) ∙ reify (acc η″ a))
(λ η″ → (_∙ reify (acc η″ a)) & h (η″ ○ η′)))
aux₄₄₂ : ∀ {A Γ Γ′} → (η : Γ′ ∋⋆ Γ) (f : (∀ {Γ′} → Γ′ ∋⋆ Γ → Γ′ ⊢ A))
→ Eq (acc η ⟪ f ⟫) (⟪ (λ η′ → f (η′ ○ η)) ⟫)
aux₄₄₂ {⎵} η f = eq⎵ (λ η′ → f & refl)
aux₄₄₂ {A ⇒ B} η f =
eq⊃ (λ η′ {a} u →
aux₄₄₁ (λ η″ → f (η″ ○ (η′ ○ η)) ∙ reify (acc η″ a))
(λ η″ → f ((η″ ○ η′) ○ η) ∙ reify (acc η″ a))
(λ η″ → (_∙ reify (acc η″ a)) & (f & assoc○ η″ η′ η)))
--------------------------------------------------------------------------------
-- Theorem 1.
mutual
thm₁ : ∀ {Γ A} → {a₁ a₂ : Γ ⊩ A}
→ Eq a₁ a₂
→ reify a₁ ≡ reify a₂
thm₁ (eq⎵ h) = h idᵣ
thm₁ (eq⊃ h) = ƛ & thm₁ (h (wkᵣ idᵣ) ⟪𝓋 0 ⟫ᵤ)
⟪𝓋_⟫ᵤ : ∀ {Γ A} → (i : Γ ∋ A)
→ Un (⟪𝓋 i ⟫)
⟪𝓋 i ⟫ᵤ = aux₄₄₃ (λ η → 𝓋 (getᵣ η i))
aux₄₄₃ : ∀ {A Γ} → (f : ∀ {Γ′} → Γ′ ∋⋆ Γ → Γ′ ⊢ A)
→ Un (⟪ f ⟫)
aux₄₄₃ {⎵} f = un⎵
aux₄₄₃ {A ⇒ B} f =
un⊃ (λ η {a} u →
aux₄₄₃ (λ η′ → f (η′ ○ η) ∙ reify (acc η′ a)))
(λ η {a₁} {a₂} p u₁ u₂ →
aux₄₄₁ (λ η′ → f (η′ ○ η) ∙ reify (acc η′ a₁))
(λ η′ → f (η′ ○ η) ∙ reify (acc η′ a₂))
(λ η′ → (f (η′ ○ η) ∙_) & thm₁ (congaccEq η′ p)))
(λ η₁ η₂ {a} u →
aux₄₄₂ η₁ (λ η′ → f (η′ ○ η₂) ∙ reify (acc η′ a))
⦙ aux₄₄₁ (λ η′ → f ((η′ ○ η₁) ○ η₂) ∙ reify (acc (η′ ○ η₁) a))
(λ η′ → f (η′ ○ (η₁ ○ η₂)) ∙ reify (acc η′ (acc η₁ a)))
(λ η′ → _∙_ & (f & assoc○ η′ η₁ η₂ ⁻¹)
⊗ thm₁ (acc◇Eq η′ η₁ u)))
--------------------------------------------------------------------------------
⌊_⌋ᵥ : ∀ {Γ Γ′} → Γ′ ∋⋆ Γ → Γ′ ⊩⋆ Γ
⌊ ∅ ⌋ᵥ = ∅
⌊ η , i ⌋ᵥ = ⌊ η ⌋ᵥ , ⟪𝓋 i ⟫
idᵥ : ∀ {Γ} → Γ ⊩⋆ Γ
idᵥ = ⌊ idᵣ ⌋ᵥ
nf : ∀ {Γ A} → Γ ⊢ A → Γ ⊢ A
nf M = reify (⟦ M ⟧ idᵥ)
-- Corollary 1.
cor₁ : ∀ {Γ A} → (M₁ M₂ : Γ ⊢ A) → Eq (⟦ M₁ ⟧ idᵥ) (⟦ M₂ ⟧ idᵥ)
→ nf M₁ ≡ nf M₂
cor₁ M₁ M₂ = thm₁
--------------------------------------------------------------------------------
|
\section{Alternative Formulations for Selective Functors}
\label{sec-alternatives}
This section discusses alternative versions of the \hs{Selective} type class
that are based on different \hs{select} operators: specifically, the
multi-way~(\S\ref{sec-alt-multi}) and symmetric~(\S\ref{sec-alt-symmetric})
generalisations of \hs{select}, as well as operators that are equivalent to
\hs{select} but may be more convenient to use~(\S\ref{sec-alt-equivalent}). All
of these ideas can be readily integrated into the presented definition of the
\hs{Selective} type class by extending it with new methods and adding new laws
that ensure that the new methods interact with \hs{select} in an appropriate
manner. This is common in standard Haskell libraries, where type classes
\hs{Applicative} and \hs{Monad} include methods like \hs{*>} and \hs{>>} for
performance reasons.
Another alternative, which is worth a remark, is to simply add \hs{select} to
the \hs{Applicative} type class, with the default implementation
\hs{select}~\hs{=}~\hs{selectA}. While this works for the purposes discussed in
this paper, it would make it harder to reason about code with the
\hs{Applicative}~\hs{f} constraint, since the \hs{select} method makes it
possible for effects to depend on values; declaring such a significant ability
by the \hs{Selective}~\hs{f} constraint is arguably a more prudent approach.
\subsection{Multiway Selective Functors}\label{sec-alt-multi}
As mentioned in~\S\ref{sec-selective}, \hs{branch} is a strong contender to be
the main method of the \hs{Selective} type class; it is parametric and all
selective combinators, including \hs{select} itself, can be derived from it:
\vspace{1mm}
\begin{minted}[xleftmargin=10pt]{haskell}
branch :: Selective f => f (Either a b) -> f (a -> c) -> f (b -> c) -> f c
\end{minted}
\vspace{0mm}
\begin{minted}[xleftmargin=10pt]{haskell}
selectB :: Selective f => f (Either a b) -> f (a -> b) -> f b
selectB x y = branch x y (pure id)
\end{minted}
\vspace{1mm}
\noindent
While we prefer \hs{select} for its simplicity, \hs{branch} does provide an
interesting advantage in the context of static analysis. Specifically, it makes
it statically apparent that the two branches are \emph{mutually exclusive}. When
\hs{branch} is ``desugared'' into a sequence of two \hs{select} operations, the
information about the mutual exclusion between the two branches is lost, which
rules out some static analysis scenarios. For example, it may be useful to know
that in our build systems example in~\S\ref{sec-static-example} we never depend
on both \cmd{lib.c} and \cmd{lib.ml}.
Another point in favour of \hs{branch} is performance: the \hs{select}-based
implementation of the \hs{ifS} combinator checks for the \hs{Left} and
\hs{Right} cases in sequence, instead of directly jumping to the correct case,
so a \hs{branch}-based implementation would be more efficient. Furthermore,
$N$-way generalisations of \hs{select} are possible, although the design space
here is quite large. As an example, one might consider adding \hs{bindS} to the
\hs{Selective} type class, i.e. a special case of the monadic bind operator that
is applicable only to enumerable types:
\vspace{1mm}
\begin{minted}[xleftmargin=10pt]{haskell}
bindS :: Selective f => (Bounded a, Enum a, Eq a) => f a -> (a -> f b) -> f b
\end{minted}
\vspace{1mm}
\noindent
The default implementation could be based on sequentially checking for every
possible value using \hs{select}, but monadic instances would supply a much
faster implementation, namely \hs{bindS}~\hs{=}~\hs{(>>=)}. This would allow
static analysis instances to record all possible cases, without incurring
the $O(N)$ slowdown during the execution of an $N$-way branch.
Interestingly, adding the ability to branch on infinite number of cases makes
selective functors equivalent to monads, e.g. see~\citet{peebles2019sigma}.
However, it is worth pointing out that static analysis of such
infinitely-branching selective functors might take infinite time too.
Exploring the design space for ``multiway selective functors'', and using them
for efficient translation of Haskell's \cmd{do}-notation into selective
combinators in the spirit of the \cmd{ApplicativeDo}
extension~\citep{marlow2016applicativedo} is left for future research. For now,
we believe that adding \hs{branch} and/or an equivalent of \hs{bindS} to the
\hs{Selective} type class would be beneficial for performance-sensitive
applications.
\subsection{Symmetric Selective Functors}\label{sec-alt-symmetric}
In this section we address the asymmetry of \hs{select}, which we remarked on
in~\S\ref{sec-haxl} and~\S\ref{sec-free}. The asymmetry can be seen in the fact
that the first argument of \hs{select} must always be executed, while the second
argument may sometimes be skipped. Consider a more symmetric alternative:
\vspace{1mm}
\begin{minted}[xleftmargin=5pt]{haskell}
biselect :: Selective f => f@\,@(Either a b) -> f@\,@(Either a c) -> f@\,@(Either a (b,c))
\end{minted}
\vspace{1mm}
\noindent
This definition is pleasantly symmetric: if either of the arguments yields a
\hs{Left}~\hs{a} value, the other argument \emph{may be skipped} since the
result must be a \hs{Left}~\hs{a} too, by parametricity. On the other hand, if
one of the arguments yields a \hs{Right} value, then the other argument
\emph{must be executed} in order to either get an \hs{a} or the other half of
the resulting pair. As an added bonus, the rather obscure associativity law
from~\S\ref{sec-laws} looks much more natural for
\hs{(?*?)}~\hs{=}~\hs{biselect}:
\vspace{1mm}
\begin{minted}[xleftmargin=10pt]{haskell}
@\blk{x}@ ?*? (y ?*? z) = fmap assoc <$> ((x ?*? y) ?*? z)
where
assoc ((a, b), c) = (a, (b, c))
\end{minted}
\vspace{1mm}
\noindent
While beautiful, we found \hs{biselect} to be a bit more awkward to work with
than \hs{select}, and also more subtle when the order in which the arguments
are executed is not fixed. So far we have identified only one example where the
symmetry of \hs{biselect} is beneficial: speculative execution of parallel OR
and AND combinators --- see the \Haxl case study~\S\ref{sec-haxl}. To support
such use-cases it is possible to add \hs{biselect} to the \hs{Selective} type
class with the following default implementation:
\vspace{1mm}
\begin{minted}[xleftmargin=5pt]{haskell}
biselect :: Selective f => f@\,@(Either a b) -> f@\,@(Either a c) -> f@\,@(Either a (b,c))
biselect x y = select ((fmap Left . swap) <$> x) ((\e a -> fmap (a,) e) <$> y)
where
swap = either Right Left -- Swap Left and Right
\end{minted}
\vspace{1mm}
\noindent
This implementation breaks the symmetry, which may be acceptable for most
instances of selective functors, but instances like \hs{Haxl} would override it
in order to gain additional performance benefits. Note that the selective
combinators like \hs{<||>} would need to be redefined via \hs{biselect} in order
to take advantage of the symmetry.
From the theoretical viewpoint, the type signature of \hs{biselect} makes it
more apparent that a selective functor \hs{f} is a composition of an applicative
functor \hs{f} and the \hs{Either} monad.
\subsection{Equivalent Formulations}\label{sec-alt-equivalent}
In this section we briefly mention three equivalent operators that can be used
instead of \hs{select}.
\begin{itemize}
\item Lennox S. Leary and Edward Kmett suggested to move the function to the
first argument:
\vspace{1mm}
\begin{minted}{haskell}
select :: Selective f => f (Either (a -> b) b) -> f a -> f b
\end{minted}
\vspace{1mm}
This operator is similar to \hs{Applicative}'s \hs{<*>} but with a
twist: the first argument might turn out to be a constant function
\hs{const}~\hs{b}, in which case the effect \hs{f}~\hs{a} may be
skipped.
\item One can take one step further and extract the selection logic into a
separate function:
\vspace{1mm}
\begin{minted}{haskell}
selectBy :: Selective f => (a -> Either (b -> c) c) -> f a -> f b -> f c
\end{minted}
\vspace{1mm}
This operator is very convenient for implementing selective
combinators, and also provides more opportunities for optimisation by
fusing construction and deconstruction of \hs{Either}'s.
\item Finally, it is possible to get rid of functions altogether:
\vspace{1mm}
\begin{minted}{haskell}
select :: Selective f => f (Either a b) -> f c -> f (Either a (b, c))
\end{minted}
\vspace{1mm}
While this formulation requires an extra tuple allocation, it uses
only sum and product types, and may therefore be useful in contexts
where functions are unavailable.
\end{itemize}
% Arseniy's raise/catch
% Loops
|
We hope you can find what you need here. We always effort to show a picture with HD resolution or at least with perfect images. Porte Pas Cher Part – 2: Porte interieur pas cher can be beneficial inspiration for those who seek an image according specific categories; you can find it in this site. Finally all pictures we have been displayed in this site will inspire you all.. |
{-# OPTIONS --without-K #-}
open import HoTT
module homotopy.JoinFunc where
module F {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l} (f : A → C) (g : B → D) where
fg-glue : (ab : A × B) → left (f (fst ab)) == right (g (snd ab)) :> (C * D)
fg-glue (a , b) = glue (f a , g b)
to : A * B → C * D
to = To.f module M where
module To = PushoutRec (left ∘ f) (right ∘ g) fg-glue
open M public
module _ {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l} where
_**_[_] : (A → C) → (B → D) → A * B → C * D
f ** g [ ab ] = M.to ab where
module M = F f g
|
theory flash35Rev imports flashPub
begin
section{*Main defintions*}
lemma NI_FAckVsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_FAck ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 , auto)
lemma NI_InvVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Inv iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P2 s"
apply(cut_tac a1 a2 b1 , auto intro!:forallVars1 simp add :invHoldForRule2'_def varsOfVar_def)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_InvAck_1VsInv35:
(*Rule2VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iRule2 \<le> N" and a3:"iInv1 \<le> N" and a4:"iRule1~=iRule2 "
shows "invHoldForRule' s (inv35 iInv1 ) (NI_InvAck_1 iRule1 iRule2 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have "?P2 s"
by(cut_tac a1 a2 a3 a4, auto)
then show "?P1 s\<or>?P2 s\<or>?P3 s"
by auto
qed
lemma NI_InvAck_1_HomeVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_InvAck_1_Home iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_InvAck_2VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_InvAck_2 N iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Local_GetX_GetXVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_GetX iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Local_GetX_Nak1VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_Nak1 iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Local_GetX_Nak2VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_Nak2 iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Local_GetX_Nak3VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_Nak3 iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Local_GetX_PutX1VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_PutX1 N iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Local_GetX_PutX2VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_PutX2 N iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Local_GetX_PutX3VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_PutX3 N iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Local_GetX_PutX4VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_PutX4 N iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Local_GetX_PutX5VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_PutX5 N iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Local_GetX_PutX6VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_PutX6 N iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Local_GetX_PutX7VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_PutX7 N iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Local_GetX_PutX8VsInv35:
(*Rule2VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iRule2 \<le> N" and a3:"iInv1 \<le> N" and a4:"iRule1~=iRule2 "
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_PutX8 N iRule1 iRule2 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1\<and>(iRule2~=iInv1 )) \<or>((iRule1~=iInv1 )\<and>iRule2=iInv1) \<or>((iRule1~=iInv1 )\<and>(iRule2~=iInv1 )) "
by( cut_tac a1 a2 a3 a4 , auto)
moreover
{assume b1:"(iRule1=iInv1\<and>(iRule2~=iInv1 ))"
have "?P1 s"
apply(cut_tac a1 a2 a3 a4 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 )\<and>iRule2=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 a3 a4 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 )\<and>(iRule2~=iInv1 ))"
have "?P1 s"
apply(cut_tac a1 a2 a3 a4 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Local_GetX_PutX8_homeVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_PutX8_home N iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Local_GetX_PutX9VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_PutX9 N iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Local_GetX_PutX10VsInv35:
(*Rule2VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iRule2 \<le> N" and a3:"iInv1 \<le> N" and a4:"iRule1~=iRule2 "
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_PutX10 N iRule1 iRule2 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have "?P2 s"
by(cut_tac a1 a2 a3 a4, auto)
then show "?P1 s\<or>?P2 s\<or>?P3 s"
by auto
qed
lemma NI_Local_GetX_PutX10_homeVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_PutX10_home N iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Local_GetX_PutX11VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_GetX_PutX11 N iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Local_Get_GetVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_Get_Get iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Local_Get_Nak1VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_Get_Nak1 iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Local_Get_Nak2VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_Get_Nak2 iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Local_Get_Nak3VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_Get_Nak3 iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Local_Get_Put1VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_Get_Put1 N iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Local_Get_Put2VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_Get_Put2 iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Local_Get_Put3VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_Get_Put3 iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P3 s"
apply( cut_tac a1 a2 b1 , simp)
apply(rule_tac x=" (neg ( andForm ( eqn ( IVar ( Para ''UniMsg_Cmd'' iInv1) ) ( Const UNI_Get )) ( eqn ( IVar ( Para ''CacheState'' iInv1) ) ( Const CACHE_E )) ) ) " in exI,auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P3 s"
apply( cut_tac a1 a2 b1 , simp)
apply(rule_tac x=" (neg ( andForm ( eqn ( IVar ( Para ''CacheState'' iInv1) ) ( Const CACHE_E )) ( eqn ( IVar ( Global ''Dir_local'') ) ( Const true )) ) ) " in exI,auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Local_PutVsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_Put ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"formEval ( eqn ( IVar ( Para ''InvMarked'' Home) ) ( Const true )) s \<or>formEval (neg ( eqn ( IVar ( Para ''InvMarked'' Home) ) ( Const true )) ) s "
by auto
moreover
{assume b1:"formEval ( eqn ( IVar ( Para ''InvMarked'' Home) ) ( Const true )) s"
have "?P1 s"
apply(cut_tac a1 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"formEval (neg ( eqn ( IVar ( Para ''InvMarked'' Home) ) ( Const true )) ) s"
have "?P3 s"
apply( cut_tac a1 b1 , simp)
apply(rule_tac x=" (neg ( andForm ( eqn ( IVar ( Para ''CacheState'' iInv1) ) ( Const CACHE_E )) ( eqn ( IVar ( Para ''UniMsg_Cmd'' Home) ) ( Const UNI_Put )) ) ) " in exI,auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Local_PutXAcksDoneVsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Local_PutXAcksDone ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have "?P1 s"
apply(cut_tac a1 , auto)
done
then show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by blast
qed
lemma NI_NakVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Nak iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Nak_ClearVsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Nak_Clear ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 , auto)
lemma NI_Nak_HomeVsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Nak_Home ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 , auto)
lemma NI_Remote_GetX_NakVsInv35:
(*Rule2VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iRule2 \<le> N" and a3:"iInv1 \<le> N" and a4:"iRule1~=iRule2 "
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Remote_GetX_Nak iRule1 iRule2 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have "?P2 s"
by(cut_tac a1 a2 a3 a4, auto)
then show "?P1 s\<or>?P2 s\<or>?P3 s"
by auto
qed
lemma NI_Remote_GetX_Nak_HomeVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Remote_GetX_Nak_Home iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Remote_GetX_PutXVsInv35:
(*Rule2VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iRule2 \<le> N" and a3:"iInv1 \<le> N" and a4:"iRule1~=iRule2 "
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Remote_GetX_PutX iRule1 iRule2 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1\<and>(iRule2~=iInv1 )) \<or>((iRule1~=iInv1 )\<and>iRule2=iInv1) \<or>((iRule1~=iInv1 )\<and>(iRule2~=iInv1 )) "
by( cut_tac a1 a2 a3 a4 , auto)
moreover
{assume b1:"(iRule1=iInv1\<and>(iRule2~=iInv1 ))"
have "?P2 s"
apply(cut_tac a1 a2 a3 a4 b1 , auto intro!:forallVars1 simp add :invHoldForRule2'_def varsOfVar_def)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 )\<and>iRule2=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 a3 a4 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 )\<and>(iRule2~=iInv1 ))"
have "?P2 s"
apply(cut_tac a1 a2 a3 a4 b1 , auto intro!:forallVars1 simp add :invHoldForRule2'_def varsOfVar_def)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Remote_GetX_PutX_HomeVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Remote_GetX_PutX_Home iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P2 s"
apply(cut_tac a1 a2 b1 , auto intro!:forallVars1 simp add :invHoldForRule2'_def varsOfVar_def)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Remote_Get_Nak1VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Remote_Get_Nak1 iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_Remote_Get_Nak2VsInv35:
(*Rule2VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iRule2 \<le> N" and a3:"iInv1 \<le> N" and a4:"iRule1~=iRule2 "
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Remote_Get_Nak2 iRule1 iRule2 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have "?P2 s"
by(cut_tac a1 a2 a3 a4, auto)
then show "?P1 s\<or>?P2 s\<or>?P3 s"
by auto
qed
lemma NI_Remote_Get_Put1VsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Remote_Get_Put1 iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P2 s"
apply(cut_tac a1 a2 b1 , auto intro!:forallVars1 simp add :invHoldForRule2'_def varsOfVar_def)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Remote_Get_Put2VsInv35:
(*Rule2VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iRule2 \<le> N" and a3:"iInv1 \<le> N" and a4:"iRule1~=iRule2 "
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Remote_Get_Put2 iRule1 iRule2 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1\<and>(iRule2~=iInv1 )) \<or>((iRule1~=iInv1 )\<and>iRule2=iInv1) \<or>((iRule1~=iInv1 )\<and>(iRule2~=iInv1 )) "
by( cut_tac a1 a2 a3 a4 , auto)
moreover
{assume b1:"(iRule1=iInv1\<and>(iRule2~=iInv1 ))"
have "?P2 s"
apply(cut_tac a1 a2 a3 a4 b1 , auto intro!:forallVars1 simp add :invHoldForRule2'_def varsOfVar_def)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 )\<and>iRule2=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 a3 a4 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 )\<and>(iRule2~=iInv1 ))"
have "?P2 s"
apply(cut_tac a1 a2 a3 a4 b1 , auto intro!:forallVars1 simp add :invHoldForRule2'_def varsOfVar_def)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Remote_PutVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Remote_Put iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have allCases:"formEval ( eqn ( IVar ( Para ''InvMarked'' iInv1) ) ( Const true )) s \<or>formEval (neg ( eqn ( IVar ( Para ''InvMarked'' iInv1) ) ( Const true )) ) s "
by auto
moreover
{assume c1:"formEval ( eqn ( IVar ( Para ''InvMarked'' iInv1) ) ( Const true )) s"
have "?P1 s"
apply(cut_tac a1 a2 b1 c1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume c1:"formEval (neg ( eqn ( IVar ( Para ''InvMarked'' iInv1) ) ( Const true )) ) s"
have "?P1 s"
apply(cut_tac a1 a2 b1 c1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately have "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P2 s"
apply(cut_tac a1 a2 b1 , auto intro!:forallVars1 simp add :invHoldForRule2'_def varsOfVar_def)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_Remote_PutXVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Remote_PutX iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P3 s"
apply( cut_tac a1 a2 b1 , simp)
apply(rule_tac x=" (neg ( andForm ( eqn ( IVar ( Para ''UniMsg_Cmd'' iInv1) ) ( Const UNI_PutX )) ( eqn ( IVar ( Para ''CacheState'' Home) ) ( Const CACHE_S )) ) ) " in exI,auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P2 s"
apply(cut_tac a1 a2 b1 , auto intro!:forallVars1 simp add :invHoldForRule2'_def varsOfVar_def)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma NI_ReplaceVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Replace iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_ReplaceHomeVsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_ReplaceHome ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 , auto)
lemma NI_ReplaceHomeShrVldVsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_ReplaceHomeShrVld ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 , auto)
lemma NI_ReplaceShrVldVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_ReplaceShrVld iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma NI_ShWbVsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_ShWb N ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 , auto)
lemma NI_WbVsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (NI_Wb ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 , auto)
lemma PI_Local_GetX_GetX1VsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (PI_Local_GetX_GetX1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 , auto)
lemma PI_Local_GetX_GetX2VsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (PI_Local_GetX_GetX2 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 , auto)
lemma PI_Local_GetX_PutX1VsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (PI_Local_GetX_PutX1 N ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have "?P1 s"
apply(cut_tac a1 , auto)
done
then show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by blast
qed
lemma PI_Local_GetX_PutX2VsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (PI_Local_GetX_PutX2 N ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have "?P1 s"
apply(cut_tac a1 , auto)
done
then show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by blast
qed
lemma PI_Local_GetX_PutX3VsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (PI_Local_GetX_PutX3 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have "?P1 s"
apply(cut_tac a1 , auto)
done
then show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by blast
qed
lemma PI_Local_GetX_PutX4VsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (PI_Local_GetX_PutX4 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have "?P1 s"
apply(cut_tac a1 , auto)
done
then show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by blast
qed
lemma PI_Local_Get_GetVsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (PI_Local_Get_Get ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 , auto)
lemma PI_Local_Get_PutVsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (PI_Local_Get_Put ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"formEval ( eqn ( IVar ( Para ''InvMarked'' Home) ) ( Const true )) s \<or>formEval (neg ( eqn ( IVar ( Para ''InvMarked'' Home) ) ( Const true )) ) s "
by auto
moreover
{assume b1:"formEval ( eqn ( IVar ( Para ''InvMarked'' Home) ) ( Const true )) s"
have "?P1 s"
apply(cut_tac a1 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"formEval (neg ( eqn ( IVar ( Para ''InvMarked'' Home) ) ( Const true )) ) s"
have "?P3 s"
apply( cut_tac a1 b1 , simp)
apply(rule_tac x=" (neg ( andForm ( eqn ( IVar ( Para ''CacheState'' iInv1) ) ( Const CACHE_E )) ( eqn ( IVar ( Global ''Dir_Dirty'') ) ( Const false )) ) ) " in exI,auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma PI_Local_PutXVsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (PI_Local_PutX ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have "?P1 s"
apply(cut_tac a1 , auto)
done
then show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by blast
qed
lemma PI_Local_ReplaceVsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (PI_Local_Replace ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have "?P1 s"
apply(cut_tac a1 , auto)
done
then show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by blast
qed
lemma PI_Remote_GetVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (PI_Remote_Get iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma PI_Remote_GetXVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (PI_Remote_GetX iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma PI_Remote_PutXVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (PI_Remote_PutX iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
proof -
have allCases:"(iRule1=iInv1) \<or>((iRule1~=iInv1 )) "
by( cut_tac a1 a2 , auto)
moreover
{assume b1:"(iRule1=iInv1)"
have "?P1 s"
apply(cut_tac a1 a2 b1 , auto)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
moreover
{assume b1:"((iRule1~=iInv1 ))"
have "?P2 s"
apply(cut_tac a1 a2 b1 , auto intro!:forallVars1 simp add :invHoldForRule2'_def varsOfVar_def)
done
then have "?P1 s\<or> ?P2 s \<or> ?P3 s"
by blast
}
ultimately show "?P1 s\<or> ?P2 s\<or> ?P3 s"
by metis
qed
lemma PI_Remote_ReplaceVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (PI_Remote_Replace iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma StoreVsInv35:
(*Rule1VsPInv1*)
assumes a1:"iRule1 \<le> N" and a2:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (Store iRule1 ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 a2 , auto)
lemma StoreHomeVsInv35:
(*Rule0VsPInv1*)
assumes a1:"iInv1 \<le> N"
shows "invHoldForRule' s (inv35 iInv1 ) (StoreHome ) (invariants N)" (is " ?P1 s\<or>?P2 s\<or>?P3 s")
by (cut_tac a1 , auto)
end
|
[STATEMENT]
lemma ok3_nul_nullable[simp]: "ok3 r \<Longrightarrow> nul r = nullable (strip3 r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. ok3 r \<Longrightarrow> nul r = nullable (strip3 r)
[PROOF STEP]
by (induct r) auto |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Functor hiding (id)
module Categories.Diagram.Colimit.Properties
{o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {J : Category o′ ℓ′ e′} (F : Functor J C) where
private
module F = Functor F
module C = Category C
open C
open import Categories.Diagram.Limit F.op
open import Categories.Diagram.Colimit F
open import Categories.Category.Construction.Cocones F
open import Categories.Diagram.Duality C
module _ (X : Obj) (coapex₁ : Coapex X) (coapex₂ : Coapex X) (L : Colimit) where
private
module coapex₁ = Coapex coapex₁
module coapex₂ = Coapex coapex₂
module L = Colimit L
K₁ : Cocone
K₁ = record { coapex = coapex₁ }
module K₁ = Cocone K₁
K₂ : Cocone
K₂ = record { coapex = coapex₂ }
module K₂ = Cocone K₂
coψ-≈⇒rep-≈ : (∀ A → coapex₁.ψ A ≈ coapex₂.ψ A) → L.rep K₁ ≈ L.rep K₂
coψ-≈⇒rep-≈ = ψ-≈⇒rep-≈ X (Coapex⇒coApex X coapex₁) (Coapex⇒coApex X coapex₂) (Colimit⇒coLimit L)
|
import os
import numpy as np
from scipy.interpolate import interp1d
from astropy import units as u
from starkit.gridkit.io.process import BaseProcessGrid
from starkit.gridkit.io.bosz.base import convert_bz2_memmap
from starkit.gridkit.util import convolve_to_resolution
class BOSZProcessGrid(BaseProcessGrid):
"""
"""
R_initial = 300000
R_initial_sampling=1
def __init__(self, index, input_wavelength, meta, wavelength_start=0*u.angstrom, wavelength_stop=np.inf*u.angstrom,
R=5000.0, R_sampling=4):
"""
Parameters
----------
index : pandas.DataFrame
input_wavelength : astropy.units.Quantity
meta : pandas.Series
wavelength_start : astropy.units.Quantity
wavelength_stop : astropy.units.Quantity
R : float
R_sampling : integer
"""
super(BOSZProcessGrid, self).__init__(index, input_wavelength, meta, wavelength_start=wavelength_start,
wavelength_stop=wavelength_stop, R=R, R_sampling=R_sampling)
def interp_wavelength(self, flux):
cut_flux = flux[self.start_idx:self.stop_idx]
processed_flux = convolve_to_resolution(cut_flux, self.R_initial, self.R_initial_sampling, self.R)
output_flux = interp1d(self.cut_wavelength, processed_flux)(
self.output_wavelength)
return output_flux
def load_flux(self, fname):
"""
load the 1D flux array from file
Parameters
----------
fname : str
Returns
-------
: numpy.ndarray
"""
fname_npy = fname.replace('.bz2', '.v1.npy')
if not os.path.exists(fname_npy):
convert_bz2_memmap(fname)
flux = np.load(fname_npy)
return flux * np.pi
|
{-# OPTIONS --without-K --safe #-}
module Math.NumberTheory.Product.Nat where
-- agda-stdlib
open import Data.Nat.Properties
-- agda-misc
open import Math.NumberTheory.Product.Generic
open MonoidProduct *-1-monoid public
|
from numba import jit
@jit('i8(i8)')
def trailing_zeros_jit(n):
order = 0
while n != 1:
d, m = divmod(n, 2)
if m != 0:
break
n //= 2
order += 1
return order
@jit('i8(i8)')
def trailing_zeros(n):
order = 0
while (n & 1) == 0:
order += 1
n //= 2
return order
def main():
print(trailing_zeros_jit(32))
print(trailing_zeros(32))
if __name__ == '__main__':
main()
|
!--------------------------------------------------------------------------------------------------
! MODULE: convert_input_mod
!> @author Marin Sapunar, Ruđer Bošković Institute
!> @date August, 2018
!
!> @brief Hold subroutines for convert program input handling.
!--------------------------------------------------------------------------------------------------
module convert_input_mod
use global_defs
use convert_variables
implicit none
private
public :: print_help
public :: set_defaults
public :: command_line_interface
contains
!----------------------------------------------------------------------------------------------
! SUBROUTINE: print_help
!> @brief Print help message and exit program.
!----------------------------------------------------------------------------------------------
subroutine print_help()
write(stdout, '(a)') 'usage: convert.exe [optional arguments] input_path output_path'
write(stdout, '(a)')
write(stdout, '(a)') 'Convert geometry/basis/MOs to different format.'
write(stdout, '(a)')
write(stdout, '(a)') 'positional arguments:'
write(stdout, '(a)') ' input_path path for input file(s) in original format '
write(stdout, '(a)') ' output_path path for output file(s) '
write(stdout, '(a)')
write(stdout, '(a)') 'optional arguments:'
write(stdout, '(a)') ' -h, --help show this help message and exit '
write(stdout, '(a)') ' -in, --input-format format of input file(s) '
write(stdout, '(32x,a,a)') 'default: ', input_format
write(stdout, '(a)') ' -out, --output-format output format '
write(stdout, '(32x,a,a)') 'default: ', output_format
write(stdout, '(a)') ' -p, --print-level p control output level of program (0 = quiet) '
write(stdout, '(32x,a,i0)') 'default: ', print_level
stop
end subroutine print_help
!----------------------------------------------------------------------------------------------
! SUBROUTINE: set_defaults
!> @brief Set default values for program options.
!----------------------------------------------------------------------------------------------
subroutine set_defaults()
use ang_mom_defs
call amp%init(7)
! CLI options.
input_format = 'turbomole'
output_format = 'molden_cart'
print_level = 0
end subroutine set_defaults
!----------------------------------------------------------------------------------------------
! SUBROUTINE: command_line_interface
!> @brief Read command line options.
!----------------------------------------------------------------------------------------------
subroutine command_line_interface()
integer :: narg, i
character(len=1000) :: temp
narg = command_argument_count()
i = 0
if (narg == 0) call print_help()
do while (i < narg)
i = i + 1
if (i == narg) call print_help()
call get_command_argument(i, temp)
if ((i == narg - 1) .and. (temp /= '--help') .and. (temp /= '-h')) exit
select case(temp)
case('--help', '-h')
call print_help()
case('--input-format', '-in')
i = i + 1
call get_command_argument(i, temp)
input_format = trim(adjustl(temp))
case('--output-format', '-out')
i = i + 1
call get_command_argument(i, temp)
output_format = trim(adjustl(temp))
case('--print-level', '-p')
i = i + 1
call get_command_argument(i, temp)
read(temp, *) print_level
end select
end do
call get_command_argument(narg-1, temp)
input_path = trim(adjustl(temp))
call get_command_argument(narg, temp)
output_path = trim(adjustl(temp))
end subroutine command_line_interface
end module convert_input_mod
|
#' @export
evaluate <- function(x, interpreter) UseMethod("evaluate")
#' @export
evaluate.lox_expr_literal <- function(x, interpreter) {
x$value
}
#' @export
evaluate.lox_expr_logical <- function(x, interpreter) {
left <- evaluate(x$left, interpreter)
if (is_type(x$operator, token_type$OR)) {
# short circuit OR
if (is_truthy(left)) return(left)
} else {
# short circuit AND
if (!is_truthy(left)) return(left)
}
evaluate(x$right, interpreter)
}
#' @export
evaluate.lox_expr_grouping <- function(x, interpreter) {
evaluate(x$expression, interpreter)
}
#' @export
evaluate.lox_expr_unary <- function(x, interpreter) {
right <- evaluate(x$right, interpreter)
type <- x$operator$type
if (type == token_type$BANG) {
!is_truthy(right)
} else if (type == token_type$MINUS) {
check_number_operand(x$operator, right)
-as.double(right)
} else {
lox_runtime_error(
sprintf("Cannot evaluate unary expression \n%s", format(x)),
x$operator
)
}
}
#' @export
evaluate.lox_expr_binary <- function(x, interpreter) {
left <- evaluate(x$left, interpreter)
right <- evaluate(x$right, interpreter)
type <- x$operator$type
if (type == token_type$BANG_EQUAL) {
!is_equal(left, right)
} else if (type == token_type$EQUAL_EQUAL) {
is_equal(left, right)
} else if (type == token_type$GREATER) {
check_number_operands(x$operator, left, right)
as.double(left) > as.double(right)
} else if (type == token_type$GREATER_EQUAL) {
check_number_operands(x$operator, left, right)
as.double(left) >= as.double(right)
} else if (type == token_type$LESS) {
check_number_operands(x$operator, left, right)
as.double(left) < as.double(right)
} else if (type == token_type$LESS_EQUAL) {
check_number_operands(x$operator, left, right)
as.double(left) <= as.double(right)
} else if (type == token_type$MINUS) {
check_number_operands(x$operator, left, right)
as.double(left) - as.double(right)
} else if (type == token_type$SLASH) {
check_number_operands(x$operator, left, right)
as.double(left) / as.double(right)
} else if (type == token_type$STAR) {
check_number_operands(x$operator, left, right)
as.double(left) * as.double(right)
} else if (type == token_type$PLUS){
if (is.numeric(left) && is.numeric(right)) {
as.double(left) + as.double(right)
} else if (is.character(left) && is.character(right)) {
paste0(left, right, collapse = " ")
} else {
lox_runtime_error(
sprintf("Operands must be two numbers or two strings: %s %s %s",
left, x$operator$lexeme, right),
x$operator
)
}
} else {
lox_runtime_error(
sprintf("Cannot evaluate binary expression \n%s", format(x)),
x$operator
)
}
}
#' @export
evaluate.lox_expr_variable <- function(x, interpreter) {
#env_get(interpreter$env_cur, x$name)
lookup_variable(x$name, x, interpreter)
}
#' Look-up variable in locals table
#' @param x expression
#' @param name token
#' @param interpreter interpreter
lookup_variable <- function(name, x, interpreter) {
id <- attr(x, "id")
if (interpreter$locals$has(id)) {
depth <- interpreter$locals$get(id)
env_get_at(interpreter$env_cur, name, depth)
} else {
env_get(interpreter$env_global, name, inherits = FALSE)
}
}
#' @export
evaluate.lox_expr_assignment <- function(x, interpreter) {
# evaluate expression
val <- evaluate(x$value, interpreter)
# assign value to name
#env_assign(env, x$name, val)
assign_variable(x$name, val, x, interpreter)
}
#' Assign variable in locals table
#' @param x expression
#' @param name token
#' @param value value to assign
#' @param interpreter interpreter
assign_variable <- function(name, value, x, interpreter) {
id <- attr(x, "id")
if (interpreter$locals$has(id)) {
depth <- interpreter$locals$get(id)
env_assign_at(interpreter$env_cur, name, value, depth)
} else {
env_assign(interpreter$env_global, name, value)
}
value
}
#' @export
evaluate.lox_expr_call <- function(x, interpreter) {
callee <- evaluate(x$callee, interpreter)
arguments <- lapply(x$arguments, evaluate, interpreter = interpreter)
if (!inherits(callee, "lox_callable")) {
lox_runtime_error("Can only call functions and classes", x$paren)
}
if (length(arguments) != arity(callee)) {
lox_runtime_error(
sprintf("Expected %i arguments but got %i.", arity(callee), length(arguments)),
x$paren
)
}
# call function
lox_call(callee, arguments, interpreter)
}
|
module Hands
import Data.Vect
import InsertionSort
import Card
import ElemsAreSame
import Sorted
import SlideWise
public export HAND_SIZE : Nat
HAND_SIZE = 5
--=======================================================================================================
--=======================================================================================================
--Utility proof data structures
--=======================================================================================================
--=======================================================================================================
data ForAll : Vect n elem -> (elem -> Type) -> Type where
ForVect : prf x -> ForAll xs prf -> ForAll (x::r) prf
End : ForAll [] pred
data AllSame : Vect n elem -> (elem -> elem -> Type) -> Type where
EmptyIsSame: AllSame [] prf
SingleIsSame: AllSame [x] prf
Same: prf x y -> AllSame (y::ys) prf -> AllSame (x::y::ys) prf
data SameValue: Card -> Card -> Type where
ValueMatch: SameValue (MkCard v _) (MkCard v _)
data SameSuit: Card -> Card -> Type where
SuitMatch: SameSuit (MkCard _ s) (MkCard _ s)
--=======================================================================================================
--=======================================================================================================
--Hand Proof data structures
--=======================================================================================================
--=======================================================================================================
data PairH: Vect 2 Card -> Type where
MkPair: PairH [(MkCard v _), (MkCard v _)]
data TwoPair: Vect HAND_SIZE Card -> Type where
MkTwoPair: Sorted hand -> (firstpair: SlideWise2 hand PairH) -> (secondPair:SlideWise2 (getRest2 hand firstpair) PairH) -> TwoPair hand
data ThreeOfAKind : Vect 3 Card -> Type where
MkThree: AllSame x SameValue -> ThreeOfAKind x
data Straight: Vect HAND_SIZE Card -> Type where
MkStraight: Sorted x -> Consecutive x -> Straight x
data Flush: Vect HAND_SIZE Card -> Type where
MkFlush: AllSame x SameSuit -> Flush x
data FullHouse: (hand:Vect HAND_SIZE Card) -> Type where
MkFullHouse: Sorted hand -> (three: SlideWise3 hand ThreeOfAKind) -> (pair: PairH (getRest3 hand three)) -> FullHouse hand
data FourOfAKind : Vect 4 Card -> Type where
MkFour: AllSame x SameValue -> FourOfAKind x
data StraightFlush: Vect HAND_SIZE Card -> Type where
MkStraightFlush: Straight x -> Flush x -> StraightFlush x
--=======================================================================================================
--=======================================================================================================
--Hand
--=======================================================================================================
--=======================================================================================================
export data Hand: Vect HAND_SIZE Card -> Type where
StraightFlushHand:
StraightFlush x -> Hand x
FourOfAKindHand:
{auto p:Sorted y} -> SlideWise4 y FourOfAKind -> Hand y
FullHouseHand:
FullHouse y -> Hand y
FlushHand:
Flush x -> Hand x
StraightHand:
Straight x -> Hand x
ThreeOfAKindHand:
{auto p:Sorted y} -> SlideWise3 y ThreeOfAKind -> Hand y
TwoPairHand:
{auto p:Sorted y} -> TwoPair y -> Hand y
PairHand:
{auto p:Sorted y} -> SlideWise2 y PairH -> Hand y
HighCardHand:
{auto p:Sorted kickers} -> (kickers: Vect HAND_SIZE Card) -> Hand kickers
--=======================================================================================================
--=======================================================================================================
-- Utility proofs
--=======================================================================================================
--=======================================================================================================
--=======================================================================================================
-- hasSameSuit
--=======================================================================================================
notSameSuit : (contra : (s1 = s2) -> Void) -> SameSuit (MkCard value s1) (MkCard value1 s2) -> Void
notSameSuit contra SuitMatch = contra Refl
hasSameSuit: (c1: Card) -> (c2: Card) -> Dec (SameSuit c1 c2)
hasSameSuit (MkCard _ s1) (MkCard _ s2) = case decEq s1 s2 of
(Yes prf) => Yes (rewrite prf in SuitMatch)
(No contra) => No (notSameSuit contra)
--=======================================================================================================
-- hasSameValue
--=======================================================================================================
notSameValue : (contra : (v1 = v2) -> Void) -> SameValue (MkCard v1 suit) (MkCard v2 suit1) -> Void
notSameValue contra ValueMatch = contra Refl
hasSameValue: (c1: Card) -> (c2: Card) -> Dec (SameValue c1 c2)
hasSameValue (MkCard v1 _) (MkCard v2 _) = case decEq v1 v2 of
(Yes prf) => Yes (rewrite prf in ValueMatch)
(No contra) => No (notSameValue contra)
--=======================================================================================================
-- allSameSuit
--=======================================================================================================
restNotSameSuit : (contra : AllSame (x2 :: xs) SameSuit -> Void) -> AllSame (x1 :: (x2 :: xs)) SameSuit -> Void
restNotSameSuit contra (Same x y) = contra y
singleNotSameSuit : (contra : SameSuit x1 x2 -> Void) -> AllSame (x1 :: (x2 :: xs)) SameSuit -> Void
singleNotSameSuit contra (Same x y) = contra x
allSameSuit: (x: Vect n Card) -> Dec (AllSame x SameSuit)
allSameSuit [] = Yes EmptyIsSame
allSameSuit [x] = Yes SingleIsSame
allSameSuit (x1 :: x2 :: xs) = case allSameSuit (x2 :: xs) of
(Yes prf_rest) => case hasSameSuit x1 x2 of
(Yes prf_single) => Yes (Same prf_single prf_rest)
(No contra) => No (singleNotSameSuit contra)
(No contra) => No (restNotSameSuit contra)
--=======================================================================================================
-- isNoOfKind
--=======================================================================================================
restNotSame: (contra : AllSame (x2 :: xs) SameValue -> Void) -> AllSame (x1 :: (x2 :: xs)) SameValue -> Void
restNotSame contra (Same x y) = contra y
singleNotSame : (contra : SameValue x1 x2 -> Void) -> AllSame (x1 :: (x2 :: xs)) SameValue -> Void
singleNotSame contra (Same x y) = contra x
isNoOfKind: (x: Vect n Card) -> Dec (AllSame x SameValue)
isNoOfKind [] = Yes EmptyIsSame
isNoOfKind [x] = Yes SingleIsSame
isNoOfKind (x1 :: x2 :: xs) = case isNoOfKind (x2 :: xs) of
(Yes prf_rest) => (case hasSameValue x1 x2 of
(Yes prf_single) => Yes (Same prf_single prf_rest)
(No contra) => No (singleNotSame contra))
(No contra) => No (restNotSame contra)
--=======================================================================================================
--=======================================================================================================
--Hand Proofs
--=======================================================================================================
--=======================================================================================================
--=======================================================================================================
-- Pair
--=======================================================================================================
isNotPair : (contra : (v1 = v2) -> Void) -> PairH [(MkCard v1 suit), (MkCard v2 suit1)] -> Void
isNotPair contra MkPair = contra Refl
isPair: (p: Vect 2 Card) -> Dec (PairH p)
isPair [(MkCard v1 _), (MkCard v2 _)] = case decEq v1 v2 of
(Yes prf) => Yes (rewrite prf in MkPair)
(No contra) => No (isNotPair contra)
isPairHand: (hand: Vect HAND_SIZE Card) -> {auto sort_prf: Sorted hand }-> Dec (SlideWise2 hand PairH)
isPairHand hand {sort_prf} = isSlideWise2 hand isPair
--=======================================================================================================
-- Two Pair
--=======================================================================================================
pairInRest: {hand: Vect HAND_SIZE Card} -> (firstPair: SlideWise2 hand PairH) -> Dec (SlideWise2 (getRest2 hand firstPair) PairH)
pairInRest (HeadMatches2 searched match rest x) = isSlideWise2 (getRest2 (match ++ rest) (HeadMatches2 searched match rest x)) isPair
pairInRest (RestMatches2 x rest y) = isSlideWise2 (getRest2 (x :: rest) (RestMatches2 x rest y)) isPair
||| TODO return Dec instead
isTwoPairHand: (hand: Vect HAND_SIZE Card) -> {auto sort_prf: Sorted hand} -> Maybe (TwoPair hand)
isTwoPairHand hand {sort_prf} = case isPairHand hand of
(Yes first_prf) => (case pairInRest first_prf of
(Yes snd_prf) => Just (MkTwoPair sort_prf first_prf snd_prf)
(No contra) => Nothing)
(No contra) => Nothing
--=======================================================================================================
-- Three of a Kind
--=======================================================================================================
notThreeOfAKind : (contra : AllSame x SameValue -> Void) -> ThreeOfAKind x -> Void
notThreeOfAKind contra (MkThree x) = contra x
isThreeOfAKind: (x: Vect 3 Card) -> Dec (ThreeOfAKind x)
isThreeOfAKind x = case isNoOfKind x of
(Yes prf) => Yes (MkThree prf)
(No contra) => No (notThreeOfAKind contra)
isThreeOfAKindHand: (hand: Vect 5 Card) -> {auto sort_prf: Sorted hand} -> Dec (SlideWise3 hand ThreeOfAKind)
isThreeOfAKindHand hand = isSlideWise3 hand isThreeOfAKind
--=======================================================================================================
-- Straight
--=======================================================================================================
notConsecSoNotStraight : (contra : Consecutive x -> Void) -> Straight x -> Void
notConsecSoNotStraight contra (MkStraight x y) = contra y
isStraight: (x: Vect HAND_SIZE Card) -> {auto sort_prf:Sorted x} -> Dec (Straight x)
isStraight {sort_prf} x = case isConsecutive x of
(Yes prf) => Yes (MkStraight sort_prf prf)
(No contra) => No (notConsecSoNotStraight contra)
--=======================================================================================================
-- Flush
--=======================================================================================================
notFlush : (contra : AllSame x SameSuit -> Void) -> Flush x -> Void
notFlush contra (MkFlush (Same z w)) = contra (Same z w)
isFlush: (x: Vect HAND_SIZE Card) -> Dec (Flush x)
isFlush x = case allSameSuit x of
(Yes prf) => Yes (MkFlush prf)
(No contra) => No (notFlush contra)
--=======================================================================================================
-- Full House
--=======================================================================================================
isFullHouse: (hand: Vect HAND_SIZE Card) -> (sort_prf: Sorted hand) -> Maybe (FullHouse hand)
isFullHouse hand sort_prf = case isThreeOfAKindHand hand of
(No contra) => Nothing
(Yes three_prf) => (case isPair (getRest3 hand three_prf) of
(Yes pair_prf) => Just (MkFullHouse sort_prf three_prf pair_prf)
(No contra) => Nothing)
--=======================================================================================================
-- Four of a Kind
--=======================================================================================================
notFourOfAKind : (contra : AllSame x SameValue -> Void) -> FourOfAKind x -> Void
notFourOfAKind contra (MkFour x) = contra x
isFourOfAKind: (x: Vect 4 Card) -> Dec (FourOfAKind x)
isFourOfAKind x = case isNoOfKind x of
(Yes prf) => Yes (MkFour prf)
(No contra) => No (notFourOfAKind contra)
isFourOfAKindHand: (hand: Vect 5 Card) -> Sorted hand -> Dec (SlideWise4 hand FourOfAKind)
isFourOfAKindHand hand sort_prf = isSlideWise4 hand isFourOfAKind
--=======================================================================================================
-- Straight Flush
--=======================================================================================================
notStraightSoNotSF : (contra : Straight x -> Void) -> StraightFlush x -> Void
notStraightSoNotSF contra (MkStraightFlush straight flush) = contra straight
notFlushSoNotSF : (contra : Flush x -> Void) -> StraightFlush x -> Void
notFlushSoNotSF contra (MkStraightFlush straight flush) = contra flush
isStraightFlush: (x: Vect HAND_SIZE Card) -> {auto sort_prf:Sorted x} -> Dec (StraightFlush x)
isStraightFlush x = case isStraight x of
(Yes straight_prf) => (case isFlush x of
(Yes flush_prf) => Yes (MkStraightFlush straight_prf flush_prf)
(No contra) => No (notFlushSoNotSF contra))
(No contra) => No (notStraightSoNotSF contra)
--=======================================================================================================
--=======================================================================================================
-- Hand evaluator
--=======================================================================================================
--=======================================================================================================
evalRestHand : (hand: Vect HAND_SIZE Card) -> (sort_prf : Sorted hand) -> (contra_4 : SlideWise4 hand FourOfAKind -> Void) -> (contra_sf : StraightFlush hand -> Void) -> Hand hand
evalRestHand hand sort_prf contra_4 contra_sf = case isFlush hand of
(Yes prf) => FlushHand prf
(No contra_flush) => (case isStraight hand of
(Yes prf) => StraightHand prf
(No contra) => (case isThreeOfAKindHand hand of
(Yes prf) => ThreeOfAKindHand prf
(No contra) => (case isTwoPairHand hand of
(Just prf) => TwoPairHand prf
Nothing => (case isPairHand hand of
(Yes prf) => PairHand prf
(No contra) => HighCardHand hand))))
export evalHand: (hand: Vect HAND_SIZE Card) -> Sorted hand -> Hand hand
evalHand hand sort_prf = case isStraightFlush hand of
(Yes prf) => StraightFlushHand prf
(No contra_sf) => (case isFourOfAKindHand hand sort_prf of
Yes prf => FourOfAKindHand prf
No contra_4 => (case isFullHouse hand sort_prf of
Just prf => FullHouseHand prf
Nothing => evalRestHand hand sort_prf contra_4 contra_sf))
compareStraightFlushes : (x : StraightFlush h1) -> (y : StraightFlush h2) -> Ordering
compareStraightFlushes {h1 = (x1 :: xs1)} {h2 = (x2:: xs2)} x y = compare (cardValue x1) (cardValue x2)
compareFourOfAKinds : (x : SlideWise4 h1 FourOfAKind) -> (y : SlideWise4 h2 FourOfAKind) -> Ordering
compareFourOfAKinds {h1} {h2} x y = let ((x1::xs), kicker1::[]) = getMatchAndRest4 h1 x
((y1::ys), kicker2::[]) = getMatchAndRest4 h2 y in
(case compare (cardValue x1) (cardValue y1) of
LT => LT
EQ => compare (cardValue kicker1) (cardValue kicker2)
GT => GT)
compareHighCards : (h1 : Vect n Card) -> (h2 : Vect n Card) -> Ordering
compareHighCards [] [] = EQ
compareHighCards (x :: xs) (y :: ys) = case compare (cardValue x) (cardValue y) of
LT => LT
EQ => compareHighCards xs ys
GT => GT
compareFlushes : (x : Flush h1) -> (y : Flush h2) -> Ordering
compareFlushes {h1} {h2} x y = compareHighCards h1 h2
comparePairs : {h1, h2: Vect (S(S n)) Card} -> (x : SlideWise2 h1 PairH) -> (y : SlideWise2 h2 PairH) -> Ordering
comparePairs {h1} {h2} x y = let ((x1::xs), kickers1) = getMatchAndRest2 h1 x
((y1::ys), kickers2) = getMatchAndRest2 h2 y in
(case compare (cardValue x1) (cardValue y1) of
LT => LT
EQ => compareHighCards kickers1 kickers2
GT => GT)
getHighLowPair: Card -> Card -> (Card, Card)
getHighLowPair x y = case compare (cardValue x) (cardValue y) of
LT => (y, x)
gtOrEq => (x, y)
compareTwoPairs : {h1, h2: Vect HAND_SIZE Card} -> (x : TwoPair h1) -> (y : TwoPair h2) -> Ordering
compareTwoPairs {h1} {h2} (MkTwoPair x firstPair1 secondPair1)
(MkTwoPair y firstPair2 secondPair2) = let (firstmatch1::f1) = getMatch2 h1 firstPair1
(secondmatch1::s1, kicker1::[]) = getMatchAndRest2 (getRest2 h1 firstPair1) secondPair1
(firstmatch2::f2) = getMatch2 h2 firstPair2
(secondmatch2::s2, kicker2::[]) = getMatchAndRest2 (getRest2 h2 firstPair2) secondPair2
(highestPair1, lowestPair1) = getHighLowPair firstmatch1 secondmatch1
(highestPair2, lowestPair2) = getHighLowPair firstmatch2 secondmatch2
in
(case compare (cardValue highestPair1) (cardValue highestPair2) of
LT => LT
GT => GT
EQ => (case compare (cardValue lowestPair1) (cardValue lowestPair2) of
LT => LT
EQ => compare (cardValue kicker1) (cardValue kicker2)
GT => GT))
compareThreeOfAKinds : {h1, h2: Vect (S(S(S n))) Card} -> (x : SlideWise3 h1 ThreeOfAKind) -> (y : SlideWise3 h2 ThreeOfAKind) -> Ordering
compareThreeOfAKinds {h1} {h2} x y = let ((x1::xs), kickers1) = getMatchAndRest3 h1 x
((y1::ys), kickers2) = getMatchAndRest3 h2 y in
(case compare (cardValue x1) (cardValue y1) of
LT => LT
EQ => compareHighCards kickers1 kickers2
GT => GT)
comparePairHs : (pair_prf1 : PairH h1) -> (pair_prf2 : PairH h2) -> Ordering
comparePairHs {h1} {h2} pair_prf1 pair_prf2 = compareHighCards h1 h2
compareFullHouseHands : (x : FullHouse h1) -> (y : FullHouse h2) -> Ordering
compareFullHouseHands {h1} (MkFullHouse x three_prf1 pair_prf1)
{h2} (MkFullHouse y three_prf2 pair_prf2) = let (threeCard1::_) = (getMatch3 h1 three_prf1)
(threeCard2::_) = (getMatch3 h2 three_prf2) in
(case compare (cardValue threeCard1) (cardValue threeCard2) of
LT => LT
EQ => comparePairHs pair_prf1 pair_prf2
GT => GT)
compareStraights : {h1, h2: Vect HAND_SIZE Card} -> (x : Straight h1) -> (y : Straight h2) -> Ordering
compareStraights {h1} {h2} x y = compareHighCards h1 h2
export compareHands: {h1, h2: Vect HAND_SIZE Card} -> (hand1: Hand h1) -> (hand2: Hand h2) -> Ordering
compareHands (StraightFlushHand x) (StraightFlushHand y) = compareStraightFlushes x y
compareHands (StraightFlushHand x) hand2 = GT
compareHands (FourOfAKindHand x) (StraightFlushHand y) = LT
compareHands (FourOfAKindHand x) (FourOfAKindHand y) = compareFourOfAKinds x y
compareHands (FourOfAKindHand x) hand2 = GT
compareHands (FullHouseHand x) (StraightFlushHand y) = LT
compareHands (FullHouseHand x) (FourOfAKindHand y) = LT
compareHands (FullHouseHand x) (FullHouseHand y) = compareFullHouseHands x y
compareHands (FullHouseHand x) hand2 = GT
compareHands (FlushHand x) (StraightFlushHand y) = LT
compareHands (FlushHand x) (FourOfAKindHand y) = LT
compareHands (FlushHand x) (FullHouseHand y) = LT
compareHands (FlushHand x) (FlushHand y) = compareFlushes x y
compareHands (FlushHand x) hand2 = GT
compareHands (StraightHand x) (StraightFlushHand y) = LT
compareHands (StraightHand x) (FourOfAKindHand y) = LT
compareHands (StraightHand x) (FullHouseHand y) = LT
compareHands (StraightHand x) (FlushHand y) = LT
compareHands (StraightHand x) (StraightHand y) = compareStraights x y
compareHands (StraightHand x) hand2 = GT
compareHands (ThreeOfAKindHand x) (StraightFlushHand y) = LT
compareHands (ThreeOfAKindHand x) (FourOfAKindHand y) = LT
compareHands (ThreeOfAKindHand x) (FullHouseHand y) = LT
compareHands (ThreeOfAKindHand x) (FlushHand y) = LT
compareHands (ThreeOfAKindHand x) (StraightHand y) = LT
compareHands (ThreeOfAKindHand x) (ThreeOfAKindHand y) = compareThreeOfAKinds x y
compareHands (ThreeOfAKindHand x) hand2 = GT
compareHands (TwoPairHand x) (HighCardHand h2) = GT
compareHands (TwoPairHand x) (PairHand y) = GT
compareHands (TwoPairHand x) (TwoPairHand y) = compareTwoPairs x y
compareHands (TwoPairHand x) hand2 = LT
compareHands (PairHand x) (HighCardHand h2) = GT
compareHands (PairHand x) (PairHand y) = comparePairs x y
compareHands (PairHand x) hand2 = LT
compareHands (HighCardHand h1) (HighCardHand h2) = compareHighCards h1 h2
compareHands (HighCardHand h1) hand2 = LT
showHighCard : (h : Vect HAND_SIZE Card) -> String
showHighCard (x :: xs) = "High Card: " ++ (show (cardValue x))
showPair :{h: Vect HAND_SIZE Card} -> (x : SlideWise2 h PairH) -> String
showPair {h} x = let (m::ms, r::rs) = getMatchAndRest2 h x in
"Pair: " ++ (show (cardValue m)) ++ "s with a " ++ (show (cardValue r)) ++ " kicker"
showTwoPair : (x : TwoPair h)-> String
showTwoPair {h} (MkTwoPair x firstPair secondPair) = let (m1::ms1) = getMatch2 h firstPair
(m2::ms2, [kicker]) = getMatchAndRest2 (getRest2 h firstPair) secondPair in
"Two Pair: " ++ (show (cardValue m1)) ++ "s and " ++ (show (cardValue m2)) ++ "s with a " ++ (show (cardValue kicker)) ++ " kicker"
showThreeOfAKind : (x : SlideWise3 h ThreeOfAKind) -> String
showThreeOfAKind {h} x = let (m::ms, r::rs) = getMatchAndRest3 h x in
"Three of a kind: " ++ (show (cardValue m)) ++ "s with a " ++ (show (cardValue r)) ++ " kicker"
showStraight : (x : Straight h) -> String
showStraight {h = (z :: xs)} (MkStraight x y) = "Straight: " ++ (show (cardValue z)) ++ " high"
showFlush : (x : Flush h) -> String
showFlush {h = (y :: xs)} x = "Flush: " ++ (show (cardValue y)) ++ " high"
showFullHouse : (x : FullHouse h) -> String
showFullHouse {h} (MkFullHouse x three pair) = let (m1::m1s) = getMatch3 h three
(m2::m2s) = (getRest3 h three) in
"Full house: " ++ (show (cardValue m1)) ++ "s over " ++ (show (cardValue m2)) ++ "s"
showFourOfAKind : (x : SlideWise4 h FourOfAKind) -> String
showFourOfAKind {h} x = let (m::ms, [kicker]) = getMatchAndRest4 h x in
"Four of a kind: " ++ (show (cardValue m)) ++ "s with a " ++ (show (cardValue kicker)) ++ " kicker"
showStraightFlush : (x : StraightFlush h) -> String
showStraightFlush {h = (y :: xs)} x = "Straight flush: " ++ (show (cardValue y)) ++ " high"
export Show (Hand h) where
show (StraightFlushHand x) = showStraightFlush x
show (FourOfAKindHand x) = showFourOfAKind x
show (FullHouseHand x) = showFullHouse x
show (FlushHand x) = showFlush x
show (StraightHand x) = showStraight x
show (ThreeOfAKindHand x) = showThreeOfAKind x
show (TwoPairHand x) = showTwoPair x
show (PairHand x) = showPair x
show (HighCardHand h) = showHighCard h
|
theory T114
imports Main
begin
lemma "(
(\<forall> x::nat. \<forall> y::nat. meet(x, y) = meet(y, x)) &
(\<forall> x::nat. \<forall> y::nat. join(x, y) = join(y, x)) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(x, meet(y, z)) = meet(meet(x, y), z)) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(x, join(y, z)) = join(join(x, y), z)) &
(\<forall> x::nat. \<forall> y::nat. meet(x, join(x, y)) = x) &
(\<forall> x::nat. \<forall> y::nat. join(x, meet(x, y)) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(x, join(y, z)) = join(mult(x, y), mult(x, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(join(x, y), z) = join(mult(x, z), mult(y, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(x, over(join(mult(x, y), z), y)) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(y, undr(x, join(mult(x, y), z))) = y) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(mult(over(x, y), y), x) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(mult(y, undr(y, x)), x) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(meet(x, y), z) = meet(mult(x, z), mult(y, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. undr(x, join(y, z)) = join(undr(x, y), undr(x, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. over(x, meet(y, z)) = join(over(x, y), over(x, z))) &
(\<forall> x::nat. \<forall> y::nat. invo(join(x, y)) = meet(invo(x), invo(y))) &
(\<forall> x::nat. \<forall> y::nat. invo(meet(x, y)) = join(invo(x), invo(y))) &
(\<forall> x::nat. invo(invo(x)) = x)
) \<longrightarrow>
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. over(join(x, y), z) = join(over(x, z), over(y, z)))
"
nitpick[card nat=7,timeout=86400]
oops
end |
Formal statement is: lemma smallI: "(\<And>c. c > 0 \<Longrightarrow> eventually (\<lambda>x. R (norm (f x)) (c * (norm (g x)))) F) \<Longrightarrow> f \<in> l F (g)" Informal statement is: If $f$ is small compared to $g$, then $f$ is in $l F (g)$. |
function MB = storage(x)
% return size of doubles matrix of size x in megabytes
MB= prod(x)*8/1024/1024;
end
|
\subsection{Identifying heuristics}
Generating heuristics for search. we can losen restriction to get a much simpler problem and rank moves by how good they are for loosened problem.
eg for for path to goal, assume can go directly from next place in a straight line.
|
lemma (in topological_space) at_within_union: "at x within (S \<union> T) = sup (at x within S) (at x within T)" |
module System.File.Virtual
import System.File.Support
import public System.File.Types
import System.FFI
%default total
fileClass : String
fileClass = "io/github/mmhelloworld/idrisjvm/runtime/ChannelIo"
%foreign support "idris2_stdin"
"node:lambda:x=>({fd:0, buffer: Buffer.alloc(0), name:'<stdin>', eof: false})"
jvm runtimeClass "getStdin"
prim__stdin : FilePtr
%foreign support "idris2_stdout"
"node:lambda:x=>({fd:1, buffer: Buffer.alloc(0), name:'<stdout>', eof: false})"
jvm runtimeClass "getStdout"
prim__stdout : FilePtr
%foreign support "idris2_stderr"
"node:lambda:x=>({fd:2, buffer: Buffer.alloc(0), name:'<stderr>', eof: false})"
jvm runtimeClass "getStderr"
prim__stderr : FilePtr
export
stdin : File
stdin = FHandle prim__stdin
export
stdout : File
stdout = FHandle prim__stdout
export
stderr : File
stderr = FHandle prim__stderr
|
module Test06
import Automa
import Automa.RegExp: @re_str
using Test
@testset "Test06" begin
re = Automa.RegExp
foo = re.cat("foo")
foos = re.rep(re.cat(foo, re" *"))
foo.actions[:exit] = [:foo]
actions = Dict(:foo => :(push!(ret, state.p:p-1); @escape))
machine = Automa.compile(foos)
@eval mutable struct MachineState
p::Int
cs::Int
function MachineState()
$(Automa.generate_init_code(Automa.CodeGenContext(), machine))
return new(p, cs)
end
end
for generator in (:table, :inline, :goto), checkbounds in (true, false), clean in (true, false)
ctx = Automa.CodeGenContext(generator=generator, checkbounds=checkbounds, clean=clean)
run! = @eval function (state, data)
ret = []
p = state.p
cs = state.cs
p_end = p_eof = lastindex(data)
$(Automa.generate_exec_code(ctx, machine, actions))
state.p = p
state.cs = cs
return ret
end
state = MachineState()
data = b"foo foofoo foo"
@test run!(state, data) == [1:3]
@test run!(state, data) == [5:7]
@test run!(state, data) == [9:10]
@test run!(state, data) == [12:16]
@test run!(state, data) == []
@test run!(state, data) == []
end
end
end
|
module CLaSH.Prelude
import CLaSH.Default
import CLaSH.Signal
import CLaSH.Prelude.Vect
import Data.HVect
%access public
window : (Default a) => Signal a -> Vect (S (S n)) (Signal a)
window {a} x = (x::prev)
where
prev : Default a => Vect (S n) (Signal a)
next : Default a => Vect (S n) (Signal a)
prev = unpack (register (pure def) (pack next))
next = x +>> prev
|
import algebra.big_operators.basic
namespace coding_theory
section hamming
open_locale big_operators
variables {n : ℕ} {K : Type*} (x y z : fin n → K)
section decidable_eq
variable [decidable_eq K]
open finset function
def ham_dist : ℕ := (filter (λ i, x i ≠ y i) univ).card
@[simp]
lemma ham_dist_eq : ham_dist x y = (filter (λ i, x i ≠ y i) univ).card := rfl
lemma ham_dist_eq_sum_ite : ham_dist x y = ∑ i, if x i ≠ y i then 1 else 0 :=
by { simp, rw [sum_ite, ← card_eq_sum_ones, sum_const_zero, zero_add] }
@[simp]
lemma ham_dist_self_eq_zero : ham_dist x x = 0 := by simp
lemma ham_dist_comm : ham_dist x y = ham_dist y x :=
by { simp, congr, ext, exact ne_comm }
lemma zero_le_ham_dist : 0 ≤ ham_dist x y := zero_le _
lemma ham_dist_eq_zero_iff_eq : ham_dist x y = 0 ↔ x = y :=
begin
split; intros h; [refine funext _, rw h]; [contrapose h, exact ham_dist_self_eq_zero _],
rw [ham_dist_eq, card_eq_zero, filter_eq_empty_iff],
simpa only [mem_univ, not_not, forall_true_left]
end
lemma ham_dist_pos_iff_neq : 0 < ham_dist x y ↔ x ≠ y :=
begin
rw [ne.def, ← ham_dist_eq_zero_iff_eq], split; intros h;
[intro c, exact lt_of_le_of_ne (zero_le_ham_dist _ _) (ne.symm h)],
rw c at h, exact nat.not_lt_zero _ h
end
lemma ham_dist_le : ham_dist x y ≤ ham_dist x z + ham_dist z y :=
begin
simp_rw ham_dist_eq,
refine le_trans (card_le_of_subset _) (card_union_le _ _),
intros i, simp_rw [mem_union, mem_filter],
simp only [mem_univ, ne.def, true_and], contrapose!,
exact λ ⟨_, _⟩, eq.trans (by assumption) (by assumption)
end
section has_zero
variable [has_zero K]
def ham_wt : ℕ := ham_dist x 0
@[simp]
lemma ham_wt_eq : ham_wt x = (filter (λ i, x i ≠ 0) univ).card := ham_dist_eq _ _
lemma ham_wt_eq_sum_ite : ham_wt x = ∑ i, if x i ≠ 0 then 1 else 0 := ham_dist_eq_sum_ite _ _
@[simp]
lemma ham_wt_zero_eq_zero : ham_wt (0 : fin n → K) = 0 := ham_dist_self_eq_zero _
lemma zero_le_ham_wt : 0 ≤ ham_wt x := zero_le_ham_dist _ _
lemma ham_wt_eq_zero_iff_zero : ham_wt x = 0 ↔ x = 0 := ham_dist_eq_zero_iff_eq _ _
lemma ham_wt_pos_iff_neq : 0 < ham_wt x ↔ x ≠ 0 := ham_dist_pos_iff_neq _ _
end has_zero
section add_group
variable [add_group K]
lemma ham_dist_eq_wt : ham_dist x y = ham_wt (x - y) :=
by simp_rw [ham_dist_eq, ham_wt_eq, pi.sub_apply, sub_ne_zero]
end add_group
section mul_zero_class
variables [mul_zero_class K] (t : K)
lemma wt_smul_le : ham_wt (t • x) ≤ (if t ≠ 0 then 1 else 0) * (ham_wt x) :=
begin
split_ifs,
{ simp only [ ham_wt_eq, pi.smul_apply, smul_eq_mul, ne.def, one_mul],
refine card_le_of_subset (λ _, _), simp only [mem_filter, mem_univ, true_and],
exact right_ne_zero_of_mul },
{ rw not_not at h, simp only [h, zero_smul, ham_wt_zero_eq_zero, zero_mul] }
end
end mul_zero_class
end decidable_eq
end hamming
/-
namespace discrete
variables
def dist {K : Type*} [decidable_eq K] := λ x y : K, if x = y then (0 : ℝ) else 1
@[simp]
def dist_eq {K : Type*} [decidable_eq K] (x y : K) : dist x y = if x = y then 0 else 1 := rfl
def pseudo_metric_space (K : Type*) [decidable_eq K] : pseudo_metric_space K := {
dist := discrete.dist,
dist_self := λ _, by simp [dist_eq],
dist_comm := λ x y, by simp_rw [dist, eq_comm],
dist_triangle := λ x y z,
by { simp[dist], split_ifs;
try {simp only [ add_zero, zero_add, zero_le_one,
one_add_one_eq_two, one_le_two, zero_le_two]},
finish }
}
def metric_space (K : Type*) [decidable_eq K] [has_zero K] : metric_space K :=
{ ..(discrete.pseudo_metric_space K),
eq_of_dist_eq_zero := λ x y h, by { by_contradiction c, simp at h,
rw ite_eq_left_iff at h, exact one_ne_zero (h c) },
}
instance [add_comm_group K] : normed_group K := {
norm := λ x, dist x 0,
dist_eq := λ x y, by simp_rw [dist, sub_eq_zero] }
instance [non_unital_ring K] : non_unital_normed_ring K := {
norm_mul := begin end,
}
end discrete
namespace fin
instance : uniform_space (fin n) := ⊥
noncomputable instance : has_dist (fin n) := ⟨λ x y, dist (x : ℝ) y⟩
lemma dist_eq (x y : fin n) : dist x y = |x - y| := rfl
lemma dist_coe_nat (x y : fin n) : dist (x : ℕ) (y : ℕ) = dist x y := rfl
@[norm_cast, simp] theorem dist_cast_real {n : ℕ} (x y : (fin n)) : dist (x : ℝ) y = dist x y := rfl
lemma pairwise_one_le_dist : pairwise (λ x y : fin n, 1 ≤ dist x y) :=
begin
intros x y hxy,
rw ← dist_coe_nat,
apply nat.pairwise_one_le_dist,
contrapose! hxy,
apply fin.coe_injective hxy
end
open metric
lemma uniform_embedding_coe_real : uniform_embedding (coe : (fin n) → ℝ) :=
uniform_embedding_bot_of_pairwise_le_dist real.zero_lt_one pairwise_one_le_dist
lemma closed_embedding_coe_real : closed_embedding (coe : (fin n) → ℝ) :=
closed_embedding_of_pairwise_le_dist real.zero_lt_one pairwise_one_le_dist
noncomputable instance : metric_space (fin n) := uniform_embedding_coe_real.comap_metric_space _
lemma dist_0_eq {x : fin (n + 1)} (h : x ≤ n / 2) : dist x 0 = x :=
begin
split_ifs; rw dist_eq; simp, norm_cast,
end
end fin
variables (p : ℕ) [fact p.prime]
instance : normed_field (zmod p) := {! !}
end zmod
def codeword (n : ℕ) := pi_Lp 1 (λ x : fin n, zmod 2)
#check (0 : pi_Lp 1 (λ x : fin 3, zmod 2))
-/
end coding_theory |
Formal statement is: lemma connected_component_refl: "x \<in> S \<Longrightarrow> connected_component S x x" Informal statement is: The connected component of a point $x$ in a set $S$ containing $x$ is $x$ itself. |
As the Vocation Formation Team of the Missionary Servants of the Most Blessed Trinity, we have the distinct pleasure of accompanying single Catholic women as they discern God’s call in their lives. If you are discerning your call, then we invite you to contact us to learn more.
You are called by God to live as a disciple of Jesus. Discernment is the process of finding out how God is leading you to live out that call.
Learn more about the deep and rewarding discernment process, from initial inquiry to the making of the Perpetual Profession of Vows.
Interested in learning more about a vocation? We'd love to hear from you! Get in touch with us now using this easy inquiry form.
The Missionary Servants of the Most Blessed Trinity (MSBT) is an apostolic community of Roman Catholic women religious. We exist to give glory to the Trinity!
Our specific mission is the preservation of the faith, (think New Evangelization), in those areas and among those people who are spiritually neglected and abandoned, especially the poor. Our chief effort is to develop a missionary spirit in the laity, with the goal that every Catholic be an Apostle. |
\chapter{Abbreviations}
\begin{flushleft}
\renewcommand{\baselinestretch}{1.5}
\small\normalsize
\begin{longtable}{ll}
ARFF & Attribute Relation File Format\\
CSV & Comma Separated Values\\
MIS & Mascot Ion Score\\
MIT & Mascot Identity Threshold\\
MS/MS & Tandem Mass Spectrometry\\
\end{longtable}
\end{flushleft} |
{-# OPTIONS --without-K --safe #-}
open import Algebra.Bundles using (Semiring)
-- Credit: This definition is taken from the stdlib issue #1175
-- As given by @MatthewDaggitt and @mechvel
module Definitions.Semiring {α α≈} (R : Semiring α α≈)
where
open Semiring R
record NonZero (x : Carrier) : Set α≈ where
constructor mkNonZero
field
nonZero : x ≉ 0#
|
Formal statement is: lemma lowdim_eq_hyperplane: fixes S :: "'a::euclidean_space set" assumes "dim S = DIM('a) - 1" obtains a where "a \<noteq> 0" and "span S = {x. a \<bullet> x = 0}" Informal statement is: If $S$ is a set of vectors in $\mathbb{R}^n$ such that $\dim(S) = n-1$, then there exists a vector $a$ such that $S$ is the set of vectors $x$ such that $a \cdot x = 0$. |
module Lib2
import Data.List as L
D : Type
D = Double
LD : Type
LD = List D
LLD : Type
LLD = List LD
-- default value of base
b : D
b = 0.03
fullNNLayer : LLD -> LLD -> LLD
fullNNLayer [] _ = []
fullNNLayer _ [] = []
fullNNLayer (x::inps) (y::ws) = (softmax $ nnLayer x y ) :: fullNNLayer inps ws
nnLayer : LD -> LD -> LD
nnLayer xs ys = L.zipWith (\x,y => x * y + b) xs ys
softmax : LD -> LD
softmax xs = let softmax_denom = sum $ map exp $ xs
in foldr (\x, acc => (exp x)/softmax_denom::acc) [] xs
ceLoss : LD -> LD -> LD
ceLoss [] _ = []
ceLoss _ [] = []
ceLoss (x::xs) (y::ys) = -(y/x) + (1-y)/(1-x)::ceLoss xs ys
adam : LD -> LD -> D -> D -> D -> D -> D -> D -> LD
adam [] _ _ _ _ _ _ _ = []
adam _ [] _ _ _ _ _ _ = []
adam (t::thetas) (gt::gts) alpha m_prev v_prev beta1 beta2 epsilon = do
let m_current = (beta1 * m_prev + (1-beta1) * gt) /(1-beta1)
v_current = (beta2 * v_prev + (1-beta2) * (pow gt 2))/ (1-pow beta2 2)
mhat_current = m_current / (1-beta1)
vhat_current = v_current / (1-beta2)
(t - alpha * mhat_current / ((sqrt vhat_current) + epsilon)) :: adam thetas gts alpha m_current v_current beta1 beta2 epsilon
optimizer : (LD -> LD -> D -> D -> D -> D ->D -> D -> LD) ->
LLD -> LLD -> D -> D -> D -> D -> D -> D -> LLD
optimizer f [] _ _ _ _ _ _ _ = []
optimizer f _ [] _ _ _ _ _ _ = []
optimizer f (ws::wss) (cs::costs) alpha m v beta1 beta2 epsilon =
(f ws cs alpha m v beta1 beta2 epsilon) :: optimizer f wss costs alpha m v beta1 beta2 epsilon
record LossFx where
constructor CreateFx
fx : LD -> LD -> LD
-- preds, targets : LLD
record Optimizer {a : D} where
constructor OptimFx
fx : LD -> LD -> D -> D -> D -> D -> D -> D -> LD
weights , costs : LLD
alpha, m, v, beta1, beta2, epsilon : D
record Model where
constructor Create
weights, inputs, targets : LLD
alpha, beta1, beta2, epsilon : D
iter : Int
|
import pseudo_normed_group.basic
import analysis.normed_space.basic
/-!
# A seminormed group is pseudo-normed
This file contains the construction of a pseudo-normed group from a seminormed group.
-/
open_locale nnreal
namespace semi_normed_group
instance (V : Type*) [semi_normed_group V] : pseudo_normed_group V :=
{ filtration := λ c, {v | ∥v∥₊ ≤ c},
filtration_mono := λ c₁ c₂ h v (hv : ∥v∥ ≤ c₁), le_trans hv h,
zero_mem_filtration := λ c, by simp only [set.mem_set_of_eq, nnnorm_zero, zero_le],
neg_mem_filtration := λ c v hv, by simpa only [set.mem_set_of_eq, nnnorm_neg] using hv,
add_mem_filtration := λ c₁ c₂ v₁ v₂ hv₁ hv₂,
calc ∥v₁ + v₂∥
≤ ∥v₁∥ + ∥v₂∥ : norm_add_le _ _
... ≤ c₁ + c₂ : add_le_add hv₁ hv₂ }
variables {V : Type*} [semi_normed_group V]
open pseudo_normed_group
lemma mem_filtration_nnnorm (v : V) : v ∈ filtration V (∥v∥₊) :=
show ∥v∥₊ ≤ ∥v∥₊, from le_rfl
@[simp] lemma mem_filtration_iff (v : V) (c : ℝ≥0) :
v ∈ filtration V c ↔ ∥v∥₊ ≤ c := iff.rfl
end semi_normed_group
|
import spaces.test_function
import measure_theory.measure.lebesgue
open measure_theory
open_locale test_function
abbreviation distribution {E : Type*} [normed_group E] [normed_space ℝ E] (Ω : set E)
(F : Type*) [normed_group F] [normed_space ℝ F] (n : with_top ℕ) : Type* :=
Cc^n⟮Ω, E, ℝ; ℝ⟯ →L[ℝ] F
localized "notation `𝓓'` := distribution" in distribution
namespace distribution
variables {E : Type*} [normed_group E] [normed_space ℝ E] (Ω : set E)
(F : Type*) [normed_group F] [normed_space ℝ F] (n : with_top ℕ)
noncomputable def dirac (x : E) : 𝓓' Ω ℝ n :=
(bounded_continuous_function.eval_clm ℝ x) ∘L
(bounded_cont_diff_map.to_bounded_continuous_functionL ℝ E ℝ n) ∘L
(test_function.to_bounded_cont_diff_mapL)
@[simp] lemma dirac_apply (x : E) (f : Cc^n⟮Ω, E, ℝ; ℝ⟯) : dirac Ω n x f = f x := rfl
noncomputable def of_measure [measurable_space E] [opens_measurable_space E]
(μ : measure E) [is_finite_measure_on_compacts μ] :
𝓓' Ω ℝ n :=
(L1.integral_clm) ∘L (test_function.to_Lp n 1 μ)
@[simp] lemma of_measure_apply [measurable_space E] [opens_measurable_space E]
(μ : measure E) [is_finite_measure_on_compacts μ] (f : Cc^n⟮Ω, E, ℝ; ℝ⟯) :
of_measure Ω n μ f = ∫ x : E, f x ∂μ :=
by rw [of_measure, integral_eq f (f.integrable μ), L1.integral_eq]; refl
noncomputable def dirac' [measurable_space E] [opens_measurable_space E] (x : E) : 𝓓' Ω ℝ n :=
of_measure Ω n (measure.dirac x)
lemma dirac_eq_dirac' [measurable_space E] [opens_measurable_space E] (x : E) :
dirac Ω n x = dirac' Ω n x :=
begin
ext f,
rw [dirac', dirac_apply, of_measure_apply, integral_dirac]
end
end distribution
section dderiv -- This will be generalized to fderiv, but I want to do some tests
variables (Ω : set ℝ) (F : Type*) [normed_group F] [normed_space ℝ F]
--def dderivₗ : 𝓓' Ω F ⊤ →ₗ[ℝ] 𝓓' Ω F ⊤ :=
end dderiv |
lemma open_sums: fixes T :: "('b::real_normed_vector) set" assumes "open S \<or> open T" shows "open (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})" |
[STATEMENT]
lemma Basis_list_R3: "Basis_list = [(1,0,0), (0, 1, 0), (0, 0, 1)::R3]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Basis_list = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
[PROOF STEP]
by (auto simp: Basis_list_prod_def Basis_list_real_def zero_prod_def) |
Dict{String,Any}("multiline" => Dict{String,Any}("value" => "This string\nhas ' a quote character\nand more than\none newline\nin it.","type" => "string"),"firstnl" => Dict{String,Any}("value" => "This string has a ' quote character.","type" => "string"),"oneline" => Dict{String,Any}("value" => "This string has a ' quote character.","type" => "string")) |
\setchapterimage[6.5cm]{seaside}
\setchapterpreamble[u]{\margintoc}
\chapter[Figures and Tables]{Figures and Tables\footnotemark[0]}
\footnotetext{The credits for the image above the chapter title go to:
Bushra Feroz --- Own work, CC~BY-SA~4.0,
\url{https://commons.wikimedia.org/w/index.php?curid=68724647}}
\section{Normal Figures and Tables}
Figures and tables can be inserted just like in any standard
\LaTeX\xspace document. The \Package{graphicx} package is already loaded
and configured in such a way that the figure width is equal to the
textwidth and the height is adjusted in order to maintain the original
aspect ratio. As you may have imagined, the captions will be
positioned\ldots well, in the margins. This is achieved with the help of
the \Package{floatrow} package.
Here is a picture of Mona Lisa (\reffig{normalmonalisa}), as an example.
The captions are formatted as the margin- and the side-notes; If you
want to change something about captions you can use the command
\Command{captsetup} from the \Package{caption} package. Remember that if
you want to reference a figure, the label must come \emph{after} the
caption!
\begin{figure}[hb]
\includegraphics[width=0.45\textwidth]{monalisa}
\caption[Mona Lisa, again]{It's Mona Lisa again. \blindtext}
\labfig{normalmonalisa}
\end{figure}
While the format of the caption is managed by \Package{caption}, its
position is handled by the \Package{floatrow} package. Achieving this
result has been quite hard, but now I am pretty satisfied. In two-side
mode, the captions are printed in the correct margin.
Tables can be inserted just as easily as figures, as exemplified by the
following code:
\begin{lstlisting}[caption={Caption of a listing.}]
\begin{table}
\begin{tabular}{ c c c c }
\toprule
col1 & col2 & col3 & col 4 \\
\midrule
\multirow{3}{4em}{Multiple row} & cell2 & cell3 & cell4\\ &
cell5 & cell6 & cell7 \\ &
cell8 & cell9 & cell10 \\
\multirow{3}{4em}{Multiple row} & cell2 & cell3 & cell4 \\ &
cell5 & cell6 & cell7 \\ &
cell8 & cell9 & cell10 \\
\bottomrule
\end{tabular}
\end{table}
\end{lstlisting}
which results in the useless \vreftab{useless}.
\begin{table}[h]
\caption[A useless table]{A useless table.}
\labtab{useless}
\begin{tabular}{ c c c c }
\toprule
col1 & col2 & col3 & col 4 \\
\midrule
\multirow{3}{4em}{Multiple row} & cell2 & cell3 & cell4\\ &
cell5 & cell6 & cell7 \\ &
cell8 & cell9 & cell10 \\
\multirow{3}{4em}{Multiple row} & cell2 & cell3 & cell4 \\ &
cell5 & cell6 & cell7 \\ &
cell8 & cell9 & cell10 \\
\bottomrule
\end{tabular}
\end{table}
I don't have much else to say, so I will just insert some blind text.
\blindtext
\section{Margin Figures and Tables}
Marginfigures can be inserted with the environment
\Environment{marginfigure}. In this case, the whole picture is confined
to the margin and the caption is below it. \reffig{marginmonalisa} is
obtained with something like this:
\begin{lstlisting}[caption={Another caption.}]
\begin{marginfigure}
\includegraphics{monalisa}
\caption[The Mona Lisa]{The Mona Lisa.}
\labfig{marginmonalisa}
\end{marginfigure}
\end{lstlisting}
There is also the \Environment{margintable} environment, of which
\reftab{anotheruseless} is an example. Notice how you can place the
caption above the table by just placing the \Command{caption} command
before beginning the \Environment{tabular} environment. Usually, figure
captions are below, while table captions are above. This rule is also
respected for normal figures and tables: the captions are always on the
side, but for figure they are aligned to the bottom, while for tables to
the top.
\begin{margintable}
\caption[Another useless table]{Another useless table.}
\labtab{anotheruseless}
\raggedright
\begin{tabular}{ c c c c }
\hline
col1 & col2 & col3 \\
\hline
\multirow{3}{4em}{Multiple row} & cell2 & cell3 \\ & cell5 & cell6
\\ & cell8 & cell9 \\ \hline
\end{tabular}
\end{margintable}
Marginfigures and tables can be positioned with an optional offset
command, like so:
\begin{lstlisting}
\begin{marginfigure}[offset]
\includegraphics{seaside}
\end{marginfigure}
\end{lstlisting}
Offset ca be either a measure or a multiple of \Command{baselineskip},
much like with \Command{sidenote}, \Command{marginnote} and
\Command{margintoc}.\todo{Improve this part.} If you are wondering how I
inserted this orange bubble, have a look at the \Package{todo} package.
\section{Wide Figures and Tables}
\begin{figure*}[h!]
\includegraphics{seaside}
\caption[A wide seaside]{A wide seaside, and a wide caption.
Credits: By Bushra Feroz --- Own work, CC BY-SA 4.0,
\url{https://commons.wikimedia.org/w/index.php?curid=68724647}}
\end{figure*}
With the environments \Environment{figure*} and \Environment{table*} you
can insert figures which span the whole page width. The caption will be
positioned below or above, according to taste.
You may have noticed the full width image at the very beginning of this
chapter: that, however, is set up in an entirely different way, which
you'll read about in \vrefch{layout}. Now it is time to tackle
hyperreferences.
|
lemma space_empty_iff: "space N = {} \<longleftrightarrow> sets N = {{}}" |
module WellFormed where
data Nat : Set where
zero : Nat
succ : Nat -> Nat
postulate Vec : Set -> Nat -> Set
postulate _X_ : Set -> Set -> Set
postulate zip : {A B : Set} -> (n : Nat) -> Vec A n -> Vec B n -> Vec (A X B) n
|
lemma path_polynomial_function: fixes g :: "real \<Rightarrow> 'b::euclidean_space" shows "polynomial_function g \<Longrightarrow> path g" |
module Language.Elab.Deriving.ShowTest
import Language.Elab.Deriving.Show
%language ElabReflection
-- Testing of elaborations all on their own. (At bottom.)
export
data Foo1 : Type -> Type where
Bor1 : Foo1 a
export
data Foo2 : Type -> Type where
Bor2 : a -> Foo2 a
data Foo4 : Type -> Type -> Type where
Bor4 : b -> Foo4 a b
data Foo5 : Type -> Type -> Type -> Type where
Bor5 : a -> b -> c -> Foo5 a b c
-- NB c is never used, so Eq shouldn't be required for it
data Foo7 : Type -> Type -> Type -> Type where
Zor7 : a -> Foo7 a b c
Gor7 : b -> Foo7 a b c
Nor7A : a -> b -> Foo7 a b c
Nor7B : a -> b -> c -> Foo7 a b c
Bor7 : Foo7 a b c
-- NB a is never used, so Eq shouldn't be required for it
data Foo7' : Type -> Type -> Type -> Type where
Zor7' : c -> Foo7' a b c
Gor7' : b -> Foo7' a b c
Nor7' : b -> c -> Foo7' a b c
Bor7' : Foo7' a b c
-- we'll use our own nat for index experimentation
export
data MyNat : Type where
MZ : MyNat
MS : MyNat -> MyNat
data Foo6 : Type -> Type -> Type -> Nat -> Type where
Zor6 : a -> b -> Foo6 a b c Z
Gor6 : b -> Foo6 a b c (S k)
Nor6A : a -> b -> c -> Foo6 a b c n
Nor6B : a -> (0 _ : b) -> c -> Foo6 a b c n -- NB: 0 Use arg
Bor6A : Foo6 a b c n
Bor6B : Foo6 a b c n -> Foo6 a b c n
Wah6 : a -> (n : Nat) -> Foo6 a b c n
export
data Foo6' : Type -> Type -> Type -> MyNat -> Type where
Zor6' : a -> b -> Foo6' a b c MZ
Gor6A' : b -> Foo6' a b c (MS k)
Gor6B' : (k : MyNat) -> b -> Foo6' a b c (MS k)
Nor6A' : a -> b -> c -> Foo6' a b c n
Nor6B' : a -> (0 _ : b) -> c -> Foo6' a b c n
Bor6' : Foo6' a b c n
Wah6' : a -> (n : MyNat) -> Foo6' a b c n
Kah6' : a -> (n : MyNat) -> (0 _ : c) -> Foo6' a b c n
Pah6' : a -> (n : MyNat) -> MyNat -> (0 _ : c) -> Foo6' a b c n
-- Rah6' : a -> (n : MyNat) -> Foo6' a b c n -> MyNat -> (0 _ : c) -> Foo6' a b c n -> Foo6' a b c n
-- Gah6' : {1 _ : a} -> (n : MyNat) -> MyNat -> (0 _ : c) -> Foo6' a b c n
-- ^ another case to consider, what if I'm implicit but M1?
-- Seems like an error would be appropriate there rather than showing
-- implicits. Though showing implicits could be a flag in instance generation
-- I guess.
-- eqImplFoo6'Fun (Wah6' 'c' MZ) (Wah6' 'c' MZ)
-- eqImplFoo6'Fun (Nor6A' {n=MZ} 'c' 'd' 'e')
-- eqImplFoo6Fun (Wah6 {b=Int} {c=String} 'c' (S Z)) (Wah6 'c' (S Z))
-- reference impl
-- NB We need to use n twice, Eq is not dependent, two values of `a` compared
-- against each other must have the same indices. Which follows since if they
-- don't they're obviously not equal.
-- if a con has no explicit, non-M0, non-index, vars then it's empty, and thus
-- vauously true to compare to itself. only explicit, non-M0, non-index vars need
-- to be compared. M0 values can't be used and index vars can't vary in an Eq
-- definition
eqFoo6 : (Eq a, Eq b, Eq c) => Foo6 a b c n -> Foo6 a b c n -> Bool
eqFoo6 (Zor6 x1 y1) (Zor6 x2 y2) = x1 == x2 && y1 == y2
eqFoo6 (Gor6 x1) (Gor6 x2) = x1 == x2
eqFoo6 (Nor6A x1 y1 z1) (Nor6A x2 y2 z2) = x1 == x2 && y1 == y2 && z1 == z2
eqFoo6 (Nor6B x1 _ z1) (Nor6B x2 _ z2) = x1 == x2 && z1 == z2
eqFoo6 Bor6A Bor6A = True
eqFoo6 (Bor6B x1) (Bor6B x2) = eqFoo6 x1 x2
-- we prefer to write this as x1 == x2, and we do so by declaring our Eq object
-- early, otherwise there's no instance for Foo6 to use == from
eqFoo6 (Wah6 x1 _) (Wah6 x2 _) = x1 == x2 -- indices do not differ
eqFoo6 _ _ = False
-- eqFoo6 {b=Int} {c=String} (Wah6 'c' (S Z)) (Wah6 'c' (S Z))
data FooN : MyNat -> Type -> Type where
BorZ : b -> FooN MZ b
BorS : b -> FooN (MS MZ) b
BorNA : (k : MyNat) -> b -> FooN n b
BorNB : (n : MyNat) -> b -> FooN n b
%runElab deriveShow Export `{{MyNat}}
%runElab deriveShow Export `{{Foo1}}
%runElab deriveShow Export `{{Foo2}}
%runElab deriveShow Private `{{Foo4}}
%runElab deriveShow Private `{{Foo5}}
%runElab deriveShow Private `{{Foo7}}
%runElab deriveShow Private `{{Foo7'}}
%runElab deriveShow Private `{{FooN}}
%runElab deriveShow Private `{{Foo6}}
%runElab deriveShow Export `{{Foo6'}}
-- can check what's generated via
-- :printdef showImplFoo7'Fun
-- Will need to supply types if playing in the repl, e.g.:
-- show (Wah6' 'c' MZ {b=Char} {c=Int})
|
If every element of a set $S$ has norm at most $B$, then $S$ is bounded. |
function [yr] = s2yr(s)
% Convert time from seconds to Julian years (365.25 days).
% Chad Greene 2012
yr = s*3.168808781403e-8; |
\begin{otherlanguage}{english}
\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
[This is the abstract in English.]
\lipsum[1]
\end{otherlanguage}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "tfg_main"
%%% TeX-PDF-mode: t
%%% ispell-local-dictionary: "english"
%%% End:
|
New South Wales is Australia’s most populous state and is recognised by the NSW Government Department of Primary Industries as the dairy state with the most regional differences of any Australian state.
There is no greater showcase of these regional differences then in the increasing number, variety of style and quality of boutique, farmhouse cheese; largely produced and sold through local networks of farmers markets and restaurants.
Australia had no goats, cows, sheep or buffalo until white settlement in 1788 when Captain Arthur Phillip sailed into Sydney Harbour and off loaded from the First Fleet boats limited livestock for milk and meat.
He did so straight onto the sandbank that is today famously known as Bennelong Point; originally called Cattle Point, as the cattle were held there in make shift enclosures. This sandbank has been built up and is now home to the Opera House.
Unbeknown to many, Sydney Harbour NSW has this rich history in Australia’s milk and cheese industry.
It was at this time in Australia’s history and from this exact region, now known as NSW, that our nations dairy industry in general and cheese industry specifically commenced.
Continued exploration and migration of people and livestock by ship down Australia’s east coast is how our dairy and cheese industry migrated to other regions.
Ideal dairy farming regions were discovered by settlers today known as VIC, TAS and SA where the majority of Australia’s dairy output comes. |
[STATEMENT]
lemma i_shrink_last_Cons: "
\<lbrakk> 0 < k; length xs = k \<rbrakk> \<Longrightarrow> (xs \<frown> f) \<div>\<^bsub>il\<^esub> k = [last xs] \<frown> (f \<div>\<^bsub>il\<^esub> k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>0 < k; length xs = k\<rbrakk> \<Longrightarrow> (xs \<frown> f) \<div>\<^sub>l k = [last xs] \<frown> f \<div>\<^sub>l k
[PROOF STEP]
by (simp add: f_shrink_last_def i_shrink_last_def i_aggregate_Cons) |
Checking up on the hybrid front, I found that the Acura ILX hybrid for 2014 is finally on sale, as of Tuesday, and an Accord hybrid, which I didn’t even know about, goes on sale at the end of this month. Unfortunately, Honda’s main vehicle Web sites didn’t tell me that — I had to dig through press releases. (This underscores the incompetence of automaker management; can you think of a technology company that would put a product on sale before their Web site had any information about it?) Hyundai is still running behind on nearly their whole lineup, including the Sonata hybrid.
Meanwhile, I’m still thinking about that 370Z that I’m probably not going to buy. I wasted a couple of hours searching on Nissan’s (awful) Web site to see which dealers actually had the model I was interested in; there are four dealers that have them, all in red and black, none with autobox, so there’s no chance I’ll end up test-driving one (unless there’s someone in New Hampshire or Rhode Island that has one). I might go find the nearest 6MT, which is in Stoneham, just to see if I can even fit in the thing, and maybe talk to a salesperson about why they’re so limited around here. Note to automakers: don’t make me select each one of thirty different dealers to find out that they don’t have what I’m interested in, just tell me which f’ing dealer does, and how far away they are.
Aside | This entry was posted in Transportation and tagged 370z, accord, acura, cars, honda, hybrids, ilx, new car 2013, nissan. Bookmark the permalink. |
[STATEMENT]
lemma smc_Par_is_monic_arrI[intro]:
assumes "T : A \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> B" and "v11 (T\<lparr>ArrVal\<rparr>)" and "\<D>\<^sub>\<circ> (T\<lparr>ArrVal\<rparr>) = A"
shows "T : A \<mapsto>\<^sub>m\<^sub>o\<^sub>n\<^bsub>smc_Par \<alpha>\<^esub> B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. T : A \<mapsto>\<^sub>m\<^sub>o\<^sub>n\<^bsub>smc_Par \<alpha>\<^esub> B
[PROOF STEP]
proof(intro is_monic_arrI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. T : A \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> B
2. \<And>f g a. \<lbrakk>f : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; g : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> f = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> g\<rbrakk> \<Longrightarrow> f = g
[PROOF STEP]
interpret T: arr_Par \<alpha> T
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. arr_Par \<alpha> T
[PROOF STEP]
by (intro smc_Par_is_arrD(1)[OF assms(1)])
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. T : A \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> B
2. \<And>f g a. \<lbrakk>f : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; g : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> f = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> g\<rbrakk> \<Longrightarrow> f = g
[PROOF STEP]
interpret Par_Rel: wide_subsemicategory \<alpha> \<open>smc_Par \<alpha>\<close> \<open>smc_Rel \<alpha>\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. smc_Par \<alpha> \<subseteq>\<^sub>S\<^sub>M\<^sub>C\<^sub>.\<^sub>w\<^sub>i\<^sub>d\<^sub>e\<^bsub>\<alpha>\<^esub> smc_Rel \<alpha>
[PROOF STEP]
by (rule T.wide_subsemicategory_smc_Par_smc_Rel)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. T : A \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> B
2. \<And>f g a. \<lbrakk>f : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; g : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> f = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> g\<rbrakk> \<Longrightarrow> f = g
[PROOF STEP]
interpret v11: v11 \<open>T\<lparr>ArrVal\<rparr>\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. v11 (T\<lparr>ArrVal\<rparr>)
[PROOF STEP]
by (rule assms(2))
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. T : A \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> B
2. \<And>f g a. \<lbrakk>f : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; g : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> f = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> g\<rbrakk> \<Longrightarrow> f = g
[PROOF STEP]
show T: "T : A \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. T : A \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> B
[PROOF STEP]
by (rule assms(1))
[PROOF STATE]
proof (state)
this:
T : A \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> B
goal (1 subgoal):
1. \<And>f g a. \<lbrakk>f : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; g : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> f = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> g\<rbrakk> \<Longrightarrow> f = g
[PROOF STEP]
fix S R A'
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>f g a. \<lbrakk>f : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; g : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> f = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> g\<rbrakk> \<Longrightarrow> f = g
[PROOF STEP]
assume S: "S : A' \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A"
and R: "R : A' \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A"
and TS_TR: "T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> S = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> R"
[PROOF STATE]
proof (state)
this:
S : A' \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A
R : A' \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A
T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> S = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> R
goal (1 subgoal):
1. \<And>f g a. \<lbrakk>f : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; g : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> f = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> g\<rbrakk> \<Longrightarrow> f = g
[PROOF STEP]
from assms(3) T Par_Rel.subsemicategory_axioms
[PROOF STATE]
proof (chain)
picking this:
\<D>\<^sub>\<circ> (T\<lparr>ArrVal\<rparr>) = A
T : A \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> B
smc_Par \<alpha> \<subseteq>\<^sub>S\<^sub>M\<^sub>C\<^bsub>\<alpha>\<^esub> smc_Rel \<alpha>
[PROOF STEP]
have "T : A \<mapsto>\<^sub>m\<^sub>o\<^sub>n\<^bsub>smc_Rel \<alpha>\<^esub> B"
[PROOF STATE]
proof (prove)
using this:
\<D>\<^sub>\<circ> (T\<lparr>ArrVal\<rparr>) = A
T : A \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> B
smc_Par \<alpha> \<subseteq>\<^sub>S\<^sub>M\<^sub>C\<^bsub>\<alpha>\<^esub> smc_Rel \<alpha>
goal (1 subgoal):
1. T : A \<mapsto>\<^sub>m\<^sub>o\<^sub>n\<^bsub>smc_Rel \<alpha>\<^esub> B
[PROOF STEP]
by (intro smc_Rel_is_monic_arrI)
(auto dest: v11.v11_vimage_vpsubset_neq elim!: smc_sub_fw_cs_intros)
[PROOF STATE]
proof (state)
this:
T : A \<mapsto>\<^sub>m\<^sub>o\<^sub>n\<^bsub>smc_Rel \<alpha>\<^esub> B
goal (1 subgoal):
1. \<And>f g a. \<lbrakk>f : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; g : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> f = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> g\<rbrakk> \<Longrightarrow> f = g
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
T : A \<mapsto>\<^sub>m\<^sub>o\<^sub>n\<^bsub>smc_Rel \<alpha>\<^esub> B
goal (1 subgoal):
1. \<And>f g a. \<lbrakk>f : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; g : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> f = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> g\<rbrakk> \<Longrightarrow> f = g
[PROOF STEP]
from S Par_Rel.subsemicategory_axioms
[PROOF STATE]
proof (chain)
picking this:
S : A' \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A
smc_Par \<alpha> \<subseteq>\<^sub>S\<^sub>M\<^sub>C\<^bsub>\<alpha>\<^esub> smc_Rel \<alpha>
[PROOF STEP]
have "S : A' \<mapsto>\<^bsub>smc_Rel \<alpha>\<^esub> A"
[PROOF STATE]
proof (prove)
using this:
S : A' \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A
smc_Par \<alpha> \<subseteq>\<^sub>S\<^sub>M\<^sub>C\<^bsub>\<alpha>\<^esub> smc_Rel \<alpha>
goal (1 subgoal):
1. S : A' \<mapsto>\<^bsub>smc_Rel \<alpha>\<^esub> A
[PROOF STEP]
by (cs_concl cs_shallow cs_intro: smc_sub_fw_cs_intros)
[PROOF STATE]
proof (state)
this:
S : A' \<mapsto>\<^bsub>smc_Rel \<alpha>\<^esub> A
goal (1 subgoal):
1. \<And>f g a. \<lbrakk>f : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; g : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> f = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> g\<rbrakk> \<Longrightarrow> f = g
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
S : A' \<mapsto>\<^bsub>smc_Rel \<alpha>\<^esub> A
goal (1 subgoal):
1. \<And>f g a. \<lbrakk>f : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; g : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> f = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> g\<rbrakk> \<Longrightarrow> f = g
[PROOF STEP]
from R Par_Rel.subsemicategory_axioms
[PROOF STATE]
proof (chain)
picking this:
R : A' \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A
smc_Par \<alpha> \<subseteq>\<^sub>S\<^sub>M\<^sub>C\<^bsub>\<alpha>\<^esub> smc_Rel \<alpha>
[PROOF STEP]
have "R : A' \<mapsto>\<^bsub>smc_Rel \<alpha>\<^esub> A"
[PROOF STATE]
proof (prove)
using this:
R : A' \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A
smc_Par \<alpha> \<subseteq>\<^sub>S\<^sub>M\<^sub>C\<^bsub>\<alpha>\<^esub> smc_Rel \<alpha>
goal (1 subgoal):
1. R : A' \<mapsto>\<^bsub>smc_Rel \<alpha>\<^esub> A
[PROOF STEP]
by (cs_concl cs_shallow cs_intro: smc_sub_fw_cs_intros)
[PROOF STATE]
proof (state)
this:
R : A' \<mapsto>\<^bsub>smc_Rel \<alpha>\<^esub> A
goal (1 subgoal):
1. \<And>f g a. \<lbrakk>f : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; g : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> f = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> g\<rbrakk> \<Longrightarrow> f = g
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
R : A' \<mapsto>\<^bsub>smc_Rel \<alpha>\<^esub> A
goal (1 subgoal):
1. \<And>f g a. \<lbrakk>f : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; g : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> f = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> g\<rbrakk> \<Longrightarrow> f = g
[PROOF STEP]
from T S R TS_TR Par_Rel.subsemicategory_axioms
[PROOF STATE]
proof (chain)
picking this:
T : A \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> B
S : A' \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A
R : A' \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A
T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> S = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> R
smc_Par \<alpha> \<subseteq>\<^sub>S\<^sub>M\<^sub>C\<^bsub>\<alpha>\<^esub> smc_Rel \<alpha>
[PROOF STEP]
have
"T \<circ>\<^sub>A\<^bsub>smc_Rel \<alpha>\<^esub> S = T \<circ>\<^sub>A\<^bsub>smc_Rel \<alpha>\<^esub> R"
[PROOF STATE]
proof (prove)
using this:
T : A \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> B
S : A' \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A
R : A' \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A
T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> S = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> R
smc_Par \<alpha> \<subseteq>\<^sub>S\<^sub>M\<^sub>C\<^bsub>\<alpha>\<^esub> smc_Rel \<alpha>
goal (1 subgoal):
1. T \<circ>\<^sub>A\<^bsub>smc_Rel \<alpha>\<^esub> S = T \<circ>\<^sub>A\<^bsub>smc_Rel \<alpha>\<^esub> R
[PROOF STEP]
by (auto simp: smc_sub_bw_cs_simps)
[PROOF STATE]
proof (state)
this:
T \<circ>\<^sub>A\<^bsub>smc_Rel \<alpha>\<^esub> S = T \<circ>\<^sub>A\<^bsub>smc_Rel \<alpha>\<^esub> R
goal (1 subgoal):
1. \<And>f g a. \<lbrakk>f : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; g : a \<mapsto>\<^bsub>smc_Par \<alpha>\<^esub> A; T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> f = T \<circ>\<^sub>A\<^bsub>smc_Par \<alpha>\<^esub> g\<rbrakk> \<Longrightarrow> f = g
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
T : A \<mapsto>\<^sub>m\<^sub>o\<^sub>n\<^bsub>smc_Rel \<alpha>\<^esub> B
S : A' \<mapsto>\<^bsub>smc_Rel \<alpha>\<^esub> A
R : A' \<mapsto>\<^bsub>smc_Rel \<alpha>\<^esub> A
T \<circ>\<^sub>A\<^bsub>smc_Rel \<alpha>\<^esub> S = T \<circ>\<^sub>A\<^bsub>smc_Rel \<alpha>\<^esub> R
[PROOF STEP]
show "S = R"
[PROOF STATE]
proof (prove)
using this:
T : A \<mapsto>\<^sub>m\<^sub>o\<^sub>n\<^bsub>smc_Rel \<alpha>\<^esub> B
S : A' \<mapsto>\<^bsub>smc_Rel \<alpha>\<^esub> A
R : A' \<mapsto>\<^bsub>smc_Rel \<alpha>\<^esub> A
T \<circ>\<^sub>A\<^bsub>smc_Rel \<alpha>\<^esub> S = T \<circ>\<^sub>A\<^bsub>smc_Rel \<alpha>\<^esub> R
goal (1 subgoal):
1. S = R
[PROOF STEP]
by (rule is_monic_arrD(2))
[PROOF STATE]
proof (state)
this:
S = R
goal:
No subgoals!
[PROOF STEP]
qed |
Fiddlehead Cellars rests in Central Coast Lompoc, CA but has a business office in Davis. Go figure.
The company produces Sauvignon Blanc and Pinot Noir; their Sauvignon Blanc grapes are grown in the Santa Rita Hills and Williamette Valley and their Pinot Noir grapes are grown in the Santa Ynez Valley. The Fiddlehead wine itself was featured in the movie http://www.imdb.com/title/tt0375063/ Sideways, despite the fact that no scenes were filmed at the winery. Fiddlehead Wines may be found at some Nugget stores, according to the website, as well as at wiki:Sacramento:Masons_Restaurant in Sacramento.
20080423 22:52:12 nbsp A friend who works at the winery in Lompoc gave us a tour and tasting. Its not a very big operation and the wine is outstanding. The sauvignon blanc was some of the best Ive ever had give it a try if you ever come across it.
Oh, and I believe theres an office here because the owner is a UCD alum. Users/BrianLum
|
library(BiocParallel)
library(tradeSeq)
library(mgcv)
library(clusterExperiment)
library(slingshot)
exprs = read.csv('./data/mic_gene_expression_raw.csv', row.names = 1)
counts = as.matrix(exprs)
meta = read.csv('./data/mic_diff_meta.csv')
rd = read.csv('./mic_diff_pca.csv')
ind_gene = colSums(counts) > (0.5 * nrow(counts) )
counts = counts[,ind_gene]
sds <- slingshot(rd[,1:2], meta$leiden)
pseudotime = slingPseudotime(sds)[,1]
#aicK = evaluateK(t(counts), sds = sds, BPPARAM = BiocParallel::bpparam())
sce <- fitGAM(counts = t(counts), pseudotime = pseudotime,
cellWeights = rep(1, nrow(counts)), verbose = TRUE,
parallel=TRUE, BPPARAM = BiocParallel::bpparam())
assoRes <- associationTest(sce)
assoRes$fdr = p.adjust(assoRes$pvalue, 'fdr')
head(assoRes)
saveRDS(assoRes, 'mic_sling_output/pseudotime_association.rds')
sigRes = assoRes[assoRes$fdr < 0.05,]
degs = rownames(sigRes[order(sigRes$pvalue),])
nPointsClus = 20
clusPat = clusterExpressionPatterns(sce, nPoints = nPointsClus,
genes = degs, clusterFunction = "hierarchical01",
ncores = 20,
)
write.csv(clusPat$yhatScaled,'mic_sling_output/yhat_scaled.csv')
dn_curves = (which(colSums(diff(t(clusPat$yhatScaled), ) <= 0, ) == (nPointsClus - 1) ))
up_curves = (which(colSums(diff(t(clusPat$yhatScaled), ) >= 0, ) == (nPointsClus - 1) ))
not_monotone = setdiff(1:length(degs), dn_curves)
not_monotone = setdiff(not_monotone, up_curves)
not_monotone_genes = rownames(clusPat$yhatScaled)[not_monotone]
clusPat_nm = clusterExpressionPatterns(sce, nPoints = nPointsClus,
genes = not_monotone_genes,
clusterFunction = "hierarchical01",
ncores = 20,
)
clusterLabels_nm <- primaryCluster(clusPat_nm$rsec)
clusterLabels_nm = clusterLabels_nm
out = data.frame(cluster = clusterLabels_nm - 1 )
rownames(out) = rownames(clusPat_nm$yhatScaled)
write.csv(out, './mic_sling_output/clusterLabel_nm.csv')
write.csv(clusPat_nm$yhatScaled, './mic_sling_output/yhat_scaled_nm.csv')
#merged_label = seq(length(degs))
merged_label = rep(-1, length(degs))
merged_label[not_monotone] = clusterLabels_nm - 1
merged_label[dn_curves] = max(clusterLabels_nm)
merged_label[up_curves] = max(clusterLabels_nm) + 1
out = data.frame(cluster = merged_label )
rownames(out) = rownames(clusPat$yhatScaled)
write.csv(out, './mic_sling_output/clusterLabel.csv')
write.csv(clusPat$yhatScaled, './mic_sling_output/yhat_scaled.csv')
pdf('fig/decreasing_genes_smooth_traj.pdf')
genes = c('MT.CO1', 'MT.ND4', 'CSMD1')
for (g in genes){
#print(plotSmoothers(sce, t(counts), gene = g))
print(plotSmoothers(sce, t(counts), gene = g))
}
dev.off()
|
% Test file for trigtech/real.m
function pass = test_real(pref)
% Get preferences.
if ( nargin < 1 )
pref = trigtech.techPref();
end
testclass = trigtech();
% Test a scalar-valued function.
f = testclass.make(@(x) exp(20i*pi*x) + 1i*sin(100*pi*x), [], pref);
g = testclass.make(@(x) cos(20*pi*x), [], pref);
h = real(f);
g = prolong(g, length(h));
pass(1) = norm(h.coeffs - g.coeffs, inf) < 10*vscale(h)*eps;
% Test an array-valued function.
f = testclass.make(@(x) [exp(20i*pi*x) + 1i*sin(100*pi*x), -exp(10i*pi*x)], [], pref);
g = testclass.make(@(x) [cos(20*pi*x), -real(exp(10i*pi*x))], [], pref);
h = real(f);
n = max(length(g),length(h));
g = prolong(g,n); h = prolong(h,n);
pass(2) = norm(h.coeffs - g.coeffs, inf) < 10*max(vscale(h)*eps);
% Test a real function.
f = 1i*testclass.make(@(x) cos(30*pi*x), [], pref);
g = real(f);
pass(3) = numel(g.coeffs) == 1 && g.coeffs == 0;
% Test an array-valued real function.
f = 1i*testclass.make(@(x) [cos(99*pi*x), sin(99*pi*x), exp(cos(pi*x))], [], pref);
g = real(f);
pass(4) = all(size(g.coeffs) == [1, 3]) && all(g.coeffs == 0);
end
|
open import Prelude hiding (id; erase)
module Implicits.WellTyped where
open import Data.Fin.Substitution
open import Data.Vec hiding ([_])
open import Data.List as List hiding ([_]; map)
open import Implicits.Syntax.Type
open import Implicits.Syntax.Term
open import Implicits.Syntax.Context
open import Implicits.Substitutions
module TypingRules (_⊢ᵣ_ : ∀ {ν} → ICtx ν → Type ν → Set) where
infixl 4 _⊢_∈_
-----------------------------------------------------------------------------
-- typings
data _⊢_∈_ {ν n} (K : Ktx ν n) : Term ν n → Type ν → Set where
var : (x : Fin n) → K ⊢ var x ∈ (lookup x (proj₁ K))
λ' : ∀ {t b} a → a ∷Γ K ⊢ t ∈ b → K ⊢ λ' a t ∈ simpl (a →' b)
Λ : ∀ {t} {a : Type (suc ν)} → ktx-weaken K ⊢ t ∈ a → K ⊢ Λ t ∈ ∀' a
_[_] : ∀ {t} {a : Type (suc ν)} →
K ⊢ t ∈ ∀' a → (b : Type ν) → K ⊢ t [ b ] ∈ a tp[/tp b ]
_·_ : ∀ {f t a b} → K ⊢ f ∈ simpl (a →' b) → K ⊢ t ∈ a → K ⊢ f · t ∈ b
-- implicit abstract/application
ρ : ∀ {t b a} → [] ⊢unamb a → a ∷K K ⊢ t ∈ b → K ⊢ ρ a t ∈ (a ⇒ b)
_⟨_⟩ : ∀ {a b f} → K ⊢ f ∈ a ⇒ b → (proj₂ K) ⊢ᵣ a → K ⊢ f ⟨⟩ ∈ b
_with'_ : ∀ {r e a b} → K ⊢ r ∈ a ⇒ b → K ⊢ e ∈ a → K ⊢ r with' e ∈ b
_⊢_∉_ : ∀ {ν n} → (K : Ktx ν n) → Term ν n → Type ν → Set
_⊢_∉_ K t τ = ¬ K ⊢ t ∈ τ
-----------------------------------------------------------------------------
-- syntactic sugar
let'_in'_ : ∀ {ν n} {e₁ : Term ν n} {e₂ : Term ν (suc n)} {a b} {K} →
K ⊢ e₁ ∈ a → a ∷Γ K ⊢ e₂ ∈ b → K ⊢ (let' e₁ ∶ a in' e₂) ∈ b
let' e₁ in' e₂ = (λ' _ e₂) · e₁
implicit'_∶_in'_ : ∀ {ν n} {e₁ : Term ν n} {e₂ : Term ν (suc n)} {a b} {K} →
K ⊢ e₁ ∈ a → [] ⊢unamb a → a ∷K K ⊢ e₂ ∈ b → K ⊢ (implicit e₁ ∶ a in' e₂) ∈ b
implicit' e₁ ∶ a in' e₂ = (ρ a e₂) with' e₁
wt-¿ : ∀ {ν n} {r : Type ν} {K : Ktx ν n} → [] ⊢unamb r → (proj₂ K) ⊢ᵣ r → K ⊢ (¿ r) ∈ r
wt-¿ r x = (ρ r (var zero)) ⟨ x ⟩
-----------------------------------------------------------------------------
-- utilities
erase : ∀ {ν n} {K : Ktx ν n} {t a} → K ⊢ t ∈ a → Term ν n
erase {t = t} _ = t
-- Collections of typing derivations for well-typed terms.
data _⊢ⁿ_∈_ {m n} (Γ : Ktx n m) : ∀ {k} → Vec (Term n m) k → Vec (Type n) k → Set where
[] : Γ ⊢ⁿ [] ∈ []
_∷_ : ∀ {t a k} {ts : Vec (Term n m) k} {as : Vec (Type n) k} →
Γ ⊢ t ∈ a → Γ ⊢ⁿ ts ∈ as → Γ ⊢ⁿ t ∷ ts ∈ (a ∷ as)
-- Lookup a well-typed term in a collection thereof.
lookup-⊢ : ∀ {m n k} {Γ : Ktx n m} {ts : Vec (Term n m) k} {as : Vec (Type n) k} →
(x : Fin k) → Γ ⊢ⁿ ts ∈ as → Γ ⊢ lookup x ts ∈ lookup x as
lookup-⊢ zero (⊢t ∷ ⊢ts) = ⊢t
lookup-⊢ (suc x) (⊢t ∷ ⊢ts) = lookup-⊢ x ⊢ts
|
The ball of radius $max(r,s)$ around $a$ is the union of the balls of radius $r$ and $s$ around $a$. |
[STATEMENT]
lemma prv_imp_psubst_scnj:
assumes "F \<subseteq> fmla" "finite F" "snd ` set txs \<subseteq> var" "fst ` set txs \<subseteq> trm"
and "distinct (map snd txs)"
shows "prv (imp (psubst (scnj F) txs) (scnj ((\<lambda>\<phi>. psubst \<phi> txs) ` F)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. prv (imp (psubst (scnj F) txs) (scnj ((\<lambda>\<phi>. psubst \<phi> txs) ` F)))
[PROOF STEP]
using prv_psubst_scnj[OF assms] assms
[PROOF STATE]
proof (prove)
using this:
prv (eqv (psubst (scnj F) txs) (scnj ((\<lambda>\<phi>. psubst \<phi> txs) ` F)))
F \<subseteq> fmla
finite F
snd ` set txs \<subseteq> var
fst ` set txs \<subseteq> trm
distinct (map snd txs)
goal (1 subgoal):
1. prv (imp (psubst (scnj F) txs) (scnj ((\<lambda>\<phi>. psubst \<phi> txs) ` F)))
[PROOF STEP]
apply(intro prv_imp_eqvEL)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
1. \<lbrakk>prv (eqv (psubst (scnj F) txs) (scnj ((\<lambda>\<phi>. psubst \<phi> txs) ` F))); F \<subseteq> fmla; finite F; snd ` set txs \<subseteq> var; fst ` set txs \<subseteq> trm; distinct (map snd txs)\<rbrakk> \<Longrightarrow> psubst (scnj F) txs \<in> fmla
2. \<lbrakk>prv (eqv (psubst (scnj F) txs) (scnj ((\<lambda>\<phi>. psubst \<phi> txs) ` F))); F \<subseteq> fmla; finite F; snd ` set txs \<subseteq> var; fst ` set txs \<subseteq> trm; distinct (map snd txs)\<rbrakk> \<Longrightarrow> scnj ((\<lambda>\<phi>. psubst \<phi> txs) ` F) \<in> fmla
3. \<lbrakk>prv (eqv (psubst (scnj F) txs) (scnj ((\<lambda>\<phi>. psubst \<phi> txs) ` F))); F \<subseteq> fmla; finite F; snd ` set txs \<subseteq> var; fst ` set txs \<subseteq> trm; distinct (map snd txs)\<rbrakk> \<Longrightarrow> prv (eqv (psubst (scnj F) txs) (scnj ((\<lambda>\<phi>. psubst \<phi> txs) ` F)))
[PROOF STEP]
by auto |
Formal statement is: lemma closed_union_complement_components: fixes S :: "'a::real_normed_vector set" assumes S: "closed S" and c: "c \<subseteq> components(- S)" shows "closed(S \<union> \<Union> c)" Informal statement is: If $S$ is a closed set and $c$ is a collection of components of the complement of $S$, then $S \cup \bigcup c$ is closed. |
Formal statement is: lemma tendsto_at_topI_sequentially: fixes f :: "real \<Rightarrow> 'b::first_countable_topology" assumes *: "\<And>X. filterlim X at_top sequentially \<Longrightarrow> (\<lambda>n. f (X n)) \<longlonglongrightarrow> y" shows "(f \<longlongrightarrow> y) at_top" Informal statement is: If $f$ is a function from the reals to a first-countable topological space, and if for every sequence $X$ that converges to $\infty$, the sequence $f(X)$ converges to $y$, then $f$ converges to $y$ at $\infty$. |
-- ------------------------------------- [ Data.Functor.Foldable.Instances.idr ]
-- Module : Data.Functor.Foldable.Internal.Instances
-- Description : Instances of 'Recursive' and 'Corecursive' for various
-- things.
-- --------------------------------------------------------------------- [ EOH ]
module Data.Functor.Foldable.Instances
import Control.Monad.Free
import Data.Functor.Foldable.Mod
%access public export
implementation Base Nat Maybe where
implementation Recursive Maybe Nat where
project Z = Nothing
project (S a) = Just a
implementation Corecursive Maybe Nat where
embed Nothing = Z
embed (Just a) = S a
||| Fix-point data type for exotic recursion schemes of various kinds
data Fix : (Type -> Type) -> Type where
Fx : f (Fix f) -> Fix f
||| Nu fix-point functor for coinduction
codata Nu : (f : Type -> Type) -> Type -> Type where
NuF : ((a -> f a) -> a) -> b -> Nu f b
||| Mu fix-point functor for induction
data Mu : (Type -> Type) -> Type where
MuF : ({a : Type} -> (a -> f a) -> a) -> Mu f
implementation Functor (Nu f) where
map g (NuF h a) = NuF h (g a)
implementation Base t (Nu f) where
implementation Base (Fix t) f where
implementation Base (Mu f) f where
||| Create a fix-point with a functor
fix : f (Fix f) -> Fix f
fix = Fx
||| Unfix a 'Fix f'
unfix : Fix f -> f (Fix f)
unfix (Fx x) = x
data ListF : Type -> Type -> Type where
NilF : ListF _ _
Cons : a -> b -> ListF a b
data StreamF : Type -> Type -> Type where
Pipe : a -> b -> StreamF a b
implementation Functor (StreamF a) where
map f (Pipe a b) = Pipe a (f b)
implementation Functor (ListF a) where
map _ NilF = NilF
map f (Cons a b) = Cons a (f b)
implementation Base b (ListF a) where
implementation Base b (StreamF a) where
||| Lambek's lemma assures us this function always exists.
lambek : (Recursive f t, Corecursive f t) => (t -> f t)
lambek = cata (map embed)
||| The dual of Lambek's lemma.
colambek : (Recursive f t, Corecursive f t) => (f t -> t)
colambek = ana (map project)
implementation Recursive (StreamF a) (Stream a) where
project (x::xs) = Pipe x xs
implementation Corecursive (StreamF a) (Stream a) where
embed (Pipe x xs) = x::xs
implementation Recursive (ListF a) (List a) where
project [] = NilF
project (x::xs) = Cons x xs
implementation Corecursive (ListF a) (List a) where
embed NilF = []
embed (Cons x xs) = x::xs
|
-- Andreas, 2017-08-13, issue #2684
-- Better error for abstract constructor.
abstract
data D : Set where
c : D
data E : Set where
c : E
test : D
test = c
-- Expected:
-- Constructor c is abstract, thus, not in scope here
-- when checking that the expression c has type D
|
So now Stephen Harper needs the Indians.
It seems everybody does these days — for all the wrong reasons.
According to sources who have seen Harper consultant Doug Eyford’s confidential report, Stephen Harper’s bureaucrats have not done him any favours in moving the Northern Gateway file forward. Eyford told the PM that genuine engagement with First Nations is the only path left. For a variety of reasons, selling the pipeline to First Nations leaders is now an unofficial panic situation.
As things now stand, the odds are against a deal with West Coast bands on the pipeline that is supposed to carry Alberta bitumen through British Columbia and out to Asian markets.
From industry and government’s perspective, time is of the essence. They want a delivery system for Alberta raw oil before other countries with energy for sale put a long-term lock on the markets that are up for grabs, particularly China.
By contrast, First Nations leaders will not be hustled into a quick or unsatisfactory deal. Northern Gateway is a multiple sore spot for them. They feel as though they have been ignored, marginalized and, to a degree, vilified. There was even a pitiful attempt to buy them off — with a 10-per-cent equity position in Northern Gateway. If it were only a matter of numbers, a deal-winning arrangement would be a stake at least three times as large.
But it’s not just dollars. It is a matter of reasonable fears by First Nations leaders about protection of the land and water in the wake of the Harper government’s gutting of environmental regulations in its anti-democratic and notorious omnibus legislation.
It is also a matter of trust: The Harper government doesn’t enjoy much of that in the native community these days. Normally, that wouldn’t bother a government that deals with opposition by taking out a baseball bat and going head-hunting.
But this time bullying and bulldozing can’t bring the First Nations into line. They have the Constitution and scores of court decisions in their favour. This time around, it is the Harper government that will have to compromise — if the First Nations decide to give it the chance.
The truth is, they might not bother.
This time around, it is the Harper government that will have to compromise — if the First Nations decide to give it the chance. The truth is, they might not bother.
Stephen Harper’s trust account is badly overdrawn. Native leaders will not soon forget how the Conservatives blithely walked away from the work-in-progress that was the Kelowna Accord.
Although former prime minister Paul Martin wasn’t around long enough to implement a program that aimed at ending native poverty in a decade, his plan enjoyed wide support and created something even more seductive: a sense of optimism.
Then-Opposition leader Stephen Harper claimed that he supported the plan to end native poverty and the principles of the Kelowna Accord, though he differed on how that should be accomplished.
Put that in the same category with Harper’s promises not to mess with income trusts or the Old Age Supplement. Canada’s First Nations leaders have had their bags packed for that meeting for going on seven years but the invitation, apparently, is still in the mail.
That statement covers more than one million people.
But when Federal Court Judge Michael Phelan ruled in 2013 that Metis and non-status Indians were in fact “Indians” under section of 91/24 of the Constitution, the Prime Minister did not adopt the advice he once gave with such alacrity to the provinces and the territories to discharge their responsibilities. He decided instead to appeal the decision and dispute the ruling that said 600,000 “new” aboriginals came under federal jurisdiction.
It’s the same story on reserves after seven years of Stephen Harper — the water is still poor, the housing Third World and the health outcomes a national scandal. The best Harper could manage during the Idle No More protests aimed at holding Ottawa to its responsibilities was to mock Chief Theresa Spence.
The last blow to the PM’s credibility on the aboriginal street may well be the government’s vaunted native education legislation — a plan AFN Chief Shawn Atleo has already panned because it was conceived, as most of this government’s legislation is, unilaterally.
It is not, in the end, that Stephen Harper has done nothing for Canada’s First Nations. There has been good work on human rights, for example, and real progress on the thorny issue of matrimonial reserve property.
There has also been some progress on First Nation’s governance. But there has been no consistent record of striking the new relationship once promised, and which looked so promising in the lustre surrounding the government’s apology to Canada’s aboriginals for the cultural atrocities of the residential schools.
There are things the federal government could do to help win First Nations’ support for pipeline plans. One is to make the bands in B.C. true stakeholders by recognizing the order of wealth transfer that must take place.
Brian Crowley and Ken Coates of the Macdonald-Laurier Institute came up with some excellent ideas: developing an advanced, evidence-based pipeline and shipping system with input from First Nations and environmental groups; designating the corridor land for pipelines as reserves under the Indian Act, thereby creating another revenue stream for First Nations which could collect taxes; and creating an endowment to cover the cost of oil spills and their clean-up — though no one believes after Exxon Valdez or Deepwater Horizon that any fund could ever hold enough money.
Even under those circumstances, Northern Gateway is still a very tough sell, and not just to First Nations leaders. The majority of people in British Columbia oppose the project. They know that one major spill could wipe out the B.C. coast, because every salmon, halibut, sea lion, gray whale and sea bird goes past the mouth of the Douglas Channel, where hundreds of tankers would be navigating.
But the Conservatives’ push needs to start somewhere and it would probably be a good thing if Stephen Harper opts to meet with Canada’s aboriginals in some place other than court. There will never be progress on this file as long as Aboriginal Affairs and Northern Development Canada owns the dubious record of having the biggest legal bills in the federal government.
Trust is earned — not litigated. |
-- @@stderr --
dtrace: failed to compile script test/unittest/translators/err.D_XLATE_SOU.BadTransInt.d: [D_XLATE_SOU] line 25: translator output type must be a struct or union
|
lemma in_components_subset: "c \<in> components s \<Longrightarrow> c \<subseteq> s" |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.