text
stringlengths 0
3.34M
|
---|
Formal statement is: lemma offset_poly_pCons: "offset_poly (pCons a p) h = smult h (offset_poly p h) + pCons a (offset_poly p h)" Informal statement is: The offset polynomial of a polynomial with a leading coefficient is the product of the offset polynomial of the rest of the polynomial with the offset, plus the offset polynomial of the rest of the polynomial. |
Call us or email us today.
A : There is no simple formula to determine the type of mortgage that is best for you. This choice depends on a number of factors, including your current financial picture and how long you intend to keep your house. ONEILL FINANCIAL SERVICES can help you evaluate your choices and help you make the most appropriate decision. |
(**
CoLoR, a Coq library on rewriting and termination.
See the COPYRIGHTS and LICENSE files.
- Stephane Le Roux, 2007-02-20
excluded middle and decidability for relations.
*)
From Coq Require Import Relations.
From CoLoR Require Import LogicUtil.
Set Implicit Arguments.
Section S.
Variables (A : Type) (R : relation A).
Definition rel_midex := forall x y : A, R x y \/ ~R x y.
Definition rel_dec := forall x y, {R x y} + {~R x y}.
Lemma rel_dec_midex : rel_dec -> rel_midex.
Proof. do 3 intro. destruct (X x y); tauto. Qed.
Definition fun_rel_dec (f : A->A->bool) :=
forall x y, if f x y then R x y else ~R x y.
Lemma bool_rel_dec : {f : A->A->bool | fun_rel_dec f} -> rel_dec.
Proof. intros (f,H) x y. gen (H x y). case (f x y); intros; tauto. Qed.
Lemma rel_dec_bool : rel_dec -> {f : A->A->bool | fun_rel_dec f}.
Proof.
intro H. exists (fun x y : A => if H x y then true else false).
intros x y. destruct (H x y); trivial.
Qed.
Lemma fun_rel_dec_true : forall f x y, fun_rel_dec f -> f x y = true -> R x y.
Proof. intros. set (w := H x y). rewrite H0 in w. hyp. Qed.
Lemma fun_rel_dec_false : forall f x y,
fun_rel_dec f -> f x y = false -> ~R x y.
Proof. intros. set (w := H x y). rewrite H0 in w. hyp. Qed.
(***********************************************************************)
(** Leibniz equality relation *)
Definition eq_midex := forall x y : A, x=y \/ x<>y.
Definition eq_dec := forall x y : A, {x=y}+{x<>y}.
Lemma eq_dec_midex : eq_dec -> eq_midex.
Proof. do 3 intro. destruct (X x y); tauto. Qed.
End S.
|
/-
Copyright (c) 2019 The Flypitch Project. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jesse Han, Floris van Doorn
-/
import .compactness
open set function nat
universe variable u
namespace fol
local notation h :: t := dvector.cons h t
local notation `[` l:(foldr `, ` (h t, dvector.cons h t) dvector.nil `]`:0) := l
namespace Language
def Lconstants (α : Type u) : Language :=
⟨λn, nat.rec α (λn ih, pempty) n, λn, pempty⟩
protected def sum (L L' : Language) : Language :=
⟨λn, L.functions n ⊕ L'.functions n, λ n, L.relations n ⊕ L'.relations n⟩
def symbols (L : Language) := (Σl, L.functions l) ⊕ (Σl, L.relations l)
end Language
section
variable {L : Language}
@[simp] def symbols_in_term : ∀{l}, preterm L l → set L.symbols
| _ &k := ∅
| l (func f) := {sum.inl ⟨l,f⟩}
| _ (app t₁ t₂) := symbols_in_term t₁ ∪ symbols_in_term t₂
@[simp] def symbols_in_formula : ∀{l}, preformula L l → set L.symbols
| _ falsum := ∅
| _ (t₁ ≃ t₂) := symbols_in_term t₁ ∪ symbols_in_term t₂
| l (rel R) := {sum.inr ⟨l, R⟩}
| _ (apprel f t) := symbols_in_formula f ∪ symbols_in_term t
| _ (f₁ ⟹ f₂) := symbols_in_formula f₁ ∪ symbols_in_formula f₂
| _ (∀' f) := symbols_in_formula f
@[simp] lemma symbols_in_term_lift_at (n m) : ∀{l} (t : preterm L l),
symbols_in_term (t ↑' n # m) = symbols_in_term t
| _ &k := by by_cases h : m ≤ k; simp [h]
| l (func f) := by refl
| _ (app t₁ t₂) := by simp*
@[simp] lemma symbols_in_term_lift (n) {l} (t : preterm L l) :
symbols_in_term (t ↑ n) = symbols_in_term t :=
symbols_in_term_lift_at n 0 t
lemma symbols_in_term_subst (s : term L) (n) : ∀{l} (t : preterm L l),
symbols_in_term (t[s // n]) ⊆ symbols_in_term t ∪ symbols_in_term s
| _ &k := by apply decidable.lt_by_cases n k; intro h; simp [h]
| _ (func f) := subset_union_left _ _
| _ (app t₁ t₂) :=
by { simp; split; refine subset.trans (symbols_in_term_subst _) _;
simp [subset_union2_left, subset_union2_middle] }
lemma symbols_in_formula_subst : ∀{l} (f : preformula L l) (s : term L) (n),
symbols_in_formula (f[s // n]) ⊆ symbols_in_formula f ∪ symbols_in_term s
| _ falsum s n := empty_subset _
| _ (t₁ ≃ t₂) s n :=
by { simp; split; refine subset.trans (symbols_in_term_subst _ _ _) _;
simp [subset_union2_left, subset_union2_middle] }
| _ (rel R) s n := subset_union_left _ _
| _ (apprel f t) s n :=
by { simp; split; [refine subset.trans (symbols_in_formula_subst _ _ _) _,
refine subset.trans (symbols_in_term_subst _ _ _) _];
simp [subset_union2_left, subset_union2_middle] }
| _ (f₁ ⟹ f₂) s n :=
by { simp; split; refine subset.trans (symbols_in_formula_subst _ _ _) _;
simp [subset_union2_left, subset_union2_middle] }
| _ (∀' f) s n := symbols_in_formula_subst f _ _
end
-- def symbols_in_prf : ∀{Γ : set $ formula L} {f : formula L} (P : Γ ⊢ f), set L.symbols
-- | Γ f (axm h) := symbols_in_formula f
-- | Γ (f₁ ⟹ f₂) (impI P) := symbols_in_prf P ∪ symbols_in_formula f₁
-- | Γ f₂ (impE f₁ P₁ P₂) := symbols_in_prf P₁ ∪ symbols_in_prf P₂
-- | Γ f (falsumE P) := symbols_in_prf P ∪ symbols_in_formula f
-- | Γ (∀' f) (allI P) := symbols_in_prf P
-- | Γ _ (allE₂ f t P) := symbols_in_prf P ∪ symbols_in_term t
-- | Γ (_ ≃ t) (ref _ _) := symbols_in_term t
-- | Γ _ (subst₂ s t f P₁ P₂) := symbols_in_prf P₁ ∪ symbols_in_prf P₂
-- def interpolation : ∀{Γ : set $ formula L} {f : formula L} (P : Γ ⊢ f),
-- Σ' (f' : formula L) (P₁ : Γ ⊢ f') (P₂ : {f'} ⊢ f),
-- symbols_in_prf P₁ ⊆ ⋃₀ (symbols_in_formula '' Γ) ∧
-- symbols_in_prf P₂ ⊆ symbols_in_formula f ∧
-- symbols_in_formula f' ⊆ ⋃₀ (symbols_in_formula '' Γ) ∩ symbols_in_formula f :=
-- sorry -- probably the last property follows automatically
structure Lhom (L L' : Language) :=
(on_function : ∀{n}, L.functions n → L'.functions n)
(on_relation : ∀{n}, L.relations n → L'.relations n)
infix ` →ᴸ `:10 := Lhom -- \^L
namespace Lhom
/- -/
variables {L : Language.{u}} {L' : Language.{u}} (ϕ : L →ᴸ L')
protected def id (L : Language) : L →ᴸ L :=
⟨λn, id, λ n, id⟩
protected def sum_inl {L L' : Language} : L →ᴸ L.sum L' :=
⟨λn, sum.inl, λ n, sum.inl⟩
protected def sum_inr {L L' : Language} : L' →ᴸ L.sum L' :=
⟨λn, sum.inr, λ n, sum.inr⟩
@[reducible]def comp {L1} {L2} {L3} (g : L2 →ᴸ L3) (f : L1 →ᴸ L2) : L1 →ᴸ L3 :=
begin
-- rcases g with ⟨g1, g2⟩, rcases f with ⟨f1,f2⟩,
-- exact ⟨λn, g1 ∘ f1, λn, g2 ∘ f2⟩
split,
all_goals{intro n},
let g1 := g.on_function, let f1 := f.on_function,-- Lean's not letting me "@" g.on_function etc
exact (@g1 n) ∘ (@f1 n),
let g2 := g.on_relation, let f2 := f.on_relation,
exact (@g2 n) ∘ (@f2 n)
end
lemma Lhom_funext {L1} {L2} {F G : L1 →ᴸ L2} (h_fun : F.on_function = G.on_function ) (h_rel : F.on_relation = G.on_relation ) : F = G :=
by {cases F with Ff Fr, cases G with Gf Gr, simp only *, exact and.intro h_fun h_rel}
local infix ` ∘ `:60 := Lhom.comp
@[simp]lemma id_is_left_identity {L1 L2} {F : L1 →ᴸ L2} : (Lhom.id L2) ∘ F = F := by {cases F, refl}
@[simp]lemma id_is_right_identity {L1 L2} {F : L1 →ᴸ L2} : F ∘ (Lhom.id L1) = F := by {cases F, refl}
structure is_injective : Prop :=
(on_function {n} : injective (on_function ϕ : L.functions n → L'.functions n))
(on_relation {n} : injective (on_relation ϕ : L.relations n → L'.relations n))
class has_decidable_range : Type u :=
(on_function {n} : decidable_pred (range (on_function ϕ : L.functions n → L'.functions n)))
(on_relation {n} : decidable_pred (range (on_relation ϕ : L.relations n → L'.relations n)))
attribute [instance] has_decidable_range.on_function has_decidable_range.on_relation
@[simp] def on_symbol : L.symbols → L'.symbols
| (sum.inl ⟨l, f⟩) := sum.inl ⟨l, ϕ.on_function f⟩
| (sum.inr ⟨l, R⟩) := sum.inr ⟨l, ϕ.on_relation R⟩
@[simp] def on_term : ∀{l}, preterm L l → preterm L' l
| _ &k := &k
| _ (func f) := func $ ϕ.on_function f
| _ (app t₁ t₂) := app (on_term t₁) (on_term t₂)
@[simp] lemma on_term_lift_at : ∀{l} (t : preterm L l) (n m : ℕ),
ϕ.on_term (t ↑' n # m) = ϕ.on_term t ↑' n # m
| _ &k n m := by simp
| _ (func f) n m := by refl
| _ (app t₁ t₂) n m := by simp*
@[simp] lemma on_term_lift {l} (n : ℕ) (t : preterm L l) : ϕ.on_term (t ↑ n) = ϕ.on_term t ↑ n :=
ϕ.on_term_lift_at t n 0
@[simp] lemma on_term_subst : ∀{l} (t : preterm L l) (s : term L) (n : ℕ),
ϕ.on_term (t[s // n]) = ϕ.on_term t[ϕ.on_term s // n]
| _ &k s n := by apply decidable.lt_by_cases k n; intro h; simp [h]
| _ (func f) s n := by refl
| _ (app t₁ t₂) s n := by simp*
@[simp] def on_term_apps : ∀{l} (t : preterm L l) (ts : dvector (term L) l),
ϕ.on_term (apps t ts) = apps (ϕ.on_term t) (ts.map ϕ.on_term)
| _ t [] := by refl
| _ t (t'::ts) := by simp*
lemma not_mem_symbols_in_term_on_term {s : L'.symbols} (h : s ∉ range (ϕ.on_symbol)) :
∀{l} (t : preterm L l), s ∉ symbols_in_term (ϕ.on_term t)
| _ &k h' := not_mem_empty _ h'
| l (func f) h' := h ⟨sum.inl ⟨l, f⟩, (eq_of_mem_singleton h').symm⟩
| _ (app t₁ t₂) h' :=
or.elim h' (not_mem_symbols_in_term_on_term t₁) (not_mem_symbols_in_term_on_term t₂)
@[simp] def on_formula : ∀{l}, preformula L l → preformula L' l
| _ falsum := falsum
| _ (t₁ ≃ t₂) := ϕ.on_term t₁ ≃ ϕ.on_term t₂
| _ (rel R) := rel $ ϕ.on_relation R
| _ (apprel f t) := apprel (on_formula f) $ ϕ.on_term t
| _ (f₁ ⟹ f₂) := on_formula f₁ ⟹ on_formula f₂
| _ (∀' f) := ∀' on_formula f
@[simp] lemma on_formula_lift_at : ∀{l} (n m : ℕ) (f : preformula L l),
ϕ.on_formula (f ↑' n # m) = ϕ.on_formula f ↑' n # m
| _ n m falsum := by refl
| _ n m (t₁ ≃ t₂) := by simp
| _ n m (rel R) := by refl
| _ n m (apprel f t) := by simp*
| _ n m (f₁ ⟹ f₂) := by simp*
| _ n m (∀' f) := by simp*
@[simp] lemma on_formula_lift {l} (n : ℕ) (f : preformula L l) :
ϕ.on_formula (f ↑ n) = ϕ.on_formula f ↑ n :=
ϕ.on_formula_lift_at n 0 f
@[simp] lemma on_formula_subst : ∀{l} (f : preformula L l) (s : term L) (n : ℕ),
ϕ.on_formula (f[s // n]) = (ϕ.on_formula f)[ϕ.on_term s // n]
| _ falsum s n := by refl
| _ (t₁ ≃ t₂) s n := by simp
| _ (rel R) s n := by refl
| _ (apprel f t) s n := by simp*
| _ (f₁ ⟹ f₂) s n := by simp*
| _ (∀' f) s n := by simp*
@[simp] def on_formula_apps_rel : ∀{l} (f : preformula L l) (ts : dvector (term L) l),
ϕ.on_formula (apps_rel f ts) = apps_rel (ϕ.on_formula f) (ts.map ϕ.on_term)
| _ f [] := by refl
| _ f (t'::ts) := by simp*
lemma not_mem_symbols_in_formula_on_formula {s : L'.symbols} (h : s ∉ range (ϕ.on_symbol)) :
∀{l} (f : preformula L l), s ∉ symbols_in_formula (ϕ.on_formula f)
| _ falsum h' := not_mem_empty _ h'
| _ (t₁ ≃ t₂) h' := by cases h'; apply not_mem_symbols_in_term_on_term ϕ h _ h'
| l (rel R) h' := h ⟨sum.inr ⟨l, R⟩, (eq_of_mem_singleton h').symm⟩
| _ (apprel f t) h' :=
by { cases h', apply not_mem_symbols_in_formula_on_formula _ h',
apply not_mem_symbols_in_term_on_term ϕ h _ h' }
| _ (f₁ ⟹ f₂) h' := by cases h'; apply not_mem_symbols_in_formula_on_formula _ h'
| _ (∀' f) h' := not_mem_symbols_in_formula_on_formula f h'
lemma not_mem_function_in_formula_on_formula {l'} {f' : L'.functions l'}
(h : f' ∉ range (@on_function _ _ ϕ l')) {l} (f : preformula L l) :
(sum.inl ⟨l', f'⟩ : L'.symbols) ∉ symbols_in_formula (ϕ.on_formula f) :=
begin
apply not_mem_symbols_in_formula_on_formula,
intro h', apply h,
rcases h' with ⟨⟨n, f⟩ | ⟨n, R⟩, hf₂⟩; dsimp at hf₂; cases hf₂ with hf₂',
apply mem_range_self
end
@[simp] def on_bounded_term {n} : ∀{l} (t : bounded_preterm L n l), bounded_preterm L' n l
| _ &k := &k
| _ (bd_func f) := bd_func $ ϕ.on_function f
| _ (bd_app t s) := bd_app (on_bounded_term t) (on_bounded_term s)
@[simp] def on_bounded_term_fst {n} : ∀{l} (t : bounded_preterm L n l),
(ϕ.on_bounded_term t).fst = ϕ.on_term t.fst
| _ &k := by refl
| _ (bd_func f) := by refl
| _ (bd_app t s) := by dsimp; simp*
@[simp] def on_bounded_formula : ∀{n l} (f : bounded_preformula L n l), bounded_preformula L' n l
| _ _ bd_falsum := ⊥
| _ _ (t₁ ≃ t₂) := ϕ.on_bounded_term t₁ ≃ ϕ.on_bounded_term t₂
| _ _ (bd_rel R) := bd_rel $ ϕ.on_relation R
| _ _ (bd_apprel f t) := bd_apprel (on_bounded_formula f) $ ϕ.on_bounded_term t
| _ _ (f₁ ⟹ f₂) := on_bounded_formula f₁ ⟹ on_bounded_formula f₂
| _ _ (∀' f) := ∀' on_bounded_formula f
@[simp] def on_bounded_formula_fst : ∀{n l} (f : bounded_preformula L n l),
(ϕ.on_bounded_formula f).fst = ϕ.on_formula f.fst
| _ _ bd_falsum := by refl
| _ _ (t₁ ≃ t₂) := by simp
| _ _ (bd_rel R) := by refl
| _ _ (bd_apprel f t) := by simp*
| _ _ (f₁ ⟹ f₂) := by simp*
| _ _ (∀' f) := by simp*
/- Various lemmas of the shape "on_etc is a functor to Type*" -/
@[simp]lemma comp_on_function {L1} {L2} {L3} (g : L2 →ᴸ L3) (f : L1 →ᴸ L2):
(g ∘ f).on_function =
begin intro n, let g1 := g.on_function, let f1 := f.on_function,
exact function.comp (@g1 n) (@f1 n) end
:= by refl
/- comp_on_function with explicit nat parameter -/
@[simp]lemma comp_on_function' {L1} {L2} {L3} (g : L2 →ᴸ L3) (f : L1 →ᴸ L2) (n):
@on_function L1 L3 (g ∘ f) n =
function.comp (@on_function L2 L3 g n) (@on_function L1 L2 f n)
:= by refl
@[simp]lemma comp_on_relation {L1} {L2} {L3} (g : L2 →ᴸ L3) (f : L1 →ᴸ L2) :
(g ∘ f).on_relation =
begin intro n, let g1 := g.on_relation, let f1 := f.on_relation,
exact function.comp (@g1 n) (@f1 n) end
:= by refl
/- comp_on_relation with explicit nat parameter -/
@[simp]lemma comp_on_relation' {L1} {L2} {L3} (g : L2 →ᴸ L3) (f : L1 →ᴸ L2) (n):
@on_relation L1 L3 (g ∘ f) n =
function.comp (@on_relation L2 L3 g n) (@on_relation L1 L2 f n)
:= by refl
@[simp]lemma comp_on_term {L1} {L2} {L3} {l : ℕ} (g : L2 →ᴸ L3) (f : L1 →ᴸ L2) :
@on_term L1 L3 (g ∘ f) l = function.comp (@on_term L2 L3 g l) (@on_term L1 L2 f l) :=
by {fapply funext, intro x, induction x, tidy}
@[simp]lemma comp_on_formula {L1} {L2} {L3} {l : ℕ}(g : L2 →ᴸ L3) (f : L1 →ᴸ L2) :
@on_formula L1 L3 (g ∘ f) l = function.comp (@on_formula L2 L3 g l) (@on_formula L1 L2 f l) :=
by {fapply funext, intro x, induction x, tidy, all_goals{rw[comp_on_term]} }
@[simp]lemma comp_on_bounded_term {L1} {L2} {L3} {n l : ℕ}(g : L2 →ᴸ L3) (f : L1 →ᴸ L2) :
@on_bounded_term L1 L3 (g ∘ f) n l = function.comp (@on_bounded_term L2 L3 g n l) (@on_bounded_term L1 L2 f n l) :=
funext $ λ _, by tidy
@[simp]lemma comp_on_bounded_formula {L1} {L2} {L3} {n l : ℕ}(g : L2 →ᴸ L3) (f : L1 →ᴸ L2) :
@on_bounded_formula L1 L3 (g ∘ f) n l = function.comp (@on_bounded_formula L2 L3 g n l) (@on_bounded_formula L1 L2 f n l) :=
by {apply funext, intro x, ext, induction x; simp}
lemma id_term {L} : Πl, Π f, (@on_term L L (Lhom.id L) l) f = f
| _ &k := by refl
| _ (func f) := by refl
| l (app t₁ t₂) := by simp[id_term (l+1) t₁, id_term 0 t₂]
lemma id_formula {L} : Π l, Π f, (@on_formula L L (Lhom.id L) l) f = f
| _ falsum := by refl
| _ (t₁ ≃ t₂) := by simp[id_term]
| _ (rel R) := by refl
| l (apprel f t) := by {dsimp, rw[id_formula _ f, id_term _ t]}
| _ (f₁ ⟹ f₂) := by {dsimp, rw[id_formula _ f₁, id_formula _ f₂]}
| _ (∀' f) := by {dsimp, rw[id_formula _ f]}
lemma id_bounded_term {L} (n) : Πl, Π f, (@on_bounded_term L L (Lhom.id L) n l) f = f
| _ (bd_var k) := by refl
| _ (bd_func k) := by refl
| l (bd_app t₁ t₂) := by simp[id_bounded_term (l+1) t₁, id_bounded_term 0 t₂]
lemma id_bounded_formula {L} : Π n l, Π f, (@on_bounded_formula L L (Lhom.id L) n l) f = f
| _ _ bd_falsum := by refl
| _ _ (t₁ ≃ t₂) := by simp[id_bounded_term]
| _ _ (bd_rel R) := by refl
| _ l (bd_apprel f t) := by {dsimp, rw[id_bounded_formula _ _ f, id_bounded_term _ _ t]}
| _ _ (f₁ ⟹ f₂) := by {dsimp, rw[id_bounded_formula _ _ f₁, id_bounded_formula _ _ f₂]}
| _ _ (∀' f) := by {dsimp, rw[id_bounded_formula _ _ f]}
@[simp] def on_closed_term (t : closed_term L) : closed_term L' := ϕ.on_bounded_term t
@[simp] def on_sentence (f : sentence L) : sentence L' := ϕ.on_bounded_formula f
def on_sentence_fst (f : sentence L) : (ϕ.on_sentence f).fst = ϕ.on_formula f.fst :=
ϕ.on_bounded_formula_fst f
def on_prf {Γ : set $ formula L} {f : formula L} (h : Γ ⊢ f) : ϕ.on_formula '' Γ ⊢ ϕ.on_formula f :=
begin
induction h,
{ apply axm, exact mem_image_of_mem _ h_h, },
{ apply impI, rw [←image_insert_eq], exact h_ih },
{ exact impE _ h_ih_h₁ h_ih_h₂, },
{ apply falsumE, rw [image_insert_eq] at h_ih, exact h_ih },
{ apply allI, rw [image_image] at h_ih ⊢, simp [image_congr' (on_formula_lift ϕ 1)] at h_ih,
exact h_ih },
{ apply allE _ _ h_ih, symmetry, apply on_formula_subst },
{ apply prf.ref },
{ simp at h_ih_h₂, apply subst _ h_ih_h₁ h_ih_h₂, simp }
end
def on_sprf {Γ : set $ sentence L} {f : sentence L} (h : Γ ⊢ f) :
ϕ.on_sentence '' Γ ⊢ ϕ.on_sentence f :=
by have := ϕ.on_prf h; simp only [sprf, Theory.fst, image_image, function.comp,
on_bounded_formula_fst, on_sentence] at this ⊢; exact this
/- replace all symbols not in the image of ϕ by a new variable -/
noncomputable def reflect_term [has_decidable_range ϕ] (t : term L') (m : ℕ) : term L :=
term.elim (λk, &k ↑' 1 # m)
(λl f' ts' ts, if hf' : f' ∈ range (@on_function _ _ ϕ l)
then apps (func (classical.some hf')) ts else &m) t
variable {ϕ}
lemma reflect_term_apps_pos [has_decidable_range ϕ] {l} {f : L'.functions l}
(hf : f ∈ range (@on_function _ _ ϕ l)) (ts : dvector (term L') l) (m : ℕ) :
ϕ.reflect_term (apps (func f) ts) m =
apps (func (classical.some hf)) (ts.map (λt, ϕ.reflect_term t m)) :=
(term.elim_apps _ _ f ts).trans $ by rw [dif_pos hf]; refl
lemma reflect_term_apps_neg [has_decidable_range ϕ] {l} {f : L'.functions l}
(hf : f ∉ range (@on_function _ _ ϕ l)) (ts : dvector (term L') l) (m : ℕ) :
ϕ.reflect_term (apps (func f) ts) m = &m :=
(term.elim_apps _ _ f ts).trans $ by rw [dif_neg hf]
lemma reflect_term_const_pos [has_decidable_range ϕ] {c : L'.constants}
(hf : c ∈ range (@on_function _ _ ϕ 0)) (m : ℕ) :
ϕ.reflect_term (func c) m = func (classical.some hf) :=
by apply reflect_term_apps_pos hf ([]) m
lemma reflect_term_const_neg [has_decidable_range ϕ] {c : L'.constants}
(hf : c ∉ range (@on_function _ _ ϕ 0)) (m : ℕ) :
ϕ.reflect_term (func c) m = &m :=
by apply reflect_term_apps_neg hf ([]) m
@[simp] lemma reflect_term_var [has_decidable_range ϕ] (k : ℕ) (m : ℕ) :
ϕ.reflect_term &k m = &k ↑' 1 # m := by refl
@[simp] lemma reflect_term_on_term [has_decidable_range ϕ] (hϕ : is_injective ϕ) (t : term L)
(m : ℕ) : ϕ.reflect_term (ϕ.on_term t) m = t ↑' 1 # m :=
begin
refine term.rec _ _ t; clear t; intros,
{ refl },
{ simp [reflect_term_apps_pos (mem_range_self f)],
rw [classical.some_eq f (λy hy, hϕ.on_function hy), dvector.map_congr_pmem ih_ts] }
end
lemma reflect_term_lift_at [has_decidable_range ϕ] (hϕ : is_injective ϕ) {n m m' : ℕ} (h : m ≤ m')
(t : term L') : ϕ.reflect_term (t ↑' n # m) (m'+n) = ϕ.reflect_term t m' ↑' n # m :=
begin
refine term.rec _ _ t; clear t; intros,
{ simp [-lift_term_at], rw[lift_term_at2_small _ _ _ h], simp },
{ by_cases h' : f ∈ range (@on_function _ _ ϕ l); simp [reflect_term_apps_pos,
reflect_term_apps_neg, h', h, dvector.map_congr_pmem ih_ts, -add_comm] }
end
lemma reflect_term_lift [has_decidable_range ϕ] (hϕ : is_injective ϕ) {n m : ℕ}
(t : term L') : ϕ.reflect_term (t ↑ n) (m+n) = ϕ.reflect_term t m ↑ n :=
reflect_term_lift_at hϕ m.zero_le t
lemma reflect_term_subst [has_decidable_range ϕ] (hϕ : is_injective ϕ) (n m : ℕ)
(s t : term L') :
ϕ.reflect_term (t[s // n]) (m+n) = (ϕ.reflect_term t (m+n+1))[ϕ.reflect_term s m // n] :=
begin
refine term.rec _ _ t; clear t; intros,
{ simp [-lift_term_at, -add_comm, -add_assoc],
apply decidable.lt_by_cases k n; intro h,
{ have h₂ : ¬(m + n ≤ k), from λh', not_le_of_gt h (le_trans (le_add_left n m) h'),
have h₃ : ¬(m + n + 1 ≤ k), from λh', h₂ $ le_trans (le_succ _) h',
simp [h, h₂, h₃, -add_comm, -add_assoc] },
{ have h₂ : ¬(m + n + 1 ≤ n), from not_le_of_gt (lt_of_le_of_lt (le_add_left n m) (lt.base _)) ,
simp [h, h₂, reflect_term_lift hϕ, -add_comm, -add_assoc] },
{ have hk := one_le_of_lt h,
have h₄ : n < k + 1, from lt.trans h (lt.base k),
by_cases h₂' : m + n + 1 ≤ k,
{ have h₂ : m + n + 1 ≤ k, from h₂',
have h₃ : m + n ≤ k - 1, from (nat.le_sub_right_iff_add_le hk).mpr h₂,
simp [h, h₂, h₃, h₄, -add_comm, -add_assoc],
rw [sub_add_eq_max, max_eq_left hk] },
{ have h₂ : ¬(m + n + 1 ≤ k), from h₂',
have h₃ : ¬(m + n ≤ k - 1), from λh', h₂ $ (nat.le_sub_right_iff_add_le hk).mp h',
simp [h, h₂, h₃, -add_comm, -add_assoc] }}},
{ have h : n < m + n + 1, from nat.lt_succ_of_le (nat.le_add_left n m),
by_cases h' : f ∈ range (@on_function _ _ ϕ l); simp [reflect_term_apps_pos,
reflect_term_apps_neg, h, h', dvector.map_congr_pmem ih_ts, -add_comm, -add_assoc] }
end
variable (ϕ)
noncomputable def reflect_formula [has_decidable_range ϕ] (f : formula L') :
∀(m : ℕ), formula L :=
formula.rec (λm, ⊥) (λt₁ t₂ m, ϕ.reflect_term t₁ m ≃ ϕ.reflect_term t₂ m)
(λl R' xs' m, if hR' : R' ∈ range (@on_relation _ _ ϕ l)
then apps_rel (rel (classical.some hR')) (xs'.map $ λt, ϕ.reflect_term t m) else ⊥)
(λf₁' f₂' f₁ f₂ m, f₁ m ⟹ f₂ m) (λf' f m, ∀' f (m+1)) f
variable {ϕ}
lemma reflect_formula_apps_rel_pos [has_decidable_range ϕ] {l} {R : L'.relations l}
(hR : R ∈ range (@on_relation _ _ ϕ l)) (ts : dvector (term L') l) (m : ℕ) :
ϕ.reflect_formula (apps_rel (rel R) ts) m =
apps_rel (rel (classical.some hR)) (ts.map (λt, ϕ.reflect_term t m)) :=
by simp [reflect_formula, formula.rec_apps_rel, dif_pos hR]
lemma reflect_formula_apps_rel_neg [has_decidable_range ϕ] {l} {R : L'.relations l}
(hR : R ∉ range (@on_relation _ _ ϕ l)) (ts : dvector (term L') l) (m : ℕ) :
ϕ.reflect_formula (apps_rel (rel R) ts) m = ⊥ :=
by simp [reflect_formula, formula.rec_apps_rel, dif_neg hR]
@[simp] lemma reflect_formula_equal [has_decidable_range ϕ] (t₁ t₂ : term L') (m : ℕ) :
ϕ.reflect_formula (t₁ ≃ t₂) m = ϕ.reflect_term t₁ m ≃ ϕ.reflect_term t₂ m := by refl
@[simp] lemma reflect_formula_imp [has_decidable_range ϕ] (f₁ f₂ : formula L') (m : ℕ) :
ϕ.reflect_formula (f₁ ⟹ f₂) m = ϕ.reflect_formula f₁ m ⟹ ϕ.reflect_formula f₂ m := by refl
@[simp] lemma reflect_formula_all [has_decidable_range ϕ] (f : formula L') (m : ℕ) :
ϕ.reflect_formula (∀' f) m = ∀' (ϕ.reflect_formula f (m+1)) := by refl
@[simp] lemma reflect_formula_on_formula [has_decidable_range ϕ] (hϕ : is_injective ϕ) (m : ℕ)
(f : formula L) : ϕ.reflect_formula (ϕ.on_formula f) m = f ↑' 1 # m :=
begin
revert m, refine formula.rec _ _ _ _ _ f; clear f; intros,
{ refl },
{ simp [hϕ] },
{ simp [reflect_formula_apps_rel_pos (mem_range_self R), hϕ],
rw [classical.some_eq R (λy hy, hϕ.on_relation hy)] },
{ simp* },
{ simp* }
end
lemma reflect_formula_lift_at [has_decidable_range ϕ] (hϕ : is_injective ϕ) {n m m' : ℕ}
(h : m ≤ m') (f : formula L') :
ϕ.reflect_formula (f ↑' n # m) (m'+n) = ϕ.reflect_formula f m' ↑' n # m :=
begin
revert m m', refine formula.rec _ _ _ _ _ f; clear f; intros,
{ refl },
{ simp [reflect_term_lift_at hϕ h, -add_comm] },
{ by_cases h' : R ∈ range (@on_relation _ _ ϕ l); simp [reflect_formula_apps_rel_pos,
reflect_formula_apps_rel_neg, h', h, ts.map_congr (reflect_term_lift_at hϕ h), -add_comm] },
{ simp [ih₁ h, ih₂ h, -add_comm] },
{ simp [-add_comm, -add_assoc], rw [←ih], simp, exact add_le_add_right h 1 },
end
lemma reflect_formula_lift [has_decidable_range ϕ] (hϕ : is_injective ϕ) (n m : ℕ)
(f : formula L') : ϕ.reflect_formula (f ↑ n) (m+n) = ϕ.reflect_formula f m ↑ n :=
reflect_formula_lift_at hϕ m.zero_le f
lemma reflect_formula_lift1 [has_decidable_range ϕ] (hϕ : is_injective ϕ) (m : ℕ)
(f : formula L') : ϕ.reflect_formula (f ↑ 1) (m+1) = ϕ.reflect_formula f m ↑ 1 :=
reflect_formula_lift hϕ 1 m f
lemma reflect_formula_subst [has_decidable_range ϕ] (hϕ : is_injective ϕ) (f : formula L')
(n m : ℕ) (s : term L') :
ϕ.reflect_formula (f[s // n]) (m+n) = (ϕ.reflect_formula f (m+n+1))[ϕ.reflect_term s m // n] :=
begin
revert n, refine formula.rec _ _ _ _ _ f; clear f; intros,
{ refl },
{ simp [reflect_term_subst hϕ, -add_comm] },
{ by_cases h' : R ∈ range (@on_relation _ _ ϕ l); simp [reflect_formula_apps_rel_pos,
reflect_formula_apps_rel_neg, h', ts.map_congr (reflect_term_subst hϕ n m s), -add_comm] },
{ simp [ih₁, ih₂, -add_comm] },
{ simp [-add_comm, ih] },
end
@[simp] lemma reflect_formula_subst0 [has_decidable_range ϕ] (hϕ : is_injective ϕ) (m : ℕ)
(f : formula L') (s : term L') :
ϕ.reflect_formula (f[s // 0]) m = (ϕ.reflect_formula f (m+1))[ϕ.reflect_term s m // 0] :=
reflect_formula_subst hϕ f 0 m s
noncomputable def reflect_prf_gen [has_decidable_range ϕ] (hϕ : is_injective ϕ) {Γ}
{f : formula L'} (m) (H : Γ ⊢ f) : (λf, ϕ.reflect_formula f m) '' Γ ⊢ ϕ.reflect_formula f m :=
begin
induction H generalizing m,
{ apply axm, apply mem_image_of_mem _ H_h },
{ apply impI, have h := @H_ih m, rw [image_insert_eq] at h, exact h },
{ apply impE, apply H_ih_h₁, apply H_ih_h₂ },
{ apply falsumE, have h := @H_ih m, rw [image_insert_eq] at h, exact h },
{ apply allI, rw [image_image], have h := @H_ih (m+1), rw [image_image] at h,
apply cast _ h, congr1, apply image_congr' (reflect_formula_lift1 hϕ m) },
{ apply allE, have h := @H_ih m, simp at h, exact h, symmetry,
apply reflect_formula_subst0 hϕ },
{ apply ref },
{ apply subst, have h := @H_ih_h₁ m, simp at h, exact h,
have h := @H_ih_h₂ m, simp [hϕ] at h, exact h, simp [hϕ] },
end
section
/- maybe generalize to filter_symbol? -/
@[reducible] def filter_symbols (p : L.symbols → Prop) : Language :=
⟨λl, subtype (λf, p (sum.inl ⟨l, f⟩)), λl, subtype (λR, p (sum.inr ⟨l, R⟩))⟩
def filter_symbols_Lhom (p : L.symbols → Prop) : filter_symbols p →ᴸ L :=
⟨λl, subtype.val, λl, subtype.val⟩
def is_injective_filter_symbols_Lhom (p : L.symbols → Prop) :
is_injective (filter_symbols_Lhom p) :=
⟨λl, subtype.val_injective, λl, subtype.val_injective⟩
lemma find_term_filter_symbols (p : L.symbols → Prop) :
∀{l} (t : preterm L l) (h : symbols_in_term t ⊆ { s | p s }),
{ t' : preterm (filter_symbols p) l // (filter_symbols_Lhom p).on_term t' = t }
| _ &k h := ⟨&k, rfl⟩
| _ (func f) h := ⟨func ⟨f, h $ mem_singleton _⟩, rfl⟩
| _ (app t₁ t₂) h :=
begin
let ih₁ := find_term_filter_symbols t₁ (subset.trans (subset_union_left _ _) h),
let ih₂ := find_term_filter_symbols t₂ (subset.trans (subset_union_right _ _) h),
refine ⟨app ih₁.1 ih₂.1, _⟩, dsimp, rw [ih₁.2, ih₂.2]
end
lemma find_formula_filter_symbols (p : L.symbols → Prop) :
∀{l} (f : preformula L l) (h : symbols_in_formula f ⊆ { s | p s }),
{ f' : preformula (filter_symbols p) l // (filter_symbols_Lhom p).on_formula f' = f }
| _ falsum h := ⟨⊥, rfl⟩
| _ (t₁ ≃ t₂) h :=
begin
let ih₁ := find_term_filter_symbols p t₁ (subset.trans (subset_union_left _ _) h),
let ih₂ := find_term_filter_symbols p t₂ (subset.trans (subset_union_right _ _) h),
refine ⟨ih₁.1 ≃ ih₂.1, _⟩, dsimp, rw [ih₁.2, ih₂.2]
end
| _ (rel R) h := ⟨rel ⟨R, h $ mem_singleton _⟩, rfl⟩
| _ (apprel f t) h :=
begin
let ih₁ := find_formula_filter_symbols f (subset.trans (subset_union_left _ _) h),
let ih₂ := find_term_filter_symbols p t (subset.trans (subset_union_right _ _) h),
refine ⟨apprel ih₁.1 ih₂.1, _⟩, dsimp, rw [ih₁.2, ih₂.2]
end
| _ (f₁ ⟹ f₂) h :=
begin
let ih₁ := find_formula_filter_symbols f₁ (subset.trans (subset_union_left _ _) h),
let ih₂ := find_formula_filter_symbols f₂ (subset.trans (subset_union_right _ _) h),
refine ⟨ih₁.1 ⟹ ih₂.1, _⟩, dsimp, rw [ih₁.2, ih₂.2]
end
| _ (∀' f) h :=
begin
let ih := find_formula_filter_symbols f h,
refine ⟨∀' ih.1, _⟩, dsimp, rw [ih.2]
end
end
noncomputable def generalize_constant {Γ} (c : L.constants)
(hΓ : (sum.inl ⟨0, c⟩ : L.symbols) ∉ ⋃₀ (symbols_in_formula '' Γ))
{f : formula L} (hf : (sum.inl ⟨0, c⟩ : L.symbols) ∉ symbols_in_formula f)
(H : Γ ⊢ f[func c // 0]) : Γ ⊢ ∀' f :=
begin
apply allI,
let p : L.symbols → Prop := (≠ sum.inl ⟨0, c⟩),
let ϕ := filter_symbols_Lhom p,
have hϕ : is_injective ϕ := is_injective_filter_symbols_Lhom p,
have hc : c ∉ range (on_function ϕ),
{ intro hc, rw [mem_range] at hc, rcases hc with ⟨c', hc'⟩,
apply c'.2, rw [←hc'], refl },
have hf' : symbols_in_formula f ⊆ {s : Language.symbols L | p s},
{ intros s hs hps, subst hps, exact hf hs },
rcases find_formula_filter_symbols p f hf' with ⟨f, rfl⟩,
have : {Γ' // Lhom.on_formula ϕ '' Γ' = Γ } ,
{ refine ⟨Lhom.on_formula ϕ ⁻¹' Γ, _⟩,
apply image_preimage_eq_of_subset, intros f' hf',
have : symbols_in_formula f' ⊆ {s : Language.symbols L | p s},
{ intros s hs hps, subst hps, exact hΓ ⟨_, mem_image_of_mem _ hf', hs⟩ },
rcases find_formula_filter_symbols p f' this with ⟨f, rfl⟩,
apply mem_range_self },
rcases this with ⟨Γ, rfl⟩,
rw [image_image, ←image_congr' (ϕ.on_formula_lift 1),
←image_image ϕ.on_formula],
apply ϕ.on_prf,
haveI : has_decidable_range (filter_symbols_Lhom p) :=
⟨λn f, classical.prop_decidable _, λn R, classical.prop_decidable _⟩,
have := reflect_prf_gen hϕ 0 H,
rwa [reflect_formula_subst0 hϕ, reflect_term_const_neg hc, image_image,
image_congr' (reflect_formula_on_formula hϕ 0),
reflect_formula_on_formula hϕ, lift_subst_formula_cancel] at this
end
noncomputable def sgeneralize_constant {T : Theory L} (c : L.constants)
(hΓ : (sum.inl ⟨0, c⟩ : L.symbols) ∉ ⋃₀ (symbols_in_formula '' T.fst))
{f : bounded_formula L 1} (hf : (sum.inl ⟨0, c⟩ : L.symbols) ∉ symbols_in_formula f.fst)
(H : T ⊢ f[bd_func c /0]) : T ⊢ ∀' f :=
by { simp [sprf] at H, exact generalize_constant c hΓ hf H }
noncomputable def reflect_prf {Γ : set $ formula L} {f : formula L} (hϕ : ϕ.is_injective)
(h : ϕ.on_formula '' Γ ⊢ ϕ.on_formula f) : Γ ⊢ f :=
begin
haveI : has_decidable_range ϕ :=
⟨λl f, classical.prop_decidable _, λl R, classical.prop_decidable _⟩,
apply reflect_prf_lift1,
have := reflect_prf_gen hϕ 0 h, simp [image_image, hϕ] at this, exact this
end
noncomputable def reflect_sprf {Γ : set $ sentence L} {f : sentence L} (hϕ : ϕ.is_injective)
(h : ϕ.on_sentence '' Γ ⊢ ϕ.on_sentence f) : Γ ⊢ f :=
by { apply reflect_prf hϕ, simp only [sprf, Theory.fst, image_image, function.comp,
on_bounded_formula_fst, on_sentence] at h ⊢, exact h }
lemma on_term_inj (h : ϕ.is_injective) {l} : injective (ϕ.on_term : preterm L l → preterm L' l) :=
begin
intros x y hxy, induction x generalizing y; cases y; try {injection hxy with hxy' hxy''},
{ rw [hxy'] },
{ rw [h.on_function hxy'] },
{ congr1, exact x_ih_t hxy', exact x_ih_s hxy'' }
end
lemma on_formula_inj (h : ϕ.is_injective) {l} :
injective (ϕ.on_formula : preformula L l → preformula L' l) :=
begin
intros x y hxy, induction x generalizing y; cases y; try {injection hxy with hxy' hxy''},
{ refl },
{ rw [on_term_inj h hxy', on_term_inj h hxy''] },
{ rw [h.on_relation hxy'] },
{ rw [x_ih hxy', on_term_inj h hxy''] },
{ rw [x_ih_f₁ hxy', x_ih_f₂ hxy''] },
{ rw [x_ih hxy'] }
end
lemma on_bounded_term_inj (h : ϕ.is_injective) {n} {l} : injective (ϕ.on_bounded_term : bounded_preterm L n l → bounded_preterm L' n l) :=
begin
intros x y hxy, induction x generalizing y; cases y; try {injection hxy with hxy' hxy''},
{ rw [hxy'] },
{ rw [h.on_function hxy'] },
{ congr1, exact x_ih_t hxy', exact x_ih_s hxy'' }
end
lemma on_bounded_formula_inj (h : ϕ.is_injective) {n l}:
injective (ϕ.on_bounded_formula : bounded_preformula L n l → bounded_preformula L' n l) :=
begin
intros x y hxy, induction x generalizing y; cases y; try {injection hxy with hxy' hxy''},
{ refl },
{ rw [on_bounded_term_inj h hxy', on_bounded_term_inj h hxy''] },
{ rw [h.on_relation hxy'] },
{ rw [x_ih hxy', on_bounded_term_inj h hxy''] },
{ rw [x_ih_f₁ hxy', x_ih_f₂ hxy''] },
{ rw [x_ih hxy'] }
end
variable (ϕ)
/-- Given L → L' and an L'-structure S, the reduct of S to L is the L-structure given by
restricting interpretations from L' to L --/
def reduct (S : Structure L') : Structure L :=
⟨ S.carrier, λn f, S.fun_map $ ϕ.on_function f, λn R, S.rel_map $ ϕ.on_relation R⟩
notation S`[[`:95 ϕ`]]`:90 := reduct ϕ S
variable {ϕ}
@[simp] def reduct_coe (S : Structure L') : ↥(reduct ϕ S) = S :=
by refl
def reduct_id {S : Structure L'} : S → S[[ϕ]] := id
@[simp] lemma reduct_term_eq {S : Structure L'} (hϕ : ϕ.is_injective) {n} :
Π(xs : dvector S n) {l} (t : bounded_preterm L n l) (xs' : dvector S l), realize_bounded_term xs (on_bounded_term ϕ t) xs' = @realize_bounded_term L (reduct ϕ S) n xs l t xs'
| xs _ (bd_var k) xs' := by refl
| xs _ (bd_func f) xs' := by refl
| xs l (bd_app t s) xs' := by simp*
lemma reduct_bounded_formula_iff {S : Structure L'} (hϕ : ϕ.is_injective) : Π{n l} (xs : dvector S n) (xs' : dvector S l) (f : bounded_preformula L n l),
realize_bounded_formula xs (on_bounded_formula ϕ f) xs' ↔ @realize_bounded_formula L (reduct ϕ S) n l xs f xs'
| _ _ xs xs' (bd_falsum) := by refl
| _ _ xs xs' (bd_equal t₁ t₂) := by simp [hϕ]
| _ _ xs xs' (bd_rel R) := by refl
| _ _ xs xs' (bd_apprel f t) := by simp*
| _ _ xs xs' (f₁ ⟹ f₂) := by simp*
| _ _ xs xs' (∀' f) := by apply forall_congr; intro x;simp*
lemma reduct_ssatisfied {S : Structure L'} {f : sentence L} (hϕ : ϕ.is_injective)
(h : S ⊨ ϕ.on_sentence f) : ϕ.reduct S ⊨ f :=
(reduct_bounded_formula_iff hϕ ([]) ([]) f).mp h
lemma reduct_ssatisfied' {S : Structure L'} {f : sentence L} (hϕ : ϕ.is_injective)
(h : S ⊨ ϕ.on_bounded_formula f) : ϕ.reduct S ⊨ f :=
(reduct_bounded_formula_iff hϕ ([]) ([]) f).mp h
def reduct_all_ssatisfied {S : Structure L'} {T : Theory L} (hϕ : ϕ.is_injective)
(h : S ⊨ ϕ.on_sentence '' T) : S[[ϕ]] ⊨ T :=
λf hf, reduct_ssatisfied hϕ $ h $ mem_image_of_mem _ hf
lemma reduct_nonempty_of_nonempty {S : Structure L'} (H : nonempty S) : nonempty (reduct ϕ S) :=
by {apply nonempty.map, repeat{assumption}, exact reduct_id}
variable (ϕ)
@[reducible]def Theory_induced (T : Theory L) : Theory L' := ϕ.on_sentence '' T
variable {ϕ}
lemma is_consistent_Theory_induced (hϕ : ϕ.is_injective) {T : Theory L} (hT : is_consistent T) :
is_consistent (ϕ.Theory_induced T) :=
λH, hT $ H.map $ λh, reflect_sprf hϕ (by apply h)
/- we could generalize this, replacing set.univ by any set s, but then we cannot use set.image
anymore (since the domain of g would be s), and things would be more annoying -/
lemma is_consistent_extend {T : Theory L} (hT : is_consistent T) (hϕ : ϕ.is_injective)
(h : bounded_formula L 1 → bounded_formula L 1)
(hT' : ∀(f : bounded_formula L 1), T ⊢ ∃' (h f))
(g : bounded_formula L 1 → L'.constants) (hg : injective g)
(hg' : ∀x, g x ∉ range (@on_function L L' ϕ 0)) :
is_consistent (ϕ.Theory_induced T ∪
(λf, (ϕ.on_bounded_formula (h f))[bd_const (g f)/0]) '' set.univ) :=
begin
haveI : decidable_eq (bounded_formula L 1) := λx y, classical.prop_decidable _,
haveI : decidable_eq (sentence L') := λx y, classical.prop_decidable _,
have lem : ∀(s₀ : finset (bounded_formula L 1)),
is_consistent (ϕ.Theory_induced T ∪
(λf, (ϕ.on_bounded_formula (h f))[bd_const (g f)/0]) '' ↑s₀),
{ refine finset.induction _ _,
{ simp, exact is_consistent_Theory_induced hϕ hT },
{ intros ψ s hψ ih hs, refine sprovable.elim _ hs, clear hs, intro hs, apply ih, constructor,
simp [image_insert_eq] at hs,
have : _ ⊢ (ϕ.on_bounded_formula $ ∼(h ψ))[bd_const (g ψ)/0] := simpI hs,
have := sgeneralize_constant (g ψ) _ _ this,
{ refine simpE _ _ this, apply sweakening (subset_union_left _ _) (ϕ.on_sprf $ hT' ψ) },
{ intro h', rcases h' with ⟨s', ⟨ψ', ⟨ψ', ⟨ψ', hψ₂, rfl⟩ | ⟨ψ', hψ₂, rfl⟩, rfl⟩, rfl⟩, hψ₃⟩,
{ rw [ϕ.on_sentence_fst] at hψ₃,
exact ϕ.not_mem_function_in_formula_on_formula (hg' _) _ hψ₃ },
{ simp at hψ₃,
cases symbols_in_formula_subst _ _ _ hψ₃ with hψ₄ hψ₄,
{ exact ϕ.not_mem_function_in_formula_on_formula (hg' _) _ hψ₄ },
{ injection eq_of_mem_singleton hψ₄ with hψ₅, injection hψ₅ with x hψ₆,
cases hg (eq_of_heq hψ₆), exact hψ hψ₂ }}},
{ rw [on_bounded_formula_fst], apply not_mem_function_in_formula_on_formula, apply hg' }}},
intro H, rcases theory_proof_compactness H with ⟨T₀, h₀, hT⟩,
have : decidable_pred (∈ ϕ.Theory_induced T) := λx, classical.prop_decidable _,
rcases finset.subset_union_elim hT with ⟨t₀, s₀, rfl, ht₀, hs₀⟩,
have hs₀' := subset.trans hs₀ (diff_subset _ _),
rcases finset.subset_image_iff.mp hs₀' with ⟨s₀, hs₀x, rfl⟩,
apply lem s₀, refine h₀.map _, apply sweakening,
simp, refine subset.trans ht₀ _, simp
end
end Lhom
end fol
-- instance nonempty_Language_over : nonempty (Language_over) :=
-- begin fapply nonempty.intro, exact ⟨L, language_id_morphism L⟩ end
--TODO define map induced by a language_morphism on terms/preterms, formulas/preformulas, sets of formulas/theories
|
Formal statement is: lemma (in topological_space) at_within_union: "at x within (S \<union> T) = sup (at x within S) (at x within T)" Informal statement is: The filter of neighbourhoods of $x$ in $S \cup T$ is the supremum of the filters of neighbourhoods of $x$ in $S$ and $T$. |
State Before: α : Type u_1
l : List α
⊢ length (tail l) = length l - 1 State After: no goals Tactic: cases l <;> rfl |
open import Relation.Unary using ( ∅ ; _∪_ )
open import Web.Semantic.DL.Concept using ( Concept )
open import Web.Semantic.DL.Role using ( Role )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.Util using ( Subset ; ⁅_⁆ )
module Web.Semantic.DL.TBox where
infixl 5 _⊑₁_ _⊑₂_
infixr 4 _,_
data TBox (Σ : Signature) : Set where
ε : TBox Σ
_,_ : (T U : TBox Σ) → TBox Σ
_⊑₁_ : (C D : Concept Σ) → TBox Σ
_⊑₂_ : (Q R : Role Σ) → TBox Σ
Ref : (R : Role Σ) → TBox Σ
Irr : (R : Role Σ) → TBox Σ
Tra : (R : Role Σ) → TBox Σ
Dis : (Q R : Role Σ) → TBox Σ
Axioms : ∀ {Σ} → TBox Σ → Subset (TBox Σ)
Axioms ε = ∅
Axioms (T , U) = (Axioms T) ∪ (Axioms U)
Axioms (C ⊑₁ D) = ⁅ C ⊑₁ D ⁆
Axioms (Q ⊑₂ R) = ⁅ Q ⊑₂ R ⁆
Axioms (Ref R) = ⁅ Ref R ⁆
Axioms (Irr R) = ⁅ Irr R ⁆
Axioms (Tra R) = ⁅ Tra R ⁆
Axioms (Dis Q R) = ⁅ Dis Q R ⁆
|
-- 2011-11-24 Andreas, James
{-# OPTIONS --copatterns #-}
module CopatternWithoutFieldName where
record R : Set2 where
field
f : Set1
open R
test : (f : R -> Set1) -> R
test f = bla where
bla : R
f bla = Set
-- not a copattern, since f not a field name
|
[STATEMENT]
lemma borel_singleton[measurable]:
"A \<in> sets borel \<Longrightarrow> insert x A \<in> sets (borel :: 'a::t1_space measure)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. A \<in> sets borel \<Longrightarrow> insert x A \<in> sets borel
[PROOF STEP]
unfolding insert_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. A \<in> sets borel \<Longrightarrow> {xa. xa = x} \<union> A \<in> sets borel
[PROOF STEP]
by (rule sets.Un) auto |
/-
Copyright (c) 2021 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies, Scott Morrison
-/
import data.finset.lattice
import data.multiset.functor
/-!
# Functoriality of `finset`
This file defines the functor structure of `finset`.
## TODO
Currently, all instances are classical because the functor classes want to run over all types. If
instead we could state that a functor is lawful/applicative/traversable... between two given types,
then we could provide the instances for types with decidable equality.
-/
universes u
open function
namespace finset
/-! ### Functor -/
section functor
variables {α β : Type u} [Π P, decidable P]
/-- Because `finset.image` requires a `decidable_eq` instance for the target type, we can only
construct `functor finset` when working classically. -/
instance : functor finset :=
{ map := λ α β f s, s.image f }
instance : is_lawful_functor finset :=
{ id_map := λ α s, image_id,
comp_map := λ α β γ f g s, image_image.symm }
@[simp] lemma fmap_def {s : finset α} (f : α → β) : f <$> s = s.image f := rfl
end functor
/-! ### Pure -/
instance : has_pure finset := ⟨λ α x, {x}⟩
@[simp] lemma pure_def {α} : (pure : α → finset α) = singleton := rfl
/-! ### Applicative functor -/
section applicative
variables {α β : Type u} [Π P, decidable P]
instance : applicative finset :=
{ seq := λ α β t s, t.sup (λ f, s.image f),
seq_left := λ α β s t, if t = ∅ then ∅ else s,
seq_right := λ α β s t, if s = ∅ then ∅ else t,
.. finset.functor,
.. finset.has_pure }
@[simp]
instance : is_lawful_applicative finset :=
{ seq_left_eq := λ α β s t, begin
rw [seq_def, fmap_def, seq_left_def],
obtain rfl | ht := t.eq_empty_or_nonempty,
{ simp_rw [if_pos rfl, image_empty], exact (sup_bot _).symm },
{ ext a,
rw [if_neg ht.ne_empty, mem_sup],
refine ⟨λ ha, ⟨const β a, mem_image_of_mem _ ha, mem_image_const_self.2 ht⟩, _⟩,
rintro ⟨f, hf, ha⟩,
rw mem_image at hf ha,
obtain ⟨b, hb, rfl⟩ := hf,
obtain ⟨_, _, rfl⟩ := ha,
exact hb }
end,
seq_right_eq := λ α β s t, begin
rw [seq_def, fmap_def, seq_right_def],
obtain rfl | hs := s.eq_empty_or_nonempty,
{ rw [if_pos rfl, image_empty, sup_empty, bot_eq_empty] },
{ ext a,
rw [if_neg hs.ne_empty, mem_sup],
refine ⟨λ ha, ⟨id, mem_image_const_self.2 hs, by rwa image_id⟩, _⟩,
rintro ⟨f, hf, ha⟩,
rw mem_image at hf ha,
obtain ⟨b, hb, rfl⟩ := ha,
obtain ⟨_, _, rfl⟩ := hf,
exact hb }
end,
pure_seq_eq_map := λ α β f s, sup_singleton,
map_pure := λ α β f a, image_singleton _ _,
seq_pure := λ α β s a, sup_singleton'' _ _,
seq_assoc := λ α β γ s t u, begin
ext a,
simp_rw [seq_def, fmap_def],
simp only [exists_prop, mem_sup, mem_image],
split,
{ rintro ⟨g, hg, b, ⟨f, hf, a, ha, rfl⟩, rfl⟩,
exact ⟨g ∘ f, ⟨comp g, ⟨g, hg, rfl⟩, f, hf, rfl⟩, a, ha, rfl⟩ },
{ rintro ⟨c, ⟨_, ⟨g, hg, rfl⟩, f, hf, rfl⟩, a, ha, rfl⟩,
exact ⟨g, hg, f a, ⟨f, hf, a, ha, rfl⟩, rfl⟩ }
end,
.. finset.is_lawful_functor }
instance : is_comm_applicative finset :=
{ commutative_prod := λ α β s t, begin
simp_rw [seq_def, fmap_def, sup_image, sup_eq_bUnion],
change s.bUnion (λ a, t.image $ λ b, (a, b)) = t.bUnion (λ b, s.image $ λ a, (a, b)),
transitivity s.product t;
[rw product_eq_bUnion, rw product_eq_bUnion_right]; congr; ext; simp_rw mem_image,
end,
.. finset.is_lawful_applicative }
end applicative
/-! ### Monad -/
section monad
variables [Π P, decidable P]
instance : monad finset :=
{ bind := λ α β, @sup _ _ _ _,
.. finset.applicative }
@[simp] lemma bind_def {α β} : (>>=) = @sup (finset α) β _ _ := rfl
instance : is_lawful_monad finset :=
{ bind_pure_comp_eq_map := λ α β f s, sup_singleton'' _ _,
bind_map_eq_seq := λ α β t s, rfl,
pure_bind := λ α β t s, sup_singleton,
bind_assoc := λ α β γ s f g, by { convert sup_bUnion _ _, exact sup_eq_bUnion _ _ },
.. finset.is_lawful_applicative }
end monad
/-! ### Alternative functor -/
section alternative
variables [Π P, decidable P]
instance : alternative finset :=
{ orelse := λ α, (∪),
failure := λ α, ∅,
.. finset.applicative }
end alternative
/-! ### Traversable functor -/
section traversable
variables {α β γ : Type u} {F G : Type u → Type u} [applicative F] [applicative G]
[is_comm_applicative F] [is_comm_applicative G]
/-- Traverse function for `finset`. -/
def traverse [decidable_eq β] (f : α → F β) (s : finset α) : F (finset β) :=
multiset.to_finset <$> multiset.traverse f s.1
@[simp] lemma id_traverse [decidable_eq α] (s : finset α) : traverse id.mk s = s :=
by { rw [traverse, multiset.id_traverse], exact s.val_to_finset }
open_locale classical
@[simp] lemma map_comp_coe (h : α → β) :
functor.map h ∘ multiset.to_finset = multiset.to_finset ∘ functor.map h :=
funext $ λ s, image_to_finset
lemma map_traverse (g : α → G β) (h : β → γ) (s : finset α) :
functor.map h <$> traverse g s = traverse (functor.map h ∘ g) s :=
begin
unfold traverse,
simp only [map_comp_coe] with functor_norm,
rw [is_lawful_functor.comp_map, multiset.map_traverse],
end
end traversable
end finset
|
Formal statement is: lemma norm_le_infnorm: fixes x :: "'a::euclidean_space" shows "norm x \<le> sqrt DIM('a) * infnorm x" Informal statement is: For any vector $x$ in $\mathbb{R}^n$, the Euclidean norm of $x$ is less than or equal to the square root of $n$ times the infinity norm of $x$. |
open import Formalization.PredicateLogic.Signature
module Formalization.PredicateLogic.Constructive.NaturalDeduction (𝔏 : Signature) where
open Signature(𝔏)
open import Data.ListSized
import Lvl
open import Formalization.PredicateLogic.Syntax(𝔏)
open import Formalization.PredicateLogic.Syntax.Substitution(𝔏)
open import Functional using (_∘_ ; _∘₂_ ; swap)
open import Numeral.Finite
open import Numeral.Natural
open import Relator.Equals.Proofs.Equiv
open import Sets.PredicateSet using (PredSet ; _∈_ ; _∉_ ; _∪_ ; _∪•_ ; _∖_ ; _⊆_ ; _⊇_ ; ∅ ; [≡]-to-[⊆] ; [≡]-to-[⊇]) renaming (•_ to · ; _≡_ to _≡ₛ_)
open import Type
private variable ℓ : Lvl.Level
private variable args vars : ℕ
private variable Γ : PredSet{ℓ}(Formula(vars))
data _⊢_ {ℓ} : PredSet{ℓ}(Formula(vars)) → Formula(vars) → Type{Lvl.𝐒(ℓₚ Lvl.⊔ ℓₒ Lvl.⊔ ℓ)} where
direct : (Γ ⊆ (Γ ⊢_))
[⊤]-intro : (Γ ⊢ ⊤)
[⊥]-elim : ∀{φ} → (Γ ⊢ ⊥) → (Γ ⊢ φ)
[∧]-intro : ∀{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ ψ) → (Γ ⊢ (φ ∧ ψ))
[∧]-elimₗ : ∀{φ ψ} → (Γ ⊢ (φ ∧ ψ)) → (Γ ⊢ φ)
[∧]-elimᵣ : ∀{φ ψ} → (Γ ⊢ (φ ∧ ψ)) → (Γ ⊢ ψ)
[∨]-introₗ : ∀{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ∨ ψ))
[∨]-introᵣ : ∀{φ ψ} → (Γ ⊢ ψ) → (Γ ⊢ (φ ∨ ψ))
[∨]-elim : ∀{φ ψ χ} → ((Γ ∪ · φ) ⊢ χ) → ((Γ ∪ · ψ) ⊢ χ) → (Γ ⊢ (φ ∨ ψ)) → (Γ ⊢ χ)
[⟶]-intro : ∀{φ ψ} → ((Γ ∪ · φ) ⊢ ψ) → (Γ ⊢ (φ ⟶ ψ))
[⟶]-elim : ∀{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ⟶ ψ)) → (Γ ⊢ ψ)
[Ɐ]-intro : ∀{φ} → (∀{t} → (Γ ⊢ (substitute0 t φ))) → (Γ ⊢ (Ɐ φ))
[Ɐ]-elim : ∀{φ} → (Γ ⊢ (Ɐ φ)) → ∀{t} → (Γ ⊢ (substitute0 t φ))
[∃]-intro : ∀{φ}{t} → (Γ ⊢ (substitute0 t φ)) → (Γ ⊢ (∃ φ))
[∃]-elim : ∀{φ ψ} → (∀{t} → (Γ ∪ ·(substitute0 t φ)) ⊢ ψ) → (Γ ⊢ (∃ φ)) → (Γ ⊢ ψ)
|
State Before: R : Type u
S : Type ?u.88744
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
⊢ support (toSubring p T hp) = support p State After: case a
R : Type u
S : Type ?u.88744
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
i : ℕ
⊢ i ∈ support (toSubring p T hp) ↔ i ∈ support p Tactic: ext i State Before: case a
R : Type u
S : Type ?u.88744
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
i : ℕ
⊢ i ∈ support (toSubring p T hp) ↔ i ∈ support p State After: case a
R : Type u
S : Type ?u.88744
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
i : ℕ
⊢ coeff (toSubring p T hp) i = 0 ↔ coeff p i = 0 Tactic: simp only [mem_support_iff, not_iff_not, Ne.def] State Before: case a
R : Type u
S : Type ?u.88744
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
i : ℕ
⊢ coeff (toSubring p T hp) i = 0 ↔ coeff p i = 0 State After: case a
R : Type u
S : Type ?u.88744
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
i : ℕ
⊢ coeff (toSubring p T hp) i = 0 ↔ ↑(coeff (toSubring p T hp) i) = 0 Tactic: conv_rhs => rw [← coeff_toSubring p T hp] State Before: case a
R : Type u
S : Type ?u.88744
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
i : ℕ
⊢ coeff (toSubring p T hp) i = 0 ↔ ↑(coeff (toSubring p T hp) i) = 0 State After: no goals Tactic: exact ⟨fun H => by rw [H, ZeroMemClass.coe_zero], fun H => Subtype.coe_injective H⟩ State Before: R : Type u
S : Type ?u.88744
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
i : ℕ
H : coeff (toSubring p T hp) i = 0
⊢ ↑(coeff (toSubring p T hp) i) = 0 State After: no goals Tactic: rw [H, ZeroMemClass.coe_zero] |
Justin Patrizio is a third year Philosophy student and an independent ASUCD ASUCD Senate Senator. Justin was an independent candidate for ASUCD ASUCD Senate Senate in the Fall 2008 ASUCD Election.
The following is an excerpt from his campaign website http://www.projectnosh.com/senate:
I have already begun working with organizations on campus to improve student life. When elected, I hope to continue working on the following projects already under way:
Increasing Accessibility to Financial Aid Information
I hope to implement a quarterly seminar series dedicated to educating students about financial aide options as well as budgeting and debt repayment. These seminars should also include information about private loans, savings/investment accounts, and credit. This program would be a combined effort between ASUCD and the UCD Financial Aid Office, and would consist of frequent (bimonthly, if not weekly) short, informational meetings held on campus in public areas. The goals would be to make financial aid and information about finances in general more available to students, hopefully making life easier for the students of UC Davis.
Going Green
Working with campus organizations like R4 recycling services, Project Compost, and the Environmental Planning and Protection Commission (EPPC) I will work to reduce the carbon footprint of individual ASUCD Units (like the coffee house, student store, bike barn, etc...) and the University as a whole. I hope to improve recycling and decrease waste campuswide, as well as work to bring Davis even further towards the forefront of sustainable living. Students, along with residents of Davis and the City Council, need to work together as a community to organize programs the reduce waste in order to increase sustainability. With the support of the community and the resources that exist within the University, I am confident that we as a community can become leaders in the fight for a better, greener future.
Increasing Campuswide Wireless Internet Coverage
Working with ASUCD Senator Joe Chatham, I will continue on the path that he and others have to a newer, more up to date and powerful campus wireless network. I hope to install new broadcast antennae regularly, and decrease the dead spots in places like lecture halls and the arboretum. There is some dissention among faculty members as to the potential impact of wireless Internet access in lecture halls like SciLec 123 and Chem 194, but I personally believe that all corners of our campus should be networked effectively. I plan to lobby against opponents to this proposition, and hope to garner support from campus units other than ASUCD, as well as from the student body, in order to convince the administration to move forward.
More generally, I hope to increase student involvement in campus projects and programs. The best way to do this is to increase accessibility and information, and discourage the uneven distribution of resources and political power that slates like L.E.A.D. and other past organizations have depended on. I believe all students deserve the same opportunity to get involved, and the same rules regarding resources should apply to everyone, not just those running independent. L.E.A.D. has an infrastructure set up that consistently grows year after year and this gives each L.E.A.D. candidate a distinct edge over the competition. Slates are divisive and can encourage candidates to conform to the ideals of the slate in order to improve their chances of winning. I am opposed to the idea that conformation and subordination to a party or slate somehow entitles a candidate to greater resources
20081111 23:32:48 nbsp Him and Greg will do good work on the Senate. (Assuming, of course, that the independents win any seats) Users/JoseBleckman
|
{-# OPTIONS --cubical --no-import-sorts --safe --guardedness #-}
module Cubical.DStructures.Experiments where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Path
open import Cubical.Functions.FunExtEquiv
open import Cubical.Homotopy.Base
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Data.Maybe
open import Cubical.Relation.Binary
open import Cubical.Structures.Subtype
open import Cubical.Structures.LeftAction
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Semidirect
-- this file also serves as Everything.agda
open import Cubical.DStructures.Base
open import Cubical.DStructures.Meta.Properties
open import Cubical.DStructures.Meta.Isomorphism
open import Cubical.DStructures.Structures.Action
open import Cubical.DStructures.Structures.Category
open import Cubical.DStructures.Structures.Constant
open import Cubical.DStructures.Structures.Group
-- open import Cubical.DStructures.Structures.Higher
open import Cubical.DStructures.Structures.Nat
open import Cubical.DStructures.Structures.PeifferGraph
open import Cubical.DStructures.Structures.ReflGraph
open import Cubical.DStructures.Structures.SplitEpi
open import Cubical.DStructures.Structures.Strict2Group
open import Cubical.DStructures.Structures.Type
-- open import Cubical.DStructures.Structures.Universe
open import Cubical.DStructures.Structures.VertComp
open import Cubical.DStructures.Structures.XModule
open import Cubical.DStructures.Equivalences.GroupSplitEpiAction
open import Cubical.DStructures.Equivalences.PreXModReflGraph
open import Cubical.DStructures.Equivalences.XModPeifferGraph
open import Cubical.DStructures.Equivalences.PeifferGraphS2G
private
variable
ℓ ℓ' ℓ'' ℓ₁ ℓ₁' ℓ₁'' ℓ₂ ℓA ℓA' ℓ≅A ℓ≅A' ℓB ℓB' ℓ≅B ℓC ℓ≅C ℓ≅ᴰ ℓ≅ᴰ' ℓ≅B' : Level
open Kernel
open GroupHom -- such .fun!
open GroupLemmas
open MorphismLemmas
{-
record Hom-𝒮 {A : Type ℓA} {ℓ≅A : Level} (𝒮-A : URGStr A ℓ≅A)
{B : Type ℓB} {ℓ≅B : Level} (𝒮-B : URGStr B ℓ≅B)
: Type (ℓ-max (ℓ-max ℓA ℓB) (ℓ-max ℓ≅A ℓ≅B)) where
constructor hom-𝒮
open URGStr
field
fun : A → B
fun-≅ : {a a' : A} → (p : _≅_ 𝒮-A a a') → _≅_ 𝒮-B (fun a) (fun a')
fun-ρ : {a : A} → fun-≅ (ρ 𝒮-A a) ≡ ρ 𝒮-B (fun a)
∫𝒮ᴰ-π₁ : {A : Type ℓA} {𝒮-A : URGStr A ℓ≅A}
{B : A → Type ℓB} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B)
→ Hom-𝒮 (∫⟨ 𝒮-A ⟩ 𝒮ᴰ-B) 𝒮-A
Hom-𝒮.fun (∫𝒮ᴰ-π₁ 𝒮ᴰ-B) = fst
Hom-𝒮.fun-≅ (∫𝒮ᴰ-π₁ 𝒮ᴰ-B) = fst
Hom-𝒮.fun-ρ (∫𝒮ᴰ-π₁ 𝒮ᴰ-B) = refl
module _ {ℓ : Level} {A : Type ℓ} (𝒮-A : URGStr A ℓ) where
𝒮ᴰ-toHom : Iso (Σ[ B ∈ (A → Type ℓ) ] (URGStrᴰ 𝒮-A B ℓ)) (Σ[ B ∈ (Type ℓ) ] Σ[ 𝒮-B ∈ (URGStr B ℓ) ] (Hom-𝒮 𝒮-B 𝒮-A))
Iso.fun 𝒮ᴰ-toHom (B , 𝒮ᴰ-B) = (Σ[ a ∈ A ] B a) , {!!} , {!!}
Iso.inv 𝒮ᴰ-toHom (B , 𝒮ᴰ-B , F) = (λ a → Σ[ b ∈ B ] F .fun b ≡ a) , {!!}
where
open Hom-𝒮
Iso.leftInv 𝒮ᴰ-toHom (B , 𝒮ᴰ-B) = ΣPathP ((funExt (λ a → {!!})) , {!!})
Iso.rightInv 𝒮ᴰ-toHom (B , 𝒮ᴰ-B , F) = {!!}
-}
-- Older Experiments --
-- needs --guardedness flag
module _ where
record Hierarchy {A : Type ℓ} (𝒮-A : URGStr A ℓ) : Type (ℓ-suc ℓ) where
coinductive
field
B : A → Type ℓ
𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ
ℋ : Maybe (Hierarchy {A = Σ A B} (∫⟨ 𝒮-A ⟩ 𝒮ᴰ-B))
|
(* 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_75
imports "../../Test_Base"
begin
datatype 'a list = nil2 | cons2 "'a" "'a list"
datatype Nat = Z | S "Nat"
fun x :: "Nat => Nat => bool" where
"x (Z) (Z) = True"
| "x (Z) (S z2) = False"
| "x (S x2) (Z) = False"
| "x (S x2) (S y2) = x x2 y2"
fun count :: "Nat => Nat list => Nat" where
"count y (nil2) = Z"
| "count y (cons2 z2 ys) =
(if x y z2 then S (count y ys) else count y ys)"
fun t2 :: "Nat => Nat => Nat" where
"t2 (Z) z = z"
| "t2 (S z2) z = S (t2 z2 z)"
theorem property0 :
"((t2 (count n xs) (count n (cons2 m (nil2)))) =
(count n (cons2 m xs)))"
oops
end
|
[STATEMENT]
lemma weak_map_of_SomeI: "(k, x) \<in> set l \<Longrightarrow> \<exists>x. map_of l k = Some x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (k, x) \<in> set l \<Longrightarrow> \<exists>x. map_of l k = Some x
[PROOF STEP]
by (induct l) auto |
-- -------------------------------------------------------------- [ Lens.idr ]
-- Description : Idris port of Control.Lens
-- Copyright : (c) Huw Campbell
-- --------------------------------------------------------------------- [ EOH ]
module Control.Lens.Maths
import Control.Lens.Types
import Control.Lens.Setter
%default total
infixr 4 +~
public export
(+~) : Num a => Setter s t a a -> a -> s -> t
l +~ n = over l (+ n)
infixr 4 *~
public export
(*~) : Num a => Setter s t a a -> a -> s -> t
l *~ n = over l (* n)
infixr 4 -~
public export
(-~) : (Neg a, Num a) => Setter s t a a -> a -> s -> t
l -~ n = over l (\x => x - n)
infixr 4 //~
public export
(//~) : Fractional a => Setter s t a a -> a -> s -> t
l //~ n = over l (/ n)
-- --------------------------------------------------------------------- [ EOF ]
|
/-
Copyright (c) 2020 Adam Topaz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Adam Topaz
-/
import category_theory.monad.basic
import category_theory.monoidal.End
import category_theory.monoidal.Mon_
/-!
# The equivalence between `Monad C` and `Mon_ (C ⥤ C)`.
A monad "is just" a monoid in the category of endofunctors.
# Definitions/Theorems
1. `to_Mon` associates a monoid object in `C ⥤ C` to any monad on `C`.
2. `Monad_to_Mon` is the functorial version of `to_Mon`.
3. `of_Mon` associates a monad on `C` to any monoid object in `C ⥤ C`.
4. `Monad_Mon_equiv` is the equivalence between `Monad C` and `Mon_ (C ⥤ C)`.
-/
namespace category_theory
open category
universes v u -- morphism levels before object levels. See note [category_theory universes].
variables {C : Type u} [category.{v} C]
namespace Monad
local attribute [instance, reducible] endofunctor_monoidal_category
/-- To every `Monad C` we associated a monoid object in `C ⥤ C`.-/
@[simps]
def to_Mon : monad C → Mon_ (C ⥤ C) := λ M,
{ X := (M : C ⥤ C),
one := M.η,
mul := M.μ,
one_mul' := by { ext, simp }, -- `obviously` provides this, but slowly
mul_one' := by { ext, simp }, -- `obviously` provides this, but slowly
mul_assoc' := by { ext, dsimp, simp [M.assoc] } }
variable (C)
/-- Passing from `Monad C` to `Mon_ (C ⥤ C)` is functorial. -/
@[simps]
def Monad_to_Mon : monad C ⥤ Mon_ (C ⥤ C) :=
{ obj := to_Mon,
map := λ _ _ f, { hom := f.to_nat_trans },
map_id' := by { intros X, refl }, -- `obviously` provides this, but slowly
map_comp' := by { intros X Y Z f g, refl, } }
variable {C}
/-- To every monoid object in `C ⥤ C` we associate a `Monad C`. -/
@[simps]
def of_Mon : Mon_ (C ⥤ C) → monad C := λ M,
{ to_functor := M.X,
η' := M.one,
μ' := M.mul,
left_unit' := λ X, by { rw [←M.one.id_hcomp_app, ←nat_trans.comp_app, M.mul_one], refl },
right_unit' := λ X, by { rw [←M.one.hcomp_id_app, ←nat_trans.comp_app, M.one_mul], refl },
assoc' := λ X, by { rw [←nat_trans.hcomp_id_app, ←nat_trans.comp_app], simp } }
variable (C)
/-- Passing from `Mon_ (C ⥤ C)` to `Monad C` is functorial. -/
@[simps]
def Mon_to_Monad : Mon_ (C ⥤ C) ⥤ monad C :=
{ obj := of_Mon,
map := λ _ _ f,
{ app_η' := begin
intro X,
erw [←nat_trans.comp_app, f.one_hom],
refl,
end,
app_μ' := begin
intro X,
erw [←nat_trans.comp_app, f.mul_hom], -- `finish` closes this goal
simpa only [nat_trans.naturality, nat_trans.hcomp_app, assoc, nat_trans.comp_app, of_Mon_μ],
end,
..f.hom } }
namespace Monad_Mon_equiv
variable {C}
/-- Isomorphism of functors used in `Monad_Mon_equiv` -/
@[simps {rhs_md := semireducible}]
def counit_iso : Mon_to_Monad C ⋙ Monad_to_Mon C ≅ 𝟭 _ :=
{ hom := { app := λ _, { hom := 𝟙 _ } },
inv := { app := λ _, { hom := 𝟙 _ } },
hom_inv_id' := by { ext, simp }, -- `obviously` provides these, but slowly
inv_hom_id' := by { ext, simp } }
/-- Auxiliary definition for `Monad_Mon_equiv` -/
@[simps]
def unit_iso_hom : 𝟭 _ ⟶ Monad_to_Mon C ⋙ Mon_to_Monad C :=
{ app := λ _, { app := λ _, 𝟙 _ } }
/-- Auxiliary definition for `Monad_Mon_equiv` -/
@[simps]
def unit_iso_inv : Monad_to_Mon C ⋙ Mon_to_Monad C ⟶ 𝟭 _ :=
{ app := λ _, { app := λ _, 𝟙 _ } }
/-- Isomorphism of functors used in `Monad_Mon_equiv` -/
@[simps]
def unit_iso : 𝟭 _ ≅ Monad_to_Mon C ⋙ Mon_to_Monad C :=
{ hom := unit_iso_hom,
inv := unit_iso_inv,
hom_inv_id' := by { ext, simp }, -- `obviously` provides these, but slowly
inv_hom_id' := by { ext, simp } }
end Monad_Mon_equiv
open Monad_Mon_equiv
/-- Oh, monads are just monoids in the category of endofunctors (equivalence of categories). -/
@[simps]
def Monad_Mon_equiv : (monad C) ≌ (Mon_ (C ⥤ C)) :=
{ functor := Monad_to_Mon _,
inverse := Mon_to_Monad _,
unit_iso := unit_iso,
counit_iso := counit_iso,
functor_unit_iso_comp' := by { intros X, ext, dsimp, simp } } -- `obviously`, slowly
-- Sanity check
example (A : monad C) {X : C} : ((Monad_Mon_equiv C).unit_iso.app A).hom.app X = 𝟙 _ := rfl
end Monad
end category_theory
|
(* Title: HOL/Auth/n_german_lemma_inv__16_on_rules.thy
Author: Yongjian Li and Kaiqiang Duan, State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences
Copyright 2016 State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences
*)
header{*The n_german Protocol Case Study*}
theory n_german_lemma_inv__16_on_rules imports n_german_lemma_on_inv__16
begin
section{*All lemmas on causal relation between inv__16*}
lemma lemma_inv__16_on_rules:
assumes b1: "r \<in> rules N" and b2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__16 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
proof -
have c1: "(\<exists> j. j\<le>N\<and>r=n_SendReqS j)\<or>
(\<exists> i. i\<le>N\<and>r=n_SendReqEI i)\<or>
(\<exists> i. i\<le>N\<and>r=n_SendReqES i)\<or>
(\<exists> i. i\<le>N\<and>r=n_RecvReq N i)\<or>
(\<exists> i. i\<le>N\<and>r=n_SendInvE i)\<or>
(\<exists> i. i\<le>N\<and>r=n_SendInvS i)\<or>
(\<exists> i. i\<le>N\<and>r=n_SendInvAck i)\<or>
(\<exists> i. i\<le>N\<and>r=n_RecvInvAck i)\<or>
(\<exists> i. i\<le>N\<and>r=n_SendGntS i)\<or>
(\<exists> i. i\<le>N\<and>r=n_SendGntE N i)\<or>
(\<exists> i. i\<le>N\<and>r=n_RecvGntS i)\<or>
(\<exists> i. i\<le>N\<and>r=n_RecvGntE i)\<or>
(\<exists> i d. i\<le>N\<and>d\<le>N\<and>r=n_Store i d)"
apply (cut_tac b1, auto) done
moreover {
assume d1: "(\<exists> j. j\<le>N\<and>r=n_SendReqS j)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendReqSVsinv__16) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendReqEI i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendReqEIVsinv__16) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendReqES i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendReqESVsinv__16) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_RecvReq N i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_RecvReqVsinv__16) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendInvE i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendInvEVsinv__16) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendInvS i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendInvSVsinv__16) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendInvAck i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendInvAckVsinv__16) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_RecvInvAck i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_RecvInvAckVsinv__16) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendGntS i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendGntSVsinv__16) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendGntE N i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendGntEVsinv__16) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_RecvGntS i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_RecvGntSVsinv__16) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_RecvGntE i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_RecvGntEVsinv__16) done
}
moreover {
assume d1: "(\<exists> i d. i\<le>N\<and>d\<le>N\<and>r=n_Store i d)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_StoreVsinv__16) done
}
ultimately show "invHoldForRule s f r (invariants N)"
by satx
qed
end
|
-- Andreas, 2015-07-18
-- Postpone checking of record expressions when type is blocked.
-- Guess type of record expressions when type is blocked.
open import Common.Product
open import Common.Prelude
open import Common.Equality
T : Bool → Set
T true = Bool × Nat
T false = ⊥
works : (P : ∀{b} → b ≡ true → T b → Set) → Set
works P = P refl record{ proj₁ = true; proj₂ = 0 }
-- Guess or postpone.
test : (P : ∀{b} → T b → b ≡ true → Set) → Set
test P = P record{ proj₁ = true; proj₂ = 0 } refl
guess : (P : ∀{b} → T b → Set) → Set
guess P = P record{ proj₁ = true; proj₂ = 0 }
record R : Set where
field
f : Bool
record S : Set where
field
f : Bool
U : Bool → Set
U true = R
U false = S
postpone : (P : ∀{b} → U b → b ≡ true → Set) → Set
postpone P = P record{ f = false } refl
-- ambiguous : (P : ∀{b} → U b → Set) → Set
-- ambiguous P = P record{ f = false }
|
[STATEMENT]
lemma Key_neq_HPair: "Key K \<noteq> Hash[X] Y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Key K \<noteq> Hash[X] Y
[PROOF STEP]
unfolding HPair_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Key K \<noteq> \<lbrace>Hash \<lbrace>X, Y\<rbrace>, Y\<rbrace>
[PROOF STEP]
by simp |
Formal statement is: lemma irreducibleI': assumes "a \<noteq> 0" "\<not>is_unit a" "\<And>b. b dvd a \<Longrightarrow> a dvd b \<or> is_unit b" shows "irreducible a" Informal statement is: If $a$ is not a unit and if every divisor of $a$ is either a unit or a multiple of $a$, then $a$ is irreducible. |
State Before: F : Type ?u.23494
α : Type u_3
β : Type u_2
γ : Type u_1
inst✝³ : LinearOrderedField α
inst✝² : ConditionallyCompleteLinearOrderedField β
inst✝¹ : ConditionallyCompleteLinearOrderedField γ
inst✝ : Archimedean α
a✝ : α
b : β
q✝ : ℚ
a : α
q : ℚ
⊢ ↑q < inducedMap β γ (inducedMap α β a) ↔ ↑q < inducedMap α γ a State After: no goals Tactic: rw [coe_lt_inducedMap_iff, coe_lt_inducedMap_iff, Iff.comm, coe_lt_inducedMap_iff] |
-- The error on Agda 2.5.3 was:
-- An internal error has occurred. Please report this as a bug.
-- Location of the error: src/full/Agda/TypeChecking/Substitute/Class.hs:209
open import Agda.Primitive using (_⊔_ ; Level ; lsuc)
record Unit {U : Level} : Set U where
-- error still occurs with no constructors or fields in these types
constructor unit
record _×_ {U V : Level} (A : Set U) (B : Set V) : Set (U ⊔ V) where
constructor _,,_
field
x : A
y : B
infixr 25 _×_
data _⇔_ {U V : Level} : (A : Set U) → (B : Set V) → Set (U ⊔ V) where
unitIL : {A : Set U} → A ⇔ A × Unit
|
%\begin{abstract}
%Neutron stars are the best.
%\end{abstract}
%When neutron stars (NS) accrete gas from low-mass binary companions, explosive nuclear burning reactions in the NS envelope fuse hydrogen and helium into heavier elements. The resulting thermonuclear (type-I) X-ray bursts produce energy spectra that are fit well with black bodies, but a significant number of burst observations show deviations from Planck spectra.
%
%Neutron star (NS) masses and radii can be estimated from observations of photospheric radius- expansion X-ray bursts, provided the chemical composition of the photosphere, the spectral colour-correction factors in the observed luminosity range, and the emission area during the bursts are known.
%
%The cooling phase of thermonuclear (type-I) X-ray bursts can be used to constrain neutron star (NS) compactness by comparing the observed cooling tracks of bursts to accurate theoretical atmosphere model calculations.
%--------------------------------------------------
%intro-intro
%First, a short history of neutron stars is presented, focusing on both theoretical and observational results.
%After this, an introduction to the basic physics of stars is given.
%intro-eos
%Next, the physics of neutron star interiors is discussed in more detail.
%The discussion first focuses on the uppermost layers of the star called an atmosphere.
%This thin layer of plasma is responsible of shaping the emergent radiation.
%Below the atmosphere is a solid layer called the crust.
%In order to understand the physics of the crust, an introduction to the degenerate matter is presented.
%The matter in the crust can then be described by the degenerate electron gas model.
%The crust is, however, only couple of kilometers thick and a bulk of the star consists of a liquid core.
%The EoS of the matter in the core is largely unknown and because of this, we present a way to parameterize the nuclear physics using a so-called polytropic model.
%intro-astro
%The introduction is continued by describing the colorful astrophysics of neutron stars.
%We mainly focus on presenting the basics of accretion, an astrophysical process where matter is transferred into a compact object such as a neutron star.
%intro-constraints
%Lastly, we show how the neutron star size can be inferred from the X-ray burst observations.
\vspace{2.0cm}
\chapter*{Abstract}
%background
Neutron stars are one of the most dense objects in the Universe.
However, the exact description of the equation of state (EoS) of the cold ultra-dense matter inside them is still a mystery.
In this thesis, we measure the size of some neutron stars using astrophysical observations of X-ray bursts that are produced by thermonuclear runaways in the uppermost layers of the star.
By measuring the size, we can then set constraints on the nuclear physics of the interiors and ultimately on the EoS of the cold dense matter.
The size measurements are done by comparing the cooling of the neutron star surfaces after the bursts to theoretical atmosphere model calculations.
Hence, accurate modeling of the emergent radiation from the atmospheres is needed.
In the first part of this thesis, I have studied how the emergent spectra differ if the atmosphere is enriched with nuclear burning ashes from the bursts.
This gives us new tools to understand and interpret the X-ray burst observations.
In addition, I have shown how the emerging radiation is modified when it originates from rapidly rotating oblate neutron stars.
Furthermore, we must also be careful in selecting only those bursts that are not influenced by the infalling material.
In the second part of the thesis, I have focused on studying the astrophysical environments of the X-ray bursts in order to quantify the effect of accretion on the mass and radius measurements.
Importantly, it is shown that only the bursts that occur during the low-accretion-rate (hard) state can be used for the size determination because otherwise the accretion flow might influence the cooling of the stellar surface.
After taking these steps into account, it is possible to set constraints on the mass, radius, distance, and atmosphere composition of neutron stars exhibiting X-ray bursts.
In the third part of the thesis, I have used the aforementioned models and methods to constrain the mass and radius of neutron stars using the hard state X-ray bursts.
The method has been applied to three neutrons stars in low-mass X-ray binary systems 4U 1702$-$429, 4U 1724$-$307, and SAX J1810.8$-$260 for which the radius is measured to be between $10.9 - 12.4\km$ ($68$\% credibility).
The newly computed atmosphere models have also been used to detect a presence of burning ashes in the atmosphere of the neutron star in HETE J1900.1$-$2455.
Later on, an improved Bayesian method of fitting the atmosphere models directly to the observed spectra has also improved the radius constraints of 4U 1702$-$429 to $R = 12.4 \pm 0.4\km$ ($68\%$ credibility).
These results are in a good agreement with the current nuclear physical predictions and demonstrate how astrophysical measurements can be used to gauge the unknown nuclear physics of neutron stars.
%method results
%conclusions
|
array A = [3] U32
constant a = 0
enum E { X, Y, Z }
type T
struct S { x: U32 }
port P
passive component C {
type T
array A = [3] U32
constant a = 0
enum E { X, Y, Z }
struct S { x: U32 }
}
instance c: C base id 0x100
topology T {
}
|
State Before: α : Type u_1
ι : Type ?u.44160
γ : Type ?u.44163
A : Type ?u.44166
B : Type ?u.44169
C : Type ?u.44172
inst✝⁶ : AddCommMonoid A
inst✝⁵ : AddCommMonoid B
inst✝⁴ : AddCommMonoid C
t : ι → A → C
h0 : ∀ (i : ι), t i 0 = 0
h1 : ∀ (i : ι) (x y : A), t i (x + y) = t i x + t i y
s : Finset α
f✝ : α → ι →₀ A
i : ι
g : ι →₀ A
k : ι → A → γ → B
x : γ
β : Type ?u.47302
M : Type u_2
M' : Type ?u.47308
N : Type u_3
P : Type ?u.47314
G : Type ?u.47317
H : Type ?u.47320
R : Type ?u.47323
S : Type ?u.47326
inst✝³ : Zero M
inst✝² : Zero M'
inst✝¹ : CommMonoid N
inst✝ : DecidableEq α
f : α →₀ M
a : α
b : α → M → N
⊢ (prod f fun x v => if a = x then b x v else 1) = if a ∈ f.support then b a (↑f a) else 1 State After: α : Type u_1
ι : Type ?u.44160
γ : Type ?u.44163
A : Type ?u.44166
B : Type ?u.44169
C : Type ?u.44172
inst✝⁶ : AddCommMonoid A
inst✝⁵ : AddCommMonoid B
inst✝⁴ : AddCommMonoid C
t : ι → A → C
h0 : ∀ (i : ι), t i 0 = 0
h1 : ∀ (i : ι) (x y : A), t i (x + y) = t i x + t i y
s : Finset α
f✝ : α → ι →₀ A
i : ι
g : ι →₀ A
k : ι → A → γ → B
x : γ
β : Type ?u.47302
M : Type u_2
M' : Type ?u.47308
N : Type u_3
P : Type ?u.47314
G : Type ?u.47317
H : Type ?u.47320
R : Type ?u.47323
S : Type ?u.47326
inst✝³ : Zero M
inst✝² : Zero M'
inst✝¹ : CommMonoid N
inst✝ : DecidableEq α
f : α →₀ M
a : α
b : α → M → N
⊢ (∏ a_1 in f.support, if a = a_1 then b a_1 (↑f a_1) else 1) = if a ∈ f.support then b a (↑f a) else 1 Tactic: dsimp [Finsupp.prod] State Before: α : Type u_1
ι : Type ?u.44160
γ : Type ?u.44163
A : Type ?u.44166
B : Type ?u.44169
C : Type ?u.44172
inst✝⁶ : AddCommMonoid A
inst✝⁵ : AddCommMonoid B
inst✝⁴ : AddCommMonoid C
t : ι → A → C
h0 : ∀ (i : ι), t i 0 = 0
h1 : ∀ (i : ι) (x y : A), t i (x + y) = t i x + t i y
s : Finset α
f✝ : α → ι →₀ A
i : ι
g : ι →₀ A
k : ι → A → γ → B
x : γ
β : Type ?u.47302
M : Type u_2
M' : Type ?u.47308
N : Type u_3
P : Type ?u.47314
G : Type ?u.47317
H : Type ?u.47320
R : Type ?u.47323
S : Type ?u.47326
inst✝³ : Zero M
inst✝² : Zero M'
inst✝¹ : CommMonoid N
inst✝ : DecidableEq α
f : α →₀ M
a : α
b : α → M → N
⊢ (∏ a_1 in f.support, if a = a_1 then b a_1 (↑f a_1) else 1) = if a ∈ f.support then b a (↑f a) else 1 State After: no goals Tactic: rw [f.support.prod_ite_eq] |
Formal statement is: lemma (in t2_space) separation_t2: "x \<noteq> y \<longleftrightarrow> (\<exists>U V. open U \<and> open V \<and> x \<in> U \<and> y \<in> V \<and> U \<inter> V = {})" Informal statement is: In a $T_2$ space, two points are distinct if and only if there exist disjoint open sets containing them. |
Formal statement is: lemma bdd_below_closure: fixes A :: "real set" assumes "bdd_below A" shows "bdd_below (closure A)" Informal statement is: If $A$ is bounded below, then its closure is bounded below. |
Formal statement is: lemma components_eq: "\<lbrakk>c \<in> components s; c' \<in> components s\<rbrakk> \<Longrightarrow> (c = c' \<longleftrightarrow> c \<inter> c' \<noteq> {})" Informal statement is: Two components of a topological space are equal if and only if they intersect. |
(* 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_53
imports "../../Test_Base"
begin
datatype 'a list = nil2 | cons2 "'a" "'a list"
datatype Nat = Z | S "Nat"
fun x :: "Nat => Nat => bool" where
"x (Z) (Z) = True"
| "x (Z) (S z2) = False"
| "x (S x2) (Z) = False"
| "x (S x2) (S y2) = x x2 y2"
fun count :: "Nat => Nat list => Nat" where
"count y (nil2) = Z"
| "count y (cons2 z2 ys) =
(if x y z2 then S (count y ys) else count y ys)"
fun t2 :: "Nat => Nat => bool" where
"t2 (Z) z = True"
| "t2 (S z2) (Z) = False"
| "t2 (S z2) (S x2) = t2 z2 x2"
fun insort :: "Nat => Nat list => Nat list" where
"insort y (nil2) = cons2 y (nil2)"
| "insort y (cons2 z2 xs) =
(if t2 y z2 then cons2 y (cons2 z2 xs) else cons2 z2 (insort y xs))"
fun sort :: "Nat list => Nat list" where
"sort (nil2) = nil2"
| "sort (cons2 z xs) = insort z (sort xs)"
theorem property0 :
"((count n xs) = (count n (sort xs)))"
oops
end
|
-- @@stderr --
dtrace: failed to compile script test/unittest/lexer/err.D_STR_NL.string.d: [D_STR_NL] line 20: newline encountered in string literal
|
proposition derivative_is_holomorphic: assumes "open S" and fder: "\<And>z. z \<in> S \<Longrightarrow> (f has_field_derivative f' z) (at z)" shows "f' holomorphic_on S" |
//
// $Id$
//
//
// Darren Kessner <[email protected]>
//
// Copyright 2009 Spielberg Family Center for Applied Proteomics
// Cedars Sinai Medical Center, Los Angeles, California 90048
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "Calibrator.hpp"
#include "ErrorEstimator.hpp"
#include "MassSpread.hpp"
#include "pwiz/utility/chemistry/Ion.hpp"
#include <cmath>
#include <iterator>
#include <stdexcept>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/lu.hpp>
#include <boost/numeric/ublas/triangular.hpp>
#include <boost/numeric/ublas/vector_proxy.hpp>
namespace ublas = boost::numeric::ublas;
using namespace std;
using pwiz::data::CalibrationParameters;
namespace pwiz {
namespace calibration {
class CalibratorImpl : public Calibrator
{
public:
CalibratorImpl(const MassDatabase& massDatabase,
const vector<Measurement>& measurements,
const CalibrationParameters& initialParameters,
double initialErrorEstimate,
int errorEstimatorIterationCount,
const string& outputDirectory);
virtual void iterate();
virtual int iterationCount() const {return iterationCount_;}
virtual const pwiz::data::CalibrationParameters& parameters() const {return parameters_;}
virtual int measurementCount() const;
virtual const Measurement* measurement(int index) const;
virtual const MassSpread* massSpread(int index) const;
virtual double error() const {return error_;}
private:
const MassDatabase& massDatabase_;
const vector<Measurement>& measurements_;
pwiz::data::CalibrationParameters parameters_;
double error_;
auto_ptr<ErrorEstimator> errorEstimator_;
int iterationCount_;
const int errorEstimatorIterationCount_;
const string outputDirectory_;
mutable ofstream log_;
void recalculateParameters();
void calculateSums(double& sum_z2_f2,
double& sum_z2_f3,
double& sum_z2_f4,
double& sum_z_f,
double& sum_z_f2);
void calculateParametersFromSums(double sum_z2_f2,
double sum_z2_f3,
double sum_z2_f4,
double sum_z_f,
double sum_z_f2);
void updateLog() const;
};
auto_ptr<Calibrator> Calibrator::create(const MassDatabase& massDatabase,
const vector<Measurement>& measurements,
const CalibrationParameters& initialParameters,
double initialErrorEstimate,
int errorEstimatorIterationCount,
const string& outputDirectory)
{
return auto_ptr<Calibrator>(new CalibratorImpl(massDatabase,
measurements,
initialParameters,
initialErrorEstimate,
errorEstimatorIterationCount,
outputDirectory));
}
CalibratorImpl::CalibratorImpl(const MassDatabase& massDatabase,
const vector<Measurement>& measurements,
const CalibrationParameters& initialParameters,
double initialErrorEstimate,
int errorEstimatorIterationCount,
const string& outputDirectory)
: massDatabase_(massDatabase),
measurements_(measurements),
parameters_(initialParameters),
error_(initialErrorEstimate),
iterationCount_(0),
errorEstimatorIterationCount_(errorEstimatorIterationCount),
outputDirectory_(outputDirectory)
{
if (!outputDirectory_.empty())
{
system(("mkdir " + outputDirectory_ + " 2> /dev/null").c_str());
ostringstream oss;
oss << outputDirectory << "/log";
log_.open(oss.str().c_str());
if (!log_) throw runtime_error(("[Calibrator] Unable to open log file " + oss.str()).c_str());
updateLog();
}
}
void CalibratorImpl::iterate()
{
using namespace proteome; // for Ion
iterationCount_++;
// convert frequencies to neutral masses, using current calibration parameters
vector<double> masses;
for (vector<Measurement>::const_iterator it=measurements_.begin(); it!=measurements_.end(); ++it)
{
double mz = parameters_.mz(it->frequency);
double neutralMass = Ion::neutralMass(mz, it->charge);
masses.push_back(neutralMass);
// cout<<it->frequency<<" "<<mz<<" "<<it->charge<<endl;
}
if (!outputDirectory_.empty())
{
ostringstream filename;
filename << outputDirectory_ << "/ee." << setw(4) << setfill('0') << iterationCount_ << ".txt";
errorEstimator_ = ErrorEstimator::create(massDatabase_, masses, error_, filename.str().c_str());
}
else
{
errorEstimator_ = ErrorEstimator::create(massDatabase_, masses, error_); // no logging
}
// ErrorEstimator calculates MassSpreads
for (int i=0; i<errorEstimatorIterationCount_; i++)
errorEstimator_->iterate();
// get new Parameter estimate
bool matrixError = false;
try{
recalculateParameters();
}
catch(range_error){
cerr<<"probably had a singular matrix - sucks to be you!"<<endl;
matrixError = true;
}
if(! matrixError){
error_ = errorEstimator_->error();
}
if (log_)
updateLog();
}
int CalibratorImpl::measurementCount() const
{
return (int)measurements_.size();
}
const Calibrator::Measurement* CalibratorImpl::measurement(int index) const
{
if (index >= measurementCount())
throw out_of_range("[Calibrator::measurement()] Index out of range.");
return &measurements_[index];
}
const MassSpread* CalibratorImpl::massSpread(int index) const
{
if (index >= measurementCount())
throw out_of_range("[Calibrator::massSpread()] Index out of range.");
return errorEstimator_.get() ? errorEstimator_->massSpread(index) : 0;
}
void CalibratorImpl::recalculateParameters()
{
double sum_z2_f2 = 0;
double sum_z2_f3 = 0;
double sum_z2_f4 = 0;
double sum_z_f = 0;
double sum_z_f2 = 0;
calculateSums(sum_z2_f2, sum_z2_f3, sum_z2_f4, sum_z_f, sum_z_f2);
cout<<sum_z2_f2<<" "<<sum_z2_f3<<" "<<sum_z2_f4<<" "<<sum_z_f<<" "<<sum_z_f2<<endl;
calculateParametersFromSums(sum_z2_f2, sum_z2_f3, sum_z2_f4, sum_z_f, sum_z_f2);
}
void CalibratorImpl::calculateSums(double& sum_z2_f2,
double& sum_z2_f3,
double& sum_z2_f4,
double& sum_z_f,
double& sum_z_f2)
{
using namespace proteome; // for Ion
if ((int)measurements_.size() != errorEstimator_->measurementCount())
throw runtime_error("[CalibratorImpl::calculateSums()] Inconsistent measurement counts!");
for (int i=0; i<errorEstimator_->measurementCount(); i++)
{
double f = measurements_[i].frequency;
int z = measurements_[i].charge;
cout<<"======================== "<<f<<" "<<z<<" ====================="<<endl;
//THE PROBLEM IS HERE!!! --BEGIN
// calculate ion MassSpread from the neutral MassSpread
auto_ptr<MassSpread> ionMassSpread = MassSpread::create();
const vector<MassSpread::Pair>& neutralDistribution = errorEstimator_->massSpread(i)->distribution();
for (vector<MassSpread::Pair>::const_iterator it=neutralDistribution.begin();
it!=neutralDistribution.end(); ++it)
{
MassSpread::Pair pair(Ion::ionMass(it->mass, z), it->probability);
ionMassSpread->distribution().push_back(pair);
}
ionMassSpread->recalculate();
double pa = ionMassSpread->sumProbabilityOverMass();
double pa2 = ionMassSpread->sumProbabilityOverMass2();
cout<<setprecision(10)<<"pa "<<pa<<" "<<pa2<<endl;
//THE PROBLEM IS HERE!!! --END
// TODO: uncommenting the following w/O2 gives different output! yuck!
//errorEstimator_->massSpread(i);
sum_z2_f2 += z*z*pa2/pow(f,2);
sum_z2_f3 += z*z*pa2/pow(f,3);
sum_z2_f4 += z*z*pa2/pow(f,4);
sum_z_f += z*pa/f;
sum_z_f2 += z*pa/pow(f,2);
cout << sum_z2_f2 << " " << sum_z2_f3 << " | " << sum_z_f << endl;
cout << sum_z2_f3 << " " << sum_z2_f4 << " | " << sum_z_f2 << endl;
}
}
void CalibratorImpl::calculateParametersFromSums(double sum_z2_f2,
double sum_z2_f3,
double sum_z2_f4,
double sum_z_f,
double sum_z_f2)
{
ublas::matrix<double> M(2,2);
ublas::vector<double> p(2);
M(0,0) = sum_z2_f2;
M(0,1) = M(1,0) = sum_z2_f3;
M(1,1) = sum_z2_f4;
p(0) = sum_z_f;
p(1) = sum_z_f2;
ublas::permutation_matrix<size_t> pm(2);
int singular = lu_factorize(M, pm);
if (singular)
throw range_error("[CalibratorImpl::calculateParametersFromSums()] Matrix is singular.");
// throw runtime_error("[CalibratorImpl::calculateParametersFromSums()] Matrix is singular.");
lu_substitute(M, pm, p);
cout<<"CALIBRATION PARAMS "<<parameters_.A<<" "<<parameters_.B<<endl;
parameters_.A = p[0];
parameters_.B = p[1];
cout<<"CALIBRATION PARAMS "<<parameters_.A<<" "<<parameters_.B<<endl;
}
namespace {
void reportMeasurement(ostream& os,
const Calibrator::Measurement& measurement,
const CalibrationParameters& parameters)
{
using namespace proteome; // for Ion
double mz = parameters.mz(measurement.frequency);
double mass = Ion::neutralMass(mz, measurement.charge);
os << measurement.frequency << " " << measurement.charge << " " << mz << " " << mass << endl;
}
}//namespace
void CalibratorImpl::updateLog() const
{
if (!log_)
{
cerr << "[CalibratorImpl::updateLog()] Warning: invalid log stream.\n";
return;
}
log_.precision(12);
log_ << "#\n";
log_ << "# iteration: " << iterationCount_ <<
" error: " << error_ <<
" A: " << parameters_.A <<
" B: " << parameters_.B << endl;
log_ << "#\n";
log_ << "# f z m/z m\n";
for (vector<Measurement>::const_iterator it=measurements_.begin(); it!=measurements_.end(); ++it)
reportMeasurement(log_, *it, parameters_);
log_ << "\n\n";
}
/* matops matrix implementation
void CalibratorImpl::calculateParametersFromSums(double sum_z2_f2,
double sum_z2_f3,
double sum_z2_f4,
double sum_z_f,
double sum_z_f2)
{
vector<vector<double> > M(2); // build matrix from sums (entries)
M[0] = vector<double>(2);
M[1] = vector<double>(2);
M[0][0] = sum_z2_f2;
M[0][1] = M[1][0] = sum_z2_f3;
M[1][1] = sum_z2_f4;
vector<double> v(2); // build vector
v[0] = sum_z_f;
v[1] = sum_z_f2;
vector<double> p = inverse(M)*v; // solution
parameters_.A = p[0];
parameters_.B = p[1];
}
*/
} // namespace calibration
} // namespace pwiz
|
[STATEMENT]
lemma ennreal_lt_0: "x < 0 \<Longrightarrow> ennreal x = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. x < 0 \<Longrightarrow> ennreal x = 0
[PROOF STEP]
by(simp add: ennreal_eq_0_iff) |
theory SestoftConf
imports Launchbury.Terms Launchbury.Substitution
begin
datatype stack_elem = Alts exp exp | Arg var | Upd var | Dummy var
instantiation stack_elem :: pt
begin
definition "\<pi> \<bullet> x = (case x of (Alts e1 e2) \<Rightarrow> Alts (\<pi> \<bullet> e1) (\<pi> \<bullet> e2) | (Arg v) \<Rightarrow> Arg (\<pi> \<bullet> v) | (Upd v) \<Rightarrow> Upd (\<pi> \<bullet> v) | (Dummy v) \<Rightarrow> Dummy (\<pi> \<bullet> v))"
instance
by standard (auto simp add: permute_stack_elem_def split:stack_elem.split)
end
lemma Alts_eqvt[eqvt]: "\<pi> \<bullet> (Alts e1 e2) = Alts (\<pi> \<bullet> e1) (\<pi> \<bullet> e2)"
and Arg_eqvt[eqvt]: "\<pi> \<bullet> (Arg v) = Arg (\<pi> \<bullet> v)"
and Upd_eqvt[eqvt]: "\<pi> \<bullet> (Upd v) = Upd (\<pi> \<bullet> v)"
and Dummy_eqvt[eqvt]: "\<pi> \<bullet> (Dummy v) = Dummy (\<pi> \<bullet> v)"
by (auto simp add: permute_stack_elem_def split:stack_elem.split)
lemma supp_Alts[simp]: "supp (Alts e1 e2) = supp e1 \<union> supp e2" unfolding supp_def by (auto simp add: Collect_imp_eq Collect_neg_eq)
lemma supp_Arg[simp]: "supp (Arg v) = supp v" unfolding supp_def by auto
lemma supp_Upd[simp]: "supp (Upd v) = supp v" unfolding supp_def by auto
lemma supp_Dummy[simp]: "supp (Dummy v) = supp v" unfolding supp_def by auto
lemma fresh_Alts[simp]: "a \<sharp> Alts e1 e2 = (a \<sharp> e1 \<and> a \<sharp> e2)" unfolding fresh_def by auto
lemma fresh_star_Alts[simp]: "a \<sharp>* Alts e1 e2 = (a \<sharp>* e1 \<and> a \<sharp>* e2)" unfolding fresh_star_def by auto
lemma fresh_Arg[simp]: "a \<sharp> Arg v = a \<sharp> v" unfolding fresh_def by auto
lemma fresh_Upd[simp]: "a \<sharp> Upd v = a \<sharp> v" unfolding fresh_def by auto
lemma fresh_Dummy[simp]: "a \<sharp> Dummy v = a \<sharp> v" unfolding fresh_def by auto
lemma fv_Alts[simp]: "fv (Alts e1 e2) = fv e1 \<union> fv e2" unfolding fv_def by auto
lemma fv_Arg[simp]: "fv (Arg v) = fv v" unfolding fv_def by auto
lemma fv_Upd[simp]: "fv (Upd v) = fv v" unfolding fv_def by auto
lemma fv_Dummy[simp]: "fv (Dummy v) = fv v" unfolding fv_def by auto
instance stack_elem :: fs
by standard (case_tac x, auto simp add: finite_supp)
type_synonym stack = "stack_elem list"
fun ap :: "stack \<Rightarrow> var set" where
"ap [] = {}"
| "ap (Alts e1 e2 # S) = ap S"
| "ap (Arg x # S) = insert x (ap S)"
| "ap (Upd x # S) = ap S"
| "ap (Dummy x # S) = ap S"
fun upds :: "stack \<Rightarrow> var set" where
"upds [] = {}"
| "upds (Alts e1 e2 # S) = upds S"
| "upds (Upd x # S) = insert x (upds S)"
| "upds (Arg x # S) = upds S"
| "upds (Dummy x # S) = upds S"
fun dummies :: "stack \<Rightarrow> var set" where
"dummies [] = {}"
| "dummies (Alts e1 e2 # S) = dummies S"
| "dummies (Upd x # S) = dummies S"
| "dummies (Arg x # S) = dummies S"
| "dummies (Dummy x # S) = insert x (dummies S)"
fun flattn :: "stack \<Rightarrow> var list" where
"flattn [] = []"
| "flattn (Alts e1 e2 # S) = fv_list e1 @ fv_list e2 @ flattn S"
| "flattn (Upd x # S) = x # flattn S"
| "flattn (Arg x # S) = x # flattn S"
| "flattn (Dummy x # S) = x # flattn S"
fun upds_list :: "stack \<Rightarrow> var list" where
"upds_list [] = []"
| "upds_list (Alts e1 e2 # S) = upds_list S"
| "upds_list (Upd x # S) = x # upds_list S"
| "upds_list (Arg x # S) = upds_list S"
| "upds_list (Dummy x # S) = upds_list S"
lemma set_upds_list[simp]:
"set (upds_list S) = upds S"
by (induction S rule: upds_list.induct) auto
lemma ups_fv_subset: "upds S \<subseteq> fv S"
by (induction S rule: upds.induct) auto
lemma fresh_distinct_ups: "atom ` V \<sharp>* S \<Longrightarrow> V \<inter> upds S = {}"
by (auto dest!: fresh_distinct_fv subsetD[OF ups_fv_subset])
lemma ap_fv_subset: "ap S \<subseteq> fv S"
by (induction S rule: upds.induct) auto
lemma dummies_fv_subset: "dummies S \<subseteq> fv S"
by (induction S rule: dummies.induct) auto
lemma fresh_flattn[simp]: "atom (a::var) \<sharp> flattn S \<longleftrightarrow> atom a \<sharp> S"
by (induction S rule:flattn.induct) (auto simp add: fresh_Nil fresh_Cons fresh_append fresh_fv[OF finite_fv])
lemma fresh_star_flattn[simp]: "atom ` (as:: var set) \<sharp>* flattn S \<longleftrightarrow> atom ` as \<sharp>* S"
by (auto simp add: fresh_star_def)
lemma fresh_upds_list[simp]: "atom a \<sharp> S \<Longrightarrow> atom (a::var) \<sharp> upds_list S"
by (induction S rule:upds_list.induct) (auto simp add: fresh_Nil fresh_Cons fresh_append fresh_fv[OF finite_fv])
lemma fresh_star_upds_list[simp]: "atom ` (as:: var set) \<sharp>* S \<Longrightarrow> atom ` (as:: var set) \<sharp>* upds_list S"
by (auto simp add: fresh_star_def)
lemma upds_append[simp]: "upds (S@S') = upds S \<union> upds S'"
by (induction S rule: upds.induct) auto
lemma upds_map_Dummy[simp]: "upds (map Dummy l) = {}"
by (induction l) auto
lemma upds_list_append[simp]: "upds_list (S@S') = upds_list S @ upds_list S'"
by (induction S rule: upds.induct) auto
lemma upds_list_map_Dummy[simp]: "upds_list (map Dummy l) = []"
by (induction l) auto
lemma dummies_append[simp]: "dummies (S@S') = dummies S \<union> dummies S'"
by (induction S rule: dummies.induct) auto
lemma dummies_map_Dummy[simp]: "dummies (map Dummy l) = set l"
by (induction l) auto
lemma map_Dummy_inj[simp]: "map Dummy l = map Dummy l' \<longleftrightarrow> l = l'"
apply (induction l arbitrary: l')
apply (case_tac [!] l')
apply auto
done
type_synonym conf = "(heap \<times> exp \<times> stack)"
inductive boring_step where
"isVal e \<Longrightarrow> boring_step (\<Gamma>, e, Upd x # S)"
fun restr_stack :: "var set \<Rightarrow> stack \<Rightarrow> stack"
where "restr_stack V [] = []"
| "restr_stack V (Alts e1 e2 # S) = Alts e1 e2 # restr_stack V S"
| "restr_stack V (Arg x # S) = Arg x # restr_stack V S"
| "restr_stack V (Upd x # S) = (if x \<in> V then Upd x # restr_stack V S else restr_stack V S)"
| "restr_stack V (Dummy x # S) = Dummy x # restr_stack V S"
lemma restr_stack_cong:
"(\<And> x. x \<in> upds S \<Longrightarrow> x \<in> V \<longleftrightarrow> x \<in> V') \<Longrightarrow> restr_stack V S = restr_stack V' S"
by (induction V S rule: restr_stack.induct) auto
lemma fresh_star_restict_stack[intro]:
"a \<sharp>* S \<Longrightarrow> a \<sharp>* restr_stack V S"
by (induction V S rule: restr_stack.induct) (auto simp add: fresh_star_Cons)
lemma restr_stack_restr_stack[simp]:
"restr_stack V (restr_stack V' S) = restr_stack (V \<inter> V') S"
by (induction V S rule: restr_stack.induct) auto
lemma Upd_eq_restr_stackD:
assumes "Upd x # S = restr_stack V S'"
shows "x \<in> V"
using arg_cong[where f = upds, OF assms]
by auto
lemma Upd_eq_restr_stackD2:
assumes "restr_stack V S' = Upd x # S"
shows "x \<in> V"
using arg_cong[where f = upds, OF assms]
by auto
lemma restr_stack_noop[simp]:
"restr_stack V S = S \<longleftrightarrow> upds S \<subseteq> V"
by (induction V S rule: restr_stack.induct)
(auto dest: Upd_eq_restr_stackD2)
subsubsection \<open>Invariants of the semantics\<close>
inductive invariant :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool"
where "(\<And> x y. rel x y \<Longrightarrow> I x \<Longrightarrow> I y) \<Longrightarrow> invariant rel I"
lemmas invariant.intros[case_names step]
lemma invariantE:
"invariant rel I \<Longrightarrow> rel x y \<Longrightarrow> I x \<Longrightarrow> I y" by (auto elim: invariant.cases)
lemma invariant_starE:
"rtranclp rel x y \<Longrightarrow> invariant rel I \<Longrightarrow> I x \<Longrightarrow> I y"
by (induction rule: rtranclp.induct) (auto elim: invariantE)
lemma invariant_True:
"invariant rel (\<lambda> _. True)"
by (auto intro: invariant.intros)
lemma invariant_conj:
"invariant rel I1 \<Longrightarrow> invariant rel I2 \<Longrightarrow> invariant rel (\<lambda> x. I1 x \<and> I2 x)"
by (auto simp add: invariant.simps)
lemma rtranclp_invariant_induct[consumes 3, case_names base step]:
assumes "r\<^sup>*\<^sup>* a b"
assumes "invariant r I"
assumes "I a"
assumes "P a"
assumes "(\<And>y z. r\<^sup>*\<^sup>* a y \<Longrightarrow> r y z \<Longrightarrow> I y \<Longrightarrow> I z \<Longrightarrow> P y \<Longrightarrow> P z)"
shows "P b"
proof-
from assms(1,3)
have "P b" and "I b"
proof(induction)
case base
from \<open>P a\<close> show "P a".
from \<open>I a\<close> show "I a".
next
case (step y z)
with \<open>I a\<close> have "P y" and "I y" by auto
from assms(2) \<open>r y z\<close> \<open>I y\<close>
show "I z" by (rule invariantE)
from \<open>r\<^sup>*\<^sup>* a y\<close> \<open>r y z\<close> \<open>I y\<close> \<open>I z\<close> \<open>P y\<close>
show "P z" by (rule assms(5))
qed
thus "P b" by-
qed
fun closed :: "conf \<Rightarrow> bool"
where "closed (\<Gamma>, e, S) \<longleftrightarrow> fv (\<Gamma>, e, S) \<subseteq> domA \<Gamma> \<union> upds S"
fun heap_upds_ok where "heap_upds_ok (\<Gamma>,S) \<longleftrightarrow> domA \<Gamma> \<inter> upds S = {} \<and> distinct (upds_list S)"
abbreviation heap_upds_ok_conf :: "conf \<Rightarrow> bool"
where "heap_upds_ok_conf c \<equiv> heap_upds_ok (fst c, snd (snd c))"
lemma heap_upds_okE: "heap_upds_ok (\<Gamma>, S) \<Longrightarrow> x \<in> domA \<Gamma> \<Longrightarrow> x \<notin> upds S"
by auto
lemma heap_upds_ok_Nil[simp]: "heap_upds_ok (\<Gamma>, [])" by auto
lemma heap_upds_ok_app1: "heap_upds_ok (\<Gamma>, S) \<Longrightarrow> heap_upds_ok (\<Gamma>,Arg x # S)" by auto
lemma heap_upds_ok_app2: "heap_upds_ok (\<Gamma>, Arg x # S) \<Longrightarrow> heap_upds_ok (\<Gamma>, S)" by auto
lemma heap_upds_ok_alts1: "heap_upds_ok (\<Gamma>, S) \<Longrightarrow> heap_upds_ok (\<Gamma>,Alts e1 e2 # S)" by auto
lemma heap_upds_ok_alts2: "heap_upds_ok (\<Gamma>, Alts e1 e2 # S) \<Longrightarrow> heap_upds_ok (\<Gamma>, S)" by auto
lemma heap_upds_ok_append:
assumes "domA \<Delta> \<inter> upds S = {}"
assumes "heap_upds_ok (\<Gamma>,S)"
shows "heap_upds_ok (\<Delta>@\<Gamma>, S)"
using assms
unfolding heap_upds_ok.simps
by auto
lemma heap_upds_ok_let:
assumes "atom ` domA \<Delta> \<sharp>* S"
assumes "heap_upds_ok (\<Gamma>, S)"
shows "heap_upds_ok (\<Delta> @ \<Gamma>, S)"
using assms(2) fresh_distinct_fv[OF assms(1)]
by (auto intro: heap_upds_ok_append dest: subsetD[OF ups_fv_subset])
lemma heap_upds_ok_to_stack:
"x \<in> domA \<Gamma> \<Longrightarrow> heap_upds_ok (\<Gamma>, S) \<Longrightarrow> heap_upds_ok (delete x \<Gamma>, Upd x #S)"
by (auto)
lemma heap_upds_ok_to_stack':
"map_of \<Gamma> x = Some e \<Longrightarrow> heap_upds_ok (\<Gamma>, S) \<Longrightarrow> heap_upds_ok (delete x \<Gamma>, Upd x #S)"
by (metis Domain.DomainI domA_def fst_eq_Domain heap_upds_ok_to_stack map_of_SomeD)
lemma heap_upds_ok_delete:
"heap_upds_ok (\<Gamma>, S) \<Longrightarrow> heap_upds_ok (delete x \<Gamma>, S)"
by auto
lemma heap_upds_ok_restrictA:
"heap_upds_ok (\<Gamma>, S) \<Longrightarrow> heap_upds_ok (restrictA V \<Gamma>, S)"
by auto
lemma heap_upds_ok_restr_stack:
"heap_upds_ok (\<Gamma>, S) \<Longrightarrow> heap_upds_ok (\<Gamma>, restr_stack V S)"
apply auto
by (induction V S rule: restr_stack.induct) auto
lemma heap_upds_ok_reorder:
"x \<in> domA \<Gamma> \<Longrightarrow> heap_upds_ok (\<Gamma>, S) \<Longrightarrow> heap_upds_ok ((x,e) # delete x \<Gamma>, S)"
by (intro heap_upds_ok_to_heap heap_upds_ok_to_stack)
lemma heap_upds_ok_upd:
"heap_upds_ok (\<Gamma>, Upd x # S) \<Longrightarrow> x \<notin> domA \<Gamma> \<and> x \<notin> upds S"
by auto
lemmas heap_upds_ok_intros[intro] =
heap_upds_ok_to_heap heap_upds_ok_to_stack heap_upds_ok_to_stack' heap_upds_ok_reorder
heap_upds_ok_app1 heap_upds_ok_app2 heap_upds_ok_alts1 heap_upds_ok_alts2 heap_upds_ok_delete
heap_upds_ok_restrictA heap_upds_ok_restr_stack
heap_upds_ok_let
lemmas heap_upds_ok.simps[simp del]
end
|
Formal statement is: lemma (in -) assumes "filterlim f (nhds L) F" shows tendsto_imp_filterlim_at_right: "eventually (\<lambda>x. f x > L) F \<Longrightarrow> filterlim f (at_right L) F" and tendsto_imp_filterlim_at_left: "eventually (\<lambda>x. f x < L) F \<Longrightarrow> filterlim f (at_left L) F" Informal statement is: If $f$ converges to $L$ in the filter of neighbourhoods of $L$, then $f$ converges to $L$ from the left or from the right, depending on whether $f$ is eventually greater than $L$ or eventually less than $L$. |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.CommRing.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Transport
open import Cubical.Foundations.SIP
open import Cubical.Data.Sigma
open import Cubical.Reflection.StrictEquiv
open import Cubical.Structures.Axioms
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.Ring.Base
open Iso
private
variable
ℓ : Level
record IsCommRing {R : Type ℓ}
(0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R) : Type ℓ where
constructor iscommring
field
isRing : IsRing 0r 1r _+_ _·_ -_
·-comm : (x y : R) → x · y ≡ y · x
open IsRing isRing public
record CommRingStr (A : Type ℓ) : Type (ℓ-suc ℓ) where
constructor commringstr
field
0r : A
1r : A
_+_ : A → A → A
_·_ : A → A → A
-_ : A → A
isCommRing : IsCommRing 0r 1r _+_ _·_ -_
infix 8 -_
infixl 7 _·_
infixl 6 _+_
open IsCommRing isCommRing public
CommRing : Type (ℓ-suc ℓ)
CommRing = TypeWithStr _ CommRingStr
makeIsCommRing : {R : Type ℓ} {0r 1r : R} {_+_ _·_ : R → R → R} { -_ : R → R}
(is-setR : isSet R)
(+-assoc : (x y z : R) → x + (y + z) ≡ (x + y) + z)
(+-rid : (x : R) → x + 0r ≡ x)
(+-rinv : (x : R) → x + (- x) ≡ 0r)
(+-comm : (x y : R) → x + y ≡ y + x)
(·-assoc : (x y z : R) → x · (y · z) ≡ (x · y) · z)
(·-rid : (x : R) → x · 1r ≡ x)
(·-rdist-+ : (x y z : R) → x · (y + z) ≡ (x · y) + (x · z))
(·-comm : (x y : R) → x · y ≡ y · x)
→ IsCommRing 0r 1r _+_ _·_ -_
makeIsCommRing {_+_ = _+_} is-setR +-assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-rdist-+ ·-comm =
iscommring (makeIsRing is-setR +-assoc +-rid +-rinv +-comm ·-assoc ·-rid
(λ x → ·-comm _ _ ∙ ·-rid x) ·-rdist-+
(λ x y z → ·-comm _ _ ∙∙ ·-rdist-+ z x y ∙∙ λ i → (·-comm z x i) + (·-comm z y i))) ·-comm
makeCommRing : {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R)
(is-setR : isSet R)
(+-assoc : (x y z : R) → x + (y + z) ≡ (x + y) + z)
(+-rid : (x : R) → x + 0r ≡ x)
(+-rinv : (x : R) → x + (- x) ≡ 0r)
(+-comm : (x y : R) → x + y ≡ y + x)
(·-assoc : (x y z : R) → x · (y · z) ≡ (x · y) · z)
(·-rid : (x : R) → x · 1r ≡ x)
(·-rdist-+ : (x y z : R) → x · (y + z) ≡ (x · y) + (x · z))
(·-comm : (x y : R) → x · y ≡ y · x)
→ CommRing
makeCommRing 0r 1r _+_ _·_ -_ is-setR +-assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-rdist-+ ·-comm =
_ , commringstr _ _ _ _ _ (makeIsCommRing is-setR +-assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-rdist-+ ·-comm)
CommRing→Ring : CommRing {ℓ} → Ring
CommRing→Ring (_ , commringstr _ _ _ _ _ H) = _ , ringstr _ _ _ _ _ (IsCommRing.isRing H)
CommRingEquiv : (R S : CommRing) (e : ⟨ R ⟩ ≃ ⟨ S ⟩) → Type ℓ
CommRingEquiv R S e = RingEquiv (CommRing→Ring R) (CommRing→Ring S) e
CommRingHom : (R S : CommRing) → Type ℓ
CommRingHom R S = RingHom (CommRing→Ring R) (CommRing→Ring S)
module CommRingΣTheory {ℓ} where
open RingΣTheory
CommRingAxioms : (R : Type ℓ) (s : RawRingStructure R) → Type ℓ
CommRingAxioms R (_+_ , 1r , _·_) = RingAxioms R (_+_ , 1r , _·_)
× ((x y : R) → x · y ≡ y · x)
CommRingStructure : Type ℓ → Type ℓ
CommRingStructure = AxiomsStructure RawRingStructure CommRingAxioms
CommRingΣ : Type (ℓ-suc ℓ)
CommRingΣ = TypeWithStr ℓ CommRingStructure
CommRingEquivStr : StrEquiv CommRingStructure ℓ
CommRingEquivStr = AxiomsEquivStr RawRingEquivStr CommRingAxioms
isPropCommRingAxioms : (R : Type ℓ) (s : RawRingStructure R)
→ isProp (CommRingAxioms R s)
isPropCommRingAxioms R (_·_ , 0r , _+_) =
isPropΣ (isPropRingAxioms R (_·_ , 0r , _+_))
λ { (_ , x , _) → isPropΠ2 λ _ _ →
x .IsMonoid.isSemigroup .IsSemigroup.is-set _ _}
CommRing→CommRingΣ : CommRing → CommRingΣ
CommRing→CommRingΣ (_ , commringstr _ _ _ _ _ (iscommring G C)) =
_ , _ , Ring→RingΣ (_ , ringstr _ _ _ _ _ G) .snd .snd , C
CommRingΣ→CommRing : CommRingΣ → CommRing
CommRingΣ→CommRing (_ , _ , G , C) =
_ , commringstr _ _ _ _ _ (iscommring (RingΣ→Ring (_ , _ , G) .snd .RingStr.isRing) C)
CommRingIsoCommRingΣ : Iso CommRing CommRingΣ
CommRingIsoCommRingΣ =
iso CommRing→CommRingΣ CommRingΣ→CommRing (λ _ → refl) (λ _ → refl)
commRingUnivalentStr : UnivalentStr CommRingStructure CommRingEquivStr
commRingUnivalentStr = axiomsUnivalentStr _ isPropCommRingAxioms rawRingUnivalentStr
CommRingΣPath : (R S : CommRingΣ) → (R ≃[ CommRingEquivStr ] S) ≃ (R ≡ S)
CommRingΣPath = SIP commRingUnivalentStr
CommRingEquivΣ : (R S : CommRing) → Type ℓ
CommRingEquivΣ R S = CommRing→CommRingΣ R ≃[ CommRingEquivStr ] CommRing→CommRingΣ S
CommRingPath : (R S : CommRing) → (Σ[ e ∈ ⟨ R ⟩ ≃ ⟨ S ⟩ ] CommRingEquiv R S e) ≃ (R ≡ S)
CommRingPath R S =
Σ[ e ∈ ⟨ R ⟩ ≃ ⟨ S ⟩ ] CommRingEquiv R S e ≃⟨ strictIsoToEquiv RingIsoΣPath ⟩
CommRingEquivΣ R S ≃⟨ CommRingΣPath _ _ ⟩
CommRing→CommRingΣ R ≡ CommRing→CommRingΣ S
≃⟨ isoToEquiv (invIso (congIso CommRingIsoCommRingΣ)) ⟩
R ≡ S ■
CommRingPath : (R S : CommRing {ℓ}) → (Σ[ e ∈ ⟨ R ⟩ ≃ ⟨ S ⟩ ] CommRingEquiv R S e) ≃ (R ≡ S)
CommRingPath = CommRingΣTheory.CommRingPath
isSetCommRing : ((R , str) : CommRing {ℓ}) → isSet R
isSetCommRing (R , str) = str .CommRingStr.is-set
isPropIsCommRing : {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R)
→ isProp (IsCommRing 0r 1r _+_ _·_ -_)
isPropIsCommRing 0r 1r _+_ _·_ -_ (iscommring RR RC) (iscommring SR SC) =
λ i → iscommring (isPropIsRing _ _ _ _ _ RR SR i)
(isPropComm RC SC i)
where
isSetR : isSet _
isSetR = RR .IsRing.·IsMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set
isPropComm : isProp ((x y : _) → x · y ≡ y · x)
isPropComm = isPropΠ2 λ _ _ → isSetR _ _
|
\documentclass[11pt]{article}
\usepackage{listings}
\newcommand{\numpy}{{\tt numpy}} % tt font for numpy
\topmargin -.5in
\textheight 9in
\oddsidemargin -.25in
\evensidemargin -.25in
\textwidth 7in
\begin{document}
% ========== Edit your name here
\author{Francesco Penasa}
\title{Formal methods - Lab1}
\maketitle
\medskip
% === Starting point === %
\texttt{2020 03 27}\\
\texttt{[email protected]}
\texttt{enricomagnago.com and patrick trentin website}
\begin{enumerate}
\item write formal models in smv language for finite, infinite and timed systems
\item inspect possible executions
\item write and verify invariant and temporal properties
\end{enumerate}
\paragraph{exam} % (fold)
\label{par:exam}
\begin{enumerate}
\item write 2 formal models in SMV language
\item simulate these models
\item verify some properties
\end{enumerate}
% paragraph exam (end)
\section{Introduction} % (fold)
\label{sec:introduction}
\begin{enumerate}
\item SMV
\item NuSMV
\item nuXmv
\end{enumerate}
% section introduction (end)
nuXmv allows for the verification of
\begin{enumerate}
\item finite-state system
\item infinite-state systems
\item timed systems
\item only \textit{synchronous} systems
\end{enumerate}
\begin{lstlisting}
nuXmv -int = interactive mode
help = show the list of all comands
reset
read_model [-i filename]
go = bdd engine only on finite system
go_bmc
go_msat
\end{lstlisting}
\begin{lstlisting}
pick state [- ]
simulate []
print_current_state [] = prints out the current state
goto_state
show_traces
show_vars
quit = exit
\end{lstlisting}
\section{First SMV model} % (fold)
\label{sec:first_smv_model}
\begin{lstlisting}
MODULE main -- mandatory
VAR -- define vars
b0 : boolean;
ASSIGN
init(b0) := FALSE; --initial constraint
next(b0) := !b0; --constraint of the transition
\end{lstlisting}
types:
\begin{enumerate}
\item boolean: \texttt{x : TRUE}
\item enumerative: \texttt{s : {ready, busy}}
\item bounded integers: \texttt{n : 1..8;1} (between INT\_MIN and INT\_MAX)
\item integers
\item somethings
\item words
\item arrays : \texttt{x : array 0..10 of boolean;}
\texttt{y : array -1..1 of {red, green, orange}}
\texttt{z : array 1..10 of array 1..5 of boolean} (matrix)
\end{enumerate}
\begin{lstlisting}
MODULE main
VAR
b0 : boolean;
b1 : boolean;
ASSIGN
init(b0) := FALSE;
next(b0) := !b0
init(y) := {1, 2, 3}; -- y can be either 1, 2 or 3
\end{lstlisting}
\begin{lstlisting}
case
c1 : e1;
c2 : e2;
TRUE : en;
esac
cond_expr ? ep1 : ep2
\end{lstlisting}
transition relation
\begin{lstlisting}
next(a) := {a, a+1};
\end{lstlisting}
\paragraph{not to do} % (fold)
\label{par:not_to_do}
\begin{enumerate}
\item write multiple init for the same value;
\end{enumerate}
% paragraph not_to_do (end)
% section first_smv_model (end)
\section{Exercise} % (fold)
\label{sec:exercise}
TODO before friday 2020 04 03
% section exercise (end)
\end{document}
\grid
\grid |
Inductive Id {A:Type} : A->A->Type := id_refl : forall (t:A),Id t t.
Notation "x == y" := (Id x y) (at level 70).
Definition concat {A} {x y z:A} : (x==y) -> (y==z) -> (x==z).
intros p q.
induction p.
exact q.
Defined.
Definition inverse {A} {x y:A} : (x==y) -> (y==x).
intros p.
induction p.
apply id_refl.
Defined.
Notation "p @ q" := (concat p q) (at level 60).
Notation "! p" := (inverse p) (at level 50).
Definition id_left_unit {A} {x y:A} (p:x==y) : (id_refl x) @ p == p.
induction p.
apply id_refl.
Defined.
Definition id_right_unit {A} {x y:A} (p:x==y) : p @ (id_refl y) == p.
induction p.
apply id_refl.
Defined.
Definition id_right_inverse {A} {x y:A} (p:x==y) : (p @ !p) == (id_refl x).
induction p.
apply id_refl.
Defined.
Definition id_left_inverse {A} {x y:A} (p:x==y) : (!p @ p) == (id_refl y).
induction p.
apply id_refl.
Defined.
Definition assoc {A} {x y z w:A} (p:x==y) (q:y==z) (r:z==w) : (p @ q) @ r == p @ (q @ r).
induction p;induction q;induction r.
apply id_refl.
Defined.
(*========= basic naturality laws ========*)
Definition concat2 {A} {x y z:A} {p q:x==y} {r s:y==z} : p==q -> r==s -> p @ r == q @ s.
intros f g.
induction f ;induction g.
apply id_refl.
Defined.
Notation "p [@] q" := (concat2 p q) (at level 61).
Definition assoc_is_left_monoidal {A} {x y z:A} (q:x==y) (r:y==z) : (assoc (id_refl _) q r)==(id_refl (q@r)).
induction q;induction r;apply id_refl.
Defined.
Definition assoc_is_center_monoidal {A} {x y z:A} (p:x==y) (r:y==z) :
(assoc p (id_refl _) r)==(id_right_unit p)[@](id_refl r).
Proof.
induction p;induction r;apply id_refl.
Defined.
Definition assoc_is_right_monoidal {A} {x y z:A} (p:x==y) (q:y==z) :
(assoc p q (id_refl _))==(id_right_unit (p@q))@(id_refl p[@]!id_right_unit q).
Proof.
induction p;induction q;apply id_refl.
Defined.
Definition id_right_unit_is_natural {A} {x y:A} {p q:x==y} (f:p==q) :
(f [@] (id_refl _))@(id_right_unit q)==(id_right_unit p)@f.
Proof.
induction f;induction t;apply id_refl.
Defined.
Definition assoc_is_natural {A} {x y z w:A} {p p':x==y} {q q':y==z} {r r':z==w} (f:p==p') (g:q==q') (h:r==r'):
(f[@]g[@]h)@(assoc p' q' r') == (assoc p q r)@(f[@](g[@]h)).
Proof.
induction f;induction g;induction h.
induction t;induction t0;induction t1.
apply id_refl.
Defined.
(*========= bicategory coherence laws ============*)
(* K4 coherence is pentagon equation *)
Definition K4 {A} {x y z w u:A} (a:x==y) (b:y==z) (c:z==w) (d:w==u) :
((assoc a b c) [@] (id_refl d)) @ (assoc a (b @ c) d) @ ((id_refl a) [@] (assoc b c d)) ==
(assoc (a @ b) c d) @ (assoc a b (c @ d)).
induction a;induction b;induction c;induction d.
apply id_refl.
Defined.
Definition u3 {A} {x y z:A} (a:x==y) (b:y==z) :
(concat2 (id_right_unit a) (id_refl b))==
(assoc a (id_refl y) b) @ (concat2(id_refl a) (id_left_unit b)).
induction a;induction b.
apply id_refl.
Defined.
(* inverseに対するcoherence? *)
Definition left_rigid1 {A} {x y:A} (a:x==y) :
!(id_left_unit a) @ (concat2 (!(id_right_inverse a)) (id_refl a)) @
(assoc a (!a) a) @ (concat2 (id_refl a) (id_left_inverse a)) @ (id_right_unit a) ==
id_refl a.
induction a.
apply id_refl.
Defined.
Definition left_rigid2 {A} {x y:A} (a:x==y) :
!(id_right_unit (!a)) @ (concat2 (id_refl (!a)) (!(id_right_inverse a))) @
!(assoc (!a) a (!a)) @ (concat2 (id_left_inverse a) (id_refl (!a))) @ (id_left_unit (!a)) ==
id_refl (!a).
induction a.
apply id_refl.
Defined.
(*=========== K5 coherence ============*)
Definition concat3 {A} {x y z:A} {p q:x==y} {r s:y==z} {X Y:p==q} {Z W:r==s} : X==Y -> Z==W -> X [@] Z==Y [@] W.
intros f g.
induction f ;induction g.
apply id_refl.
Defined.
Notation "p [[@]] q" := (concat3 p q) (at level 62).
(*
distl and distr are special cases of "(a@b)[@](c@d) == (a[@]b)@(c[@]d)"
*)
Definition distr {A} {x y z:A} {p q r:x==y} (s:y==z) (X:p==q) (Y:q==r) :
(X @ Y) [@] (id_refl s) == (X[@](id_refl s)) @ (Y[@](id_refl s)).
Proof.
induction X;induction Y.
apply id_refl.
Defined.
Definition distl {A} {x y z:A} {p q r:y==z} (s:x==y) (X:p==q) (Y:q==r) :
(id_refl s) [@] (X @ Y) == ((id_refl s) [@] X) @ ((id_refl s) [@] Y).
Proof.
induction X;induction Y.
apply id_refl.
Defined.
Definition id_save {A} {x y z:A} (p:x==y) (q:y==z) : (id_refl p) [@] (id_refl q) == id_refl (p@q).
induction p;induction q;apply id_refl.
Defined.
Definition K5_LHS {A} {x y z w u v:A} (a:x==y) (b:y==z) (c:z==w) (d:w==u) (e:u==v) :=
(
((assoc _ _ _) [@] (id_refl _)) @
(assoc _ (_@_) _)
) @
(
(
(
(!(distr e ((assoc a b c)[@](id_refl d)) (assoc a (b@c) d))) [@]
(id_refl ( (id_refl a) [@] (assoc b c d) [@] (id_refl e) ))
) @
(
(!(distr e _ _))
)
) [@]
(
(id_refl _)
)
) @
(
(
( (K4 a b c d) [[@]] (id_refl (id_refl e)) ) @
( distr e (assoc (a @ b) c d) (assoc a b (c @ d)) )
) [@]
(id_refl
( (assoc a (b@(c@d)) e) @
((id_refl a) [@] (assoc b (c@d) e)) @
((id_refl a) [@] ((id_refl b) [@] (assoc c d e)))
)
)
) @
(
!(assoc (_@_) (_@_) _) @
((assoc _ _ (_@_)) [@] (id_refl _)) @
(((id_refl _) [@] !(assoc _ _ _))[@](id_refl _))
) @
(
(id_refl ( (assoc (a@b) c d) [@] (id_refl e) )) [@]
(K4 a b (c@d) e) [@]
(id_refl (( (id_refl a) [@] ((id_refl b) [@] (assoc c d e)) )))
) @
(
(!(assoc _ _ _) [@] (id_refl _)) @ (assoc _ _ _)
) @
(
(id_refl ( (assoc (a@b) c d) [@] (id_refl e) )) [@]
(id_refl (assoc (a@b) (c@d) e)) [@]
(
(!assoc_is_natural (id_refl a) (id_refl b) (assoc c d e)) @
( ((id_save a b) [[@]] (id_refl (assoc c d e))) [@] (id_refl _) )
)
) @
(
!(assoc _ _ _)
) @
(
(K4 (a@b) c d e) [@] (id_refl (assoc a b _))
).
Definition K5_RHS {A} {x y z w u v:A} (a:x==y) (b:y==z) (c:z==w) (d:w==u) (e:u==v) :=
(
(assoc (_@_) _ _) [@] (id_refl _) [@] (id_refl _)
) @
(
(id_refl ((assoc a b c) [@] (id_refl d) [@] (id_refl e))) [@]
(id_refl ((assoc a (b@c) d) [@] (id_refl e))) [@]
(assoc_is_natural (id_refl a) (assoc b c d) (id_refl e)) [@]
(id_refl ((id_refl a) [@] (assoc b (c@d) e))) [@]
(id_refl ((id_refl a) [@] ((id_refl b) [@] (assoc c d e))))
) @
(
( (!(assoc (_@_) _ _)) [@] (id_refl _) [@] (id_refl _) ) @
( assoc (_@_@_@_) _ _ ) @
( assoc (_@_@_) _ (_@_) ) @
( (id_refl _) [@] ((id_refl _) [@] (!(distl a _ _))) ) @
( (id_refl _) [@] (!(distl a _ _)) ) @
( (id_refl _) [@] ((id_refl (id_refl a)) [[@]] !(assoc _ _ _)) )
) @
(
(id_refl ((assoc a b c) [@] (id_refl d) [@] (id_refl e))) [@]
(id_refl ((assoc a (b@c) d) [@] (id_refl e))) [@]
(id_refl (assoc a _ e)) [@]
( (id_refl (id_refl a)) [[@]] (K4 b c d e) )
) @
(
((id_refl _) [@] (distl a _ _)) @
!(assoc _ _ _) @
( (assoc _ _ _) [@] (id_refl _) [@] (id_refl _) ) @
( (assoc _ _ _) [@] (id_refl _) )
) @
(
(id_refl ((assoc a b c[@]id_refl d)[@]id_refl e) ) [@]
(K4 a (b@c) d e) [@]
(id_refl ((id_refl a) [@] (assoc _ _ _)))
) @
(
( !(assoc _ _ _) [@] (id_refl _) )
) @
(
((assoc_is_natural (assoc a b c) (id_refl d) (id_refl e))) [@]
(id_refl (assoc _ _ _)) [@]
(id_refl ((id_refl a) [@] (assoc _ _ _)))
) @
(
( ( (id_refl _) [@]
((id_refl (assoc a b c))[[@]](id_save d e)) ) [@]
(id_refl _) ) [@]
(id_refl _)
) @
(
(assoc (_ @ _) _ _) @
(assoc _ _ (_ @ _)) @
((id_refl _) [@] !(assoc _ _ _))
) @
(
(id_refl _) [@] (K4 a b c (d@e))
) @
(
!(assoc _ _ _)
).
Definition K5 {A} {x y z w u v:A} (a:x==y) (b:y==z) (c:z==w) (d:w==u) (e:u==v) :
K5_LHS a b c d e == K5_RHS a b c d e.
Proof.
induction a;induction b;induction c;induction d;induction e.
apply id_refl.
Defined.
(*===================== higher commutativity laws =====================*)
Definition interchange {A} {x y z:A} {p q r:x==y} {s t u:y==z} (a:p==q) (b:q==r) (c:s==t) (d:t==u) :
(a @ b) [@] (c @ d) == (a [@] c) @ (b [@] d).
Proof.
induction a;induction b;induction c;induction d.
apply id_refl.
Defined.
Definition concat2_is_left_unital {A} {x y:A} {p q:x==y} (s:p==q) :
(id_refl (id_refl x)) [@] s == (id_left_unit p) @ s @ !(id_left_unit q).
Proof.
induction s.
induction t.
apply id_refl.
Defined.
Definition concat2_is_right_unital {A} {x y:A} {p q:x==y} (s:p==q) :
s [@] (id_refl (id_refl y)) == (id_right_unit p) @ s @ !(id_right_unit q).
Proof.
induction s.
induction t.
apply id_refl.
Defined.
Definition concat2_is_left_unital_pt {A} {x:A} (s:(id_refl x)==(id_refl x)) :
(id_refl (id_refl x)) [@] s == s.
Proof.
exact( (concat2_is_left_unital s) @ (id_right_unit (_@s)) ).
Defined.
Definition concat2_is_right_unital_pt {A} {x:A} (s:(id_refl x)==(id_refl x)) :
s [@] (id_refl (id_refl x)) == s.
Proof.
exact( (concat2_is_right_unital s) @ (id_right_unit s) ).
Defined.
(*
Eckmann-Hilton argument:
a @ b == (e [@] a) @ (b [@] e) == (e @ b) [@] (a @ e) == b [@] a ==
(b @ e) [@] (e @ a) == (b [@] e) @ (e [@] a) == b@a
*)
Definition comm {A} {x:A} (a b:(id_refl x)==(id_refl x)): a @ b == b @ a.
set (e:=id_refl (id_refl x)).
assert(p1 := ((concat2_is_left_unital_pt a) [@] (concat2_is_right_unital_pt b))).
assert(p2 := interchange e b a e).
assert(p3 := (!id_left_unit b) [[@]] (!id_right_unit a)).
assert(p4 := (!id_right_unit b) [[@]] (!id_left_unit a)).
assert(p5 := interchange b e e a).
assert(p6 := ((concat2_is_right_unital_pt b) [@] (concat2_is_left_unital_pt a))).
exact ( ((!p1) @ (!(p3 @ p2))) @ ((p4 @ p5) @ p6) ).
Defined.
Definition comm_is_dinatural {A} {x:A} {a b a' b':(id_refl x)==(id_refl x)} (f:a==a') (g:b==b') :
(f [@] g)@(comm a' b')==(comm a b)@(g [@] f).
Proof.
induction f;induction g.
exact (!id_right_unit _).
Defined.
(* ===== prove hexagon and Yang-Baxter equation ======*)
(*
Reference:
A.Joyal and R.Street,
Braided tensor categories, Advances in Math. 102 (1993) 20-78
http://maths.mq.edu.au/~street/JS1.pdf
*)
(* analogous to Hom(X,Y) -> Hom(Y^{*},X^{*}) *)
Definition dualize {A} {x y:A} {p q:x==y} : (p==q) -> (!q==!p).
Proof.
intro f.
exact(
(!id_right_unit (!q)) @
((id_refl _) [@] (!id_right_inverse p)) @
((id_refl _) [@] (f [@] id_refl _)) @
(!assoc (!q) (q) (!p)) @
((id_left_inverse _) [@] (id_refl _)) @
(id_left_unit _)
).
Defined.
Definition inv_dist {A} {x y z:A} (p:x==y) (q:y==z):!(p @ q)==!q @ !p.
induction p;induction q;apply id_refl.
Defined.
Definition dualize_dist {A} {x y:A} {p q r:x==y} (s:p==q) (t:q==r) :
dualize (s @ t) == (dualize t) @ (dualize s).
Proof.
induction s;induction t.
induction t.
apply id_refl.
Defined.
Definition dualize_id_left_unit {A} {x y:A} (p:x==y) :
(dualize (id_left_unit p)) == (!id_right_unit (!p))@(!inv_dist (!id_refl x) p).
Proof.
induction p;apply id_refl.
Defined.
Definition inv_sq {A} {x y:A} (p:x==y) : !(!p)==p.
induction p;apply id_refl.
Defined.
Definition dualize_sq {A} {x y:A} {p q:x==y} (s:p==q) :
(dualize (dualize s))==(inv_sq p)@s@(!inv_sq q).
Proof.
induction s;induction t;apply id_refl.
Defined.
Definition dualize_commute_inv {A} {x y:A} {p q:x==y} (s:p==q):
dualize (!s)==!(dualize s).
Proof.
induction s;induction t;apply id_refl.
Defined.
Definition inv3 {A} {x y:A} {p q:x==y} {s t:p==q} : s==t -> dualize t==dualize s.
intro f;induction f;apply id_refl.
Defined.
Definition MF3 {A} {x y z:A} {p1 p2 p3 p4:x==y} {q1 q2 q3 q4:y==z}
(a:p1==p2) (b:p2==p3) (c:p3==p4) (a':q1==q2) (b':q2==q3) (c':q3==q4):
(interchange a (b@c) a' (b'@c'))@
((id_refl (a[@]a')) [@] (interchange b c b' c'))@
(!assoc (a[@]a') (b[@]b') (c[@]c'))
==
(!((assoc a b c) [[@]] (assoc a' b' c')))@
(interchange (a@b) c (a'@b') c')@
((interchange a b a' b') [@] (id_refl (c[@]c'))).
Proof.
induction a;induction b;induction c;induction a';induction b';induction c'.
apply id_refl.
Defined.
Definition id_left_unit_is_identity {A} {x y:A} (p:x==y):id_left_unit p==id_refl p.
induction p;apply id_refl.
Defined.
Definition PI_partL {A} {x y:A} {p q r:x==y} (a:p==q) (b:q==r) :
(id_left_unit p @ a @ !id_left_unit q) @ (id_left_unit q @ b @ !id_left_unit r)==
(id_left_unit p)@(a@b)@(!id_left_unit r).
Proof.
exact(
(
(
((id_refl _) [@] (!dualize (id_left_unit_is_identity q))) @
(id_right_unit (_@a)) @
((id_left_unit_is_identity p) [@] (id_refl _))
) [@]
(
((id_refl _) [@] (!dualize (id_left_unit_is_identity r))) @
(id_right_unit (_@b)) @
((id_left_unit_is_identity q) [@] (id_refl _))
)
) @
!(
((id_refl _) [@] (!dualize (id_left_unit_is_identity r))) @
(id_right_unit (_@(a@b))) @
((id_left_unit_is_identity p) [@] (id_refl _))
)
).
Defined.
Definition PIL_proto {A} {x y:A} {p q r:x==y} (a:p==q) (b:q==r) :
concat2_is_left_unital (a@b) ==
(interchange _ _ a b) @
(concat2_is_left_unital a [@] concat2_is_left_unital b) @
(PI_partL a b).
Proof.
induction a;induction b.
induction t.
apply id_refl.
Defined.
Definition PIL {A} {x:A} (a b:(id_refl x)==(id_refl x)) :
concat2_is_left_unital_pt (a@b) ==
( interchange (id_refl (id_refl x)) (id_refl (id_refl x)) a b ) @
( concat2_is_left_unital_pt a [@] concat2_is_left_unital_pt b ).
Proof.
set(Hab := id_right_unit (id_left_unit (id_refl x) @ (a @ b))).
set(Ha := id_right_unit (id_left_unit (id_refl x) @ a)).
set(Hb := id_right_unit (id_left_unit (id_refl x) @ b)).
set(c := id_right_unit (a @ b) @ id_refl (a @ b)).
exact (
((PIL_proto a b) [@] (id_refl Hab)) @
(assoc _ (PI_partL a b) Hab) @
((id_refl _) [@] (assoc _ (!c) Hab)) @
((id_refl _) [@] ((id_refl _) [@] ((inv_dist _ _)[@](id_refl Hab)))) @
((id_refl _) [@] ((id_refl _) [@] (id_left_inverse _))) @
((id_refl _) [@] (id_right_unit _)) @
(assoc _ _ _) @
((id_refl _) [@] (((id_refl _) [[@]] (id_refl _)) [@] ((id_right_unit Ha) [[@]] (id_right_unit Hb)))) @
((id_refl _) [@] (!interchange _ Ha _ Hb))
).
Defined.
Definition inv_dist2 {A} {x y z:A} {p q:x==y} {r s:y==z} (X:p==q) (Y:r==s) : !(X[@]Y)==(!X[@]!Y).
induction X;induction Y;apply id_refl.
Defined.
Definition PI_partR {A} {x y:A} {p q r:x==y} (a:p==q) (b:q==r) :
(id_right_unit p @ a @ !id_right_unit q) @ (id_right_unit q @ b @ !id_right_unit r)==
(id_right_unit p)@(a@b)@(!id_right_unit r).
Proof.
set(H:=
(assoc a (!id_right_unit q) (id_right_unit q @ b)) @
((id_refl a) [@] (!assoc (!id_right_unit q) _ b)) @
((id_refl a) [@] ((id_left_inverse _) [@] (id_refl b))) @
((id_refl a) [@] (id_left_unit b))
).
exact(
((assoc (id_right_unit p) a (!id_right_unit q)) [@] (id_refl (id_right_unit q @ b @ !id_right_unit r))) @
(assoc (id_right_unit p) _ _)@
((id_refl (id_right_unit p)) [@] (!assoc _ _ _))@
(!assoc (id_right_unit p) _ (!id_right_unit r)) @
((id_refl (id_right_unit p)) [@] H [@] (id_refl _))
).
Defined.
Definition PIR_proto {A} {x y:A} {p q r:x==y} (a:p==q) (b:q==r) :
concat2_is_right_unital (a@b) ==
(interchange a b _ _) @
(concat2_is_right_unital a [@] concat2_is_right_unital b) @
(PI_partR a b).
Proof.
induction a;induction b.
induction t.
apply id_refl.
Defined.
Definition PIR {A} {x:A} (a b:id_refl x==id_refl x) :
concat2_is_right_unital_pt (a@b) ==
( interchange a b (id_refl (id_refl x)) (id_refl (id_refl x)) ) @
( concat2_is_right_unital_pt a [@] concat2_is_right_unital_pt b ).
Proof.
set(p:=id_refl x).
set(q:=id_refl x).
set(r:=id_refl x).
set(va:=a @ (!id_right_unit q)).
set(vb:=(id_right_unit q) @ b).
set(redH :=
(
(
(
(assoc_is_center_monoidal a (id_right_unit q @ b)) [@]
((id_refl (id_refl a)) [[@]] (!dualize (assoc_is_center_monoidal (!id_right_unit q) b))) [@]
(id_refl ((id_refl a) [@] ((id_left_inverse _) [@] (id_refl b))))
)@(id_right_unit _)@(id_right_unit _)
)[@]
(id_refl ((id_refl a) [@] (id_left_unit b)))
)@(!interchange _ _ _ _)@((id_right_unit _)[[@]](id_left_unit _))
).
set(redX:=
(!id_right_unit _)@
((id_refl _)[@](!id_right_inverse _))@
(!assoc _ _ _)@
(
(assoc_is_natural (id_refl (id_right_unit p))
(id_right_unit a[@]id_left_unit b)
(id_refl (!id_right_unit r)))[@]
(id_refl (!assoc (id_right_unit p) (a @ b) (!id_right_unit r)))
)@
( (id_refl _)[@](!dualize (assoc_is_left_monoidal (a@b) (!id_right_unit r))) )@
(id_right_unit _)@
( (assoc_is_left_monoidal _ _)[@](id_refl _) )@
(id_left_unit _)
).
set(redP:=
(id_refl (PI_partR a b))@
(
(
(assoc_is_left_monoidal a (!id_right_unit q)) [[@]]
(id_refl (id_refl (id_right_unit q @ b @ !id_right_unit r)))
)[@]
(
assoc_is_left_monoidal (a @ !id_right_unit q) (id_right_unit q @ b @ !id_right_unit r)
)[@]
(id_refl _)[@]
(
!dualize (assoc_is_left_monoidal ((a @ !id_right_unit q) @ (id_right_unit q @ b)) (!id_right_unit r))
)[@]
( (id_refl _)[[@]]redH[[@]](id_refl _) )
)@
( ((id_right_unit _)@(id_left_unit _)) [@] (id_refl _) )@
( (id_refl _)[@]redX )@
( !interchange (id_refl (id_right_unit p)) (id_refl (id_right_unit p)) (!assoc va vb _) _)@
(
(id_left_unit (id_refl (id_right_unit p))) [[@]]
(
(
(!dualize (assoc_is_right_monoidal va vb))@(inv_dist _ _)[@]
(concat2_is_right_unital _)
)@
(!assoc (_@_) (_@_) _)@
((!assoc (_@_) _ _)[@](id_refl _))@
((assoc _ _ _)[@](id_refl _)[@](id_refl _))@
(( (inv_dist2 _ _)@((id_refl _)[[@]](inv_sq _)) )[@](id_left_inverse _)[@](id_refl _)[@](id_refl _))@
((id_right_unit _)[@](id_refl _)[@](id_refl _))@
((!interchange (!id_refl va) (id_right_unit a) (id_right_unit vb) (id_left_unit b))[@](id_refl _))
)
)
).
set(redA:=
(
(
redP@
(interchange
(id_refl (id_right_unit p))
(id_refl (id_right_unit p))
(!id_refl va @ id_right_unit a[@]id_right_unit vb @ id_left_unit b)
(!id_right_unit (a@b))
)@
((id_refl _)[@]
(
(concat2_is_left_unital (!id_right_unit (a @ b)))@
((id_left_unit_is_identity _) [@] (id_refl _) [@] (!dualize (id_left_unit_is_identity _)))@
(id_right_unit _)@(id_left_unit _)
)
)
)[@](id_refl (id_right_unit (a@b)))
)@(assoc _ _ _)@((id_refl _)[@](id_left_inverse _))@(id_right_unit _)
).
exact(
((PIR_proto a b)[@](id_refl (id_right_unit (a @ b)))) @
(assoc _ (PI_partR a b) (id_right_unit (a @ b)))@
((id_refl _)[@](
redA@(concat2_is_left_unital _)@
((id_left_unit_is_identity _) [@] (id_refl _) [@] (!dualize (id_left_unit_is_identity _)))
@(id_right_unit _)@(id_left_unit _)@
((id_left_unit _)[[@]](
(!id_right_unit_is_natural (id_left_unit b))@
(((id_left_unit_is_identity _)[[@]](id_refl _))[@](id_refl _))@(id_left_unit _)
))
))@
(assoc _ _ _)@((id_refl _)[@](!interchange _ _ _ _))
).
Defined.
Definition assoc_rr_inv {A} {x y z:A} (p:x==y) (q:y==z) : (p @ q) @ !q == p.
Proof.
exact (((assoc p q (!q))@(concat2 (id_refl p) (id_right_inverse q)))@(id_right_unit p)).
Defined.
Definition assoc_rl_inv {A} {x y z:A} (p:x==y) (q:z==y) : (p @ !q) @ q == p.
Proof.
exact ((concat2 (id_refl (p @ !q)) (!inv_sq q))@(assoc_rr_inv p (!q))).
Defined.
Definition assoc_ll_inv {A} {x y z:A} (p:x==y) (q:y==z) : !p @ (p @ q) == q.
Proof.
exact (((!assoc (!p) p q)@(concat2 (id_left_inverse p) (id_refl _)))@(id_left_unit q)).
Defined.
Definition assoc_lr_inv {A} {x y z:A} (p:y==x) (q:y==z) : p @ (!p @ q) == q.
Proof.
exact ((concat2 (!inv_sq p) (id_refl (!p @ q)))@(assoc_ll_inv (!p) q)).
Defined.
Definition inv_idrefl {A} (x : A) : !(id_refl x) == id_refl x.
Proof.
apply id_refl.
Defined.
Definition inv_idl_dist2 {A} {x y z:A} (p:x == y) {q r:y == z} (X:q==r) : !((id_refl p)[@]X) ==
(id_refl p[@]!X).
Proof.
exact ((inv_dist2 (id_refl p) X)@((inv_idrefl p) [[@]] (id_refl (!X)))).
Defined.
Definition inv_idr_dist2 {A} {x y z:A} {p q:x == y} (r:y == z) (X:p==q) : !(X[@](id_refl r)) == (!X
[@] id_refl r).
Proof.
exact ((inv_dist2 X (id_refl r))@(id_refl (!X) [[@]] inv_idrefl r)).
Defined.
Definition inv_dist3 {A} {x y z:A} {p q:x==y} {r s:y==z} {X Y:p==q} {Z W:r==s} (a:X==Y) (b:Z==W) : !(a[[@]]b)==(!a[[@]]!b).
induction a.
induction b.
apply id_refl.
Defined.
Definition concat3_dist {A} {x y z:A} {p q:x==y} {r s:y==z} {X Y Z:p==q} {U V W:r==s} (a:X==Y)
(b:Y==Z) (c:U==V) (d:V==W):
(a@b)[[@]](c@d) == (a[[@]]c)@(b[[@]]d).
induction a; induction b; induction c; induction d; apply id_refl.
Defined.
Definition concat4 {A} {x y z:A} {p q:x==y} {r s:y==z} {X Y:p==q} {Z W:r==s} {a b:X==Y} {c d:Z==W} : a==b -> c==d -> a [[@]] c==b [[@]] d.
intros f g.
induction f ;induction g.
apply id_refl.
Defined.
Notation "p [[[@]]] q" := (concat4 p q) (at level 63).
Definition id_save2 {A} {x y z:A} {p q:x==y} {r s:y==z} (X:p==q) (Y:r==s) :
(id_refl X) [[@]] (id_refl Y) == id_refl (X[@]Y).
induction X;induction Y;apply id_refl.
Defined.
Definition interchange_is_dinatural {A} {x y z:A} {p q r:x==y} {s t u:y==z} {a a':p==q} {b b':q==r} {c c':s==t} {d d':t==u} (f:a==a') (g:b==b') (h:c==c') (l:d==d'):
(f[@]g [[@]] h[@]l)@(interchange a' b' c' d')==(interchange a b c d)@((f[[@]]h)[@](g[[@]]l)).
Proof.
induction f.
induction g.
induction h.
induction l.
exact (((id_save _ _ [[[@]]] id_save _ _) @ id_save2 _ _ [@] id_refl _)
@ id_left_unit _
@ !id_right_unit _
@ (id_refl _ [@] !id_save _ _
@ (!id_save2 _ _ [[@]] !id_save2 _ _))).
Defined.
Definition concat2_left_unit {A} {x:A} {p q:(id_refl x)==(id_refl x)} (f:p==q): (id_refl (id_refl (id_refl x))) [@] f == f.
Proof.
exact(concat2_is_left_unital f
@ ((id_left_unit_is_identity _ [@] id_refl _)
@ id_left_unit _
[@] dualize (!id_left_unit_is_identity _) @ inv_idrefl _)
@ id_right_unit _).
Defined.
Definition hexagonR {A} {x:A} (a b c:(id_refl x)==(id_refl x)) :
(assoc a b c) @ (comm a (b@c)) @ (assoc b c a) ==
((comm a b) [@] (id_refl c)) @ (assoc b a c) @ ((id_refl b) [@] (comm a c)).
Proof.
assert(H1:(id_refl (b@a)[@](id_refl c))==id_refl _) by (apply id_refl).
assert(H2:(id_refl b)[@](id_refl (c @ a)) == id_refl (b@(c@a))) by (apply id_refl).
set (e:=id_refl (id_refl x)).
set(LA:=concat2_is_left_unital_pt a).
set(RB:=concat2_is_right_unital_pt b).
set(RC:=concat2_is_right_unital_pt c).
set(R1:=
((PIR b c)[[@]](id_refl LA))@
(interchange _ (RB[@]RC) (id_refl (e[@]a)) LA)
).
set(L1:=
( ((id_refl LA)[[@]](PIR b c))[@](id_refl (!assoc a b c)) )@
( (interchange (id_refl (e[@]a)) LA _ (RB[@]RC))[@](id_refl (!assoc a b c)) )@
(assoc _ _ (!assoc a b c))@
( (id_refl _)[@]
(
((!id_left_inverse _)[@](id_refl (LA[@](RB[@]RC)))[@](id_refl _))@
((assoc _ _ _)[@](id_refl _))@
((id_refl (!assoc (e[@]a) (b[@]e) (c[@]e)))[@](!assoc_is_natural LA RB RC)[@](id_refl (!assoc a b c)))@
(assoc _ (_@_) _)@
((id_refl _)[@](assoc _ _ _))@
((id_refl _)[@]((id_refl _)[@](id_right_inverse _)))@
((id_refl _)[@](id_right_unit _))
)
)@
(!assoc _ _ _)
).
set(L2:=
((id_refl (interchange e (b @ c) a (e @ e)))[@]L1)@
(!assoc _ (_@_) _)@((!assoc _ _ _)[@](id_refl (LA[@]RB[@]RC)))@
((MF3 e b c a e e)[@](id_refl _))
).
set(T1:=
(!id_right_unit _)@
((id_refl _)[@](!H1))@
((id_refl _)[@]((!id_left_unit _)[[@]](!id_left_inverse RC)))@
((id_refl _)[@](interchange _ _ (!RC) RC))@
(!assoc ((comm a b)[@](id_refl c)) ((id_refl (b@a))[@](!RC)) ((id_refl (b@a)[@]RC)))@
(
(
(!interchange (comm a b) (id_refl _) (id_refl _) (!RC))@
((id_right_unit (comm a b))[[@]](id_left_unit (!RC)))@
((!id_left_unit (comm a b))[[@]](!id_right_unit (!RC)))@
(interchange (id_refl _) (comm a b) (!RC) (id_refl _))
)[@](id_refl _)
)@
((id_refl _)[@](interchange _ _ (id_refl _) (id_refl _))[@](id_refl _))@
((!assoc _ _ _)[@](id_refl _))@(assoc (_@_) _ _)@
((!interchange _ _ _ _)[@](!interchange _ _ _ _))@
(((id_left_unit _)[[@]](id_refl _))[@]((id_right_unit _)[[@]](id_refl _)))@
((interchange (!(LA[@]RB)) _ (!RC) (id_refl (c[@]e)))[@](interchange _ (RB[@]LA) (id_refl (c[@]e)) RC))@
(((!inv_dist2 (LA[@]RB) RC)[@](id_refl _))[@](id_refl _))@
(!assoc (_@_) _ _)@((assoc _ _ _)[@](id_refl _))
).
set(T2:=
(!id_right_unit _)@
((id_refl _)[@](!H2))@
((id_refl _)[@]((!id_left_inverse RB)[[@]](!id_left_unit _)))@
((id_refl _)[@](interchange (!RB) RB _ _))@
(!assoc ((id_refl b)[@](comm a c)) ((!RB)[@](id_refl (c@a))) (RB[@](id_refl (c@a))))@
(
(
(!interchange (id_refl b) (!RB) (comm a c) (id_refl _))@
((id_left_unit (!RB))[[@]](id_right_unit _))@
((!id_right_unit (!RB))[[@]](!id_left_unit _))@
(interchange _ _ _ _)
)[@](id_refl _)
)@
((id_refl _)[@](interchange (id_refl (b[@]e)) (id_refl (b[@]e)) _ _)[@](id_refl _))@
((!assoc _ _ _)[@](id_refl _))@
(assoc (_@_) _ _)@
((!interchange (!RB) (id_refl (b[@]e)) (id_refl _) _)[@](!interchange (id_refl (b[@]e)) RB _ _))@
(((id_refl _)[[@]](id_left_unit _))[@]((id_refl _)[[@]](id_right_unit _)))@
((interchange (!RB) (id_refl (b[@]e)) _ _)[@](interchange _ RB _ (RC[@]LA)))@
(((!inv_dist2 RB (LA[@]RC))[@](id_refl _))[@](id_refl _))@
(assoc _ _ (_@_))@((id_refl _)[@](!assoc _ _ _))
).
set(T3:=
(T1[@](id_refl (assoc b a c))[@]T2)@
((assoc (_@(_@_)) _ _)[@](id_refl _))@
(assoc _ _ _)@((id_refl (_@(_@_)))[@](!assoc (_@_) _ _))@
(
(id_refl _)[@](
(
((assoc_is_natural RB LA RC)[@](id_refl (!(RB[@](LA[@]RC)))))@
(assoc _ _ _)@
((id_refl _)[@](id_right_inverse _))@
(id_right_unit _)
)[@]
(id_refl _))
)@
((id_refl _)[@](!assoc _ _ _))@
(!assoc _ _ _)
).
(* Note: M1は(MF3 b e c e a e)を変形するだけ *)
assert(M1 : (interchange b e e a[@]id_refl (c[@]e))@
(assoc (b[@]e) (e[@]a) (c[@]e))@
(id_refl (b[@]e)[@]!interchange e c a e)==
(!interchange (b @ e) c (e @ a) e)@
(assoc b e c[[@]]assoc e a e)@
(interchange b (e @ c) e (a @ e)) ).
exact ((!(((((id_refl ((!(interchange (b @ e) c (e @ a) e)) @ (assoc b e c[[@]]assoc e a e)))
[@]
((((!assoc_rl_inv (interchange b (e @ c) e (a @ e)) (id_refl (b[@]e)[@]!interchange e c a e))
@
(concat2
((concat2
(id_refl (interchange b (e @ c) e (a @ e)))
((dualize ((inv_idrefl (b[@]e))[[@]](id_refl (!interchange e c a e))))
@
((dualize (inv_dist2 (id_refl (b[@]e)) (interchange e c a e)))
@
(inv_sq (id_refl (b[@]e)[@]interchange e c a e)))))
@
((!assoc_rl_inv ((interchange b (e @ c) e (a @ e)) @ (id_refl (b[@]e)[@]interchange e c a e)) (assoc (b[@]e) (e[@]a) (c[@]e)))
@
(concat2
(MF3 b e c e a e)
(id_refl (assoc (b[@]e) (e[@]a) (c[@]e))))))
(id_refl (id_refl (b[@]e)[@]!interchange e c a e))))
@
(assoc ((!(assoc b e c[[@]]assoc e a e) @ (interchange (b @ e) c (e @ a) e)) @ (interchange b e e a[@]id_refl (c[@]e))) (assoc (b[@]e) (e[@]a) (c[@]e)) (id_refl (b[@]e)[@]!interchange e c a e)))
@
(assoc (!(assoc b e c[[@]]assoc e a e) @ (interchange (b @ e) c (e @ a) e)) (interchange b e e a[@]id_refl (c[@]e)) ((assoc (b[@]e) (e[@]a) (c[@]e)) @ (id_refl (b[@]e)[@]!interchange e c a e)))))
@
((!((inv_dist (!(assoc b e c[[@]]assoc e a e)) (interchange (b @ e) c (e @ a) e))@((id_refl (!(interchange (b @ e) c (e @ a) e))) [@] (inv_sq (assoc b e c[[@]]assoc e a e)))))
[@] (id_refl ((!(assoc b e c[[@]]assoc e a e) @ (interchange (b @ e) c (e @ a) e)) @ ((interchange b e e a[@]id_refl (c[@]e)) @ ((assoc (b[@]e) (e[@]a) (c[@]e)) @ (id_refl (b[@]e)[@]!interchange e c a e)))))))
@
(assoc_ll_inv (!(assoc b e c[[@]]assoc e a e) @ (interchange (b @ e) c (e @ a) e)) ((interchange b e e a[@]id_refl (c[@]e)) @ ((assoc (b[@]e) (e[@]a) (c[@]e)) @ (id_refl (b[@]e)[@]!interchange e c a e)))))
@
(!assoc (interchange b e e a[@]id_refl (c[@]e)) (assoc (b[@]e) (e[@]a) (c[@]e)) (id_refl (b[@]e)[@]!interchange e c a e))))).
(* Note: M2は(!dualize (MF3 e b c a e e))を変形 *)
assert(M2 : (!interchange e b a e[@]id_refl (c[@]e))@
(!interchange (e @ b) c (a @ e) e)@
(assoc e b c[[@]]assoc a e e) ==
(assoc (e[@]a) (b[@]e) (c[@]e))@
(id_refl (e[@]a)[@]!interchange b c e e)@
(!interchange e (b @ c) a (e @ e)) ).
exact(
((id_refl ((!interchange e b a e[@]id_refl (c[@]e)) @ (!interchange (e @ b) c (a @ e) e)))
[@] (!inv_sq (assoc e b c[[@]]assoc a e e)))
@
(assoc (!interchange e b a e[@]id_refl (c[@]e)) (!(interchange (e @ b) c (a @ e) e)) (!!(assoc e b c[[@]]assoc a e e)))
@
((!inv_idr_dist2 (c[@]e) (interchange e b a e))[@](!inv_dist (!(assoc e b c[[@]]assoc a e e)) (interchange (e @ b) c (a @ e) e)))
@
(!inv_dist ((!(assoc e b c[[@]]assoc a e e)) @ (interchange (e @ b) c (a @ e) e)) (interchange e b a e[@]id_refl (c[@]e)))
@
(dualize (MF3 e b c a e e))
@
(inv_dist ((interchange e (b @ c) a (e @ e)) @ (id_refl (e[@]a)[@]interchange b c e e)) (!(assoc (e[@]a) (b[@]e) (c[@]e))))
@
((inv_sq (assoc (e[@]a) (b[@]e) (c[@]e)))[@](inv_dist (interchange e (b @ c) a (e @ e)) (id_refl (e[@]a)[@]interchange b c e e)))
@
(id_refl (assoc (e[@]a) (b[@]e) (c[@]e)) [@] ((inv_idl_dist2 (e[@]a) (interchange b c e e)) [@] (id_refl (!(interchange e (b @ c) a (e @ e))))))
@
(!assoc (assoc (e[@]a) (b[@]e) (c[@]e)) (id_refl (e[@]a)[@]!interchange b c e e) (!(interchange e (b @ c) a (e @ e))))).
assert(M3 : (interchange b (c @ e) e (e @ a)@
(id_refl (b[@]e)[@]interchange c e e a))@
(!assoc (b[@]e) (c[@]e) (e[@]a)) ==
(!(assoc b c e[[@]]assoc e e a))@
(interchange (b @ c) e (e @ e) a) @
(interchange b c e e[@]id_refl (e[@]a)) ).
exact (MF3 b c e e e a).
assert (M4 : ((comm a b[@]id_refl c) @ assoc b a c) @ (id_refl b[@]comm a c) ==
(((!((LA[@]RB)[@]RC)
@ (!((!id_left_unit b[[@]]!id_right_unit a) @ interchange e b a e)
[@] id_refl (c[@]e)))
@ ((!id_right_unit b[[@]]!id_left_unit a)[@] id_refl (c[@]e)))
@ (
((!interchange (b @ e) c (e @ a) e @ (assoc b e c[[@]]assoc e a e))
@ interchange b (e @ c) e (a @ e))
@ ((id_refl (b[@]e) [@] !(!id_left_unit c[[@]]!id_right_unit a))
@ (id_refl (b[@]e)
[@] (!id_right_unit c[[@]]!id_left_unit a)
@ interchange c e e a))))
@ (RB[@](RC[@]LA))).
exact(T3
@ (id_refl _[@](id_refl _[@]distr _ _ _)
[@](id_refl _
[@](((id_refl _ [[@]] inv_dist _ _) @ distl _ _ _)
[@]id_refl _))
[@]id_refl _)
@ (!assoc _ _ _ @ !assoc _ _ _[@] (id_refl _ [@] assoc _ _ _) [@]id_refl _)
@ (assoc _ _ _ [@] id_refl _)
@ (id_refl _ [@] !assoc _ _ _ @ !assoc _ _ _ [@] id_refl _)
@ (id_refl _ [@] (M1 [@] id_refl _) [@] id_refl _)).
assert (M5 :
((comm a b[@]id_refl c) @ assoc b a c) @ (id_refl b[@]comm a c) ==
(((!((LA[@]RB)[@]RC)
@ (!((!id_left_unit b[[@]]!id_right_unit a) @ interchange e b a e)
[@] id_refl (c[@]e)))
@ ((!id_right_unit b[[@]]!id_left_unit a)[@] id_refl (c[@]e)))
@ (
((!interchange (b @ e) c (e @ a) e
@ (((id_right_unit b)[@](id_refl c) [[@]] (id_left_unit a)[@] (id_refl e))
@ ((!id_left_unit b)[@](id_refl c) [[@]] (!id_right_unit a)[@] (id_refl e))
@ (assoc e b c[[@]]assoc a e e)))
@ interchange b (e @ c) e (a @ e))
@ ((id_refl (b[@]e) [@] !(!id_left_unit c[[@]]!id_right_unit a))
@ (id_refl (b[@]e)
[@] (!id_right_unit c[[@]]!id_left_unit a)
@ interchange c e e a))))
@ (!assoc (b[@]e) (c[@]e) (e[@]a) @ (((RB[@]RC)[@]LA) @ (assoc b c a)))
).
exact(M4
@ (id_refl _
[@] (id_refl _
[@] !((!concat3_dist _ _ _ _ [@] (id_refl (assoc e b c[[@]]assoc a e e)))
@ (!concat3_dist _ _ _ _)
@ ((((id_refl _) [@] (!(dualize (id_left_unit_is_identity b))[[@]] (id_refl _))
[@] (assoc_is_left_monoidal _ _))
@ (id_right_unit _)
@ ((id_refl _) [@] ((inv_idrefl b) [[@]] (id_refl _)))
@ ((id_refl _) [@] (id_save b _))
@ (id_right_unit _)
@ (!assoc_is_center_monoidal b c))
[[[@]]] ((((id_left_unit_is_identity _)[[@]] (id_refl _))
[@] ((id_refl _) [[@]] (!inv_idrefl e))
[@] (id_refl _))
@ ((id_save a e) [@] (!inv_dist2 _ _) [@] (id_refl _))
@ ((!assoc_is_left_monoidal a e) [@] (dualize (assoc_is_center_monoidal a e)) [@] (id_refl _))
@ (assoc_rl_inv _ _))))
[@] id_refl _ [@] id_refl _)
[@] (!assoc_ll_inv _ _) @ (id_refl _ [@] !assoc_is_natural _ _ _))).
assert (M6 :
(!(!id_left_unit b[[@]]!id_right_unit a) [@] id_refl (c[@]e))
@ (((!id_right_unit b[[@]]!id_left_unit a)[@] id_refl (c[@]e))
@ !interchange (b @ e) c (e @ a) e
@ ((id_right_unit b[@]id_refl c [[@]] id_left_unit a[@] id_refl e)
@ (!id_left_unit b[@]id_refl c [[@]] !id_right_unit a[@]id_refl e)))
==
!interchange (e @ b) c (a @ e) e).
exact (!assoc _ _ _
@ (!assoc _ _ _ @ (!distr _ _ _
@ ((inv_dist3 _ _
[@] id_refl _) @ !concat3_dist _ _ _ _
@ (!inv_dist _ _ [[[@]]] !inv_dist _ _)
@ !inv_dist3 _ _
[[@]] !id_save2 c e
@ !inv_sq _
@ dualize (!inv_dist3 _ _))
[@] id_refl _) [@] id_refl _)
@ ((!inv_dist2 _ _ [@] id_refl _) @ !inv_dist _ _
@ dualize (interchange_is_dinatural _ _ _ _)
@ inv_dist _ _
[@] !concat3_dist _ _ _ _
@ (!distr _ _ _
@ (id_refl _ [[@]] !inv_idrefl _)
[[[@]]] !distr _ _ _
@ (id_refl _ [[@]] !inv_idrefl _)))
@ assoc_rl_inv _ _).
assert (M7 :
interchange b (e @ c) e (a @ e)
@ (id_refl (b[@]e) [@] (!(!id_left_unit c[[@]]!id_right_unit a)))
@ (id_refl (b[@]e) [@] (!id_right_unit c[[@]]!id_left_unit a))
==
((id_refl b [@] id_left_unit c)[[@]](id_refl e [@] id_right_unit a))
@ ((id_refl b [@] !id_right_unit c)[[@]](id_refl e [@] !id_left_unit a))
@ interchange b (c @ e) e (e @ a)).
exact (assoc _ _ _
@ (id_refl _ [@] !distl _ _ _ @ (id_save2 _ _ [[@]] id_refl _))
@ (id_refl _ [@] (id_refl _ [[@]] (inv_dist3 _ _ @ (inv_sq _ [[[@]]] inv_sq _)
[@] id_refl _)
@ !concat3_dist _ _ _ _))
@ !interchange_is_dinatural (id_refl b) _ (id_refl e) _
@ ((distl _ _ _ [[[@]]] distl _ _ _)
@ concat3_dist _ _ _ _
[@] id_refl _ )).
assert (M8 :
((comm a b[@]id_refl c) @ assoc b a c) @ (id_refl b[@]comm a c) ==
(((!((LA[@]RB)[@]RC)
@ (!interchange e b a e [@] id_refl (c[@]e)))
@ (
!interchange (e @ b) c (a @ e) e
@ (assoc e b c[[@]]assoc a e e)))
@ (((((id_refl b [@] id_left_unit c)[[@]](id_refl e [@] id_right_unit a))
@ ((id_refl b [@] !id_right_unit c)[[@]](id_refl e [@] !id_left_unit a)))
@ interchange b (c @ e) e (e @ a))
@ (id_refl (b[@]e) [@] interchange c e e a)))
@ (!assoc (b[@]e) (c[@]e) (e[@]a) @ (((RB[@]RC)[@]LA) @ (assoc b c a)))).
exact (M5
@ (id_refl _ [@] (inv_dist _ _ [[@]] id_refl _) @ distr _ _ _
[@] id_refl _
[@] (id_refl _ [@] (id_refl _ [@] distl _ _ _))
[@] id_refl _)
@ (!assoc _ _ _ @ (!assoc _ _ _ [@] id_refl _) @ assoc _ _ _[@] id_refl _)
@ (assoc _ _ _ @ (!assoc _ _ _ [@] !assoc _ _ _ @ !assoc _ _ _)
[@] !assoc _ _ _ @ !assoc _ _ _[@] id_refl _)
@ (assoc _ _ _ @ (id_refl _ [@] !assoc _ _ _) [@] id_refl _ [@] id_refl _)
@ (id_refl _ [@] (M6 [@] id_refl _) [@] (M7 [@] id_refl _) [@] id_refl _)).
assert (M9 : (comm a (b@c))
== !(LA[@]concat2_is_right_unital_pt (b@c))
@ !((!id_left_unit (b@c)[[@]]!id_right_unit a)
@ interchange e (b@c) a e)
@ (((!id_right_unit (b@c)[[@]]!id_left_unit a)
@ interchange (b@c) e e a)
@ (concat2_is_right_unital_pt (b@c)[@]LA))).
apply id_refl.
exact(!(M8
@ (assoc _ _ _ @ (id_refl _ [@] !assoc _ _ _ @ M2) [@] assoc _ _ _ [@] id_refl _)
@ assoc _ _ _
@ (id_refl _ [@] assoc _ _ _ @ (id_refl _ [@] !assoc _ _ _ @ (M3 [@] id_refl _)))
@ (!assoc _ _ _ @ (!assoc _ _ _ [@] id_refl _) [@] id_refl _)
@ ((inv_dist2 _ _ @ (inv_dist2 _ _ [[@]] id_refl _ ) [@] id_refl _)
@ assoc_is_natural _ _ _
[@] id_refl _ [@] id_refl _ [@] id_refl _)
@ !assoc _ _ _ @ !assoc _ _ _ @ !assoc _ _ _
@ (assoc _ _ _ @ assoc _ _ _ @ assoc _ _ _ @ assoc _ _ _ @ assoc _ _ _ [@] id_refl _)
@ (id_refl _
[@] (!assoc _ _ _
@ (!interchange _ _ _ _
@ (id_right_unit _ [[@]] (!inv_dist2 _ _ [@] id_refl _ ) @ !inv_dist _ _ @ dualize (PIR _ _))
[@] (id_refl _
[@] (id_refl _
[@] assoc _ _ _
@ (inv_dist3 _ _ @ (dualize (!assoc_is_right_monoidal _ _) @ inv_dist _ _ [[[@]]] dualize (!assoc_is_left_monoidal _ _) @ dualize (id_left_unit_is_identity _) @ !id_left_unit _)
@ concat3_dist _ _ _ _
[@] id_refl _
[@] !interchange _ _ _ _ @ (!PIR _ _ [[@]] id_left_unit _)))))
@ (id_refl _ [@] !assoc _ _ _
@ (id_refl _ [@] assoc _ _ _ @ assoc _ _ _)
@ !assoc _ _ _
@ (assoc _ _ _ @ (id_refl _ [@] assoc _ _ _)
[@] !assoc _ _ _))
@ (id_refl _ [@] (id_refl _
[@] (((id_refl _ [[@]] id_left_unit_is_identity _) @ id_save _ _
[[[@]]] concat2_left_unit (id_right_unit a))
[@] ((id_refl _ [[[@]]] concat2_left_unit (!id_left_unit a) @ dualize (!id_left_unit_is_identity _))
[@] (id_refl _ [[[@]]] !inv_sq _) @ !inv_dist3 _ _)
@ id_right_inverse _)
@ id_right_unit _
[@] id_refl _))
@ (!inv_dist2 _ _ [@] ((id_refl _ [@] (!id_left_unit_is_identity (b@c) @ !inv_sq _ [[[@]]] !inv_sq _) @ !inv_dist3 _ _)
@ !inv_dist _ _
[@] id_refl _))
@ !assoc _ _ _)
@ !M9
[@] id_refl _))).
Defined.
(* FIXME:hexagonRと同様にして示す *)
Definition hexagonL {A} {x:A} (a b c:(id_refl x)==(id_refl x)) :
(!assoc a b c)@(comm (a@b) c)@(!assoc c a b)==
((id_refl a)[@](comm b c))@(!assoc a c b)@((comm a c)[@](id_refl b)).
Proof.
Admitted.
(* Yang-Baxter equation *)
Definition YBE {A} {x:A} (a b c:(id_refl x)==(id_refl x)) :
((comm a b)[@](id_refl c)) @ (assoc b a c) @
((id_refl b)[@](comm a c)) @ (!assoc b c a) @
((comm b c)[@](id_refl a)) @ (assoc c b a) ==
(assoc a b c) @ ((id_refl a)[@](comm b c)) @
(!assoc a c b) @ ((comm a c)[@](id_refl b)) @
(assoc c a b) @ ((id_refl c)[@](comm a b)).
Proof.
(* N : comm a (b @ c) @ (comm b c[@]id_refl a) == (id_refl a[@]comm b c) @ comm a (c @ b) *)
set(N := !comm_is_dinatural (id_refl a) (comm b c)).
set(BX := !((hexagonR a b c)[@](id_refl (!assoc b c a)))@(assoc_rr_inv _ (assoc b c a)) ).
set(BY := (!assoc_ll_inv (assoc a c b) _)@
((id_refl (!assoc a c b))[@]((!assoc _ _ _)@(hexagonR a c b)))@
(!assoc _ _ _)@((!assoc _ _ _)[@](id_refl _)) ).
set(P := (BX [@] (id_refl (comm b c[@]id_refl a)))@
(assoc _ _ _)@
((id_refl (assoc a b c))[@]N)
).
exact (
(P [@] (id_refl (assoc c b a)))@
( (!assoc _ _ _)[@](id_refl _) )@(assoc _ _ _)@
( (id_refl _)[@]BY)@
(!assoc _ _ _)@
((!assoc _ _ _)[@](id_refl _))@
((!assoc _ _ _)[@](id_refl _)[@](id_refl _))
).
Defined.
(*
MEMO:YBEがZamolodchikov tetrahedron equationを満たすこと
((YBE a b c)[@](id_refl d))[[@]]???? : (1)==(2)
???[[@]]???[[@]]((id_refl c)[@](YBE a b d))[[@]]??? : (2)==(3)
(4)==(4.5) from ((id_refl a)[@](YBE b c d))
(4.5)==(5) from naturality of comm
(1)(ABC)D->(BAC)D->(BCA)D->(CBA)D->CBDA->CDBA->DCBA
(2)(ABC)D->(ACB)D->(CAB)D->(CBA)D->CBDA->CDBA->DCBA
(3)(ABC)D->(ACB)D->CABD->CADB->CDAB->CDBA->DCBA
(3.5)
(4)ABCD->ACBD->ACDB->ADCB->DACB->DCAB->DCBA
(4.5)ABCD->ABDC->ADBC->ADCB->DACB->DCAB->DCBA
(5)ABCD->ABDC->ADBC->DABC->DACB->DCAB->DCBA
(1')=(1)
(2')ABCD->BACD->BCAD->BCDA->BDCA->DBCA->DCBA
(3')ABCD->BACD->BADC->BDAC->DBAC->DBCA->DCBA
(4')ABCD->ABDC->ADBC->DABC->DBAC->DBCA->DCBA
(5')=(5)
References:
[1]Kapranov and Voevodsky ,2-categories and Zamolodchikov tetrahedra equations, in Algebraic Groups and Their Generalizations
*)
(*
(pivotal) monoidal categoryに於けるcategorical trace
Q1: left traceとright traceがあるけど、一致する?
多分、Whitehead bracketは、
WB x y := trace ((comm x y)@(comm y x))
Whitehead half-square mapは、
WM x := trace (comm x x)
Q2: (WB x y)@(WM x)@(WM y) == WM (x@y)が言える?
Q3: n-基本亜群(n>2)に於ける標準的なWhitehead積$\pi_2 \times \pi_2 \to \pi_3$とこの定義が一致することの証明
Reference: Fusion categories and homotopy theory(arXiv:0909.3140) Chapter7.3
*)
Definition trace {A} {x:A} {a:id_refl x==id_refl x} (f:a==a) :=
(!id_right_inverse a) @ (f [@] (id_refl (!a))) @
((!inv_sq a)[@](id_refl (!a))) @ (id_left_inverse (!a)).
|
//==================================================================================================
/*!
@file
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
//==================================================================================================
#ifndef BOOST_SIMD_ARCH_COMMON_SCALAR_FUNCTION_IDIVNEARBYINT_HPP_INCLUDED
#define BOOST_SIMD_ARCH_COMMON_SCALAR_FUNCTION_IDIVNEARBYINT_HPP_INCLUDED
// workaround for "idivnearbyint(a0/a1) in floating scalar mode when a0 is non zero and a1 is zero
// with clang 3.7 and 3.8
// 04/24/2016
#include <boost/predef/compiler.h>
#if BOOST_COMP_CLANG >= BOOST_VERSION_NUMBER(3,7,0)
#include <boost/simd/constant/nan.hpp>
#include <boost/simd/constant/valmin.hpp>
#include <boost/simd/constant/valmax.hpp>
#include <boost/simd/function/bitwise_or.hpp>
#include <boost/simd/function/inearbyint.hpp>
#include <boost/simd/function/is_negative.hpp>
#include <boost/simd/detail/dispatch/function/overload.hpp>
#include <boost/simd/detail/dispatch/meta/as_integer.hpp>
#include <boost/config.hpp>
namespace boost { namespace simd { namespace ext
{
BOOST_DISPATCH_OVERLOAD ( div_
, (typename A0)
, bd::cpu_
, bs::tag::inearbyint_
, bd::scalar_< bd::floating_<A0> >
, bd::scalar_< bd::floating_<A0> >
)
{
using result_t = bd::as_integer_t<A0>;
BOOST_FORCEINLINE result_t operator() ( bd::functor<bs::tag::inearbyint_> const&
, A0 const& a0, A0 const& a1) const BOOST_NOEXCEPT
{
if (a1) return inearbyint(a0/a1);
if (!a0) return Nan<result_t>();
return is_negative(bitwise_or(a0, a1)) ? Valmin<result_t>() : Valmax<result_t>();
}
};
BOOST_DISPATCH_OVERLOAD ( div_
, (typename A0)
, bd::cpu_
, bs::tag::inearbyint_
, bd::scalar_< bd::arithmetic_<A0> >
, bd::scalar_< bd::arithmetic_<A0> >
)
{
BOOST_FORCEINLINE A0 operator() ( bd::functor<bs::tag::inearbyint_> const&,
A0 a0, A0 a1) const BOOST_NOEXCEPT
{
return div(nearbyint, a0, a1);
}
};
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4723) // potential divide by 0
#endif
BOOST_DISPATCH_OVERLOAD ( div_
, (typename A0)
, bd::cpu_
, bs::tag::inearbyint_
, bd::scalar_< bd::floating_<A0> >
, bd::scalar_< bd::floating_<A0> >
)
{
BOOST_FORCEINLINE bd::as_integer_t<A0> operator() ( bd::functor<bs::tag::inearbyint_> const&
, A0 a0
, A0 a1) const BOOST_NOEXCEPT
{
return inearbyint(a0/a1);
}
};
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
} } }
#endif
#endif
|
-- Copyright 2017, the blau.io contributors
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
module API.Web.Time.HighResolution
%access public export
%default total
||| The DOMHighResTimeStamp type is used to store a time value in milliseconds,
||| measured relative from the time origin, global monotonic clock, or a time
||| value that represents a duration between two DOMHighResTimeStamp's.
|||
||| The original specification can be found at
||| https://w3c.github.io/hr-time/#dom-domhighrestimestamp
DOMHighResTimeStamp : Type
DOMHighResTimeStamp = Double
|
import numpy as np
import random
from glob import glob
import warnings
from collections import defaultdict, Counter
from classification_indicies import NamedMulticlassIndices
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import OneHotEncoder
from sklearn.preprocessing import LabelEncoder
from sklearn.tree import ExtraTreeClassifier
from sklearn.ensemble import ExtraTreesClassifier
from sklearn.neighbors import RadiusNeighborsClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.naive_bayes import BernoulliNB
from sklearn.naive_bayes import GaussianNB
from sklearn.semi_supervised import LabelSpreading
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
from sklearn.neighbors import NearestCentroid
from sklearn.linear_model import LogisticRegression
from sklearn.linear_model import LogisticRegressionCV
from sklearn.linear_model import RidgeClassifier
from sklearn.linear_model import RidgeClassifierCV
from sklearn.svm import LinearSVC
from sklearn.tree import DecisionTreeClassifier
from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis
from sklearn.neural_network import MLPClassifier
from sklearn.neighbors import KNeighborsClassifier
EPS = 1e-5
SEED = 42
random.seed(SEED)
np.random.seed(SEED)
cast_fns_base = {
'float' : lambda x:float(x),
'int' : lambda x:int(x),
'float_int' : lambda x:float(x) if '.' in str(x) else float(int(x)),
'str' : lambda x:str(x),
'class' : lambda x:str(x)
}
classifiers = (
("DecisionTree", DecisionTreeClassifier(max_depth=5)),
("ExtraTree", ExtraTreeClassifier(max_depth=5)),
("ExtraTreesEnsemble", ExtraTreesClassifier(max_depth=5)),
("NearestNeighbors", KNeighborsClassifier(3)),
("RadiusNeighbors", RadiusNeighborsClassifier(radius=10.)),
("RandomForest", RandomForestClassifier(max_depth=5, n_estimators=10, max_features=1)),
("BernoulliNB", BernoulliNB()),
("GaussianNB", GaussianNB()),
("LabelSpreading", LabelSpreading()),
("QuadraticDiscriminantAnalysis", QuadraticDiscriminantAnalysis()),
("LinearDiscriminantAnalysis", LinearDiscriminantAnalysis()),
("NearestCentroid", NearestCentroid()),
("MLPClassifier", MLPClassifier(alpha=1, max_iter=1000)),
("LogisticRegression", LogisticRegression(multi_class="multinomial")),
("LogisticRegressionCV", LogisticRegressionCV(multi_class="multinomial")),
("RidgeClassifier", RidgeClassifier()),
("RidgeClassifierCV", RidgeClassifierCV()),
("LinearSVC", LinearSVC(multi_class="crammer_singer")),
)
classification_results = dict()
exps = set()
le = LabelEncoder()
for dataset_name in glob(f'data/multiclass/*.tsv'):
# load and parse dataset
lines = open(dataset_name, encoding='utf-8').read().split('\n')
converters = dict()
fnames = []
formats = []
for idx, dtype in enumerate(lines[0].split('\t')):
converters[idx] = cast_fns_base[dtype]
fnames.append( f'f{idx:03}' )
sdtype = dtype.replace('class','str').replace('str','STR')[0]
if sdtype == 'S':
sdtype += '100'
else:
sdtype += '8'
formats.append( sdtype )
data = np.loadtxt(dataset_name, delimiter='\t', converters=converters, skiprows=1, dtype={'names': fnames, 'formats': formats}, encoding='utf-8')
recoded_data = []
for idx, c in enumerate(formats):
if c[0]!='S':
recoded_data.append( list(zip(*data))[idx] )
continue
encoded = le.fit_transform(list(zip(*data))[idx])
recoded_data.append( encoded )
y = np.array(recoded_data[0])
X = np.array(list(zip(*recoded_data[1:])))
# scale and split data
X = StandardScaler().fit_transform(X)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.25, random_state=42)
# iterate over classifiers
for cls_name, clf in classifiers:
with warnings.catch_warnings():
warnings.simplefilter('ignore')
# train
clf.fit(X_train, y_train)
# predict
preds = clf.predict(X_test)
# measure indicies
for metric_name, metric_fn in NamedMulticlassIndices.items():
classification_results[(dataset_name, cls_name, metric_name)] = metric_fn(y_test, preds)
exps.add( (dataset_name, cls_name) )
metrics = list(sorted(NamedMulticlassIndices.keys()))
found_examples = defaultdict(list)
discr_examples = defaultdict(list)
full_examples = set()
sampled_metrics = defaultdict(dict)
for ds, alg in exps:
sample = dict()
for m in metrics:
sample[m] = classification_results[(ds, alg, m)]
sampled_metrics[ds][alg] = sample
for ds in sampled_metrics:
for i, (a1, cmp1) in enumerate(sampled_metrics[ds].items()):
for j, (a2, cmp2) in enumerate(sampled_metrics[ds].items()):
if i<j:
left_winners = []
right_winners = []
draw_cases = []
for m in NamedMulticlassIndices:
if np.isnan(cmp1[m]) or np.isnan(cmp2[m]):
continue
if cmp1[m]>cmp2[m] and abs(cmp1[m]-cmp2[m])>EPS:
left_winners.append( (m,i,j) )
if cmp1[m]<cmp2[m] and abs(cmp1[m]-cmp2[m])>EPS:
right_winners.append( (m,i,j) )
if abs(cmp1[m]-cmp2[m])<=EPS:
draw_cases.append( (m,i,j) )
handle = (a1,a2)
full_examples.add(handle)
if left_winners and right_winners:
for r1 in left_winners:
for r2 in right_winners:
pair = tuple(sorted((r1[0],r2[0])))
found_examples[handle].append( pair )
discr_examples[ pair ].append( handle )
elif left_winners and draw_cases:
for r1 in left_winners:
for r2 in draw_cases:
pair = tuple(sorted((r1,r2)))
found_examples[handle].append( pair )
discr_examples[ pair ].append( handle )
elif right_winners and draw_cases:
for r1 in right_winners:
for r2 in draw_cases:
pair = tuple(sorted((r1,r2)))
found_examples[handle].append( pair )
discr_examples[ pair ].append( handle )
else:
if handle not in found_examples:
found_examples[handle] = list()
possible = set()
for m1 in NamedMulticlassIndices:
for m2 in NamedMulticlassIndices:
if m1!=m2:
possible.add( tuple(sorted([m1,m2])) )
print(f'Finally, disciminated {len(discr_examples)} pairs out of {len(possible)} total.')
print(f'{len(possible-set(discr_examples))} are left:', tuple(sorted(possible-set(discr_examples))) )
print()
totals = set()
print('\t'+'\t'.join(metrics))
for r1 in sorted(NamedMulticlassIndices):
r = [r1]
for r2 in sorted(NamedMulticlassIndices):
totals.add(tuple(sorted([r1,r2])))
n = len(discr_examples[
tuple(sorted([r1,r2]))
]
)
if n:
r.append( str( n ) )
else:
r.append( '' )
print('\t'.join(r))
print('total', len(full_examples)) |
Set Implicit Arguments.
Require Import Metalib.Metatheory.
Require Import Program.Equality.
Require Export Progress.
Require Export Coq.micromega.Lia.
(* The first one is for recursive,
the second one is for universal. *)
Definition menv := list (nat * nat).
Notation empty_menv := (@nil (nat * nat)).
Definition genv := list (atom * nat).
Fixpoint find (n:nat) (E: list (nat * nat)) :=
match E with
| (k, v) :: E' =>
if (n == k) then Some v else find n E'
| nil => None
end.
Fixpoint findX (x:var) (G: list (atom * nat)) :=
match G with
| (k, v) :: E' =>
if (x == k) then Some v else findX x E'
| nil => None
end.
Fixpoint bindings_rec (G:genv) (E: menv) (n: nat) (T:typ) : nat :=
match T with
| typ_nat => 1
| typ_top => 1
| typ_fvar x => 1 + match findX x G with
| Some k => k
| None => 1
end
| typ_bvar m => 1 + match find (n - m) E with
| Some k => k
| None => 1
end
| typ_arrow A B => S (bindings_rec G E n A) + (bindings_rec G E n B)
| typ_label _ A => S (bindings_rec G E n A)
| typ_all A B =>
let i := bindings_rec G E n A in
S (i + (bindings_rec G ((S n, i) :: E) (S n) B))
| typ_mu A =>
let i := bindings_rec G ((S n , 1) :: E) (S n) A in
S (bindings_rec G ((S n, i) :: E) (S n) A)
| typ_rcd_nil => 1
| typ_rcd_cons i T1 T2 =>
S (bindings_rec G E n T1) + (bindings_rec G E n T2)
end.
Fixpoint mk_benv (E:env) : genv :=
match E with
| nil => nil
| (_, bind_typ _)::E' => mk_benv E'
| (X, bind_sub U)::E' =>
let G := mk_benv E' in
(X, bindings_rec G nil 0 U) :: G
end.
Definition bindings E T := bindings_rec (mk_benv E) nil 0 T.
Definition zero := 0.
Lemma bindings_find_in: forall (E1 E2:menv) k,
find 0 (E1 ++ E2) = None ->
find 0 (E1 ++ (0, k) :: E2) = Some k.
Proof with auto.
induction E1...
intros.
destruct a.
simpl in *.
destruct n;simpl in *...
inversion H.
Qed.
Lemma bindings_find_notin: forall (E1 E2:menv) k (n:nat),
find (S n) (E1 ++ (0, k) :: E2) = find (S n) (E1++E2).
Proof with auto.
induction E1;intros...
-
destruct a...
simpl...
destruct (S n == n0)...
Qed.
(* WFC typ n : type with <= k binded variables *)
Inductive WFC : typ -> nat -> Prop :=
| WC_nat: forall k,
WFC typ_nat k
| WC_top: forall k,
WFC typ_top k
| WC_fvar: forall X k,
WFC (typ_fvar X) k
| WC_bvar: forall b k,
b <= k ->
WFC (typ_bvar b) k
| WC_arrow: forall A B k,
WFC A k ->
WFC B k ->
WFC (typ_arrow A B) k
| WC_all : forall A B n,
WFC A n ->
WFC B (S n) ->
WFC (typ_all A B) n
| WC_rec: forall A n,
WFC A (S n) ->
WFC (typ_mu A) n
| WC_label: forall l A k,
WFC A k ->
WFC (typ_label l A) k
| WC_nil: forall k,
WFC typ_rcd_nil k
| WC_cons: forall i A B k,
WFC A k ->
WFC B k ->
WFC (typ_rcd_cons i A B) k
.
(* WFC typ n : type with < k binded variables *)
Inductive WFD : typ -> nat -> Prop :=
| WD_nat: forall k,
WFD typ_nat k
| WD_top: forall k,
WFD typ_top k
| WD_fvar: forall X k,
WFD (typ_fvar X) k
| WD_bvar: forall b k,
b < k ->
WFD (typ_bvar b) k
| WD_arrow: forall A B k,
WFD A k ->
WFD B k ->
WFD (typ_arrow A B) k
| WD_rec: forall A n,
WFD A (S n) ->
WFD (typ_mu A) n
| WD_all: forall A B n,
WFD A n ->
WFD B (S n) ->
WFD (typ_all A B) n
| WD_rcd: forall l A k,
WFD A k ->
WFD (typ_label l A) k
| WD_nil: forall k,
WFD typ_rcd_nil k
| WD_cons: forall i A B k,
WFD A k ->
WFD B k ->
WFD (typ_rcd_cons i A B) k
.
Inductive WFE : menv -> nat -> Prop :=
| WFE_empty:
WFE nil 0
| WFE_cons: forall b E k,
WFE E k ->
find (S k) E = None ->
WFE ((S k,b)::E) (S k).
Hint Constructors WFC WFD WFE: core.
Fixpoint minusk (E:menv) (k:nat): menv :=
match E with
| nil => nil
| (a,b)::E' => (a - k,b)::(minusk E' k)
end.
Fixpoint maxfst (E:menv) : nat :=
match E with
| nil => 0
| (a,_)::E' => max a (maxfst E')
end.
Lemma WFE_maxfst : forall E k,
WFE E k ->
maxfst E <= k.
Proof with auto.
induction 1...
simpl...
destruct (maxfst E)...
lia.
Qed.
Lemma maxfst_find_none: forall E k,
maxfst E <= k ->
find (S k) E = None.
Proof with auto.
induction E;intros...
destruct a.
simpl in *...
destruct (S k == n)...
lia.
apply IHE...
lia.
Qed.
Lemma WFE_find_none: forall k E,
WFE E k ->
find (S k) E = None.
Proof with auto.
intros.
apply maxfst_find_none...
apply WFE_maxfst...
Qed.
Lemma WFE_S_n:forall E n k,
WFE E n ->
WFE ((S n, k)::E) (S n).
Proof with auto.
induction E;intros...
constructor...
apply WFE_find_none...
Qed.
Lemma neq_minus: forall k n,
n <= k ->
n <> k ->
exists q, k - n = S q.
Proof with auto.
induction k;intros...
inversion H...
destruct H0...
induction n...
exists k...
destruct IHk with (n:=n)...
lia.
exists x...
Qed.
Lemma neq_minus_v2: forall k n,
n < k ->
exists q, k - n = S q.
Proof with auto.
induction k;intros...
inversion H...
induction n...
exists k...
destruct IHk with (n:=n)...
lia.
exists x...
Qed.
Fixpoint addone (E:menv) : menv :=
match E with
| nil => nil
| (a,b)::E' => (S a,b)::(addone E')
end.
Lemma find_add_eq: forall E k,
find k E = find (S k) (addone E).
Proof with auto.
induction E;intros...
destruct a...
simpl...
destruct (k == n) ...
destruct (S k == S n)...
destruct n1...
destruct (S k == S n)...
destruct n1...
Qed.
Lemma find_add: forall E k b,
k >= b ->
find (k - b) E = find (S k - b) (addone E).
Proof with auto using find_add_eq.
induction E;intros...
-
destruct a...
assert (addone ((n, n0) :: E) = (S n, n0) :: addone E) by auto.
rewrite H0.
assert (S k - b = S (k-b)) by lia.
rewrite H1.
destruct (k-b);simpl...
destruct (0==n)...
destruct (1== S n)...
destruct n1...
destruct (1== S n)...
destruct n1...
destruct (S n1 == n)...
destruct (S (S n1) == S n)...
destruct n2...
destruct (S (S n1) == S n)...
destruct n2...
Qed.
Lemma bindings_add : forall E n A G,
WFC A n ->
bindings_rec G E n A = bindings_rec G (addone E) (S n) A.
Proof with auto.
intros.
generalize dependent E.
induction H;intros;try solve [simpl;auto]...
-
simpl.
rewrite find_add...
-
(* all *)
simpl. f_equal.
rewrite <- IHWFC1.
replace ((S (S n), bindings_rec G E n A) :: addone E)
with (addone ((S n, bindings_rec G E n A) :: E))...
-
simpl...
f_equal...
assert (bindings_rec G ((S (S n), 1) :: addone E) (S (S n)) A =
bindings_rec G (addone ((S n, 1)::E)) (S (S n)) A) by auto.
rewrite H0...
rewrite <- IHWFC ...
remember ((bindings_rec G ((S n, 1) :: E) (S n) A)).
assert ((S (S n), n0) :: addone E = addone ((S n,n0)::E)) by auto.
rewrite H1.
rewrite <- IHWFC...
Qed.
Fixpoint close_tt_rec (K : nat) (Z : atom) (T : typ) {struct T} : typ :=
match T with
| typ_nat => typ_nat
| typ_top => typ_top
| typ_bvar J => typ_bvar J
| typ_fvar X => if X == Z then typ_bvar K else typ_fvar X
| typ_arrow T1 T2 => typ_arrow (close_tt_rec K Z T1) (close_tt_rec K Z T2)
| typ_mu T => typ_mu (close_tt_rec (S K) Z T)
| typ_all A B => typ_all (close_tt_rec K Z A)
(close_tt_rec (S K) Z B)
| typ_label l T => typ_label l (close_tt_rec K Z T)
| typ_rcd_nil => typ_rcd_nil
| typ_rcd_cons i A B => typ_rcd_cons i (close_tt_rec K Z A) (close_tt_rec K Z B)
end.
Definition close_tt T X := close_tt_rec 0 X T.
Lemma close_wfc : forall A X,
WFC A 0 ->
WFC (close_tt A X) 0.
Proof with auto.
intros A.
unfold close_tt.
generalize 0.
induction A;intros;try solve [dependent destruction H;simpl in *;auto]...
-
simpl...
destruct (a==X)...
Qed.
Lemma WFC_add_one : forall A k,
WFC A k -> WFC A (S k).
Proof with auto.
intros.
induction H...
Qed.
Lemma close_wfd : forall A X,
WFD A 0 ->
WFD (close_tt A X) 1.
Proof with auto.
intros A.
unfold close_tt.
generalize 0.
induction A;intros;try solve [dependent destruction H;simpl in *;auto]...
-
simpl...
destruct (a==X)...
Qed.
Lemma close_open_reverse_rec: forall T X,
(X \notin fv_tt T) -> forall k, T = close_tt_rec k X (open_tt_rec k (typ_fvar X) T).
Proof with auto.
intros T.
induction T;intros;simpl in *;try solve [f_equal;auto]...
-
destruct (k==n)...
simpl...
destruct (X==X)...
destruct n0...
-
destruct (a==X)...
apply notin_singleton_1 in H...
destruct H...
Qed.
Lemma close_open_reverse: forall T X,
(X \notin fv_tt T) -> T = close_tt (open_tt T (typ_fvar X)) X.
Proof with auto.
intros.
apply close_open_reverse_rec...
Qed.
Lemma close_type_wfc: forall A,
type A -> WFC A 0.
Proof with auto.
intros.
induction H;intros...
- constructor...
apply WFC_add_one.
pick fresh X.
specialize_x_and_L X L.
apply close_wfc with (X:=X) in H0.
rewrite <- close_open_reverse in H0...
- (* WFC_all *)
constructor...
apply WFC_add_one.
pick_fresh X.
specialize_x_and_L X L.
apply close_wfc with (X:=X) in H1.
rewrite <- close_open_reverse in H1...
Qed.
Lemma close_type_wfd: forall A,
type A -> WFD A 0.
Proof with auto.
intros.
induction H;intros...
- pick fresh X.
specialize_x_and_L X L.
constructor...
apply close_wfd with (X:=X) in H0.
rewrite <-close_open_reverse in H0...
- (* WFD_all *)
constructor...
pick_fresh X.
specialize_x_and_L X L.
apply close_wfd with (X:=X) in H1.
rewrite <- close_open_reverse in H1...
Qed.
Lemma type_open_tt_WFC :forall T X,
X \notin fv_tt T ->
type (open_tt T X) ->
WFC T 0.
Proof with auto.
intros.
apply close_type_wfc in H0.
apply close_wfc with (X:=X) in H0...
rewrite <- close_open_reverse in H0...
Qed.
Lemma WFE_find_in: forall E k,
WFE E k ->
forall q n, 0 < n ->
q < n ->
find n E = find (n - q) (minusk E q).
Proof with auto.
intros E k H.
induction H;intros...
remember (n-q).
assert (minusk ((S k, b) :: E) q = (S k - q, b) :: (minusk E q)) as W by (simpl;auto).
rewrite W.
remember (S k - q).
simpl...
destruct (n==S k);destruct (n0==n1)...
lia.
lia.
subst.
apply IHWFE...
Qed.
Lemma bindings_WFD_drop: forall E n b q G,
WFE E n -> q < n - b ->
bindings_rec G E n b = bindings_rec G (minusk E q) (n - q) b.
Proof with auto.
induction E;intros...
dependent destruction H.
assert (minusk ((S k, b0) :: E) q = (S k - q, b0) :: (minusk E q)) as W1 by (simpl;auto).
rewrite W1...
remember (S k - q).
remember (S k).
simpl...
destruct (n-b == n);destruct (n0-b==n0)...
lia.
lia.
subst.
assert (S k - q - b = (S k - b) - q) as W2 by lia.
rewrite W2.
assert (0 < S k - b) as W3 by lia.
remember (S k - b).
rewrite <- WFE_find_in with (k:=k)...
Qed.
Lemma bindings_WFD_WFE: forall A k n E q G,
WFD A k-> WFE E n -> k <= n - q -> q <= n ->
bindings_rec G E n A = bindings_rec G (minusk E q) (n-q) A.
Proof with auto using WFE_S_n.
intros.
generalize dependent E.
generalize dependent n.
generalize dependent q.
induction H;intros;try solve [simpl in *;auto]...
-
assert (q < n-b). lia.
apply bindings_WFD_drop...
- (* typ_mu *)
simpl...
f_equal.
remember (bindings_rec G ((S (n0 - q), 1) :: minusk E q) (S (n0 - q)) A).
assert (S (n0 - q) = (S n0) - q) as W by lia.
rewrite W.
assert ( ((S n0 - q, n1) :: minusk E q) = minusk ((S n0, n1)::E) q) as W2 by (simpl;auto).
rewrite W2.
rewrite <- IHWFD...
f_equal...
f_equal...
f_equal...
f_equal...
subst.
rewrite W.
assert ((S n0 - q, 1) :: minusk E q = minusk ((S n0, 1)::E) q) as W3 by (simpl;auto).
rewrite W3.
rewrite <- IHWFD...
lia.
lia.
- (* typ_all *)
simpl...
f_equal.
rewrite <- IHWFD1... f_equal.
replace (S (n0 - q)) with (S n0 - q) by lia.
assert ( ((S n0 - q, bindings_rec G E n0 A) :: minusk E q) = minusk ((S n0, bindings_rec G E n0 A)::E) q) as W2 by (simpl;auto).
rewrite W2.
rewrite <- IHWFD2... lia.
Qed.
Lemma find_former: forall (E2 E1:list (nat * nat)) (k:nat),
(exists p, In (k,p) E1) ->
find k E1 = find k (E1++E2).
Proof with auto.
induction E1;intros...
-
inversion H...
inversion H0.
-
destruct a.
destruct H.
destruct (k==n);subst...
+
simpl...
destruct (n==n)...
destruct n1...
+
simpl.
destruct (k == n)...
apply in_inv in H.
destruct H...
dependent destruction H...
destruct n1...
apply IHE1...
exists x...
Qed.
Lemma minus_in_for_bindings: forall E ( n k:nat),
(forall q, exists p, q < n -> In (n - q, p) E) ->
(forall q, exists p, q < S n -> In (S n - q, p) ((S n, k) :: E)).
Proof with auto.
intros.
destruct n.
-
destruct q.
exists k...
intros.
simpl...
exists 0...
intros.
lia.
-
destruct q...
exists k.
intros.
simpl...
destruct H with (q:=q)...
exists x.
intros.
assert (S (S n) - S q = S n - q).
lia.
rewrite H2.
apply in_cons...
apply H0...
lia.
Qed.
Lemma bindings_close_env_aux: forall G A k,
WFD A k-> forall E1 E2 ,
(forall q, exists p, q < k -> In (k-q,p) E1) ->
bindings_rec G (E1++E2) k A = bindings_rec G E1 k A.
Proof with eauto.
intros G A k H.
induction H;intros;try solve [simpl in *;auto]...
-
simpl...
assert (find (k - b) E1 = find (k - b) (E1++E2)).
{
rewrite find_former with (E2:=E2)...
destruct H0 with (q:=b)...
}
rewrite H1...
-
simpl.
f_equal.
remember (bindings_rec G ((S n, 1) :: E1 ++ E2) (S n) A).
rewrite_env (((S n, n0) :: E1) ++ E2).
rewrite IHWFD...
subst.
rewrite_env (((S n, 1) :: E1) ++ E2).
rewrite IHWFD...
intros.
apply minus_in_for_bindings...
intros.
apply minus_in_for_bindings...
-
simpl. f_equal.
rewrite IHWFD1... f_equal.
remember (bindings_rec G E1 n A).
rewrite_env (((S n, n0) :: E1) ++ E2).
rewrite IHWFD2...
intros.
apply minus_in_for_bindings...
Qed.
Lemma bindings_close_env: forall A E G,
type A->
bindings_rec G E 0 A = bindings_rec G nil 0 A.
Proof with eauto.
intros.
rewrite_env (nil++E).
rewrite_env (nil ++ empty_menv).
apply bindings_close_env_aux...
apply close_type_wfd...
intros.
exists 0.
intros.
lia.
Qed.
Lemma bindings_local_close: forall B E n G,
type B -> WFE E n ->
bindings_rec G E n B = bindings_rec G nil 0 B.
Proof with auto.
intros.
rewrite bindings_WFD_WFE with (k:=0) (q:=n)...
assert (0=n-n ) by lia.
rewrite <- H1.
rewrite bindings_close_env...
apply close_type_wfd...
lia.
Qed.
Lemma bindings_close : forall B a G E n,
type B -> WFE E n ->
bindings_rec G E n B = bindings_rec G ((S n, a) :: E) (S n) B.
Proof with auto.
intros.
rewrite bindings_local_close...
remember (bindings_rec G empty_menv 0 B).
rewrite bindings_local_close...
apply WFE_S_n...
Qed.
Lemma bindings_rec_ge_1: forall G E n A,
bindings_rec G E n A >= 1.
Proof.
intros. revert E n.
induction A;intros;simpl;try solve[lia]...
Qed.
Lemma findX_extend: forall Q G E X T n,
WFD Q n ->
X \notin fv_tt Q ->
WFE E n ->
bindings_rec (mk_benv G) E n Q =
bindings_rec (mk_benv (X ~ T ++ G)) E n Q.
Proof with auto.
intros. generalize dependent E.
induction H;try solve [simpl in H0;simpl;intros;auto];intros...
- simpl. destruct T...
simpl. destruct (X0==X)...
subst. exfalso.
apply H0. simpl...
- simpl. f_equal. destruct T...
rewrite IHWFD... 2:{ constructor... apply WFE_find_none... }
simpl. f_equal. f_equal. f_equal.
rewrite IHWFD... { constructor... apply WFE_find_none... }
- simpl. f_equal. destruct T... simpl in H0.
rewrite IHWFD1... f_equal.
rewrite IHWFD2... { constructor... apply WFE_find_none... }
Qed.
Lemma findX_extend_spec: forall Q E X T,
type Q ->
X \notin fv_tt Q ->
bindings_rec (mk_benv E) nil 0 Q =
bindings_rec (mk_benv (X ~ T ++ E)) nil 0 Q.
Proof with auto.
intros.
apply findX_extend...
apply close_type_wfd...
Qed.
Lemma findX_sem: forall E X Q,
wf_env E ->
binds X (bind_sub Q) E ->
findX X (mk_benv E) = Some (bindings_rec (mk_benv E) nil 0 Q).
Proof with auto.
induction E.
- intros. inversion H0.
- intros. destruct H0.
+ destruct a. inversion H0;subst.
simpl. rewrite eq_dec_refl.
f_equal. rewrite_alist (mk_benv (X ~ bind_sub Q ++ E)).
apply findX_extend_spec...
{ inversion H;subst. apply WF_type in H5... }
rewrite_env (nil ++ X ~ bind_sub Q ++ E) in H.
apply notin_from_wf_env in H...
+ destruct a. simpl. destruct b...
* simpl. destruct (X == a)...
{ subst. inversion H;subst.
exfalso. apply H6.
apply in_split in H0. destruct H0 as [E1 [E2 H1]].
rewrite H1. rewrite dom_app. simpl... }
{ rewrite IHE with (Q:= Q)... 2:{ inversion H... }
rewrite_alist (mk_benv (a ~ bind_sub t ++ E)). f_equal.
apply findX_extend_spec...
{ inversion H;subst. apply in_split in H0. destruct H0 as [? [? ?]].
rewrite H0 in H4. apply WF_from_binds_typ_strong in H4.
apply WF_type in H4... }
{ rewrite_env (nil ++ a ~ bind_sub t ++ E) in H.
apply notin_from_wf_env in H.
assert (binds X (bind_sub Q) E)...
apply notin_fv_tt_fv_env with (E:=E) (Y:=X)...
}
}
* inversion H...
Qed.
Lemma bindings_find: forall A G E1 E2 B,
find zero (E1++E2) = None ->
type B ->
WFC A 0 ->
WFE (E1++E2) 0 ->
(bindings_rec G (E1++E2) 0 (open_tt A B)) =
bindings_rec G (E1 ++ (zero, (bindings_rec G (E1++E2) 0 B) - 1) :: E2) 0 A.
Proof with auto.
intro A.
unfold open_tt. remember 1 as one.
generalize 0.
unfold zero. subst one.
induction A;intros;try solve [dependent destruction H1;simpl;auto]...
- destruct (n0==n);subst...
+
assert (open_tt_rec n B n = B) as Q.
{
simpl...
destruct (n==n)...
destruct n0...
}
rewrite Q.
simpl.
rewrite Nat.sub_diag.
rewrite bindings_find_in...
pose proof bindings_rec_ge_1 G (E1 ++ E2) n B.
lia.
+
assert (open_tt_rec n0 B n = n) as Q.
{
simpl...
destruct (n0==n)...
destruct e...
destruct n1...
}
rewrite Q.
simpl.
dependent destruction H1.
apply neq_minus in H1...
destruct H1...
rewrite H1.
erewrite <- bindings_find_notin...
- (* all *)
dependent destruction H1.
simpl. f_equal.
rewrite IHA1... f_equal.
remember ((S n,
bindings_rec G (E1 ++ (0, bindings_rec G (E1 ++ E2) n B - 1) :: E2) n A1)) as R1.
assert (bindings_rec G (E1++E2) n B = bindings_rec G (R1 :: E1++E2) (S n) B) as Q1.
subst.
apply bindings_close...
rewrite Q1.
rewrite_alist ((R1 :: E1) ++ (0, bindings_rec G ((R1 :: E1) ++ E2) (S n) B - 1) :: E2).
rewrite <- IHA2...
rewrite_alist (R1 :: E1 ++E2)...
subst...
rewrite_env (R1 :: E1 ++ E2).
subst.
apply WFE_S_n...
-
dependent destruction H1...
simpl.
f_equal.
remember (S n,
(bindings_rec G
((S n, 1) :: E1 ++ (0, bindings_rec G (E1 ++ E2) n B - 1) :: E2)
(S n) A)) as R1.
assert (bindings_rec G (E1++E2) n B = bindings_rec G (R1 :: E1++E2) (S n) B) as Q1.
subst.
apply bindings_close...
rewrite Q1.
rewrite_alist ((R1 :: E1) ++ (0, bindings_rec G ((R1 :: E1) ++ E2) (S n) B - 1) :: E2).
rewrite <- IHA...
f_equal...
remember (bindings_rec G ((S n, 1) :: E1 ++ E2) (S n) (open_tt_rec (S n) B A)) as R2.
rewrite_alist (R1 :: E1 ++ E2).
f_equal.
subst.
f_equal...
(* f_equal. *)
assert (bindings_rec G (E1++E2) n B = bindings_rec G (((S n, 1) :: E1)++E2) (S n) B) as Q2.
apply bindings_close...
rewrite Q2.
rewrite_alist (((S n, 1) :: E1) ++ (0, bindings_rec G (((S n, 1) :: E1) ++ E2) (S n) B - 1) :: E2).
rewrite <- IHA...
rewrite_env ((S n, 1) :: E1 ++ E2).
apply WFE_S_n...
rewrite_alist (R1 :: E1 ++E2)...
subst...
rewrite_env (R1 :: E1 ++ E2).
subst.
apply WFE_S_n...
Qed.
Lemma bindings_find_spec: forall A G E B,
find zero E = None ->
type B ->
WFC A 0 ->
WFE E 0 ->
bindings_rec
(mk_benv G) E 0 (open_tt A B) =
bindings_rec
(mk_benv G) ((zero, (bindings_rec (mk_benv G) E 0 B - 1)) :: E) 0 A.
Proof with auto.
intros.
rewrite_env (nil ++ (zero, (bindings_rec (mk_benv G) E 0 B - 1)) :: E).
rewrite_env (nil ++ E).
apply bindings_find...
Qed.
(* minus one because we add one to each lookup *)
Lemma bindings_find_spec': forall A G B,
type B ->
WFC A 0 ->
bindings_rec
(mk_benv G) empty_menv 0 (open_tt A B) =
bindings_rec
(mk_benv G) ((1, (bindings_rec (mk_benv G) empty_menv 0 B - 1)) :: empty_menv) 1 A.
Proof with auto.
intros.
rewrite bindings_find_spec...
rewrite bindings_add...
Qed.
Lemma bindings_fvar: forall A G E1 E2 X B,
WFC A 0 ->
X \notin fv_tt A ->
wf_env (X ~ bind_sub B ++ G) ->
find zero (E1++E2) = None ->
type B ->
WFE (E1 ++ E2) 0 ->
bindings_rec (mk_benv (X ~ bind_sub B ++ G)) (E1 ++ E2) 0 (open_tt A X) =
bindings_rec (mk_benv G)
(E1 ++ [(zero, bindings_rec (mk_benv G) (E1 ++ E2) 0 B )] ++ E2) 0 A.
Proof with auto.
intro A.
unfold open_tt.
generalize 0.
unfold zero.
induction A;intros;try solve [dependent destruction H;simpl;auto]...
-
destruct (n0==n);subst...
+
assert (open_tt_rec n X n = X) as Q.
{
simpl...
destruct (n==n)...
destruct n0...
}
rewrite Q.
simpl. destruct (X == X)... 2:{ exfalso... }
rewrite Nat.sub_diag.
rewrite bindings_find_in...
rewrite <- bindings_local_close with (E:=E1 ++ E2) (n:=n)...
+
assert (open_tt_rec n0 X n = n) as Q.
{
simpl...
destruct (n0==n)...
destruct e...
destruct n1...
}
rewrite Q.
simpl.
dependent destruction H.
apply neq_minus in H...
destruct H...
rewrite H.
erewrite <- bindings_find_notin...
-
simpl. destruct (a == X)...
subst X. exfalso. apply H0... simpl...
-
simpl.
dependent destruction H. simpl in H1.
simpl in IHA1. rewrite IHA1...
simpl in IHA2. rewrite IHA2...
-
simpl.
dependent destruction H. simpl in H1.
simpl in IHA1. rewrite IHA1... f_equal. f_equal.
remember (bindings_rec (mk_benv G) (E1 ++ (0, bindings_rec (mk_benv G) (E1 ++ E2) n B) :: E2) n A1) as K.
rewrite_env (
((S n, K)
:: E1) ++ E2
).
simpl in IHA2. rewrite IHA2 at 1...
2:{ constructor... apply WFE_find_none... }
rewrite_alist ((S n, K) :: (E1 ++ E2)).
rewrite <- bindings_close with (B:=B)...
-
simpl.
dependent destruction H. simpl in H0.
f_equal.
remember ((bindings_rec ((X, bindings_rec (mk_benv G) empty_menv 0 B) :: mk_benv G) ((S n, 1) :: E1 ++ E2) (S n) (open_tt_rec (S n) X A))) as K1.
remember (
(bindings_rec (mk_benv G)
((S n, 1) :: E1 ++ (0, bindings_rec (mk_benv G) (E1 ++ E2) n B) :: E2)
(S n) A)) as K2.
rewrite_env (
((S n, K1)
:: E1) ++ E2
). simpl in IHA. rewrite IHA...
2:{ constructor... apply WFE_find_none... }
rewrite_alist ((S n, K1) :: (E1 ++ E2)).
rewrite <- bindings_close with (B:=B)... simpl.
f_equal. f_equal. f_equal. subst K1 K2.
(* f_equal. *)
rewrite_alist (((S n, 1) :: E1) ++ E2).
rewrite IHA...
2:{ constructor... apply WFE_find_none... }
rewrite_alist ((S n, 1) :: (E1 ++ E2)).
rewrite <- bindings_close with (B:=B)...
- simpl. f_equal. simpl in IHA. simpl in H0.
rewrite IHA... inversion H...
-
inversion H;subst. simpl in H0.
simpl. f_equal. simpl in IHA1. simpl in IHA2.
rewrite IHA1...
Qed.
Lemma bindings_fvar_spec: forall G A X B,
WFC A 0 ->
X \notin fv_tt A ->
wf_env (X ~ bind_sub B ++ G) ->
(* find zero (E1++E2) = None -> *)
type B ->
bindings_rec (mk_benv (X ~ bind_sub B ++ G)) empty_menv 0 (open_tt A X) =
bindings_rec (mk_benv G)
((1, bindings_rec (mk_benv G) empty_menv 0 B ) :: empty_menv) 1 A.
Proof with auto.
intros.
rewrite_env (X ~ bind_sub B ++ G).
rewrite_env (empty_menv ++ empty_menv).
rewrite bindings_fvar...
{ simpl. rewrite bindings_add... }
Qed.
Lemma binds_key_dec: forall (E: env) X,
{Q | binds X Q E} + {forall Q, ~ binds X Q E}.
Proof with auto.
induction E...
intros.
destruct a.
destruct (X==a)...
-
subst. left. exists b. simpl...
-
destruct IHE with (X:=X)...
+ destruct s. left. exists x. simpl...
+ right. intros. intros C. destruct C.
* inversion H...
* apply n0 with (Q:=Q)...
Qed.
Lemma WFC_WFD_S : forall A k,
WFC A k -> WFD A (S k).
Proof with auto.
intros.
induction H...
constructor. lia.
Qed.
Inductive sub_menv: menv -> menv -> Prop :=
| sub_menv_nil : sub_menv empty_menv empty_menv
| sub_menv_cons : forall n v1 v2 R1 R2,
v1 <= v2 ->
sub_menv R1 R2 ->
sub_menv ((n, v1) :: R1) ((n, v2) :: R2).
Hint Constructors sub_menv : core.
Lemma sub_menv_find : forall R1 R2 n,
sub_menv R1 R2 ->
match find n R1 with
| Some k => k
| None => 1
end <= match find n R2 with
| Some k => k
| None => 1
end.
Proof with auto.
intros.
induction H.
- simpl...
- simpl in *. destruct (n == n0)...
Qed.
Lemma sub_menv_sem: forall G R1 R2 n A,
sub_menv R1 R2 ->
bindings_rec G R1 n A <= bindings_rec G R2 n A.
Proof with auto.
intros. revert n R1 R2 H.
induction A;intros...
- simpl. apply le_n_S. apply sub_menv_find...
- simpl. specialize (IHA1 n _ _ H).
specialize (IHA2 n _ _ H). lia.
- simpl.
specialize (IHA1 n _ _ H).
assert (sub_menv
((S n, (bindings_rec G R1 n A1)) :: R1)
((S n, (bindings_rec G R2 n A1)) :: R2)).
{ constructor... }
specialize (IHA2 (S n) _ _ H0).
lia.
- simpl.
assert (sub_menv ((S n, 1) :: R1) ((S n, 1) :: R2))...
pose proof IHA (S n) _ _ H0.
assert (sub_menv
(((S n, (bindings_rec G ((S n, 1) :: R1) (S n) A)) :: R1))
(((S n, (bindings_rec G ((S n, 1) :: R2) (S n) A)) :: R2))
)...
pose proof IHA (S n) _ _ H2. lia.
- simpl. specialize (IHA n _ _ H). lia.
- simpl. specialize (IHA1 n _ _ H). specialize (IHA2 n _ _ H).
lia.
Qed.
Ltac solve_right_dec := right;intro v;inversion v;try inv_rt;auto.
Lemma WFC_dec : forall m A,
{WFC A m} + {~ WFC A m}.
Proof with auto.
intros. revert m.
induction A;intros...
- destruct (le_gt_dec n m)...
right. intros C. inversion C;lia.
- destruct (IHA1 m); try solve [solve_right_dec].
destruct (IHA2 m); try solve [solve_right_dec]...
- destruct (IHA1 m); try solve [solve_right_dec].
destruct (IHA2 (S m)); try solve [solve_right_dec]...
- destruct (IHA (S m)); try solve [solve_right_dec]...
- destruct (IHA m); try solve [solve_right_dec]...
- destruct (IHA1 m); try solve [solve_right_dec].
destruct (IHA2 (m)); try solve [solve_right_dec]...
Qed.
Lemma wf_fvar_dec: forall E (a:atom),
uniq E ->
{WF E a} + {~ WF E a}.
Proof with auto.
intros.
pose proof binds_key_dec E a.
destruct H0.
{ destruct s. destruct x.
* left. apply WF_var with (U:=t)...
* right. intros C. inversion C;subst.
pose proof binds_unique _ _ _ _ _ b H2 H.
inversion H0.
}
{ right. intros C.
inversion C;subst.
apply n with (Q:=bind_sub U)...
}
Qed.
Lemma findX_notin: forall G X,
X \notin dom G ->
findX X G = None.
Proof with auto.
induction G;intros...
simpl in *.
destruct a.
destruct (X==a)...
apply notin_add_1 in H.
destruct H...
Qed.
Lemma rt_type_dec: forall A,
{ rt_type A } + { ~ rt_type A }.
Proof with auto.
intros. destruct A;try solve [left;constructor|right;intros C;inversion C].
Qed.
Lemma collectLabelDec: forall i A,
{ i `in` collectLabel A } + { i `notin` collectLabel A }.
Proof with auto.
intros. induction A;try solve [right;simpl;apply notin_empty_1].
- simpl. destruct IHA2.
+ left. apply union_iff. right...
+ destruct (i == a)...
Qed.
Lemma wf_dec_aux : forall G k A E,
uniq E ->
(* new constraint,
to show (binds a typ) -> (binds a sub) -> False
uniq should be decidable, indeed
*)
bindings_rec G nil 0 A <= k ->
{WF E A} + {~ WF E A}.
Proof with auto.
induction k.
-
induction A;intros;try solve [simpl in *;exfalso;lia]...
(*
+ (* bvar *)
right. intros C. inversion C.
+ (* fvar *)
apply wf_fvar_dec...
*)
-
unfold bindings in *.
induction A;intros;try solve [ solve_right_dec]...
+ (* fvar *)
apply wf_fvar_dec...
+ (* arrow *)
simpl in H0.
destruct IHA1 with (E:=E);destruct IHA2 with (E:=E);try solve [lia|solve_right_dec]...
+ (* all *)
simpl in H0.
destruct IHA1 with (E:=E);try solve [lia|solve_right_dec]...
assert (type A1). { apply WF_type with (E:=E)... }
destruct (WFC_dec 0 A2).
2:{ right. intros C. apply WF_type in C.
inversion C;subst. apply n.
pick_fresh X.
apply type_open_tt_WFC with (X:=X)... }
pick fresh X.
remember (open_tt A2 X) as Q1.
destruct IHk with (A:=Q1) (E:= X ~ bind_sub A1 ++ E)...
{ subst. rewrite_alist (empty_menv ++ empty_menv).
rewrite bindings_find...
rewrite bindings_add... unfold zero. simpl.
simpl.
eapply le_trans.
{ apply sub_menv_sem with
(R2:=((1, bindings_rec G empty_menv 0 A1) :: empty_menv)).
constructor...
rewrite findX_notin...
simpl.
apply bindings_rec_ge_1. }
lia.
}
* (* A2 is well formed *)
left. apply WF_all with (L:={{X}} \u fv_tt A2 \u dom E)...
intros. subst Q1.
apply WF_replacing_var with (X:=X)...
* (* A2 is not well formed *)
right. intros C. apply n. subst Q1.
dependent destruction C. pick_fresh Y.
specialize_x_and_L Y L.
apply WF_replacing_var with (X:=Y)...
+ (* mu *)
simpl in H0.
destruct (WFC_dec 0 A).
2:{ right. intros C. apply WF_type in C.
inversion C;subst. apply n.
pick_fresh X.
apply type_open_tt_WFC with (X:=X)... }
pick fresh X.
remember (open_tt A X) as Q1.
remember (open_tt A (typ_label X (open_tt A X))) as Q2.
destruct IHk with (A:=Q1) (E:= X ~ bind_sub typ_top ++ E)...
{ subst. rewrite_alist (empty_menv ++ empty_menv).
rewrite bindings_find...
rewrite bindings_add... unfold zero. simpl.
rewrite findX_notin...
simpl.
eapply le_trans.
{ apply sub_menv_sem with
(R2:=((1, (bindings_rec G ((1, 1) :: empty_menv) 1 A)) :: empty_menv)).
constructor...
apply bindings_rec_ge_1. }
lia. }
* (* open_tt A X is well-formed *)
destruct IHk with (A:=Q2) (E:= X ~ bind_sub typ_top ++ E)...
{ subst. rewrite_alist (empty_menv ++ empty_menv).
rewrite bindings_find...
2:{ apply WF_type in w0... }
simpl.
replace (bindings_rec G empty_menv 0 (open_tt A X))
with (bindings_rec G ((1, match findX X G with
| Some k => k | None => 1 end )::empty_menv) 1 A).
2:{ rewrite_alist (empty_menv ++ empty_menv).
rewrite bindings_find... simpl.
rewrite bindings_add with (n:=0)... unfold zero...
rewrite Nat.sub_0_r... }
rewrite bindings_add with (n:=0)...
simpl. unfold zero.
apply le_S_n in H0.
eapply le_trans. 2:{ apply H0. }
apply sub_menv_sem.
constructor...
rewrite findX_notin...
lia. }
** (* A [X |-> {x: A}] is well-formed *)
left. subst Q1 Q2.
apply WF_rec with (L:={{X}} \u fv_tt A \u dom E \u fl_tt A);intros...
apply WF_replacing_var with (X:=X)...
apply WF_replacing' with (Y:=X0) in w1...
rewrite subst_tt_open_tt in w1... simpl in w1.
rewrite subst_tt_open_tt in w1... simpl in w1.
rewrite eq_dec_refl in w1.
rewrite <- subst_tt_fresh in w1...
(* stuck: how to get
WF (X0 ~ bind_sub typ_top ++ E)
(open_tt A (typ_label X0 (open_tt A X0)))
from
WF ((X0, bind_sub typ_top) :: E)
(open_tt A (typ_label X (open_tt A X0)))
*)
apply WF_renaming_tl with (X:=X) (Y:=X0) in w1...
rewrite label_transform in w1...
solve_notin.
** (* A [X |-> {x: A}] is not well-formed *)
right. intros C. apply n. subst Q1 Q2.
inversion C;subst.
pick_fresh Y.
specialize_x_and_L Y L.
apply WF_renaming_unfolding with (X:=Y)...
(* Same issue as above case *)
* (* open_tt A X is not well-formed *)
right. intros C. apply n. subst Q1.
inversion C. subst.
pick_fresh Y.
specialize_x_and_L Y L.
apply WF_replacing_var with (X:=Y)...
+ (* label *)
simpl in H0.
destruct IHA with (E:=E);try solve [lia|solve_right_dec]...
+ (* rcd *)
simpl in H0.
destruct IHA1 with (E:=E);try solve [lia|solve_right_dec]...
destruct IHA2 with (E:=E);try solve [lia|solve_right_dec]...
destruct (rt_type_dec A2);try solve [lia|solve_right_dec]...
destruct (collectLabelDec a A2);try solve [lia|solve_right_dec]...
Qed.
Lemma wf_dec : forall A E,
uniq E ->
{WF E A} + {~ WF E A}.
Proof with auto.
intros.
apply wf_dec_aux with (k:=bindings_rec nil nil 0 A) (G:=nil)...
Qed.
Lemma binds_key_dom_dec: forall (E: env) X,
{X \in dom E} + {X \notin dom E}.
Proof with auto.
induction E...
intros.
destruct a.
destruct (X==a)...
-
subst. left. simpl...
-
destruct IHE with (X:=X)...
left. simpl...
Qed.
Lemma wf_env_dec: forall E,
{wf_env E} + {~wf_env E}.
Proof with auto.
induction E...
destruct IHE.
-
pose proof wf_dec.
assert (Ht:=w).
apply uniq_from_wf_env in Ht.
pose proof binds_key_dom_dec.
destruct a.
destruct b.
+
destruct H with (E:=E) (A:=t)...
destruct H0 with (E:=E) (X:=a)...
*
right.
intros v.
dependent destruction v...
*
left.
constructor...
*
right.
intros v.
dependent destruction v...
+
destruct H with (E:=E) (A:=t)...
destruct H0 with (E:=E) (X:=a)...
*
right.
intros v.
dependent destruction v...
*
left.
constructor...
*
right.
intros v.
dependent destruction v...
-
right.
intros v.
dependent destruction v;
apply n...
Qed.
Ltac solve_top_dec E :=
pose wf_env_dec as Q;destruct Q with (E:=E) as [Ql|Qr];try solve [
left;auto |
solve_right_dec ].
Ltac solve_top_wfs_dec E A :=
match goal with
| H : wf_env E |- _ =>
destruct (wf_dec A (uniq_from_wf_env H));
try solve [left;auto|right;intros v;dependent destruction v;auto]
| _ => idtac
end.
Lemma find_var_one: forall Q G X E n,
X \notin dom G ->
bindings_rec ( G) E n Q =
bindings_rec (X ~ 1 ++ G) E n Q.
Proof with auto.
intros Q G X.
induction Q;intros...
+ simpl. destruct (a == X)...
subst.
rewrite (findX_notin _ H)...
+ simpl. rewrite IHQ1...
+ simpl. rewrite IHQ1...
+ simpl. rewrite IHQ...
f_equal. f_equal. f_equal.
f_equal. rewrite IHQ...
+ simpl...
+ simpl. rewrite IHQ1...
Qed.
Lemma mk_benv_dom: forall X G,
X `notin` dom G -> X `notin` dom (mk_benv G).
Proof with auto.
induction G;intros...
+ intros. destruct a. simpl. destruct b...
Qed.
Lemma bindings_drop_label: forall T E G t i,
WF E T ->
Tlookup i T = Some t ->
S (bindings_rec (mk_benv E) G 0 t + bindings_rec (mk_benv E) G 0 (dropLabel i T)) =
bindings_rec (mk_benv E) G 0 T.
Proof with auto.
intros T.
induction T;intros;try solve [inversion H0]...
+ simpl. simpl in H0. destruct (a == i).
* inversion H0. subst. inversion H;subst...
rewrite dropLable_notin with (E:=E)...
* inversion H;subst...
rewrite <- IHT2 with (t:=t) (i:=i)...
simpl. lia.
Qed.
Lemma subset_dec: forall A B, { A [<=] B} + { ~ A [<=] B}.
Proof with auto.
intros. destruct (AtomSetImpl.subset A B) eqn:E'.
+ apply subset_iff in E'...
+ right. intros C. apply subset_iff in C...
rewrite C in E'. inversion E'.
Qed.
(* Lemma dropLabel_first_element': forall i T1 T2,
(* WF E (typ_rcd_cons i T1 T2) -> *)
dropLabel i (typ_rcd_cons i T1 T2) = T2.
Proof with auto.
intros. simpl. rewrite eq_dec_refl.
dependent destruction H...
simpl...
destruct (i==i)...
apply dropLable_notin with (E:=E)...
destruct n...
Qed. *)
(* Lemma record_permutation_exists_aux:
forall E j x a T1 T2,
rt_type T2 -> a <> j ->
equiv E (typ_rcd_cons j x (dropLabel j T2)) T2 ->
equiv E (typ_rcd_cons j x (dropLabel j (typ_rcd_cons a T1 T2)))
(typ_rcd_cons a T1 T2).
Proof with auto.
intros.
destruct H1 as [e1 e2].
split.
+ inversion e1;subst;inv_rt.
simpl. destruct (a == j);try solve [exfalso;auto]...
apply sa_rcd;try solve [get_well_form;auto]...
- simpl.
simpl. simpl in H4. admit.
- inversion H5;subst. constructor... *)
Lemma equiv_trans: forall E P Q R,
equiv E P Q -> equiv E Q R -> equiv E P R.
Proof.
intros.
destruct H. destruct H0.
split;apply sub_transitivity with (Q:=Q);auto.
Qed.
Lemma sub_rcd_proper: forall E a T1 T2 T1' T2',
sub E T1 T1' ->
sub E T2 T2' ->
rt_type T2 -> rt_type T2' ->
a `notin` collectLabel T2 ->
sub E (typ_rcd_cons a T1 T2) (typ_rcd_cons a T1' T2').
Proof with auto.
intros.
apply sa_rcd...
+ get_well_form...
+ simpl.
rewrite <- !KeySetProperties.add_union_singleton.
apply add_s_m...
inversion H0;subst;inv_rt...
+ constructor;try solve [get_well_form;auto]...
+ constructor;try solve [get_well_form;auto]...
inversion H0;subst;inv_rt...
+ intros. simpl in H4, H5. destruct (a==i).
* inversion H4;subst. inversion H5;subst...
* inversion H0;subst;inv_rt...
apply H12 with (i:=i)...
Qed.
Lemma equiv_rcd_proper: forall E a T1 T2 T1' T2',
equiv E T1 T1' ->
equiv E T2 T2' ->
rt_type T2 -> rt_type T2' ->
a `notin` collectLabel T2 ->
equiv E (typ_rcd_cons a T1 T2) (typ_rcd_cons a T1' T2').
Proof with auto.
intros. destruct H as [H H'], H0 as [H0 H0'].
split.
{ apply sub_rcd_proper... }
{ apply sub_rcd_proper...
inversion H0;subst;inv_rt...
}
Qed.
Lemma sub_rcd_first_permute: forall E a b T1 T2 T3,
wf_env E -> WF E (typ_rcd_cons a T1 (typ_rcd_cons b T2 T3)) ->
sub E (typ_rcd_cons a T1 (typ_rcd_cons b T2 T3))
(typ_rcd_cons b T2 (typ_rcd_cons a T1 T3)).
Proof with auto.
intros.
{ apply sa_rcd...
+ simpl. rewrite <- !KeySetProperties.union_assoc.
rewrite KeySetProperties.union_sym with (s:= singleton a). reflexivity.
+ inversion H0;subst. inversion H6;subst.
constructor... 2:{ simpl in H8... }
constructor... { simpl in H8 ... }
+ intros. simpl in H1, H2.
assert (a <> b). { inversion H0;subst. simpl in H10... }
destruct (a==i), (b==i);try inversion H1; try inversion H2;subst...
* congruence.
* apply Reflexivity... inversion H0...
* apply Reflexivity... inversion H0... inversion H9...
* assert (t1 = t2) by congruence. subst.
apply Reflexivity... apply wf_rcd_lookup with (E:=E) in H1...
inversion H0... inversion H11...
}
Qed.
Lemma equiv_rcd_first_permute: forall E a b T1 T2 T3,
wf_env E -> WF E (typ_rcd_cons a T1 (typ_rcd_cons b T2 T3)) ->
equiv E (typ_rcd_cons a T1 (typ_rcd_cons b T2 T3))
(typ_rcd_cons b T2 (typ_rcd_cons a T1 T3)).
Proof with auto.
intros.
split.
{ apply sub_rcd_first_permute... }
{ apply sub_rcd_first_permute...
inversion H0;subst.
inversion H6;subst.
constructor... 2:{ simpl in H8... }
constructor... { simpl in H8 ... }
}
Qed.
Lemma record_permutation_exists:
forall j E T,
wf_env E ->
j `in` collectLabel T ->
{ A' |
equiv E (typ_rcd_cons j A' ((dropLabel j T))) T} + {~ WF E T}.
Proof with auto.
intros.
induction T;try solve [apply empty_iff in H0;destruct H0].
- simpl in H0.
destruct (Atom.eq_dec j a).
+ subst j.
solve_top_wfs_dec E (typ_rcd_cons a T1 T2).
left. exists T1.
rewrite dropLabel_first_element with (E:=E)...
apply equiv_reflexivity...
+ solve_top_wfs_dec E (typ_rcd_cons a T1 T2).
destruct (collectLabelDec j T2).
2:{ assert (j `notin` union (singleton a) (collectLabel T2))... }
destruct (IHT2 i);try solve [solve_right_dec].
left. destruct s. exists x.
simpl. destruct (a ==j);try solve [exfalso;auto]...
apply equiv_trans with
(Q:= (typ_rcd_cons a T1 (typ_rcd_cons j x (dropLabel j T2)))).
* apply equiv_rcd_first_permute...
{ destruct e. get_well_form.
inversion H5;subst.
inversion w;subst. constructor...
constructor... apply notin_drop_collect... }
* apply equiv_rcd_proper...
{ apply equiv_reflexivity...
{ inversion w;subst... }
}
{ inversion w;subst... }
{ simpl. solve_notin. apply notin_drop_collect...
inversion w... }
Qed.
Lemma equiv_measure: forall A,
type4rec A -> forall B, type4rec B -> forall E,
sub E A B -> sub E B A ->
bindings_rec (mk_benv E) nil 0 A = bindings_rec (mk_benv E) nil 0 B.
Proof with auto.
intros A HA;induction HA.
- intros B HB;induction HB;intros;
try solve [simpl; lia| inversion H;inv_rt|inversion H0;inv_rt|
inversion H1;inv_rt|
inversion H2;inv_rt|inversion H3;inv_rt].
- intros B HB;induction HB;intros;
try solve [simpl; lia| inversion H;inv_rt|inversion H0;inv_rt|
inversion H1;inv_rt|
inversion H2;inv_rt|inversion H3;inv_rt].
- intros B HB;induction HB;intros;
try solve [simpl; lia| inversion H;inv_rt|inversion H0;inv_rt|
inversion H1;inv_rt|
inversion H2;inv_rt|inversion H3;inv_rt| inversion H4;inv_rt].
apply suba_sub_tvar_chain in H.
apply suba_sub_tvar_chain in H0.
destruct H as [W1], H0 as [W2].
pose proof sub_tvar_chain_antisym H H0. subst. lia.
- intros. dependent destruction H0.
{ dependent destruction H2. inv_rt. }
2:{ inv_rt. }
dependent destruction H1.
2:{ inv_rt. }
simpl.
rewrite IHHA1 with (B:=B1)...
2:{ apply type_to_rec. apply WF_type with (E:=E). get_well_form... }
rewrite IHHA2 with (B:=B2)...
{ apply type_to_rec. apply WF_type with (E:=E). get_well_form... }
- intros. rename T into A1.
dependent destruction H4.
{ dependent destruction H6. inv_rt. }
2:{ inv_rt. }
dependent destruction H7.
2:{ inv_rt. }
dependent destruction H3.
pick_fresh X.
specialize_x_and_L X L.
specialize_x_and_L X L0.
specialize_x_and_L X L1.
specialize_x_and_L X L2.
assert (Eh1: sub (X ~ bind_sub typ_top ++ E) (open_tt A1 X) (open_tt A2 X)).
{ apply sub_nominal_inversion... }
assert (Eh2: sub (X ~ bind_sub typ_top ++ E) (open_tt A2 X) (open_tt A1 X)).
{ apply sub_nominal_inversion... }
simpl.
specialize (H2 _ H4 ((X ~ bind_sub typ_top) ++ E) Eh1 Eh2).
assert (WFC A2 0).
{ apply type_open_tt_WFC with (X:=X)...
apply type4rec_to_type... }
assert (WFC A1 0).
{ apply type_open_tt_WFC with (X:=X)...
apply type4rec_to_type... }
rewrite_env (empty_menv ++ empty_menv) in H2...
pose proof H2 as H2'. simpl in H2'.
rewrite bindings_find in H2...
rewrite bindings_add in H2...
rewrite bindings_find in H2...
rewrite bindings_add with (A:=A2) in H2...
unfold zero in H2. simpl in H2. rewrite eq_dec_refl in H2.
replace (1-0) with 1 in H2...
rewrite_env (X ~ 1 ++ mk_benv E) in H2.
rewrite <- find_var_one with (X:=X) in H2...
2:{ apply mk_benv_dom... }
rewrite <- find_var_one with (X:=X) in H2...
2:{ apply mk_benv_dom... }
rewrite H2. f_equal...
specialize (H0 _ H3 ((X ~ bind_sub typ_top) ++ E) H7 H10).
rewrite_env (empty_menv ++ empty_menv) in H0...
rewrite bindings_find in H0...
rewrite bindings_add in H0...
rewrite bindings_find in H0...
rewrite bindings_add with (A:=A2) in H0...
unfold zero in H0. simpl in H0. rewrite H2' in H0.
rewrite_env (X ~ 1 ++ mk_benv E) in H0.
rewrite <- find_var_one with (X:=X) in H0...
2:{ apply mk_benv_dom... }
rewrite <- find_var_one with (Q:=A2) (X:=X) in H0...
2:{ apply mk_benv_dom... }
rewrite <- find_var_one with (X:=X) in H0...
2:{ apply mk_benv_dom... }
rewrite_env (empty_menv ++ empty_menv) in H0...
rewrite bindings_find in H0...
replace (bindings_rec (mk_benv E) (empty_menv ++ empty_menv) 0 X) with 2 in H0.
2:{ simpl. rewrite findX_notin... apply mk_benv_dom... }
simpl in H0. rewrite bindings_add with (A:=A2) in H0...
simpl in H0. unfold zero in H0. rewrite Nat.sub_0_r in H0...
constructor. apply WF_type with (E:=X ~ bind_sub typ_top ++ E)...
constructor. apply WF_type with (E:=X ~ bind_sub typ_top ++ E)...
-
intros.
dependent destruction H2.
{ dependent destruction H4. inv_rt. }
2:{ inv_rt. }
dependent destruction H3.
2:{ inv_rt. }
rename T2 into S1. rename S2 into T2.
rename T3 into S2.
inversion H1;subst.
pick_fresh X.
specialize_x_and_L X L.
specialize_x_and_L X L0.
specialize_x_and_L X L1.
specialize_x_and_L X L2.
specialize (IHHA _ H6 E H2_ H2_0).
simpl. rewrite IHHA. f_equal. f_equal.
rewrite_env (nil ++ X ~ bind_sub T1 ++ E) in H3.
apply sub_narrowing with (P:=T2) in H3...
specialize (H0 _ H7 (X ~ bind_sub T2 ++ E) H2 H3).
apply type4rec_to_type in H6.
get_well_form...
assert (WFC S1 0). { apply type_open_tt_WFC with (X:=X)... apply WF_type with (E:=X~bind_sub T2 ++ E)... }
assert (WFC S2 0). { apply type_open_tt_WFC with (X:=X)... apply WF_type with (E:=X~bind_sub T2 ++ E)... }
rewrite bindings_fvar_spec in H0...
rewrite bindings_fvar_spec with (A:=S2) in H0...
-
intros.
dependent destruction H0.
{ dependent destruction H2. inv_rt. }
2:{ inv_rt. }
dependent destruction H1.
2:{ inv_rt. }
dependent destruction H.
simpl. f_equal. apply IHHA...
-
intros. dependent destruction H0.
{ dependent destruction H2. inv_rt. }
dependent destruction H7;try inv_rt...
dependent destruction H8...
simpl in H3. collect_nil H3.
-
intros. inversion H1;subst.
{ dependent destruction H2;try inv_rt. }
inversion H2;subst;try inv_rt...
dependent destruction H5...
{ simpl in H13. collect_nil H13. }
simpl.
assert (equiv E (typ_rcd_cons i0 T0 T3) (typ_rcd_cons i T1 T2)) by (split;auto)...
apply record_permutation in H5. unfold equiv in H5. destruct_hypos.
rewrite IHHA1 with (B:=x)...
2:{ apply type_to_rec. apply WF_type with (E:=E). get_well_form... }
rewrite IHHA2 with (B:=(dropLabel i (typ_rcd_cons i0 T0 T3)))...
2:{ apply type_to_rec. apply WF_type with (E:=E). apply WF_drop. get_well_form... }
pose proof bindings_drop_label (T:=typ_rcd_cons i0 T0 T3) (E:=E) empty_menv (t:=x) i.
rewrite H22...
Qed.
Lemma subtyping_dec : forall k A B E,
bindings_rec (mk_benv E) nil 0 A +
bindings_rec (mk_benv E) nil 0 B <= k ->
{sub E A B} + {~ sub E A B}.
Proof with auto.
induction k.
-
induction A;intros;try solve [unfold bindings in *;exfalso;simpl in *;lia]...
-
induction A.
+
induction B;intros;try solve [ solve_right_dec | solve_top_dec E]...
+
induction B;intros;try solve [ solve_right_dec | solve_top_dec E]...
+
induction B;intros;try solve [ solve_right_dec | solve_top_dec E]...
right. intros C. inversion C;subst. inversion H1. inv_rt.
+
intros. simpl in H.
destruct (wf_env_dec E).
2:{ right. intros C. apply sub_regular in C. destruct C... }
destruct (binds_key_dec E a).
*
pose proof uniq_from_wf_env w as u.
destruct s.
destruct x.
{ assert (WF E t).
{ apply WF_from_binds_typ with (x:=a)... }
apply WF_type in H0.
rewrite (findX_sem _ _ w b) in H.
(* 2:{ apply binds_split in b.
destruct b as [E1 [E2 b]]. rewrite b in w.
apply wf_env_binds_not_fv_tt in w... } *)
apply le_S_n in H.
destruct (IHk _ _ _ H)...
{ left. apply sa_trans_tvar with (U:=t)... }
{ destruct (EqDec_eq a B).
{ left. subst. apply sa_fvar... apply WF_var with (U:=t)... }
destruct (EqDec_eq typ_top B).
{ left. subst. apply sa_top... apply WF_var with (U:=t)... }
right. intros C. inversion C;inv_rt;subst...
{ assert (bind_sub t = bind_sub U).
{ eapply binds_unique with (x:=a) (E:=E)... }
inversion H1;subst... }
}
}
{ right. intros C. apply uniq_from_wf_env in w.
inversion C;subst;inv_rt.
{ inversion H3;subst. pose proof binds_unique _ _ _ _ _ b H4 w.
inversion H0. }
{ inversion H1;subst. pose proof binds_unique _ _ _ _ _ b H4 w.
inversion H2. }
{ pose proof binds_unique _ _ _ _ _ b H1 w.
inversion H0. }
}
*
right. intros C.
inversion C;inv_rt;subst...
{ inversion H3;subst. apply n in H4... }
{ inversion H1;subst. apply n in H4... }
{ apply n in H1... }
+ intros. simpl in H.
induction B;intros;try solve [ solve_right_dec | solve_top_dec E]...
* solve_top_dec E. solve_top_wfs_dec E (typ_arrow A1 A2).
*
simpl in H.
destruct IHk with (A:=B1) (B:=A1) (E:=E); try solve [lia];
destruct IHk with (A:=A2) (B:=B2) (E:=E);try solve [lia];
try solve [solve_right_dec].
left. apply sa_arrow...
+
intros. simpl in H.
induction B;intros;try solve [ solve_right_dec]...
* solve_top_dec E. solve_top_wfs_dec E (typ_all A1 A2).
*
destruct (IHk A1 B1 E); try solve [solve_right_dec].
{ simpl in H. lia. }
destruct (IHk B1 A1 E); try solve [solve_right_dec].
{ simpl in H. lia. }
(* destruct (EqDec_eq A1 B1);try solve [solve_right_dec]. *)
(* rename A1 into A. *)
(* rename A2 into B1. *)
destruct (wf_env_dec E).
2:{ right. intros C. apply sub_regular in C. destruct C as [? [? ?]]... }
pose proof uniq_from_wf_env w as u.
(* destruct (wf_dec A1 u);try solve [solve_right_dec]. *)
pick_fresh X1.
assert (uniq ((X1 ~ bind_sub A1) ++ E)) as u2...
assert (uniq ((X1 ~ bind_sub B1) ++ E)) as u3...
destruct (wf_dec (open_tt A2 X1) u2).
2:{ right. intros C.
apply sub_regular in C. destruct C as [? [? ?]].
inversion H1;subst.
pick_fresh X2. specialize_x_and_L X2 L.
apply n. apply WF_replacing_var with (X:=X2)... }
destruct (wf_dec (open_tt B2 X1) u3).
2:{ right. intros C.
apply sub_regular in C. destruct C as [? [? ?]].
inversion H2;subst.
pick_fresh X2. specialize_x_and_L X2 L.
apply n. apply WF_replacing_var with (X:=X2)... }
clear IHA1 IHA2 IHB1 IHB2. simpl in H.
specialize (IHk (open_tt A2 X1) (open_tt B2 X1)
(X1 ~ bind_sub B1 ++ E)).
rewrite <- bindings_fvar_spec with (X:=X1)in H...
2:{ apply type_open_tt_WFC with (X:=X1)... apply WF_type in w0... }
2:{ get_well_form... }
2:{ get_well_form... apply WF_type in H4... }
rewrite <- bindings_fvar_spec with (X:=X1)in H...
2:{ apply type_open_tt_WFC with (X:=X1)... apply WF_type in w1... }
2:{ get_well_form... }
2:{ get_well_form... apply WF_type in H5... }
assert (Eq: bindings_rec (mk_benv E) empty_menv 0 A1 = bindings_rec (mk_benv E) empty_menv 0 B1).
{ apply equiv_measure...
{ apply type_to_rec. apply WF_type with (E:=E). get_well_form... }
{ apply type_to_rec. apply WF_type with (E:=E). get_well_form... }
}
rewrite Eq in *.
destruct IHk.
{ simpl in H. simpl. rewrite Eq in H. lia. }
{ left.
apply sa_all with (L:={{X1}} \u fv_tt A1 \u fv_tt A2 \u fv_tt B1 \u fv_tt B2 \u dom E);intros...
(* { apply Reflexivity... } { apply Reflexivity... } *)
apply sub_replacing_var with (X:=X1)...
get_well_form...
}
{ right. intros. intros C.
inversion C;inv_rt. subst. pick_fresh X2.
specialize_x_and_L X2 L.
apply n. apply sub_replacing_var with (X:=X2)...
get_well_form... }
+
intros. simpl in H.
induction B;intros;try solve [ solve_right_dec]...
* solve_top_dec E. solve_top_wfs_dec E (typ_mu A).
*
destruct (wf_env_dec E).
2:{ right. intros C. apply sub_regular in C. destruct C as [? [? ?]]... }
pose proof uniq_from_wf_env w as u.
pick_fresh X1. assert (uniq ((X1 ~ bind_sub typ_top) ++ E)) as u2...
destruct (wf_dec (open_tt A X1) u2).
2:{ right. intros C. apply n.
inversion C;inv_rt. subst.
pick_fresh X2. specialize_x_and_L X2 L.
apply WF_replacing_var with (X:=X2)... }
destruct (wf_dec (open_tt B X1) u2).
2:{ right. intros C. apply n.
inversion C;inv_rt. subst.
pick_fresh X2. specialize_x_and_L X2 L.
apply WF_replacing_var with (X:=X2)... }
clear IHA IHB. simpl in H.
specialize (IHk (open_tt A (typ_label X1 (open_tt A X1)))
(open_tt B (typ_label X1 (open_tt B X1)))
(X1 ~ bind_sub typ_top ++ E)).
assert (WFC A 0). { apply WF_type in w0. apply type_open_tt_WFC in w0... }
assert (WFC B 0). { apply WF_type in w1. apply type_open_tt_WFC in w1... }
rewrite bindings_find_spec'
with (A:=A) (B:= typ_label X1 (open_tt A X1)) in IHk...
2:{ constructor. apply WF_type in w0... }
rewrite bindings_find_spec'
with (A:=B) (B:= typ_label X1 (open_tt B X1)) in IHk...
2:{ constructor. apply WF_type in w1... }
assert (Haux: forall G E n A X,
bindings_rec G E n (typ_label X A) = S (bindings_rec G E n A))...
rewrite !Haux in IHk. clear Haux.
rewrite bindings_fvar_spec in IHk...
rewrite bindings_fvar_spec in IHk...
rewrite <- findX_extend in IHk...
2:{ apply WFC_WFD_S... }
rewrite <- findX_extend in IHk...
2:{ apply WFC_WFD_S... }
destruct IHk.
{ apply le_S_n in H. eapply le_trans;[|apply H].
apply plus_le_compat.
{ apply sub_menv_sem. constructor...
simpl. lia. }
{ apply le_S. apply sub_menv_sem.
constructor... simpl. lia. }
}
{ left.
apply sa_rec with (L:={{X1}} \u fv_tt A \u fv_tt B \u dom E \u fl_tt A \u fl_tt B);intros...
{ apply WF_replacing_var with (X:=X1)... }
{ apply WF_replacing_var with (X:=X1)... }
{
apply sub_renaming_unfolding with (X:=X1)...
}
}
{ right. intros. intros C.
inversion C;inv_rt. subst. pick_fresh X2.
specialize_x_and_L X2 L.
apply n. simpl.
apply sub_renaming_unfolding with (X:=X2)...
}
+
intros. simpl in H.
induction B;intros;try solve [ solve_right_dec]...
* solve_top_dec E. solve_top_wfs_dec E (typ_label a A).
*
simpl in H. destruct IHk with (A:=A) (B:=B) (E:=E).
{ lia. }
{ destruct (a == a0).
+ subst. constructor...
+ right. intros C. inversion C;inv_rt;subst... }
{ right. intros C. inversion C;inv_rt;subst... }
+
intros. simpl in H.
induction B;intros;try solve [ solve_right_dec]...
* solve_top_dec E.
* solve_top_dec E. left. apply Reflexivity...
* right. intros C. inversion C. collect_nil H3.
+
intros.
induction B;intros;try solve [ solve_right_dec]...
* solve_top_dec E. solve_top_wfs_dec E (typ_rcd_cons a A1 A2).
* solve_top_dec E.
solve_top_wfs_dec E (typ_rcd_cons a A1 A2).
left.
apply sa_rcd...
{ intro r. intros. simpl in H0. exfalso. apply notin_empty_1 in H0... }
{ intros. inversion H1. }
*
destruct (subset_dec (collectLabel (typ_rcd_cons a0 B1 B2)) (collectLabel (typ_rcd_cons a A1 A2)) );
try solve [ solve_right_dec].
solve_top_dec E.
solve_top_wfs_dec E (typ_rcd_cons a A1 A2).
solve_top_wfs_dec E (typ_rcd_cons a0 B1 B2).
destruct (@record_permutation_exists a0 E (typ_rcd_cons a A1 A2)) as [[x e]| e]...
{ apply s... simpl. apply union_iff. left... }
pose proof (e':=e).
destruct e'.
assert (type4rec (typ_rcd_cons a0 x (dropLabel a0 (typ_rcd_cons a A1 A2)))).
{ apply type_to_rec. apply WF_type with (E:=E). get_well_form... }
assert (type4rec (typ_rcd_cons a A1 A2)).
{ apply type_to_rec. apply WF_type with (E:=E). get_well_form... }
pose proof equiv_measure H2 H3 H0 H1.
rewrite <- H4 in H.
destruct IHk with (E:=E)
(A:= x) (B:=B1)...
{ simpl in H. lia... }
2:{ right. intros C.
pose proof sub_transitivity H0 C.
inversion H5;subst.
specialize (H12 a0 x B1).
apply n. apply H12;simpl;rewrite eq_dec_refl...
}
destruct IHk with (E:=E)
(B:= B2) (A:=(dropLabel a0 (typ_rcd_cons a A1 A2)))...
{ simpl in H. simpl. lia... }
-- left.
apply sub_transitivity with (typ_rcd_cons a0 x (dropLabel a0 (typ_rcd_cons a A1 A2)))...
apply sa_rcd...
{ apply label_equiv in e. rewrite e... }
{ destruct e. get_well_form... }
{ intros. simpl in H5. simpl in H6.
destruct (a0 == i).
{ inversion H5. inversion H6. subst... }
{ apply (rcd_inversion s1) with (i:=i)...
+ get_well_form. apply rt_type_drop with (E:=E)...
+ inversion w0... }
}
-- right.
intros C.
pose proof sub_transitivity H0 C.
inversion H5;subst.
apply n. apply sa_rcd...
{ apply rt_type_drop with (E:=E)... }
{ inversion w0... }
{ simpl in H9.
rewrite <- !KeySetProperties.add_union_singleton in H9.
apply dom_add_subset in H9...
inversion H10;inversion H11... }
{ inversion H10... }
{ inversion H11... }
{ intros. apply H12 with (i:=i).
+ simpl. destruct (a0 == i)... subst i.
apply label_belong in H14.
inversion H11. exfalso...
+ simpl. destruct (a0 == i)... subst i.
apply label_belong in H14.
inversion H11. exfalso...
}
Qed.
Lemma decidability : forall A B E,
{sub E A B} + {~ sub E A B}.
Proof with auto.
intros.
apply subtyping_dec with (k:=bindings_rec (mk_benv E) nil 0 A +
bindings_rec (mk_benv E) nil 0 B )...
Qed.
|
(* This program is free software; you can redistribute it and/or *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1 *)
(* of the License, or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU Lesser General Public *)
(* License along with this program; if not, write to the Free *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA *)
(*****************************************************************************)
(* Projet Formel - Calculus of Inductive Constructions V5.10 *)
(*****************************************************************************)
(* *)
(* Category ONE *)
(* *)
(*****************************************************************************)
(* *)
(* A. SAIBI May 95 *)
(* *)
(*****************************************************************************)
Require Export ONE.
Require Export Functor.
Set Implicit Arguments.
Unset Strict Implicit.
(* !C : C -> One *)
Section Fun_One.
Variable C : Category.
Definition FunOne_ob (a : C) := Obone.
Section funone_map_def.
Variable a b : C.
Definition FunOne_mor (f : a --> b) : FunOne_ob a --> FunOne_ob b :=
Id_Obone.
Lemma FunOne_map_law : Map_law FunOne_mor.
Proof.
unfold Map_law, FunOne_mor in |- *.
intros; apply Refl.
Qed.
Canonical Structure FunOne_map := Build_Map FunOne_map_law.
End funone_map_def.
Lemma FunOne_comp_law : Fcomp_law FunOne_map.
Proof.
unfold Fcomp_law in |- *; simpl in |- *.
unfold Equal_One_mor in |- *; auto.
Qed.
Lemma FunOne_id_law : Fid_law FunOne_map.
Proof.
unfold Fid_law in |- *; simpl in |- *.
unfold Equal_One_mor in |- *; auto.
Qed.
Canonical Structure FunOne := Build_Functor FunOne_comp_law FunOne_id_law.
End Fun_One.
|
Formal statement is: lemma arc_image_uncountable: fixes g :: "real \<Rightarrow> 'a::metric_space" assumes "arc g" shows "uncountable (path_image g)" Informal statement is: If $g$ is an arc, then the image of $g$ is uncountable. |
[GOAL]
α : Type u_1
β : Type u_2
m✝ : MeasurableSpace α
μ✝ ν : Measure α
inst✝ : ConditionallyCompleteLinearOrder β
x : β
f✝ : α → β
m : MeasurableSpace α
μ : Measure α
f : α → β
⊢ essSup f μ = sInf {a | ↑↑μ {x | a < f x} = 0}
[PROOFSTEP]
dsimp [essSup, limsup, limsSup]
[GOAL]
α : Type u_1
β : Type u_2
m✝ : MeasurableSpace α
μ✝ ν : Measure α
inst✝ : ConditionallyCompleteLinearOrder β
x : β
f✝ : α → β
m : MeasurableSpace α
μ : Measure α
f : α → β
⊢ sInf {a | ∀ᶠ (n : β) in map f (Measure.ae μ), n ≤ a} = sInf {a | ↑↑μ {x | a < f x} = 0}
[PROOFSTEP]
simp only [eventually_map, ae_iff, not_le]
[GOAL]
α : Type u_1
β : Type u_2
m✝ : MeasurableSpace α
μ✝ ν : Measure α
inst✝ : ConditionallyCompleteLinearOrder β
x : β
f✝ : α → β
m : MeasurableSpace α
μ : Measure α
f : α → β
⊢ essInf f μ = sSup {a | ↑↑μ {x | f x < a} = 0}
[PROOFSTEP]
dsimp [essInf, liminf, limsInf]
[GOAL]
α : Type u_1
β : Type u_2
m✝ : MeasurableSpace α
μ✝ ν : Measure α
inst✝ : ConditionallyCompleteLinearOrder β
x : β
f✝ : α → β
m : MeasurableSpace α
μ : Measure α
f : α → β
⊢ sSup {a | ∀ᶠ (n : β) in map f (Measure.ae μ), a ≤ n} = sSup {a | ↑↑μ {x | f x < a} = 0}
[PROOFSTEP]
simp only [eventually_map, ae_iff, not_le]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝³ : ConditionallyCompleteLinearOrder β
x : β
f : α → β
inst✝² : TopologicalSpace β
inst✝¹ : FirstCountableTopology β
inst✝ : OrderTopology β
hf : autoParam (IsBoundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae μ) f) _auto✝
⊢ ↑↑μ {y | essSup f μ < f y} = 0
[PROOFSTEP]
simp_rw [← not_le]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝³ : ConditionallyCompleteLinearOrder β
x : β
f : α → β
inst✝² : TopologicalSpace β
inst✝¹ : FirstCountableTopology β
inst✝ : OrderTopology β
hf : autoParam (IsBoundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae μ) f) _auto✝
⊢ ↑↑μ {y | ¬f y ≤ essSup f μ} = 0
[PROOFSTEP]
exact ae_le_essSup hf
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝³ : ConditionallyCompleteLinearOrder β
x : β
f : α → β
inst✝² : TopologicalSpace β
inst✝¹ : FirstCountableTopology β
inst✝ : OrderTopology β
hf : autoParam (IsBoundedUnder (fun x x_1 => x ≥ x_1) (Measure.ae μ) f) _auto✝
⊢ ↑↑μ {y | f y < essInf f μ} = 0
[PROOFSTEP]
simp_rw [← not_le]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝³ : ConditionallyCompleteLinearOrder β
x : β
f : α → β
inst✝² : TopologicalSpace β
inst✝¹ : FirstCountableTopology β
inst✝ : OrderTopology β
hf : autoParam (IsBoundedUnder (fun x x_1 => x ≥ x_1) (Measure.ae μ) f) _auto✝
⊢ ↑↑μ {y | ¬essInf f μ ≤ f y} = 0
[PROOFSTEP]
exact ae_essInf_le hf
[GOAL]
α : Type u_1
β : Type u_2
m✝ : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
m : MeasurableSpace α
f : α → β
⊢ ⊥ ∈ {a | ∀ᶠ (n : β) in map f (Measure.ae 0), n ≤ a}
[PROOFSTEP]
simp [Set.mem_setOf_eq, EventuallyLE, ae_iff]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
c : β
hf : f ≤ᵐ[μ] fun x => c
⊢ essSup f μ ≤ c
[PROOFSTEP]
refine' (essSup_mono_ae hf).trans _
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
c : β
hf : f ≤ᵐ[μ] fun x => c
⊢ essSup (fun x => c) μ ≤ c
[PROOFSTEP]
by_cases hμ : μ = 0
[GOAL]
case pos
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
c : β
hf : f ≤ᵐ[μ] fun x => c
hμ : μ = 0
⊢ essSup (fun x => c) μ ≤ c
[PROOFSTEP]
simp [hμ]
[GOAL]
case neg
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
c : β
hf : f ≤ᵐ[μ] fun x => c
hμ : ¬μ = 0
⊢ essSup (fun x => c) μ ≤ c
[PROOFSTEP]
rwa [essSup_const]
[GOAL]
α : Type u_1
β : Type u_2
m✝ : MeasurableSpace α
μ✝ ν : Measure α
inst✝¹ : CompleteLattice β
m : MeasurableSpace α
γ : Type u_3
inst✝ : CompleteLattice γ
f : α → β
μ : Measure α
g : β ≃o γ
⊢ ↑g (essSup f μ) = essSup (fun x => ↑g (f x)) μ
[PROOFSTEP]
refine' OrderIso.limsup_apply g _ _ _ _
[GOAL]
case refine'_1
α : Type u_1
β : Type u_2
m✝ : MeasurableSpace α
μ✝ ν : Measure α
inst✝¹ : CompleteLattice β
m : MeasurableSpace α
γ : Type u_3
inst✝ : CompleteLattice γ
f : α → β
μ : Measure α
g : β ≃o γ
⊢ IsBoundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae μ) f
case refine'_2
α : Type u_1
β : Type u_2
m✝ : MeasurableSpace α
μ✝ ν : Measure α
inst✝¹ : CompleteLattice β
m : MeasurableSpace α
γ : Type u_3
inst✝ : CompleteLattice γ
f : α → β
μ : Measure α
g : β ≃o γ
⊢ IsCoboundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae μ) f
case refine'_3
α : Type u_1
β : Type u_2
m✝ : MeasurableSpace α
μ✝ ν : Measure α
inst✝¹ : CompleteLattice β
m : MeasurableSpace α
γ : Type u_3
inst✝ : CompleteLattice γ
f : α → β
μ : Measure α
g : β ≃o γ
⊢ IsBoundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae μ) fun x => ↑g (f x)
case refine'_4
α : Type u_1
β : Type u_2
m✝ : MeasurableSpace α
μ✝ ν : Measure α
inst✝¹ : CompleteLattice β
m : MeasurableSpace α
γ : Type u_3
inst✝ : CompleteLattice γ
f : α → β
μ : Measure α
g : β ≃o γ
⊢ IsCoboundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae μ) fun x => ↑g (f x)
[PROOFSTEP]
all_goals isBoundedDefault
[GOAL]
case refine'_1
α : Type u_1
β : Type u_2
m✝ : MeasurableSpace α
μ✝ ν : Measure α
inst✝¹ : CompleteLattice β
m : MeasurableSpace α
γ : Type u_3
inst✝ : CompleteLattice γ
f : α → β
μ : Measure α
g : β ≃o γ
⊢ IsBoundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae μ) f
[PROOFSTEP]
isBoundedDefault
[GOAL]
case refine'_2
α : Type u_1
β : Type u_2
m✝ : MeasurableSpace α
μ✝ ν : Measure α
inst✝¹ : CompleteLattice β
m : MeasurableSpace α
γ : Type u_3
inst✝ : CompleteLattice γ
f : α → β
μ : Measure α
g : β ≃o γ
⊢ IsCoboundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae μ) f
[PROOFSTEP]
isBoundedDefault
[GOAL]
case refine'_3
α : Type u_1
β : Type u_2
m✝ : MeasurableSpace α
μ✝ ν : Measure α
inst✝¹ : CompleteLattice β
m : MeasurableSpace α
γ : Type u_3
inst✝ : CompleteLattice γ
f : α → β
μ : Measure α
g : β ≃o γ
⊢ IsBoundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae μ) fun x => ↑g (f x)
[PROOFSTEP]
isBoundedDefault
[GOAL]
case refine'_4
α : Type u_1
β : Type u_2
m✝ : MeasurableSpace α
μ✝ ν : Measure α
inst✝¹ : CompleteLattice β
m : MeasurableSpace α
γ : Type u_3
inst✝ : CompleteLattice γ
f : α → β
μ : Measure α
g : β ≃o γ
⊢ IsCoboundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae μ) fun x => ↑g (f x)
[PROOFSTEP]
isBoundedDefault
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
hμν : ν ≪ μ
⊢ essSup f ν ≤ essSup f μ
[PROOFSTEP]
refine' limsup_le_limsup_of_le (Measure.ae_le_iff_absolutelyContinuous.mpr hμν) _ _
[GOAL]
case refine'_1
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
hμν : ν ≪ μ
⊢ IsCoboundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae ν) f
case refine'_2
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
hμν : ν ≪ μ
⊢ IsBoundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae μ) f
[PROOFSTEP]
all_goals isBoundedDefault
[GOAL]
case refine'_1
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
hμν : ν ≪ μ
⊢ IsCoboundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae ν) f
[PROOFSTEP]
isBoundedDefault
[GOAL]
case refine'_2
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
hμν : ν ≪ μ
⊢ IsBoundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae μ) f
[PROOFSTEP]
isBoundedDefault
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
hμν : μ ≪ ν
⊢ essInf f ν ≤ essInf f μ
[PROOFSTEP]
refine' liminf_le_liminf_of_le (Measure.ae_le_iff_absolutelyContinuous.mpr hμν) _ _
[GOAL]
case refine'_1
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
hμν : μ ≪ ν
⊢ IsBoundedUnder (fun x x_1 => x ≥ x_1) (Measure.ae ν) f
case refine'_2
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
hμν : μ ≪ ν
⊢ IsCoboundedUnder (fun x x_1 => x ≥ x_1) (Measure.ae μ) f
[PROOFSTEP]
all_goals isBoundedDefault
[GOAL]
case refine'_1
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
hμν : μ ≪ ν
⊢ IsBoundedUnder (fun x x_1 => x ≥ x_1) (Measure.ae ν) f
[PROOFSTEP]
isBoundedDefault
[GOAL]
case refine'_2
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
hμν : μ ≪ ν
⊢ IsCoboundedUnder (fun x x_1 => x ≥ x_1) (Measure.ae μ) f
[PROOFSTEP]
isBoundedDefault
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
c : ℝ≥0∞
hc : c ≠ 0
⊢ essSup f (c • μ) = essSup f μ
[PROOFSTEP]
simp_rw [essSup]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
c : ℝ≥0∞
hc : c ≠ 0
⊢ limsup f (Measure.ae (c • μ)) = limsup f (Measure.ae μ)
[PROOFSTEP]
suffices h_smul : (c • μ).ae = μ.ae
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
c : ℝ≥0∞
hc : c ≠ 0
h_smul : Measure.ae (c • μ) = Measure.ae μ
⊢ limsup f (Measure.ae (c • μ)) = limsup f (Measure.ae μ)
[PROOFSTEP]
rw [h_smul]
[GOAL]
case h_smul
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
c : ℝ≥0∞
hc : c ≠ 0
⊢ Measure.ae (c • μ) = Measure.ae μ
[PROOFSTEP]
ext1
[GOAL]
case h_smul.a
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
c : ℝ≥0∞
hc : c ≠ 0
s✝ : Set α
⊢ s✝ ∈ Measure.ae (c • μ) ↔ s✝ ∈ Measure.ae μ
[PROOFSTEP]
simp_rw [mem_ae_iff]
[GOAL]
case h_smul.a
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
f : α → β
c : ℝ≥0∞
hc : c ≠ 0
s✝ : Set α
⊢ ↑↑(c • μ) s✝ᶜ = 0 ↔ ↑↑μ s✝ᶜ = 0
[PROOFSTEP]
simp [hc]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : AEMeasurable f
⊢ essSup (g ∘ f) μ ≤ essSup g (Measure.map f μ)
[PROOFSTEP]
refine' limsSup_le_limsSup_of_le (fun t => _) (by isBoundedDefault) (by isBoundedDefault)
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : AEMeasurable f
⊢ IsCobounded (fun x x_1 => x ≤ x_1) (map (g ∘ f) (Measure.ae μ))
[PROOFSTEP]
isBoundedDefault
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : AEMeasurable f
⊢ IsBounded (fun x x_1 => x ≤ x_1) (map g (Measure.ae (Measure.map f μ)))
[PROOFSTEP]
isBoundedDefault
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : AEMeasurable f
t : Set β
⊢ t ∈ map g (Measure.ae (Measure.map f μ)) → t ∈ map (g ∘ f) (Measure.ae μ)
[PROOFSTEP]
simp_rw [Filter.mem_map]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : AEMeasurable f
t : Set β
⊢ g ⁻¹' t ∈ Measure.ae (Measure.map f μ) → g ∘ f ⁻¹' t ∈ Measure.ae μ
[PROOFSTEP]
have : g ∘ f ⁻¹' t = f ⁻¹' (g ⁻¹' t) := by
ext1 x
simp_rw [Set.mem_preimage, Function.comp]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : AEMeasurable f
t : Set β
⊢ g ∘ f ⁻¹' t = f ⁻¹' (g ⁻¹' t)
[PROOFSTEP]
ext1 x
[GOAL]
case h
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : AEMeasurable f
t : Set β
x : α
⊢ x ∈ g ∘ f ⁻¹' t ↔ x ∈ f ⁻¹' (g ⁻¹' t)
[PROOFSTEP]
simp_rw [Set.mem_preimage, Function.comp]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : AEMeasurable f
t : Set β
this : g ∘ f ⁻¹' t = f ⁻¹' (g ⁻¹' t)
⊢ g ⁻¹' t ∈ Measure.ae (Measure.map f μ) → g ∘ f ⁻¹' t ∈ Measure.ae μ
[PROOFSTEP]
rw [this]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : AEMeasurable f
t : Set β
this : g ∘ f ⁻¹' t = f ⁻¹' (g ⁻¹' t)
⊢ g ⁻¹' t ∈ Measure.ae (Measure.map f μ) → f ⁻¹' (g ⁻¹' t) ∈ Measure.ae μ
[PROOFSTEP]
exact fun h => mem_ae_of_mem_ae_map hf h
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : MeasurableEmbedding f
⊢ essSup g (Measure.map f μ) = essSup (g ∘ f) μ
[PROOFSTEP]
refine' le_antisymm _ (essSup_comp_le_essSup_map_measure hf.measurable.aemeasurable)
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : MeasurableEmbedding f
⊢ essSup g (Measure.map f μ) ≤ essSup (g ∘ f) μ
[PROOFSTEP]
refine' limsSup_le_limsSup (by isBoundedDefault) (by isBoundedDefault) (fun c h_le => _)
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : MeasurableEmbedding f
⊢ IsCobounded (fun x x_1 => x ≤ x_1) (map g (Measure.ae (Measure.map f μ)))
[PROOFSTEP]
isBoundedDefault
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : MeasurableEmbedding f
⊢ IsBounded (fun x x_1 => x ≤ x_1) (map (g ∘ f) (Measure.ae μ))
[PROOFSTEP]
isBoundedDefault
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : MeasurableEmbedding f
c : β
h_le : ∀ᶠ (n : β) in map (g ∘ f) (Measure.ae μ), n ≤ c
⊢ ∀ᶠ (n : β) in map g (Measure.ae (Measure.map f μ)), n ≤ c
[PROOFSTEP]
rw [eventually_map] at h_le ⊢
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
hf : MeasurableEmbedding f
c : β
h_le : ∀ᵐ (a : α) ∂μ, (g ∘ f) a ≤ c
⊢ ∀ᵐ (a : γ) ∂Measure.map f μ, g a ≤ c
[PROOFSTEP]
exact hf.ae_map_iff.mpr h_le
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝⁵ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
inst✝⁴ : MeasurableSpace β
inst✝³ : TopologicalSpace β
inst✝² : SecondCountableTopology β
inst✝¹ : OrderClosedTopology β
inst✝ : OpensMeasurableSpace β
hg : Measurable g
hf : AEMeasurable f
⊢ essSup g (Measure.map f μ) = essSup (g ∘ f) μ
[PROOFSTEP]
refine' le_antisymm _ (essSup_comp_le_essSup_map_measure hf)
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝⁵ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
inst✝⁴ : MeasurableSpace β
inst✝³ : TopologicalSpace β
inst✝² : SecondCountableTopology β
inst✝¹ : OrderClosedTopology β
inst✝ : OpensMeasurableSpace β
hg : Measurable g
hf : AEMeasurable f
⊢ essSup g (Measure.map f μ) ≤ essSup (g ∘ f) μ
[PROOFSTEP]
refine' limsSup_le_limsSup (by isBoundedDefault) (by isBoundedDefault) (fun c h_le => _)
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝⁵ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
inst✝⁴ : MeasurableSpace β
inst✝³ : TopologicalSpace β
inst✝² : SecondCountableTopology β
inst✝¹ : OrderClosedTopology β
inst✝ : OpensMeasurableSpace β
hg : Measurable g
hf : AEMeasurable f
⊢ IsCobounded (fun x x_1 => x ≤ x_1) (map g (Measure.ae (Measure.map f μ)))
[PROOFSTEP]
isBoundedDefault
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝⁵ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
inst✝⁴ : MeasurableSpace β
inst✝³ : TopologicalSpace β
inst✝² : SecondCountableTopology β
inst✝¹ : OrderClosedTopology β
inst✝ : OpensMeasurableSpace β
hg : Measurable g
hf : AEMeasurable f
⊢ IsBounded (fun x x_1 => x ≤ x_1) (map (g ∘ f) (Measure.ae μ))
[PROOFSTEP]
isBoundedDefault
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝⁵ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
inst✝⁴ : MeasurableSpace β
inst✝³ : TopologicalSpace β
inst✝² : SecondCountableTopology β
inst✝¹ : OrderClosedTopology β
inst✝ : OpensMeasurableSpace β
hg : Measurable g
hf : AEMeasurable f
c : β
h_le : ∀ᶠ (n : β) in map (g ∘ f) (Measure.ae μ), n ≤ c
⊢ ∀ᶠ (n : β) in map g (Measure.ae (Measure.map f μ)), n ≤ c
[PROOFSTEP]
rw [eventually_map] at h_le ⊢
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝⁵ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
inst✝⁴ : MeasurableSpace β
inst✝³ : TopologicalSpace β
inst✝² : SecondCountableTopology β
inst✝¹ : OrderClosedTopology β
inst✝ : OpensMeasurableSpace β
hg : Measurable g
hf : AEMeasurable f
c : β
h_le : ∀ᵐ (a : α) ∂μ, (g ∘ f) a ≤ c
⊢ ∀ᵐ (a : γ) ∂Measure.map f μ, g a ≤ c
[PROOFSTEP]
rw [ae_map_iff hf (measurableSet_le hg measurable_const)]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝⁵ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
inst✝⁴ : MeasurableSpace β
inst✝³ : TopologicalSpace β
inst✝² : SecondCountableTopology β
inst✝¹ : OrderClosedTopology β
inst✝ : OpensMeasurableSpace β
hg : Measurable g
hf : AEMeasurable f
c : β
h_le : ∀ᵐ (a : α) ∂μ, (g ∘ f) a ≤ c
⊢ ∀ᵐ (x : α) ∂μ, g (f x) ≤ c
[PROOFSTEP]
exact h_le
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝⁵ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
inst✝⁴ : MeasurableSpace β
inst✝³ : TopologicalSpace β
inst✝² : SecondCountableTopology β
inst✝¹ : OrderClosedTopology β
inst✝ : OpensMeasurableSpace β
hg : AEMeasurable g
hf : AEMeasurable f
⊢ essSup g (Measure.map f μ) = essSup (g ∘ f) μ
[PROOFSTEP]
rw [essSup_congr_ae hg.ae_eq_mk, essSup_map_measure_of_measurable hg.measurable_mk hf]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝⁵ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
inst✝⁴ : MeasurableSpace β
inst✝³ : TopologicalSpace β
inst✝² : SecondCountableTopology β
inst✝¹ : OrderClosedTopology β
inst✝ : OpensMeasurableSpace β
hg : AEMeasurable g
hf : AEMeasurable f
⊢ essSup (AEMeasurable.mk g hg ∘ f) μ = essSup (g ∘ f) μ
[PROOFSTEP]
refine' essSup_congr_ae _
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝⁵ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
inst✝⁴ : MeasurableSpace β
inst✝³ : TopologicalSpace β
inst✝² : SecondCountableTopology β
inst✝¹ : OrderClosedTopology β
inst✝ : OpensMeasurableSpace β
hg : AEMeasurable g
hf : AEMeasurable f
⊢ AEMeasurable.mk g hg ∘ f =ᵐ[μ] g ∘ f
[PROOFSTEP]
have h_eq := ae_of_ae_map hf hg.ae_eq_mk
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝⁵ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
inst✝⁴ : MeasurableSpace β
inst✝³ : TopologicalSpace β
inst✝² : SecondCountableTopology β
inst✝¹ : OrderClosedTopology β
inst✝ : OpensMeasurableSpace β
hg : AEMeasurable g
hf : AEMeasurable f
h_eq : ∀ᵐ (x : α) ∂μ, g (f x) = AEMeasurable.mk g hg (f x)
⊢ AEMeasurable.mk g hg ∘ f =ᵐ[μ] g ∘ f
[PROOFSTEP]
rw [← EventuallyEq] at h_eq
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝⁵ : CompleteLattice β
γ : Type u_3
mγ : MeasurableSpace γ
f : α → γ
g : γ → β
inst✝⁴ : MeasurableSpace β
inst✝³ : TopologicalSpace β
inst✝² : SecondCountableTopology β
inst✝¹ : OrderClosedTopology β
inst✝ : OpensMeasurableSpace β
hg : AEMeasurable g
hf : AEMeasurable f
h_eq : (fun x => g (f x)) =ᵐ[μ] fun x => AEMeasurable.mk g hg (f x)
⊢ AEMeasurable.mk g hg ∘ f =ᵐ[μ] g ∘ f
[PROOFSTEP]
exact h_eq.symm
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
⊢ essSup (indicator s f) μ = essSup f (Measure.restrict μ s)
[PROOFSTEP]
refine'
le_antisymm _
(limsSup_le_limsSup_of_le (map_restrict_ae_le_map_indicator_ae hs) (by isBoundedDefault) (by isBoundedDefault))
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
⊢ IsCobounded (fun x x_1 => x ≤ x_1) (map f (Measure.ae (Measure.restrict μ s)))
[PROOFSTEP]
isBoundedDefault
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
⊢ IsBounded (fun x x_1 => x ≤ x_1) (map (indicator s f) (Measure.ae μ))
[PROOFSTEP]
isBoundedDefault
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
⊢ essSup (indicator s f) μ ≤ essSup f (Measure.restrict μ s)
[PROOFSTEP]
refine' limsSup_le_limsSup (by isBoundedDefault) (by isBoundedDefault) (fun c h_restrict_le => _)
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
⊢ IsCobounded (fun x x_1 => x ≤ x_1) (map (indicator s f) (Measure.ae μ))
[PROOFSTEP]
isBoundedDefault
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
⊢ IsBounded (fun x x_1 => x ≤ x_1) (map f (Measure.ae (Measure.restrict μ s)))
[PROOFSTEP]
isBoundedDefault
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᶠ (n : β) in map f (Measure.ae (Measure.restrict μ s)), n ≤ c
⊢ ∀ᶠ (n : β) in map (indicator s f) (Measure.ae μ), n ≤ c
[PROOFSTEP]
rw [eventually_map] at h_restrict_le ⊢
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (a : α) ∂Measure.restrict μ s, f a ≤ c
⊢ ∀ᵐ (a : α) ∂μ, indicator s f a ≤ c
[PROOFSTEP]
rw [ae_restrict_iff' hs] at h_restrict_le
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
⊢ ∀ᵐ (a : α) ∂μ, indicator s f a ≤ c
[PROOFSTEP]
have hc : 0 ≤ c := by
rsuffices ⟨x, hx⟩ : ∃ x, 0 ≤ f x ∧ f x ≤ c
exact hx.1.trans hx.2
refine' Frequently.exists _
· exact μ.ae
rw [EventuallyLE, ae_restrict_iff' hs] at hf
have hs' : ∃ᵐ x ∂μ, x ∈ s := by
contrapose! hs_not_null
rw [not_frequently, ae_iff] at hs_not_null
suffices {a : α | ¬a ∉ s} = s by rwa [← this]
simp
refine' hs'.mp (hf.mp (h_restrict_le.mono fun x hxs_imp_c hxf_nonneg hxs => _))
rw [Pi.zero_apply] at hxf_nonneg
exact ⟨hxf_nonneg hxs, hxs_imp_c hxs⟩
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
⊢ 0 ≤ c
[PROOFSTEP]
rsuffices ⟨x, hx⟩ : ∃ x, 0 ≤ f x ∧ f x ≤ c
[GOAL]
case intro
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
x : α
hx : 0 ≤ f x ∧ f x ≤ c
⊢ 0 ≤ c
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
⊢ ∃ x, 0 ≤ f x ∧ f x ≤ c
[PROOFSTEP]
exact hx.1.trans hx.2
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
⊢ ∃ x, 0 ≤ f x ∧ f x ≤ c
[PROOFSTEP]
refine' Frequently.exists _
[GOAL]
case refine'_1
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
⊢ Filter α
[PROOFSTEP]
exact μ.ae
[GOAL]
case refine'_2
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
⊢ ∃ᵐ (x : α) ∂μ, 0 ≤ f x ∧ f x ≤ c
[PROOFSTEP]
rw [EventuallyLE, ae_restrict_iff' hs] at hf
[GOAL]
case refine'_2
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : ∀ᵐ (x : α) ∂μ, x ∈ s → OfNat.ofNat 0 x ≤ f x
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
⊢ ∃ᵐ (x : α) ∂μ, 0 ≤ f x ∧ f x ≤ c
[PROOFSTEP]
have hs' : ∃ᵐ x ∂μ, x ∈ s := by
contrapose! hs_not_null
rw [not_frequently, ae_iff] at hs_not_null
suffices {a : α | ¬a ∉ s} = s by rwa [← this]
simp
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : ∀ᵐ (x : α) ∂μ, x ∈ s → OfNat.ofNat 0 x ≤ f x
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
⊢ ∃ᵐ (x : α) ∂μ, x ∈ s
[PROOFSTEP]
contrapose! hs_not_null
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : ∀ᵐ (x : α) ∂μ, x ∈ s → OfNat.ofNat 0 x ≤ f x
hs : MeasurableSet s
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
hs_not_null : ¬∃ᵐ (x : α) ∂μ, x ∈ s
⊢ ↑↑μ s = 0
[PROOFSTEP]
rw [not_frequently, ae_iff] at hs_not_null
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : ∀ᵐ (x : α) ∂μ, x ∈ s → OfNat.ofNat 0 x ≤ f x
hs : MeasurableSet s
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
hs_not_null : ↑↑μ {a | ¬¬a ∈ s} = 0
⊢ ↑↑μ s = 0
[PROOFSTEP]
suffices {a : α | ¬a ∉ s} = s by rwa [← this]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : ∀ᵐ (x : α) ∂μ, x ∈ s → OfNat.ofNat 0 x ≤ f x
hs : MeasurableSet s
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
hs_not_null : ↑↑μ {a | ¬¬a ∈ s} = 0
this : {a | ¬¬a ∈ s} = s
⊢ ↑↑μ s = 0
[PROOFSTEP]
rwa [← this]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : ∀ᵐ (x : α) ∂μ, x ∈ s → OfNat.ofNat 0 x ≤ f x
hs : MeasurableSet s
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
hs_not_null : ↑↑μ {a | ¬¬a ∈ s} = 0
⊢ {a | ¬¬a ∈ s} = s
[PROOFSTEP]
simp
[GOAL]
case refine'_2
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : ∀ᵐ (x : α) ∂μ, x ∈ s → OfNat.ofNat 0 x ≤ f x
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
hs' : ∃ᵐ (x : α) ∂μ, x ∈ s
⊢ ∃ᵐ (x : α) ∂μ, 0 ≤ f x ∧ f x ≤ c
[PROOFSTEP]
refine' hs'.mp (hf.mp (h_restrict_le.mono fun x hxs_imp_c hxf_nonneg hxs => _))
[GOAL]
case refine'_2
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : ∀ᵐ (x : α) ∂μ, x ∈ s → OfNat.ofNat 0 x ≤ f x
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
hs' : ∃ᵐ (x : α) ∂μ, x ∈ s
x : α
hxs_imp_c : x ∈ s → f x ≤ c
hxf_nonneg : x ∈ s → OfNat.ofNat 0 x ≤ f x
hxs : x ∈ s
⊢ 0 ≤ f x ∧ f x ≤ c
[PROOFSTEP]
rw [Pi.zero_apply] at hxf_nonneg
[GOAL]
case refine'_2
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : ∀ᵐ (x : α) ∂μ, x ∈ s → OfNat.ofNat 0 x ≤ f x
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
hs' : ∃ᵐ (x : α) ∂μ, x ∈ s
x : α
hxs_imp_c : x ∈ s → f x ≤ c
hxf_nonneg : x ∈ s → 0 ≤ f x
hxs : x ∈ s
⊢ 0 ≤ f x ∧ f x ≤ c
[PROOFSTEP]
exact ⟨hxf_nonneg hxs, hxs_imp_c hxs⟩
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
hc : 0 ≤ c
⊢ ∀ᵐ (a : α) ∂μ, indicator s f a ≤ c
[PROOFSTEP]
refine' h_restrict_le.mono fun x hxc => _
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
hc : 0 ≤ c
x : α
hxc : x ∈ s → f x ≤ c
⊢ indicator s f x ≤ c
[PROOFSTEP]
by_cases hxs : x ∈ s
[GOAL]
case pos
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
hc : 0 ≤ c
x : α
hxc : x ∈ s → f x ≤ c
hxs : x ∈ s
⊢ indicator s f x ≤ c
[PROOFSTEP]
simpa [hxs] using hxc hxs
[GOAL]
case neg
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : CompleteLinearOrder β
inst✝ : Zero β
s : Set α
f : α → β
hf : 0 ≤ᵐ[Measure.restrict μ s] f
hs : MeasurableSet s
hs_not_null : ↑↑μ s ≠ 0
c : β
h_restrict_le : ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ c
hc : 0 ≤ c
x : α
hxc : x ∈ s → f x ≤ c
hxs : ¬x ∈ s
⊢ indicator s f x ≤ c
[PROOFSTEP]
simpa [hxs] using hc
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
f✝ : α → ℝ≥0∞
ι : Type u_3
inst✝¹ : Countable ι
inst✝ : LinearOrder ι
f : ι → α → ℝ≥0∞
⊢ essSup (fun x => liminf (fun n => f n x) atTop) μ ≤ liminf (fun n => essSup (fun x => f n x) μ) atTop
[PROOFSTEP]
simp_rw [essSup]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
f✝ : α → ℝ≥0∞
ι : Type u_3
inst✝¹ : Countable ι
inst✝ : LinearOrder ι
f : ι → α → ℝ≥0∞
⊢ limsup (fun x => liminf (fun n => f n x) atTop) (Measure.ae μ) ≤
liminf (fun n => limsup (fun x => f n x) (Measure.ae μ)) atTop
[PROOFSTEP]
exact ENNReal.limsup_liminf_le_liminf_limsup fun a b => f b a
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
f✝ : α → ℝ≥0∞
f : α → ℝ≥0
hf : IsBoundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae μ) f
r : ℝ≥0∞
⊢ r ≤
⨅ (a : ℝ≥0) (_ : a ∈ fun x => sets (map f (Measure.ae μ)) {x_1 | (fun x_2 => (fun x x_3 => x ≤ x_3) x_2 x) x_1}),
↑a ↔
r ≤ essSup (fun x => ↑(f x)) μ
[PROOFSTEP]
simp [essSup, limsup, limsSup, eventually_map, ENNReal.forall_ennreal]
[GOAL]
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
f✝ : α → ℝ≥0∞
f : α → ℝ≥0
hf : IsBoundedUnder (fun x x_1 => x ≤ x_1) (Measure.ae μ) f
r : ℝ≥0∞
⊢ (∀ (i : ℝ≥0), (i ∈ fun x => sets (map f (Measure.ae μ)) {x_1 | x_1 ≤ x}) → r ≤ ↑i) ↔
∀ (r_1 : ℝ≥0), (∀ᵐ (a : α) ∂μ, f a ≤ r_1) → r ≤ ↑r_1
[PROOFSTEP]
rfl
|
(* 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_77
imports "../../Test_Base"
begin
datatype 'a list = nil2 | cons2 "'a" "'a list"
datatype Nat = Z | S "Nat"
fun x :: "bool => bool => bool" where
"x True z = z"
| "x False z = False"
fun t2 :: "Nat => Nat => bool" where
"t2 (Z) z = True"
| "t2 (S z2) (Z) = False"
| "t2 (S z2) (S x2) = t2 z2 x2"
fun insort :: "Nat => Nat list => Nat list" where
"insort y (nil2) = cons2 y (nil2)"
| "insort y (cons2 z2 xs) =
(if t2 y z2 then cons2 y (cons2 z2 xs) else cons2 z2 (insort y xs))"
fun sorted :: "Nat list => bool" where
"sorted (nil2) = True"
| "sorted (cons2 z (nil2)) = True"
| "sorted (cons2 z (cons2 y2 ys)) =
x (t2 z y2) (sorted (cons2 y2 ys))"
theorem property0 :
"((sorted xs) ==> (sorted (insort y xs)))"
oops
end
|
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Mario Carneiro
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.data.multiset.powerset
import Mathlib.PostPort
universes u_1 u_2
namespace Mathlib
/-!
# The antidiagonal on a multiset.
The antidiagonal of a multiset `s` consists of all pairs `(t₁, t₂)`
such that `t₁ + t₂ = s`. These pairs are counted with multiplicities.
-/
namespace multiset
/-- The antidiagonal of a multiset `s` consists of all pairs `(t₁, t₂)`
such that `t₁ + t₂ = s`. These pairs are counted with multiplicities. -/
def antidiagonal {α : Type u_1} (s : multiset α) : multiset (multiset α × multiset α) :=
quot.lift_on s (fun (l : List α) => ↑(list.revzip (powerset_aux l))) sorry
theorem antidiagonal_coe {α : Type u_1} (l : List α) : antidiagonal ↑l = ↑(list.revzip (powerset_aux l)) :=
rfl
@[simp] theorem antidiagonal_coe' {α : Type u_1} (l : List α) : antidiagonal ↑l = ↑(list.revzip (powerset_aux' l)) :=
quot.sound revzip_powerset_aux_perm_aux'
/-- A pair `(t₁, t₂)` of multisets is contained in `antidiagonal s`
if and only if `t₁ + t₂ = s`. -/
@[simp] theorem mem_antidiagonal {α : Type u_1} {s : multiset α} {x : multiset α × multiset α} : x ∈ antidiagonal s ↔ prod.fst x + prod.snd x = s := sorry
@[simp] theorem antidiagonal_map_fst {α : Type u_1} (s : multiset α) : map prod.fst (antidiagonal s) = powerset s := sorry
@[simp] theorem antidiagonal_map_snd {α : Type u_1} (s : multiset α) : map prod.snd (antidiagonal s) = powerset s := sorry
@[simp] theorem antidiagonal_zero {α : Type u_1} : antidiagonal 0 = (0, 0) ::ₘ 0 :=
rfl
@[simp] theorem antidiagonal_cons {α : Type u_1} (a : α) (s : multiset α) : antidiagonal (a ::ₘ s) = map (prod.map id (cons a)) (antidiagonal s) + map (prod.map (cons a) id) (antidiagonal s) := sorry
@[simp] theorem card_antidiagonal {α : Type u_1} (s : multiset α) : coe_fn card (antidiagonal s) = bit0 1 ^ coe_fn card s := sorry
theorem prod_map_add {α : Type u_1} {β : Type u_2} [comm_semiring β] {s : multiset α} {f : α → β} {g : α → β} : prod (map (fun (a : α) => f a + g a) s) =
sum
(map (fun (p : multiset α × multiset α) => prod (map f (prod.fst p)) * prod (map g (prod.snd p))) (antidiagonal s)) := sorry
|
Formal statement is: lemma higher_deriv_add: fixes z::complex assumes "f holomorphic_on S" "g holomorphic_on S" "open S" and z: "z \<in> S" shows "(deriv ^^ n) (\<lambda>w. f w + g w) z = (deriv ^^ n) f z + (deriv ^^ n) g z" Informal statement is: If $f$ and $g$ are holomorphic functions on an open set $S$, then the $n$th derivative of $f + g$ is equal to the $n$th derivative of $f$ plus the $n$th derivative of $g$. |
section \<open>Values\<close>
theory Sep_Value
imports
"../../lib/Monad"
begin
subsection \<open>Values and Addresses\<close>
datatype 'a val = STRUCT (fields: "'a val list") | PRIMITIVE (the: 'a)
hide_const (open) val.fields val.the
define_lenses (open) val
datatype va_item = PFLD (the_va_item_idx: nat)
type_synonym vaddr = "va_item list"
subsection \<open>Focusing on Address\<close>
fun lens_of_item where
"lens_of_item (PFLD i) = val.fields\<^sub>L \<bullet>\<^sub>L idx\<^sub>L i"
definition "lens_of_vaddr vp = foldr (\<lambda>i L. lens_of_item i \<bullet>\<^sub>L L) vp id\<^sub>L"
lemma lens_of_vaddr_simps[simp]:
"lens_of_vaddr [] = id\<^sub>L"
"lens_of_vaddr (i#is) = lens_of_item i \<bullet>\<^sub>L lens_of_vaddr is"
unfolding lens_of_vaddr_def
by auto
lemma ex_two_vals[simp, intro]: "\<exists>a b::'a val. a \<noteq> b" by auto
lemma lens_of_item_rnl[simp, intro!]: "rnlens (lens_of_item i :: 'a val \<Longrightarrow> 'a val)"
proof (cases i)
case [simp]: (PFLD i)
show ?thesis
apply (rule rnlensI[where x="PRIMITIVE undefined" and y="STRUCT undefined" and s="STRUCT (replicate (Suc i) undefined)"])
by simp_all
qed
lemma lens_of_item_hlens[simp, intro!]: "hlens (lens_of_item i :: 'a val \<Longrightarrow> 'a val)"
by (cases i) (auto)
lemma lens_of_vaddr_rnl[simp, intro!]: "rnlens (lens_of_vaddr vp)"
by (induction vp) auto
lemma lens_of_vaddr_hlens[simp, intro!]: "hlens (lens_of_vaddr vp)"
by (induction vp) auto
lemma lens_of_item_complete[simp, intro!]: "complete_lens (lens_of_item i)"
apply (rule)
apply (simp; fail)
by (meson lens.get_put lens.get_put_pre lens_of_item_rnl rnlens_def)
subsection \<open>Loading and Storing Address\<close>
definition "vload err a \<equiv> zoom (lift_lens err (lens_of_vaddr a)) Monad.get"
definition "vstore err x a \<equiv> zoom (lift_lens err (lens_of_vaddr a)) (Monad.set x)"
subsection \<open>GEP\<close>
definition "checked_gep err addr item \<equiv> doM {
let addr = addr@[item];
use (lift_lens err (lens_of_vaddr addr));
return addr
}"
subsection \<open>Structure of Value\<close>
datatype 's vstruct = VS_STRUCT "'s vstruct list" | VS_PRIMITIVE 's
locale structured_value_defs =
fixes struct_of_primval :: "'a \<Rightarrow> 's"
and init_primval :: "'s \<Rightarrow> 'a"
begin
fun struct_of_val :: "'a val \<Rightarrow> 's vstruct" where
"struct_of_val (STRUCT fs) = VS_STRUCT (map struct_of_val fs)"
| "struct_of_val (PRIMITIVE x) = VS_PRIMITIVE (struct_of_primval x)"
fun init_val :: "'s vstruct \<Rightarrow> 'a val" where
"init_val (VS_STRUCT fs) = STRUCT (map init_val fs)"
| "init_val (VS_PRIMITIVE ps) = PRIMITIVE (init_primval ps)"
end
lemmas structured_value_code[code] =
structured_value_defs.struct_of_val.simps
structured_value_defs.init_val.simps
locale structured_value = structured_value_defs struct_of_primval init_primval
for struct_of_primval :: "'a \<Rightarrow> 's"
and init_primval :: "'s \<Rightarrow> 'a" +
assumes struct_of_init_primval[simp]: "struct_of_primval (init_primval s) = s"
begin
lemma put_preserves_struct:
assumes "pre_get (lens_of_vaddr a) s"
assumes "struct_of_val (get' (lens_of_vaddr a) s) = struct_of_val x"
shows "struct_of_val (put' (lens_of_vaddr a) x s) = struct_of_val s"
using assms
proof (induction a arbitrary: s)
case Nil
then show ?case by auto
next
case (Cons i as)
then show ?case
by (cases s; cases i; simp add: map_upd_eq)
qed
lemma struct_of_init[simp]: "struct_of_val (init_val s) = s"
apply (induction s)
by (auto simp: map_idI)
end
end
|
/-
Copyright (c) 2022 Jannis Limperg. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sebastian Ullrich, Jannis Limperg
-/
import Aesop
set_option aesop.check.all true
namespace TBA
inductive List (α : Type) where
| nil : List α
| cons (head : α) (tail : List α) : List α
notation (priority := high) "[" "]" => List.nil
infixr:67 (priority := high) " :: " => List.cons
def filter (p : α → Prop) [DecidablePred p] (as : List α) : List α :=
match as with
| [] => []
| a::as => if p a then a :: filter p as else filter p as
variable {p : α → Prop} [DecidablePred p] {as bs : List α}
@[simp]
theorem filter_cons_true (h : p a) : filter p (a :: as) = a :: filter p as := by
simp [filter, h]
@[simp]
theorem filter_cons_false (h : ¬ p a) : filter p (a :: as) = filter p as := by
simp [filter, h]
@[aesop 50% [constructors, cases]]
inductive Mem (a : α) : List α → Prop where
| head {as} : Mem a (a::as)
| tail {as} : Mem a as → Mem a (a'::as)
infix:50 " ∈ " => Mem
theorem mem_filter : a ∈ filter p as ↔ a ∈ as ∧ p a := by
apply Iff.intro
case mp =>
intro h
induction as with
| nil => cases h
| cons a' as ih => by_cases ha' : p a' <;> aesop
case mpr =>
intro h
induction as with
| nil => cases h.1
| cons a' as ih =>
cases h.1 with
| head =>
rw [filter_cons_true h.2]
constructor
| tail ha =>
have : a ∈ filter p as := ih ⟨ha, h.2⟩
by_cases hpa' : p a'
case pos =>
rw [filter_cons_true hpa']
exact Mem.tail this
case neg =>
rw [filter_cons_false hpa']
exact this
end TBA
|
Formal statement is: lemma filterlim_pow_at_bot_odd: fixes f :: "real \<Rightarrow> real" shows "0 < n \<Longrightarrow> LIM x F. f x :> at_bot \<Longrightarrow> odd n \<Longrightarrow> LIM x F. (f x)^n :> at_bot" Informal statement is: If $f$ is a real-valued function that converges to $-\infty$ as $x$ approaches $-\infty$ along a filter $F$, and $n$ is an odd positive integer, then $f^n$ converges to $-\infty$ as $x$ approaches $-\infty$ along $F$. |
theory Abbrevs
imports PIMP SyntaxTweaks
begin
text \<open>now we can use dots as a term\<close>
consts dots::"'a" ("\<dots>")
lemma conj_to_impl: "(P \<and> Q \<longrightarrow> R) = (P \<longrightarrow> Q \<longrightarrow> R)"
by auto
notation (in xvalid_program) (latex output)
barrier_inv ("flush'_inv")
abbreviation
"acquire sb owns \<equiv> acquired True sb owns"
notation (latex output)
direct_memop_step ("_ \<^latex>\<open>$\\overset{\\isa{v}_\\isa{d}}{\\rightarrow}_{\\isa{m}}$\<close> _" [60,60] 100)
notation (latex output)
virtual_memop_step ("_ \<^latex>\<open>$\\overset{\\isa{v}}{\\rightarrow}_{\\isa{m}}$\<close> _" [60,60] 100)
context program
begin
term "(ts, m) \<Rightarrow>\<^sub>s\<^sub>b (ts',m')"
notation (latex output) store_buffer.concurrent_step ("_ \<^latex>\<open>$\\overset{\\isa{sb}}{\\Rightarrow}$\<close> _" [60,60] 100)
notation (latex output) virtual.concurrent_step ("_ \<^latex>\<open>$\\overset{\\isa{v}}{\\Rightarrow}$\<close> _" [60,60] 100)
thm store_buffer.concurrent_step.Program
end
abbreviation (output)
"sbh_global_step \<equiv> computation.concurrent_step sbh_memop_step flush_step stmt_step (\<lambda>p p' is sb. sb @ [Prog\<^sub>s\<^sub>b p p' is])"
notation (latex output)
sbh_global_step ("_ \<^latex>\<open>$\\overset{\\isa{sbh}}{\\Rightarrow}$\<close> _" [60,60] 100)
notation (latex output)
direct_pimp_step ("_ \<^latex>\<open>$\\overset{\\isa{v}}{\\Rightarrow}$\<close> _" [60,60] 100)
notation (latex output)
sbh_memop_step ("_ \<^latex>\<open>$\\overset{\\isa{sbh}}{\\rightarrow}_{\\isa{m}}$\<close> _" [60,60] 100)
notation (latex output)
sb_memop_step ("_ \<^latex>\<open>$\\overset{\\isa{sb}}{\\rightarrow}_{\\isa{m}}$\<close> _" [60,60] 100)
notation (output)
sim_direct_config ("_ \<sim> _ " [60,60] 100)
notation (output)
flush_step ("_ \<rightarrow>\<^sub>s\<^sub>b\<^sub>h _" [60,60] 100)
notation (output)
store_buffer_step ("_ \<rightarrow>\<^sub>s\<^sub>b _" [60,60] 100)
notation (output)
outstanding_refs ("refs")
notation (output)
is_volatile_Write\<^sub>s\<^sub>b ("volatile'_Write")
abbreviation (output)
"not_volatile_write \<equiv> Not \<circ> is_volatile_Write\<^sub>s\<^sub>b"
notation (output)
"flush_all_until_volatile_write" ("exec'_all'_until'_volatile'_write")
notation (output)
"share_all_until_volatile_write" ("share'_all'_until'_volatile'_write")
notation (output)
stmt_step ("_\<turnstile> _ \<rightarrow>\<^sub>p _" [60,60,60] 100)
notation (output)
augment_rels ("aug")
context program
begin
notation (latex output)
direct_concurrent_step ("_ \<^latex>\<open>$\\overset{\\isa{v}_\\isa{d}}{\\Rightarrow}$\<close> _" [60,60] 100)
notation (latex output)
direct_concurrent_steps ("_ \<^latex>\<open>$\\overset{\\isa{v}_\\isa{d}}{\\Rightarrow}^{*}$\<close> _" [60,60] 100)
notation (latex output)
sbh_concurrent_step ("_ \<^latex>\<open>$\\overset{\\isa{sbh}}{\\Rightarrow}$\<close> _" [60,60] 100)
notation (latex output)
sbh_concurrent_steps ("_ \<^latex>\<open>$\\overset{\\isa{sbh}}{\\Rightarrow}^{*}$\<close> _" [60,60] 100)
notation (latex output)
sb_concurrent_step ("_ \<^latex>\<open>$\\overset{\\isa{sb}}{\\Rightarrow}$\<close> _" [60,60] 100)
notation (latex output)
sb_concurrent_steps ("_ \<^latex>\<open>$\\overset{\\isa{sb}}{\\Rightarrow}^{*}$\<close> _" [60,60] 100)
notation (latex output)
virtual_concurrent_step ("_ \<^latex>\<open>$\\overset{\\isa{v}}{\\Rightarrow}$\<close> _" [60,60] 100)
notation (latex output)
virtual_concurrent_steps ("_ \<^latex>\<open>$\\overset{\\isa{v}}{\\Rightarrow}^{*}$\<close> _" [60,60] 100)
end
context xvalid_program_progress
begin
abbreviation
"safe_reach_virtual_free_flowing \<equiv> safe_reach virtual_concurrent_step safe_free_flowing"
notation (latex output)
"safe_reach_virtual_free_flowing" ("safe'_reach")
abbreviation
"safe_reach_direct_delayed \<equiv> safe_reach direct_concurrent_step safe_delayed"
notation (latex output)
"safe_reach_direct_delayed" ("safe'_reach'_delayed")
end
(* hide unit's in tuples *)
translations
"x" <= "(x,())"
"x" <= "((),x)"
translations
"CONST initial\<^sub>v xs ys" <= "CONST initial\<^sub>v xs ys zs"
end
|
lemma filterlim_subseq: "strict_mono f \<Longrightarrow> filterlim f sequentially sequentially" |
lemma homeomorphic_subspaces: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" assumes S: "subspace S" and T: "subspace T" and d: "dim S = dim T" shows "S homeomorphic T" |
subroutine wridoc(error, neffil, ftype, simdat, runtxt, commrd, part_nr, gdp)
!----- GPL ---------------------------------------------------------------------
!
! Copyright (C) Stichting Deltares, 2011-2016.
!
! This program is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation version 3.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
!
! contact: [email protected]
! Stichting Deltares
! P.O. Box 177
! 2600 MH Delft, The Netherlands
!
! All indications and logos of, and references to, "Delft3D" and "Deltares"
! are registered trademarks of Stichting Deltares, and remain the property of
! Stichting Deltares. All rights reserved.
!
!-------------------------------------------------------------------------------
! $Id: wridoc.f90 5717 2016-01-12 11:35:24Z mourits $
! $HeadURL: https://svn.oss.deltares.nl/repos/delft3d/tags/6686/src/engines_gpl/flow2d3d/packages/io/src/output/wridoc.f90 $
!!--description-----------------------------------------------------------------
!
! Function: Writes the initial group 4 ('"ftype"-version') to
! the "ftype"-DAT/DEF files
! Method used:
!
!!--pseudo code and references--------------------------------------------------
! NONE
!!--declarations----------------------------------------------------------------
use precision
use datagroups
use globaldata
use string_module
!
implicit none
!
type(globdat),target :: gdp
!
! The following list of pointer parameters is used to point inside the gdp structure
!
logical , pointer :: first
integer , pointer :: lundia ! Description and declaration in inout.igs
integer , pointer :: lunprt ! Description and declaration in inout.igs
character*131, dimension(:), pointer :: header ! Description and declaration in postpr.igs
logical :: commrd
type (datagroup) , pointer :: group
!
! Global variables
!
logical , intent(out) :: error !! Flag=TRUE if an error is encountered
character(*) , intent(in) :: neffil !! File name for FLOW NEFIS output
!! files: tri"h/m/d"-"casl""labl" or
!! for Comm. file com-"casl""labl"
character(*) , intent(in) :: part_nr !! Partition number string
character(16) , intent(in) :: simdat !! Simulation date representing the flow condition at this date
character(6) , intent(in) :: ftype !! String containing to which output file version group or to diagnostic file should be written
character(30), dimension(10) :: runtxt !! Textual description of model input
!
! Local variables
!
integer :: fds
integer :: IO_FIL
integer :: i ! Help var.
integer :: ierror ! Local errorflag for NEFIS files
integer :: iheader ! Loop counter for writing header
integer :: lrid ! Help var. to determine the actual length of RUNID
integer :: lridmx ! Help var. for lunprt: LRID < 47
integer :: na
integer , dimension(3,5) :: uindex
integer , external :: putels
integer , external :: clsnef
integer , external :: open_datdef
integer , external :: neferr
character(10) :: date ! Date to be filled in the header
character(256) :: datnam
character(256) :: defnam
character(16), dimension(1) :: cdum16 ! Help array to read/write Nefis files
character(16) :: grnam4 ! Data-group name defined for the NEFIS-files
character(256) :: filnam ! Help var. for FLOW file name
character(4) :: errnr ! Character var. containing the errormessage number corresponding to errormessage in ERRFIL
character(256) :: errmsg ! Character var. containing the errormessage to be written to file. The message depends on the error.
character(20) :: rundat ! Current date and time containing a combination of DATE and TIME
character(256) :: version_full ! Version nr. of the module of the current package
character(256), dimension(1) :: cdumcident ! Help array to read/write Nefis files
!
!! executable statements -------------------------------------------------------
!
lundia => gdp%gdinout%lundia
lunprt => gdp%gdinout%lunprt
header => gdp%gdpostpr%header
!
!
! Initialize local variables
!
ierror = 0
!
filnam = neffil
if (ftype(1:3)/='com') filnam = neffil(1:3) // ftype(1:1) // trim(neffil(5:)) // trim(part_nr)
grnam4 = ftype(1:3) // '-version'
errmsg = ' '
!
! Write system definition to diagnostic file for ftype = 'dia' and skip rest of routine
!
version_full = ' '
!version_short = ' '
call getfullversionstring_flow2d3d(version_full)
!
if (ftype(1:3) == 'dia') then
! nothing
elseif (ftype(1:5) == 'ascii') then
!
! write start date and time to LUNPRT
!
call remove_leading_spaces(gdp%runid, lrid)
lridmx = min(lrid, 47)
!
! Date and time
!
call dattim(rundat)
date(1:4) = rundat(1:4)
date(5:5) = '-'
date(6:7) = rundat(6:7)
date(8:8) = '-'
date(9:10) = rundat(9:10)
!
! Version info
!
write (header(1 ), '(131a1)' ) ('*', na = 1, 131)
write (header(2 ), '(a,a,a,a,a,a,a,a,a,t129,a)') &
& '*** Print of ', 'Delft3D-FLOW', ' for Run ', gdp%runid(:lridmx) , ' - Simulation date: ', &
& date, ' ', rundat(11:19), ' page 1', '***'
write (header(3 ), '(2a,t129,a)') '*** ', trim(version_full), '***'
write (header(4 ), '(a,t129,a)' ) '*** User: Unknown ', '***'
write (header(5 ), '(131a1)' ) ('*', na = 1, 131)
write (header(6 ), '(a)' )
write (header(10), '(a)' )
!
do iheader = 1,5
write (lunprt, '(a)') header(iheader)
enddo
else
select case (ftype(1:3))
case ('his')
IO_FIL = FILOUT_HIS
case ('map')
IO_FIL = FILOUT_MAP
case ('dro')
IO_FIL = FILOUT_DRO
case ('com')
IO_FIL = FILOUT_COM
end select
!
call getdatagroup(gdp, IO_FIL, grnam4, group)
first => group%first
!
if (first) then
!
! Set up the element chracteristics
!
call addelm(gdp, lundia, IO_FIL, grnam4, 'FLOW-SIMDAT', ' ', 16, 1, (/1/), ' ', 'FLOW Simulation date and time [YYYYMMDD HHMMSS]', '[ - ]') !CHARACTER
call addelm(gdp, lundia, IO_FIL, grnam4, 'FLOW-SYSTXT', ' ', 256, 1, (/1/), ' ', 'FLOW System description', '[ - ]') !CHARACTER
call addelm(gdp, lundia, IO_FIL, grnam4, 'FLOW-RUNTXT', ' ', 30, 1, (/10/), ' ', 'FLOW User defined Model description', '[ - ]') !CHARACTER
call addelm(gdp, lundia, IO_FIL, grnam4, 'FILE-VERSION', ' ', 16, 1, (/1/), ' ', 'Version number of file', '[ - ]') !CHARACTER
endif
!
ierror = open_datdef(filnam, fds, .false.)
if (ierror /= 0) goto 9999
!
if (first) then
call defnewgrp(fds, IO_FIL, grnam4, gdp, filnam, errlog=ERRLOG_NONE)
first = .false.
endif
!
! initialize group index
!
uindex (1,1) = 1 ! start index
uindex (2,1) = 1 ! end index
uindex (3,1) = 1 ! increment in time
!
! element 'FLOW-SIMDAT'
!
cdum16(1) = simdat
ierror = putels(fds, grnam4, 'FLOW-SIMDAT', uindex, 1, cdum16)
if (ierror/= 0) goto 9999
!
! element 'FLOW-SYSTXT'
!
cdumcident(1) = trim(version_full)
ierror = putels(fds, grnam4, 'FLOW-SYSTXT', uindex, 1, cdumcident)
if (ierror/= 0) goto 9999
!
! element 'FLOW-RUNTXT'
!
ierror = putels(fds, grnam4, 'FLOW-RUNTXT', uindex, 1, runtxt)
if (ierror/= 0) goto 9999
!
! element 'FILE-VERSION'
! drogues file 'd'
! history file 'h'
! map file 'f'
! comm file 'c'
!
cdum16(1) = '00.00.00.00'
if (ftype(1:1)=='d') then
call getdrofileversionstring_flow2d3d(cdum16(1))
elseif (ftype(1:1)=='h') then
call gethisfileversionstring_flow2d3d(cdum16(1))
elseif (ftype(1:1)=='m') then
call getmapfileversionstring_flow2d3d(cdum16(1))
elseif (ftype(1:1)=='c') then
call getcomfileversionstring_flow2d3d(cdum16(1))
else
endif
if (ftype(1:1)=='c') then
!
! Check if COM-file is a new one or an existing one
!
if (.not. commrd) then
!
! COM-file has been newly generated
!
ierror = putels(fds, grnam4, 'FILE-VERSION', uindex, 1, cdum16)
if (ierror/= 0) goto 9999
endif
else
ierror = putels(fds, grnam4, 'FILE-VERSION', uindex, 1, cdum16)
if (ierror/= 0) goto 9999
endif
!
ierror = clsnef(fds)
endif
!
! write error message if error occured and set error= .true.
!
9999 continue
if (ierror /= 0) then
ierror = neferr(0, errmsg)
call prterr(lundia, 'P004', errmsg)
error= .true.
endif
end subroutine wridoc
|
lemma banach_fix_type: fixes f::"'a::complete_space\<Rightarrow>'a" assumes c:"0 \<le> c" "c < 1" and lipschitz:"\<forall>x. \<forall>y. dist (f x) (f y) \<le> c * dist x y" shows "\<exists>!x. (f x = x)" |
SUBROUTINE INITGL (IDENT)
C Initgl accepts the identifying hierarchical number of the test
C program and initializes the GLOBAL COMMON variables, mostly from
C values read from the INITPH.DAT file. It then opens message
C files as indicated by control variables. This routine is
C normally the first thing called by a test program.
COMMON /GLOBNU/ CTLHND, ERRSIG, ERRFIL, IERRCT, UNERR,
1 TESTCT, IFLERR, PASSSW, ERRSW, MAXLIN,
2 CONID, MEMUN, WKID, WTYPE, GLBLUN, INDLUN,
3 DUMINT, DUMRL
INTEGER CTLHND, ERRSIG, ERRFIL, IERRCT, UNERR,
1 TESTCT, IFLERR, PASSSW, ERRSW, MAXLIN,
2 CONID, MEMUN, WKID, WTYPE, GLBLUN, INDLUN,
3 DUMINT(20), ERRIND
REAL DUMRL(20)
COMMON /GLOBCH/ PIDENT, GLBERR, TSTMSG, FUNCID,
1 DUMCH
CHARACTER PIDENT*40, GLBERR*60, TSTMSG*900, FUNCID*80,
1 DUMCH(20)*20
COMMON /DIALOG/ DOUTYP, DINTYP, DSTDNR, DSTRID, PSTRID, DTCLIM,
1 SCRMOD, DTXCI, SPECWT,
2 DSIZE, EFRAC, DYXRAT, SYXRAT, MTRPDC, WCPDC, QVIS
INTEGER DOUTYP, DINTYP, DSTDNR, DSTRID, PSTRID, DTCLIM,
1 SCRMOD, DTXCI, SPECWT
REAL DSIZE, EFRAC, DYXRAT, SYXRAT, MTRPDC, WCPDC, QVIS
COMMON /ERRINF/ ERRCOM,FUNCOM,FILCOM, ERNMSW, EXPSIZ,EXPERR,
1 USRERR, ERRSAV, FUNSAV, FILSAV,
2 EFCNT, EFID
INTEGER ERRCOM,FUNCOM,FILCOM, ERNMSW, EXPSIZ,EXPERR(10),
1 USRERR, ERRSAV(200), FUNSAV(200), FILSAV(200),
2 EFCNT, EFID(100)
COMMON /ERRCHR/ CURCON, ERRSRS, ERRMRK, ERFLNM,
1 CONTAB
CHARACTER CURCON*200, ERRSRS*40, ERRMRK*20, ERFLNM*80,
1 CONTAB(40)*150
COMMON /OPCOMM/ OPHEAD
CHARACTER OPHEAD*300
COMMON /RANCTL/ RLSEED
REAL RLSEED
INTEGER ITRIM, LUN, IOERR, IT, NWKSAV, IX
CHARACTER IDENT*(*), FILENM*60, INDERR*30
CHARACTER DUMREC*300, ANS*1, ERRPRF*30, IDCHAR*1
C check validity of IDENT
IT = ITRIM(IDENT)
IF (IT.LT.5) GOTO 60
DO 50 IX = 1, IT
IDCHAR = IDENT(IX:IX)
IF (IX .EQ. IT-2) THEN
IF (IDCHAR .NE. '/') GOTO 60
ELSEIF (MOD(IX,3) .EQ. 0) THEN
IF (IDCHAR .NE. '.') GOTO 60
ELSE
IF (IDCHAR.LT.'0' .OR. IDCHAR.GT.'9') GOTO 60
ENDIF
50 CONTINUE
GOTO 70
60 CONTINUE
PRINT *, 'Format of program-identifier is invalid: ', IDENT
STOP
70 CONTINUE
C *** *** *** *** Initialize common for operator comment
OPHEAD = 'NO TEST CASES YET:'
C *** *** *** *** Initialize global common
C initialize global common from input parameter
PIDENT = IDENT
TSTMSG = ' '
C set error and test counts to 0
UNERR = 0
IERRCT = 0
TESTCT = 0
C set handler-control to default (perhnd reports and aborts).
CTLHND = 0
C initialize global common from system configuration file
C filename and logical unit number for system configuration file.
C **********************************************************
C
CUSERMOD NOTE: The following must be initialized to the absolute file
CUSERMOD name for the system configuration file. This must be
CUSERMOD customized for each installation. See the MULTWS
CUSERMOD subroutine, immediately below, and also the INITPH
CUSERMOD program which writes the file.
C
C **********************************************************
FILENM = '/home/cugini/pvt/work/v2.1/INITPH.DAT'
C *********************************************************
C
CUSERMOD End of customization
C
C *********************************************************
C Use random unit number - no other files open yet, so should be OK.
LUN = 21
ERRPRF = 'INITGL abort. Error code for '
OPEN (UNIT=LUN, IOSTAT=IOERR, FILE=FILENM, STATUS='OLD',
1 FORM='UNFORMATTED')
IF (IOERR .NE. 0) THEN
PRINT *, ERRPRF, 'OPEN of configuration file = ', IOERR
STOP
ENDIF
C position at beginning of file
REWIND (UNIT=LUN, IOSTAT=IOERR)
IF (IOERR .NE. 0) THEN
PRINT *, ERRPRF, 'REWIND of configuration file = ', IOERR
STOP
ENDIF
READ (UNIT=LUN, IOSTAT=IOERR) ERNMSW, ERRMRK
IF (IOERR .NE. 0) THEN
PRINT *, ERRPRF, 'READ1 of configuration file = ', IOERR
STOP
ENDIF
READ (UNIT=LUN, IOSTAT=IOERR) DOUTYP, DTCLIM, DINTYP, DSTDNR,
1 DSIZE, EFRAC, SCRMOD, MTRPDC
IF (IOERR .NE. 0) THEN
PRINT *, ERRPRF, 'READ2 of configuration file = ', IOERR
STOP
ENDIF
READ (UNIT=LUN, IOSTAT=IOERR) ERRFIL, IFLERR, PASSSW, ERRSW,
1 MAXLIN, CONID, MEMUN, WKID, WTYPE, GLBERR, GLBLUN, INDLUN,
2 NWKSAV, RLSEED
IF (IOERR .NE. 0) THEN
PRINT *, ERRPRF, 'READ3 of configuration file = ', IOERR
STOP
ENDIF
CLOSE (UNIT=LUN, IOSTAT=IOERR)
IF (IOERR .NE. 0) THEN
PRINT *, ERRPRF, 'CLOSE of configuration file = ', IOERR
STOP
ENDIF
C *** *** *** Initialize error-handling common area *** *** ***
C set these to invalid values to make sure error handling routines
C initialize them:
ERRCOM = -1
FUNCOM = -1
FILCOM = -1
EXPSIZ = -1
DO 80 IT = 1,10
EXPERR(IT) = -1
80 CONTINUE
DO 90 IT = 1,200
ERRSAV(IT) = -1
FUNSAV(IT) = -1
FILSAV(IT) = -1
90 CONTINUE
ERRSRS = 'Un-initialized'
ERFLNM = 'Un-initialized'
CURCON = 'Un-initialized'
CONTAB(1) = 'Un-initialized'
C normal mode: NOT testing error handling.
USRERR = 0
C *** *** *** *** Initialize global common from operator, if necessary
IF (PASSSW .EQ. 2) THEN
CALL OPYN ('Generate run-time messages for successful ' //
1 'conditions?', ANS)
IF (ANS .EQ. 'y') THEN
PASSSW = 1
ELSE
PASSSW = 0
ENDIF
ENDIF
C *** *** *** *** Open message files, as needed.
IF (IFLERR .EQ. 1 .OR. IFLERR .EQ. 3) THEN
C open global file for append
OPEN (UNIT=GLBLUN, IOSTAT=IOERR, FILE=GLBERR, STATUS='OLD',
1 FORM='FORMATTED')
IF (IOERR .NE. 0) THEN
PRINT *, ERRPRF, 'OPEN of global file = ', IOERR
STOP
ENDIF
800 FORMAT (A)
C *********************************************************
C
CUSERMOD To make append work more efficiently, if desired, change the
CUSERMOD following to system-specific magic code which will open the
CUSERMOD global message file and position it after the last record,
CUSERMOD to allow new records to be added. The routine above seems
CUSERMOD to be the only Fortran-standard way to do it.
C
C *********************************************************
C position at end-of-file
100 CONTINUE
READ (UNIT=GLBLUN, FMT=800, IOSTAT=IOERR, END=200) DUMREC
IF (IOERR .NE. 0) THEN
PRINT *, ERRPRF, 'READ of global file = ', IOERR
STOP
ENDIF
GOTO 100
200 CONTINUE
BACKSPACE (UNIT=GLBLUN)
C *********************************************************
C
CUSERMOD End of customization
C
C *********************************************************
ENDIF
IT = ITRIM(PIDENT)
IF (IFLERR .EQ. 2 .OR. IFLERR .EQ. 3) THEN
C create individual message file
C generate file name
INDERR = 'p' // PIDENT(IT-1:IT) // '.msg'
OPEN (UNIT=INDLUN, IOSTAT=IOERR, FILE=INDERR, STATUS='UNKNOWN',
1 FORM='FORMATTED')
REWIND INDLUN
IF (IOERR .NE. 0) THEN
PRINT *, ERRPRF, 'OPEN of individual file = ', IOERR
STOP
ENDIF
ENDIF
C Broadcast beginning-of-program message
CALL BRDMSG ('SY: ------- Begin execution of PVT #' //
1 PIDENT(1:IT) // ', version 2.2')
C Following statement is never executed, but may help cause PERHND
C to be linked into executable module, as well as routines called
C directly by PVT version of PERHND.
IF (PIDENT .EQ. 'A bogus string value') THEN
CALL UNMSG ('This should never happen.')
CALL NCMSG ('This should never happen.')
CALL SIGMSG (0, 'bogus function name', DUMREC)
CALL ERFUNM (-1, FUNCID)
CALL PERHND (0, 0, 0)
ENDIF
666 CONTINUE
END
|
struct Propagator{T,D} <: AbstractParameterizedFunction{false}
U::Matrix{Complex{T}}
Δt::T
dims::Dims{D}
end
dimsmatch(U::Propagator,A::QuObject) = U.dims==dims(A) || throw(DimensionMismatch("subspace dimensions must match"))
function (U::Propagator)(ψ::Ket)
dimsmatch(U,ψ)
return Ket(U.U*data(ψ),dims(ψ))
end
function (U::Propagator)(ψ::Ket, n::Integer)
dimsmatch(U,ψ)
return Ket(U.U^n*data(ψ),dims(ψ))
end
function (U::Propagator)(ρ::Operator)
dimsmatch(U,ρ)
vecρ = vec(data(ρ))
d = prod(dims(ρ))
return Operator(reshape(U.U*vecρ,(d,d)),dims(ρ))
end
function (U::Propagator)(ρ::Operator, n::Integer)
dimsmatch(U,ρ)
vecρ = vec(data(ρ))
d = prod(dims(ρ))
return Operator(reshape(U.U^n*vecρ,(d,d)),dims(ρ))
end
# Convert a Propagator to an Operator
Operator(U::Propagator) = Operator(U.U,U.dims)
# Convert a Liouvillian to a Propagator
function SchrodingerProp(L::Liouvillian,tspan,alg=Vern8();kwargs...)
d = prod(dims(L))
prob = ODEProblem(L,Matrix{ComplexF64}(I,d,d),tspan)
sol = solve(prob,alg;save_start=false,saveat=tspan[end],abstol=1E-8,reltol=1E-6,kwargs...)
return Propagator(sol.u[end],float(tspan[2]-tspan[1]),dims(L))
end
function LindbladProp(L::Liouvillian,tspan,alg=Tsit5();kwargs...)
d = prod(dims(L))^2
prob = ODEProblem(L,Matrix{ComplexF64}(I,d,d),tspan)
sol = solve(prob,alg;save_start=false,saveat=tspan[end],abstol=1E-7,reltol=1E-5,kwargs...)
return Propagator(sol.u[end],float(tspan[2]-tspan[1]),dims(L))
end
|
/-
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] lemma coe_mk (s : set α) (h) : (mk s h : set α) = s := rfl
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
|
export map_to
"""
map_to(value::T) where T
Creates a map operator, which emits the given constant value on the output Observable every time the source Observable emits a value.
# Arguments
- `value::T`: the constant value to map each source value to
# Producing
Stream of type `<: Subscribable{T}`
# Examples
```jldoctest
using Rocket
source = from([ 1, 2, 3 ])
subscribe!(source |> map_to('a'), logger())
;
# output
[LogActor] Data: a
[LogActor] Data: a
[LogActor] Data: a
[LogActor] Completed
```
See also: [`map`](@ref), [`AbstractOperator`](@ref), [`RightTypedOperator`](@ref), [`ProxyObservable`](@ref), [`logger`](@ref)
"""
map_to(value::T) where T = map(T, _ -> value)
|
/-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
! This file was ported from Lean 3 source module topology.sheaves.sheaf_condition.equalizer_products
! leanprover-community/mathlib commit 85d6221d32c37e68f05b2e42cde6cee658dae5e9
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.CategoryTheory.Limits.Shapes.Equalizers
import Mathbin.CategoryTheory.Limits.Shapes.Products
import Mathbin.Topology.Sheaves.SheafCondition.PairwiseIntersections
/-!
# The sheaf condition in terms of an equalizer of products
Here we set up the machinery for the "usual" definition of the sheaf condition,
e.g. as in https://stacks.math.columbia.edu/tag/0072
in terms of an equalizer diagram where the two objects are
`∏ F.obj (U i)` and `∏ F.obj (U i) ⊓ (U j)`.
We show that this sheaf condition is equivalent to the `pairwise_intersections` sheaf condition when
the presheaf is valued in a category with products, and thereby equivalent to the default sheaf
condition.
-/
universe v' v u
noncomputable section
open CategoryTheory
open CategoryTheory.Limits
open TopologicalSpace
open Opposite
open TopologicalSpace.Opens
namespace TopCat
variable {C : Type u} [Category.{v} C] [HasProducts.{v'} C]
variable {X : TopCat.{v'}} (F : Presheaf C X) {ι : Type v'} (U : ι → Opens X)
namespace Presheaf
namespace SheafConditionEqualizerProducts
/-- The product of the sections of a presheaf over a family of open sets. -/
def piOpens : C :=
∏ fun i : ι => F.obj (op (U i))
#align Top.presheaf.sheaf_condition_equalizer_products.pi_opens TopCat.Presheaf.SheafConditionEqualizerProducts.piOpens
/-- The product of the sections of a presheaf over the pairwise intersections of
a family of open sets.
-/
def piInters : C :=
∏ fun p : ι × ι => F.obj (op (U p.1 ⊓ U p.2))
#align Top.presheaf.sheaf_condition_equalizer_products.pi_inters TopCat.Presheaf.SheafConditionEqualizerProducts.piInters
/-- The morphism `Π F.obj (U i) ⟶ Π F.obj (U i) ⊓ (U j)` whose components
are given by the restriction maps from `U i` to `U i ⊓ U j`.
-/
def leftRes : piOpens F U ⟶ piInters.{v'} F U :=
Pi.lift fun p : ι × ι => Pi.π _ p.1 ≫ F.map (inf_le_left (U p.1) (U p.2)).op
#align Top.presheaf.sheaf_condition_equalizer_products.left_res TopCat.Presheaf.SheafConditionEqualizerProducts.leftRes
/-- The morphism `Π F.obj (U i) ⟶ Π F.obj (U i) ⊓ (U j)` whose components
are given by the restriction maps from `U j` to `U i ⊓ U j`.
-/
def rightRes : piOpens F U ⟶ piInters.{v'} F U :=
Pi.lift fun p : ι × ι => Pi.π _ p.2 ≫ F.map (inf_le_right (U p.1) (U p.2)).op
#align Top.presheaf.sheaf_condition_equalizer_products.right_res TopCat.Presheaf.SheafConditionEqualizerProducts.rightRes
/-- The morphism `F.obj U ⟶ Π F.obj (U i)` whose components
are given by the restriction maps from `U j` to `U i ⊓ U j`.
-/
def res : F.obj (op (supᵢ U)) ⟶ piOpens.{v'} F U :=
Pi.lift fun i : ι => F.map (TopologicalSpace.Opens.leSupr U i).op
#align Top.presheaf.sheaf_condition_equalizer_products.res TopCat.Presheaf.SheafConditionEqualizerProducts.res
@[simp, elementwise]
theorem res_π (i : ι) : res F U ≫ limit.π _ ⟨i⟩ = F.map (Opens.leSupr U i).op := by
rw [res, limit.lift_π, fan.mk_π_app]
#align Top.presheaf.sheaf_condition_equalizer_products.res_π TopCat.Presheaf.SheafConditionEqualizerProducts.res_π
@[elementwise]
theorem w : res F U ≫ leftRes F U = res F U ≫ rightRes F U :=
by
dsimp [res, left_res, right_res]
ext
simp only [limit.lift_π, limit.lift_π_assoc, fan.mk_π_app, category.assoc]
rw [← F.map_comp]
rw [← F.map_comp]
congr
#align Top.presheaf.sheaf_condition_equalizer_products.w TopCat.Presheaf.SheafConditionEqualizerProducts.w
/-- The equalizer diagram for the sheaf condition.
-/
@[reducible]
def diagram : WalkingParallelPair ⥤ C :=
parallelPair (leftRes.{v'} F U) (rightRes F U)
#align Top.presheaf.sheaf_condition_equalizer_products.diagram TopCat.Presheaf.SheafConditionEqualizerProducts.diagram
/-- The restriction map `F.obj U ⟶ Π F.obj (U i)` gives a cone over the equalizer diagram
for the sheaf condition. The sheaf condition asserts this cone is a limit cone.
-/
def fork : Fork.{v} (leftRes F U) (rightRes F U) :=
Fork.ofι _ (w F U)
#align Top.presheaf.sheaf_condition_equalizer_products.fork TopCat.Presheaf.SheafConditionEqualizerProducts.fork
@[simp]
theorem fork_pt : (fork F U).pt = F.obj (op (supᵢ U)) :=
rfl
#align Top.presheaf.sheaf_condition_equalizer_products.fork_X TopCat.Presheaf.SheafConditionEqualizerProducts.fork_pt
@[simp]
theorem fork_ι : (fork F U).ι = res F U :=
rfl
#align Top.presheaf.sheaf_condition_equalizer_products.fork_ι TopCat.Presheaf.SheafConditionEqualizerProducts.fork_ι
@[simp]
theorem fork_π_app_walkingParallelPair_zero : (fork F U).π.app WalkingParallelPair.zero = res F U :=
rfl
#align Top.presheaf.sheaf_condition_equalizer_products.fork_π_app_walking_parallel_pair_zero TopCat.Presheaf.SheafConditionEqualizerProducts.fork_π_app_walkingParallelPair_zero
@[simp]
theorem fork_π_app_walkingParallelPair_one :
(fork F U).π.app WalkingParallelPair.one = res F U ≫ leftRes F U :=
rfl
#align Top.presheaf.sheaf_condition_equalizer_products.fork_π_app_walking_parallel_pair_one TopCat.Presheaf.SheafConditionEqualizerProducts.fork_π_app_walkingParallelPair_one
variable {F} {G : Presheaf C X}
/-- Isomorphic presheaves have isomorphic `pi_opens` for any cover `U`. -/
@[simp]
def piOpens.isoOfIso (α : F ≅ G) : piOpens F U ≅ piOpens.{v'} G U :=
Pi.mapIso fun X => α.app _
#align Top.presheaf.sheaf_condition_equalizer_products.pi_opens.iso_of_iso TopCat.Presheaf.SheafConditionEqualizerProducts.piOpens.isoOfIso
/-- Isomorphic presheaves have isomorphic `pi_inters` for any cover `U`. -/
@[simp]
def piInters.isoOfIso (α : F ≅ G) : piInters F U ≅ piInters.{v'} G U :=
Pi.mapIso fun X => α.app _
#align Top.presheaf.sheaf_condition_equalizer_products.pi_inters.iso_of_iso TopCat.Presheaf.SheafConditionEqualizerProducts.piInters.isoOfIso
/-- Isomorphic presheaves have isomorphic sheaf condition diagrams. -/
def diagram.isoOfIso (α : F ≅ G) : diagram F U ≅ diagram.{v'} G U :=
NatIso.ofComponents (by rintro ⟨⟩; exact pi_opens.iso_of_iso U α; exact pi_inters.iso_of_iso U α)
(by
rintro ⟨⟩ ⟨⟩ ⟨⟩
· simp
· ext
simp [left_res]
· ext
simp [right_res]
· simp)
#align Top.presheaf.sheaf_condition_equalizer_products.diagram.iso_of_iso TopCat.Presheaf.SheafConditionEqualizerProducts.diagram.isoOfIso
/-- If `F G : presheaf C X` are isomorphic presheaves,
then the `fork F U`, the canonical cone of the sheaf condition diagram for `F`,
is isomorphic to `fork F G` postcomposed with the corresponding isomorphism between
sheaf condition diagrams.
-/
def fork.isoOfIso (α : F ≅ G) :
fork F U ≅ (Cones.postcompose (diagram.isoOfIso U α).inv).obj (fork G U) :=
by
fapply fork.ext
· apply α.app
· ext
dsimp only [fork.ι]
-- Ugh, `simp` can't unfold abbreviations.
simp [res, diagram.iso_of_iso]
#align Top.presheaf.sheaf_condition_equalizer_products.fork.iso_of_iso TopCat.Presheaf.SheafConditionEqualizerProducts.fork.isoOfIso
end SheafConditionEqualizerProducts
/-- The sheaf condition for a `F : presheaf C X` requires that the morphism
`F.obj U ⟶ ∏ F.obj (U i)` (where `U` is some open set which is the union of the `U i`)
is the equalizer of the two morphisms
`∏ F.obj (U i) ⟶ ∏ F.obj (U i) ⊓ (U j)`.
-/
def IsSheafEqualizerProducts (F : Presheaf.{v', v, u} C X) : Prop :=
∀ ⦃ι : Type v'⦄ (U : ι → Opens X), Nonempty (IsLimit (SheafConditionEqualizerProducts.fork F U))
#align Top.presheaf.is_sheaf_equalizer_products TopCat.Presheaf.IsSheafEqualizerProducts
/-!
The remainder of this file shows that the equalizer_products sheaf condition is equivalent
to the pariwise_intersections sheaf condition.
-/
namespace SheafConditionPairwiseIntersections
open CategoryTheory.Pairwise CategoryTheory.Pairwise.Hom
/-- Implementation of `sheaf_condition_pairwise_intersections.cone_equiv`. -/
@[simps]
def coneEquivFunctorObj (c : Cone ((diagram U).op ⋙ F)) :
Cone (SheafConditionEqualizerProducts.diagram F U)
where
pt := c.pt
π :=
{ app := fun Z =>
WalkingParallelPair.casesOn Z (Pi.lift fun i : ι => c.π.app (op (single i)))
(Pi.lift fun b : ι × ι => c.π.app (op (pair b.1 b.2)))
naturality' := fun Y Z f => by
cases Y <;> cases Z <;> cases f
· ext i
dsimp
simp only [limit.lift_π, category.id_comp, fan.mk_π_app, CategoryTheory.Functor.map_id,
category.assoc]
dsimp
simp only [limit.lift_π, category.id_comp, fan.mk_π_app]
· ext ⟨i, j⟩
dsimp [sheaf_condition_equalizer_products.left_res]
simp only [limit.lift_π, limit.lift_π_assoc, category.id_comp, fan.mk_π_app,
category.assoc]
have h := c.π.naturality (Quiver.Hom.op (hom.left i j))
dsimp at h
simpa using h
· ext ⟨i, j⟩
dsimp [sheaf_condition_equalizer_products.right_res]
simp only [limit.lift_π, limit.lift_π_assoc, category.id_comp, fan.mk_π_app,
category.assoc]
have h := c.π.naturality (Quiver.Hom.op (hom.right i j))
dsimp at h
simpa using h
· ext i
dsimp
simp only [limit.lift_π, category.id_comp, fan.mk_π_app, CategoryTheory.Functor.map_id,
category.assoc]
dsimp
simp only [limit.lift_π, category.id_comp, fan.mk_π_app] }
#align Top.presheaf.sheaf_condition_pairwise_intersections.cone_equiv_functor_obj TopCat.Presheaf.SheafConditionPairwiseIntersections.coneEquivFunctorObj
section
attribute [local tidy] tactic.case_bash
/-- Implementation of `sheaf_condition_pairwise_intersections.cone_equiv`. -/
@[simps]
def coneEquivFunctor :
Limits.Cone ((diagram U).op ⋙ F) ⥤ Limits.Cone (SheafConditionEqualizerProducts.diagram F U)
where
obj c := coneEquivFunctorObj F U c
map c c' f :=
{ Hom := f.Hom
w' := fun j => by
cases j <;>
· ext
simp only [limits.fan.mk_π_app, limits.cone_morphism.w, limits.limit.lift_π,
category.assoc, cone_equiv_functor_obj_π_app] }
#align Top.presheaf.sheaf_condition_pairwise_intersections.cone_equiv_functor TopCat.Presheaf.SheafConditionPairwiseIntersections.coneEquivFunctor
end
/-- Implementation of `sheaf_condition_pairwise_intersections.cone_equiv`. -/
@[simps]
def coneEquivInverseObj (c : Limits.Cone (SheafConditionEqualizerProducts.diagram F U)) :
Limits.Cone ((diagram U).op ⋙ F) where
pt := c.pt
π :=
{ app := by
intro x
induction x using Opposite.rec
rcases x with (⟨i⟩ | ⟨i, j⟩)
· exact c.π.app walking_parallel_pair.zero ≫ pi.π _ i
· exact c.π.app walking_parallel_pair.one ≫ pi.π _ (i, j)
naturality' := by
intro x y f
induction x using Opposite.rec
induction y using Opposite.rec
have ef : f = f.unop.op := rfl
revert ef
generalize f.unop = f'
rintro rfl
rcases x with (⟨i⟩ | ⟨⟩) <;> rcases y with (⟨⟩ | ⟨j, j⟩) <;> rcases f' with ⟨⟩
· dsimp
erw [F.map_id]
simp
· dsimp
simp only [category.id_comp, category.assoc]
have h := c.π.naturality walking_parallel_pair_hom.left
dsimp [sheaf_condition_equalizer_products.left_res] at h
simp only [category.id_comp] at h
have h' := h =≫ pi.π _ (i, j)
rw [h']
simp only [category.assoc, limit.lift_π, fan.mk_π_app]
rfl
· dsimp
simp only [category.id_comp, category.assoc]
have h := c.π.naturality walking_parallel_pair_hom.right
dsimp [sheaf_condition_equalizer_products.right_res] at h
simp only [category.id_comp] at h
have h' := h =≫ pi.π _ (j, i)
rw [h']
simp
rfl
· dsimp
erw [F.map_id]
simp }
#align Top.presheaf.sheaf_condition_pairwise_intersections.cone_equiv_inverse_obj TopCat.Presheaf.SheafConditionPairwiseIntersections.coneEquivInverseObj
/-- Implementation of `sheaf_condition_pairwise_intersections.cone_equiv`. -/
@[simps]
def coneEquivInverse :
Limits.Cone (SheafConditionEqualizerProducts.diagram F U) ⥤ Limits.Cone ((diagram U).op ⋙ F)
where
obj c := coneEquivInverseObj F U c
map c c' f :=
{ Hom := f.Hom
w' := by
intro x
induction x using Opposite.rec
rcases x with (⟨i⟩ | ⟨i, j⟩)
· dsimp
dsimp only [fork.ι]
rw [← f.w walking_parallel_pair.zero, category.assoc]
· dsimp
rw [← f.w walking_parallel_pair.one, category.assoc] }
#align Top.presheaf.sheaf_condition_pairwise_intersections.cone_equiv_inverse TopCat.Presheaf.SheafConditionPairwiseIntersections.coneEquivInverse
/-- Implementation of `sheaf_condition_pairwise_intersections.cone_equiv`. -/
@[simps]
def coneEquivUnitIsoApp (c : Cone ((diagram U).op ⋙ F)) :
(𝟭 (Cone ((diagram U).op ⋙ F))).obj c ≅ (coneEquivFunctor F U ⋙ coneEquivInverse F U).obj c
where
Hom :=
{ Hom := 𝟙 _
w' := fun j => by induction j using Opposite.rec;
rcases j with ⟨⟩ <;>
· dsimp
simp only [limits.fan.mk_π_app, category.id_comp, limits.limit.lift_π] }
inv :=
{ Hom := 𝟙 _
w' := fun j => by induction j using Opposite.rec;
rcases j with ⟨⟩ <;>
· dsimp
simp only [limits.fan.mk_π_app, category.id_comp, limits.limit.lift_π] }
hom_inv_id' := by
ext
simp only [category.comp_id, limits.cone.category_comp_hom, limits.cone.category_id_hom]
inv_hom_id' := by
ext
simp only [category.comp_id, limits.cone.category_comp_hom, limits.cone.category_id_hom]
#align Top.presheaf.sheaf_condition_pairwise_intersections.cone_equiv_unit_iso_app TopCat.Presheaf.SheafConditionPairwiseIntersections.coneEquivUnitIsoApp
/-- Implementation of `sheaf_condition_pairwise_intersections.cone_equiv`. -/
@[simps]
def coneEquivUnitIso :
𝟭 (Limits.Cone ((diagram U).op ⋙ F)) ≅ coneEquivFunctor F U ⋙ coneEquivInverse F U :=
NatIso.ofComponents (coneEquivUnitIsoApp F U) (by tidy)
#align Top.presheaf.sheaf_condition_pairwise_intersections.cone_equiv_unit_iso TopCat.Presheaf.SheafConditionPairwiseIntersections.coneEquivUnitIso
/-- Implementation of `sheaf_condition_pairwise_intersections.cone_equiv`. -/
@[simps]
def coneEquivCounitIso :
coneEquivInverse F U ⋙ coneEquivFunctor F U ≅
𝟭 (Limits.Cone (SheafConditionEqualizerProducts.diagram F U)) :=
NatIso.ofComponents
(fun c =>
{ Hom :=
{ Hom := 𝟙 _
w' := by
rintro ⟨_ | _⟩
· ext ⟨j⟩
dsimp
simp only [category.id_comp, limits.fan.mk_π_app, limits.limit.lift_π]
· ext ⟨i, j⟩
dsimp
simp only [category.id_comp, limits.fan.mk_π_app, limits.limit.lift_π] }
inv :=
{ Hom := 𝟙 _
w' := by
rintro ⟨_ | _⟩
· ext ⟨j⟩
dsimp
simp only [category.id_comp, limits.fan.mk_π_app, limits.limit.lift_π]
· ext ⟨i, j⟩
dsimp
simp only [category.id_comp, limits.fan.mk_π_app, limits.limit.lift_π] }
hom_inv_id' := by
ext
dsimp
simp only [category.comp_id]
inv_hom_id' := by
ext
dsimp
simp only [category.comp_id] })
fun c d f => by
ext
dsimp
simp only [category.comp_id, category.id_comp]
#align Top.presheaf.sheaf_condition_pairwise_intersections.cone_equiv_counit_iso TopCat.Presheaf.SheafConditionPairwiseIntersections.coneEquivCounitIso
/--
Cones over `diagram U ⋙ F` are the same as a cones over the usual sheaf condition equalizer diagram.
-/
@[simps]
def coneEquiv :
Limits.Cone ((diagram U).op ⋙ F) ≌ Limits.Cone (SheafConditionEqualizerProducts.diagram F U)
where
Functor := coneEquivFunctor F U
inverse := coneEquivInverse F U
unitIso := coneEquivUnitIso F U
counitIso := coneEquivCounitIso F U
#align Top.presheaf.sheaf_condition_pairwise_intersections.cone_equiv TopCat.Presheaf.SheafConditionPairwiseIntersections.coneEquiv
attribute [local reducible]
sheaf_condition_equalizer_products.res sheaf_condition_equalizer_products.left_res
/-- If `sheaf_condition_equalizer_products.fork` is an equalizer,
then `F.map_cone (cone U)` is a limit cone.
-/
def isLimitMapConeOfIsLimitSheafConditionFork
(P : IsLimit (SheafConditionEqualizerProducts.fork F U)) : IsLimit (F.mapCone (cocone U).op) :=
IsLimit.ofIsoLimit ((IsLimit.ofConeEquiv (coneEquiv F U).symm).symm P)
{ Hom :=
{ Hom := 𝟙 _
w' := by
intro x
induction x using Opposite.rec
rcases x with ⟨⟩
· dsimp
simp
rfl
· dsimp
simp only [limit.lift_π, limit.lift_π_assoc, category.id_comp, fan.mk_π_app,
category.assoc]
rw [← F.map_comp]
rfl }
inv :=
{ Hom := 𝟙 _
w' := by
intro x
induction x using Opposite.rec
rcases x with ⟨⟩
· dsimp
simp
rfl
· dsimp
simp only [limit.lift_π, limit.lift_π_assoc, category.id_comp, fan.mk_π_app,
category.assoc]
rw [← F.map_comp]
rfl }
hom_inv_id' := by
ext
dsimp
simp only [category.comp_id]
inv_hom_id' := by
ext
dsimp
simp only [category.comp_id] }
#align Top.presheaf.sheaf_condition_pairwise_intersections.is_limit_map_cone_of_is_limit_sheaf_condition_fork TopCat.Presheaf.SheafConditionPairwiseIntersections.isLimitMapConeOfIsLimitSheafConditionFork
/-- If `F.map_cone (cone U)` is a limit cone,
then `sheaf_condition_equalizer_products.fork` is an equalizer.
-/
def isLimitSheafConditionForkOfIsLimitMapCone (Q : IsLimit (F.mapCone (cocone U).op)) :
IsLimit (SheafConditionEqualizerProducts.fork F U) :=
IsLimit.ofIsoLimit ((IsLimit.ofConeEquiv (coneEquiv F U)).symm Q)
{ Hom :=
{ Hom := 𝟙 _
w' := by
rintro ⟨⟩
· dsimp
simp
rfl
· dsimp
ext ⟨i, j⟩
simp only [limit.lift_π, limit.lift_π_assoc, category.id_comp, fan.mk_π_app,
category.assoc]
rw [← F.map_comp]
rfl }
inv :=
{ Hom := 𝟙 _
w' := by
rintro ⟨⟩
· dsimp
simp
rfl
· dsimp
ext ⟨i, j⟩
simp only [limit.lift_π, limit.lift_π_assoc, category.id_comp, fan.mk_π_app,
category.assoc]
rw [← F.map_comp]
rfl }
hom_inv_id' := by
ext
dsimp
simp only [category.comp_id]
inv_hom_id' := by
ext
dsimp
simp only [category.comp_id] }
#align Top.presheaf.sheaf_condition_pairwise_intersections.is_limit_sheaf_condition_fork_of_is_limit_map_cone TopCat.Presheaf.SheafConditionPairwiseIntersections.isLimitSheafConditionForkOfIsLimitMapCone
end SheafConditionPairwiseIntersections
open SheafConditionPairwiseIntersections
/-- The sheaf condition in terms of an equalizer diagram is equivalent
to the default sheaf condition.
-/
theorem isSheaf_iff_isSheafEqualizerProducts (F : Presheaf C X) :
F.IsSheaf ↔ F.IsSheafEqualizerProducts :=
(isSheaf_iff_isSheafPairwiseIntersections F).trans <|
Iff.intro (fun h ι U => ⟨isLimitSheafConditionForkOfIsLimitMapCone F U (h U).some⟩) fun h ι U =>
⟨isLimitMapConeOfIsLimitSheafConditionFork F U (h U).some⟩
#align Top.presheaf.is_sheaf_iff_is_sheaf_equalizer_products TopCat.Presheaf.isSheaf_iff_isSheafEqualizerProducts
end Presheaf
end TopCat
|
(* Title: HOL/Auth/n_german_lemma_inv__49_on_rules.thy
Author: Yongjian Li and Kaiqiang Duan, State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences
Copyright 2016 State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences
*)
header{*The n_german Protocol Case Study*}
theory n_german_lemma_inv__49_on_rules imports n_german_lemma_on_inv__49
begin
section{*All lemmas on causal relation between inv__49*}
lemma lemma_inv__49_on_rules:
assumes b1: "r \<in> rules N" and b2: "(\<exists> p__Inv3 p__Inv4. p__Inv3\<le>N\<and>p__Inv4\<le>N\<and>p__Inv3~=p__Inv4\<and>f=inv__49 p__Inv3 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
proof -
have c1: "(\<exists> j. j\<le>N\<and>r=n_SendReqS j)\<or>
(\<exists> i. i\<le>N\<and>r=n_SendReqEI i)\<or>
(\<exists> i. i\<le>N\<and>r=n_SendReqES i)\<or>
(\<exists> i. i\<le>N\<and>r=n_RecvReq N i)\<or>
(\<exists> i. i\<le>N\<and>r=n_SendInvE i)\<or>
(\<exists> i. i\<le>N\<and>r=n_SendInvS i)\<or>
(\<exists> i. i\<le>N\<and>r=n_SendInvAck i)\<or>
(\<exists> i. i\<le>N\<and>r=n_RecvInvAck i)\<or>
(\<exists> i. i\<le>N\<and>r=n_SendGntS i)\<or>
(\<exists> i. i\<le>N\<and>r=n_SendGntE N i)\<or>
(\<exists> i. i\<le>N\<and>r=n_RecvGntS i)\<or>
(\<exists> i. i\<le>N\<and>r=n_RecvGntE i)\<or>
(\<exists> i d. i\<le>N\<and>d\<le>N\<and>r=n_Store i d)"
apply (cut_tac b1, auto) done
moreover {
assume d1: "(\<exists> j. j\<le>N\<and>r=n_SendReqS j)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendReqSVsinv__49) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendReqEI i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendReqEIVsinv__49) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendReqES i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendReqESVsinv__49) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_RecvReq N i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_RecvReqVsinv__49) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendInvE i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendInvEVsinv__49) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendInvS i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendInvSVsinv__49) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendInvAck i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendInvAckVsinv__49) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_RecvInvAck i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_RecvInvAckVsinv__49) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendGntS i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendGntSVsinv__49) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendGntE N i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_SendGntEVsinv__49) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_RecvGntS i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_RecvGntSVsinv__49) done
}
moreover {
assume d1: "(\<exists> i. i\<le>N\<and>r=n_RecvGntE i)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_RecvGntEVsinv__49) done
}
moreover {
assume d1: "(\<exists> i d. i\<le>N\<and>d\<le>N\<and>r=n_Store i d)"
have "invHoldForRule s f r (invariants N)"
apply (cut_tac b2 d1, metis n_StoreVsinv__49) done
}
ultimately show "invHoldForRule s f r (invariants N)"
by satx
qed
end
|
// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
// Use of this source code is governed by a apache 2.0 license that can be
// found in the LICENSE file.
#include "common/step/backup/step_backup_manifest.h"
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/system/error_code.hpp>
#include <pkgmgr-info.h>
#include <pkgmgr_installer.h>
#include <algorithm>
#include <string>
#include "common/paths.h"
#include "common/utils/file_util.h"
namespace bf = boost::filesystem;
namespace bs = boost::system;
namespace common_installer {
namespace backup {
Step::Status StepBackupManifest::precheck() {
if (!bf::exists(context_->xml_path.get())) {
LOG(ERROR) << "Xml manifest file does not exist";
return Status::MANIFEST_NOT_FOUND;
}
return Status::OK;
}
Step::Status StepBackupManifest::process() {
// set backup file path
bf::path backup_xml_path =
GetBackupPathForManifestFile(context_->xml_path.get());
context_->backup_xml_path.set(backup_xml_path);
bs::error_code error;
bf::copy(context_->xml_path.get(), context_->backup_xml_path.get(), error);
if (error) {
LOG(ERROR) << "Failed to make a copy of xml manifest file";
return Status::MANIFEST_ERROR;
}
LOG(DEBUG) << "Manifest backup created";
return Status::OK;
}
Step::Status StepBackupManifest::clean() {
bs::error_code error;
bf::remove(context_->backup_xml_path.get(), error);
if (error) {
LOG(WARNING) << "Cannot remove backup manifest file";
return Status::MANIFEST_ERROR;
}
LOG(DEBUG) << "Manifest backup removed";
return Status::OK;
}
Step::Status StepBackupManifest::undo() {
if (bf::exists(context_->backup_xml_path.get())) {
bs::error_code error;
bf::remove(context_->xml_path.get(), error);
if (error) {
LOG(ERROR) << "Failed to remove newly generated xml file in revert";
return Status::MANIFEST_ERROR;
}
if (!MoveFile(context_->backup_xml_path.get(),
context_->xml_path.get())) {
LOG(ERROR) << "Failed to revert a content of xml manifest file";
return Status::MANIFEST_ERROR;
}
LOG(DEBUG) << "Manifest reverted from backup";
}
return Status::OK;
}
} // namespace backup
} // namespace common_installer
|
module Utils
import Data.Vect
import RFC.Utils
%access public
-- ----------------------------------------------------------------- [ DayTime ]
||| Embarrassingly bad function to do conversion between unix time and
||| date time
private
convert : Int -> DayTime
convert i = MkDaytime
(getYears + 1970)
getMonths
getDays
getHours
getMins
getSecs
where
getYears : Int
getYears = div i 31556926
epoM : Int
epoM = mod i 31556926
getMonths : Int
getMonths = div epoM 2629743
epoD : Int
epoD = mod epoM 2629743
getDays : Int
getDays = div epoD 86400
epoH : Int
epoH = mod epoD 86400
getHours : Int
getHours = div epoH 3600
epoMin : Int
epoMin = mod epoH 3600
getMins : Int
getMins = div epoMin 60
epoSec : Int
epoSec = mod epoMin 60
getSecs : Int
getSecs = epoSec
||| Return the daytime if possible.
%assert_total
getDayTime : Either String DayTime
getDayTime = let t = systime in
if (t /= 0)
then Right (convert t)
else Left "No time"
where
systime : Int
systime = unsafePerformIO time
-- --------------------------------------------------------------------- [ EOF ]
|
library(ggplot2)
library(plyr)
S <- 0.005
H <- 5
E <- 100
hic <- read.delim("hic.csv")
oeg <- read.delim("oeg.csv")
rna <- read.delim("rna.csv")
rna$padj[is.na(rna$padj)] <- 1
print(nrow(rna))
print(nrow(rna[rna$padj < S,]))
print(nrow(rna[rna$padj < S & rna$log2FoldChange > 0,]))
print(nrow(rna[rna$padj < S & rna$log2FoldChange < 0,]))
print(table(rna[rna$padj < S, 'biotype']))
a <- (rna$activated.1 + rna$activated.2) / 2 >= E
b <- (rna$nonactivated.1 + rna$nonactivated.2) / 2 >= E
print(sum(a)) # expressed act
print(sum(b)) # expressed nonact
print(sum(a | b)) # expressed union
print(nrow(hic))
c <- hic$activated >= H & hic$nonactivated < H
d <- hic$activated < H & hic$nonactivated >= H
print(nrow(hic[c | d,])) # diff contact
print(nrow(hic[c,])) # upreg
print(nrow(hic[d,])) # downreg
e <- hic$activated >= H
f <- hic$nonactivated >= H
print(sum(e))
print(sum(f))
print(sum(e | f))
png("1.png")
ggplot(hic, aes(log2(nonactivated + 0.1), log2(activated + 0.1))) + geom_point() + geom_rug(alpha=0.1)
dev.off()
all <- merge(merge(hic, oeg), rna)
sig <- all[all$padj < S,]
sgu <- unique(sig[,colnames(hic)])
png("2.png")
ggplot(sgu, aes(log2(nonactivated + 0.1), log2(activated + 0.1))) + geom_point() + geom_rug(alpha=0.1)
dev.off()
act <- ddply(hic[hic$activated >= H,], 'oeID', function(x) data.frame(nactivated=nrow(x)))
nct <- ddply(hic[hic$nonactivated >= H,], 'oeID', function(x) data.frame(nnonactivated=nrow(x)))
nin <- merge(act, nct, all=T)
nin$nactivated[is.na(nin$nactivated)] <- 0
nin$nnonactivated[is.na(nin$nnonactivated)] <- 0
png("3.png")
ggplot(nin, aes(nnonactivated, nactivated)) + geom_point() + geom_jitter() + geom_rug(alpha=0.1)
dev.off()
nnn <- merge(merge(nin, oeg), rna)
snn <- nnn[nnn$padj < S,]
unn <- unique(snn[,colnames(nin)])
png("4.png")
ggplot(unn, aes(nnonactivated, nactivated)) + geom_point() + geom_jitter() + geom_rug(alpha=0.1)
dev.off()
|
{-# OPTIONS --safe #-}
module Cubical.Categories.Instances.Sets where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Unit
open import Cubical.Data.Sigma using (ΣPathP)
open import Cubical.Categories.Category
open import Cubical.Categories.Functor
open import Cubical.Categories.NaturalTransformation
open import Cubical.Categories.Limits
open Category
module _ ℓ where
SET : Category (ℓ-suc ℓ) ℓ
ob SET = hSet ℓ
Hom[_,_] SET (A , _) (B , _) = A → B
id SET x = x
_⋆_ SET f g x = g (f x)
⋆IdL SET f = refl
⋆IdR SET f = refl
⋆Assoc SET f g h = refl
isSetHom SET {A} {B} = isSetΠ (λ _ → snd B)
private
variable
ℓ ℓ' : Level
open Functor
-- Hom functors
_[-,_] : (C : Category ℓ ℓ') → (c : C .ob) → Functor (C ^op) (SET ℓ')
(C [-, c ]) .F-ob x = (C [ x , c ]) , C .isSetHom
(C [-, c ]) .F-hom f k = f ⋆⟨ C ⟩ k
(C [-, c ]) .F-id = funExt λ _ → C .⋆IdL _
(C [-, c ]) .F-seq _ _ = funExt λ _ → C .⋆Assoc _ _ _
_[_,-] : (C : Category ℓ ℓ') → (c : C .ob)→ Functor C (SET ℓ')
(C [ c ,-]) .F-ob x = (C [ c , x ]) , C .isSetHom
(C [ c ,-]) .F-hom f k = k ⋆⟨ C ⟩ f
(C [ c ,-]) .F-id = funExt λ _ → C .⋆IdR _
(C [ c ,-]) .F-seq _ _ = funExt λ _ → sym (C .⋆Assoc _ _ _)
module _ {C : Category ℓ ℓ'} {F : Functor C (SET ℓ')} where
open NatTrans
-- natural transformations by pre/post composition
preComp : {x y : C .ob}
→ (f : C [ x , y ])
→ C [ x ,-] ⇒ F
→ C [ y ,-] ⇒ F
preComp f α .N-ob c k = (α ⟦ c ⟧) (f ⋆⟨ C ⟩ k)
preComp f α .N-hom {x = c} {d} k
= (λ l → (α ⟦ d ⟧) (f ⋆⟨ C ⟩ (l ⋆⟨ C ⟩ k)))
≡[ i ]⟨ (λ l → (α ⟦ d ⟧) (⋆Assoc C f l k (~ i))) ⟩
(λ l → (α ⟦ d ⟧) (f ⋆⟨ C ⟩ l ⋆⟨ C ⟩ k))
≡[ i ]⟨ (λ l → (α .N-hom k) i (f ⋆⟨ C ⟩ l)) ⟩
(λ l → (F ⟪ k ⟫) ((α ⟦ c ⟧) (f ⋆⟨ C ⟩ l)))
∎
-- properties
-- TODO: move to own file
open CatIso renaming (inv to cInv)
open Iso
Iso→CatIso : ∀ {A B : (SET ℓ) .ob}
→ Iso (fst A) (fst B)
→ CatIso (SET ℓ) A B
Iso→CatIso is .mor = is .fun
Iso→CatIso is .cInv = is .inv
Iso→CatIso is .sec = funExt λ b → is .rightInv b -- is .rightInv
Iso→CatIso is .ret = funExt λ b → is .leftInv b -- is .rightInv
-- SET is complete
-- notes:
-- didn't need to restrict to *finite* diagrams , why is that required in Set theoretic?
-- didn't use coinduction here because Agda didn't like me referencing 'cone' frome 'up' (termination check)
open NatTrans
isCompleteSET : ∀ {ℓJ ℓJ'} → complete' {ℓJ = ℓJ} {ℓJ'} (SET (ℓ-max ℓJ ℓJ'))
isCompleteSET J K = record
{ head = head'
; islim = record { cone = cone' ; up = up' } }
where
-- the limit is defined as the Set of all cones with head Unit
head' = Cone K (Unit* , isOfHLevelLift 2 isSetUnit) , isSetNatTrans
-- the legs are defined by taking a cone to its component at j
cone' : Cone K head'
cone' .N-ob j μ = (μ ⟦ j ⟧) tt*
-- Naturality follows from naturality of the Unit cone
cone' .N-hom {x = i} {j} f
= funExt λ μ → (μ ⟦ j ⟧) tt*
≡[ i ]⟨ (μ .N-hom f i) tt* ⟩
(K ⟪ f ⟫) ((μ ⟦ i ⟧) tt*)
∎
-- Given another cone α, we want a unique function f from α → cone' which factors it
-- factorization property enforces that (cone' ⟦ j ⟧ ● f) ≡ α ⟦ j ⟧
-- but cone' ⟦ j ⟧ simply takes the jth component the output Cone K Unit from f
-- so this enforces that for all x ∈ A, (f x) ⟦ j ⟧ ≡ α ⟦ j ⟧ x
-- this determines the *only* possible factoring morphism
up' : ∀ {A} (α : Cone K A) → cone' uniquelyFactors α
up' {A} α = (f , fact) , unique
where
f : fst A → Cone K (Unit* , isOfHLevelLift 2 isSetUnit)
f x = natTrans (λ j _ → α .N-ob j x)
(λ {m} {n} f → funExt λ μ i → α .N-hom f i x)
fact : α ≡ (f ◼ cone')
fact = makeNatTransPath refl -- I LOVE DEFINITIONAL EQUALITY
unique : (τ : cone' factors α) → (f , fact) ≡ τ
unique (f' , fact') = ΣPathP (f≡f' , fact≡fact')
where
f≡f' : f ≡ f'
f≡f' = funExt λ x → makeNatTransPath (funExt λ _ → sym eq2)
where
-- the factorization property enforces that f' must have the same behavior as f
eq1 : ∀ {x j} → ((cone' ⟦ j ⟧) (f' x)) ≡ (α ⟦ j ⟧) x
eq1 {x} {j} i = ((fact' (~ i)) ⟦ j ⟧) x
eq2 : ∀ {x j} → (f' x) ⟦ j ⟧ ≡ λ _ → (α ⟦ j ⟧) x -- = (f x) ⟦ j ⟧
eq2 {x} {j} = funExt λ _ → eq1
-- follows from Set having homsets
fact≡fact' : PathP (λ i → α ≡ ((f≡f' i) ◼ cone')) fact fact'
fact≡fact' = isOfHLevel→isOfHLevelDep 1 (λ β → isSetNatTrans α β) fact fact' λ i → (f≡f' i) ◼ cone'
|
Require Export LimitFunctorTheorems SpecializedLaxCommaCategory.
Require Import Common DefinitionSimplification SpecializedCategory Functor NaturalTransformation Duals CanonicalStructureSimplification.
Set Implicit Arguments.
Generalizable All Variables.
Set Asymmetric Patterns.
Set Universe Polymorphism.
Section InducedFunctor.
(* The components of the functor can be useful even if we don't have
a category that we're coming from. So prove them separately, so
we can use them elsewhere, without assuming a full [HasLimits]. *)
Variable I : Type.
Context `(Index2Cat : forall i : I, @SpecializedCategory (@Index2Object i)).
Local Coercion Index2Cat : I >-> SpecializedCategory.
Local Notation "'CAT' ⇑ D" := (@LaxCosliceSpecializedCategory _ _ Index2Cat _ D).
Local Notation "'CAT' ⇓ D" := (@LaxSliceSpecializedCategory _ _ Index2Cat _ D).
Context `(D : @SpecializedCategory objD).
Let DOp := OppositeCategory D.
Section Limit.
Definition InducedLimitFunctor_MorphismOf (s d : CAT ⇑ D) (limS : Limit (projT2 s)) (limD : Limit (projT2 d))
(m : Morphism (CAT ⇑ D) s d) :
Morphism D (LimitObject limS) (LimitObject limD)
:= InducedLimitMap (projT2 m) _ _.
Lemma InducedLimitFunctor_FCompositionOf (s d d' : CAT ⇑ D) (limS : Limit (projT2 s)) (limD : Limit (projT2 d)) (limD' : Limit (projT2 d'))
(m1 : Morphism _ s d) (m2 : Morphism _ d d') :
InducedLimitFunctor_MorphismOf limS limD' (Compose m2 m1) =
Compose (InducedLimitFunctor_MorphismOf limD limD' m2) (InducedLimitFunctor_MorphismOf limS limD m1).
Proof.
unfold InducedLimitFunctor_MorphismOf.
unfold InducedLimitMap at 1; cbv zeta.
match goal with
| [ |- TerminalProperty_Morphism ?a ?b ?c = _ ] => apply (proj2 (TerminalProperty a b c))
end (* 3 s *).
nt_eq (* 4 s *).
rsimplify_morphisms (* 11 s *).
repeat rewrite Associativity (* 3 s *).
match goal with
| [ |- Compose ?a (Compose ?b ?c) = Compose ?a' (Compose ?b' ?c') ] =>
eapply (@eq_trans _ _ (Compose a' (Compose _ c)) _);
try_associativity ltac:(apply f_equal2; try reflexivity)
end (* 13 s *);
unfold InducedLimitMap;
match goal with
| [ |- appcontext[TerminalProperty_Morphism ?a ?b ?c] ] =>
let H := constr:(TerminalProperty a) in
let H' := fresh in
pose proof (fun x Y f => f_equal (fun T => T.(ComponentsOf) x) (proj1 (H Y f))) as H';
simpl in H';
unfold Object, Morphism in *;
simpl in *;
rewrite H';
clear H'
end (* 7 s *);
simpl;
rsimplify_morphisms;
reflexivity (* 6 s since [simpl] *).
Qed.
Lemma InducedLimitFunctor_FIdentityOf (x : CAT ⇑ D) (limX : Limit (projT2 x)) :
InducedLimitFunctor_MorphismOf limX limX (Identity x) =
Identity (LimitObject limX).
Proof.
unfold InducedLimitFunctor_MorphismOf.
unfold InducedLimitMap at 1; cbv zeta.
match goal with
| [ |- TerminalProperty_Morphism ?a ?b ?c = _ ] => apply (proj2 (TerminalProperty a b c))
end (* 3 s *).
nt_eq (* 4 s *).
rsimplify_morphisms;
reflexivity. (* 2 s *)
Qed.
Variable HasLimits : forall C : CAT ⇑ D, Limit (projT2 C).
Hint Resolve InducedLimitFunctor_FCompositionOf InducedLimitFunctor_FIdentityOf.
Definition InducedLimitFunctor : SpecializedFunctor (CAT ⇑ D) D.
match goal with
| [ |- SpecializedFunctor ?C ?D ] =>
refine (Build_SpecializedFunctor C D
(fun x => LimitObject (HasLimits x))
(fun s d => @InducedLimitFunctor_MorphismOf s d (HasLimits s) (HasLimits d))
_
_
)
end;
abstract trivial.
Defined.
End Limit.
Section Colimit.
Definition InducedColimitFunctor_MorphismOf (s d : CAT ⇓ D) (colimS : Colimit (projT2 s)) (colimD : Colimit (projT2 d))
(m : Morphism (CAT ⇓ D) s d) :
Morphism D (ColimitObject colimS) (ColimitObject colimD)
:= InducedColimitMap (projT2 m) _ _.
Lemma InducedColimitFunctor_FCompositionOf (s d d' : CAT ⇓ D) (colimS : Colimit (projT2 s)) (colimD : Colimit (projT2 d)) (colimD' : Colimit (projT2 d'))
(m1 : Morphism _ s d) (m2 : Morphism _ d d') :
InducedColimitFunctor_MorphismOf colimS colimD' (Compose m2 m1) =
Compose (InducedColimitFunctor_MorphismOf colimD colimD' m2) (InducedColimitFunctor_MorphismOf colimS colimD m1).
Proof.
unfold InducedColimitFunctor_MorphismOf.
unfold InducedColimitMap at 1; cbv zeta.
match goal with
| [ |- InitialProperty_Morphism ?a ?b ?c = _ ] => apply (proj2 (InitialProperty a b c))
end (* 3 s *).
nt_eq (* 4 s *).
rsimplify_morphisms (* 8 s *).
repeat rewrite Associativity (* 3 s *).
match goal with
| [ |- Compose ?a (Compose ?b ?c) = Compose ?a' (Compose ?b' ?c') ] =>
symmetry; eapply (@eq_trans _ _ (Compose a (Compose _ c')) _);
try_associativity ltac:(apply f_equal2; try reflexivity)
end (* 13 s *);
unfold InducedColimitMap;
match goal with
| [ |- appcontext[InitialProperty_Morphism ?a ?b ?c] ] =>
let H := constr:(InitialProperty a) in
let H' := fresh in
pose proof (fun x Y f => f_equal (fun T => T.(ComponentsOf) x) (proj1 (H Y f))) as H';
simpl in H';
unfold Object in *;
simpl in *;
try (rewrite H'; clear H')
end (* 7 s *);
simpl;
rsimplify_morphisms;
reflexivity (* 4 s since [simpl] *).
Qed.
Lemma InducedColimitFunctor_FIdentityOf (x : CAT ⇓ D) (colimX : Colimit (projT2 x)) :
InducedColimitFunctor_MorphismOf colimX colimX (Identity x) =
Identity (ColimitObject colimX).
Proof.
unfold InducedColimitFunctor_MorphismOf.
unfold InducedColimitMap at 1; cbv zeta.
match goal with
| [ |- InitialProperty_Morphism ?a ?b ?c = _ ] => apply (proj2 (InitialProperty a b c))
end (* 3 s *).
nt_eq (* 4 s *).
rsimplify_morphisms. (* 1.5 s *)
reflexivity.
Qed.
Variable HasColimits : forall C : CAT ⇓ D, Colimit (projT2 C).
Hint Resolve InducedColimitFunctor_FCompositionOf InducedColimitFunctor_FIdentityOf.
Definition InducedColimitFunctor : SpecializedFunctor (CAT ⇓ D) D.
match goal with
| [ |- SpecializedFunctor ?C ?D ] =>
refine (Build_SpecializedFunctor C D
(fun x => ColimitObject (HasColimits x))
(fun s d => @InducedColimitFunctor_MorphismOf s d (HasColimits s) (HasColimits d))
_
_
)
end;
abstract trivial.
Defined.
End Colimit.
End InducedFunctor.
|
module Bimonad
import Bifunctor
import Biapplicative
infixl 4 >>==
||| Bimonads
||| @p the action of the first Bifunctor component on pairs of objects
||| @q the action of the second Bifunctor component on pairs of objects
interface (Biapplicative p, Biapplicative q) =>
Bimonad (p : Type -> Type -> Type) (q : Type -> Type -> Type) where
bijoin : (p (p a b) (q a b), q (p a b) (q a b)) -> (p a b, q a b)
bijoin p = p >>== (id, id)
(>>==) : (p a b, q a b) -> ((a -> p c d), (b -> q c d)) -> (p c d, q c d)
(pab, qab) >>== (f, g) = bijoin $ (bimap f g, bimap f g) <<*>> (pab, qab)
biunit : (Bimonad p q) => a -> b -> (p a b, q a b)
biunit a b = (bipure a b, bipure a b)
implementation Bimonad Pair Pair where
bijoin = bimap fst snd
|
Think ice cream cone shape. This is another form of rolled cannabis, and the go-to shape of a hand-rolled joint. Most cones include a rolled paper crutch (or nib) for the mouth to wrap around, avoiding the problem of a soggy joint or slipping flower. |
/-
Copyright (c) 2022 Jujian Zhang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jujian Zhang
-/
import category_theory.limits.shapes.images
import category_theory.limits.constructions.epi_mono
/-!
# Preserving images
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
In this file, we show that if a functor preserves span and cospan, then it preserves images.
-/
noncomputable theory
namespace category_theory
namespace preserves_image
open category_theory
open category_theory.limits
universes u₁ u₂ v₁ v₂
variables {A : Type u₁} {B : Type u₂} [category.{v₁} A] [category.{v₂} B]
variables [has_equalizers A] [has_images A]
variables [strong_epi_category B] [has_images B]
variables (L : A ⥤ B)
variables [Π {X Y Z : A} (f : X ⟶ Z) (g : Y ⟶ Z), preserves_limit (cospan f g) L]
variables [Π {X Y Z : A} (f : X ⟶ Y) (g : X ⟶ Z), preserves_colimit (span f g) L]
/--
If a functor preserves span and cospan, then it preserves images.
-/
@[simps] def iso {X Y : A} (f : X ⟶ Y) : image (L.map f) ≅ L.obj (image f) :=
let aux1 : strong_epi_mono_factorisation (L.map f) :=
{ I := L.obj (limits.image f),
m := L.map $ limits.image.ι _,
m_mono := preserves_mono_of_preserves_limit _ _,
e := L.map $ factor_thru_image _,
e_strong_epi := @@strong_epi_of_epi _ _ _ $ preserves_epi_of_preserves_colimit L _,
fac' := by rw [←L.map_comp, limits.image.fac] } in
is_image.iso_ext (image.is_image (L.map f)) aux1.to_mono_is_image
@[reassoc] lemma factor_thru_image_comp_hom {X Y : A} (f : X ⟶ Y) :
factor_thru_image (L.map f) ≫ (iso L f).hom =
L.map (factor_thru_image f) :=
by simp
@[reassoc] lemma hom_comp_map_image_ι {X Y : A} (f : X ⟶ Y) :
(iso L f).hom ≫ L.map (image.ι f) = image.ι (L.map f) :=
by simp
@[reassoc] lemma inv_comp_image_ι_map {X Y : A} (f : X ⟶ Y) :
(iso L f).inv ≫ image.ι (L.map f) = L.map (image.ι f) :=
by simp
end preserves_image
end category_theory
|
(*
Copyright (C) 2017 M.A.L. Marques
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)
(* type: gga_exc *)
params_a_n := 19:
params_a_a := [
13/12, 7/6, 8/6, 9/6, 10/6, 17/12, 9/6, 10/6,
11/6, 10/6, 11/6, 12/6, 10/6, 11/6, 12/6, 7/6,
8/6, 9/6, 10/6.0
]:
params_a_b := [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]:
params_a_c := [0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0]:
params_a_d := [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0]:
params_a_omega := [
+0.678831e+00, -0.175821e+01, +0.127676e+01, -0.160789e+01, +0.365610e+00, -0.181327e+00,
+0.146973e+00, +0.147141e+00, -0.716917e-01, -0.407167e-01, +0.214625e-01, -0.768156e-03,
+0.310377e-01, -0.720326e-01, +0.446562e-01, -0.266802e+00, +0.150822e+01, -0.194515e+01,
+0.679078e+00
]:
$include "th.mpl"
f := (rs, z, xt, xs0, xs1) -> f_th(rs, z, xt, xs0, xs1):
|
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import ring_theory.subsemiring.pointwise
import group_theory.subgroup.pointwise
import ring_theory.subring.basic
/-! # Pointwise instances on `subring`s
This file provides the action `subring.pointwise_mul_action` which matches the action of
`mul_action_set`.
This actions is available in the `pointwise` locale.
## Implementation notes
This file is almost identical to `ring_theory/subsemiring/pointwise.lean`. Where possible, try to
keep them in sync.
-/
open set
variables {M R : Type*}
namespace subring
section monoid
variables [monoid M] [ring R] [mul_semiring_action M R]
/-- The action on a subring corresponding to applying the action to every element.
This is available as an instance in the `pointwise` locale. -/
protected def pointwise_mul_action : mul_action M (subring R) :=
{ smul := λ a S, S.map (mul_semiring_action.to_ring_hom _ _ a),
one_smul := λ S,
(congr_arg (λ f, S.map f) (ring_hom.ext $ by exact one_smul M)).trans S.map_id,
mul_smul := λ a₁ a₂ S,
(congr_arg (λ f, S.map f) (ring_hom.ext $ by exact mul_smul _ _)).trans (S.map_map _ _).symm }
localized "attribute [instance] subring.pointwise_mul_action" in pointwise
open_locale pointwise
lemma pointwise_smul_def {a : M} (S : subring R) :
a • S = S.map (mul_semiring_action.to_ring_hom _ _ a) := rfl
@[simp] lemma coe_pointwise_smul (m : M) (S : subring R) : ↑(m • S) = m • (S : set R) := rfl
@[simp] lemma pointwise_smul_to_add_subgroup (m : M) (S : subring R) :
(m • S).to_add_subgroup = m • S.to_add_subgroup := rfl
@[simp] lemma pointwise_smul_to_subsemiring (m : M) (S : subring R) :
(m • S).to_subsemiring = m • S.to_subsemiring := rfl
lemma smul_mem_pointwise_smul (m : M) (r : R) (S : subring R) : r ∈ S → m • r ∈ m • S :=
(set.smul_mem_smul_set : _ → _ ∈ m • (S : set R))
lemma mem_smul_pointwise_iff_exists (m : M) (r : R) (S : subring R) :
r ∈ m • S ↔ ∃ (s : R), s ∈ S ∧ m • s = r :=
(set.mem_smul_set : r ∈ m • (S : set R) ↔ _)
instance pointwise_central_scalar [mul_semiring_action Mᵐᵒᵖ R] [is_central_scalar M R] :
is_central_scalar M (subring R) :=
⟨λ a S, congr_arg (λ f, S.map f) $ ring_hom.ext $ by exact op_smul_eq_smul _⟩
end monoid
section group
variables [group M] [ring R] [mul_semiring_action M R]
open_locale pointwise
@[simp] lemma smul_mem_pointwise_smul_iff {a : M} {S : subring R} {x : R} :
a • x ∈ a • S ↔ x ∈ S :=
smul_mem_smul_set_iff
lemma mem_pointwise_smul_iff_inv_smul_mem {a : M} {S : subring R} {x : R} :
x ∈ a • S ↔ a⁻¹ • x ∈ S :=
mem_smul_set_iff_inv_smul_mem
lemma mem_inv_pointwise_smul_iff {a : M} {S : subring R} {x : R} : x ∈ a⁻¹ • S ↔ a • x ∈ S :=
mem_inv_smul_set_iff
@[simp] lemma pointwise_smul_le_pointwise_smul_iff {a : M} {S T : subring R} :
a • S ≤ a • T ↔ S ≤ T :=
set_smul_subset_set_smul_iff
lemma pointwise_smul_subset_iff {a : M} {S T : subring R} : a • S ≤ T ↔ S ≤ a⁻¹ • T :=
set_smul_subset_iff
lemma subset_pointwise_smul_iff {a : M} {S T : subring R} : S ≤ a • T ↔ a⁻¹ • S ≤ T :=
subset_set_smul_iff
/-! TODO: add `equiv_smul` like we have for subgroup. -/
end group
section group_with_zero
variables [group_with_zero M] [ring R] [mul_semiring_action M R]
open_locale pointwise
@[simp] lemma smul_mem_pointwise_smul_iff₀ {a : M} (ha : a ≠ 0) (S : subring R)
(x : R) : a • x ∈ a • S ↔ x ∈ S :=
smul_mem_smul_set_iff₀ ha (S : set R) x
lemma mem_pointwise_smul_iff_inv_smul_mem₀ {a : M} (ha : a ≠ 0) (S : subring R) (x : R) :
x ∈ a • S ↔ a⁻¹ • x ∈ S :=
mem_smul_set_iff_inv_smul_mem₀ ha (S : set R) x
lemma mem_inv_pointwise_smul_iff₀ {a : M} (ha : a ≠ 0) (S : subring R) (x : R) :
x ∈ a⁻¹ • S ↔ a • x ∈ S :=
mem_inv_smul_set_iff₀ ha (S : set R) x
@[simp] lemma pointwise_smul_le_pointwise_smul_iff₀ {a : M} (ha : a ≠ 0) {S T : subring R} :
a • S ≤ a • T ↔ S ≤ T :=
set_smul_subset_set_smul_iff₀ ha
lemma pointwise_smul_le_iff₀ {a : M} (ha : a ≠ 0) {S T : subring R} : a • S ≤ T ↔ S ≤ a⁻¹ • T :=
set_smul_subset_iff₀ ha
lemma le_pointwise_smul_iff₀ {a : M} (ha : a ≠ 0) {S T : subring R} : S ≤ a • T ↔ a⁻¹ • S ≤ T :=
subset_set_smul_iff₀ ha
end group_with_zero
end subring
|
State Before: α : Type u_1
β : Type ?u.363947
γ : Type ?u.363950
inst✝ : DecidableEq α
a b : α
n : ℕ
⊢ count a (replicate n b) = if a = b then n else 0 State After: case h.e'_2
α : Type u_1
β : Type ?u.363947
γ : Type ?u.363950
inst✝ : DecidableEq α
a b : α
n : ℕ
⊢ count a (replicate n b) = List.count a (List.replicate n b) Tactic: convert List.count_replicate a b n State Before: case h.e'_2
α : Type u_1
β : Type ?u.363947
γ : Type ?u.363950
inst✝ : DecidableEq α
a b : α
n : ℕ
⊢ count a (replicate n b) = List.count a (List.replicate n b) State After: no goals Tactic: rw [←coe_count, coe_replicate] |
import pseudo_normed_group.category
import rescale.basic
noncomputable theory
open_locale nnreal
namespace rescale
open pseudo_normed_group
variables (r r' : ℝ≥0) (M : Type*)
section pseudo_normed_group
variables [pseudo_normed_group M]
instance : pseudo_normed_group (rescale r M) :=
{ filtration := λ c, show set M, from filtration M (c * r⁻¹),
filtration_mono := λ c₁ c₂ h, filtration_mono (mul_le_mul' h le_rfl),
zero_mem_filtration := λ c, @zero_mem_filtration M _ _,
neg_mem_filtration := λ c, @neg_mem_filtration M _ _,
add_mem_filtration := λ c₁ c₂, by { simp only [add_mul], apply add_mem_filtration } }
lemma mem_filtration (x : rescale r M) (c : ℝ≥0) :
x ∈ filtration (rescale r M) c ↔ (of.symm x) ∈ filtration M (c * r⁻¹) :=
iff.rfl
lemma mem_filtration' (x : rescale r M) (c : ℝ≥0) [fact (0 < r)] :
of x ∈ filtration (rescale r M) c ↔ x ∈ filtration M (c * r⁻¹) := iff.rfl
def to_rescale_one_strict_pseudo_normed_group_hom :
strict_pseudo_normed_group_hom M (rescale 1 M) :=
{ to_fun := rescale.of,
map_zero' := rfl,
map_add' := λ _ _, rfl,
strict' := λ c x hx, by rwa [mem_filtration', inv_one, mul_one]
}
def of_rescale_one_strict_pseudo_normed_group_hom :
strict_pseudo_normed_group_hom (rescale 1 M) M :=
{ to_fun := rescale.of.symm,
map_zero' := rfl,
map_add' := λ _ _, rfl,
strict' := λ c x hx, by rwa [mem_filtration, inv_one, mul_one] at hx
}
-- def of_to_rescale_one_comp_eq_id [fact (0 < r)] [fact (0 < r')] :
-- (of_rescale_one_strict_pseudo_normed_group_hom M).comp
-- (to_rescale_one_strict_pseudo_normed_group_hom M) =
-- strict_pseudo_normed_group_hom.id (rescale 1 M) :=
-- rfl
-- def to_of_rescale_one_comp_eq_id [fact (0 < r)] [fact (0 < r')] :
-- (to_rescale_one_strict_pseudo_normed_group_hom M).comp
-- (of_rescale_one_strict_pseudo_normed_group_hom M) =
-- strict_pseudo_normed_group_hom.id M :=
-- rfl
def of_rescale_eq_strict_pseudo_normed_group_hom [fact (0 < r)] [fact (0 < r')] (h : r = r') :
strict_pseudo_normed_group_hom (rescale r M) (rescale r' M) :=
{ to_fun := λ m, rescale.of (rescale.of.symm m),
map_zero' := rfl,
map_add' := λ _ _, rfl,
strict' := λ c x hx, by rwa [mem_filtration', ← h, ← mem_filtration r M],
}
def of_rescale_rescale_strict_pseudo_normed_group_hom [fact (0 < r)] [fact (0 < r')] :
strict_pseudo_normed_group_hom (rescale r (rescale r' M)) (rescale (r' * r) M) :=
{ to_fun := λ m, (rescale.of (rescale.of.symm (rescale.of.symm m))),
map_zero' := rfl,
map_add' := λ _ _, rfl,
strict' := λ c x hx, by rwa [mem_filtration', mul_inv_rev, ← mul_assoc],
}
def to_rescale_rescale_strict_pseudo_normed_group_hom [fact (0 < r)] [fact (0 < r')]:
strict_pseudo_normed_group_hom (rescale (r' * r) M) (rescale r (rescale r' M)) :=
{ to_fun := λ m, (rescale.of (rescale.of (rescale.of.symm m))),
map_zero' := rfl,
map_add' := λ _ _, rfl,
strict' := λ c x hx, by
rwa [mem_filtration' r (rescale r' M), mem_filtration', mul_assoc, ← mul_inv_rev,
← mem_filtration (r' * r) M] }
-- def of_to_rescale_rescale_comp_eq_id [fact (0 < r)] [fact (0 < r')] :
-- (of_rescale_rescale_strict_pseudo_normed_group_hom r r' M).comp
-- (to_rescale_rescale_strict_pseudo_normed_group_hom r r' M) =
-- strict_pseudo_normed_group_hom.id (rescale r (rescale r' M)) :=
-- rfl
-- def to_of_rescale_rescale_comp_eq_id' [fact (0 < r)] [fact (0 < r')] :
-- (to_rescale_rescale_strict_pseudo_normed_group_hom r r' M).comp
-- (of_rescale_rescale_strict_pseudo_normed_group_hom r r' M) =
-- strict_pseudo_normed_group_hom.id (rescale (r' * r) M) :=
-- rfl
end pseudo_normed_group
--Should we change name to this section? But one for the comphaus_fil.. and one for the
--profinitely_filt.. seems a lot
section profinitely_filtered_pseudo_normed_group
open comphaus_filtered_pseudo_normed_group profinitely_filtered_pseudo_normed_group
instance [comphaus_filtered_pseudo_normed_group M] :
comphaus_filtered_pseudo_normed_group (rescale r M) :=
{ topology := by { delta rescale, apply_instance },
t2 := by { delta rescale, apply_instance },
compact := by { delta rescale, apply_instance },
continuous_add' :=
begin
intros c₁ c₂,
haveI : fact ((c₁ + c₂) * r⁻¹ ≤ c₁ * r⁻¹ + c₂ * r⁻¹) := ⟨(add_mul _ _ _).le⟩,
rw (embedding_cast_le ((c₁ + c₂) * r⁻¹) (c₁ * r⁻¹ + c₂ * r⁻¹)).continuous_iff,
exact (continuous_add' (c₁ * r⁻¹) (c₂ * r⁻¹)),
end,
continuous_neg' := λ c, continuous_neg' _,
continuous_cast_le := λ c₁ c₂ h, by exactI continuous_cast_le _ _,}
instance [profinitely_filtered_pseudo_normed_group M] :
profinitely_filtered_pseudo_normed_group (rescale r M) := {}
@[simps]
def map_comphaus_filtered_pseudo_normed_group_hom {M₁ M₂ : Type*}
[comphaus_filtered_pseudo_normed_group M₁] [comphaus_filtered_pseudo_normed_group M₂]
(N : ℝ≥0) (f : comphaus_filtered_pseudo_normed_group_hom M₁ M₂) :
comphaus_filtered_pseudo_normed_group_hom (rescale N M₁) (rescale N M₂) :=
{ to_fun := rescale.of ∘ f ∘ rescale.of.symm,
map_zero' := f.map_zero,
map_add' := λ x y, f.map_add x y,
bound' := begin
obtain ⟨C, hC⟩ := f.bound,
refine ⟨C, λ c x hx, _⟩,
rw rescale.mem_filtration at hx ⊢,
simp only [function.comp_app, equiv.symm_apply_apply, mul_assoc],
exact hC hx,
end,
continuous' := λ c₁ c₂ f₀ hf₀, f.continuous f₀ hf₀, }
@[simps]
def map_strict_comphaus_filtered_pseudo_normed_group_hom {M₁ M₂ : Type*}
[comphaus_filtered_pseudo_normed_group M₁] [comphaus_filtered_pseudo_normed_group M₂]
(N : ℝ≥0) (f : strict_comphaus_filtered_pseudo_normed_group_hom M₁ M₂) :
strict_comphaus_filtered_pseudo_normed_group_hom (rescale N M₁) (rescale N M₂) :=
{ to_fun := rescale.of ∘ f ∘ rescale.of.symm,
map_zero' := f.map_zero,
map_add' := λ x y, f.map_add x y,
strict' := λ c x hx, begin
rw rescale.mem_filtration at hx ⊢,
simp only [function.comp_app, equiv.symm_apply_apply, mul_assoc],
exact f.strict hx,
end,
continuous' := λ c, f.continuous' _, }
end profinitely_filtered_pseudo_normed_group
section profinitely_filtered_pseudo_normed_group_with_Tinv
open profinitely_filtered_pseudo_normed_group_with_Tinv
open profinitely_filtered_pseudo_normed_group
variables [profinitely_filtered_pseudo_normed_group_with_Tinv r' M]
include r'
@[simps]
def Tinv' : rescale r M →+ rescale r M :=
{ to_fun := λ x, of $ Tinv $ of.symm x,
map_zero' := by { delta rescale, exact Tinv.map_zero },
map_add' := by { delta rescale, exact Tinv.map_add } }
lemma Tinv'_mem_filtration (c : ℝ≥0) (x : rescale r M) (hx : x ∈ filtration (rescale r M) c) :
(Tinv' r r' M) x ∈ filtration (rescale r M) (r'⁻¹ * c) :=
by simpa only [mem_filtration, Tinv'_apply, equiv.symm_apply_apply, mul_assoc]
using Tinv_mem_filtration _ _ hx
variable [fact (0 < r')]
@[simps]
def Tinv : comphaus_filtered_pseudo_normed_group_hom (rescale r M) (rescale r M) :=
comphaus_filtered_pseudo_normed_group_hom.mk' (Tinv' r r' M)
begin
refine ⟨r'⁻¹, λ c, ⟨Tinv'_mem_filtration r r' M c, _⟩⟩,
haveI : fact (c * r⁻¹ ≤ r' * (r'⁻¹ * c * r⁻¹)) :=
⟨by rw [mul_assoc, mul_inv_cancel_left₀ ‹fact (0 < r')›.1.ne.symm]⟩,
apply Tinv₀_continuous,
end
instance : profinitely_filtered_pseudo_normed_group_with_Tinv r' (rescale r M) :=
{ Tinv := rescale.Tinv r r' M,
Tinv_mem_filtration := Tinv'_mem_filtration r r' M,
.. rescale.profinitely_filtered_pseudo_normed_group r M }
@[simps]
def map_comphaus_filtered_pseudo_normed_group_with_Tinv_hom {M₁ M₂ : Type*}
[profinitely_filtered_pseudo_normed_group_with_Tinv r' M₁]
[profinitely_filtered_pseudo_normed_group_with_Tinv r' M₂]
(N : ℝ≥0) (f : comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M₁ M₂) :
comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' (rescale N M₁) (rescale N M₂) :=
{ to_fun := rescale.of ∘ f ∘ rescale.of.symm,
strict' := λ c x hx, begin
rw rescale.mem_filtration at hx ⊢,
simp only [function.comp_app, equiv.symm_apply_apply, mul_assoc],
exact f.strict hx,
end,
map_Tinv' := f.map_Tinv,
continuous' := λ c, f.continuous' (c * N⁻¹),
.. map_comphaus_filtered_pseudo_normed_group_hom N
f.to_comphaus_filtered_pseudo_normed_group_hom }
end profinitely_filtered_pseudo_normed_group_with_Tinv
end rescale
namespace ProFiltPseuNormGrpWithTinv
variables (r' : ℝ≥0) [fact (0 < r')]
@[simps]
def rescale (N : ℝ≥0) : ProFiltPseuNormGrpWithTinv r' ⥤ ProFiltPseuNormGrpWithTinv r' :=
{ obj := λ M, of r' $ rescale N M,
map := λ M₁ M₂ f, rescale.map_comphaus_filtered_pseudo_normed_group_with_Tinv_hom _ _ f }
end ProFiltPseuNormGrpWithTinv
namespace ProFiltPseuNormGrpWithTinv₁
variables (r' : ℝ≥0) [fact (0 < r')]
@[simps]
def rescale (N : ℝ≥0) [fact (0 < N)] :
ProFiltPseuNormGrpWithTinv₁ r' ⥤ ProFiltPseuNormGrpWithTinv₁ r' :=
{ obj := λ M,
{ M := rescale N M,
exhaustive' := λ x,
begin
obtain ⟨c, hc⟩ := M.exhaustive r' (rescale.of.symm x),
refine ⟨c * N, _⟩,
rw rescale.mem_filtration,
rwa mul_inv_cancel_right₀,
exact (fact.out _ : 0 < N).ne'
end },
map := λ M₁ M₂ f, rescale.map_comphaus_filtered_pseudo_normed_group_with_Tinv_hom _ _ f, }
.
@[simps]
def rescale_out (N : ℝ≥0) [fact (1 ≤ N)] :
rescale r' N ⟶ 𝟭 _ :=
{ app := λ M,
{ to_fun := (rescale.of.symm : _root_.rescale N M → M),
map_zero' := rfl,
map_add' := λ x y, rfl,
strict' := λ c x hx, pseudo_normed_group.filtration_mono (fact.out _) hx,
continuous' := λ c, comphaus_filtered_pseudo_normed_group.continuous_cast_le (c * N⁻¹) c,
map_Tinv' := λ x, rfl } }
end ProFiltPseuNormGrpWithTinv₁
|
-- just an old factorial function
def fac : ℕ → ℕ
| 0 := 1
| (nat.succ n') :=
(nat.succ n') * (fac n')
/-
Let's look at proofs of (fac k = 0) in two
different styles. In one style we'll use
metavariables and axioms. In the other, it's
ordinary variables and constructive proofs.
-/
-- with metavariables and axioms
variable k : ℕ
#check k
#reduce k -- can't reduce a metavariable
axiom k0 : k = 0 -- omg, it's a real function
#check k0 -- wait, that's kind of weird
#check k0 k -- we can create proofs of k = 0
variable l : ℕ -- for any k, let's try it on l
#check k0 l -- here we have a proof of l = 0
#reduce k0 k -- but again can't reduce metavar
-- that said, we can use the axiom in proofs
example : fac k = 1 :=
begin
have keq0 := k0 k,
rw keq0,
trivial,
end
-- QED
/-
Now with ordinary variables: it's just rfl.
In a way, rfl causes (fac k) to compute, to
reduce, after which it's just reflexive eq.
-/
/-
Here's a zero-valued (non-meta) variable. It
thus has a definite value, which, in this case
is zero. There's a constructive proof, namely
0, of the type of k', i.e., ℕ.
-/
def k' := 0
/-
Now the proof is literally trivial. In this
case, the trivial tactic tries applying rfl
and that is all it takes.
-/
example : fac k' = 1 :=
begin
trivial,
end |
#' bubbles.
#'
#' @name bubbles
#' @docType package
NULL
|
-- an example showing how to use sigma types to define a type for non-zero natural numbers
module nat-nonzero where
open import bool
open import eq
open import nat
open import nat-thms
open import product
ℕ⁺ : Set
ℕ⁺ = Σ ℕ (λ n → iszero n ≡ ff)
suc⁺ : ℕ⁺ → ℕ⁺
suc⁺ (x , p) = (suc x , refl)
_+⁺_ : ℕ⁺ → ℕ⁺ → ℕ⁺
(x , p) +⁺ (y , q) = x + y , iszerosum2 x y p
_*⁺_ : ℕ⁺ → ℕ⁺ → ℕ⁺
(x , p) *⁺ (y , q) = (x * y , iszeromult x y p q)
|
/-
Copyright (c) 2020 Johan Commelin, Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Damiano Testa, Yaël Dillies
! This file was ported from Lean 3 source module order.synonym
! leanprover-community/mathlib commit c4658a649d216f57e99621708b09dcb3dcccbd23
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathlib.Logic.Equiv.Defs
import Mathlib.Logic.Nontrivial
import Mathlib.Order.Basic
/-!
# Type synonyms
This file provides two type synonyms for order theory:
* `OrderDual α`: Type synonym of `α` to equip it with the dual order (`a ≤ b` becomes `b ≤ a`).
* `Lex α`: Type synonym of `α` to equip it with its lexicographic order. The precise meaning depends
on the type we take the lex of. Examples include `Prod`, `Sigma`, `List`, `Finset`.
## Notation
`αᵒᵈ` is notation for `OrderDual α`.
The general rule for notation of `Lex` types is to append `ₗ` to the usual notation.
## Implementation notes
One should not abuse definitional equality between `α` and `αᵒᵈ`/`Lex α`. Instead, explicit
coercions should be inserted:
* `OrderDual`: `OrderDual.toDual : α → αᵒᵈ` and `OrderDual.ofDual : αᵒᵈ → α`
* `Lex`: `toLex : α → Lex α` and `ofLex : Lex α → α`.
## See also
This file is similar to `Algebra.Group.TypeTags`.
-/
variable {α β γ : Type _}
/-! ### Order dual -/
namespace OrderDual
instance [h : Nontrivial α] : Nontrivial αᵒᵈ :=
h
/-- `toDual` is the identity function to the `OrderDual` of a linear order. -/
def toDual : α ≃ αᵒᵈ :=
Equiv.refl _
#align order_dual.to_dual OrderDual.toDual
/-- `ofDual` is the identity function from the `OrderDual` of a linear order. -/
def ofDual : αᵒᵈ ≃ α :=
Equiv.refl _
#align order_dual.of_dual OrderDual.ofDual
@[simp]
theorem toDual_symm_eq : (@toDual α).symm = ofDual := rfl
#align order_dual.to_dual_symm_eq OrderDual.toDual_symm_eq
@[simp]
theorem ofDual_symm_eq : (@ofDual α).symm = toDual := rfl
#align order_dual.of_dual_symm_eq OrderDual.ofDual_symm_eq
@[simp]
theorem toDual_ofDual (a : αᵒᵈ) : toDual (ofDual a) = a :=
rfl
#align order_dual.to_dual_of_dual OrderDual.toDual_ofDual
@[simp]
-- Porting note:
-- removed @[simp] since this already follows by `simp only [EmbeddingLike.apply_eq_iff_eq]`
theorem toDual_inj {a b : α} : toDual a = toDual b ↔ a = b :=
Iff.rfl
#align order_dual.to_dual_inj OrderDual.toDual_inj
-- Porting note:
-- removed @[simp] since this already follows by `simp only [EmbeddingLike.apply_eq_iff_eq]`
theorem ofDual_inj {a b : αᵒᵈ} : ofDual a = ofDual b ↔ a = b :=
Iff.rfl
#align order_dual.of_dual_inj OrderDual.ofDual_inj
@[simp]
theorem toDual_le_toDual [LE α] {a b : α} : toDual a ≤ toDual b ↔ b ≤ a :=
Iff.rfl
#align order_dual.to_dual_le_to_dual OrderDual.toDual_le_toDual
@[simp]
theorem toDual_lt_toDual [LT α] {a b : α} : toDual a < toDual b ↔ b < a :=
Iff.rfl
#align order_dual.to_dual_lt_to_dual OrderDual.toDual_lt_toDual
@[simp]
theorem ofDual_le_ofDual [LE α] {a b : αᵒᵈ} : ofDual a ≤ ofDual b ↔ b ≤ a :=
Iff.rfl
#align order_dual.of_dual_le_of_dual OrderDual.ofDual_le_ofDual
@[simp]
theorem ofDual_lt_ofDual [LT α] {a b : αᵒᵈ} : ofDual a < ofDual b ↔ b < a :=
Iff.rfl
#align order_dual.of_dual_lt_of_dual OrderDual.ofDual_lt_ofDual
theorem le_toDual [LE α] {a : αᵒᵈ} {b : α} : a ≤ toDual b ↔ b ≤ ofDual a :=
Iff.rfl
#align order_dual.le_to_dual OrderDual.le_toDual
theorem lt_toDual [LT α] {a : αᵒᵈ} {b : α} : a < toDual b ↔ b < ofDual a :=
Iff.rfl
#align order_dual.lt_to_dual OrderDual.lt_toDual
theorem toDual_le [LE α] {a : α} {b : αᵒᵈ} : toDual a ≤ b ↔ ofDual b ≤ a :=
Iff.rfl
#align order_dual.to_dual_le OrderDual.toDual_le
theorem toDual_lt [LT α] {a : α} {b : αᵒᵈ} : toDual a < b ↔ ofDual b < a :=
Iff.rfl
#align order_dual.to_dual_lt OrderDual.toDual_lt
/-- Recursor for `αᵒᵈ`. -/
@[elab_as_elim]
protected def rec {C : αᵒᵈ → Sort _} (h₂ : ∀ a : α, C (toDual a)) : ∀ a : αᵒᵈ, C a :=
h₂
#align order_dual.rec OrderDual.rec
@[simp]
protected theorem «forall» {p : αᵒᵈ → Prop} : (∀ a, p a) ↔ ∀ a, p (toDual a) :=
Iff.rfl
#align order_dual.forall OrderDual.forall
@[simp]
protected theorem «exists» {p : αᵒᵈ → Prop} : (∃ a, p a) ↔ ∃ a, p (toDual a) :=
Iff.rfl
#align order_dual.exists OrderDual.exists
alias toDual_le_toDual ↔ _ _root_.LE.le.dual
alias toDual_lt_toDual ↔ _ _root_.LT.lt.dual
alias ofDual_le_ofDual ↔ _ _root_.LE.le.ofDual
#align has_le.le.of_dual LE.le.ofDual
alias ofDual_lt_ofDual ↔ _ _root_.LT.lt.ofDual
#align has_lt.lt.of_dual LT.lt.ofDual
end OrderDual
/-! ### Lexicographic order -/
/-- A type synonym to equip a type with its lexicographic order. -/
def Lex (α : Type _) :=
α
#align lex Lex
/-- `toLex` is the identity function to the `Lex` of a type. -/
@[match_pattern]
def toLex : α ≃ Lex α :=
Equiv.refl _
#align to_lex toLex
/-- `ofLex` is the identity function from the `lex` of a type. -/
@[match_pattern]
def ofLex : Lex α ≃ α :=
Equiv.refl _
#align of_lex ofLex
@[simp]
theorem toLex_symm_eq : (@toLex α).symm = ofLex :=
rfl
#align to_lex_symm_eq toLex_symm_eq
@[simp]
theorem ofLex_symm_eq : (@ofLex α).symm = toLex :=
rfl
#align of_lex_symm_eq ofLex_symm_eq
@[simp]
theorem toLex_ofLex (a : Lex α) : toLex (ofLex a) = a :=
rfl
#align to_lex_of_lex toLex_ofLex
@[simp]
theorem ofLex_toLex (a : α) : ofLex (toLex a) = a :=
rfl
#align of_lex_to_lex ofLex_toLex
-- Porting note:
-- removed @[simp] since this already follows by `simp only [EmbeddingLike.apply_eq_iff_eq]`
theorem toLex_inj {a b : α} : toLex a = toLex b ↔ a = b :=
Iff.rfl
#align to_lex_inj toLex_inj
-- Porting note:
-- removed @[simp] since this already follows by `simp only [EmbeddingLike.apply_eq_iff_eq]`
theorem ofLex_inj {a b : Lex α} : ofLex a = ofLex b ↔ a = b :=
Iff.rfl
#align of_lex_inj ofLex_inj
/-- A recursor for `Lex`. Use as `induction x using Lex.rec`. -/
protected def Lex.rec {β : Lex α → Sort _} (h : ∀ a, β (toLex a)) : ∀ a, β a := fun a => h (ofLex a)
#align lex.rec Lex.rec
|
In June 2010 , it was announced Fey would receive a star on the Hollywood Walk of Fame in 2011 .
|
MODULE stel_constants
USE stel_kinds
!----------------------------------------------------------------------
! Mathematical constants
!----------------------------------------------------------------------
REAL(rprec), PARAMETER :: pi=3.14159265358979323846264338328_rprec
REAL(rprec), PARAMETER :: pio2=1.570796326794896619231321691_rprec
REAL(rprec), PARAMETER :: twopi=6.28318530717958647692528677_rprec
REAL(rprec), PARAMETER :: sqrt2=1.41421356237309504880168872_rprec
REAL(rprec), PARAMETER :: degree = twopi / 360
REAL(rprec), PARAMETER :: one = 1.0_rprec
REAL(rprec), PARAMETER :: zero = 0.0_rprec
!----------------------------------------------------------------------
! Physical constants
!------------------------------------------------------------------
REAL(rprec), PARAMETER :: mu0 = 2 * twopi * 1.0e-7_rprec
END MODULE stel_constants
|
lemma continuous_mult_right: fixes c::"'a::real_normed_algebra" shows "continuous F f \<Longrightarrow> continuous F (\<lambda>x. f x * c)" |
[STATEMENT]
lemma V_of_Real_set: "bij_betw V_of (UNIV::real set) (elts Real_set)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. bij_betw V_of UNIV (elts Real_set)
[PROOF STEP]
by (simp add: Real_set_def bij_betw_def inj_V_of) |
-- @@stderr --
dtrace: failed to compile script test/unittest/union/err.D_DECL_COMBO.UnionWithoutColon1.d: [D_DECL_COMBO] line 30: invalid type combination
|
theory T109
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. mult(meet(x, y), z) = meet(mult(x, z), mult(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. 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=4,timeout=86400]
oops
end |
module Let0
import Data.Nat
import Data.Vect
go : (_ : Vect n elem) -> (_ : Vect m elem) -> Vect (n + m) elem
go acc [] = let 0 prf = plusZeroRightNeutral n in ?rhs
go {m=S m} acc (x :: xs) = rewrite sym $ plusSuccRightSucc n m in go (x::acc) xs
|
(*
Title: Locale-Based Duality
Author: Georg Struth
Maintainer:Georg Struth <[email protected]>
*)
section \<open>Locale-Based Duality\<close>
theory Order_Lattice_Props_Loc
imports Main
"HOL-Library.Lattice_Syntax"
begin
text \<open>This section explores order and lattice duality based on locales. Used within the context of a class or locale,
this is very effective, though more opaque than the previous approach. Outside of such a context, however, it apparently
cannot be used for dualising theorems. Examples are properties of functions between orderings or lattices.\<close>
definition Fix :: "('a \<Rightarrow> 'a) \<Rightarrow> 'a set" where
"Fix f = {x. f x = x}"
context ord
begin
definition min_set :: "'a set \<Rightarrow> 'a set" where
"min_set X = {y \<in> X. \<forall>x \<in> X. x \<le> y \<longrightarrow> x = y}"
definition max_set :: "'a set \<Rightarrow> 'a set" where
"max_set X = {x \<in> X. \<forall>y \<in> X. x \<le> y \<longrightarrow> x = y}"
definition directed :: "'a set \<Rightarrow> bool" where
"directed X = (\<forall>Y. finite Y \<and> Y \<subseteq> X \<longrightarrow> (\<exists>x \<in> X. \<forall>y \<in> Y. y \<le> x))"
definition filtered :: "'a set \<Rightarrow> bool" where
"filtered X = (\<forall>Y. finite Y \<and> Y \<subseteq> X \<longrightarrow> (\<exists>x \<in> X. \<forall>y \<in> Y. x \<le> y))"
definition downset_set :: "'a set \<Rightarrow> 'a set" ("\<Down>") where
"\<Down>X = {y. \<exists>x \<in> X. y \<le> x}"
definition upset_set :: "'a set \<Rightarrow> 'a set" ("\<Up>") where
"\<Up>X = {y. \<exists>x \<in> X. x \<le> y}"
definition downset :: "'a \<Rightarrow> 'a set" ("\<down>") where
"\<down> = \<Down> \<circ> (\<lambda>x. {x})"
definition upset :: "'a \<Rightarrow> 'a set" ("\<up>") where
"\<up> = \<Up> \<circ> (\<lambda>x. {x})"
definition downsets :: "'a set set" where
"downsets = Fix \<Down>"
definition upsets :: "'a set set" where
"upsets = Fix \<Up>"
abbreviation "downset_setp X \<equiv> X \<in> downsets"
abbreviation "upset_setp X \<equiv> X \<in> upsets"
definition ideals :: "'a set set" where
"ideals = {X. X \<noteq> {} \<and> downset_setp X \<and> directed X}"
definition filters :: "'a set set" where
"filters = {X. X \<noteq> {} \<and> upset_setp X \<and> filtered X}"
abbreviation "idealp X \<equiv> X \<in> ideals"
abbreviation "filterp X \<equiv> X \<in> filters"
end
abbreviation Sup_pres :: "('a::Sup \<Rightarrow> 'b::Sup) \<Rightarrow> bool" where
"Sup_pres f \<equiv> f \<circ> Sup = Sup \<circ> (`) f"
abbreviation Inf_pres :: "('a::Inf \<Rightarrow> 'b::Inf) \<Rightarrow> bool" where
"Inf_pres f \<equiv> f \<circ> Inf = Inf \<circ> (`) f"
abbreviation sup_pres :: "('a::sup \<Rightarrow> 'b::sup) \<Rightarrow> bool" where
"sup_pres f \<equiv> (\<forall>x y. f (x \<squnion> y) = f x \<squnion> f y)"
abbreviation inf_pres :: "('a::inf \<Rightarrow> 'b::inf) \<Rightarrow> bool" where
"inf_pres f \<equiv> (\<forall>x y. f (x \<sqinter> y) = f x \<sqinter> f y)"
abbreviation bot_pres :: "('a::bot \<Rightarrow> 'b::bot) \<Rightarrow> bool" where
"bot_pres f \<equiv> f \<bottom> = \<bottom>"
abbreviation top_pres :: "('a::top \<Rightarrow> 'b::top) \<Rightarrow> bool" where
"top_pres f \<equiv> f \<top> = \<top>"
abbreviation Sup_dual :: "('a::Sup \<Rightarrow> 'b::Inf) \<Rightarrow> bool" where
"Sup_dual f \<equiv> f \<circ> Sup = Inf \<circ> (`) f"
abbreviation Inf_dual :: "('a::Inf \<Rightarrow> 'b::Sup) \<Rightarrow> bool" where
"Inf_dual f \<equiv> f \<circ> Inf = Sup \<circ> (`) f"
abbreviation sup_dual :: "('a::sup \<Rightarrow> 'b::inf) \<Rightarrow> bool" where
"sup_dual f \<equiv> (\<forall>x y. f (x \<squnion> y) = f x \<sqinter> f y)"
abbreviation inf_dual :: "('a::inf \<Rightarrow> 'b::sup) \<Rightarrow> bool" where
"inf_dual f \<equiv> (\<forall>x y. f (x \<sqinter> y) = f x \<squnion> f y)"
abbreviation bot_dual :: "('a::bot \<Rightarrow> 'b::top) \<Rightarrow> bool" where
"bot_dual f \<equiv> f \<bottom> = \<top>"
abbreviation top_dual :: "('a::top \<Rightarrow> 'b::bot) \<Rightarrow> bool" where
"top_dual f \<equiv> f \<top> = \<bottom>"
subsection \<open>Duality via Locales\<close>
sublocale ord \<subseteq> dual_ord: ord "(\<ge>)" "(>)"
rewrites dual_max_set: "max_set = dual_ord.min_set"
and dual_filtered: "filtered = dual_ord.directed"
and dual_upset_set: "upset_set = dual_ord.downset_set"
and dual_upset: "upset = dual_ord.downset"
and dual_upsets: "upsets = dual_ord.downsets"
and dual_filters: "filters = dual_ord.ideals"
apply unfold_locales
unfolding max_set_def ord.min_set_def fun_eq_iff apply blast
unfolding filtered_def ord.directed_def apply simp
unfolding upset_set_def ord.downset_set_def apply simp
apply (simp add: ord.downset_def ord.downset_set_def ord.upset_def ord.upset_set_def)
unfolding upsets_def ord.downsets_def apply (metis ord.downset_set_def upset_set_def)
unfolding filters_def ord.ideals_def Fix_def ord.downsets_def upsets_def ord.downset_set_def upset_set_def ord.directed_def filtered_def
by simp
sublocale preorder \<subseteq> dual_preorder: preorder "(\<ge>)" "(>)"
apply unfold_locales
apply (simp add: less_le_not_le)
apply simp
using order_trans by blast
sublocale order \<subseteq> dual_order: order "(\<ge>)" "(>)"
by (unfold_locales, simp)
sublocale lattice \<subseteq> dual_lattice: lattice sup "(\<ge>)" "(>)" inf
by (unfold_locales, simp_all)
sublocale bounded_lattice \<subseteq> dual_bounded_lattice: bounded_lattice sup "(\<ge>)" "(>)" inf \<top> \<bottom>
by (unfold_locales, simp_all)
sublocale boolean_algebra \<subseteq> dual_boolean_algebra: boolean_algebra "\<lambda>x y. x \<squnion> -y" uminus sup "(\<ge>)" "(>)" inf \<top> \<bottom>
by (unfold_locales, simp_all add: inf_sup_distrib1)
sublocale complete_lattice \<subseteq> dual_complete_lattice: complete_lattice Sup Inf sup "(\<ge>)" "(>)" inf \<top> \<bottom>
rewrites dual_gfp: "gfp = dual_complete_lattice.lfp"
proof-
show "class.complete_lattice Sup Inf sup (\<ge>) (>) inf \<top> \<bottom>"
by (unfold_locales, simp_all add: Sup_upper Sup_least Inf_lower Inf_greatest)
then interpret dual_complete_lattice: complete_lattice Sup Inf sup "(\<ge>)" "(>)" inf \<top> \<bottom>.
show "gfp = dual_complete_lattice.lfp"
unfolding gfp_def dual_complete_lattice.lfp_def fun_eq_iff by simp
qed
context ord
begin
lemma dual_min_set: "min_set = dual_ord.max_set"
by (simp add: dual_ord.dual_max_set)
lemma dual_directed: "directed = dual_ord.filtered"
by (simp add:dual_ord.dual_filtered)
lemma dual_downset: "downset = dual_ord.upset"
by (simp add: dual_ord.dual_upset)
lemma dual_downset_set: "downset_set = dual_ord.upset_set"
by (simp add: dual_ord.dual_upset_set)
lemma dual_downsets: "downsets = dual_ord.upsets"
by (simp add: dual_ord.dual_upsets)
lemma dual_ideals: "ideals = dual_ord.filters"
by (simp add: dual_ord.dual_filters)
end
context complete_lattice
begin
lemma dual_lfp: "lfp = dual_complete_lattice.gfp"
by (simp add: dual_complete_lattice.dual_gfp)
end
subsection \<open>Properties of Orderings, Again\<close>
context ord
begin
lemma directed_nonempty: "directed X \<Longrightarrow> X \<noteq> {}"
unfolding directed_def by fastforce
lemma directed_ub: "directed X \<Longrightarrow> (\<forall>x \<in> X. \<forall>y \<in> X. \<exists>z \<in> X. x \<le> z \<and> y \<le> z)"
by (meson empty_subsetI directed_def finite.emptyI finite_insert insert_subset order_refl)
lemma downset_set_prop: "\<Down> = Union \<circ> (`) \<down>"
unfolding downset_set_def downset_def fun_eq_iff by fastforce
lemma downset_set_prop_var: "\<Down>X = (\<Union>x \<in> X. \<down>x)"
by (simp add: downset_set_prop)
lemma downset_prop: "\<down>x = {y. y \<le> x}"
unfolding downset_def downset_set_def fun_eq_iff comp_def by fastforce
end
context preorder
begin
lemma directed_prop: "X \<noteq> {} \<Longrightarrow> (\<forall>x \<in> X. \<forall>y \<in> X. \<exists>z \<in> X. x \<le> z \<and> y \<le> z) \<Longrightarrow> directed X"
proof-
assume h1: "X \<noteq> {}"
and h2: "\<forall>x \<in> X. \<forall>y \<in> X. \<exists>z \<in> X. x \<le> z \<and> y \<le> z"
{fix Y
have "finite Y \<Longrightarrow> Y \<subseteq> X \<Longrightarrow> (\<exists>x \<in> X. \<forall>y \<in> Y. y \<le> x)"
proof (induct rule: finite_induct)
case empty
then show ?case
using h1 by blast
next
case (insert x F)
then show ?case
by (metis h2 insert_iff insert_subset order_trans)
qed}
thus ?thesis
by (simp add: directed_def)
qed
lemma directed_alt: "directed X = (X \<noteq> {} \<and> (\<forall>x \<in> X. \<forall>y \<in> X. \<exists>z \<in> X. x \<le> z \<and> y \<le> z))"
by (metis directed_prop directed_nonempty directed_ub)
lemma downset_set_ext: "id \<le> \<Down>"
unfolding le_fun_def id_def downset_set_def by auto
lemma downset_set_iso: "mono \<Down>"
unfolding mono_def downset_set_def by blast
lemma downset_set_idem [simp]: "\<Down> \<circ> \<Down> = \<Down>"
unfolding fun_eq_iff downset_set_def comp_def using order_trans by auto
lemma downset_faithful: "\<down>x \<subseteq> \<down>y \<Longrightarrow> x \<le> y"
by (simp add: downset_prop subset_eq)
lemma downset_iso_iff: "(\<down>x \<subseteq> \<down>y) = (x \<le> y)"
using atMost_iff downset_prop order_trans by blast
lemma downset_directed_downset_var [simp]: "directed (\<Down>X) = directed X"
proof
assume h1: "directed X"
{fix Y
assume h2: "finite Y" and h3: "Y \<subseteq> \<Down>X"
hence "\<forall>y. \<exists>x. y \<in> Y \<longrightarrow> x \<in> X \<and> y \<le> x"
by (force simp: downset_set_def)
hence "\<exists>f. \<forall>y. y \<in> Y \<longrightarrow> f y \<in> X \<and> y \<le> f y"
by (rule choice)
hence "\<exists>f. finite (f ` Y) \<and> f ` Y \<subseteq> X \<and> (\<forall>y \<in> Y. y \<le> f y)"
by (metis finite_imageI h2 image_subsetI)
hence "\<exists>Z. finite Z \<and> Z \<subseteq> X \<and> (\<forall>y \<in> Y. \<exists> z \<in> Z. y \<le> z)"
by fastforce
hence "\<exists>Z. finite Z \<and> Z \<subseteq> X \<and> (\<forall>y \<in> Y. \<exists> z \<in> Z. y \<le> z) \<and> (\<exists>x \<in> X. \<forall> z \<in> Z. z \<le> x)"
by (metis directed_def h1)
hence "\<exists>x \<in> X. \<forall>y \<in> Y. y \<le> x"
by (meson order_trans)}
thus "directed (\<Down>X)"
unfolding directed_def downset_set_def by fastforce
next
assume "directed (\<Down>X)"
thus "directed X"
unfolding directed_def downset_set_def
apply clarsimp
by (smt Ball_Collect order_refl order_trans subsetCE)
qed
lemma downset_directed_downset [simp]: "directed \<circ> \<Down> = directed"
unfolding fun_eq_iff comp_def by simp
lemma directed_downset_ideals: "directed (\<Down>X) = (\<Down>X \<in> ideals)"
by (metis (mono_tags, lifting) Fix_def comp_apply directed_alt downset_set_idem downsets_def ideals_def mem_Collect_eq)
end
lemma downset_iso: "mono (\<down>::'a::order \<Rightarrow> 'a set)"
by (simp add: downset_iso_iff mono_def)
context order
begin
lemma downset_inj: "inj \<down>"
by (metis injI downset_iso_iff eq_iff)
end
context lattice
begin
lemma lat_ideals: "X \<in> ideals = (X \<noteq> {} \<and> X \<in> downsets \<and> (\<forall>x \<in> X. \<forall> y \<in> X. x \<squnion> y \<in> X))"
unfolding ideals_def directed_alt downsets_def Fix_def downset_set_def
by (clarsimp, smt sup.cobounded1 sup.orderE sup.orderI sup_absorb2 sup_left_commute mem_Collect_eq)
end
context bounded_lattice
begin
lemma bot_ideal: "X \<in> ideals \<Longrightarrow> \<bottom> \<in> X"
unfolding ideals_def downsets_def Fix_def downset_set_def by fastforce
end
context complete_lattice
begin
lemma Sup_downset_id [simp]: "Sup \<circ> \<down> = id"
using Sup_atMost atMost_def downset_prop by fastforce
lemma downset_Sup_id: "id \<le> \<down> \<circ> Sup"
by (simp add: Sup_upper downset_prop le_funI subsetI)
lemma Inf_Sup_var: "\<Squnion>(\<Inter>x \<in> X. \<down>x) = \<Sqinter>X"
unfolding downset_prop by (simp add: Collect_ball_eq Inf_eq_Sup)
lemma Inf_pres_downset_var: "(\<Inter>x \<in> X. \<down>x) = \<down>(\<Sqinter>X)"
unfolding downset_prop by (safe, simp_all add: le_Inf_iff)
end
lemma lfp_in_Fix:
fixes f :: "'a::complete_lattice \<Rightarrow> 'a"
shows "mono f \<Longrightarrow> lfp f \<in> Fix f"
using Fix_def lfp_unfold by fastforce
lemma gfp_in_Fix:
fixes f :: "'a::complete_lattice \<Rightarrow> 'a"
shows "mono f \<Longrightarrow> gfp f \<in> Fix f"
using Fix_def gfp_unfold by fastforce
lemma nonempty_Fix:
fixes f :: "'a::complete_lattice \<Rightarrow> 'a"
shows "mono f \<Longrightarrow> Fix f \<noteq> {}"
using lfp_in_Fix by fastforce
subsection \<open>Dual Properties of Orderings from Locales\<close>
text \<open>These properties can be proved very smoothly overall. But only within the context of a class
or locale!\<close>
context ord
begin
lemma filtered_lb: "filtered X \<Longrightarrow> (\<forall>x \<in> X. \<forall>y \<in> X. \<exists>z \<in> X. z \<le> x \<and> z \<le> y)"
by (simp add: dual_filtered dual_ord.directed_ub)
lemma upset_set_prop: "\<Up> = Union \<circ> (`) \<up>"
by (simp add: dual_ord.downset_set_prop dual_upset dual_upset_set)
lemma upset_set_prop_var: "\<Up>X = (\<Union>x \<in> X. \<up>x)"
by (simp add: dual_ord.downset_set_prop_var dual_upset dual_upset_set)
lemma upset_prop: "\<up>x = {y. x \<le> y}"
by (simp add: dual_ord.downset_prop dual_upset)
end
context preorder
begin
lemma filtered_prop: "X \<noteq> {} \<Longrightarrow> (\<forall>x \<in> X. \<forall>y \<in> X. \<exists>z \<in> X. z \<le> x \<and> z \<le> y) \<Longrightarrow> filtered X"
by (simp add: dual_filtered dual_preorder.directed_prop)
lemma filtered_alt: "filtered X = (X \<noteq> {} \<and> (\<forall>x \<in> X. \<forall>y \<in> X. \<exists>z \<in> X. z \<le> x \<and> z \<le> y))"
by (simp add: dual_filtered dual_preorder.directed_alt)
lemma upset_set_ext: "id \<le> \<Up>"
by (simp add: dual_preorder.downset_set_ext dual_upset_set)
lemma upset_set_anti: "mono \<Up>"
by (simp add: dual_preorder.downset_set_iso dual_upset_set)
lemma up_set_idem [simp]: "\<Up> \<circ> \<Up> = \<Up>"
by (simp add: dual_upset_set)
lemma upset_faithful: "\<up>x \<subseteq> \<up>y \<Longrightarrow> y \<le> x"
by (metis dual_preorder.downset_faithful dual_upset)
lemma upset_anti_iff: "(\<up>y \<subseteq> \<up>x) = (x \<le> y)"
by (simp add: dual_preorder.downset_iso_iff dual_upset)
lemma upset_filtered_upset [simp]: "filtered \<circ> \<Up> = filtered"
by (simp add: dual_filtered dual_upset_set)
lemma filtered_upset_filters: "filtered (\<Up>X) = (\<Up>X \<in> filters)"
using dual_filtered dual_preorder.directed_downset_ideals dual_upset_set ord.dual_filters by fastforce
end
context order
begin
lemma upset_inj: "inj \<up>"
by (simp add: dual_order.downset_inj dual_upset)
end
context lattice
begin
end
context bounded_lattice
begin
lemma top_filter: "X \<in> filters \<Longrightarrow> \<top> \<in> X"
by (simp add: dual_bounded_lattice.bot_ideal dual_filters)
end
context complete_lattice
begin
lemma Inf_upset_id [simp]: "Inf \<circ> \<up> = id"
by (simp add: dual_upset)
lemma upset_Inf_id: "id \<le> \<up> \<circ> Inf"
by (simp add: dual_complete_lattice.downset_Sup_id dual_upset)
lemma Sup_Inf_var: " \<Sqinter>(\<Inter>x \<in> X. \<up>x) = \<Squnion>X"
by (simp add: dual_complete_lattice.Inf_Sup_var dual_upset)
lemma Sup_dual_upset_var: "(\<Inter>x \<in> X. \<up>x) = \<up>(\<Squnion>X)"
by (simp add: dual_complete_lattice.Inf_pres_downset_var dual_upset)
end
subsection \<open>Examples that Do Not Dualise\<close>
lemma upset_anti: "antimono (\<up>::'a::order \<Rightarrow> 'a set)"
by (simp add: antimono_def upset_anti_iff)
context complete_lattice
begin
lemma fSup_unfold: "(f::nat \<Rightarrow> 'a) 0 \<squnion> (\<Squnion>n. f (Suc n)) = (\<Squnion>n. f n)"
apply (intro antisym sup_least)
apply (rule Sup_upper, force)
apply (rule Sup_mono, force)
apply (safe intro!: Sup_least)
by (case_tac n, simp_all add: Sup_upper le_supI2)
lemma fInf_unfold: "(f::nat \<Rightarrow> 'a) 0 \<sqinter> (\<Sqinter>n. f (Suc n)) = (\<Sqinter>n. f n)"
apply (intro antisym inf_greatest)
apply (rule Inf_greatest, safe)
apply (case_tac n)
apply simp_all
using Inf_lower inf.coboundedI2 apply force
apply (simp add: Inf_lower)
by (auto intro: Inf_mono)
end
lemma fun_isol: "mono f \<Longrightarrow> mono ((\<circ>) f)"
by (simp add: le_fun_def mono_def)
lemma fun_isor: "mono f \<Longrightarrow> mono (\<lambda>x. x \<circ> f)"
by (simp add: le_fun_def mono_def)
lemma Sup_sup_pres:
fixes f :: "'a::complete_lattice \<Rightarrow> 'b::complete_lattice"
shows "Sup_pres f \<Longrightarrow> sup_pres f"
by (metis (no_types, hide_lams) Sup_empty Sup_insert comp_apply image_insert sup_bot.right_neutral)
lemma Inf_inf_pres:
fixes f :: "'a::complete_lattice \<Rightarrow> 'b::complete_lattice"
shows"Inf_pres f \<Longrightarrow> inf_pres f"
by (smt INF_insert comp_eq_elim dual_complete_lattice.Sup_empty dual_complete_lattice.Sup_insert inf_top.right_neutral)
lemma Sup_bot_pres:
fixes f :: "'a::complete_lattice \<Rightarrow> 'b::complete_lattice"
shows "Sup_pres f \<Longrightarrow> bot_pres f"
by (metis SUP_empty Sup_empty comp_eq_elim)
lemma Inf_top_pres:
fixes f :: "'a::complete_lattice \<Rightarrow> 'b::complete_lattice"
shows "Inf_pres f \<Longrightarrow> top_pres f"
by (metis INF_empty comp_eq_elim dual_complete_lattice.Sup_empty)
context complete_lattice
begin
lemma iso_Inf_subdistl:
assumes "mono (f::'a \<Rightarrow> 'b::complete_lattice)"
shows "f \<circ> Inf \<le> Inf \<circ> (`) f"
by (simp add: assms complete_lattice_class.le_Inf_iff le_funI Inf_lower monoD)
lemma iso_Sup_supdistl:
assumes "mono (f::'a \<Rightarrow> 'b::complete_lattice)"
shows "Sup \<circ> (`) f \<le> f \<circ> Sup"
by (simp add: assms complete_lattice_class.SUP_le_iff le_funI dual_complete_lattice.Inf_lower monoD)
lemma Inf_subdistl_iso:
fixes f :: "'a \<Rightarrow> 'b::complete_lattice"
shows "f \<circ> Inf \<le> Inf \<circ> (`) f \<Longrightarrow> mono f"
unfolding mono_def le_fun_def comp_def by (metis complete_lattice_class.le_INF_iff Inf_atLeast atLeast_iff)
lemma Sup_supdistl_iso:
fixes f :: "'a \<Rightarrow> 'b::complete_lattice"
shows "Sup \<circ> (`) f \<le> f \<circ> Sup \<Longrightarrow> mono f"
unfolding mono_def le_fun_def comp_def by (metis complete_lattice_class.SUP_le_iff Sup_atMost atMost_iff)
lemma supdistl_iso:
fixes f :: "'a \<Rightarrow> 'b::complete_lattice"
shows "(Sup \<circ> (`) f \<le> f \<circ> Sup) = mono f"
using Sup_supdistl_iso iso_Sup_supdistl by force
lemma subdistl_iso:
fixes f :: "'a \<Rightarrow> 'b::complete_lattice"
shows "(f \<circ> Inf \<le> Inf \<circ> (`) f) = mono f"
using Inf_subdistl_iso iso_Inf_subdistl by force
end
lemma fSup_distr: "Sup_pres (\<lambda>x. x \<circ> f)"
unfolding fun_eq_iff comp_def
by (smt Inf.INF_cong SUP_apply Sup_apply)
lemma fSup_distr_var: "\<Squnion>F \<circ> g = (\<Squnion>f \<in> F. f \<circ> g)"
unfolding fun_eq_iff comp_def
by (smt Inf.INF_cong SUP_apply Sup_apply)
lemma fInf_distr: "Inf_pres (\<lambda>x. x \<circ> f)"
unfolding fun_eq_iff comp_def
by (smt INF_apply Inf.INF_cong Inf_apply)
lemma fInf_distr_var: "\<Sqinter>F \<circ> g = (\<Sqinter>f \<in> F. f \<circ> g)"
unfolding fun_eq_iff comp_def
by (smt INF_apply Inf.INF_cong Inf_apply)
lemma fSup_subdistl:
assumes "mono (f::'a::complete_lattice \<Rightarrow> 'b::complete_lattice)"
shows "Sup \<circ> (`) ((\<circ>) f) \<le> (\<circ>) f \<circ> Sup"
using assms by (simp add: SUP_least Sup_upper le_fun_def monoD image_comp)
lemma fSup_subdistl_var:
fixes f :: "'a::complete_lattice \<Rightarrow> 'b::complete_lattice"
shows "mono f \<Longrightarrow> (\<Squnion>g \<in> G. f \<circ> g) \<le> f \<circ> \<Squnion>G"
by (simp add: SUP_least Sup_upper le_fun_def monoD image_comp)
lemma fInf_subdistl:
fixes f :: "'a::complete_lattice \<Rightarrow> 'b::complete_lattice"
shows "mono f \<Longrightarrow> (\<circ>) f \<circ> Inf \<le> Inf \<circ> (`) ((\<circ>) f)"
by (simp add: INF_greatest Inf_lower le_fun_def monoD image_comp)
lemma fInf_subdistl_var:
fixes f :: "'a::complete_lattice \<Rightarrow> 'b::complete_lattice"
shows "mono f \<Longrightarrow> f \<circ> \<Sqinter>G \<le> (\<Sqinter>g \<in> G. f \<circ> g)"
by (simp add: INF_greatest Inf_lower le_fun_def monoD image_comp)
lemma Inf_pres_downset: "Inf_pres (\<down>::'a::complete_lattice \<Rightarrow> 'a set)"
unfolding downset_prop fun_eq_iff comp_def
by (safe, simp_all add: le_Inf_iff)
text \<open>This approach could probably be combined with the explicit functor-based one. This may be good for proofs, but seems conceptually rather ugly.\<close>
end |
import tactic
variables (x y : ℕ)
open nat
theorem Q2a : 1 * x = x ∧ x = x * 1 :=
begin
split,
{ induction x with d hd,
refl,
rw [mul_succ,hd],
},
rw [mul_succ, mul_zero, zero_add],
end
-- Dr Lawn does not define z in her problem sheet.
-- Fortunately I can infer the type of z from the context.
variable z : ℕ
theorem Q2b : (x + y) * z = x * z + y * z :=
begin
induction z with d hd,
refl,
rw [mul_succ, hd, mul_succ, mul_succ],
ac_refl,
end
theorem Q2c : (x * y) * z = x * (y * z) :=
begin
induction z with d hd,
{ refl },
{ rw [mul_succ, mul_succ, hd, mul_add] }
end
-- Q3 def
def is_pred (x y : ℕ) := x.succ = y
theorem Q3a : ¬ ∃ x : ℕ, is_pred x 0 :=
begin
intro h,
cases h with x hx,
unfold is_pred at hx,
apply succ_ne_zero x,
assumption,
end
theorem Q3b : y ≠ 0 → ∃! x, is_pred x y :=
begin
intro hy,
cases y,
exfalso,
apply hy,
refl,
clear hy,
use y,
split,
{ dsimp only,
unfold is_pred,
},
intro z,
dsimp only [is_pred],
exact succ_inj'.1,
end
def aux : 0 < y → ∃ x, is_pred x y :=
begin
intro hy,
cases Q3b _ (ne_of_lt hy).symm with x hx,
use x,
exact hx.1,
end
-- definition of pred' is "choose a random d such that succ(d) = n"
noncomputable def pred' : ℕ+ → ℕ := λ nhn, classical.some (aux nhn nhn.2)
theorem pred'_def : ∀ np : ℕ+, is_pred (pred' np) np :=
λ nhn, classical.some_spec (aux nhn nhn.2)
def succ' : ℕ → ℕ+ :=
λ n, ⟨n.succ, zero_lt_succ n⟩
noncomputable definition Q3c : ℕ+ ≃ ℕ :=
{ to_fun := pred',
inv_fun := succ',
left_inv := begin
rintro np,
have h := pred'_def,
unfold succ',
ext, dsimp,
unfold is_pred at h,
rw h,
end,
right_inv := begin
intro n,
unfold succ',
have h := pred'_def,
unfold is_pred at h,
rw ← succ_inj',
rw h,
clear h,
refl,
end
}
|
/-
Copyright (c) 2021 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta
-/
import category_theory.limits.shapes.terminal
import category_theory.limits.shapes.binary_products
import category_theory.epi_mono
/-!
# Strict initial objects
This file sets up the basic theory of strict initial objects: initial objects where every morphism
to it is an isomorphism. This generalises a property of the empty set in the category of sets:
namely that the only function to the empty set is from itself.
We say `C` has strict initial objects if every initial object is strict, ie given any morphism
`f : A ⟶ I` where `I` is initial, then `f` is an isomorphism.
Strictly speaking, this says that *any* initial object must be strict, rather than that strict
initial objects exist, which turns out to be a more useful notion to formalise.
If the binary product of `X` with a strict initial object exists, it is also initial.
To show a category `C` with an initial object has strict initial objects, the most convenient way
is to show any morphism to the (chosen) initial object is an isomorphism and use
`has_strict_initial_objects_of_initial_is_strict`.
The dual notion (strict terminal objects) occurs much less frequently in practice so is ignored.
## TODO
* Construct examples of this: `Type*`, `Top`, `Groupoid`, simplicial types, posets.
* Construct the bottom element of the subobject lattice given strict initials.
* Show cartesian closed categories have strict initials
## References
* https://ncatlab.org/nlab/show/strict+initial+object
-/
universes v u
namespace category_theory
namespace limits
open category
variables (C : Type u) [category.{v} C]
section strict_initial
/--
We say `C` has strict initial objects if every initial object is strict, ie given any morphism
`f : A ⟶ I` where `I` is initial, then `f` is an isomorphism.
Strictly speaking, this says that *any* initial object must be strict, rather than that strict
initial objects exist.
-/
class has_strict_initial_objects : Prop :=
(out : ∀ {I A : C} (f : A ⟶ I), is_initial I → is_iso f)
variables {C}
section
variables [has_strict_initial_objects C] {I : C}
lemma is_initial.is_iso_to (hI : is_initial I) {A : C} (f : A ⟶ I) :
is_iso f :=
has_strict_initial_objects.out f hI
lemma is_initial.strict_hom_ext (hI : is_initial I) {A : C} (f g : A ⟶ I) :
f = g :=
begin
haveI := hI.is_iso_to f,
haveI := hI.is_iso_to g,
exact eq_of_inv_eq_inv (hI.hom_ext (inv f) (inv g)),
end
lemma is_initial.subsingleton_to (hI : is_initial I) {A : C} :
subsingleton (A ⟶ I) :=
⟨hI.strict_hom_ext⟩
@[priority 100] instance initial_mono_of_strict_initial_objects : initial_mono_class C :=
{ is_initial_mono_from := λ I A hI,
{ right_cancellation := λ B g h i, hI.strict_hom_ext _ _ } }
/-- If `I` is initial, then `X ⨯ I` is isomorphic to it. -/
@[simps hom]
noncomputable def mul_is_initial (X : C) [has_binary_product X I] (hI : is_initial I) :
X ⨯ I ≅ I :=
@@as_iso _ prod.snd (hI.is_iso_to _)
@[simp] lemma mul_is_initial_inv (X : C) [has_binary_product X I] (hI : is_initial I) :
(mul_is_initial X hI).inv = hI.to _ :=
hI.hom_ext _ _
/-- If `I` is initial, then `I ⨯ X` is isomorphic to it. -/
@[simps hom]
noncomputable def is_initial_mul (X : C) [has_binary_product I X] (hI : is_initial I) :
I ⨯ X ≅ I :=
@@as_iso _ prod.fst (hI.is_iso_to _)
@[simp] lemma is_initial_mul_inv (X : C) [has_binary_product I X] (hI : is_initial I) :
(is_initial_mul X hI).inv = hI.to _ :=
hI.hom_ext _ _
variable [has_initial C]
instance initial_is_iso_to {A : C} (f : A ⟶ ⊥_ C) : is_iso f :=
initial_is_initial.is_iso_to _
@[ext] lemma initial.hom_ext {A : C} (f g : A ⟶ ⊥_ C) : f = g :=
initial_is_initial.strict_hom_ext _ _
lemma initial.subsingleton_to {A : C} : subsingleton (A ⟶ ⊥_ C) :=
initial_is_initial.subsingleton_to
/--
The product of `X` with an initial object in a category with strict initial objects is itself
initial.
This is the generalisation of the fact that `X × empty ≃ empty` for types (or `n * 0 = 0`).
-/
@[simps hom]
noncomputable def mul_initial (X : C) [has_binary_product X ⊥_ C] :
X ⨯ ⊥_ C ≅ ⊥_ C :=
mul_is_initial _ initial_is_initial
@[simp] lemma mul_initial_inv (X : C) [has_binary_product X ⊥_ C] :
(mul_initial X).inv = initial.to _ :=
subsingleton.elim _ _
/--
The product of `X` with an initial object in a category with strict initial objects is itself
initial.
This is the generalisation of the fact that `empty × X ≃ empty` for types (or `0 * n = 0`).
-/
@[simps hom]
noncomputable def initial_mul (X : C) [has_binary_product (⊥_ C) X] :
⊥_ C ⨯ X ≅ ⊥_ C :=
is_initial_mul _ initial_is_initial
@[simp] lemma initial_mul_inv (X : C) [has_binary_product (⊥_ C) X] :
(initial_mul X).inv = initial.to _ :=
subsingleton.elim _ _
end
/-- If `C` has an initial object such that every morphism *to* it is an isomorphism, then `C`
has strict initial objects. -/
lemma has_strict_initial_objects_of_initial_is_strict [has_initial C]
(h : ∀ A (f : A ⟶ ⊥_ C), is_iso f) :
has_strict_initial_objects C :=
{ out := λ I A f hI,
begin
haveI := h A (f ≫ hI.to _),
exact ⟨⟨hI.to _ ≫ inv (f ≫ hI.to ⊥_ C), by rw [←assoc, is_iso.hom_inv_id], hI.hom_ext _ _⟩⟩,
end }
end strict_initial
section strict_terminal
/--
We say `C` has strict terminal objects if every terminal object is strict, ie given any morphism
`f : I ⟶ A` where `I` is terminal, then `f` is an isomorphism.
Strictly speaking, this says that *any* terminal object must be strict, rather than that strict
terminal objects exist.
-/
class has_strict_terminal_objects : Prop :=
(out : ∀ {I A : C} (f : I ⟶ A), is_terminal I → is_iso f)
variables {C}
section
variables [has_strict_terminal_objects C] {I : C}
lemma is_terminal.is_iso_from (hI : is_terminal I) {A : C} (f : I ⟶ A) :
is_iso f :=
has_strict_terminal_objects.out f hI
lemma is_terminal.strict_hom_ext (hI : is_terminal I) {A : C} (f g : I ⟶ A) :
f = g :=
begin
haveI := hI.is_iso_from f,
haveI := hI.is_iso_from g,
exact eq_of_inv_eq_inv (hI.hom_ext (inv f) (inv g)),
end
lemma is_terminal.subsingleton_to (hI : is_terminal I) {A : C} :
subsingleton (I ⟶ A) :=
⟨hI.strict_hom_ext⟩
variables {J : Type v} [small_category J]
/-- If all but one object in a diagram is strict terminal, the the limit is isomorphic to the
said object via `limit.π`. -/
lemma limit_π_is_iso_of_is_strict_terminal (F : J ⥤ C) [has_limit F] (i : J)
(H : ∀ j ≠ i, is_terminal (F.obj j)) [subsingleton (i ⟶ i)] :
is_iso (limit.π F i) :=
begin
classical,
refine ⟨⟨limit.lift _ ⟨_,⟨_,_⟩⟩,_,_⟩⟩,
{ exact λ j, dite (j = i) (λ h, eq_to_hom (by { cases h, refl })) (λ h, (H _ h).from _) },
{ intros j k f,
split_ifs,
{ cases h, cases h_1, have : f = 𝟙 _ := subsingleton.elim _ _, subst this, simpa },
{ cases h, erw category.comp_id,
haveI : is_iso (F.map f) := (H _ h_1).is_iso_from _,
rw ← is_iso.comp_inv_eq,
apply (H _ h_1).hom_ext },
{ cases h_1, apply (H _ h).hom_ext },
{ apply (H _ h).hom_ext } },
{ ext,
rw [assoc, limit.lift_π],
dsimp only,
split_ifs,
{ cases h, rw [id_comp, eq_to_hom_refl], exact comp_id _ },
{ apply (H _ h).hom_ext } },
{ rw limit.lift_π, simpa }
end
variable [has_terminal C]
instance terminal_is_iso_from {A : C} (f : ⊤_ C ⟶ A) : is_iso f :=
terminal_is_terminal.is_iso_from _
@[ext] lemma terminal.hom_ext {A : C} (f g : ⊤_ C ⟶ A) : f = g :=
terminal_is_terminal.strict_hom_ext _ _
lemma terminal.subsingleton_to {A : C} : subsingleton (⊤_ C ⟶ A) :=
terminal_is_terminal.subsingleton_to
end
/-- If `C` has an object such that every morphism *from* it is an isomorphism, then `C`
has strict terminal objects. -/
lemma has_strict_terminal_objects_of_terminal_is_strict (I : C) (h : ∀ A (f : I ⟶ A), is_iso f) :
has_strict_terminal_objects C :=
{ out := λ I' A f hI',
begin
haveI := h A (hI'.from _ ≫ f),
exact ⟨⟨inv (hI'.from I ≫ f) ≫ hI'.from I,
hI'.hom_ext _ _, by rw [assoc, is_iso.inv_hom_id]⟩⟩,
end }
end strict_terminal
end limits
end category_theory
|
[STATEMENT]
lemma while_option_NoneD:
assumes "while_option b c s = None"
and "wf r" and "\<And>s. b s \<Longrightarrow> (c s, s) \<in> r"
shows "False"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. False
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
while_option b c s = None
wf r
b ?s \<Longrightarrow> (c ?s, ?s) \<in> r
goal (1 subgoal):
1. False
[PROOF STEP]
by (blast intro: while_option_None_invD) |
Formal statement is: lemmas le_sup_lexord = sup_lexord[where P="\<lambda>a. c \<le> a" for c] Informal statement is: If $a$ is a real number, then $a \leq \sup(S)$ if and only if $a \leq s$ for all $s \in S$. |
C Copyright(C) 1999-2020 National Technology & Engineering Solutions
C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
C NTESS, the U.S. Government retains certain rights in this software.
C
C See packages/seacas/LICENSE for details
C=======================================================================
SUBROUTINE FFADDR (RVAL, LINE)
C=======================================================================
C --*** FFADDR *** (FFLIB) Add real to line
C -- Written by Amy Gilkey - revised 11/16/87
C --
C --FFADDR adds a real (as a character string) to a line.
C --
C --Parameters:
C -- RVAL - IN - the real to add
C -- LINE - IN/OUT - the line being built
REAL RVAL
CHARACTER*(*) LINE
CHARACTER*20 STR
IF (LINE .EQ. ' ') THEN
I = 0
ELSE
I = LENSTR (LINE) + 1
IF (I .LE. LEN (LINE)) LINE(I:I) = ' '
END IF
IF (I .LT. LEN (LINE)) THEN
CALL NUMSTR (1, 6, RVAL, STR, L)
LINE(I+1:) = STR
END IF
RETURN
END
|
State Before: M : Type u_1
A : Type ?u.128599
B : Type ?u.128602
inst✝ : Monoid M
n : M
⊢ powers n = closure {n} State After: case h
M : Type u_1
A : Type ?u.128599
B : Type ?u.128602
inst✝ : Monoid M
n x✝ : M
⊢ x✝ ∈ powers n ↔ x✝ ∈ closure {n} Tactic: ext State Before: case h
M : Type u_1
A : Type ?u.128599
B : Type ?u.128602
inst✝ : Monoid M
n x✝ : M
⊢ x✝ ∈ powers n ↔ x✝ ∈ closure {n} State After: no goals Tactic: exact mem_closure_singleton.symm |
/-
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Jeremy Avigad
-/
import data.finset.basic
import tactic.by_contra
/-!
# Cardinality of a finite set
This defines the cardinality of a `finset` and provides induction principles for finsets.
## Main declarations
* `finset.card`: `s.card : ℕ` returns the cardinality of `s : finset α`.
### Induction principles
* `finset.strong_induction`: Strong induction
* `finset.strong_induction_on`
* `finset.strong_downward_induction`
* `finset.strong_downward_induction_on`
* `finset.case_strong_induction_on`
## TODO
Should we add a noncomputable version?
-/
open function multiset nat
variables {α β : Type*}
namespace finset
variables {s t : finset α} {a b : α}
/-- `s.card` is the number of elements of `s`, aka its cardinality. -/
def card (s : finset α) : ℕ := s.1.card
lemma card_def (s : finset α) : s.card = s.1.card := rfl
@[simp] lemma card_mk {m nodup} : (⟨m, nodup⟩ : finset α).card = m.card := rfl
@[simp] lemma card_empty : card (∅ : finset α) = 0 := rfl
lemma card_le_of_subset : s ⊆ t → s.card ≤ t.card := multiset.card_le_of_le ∘ val_le_iff.mpr
@[mono] lemma card_mono : monotone (@card α) := by apply card_le_of_subset
@[simp] lemma card_eq_zero : s.card = 0 ↔ s = ∅ := card_eq_zero.trans val_eq_zero
lemma card_pos : 0 < s.card ↔ s.nonempty :=
pos_iff_ne_zero.trans $ (not_congr card_eq_zero).trans nonempty_iff_ne_empty.symm
alias finset.card_pos ↔ _ finset.nonempty.card_pos
lemma card_ne_zero_of_mem (h : a ∈ s) : s.card ≠ 0 := (not_congr card_eq_zero).2 $ ne_empty_of_mem h
@[simp] lemma card_singleton (a : α) : card ({a} : finset α) = 1 := card_singleton _
lemma card_singleton_inter [decidable_eq α] : ({a} ∩ s).card ≤ 1 :=
begin
cases (finset.decidable_mem a s),
{ simp [finset.singleton_inter_of_not_mem h] },
{ simp [finset.singleton_inter_of_mem h] }
end
@[simp] lemma card_cons (h : a ∉ s) : (s.cons a h).card = s.card + 1 := card_cons _ _
section insert_erase
variables [decidable_eq α]
@[simp] lemma card_insert_of_not_mem (h : a ∉ s) : (insert a s).card = s.card + 1 :=
by rw [←cons_eq_insert _ _ h, card_cons]
lemma card_insert_of_mem (h : a ∈ s) : card (insert a s) = s.card := by rw insert_eq_of_mem h
lemma card_insert_le (a : α) (s : finset α) : card (insert a s) ≤ s.card + 1 :=
by by_cases a ∈ s; [{rw insert_eq_of_mem h, exact nat.le_succ _ }, rw card_insert_of_not_mem h]
/-- If `a ∈ s` is known, see also `finset.card_insert_of_mem` and `finset.card_insert_of_not_mem`.
-/
lemma card_insert_eq_ite : card (insert a s) = if a ∈ s then s.card else s.card + 1 :=
begin
by_cases h : a ∈ s,
{ rw [card_insert_of_mem h, if_pos h] },
{ rw [card_insert_of_not_mem h, if_neg h] }
end
@[simp] lemma card_doubleton (h : a ≠ b) : ({a, b} : finset α).card = 2 :=
by rw [card_insert_of_not_mem (not_mem_singleton.2 h), card_singleton]
@[simp] lemma card_erase_of_mem : a ∈ s → (s.erase a).card = s.card - 1 := card_erase_of_mem
@[simp] lemma card_erase_add_one : a ∈ s → (s.erase a).card + 1 = s.card := card_erase_add_one
lemma card_erase_lt_of_mem : a ∈ s → (s.erase a).card < s.card := card_erase_lt_of_mem
lemma card_erase_le : (s.erase a).card ≤ s.card := card_erase_le
lemma pred_card_le_card_erase : s.card - 1 ≤ (s.erase a).card :=
begin
by_cases h : a ∈ s,
{ exact (card_erase_of_mem h).ge },
{ rw erase_eq_of_not_mem h,
exact nat.sub_le _ _ }
end
/-- If `a ∈ s` is known, see also `finset.card_erase_of_mem` and `finset.erase_eq_of_not_mem`. -/
lemma card_erase_eq_ite : (s.erase a).card = if a ∈ s then s.card - 1 else s.card :=
card_erase_eq_ite
end insert_erase
@[simp] lemma card_range (n : ℕ) : (range n).card = n := card_range n
@[simp] lemma card_attach : s.attach.card = s.card := multiset.card_attach
end finset
section to_list_multiset
variables [decidable_eq α] (m : multiset α) (l : list α)
lemma multiset.card_to_finset : m.to_finset.card = m.dedup.card := rfl
lemma multiset.to_finset_card_le : m.to_finset.card ≤ m.card := card_le_of_le $ dedup_le _
lemma multiset.to_finset_card_of_nodup {m : multiset α} (h : m.nodup) : m.to_finset.card = m.card :=
congr_arg card $ multiset.dedup_eq_self.mpr h
lemma list.card_to_finset : l.to_finset.card = l.dedup.length := rfl
lemma list.to_finset_card_le : l.to_finset.card ≤ l.length := multiset.to_finset_card_le ⟦l⟧
lemma list.to_finset_card_of_nodup {l : list α} (h : l.nodup) : l.to_finset.card = l.length :=
multiset.to_finset_card_of_nodup h
end to_list_multiset
namespace finset
variables {s t : finset α} {f : α → β} {n : ℕ}
@[simp] lemma length_to_list (s : finset α) : s.to_list.length = s.card :=
by { rw [to_list, ←multiset.coe_card, multiset.coe_to_list], refl }
lemma card_image_le [decidable_eq β] : (s.image f).card ≤ s.card :=
by simpa only [card_map] using (s.1.map f).to_finset_card_le
lemma card_image_of_inj_on [decidable_eq β] (H : set.inj_on f s) : (s.image f).card = s.card :=
by simp only [card, image_val_of_inj_on H, card_map]
lemma inj_on_of_card_image_eq [decidable_eq β] (H : (s.image f).card = s.card) : set.inj_on f s :=
begin
change (s.1.map f).dedup.card = s.1.card at H,
have : (s.1.map f).dedup = s.1.map f,
{ refine multiset.eq_of_le_of_card_le (multiset.dedup_le _) _,
rw H,
simp only [multiset.card_map] },
rw multiset.dedup_eq_self at this,
exact inj_on_of_nodup_map this,
end
lemma card_image_eq_iff_inj_on [decidable_eq β] : (s.image f).card = s.card ↔ set.inj_on f s :=
⟨inj_on_of_card_image_eq, card_image_of_inj_on⟩
lemma card_image_of_injective [decidable_eq β] (s : finset α) (H : injective f) :
(s.image f).card = s.card :=
card_image_of_inj_on $ λ x _ y _ h, H h
@[simp] lemma card_map (f : α ↪ β) : (s.map f).card = s.card := multiset.card_map _ _
@[simp] lemma card_subtype (p : α → Prop) [decidable_pred p] (s : finset α) :
(s.subtype p).card = (s.filter p).card :=
by simp [finset.subtype]
lemma card_filter_le (s : finset α) (p : α → Prop) [decidable_pred p] :
(s.filter p).card ≤ s.card :=
card_le_of_subset $ filter_subset _ _
lemma eq_of_subset_of_card_le {s t : finset α} (h : s ⊆ t) (h₂ : t.card ≤ s.card) : s = t :=
eq_of_veq $ multiset.eq_of_le_of_card_le (val_le_iff.mpr h) h₂
lemma map_eq_of_subset {f : α ↪ α} (hs : s.map f ⊆ s) : s.map f = s :=
eq_of_subset_of_card_le hs (card_map _).ge
lemma filter_card_eq {p : α → Prop} [decidable_pred p] (h : (s.filter p).card = s.card) (x : α)
(hx : x ∈ s) :
p x :=
begin
rw [←eq_of_subset_of_card_le (s.filter_subset p) h.ge, mem_filter] at hx,
exact hx.2,
end
lemma card_lt_card (h : s ⊂ t) : s.card < t.card := card_lt_of_lt $ val_lt_iff.2 h
lemma card_eq_of_bijective (f : ∀ i, i < n → α) (hf : ∀ a ∈ s, ∃ i, ∃ h : i < n, f i h = a)
(hf' : ∀ i (h : i < n), f i h ∈ s) (f_inj : ∀ i j (hi : i < n)
(hj : j < n), f i hi = f j hj → i = j) :
s.card = n :=
begin
classical,
have : ∀ (a : α), a ∈ s ↔ ∃ i (hi : i ∈ range n), f i (mem_range.1 hi) = a,
from λ a, ⟨λ ha, let ⟨i, hi, eq⟩ := hf a ha in ⟨i, mem_range.2 hi, eq⟩,
λ ⟨i, hi, eq⟩, eq ▸ hf' i (mem_range.1 hi)⟩,
have : s = ((range n).attach.image $ λi, f i.1 (mem_range.1 i.2)),
by simpa only [ext_iff, mem_image, exists_prop, subtype.exists, mem_attach, true_and],
calc s.card = card ((range n).attach.image $ λ i, f i.1 (mem_range.1 i.2)) :
by rw this
... = card ((range n).attach) :
card_image_of_injective _ $ λ ⟨i, hi⟩ ⟨j, hj⟩ eq,
subtype.eq $ f_inj i j (mem_range.1 hi) (mem_range.1 hj) eq
... = card (range n) : card_attach
... = n : card_range n
end
lemma card_congr {t : finset β} (f : Π a ∈ s, β) (h₁ : ∀ a ha, f a ha ∈ t)
(h₂ : ∀ a b ha hb, f a ha = f b hb → a = b) (h₃ : ∀ b ∈ t, ∃ a ha, f a ha = b) :
s.card = t.card :=
by classical;
calc s.card = s.attach.card : card_attach.symm
... = (s.attach.image (λ (a : {a // a ∈ s}), f a.1 a.2)).card
: eq.symm (card_image_of_injective _ $ λ a b h, subtype.eq $ h₂ _ _ _ _ h)
... = t.card : congr_arg card (finset.ext $ λ b,
⟨λ h, let ⟨a, ha₁, ha₂⟩ := mem_image.1 h in ha₂ ▸ h₁ _ _,
λ h, let ⟨a, ha₁, ha₂⟩ := h₃ b h in mem_image.2 ⟨⟨a, ha₁⟩, by simp [ha₂]⟩⟩)
lemma card_le_card_of_inj_on {t : finset β} (f : α → β) (hf : ∀ a ∈ s, f a ∈ t)
(f_inj : ∀ a₁ ∈ s, ∀ a₂ ∈ s, f a₁ = f a₂ → a₁ = a₂) :
s.card ≤ t.card :=
by classical;
calc s.card = (s.image f).card : (card_image_of_inj_on f_inj).symm
... ≤ t.card : card_le_of_subset $ image_subset_iff.2 hf
/-- If there are more pigeons than pigeonholes, then there are two pigeons in the same pigeonhole.
-/
lemma exists_ne_map_eq_of_card_lt_of_maps_to {t : finset β} (hc : t.card < s.card)
{f : α → β} (hf : ∀ a ∈ s, f a ∈ t) :
∃ (x ∈ s) (y ∈ s), x ≠ y ∧ f x = f y :=
begin
classical,
by_contra' hz,
refine hc.not_le (card_le_card_of_inj_on f hf _),
intros x hx y hy, contrapose, exact hz x hx y hy,
end
lemma le_card_of_inj_on_range (f : ℕ → α) (hf : ∀ i < n, f i ∈ s)
(f_inj : ∀ (i < n) (j < n), f i = f j → i = j) :
n ≤ s.card :=
calc n = card (range n) : (card_range n).symm
... ≤ s.card : card_le_card_of_inj_on f (by simpa only [mem_range]) (by simpa only [mem_range])
lemma surj_on_of_inj_on_of_card_le {t : finset β} (f : Π a ∈ s, β) (hf : ∀ a ha, f a ha ∈ t)
(hinj : ∀ a₁ a₂ ha₁ ha₂, f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂) (hst : t.card ≤ s.card) :
∀ b ∈ t, ∃ a ha, b = f a ha :=
begin
classical,
intros b hb,
have h : (s.attach.image $ λ (a : {a // a ∈ s}), f a a.prop).card = s.card,
{ exact @card_attach _ s ▸ card_image_of_injective _
(λ ⟨a₁, ha₁⟩ ⟨a₂, ha₂⟩ h, subtype.eq $ hinj _ _ _ _ h) },
have h' : image (λ a : {a // a ∈ s}, f a a.prop) s.attach = t,
{ exact eq_of_subset_of_card_le (λ b h, let ⟨a, ha₁, ha₂⟩ := mem_image.1 h in
ha₂ ▸ hf _ _) (by simp [hst, h]) },
rw ←h' at hb,
obtain ⟨a, ha₁, ha₂⟩ := mem_image.1 hb,
exact ⟨a, a.2, ha₂.symm⟩,
end
lemma inj_on_of_surj_on_of_card_le {t : finset β} (f : Π a ∈ s, β) (hf : ∀ a ha, f a ha ∈ t)
(hsurj : ∀ b ∈ t, ∃ a ha, b = f a ha) (hst : s.card ≤ t.card) ⦃a₁ a₂⦄ (ha₁ : a₁ ∈ s)
(ha₂ : a₂ ∈ s) (ha₁a₂: f a₁ ha₁ = f a₂ ha₂) :
a₁ = a₂ :=
by haveI : inhabited {x // x ∈ s} := ⟨⟨a₁, ha₁⟩⟩; exact
let f' : {x // x ∈ s} → {x // x ∈ t} := λ x, ⟨f x.1 x.2, hf x.1 x.2⟩ in
let g : {x // x ∈ t} → {x // x ∈ s} :=
@surj_inv _ _ f'
(λ x, let ⟨y, hy₁, hy₂⟩ := hsurj x.1 x.2 in ⟨⟨y, hy₁⟩, subtype.eq hy₂.symm⟩) in
have hg : injective g, from injective_surj_inv _,
have hsg : surjective g, from λ x,
let ⟨y, hy⟩ := surj_on_of_inj_on_of_card_le (λ (x : {x // x ∈ t}) (hx : x ∈ t.attach), g x)
(λ x _, show (g x) ∈ s.attach, from mem_attach _ _)
(λ x y _ _ hxy, hg hxy) (by simpa) x (mem_attach _ _) in
⟨y, hy.snd.symm⟩,
have hif : injective f',
from (left_inverse_of_surjective_of_right_inverse hsg
(right_inverse_surj_inv _)).injective,
subtype.ext_iff_val.1 (@hif ⟨a₁, ha₁⟩ ⟨a₂, ha₂⟩ (subtype.eq ha₁a₂))
@[simp] lemma card_disj_union (s t : finset α) (h) : (s.disj_union t h).card = s.card + t.card :=
multiset.card_add _ _
/-! ### Lattice structure -/
section lattice
variables [decidable_eq α]
lemma card_union_add_card_inter (s t : finset α) : (s ∪ t).card + (s ∩ t).card = s.card + t.card :=
finset.induction_on t (by simp) $ λ a r har, by by_cases a ∈ s; simp *; cc
lemma card_union_le (s t : finset α) : (s ∪ t).card ≤ s.card + t.card :=
card_union_add_card_inter s t ▸ nat.le_add_right _ _
lemma card_union_eq (h : disjoint s t) : (s ∪ t).card = s.card + t.card :=
by rw [←disj_union_eq_union s t $ λ x, disjoint_left.mp h, card_disj_union _ _ _]
@[simp] lemma card_disjoint_union (h : disjoint s t) : card (s ∪ t) = s.card + t.card :=
card_union_eq h
lemma card_sdiff (h : s ⊆ t) : card (t \ s) = t.card - s.card :=
suffices card (t \ s) = card ((t \ s) ∪ s) - s.card, by rwa sdiff_union_of_subset h at this,
by rw [card_disjoint_union sdiff_disjoint, add_tsub_cancel_right]
lemma card_sdiff_add_card_eq_card {s t : finset α} (h : s ⊆ t) : card (t \ s) + card s = card t :=
((nat.sub_eq_iff_eq_add (card_le_of_subset h)).mp (card_sdiff h).symm).symm
lemma le_card_sdiff (s t : finset α) : t.card - s.card ≤ card (t \ s) :=
calc card t - card s
≤ card t - card (s ∩ t) : tsub_le_tsub_left (card_le_of_subset (inter_subset_left s t)) _
... = card (t \ (s ∩ t)) : (card_sdiff (inter_subset_right s t)).symm
... ≤ card (t \ s) : by rw sdiff_inter_self_right t s
lemma card_sdiff_add_card : (s \ t).card + t.card = (s ∪ t).card :=
by rw [←card_disjoint_union sdiff_disjoint, sdiff_union_self_eq_union]
end lattice
lemma filter_card_add_filter_neg_card_eq_card (p : α → Prop) [decidable_pred p] :
(s.filter p).card + (s.filter (not ∘ p)).card = s.card :=
by { classical, simp [←card_union_eq, filter_union_filter_neg_eq, disjoint_filter] }
/-- Given a set `A` and a set `B` inside it, we can shrink `A` to any appropriate size, and keep `B`
inside it. -/
lemma exists_intermediate_set {A B : finset α} (i : ℕ) (h₁ : i + card B ≤ card A) (h₂ : B ⊆ A) :
∃ (C : finset α), B ⊆ C ∧ C ⊆ A ∧ card C = i + card B :=
begin
classical,
rcases nat.le.dest h₁ with ⟨k, _⟩,
clear h₁,
induction k with k ih generalizing A,
{ exact ⟨A, h₂, subset.refl _, h.symm⟩ },
have : (A \ B).nonempty,
{ rw [←card_pos, card_sdiff h₂, ←h, nat.add_right_comm,
add_tsub_cancel_right, nat.add_succ],
apply nat.succ_pos },
rcases this with ⟨a, ha⟩,
have z : i + card B + k = card (erase A a),
{ rw [card_erase_of_mem (mem_sdiff.1 ha).1, ←h],
refl },
rcases ih _ z with ⟨B', hB', B'subA', cards⟩,
{ exact ⟨B', hB', trans B'subA' (erase_subset _ _), cards⟩ },
{ rintro t th,
apply mem_erase_of_ne_of_mem _ (h₂ th),
rintro rfl,
exact not_mem_sdiff_of_mem_right th ha }
end
/-- We can shrink `A` to any smaller size. -/
lemma exists_smaller_set (A : finset α) (i : ℕ) (h₁ : i ≤ card A) :
∃ (B : finset α), B ⊆ A ∧ card B = i :=
let ⟨B, _, x₁, x₂⟩ := exists_intermediate_set i (by simpa) (empty_subset A) in ⟨B, x₁, x₂⟩
lemma exists_subset_or_subset_of_two_mul_lt_card [decidable_eq α] {X Y : finset α} {n : ℕ}
(hXY : 2 * n < (X ∪ Y).card) :
∃ C : finset α, n < C.card ∧ (C ⊆ X ∨ C ⊆ Y) :=
begin
have h₁ : (X ∩ (Y \ X)).card = 0 := finset.card_eq_zero.mpr (finset.inter_sdiff_self X Y),
have h₂ : (X ∪ Y).card = X.card + (Y \ X).card,
{ rw [←card_union_add_card_inter X (Y \ X), finset.union_sdiff_self_eq_union, h₁, add_zero] },
rw [h₂, two_mul] at hXY,
rcases lt_or_lt_of_add_lt_add hXY with h|h,
{ exact ⟨X, h, or.inl (finset.subset.refl X)⟩ },
{ exact ⟨Y \ X, h, or.inr (finset.sdiff_subset Y X)⟩ }
end
/-! ### Explicit description of a finset from its card -/
lemma card_eq_one : s.card = 1 ↔ ∃ a, s = {a} :=
by cases s; simp only [multiset.card_eq_one, finset.card, ←val_inj, singleton_val]
lemma exists_eq_insert_iff [decidable_eq α] {s t : finset α} :
(∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card :=
begin
split,
{ rintro ⟨a, ha, rfl⟩,
exact ⟨subset_insert _ _, (card_insert_of_not_mem ha).symm⟩ },
{ rintro ⟨hst, h⟩,
obtain ⟨a, ha⟩ : ∃ a, t \ s = {a},
{ exact card_eq_one.1 (by rw [card_sdiff hst, ←h, add_tsub_cancel_left]) },
refine ⟨a, λ hs, (_ : a ∉ {a}) $ mem_singleton_self _,
by rw [insert_eq, ←ha, sdiff_union_of_subset hst]⟩,
rw ←ha,
exact not_mem_sdiff_of_mem_right hs }
end
lemma card_le_one : s.card ≤ 1 ↔ ∀ (a ∈ s) (b ∈ s), a = b :=
begin
obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty,
{ simp },
refine (nat.succ_le_of_lt (card_pos.2 ⟨x, hx⟩)).le_iff_eq.trans (card_eq_one.trans ⟨_, _⟩),
{ rintro ⟨y, rfl⟩,
simp },
{ exact λ h, ⟨x, eq_singleton_iff_unique_mem.2 ⟨hx, λ y hy, h _ hy _ hx⟩⟩ }
end
lemma card_le_one_iff : s.card ≤ 1 ↔ ∀ {a b}, a ∈ s → b ∈ s → a = b := by { rw card_le_one, tauto }
lemma card_le_one_iff_subset_singleton [nonempty α] : s.card ≤ 1 ↔ ∃ (x : α), s ⊆ {x} :=
begin
refine ⟨λ H, _, _⟩,
{ obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty,
{ exact ⟨classical.arbitrary α, empty_subset _⟩ },
{ exact ⟨x, λ y hy, by rw [card_le_one.1 H y hy x hx, mem_singleton]⟩ } },
{ rintro ⟨x, hx⟩,
rw ←card_singleton x,
exact card_le_of_subset hx }
end
/-- A `finset` of a subsingleton type has cardinality at most one. -/
lemma card_le_one_of_subsingleton [subsingleton α] (s : finset α) : s.card ≤ 1 :=
finset.card_le_one_iff.2 $ λ _ _ _ _, subsingleton.elim _ _
lemma one_lt_card : 1 < s.card ↔ ∃ (a ∈ s) (b ∈ s), a ≠ b :=
by { rw ←not_iff_not, push_neg, exact card_le_one }
lemma one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b :=
by { rw one_lt_card, simp only [exists_prop, exists_and_distrib_left] }
lemma two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c :=
begin
classical,
refine ⟨λ h, _, _⟩,
{ obtain ⟨c, hc⟩ := card_pos.mp (zero_lt_two.trans h),
have : 1 < (s.erase c).card := by rwa [←add_lt_add_iff_right 1, card_erase_add_one hc],
obtain ⟨a, b, ha, hb, hab⟩ := one_lt_card_iff.mp this,
exact ⟨a, b, c, mem_of_mem_erase ha, mem_of_mem_erase hb, hc,
hab, ne_of_mem_erase ha, ne_of_mem_erase hb⟩ },
{ rintros ⟨a, b, c, ha, hb, hc, hab, hac, hbc⟩,
rw [←card_erase_add_one hc, ←card_erase_add_one (mem_erase_of_ne_of_mem hbc hb),
←card_erase_add_one (mem_erase_of_ne_of_mem hab (mem_erase_of_ne_of_mem hac ha))],
apply nat.le_add_left },
end
lemma two_lt_card : 2 < s.card ↔ ∃ (a ∈ s) (b ∈ s) (c ∈ s), a ≠ b ∧ a ≠ c ∧ b ≠ c :=
by simp_rw [two_lt_card_iff, exists_prop, exists_and_distrib_left]
lemma exists_ne_of_one_lt_card (hs : 1 < s.card) (a : α) : ∃ b, b ∈ s ∧ b ≠ a :=
begin
obtain ⟨x, hx, y, hy, hxy⟩ := finset.one_lt_card.mp hs,
by_cases ha : y = a,
{ exact ⟨x, hx, ne_of_ne_of_eq hxy ha⟩ },
{ exact ⟨y, hy, ha⟩ }
end
lemma card_eq_succ [decidable_eq α] : s.card = n + 1 ↔ ∃ a t, a ∉ t ∧ insert a t = s ∧ t.card = n :=
⟨λ h,
let ⟨a, has⟩ := card_pos.mp (h.symm ▸ nat.zero_lt_succ _ : 0 < s.card) in
⟨a, s.erase a, s.not_mem_erase a, insert_erase has,
by simp only [h, card_erase_of_mem has, add_tsub_cancel_right]⟩,
λ ⟨a, t, hat, s_eq, n_eq⟩, s_eq ▸ n_eq ▸ card_insert_of_not_mem hat⟩
lemma card_eq_two [decidable_eq α] : s.card = 2 ↔ ∃ x y, x ≠ y ∧ s = {x, y} :=
begin
split,
{ rw card_eq_succ,
simp_rw [card_eq_one],
rintro ⟨a, _, hab, rfl, b, rfl⟩,
exact ⟨a, b, not_mem_singleton.1 hab, rfl⟩ },
{ rintro ⟨x, y, h, rfl⟩,
exact card_doubleton h }
end
lemma card_eq_three [decidable_eq α] :
s.card = 3 ↔ ∃ x y z, x ≠ y ∧ x ≠ z ∧ y ≠ z ∧ s = {x, y, z} :=
begin
split,
{ rw card_eq_succ,
simp_rw [card_eq_two],
rintro ⟨a, _, abc, rfl, b, c, bc, rfl⟩,
rw [mem_insert, mem_singleton, not_or_distrib] at abc,
exact ⟨a, b, c, abc.1, abc.2, bc, rfl⟩ },
{ rintro ⟨x, y, z, xy, xz, yz, rfl⟩,
simp only [xy, xz, yz, mem_insert, card_insert_of_not_mem, not_false_iff, mem_singleton,
or_self, card_singleton] }
end
/-! ### Inductions -/
/-- Suppose that, given objects defined on all strict subsets of any finset `s`, one knows how to
define an object on `s`. Then one can inductively define an object on all finsets, starting from
the empty set and iterating. This can be used either to define data, or to prove properties. -/
def strong_induction {p : finset α → Sort*} (H : ∀ s, (∀ t ⊂ s, p t) → p s) :
∀ (s : finset α), p s
| s := H s (λ t h, have t.card < s.card, from card_lt_card h, strong_induction t)
using_well_founded {rel_tac := λ _ _, `[exact ⟨_, measure_wf card⟩]}
lemma strong_induction_eq {p : finset α → Sort*} (H : ∀ s, (∀ t ⊂ s, p t) → p s) (s : finset α) :
strong_induction H s = H s (λ t h, strong_induction H t) :=
by rw strong_induction
/-- Analogue of `strong_induction` with order of arguments swapped. -/
@[elab_as_eliminator] def strong_induction_on {p : finset α → Sort*} (s : finset α) :
(∀ s, (∀ t ⊂ s, p t) → p s) → p s :=
λ H, strong_induction H s
lemma strong_induction_on_eq {p : finset α → Sort*} (s : finset α) (H : ∀ s, (∀ t ⊂ s, p t) → p s) :
s.strong_induction_on H = H s (λ t h, t.strong_induction_on H) :=
by { dunfold strong_induction_on, rw strong_induction }
@[elab_as_eliminator] lemma case_strong_induction_on [decidable_eq α] {p : finset α → Prop}
(s : finset α) (h₀ : p ∅) (h₁ : ∀ a s, a ∉ s → (∀ t ⊆ s, p t) → p (insert a s)) :
p s :=
finset.strong_induction_on s $ λ s,
finset.induction_on s (λ _, h₀) $ λ a s n _ ih, h₁ a s n $
λ t ss, ih _ (lt_of_le_of_lt ss (ssubset_insert n) : t < _)
/-- Suppose that, given that `p t` can be defined on all supersets of `s` of cardinality less than
`n`, one knows how to define `p s`. Then one can inductively define `p s` for all finsets `s` of
cardinality less than `n`, starting from finsets of card `n` and iterating. This
can be used either to define data, or to prove properties. -/
def strong_downward_induction {p : finset α → Sort*} {n : ℕ} (H : ∀ t₁, (∀ {t₂ : finset α},
t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
∀ (s : finset α), s.card ≤ n → p s
| s := H s (λ t ht h, have n - t.card < n - s.card,
from (tsub_lt_tsub_iff_left_of_le ht).2 (finset.card_lt_card h),
strong_downward_induction t ht)
using_well_founded {rel_tac := λ _ _, `[exact ⟨_, measure_wf (λ (t : finset α), n - t.card)⟩]}
lemma strong_downward_induction_eq {p : finset α → Sort*}
(H : ∀ t₁, (∀ {t₂ : finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁)
(s : finset α) :
strong_downward_induction H s = H s (λ t ht hst, strong_downward_induction H t ht) :=
by rw strong_downward_induction
/-- Analogue of `strong_downward_induction` with order of arguments swapped. -/
@[elab_as_eliminator] def strong_downward_induction_on {p : finset α → Sort*} (s : finset α)
(H : ∀ t₁, (∀ {t₂ : finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
s.card ≤ n → p s :=
strong_downward_induction H s
lemma strong_downward_induction_on_eq {p : finset α → Sort*} (s : finset α) (H : ∀ t₁,
(∀ {t₂ : finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
s.strong_downward_induction_on H = H s (λ t ht h, t.strong_downward_induction_on H ht) :=
by { dunfold strong_downward_induction_on, rw strong_downward_induction }
lemma lt_wf {α} : well_founded (@has_lt.lt (finset α) _) :=
have H : subrelation (@has_lt.lt (finset α) _)
(inv_image ( < ) card),
from λ x y hxy, card_lt_card hxy,
subrelation.wf H $ inv_image.wf _ $ nat.lt_wf
end finset
|
{-
This file contains a summary of the proofs that π₄(S³) ≡ ℤ/2ℤ
- The first proof "π₄S³≃ℤ/2ℤ" closely follows Brunerie's thesis.
- The second proof "π₄S³≃ℤ/2ℤ-direct" is much more direct and avoids
all of the more advanced constructions in chapters 4-6 in Brunerie's
thesis.
- The third proof "π₄S³≃ℤ/2ℤ-computation" uses ideas from the direct
proof to define an alternative Brunerie number which computes to -2
in a few seconds and the main result is hence obtained by computation
as conjectured on page 85 of Brunerie's thesis.
The --experimental-lossy-unification flag is used to speed up type checking.
The file still type checks without it, but it's a lot slower (about 10 times).
-}
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Homotopy.Group.Pi4S3.Summary where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Data.Nat.Base
open import Cubical.Data.Int.Base
open import Cubical.Data.Sigma.Base
open import Cubical.HITs.Sn
open import Cubical.HITs.SetTruncation
open import Cubical.Homotopy.HopfInvariant.Base
open import Cubical.Homotopy.HopfInvariant.Homomorphism
open import Cubical.Homotopy.HopfInvariant.HopfMap
open import Cubical.Homotopy.HopfInvariant.Brunerie
open import Cubical.Homotopy.Whitehead
open import Cubical.Homotopy.Group.Base hiding (π)
open import Cubical.Homotopy.Group.Pi3S2
open import Cubical.Homotopy.Group.Pi4S3.BrunerieNumber
open import Cubical.Homotopy.Group.Pi4S3.DirectProof as DirectProof
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Group.Instances.Bool
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.GroupPath
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.Instances.Int
open import Cubical.Algebra.Group.Instances.IntMod
open import Cubical.Algebra.Group.ZAction
-- Homotopy groups (shifted version of π'Gr to get nicer numbering)
π : ℕ → Pointed₀ → Group₀
π n X = π'Gr (predℕ n) X
-- Nicer notation for the spheres (as pointed types)
𝕊² 𝕊³ : Pointed₀
𝕊² = S₊∙ 2
𝕊³ = S₊∙ 3
-- The Brunerie number; defined in Cubical.Homotopy.Group.Pi4S3.BrunerieNumber
-- as "abs (HopfInvariant-π' 0 ([ (∣ idfun∙ _ ∣₂ , ∣ idfun∙ _ ∣₂) ]×))"
β : ℕ
β = Brunerie
-- The connection to π₄(S³) is then also proved in the BrunerieNumber
-- file following Corollary 3.4.5 in Guillaume Brunerie's PhD thesis.
βSpec : GroupEquiv (π 4 𝕊³) (ℤGroup/ β)
βSpec = BrunerieIso
-- Ideally one could prove that β is 2 by normalization, but this does
-- not seem to terminate before we run out of memory. To try normalize
-- this use "C-u C-c C-n β≡2" (which normalizes the term, ignoring
-- abstract's). So instead we prove this by hand as in the second half
-- of Guillaume's thesis.
β≡2 : β ≡ 2
β≡2 = Brunerie≡2
-- This involves a lot of theory, for example that π₃(S²) ≃ ℤGroup where
-- the underlying map is induced by the Hopf invariant (which involves
-- the cup product on cohomology).
_ : GroupEquiv (π 3 𝕊²) ℤGroup
_ = hopfInvariantEquiv
-- Which is a consequence of the fact that π₃(S²) is generated by the
-- Hopf map.
_ : gen₁-by (π 3 𝕊²) ∣ HopfMap ∣₂
_ = π₂S³-gen-by-HopfMap
-- etc. For more details see the proof of "Brunerie≡2".
-- Combining all of this gives us the desired equivalence of groups:
π₄S³≃ℤ/2ℤ : GroupEquiv (π 4 𝕊³) (ℤGroup/ 2)
π₄S³≃ℤ/2ℤ = subst (GroupEquiv (π 4 𝕊³)) (cong ℤGroup/_ β≡2) βSpec
-- By the SIP this induces an equality of groups:
π₄S³≡ℤ/2ℤ : π 4 𝕊³ ≡ ℤGroup/ 2
π₄S³≡ℤ/2ℤ = GroupPath _ _ .fst π₄S³≃ℤ/2ℤ
-- As a sanity check we also establish the equality with Bool:
π₄S³≡Bool : π 4 𝕊³ ≡ BoolGroup
π₄S³≡Bool = π₄S³≡ℤ/2ℤ ∙ GroupPath _ _ .fst (GroupIso→GroupEquiv ℤGroup/2≅Bool)
-- We also have a much more direct proof in Cubical.Homotopy.Group.Pi4S3.DirectProof,
-- not relying on any of the more advanced constructions in chapters
-- 4-6 in Brunerie's thesis (but still using chapters 1-3 for the
-- construction). For details see the header of that file.
π₄S³≃ℤ/2ℤ-direct : GroupEquiv (π 4 𝕊³) (ℤGroup/ 2)
π₄S³≃ℤ/2ℤ-direct = DirectProof.BrunerieGroupEquiv
-- This direct proof allows us to define a much simplified version of
-- the Brunerie number:
β' : ℤ
β' = fst DirectProof.computer η₃'
-- This number computes definitionally to -2 in a few seconds!
β'≡-2 : β' ≡ -2
β'≡-2 = refl
-- As a sanity check we have proved (commented as typechecking is quite slow):
-- β'Spec : GroupEquiv (π 4 𝕊³) (ℤGroup/ abs β')
-- β'Spec = DirectProof.BrunerieGroupEquiv'
-- Combining all of this gives us the desired equivalence of groups by
-- computation as conjectured in Brunerie's thesis:
π₄S³≃ℤ/2ℤ-computation : GroupEquiv (π 4 𝕊³) (ℤGroup/ 2)
π₄S³≃ℤ/2ℤ-computation = DirectProof.BrunerieGroupEquiv''
|
lemma valid_path_polynomial_function: fixes p :: "real \<Rightarrow> 'a::euclidean_space" shows "polynomial_function p \<Longrightarrow> valid_path p" |
[STATEMENT]
lemma bifunctor_proj_snd_ArrMap_vdomain[cat_cs_simps]:
assumes "\<SS> : \<AA> \<times>\<^sub>C \<BB> \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<DD>" and "a \<in>\<^sub>\<circ> \<AA>\<lparr>Obj\<rparr>"
shows "\<D>\<^sub>\<circ> ((\<SS>\<^bsub>\<AA>,\<BB>\<^esub>(a,-)\<^sub>C\<^sub>F)\<lparr>ArrMap\<rparr>) = \<BB>\<lparr>Arr\<rparr>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<D>\<^sub>\<circ> ((\<SS>\<^bsub>\<AA>,\<BB>\<^esub>(a,-)\<^sub>C\<^sub>F)\<lparr>ArrMap\<rparr>) = \<BB>\<lparr>Arr\<rparr>
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<D>\<^sub>\<circ> ((\<SS>\<^bsub>\<AA>,\<BB>\<^esub>(a,-)\<^sub>C\<^sub>F)\<lparr>ArrMap\<rparr>) = \<BB>\<lparr>Arr\<rparr>
[PROOF STEP]
interpret \<SS>: is_functor \<alpha> \<BB> \<DD> \<open>\<SS>\<^bsub>\<AA>,\<BB>\<^esub>(a,-)\<^sub>C\<^sub>F\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<SS>\<^bsub>\<AA>,\<BB>\<^esub>(a,-)\<^sub>C\<^sub>F : \<BB> \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<DD>
[PROOF STEP]
by (rule bifunctor_proj_snd_is_functor[OF assms])
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<D>\<^sub>\<circ> ((\<SS>\<^bsub>\<AA>,\<BB>\<^esub>(a,-)\<^sub>C\<^sub>F)\<lparr>ArrMap\<rparr>) = \<BB>\<lparr>Arr\<rparr>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<D>\<^sub>\<circ> ((\<SS>\<^bsub>\<AA>,\<BB>\<^esub>(a,-)\<^sub>C\<^sub>F)\<lparr>ArrMap\<rparr>) = \<BB>\<lparr>Arr\<rparr>
[PROOF STEP]
by (rule \<SS>.cf_ArrMap_vdomain)
[PROOF STATE]
proof (state)
this:
\<D>\<^sub>\<circ> ((\<SS>\<^bsub>\<AA>,\<BB>\<^esub>(a,-)\<^sub>C\<^sub>F)\<lparr>ArrMap\<rparr>) = \<BB>\<lparr>Arr\<rparr>
goal:
No subgoals!
[PROOF STEP]
qed |
module InteractMithril
using WebIO: node, Node, instanceof, props, children, Scope, JSString, @js_str, onimport,
setobservable!, onjs, WebIO
using Widgets: AbstractWidget, Widget, Widgets
using Observables: on, Observable, AbstractObservable, ObservablePair, Observables
using Dates
using Colors: Colorant, hex
import JSON
export mithril, MithrilComponent
include("component.jl")
include("input.jl")
include("slider.jl")
include("optioninput.jl")
end # module
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.