text
stringlengths 0
3.34M
|
---|
/-
Copyright (c) 2022 Eric Rodriguez. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Rodriguez, Eric Wieser
-/
import data.list.chain
/-!
# Destuttering of Lists
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file proves theorems about `list.destutter` (in `data.list.defs`), which greedily removes all
non-related items that are adjacent in a list, e.g. `[2, 2, 3, 3, 2].destutter (≠) = [2, 3, 2]`.
Note that we make no guarantees of being the longest sublist with this property; e.g.,
`[123, 1, 2, 5, 543, 1000].destutter (<) = [123, 543, 1000]`, but a longer ascending chain could be
`[1, 2, 5, 543, 1000]`.
## Main statements
* `list.destutter_sublist`: `l.destutter` is a sublist of `l`.
* `list.destutter_is_chain'`: `l.destutter` satisfies `chain' R`.
* Analogies of these theorems for `list.destutter'`, which is the `destutter` equivalent of `chain`.
## Tags
adjacent, chain, duplicates, remove, list, stutter, destutter
-/
variables {α : Type*} (l : list α) (R : α → α → Prop) [decidable_rel R] {a b : α}
namespace list
@[simp] lemma destutter'_nil : destutter' R a [] = [a] := rfl
lemma destutter'_cons :
(b :: l).destutter' R a = if R a b then a :: destutter' R b l else destutter' R a l := rfl
variables {R}
@[simp] lemma destutter'_cons_pos (h : R b a) :
(a :: l).destutter' R b = b :: l.destutter' R a :=
by rw [destutter', if_pos h]
@[simp] lemma destutter'_cons_neg (h : ¬ R b a) :
(a :: l).destutter' R b = l.destutter' R b :=
by rw [destutter', if_neg h]
variables (R)
@[simp] lemma destutter'_singleton : [b].destutter' R a = if R a b then [a, b] else [a] :=
by split_ifs; simp! [h]
lemma destutter'_sublist (a) : l.destutter' R a <+ a :: l :=
begin
induction l with b l hl generalizing a,
{ simp },
rw destutter',
split_ifs,
{ exact sublist.cons2 _ _ _ (hl b) },
{ exact (hl a).trans ((l.sublist_cons b).cons_cons a) }
end
lemma mem_destutter' (a) : a ∈ l.destutter' R a :=
begin
induction l with b l hl,
{ simp },
rw destutter',
split_ifs,
{ simp },
{ assumption }
end
lemma destutter'_is_chain : ∀ l : list α, ∀ {a b}, R a b → (l.destutter' R b).chain R a
| [] a b h := chain_singleton.mpr h
| (c :: l) a b h :=
begin
rw destutter',
split_ifs with hbc,
{ rw chain_cons,
exact ⟨h, destutter'_is_chain l hbc⟩ },
{ exact destutter'_is_chain l h },
end
lemma destutter'_is_chain' (a) : (l.destutter' R a).chain' R :=
begin
induction l with b l hl generalizing a,
{ simp },
rw destutter',
split_ifs,
{ exact destutter'_is_chain R l h },
{ exact hl a },
end
lemma destutter'_of_chain (h : l.chain R a) : l.destutter' R a = a :: l :=
begin
induction l with b l hb generalizing a,
{ simp },
obtain ⟨h, hc⟩ := chain_cons.mp h,
rw [l.destutter'_cons_pos h, hb hc]
end
@[simp] lemma destutter'_eq_self_iff (a) : l.destutter' R a = a :: l ↔ l.chain R a :=
⟨λ h, by { rw [←chain', ←h], exact l.destutter'_is_chain' R a }, destutter'_of_chain _ _⟩
lemma destutter'_ne_nil : l.destutter' R a ≠ [] :=
ne_nil_of_mem $ l.mem_destutter' R a
@[simp] lemma destutter_nil : ([] : list α).destutter R = [] := rfl
lemma destutter_cons' : (a :: l).destutter R = destutter' R a l := rfl
lemma destutter_cons_cons : (a :: b :: l).destutter R =
if R a b then a :: destutter' R b l else destutter' R a l := rfl
@[simp] lemma destutter_singleton : destutter R [a] = [a] := rfl
@[simp] lemma destutter_pair : destutter R [a, b] = if R a b then [a, b] else [a] :=
destutter_cons_cons _ R
lemma destutter_is_chain' : ∀ (l : list α), (l.destutter R).chain' R
| [] := list.chain'_nil
| (h :: l) := l.destutter'_is_chain' R h
lemma destutter_of_chain' : ∀ (l : list α), l.chain' R → l.destutter R = l
| [] h := rfl
| (a :: l) h := l.destutter'_of_chain _ h
@[simp] lemma destutter_eq_self_iff : ∀ (l : list α), l.destutter R = l ↔ l.chain' R
| [] := by simp
| (a :: l) := l.destutter'_eq_self_iff R a
lemma destutter_idem : (l.destutter R).destutter R = l.destutter R :=
destutter_of_chain' R _ $ l.destutter_is_chain' R
@[simp] lemma destutter_eq_nil : ∀ {l : list α}, destutter R l = [] ↔ l = []
| [] := iff.rfl
| (a :: l) := ⟨λ h, absurd h $ l.destutter'_ne_nil R, λ h, match h with end⟩
end list
|
/-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import category_theory.limits.shapes.pullbacks
import category_theory.limits.shapes.kernel_pair
import category_theory.limits.shapes.comm_sq
/-!
# The diagonal object of a morphism.
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
We provide various API and isomorphisms considering the diagonal object `Δ_{Y/X} := pullback f f`
of a morphism `f : X ⟶ Y`.
-/
open category_theory
noncomputable theory
namespace category_theory.limits
variables {C : Type*} [category C] {X Y Z : C}
namespace pullback
section diagonal
variables (f : X ⟶ Y) [has_pullback f f]
/-- The diagonal object of a morphism `f : X ⟶ Y` is `Δ_{X/Y} := pullback f f`. -/
abbreviation diagonal_obj : C := pullback f f
/-- The diagonal morphism `X ⟶ Δ_{X/Y}` for a morphism `f : X ⟶ Y`. -/
def diagonal : X ⟶ diagonal_obj f :=
pullback.lift (𝟙 _) (𝟙 _) rfl
@[simp, reassoc] lemma diagonal_fst : diagonal f ≫ pullback.fst = 𝟙 _ :=
pullback.lift_fst _ _ _
@[simp, reassoc] lemma diagonal_snd : diagonal f ≫ pullback.snd = 𝟙 _ :=
pullback.lift_snd _ _ _
instance : is_split_mono (diagonal f) :=
⟨⟨⟨pullback.fst, diagonal_fst f⟩⟩⟩
instance : is_split_epi (pullback.fst : pullback f f ⟶ X) :=
⟨⟨⟨diagonal f, diagonal_fst f⟩⟩⟩
instance : is_split_epi (pullback.snd : pullback f f ⟶ X) :=
⟨⟨⟨diagonal f, diagonal_snd f⟩⟩⟩
instance [mono f] : is_iso (diagonal f) :=
begin
rw (is_iso.inv_eq_of_inv_hom_id (diagonal_fst f)).symm,
apply_instance
end
/-- The two projections `Δ_{X/Y} ⟶ X` form a kernel pair for `f : X ⟶ Y`. -/
lemma diagonal_is_kernel_pair :
is_kernel_pair f (pullback.fst : diagonal_obj f ⟶ _) pullback.snd :=
is_pullback.of_has_pullback f f
end diagonal
end pullback
variable [has_pullbacks C]
open pullback
section
variables {U V₁ V₂ : C} (f : X ⟶ Y) (i : U ⟶ Y)
variables (i₁ : V₁ ⟶ pullback f i) (i₂ : V₂ ⟶ pullback f i)
@[simp, reassoc]
lemma pullback_diagonal_map_snd_fst_fst :
(pullback.snd : pullback (diagonal f) (map (i₁ ≫ snd) (i₂ ≫ snd) f f (i₁ ≫ fst) (i₂ ≫ fst) i
(by simp [condition]) (by simp [condition])) ⟶ _) ≫ fst ≫ i₁ ≫ fst = pullback.fst :=
begin
conv_rhs { rw ← category.comp_id pullback.fst },
rw [← diagonal_fst f, pullback.condition_assoc, pullback.lift_fst]
end
@[simp, reassoc]
lemma pullback_diagonal_map_snd_snd_fst :
(pullback.snd : pullback (diagonal f) (map (i₁ ≫ snd) (i₂ ≫ snd) f f (i₁ ≫ fst) (i₂ ≫ fst) i
(by simp [condition]) (by simp [condition])) ⟶ _) ≫ snd ≫ i₂ ≫ fst = pullback.fst :=
begin
conv_rhs { rw ← category.comp_id pullback.fst },
rw [← diagonal_snd f, pullback.condition_assoc, pullback.lift_snd]
end
variable [has_pullback i₁ i₂]
/--
This iso witnesses the fact that
given `f : X ⟶ Y`, `i : U ⟶ Y`, and `i₁ : V₁ ⟶ X ×[Y] U`, `i₂ : V₂ ⟶ X ×[Y] U`, the diagram
V₁ ×[X ×[Y] U] V₂ ⟶ V₁ ×[U] V₂
| |
| |
↓ ↓
X ⟶ X ×[Y] X
is a pullback square.
Also see `pullback_fst_map_snd_is_pullback`.
-/
def pullback_diagonal_map_iso :
pullback (diagonal f) (map (i₁ ≫ snd) (i₂ ≫ snd) f f (i₁ ≫ fst) (i₂ ≫ fst) i
(by simp [condition]) (by simp [condition])) ≅ pullback i₁ i₂ :=
{ hom := pullback.lift (pullback.snd ≫ pullback.fst) (pullback.snd ≫ pullback.snd)
begin
ext; simp only [category.assoc, pullback.condition, pullback_diagonal_map_snd_fst_fst,
pullback_diagonal_map_snd_snd_fst],
end,
inv := pullback.lift (pullback.fst ≫ i₁ ≫ pullback.fst) (pullback.map _ _ _ _ (𝟙 _) (𝟙 _)
pullback.snd (category.id_comp _).symm (category.id_comp _).symm)
begin
ext; simp only [diagonal_fst, diagonal_snd, category.comp_id, pullback.condition_assoc,
category.assoc, lift_fst, lift_fst_assoc, lift_snd, lift_snd_assoc],
end,
hom_inv_id' := by ext; simp only [category.id_comp, category.assoc, lift_fst_assoc,
pullback_diagonal_map_snd_fst_fst, lift_fst, lift_snd, category.comp_id],
inv_hom_id' := by ext; simp }
@[simp, reassoc]
lemma pullback_diagonal_map_iso_hom_fst :
(pullback_diagonal_map_iso f i i₁ i₂).hom ≫ pullback.fst = pullback.snd ≫ pullback.fst :=
by { delta pullback_diagonal_map_iso, simp }
@[simp, reassoc]
lemma pullback_diagonal_map_iso_hom_snd :
(pullback_diagonal_map_iso f i i₁ i₂).hom ≫ pullback.snd = pullback.snd ≫ pullback.snd :=
by { delta pullback_diagonal_map_iso, simp }
@[simp, reassoc]
lemma pullback_diagonal_map_iso_inv_fst :
(pullback_diagonal_map_iso f i i₁ i₂).inv ≫ pullback.fst = pullback.fst ≫ i₁ ≫ pullback.fst :=
by { delta pullback_diagonal_map_iso, simp }
@[simp, reassoc]
lemma pullback_diagonal_map_iso_inv_snd_fst :
(pullback_diagonal_map_iso f i i₁ i₂).inv ≫ pullback.snd ≫ pullback.fst = pullback.fst :=
by { delta pullback_diagonal_map_iso, simp }
@[simp, reassoc]
lemma pullback_diagonal_map_iso_inv_snd_snd :
(pullback_diagonal_map_iso f i i₁ i₂).inv ≫ pullback.snd ≫ pullback.snd = pullback.snd :=
by { delta pullback_diagonal_map_iso, simp }
lemma pullback_fst_map_snd_is_pullback :
is_pullback
(fst ≫ i₁ ≫ fst)
(map i₁ i₂ (i₁ ≫ snd) (i₂ ≫ snd) _ _ _ (category.id_comp _).symm (category.id_comp _).symm)
(diagonal f)
(map (i₁ ≫ snd) (i₂ ≫ snd) f f (i₁ ≫ fst) (i₂ ≫ fst) i
(by simp [condition]) (by simp [condition])) :=
is_pullback.of_iso_pullback ⟨by ext; simp [condition_assoc]⟩
(pullback_diagonal_map_iso f i i₁ i₂).symm (pullback_diagonal_map_iso_inv_fst f i i₁ i₂)
(by ext1; simp)
end
section
variables {S T : C} (f : X ⟶ T) (g : Y ⟶ T) (i : T ⟶ S)
variables [has_pullback i i] [has_pullback f g] [has_pullback (f ≫ i) (g ≫ i)]
variable [has_pullback (diagonal i) (pullback.map (f ≫ i) (g ≫ i) i i f g (𝟙 _)
(category.comp_id _) (category.comp_id _))]
/--
This iso witnesses the fact that
given `f : X ⟶ T`, `g : Y ⟶ T`, and `i : T ⟶ S`, the diagram
X ×ₜ Y ⟶ X ×ₛ Y
| |
| |
↓ ↓
T ⟶ T ×ₛ T
is a pullback square.
Also see `pullback_map_diagonal_is_pullback`.
-/
def pullback_diagonal_map_id_iso :
pullback (diagonal i) (pullback.map (f ≫ i) (g ≫ i) i i f g (𝟙 _)
(category.comp_id _) (category.comp_id _)) ≅ pullback f g :=
begin
refine (as_iso $ pullback.map _ _ _ _ (𝟙 _) (pullback.congr_hom _ _).hom (𝟙 _) _ _) ≪≫
pullback_diagonal_map_iso i (𝟙 _) (f ≫ inv pullback.fst) (g ≫ inv pullback.fst) ≪≫
(as_iso $ pullback.map _ _ _ _ (𝟙 _) (𝟙 _) pullback.fst _ _),
{ rw [← category.comp_id pullback.snd, ← condition, category.assoc, is_iso.inv_hom_id_assoc] },
{ rw [← category.comp_id pullback.snd, ← condition, category.assoc, is_iso.inv_hom_id_assoc] },
{ rw [category.comp_id, category.id_comp] },
{ ext; simp },
{ apply_instance },
{ rw [category.assoc, category.id_comp, is_iso.inv_hom_id, category.comp_id] },
{ rw [category.assoc, category.id_comp, is_iso.inv_hom_id, category.comp_id] },
{ apply_instance },
end
@[simp, reassoc]
lemma pullback_diagonal_map_id_iso_hom_fst :
(pullback_diagonal_map_id_iso f g i).hom ≫ pullback.fst = pullback.snd ≫ pullback.fst :=
by { delta pullback_diagonal_map_id_iso, simp }
@[simp, reassoc]
lemma pullback_diagonal_map_id_iso_hom_snd :
(pullback_diagonal_map_id_iso f g i).hom ≫ pullback.snd = pullback.snd ≫ pullback.snd :=
by { delta pullback_diagonal_map_id_iso, simp }
@[simp, reassoc]
lemma pullback_diagonal_map_id_iso_inv_fst :
(pullback_diagonal_map_id_iso f g i).inv ≫ pullback.fst = pullback.fst ≫ f :=
begin
rw [iso.inv_comp_eq, ← category.comp_id pullback.fst, ← diagonal_fst i, pullback.condition_assoc],
simp,
end
@[simp, reassoc]
lemma pullback_diagonal_map_id_iso_inv_snd_fst :
(pullback_diagonal_map_id_iso f g i).inv ≫ pullback.snd ≫ pullback.fst = pullback.fst :=
by { rw iso.inv_comp_eq, simp }
@[simp, reassoc]
lemma pullback_diagonal_map_id_iso_inv_snd_snd :
(pullback_diagonal_map_id_iso f g i).inv ≫ pullback.snd ≫ pullback.snd = pullback.snd :=
by { rw iso.inv_comp_eq, simp }
lemma pullback.diagonal_comp (f : X ⟶ Y) (g : Y ⟶ Z) [has_pullback f f] [has_pullback g g]
[has_pullback (f ≫ g) (f ≫ g)] :
diagonal (f ≫ g) = diagonal f ≫ (pullback_diagonal_map_id_iso f f g).inv ≫ pullback.snd :=
by ext; simp
lemma pullback_map_diagonal_is_pullback : is_pullback (pullback.fst ≫ f)
(pullback.map f g (f ≫ i) (g ≫ i) _ _ i (category.id_comp _).symm (category.id_comp _).symm)
(diagonal i)
(pullback.map (f ≫ i) (g ≫ i) i i f g (𝟙 _) (category.comp_id _) (category.comp_id _)) :=
begin
apply is_pullback.of_iso_pullback _ (pullback_diagonal_map_id_iso f g i).symm,
{ simp },
{ ext; simp },
{ constructor, ext; simp [condition] },
end
/-- The diagonal object of `X ×[Z] Y ⟶ X` is isomorphic to `Δ_{Y/Z} ×[Z] X`. -/
def diagonal_obj_pullback_fst_iso {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :
diagonal_obj (pullback.fst : pullback f g ⟶ X) ≅
pullback (pullback.snd ≫ g : diagonal_obj g ⟶ Z) f :=
pullback_right_pullback_fst_iso _ _ _ ≪≫ pullback.congr_hom pullback.condition rfl ≪≫
pullback_assoc _ _ _ _ ≪≫ pullback_symmetry _ _ ≪≫ pullback.congr_hom pullback.condition rfl
@[simp, reassoc] lemma diagonal_obj_pullback_fst_iso_hom_fst_fst {X Y Z : C} (f : X ⟶ Z)
(g : Y ⟶ Z) :
(diagonal_obj_pullback_fst_iso f g).hom ≫ pullback.fst ≫ pullback.fst =
pullback.fst ≫ pullback.snd :=
by { delta diagonal_obj_pullback_fst_iso, simp }
@[simp, reassoc] lemma diagonal_obj_pullback_fst_iso_hom_fst_snd {X Y Z : C} (f : X ⟶ Z)
(g : Y ⟶ Z) :
(diagonal_obj_pullback_fst_iso f g).hom ≫ pullback.fst ≫ pullback.snd =
pullback.snd ≫ pullback.snd :=
by { delta diagonal_obj_pullback_fst_iso, simp }
@[simp, reassoc] lemma diagonal_obj_pullback_fst_iso_hom_snd {X Y Z : C} (f : X ⟶ Z)
(g : Y ⟶ Z) :
(diagonal_obj_pullback_fst_iso f g).hom ≫ pullback.snd = pullback.fst ≫ pullback.fst :=
by { delta diagonal_obj_pullback_fst_iso, simp }
@[simp, reassoc] lemma diagonal_obj_pullback_fst_iso_inv_fst_fst {X Y Z : C} (f : X ⟶ Z)
(g : Y ⟶ Z) :
(diagonal_obj_pullback_fst_iso f g).inv ≫ pullback.fst ≫ pullback.fst =
pullback.snd :=
by { delta diagonal_obj_pullback_fst_iso, simp }
@[simp, reassoc] lemma diagonal_obj_pullback_fst_iso_inv_fst_snd {X Y Z : C} (f : X ⟶ Z)
(g : Y ⟶ Z) :
(diagonal_obj_pullback_fst_iso f g).inv ≫ pullback.fst ≫ pullback.snd =
pullback.fst ≫ pullback.fst :=
by { delta diagonal_obj_pullback_fst_iso, simp }
@[simp, reassoc] lemma diagonal_obj_pullback_fst_iso_inv_snd_fst {X Y Z : C} (f : X ⟶ Z)
(g : Y ⟶ Z) :
(diagonal_obj_pullback_fst_iso f g).inv ≫ pullback.snd ≫ pullback.fst = pullback.snd :=
by { delta diagonal_obj_pullback_fst_iso, simp }
@[simp, reassoc]
lemma diagonal_pullback_fst {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :
diagonal (pullback.fst : pullback f g ⟶ _) =
(pullback_symmetry _ _).hom ≫ ((base_change f).map
(over.hom_mk (diagonal g) (by simp) : over.mk g ⟶ over.mk (pullback.snd ≫ g))).left ≫
(diagonal_obj_pullback_fst_iso f g).inv :=
by ext; simp
end
/--
Given the following diagram with `S ⟶ S'` a monomorphism,
X ⟶ X'
↘ ↘
S ⟶ S'
↗ ↗
Y ⟶ Y'
This iso witnesses the fact that
X ×[S] Y ⟶ (X' ×[S'] Y') ×[Y'] Y
| |
| |
↓ ↓
(X' ×[S'] Y') ×[X'] X ⟶ X' ×[S'] Y'
is a pullback square. The diagonal map of this square is `pullback.map`.
Also see `pullback_lift_map_is_pullback`.
-/
@[simps]
def pullback_fst_fst_iso {X Y S X' Y' S' : C} (f : X ⟶ S) (g : Y ⟶ S) (f' : X' ⟶ S')
(g' : Y' ⟶ S') (i₁ : X ⟶ X') (i₂ : Y ⟶ Y') (i₃ : S ⟶ S') (e₁ : f ≫ i₃ = i₁ ≫ f')
(e₂ : g ≫ i₃ = i₂ ≫ g') [mono i₃] :
pullback (pullback.fst : pullback (pullback.fst : pullback f' g' ⟶ _) i₁ ⟶ _)
(pullback.fst : pullback (pullback.snd : pullback f' g' ⟶ _) i₂ ⟶ _) ≅ pullback f g :=
{ hom := pullback.lift (pullback.fst ≫ pullback.snd) (pullback.snd ≫ pullback.snd)
begin
rw [← cancel_mono i₃, category.assoc, category.assoc, category.assoc, category.assoc, e₁, e₂,
← pullback.condition_assoc, pullback.condition_assoc, pullback.condition,
pullback.condition_assoc]
end,
inv := pullback.lift
(pullback.lift (pullback.map _ _ _ _ _ _ _ e₁ e₂) pullback.fst (pullback.lift_fst _ _ _))
(pullback.lift (pullback.map _ _ _ _ _ _ _ e₁ e₂) pullback.snd (pullback.lift_snd _ _ _))
begin
rw [pullback.lift_fst, pullback.lift_fst]
end,
hom_inv_id' := by ext; simp only [category.assoc, category.id_comp, lift_fst, lift_snd,
lift_fst_assoc, lift_snd_assoc, condition, ← condition_assoc],
inv_hom_id' := by ext; simp only [category.assoc, category.id_comp, lift_fst, lift_snd,
lift_fst_assoc, lift_snd_assoc], }
lemma pullback_map_eq_pullback_fst_fst_iso_inv {X Y S X' Y' S' : C} (f : X ⟶ S) (g : Y ⟶ S)
(f' : X' ⟶ S')
(g' : Y' ⟶ S') (i₁ : X ⟶ X') (i₂ : Y ⟶ Y') (i₃ : S ⟶ S') (e₁ : f ≫ i₃ = i₁ ≫ f')
(e₂ : g ≫ i₃ = i₂ ≫ g') [mono i₃] :
pullback.map f g f' g' i₁ i₂ i₃ e₁ e₂ =
(pullback_fst_fst_iso f g f' g' i₁ i₂ i₃ e₁ e₂).inv ≫ pullback.snd ≫ pullback.fst :=
begin
ext; simp only [category.assoc, category.id_comp, lift_fst, lift_snd, lift_fst_assoc,
lift_snd_assoc, pullback_fst_fst_iso_inv, ← pullback.condition, ← pullback.condition_assoc],
end
lemma pullback_lift_map_is_pullback {X Y S X' Y' S' : C} (f : X ⟶ S) (g : Y ⟶ S) (f' : X' ⟶ S')
(g' : Y' ⟶ S') (i₁ : X ⟶ X') (i₂ : Y ⟶ Y') (i₃ : S ⟶ S') (e₁ : f ≫ i₃ = i₁ ≫ f')
(e₂ : g ≫ i₃ = i₂ ≫ g') [mono i₃] :
is_pullback
(pullback.lift (pullback.map f g f' g' i₁ i₂ i₃ e₁ e₂) fst (lift_fst _ _ _))
(pullback.lift (pullback.map f g f' g' i₁ i₂ i₃ e₁ e₂) snd (lift_snd _ _ _))
pullback.fst pullback.fst :=
is_pullback.of_iso_pullback ⟨by rw [lift_fst, lift_fst]⟩
(pullback_fst_fst_iso f g f' g' i₁ i₂ i₃ e₁ e₂).symm (by simp) (by simp)
end category_theory.limits
|
Formal statement is: lemma greaterThanLessThan_eq_ball: fixes a b::real shows "{a <..< b} = ball ((a + b)/2) ((b - a)/2)" Informal statement is: The open interval $(a, b)$ is equal to the open ball of radius $(b - a)/2$ centered at $(a + b)/2$. |
(* Title: HOL/Auth/n_german_lemma_inv__18_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__18_on_rules imports n_german_lemma_on_inv__18
begin
section{*All lemmas on causal relation between inv__18*}
lemma lemma_inv__18_on_rules:
assumes b1: "r \<in> rules N" and b2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__18 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__18) 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__18) 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__18) 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__18) 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__18) 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__18) 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__18) 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__18) 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__18) 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__18) 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__18) 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__18) 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__18) done
}
ultimately show "invHoldForRule s f r (invariants N)"
by satx
qed
end
|
Require Import Logic.lib.Coqlib.
Require Import Logic.GeneralLogic.Base.
Require Import Logic.GeneralLogic.ProofTheory.BasicSequentCalculus.
Require Import Logic.MinimunLogic.Syntax.
Require Import Logic.MinimunLogic.ProofTheory.Minimun.
Require Import Logic.MinimunLogic.ProofTheory.RewriteClass.
Require Import Logic.PropositionalLogic.Syntax.
Require Import Logic.PropositionalLogic.ProofTheory.Intuitionistic.
Require Import Logic.PropositionalLogic.ProofTheory.DeMorgan.
Require Import Logic.PropositionalLogic.ProofTheory.GodelDummett.
Require Import Logic.PropositionalLogic.ProofTheory.Classical.
Require Import Logic.PropositionalLogic.ProofTheory.RewriteClass.
Require Import Logic.SeparationLogic.Syntax.
Require Import Logic.SeparationLogic.ProofTheory.SeparationLogic.
Require Import Logic.SeparationLogic.ProofTheory.RewriteClass.
Local Open Scope logic_base.
Local Open Scope syntax.
Import PropositionalLanguageNotation.
Import SeparationLogicNotation.
Section WandFrame.
Context {L: Language}
{minL: MinimunLanguage L}
{pL: PropositionalLanguage L}
{sL: SeparationLanguage L}
{Gamma: ProofTheory L}
{minAX: MinimunAxiomatization L Gamma}
{ipGamma: IntuitionisticPropositionalLogic L Gamma}
{sGamma: SeparationLogic L Gamma}.
Lemma wand_frame_intros: forall (x y: expr),
|-- x --> (y -* x * y).
Proof.
intros.
apply wand_sepcon_adjoint.
apply provable_impp_refl.
Qed.
Lemma wand_frame_elim: forall (x y: expr),
|-- x * (x -* y) --> y.
Proof.
intros.
apply provable_wand_sepcon_modus_ponens2.
Qed.
Lemma wand_frame_ver: forall (x y z: expr),
|-- (x -* y) * (y -* z) --> (x -* z).
Proof.
intros.
rewrite <- wand_sepcon_adjoint.
rewrite sepcon_comm, sepcon_assoc.
rewrite !wand_frame_elim.
apply provable_impp_refl.
Qed.
Lemma wand_frame_hor: forall (x1 y1 x2 y2: expr),
|-- (x1 -* y1) * (x2 -* y2) --> (x1 * x2 -* y1 * y2).
Proof.
intros.
rewrite <- wand_sepcon_adjoint.
rewrite sepcon_assoc, (sepcon_comm _ x1), sepcon_assoc.
rewrite wand_frame_elim.
rewrite <- sepcon_assoc, (sepcon_comm _ x2).
rewrite wand_frame_elim.
apply provable_impp_refl.
Qed.
End WandFrame.
|
[STATEMENT]
lemma less_eq_imp_interp_subseteq_Interp: "C \<le> D \<Longrightarrow> interp C \<subseteq> Interp D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. C \<le> D \<Longrightarrow> interp C \<subseteq> Interp D
[PROOF STEP]
unfolding Interp_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. C \<le> D \<Longrightarrow> interp C \<subseteq> interp D \<union> production D
[PROOF STEP]
using less_eq_imp_interp_subseteq_interp
[PROOF STATE]
proof (prove)
using this:
?C \<le> ?D \<Longrightarrow> interp ?C \<subseteq> interp ?D
goal (1 subgoal):
1. C \<le> D \<Longrightarrow> interp C \<subseteq> interp D \<union> production D
[PROOF STEP]
by blast |
<b>Q1. Consider a Support Vector Machine and the following training data from two categories:</b>
\begin{align}
w1 & = {(1, 1)^T, (2, 2)^T, (2, 0)^T} \\
w2 & = {(0, 0)^T, (1, 0)^T, (0, 1)^T} \\
\end{align}
<b>a. Construct the optimal hyperplane, and the optimal hypermargin. </b><br>
<b>Answer 1.a.</b> <br> Let's assume that w1 is the positively labelled data points and w2 be the negatively labelled data points. We want to find optimal hyperplane such that it effectively discriminates between two classes. <br>
```python
import numpy as np
import matplotlib.pyplot as plt
w11a = np.array([[1, 2, 2],[1, 2, 0]])
w21a = np.array([[0, 1, 0],[0, 0, 1]])
fig1a = plt.figure()
fig1a = plt.figure(figsize=(7,5))
ax1a = fig1a.add_subplot(111)
ax1a.scatter(w11a.T[:,0], w11a.T[:,1])
ax1a.scatter(w21a.T[:,0], w21a.T[:,1])
```
<matplotlib.collections.PathCollection at 0x7f4e682ab390>
Since the data points are linearly separable, we can use Linear SVM i.e mapping function is Identity function. <br>
It's obvious from the above plot that there are three support vectors, <br>
\begin{align}
s1 & = (1, 0)^T \\
s2 & = (0, 1)^T \\
s3 & = (1, 1)^T
\end{align}
We augment the support vectors with 1 as the bias input. Hence, <br>
\begin{align}
s1' & = (1, 0, 1)^T \\
s2' & = (0, 1, 1)^T \\
s3' & = (1, 1, 1)^T
\end{align}
We need to find values for αi such that, <br>
\begin{align}
α1Φ(s1)·Φ(s1) +α2Φ(s2)·Φ(s1) +α3Φ(s3)·Φ(s1) = -1 \\
α1Φ(s1)·Φ(s2) +α2Φ(s2)·Φ(s2) +α3Φ(s3)·Φ(s2) = -1 \\
α1Φ(s1)·Φ(s3) +α2Φ(s2)·Φ(s3) +α3Φ(s3)·Φ(s3) = +1
\end{align}
<br>Since Φ = 1, the above equations reduces to, <br>
\begin{align}
α1 s1'.s1' + α2 s2'.s1' + α3 s3'.s1' = -1 \\
α1 s1'.s2' + α2 s2'.s2' + α3 s3'.s2' = -1 \\
α1 s1'.s3' + α2 s2'.s3' + α3 s3'.s3' = +1
\end{align}
<br>Substituting the values for s1', s2' and s3', we get, <br>
\begin{align}
α1 (1, 0, 1)^T.(1, 0, 1)^T + α2 (0, 1, 1)^T.(1, 0, 1)^T + α3 (1, 1, 1)^T.(1, 0, 1)^T = -1 \\
α1 (1, 0, 1)^T.(0, 1, 1)^T + α2 (0, 1, 1)^T.(0, 1, 1)^T + α3 (1, 1, 1)^T.(0, 1, 1)^T = -1 \\
α1 (1, 0, 1)^T.(1, 1, 1)^T + α2 (0, 1, 1)^T.(1, 1, 1)^T + α3 (1, 1, 1)^T.(1, 1, 1)^T = +1
\end{align}
After computing the dot products, the above equations result in,
\begin{align}
2α1 + α2 + 2α3 = -1 \\
α1 + 2α2 + 2α3 = -1 \\
2α1 + 2α2 + 3α3 = +1
\end{align}
<br>Solving the above set of linear equations, we will get the value for α1, α2 and α3. <br>
\begin{align}
α1 & = -5 \\
α2 & = -5 \\
α3 & = +7
\end{align}
Now,
\begin{equation*}
w' = \sum_{i} αi si'
\end{equation*}
\begin{align}
w' = -5 (1, 0, 1)^T + -5 (0, 1, 1)^T + 7 (1, 1, 1)^T \\
w' = (2, 2, -3)^T
\end{align}
The vectors were augmented with a bias, so equating the last entry in w' with the hyperplane offset b. The separating equation, <br>
\begin{align}
w^T x + b = 0 \\
(1, 1)x + (-3) = 0
\end{align}
<br> Solving for x, we get, <br>
\begin{align}
x = (3/2, 3/2)^T
\end{align}
<br>Plotting x gives the optimal hyperplane for the data points.<br>
```python
fig1a = plt.figure()
fig1a = plt.figure(figsize=(7,5))
ax1a = fig1a.add_subplot(111)
ax1a.scatter(w11a.T[:,0], w11a.T[:,1])
ax1a.scatter(w21a.T[:,0], w21a.T[:,1])
ax1a.plot([0, 3/2],[3/2, 0])
ax1a.plot([0, 1],[1, 0])
ax1a.plot([0, 2],[2, 0])
```
The optimal margin can be calculated by,
\begin{align}
d = \frac{1}{||w||} \\
d = \frac{1}{\frac{8}{\sqrt{8}}} \\
d = \frac{\sqrt{2}}{4}
\end{align}
<b>b. What are the hyper parameters involved in SVM.</b><br>
<b>Answer 1.b</b><br>
Support vector classifier is used for discriminating between classes, it tries to find the optimal hyperplane by maximizing the distance between the hyperplane and the data points.<br>
There are several hyperparameters for Support vector machines, some of them are:
<ul>
<li>Kernel - Kernel hyperparameter defines the type of hyperplane which is used to discriminate between the classes. There are several type of Kernels, some of them are, <ul><li>Linear kernel</li><li>Poly kernel</li><li>Sigmoid kernel</li><li>RBF (radial basis function) kernel</li><li>Non-linear kernel</li></ul></li>
<li>gamma - gamma hyperparameter is used for non-linear hyperplanes, the higher the value for gamma the more it tries to fit in the training data.</li>
<li>C - C hyperparameter is used to control the tradeoff between smooth decision boundary and classifying the training points accurately.</li>
<li>degree - degree hyperparameter is used in conjunction with Poly kernel, it is used to specify the degree of polynomial to be used to discriminate between the classes.</li>
</ul>
<b>c. Construct the solution in dual space by finding the Lagrange undetermined multipliers αi.</b><br>
<b>Answer 1.c</b><br>
We need to maximize L(α),
\begin{align}
L(α) = \sum_{i=1}^{n} αi - 1/2 \sum_{i,j}^{n} αi yi αj yj xi^t xj \\
with constraint \sum_{i} αi yi = 0 \\
0 <= αi <= c
\end{align} <br>
Solved above!
<b>Q2. Write your own code to implement a support vector machine (SVM) to classify the above given data.</b><br>
<b>Answer 2</b>
```python
x = np.array([[-3.0, -2.9, 1],[0.5, 8.7, 1],
[2.9, 2.1, 1],[-0.1, 5.2, 1],
[-4.0, 2.2, 1],[-1.3, 3.7, 1],
[-3.4, 6.2, 1],[-4.1, 3.4, 1],
[-5.1, 1.6, 1],[1.9, 5.1, 1],
[-2.0, -8.4, 1],[-8.9, 0.2, 1],
[-4.2, -7.7, 1],[-8.5, -3.2, 1],
[-6.7, -4.0, 1],[-0.5, -9.2, 1],
[-5.3, -6.7, 1],[-8.7, -6.4, 1],
[-7.1, -9.7, 1],[-8.0, -6.3, 1]
])
y = ([+1,+1,+1,+1,+1,+1,+1,+1,+1,+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1])
print(x)
print(y)
```
[[-3. -2.9 1. ]
[ 0.5 8.7 1. ]
[ 2.9 2.1 1. ]
[-0.1 5.2 1. ]
[-4. 2.2 1. ]
[-1.3 3.7 1. ]
[-3.4 6.2 1. ]
[-4.1 3.4 1. ]
[-5.1 1.6 1. ]
[ 1.9 5.1 1. ]
[-2. -8.4 1. ]
[-8.9 0.2 1. ]
[-4.2 -7.7 1. ]
[-8.5 -3.2 1. ]
[-6.7 -4. 1. ]
[-0.5 -9.2 1. ]
[-5.3 -6.7 1. ]
[-8.7 -6.4 1. ]
[-7.1 -9.7 1. ]
[-8. -6.3 1. ]]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
```python
for val, inp in enumerate(x):
if y[val] == 1:
plt.scatter(inp[0], inp[1], marker='^', c='yellow', edgecolor='black')
else:
plt.scatter(inp[0], inp[1], marker='o', c='green', edgecolor='black')
```
```python
def svm_function(x,y):
w = np.zeros(len(x[0]))
l_rate = 0.3
epoch = 100000 #100000
for e in range(epoch):
for i, val in enumerate(x):
val1 = np.dot(x[i], w)
if (y[i]*val1 < 1):
w = w + l_rate * ((y[i]*x[i]) - (2*(1/epoch)*w))
else:
w = w + l_rate * (-2*(1/epoch)*w)
return w
```
```python
w = svm_function(x, y)
print(w)
```
[0.75929164 0.66233337 5.32078152]
```python
a = -w[2] / w[0]
b = -w[2] / w[1]
print(a)
print(b)
na = (-w[2]-1) / w[0]
nb = (-w[2]-1) / w[1]
print(na)
print(nb)
pa = (-w[2]+1) / w[0]
pb = (-w[2]+1) / w[1]
print(pa)
print(pb)
```
-7.0075597637536715
-8.033388864917443
-8.32457677331757
-9.543202571289624
-5.690542754189773
-6.523575158545262
```python
for val, inp in enumerate(x):
if y[val] == 1:
plt.scatter(inp[0], inp[1], marker='^', c='yellow', edgecolor='black')
else:
plt.scatter(inp[0], inp[1], marker='o', c='green', edgecolor='black')
plt.plot([0, a],[b, 0], label='Optimal Hyperplane')
plt.plot([0, na],[nb, 0])
plt.plot([0, pa],[pb, 0])
```
```python
```
|
Formal statement is: lemma convergent_imp_bounded: fixes S :: "nat \<Rightarrow> 'a::metric_space" shows "(S \<longlongrightarrow> l) sequentially \<Longrightarrow> bounded (range S)" Informal statement is: If a sequence converges, then it is bounded. |
(*
(C) Copyright 2010, COQTAIL team
Project Info: http://sourceforge.net/projects/coqtail/
This library 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 library 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 Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
*)
(** Common definitions of real functions sequences. *)
Require Import Cbase.
Require Import Cfunctions.
Require Import Csequence.
Require Import Canalysis_def.
Declare Scope CFseq_scope.
Delimit Scope CFseq_scope with Cseq_scope.
Local Open Scope C_scope.
Local Open Scope CFseq_scope.
Implicit Type n : nat.
Implicit Type fn gn : nat -> C -> C.
Implicit Type f g : C -> C.
(** * Morphism of functions on R -> R to sequences. *)
Definition CFseq_plus fn gn n := (fn n + gn n)%F.
Definition CFseq_mult fn gn n := (fn n * gn n)%F.
Definition CFseq_opp fn n := (fun x => Copp (fn n x))%F.
Definition CFseq_inv fn n := (fun x => Cinv (fn n x))%F.
Infix "+" := CFseq_plus : CFseq_scope.
Infix "*" := CFseq_mult : CFseq_scope.
Notation "- u" := (CFseq_opp u) : CFseq_scope.
Notation "/ u" := (CFseq_inv u) : CFseq_scope.
Definition CFseq_minus fn gn n := (fn n - gn n)%F.
Definition CFseq_div fn gn n := (fn n / gn n)%F.
Infix "-" := CFseq_minus : CFseq_scope.
Infix "/" := CFseq_div : CFseq_scope.
(** * Convergence of functions sequences. *)
Definition CFseq_cv fn f := forall x, Cseq_cv (fun n => fn n x) (f x).
Definition CFseq_cv_boule fn f (c : C) (r : posreal) := forall x, Boule c r x -> Cseq_cv (fun n => fn n x) (f x).
Definition CFseq_cvu fn f (x : C) (r : posreal) := forall eps : R, 0 < eps ->
exists N : nat, forall n (y : C), (N <= n)%nat -> Boule x r y ->
C_dist (fn n y) (f y) < eps.
Definition CFpartial_sum (fn : nat -> C) N := sum_f_C0 fn N.
|
FUNCTION:NAME
main:place
-- @@stderr --
dtrace: script 'test/unittest/usdt/tst.args-alt.d' matched 4 probes
|
[STATEMENT]
lemma triangle_set_graph_edge_ss:
assumes "uedges Gnew \<subseteq> uedges G"
assumes "uverts Gnew = uverts G"
shows "triangle_set Gnew \<subseteq> triangle_set G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. triangle_set Gnew \<subseteq> triangle_set G
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
uedges Gnew \<subseteq> uedges G
uverts Gnew = uverts G
goal (1 subgoal):
1. triangle_set Gnew \<subseteq> triangle_set G
[PROOF STEP]
unfolding triangle_set_def
[PROOF STATE]
proof (prove)
using this:
uedges Gnew \<subseteq> uedges G
uverts Gnew = uverts G
goal (1 subgoal):
1. {{x, y, z} |x y z. triangle_in_graph x y z Gnew} \<subseteq> {{x, y, z} |x y z. triangle_in_graph x y z G}
[PROOF STEP]
by (blast intro: triangle_in_graph_ss) |
module Main
import Data.Vect
vtake : (n:Nat) -> Vect (n+m) a -> Vect n a
vtake Z v = Nil
vtake (S k) (x::xs) = x :: (vtake k xs)
main : IO ()
-- BOOM!
main = putStrLn (show (vtake 5 (1 :: 2 :: 3 :: 4 :: 5 :: Nil)))
|
{- Example by Andrew Pitts, 2016-05-23 -}
{-# OPTIONS --rewriting --cubical-compatible #-}
open import Agda.Builtin.Equality public
infix 6 I─_
postulate
𝕀 : Set
O : 𝕀
I : 𝕀
I─_ : 𝕀 → 𝕀
{-# BUILTIN REWRITE _≡_ #-}
postulate
I─O≡I : I─ O ≡ I
{-# REWRITE I─O≡I #-}
data Pth (A : Set) : A → A → Set where
path : (f : 𝕀 → A) → Pth A (f O) (f I)
infix 6 _at_
_at_ : {A : Set}{x y : A} → Pth A x y → 𝕀 → A
path f at i = f i
record Path (A : Set)(x y : A) : Set where
field
pth : Pth A x y
feq : pth at O ≡ x
seq : pth at I ≡ y
open Path public
{-# REWRITE feq #-}
{-# REWRITE seq #-}
infix 6 _′_
_′_ : {A : Set}{x y : A} → Path A x y → 𝕀 → A
p ′ i = pth p at i
fun2path : {A : Set}(f : 𝕀 → A) → Path A (f O) (f I)
pth (fun2path f) = path f
feq (fun2path f) = refl
seq (fun2path f) = refl
inv : {A : Set}{x y : A} → Path A x y → Path A y x
inv p = fun2path (λ i → p ′ (I─ i))
|
//////////////////////////////////////////////////////////////////////////////////////////////
/// \file GemanMcClureLossFunc.hpp
///
/// \author Sean Anderson, ASRL
//////////////////////////////////////////////////////////////////////////////////////////////
#ifndef STEAM_GM_LOSS_FUNCTION_HPP
#define STEAM_GM_LOSS_FUNCTION_HPP
#include <Eigen/Core>
#include <steam/problem/lossfunc/LossFunctionBase.hpp>
namespace steam {
//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Geman-McClure loss function class
//////////////////////////////////////////////////////////////////////////////////////////////
class GemanMcClureLossFunc : public LossFunctionBase
{
public:
/// Convenience typedefs
typedef std::shared_ptr<GemanMcClureLossFunc> Ptr;
typedef std::shared_ptr<const GemanMcClureLossFunc> ConstPtr;
//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Constructor -- k is the `threshold' based on number of std devs (1-3 is typical)
//////////////////////////////////////////////////////////////////////////////////////////////
GemanMcClureLossFunc(double k) : k2_(k*k) {}
//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Cost function (basic evaluation of the loss function)
//////////////////////////////////////////////////////////////////////////////////////////////
virtual double cost(double whitened_error_norm) const;
//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Weight for iteratively reweighted least-squares (influence function div. by error)
//////////////////////////////////////////////////////////////////////////////////////////////
virtual double weight(double whitened_error_norm) const;
private:
//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief GM constant
//////////////////////////////////////////////////////////////////////////////////////////////
double k2_;
};
} // steam
#endif // STEAM_GM_LOSS_FUNCTION_HPP
|
lemma box_subset_cbox: fixes a :: "'a::euclidean_space" shows "box a b \<subseteq> cbox a b" |
Require Import Arith.
Inductive even : nat -> Prop :=
| O_even : even 0
| plus_2_even : forall n:nat, even n -> even (S (S n)).
Hint Constructors even.
Fixpoint mult2 (n:nat) : nat :=
match n with
| O => 0
| S p => S (S (mult2 p))
end.
Lemma mult2_even : forall n:nat, even (mult2 n).
Proof.
induction n; simpl; auto.
Qed.
Theorem sum_even : forall n p:nat, even n -> even p -> even (n + p).
Proof.
intros n p Heven_n; induction Heven_n; simpl; auto.
Qed.
Hint Resolve sum_even.
Lemma square_even : forall n:nat, even n -> even (n * n).
Proof.
intros n Hn; elim Hn; simpl; auto.
intros n0 H0 H1; rewrite (mult_comm n0 (S (S n0))).
right; simpl;apply sum_even; auto.
Qed.
Lemma even_mult2 : forall n:nat, even n -> (exists p, n = mult2 p).
Proof.
induction 1.
- exists 0; reflexivity.
- destruct IHeven as [p Hp]; exists (S p); simpl; now rewrite Hp.
Qed.
|
import init.data.list.lemmas
variable {α : Type}
open list
#check subset_of_cons_subset
structure sublist (α : Type) (ll : list α) :=
(l : list α)
(p: l ⊆ ll)
def filter (p : α → Prop) [decidable_pred p] : list α → list α
| [] := []
| (a::l) := if p a then a :: filter l else filter l
def filter_sublist (p : α → Prop) [decidable_pred p] : (Π l: list α, sublist α l)
| l : [] := sorry
end
lemma shrink_sublist_type {l ll : list α} (s : l ⊆ ll) (f : sublist α ll -> sublist α ll) : sublist α l -> sublist α l :=
(λ x,
sorry)
private def filter_sublist_helper (p : α → Prop) [decidable_pred p] (ll : list α) : sublist α ll -> sublist α ll
| ⟨[], s⟩ := ⟨[], s⟩
| ⟨a::l, s⟩ := begin
let smol : sublist α l := ⟨l, list.subset.refl l⟩,
let h : l ⊆ ll := subset_of_cons_subset s,
have r := shrink_sublist_type h filter_sublist_helper,
have rest := (r smol),
have f := if p a then begin
let l := a :: rest.l,
end
end
-- if p a then a :: (filter_sublist_helper ⟨l, list.subset_of_cons_subset s⟩) else sorry
|
using Pkg
using Test
@testset "Pkg UUID" begin
project_filename = joinpath(dirname(@__DIR__), "Project.toml")
project = Pkg.TOML.parsefile(project_filename)
uuid = project["uuid"]
correct_uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
@test uuid == correct_uuid
end
|
module Quantities.Screen
import Quantities.Core
import Quantities.SIBaseQuantities
import Quantities.ImperialUnits
import Quantities.SIBaseUnits
%default total
%access public export
ScreenLength : Dimension
ScreenLength = MkDimension "ScreenLength"
Pixel : ElemUnit ScreenLength
Pixel = MkElemUnit "px" 1
Px : ElemUnit ScreenLength
Px = Pixel
ScreenArea : Quantity
ScreenArea = ScreenLength ^ 2
ScreenEstate : Quantity
ScreenEstate = ScreenArea
ScreenResolution : Quantity
ScreenResolution = ScreenLength </> Length
PixelPerCentimetre : ElemUnit ScreenResolution
PixelPerCentimetre = < one "ppcm" equals 1 (Pixel <//> Centimetre) >
PixelPerCentimeter : ElemUnit ScreenResolution
PixelPerCentimeter = PixelPerCentimetre
Ppcm : ElemUnit ScreenResolution
Ppcm = PixelPerCentimetre
PixelPerInch : ElemUnit ScreenResolution
PixelPerInch = < one "ppi" equals 1 (Pixel <//> Inch) >
Ppi : ElemUnit ScreenResolution
Ppi = PixelPerInch
|
module JS.Callback
import JS.Util
||| Interface for converting Idris functions to
||| an external callback type.
|||
||| @cb external callback type (for instance `EventListener`
||| @fun Idris function type
public export
interface Callback cb fun | cb where
callback : fun -> JSIO cb
|
State Before: α : Type u_1
β : Type ?u.24500
γ : Type ?u.24503
δ : Type ?u.24506
r : α → α → Prop
a b c d : α
⊢ ReflTransGen r a b ↔ b = a ∨ TransGen r a b State After: case refine'_1
α : Type u_1
β : Type ?u.24500
γ : Type ?u.24503
δ : Type ?u.24506
r : α → α → Prop
a b c d : α
h : ReflTransGen r a b
⊢ b = a ∨ TransGen r a b
case refine'_2
α : Type u_1
β : Type ?u.24500
γ : Type ?u.24503
δ : Type ?u.24506
r : α → α → Prop
a b c d : α
h : b = a ∨ TransGen r a b
⊢ ReflTransGen r a b Tactic: refine' ⟨fun h ↦ _, fun h ↦ _⟩ State Before: case refine'_1
α : Type u_1
β : Type ?u.24500
γ : Type ?u.24503
δ : Type ?u.24506
r : α → α → Prop
a b c d : α
h : ReflTransGen r a b
⊢ b = a ∨ TransGen r a b State After: case refine'_1.refl
α : Type u_1
β : Type ?u.24500
γ : Type ?u.24503
δ : Type ?u.24506
r : α → α → Prop
a c d : α
⊢ a = a ∨ TransGen r a a
case refine'_1.tail
α : Type u_1
β : Type ?u.24500
γ : Type ?u.24503
δ : Type ?u.24506
r : α → α → Prop
a b c✝ d c : α
hac : ReflTransGen r a c
hcb : r c b
⊢ b = a ∨ TransGen r a b Tactic: cases' h with c _ hac hcb State Before: case refine'_1.refl
α : Type u_1
β : Type ?u.24500
γ : Type ?u.24503
δ : Type ?u.24506
r : α → α → Prop
a c d : α
⊢ a = a ∨ TransGen r a a State After: no goals Tactic: exact Or.inl rfl State Before: case refine'_1.tail
α : Type u_1
β : Type ?u.24500
γ : Type ?u.24503
δ : Type ?u.24506
r : α → α → Prop
a b c✝ d c : α
hac : ReflTransGen r a c
hcb : r c b
⊢ b = a ∨ TransGen r a b State After: no goals Tactic: exact Or.inr (TransGen.tail' hac hcb) State Before: case refine'_2
α : Type u_1
β : Type ?u.24500
γ : Type ?u.24503
δ : Type ?u.24506
r : α → α → Prop
a b c d : α
h : b = a ∨ TransGen r a b
⊢ ReflTransGen r a b State After: case refine'_2.inl
α : Type u_1
β : Type ?u.24500
γ : Type ?u.24503
δ : Type ?u.24506
r : α → α → Prop
b c d : α
⊢ ReflTransGen r b b
case refine'_2.inr
α : Type u_1
β : Type ?u.24500
γ : Type ?u.24503
δ : Type ?u.24506
r : α → α → Prop
a b c d : α
h : TransGen r a b
⊢ ReflTransGen r a b Tactic: rcases h with (rfl | h) State Before: case refine'_2.inl
α : Type u_1
β : Type ?u.24500
γ : Type ?u.24503
δ : Type ?u.24506
r : α → α → Prop
b c d : α
⊢ ReflTransGen r b b State After: no goals Tactic: rfl State Before: case refine'_2.inr
α : Type u_1
β : Type ?u.24500
γ : Type ?u.24503
δ : Type ?u.24506
r : α → α → Prop
a b c d : α
h : TransGen r a b
⊢ ReflTransGen r a b State After: no goals Tactic: exact h.to_reflTransGen |
import ring_theory.graded_algebra.basic
import ring_theory.graded_algebra.homogeneous_ideal
namespace graded_algebra
variables {R A : Type*}
variables [comm_semiring R] [semiring A] [algebra R A]
variables (𝓐 : ℕ → submodule R A) [graded_algebra 𝓐]
open_locale direct_sum big_operators
def nat_to_int : ℤ → submodule R A
| (int.of_nat n) := 𝓐 n
| (int.neg_succ_of_nat n) := ⊥
namespace nat_to_int
instance (n : ℕ) : unique (nat_to_int 𝓐 (int.neg_succ_of_nat n)) :=
{ default := 0,
uniq := λ ⟨a, ha⟩, begin
change a ∈ ⊥ at ha,
simpa only [submodule.mem_bot, submodule.mk_eq_zero] using ha,
end }
lemma supr_eq_top : (⨆ i, nat_to_int 𝓐 i) = ⊤ :=
have m : ∀ x, x ∈ supr 𝓐,
from λ x, (graded_algebra.is_internal 𝓐).submodule_supr_eq_top.symm ▸ submodule.mem_top,
begin
ext a,
split; intros ha,
{ trivial },
{ refine submodule.supr_induction 𝓐 (m a) (λ n x hx, _) _ _,
{ rw submodule.supr_eq_span,
apply submodule.subset_span,
exact set.mem_Union.mpr ⟨int.of_nat n, hx⟩, },
{ rw submodule.supr_eq_span,
apply submodule.subset_span,
exact set.mem_Union.mpr ⟨0, submodule.zero_mem _⟩, },
{ intros x y hx hy,
exact submodule.add_mem _ hx hy, }, },
end
lemma one_mem' : (1 : A) ∈ (nat_to_int 𝓐 0) :=
begin
have triv : (0 : ℤ) = int.of_nat 0 := rfl,
rw triv,
change _ ∈ 𝓐 0,
exact set_like.graded_monoid.one_mem,
end
lemma mul_mem' ⦃i j : ℤ⦄ {gi gj : A}
(hi : gi ∈ nat_to_int 𝓐 i) (hj : gj ∈ nat_to_int 𝓐 j) :
gi * gj ∈ nat_to_int 𝓐 (i + j) :=
begin
cases i; cases j,
{ change _ ∈ 𝓐 i at hi,
change _ ∈ 𝓐 j at hj,
change _ ∈ 𝓐 (i + j),
exact set_like.graded_monoid.mul_mem hi hj },
{ change _ ∈ ⊥ at hj,
rw [submodule.mem_bot] at hj,
subst hj,
rw [mul_zero],
exact submodule.zero_mem _ },
{ change _ ∈ ⊥ at hi,
rw [submodule.mem_bot] at hi,
subst hi,
rw [zero_mul],
exact submodule.zero_mem _ },
{ change _ ∈ ⊥ at hi,
rw [submodule.mem_bot] at hi,
subst hi,
rw [zero_mul],
exact submodule.zero_mem _ },
end
def add_hom_nat_to_int : (⨁ i, 𝓐 i) →+ (⨁ i, nat_to_int 𝓐 i) :=
{ to_fun := direct_sum.to_add_monoid begin
rintro n,
refine { to_fun := _, map_zero' := _, map_add' := _ },
{ intros a, refine direct_sum.of _ (int.of_nat n) _, exact a, },
{ rw [map_zero], },
{ intros a b, rw [map_add], },
end,
map_zero' := by rw [map_zero],
map_add' := λ x y, begin
dsimp only,
rw [map_add],
end }
def add_hom_int_to_nat : (⨁ i, nat_to_int 𝓐 i) →+ (⨁ i, 𝓐 i) :=
{ to_fun := direct_sum.to_add_monoid $ begin
rintro n,
cases n,
{ refine { to_fun := _, map_zero' := _, map_add' := _},
{ exact λ x, direct_sum.of _ n x, },
{ rw map_zero },
{ intros x y,
simp [map_add] }, },
{ exact 0 },
end,
map_zero' := by simp only [map_zero],
map_add' := λ x y, by simp [map_add] }
def equiv_nat_to_int : (⨁ i, 𝓐 i) ≃+ (⨁ i, nat_to_int 𝓐 i) :=
{ to_fun := add_hom_nat_to_int 𝓐,
inv_fun := add_hom_int_to_nat 𝓐,
left_inv := λ x, begin
induction x using direct_sum.induction_on with i x x y hx hy,
{ simp [map_zero] },
{ simp only [add_hom_nat_to_int, add_hom_int_to_nat, add_monoid_hom.mk_coe, direct_sum.to_add_monoid_of],
ext1 j,
by_cases ineq1 : i = j,
{ subst ineq1,
rw [direct_sum.of_eq_same, direct_sum.of_eq_same], },
{ rw [direct_sum.of_eq_of_ne, direct_sum.of_eq_of_ne];
exact ineq1 }, },
{ rw [map_add, map_add, hx, hy], },
end,
right_inv := λ x, begin
induction x using direct_sum.induction_on with i x x y hx hy,
{ simp [map_zero] },
{ cases i,
{ simp only [add_hom_nat_to_int, add_hom_int_to_nat, add_monoid_hom.mk_coe, direct_sum.to_add_monoid_of],
erw [direct_sum.to_add_monoid_of], },
{ simp only [add_hom_int_to_nat, add_monoid_hom.mk_coe, direct_sum.to_add_monoid_of, add_monoid_hom.zero_apply, map_zero],
have : x = 0,
{ have := x.2,
change _ ∈ ⊥ at this,
rw submodule.mem_bot at this,
ext, },
subst this,
rw [map_zero], }, },
{ rw [map_add, map_add, hx, hy], },
end,
map_add' := λ x y, by simp [map_add] }
def decompose_to_int : A →+ ⨁ (i : ℤ), nat_to_int 𝓐 i :=
(equiv_nat_to_int 𝓐).to_add_monoid_hom.comp (graded_algebra.decompose 𝓐).to_add_equiv.to_add_monoid_hom
lemma decompose_to_int_apply_of_nat (i : ℕ) (a : A) :
decompose_to_int 𝓐 a (int.of_nat i) = graded_algebra.decompose 𝓐 a i :=
have m : ∀ x, x ∈ supr 𝓐,
from λ x, (graded_algebra.is_internal 𝓐).submodule_supr_eq_top.symm ▸ submodule.mem_top,
begin
refine submodule.supr_induction 𝓐 (m a) _ _ _,
{ intros j x hj,
rw [graded_algebra.decompose_of_mem 𝓐 hj, decompose_to_int],
simp only [add_monoid_hom.coe_comp, function.comp_app],
erw [graded_algebra.decompose_of_mem 𝓐 hj],
simp only [equiv_nat_to_int, add_hom_nat_to_int, add_monoid_hom.mk_coe],
erw [direct_sum.to_add_monoid_of],
by_cases ineq : i = j,
{ subst ineq,
erw [direct_sum.of_eq_same, direct_sum.of_eq_same], },
{ erw [direct_sum.of_eq_of_ne _ _ _ _ (ne.symm ineq), direct_sum.of_eq_of_ne],
contrapose! ineq,
subst ineq, }, },
{ simp only [map_zero, direct_sum.zero_apply], },
{ intros x y hx hy,
rw [map_add, map_add, direct_sum.add_apply, direct_sum.add_apply, hx, hy], },
end
lemma decompose_to_int_apply_of_neg_succ_of_nat (i : ℕ) (a : A) :
decompose_to_int 𝓐 a (int.neg_succ_of_nat i) = 0 := by simp only [eq_iff_true_of_subsingleton]
lemma decompose_to_int_of_aux (a : ⨁ i, 𝓐 i) :
decompose_to_int 𝓐 (direct_sum.coe_add_monoid_hom 𝓐 a) = add_hom_nat_to_int 𝓐 a :=
begin
apply_fun (equiv_nat_to_int 𝓐).symm using (equiv_nat_to_int 𝓐).symm.injective,
change _ = (equiv_nat_to_int 𝓐).symm ((equiv_nat_to_int 𝓐) a),
simp only [decompose_to_int, add_monoid_hom.coe_comp, add_equiv.coe_to_add_monoid_hom, add_equiv.symm_apply_apply],
convert graded_algebra.left_inv a,
end
lemma decompose_to_int_of_mem (i : ℤ) (a : A) (h : a ∈ nat_to_int 𝓐 i) :
decompose_to_int 𝓐 a = direct_sum.of (λ i, nat_to_int 𝓐 i) i ⟨a, h⟩ :=
begin
have eq1 : (direct_sum.coe_add_monoid_hom 𝓐) (graded_algebra.decompose 𝓐 a) = a := graded_algebra.right_inv a,
have : decompose_to_int 𝓐 a = decompose_to_int 𝓐 ((direct_sum.coe_add_monoid_hom 𝓐) (graded_algebra.decompose 𝓐 a)),
{ rw eq1 },
rw [this, decompose_to_int_of_aux],
rw [add_hom_nat_to_int],
simp only [add_monoid_hom.mk_coe],
rw direct_sum.coe_add_monoid_hom at eq1,
cases i,
{ change _ ∈ 𝓐 _ at h,
rw graded_algebra.decompose_of_mem 𝓐 h,
erw direct_sum.to_add_monoid_of, },
{ change a ∈ ⊥ at h,
rw submodule.mem_bot at h,
simp only [h, map_zero],
generalize_proofs h2,
have : (⟨0, h2⟩ : {x // x ∈ nat_to_int 𝓐 -[1+ i]}) = 0,
{ ext, refl, },
rw this,
simp only [map_zero], },
end
lemma left_inverse' : function.left_inverse (decompose_to_int 𝓐)
(direct_sum.coe_add_monoid_hom (nat_to_int 𝓐)) := λ x,
begin
induction x using direct_sum.induction_on with i x x y hx hy,
{ rw [map_zero],
ext1 i,
simp only [decompose, function.comp_app, map_zero, direct_sum.zero_apply], },
{ erw [direct_sum.coe_add_monoid_hom_of],
cases i,
{ ext1 j,
by_cases ineq : int.of_nat i = j,
{ subst ineq,
erw [decompose_to_int_apply_of_nat, graded_algebra.decompose_of_mem 𝓐 x.2, direct_sum.of_eq_same, direct_sum.of_eq_same],
ext,
refl, },
{ cases j,
{ have ineq2 : i ≠ j,
{ contrapose! ineq, exact ineq },
erw [decompose_to_int_apply_of_nat, direct_sum.of_eq_of_ne _ _ _ _ ineq],
have := graded_algebra.decompose_of_mem_ne 𝓐 x.2 ineq2,
simpa only [subtype.val_eq_coe, decompose_coe, submodule.coe_eq_zero] using this, },
{ simp only [eq_iff_true_of_subsingleton], }, }, },
{ have := x.2,
change _ ∈ ⊥ at this,
rw submodule.mem_bot at this,
have eqz : x = 0,
{ ext, },
change ↑x = _ at this,
rw [this, eqz],
simp only [map_zero], }, },
{ rw [map_add, map_add, hx, hy], },
end
lemma right_inverse' : function.right_inverse (decompose_to_int 𝓐)
(direct_sum.coe_add_monoid_hom (nat_to_int 𝓐)) := λ a,
have m : ∀ x, x ∈ supr (nat_to_int 𝓐), from λ x, by rw [supr_eq_top 𝓐]; trivial,
begin
refine submodule.supr_induction (nat_to_int 𝓐) (m a) _ _ _,
{ intros i a hi,
rw [decompose_to_int_of_mem 𝓐 i a hi, direct_sum.coe_add_monoid_hom_of],
refl, },
{ simp [map_zero] },
{ intros x y hx hy,
rw [map_add, map_add, hx, hy], },
end
section
variable [Π (i : ℕ) (x : 𝓐 i), decidable (x ≠ 0)]
instance : graded_algebra (nat_to_int 𝓐) :=
{ one_mem := nat_to_int.one_mem' _,
mul_mem := nat_to_int.mul_mem' _,
decompose' := nat_to_int.decompose_to_int _,
left_inv := nat_to_int.left_inverse' _,
right_inv := nat_to_int.right_inverse' _, }
lemma decompose_eq (a : A) :
graded_algebra.decompose (nat_to_int 𝓐) a = decompose_to_int 𝓐 a := rfl
lemma ideal.is_homogeneous_int_iff_is_homogeneous_nat (I : ideal A) :
I.is_homogeneous (nat_to_int 𝓐) ↔ I.is_homogeneous 𝓐 :=
{ mp := λ hI i a ha, begin
specialize hI (int.of_nat i) ha,
convert hI,
rw [decompose_eq, decompose_to_int_apply_of_nat],
end,
mpr := λ hI i a ha, begin
cases i,
{ specialize hI i ha,
convert hI,
rw [decompose_eq, decompose_to_int_apply_of_nat], },
{ rw [decompose_eq, decompose_to_int_apply_of_neg_succ_of_nat, submodule.coe_zero],
exact submodule.zero_mem _, },
end }
end
end nat_to_int
end graded_algebra |
!*==csytf2.f90 processed by SPAG 7.51RB at 20:08 on 3 Mar 2022
!> \brief \b CSYTF2 computes the factorization of a real symmetric indefinite matrix, using the diagonal pivoting method (unblocked algorithm).
!
! =========== DOCUMENTATION ===========
!
! Online html documentation available at
! http://www.netlib.org/lapack/explore-html/
!
!> \htmlonly
!> Download CSYTF2 + dependencies
!> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/csytf2.f">
!> [TGZ]</a>
!> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/csytf2.f">
!> [ZIP]</a>
!> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/csytf2.f">
!> [TXT]</a>
!> \endhtmlonly
!
! Definition:
! ===========
!
! SUBROUTINE CSYTF2( UPLO, N, A, LDA, IPIV, INFO )
!
! .. Scalar Arguments ..
! CHARACTER UPLO
! INTEGER INFO, LDA, N
! ..
! .. Array Arguments ..
! INTEGER IPIV( * )
! COMPLEX A( LDA, * )
! ..
!
!
!> \par Purpose:
! =============
!>
!> \verbatim
!>
!> CSYTF2 computes the factorization of a complex symmetric matrix A
!> using the Bunch-Kaufman diagonal pivoting method:
!>
!> A = U*D*U**T or A = L*D*L**T
!>
!> where U (or L) is a product of permutation and unit upper (lower)
!> triangular matrices, U**T is the transpose of U, and D is symmetric and
!> block diagonal with 1-by-1 and 2-by-2 diagonal blocks.
!>
!> This is the unblocked version of the algorithm, calling Level 2 BLAS.
!> \endverbatim
!
! Arguments:
! ==========
!
!> \param[in] UPLO
!> \verbatim
!> UPLO is CHARACTER*1
!> Specifies whether the upper or lower triangular part of the
!> symmetric matrix A is stored:
!> = 'U': Upper triangular
!> = 'L': Lower triangular
!> \endverbatim
!>
!> \param[in] N
!> \verbatim
!> N is INTEGER
!> The order of the matrix A. N >= 0.
!> \endverbatim
!>
!> \param[in,out] A
!> \verbatim
!> A is COMPLEX array, dimension (LDA,N)
!> On entry, the symmetric matrix A. If UPLO = 'U', the leading
!> n-by-n upper triangular part of A contains the upper
!> triangular part of the matrix A, and the strictly lower
!> triangular part of A is not referenced. If UPLO = 'L', the
!> leading n-by-n lower triangular part of A contains the lower
!> triangular part of the matrix A, and the strictly upper
!> triangular part of A is not referenced.
!>
!> On exit, the block diagonal matrix D and the multipliers used
!> to obtain the factor U or L (see below for further details).
!> \endverbatim
!>
!> \param[in] LDA
!> \verbatim
!> LDA is INTEGER
!> The leading dimension of the array A. LDA >= max(1,N).
!> \endverbatim
!>
!> \param[out] IPIV
!> \verbatim
!> IPIV is INTEGER array, dimension (N)
!> Details of the interchanges and the block structure of D.
!>
!> If UPLO = 'U':
!> If IPIV(k) > 0, then rows and columns k and IPIV(k) were
!> interchanged and D(k,k) is a 1-by-1 diagonal block.
!>
!> If IPIV(k) = IPIV(k-1) < 0, then rows and columns
!> k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)
!> is a 2-by-2 diagonal block.
!>
!> If UPLO = 'L':
!> If IPIV(k) > 0, then rows and columns k and IPIV(k) were
!> interchanged and D(k,k) is a 1-by-1 diagonal block.
!>
!> If IPIV(k) = IPIV(k+1) < 0, then rows and columns
!> k+1 and -IPIV(k) were interchanged and D(k:k+1,k:k+1)
!> is a 2-by-2 diagonal block.
!> \endverbatim
!>
!> \param[out] INFO
!> \verbatim
!> INFO is INTEGER
!> = 0: successful exit
!> < 0: if INFO = -k, the k-th argument had an illegal value
!> > 0: if INFO = k, D(k,k) is exactly zero. The factorization
!> has been completed, but the block diagonal matrix D is
!> exactly singular, and division by zero will occur if it
!> is used to solve a system of equations.
!> \endverbatim
!
! Authors:
! ========
!
!> \author Univ. of Tennessee
!> \author Univ. of California Berkeley
!> \author Univ. of Colorado Denver
!> \author NAG Ltd.
!
!> \date December 2016
!
!> \ingroup complexSYcomputational
!
!> \par Further Details:
! =====================
!>
!> \verbatim
!>
!> If UPLO = 'U', then A = U*D*U**T, where
!> U = P(n)*U(n)* ... *P(k)U(k)* ...,
!> i.e., U is a product of terms P(k)*U(k), where k decreases from n to
!> 1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
!> and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as
!> defined by IPIV(k), and U(k) is a unit upper triangular matrix, such
!> that if the diagonal block D(k) is of order s (s = 1 or 2), then
!>
!> ( I v 0 ) k-s
!> U(k) = ( 0 I 0 ) s
!> ( 0 0 I ) n-k
!> k-s s n-k
!>
!> If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k).
!> If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k),
!> and A(k,k), and v overwrites A(1:k-2,k-1:k).
!>
!> If UPLO = 'L', then A = L*D*L**T, where
!> L = P(1)*L(1)* ... *P(k)*L(k)* ...,
!> i.e., L is a product of terms P(k)*L(k), where k increases from 1 to
!> n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
!> and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as
!> defined by IPIV(k), and L(k) is a unit lower triangular matrix, such
!> that if the diagonal block D(k) is of order s (s = 1 or 2), then
!>
!> ( I 0 0 ) k-1
!> L(k) = ( 0 I 0 ) s
!> ( 0 v I ) n-k-s+1
!> k-1 s n-k-s+1
!>
!> If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k).
!> If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k),
!> and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1).
!> \endverbatim
!
!> \par Contributors:
! ==================
!>
!> \verbatim
!>
!> 09-29-06 - patch from
!> Bobby Cheng, MathWorks
!>
!> Replace l.209 and l.377
!> IF( MAX( ABSAKK, COLMAX ).EQ.ZERO ) THEN
!> by
!> IF( (MAX( ABSAKK, COLMAX ).EQ.ZERO) .OR. SISNAN(ABSAKK) ) THEN
!>
!> 1-96 - Based on modifications by J. Lewis, Boeing Computer Services
!> Company
!> \endverbatim
!
! =====================================================================
SUBROUTINE CSYTF2(Uplo,N,A,Lda,Ipiv,Info)
IMPLICIT NONE
!*--CSYTF2196
!
! -- LAPACK computational routine (version 3.7.0) --
! -- LAPACK is a software package provided by Univ. of Tennessee, --
! -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
! December 2016
!
! .. Scalar Arguments ..
CHARACTER Uplo
INTEGER Info , Lda , N
! ..
! .. Array Arguments ..
INTEGER Ipiv(*)
COMPLEX A(Lda,*)
! ..
!
! =====================================================================
!
! .. Parameters ..
REAL ZERO , ONE
PARAMETER (ZERO=0.0E+0,ONE=1.0E+0)
REAL EIGHT , SEVTEN
PARAMETER (EIGHT=8.0E+0,SEVTEN=17.0E+0)
COMPLEX CONE
PARAMETER (CONE=(1.0E+0,0.0E+0))
! ..
! .. Local Scalars ..
LOGICAL upper
INTEGER i , imax , j , jmax , k , kk , kp , kstep
REAL absakk , alpha , colmax , rowmax
COMPLEX d11 , d12 , d21 , d22 , r1 , t , wk , wkm1 , wkp1 , z
! ..
! .. External Functions ..
LOGICAL LSAME , SISNAN
INTEGER ICAMAX
EXTERNAL LSAME , ICAMAX , SISNAN
! ..
! .. External Subroutines ..
EXTERNAL CSCAL , CSWAP , CSYR , XERBLA
! ..
! .. Intrinsic Functions ..
INTRINSIC ABS , AIMAG , MAX , REAL , SQRT
! ..
! .. Statement Functions ..
REAL CABS1
! ..
! .. Statement Function definitions ..
CABS1(z) = ABS(REAL(z)) + ABS(AIMAG(z))
! ..
! .. Executable Statements ..
!
! Test the input parameters.
!
Info = 0
upper = LSAME(Uplo,'U')
IF ( .NOT.upper .AND. .NOT.LSAME(Uplo,'L') ) THEN
Info = -1
ELSEIF ( N<0 ) THEN
Info = -2
ELSEIF ( Lda<MAX(1,N) ) THEN
Info = -4
ENDIF
IF ( Info/=0 ) THEN
CALL XERBLA('CSYTF2',-Info)
RETURN
ENDIF
!
! Initialize ALPHA for use in choosing pivot block size.
!
alpha = (ONE+SQRT(SEVTEN))/EIGHT
!
IF ( upper ) THEN
!
! Factorize A as U*D*U**T using the upper triangle of A
!
! K is the main loop index, decreasing from N to 1 in steps of
! 1 or 2
!
k = N
!
! If K < 1, exit from loop
!
DO WHILE ( k>=1 )
kstep = 1
!
! Determine rows and columns to be interchanged and whether
! a 1-by-1 or 2-by-2 pivot block will be used
!
absakk = CABS1(A(k,k))
!
! IMAX is the row-index of the largest off-diagonal element in
! column K, and COLMAX is its absolute value.
! Determine both COLMAX and IMAX.
!
IF ( k>1 ) THEN
imax = ICAMAX(k-1,A(1,k),1)
colmax = CABS1(A(imax,k))
ELSE
colmax = ZERO
ENDIF
!
IF ( MAX(absakk,colmax)==ZERO .OR. SISNAN(absakk) ) THEN
!
! Column K is zero or underflow, or contains a NaN:
! set INFO and continue
!
IF ( Info==0 ) Info = k
kp = k
ELSE
IF ( absakk>=alpha*colmax ) THEN
!
! no interchange, use 1-by-1 pivot block
!
kp = k
ELSE
!
! JMAX is the column-index of the largest off-diagonal
! element in row IMAX, and ROWMAX is its absolute value
!
jmax = imax + ICAMAX(k-imax,A(imax,imax+1),Lda)
rowmax = CABS1(A(imax,jmax))
IF ( imax>1 ) THEN
jmax = ICAMAX(imax-1,A(1,imax),1)
rowmax = MAX(rowmax,CABS1(A(jmax,imax)))
ENDIF
!
IF ( absakk>=alpha*colmax*(colmax/rowmax) ) THEN
!
! no interchange, use 1-by-1 pivot block
!
kp = k
ELSEIF ( CABS1(A(imax,imax))>=alpha*rowmax ) THEN
!
! interchange rows and columns K and IMAX, use 1-by-1
! pivot block
!
kp = imax
ELSE
!
! interchange rows and columns K-1 and IMAX, use 2-by-2
! pivot block
!
kp = imax
kstep = 2
ENDIF
ENDIF
!
kk = k - kstep + 1
IF ( kp/=kk ) THEN
!
! Interchange rows and columns KK and KP in the leading
! submatrix A(1:k,1:k)
!
CALL CSWAP(kp-1,A(1,kk),1,A(1,kp),1)
CALL CSWAP(kk-kp-1,A(kp+1,kk),1,A(kp,kp+1),Lda)
t = A(kk,kk)
A(kk,kk) = A(kp,kp)
A(kp,kp) = t
IF ( kstep==2 ) THEN
t = A(k-1,k)
A(k-1,k) = A(kp,k)
A(kp,k) = t
ENDIF
ENDIF
!
! Update the leading submatrix
!
IF ( kstep==1 ) THEN
!
! 1-by-1 pivot block D(k): column k now holds
!
! W(k) = U(k)*D(k)
!
! where U(k) is the k-th column of U
!
! Perform a rank-1 update of A(1:k-1,1:k-1) as
!
! A := A - U(k)*D(k)*U(k)**T = A - W(k)*1/D(k)*W(k)**T
!
r1 = CONE/A(k,k)
CALL CSYR(Uplo,k-1,-r1,A(1,k),1,A,Lda)
!
! Store U(k) in column k
!
CALL CSCAL(k-1,r1,A(1,k),1)
!
! 2-by-2 pivot block D(k): columns k and k-1 now hold
!
! ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k)
!
! where U(k) and U(k-1) are the k-th and (k-1)-th columns
! of U
!
! Perform a rank-2 update of A(1:k-2,1:k-2) as
!
! A := A - ( U(k-1) U(k) )*D(k)*( U(k-1) U(k) )**T
! = A - ( W(k-1) W(k) )*inv(D(k))*( W(k-1) W(k) )**T
!
ELSEIF ( k>2 ) THEN
!
d12 = A(k-1,k)
d22 = A(k-1,k-1)/d12
d11 = A(k,k)/d12
t = CONE/(d11*d22-CONE)
d12 = t/d12
!
DO j = k - 2 , 1 , -1
wkm1 = d12*(d11*A(j,k-1)-A(j,k))
wk = d12*(d22*A(j,k)-A(j,k-1))
DO i = j , 1 , -1
A(i,j) = A(i,j) - A(i,k)*wk - A(i,k-1)*wkm1
ENDDO
A(j,k) = wk
A(j,k-1) = wkm1
ENDDO
!
!
ENDIF
ENDIF
!
! Store details of the interchanges in IPIV
!
IF ( kstep==1 ) THEN
Ipiv(k) = kp
ELSE
Ipiv(k) = -kp
Ipiv(k-1) = -kp
ENDIF
!
! Decrease K and return to the start of the main loop
!
k = k - kstep
ENDDO
!
ELSE
!
! Factorize A as L*D*L**T using the lower triangle of A
!
! K is the main loop index, increasing from 1 to N in steps of
! 1 or 2
!
k = 1
!
! If K > N, exit from loop
!
DO WHILE ( k<=N )
kstep = 1
!
! Determine rows and columns to be interchanged and whether
! a 1-by-1 or 2-by-2 pivot block will be used
!
absakk = CABS1(A(k,k))
!
! IMAX is the row-index of the largest off-diagonal element in
! column K, and COLMAX is its absolute value.
! Determine both COLMAX and IMAX.
!
IF ( k<N ) THEN
imax = k + ICAMAX(N-k,A(k+1,k),1)
colmax = CABS1(A(imax,k))
ELSE
colmax = ZERO
ENDIF
!
IF ( MAX(absakk,colmax)==ZERO .OR. SISNAN(absakk) ) THEN
!
! Column K is zero or underflow, or contains a NaN:
! set INFO and continue
!
IF ( Info==0 ) Info = k
kp = k
ELSE
IF ( absakk>=alpha*colmax ) THEN
!
! no interchange, use 1-by-1 pivot block
!
kp = k
ELSE
!
! JMAX is the column-index of the largest off-diagonal
! element in row IMAX, and ROWMAX is its absolute value
!
jmax = k - 1 + ICAMAX(imax-k,A(imax,k),Lda)
rowmax = CABS1(A(imax,jmax))
IF ( imax<N ) THEN
jmax = imax + ICAMAX(N-imax,A(imax+1,imax),1)
rowmax = MAX(rowmax,CABS1(A(jmax,imax)))
ENDIF
!
IF ( absakk>=alpha*colmax*(colmax/rowmax) ) THEN
!
! no interchange, use 1-by-1 pivot block
!
kp = k
ELSEIF ( CABS1(A(imax,imax))>=alpha*rowmax ) THEN
!
! interchange rows and columns K and IMAX, use 1-by-1
! pivot block
!
kp = imax
ELSE
!
! interchange rows and columns K+1 and IMAX, use 2-by-2
! pivot block
!
kp = imax
kstep = 2
ENDIF
ENDIF
!
kk = k + kstep - 1
IF ( kp/=kk ) THEN
!
! Interchange rows and columns KK and KP in the trailing
! submatrix A(k:n,k:n)
!
IF ( kp<N ) CALL CSWAP(N-kp,A(kp+1,kk),1,A(kp+1,kp),1)
CALL CSWAP(kp-kk-1,A(kk+1,kk),1,A(kp,kk+1),Lda)
t = A(kk,kk)
A(kk,kk) = A(kp,kp)
A(kp,kp) = t
IF ( kstep==2 ) THEN
t = A(k+1,k)
A(k+1,k) = A(kp,k)
A(kp,k) = t
ENDIF
ENDIF
!
! Update the trailing submatrix
!
IF ( kstep==1 ) THEN
!
! 1-by-1 pivot block D(k): column k now holds
!
! W(k) = L(k)*D(k)
!
! where L(k) is the k-th column of L
!
IF ( k<N ) THEN
!
! Perform a rank-1 update of A(k+1:n,k+1:n) as
!
! A := A - L(k)*D(k)*L(k)**T = A - W(k)*(1/D(k))*W(k)**T
!
r1 = CONE/A(k,k)
CALL CSYR(Uplo,N-k,-r1,A(k+1,k),1,A(k+1,k+1),Lda)
!
! Store L(k) in column K
!
CALL CSCAL(N-k,r1,A(k+1,k),1)
ENDIF
!
! 2-by-2 pivot block D(k)
!
ELSEIF ( k<N-1 ) THEN
!
! Perform a rank-2 update of A(k+2:n,k+2:n) as
!
! A := A - ( L(k) L(k+1) )*D(k)*( L(k) L(k+1) )**T
! = A - ( W(k) W(k+1) )*inv(D(k))*( W(k) W(k+1) )**T
!
! where L(k) and L(k+1) are the k-th and (k+1)-th
! columns of L
!
d21 = A(k+1,k)
d11 = A(k+1,k+1)/d21
d22 = A(k,k)/d21
t = CONE/(d11*d22-CONE)
d21 = t/d21
!
DO j = k + 2 , N
wk = d21*(d11*A(j,k)-A(j,k+1))
wkp1 = d21*(d22*A(j,k+1)-A(j,k))
DO i = j , N
A(i,j) = A(i,j) - A(i,k)*wk - A(i,k+1)*wkp1
ENDDO
A(j,k) = wk
A(j,k+1) = wkp1
ENDDO
ENDIF
ENDIF
!
! Store details of the interchanges in IPIV
!
IF ( kstep==1 ) THEN
Ipiv(k) = kp
ELSE
Ipiv(k) = -kp
Ipiv(k+1) = -kp
ENDIF
!
! Increase K and return to the start of the main loop
!
k = k + kstep
ENDDO
!
ENDIF
!
!
! End of CSYTF2
!
END SUBROUTINE CSYTF2
|
module Twicer
import RealizedFunction
%default total
-- Realized twicer
public export
twicer : Int -> Int
twicer = (*2)
public export
twicer_attrs : RealizedAttributes
twicer_attrs = MkRealizedAttributes (MkCosts 200 20 2) 0.9
public export
rlz_twicer : RealizedFunction (Int -> Int) Twicer.twicer_attrs
rlz_twicer = MkRealizedFunction twicer twicer_attrs
|
Formal statement is: lemma islimpt_Un: "x islimpt (S \<union> T) \<longleftrightarrow> x islimpt S \<or> x islimpt T" Informal statement is: A point $x$ is a limit point of the union of two sets $S$ and $T$ if and only if $x$ is a limit point of $S$ or $x$ is a limit point of $T$. |
My http://www.netmotifs.com/ homepage from about 1997. May not work in explorer, because the still havent updated their buggy css implementation.
20041207 12:40:55 nbsp Yes. Zach is too busy with work. Users/EricKlein
20051019 17:29:11 nbsp Hey Zach! Users/NicoleChunNelson
|
@testset "Geometry" begin
tests = ["vector",
"point",
"plane",
"axisalignedbox",
"polytopes/polytope",
"polytopes/interpolate",
"polytopes/jacobian",
"polytopes/faces",
"polytopes/edges",
"polytopes/measure",
"polytopes/triangulate",
]
for t in tests
include("$(t).jl")
end
end
|
Lighthouse blog includes musings and photographs of lighthouses that I have visited. I also have guest bloggers who talk about lighthouses they have visited. In the last four years I have visited and photographed 30 lighthouses.
Wow great lighthouses. my girlfriend has one and they are beautiful. |
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import group_theory.subgroup.pointwise
import linear_algebra.span
/-! # Pointwise instances on `submodule`s
This file provides:
* `submodule.has_pointwise_neg`
and the actions
* `submodule.pointwise_distrib_mul_action`
* `submodule.pointwise_mul_action_with_zero`
which matches the action of `mul_action_set`.
These actions are available in the `pointwise` locale.
## Implementation notes
Most of the lemmas in this file are direct copies of lemmas from
`group_theory/submonoid/pointwise.lean`.
-/
variables {α : Type*} {R : Type*} {M : Type*}
open_locale pointwise
namespace submodule
section neg
section semiring
variables [semiring R] [add_comm_group M] [module R M]
/-- The submodule with every element negated. Note if `R` is a ring and not just a semiring, this
is a no-op, as shown by `submodule.neg_eq_self`.
Recall that When `R` is the semiring corresponding to the nonnegative elements of `R'`,
`submodule R' M` is the type of cones of `M`. This instance reflects such cones about `0`.
This is available as an instance in the `pointwise` locale. -/
protected def has_pointwise_neg : has_neg (submodule R M) :=
{ neg := λ p,
{ carrier := -(p : set M),
smul_mem' := λ r m hm, set.mem_neg.2 $ smul_neg r m ▸ p.smul_mem r $ set.mem_neg.1 hm,
..(- p.to_add_submonoid) } }
localized "attribute [instance] submodule.has_pointwise_neg" in pointwise
open_locale pointwise
@[simp] lemma coe_set_neg (S : submodule R M) : ↑(-S) = -(S : set M) := rfl
@[simp] lemma neg_to_add_submonoid (S : submodule R M) :
(-S).to_add_submonoid = -S.to_add_submonoid := rfl
@[simp]
/-- `submodule.has_pointwise_neg` is involutive.
This is available as an instance in the `pointwise` locale. -/
protected def has_involutive_pointwise_neg : has_involutive_neg (submodule R M) :=
{ neg := has_neg.neg,
neg_neg := λ S, set_like.coe_injective $ neg_neg _ }
localized "attribute [instance] submodule.has_involutive_pointwise_neg" in pointwise
@[simp] lemma neg_le_neg (S T : submodule R M) : -S ≤ -T ↔ S ≤ T :=
set_like.coe_subset_coe.symm.trans set.neg_subset_neg
lemma neg_le (S T : submodule R M) : -S ≤ T ↔ S ≤ -T :=
set_like.coe_subset_coe.symm.trans set.neg_subset
/-- `submodule.has_pointwise_neg` as an order isomorphism. -/
def neg_order_iso : submodule R M ≃o submodule R M :=
{ to_equiv := equiv.neg _,
map_rel_iff' := neg_le_neg }
lemma closure_neg (s : set M) : span R (-s) = -(span R s) :=
begin
apply le_antisymm,
{ rw [span_le, coe_set_neg, ←set.neg_subset, neg_neg],
exact subset_span },
{ rw [neg_le, span_le, coe_set_neg, ←set.neg_subset],
exact subset_span }
end
@[simp]
lemma neg_inf (S T : submodule R M) : -(S ⊓ T) = (-S) ⊓ (-T) :=
set_like.coe_injective set.inter_neg
@[simp]
lemma neg_sup (S T : submodule R M) : -(S ⊔ T) = (-S) ⊔ (-T) :=
(neg_order_iso : submodule R M ≃o submodule R M).map_sup S T
@[simp]
lemma neg_bot : -(⊥ : submodule R M) = ⊥ :=
set_like.coe_injective $ (set.neg_singleton 0).trans $ congr_arg _ neg_zero
@[simp]
lemma neg_top : -(⊤ : submodule R M) = ⊤ :=
set_like.coe_injective $ set.neg_univ
@[simp]
lemma neg_infi {ι : Sort*} (S : ι → submodule R M) : -(⨅ i, S i) = ⨅ i, -S i :=
(neg_order_iso : submodule R M ≃o submodule R M).map_infi _
@[simp]
lemma neg_supr {ι : Sort*} (S : ι → submodule R M) : -(⨆ i, S i) = ⨆ i, -(S i) :=
(neg_order_iso : submodule R M ≃o submodule R M).map_supr _
end semiring
open_locale pointwise
@[simp] lemma neg_eq_self [ring R] [add_comm_group M] [module R M] (p : submodule R M) : -p = p :=
ext $ λ _, p.neg_mem_iff
end neg
variables [semiring R] [add_comm_monoid M] [module R M]
instance pointwise_add_comm_monoid : add_comm_monoid (submodule R M) :=
{ add := (⊔),
add_assoc := λ _ _ _, sup_assoc,
zero := ⊥,
zero_add := λ _, bot_sup_eq,
add_zero := λ _, sup_bot_eq,
add_comm := λ _ _, sup_comm }
@[simp] lemma add_eq_sup (p q : submodule R M) : p + q = p ⊔ q := rfl
@[simp] lemma zero_eq_bot : (0 : submodule R M) = ⊥ := rfl
instance : canonically_ordered_add_monoid (submodule R M) :=
{ zero := 0,
bot := ⊥,
add := (+),
add_le_add_left := λ a b, sup_le_sup_left,
exists_add_of_le := λ a b h, ⟨b, (sup_eq_right.2 h).symm⟩,
le_self_add := λ a b, le_sup_left,
..submodule.pointwise_add_comm_monoid,
..submodule.complete_lattice }
section
variables [monoid α] [distrib_mul_action α M] [smul_comm_class α R M]
/-- The action on a submodule corresponding to applying the action to every element.
This is available as an instance in the `pointwise` locale. -/
protected def pointwise_distrib_mul_action : distrib_mul_action α (submodule R M) :=
{ smul := λ a S, S.map (distrib_mul_action.to_linear_map _ _ a),
one_smul := λ S,
(congr_arg (λ f, S.map f) (linear_map.ext $ by exact one_smul α)).trans S.map_id,
mul_smul := λ a₁ a₂ S,
(congr_arg (λ f : M →ₗ[R] M, S.map f) (linear_map.ext $ by exact mul_smul _ _)).trans
(S.map_comp _ _),
smul_zero := λ a, map_bot _,
smul_add := λ a S₁ S₂, map_sup _ _ _ }
localized "attribute [instance] submodule.pointwise_distrib_mul_action" in pointwise
open_locale pointwise
@[simp] lemma coe_pointwise_smul (a : α) (S : submodule R M) : ↑(a • S) = a • (S : set M) := rfl
@[simp] lemma pointwise_smul_to_add_submonoid (a : α) (S : submodule R M) :
(a • S).to_add_submonoid = a • S.to_add_submonoid := rfl
@[simp] lemma pointwise_smul_to_add_subgroup {R M : Type*}
[ring R] [add_comm_group M] [distrib_mul_action α M] [module R M] [smul_comm_class α R M]
(a : α) (S : submodule R M) :
(a • S).to_add_subgroup = a • S.to_add_subgroup := rfl
lemma smul_mem_pointwise_smul (m : M) (a : α) (S : submodule R M) : m ∈ S → a • m ∈ a • S :=
(set.smul_mem_smul_set : _ → _ ∈ a • (S : set M))
instance pointwise_central_scalar [distrib_mul_action αᵐᵒᵖ M] [smul_comm_class αᵐᵒᵖ R M]
[is_central_scalar α M] :
is_central_scalar α (submodule R M) :=
⟨λ a S, congr_arg (λ f, S.map f) $ linear_map.ext $ by exact op_smul_eq_smul _⟩
@[simp] lemma smul_le_self_of_tower {α : Type*}
[semiring α] [module α R] [module α M] [smul_comm_class α R M] [is_scalar_tower α R M]
(a : α) (S : submodule R M) : a • S ≤ S :=
begin
rintro y ⟨x, hx, rfl⟩,
exact smul_of_tower_mem _ a hx,
end
end
section
variables [semiring α] [module α M] [smul_comm_class α R M]
/-- The action on a submodule corresponding to applying the action to every element.
This is available as an instance in the `pointwise` locale.
This is a stronger version of `submodule.pointwise_distrib_mul_action`. Note that `add_smul` does
not hold so this cannot be stated as a `module`. -/
protected def pointwise_mul_action_with_zero : mul_action_with_zero α (submodule R M) :=
{ zero_smul := λ S,
(congr_arg (λ f : M →ₗ[R] M, S.map f) (linear_map.ext $ by exact zero_smul α)).trans S.map_zero,
.. submodule.pointwise_distrib_mul_action }
localized "attribute [instance] submodule.pointwise_mul_action_with_zero" in pointwise
end
end submodule
|
Suppose $f$ and $g$ are L-Lipschitz functions on $[a,b]$ and $[b,c]$, respectively, and $f(b) = g(b)$. Then the function $h$ defined by $h(x) = f(x)$ if $x \leq b$ and $h(x) = g(x)$ if $x > b$ is L-Lipschitz on $[a,c]$. |
section \<open>Factorization into Monic Polynomials\label{sec:monic}\<close>
theory Monic_Polynomial_Factorization
imports
Finite_Fields_Factorization_Ext
Formal_Polynomial_Derivatives
begin
hide_const Factorial_Ring.multiplicity
hide_const Factorial_Ring.irreducible
lemma (in domain) finprod_mult_of:
assumes "finite A"
assumes "\<And>x. x \<in> A \<Longrightarrow> f x \<in> carrier (mult_of R)"
shows "finprod R f A = finprod (mult_of R) f A"
using assms by (induction A rule:finite_induct, auto)
lemma (in ring) finite_poly:
assumes "subring K R"
assumes "finite K"
shows
"finite {f. f \<in> carrier (K[X]) \<and> degree f = n}" (is "finite ?A")
"finite {f. f \<in> carrier (K[X]) \<and> degree f \<le> n}" (is "finite ?B")
proof -
have "finite {f. set f \<subseteq> K \<and> length f \<le> n + 1}" (is "finite ?C")
using assms(2) finite_lists_length_le by auto
moreover have "?B \<subseteq> ?C"
by (intro subsetI)
(auto simp:univ_poly_carrier[symmetric] polynomial_def)
ultimately show a: "finite ?B"
using finite_subset by auto
moreover have "?A \<subseteq> ?B"
by (intro subsetI, simp)
ultimately show "finite ?A"
using finite_subset by auto
qed
definition pmult :: "_ \<Rightarrow> 'a list \<Rightarrow> 'a list \<Rightarrow> nat" ("pmult\<index>")
where "pmult\<^bsub>R\<^esub> d p = multiplicity (mult_of (poly_ring R)) d p"
definition monic_poly :: "_ \<Rightarrow> 'a list \<Rightarrow> bool"
where "monic_poly R f =
(f \<noteq> [] \<and> lead_coeff f = \<one>\<^bsub>R\<^esub> \<and> f \<in> carrier (poly_ring R))"
definition monic_irreducible_poly where
"monic_irreducible_poly R f =
(monic_poly R f \<and> pirreducible\<^bsub>R\<^esub> (carrier R) f)"
abbreviation "m_i_p \<equiv> monic_irreducible_poly"
locale polynomial_ring = field +
fixes K
assumes polynomial_ring_assms: "subfield K R"
begin
lemma K_subring: "subring K R"
using polynomial_ring_assms subfieldE(1) by auto
abbreviation P where "P \<equiv> K[X]"
text \<open>This locale is used to specialize the following lemmas for a fixed coefficient ring.
It can be introduced in a context as an intepretation to be able to use the following specialized
lemmas. Because it is not (and should not) introduced as a sublocale it has no lasting effect
for the field locale itself.\<close>
lemmas
poly_mult_lead_coeff = poly_mult_lead_coeff[OF K_subring]
and degree_add_distinct = degree_add_distinct[OF K_subring]
and coeff_add = coeff_add[OF K_subring]
and var_closed = var_closed[OF K_subring]
and degree_prod = degree_prod[OF _ K_subring]
and degree_pow = degree_pow[OF K_subring]
and pirreducible_degree = pirreducible_degree[OF polynomial_ring_assms]
and degree_one_imp_pirreducible =
degree_one_imp_pirreducible[OF polynomial_ring_assms]
and var_pow_closed = var_pow_closed[OF K_subring]
and var_pow_carr = var_pow_carr[OF K_subring]
and univ_poly_a_inv_degree = univ_poly_a_inv_degree[OF K_subring]
and var_pow_degree = var_pow_degree[OF K_subring]
and pdivides_zero = pdivides_zero[OF K_subring]
and pdivides_imp_degree_le = pdivides_imp_degree_le[OF K_subring]
and var_carr = var_carr[OF K_subring]
and rupture_eq_0_iff = rupture_eq_0_iff[OF polynomial_ring_assms]
and rupture_is_field_iff_pirreducible =
rupture_is_field_iff_pirreducible[OF polynomial_ring_assms]
and rupture_surj_hom = rupture_surj_hom[OF K_subring]
and canonical_embedding_ring_hom =
canonical_embedding_ring_hom[OF K_subring]
and rupture_surj_norm_is_hom = rupture_surj_norm_is_hom[OF K_subring]
and rupture_surj_as_eval = rupture_surj_as_eval[OF K_subring]
and eval_cring_hom = eval_cring_hom[OF K_subring]
and coeff_range = coeff_range[OF K_subring]
and finite_poly = finite_poly[OF K_subring]
and int_embed_consistent_with_poly_of_const =
int_embed_consistent_with_poly_of_const[OF K_subring]
and pderiv_var_pow = pderiv_var_pow[OF _ K_subring]
and pderiv_add = pderiv_add[OF K_subring]
and pderiv_inv = pderiv_inv[OF K_subring]
and pderiv_mult = pderiv_mult[OF K_subring]
and pderiv_pow = pderiv_pow[OF _ K_subring]
and pderiv_carr = pderiv_carr[OF K_subring]
sublocale p:principal_domain "poly_ring R"
by (simp add: carrier_is_subfield univ_poly_is_principal)
end
context field
begin
interpretation polynomial_ring "R" "carrier R"
using carrier_is_subfield field_axioms
by (simp add:polynomial_ring_def polynomial_ring_axioms_def)
lemma pdivides_mult_r:
assumes "a \<in> carrier (mult_of P)"
assumes "b \<in> carrier (mult_of P)"
assumes "c \<in> carrier (mult_of P)"
shows "a \<otimes>\<^bsub>P\<^esub> c pdivides b \<otimes>\<^bsub>P\<^esub> c \<longleftrightarrow> a pdivides b"
(is "?lhs \<longleftrightarrow> ?rhs")
proof -
have a:"b \<otimes>\<^bsub>P\<^esub> c \<in> carrier P - {\<zero>\<^bsub>P\<^esub>}"
using assms p.mult_of.m_closed by force
have b:"a \<otimes>\<^bsub>P\<^esub> c \<in> carrier P"
using assms by simp
have c:"b \<in> carrier P - {\<zero>\<^bsub>P\<^esub>}"
using assms p.mult_of.m_closed by force
have d:"a \<in> carrier P" using assms by simp
have "?lhs \<longleftrightarrow> a \<otimes>\<^bsub>P\<^esub> c divides\<^bsub>mult_of P\<^esub> b \<otimes>\<^bsub>P\<^esub> c"
unfolding pdivides_def using p.divides_imp_divides_mult a b
by (meson divides_mult_imp_divides)
also have "... \<longleftrightarrow> a divides\<^bsub>mult_of P\<^esub> b"
using p.mult_of.divides_mult_r[OF assms] by simp
also have "... \<longleftrightarrow> ?rhs"
unfolding pdivides_def using p.divides_imp_divides_mult c d
by (meson divides_mult_imp_divides)
finally show ?thesis by simp
qed
lemma lead_coeff_carr:
assumes "x \<in> carrier (mult_of P)"
shows "lead_coeff x \<in> carrier R - {\<zero>}"
proof (cases x)
case Nil
then show ?thesis using assms by (simp add:univ_poly_zero)
next
case (Cons a list)
hence a: "polynomial (carrier R) (a # list)"
using assms univ_poly_carrier by auto
have "lead_coeff x = a"
using Cons by simp
also have "a \<in> carrier R - {\<zero>}"
using lead_coeff_not_zero a by simp
finally show ?thesis by simp
qed
lemma lead_coeff_poly_of_const:
assumes "r \<noteq> \<zero>"
shows "lead_coeff (poly_of_const r) = r"
using assms
by (simp add:poly_of_const_def)
lemma lead_coeff_mult:
assumes "f \<in> carrier (mult_of P)"
assumes "g \<in> carrier (mult_of P)"
shows "lead_coeff (f \<otimes>\<^bsub>P\<^esub> g) = lead_coeff f \<otimes> lead_coeff g"
unfolding univ_poly_mult using assms
using univ_poly_carrier[where R="R" and K="carrier R"]
by (subst poly_mult_lead_coeff) (simp_all add:univ_poly_zero)
lemma monic_poly_carr:
assumes "monic_poly R f"
shows "f \<in> carrier P"
using assms unfolding monic_poly_def by simp
lemma monic_poly_add_distinct:
assumes "monic_poly R f"
assumes "g \<in> carrier P" "degree g < degree f"
shows "monic_poly R (f \<oplus>\<^bsub>P\<^esub> g)"
proof (cases "g \<noteq> \<zero>\<^bsub>P\<^esub>")
case True
define n where "n = degree f"
have "f \<in> carrier P - {\<zero>\<^bsub>P\<^esub>}"
using assms(1) univ_poly_zero
unfolding monic_poly_def by auto
hence "degree (f \<oplus>\<^bsub>P\<^esub> g) = max (degree f) (degree g)"
using assms(2,3) True
by (subst degree_add_distinct, simp_all)
also have "... = degree f"
using assms(3) by simp
finally have b: "degree (f \<oplus>\<^bsub>P\<^esub> g) = n"
unfolding n_def by simp
moreover have "n > 0"
using assms(3) unfolding n_def by simp
ultimately have "degree (f \<oplus>\<^bsub>P\<^esub> g) \<noteq> degree ([])"
by simp
hence a:"f \<oplus>\<^bsub>P\<^esub> g \<noteq> []" by auto
have "degree [] = 0" by simp
also have "... < degree f"
using assms(3) by simp
finally have "degree f \<noteq> degree []" by simp
hence c: "f \<noteq> []" by auto
have d: "length g \<le> n"
using assms(3) unfolding n_def by simp
have "lead_coeff (f \<oplus>\<^bsub>P\<^esub> g) = coeff (f \<oplus>\<^bsub>P\<^esub> g) n"
using a b by (cases "f \<oplus>\<^bsub>P\<^esub> g", auto)
also have "... = coeff f n \<oplus> coeff g n"
using monic_poly_carr assms
by (subst coeff_add, auto)
also have "... = lead_coeff f \<oplus> coeff g n"
using c unfolding n_def by (cases "f", auto)
also have "... = \<one> \<oplus> \<zero>"
using assms(1) unfolding monic_poly_def
unfolding subst coeff_length[OF d] by simp
also have "... = \<one>"
by simp
finally have "lead_coeff (f \<oplus>\<^bsub>P\<^esub> g) = \<one>" by simp
moreover have "f \<oplus>\<^bsub>P\<^esub> g \<in> carrier P"
using monic_poly_carr assms by simp
ultimately show ?thesis
using a unfolding monic_poly_def by auto
next
case False
then show ?thesis using assms monic_poly_carr by simp
qed
lemma monic_poly_one: "monic_poly R \<one>\<^bsub>P\<^esub>"
proof -
have "\<one>\<^bsub>P\<^esub> \<in> carrier P"
by simp
thus ?thesis
by (simp add:univ_poly_one monic_poly_def)
qed
lemma monic_poly_var: "monic_poly R X"
proof -
have "X \<in> carrier P"
using var_closed by simp
thus ?thesis
by (simp add:var_def monic_poly_def)
qed
lemma monic_poly_carr_2:
assumes "monic_poly R f"
shows "f \<in> carrier (mult_of P)"
using assms unfolding monic_poly_def
by (simp add:univ_poly_zero)
lemma monic_poly_mult:
assumes "monic_poly R f"
assumes "monic_poly R g"
shows "monic_poly R (f \<otimes>\<^bsub>P\<^esub> g)"
proof -
have "lead_coeff (f \<otimes>\<^bsub>P\<^esub> g) = lead_coeff f \<otimes>\<^bsub>R\<^esub> lead_coeff g"
using assms monic_poly_carr_2
by (subst lead_coeff_mult) auto
also have "... = \<one>"
using assms unfolding monic_poly_def by simp
finally have "lead_coeff (f \<otimes>\<^bsub>P\<^esub> g) = \<one>\<^bsub>R\<^esub>" by simp
moreover have "(f \<otimes>\<^bsub>P\<^esub> g) \<in> carrier (mult_of P)"
using monic_poly_carr_2 assms by blast
ultimately show ?thesis
by (simp add:monic_poly_def univ_poly_zero)
qed
lemma monic_poly_pow:
assumes "monic_poly R f"
shows "monic_poly R (f [^]\<^bsub>P\<^esub> (n::nat))"
using assms monic_poly_one monic_poly_mult
by (induction n, auto)
lemma monic_poly_prod:
assumes "finite A"
assumes "\<And>x. x \<in> A \<Longrightarrow> monic_poly R (f x)"
shows "monic_poly R (finprod P f A)"
using assms
proof (induction A rule:finite_induct)
case empty
then show ?case by (simp add:monic_poly_one)
next
case (insert x F)
have a: "f \<in> F \<rightarrow> carrier P"
using insert monic_poly_carr by simp
have b: "f x \<in> carrier P"
using insert monic_poly_carr by simp
have "monic_poly R (f x \<otimes>\<^bsub>P\<^esub> finprod P f F)"
using insert by (intro monic_poly_mult) auto
thus ?case
using insert a b by (subst p.finprod_insert, auto)
qed
lemma monic_poly_not_assoc:
assumes "monic_poly R f"
assumes "monic_poly R g"
assumes "f \<sim>\<^bsub>(mult_of P)\<^esub> g"
shows "f = g"
proof -
obtain u where u_def: "f = g \<otimes>\<^bsub>P\<^esub> u" "u \<in> Units (mult_of P)"
using p.mult_of.associatedD2 assms monic_poly_carr_2
by blast
hence "u \<in> Units P" by simp
then obtain v where v_def: "u = [v]" "v \<noteq> \<zero>\<^bsub>R\<^esub>" "v \<in> carrier R"
using univ_poly_carrier_units by auto
have "\<one> = lead_coeff f"
using assms(1) by (simp add:monic_poly_def)
also have "... = lead_coeff (g \<otimes>\<^bsub>P\<^esub> u)"
by (simp add:u_def)
also have "... = lead_coeff g \<otimes> lead_coeff u"
using assms(2) monic_poly_carr_2 v_def u_def(2)
by (subst lead_coeff_mult, auto simp add:univ_poly_zero)
also have "... = lead_coeff g \<otimes> v"
using v_def by simp
also have "... = v"
using assms(2) v_def(3) by (simp add:monic_poly_def)
finally have "\<one> = v" by simp
hence "u = \<one>\<^bsub>P\<^esub>"
using v_def by (simp add:univ_poly_one)
thus "f = g"
using u_def assms monic_poly_carr by simp
qed
lemma monic_poly_span:
assumes "x \<in> carrier (mult_of P)" "irreducible (mult_of P) x"
shows "\<exists>y. monic_irreducible_poly R y \<and> x \<sim>\<^bsub>(mult_of P)\<^esub> y"
proof -
define z where "z = poly_of_const (inv (lead_coeff x))"
define y where "y = x \<otimes>\<^bsub>P\<^esub> z"
have x_carr: "x \<in> carrier (mult_of P)" using assms by simp
hence lx_ne_0: "lead_coeff x \<noteq> \<zero>"
and lx_unit: "lead_coeff x \<in> Units R"
using lead_coeff_carr[OF x_carr] by (auto simp add:field_Units)
have lx_inv_ne_0: "inv (lead_coeff x) \<noteq> \<zero>"
using lx_unit
by (metis Units_closed Units_r_inv r_null zero_not_one)
have lx_inv_carr: "inv (lead_coeff x) \<in> carrier R"
using lx_unit by simp
have "z \<in> carrier P"
using lx_inv_carr poly_of_const_over_carrier
unfolding z_def by auto
moreover have "z \<noteq> \<zero>\<^bsub>P\<^esub>"
using lx_inv_ne_0
by (simp add:z_def poly_of_const_def univ_poly_zero)
ultimately have z_carr: "z \<in> carrier (mult_of P)" by simp
have z_unit: "z \<in> Units (mult_of P)"
using lx_inv_ne_0 lx_inv_carr
by (simp add:univ_poly_carrier_units z_def poly_of_const_def)
have y_exp: "y = x \<otimes>\<^bsub>(mult_of P)\<^esub> z"
by (simp add:y_def)
hence y_carr: "y \<in> carrier (mult_of P)"
using x_carr z_carr p.mult_of.m_closed by simp
have "irreducible (mult_of P) y"
unfolding y_def using assms z_unit z_carr
by (intro p.mult_of.irreducible_prod_rI, auto)
moreover have "lead_coeff y = \<one>\<^bsub>R\<^esub>"
unfolding y_def using x_carr z_carr lx_inv_ne_0 lx_unit
by (simp add: lead_coeff_mult z_def lead_coeff_poly_of_const)
hence "monic_poly R y"
using y_carr unfolding monic_poly_def
by (simp add:univ_poly_zero)
ultimately have "monic_irreducible_poly R y"
using p.irreducible_mult_imp_irreducible y_carr
by (simp add:monic_irreducible_poly_def ring_irreducible_def)
moreover have "y \<sim>\<^bsub>(mult_of P)\<^esub> x"
by (intro p.mult_of.associatedI2[OF z_unit] y_def x_carr)
hence "x \<sim>\<^bsub>(mult_of P)\<^esub> y"
using x_carr y_carr by (simp add:p.mult_of.associated_sym)
ultimately show ?thesis by auto
qed
lemma monic_polys_are_canonical_irreducibles:
"canonical_irreducibles (mult_of P) {d. monic_irreducible_poly R d}"
(is "canonical_irreducibles (mult_of P) ?S")
proof -
have sp_1:
"?S \<subseteq> {x \<in> carrier (mult_of P). irreducible (mult_of P) x}"
unfolding monic_irreducible_poly_def ring_irreducible_def
using monic_poly_carr
by (intro subsetI, simp add: p.irreducible_imp_irreducible_mult)
have sp_2: "x = y"
if "x \<in> ?S" "y \<in> ?S" "x \<sim>\<^bsub>(mult_of P)\<^esub> y" for x y
using that monic_poly_not_assoc
by (simp add:monic_irreducible_poly_def)
have sp_3: "\<exists>y \<in> ?S. x \<sim>\<^bsub>(mult_of P)\<^esub> y"
if "x \<in> carrier (mult_of P)" "irreducible (mult_of P) x" for x
using that monic_poly_span by simp
thus ?thesis using sp_1 sp_2 sp_3
unfolding canonical_irreducibles_def by simp
qed
lemma
assumes "monic_poly R a"
shows factor_monic_poly:
"a = (\<Otimes>\<^bsub>P\<^esub>d\<in>{d. monic_irreducible_poly R d \<and> pmult d a > 0}.
d [^]\<^bsub>P\<^esub> pmult d a)" (is "?lhs = ?rhs")
and factor_monic_poly_fin:
"finite {d. monic_irreducible_poly R d \<and> pmult d a > 0}"
proof -
let ?S = "{d. monic_irreducible_poly R d}"
let ?T = "{d. monic_irreducible_poly R d \<and> pmult d a > 0}"
let ?mip = "monic_irreducible_poly R"
have sp_4: "a \<in> carrier (mult_of P)"
using assms monic_poly_carr_2
unfolding monic_irreducible_poly_def by simp
have b_1: "x \<in> carrier (mult_of P)" if "?mip x" for x
using that monic_poly_carr_2
unfolding monic_irreducible_poly_def by simp
have b_2:"irreducible (mult_of P) x" if "?mip x" for x
using that
unfolding monic_irreducible_poly_def ring_irreducible_def
by (simp add: monic_poly_carr p.irreducible_imp_irreducible_mult)
have b_3:"x \<in> carrier P" if "?mip x" for x
using that monic_poly_carr
unfolding monic_irreducible_poly_def
by simp
have a_carr: "a \<in> carrier P - {\<zero>\<^bsub>P\<^esub>}"
using sp_4 by simp
have "?T = {d. ?mip d \<and> multiplicity (mult_of P) d a > 0}"
by (simp add:pmult_def)
also have "... = {d \<in> ?S. multiplicity (mult_of P) d a > 0}"
using p.mult_of.multiplicity_gt_0_iff[OF b_1 b_2 sp_4]
by (intro order_antisym subsetI, auto)
finally have t:"?T = {d \<in> ?S. multiplicity (mult_of P) d a > 0}"
by simp
show fin_T: "finite ?T"
unfolding t
using p.mult_of.split_factors(1)
[OF monic_polys_are_canonical_irreducibles]
using sp_4 by auto
have a:"x [^]\<^bsub>P\<^esub> (n::nat) \<in> carrier (mult_of P)" if "?mip x" for x n
proof -
have "monic_poly R (x [^]\<^bsub>P\<^esub> n)"
using that monic_poly_pow
unfolding monic_irreducible_poly_def by auto
thus ?thesis
using monic_poly_carr_2 by simp
qed
have "?lhs \<sim>\<^bsub>(mult_of P)\<^esub>
finprod (mult_of P)
(\<lambda>d. d [^]\<^bsub>(mult_of P)\<^esub> (multiplicity (mult_of P) d a)) ?T"
unfolding t
by (intro p.mult_of.split_factors(2)
[OF monic_polys_are_canonical_irreducibles sp_4])
also have "... =
finprod (mult_of P) (\<lambda>d. d [^]\<^bsub>P\<^esub> (multiplicity (mult_of P) d a)) ?T"
by (simp add:nat_pow_mult_of)
also have "... = ?rhs"
using fin_T a
by (subst p.finprod_mult_of, simp_all add:pmult_def)
finally have "?lhs \<sim>\<^bsub>(mult_of P)\<^esub> ?rhs" by simp
moreover have "monic_poly R ?rhs"
using fin_T
by (intro monic_poly_prod monic_poly_pow)
(auto simp:monic_irreducible_poly_def)
ultimately show "?lhs = ?rhs"
using monic_poly_not_assoc assms monic_irreducible_poly_def
by blast
qed
lemma degree_monic_poly':
assumes "monic_poly R f"
shows
"sum' (\<lambda>d. pmult d f * degree d) {d. monic_irreducible_poly R d} =
degree f"
proof -
let ?mip = "monic_irreducible_poly R"
have b: "d \<in> carrier P - {\<zero>\<^bsub>P\<^esub>}" if "?mip d" for d
using that monic_poly_carr_2
unfolding monic_irreducible_poly_def by simp
have a: "d [^]\<^bsub>P\<^esub> n \<in> carrier P - {\<zero>\<^bsub>P\<^esub>}" if "?mip d" for d and n :: "nat"
using b that monic_poly_pow
unfolding monic_irreducible_poly_def
by (simp add: p.pow_non_zero)
have "degree f =
degree (\<Otimes>\<^bsub>P\<^esub>d\<in>{d. ?mip d \<and> pmult d f > 0}. d [^]\<^bsub>P\<^esub> pmult d f)"
using factor_monic_poly[OF assms(1)] by simp
also have "... =
(\<Sum>i\<in>{d. ?mip d \<and> 0 < pmult d f}. degree (i [^]\<^bsub>P\<^esub> pmult i f))"
using a assms(1)
by (subst degree_prod[OF factor_monic_poly_fin])
(simp_all add:Pi_def)
also have "... =
(\<Sum>i\<in>{d. ?mip d \<and> 0 < pmult d f}. degree i * pmult i f)"
using b degree_pow by (intro sum.cong, auto)
also have "... =
(\<Sum>d\<in>{d. ?mip d \<and> 0 < pmult d f}. pmult d f * degree d)"
by (simp add:mult.commute)
also have "... =
sum' (\<lambda>d. pmult d f * degree d) {d. ?mip d \<and> 0 < pmult d f}"
using sum.eq_sum factor_monic_poly_fin[OF assms(1)] by simp
also have "... = sum' (\<lambda>d. pmult d f * degree d) {d. ?mip d}"
by (intro sum.mono_neutral_cong_left' subsetI, auto)
finally show ?thesis by simp
qed
lemma monic_poly_min_degree:
assumes "monic_irreducible_poly R f"
shows "degree f \<ge> 1"
using assms unfolding monic_irreducible_poly_def monic_poly_def
by (intro pirreducible_degree) auto
lemma degree_one_monic_poly:
"monic_irreducible_poly R f \<and> degree f = 1 \<longleftrightarrow>
(\<exists>x \<in> carrier R. f = [\<one>, \<ominus>x])"
proof
assume "monic_irreducible_poly R f \<and> degree f = 1"
hence a:"monic_poly R f" "length f = 2"
unfolding monic_irreducible_poly_def by auto
then obtain u v where f_def: "f = [u,v]"
by (cases f, simp, cases "tl f", auto)
have "u = \<one>" using a unfolding monic_poly_def f_def by simp
moreover have "v \<in> carrier R"
using a unfolding monic_poly_def univ_poly_carrier[symmetric]
unfolding polynomial_def f_def by simp
ultimately have "f = [\<one>, \<ominus>(\<ominus>v)]" "(\<ominus>v) \<in> carrier R"
using a_inv_closed f_def by auto
thus "(\<exists>x \<in> carrier R. f = [\<one>\<^bsub>R\<^esub>, \<ominus>\<^bsub>R\<^esub>x])" by auto
next
assume "(\<exists>x \<in> carrier R. f = [\<one>, \<ominus>x])"
then obtain x where f_def: "f = [\<one>,\<ominus>x]" "x \<in> carrier R" by auto
have a:"degree f = 1" using f_def(2) unfolding f_def by simp
have b:"f \<in> carrier P"
using f_def(2) unfolding univ_poly_carrier[symmetric]
unfolding f_def polynomial_def by simp
have c: "pirreducible (carrier R) f"
by (intro degree_one_imp_pirreducible a b)
have d: "lead_coeff f = \<one>" unfolding f_def by simp
show "monic_irreducible_poly R f \<and> degree f = 1"
using a b c d
unfolding monic_irreducible_poly_def monic_poly_def
by auto
qed
lemma multiplicity_ge_iff:
assumes "monic_irreducible_poly R d"
assumes "f \<in> carrier P - {\<zero>\<^bsub>P\<^esub>}"
shows "pmult d f \<ge> k \<longleftrightarrow> d [^]\<^bsub>P\<^esub> k pdivides f"
proof -
have a:"f \<in> carrier (mult_of P)"
using assms(2) by simp
have b: "d \<in> carrier (mult_of P)"
using assms(1) monic_poly_carr_2
unfolding monic_irreducible_poly_def by simp
have c: "irreducible (mult_of P) d"
using assms(1) monic_poly_carr_2
using p.irreducible_imp_irreducible_mult
unfolding monic_irreducible_poly_def
unfolding ring_irreducible_def monic_poly_def
by simp
have d: "d [^]\<^bsub>P\<^esub> k \<in> carrier P" using b by simp
have "pmult d f \<ge> k \<longleftrightarrow> d [^]\<^bsub>(mult_of P)\<^esub> k divides\<^bsub>(mult_of P)\<^esub> f"
unfolding pmult_def
by (intro p.mult_of.multiplicity_ge_iff a b c)
also have "... \<longleftrightarrow> d [^]\<^bsub>P\<^esub> k pdivides\<^bsub>R\<^esub> f"
using p.divides_imp_divides_mult[OF d assms(2)]
using divides_mult_imp_divides
unfolding pdivides_def nat_pow_mult_of
by auto
finally show ?thesis by simp
qed
lemma multiplicity_ge_1_iff_pdivides:
assumes "monic_irreducible_poly R d" "f \<in> carrier P - {\<zero>\<^bsub>P\<^esub>}"
shows "pmult d f \<ge> 1 \<longleftrightarrow> d pdivides f"
proof -
have "d \<in> carrier P"
using assms(1) monic_poly_carr
unfolding monic_irreducible_poly_def
by simp
thus ?thesis
using multiplicity_ge_iff[OF assms, where k="1"]
by simp
qed
lemma divides_monic_poly:
assumes "monic_poly R f" "monic_poly R g"
assumes "\<And>d. monic_irreducible_poly R d
\<Longrightarrow> pmult d f \<le> pmult d g"
shows "f pdivides g"
proof -
have a:"f \<in> carrier (mult_of P)" "g \<in> carrier (mult_of P)"
using monic_poly_carr_2 assms(1,2) by auto
have "f divides\<^bsub>(mult_of P)\<^esub> g"
using assms(3) unfolding pmult_def
by (intro p.mult_of.divides_iff_mult_mono
[OF a monic_polys_are_canonical_irreducibles]) simp
thus ?thesis
unfolding pdivides_def using divides_mult_imp_divides by simp
qed
end
lemma monic_poly_hom:
assumes "monic_poly R f"
assumes "h \<in> ring_iso R S" "domain R" "domain S"
shows "monic_poly S (map h f)"
proof -
have c: "h \<in> ring_hom R S"
using assms(2) ring_iso_def by auto
have e: "f \<in> carrier (poly_ring R)"
using assms(1) unfolding monic_poly_def by simp
have a:"f \<noteq> []"
using assms(1) unfolding monic_poly_def by simp
hence "map h f \<noteq> []" by simp
moreover have "lead_coeff f = \<one>\<^bsub>R\<^esub>"
using assms(1) unfolding monic_poly_def by simp
hence "lead_coeff (map h f) = \<one>\<^bsub>S\<^esub>"
using ring_hom_one[OF c] by (simp add: hd_map[OF a])
ultimately show ?thesis
using carrier_hom[OF e assms(2-4)]
unfolding monic_poly_def by simp
qed
lemma monic_irreducible_poly_hom:
assumes "monic_irreducible_poly R f"
assumes "h \<in> ring_iso R S" "domain R" "domain S"
shows "monic_irreducible_poly S (map h f)"
proof -
have a:
"pirreducible\<^bsub>R\<^esub> (carrier R) f"
"f \<in> carrier (poly_ring R)"
"monic_poly R f"
using assms(1)
unfolding monic_poly_def monic_irreducible_poly_def
by auto
have "pirreducible\<^bsub>S\<^esub> (carrier S) (map h f)"
using a pirreducible_hom assms by auto
moreover have "monic_poly S (map h f)"
using a monic_poly_hom[OF _ assms(2,3,4)] by simp
ultimately show ?thesis
unfolding monic_irreducible_poly_def by simp
qed
end
|
#include <boost/regex/icu.hpp>
#include <unicode/unistr.h>
int main()
{
UnicodeString ustr;
try {
boost::u32regex pattern = boost::make_u32regex(ustr);
}
// an exception is fine, still indicates support is
// likely compiled into regex
catch (...) {
return 0;
}
return 0;
}
|
lemma enum_inj: "i \<le> n \<Longrightarrow> j \<le> n \<Longrightarrow> enum i = enum j \<longleftrightarrow> i = j" |
/-
Copyright (c) Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import data.complex.module
import data.complex.is_R_or_C
/-!
# Normed space structure on `ℂ`.
This file gathers basic facts on complex numbers of an analytic nature.
## Main results
This file registers `ℂ` as a normed field, expresses basic properties of the norm, and gives
tools on the real vector space structure of `ℂ`. Notably, in the namespace `complex`,
it defines functions:
* `re_clm`
* `im_clm`
* `of_real_clm`
* `conj_clm`
They are bundled versions of the real part, the imaginary part, the embedding of `ℝ` in `ℂ`, and
the complex conjugate as continuous `ℝ`-linear maps. The last two are also bundled as linear
isometries in `of_real_li` and `conj_li`.
We also register the fact that `ℂ` is an `is_R_or_C` field.
-/
noncomputable theory
namespace complex
instance : has_norm ℂ := ⟨abs⟩
instance : normed_group ℂ :=
normed_group.of_core ℂ
{ norm_eq_zero_iff := λ z, abs_eq_zero,
triangle := abs_add,
norm_neg := abs_neg }
instance : normed_field ℂ :=
{ norm := abs,
dist_eq := λ _ _, rfl,
norm_mul' := abs_mul,
.. complex.field }
instance : nondiscrete_normed_field ℂ :=
{ non_trivial := ⟨2, by simp [norm]; norm_num⟩ }
instance {R : Type*} [normed_field R] [normed_algebra R ℝ] : normed_algebra R ℂ :=
{ norm_algebra_map_eq := λ x, (abs_of_real $ algebra_map R ℝ x).trans (norm_algebra_map_eq ℝ x),
to_algebra := complex.algebra }
@[simp] lemma norm_eq_abs (z : ℂ) : ∥z∥ = abs z := rfl
lemma dist_eq (z w : ℂ) : dist z w = abs (z - w) := rfl
@[simp] lemma norm_real (r : ℝ) : ∥(r : ℂ)∥ = ∥r∥ := abs_of_real _
@[simp] lemma norm_rat (r : ℚ) : ∥(r : ℂ)∥ = _root_.abs (r : ℝ) :=
suffices ∥((r : ℝ) : ℂ)∥ = _root_.abs r, by simpa,
by rw [norm_real, real.norm_eq_abs]
@[simp] lemma norm_nat (n : ℕ) : ∥(n : ℂ)∥ = n := abs_of_nat _
@[simp] lemma norm_int {n : ℤ} : ∥(n : ℂ)∥ = _root_.abs n :=
suffices ∥((n : ℝ) : ℂ)∥ = _root_.abs n, by simpa,
by rw [norm_real, real.norm_eq_abs]
lemma norm_int_of_nonneg {n : ℤ} (hn : 0 ≤ n) : ∥(n : ℂ)∥ = n :=
by rw [norm_int, _root_.abs_of_nonneg]; exact int.cast_nonneg.2 hn
open continuous_linear_map
/-- Continuous linear map version of the real part function, from `ℂ` to `ℝ`. -/
def re_clm : ℂ →L[ℝ] ℝ := re_lm.mk_continuous 1 (λ x, by simp [real.norm_eq_abs, abs_re_le_abs])
@[continuity] lemma continuous_re : continuous re := re_clm.continuous
@[simp] lemma re_clm_coe : (coe (re_clm) : ℂ →ₗ[ℝ] ℝ) = re_lm := rfl
@[simp]
@[simp] lemma re_clm_norm : ∥re_clm∥ = 1 :=
le_antisymm (linear_map.mk_continuous_norm_le _ zero_le_one _) $
calc 1 = ∥re_clm 1∥ : by simp
... ≤ ∥re_clm∥ : unit_le_op_norm _ _ (by simp)
/-- Continuous linear map version of the real part function, from `ℂ` to `ℝ`. -/
def im_clm : ℂ →L[ℝ] ℝ := im_lm.mk_continuous 1 (λ x, by simp [real.norm_eq_abs, abs_im_le_abs])
@[continuity] lemma continuous_im : continuous im := im_clm.continuous
@[simp] lemma im_clm_coe : (coe (im_clm) : ℂ →ₗ[ℝ] ℝ) = im_lm := rfl
@[simp] lemma im_clm_apply (z : ℂ) : (im_clm : ℂ → ℝ) z = z.im := rfl
@[simp] lemma im_clm_norm : ∥im_clm∥ = 1 :=
le_antisymm (linear_map.mk_continuous_norm_le _ zero_le_one _) $
calc 1 = ∥im_clm I∥ : by simp
... ≤ ∥im_clm∥ : unit_le_op_norm _ _ (by simp)
/-- The complex-conjugation function from `ℂ` to itself is an isometric linear map. -/
def conj_li : ℂ →ₗᵢ[ℝ] ℂ := ⟨conj_lm, λ x, by simp⟩
/-- Continuous linear map version of the conj function, from `ℂ` to `ℂ`. -/
def conj_clm : ℂ →L[ℝ] ℂ := conj_li.to_continuous_linear_map
lemma isometry_conj : isometry (conj : ℂ → ℂ) := conj_li.isometry
@[continuity] lemma continuous_conj : continuous conj := conj_clm.continuous
@[simp] lemma conj_clm_coe : (coe (conj_clm) : ℂ →ₗ[ℝ] ℂ) = conj_lm := rfl
@[simp] lemma conj_clm_apply (z : ℂ) : (conj_clm : ℂ → ℂ) z = z.conj := rfl
@[simp] lemma conj_clm_norm : ∥conj_clm∥ = 1 := conj_li.norm_to_continuous_linear_map
/-- Linear isometry version of the canonical embedding of `ℝ` in `ℂ`. -/
def of_real_li : ℝ →ₗᵢ[ℝ] ℂ := ⟨of_real_lm, λ x, by simp⟩
/-- Continuous linear map version of the canonical embedding of `ℝ` in `ℂ`. -/
def of_real_clm : ℝ →L[ℝ] ℂ := of_real_li.to_continuous_linear_map
lemma isometry_of_real : isometry (coe : ℝ → ℂ) := of_real_li.isometry
@[continuity] lemma continuous_of_real : continuous (coe : ℝ → ℂ) := isometry_of_real.continuous
@[simp] lemma of_real_clm_coe : (coe (of_real_clm) : ℝ →ₗ[ℝ] ℂ) = of_real_lm := rfl
@[simp] lemma of_real_clm_apply (x : ℝ) : (of_real_clm : ℝ → ℂ) x = x := rfl
@[simp] lemma of_real_clm_norm : ∥of_real_clm∥ = 1 := of_real_li.norm_to_continuous_linear_map
noncomputable instance : is_R_or_C ℂ :=
{ re := ⟨complex.re, complex.zero_re, complex.add_re⟩,
im := ⟨complex.im, complex.zero_im, complex.add_im⟩,
conj := complex.conj,
I := complex.I,
I_re_ax := by simp only [add_monoid_hom.coe_mk, complex.I_re],
I_mul_I_ax := by simp only [complex.I_mul_I, eq_self_iff_true, or_true],
re_add_im_ax := λ z, by simp only [add_monoid_hom.coe_mk, complex.re_add_im,
complex.coe_algebra_map, complex.of_real_eq_coe],
of_real_re_ax := λ r, by simp only [add_monoid_hom.coe_mk, complex.of_real_re,
complex.coe_algebra_map, complex.of_real_eq_coe],
of_real_im_ax := λ r, by simp only [add_monoid_hom.coe_mk, complex.of_real_im,
complex.coe_algebra_map, complex.of_real_eq_coe],
mul_re_ax := λ z w, by simp only [complex.mul_re, add_monoid_hom.coe_mk],
mul_im_ax := λ z w, by simp only [add_monoid_hom.coe_mk, complex.mul_im],
conj_re_ax := λ z, by simp only [ring_hom.coe_mk, add_monoid_hom.coe_mk, complex.conj_re],
conj_im_ax := λ z, by simp only [ring_hom.coe_mk, complex.conj_im, add_monoid_hom.coe_mk],
conj_I_ax := by simp only [complex.conj_I, ring_hom.coe_mk],
norm_sq_eq_def_ax := λ z, by simp only [←complex.norm_sq_eq_abs, ←complex.norm_sq_apply,
add_monoid_hom.coe_mk, complex.norm_eq_abs],
mul_im_I_ax := λ z, by simp only [mul_one, add_monoid_hom.coe_mk, complex.I_im],
inv_def_ax := λ z, by simp only [complex.inv_def, complex.norm_sq_eq_abs, complex.coe_algebra_map,
complex.of_real_eq_coe, complex.norm_eq_abs],
div_I_ax := complex.div_I }
end complex
namespace is_R_or_C
local notation `reC` := @is_R_or_C.re ℂ _
local notation `imC` := @is_R_or_C.im ℂ _
local notation `conjC` := @is_R_or_C.conj ℂ _
local notation `IC` := @is_R_or_C.I ℂ _
local notation `absC` := @is_R_or_C.abs ℂ _
local notation `norm_sqC` := @is_R_or_C.norm_sq ℂ _
@[simp] lemma re_to_complex {x : ℂ} : reC x = x.re := rfl
@[simp] lemma im_to_complex {x : ℂ} : imC x = x.im := rfl
@[simp] lemma conj_to_complex {x : ℂ} : conjC x = x.conj := rfl
@[simp] lemma I_to_complex : IC = complex.I := rfl
@[simp] lemma norm_sq_to_complex {x : ℂ} : norm_sqC x = complex.norm_sq x :=
by simp [is_R_or_C.norm_sq, complex.norm_sq]
@[simp] lemma abs_to_complex {x : ℂ} : absC x = complex.abs x :=
by simp [is_R_or_C.abs, complex.abs]
end is_R_or_C
|
[STATEMENT]
lemma Zn_order: "order (Z n) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. order (Z n) = n
[PROOF STEP]
by (unfold integer_mod_group_def integer_group_def order_def, auto) |
module Text.WebIDL.Types.Type
import Data.Bitraversable
import Data.Bifoldable
import Data.Traversable
import Text.WebIDL.Types.Attribute
import Text.WebIDL.Types.Identifier
import Generics.Derive
%language ElabReflection
||| BufferRelatedType ::
||| ArrayBuffer
||| DataView
||| Int8Array
||| Int16Array
||| Int32Array
||| Uint8Array
||| Uint16Array
||| Uint32Array
||| Uint8ClampedArray
||| Float32Array
||| Float64Array
public export
data BufferRelatedType = ArrayBuffer
| DataView
| Int8Array
| Int16Array
| Int32Array
| Uint8Array
| Uint16Array
| Uint32Array
| Uint8ClampedArray
| Float32Array
| Float64Array
%runElab derive "BufferRelatedType" [Generic,Meta,Eq,Show,HasAttributes]
||| StringType ::
||| ByteString
||| DOMString
||| USVString
public export
data StringType = ByteString
| DOMString
| USVString
%runElab derive "Type.StringType" [Generic,Meta,Eq,Show,HasAttributes]
public export
data IntType = Short | Long | LongLong
%runElab derive "Type.IntType" [Generic,Meta,Eq,Show,HasAttributes]
public export
data FloatType = Float | Dbl
%runElab derive "Type.FloatType" [Generic,Meta,Eq,Show,HasAttributes]
||| PrimitiveType ::
||| UnsignedIntegerType
||| UnrestrictedFloatType
||| undefined
||| boolean
||| byte
||| octet
||| bigint
||| UnrestrictedFloatType ::
||| unrestricted FloatType
||| FloatType
|||
||| FloatType ::
||| float
||| double
|||
||| UnsignedIntegerType ::
||| unsigned IntegerType
||| IntegerType
|||
||| IntegerType ::
||| short
||| long OptionalLong
|||
||| OptionalLong ::
||| long
||| ε
public export
data PrimitiveType = Unsigned IntType
| Signed IntType
| Unrestricted FloatType
| Restricted FloatType
| Undefined
| Boolean
| Byte
| Octet
| BigInt
%runElab derive "PrimitiveType" [Generic,Meta,Eq,Show,HasAttributes]
public export
data ConstTypeF a = CP PrimitiveType | CI a
%runElab derive "ConstTypeF" [Generic,Meta,Eq,Show,HasAttributes]
||| Null ::
||| ?
||| ε
public export
data Nullable a = MaybeNull a | NotNull a
%runElab derive "Nullable" [Generic,Meta,Eq,Show,HasAttributes]
export
nullVal : Nullable a -> a
nullVal (MaybeNull x) = x
nullVal (NotNull x) = x
export
nullable : Nullable a -> Nullable a
nullable = MaybeNull . nullVal
export
notNullable : Nullable a -> Nullable a
notNullable = NotNull . nullVal
export
isNullable : Nullable a -> Bool
isNullable (MaybeNull _) = True
isNullable (NotNull _) = False
mutual
||| Type ::
||| SingleType
||| UnionType Null
|||
||| SingleType ::
||| DistinguishableType
||| any
||| PromiseType
|||
||| PromiseType ::
||| Promise < Type >
public export
data IdlTypeF : (a : Type) -> (b : Type) -> Type where
Any : IdlTypeF a b
D : Nullable (DistinguishableF a b) -> IdlTypeF a b
U : Nullable (UnionTypeF a b) -> IdlTypeF a b
Promise : IdlTypeF a b -> IdlTypeF a b
||| UnionType ::
||| ( UnionMemberType or UnionMemberType UnionMemberTypes )
|||
||| UnionMemberTypes ::
||| or UnionMemberType UnionMemberTypes
||| ε
public export
record UnionTypeF (a : Type) (b : Type) where
constructor UT
fst : UnionMemberTypeF a b
snd : UnionMemberTypeF a b
rest : List (UnionMemberTypeF a b)
||| UnionMemberType ::
||| ExtendedAttributeList DistinguishableType
||| UnionType Null
public export
record UnionMemberTypeF (a : Type) (b : Type) where
constructor MkUnionMember
attr : a
type : DistinguishableF a b
||| DistinguishableType ::
||| PrimitiveType Null
||| StringType Null
||| identifier Null
||| sequence < TypeWithExtendedAttributes > Null
||| object Null
||| symbol Null
||| BufferRelatedType Null
||| FrozenArray < TypeWithExtendedAttributes > Null
||| ObservableArray < TypeWithExtendedAttributes > Null
||| RecordType Null
|||
||| RecordType ::
||| record < StringType , TypeWithExtendedAttributes >
public export
data DistinguishableF : (a : Type) -> (b : Type) -> Type where
P : PrimitiveType -> DistinguishableF a b
S : StringType -> DistinguishableF a b
I : b -> DistinguishableF a b
B : BufferRelatedType -> DistinguishableF a b
Sequence : a -> IdlTypeF a b -> DistinguishableF a b
FrozenArray : a -> IdlTypeF a b -> DistinguishableF a b
ObservableArray : a -> IdlTypeF a b -> DistinguishableF a b
Record : StringType -> a -> IdlTypeF a b -> DistinguishableF a b
Object : DistinguishableF a b
Symbol : DistinguishableF a b
%runElab deriveMutual [ ("DistinguishableF", [Generic,Meta,Show,Eq])
, ("UnionMemberTypeF", [Generic,Meta,Show,Eq])
, ("UnionTypeF", [Generic,Meta,Show,Eq])
, ("IdlTypeF", [Generic,Meta,Show,Eq])
]
public export
IdlType : Type
IdlType = IdlTypeF ExtAttributeList Identifier
public export
UnionType : Type
UnionType = UnionTypeF ExtAttributeList Identifier
public export
UnionMemberType : Type
UnionMemberType = UnionMemberTypeF ExtAttributeList Identifier
public export
Distinguishable : Type
Distinguishable = DistinguishableF ExtAttributeList Identifier
public export
ConstType : Type
ConstType = ConstTypeF Identifier
||| OptionalType ::
||| , TypeWithExtendedAttributes
||| ε
public export
0 OptionalType : Type
OptionalType = Maybe (Attributed IdlType)
||| Wraps and `Indentifier` as a non-nullable type.
export
identToType : b -> IdlTypeF a b
identToType = D . NotNull . I
||| The `Undefined` type
export
undefined : IdlTypeF a b
undefined = D $ NotNull $ P Undefined
export
isUndefined : IdlTypeF a b -> Bool
isUndefined (D $ NotNull $ P Undefined) = True
isUndefined _ = False
export
domString : IdlTypeF a b
domString = D $ NotNull $ S DOMString
export
ulong : IdlTypeF a b
ulong = D $ NotNull $ P $ Unsigned Long
export
isIndex : IdlTypeF a b -> Bool
isIndex (D $ NotNull $ S DOMString) = True
isIndex (D $ NotNull $ P $ Unsigned Long) = True
isIndex _ = False
--------------------------------------------------------------------------------
-- Implementations
--------------------------------------------------------------------------------
mutual
export
Functor Nullable where map = mapDefault
export
Foldable Nullable where foldr = foldrDefault
export
Traversable Nullable where
traverse f (MaybeNull x) = MaybeNull <$> f x
traverse f (NotNull x) = NotNull <$> f x
mutual
export
Functor ConstTypeF where map = mapDefault
export
Foldable ConstTypeF where foldr = foldrDefault
export
Traversable ConstTypeF where
traverse _ (CP x) = pure (CP x)
traverse f (CI x) = CI <$> f x
mutual
export
Bifunctor DistinguishableF where bimap = assert_total bimapDefault
export
Bifoldable DistinguishableF where bifoldr = bifoldrDefault
export
Bitraversable DistinguishableF where
bitraverse _ _ (P x) = pure (P x)
bitraverse _ _ (S x) = pure (S x)
bitraverse _ g (I x) = I <$> g x
bitraverse _ _ (B x) = pure (B x)
bitraverse f g (Sequence x y) = [| Sequence (f x) (bitraverse f g y) |]
bitraverse f g (FrozenArray x y) = [| FrozenArray (f x) (bitraverse f g y) |]
bitraverse f g (ObservableArray x y) = [| ObservableArray (f x) (bitraverse f g y) |]
bitraverse f g (Record x y z) = [| Record (pure x) (f y) (bitraverse f g z) |]
bitraverse _ _ Object = pure Object
bitraverse _ _ Symbol = pure Symbol
export
Functor (DistinguishableF a) where map = bimap id
export
Foldable (DistinguishableF a) where foldr = bifoldr (const id)
export
Traversable (DistinguishableF a) where traverse = bitraverse pure
export
Bifunctor UnionMemberTypeF where bimap = assert_total bimapDefault
export
Bifoldable UnionMemberTypeF where bifoldr = bifoldrDefault
export
Bitraversable UnionMemberTypeF where
bitraverse f g (MkUnionMember a t) =
[| MkUnionMember (f a) (bitraverse f g t) |]
export
Functor (UnionMemberTypeF a) where map = bimap id
export
Foldable (UnionMemberTypeF a) where foldr = bifoldr (const id)
export
Traversable (UnionMemberTypeF a) where traverse = bitraverse pure
export
Bifunctor UnionTypeF where bimap = assert_total bimapDefault
export
Bifoldable UnionTypeF where bifoldr = bifoldrDefault
export
Bitraversable UnionTypeF where
bitraverse f g (UT a b ts) =
[| UT (bitraverse f g a) (bitraverse f g b)
(traverse (bitraverse f g) ts) |]
export
Functor (UnionTypeF a) where map = bimap id
export
Foldable (UnionTypeF a) where foldr = bifoldr (const id)
export
Traversable (UnionTypeF a) where traverse = bitraverse pure
export
Bifunctor IdlTypeF where bimap = assert_total bimapDefault
export
Bifoldable IdlTypeF where bifoldr = bifoldrDefault
export
Bitraversable IdlTypeF where
bitraverse f g Any = pure Any
bitraverse f g (D x) = D <$> traverse (bitraverse f g) x
bitraverse f g (U x) = U <$> traverse (bitraverse f g) x
bitraverse f g (Promise x) = Promise <$> bitraverse f g x
export
Functor (IdlTypeF a) where map = bimap id
export
Foldable (IdlTypeF a) where foldr = bifoldr (const id)
export
Traversable (IdlTypeF a) where traverse = bitraverse pure
export
HasAttributes a => HasAttributes (IdlTypeF a b) where
attributes = bifoldMap attributes (const Nil)
|
Formal statement is: lemma is_unit_monom_0: fixes a :: "'a::field" assumes "a \<noteq> 0" shows "is_unit (monom a 0)" Informal statement is: If $a \neq 0$, then $a$ is a unit in the polynomial ring $\mathbb{Z}[x]$. |
[STATEMENT]
lemma w_value_greater: "vs0 \<le> w_value P vs0 ob"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. vs0 \<le> w_value P vs0 ob
[PROOF STEP]
by(rule le_funI)(rule w_value_mono) |
theory T141
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. undr(meet(x, y), z) = join(undr(x, z), undr(y, z))) &
(\<forall> x::nat. \<forall> y::nat. invo(join(x, y)) = meet(invo(x), invo(y))) &
(\<forall> x::nat. \<forall> y::nat. invo(meet(x, y)) = join(invo(x), invo(y))) &
(\<forall> x::nat. invo(invo(x)) = x)
) \<longrightarrow>
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. over(x, meet(y, z)) = join(over(x, y), over(x, z)))
"
nitpick[card nat=4,timeout=86400]
oops
end |
theory T37
imports Main
begin
lemma "(
(\<forall> x::nat. \<forall> y::nat. meet(x, y) = meet(y, x)) &
(\<forall> x::nat. \<forall> y::nat. join(x, y) = join(y, x)) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(x, meet(y, z)) = meet(meet(x, y), z)) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(x, join(y, z)) = join(join(x, y), z)) &
(\<forall> x::nat. \<forall> y::nat. meet(x, join(x, y)) = x) &
(\<forall> x::nat. \<forall> y::nat. join(x, meet(x, y)) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(x, join(y, z)) = join(mult(x, y), mult(x, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(join(x, y), z) = join(mult(x, z), mult(y, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(x, over(join(mult(x, y), z), y)) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(y, undr(x, join(mult(x, y), z))) = y) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(mult(over(x, y), y), x) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(mult(y, undr(y, x)), x) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(x, meet(y, z)) = meet(mult(x, y), mult(x, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. over(join(x, y), z) = join(over(x, z), over(y, z))) &
(\<forall> x::nat. \<forall> y::nat. 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. mult(meet(x, y), z) = meet(mult(x, z), mult(y, z)))
"
nitpick[card nat=4,timeout=86400]
oops
end |
Require Import GeoCoq.Axioms.continuity_axioms.
Require Import GeoCoq.Meta_theory.Continuity.first_order.
Require Import GeoCoq.Meta_theory.Continuity.first_order_dedekind_circle_circle.
Require Import GeoCoq.Meta_theory.Continuity.elementary_continuity_props.
Require Import GeoCoq.Tarski_dev.Ch05_bet_le.
Section Tarski_continuous_to_TRC.
Context `{TC:Tarski_continuous}.
Instance TC_to_TRC : Tarski_ruler_and_compass TnEQD.
Proof.
split.
apply circle_circle_bis__circle_circle_axiom, circle_circle__circle_circle_bis, fod__circle_circle, dedekind__fod.
unfold dedekind_s_axiom.
exact continuity.
Defined.
End Tarski_continuous_to_TRC. |
/-
Copyright (c) 2022 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import algebra.group.pi
import category_theory.limits.shapes.biproducts
import algebra.category.Module.limits
import algebra.category.Module.abelian
import algebra.homology.short_exact.abelian
/-!
# The category of `R`-modules has finite biproducts
-/
open category_theory
open category_theory.limits
open_locale big_operators
universes w v u
namespace Module
variables {R : Type u} [ring R]
-- As `Module R` is preadditive, and has all limits, it automatically has biproducts.
instance : has_binary_biproducts (Module.{v} R) :=
has_binary_biproducts.of_has_binary_products
instance : has_finite_biproducts (Module.{v} R) :=
has_finite_biproducts.of_has_finite_products
-- We now construct explicit limit data,
-- so we can compare the biproducts to the usual unbundled constructions.
/--
Construct limit data for a binary product in `Module R`, using `Module.of R (M × N)`.
-/
@[simps cone_X is_limit_lift]
def binary_product_limit_cone (M N : Module.{v} R) : limits.limit_cone (pair M N) :=
{ cone :=
{ X := Module.of R (M × N),
π :=
{ app := λ j, discrete.cases_on j
(λ j, walking_pair.cases_on j (linear_map.fst R M N) (linear_map.snd R M N)),
naturality' := by rintros ⟨⟨⟩⟩ ⟨⟨⟩⟩ ⟨⟨⟨⟩⟩⟩; refl, }},
is_limit :=
{ lift := λ s, linear_map.prod (s.π.app ⟨walking_pair.left⟩) (s.π.app ⟨walking_pair.right⟩),
fac' := by { rintros s (⟨⟩|⟨⟩); { ext x, simp only
[binary_fan.π_app_right, binary_fan.π_app_left, Module.coe_comp, function.comp_app,
linear_map.fst_apply, linear_map.snd_apply, linear_map.prod_apply, pi.prod], }, },
uniq' := λ s m w,
begin
ext; [rw ← w ⟨walking_pair.left⟩, rw ← w ⟨walking_pair.right⟩]; refl,
end, } }
@[simp] lemma binary_product_limit_cone_cone_π_app_left (M N : Module.{v} R) :
(binary_product_limit_cone M N).cone.π.app ⟨walking_pair.left⟩ = linear_map.fst R M N := rfl
@[simp] lemma binary_product_limit_cone_cone_π_app_right (M N : Module.{v} R) :
(binary_product_limit_cone M N).cone.π.app ⟨walking_pair.right⟩ = linear_map.snd R M N := rfl
/--
We verify that the biproduct in `Module R` is isomorphic to
the cartesian product of the underlying types:
-/
@[simps hom_apply] noncomputable
def biprod_iso_prod (M N : Module.{v} R) : (M ⊞ N : Module.{v} R) ≅ Module.of R (M × N) :=
is_limit.cone_point_unique_up_to_iso
(binary_biproduct.is_limit M N)
(binary_product_limit_cone M N).is_limit
@[simp, elementwise] lemma biprod_iso_prod_inv_comp_fst (M N : Module.{v} R) :
(biprod_iso_prod M N).inv ≫ biprod.fst = linear_map.fst R M N :=
is_limit.cone_point_unique_up_to_iso_inv_comp _ _ (discrete.mk walking_pair.left)
@[simp, elementwise] lemma biprod_iso_prod_inv_comp_snd (M N : Module.{v} R) :
(biprod_iso_prod M N).inv ≫ biprod.snd = linear_map.snd R M N :=
is_limit.cone_point_unique_up_to_iso_inv_comp _ _ (discrete.mk walking_pair.right)
namespace has_limit
variables {J : Type w} (f : J → Module.{max w v} R)
/--
The map from an arbitrary cone over a indexed family of abelian groups
to the cartesian product of those groups.
-/
@[simps]
def lift (s : fan f) :
s.X ⟶ Module.of R (Π j, f j) :=
{ to_fun := λ x j, s.π.app ⟨j⟩ x,
map_add' := λ x y, by { ext, simp, },
map_smul' := λ r x, by { ext, simp, }, }
/--
Construct limit data for a product in `Module R`, using `Module.of R (Π j, F.obj j)`.
-/
@[simps] def product_limit_cone : limits.limit_cone (discrete.functor f) :=
{ cone :=
{ X := Module.of R (Π j, f j),
π := discrete.nat_trans (λ j, (linear_map.proj j.as : (Π j, f j) →ₗ[R] f j.as)), },
is_limit :=
{ lift := lift f,
fac' := λ s j, by { cases j, ext, simp, },
uniq' := λ s m w,
begin
ext x j,
dsimp only [has_limit.lift],
simp only [linear_map.coe_mk],
exact congr_arg (λ g : s.X ⟶ f j, (g : s.X → f j) x) (w ⟨j⟩),
end, }, }
end has_limit
open has_limit
variables {J : Type} (f : J → Module.{v} R)
/--
We verify that the biproduct we've just defined is isomorphic to the `Module R` structure
on the dependent function type
-/
@[simps hom_apply] noncomputable
def biproduct_iso_pi [fintype J] (f : J → Module.{v} R) :
(⨁ f : Module.{v} R) ≅ Module.of R (Π j, f j) :=
is_limit.cone_point_unique_up_to_iso
(biproduct.is_limit f)
(product_limit_cone f).is_limit
@[simp, elementwise] lemma biproduct_iso_pi_inv_comp_π [fintype J]
(f : J → Module.{v} R) (j : J) :
(biproduct_iso_pi f).inv ≫ biproduct.π f j = (linear_map.proj j : (Π j, f j) →ₗ[R] f j) :=
is_limit.cone_point_unique_up_to_iso_inv_comp _ _ (discrete.mk j)
end Module
section split_exact
variables {R : Type u} {A M B : Type v} [ring R] [add_comm_group A] [module R A]
[add_comm_group B] [module R B] [add_comm_group M] [module R M]
variables {j : A →ₗ[R] M} {g : M →ₗ[R] B}
open Module
/--The isomorphism `A × B ≃ₗ[R] M` coming from a right split exact sequence `0 ⟶ A ⟶ M ⟶ B ⟶ 0`
of modules.-/
noncomputable def lequiv_prod_of_right_split_exact {f : B →ₗ[R] M}
(hj : function.injective j) (exac : j.range = g.ker) (h : g.comp f = linear_map.id) :
(A × B) ≃ₗ[R] M :=
(({ right_split := ⟨as_hom f, h⟩,
mono := (Module.mono_iff_injective $ as_hom j).mpr hj,
exact := (exact_iff _ _).mpr exac } : right_split _ _).splitting.iso.trans $
biprod_iso_prod _ _).to_linear_equiv.symm
/--The isomorphism `A × B ≃ₗ[R] M` coming from a left split exact sequence `0 ⟶ A ⟶ M ⟶ B ⟶ 0`
of modules.-/
noncomputable def lequiv_prod_of_left_split_exact {f : M →ₗ[R] A}
(hg : function.surjective g) (exac : j.range = g.ker) (h : f.comp j = linear_map.id) :
(A × B) ≃ₗ[R] M :=
(({ left_split := ⟨as_hom f, h⟩,
epi := (Module.epi_iff_surjective $ as_hom g).mpr hg,
exact := (exact_iff _ _).mpr exac } : left_split _ _).splitting.iso.trans $
biprod_iso_prod _ _).to_linear_equiv.symm
end split_exact
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Monoid.MorphismProperties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.SIP
open import Cubical.Foundations.Function using (_∘_; id)
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Functions.Embedding
open import Cubical.Data.Sigma
open import Cubical.Algebra
open import Cubical.Algebra.Properties
open import Cubical.Algebra.Monoid.Morphism
open import Cubical.Structures.Axioms
open import Cubical.Structures.Auto
open import Cubical.Structures.Pointed
open import Cubical.Algebra.Semigroup.Properties using (isPropIsSemigroup)
open import Cubical.Relation.Binary.Reasoning.Equality
open Iso
private
variable
ℓ ℓ′ ℓ′′ : Level
L : Monoid ℓ
M : Monoid ℓ′
N : Monoid ℓ′′
isPropIsMonoidHom : ∀ (M : Monoid ℓ) (N : Monoid ℓ′) f → isProp (IsMonoidHom M N f)
isPropIsMonoidHom M N f (ismonoidhom aOp aId) (ismonoidhom bOp bId) =
cong₂ ismonoidhom
(isPropHomomorphic₂ (Monoid.is-set N) f (Monoid._•_ M) (Monoid._•_ N) aOp bOp)
(isPropHomomorphic₀ (Monoid.is-set N) f (Monoid.ε M) (Monoid.ε N) aId bId)
isSetMonoidHom : isSet (M ⟶ᴴ N)
isSetMonoidHom {M = M} {N = N} = isOfHLevelRespectEquiv 2 equiv
(isSetΣ (isSetΠ λ _ → is-set N)
(λ f → isProp→isSet (isPropIsMonoidHom M N f)))
where
open Monoid
equiv : (Σ[ g ∈ (⟨ M ⟩ → ⟨ N ⟩) ] IsMonoidHom M N g) ≃ MonoidHom M N
equiv = isoToEquiv (iso (λ (g , m) → monoidhom g m) (λ (monoidhom g m) → g , m) (λ _ → refl) λ _ → refl)
isMonoidHomComp : {f : ⟨ L ⟩ → ⟨ M ⟩} {g : ⟨ M ⟩ → ⟨ N ⟩}
→ IsMonoidHom L M f → IsMonoidHom M N g → IsMonoidHom L N (g ∘ f)
isMonoidHomComp {g = g} (ismonoidhom fOp fId) (ismonoidhom gOp gId) =
ismonoidhom (λ _ _ → cong g (fOp _ _) ∙ gOp _ _) (cong g fId ∙ gId)
private
isMonoidHomComp′ : (f : L ⟶ᴴ M) (g : M ⟶ᴴ N)
→ IsMonoidHom L N (MonoidHom.fun g ∘ MonoidHom.fun f)
isMonoidHomComp′ (monoidhom f (ismonoidhom fOp fId)) (monoidhom g (ismonoidhom gOp gId)) =
ismonoidhom (λ _ _ → cong g (fOp _ _) ∙ gOp _ _) (cong g fId ∙ gId)
compMonoidHom : (L ⟶ᴴ M) → (M ⟶ᴴ N) → (L ⟶ᴴ N)
compMonoidHom f g = monoidhom _ (isMonoidHomComp′ f g)
compMonoidEquiv : L ≃ᴴ M → M ≃ᴴ N → L ≃ᴴ N
compMonoidEquiv f g = monoidequiv (compEquiv f.eq g.eq) (isMonoidHomComp′ f.hom g.hom)
where
module f = MonoidEquiv f
module g = MonoidEquiv g
isMonoidHomId : (M : Monoid ℓ) → IsMonoidHom M M id
isMonoidHomId M = record
{ preservesOp = λ _ _ → refl
; preservesId = refl
}
idMonoidHom : (M : Monoid ℓ) → (M ⟶ᴴ M)
idMonoidHom M = record
{ fun = id
; isHom = isMonoidHomId M
}
idMonoidEquiv : (M : Monoid ℓ) → M ≃ᴴ M
idMonoidEquiv M = record
{ eq = idEquiv ⟨ M ⟩
; isHom = isMonoidHomId M
}
-- Isomorphism inversion
isMonoidHomInv : (eqv : M ≃ᴴ N) → IsMonoidHom N M (invEq (MonoidEquiv.eq eqv))
isMonoidHomInv {M = M} {N = N} (monoidequiv eq (ismonoidhom hOp hId)) = ismonoidhom
(λ x y → isInj-f (
f (f⁻¹ (x N.• y)) ≡⟨ retEq eq _ ⟩
x N.• y ≡˘⟨ cong₂ N._•_ (retEq eq x) (retEq eq y) ⟩
f (f⁻¹ x) N.• f (f⁻¹ y) ≡˘⟨ hOp (f⁻¹ x) (f⁻¹ y) ⟩
f (f⁻¹ x M.• f⁻¹ y) ∎))
(isInj-f (
f (f⁻¹ N.ε) ≡⟨ retEq eq _ ⟩
N.ε ≡˘⟨ hId ⟩
f M.ε ∎))
where
module M = Monoid M
module N = Monoid N
f = equivFun eq
f⁻¹ = invEq eq
isInj-f : {x y : ⟨ M ⟩} → f x ≡ f y → x ≡ y
isInj-f {x} {y} = invEq (_ , isEquiv→isEmbedding (eq .snd) x y)
invMonoidHom : M ≃ᴴ N → (N ⟶ᴴ M)
invMonoidHom eq = record { isHom = isMonoidHomInv eq }
invMonoidEquiv : M ≃ᴴ N → N ≃ᴴ M
invMonoidEquiv eq = record
{ eq = invEquiv (MonoidEquiv.eq eq)
; isHom = isMonoidHomInv eq
}
monoidHomEq : {f g : M ⟶ᴴ N} → MonoidHom.fun f ≡ MonoidHom.fun g → f ≡ g
monoidHomEq {M = M} {N = N} {monoidhom f fm} {monoidhom g gm} p i =
monoidhom (p i) (p-hom i)
where
p-hom : PathP (λ i → IsMonoidHom M N (p i)) fm gm
p-hom = toPathP (isPropIsMonoidHom M N _ _ _)
monoidEquivEq : {f g : M ≃ᴴ N} → MonoidEquiv.eq f ≡ MonoidEquiv.eq g → f ≡ g
monoidEquivEq {M = M} {N = N} {monoidequiv f fm} {monoidequiv g gm} p i =
monoidequiv (p i) (p-hom i)
where
p-hom : PathP (λ i → IsMonoidHom M N (p i .fst)) fm gm
p-hom = toPathP (isPropIsMonoidHom M N _ _ _)
module MonoidΣTheory {ℓ} where
RawMonoidStructure : Type ℓ → Type ℓ
RawMonoidStructure X = (X → X → X) × X
RawMonoidEquivStr = AutoEquivStr RawMonoidStructure
rawMonoidUnivalentStr : UnivalentStr _ RawMonoidEquivStr
rawMonoidUnivalentStr = autoUnivalentStr RawMonoidStructure
MonoidAxioms : (M : Type ℓ) → RawMonoidStructure M → Type ℓ
MonoidAxioms M (_•_ , ε) = IsSemigroup M _•_ × Identity ε _•_
MonoidStructure : Type ℓ → Type ℓ
MonoidStructure = AxiomsStructure RawMonoidStructure MonoidAxioms
MonoidΣ : Type (ℓ-suc ℓ)
MonoidΣ = TypeWithStr ℓ MonoidStructure
isPropMonoidAxioms : (M : Type ℓ) (s : RawMonoidStructure M) → isProp (MonoidAxioms M s)
isPropMonoidAxioms M (_•_ , ε) = isPropΣ isPropIsSemigroup
λ isSemiM → isPropIdentity (IsSemigroup.is-set isSemiM) _•_ ε
MonoidEquivStr : StrEquiv MonoidStructure ℓ
MonoidEquivStr = AxiomsEquivStr RawMonoidEquivStr MonoidAxioms
MonoidAxiomsIsoIsMonoid : {M : Type ℓ} (s : RawMonoidStructure M) →
Iso (MonoidAxioms M s) (IsMonoid M (s .fst) (s .snd))
fun (MonoidAxiomsIsoIsMonoid s) (x , y) = ismonoid x y
inv (MonoidAxiomsIsoIsMonoid s) (ismonoid x y) = (x , y)
rightInv (MonoidAxiomsIsoIsMonoid s) _ = refl
leftInv (MonoidAxiomsIsoIsMonoid s) _ = refl
MonoidAxioms≡IsMonoid : {M : Type ℓ} (s : RawMonoidStructure M) →
MonoidAxioms M s ≡ IsMonoid M (s .fst) (s .snd)
MonoidAxioms≡IsMonoid s = isoToPath (MonoidAxiomsIsoIsMonoid s)
Monoid→MonoidΣ : Monoid ℓ → MonoidΣ
Monoid→MonoidΣ (mkmonoid M _•_ ε isMonoidM) =
M , (_•_ , ε) , MonoidAxiomsIsoIsMonoid (_•_ , ε) .inv isMonoidM
MonoidΣ→Monoid : MonoidΣ → Monoid ℓ
MonoidΣ→Monoid (M , (_•_ , ε) , isMonoidM) =
mkmonoid M _•_ ε (MonoidAxiomsIsoIsMonoid (_•_ , ε) .fun isMonoidM)
MonoidIsoMonoidΣ : Iso (Monoid ℓ) MonoidΣ
MonoidIsoMonoidΣ =
iso Monoid→MonoidΣ MonoidΣ→Monoid (λ _ → refl) (λ _ → refl)
monoidUnivalentStr : UnivalentStr MonoidStructure MonoidEquivStr
monoidUnivalentStr = axiomsUnivalentStr _ isPropMonoidAxioms rawMonoidUnivalentStr
MonoidΣPath : (M N : MonoidΣ) → (M ≃[ MonoidEquivStr ] N) ≃ (M ≡ N)
MonoidΣPath = SIP monoidUnivalentStr
MonoidEquivΣ : (M N : Monoid ℓ) → Type ℓ
MonoidEquivΣ M N = Monoid→MonoidΣ M ≃[ MonoidEquivStr ] Monoid→MonoidΣ N
MonoidIsoΣPath : {M N : Monoid ℓ} → Iso (MonoidEquiv M N) (MonoidEquivΣ M N)
fun MonoidIsoΣPath (monoidequiv eq (ismonoidhom hOp hId)) = (eq , hOp , hId)
inv MonoidIsoΣPath (eq , hOp , hId) = monoidequiv eq (ismonoidhom hOp hId)
rightInv MonoidIsoΣPath _ = refl
leftInv MonoidIsoΣPath _ = refl
MonoidPath : (M N : Monoid ℓ) → (MonoidEquiv M N) ≃ (M ≡ N)
MonoidPath M N =
MonoidEquiv M N ≃⟨ isoToEquiv MonoidIsoΣPath ⟩
MonoidEquivΣ M N ≃⟨ MonoidΣPath _ _ ⟩
Monoid→MonoidΣ M ≡ Monoid→MonoidΣ N ≃⟨ isoToEquiv (invIso (congIso MonoidIsoMonoidΣ)) ⟩
M ≡ N ■
RawMonoidΣ : Type (ℓ-suc ℓ)
RawMonoidΣ = TypeWithStr ℓ RawMonoidStructure
Monoid→RawMonoidΣ : Monoid ℓ → RawMonoidΣ
Monoid→RawMonoidΣ (mkmonoid A _•_ ε _) = A , _•_ , ε
InducedMonoid : (M : Monoid ℓ) (N : RawMonoidΣ) (e : M .Monoid.Carrier ≃ N .fst) →
RawMonoidEquivStr (Monoid→RawMonoidΣ M) N e → Monoid ℓ
InducedMonoid M N e r =
MonoidΣ→Monoid (inducedStructure rawMonoidUnivalentStr (Monoid→MonoidΣ M) N (e , r))
InducedMonoidPath : (M : Monoid ℓ) (N : RawMonoidΣ) (e : M .Monoid.Carrier ≃ N .fst)
(E : RawMonoidEquivStr (Monoid→RawMonoidΣ M) N e) →
M ≡ InducedMonoid M N e E
InducedMonoidPath M N e E =
MonoidPath M (InducedMonoid M N e E) .fst (monoidequiv e (ismonoidhom (E .fst) (E .snd)))
-- We now extract the important results from the above module
open MonoidΣTheory public using (InducedMonoid; InducedMonoidPath)
isPropIsMonoid : {M : Type ℓ} {_•_ : Op₂ M} {ε : M} → isProp (IsMonoid M _•_ ε)
isPropIsMonoid {_•_ = _•_} {ε} =
subst isProp (MonoidΣTheory.MonoidAxioms≡IsMonoid (_•_ , ε))
(MonoidΣTheory.isPropMonoidAxioms _ (_•_ , ε))
MonoidPath : (M ≃ᴴ N) ≃ (M ≡ N)
MonoidPath {M = M} {N} = MonoidΣTheory.MonoidPath M N
open Monoid
uaMonoid : M ≃ᴴ N → M ≡ N
uaMonoid = equivFun MonoidPath
carac-uaMonoid : {M N : Monoid ℓ} (f : M ≃ᴴ N) → cong Carrier (uaMonoid f) ≡ ua (MonoidEquiv.eq f)
carac-uaMonoid (monoidequiv f m) =
(refl ∙∙ ua f ∙∙ refl) ≡˘⟨ rUnit (ua f) ⟩
ua f ∎
Monoid≡ : (M N : Monoid ℓ) → (
Σ[ p ∈ ⟨ M ⟩ ≡ ⟨ N ⟩ ]
Σ[ q ∈ PathP (λ i → p i → p i → p i) (_•_ M) (_•_ N) ]
Σ[ r ∈ PathP (λ i → p i) (ε M) (ε N) ]
PathP (λ i → IsMonoid (p i) (q i) (r i)) (isMonoid M) (isMonoid N))
≃ (M ≡ N)
Monoid≡ M N = isoToEquiv (iso
(λ (p , q , r , s) i → mkmonoid (p i) (q i) (r i) (s i))
(λ p → cong Carrier p , cong _•_ p , cong ε p , cong isMonoid p)
(λ _ → refl) (λ _ → refl))
caracMonoid≡ : {M N : Monoid ℓ} (p q : M ≡ N) → cong Carrier p ≡ cong Carrier q → p ≡ q
caracMonoid≡ {M = M} {N} p q t = cong (fst (Monoid≡ M N)) (Σ≡Prop (λ _ →
isPropΣ
(isOfHLevelPathP' 1 (isSetΠ2 λ _ _ → is-set N) _ _) λ _ → isPropΣ
(isOfHLevelPathP' 1 (is-set N) _ _) λ _ →
isOfHLevelPathP 1 isPropIsMonoid _ _)
t)
uaMonoidId : (M : Monoid ℓ) → uaMonoid (idMonoidEquiv M) ≡ refl
uaMonoidId M = caracMonoid≡ _ _ (carac-uaMonoid (idMonoidEquiv M) ∙ uaIdEquiv)
uaCompMonoidEquiv : {L M N : Monoid ℓ} (f : L ≃ᴴ M) (g : M ≃ᴴ N)
→ uaMonoid (compMonoidEquiv f g) ≡ uaMonoid f ∙ uaMonoid g
uaCompMonoidEquiv f g = caracMonoid≡ _ _ (
cong Carrier (uaMonoid (compMonoidEquiv f g))
≡⟨ carac-uaMonoid (compMonoidEquiv f g) ⟩
ua (eq (compMonoidEquiv f g))
≡⟨ uaCompEquiv _ _ ⟩
ua (eq f) ∙ ua (eq g)
≡˘⟨ cong (_∙ ua (eq g)) (carac-uaMonoid f) ⟩
cong Carrier (uaMonoid f) ∙ ua (eq g)
≡˘⟨ cong (cong Carrier (uaMonoid f) ∙_) (carac-uaMonoid g) ⟩
cong Carrier (uaMonoid f) ∙ cong Carrier (uaMonoid g)
≡˘⟨ cong-∙ Carrier (uaMonoid f) (uaMonoid g) ⟩
cong Carrier (uaMonoid f ∙ uaMonoid g) ∎)
where open MonoidEquiv
|
[STATEMENT]
lemma optimize_matches_append: "optimize_matches f (rs1@rs2) = optimize_matches f rs1 @ optimize_matches f rs2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. optimize_matches f (rs1 @ rs2) = optimize_matches f rs1 @ optimize_matches f rs2
[PROOF STEP]
by(simp add: optimize_matches_def optimize_matches_option_append) |
module Test.Bits32
import Data.Prim.Bits32
import Data.SOP
import Hedgehog
import Test.RingLaws
allBits32 : Gen Bits32
allBits32 = bits32 (linear 0 0xffffffff)
gt0 : Gen Bits32
gt0 = bits32 (linear 1 MaxBits32)
gt1 : Gen Bits32
gt1 = bits32 (linear 2 MaxBits32)
prop_ltMax : Property
prop_ltMax = property $ do
b8 <- forAll allBits32
(b8 <= MaxBits32) === True
prop_ltMin : Property
prop_ltMin = property $ do
b8 <- forAll allBits32
(b8 >= MinBits32) === True
prop_comp : Property
prop_comp = property $ do
[m,n] <- forAll $ np [allBits32, allBits32]
toOrdering (comp m n) === compare m n
prop_mod : Property
prop_mod = property $ do
[n,d] <- forAll $ np [allBits32, gt0]
compare (n `mod` d) d === LT
prop_div : Property
prop_div = property $ do
[n,d] <- forAll $ np [gt0, gt1]
compare (n `div` d) n === LT
prop_divMod : Property
prop_divMod = property $ do
[n,d] <- forAll $ np [allBits32, gt0]
let x = n `div` d
r = n `mod` d
n === x * d + r
export
props : Group
props = MkGroup "Bits32" $
[ ("prop_ltMax", prop_ltMax)
, ("prop_ltMin", prop_ltMin)
, ("prop_comp", prop_comp)
, ("prop_mod", prop_mod)
, ("prop_div", prop_div)
, ("prop_divMod", prop_divMod)
] ++ ringProps allBits32
|
/-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import for_mathlib.dold_kan.projections
import category_theory.idempotents.functor_categories
import category_theory.idempotents.functor_extension
/-!
# Construction of the projection `P_infty` for the Dold-Kan correspondence
TODO (@joelriou) continue adding the various files referenced below
In this file, we construct the projection `P_infty : K[X] ⟶ K[X]` by passing
to the limit the projections `P q` defined in `projections.lean`. This
projection is a critical tool in this formalisation of the Dold-Kan correspondence,
because in the case of abelian categories, `P_infty` corresponds to the
projection on the normalized Moore subcomplex, with kernel the degenerate subcomplex.
(See `equivalence.lean` for the general strategy of proof.)
-/
open category_theory
open category_theory.category
open category_theory.preadditive
open category_theory.simplicial_object
open category_theory.idempotents
open opposite
open_locale simplicial dold_kan
noncomputable theory
namespace algebraic_topology
namespace dold_kan
variables {C : Type*} [category C] [preadditive C] {X : simplicial_object C}
lemma P_is_eventually_constant {q n : ℕ} (hqn : n ≤ q) :
((P (q+1)).f n : X _[n] ⟶ _ ) = (P q).f n :=
begin
cases n,
{ simp only [P_f_0_eq], },
{ unfold P,
simp only [add_right_eq_self, comp_add, homological_complex.comp_f,
homological_complex.add_f_apply, comp_id],
exact (higher_faces_vanish.of_P q n).comp_Hσ_eq_zero
(nat.succ_le_iff.mp hqn), },
end
lemma Q_is_eventually_constant {q n : ℕ} (hqn : n ≤ q) :
((Q (q+1)).f n : X _[n] ⟶ _ ) = (Q q).f n :=
by simp only [Q, homological_complex.sub_f_apply, P_is_eventually_constant hqn]
/-- The endomorphism `P_infty : K[X] ⟶ K[X]` obtained from the `P q` by passing to the limit. -/
def P_infty : K[X] ⟶ K[X] := chain_complex.of_hom _ _ _ _ _ _
(λ n, ((P n).f n : X _[n] ⟶ _ ))
(λ n, by simpa only [← P_is_eventually_constant (show n ≤ n, by refl),
alternating_face_map_complex.obj_d_eq] using (P (n+1)).comm (n+1) n)
/-- The endomorphism `Q_infty : K[X] ⟶ K[X]` obtained from the `Q q` by passing to the limit. -/
def Q_infty : K[X] ⟶ K[X] := 𝟙 _ - P_infty
@[simp]
lemma P_infty_f_0 : (P_infty.f 0 : X _[0] ⟶ X _[0]) = 𝟙 _ := rfl
lemma P_infty_f (n : ℕ) : (P_infty.f n : X _[n] ⟶ X _[n] ) = (P n).f n := rfl
@[simp]
lemma Q_infty_f_0 : (Q_infty.f 0 : X _[0] ⟶ X _[0]) = 0 :=
by { dsimp [Q_infty], simp only [sub_self], }
lemma Q_infty_f (n : ℕ) : (Q_infty.f n : X _[n] ⟶ X _[n] ) = (Q n).f n := rfl
@[simp, reassoc]
lemma P_infty_f_naturality (n : ℕ) {X Y : simplicial_object C} (f : X ⟶ Y) :
f.app (op [n]) ≫ P_infty.f n = P_infty.f n ≫ f.app (op [n]) :=
P_f_naturality n n f
@[simp, reassoc]
lemma Q_infty_f_naturality (n : ℕ) {X Y : simplicial_object C} (f : X ⟶ Y) :
f.app (op [n]) ≫ Q_infty.f n = Q_infty.f n ≫ f.app (op [n]) :=
Q_f_naturality n n f
@[simp, reassoc]
lemma P_infty_f_idem (n : ℕ) :
(P_infty.f n : X _[n] ⟶ _) ≫ (P_infty.f n) = P_infty.f n :=
by simp only [P_infty_f, P_f_idem]
@[simp, reassoc]
lemma P_infty_idem : (P_infty : K[X] ⟶ _) ≫ P_infty = P_infty :=
by { ext n, exact P_infty_f_idem n, }
@[simp, reassoc]
lemma Q_infty_f_idem (n : ℕ) :
(Q_infty.f n : X _[n] ⟶ _) ≫ (Q_infty.f n) = Q_infty.f n :=
Q_f_idem _ _
@[simp, reassoc]
lemma Q_infty_idem : (Q_infty : K[X] ⟶ _) ≫ Q_infty = Q_infty :=
by { ext n, exact Q_infty_f_idem n, }
@[simp, reassoc]
lemma P_infty_f_comp_Q_infty_f (n : ℕ) :
(P_infty.f n : X _[n] ⟶ _) ≫ Q_infty.f n = 0 :=
begin
dsimp only [Q_infty],
simp only [homological_complex.sub_f_apply, homological_complex.id_f, comp_sub, comp_id,
P_infty_f_idem, sub_self],
end
@[simp, reassoc]
lemma P_infty_comp_Q_infty :
(P_infty : K[X] ⟶ _) ≫ Q_infty = 0 :=
by { ext n, apply P_infty_f_comp_Q_infty_f, }
@[simp, reassoc]
lemma Q_infty_f_comp_P_infty_f (n : ℕ) :
(Q_infty.f n : X _[n] ⟶ _) ≫ P_infty.f n = 0 :=
begin
dsimp only [Q_infty],
simp only [homological_complex.sub_f_apply, homological_complex.id_f, sub_comp, id_comp,
P_infty_f_idem, sub_self],
end
@[simp, reassoc]
lemma Q_infty_comp_P_infty :
(Q_infty : K[X] ⟶ _) ≫ P_infty = 0 :=
by { ext n, apply Q_infty_f_comp_P_infty_f, }
@[simp]
lemma P_infty_add_Q_infty :
(P_infty : K[X] ⟶ _) + Q_infty = 𝟙 _ :=
by { dsimp only [Q_infty], simp only [add_sub_cancel'_right], }
lemma P_infty_f_add_Q_infty_f (n : ℕ) :
(P_infty.f n : X _[n] ⟶ _ ) + Q_infty.f n = 𝟙 _ :=
homological_complex.congr_hom (P_infty_add_Q_infty) n
variable (C)
/-- `P_infty` induces a natural transformation, i.e. an endomorphism of
the functor `alternating_face_map_complex C`. -/
@[simps]
def nat_trans_P_infty :
alternating_face_map_complex C ⟶ alternating_face_map_complex C :=
{ app := λ _, P_infty,
naturality' := λ X Y f, by { ext n, exact P_infty_f_naturality n f, }, }
/-- The natural transformation in each degree that is induced by `nat_trans_P_infty`. -/
@[simps]
def nat_trans_P_infty_f (n : ℕ) :=
nat_trans_P_infty C ◫ 𝟙 (homological_complex.eval _ _ n)
variable {C}
@[simp]
lemma map_P_infty_f {D : Type*} [category D] [preadditive D]
(G : C ⥤ D) [G.additive] (X : simplicial_object C) (n : ℕ) :
(P_infty : K[((whiskering C D).obj G).obj X] ⟶ _).f n =
G.map ((P_infty : alternating_face_map_complex.obj X ⟶ _).f n) :=
by simp only [P_infty_f, map_P]
/-- Given an object `Y : karoubi (simplicial_object C)`, this lemma
computes `P_infty` for the associated object in `simplicial_object (karoubi C)`
in terms of `P_infty` for `Y.X : simplicial_object C` and `Y.p`. -/
lemma karoubi_P_infty_f {Y : karoubi (simplicial_object C)} (n : ℕ) :
((P_infty : K[(karoubi_functor_category_embedding _ _).obj Y] ⟶ _).f n).f =
Y.p.app (op [n]) ≫ (P_infty : K[Y.X] ⟶ _).f n :=
begin
-- We introduce P_infty endomorphisms P₁, P₂, P₃, P₄ on various objects Y₁, Y₂, Y₃, Y₄.
let Y₁ := (karoubi_functor_category_embedding _ _).obj Y,
let Y₂ := Y.X,
let Y₃ := (((whiskering _ _).obj (to_karoubi C)).obj Y.X),
let Y₄ := (karoubi_functor_category_embedding _ _).obj ((to_karoubi _).obj Y.X),
let P₁ : K[Y₁] ⟶ _ := P_infty,
let P₂ : K[Y₂] ⟶ _ := P_infty,
let P₃ : K[Y₃] ⟶ _ := P_infty,
let P₄ : K[Y₄] ⟶ _ := P_infty,
-- The statement of lemma relates P₁ and P₂.
change (P₁.f n).f = Y.p.app (op [n]) ≫ P₂.f n,
-- The proof proceeds by obtaining relations h₃₂, h₄₃, h₁₄.
have h₃₂ : (P₃.f n).f = P₂.f n := karoubi.hom_ext.mp (map_P_infty_f (to_karoubi C) Y₂ n),
have h₄₃ : P₄.f n = P₃.f n,
{ have h := functor.congr_obj (to_karoubi_comp_karoubi_functor_category_embedding _ _) Y₂,
simp only [← nat_trans_P_infty_f_app],
congr', },
let τ₁ := 𝟙 (karoubi_functor_category_embedding (simplex_categoryᵒᵖ) C),
let τ₂ := nat_trans_P_infty_f (karoubi C) n,
let τ := τ₁ ◫ τ₂,
have h₁₄ := idempotents.nat_trans_eq τ Y,
dsimp [τ, τ₁, τ₂, nat_trans_P_infty_f] at h₁₄,
rw [id_comp, id_comp, comp_id, comp_id] at h₁₄,
/- We use the three equalities h₃₂, h₄₃, h₁₄. -/
rw [← h₃₂, ← h₄₃, h₁₄],
simp only [karoubi_functor_category_embedding.map_app_f, karoubi.decomp_id_p_f,
karoubi.decomp_id_i_f, karoubi.comp_f],
let π : Y₄ ⟶ Y₄ := (to_karoubi _ ⋙ karoubi_functor_category_embedding _ _).map Y.p,
have eq := karoubi.hom_ext.mp (P_infty_f_naturality n π),
simp only [karoubi.comp_f] at eq,
dsimp [π] at eq,
rw [← eq, reassoc_of (app_idem Y (op [n]))],
end
end dold_kan
end algebraic_topology
|
Formal statement is: lemma filterlim_subseq: "strict_mono f \<Longrightarrow> filterlim f sequentially sequentially" Informal statement is: If $f$ is a strictly monotone function, then $f$ is a filter limit of the sequence $f(n)$. |
(* Title: HOL/MicroJava/BV/Semilat.thy
Author: Tobias Nipkow
Copyright 2000 TUM
Semilattices.
*)
header {*
\chapter{Bytecode Verifier}\label{cha:bv}
\isaheader{Semilattices}
*}
theory Semilat
imports Main "~~/src/HOL/Library/While_Combinator"
begin
type_synonym 'a ord = "'a \<Rightarrow> 'a \<Rightarrow> bool"
type_synonym 'a binop = "'a \<Rightarrow> 'a \<Rightarrow> 'a"
type_synonym 'a sl = "'a set \<times> 'a ord \<times> 'a binop"
consts
"lesub" :: "'a \<Rightarrow> 'a ord \<Rightarrow> 'a \<Rightarrow> bool"
"lesssub" :: "'a \<Rightarrow> 'a ord \<Rightarrow> 'a \<Rightarrow> bool"
"plussub" :: "'a \<Rightarrow> ('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> 'b \<Rightarrow> 'c"
(*<*)
notation
"lesub" ("(_ /<='__ _)" [50, 1000, 51] 50) and
"lesssub" ("(_ /<'__ _)" [50, 1000, 51] 50) and
"plussub" ("(_ /+'__ _)" [65, 1000, 66] 65)
(*>*)
notation (xsymbols)
"lesub" ("(_ /\<sqsubseteq>\<^bsub>_\<^esub> _)" [50, 0, 51] 50) and
"lesssub" ("(_ /\<sqsubset>\<^bsub>_\<^esub> _)" [50, 0, 51] 50) and
"plussub" ("(_ /\<squnion>\<^bsub>_\<^esub> _)" [65, 0, 66] 65)
(*<*)
(* allow \<sub> instead of \<bsub>..\<esub> *)
abbreviation (input)
lesub1 :: "'a \<Rightarrow> 'a ord \<Rightarrow> 'a \<Rightarrow> bool" ("(_ /\<sqsubseteq>\<^sub>_ _)" [50, 1000, 51] 50)
where "x \<sqsubseteq>\<^sub>r y == x \<sqsubseteq>\<^bsub>r\<^esub> y"
abbreviation (input)
lesssub1 :: "'a \<Rightarrow> 'a ord \<Rightarrow> 'a \<Rightarrow> bool" ("(_ /\<sqsubset>\<^sub>_ _)" [50, 1000, 51] 50)
where "x \<sqsubset>\<^sub>r y == x \<sqsubset>\<^bsub>r\<^esub> y"
abbreviation (input)
plussub1 :: "'a \<Rightarrow> ('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> 'b \<Rightarrow> 'c" ("(_ /\<squnion>\<^sub>_ _)" [65, 1000, 66] 65)
where "x \<squnion>\<^sub>f y == x \<squnion>\<^bsub>f\<^esub> y"
(*>*)
defs
lesub_def: "x \<sqsubseteq>\<^sub>r y \<equiv> r x y"
lesssub_def: "x \<sqsubset>\<^sub>r y \<equiv> x \<sqsubseteq>\<^sub>r y \<and> x \<noteq> y"
plussub_def: "x \<squnion>\<^sub>f y \<equiv> f x y"
definition ord :: "('a \<times> 'a) set \<Rightarrow> 'a ord"
where
"ord r = (\<lambda>x y. (x,y) \<in> r)"
definition order :: "'a ord \<Rightarrow> bool"
where
"order r \<longleftrightarrow> (\<forall>x. x \<sqsubseteq>\<^sub>r x) \<and> (\<forall>x y. x \<sqsubseteq>\<^sub>r y \<and> y \<sqsubseteq>\<^sub>r x \<longrightarrow> x=y) \<and> (\<forall>x y z. x \<sqsubseteq>\<^sub>r y \<and> y \<sqsubseteq>\<^sub>r z \<longrightarrow> x \<sqsubseteq>\<^sub>r z)"
definition top :: "'a ord \<Rightarrow> 'a \<Rightarrow> bool"
where
"top r T \<longleftrightarrow> (\<forall>x. x \<sqsubseteq>\<^sub>r T)"
definition acc :: "'a ord \<Rightarrow> bool"
where
"acc r \<longleftrightarrow> wf {(y,x). x \<sqsubset>\<^sub>r y}"
definition closed :: "'a set \<Rightarrow> 'a binop \<Rightarrow> bool"
where
"closed A f \<longleftrightarrow> (\<forall>x\<in>A. \<forall>y\<in>A. x \<squnion>\<^sub>f y \<in> A)"
definition semilat :: "'a sl \<Rightarrow> bool"
where
"semilat = (\<lambda>(A,r,f). order r \<and> closed A f \<and>
(\<forall>x\<in>A. \<forall>y\<in>A. x \<sqsubseteq>\<^sub>r x \<squnion>\<^sub>f y) \<and>
(\<forall>x\<in>A. \<forall>y\<in>A. y \<sqsubseteq>\<^sub>r x \<squnion>\<^sub>f y) \<and>
(\<forall>x\<in>A. \<forall>y\<in>A. \<forall>z\<in>A. x \<sqsubseteq>\<^sub>r z \<and> y \<sqsubseteq>\<^sub>r z \<longrightarrow> x \<squnion>\<^sub>f y \<sqsubseteq>\<^sub>r z))"
definition is_ub :: "('a \<times> 'a) set \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool"
where
"is_ub r x y u \<longleftrightarrow> (x,u)\<in>r \<and> (y,u)\<in>r"
definition is_lub :: "('a \<times> 'a) set \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool"
where
"is_lub r x y u \<longleftrightarrow> is_ub r x y u \<and> (\<forall>z. is_ub r x y z \<longrightarrow> (u,z)\<in>r)"
definition some_lub :: "('a \<times> 'a) set \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a"
where
"some_lub r x y = (SOME z. is_lub r x y z)"
locale Semilat =
fixes A :: "'a set"
fixes r :: "'a ord"
fixes f :: "'a binop"
assumes semilat: "semilat (A, r, f)"
lemma order_refl [simp, intro]: "order r \<Longrightarrow> x \<sqsubseteq>\<^sub>r x"
(*<*) by (unfold order_def) (simp (no_asm_simp)) (*>*)
lemma order_antisym: "\<lbrakk> order r; x \<sqsubseteq>\<^sub>r y; y \<sqsubseteq>\<^sub>r x \<rbrakk> \<Longrightarrow> x = y"
(*<*) by (unfold order_def) (simp (no_asm_simp)) (*>*)
lemma order_trans: "\<lbrakk> order r; x \<sqsubseteq>\<^sub>r y; y \<sqsubseteq>\<^sub>r z \<rbrakk> \<Longrightarrow> x \<sqsubseteq>\<^sub>r z"
(*<*) by (unfold order_def) blast (*>*)
lemma order_less_irrefl [intro, simp]: "order r \<Longrightarrow> \<not> x \<sqsubset>\<^sub>r x"
(*<*) by (unfold order_def lesssub_def) blast (*>*)
lemma order_less_trans: "\<lbrakk> order r; x \<sqsubset>\<^sub>r y; y \<sqsubset>\<^sub>r z \<rbrakk> \<Longrightarrow> x \<sqsubset>\<^sub>r z"
(*<*) by (unfold order_def lesssub_def) blast (*>*)
lemma topD [simp, intro]: "top r T \<Longrightarrow> x \<sqsubseteq>\<^sub>r T"
(*<*) by (simp add: top_def) (*>*)
lemma top_le_conv [simp]: "\<lbrakk> order r; top r T \<rbrakk> \<Longrightarrow> (T \<sqsubseteq>\<^sub>r x) = (x = T)"
(*<*) by (blast intro: order_antisym) (*>*)
lemma semilat_Def:
"semilat(A,r,f) \<longleftrightarrow> order r \<and> closed A f \<and>
(\<forall>x\<in>A. \<forall>y\<in>A. x \<sqsubseteq>\<^sub>r x \<squnion>\<^sub>f y) \<and>
(\<forall>x\<in>A. \<forall>y\<in>A. y \<sqsubseteq>\<^sub>r x \<squnion>\<^sub>f y) \<and>
(\<forall>x\<in>A. \<forall>y\<in>A. \<forall>z\<in>A. x \<sqsubseteq>\<^sub>r z \<and> y \<sqsubseteq>\<^sub>r z \<longrightarrow> x \<squnion>\<^sub>f y \<sqsubseteq>\<^sub>r z)"
(*<*) by (unfold semilat_def) clarsimp (*>*)
lemma (in Semilat) orderI [simp, intro]: "order r"
(*<*) using semilat by (simp add: semilat_Def) (*>*)
lemma (in Semilat) closedI [simp, intro]: "closed A f"
(*<*) using semilat by (simp add: semilat_Def) (*>*)
lemma closedD: "\<lbrakk> closed A f; x\<in>A; y\<in>A \<rbrakk> \<Longrightarrow> x \<squnion>\<^sub>f y \<in> A"
(*<*) by (unfold closed_def) blast (*>*)
lemma closed_UNIV [simp]: "closed UNIV f"
(*<*) by (simp add: closed_def) (*>*)
lemma (in Semilat) closed_f [simp, intro]: "\<lbrakk>x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> x \<squnion>\<^sub>f y \<in> A"
(*<*) by (simp add: closedD [OF closedI]) (*>*)
lemma (in Semilat) refl_r [intro, simp]: "x \<sqsubseteq>\<^sub>r x" by simp
lemma (in Semilat) antisym_r [intro?]: "\<lbrakk> x \<sqsubseteq>\<^sub>r y; y \<sqsubseteq>\<^sub>r x \<rbrakk> \<Longrightarrow> x = y"
(*<*) by (rule order_antisym) auto (*>*)
lemma (in Semilat) trans_r [trans, intro?]: "\<lbrakk>x \<sqsubseteq>\<^sub>r y; y \<sqsubseteq>\<^sub>r z\<rbrakk> \<Longrightarrow> x \<sqsubseteq>\<^sub>r z"
(*<*) by (auto intro: order_trans) (*>*)
lemma (in Semilat) ub1 [simp, intro?]: "\<lbrakk> x \<in> A; y \<in> A \<rbrakk> \<Longrightarrow> x \<sqsubseteq>\<^sub>r x \<squnion>\<^sub>f y"
(*<*) by (insert semilat) (unfold semilat_Def, simp) (*>*)
lemma (in Semilat) ub2 [simp, intro?]: "\<lbrakk> x \<in> A; y \<in> A \<rbrakk> \<Longrightarrow> y \<sqsubseteq>\<^sub>r x \<squnion>\<^sub>f y"
(*<*) by (insert semilat) (unfold semilat_Def, simp) (*>*)
lemma (in Semilat) lub [simp, intro?]:
"\<lbrakk> x \<sqsubseteq>\<^sub>r z; y \<sqsubseteq>\<^sub>r z; x \<in> A; y \<in> A; z \<in> A \<rbrakk> \<Longrightarrow> x \<squnion>\<^sub>f y \<sqsubseteq>\<^sub>r z"
(*<*) by (insert semilat) (unfold semilat_Def, simp) (*>*)
lemma (in Semilat) plus_le_conv [simp]:
"\<lbrakk> x \<in> A; y \<in> A; z \<in> A \<rbrakk> \<Longrightarrow> (x \<squnion>\<^sub>f y \<sqsubseteq>\<^sub>r z) = (x \<sqsubseteq>\<^sub>r z \<and> y \<sqsubseteq>\<^sub>r z)"
(*<*) by (blast intro: ub1 ub2 lub order_trans) (*>*)
lemma (in Semilat) le_iff_plus_unchanged:
assumes "x \<in> A" and "y \<in> A"
shows "x \<sqsubseteq>\<^sub>r y \<longleftrightarrow> x \<squnion>\<^sub>f y = y" (is "?P \<longleftrightarrow> ?Q")
(*<*)
proof
assume ?P
with assms show ?Q by (blast intro: antisym_r lub ub2)
next
assume ?Q
then have "y = x \<squnion>\<^bsub>f\<^esub> y" by simp
moreover from assms have "x \<sqsubseteq>\<^bsub>r\<^esub> x \<squnion>\<^bsub>f\<^esub> y" by simp
ultimately show ?P by simp
qed
(*>*)
lemma (in Semilat) le_iff_plus_unchanged2:
assumes "x \<in> A" and "y \<in> A"
shows "x \<sqsubseteq>\<^sub>r y \<longleftrightarrow> y \<squnion>\<^sub>f x = y" (is "?P \<longleftrightarrow> ?Q")
(*<*)
proof
assume ?P
with assms show ?Q by (blast intro: antisym_r lub ub1)
next
assume ?Q
then have "y = y \<squnion>\<^bsub>f\<^esub> x" by simp
moreover from assms have "x \<sqsubseteq>\<^bsub>r\<^esub> y \<squnion>\<^bsub>f\<^esub> x" by simp
ultimately show ?P by simp
qed
(*>*)
lemma (in Semilat) plus_assoc [simp]:
assumes a: "a \<in> A" and b: "b \<in> A" and c: "c \<in> A"
shows "a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c) = a \<squnion>\<^sub>f b \<squnion>\<^sub>f c"
(*<*)
proof -
from a b have ab: "a \<squnion>\<^sub>f b \<in> A" ..
from this c have abc: "(a \<squnion>\<^sub>f b) \<squnion>\<^sub>f c \<in> A" ..
from b c have bc: "b \<squnion>\<^sub>f c \<in> A" ..
from a this have abc': "a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c) \<in> A" ..
show ?thesis
proof
show "a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c) \<sqsubseteq>\<^sub>r (a \<squnion>\<^sub>f b) \<squnion>\<^sub>f c"
proof -
from a b have "a \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f b" ..
also from ab c have "\<dots> \<sqsubseteq>\<^sub>r \<dots> \<squnion>\<^sub>f c" ..
finally have "a<": "a \<sqsubseteq>\<^sub>r (a \<squnion>\<^sub>f b) \<squnion>\<^sub>f c" .
from a b have "b \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f b" ..
also from ab c have "\<dots> \<sqsubseteq>\<^sub>r \<dots> \<squnion>\<^sub>f c" ..
finally have "b<": "b \<sqsubseteq>\<^sub>r (a \<squnion>\<^sub>f b) \<squnion>\<^sub>f c" .
from ab c have "c<": "c \<sqsubseteq>\<^sub>r (a \<squnion>\<^sub>f b) \<squnion>\<^sub>f c" ..
from "b<" "c<" b c abc have "b \<squnion>\<^sub>f c \<sqsubseteq>\<^sub>r (a \<squnion>\<^sub>f b) \<squnion>\<^sub>f c" ..
from "a<" this a bc abc show ?thesis ..
qed
show "(a \<squnion>\<^sub>f b) \<squnion>\<^sub>f c \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c)"
proof -
from b c have "b \<sqsubseteq>\<^sub>r b \<squnion>\<^sub>f c" ..
also from a bc have "\<dots> \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f \<dots>" ..
finally have "b<": "b \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c)" .
from b c have "c \<sqsubseteq>\<^sub>r b \<squnion>\<^sub>f c" ..
also from a bc have "\<dots> \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f \<dots>" ..
finally have "c<": "c \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c)" .
from a bc have "a<": "a \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c)" ..
from "a<" "b<" a b abc' have "a \<squnion>\<^sub>f b \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c)" ..
from this "c<" ab c abc' show ?thesis ..
qed
qed
qed
(*>*)
lemma (in Semilat) plus_com_lemma:
"\<lbrakk>a \<in> A; b \<in> A\<rbrakk> \<Longrightarrow> a \<squnion>\<^sub>f b \<sqsubseteq>\<^sub>r b \<squnion>\<^sub>f a"
(*<*)
proof -
assume a: "a \<in> A" and b: "b \<in> A"
from b a have "a \<sqsubseteq>\<^sub>r b \<squnion>\<^sub>f a" ..
moreover from b a have "b \<sqsubseteq>\<^sub>r b \<squnion>\<^sub>f a" ..
moreover note a b
moreover from b a have "b \<squnion>\<^sub>f a \<in> A" ..
ultimately show ?thesis ..
qed
(*>*)
lemma (in Semilat) plus_commutative:
"\<lbrakk>a \<in> A; b \<in> A\<rbrakk> \<Longrightarrow> a \<squnion>\<^sub>f b = b \<squnion>\<^sub>f a"
(*<*) by(blast intro: order_antisym plus_com_lemma) (*>*)
lemma is_lubD:
"is_lub r x y u \<Longrightarrow> is_ub r x y u \<and> (\<forall>z. is_ub r x y z \<longrightarrow> (u,z) \<in> r)"
(*<*) by (simp add: is_lub_def) (*>*)
lemma is_ubI:
"\<lbrakk> (x,u) \<in> r; (y,u) \<in> r \<rbrakk> \<Longrightarrow> is_ub r x y u"
(*<*) by (simp add: is_ub_def) (*>*)
lemma is_ubD:
"is_ub r x y u \<Longrightarrow> (x,u) \<in> r \<and> (y,u) \<in> r"
(*<*) by (simp add: is_ub_def) (*>*)
lemma is_lub_bigger1 [iff]:
"is_lub (r^* ) x y y = ((x,y)\<in>r^* )"
(*<*)
apply (unfold is_lub_def is_ub_def)
apply blast
done
(*>*)
lemma is_lub_bigger2 [iff]:
"is_lub (r^* ) x y x = ((y,x)\<in>r^* )"
(*<*)
apply (unfold is_lub_def is_ub_def)
apply blast
done
(*>*)
lemma extend_lub:
"\<lbrakk> single_valued r; is_lub (r^* ) x y u; (x',x) \<in> r \<rbrakk>
\<Longrightarrow> EX v. is_lub (r^* ) x' y v"
(*<*)
apply (unfold is_lub_def is_ub_def)
apply (case_tac "(y,x) \<in> r^*")
apply (case_tac "(y,x') \<in> r^*")
apply blast
apply (blast elim: converse_rtranclE dest: single_valuedD)
apply (rule exI)
apply (rule conjI)
apply (blast intro: converse_rtrancl_into_rtrancl dest: single_valuedD)
apply (blast intro: rtrancl_into_rtrancl converse_rtrancl_into_rtrancl
elim: converse_rtranclE dest: single_valuedD)
done
(*>*)
lemma single_valued_has_lubs [rule_format]:
"\<lbrakk> single_valued r; (x,u) \<in> r^* \<rbrakk> \<Longrightarrow> (\<forall>y. (y,u) \<in> r^* \<longrightarrow>
(EX z. is_lub (r^* ) x y z))"
(*<*)
apply (erule converse_rtrancl_induct)
apply clarify
apply (erule converse_rtrancl_induct)
apply blast
apply (blast intro: converse_rtrancl_into_rtrancl)
apply (blast intro: extend_lub)
done
(*>*)
lemma some_lub_conv:
"\<lbrakk> acyclic r; is_lub (r^* ) x y u \<rbrakk> \<Longrightarrow> some_lub (r^* ) x y = u"
(*<*)
apply (unfold some_lub_def is_lub_def)
apply (rule someI2)
apply (unfold is_lub_def)
apply assumption
apply (blast intro: antisymD dest!: acyclic_impl_antisym_rtrancl)
done
(*>*)
lemma is_lub_some_lub:
"\<lbrakk> single_valued r; acyclic r; (x,u)\<in>r^*; (y,u)\<in>r^* \<rbrakk>
\<Longrightarrow> is_lub (r^* ) x y (some_lub (r^* ) x y)"
(*<*) by (fastforce dest: single_valued_has_lubs simp add: some_lub_conv) (*>*)
subsection{*An executable lub-finder*}
definition exec_lub :: "('a * 'a) set \<Rightarrow> ('a \<Rightarrow> 'a) \<Rightarrow> 'a binop"
where
"exec_lub r f x y = while (\<lambda>z. (x,z) \<notin> r\<^sup>*) f y"
lemma exec_lub_refl: "exec_lub r f T T = T"
by (simp add: exec_lub_def while_unfold)
lemma acyclic_single_valued_finite:
"\<lbrakk>acyclic r; single_valued r; (x,y) \<in> r\<^sup>*\<rbrakk>
\<Longrightarrow> finite (r \<inter> {a. (x, a) \<in> r\<^sup>*} \<times> {b. (b, y) \<in> r\<^sup>*})"
(*<*)
apply(erule converse_rtrancl_induct)
apply(rule_tac B = "{}" in finite_subset)
apply(simp only:acyclic_def)
apply(blast intro:rtrancl_into_trancl2 rtrancl_trancl_trancl)
apply simp
apply(rename_tac x x')
apply(subgoal_tac "r \<inter> {a. (x,a) \<in> r\<^sup>*} \<times> {b. (b,y) \<in> r\<^sup>*} =
insert (x,x') (r \<inter> {a. (x', a) \<in> r\<^sup>*} \<times> {b. (b, y) \<in> r\<^sup>*})")
apply simp
apply(blast intro:converse_rtrancl_into_rtrancl
elim:converse_rtranclE dest:single_valuedD)
done
(*>*)
lemma exec_lub_conv:
"\<lbrakk> acyclic r; \<forall>x y. (x,y) \<in> r \<longrightarrow> f x = y; is_lub (r\<^sup>*) x y u \<rbrakk> \<Longrightarrow>
exec_lub r f x y = u"
(*<*)
apply(unfold exec_lub_def)
apply(rule_tac P = "\<lambda>z. (y,z) \<in> r\<^sup>* \<and> (z,u) \<in> r\<^sup>*" and
r = "(r \<inter> {(a,b). (y,a) \<in> r\<^sup>* \<and> (b,u) \<in> r\<^sup>*})^-1" in while_rule)
apply(blast dest: is_lubD is_ubD)
apply(erule conjE)
apply(erule_tac z = u in converse_rtranclE)
apply(blast dest: is_lubD is_ubD)
apply(blast dest:rtrancl_into_rtrancl)
apply(rename_tac s)
apply(subgoal_tac "is_ub (r\<^sup>*) x y s")
prefer 2 apply(simp add:is_ub_def)
apply(subgoal_tac "(u, s) \<in> r\<^sup>*")
prefer 2 apply(blast dest:is_lubD)
apply(erule converse_rtranclE)
apply blast
apply(simp only:acyclic_def)
apply(blast intro:rtrancl_into_trancl2 rtrancl_trancl_trancl)
apply(rule finite_acyclic_wf)
apply simp
apply(erule acyclic_single_valued_finite)
apply(blast intro:single_valuedI)
apply(simp add:is_lub_def is_ub_def)
apply simp
apply(erule acyclic_subset)
apply blast
apply simp
apply(erule conjE)
apply(erule_tac z = u in converse_rtranclE)
apply(blast dest: is_lubD is_ubD)
apply(blast dest:rtrancl_into_rtrancl)
done
(*>*)
lemma is_lub_exec_lub:
"\<lbrakk> single_valued r; acyclic r; (x,u):r^*; (y,u):r^*; \<forall>x y. (x,y) \<in> r \<longrightarrow> f x = y \<rbrakk>
\<Longrightarrow> is_lub (r^* ) x y (exec_lub r f x y)"
(*<*) by (fastforce dest: single_valued_has_lubs simp add: exec_lub_conv) (*>*)
end
|
theory Ex2
imports Main
begin
fun count :: "'a \<Rightarrow> 'a list \<Rightarrow> nat" where
"count n [] = 0" |
"count n (x # xs) = (if x = n then 1 + count n xs else count n xs)"
value "count 1 []"
value "count 1 [1]"
lemma count_lt_length [simp]: "count x xs \<le> length xs"
apply(induction xs)
apply(auto)
done
(* Ex 2.4 *)
fun snoc :: "'a list \<Rightarrow> 'a \<Rightarrow> 'a list" where
"snoc [] x = [x]" |
"snoc (x # xs) y = (x # (snoc xs y))"
fun reverse :: "'a list \<Rightarrow> 'a list" where
"reverse [] = []" |
"reverse (x # xs) = snoc (reverse xs) x"
value "reverse [1,2,3]"
lemma snoc_rev [simp]: "reverse (snoc xs a) = a # (reverse xs)"
apply(induction xs)
apply(auto)
done
lemma rev_rev [simp]: "reverse (reverse xs) = xs"
apply(induction xs)
apply(auto)
done
(* Ex 2.5 *)
fun sum :: "nat \<Rightarrow> nat" where
"sum 0 = 0" |
"sum (Suc n) = (Suc n) + (sum n)"
value "(sum 3)"
value "(4 div 2)::nat"
lemma sum_bin [simp]: "sum n = n * (n + 1) div 2"
apply(induction n)
apply(auto)
done
end
|
-- @@stderr --
dtrace: failed to compile script test/unittest/speculation/err.D_SPEC_DREC.SpecAftDataRec.d: [D_SPEC_DREC] line 30: speculate( ) may not follow data-recording action(s)
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Data.FinData.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Data.Nat
open import Cubical.Data.Bool.Base
open import Cubical.Relation.Nullary
private
variable
ℓ : Level
A B : Type ℓ
data Fin : ℕ → Type₀ where
zero : {n : ℕ} → Fin (suc n)
suc : {n : ℕ} (i : Fin n) → Fin (suc n)
toℕ : ∀ {n} → Fin n → ℕ
toℕ zero = 0
toℕ (suc i) = suc (toℕ i)
fromℕ : (n : ℕ) → Fin (suc n)
fromℕ zero = zero
fromℕ (suc n) = suc (fromℕ n)
¬Fin0 : ¬ Fin 0
¬Fin0 ()
_==_ : ∀ {n} → Fin n → Fin n → Bool
zero == zero = true
zero == suc _ = false
suc _ == zero = false
suc m == suc n = m == n
foldrFin : ∀ {n} → (A → B → B) → B → (Fin n → A) → B
foldrFin {n = zero} _ b _ = b
foldrFin {n = suc n} f b l = f (l zero) (foldrFin f b (l ∘ suc))
|
lemma continuous_at_Inf_mono: fixes f :: "'a::{linorder_topology,conditionally_complete_linorder} \<Rightarrow> 'b::{linorder_topology,conditionally_complete_linorder}" assumes "mono f" and cont: "continuous (at_right (Inf S)) f" and S: "S \<noteq> {}" "bdd_below S" shows "f (Inf S) = (INF s\<in>S. f s)" |
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sb
import pandas as pd
#def getTemprature():
#path= "main/static/main/temp_values/"
#colnames = ['MONTH', 'MAX_TEMP', 'MIN_TEMP', 'AVG']
#data = pd.read_csv(path + 'temp_values.csv', names=colnames, skiprows=(1))
#return data
from sklearn.preprocessing import PolynomialFeatures
x = np.array([2, 3, 4])
poly = PolynomialFeatures(3, include_bias=False)
poly.fit_transform(x[:, None])
|
module slots.test where
open import slots.imports
open import slots.defs using (config ; game)
open import slots.bruteforce using (rtp)
c : config
c = record { n = 3 ; m = 4 }
g : game c
g = record { reels = reels ; winTable = winTable } where
open config c
reel : Reel
reel = # 1 ∷ # 1 ∷ # 1 ∷ # 0 ∷ []
reel′ : Reel
reel′ = # 1 ∷ # 1 ∷ # 2 ∷ # 0 ∷ []
reel″ : Reel
reel″ = # 1 ∷ # 3 ∷ # 1 ∷ # 0 ∷ []
reels : Reels
reels =
reel ∷
reel′ ∷
reel″ ∷
[]
winTable : WinTable
winTable =
(0 ∷ 0 ∷ 0 ∷ []) ∷
(0 ∷ 1 ∷ 2 ∷ []) ∷
(0 ∷ 0 ∷ 0 ∷ []) ∷
(0 ∷ 0 ∷ 0 ∷ []) ∷
[]
% : ℕ × ℕ
% = rtp g
%-prf : % ≡ (36 , 64)
%-prf = refl
|
#pragma once
#include "kl/type_traits.hpp"
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/static_visitor.hpp>
#include <type_traits>
#include <utility>
namespace kl {
namespace detail {
template <typename... F>
struct overloader;
template <typename Head, typename... Tail>
struct overloader<Head, Tail...> : Head, overloader<Tail...>
{
overloader(Head head, Tail... tail)
: Head(std::move(head)), overloader<Tail...>(std::move(tail)...)
{
}
using Head::operator();
using overloader<Tail...>::operator();
};
template <typename F>
struct overloader<F> : F
{
overloader(F f) : F(std::move(f)) {}
using F::operator();
};
template <>
struct overloader<>
{
template <typename U>
void operator()(U)
{
static_assert(always_false_v<U>,
"No callable supplied for this overloader");
}
};
template <typename F, typename... Fs>
struct overload_return_type
{
static constexpr auto value =
is_same_v<typename func_traits<F>::return_type,
typename func_traits<Fs>::return_type...>;
static_assert(value, "All supplied callables must return the same type");
using type = typename func_traits<F>::return_type;
};
} // namespace detail
template <typename ReturnType, typename... Fs>
struct overloader : public boost::static_visitor<ReturnType>,
detail::overloader<Fs...>
{
overloader(Fs... fs) : detail::overloader<Fs...>(std::move(fs)...) {}
};
template <typename ReturnType, typename... Fs>
overloader<ReturnType, Fs...> make_overloader(Fs&&... fs)
{
return {std::forward<Fs>(fs)...};
}
template <typename Visitable, typename... Fs>
auto match(Visitable&& visitable, Fs&&... fs) ->
typename detail::overload_return_type<Fs...>::type
{
using return_type = typename detail::overload_return_type<Fs...>::type;
auto visitor = make_overloader<return_type>(std::forward<Fs>(fs)...);
return ::boost::apply_visitor(visitor, std::forward<Visitable>(visitable));
}
// We can't use boost::visitor_ptr along with our overloader since it derives
// from boost::static_visitor which overloader also does
template <typename ReturnType, typename Arg>
struct func_overload
{
using func_ptr = ReturnType (*)(Arg);
func_overload(func_ptr func) : func_{func} {}
using forward_arg =
std::conditional_t<std::is_reference_v<Arg>, Arg,
std::add_lvalue_reference_t<const Arg>>;
ReturnType operator()(forward_arg arg) const { return func_(arg); }
private:
func_ptr func_;
};
template <typename ReturnType, typename Arg>
func_overload<ReturnType, Arg> make_func_overload(ReturnType (*func)(Arg))
{
return {func};
}
} // namespace kl
|
module Node.HTTP
import Coda.Node.Core
%access public export
%default total
record Server where
constructor MkServer
server : Ptr
data Port : Type where
MkPort : (n : Int) -> { auto p : Dec ( n > 0 = True ) } -> Port
Handler : Type
Handler = Ptr -> Ptr -> JS_IO ()
wrapHandler : Handler -> Ptr -> JS_IO ()
wrapHandler handler ptr = do
req <- prop { ty = Ptr } ptr "req"
res <- prop { ty = Ptr } ptr "res"
handler req res
partial
createServer : Handler -> JS_IO Server
createServer handler = do
http <- require "http"
server <- eval { ty = (Ptr -> String -> (JsFn (Ptr -> JS_IO())) -> JS_IO Ptr) }
"%0[%1]( (req, res) => %2({req, res}))"
http "createServer" (MkJsFn (wrapHandler handler))
pure $ MkServer server
listen : Server -> Port -> JS_IO ()
listen (MkServer server) (MkPort number) = do
startedPtr <- method { a = Int } { b = Ptr } server "listen" number
log ("Started server on http://localhost:" ++ (show number))
|
Formal statement is: lemma pcompose_pCons: "pcompose (pCons a p) q = [:a:] + q * pcompose p q" Informal statement is: The composition of a polynomial with a constant polynomial is equal to the sum of the constant polynomial and the product of the constant polynomial and the composition of the original polynomial with the constant polynomial. |
State Before: α : Type u_1
E : Type ?u.1987410
F : Type u_2
G : Type ?u.1987416
m m0 : MeasurableSpace α
p : ℝ≥0∞
q : ℝ
μ ν : Measure α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedAddCommGroup F
inst✝ : NormedAddCommGroup G
f : α → F
hμν : ν ≪ μ
⊢ snormEssSup f ν ≤ snormEssSup f μ State After: α : Type u_1
E : Type ?u.1987410
F : Type u_2
G : Type ?u.1987416
m m0 : MeasurableSpace α
p : ℝ≥0∞
q : ℝ
μ ν : Measure α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedAddCommGroup F
inst✝ : NormedAddCommGroup G
f : α → F
hμν : ν ≪ μ
⊢ essSup (fun x => ↑‖f x‖₊) ν ≤ essSup (fun x => ↑‖f x‖₊) μ Tactic: simp_rw [snormEssSup] State Before: α : Type u_1
E : Type ?u.1987410
F : Type u_2
G : Type ?u.1987416
m m0 : MeasurableSpace α
p : ℝ≥0∞
q : ℝ
μ ν : Measure α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedAddCommGroup F
inst✝ : NormedAddCommGroup G
f : α → F
hμν : ν ≪ μ
⊢ essSup (fun x => ↑‖f x‖₊) ν ≤ essSup (fun x => ↑‖f x‖₊) μ State After: no goals Tactic: exact essSup_mono_measure hμν |
rm(list=ls())
outFile='PH_scRNA'
parSampleFile1='fileList1.txt'
parSampleFile2='fileList2.txt'
parSampleFile3=''
parFile1='C:/projects/scratch/cqs/shengq2/paula_hurley_projects/20210303_scRNA_human/seurat_sct/result/PH_scRNA.final.rds'
parFile2='C:/projects/scratch/cqs/shengq2/paula_hurley_projects/20210303_scRNA_human/seurat_sct_celltype/result/PH_scRNA.celltype_cluster.csv'
parFile3='C:/projects/scratch/cqs/shengq2/paula_hurley_projects/20210303_scRNA_human/seurat_sct_celltype/result/PH_scRNA.celltype.csv'
setwd('C:/projects/scratch/cqs/shengq2/paula_hurley_projects/20210303_scRNA_human/seurat_sct_celltype_rename/result')
source("scRNA_func.r")
library(Seurat)
library(ggplot2)
myoptions<-read.table(parSampleFile1, stringsAsFactors = F, sep="\t", header=F)
myoptions<-split(myoptions$V1, myoptions$V2)
newnames<-read.table(parSampleFile2, stringsAsFactors = F, sep="\t", header=F)
newnames<-split(newnames$V1, newnames$V2)
clusters<-read.csv(parFile3, stringsAsFactors = F, header=T)
rownames(clusters)=clusters$seurat_clusters
renamed_column = paste0("renamed_", myoptions$celltype_name)
clusters[,renamed_column] = clusters[,myoptions$celltype_name]
clusters[names(newnames),renamed_column] = unlist(newnames)
seurat_renamed_column=paste0("seurat_", renamed_column)
clusters[,seurat_renamed_column] = paste0(clusters$seurat_clusters, " : ", clusters[,renamed_column])
clusters[,seurat_renamed_column] = factor(clusters[,seurat_renamed_column], levels=clusters[,seurat_renamed_column])
write.csv(clusters, file=paste0(outFile, ".rename_celltype.csv"), row.names=F)
cells<-read.csv(parFile2, stringsAsFactors = F, row.names=1, header=T)
renames<-split(clusters[,renamed_column], clusters$seurat_clusters)
cells[,renamed_column]=unlist(renames[as.character(cells$seurat_clusters)])
renames<-split(clusters[,seurat_renamed_column], clusters$seurat_clusters)
cells[,seurat_renamed_column]=unlist(renames[as.character(cells$seurat_clusters)])
write.csv(cells, file=paste0(outFile, ".rename_cluster.csv"))
finalList<-readRDS(parFile1)
obj<-finalList$obj
#make sure with same cell order
cells<-cells[colnames(obj),]
obj[[seurat_renamed_column]]<-cells[,seurat_renamed_column]
png(file=paste0(outFile, ".rename_cluster.png"), width=4000, height=3000, res=300)
g<-DimPlot(object = obj, reduction = 'umap', label=TRUE, group.by=seurat_renamed_column) + guides(colour = guide_legend(override.aes = list(size = 3), ncol=1))
print(g)
dev.off()
png(file=paste0(outFile, ".rename_cluster.number.png"), width=4000, height=3000, res=300)
g<-DimPlot(object = obj, reduction = 'umap', label=TRUE, group.by="seurat_clusters") + guides(colour = guide_legend(override.aes = list(size = 3), ncol=1))
g<-g+scale_color_manual(labels = levels(clusters[,seurat_renamed_column]), values=finalList$seurat_colors) + labs(title="", color = "Cluster")
print(g)
dev.off()
cellcounts<-data.frame(Sample=obj$orig.ident, Cluster=obj[[seurat_renamed_column]])
ctable<-t(table(cellcounts))
ctable_perThousand <- round(ctable / colSums(ctable) * 1000)
colnames(ctable_perThousand)<-paste0(colnames(ctable), "_perThousand")
final<-cbind(ctable, ctable_perThousand)
write.csv(final, file=paste0(outFile, ".rename_cluster.summery.csv"))
|
If $X$ is a first-countable topological space, then for every $x \in X$, there exists a countable collection of open sets $\{A_n\}$ such that $x \in A_n$ for all $n$ and for every open set $S$ containing $x$, there exists $n$ such that $A_n \subseteq S$. |
The first horses were introduced to New Zealand by Protestant missionary Reverend Samuel Marsden in December 1814 , and wild horses were first reported in the Kaimanawa Range in central North Island of New Zealand in 1876 . The Kaimanawa breed descended from domestic horses that were released in the late 19th century and early 20th century in the middle of the North Island around the Kaimanawa mountains . Between 1858 and 1875 , Major George <unk> Carlyon imported Exmoor ponies to Hawkes Bay and crossed them with local stock to produce the Carlyon pony . These Carlyon ponies were later crossed with two Welsh stallions , <unk> Caesar and Comet , imported by Sir Donald McLean , and a breed known as the Comet resulted . At some point during the 1870s , McLean released a Comet stallion and several mares on the <unk> Plains and the bloodline apparently became part of the wild Kaimanawa population . Other horses were added to the bloodline through escapes and releases from local sheep stations and from cavalry units at Waiouru that were threatened with a strangles epidemic . It is also thought that in the 1960s Nicholas <unk> released an Arabian stallion into the Argo Valley region .
|
import .preamble_results
variables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]
{E : Type*} [normed_group E] [normed_space 𝕜 E]
{E' : Type*} [normed_group E'] [normed_space 𝕜 E']
{F : Type*} [normed_group F] [normed_space 𝕜 F]
{F' : Type*} [normed_group F'] [normed_space 𝕜 F']
{H : Type*} [topological_space H]
{H' : Type*} [topological_space H']
{G : Type*} [topological_space G]
{G' : Type*} [topological_space G']
(I : model_with_corners 𝕜 E H) (I' : model_with_corners 𝕜 E' H')
(J : model_with_corners 𝕜 F G) (J' : model_with_corners 𝕜 F' G')
section diffeomorph
variables (M : Type*) [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M]
(M' : Type*) [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I' M']
(N : Type*) [topological_space N] [charted_space G N] [smooth_manifold_with_corners J N]
(N' : Type*) [topological_space N'] [charted_space G' N'] [smooth_manifold_with_corners J' N']
(n : with_top ℕ)
/-- α and β are homeomorph, also called topological isomoph -/
structure diffeomorph extends M ≃ M' :=
(times_cont_mdiff_to_fun : smooth I I' to_fun)
(times_cont_mdiff_inv_fun : smooth I' I inv_fun)
infix ` ≃ₘ `:50 := diffeomorph _ _
notation M ` ≃ₘ[` I `;` J `]` N := diffeomorph I J M N
namespace diffeomorph
instance : has_coe_to_fun (diffeomorph I I' M M') := ⟨λ _, M → M', λe, e.to_equiv⟩
lemma coe_eq_to_equiv (h : diffeomorph I I' M M') (x : M) : h x = h.to_equiv x := rfl
/-- Identity map is a diffeomorphism. -/
protected def refl : M ≃ₘ[I; I] M :=
{ smooth_to_fun := smooth_in_charts_id, smooth_inv_fun := smooth_in_charts_id, .. homeomorph.refl M }
/-- Composition of two diffeomorphisms. -/
protected def trans (h₁ : diffeomorph I I' M M') (h₂ : diffeomorph I' J M' N) : M ≃ₘ[I | J] N :=
{ smooth_to_fun := h₂.smooth_to_fun.comp h₁.smooth_to_fun,
smooth_inv_fun := h₁.smooth_inv_fun.comp h₂.smooth_inv_fun,
.. homeomorph.trans h₁.to_homeomorph h₂.to_homeomorph }
/-- Inverse of a diffeomorphism. -/
protected def symm (h : M ≃ₘ[I | J] N) : N ≃ₘ[J | I] M :=
{ smooth_to_fun := h.smooth_inv_fun,
smooth_inv_fun := h.smooth_to_fun,
.. h.to_homeomorph.symm }
end diffeomorph
end diffeomorph |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Jeremy Avigad, Yury Kudryashov
-/
import order.filter.at_top_bot
import order.filter.pi
/-!
# The cofinite filter
In this file we define
`cofinite`: the filter of sets with finite complement
and prove its basic properties. In particular, we prove that for `ℕ` it is equal to `at_top`.
## TODO
Define filters for other cardinalities of the complement.
-/
open set function
open_locale classical
variables {α : Type*}
namespace filter
/-- The cofinite filter is the filter of subsets whose complements are finite. -/
def cofinite : filter α :=
{ sets := {s | finite sᶜ},
univ_sets := by simp only [compl_univ, finite_empty, mem_set_of_eq],
sets_of_superset := assume s t (hs : finite sᶜ) (st: s ⊆ t),
hs.subset $ compl_subset_compl.2 st,
inter_sets := assume s t (hs : finite sᶜ) (ht : finite (tᶜ)),
by simp only [compl_inter, finite.union, ht, hs, mem_set_of_eq] }
@[simp] lemma mem_cofinite {s : set α} : s ∈ (@cofinite α) ↔ finite sᶜ := iff.rfl
@[simp] lemma eventually_cofinite {p : α → Prop} :
(∀ᶠ x in cofinite, p x) ↔ finite {x | ¬p x} := iff.rfl
lemma has_basis_cofinite : has_basis cofinite (λ s : set α, s.finite) compl :=
⟨λ s, ⟨λ h, ⟨sᶜ, h, (compl_compl s).subset⟩, λ ⟨t, htf, hts⟩, htf.subset $ compl_subset_comm.2 hts⟩⟩
instance cofinite_ne_bot [infinite α] : ne_bot (@cofinite α) :=
has_basis_cofinite.ne_bot_iff.2 $ λ s hs, hs.infinite_compl.nonempty
lemma frequently_cofinite_iff_infinite {p : α → Prop} :
(∃ᶠ x in cofinite, p x) ↔ set.infinite {x | p x} :=
by simp only [filter.frequently, filter.eventually, mem_cofinite, compl_set_of, not_not,
set.infinite]
/-- The coproduct of the cofinite filters on two types is the cofinite filter on their product. -/
lemma coprod_cofinite {β : Type*} :
(cofinite : filter α).coprod (cofinite : filter β) = cofinite :=
begin
ext S,
simp only [mem_coprod_iff, exists_prop, mem_comap, mem_cofinite],
split,
{ rintro ⟨⟨A, hAf, hAS⟩, B, hBf, hBS⟩,
rw [← compl_subset_compl, ← preimage_compl] at hAS hBS,
exact (hAf.prod hBf).subset (subset_inter hAS hBS) },
{ intro hS,
refine ⟨⟨(prod.fst '' Sᶜ)ᶜ, _, _⟩, ⟨(prod.snd '' Sᶜ)ᶜ, _, _⟩⟩,
{ simpa using hS.image prod.fst },
{ simpa [compl_subset_comm] using subset_preimage_image prod.fst Sᶜ },
{ simpa using hS.image prod.snd },
{ simpa [compl_subset_comm] using subset_preimage_image prod.snd Sᶜ } },
end
/-- Finite product of finite sets is finite -/
lemma Coprod_cofinite {δ : Type*} {κ : δ → Type*} [fintype δ] :
filter.Coprod (λ d, (cofinite : filter (κ d))) = cofinite :=
begin
ext S,
rcases compl_surjective S with ⟨S, rfl⟩,
simp_rw [compl_mem_Coprod_iff, mem_cofinite, compl_compl],
split,
{ rintro ⟨t, htf, hsub⟩,
exact (finite.pi htf).subset hsub },
{ exact λ hS, ⟨λ i, eval i '' S, λ i, hS.image _, subset_pi_eval_image _ _⟩ }
end
end filter
open filter
lemma set.finite.compl_mem_cofinite {s : set α} (hs : s.finite) : sᶜ ∈ (@cofinite α) :=
mem_cofinite.2 $ (compl_compl s).symm ▸ hs
lemma set.finite.eventually_cofinite_nmem {s : set α} (hs : s.finite) : ∀ᶠ x in cofinite, x ∉ s :=
hs.compl_mem_cofinite
lemma finset.eventually_cofinite_nmem (s : finset α) : ∀ᶠ x in cofinite, x ∉ s :=
s.finite_to_set.eventually_cofinite_nmem
lemma set.infinite_iff_frequently_cofinite {s : set α} :
set.infinite s ↔ (∃ᶠ x in cofinite, x ∈ s) :=
frequently_cofinite_iff_infinite.symm
lemma filter.eventually_cofinite_ne (x : α) : ∀ᶠ a in cofinite, a ≠ x :=
(set.finite_singleton x).eventually_cofinite_nmem
lemma filter.le_cofinite_iff_compl_singleton_mem {l : filter α} :
l ≤ cofinite ↔ ∀ x, {x}ᶜ ∈ l :=
begin
refine ⟨λ h x, h (finite_singleton x).compl_mem_cofinite, λ h s (hs : sᶜ.finite), _⟩,
rw [← compl_compl s, ← bUnion_of_singleton sᶜ, compl_Union₂,filter.bInter_mem hs],
exact λ x _, h x
end
/-- If `α` is a sup-semilattice with no maximal element, then `at_top ≤ cofinite`. -/
lemma at_top_le_cofinite [semilattice_sup α] [no_max_order α] : (at_top : filter α) ≤ cofinite :=
begin
refine compl_surjective.forall.2 (λ s hs, _),
rcases eq_empty_or_nonempty s with rfl|hne, { simp only [compl_empty, univ_mem] },
rw [mem_cofinite, compl_compl] at hs, lift s to finset α using hs,
rcases exists_gt (s.sup' hne id) with ⟨y, hy⟩,
filter_upwards [mem_at_top y] with x hx hxs,
exact (finset.le_sup' id hxs).not_lt (hy.trans_le hx)
end
/-- For natural numbers the filters `cofinite` and `at_top` coincide. -/
lemma nat.cofinite_eq_at_top : @cofinite ℕ = at_top :=
begin
refine le_antisymm _ at_top_le_cofinite,
refine at_top_basis.ge_iff.2 (λ N hN, _),
simpa only [mem_cofinite, compl_Ici] using finite_lt_nat N
end
lemma nat.frequently_at_top_iff_infinite {p : ℕ → Prop} :
(∃ᶠ n in at_top, p n) ↔ set.infinite {n | p n} :=
by simp only [← nat.cofinite_eq_at_top, frequently_cofinite_iff_infinite]
lemma filter.tendsto.exists_within_forall_le {α β : Type*} [linear_order β] {s : set α}
(hs : s.nonempty)
{f : α → β} (hf : filter.tendsto f filter.cofinite filter.at_top) :
∃ a₀ ∈ s, ∀ a ∈ s, f a₀ ≤ f a :=
begin
rcases em (∃ y ∈ s, ∃ x, f y < x) with ⟨y, hys, x, hx⟩|not_all_top,
{ -- the set of points `{y | f y < x}` is nonempty and finite, so we take `min` over this set
have : finite {y | ¬x ≤ f y} := (filter.eventually_cofinite.mp (tendsto_at_top.1 hf x)),
simp only [not_le] at this,
obtain ⟨a₀, ⟨ha₀ : f a₀ < x, ha₀s⟩, others_bigger⟩ :=
exists_min_image _ f (this.inter_of_left s) ⟨y, hx, hys⟩,
refine ⟨a₀, ha₀s, λ a has, (lt_or_le (f a) x).elim _ (le_trans ha₀.le)⟩,
exact λ h, others_bigger a ⟨h, has⟩ },
{ -- in this case, f is constant because all values are at top
push_neg at not_all_top,
obtain ⟨a₀, ha₀s⟩ := hs,
exact ⟨a₀, ha₀s, λ a ha, not_all_top a ha (f a₀)⟩ }
end
lemma filter.tendsto.exists_forall_le {α β : Type*} [nonempty α] [linear_order β]
{f : α → β} (hf : tendsto f cofinite at_top) :
∃ a₀, ∀ a, f a₀ ≤ f a :=
let ⟨a₀, _, ha₀⟩ := hf.exists_within_forall_le univ_nonempty in ⟨a₀, λ a, ha₀ a (mem_univ _)⟩
lemma filter.tendsto.exists_within_forall_ge {α β : Type*} [linear_order β] {s : set α}
(hs : s.nonempty)
{f : α → β} (hf : filter.tendsto f filter.cofinite filter.at_bot) :
∃ a₀ ∈ s, ∀ a ∈ s, f a ≤ f a₀ :=
@filter.tendsto.exists_within_forall_le _ (order_dual β) _ _ hs _ hf
lemma filter.tendsto.exists_forall_ge {α β : Type*} [nonempty α] [linear_order β]
{f : α → β} (hf : tendsto f cofinite at_bot) :
∃ a₀, ∀ a, f a ≤ f a₀ :=
@filter.tendsto.exists_forall_le _ (order_dual β) _ _ _ hf
/-- For an injective function `f`, inverse images of finite sets are finite. -/
lemma function.injective.tendsto_cofinite {α β : Type*} {f : α → β} (hf : injective f) :
tendsto f cofinite cofinite :=
λ s h, h.preimage (hf.inj_on _)
/-- An injective sequence `f : ℕ → ℕ` tends to infinity at infinity. -/
lemma function.injective.nat_tendsto_at_top {f : ℕ → ℕ} (hf : injective f) :
tendsto f at_top at_top :=
nat.cofinite_eq_at_top ▸ hf.tendsto_cofinite
|
Theorem NotNot_LEM : forall P : Prop, ~ ~(P \/ ~P).
Proof.
unfold not.
intros.
apply H.
right.
intro.
apply (H (or_introl H0)).
Qed.
|
(* Title: HOL/Auth/n_german_lemma_inv__50_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__50_on_rules imports n_german_lemma_on_inv__50
begin
section{*All lemmas on causal relation between inv__50*}
lemma lemma_inv__50_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__50 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__50) 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__50) 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__50) 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__50) 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__50) 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__50) 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__50) 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__50) 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__50) 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__50) 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__50) 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__50) 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__50) done
}
ultimately show "invHoldForRule s f r (invariants N)"
by satx
qed
end
|
//=======================================================================
// Copyright Baptiste Wicht 2012-2013.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================
/*!
* \file utils.cpp
* \brief Implementation of the various utility functions.
*/
#include <sstream>
#include <iostream>
#include <fstream>
#include <sys/stat.h>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include "utils.hpp"
#include "gooda_exception.hpp"
bool gooda::exists(const std::string& file){
struct stat buf;
return stat(file.c_str(), &buf) != -1;
}
bool gooda::is_directory(const std::string& file){
struct stat st;
lstat(file.c_str(), &st);
return S_ISDIR(st.st_mode);
}
int gooda::exec_command(const std::string& command) {
return system(command.c_str());
}
std::string gooda::exec_command_result(const std::string& command){
FILE* stream = popen(command.c_str(), "r");
if(!stream){
throw gooda::gooda_exception("Unable to execute \"" + command + "\": Null pipe");
}
std::string result;
char buffer[1024];
while(!feof(stream)) {
if(fgets(buffer, 1024, stream) != NULL){
result += buffer;
}
}
pclose(stream);
return result;
}
int gooda::processor_model(){
std::ifstream cpuinfo_file;
cpuinfo_file.open ("/proc/cpuinfo", std::ios::in);
if(!cpuinfo_file.is_open()){
throw gooda::gooda_exception("Unable to read /proc/cpuinfo");
}
std::string line;
while(!cpuinfo_file.eof()){
std::getline(cpuinfo_file, line);
if(boost::starts_with(line, "model\t")){
std::vector<std::string> parts;
boost::split(parts, line, [](char a){return a == ':';});
std::string model_str = parts.at(1);
boost::trim(model_str);
return boost::lexical_cast<int>(model_str);
}
}
throw gooda::gooda_exception("Uhandled /proc/cpuinfo format");
}
|
lemma connected_eq_components_subset_sing: "connected s \<longleftrightarrow> components s \<subseteq> {s}" |
{-# OPTIONS --without-K --safe #-}
-- A Monad in a Bicategory.
-- For the more elementary version of Monads, see 'Categories.Monad'.
module Categories.Bicategory.Monad where
open import Level
open import Data.Product using (_,_)
open import Categories.Bicategory
import Categories.Bicategory.Extras as Bicat
open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism)
record Monad {o ℓ e t} (𝒞 : Bicategory o ℓ e t) : Set (o ⊔ ℓ ⊔ e ⊔ t) where
open Bicat 𝒞
field
C : Obj
T : C ⇒₁ C
η : id₁ ⇒₂ T
μ : (T ⊚₀ T) ⇒₂ T
assoc : μ ∘ᵥ (T ▷ μ) ∘ᵥ associator.from ≈ (μ ∘ᵥ (μ ◁ T))
sym-assoc : μ ∘ᵥ (μ ◁ T) ∘ᵥ associator.to ≈ (μ ∘ᵥ (T ▷ μ))
identityˡ : μ ∘ᵥ (T ▷ η) ∘ᵥ unitorʳ.to ≈ id₂
identityʳ : μ ∘ᵥ (η ◁ T) ∘ᵥ unitorˡ.to ≈ id₂
|
Formal statement is: lemma small_refl_iff: "f \<in> l F (f) \<longleftrightarrow> eventually (\<lambda>x. f x = 0) F" Informal statement is: A function $f$ is small with respect to a filter $F$ if and only if $f$ is eventually zero with respect to $F$. |
import algebra.category.Module.filtered_colimits
import algebra.category.Module.limits
import category_theory.sites.sheafification
import category_theory.sites.whiskering
import linear_algebra.pi
import linear_algebra.multilinear.basic
open_locale classical
namespace Module
universe u
variables {R : Type u} [comm_ring R]
def product {ι : Type u} (e : ι → Module.{u} R) : Module.{u} R :=
Module.of _ $ Π i, e i
def product.π {ι : Type u} (e : ι → Module.{u} R) (i) : product e ⟶ e i :=
(linear_map.proj i : (Π j, e j) →ₗ[R] e i)
def product.lift {M : Module.{u} R} {ι : Type u} (e : ι → Module.{u} R)
(f : Π i, M ⟶ e i) : M ⟶ product e := linear_map.pi f
@[simp, reassoc, elementwise]
lemma product.lift_π {M : Module.{u} R} {ι : Type u} (e : ι → Module.{u} R)
(f : Π i, M ⟶ e i) (i) : product.lift e f ≫ product.π e i = f i := by { ext, refl }
lemma product.hom_ext {M : Module.{u} R} {ι : Type u} (e : ι → Module.{u} R)
(f g : M ⟶ product e) (h : ∀ i, f ≫ product.π e i = g ≫ product.π e i) : f = g :=
begin
ext m i,
specialize h i,
apply_fun (λ e, e m) at h,
exact h
end
end Module
namespace category_theory
universes w v u
variables (C : Type (max v u)) [category.{v} C] (J : grothendieck_topology C)
variables (R : Type (max v u)) [comm_ring R]
abbreviation functor_of_modules := C ⥤ Module.{max v u} R
variable {C}
abbreviation Sheaf_of_modules := Sheaf J (Module.{max v u} R)
variables {R J}
@[simps]
def functor_of_modules.product {ι : Type (max v u)} (e : ι → functor_of_modules C R) :
functor_of_modules C R :=
{ obj := λ U, Module.product (λ i, (e i).obj U),
map := λ U V f, Module.product.lift _ $ λ i, Module.product.π _ i ≫ (e i).map f }
@[simps]
def functor_of_modules.product.π {ι : Type (max v u)} (e : ι → functor_of_modules C R) (i) :
functor_of_modules.product e ⟶ e i :=
{ app := λ U, Module.product.π _ _ }
@[simps]
def functor_of_modules.product.lift {M : functor_of_modules C R} {ι : Type (max v u)}
(e : ι → functor_of_modules C R)
(f : Π i, M ⟶ e i) : M ⟶ functor_of_modules.product e :=
{ app := λ U, Module.product.lift _ $ λ i, (f i).app U,
naturality' := begin
intros U V f,
apply Module.product.hom_ext,
intros i,
simp,
end }
@[simp, reassoc]
lemma functor_of_modules.product.lift_π {M : functor_of_modules C R} {ι : Type (max v u)}
(e : ι → functor_of_modules C R)
(f : Π i, M ⟶ e i) (i) :
functor_of_modules.product.lift e f ≫ functor_of_modules.product.π e i = f i :=
by { ext : 2, dsimp, simp }
lemma functor_of_modules.product.hom_ext {M : functor_of_modules C R} {ι : Type (max v u)}
(e : ι → functor_of_modules C R) (f g : M ⟶ functor_of_modules.product e)
(h : ∀ i, f ≫ functor_of_modules.product.π e i = g ≫ functor_of_modules.product.π e i) :
f = g :=
begin
ext x : 2,
apply Module.product.hom_ext,
intros i,
specialize h i,
apply_fun (λ e, e.app x) at h,
simpa using h,
end
structure functor_of_modules.multilinear_map {ι : Type (max v u)}
(e : ι → functor_of_modules C R) (M : functor_of_modules C R) :=
(η : functor_of_modules.product e ⋙ forget _ ⟶ M ⋙ forget _)
(F : Π U : C, multilinear_map R (λ i, (e i).obj U) (M.obj U))
(h : ∀ U, η.app U = F U)
@[simps val_obj val_map]
def Sheaf_of_modules.product {ι : Type (max v u)} (e : ι → Sheaf_of_modules J R) :
Sheaf_of_modules J R :=
{ val := functor_of_modules.product (λ i, (e i).val),
cond := begin
-- Idea: The underlying presheaf is the product of the underlying presheaves of
-- the given sheaves. The forgetful functor from sheaves to presheaves creates limits.
sorry,
end }
@[simps val_app]
def Sheaf_of_modules.product.π {ι : Type (max v u)} (e : ι → Sheaf_of_modules J R) (i) :
Sheaf_of_modules.product e ⟶ e i :=
⟨functor_of_modules.product.π _ _⟩
@[simps val_app]
def Sheaf_of_modules.product.lift {M : Sheaf_of_modules J R} {ι : Type (max v u)}
(e : ι → Sheaf_of_modules J R)
(f : Π i, M ⟶ e i) : M ⟶ Sheaf_of_modules.product e :=
⟨functor_of_modules.product.lift _ $ λ i, (f i).val⟩
@[simp]
lemma Sheaf_of_modules.product.lift_π {M : Sheaf_of_modules J R} {ι : Type (max v u)}
(e : ι → Sheaf_of_modules J R)
(f : Π i, M ⟶ e i) (i) :
Sheaf_of_modules.product.lift e f ≫ Sheaf_of_modules.product.π e i = f i :=
by { ext, simp }
lemma Sheaf_of_modules.product.hom_ext {M : Sheaf_of_modules J R} {ι : Type (max v u)}
(e : ι → Sheaf_of_modules J R) (f g : M ⟶ Sheaf_of_modules.product e)
(h : ∀ i, f ≫ Sheaf_of_modules.product.π _ i = g ≫ Sheaf_of_modules.product.π _ i) : f = g :=
begin
ext1,
apply functor_of_modules.product.hom_ext,
intros i,
specialize h i,
apply_fun (λ e, e.val) at h,
exact h
end
abbreviation Sheaf_of_modules.forget (M : Sheaf_of_modules J R) : Sheaf J (Type (max v u)) :=
(Sheaf_compose _ $ forget _).obj M
structure Sheaf_of_modules.multilinear_map {ι : Type (max v u)}
(e : ι → Sheaf_of_modules J R) (M : Sheaf_of_modules J R) :=
(η : functor_of_modules.multilinear_map (λ i, (e i).val) M.val)
end category_theory
|
[STATEMENT]
lemma L_correct[simp]:"Rep_measure (qbs_to_measure X) = (qbs_space X, sigma_Mx X, \<lambda>A. (if A = {} then 0 else if A \<in> - sigma_Mx X then 0 else \<infinity>))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Rep_measure (qbs_to_measure X) = (qbs_space X, sigma_Mx X, \<lambda>A. if A = {} then 0 else if A \<in> - sigma_Mx X then 0 else \<infinity>)
[PROOF STEP]
unfolding qbs_to_measure_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Rep_measure (Abs_measure (qbs_space X, sigma_Mx X, \<lambda>A. if A = {} then 0 else if A \<in> - sigma_Mx X then 0 else \<infinity>)) = (qbs_space X, sigma_Mx X, \<lambda>A. if A = {} then 0 else if A \<in> - sigma_Mx X then 0 else \<infinity>)
[PROOF STEP]
by(auto intro!: Abs_measure_inverse simp: measure_space_L) |
SUBROUTINE DIJKL1 (C,N,NATI,W,CIJ,WCIJ,CKL)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
INCLUDE 'SIZES'
DIMENSION C(N,*), W(*)
DIMENSION CIJ(10*MAXORB), WCIJ(10*MAXORB), CKL(10*MAXORB)
************************************************************************
*
* DIJKL1 IS SIMILAR TO IJKL. THE MAIN DIFFERENCES ARE THAT
* THE ARRAY W CONTAINS THE TWO ELECTRON INTEGRALS BETWEEN
* ONE ATOM (NATI) AND ALL THE OTHER ATOMS IN THE SYSTEM.
*
* ON EXIT
*
* THE ARRAY XY IS FILLED WITH THE DIFFERENTIALS OF THE
* TWO-ELECTRON INTEGRALS OVER ACTIVE-SPACE M.O.S W.R.T. MOTION
* OF THE ATOM NATI.
************************************************************************
COMMON /MOLKST/ NUMAT,NAT(NUMATM),NFIRST(NUMATM),NMIDLE(NUMATM),
1 NLAST(NUMATM), NORBS, NELECS,NALPHA,NBETA,
2 NCLOSE,NOPEN,NDUMY,FRACT
COMMON /CIBITS/ NMOS,LAB,NELEC, NBO(3)
COMMON /XYIJKL/ XY(NMECI,NMECI,NMECI,NMECI)
DIMENSION NB(0:8)
DATA NB /1,0,0,10,0,0,0,0,45/
NA=NMOS
DO 110 I=1,NA
DO 110 J=1,I
IPQ=0
DO 20 II=1,NUMAT
IF(II.EQ.NATI) GOTO 20
DO 10 IP=NFIRST(II),NLAST(II)
DO 10 IQ=NFIRST(II),IP
IPQ=IPQ+1
CIJ(IPQ)=C(IP,I)*C(IQ,J)+C(IP,J)*C(IQ,I)
10 CONTINUE
20 CONTINUE
I77=IPQ+1
DO 30 IP=NFIRST(NATI),NLAST(NATI)
DO 30 IQ=NFIRST(NATI),IP
IPQ=IPQ+1
CIJ(IPQ)=C(IP,I)*C(IQ,J)+C(IP,J)*C(IQ,I)
30 CONTINUE
DO 40 II=1,IPQ
40 WCIJ(II)=0.D0
KR=1
JS=1
NBJ=NB(NLAST(NATI)-NFIRST(NATI))
DO 50 II=1,NUMAT
IF (II.EQ.NATI) GOTO 50
NBI=NB(NLAST(II)-NFIRST(II))
CALL FORMXY
1(W(KR), KR, WCIJ(I77), WCIJ(JS), CIJ(I77), NBJ, CIJ(JS), NBI)
JS=JS+NBI
50 CONTINUE
DO 100 K=1,I
IF(K.EQ.I) THEN
LL=J
ELSE
LL=K
ENDIF
DO 100 L=1,LL
IPQ=0
DO 70 II=1,NUMAT
IF(II.EQ.NATI) GOTO 70
DO 60 IP=NFIRST(II),NLAST(II)
DO 60 IQ=NFIRST(II),IP
IPQ=IPQ+1
CKL(IPQ)=C(IP,K)*C(IQ,L)+C(IP,L)*C(IQ,K)
60 CONTINUE
70 CONTINUE
DO 80 IP=NFIRST(NATI),NLAST(NATI)
DO 80 IQ=NFIRST(NATI),IP
IPQ=IPQ+1
CKL(IPQ)=C(IP,K)*C(IQ,L)+C(IP,L)*C(IQ,K)
80 CONTINUE
SUM=0.D0
DO 90 II=1,IPQ
90 SUM=SUM+CKL(II)*WCIJ(II)
XY(I,J,K,L)=SUM
XY(I,J,L,K)=SUM
XY(J,I,K,L)=SUM
XY(J,I,L,K)=SUM
XY(K,L,I,J)=SUM
XY(K,L,J,I)=SUM
XY(L,K,I,J)=SUM
XY(L,K,J,I)=SUM
100 CONTINUE
110 CONTINUE
RETURN
END
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Relation.Binary.Raw where
open import Cubical.Relation.Binary.Base public
open import Cubical.Relation.Binary.Raw.Definitions public
open import Cubical.Relation.Binary.Raw.Structures public
open import Cubical.Relation.Binary.Raw.Bundles public
|
import mathlib.prod
import group_theory.group_action.sigma
import phase1.code_equiv
/-!
# Allowable permutations
-/
-- Note to whoever fixes this file: We may want to use `type_index` instead of `Λ` in some places
-- now that supports are defined in these cases.
open function set with_bot
open_locale pointwise
noncomputable theory
universe u
namespace con_nf
variables [params.{u}] (α : Λ) [core_tangle_cumul α] (β : Iio_index α) (γ : Iio α)
open code
/-- A semi-allowable permutation is a `-1`-allowable permutation of atoms (a near-litter
permutation) together with allowable permutations on all `γ < β`. This forms a group structure
automatically. -/
@[derive group] def semiallowable_perm : Type u := Π β : Iio_index α, allowable β
namespace semiallowable_perm
variables {α} (π : semiallowable_perm α) (c : code α)
/-- The allowable permutation at a lower level corresponding to a semi-allowable permutation. -/
noncomputable! def to_allowable : semiallowable_perm α →* allowable β :=
⟨λ f, f β, rfl, λ _ _, rfl⟩
/-- Reinterpret a semi-allowable permutation as a structural permutation. -/
noncomputable! def to_struct_perm : semiallowable_perm α →* struct_perm α :=
{ to_fun := λ f, struct_perm.to_coe $ λ β hβ, (f ⟨β, hβ⟩).to_struct_perm,
map_one' := struct_perm.of_coe.injective $ funext $ λ β, funext $ λ hβ, match β, hβ with
| ⊥, _ := by { simp only [struct_perm.of_coe_to_coe, struct_perm.of_coe_one, pi.one_apply],
exact struct_perm.to_bot_one }
| (β : Λ), (hβ : ↑β < ↑α) := by { simp only [struct_perm.of_coe_to_coe, struct_perm.of_coe_one,
pi.one_apply], exact allowable.to_struct_perm.map_one }
end,
map_mul' := λ f g, struct_perm.of_coe.injective $ funext $ λ β, funext $ λ hβ, match β, hβ with
| ⊥, _ := by { simp only [struct_perm.of_coe_to_coe, struct_perm.of_coe_mul, pi.mul_apply],
exact struct_perm.to_bot_mul _ _ }
| (β : Λ), (hβ : ↑β < ↑α) := by { simp only [struct_perm.of_coe_to_coe, struct_perm.of_coe_mul,
pi.mul_apply], exact allowable.to_struct_perm.map_mul _ _ }
end }
section
variables {X : Type*} [mul_action (struct_perm α) X]
instance mul_action_of_struct_perm : mul_action (semiallowable_perm α) X :=
mul_action.comp_hom _ to_struct_perm
@[simp] lemma to_struct_perm_smul (f : semiallowable_perm α) (x : X) :
f.to_struct_perm • x = f • x := rfl
end
instance mul_action_tangle : mul_action (semiallowable_perm α) (tangle β) :=
mul_action.comp_hom _ $ to_allowable β
instance mul_action_tangle' {β : Iio α} : mul_action (semiallowable_perm α) (tangle β) :=
show mul_action (semiallowable_perm α) (tangle $ Iio_coe β), from infer_instance
instance mul_action_tangle'' : mul_action (semiallowable_perm α) (tangle (γ : Λ)) :=
show mul_action (semiallowable_perm α) (tangle $ Iio_coe γ), from infer_instance
@[simp] lemma to_allowable_smul (f : semiallowable_perm α) (t : tangle β) :
to_allowable β f • t = f • t := rfl
attribute [derive mul_action (semiallowable_perm α)] code
@[simp] lemma fst_smul : (π • c).1 = c.1 := rfl
@[simp] lemma snd_smul : (π • c).2 = π • c.2 := rfl
@[simp] lemma smul_mk (f : semiallowable_perm α) (γ s) : f • (mk γ s : code α) = mk γ (f • s) := rfl
instance has_smul_nonempty_code : has_smul (semiallowable_perm α) (nonempty_code α) :=
⟨λ π c, ⟨π • c, c.2.image _⟩⟩
@[simp, norm_cast] lemma coe_smul (c : nonempty_code α) : (↑(π • c) : code α) = π • c := rfl
instance mul_action_nonempty_code : mul_action (semiallowable_perm α) (nonempty_code α) :=
subtype.coe_injective.mul_action _ coe_smul
end semiallowable_perm
variables [position_data.{}] [positioned_tangle_cumul α] [almost_tangle_cumul α]
[core_tangle_data α]
/-- An allowable permutation is a semi-allowable permutation whose action on codes preserves
equivalence. -/
def allowable_perm := {π : semiallowable_perm α // ∀ X Y : code α, π • X ≡ π • Y ↔ X ≡ Y}
variables {α} {f : allowable_perm α} {c d : code α}
namespace allowable_perm
instance : has_coe_t (allowable_perm α) (semiallowable_perm α) := @coe_base _ _ coe_subtype
lemma coe_injective : injective (coe : allowable_perm α → semiallowable_perm α) :=
subtype.coe_injective
instance : has_one (allowable_perm α) := ⟨⟨1, λ _ _, by simp_rw one_smul⟩⟩
instance : has_inv (allowable_perm α) :=
⟨λ f, ⟨f⁻¹, λ c d, by rw [←f.prop, smul_inv_smul, smul_inv_smul]⟩⟩
instance : has_mul (allowable_perm α) :=
⟨λ f g, ⟨f * g, λ c d, by simp_rw [mul_smul, f.prop, g.prop]⟩⟩
instance : has_div (allowable_perm α) :=
⟨λ f g, ⟨f / g, by { simp_rw [div_eq_mul_inv], exact (f * g⁻¹).2 }⟩⟩
instance : has_pow (allowable_perm α) ℕ :=
⟨λ f n, ⟨f ^ n, begin
induction n with d hd,
{ simp_rw pow_zero,
exact (1 : allowable_perm α).2 },
{ simp_rw pow_succ,
exact (f * ⟨f ^ d, hd⟩).2 }
end⟩⟩
instance : has_pow (allowable_perm α) ℤ :=
⟨λ f n, ⟨f ^ n, begin
cases n,
{ simp_rw zpow_of_nat,
exact (f ^ n).2 },
{ simp_rw zpow_neg_succ_of_nat,
exact (f ^ (n + 1))⁻¹.2 }
end⟩⟩
@[simp] lemma coe_one : ((1 : allowable_perm α) : semiallowable_perm α) = 1 := rfl
@[simp] lemma coe_inv (f : allowable_perm α) : (↑(f⁻¹) : semiallowable_perm α) = f⁻¹ := rfl
@[simp] lemma coe_mul (f g : allowable_perm α) : (↑(f * g) : semiallowable_perm α) = f * g := rfl
@[simp] lemma coe_div (f g : allowable_perm α) : (↑(f / g) : semiallowable_perm α) = f / g := rfl
@[simp] lemma coe_pow (f : allowable_perm α) (n : ℕ) :
(↑(f ^ n) : semiallowable_perm α) = f ^ n := rfl
@[simp] lemma coe_zpow (f : allowable_perm α) (n : ℤ) :
(↑(f ^ n) : semiallowable_perm α) = f ^ n := rfl
instance : group (allowable_perm α) :=
coe_injective.group _ coe_one coe_mul coe_inv coe_div coe_pow coe_zpow
/-- The coercion from allowable to semi-allowable permutation as a monoid homomorphism. -/
@[simps] noncomputable! def coe_hom : allowable_perm α →* semiallowable_perm α :=
⟨coe, coe_one, coe_mul⟩
/-- Turn an allowable permutation into a structural permutation. -/
def to_struct_perm : allowable_perm α →* struct_perm α :=
semiallowable_perm.to_struct_perm.comp coe_hom
section
variables {X : Type*} [mul_action (semiallowable_perm α) X]
instance mul_action_of_semiallowable_perm : mul_action (allowable_perm α) X :=
mul_action.comp_hom _ coe_hom
@[simp] lemma coe_smul (f : allowable_perm α) (x : X) : (f : semiallowable_perm α) • x = f • x :=
rfl
end
@[simp] lemma fst_smul_near_litter (f : allowable_perm α) (N : near_litter) : (f • N).1 = f • N.1 :=
rfl
@[simp] lemma snd_smul_near_litter (f : allowable_perm α) (N : near_litter) :
((f • N).2 : set atom) = f • ↑N.2 := rfl
@[simp] lemma smul_typed_near_litter (f : allowable_perm α) (N : near_litter) :
f • (typed_near_litter N : tangle (γ : Λ)) =
typed_near_litter ((f : semiallowable_perm α) γ • N) :=
allowable.smul_typed_near_litter _ _
@[simp] lemma fst_smul (f : allowable_perm α) (c : code α) : (f • c).1 = c.1 := rfl
@[simp] lemma snd_smul (f : allowable_perm α) (c : code α) : (f • c).2 = f • c.2 := rfl
@[simp] lemma smul_mk (f : allowable_perm α) (γ s) : f • (mk γ s : code α) = mk γ (f • s) := rfl
lemma _root_.con_nf.code.equiv.smul : c ≡ d → f • c ≡ f • d := (f.2 _ _).2
end allowable_perm
namespace allowable_perm
variables {β γ}
lemma smul_f_map (hβγ : β ≠ γ) (π : allowable_perm α) (t : tangle β) :
((π : semiallowable_perm α) γ) • f_map (coe_ne hβγ) t = f_map (coe_ne hβγ) (π • t) :=
begin
classical,
have equiv := code.equiv.singleton hβγ t,
rw ← π.prop at equiv,
simp only [subtype.val_eq_coe, rec_bot_coe_coe, image_smul, smul_set_singleton] at equiv,
simp only [code.equiv_iff] at equiv,
obtain a | ⟨heven, ε, hε, hA⟩ | ⟨heven, ε, hε, hA⟩ | ⟨c, heven, ε, hε, ζ, hζ, h₁, h₂⟩ := equiv,
{ cases hβγ.symm (congr_arg sigma.fst a) },
{ simp_rw [semiallowable_perm.smul_mk, smul_set_singleton] at hA,
cases A_map_code_ne_singleton _ hA.symm,
exact hβγ.symm },
{ have := congr_arg sigma.fst hA,
simp only [semiallowable_perm.smul_mk, fst_A_map_code, fst_mk, Iio.coe_inj] at this,
subst this,
simp only [semiallowable_perm.smul_mk, A_map_code_ne _ (mk β _) hβγ, mk_inj] at hA,
simp only [coe_smul, snd_mk, smul_set_singleton, A_map_singleton] at hA,
simp only [← image_smul, image_image, smul_typed_near_litter] at hA,
rw ← image_image at hA,
rw image_eq_image typed_near_litter.injective at hA,
have := litter.to_near_litter_mem_local_cardinal (f_map (coe_ne hβγ) (π • t)),
rw ← hA at this,
obtain ⟨N, hN₁, hN₂⟩ := this,
have := congr_arg sigma.fst hN₂,
simp only [litter.to_near_litter_fst] at this,
rw [← allowable.to_struct_perm_smul, struct_perm.smul_near_litter_fst,
allowable.to_struct_perm_smul] at this,
rw mem_local_cardinal at hN₁,
rw hN₁ at this,
exact this },
{ have := congr_arg sigma.fst h₁,
simp only [coe_smul, smul_mk, fst_mk, fst_A_map_code] at this,
subst this,
simp only [coe_smul, smul_mk, smul_set_singleton] at h₁,
cases A_map_code_ne_singleton hε h₁.symm }
end
lemma smul_A_map (π : allowable_perm α) (s : set (tangle β)) (hβγ : β ≠ γ) :
π • A_map hβγ s = A_map hβγ (π • s) :=
begin
ext,
simp only [A_map, mem_image, mem_Union, mem_local_cardinal, exists_prop, ← image_smul],
simp only [exists_exists_and_eq_and, smul_typed_near_litter, ← smul_f_map hβγ],
split,
{ rintro ⟨N, ⟨y, y_mem, y_fmap⟩, rfl⟩,
refine ⟨(π : semiallowable_perm α) γ • N, ⟨y, y_mem, _⟩, rfl⟩,
rw ← y_fmap,
refl },
{ rintro ⟨N, ⟨y, y_mem, y_fmap⟩, rfl⟩,
refine ⟨((π : semiallowable_perm α) γ)⁻¹ • N, ⟨y, y_mem, _⟩, _⟩,
{ change _ • N.fst = _,
simp only [y_fmap, map_inv, inv_smul_eq_iff],
refl },
{ simp only [smul_inv_smul] } },
end
lemma smul_A_map_code (π : allowable_perm α) (hc : c.1 ≠ γ) :
π • A_map_code γ c = A_map_code γ (π • c) :=
by simp only [A_map_code_ne γ c hc, A_map_code_ne γ (π • c) hc, smul_A_map, snd_smul, smul_mk]
end allowable_perm
lemma A_map_rel.smul : c ↝ d → f • c ↝ f • d :=
by { rintro ⟨γ, hγ⟩, exact (A_map_rel_iff _ _).2 ⟨_, hγ, f.smul_A_map_code hγ⟩ }
@[simp] lemma smul_A_map_rel : f • c ↝ f • d ↔ c ↝ d :=
by { refine ⟨λ h, _, A_map_rel.smul⟩, rw [←inv_smul_smul f c, ←inv_smul_smul f d], exact h.smul }
namespace code
lemma is_even_smul_nonempty : ∀ (c : nonempty_code α), (f • c.val).is_even ↔ c.val.is_even
| ⟨c, hc⟩ := begin
simp_rw code.is_even_iff,
split; intros h d hd,
{ have := hd.nonempty_iff.2 hc,
let rec : A_map_rel' ⟨d, this⟩ ⟨c, hc⟩ := A_map_rel_coe_coe.1 hd,
exact code.not_is_even.1 (λ H, (h _ hd.smul).not_is_even $
(is_even_smul_nonempty ⟨d, this⟩).2 H) },
{ rw ←smul_inv_smul f d at hd ⊢,
rw smul_A_map_rel at hd,
have := hd.nonempty_iff.2 hc,
let rec : A_map_rel' ⟨_, this⟩ ⟨c, hc⟩ := A_map_rel_coe_coe.1 hd,
exact code.not_is_even.1 (λ H, (h _ hd).not_is_even $ (is_even_smul_nonempty ⟨_, this⟩).1 H) }
end
using_well_founded { dec_tac := `[assumption] }
@[simp] lemma is_even_smul : (f • c).is_even ↔ c.is_even :=
begin
cases c.2.eq_empty_or_nonempty,
{ rw [is_empty.is_even_iff h, is_empty.is_even_iff],
{ refl },
simpa [code.is_empty] },
{ exact is_even_smul_nonempty ⟨c, h⟩ }
end
@[simp] lemma is_odd_smul : (f • c).is_odd ↔ c.is_odd :=
by simp_rw [←code.not_is_even, is_even_smul]
alias is_even_smul ↔ _ is_even.smul
alias is_odd_smul ↔ _ is_odd.smul
end code
end con_nf
|
(*
* Copyright Florian Haftmann
*
* SPDX-License-Identifier: BSD-2-Clause
*)
section \<open>Ancient comprehensive Word Library\<close>
theory Word_Lib_Sumo
imports
"HOL-Library.Word"
Aligned
Bit_Comprehension
Bit_Shifts_Infix_Syntax
Bits_Int
Bitwise_Signed
Bitwise
Enumeration_Word
Generic_set_bit
Hex_Words
Least_significant_bit
More_Arithmetic
More_Divides
More_Sublist
Even_More_List
More_Misc
Strict_part_mono
Legacy_Aliases
Most_significant_bit
Next_and_Prev
Norm_Words
Reversed_Bit_Lists
Rsplit
Signed_Words
Syntax_Bundles
Typedef_Morphisms
Type_Syntax
Word_EqI
Word_Lemmas
Word_8
Word_16
Word_32
Word_Syntax
Signed_Division_Word
More_Word_Operations
Many_More
begin
unbundle bit_projection_infix_syntax
declare word_induct2[induct type]
declare word_nat_cases[cases type]
declare signed_take_bit_Suc [simp]
(* these generate take_bit terms, which we often don't want for concrete lengths *)
lemmas of_int_and_nat = unsigned_of_nat unsigned_of_int signed_of_int signed_of_nat
bundle no_take_bit
begin
declare of_int_and_nat[simp del]
end
lemmas bshiftr1_def = bshiftr1_eq
lemmas is_down_def = is_down_eq
lemmas is_up_def = is_up_eq
lemmas mask_def = mask_eq
lemmas scast_def = scast_eq
lemmas shiftl1_def = shiftl1_eq
lemmas shiftr1_def = shiftr1_eq
lemmas sshiftr1_def = sshiftr1_eq
lemmas sshiftr_def = sshiftr_eq_funpow_sshiftr1
lemmas to_bl_def = to_bl_eq
lemmas ucast_def = ucast_eq
lemmas unat_def = unat_eq_nat_uint
lemmas word_cat_def = word_cat_eq
lemmas word_reverse_def = word_reverse_eq_of_bl_rev_to_bl
lemmas word_roti_def = word_roti_eq_word_rotr_word_rotl
lemmas word_rotl_def = word_rotl_eq
lemmas word_rotr_def = word_rotr_eq
lemmas word_sle_def = word_sle_eq
lemmas word_sless_def = word_sless_eq
lemmas uint_0 = uint_nonnegative
lemmas uint_lt = uint_bounded
lemmas uint_mod_same = uint_idem
lemmas of_nth_def = word_set_bits_def
lemmas of_nat_word_eq_iff = word_of_nat_eq_iff
lemmas of_nat_word_eq_0_iff = word_of_nat_eq_0_iff
lemmas of_int_word_eq_iff = word_of_int_eq_iff
lemmas of_int_word_eq_0_iff = word_of_int_eq_0_iff
lemmas word_next_def = word_next_unfold
lemmas word_prev_def = word_prev_unfold
lemmas is_aligned_def = is_aligned_iff_dvd_nat
lemmas word_and_max_simps =
word8_and_max_simp
word16_and_max_simp
word32_and_max_simp
lemma distinct_lemma: "f x \<noteq> f y \<Longrightarrow> x \<noteq> y" by auto
lemmas and_bang = word_and_nth
lemmas sdiv_int_def = signed_divide_int_def
lemmas smod_int_def = signed_modulo_int_def
(* shortcut for some specific lengths *)
lemma word_fixed_sint_1[simp]:
"sint (1::8 word) = 1"
"sint (1::16 word) = 1"
"sint (1::32 word) = 1"
"sint (1::64 word) = 1"
by (auto simp: sint_word_ariths)
declare of_nat_diff [simp]
(* Haskellish names/syntax *)
notation (input)
bit ("testBit")
lemmas cast_simps = cast_simps ucast_down_bl
(* shadows the slightly weaker Word.nth_ucast *)
lemma nth_ucast:
"(ucast (w::'a::len word)::'b::len word) !! n =
(w !! n \<and> n < min LENGTH('a) LENGTH('b))"
by (auto simp add: bit_simps not_le dest: bit_imp_le_length)
end
|
-- Andreas, Jesper, 2015-07-02 Error in copyScope
-- To trigger the bug, it is important that
-- the main module is in a subdirectory of the imported module.
module Issue1597.Main where
open import Issue1597 -- external import is needed
module B where
open A public -- public is needed
module C = B
postulate p : C.M.Nat
-- ERROR WAS: not in scope C.M.Nat
|
Formal statement is: lemma holomorphic_on_imp_differentiable_on: "f holomorphic_on s \<Longrightarrow> f differentiable_on s" Informal statement is: If $f$ is holomorphic on $s$, then $f$ is differentiable on $s$. |
State Before: M : Type u_2
N : Type u_1
P : Type ?u.144954
inst✝³ : MulOneClass M
inst✝² : MulOneClass N
inst✝¹ : MulOneClass P
S : Submonoid M
A : Type ?u.144975
inst✝ : SetLike A M
hA : SubmonoidClass A M
S' : A
F : Type ?u.144999
mc : MonoidHomClass F M N
⊢ mker (inr M N) = ⊥ State After: case h
M : Type u_2
N : Type u_1
P : Type ?u.144954
inst✝³ : MulOneClass M
inst✝² : MulOneClass N
inst✝¹ : MulOneClass P
S : Submonoid M
A : Type ?u.144975
inst✝ : SetLike A M
hA : SubmonoidClass A M
S' : A
F : Type ?u.144999
mc : MonoidHomClass F M N
x : N
⊢ x ∈ mker (inr M N) ↔ x ∈ ⊥ Tactic: ext x State Before: case h
M : Type u_2
N : Type u_1
P : Type ?u.144954
inst✝³ : MulOneClass M
inst✝² : MulOneClass N
inst✝¹ : MulOneClass P
S : Submonoid M
A : Type ?u.144975
inst✝ : SetLike A M
hA : SubmonoidClass A M
S' : A
F : Type ?u.144999
mc : MonoidHomClass F M N
x : N
⊢ x ∈ mker (inr M N) ↔ x ∈ ⊥ State After: no goals Tactic: simp [mem_mker] |
/-
Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-/
import data.finsupp.basic
/-!
# Lattice structure on finsupps
This file provides instances of ordered structures on finsupps.
-/
open_locale classical
noncomputable theory
variables {α : Type*} {β : Type*} [has_zero β] {μ : Type*} [canonically_ordered_add_monoid μ]
variables {γ : Type*} [canonically_linear_ordered_add_monoid γ]
namespace finsupp
instance [semilattice_inf β] : semilattice_inf (α →₀ β) :=
{ inf := zip_with (⊓) inf_idem,
inf_le_left := λ a b c, inf_le_left,
inf_le_right := λ a b c, inf_le_right,
le_inf := λ a b c h1 h2 s, le_inf (h1 s) (h2 s),
..finsupp.partial_order, }
@[simp]
lemma inf_apply [semilattice_inf β] {a : α} {f g : α →₀ β} : (f ⊓ g) a = f a ⊓ g a := rfl
@[simp]
lemma support_inf {f g : α →₀ γ} : (f ⊓ g).support = f.support ∩ g.support :=
begin
ext, simp only [inf_apply, mem_support_iff, ne.def,
finset.mem_union, finset.mem_filter, finset.mem_inter],
simp only [inf_eq_min, ← nonpos_iff_eq_zero, min_le_iff, not_or_distrib]
end
instance [semilattice_sup β] : semilattice_sup (α →₀ β) :=
{ sup := zip_with (⊔) sup_idem,
le_sup_left := λ a b c, le_sup_left,
le_sup_right := λ a b c, le_sup_right,
sup_le := λ a b c h1 h2 s, sup_le (h1 s) (h2 s),
..finsupp.partial_order, }
@[simp]
lemma sup_apply [semilattice_sup β] {a : α} {f g : α →₀ β} : (f ⊔ g) a = f a ⊔ g a := rfl
@[simp]
lemma support_sup {f g : α →₀ γ} : (f ⊔ g).support = f.support ∪ g.support :=
begin
ext, simp only [finset.mem_union, mem_support_iff, sup_apply, ne.def, ← bot_eq_zero],
rw sup_eq_bot_iff, tauto,
end
instance lattice [lattice β] : lattice (α →₀ β) :=
{ .. finsupp.semilattice_inf, .. finsupp.semilattice_sup}
lemma bot_eq_zero : (⊥ : α →₀ γ) = 0 := rfl
lemma disjoint_iff {x y : α →₀ γ} : disjoint x y ↔ disjoint x.support y.support :=
begin
unfold disjoint, repeat {rw le_bot_iff},
rw [finsupp.bot_eq_zero, ← finsupp.support_eq_empty, finsupp.support_inf], refl,
end
variable [partial_order β]
/-- The order on `finsupp`s over a partial order embeds into the order on functions -/
def order_embedding_to_fun :
(α →₀ β) ↪o (α → β) :=
⟨⟨λ (f : α →₀ β) (a : α), f a, λ f g h, finsupp.ext (λ a, by { dsimp at h, rw h,} )⟩,
λ a b, (@le_def _ _ _ _ a b).symm⟩
@[simp] lemma order_embedding_to_fun_apply {f : α →₀ β} {a : α} :
order_embedding_to_fun f a = f a := rfl
lemma monotone_to_fun : monotone (finsupp.to_fun : (α →₀ β) → (α → β)) := λ f g h a, le_def.1 h a
end finsupp
|
-- Andreas, 2015-12-10, issue reported by Andrea Vezzosi
open import Common.Equality
open import Common.Bool
id : Bool → Bool
id true = true
id false = false
is-id : ∀ x → x ≡ id x
is-id true = refl
is-id false = refl
postulate
P : Bool → Set
b : Bool
p : P (id b)
proof : P b
proof rewrite is-id b = p
|
The heavily armed WA @-@ 116 autogyro " Little Nellie " was included after Ken Adam heard a radio interview with its inventor , RAF Wing Commander Ken Wallis . Little Nellie was named after music hall star Nellie Wallace , who has a similar surname to its inventor . Wallis piloted his invention , which was equipped with various mock @-@ up armaments by John Stears ' special effects team , during production .
|
theory T10
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. undr(x, join(y, z)) = join(undr(x, y), undr(x, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. over(x, meet(y, z)) = join(over(x, y), over(x, z))) &
(\<forall> x::nat. \<forall> y::nat. invo(join(x, y)) = meet(invo(x), invo(y))) &
(\<forall> x::nat. \<forall> y::nat. invo(meet(x, y)) = join(invo(x), invo(y))) &
(\<forall> x::nat. invo(invo(x)) = x)
) \<longrightarrow>
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(x, meet(y, z)) = meet(mult(x, y), mult(x, z)))
"
nitpick[card nat=4,timeout=86400]
oops
end |
(* Title: HOL/Auth/n_german_lemma_inv__23_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__23_on_rules imports n_german_lemma_on_inv__23
begin
section{*All lemmas on causal relation between inv__23*}
lemma lemma_inv__23_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__23 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__23) 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__23) 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__23) 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__23) 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__23) 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__23) 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__23) 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__23) 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__23) 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__23) 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__23) 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__23) 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__23) done
}
ultimately show "invHoldForRule s f r (invariants N)"
by satx
qed
end
|
@testset "Player" begin
# Test Player
T = Float64
p = 3
model = UnicycleGame(p=p)
x0 = @SVector [1.0, 2.0, 3.0, 4.0]
id = 2
lane_id = 1
Q = Diagonal(rand(SVector{model.ni[1],T}))
R = Diagonal(rand(SVector{model.mi[1],T}))
xf = rand(SVector{model.ni[1],T})
uf = rand(SVector{model.mi[1],T})
u_min = rand(SVector{model.mi[1],T})
u_max = rand(SVector{model.mi[1],T})
v_min = rand()
v_max = rand()
r_col = 1.0
r_cost = 1.0
μ = 1.0
player = Player(x0, id, lane_id, Q, R, xf, uf, u_min, u_max, v_min, v_max, r_col, r_cost, μ)
@test typeof(player) <: Player
lane = Lane()
player1 = Player(model, lane)
@test typeof(player1) <: Player
end
|
! { dg-do run }
!
! PR 42647: Missed initialization/dealloc of allocatable scalar DT with allocatable component
!
! Contributed by Tobias Burnus <[email protected]>
module m
type st
integer , allocatable :: a1
end type st
type at
integer , allocatable :: a2(:)
end type at
type t1
type(st), allocatable :: b1
end type t1
type t2
type(st), allocatable :: b2(:)
end type t2
type t3
type(at), allocatable :: b3
end type t3
type t4
type(at), allocatable :: b4(:)
end type t4
end module m
use m
type(t1) :: na1, a1, aa1(:)
type(t2) :: na2, a2, aa2(:)
type(t3) :: na3, a3, aa3(:)
type(t4) :: na4, a4, aa4(:)
allocatable :: a1, a2, a3, a4, aa1, aa2, aa3,aa4
if(allocated(a1)) call abort()
if(allocated(a2)) call abort()
if(allocated(a3)) call abort()
if(allocated(a4)) call abort()
if(allocated(aa1)) call abort()
if(allocated(aa2)) call abort()
if(allocated(aa3)) call abort()
if(allocated(aa4)) call abort()
if(allocated(na1%b1)) call abort()
if(allocated(na2%b2)) call abort()
if(allocated(na3%b3)) call abort()
if(allocated(na4%b4)) call abort()
end
! { dg-final { cleanup-modules "m" } }
|
State Before: α : Type u_1
β : Type ?u.123028
γ : Type ?u.123031
l✝ m : Language α
a b x : List α
l : Language α
⊢ 1 + l∗ * l = l∗ State After: no goals Tactic: rw [mul_self_kstar_comm, one_add_self_mul_kstar_eq_kstar] |
State Before: ι : Type ?u.59758
α : Type u_1
β : Type ?u.59764
π : ι → Type ?u.59769
inst✝ : GeneralizedBooleanAlgebra α
a b c d : α
⊢ Disjoint (a ∆ b) (a ⊓ b) State After: ι : Type ?u.59758
α : Type u_1
β : Type ?u.59764
π : ι → Type ?u.59769
inst✝ : GeneralizedBooleanAlgebra α
a b c d : α
⊢ Disjoint ((a ⊔ b) \ (a ⊓ b)) (a ⊓ b) Tactic: rw [symmDiff_eq_sup_sdiff_inf] State Before: ι : Type ?u.59758
α : Type u_1
β : Type ?u.59764
π : ι → Type ?u.59769
inst✝ : GeneralizedBooleanAlgebra α
a b c d : α
⊢ Disjoint ((a ⊔ b) \ (a ⊓ b)) (a ⊓ b) State After: no goals Tactic: exact disjoint_sdiff_self_left |
theory Just_Do_It_Examples imports Monomorphic_Monad begin
text \<open>Examples adapted from Gibbons and Hinze (ICFP 2011)\<close>
subsection \<open>Towers of Hanoi\<close>
type_synonym 'm tick = "'m \<Rightarrow> 'm"
locale monad_count_base = monad_base return bind
for return :: "('a, 'm) return"
and bind :: "('a, 'm) bind"
+
fixes tick :: "'m tick"
locale monad_count = monad_count_base return bind tick + monad return bind
for return :: "('a, 'm) return"
and bind :: "('a, 'm) bind"
and tick :: "'m tick"
+
assumes bind_tick: "bind (tick m) f = tick (bind m f)"
locale hanoi_base = monad_count_base return bind tick
for return :: "(unit, 'm) return"
and bind :: "(unit, 'm) bind"
and tick :: "'m tick"
begin
primrec hanoi :: "nat \<Rightarrow> 'm" where
"hanoi 0 = return ()"
| "hanoi (Suc n) = bind (hanoi n) (\<lambda>_. tick (hanoi n))"
primrec repeat :: "nat \<Rightarrow> 'm \<Rightarrow> 'm"
where
"repeat 0 mx = return ()"
| "repeat (Suc n) mx = bind mx (\<lambda>_. repeat n mx)"
end
locale hanoi = hanoi_base return bind tick + monad_count return bind tick
for return :: "(unit, 'm) return"
and bind :: "(unit, 'm) bind"
and tick :: "'m tick"
begin
lemma repeat_1: "repeat 1 mx = mx"
by(simp add: bind_return)
lemma repeat_add: "repeat (n + m) mx = bind (repeat n mx) (\<lambda>_. repeat m mx)"
by(induction n)(simp_all add: return_bind bind_assoc)
lemma hanoi_correct: "hanoi n = repeat (2 ^ n - 1) (tick (return ()))"
proof(induction n)
case 0 show ?case by simp
next
case (Suc n)
have "hanoi (Suc n) = repeat ((2 ^ n - 1) + 1 + (2 ^ n - 1)) (tick (return ()))"
by(simp only: hanoi.simps repeat_add repeat_1 Suc.IH bind_assoc bind_tick return_bind)
also have "(2 ^ n - 1) + 1 + (2 ^ n - 1) = (2 ^ Suc n - 1 :: nat)" by simp
finally show ?case .
qed
end
subsection \<open>Fast product\<close>
locale fast_product_base = monad_catch_base return bind fail catch
for return :: "(int, 'm) return"
and bind :: "(int, 'm) bind"
and fail :: "'m fail"
and catch :: "'m catch"
begin
primrec work :: "int list \<Rightarrow> 'm"
where
"work [] = return 1"
| "work (x # xs) = (if x = 0 then fail else bind (work xs) (\<lambda>i. return (x * i)))"
definition fastprod :: "int list \<Rightarrow> 'm"
where "fastprod xs = catch (work xs) (return 0)"
end
locale fast_product = fast_product_base return bind fail catch + monad_catch return bind fail catch
for return :: "(int, 'm) return"
and bind :: "(int, 'm) bind"
and fail :: "'m fail"
and catch :: "'m catch"
begin
lemma work_alt_def: "work xs = (if 0 \<in> set xs then fail else return (prod_list xs))"
by(induction xs)(simp_all add: fail_bind return_bind)
lemma fastprod_correct: "fastprod xs = return (prod_list xs)"
by(simp add: fastprod_def work_alt_def catch_fail catch_return prod_list_zero_iff[symmetric])
end
end
|
! Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
!
! 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 m
type :: t
real :: y
end type
end module
use m
implicit type(t)(x)
z = x%y !OK: x is type(t)
!ERROR: 'w' is not an object of derived type; it is implicitly typed
z = w%y
end
|
lemma fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space" shows borel_measurable_vimage_open_interval: "f \<in> borel_measurable (lebesgue_on S) \<longleftrightarrow> (\<forall>a b. {x \<in> S. f x \<in> box a b} \<in> sets (lebesgue_on S))" (is ?thesis1) and borel_measurable_vimage_open: "f \<in> borel_measurable (lebesgue_on S) \<longleftrightarrow> (\<forall>T. open T \<longrightarrow> {x \<in> S. f x \<in> T} \<in> sets (lebesgue_on S))" (is ?thesis2) |
(** Construction of actegory morphisms
Part Generalization of pointed distributivity laws to lifted distributivity laws in general monads
- definition
- construction of actegory morphism from it
- composition
Part Closure of the notion of actegory morphisms under
- the pointwise binary product of functors
- the pointwise binary coproduct of functors
author: Ralph Matthes 2022
*)
Require Import UniMath.Foundations.All.
Require Import UniMath.MoreFoundations.All.
Require Import UniMath.CategoryTheory.Core.Categories.
Require Import UniMath.CategoryTheory.Core.Functors.
Require Import UniMath.CategoryTheory.Core.NaturalTransformations.
Require Import UniMath.CategoryTheory.Core.Isos.
Require Import UniMath.CategoryTheory.PrecategoryBinProduct.
Require Import UniMath.CategoryTheory.whiskering.
Require Import UniMath.CategoryTheory.Monoidal.WhiskeredBifunctors.
Require Import UniMath.CategoryTheory.Monoidal.Categories.
Require Import UniMath.CategoryTheory.Monoidal.Functors.
Require Import UniMath.CategoryTheory.Actegories.Actegories.
Require Import UniMath.CategoryTheory.Actegories.MorphismsOfActegories.
Require Import UniMath.CategoryTheory.Actegories.ConstructionOfActegories.
Require Import UniMath.CategoryTheory.coslicecat.
Require Import UniMath.CategoryTheory.Monoidal.Examples.MonoidalPointedObjects.
Require Import UniMath.CategoryTheory.limits.binproducts.
Require Import UniMath.CategoryTheory.limits.bincoproducts.
Require Import UniMath.CategoryTheory.limits.coproducts.
Require Import UniMath.CategoryTheory.Actegories.CoproductsInActegories.
Require Import UniMath.CategoryTheory.Actegories.ProductsInActegories.
Require Import UniMath.CategoryTheory.Actegories.ProductActegory.
Local Open Scope cat.
Import BifunctorNotations.
Import MonoidalNotations.
Import ActegoryNotations.
Section LiftedLineatorAndLiftedDistributivity.
Context {V : category} (Mon_V : monoidal V)
{W : category} (Mon_W : monoidal W)
{F : W ⟶ V} (U : fmonoidal Mon_W Mon_V F).
Section LiftedLaxLineator.
Context {C D : category} (ActC : actegory Mon_V C) (ActD : actegory Mon_V D).
Section OnFunctors.
Context {H : functor C D} (ll : lineator_lax Mon_V ActC ActD H).
Definition lifted_lax_lineator_data : lineator_data Mon_W (lifted_actegory Mon_V ActC Mon_W U)
(lifted_actegory Mon_V ActD Mon_W U) H.
Proof.
intros w c. exact (ll (F w) c).
Defined.
Lemma lifted_lax_lineator_laws : lineator_laxlaws Mon_W (lifted_actegory Mon_V ActC Mon_W U)
(lifted_actegory Mon_V ActD Mon_W U) H lifted_lax_lineator_data.
Proof.
split4.
- intro; intros. apply (lineator_linnatleft _ _ _ _ ll).
- intro; intros. apply (lineator_linnatright _ _ _ _ ll).
- intro; intros. cbn. unfold lifted_lax_lineator_data, lifted_actor_data.
etrans.
2: { repeat rewrite assoc'. apply maponpaths.
rewrite assoc.
apply (lineator_preservesactor _ _ _ _ ll). }
etrans.
2: { rewrite assoc.
apply cancel_postcomposition.
apply pathsinv0, lineator_linnatright. }
etrans.
2: { rewrite assoc'.
apply maponpaths.
apply functor_comp. }
apply idpath.
- intro; intros. cbn. unfold lifted_lax_lineator_data, lifted_action_unitor_data.
etrans.
2: { apply maponpaths.
apply (lineator_preservesunitor _ _ _ _ ll). }
etrans.
2: { rewrite assoc.
apply cancel_postcomposition.
apply pathsinv0, lineator_linnatright. }
etrans.
2: { rewrite assoc'.
apply maponpaths.
apply functor_comp. }
apply idpath.
Qed.
Definition lifted_lax_lineator : lineator_lax Mon_W (lifted_actegory Mon_V ActC Mon_W U)
(lifted_actegory Mon_V ActD Mon_W U) H :=
_,,lifted_lax_lineator_laws.
End OnFunctors.
Section OnNaturalTransformations.
Context {H : functor C D} (Hl : lineator_lax Mon_V ActC ActD H)
{K : functor C D} (Kl : lineator_lax Mon_V ActC ActD K)
{ξ : H ⟹ K} (islntξ : is_linear_nat_trans Hl Kl ξ).
Lemma preserves_linearity_lifted_lax_lineator :
is_linear_nat_trans (lifted_lax_lineator Hl) (lifted_lax_lineator Kl) ξ.
Proof.
intros w c.
apply islntξ.
Qed.
End OnNaturalTransformations.
End LiftedLaxLineator.
Section LiftedDistributivity.
Section FixAnObject.
Context {v0 : V}.
Definition lifteddistributivity_data: UU := ∏ (w: W), F w ⊗_{Mon_V} v0 --> v0 ⊗_{Mon_V} F w.
Identity Coercion lifteddistributivity_data_funclass: lifteddistributivity_data >-> Funclass.
Section δ_laws.
Context (δ : lifteddistributivity_data).
Definition lifteddistributivity_nat: UU := is_nat_trans (functor_composite F (rightwhiskering_functor Mon_V v0))
(functor_composite F (leftwhiskering_functor Mon_V v0)) δ.
Definition lifteddistributivity_tensor_body (w w' : W): UU :=
δ (w ⊗_{Mon_W} w') = pr1 (fmonoidal_preservestensorstrongly U w w') ⊗^{Mon_V}_{r} v0 · α_{Mon_V} _ _ _ ·
F w ⊗^{Mon_V}_{l} δ w' · αinv_{Mon_V} _ _ _ · δ w ⊗^{Mon_V}_{r} F w' ·
α_{Mon_V} _ _ _ · v0 ⊗^{Mon_V}_{l} fmonoidal_preservestensordata U w w'.
Definition lifteddistributivity_tensor: UU := ∏ (w w' : W), lifteddistributivity_tensor_body w w'.
Definition lifteddistributivity_unit: UU :=
δ I_{Mon_W} = pr1 (fmonoidal_preservesunitstrongly U) ⊗^{Mon_V}_{r} v0 · lu_{Mon_V} v0 ·
ruinv_{Mon_V} v0 · v0 ⊗^{Mon_V}_{l} fmonoidal_preservesunit U.
End δ_laws.
Definition lifteddistributivity: UU := ∑ δ : lifteddistributivity_data,
lifteddistributivity_nat δ × lifteddistributivity_tensor δ × lifteddistributivity_unit δ.
Definition lifteddistributivity_lddata (δ : lifteddistributivity): lifteddistributivity_data := pr1 δ.
Coercion lifteddistributivity_lddata : lifteddistributivity >-> lifteddistributivity_data.
Definition lifteddistributivity_ldnat (δ : lifteddistributivity): lifteddistributivity_nat δ := pr12 δ.
Definition lifteddistributivity_ldtensor (δ : lifteddistributivity): lifteddistributivity_tensor δ := pr122 δ.
Definition lifteddistributivity_ldunit (δ : lifteddistributivity): lifteddistributivity_unit δ := pr222 δ.
Section ActegoryMorphismFromLiftedDistributivity.
Context (δ : lifteddistributivity) {C : category} (ActV : actegory Mon_V C).
Local Definition FF: C ⟶ C := leftwhiskering_functor ActV v0.
Local Definition ActW: actegory Mon_W C := lifted_actegory Mon_V ActV Mon_W U.
Definition lineator_data_from_δ: lineator_data Mon_W ActW ActW FF.
Proof.
intros w x. unfold FF. cbn.
exact (aαinv^{ActV}_{F w, v0, x} · δ w ⊗^{ActV}_{r} x · aα^{ActV}_{v0, F w, x}).
Defined.
Lemma lineator_laxlaws_from_δ: lineator_laxlaws Mon_W ActW ActW FF lineator_data_from_δ.
Proof.
assert (δ_nat := lifteddistributivity_ldnat δ).
do 2 red in δ_nat. cbn in δ_nat.
repeat split; red; intros; unfold lineator_data_from_δ; try unfold lifted_actor_data; try unfold lifted_action_unitor_data; cbn;
try unfold lifted_actor_data; try unfold lifted_action_unitor_data; cbn.
- etrans.
{ repeat rewrite assoc.
do 2 apply cancel_postcomposition.
apply actorinv_nat_leftwhisker. }
etrans.
2: { repeat rewrite assoc'.
do 2 apply maponpaths.
apply pathsinv0, actegory_actornatleft.
}
repeat rewrite assoc'.
apply maponpaths.
repeat rewrite assoc.
apply cancel_postcomposition.
apply pathsinv0, (bifunctor_equalwhiskers ActV).
- etrans.
{ repeat rewrite assoc.
do 2 apply cancel_postcomposition.
apply actorinv_nat_rightwhisker. }
etrans.
2: { repeat rewrite assoc'.
do 2 apply maponpaths.
apply pathsinv0, actegory_actornatleftright.
}
repeat rewrite assoc'.
apply maponpaths.
repeat rewrite assoc.
apply cancel_postcomposition.
etrans.
{ apply pathsinv0, (functor_comp (rightwhiskering_functor ActV x)). }
etrans.
2: { apply (functor_comp (rightwhiskering_functor ActV x)). }
apply maponpaths.
apply δ_nat.
- etrans.
{ apply maponpaths.
apply (functor_comp (leftwhiskering_functor ActV v0)). }
cbn.
etrans.
{ repeat rewrite assoc.
apply cancel_postcomposition.
repeat rewrite assoc'.
do 2 apply maponpaths.
apply actegory_actornatleftright.
}
etrans.
{ repeat rewrite assoc.
do 2 apply cancel_postcomposition.
repeat rewrite assoc'.
apply maponpaths.
apply pathsinv0, (functor_comp (rightwhiskering_functor ActV x)).
}
cbn.
etrans.
{ do 2 apply cancel_postcomposition.
do 2 apply maponpaths.
rewrite (lifteddistributivity_ldtensor δ).
repeat rewrite assoc'.
do 6 apply maponpaths.
etrans.
{ apply pathsinv0, (functor_comp (leftwhiskering_functor Mon_V v0)). }
apply (functor_id_id _ _ (leftwhiskering_functor Mon_V v0)).
apply (pr2 (fmonoidal_preservestensorstrongly U v w)).
}
rewrite id_right.
etrans.
{ do 2 apply cancel_postcomposition.
etrans.
{ apply maponpaths.
apply (functor_comp (rightwhiskering_functor ActV x)). }
cbn.
rewrite assoc.
apply cancel_postcomposition.
apply pathsinv0, actorinv_nat_rightwhisker.
}
repeat rewrite assoc'.
apply maponpaths.
(* the extra effort for having an abstract strong monoidal functor has now been accomplished *)
apply (z_iso_inv_on_right _ _ _ (z_iso_from_actor_iso Mon_V ActV _ _ _)).
etrans.
{ apply cancel_postcomposition.
repeat rewrite assoc.
apply (functor_comp (rightwhiskering_functor ActV x)). }
cbn.
etrans.
{ rewrite assoc'.
apply maponpaths.
rewrite assoc.
apply actegory_pentagonidentity.
}
repeat rewrite assoc.
apply cancel_postcomposition.
rewrite <- actegory_pentagonidentity.
etrans.
{ apply cancel_postcomposition.
repeat rewrite assoc'.
apply (functor_comp (rightwhiskering_functor ActV x)). }
cbn.
repeat rewrite assoc'.
apply maponpaths.
etrans.
2: { apply maponpaths.
etrans.
2: { apply maponpaths.
apply cancel_postcomposition.
apply pathsinv0, (functor_comp (leftwhiskering_functor ActV (F v))). }
cbn.
repeat rewrite assoc.
do 3 apply cancel_postcomposition.
etrans.
2: { apply (functor_comp (leftwhiskering_functor ActV (F v))). }
apply pathsinv0, (functor_id_id _ _ (leftwhiskering_functor ActV (F v))).
apply (pr1 (actegory_actorisolaw Mon_V ActV _ _ _)).
}
rewrite id_left.
etrans.
2: { apply maponpaths.
rewrite assoc'.
apply cancel_postcomposition.
apply pathsinv0, (functor_comp (leftwhiskering_functor ActV (F v))).
}
cbn.
etrans.
2: { repeat rewrite assoc.
do 3 apply cancel_postcomposition.
apply pathsinv0, actegory_actornatleftright. }
etrans.
{ apply cancel_postcomposition.
apply (functor_comp (rightwhiskering_functor ActV x)). }
cbn.
repeat rewrite assoc'.
apply maponpaths.
etrans.
{ apply cancel_postcomposition.
apply (functor_comp (rightwhiskering_functor ActV x)). }
cbn.
etrans.
{ rewrite assoc'.
apply maponpaths.
apply pathsinv0, actegory_actornatright. }
repeat rewrite assoc.
apply cancel_postcomposition.
(* only a variant of the pentagon law with some inverses is missing here *)
apply (z_iso_inv_on_left _ _ _ _ (z_iso_from_actor_iso Mon_V ActV _ _ _)).
cbn.
rewrite assoc'.
rewrite <- actegory_pentagonidentity.
etrans.
2: { repeat rewrite assoc.
do 2 apply cancel_postcomposition.
etrans.
2: { apply (functor_comp (rightwhiskering_functor ActV x)). }
apply pathsinv0, (functor_id_id _ _ (rightwhiskering_functor ActV x)).
apply (pr2 (monoidal_associatorisolaw Mon_V _ _ _)).
}
rewrite id_left.
apply idpath.
- etrans.
{ apply maponpaths.
apply (functor_comp (leftwhiskering_functor ActV v0)). }
cbn.
etrans.
{ repeat rewrite assoc.
apply cancel_postcomposition.
repeat rewrite assoc'.
do 2 apply maponpaths.
apply actegory_actornatleftright.
}
etrans.
{ repeat rewrite assoc.
do 2 apply cancel_postcomposition.
repeat rewrite assoc'.
apply maponpaths.
apply pathsinv0, (functor_comp (rightwhiskering_functor ActV x)).
}
cbn.
etrans.
{ do 2 apply cancel_postcomposition.
do 2 apply maponpaths.
rewrite (lifteddistributivity_ldunit δ).
repeat rewrite assoc'.
do 3 apply maponpaths.
etrans.
{ apply pathsinv0, (functor_comp (leftwhiskering_functor Mon_V v0)). }
apply (functor_id_id _ _ (leftwhiskering_functor Mon_V v0)).
apply (pr2 (fmonoidal_preservesunitstrongly U)).
}
rewrite id_right.
etrans.
{ do 2 apply cancel_postcomposition.
etrans.
{ apply maponpaths.
apply (functor_comp (rightwhiskering_functor ActV x)). }
cbn.
rewrite assoc.
apply cancel_postcomposition.
apply pathsinv0, actorinv_nat_rightwhisker.
}
repeat rewrite assoc'.
apply maponpaths.
(* the extra effort for having an abstract strong monoidal functor has now been accomplished *)
etrans.
{ repeat rewrite assoc'.
do 2 apply maponpaths.
apply actegory_triangleidentity. }
etrans.
{ apply maponpaths.
apply pathsinv0, (functor_comp (rightwhiskering_functor ActV x)). }
cbn.
rewrite assoc'.
rewrite (pr2 (monoidal_rightunitorisolaw Mon_V v0)).
rewrite id_right.
rewrite <- actegory_triangleidentity'.
rewrite assoc.
rewrite (pr2 (actegory_actorisolaw Mon_V ActV _ _ _)).
apply id_left.
Qed.
Definition liftedstrength_from_δ: liftedstrength Mon_V Mon_W U ActV ActV FF :=
lineator_data_from_δ,,lineator_laxlaws_from_δ.
End ActegoryMorphismFromLiftedDistributivity.
End FixAnObject.
Arguments liftedstrength_from_δ _ _ {_} _.
Arguments lifteddistributivity _ : clear implicits.
Arguments lifteddistributivity_data _ : clear implicits.
Definition unit_lifteddistributivity_data: lifteddistributivity_data I_{Mon_V}.
Proof.
intro w.
exact (ru^{Mon_V}_{F w} · luinv^{Mon_V}_{F w}).
Defined.
Lemma unit_lifteddistributivity_nat: lifteddistributivity_nat unit_lifteddistributivity_data.
Proof.
intro; intros. unfold unit_lifteddistributivity_data.
cbn.
etrans.
{ rewrite assoc.
apply cancel_postcomposition.
apply monoidal_rightunitornat. }
repeat rewrite assoc'.
apply maponpaths.
apply pathsinv0, monoidal_leftunitorinvnat.
Qed.
Lemma unit_lifteddistributivity_tensor: lifteddistributivity_tensor unit_lifteddistributivity_data.
Proof.
intro; intros. unfold lifteddistributivity_tensor_body, unit_lifteddistributivity_data.
etrans.
2: { do 2 apply cancel_postcomposition.
etrans.
2: { do 2 apply cancel_postcomposition.
rewrite assoc'.
do 2 apply maponpaths.
apply pathsinv0, (functor_comp (leftwhiskering_functor Mon_V _)). }
apply maponpaths.
apply pathsinv0, (functor_comp (rightwhiskering_functor Mon_V _)).
}
cbn.
etrans.
2: { repeat rewrite assoc'.
apply maponpaths.
repeat rewrite assoc.
do 6 apply cancel_postcomposition.
apply pathsinv0, left_whisker_with_runitor. }
etrans.
2: { repeat rewrite assoc.
do 4 apply cancel_postcomposition.
repeat rewrite assoc'.
do 2 apply maponpaths.
apply pathsinv0, monoidal_triangle_identity_inv. }
etrans.
2: { repeat rewrite assoc'.
do 2 apply maponpaths.
repeat rewrite assoc.
do 3 apply cancel_postcomposition.
etrans.
2: { apply (functor_comp (rightwhiskering_functor Mon_V _)). }
apply maponpaths.
apply pathsinv0, monoidal_rightunitorisolaw.
}
rewrite functor_id, id_left.
etrans.
2: { do 2 apply maponpaths.
apply cancel_postcomposition.
rewrite <- monoidal_triangle_identity'_inv.
rewrite assoc'.
apply maponpaths.
apply pathsinv0, monoidal_associatorisolaw.
}
rewrite id_right.
etrans.
2: { repeat rewrite assoc'.
do 2 apply maponpaths.
apply pathsinv0, monoidal_leftunitorinvnat. }
do 2 rewrite assoc.
apply cancel_postcomposition.
etrans.
2: { apply cancel_postcomposition.
apply pathsinv0, monoidal_rightunitornat. }
etrans.
2: { rewrite assoc'.
apply maponpaths.
apply pathsinv0, fmonoidal_preservestensorstrongly.
}
apply pathsinv0, id_right.
Qed.
Lemma unit_lifteddistributivity_unit: lifteddistributivity_unit unit_lifteddistributivity_data.
Proof.
unfold lifteddistributivity_unit, unit_lifteddistributivity_data.
etrans.
2: { do 2 apply cancel_postcomposition.
rewrite unitors_coincide_on_unit.
apply pathsinv0, monoidal_rightunitornat. }
repeat rewrite assoc'.
apply maponpaths.
etrans.
2: { apply maponpaths.
rewrite <- unitorsinv_coincide_on_unit.
apply pathsinv0, monoidal_leftunitorinvnat. }
rewrite assoc.
etrans.
2: {apply cancel_postcomposition.
apply pathsinv0, (pr22 (fmonoidal_preservesunitstrongly U)). }
apply pathsinv0, id_left.
Qed.
Definition unit_lifteddistributivity: lifteddistributivity I_{Mon_V}.
Proof.
use tpair.
- exact unit_lifteddistributivity_data.
- split3.
+ exact unit_lifteddistributivity_nat.
+ exact unit_lifteddistributivity_tensor.
+ exact unit_lifteddistributivity_unit.
Defined.
Section CompositionOfLiftedDistributivities.
Context (v1 v2 : V) (δ1 : lifteddistributivity v1) (δ2 : lifteddistributivity v2).
Definition composedlifteddistributivity_data: lifteddistributivity_data (v1 ⊗_{Mon_V} v2).
Proof.
red; intros.
exact (αinv_{Mon_V} _ _ _ · δ1 w ⊗^{Mon_V}_{r} v2 · α_{Mon_V} _ _ _
· v1 ⊗^{Mon_V}_{l} δ2 w · αinv_{Mon_V} _ _ _).
Defined.
Lemma composedlifteddistributivity_nat: lifteddistributivity_nat composedlifteddistributivity_data.
Proof.
do 2 red; intros; unfold composedlifteddistributivity_data; cbn.
assert (δ1_nat := lifteddistributivity_ldnat δ1).
assert (δ2_nat := lifteddistributivity_ldnat δ2).
do 2 red in δ1_nat, δ2_nat; cbn in δ1_nat, δ2_nat.
etrans.
{ repeat rewrite assoc.
do 4 apply cancel_postcomposition.
apply monoidal_associatorinvnatright. }
repeat rewrite assoc'.
apply maponpaths.
etrans.
{ rewrite assoc.
apply cancel_postcomposition.
apply pathsinv0, (functor_comp (rightwhiskering_functor Mon_V v2)). }
cbn.
rewrite δ1_nat.
etrans.
{ rewrite assoc.
do 2 apply cancel_postcomposition.
apply (functor_comp (rightwhiskering_functor Mon_V v2)). }
cbn.
repeat rewrite assoc'.
apply maponpaths.
etrans.
2: { do 2 apply maponpaths.
apply monoidal_associatorinvnatleft. }
repeat rewrite assoc.
apply cancel_postcomposition.
etrans.
2: { rewrite assoc'.
apply maponpaths.
apply (functor_comp (leftwhiskering_functor Mon_V v1)). }
cbn.
rewrite <- δ2_nat.
etrans.
2: { apply maponpaths.
apply pathsinv0, (functor_comp (leftwhiskering_functor Mon_V v1)). }
cbn.
repeat rewrite assoc.
apply cancel_postcomposition.
apply pathsinv0, monoidal_associatornatleftright.
Qed.
Lemma composedlifteddistributivity_tensor: lifteddistributivity_tensor composedlifteddistributivity_data.
Proof.
do 2 red; intros; unfold composedlifteddistributivity_data; cbn.
rewrite (lifteddistributivity_ldtensor δ1).
rewrite (lifteddistributivity_ldtensor δ2).
etrans.
{ do 3 apply cancel_postcomposition.
apply maponpaths.
etrans.
{ apply (functor_comp (rightwhiskering_functor Mon_V v2)). }
do 5 rewrite functor_comp.
cbn.
apply idpath.
}
etrans.
{ apply cancel_postcomposition.
repeat rewrite assoc'.
do 9 apply maponpaths.
etrans.
{ apply (functor_comp (leftwhiskering_functor Mon_V v1)). }
do 5 rewrite functor_comp.
cbn.
apply idpath.
}
etrans.
{ repeat rewrite assoc.
do 15 apply cancel_postcomposition.
apply pathsinv0, monoidal_associatorinvnatright. }
repeat rewrite assoc'.
apply maponpaths.
etrans.
{ do 14 apply maponpaths.
apply monoidal_associatorinvnatleft. }
repeat rewrite assoc.
apply cancel_postcomposition.
etrans.
2: { do 3 apply cancel_postcomposition.
apply maponpaths.
etrans.
2: { apply pathsinv0, (functor_comp (leftwhiskering_functor Mon_V (F w))). }
do 3 rewrite functor_comp.
cbn.
apply idpath.
}
etrans.
2: { apply cancel_postcomposition.
repeat rewrite assoc'.
do 7 apply maponpaths.
etrans.
2: { apply pathsinv0, (functor_comp (rightwhiskering_functor Mon_V (F w'))). }
do 3 rewrite functor_comp.
cbn.
apply idpath.
}
etrans.
{ do 6 apply cancel_postcomposition.
repeat rewrite assoc'.
do 6 apply maponpaths.
etrans.
{ apply maponpaths.
apply monoidal_associatornatleftright. }
rewrite assoc.
apply cancel_postcomposition.
etrans.
{ apply pathsinv0, (functor_comp (rightwhiskering_functor Mon_V v2)). }
apply maponpaths.
etrans.
{ apply pathsinv0, (functor_comp (leftwhiskering_functor Mon_V v1)). }
apply (functor_id_id _ _ (leftwhiskering_functor Mon_V v1)).
apply (pr2 (fmonoidal_preservestensorstrongly U w w')).
}
rewrite functor_id.
rewrite id_left.
etrans.
{ repeat rewrite assoc'. apply idpath. }
apply (z_iso_inv_on_right _ _ _ (z_iso_from_associator_iso Mon_V _ _ _)).
cbn.
etrans.
2: { repeat rewrite assoc.
do 11 apply cancel_postcomposition.
etrans.
2: { apply cancel_postcomposition.
apply monoidal_pentagonidentity. }
repeat rewrite assoc'.
do 2 apply maponpaths.
etrans.
2: { apply (functor_comp (leftwhiskering_functor Mon_V (F w))). }
apply pathsinv0, (functor_id_id _ _ (leftwhiskering_functor Mon_V (F w))).
apply (pr1 (monoidal_associatorisolaw Mon_V _ _ _)).
}
rewrite id_right.
repeat rewrite assoc'.
apply maponpaths.
etrans.
2: { repeat rewrite assoc.
do 10 apply cancel_postcomposition.
apply pathsinv0, monoidal_associatornatleftright. }
repeat rewrite assoc'.
apply maponpaths.
apply (z_iso_inv_on_right _ _ _ (functor_on_z_iso (rightwhiskering_functor Mon_V v2) (z_iso_from_associator_iso Mon_V _ _ _))).
cbn.
etrans.
2: { repeat rewrite assoc.
do 9 apply cancel_postcomposition.
apply pathsinv0, monoidal_pentagonidentity. }
etrans.
{ repeat rewrite assoc. apply idpath. }
apply pathsinv0, (z_iso_inv_on_left _ _ _ _ (z_iso_from_associator_iso Mon_V _ _ _)).
cbn.
etrans.
2: { repeat rewrite assoc'.
do 9 apply maponpaths.
etrans.
2: { apply maponpaths.
apply monoidal_pentagonidentity. }
repeat rewrite assoc.
do 2 apply cancel_postcomposition.
etrans.
2: { apply (functor_comp (rightwhiskering_functor Mon_V _)). }
apply pathsinv0, (functor_id_id _ _ (rightwhiskering_functor Mon_V (F w'))).
apply (pr2 (monoidal_associatorisolaw Mon_V _ _ _)).
}
rewrite id_left.
repeat rewrite assoc.
apply cancel_postcomposition.
etrans.
{ do 3 apply cancel_postcomposition.
repeat rewrite assoc'.
apply maponpaths.
rewrite assoc.
apply monoidal_pentagonidentity. }
etrans.
{ repeat rewrite assoc.
do 4 apply cancel_postcomposition.
apply pathsinv0, monoidal_associatornatright. }
repeat rewrite assoc'.
apply maponpaths.
etrans.
{ apply maponpaths.
repeat rewrite assoc.
do 2 apply cancel_postcomposition.
apply monoidal_associatornatleft. }
etrans.
{ repeat rewrite assoc.
do 3 apply cancel_postcomposition.
apply (bifunctor_equalwhiskers Mon_V). }
unfold functoronmorphisms2.
etrans.
2: { repeat rewrite assoc.
do 7 apply cancel_postcomposition.
apply pathsinv0, monoidal_associatornatleft. }
repeat rewrite assoc'.
apply maponpaths.
etrans.
2: { repeat rewrite assoc.
do 4 apply cancel_postcomposition.
etrans.
2: { repeat rewrite assoc'.
apply maponpaths.
rewrite assoc.
apply pathsinv0, monoidal_pentagon_identity_inv. }
rewrite assoc.
apply cancel_postcomposition.
apply pathsinv0, (pr1 (monoidal_associatorisolaw Mon_V _ _ _)).
}
rewrite id_left.
etrans.
2: { repeat rewrite assoc'.
do 3 apply maponpaths.
apply monoidal_associatornatleftright. }
repeat rewrite assoc.
apply cancel_postcomposition.
repeat rewrite assoc'.
apply pathsinv0, (z_iso_inv_on_right _ _ _ (z_iso_from_associator_iso Mon_V _ _ _)).
cbn.
etrans.
2: { repeat rewrite assoc.
do 2 apply cancel_postcomposition.
apply pathsinv0, monoidal_associatornatright. }
repeat rewrite assoc'.
apply maponpaths.
rewrite assoc.
apply (z_iso_inv_on_left _ _ _ _ (functor_on_z_iso (leftwhiskering_functor Mon_V v1) (z_iso_from_associator_iso Mon_V _ _ _))).
cbn.
apply pathsinv0, monoidal_pentagonidentity.
Qed.
Lemma composedlifteddistributivity_unit: lifteddistributivity_unit composedlifteddistributivity_data.
Proof.
red; unfold composedlifteddistributivity_data; cbn.
rewrite (lifteddistributivity_ldunit δ1).
rewrite (lifteddistributivity_ldunit δ2).
etrans.
{ do 3 apply cancel_postcomposition.
apply maponpaths.
etrans.
{ apply (functor_comp (rightwhiskering_functor Mon_V v2)). }
do 2 rewrite functor_comp.
cbn.
apply idpath.
}
etrans.
{ apply cancel_postcomposition.
repeat rewrite assoc'.
do 6 apply maponpaths.
etrans.
{ apply (functor_comp (leftwhiskering_functor Mon_V v1)). }
do 2 rewrite functor_comp.
cbn.
apply idpath.
}
etrans.
{ repeat rewrite assoc.
do 9 apply cancel_postcomposition.
apply pathsinv0, monoidal_associatorinvnatright. }
repeat rewrite assoc'.
apply maponpaths.
etrans.
{ repeat rewrite assoc.
do 8 apply cancel_postcomposition.
rewrite <- monoidal_triangleidentity'.
rewrite assoc.
apply cancel_postcomposition.
apply (pr2 (monoidal_associatorisolaw Mon_V _ _ _)).
}
rewrite id_left.
repeat rewrite assoc'.
apply maponpaths.
etrans.
{ do 6 apply maponpaths.
apply monoidal_associatorinvnatleft. }
repeat rewrite assoc.
apply cancel_postcomposition.
etrans.
{ do 4 apply cancel_postcomposition.
rewrite assoc'.
apply maponpaths.
apply pathsinv0, monoidal_associatornatleftright.
}
etrans.
{ do 3 apply cancel_postcomposition.
repeat rewrite assoc'.
do 2 apply maponpaths.
etrans.
{ apply pathsinv0, (functor_comp (leftwhiskering_functor Mon_V v1)). }
apply maponpaths.
etrans.
{ apply pathsinv0, (functor_comp (rightwhiskering_functor Mon_V v2)). }
apply (functor_id_id _ _ (rightwhiskering_functor Mon_V v2)).
apply (pr2 (fmonoidal_preservesunitstrongly U)).
}
rewrite functor_id.
rewrite id_right.
etrans.
{ repeat rewrite assoc'.
do 3 apply maponpaths.
apply monoidal_triangle_identity''_inv. }
etrans.
{ apply maponpaths.
rewrite assoc.
apply cancel_postcomposition.
apply monoidal_triangleidentity. }
rewrite assoc.
etrans.
{ apply cancel_postcomposition.
etrans.
{ apply pathsinv0, (functor_comp (rightwhiskering_functor Mon_V v2)). }
apply (functor_id_id _ _ (rightwhiskering_functor Mon_V v2)).
apply (monoidal_rightunitorisolaw Mon_V).
}
apply id_left.
Qed.
Definition composedlifteddistributivity: lifteddistributivity (v1 ⊗_{Mon_V} v2).
Proof.
exists composedlifteddistributivity_data.
exact (composedlifteddistributivity_nat,,
composedlifteddistributivity_tensor,,
composedlifteddistributivity_unit).
Defined.
End CompositionOfLiftedDistributivities.
End LiftedDistributivity.
End LiftedLineatorAndLiftedDistributivity.
Arguments lifteddistributivity {_} _ {_} _ {_} _ _.
Arguments lifteddistributivity_data {_} _ {_ _} _.
Section PointwiseOperationsOnLinearFunctors.
Context {V : category} (Mon_V : monoidal V)
{C D : category}
(ActC : actegory Mon_V C) (ActD : actegory Mon_V D).
Section PointwiseBinaryOperationsOnLinearFunctors.
Context {F1 F2 : functor C D}
(ll1 : lineator_lax Mon_V ActC ActD F1)
(ll2 : lineator_lax Mon_V ActC ActD F2).
Section PointwiseBinaryProductOfLinearFunctors.
Context (BPD : BinProducts D).
Let FF : functor C D := BinProduct_of_functors _ _ BPD F1 F2.
Let FF' : functor C D := BinProduct_of_functors_alt BPD F1 F2.
Definition lax_lineator_binprod_aux: lineator_lax Mon_V ActC ActD FF'.
Proof.
use comp_lineator_lax.
- apply actegory_binprod; assumption.
- apply actegory_binprod_delta_lineator.
- use comp_lineator_lax.
+ apply actegory_binprod; assumption.
+ apply actegory_pair_functor_lineator; assumption.
+ apply binprod_functor_lax_lineator.
Defined.
Definition lax_lineator_binprod_indirect: lineator_lax Mon_V ActC ActD FF.
Proof.
unfold FF.
rewrite <- BinProduct_of_functors_alt_eq_BinProduct_of_functors.
apply lax_lineator_binprod_aux.
Defined.
Lemma lax_lineator_binprod_indirect_data_ok (v : V) (c : C):
lax_lineator_binprod_indirect v c =
binprod_collector_data Mon_V BPD ActD v (F1 c) (F2 c) ·
BinProductOfArrows _ (BPD _ _) (BPD _ _) (ll1 v c) (ll2 v c).
Proof.
unfold lax_lineator_binprod_indirect.
Abort.
(* how could one use the equality proof? *)
(** now an alternative concrete construction *)
Definition lineator_data_binprod: lineator_data Mon_V ActC ActD FF.
Proof.
intros v c.
exact (binprod_collector_data Mon_V BPD ActD v (F1 c) (F2 c) ·
BinProductOfArrows _ (BPD _ _) (BPD _ _) (ll1 v c) (ll2 v c)).
Defined.
Let cll : lineator_lax Mon_V (actegory_binprod Mon_V ActD ActD) ActD (binproduct_functor BPD)
:= binprod_functor_lax_lineator Mon_V BPD ActD.
Lemma lineator_laxlaws_binprod: lineator_laxlaws Mon_V ActC ActD FF lineator_data_binprod.
Proof.
repeat split; red; intros; unfold lineator_data_binprod.
- etrans.
{ repeat rewrite assoc.
apply cancel_postcomposition.
apply (lineator_linnatleft _ _ _ _ cll v (_,,_) (_,,_) (_,,_)). }
repeat rewrite assoc'.
apply maponpaths.
etrans.
{ apply BinProductOfArrows_comp. }
etrans.
2: { apply pathsinv0, BinProductOfArrows_comp. }
apply maponpaths_12; apply lineator_linnatleft.
- etrans.
{ repeat rewrite assoc.
apply cancel_postcomposition.
apply (lineator_linnatright _ _ _ _ cll v1 v2 (_,,_) f). }
repeat rewrite assoc'.
apply maponpaths.
etrans.
{ apply BinProductOfArrows_comp. }
etrans.
2: { apply pathsinv0, BinProductOfArrows_comp. }
apply maponpaths_12; apply lineator_linnatright.
- etrans.
{ rewrite assoc'.
apply maponpaths.
etrans.
{ apply BinProductOfArrows_comp. }
apply maponpaths_12; apply lineator_preservesactor.
}
etrans.
{ apply maponpaths.
repeat rewrite assoc'.
apply pathsinv0, BinProductOfArrows_comp. }
etrans.
{ rewrite assoc.
apply cancel_postcomposition.
apply (lineator_preservesactor _ _ _ _ cll v w (_,,_)). }
etrans.
2: { apply cancel_postcomposition.
apply maponpaths.
apply pathsinv0, (functor_comp (leftwhiskering_functor ActD v)). }
repeat rewrite assoc'.
do 2 apply maponpaths.
repeat rewrite assoc.
etrans.
2: { apply cancel_postcomposition.
apply pathsinv0, (lineator_linnatleft _ _ _ _ cll v (_,,_) (_,,_) (_,,_)). }
rewrite assoc'.
apply maponpaths.
etrans.
2: { apply pathsinv0, BinProductOfArrows_comp. }
apply idpath.
- etrans.
2: { apply (lineator_preservesunitor _ _ _ _ cll (_,,_)). }
rewrite assoc'.
apply maponpaths.
etrans.
{ apply BinProductOfArrows_comp. }
cbn.
apply maponpaths_12; apply lineator_preservesunitor.
Qed.
Definition lax_lineator_binprod: lineator_lax Mon_V ActC ActD FF :=
lineator_data_binprod,,lineator_laxlaws_binprod.
End PointwiseBinaryProductOfLinearFunctors.
Section PointwiseBinaryCoproductOfLinearFunctors.
Context (BCD : BinCoproducts D) (δ : actegory_bincoprod_distributor Mon_V BCD ActD).
Let FF : functor C D := BinCoproduct_of_functors _ _ BCD F1 F2.
Let FF' : functor C D := BinCoproduct_of_functors_alt2 BCD F1 F2.
Definition lax_lineator_bincoprod_aux : lineator_lax Mon_V ActC ActD FF'.
Proof.
use comp_lineator_lax.
- apply actegory_binprod; assumption.
- apply actegory_binprod_delta_lineator.
- use comp_lineator_lax.
+ apply actegory_binprod; assumption.
+ apply actegory_pair_functor_lineator; assumption.
+ apply (bincoprod_functor_lineator Mon_V BCD ActD δ).
Defined.
Definition lax_lineator_bincoprod_indirect : lineator_lax Mon_V ActC ActD FF.
Proof.
unfold FF.
rewrite <- BinCoproduct_of_functors_alt_eq_BinCoproduct_of_functors.
apply lax_lineator_bincoprod_aux.
Defined.
Lemma lax_lineator_bincoprod_data_ok (v : V) (c : C) : lax_lineator_bincoprod_indirect v c =
δ v (F1 c) (F2 c) · (BinCoproductOfArrows _ (BCD _ _) (BCD _ _) (ll1 v c) (ll2 v c)).
Proof.
unfold lax_lineator_bincoprod_indirect.
Abort.
(* how could one use the equality proof? *)
(** now an alternative concrete construction *)
Definition lineator_data_bincoprod: lineator_data Mon_V ActC ActD FF.
Proof.
intros v c.
exact (δ v (F1 c) (F2 c) · (BinCoproductOfArrows _ (BCD _ _) (BCD _ _) (ll1 v c) (ll2 v c))).
Defined.
Let δll : lineator Mon_V (actegory_binprod Mon_V ActD ActD) ActD (bincoproduct_functor BCD)
:= bincoprod_functor_lineator Mon_V BCD ActD δ.
Lemma lineator_laxlaws_bincoprod
: lineator_laxlaws Mon_V ActC ActD FF lineator_data_bincoprod.
Proof.
repeat split; red; intros; unfold lineator_data_bincoprod.
- etrans.
{ repeat rewrite assoc.
apply cancel_postcomposition.
apply (lineator_linnatleft _ _ _ _ δll v (_,,_) (_,,_) (_,,_)). }
repeat rewrite assoc'.
apply maponpaths.
etrans.
{ apply BinCoproductOfArrows_comp. }
etrans.
2: { apply pathsinv0, BinCoproductOfArrows_comp. }
apply maponpaths_12; apply lineator_linnatleft.
- etrans.
{ repeat rewrite assoc.
apply cancel_postcomposition.
apply (lineator_linnatright _ _ _ _ δll v1 v2 (_,,_) f). }
repeat rewrite assoc'.
apply maponpaths.
etrans.
{ apply BinCoproductOfArrows_comp. }
etrans.
2: { apply pathsinv0, BinCoproductOfArrows_comp. }
apply maponpaths_12; apply lineator_linnatright.
- etrans.
{ rewrite assoc'.
apply maponpaths.
etrans.
{ apply BinCoproductOfArrows_comp. }
apply maponpaths_12; apply lineator_preservesactor.
}
etrans.
{ apply maponpaths.
repeat rewrite assoc'.
apply pathsinv0, BinCoproductOfArrows_comp. }
etrans.
{ rewrite assoc.
apply cancel_postcomposition.
apply (lineator_preservesactor _ _ _ _ δll v w (_,,_)). }
etrans.
2: { apply cancel_postcomposition.
apply maponpaths.
apply pathsinv0, (functor_comp (leftwhiskering_functor ActD v)). }
repeat rewrite assoc'.
do 2 apply maponpaths.
repeat rewrite assoc.
etrans.
2: { apply cancel_postcomposition.
apply pathsinv0, (lineator_linnatleft _ _ _ _ δll v (_,,_) (_,,_) (_,,_)). }
rewrite assoc'.
apply maponpaths.
etrans.
2: { apply pathsinv0, BinCoproductOfArrows_comp. }
apply idpath.
- etrans.
2: { apply (lineator_preservesunitor _ _ _ _ δll (_,,_)). }
rewrite assoc'.
apply maponpaths.
etrans.
{ apply BinCoproductOfArrows_comp. }
cbn.
apply maponpaths_12; apply lineator_preservesunitor.
Qed.
Definition lax_lineator_bincoprod: lineator_lax Mon_V ActC ActD FF :=
lineator_data_bincoprod,,lineator_laxlaws_bincoprod.
End PointwiseBinaryCoproductOfLinearFunctors.
End PointwiseBinaryOperationsOnLinearFunctors.
Section PointwiseCoproductOfLinearFunctors.
Context {I : UU} {F : I -> functor C D}
(ll : ∏ (i: I), lineator_lax Mon_V ActC ActD (F i))
(CD : Coproducts I D) (δ : actegory_coprod_distributor Mon_V CD ActD).
Let FF : functor C D := coproduct_of_functors _ _ _ CD F.
Let FF' : functor C D := coproduct_of_functors_alt_old _ CD F.
Definition lax_lineator_coprod_aux : lineator_lax Mon_V ActC ActD FF'.
Proof.
use comp_lineator_lax.
- apply actegory_power; assumption.
- apply actegory_prod_delta_lineator.
- use comp_lineator_lax.
+ apply actegory_power; assumption.
+ apply actegory_family_functor_lineator; assumption.
+ apply (coprod_functor_lineator Mon_V CD ActD δ).
Defined.
Definition lax_lineator_coprod_indirect : lineator_lax Mon_V ActC ActD FF.
Proof.
unfold FF.
rewrite <- coproduct_of_functors_alt_old_eq_coproduct_of_functors.
apply lax_lineator_coprod_aux.
Defined.
Lemma lax_lineator_coprod_data_ok (v : V) (c : C) : lax_lineator_coprod_indirect v c =
δ v (fun i => F i c) · (CoproductOfArrows I _ (CD _) (CD _) (fun i => ll i v c)).
Proof.
unfold lax_lineator_coprod_indirect.
Abort.
(* how could one use the equality proof? *)
(** now an alternative concrete construction *)
Definition lineator_data_coprod: lineator_data Mon_V ActC ActD FF.
Proof.
intros v c.
exact (δ v (fun i => F i c) · (CoproductOfArrows I _ (CD _) (CD _) (fun i => ll i v c))).
Defined.
Let δll : lineator Mon_V (actegory_power Mon_V I ActD) ActD (coproduct_functor I CD)
:= coprod_functor_lineator Mon_V CD ActD δ.
Lemma lineator_laxlaws_coprod
: lineator_laxlaws Mon_V ActC ActD FF lineator_data_coprod.
Proof.
repeat split; red; intros; unfold lineator_data_coprod.
- etrans.
{ repeat rewrite assoc.
apply cancel_postcomposition.
apply (lineator_linnatleft _ _ _ _ δll v). }
repeat rewrite assoc'.
apply maponpaths.
etrans.
{ apply CoproductOfArrows_comp. }
etrans.
2: { apply pathsinv0, CoproductOfArrows_comp. }
apply maponpaths, funextsec; intro i; apply lineator_linnatleft.
- etrans.
{ repeat rewrite assoc.
apply cancel_postcomposition.
apply (lineator_linnatright _ _ _ _ δll v1 v2 _ f). }
repeat rewrite assoc'.
apply maponpaths.
etrans.
{ apply CoproductOfArrows_comp. }
etrans.
2: { apply pathsinv0, CoproductOfArrows_comp. }
apply maponpaths, funextsec; intro i; apply lineator_linnatright.
- etrans.
{ rewrite assoc'.
apply maponpaths.
etrans.
{ apply CoproductOfArrows_comp. }
cbn.
apply maponpaths, funextsec; intro i; apply lineator_preservesactor.
}
etrans.
{ apply maponpaths.
assert (aux : (fun i => aα^{ ActD }_{ v, w, F i x} · v ⊗^{ ActD}_{l} ll i w x · ll i v (w ⊗_{ ActC} x))
= (fun i => aα^{ ActD }_{ v, w, F i x} · (v ⊗^{ ActD}_{l} ll i w x · ll i v (w ⊗_{ ActC} x)))).
{ apply funextsec; intro i; apply assoc'. }
rewrite aux.
apply pathsinv0, CoproductOfArrows_comp. }
etrans.
{ rewrite assoc.
apply cancel_postcomposition.
apply (lineator_preservesactor _ _ _ _ δll v w).
}
etrans.
2: { apply cancel_postcomposition.
apply maponpaths.
apply pathsinv0, (functor_comp (leftwhiskering_functor ActD v)). }
repeat rewrite assoc'.
do 2 apply maponpaths.
repeat rewrite assoc.
etrans.
2: { apply cancel_postcomposition.
apply pathsinv0, (lineator_linnatleft _ _ _ _ δll v). }
rewrite assoc'.
apply maponpaths.
etrans.
2: { apply pathsinv0, CoproductOfArrows_comp. }
apply idpath.
- etrans.
2: { apply (lineator_preservesunitor _ _ _ _ δll). }
rewrite assoc'.
apply maponpaths.
etrans.
{ apply CoproductOfArrows_comp. }
cbn.
apply maponpaths, funextsec; intro i; apply lineator_preservesunitor.
Qed.
Definition lax_lineator_coprod: lineator_lax Mon_V ActC ActD FF :=
lineator_data_coprod,,lineator_laxlaws_coprod.
End PointwiseCoproductOfLinearFunctors.
End PointwiseOperationsOnLinearFunctors.
|
[STATEMENT]
lemma nonzero_ac_imp_nonzero:
assumes "x \<in> carrier Q\<^sub>p"
assumes "ac m x \<noteq> 0"
shows "x \<in> nonzero Q\<^sub>p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. x \<in> nonzero Q\<^sub>p
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier Q\<^sub>p
ac m x \<noteq> 0
goal (1 subgoal):
1. x \<in> nonzero Q\<^sub>p
[PROOF STEP]
unfolding ac_def nonzero_def mem_Collect_eq
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier Q\<^sub>p
(if x = \<zero> then 0 else angular_component x m) \<noteq> 0
goal (1 subgoal):
1. x \<in> carrier Q\<^sub>p \<and> x \<noteq> \<zero>
[PROOF STEP]
by presburger |
[STATEMENT]
lemma fv_formula_of_constraint: "fv (formula_of_constraint (t1, p, c, t2)) = fv_trm t1 \<union> fv_trm t2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. fv (formula_of_constraint (t1, p, c, t2)) = fv_trm t1 \<union> fv_trm t2
[PROOF STEP]
by (induction "(t1, p, c, t2)" rule: formula_of_constraint.induct) simp_all |
/*
Copyright (c) 2015, Patrick Weltevrede
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define _FILE_OFFSET_BITS 64
#define _USE_LARGEFILE 1
#define _LARGEFILE_SOURCE 1
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <gsl/gsl_sort.h>
#include "psrsalsa.h"
#define MaxNrOnpulseRegions 10
int NrOnpulseRegions, OnPulseRegion[MaxNrOnpulseRegions][2];
void PlotProfile(int NrBins, float *Ipulse, char *xlabel, char *ylabel, char *title, int Highlight, int color, int clearPage);
void ShiftProfile(int shift, int NrBins, float *Iprofile, float *outputProfile);
int main(int argc, char **argv)
{
char output_fname[1000], PlotDevice[100], singlechar, *inputname;
int circularShift, noinput, onlyI, memsave, currentfilenumber, dummy_int;
int shift, bin1, bin2, subintWritten, poladd, freqadd;
long i, j, pol, fchan, nsub, binnr, nrinputfiles, subintslost, currentOutputSubint, sumNsub, curNrInsubint;
float *Iprofile, *Iprofile_firstfile, *shiftedProfile, *subint, x, y, *float_ptr, *float_ptr2;
datafile_definition **fin;
datafile_definition fout, clone;
psrsalsaApplication application;
initApplication(&application, "padd", "[options] inputfiles");
application.switch_blocksize = 1;
application.switch_verbose = 1;
application.switch_debug = 1;
application.switch_filelist = 1;
application.switch_iformat = 1;
application.switch_oformat = 1;
application.switch_formatlist = 1;
application.switch_fscr = 1;
application.switch_FSCR = 1;
application.switch_nocounters = 1;
application.switch_changeRefFreq = 1;
application.oformat = FITS_format;
strcpy(PlotDevice, "?");
onlyI = 0;
strcpy(output_fname, "addedfile.gg");
NrOnpulseRegions = 0;
circularShift = 0;
noinput = 0;
shift = 0;
memsave = 0;
sumNsub = 1;
poladd = 0;
freqadd = 0;
x = y = singlechar = 0;
if(argc < 2) {
printf("Program to add data files together. Usage:\n\n");
printApplicationHelp(&application);
printf("Optional options:\n");
printf("-w Output name. Default is \"%s\"\n", output_fname);
printf("-I Only process the first polarization channel\n");
printf("-c Turn on circular shifting (so that no subint is lost).\n");
printf(" The first and last subintegrations are spilling over\n");
printf(" into each other.\n");
printf("-n No graphical input, circular shifting by this number of\n");
printf(" bins, so this option implies -c. So -n 0 results in a\n");
printf(" simple concatenation of the input files.\n");
printf("-nsub This number of subintegrations are summed before being\n");
printf(" written out\n");
printf("-poladd The input files are to be interpretted as separate\n");
printf(" polarization channels (option implies -n 0).\n");
printf("-freqadd The input files are to be interpretted as separate\n");
printf(" frequency bands (option implies -n 0).\n");
printf("-memsave Only one full input data-set exists in memory at a time,\n");
printf(" but every input file will be opened twice.\n");
printf("\n");
printCitationInfo();
terminateApplication(&application);
return 0;
}else {
for(i = 1; i < argc; i++) {
dummy_int = i;
if(processCommandLine(&application, argc, argv, &dummy_int)) {
i = dummy_int;
}else if(strcmp(argv[i], "-w") == 0 || strcmp(argv[i], "-W") == 0) {
strcpy(output_fname,argv[i+1]);
i++;
}else if(strcmp(argv[i], "-memsave") == 0) {
memsave = 1;
}else if(strcmp(argv[i], "-c") == 0 || strcmp(argv[i], "-C") == 0) {
circularShift = 1;
}else if(strcmp(argv[i], "-I") == 0) {
onlyI = 1;
}else if(strcmp(argv[i], "-poladd") == 0) {
poladd = 1;
circularShift = 1;
noinput = 1;
shift = 0;
}else if(strcmp(argv[i], "-freqadd") == 0) {
freqadd = 1;
circularShift = 1;
noinput = 1;
shift = 0;
}else if(strcmp(argv[i], "-n") == 0) {
circularShift = 1;
noinput = 1;
if(parse_command_string(application.verbose_state, argc, argv, i+1, 0, -1, "%d", &shift, NULL) == 0) {
printerror(application.verbose_state.debug, "ERROR padd: Cannot parse '%s' option.", argv[i]);
return 0;
}
i++;
}else if(strcmp(argv[i], "-nsub") == 0) {
if(parse_command_string(application.verbose_state, argc, argv, i+1, 0, -1, "%ld", &sumNsub, NULL) == 0) {
printerror(application.verbose_state.debug, "ERROR padd: Cannot parse '%s' option.", argv[i]);
return 0;
}
if(sumNsub < 1) {
fflush(stdout);
printerror(application.verbose_state.debug, "ERROR padd: Cannot parse option %s, expected one integer number > 1", argv[i]);
return 0;
}
i++;
}else {
if(argv[i][0] == '-') {
printerror(application.verbose_state.debug, "ERROR padd: Unknown option %s. Run padd without command-line options to get help.", argv[i]);
terminateApplication(&application);
return 0;
}else {
if(applicationAddFilename(i, application.verbose_state) == 0)
return 0;
}
}
}
}
if(applicationFilenameList_checkConsecutive(argv, application.verbose_state) == 0) {
return 0;
}
nrinputfiles = numberInApplicationFilenameList(&application, argv, application.verbose_state);
if(nrinputfiles < 2) {
printerror(application.verbose_state.debug, "ERROR padd: Need at least two input files");
return 0;
}
if(freqadd && poladd) {
printerror(application.verbose_state.debug, "ERROR padd: Cannot use the -freqadd and -poladd flag simultaneously.");
return 0;
}
if(sumNsub != 1 && poladd) {
printerror(application.verbose_state.debug, "ERROR padd: Cannot use the -nsub and -poladd flag simultaneously.");
return 0;
}
if(sumNsub != 1 && freqadd) {
printerror(application.verbose_state.debug, "ERROR padd: Cannot use the -nsub and -freqadd flag simultaneously.");
return 0;
}
if(circularShift != 1 && poladd) {
printerror(application.verbose_state.debug, "ERROR padd: You must use the -c option together with -poladd.");
return 0;
}
if(circularShift != 1 && freqadd) {
printerror(application.verbose_state.debug, "ERROR padd: You must use the -c option together with -freqadd.");
return 0;
}
if((noinput != 1 || shift != 0) && poladd) {
printerror(application.verbose_state.debug, "ERROR padd: You must use the -n 0 option together with -poladd.");
return 0;
}
if((noinput != 1 || shift != 0) && freqadd) {
printerror(application.verbose_state.debug, "ERROR padd: You must use the -n 0 option together with -poladd.");
return 0;
}
fin = malloc(nrinputfiles*sizeof(datafile_definition *));
if(fin == NULL) {
printerror(application.verbose_state.debug, "ERROR padd: Memory allocation error");
return 0;
}
for(i = 0; i < nrinputfiles; i++) {
fin[i] = malloc(sizeof(datafile_definition));
if(fin[i] == NULL) {
printerror(application.verbose_state.debug, "ERROR padd: Memory allocation error");
return 0;
}
}
currentfilenumber = 0;
while((inputname = getNextFilenameFromList(&application, argv, application.verbose_state)) != NULL) {
verbose_definition verbose2;
copyVerboseState(application.verbose_state, &verbose2);
verbose2.indent = application.verbose_state.indent + 2;
if(memsave == 0 || (currentfilenumber == 0 && noinput == 0)) {
if(currentfilenumber == 0) {
printf("Read in input files:\n");
}
if(openPSRData(fin[currentfilenumber], inputname, application.iformat, 0, 1, 0, verbose2) == 0) {
printerror(application.verbose_state.debug, "ERROR padd: Cannot open %s\n", inputname);
return 0;
}
if(currentfilenumber == 0) {
for(i = 1; i < argc; i++) {
if(strcmp(argv[i], "-header") == 0) {
fflush(stdout);
printwarning(application.verbose_state.debug, "WARNING: If using the -header option, be aware it applied BEFORE the preprocessing.");
}
}
}
if(preprocessApplication(&application, fin[currentfilenumber]) == 0) {
printerror(application.verbose_state.debug, "ERROR padd: preprocess option failed on file %s\n", inputname);
return 0;
}
}else {
if(currentfilenumber == 0)
printf("Read in headers of input files:\n");
if(openPSRData(fin[currentfilenumber], inputname, application.iformat, 0, 0, 0, verbose2) == 0) {
printerror(application.verbose_state.debug, "ERROR padd: Cannot open %s\n", inputname);
return 0;
}
if(readHeaderPSRData(fin[currentfilenumber], 1, 0, verbose2) == 0) {
printerror(application.verbose_state.debug, "ERROR padd: Cannot read header of file %s\n", inputname);
return 0;
}
}
if(currentfilenumber == 0 && noinput == 0) {
Iprofile_firstfile = (float *)malloc(fin[0]->NrPols*fin[0]->NrBins*sizeof(float));
shiftedProfile = (float *)malloc(fin[0]->NrPols*fin[0]->NrBins*sizeof(float));
if(Iprofile_firstfile == NULL || shiftedProfile == NULL) {
printerror(application.verbose_state.debug, "ERROR padd: Cannot allocate memory.");
return 0;
}
if(read_profilePSRData(*fin[0], Iprofile_firstfile, NULL, 0, application.verbose_state) != 1) {
printerror(application.verbose_state.debug, "ERROR padd: Reading pulse profile of first input file failed.");
return 0;
}
}
if(memsave) {
if(closePSRData(fin[currentfilenumber], 1, application.verbose_state) != 0) {
printerror(application.verbose_state.debug, "ERROR padd: Closing file %s failed\n", inputname);
return 0;
}
}
if(fin[currentfilenumber]->NrBins != fin[0]->NrBins) {
printerror(application.verbose_state.debug, "ERROR padd: Number of pulse longitude bins not equal in input files.");
return 0;
}
if(fin[0]->NrPols != fin[currentfilenumber]->NrPols && onlyI == 0) {
printerror(application.verbose_state.debug, "ERROR padd: Number of polarization channels are different. Maybe you want to use the -I option?");
return 0;
}
if(freqadd == 0) {
if(fin[currentfilenumber]->NrFreqChan != fin[0]->NrFreqChan) {
printerror(application.verbose_state.debug, "ERROR padd: Number of frequency channels not equal in input files.");
return 0;
}
}
if(poladd || freqadd) {
if(fin[0]->NrSubints != fin[currentfilenumber]->NrSubints) {
printerror(application.verbose_state.debug, "ERROR padd: Number of subints are different. This is not allowed with the -poladd or -freqadd options.");
return 0;
}
}
if(poladd) {
if(fin[currentfilenumber]->NrPols != 1) {
printerror(application.verbose_state.debug, "ERROR padd: Number of polarization channels in input files should be 1 if using the -poladd option.");
return 0;
}
}
if(fin[currentfilenumber]->isDeDisp != fin[0]->isDeDisp) {
printerror(application.verbose_state.debug, "ERROR padd: Dedispersion state is not equal in input files.");
return 0;
}
if(fin[currentfilenumber]->isDeFarad != fin[0]->isDeFarad) {
printerror(application.verbose_state.debug, "ERROR padd: De-Faraday rotation state is not equal in input files.");
return 0;
}
if(fin[currentfilenumber]->isDePar != fin[0]->isDePar) {
printerror(application.verbose_state.debug, "ERROR padd: Parallactic angle state is not equal in input files.");
return 0;
}
currentfilenumber++;
}
printf("Reading of input files done\n");
unsigned long *sort_indx;
sort_indx = (unsigned long *)malloc(nrinputfiles*sizeof(unsigned long));
if(sort_indx == NULL) {
printerror(application.verbose_state.debug, "ERROR padd: Memory allocation error\n");
return 0;
}
for(currentfilenumber = 0; currentfilenumber < nrinputfiles; currentfilenumber++) {
sort_indx[currentfilenumber] = currentfilenumber;
}
cleanPSRData(&fout, application.verbose_state);
copy_params_PSRData(*(fin[0]), &fout, application.verbose_state);
if(onlyI) {
fout.NrPols = 1;
}
fout.format = application.oformat;
fout.NrSubints = 0;
subintslost = 0;
if(poladd) {
fout.NrPols = nrinputfiles;
fout.NrSubints = fin[0]->NrSubints;
}else if(freqadd) {
fout.NrSubints = fin[0]->NrSubints;
fout.NrFreqChan = 0;
for(currentfilenumber = 0; currentfilenumber < nrinputfiles; currentfilenumber++) {
fout.NrFreqChan += fin[currentfilenumber]->NrFreqChan;
}
fout.freqMode = FREQMODE_FREQTABLE;
if(fout.freqlabel_list != NULL) {
free(fout.freqlabel_list);
}
fout.freqlabel_list = (double *)malloc(fout.NrFreqChan*fout.NrSubints*sizeof(double));
if(fout.freqlabel_list == NULL) {
printerror(application.verbose_state.debug, "ERROR padd: Memory allocation error");
return 0;
}
long currentOutputChan = 0;
for(i = 0; i < nrinputfiles; i++) {
currentfilenumber = sort_indx[i];
for(fchan = 0; fchan < fin[currentfilenumber]->NrFreqChan; fchan++) {
for(nsub = 0; nsub < fin[currentfilenumber]->NrSubints; nsub++) {
double freq;
freq = get_weighted_channel_freq(*(fin[currentfilenumber]), nsub, fchan, application.verbose_state);
if(set_weighted_channel_freq(&fout, nsub, currentOutputChan, freq, application.verbose_state) == 0) {
printerror(application.verbose_state.debug, "ERROR padd: Constructing frequency table failed");
return 0;
}
}
currentOutputChan++;
}
}
}else {
for(i = 0; i < nrinputfiles; i++) {
fout.NrSubints += fin[i]->NrSubints;
if(circularShift == 0) {
fout.NrSubints -= 1;
subintslost += 1;
}
}
}
if(freqadd || poladd) {
printf("\nOutput data will be %ld subints, %ld phase bins %ld frequency channels and %ld polarizations.\n", fout.NrSubints, fout.NrBins, fout.NrFreqChan, fout.NrPols);
}else {
printf("\nInput data contains %ld subints, %ld phase bins %ld frequency channels and %ld polarizations.\n", fout.NrSubints+subintslost, fout.NrBins, fout.NrFreqChan, fout.NrPols);
printf("%ld subints are lost because of the alignment of input data", subintslost);
if(subintslost > 0)
printf(" (consider using -c option)");
}
fout.tsubMode = TSUBMODE_TSUBLIST;
if(fout.tsub_list != NULL) {
free(fout.tsub_list);
}
fout.tsub_list = (double *)malloc(fout.NrSubints*sizeof(double));
if(fout.tsub_list == NULL) {
printerror(application.verbose_state.debug, "ERROR padd: Memory allocation error");
return 0;
}
currentOutputSubint = 0;
fout.tsub_list[0] = 0;
subintWritten = 0;
curNrInsubint = 0;
if(poladd || freqadd) {
for(nsub = 0; nsub < fin[0]->NrSubints; nsub++) {
fout.tsub_list[nsub] = get_tsub(*(fin[0]), nsub, application.verbose_state);
}
}else {
for(i = 0; i < nrinputfiles; i++) {
currentfilenumber = sort_indx[i];
for(nsub = 0; nsub < fin[currentfilenumber]->NrSubints; nsub++) {
if(currentOutputSubint < fout.NrSubints)
fout.tsub_list[currentOutputSubint] += get_tsub(*(fin[currentfilenumber]), nsub, application.verbose_state);
if(sumNsub == 1) {
subintWritten = 1;
}else if(curNrInsubint == sumNsub - 1) {
subintWritten = 1;
}
curNrInsubint++;
if(subintWritten) {
subintWritten = 0;
curNrInsubint = 0;
currentOutputSubint++;
if(currentOutputSubint < fout.NrSubints)
fout.tsub_list[currentOutputSubint] = 0;
}
}
}
}
if(freqadd == 0 && poladd == 0) {
dummy_int = fout.NrSubints % sumNsub;
fout.NrSubints = fout.NrSubints/sumNsub;
printf("\nOutput data will contain %ld subints", fout.NrSubints);
if(sumNsub > 1)
printf(" after summing every %ld input subints", sumNsub);
if(dummy_int)
printf(" (%d input subints lost because of incomplete last subint)", dummy_int);
printf("\n\n");
}
if(fout.gentype == GENTYPE_PULSESTACK && sumNsub != 1) {
if(fout.NrSubints != 1) {
fout.gentype = GENTYPE_SUBINTEGRATIONS;
}else {
fout.gentype = GENTYPE_PROFILE;
}
}
if(openPSRData(&fout, output_fname, fout.format, 1, 0, 0, application.verbose_state) == 0) {
printerror(application.verbose_state.debug, "ERROR padd: Cannot open %s", output_fname);
return 0;
}
if(writeHeaderPSRData(&fout, argc, argv, application.history_cmd_only, application.verbose_state) != 1) {
printerror(application.verbose_state.debug, "ERROR padd: Cannot write header to %s", output_fname);
return 0;
}
Iprofile = (float *)malloc(fout.NrPols*fout.NrBins*sizeof(float));
if(Iprofile == NULL) {
printerror(application.verbose_state.debug, "ERROR padd: Cannot allocate memory.");
return 0;
}
if(sumNsub > 1) {
subint = (float *)malloc(fout.NrPols*fout.NrBins*fout.NrFreqChan*sizeof(float));
if(subint == NULL) {
printerror(application.verbose_state.debug, "ERROR padd: Cannot allocate memory.");
return 0;
}
}
if(noinput == 0) {
ppgopen(PlotDevice);
ppgask(0);
ppgslw(1);
}
currentfilenumber = 0;
currentOutputSubint = 0;
curNrInsubint = 0;
subintWritten = 0;
rewindFilenameList(&application);
long currentfilenumber_index;
long fchan_offset = 0;
while((inputname = getNextFilenameFromList(&application, argv, application.verbose_state)) != NULL) {
currentfilenumber_index = sort_indx[currentfilenumber];
if(memsave) {
closePSRData(fin[currentfilenumber_index], 0, application.verbose_state);
if(openPSRData(fin[currentfilenumber_index], inputname, application.iformat, 0, 1, 0, application.verbose_state) == 0) {
printerror(application.verbose_state.debug, "ERROR padd: Cannot open %s\n", inputname);
return 0;
}
if(currentfilenumber == 0) {
for(i = 1; i < argc; i++) {
if(strcmp(argv[i], "-header") == 0) {
fflush(stdout);
printwarning(application.verbose_state.debug, "WARNING: If using the -header option, be aware it applied BEFORE the preprocessing.");
}
}
}
if(preprocessApplication(&application, fin[currentfilenumber_index]) == 0) {
printerror(application.verbose_state.debug, "ERROR padd: preprocess option failed on file %s\n", inputname);
return 0;
}
}
if(shift >= fout.NrBins)
shift -= fout.NrBins;
if(shift < 0)
shift += fout.NrBins;
if(noinput == 0 && currentfilenumber != 0) {
if(read_profilePSRData(*fin[currentfilenumber_index], Iprofile, NULL, 0, application.verbose_state) != 1) {
printerror(application.verbose_state.debug, "ERROR padd: Reading pulse profile failed.");
return 0;
}
do {
ShiftProfile(shift, fout.NrBins, Iprofile, shiftedProfile);
PlotProfile(fout.NrBins, Iprofile_firstfile, "Bin number", "Intensity", "Click to shift profile, press s to stop", 0, 1, 1);
PlotProfile(fout.NrBins, shiftedProfile, "", "", "", 0, 2, 0);
j = 0;
do {
if(j == 0)
ppgband(0, 0, 0.0, 0.0, &x, &y, &singlechar);
else
ppgband(4, 0, bin1, 0.0, &x, &y, &singlechar);
if(singlechar == 65) {
if(j == 0)
bin1 = x;
else
bin2 = x;
j++;
}else if(singlechar == 115 || singlechar ==83 ) {
j = 10;
}
}while(j < 2);
if(j < 10) {
shift += bin2 - bin1;
if(shift >= fout.NrBins)
shift -= fout.NrBins;
if(shift < 0)
shift += fout.NrBins;
}
}while(j < 10);
}
if(shift != 0) {
if(continuous_shift(*fin[currentfilenumber_index], &clone, shift, circularShift, "padd", MEMORY_format, 0, NULL, application.verbose_state, application.verbose_state.debug) != 1) {
printerror(application.verbose_state.debug, "ERROR padd: circular shift failed.");
}
swap_orig_clone(fin[currentfilenumber_index], &clone, application.verbose_state);
}
long nrPulsesInCurFile;
nrPulsesInCurFile = fin[currentfilenumber_index]->NrSubints;
if(shift == 0 && circularShift == 0)
nrPulsesInCurFile -= 1;
for(nsub = 0; nsub < nrPulsesInCurFile; nsub++) {
int nrpolsinloop;
nrpolsinloop = fout.NrPols;
if(poladd) {
nrpolsinloop = 1;
}
for(pol = 0; pol < nrpolsinloop; pol++) {
for(fchan = 0; fchan < fin[currentfilenumber_index]->NrFreqChan; fchan++) {
if(readPulsePSRData(fin[currentfilenumber_index], nsub, pol, fchan, 0, fin[currentfilenumber_index]->NrBins, Iprofile, application.verbose_state) != 1) {
printerror(application.verbose_state.debug, "ERROR padd: Read error");
return 0;
}
if(sumNsub == 1) {
if(poladd == 0 && freqadd == 0) {
if(writePulsePSRData(&fout, currentOutputSubint, pol, fchan, 0, fout.NrBins, Iprofile, application.verbose_state) != 1) {
printerror(application.verbose_state.debug, "ERROR padd: Write error");
return 0;
}
}else {
if(poladd) {
if(writePulsePSRData(&fout, nsub, currentfilenumber, fchan, 0, fout.NrBins, Iprofile, application.verbose_state) != 1) {
printerror(application.verbose_state.debug, "ERROR padd: Write error");
return 0;
}
}else if(freqadd) {
if(writePulsePSRData(&fout, nsub, pol, fchan+fchan_offset, 0, fout.NrBins, Iprofile, application.verbose_state) != 1) {
printerror(application.verbose_state.debug, "ERROR padd: Write error");
return 0;
}
}
}
subintWritten = 1;
}else {
float_ptr = &subint[fout.NrBins*(pol+fout.NrPols*fchan)];
float_ptr2 = Iprofile;
if(curNrInsubint == 0) {
for(binnr = 0; binnr < fout.NrBins; binnr++) {
*float_ptr = *float_ptr2;
float_ptr++;
float_ptr2++;
}
}else {
for(binnr = 0; binnr < fout.NrBins; binnr++) {
*float_ptr += *float_ptr2;
float_ptr++;
float_ptr2++;
}
}
if(curNrInsubint == sumNsub - 1) {
if(writePulsePSRData(&fout, currentOutputSubint, pol, fchan, 0, fout.NrBins, float_ptr-fout.NrBins, application.verbose_state) != 1) {
printerror(application.verbose_state.debug, "ERROR padd: Write error");
return 0;
}
subintWritten = 1;
}
}
}
}
curNrInsubint++;
if(subintWritten) {
subintWritten = 0;
curNrInsubint = 0;
currentOutputSubint++;
}
if(application.verbose_state.nocounters == 0) {
printf("Processing input file %d: %.1f%% \r", currentfilenumber+1, (100.0*(nsub+1))/(float)(fin[currentfilenumber_index]->NrSubints));
fflush(stdout);
}
}
if(freqadd) {
fchan_offset += fin[currentfilenumber_index]->NrFreqChan;
}
if(application.verbose_state.nocounters == 0) {
printf("Processing file %d is done (%s). \n", currentfilenumber+1, fin[currentfilenumber_index]->filename);
}
closePSRData(fin[currentfilenumber_index], 0, application.verbose_state);
currentfilenumber++;
}
closePSRData(&fout, 0, application.verbose_state);
if(noinput == 0)
ppgend();
free(Iprofile);
if(noinput == 0) {
free(shiftedProfile);
free(Iprofile_firstfile);
}
if(sumNsub > 1)
free(subint);
for(i = 0; i < nrinputfiles; i++) {
free(fin[i]);
}
free(fin);
free(sort_indx);
terminateApplication(&application);
return 0;
}
int CheckOnPulse(int bin, int NrRegions, int Regions[MaxNrOnpulseRegions][2])
{
int i;
for(i = 0; i < NrRegions; i++) {
if(bin >= Regions[i][0] && bin <= Regions[i][1])
return i+1;
}
return 0;
}
void PlotProfile(int NrBins, float *Ipulse, char *xlabel, char *ylabel, char *title, int Highlight, int color, int clearPage)
{
long j;
float ymin, ymax;
ymin = ymax = Ipulse[0];
for(j = 1; j < NrBins; j++) {
if(Ipulse[j] > ymax)
ymax = Ipulse[j];
if(Ipulse[j] < ymin)
ymin = Ipulse[j];
}
if(clearPage) {
ppgpage();
ppgsci(1);
ppgsvp(0.1, 0.9, 0.1, 0.9);
ppgswin(0,NrBins-1,-0.1,1.1);
ppgbox("bcnsti",0.0,0,"bcnti",0.0,0);
ppglab(xlabel, ylabel, title);
}
ppgsci(color);
ppgmove(0, Ipulse[0]/ymax);
for(j = 1; j < NrBins; j++) {
if(Highlight != 0)
ppgsci(color+CheckOnPulse(j,NrOnpulseRegions,OnPulseRegion));
else
ppgsci(color);
ppgdraw(j, Ipulse[j]/ymax);
}
ppgsci(1);
}
void ShiftProfile(int shift, int NrBins, float *Iprofile, float *outputProfile)
{
int b, b2;
for(b = 0; b < NrBins; b++) {
b2 = b+shift;
if(b2 < 0)
b2 += NrBins;
if(b2 >= NrBins)
b2 -= NrBins;
outputProfile[b2] = Iprofile[b];
}
}
|
/-
Copyright (c) 2021 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import algebra.algebra.basic
import topology.locally_constant.basic
/-!
# Algebraic structure on locally constant functions
This file puts algebraic structure (`add_group`, etc)
on the type of locally constant functions.
-/
namespace locally_constant
variables {X Y : Type*} [topological_space X]
@[to_additive] instance [has_one Y] : has_one (locally_constant X Y) :=
{ one := const X 1 }
@[simp, to_additive] lemma coe_one [has_one Y] : ⇑(1 : locally_constant X Y) = (1 : X → Y) := rfl
@[to_additive] lemma one_apply [has_one Y] (x : X) : (1 : locally_constant X Y) x = 1 := rfl
@[to_additive] instance [has_inv Y] : has_inv (locally_constant X Y) :=
{ inv := λ f, ⟨f⁻¹ , f.is_locally_constant.inv⟩ }
@[simp, to_additive] lemma coe_inv [has_inv Y] (f : locally_constant X Y) : ⇑(f⁻¹) = f⁻¹ := rfl
@[to_additive] lemma inv_apply [has_inv Y] (f : locally_constant X Y) (x : X) :
f⁻¹ x = (f x)⁻¹ := rfl
@[to_additive] instance [has_mul Y] : has_mul (locally_constant X Y) :=
{ mul := λ f g, ⟨f * g, f.is_locally_constant.mul g.is_locally_constant⟩ }
@[simp, to_additive] lemma coe_mul [has_mul Y] (f g : locally_constant X Y) :
⇑(f * g) = f * g :=
rfl
@[to_additive] lemma mul_apply [has_mul Y] (f g : locally_constant X Y) (x : X) :
(f * g) x = f x * g x := rfl
@[to_additive] instance [mul_one_class Y] : mul_one_class (locally_constant X Y) :=
{ one_mul := by { intros, ext, simp only [mul_apply, one_apply, one_mul] },
mul_one := by { intros, ext, simp only [mul_apply, one_apply, mul_one] },
.. locally_constant.has_one,
.. locally_constant.has_mul }
/-- `coe_fn` is a `monoid_hom`. -/
@[to_additive "`coe_fn` is an `add_monoid_hom`.", simps]
def coe_fn_monoid_hom [mul_one_class Y] : locally_constant X Y →* (X → Y) :=
{ to_fun := coe_fn,
map_one' := rfl,
map_mul' := λ _ _, rfl }
/-- The constant-function embedding, as a multiplicative monoid hom. -/
@[to_additive "The constant-function embedding, as an additive monoid hom.", simps]
def const_monoid_hom [mul_one_class Y] : Y →* locally_constant X Y :=
{ to_fun := const X,
map_one' := rfl,
map_mul' := λ _ _, rfl, }
instance [mul_zero_class Y] : mul_zero_class (locally_constant X Y) :=
{ zero_mul := by { intros, ext, simp only [mul_apply, zero_apply, zero_mul] },
mul_zero := by { intros, ext, simp only [mul_apply, zero_apply, mul_zero] },
.. locally_constant.has_zero,
.. locally_constant.has_mul }
instance [mul_zero_one_class Y] : mul_zero_one_class (locally_constant X Y) :=
{ .. locally_constant.mul_zero_class, .. locally_constant.mul_one_class }
section char_fn
variables (Y) [mul_zero_one_class Y] {U V : set X}
/-- Characteristic functions are locally constant functions taking `x : X` to `1` if `x ∈ U`,
where `U` is a clopen set, and `0` otherwise. -/
noncomputable def char_fn (hU : is_clopen U) : locally_constant X Y := indicator 1 hU
lemma coe_char_fn (hU : is_clopen U) : (char_fn Y hU : X → Y) = set.indicator U 1 :=
rfl
lemma char_fn_eq_one [nontrivial Y] (x : X) (hU : is_clopen U) :
char_fn Y hU x = (1 : Y) ↔ x ∈ U := set.indicator_eq_one_iff_mem _
lemma char_fn_eq_zero [nontrivial Y] (x : X) (hU : is_clopen U) :
char_fn Y hU x = (0 : Y) ↔ x ∉ U := set.indicator_eq_zero_iff_not_mem _
lemma char_fn_inj [nontrivial Y] (hU : is_clopen U) (hV : is_clopen V)
(h : char_fn Y hU = char_fn Y hV) : U = V :=
set.indicator_one_inj Y $ coe_inj.mpr h
end char_fn
@[to_additive] instance [has_div Y] : has_div (locally_constant X Y) :=
{ div := λ f g, ⟨f / g, f.is_locally_constant.div g.is_locally_constant⟩ }
@[to_additive] lemma coe_div [has_div Y] (f g : locally_constant X Y) :
⇑(f / g) = f / g := rfl
@[to_additive] lemma div_apply [has_div Y] (f g : locally_constant X Y) (x : X) :
(f / g) x = f x / g x := rfl
@[to_additive] instance [semigroup Y] : semigroup (locally_constant X Y) :=
{ mul_assoc := by { intros, ext, simp only [mul_apply, mul_assoc] },
.. locally_constant.has_mul }
instance [semigroup_with_zero Y] : semigroup_with_zero (locally_constant X Y) :=
{ .. locally_constant.mul_zero_class,
.. locally_constant.semigroup }
@[to_additive] instance [comm_semigroup Y] : comm_semigroup (locally_constant X Y) :=
{ mul_comm := by { intros, ext, simp only [mul_apply, mul_comm] },
.. locally_constant.semigroup }
@[to_additive] instance [monoid Y] : monoid (locally_constant X Y) :=
{ mul := (*),
.. locally_constant.semigroup, .. locally_constant.mul_one_class }
instance [add_monoid_with_one Y] : add_monoid_with_one (locally_constant X Y) :=
{ nat_cast := λ n, const X n,
nat_cast_zero := by ext; simp [nat.cast],
nat_cast_succ := λ _, by ext; simp [nat.cast],
.. locally_constant.add_monoid, .. locally_constant.has_one }
@[to_additive] instance [comm_monoid Y] : comm_monoid (locally_constant X Y) :=
{ .. locally_constant.comm_semigroup, .. locally_constant.monoid }
@[to_additive] instance [group Y] : group (locally_constant X Y) :=
{ mul_left_inv := by { intros, ext, simp only [mul_apply, inv_apply, one_apply, mul_left_inv] },
div_eq_mul_inv := by { intros, ext, simp only [mul_apply, inv_apply, div_apply, div_eq_mul_inv] },
.. locally_constant.monoid, .. locally_constant.has_inv, .. locally_constant.has_div }
@[to_additive] instance [comm_group Y] : comm_group (locally_constant X Y) :=
{ .. locally_constant.comm_monoid, .. locally_constant.group }
instance [distrib Y] : distrib (locally_constant X Y) :=
{ left_distrib := by { intros, ext, simp only [mul_apply, add_apply, mul_add] },
right_distrib := by { intros, ext, simp only [mul_apply, add_apply, add_mul] },
.. locally_constant.has_add, .. locally_constant.has_mul }
instance [non_unital_non_assoc_semiring Y] : non_unital_non_assoc_semiring (locally_constant X Y) :=
{ .. locally_constant.add_comm_monoid, .. locally_constant.has_mul,
.. locally_constant.distrib, .. locally_constant.mul_zero_class }
instance [non_unital_semiring Y] : non_unital_semiring (locally_constant X Y) :=
{ .. locally_constant.semigroup, .. locally_constant.non_unital_non_assoc_semiring }
instance [non_assoc_semiring Y] : non_assoc_semiring (locally_constant X Y) :=
{ .. locally_constant.mul_one_class, .. locally_constant.add_monoid_with_one,
.. locally_constant.non_unital_non_assoc_semiring }
/-- The constant-function embedding, as a ring hom. -/
@[simps] def const_ring_hom [non_assoc_semiring Y] : Y →+* locally_constant X Y :=
{ to_fun := const X,
.. const_monoid_hom,
.. const_add_monoid_hom, }
instance [semiring Y] : semiring (locally_constant X Y) :=
{ .. locally_constant.non_assoc_semiring, .. locally_constant.monoid }
instance [non_unital_comm_semiring Y] : non_unital_comm_semiring (locally_constant X Y) :=
{ .. locally_constant.non_unital_semiring, .. locally_constant.comm_semigroup }
instance [comm_semiring Y] : comm_semiring (locally_constant X Y) :=
{ .. locally_constant.semiring, .. locally_constant.comm_monoid }
instance [non_unital_non_assoc_ring Y] : non_unital_non_assoc_ring (locally_constant X Y) :=
{ .. locally_constant.add_comm_group, .. locally_constant.has_mul,
.. locally_constant.distrib, .. locally_constant.mul_zero_class }
instance [non_unital_ring Y] : non_unital_ring (locally_constant X Y) :=
{ .. locally_constant.semigroup, .. locally_constant.non_unital_non_assoc_ring }
instance [non_assoc_ring Y] : non_assoc_ring (locally_constant X Y) :=
{ .. locally_constant.mul_one_class, .. locally_constant.non_unital_non_assoc_ring }
instance [ring Y] : ring (locally_constant X Y) :=
{ .. locally_constant.semiring, .. locally_constant.add_comm_group }
instance [non_unital_comm_ring Y] : non_unital_comm_ring (locally_constant X Y) :=
{ .. locally_constant.non_unital_comm_semiring, .. locally_constant.non_unital_ring }
instance [comm_ring Y] : comm_ring (locally_constant X Y) :=
{ .. locally_constant.comm_semiring, .. locally_constant.ring }
variables {R : Type*}
instance [has_smul R Y] : has_smul R (locally_constant X Y) :=
{ smul := λ r f,
{ to_fun := r • f,
is_locally_constant := ((is_locally_constant f).comp ((•) r) : _), } }
@[simp] lemma coe_smul [has_smul R Y] (r : R) (f : locally_constant X Y) : ⇑(r • f) = r • f := rfl
lemma smul_apply [has_smul R Y] (r : R) (f : locally_constant X Y) (x : X) :
(r • f) x = r • (f x) :=
rfl
instance [monoid R] [mul_action R Y] : mul_action R (locally_constant X Y) :=
function.injective.mul_action _ coe_injective (λ _ _, rfl)
instance [monoid R] [add_monoid Y] [distrib_mul_action R Y] :
distrib_mul_action R (locally_constant X Y) :=
function.injective.distrib_mul_action coe_fn_add_monoid_hom coe_injective (λ _ _, rfl)
instance [semiring R] [add_comm_monoid Y] [module R Y] : module R (locally_constant X Y) :=
function.injective.module R coe_fn_add_monoid_hom coe_injective (λ _ _, rfl)
section algebra
variables [comm_semiring R] [semiring Y] [algebra R Y]
instance : algebra R (locally_constant X Y) :=
{ to_ring_hom := const_ring_hom.comp $ algebra_map R Y,
commutes' := by { intros, ext, exact algebra.commutes' _ _, },
smul_def' := by { intros, ext, exact algebra.smul_def' _ _, }, }
@[simp] lemma coe_algebra_map (r : R) :
⇑(algebra_map R (locally_constant X Y) r) = algebra_map R (X → Y) r :=
rfl
end algebra
end locally_constant
|
[STATEMENT]
lemma smult_sum: fixes a :: "'a::ring_1" shows "(\<Sum>i\<in>I. a *\<^sub>S f i) = a *\<^sub>S (sum f I)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<Sum>i\<in>I. a *\<^sub>S f i) = a *\<^sub>S sum f I
[PROOF STEP]
by (induction I rule: infinite_finite_induct)
(simp_all add: smult_right_add vec_eq_iff) |
/-
Copyright (c) 2022 Jireh Loreaux All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jireh Loreaux
! This file was ported from Lean 3 source module ring_theory.non_unital_subsemiring.basic
! leanprover-community/mathlib commit feb99064803fd3108e37c18b0f77d0a8344677a3
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Algebra.Ring.Equiv
import Mathbin.Algebra.Ring.Prod
import Mathbin.Data.Set.Finite
import Mathbin.GroupTheory.Submonoid.Membership
import Mathbin.GroupTheory.Subsemigroup.Membership
import Mathbin.GroupTheory.Subsemigroup.Centralizer
/-!
# Bundled non-unital subsemirings
We define bundled non-unital subsemirings and some standard constructions:
`complete_lattice` structure, `subtype` and `inclusion` ring homomorphisms, non-unital subsemiring
`map`, `comap` and range (`srange`) of a `non_unital_ring_hom` etc.
-/
open BigOperators
universe u v w
variable {R : Type u} {S : Type v} {T : Type w} [NonUnitalNonAssocSemiring R] (M : Subsemigroup R)
/-- `non_unital_subsemiring_class S R` states that `S` is a type of subsets `s ⊆ R` that
are both an additive submonoid and also a multiplicative subsemigroup. -/
class NonUnitalSubsemiringClass (S : Type _) (R : Type u) [NonUnitalNonAssocSemiring R]
[SetLike S R] extends AddSubmonoidClass S R where
mul_mem : ∀ {s : S} {a b : R}, a ∈ s → b ∈ s → a * b ∈ s
#align non_unital_subsemiring_class NonUnitalSubsemiringClass
-- See note [lower instance priority]
instance (priority := 100) NonUnitalSubsemiringClass.mulMemClass (S : Type _) (R : Type u)
[NonUnitalNonAssocSemiring R] [SetLike S R] [h : NonUnitalSubsemiringClass S R] :
MulMemClass S R :=
{ h with }
#align non_unital_subsemiring_class.mul_mem_class NonUnitalSubsemiringClass.mulMemClass
namespace NonUnitalSubsemiringClass
variable [SetLike S R] [NonUnitalSubsemiringClass S R] (s : S)
include R S
open AddSubmonoidClass
/- Prefer subclasses of `non_unital_non_assoc_semiring` over subclasses of
`non_unital_subsemiring_class`. -/
/-- A non-unital subsemiring of a `non_unital_non_assoc_semiring` inherits a
`non_unital_non_assoc_semiring` structure -/
instance (priority := 75) toNonUnitalNonAssocSemiring : NonUnitalNonAssocSemiring s :=
Subtype.coe_injective.NonUnitalNonAssocSemiring coe rfl (by simp) (fun _ _ => rfl) fun _ _ => rfl
#align non_unital_subsemiring_class.to_non_unital_non_assoc_semiring NonUnitalSubsemiringClass.toNonUnitalNonAssocSemiring
instance noZeroDivisors [NoZeroDivisors R] : NoZeroDivisors s :=
Subtype.coe_injective.NoZeroDivisors coe rfl fun x y => rfl
#align non_unital_subsemiring_class.no_zero_divisors NonUnitalSubsemiringClass.noZeroDivisors
/-- The natural non-unital ring hom from a non-unital subsemiring of a non-unital semiring `R` to
`R`. -/
def subtype : s →ₙ+* R :=
{ AddSubmonoidClass.Subtype s, MulMemClass.subtype s with toFun := coe }
#align non_unital_subsemiring_class.subtype NonUnitalSubsemiringClass.subtype
@[simp]
theorem coeSubtype : (subtype s : s → R) = coe :=
rfl
#align non_unital_subsemiring_class.coe_subtype NonUnitalSubsemiringClass.coeSubtype
omit R S
/-- A non-unital subsemiring of a `non_unital_semiring` is a `non_unital_semiring`. -/
instance toNonUnitalSemiring {R} [NonUnitalSemiring R] [SetLike S R]
[NonUnitalSubsemiringClass S R] : NonUnitalSemiring s :=
Subtype.coe_injective.NonUnitalSemiring coe rfl (by simp) (fun _ _ => rfl) fun _ _ => rfl
#align non_unital_subsemiring_class.to_non_unital_semiring NonUnitalSubsemiringClass.toNonUnitalSemiring
/-- A non-unital subsemiring of a `non_unital_comm_semiring` is a `non_unital_comm_semiring`. -/
instance toNonUnitalCommSemiring {R} [NonUnitalCommSemiring R] [SetLike S R]
[NonUnitalSubsemiringClass S R] : NonUnitalCommSemiring s :=
Subtype.coe_injective.NonUnitalCommSemiring coe rfl (by simp) (fun _ _ => rfl) fun _ _ => rfl
#align non_unital_subsemiring_class.to_non_unital_comm_semiring NonUnitalSubsemiringClass.toNonUnitalCommSemiring
/-! Note: currently, there are no ordered versions of non-unital rings. -/
end NonUnitalSubsemiringClass
variable [NonUnitalNonAssocSemiring S] [NonUnitalNonAssocSemiring T]
/-- A non-unital subsemiring of a non-unital semiring `R` is a subset `s` that is both an additive
submonoid and a semigroup. -/
structure NonUnitalSubsemiring (R : Type u) [NonUnitalNonAssocSemiring R] extends AddSubmonoid R,
Subsemigroup R
#align non_unital_subsemiring NonUnitalSubsemiring
/-- Reinterpret a `non_unital_subsemiring` as a `subsemigroup`. -/
add_decl_doc NonUnitalSubsemiring.toSubsemigroup
/-- Reinterpret a `non_unital_subsemiring` as an `add_submonoid`. -/
add_decl_doc NonUnitalSubsemiring.toAddSubmonoid
namespace NonUnitalSubsemiring
instance : SetLike (NonUnitalSubsemiring R) R
where
coe := NonUnitalSubsemiring.carrier
coe_injective' p q h := by cases p <;> cases q <;> congr
instance : NonUnitalSubsemiringClass (NonUnitalSubsemiring R) R
where
zero_mem := zero_mem'
add_mem := add_mem'
mul_mem := mul_mem'
@[simp]
theorem mem_carrier {s : NonUnitalSubsemiring R} {x : R} : x ∈ s.carrier ↔ x ∈ s :=
Iff.rfl
#align non_unital_subsemiring.mem_carrier NonUnitalSubsemiring.mem_carrier
/-- Two non-unital subsemirings are equal if they have the same elements. -/
@[ext]
theorem ext {S T : NonUnitalSubsemiring R} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T :=
SetLike.ext h
#align non_unital_subsemiring.ext NonUnitalSubsemiring.ext
/-- Copy of a non-unital subsemiring with a new `carrier` equal to the old one. Useful to fix
definitional equalities.-/
protected def copy (S : NonUnitalSubsemiring R) (s : Set R) (hs : s = ↑S) :
NonUnitalSubsemiring R :=
{ S.toAddSubmonoid.copy s hs, S.toSubsemigroup.copy s hs with carrier := s }
#align non_unital_subsemiring.copy NonUnitalSubsemiring.copy
@[simp]
theorem coe_copy (S : NonUnitalSubsemiring R) (s : Set R) (hs : s = ↑S) :
(S.copy s hs : Set R) = s :=
rfl
#align non_unital_subsemiring.coe_copy NonUnitalSubsemiring.coe_copy
theorem copy_eq (S : NonUnitalSubsemiring R) (s : Set R) (hs : s = ↑S) : S.copy s hs = S :=
SetLike.coe_injective hs
#align non_unital_subsemiring.copy_eq NonUnitalSubsemiring.copy_eq
theorem toSubsemigroup_injective :
Function.Injective (toSubsemigroup : NonUnitalSubsemiring R → Subsemigroup R)
| r, s, h => ext (SetLike.ext_iff.mp h : _)
#align non_unital_subsemiring.to_subsemigroup_injective NonUnitalSubsemiring.toSubsemigroup_injective
@[mono]
theorem toSubsemigroup_strictMono :
StrictMono (toSubsemigroup : NonUnitalSubsemiring R → Subsemigroup R) := fun _ _ => id
#align non_unital_subsemiring.to_subsemigroup_strict_mono NonUnitalSubsemiring.toSubsemigroup_strictMono
@[mono]
theorem toSubsemigroup_mono : Monotone (toSubsemigroup : NonUnitalSubsemiring R → Subsemigroup R) :=
toSubsemigroup_strictMono.Monotone
#align non_unital_subsemiring.to_subsemigroup_mono NonUnitalSubsemiring.toSubsemigroup_mono
theorem toAddSubmonoid_injective :
Function.Injective (toAddSubmonoid : NonUnitalSubsemiring R → AddSubmonoid R)
| r, s, h => ext (SetLike.ext_iff.mp h : _)
#align non_unital_subsemiring.to_add_submonoid_injective NonUnitalSubsemiring.toAddSubmonoid_injective
@[mono]
theorem toAddSubmonoid_strictMono :
StrictMono (toAddSubmonoid : NonUnitalSubsemiring R → AddSubmonoid R) := fun _ _ => id
#align non_unital_subsemiring.to_add_submonoid_strict_mono NonUnitalSubsemiring.toAddSubmonoid_strictMono
@[mono]
theorem toAddSubmonoid_mono : Monotone (toAddSubmonoid : NonUnitalSubsemiring R → AddSubmonoid R) :=
toAddSubmonoid_strictMono.Monotone
#align non_unital_subsemiring.to_add_submonoid_mono NonUnitalSubsemiring.toAddSubmonoid_mono
/-- Construct a `non_unital_subsemiring R` from a set `s`, a subsemigroup `sg`, and an additive
submonoid `sa` such that `x ∈ s ↔ x ∈ sg ↔ x ∈ sa`. -/
protected def mk' (s : Set R) (sg : Subsemigroup R) (hg : ↑sg = s) (sa : AddSubmonoid R)
(ha : ↑sa = s) : NonUnitalSubsemiring R
where
carrier := s
zero_mem' := ha ▸ sa.zero_mem
add_mem' x y := by simpa only [← ha] using sa.add_mem
mul_mem' x y := by simpa only [← hg] using sg.mul_mem
#align non_unital_subsemiring.mk' NonUnitalSubsemiring.mk'
@[simp]
theorem coe_mk' {s : Set R} {sg : Subsemigroup R} (hg : ↑sg = s) {sa : AddSubmonoid R}
(ha : ↑sa = s) : (NonUnitalSubsemiring.mk' s sg hg sa ha : Set R) = s :=
rfl
#align non_unital_subsemiring.coe_mk' NonUnitalSubsemiring.coe_mk'
@[simp]
theorem mem_mk' {s : Set R} {sg : Subsemigroup R} (hg : ↑sg = s) {sa : AddSubmonoid R}
(ha : ↑sa = s) {x : R} : x ∈ NonUnitalSubsemiring.mk' s sg hg sa ha ↔ x ∈ s :=
Iff.rfl
#align non_unital_subsemiring.mem_mk' NonUnitalSubsemiring.mem_mk'
@[simp]
theorem mk'_toSubsemigroup {s : Set R} {sg : Subsemigroup R} (hg : ↑sg = s) {sa : AddSubmonoid R}
(ha : ↑sa = s) : (NonUnitalSubsemiring.mk' s sg hg sa ha).toSubsemigroup = sg :=
SetLike.coe_injective hg.symm
#align non_unital_subsemiring.mk'_to_subsemigroup NonUnitalSubsemiring.mk'_toSubsemigroup
@[simp]
theorem mk'_toAddSubmonoid {s : Set R} {sg : Subsemigroup R} (hg : ↑sg = s) {sa : AddSubmonoid R}
(ha : ↑sa = s) : (NonUnitalSubsemiring.mk' s sg hg sa ha).toAddSubmonoid = sa :=
SetLike.coe_injective ha.symm
#align non_unital_subsemiring.mk'_to_add_submonoid NonUnitalSubsemiring.mk'_toAddSubmonoid
end NonUnitalSubsemiring
namespace NonUnitalSubsemiring
variable {F G : Type _} [NonUnitalRingHomClass F R S] [NonUnitalRingHomClass G S T]
(s : NonUnitalSubsemiring R)
@[simp, norm_cast]
theorem coe_zero : ((0 : s) : R) = (0 : R) :=
rfl
#align non_unital_subsemiring.coe_zero NonUnitalSubsemiring.coe_zero
@[simp, norm_cast]
theorem coe_add (x y : s) : ((x + y : s) : R) = (x + y : R) :=
rfl
#align non_unital_subsemiring.coe_add NonUnitalSubsemiring.coe_add
@[simp, norm_cast]
theorem coe_mul (x y : s) : ((x * y : s) : R) = (x * y : R) :=
rfl
#align non_unital_subsemiring.coe_mul NonUnitalSubsemiring.coe_mul
/-! Note: currently, there are no ordered versions of non-unital rings. -/
@[simp]
theorem mem_toSubsemigroup {s : NonUnitalSubsemiring R} {x : R} : x ∈ s.toSubsemigroup ↔ x ∈ s :=
Iff.rfl
#align non_unital_subsemiring.mem_to_subsemigroup NonUnitalSubsemiring.mem_toSubsemigroup
@[simp]
theorem coe_toSubsemigroup (s : NonUnitalSubsemiring R) : (s.toSubsemigroup : Set R) = s :=
rfl
#align non_unital_subsemiring.coe_to_subsemigroup NonUnitalSubsemiring.coe_toSubsemigroup
@[simp]
theorem mem_toAddSubmonoid {s : NonUnitalSubsemiring R} {x : R} : x ∈ s.toAddSubmonoid ↔ x ∈ s :=
Iff.rfl
#align non_unital_subsemiring.mem_to_add_submonoid NonUnitalSubsemiring.mem_toAddSubmonoid
@[simp]
theorem coe_toAddSubmonoid (s : NonUnitalSubsemiring R) : (s.toAddSubmonoid : Set R) = s :=
rfl
#align non_unital_subsemiring.coe_to_add_submonoid NonUnitalSubsemiring.coe_toAddSubmonoid
/-- The non-unital subsemiring `R` of the non-unital semiring `R`. -/
instance : Top (NonUnitalSubsemiring R) :=
⟨{ (⊤ : Subsemigroup R), (⊤ : AddSubmonoid R) with }⟩
@[simp]
theorem mem_top (x : R) : x ∈ (⊤ : NonUnitalSubsemiring R) :=
Set.mem_univ x
#align non_unital_subsemiring.mem_top NonUnitalSubsemiring.mem_top
@[simp]
theorem coe_top : ((⊤ : NonUnitalSubsemiring R) : Set R) = Set.univ :=
rfl
#align non_unital_subsemiring.coe_top NonUnitalSubsemiring.coe_top
/-- The preimage of a non-unital subsemiring along a non-unital ring homomorphism is a
non-unital subsemiring. -/
def comap (f : F) (s : NonUnitalSubsemiring S) : NonUnitalSubsemiring R :=
{ s.toSubsemigroup.comap (f : MulHom R S), s.toAddSubmonoid.comap (f : R →+ S) with
carrier := f ⁻¹' s }
#align non_unital_subsemiring.comap NonUnitalSubsemiring.comap
@[simp]
theorem coe_comap (s : NonUnitalSubsemiring S) (f : F) : (s.comap f : Set R) = f ⁻¹' s :=
rfl
#align non_unital_subsemiring.coe_comap NonUnitalSubsemiring.coe_comap
@[simp]
theorem mem_comap {s : NonUnitalSubsemiring S} {f : F} {x : R} : x ∈ s.comap f ↔ f x ∈ s :=
Iff.rfl
#align non_unital_subsemiring.mem_comap NonUnitalSubsemiring.mem_comap
-- this has some nasty coercions, how to deal with it?
theorem comap_comap (s : NonUnitalSubsemiring T) (g : G) (f : F) :
((s.comap g : NonUnitalSubsemiring S).comap f : NonUnitalSubsemiring R) =
s.comap ((g : S →ₙ+* T).comp (f : R →ₙ+* S)) :=
rfl
#align non_unital_subsemiring.comap_comap NonUnitalSubsemiring.comap_comap
/-- The image of a non-unital subsemiring along a ring homomorphism is a non-unital subsemiring. -/
def map (f : F) (s : NonUnitalSubsemiring R) : NonUnitalSubsemiring S :=
{ s.toSubsemigroup.map (f : R →ₙ* S), s.toAddSubmonoid.map (f : R →+ S) with carrier := f '' s }
#align non_unital_subsemiring.map NonUnitalSubsemiring.map
@[simp]
theorem coe_map (f : F) (s : NonUnitalSubsemiring R) : (s.map f : Set S) = f '' s :=
rfl
#align non_unital_subsemiring.coe_map NonUnitalSubsemiring.coe_map
@[simp]
theorem mem_map {f : F} {s : NonUnitalSubsemiring R} {y : S} : y ∈ s.map f ↔ ∃ x ∈ s, f x = y :=
Set.mem_image_iff_bex
#align non_unital_subsemiring.mem_map NonUnitalSubsemiring.mem_map
@[simp]
theorem map_id : s.map (NonUnitalRingHom.id R) = s :=
SetLike.coe_injective <| Set.image_id _
#align non_unital_subsemiring.map_id NonUnitalSubsemiring.map_id
-- unavoidable coercions?
theorem map_map (g : G) (f : F) :
(s.map (f : R →ₙ+* S)).map (g : S →ₙ+* T) = s.map ((g : S →ₙ+* T).comp (f : R →ₙ+* S)) :=
SetLike.coe_injective <| Set.image_image _ _ _
#align non_unital_subsemiring.map_map NonUnitalSubsemiring.map_map
theorem map_le_iff_le_comap {f : F} {s : NonUnitalSubsemiring R} {t : NonUnitalSubsemiring S} :
s.map f ≤ t ↔ s ≤ t.comap f :=
Set.image_subset_iff
#align non_unital_subsemiring.map_le_iff_le_comap NonUnitalSubsemiring.map_le_iff_le_comap
theorem gc_map_comap (f : F) :
@GaloisConnection (NonUnitalSubsemiring R) (NonUnitalSubsemiring S) _ _ (map f) (comap f) :=
fun S T => map_le_iff_le_comap
#align non_unital_subsemiring.gc_map_comap NonUnitalSubsemiring.gc_map_comap
/-- A non-unital subsemiring is isomorphic to its image under an injective function -/
noncomputable def equivMapOfInjective (f : F) (hf : Function.Injective (f : R → S)) :
s ≃+* s.map f :=
{
Equiv.Set.image f s
hf with
map_mul' := fun _ _ => Subtype.ext (map_mul f _ _)
map_add' := fun _ _ => Subtype.ext (map_add f _ _) }
#align non_unital_subsemiring.equiv_map_of_injective NonUnitalSubsemiring.equivMapOfInjective
@[simp]
theorem coe_equivMapOfInjective_apply (f : F) (hf : Function.Injective f) (x : s) :
(equivMapOfInjective s f hf x : S) = f x :=
rfl
#align non_unital_subsemiring.coe_equiv_map_of_injective_apply NonUnitalSubsemiring.coe_equivMapOfInjective_apply
end NonUnitalSubsemiring
namespace NonUnitalRingHom
open NonUnitalSubsemiring
variable {F G : Type _} [NonUnitalRingHomClass F R S] [NonUnitalRingHomClass G S T] (f : F) (g : G)
/-- The range of a non-unital ring homomorphism is a non-unital subsemiring.
See note [range copy pattern]. -/
def srange : NonUnitalSubsemiring S :=
((⊤ : NonUnitalSubsemiring R).map (f : R →ₙ+* S)).copy (Set.range f) Set.image_univ.symm
#align non_unital_ring_hom.srange NonUnitalRingHom.srange
@[simp]
theorem coe_srange : (@srange R S _ _ _ _ f : Set S) = Set.range f :=
rfl
#align non_unital_ring_hom.coe_srange NonUnitalRingHom.coe_srange
@[simp]
theorem mem_srange {f : F} {y : S} : y ∈ @srange R S _ _ _ _ f ↔ ∃ x, f x = y :=
Iff.rfl
#align non_unital_ring_hom.mem_srange NonUnitalRingHom.mem_srange
theorem srange_eq_map : @srange R S _ _ _ _ f = (⊤ : NonUnitalSubsemiring R).map f :=
by
ext
simp
#align non_unital_ring_hom.srange_eq_map NonUnitalRingHom.srange_eq_map
theorem mem_srange_self (f : F) (x : R) : f x ∈ @srange R S _ _ _ _ f :=
mem_srange.mpr ⟨x, rfl⟩
#align non_unital_ring_hom.mem_srange_self NonUnitalRingHom.mem_srange_self
theorem map_srange (g : S →ₙ+* T) (f : R →ₙ+* S) : map g (srange f) = srange (g.comp f) := by
simpa only [srange_eq_map] using (⊤ : NonUnitalSubsemiring R).map_map g f
#align non_unital_ring_hom.map_srange NonUnitalRingHom.map_srange
/-- The range of a morphism of non-unital semirings is finite if the domain is a finite. -/
instance finite_srange [Finite R] (f : F) : Finite (srange f : NonUnitalSubsemiring S) :=
(Set.finite_range f).to_subtype
#align non_unital_ring_hom.finite_srange NonUnitalRingHom.finite_srange
end NonUnitalRingHom
namespace NonUnitalSubsemiring
-- should we define this as the range of the zero homomorphism?
instance : Bot (NonUnitalSubsemiring R) :=
⟨{ carrier := {0}
add_mem' := fun _ _ _ _ => by simp_all
zero_mem' := Set.mem_singleton 0
mul_mem' := fun _ _ _ _ => by simp_all }⟩
instance : Inhabited (NonUnitalSubsemiring R) :=
⟨⊥⟩
theorem coe_bot : ((⊥ : NonUnitalSubsemiring R) : Set R) = {0} :=
rfl
#align non_unital_subsemiring.coe_bot NonUnitalSubsemiring.coe_bot
theorem mem_bot {x : R} : x ∈ (⊥ : NonUnitalSubsemiring R) ↔ x = 0 :=
Set.mem_singleton_iff
#align non_unital_subsemiring.mem_bot NonUnitalSubsemiring.mem_bot
/-- The inf of two non-unital subsemirings is their intersection. -/
instance : Inf (NonUnitalSubsemiring R) :=
⟨fun s t =>
{ s.toSubsemigroup ⊓ t.toSubsemigroup, s.toAddSubmonoid ⊓ t.toAddSubmonoid with
carrier := s ∩ t }⟩
@[simp]
theorem coe_inf (p p' : NonUnitalSubsemiring R) :
((p ⊓ p' : NonUnitalSubsemiring R) : Set R) = p ∩ p' :=
rfl
#align non_unital_subsemiring.coe_inf NonUnitalSubsemiring.coe_inf
@[simp]
theorem mem_inf {p p' : NonUnitalSubsemiring R} {x : R} : x ∈ p ⊓ p' ↔ x ∈ p ∧ x ∈ p' :=
Iff.rfl
#align non_unital_subsemiring.mem_inf NonUnitalSubsemiring.mem_inf
instance : InfSet (NonUnitalSubsemiring R) :=
⟨fun s =>
NonUnitalSubsemiring.mk' (⋂ t ∈ s, ↑t) (⨅ t ∈ s, NonUnitalSubsemiring.toSubsemigroup t)
(by simp) (⨅ t ∈ s, NonUnitalSubsemiring.toAddSubmonoid t) (by simp)⟩
@[simp, norm_cast]
theorem coe_infₛ (S : Set (NonUnitalSubsemiring R)) :
((infₛ S : NonUnitalSubsemiring R) : Set R) = ⋂ s ∈ S, ↑s :=
rfl
#align non_unital_subsemiring.coe_Inf NonUnitalSubsemiring.coe_infₛ
theorem mem_infₛ {S : Set (NonUnitalSubsemiring R)} {x : R} : x ∈ infₛ S ↔ ∀ p ∈ S, x ∈ p :=
Set.mem_interᵢ₂
#align non_unital_subsemiring.mem_Inf NonUnitalSubsemiring.mem_infₛ
@[simp]
theorem infₛ_toSubsemigroup (s : Set (NonUnitalSubsemiring R)) :
(infₛ s).toSubsemigroup = ⨅ t ∈ s, NonUnitalSubsemiring.toSubsemigroup t :=
mk'_toSubsemigroup _ _
#align non_unital_subsemiring.Inf_to_subsemigroup NonUnitalSubsemiring.infₛ_toSubsemigroup
@[simp]
theorem infₛ_toAddSubmonoid (s : Set (NonUnitalSubsemiring R)) :
(infₛ s).toAddSubmonoid = ⨅ t ∈ s, NonUnitalSubsemiring.toAddSubmonoid t :=
mk'_toAddSubmonoid _ _
#align non_unital_subsemiring.Inf_to_add_submonoid NonUnitalSubsemiring.infₛ_toAddSubmonoid
/-- Non-unital subsemirings of a non-unital semiring form a complete lattice. -/
instance : CompleteLattice (NonUnitalSubsemiring R) :=
{
completeLatticeOfInf (NonUnitalSubsemiring R) fun s =>
IsGLB.of_image (fun s t => show (s : Set R) ≤ t ↔ s ≤ t from SetLike.coe_subset_coe)
isGLB_binfᵢ with
bot := ⊥
bot_le := fun s x hx => (mem_bot.mp hx).symm ▸ zero_mem s
top := ⊤
le_top := fun s x hx => trivial
inf := (· ⊓ ·)
inf_le_left := fun s t x => And.left
inf_le_right := fun s t x => And.right
le_inf := fun s t₁ t₂ h₁ h₂ x hx => ⟨h₁ hx, h₂ hx⟩ }
theorem eq_top_iff' (A : NonUnitalSubsemiring R) : A = ⊤ ↔ ∀ x : R, x ∈ A :=
eq_top_iff.trans ⟨fun h m => h <| mem_top m, fun h m _ => h m⟩
#align non_unital_subsemiring.eq_top_iff' NonUnitalSubsemiring.eq_top_iff'
section Center
/-- The center of a semiring `R` is the set of elements that commute with everything in `R` -/
def center (R) [NonUnitalSemiring R] : NonUnitalSubsemiring R :=
{ Subsemigroup.center R with
carrier := Set.center R
zero_mem' := Set.zero_mem_center R
add_mem' := fun a b => Set.add_mem_center }
#align non_unital_subsemiring.center NonUnitalSubsemiring.center
theorem coe_center (R) [NonUnitalSemiring R] : ↑(center R) = Set.center R :=
rfl
#align non_unital_subsemiring.coe_center NonUnitalSubsemiring.coe_center
@[simp]
theorem center_toSubsemigroup (R) [NonUnitalSemiring R] :
(center R).toSubsemigroup = Subsemigroup.center R :=
rfl
#align non_unital_subsemiring.center_to_subsemigroup NonUnitalSubsemiring.center_toSubsemigroup
theorem mem_center_iff {R} [NonUnitalSemiring R] {z : R} : z ∈ center R ↔ ∀ g, g * z = z * g :=
Iff.rfl
#align non_unital_subsemiring.mem_center_iff NonUnitalSubsemiring.mem_center_iff
instance decidableMemCenter {R} [NonUnitalSemiring R] [DecidableEq R] [Fintype R] :
DecidablePred (· ∈ center R) := fun _ => decidable_of_iff' _ mem_center_iff
#align non_unital_subsemiring.decidable_mem_center NonUnitalSubsemiring.decidableMemCenter
@[simp]
theorem center_eq_top (R) [NonUnitalCommSemiring R] : center R = ⊤ :=
SetLike.coe_injective (Set.center_eq_univ R)
#align non_unital_subsemiring.center_eq_top NonUnitalSubsemiring.center_eq_top
/-- The center is commutative. -/
instance {R} [NonUnitalSemiring R] : NonUnitalCommSemiring (center R) :=
{ Subsemigroup.center.commSemigroup,
NonUnitalSubsemiringClass.toNonUnitalSemiring (center R) with }
end Center
section Centralizer
/-- The centralizer of a set as non-unital subsemiring. -/
def centralizer {R} [NonUnitalSemiring R] (s : Set R) : NonUnitalSubsemiring R :=
{ Subsemigroup.centralizer s with
carrier := s.centralizer
zero_mem' := Set.zero_mem_centralizer _
add_mem' := fun x y hx hy => Set.add_mem_centralizer hx hy }
#align non_unital_subsemiring.centralizer NonUnitalSubsemiring.centralizer
@[simp, norm_cast]
theorem coe_centralizer {R} [NonUnitalSemiring R] (s : Set R) :
(centralizer s : Set R) = s.centralizer :=
rfl
#align non_unital_subsemiring.coe_centralizer NonUnitalSubsemiring.coe_centralizer
theorem centralizer_toSubsemigroup {R} [NonUnitalSemiring R] (s : Set R) :
(centralizer s).toSubsemigroup = Subsemigroup.centralizer s :=
rfl
#align non_unital_subsemiring.centralizer_to_subsemigroup NonUnitalSubsemiring.centralizer_toSubsemigroup
theorem mem_centralizer_iff {R} [NonUnitalSemiring R] {s : Set R} {z : R} :
z ∈ centralizer s ↔ ∀ g ∈ s, g * z = z * g :=
Iff.rfl
#align non_unital_subsemiring.mem_centralizer_iff NonUnitalSubsemiring.mem_centralizer_iff
theorem centralizer_le {R} [NonUnitalSemiring R] (s t : Set R) (h : s ⊆ t) :
centralizer t ≤ centralizer s :=
Set.centralizer_subset h
#align non_unital_subsemiring.centralizer_le NonUnitalSubsemiring.centralizer_le
@[simp]
theorem centralizer_univ {R} [NonUnitalSemiring R] : centralizer Set.univ = center R :=
SetLike.ext' (Set.centralizer_univ R)
#align non_unital_subsemiring.centralizer_univ NonUnitalSubsemiring.centralizer_univ
end Centralizer
/-- The `non_unital_subsemiring` generated by a set. -/
def closure (s : Set R) : NonUnitalSubsemiring R :=
infₛ { S | s ⊆ S }
#align non_unital_subsemiring.closure NonUnitalSubsemiring.closure
theorem mem_closure {x : R} {s : Set R} :
x ∈ closure s ↔ ∀ S : NonUnitalSubsemiring R, s ⊆ S → x ∈ S :=
mem_infₛ
#align non_unital_subsemiring.mem_closure NonUnitalSubsemiring.mem_closure
/-- The non-unital subsemiring generated by a set includes the set. -/
@[simp]
theorem subset_closure {s : Set R} : s ⊆ closure s := fun x hx => mem_closure.2 fun S hS => hS hx
#align non_unital_subsemiring.subset_closure NonUnitalSubsemiring.subset_closure
theorem not_mem_of_not_mem_closure {s : Set R} {P : R} (hP : P ∉ closure s) : P ∉ s := fun h =>
hP (subset_closure h)
#align non_unital_subsemiring.not_mem_of_not_mem_closure NonUnitalSubsemiring.not_mem_of_not_mem_closure
/-- A non-unital subsemiring `S` includes `closure s` if and only if it includes `s`. -/
@[simp]
theorem closure_le {s : Set R} {t : NonUnitalSubsemiring R} : closure s ≤ t ↔ s ⊆ t :=
⟨Set.Subset.trans subset_closure, fun h => infₛ_le h⟩
#align non_unital_subsemiring.closure_le NonUnitalSubsemiring.closure_le
/-- Subsemiring closure of a set is monotone in its argument: if `s ⊆ t`,
then `closure s ≤ closure t`. -/
theorem closure_mono ⦃s t : Set R⦄ (h : s ⊆ t) : closure s ≤ closure t :=
closure_le.2 <| Set.Subset.trans h subset_closure
#align non_unital_subsemiring.closure_mono NonUnitalSubsemiring.closure_mono
theorem closure_eq_of_le {s : Set R} {t : NonUnitalSubsemiring R} (h₁ : s ⊆ t)
(h₂ : t ≤ closure s) : closure s = t :=
le_antisymm (closure_le.2 h₁) h₂
#align non_unital_subsemiring.closure_eq_of_le NonUnitalSubsemiring.closure_eq_of_le
theorem mem_map_equiv {f : R ≃+* S} {K : NonUnitalSubsemiring R} {x : S} :
x ∈ K.map (f : R →ₙ+* S) ↔ f.symm x ∈ K :=
@Set.mem_image_equiv _ _ (↑K) f.toEquiv x
#align non_unital_subsemiring.mem_map_equiv NonUnitalSubsemiring.mem_map_equiv
theorem map_equiv_eq_comap_symm (f : R ≃+* S) (K : NonUnitalSubsemiring R) :
K.map (f : R →ₙ+* S) = K.comap f.symm :=
SetLike.coe_injective (f.toEquiv.image_eq_preimage K)
#align non_unital_subsemiring.map_equiv_eq_comap_symm NonUnitalSubsemiring.map_equiv_eq_comap_symm
theorem comap_equiv_eq_map_symm (f : R ≃+* S) (K : NonUnitalSubsemiring S) :
K.comap (f : R →ₙ+* S) = K.map f.symm :=
(map_equiv_eq_comap_symm f.symm K).symm
#align non_unital_subsemiring.comap_equiv_eq_map_symm NonUnitalSubsemiring.comap_equiv_eq_map_symm
end NonUnitalSubsemiring
namespace Subsemigroup
/-- The additive closure of a non-unital subsemigroup is a non-unital subsemiring. -/
def nonUnitalSubsemiringClosure (M : Subsemigroup R) : NonUnitalSubsemiring R :=
{ AddSubmonoid.closure (M : Set R) with mul_mem' := fun x y => MulMemClass.mul_mem_add_closure }
#align subsemigroup.non_unital_subsemiring_closure Subsemigroup.nonUnitalSubsemiringClosure
theorem nonUnitalSubsemiringClosure_coe :
(M.nonUnitalSubsemiringClosure : Set R) = AddSubmonoid.closure (M : Set R) :=
rfl
#align subsemigroup.non_unital_subsemiring_closure_coe Subsemigroup.nonUnitalSubsemiringClosure_coe
theorem nonUnitalSubsemiringClosure_toAddSubmonoid :
M.nonUnitalSubsemiringClosure.toAddSubmonoid = AddSubmonoid.closure (M : Set R) :=
rfl
#align subsemigroup.non_unital_subsemiring_closure_to_add_submonoid Subsemigroup.nonUnitalSubsemiringClosure_toAddSubmonoid
/-- The `non_unital_subsemiring` generated by a multiplicative subsemigroup coincides with the
`non_unital_subsemiring.closure` of the subsemigroup itself . -/
theorem nonUnitalSubsemiringClosure_eq_closure :
M.nonUnitalSubsemiringClosure = NonUnitalSubsemiring.closure (M : Set R) :=
by
ext
refine'
⟨fun hx => _, fun hx =>
(non_unital_subsemiring.mem_closure.mp hx) M.non_unital_subsemiring_closure fun s sM =>
_⟩ <;>
rintro - ⟨H1, rfl⟩ <;>
rintro - ⟨H2, rfl⟩
· exact add_submonoid.mem_closure.mp hx H1.to_add_submonoid H2
· exact H2 sM
#align subsemigroup.non_unital_subsemiring_closure_eq_closure Subsemigroup.nonUnitalSubsemiringClosure_eq_closure
end Subsemigroup
namespace NonUnitalSubsemiring
@[simp]
theorem closure_subsemigroup_closure (s : Set R) : closure ↑(Subsemigroup.closure s) = closure s :=
le_antisymm
(closure_le.mpr fun y hy =>
(Subsemigroup.mem_closure.mp hy) (closure s).toSubsemigroup subset_closure)
(closure_mono Subsemigroup.subset_closure)
#align non_unital_subsemiring.closure_subsemigroup_closure NonUnitalSubsemiring.closure_subsemigroup_closure
/-- The elements of the non-unital subsemiring closure of `M` are exactly the elements of the
additive closure of a multiplicative subsemigroup `M`. -/
theorem coe_closure_eq (s : Set R) :
(closure s : Set R) = AddSubmonoid.closure (Subsemigroup.closure s : Set R) := by
simp [← Subsemigroup.nonUnitalSubsemiringClosure_toAddSubmonoid,
Subsemigroup.nonUnitalSubsemiringClosure_eq_closure]
#align non_unital_subsemiring.coe_closure_eq NonUnitalSubsemiring.coe_closure_eq
theorem mem_closure_iff {s : Set R} {x} :
x ∈ closure s ↔ x ∈ AddSubmonoid.closure (Subsemigroup.closure s : Set R) :=
Set.ext_iff.mp (coe_closure_eq s) x
#align non_unital_subsemiring.mem_closure_iff NonUnitalSubsemiring.mem_closure_iff
@[simp]
theorem closure_addSubmonoid_closure {s : Set R} : closure ↑(AddSubmonoid.closure s) = closure s :=
by
ext x
refine' ⟨fun hx => _, fun hx => closure_mono AddSubmonoid.subset_closure hx⟩
rintro - ⟨H, rfl⟩
rintro - ⟨J, rfl⟩
refine' (add_submonoid.mem_closure.mp (mem_closure_iff.mp hx)) H.to_add_submonoid fun y hy => _
refine' (subsemigroup.mem_closure.mp hy) H.to_subsemigroup fun z hz => _
exact (add_submonoid.mem_closure.mp hz) H.to_add_submonoid fun w hw => J hw
#align non_unital_subsemiring.closure_add_submonoid_closure NonUnitalSubsemiring.closure_addSubmonoid_closure
/-- An induction principle for closure membership. If `p` holds for `0`, `1`, and all elements
of `s`, and is preserved under addition and multiplication, then `p` holds for all elements
of the closure of `s`. -/
@[elab_as_elim]
theorem closure_induction {s : Set R} {p : R → Prop} {x} (h : x ∈ closure s) (Hs : ∀ x ∈ s, p x)
(H0 : p 0) (Hadd : ∀ x y, p x → p y → p (x + y)) (Hmul : ∀ x y, p x → p y → p (x * y)) : p x :=
(@closure_le _ _ _ ⟨p, Hadd, H0, Hmul⟩).2 Hs h
#align non_unital_subsemiring.closure_induction NonUnitalSubsemiring.closure_induction
/-- An induction principle for closure membership for predicates with two arguments. -/
@[elab_as_elim]
theorem closure_induction₂ {s : Set R} {p : R → R → Prop} {x} {y : R} (hx : x ∈ closure s)
(hy : y ∈ closure s) (Hs : ∀ x ∈ s, ∀ y ∈ s, p x y) (H0_left : ∀ x, p 0 x)
(H0_right : ∀ x, p x 0) (Hadd_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ + x₂) y)
(Hadd_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ + y₂))
(Hmul_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ * x₂) y)
(Hmul_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ * y₂)) : p x y :=
closure_induction hx
(fun x₁ x₁s => closure_induction hy (Hs x₁ x₁s) (H0_right x₁) (Hadd_right x₁) (Hmul_right x₁))
(H0_left y) (fun z z' => Hadd_left z z' y) fun z z' => Hmul_left z z' y
#align non_unital_subsemiring.closure_induction₂ NonUnitalSubsemiring.closure_induction₂
variable (R)
/-- `closure` forms a Galois insertion with the coercion to set. -/
protected def gi : GaloisInsertion (@closure R _) coe
where
choice s _ := closure s
gc s t := closure_le
le_l_u s := subset_closure
choice_eq s h := rfl
#align non_unital_subsemiring.gi NonUnitalSubsemiring.gi
variable {R} {F : Type _} [NonUnitalRingHomClass F R S]
/-- Closure of a non-unital subsemiring `S` equals `S`. -/
theorem closure_eq (s : NonUnitalSubsemiring R) : closure (s : Set R) = s :=
(NonUnitalSubsemiring.gi R).l_u_eq s
#align non_unital_subsemiring.closure_eq NonUnitalSubsemiring.closure_eq
@[simp]
theorem closure_empty : closure (∅ : Set R) = ⊥ :=
(NonUnitalSubsemiring.gi R).gc.l_bot
#align non_unital_subsemiring.closure_empty NonUnitalSubsemiring.closure_empty
@[simp]
theorem closure_univ : closure (Set.univ : Set R) = ⊤ :=
@coe_top R _ ▸ closure_eq ⊤
#align non_unital_subsemiring.closure_univ NonUnitalSubsemiring.closure_univ
theorem closure_union (s t : Set R) : closure (s ∪ t) = closure s ⊔ closure t :=
(NonUnitalSubsemiring.gi R).gc.l_sup
#align non_unital_subsemiring.closure_union NonUnitalSubsemiring.closure_union
theorem closure_unionᵢ {ι} (s : ι → Set R) : closure (⋃ i, s i) = ⨆ i, closure (s i) :=
(NonUnitalSubsemiring.gi R).gc.l_supᵢ
#align non_unital_subsemiring.closure_Union NonUnitalSubsemiring.closure_unionᵢ
theorem closure_unionₛ (s : Set (Set R)) : closure (⋃₀ s) = ⨆ t ∈ s, closure t :=
(NonUnitalSubsemiring.gi R).gc.l_supₛ
#align non_unital_subsemiring.closure_sUnion NonUnitalSubsemiring.closure_unionₛ
theorem map_sup (s t : NonUnitalSubsemiring R) (f : F) :
(map f (s ⊔ t) : NonUnitalSubsemiring S) = map f s ⊔ map f t :=
@GaloisConnection.l_sup _ _ s t _ _ _ _ (gc_map_comap f)
#align non_unital_subsemiring.map_sup NonUnitalSubsemiring.map_sup
theorem map_supᵢ {ι : Sort _} (f : F) (s : ι → NonUnitalSubsemiring R) :
(map f (supᵢ s) : NonUnitalSubsemiring S) = ⨆ i, map f (s i) :=
@GaloisConnection.l_supᵢ _ _ _ _ _ _ _ (gc_map_comap f) s
#align non_unital_subsemiring.map_supr NonUnitalSubsemiring.map_supᵢ
theorem comap_inf (s t : NonUnitalSubsemiring S) (f : F) :
(comap f (s ⊓ t) : NonUnitalSubsemiring R) = comap f s ⊓ comap f t :=
@GaloisConnection.u_inf _ _ s t _ _ _ _ (gc_map_comap f)
#align non_unital_subsemiring.comap_inf NonUnitalSubsemiring.comap_inf
theorem comap_infᵢ {ι : Sort _} (f : F) (s : ι → NonUnitalSubsemiring S) :
(comap f (infᵢ s) : NonUnitalSubsemiring R) = ⨅ i, comap f (s i) :=
@GaloisConnection.u_infᵢ _ _ _ _ _ _ _ (gc_map_comap f) s
#align non_unital_subsemiring.comap_infi NonUnitalSubsemiring.comap_infᵢ
@[simp]
theorem map_bot (f : F) : map f (⊥ : NonUnitalSubsemiring R) = (⊥ : NonUnitalSubsemiring S) :=
(gc_map_comap f).l_bot
#align non_unital_subsemiring.map_bot NonUnitalSubsemiring.map_bot
@[simp]
theorem comap_top (f : F) : comap f (⊤ : NonUnitalSubsemiring S) = (⊤ : NonUnitalSubsemiring R) :=
(gc_map_comap f).u_top
#align non_unital_subsemiring.comap_top NonUnitalSubsemiring.comap_top
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/-- Given `non_unital_subsemiring`s `s`, `t` of semirings `R`, `S` respectively, `s.prod t` is
`s × t` as a non-unital subsemiring of `R × S`. -/
def prod (s : NonUnitalSubsemiring R) (t : NonUnitalSubsemiring S) : NonUnitalSubsemiring (R × S) :=
{ s.toSubsemigroup.Prod t.toSubsemigroup, s.toAddSubmonoid.Prod t.toAddSubmonoid with
carrier := (s : Set R) ×ˢ (t : Set S) }
#align non_unital_subsemiring.prod NonUnitalSubsemiring.prod
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@[norm_cast]
theorem coe_prod (s : NonUnitalSubsemiring R) (t : NonUnitalSubsemiring S) :
(s.Prod t : Set (R × S)) = (s : Set R) ×ˢ (t : Set S) :=
rfl
#align non_unital_subsemiring.coe_prod NonUnitalSubsemiring.coe_prod
theorem mem_prod {s : NonUnitalSubsemiring R} {t : NonUnitalSubsemiring S} {p : R × S} :
p ∈ s.Prod t ↔ p.1 ∈ s ∧ p.2 ∈ t :=
Iff.rfl
#align non_unital_subsemiring.mem_prod NonUnitalSubsemiring.mem_prod
@[mono]
theorem prod_mono ⦃s₁ s₂ : NonUnitalSubsemiring R⦄ (hs : s₁ ≤ s₂) ⦃t₁ t₂ : NonUnitalSubsemiring S⦄
(ht : t₁ ≤ t₂) : s₁.Prod t₁ ≤ s₂.Prod t₂ :=
Set.prod_mono hs ht
#align non_unital_subsemiring.prod_mono NonUnitalSubsemiring.prod_mono
theorem prod_mono_right (s : NonUnitalSubsemiring R) :
Monotone fun t : NonUnitalSubsemiring S => s.Prod t :=
prod_mono (le_refl s)
#align non_unital_subsemiring.prod_mono_right NonUnitalSubsemiring.prod_mono_right
theorem prod_mono_left (t : NonUnitalSubsemiring S) :
Monotone fun s : NonUnitalSubsemiring R => s.Prod t := fun s₁ s₂ hs => prod_mono hs (le_refl t)
#align non_unital_subsemiring.prod_mono_left NonUnitalSubsemiring.prod_mono_left
theorem prod_top (s : NonUnitalSubsemiring R) :
s.Prod (⊤ : NonUnitalSubsemiring S) = s.comap (NonUnitalRingHom.fst R S) :=
ext fun x => by simp [mem_prod, MonoidHom.coe_fst]
#align non_unital_subsemiring.prod_top NonUnitalSubsemiring.prod_top
theorem top_prod (s : NonUnitalSubsemiring S) :
(⊤ : NonUnitalSubsemiring R).Prod s = s.comap (NonUnitalRingHom.snd R S) :=
ext fun x => by simp [mem_prod, MonoidHom.coe_snd]
#align non_unital_subsemiring.top_prod NonUnitalSubsemiring.top_prod
@[simp]
theorem top_prod_top : (⊤ : NonUnitalSubsemiring R).Prod (⊤ : NonUnitalSubsemiring S) = ⊤ :=
(top_prod _).trans <| comap_top _
#align non_unital_subsemiring.top_prod_top NonUnitalSubsemiring.top_prod_top
/-- Product of non-unital subsemirings is isomorphic to their product as semigroups. -/
def prodEquiv (s : NonUnitalSubsemiring R) (t : NonUnitalSubsemiring S) : s.Prod t ≃+* s × t :=
{ Equiv.Set.prod ↑s ↑t with
map_mul' := fun x y => rfl
map_add' := fun x y => rfl }
#align non_unital_subsemiring.prod_equiv NonUnitalSubsemiring.prodEquiv
theorem mem_supᵢ_of_directed {ι} [hι : Nonempty ι] {S : ι → NonUnitalSubsemiring R}
(hS : Directed (· ≤ ·) S) {x : R} : (x ∈ ⨆ i, S i) ↔ ∃ i, x ∈ S i :=
by
refine' ⟨_, fun ⟨i, hi⟩ => (SetLike.le_def.1 <| le_supᵢ S i) hi⟩
let U : NonUnitalSubsemiring R :=
NonUnitalSubsemiring.mk' (⋃ i, (S i : Set R)) (⨆ i, (S i).toSubsemigroup)
(Subsemigroup.coe_supᵢ_of_directed <| hS.mono_comp _ fun _ _ => id)
(⨆ i, (S i).toAddSubmonoid)
(AddSubmonoid.coe_supᵢ_of_directed <| hS.mono_comp _ fun _ _ => id)
suffices (⨆ i, S i) ≤ U by simpa using @this x
exact supᵢ_le fun i x hx => Set.mem_unionᵢ.2 ⟨i, hx⟩
#align non_unital_subsemiring.mem_supr_of_directed NonUnitalSubsemiring.mem_supᵢ_of_directed
theorem coe_supᵢ_of_directed {ι} [hι : Nonempty ι] {S : ι → NonUnitalSubsemiring R}
(hS : Directed (· ≤ ·) S) : ((⨆ i, S i : NonUnitalSubsemiring R) : Set R) = ⋃ i, ↑(S i) :=
Set.ext fun x => by simp [mem_supr_of_directed hS]
#align non_unital_subsemiring.coe_supr_of_directed NonUnitalSubsemiring.coe_supᵢ_of_directed
theorem mem_supₛ_of_directedOn {S : Set (NonUnitalSubsemiring R)} (Sne : S.Nonempty)
(hS : DirectedOn (· ≤ ·) S) {x : R} : x ∈ supₛ S ↔ ∃ s ∈ S, x ∈ s :=
by
haveI : Nonempty S := Sne.to_subtype
simp only [supₛ_eq_supᵢ', mem_supr_of_directed hS.directed_coe, SetCoe.exists, Subtype.coe_mk]
#align non_unital_subsemiring.mem_Sup_of_directed_on NonUnitalSubsemiring.mem_supₛ_of_directedOn
theorem coe_supₛ_of_directedOn {S : Set (NonUnitalSubsemiring R)} (Sne : S.Nonempty)
(hS : DirectedOn (· ≤ ·) S) : (↑(supₛ S) : Set R) = ⋃ s ∈ S, ↑s :=
Set.ext fun x => by simp [mem_Sup_of_directed_on Sne hS]
#align non_unital_subsemiring.coe_Sup_of_directed_on NonUnitalSubsemiring.coe_supₛ_of_directedOn
end NonUnitalSubsemiring
namespace NonUnitalRingHom
variable {F : Type _} [NonUnitalNonAssocSemiring T] [NonUnitalRingHomClass F R S]
{s : NonUnitalSubsemiring R}
open NonUnitalSubsemiringClass NonUnitalSubsemiring
/-- Restriction of a non-unital ring homomorphism to a non-unital subsemiring of the codomain. -/
def codRestrict (f : F) (s : NonUnitalSubsemiring S) (h : ∀ x, f x ∈ s) : R →ₙ+* s :=
{ (f : R →ₙ* S).codRestrict s.toSubsemigroup h, (f : R →+ S).codRestrict s.toAddSubmonoid h with
toFun := fun n => ⟨f n, h n⟩ }
#align non_unital_ring_hom.cod_restrict NonUnitalRingHom.codRestrict
/-- Restriction of a non-unital ring homomorphism to its range interpreted as a
non-unital subsemiring.
This is the bundled version of `set.range_factorization`. -/
def srangeRestrict (f : F) : R →ₙ+* (srange f : NonUnitalSubsemiring S) :=
codRestrict f (srange f) (mem_srange_self f)
#align non_unital_ring_hom.srange_restrict NonUnitalRingHom.srangeRestrict
@[simp]
theorem coe_srangeRestrict (f : F) (x : R) : (srangeRestrict f x : S) = f x :=
rfl
#align non_unital_ring_hom.coe_srange_restrict NonUnitalRingHom.coe_srangeRestrict
theorem srangeRestrict_surjective (f : F) :
Function.Surjective (srangeRestrict f : R → (srange f : NonUnitalSubsemiring S)) :=
fun ⟨y, hy⟩ =>
let ⟨x, hx⟩ := mem_srange.mp hy
⟨x, Subtype.ext hx⟩
#align non_unital_ring_hom.srange_restrict_surjective NonUnitalRingHom.srangeRestrict_surjective
theorem srange_top_iff_surjective {f : F} :
srange f = (⊤ : NonUnitalSubsemiring S) ↔ Function.Surjective (f : R → S) :=
SetLike.ext'_iff.trans <| Iff.trans (by rw [coe_srange, coe_top]) Set.range_iff_surjective
#align non_unital_ring_hom.srange_top_iff_surjective NonUnitalRingHom.srange_top_iff_surjective
/-- The range of a surjective non-unital ring homomorphism is the whole of the codomain. -/
theorem srange_top_of_surjective (f : F) (hf : Function.Surjective (f : R → S)) :
srange f = (⊤ : NonUnitalSubsemiring S) :=
srange_top_iff_surjective.2 hf
#align non_unital_ring_hom.srange_top_of_surjective NonUnitalRingHom.srange_top_of_surjective
/-- The non-unital subsemiring of elements `x : R` such that `f x = g x` -/
def eqSlocus (f g : F) : NonUnitalSubsemiring R :=
{ (f : R →ₙ* S).eqLocus (g : R →ₙ* S), (f : R →+ S).eqLocus g with carrier := { x | f x = g x } }
#align non_unital_ring_hom.eq_slocus NonUnitalRingHom.eqSlocus
/-- If two non-unital ring homomorphisms are equal on a set, then they are equal on its
non-unital subsemiring closure. -/
theorem eqOn_sclosure {f g : F} {s : Set R} (h : Set.EqOn (f : R → S) (g : R → S) s) :
Set.EqOn f g (closure s) :=
show closure s ≤ eqSlocus f g from closure_le.2 h
#align non_unital_ring_hom.eq_on_sclosure NonUnitalRingHom.eqOn_sclosure
theorem eq_of_eqOn_stop {f g : F}
(h : Set.EqOn (f : R → S) (g : R → S) (⊤ : NonUnitalSubsemiring R)) : f = g :=
FunLike.ext _ _ fun x => h trivial
#align non_unital_ring_hom.eq_of_eq_on_stop NonUnitalRingHom.eq_of_eqOn_stop
theorem eq_of_eqOn_sdense {s : Set R} (hs : closure s = ⊤) {f g : F}
(h : s.EqOn (f : R → S) (g : R → S)) : f = g :=
eq_of_eqOn_stop <| hs ▸ eqOn_sclosure h
#align non_unital_ring_hom.eq_of_eq_on_sdense NonUnitalRingHom.eq_of_eqOn_sdense
theorem sclosure_preimage_le (f : F) (s : Set S) :
closure ((f : R → S) ⁻¹' s) ≤ (closure s).comap f :=
closure_le.2 fun x hx => SetLike.mem_coe.2 <| mem_comap.2 <| subset_closure hx
#align non_unital_ring_hom.sclosure_preimage_le NonUnitalRingHom.sclosure_preimage_le
/-- The image under a ring homomorphism of the subsemiring generated by a set equals
the subsemiring generated by the image of the set. -/
theorem map_sclosure (f : F) (s : Set R) : (closure s).map f = closure ((f : R → S) '' s) :=
le_antisymm
(map_le_iff_le_comap.2 <|
le_trans (closure_mono <| Set.subset_preimage_image _ _) (sclosure_preimage_le _ _))
(closure_le.2 <| Set.image_subset _ subset_closure)
#align non_unital_ring_hom.map_sclosure NonUnitalRingHom.map_sclosure
end NonUnitalRingHom
namespace NonUnitalSubsemiring
open NonUnitalRingHom NonUnitalSubsemiringClass
/-- The non-unital ring homomorphism associated to an inclusion of
non-unital subsemirings. -/
def inclusion {S T : NonUnitalSubsemiring R} (h : S ≤ T) : S →ₙ+* T :=
codRestrict (Subtype S) _ fun x => h x.2
#align non_unital_subsemiring.inclusion NonUnitalSubsemiring.inclusion
@[simp]
theorem srange_subtype (s : NonUnitalSubsemiring R) : (Subtype s).srange = s :=
SetLike.coe_injective <| (coe_srange _).trans Subtype.range_coe
#align non_unital_subsemiring.srange_subtype NonUnitalSubsemiring.srange_subtype
@[simp]
theorem range_fst : (fst R S).srange = ⊤ :=
NonUnitalRingHom.srange_top_of_surjective (fst R S) Prod.fst_surjective
#align non_unital_subsemiring.range_fst NonUnitalSubsemiring.range_fst
@[simp]
theorem range_snd : (snd R S).srange = ⊤ :=
NonUnitalRingHom.srange_top_of_surjective (snd R S) <| Prod.snd_surjective
#align non_unital_subsemiring.range_snd NonUnitalSubsemiring.range_snd
end NonUnitalSubsemiring
namespace RingEquiv
open NonUnitalRingHom NonUnitalSubsemiringClass
variable {s t : NonUnitalSubsemiring R}
variable {F : Type _} [NonUnitalRingHomClass F R S]
/-- Makes the identity isomorphism from a proof two non-unital subsemirings of a multiplicative
monoid are equal. -/
def nonUnitalSubsemiringCongr (h : s = t) : s ≃+* t :=
{
Equiv.setCongr <| congr_arg _ h with
map_mul' := fun _ _ => rfl
map_add' := fun _ _ => rfl }
#align ring_equiv.non_unital_subsemiring_congr RingEquiv.nonUnitalSubsemiringCongr
/-- Restrict a non-unital ring homomorphism with a left inverse to a ring isomorphism to its
`non_unital_ring_hom.srange`. -/
def sofLeftInverse' {g : S → R} {f : F} (h : Function.LeftInverse g f) : R ≃+* srange f :=
{ srangeRestrict f with
toFun := srangeRestrict f
invFun := fun x => g (Subtype (srange f) x)
left_inv := h
right_inv := fun x =>
Subtype.ext <|
let ⟨x', hx'⟩ := NonUnitalRingHom.mem_srange.mp x.Prop
show f (g x) = x by rw [← hx', h x'] }
#align ring_equiv.sof_left_inverse' RingEquiv.sofLeftInverse'
@[simp]
theorem sofLeftInverse'_apply {g : S → R} {f : F} (h : Function.LeftInverse g f) (x : R) :
↑(sofLeftInverse' h x) = f x :=
rfl
#align ring_equiv.sof_left_inverse'_apply RingEquiv.sofLeftInverse'_apply
@[simp]
theorem sofLeftInverse'_symm_apply {g : S → R} {f : F} (h : Function.LeftInverse g f)
(x : srange f) : (sofLeftInverse' h).symm x = g x :=
rfl
#align ring_equiv.sof_left_inverse'_symm_apply RingEquiv.sofLeftInverse'_symm_apply
/-- Given an equivalence `e : R ≃+* S` of non-unital semirings and a non-unital subsemiring
`s` of `R`, `non_unital_subsemiring_map e s` is the induced equivalence between `s` and
`s.map e` -/
@[simps]
def nonUnitalSubsemiringMap (e : R ≃+* S) (s : NonUnitalSubsemiring R) :
s ≃+* NonUnitalSubsemiring.map e.toNonUnitalRingHom s :=
{ e.toAddEquiv.addSubmonoidMap s.toAddSubmonoid,
e.toMulEquiv.subsemigroupMap s.toSubsemigroup with }
#align ring_equiv.non_unital_subsemiring_map RingEquiv.nonUnitalSubsemiringMap
end RingEquiv
|
(* Title: HOL/Auth/n_germanSimp_lemma_on_inv__29.thy
Author: Yongjian Li and Kaiqiang Duan, State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences
Copyright 2016 State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences
*)
header{*The n_germanSimp Protocol Case Study*}
theory n_germanSimp_lemma_on_inv__29 imports n_germanSimp_base
begin
section{*All lemmas on causal relation between inv__29 and some rule r*}
lemma n_SendInv__part__0Vsinv__29:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendInv__part__0 i)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__29 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendInv__part__0 i" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__29 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv4)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (eqn (IVar (Para (Ident ''InvSet'') p__Inv4)) (Const true)) (eqn (IVar (Para (Ident ''ShrSet'') p__Inv4)) (Const false))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_SendInv__part__1Vsinv__29:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendInv__part__1 i)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__29 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendInv__part__1 i" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__29 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv4)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (eqn (IVar (Para (Ident ''InvSet'') p__Inv4)) (Const true)) (eqn (IVar (Para (Ident ''ShrSet'') p__Inv4)) (Const false))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_SendInvAckVsinv__29:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendInvAck i)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__29 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendInvAck i" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__29 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_RecvInvAckVsinv__29:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_RecvInvAck i)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__29 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_RecvInvAck i" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__29 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv4)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Para (Ident ''Chan2'') p__Inv4) ''Cmd'')) (Const Inv)) (eqn (IVar (Field (Para (Ident ''Chan3'') p__Inv4) ''Cmd'')) (Const InvAck))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_SendGntSVsinv__29:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendGntS i)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__29 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendGntS i" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__29 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_SendGntEVsinv__29:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendGntE N i)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__29 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendGntE N i" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__29 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_RecvGntSVsinv__29:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_RecvGntS i)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__29 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_RecvGntS i" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__29 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_RecvGntEVsinv__29:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_RecvGntE i)" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__29 p__Inv4)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_RecvGntE i" apply fastforce done
from a2 obtain p__Inv4 where a2:"p__Inv4\<le>N\<and>f=inv__29 p__Inv4" apply fastforce done
have "(i=p__Inv4)\<or>(i~=p__Inv4)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv4)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv4)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_StoreVsinv__29:
assumes a1: "\<exists> i d. i\<le>N\<and>d\<le>N\<and>r=n_Store i d" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__29 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_RecvReqE__part__0Vsinv__29:
assumes a1: "\<exists> i. i\<le>N\<and>r=n_RecvReqE__part__0 N i" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__29 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_RecvReqE__part__1Vsinv__29:
assumes a1: "\<exists> i. i\<le>N\<and>r=n_RecvReqE__part__1 N i" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__29 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_RecvReqSVsinv__29:
assumes a1: "\<exists> i. i\<le>N\<and>r=n_RecvReqS N i" and
a2: "(\<exists> p__Inv4. p__Inv4\<le>N\<and>f=inv__29 p__Inv4)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
end
|
(* 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 *)
Set Implicit Arguments.
Unset Strict Implicit.
Require Export Monoid_cat.
(** Title "The category of groups." *)
Section Inverse.
Variable G : SET.
Variable f : law_of_composition G.
Variable e : G.
Variable inv : MAP G G.
Definition inverse_r := forall x : G, Equal (f (couple x (inv x))) e.
Definition inverse_l := forall x : G, Equal (f (couple (inv x) x)) e.
End Inverse.
Record group_on (G : monoid) : Type :=
{group_inverse_map : Map G G;
group_inverse_r_prf :
inverse_r (sgroup_law_map G) (monoid_unit G) group_inverse_map;
group_inverse_l_prf :
inverse_l (sgroup_law_map G) (monoid_unit G) group_inverse_map}.
Record group : Type :=
{group_monoid :> monoid; group_on_def :> group_on group_monoid}.
Coercion Build_group : group_on >-> group.
Set Strict Implicit.
Unset Implicit Arguments.
Definition group_inverse (G : group) (x : G) := group_inverse_map G x.
Set Implicit Arguments.
Unset Strict Implicit.
Definition GROUP := full_subcat (C:=MONOID) (C':=group) group_monoid. |
John R. Munn is a graduate of UC Davis with multiple degrees who has lived in Davis since his college days in the early 1970s. He has been active in the community including a term on the school board of Davis Joint Unified School District (19972001) and as a Republican candidate for State Assembly in 2000, 2002, 2004, and 2012. He is currently a candidate for City Council Davis City Council for the June 2014 election.
Source:
Ryan, Dave; 7 March 2014, http://www.davisenterprise.com/localnews/numbersguymunnenterscouncilrace/ Numbers guy Munn enters council race, Davis Enterprise, p. A1.
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.