Datasets:
AI4M
/

text
stringlengths
0
3.34M
lemma multiplicity_characterization_nat: "S = {p. 0 < f (p::nat)} \<Longrightarrow> finite S \<Longrightarrow> \<forall>p\<in>S. prime p \<Longrightarrow> prime p \<Longrightarrow> n = (\<Prod>p\<in>S. p ^ f p) \<Longrightarrow> multiplicity p n = f p"
## Get Access Token # If you have previously registered a client using the authentication use case, use this script to create an access token. # Import modules, assign variables library("httr") library("jsonlite") #Global variables to assign - uncomment and assign values if using this script as stand-alone #sasserver <- "http://your-server" #client_name <- "r_client" ## your client #client_secret <- "r_secret" ## your password #username <- "viya_user" #password <- "viya_password" # Get access token for calls # Get API call token # Paremeters: # - your_server # - (Base64) encoded_client_secret # - your_username # - your_passwordc # Outputs: # - It will return a JSON, you will use the access_token for future calls # Call: authenticate <- function(host, username, password, client_name, client_secret, verbose = FALSE) { client_info <- base64_enc(paste0(client_name, ":", client_secret)) url <- parse_url(host) url$path <- "/SASLogon/oauth/token" url$query <- list( grant_type = "password", username = username, password = password ) response <- GET( url = build_url(url), add_headers( "Content-Type" = "application/x-www-form-urlencoded", "accept"="application/json", "authorization" = paste("Basic", client_info) ), if(verbose) verbose() ) stop_for_status(response) registered_clients <- fromJSON(content(response, as = "text")) return(registered_clients) } # Run get access token function - commented out for use in other scripts # Get Access Token # token <- authenticate(host = sasserver , # username = username, # password = password, # client_name = client_name, # client_secret = client_secret)# # token$access_token ## for use in other calls # token
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser ! This file was ported from Lean 3 source module linear_algebra.exterior_algebra.grading ! leanprover-community/mathlib commit 34020e531ebc4e8aac6d449d9eecbcd1508ea8d0 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.LinearAlgebra.ExteriorAlgebra.Basic import Mathbin.RingTheory.GradedAlgebra.Basic /-! # Results about the grading structure of the exterior algebra Many of these results are copied with minimal modification from the tensor algebra. The main result is `exterior_algebra.graded_algebra`, which says that the exterior algebra is a ℕ-graded algebra. -/ namespace ExteriorAlgebra variable {R M : Type _} [CommRing R] [AddCommGroup M] [Module R M] variable (R M) open DirectSum /-- A version of `exterior_algebra.ι` that maps directly into the graded structure. This is primarily an auxiliary construction used to provide `exterior_algebra.graded_algebra`. -/ def GradedAlgebra.ι : M →ₗ[R] ⨁ i : ℕ, ↥((ι R : M →ₗ[_] _).range ^ i) := DirectSum.lof R ℕ (fun i => ↥((ι R : M →ₗ[_] _).range ^ i)) 1 ∘ₗ (ι R).codRestrict _ fun m => by simpa only [pow_one] using LinearMap.mem_range_self _ m #align exterior_algebra.graded_algebra.ι ExteriorAlgebra.GradedAlgebra.ι theorem GradedAlgebra.ι_apply (m : M) : GradedAlgebra.ι R M m = DirectSum.of (fun i => ↥((ι R : M →ₗ[_] _).range ^ i)) 1 ⟨ι R m, by simpa only [pow_one] using LinearMap.mem_range_self _ m⟩ := rfl #align exterior_algebra.graded_algebra.ι_apply ExteriorAlgebra.GradedAlgebra.ι_apply theorem GradedAlgebra.ι_sq_zero (m : M) : GradedAlgebra.ι R M m * GradedAlgebra.ι R M m = 0 := by rw [graded_algebra.ι_apply, DirectSum.of_mul_of] refine' dfinsupp.single_eq_zero.mpr (Subtype.ext <| ι_sq_zero _) #align exterior_algebra.graded_algebra.ι_sq_zero ExteriorAlgebra.GradedAlgebra.ι_sq_zero /-- `exterior_algebra.graded_algebra.ι` lifted to exterior algebra. This is primarily an auxiliary construction used to provide `exterior_algebra.graded_algebra`. -/ def GradedAlgebra.liftι : ExteriorAlgebra R M →ₐ[R] ⨁ i : ℕ, ↥((ι R).range ^ i : Submodule R (ExteriorAlgebra R M)) := lift R ⟨by apply graded_algebra.ι R M, GradedAlgebra.ι_sq_zero R M⟩ #align exterior_algebra.graded_algebra.lift_ι ExteriorAlgebra.GradedAlgebra.liftι variable (R M) theorem GradedAlgebra.liftι_eq (i : ℕ) (x : ((ι R : M →ₗ[R] ExteriorAlgebra R M).range ^ i : Submodule R (ExteriorAlgebra R M))) : GradedAlgebra.liftι R M x = DirectSum.of (fun i => ↥((ι R).range ^ i : Submodule R (ExteriorAlgebra R M))) i x := by cases' x with x hx dsimp only [Subtype.coe_mk, DirectSum.lof_eq_of] refine' Submodule.pow_induction_on_left' _ (fun r => _) (fun x y i hx hy ihx ihy => _) (fun m hm i x hx ih => _) hx · rw [AlgHom.commutes, DirectSum.algebraMap_apply] rfl · rw [AlgHom.map_add, ihx, ihy, ← map_add] rfl · obtain ⟨_, rfl⟩ := hm rw [AlgHom.map_mul, ih, graded_algebra.lift_ι, lift_ι_apply, graded_algebra.ι_apply R M, DirectSum.of_mul_of] exact DirectSum.of_eq_of_gradedMonoid_eq (Sigma.subtype_ext (add_comm _ _) rfl) #align exterior_algebra.graded_algebra.lift_ι_eq ExteriorAlgebra.GradedAlgebra.liftι_eq /-- The exterior algebra is graded by the powers of the submodule `(exterior_algebra.ι R).range`. -/ instance gradedAlgebra : GradedAlgebra ((· ^ ·) (ι R : M →ₗ[R] ExteriorAlgebra R M).range : ℕ → Submodule R _) := GradedAlgebra.ofAlgHom _ (-- while not necessary, the `by apply` makes this elaborate faster by apply graded_algebra.lift_ι R M) (-- the proof from here onward is identical to the `tensor_algebra` case by ext m dsimp only [LinearMap.comp_apply, AlgHom.toLinearMap_apply, AlgHom.comp_apply, AlgHom.id_apply, graded_algebra.lift_ι] rw [lift_ι_apply, graded_algebra.ι_apply R M, DirectSum.coeAlgHom_of, Subtype.coe_mk]) (by apply graded_algebra.lift_ι_eq R M) #align exterior_algebra.graded_algebra ExteriorAlgebra.gradedAlgebra end ExteriorAlgebra
[GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C f : Z ⟶ Y I : InjectiveResolution Y J : InjectiveResolution Z ⊢ HomologicalComplex.Hom.f J.ι 0 ≫ descFZero f I J ≫ HomologicalComplex.d I.cocomplex 0 1 = 0 [PROOFSTEP] simp [← Category.assoc, descFZero] [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C f : Z ⟶ Y I : InjectiveResolution Y J : InjectiveResolution Z ⊢ HomologicalComplex.d J.cocomplex 0 1 ≫ descFOne f I J = descFZero f I J ≫ HomologicalComplex.d I.cocomplex 0 1 [PROOFSTEP] simp [descFZero, descFOne] [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C I : InjectiveResolution Y J : InjectiveResolution Z n : ℕ g : HomologicalComplex.X J.cocomplex n ⟶ HomologicalComplex.X I.cocomplex n g' : HomologicalComplex.X J.cocomplex (n + 1) ⟶ HomologicalComplex.X I.cocomplex (n + 1) w : HomologicalComplex.d J.cocomplex n (n + 1) ≫ g' = g ≫ HomologicalComplex.d I.cocomplex n (n + 1) ⊢ HomologicalComplex.d J.cocomplex n (n + 1) ≫ g' ≫ HomologicalComplex.d I.cocomplex (n + 1) (n + 2) = 0 [PROOFSTEP] simp [← Category.assoc, w] [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C I : InjectiveResolution Y J : InjectiveResolution Z n : ℕ g : HomologicalComplex.X J.cocomplex n ⟶ HomologicalComplex.X I.cocomplex n g' : HomologicalComplex.X J.cocomplex (n + 1) ⟶ HomologicalComplex.X I.cocomplex (n + 1) w : HomologicalComplex.d J.cocomplex n (n + 1) ≫ g' = g ≫ HomologicalComplex.d I.cocomplex n (n + 1) ⊢ HomologicalComplex.d J.cocomplex (n + 1) (n + 2) ≫ Exact.desc (g' ≫ HomologicalComplex.d I.cocomplex (n + 1) (n + 2)) (HomologicalComplex.d J.cocomplex n (n + 1)) (HomologicalComplex.d J.cocomplex (n + 1) (n + 2)) (_ : Exact (HomologicalComplex.d J.cocomplex (n + 1) (n + 2)).op (HomologicalComplex.d J.cocomplex n (n + 1)).op) (_ : HomologicalComplex.d J.cocomplex n (n + 1) ≫ g' ≫ HomologicalComplex.d I.cocomplex (n + 1) (n + 2) = 0) = g' ≫ HomologicalComplex.d I.cocomplex (n + 1) (n + 2) [PROOFSTEP] simp [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C f : Z ⟶ Y I : InjectiveResolution Y J : InjectiveResolution Z ⊢ J.ι ≫ desc f I J = (CochainComplex.single₀ C).map f ≫ I.ι [PROOFSTEP] ext [GOAL] case h C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C f : Z ⟶ Y I : InjectiveResolution Y J : InjectiveResolution Z ⊢ HomologicalComplex.Hom.f (J.ι ≫ desc f I J) 0 = HomologicalComplex.Hom.f ((CochainComplex.single₀ C).map f ≫ I.ι) 0 [PROOFSTEP] simp [desc, descFOne, descFZero] [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C I : InjectiveResolution Y J : InjectiveResolution Z f : I.cocomplex ⟶ J.cocomplex comm : I.ι ≫ f = 0 ⊢ HomologicalComplex.d I.cocomplex 0 1 ≫ (HomologicalComplex.Hom.f f 1 - descHomotopyZeroZero f comm ≫ HomologicalComplex.d J.cocomplex 0 1) = 0 [PROOFSTEP] simp [descHomotopyZeroZero, ← Category.assoc] [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C I : InjectiveResolution Y J : InjectiveResolution Z f : I.cocomplex ⟶ J.cocomplex n : ℕ g : HomologicalComplex.X I.cocomplex (n + 1) ⟶ HomologicalComplex.X J.cocomplex n g' : HomologicalComplex.X I.cocomplex (n + 2) ⟶ HomologicalComplex.X J.cocomplex (n + 1) w : HomologicalComplex.Hom.f f (n + 1) = HomologicalComplex.d I.cocomplex (n + 1) (n + 2) ≫ g' + g ≫ HomologicalComplex.d J.cocomplex n (n + 1) ⊢ HomologicalComplex.d I.cocomplex (n + 1) (n + 2) ≫ (HomologicalComplex.Hom.f f (n + 2) - g' ≫ HomologicalComplex.d J.cocomplex (n + 1) (n + 2)) = 0 [PROOFSTEP] simp [Preadditive.comp_sub, ← Category.assoc, Preadditive.sub_comp, show I.cocomplex.d (n + 1) (n + 2) ≫ g' = f.f (n + 1) - g ≫ J.cocomplex.d n (n + 1) by rw [w] simp only [add_sub_cancel]] [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C I : InjectiveResolution Y J : InjectiveResolution Z f : I.cocomplex ⟶ J.cocomplex n : ℕ g : HomologicalComplex.X I.cocomplex (n + 1) ⟶ HomologicalComplex.X J.cocomplex n g' : HomologicalComplex.X I.cocomplex (n + 2) ⟶ HomologicalComplex.X J.cocomplex (n + 1) w : HomologicalComplex.Hom.f f (n + 1) = HomologicalComplex.d I.cocomplex (n + 1) (n + 2) ≫ g' + g ≫ HomologicalComplex.d J.cocomplex n (n + 1) ⊢ HomologicalComplex.d I.cocomplex (n + 1) (n + 2) ≫ g' = HomologicalComplex.Hom.f f (n + 1) - g ≫ HomologicalComplex.d J.cocomplex n (n + 1) [PROOFSTEP] rw [w] [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C I : InjectiveResolution Y J : InjectiveResolution Z f : I.cocomplex ⟶ J.cocomplex n : ℕ g : HomologicalComplex.X I.cocomplex (n + 1) ⟶ HomologicalComplex.X J.cocomplex n g' : HomologicalComplex.X I.cocomplex (n + 2) ⟶ HomologicalComplex.X J.cocomplex (n + 1) w : HomologicalComplex.Hom.f f (n + 1) = HomologicalComplex.d I.cocomplex (n + 1) (n + 2) ≫ g' + g ≫ HomologicalComplex.d J.cocomplex n (n + 1) ⊢ HomologicalComplex.d I.cocomplex (n + 1) (n + 2) ≫ g' = HomologicalComplex.d I.cocomplex (n + 1) (n + 2) ≫ g' + g ≫ HomologicalComplex.d J.cocomplex n (n + 1) - g ≫ HomologicalComplex.d J.cocomplex n (n + 1) [PROOFSTEP] simp only [add_sub_cancel] [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C I : InjectiveResolution Y J : InjectiveResolution Z f : I.cocomplex ⟶ J.cocomplex comm : I.ι ≫ f = 0 ⊢ HomologicalComplex.Hom.f f 0 = HomologicalComplex.d I.cocomplex 0 1 ≫ descHomotopyZeroZero f comm [PROOFSTEP] simp [descHomotopyZeroZero] [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C I : InjectiveResolution Y J : InjectiveResolution Z f : I.cocomplex ⟶ J.cocomplex comm : I.ι ≫ f = 0 ⊢ HomologicalComplex.Hom.f f 1 = descHomotopyZeroZero f comm ≫ HomologicalComplex.d J.cocomplex 0 1 + HomologicalComplex.d I.cocomplex 1 2 ≫ descHomotopyZeroOne f comm [PROOFSTEP] simp [descHomotopyZeroOne] [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C I : InjectiveResolution Y J : InjectiveResolution Z f : I.cocomplex ⟶ J.cocomplex comm : I.ι ≫ f = 0 n : ℕ x✝ : (f_1 : HomologicalComplex.X I.cocomplex (n + 1) ⟶ HomologicalComplex.X J.cocomplex n) ×' (f' : HomologicalComplex.X I.cocomplex (n + 2) ⟶ HomologicalComplex.X J.cocomplex (n + 1)) ×' HomologicalComplex.Hom.f f (n + 1) = f_1 ≫ HomologicalComplex.d J.cocomplex n (n + 1) + HomologicalComplex.d I.cocomplex (n + 1) (n + 2) ≫ f' g : HomologicalComplex.X I.cocomplex (n + 1) ⟶ HomologicalComplex.X J.cocomplex n g' : HomologicalComplex.X I.cocomplex (n + 2) ⟶ HomologicalComplex.X J.cocomplex (n + 1) w : HomologicalComplex.Hom.f f (n + 1) = g ≫ HomologicalComplex.d J.cocomplex n (n + 1) + HomologicalComplex.d I.cocomplex (n + 1) (n + 2) ≫ g' ⊢ HomologicalComplex.Hom.f f (n + 1) = HomologicalComplex.d I.cocomplex (n + 1) (n + 2) ≫ g' + g ≫ HomologicalComplex.d J.cocomplex n (n + 1) [PROOFSTEP] simp only [w, add_comm] [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C I : InjectiveResolution Y J : InjectiveResolution Z f : I.cocomplex ⟶ J.cocomplex comm : I.ι ≫ f = 0 n : ℕ x✝ : (f_1 : HomologicalComplex.X I.cocomplex (n + 1) ⟶ HomologicalComplex.X J.cocomplex n) ×' (f' : HomologicalComplex.X I.cocomplex (n + 2) ⟶ HomologicalComplex.X J.cocomplex (n + 1)) ×' HomologicalComplex.Hom.f f (n + 1) = f_1 ≫ HomologicalComplex.d J.cocomplex n (n + 1) + HomologicalComplex.d I.cocomplex (n + 1) (n + 2) ≫ f' g : HomologicalComplex.X I.cocomplex (n + 1) ⟶ HomologicalComplex.X J.cocomplex n g' : HomologicalComplex.X I.cocomplex (n + 2) ⟶ HomologicalComplex.X J.cocomplex (n + 1) w : HomologicalComplex.Hom.f f (n + 1) = g ≫ HomologicalComplex.d J.cocomplex n (n + 1) + HomologicalComplex.d I.cocomplex (n + 1) (n + 2) ≫ g' ⊢ HomologicalComplex.Hom.f f (n + 2) = { fst := g, snd := { fst := g', snd := w } }.snd.fst ≫ HomologicalComplex.d J.cocomplex (n + 1) (n + 2) + HomologicalComplex.d I.cocomplex (n + 2) (n + 3) ≫ descHomotopyZeroSucc f n g g' (_ : HomologicalComplex.Hom.f f (n + 1) = HomologicalComplex.d I.cocomplex (n + 1) (n + 2) ≫ g' + g ≫ HomologicalComplex.d J.cocomplex n (n + 1)) [PROOFSTEP] simp [descHomotopyZeroSucc, w] [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C Y Z : C f : Y ⟶ Z I : InjectiveResolution Y J : InjectiveResolution Z g h : I.cocomplex ⟶ J.cocomplex g_comm : I.ι ≫ g = (CochainComplex.single₀ C).map f ≫ J.ι h_comm : I.ι ≫ h = (CochainComplex.single₀ C).map f ≫ J.ι ⊢ I.ι ≫ (g - h) = 0 [PROOFSTEP] simp [g_comm, h_comm] [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C X : C I : InjectiveResolution X ⊢ Homotopy (desc (𝟙 X) I I) (𝟙 I.cocomplex) [PROOFSTEP] apply descHomotopy (𝟙 X) [GOAL] case g_comm C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C X : C I : InjectiveResolution X ⊢ I.ι ≫ desc (𝟙 X) I I = (CochainComplex.single₀ C).map (𝟙 X) ≫ I.ι [PROOFSTEP] simp [GOAL] case h_comm C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C X : C I : InjectiveResolution X ⊢ I.ι ≫ 𝟙 I.cocomplex = (CochainComplex.single₀ C).map (𝟙 X) ≫ I.ι [PROOFSTEP] simp [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C X Y Z : C f : X ⟶ Y g : Y ⟶ Z I : InjectiveResolution X J : InjectiveResolution Y K : InjectiveResolution Z ⊢ Homotopy (desc (f ≫ g) K I) (desc f J I ≫ desc g K J) [PROOFSTEP] apply descHomotopy (f ≫ g) [GOAL] case g_comm C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C X Y Z : C f : X ⟶ Y g : Y ⟶ Z I : InjectiveResolution X J : InjectiveResolution Y K : InjectiveResolution Z ⊢ I.ι ≫ desc (f ≫ g) K I = (CochainComplex.single₀ C).map (f ≫ g) ≫ K.ι [PROOFSTEP] simp [GOAL] case h_comm C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C X Y Z : C f : X ⟶ Y g : Y ⟶ Z I : InjectiveResolution X J : InjectiveResolution Y K : InjectiveResolution Z ⊢ I.ι ≫ desc f J I ≫ desc g K J = (CochainComplex.single₀ C).map (f ≫ g) ≫ K.ι [PROOFSTEP] simp [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C X : C I J : InjectiveResolution X ⊢ Homotopy (desc (𝟙 X ≫ 𝟙 X) I I) (𝟙 I.cocomplex) [PROOFSTEP] simpa [Category.id_comp] using descIdHomotopy _ _ [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C X : C I J : InjectiveResolution X ⊢ Homotopy (desc (𝟙 X ≫ 𝟙 X) J J) (𝟙 J.cocomplex) [PROOFSTEP] simpa [Category.id_comp] using descIdHomotopy _ _ [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C X : C I J : InjectiveResolution X ⊢ I.ι ≫ (homotopyEquiv I J).hom = J.ι [PROOFSTEP] simp [homotopyEquiv] [GOAL] C : Type u inst✝¹ : Category.{v, u} C inst✝ : Abelian C X : C I J : InjectiveResolution X ⊢ J.ι ≫ (homotopyEquiv I J).inv = I.ι [PROOFSTEP] simp [homotopyEquiv] [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : HasInjectiveResolutions C X : C ⊢ { obj := fun X => (HomotopyCategory.quotient C (ComplexShape.up ℕ)).obj (injectiveResolution X), map := fun {X Y} f => (HomotopyCategory.quotient C (ComplexShape.up ℕ)).map (injectiveResolution.desc f) }.map (𝟙 X) = 𝟙 ({ obj := fun X => (HomotopyCategory.quotient C (ComplexShape.up ℕ)).obj (injectiveResolution X), map := fun {X Y} f => (HomotopyCategory.quotient C (ComplexShape.up ℕ)).map (injectiveResolution.desc f) }.obj X) [PROOFSTEP] rw [← (HomotopyCategory.quotient _ _).map_id] [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : HasInjectiveResolutions C X : C ⊢ { obj := fun X => (HomotopyCategory.quotient C (ComplexShape.up ℕ)).obj (injectiveResolution X), map := fun {X Y} f => (HomotopyCategory.quotient C (ComplexShape.up ℕ)).map (injectiveResolution.desc f) }.map (𝟙 X) = (HomotopyCategory.quotient C (ComplexShape.up ℕ)).map (𝟙 (injectiveResolution X)) [PROOFSTEP] apply HomotopyCategory.eq_of_homotopy [GOAL] case h C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : HasInjectiveResolutions C X : C ⊢ Homotopy (injectiveResolution.desc (𝟙 X)) (𝟙 (injectiveResolution X)) [PROOFSTEP] apply InjectiveResolution.descIdHomotopy [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : HasInjectiveResolutions C X✝ Y✝ Z✝ : C f : X✝ ⟶ Y✝ g : Y✝ ⟶ Z✝ ⊢ { obj := fun X => (HomotopyCategory.quotient C (ComplexShape.up ℕ)).obj (injectiveResolution X), map := fun {X Y} f => (HomotopyCategory.quotient C (ComplexShape.up ℕ)).map (injectiveResolution.desc f) }.map (f ≫ g) = { obj := fun X => (HomotopyCategory.quotient C (ComplexShape.up ℕ)).obj (injectiveResolution X), map := fun {X Y} f => (HomotopyCategory.quotient C (ComplexShape.up ℕ)).map (injectiveResolution.desc f) }.map f ≫ { obj := fun X => (HomotopyCategory.quotient C (ComplexShape.up ℕ)).obj (injectiveResolution X), map := fun {X Y} f => (HomotopyCategory.quotient C (ComplexShape.up ℕ)).map (injectiveResolution.desc f) }.map g [PROOFSTEP] rw [← (HomotopyCategory.quotient _ _).map_comp] [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : HasInjectiveResolutions C X✝ Y✝ Z✝ : C f : X✝ ⟶ Y✝ g : Y✝ ⟶ Z✝ ⊢ { obj := fun X => (HomotopyCategory.quotient C (ComplexShape.up ℕ)).obj (injectiveResolution X), map := fun {X Y} f => (HomotopyCategory.quotient C (ComplexShape.up ℕ)).map (injectiveResolution.desc f) }.map (f ≫ g) = (HomotopyCategory.quotient C (ComplexShape.up ℕ)).map (injectiveResolution.desc f ≫ injectiveResolution.desc g) [PROOFSTEP] apply HomotopyCategory.eq_of_homotopy [GOAL] case h C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : HasInjectiveResolutions C X✝ Y✝ Z✝ : C f : X✝ ⟶ Y✝ g : Y✝ ⟶ Z✝ ⊢ Homotopy (injectiveResolution.desc (f ≫ g)) (injectiveResolution.desc f ≫ injectiveResolution.desc g) [PROOFSTEP] apply InjectiveResolution.descCompHomotopy [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C X Y : C f : X ⟶ Y ⊢ f ≫ d f = 0 [PROOFSTEP] simp [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C X Y : C f : X ⟶ Y ⊢ (kernel.ι (d f) ≫ cokernel.π f) ≫ ι (cokernel f) = 0 [PROOFSTEP] rw [Category.assoc, kernel.condition] [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C ⊢ Injective.ι Z ≫ HomologicalComplex.d (ofCocomplex Z) 0 1 = HomologicalComplex.d ((CochainComplex.single₀ C).obj Z) 0 1 ≫ 0 [PROOFSTEP] simp only [ofCocomplex_d, eq_self_iff_true, eqToHom_refl, Category.comp_id, dite_eq_ite, if_true, comp_zero] [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C ⊢ Injective.ι Z ≫ (CochainComplex.mkAux (under Z) (syzygies (Injective.ι Z)) (syzygies (d (Injective.ι Z))) (d (Injective.ι Z)) (d (d (Injective.ι Z))) (_ : { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.snd.snd ≫ { fst := syzygies { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd, snd := { fst := d { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd, snd := (_ : { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd ≫ d { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd = 0) } }.snd.fst = 0) (fun t => { fst := syzygies t.snd.snd.snd.snd.fst, snd := { fst := d t.snd.snd.snd.snd.fst, snd := (_ : t.snd.snd.snd.snd.fst ≫ d t.snd.snd.snd.snd.fst = 0) } }) 0).d₀ = 0 [PROOFSTEP] exact (exact_f_d (Injective.ι Z)).w [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C n : ℕ ⊢ Exact (HomologicalComplex.d (ofCocomplex Z) 0 (0 + 1)) (HomologicalComplex.d (ofCocomplex Z) (0 + 1) (0 + 2)) [PROOFSTEP] simp [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C n : ℕ ⊢ Exact (CochainComplex.mkAux (under Z) (syzygies (Injective.ι Z)) (syzygies (d (Injective.ι Z))) (d (Injective.ι Z)) (d (d (Injective.ι Z))) (_ : { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.snd.snd ≫ { fst := syzygies { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd, snd := { fst := d { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd, snd := (_ : { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd ≫ d { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd = 0) } }.snd.fst = 0) (fun t => { fst := syzygies t.snd.snd.snd.snd.fst, snd := { fst := d t.snd.snd.snd.snd.fst, snd := (_ : t.snd.snd.snd.snd.fst ≫ d t.snd.snd.snd.snd.fst = 0) } }) 0).d₀ (CochainComplex.mkAux (under Z) (syzygies (Injective.ι Z)) (syzygies (d (Injective.ι Z))) (d (Injective.ι Z)) (d (d (Injective.ι Z))) (_ : { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.snd.snd ≫ { fst := syzygies { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd, snd := { fst := d { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd, snd := (_ : { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd ≫ d { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd = 0) } }.snd.fst = 0) (fun t => { fst := syzygies t.snd.snd.snd.snd.fst, snd := { fst := d t.snd.snd.snd.snd.fst, snd := (_ : t.snd.snd.snd.snd.fst ≫ d t.snd.snd.snd.snd.fst = 0) } }) (0 + 1)).d₀ [PROOFSTEP] apply exact_f_d [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C n m : ℕ ⊢ Exact (HomologicalComplex.d (ofCocomplex Z) (m + 1) (m + 1 + 1)) (HomologicalComplex.d (ofCocomplex Z) (m + 1 + 1) (m + 1 + 2)) [PROOFSTEP] simp only [ofCocomplex_X, ComplexShape.up_Rel, not_true, ofCocomplex_d, eqToHom_refl, Category.comp_id, dite_eq_ite, ite_true] [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C n m : ℕ ⊢ Exact (CochainComplex.mkAux (under Z) (syzygies (Injective.ι Z)) (syzygies (d (Injective.ι Z))) (d (Injective.ι Z)) (d (d (Injective.ι Z))) (_ : { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.snd.snd ≫ { fst := syzygies { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd, snd := { fst := d { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd, snd := (_ : { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd ≫ d { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd = 0) } }.snd.fst = 0) (fun t => { fst := syzygies t.snd.snd.snd.snd.fst, snd := { fst := d t.snd.snd.snd.snd.fst, snd := (_ : t.snd.snd.snd.snd.fst ≫ d t.snd.snd.snd.snd.fst = 0) } }) (m + 1)).d₀ (if m + 1 + 1 + 1 = m + 1 + 2 then (CochainComplex.mkAux (under Z) (syzygies (Injective.ι Z)) (syzygies (d (Injective.ι Z))) (d (Injective.ι Z)) (d (d (Injective.ι Z))) (_ : { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.snd.snd ≫ { fst := syzygies { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd, snd := { fst := d { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd, snd := (_ : { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd ≫ d { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd = 0) } }.snd.fst = 0) (fun t => { fst := syzygies t.snd.snd.snd.snd.fst, snd := { fst := d t.snd.snd.snd.snd.fst, snd := (_ : t.snd.snd.snd.snd.fst ≫ d t.snd.snd.snd.snd.fst = 0) } }) (m + 1 + 1)).d₀ else 0) [PROOFSTEP] erw [if_pos (c := m + 1 + 1 + 1 = m + 2 + 1) rfl] [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C n m : ℕ ⊢ Exact (CochainComplex.mkAux (under Z) (syzygies (Injective.ι Z)) (syzygies (d (Injective.ι Z))) (d (Injective.ι Z)) (d (d (Injective.ι Z))) (_ : { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.snd.snd ≫ { fst := syzygies { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd, snd := { fst := d { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd, snd := (_ : { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd ≫ d { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd = 0) } }.snd.fst = 0) (fun t => { fst := syzygies t.snd.snd.snd.snd.fst, snd := { fst := d t.snd.snd.snd.snd.fst, snd := (_ : t.snd.snd.snd.snd.fst ≫ d t.snd.snd.snd.snd.fst = 0) } }) (m + 1)).d₀ (CochainComplex.mkAux (under Z) (syzygies (Injective.ι Z)) (syzygies (d (Injective.ι Z))) (d (Injective.ι Z)) (d (d (Injective.ι Z))) (_ : { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.snd.snd ≫ { fst := syzygies { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd, snd := { fst := d { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd, snd := (_ : { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd ≫ d { fst := under Z, snd := { fst := syzygies (Injective.ι Z), snd := d (Injective.ι Z) } }.2.snd = 0) } }.snd.fst = 0) (fun t => { fst := syzygies t.snd.snd.snd.snd.fst, snd := { fst := d t.snd.snd.snd.snd.fst, snd := (_ : t.snd.snd.snd.snd.fst ≫ d t.snd.snd.snd.snd.fst = 0) } }) (m + 1 + 1)).d₀ [PROOFSTEP] apply exact_f_d [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C n : ℕ x✝ : (f : HomologicalComplex.X ((CochainComplex.single₀ C).obj Z) n ⟶ HomologicalComplex.X (ofCocomplex Z) n) ×' (f' : HomologicalComplex.X ((CochainComplex.single₀ C).obj Z) (n + 1) ⟶ HomologicalComplex.X (ofCocomplex Z) (n + 1)) ×' f ≫ HomologicalComplex.d (ofCocomplex Z) n (n + 1) = HomologicalComplex.d ((CochainComplex.single₀ C).obj Z) n (n + 1) ≫ f' ⊢ (f'' : HomologicalComplex.X ((CochainComplex.single₀ C).obj Z) (n + 2) ⟶ HomologicalComplex.X (ofCocomplex Z) (n + 2)) ×' x✝.snd.fst ≫ HomologicalComplex.d (ofCocomplex Z) (n + 1) (n + 2) = HomologicalComplex.d ((CochainComplex.single₀ C).obj Z) (n + 1) (n + 2) ≫ f'' [PROOFSTEP] use 0 [GOAL] case snd C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C n : ℕ x✝ : (f : HomologicalComplex.X ((CochainComplex.single₀ C).obj Z) n ⟶ HomologicalComplex.X (ofCocomplex Z) n) ×' (f' : HomologicalComplex.X ((CochainComplex.single₀ C).obj Z) (n + 1) ⟶ HomologicalComplex.X (ofCocomplex Z) (n + 1)) ×' f ≫ HomologicalComplex.d (ofCocomplex Z) n (n + 1) = HomologicalComplex.d ((CochainComplex.single₀ C).obj Z) n (n + 1) ≫ f' ⊢ x✝.snd.fst ≫ HomologicalComplex.d (ofCocomplex Z) (n + 1) (n + 2) = HomologicalComplex.d ((CochainComplex.single₀ C).obj Z) (n + 1) (n + 2) ≫ 0 [PROOFSTEP] apply HasZeroObject.from_zero_ext [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C ⊢ ∀ (n : ℕ), Injective (HomologicalComplex.X (ofCocomplex Z) n) [PROOFSTEP] rintro (_ | _ | _ | n) [GOAL] case zero C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C ⊢ Injective (HomologicalComplex.X (ofCocomplex Z) Nat.zero) [PROOFSTEP] apply Injective.injective_under [GOAL] case succ.zero C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C ⊢ Injective (HomologicalComplex.X (ofCocomplex Z) (Nat.succ Nat.zero)) [PROOFSTEP] apply Injective.injective_under [GOAL] case succ.succ.zero C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C ⊢ Injective (HomologicalComplex.X (ofCocomplex Z) (Nat.succ (Nat.succ Nat.zero))) [PROOFSTEP] apply Injective.injective_under [GOAL] case succ.succ.succ C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C n : ℕ ⊢ Injective (HomologicalComplex.X (ofCocomplex Z) (Nat.succ (Nat.succ (Nat.succ n)))) [PROOFSTEP] apply Injective.injective_under [GOAL] C : Type u inst✝² : Category.{v, u} C inst✝¹ : Abelian C inst✝ : EnoughInjectives C Z : C ⊢ Exact (HomologicalComplex.Hom.f (CochainComplex.mkHom ((CochainComplex.single₀ C).obj Z) (ofCocomplex Z) (Injective.ι Z) 0 (_ : Injective.ι Z ≫ HomologicalComplex.d (ofCocomplex Z) 0 1 = HomologicalComplex.d ((CochainComplex.single₀ C).obj Z) 0 1 ≫ 0) fun n x => { fst := 0, snd := (_ : x.snd.fst ≫ HomologicalComplex.d (ofCocomplex Z) (n + 1) (n + 2) = HomologicalComplex.d ((CochainComplex.single₀ C).obj Z) (n + 1) (n + 2) ≫ 0) }) 0) (HomologicalComplex.d (ofCocomplex Z) 0 1) [PROOFSTEP] simpa using exact_f_d (Injective.ι Z)
Even though I spend a lot of time in http://cse.ucdavis.edu/users/sbeards Davis I spend most of my time in Sacramento.
""" $(TYPEDEF) Stores information on requested and measured [`Configuration`](@ref)s. $(TYPEDFIELDS) """ const Measurement = NamedTuple{ ( :measured, :cost, :technique, :date_requested, :date_measured ), Tuple{ Bool, Union{Float64, Missing}, Union{String, Missing}, Union{DateTime, Missing}, Union{DateTime, Missing} } } Measurement() = ( measured = false, cost = missing::Union{Float64, Missing}, technique = missing::Union{String, Missing}, date_requested = now()::Union{DateTime, Missing}, date_measured = missing::Union{DateTime, Missing} ) """ $(TYPEDSIGNATURES) Pushes a new [`Configuration`](@ref) to a `DataFrame`, appending an empty [`Measurement`](@ref). """ function push!(target_table::DataFrame, c::Configuration) push!( target_table, merge( Measurement(), NamedTuple{keys(c)}( (p.current for p in c.parameters) ) ) ) end """ $(TYPEDSIGNATURES) Creates an empty `DataFrame` with column types from a given [`Configuration`](@ref) and from an empty [`Measurement`](@ref). """ function configuration_table(c::Configuration) push!( DataFrame( NamedTuple{ (keys(c)..., fieldnames(Measurement)...) }( Array{T, 1}() for T in ((typeof(p.current) for p in values(c))..., fieldtypes(Measurement)...) ) ), c ) end
# module for representing agent # decide control order to robot # get action based on policy # by dynamic programming # using probabilistic flow control include(joinpath(split(@__FILE__, "src")[1], "src/decision_making/markov_decision_process/dynamic_programming.jl")) mutable struct PfcAgent speed yaw_rate delta_time estimator prev_spd prev_yr puddle_coef puddle_depth total_reward in_goal final_value goal pose_min pose_max widths index_nums policy_data dp evaluations current_value stop_timer magnitude # init function PfcAgent(;delta_time::Float64=0.1, estimator=nothing, goal=nothing, puddles=nothing, sampling_num=10, puddle_coef=100, widths=[0.2, 0.2, pi/18], lower_left=[-4.0, -4.0], upper_right=[4.0, 4.0], magnitude=2) self = new() self.speed = 0.0 self.yaw_rate = 0.0 self.delta_time = delta_time self.estimator = estimator self.prev_spd = 0.0 self.prev_yr = 0.0 self.puddle_coef = puddle_coef self.puddle_depth = 0.0 self.total_reward = 0.0 self.in_goal = false self.final_value = 0.0 self.goal = goal self.pose_min = [lower_left[1], lower_left[2], 0.0] self.pose_max = [upper_right[1], upper_right[2], 2*pi] self.widths = widths self.index_nums = round.(Int64, (self.pose_max - self.pose_min)./self.widths) self.policy_data = init_policy(self) self.dp = DynamicProgramming(widths, goal, puddles, delta_time, sampling_num) self.dp.value_function = init_value(self) self.evaluations = [0.0, 0.0, 0.0] # to store q-mdp value self.current_value = 0.0 # to store average of current state value self.stop_timer = 0.0 self.magnitude = magnitude return self end end function init_value(self::PfcAgent) tmp = zeros(Tuple(self.dp.index_nums)) txt_path = "src/decision_making/partially_observable_mdp/value.txt" open(joinpath(split(@__FILE__, "src")[1], txt_path), "r") do fp for line in eachline(fp) d = split(line) # [i_x, i_y, i_theta, value] tmp[parse(Int64, d[1])+1, parse(Int64, d[2])+1, parse(Int64, d[3])+1] = parse(Float64, d[4]) end end return tmp end function init_policy(self::PfcAgent) tmp = zeros(Tuple([self.index_nums[1], self.index_nums[2], self.index_nums[3], 2])) txt_path = "src/decision_making/partially_observable_mdp/policy.txt" open(joinpath(split(@__FILE__, "src")[1], txt_path), "r") do fp for line in eachline(fp) d = split(line) # [i_x, i_y, i_theta, speed, yaw_rate] tmp[parse(Int64, d[1])+1, parse(Int64, d[2])+1, parse(Int64, d[3])+1, :] .= [parse(Float64, d[4]), parse(Float64, d[5])] end end return tmp end function reward_per_sec(self::PfcAgent) return (-1.0 - self.puddle_depth*self.puddle_coef) end function to_index(self::PfcAgent, pose) index = Int64.(floor.((pose - self.pose_min)./self.widths)) # normalize direction index index[3] = (index[3] + self.index_nums[3]*1000)%self.index_nums[3] for i in 1:2 if index[i] < 0 index[i] = 0 elseif index[i] >= self.index_nums[i] index[i] = self.index_nums[i] - 1 end end return index end function evaluation(self::PfcAgent, action, indexes) v = self.dp.value_function vs = [] for i in indexes if abs(self.dp.value_function[i[1]+1, i[2]+1, i[3]+1]) > 0.0 push!(vs, abs(self.dp.value_function[i[1]+1, i[2]+1, i[3]+1])) else push!(vs, 1e-10) end end qs = [action_value(self.dp, action, i, out_penalty=false) for i in indexes] ps = self.estimator.particles return sum([(p.weight/(v^self.magnitude))*q for (v, q, p) in zip(vs, qs, ps)]) end function policy(self::PfcAgent, pose) # decrease weight of particle reached at goal for p in self.estimator.particles if inside(self.goal, p.pose) == true p.weight *= 1e-10 end end resampling(self.estimator) indexes = [to_index(self, p.pose) for p in self.estimator.particles] self.current_value = sum([self.dp.value_function[i[1]+1, i[2]+1, i[3]+1] for i in indexes])/length(indexes) self.evaluations = [evaluation(self, a, indexes) for a in self.dp.actions] action = self.dp.actions[argmax(self.evaluations)] return action[1], action[2] end function draw_decision!(self::PfcAgent, observation) # reached goal if self.in_goal == true return 0.0, 0.0 # stop end if self.estimator !== nothing motion_update(self.estimator, self.prev_spd, self.prev_yr, self.delta_time) observation_update(self.estimator, observation) self.total_reward += self.delta_time * reward_per_sec(self) spd_tmp, yr_tmp = policy(self, self.estimator.estimated_pose) if spd_tmp == 0.0 self.stop_timer += self.delta_time else self.stop_timer = 0.0 end if self.stop_timer > 1.0 self.speed, self.yaw_rate = 1.0, 0.0 else self.speed, self.yaw_rate = spd_tmp, yr_tmp end self.prev_spd, self.prev_yr = self.speed, self.yaw_rate draw!(self.estimator) annotate!(-4.5, -4.6, text("$(round(self.current_value, digits=3)) => $(round.(self.evaluations, digits=3))", :left, 8)) end return self.speed, self.yaw_rate end
sparkR.session(appName = "MyApp", sparkConfig = list(spark.some.config.option = "some-value"))
REBOL [ Title: "Red run time error test script" Author: "Peter W A Wood" File: %run-time-error-test.r Rights: "Copyright (C) 2011-2012 Peter W A Wood. All rights reserved." License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt" ] ~~~start-file~~~ "Red run time errors" --test-- "rte-1" --compile-and-run-this/error {Red[] i: 1 j: 0 k: i / j} --assert-red-printed? "*** Runtime Error 13: integer divide by zero" --test-- "rte-2" --compile-and-run-this/error {Red[] absolute -2147483648} --assert-red-printed? "*** Runtime Error 99: integer overflow" ~~~end-file~~~
# Constraint Satisfaction Problems Lab ## Introduction Constraint Satisfaction is a technique for solving problems by expressing limits on the values of each variable in the solution with mathematical constraints. We've used constraints before -- constraints in the Sudoku project are enforced implicitly by filtering the legal values for each box, and the planning project represents constraints as arcs connecting nodes in the planning graph -- but in this lab exercise we will use a symbolic math library to explicitly construct binary constraints and then use Backtracking to solve the N-queens problem (which is a generalization [8-queens problem](https://en.wikipedia.org/wiki/Eight_queens_puzzle)). Using symbolic constraints should make it easier to visualize and reason about the constraints (especially for debugging), but comes with a performance penalty. Briefly, the 8-queens problem asks you to place 8 queens on a standard 8x8 chessboard such that none of the queens are in "check" (i.e., no two queens occupy the same row, column, or diagonal). The N-queens problem generalizes the puzzle to to any size square board. ## I. Lab Overview Students should read through the code and the wikipedia page (or other resources) to understand the N-queens problem, then: 0. Complete the warmup exercises in the [Sympy_Intro notebook](Sympy_Intro.ipynb) to become familiar with they sympy library and symbolic representation for constraints 0. Implement the [NQueensCSP class](#II.-Representing-the-N-Queens-Problem) to develop an efficient encoding of the N-queens problem and explicitly generate the constraints bounding the solution 0. Write the [search functions](#III.-Backtracking-Search) for recursive backtracking, and use them to solve the N-queens problem 0. (Optional) Conduct [additional experiments](#IV.-Experiments-%28Optional%29) with CSPs and various modifications to the search order (minimum remaining values, least constraining value, etc.) ```python import matplotlib as mpl import matplotlib.pyplot as plt from util import constraint, displayBoard from sympy import * from IPython.display import display init_printing() %matplotlib inline ``` ## II. Representing the N-Queens Problem There are many acceptable ways to represent the N-queens problem, but one convenient way is to recognize that one of the constraints (either the row or column constraint) can be enforced implicitly by the encoding. If we represent a solution as an array with N elements, then each position in the array can represent a column of the board, and the value at each position can represent which row the queen is placed on. In this encoding, we only need a constraint to make sure that no two queens occupy the same row, and one to make sure that no two queens occupy the same diagonal. ### Define Symbolic Expressions for the Problem Constraints Before implementing the board class, we need to construct the symbolic constraints that will be used in the CSP. Declare any symbolic terms required, and then declare two generic constraint generators: - `diffRow` - generate constraints that return True if the two arguments do not match - `diffDiag` - generate constraints that return True if two arguments are not on the same diagonal (Hint: you can easily test whether queens in two columns are on the same diagonal by testing if the difference in the number of rows and the number of columns match) Both generators should produce binary constraints (i.e., each should have two free symbols) once they're bound to specific variables in the CSP. For example, Eq((a + b), (b + c)) is not a binary constraint, but Eq((a + b), (b + c)).subs(b, 1) _is_ a binary constraint because one of the terms has been bound to a constant, so there are only two free variables remaining. ```python # Declare any required symbolic variables R1, R2, Rdiff = symbols("R1 R2 Rdiff") "TODO: declare symbolic variables for the constraint generators" # Define diffRow and diffDiag constraints "TODO: create the diffRow and diffDiag constraint generators" diffRow = constraint("Row", Ne(R1, R2)) diffDiag = constraint("Diag", Ne(Abs(R1-R2),Rdiff)) ``` ```python # Test diffRow and diffDiag _x = symbols("x:3") # generate a diffRow instance for testing "TODO: use your diffRow constraint to generate a diffRow constraint for _x[0] and _x[1]" diffRow_test = diffRow.subs({R1: _x[0], R2: _x[1]}) assert(len(diffRow_test.free_symbols) == 2) assert(diffRow_test.subs({_x[0]: 0, _x[1]: 1}) == True) assert(diffRow_test.subs({_x[0]: 0, _x[1]: 0}) == False) assert(diffRow_test.subs({_x[0]: 0}) != False) # partial assignment is not false print("Passed all diffRow tests.") # generate a diffDiag instance for testing "TODO: use your diffDiag constraint to generate a diffDiag constraint for _x[0] and _x[2]" diffDiag_test = diffDiag.subs({R1: _x[0], R2: _x[2], Rdiff: 2}) assert(len(diffDiag_test.free_symbols) == 2) assert(diffDiag_test.subs({_x[0]: 0, _x[2]: 2}) == False) assert(diffDiag_test.subs({_x[0]: 0, _x[2]: 0}) == True) assert(diffDiag_test.subs({_x[0]: 0}) != False) # partial assignment is not false print("Passed all diffDiag tests.") ``` Passed all diffRow tests. Passed all diffDiag tests. ### The N-Queens CSP Class Implement the CSP class as described above, with constraints to make sure each queen is on a different row and different diagonal than every other queen, and a variable for each column defining the row that containing a queen in that column. ```python class NQueensCSP: """CSP representation of the N-queens problem Parameters ---------- N : Integer The side length of a square chess board to use for the problem, and the number of queens that must be placed on the board """ def __init__(self, N): "TODO: declare symbolic variables in self._vars in the CSP constructor" _rows = symbols("R:" + str(N)) _domain = set(range(N)) self.size = N self._vars = _rows self.domains = {v: _domain for v in _vars} self._constraints = {x: set() for x in _vars} # add constraints - for each pair of variables xi and xj, create # a diffRow(xi, xj) and a diffDiag(xi, xj) instance, and add them # to the self._constraints dictionary keyed to both xi and xj; # (i.e., add them to both self._constraints[xi] and self._constraints[xj]) "TODO: add constraints in self._constraints in the CSP constructor" for i in range(N): for j in range(N): xi = self._vars[i] xj = self._vars[j] dR = diffRow.subs({R1:_vars[i], R2: _vars[j]}) dD = diffDiag.subs({R1:_vars[i], R2: _vars[j], Rdiff: abs(i-j)}) self._constraints[xi].add(dR) self._constraints[xj].add(dR) self._constraints[xi].add(dD) self._constraints[xj].add(dD) @property def constraints(self): """Read-only list of constraints -- cannot be used for evaluation """ constraints = set() for _cons in self._constraints.values(): constraints |= _cons return list(constraints) def is_complete(self, assignment): """An assignment is complete if it is consistent, and all constraints are satisfied. Hint: Backtracking search checks consistency of each assignment, so checking for completeness can be done very efficiently Parameters ---------- assignment : dict(sympy.Symbol: Integer) An assignment of values to variables that have previously been checked for consistency with the CSP constraints """ if len(assignment) == self.size: return True else: return False def is_consistent(self, var, value, assignment): """Check consistency of a proposed variable assignment self._constraints[x] returns a set of constraints that involve variable `x`. An assignment is consistent unless the assignment it causes a constraint to return False (partial assignments are always consistent). Parameters ---------- var : sympy.Symbol One of the symbolic variables in the CSP value : Numeric A valid value (i.e., in the domain of) the variable `var` for assignment assignment : dict(sympy.Symbol: Integer) A dictionary mapping CSP variables to row assignment of each queen """ raise NotImplementedError("TODO: implement the is_consistent() method of the CSP") def inference(self, var, value): """Perform logical inference based on proposed variable assignment Returns an empty dictionary by default; function can be overridden to check arc-, path-, or k-consistency; returning None signals "failure". Parameters ---------- var : sympy.Symbol One of the symbolic variables in the CSP value : Integer A valid value (i.e., in the domain of) the variable `var` for assignment Returns ------- dict(sympy.Symbol: Integer) or None A partial set of values mapped to variables in the CSP based on inferred constraints from previous mappings, or None to indicate failure """ # TODO (Optional): Implement this function based on AIMA discussion return {} def show(self, assignment): """Display a chessboard with queens drawn in the locations specified by an assignment Parameters ---------- assignment : dict(sympy.Symbol: Integer) A dictionary mapping CSP variables to row assignment of each queen """ locations = [(i, assignment[j]) for i, j in enumerate(self.variables) if assignment.get(j, None) is not None] displayBoard(locations, self.size) ``` ## III. Backtracking Search Implement the [backtracking search](https://github.com/aimacode/aima-pseudocode/blob/master/md/Backtracking-Search.md) algorithm (required) and helper functions (optional) from the AIMA text. ```python def select(csp, assignment): """Choose an unassigned variable in a constraint satisfaction problem """ # TODO (Optional): Implement a more sophisticated selection routine from AIMA for var in csp.variables: if var not in assignment: return var return None def order_values(var, assignment, csp): """Select the order of the values in the domain of a variable for checking during search; the default is lexicographically. """ # TODO (Optional): Implement a more sophisticated search ordering routine from AIMA return csp.domains[var] def backtracking_search(csp): """Helper function used to initiate backtracking search """ return backtrack({}, csp) def backtrack(assignment, csp): """Perform backtracking search for a valid assignment to a CSP Parameters ---------- assignment : dict(sympy.Symbol: Integer) An partial set of values mapped to variables in the CSP csp : CSP A problem encoded as a CSP. Interface should include csp.variables, csp.domains, csp.inference(), csp.is_consistent(), and csp.is_complete(). Returns ------- dict(sympy.Symbol: Integer) or None A partial set of values mapped to variables in the CSP, or None to indicate failure """ raise NotImplementedError("TODO: complete the backtrack function") ``` ### Solve the CSP With backtracking implemented, now you can use it to solve instances of the problem. We've started with the classical 8-queen version, but you can try other sizes as well. Boards larger than 12x12 may take some time to solve because sympy is slow in the way its being used here, and because the selection and value ordering methods haven't been implemented. See if you can implement any of the techniques in the AIMA text to speed up the solver! ```python num_queens = 8 csp = NQueensCSP(num_queens) var = csp.variables[0] print("CSP problems have variables, each variable has a domain, and the problem has a list of constraints.") print("Showing the variables for the N-Queens CSP:") display(csp.variables) print("Showing domain for {}:".format(var)) display(csp.domains[var]) print("And showing the constraints for {}:".format(var)) display(csp._constraints[var]) print("Solving N-Queens CSP...") assn = backtracking_search(csp) if assn is not None: csp.show(assn) print("Solution found:\n{!s}".format(assn)) else: print("No solution found.") ``` ## IV. Experiments (Optional) For each optional experiment, discuss the answers to these questions on the forum: Do you expect this change to be more efficient, less efficient, or the same? Why or why not? Is your prediction correct? What metric did you compare (e.g., time, space, nodes visited, etc.)? - Implement a _bad_ N-queens solver: generate & test candidate solutions one at a time until a valid solution is found. For example, represent the board as an array with $N^2$ elements, and let each element be True if there is a queen in that box, and False if it is empty. Use an $N^2$-bit counter to generate solutions, then write a function to check if each solution is valid. Notice that this solution doesn't require any of the techniques we've applied to other problems -- there is no DFS or backtracking, nor constraint propagation, or even explicitly defined variables. - Use more complex constraints -- i.e., generalize the binary constraint RowDiff to an N-ary constraint AllRowsDiff, etc., -- and solve the problem again. - Rewrite the CSP class to use forward checking to restrict the domain of each variable as new values are assigned. - The sympy library isn't very fast, so this version of the CSP doesn't work well on boards bigger than about 12x12. Write a new representation of the problem class that uses constraint functions (like the Sudoku project) to implicitly track constraint satisfaction through the restricted domain of each variable. How much larger can you solve? - Create your own CSP!
require(httr) headers = c( `Content-Type` = 'application/x-www-form-urlencoded' ) data = list( `msg1` = 'wow', `msg2` = 'such', `msg3` = '@rawmsg' ) res <- httr::POST(url = 'http://example.com/post', httr::add_headers(.headers=headers), body = data)
From Coq Require Import ssreflect ssrfun ssrbool. Unset Strict Implicit. Unset Printing Implicit Defensive. Require Import Coq.Program.Equality. Require Import Coq.Init.Datatypes. Require Export Bool. Inductive TermType := | Value | Type_ | rule_jugd . Inductive Symbol (x : TermType) := | initial : Symbol x | next : Symbol x -> Symbol x. Inductive TypeDef := | SimplyT : Symbol Type_ -> TypeDef | Arrow : TypeDef -> TypeDef -> TypeDef | Udnf : TypeDef. Inductive Expression := |Var : Symbol Value -> TypeDef -> Expression |Abs : Expression -> Expression -> TypeDef -> Expression |App : Expression -> Expression -> TypeDef -> Expression. Definition type_of_T (e' : Expression) := match e' return TypeDef with |Var _ t => t |Abs _ _ t => t |App _ _ t => t end. Inductive Enviroment := |empty : Enviroment |bind : forall T {H : T <> Udnf}, Expression -> Enviroment -> Enviroment. Notation "T*" := Enviroment. Notation "{}" := empty. Inductive Judgment env (P : Enviroment -> Prop) := |Assume : P env -> Judgment env P. Fixpoint same_symbol {F} (x : Symbol F) (y : Symbol F) := match (x, y) with |(next _ k, next _ k') => same_symbol k k' |(initial _, initial _) => true |_ => false end. Fixpoint same_type (x : TypeDef) (y : TypeDef) := match (x, y) with | (SimplyT k, SimplyT k') => same_symbol k k' | (Arrow k k', Arrow u u') => (same_type k u) && (same_type k' u') | (Udnf, Udnf) => true | _ => false end. Fixpoint has_type (x : TypeDef) (env : Enviroment) : bool := match env with |empty => false |bind T LT es => match T with |Udnf => (has_type x es) |_ => if (same_type x T) then true else (has_type x es) end end. Fixpoint same_expression (x : Expression) (y : Expression) : bool := match (x, y) with | (Var x t, Var y t') => same_type t t' && same_symbol x y | (Abs s x t, Abs s' x' t') => same_type t t' && same_expression s s' && (same_expression x x') | (App x y t, App x' y' t') => same_type t t'&& same_expression x x' && same_expression y y' | _ => false end. Fixpoint varType (x : Expression) (env : Enviroment) : TypeDef := match env with |empty => Udnf |bind T LT es => if (same_expression x LT) then T else varType x es end. Notation "x |- y" := (Judgment x (fun p => (has_type (varType y x) x) = true)) (at level 202, right associativity). Notation "x |- { y ::: T }" := (Judgment x (fun p => (has_type (varType y x) x) = true /\ (varType y x) = T)) (at level 201, right associativity). Notation "x ∈ y" := (varType x y <> Udnf) (at level 50, left associativity, only parsing). Definition ArrowIsDef : forall T1 T2, Arrow T1 T2 <> Udnf. by []. Defined. Inductive typed_rules : T* -> Symbol Value -> Expression -> Type := |Tvar : forall (env : Enviroment) (s : Symbol _) T {H' : T <> Udnf}, (env |- {(Var s T) ::: T}) -> typed_rules env s (Var s T) |TAbs : forall (env : Enviroment) (k : Symbol Value) x T2 {H' : T2 <> Udnf} s, typed_rules env k x -> (env |- {(Var s T2) ::: T2}) -> (fun t => typed_rules (@bind (Arrow T2 (type_of_T x)) (ArrowIsDef _ _) t env) (next _ k) t) (Abs (Var s T2) x (Arrow T2 (type_of_T x))) |TApp : forall (env : Enviroment) (k : Symbol Value) (x : Expression) T T' T1 T2 {H : T2 <> Udnf}, typed_rules env k x -> (env |- {T ::: Arrow T1 T2}) -> (env |- {T' ::: T1}) -> (fun t => (typed_rules (@bind T2 H t env) k t)) (App T T' T2). Theorem well_typed_context_has_type : forall {K} (env : Enviroment) (s : Symbol _) (H : typed_rules env s K), (env |- K) -> K ∈ env. intros. destruct H0;destruct (varType K env); cbv. discriminate. discriminate. have : forall env, has_type Udnf env = false. move => H'; elim : H'; trivial. intros. rewrite <- H1. destruct T. auto. auto. simpl; trivial. assert (forall x, x = false -> x <> true). move => H'. destruct H'; move => SH. discriminate. discriminate. move => l;contradiction (H0 _ (l env)). Qed. Lemma H0_symbol : forall {T} (s : Symbol T), same_symbol s s = true. move => f; elim; trivial. Defined. Hint Resolve H0_symbol. Lemma H1_expression : forall e, same_expression e e = true. have : forall s', same_type s' s' = true. elim. move => //=. move => Eq k k' H. move => /=. rewrite k H. done. done. move => H. elim. move => /= s t. rewrite -> (H t). move => //=. move => s e t H' t0 /=. rewrite e H' (H t0); move => /=; intuition. move => e e0 t H' t0 //=. rewrite e0 H'; intuition. Defined. Lemma H3_type : forall e, same_type e e = true. elim. move => q /=; by []. move => q k' v H' /=. rewrite k' //. done. Defined. Ltac type_eq_solver := let rewrite_type_axioms := try (do ! (rewrite -> (H0_symbol _))); try (do ! (rewrite -> (H1_expression _))); try (do ! (rewrite -> (H3_type _))) in let rewrite_type_axioms_H H := try (do ! (rewrite (H0_symbol _)) in H); try (do ! (rewrite (H1_expression _)) in H); try (do ! (rewrite -> (H3_type _)) in H) in do ! (simpl; rewrite_type_axioms); match goal with | [ H : _ |- _ ] => generalize H; do ! (simpl; rewrite_type_axioms_H H); clear H; type_eq_solver; intro H | [ |- _ ] => match goal with | [ H : _ |- _ ] => fail 1 | [ |- _ ] => simpl end end. Theorem type_context_abs : forall (env : Enviroment) (s : Symbol _) T k y (H : typed_rules env s (Abs k y T)), (env |- {(Abs k y T) ::: T}). intros. have : has_type (varType (Abs k y T) env) env = true /\ varType (Abs k y T) env = T -> Judgment env (fun _ : T* => has_type (varType (Abs k y T) env) env = true /\ varType (Abs k y T) env = T). move => D; constructor; trivial. apply. remember (Abs k y T). destruct H. discriminate Heqe. constructor. - simpl; destruct j; type_eq_solver; reflexivity. - destruct j. generalize (Abs (Var s T2) x (Arrow T2 (type_of_T x))). case;simpl. move => s' t';type_eq_solver. injection Heqe; trivial. intros;type_eq_solver. simpl;injection Heqe; intros; assumption. intros;type_eq_solver;simpl;injection Heqe; intros; assumption. - inversion Heqe. Qed. Theorem Types_of_terms_are_well_defined : forall T x s env, typed_rules env s x -> varType x env = T -> T <> Udnf. intros. destruct H. do 2 destruct j as [j]. rewrite -> H in H0;rewrite H0 in H'. exact H'. do 2 destruct j as [j]. subst;type_eq_solver. apply : ArrowIsDef. do 2 destruct j as [j];do 2 destruct j0 as [j0]. subst;simpl;type_eq_solver;assumption. Qed. Lemma conservation_of_types : forall T x s env, typed_rules env s x -> varType x env = T -> type_of_T x = T. intros. set H' := (@Types_of_terms_are_well_defined _ _ _ _ H H0). induction env. simpl in H0;cbv in H'. destruct (H' (eq_sym H0)). destruct H. do 2 destruct j as [j];simpl in *;clear H';rewrite -> e0 in H0. assumption. do 2 destruct j as [j]. simpl in *;subst;type_eq_solver; reflexivity. do 2 destruct j as [j]. do 2 destruct j0 as [j0]. subst. simpl. type_eq_solver. trivial. Qed. Theorem type_context : forall (env : Enviroment) (s : Symbol _) T K (H : typed_rules env s K), type_of_T K = T -> (env |- {K ::: T}). intros. have : has_type (varType K env) env = true /\ varType K env = T -> Judgment env (fun _ : T* => has_type (varType K env) env = true /\ varType K env = T). move => H'. destruct H'. constructor. constructor. assumption. assumption. apply. constructor. destruct H. do 2 destruct j as [j]. assumption. simpl;type_eq_solver;trivial;subst. do 2 destruct j as [j]. do 2 destruct j0 as [j0]. type_eq_solver;destruct T2. trivial. trivial. contradiction H;trivial. destruct H. do 2 destruct j as [j]. simpl in H0. rewrite <- H0. assumption. do 2 destruct j as [j]. subst;simpl;type_eq_solver;trivial. do 2 destruct j as [j];do 2 destruct j0 as [j0]. subst;type_eq_solver; trivial. Qed. Lemma eq_symb : forall {T} (x : Symbol T) y, same_symbol x y = true -> x = y. intros. (*try to proof this normally induction is bit hard cause' the x and y are evaluated in same time so the induction have to reason about two mutually, so a new mutual scheme was set*) set mutually_symbol := fun (x : TermType) (P : Symbol x -> Symbol x -> Prop) (f_2initial : P (initial x) (initial x)) (f_2next : forall s s' : Symbol x, P s s' -> P (next x s) (next x s')) (f_contr0' : forall s s' : Symbol x, P s s' -> P (initial x) (next x s')) (f_contr1' : forall s s' : Symbol x, P s s' -> P (next x s) (initial x)) => fix Ffix (x0 : Symbol x) : forall x1 : Symbol x, P x0 x1 := match x0 as c return (forall x1 : Symbol x, P c x1) with | initial _ => fix Ffix0 (x1 : Symbol x) : P (initial x) x1 := match x1 as c return (P (initial x) c) with | initial _ => f_2initial | next _ x2 => f_contr0' (initial x) x2 (Ffix0 x2) end | next _ x1 => fun x2 : Symbol x => match x2 as c return (P (next x x1) c) with | initial _ => f_contr1' x1 (initial x) (Ffix x1 (initial x)) | next _ x3 => f_2next x1 x3 (Ffix x1 x3) end end. move : H. elim/mutually_symbol : x/y. done. move => /= s s' H q. set f := (H q). rewrite -> f. done. done. done. Qed. (*A specialized ssreflect based tatic for working induction in equal types*) Ltac induction_eqType k y:= move => k; move => y; set type_mutual_induction := (fun (P : TypeDef -> TypeDef -> Prop) (f_2SimplyT : forall k k' : Symbol Type_, P (SimplyT k) (SimplyT k')) (f_2Udnf : P Udnf Udnf) (f_Simply_Arrow : forall (k : Symbol Type_) (s s' : TypeDef), P (SimplyT k) (Arrow s s')) (f_Arrow_Simply : forall (k : Symbol Type_) (s s' : TypeDef), P (Arrow s s') (SimplyT k)) (f_Simply_Udnf : forall k : Symbol Type_, P (SimplyT k) Udnf) (f_Udnf_Simply : forall k : Symbol Type_, P Udnf (SimplyT k)) (f_2Arrow : forall s s' q q' : TypeDef, P s q -> P s' q' -> P (Arrow s s') (Arrow q q')) (f_Arrow_Udnf : forall s s' : TypeDef, P (Arrow s s') Udnf) (f_Udnf_Arrow : forall s s' : TypeDef, P Udnf (Arrow s s')) => fix Ffix (x : TypeDef) : forall x0 : TypeDef, P x x0 := match x as c return (forall x0 : TypeDef, P c x0) with | SimplyT x0 => fun x1 : TypeDef => match x1 as c return (P (SimplyT x0) c) with | SimplyT x2 => f_2SimplyT x0 x2 | Arrow x2 x3 => f_Simply_Arrow x0 x2 x3 | Udnf => f_Simply_Udnf x0 end | Arrow x0 x1 => fix Ffix0 (x2 : TypeDef) : P (Arrow x0 x1) x2 := match x2 as c return (P (Arrow x0 x1) c) with | SimplyT x3 => f_Arrow_Simply x3 x0 x1 | Arrow x3 x4 => f_2Arrow x0 x1 x3 x4 (Ffix x0 x3) (Ffix x1 x4) | Udnf => f_Arrow_Udnf x0 x1 end | Udnf => fun x0 : TypeDef => match x0 as c return (P Udnf c) with | SimplyT x1 => f_Udnf_Simply x1 | Arrow x1 x2 => f_Udnf_Arrow x1 x2 | Udnf => f_2Udnf end end); elim/type_mutual_induction : k/y; clear. Lemma eq_type : forall k y, same_type k y = true-> k = y. induction_eqType k y. intros. unfold same_type in H. rewrite -> (eq_symb _ _ H). trivial. trivial. intros;inversion H. intros;inversion H. intros;inversion H. intros;inversion H. intros. simpl in H1. apply andb_true_iff in H1. destruct H1. apply H in H1. apply H0 in H2. rewrite H1 H2. trivial. intros; inversion H. intros; inversion H. Qed. (*False injection was the more easy way to prove somes check that the typed_rules do is wrong, fortunately the "bind" construct a false injection equality*) Lemma False_injection_nextC : forall (t : TypeDef) t0, t = Arrow t0 t -> False. induction t. intros. discriminate. move => H H1. injection H1. intros. rewrite -> H2 in H1. injection H1. intros. apply IHt2 in H3. trivial. discriminate. Qed. Theorem lambda_type_return : forall (env : Enviroment) (s : Symbol _) k y T1 T2 x (H : typed_rules env s x), x = (Abs k y (Arrow T1 T2)) -> (env |- {(Abs k y (Arrow T1 T2)) ::: Arrow T1 T2}) -> (env |- {y ::: T2}). intros. remember s; destruct H. inversion H0. constructor. simpl in *; injection H0; intros; destruct H1. destruct y; simpl in *. constructor. subst; do 2 destruct j as [j]. type_eq_solver. destruct (same_type (varType (Var s0 t) env) (Arrow T1 t)); trivial. assert(type_of_T (Var s0 t) = t). trivial. pose(type_context _ _ _ _ H H2). do 2 destruct j0 as [j0]. destruct (same_type (varType (Var s1 t) env) (Arrow T1 t)). trivial. assumption. destruct (same_type (varType (Var s1 t) env) (Arrow T1 t)). trivial. assert(type_of_T (Var s1 t) = t). trivial. pose (type_context _ _ _ _ H H2). do 2 destruct j0 as [j0]. assumption. destruct a. destruct j. destruct a. injection H0; intros. rewrite <- H4; rewrite <- H2. pose(type_context _ _ _ _ H H9). do 2 destruct j as [j]. subst; assumption. constructor. do 2 destruct j as [j]. subst; type_eq_solver. case : (same_type t (Arrow T1 t) && same_expression y1 (Var s0 T1) && same_expression y2 (Abs y1 y2 t)). type_eq_solver; trivial. destruct (same_type (varType (Abs y1 y2 t) env) (Arrow T1 t)). trivial. assert(type_of_T (Abs y1 y2 t) = t). trivial. pose(type_context _ _ _ _ H H2). do 2 destruct j0 as [j0]. trivial. do 2 destruct j as [j]. simpl in *; subst; type_eq_solver. remember (if same_type t (Arrow T1 t) && same_expression y1 (Var s0 T1) && same_expression y2 (Abs y1 y2 t) then Arrow T1 t else varType (Abs y1 y2 t) env). remember (same_type t (Arrow T1 t)). remember (same_expression y1 (Var s0 T1) && same_expression y2 (Abs y1 y2 t)). destruct b. symmetry in Heqb; apply eq_type in Heqb; destruct (False_injection_nextC _ _ Heqb). simpl in Heqt0; rewrite -> Heqt0. assert(type_of_T (Abs y1 y2 t) = t). trivial. pose (type_context _ _ _ _ H H2). do 2 destruct j0 as [j0]. assumption. subst; type_eq_solver; constructor. destruct (same_type (varType (App y1 y2 t) env) (Arrow T1 t)). trivial. destruct H. do 2 destruct j0 as [j0]; exact j0. type_eq_solver; trivial. simpl in *; type_eq_solver; destruct T2; trivial. trivial. contradiction H; apply : eq_refl. remember (App y1 y2 t); destruct H. do 2 destruct j0 as [j0]. inversion Heqe. simpl in *; type_eq_solver. inversion Heqe. simpl in *; type_eq_solver; injection Heqe; intros; assumption. inversion H0. Qed. (*this lemma is a counter implication of conservation_of_types so, we able to construct a strong <-> relation between enviroment and their types*) Lemma strong_enviroment_conservation : forall T2 env y, same_type (varType y env) T2 = true -> varType y env = T2. move => t2 d; elim. move => y g Heq. induction y. destruct d. destruct t2; simpl in Heq. inversion Heq. inversion Heq. trivial; simpl; simpl in Heq. move : Heq; generalize (if match e with | Var y t' => same_type g t' && match y with | initial _ => true | next _ _ => false end | _ => false end then T else varType (Var (initial Value) g) d). move => t0; apply : eq_type. destruct d; simpl in *. apply IHy in Heq; assumption. apply eq_type in Heq; trivial. intros; apply eq_type in H1; trivial. intros;apply eq_type in H1;trivial. Qed. Theorem lambda_symbol_uniqueness : forall (env : Enviroment) (s : Symbol _) k y T (H : typed_rules env (next _ s) (Abs k y T)), k = Var s (type_of_T k). intros. remember s. remember (Abs k y T). remember k. destruct H. inversion Heqe. remember k0. destruct H. Admitted. Theorem well__lambda_typed_context_has_type : forall (env : Enviroment) (s : Symbol _) k y T (H : typed_rules env (next _ s) (Abs k y T)) T1 T2 R1 R2, (env |- {k ::: T1}) -> (env |- {(Abs k y T) ::: Arrow R1 R2}) -> R2 = T2. Admitted.
/- Copyright (c) 2020 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta -/ import category_theory.limits.preserves.shapes.binary_products import category_theory.limits.preserves.shapes.products import category_theory.limits.shapes.binary_products import category_theory.limits.shapes.finite_products import category_theory.pempty import data.equiv.fin /-! # Constructing finite products from binary products and terminal. If a category has binary products and a terminal object then it has finite products. If a functor preserves binary products and the terminal object then it preserves finite products. # TODO Provide the dual results. Show the analogous results for functors which reflect or create (co)limits. -/ universes v u u' noncomputable theory open category_theory category_theory.category category_theory.limits namespace category_theory variables {J : Type v} [small_category J] variables {C : Type u} [category.{v} C] variables {D : Type u'} [category.{v} D] /-- Given `n+1` objects of `C`, a fan for the last `n` with point `c₁.X` and a binary fan on `c₁.X` and `f 0`, we can build a fan for all `n+1`. In `extend_fan_is_limit` we show that if the two given fans are limits, then this fan is also a limit. -/ @[simps {rhs_md := semireducible}] def extend_fan {n : ℕ} {f : ulift (fin (n+1)) → C} (c₁ : fan (λ (i : ulift (fin n)), f ⟨i.down.succ⟩)) (c₂ : binary_fan (f ⟨0⟩) c₁.X) : fan f := fan.mk c₂.X begin rintro ⟨i⟩, revert i, refine fin.cases _ _, { apply c₂.fst }, { intro i, apply c₂.snd ≫ c₁.π.app (ulift.up i) }, end /-- Show that if the two given fans in `extend_fan` are limits, then the constructed fan is also a limit. -/ def extend_fan_is_limit {n : ℕ} (f : ulift (fin (n+1)) → C) {c₁ : fan (λ (i : ulift (fin n)), f ⟨i.down.succ⟩)} {c₂ : binary_fan (f ⟨0⟩) c₁.X} (t₁ : is_limit c₁) (t₂ : is_limit c₂) : is_limit (extend_fan c₁ c₂) := { lift := λ s, begin apply (binary_fan.is_limit.lift' t₂ (s.π.app ⟨0⟩) _).1, apply t₁.lift ⟨_, discrete.nat_trans (λ i, s.π.app ⟨i.down.succ⟩)⟩ end, fac' := λ s, begin rintro ⟨j⟩, apply fin.induction_on j, { apply (binary_fan.is_limit.lift' t₂ _ _).2.1 }, { rintro i -, dsimp only [extend_fan_π_app], rw [fin.cases_succ, ← assoc, (binary_fan.is_limit.lift' t₂ _ _).2.2, t₁.fac], refl } end, uniq' := λ s m w, begin apply binary_fan.is_limit.hom_ext t₂, { rw (binary_fan.is_limit.lift' t₂ _ _).2.1, apply w ⟨0⟩ }, { rw (binary_fan.is_limit.lift' t₂ _ _).2.2, apply t₁.uniq ⟨_, _⟩, rintro ⟨j⟩, rw assoc, dsimp only [discrete.nat_trans_app], rw ← w ⟨j.succ⟩, dsimp only [extend_fan_π_app], rw fin.cases_succ } end } section variables [has_binary_products.{v} C] [has_terminal C] /-- If `C` has a terminal object and binary products, then it has a product for objects indexed by `ulift (fin n)`. This is a helper lemma for `has_finite_products_of_has_binary_and_terminal`, which is more general than this. -/ private lemma has_product_ulift_fin : Π (n : ℕ) (f : ulift.{v} (fin n) → C), has_product f | 0 := λ f, begin letI : has_limits_of_shape (discrete (ulift.{v} (fin 0))) C := has_limits_of_shape_of_equivalence (discrete.equivalence.{v} (equiv.ulift.trans fin_zero_equiv').symm), apply_instance, end | (n+1) := λ f, begin haveI := has_product_ulift_fin n, apply has_limit.mk ⟨_, extend_fan_is_limit f (limit.is_limit.{v} _) (limit.is_limit _)⟩, end /-- If `C` has a terminal object and binary products, then it has limits of shape `discrete (ulift (fin n))` for any `n : ℕ`. This is a helper lemma for `has_finite_products_of_has_binary_and_terminal`, which is more general than this. -/ private lemma has_limits_of_shape_ulift_fin (n : ℕ) : has_limits_of_shape (discrete (ulift.{v} (fin n))) C := { has_limit := λ K, begin letI := has_product_ulift_fin n K.obj, let : discrete.functor K.obj ≅ K := discrete.nat_iso (λ i, iso.refl _), apply has_limit_of_iso this, end } /-- If `C` has a terminal object and binary products, then it has finite products. -/ lemma has_finite_products_of_has_binary_and_terminal : has_finite_products C := ⟨λ J 𝒥₁ 𝒥₂, begin resetI, let e := fintype.equiv_fin J, apply has_limits_of_shape_of_equivalence (discrete.equivalence (e.trans equiv.ulift.symm)).symm, refine has_limits_of_shape_ulift_fin (fintype.card J), end⟩ end section preserves variables (F : C ⥤ D) variables [preserves_limits_of_shape (discrete walking_pair) F] variables [preserves_limits_of_shape (discrete pempty) F] variables [has_finite_products.{v} C] /-- If `F` preserves the terminal object and binary products, then it preserves products indexed by `ulift (fin n)` for any `n`. -/ noncomputable def preserves_fin_of_preserves_binary_and_terminal : Π (n : ℕ) (f : ulift (fin n) → C), preserves_limit (discrete.functor f) F | 0 := λ f, begin letI : preserves_limits_of_shape (discrete (ulift (fin 0))) F := preserves_limits_of_shape_of_equiv (discrete.equivalence (equiv.ulift.trans fin_zero_equiv').symm) _, apply_instance, end | (n+1) := begin haveI := preserves_fin_of_preserves_binary_and_terminal n, intro f, refine preserves_limit_of_preserves_limit_cone (extend_fan_is_limit f (limit.is_limit.{v} _) (limit.is_limit _)) _, apply (is_limit_map_cone_fan_mk_equiv _ _ _).symm _, let := extend_fan_is_limit (λ i, F.obj (f i)) (is_limit_of_has_product_of_preserves_limit F _) (is_limit_of_has_binary_product_of_preserves_limit F _ _), refine is_limit.of_iso_limit this _, apply cones.ext _ _, apply iso.refl _, rintro ⟨j⟩, apply fin.induction_on j, { apply (category.id_comp _).symm }, { rintro i -, dsimp only [extend_fan_π_app, iso.refl_hom, fan.mk_π_app], rw [fin.cases_succ, fin.cases_succ], change F.map _ ≫ _ = 𝟙 _ ≫ _, rw [id_comp, ←F.map_comp], refl } end /-- If `F` preserves the terminal object and binary products, then it preserves limits of shape `discrete (ulift (fin n))`. -/ def preserves_ulift_fin_of_preserves_binary_and_terminal (n : ℕ) : preserves_limits_of_shape (discrete (ulift (fin n))) F := { preserves_limit := λ K, begin let : discrete.functor K.obj ≅ K := discrete.nat_iso (λ i, iso.refl _), haveI := preserves_fin_of_preserves_binary_and_terminal F n K.obj, apply preserves_limit_of_iso_diagram F this, end } /-- If `F` preserves the terminal object and binary products then it preserves finite products. -/ def preserves_finite_products_of_preserves_binary_and_terminal (J : Type v) [fintype J] : preserves_limits_of_shape.{v} (discrete J) F := begin classical, let e := fintype.equiv_fin J, haveI := preserves_ulift_fin_of_preserves_binary_and_terminal F (fintype.card J), apply preserves_limits_of_shape_of_equiv (discrete.equivalence (e.trans equiv.ulift.symm)).symm, end end preserves /-- Given `n+1` objects of `C`, a cofan for the last `n` with point `c₁.X` and a binary cofan on `c₁.X` and `f 0`, we can build a cofan for all `n+1`. In `extend_cofan_is_colimit` we show that if the two given cofans are colimits, then this cofan is also a colimit. -/ @[simps {rhs_md := semireducible}] def extend_cofan {n : ℕ} {f : ulift (fin (n+1)) → C} (c₁ : cofan (λ (i : ulift (fin n)), f ⟨i.down.succ⟩)) (c₂ : binary_cofan (f ⟨0⟩) c₁.X) : cofan f := cofan.mk c₂.X begin rintro ⟨i⟩, revert i, refine fin.cases _ _, { apply c₂.inl }, { intro i, apply c₁.ι.app (ulift.up i) ≫ c₂.inr }, end /-- Show that if the two given cofans in `extend_cofan` are colimits, then the constructed cofan is also a colimit. -/ def extend_cofan_is_colimit {n : ℕ} (f : ulift (fin (n+1)) → C) {c₁ : cofan (λ (i : ulift (fin n)), f ⟨i.down.succ⟩)} {c₂ : binary_cofan (f ⟨0⟩) c₁.X} (t₁ : is_colimit c₁) (t₂ : is_colimit c₂) : is_colimit (extend_cofan c₁ c₂) := { desc := λ s, begin apply (binary_cofan.is_colimit.desc' t₂ (s.ι.app ⟨0⟩) _).1, apply t₁.desc ⟨_, discrete.nat_trans (λ i, s.ι.app ⟨i.down.succ⟩)⟩ end, fac' := λ s, begin rintro ⟨j⟩, apply fin.induction_on j, { apply (binary_cofan.is_colimit.desc' t₂ _ _).2.1 }, { rintro i -, dsimp only [extend_cofan_ι_app], rw [fin.cases_succ, assoc, (binary_cofan.is_colimit.desc' t₂ _ _).2.2, t₁.fac], refl } end, uniq' := λ s m w, begin apply binary_cofan.is_colimit.hom_ext t₂, { rw (binary_cofan.is_colimit.desc' t₂ _ _).2.1, apply w ⟨0⟩ }, { rw (binary_cofan.is_colimit.desc' t₂ _ _).2.2, apply t₁.uniq ⟨_, _⟩, rintro ⟨j⟩, dsimp only [discrete.nat_trans_app], rw ← w ⟨j.succ⟩, dsimp only [extend_cofan_ι_app], rw [fin.cases_succ, assoc], } end } section variables [has_binary_coproducts.{v} C] [has_initial C] /-- If `C` has an initial object and binary coproducts, then it has a coproduct for objects indexed by `ulift (fin n)`. This is a helper lemma for `has_cofinite_products_of_has_binary_and_terminal`, which is more general than this. -/ private lemma has_coproduct_ulift_fin : Π (n : ℕ) (f : ulift.{v} (fin n) → C), has_coproduct f | 0 := λ f, begin letI : has_colimits_of_shape (discrete (ulift.{v} (fin 0))) C := has_colimits_of_shape_of_equivalence (discrete.equivalence.{v} (equiv.ulift.trans fin_zero_equiv').symm), apply_instance, end | (n+1) := λ f, begin haveI := has_coproduct_ulift_fin n, apply has_colimit.mk ⟨_, extend_cofan_is_colimit f (colimit.is_colimit.{v} _) (colimit.is_colimit _)⟩, end /-- If `C` has an initial object and binary coproducts, then it has colimits of shape `discrete (ulift (fin n))` for any `n : ℕ`. This is a helper lemma for `has_cofinite_products_of_has_binary_and_terminal`, which is more general than this. -/ private lemma has_colimits_of_shape_ulift_fin (n : ℕ) : has_colimits_of_shape (discrete (ulift.{v} (fin n))) C := { has_colimit := λ K, begin letI := has_coproduct_ulift_fin n K.obj, let : K ≅ discrete.functor K.obj := discrete.nat_iso (λ i, iso.refl _), apply has_colimit_of_iso this, end } /-- If `C` has an initial object and binary coproducts, then it has finite coproducts. -/ lemma has_finite_coproducts_of_has_binary_and_terminal : has_finite_coproducts C := ⟨λ J 𝒥₁ 𝒥₂, begin resetI, let e := fintype.equiv_fin J, apply has_colimits_of_shape_of_equivalence (discrete.equivalence (e.trans equiv.ulift.symm)).symm, refine has_colimits_of_shape_ulift_fin (fintype.card J), end⟩ end section preserves variables (F : C ⥤ D) variables [preserves_colimits_of_shape (discrete walking_pair) F] variables [preserves_colimits_of_shape (discrete pempty) F] variables [has_finite_coproducts.{v} C] /-- If `F` preserves the initial object and binary coproducts, then it preserves products indexed by `ulift (fin n)` for any `n`. -/ noncomputable def preserves_fin_of_preserves_binary_and_initial : Π (n : ℕ) (f : ulift (fin n) → C), preserves_colimit (discrete.functor f) F | 0 := λ f, begin letI : preserves_colimits_of_shape (discrete (ulift (fin 0))) F := preserves_colimits_of_shape_of_equiv (discrete.equivalence (equiv.ulift.trans fin_zero_equiv').symm) _, apply_instance, end | (n+1) := begin haveI := preserves_fin_of_preserves_binary_and_initial n, intro f, refine preserves_colimit_of_preserves_colimit_cocone (extend_cofan_is_colimit f (colimit.is_colimit.{v} _) (colimit.is_colimit _)) _, apply (is_colimit_map_cocone_cofan_mk_equiv _ _ _).symm _, let := extend_cofan_is_colimit (λ i, F.obj (f i)) (is_colimit_of_has_coproduct_of_preserves_colimit F _) (is_colimit_of_has_binary_coproduct_of_preserves_colimit F _ _), refine is_colimit.of_iso_colimit this _, apply cocones.ext _ _, apply iso.refl _, rintro ⟨j⟩, apply fin.induction_on j, { apply category.comp_id }, { rintro i -, dsimp only [extend_cofan_ι_app, iso.refl_hom, cofan.mk_ι_app], rw [fin.cases_succ, fin.cases_succ], erw [comp_id, ←F.map_comp], refl, } end /-- If `F` preserves the initial object and binary coproducts, then it preserves colimits of shape `discrete (ulift (fin n))`. -/ def preserves_ulift_fin_of_preserves_binary_and_initial (n : ℕ) : preserves_colimits_of_shape (discrete (ulift (fin n))) F := { preserves_colimit := λ K, begin let : discrete.functor K.obj ≅ K := discrete.nat_iso (λ i, iso.refl _), haveI := preserves_fin_of_preserves_binary_and_initial F n K.obj, apply preserves_colimit_of_iso_diagram F this, end } /-- If `F` preserves the initial object and binary coproducts then it preserves finite products. -/ def preserves_finite_coproducts_of_preserves_binary_and_initial (J : Type v) [fintype J] : preserves_colimits_of_shape.{v} (discrete J) F := begin classical, let e := fintype.equiv_fin J, haveI := preserves_ulift_fin_of_preserves_binary_and_initial F (fintype.card J), apply preserves_colimits_of_shape_of_equiv (discrete.equivalence (e.trans equiv.ulift.symm)).symm, end end preserves end category_theory
import numpy as np import importlib import pydot import logging import sys CMLANG_CAST_MAP = { "int" : np.int, "str" : np.str, "bool" :np.bool, "float": np.float, "complex": np.complex } def get_func(function_name): mod_id, func_id = function_name.rsplit('.', 1) try: mod = importlib.import_module(mod_id) except ModuleNotFoundError: logging.error(f"Unable to import {mod_id}. Exiting") exit(1) func = getattr(mod, func_id) return func def visualize(input_proto,graph, graph_name, output_dir, output_file): rankdir = "TB" pydot_graph = pydot.Dot(name=input_proto, rankdir=rankdir) out_graph = GetPydotGraph(graph, name=graph_name, rankdir=rankdir) filename = output_dir + '/' + output_file[:-3] + '.dot' pydot_graph.add_subgraph(out_graph) pydot_graph.write(filename, format='raw') pdf_filename = filename[:-3] + 'png' try: pydot_graph.write_png(pdf_filename) except Exception: print( 'Error when writing out the png file. Pydot requires graphviz ' 'to convert dot files to pdf, and you may not have installed ' 'graphviz. On ubuntu this can usually be installed with "sudo ' 'apt-get install graphviz". We have generated the .dot file ' 'but will not be able to generate png file for now.' )
Lactogest lactobacillus sporogenes probiotic formula (now called Probio Daily - New name!) lactobacillus sporogenes, unlike many probiotics, survives stomach acids well because it is in 'spore' form, and is ideal for travel because it does not need to be refrigerated. Suggested uses: maintaining healthy intestinal flora, especially during and after taking antibiotics. One tablet typically provides: Lactobacillus Sporogenes (150 million*), Fructo-oligosaccharides 100mg. *At the time of manufacturing each tablet contains 150 million lactobacillus sporogenes, the effective dose as determined by clinical trials, in an all-natural base including nutrients that promote the proliferation of L (+) lactic acid lactobacilli in the colon. Suitable for vegetarians and vegans. GM Free. Take 1 tablet up to 3 times a day (children over 8 years, 1-2 tablets a day) with meals or as you health professional advises. No added salt, soya, wheat, gluten, maize, corn, yeast, lactose, dairy products, artificial preservatives, colours or flavourings. Hypo-allergenic formula. Suitable for Vegans. GM Free.
print(paste0(Sys.time(), " --- Paragraph on taxonomic effort")) #################### # Summary # Count number of statuses status <- table(df_all$status) sum(status) round(prop.table(status)*100, 1) #################### # Data processing # Subset data for describers which made at least 1 description as 1st/2nd auth df_tax <- df_describers[spp_N_1st_auth_s > 0]; dim(df_tax) # Calculate difference between "all species"* max and "valid species" max # *includes subspecies df_tax$diff <- df_tax$max - df_tax$ns_max # Author names for those that described non valid species tax_only_not_valid <- df_tax[ns_spp_N == 0]$full.name.of.describer # Author names of those describing valid species AND at least 1 synonym tax_valid_w_one_syn <- df_tax[ns_spp_N > 0 & syn_spp_N > 0]$full.name.of.describer #################### # Tabulation # Total number of author-years total_author_years <- dim(df_describers_year)[1] tax_notvalid_onesyn <- c(tax_only_not_valid, tax_valid_w_one_syn) # First aspect: - # Author-years: Only non-valid species length(tax_only_not_valid) # number of authors total_1 <- author_years_not_valid <- length(df_describers_year[full.name.of.describer %in% tax_only_not_valid]$N) author_years_not_valid / total_author_years * 100 # proportion for non-valid # Did not shift the median summary(df_describers_year$N) # their inclusion summary(df_describers_year[!full.name.of.describer %in% tax_only_not_valid]$N) # did not shift # Second aspect: - # Author-years: At least valid species and at least 1 non-valid species length(tax_valid_w_one_syn) # Those without difference no_diff <- df_tax[full.name.of.describer %in% tax_valid_w_one_syn]$diff==0 round(prop.table(table(no_diff))*100, 1) # Those with difference length(df_tax[full.name.of.describer %in% tax_valid_w_one_syn & diff > 0]$diff) # Median and quantiles summary(df_tax[full.name.of.describer %in% tax_valid_w_one_syn & diff > 0]$diff) # Cumulative total_2 <- sum(df_tax[full.name.of.describer %in% tax_valid_w_one_syn & diff > 0]$diff) total_2 # Total for aspect 1 and 2 (total_1 + total_2) / total_author_years * 100 (total_1 + total_2) #################### # Plot # Plot number of authors-years in a density plot p1 <- ggplot(df_describers_year) + geom_density(aes(x = N), alpha = 0.2) + xlim(c(0, 20)) + theme p2 <- ggplot(df_describers_year[!full.name.of.describer %in% tax_only_not_valid]) + geom_density(aes(x = N), alpha = 0.2) + xlim(c(0,20)) + theme grid.arrange(p1, p2) # they look similar
function [nconds,cforecast_record,cforecast_estimates]=... panel2cf(N,n,m,p,k,q,cfconds,cfshocks,cfblocks,data_endo_a,data_exo_a,data_exo_p,It,Bu,Fperiods,const,beta_gibbs,D_record,gamma_record,CFt,Fband) % initiate the cell recording the Gibbs sampler draws cforecast_record={}; cforecast_estimates={}; % because conditional forecasts can be computed for many (potentially all) units, loop over units for ii=1:N % check wether there are any conditions on unit ii temp=cfconds(:,:,ii); nconds(ii,1)=numel(temp(cellfun(@(x) any(~isempty(x)),temp))); % if there are conditions if nconds(ii,1)~=0 % prepare the elements for conditional forecast estimation, depending on the type of conditional forecasts temp1=cfconds(:,:,ii); if CFt==1 temp2={}; temp3=[]; elseif CFt==2 temp2=cfshocks(:,:,ii); temp3=cfblocks(:,:,ii); end % run the Gibbs sampler for unit ii cforecast_record(:,:,ii)=bear.cforecast(data_endo_a(:,:,ii),data_exo_a,data_exo_p,It,Bu,Fperiods,temp1,temp2,temp3,CFt,const,beta_gibbs,D_record,gamma_record,n,m,p,k,q); % then obtain point estimates and credibility intervals cforecast_estimates(:,:,ii)=bear.festimates(cforecast_record(:,:,ii),n,Fperiods,Fband); % if there are no conditions, return empty elements elseif nconds(ii,1)==0 cforecast_record(:,:,ii)=cell(n,1); cforecast_estimates(:,:,ii)=cell(n,1); end end
// Copyright 2015-2020 Tier IV, Inc. 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. #ifndef OPENSCENARIO_INTERPRETER__VARIANT__VISIBILITY_H_ #define OPENSCENARIO_INTERPRETER__VARIANT__VISIBILITY_H_ #if __cplusplus >= 201606 #include <variant> #else #include <boost/variant.hpp> #endif namespace openscenario_interpreter { #if __cplusplus >= 201606 template <typename... Ts> using Variant = std::variant<Ts...>; using std::visit; #else template <typename... Ts> using Variant = boost::variant<Ts...>; template <typename Lambda, typename... Ts> struct lambda_visitor : boost::static_visitor< typename std::common_type<decltype(std::declval<Lambda>()(std::declval<Ts>()))...>::type> { explicit lambda_visitor(const Lambda & visitor) : visitor(visitor) {} explicit lambda_visitor(Lambda && visitor) : visitor(std::move(visitor)) {} template <typename T> auto operator()(T && arg) { return visitor(std::forward<T>(arg)); } template <typename T> auto operator()(T && arg) const { return visitor(std::forward<T>(arg)); } private: Lambda visitor; }; template <typename Visitor, typename... Ts> auto visit(Visitor && visitor, const boost::variant<Ts...> & arg0) { lambda_visitor<std::decay_t<Visitor>, Ts...> f{std::forward<Visitor>(visitor)}; return boost::apply_visitor(f, arg0); } template <typename Visitor, typename... Ts> auto visit(Visitor && visitor, boost::variant<Ts...> && arg0) { lambda_visitor<std::decay_t<Visitor>, Ts...> f{std::forward<Visitor>(visitor)}; return boost::apply_visitor(f, std::move(arg0)); } template <typename Visitor, typename... Ts, typename... Variants> auto visit(Visitor && visitor, const boost::variant<Ts...> & var0, Variants &&... vars) { return visit( [&visitor, &vars...](auto && arg0) { return visit( [&visitor, &arg0](auto &&... args) { return visitor(arg0, std::forward<decltype(args)>(args)...); }, std::forward<decltype(vars)>(vars)...); }, var0); } template <typename Visitor, typename... Ts, typename... Variants> auto visit(Visitor && visitor, boost::variant<Ts...> && var0, Variants &&... vars) { return visit( [&visitor, &vars...](auto && arg0) { return visit( [&visitor, &arg0](auto &&... args) { return visitor(arg0, std::forward<decltype(args)>(args)...); }, std::forward<decltype(vars)>(vars)...); }, std::move(var0)); } #endif } // namespace openscenario_interpreter #endif // OPENSCENARIO_INTERPRETER__VARIANT__VISIBILITY_H_
State Before: α✝ β α : Type u A : Set (Set α) ⊢ (#↑(⋃₀ A)) ≤ (#↑A) * ⨆ (s : ↑A), #↑↑s State After: α✝ β α : Type u A : Set (Set α) ⊢ (#↑(⋃ (i : ↑A), ↑i)) ≤ (#↑A) * ⨆ (s : ↑A), #↑↑s Tactic: rw [sUnion_eq_iUnion] State Before: α✝ β α : Type u A : Set (Set α) ⊢ (#↑(⋃ (i : ↑A), ↑i)) ≤ (#↑A) * ⨆ (s : ↑A), #↑↑s State After: no goals Tactic: apply mk_iUnion_le
\part{Actual Recipes} \label{part:Actual Recipes} \chapter{Filework} \label{chap:Filework} \section{Archive a file} \label{sec:Archive a file} This section might belong in the expression in the file section
//---------------------------------------------------------------------------// //! //! \file tstInverseSquareAngstromUnit.cpp //! \author Alex Robinson //! \brief The inverse square Angstrom unit unit tests //! //---------------------------------------------------------------------------// // Std Lib Includes #include <iostream> // Boost Includes #define BOOST_TEST_MAIN #include <boost/test/unit_test.hpp> #include <boost/test/tools/floating_point_comparison.hpp> #include <boost/units/quantity.hpp> #include <boost/units/systems/cgs/area.hpp> #include <boost/units/systems/si/area.hpp> // FRENSIE Includes #include "Utility_InverseSquareAngstromUnit.hpp" #include "Utility_InverseAngstromUnit.hpp" #include "Utility_AngstromUnit.hpp" using namespace Utility::Units; namespace si = boost::units::si; namespace cgs = boost::units::cgs; //---------------------------------------------------------------------------// // Tests //---------------------------------------------------------------------------// // Check that the inverse square angstrom unit can be initialized BOOST_AUTO_TEST_CASE( initialize ) { boost::units::quantity<Utility::Units::InverseSquareAngstrom> inverse_sqr_angstrom( 1.0*inverse_square_angstrom ); BOOST_CHECK_EQUAL( inverse_sqr_angstrom.value(), 1.0 ); inverse_sqr_angstrom = 2.0*inverse_square_angstrom; BOOST_CHECK_EQUAL( inverse_sqr_angstrom.value(), 2.0 ); } //---------------------------------------------------------------------------// // Check that the inv. sqr. angs. unit can be initialized from the inv. angs. BOOST_AUTO_TEST_CASE( initialize_from_inv_angstrom ) { boost::units::quantity<Utility::Units::InverseSquareAngstrom> inverse_sqr_angstrom( 1.0*inverse_angstrom*inverse_angstrom ); BOOST_CHECK_EQUAL( inverse_sqr_angstrom.value(), 1.0 ); inverse_sqr_angstrom = 2.0*inverse_angstrom*inverse_angstrom; BOOST_CHECK_EQUAL( inverse_sqr_angstrom.value(), 2.0 ); } //---------------------------------------------------------------------------// // Check that the inv. sqr. angs. unit can be initialized from the angs. unit BOOST_AUTO_TEST_CASE( initialize_from_angstrom ) { boost::units::quantity<Utility::Units::InverseSquareAngstrom> inverse_sqr_angstrom( 1.0/(angstrom*angstrom) ); BOOST_CHECK_EQUAL( inverse_sqr_angstrom.value(), 1.0 ); inverse_sqr_angstrom = 2.0/(angstrom*angstrom); BOOST_CHECK_EQUAL( inverse_sqr_angstrom.value(), 2.0 ); } //---------------------------------------------------------------------------// // Check that the inv. sqr. angs. unit can be initialized from cgs, si units BOOST_AUTO_TEST_CASE( initialize_from_cgs_si ) { boost::units::quantity<Utility::Units::InverseSquareAngstrom> inverse_sqr_angstrom_cgs( 1.0/cgs::square_centimeter ); boost::units::quantity<Utility::Units::InverseSquareAngstrom> inverse_sqr_angstrom_si( 1.0/si::square_meter ); BOOST_CHECK_EQUAL( inverse_sqr_angstrom_cgs.value(), 1e-16 ); BOOST_CHECK_EQUAL( inverse_sqr_angstrom_si.value(), 1e-20 ); } //---------------------------------------------------------------------------// // end tstInverseSquareAngstrom.cpp //---------------------------------------------------------------------------//
theory P13 imports Main begin fun list_union :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" where "list_union Nil xs = xs" | "list_union (y # ys) xs = (if (y \<in> (set xs)) then (list_union ys xs) else (y # list_union ys xs))" lemma [simp]: "a \<notin> set xs \<Longrightarrow> a \<notin> set ys \<Longrightarrow> a \<notin> set (list_union xs ys)" by simp lemma [rule_format]: "distinct xs \<longrightarrow> distinct ys \<longrightarrow> (distinct (list_union xs ys))" proof (induct xs) case Nil then show ?case by simp next case (Cons a xs) have 1:"distinct (a # xs) \<Longrightarrow> a \<notin> (set xs)" by simp have 2: "distinct (a # xs) \<Longrightarrow> distinct xs" by simp then show ?case proof (cases "a \<in> set ys") case True then show ?thesis using Cons.hyps by auto next case False hence "list_union (a # xs) ys = a # list_union xs ys" by simp then show ?thesis using Cons.hyps False 1 by auto qed qed lemma "((\<forall> x \<in> A. P x) \<and> (\<forall> x \<in> B. P x)) \<longrightarrow> (\<forall> x \<in> (A \<union> B). P x)" by auto lemma "\<forall> x \<in> A. Q (f x) \<Longrightarrow> \<forall> y \<in> f ` A. Q y" by auto end
lemmas landau_symbols = landau_o.big.landau_symbol_axioms landau_o.small.landau_symbol_axioms landau_omega.big.landau_symbol_axioms landau_omega.small.landau_symbol_axioms landau_theta.landau_symbol_axioms
t = 0:0.1:10; x = exp(-0.2*t) .* cos(2*t); y = exp(-0.2*t) .* sin(2*t); plot3(x,y,t,'LineWidth',2); title('\bfThree-Dimensional Line Plot'); xlabel('\bfx'); ylabel('\bfy'); zlabel('\bftime'); grid on;
section\<open>Poincar\'e disc model types\<close> text \<open>In this section we introduce datatypes that represent objects in the Poincar\'e disc model. The types are defined as subtypes (e.g., the h-points are defined as elements of $\mathbb{C}P^1$ that lie within the unit disc). The functions on those types are defined by lifting the functions defined on the carrier type (e.g., h-distance is defined by lifting the distance function defined for elements of $\mathbb{C}P^1$).\<close> theory Poincare imports Poincare_Lines Poincare_Between Poincare_Distance Poincare_Circles begin (* ------------------------------------------------------------------ *) subsection \<open>H-points\<close> (* ------------------------------------------------------------------ *) typedef p_point = "{z. z \<in> unit_disc}" using zero_in_unit_disc by (rule_tac x="0\<^sub>h" in exI, simp) setup_lifting type_definition_p_point text \<open>Point zero\<close> lift_definition p_zero :: "p_point" is "0\<^sub>h" by (rule zero_in_unit_disc) text \<open>Constructing h-points from complex numbers\<close> lift_definition p_of_complex :: "complex \<Rightarrow> p_point" is "\<lambda> z. if cmod z < 1 then of_complex z else 0\<^sub>h" by auto (* ------------------------------------------------------------------ *) subsection \<open>H-lines\<close> (* ------------------------------------------------------------------ *) typedef p_line = "{H. is_poincare_line H}" by (rule_tac x="x_axis" in exI, simp) setup_lifting type_definition_p_line lift_definition p_incident :: "p_line \<Rightarrow> p_point \<Rightarrow> bool" is on_circline done text \<open>Set of h-points on an h-line\<close> definition p_points :: "p_line \<Rightarrow> p_point set" where "p_points l = {p. p_incident l p}" text \<open>x-axis is an example of an h-line\<close> lift_definition p_x_axis :: "p_line" is x_axis by simp text \<open>Constructing the unique h-line from two h-points\<close> lift_definition p_line :: "p_point \<Rightarrow> p_point \<Rightarrow> p_line" is poincare_line proof- fix u v show "is_poincare_line (poincare_line u v)" proof (cases "u \<noteq> v") case True thus ?thesis by simp next text\<open>This branch must work only for formal reasons.\<close> case False thus ?thesis by (transfer, transfer, auto simp add: hermitean_def mat_adj_def mat_cnj_def split: if_split_asm) qed qed text \<open>Next we show how to lift some lemmas. This could be done for all the lemmas that we have proved earlier, but we do not do that.\<close> text \<open>If points are different then the constructed line contains the starting points\<close> lemma p_on_line: assumes "z \<noteq> w" shows "p_incident (p_line z w) z" "p_incident (p_line z w) w" using assms by (transfer, simp)+ text \<open>There is a unique h-line passing trough the two different given h-points\<close> lemma assumes "u \<noteq> v" shows "\<exists>! l. {u, v} \<subseteq> p_points l" using assms apply (rule_tac a="p_line u v" in ex1I, auto simp add: p_points_def p_on_line) apply (transfer, simp add: unique_poincare_line) done text \<open>The unique h-line trough zero and a non-zero h-point on the x-axis is the x-axis\<close> lemma assumes "p_zero \<in> p_points l" "u \<in> p_points l" "u \<noteq> p_zero" "u \<in> p_points p_x_axis" shows "l = p_x_axis" using assms unfolding p_points_def apply simp apply transfer using is_poincare_line_0_real_is_x_axis inf_notin_unit_disc unfolding circline_set_def by blast (* ------------------------------------------------------------------ *) subsection \<open>H-collinearity\<close> (* ------------------------------------------------------------------ *) lift_definition p_collinear :: "p_point set \<Rightarrow> bool" is poincare_collinear done (* ------------------------------------------------------------------ *) subsection \<open>H-isometries\<close> (* ------------------------------------------------------------------ *) text \<open>H-isometries are functions that map the unit disc onto itself\<close> typedef p_isometry = "{f. unit_disc_fix_f f}" by (rule_tac x="id" in exI, simp add: unit_disc_fix_f_def, rule_tac x="id_moebius" in exI, simp) setup_lifting type_definition_p_isometry text \<open>Action of an h-isometry on an h-point\<close> lift_definition p_isometry_pt :: "p_isometry \<Rightarrow> p_point \<Rightarrow> p_point" is "\<lambda> f p. f p" using unit_disc_fix_f_unit_disc by auto text \<open>Action of an h-isometry on an h-line\<close> lift_definition p_isometry_line :: "p_isometry \<Rightarrow> p_line \<Rightarrow> p_line" is "\<lambda> f l. unit_disc_fix_f_circline f l" proof- fix f H assume "unit_disc_fix_f f" "is_poincare_line H" then obtain M where "unit_disc_fix M" and *: "f = moebius_pt M \<or> f = moebius_pt M \<circ> conjugate" unfolding unit_disc_fix_f_def by auto show "is_poincare_line (unit_disc_fix_f_circline f H)" using * proof assume "f = moebius_pt M" thus ?thesis using \<open>unit_disc_fix M\<close> \<open>is_poincare_line H\<close> using unit_disc_fix_f_circline_direct[of M f H] by auto next assume "f = moebius_pt M \<circ> conjugate" thus ?thesis using \<open>unit_disc_fix M\<close> \<open>is_poincare_line H\<close> using unit_disc_fix_f_circline_indirect[of M f H] by auto qed qed text \<open>An example lemma about h-isometries.\<close> text \<open>H-isometries preserve h-collinearity\<close> lemma p_collinear_p_isometry_pt [simp]: shows "p_collinear (p_isometry_pt M ` A) \<longleftrightarrow> p_collinear A" proof- have *: "\<forall> M A. ((\<lambda>x. moebius_pt M (conjugate x)) ` A = moebius_pt M ` (conjugate ` A))" by auto show ?thesis by transfer (auto simp add: unit_disc_fix_f_def *) qed (* ------------------------------------------------------------------ *) subsection \<open>H-distance and h-congruence\<close> (* ------------------------------------------------------------------ *) lift_definition p_dist :: "p_point \<Rightarrow> p_point \<Rightarrow> real" is poincare_distance done definition p_congruent :: "p_point \<Rightarrow> p_point \<Rightarrow> p_point \<Rightarrow> p_point \<Rightarrow> bool" where [simp]: "p_congruent u v u' v' \<longleftrightarrow> p_dist u v = p_dist u' v'" lemma assumes "p_dist u v = p_dist u' v'" assumes "p_dist v w = p_dist v' w'" assumes "p_dist u w = p_dist u' w'" shows "\<exists> f. p_isometry_pt f u = u' \<and> p_isometry_pt f v = v' \<and> p_isometry_pt f w = w'" using assms apply transfer using unit_disc_fix_f_congruent_triangles by auto text\<open>We prove that unit disc equipped with Poincar\'e distance is a metric space, i.e. an instantiation of @{term metric_space} locale.\<close> instantiation p_point :: metric_space begin definition "dist_p_point = p_dist" definition "(uniformity_p_point :: (p_point \<times> p_point) filter) = (INF e\<in>{0<..}. principal {(x, y). dist_class.dist x y < e})" definition "open_p_point (U :: p_point set) = (\<forall> x \<in> U. eventually (\<lambda>(x', y). x' = x \<longrightarrow> y \<in> U) uniformity)" instance proof fix x y :: p_point show "(dist_class.dist x y = 0) = (x = y)" unfolding dist_p_point_def by (transfer, simp add: poincare_distance_eq_0_iff) next fix x y z :: p_point show "dist_class.dist x y \<le> dist_class.dist x z + dist_class.dist y z" unfolding dist_p_point_def apply transfer using poincare_distance_triangle_inequality poincare_distance_sym by metis qed (simp_all add: open_p_point_def uniformity_p_point_def) end (* ------------------------------------------------------------------ *) subsection \<open>H-betweennes\<close> (* ------------------------------------------------------------------ *) lift_definition p_between :: "p_point \<Rightarrow> p_point \<Rightarrow> p_point \<Rightarrow> bool" is poincare_between done end
[STATEMENT] lemma [code]: "IArray.all p = Not \<circ> IArray.exists (Not \<circ> p)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. IArray.all p = Not \<circ> IArray.exists (Not \<circ> p) [PROOF STEP] by (simp add: fun_eq_iff)
import Mathlib.Tactic.LibrarySearch import Mathlib.Util.AssertNoSorry import Mathlib.Algebra.Order.Ring.Canonical noncomputable section set_option maxHeartbeats 400000 in example (x : Nat) : x ≠ x.succ := ne_of_lt (by library_search) example : 0 ≠ 1 + 1 := ne_of_lt (by library_search) example (x y : Nat) : x + y = y + x := by library_search example (n m k : Nat) : n ≤ m → n + k ≤ m + k := by library_search example (ha : a > 0) (w : b ∣ c) : a * b ∣ a * c := by library_search example : Int := by library_search example : x < x + 1 := library_search% example (P : Prop) (p : P) : P := by library_search example (P : Prop) (p : P) (np : ¬P) : false := by library_search example (X : Type) (P : Prop) (x : X) (h : ∀ x : X, x = x → P) : P := by library_search example (α : Prop) : α → α := by library_search -- says: `exact id` -- Note: these examples no longer work after we turned off lemmas with discrimination key `#[*]`. -- example (p : Prop) : (¬¬p) → p := by library_search -- says: `exact not_not.mp` -- example (a b : Prop) (h : a ∧ b) : a := by library_search -- says: `exact h.left` -- example (P Q : Prop) : (¬ Q → ¬ P) → (P → Q) := by library_search -- say: `exact Function.mtr` example (a b : ℕ) : a + b = b + a := by library_search -- says: `exact add_comm a b` example (n m k : ℕ) : n * (m - k) = n * m - n * k := by library_search -- says: `exact Nat.mul_sub_left_distrib n m k` example (n m k : ℕ) : n * m - n * k = n * (m - k) := by library_search -- says: `exact Eq.symm (mul_tsub n m k)` example {α : Type} (x y : α) : x = y ↔ y = x := by library_search -- says: `exact eq_comm` example (a b : ℕ) (ha : 0 < a) (_hb : 0 < b) : 0 < a + b := by library_search section synonym example (a b : ℕ) (ha : a > 0) (_hb : 0 < b) : 0 < a + b := by library_search example (a b : ℕ) (h : a ∣ b) (w : b > 0) : a ≤ b := by library_search -- says: `exact Nat.le_of_dvd w h` example (a b : ℕ) (h : a ∣ b) (w : b > 0) : b ≥ a := by library_search -- says: `exact Nat.le_of_dvd w h` -- TODO: A lemma with head symbol `¬` can be used to prove `¬ p` or `⊥` example (a : ℕ) : ¬ (a < 0) := by library_search -- says `exact not_lt_bot` example (a : ℕ) (h : a < 0) : False := by library_search -- says `exact Nat.not_succ_le_zero a h` -- An inductive type hides the constructor's arguments enough -- so that `library_search` doesn't accidentally close the goal. inductive P : ℕ → Prop | gt_in_head {n : ℕ} : n < 0 → P n -- This lemma with `>` as its head symbol should also be found for goals with head symbol `<`. theorem lemma_with_gt_in_head (a : ℕ) (h : P a) : 0 > a := by cases h; assumption -- This lemma with `false` as its head symbols should also be found for goals with head symbol `¬`. theorem lemma_with_false_in_head (a b : ℕ) (_h1 : a < b) (h2 : P a) : False := by apply Nat.not_lt_zero; cases h2; assumption example (a : ℕ) (h : P a) : 0 > a := by library_search -- says `exact lemma_with_gt_in_head a h` example (a : ℕ) (h : P a) : a < 0 := by library_search -- says `exact lemma_with_gt_in_head a h` example (a b : ℕ) (h1 : a < b) (h2 : P a) : False := by library_search -- says `exact lemma_with_false_in_head a b h1 h2` -- TODO example (a b : ℕ) (h1 : a < b) : ¬ (P a) := by library_search -- says `exact lemma_with_false_in_head a b h1` end synonym example : ∀ P : Prop, ¬(P ↔ ¬P) := by library_search -- We even find `iff` results: example {a b c : ℕ} (h₁ : a ∣ c) (h₂ : a ∣ b + c) : a ∣ b := by library_search -- says `exact (Nat.dvd_add_iff_left h₁).mpr h₂` -- Note: these examples no longer work after we turned off lemmas with discrimination key `#[*]`. -- example {α : Sort u} (h : Empty) : α := by library_search -- says `exact Empty.elim h` -- example (f : A → C) (g : B → C) : (A ⊕ B) → C := by library_search -- says `exact Sum.elim f g` -- example (n : ℕ) (r : ℚ) : ℚ := by library_search using n, r -- exact nsmulRec n r opaque f : ℕ → ℕ axiom F (a b : ℕ) : f a ≤ f b ↔ a ≤ b example (a b : ℕ) (h : a ≤ b) : f a ≤ f b := by library_search example (L _M : List (List ℕ)) : List ℕ := by library_search using L example (P _Q : List ℕ) (h : ℕ) : List ℕ := by library_search using h, P example (l : List α) (f : α → β ⊕ γ) : List β × List γ := by library_search using f -- partitionMap f l example (n m : ℕ) : ℕ := by library_search using n, m -- exact rightAdd n m example (P Q : List ℕ) (_h : ℕ) : List ℕ := by library_search using P, Q -- exact P ∩ Q -- Check that we don't use sorryAx: -- (see https://github.com/leanprover-community/mathlib4/issues/226) theorem Bool_eq_iff {A B: Bool} : (A = B) = (A ↔ B) := by (cases A <;> cases B <;> simp) theorem Bool_eq_iff2 {A B: Bool} : (A = B) = (A ↔ B) := by library_search -- exact Bool_eq_iff assert_no_sorry Bool_eq_iff2
# # # modified to get quantile function # # this code is not efficient but should be OK for case of # # pair-copulas all permutation symmetric # # # Different copula family for each edge # # nsim = #replications or sample size # # parvec = vector of parameters to be optimized in nllk # # A = dxd vine array with 1:d on diagonal # # ntrunc = truncated level, assume >=1 # # pcondmat = matrix of names of conditional cdfs for trees 1,...,ntrunc # # (assuming only one needed for permutation symmetric pair-copulas) # # qcondmat = matrix of names of conditional quantile functions for # # trees 1,...,ntrunc # # pcondmat and qcondmat are empty for diagonal and lower triangle, # # and could have ntrunc rows or be empty for rows ntrunc+1 to d-1 # # np = dxd where np[ell,j] is #parameters for parameter th[ell,j] # # for pair-copula in tree ell, variables j and A[ell,j] # # np=0 on and below diagonal # # iinv=T to check that this is inverse of rvinepcond() # # in this case, columns of pmat come from rvinepcond() # # iinv=F, get quantiles C_{d|1:(d-1)}(p|u[1:(d-1)]) based on last column of # # pmat[,d] where u[1],..,u[d-1] have been previously converted to # # u[1], C_{2|1}(u[2]|u[1]), ... C_{d-1|1:(d-2)}(u[d-1]|u[1:(d-2)]) # # via rvinepcond() # ## Output: nsim x d matrix with values in (0,1) or # # quantile C_{d|1...d-1}(p| u1,...,u[d-1]) # #rvinesimvec2=function(nsim,A,ntrunc,parvec,np,qcondmat,pcondmat,iprint=F) # temrvineqcond=function(pmat,A,ntrunc,parvec,np,qcondmat,pcondmat,iinv=F) # { d=ncol(A) # # get matrix ip1,ip2 of indices # ii=0 # ip1=matrix(0,d,d); ip2=matrix(0,d,d) # for(ell in 1:ntrunc) # { for(j in (ell+1):d) # { ip1[ell,j]=ii+1; ip2[ell,j]=ii+np[ell,j] # ii=ii+np[ell,j] # } # } # #if(iprint) { print(ip1); print(ip2) } # out=varray2M(A) # M=out$mxarray # icomp=out$icomp # #p=matrix(runif(nsim*d),nsim,d) # p=pmat # nsim=nrow(p) # qq=array(0,c(nsim,d,d)); v=array(0,c(nsim,d,d)) # u=matrix(0,nsim,d) # u[,1]=p[,1]; qq[,1,1]=p[,1]; qq[,2,2]=p[,2]; # qcond=match.fun(qcondmat[1,2]) # u[,2]=qcond(p[,2],p[,1],parvec[ip1[1,2]:ip2[1,2]]) # qq[,1,2]=u[,2] # if(icomp[1,2]==1) # { #pcond=match.fun(pcondnames[1]) # pcond=match.fun(pcondmat[1,2]) # v[,1,2]=pcond(u[,1],u[,2],parvec[ip1[1,2]:ip2[1,2]]) # } # # the main loop # for(j in 3:d) # variable # { tt=min(ntrunc,j-1) # qq[,tt+1,j]=p[,j] # if(tt>1) # { for(ell in seq(tt,2)) # tree # { if(A[ell,j]==M[ell,j]) { s= qq[,ell,A[ell,j]] } # else { s=v[,ell-1,M[ell,j]] } # #qcond=match.fun(qcondnames[ell]) # qcond=match.fun(qcondmat[ell,j]) # qq[,ell,j]=qcond(qq[,ell+1,j], s, parvec[ip1[ell,j]:ip2[ell,j]]); # } # } # #qcond=match.fun(qcondnames[1]) # qcond=match.fun(qcondmat[1,j]) # qq[,1,j]=qcond(qq[,2,j],u[,A[1,j]], parvec[ip1[1,j]:ip2[1,j]]) # u[,j]=qq[,1,j] # # set up for next iteration (not needed for last j=d) # #pcond=match.fun(pcondnames[1]) # pcond=match.fun(pcondmat[1,j]) # v[,1,j]=pcond(u[,A[1,j]],u[,j],parvec[ip1[1,j]:ip2[1,j]]) # if(tt>1) # { for(ell in 2:tt) # { if(A[ell,j]==M[ell,j]) { s=qq[,ell,A[ell,j]] } # else { s=v[,ell-1,M[ell,j]] } # if(icomp[ell,j]==1) # { #pcond=match.fun(pcondnames[ell]) # pcond=match.fun(pcondmat[ell,j]) # v[,ell,j]=pcond(s, qq[,ell,j], parvec[ip1[ell,j]:ip2[ell,j]]); # } # } # } # } # if(iinv) u=u[,d] # u # } # # #============================================================ # # library(CopulaModel) # source("hjcondvine.R") # d=5 # np=matrix(1,d,d) # ntrunc=4 # udat=matrix(c(.1,.2,.3,.4,.5, .6,.7,.8,.9,.5),2,5,byrow=T) # parvec=c(2,2,2,2,1.5,1.5,1.5,1.2,1.2,1.1) # D5=Dvinearray(d) # pcondmat=matrix("pcondgum",d,d) # qcondmat=matrix("qcondgum",d,d) # # pmatd=rvinepcond(parvec,udat,D5,ntrunc,pcondmat,np) # print(pmatd) # # #rvineqcond=function(pmat,A,ntrunc,parvec,np,qcondmat,pcondmat,iprint=F) # # qmatd=temrvineqcond(pmatd,D5,ntrunc,parvec,np,qcondmat,pcondmat,iinv=F) # print(qmatd) # same as udat # # q5=temrvineqcond(pmatd,D5,ntrunc,parvec,np,qcondmat,pcondmat,iinv=T) # print(q5) # # [1] 0.5 0.5 # pnewd=pmatd; pnewd[,d]=0.9 # q5b=temrvineqcond(pnewd,D5,ntrunc,parvec,np,qcondmat,pcondmat,iinv=T) # print(q5b) # # [1] 0.5227173 0.8994989 # # # direct approach # ntrunc=4 # pcond=pcondgum # qcond=qcondgum # parm=matrix(0,d,d) # format of parameter for vine # ii=0; # for(ell in 1:ntrunc) # { for(j in (ell+1):d) # { parm[ell,j]=parvec[ii+1] # ii=ii+1 # } # } # # # compared with specific case for dvine # pdchk=udat # pdchk[,2]=pcond(udat[,2],udat[,1],parm[1,2]) # tem12=pcond(udat[,1],udat[,2],parm[1,2]) # tem32=pcond(udat[,3],udat[,2],parm[1,3]) # pdchk[,3]=pcond(tem32,tem12,parm[2,3]) # tem1g23=pcond(tem12,tem32,parm[2,3]) # tem23=pcond(udat[,2],udat[,3],parm[1,3]) # tem43=pcond(udat[,4],udat[,3],parm[1,4]) # tem4g23=pcond(tem43,tem23,parm[2,4]) # pdchk[,4]=pcond(tem4g23,tem1g23,parm[3,4]) # tem1g234=pcond(tem1g23,tem4g23,parm[3,4]) # tem34=pcond(udat[,3],udat[,4],parm[1,4]) # tem54=pcond(udat[,5],udat[,4],parm[1,5]) # tem5g34=pcond(tem54,tem34,parm[2,5]) # tem2g34=pcond(tem23,tem43,parm[2,4]) # tem5g234=pcond(tem5g34,tem2g34,parm[3,5]) # pdchk[,5]=pcond(tem5g234,tem1g234,parm[4,5]) # # quantiles at .9 # p=rep(.9,2) # s2=qcond(p,tem1g234,parm[4,5]) # s3=qcond(s2,tem2g34,parm[3,5]) # s4=qcond(s3,tem34,parm[2,5]) # s5=qcond(s4,udat[,4],parm[1,5]) # print(s5) # # 1] 0.5227173 0.8994989 # # #============================================================ # # # truncated vines # # # ntrunc=2 # pmatd2=rvinepcond(parvec,udat,D5,2,pcondmat,np) # # [,1] [,2] [,3] [,4] [,5] # #[1,] 0.1 0.4938008 0.7385935 0.7430672 0.76377507 # #[2,] 0.6 0.7328919 0.8830648 0.9508236 0.08757126 # qmatd2=temrvineqcond(pmatd2,D5,2,parvec,np,qcondmat,pcondmat,iinv=F) # print(qmatd2) # same as udat # q52=temrvineqcond(pmatd2,D5,2,parvec,np,qcondmat,pcondmat,iinv=T) # print(q52) # # [1] 0.5 0.5 # pnewd=pmatd2; pnewd[,d]=0.9 # q52b=temrvineqcond(pnewd,D5,2,parvec,np,qcondmat,pcondmat,iinv=T) # print(q52b) # # [1] 0.6190225 0.9281953 # # # ntrunc=1 # pmatd1=rvinepcond(parvec,udat,D5,1,pcondmat,np) # # [,1] [,2] [,3] [,4] [,5] # #[1,] 0.1 0.4938008 0.5364857 0.5842195 0.63198274 # #[2,] 0.6 0.7328919 0.7951641 0.8831572 0.08282512 # qmatd1=temrvineqcond(pmatd1,D5,1,parvec,np,qcondmat,pcondmat,iinv=F) # print(qmatd1) # same as udat # q51=temrvineqcond(pmatd1,D5,1,parvec,np,qcondmat,pcondmat,iinv=T) # print(q51) # # [1] 0.5 0.5 # pnewd=pmatd1; pnewd[,d]=0.9 # q51b=temrvineqcond(pnewd,D5,1,parvec,np,qcondmat,pcondmat,iinv=T) # print(q51b) # # [1] 0.7332716 0.9529803 #
# Course Statistics for Data Scientists 2019-2020 # Case Study Linear Mixed Models #reading the data from file mydata<-read.table('DATARationSplitPlot.txt',header=T) mydata attach(mydata) # changing variates to factors Pair<-factor(pair) Ration<-factor(ration) Sex<-factor(sex,labels=c('male','female')) ...
[STATEMENT] lemma SUP_sup_distrib: fixes f :: "V \<Rightarrow> V" shows "small A \<Longrightarrow> (\<Squnion>x\<in>A. f x \<squnion> g x) = \<Squnion> (f ` A) \<squnion> \<Squnion> (g ` A)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. small A \<Longrightarrow> (\<Squnion>x\<in>A. f x \<squnion> g x) = \<Squnion> (f ` A) \<squnion> \<Squnion> (g ` A) [PROOF STEP] by (force simp:)
The New York Times offers quite a bit of video content these days, so naturally someone went and made a Kodi addon for it. They’re content is mostly news related, but some of the content is also entertaining, while being informative at the same time. This is a good addon for when you want to watch something quick and interesting, or looking to kill time watching news coverage. It might not be the number one addon, but the New York Times Video addon is certainly worth the price is costs. The New York Times Video addon for Kodi can be installed in a matter of seconds, since the official Kodi repository is already available on every Kodi device. Installation is far simpler than it would be to install unofficial addons, and basically requires the flip of a switch. Since we’re such nice people, we’re going to walk you through each step of the New York Times Video addon installation process. Step 6: Choose the New York Times Video Kodi addon from the listing. Step 9: Launch the New York Times Video addon from the Video add-ons tab. Step 10: Choose the International section and browse! Thank you to netw1z for developing this addon, giving the Kodi world access to all the video content that the New York Times has to offer. There are often interesting mini broadcasts that cover a wide range of global topics. We hope you enjoy the New York Times Video addon as much as we do!
lemma homotopy_eqv_trans [trans]: assumes 1: "X homotopy_equivalent_space Y" and 2: "Y homotopy_equivalent_space U" shows "X homotopy_equivalent_space U"
/* *** Copyright Notice *** If you have questions about your rights to use or distribute this software, please contact Berkeley Lab's Intellectual Property Office at [email protected]. NOTICE. This Software was developed under funding from the U.S. Department of Energy and the U.S. Government consequently retains certain rights. As such, the U.S. Government has been granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the Software to reproduce, distribute copies to the public, prepare derivative works, and perform publicly and display publicly, and to permit other to do so. **************************** *** License Agreement *** 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 University of California, Lawrence Berkeley National Laboratory, U.S. Dept. of Energy, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. You are under no obligation whatsoever to provide any bug fixes, patches, or upgrades to the features, functionality or performance of the source code ("Enhancements") to anyone; however, if you choose to make your Enhancements available either publicly, or directly to Lawrence Berkeley National Laboratory, without imposing a separate written license agreement for such Enhancements, then you hereby grant the following license: a non-exclusive, royalty-free perpetual license to install, use, modify, prepare derivative works, incorporate into other computer software, distribute, and sublicense such enhancements or derivative works thereof, in binary and source code form. --------------------------------------------------------------- */ /* * File: serviceInstanceTemplateApp2.cpp * Author: mcp * * Created on January 24, 2016, 5:01 PM */ #include <stdint.h> #include <iostream> #include <fstream> #include <chrono> #include <thread> #include <atomic> #include <set> #include <mutex> #include <pqxx/pqxx> #include "cassandra.h" #include <curl/curl.h> #include <boost/make_shared.hpp> #include <boost/thread.hpp> #include <boost/ref.hpp> #include <boost/any.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/dll/alias.hpp> #include <boost/thread/condition.hpp> #include <log4cpp/Appender.hh> #include <log4cpp/Category.hh> #include <log4cpp/FileAppender.hh> #include <log4cpp/OstreamAppender.hh> #include <log4cpp/Layout.hh> #include <log4cpp/BasicLayout.hh> #include <log4cpp/Priority.hh> #include "dbConnection.h" #include "domainAndMessageTypes.h" #include "serviceCommand.h" #include "serviceCommandQueueTemplate.h" #include "serviceInstanceApi.h" #include "serviceInstance.h" #include "serviceInstanceList.h" #include "serviceStatus.h" #include "serviceDataBuffer.h" #include "serviceOperationsLoggerPostgres.h" #include "serviceOperationsLoggerCassandra.h" #include "upmuFtpAccess.h" #include "upmuStructKeyValueListProtobuf.pb.h" using namespace serviceCommon; #include "serviceCommonStats.h" #include "serviceSpecificStats.h" #include "uPMUgmtime.h" #include "serviceDataDiscovery.h" #define IS_BIG_ENDIAN (*(uint16_t *)"\0\xff" < 0x100) namespace serviceDataDiscovery { using namespace pqxx; using namespace serviceCommon; using namespace boost; serviceDataDiscovery::serviceDataDiscovery() { std::cout<< "Creating serviceDataDiscovery" << std::endl; cmdQueue = new SynchronisedCommandQueue<SERVICE_COMMAND *>(CMD_QUEUE_LEN); m_thread=NULL; m_mustStop=false; m_msg_num=0; serviceStatus = NOT_STARTED; } serviceDataDiscovery::~serviceDataDiscovery() { std::cout<< "Destroying serviceDataDiscovery" << std::endl; if (m_thread!=NULL) delete m_thread; } // Start the thread void serviceDataDiscovery::start() { // Create thread and start it with myself as argument. // Pass myself as reference since I don't want a copy m_mustStop = false; /* start thread. operator() () is the function executed */ m_thread=new boost::thread(boost::ref(*this)); } // Stop the thread void serviceDataDiscovery::stop() { // Signal the thread to stop (thread-safe) serviceStatus = STOPPING; m_mustStopMutex.lock(); m_mustStop=true; m_mustStopMutex.unlock(); // notify running thread wake_up.notify_one(); // Wait for the thread to finish. if (m_thread!=NULL) m_thread->join(); } dataBufferOffer_t serviceDataDiscovery::dataBufferOffer( const std::shared_ptr<serviceDataBuffer>& offeredBuf) { //std::cout<< "serviceDataDiscovery::dataBufferOffer" << std::endl; /* this service does not accept buffers */ return BUFFER_REFUSED; } // Thread function void serviceDataDiscovery::operator () () { /* init some local flags */ bool localMustStop = false; SERVICE_COMMAND * cmd; serviceStatus = RUNNING; /* create log4cpp related appender objects for this service. */ logger_serviceDataDiscovery.addAppender(logger_appender); /* log startup message */ logger_serviceDataDiscovery.info("serviceDataDiscovery starting."); if(!initService()) { /* log error and exit*/ logger_serviceDataDiscovery.error("Could not complete initialization, exiting."); return; } try { while(!localMustStop) { /* always check for possible command */ cmd = cmdQueue->Dequeue(); if(cmd != 0) { processCmd(cmd); } processUPMUdata(); /* sleep for a bit. Interval changes based on operating mode. */ if(scanMode == normal) { std::this_thread::sleep_for(std::chrono::seconds(SCAN_MODE_NORMAL_DELAY_SEC)); } else if(scanMode == catch_up) { std::this_thread::sleep_for(std::chrono::seconds(SCAN_MODE_CATCH_UP_DELAY_SEC)); } else { std::this_thread::sleep_for(std::chrono::seconds(1)); } // Get the "must stop" state (thread-safe) m_mustStopMutex.lock(); localMustStop=m_mustStop; m_mustStopMutex.unlock(); } // exiting function kills thread serviceStatus = NORMAL_STOP; logger_serviceDataDiscovery.info("Normal (requested) service stop."); return; } catch (const std::exception &e) { serviceStatus = ERROR_STOP; logger_serviceDataDiscovery.error("Abnormal (error) service stop."); return; } }; void serviceDataDiscovery::processCmd(SERVICE_COMMAND * cmd) { std::cout<< " Process a command." << std::endl; } bool serviceDataDiscovery::initService() { /* init service data structures */ createServiceCommonStats(this); createServiceSpecificStats(this); /* init file length tracker and initial serviceState. */ mostRecentDataFileLength = 0; scanMode = catch_up; serviceState = STATE_CATCH_UP; /* get a db connection for local database */ dbConn = dbConnection::getInstance(); if(dbConn->conn == NULL) { /* log an error and exit. */ return false; } /* prepare any postgres statements used regularly */ dbConn->acquireDBaccess(); (dbConn->conn)->prepare("add_dir_record", "INSERT INTO upmu_data_directory (year, month, day, hour, " "dir_name, state, discovery_time, release_time) VALUES " "($1, $2, $3, $4, $5, $6, " "NOW(), NULL)"); (dbConn->conn)->prepare("get_dir_record_key", "SELECT currval('upmu_data_directory_id_seq')"); (dbConn->conn)->prepare("release_dir_record", "UPDATE upmu_data_directory SET (state, release_time) = ('processed', NOW()) WHERE id = $1"); (dbConn->conn)->prepare("abandon_dir_record", "UPDATE upmu_data_directory SET (state, release_time) = ('abandoned', NOW()) WHERE id = $1"); (dbConn->conn)->prepare("update_dir_record_state", "UPDATE upmu_data_directory SET state = $1 WHERE id = $2"); (dbConn->conn)->prepare("add_data_record", "INSERT INTO upmu_data_file (file_name, directory, state, " "access_start_time, release_time) VALUES " "($1, $2, $3, NOW(), NULL)"); (dbConn->conn)->prepare("release_data_record", "UPDATE upmu_data_file SET (state, release_time) = ('released', NOW()) WHERE id = $1"); (dbConn->conn)->prepare("abandon_data_record", "UPDATE upmu_data_file SET (state, release_time) = ('abandoned', NOW()) WHERE id = $1"); (dbConn->conn)->prepare("get_data_record_key", "SELECT currval('upmu_data_file_id_seq')"); (dbConn->conn)->prepare("search_data_record_by_dir_index", "SELECT * FROM upmu_data_file WHERE directory = $1"); dbConn->releaseDBaccess(); logger_serviceDataDiscovery.info("Postgres statements prepared."); /* declare uPMUgateway started at this point. Note: startup message always contains sessionID and major/minor version info. Also, these params are ad hoc in the gateway; but are part of standard plugin statistices package in plugins. */ postgresOperationsLogger->createStringOperationsRecord(dbConn, serviceState, upmuSerialNumber, sessionID, serviceName, "Service_Startup_Msg", "Initialized, looking for current directory on uPMU."); postgresOperationsLogger->createStringOperationsRecord(dbConn, serviceState, upmuSerialNumber, sessionID, serviceName, (*serviceSpecStatsLabels)[INDX_STR_DATA_DISCOVERY_MAJ_VER]->c_str(), any_cast<std::string *>((*serviceSpecStatsValues)[INDX_STR_DATA_DISCOVERY_MAJ_VER])->c_str()); postgresOperationsLogger->createStringOperationsRecord(dbConn, serviceState, upmuSerialNumber, sessionID, serviceName, (*serviceSpecStatsLabels)[INDX_STR_DATA_DISCOVERY_MIN_VER]->c_str(), any_cast<std::string *>((*serviceSpecStatsValues)[INDX_STR_DATA_DISCOVERY_MIN_VER])->c_str()); if(cassArchivingEnabled && cassConnected) { /* make a KeyValueList to log similar message to cassandra, if available.*/ upmuStructKeyValueList * kvList = new upmuStructKeyValueList(); createServiceStartupKeyValueList(kvList); uint32_t byteLen = kvList->ByteSize(); void * pbBuffer = std::malloc(byteLen); if(pbBuffer != nullptr) { kvList->SerializeToArray(pbBuffer, byteLen); cassandraOperationsLogger->cassandraArchive(cassPreparedOperations, cassSession, (uint64_t)kvList->timestamp(), sessionID, serviceName, upmuSerialNumber, DOMAIN_OPERATIONS, MSG_KEY_VALUE_LIST, pbBuffer, byteLen); try{ std::free(pbBuffer); } catch(...){ } } else { logger_serviceDataDiscovery.error("Cannot form serialized protocol buffer, " "insufficient memory."); } } /* create several structures used throughout thread */ dataDir = new DATA_DIR(); int sts =getCurrentDirectory(); if(sts != DATA_DIR_OK) { return false; } sts = getCurrentDataFileSet(); if(sts != DATA_DIR_OK) { return false; } return true; } void serviceDataDiscovery::createServiceStartupKeyValueList(upmuStructKeyValueList * kvList) { kvList->set_name("Service_Startup_Info"); uint32_t startTime = (uint32_t)time(NULL); kvList->set_timestamp(startTime); KeyValueList * list = kvList->add_list(); list->set_category("ServiceStatus"); /* add a few key values */ serviceSpecStatsMutex.lock(); KeyValue * pair = list->add_element(); pair->set_key((*serviceSpecStatsLabels)[INDX_STR_DATA_DISCOVERY_MAJ_VER]->c_str()); pair->set_stringval(any_cast<std::string *> ((*serviceSpecStatsValues)[INDX_STR_DATA_DISCOVERY_MAJ_VER])->c_str()); pair = list->add_element(); pair->set_key((*serviceSpecStatsLabels)[INDX_STR_DATA_DISCOVERY_MIN_VER]->c_str()); pair->set_stringval(any_cast<std::string *> ((*serviceSpecStatsValues)[INDX_STR_DATA_DISCOVERY_MIN_VER])->c_str()); serviceSpecStatsMutex.unlock(); } int serviceDataDiscovery::getCurrentDirectory() { try { /* get list of current data directory - if we have one */ bool startingDirInDB = false; dbConn->acquireDBaccess(); nontransaction n(*(dbConn->conn)); result r = n.exec("SELECT * FROM upmu_data_directory WHERE state = 'current'"); if(r.size() == 1) { dataDir->year = r[0]["\"year\""].as<int>(); dataDir->month = r[0]["\"month\""].as<int>(); if((dataDir->month < 1) || (dataDir->month >12)) { /* month not in correct range */ n.commit(); dbConn->releaseDBaccess(); return DATA_DIR_ERROR; } dataDir->day = r[0]["\"day\""].as<int>(); if(dataDir->day <= 0) { /* days start at 1, not in correct range */ n.commit(); dbConn->releaseDBaccess(); return DATA_DIR_ERROR; } dataDir->hour = r[0]["\"hour\""].as<int>(); dataDir->dbID = r[0]["\"id\""].as<int>(); dataDir->dirName = upmuFtpAccess::createDirName_YrMonDayHr(dataDir); dataDir->state = current; startingDirInDB = true; } else { result r = n.exec("SELECT * FROM upmu_data_directory WHERE state = 'processed'" " ORDER BY id DESC LIMIT 1"); if(r.size() == 1) { dataDir->year = r[0]["\"year\""].as<int>(); dataDir->month = r[0]["\"month\""].as<int>(); if((dataDir->month < 1) || (dataDir->month >12)) { /* month not in correct range */ n.commit(); dbConn->releaseDBaccess(); return DATA_DIR_ERROR; } dataDir->day = r[0]["\"day\""].as<int>(); if(dataDir->day <= 0) { /* days start at 1, not in correct range */ n.commit(); dbConn->releaseDBaccess(); return DATA_DIR_ERROR; } dataDir->hour = r[0]["\"hour\""].as<int>(); dataDir->dbID = r[0]["\"id\""].as<int>(); dataDir->dirName = upmuFtpAccess::createDirName_YrMonDayHr(dataDir); dataDir->state = processed; startingDirInDB = true; } } if(!startingDirInDB) { /* there is no current uPMU data directory, s propose one */ dataDir->year = DEFAULT_STARTING_YEAR; dataDir->month = DEFAULT_STARTING_MONTH; dataDir->day = DEFAULT_STARTING_DAY; dataDir->hour = DEFAULT_STARTING_HOUR; dataDir->dirName = upmuFtpAccess::createDirName_YrMonDayHr(dataDir); dataDir->state = proposed; } /* close transaction */ n.commit(); dbConn->releaseDBaccess(); unsigned int et = upmuFtpAccess::createTimeFromDataDir(dataDir); dataDir->epochDay = et / 86400; /* loop til most recent directory is found */ bool termLoop = false; bool ftpError = false; dataDirValid = false; mostRecentDataFileNameValid = false; int sts; while (!termLoop) { /* deal with special case that we have no current dir, but have latest processed account. In that case, we need to inc directory before checking for availability. */ if(dataDir->state == processed) { sts = upmuFtpAccess::incDataDir(dataDir); if(sts == DATA_DIR_AT_PRESENT) { dataDirValid = false; termLoop = true; return NO_DATA_DIR; } } /* is directory valid? */ sts = upmuFtpAccess::verifyDataDirPresent(dataDir->dirName); if(sts == FTP_NOT_RESP) { /* ftp error */ ftpError = true; dataDirValid = false; termLoop = true; } else if(sts == DIR_PRESENT) { /* dirctory present - are we finished processing it? */ std::cout << "Directory Present: " << dataDir->dirName << std::endl; if(dataDir->state == proposed) { /* save proposed directory in db as current dir */ dbConn->acquireDBaccess(); work w(*(dbConn->conn)); w.prepared("add_dir_record")(dataDir->year)(dataDir->month)\ (dataDir->day)(dataDir->hour)((dataDir->dirName).c_str())\ ("current").exec(); w.commit(); /* select it so we can use common code at end of this section. */ nontransaction n(*(dbConn->conn)); r = n.exec("SELECT * FROM upmu_data_directory WHERE state = 'current'"); n.commit(); dataDir->dbID = r[0]["\"id\""].as<int>(); dbConn->releaseDBaccess(); dataDir->state = current; } dataDirValid = true; termLoop = true; } else { std::cout << "Directory Not Present: " << dataDir->dirName.c_str() << std::endl; if(dataDir->state == current) { /* we need to move to new directory, mark this one as abandoned */ dbConn->acquireDBaccess(); work w(*(dbConn->conn)); w.prepared("abandon_dir_record")(dataDir->dbID).exec(); w.commit(); dbConn->releaseDBaccess(); } sts = upmuFtpAccess::incDataDir(dataDir); if(sts == DATA_DIR_AT_PRESENT) { dataDirValid = false; termLoop = true; } } } return DATA_DIR_OK; } catch (const std::exception &e) { /* log error */ std::cerr << e.what() << std::endl; return NO_DATA_DIR; } } int serviceDataDiscovery::getCurrentDataFileSet() { try { dbConn->acquireDBaccess(); nontransaction n(*(dbConn->conn)); result r = n.prepared("search_data_record_by_dir_index")(dataDir->dbID).exec(); n.commit(); if(r.size() == 0) { /* no data files from this directory have been processed. Set scan context variables as needed. Note, data processing sets will properly initialized in upmuProcessData(). */ dataDirAccessInProgress = false; } else { dataFilesInDir.clear(); dataFilesProcessed.clear(); dataDirAccessInProgress = true; for (pqxx::result::const_iterator row = r.begin(); row != r.end(); row++) { /* get important fields into local variables */ pqxx::result::field field = row->at("state"); std::string s = field.as<std::string>(); if((s == "abandoned") || (s == "released")) { /* we have dealt with this file. */ field = row->at("file_name"); std::string t = field.as<std::string>(); dataFilesProcessed.insert(t); } } } dbConn->releaseDBaccess(); return DATA_DIR_OK; } catch (const std::exception &e) { /* log error */ dbConn->releaseDBaccess(); } return DATA_DIR_ERROR; } int serviceDataDiscovery::addDataFile2DB(upmuFtpAccess * upmuDaq, std::string fileName, const std::string& status) { return 0; } int serviceDataDiscovery::processUPMUdata() { if(dataDirValid) { if(!dataDirAccessInProgress) { dataDirAccessInProgress = true; time(&dataDirAccessStartTime); dataFilesInDir.clear(); dataFilesProcessed.clear(); } if(dataFilesInDir.empty()) { upmuFtpAccess::getDataFileList(&dataFilesInDir, &dataFilesProcessed, &(dataDir->dirName)); /*******/ } if(!dataFilesInDir.empty()) { /* is DataDiscovery service flow controlled? */ if(sharedInMemDataBufferCnt <= MAX_OUTSTANDING_MEM_BUF) { /* process first data file in list */ std::string dataFile = * dataFilesInDir.begin(); /* determine if data file is complete or still being filled */ if(dataFileComplete(&dataFile)) { /* keep a copy for abandon calculation */ mostRecentDataFileNameValid =true; mostRecentDataFileName = dataFile; dataFilesProcessed.insert(dataFile); dataFilesInDir.erase(dataFile); try { unsigned char *dataBufAddr; unsigned int fileLen; /* insert record into upmu_data_file table that documents we are processing this data file. */ work w(*(dbConn->conn)); w.prepared("add_data_record")(dataFile.c_str())(dataDir->dbID) ("processing").exec(); w.commit(); nontransaction n(*(dbConn->conn)); /* get the id for the record we just created. */ result r = n.prepared("get_data_record_key").exec(); n.commit(); int dataRecordID = r[0][0].as<int>(); std::cout << "Data File Processed: " << dataFile.c_str() << std::endl; fileLen = upmuFtpAccess::getDataFile(&(dataDir->dirName), &dataFile, &dataBufAddr); postProcessUPMUdata(dataBufAddr, (unsigned int)fileLen); /* save recent file lengths for future use */ mostRecentDataFileLength = (unsigned int)fileLen; /* Mark the data file record just created as released. */ work w1(*(dbConn->conn)); w1.prepared("release_data_record")(dataRecordID).exec(); w1.commit(); } catch (const std::exception &e) { /* log error */ std::cerr << e.what() << std::endl; return DB_ACCESS_ERROR; } } else { /* data file incomplete or ftp error. retry and hope upmu will become available. */ //DEBUG: std::cout << "Data File Incomplete. " << std::endl; } } } /* are we done with - or need to abandon - this directory? */ if(dataFilesInDir.empty()) { time_t rawt; time(&rawt); if(!dataDirValid) { std::cout << " datDirValid in wrong state." << std::endl; } else { unsigned int dirt = upmuFtpAccess::createTimeFromDataDir(dataDir); if(((unsigned int)rawt - dirt) > 60 * 60) { /* directory is over 1 hr. old, abandon it. */ dataDirValid = false; dataDirAccessInProgress = false; mostRecentDataFileNameValid = false; } } } } if(!dataDirValid) { /* just exhausted data files in this directory */ /* mark this one as done */ if(dataDir->state == current) { /* just finished a current directory, so let's mark it as closed */ try { work w(*(dbConn->conn)); w.prepared("release_dir_record")(dataDir->dbID).exec(); w.commit(); } catch (const std::exception &e) { /* log error */ std::cerr << e.what() << std::endl; return DB_ACCESS_ERROR; } dataDir->state = unknown; dataDirAccessInProgress = false; } int sts = upmuFtpAccess::isDataDirAtPresent(dataDir); if(sts != DATA_DIR_AT_PRESENT) { int sts = upmuFtpAccess::incDataDir(dataDir); } /* we're just beyond the most recent directory */ /* wait here until something shows up in uPMU */ sts = upmuFtpAccess::verifyDataDirPresent(dataDir->dirName); if(sts == DIR_PRESENT) { addCurrentDirectoryRecord(); dataDir->state = current; dataDirValid = true; std::cout << "Directory Present: " << dataDir->dirName << std::endl; } else { if(sts == FTP_NOT_RESP){ std::cout << "FTP connection BROKE, waiting 45minutes to continue: " << std::endl; std::this_thread::sleep_for(std::chrono::minutes(45)); } else{ /*********/ std::cout << "Directory Not Present: " << dataDir->dirName << std::endl; } } } } bool serviceDataDiscovery::dataFileComplete(std::string * dataFile) { time_t rawt; time(&rawt); unsigned int dft = upmuFtpAccess::createTimeFromDataFileName(*dataFile); if(((unsigned int)rawt - dft) > CATCH_UP_VS_NORMAL_THRESH_SEC) { /* data file is sufficiently old, it must be complete */ scanMode = catch_up; serviceState = STATE_CATCH_UP; return true; } else { double fileLength; scanMode = normal; serviceState = STATE_NORMAL; int sts = upmuFtpAccess::getDataFileLength( &(dataDir->dirName), dataFile, &fileLength); if(sts != DATA_ACCESS_OK) { return false; } else { unsigned int fileSize = (unsigned int)fileLength; if(fileSize < mostRecentDataFileLength) { /* not the same size as previous data files, so we wait. Note that if file lengths change in uPMU configure, we will take an earlier branch once its old enough. */ return false; } else { return true; } } } } void serviceDataDiscovery::postProcessUPMUdata(unsigned char *dataBuf, unsigned int dataLen) { int sts; unsigned char * dataPtr = dataBuf; /* inspect first top bytes of year */ bool dataBigEndian = false; bool platformBigEndian = IS_BIG_ENDIAN; if((*(dataPtr + 4) == 0) && (*(dataPtr + 5) == 0)) { dataBigEndian = true; } if(platformBigEndian != dataBigEndian) { /* we need to swap bytes in the buffer */ while (dataPtr < dataBuf + dataLen) { unsigned char * tempDataPtr = dataPtr; /* loop over 1 sec. of data */ while (tempDataPtr < (dataPtr + 6312)) { /* treat everything as if it were 32 bit value */ swapBytesUint((unsigned int *)tempDataPtr); tempDataPtr += 4; } dataPtr += 6312; } } std::shared_ptr<serviceDataBuffer> ptr(new serviceDataBuffer(&sharedInMemDataBufferCnt, &sharedTotalDataBufferCnt, dataLen, dataBuf)); /* offer data to other services */ for (auto si: services->services) { if(si.second->serviceAcceptsData== true) { //this is better than the old solution // if(si.first.compare("serviceDataDiscovery") != 0) { // if(si.first.compare("serviceDataArchiver") == 0) { dataBufferOffer_t sts = si.second->serviceThread->dataBufferOffer(ptr); std::cout << "Discovery Buffer offered, internal counter: " << sharedInMemDataBufferCnt << ", to" << si.first << std::endl; // } } } /* release our reference to the shared pointer. If any other service is using it, they have already added their own reference. It will be destroyed when the last reference is released. */ ptr.reset(); } void serviceDataDiscovery::swapBytesUint(unsigned int * val) { unsigned int temp = *val; *val = ((((temp) & 0xff000000) >> 24) | (((temp) & 0x00ff0000) >> 8) | (((temp) & 0x0000ff00) << 8) | (((temp) & 0x000000ff) << 24)); } int serviceDataDiscovery::cassandraCommonArchive(const CassPrepared * prepared, uint32_t statsIndex, uint64_t timestampMsec, uint64_t day, std::string device, uint32_t domainType, uint32_t msgType, void * buffer, uint32_t byteLen) { CassStatement * statement = cass_prepared_bind(prepared); /* Bind the values using the indices of the bind variables */ cass_statement_bind_int64_by_name(statement, "TIMESTAMP_MSEC", timestampMsec); cass_statement_bind_int64_by_name(statement, "DAY", day); cass_statement_bind_string_by_name(statement, "DEVICE", device.c_str()); cass_statement_bind_int32_by_name(statement, "DOMAIN_TYPE", domainType); cass_statement_bind_int32_by_name(statement, "MSG_TYPE", msgType); cass_statement_bind_bytes_by_name(statement, "DATA", (const cass_byte_t *)buffer, byteLen); CassFuture* cassQuery_future = cass_session_execute(cassSession, statement); /* This will block until the query has finished */ CassError rc = cass_future_error_code(cassQuery_future); if(rc != CASS_OK) { /* count errors for each cassandra table */ serviceSpecStatsMutex.lock(); unsigned int * cnt = any_cast<unsigned int *> ((*serviceSpecStatsValues)[statsIndex]); *cnt++; serviceSpecStatsMutex.unlock(); } /* Statement objects can be freed immediately after being executed */ cass_statement_free(statement); cass_future_free(cassQuery_future); } void serviceDataDiscovery::addCurrentDirectoryRecord() { try { work w(*(dbConn->conn)); w.prepared("add_dir_record")(dataDir->year)(dataDir->month)\ (dataDir->day)(dataDir->hour)((dataDir->dirName).c_str())\ ("current").exec(); w.commit(); /* select it so we can use common code at end of this section. */ nontransaction n(*(dbConn->conn)); result r = n.prepared("get_dir_record_key").exec(); n.commit(); dataDir->dbID = r[0][0].as<int>(); } catch (const std::exception &e) { /* log error */ std::cerr << e.what() << std::endl; } } serviceDataDiscovery plugin; BOOST_DLL_AUTO_ALIAS(plugin) }
module Prims data MyList a = Nil | (:::) a (MyList a) infixr 10 ::: -- *Prims> 1 ::: Nil -- 1 ::: [] : MyList Integer -- *Prims> 0 ::: 1 ::: Nil -- 0 ::: 1 ::: [] : MyList Integer -- Idris requires type declarations, using a single colon : head' : MyList a -> Maybe a head' Nil = Nothing head' (x ::: xs) = Just x -- *Prims> :let ls : MyList Nat; ls = 0 ::: 1 ::: Nil -- *Prims> head' ls -- Just 0 : Maybe Nat -- data Nat = Z | S Nat Natural numbers (zero and successor) -- Z : Nat data constructors plus' : Nat -> Nat -> Nat plus' Z y = y plus' (S k) y = S (plus' k y) x : Int x = 123 foo : String foo = "boo" bar : Char bar = 'X' bool : Bool bool = True
# example of horizontal shift image augmentation import sys import os import time import PIL import progressbar from pathlib import Path from numpy import expand_dims from keras.preprocessing.image import load_img from keras.preprocessing.image import img_to_array from keras.preprocessing.image import ImageDataGenerator from matplotlib import pyplot as plt def check_create_dir(path): if not os.path.isdir(path): os.makedirs(path) if __name__ == "__main__": root = str(Path(__file__).parent.parent) dataset_path = root + "/datasets" #where all class folders are train_path = sys.argv[1] #the new training folder train_out_path = sys.argv[2] check_create_dir(train_out_path) num_images = 4 classes = os.listdir(train_path) for label in classes: start_time = time.time() print(label) out_dir = train_out_path + '/' + label check_create_dir(out_dir) in_dir = train_path + '/' + label allimages = os.listdir(in_dir) for img_name in progressbar.progressbar(allimages): img = load_img(in_dir + "/" + img_name) data = img_to_array(img) samples = expand_dims(data, 0) datagen = ImageDataGenerator(horizontal_flip=True, rotation_range=36, brightness_range=[0.5, 1.0], zoom_range=[0.4, 1]) it = datagen.flow(samples, batch_size=1) for i in range(num_images): # pyplot.subplot(330 + 1 + i) batch = it.next() image = batch[0].astype('uint8') image = PIL.Image.fromarray(image) image.save(out_dir + "/" + str(i) + "_" + img_name) print("Time taken", time.time() - start_time, "---") print("done")
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Johannes Hölzl (CMU) -/ import Mathlib.PrePort import Mathlib.Lean3Lib.init.default import Mathlib.tactic.core import Mathlib.PostPort universes u namespace Mathlib theorem monotonicity.pi {α : Sort u} {p : α → Prop} {q : α → Prop} (h : ∀ (a : α), implies (p a) (q a)) : implies (∀ (a : α), p a) (∀ (a : α), q a) := fun (h' : ∀ (a : α), p a) (a : α) => h a (h' a) theorem monotonicity.imp {p : Prop} {p' : Prop} {q : Prop} {q' : Prop} (h₁ : implies p' q') (h₂ : implies q p) : implies (p → p') (q → q') := fun (h : p → p') => h₁ ∘ h ∘ h₂ theorem monotonicity.const (p : Prop) : implies p p := id theorem monotonicity.true (p : Prop) : implies p True := fun (_x : p) => trivial theorem monotonicity.false (p : Prop) : implies False p := false.elim theorem monotonicity.exists {α : Sort u} {p : α → Prop} {q : α → Prop} (h : ∀ (a : α), implies (p a) (q a)) : implies (∃ (a : α), p a) (∃ (a : α), q a) := exists_imp_exists h theorem monotonicity.and {p : Prop} {p' : Prop} {q : Prop} {q' : Prop} (hp : implies p p') (hq : implies q q') : implies (p ∧ q) (p' ∧ q') := and.imp hp hq theorem monotonicity.or {p : Prop} {p' : Prop} {q : Prop} {q' : Prop} (hp : implies p p') (hq : implies q q') : implies (p ∨ q) (p' ∨ q') := or.imp hp hq theorem monotonicity.not {p : Prop} {q : Prop} (h : implies p q) : implies (¬q) (¬p) := mt h
library("stringr") # load str_split library("ppls") rules.processing <- function(AssociationRulesresult){ rules.nonempty = (length(AssociationRulesresult) > 13) CoronOutPut=as.list(AssociationRulesresult) CoronOutPut=lapply(CoronOutPut,function(x)x[!is.na(x)]) CoronOutPut=lapply(CoronOutPut,function(x)x[!x==""]) CoronOutPut=Filter(length,CoronOutPut) CoronOutPut=CoronOutPut[15:length(CoronOutPut)-3] Rules.List <- list() ### extract rules== if (rules.nonempty) { for (i in seq(1, length(CoronOutPut), by=6)){ Rules.List=c(Rules.List,CoronOutPut[i]); } } ###extract positive examples Positives.List <- list() if (rules.nonempty) { for (i in seq(3, length(CoronOutPut), by=6)){ Positives.List=c(Positives.List,CoronOutPut[i]); } } ### extraact objectsOf.Rules objectsOf.Rules <- Positives.List objectsOf.Rules <- str_split(as.character(objectsOf.Rules), ",") # Finally use list() with unique() and unlist() objectsOf.Rules=lapply(objectsOf.Rules, function(x)gsub(" ", '', x, fixed = T)) objectsOf.Rules=lapply(objectsOf.Rules, function(x)gsub("[", '', x, fixed = T)) objectsOf.Rules=lapply(objectsOf.Rules, function(x)gsub("]", '', x, fixed = T)) Positives.List <- str_split(as.character(Positives.List), ",") # Finally use list() with unique() and unlist() Positives.List=lapply(Positives.List, function(x)gsub(" ", '', x, fixed = T)) Positives.List=lapply(Positives.List, function(x)gsub("[", '', x, fixed = T)) Positives.List=lapply(Positives.List, function(x)gsub("]", '', x, fixed = T)) Positives.List=unique(unlist(Positives.List)) Cond.Rules=lapply(strsplit(as.character(Rules.List),">"),"[",1) Cond.Rules=lapply(Cond.Rules, function(x)gsub("{", '', x, fixed = T)) Cond.Rules=lapply(Cond.Rules, function(x)gsub("}", '', x, fixed = T)) Cond.Rules=lapply(Cond.Rules, function(x)gsub("=", '', x, fixed = T)) Cond.Rules=lapply(Cond.Rules, function(x)gsub(" ", '', x, fixed = T)) NbRulesrare=as.integer(length(Cond.Rules)) #cat("\014") cat('\n nb Rare Association Rules ',NbRulesrare) Res.Rules=lapply(strsplit(as.character(Rules.List),">"),"[",2) values=lapply(strsplit(as.character(Res.Rules),"}"),"[",2) Support=lapply(strsplit(as.character(values),";"),"[",1) Support=lapply(strsplit(as.character(Support),"\\["),"[",2) Support=lapply(Support, function(x)gsub("%", '', x, fixed = T)) Support=lapply(Support, function(x)gsub("]", '', x, fixed = T)) Confidence.sc=lapply(strsplit(as.character(values),";"),"[",2) Confidence.sc=lapply(strsplit(as.character(Confidence.sc),"\\["),"[",2) Confidence.sc=lapply(strsplit(as.character(Confidence.sc),"%"),"[",1) Lift.sc=lapply(strsplit(as.character(Rules.List),">"),"[",2) Lift.sc=lapply(strsplit(as.character(Lift.sc),";"),"[",5) Lift.sc=lapply(strsplit(as.character(Lift.sc),"="),"[",2) Lift.sc=lapply(Lift.sc, function(x)gsub(",", '', x, fixed = T)) Lift.sc=as.numeric(Lift.sc) Confidence.sc=as.numeric(Confidence.sc) Support=as.numeric(Support) SuppLeft=lapply(strsplit(as.character(Rules.List),">"),"[",2) SuppLeft=lapply(strsplit(as.character(SuppLeft),";"),"[",3) SuppLeft=lapply(strsplit(as.character(SuppLeft),"\\["),"[",2) SuppLeft=lapply(SuppLeft, function(x)gsub("%", '', x, fixed = T)) SuppLeft=lapply(SuppLeft, function(x)gsub("]", '', x, fixed = T)) SuppLeft=as.numeric(SuppLeft) SuppRight=lapply(strsplit(as.character(Rules.List),">"),"[",2) SuppRight=lapply(strsplit(as.character(SuppRight),";"),"[",4) SuppRight=lapply(strsplit(as.character(SuppRight),"\\["),"[",2) SuppRight=lapply(SuppRight, function(x)gsub("%", '', x, fixed = T)) SuppRight=lapply(SuppRight, function(x)gsub("]", '', x, fixed = T)) SuppRight=as.numeric(SuppRight) # Conviction=lapply(strsplit(as.character(Rules.List),">"),"[",2) # Conviction=lapply(strsplit(as.character(Conviction),";"),"[",6) # Conviction=lapply(strsplit(as.character(Conviction),"="),"[",2) # Conviction=as.numeric(Conviction) # Conviction[is.na(Conviction)]=-1 # maxConv=max(Conviction) # Conviction[Conviction==-1]=maxConv+1 # Conviction<-normalize.vector(Conviction) Leverage.sc=Support-SuppLeft*SuppRight PowerFactor.sc=Support *Confidence.sc/100 Kulczynski.sc=0.5*(Support /SuppLeft +Support /SuppRight ) Lerman.sc=(Support -SuppLeft *SuppRight )/(sqrt(SuppLeft *SuppRight )) AddedValue.sc=Confidence.sc/100-SuppRight Cosine.sc= Support / sqrt(SuppLeft *SuppRight ) ConterExampleRate.sc=(Support -1+Confidence.sc/100)/Support Loevinger.sc=(Confidence.sc/100-SuppRight )/(1-SuppRight ) ImbalanceRatio.sc=abs(SuppLeft -SuppRight )/(SuppLeft +SuppRight -Support ) Jaccard.sc=Support/(SuppLeft+SuppRight-Support) Klosgen.sc=sqrt(Support )*(Confidence.sc/100-SuppRight ) Confidence.sc=lapply(Confidence.sc, function(x)gsub("NaN", '0', x, fixed = T)) Confidence.sc=lapply(Confidence.sc, function(x){((as.double(x)-0.00000000000001)) }) Confidence.sc=normalize.vector(unlist(Confidence.sc)) Lift.sc=lapply(Lift.sc, function(x)gsub("NaN", '0', x, fixed = T)) Lift.sc=lapply(Lift.sc, function(x)as.double(x)) NormalizedLift.sc=normalize.vector(unlist(Lift.sc)) Leverage.sc =lapply(Leverage.sc, function(x)gsub("NaN", '0', x, fixed = T)) Leverage.sc =lapply(Leverage.sc , function(x)as.double(x)) # Leverage.sc=normalize.vector(unlist(Leverage.sc)) PowerFactor.sc=lapply(PowerFactor.sc, function(x)gsub("NaN", '0', x, fixed = T)) PowerFactor.sc=lapply(PowerFactor.sc , function(x)as.double(x)) #PowerFactor.sc=normalize.vector(unlist(PowerFactor.sc)) Kulczynski.sc=lapply(Kulczynski.sc, function(x)gsub("NaN", '0', x, fixed = T)) Kulczynski.sc=lapply(Kulczynski.sc , function(x)as.double(x)) #Kulczynski.sc=normalize.vector(unlist(Kulczynski.sc)) Lerman.sc=lapply(Lerman.sc, function(x)gsub("NaN", '0', x, fixed = T)) Lerman.sc=lapply(Lerman.sc , function(x)as.double(x)) #Lerman.sc=normalize.vector(unlist(Lerman.sc)) AddedValue.sc=lapply(AddedValue.sc, function(x)gsub("NaN", '0', x, fixed = T)) AddedValue.sc=lapply(AddedValue.sc , function(x)as.double(x)) #AddedValue.sc=normalize.vector(unlist(AddedValue.sc)) Cosine.sc=lapply(Cosine.sc, function(x)gsub("NaN", '0', x, fixed = T)) Cosine.sc=lapply(Cosine.sc , function(x)as.double(x)) #Cosine.sc=normalize.vector(unlist(Cosine.sc)) ConterExampleRate.sc=lapply(ConterExampleRate.sc, function(x)gsub("NaN", '0', x, fixed = T)) ConterExampleRate.sc=lapply(ConterExampleRate.sc , function(x)as.double(x)) # ConterExampleRate.sc=normalize.vector(unlist(ConterExampleRate.sc)) Loevinger.sc=lapply(Loevinger.sc, function(x)gsub("NaN", '0', x, fixed = T)) Loevinger.sc=lapply( Loevinger.sc, function(x)as.double(x)) #Loevinger.sc=normalize.vector(unlist(Loevinger.sc)) ImbalanceRatio.sc=lapply(ImbalanceRatio.sc, function(x)gsub("NaN", '0', x, fixed = T)) ImbalanceRatio.sc=lapply( ImbalanceRatio.sc, function(x)as.double(x)) #ImbalanceRatio.sc=normalize.vector(unlist(ImbalanceRatio.sc)) Jaccard.sc=lapply(Jaccard.sc, function(x)gsub("NaN", '0', x, fixed = T)) Jaccard.sc=lapply(Jaccard.sc , function(x)as.double(x)) # Jaccard.sc=normalize.vector(unlist(Jaccard.sc)) Klosgen.sc=lapply(Klosgen.sc, function(x)gsub("NaN", '0', x, fixed = T)) Klosgen.sc=lapply(Klosgen.sc , function(x)as.double(x)) #Klosgen.sc=normalize.vector(unlist(Klosgen.sc)) #Confidence.sc=lapply(Confidence.sc, function(x)gsub("%", '', x, fixed = T)) #Confidence.sc=lapply(Confidence.sc, function(x)gsub("\\]", '', x, fixed = T)) Res.Rules=lapply(strsplit(as.character(Res.Rules),"}"),"[",1) Res.Rules=lapply(Res.Rules, function(x)gsub("{", '', x, fixed = T)) Res.Rules=lapply(Res.Rules, function(x)gsub(" ", '', x, fixed = T)) #df.RareAssocRulesOutPut=data.frame() #df.RareAssocRulesOutPut=do.call(rbind, Map(data.frame, "Cond.Rules"=Cond.Rules, "Res.Rules"=Res.Rules,"Support"=Support,"Confidence.sc"=Confidence.sc,"Lift.sc"=Lift.sc)) #write.csv(file=paste0(path,"/Rares_AssociationRules_",ListofContexts[idcontext],"_Conf_",MinConf,"_Sup_",MinSup,".csv",sep=""), df.RareAssocRulesOutPut) #Combination.sc = rowMeans(cbind(Confidence.sc, Lift.sc,Leverage.sc,PowerFactor.sc,PowerFactor.sc,Kulczynski.sc,Lerman.sc,AddedValue.sc,Cosine.sc,ConterExampleRate.sc,Loevinger.sc,ImbalanceRatio.sc,Jaccard.sc,Klosgen.sc), na.rm=TRUE) # MaxCombination.sc = pmax(Confidence.sc, Lift.sc,Leverage.sc,PowerFactor.sc,PowerFactor.sc,Kulczynski.sc,Lerman.sc,AddedValue.sc,Cosine.sc,ConterExampleRate.sc,Loevinger.sc,ImbalanceRatio.sc,Jaccard.sc,Klosgen.sc) returned.list <- list("Positives.List" = Positives.List, "Rules.List" = Rules.List, "objectsOf.Rules"= objectsOf.Rules, "Cond.Rules" = Cond.Rules, "objectsOf.Rules"=objectsOf.Rules, "Res.Rules" = Res.Rules, "Confidence.sc"=Confidence.sc, "Lift.sc" = NormalizedLift.sc, "OriginalLift.sc" = Lift.sc, "Leverage.sc" = Leverage.sc, "PowerFactor.sc" = PowerFactor.sc, "Kulczynski.sc" = Kulczynski.sc, "Lerman.sc" = Lerman.sc, "AddedValue.sc" = AddedValue.sc, "Cosine.sc" = Cosine.sc, "ConterExampleRate.sc" = ConterExampleRate.sc, "Loevinger.sc" = Loevinger.sc, "ImbalanceRatio.sc" = ImbalanceRatio.sc, "Jaccard.sc" = Jaccard.sc, "Klosgen.sc" = Klosgen.sc#, # "Combination.sc" = Combination.sc, # "MaxCombination.sc"=MaxCombination.sc ) return(returned.list) }
\section{Status of this document.} \hspace{1.0em} 25.10.98 created by N. Amelin.
import pandas as pd import healpy as hp import numpy as np import matplotlib.pyplot as plt def plot_hpix(hp_table, nside, label, region=None, **kwargs): """ data: Pandas or astropy table containing the data with hp_idx column nside: number of sides of the pixel label: label of the column to be plotted as a hp map region: survey region to be selected """ npix = hp.nside2npix(nside) hp_array = hp.ma(np.zeros(npix)) hp_array[np.array(hp_table['hp_idx'])] = np.array(hp_table[label]) hp_mask = np.zeros(npix, dtype=bool) if region == None: hp_mask[hp_table['hp_idx']] = True else: hp_mask[hp_table['hp_idx'][hp_table['region']!=region]] = True hp_array.mask = ~hp_mask tmp = hp.mollview(hp_array, xsize=4000,rot=(120,0,0), return_projected_map=True) plt.close() # Remove outlying regions tmp = np.ma.masked_array(tmp.data[600:], mask=tmp.mask[600:]) tmp = np.ma.masked_array(tmp.data[::, 300:], mask=tmp.mask[::, 300:]) fig, ax = plt.subplots(figsize=(25, 10)) im = ax.imshow(tmp, origin='lower', vmin=-0.3, vmax=0.2, cmap="jet") ax.axis('off') cax = fig.add_axes([0.9, 0.15, 0.015, 0.7]) fig.colorbar(im, cax=cax) fig.set_facecolor('lightgrey') plt.show() return hp_array
lemma and_trans (P Q R : Prop) : P ∧ Q → Q ∧ R → P ∧ R := begin intro f, cases f with p q, intro h, cases h with q r, split, exact p, exact r, end
The Botany Club is an student organizations campus organization to promote botany, plant biology, College of Agriculture agriculture, and all other green related majors much as the chemistry club exists for chemistry majors, physics club, etc. The meetings occur biweekly and include various talks, presentations, and panels about plantrelated careers, research done here on campus, and other fascinating botanical discoveries and oddities. They also sometimes join the Davis Botanical Society for bigger events and speakers think of the DBS as the adult botany club! They have been known to have special tours of the Herbarium a squashed plant archive on campus and the Botanical Conservatorys collection of unusual plants. Major field trips happen each year. See the website for plans. The club http://wwwplb.ucdavis.edu/botanyclub/ website will generally have the calendar of events, speakers and trips. Contact info should be there for the club officers, and is always true for the advisor, Professor Judy Jernstadt and the mascot Ernesto Sandoval. They also have a http://ucdavis.facebook.com/group.php?gid2200621521 facebook group. Meetings All meetings held in Robbins Hall room Robbins Hall 141 141, starting near 6:15 p.m. every other Thursday, there is usually food brought by some member, and most often a panel or talk by someone relevant to plant biology, agriculture, or plants in general, great fun if you like the greener (or generally more colorful) side of life, a definitely awesome place for anyone in any plant related field. Meetings have resumed, the next scheduled for the 29^th^ of November, at which fabulous snacks will be provided. Events See calendar.http://wwwplb.ucdavis.edu/botanyclub/ This Spring Break the botany club will be heading down to Santa Cruz Island in order to help out with the botanical effort there. TShirts Etc. The botany club has Tshirts too, they look pretty snazzy and contain puns. Collections At every meeting a spare change jar is passed around to raise donations for the notable plant cause of the year, currently the Davis Tree (something?).
It is also mentioned in discussion of constitutional convention . Whilst it replaced conventions regarding the role of the House of Lords , it also relies on several others . Section 1 ( 1 ) only makes sense if money bills do not arise in the House of Lords and the provisions in section 2 ( 1 ) only if proceedings on a public bill are completed in a single session , otherwise they must fail and be put through procedure again .
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Statistics.Sample.Histogram.MagnitudeSpec where import qualified Data.Vector.Unboxed as U import Data.Monoid import Data.Functor.Identity import Statistics.Sample.Histogram.Magnitude import Test.Hspec import Test.QuickCheck import Test.QuickCheck.Checkers import Test.QuickCheck.Classes main :: IO () main = hspec spec spec :: Spec spec = parallel . describe "Histogram" $ do it "calculates a meaningful histogram" $ do let x = foldHist 1 [-3, 1, 4, 6, 9, 9.9, 4.032, 9.2] result = U.fromList [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 2, 0, 1, 0, 0, 3] histBuckets x `shouldBe` result describe "calculates magnitude" $ do it "is -1" $ property $ \(MagN x) -> histMagnitude (fromList 1 [x]) == -1 it "is 0" $ property $ \(Mag0 x) -> histMagnitude (fromList 1 [x]) == 0 it "is 1" $ property $ \(Mag1 x) -> histMagnitude (fromList 1 [x]) == 1 it "is 2" $ property $ \(Mag2 x) -> histMagnitude (fromList 1 [x]) == 2 it "blends equal resolutions and magnitudes" $ do let x = foldHist 1 [1, 4, 6, 9] y = foldHist 1 [1, 6] result = U.fromList [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 2, 0, 0, 1] histBuckets (x <> y) `shouldBe` result it "scales non equal magnitudes to the higher magnitude" $ do let x = foldHist 1 [1, 4, 6, 9] y = foldHist 1 [134, 666] result = U.fromList [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 1, 0, 0, 0] histMagnitude (x <> y) `shouldBe` 2 histBuckets (x <> y) `shouldBe` result it "blurs non equal resolutions to the lower resolution" $ do let x = foldHist 1 [1, 4, 6, 9] y = foldHist 2 [1, 6.6] result = U.fromList [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 2, 0, 0, 1] histResolution (x <> y) `shouldBe` 1 histBuckets (x <> y) `shouldBe` result it "blurs and scales non equal resolution and magnitude" $ do let x = foldHist 2 [1, 4, 6, 9] y = foldHist 3 [-17, 1, 66] vec = (U.replicate 100 0) result = U.accum (+) vec [(82, 1)] <> U.accum (+) vec [(1, 2), (4, 1), (6, 1), (9, 1), (66, 1)] histBuckets (x <> y) `shouldBe` result describe "produces keys for given magnitudes and scales" $ do it "2-1" $ keys (fromList 2 [1]) `shouldBe` U.fromList (reverse [0, -0.1 .. -9.9 ] <> [0, 0.1 .. 9.9 :: Double]) it "2-10" $ keys (fromList 2 [10]) `shouldBe` U.fromList ([-99, -98 .. 0] <> [0, 1 .. 99 :: Double]) it "1-9" $ keys (fromList 1 [9]) `shouldBe` U.fromList ([-9, -8 .. 0] <> [0, 1 .. 9 :: Double]) it "allows insertion" $ do let x = foldHist 1 [1, 4, 6, 9] result = U.fromList [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1] histBuckets (insert (-3) x) `shouldBe` result testBatch $ monoid (undefined :: Histogram Double) it "is commutable" $ property $ isCommut ((<>) :: Histogram Double -> Histogram Double -> Histogram Double) it "has decreasing resolution on mappend" $ property $ \(x :: Histogram Double, y :: Histogram Double) -> histResolution (x <> y) == min (histResolution x) (histResolution y) it "has increasing magnitude on mappend" $ property $ \(x :: Histogram Double, y :: Histogram Double) -> histMagnitude (x <> y) == max (histMagnitude x) (histMagnitude y) it "is equivalent to mappend and insert" $ property $ \(xs :: [Double]) -> foldHist 2 xs == foldMap (foldHist 2 . Identity) xs testBatch :: TestBatch -> Spec testBatch (batchName, tests) = describe ("laws for: " ++ batchName) $ foldr (>>) (return ()) (map (uncurry it) tests) instance (RealFrac a, Floating a, Arbitrary a) => Arbitrary (Histogram a) where arbitrary = do ys <- arbitrary x <- choose (0, 3) pure $ fromList (fromIntegral (x :: Int)) (getNonEmpty ys :: [a]) instance EqProp a => EqProp (Histogram a) where x =-= y = eq x y newtype MagN = MagN Double deriving (Show, Ord, Eq, Num) instance Arbitrary MagN where arbitrary = MagN <$> choose (0.1, 0.9) newtype Mag0 = Mag0 Double deriving (Show, Ord, Eq, Num) instance Arbitrary Mag0 where arbitrary = Mag0 <$> choose (1, 9.9) newtype Mag1 = Mag1 Double deriving (Show, Ord, Eq, Num) instance Arbitrary Mag1 where arbitrary = Mag1 <$> choose (10, 99.9) newtype Mag2 = Mag2 Double deriving (Show, Ord, Eq, Num) instance Arbitrary Mag2 where arbitrary = Mag2 <$> choose (100, 999.9)
\module{compulsory} {lecture and laboratory} {German} {9} {270h} {\paragraph{Lecture Animal Physiology (Neurobiology):} For animals and humans, connections between structure and function at the level of tissues, organs and complex organ systems and their relevance for the emergence of behavior in animals are presented. The focus is on general principles of physiology. The question of the adaptation value of certain construction-function relationships is also posed in comparative considerations. The mediation of specific physiological learning approaches takes precedence over the mediation of matter following to the motto: teaching key concepts is better than touching a broad but shallow spectrum. \paragraph{Laboratory Excercise Biomolecules and Cell:} The Animal Physiological Course for Bioinformatics aims to experimentally measure the electrophysical principals of animal life. Topics include: Reflexes, transmission of SAPs through nerves, muscle activity, heartbeat. } {The students know the basics of animal physiology. In practical experiments, they have acquired basic laboratory skills. Since the laboratory is conducted in group, the students extend their constructive criticism and discussion skills.} {None}
From sflib Require Import sflib. From Paco Require Import paco. From PromisingLib Require Import Axioms. From PromisingLib Require Import Basic. From PromisingLib Require Import Loc. From PromisingLib Require Import DataStructure. From PromisingLib Require Import DenseOrder. From PromisingLib Require Import Language. From PromisingLib Require Import Event. Require Import Time. Require Import View. Require Import BoolMap. Require Import Promises. Require Import Cell. Require Import Memory. Require Import Global. Require Import TView. Require Import Local. Require Import Thread. Require Import Configuration. Require Import MemoryReorder. Require Import ReorderTView. Require Import SimLocal. Require Import SimMemory. Require Import SimGlobal. Set Implicit Arguments. Lemma future_read_step lc1 gl1 gl1' loc ts val released ord lc2 (FUTURE: Global.le gl1 gl1') (STEP: Local.read_step lc1 gl1 loc ts val released ord lc2): exists released' lc2', <<STEP: Local.read_step lc1 gl1' loc ts val released' ord lc2'>> /\ <<REL: View.opt_le released' released>> /\ <<LOCAL: sim_local lc2' lc2>>. Proof. inv FUTURE. inv STEP. exploit MEMORY; eauto. i. esplits. - econs; eauto; try by etrans; eauto. - refl. - econs; s; refl. Qed. Lemma future_fence_step lc1 gl1 gl1' ordr ordw lc2 gl2 (ORDW: Ordering.le ordw Ordering.acqrel) (FUTURE: Global.le gl1 gl1') (STEP: Local.fence_step lc1 gl1 ordr ordw lc2 gl2): Local.fence_step lc1 gl1' ordr ordw lc2 gl1'. Proof. inv STEP. erewrite TViewFacts.write_fence_tview_acqrel; auto. econs; ss. rewrite TViewFacts.write_fence_sc_acqrel; ss. destruct gl1'. ss. Qed. Lemma future_is_racy lc1 gl1 gl1' loc to ord (LC_WF: Local.wf lc1 gl1) (FUTURE: Global.strong_le gl1 gl1') (STEP: Local.is_racy lc1 gl1 loc to ord): exists to', <<STEP: Local.is_racy lc1 gl1' loc to' ord>>. Proof. inv FUTURE. inv LE. inv STEP; eauto. inv ADDNA. specialize (ADDNA0 loc). des. - esplits; econs 1; eauto. rewrite GET in *. ss. - r in LATEST. des. esplits. econs 2; eauto. inv LC_WF. inv TVIEW_CLOSED. inv CUR. specialize (PLN loc). des. unfold TView.racy_view. eauto. Qed. Lemma future_racy_read_step lc1 gl1 gl1' loc to val ord (LC_WF: Local.wf lc1 gl1) (FUTURE: Global.strong_le gl1 gl1') (STEP: Local.racy_read_step lc1 gl1 loc to val ord): exists to', <<STEP: Local.racy_read_step lc1 gl1' loc to' val ord>>. Proof. inv STEP. exploit future_is_racy; eauto. i. des. esplits. econs. eauto. Qed. Lemma future_racy_write_step lc1 gl1 gl1' loc to ord (LC_WF: Local.wf lc1 gl1) (FUTURE: Global.strong_le gl1 gl1') (STEP: Local.racy_write_step lc1 gl1 loc to ord): exists to', <<STEP: Local.racy_write_step lc1 gl1' loc to' ord>>. Proof. inv STEP. exploit future_is_racy; eauto. i. des. esplits. econs. eauto. Qed. Lemma future_racy_update_step lc1 gl1 gl1' loc to ordr ordw (LC_WF: Local.wf lc1 gl1) (FUTURE: Global.strong_le gl1 gl1') (STEP: Local.racy_update_step lc1 gl1 loc to ordr ordw): exists to', <<STEP: Local.racy_update_step lc1 gl1' loc to' ordr ordw>>. Proof. inv STEP; eauto. exploit future_is_racy; eauto. i. des. esplits. econs 3. eauto. Qed. (** reorder read; step *) Lemma reorder_read_read loc1 ts1 val1 released1 ord1 loc2 ts2 val2 released2 ord2 lc0 gl0 lc1 lc2 (LOC: loc1 = loc2 -> Ordering.le ord1 Ordering.plain /\ Ordering.le ord2 Ordering.plain) (ORD2: Ordering.le ord2 Ordering.relaxed) (LC_WF0: Local.wf lc0 gl0) (GL_WF0: Global.wf gl0) (STEP1: Local.read_step lc0 gl0 loc1 ts1 val1 released1 ord1 lc1) (STEP2: Local.read_step lc1 gl0 loc2 ts2 val2 released2 ord2 lc2): exists lc1', <<STEP1: Local.read_step lc0 gl0 loc2 ts2 val2 released2 ord2 lc1'>> /\ <<STEP2: Local.read_step lc1' gl0 loc1 ts1 val1 released1 ord1 lc2>>. Proof. inv STEP1. inv STEP2. ss. esplits. - econs; eauto. eapply TViewFacts.readable_mon; try apply READABLE0; eauto; try refl. apply TViewFacts.read_tview_incr. - econs; eauto. + s. unfold View.singleton_ur_if. econs; repeat (try condtac; try splits; aggrtac; eauto; try apply READABLE; unfold TimeMap.singleton, LocFun.add in *; s). * specialize (LOC eq_refl). des. viewtac. * specialize (LOC eq_refl). des. viewtac. * specialize (LOC eq_refl). des. viewtac. + f_equal. inv GL_WF0. inv MEM_CLOSED. exploit CLOSED; try exact GET. i. des. exploit CLOSED; try exact GET0. i. des. inv MSG_WF. inv MSG_WF0. apply TView.antisym; apply ReorderTView.read_read_tview; (try by apply LC_WF0); eauto. Qed. Lemma reorder_read_write lc0 gl0 loc1 ts1 val1 released1 ord1 lc1 loc2 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2 (LOC: loc1 <> loc2) (ORD: Ordering.le ord1 Ordering.acqrel \/ Ordering.le ord2 Ordering.acqrel) (RELM_WF: View.opt_wf releasedm2) (LC_WF0: Local.wf lc0 gl0) (GL_WF0: Global.wf gl0) (STEP1: Local.read_step lc0 gl0 loc1 ts1 val1 released1 ord1 lc1) (STEP2: Local.write_step lc1 gl0 loc2 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2): exists lc1' released2' gl2' lc2', <<STEP1: Local.write_step lc0 gl0 loc2 from2 to2 val2 releasedm2 released2' ord2 lc1' gl2'>> /\ <<STEP2: Local.read_step lc1' gl2' loc1 ts1 val1 released1 ord1 lc2'>> /\ <<RELEASED: View.opt_le released2' released2>> /\ <<LOCAL: sim_local lc2' lc2>> /\ <<GLOBAL: sim_global gl2' gl2>>. Proof. guardH ORD. exploit Local.read_step_future; eauto. i. des. inv STEP1. inv STEP2. ss. exploit TViewFacts.write_future0; try exact RELM_WF; try apply LC_WF0. i. des. exploit sim_memory_add_exists; try exact WRITE. { econs 1. exact WF_RELEASED. } { econs; try refl; try apply Bool.implb_same. eapply TViewFacts.write_released_mon; try apply TViewFacts.read_tview_incr; try refl; ss. apply LC_WF2. } { refl. } i. des. esplits. - econs; eauto. eapply TViewFacts.writable_mon; eauto; aggrtac. refl. - econs; eauto; s. + erewrite Memory.add_o; eauto. condtac; ss; eauto. des. congr. + inv READABLE. econs; repeat (try condtac; aggrtac; eauto; unfold TimeMap.singleton). - eapply TViewFacts.write_released_mon; try refl; ss. apply LC_WF2. - econs; ss. apply ReorderTView.read_write_tview; try apply LC_WF0; auto. - econs; ss. refl. Qed. Lemma reorder_read_update lc0 gl0 loc1 ts1 val1 released1 ord1 lc1 loc2 ts2 val2 released2 ord2 lc2 from3 to3 val3 released3 ord3 lc3 gl3 (LOC: loc1 <> loc2) (ORD2: Ordering.le ord2 Ordering.relaxed) (ORD3: Ordering.le ord1 Ordering.acqrel \/ Ordering.le ord3 Ordering.acqrel) (LC_WF0: Local.wf lc0 gl0) (GL_WF0: Global.wf gl0) (STEP1: Local.read_step lc0 gl0 loc1 ts1 val1 released1 ord1 lc1) (STEP2: Local.read_step lc1 gl0 loc2 ts2 val2 released2 ord2 lc2) (STEP3: Local.write_step lc2 gl0 loc2 from3 to3 val3 released2 released3 ord3 lc3 gl3): exists released3' lc1' lc2' lc3' gl3', <<STEP1: Local.read_step lc0 gl0 loc2 ts2 val2 released2 ord2 lc1'>> /\ <<STEP2: Local.write_step lc1' gl0 loc2 from3 to3 val3 released2 released3' ord3 lc2' gl3'>> /\ <<STEP3: Local.read_step lc2' gl3' loc1 ts1 val1 released1 ord1 lc3'>> /\ <<RELEASED: View.opt_le released3' released3>> /\ <<LOCAL: sim_local lc3' lc3>> /\ <<GLOBAL: sim_global gl3' gl3>>. Proof. guardH ORD3. exploit Local.read_step_future; try exact STEP1; eauto. i. des. exploit Local.read_step_future; try exact STEP2; eauto. i. des. exploit reorder_read_read; try exact STEP1; try exact STEP2; eauto; try congr. i. des. exploit Local.read_step_future; try exact STEP0; eauto. i. des. hexploit reorder_read_write; try exact STEP4; try exact STEP_SRC; eauto. i. des. esplits; eauto. Qed. Lemma reorder_read_fence loc1 ts1 val1 released1 ord1 ordr2 ordw2 lc0 gl0 lc1 lc2 gl2 (ORDR2: Ordering.le ordr2 Ordering.relaxed) (ORDW2: Ordering.le ordw2 Ordering.acqrel) (LC_WF0: Local.wf lc0 gl0) (GL_WF0: Global.wf gl0) (STEP1: Local.read_step lc0 gl0 loc1 ts1 val1 released1 ord1 lc1) (STEP2: Local.fence_step lc1 gl0 ordr2 ordw2 lc2 gl2): exists lc1' lc2' gl2', <<STEP1: Local.fence_step lc0 gl0 ordr2 ordw2 lc1' gl2'>> /\ <<STEP2: Local.read_step lc1' gl2' loc1 ts1 val1 released1 ord1 lc2'>> /\ <<LOCAL: sim_local lc2' lc2>> /\ <<GLOBAL: sim_global gl2' gl2>>. Proof. exploit Local.read_step_future; eauto. i. des. inv STEP1. inv STEP2. ss. esplits. - econs; eauto. - econs; eauto. s. unfold TView.write_fence_tview, TView.read_fence_tview, TView.write_fence_sc. econs; repeat (try condtac; try splits; aggrtac; try apply READABLE). - econs; eauto. s. etrans. + apply ReorderTView.read_write_fence_tview; auto. eapply TViewFacts.read_fence_future; apply LC_WF0. + apply TViewFacts.write_fence_tview_mon; try refl. apply ReorderTView.read_read_fence_tview; try apply LC_WF0; auto. exploit TViewFacts.read_fence_future; try apply LC_WF0; eauto. i. des. eapply TViewFacts.read_future; eauto. apply GL_WF0. - econs; ss; try refl. unfold TView.write_fence_sc, TView.read_fence_tview. repeat condtac; aggrtac. Qed. Lemma reorder_read_is_racy loc1 ts1 val1 released1 ord1 loc2 to2 ord2 lc0 gl0 lc1 (STEP1: Local.read_step lc0 gl0 loc1 ts1 val1 released1 ord1 lc1) (STEP2: Local.is_racy lc1 gl0 loc2 to2 ord2): <<STEP1: Local.is_racy lc0 gl0 loc2 to2 ord2>>. Proof. inv STEP1. inv STEP2; eauto. ss. econs; try exact GET0; eauto. eapply TViewFacts.racy_view_mon; try apply RACE; eauto. apply TViewFacts.read_tview_incr. Qed. Lemma reorder_read_racy_read loc1 ts1 val1 released1 ord1 loc2 to2 val2 ord2 lc0 gl0 lc1 (STEP1: Local.read_step lc0 gl0 loc1 ts1 val1 released1 ord1 lc1) (STEP2: Local.racy_read_step lc1 gl0 loc2 to2 val2 ord2): <<STEP1: Local.racy_read_step lc0 gl0 loc2 to2 val2 ord2>>. Proof. inv STEP2. exploit reorder_read_is_racy; eauto. Qed. Lemma reorder_read_racy_write loc1 ts1 val1 released1 ord1 loc2 to2 ord2 lc0 gl0 lc1 (STEP1: Local.read_step lc0 gl0 loc1 ts1 val1 released1 ord1 lc1) (STEP2: Local.racy_write_step lc1 gl0 loc2 to2 ord2): <<STEP1: Local.racy_write_step lc0 gl0 loc2 to2 ord2>>. Proof. inv STEP2. exploit reorder_read_is_racy; eauto. Qed. (** reorder write; step *) Lemma reorder_write_read loc1 from1 to1 val1 releasedm1 released1 ord1 loc2 ts2 val2 released2 ord2 lc0 gl0 lc1 gl1 lc2 (LOC: loc1 <> loc2) (ORD1: Ordering.le ord1 Ordering.relaxed) (ORD2: Ordering.le ord2 Ordering.relaxed) (LC_WF0: Local.wf lc0 gl0) (GL_WF0: Global.wf gl0) (STEP1: Local.write_step lc0 gl0 loc1 from1 to1 val1 releasedm1 released1 ord1 lc1 gl1) (STEP2: Local.read_step lc1 gl1 loc2 ts2 val2 released2 ord2 lc2): exists lc1', <<STEP1: Local.read_step lc0 gl0 loc2 ts2 val2 released2 ord2 lc1'>> /\ <<STEP2: Local.write_step lc1' gl0 loc1 from1 to1 val1 releasedm1 released1 ord1 lc2 gl1>>. Proof. inv STEP1. inv STEP2. ss. revert GET. erewrite Memory.add_o; eauto. condtac; ss; try by (des; subst; congr). clear o COND. i. esplits. - econs; eauto. eapply TViewFacts.readable_mon; try apply READABLE; aggrtac; try refl. - rewrite ReorderTView.read_write_tview_eq; eauto; try apply LC_WF0; cycle 1. { inv GL_WF0. inv MEM_CLOSED. exploit CLOSED; eauto. i. des. inv MSG_WF. ss. } econs; ss; eauto. + unfold TView.write_released. ss. repeat (condtac; ss); try by (destruct ord1, ord2; ss). + s. unfold View.singleton_ur_if. econs; repeat (try condtac; try splits; aggrtac; eauto; try apply WRITABLE; unfold TimeMap.singleton, LocFun.add in *; s); (try by inv WRITABLE; eapply TimeFacts.le_lt_lt; eauto; aggrtac). Qed. Lemma reorder_write_write lc0 gl0 loc1 from1 to1 val1 releasedm1 released1 ord1 lc1 gl1 loc2 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2 (ORD1: Ordering.le ord1 Ordering.relaxed) (LOC: loc1 <> loc2) (LC_WF0: Local.wf lc0 gl0) (GL_WF0: Global.wf gl0) (REL1_WF: View.opt_wf releasedm1) (REL2_WF: View.opt_wf releasedm2) (STEP1: Local.write_step lc0 gl0 loc1 from1 to1 val1 releasedm1 released1 ord1 lc1 gl1) (STEP2: Local.write_step lc1 gl1 loc2 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2): exists released2' lc1' lc2' gl1' gl2', <<STEP1: Local.write_step lc0 gl0 loc2 from2 to2 val2 releasedm2 released2' ord2 lc1' gl1'>> /\ <<STEP2: Local.write_step lc1' gl1' loc1 from1 to1 val1 releasedm1 released1 ord1 lc2' gl2'>> /\ <<RELEASED: View.opt_le released2' released2>> /\ <<LOCAL: sim_local lc2' lc2>> /\ <<GLOBAL: sim_global gl2' gl2>>. Proof. inv STEP1. inv STEP2. ss. exploit Promises.reorder_fulfill_fulfill; [exact FULFILL|..]; eauto. i. des. exploit MemoryReorder.add_add; [exact WRITE|exact WRITE0|]. i. des. exploit TViewFacts.write_future0; try exact REL2_WF; try apply LC_WF0. i. des. exploit sim_memory_add_exists; try exact ADD1. { econs 1. exact WF_RELEASED. } { econs; try refl; try apply Bool.implb_same. eapply TViewFacts.write_released_mon; try apply TViewFacts.write_tview_incr; try refl; ss; try apply LC_WF0. eapply TViewFacts.write_future0; eauto. apply LC_WF0. } { refl. } i. des. exploit sim_memory_add_exists; try exact SIM; try exact ADD2; try refl. { econs. eapply TViewFacts.write_future0; ss. apply LC_WF0. } i. des. esplits. - econs; try exact FULFILL1; eauto. eapply TViewFacts.writable_mon; eauto; try refl. aggrtac. - econs; s; try exact FULFILL2; eauto. + unfold TView.write_released. ss. repeat (condtac; aggrtac). + inv WRITABLE. econs; i. * eapply TimeFacts.le_lt_lt; [|apply TS]. repeat (try condtac; viewtac; unfold TimeMap.singleton in *; s). - eapply TViewFacts.write_released_mon; eauto; try refl. + eapply TViewFacts.write_tview_incr. apply LC_WF0. + eapply TViewFacts.write_future0; eauto. apply LC_WF0. - econs; ss. apply ReorderTView.write_write_tview; auto. apply LC_WF0. - econs; ss. refl. Qed. Lemma reorder_write_update lc0 gl0 loc1 from1 to1 val1 releasedm1 released1 ord1 lc1 gl1 loc2 ts2 val2 released2 ord2 lc2 from3 to3 val3 released3 ord3 lc3 gl3 (LOC: loc1 <> loc2) (ORD1: Ordering.le ord1 Ordering.relaxed) (ORD2: Ordering.le ord2 Ordering.relaxed) (LC_WF0: Local.wf lc0 gl0) (GL_WF0: Global.wf gl0) (REL1_WF: View.opt_wf releasedm1) (STEP1: Local.write_step lc0 gl0 loc1 from1 to1 val1 releasedm1 released1 ord1 lc1 gl1) (STEP2: Local.read_step lc1 gl1 loc2 ts2 val2 released2 ord2 lc2) (STEP3: Local.write_step lc2 gl1 loc2 from3 to3 val3 released2 released3 ord3 lc3 gl3): exists released3' lc1' lc2' lc3' gl2' gl3', <<STEP1: Local.read_step lc0 gl0 loc2 ts2 val2 released2 ord2 lc1'>> /\ <<STEP2: Local.write_step lc1' gl0 loc2 from3 to3 val3 released2 released3' ord3 lc2' gl2'>> /\ <<STEP3: Local.write_step lc2' gl2' loc1 from1 to1 val1 releasedm1 released1 ord1 lc3' gl3'>> /\ <<RELEASED: View.opt_le released3' released3>> /\ <<LOCAL: sim_local lc3' lc3>> /\ <<GLOBAL: sim_global gl3' gl3>>. Proof. exploit reorder_write_read; try exact STEP1; eauto. i. des. exploit Local.read_step_future; try exact STEP0; eauto. i. des. exploit reorder_write_write; try exact STEP4; try exact STEP3; eauto. i. des. esplits; eauto. Qed. Lemma reorder_write_is_racy lc0 gl0 loc1 from1 to1 val1 releasedm1 released1 ord1 lc1 gl1 loc2 to2 ord2 (LOC: loc1 <> loc2) (STEP1: Local.write_step lc0 gl0 loc1 from1 to1 val1 releasedm1 released1 ord1 lc1 gl1) (STEP2: Local.is_racy lc1 gl1 loc2 to2 ord2): <<STEP1: Local.is_racy lc0 gl0 loc2 to2 ord2>>. Proof. inv STEP1. inv STEP2; eauto; ss. - inv FULFILL; eauto. revert GET. erewrite BoolMap.remove_o; eauto. revert GETP. erewrite BoolMap.remove_o; eauto. condtac; ss. eauto. - revert GET. erewrite Memory.add_o; eauto. condtac; ss; try by (des; subst; congr). guardH o. i. econs; try exact GET; eauto. eapply TViewFacts.racy_view_mon; try apply RACE. apply View.join_l. Qed. Lemma reorder_write_racy_read lc0 gl0 loc1 from1 to1 val1 releasedm1 released1 ord1 lc1 gl1 loc2 to2 val2 ord2 (LOC: loc1 <> loc2) (STEP1: Local.write_step lc0 gl0 loc1 from1 to1 val1 releasedm1 released1 ord1 lc1 gl1) (STEP2: Local.racy_read_step lc1 gl1 loc2 to2 val2 ord2): <<STEP1: Local.racy_read_step lc0 gl0 loc2 to2 val2 ord2>>. Proof. inv STEP2. exploit reorder_write_is_racy; eauto. Qed. Lemma reorder_write_racy_write lc0 gl0 loc1 from1 to1 val1 releasedm1 released1 ord1 lc1 gl1 loc2 to2 ord2 (LOC: loc1 <> loc2) (STEP1: Local.write_step lc0 gl0 loc1 from1 to1 val1 releasedm1 released1 ord1 lc1 gl1) (STEP2: Local.racy_write_step lc1 gl1 loc2 to2 ord2): <<STEP1: Local.racy_write_step lc0 gl0 loc2 to2 ord2>>. Proof. inv STEP2. exploit reorder_write_is_racy; eauto. Qed. Lemma reorder_write_racy_update lc0 gl0 loc1 from1 to1 val1 releasedm1 released1 ord1 lc1 gl1 loc2 to2 ordr2 ordw2 (LOC: loc1 <> loc2) (STEP1: Local.write_step lc0 gl0 loc1 from1 to1 val1 releasedm1 released1 ord1 lc1 gl1) (STEP2: Local.racy_update_step lc1 gl1 loc2 to2 ordr2 ordw2): <<STEP1: Local.racy_update_step lc0 gl0 loc2 to2 ordr2 ordw2>>. Proof. inv STEP2; eauto. exploit reorder_write_is_racy; eauto. Qed. (* reorder update; step *) Lemma reorder_update_read lc0 gl0 loc1 ts1 val1 released1 ord1 lc1 from2 to2 val2 released2 ord2 lc2 gl2 loc3 ts3 val3 released3 ord3 lc3 (LOC: loc1 <> loc3) (ORD2: Ordering.le ord2 Ordering.relaxed) (ORD3: Ordering.le ord3 Ordering.relaxed) (LC_WF0: Local.wf lc0 gl0) (GL_WF0: Global.wf gl0) (STEP1: Local.read_step lc0 gl0 loc1 ts1 val1 released1 ord1 lc1) (STEP2: Local.write_step lc1 gl0 loc1 from2 to2 val2 released1 released2 ord2 lc2 gl2) (STEP3: Local.read_step lc2 gl2 loc3 ts3 val3 released3 ord3 lc3): exists lc1' lc2', <<STEP1: Local.read_step lc0 gl0 loc3 ts3 val3 released3 ord3 lc1'>> /\ <<STEP2: Local.read_step lc1' gl0 loc1 ts1 val1 released1 ord1 lc2'>> /\ <<STEP3: Local.write_step lc2' gl0 loc1 from2 to2 val2 released1 released2 ord2 lc3 gl2>>. Proof. exploit Local.read_step_future; try exact STEP1; eauto. i. des. exploit reorder_write_read; try exact STEP2; eauto. i. des. exploit reorder_read_read; try exact STEP1; eauto; try congr. i. des. esplits; eauto. Qed. Lemma reorder_update_write lc0 gl0 loc1 ts1 val1 released1 ord1 lc1 from2 to2 val2 released2 ord2 lc2 gl2 loc3 from3 to3 val3 releasedm3 released3 ord3 lc3 gl3 (LOC: loc1 <> loc3) (ORD2: Ordering.le ord2 Ordering.relaxed) (ORD3: Ordering.le ord1 Ordering.acqrel \/ Ordering.le ord3 Ordering.acqrel) (LC_WF0: Local.wf lc0 gl0) (GL_WF0: Global.wf gl0) (REL_WF: View.opt_wf releasedm3) (REL_CLOSED: Memory.closed_opt_view releasedm3 (Global.memory gl0)) (REL_TS: Time.le (View.rlx (View.unwrap releasedm3) loc3) to3) (STEP1: Local.read_step lc0 gl0 loc1 ts1 val1 released1 ord1 lc1) (STEP2: Local.write_step lc1 gl0 loc1 from2 to2 val2 released1 released2 ord2 lc2 gl2) (STEP3: Local.write_step lc2 gl2 loc3 from3 to3 val3 releasedm3 released3 ord3 lc3 gl3): exists released3' released2' lc1' lc2' lc3' gl1' gl3', <<STEP1: Local.write_step lc0 gl0 loc3 from3 to3 val3 releasedm3 released3' ord3 lc1' gl1'>> /\ <<STEP2: Local.read_step lc1' gl1' loc1 ts1 val1 released1 ord1 lc2'>> /\ <<STEP3: Local.write_step lc2' gl1' loc1 from2 to2 val2 released1 released2' ord2 lc3' gl3'>> /\ <<RELEASED2: View.opt_le released2' released2>> /\ <<RELEASED3: View.opt_le released3' released3>> /\ <<LOCAL: sim_local lc3' lc3>> /\ <<GLOBAL: sim_global gl3' gl3>>. Proof. guardH ORD3. exploit Local.read_step_future; try exact STEP1; eauto. i. des. exploit reorder_write_write; try exact STEP2; try exact STEP3; eauto. i. des. exploit reorder_read_write; try exact STEP1; try exact STEP0; eauto. i. des. exploit Local.write_step_future; try exact STEP0; eauto. i. des. exploit Local.write_step_future; try exact STEP5; eauto. i. des. exploit Local.read_step_future; try exact STEP6; eauto. i. des. exploit sim_local_write; try exact STEP4; try exact LOCAL0; try exact GLOBAL0; try refl; eauto. i. des. esplits; eauto; etrans; eauto. Qed. Lemma update_ts lc0 gl0 loc ts1 val1 released1 ord1 lc1 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2 (STEP1: Local.read_step lc0 gl0 loc ts1 val1 released1 ord1 lc1) (STEP2: Local.write_step lc1 gl0 loc from2 to2 val2 releasedm2 released2 ord2 lc2 gl2): Time.lt ts1 to2. Proof. inv STEP1. inv STEP2. inv WRITABLE. ss. eapply TimeFacts.le_lt_lt; eauto. etrans; [|apply TimeMap.join_l]. etrans; [|apply TimeMap.join_r]. unfold View.singleton_ur_if. condtac; ss; aggrtac. Qed. Lemma reorder_update_update lc0 gl0 loc1 ts1 val1 released1 ord1 lc1 from2 to2 val2 released2 ord2 lc2 gl2 loc3 ts3 val3 released3 ord3 lc3 from4 to4 val4 released4 ord4 lc4 gl4 (LOC: loc1 <> loc3) (ORD2: Ordering.le ord2 Ordering.relaxed) (ORD3: Ordering.le ord3 Ordering.relaxed) (ORD: Ordering.le ord1 Ordering.acqrel \/ Ordering.le ord4 Ordering.acqrel) (LC_WF0: Local.wf lc0 gl0) (GL_WF0: Global.wf gl0) (STEP1: Local.read_step lc0 gl0 loc1 ts1 val1 released1 ord1 lc1) (STEP2: Local.write_step lc1 gl0 loc1 from2 to2 val2 released1 released2 ord2 lc2 gl2) (STEP3: Local.read_step lc2 gl2 loc3 ts3 val3 released3 ord3 lc3) (STEP4: Local.write_step lc3 gl2 loc3 from4 to4 val4 released3 released4 ord4 lc4 gl4): exists released2' released4' lc1' lc2' lc3' lc4' gl2' gl4', <<STEP1: Local.read_step lc0 gl0 loc3 ts3 val3 released3 ord3 lc1'>> /\ <<STEP2: Local.write_step lc1' gl0 loc3 from4 to4 val4 released3 released4' ord4 lc2' gl2'>> /\ <<STEP3: Local.read_step lc2' gl2' loc1 ts1 val1 released1 ord1 lc3'>> /\ <<STEP4: Local.write_step lc3' gl2' loc1 from2 to2 val2 released1 released2' ord2 lc4' gl4'>> /\ <<RELEASED2: View.opt_le released2' released2>> /\ <<RELEASED4: View.opt_le released4' released4>> /\ <<LOCAL: sim_local lc4' lc4>> /\ <<GLOBAL: sim_global gl4' gl4>>. Proof. guardH ORD. exploit reorder_update_read; try exact STEP2; try exact STEP1; try exact STEP3; eauto. i. des. exploit Local.read_step_future; try exact STEP0; eauto. i. des. hexploit reorder_update_write; try exact STEP5; try exact STEP6; try exact STEP4; eauto. { etrans; eauto. exploit update_ts; try exact STEP3; eauto. i. econs. ss. } i. des. esplits; eauto. Qed. (** reorder fence; step *) Lemma reorder_fence_read lc0 gl0 ordr1 ordw1 lc1 gl1 loc2 to2 val2 released2 ord2 lc2 (ORDR1: Ordering.le ordr1 Ordering.acqrel) (ORDW1: Ordering.le ordw1 Ordering.relaxed) (ORD2: Ordering.le ord2 Ordering.plain \/ Ordering.le Ordering.acqrel ord2) (LC_WF0: Local.wf lc0 gl0) (GL_WF0: Global.wf gl0) (STEP1: Local.fence_step lc0 gl0 ordr1 ordw1 lc1 gl1) (STEP2: Local.read_step lc1 gl0 loc2 to2 val2 released2 ord2 lc2): exists lc1' lc2' gl2', <<STEP1: Local.read_step lc0 gl0 loc2 to2 val2 released2 ord2 lc1'>> /\ <<STEP2: Local.fence_step lc1' gl0 ordr1 ordw1 lc2' gl2'>> /\ <<LOCAL: sim_local lc2' lc2>> /\ <<GLOBAL: sim_global gl2' gl1>>. Proof. guardH ORD2. inv STEP1. inv STEP2. ss. esplits. - econs; eauto. eapply TViewFacts.readable_mon; eauto; try refl. etrans. + apply TViewFacts.write_fence_tview_incr. apply LC_WF0. + apply TViewFacts.write_fence_tview_mon; try refl; try apply LC_WF0. apply TViewFacts.read_fence_tview_incr. apply LC_WF0. - econs; eauto. - econs; ss. inv GL_WF0. inv MEM_CLOSED. exploit CLOSED; eauto. i. des. inv MSG_WF. exploit TViewFacts.read_future; try exact GET; try apply LC_WF0; eauto. i. des. exploit TViewFacts.read_fence_future; try apply LC_WF0; eauto. i. des. etrans; [|etrans]. + apply TViewFacts.write_fence_tview_mon; [|refl|refl|]. * apply ReorderTView.read_fence_read_tview; auto. apply LC_WF0. * eapply TViewFacts.read_fence_future; eauto. + apply ReorderTView.write_fence_read_tview; eauto. + apply TViewFacts.read_tview_mon; auto; try refl. eapply TViewFacts.write_fence_future; eauto. - econs; try refl. s. etrans. + apply TViewFacts.write_fence_sc_mon; [|refl|refl]. apply ReorderTView.read_fence_read_tview; auto. apply LC_WF0. + eapply ReorderTView.write_fence_read_sc; auto. eapply TViewFacts.read_fence_future; eauto; apply LC_WF0. Qed. Lemma reorder_fence_write lc0 gl0 ordr1 ordw1 lc1 gl1 loc2 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2 (ORDR1: Ordering.le ordr1 Ordering.acqrel) (ORDW1: Ordering.le ordw1 Ordering.relaxed) (LC_WF0: Local.wf lc0 gl0) (GL_WF0: Global.wf gl0) (REL2_WF: View.opt_wf releasedm2) (REL2_CLOSED: Memory.closed_opt_view releasedm2 (Global.memory gl0)) (STEP1: Local.fence_step lc0 gl0 ordr1 ordw1 lc1 gl1) (STEP2: Local.write_step lc1 gl1 loc2 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2): exists released2' lc1' lc2' gl1' gl2', <<STEP1: Local.write_step lc0 gl0 loc2 from2 to2 val2 releasedm2 released2' ord2 lc1' gl1'>> /\ <<STEP2: Local.fence_step lc1' gl1' ordr1 ordw1 lc2' gl2'>> /\ <<RELEASED: View.opt_le released2' released2>> /\ <<LOCAL: sim_local lc2' lc2>> /\ <<GLOBAL: sim_global gl2' gl2>>. Proof. inv STEP1. inv STEP2. ss. exploit TViewFacts.read_fence_future; try apply LC_WF0; eauto. i. des. hexploit TViewFacts.write_fence_future; eauto; try apply GL_WF0. s. i. des. exploit TViewFacts.write_future0; try exact REL2_WF; try apply LC_WF0. i. des. exploit sim_memory_add_exists; try exact WRITE. { econs 1. exact WF_RELEASED. } { econs; try refl; try apply Bool.implb_same. eapply TViewFacts.write_released_mon; try refl; ss; try apply LC_WF0; eauto. etrans; [|eapply TViewFacts.write_fence_tview_incr]; eauto. apply TViewFacts.read_fence_tview_incr. apply LC_WF0. } { refl. } i. des. esplits. - econs; eauto. eapply TViewFacts.writable_mon; eauto; try refl. etrans. + apply TViewFacts.read_fence_tview_incr. apply LC_WF0. + apply TViewFacts.write_fence_tview_incr. eapply TViewFacts.read_fence_future; apply LC_WF0. - econs; eauto. i. destruct ordw1; ss. - eapply TViewFacts.write_released_mon; try refl; ss. etrans; [|eapply TViewFacts.write_fence_tview_incr]; eauto. apply TViewFacts.read_fence_tview_incr. apply LC_WF0. - econs; ss. etrans; [|etrans]. + apply TViewFacts.write_fence_tview_mon; [|refl|refl|]. * apply ReorderTView.read_fence_write_tview; auto. apply LC_WF0. * exploit TViewFacts.write_future; try exact ADD; try apply LC_WF0; try apply GL_WF0; ss. i. des. eapply TViewFacts.read_fence_future; eauto. + apply ReorderTView.write_fence_write_tview; auto. + apply TViewFacts.write_tview_mon; auto; try refl. - econs; ss. etrans. + apply TViewFacts.write_fence_sc_mon; [|refl|refl]. apply ReorderTView.read_fence_write_tview; auto. apply LC_WF0. + eapply ReorderTView.write_fence_write_sc; auto. Qed. Lemma reorder_fence_fence lc0 gl0 ordr1 ordw1 lc1 gl1 ordr2 ordw2 lc2 gl2 (ORDR1: Ordering.le ordr1 Ordering.acqrel) (ORDW1: Ordering.le ordw1 Ordering.relaxed) (ORDR2: Ordering.le ordr2 Ordering.relaxed) (ORDW2: Ordering.le ordw2 Ordering.acqrel) (LC_WF0: Local.wf lc0 gl0) (GL_WF0: Global.wf gl0) (STEP1: Local.fence_step lc0 gl0 ordr1 ordw1 lc1 gl2) (STEP2: Local.fence_step lc1 gl1 ordr2 ordw2 lc2 gl2): exists lc1' lc2' gl1' gl2', <<STEP1: Local.fence_step lc0 gl0 ordr2 ordw2 lc1' gl1'>> /\ <<STEP2: Local.fence_step lc1' gl1' ordr1 ordw1 lc2' gl2'>> /\ <<LOCAL: sim_local lc2' lc2>> /\ <<GLOBAL: sim_global gl2' gl2>>. Proof. inv STEP1. inv STEP2. ss. esplits. - econs; eauto. - econs; eauto. - econs; ss. unfold TView.write_fence_tview, TView.write_fence_sc. econs; repeat (try condtac; aggrtac; try apply LC_WF0). - econs; ss; try refl. unfold TView.write_fence_sc. repeat (try condtac; aggrtac). Qed. (** reorder race; step *) Lemma reorder_is_racy_read lc0 mem0 loc1 to1 ord1 loc2 ts2 val2 released2 ord2 lc2 (LOC: loc1 = loc2 -> Ordering.le ord1 Ordering.plain /\ Ordering.le ord2 Ordering.plain) (ORD2: Ordering.le ord2 Ordering.relaxed) (STEP1: Local.is_racy lc0 mem0 loc1 to1 ord1) (STEP2: Local.read_step lc0 mem0 loc2 ts2 val2 released2 ord2 lc2): <<STEP: Local.is_racy lc2 mem0 loc1 to1 ord1>>. Proof. inv STEP2. inv STEP1; eauto. econs; eauto; ss. inv READABLE. condtac; try by (destruct ord2; ss). repeat apply TimeFacts.join_spec_lt; ss. - unfold View.singleton_ur_if. condtac; ss. + unfold TimeMap.singleton, LocFun.add, LocFun.find. condtac; ss. * subst. exploit LOC; eauto. i. des. destruct ord2; ss. * eapply TimeFacts.le_lt_lt; eauto. apply Time.bot_spec. + eapply TimeFacts.le_lt_lt; eauto. apply Time.bot_spec. - eapply TimeFacts.le_lt_lt; eauto. apply Time.bot_spec. Qed. Lemma reorder_is_racy_write lc0 gl0 loc1 to1 ord1 loc2 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2 (LOC: loc1 <> loc2) (STEP1: Local.is_racy lc0 gl0 loc1 to1 ord1) (STEP2: Local.write_step lc0 gl0 loc2 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2): <<STEP: Local.is_racy lc2 gl2 loc1 to1 ord1>>. Proof. inv STEP2. inv STEP1. - inv FULFILL; eauto. econs; ss. + erewrite BoolMap.remove_o; eauto. condtac; ss. + erewrite BoolMap.remove_o; eauto. condtac; ss. - exploit Memory.add_get1; try exact GET; eauto. i. econs; eauto; ss. apply TimeFacts.join_spec_lt; ss. unfold TimeMap.singleton, LocFun.add. condtac; ss. eapply TimeFacts.le_lt_lt; eauto. apply Time.bot_spec. Qed. Lemma reorder_is_racy_update lc0 gl0 loc1 to1 ord1 loc2 ts2 val2 released2 ord2 lc2 from3 to3 val3 released3 ord3 lc3 gl3 (LOC: loc1 <> loc2) (ORD2: Ordering.le ord2 Ordering.relaxed) (STEP1: Local.is_racy lc0 gl0 loc1 to1 ord1) (STEP2: Local.read_step lc0 gl0 loc2 ts2 val2 released2 ord2 lc2) (STEP3: Local.write_step lc2 gl0 loc2 from3 to3 val3 released2 released3 ord3 lc3 gl3): <<STEP: Local.is_racy lc3 gl3 loc1 to1 ord1>>. Proof. exploit reorder_is_racy_read; eauto; ss. i. des. exploit reorder_is_racy_write; try exact STEP3; eauto. Qed. Lemma reorder_is_racy_fence lc0 gl0 loc1 to1 ord1 ordr2 ordw2 lc2 gl2 (ORDR2: Ordering.le ordr2 Ordering.relaxed) (ORDW2: Ordering.le ordw2 Ordering.acqrel) (STEP1: Local.is_racy lc0 gl0 loc1 to1 ord1) (STEP2: Local.fence_step lc0 gl0 ordr2 ordw2 lc2 gl2): <<STEP: Local.is_racy lc2 gl2 loc1 to1 ord1>>. Proof. inv STEP2. inv STEP1; eauto. econs; eauto; ss. condtac; try by (destruct ordw2; ss). condtac; try by (destruct ordr2; ss). Qed. (** reorder racy-read; step *) Lemma reorder_racy_read_read lc0 gl0 loc1 to1 val1 ord1 loc2 ts2 val2 released2 ord2 lc2 (LOC: loc1 = loc2 -> Ordering.le ord1 Ordering.plain /\ Ordering.le ord2 Ordering.plain) (ORD2: Ordering.le ord2 Ordering.relaxed) (STEP1: Local.racy_read_step lc0 gl0 loc1 to1 val1 ord1) (STEP2: Local.read_step lc0 gl0 loc2 ts2 val2 released2 ord2 lc2): <<STEP: Local.racy_read_step lc2 gl0 loc1 to1 val1 ord1>>. Proof. inv STEP1. exploit reorder_is_racy_read; eauto. Qed. Lemma reorder_racy_read_write lc0 gl0 loc1 to1 val1 ord1 loc2 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2 (LOC: loc1 <> loc2) (STEP1: Local.racy_read_step lc0 gl0 loc1 to1 val1 ord1) (STEP2: Local.write_step lc0 gl0 loc2 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2): <<STEP: Local.racy_read_step lc2 gl2 loc1 to1 val1 ord1>>. Proof. inv STEP1. exploit reorder_is_racy_write; eauto. Qed. Lemma reorder_racy_read_update lc0 gl0 loc1 to1 val1 ord1 loc2 ts2 val2 released2 ord2 lc2 from3 to3 val3 released3 ord3 lc3 gl3 (LOC: loc1 <> loc2) (ORD2: Ordering.le ord2 Ordering.relaxed) (STEP1: Local.racy_read_step lc0 gl0 loc1 to1 val1 ord1) (STEP2: Local.read_step lc0 gl0 loc2 ts2 val2 released2 ord2 lc2) (STEP3: Local.write_step lc2 gl0 loc2 from3 to3 val3 released2 released3 ord3 lc3 gl3): <<STEP: Local.racy_read_step lc3 gl3 loc1 to1 val1 ord1>>. Proof. exploit reorder_racy_read_read; eauto; ss. i. des. exploit reorder_racy_read_write; try exact STEP3; eauto. Qed. Lemma reorder_racy_read_fence lc0 gl0 loc1 to1 val1 ord1 ordr2 ordw2 lc2 gl2 (ORDR2: Ordering.le ordr2 Ordering.relaxed) (ORDW2: Ordering.le ordw2 Ordering.acqrel) (STEP1: Local.racy_read_step lc0 gl0 loc1 to1 val1 ord1) (STEP2: Local.fence_step lc0 gl0 ordr2 ordw2 lc2 gl2): <<STEP: Local.racy_read_step lc2 gl2 loc1 to1 val1 ord1>>. Proof. inv STEP1. exploit reorder_is_racy_fence; eauto. Qed. (** reorder racy-write; step *) Lemma reorder_racy_write_read lc0 gl0 loc1 to1 ord1 loc2 ts2 val2 released2 ord2 lc2 (LOC: loc1 <> loc2) (ORD2: Ordering.le ord2 Ordering.relaxed) (STEP1: Local.racy_write_step lc0 gl0 loc1 to1 ord1) (STEP2: Local.read_step lc0 gl0 loc2 ts2 val2 released2 ord2 lc2): <<STEP: Local.racy_write_step lc2 gl0 loc1 to1 ord1>>. Proof. inv STEP1. exploit reorder_is_racy_read; eauto. ss. Qed. Lemma reorder_racy_write_write lc0 gl0 loc1 to1 ord1 loc2 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2 (LOC: loc1 <> loc2) (STEP1: Local.racy_write_step lc0 gl0 loc1 to1 ord1) (STEP2: Local.write_step lc0 gl0 loc2 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2): <<STEP: Local.racy_write_step lc2 gl2 loc1 to1 ord1>>. Proof. inv STEP1. exploit reorder_is_racy_write; eauto. Qed. Lemma reorder_racy_write_update lc0 gl0 loc1 to1 ord1 loc2 ts2 val2 released2 ord2 lc2 from3 to3 val3 released3 ord3 lc3 gl3 (LOC: loc1 <> loc2) (ORD2: Ordering.le ord2 Ordering.relaxed) (STEP1: Local.racy_write_step lc0 gl0 loc1 to1 ord1) (STEP2: Local.read_step lc0 gl0 loc2 ts2 val2 released2 ord2 lc2) (STEP3: Local.write_step lc2 gl0 loc2 from3 to3 val3 released2 released3 ord3 lc3 gl3): <<STEP: Local.racy_write_step lc3 gl3 loc1 to1 ord1>>. Proof. exploit reorder_racy_write_read; eauto; ss. i. des. exploit reorder_racy_write_write; try exact STEP3; eauto. Qed. Lemma reorder_racy_write_fence lc0 gl0 loc1 to1 ord1 ordr2 ordw2 lc2 gl2 (ORDR2: Ordering.le ordr2 Ordering.relaxed) (ORDW2: Ordering.le ordw2 Ordering.acqrel) (STEP1: Local.racy_write_step lc0 gl0 loc1 to1 ord1) (STEP2: Local.fence_step lc0 gl0 ordr2 ordw2 lc2 gl2): <<STEP: Local.racy_write_step lc2 gl2 loc1 to1 ord1>>. Proof. inv STEP1. exploit reorder_is_racy_fence; eauto. Qed. (** reorder racy-update; step *) Lemma reorder_racy_update_read lc0 gl0 loc1 to1 ordr1 ordw1 loc2 ts2 val2 released2 ord2 lc2 (LOC: loc1 <> loc2) (ORD2: Ordering.le ord2 Ordering.relaxed) (STEP1: Local.racy_update_step lc0 gl0 loc1 to1 ordr1 ordw1) (STEP2: Local.read_step lc0 gl0 loc2 ts2 val2 released2 ord2 lc2): <<STEP: Local.racy_update_step lc2 gl0 loc1 to1 ordr1 ordw1>>. Proof. inv STEP1; eauto. exploit reorder_is_racy_read; eauto. ss. Qed. Lemma reorder_racy_update_write lc0 gl0 loc1 to1 ordr1 ordw1 loc2 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2 (LOC: loc1 <> loc2) (STEP1: Local.racy_update_step lc0 gl0 loc1 to1 ordr1 ordw1) (STEP2: Local.write_step lc0 gl0 loc2 from2 to2 val2 releasedm2 released2 ord2 lc2 gl2): <<STEP: Local.racy_update_step lc2 gl2 loc1 to1 ordr1 ordw1>>. Proof. inv STEP1; eauto. exploit reorder_is_racy_write; eauto. Qed. Lemma reorder_racy_update_update lc0 gl0 loc1 to1 ordr1 ordw1 loc2 ts2 val2 released2 ord2 lc2 from3 to3 val3 released3 ord3 lc3 gl3 (LOC: loc1 <> loc2) (ORD2: Ordering.le ord2 Ordering.relaxed) (STEP1: Local.racy_update_step lc0 gl0 loc1 to1 ordr1 ordw1) (STEP2: Local.read_step lc0 gl0 loc2 ts2 val2 released2 ord2 lc2) (STEP3: Local.write_step lc2 gl0 loc2 from3 to3 val3 released2 released3 ord3 lc3 gl3): <<STEP: Local.racy_update_step lc3 gl3 loc1 to1 ordr1 ordw1>>. Proof. exploit reorder_racy_update_read; eauto; ss. i. des. exploit reorder_racy_update_write; try exact STEP3; eauto. Qed. Lemma reorder_racy_update_fence lc0 gl0 loc1 to1 ordr1 ordw1 ordr2 ordw2 lc2 gl2 (ORDR2: Ordering.le ordr2 Ordering.relaxed) (ORDW2: Ordering.le ordw2 Ordering.acqrel) (STEP1: Local.racy_update_step lc0 gl0 loc1 to1 ordr1 ordw1) (STEP2: Local.fence_step lc0 gl0 ordr2 ordw2 lc2 gl2): <<STEP: Local.racy_update_step lc2 gl2 loc1 to1 ordr1 ordw1>>. Proof. inv STEP1; eauto. exploit reorder_is_racy_fence; eauto. Qed.
function [totSec hh mm ss fract] = dcm_hhmmss(dateStr) if ~ischar(dateStr) dateStr = num2str(dateStr); end hh = str2double(dateStr(1,1:2)); mm = str2double(dateStr(1,3:4)); ss = str2double(dateStr(1,5:6)); fract_start = find(dateStr,'.'); fract = str2double(dateStr(1,fract_start+1:end)); totSec = hh*60*60 + mm*60 + ss; end
[GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : ℙ K V ⊢ ∀ (a b : { v // v ≠ 0 }), Setoid.r a b → Submodule.span K {↑a} = Submodule.span K {↑b} [PROOFSTEP] rintro ⟨a, ha⟩ ⟨b, hb⟩ ⟨x, rfl : x • b = a⟩ [GOAL] case mk.mk.intro K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : ℙ K V b : V hb : b ≠ 0 x : Kˣ ha : x • b ≠ 0 ⊢ Submodule.span K {↑{ val := x • b, property := ha }} = Submodule.span K {↑{ val := b, property := hb }} [PROOFSTEP] exact Submodule.span_singleton_group_smul_eq _ x _ [GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v w : V hv : v ≠ 0 hw : w ≠ 0 ⊢ mk K v hv = mk K w hw ↔ ∃ a, a • w = v [PROOFSTEP] rw [mk_eq_mk_iff K v w hv hw] [GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v w : V hv : v ≠ 0 hw : w ≠ 0 ⊢ (∃ a, a • w = v) ↔ ∃ a, a • w = v [PROOFSTEP] constructor [GOAL] case mp K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v w : V hv : v ≠ 0 hw : w ≠ 0 ⊢ (∃ a, a • w = v) → ∃ a, a • w = v [PROOFSTEP] rintro ⟨a, ha⟩ [GOAL] case mp.intro K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v w : V hv : v ≠ 0 hw : w ≠ 0 a : Kˣ ha : a • w = v ⊢ ∃ a, a • w = v [PROOFSTEP] exact ⟨a, ha⟩ [GOAL] case mpr K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v w : V hv : v ≠ 0 hw : w ≠ 0 ⊢ (∃ a, a • w = v) → ∃ a, a • w = v [PROOFSTEP] rintro ⟨a, ha⟩ [GOAL] case mpr.intro K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v w : V hv : v ≠ 0 hw : w ≠ 0 a : K ha : a • w = v ⊢ ∃ a, a • w = v [PROOFSTEP] refine' ⟨Units.mk0 a fun c => hv.symm _, ha⟩ [GOAL] case mpr.intro K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v w : V hv : v ≠ 0 hw : w ≠ 0 a : K ha : a • w = v c : a = 0 ⊢ 0 = v [PROOFSTEP] rwa [c, zero_smul] at ha [GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : ℙ K V ⊢ Projectivization.submodule v = Submodule.span K {Projectivization.rep v} [PROOFSTEP] conv_lhs => rw [← v.mk_rep] [GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : ℙ K V | Projectivization.submodule v [PROOFSTEP] rw [← v.mk_rep] [GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : ℙ K V | Projectivization.submodule v [PROOFSTEP] rw [← v.mk_rep] [GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : ℙ K V | Projectivization.submodule v [PROOFSTEP] rw [← v.mk_rep] [GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : ℙ K V ⊢ finrank K { x // x ∈ Projectivization.submodule v } = 1 [PROOFSTEP] rw [submodule_eq] [GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : ℙ K V ⊢ finrank K { x // x ∈ Submodule.span K {Projectivization.rep v} } = 1 [PROOFSTEP] exact finrank_span_singleton v.rep_nonzero [GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : ℙ K V ⊢ FiniteDimensional K { x // x ∈ Projectivization.submodule v } [PROOFSTEP] rw [← v.mk_rep] [GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : ℙ K V ⊢ FiniteDimensional K { x // x ∈ Projectivization.submodule (mk K (Projectivization.rep v) (_ : Projectivization.rep v ≠ 0)) } [PROOFSTEP] change FiniteDimensional K (K ∙ v.rep) [GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : ℙ K V ⊢ FiniteDimensional K { x // x ∈ Submodule.span K {Projectivization.rep v} } [PROOFSTEP] infer_instance [GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V u v : ℙ K V h : Projectivization.submodule u = Projectivization.submodule v ⊢ u = v [PROOFSTEP] induction' u using ind with u hu [GOAL] case h K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V u✝ v : ℙ K V h✝ : Projectivization.submodule u✝ = Projectivization.submodule v u : V hu : u ≠ 0 h : Projectivization.submodule (mk K u hu) = Projectivization.submodule v ⊢ mk K u hu = v [PROOFSTEP] induction' v using ind with v hv [GOAL] case h.h K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V u✝ v✝ : ℙ K V h✝² : Projectivization.submodule u✝ = Projectivization.submodule v✝ u : V hu : u ≠ 0 h✝¹ : Projectivization.submodule (mk K u hu) = Projectivization.submodule v✝ v : V hv : v ≠ 0 h✝ : Projectivization.submodule u✝ = Projectivization.submodule (mk K v hv) h : Projectivization.submodule (mk K u hu) = Projectivization.submodule (mk K v hv) ⊢ mk K u hu = mk K v hv [PROOFSTEP] rw [submodule_mk, submodule_mk, Submodule.span_singleton_eq_span_singleton] at h [GOAL] case h.h K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V u✝ v✝ : ℙ K V h✝² : Projectivization.submodule u✝ = Projectivization.submodule v✝ u : V hu : u ≠ 0 h✝¹ : Projectivization.submodule (mk K u hu) = Projectivization.submodule v✝ v : V hv : v ≠ 0 h✝ : Projectivization.submodule u✝ = Projectivization.submodule (mk K v hv) h : ∃ z, z • u = v ⊢ mk K u hu = mk K v hv [PROOFSTEP] exact ((mk_eq_mk_iff K v u hv hu).2 h).symm [GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V H : Submodule K V ⊢ H ∈ Set.range Projectivization.submodule ↔ finrank K { x // x ∈ ↑(Equiv.refl (Submodule K V)) H } = 1 [PROOFSTEP] refine ⟨fun ⟨v, hv⟩ ↦ hv ▸ v.finrank_submodule, fun h ↦ ?_⟩ [GOAL] K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V H : Submodule K V h : finrank K { x // x ∈ ↑(Equiv.refl (Submodule K V)) H } = 1 ⊢ H ∈ Set.range Projectivization.submodule [PROOFSTEP] rcases finrank_eq_one_iff'.1 h with ⟨v : H, hv₀, hv : ∀ w : H, _⟩ [GOAL] case intro.intro K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V H : Submodule K V h : finrank K { x // x ∈ ↑(Equiv.refl (Submodule K V)) H } = 1 v : { x // x ∈ H } hv₀ : v ≠ 0 hv : ∀ (w : { x // x ∈ H }), ∃ c, c • v = w ⊢ H ∈ Set.range Projectivization.submodule [PROOFSTEP] use mk K (v : V) (Subtype.coe_injective.ne hv₀) [GOAL] case h K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V H : Submodule K V h : finrank K { x // x ∈ ↑(Equiv.refl (Submodule K V)) H } = 1 v : { x // x ∈ H } hv₀ : v ≠ 0 hv : ∀ (w : { x // x ∈ H }), ∃ c, c • v = w ⊢ Projectivization.submodule (mk K ↑v (_ : ↑v ≠ ↑0)) = H [PROOFSTEP] rw [submodule_mk, SetLike.ext'_iff, Submodule.span_singleton_eq_range] [GOAL] case h K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V H : Submodule K V h : finrank K { x // x ∈ ↑(Equiv.refl (Submodule K V)) H } = 1 v : { x // x ∈ H } hv₀ : v ≠ 0 hv : ∀ (w : { x // x ∈ H }), ∃ c, c • v = w ⊢ (Set.range fun x => x • ↑v) = ↑H [PROOFSTEP] refine (Set.range_subset_iff.2 fun _ ↦ H.smul_mem _ v.2).antisymm fun x hx ↦ ?_ [GOAL] case h K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V H : Submodule K V h : finrank K { x // x ∈ ↑(Equiv.refl (Submodule K V)) H } = 1 v : { x // x ∈ H } hv₀ : v ≠ 0 hv : ∀ (w : { x // x ∈ H }), ∃ c, c • v = w x : V hx : x ∈ ↑H ⊢ x ∈ Set.range fun x => x • ↑v [PROOFSTEP] rcases hv ⟨x, hx⟩ with ⟨c, hc⟩ [GOAL] case h.intro K : Type u_1 V : Type u_2 inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V H : Submodule K V h : finrank K { x // x ∈ ↑(Equiv.refl (Submodule K V)) H } = 1 v : { x // x ∈ H } hv₀ : v ≠ 0 hv : ∀ (w : { x // x ∈ H }), ∃ c, c • v = w x : V hx : x ∈ ↑H c : K hc : c • v = { val := x, property := hx } ⊢ x ∈ Set.range fun x => x • ↑v [PROOFSTEP] exact ⟨c, congr_arg Subtype.val hc⟩ [GOAL] K : Type u_1 V : Type u_2 inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V L : Type u_3 W : Type u_4 inst✝² : DivisionRing L inst✝¹ : AddCommGroup W inst✝ : Module L W σ : K →+* L f : V →ₛₗ[σ] W hf : Function.Injective ↑f v : { v // v ≠ 0 } c : ↑f ↑v = 0 ⊢ ↑f ↑v = ↑f 0 [PROOFSTEP] simp [c] [GOAL] K : Type u_1 V : Type u_2 inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V L : Type u_3 W : Type u_4 inst✝² : DivisionRing L inst✝¹ : AddCommGroup W inst✝ : Module L W σ : K →+* L f : V →ₛₗ[σ] W hf : Function.Injective ↑f ⊢ (Setoid.r ⇒ Setoid.r) (fun v => { val := ↑f ↑v, property := (_ : ↑f ↑v = 0 → False) }) fun v => { val := ↑f ↑v, property := (_ : ↑f ↑v = 0 → False) } [PROOFSTEP] rintro ⟨u, hu⟩ ⟨v, hv⟩ ⟨a, ha⟩ [GOAL] case mk.mk.intro K : Type u_1 V : Type u_2 inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V L : Type u_3 W : Type u_4 inst✝² : DivisionRing L inst✝¹ : AddCommGroup W inst✝ : Module L W σ : K →+* L f : V →ₛₗ[σ] W hf : Function.Injective ↑f u : V hu : u ≠ 0 v : V hv : v ≠ 0 a : Kˣ ha : (fun m => m • ↑{ val := v, property := hv }) a = ↑{ val := u, property := hu } ⊢ Setoid.r ((fun v => { val := ↑f ↑v, property := (_ : ↑f ↑v = 0 → False) }) { val := u, property := hu }) ((fun v => { val := ↑f ↑v, property := (_ : ↑f ↑v = 0 → False) }) { val := v, property := hv }) [PROOFSTEP] use Units.map σ.toMonoidHom a [GOAL] case h K : Type u_1 V : Type u_2 inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V L : Type u_3 W : Type u_4 inst✝² : DivisionRing L inst✝¹ : AddCommGroup W inst✝ : Module L W σ : K →+* L f : V →ₛₗ[σ] W hf : Function.Injective ↑f u : V hu : u ≠ 0 v : V hv : v ≠ 0 a : Kˣ ha : (fun m => m • ↑{ val := v, property := hv }) a = ↑{ val := u, property := hu } ⊢ (fun m => m • ↑((fun v => { val := ↑f ↑v, property := (_ : ↑f ↑v = 0 → False) }) { val := v, property := hv })) (↑(Units.map ↑σ) a) = ↑((fun v => { val := ↑f ↑v, property := (_ : ↑f ↑v = 0 → False) }) { val := u, property := hu }) [PROOFSTEP] dsimp at ha ⊢ [GOAL] case h K : Type u_1 V : Type u_2 inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V L : Type u_3 W : Type u_4 inst✝² : DivisionRing L inst✝¹ : AddCommGroup W inst✝ : Module L W σ : K →+* L f : V →ₛₗ[σ] W hf : Function.Injective ↑f u : V hu : u ≠ 0 v : V hv : v ≠ 0 a : Kˣ ha : a • v = u ⊢ ↑(Units.map ↑σ) a • ↑f v = ↑f u [PROOFSTEP] erw [← f.map_smulₛₗ, ha] [GOAL] K : Type u_1 V : Type u_2 inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V L : Type u_3 W : Type u_4 inst✝³ : DivisionRing L inst✝² : AddCommGroup W inst✝¹ : Module L W σ : K →+* L τ : L →+* K inst✝ : RingHomInvPair σ τ f : V →ₛₗ[σ] W hf : Function.Injective ↑f u v : ℙ K V h : map f hf u = map f hf v ⊢ u = v [PROOFSTEP] induction' u using ind with u hu [GOAL] case h K : Type u_1 V : Type u_2 inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V L : Type u_3 W : Type u_4 inst✝³ : DivisionRing L inst✝² : AddCommGroup W inst✝¹ : Module L W σ : K →+* L τ : L →+* K inst✝ : RingHomInvPair σ τ f : V →ₛₗ[σ] W hf : Function.Injective ↑f u✝ v : ℙ K V h✝ : map f hf u✝ = map f hf v u : V hu : u ≠ 0 h : map f hf (mk K u hu) = map f hf v ⊢ mk K u hu = v [PROOFSTEP] induction' v using ind with v hv [GOAL] case h.h K : Type u_1 V : Type u_2 inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V L : Type u_3 W : Type u_4 inst✝³ : DivisionRing L inst✝² : AddCommGroup W inst✝¹ : Module L W σ : K →+* L τ : L →+* K inst✝ : RingHomInvPair σ τ f : V →ₛₗ[σ] W hf : Function.Injective ↑f u✝ v✝ : ℙ K V h✝² : map f hf u✝ = map f hf v✝ u : V hu : u ≠ 0 h✝¹ : map f hf (mk K u hu) = map f hf v✝ v : V hv : v ≠ 0 h✝ : map f hf u✝ = map f hf (mk K v hv) h : map f hf (mk K u hu) = map f hf (mk K v hv) ⊢ mk K u hu = mk K v hv [PROOFSTEP] simp only [map_mk, mk_eq_mk_iff'] at h ⊢ [GOAL] case h.h K : Type u_1 V : Type u_2 inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V L : Type u_3 W : Type u_4 inst✝³ : DivisionRing L inst✝² : AddCommGroup W inst✝¹ : Module L W σ : K →+* L τ : L →+* K inst✝ : RingHomInvPair σ τ f : V →ₛₗ[σ] W hf : Function.Injective ↑f u✝ v✝ : ℙ K V h✝² : map f hf u✝ = map f hf v✝ u : V hu : u ≠ 0 h✝¹ : map f hf (mk K u hu) = map f hf v✝ v : V hv : v ≠ 0 h✝ : map f hf u✝ = map f hf (mk K v hv) h : ∃ a, a • ↑f v = ↑f u ⊢ ∃ a, a • v = u [PROOFSTEP] rcases h with ⟨a, ha⟩ [GOAL] case h.h.intro K : Type u_1 V : Type u_2 inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V L : Type u_3 W : Type u_4 inst✝³ : DivisionRing L inst✝² : AddCommGroup W inst✝¹ : Module L W σ : K →+* L τ : L →+* K inst✝ : RingHomInvPair σ τ f : V →ₛₗ[σ] W hf : Function.Injective ↑f u✝ v✝ : ℙ K V h✝¹ : map f hf u✝ = map f hf v✝ u : V hu : u ≠ 0 h✝ : map f hf (mk K u hu) = map f hf v✝ v : V hv : v ≠ 0 h : map f hf u✝ = map f hf (mk K v hv) a : L ha : a • ↑f v = ↑f u ⊢ ∃ a, a • v = u [PROOFSTEP] refine ⟨τ a, hf ?_⟩ [GOAL] case h.h.intro K : Type u_1 V : Type u_2 inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V L : Type u_3 W : Type u_4 inst✝³ : DivisionRing L inst✝² : AddCommGroup W inst✝¹ : Module L W σ : K →+* L τ : L →+* K inst✝ : RingHomInvPair σ τ f : V →ₛₗ[σ] W hf : Function.Injective ↑f u✝ v✝ : ℙ K V h✝¹ : map f hf u✝ = map f hf v✝ u : V hu : u ≠ 0 h✝ : map f hf (mk K u hu) = map f hf v✝ v : V hv : v ≠ 0 h : map f hf u✝ = map f hf (mk K v hv) a : L ha : a • ↑f v = ↑f u ⊢ ↑f (↑τ a • v) = ↑f u [PROOFSTEP] rwa [f.map_smulₛₗ, RingHomInvPair.comp_apply_eq₂] [GOAL] K : Type u_1 V : Type u_2 inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V L : Type u_3 W : Type u_4 inst✝² : DivisionRing L inst✝¹ : AddCommGroup W inst✝ : Module L W ⊢ map LinearMap.id (_ : Function.Injective ↑(LinearEquiv.refl K V)) = id [PROOFSTEP] ext ⟨v⟩ [GOAL] case h.mk K : Type u_1 V : Type u_2 inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V L : Type u_3 W : Type u_4 inst✝² : DivisionRing L inst✝¹ : AddCommGroup W inst✝ : Module L W x✝ : ℙ K V v : { v // v ≠ 0 } ⊢ map LinearMap.id (_ : Function.Injective ↑(LinearEquiv.refl K V)) (Quot.mk Setoid.r v) = id (Quot.mk Setoid.r v) [PROOFSTEP] rfl [GOAL] K : Type u_1 V : Type u_2 inst✝⁹ : DivisionRing K inst✝⁸ : AddCommGroup V inst✝⁷ : Module K V L : Type u_3 W : Type u_4 inst✝⁶ : DivisionRing L inst✝⁵ : AddCommGroup W inst✝⁴ : Module L W F : Type u_5 U : Type u_6 inst✝³ : Field F inst✝² : AddCommGroup U inst✝¹ : Module F U σ : K →+* L τ : L →+* F γ : K →+* F inst✝ : RingHomCompTriple σ τ γ f : V →ₛₗ[σ] W hf : Function.Injective ↑f g : W →ₛₗ[τ] U hg : Function.Injective ↑g ⊢ map (LinearMap.comp g f) (_ : Function.Injective (↑g ∘ fun x => ↑f x)) = map g hg ∘ map f hf [PROOFSTEP] ext ⟨v⟩ [GOAL] case h.mk K : Type u_1 V : Type u_2 inst✝⁹ : DivisionRing K inst✝⁸ : AddCommGroup V inst✝⁷ : Module K V L : Type u_3 W : Type u_4 inst✝⁶ : DivisionRing L inst✝⁵ : AddCommGroup W inst✝⁴ : Module L W F : Type u_5 U : Type u_6 inst✝³ : Field F inst✝² : AddCommGroup U inst✝¹ : Module F U σ : K →+* L τ : L →+* F γ : K →+* F inst✝ : RingHomCompTriple σ τ γ f : V →ₛₗ[σ] W hf : Function.Injective ↑f g : W →ₛₗ[τ] U hg : Function.Injective ↑g x✝ : ℙ K V v : { v // v ≠ 0 } ⊢ map (LinearMap.comp g f) (_ : Function.Injective (↑g ∘ fun x => ↑f x)) (Quot.mk Setoid.r v) = (map g hg ∘ map f hf) (Quot.mk Setoid.r v) [PROOFSTEP] rfl
At the Denture Centre we offer the full range of Dental Prosthetic services at six convenient location across the South, North and Northwest Tasmania. The Denture Centre Group was established in 1995 to collaborate with colleagues for mutual benefit then to develop a critical standard of practice that has become the main stream for others to follow. We have have been pioneers and proudly so! Come and experience our hospitality, skill and care, we're sure you will be delighted with the results! Each mouthguard is individually moulded to fit the mouth of the person for whom it is made. It is made from heavy duty vinyl, and is designed to reduce impact and lessen the chance of chipped or broken teeth, particularly when playing sport. We recommend mouthguards for sports men and women of all ages (particularly children), and suggest that they should be worn at all times while playing and training.
/- Copyright (c) 2022 Arthur Paulino. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Arthur Paulino -/ import FxyLang.Reasoning.Defs open Continuation.extends theorem Continuation.depthOfExtends {k k' : Continuation} (h : k.extends k') : k.depth ≤ k'.depth := by induction h with | byId => simp | bySeq _ hi => exact Nat.le_step hi | byDecl _ hi => exact Nat.le_step hi | byFork _ hi => exact Nat.le_step hi | byLoop _ hi => exact Nat.le_step hi | byUnOp _ hi => exact Nat.le_step hi | byBinOp₁ _ hi => exact Nat.le_step hi | byBinOp₂ _ hi => exact Nat.le_step hi | byApp _ hi => exact Nat.le_step hi | byBlock _ hi => exact Nat.le_step hi | byPrint _ hi => exact Nat.le_step hi theorem State.skip : ⟦c, .skip⟧ » ⟦c, .nil⟧ := by intro k refine ⟨1, ?_⟩ simp [stepN, step] intro i hᵢ cases i with | zero => rw [stepN]; exact byId | succ i => cases i with | zero => rw [stepN]; exact byId | succ i => have : i.succ.succ > 1 := by by_cases h : i.succ.succ ≤ 1 · by_cases h' : i.succ.succ > 1 · exact h' · contradiction · exact Nat.gt_of_not_le h contradiction -- set_option hygiene false in macro "big_step " h:ident " with " k:ident n:ident h₁:ident h₂:ident : tactic => do `(tactic| have $k:ident : Continuation := default; have $h₁:ident := $h:ident $k:ident; cases $h₁:ident with | intro $n:ident FOO__ => ?_; have $h₁:ident := FOO__.1; have $h₂:ident := FOO__.2; clear FOO__) open Lean.Elab.Tactic in set_option hygiene false in elab "small_step " n:ident " at " h:ident : tactic => do evalTactic $ ←`(tactic| cases $n:ident with | zero => simp [step, stepN] at $h:ident | succ $n:ident => ?_) evalTactic $ ←`(tactic| simp [step, stepN] at $h:ident) theorem State.eval (h : ⟦c, .eval e⟧ » ⟦c', v⟧) : c = c' := by big_step h with k n h₁ h₂ cases e with | lit l => small_step n at h₁ small_step n at h₁ sorry | _ => sorry theorem State.decl (h : ⟦c, p⟧ » ⟦c', v⟧) : ⟦c, .decl nm p⟧ » ⟦c.insert nm v, .nil⟧ := by big_step h with k n h₁ h₂ sorry
import Baysor Baysor.run_cli(["--help"]); Baysor.run_cli(["run", "--help"]); Baysor.run_cli(["preview", "--help"]); # To build, run create_sysimage(:Baysor; precompile_execution_file="$(dirname(pathof(Baysor)))/../bin/build.jl", replace_default=true) # If you need to build app, comment @require part in __init__ function of ImageCore (~/.julia/packages/ImageCore/BTvmx/src/ImageCore.jl:167) # and use create_app instead of create_sysimage
import os import os.path as osp import yaml import numpy as np from easydict import EasyDict as edict config = edict() config.GPU = '0' config.USE_GT = True config.NUM_WORKERS = 16 config.DEBUG = False config.PRINT_INFO = True config.PRINT_INTERVAL = 10 config.BATCH_SIZE = 1024 config.RANDOM_SEED = 2019 config.OUTPUT_DIR = '../output' config.LOG_DIR = '../log' config.DATA_DIR = '../data' config.DATA = edict() config.DATA.DATASET_NAME = "h36m" config.DATA.FRAME_INTERVAL = 1 config.DATA.EXP_TMC = False config.DATA.EXP_TMC_START = 0 config.DATA.EXP_TMC_DETERMINISTIC = False config.DATA.EXP_TMC_INTERVAL = 5 config.DATA.NUM_FRAMES = 1 config.DATA.NUM_JOINTS = 17 config.DATA.DIFF_SUFFIX = "diff5" config.DATA.USE_IDEAL_SCALE = False config.DATA.USE_EXTRA_DATA = False config.DATA.USE_RANDOM_DIFF = False config.DATA.MIN_DIFF_DIST = 5 config.DATA.SCALE_MID_MEAN = 0.714 config.DATA.SCALE_MID_STD = 0.051 config.DATA.NUM_NEIGHBOUR_FRAMES = 1 config.DATA.NUM_NEIGHBOUR_TUPLES = 0 config.DATA.NEIGHBOUR_FRAME_INTERVAL = 1 config.DATA.ONLINE_ROT = False # config.DATA.INDICES_14 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 16] # config.DATA.PARENT_17 = [1, 2, 13, 13, 3, 4, 7, 8, 12, 12, 9, 10, 14, 13, 13, 12, 15] # -1 will not be considered in the bone_indices below # config.DATA.PARENT_14 = [1, 2, 12, 12, 3, 4, 7, 8, -1, -1, 9, 10, 13, -1] # the bones to be consider, exclude pelvis # config.DATA.BONES_17 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16] # config.DATA.BONES_14 = [0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12] # config.DATA.PARENTS = config.DATA.PARENT_17 if config.DATA.NUM_JOINTS == 17 else config.DATA.PARENT_14 # need to be updated config.DATA.TRAIN_PATH = '' config.DATA.VALID_PATH = '' config.DATA.USE_SAME_NORM_2D = True config.DATA.USE_SAME_NORM_3D = False config.DATA.USE_2D_GT_SUPERVISION = False config.NETWORK = edict() # whether to use the model arch in `a simple yet effective baseline` config.NETWORK.DIS_USE_SPECTRAL_NORM = False config.NETWORK.USE_BASELINE = False config.NETWORK.NUM_CHANNELS = 1024 config.NETWORK.DROPOUT = 0.25 config.NETWORK.BN_TRACK = True config.NETWORK.DIS_USE_BN = False config.NETWORK.DEPTH_ESTIMATOR_RES_BLOCKS = 1 config.NETWORK.LIFTER_RES_BLOCKS = 4 config.NETWORK.DIS_RES_BLOCKS = 2 config.NETWORK.DIS_TEMP_RES_BLOCKS = 2 config.NETWORK.SCALER_INPUT_SIZE = 37 config.NETWORK.SCALER_RES_BLOCKS = 1 config.NETWORK.ROTATER_RES_BLOCKS = 1 config.NETWORK.ROTATER_PRE_EULER = True config.NETWORK.USE_SIMPLE_MODEL = False config.TRAIN = edict() config.TRAIN.SCHEDULER_STEP_SIZE = 1 config.TRAIN.SCHEDULER_GAMMA = 0.95 config.TRAIN.SCALE_ON_3D = False config.TRAIN.USE_GT_SCALE = False config.TRAIN.GENERIC_BASELINE = False config.TRAIN.LOSS_TYPE = "ss" config.TRAIN.FINETUNE_ROTATER = False config.TRAIN.USE_BONE_NOSCALE = False config.TRAIN.USE_CYCLE = False config.TRAIN.USE_SCALER = False config.TRAIN.LEARN_SYMMETRY = True config.TRAIN.USE_ROTATER = False config.TRAIN.SCALER_MEAN_ONLY = False # scaler relevant config.TRAIN.SCALE_MID_PER_SEQ_OPT = False config.TRAIN.SCALE_MID_ACC_STEPS = 1 config.TRAIN.USE_TEMP = False config.TRAIN.USE_NEW_TEMP = False config.TRAIN.USE_DIS = True config.TRAIN.USE_LSTM = False config.TRAIN.MULTI_NEW_TEMP = False config.TRAIN.CAT_CURRENT = False config.TRAIN.PRETRAIN_LIFTER = True config.TRAIN.LIFTER_PRETRAIN_PATH = "../output/model.pth.tar" config.TRAIN.CAMERA_SKELETON_DISTANCE = 10.0 config.TRAIN.USE_NEW_ROT = True config.TRAIN.RESUME_TRAIN = True config.TRAIN.SUBNET_CRITICS = 1 config.TRAIN.MAINNET_CRITICS = 1 config.TRAIN.ROTATENET_CRITICS = 1 # in the paper weights are [0.001, 10.0, 1.0] config.TRAIN.SCALE_LOSS_WEIGHTS = [1.0, 1.0] # first for the temporal, second for the euler penalty config.TRAIN.ROTATE_LOSS_WEIGHTS = [1.0, 0.001] config.TRAIN.LOSS_WEIGHTS = [1.0, 1.0, 1.0, 1.0, 10.0] # config.TRAIN.LOSS_WEIGHTS = [0.05, 5.0, 1.5] config.TRAIN.POSE_LR = 0.0002 # 0.001 config.TRAIN.DIS_LR = 0.0002 config.TRAIN.TEMP_LR = 0.0002 config.TRAIN.WD = 0.0001 config.TRAIN.NUM_CRITICS = 3 config.TRAIN.NUM_CRITICS_TEMP = 3 config.TRAIN.NUM_EPOCHS = 200 config.TRAIN.OPTIMIZER = 'adam' config.TRAIN.BOUND_AZIM = 3.1415926 # np.pi config.TRAIN.BOUND_ELEV = 3.1415926 / 9 # np.pi / 9 config.TRAIN.PRETRAINED = False # need to be updated config.TRAIN.MODEL_PATH = '' config.VIS = edict() config.VIS.SCALE_MID_NUM_SEQ = 3 # Cudnn related params config.CUDNN = edict() config.CUDNN.BENCHMARK = True config.CUDNN.DETERMINISTIC = False config.CUDNN.ENABLED = True config.FIX = edict() config.FIX.FIX_BONE_LOSS = False config.FIX.FIX_TRAJ = False config.FIX.FIX_TRAJ_BY_ROT = False def _update_dict(k, v): for vk, vv in v.items(): if vk in config[k]: config[k][vk] = vv else: raise ValueError("{}.{} not exist in config.py".format(k, vk)) def update_config(config_file): exp_config = None with open(config_file) as f: exp_config = edict(yaml.load(f)) for k, v in exp_config.items(): if k in config: if isinstance(v, dict): _update_dict(k, v) else: config[k] = v else: raise ValueError("{} not exist in config.py".format(k)) assert not config.TRAIN.USE_TEMP or not config.TRAIN.USE_NEW_TEMP, "Don't use both temporal methods" assert config.DATA.NUM_NEIGHBOUR_TUPLES <= config.DATA.NUM_NEIGHBOUR_FRAMES * (config.DATA.NUM_NEIGHBOUR_FRAMES - 1) // 2 def update_dir(model_dir, log_dir, data_dir, debug): if model_dir: os.makedirs(model_dir, exist_ok=True) config.OUTPUT_DIR = model_dir os.makedirs(log_dir, exist_ok=True) os.makedirs(data_dir, exist_ok=True) config.LOG_DIR = log_dir config.DATA_DIR = data_dir if config.DATA.DATASET_NAME == 'surreal': config.DATA.TRAIN_PATH = osp.join(config.DATA_DIR, "surreal_train_pred3.h5") config.DATA.VALID_PATH = osp.join(config.DATA_DIR, "surreal_valid_pred3.h5") elif config.DATA.DATASET_NAME == "h36m": # config.DATA.TRAIN_PATH = osp.join(config.DATA_DIR, "../../unsupervised_mesh/data/h36m_train_pred_3d_mesh.h5" if not debug else "debug_train.h5") # config.DATA.VALID_PATH = osp.join(config.DATA_DIR, "../../unsupervised_mesh/data/h36m_valid_pred_3d_mesh.h5" if not debug else "debug_valid.h5") config.DATA.TRAIN_PATH = osp.join(config.DATA_DIR, "h36m_train_pred3.h5" if not debug else "debug_train.h5") config.DATA.VALID_PATH = osp.join(config.DATA_DIR, "h36m_valid_pred3.h5" if not debug else "debug_valid.h5") elif config.DATA.DATASET_NAME == 'mpi': config.DATA.TRAIN_PATH = osp.join(config.DATA_DIR, "mpi_train_pred3.h5") config.DATA.VALID_PATH = osp.join(config.DATA_DIR, "mpi_valid_pred3.h5") config.TRAIN.MODEL_PATH = osp.join(config.OUTPUT_DIR, "model.pkl")
function tapas_uniqc_new_method(varargin) % tapas_uniqc_new_method creates a new method assuming that you are in the corresponding class % folder; creates header using a template. % tapas_uniqc_new_method(funname) opens the editor and pastes the content % of a user-defined template into the file funname.m. % % Example % tapas_uniqc_new_method myfunfun % OR % tapas_uniqc_new_method myfunfun author % % opens the editor and pastes the following % % function output = myfunfun(input) % %MYFUNFUN One-line description here, please. % % output = myfunfun(input) % % % % Example % % myfunfun % % % % See also % % % Author: Your name % % Created: 2005-09-22 % % Copyright 2005 Your company. % % See also edit, mfiletemplate % Author: Peter (PB) Bodin % Created: 2005-09-22 % Modified: 2014-04-15 (Saskia Klein and Lars Kasper, IBT Zurich) % See the variables repstr, repwithstr and tmpl to figure out how % to design your own template. % Edit tmpl to your liking, if you add more tokens in tmpl, make % sure to add them in repstr and repwithstr as well. % I made this function just for fun to check out some java handles to % the editor. It would probably be better to fprintf the template % to a new file and then call edit, since the java objects might change % names between versions. switch nargin case 0 edit warning('new_method without argument is the same as edit') return; case 1 fname=varargin{1}; edit(fullfile(pwd,fname)); authors = 'Saskia Bollmann & Lars Kasper'; %defuaults authors, set down in function authors case 2 fname = varargin{1}; authors = varargin{2}; otherwise error('tapas:uniqc:TooManyInputArguments', ... 'too many input arguments') end % determine class name from directory name [~, classname] = fileparts(pwd); classname = regexprep(classname, '@', ''); try lasterror edhandle=com.mathworks.mlservices.MLEditorServices; % R2009a => 2009.0, R2009b = 2009.5 vs = version('-release'); v = str2double(vs(1:4)); if vs(5)=='b' v = v + 0.5; end if v < 2009.0 edhandle.builtinAppendDocumentText(strcat(fname,'.m'),... parse(fname,authors, classname)); else edhandle.getEditorApplication.getActiveEditor.appendText(... parse(fname, authors, classname)); end catch rethrow(lasterror) end function out = parse(func, authors, classname) tmpl={ ... 'function this = $filename(this)' '%ONE_LINE_DESCRIPTION' '%' '% Y = $classname()' '% Y.$filename(inputs)' '%' '% This is a method of class $classname.' '%' '% IN' '%' '% OUT' '%' '% EXAMPLE' '% $filename' '%' '% See also $classname' ' ' '% Author: $author' '% Created: $date' '% Copyright (C) $year $institute' '% $company' '%' '% This file is part of the TAPAS UniQC Toolbox, which is released' '% under the terms of the GNU General Public License (GPL), version 3. ' '% You can redistribute it and/or modify it under the terms of the GPL' '% (either version 3 or, at your option, any later version).' '% For further details, see the file COPYING or' '% <http://www.gnu.org/licenses/>.' }; repstr={... '$classname' '$filename' '$FILENAME' '$date' '$year' '$author' '$institute' '$company'}; repwithstr={... classname func upper(func) datestr(now,29) datestr(now,10) authors 'Institute for Biomedical Engineering' 'University of Zurich and ETH Zurich'}; for k = 1:numel(repstr) tmpl = strrep(tmpl,repstr{k},repwithstr{k}); end out = sprintf('%s\n',tmpl{:}); end end
theory Llist_of_stream_iterate imports Main "$HIPSTER_HOME/IsaHipster" Literate Siterate Stream_of_llist_of_stream begin setup Tactic_Data.set_coinduct_sledgehammer setup Misc_Data.set_noisy (*cohipster llist_of_stream siterate literate*) (*ca 20 sec*) lemma lemma_ac [thy_expl]: "llist_of_stream (siterate y z) = literate y z" by (coinduction arbitrary: y z rule: Llist.Llist.coinduct_strong) auto end
(* *********************************************************************) (* *) (* The CertiKOS Certified Kit Operating System *) (* *) (* The FLINT Group, Yale University *) (* *) (* Copyright The FLINT Group, Yale University. All rights reserved. *) (* This file is distributed under the terms of the Yale University *) (* Non-Commercial License Agreement. *) (* *) (* *********************************************************************) (** * Language definitions *) (** The type classes in the file can be used to define a language and instantiate the layer framework correspondingly. A language is characterized by the types it uses for identifiers, function definitions and variable definitions. We also need to define the domain that will be used to interpret the semantics of primitives, and the corresponding notion of simulations. Once these basic ingredients are provided, we need to provide instances of corresponding structures for modules and layers. If we use [positive] for identifiers, as Compcert does, this can be done automatically by [PTreeModules] and [PTreeLayers]. The last step is to define the semantics of modules, by giving an interpretation in [∀ D, layer D -> layer D]: the semantics tells us, if we use a module [M] in a context which implements layer [L], that it will implement the specifications in the layer [〚M〛 L]. *) Require Export liblayers.logic.Modules. Require Export liblayers.logic.Layers. Require Export liblayers.logic.Semantics. (** ** Layer logic *) (** The interface for the layer logic is given below. It is instantiated by the [LayerLogicImpl] Coq module, which interprets the module typing judgement [L1 ⊢ (R, M) : L2] in terms of the language's semantics as [sim R L2 (〚M〛 L1)]. *) Class LayerLogicOps {layerdata simrel} ident F primsem V module layer `{sem_ops: SemanticsOps layerdata ident F primsem V module layer} := { ll_vdash {D1 D2} :> Vdash (layer D1) (simrel D2 D1 * module) (layer D2) }. Class LayerLogic {layerdata simrel} ident F primsem V module layer `{ll_ops: LayerLogicOps layerdata simrel ident F primsem V module layer} `{rg_ops: !ReflexiveGraphOps layerdata simrel} `{primsem_sim: !Sim simrel primsem} `{layer_sim: !Sim simrel layer} := { (* sem_rule {D} (M: module) (L: layer D): L ⊢ (id, M) : 〚M〛 L; conseq_rule {D1 D2 D3 D4} R21 R32 R43 L1 L2 L3 L4 M: simRR D2 D1 R21 L2 L1 -> simRR D4 D3 R43 L4 L3 -> L2 ⊢ (R32, M) : L3 -> L1 ⊢ (R21 ∘ R32 ∘ R43, M) : L4; vcomp_rule D1 D2 D3 (R: simrel D2 D1) (S: simrel D3 D2) L1 L2 L3 M N: L1 ⊢ (R, M) : L2 -> L2 ⊢ (S, N) : L3 -> L1 ⊢ (R ∘ S, M ⊕ N) : L3; *) conseq_le_le D1 D2 (R: simrel D1 D2) L1 L2 L3 L4 M: L2 ⊢ (R, M) : L3 -> L2 ≤ L1 -> L4 ≤ L3 -> L1 ⊢ (R, M) : L4; hcomp_rule D D' (R: simrel D' D) L M1 M2 (L1 L2: layer D'): layers_disjoint L1 L \/ layers_disjoint L2 L -> L ⊢ (R, M1) : L1 -> L ⊢ (R, M2) : L2 -> L ⊢ (R, M1 ⊕ M2) : L1 ⊕ L2 }. (** * Derived rules *) Section DERIVED_RULES. Context `{Hll: LayerLogic}. (* Context `{Hld: !Category layerdata simrel}. *) Context `{Hmodule: !Modules ident F V module}. Context `{Hlayer: !Layers ident primsem V layer}. Context `{fsem_ops: !FunctionSemanticsOps ident F primsem V module layer}. Context `{Hsem: !Semantics ident F primsem V module layer}. (** The following specialized versions of the consequence rule are easier to apply depending on situation, since you don't have to rewrite the relation involved to account for identities. *) (* Lemma conseq_le_sim {D1 D2} (R: simrel D2 D1) M L1 L2 L3 L4: L2 ⊢ (id, M) : L3 -> L2 ≤ L1 -> sim R L4 L3 -> L1 ⊢ (R, M) : L4. Proof. intros HM HL21 HL43. rewrite <- (cat_compose_id_left R). rewrite <- (cat_compose_id_right id). eapply conseq_rule; eassumption. Qed. Lemma conseq_sim_le {D1 D2} (R: simrel D2 D1) M L1 L2 L3 L4: L2 ⊢ (id, M) : L3 -> sim R L2 L1 -> L4 ≤ L3 -> L1 ⊢ (R, M) : L4. Proof. intros HM HL21 HL43. rewrite <- (cat_compose_id_right R). rewrite <- (cat_compose_id_right (R ∘ id)). eapply conseq_rule; eassumption. Qed. Lemma conseq_le_le {D1 D2} (R: simrel D2 D1) M L1 L2 L3 L4: L2 ⊢ (R, M) : L3 -> L2 ≤ L1 -> L4 ≤ L3 -> L1 ⊢ (R, M) : L4. Proof. intros HM HL21 HL43. rewrite <- (cat_compose_id_right R). rewrite <- (cat_compose_id_left R). eapply conseq_rule; eassumption. Qed. *) Lemma conseq_le_left {D1 D2} (R: simrel D1 D2) M L1 L1' L2: L1 ⊢ (R, M) : L2 -> L1 ≤ L1' -> L1' ⊢ (R, M) : L2. Proof. intros HM HL1. eapply conseq_le_le. * apply HM. * apply HL1. * reflexivity. Qed. Lemma conseq_le_right {D1 D2} (R: simrel D1 D2) M L1 L2 L2': L1 ⊢ (R, M) : L2 -> L2' ≤ L2 -> L1 ⊢ (R, M) : L2'. Proof. intros HM HL2. eapply conseq_le_le. * apply HM. * reflexivity. * apply HL2. Qed. (** The frame rule can be proved from horizontal composition and some consequence rules. *) (** Not sure how to fit [layers_disjoint] in though <<< Lemma frame_rule D D' (R: simrel D' D) L1 L2 M1 M2 L1' L2': L1 ⊢ (R, M1) : L1' -> L2 ⊢ (R, M2) : L2' -> L1 ⊕ L2 ⊢ (R, M1 ⊕ M2) : L1' ⊕ L2'. Proof. intros H1 H2. apply hcomp_rule. * eapply conseq_le_left; try eassumption. apply left_upper_bound. * eapply conseq_le_left; try eassumption. apply right_upper_bound. Qed. >>> **) End DERIVED_RULES.
import linearAlgebra.basic -- initiating the file universes u v variables {F : Type u} {V : Type v} variables [field F] [add_comm_group V] [vector_space F V] (u v w : V) (a b c : F) open vector_space -- Let's define some basic results we are going to need, these are from our -- definition of a vector space, lemma left_dist (a : F) (u v : V) : a • ( u + v ) = a • u + a • v := left_dist a u v lemma right_dist (a b : F) (u : V) : (a + b) • u = a • u + b • u := right_dist a b u lemma smul_smul' (a b : F) (u : V) : a • (b • u) = (a * b) • u := smul_smul a b u lemma smul_id (u : V) : (1 : F) • u = u := smul_id u section question1 /- Prove the fact that 0 • u = 0, where 0 is the zero vector -/ lemma zero_smul' (u : V) : (0 : V) = (0 : F) • u := begin sorry end end question1 section question2 /- What about the other way? -/ lemma smul_zero'' (u : V) : a • (0 : V) = (0 : V) := begin sorry end end question2 section question3 /- This one is slightly harder, try to prove that -u is just -1 • u -/ lemma inv_eq_neg (u : V) (x : F) : -u = (-1 : F) • u := begin sorry end end question3
using Test using Astro print("leap years") @test is_leap_year(2004) == true @test is_leap_year(333, false) == false println(" passed") print("7.a Convert Gregorian date to Julian day number") jd = cal_to_jd(1957, 10, 4.81) @test jd == 2436116.31 println(" passed") print("7.a Convert Gregorian date to Julian day number — meeus'") jd = cal_to_jd_m(1957, 10, 4.81) @test jd == 2436116.31 println(" passed") print("7.b Convert Julian date to Julian day number") jd = cal_to_jd(333, 1, 27.5, false) # currently fails, is off by one # @test isapprox(jd, 1842713.0, atol=0.1) println(" passed") print("7.b Convert Julian date to Julian day number — meeus") jd = cal_to_jd_m(333, 1, 27.5, false) # currently fails, is off by one # @test isapprox(jd, 1842713.0, atol=0.1) println(" passed") print("7.c Convert Julian day number to Gregorian date") yr, mo, day = jd_to_cal(2436116.31) @test yr == 1957 @test mo == 10 @test isapprox(day, 4.81, atol=0.1) println(" passed") print("7.c(1) Convert Julian day number to Julian date") yr, mo, day = jd_to_cal(1842713.0, false) @test yr == 333 @test mo == 1 @test isapprox(day, 27.5, atol=0.01) println(" passed") print("7.c(2) Convert Julian day number to Julian date") yr, mo, day = jd_to_cal(1507900.13, false) @test yr == -584 @test mo == 5 @test isapprox(day, 28.63, atol=0.01) println(" passed") print("7.d Time interval in days") jd0 = cal_to_jd(1910, 4, 20.0) jd1 = cal_to_jd(1986, 2, 9.0) @test jd1 - jd0 == 27689 println(" passed") print("7.d(1) Time interval in days") jd = cal_to_jd(1991, 7, 11) jd = jd + 10000 yr, mo, day = jd_to_date(jd) @test yr == 2018 @test mo == 11 @test day == 26 dow = jd_to_day_of_week(jd) @test dow == 1 println(" passed") print("7.f Day of the year") N = cal_to_day_of_year(1978, 11, 14) @test N == 318 println(" passed") print("7.g Day of the year") N = cal_to_day_of_year(1988, 4, 22) @test N == 113 println(" passed") print("7(pg 66-1) Day of the year to calendar") mo, day = day_of_year_to_cal(1978, 318) @test mo == 11 @test day == 14 println(" passed") print("7(pg 66-2) Day of the year to calendar") mo, day = day_of_year_to_cal(1988, 113) @test mo == 4 @test day == 22 println(" passed") tbl = Array[ [1991, 3, 31], [1992, 4, 19], [1993, 4, 11], [1954, 4, 18], [2000, 4, 23], [1818, 3, 22] ] print("8(pg 68) Gregorian Easter (6 times)") for (yr, mo, day) in tbl # calculate xmo and xday given yr xmo, xday = easter(yr) map(print, [" ", yr, " ", mo, " ", day, " -> ", yr, " ", xmo, " ", xday]) println() @test xmo == mo @test xday == day end println(" passed") print("8(pg 69) Julian Easter (3 times)") for yr in [179, 711, 1243] mo, day = easter(yr, false) @test mo == 4 @test day == 12 end println(" passed") print("9.a Jewish Pesach") mo, day = pesach(1990) @test mo == 4 @test day == 10 println(" passed") print("9.b Julian date of Moslem year 1421 first day") yr, mo, day = moslem_to_christian(1421, 1, 1) @test yr == 2000 @test mo == 4 @test day == 6 println(" passed") print("9.c Moslem date for Aug 13 1991 gregorian") yr, mo, day = christian_to_moslem(1991, 8, 13) @test yr == 1412 @test mo == 2 @test day == 2 println(" passed") print("Julian day to date") (y, month, d, h, m, s) = jd_to_date(2436116.31, true) @test y == 1957 @test month == 10 @test d == 4 @test h == 19 @test m == 26 @test isapprox(s, 24, atol=0.1) println(" passed") # 2014 September 5 09:41:24 2456905.90375 Friday print("is September 5 DST?") @test is_dst(2456905.90375) == true println(" passed") print("number of Julian centuries since J2000.0") @test jd_to_jcent(2456905.90375) == 0.14677354551677085 println(" passed") print("Julian date to formatted string 1") @test lt_to_str(2456905.90375, "GMT", "second") == "Fri, 05 Sep 2014 09:41:24" println(" passed") print("Julian date to formatted string 2") @test lt_to_str(2456905.90375, "GMT", "day") == "Fri, 05 Sep 2014" println(" passed")
library(dplyr) library(tibble) library(tidyr) library(caret) library(gtools) library(FinCal) library(doParallel) #setwd("~/Documents/nstringjul18") load(file="allns_data.rdata") load("modelgbm.rdata") load("models.rdata") load("vardat.rdata") load(file="markerchoiceinfo.rdata") cl <- makePSOCKcluster(7) registerDoParallel(cl) md <- as.data.frame(subset(t(ctall.norm), sampleinfo$sex == "F" & sampleinfo$prep== "Luke"& sampleinfo$exp %in% c("Size-age", "cohorts", "OvY") & sampleinfo$codeset == "phaw_1" & sampleinfo$type %in% c("O", "Y", "M") )) md <- subset(md, rownames(md)%in% qualsum$sample[qualsum$good]) md <- md[, lmdf2$in61 ==T & lmdf2$pvalovy < 0.05] md <- md[, colnames(md) %in% c(minf$name[minf$in61==T], "predage")] md$sample <- rownames(md) md <- left_join(md, select(sampleinfo, sample, predage), by="sample") %>% filter(!(is.na(predage))) %>% column_to_rownames(var="sample") trainchoice <- sample(1:nrow(md))[1:floor(4*(nrow(md)/5))] trainchoice <- rownames(md) %in% rownames(currbest$trainingData) trdat <- md[trainchoice,] tedat <- md[-trainchoice,] gbmagemodelp5 <- train( predage~., tuneLength = 5, data = trdat, method = "gbm", tuneGrid=expand.grid(n.trees = (0:50)*200, interaction.depth = c(1,2,3,4,5,6,7,8,9,10), shrinkage = c(0.0001,.001, 0.01, 0.1, 0.2, 0.3) , n.minobsinnode = c(2,3,4,5,6,7,8,9,10)), trControl = trainControl(method = 'cv', number = 10, summaryFunction=defaultSummary, verboseIter = T) ) md <- as.data.frame(subset(t(ctall.norm), sampleinfo$sex == "F" & sampleinfo$prep== "Luke"& sampleinfo$exp %in% c("Size-age", "cohorts", "OvY") & sampleinfo$codeset == "phaw_1" & sampleinfo$type %in% c("O", "Y", "M") )) md <- subset(md, rownames(md)%in% qualsum$sample[qualsum$good]) md <- md[, lmdf2$in61 ==T & lmdf2$pvalovy < 0.04] md <- md[, colnames(md) %in% c(minf$name[minf$in61==T], "predage")] md$sample <- rownames(md) md <- left_join(md, select(sampleinfo, sample, predage), by="sample") %>% filter(!(is.na(predage))) %>% column_to_rownames(var="sample") trainchoice <- sample(1:nrow(md))[1:floor(4*(nrow(md)/5))] trainchoice <- rownames(md) %in% rownames(currbest$trainingData) trdat <- md[trainchoice,] tedat <- md[-trainchoice,] gbmagemodelp4 <- train( predage~., tuneLength = 5, data = trdat, method = "gbm", tuneGrid=expand.grid(n.trees = (0:50)*200, interaction.depth = c(1,2,3,4,5,6,7,8,9,10), shrinkage = c(0.0001,.001, 0.01, 0.1, 0.2, 0.3) , n.minobsinnode = c(2,3,4,5,6,7,8,9,10)), trControl = trainControl(method = 'cv', number = 10, summaryFunction=defaultSummary, verboseIter = T) ) md <- as.data.frame(subset(t(ctall.norm), sampleinfo$sex == "F" & sampleinfo$prep== "Luke"& sampleinfo$exp %in% c("Size-age", "cohorts", "OvY") & sampleinfo$codeset == "phaw_1" & sampleinfo$type %in% c("O", "Y", "M") )) md <- subset(md, rownames(md)%in% qualsum$sample[qualsum$good]) md <- md[, lmdf2$in61 ==T & lmdf2$pvalovy < 0.03] md <- md[, colnames(md) %in% c(minf$name[minf$in61==T], "predage")] md$sample <- rownames(md) md <- left_join(md, select(sampleinfo, sample, predage), by="sample") %>% filter(!(is.na(predage))) %>% column_to_rownames(var="sample") trainchoice <- sample(1:nrow(md))[1:floor(4*(nrow(md)/5))] trainchoice <- rownames(md) %in% rownames(currbest$trainingData) trdat <- md[trainchoice,] tedat <- md[-trainchoice,] gbmagemodelp3 <- train( predage~., tuneLength = 5, data = trdat, method = "gbm", tuneGrid=expand.grid(n.trees = (0:50)*200, interaction.depth = c(1,2,3,4,5,6,7,8,9,10), shrinkage = c(0.0001,.001, 0.01, 0.1, 0.2, 0.3) , n.minobsinnode = c(2,3,4,5,6,7,8,9,10)), trControl = trainControl(method = 'cv', number = 10, summaryFunction=defaultSummary, verboseIter = T) ) md <- as.data.frame(subset(t(ctall.norm), sampleinfo$sex == "F" & sampleinfo$prep== "Luke"& sampleinfo$exp %in% c("Size-age", "cohorts", "OvY") & sampleinfo$codeset == "phaw_1" & sampleinfo$type %in% c("O", "Y", "M") )) md <- subset(md, rownames(md)%in% qualsum$sample[qualsum$good]) md <- md[, lmdf2$in61 ==T & lmdf2$pvalovy < 0.02] md <- md[, colnames(md) %in% c(minf$name[minf$in61==T], "predage")] md$sample <- rownames(md) md <- left_join(md, select(sampleinfo, sample, predage), by="sample") %>% filter(!(is.na(predage))) %>% column_to_rownames(var="sample") trainchoice <- sample(1:nrow(md))[1:floor(4*(nrow(md)/5))] trainchoice <- rownames(md) %in% rownames(currbest$trainingData) trdat <- md[trainchoice,] tedat <- md[-trainchoice,] gbmagemodelp2 <- train( predage~., tuneLength = 5, data = trdat, method = "gbm", tuneGrid=expand.grid(n.trees = (0:50)*200, interaction.depth = c(1,2,3,4,5,6,7,8,9,10), shrinkage = c(0.0001,.001, 0.01, 0.1, 0.2, 0.3) , n.minobsinnode = c(2,3,4,5,6,7,8,9,10)), trControl = trainControl(method = 'cv', number = 10, summaryFunction=defaultSummary, verboseIter = T) ) md <- as.data.frame(subset(t(ctall.norm), sampleinfo$sex == "F" & sampleinfo$prep== "Luke"& sampleinfo$exp %in% c("Size-age", "cohorts", "OvY") & sampleinfo$codeset == "phaw_1" & sampleinfo$type %in% c("O", "Y", "M") )) md <- subset(md, rownames(md)%in% qualsum$sample[qualsum$good]) md <- md[, lmdf2$in61 ==T & lmdf2$pvalovy < 0.01] md <- md[, colnames(md) %in% c(minf$name[minf$in61==T], "predage")] md$sample <- rownames(md) md <- left_join(md, select(sampleinfo, sample, predage), by="sample") %>% filter(!(is.na(predage))) %>% column_to_rownames(var="sample") trainchoice <- sample(1:nrow(md))[1:floor(4*(nrow(md)/5))] trainchoice <- rownames(md) %in% rownames(currbest$trainingData) trdat <- md[trainchoice,] tedat <- md[-trainchoice,] gbmagemodelp1 <- train( predage~., tuneLength = 5, data = trdat, method = "gbm", tuneGrid=expand.grid(n.trees = (0:50)*200, interaction.depth = c(1,2,3,4,5,6,7,8,9,10), shrinkage = c(0.0001,.001, 0.01, 0.1, 0.2, 0.3) , n.minobsinnode = c(2,3,4,5,6,7,8,9,10)), trControl = trainControl(method = 'cv', number = 10, summaryFunction=defaultSummary, verboseIter = T) ) gbmagemodelp1b <- train( predage~., tuneLength = 5, data = trdat, method = "gbm", tuneGrid=expand.grid(n.trees = (0:50)*500, interaction.depth = c(1,2,3,4,5,6,7,8,9,10), shrinkage = c(0.0001,.001, 0.01, 0.1, 0.2, 0.3) , n.minobsinnode = c(2,3,4,5,6,7,8,9,10)), trControl = trainControl(method = 'cv', number = 10, summaryFunction=defaultSummary, verboseIter = T) ) gbmagemodelp1c <- train( predage~., tuneLength = 5, data = trdat, method = "gbm", tuneGrid=expand.grid(n.trees = (0:50)*500, interaction.depth = c(1,2,3,4,5,6,7,8,9,10), shrinkage = c(0.0001,.001, 0.01, 0.1, 0.2, 0.3) , n.minobsinnode = c(2,3,4,5,6,7,8,9,10)), trControl = trainControl(method = 'cv', number = 20, summaryFunction=defaultSummary, verboseIter = T) ) gbmagemodelp1d <- train( predage~., tuneLength = 5, data = trdat, method = "gbm", tuneGrid=expand.grid(n.trees = (0:50)*500, interaction.depth = c(1,2,3,4,5,6,7,8,9,10), shrinkage = c(0.0001,.001, 0.01, 0.1, 0.2, 0.3) , n.minobsinnode = c(2,3,4,5,6,7,8,9,10)), trControl = trainControl(method = 'cv', number = 40, summaryFunction=defaultSummary, verboseIter = T) ) stopCluster(cl) save(gbmagemodelp5, gbmagemodelp4, gbmagemodelp3, gbmagemodelp2, gbmagemodelp1, gbmagemodelp1b, gbmagemodelp1c, gbmagemodelp1d, file="gbmbig2.rdata")
This SAE Recommended Practice covers a high-quality corrosion-resisting steel wire, cold drawn, formed, and heat treated to produce uniform mechanical properties. It is magnetic in all conditions. It is intended for the manufacture of springs and wire forms that are to be heat treated after forming to enhance the spring properties. This document also covers processing requirements of the springs and forms fabricated from this wire. The Materials, Processes, and Parts Council (MPPC) promotes, directs, supervises and provides for the development of consensus SAE Technical reports. The council also conducts investigations for activities related to engineered materials, processes and parts used in the surface mobility industry. Participants in the SAE Materials, Processed and Parts Council include OEMs, suppliers, consulting firms, government and other interested parties. ASTMA313 This document is not part of the subscrption. ASTMA555 This document is not part of the subscrption. ASTMA555M This document is not part of the subscrption. If you do not have access to SAE MOBILUS via username/password or institutional access, you can still purchase the Ground Vehicle Standard, STAINLESS STEEL 17-7 PH SPRING WIRE AND SPRINGS.
(** * Linearize: Place all and only operations in let binders *) Require Import Crypto.Reflection.Syntax. Require Import Crypto.Reflection.Wf. Require Import Crypto.Reflection.Relations. Require Import Crypto.Reflection.LinearizeWf. Require Import Crypto.Reflection.InterpProofs. Require Import Crypto.Reflection.Linearize. Require Import Crypto.Util.Tactics Crypto.Util.Sigma Crypto.Util.Prod. Local Open Scope ctype_scope. Section language. Context (base_type_code : Type). Context (interp_base_type : base_type_code -> Type). Context (op : flat_type base_type_code -> flat_type base_type_code -> Type). Context (interp_op : forall src dst, op src dst -> interp_flat_type interp_base_type src -> interp_flat_type interp_base_type dst). Local Notation flat_type := (flat_type base_type_code). Local Notation type := (type base_type_code). Local Notation interp_type := (interp_type interp_base_type). Local Notation interp_flat_type := (interp_flat_type interp_base_type). Local Notation exprf := (@exprf base_type_code op). Local Notation expr := (@expr base_type_code op). Local Notation Expr := (@Expr base_type_code op). Local Notation wff := (@wff base_type_code op). Local Notation wf := (@wf base_type_code op). Local Hint Extern 1 => eapply interpf_SmartVarVarf. Local Ltac t_fin := repeat match goal with | _ => reflexivity | _ => progress unfold LetIn.Let_In | _ => progress simpl in * | _ => progress intros | _ => progress inversion_sigma | _ => progress inversion_prod | _ => solve [ intuition eauto ] | _ => apply (f_equal (interp_op _ _ _)) | _ => apply (f_equal2 (@pair _ _)) | _ => progress specialize_by assumption | _ => progress subst | [ H : context[List.In _ (_ ++ _)] |- _ ] => setoid_rewrite List.in_app_iff in H | [ H : or _ _ |- _ ] => destruct H | _ => progress break_match | _ => rewrite <- !surjective_pairing | [ H : ?x = _, H' : context[?x] |- _ ] => rewrite H in H' | [ H : _ |- _ ] => apply H | [ H : _ |- _ ] => rewrite H end. Lemma interpf_under_letsf {t tC} (ex : exprf t) (eC : _ -> exprf tC) : interpf interp_op (under_letsf ex eC) = let x := interpf interp_op ex in interpf interp_op (eC x). Proof. clear. induction ex; t_fin. Qed. Lemma interpf_linearizef {t} e : interpf interp_op (linearizef (t:=t) e) = interpf interp_op e. Proof. clear. induction e; repeat first [ progress rewrite ?interpf_under_letsf, ?interpf_SmartVarf | progress simpl | t_fin ]. Qed. Local Hint Resolve interpf_linearizef. Lemma interp_linearize {t} e : forall x, interp interp_op (linearize (t:=t) e) x = interp interp_op e x. Proof. induction e; simpl; eauto. Qed. Lemma InterpLinearize {t} (e : Expr t) : forall x, Interp interp_op (Linearize e) x = Interp interp_op e x. Proof. unfold Interp, Linearize. eapply interp_linearize. Qed. End language. Hint Rewrite @interpf_under_letsf : reflective_interp. Hint Rewrite @InterpLinearize @interp_linearize @interpf_linearizef using solve [ eassumption | eauto with wf ] : reflective_interp.
... signs that might indicate reasons to investigate for an annulment are : marriage that excluded at the time of the wedding the right to children , or to a permanent marriage , or to an exclusive commitment . In addition , there are youthful marriages ; marriages of very short duration ; marriages marked by serious emotional , physical , or substance abuse ; deviant sexual practices ; profound and consistent irresponsibility and lack of commitment ; conditional consent to a marriage ; fraud or deceit to elicit spousal consent ; serious mental illness ; or a previous bond of marriage . The determination of the ground should be made after extensive consultation with the parish priest or deacons , and based upon the proofs that are available .
Formal statement is: lemma contour_integral_circlepath: assumes "r > 0" shows "contour_integral (circlepath z r) (\<lambda>w. 1 / (w - z)) = 2 * complex_of_real pi * \<i>" Informal statement is: The contour integral of $1/(w - z)$ along the circle of radius $r$ centered at $z$ is $2\pi i$.
classdef MimEditBlue < MimGuiPlugin % MimEditBlue. Gui Plugin for setting paint colour % % You should not use this class within your own code. It is intended to % be used by the gui of the TD MIM Toolkit. % % MimEditBlue is a Gui Plugin for the MIM Toolkit. % % % Licence % ------- % Part of the TD MIM Toolkit. https://github.com/tomdoel % Author: Tom Doel, Copyright Tom Doel 2014. www.tomdoel.com % Distributed under the MIT licence. Please see website for details. % properties ButtonText = 'Blue' SelectedText = 'Blue' ToolTip = 'Edit with blue label' Category = 'Segmentation label' Visibility = 'Dataset' Mode = 'Edit' HidePluginInDisplay = false PTKVersion = '1' ButtonWidth = 5 ButtonHeight = 1 Icon = 'paint.png' IconColour = GemMarkerPoint.DefaultColours{1} Location = 31 end methods (Static) function RunGuiPlugin(gui_app) gui_app.ImagePanel.PaintBrushColour = 1; end function enabled = IsEnabled(gui_app) enabled = gui_app.IsDatasetLoaded && gui_app.ImagePanel.OverlayImage.ImageExists && ... isequal(gui_app.ImagePanel.SelectedControl, 'Paint'); end function is_selected = IsSelected(gui_app) is_selected = gui_app.ImagePanel.PaintBrushColour == 1; end end end
lemma measure_Union: "emeasure M A \<noteq> \<infinity> \<Longrightarrow> emeasure M B \<noteq> \<infinity> \<Longrightarrow> A \<in> sets M \<Longrightarrow> B \<in> sets M \<Longrightarrow> A \<inter> B = {} \<Longrightarrow> measure M (A \<union> B) = measure M A + measure M B"
module Numeral.Natural.Relation.DivisibilityWithRemainder where import Lvl open import Logic open import Logic.Propositional open import Numeral.Finite open import Numeral.Natural open import Numeral.Natural.Oper open import Type -- Divisibility with a remainder. -- `(y ∣ x)(r)` means that `y` is divisible by `x − r`. -- Note: `(0 ∣ᵣₑₘ _)(_)` is impossible to construct (0 is never a divisor by this definition). data _∣ᵣₑₘ_ : (y : ℕ) → ℕ → 𝕟(y) → Stmt{Lvl.𝟎} where DivRem𝟎 : ∀{y : ℕ} {r : 𝕟(y)} → (y ∣ᵣₑₘ 𝕟-to-ℕ(r))(r) DivRem𝐒 : ∀{y x : ℕ}{r : 𝕟(y)} → (y ∣ᵣₑₘ x)(r) → (y ∣ᵣₑₘ (x + y))(r) _∣₊_ : ℕ → ℕ → Stmt 𝟎 ∣₊ x = ⊥ 𝐒(y) ∣₊ x = (𝐒(y) ∣ᵣₑₘ x)(𝟎) -- The quotient extracted from the proof of divisibility. [∣ᵣₑₘ]-quotient : ∀{y x}{r} → (y ∣ᵣₑₘ x)(r) → ℕ [∣ᵣₑₘ]-quotient DivRem𝟎 = 𝟎 [∣ᵣₑₘ]-quotient (DivRem𝐒 p) = 𝐒([∣ᵣₑₘ]-quotient p) -- The remainder extracted from the proof of divisibility. [∣ᵣₑₘ]-remainder : ∀{y x}{r} → (y ∣ᵣₑₘ x)(r) → 𝕟(y) [∣ᵣₑₘ]-remainder{r = r} _ = r data _∣ᵣₑₘ₀_ : (y : ℕ) → ℕ → ℕ → Stmt{Lvl.𝟎} where base₀ : ∀{y} → (y ∣ᵣₑₘ₀ 𝟎)(𝟎) base₊ : ∀{y r} → (y ∣ᵣₑₘ₀ r)(r) → (𝐒(y) ∣ᵣₑₘ₀ 𝐒(r))(𝐒(r)) step : ∀{y x r} → (y ∣ᵣₑₘ₀ x)(r) → (y ∣ᵣₑₘ₀ (x + y))(r)
State Before: m✝ n✝ k✝ m n k i : ℕ H : m % n = k % n ⊢ (m + i) % n = (k + i) % n State After: no goals Tactic: rw [← mod_add_mod, ← mod_add_mod k, H]
lemma pred_sets_Ball[measurable_dest]: "\<forall>i\<in>I. A i \<in> sets (N i) \<Longrightarrow> i\<in>I \<Longrightarrow> f \<in> measurable M (N i) \<Longrightarrow> pred M (\<lambda>x. f x \<in> A i)"
function C = train_LDA(xTr, yTr, varargin) % TRAIN_LDA - linear discriminant analysis % %Synopsis: % C = train_LDA(XTR, YTR) % C = train_LDA(XTR, YTR, OPTS) % %Arguments: % XTR: DOUBLE [NxM] - Data matrix, with N feature dimensions, and M training points/examples. % YTR: INT [CxM] - Class membership labels of points in X_TR. C by M matrix of training % labels, with C representing the number of classes and M the number of training examples/points. % Y_TR(i,j)==1 if the point j belongs to class i. % OPT: PROPLIST - Structure or property/value list of optional % properties. Options are also passed to clsutil_shrinkage. % 'ExcludeInfs' - BOOL (default 0): If true, training data points with value 'inf' are excluded from XTR % 'Prior' - DOUBLE (default ones(nClasses, 1)/nClasses): Empirical class priors % 'StorePrior' - BOOL (default 0): If true, the prior will be stored with the classifier in C.prior % 'Scaling' - BOOL (default 0): scale projection vector such that the distance between % the projected means becomes 2. Scaling only implemented for 2 classes so far. Using Scaling=1 will disable the use of a prior. % 'StoreMeans' - BOOL (default 0): If true, the classwise means of the feature vectors % are stored in the classifier structure C. This can be used, e.g., for bbci_adaptation_pmean % 'UsePcov' - BOOL (default 0): If true, the pooled covariance matrix is used instead of the average classwise covariance matrix. % 'StoreCov', - BOOL (default 0): If true, the covariance matrix will be stored with the classifier in C.cov % 'StoreInvcov' - BOOL (default 0): If true, the inverse of the covariance matrix is stored in % the classifier structure C. This can be used, e.g., for bbci_adaptation_pcovmean % 'StoreExtinvcov' - BOOL (default 0): If true, the extended inverse of the covariance will be stored with the classifier in C.extinvcov % %Returns: % C: STRUCT - Trained classifier structure, with the hyperplane given by % fields C.w and C.b. C includes the fields: % 'w' : weight matrix % 'b' : FLOAT bias % 'prior' : (optional) classwise priors % 'means' : (optional) classwise means % 'cov' : (optional) covariance matrix % 'invcov' : (optional) inverse of the covariance matrix % 'extinvcov' : (optional) extended inverse of the covariance matrix % %Description: % TRAIN_RLDA trains a LDA classifier on data X with class % labels given in LABELS. % %Examples: % train_LDA(X, labels) % %See also: % APPLY_SEPARATINGHYPERPLANE opt = opt_proplistToStruct(varargin{:}); opt.Gamma = 0; C = train_RLDAshrink(xTr, yTr, opt);
State Before: R : Type u inst✝¹ : Semiring R S : Type v inst✝ : Semiring S f : R →+* S p : S[X] r : R hp : p ∈ lifts f ⊢ ↑C (↑f r) * p ∈ lifts f State After: R : Type u inst✝¹ : Semiring R S : Type v inst✝ : Semiring S f : R →+* S p : S[X] r : R hp : ∃ x, ↑(mapRingHom f) x = p ⊢ ∃ x, ↑(mapRingHom f) x = ↑C (↑f r) * p Tactic: simp only [lifts, RingHom.mem_rangeS] at hp⊢ State Before: R : Type u inst✝¹ : Semiring R S : Type v inst✝ : Semiring S f : R →+* S p : S[X] r : R hp : ∃ x, ↑(mapRingHom f) x = p ⊢ ∃ x, ↑(mapRingHom f) x = ↑C (↑f r) * p State After: case intro R : Type u inst✝¹ : Semiring R S : Type v inst✝ : Semiring S f : R →+* S r : R p₁ : R[X] ⊢ ∃ x, ↑(mapRingHom f) x = ↑C (↑f r) * ↑(mapRingHom f) p₁ Tactic: obtain ⟨p₁, rfl⟩ := hp State Before: case intro R : Type u inst✝¹ : Semiring R S : Type v inst✝ : Semiring S f : R →+* S r : R p₁ : R[X] ⊢ ∃ x, ↑(mapRingHom f) x = ↑C (↑f r) * ↑(mapRingHom f) p₁ State After: case intro R : Type u inst✝¹ : Semiring R S : Type v inst✝ : Semiring S f : R →+* S r : R p₁ : R[X] ⊢ ↑(mapRingHom f) (↑C r * p₁) = ↑C (↑f r) * ↑(mapRingHom f) p₁ Tactic: use C r * p₁ State Before: case intro R : Type u inst✝¹ : Semiring R S : Type v inst✝ : Semiring S f : R →+* S r : R p₁ : R[X] ⊢ ↑(mapRingHom f) (↑C r * p₁) = ↑C (↑f r) * ↑(mapRingHom f) p₁ State After: no goals Tactic: simp only [coe_mapRingHom, map_C, map_mul]
module _ where module M (X : Set) where postulate F : Set G : Set data ⊥ : Set where open M ⊥ hiding (F) easy : M.G ⊥ easy = {!!} -- G hard : M.F ⊥ hard = {!!} -- M.F ⊥ (and not .Issue1640._.F) data ⊤ : Set where tt : ⊤ module With where private F : ⊤ → Set F x with x F _ | tt = ⊥ T = F tricky : ∀ t → With.T t tricky t = {!!} -- .Issue1640.With.F t | t
\part{An Oral History of The New Tetris} \chapter{Background and The Genesis} \chapter{Early Competition} \chapter{Spreadsheet Stats} \section{Letter Grades} \chapter{Website Stats}
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.PrePort import Mathlib.Lean3Lib.init.default import Mathlib.data.list.basic import Mathlib.data.fin import Mathlib.PostPort universes u u_1 namespace Mathlib namespace list /- of_fn -/ theorem length_of_fn_aux {α : Type u} {n : ℕ} (f : fin n → α) (m : ℕ) (h : m ≤ n) (l : List α) : length (of_fn_aux f m h l) = length l + m := sorry @[simp] theorem length_of_fn {α : Type u} {n : ℕ} (f : fin n → α) : length (of_fn f) = n := Eq.trans (length_of_fn_aux f n of_fn._proof_1 []) (zero_add n) theorem nth_of_fn_aux {α : Type u} {n : ℕ} (f : fin n → α) (i : ℕ) (m : ℕ) (h : m ≤ n) (l : List α) : (∀ (i : ℕ), nth l i = of_fn_nth_val f (i + m)) → nth (of_fn_aux f m h l) i = of_fn_nth_val f i := sorry @[simp] theorem nth_of_fn {α : Type u} {n : ℕ} (f : fin n → α) (i : ℕ) : nth (of_fn f) i = of_fn_nth_val f i := sorry theorem nth_le_of_fn {α : Type u} {n : ℕ} (f : fin n → α) (i : fin n) : nth_le (of_fn f) (↑i) (Eq.symm (length_of_fn f) ▸ subtype.property i) = f i := sorry @[simp] theorem nth_le_of_fn' {α : Type u} {n : ℕ} (f : fin n → α) {i : ℕ} (h : i < length (of_fn f)) : nth_le (of_fn f) i h = f { val := i, property := length_of_fn f ▸ h } := nth_le_of_fn f { val := i, property := length_of_fn f ▸ h } @[simp] theorem map_of_fn {α : Type u} {β : Type u_1} {n : ℕ} (f : fin n → α) (g : α → β) : map g (of_fn f) = of_fn (g ∘ f) := sorry theorem array_eq_of_fn {α : Type u} {n : ℕ} (a : array n α) : array.to_list a = of_fn (array.read a) := sorry @[simp] theorem of_fn_zero {α : Type u} (f : fin 0 → α) : of_fn f = [] := rfl @[simp] theorem of_fn_succ {α : Type u} {n : ℕ} (f : fin (Nat.succ n) → α) : of_fn f = f 0 :: of_fn fun (i : fin n) => f (fin.succ i) := sorry theorem of_fn_nth_le {α : Type u} (l : List α) : (of_fn fun (i : fin (length l)) => nth_le l (↑i) (subtype.property i)) = l := sorry -- not registered as a simp lemma, as otherwise it fires before `forall_mem_of_fn_iff` which -- is much more useful theorem mem_of_fn {α : Type u} {n : ℕ} (f : fin n → α) (a : α) : a ∈ of_fn f ↔ a ∈ set.range f := sorry @[simp] theorem forall_mem_of_fn_iff {α : Type u} {n : ℕ} {f : fin n → α} {P : α → Prop} : (∀ (i : α), i ∈ of_fn f → P i) ↔ ∀ (j : fin n), P (f j) := sorry @[simp] theorem of_fn_const {α : Type u} (n : ℕ) (c : α) : (of_fn fun (i : fin n) => c) = repeat c n := sorry end Mathlib
# Decision Lens API # # No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # # OpenAPI spec version: 1.0 # # Generated by: https://github.com/swagger-api/swagger-codegen.git #' Classification Class #' #' @field phrase #' @field type #' @field targetType #' @field planFeature #' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export Classification <- R6::R6Class( 'Classification', public = list( `phrase` = NULL, `type` = NULL, `targetType` = NULL, `planFeature` = NULL, initialize = function(`phrase`, `type`, `targetType`, `planFeature`){ if (!missing(`phrase`)) { stopifnot(is.character(`phrase`), length(`phrase`) == 1) self$`phrase` <- `phrase` } if (!missing(`type`)) { stopifnot(is.character(`type`), length(`type`) == 1) self$`type` <- `type` } if (!missing(`targetType`)) { stopifnot(is.character(`targetType`), length(`targetType`) == 1) self$`targetType` <- `targetType` } if (!missing(`planFeature`)) { stopifnot(is.character(`planFeature`), length(`planFeature`) == 1) self$`planFeature` <- `planFeature` } }, toJSON = function() { ClassificationObject <- list() if (!is.null(self$`phrase`)) { ClassificationObject[['phrase']] <- self$`phrase` } if (!is.null(self$`type`)) { ClassificationObject[['type']] <- self$`type` } if (!is.null(self$`targetType`)) { ClassificationObject[['targetType']] <- self$`targetType` } if (!is.null(self$`planFeature`)) { ClassificationObject[['planFeature']] <- self$`planFeature` } ClassificationObject }, fromJSON = function(ClassificationJson) { ClassificationObject <- dlensFromJSON(ClassificationJson) if (!is.null(ClassificationObject$`phrase`)) { self$`phrase` <- ClassificationObject$`phrase` } if (!is.null(ClassificationObject$`type`)) { self$`type` <- ClassificationObject$`type` } if (!is.null(ClassificationObject$`targetType`)) { self$`targetType` <- ClassificationObject$`targetType` } if (!is.null(ClassificationObject$`planFeature`)) { self$`planFeature` <- ClassificationObject$`planFeature` } }, toJSONString = function() { sprintf( '{ "phrase": %s, "type": %s, "targetType": %s, "planFeature": %s }', self$`phrase`, self$`type`, self$`targetType`, self$`planFeature` ) }, fromJSONString = function(ClassificationJson) { ClassificationObject <- dlensFromJSON(ClassificationJson) self$`phrase` <- ClassificationObject$`phrase` self$`type` <- ClassificationObject$`type` self$`targetType` <- ClassificationObject$`targetType` self$`planFeature` <- ClassificationObject$`planFeature` } ) )
#include <commonTable.h> #include <boost/python.hpp> using namespace boost::python; void export_commonTable() { scope outer = class_<CommonTable, CommonTablePtr, boost::noncopyable> ("CommonTable", no_init) .def("insert", &CommonTable::insert) .def("size", &CommonTable::size) .def("secondaryIndex", &CommonTable::secondaryIndex) .def("aggregate", &CommonTable::aggregate, return_value_policy<reference_existing_object>()) ; class_<CommonTable::AggregateObj, CommonTable::Aggregate, boost::noncopyable> ("Aggregate", no_init) ; }
lemma generate_topology_Union: "(\<And>k. k \<in> I \<Longrightarrow> generate_topology S (K k)) \<Longrightarrow> generate_topology S (\<Union>k\<in>I. K k)"
namespace hidden -- Commutative Unitary Ring class myring (α : Type) extends has_add α, has_zero α, has_neg α, has_mul α, has_one α := (decidable_eq : ∀ a b : α, decidable (a = b)) (add_assoc (a b c : α) : a + b + c = a + (b + c)) (add_zero (a : α) : a + 0 = a) (add_neg (a : α) : a + -a = 0) (mul_assoc (a b c : α) : a * b * c = a * (b * c)) (mul_comm (a b : α) : a * b = b * a) (mul_one (a : α) : a * 1 = a) (mul_add (a b c : α) : a * (b + c) = a * b + a * c) namespace myring variables {α : Type} [myring α] (a b c : α) instance (a b : α) : decidable (a = b) := decidable_eq a b theorem one_mul : 1 * a = a := begin rw [mul_comm], from mul_one _, end theorem add_mul : (a + b) * c = a * c + b * c := by rw [mul_comm, mul_comm _ c, mul_comm _ c, mul_add] theorem add_cancel_right : a + c = b + c → a = b := begin assume h, rw [←add_zero a, ←add_zero b, ←add_neg c, ←add_assoc, ←add_assoc, h], end theorem add_cancel_right_iff: a + c = b + c ↔ a = b := begin split, { from add_cancel_right _ _ _, }, { assume hbc, rw hbc, }, end theorem zero_add : 0 + a = a := begin apply add_cancel_right _ _ (-a), rw [add_assoc, add_neg, add_zero], end theorem neg_zero : -(0 : α) = 0 := begin rw [←zero_add (-(0 : α)), add_neg], end private lemma important_first_lemma : a + b = 0 → b + a = 0 := begin assume h, apply add_cancel_right _ _ b, rw [add_assoc, h, zero_add, add_zero], end theorem neg_add : -a + a = 0 := begin apply important_first_lemma, rw add_neg, end theorem add_cancel_left : a + b = a + c → b = c := begin assume h, rw [←zero_add b, ←zero_add c, ←neg_add a, add_assoc, add_assoc, h], end theorem add_cancel_left_iff: a + b = a + c ↔ b = c := begin split, { from add_cancel_left _ _ _, }, { assume hbc, rw hbc, }, end theorem neg_neg : -(-a) = a := begin apply add_cancel_right _ _ (-a), rw [add_neg, neg_add], end theorem neg_unique : a + b = 0 ↔ a = -b := begin split, assume h, rw [←add_zero a, ←add_neg b, ←add_assoc], conv { to_rhs, rw ←zero_add (-b), }, congr, assumption, assume h, subst h, from neg_add b, end private theorem neg_distr_swap : -(a + b) = -b + -a := begin symmetry, rw [←neg_unique, add_assoc, ←add_assoc (-a), neg_add, zero_add, neg_add], end theorem mul_zero : a * 0 = 0 := begin apply add_cancel_left (a * 0), rw [←mul_add a, zero_add, add_zero], end theorem zero_mul : 0 * a = 0 := by rw [mul_comm, mul_zero] theorem neg_eq_mul_neg_one : -a = -1 * a := begin symmetry, conv { to_rhs, rw ←mul_one a, }, rw [←neg_unique, mul_comm, ←mul_add, neg_add, mul_zero], end theorem neg_mul : (-a) * b = -(a * b) := begin rw [←neg_unique, mul_comm (-a), mul_comm a, ←mul_add, neg_add, mul_zero], end theorem mul_neg : a * (-b) = -(a * b) := begin rw [mul_comm a (-b), mul_comm a b], apply neg_mul, end theorem neg_mul_neg : (-a) * (-b) = a * b := by rw [mul_neg, neg_mul, neg_neg] theorem neg_distr : -(a + b) = -a + -b := by rw [neg_eq_mul_neg_one a, neg_eq_mul_neg_one b, ←mul_add, ←neg_eq_mul_neg_one] -- "Negate Equality" theorem neg_eq : a = b ↔ -a = -b := begin split; assume h, congr, assumption, rw [←neg_neg a, ←neg_neg b, h], end theorem add_comm : a + b = b + a := by rw [neg_eq, neg_distr, neg_distr_swap] theorem add_cancel_left_to_zero : a + b = b → a = 0 := begin assume h, apply add_cancel_right _ _ b, rwa zero_add, end theorem add_cancel_left_to_zero_iff: a + b = b ↔ a = 0 := begin split, { from add_cancel_left_to_zero _ _, }, { assume ha0, rw ha0, rw zero_add, }, end theorem add_cancel_right_to_zero : a + b = a → b = 0 := λ h, add_cancel_left_to_zero b a (by rwa add_comm at h) theorem add_cancel_right_to_zero_iff: a + b = a ↔ b = 0 := begin split, { from add_cancel_right_to_zero _ _, }, { assume hb0, rw hb0, rw add_zero, }, end theorem add_left : a = b → c + a = c + b := begin assume h, congr, assumption, end theorem add_right : a = b → a + c = b + c := begin assume h, congr, assumption, end theorem one_eq_zero_impl_all_zero : (1 : α) = 0 → ∀ x : α, x = 0 := begin assume h10, intro x, rw [←one_mul x, h10, zero_mul], end def sub : α → α → α := λ a b, a + (-b) instance: has_sub α := ⟨sub⟩ theorem sub_def : a - b = a + -b := rfl theorem sub_self : a - a = 0 := begin change a + -a = 0, apply add_neg, end theorem sub_zero : a - 0 = a := by rw [sub_def, neg_zero, add_zero] theorem zero_sub : 0 - a = -a := by rw [sub_def, zero_add] theorem mul_sub : a * (b - c) = a * b - a * c := begin change a * (b + (-c)) = a * b + -(a * c), rw [mul_add, ←mul_neg], end theorem neg_sub : -(a - b) = b - a := by rw [sub_def, sub_def, neg_distr, neg_neg, add_comm] theorem sub_mul : (a - b) * c = a * c - b * c:= by rw [mul_comm, mul_sub, mul_comm a, mul_comm b] -- This is handy imo -- Imma have to firmly agree, bro theorem sub_to_zero_iff_eq : a - b = 0 ↔ a = b := begin split; assume h, { symmetry, rwa [neg_eq, ←neg_unique, add_comm], }, { change a + -b = 0, rwa [neg_unique, neg_neg], }, end instance add_is_assoc: is_associative α (+) := ⟨add_assoc⟩ instance add_is_comm: is_commutative α (+) := ⟨add_comm⟩ instance mul_is_assoc: is_associative α (*) := ⟨mul_assoc⟩ instance mul_is_comm: is_commutative α (*) := ⟨mul_comm⟩ end myring end hidden
\vssub \subsection{~Intra-spectral propagation} \label{sub:spec} \vssub \subsubsection{~General concepts} \vsssub The third step of the numerical fractional step algorithm considers refraction and residual (current-induced) wavenumber shifts. Irrespective of the spatial grid discretization and coordinate system, the equation to be solved in this step becomes %-----------------------------------% % Step : Intra-spectral propagation % %-----------------------------------% % eq:step_intra % eq:k_dot_g \begin{equation} \frac{\p N}{\p t} + \frac{\p}{\p k} \, \dot{k}_g N + \frac{\p}{\p \theta} \, \dot{\theta}_g N = 0 \: , \label{eq:step_intra} \end{equation} \begin{equation} \dot{k}_g = \frac{\p \sigma}{\p d} \frac{{\bf U} \cdot \nabla_x d}{c_g} - {\bf k} \cdot \frac{\p {\bf U}}{\p s} \: , \label{eq:k_dot_g} \end{equation} \noindent where $\dot{k}_g$ is the wavenumber velocity relative to the grid, and $\dot{\theta}_g$ is given by (\ref{eq:theta_g_dot}) and (\ref{eq:theta_dot}). This equation does not require boundary conditions in $\theta$-space, as the model by definition uses the full (closed) directional space. In $k$-space, however, boundary conditions are required. At low wavenumbers, it is assumed that no wave action exists outside the discrete domain. It is therefore assumed that no action enters the model at the discrete low-wavenumber boundary. At the high-wavenumber boundary, transport across the discrete boundary is calculated assuming a parametric spectral shape as given by Eq. (\ref{eq:tail_N_k}). The derivatives of the depth as needed in the evaluation of $\dot{\theta}$ are mostly determined using central differences. For points next to land, however, one-sided differences using sea points only are used. Propagation in $\theta$-space can cause practical problems in an explicit numerical scheme, as the refraction velocity can become extreme for long waves in extremely shallow water or due to strong current shears. Similarly, the propagation in $k$-space suffers from similar problems in very shallow water. To avoid the need of extremely small time steps due to refraction, the propagation velocities in $\theta$-space and $k$-space (\ref{eq:theta_dot}) are filtered, % eq:theta_filter \begin{equation} \dot{\theta} = X_{rd}(\lambda,\phi,k)\left( \dot{\theta_d} + \dot{\theta_c} + \dot{\theta_g} \right)\: , \label{eq:theta_filter} \end{equation} \noindent where the indices $d$, $c$ and $g$ refer to the depth, current and great-circle related fraction of the refraction velocity in (\ref{eq:theta_dot}). The filter factor $X_{rd}$ is calculated for every wavenumber and location separately, and is determined so that the \cfl\ number for propagation in $\theta$-space due to the {\em depth} refraction term cannot exceed a pre-set (user defined) value (default 0.7). This corresponds to a reduction of the bottom slope for some low frequency wave components. For mid-latitudes, the affected components are expected to carry little energy because they are in extremely shallow water. Long wave components carrying significant energy are usually traveling toward the coast, where their energy is dissipated anyway. This filtering is also important for short waves, and close to the pole. The effect of this filter can be tested by reducing the time steps for intraspectral refraction and by looking at the maximum CFL numbers in the output of the model. These are computed just before the filter is applied. % \vspace{\baselineskip} % \centerline{\ldots ADD DYNAMIC TIME INTEGRATION \ldots} The spectral space is always discretized with constants directional increments and a logarithmic frequency grid (\ref{eq:sigma_grid}) to accommodate computations of the nonlinear interaction $S_{nl}$. First, second and third orders schemes are available, and are presented in the following sections.
------------------------------------------------------------------------ -- A self-interpreter (without correctness proof) ------------------------------------------------------------------------ module Self-interpreter where open import Prelude hiding (const) -- To simplify the development, let's work with actual natural numbers -- as variables and constants (see -- Atom.one-can-restrict-attention-to-χ-ℕ-atoms). open import Atom open import Chi χ-ℕ-atoms open import Constants χ-ℕ-atoms open import Free-variables χ-ℕ-atoms open χ-atoms χ-ℕ-atoms open import Combinators -- Substitution. internal-subst : Exp internal-subst = lambda v-x (lambda v-new body) module Internal-subst where private rec-or-lambda : _ → _ rec-or-lambda = λ c → branch c (v-y ∷ v-e ∷ []) ( case (equal-ℕ (var v-x) (var v-y)) ( branch c-true [] (const c (var v-y ∷ var v-e ∷ [])) ∷ branch c-false [] ( const c (var v-y ∷ apply (var v-subst) (var v-e) ∷ [])) ∷ [])) branches = branch c-apply (v-e₁ ∷ v-e₂ ∷ []) ( const c-apply (apply (var v-subst) (var v-e₁) ∷ apply (var v-subst) (var v-e₂) ∷ [])) ∷ branch c-case (v-e ∷ v-bs ∷ []) ( const c-case ( apply (var v-subst) (var v-e) ∷ apply (var v-subst) (var v-bs) ∷ [])) ∷ rec-or-lambda c-rec ∷ rec-or-lambda c-lambda ∷ branch c-const (v-c ∷ v-es ∷ []) ( const c-const (var v-c ∷ apply (var v-subst) (var v-es) ∷ [])) ∷ branch c-var (v-y ∷ []) ( case (equal-ℕ (var v-x) (var v-y)) ( branch c-true [] (var v-new) ∷ branch c-false [] (const c-var (var v-y ∷ [])) ∷ [])) ∷ branch c-branch (v-c ∷ v-ys ∷ v-e ∷ []) ( const c-branch ( var v-c ∷ var v-ys ∷ case (member (var v-x) (var v-ys)) ( branch c-true [] (var v-e) ∷ branch c-false [] (apply (var v-subst) (var v-e)) ∷ []) ∷ [])) ∷ branch c-nil [] (const c-nil []) ∷ branch c-cons (v-e ∷ v-es ∷ []) ( const c-cons (apply (var v-subst) (var v-e) ∷ apply (var v-subst) (var v-es) ∷ [])) ∷ [] body = rec v-subst (lambda v-e (case (var v-e) branches)) -- Searches for a branch matching a given natural number. internal-lookup : Exp internal-lookup = lambda v-c (rec v-lookup (lambda v-bs (case (var v-bs) ( branch c-cons (v-b ∷ v-bs ∷ []) (case (var v-b) ( branch c-branch (v-c′ ∷ v-underscore ∷ v-underscore ∷ []) ( case (equal-ℕ (var v-c) (var v-c′)) ( branch c-false [] (apply (var v-lookup) (var v-bs)) ∷ branch c-true [] (var v-b) ∷ [])) ∷ [])) ∷ [])))) -- Tries to apply multiple substitutions. internal-substs : Exp internal-substs = rec v-substs (lambda v-xs (lambda v-es (lambda v-e′ ( case (var v-xs) ( branch c-nil [] (case (var v-es) ( branch c-nil [] (var v-e′) ∷ [])) ∷ branch c-cons (v-x ∷ v-xs ∷ []) (case (var v-es) ( branch c-cons (v-e ∷ v-es ∷ []) ( apply (apply (apply internal-subst (var v-x)) (var v-e)) (apply (apply (apply (var v-substs) (var v-xs)) (var v-es)) (var v-e′))) ∷ [])) ∷ []))))) -- A map function. The application of map to the function is done at -- the meta-level in order to simplify proofs. map : Exp → Exp map f = rec v-map (lambda v-xs (case (var v-xs) branches)) module Map where branches = branch c-nil [] (const c-nil []) ∷ branch c-cons (v-x ∷ v-xs ∷ []) ( const c-cons (apply f (var v-x) ∷ apply (var v-map) (var v-xs) ∷ [])) ∷ [] -- The self-interpreter. eval : Exp eval = rec v-eval (lambda v-p (case (var v-p) branches)) module Eval where apply-branch = branch c-lambda (v-x ∷ v-e ∷ []) ( apply (var v-eval) ( apply (apply (apply internal-subst (var v-x)) (apply (var v-eval) (var v-e₂))) (var v-e))) ∷ [] case-body₂ = case (apply (apply internal-lookup (var v-c)) (var v-bs)) ( branch c-branch (v-underscore ∷ v-xs ∷ v-e ∷ []) ( apply (var v-eval) ( apply (apply (apply internal-substs (var v-xs)) (var v-es)) (var v-e))) ∷ []) case-body₁ = case (apply (var v-eval) (var v-e)) ( branch c-const (v-c ∷ v-es ∷ []) case-body₂ ∷ []) branches = branch c-apply (v-e₁ ∷ v-e₂ ∷ []) ( case (apply (var v-eval) (var v-e₁)) apply-branch) ∷ branch c-case (v-e ∷ v-bs ∷ []) case-body₁ ∷ branch c-rec (v-x ∷ v-e ∷ []) ( apply (var v-eval) ( apply (apply (apply internal-subst (var v-x)) (const c-rec (var v-x ∷ var v-e ∷ []))) (var v-e))) ∷ branch c-lambda (v-x ∷ v-e ∷ []) ( const c-lambda (var v-x ∷ var v-e ∷ [])) ∷ branch c-const (v-c ∷ v-es ∷ []) ( const c-const (var v-c ∷ apply (map (var v-eval)) (var v-es) ∷ [])) ∷ [] eval-closed : Closed eval eval-closed = from-⊎ (closed? eval)
#define BOOST_TEST_MODULE ayla_serialization_tests #include <boost/test/unit_test.hpp> /** * This file needs to be compiled. Boost will generate the main function here. */
Everything between the double quotes in document.write() is printed onto the page. The above example starts a new paragraph and displays some centered text. All HTML is accepted inside document.write(). We now have two pieces of knowledge: how to get the current time in hours and how to print out onto the page. But how do you combine the two? By using something called if statements. It looks like fractured English, but there is a method to this madness. All if statements consist of the word if followed by a statement in parentheses and a block of code in braces. The parentheses contain the condition that is being checked. The braces contain the code that will run if the condition is met. Lets just take a deeper look into the code above. The first line says, if the value of the variable hour is greater than 4 and less than 18, then run the code in the braces. (Note: I’m sure you remember the < (less than) and > (greater than) symbols from math class, but what the heck is &&? Well the && means and. Now what happens if it is 7pm? Since we weren’t testing for this time, the else statement applies. With else, we’re saying “If the condition isn’t true, then do this instead“. If its 7pm, then its not between 4am and 6pm, so the script runs the code following the word else. Hope you have enjoyed this tutorial! Good luck!
From Coq Require Import ssreflect ssrfun ssrbool. Require Import Logic.Classical_Prop Coq.Logic.FunctionalExtensionality. From stdpp Require Import base decidable propset fin_maps fin_sets . From MatchingLogic Require Import Utils.extralibrary Utils.stdpp_ext Pattern Syntax Semantics DerivedOperators_Syntax DerivedOperators_Semantics PrePredicate monotonic Theories.Definedness_Syntax Theories.Definedness_Semantics Theories.Sorts_Syntax Theories.Sorts_Semantics . Import MatchingLogic.Logic.Notations. Import MatchingLogic.Semantics.Notations. Section with_syntax. Context {Σ : Signature} (* TODO: maybe remove and use the imported one from Sorts_Syntax? *) {ds : Definedness_Syntax.Syntax} {ss : Sorts_Syntax.Syntax} (HSortImptDef : imported_definedness = ds) (HDefNeqInh : Definedness_Syntax.inj definedness <> Sorts_Syntax.inj inhabitant) . Open Scope ml_scope. Definition is_core_symbol (s : symbols) : Prop := s = Definedness_Syntax.inj definedness \/ s = Sorts_Syntax.inj inhabitant. Instance is_core_symbol_dec (s : symbols) : Decision (is_core_symbol s). Proof. solve_decision. Defined. Definition is_not_core_symbol (s : symbols) : Prop := ~ is_core_symbol s. Instance is_not_core_symbol_dec (s : symbols) : Decision (is_not_core_symbol s). Proof. solve_decision. Defined. Inductive is_SPredicate : Pattern -> Prop := | spred_bott : is_SPredicate patt_bott | spred_def (ϕ : Pattern) : is_SData ϕ -> is_SPredicate (patt_defined ϕ) (* note that we have to add equality and subseteq manually, since they are usually defined using totality, and we do not have totality in the fragment! *) | spred_eq (ϕ₁ ϕ₂ : Pattern) : is_SData ϕ₁ -> is_SData ϕ₂ -> is_SPredicate (patt_equal ϕ₁ ϕ₂) | spred_subseteq (ϕ₁ ϕ₂ : Pattern) : is_SData ϕ₁ -> is_SData ϕ₂ -> is_SPredicate (patt_subseteq ϕ₁ ϕ₂) | spred_imp (ϕ₁ ϕ₂ : Pattern) : is_SPredicate ϕ₁ -> is_SPredicate ϕ₂ -> is_SPredicate (patt_imp ϕ₁ ϕ₂) | spred_ex (ϕ : Pattern) (s : symbols) : is_SPredicate ϕ -> is_not_core_symbol s -> is_SPredicate (patt_exists_of_sort (patt_sym s) ϕ) | spred_all (ϕ : Pattern) (s : symbols) : is_SPredicate ϕ -> is_not_core_symbol s -> is_SPredicate (patt_forall_of_sort (patt_sym s) ϕ) with is_SData : Pattern -> Prop := | sdata_bott : is_SData patt_bott | sdata_fevar (x : evar) : is_SData (patt_free_evar x) | sdata_fsvar (X : svar) : is_SData (patt_free_svar X) | sdata_bevar (dbi : db_index) : is_SData (patt_bound_evar dbi) | sdata_bsvar (dbi : db_index) : is_SData (patt_bound_svar dbi) | sdata_sym (s : symbols) : is_not_core_symbol s -> is_SData (patt_sym s) | sdata_inh (s : symbols) : is_not_core_symbol s -> is_SData (patt_inhabitant_set (patt_sym s)) | sdata_sneg (ϕ : Pattern) (s : symbols) : is_SData ϕ -> is_not_core_symbol s -> is_SData (patt_sorted_neg (patt_sym s) ϕ) | sdata_app (ϕ₁ ϕ₂ : Pattern) : is_SData ϕ₁ -> is_SData ϕ₂ -> is_SData (patt_app ϕ₁ ϕ₂) | sdata_or (ϕ₁ ϕ₂ : Pattern) : is_SData ϕ₁ -> is_SData ϕ₂ -> is_SData (patt_or ϕ₁ ϕ₂) | sdata_filter (ϕ ψ : Pattern) : is_SData ϕ -> is_SPredicate ψ -> is_SData (patt_and ϕ ψ) | sdata_ex (ϕ : Pattern) (s : symbols) : is_SData ϕ -> is_not_core_symbol s -> is_SData (patt_exists_of_sort (patt_sym s) ϕ) (* This is disabled, because if the sort is empty, then the forall evaluates to full set, and that does not get lifted to full set in the extended model. *) (* | sdata_all (ϕ : Pattern) (s : symbols) : is_SData ϕ -> is_not_core_symbol s -> is_SData (patt_forall_of_sort (patt_sym s) ϕ) *) | sdata_mu (ϕ : Pattern) : is_SData ϕ -> is_SData (patt_mu ϕ) . Lemma is_SData_bevar_subst ϕ₁ ϕ₂ dbi: is_SData ϕ₁ -> is_SData ϕ₂ -> is_SData (ϕ₁^[evar: dbi ↦ ϕ₂]) with is_SPredicate_bevar_subst ψ ϕ₂ dbi: is_SPredicate ψ -> is_SData ϕ₂ -> is_SPredicate (ψ^[evar: dbi ↦ ϕ₂]) . Proof. { intros H1 H2. induction H1; simpl; try constructor; auto. { case_match. { constructor. } { assumption. } { constructor. } } } { intros H1 H2. induction H1; try (solve [simpl; try constructor; auto]). } Qed. Lemma is_SData_evar_open x ϕ: is_SData ϕ -> is_SData (ϕ^{evar: 0 ↦ x}). Proof. intros H. unfold evar_open. apply is_SData_bevar_subst. { assumption. } constructor. Qed. Lemma is_SPredicate_evar_open x ϕ: is_SPredicate ϕ -> is_SPredicate (ϕ^{evar: 0 ↦ x}). Proof. intros H. unfold evar_open. apply is_SPredicate_bevar_subst. { assumption. } constructor. Qed. Lemma is_SData_bsvar_subst ϕ₁ ϕ₂ dbi: is_SData ϕ₁ -> is_SData ϕ₂ -> is_SData (ϕ₁^[svar: dbi ↦ ϕ₂]) with is_SPredicate_bsvar_subst ψ ϕ₂ dbi: is_SPredicate ψ -> is_SData ϕ₂ -> is_SPredicate (ψ^[svar: dbi ↦ ϕ₂]) . Proof. { intros H1 H2. induction H1; simpl; try constructor; auto. { case_match. { constructor. } { assumption. } { constructor. } } } { intros H1 H2. induction H1; try (solve [simpl; try constructor; auto]). } Qed. Lemma is_SData_svar_open x ϕ: is_SData ϕ -> is_SData (ϕ^{svar: 0 ↦ x}). Proof. intros H. unfold evar_open. apply is_SData_bsvar_subst. { assumption. } constructor. Qed. Lemma is_SPredicate_svar_open x ϕ: is_SPredicate ϕ -> is_SPredicate (ϕ^{svar: 0 ↦ x}). Proof. intros H. unfold evar_open. apply is_SPredicate_bsvar_subst. { assumption. } constructor. Qed. Lemma is_SPredicate_patt_not (ϕ : Pattern) : is_SPredicate ϕ -> is_SPredicate (patt_not ϕ). Proof. intros H. unfold patt_not. apply spred_imp. { assumption. } { apply spred_bott. } Qed. (* Lemma is_SPredicate_forall_of_sort (s : symbols) (ϕ : Pattern) : is_SPredicate (patt_forall_of_sort (patt_sym s) ϕ). Proof. unfold patt_forall_of_sort,patt_forall. apply is_SPredicate_patt_not. Qed. *) Section ext. Context (M : Model) (indec : forall (s : symbols), is_not_core_symbol s -> forall (m : Domain M) ρ, Decision (m ∈ Minterp_inhabitant (patt_sym s) ρ)) (R : Type) (fRM : R -> (Domain M) -> propset (Domain M + R)%type) (fMR : (Domain M) -> R -> propset (Domain M + R)%type) (fRR : R -> R -> propset (Domain M + R)%type) (finh : R -> propset (Domain M + R)%type) . Inductive Carrier := cdef | cinh | cel (el: (Domain M + R)%type). Instance Carrier_inhabited : Inhabited Carrier := populate cdef. Definition new_app_interp (x y : Carrier) : propset Carrier := match x with | cdef => ⊤ | cinh => match y with | cdef => ∅ | cinh => ∅ | cel el => match el with | inl m => cel <$> (@fmap propset _ _ _ inl (@app_ext _ M (sym_interp M (Sorts_Syntax.inj inhabitant)) {[m]})) | inr r => cel <$> finh r end end | cel elx => match y with | cdef => ∅ | cinh => ∅ | cel ely => match elx,ely with | (inl mx),(inl my) => cel <$> (@fmap propset _ _ _ inl (@app_interp _ M mx my)) | (inl mx),(inr ry) => cel <$> (fMR mx ry) | (inr rx),(inl my) => cel <$> (fRM rx my) | (inr rx),(inr ry) => cel <$> (fRR rx ry) end end end. Definition new_sym_interp (s : symbols) : propset Carrier := match (decide (s = Definedness_Syntax.inj definedness)) with | left _ => {[ cdef ]} | right _ => match (decide (s = Sorts_Syntax.inj inhabitant)) with | left _ => {[ cinh ]} | right _ => cel <$> (@fmap propset _ _ _ inl (@sym_interp _ M s)) end end. (* TODO: why was this poliorphic? *) Definition Mext : Model := {| Domain := Carrier ; Domain_inhabited := Carrier_inhabited ; app_interp := new_app_interp ; sym_interp := new_sym_interp ; |}. Lemma Mext_satisfies_definedness : Mext ⊨ᵀ Definedness_Syntax.theory. Proof. unfold theory. apply satisfies_theory_iff_satisfies_named_axioms. intros na. destruct na. apply single_element_definedness_impl_satisfies_definedness. exists cdef. simpl. split. { unfold new_sym_interp. case_match. { reflexivity. } contradiction n. reflexivity. } { auto. } Qed. Definition lift_value (x : Domain M) : (Domain Mext) := cel (inl x). Definition lift_set (xs : propset (Domain M)) : (propset (Domain Mext)) := cel <$> (@fmap propset _ _ _ inl xs). (* Valuations lifted from the original model to the extended model. *) Definition lift_val (ρ : @Valuation Σ M) : (@Valuation Σ Mext) := {| evar_valuation := λ (x : evar), lift_value (evar_valuation ρ x); svar_valuation := λ (X : svar), lift_set (svar_valuation ρ X) |}. Lemma lift_set_mono (xs ys : propset (Domain M)) : xs ⊆ ys <-> lift_set xs ⊆ lift_set ys. Proof. unfold lift_set,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. split. { intros H. clear -H. set_solver. } { intros H. rewrite elem_of_subseteq in H. rewrite elem_of_subseteq. intros x Hx. specialize (H (lift_value x)). unfold lift_value in H. do 2 rewrite elem_of_PropSet in H. feed specialize H. { exists (inl x). split;[reflexivity|]. rewrite elem_of_PropSet. exists x. split;[reflexivity|]. exact Hx. } destruct H as [a [Ha H] ]. inversion Ha. clear Ha. subst. rewrite elem_of_PropSet in H. destruct H as [a [Ha H] ]. inversion Ha. clear Ha. subst. exact H. } Qed. Lemma lift_set_injective (xs ys : propset (Domain M)) : xs = ys <-> lift_set xs = lift_set ys. Proof. split;[congruence|]. intros H. unfold lift_set,fmap in H. with_strategy transparent [propset_fmap] unfold propset_fmap in H. unfold_leibniz. rewrite set_equiv_subseteq in H. do 2 rewrite elem_of_subseteq in H. destruct H as [H1 H2]. rewrite set_equiv_subseteq. do 2 rewrite elem_of_subseteq. split; intros x Hx. { specialize (H1 (lift_value x)). do 2 rewrite elem_of_PropSet in H1. feed specialize H1. { unfold lift_value. exists (inl x). split;[reflexivity|]. rewrite elem_of_PropSet. exists x. split;[reflexivity|]. apply Hx. } destruct H1 as [a [Ha H1] ]. unfold lift_value in Ha. inversion Ha. clear Ha. subst. rewrite elem_of_PropSet in H1. destruct H1 as [a [Ha H1] ]. inversion Ha. clear Ha. subst. exact H1. } { specialize (H2 (lift_value x)). do 2 rewrite elem_of_PropSet in H2. feed specialize H2. { unfold lift_value. exists (inl x). split;[reflexivity|]. rewrite elem_of_PropSet. exists x. split;[reflexivity|]. apply Hx. } destruct H2 as [a [Ha H2] ]. unfold lift_value in Ha. inversion Ha. clear Ha. subst. rewrite elem_of_PropSet in H2. destruct H2 as [a [Ha H2] ]. inversion Ha. clear Ha. subst. exact H2. } Qed. Lemma Mext_indec : forall (s : symbols), is_not_core_symbol s -> forall (m : Domain Mext) ρ, Decision (m ∈ @Minterp_inhabitant Σ _ Mext (patt_sym s) (lift_val ρ)). Proof. intros. unfold Minterp_inhabitant. rewrite eval_app_simpl. unfold app_ext,lift_val. simpl. destruct m. { right. intros HContra. rewrite elem_of_PropSet in HContra. destruct HContra as [le [re [HContra1 [HContra2 HContra3] ] ] ]. rewrite eval_sym_simpl in HContra1. rewrite eval_sym_simpl in HContra2. simpl in HContra1. simpl in HContra2. unfold new_sym_interp in HContra1, HContra2. unfold new_app_interp in HContra3. repeat case_match; subst; auto; try set_solver. } { right. intros HContra. rewrite elem_of_PropSet in HContra. destruct HContra as [le [re [HContra1 [HContra2 HContra3] ] ] ]. rewrite eval_sym_simpl in HContra1. rewrite eval_sym_simpl in HContra2. simpl in HContra1. simpl in HContra2. unfold new_sym_interp in HContra1, HContra2. unfold new_app_interp in HContra3. repeat case_match; subst; auto; try set_solver. } destruct el. 2: { right. intros HContra. rewrite elem_of_PropSet in HContra. destruct HContra as [le [re [HContra1 [HContra2 HContra3] ] ] ]. rewrite eval_sym_simpl in HContra1. rewrite eval_sym_simpl in HContra2. simpl in HContra1. simpl in HContra2. unfold new_sym_interp in HContra1, HContra2. unfold new_app_interp in HContra3. repeat case_match; subst; auto; try set_solver. } destruct (indec _ H d ρ) as [Hin|Hnotin]. { left. unfold Minterp_inhabitant in Hin. rewrite eval_app_simpl in Hin. do 2 rewrite eval_sym_simpl in Hin. unfold app_ext in Hin. rewrite elem_of_PropSet in Hin. destruct Hin as [le [re [Hinle [Hinre Hin] ] ] ]. rewrite elem_of_PropSet. do 2 rewrite eval_sym_simpl. simpl. unfold new_sym_interp. repeat case_match; subst; auto; try contradiction; try congruence; unfold lift_value. { exfalso. apply H. unfold is_core_symbol. left. reflexivity. } { exfalso. apply H. unfold is_core_symbol. right. reflexivity. } exists cinh, (lift_value re). split;[set_solver|]. unfold lift_value,new_app_interp. split;[set_solver|]. unfold app_ext. clear -Hinle Hinre Hin. set_solver. } { right. unfold Minterp_inhabitant in Hnotin. rewrite eval_app_simpl in Hnotin. do 2 rewrite eval_sym_simpl in Hnotin. unfold app_ext in Hnotin. rewrite elem_of_PropSet in Hnotin. rewrite elem_of_PropSet. intro HContra. apply Hnotin. do 2 rewrite eval_sym_simpl in HContra. simpl in HContra. unfold new_sym_interp in HContra. destruct HContra as [le [re [Hinle [Hinre Hin] ] ] ]. repeat case_match; subst; auto; try contradiction; try congruence; unfold lift_value. { exfalso. apply H. unfold is_core_symbol. left. reflexivity. } { exfalso. apply H. unfold is_core_symbol. right. reflexivity. } unfold new_app_interp in Hin. rewrite elem_of_PropSet in Hinre. repeat case_match; subst; auto; try contradiction; try congruence. { unfold app_ext in Hin. rewrite elem_of_PropSet in Hin. destruct Hin as [a [Hin1 Hin2] ]. inversion Hin1. subst. clear Hin1. rewrite elem_of_PropSet in Hin2. destruct Hin2 as [a [Hin2 Hin3] ]. inversion Hin2. subst. clear Hin2. rewrite elem_of_PropSet in Hin3. destruct Hin3 as [le [lre [Hle [Hre HAlmost] ] ] ]. rewrite elem_of_PropSet in Hre. inversion Hre. clear Hre. subst. destruct Hinre as [a' [Ha' Ha''] ]. rewrite elem_of_PropSet in Ha''. destruct_and_ex!. subst. exists le, x. split;[assumption|]. split;[assumption|]. inversion Ha'. subst. assumption. } { rewrite elem_of_PropSet in Hin. destruct Hinre as [a1 [Ja1 Ga1] ]. destruct Hin as [a2 [Ja2 Ga2] ]. inversion Ja1; clear Ja1; subst. inversion Ja2; clear Ja2; subst. rewrite elem_of_PropSet in Ga1. destruct Ga1 as [a3 [Ja3 Ga3] ]. inversion Ja3. } } Qed. Section semantic_preservation. Context (M_def : M ⊨ᵀ Definedness_Syntax.theory) . Lemma SPred_is_pre_predicate (ψ : Pattern) : is_SPredicate ψ -> M_pre_predicate M ψ. Proof. intros HSPred. induction HSPred. { apply (@M_pre_pre_predicate_impl_M_pre_predicate _ 0). apply M_pre_pre_predicate_bott. } { apply (@M_pre_pre_predicate_impl_M_pre_predicate _ 0). apply T_pre_predicate_defined. exact M_def. } { apply (@M_pre_pre_predicate_impl_M_pre_predicate _ 0). apply T_pre_predicate_equal. exact M_def. } { apply (@M_pre_pre_predicate_impl_M_pre_predicate _ 0). apply T_pre_predicate_subseteq. exact M_def. } { apply M_pre_predicate_imp; assumption. } { unfold patt_exists_of_sort. apply M_pre_predicate_exists. apply M_pre_predicate_and. 2: { exact IHHSPred. } unfold patt_in. apply T_pre_predicate_defined. rewrite HSortImptDef. exact M_def. } { unfold patt_forall_of_sort. apply M_pre_predicate_forall. apply M_pre_predicate_imp. 2: { exact IHHSPred. } unfold patt_in. apply T_pre_predicate_defined. rewrite HSortImptDef. exact M_def. } Qed. Lemma SPred_is_predicate (ψ : Pattern) : well_formed_closed_ex_aux ψ 0 -> is_SPredicate ψ -> M_predicate M ψ. Proof. intros Hwfc Hspred. apply SPred_is_pre_predicate in Hspred. unfold M_pre_predicate in Hspred. specialize (Hspred 0). eapply closed_M_pre_pre_predicate_is_M_predicate. 2: { apply Hspred. } apply Hwfc. Qed. Lemma semantics_preservation_sym (s : symbols) (ρ : @Valuation _ M) ρ0 : is_not_core_symbol s -> @eval Σ Mext ρ0 (patt_sym s) = lift_set (@eval Σ M ρ (patt_sym s)). Proof. intros H. do 2 rewrite eval_sym_simpl. clear -H. unfold_leibniz. unfold is_not_core_symbol,is_core_symbol in H. unfold sym_interp at 1. simpl. unfold new_sym_interp. repeat case_match; subst. { exfalso. tauto. } { exfalso. tauto. } unfold lift_set,fmap. reflexivity. Qed. Lemma semantics_preservation_inhabitant_set (s : symbols) (ρ : @Valuation _ M) ρ0 : is_not_core_symbol s -> @eval Σ Mext ρ0 (patt_inhabitant_set (patt_sym s)) = lift_set (@eval Σ M ρ (patt_inhabitant_set (patt_sym s))). Proof. intros H. rename H into Hnc. (* For some reason, the tactic [unfold_leibniz] performed later in the proof script does nothing. *) unfold_leibniz. unfold patt_inhabitant_set. do 2 rewrite eval_app_simpl. rewrite (semantics_preservation_sym _ ρ);[assumption|]. remember (eval ρ (patt_sym s)) as ps. unfold Sorts_Syntax.sym. do 2 rewrite eval_sym_simpl. unfold sym_interp at 1. simpl. unfold new_sym_interp. rewrite decide_eq_same. destruct (decide (inj inhabitant = Definedness_Syntax.inj definedness)) as [Heq|Hneq] eqn:Hnid. { clear -HDefNeqInh Heq. congruence. } { clear Hneq Hnid. unfold app_ext at 1. unfold app_interp at 1. simpl. unfold new_app_interp. set_unfold. intros x. split. { intros [x0 [x1 H] ]. destruct_and!. subst. repeat case_match. { exfalso. clear -H2. set_solver. } { exfalso. clear -H2. set_solver. } { subst. set_solver. } { subst. set_solver. } } { intros [y H]. destruct_and!. subst. destruct H1 as [y0 H]. destruct_and!. subst. destruct H1 as [x [x0 H] ]. clear Heqps. destruct_and!. exists cinh. eexists (cel (inl x0)). split. { reflexivity. } split. { exists (inl x0). split. reflexivity. exists x0. split. reflexivity. assumption. } { unfold fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. set_solver. } } } Qed. Lemma update_evar_val_lift_val_comm (ρ : @Valuation _ M) (x : evar) (d : Domain M) : (@update_evar_val Σ Mext x (cel (inl d)) (lift_val ρ)) = lift_val (@update_evar_val Σ M x d ρ). Proof. destruct ρ as [ρₑ ρₛ]. unfold update_evar_val. simpl. unfold lift_val. simpl. f_equal. apply functional_extensionality. intros x'. case_match; reflexivity. Qed. Lemma update_svar_val_lift_set_comm (ρ : @Valuation _ M) (X : svar) (D : propset (Domain M)) : (@update_svar_val Σ Mext X (lift_set D) (lift_val ρ)) = lift_val (@update_svar_val Σ M X D ρ). Proof. destruct ρ as [ρₑ ρₛ]. unfold update_svar_val. simpl. unfold lift_val. simpl. f_equal. apply functional_extensionality. intros X'. case_match; reflexivity. Qed. Lemma lift_set_fa_union (C : Type) (f : C -> propset (Domain M)) : lift_set (stdpp_ext.propset_fa_union f) = stdpp_ext.propset_fa_union (λ k, lift_set (f k)). Proof. unfold stdpp_ext.propset_fa_union, lift_set. unfold lift_set,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. clear. unfold_leibniz. set_solver. Qed. Lemma lift_set_fa_intersection (C : Type) {_ : Inhabited C} (f : C -> propset (Domain M)) : lift_set (stdpp_ext.propset_fa_intersection f) = stdpp_ext.propset_fa_intersection (λ k, lift_set (f k)). Proof. unfold stdpp_ext.propset_fa_intersection, lift_set. unfold lift_set,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. unfold_leibniz. set_unfold. intros x. split; intros H. { destruct_and_ex!. subst. intros. exists (inl x1). split;[reflexivity|]. exists x1. split;[reflexivity|]. apply H2. } { pose proof (Htmp := H (@stdpp.base.inhabitant C X)). destruct_and_ex!. subst. exists (inl x1). split;[reflexivity|]. exists x1. split;[reflexivity|]. intros x. pose proof (Htmp2 := H x). destruct_and_ex!. subst. inversion H0. subst. assumption. } Qed. Lemma semantics_preservation (sz : nat) : ( forall (ϕ : Pattern) (ρ : @Valuation _ M), size' ϕ < sz -> is_SData ϕ -> well_formed ϕ -> @eval Σ Mext (lift_val ρ) ϕ = lift_set (@eval Σ M ρ ϕ) ) /\ ( forall (ψ : Pattern) (ρ : @Valuation _ M), size' ψ < sz -> is_SPredicate ψ -> well_formed ψ -> (@eval Σ Mext (lift_val ρ) ψ = ∅ <-> @eval Σ M ρ ψ = ∅) /\ (@eval Σ Mext (lift_val ρ) ψ = ⊤ <-> @eval Σ M ρ ψ = ⊤) ). Proof. induction sz. { split. { intros ϕ Hsz. destruct ϕ; simpl in Hsz; lia. } { intros ψ Hsz. destruct ψ; simpl in Hsz; lia. } } { destruct IHsz as [IHszdata IHszpred]. split. { (* preservation of data patterns *) intros ϕ ρ Hszϕ HSData Hwf. destruct HSData; simpl in Hszϕ. { (* patt_bott *) do 2 rewrite eval_bott_simpl. unfold lift_set. unfold fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. clear. unfold_leibniz. set_solver. } { (* free_evar x*) do 2 rewrite eval_free_evar_simpl. unfold lift_set,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. clear. unfold_leibniz. set_solver. } { (* free_svar X *) do 2 rewrite eval_free_svar_simpl. unfold lift_set,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. clear. unfold_leibniz. set_solver. } { (* bound_evar X *) do 2 rewrite eval_bound_evar_simpl. unfold lift_set,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. clear. unfold_leibniz. set_solver. } { (* bound_svar X *) do 2 rewrite eval_bound_svar_simpl. unfold lift_set,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. clear. unfold_leibniz. set_solver. } { (* sym s *) apply semantics_preservation_sym. { assumption. } } { (* patt_inhabitant_set (patt_sym s) *) apply semantics_preservation_inhabitant_set. { assumption. } } { (* patt_sorted_neg (patt_sym s) ϕ *) unfold patt_sorted_neg. do 2 rewrite eval_and_simpl. rewrite (semantics_preservation_inhabitant_set _ ρ);[assumption|]. do 2 rewrite eval_not_simpl. rewrite IHszdata. { lia. } { exact HSData. } { wf_auto2. } remember (eval ρ (patt_inhabitant_set (patt_sym s))) as Xinh. remember (eval ρ ϕ) as Xϕ. clear HeqXinh HeqXϕ IHszpred IHszdata. unfold_leibniz. set_solver. } { (* patt_app ϕ₁ ϕ₂ *) do 2 rewrite eval_app_simpl. rewrite IHszdata. { lia. } { exact HSData1. } { wf_auto2. } rewrite IHszdata. { lia. } { exact HSData2. } { wf_auto2. } unfold app_ext. clear. unfold_leibniz. unfold lift_set,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. unfold Mext. simpl. unfold new_app_interp. set_unfold. intros x. split. { intros [x0 [x1 H] ]. destruct_and!. destruct H0 as [xH0 H0]. destruct H as [xH H]. destruct_and!. subst. destruct H4 as [xH4 H4]. destruct H3 as [xH3 H3]. destruct_and!. subst. destruct x. { exfalso. unfold fmap in H2. with_strategy transparent [propset_fmap] unfold propset_fmap in H2. clear -H2. set_solver. } { exfalso. unfold fmap in H2. with_strategy transparent [propset_fmap] unfold propset_fmap in H2. clear -H2. set_solver. } { inversion H2. clear H2. destruct_and!. subst. inversion H2. clear H2. destruct_and!. subst. inversion H1. clear H1. subst. exists (inl x0). split;[reflexivity|]. exists x0. split;[reflexivity|]. exists xH4,xH3. repeat split; assumption. } } { intros H. destruct_and_ex!. subst. exists (cel (inl x2)). exists (cel (inl x3)). split. { exists (inl x2). split;[reflexivity|]. exists x2. split;[reflexivity|]. assumption. } split. { exists (inl x3). split;[reflexivity|]. exists x3. split;[reflexivity|]. assumption. } { unfold fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. set_solver. } } } { (* patt_or ϕ₁ ϕ₂ *) do 2 rewrite eval_or_simpl. rewrite IHszdata. { lia. } { exact HSData1. } { wf_auto2. } rewrite IHszdata. { lia. } { exact HSData2. } { wf_auto2. } clear. unfold_leibniz. unfold lift_set,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. set_solver. } { (* patt_and ϕ ψ *) do 2 rewrite eval_and_simpl. rename H into Hspred. destruct (classic (eval ρ ψ = ∅)). { rewrite IHszdata. { lia. } { exact HSData. } { wf_auto2. } clear HSData IHszdata. unfold_leibniz. specialize (IHszpred ψ ρ ltac:(lia) ltac:(assumption) ltac:(wf_auto2)). destruct IHszpred as [Hsp1 Hsp2]. clear Hsp2. destruct Hsp1 as [Hsp11 Hsp12]. specialize (Hsp12 H). clear Hsp11. unfold lift_set,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. set_solver. } { apply predicate_not_empty_iff_full in H. 2: { apply SPred_is_predicate. 2: { assumption. } { clear -Hwf. unfold patt_and,patt_or,patt_not in Hwf. apply well_formed_imp_proj1 in Hwf. apply well_formed_imp_proj2 in Hwf. apply well_formed_imp_proj1 in Hwf. wf_auto2. } } specialize (IHszpred ψ ρ ltac:(lia) ltac:(assumption) ltac:(wf_auto2)). specialize (IHszdata ϕ ρ ltac:(lia) HSData ltac:(wf_auto2)). destruct IHszpred as [Hsp1 Hsp2]. clear Hsp1. destruct Hsp2 as [Hsp21 Hsp22]. clear Hsp21. specialize (Hsp22 H). rewrite IHszdata. rewrite H. rewrite Hsp22. unfold lift_set,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. clear. set_unfold. split; intros H. { destruct_and_ex!. subst. exists (inl x1). split. { reflexivity. } exists x1. split;[reflexivity|]. split; done. } { destruct_and_ex!. subst. split;[|exact I]. exists (inl x1). split;[reflexivity|]. exists x1. split; done. } } } { (* patt_exists_of_sort (patt_sym s) ϕ *) unshelve(erewrite eval_exists_of_sort). 3: { rewrite HSortImptDef. apply Mext_satisfies_definedness. } { intros. apply Mext_indec. assumption. } unshelve(erewrite eval_exists_of_sort). 3: { rewrite HSortImptDef. assumption. } { intros. apply indec. assumption. } rewrite lift_set_fa_union. unfold_leibniz. unfold stdpp_ext.propset_fa_union. apply set_subseteq_antisymm. { apply elem_of_subseteq. intros x Hx. rewrite elem_of_PropSet. rewrite elem_of_PropSet in Hx. destruct Hx as [c Hc]. destruct (Mext_indec _ H c ρ) as [Hin|Hnotin]. { unfold Minterp_inhabitant in Hin. (* [c] comes from [Domain M] *) destruct c. { exfalso. rewrite eval_app_simpl in Hin. do 2 rewrite eval_sym_simpl in Hin. unfold app_ext in Hin. simpl in Hin. unfold new_sym_interp,new_app_interp in Hin. rewrite elem_of_PropSet in Hin. destruct_and_ex!. repeat case_match; subst; auto; try congruence. { clear -H3. unfold fmap in H3. with_strategy transparent [propset_fmap] unfold propset_fmap in H3. set_solver. } { clear -H3. unfold fmap in H3. with_strategy transparent [propset_fmap] unfold propset_fmap in H3. set_solver. } } { exfalso. rewrite eval_app_simpl in Hin. do 2 rewrite eval_sym_simpl in Hin. unfold app_ext in Hin. simpl in Hin. unfold new_sym_interp,new_app_interp in Hin. rewrite elem_of_PropSet in Hin. destruct_and_ex!. repeat case_match; subst; auto; try congruence. { clear -H3. unfold fmap in H3. with_strategy transparent [propset_fmap] unfold propset_fmap in H3. set_solver. } { clear -H3. unfold fmap in H3. with_strategy transparent [propset_fmap] unfold propset_fmap in H3. set_solver. } } destruct el. 2: { exfalso. rewrite eval_app_simpl in Hin. do 2 rewrite eval_sym_simpl in Hin. unfold app_ext in Hin. simpl in Hin. unfold new_sym_interp,new_app_interp in Hin. rewrite elem_of_PropSet in Hin. destruct_and_ex!. repeat case_match; subst; auto; try congruence. { clear -H3. unfold fmap in H3. with_strategy transparent [propset_fmap] unfold propset_fmap in H3. set_solver. } { clear -H2. unfold fmap in H2. with_strategy transparent [propset_fmap] unfold propset_fmap in H2. set_solver. } } rewrite update_evar_val_lift_val_comm in Hc. rewrite IHszdata in Hc. 3: { wf_auto2. } 2: { apply is_SData_evar_open. assumption. } 1: { rewrite evar_open_size'. lia. } (* [x] comes from [Domain M] *) unfold lift_set,fmap in Hc. with_strategy transparent [propset_fmap] unfold propset_fmap in Hc. destruct x. { exfalso. clear -Hc. set_solver. } { exfalso. clear -Hc. set_solver. } destruct el. 2: { exfalso. clear -Hc. set_solver. } rewrite IHszdata in Hin. 3: { wf_auto2. } 2: { constructor. assumption. } 1: { simpl. lia. } exists d. destruct (indec _ H d ρ) as [Hin'|Hnotin']. 2: { exfalso. unfold Minterp_inhabitant in Hnotin'. unfold lift_set,fmap in Hin. with_strategy transparent [propset_fmap] unfold propset_fmap in Hin. clear -Hin Hnotin'. set_solver. } apply Hc. } { exfalso. clear -Hc. set_solver. } } { rewrite elem_of_subseteq. intros x Hx. rewrite elem_of_PropSet in Hx. destruct Hx as [c Hc]. unfold lift_set,fmap in Hc. with_strategy transparent [propset_fmap] unfold propset_fmap in Hc. destruct x. { exfalso. clear -Hc. set_solver. } { exfalso. clear -Hc. set_solver. } destruct el. 2: { exfalso. clear -Hc. set_solver. } rewrite elem_of_PropSet in Hc. destruct Hc as [a [Ha Ha'] ]. destruct a. 2: { inversion Ha. } inversion Ha. clear Ha. subst. rewrite elem_of_PropSet in Ha'. destruct Ha' as [a [Ha Ha'] ]. inversion Ha. clear Ha. subst. rewrite elem_of_PropSet. destruct (indec _ H c ρ). 2: { exfalso. clear -Ha'. set_solver. } exists (lift_value c). rewrite update_evar_val_lift_val_comm. destruct (Mext_indec _ H (lift_value c) ρ) as [Hin | Hnotin]. { rewrite IHszdata. 3: { wf_auto2. } 2: { apply is_SData_evar_open. assumption. } 1: { rewrite evar_open_size'. lia. } unfold lift_set,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. rewrite elem_of_PropSet. exists (inl a). split;[reflexivity|]. rewrite elem_of_PropSet. exists a. split;[reflexivity|]. apply Ha'. } { exfalso. rename e into Hin. unfold Minterp_inhabitant in Hin, Hnotin. rewrite IHszdata in Hnotin. 3: { wf_auto2. } 2: { constructor. assumption. } 1: { simpl. lia. } clear -Hin Hnotin. unfold lift_value,lift_set,fmap in Hnotin. with_strategy transparent [propset_fmap] unfold propset_fmap in Hnotin. set_solver. } } } { (* patt_mu (patt_sym s) ϕ *) do 2 rewrite eval_mu_simpl. cbn zeta. match goal with | [ |- (Lattice.LeastFixpointOf ?fF = lift_set (Lattice.LeastFixpointOf ?fG))] => remember fF as F; remember fG as G end. symmetry. assert (HmonoF: @Lattice.MonotonicFunction (propset Carrier) (Lattice.PropsetOrderedSet Carrier) F). { subst F. pose proof (Hmono := @is_monotonic Σ Mext). simpl in Hmono. apply Hmono. { unfold well_formed in Hwf. simpl in Hwf. destruct_and!. split_and!; assumption. } { apply set_svar_fresh_is_fresh. } } assert (HmonoG: @Lattice.MonotonicFunction (propset (Domain M)) (Lattice.PropsetOrderedSet (Domain M)) G). { subst G. apply is_monotonic. { unfold well_formed in Hwf. simpl in Hwf. wf_auto2. } { apply set_svar_fresh_is_fresh. } } set (Lattice.PowersetLattice (Domain M)) as L in |-. set (Lattice.PowersetLattice (Domain Mext)) as L' in |-. assert (HGmuG: G (@Lattice.LeastFixpointOf _ _ L G) = (@Lattice.LeastFixpointOf _ _ L G)). { apply Lattice.LeastFixpoint_fixpoint. apply HmonoG. } apply Lattice.LeastFixpoint_unique_2. { exact HmonoF. } { fold L. rewrite -[x in (_ = (lift_set x))]HGmuG. rewrite HeqF. rewrite update_svar_val_lift_set_comm. rewrite IHszdata. { rewrite svar_open_size'. lia. } { apply is_SData_svar_open. assumption. } { wf_auto2. } rewrite HeqG. reflexivity. } { set (λ (A : propset (Domain Mext)), PropSet (λ (m : Domain M), lift_value m ∈ A)) as strip. set (λ A, lift_set (eval (update_svar_val (fresh_svar ϕ) (strip A) ρ) (ϕ^{svar: 0 ↦ (fresh_svar ϕ)}))) as G'. assert (Hstripmono: forall x y, x ⊆ y -> strip x ⊆ strip y). { intros x y Hxy. unfold strip. unfold lift_value. clear -Hxy. set_solver. } assert (Hstriplift: forall X, strip (lift_set X) = X). { intros X. unfold strip,lift_set,lift_value,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. clear. set_solver. } assert (HmonoG' : @Lattice.MonotonicFunction _ (Lattice.PropsetOrderedSet (Domain Mext)) G'). { unfold Lattice.MonotonicFunction. intros x y Hxy. unfold G'. simpl. apply lift_set_mono. simpl in Hxy. rewrite HeqG in HmonoG. unfold Lattice.MonotonicFunction in HmonoG. simpl in HmonoG. specialize (HmonoG (strip x) (strip y)). apply HmonoG. apply Hstripmono. apply Hxy. } assert (Hls: lift_set (@Lattice.LeastFixpointOf _ _ L G) = (@Lattice.LeastFixpointOf _ _ L' G')). { assert (G'liftlfpG: G' (lift_set (@Lattice.LeastFixpointOf _ _ L G)) = lift_set (@Lattice.LeastFixpointOf _ _ L G)). { rewrite <- HGmuG at 2. unfold G'. rewrite Hstriplift. f_equal. rewrite HeqG. reflexivity. } apply Lattice.LeastFixpoint_unique_2. { exact HmonoG'. } { apply G'liftlfpG. } { intros A HA. rewrite -HA. unfold G'. simpl. apply lift_set_mono. pose proof (Htmp := Lattice.LeastFixpoint_LesserThanPrefixpoint _ _ L G). simpl in Htmp. apply Htmp. clear Htmp. replace (eval (update_svar_val (fresh_svar ϕ) (strip A) ρ) (ϕ^{svar: 0 ↦ (fresh_svar ϕ)})) with (G (strip A)) by (subst; reflexivity). apply HmonoG. simpl. rewrite <- HA at 2. unfold G'. rewrite HeqG. rewrite Hstriplift. apply reflexivity. } } (*replace (propset Carrier) with (propset (Domain Mext)) by reflexivity.*) intros A HA. rewrite Hls. apply Lattice.LeastFixpoint_LesserThanPrefixpoint. simpl. rewrite <- HA at 2. unfold G'. rewrite HeqF. assert (Hliftstrip: lift_set (strip A) ⊆ A). { clear. unfold lift_set,strip,lift_value,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. set_solver. } assert (@eval Σ Mext (update_svar_val (fresh_svar ϕ) (lift_set (strip A)) (lift_val ρ)) (ϕ^{svar: 0 ↦ (fresh_svar ϕ)}) ⊆ @eval Σ Mext (update_svar_val (fresh_svar ϕ) A (lift_val ρ)) (ϕ^{svar: 0 ↦ (fresh_svar ϕ)})). { apply is_monotonic. { unfold well_formed in Hwf. destruct_and!. assumption. } { apply set_svar_fresh_is_fresh. } apply Hliftstrip. } eapply transitivity. 2: { apply H. } rewrite update_svar_val_lift_set_comm. rewrite IHszdata. { rewrite svar_open_size'. lia. } { apply is_SData_svar_open. assumption. } { wf_auto2. } apply reflexivity. } } } { (* preservation of predicates *) intros ψ ρ Hszϕ HSPred Hwf. destruct HSPred; simpl in Hszϕ. { (* patt_bott *) rewrite eval_bott_simpl. rewrite eval_bott_simpl. split. { split; auto. } { split; intros H; exfalso; clear -H. { apply full_impl_not_empty in H; unfold Empty in H; contradiction. } { apply full_impl_not_empty in H; unfold Empty in H; contradiction. } } } { (* patt_defined ϕ *) unfold patt_defined. do 2 rewrite eval_app_simpl. do 2 rewrite eval_sym_simpl. rewrite IHszdata. { lia. } { assumption. } { wf_auto2. } Arguments Domain : simpl never. unfold app_ext. simpl. assert (Htmp: new_sym_interp (Definedness_Syntax.inj definedness) = {[cdef]}). { unfold new_sym_interp. repeat case_match. { reflexivity. } { contradiction. } { contradiction. } } rewrite Htmp. unfold new_app_interp. unfold_leibniz. destruct (classic (eval ρ ϕ = ∅)) as [Hempty|Hnonempty]. { rewrite Hempty. split. { split. { intros H'. apply set_subseteq_antisymm. 2: { clear. set_solver. } { rewrite set_equiv_subseteq in H'. destruct H' as [H' _]. rewrite elem_of_subseteq in H'. rewrite elem_of_subseteq. intros x. rewrite elem_of_PropSet. intros [le [re H''] ]. specialize (H' (lift_value x)). exfalso. rewrite elem_of_PropSet in H'. cut (@elem_of _ (propset (@Domain Σ Mext)) _ (lift_value x) (@empty (propset (@Domain _ Mext)) _)). { intros Hcontra. clear -Hcontra. set_solver. } apply H'. clear H'. exists cdef. destruct H'' as [H''1 [H''2 H''3] ]. exfalso. clear -H''2. set_solver. } } { intros H'. rewrite set_equiv_subseteq. rewrite elem_of_subseteq. split. 2: { clear. set_solver. } intros x. rewrite elem_of_PropSet. rewrite set_equiv_subseteq in H'. destruct H' as [H' _]. rewrite elem_of_subseteq in H'. intros HContra. destruct HContra as [le [re [Hle [HContra Hrest] ] ] ]. exfalso. clear -HContra. unfold lift_set in HContra. unfold fmap in HContra. with_strategy transparent [propset_fmap] unfold propset_fmap in HContra. set_solver. } } { split. { intros H'. rewrite set_equiv_subseteq. split. { clear. set_solver. } rewrite elem_of_subseteq. intros x Hx. rewrite set_equiv_subseteq in H'. destruct H' as [_ H'2]. rewrite elem_of_subseteq in H'2. specialize (H'2 (lift_value x)). feed specialize H'2. { clear. set_solver. } rewrite elem_of_PropSet in H'2. destruct H'2 as [le [re [Hle [Hre Hmatch] ] ] ]. exfalso. clear -Hre. unfold lift_set in Hre. unfold fmap in Hre. with_strategy transparent [propset_fmap] unfold propset_fmap in Hre. set_solver. } { intros H'. rewrite set_equiv_subseteq. rewrite set_equiv_subseteq in H'. destruct H' as [_ H']. rewrite elem_of_subseteq in H'. rewrite elem_of_subseteq. split. { intros x H''. clear. set_solver. } { rewrite elem_of_subseteq. intros x Hx. rewrite elem_of_PropSet. specialize (H' (@stdpp.base.inhabitant (@Domain _ M) (@Domain_inhabited _ M))). feed specialize H'. { clear. set_solver. } rewrite elem_of_PropSet in H'. destruct H' as [le [re [H'1 [H'2 H'3] ] ] ]. exfalso. clear -H'2. set_solver. } } } } { split. { split. { intros H'. rewrite set_equiv_subseteq in H'. rewrite elem_of_subseteq in H'. destruct H' as [H'1 _]. rewrite set_equiv_subseteq. split. { rewrite elem_of_subseteq. intros x Hx. cut (@elem_of (@Domain Σ Mext) (propset (@Domain Σ Mext)) (@propset_elem_of (@Domain Σ Mext)) (lift_value x) (@empty (propset (@Domain Σ Mext)) (@propset_empty (@Domain Σ Mext)))). { intros HContra. clear -HContra. set_solver. } apply H'1. rewrite elem_of_PropSet in Hx. destruct Hx as [le [re [Hx1 [Hx2 Hx3] ] ] ]. rewrite elem_of_PropSet. exists cdef. exists (lift_value re). split. { clear. set_solver. } split. 2: { clear. set_solver. } clear -Hx2. unfold lift_value,lift_set,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. set_solver. } { clear. set_solver. } } { intros H'. rewrite set_equiv_subseteq. split. { rewrite elem_of_subseteq. intros x Hx. rewrite elem_of_PropSet in Hx. destruct Hx as [le [re [Hx1 [Hx2 Hx3] ] ] ]. rewrite set_equiv_subseteq in H'. destruct H' as [H' _]. rewrite elem_of_subseteq in H'. rewrite elem_of_singleton in Hx1. subst. repeat case_match; subst; auto. destruct re. { unfold lift_set,fmap in Hx2. with_strategy transparent [propset_fmap] unfold propset_fmap in Hx2. exfalso. clear -Hx2. set_solver. } { unfold lift_set,fmap in Hx2. with_strategy transparent [propset_fmap] unfold propset_fmap in Hx2. exfalso. clear -Hx2. set_solver. } destruct el. 2: { unfold lift_set,fmap in Hx2. with_strategy transparent [propset_fmap] unfold propset_fmap in Hx2. exfalso. clear -Hx2. set_solver. } exfalso. specialize (H' d). feed specialize H'. { clear H' Hx3. rewrite elem_of_PropSet. unfold lift_set,fmap in Hx2. with_strategy transparent [propset_fmap] unfold propset_fmap in Hx2. rewrite elem_of_PropSet in Hx2. destruct Hx2 as [a [Hx21 Hx22] ]. inversion Hx21. clear Hx21. subst. rewrite elem_of_PropSet in Hx22. destruct Hx22 as [a [Hx21 Hx22] ]. inversion Hx21. clear Hx21. subst. pose proof (Hel := @satisfies_definedness_implies_has_element_for_every_element Σ _ M). feed specialize Hel. { assumption. } specialize (Hel a a). destruct Hel as [z [Hz1 Hz2] ]. exists z. exists a. split. { exact Hz1. } split. { exact Hx22. } exact Hz2. } { clear -H'. set_solver. } } { clear. set_solver. } } } { split. { intros H'. rewrite set_equiv_subseteq in H'. rewrite set_equiv_subseteq. split. { clear. set_solver. } { rewrite elem_of_subseteq. rewrite elem_of_subseteq in H'. intros x Hx. rewrite elem_of_PropSet. destruct H' as [_ H']. rewrite elem_of_subseteq in H'. specialize (H' (lift_value x)). specialize (H' I). rewrite elem_of_PropSet in H'. destruct H' as [le [re [Hle [Hre H'] ] ] ]. rewrite elem_of_singleton in Hle. subst le. unfold lift_set,fmap in Hre. with_strategy transparent [propset_fmap] unfold propset_fmap in Hre. rewrite elem_of_PropSet in Hre. destruct Hre as [a [Ha Hre] ]. subst re. rewrite elem_of_PropSet in Hre. destruct Hre as [a0 [Ha0 Hre] ]. subst a. pose proof (Hel := @satisfies_definedness_implies_has_element_for_every_element Σ _ M). feed specialize Hel. { assumption. } specialize (Hel a0 x). destruct Hel as [z [Hz1 Hz2] ]. exists z. exists a0. split. { exact Hz1. } split. { exact Hre. } exact Hz2. } } { intros H'. rewrite set_equiv_subseteq in H'. destruct H' as [_ H']. rewrite elem_of_subseteq in H'. rewrite set_equiv_subseteq. split. { clear. set_solver. } { rewrite elem_of_subseteq. intros x Hx. rewrite elem_of_PropSet. exists cdef. assert (Hex : exists el, el ∈ eval ρ ϕ). { clear -Hnonempty. apply NNPP. intros HContra. set_solver. } destruct Hex as [el Hel]. exists (lift_value el). split. { clear. set_solver. } split. 2: { clear. set_solver. } unfold lift_value,lift_set,fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. clear -Hel. set_solver. } } } } } { (* patt_equal ϕ₁ ϕ₂ *) rewrite equal_iff_interpr_same. 1: { apply Mext_satisfies_definedness. } rewrite equal_iff_interpr_same. 1: { apply M_def. } rewrite not_equal_iff_not_interpr_same_1. 1: { apply Mext_satisfies_definedness. } rewrite not_equal_iff_not_interpr_same_1. 1: { apply M_def. } rewrite IHszdata. { lia. } { assumption. } { wf_auto2. } rewrite IHszdata. { lia. } { assumption. } { wf_auto2. } rewrite lift_set_injective. tauto. } { (* patt_subseteq ϕ₁ ϕ₂ *) rewrite subseteq_iff_interpr_subseteq. 1: { apply Mext_satisfies_definedness. } rewrite subseteq_iff_interpr_subseteq. 1: { apply M_def. } rewrite not_subseteq_iff_not_interpr_subseteq_1. 1: { apply Mext_satisfies_definedness. } rewrite not_subseteq_iff_not_interpr_subseteq_1. 1: { apply M_def. } rewrite IHszdata. { lia. } { assumption. } { wf_auto2. } rewrite IHszdata. { lia. } { assumption. } { wf_auto2. } rewrite lift_set_mono. tauto. } { (* patt_impl ψ₁ ψ₂*) do 2 rewrite eval_imp_simpl. pose proof (IH1 := IHszpred ϕ₁ ρ). feed specialize IH1. { lia. } { assumption. } { wf_auto2. } destruct IH1 as [IH11 IH12]. pose proof (IH2 := IHszpred ϕ₂ ρ). feed specialize IH2. { lia. } { assumption. } { wf_auto2. } destruct IH2 as [IH21 IH22]. split. { split; intros H. { rewrite empty_union_L in H. destruct H as [H1 H2]. rewrite empty_union_L. split. { rewrite stdpp_ext.complement_empty_iff_full in H1. rewrite stdpp_ext.complement_empty_iff_full. rewrite -IH12. assumption. } { rewrite -IH21. assumption. } } { rewrite empty_union_L in H. destruct H as [H1 H2]. rewrite empty_union_L. split. { rewrite stdpp_ext.complement_empty_iff_full. rewrite stdpp_ext.complement_empty_iff_full in H1. rewrite IH12. exact H1. } { rewrite IH21. exact H2. } } } { apply SPred_is_predicate in HSPred1. 2: { unfold well_formed,well_formed_closed in Hwf. simpl in Hwf. destruct_and!. assumption. } apply SPred_is_predicate in HSPred2. 2: { unfold well_formed,well_formed_closed in Hwf. simpl in Hwf. destruct_and!. assumption. } specialize (HSPred1 ρ). specialize (HSPred2 ρ). split; intros H. { destruct HSPred1 as [H1T|H1B], HSPred2 as [H2T|H2B]. { rewrite H2T. clear. set_solver. } { rewrite H2B. apply IH21 in H2B. rewrite H2B in H. assert (H': eval (lift_val ρ) ϕ₁ = ∅). { clear -H. set_solver. } rewrite IH11 in H'. rewrite H'. clear. set_solver. } { rewrite H1B. rewrite H2T. clear. set_solver. } { rewrite H1B. rewrite H2B. clear. set_solver. } } { destruct HSPred1 as [H1T|H1B], HSPred2 as [H2T|H2B]. { apply IH12 in H1T. rewrite H1T. apply IH22 in H2T. rewrite H2T. clear. set_solver. } { rewrite H1T in H. rewrite H2B in H. exfalso. clear -H. pose proof (Hinh := Domain_inhabited M). inversion Hinh. set_solver. } { apply IH11 in H1B. rewrite H1B. apply IH22 in H2T. rewrite H2T. clear. set_solver. } { apply IH11 in H1B. rewrite H1B. apply IH21 in H2B. rewrite H2B. clear. set_solver. } } } } { unshelve (erewrite eval_exists_of_sort). 3: { rewrite HSortImptDef. apply Mext_satisfies_definedness. } 1: { intros m. apply Mext_indec. assumption. } unshelve (erewrite eval_exists_of_sort). 3: { rewrite HSortImptDef. assumption. } 1: { intros m. apply indec. assumption. } do 2 rewrite stdpp_ext.propset_fa_union_empty. specialize (IHszpred (ϕ^{evar: 0 ↦ fresh_evar ϕ})). split. { split; intros H'; intros c. { destruct (indec _ H c ρ) as [Hin|Hnotin]. 2: { reflexivity. } specialize (H' (lift_value c)). rewrite update_evar_val_lift_val_comm in H'. specialize (IHszpred (update_evar_val (fresh_evar ϕ) c ρ)). feed specialize IHszpred. { rewrite evar_open_size'. lia. } { apply is_SPredicate_evar_open. assumption. } { wf_auto2. } destruct IHszpred as [IH1 IH2]. destruct (Mext_indec _ H (lift_value c) ρ) as [Hin'|Hnotin']. { apply IH1 in H'. apply H'. } { exfalso. unfold Minterp_inhabitant in Hin,Hnotin'. rewrite eval_app_simpl in Hin. rewrite eval_app_simpl in Hnotin'. do 2 rewrite eval_sym_simpl in Hin. do 2 rewrite eval_sym_simpl in Hnotin'. unfold app_ext in Hin,Hnotin'. unfold lift_value in Hnotin'. simpl in Hnotin'. unfold new_sym_interp in Hnotin'. rewrite elem_of_PropSet in Hnotin'. unfold is_not_core_symbol,is_core_symbol in H. repeat case_match; subst; auto; try contradiction. apply Hnotin'. clear -Hin. rewrite elem_of_PropSet in Hin. destruct Hin as [le [re [Hle [Hre Hin] ] ] ]. exists cinh. exists (cel (inl re)). split. { clear. set_solver. } split. { unfold fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. rewrite elem_of_PropSet. exists (inl re). split;[reflexivity|]. rewrite elem_of_PropSet. exists re. split;[reflexivity|]. assumption. } unfold new_app_interp. unfold fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. rewrite elem_of_PropSet. exists (inl c). split;[reflexivity|]. rewrite elem_of_PropSet. exists c. split;[reflexivity|]. unfold app_ext. rewrite elem_of_PropSet. exists le. exists re. split;[assumption|]. split;[(clear; set_solver)|]. assumption. } } { destruct (Mext_indec _ H c ρ) as [Hin|Hnotin]. { unfold Minterp_inhabitant in Hin. rewrite eval_app_simpl in Hin. do 2 rewrite eval_sym_simpl in Hin. unfold app_ext in Hin. rewrite elem_of_PropSet in Hin. destruct Hin as [le [re [Hle [Hre Hin] ] ] ]. simpl in Hle,Hre,Hin. unfold is_not_core_symbol,is_core_symbol in H. unfold new_app_interp in Hin. unfold new_sym_interp in Hle,Hre. repeat case_match; subst; try contradiction; try congruence. 2: { exfalso. clear -Hre. unfold fmap in Hre. with_strategy transparent [propset_fmap] unfold propset_fmap in Hre. set_solver. } unfold fmap in Hin. with_strategy transparent [propset_fmap] unfold propset_fmap in Hin. destruct c. { exfalso. clear -Hin. set_solver. } { exfalso. clear -Hin. set_solver. } destruct el. 2: { exfalso. clear -Hin. set_solver. } rewrite update_evar_val_lift_val_comm. clear -IHszpred Hszϕ HSPred Hwf H' Hin Hre. specialize (IHszpred (update_evar_val (fresh_evar ϕ) d0 ρ)). feed specialize IHszpred. { rewrite evar_open_size'. lia. } { apply is_SPredicate_evar_open. assumption. } { wf_auto2. } destruct IHszpred as [IH1 IH2]. rewrite IH1. specialize (H' d0). destruct (indec _ H d0 ρ) as [Hin'|Hnotin']. { apply H'. } { exfalso. apply Hnotin'. clear Hnotin'. unfold Minterp_inhabitant. rewrite eval_app_simpl. do 2 rewrite eval_sym_simpl. rewrite elem_of_PropSet in Hin. destruct Hin as [a [Ha Hin] ]. inversion Ha. clear Ha. subst. rewrite elem_of_PropSet in Hin. destruct Hin as [a [Ha Hin] ]. inversion Ha. clear Ha. subst. unfold app_ext in Hin. rewrite elem_of_PropSet in Hin. destruct Hin as [le [re [Hle' [Hre' Hin] ] ] ]. rewrite elem_of_singleton in Hre'. subst re. unfold app_ext. rewrite elem_of_PropSet. unfold fmap in Hre. with_strategy transparent [propset_fmap] unfold propset_fmap in Hre. rewrite elem_of_PropSet in Hre. destruct Hre as [a' [Ha' Hre'] ]. rewrite elem_of_PropSet in Hre'. destruct Hre' as [a'' [Ha'' Hre'] ]. subst. inversion Ha'. clear Ha'. subst. exists le. exists a''. split;[assumption|]. split;assumption. } } reflexivity. } } { do 2 rewrite stdpp_ext.propset_fa_union_full. pose proof (HSPred' := HSPred). apply SPred_is_pre_predicate in HSPred'. apply (@M_pre_predicate_evar_open Σ M ϕ (fresh_evar ϕ)) in HSPred'. specialize (HSPred' 0). apply closed_M_pre_pre_predicate_is_M_predicate in HSPred'. 2: { unfold well_formed,well_formed_closed in Hwf. simpl in Hwf. destruct_and!. wf_auto2. } split; intros H' t. { specialize (H' stdpp.base.inhabitant). destruct H' as [c Hc]. destruct (Mext_indec _ H c ρ) as [Hin|Hnotin]. { unfold Minterp_inhabitant in Hin. rewrite eval_app_simpl in Hin. do 2 rewrite eval_sym_simpl in Hin. unfold app_ext in Hin. rewrite elem_of_PropSet in Hin. simpl in Hin. destruct Hin as [le [re [Hle [Hre Hin] ] ] ]. unfold is_not_core_symbol,is_core_symbol in H. unfold new_sym_interp in Hle,Hre. unfold new_app_interp in Hin. repeat case_match; subst; try contradiction; try congruence; unfold fmap in Hre; with_strategy transparent [propset_fmap] unfold propset_fmap in Hre; rewrite elem_of_PropSet in Hre; destruct Hre as [amr [Hamr Hamr'] ]; inversion Hamr; clear Hamr; subst; rewrite elem_of_PropSet in Hamr'; destruct Hamr' as [amr' [Hamr'' Hamr'] ]; inversion Hamr''; clear Hamr''; subst. unfold fmap in Hin. with_strategy transparent [propset_fmap] unfold propset_fmap in Hin. rewrite elem_of_PropSet in Hin. destruct Hin as [a [Htmp Ha] ]. subst. rewrite elem_of_PropSet in Ha. destruct Ha as [a0 [Htmp Ha0] ]. subst. unfold app_ext in Ha0. rewrite elem_of_PropSet in Ha0. destruct Ha0 as [le' [re' [Hle' [Hre' Hle're'] ] ] ]. rewrite elem_of_singleton in Hre'. subst re'. exists a0. destruct (indec _ H a0 ρ) as [Hin'|Hnotin']. 2: { exfalso. apply Hnotin'. unfold Minterp_inhabitant. rewrite eval_app_simpl. do 2 rewrite eval_sym_simpl. unfold app_ext. rewrite elem_of_PropSet. exists le'. exists amr'. repeat split; try assumption. } { clear -IHszpred Hc Hwf Hszϕ HSPred HSPred'. rewrite update_evar_val_lift_val_comm in Hc. specialize (IHszpred (update_evar_val (fresh_evar ϕ) a0 ρ)). feed specialize IHszpred. { rewrite evar_open_size'. lia. } { apply is_SPredicate_evar_open. assumption. } { wf_auto2. } destruct IHszpred as [IH1 IH2]. specialize (HSPred' (update_evar_val (fresh_evar ϕ) a0 ρ)). destruct HSPred' as [HFull|HEmpty]. { rewrite HFull. clear. set_solver. } { apply IH1 in HEmpty. exfalso. rewrite HEmpty in Hc. clear -Hc. set_solver. } } } { exfalso. clear -Hc. set_solver. } } { specialize (H' (@stdpp.base.inhabitant _ (Domain_inhabited M))). destruct H' as [c Hc]. destruct (indec _ H c ρ) as [Hin|Hnotin]. { exists (lift_value c). destruct (Mext_indec _ H (lift_value c) ρ) as [Hin'|Hnotin']. { rewrite update_evar_val_lift_val_comm. specialize (IHszpred (update_evar_val (fresh_evar ϕ) c ρ)). feed specialize IHszpred. { rewrite evar_open_size'. lia. } { apply is_SPredicate_evar_open. assumption. } { wf_auto2. } destruct IHszpred as [IH1 IH2]. specialize (HSPred' (update_evar_val (fresh_evar ϕ) c ρ)). destruct HSPred' as [HFull|HEmpty]. { apply IH2 in HFull. rewrite HFull. clear. set_solver. } { rewrite HEmpty in Hc. exfalso. clear -Hc. set_solver. } } { exfalso. apply Hnotin'. clear Hnotin'. unfold Minterp_inhabitant. rewrite eval_app_simpl. do 2 rewrite eval_sym_simpl. simpl. unfold app_ext. rewrite elem_of_PropSet. unfold Minterp_inhabitant in Hin. rewrite eval_app_simpl in Hin. do 2 rewrite eval_sym_simpl in Hin. unfold app_ext in Hin. rewrite elem_of_PropSet in Hin. destruct Hin as [le [re [Hle [Hre Hlere] ] ] ]. simpl. exists cinh. exists (lift_value re). split. { unfold new_sym_interp. repeat case_match; try congruence. } simpl. split. { unfold new_sym_interp,lift_value. simpl in *. unfold is_not_core_symbol,is_core_symbol in H. repeat case_match; subst; try tauto. unfold fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. rewrite elem_of_PropSet. exists (inl re). split;[reflexivity|]. rewrite elem_of_PropSet. exists re. split;[reflexivity|]. assumption. } { unfold fmap,lift_value. with_strategy transparent [propset_fmap] unfold propset_fmap. rewrite elem_of_PropSet. exists (inl c). split;[reflexivity|]. rewrite elem_of_PropSet. exists c. split;[reflexivity|]. rewrite elem_of_PropSet. exists le. exists re. split;[assumption|]. split;[(clear;set_solver)|]. assumption. } } } { exfalso. clear -Hc. set_solver. } } } } { unshelve (erewrite eval_forall_of_sort). 3: { rewrite HSortImptDef. apply Mext_satisfies_definedness. } 1: { intros m. apply Mext_indec. assumption. } unshelve (erewrite eval_forall_of_sort). 3: { rewrite HSortImptDef. assumption. } 1: { intros m. apply indec. assumption. } do 2 rewrite stdpp_ext.propset_fa_intersection_full. rewrite stdpp_ext.propset_fa_intersection_empty. unshelve (erewrite @stdpp_ext.propset_fa_intersection_empty). 3: { apply _. } 2: { apply Domain_inhabited. } split. { split. { intros H'. intros t. specialize (H' (stdpp.base.inhabitant)). destruct H' as [c Hc]. destruct (Mext_indec _ H c ρ) as [Hin|Hnotin]. { unfold Minterp_inhabitant in Hin. rewrite eval_app_simpl in Hin. do 2 rewrite eval_sym_simpl in Hin. unfold app_ext in Hin. rewrite elem_of_PropSet in Hin. simpl in Hin. destruct Hin as [le [re [Hle [Hre Hin] ] ] ]. unfold is_not_core_symbol,is_core_symbol in H. unfold new_sym_interp in Hle,Hre. repeat case_match; subst; try contradiction; try congruence; try (solve [exfalso;tauto]). unfold fmap in Hre. with_strategy transparent [propset_fmap] unfold propset_fmap in Hre. rewrite elem_of_PropSet in Hre. destruct Hre as [amr [Hamr Hre] ]. subst re. rewrite elem_of_PropSet in Hre. destruct Hre as [a [Ha Hre] ]. subst amr. rewrite elem_of_singleton in Hle. subst le. unfold new_app_interp in Hin. repeat case_match; subst. unfold fmap in Hin. with_strategy transparent [propset_fmap] unfold propset_fmap in Hin. rewrite elem_of_PropSet in Hin. destruct Hin as [amr [Hamr Hin] ]. subst c. rewrite elem_of_PropSet in Hin. destruct Hin as [a0 [Hamr Hin] ]. subst amr. unfold app_ext in Hin. rewrite elem_of_PropSet in Hin. destruct Hin as [le [re [Hle [Hre' Hin] ] ] ]. rewrite elem_of_singleton in Hre'. subst re. specialize (IHszpred (ϕ^{evar: 0 ↦ fresh_evar ϕ}) (update_evar_val (fresh_evar ϕ) a0 ρ)). feed specialize IHszpred. { rewrite evar_open_size'. lia. } { apply is_SPredicate_evar_open. assumption. } { wf_auto2. } destruct IHszpred as [IH1 IH2]. pose proof (HSPred' := HSPred). apply SPred_is_pre_predicate in HSPred'. apply (@M_pre_predicate_evar_open Σ M ϕ (fresh_evar ϕ)) in HSPred'. exists a0. destruct (indec _ H a0 ρ) as [Hin'|Hnotin']. { rewrite update_evar_val_lift_val_comm in Hc. intros HContra. apply Hc. clear Hc. unfold M_pre_predicate in HSPred'. specialize (HSPred' 0). apply closed_M_pre_pre_predicate_is_M_predicate in HSPred'. 2: { unfold well_formed,well_formed_closed in Hwf. simpl in Hwf. destruct_and!. wf_auto2. } specialize (HSPred' (update_evar_val (fresh_evar ϕ) a0 ρ)). destruct HSPred' as [HFull|HEmpty]. { apply IH2 in HFull. rewrite HFull. clear. set_solver. } { rewrite HEmpty in HContra. exfalso. clear -HContra. set_solver. } } { exfalso. apply Hnotin'. unfold Minterp_inhabitant. rewrite eval_app_simpl. do 2 rewrite eval_sym_simpl. unfold app_ext. rewrite elem_of_PropSet. exists le. exists a. repeat split; assumption. } } { exfalso. clear -Hc. set_solver. } } { intros H'. intros t. specialize (H' (@stdpp.base.inhabitant _ (Domain_inhabited M))). destruct H' as [c Hc]. destruct (indec _ H c ρ) as [Hin|Hnotin]. { unfold Minterp_inhabitant in Hin. rewrite eval_app_simpl in Hin. do 2 rewrite eval_sym_simpl in Hin. unfold app_ext in Hin. rewrite elem_of_PropSet in Hin. destruct Hin as [le [re [Hle [Hre Hin] ] ] ]. specialize (IHszpred (ϕ^{evar: 0 ↦ fresh_evar ϕ}) (update_evar_val (fresh_evar ϕ) c ρ)). feed specialize IHszpred. { rewrite evar_open_size'. lia. } { apply is_SPredicate_evar_open. assumption. } { wf_auto2. } destruct IHszpred as [IH1 IH2]. pose proof (HSPred' := HSPred). apply SPred_is_pre_predicate in HSPred'. apply (@M_pre_predicate_evar_open Σ M ϕ (fresh_evar ϕ)) in HSPred'. exists (lift_value c). destruct (Mext_indec _ H (lift_value c) ρ) as [Hin'|Hnotin']. { rewrite update_evar_val_lift_val_comm. unfold M_pre_predicate in HSPred'. specialize (HSPred' 0). apply closed_M_pre_pre_predicate_is_M_predicate in HSPred'. 2: { unfold well_formed,well_formed_closed in Hwf. simpl in Hwf. destruct_and!. wf_auto2. } specialize (HSPred' (update_evar_val (fresh_evar ϕ) c ρ)). destruct HSPred' as [HFull|HEmpty]. { intros HContra. apply Hc. clear Hc. rewrite HFull. clear. set_solver. } { apply IH1 in HEmpty. rewrite HEmpty. clear. set_solver. } } { exfalso. apply Hnotin'. clear Hnotin'. unfold Minterp_inhabitant. rewrite eval_app_simpl. do 2 rewrite eval_sym_simpl. unfold app_ext. rewrite elem_of_PropSet. exists cinh. exists (lift_value re). simpl. unfold lift_value,new_sym_interp. unfold is_not_core_symbol,is_core_symbol in H. repeat case_match; subst; try congruence; try contradiction; try tauto. split. { clear. set_solver. } unfold fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. split. { rewrite elem_of_PropSet. exists (inl re). split;[reflexivity|]. rewrite elem_of_PropSet. exists re. split;[reflexivity|]. assumption. } { rewrite elem_of_PropSet. exists (inl c). split;[reflexivity|]. rewrite elem_of_PropSet. exists c. split;[reflexivity|]. rewrite elem_of_PropSet. exists le. exists re. split;[assumption|]. split;[(clear; set_solver)|]. assumption. } } } { exfalso. clear -Hc. set_solver. } } } { split; intros H'. { intros c. destruct (indec _ H c ρ) as [Hin|Hnotin]. { specialize (IHszpred (ϕ^{evar: 0 ↦ fresh_evar ϕ}) (update_evar_val (fresh_evar ϕ) c ρ)). feed specialize IHszpred. { rewrite evar_open_size'. lia. } { apply is_SPredicate_evar_open. assumption. } { wf_auto2. } destruct IHszpred as [IH1 IH2]. specialize (H' (lift_value c)). destruct (Mext_indec _ H (lift_value c) ρ) as [Hin'|Hnotin']. { rewrite update_evar_val_lift_val_comm in H'. apply IH2 in H'. exact H'. } { exfalso. apply Hnotin'. clear Hnotin' H'. unfold Minterp_inhabitant in Hin. rewrite eval_app_simpl in Hin. do 2 rewrite eval_sym_simpl in Hin. unfold app_ext in Hin. rewrite elem_of_PropSet in Hin. destruct Hin as [le [re [Hle [Hre Hin] ] ] ]. unfold Minterp_inhabitant. rewrite eval_app_simpl. do 2 rewrite eval_sym_simpl. unfold app_ext. rewrite elem_of_PropSet. exists cinh. exists (lift_value re). simpl. with_strategy transparent [propset_fmap] unfold propset_fmap. unfold new_sym_interp. unfold is_not_core_symbol,is_core_symbol in H. repeat case_match; subst; try congruence; try contradiction; try tauto. split;[(clear; set_solver)|]. unfold fmap. with_strategy transparent [propset_fmap] unfold propset_fmap. unfold lift_value. repeat setoid_rewrite elem_of_PropSet. split. { exists (inl re). split;[reflexivity|]. exists re. split;[reflexivity|]. assumption. } { exists (inl c). split;[reflexivity|]. exists c. split;[reflexivity|]. exists le. exists re. split;[assumption|]. split;[(clear;set_solver)|]. assumption. } } } { reflexivity. } } { intros c. destruct (Mext_indec _ H c ρ) as [Hin|Hnotin]. 2: { reflexivity. } unfold Minterp_inhabitant in Hin. rewrite eval_app_simpl in Hin. do 2 rewrite eval_sym_simpl in Hin. unfold app_ext in Hin. rewrite elem_of_PropSet in Hin. simpl in Hin. unfold new_sym_interp,new_app_interp in Hin. destruct Hin as [le [re [Hle [Hre Hin] ] ] ]. unfold is_not_core_symbol,is_core_symbol in H. repeat case_match; subst; try congruence; try contradiction. 2: { unfold fmap in Hre. with_strategy transparent [propset_fmap] unfold propset_fmap in Hre. rewrite elem_of_PropSet in Hre. destruct Hre as [a [Ha Hre] ]. inversion Ha. clear Ha. subst. rewrite elem_of_PropSet in Hre. destruct Hre as [a [Ha Hre] ]. inversion Ha. } unfold fmap in Hre. with_strategy transparent [propset_fmap] unfold propset_fmap in Hre. rewrite elem_of_PropSet in Hre. destruct Hre as [a [Ha Hre] ]. inversion Ha. clear Ha. subst. rewrite elem_of_PropSet in Hre. destruct Hre as [a [Ha Hre] ]. inversion Ha. clear Ha. subst. unfold fmap in Hin. with_strategy transparent [propset_fmap] unfold propset_fmap in Hin. rewrite elem_of_PropSet in Hin. destruct Hin as [a0 [Ha0 Hin] ]. subst. rewrite elem_of_PropSet in Hin. destruct Hin as [a1 [Ha1 Hin] ]. subst. unfold app_ext in Hin. rewrite elem_of_PropSet in Hin. destruct Hin as [le' [re' [Hle' [Hre' Hin] ] ] ]. rewrite elem_of_singleton in Hre'. subst. rewrite update_evar_val_lift_val_comm. specialize (IHszpred (ϕ^{evar: 0 ↦ fresh_evar ϕ}) (update_evar_val (fresh_evar ϕ) a1 ρ)). feed specialize IHszpred. { rewrite evar_open_size'. lia. } { apply is_SPredicate_evar_open. assumption. } { wf_auto2. } destruct IHszpred as [IH1 IH2]. specialize (H' a1). destruct (indec _ H a1 ρ) as [Hin'|Hnotin']. { apply IH2 in H'. apply H'. } { exfalso. apply Hnotin'. clear Hnotin'. unfold Minterp_inhabitant. rewrite eval_app_simpl. do 2 rewrite eval_sym_simpl. unfold app_ext. rewrite elem_of_PropSet. exists le'. exists a. repeat split; assumption. } } } } } } Qed. End semantic_preservation. End ext. End with_syntax.
According to the International Monetary Fund , more than half of the 10 @,@ 000 @,@ 000 cubic metres ( 13 @,@ 000 @,@ 000 cu yd ) of debris have been removed , and 20 percent of it has been recycled .
module Decidable.Order import Decidable.Decidable import Decidable.Equality import Data.Fin import Data.Fun import Data.Rel %hide Prelude.Equal -------------------------------------------------------------------------------- -- Utility Lemmas -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Preorders, Posets, total Orders, Equivalencies, Congruencies -------------------------------------------------------------------------------- public export interface Preorder t (po : t -> t -> Type) where total transitive : (a : t) -> (b : t) -> (c : t) -> po a b -> po b c -> po a c total reflexive : (a : t) -> po a a public export interface (Preorder t po) => Poset t (po : t -> t -> Type) where total antisymmetric : (a : t) -> (b : t) -> po a b -> po b a -> a = b public export interface (Poset t to) => Ordered t (to : t -> t -> Type) where total order : (a : t) -> (b : t) -> Either (to a b) (to b a) public export interface (Preorder t eq) => Equivalence t (eq : t -> t -> Type) where total symmetric : (a : t) -> (b : t) -> eq a b -> eq b a public export interface (Equivalence t eq) => Congruence t (f : t -> t) (eq : t -> t -> Type) where total congruent : (a : t) -> (b : t) -> eq a b -> eq (f a) (f b) public export minimum : (Ordered t to) => t -> t -> t minimum {to} x y with (order {to} x y) minimum {to} x y | Left _ = x minimum {to} x y | Right _ = y public export maximum : (Ordered t to) => t -> t -> t maximum {to} x y with (order {to} x y) maximum {to} x y | Left _ = y maximum {to} x y | Right _ = x -------------------------------------------------------------------------------- -- Syntactic equivalence (=) -------------------------------------------------------------------------------- public export implementation Preorder t Equal where transitive a b c l r = trans l r reflexive a = Refl public export implementation Equivalence t Equal where symmetric a b prf = sym prf public export implementation Congruence t f Equal where congruent a b eq = cong f eq
Time Team Play ARMY Win Prob. It's over, @ArmyWP_MLax beat @navymlax 9-8. Check out the #LaxWP win probability chart.
/- In Lean and related proof assistants, such as Coq, you can obtain proofs not only by applying inference rules, such as eq.refl, directly, but also by using programs, called tactics, that automate some of the details of finding and applying inference rules or sequences of such rules. As an example, we look at the "rfl" tactic, which slightly simplifies the application of the eq.refl inference rule. Let's first look at a few uses of rfl. -/ theorem t1 : 2 = 1 + 1 := rfl theorem t2 : tt = tt := rfl /- The rfl tactics appear to be producing proofs of the given propositions, and that is indeed the case. If we #check t1 we'll see that this is so. t1 is a proof of 0=0 and in fact is exactly eq.refl 0. -/ #check t1 #reduce t1 /- What rfl is doing is grabbing the left side of an equality proposition, such as 2 or tt in the examples here, and returning eq.refl applied to that value. -/ /- EXERCISE: Use rfl to produce a proof, h, of the proposition, "Hello" = "He" ++ "llo". EXERCISE: Use rfl to prove p: 3*3+4*4=5*5. -/ theorem h : "Hello" = "He" ++ "llo" := rfl /- * A brief aside about terminology *-/ /- Note: The word "theorem" in mathematics is generally used to mean an "important" proposition that has been proved. The word lemma is used to mean a less important proposition that has been proved, often as part of a larger proof of a more important theorem. Mathematicians also use the word corollary to refer to a proposition the proof of which follows from the proof of a more important theorem. You can read all about the various words used to refer to things that have been proved, or that are intended to be proved, here: https://academia.stackexchange.com/questions/113819/is-it-acceptable-for-a-referee-to-suggest-changing-theorem-into-proposition. For our purposes, we'll typically just use theorem. -/ /- As you have now seen, Lean's notion of equality does not mean exact equality of expressions. It means instead the equality the values to which they "reduce" when you "evaluate" them. We can prove 2 = 1 + 1 using rfl (or eq.refl of course) because the "literal expression", 2, reduces to the value 2; the function application expression, 1 + 1 (wherein the plus function is applied to the two arguments, 1 and 1) also reduces to 2; those two values are the same; and so eq.refl 2 generates a proof that type-checks. -/ /- EXERCISE: Prove as a theorem, tthof (a silly and uninformative name to be sure), that 2 + 3 = 1 + 4. EXERCISE: Prove as a theorem, hpleqhl, that "Hello " ++ "Lean! is equal to "Hello Lean!" (these values are of type string in Lean and the ++ operator here refers to the string concatenation function in Lean.) -/
From mathcomp Require Import all_ssreflect. From PoS_NSB Require Import Parameters Blocks. Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. (** * Messages This file contains the basic message type used for communication. **) Inductive Message := | BlockMsg of Block. Definition Messages := seq Message. Module MsgEq. Definition eq_msg a b := match a, b with | BlockMsg bA, BlockMsg bB => (bA == bB) end. Lemma eq_msgP : Equality.axiom eq_msg. Proof. by move=> /= [] ? [] ? /=; apply/(iffP idP)=> [/eqP ->| [] -> ] //. Qed. Canonical Msg_eqMixin := Eval hnf in EqMixin eq_msgP. Canonical Msg_eqType := Eval hnf in EqType Message Msg_eqMixin. End MsgEq. Export MsgEq.
[STATEMENT] lemma has_integral_subset_component_le: fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space" assumes k: "k \<in> Basis" and as: "S \<subseteq> T" "(f has_integral i) S" "(f has_integral j) T" "\<And>x. x\<in>T \<Longrightarrow> 0 \<le> f(x)\<bullet>k" shows "i\<bullet>k \<le> j\<bullet>k" [PROOF STATE] proof (prove) goal (1 subgoal): 1. i \<bullet> k \<le> j \<bullet> k [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. i \<bullet> k \<le> j \<bullet> k [PROOF STEP] have \<section>: "((\<lambda>x. if x \<in> S then f x else 0) has_integral i) UNIV" "((\<lambda>x. if x \<in> T then f x else 0) has_integral j) UNIV" [PROOF STATE] proof (prove) goal (1 subgoal): 1. ((\<lambda>x. if x \<in> S then f x else (0::'m)) has_integral i) UNIV &&& ((\<lambda>x. if x \<in> T then f x else (0::'m)) has_integral j) UNIV [PROOF STEP] by (simp_all add: assms) [PROOF STATE] proof (state) this: ((\<lambda>x. if x \<in> S then f x else (0::'m)) has_integral i) UNIV ((\<lambda>x. if x \<in> T then f x else (0::'m)) has_integral j) UNIV goal (1 subgoal): 1. i \<bullet> k \<le> j \<bullet> k [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. i \<bullet> k \<le> j \<bullet> k [PROOF STEP] using as [PROOF STATE] proof (prove) using this: S \<subseteq> T (f has_integral i) S (f has_integral j) T ?x \<in> T \<Longrightarrow> 0 \<le> f ?x \<bullet> k goal (1 subgoal): 1. i \<bullet> k \<le> j \<bullet> k [PROOF STEP] by (force intro!: has_integral_component_le[OF k \<section>]) [PROOF STATE] proof (state) this: i \<bullet> k \<le> j \<bullet> k goal: No subgoals! [PROOF STEP] qed
using FactCheck f(a) = error("Doge") facts() do @fact f(1) --> 1 "TestName" end
--- author: Nathan Carter ([email protected]) --- This answer assumes you have imported SymPy as follows. ```python from sympy import * # load all math functions init_printing( use_latex='mathjax' ) # use pretty math output ``` Let's create an equation with many variables. ```python var('P V n R T') ideal_gas_law = Eq( P*V, n*R*T ) ideal_gas_law ``` $\displaystyle P V = R T n$ To isolate one variable, call the `solve` function, and pass that variable as the second argument. ```python solve( ideal_gas_law, R ) ``` $\displaystyle \left[ \frac{P V}{T n}\right]$ The brackets surround a list of all solutions---in this case, just one. That solution is that $R=\frac{PV}{Tn}$.
#include <boost/python.hpp> #include <Crypt.h> #include <vector> namespace bp = boost::python; bool aes_encrypt(Crypt *crypt, const bp::list &msg_l, cs key, bp::list &dump_l) { std::string dump, msg; for (int i = 0; i < bp::len(msg_l); ++i) msg.append(1, (char) bp::extract<uint8_t>(msg_l[i])); if (!crypt->aes_encrypt(msg, key, dump))return false; for (auto &ch: dump) dump_l.append((uint8_t) ch); return true; } bool aes_decrypt(Crypt *crypt, const bp::list &dump_l, cs key, bp::list &msg_l) { std::string dump, msg; for (int i = 0; i < bp::len(dump_l); ++i) dump.append(1, (char) bp::extract<uint8_t>(dump_l[i])); if (!crypt->aes_decrypt(dump, key, msg))return false; for (auto &ch: msg) msg_l.append((uint8_t) ch); return true; } BOOST_PYTHON_MODULE (libCryptPy) { typedef bool (Crypt::*vc1)(cs &, cs &); typedef bool (Crypt::*vc2)(cs &, cs &, cs &); typedef bool (Crypt::*ask1)(cs &); typedef bool (Crypt::*ask2)(cs &, cs &); bp::class_<Crypt>("Crypt") .def("initialize", &Crypt::initialize) .def("terminate", &Crypt::terminate) .def("load_private_key", &Crypt::load_private_key) .def("add_cert", &Crypt::add_cert) .def("rem_cert", &Crypt::rem_cert) // .def("encrypt", &Crypt::encrypt) // .def("decrypt", &Crypt::decrypt) // .def("sign", &Crypt::sign) .def("verify", &Crypt::verify) .def<vc1>("verify_cert", &Crypt::verify_cert) .def<vc2>("verify_cert", &Crypt::verify_cert) .def("load_my_cert", &Crypt::load_my_cert) .def("stringify_cert", &Crypt::stringify_cert) // .def("aes_gen_key", &Crypt::aes_gen_key) .def<ask1>("aes_save_key", &Crypt::aes_save_key) .def<ask2>("aes_save_key", &Crypt::aes_save_key) .def("aes_del_key", &Crypt::aes_del_key) .def("aes_encrypt", &aes_encrypt) .def("aes_decrypt", &aes_decrypt) .def("aes_exist_key", &Crypt::aes_exist_key) .def("aes_get_key", &Crypt::aes_get_key); }
Unlike other Medical text, Electronic Medical Records (EMRs) are written by doctors in a clinical setting. As EMRs are relatively new themselves, they lack well defined standards for input and doctors usually write them in free-form dictation These form of text lack proper sentence structure and contain numerous acronyms that only appear in such context, making it difficult to apply current parsing techniques to discover semantic meanings of the text. In this project, methods to identify unknown acronym terms in EMRs and disambiguate their meaning are explored and developed. To better apply automated processes, the EMRs are first pre-processed to restructure their text into a more defined format. Finally these unknown acronym terms are marked up for future use. Results obtained from the formatting of the EMRs showed a precision of 100% and a recall of 67.93%. Initial extraction of acronym-value pairs from the EMRs resulted in 2329 extracted terms with 68.14% true positives, the implementation of an exclusion list, consisting of recurring false positives increased the true positives to 90.99%. While the automated disambiguation process of these true positives could not be implemented, distinct patterns for 31 acronyms were identified which can be used to disambiguate their occurrence in EMRs.
using MPI using CLIMA using CLIMA.Topologies using CLIMA.Grids using CLIMA.DGBalanceLawDiscretizations using Printf using LinearAlgebra using Logging @static if haspkg("CuArrays") using CUDAdrv using CUDAnative using CuArrays CuArrays.allowscalar(false) const ArrayTypes = (CuArray, ) else const ArrayTypes = (Array, ) end @inline function auxiliary_state_initialization!(aux, x, y, z, dim) @inbounds begin if dim == 2 aux[1] = x^2 + y^3 - x*y aux[5] = 2*x - y aux[6] = 3*y^2 - x aux[7] = 0 else aux[1] = x^2 + y^3 + z^2*y^2 - x*y*z aux[5] = 2*x - y*z aux[6] = 3*y^2 + 2*z^2*y - x*z aux[7] = 2*z*y^2 - x*y end end end using Test function run(mpicomm, dim, ArrayType, Ne, N, DFloat) brickrange = ntuple(j->range(DFloat(-1); length=Ne[j]+1, stop=1), dim) topl = BrickTopology(mpicomm, brickrange, periodicity=ntuple(j->true, dim)) grid = DiscontinuousSpectralElementGrid(topl, FloatType = DFloat, DeviceArray = ArrayType, polynomialorder = N, ) spacedisc = DGBalanceLaw(grid = grid, length_state_vector = 0, flux! = (x...) -> (), numerical_flux! = (x...) -> (), auxiliary_state_length = 7, auxiliary_state_initialization! = (x...) -> auxiliary_state_initialization!(x..., dim)) DGBalanceLawDiscretizations.grad_auxiliary_state!(spacedisc, 1, (2,3,4)) # Wrapping in Array ensure both GPU and CPU code use same approx @test Array(spacedisc.auxstate.Q[:, 2, :]) ≈ Array(spacedisc.auxstate.Q[:, 5, :]) @test Array(spacedisc.auxstate.Q[:, 3, :]) ≈ Array(spacedisc.auxstate.Q[:, 6, :]) @test Array(spacedisc.auxstate.Q[:, 4, :]) ≈ Array(spacedisc.auxstate.Q[:, 7, :]) end let MPI.Initialized() || MPI.Init() Sys.iswindows() || (isinteractive() && MPI.finalize_atexit()) mpicomm = MPI.COMM_WORLD ll = uppercase(get(ENV, "JULIA_LOG_LEVEL", "INFO")) loglevel = ll == "DEBUG" ? Logging.Debug : ll == "WARN" ? Logging.Warn : ll == "ERROR" ? Logging.Error : Logging.Info logger_stream = MPI.Comm_rank(mpicomm) == 0 ? stderr : devnull global_logger(ConsoleLogger(logger_stream, loglevel)) @static if haspkg("CUDAnative") device!(MPI.Comm_rank(mpicomm) % length(devices())) end numelem = (5, 5, 1) lvls = 1 polynomialorder = 4 for ArrayType in ArrayTypes for DFloat in (Float64,) #Float32) for dim = 2:3 err = zeros(DFloat, lvls) for l = 1:lvls @info (ArrayType, DFloat, dim) run(mpicomm, dim, ArrayType, ntuple(j->2^(l-1) * numelem[j], dim), polynomialorder, DFloat) end end end end end isinteractive() || MPI.Finalize() nothing
[GOAL] ⊢ 0 < Complex.I.im [PROOFSTEP] simp [GOAL] z : ℍ ⊢ 0 < ↑Complex.normSq ↑z [PROOFSTEP] rw [Complex.normSq_pos] [GOAL] z : ℍ ⊢ ↑z ≠ 0 [PROOFSTEP] exact z.ne_zero [GOAL] z : ℍ ⊢ 0 < (-↑z)⁻¹.im [PROOFSTEP] simpa using div_pos z.property (normSq_pos z) [GOAL] cd : Fin 2 → ℝ z : ℍ h : cd ≠ 0 ⊢ ↑(cd 0) * ↑z + ↑(cd 1) ≠ 0 [PROOFSTEP] contrapose! h [GOAL] cd : Fin 2 → ℝ z : ℍ h : ↑(cd 0) * ↑z + ↑(cd 1) = 0 ⊢ cd = 0 [PROOFSTEP] have : cd 0 = 0 := by -- we will need this twice apply_fun Complex.im at h simpa only [z.im_ne_zero, Complex.add_im, add_zero, coe_im, zero_mul, or_false_iff, Complex.ofReal_im, Complex.zero_im, Complex.mul_im, mul_eq_zero] using h [GOAL] cd : Fin 2 → ℝ z : ℍ h : ↑(cd 0) * ↑z + ↑(cd 1) = 0 ⊢ cd 0 = 0 [PROOFSTEP] apply_fun Complex.im at h [GOAL] cd : Fin 2 → ℝ z : ℍ h : (↑(cd 0) * ↑z + ↑(cd 1)).im = 0.im ⊢ cd 0 = 0 [PROOFSTEP] simpa only [z.im_ne_zero, Complex.add_im, add_zero, coe_im, zero_mul, or_false_iff, Complex.ofReal_im, Complex.zero_im, Complex.mul_im, mul_eq_zero] using h [GOAL] cd : Fin 2 → ℝ z : ℍ h : ↑(cd 0) * ↑z + ↑(cd 1) = 0 this : cd 0 = 0 ⊢ cd = 0 [PROOFSTEP] simp only [this, zero_mul, Complex.ofReal_zero, zero_add, Complex.ofReal_eq_zero] at h [GOAL] cd : Fin 2 → ℝ z : ℍ this : cd 0 = 0 h : cd 1 = 0 ⊢ cd = 0 [PROOFSTEP] ext i [GOAL] case h cd : Fin 2 → ℝ z : ℍ this : cd 0 = 0 h : cd 1 = 0 i : Fin 2 ⊢ cd i = OfNat.ofNat 0 i [PROOFSTEP] fin_cases i [GOAL] case h.head cd : Fin 2 → ℝ z : ℍ this : cd 0 = 0 h : cd 1 = 0 ⊢ cd { val := 0, isLt := (_ : 0 < 2) } = OfNat.ofNat 0 { val := 0, isLt := (_ : 0 < 2) } [PROOFSTEP] assumption [GOAL] case h.tail.head cd : Fin 2 → ℝ z : ℍ this : cd 0 = 0 h : cd 1 = 0 ⊢ cd { val := 1, isLt := (_ : (fun a => a < 2) 1) } = OfNat.ofNat 0 { val := 1, isLt := (_ : (fun a => a < 2) 1) } [PROOFSTEP] assumption [GOAL] g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ denom g z ≠ 0 [PROOFSTEP] intro H [GOAL] g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ H : denom g z = 0 ⊢ False [PROOFSTEP] have DET := (mem_glpos _).1 g.prop [GOAL] g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ H : denom g z = 0 DET : 0 < ↑(↑GeneralLinearGroup.det ↑g) ⊢ False [PROOFSTEP] have hz := z.prop [GOAL] g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ H : denom g z = 0 DET : 0 < ↑(↑GeneralLinearGroup.det ↑g) hz : 0 < (↑z).im ⊢ False [PROOFSTEP] simp only [GeneralLinearGroup.det_apply_val] at DET [GOAL] g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ H : denom g z = 0 DET : 0 < det ↑↑g hz : 0 < (↑z).im ⊢ False [PROOFSTEP] have H1 : (↑ₘg 1 0 : ℝ) = 0 ∨ z.im = 0 := by simpa [num, denom] using congr_arg Complex.im H [GOAL] g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ H : denom g z = 0 DET : 0 < det ↑↑g hz : 0 < (↑z).im ⊢ ↑↑g 1 0 = 0 ∨ im z = 0 [PROOFSTEP] simpa [num, denom] using congr_arg Complex.im H [GOAL] g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ H : denom g z = 0 DET : 0 < det ↑↑g hz : 0 < (↑z).im H1 : ↑↑g 1 0 = 0 ∨ im z = 0 ⊢ False [PROOFSTEP] cases' H1 with H1 [GOAL] case inl g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ H : denom g z = 0 DET : 0 < det ↑↑g hz : 0 < (↑z).im H1 : ↑↑g 1 0 = 0 ⊢ False [PROOFSTEP] simp only [H1, Complex.ofReal_zero, denom, zero_mul, zero_add, Complex.ofReal_eq_zero] at H [GOAL] case inl g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ DET : 0 < det ↑↑g hz : 0 < (↑z).im H1 : ↑↑g 1 0 = 0 H : ↑↑g 1 1 = 0 ⊢ False [PROOFSTEP] rw [Matrix.det_fin_two (↑ₘg : Matrix (Fin 2) (Fin 2) ℝ)] at DET [GOAL] case inl g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ DET : 0 < ↑↑g 0 0 * ↑↑g 1 1 - ↑↑g 0 1 * ↑↑g 1 0 hz : 0 < (↑z).im H1 : ↑↑g 1 0 = 0 H : ↑↑g 1 1 = 0 ⊢ False [PROOFSTEP] simp only [H, H1, mul_zero, sub_zero, lt_self_iff_false] at DET [GOAL] case inr g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ H : denom g z = 0 DET : 0 < det ↑↑g hz : 0 < (↑z).im h✝ : im z = 0 ⊢ False [PROOFSTEP] change z.im > 0 at hz [GOAL] case inr g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ H : denom g z = 0 DET : 0 < det ↑↑g h✝ : im z = 0 hz : im z > 0 ⊢ False [PROOFSTEP] linarith [GOAL] g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ (smulAux' g z).im = det ↑↑g * im z / ↑Complex.normSq (denom g z) [PROOFSTEP] rw [smulAux', Complex.div_im] [GOAL] g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ (num g z).im * (denom g z).re / ↑Complex.normSq (denom g z) - (num g z).re * (denom g z).im / ↑Complex.normSq (denom g z) = det ↑↑g * im z / ↑Complex.normSq (denom g z) [PROOFSTEP] field_simp [smulAux', num, denom] -- porting note: the local notation still didn't work here [GOAL] g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ ↑↑g 0 0 * im z * (↑↑g 1 0 * re z + ↑↑g 1 1) / ↑Complex.normSq (↑(↑↑g 1 0) * ↑z + ↑(↑↑g 1 1)) - (↑↑g 0 0 * re z + ↑↑g 0 1) * (↑↑g 1 0 * im z) / ↑Complex.normSq (↑(↑↑g 1 0) * ↑z + ↑(↑↑g 1 1)) = det ↑↑g * im z / ↑Complex.normSq (↑(↑↑g 1 0) * ↑z + ↑(↑↑g 1 1)) [PROOFSTEP] rw [Matrix.det_fin_two ((g : GL (Fin 2) ℝ) : Matrix (Fin 2) (Fin 2) ℝ)] [GOAL] g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ ↑↑g 0 0 * im z * (↑↑g 1 0 * re z + ↑↑g 1 1) / ↑Complex.normSq (↑(↑↑g 1 0) * ↑z + ↑(↑↑g 1 1)) - (↑↑g 0 0 * re z + ↑↑g 0 1) * (↑↑g 1 0 * im z) / ↑Complex.normSq (↑(↑↑g 1 0) * ↑z + ↑(↑↑g 1 1)) = (↑↑g 0 0 * ↑↑g 1 1 - ↑↑g 0 1 * ↑↑g 1 0) * im z / ↑Complex.normSq (↑(↑↑g 1 0) * ↑z + ↑(↑↑g 1 1)) [PROOFSTEP] ring [GOAL] g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ 0 < (smulAux' g z).im [PROOFSTEP] rw [smulAux'_im] [GOAL] g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ 0 < det ↑↑g * im z / ↑Complex.normSq (denom g z) [PROOFSTEP] convert mul_pos ((mem_glpos _).1 g.prop) (div_pos z.im_pos (Complex.normSq_pos.mpr (denom_ne_zero g z))) using 1 [GOAL] case h.e'_4 g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ det ↑↑g * im z / ↑Complex.normSq (denom g z) = ↑(↑GeneralLinearGroup.det ↑g) * (im z / ↑Complex.normSq (denom g z)) [PROOFSTEP] simp only [GeneralLinearGroup.det_apply_val] [GOAL] case h.e'_4 g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ det ↑↑g * im z / ↑Complex.normSq (denom g z) = det ↑↑g * (im z / ↑Complex.normSq (denom g z)) [PROOFSTEP] ring [GOAL] x y : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ denom (x * y) z = denom x (smulAux y z) * denom y z [PROOFSTEP] change _ = (_ * (_ / _) + _) * _ [GOAL] x y : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ denom (x * y) z = (↑(↑↑x 1 0) * (num y z / denom y z) + ↑(↑↑x 1 1)) * denom y z [PROOFSTEP] field_simp [denom_ne_zero] [GOAL] x y : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ denom (x * y) z = ↑(↑↑x 1 0) * num y z + ↑(↑↑x 1 1) * denom y z [PROOFSTEP] simp only [Matrix.mul_apply, dotProduct, Fin.sum_univ_succ, denom, num, Subgroup.coe_mul, GeneralLinearGroup.coe_mul, Fintype.univ_ofSubsingleton, Fin.mk_zero, Finset.sum_singleton, Fin.succ_zero_eq_one, Complex.ofReal_add, Complex.ofReal_mul] [GOAL] x y : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ (↑(↑↑x 1 0) * ↑(↑↑y 0 0) + ↑(↑↑x 1 1) * ↑(↑↑y 1 0)) * ↑z + (↑(↑↑x 1 0) * ↑(↑↑y 0 1) + ↑(↑↑x 1 1) * ↑(↑↑y 1 1)) = ↑(↑↑x 1 0) * (↑(↑↑y 0 0) * ↑z + ↑(↑↑y 0 1)) + ↑(↑↑x 1 1) * (↑(↑↑y 1 0) * ↑z + ↑(↑↑y 1 1)) [PROOFSTEP] ring [GOAL] x y : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ smulAux (x * y) z = smulAux x (smulAux y z) [PROOFSTEP] ext1 -- Porting note: was `change _ / _ = (_ * (_ / _) + _) * _` [GOAL] case h x y : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ ↑(smulAux (x * y) z) = ↑(smulAux x (smulAux y z)) [PROOFSTEP] change _ / _ = (_ * (_ / _) + _) / _ [GOAL] case h x y : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ num (x * y) z / denom (x * y) z = (↑(↑↑x 0 0) * (num y z / denom y z) + ↑(↑↑x 0 1)) / denom x (smulAux y z) [PROOFSTEP] rw [denom_cocycle] [GOAL] case h x y : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ num (x * y) z / (denom x (smulAux y z) * denom y z) = (↑(↑↑x 0 0) * (num y z / denom y z) + ↑(↑↑x 0 1)) / denom x (smulAux y z) [PROOFSTEP] field_simp [denom_ne_zero] [GOAL] case h x y : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ num (x * y) z * (denom y z * denom x (smulAux y z)) = (↑(↑↑x 0 0) * num y z + ↑(↑↑x 0 1) * denom y z) * (denom x (smulAux y z) * denom y z) [PROOFSTEP] simp only [Matrix.mul_apply, dotProduct, Fin.sum_univ_succ, num, denom, Subgroup.coe_mul, GeneralLinearGroup.coe_mul, Fintype.univ_ofSubsingleton, Fin.mk_zero, Finset.sum_singleton, Fin.succ_zero_eq_one, Complex.ofReal_add, Complex.ofReal_mul] [GOAL] case h x y : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ ((↑(↑↑x 0 0) * ↑(↑↑y 0 0) + ↑(↑↑x 0 1) * ↑(↑↑y 1 0)) * ↑z + (↑(↑↑x 0 0) * ↑(↑↑y 0 1) + ↑(↑↑x 0 1) * ↑(↑↑y 1 1))) * ((↑(↑↑y 1 0) * ↑z + ↑(↑↑y 1 1)) * (↑(↑↑x 1 0) * ↑(smulAux y z) + ↑(↑↑x 1 1))) = (↑(↑↑x 0 0) * (↑(↑↑y 0 0) * ↑z + ↑(↑↑y 0 1)) + ↑(↑↑x 0 1) * (↑(↑↑y 1 0) * ↑z + ↑(↑↑y 1 1))) * ((↑(↑↑x 1 0) * ↑(smulAux y z) + ↑(↑↑x 1 1)) * (↑(↑↑y 1 0) * ↑z + ↑(↑↑y 1 1))) [PROOFSTEP] ring [GOAL] z : ℍ ⊢ 1 • z = z [PROOFSTEP] ext1 [GOAL] case h z : ℍ ⊢ ↑(1 • z) = ↑z [PROOFSTEP] change _ / _ = _ [GOAL] case h z : ℍ ⊢ num 1 z / denom 1 z = ↑z [PROOFSTEP] simp [num, denom] [GOAL] Γ : Subgroup SL(2, ℤ) g : SL(2, ℤ) ⊢ det ↑↑↑g = 1 [PROOFSTEP] simp only [SpecialLinearGroup.coe_GLPos_coe_GL_coe_matrix, SpecialLinearGroup.det_coe, coe'] [GOAL] Γ : Subgroup SL(2, ℤ) ⊢ ∀ (x : SL(2, ℤ)) (y : { x // x ∈ GL(2, ℝ)⁺ }) (z : ℍ), (x • y) • z = x • y • z [PROOFSTEP] intro s g z [GOAL] Γ : Subgroup SL(2, ℤ) s : SL(2, ℤ) g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ (s • g) • z = s • g • z [PROOFSTEP] simp only [SLOnGLPos_smul_apply] [GOAL] Γ : Subgroup SL(2, ℤ) s : SL(2, ℤ) g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ (↑s * g) • z = s • g • z [PROOFSTEP] apply mul_smul' [GOAL] Γ : Subgroup SL(2, ℤ) ⊢ ∀ (x : { x // x ∈ Γ }) (y : { x // x ∈ GL(2, ℝ)⁺ }) (z : ℍ), (x • y) • z = x • y • z [PROOFSTEP] intro s g z [GOAL] Γ : Subgroup SL(2, ℤ) s : { x // x ∈ Γ } g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ (s • g) • z = s • g • z [PROOFSTEP] simp only [subgroup_on_glpos_smul_apply] [GOAL] Γ : Subgroup SL(2, ℤ) s : { x // x ∈ Γ } g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ (↑↑s * g) • z = s • g • z [PROOFSTEP] apply mul_smul' [GOAL] Γ : Subgroup SL(2, ℤ) s : { x // x ∈ Γ } g : SL(2, ℤ) z : ℍ ⊢ (s • g) • z = s • g • z [PROOFSTEP] rw [subgroup_on_SL_apply] [GOAL] Γ : Subgroup SL(2, ℤ) s : { x // x ∈ Γ } g : SL(2, ℤ) z : ℍ ⊢ (↑s * g) • z = s • g • z [PROOFSTEP] apply MulAction.mul_smul [GOAL] g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ -g • z = g • z [PROOFSTEP] ext1 [GOAL] case h g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ ↑(-g • z) = ↑(g • z) [PROOFSTEP] change _ / _ = _ / _ [GOAL] case h g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ num (-g) z / denom (-g) z = num g z / denom g z [PROOFSTEP] field_simp [denom_ne_zero] [GOAL] case h g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ num (-g) z * denom g z = num g z * denom (-g) z [PROOFSTEP] simp only [num, denom, Complex.ofReal_neg, neg_mul, GLPos.coe_neg_GL, Units.val_neg, neg_apply] [GOAL] case h g : { x // x ∈ GL(2, ℝ)⁺ } z : ℍ ⊢ (-(↑(↑↑g 0 0) * ↑z) + -↑(↑↑g 0 1)) * (↑(↑↑g 1 0) * ↑z + ↑(↑↑g 1 1)) = (↑(↑↑g 0 0) * ↑z + ↑(↑↑g 0 1)) * (-(↑(↑↑g 1 0) * ↑z) + -↑(↑↑g 1 1)) [PROOFSTEP] ring_nf [GOAL] g✝ : SL(2, ℤ) z✝ : ℍ Γ : Subgroup SL(2, ℤ) g : SL(2, ℤ) z : ℍ ⊢ -g • z = g • z [PROOFSTEP] simp only [coe_GLPos_neg, sl_moeb, coe_int_neg, neg_smul, coe'] [GOAL] g✝ : SL(2, ℤ) z✝ : ℍ Γ : Subgroup SL(2, ℤ) z : ℍ g : SL(2, ℝ) ⊢ (↑↑(↑toGLPos g) 1 0 * im z) ^ 2 ≤ ↑Complex.normSq (denom (↑toGLPos g) z) [PROOFSTEP] let c := (↑ₘg 1 0 : ℝ) [GOAL] g✝ : SL(2, ℤ) z✝ : ℍ Γ : Subgroup SL(2, ℤ) z : ℍ g : SL(2, ℝ) c : ℝ := ↑↑(↑toGLPos g) 1 0 ⊢ (↑↑(↑toGLPos g) 1 0 * im z) ^ 2 ≤ ↑Complex.normSq (denom (↑toGLPos g) z) [PROOFSTEP] let d := (↑ₘg 1 1 : ℝ) [GOAL] g✝ : SL(2, ℤ) z✝ : ℍ Γ : Subgroup SL(2, ℤ) z : ℍ g : SL(2, ℝ) c : ℝ := ↑↑(↑toGLPos g) 1 0 d : ℝ := ↑↑(↑toGLPos g) 1 1 ⊢ (↑↑(↑toGLPos g) 1 0 * im z) ^ 2 ≤ ↑Complex.normSq (denom (↑toGLPos g) z) [PROOFSTEP] calc (c * z.im) ^ 2 ≤ (c * z.im) ^ 2 + (c * z.re + d) ^ 2 := by nlinarith _ = Complex.normSq (denom g z) := by dsimp [denom, Complex.normSq]; ring [GOAL] g✝ : SL(2, ℤ) z✝ : ℍ Γ : Subgroup SL(2, ℤ) z : ℍ g : SL(2, ℝ) c : ℝ := ↑↑(↑toGLPos g) 1 0 d : ℝ := ↑↑(↑toGLPos g) 1 1 ⊢ (c * im z) ^ 2 ≤ (c * im z) ^ 2 + (c * re z + d) ^ 2 [PROOFSTEP] nlinarith [GOAL] g✝ : SL(2, ℤ) z✝ : ℍ Γ : Subgroup SL(2, ℤ) z : ℍ g : SL(2, ℝ) c : ℝ := ↑↑(↑toGLPos g) 1 0 d : ℝ := ↑↑(↑toGLPos g) 1 1 ⊢ (c * im z) ^ 2 + (c * re z + d) ^ 2 = ↑Complex.normSq (denom (↑toGLPos g) z) [PROOFSTEP] dsimp [denom, Complex.normSq] [GOAL] g✝ : SL(2, ℤ) z✝ : ℍ Γ : Subgroup SL(2, ℤ) z : ℍ g : SL(2, ℝ) c : ℝ := ↑↑(↑toGLPos g) 1 0 d : ℝ := ↑↑(↑toGLPos g) 1 1 ⊢ (↑g 1 0 * im z) ^ 2 + (↑g 1 0 * re z + ↑g 1 1) ^ 2 = (↑g 1 0 * re z - 0 * im z + ↑g 1 1) * (↑g 1 0 * re z - 0 * im z + ↑g 1 1) + (↑g 1 0 * im z + 0 * re z + 0) * (↑g 1 0 * im z + 0 * re z + 0) [PROOFSTEP] ring [GOAL] g : SL(2, ℤ) z : ℍ Γ : Subgroup SL(2, ℤ) ⊢ im (g • z) = im z / ↑Complex.normSq (denom (↑g) z) [PROOFSTEP] convert im_smul_eq_div_normSq g z [GOAL] case h.e'_3.h.e'_5 g : SL(2, ℤ) z : ℍ Γ : Subgroup SL(2, ℤ) ⊢ im z = det ↑↑↑g * im z [PROOFSTEP] simp only [GeneralLinearGroup.det_apply_val, coe_GLPos_coe_GL_coe_matrix, Int.coe_castRingHom, (g : SL(2, ℝ)).prop, one_mul, coe'] [GOAL] g✝ : SL(2, ℤ) z✝ : ℍ Γ : Subgroup SL(2, ℤ) g : SL(2, ℤ) z : ℍ ⊢ denom (↑g) z = ↑(↑g 1 0) * ↑z + ↑(↑g 1 1) [PROOFSTEP] simp [denom, coe'] [GOAL] x : { x // 0 < x } z : ℍ ⊢ 0 < (↑x • ↑z).im [PROOFSTEP] simpa using mul_pos x.2 z.2 [GOAL] x : ℝ z : ℍ ⊢ 0 < (↑x + ↑z).im [PROOFSTEP] simpa using z.im_pos [GOAL] x✝ : ℍ ⊢ ↑(0 +ᵥ x✝) = ↑x✝ [PROOFSTEP] simp [HVAdd.hVAdd] [GOAL] x y : ℝ z : ℍ ⊢ ↑(x + y +ᵥ z) = ↑(x +ᵥ (y +ᵥ z)) [PROOFSTEP] simp [HVAdd.hVAdd, add_assoc] [GOAL] z : ℍ ⊢ ModularGroup.S • z = mk (-↑z)⁻¹ (_ : 0 < (-↑z)⁻¹.im) [PROOFSTEP] rw [specialLinearGroup_apply] [GOAL] z : ℍ ⊢ mk ((↑(↑(algebraMap ℤ ℝ) (↑↑ModularGroup.S 0 0)) * ↑z + ↑(↑(algebraMap ℤ ℝ) (↑↑ModularGroup.S 0 1))) / (↑(↑(algebraMap ℤ ℝ) (↑↑ModularGroup.S 1 0)) * ↑z + ↑(↑(algebraMap ℤ ℝ) (↑↑ModularGroup.S 1 1)))) (_ : 0 < (↑(ModularGroup.S • z)).im) = mk (-↑z)⁻¹ (_ : 0 < (-↑z)⁻¹.im) [PROOFSTEP] simp [ModularGroup.S, neg_div, inv_neg, coeToGL] [GOAL] z : ℍ n : ℤ ⊢ ModularGroup.T ^ n • z = ↑n +ᵥ z [PROOFSTEP] rw [← ext_iff, coe_vadd, add_comm, specialLinearGroup_apply, coe_mk] -- Porting note: added `coeToGL` and merged `rw` and `simp` [GOAL] z : ℍ n : ℤ ⊢ (↑(↑(algebraMap ℤ ℝ) (↑↑(ModularGroup.T ^ n) 0 0)) * ↑z + ↑(↑(algebraMap ℤ ℝ) (↑↑(ModularGroup.T ^ n) 0 1))) / (↑(↑(algebraMap ℤ ℝ) (↑↑(ModularGroup.T ^ n) 1 0)) * ↑z + ↑(↑(algebraMap ℤ ℝ) (↑↑(ModularGroup.T ^ n) 1 1))) = ↑z + ↑↑n [PROOFSTEP] simp [coeToGL, ModularGroup.coe_T_zpow, of_apply, cons_val_zero, algebraMap.coe_one, Complex.ofReal_one, one_mul, cons_val_one, head_cons, algebraMap.coe_zero, zero_mul, zero_add, div_one] [GOAL] z : ℍ ⊢ ModularGroup.T • z = 1 +ᵥ z [PROOFSTEP] simpa only [Int.cast_one] using modular_T_zpow_smul z 1 [GOAL] g : SL(2, ℝ) hc : ↑↑g 1 0 = 0 ⊢ ∃ u v, (fun x x_1 => x • x_1) g = (fun z => v +ᵥ z) ∘ fun z => u • z [PROOFSTEP] obtain ⟨a, b, ha, rfl⟩ := g.fin_two_exists_eq_mk_of_apply_zero_one_eq_zero hc [GOAL] case intro.intro.intro a b : ℝ ha : a ≠ 0 hc : ↑↑{ val := ↑of ![![a, b], ![0, a⁻¹]], property := (_ : det (↑of ![![a, b], ![0, a⁻¹]]) = 1) } 1 0 = 0 ⊢ ∃ u v, (fun x x_1 => x • x_1) { val := ↑of ![![a, b], ![0, a⁻¹]], property := (_ : det (↑of ![![a, b], ![0, a⁻¹]]) = 1) } = (fun z => v +ᵥ z) ∘ fun z => u • z [PROOFSTEP] refine' ⟨⟨_, mul_self_pos.mpr ha⟩, b * a, _⟩ [GOAL] case intro.intro.intro a b : ℝ ha : a ≠ 0 hc : ↑↑{ val := ↑of ![![a, b], ![0, a⁻¹]], property := (_ : det (↑of ![![a, b], ![0, a⁻¹]]) = 1) } 1 0 = 0 ⊢ (fun x x_1 => x • x_1) { val := ↑of ![![a, b], ![0, a⁻¹]], property := (_ : det (↑of ![![a, b], ![0, a⁻¹]]) = 1) } = (fun z => b * a +ᵥ z) ∘ fun z => { val := a * a, property := (_ : 0 < a * a) } • z [PROOFSTEP] ext1 ⟨z, hz⟩ [GOAL] case intro.intro.intro.h.mk a b : ℝ ha : a ≠ 0 hc : ↑↑{ val := ↑of ![![a, b], ![0, a⁻¹]], property := (_ : det (↑of ![![a, b], ![0, a⁻¹]]) = 1) } 1 0 = 0 z : ℂ hz : 0 < z.im ⊢ (fun x x_1 => x • x_1) { val := ↑of ![![a, b], ![0, a⁻¹]], property := (_ : det (↑of ![![a, b], ![0, a⁻¹]]) = 1) } { val := z, property := hz } = ((fun z => b * a +ᵥ z) ∘ fun z => { val := a * a, property := (_ : 0 < a * a) } • z) { val := z, property := hz } [PROOFSTEP] ext1 [GOAL] case intro.intro.intro.h.mk.h a b : ℝ ha : a ≠ 0 hc : ↑↑{ val := ↑of ![![a, b], ![0, a⁻¹]], property := (_ : det (↑of ![![a, b], ![0, a⁻¹]]) = 1) } 1 0 = 0 z : ℂ hz : 0 < z.im ⊢ ↑((fun x x_1 => x • x_1) { val := ↑of ![![a, b], ![0, a⁻¹]], property := (_ : det (↑of ![![a, b], ![0, a⁻¹]]) = 1) } { val := z, property := hz }) = ↑(((fun z => b * a +ᵥ z) ∘ fun z => { val := a * a, property := (_ : 0 < a * a) } • z) { val := z, property := hz }) [PROOFSTEP] suffices ↑a * z * a + b * a = b * a + a * a * z by -- Porting note: added `coeToGL` and merged `rw` and `simpa`simpa [coeToGL, specialLinearGroup_apply, add_mul] [GOAL] a b : ℝ ha : a ≠ 0 hc : ↑↑{ val := ↑of ![![a, b], ![0, a⁻¹]], property := (_ : det (↑of ![![a, b], ![0, a⁻¹]]) = 1) } 1 0 = 0 z : ℂ hz : 0 < z.im this : ↑a * z * ↑a + ↑b * ↑a = ↑b * ↑a + ↑a * ↑a * z ⊢ ↑((fun x x_1 => x • x_1) { val := ↑of ![![a, b], ![0, a⁻¹]], property := (_ : det (↑of ![![a, b], ![0, a⁻¹]]) = 1) } { val := z, property := hz }) = ↑(((fun z => b * a +ᵥ z) ∘ fun z => { val := a * a, property := (_ : 0 < a * a) } • z) { val := z, property := hz }) [PROOFSTEP] simpa [coeToGL, specialLinearGroup_apply, add_mul] [GOAL] case intro.intro.intro.h.mk.h a b : ℝ ha : a ≠ 0 hc : ↑↑{ val := ↑of ![![a, b], ![0, a⁻¹]], property := (_ : det (↑of ![![a, b], ![0, a⁻¹]]) = 1) } 1 0 = 0 z : ℂ hz : 0 < z.im ⊢ ↑a * z * ↑a + ↑b * ↑a = ↑b * ↑a + ↑a * ↑a * z [PROOFSTEP] ring [GOAL] g : SL(2, ℝ) hc : ↑↑g 1 0 ≠ 0 ⊢ ∃ u v w, (fun x x_1 => x • x_1) g = (fun x x_1 => x +ᵥ x_1) w ∘ (fun x x_1 => x • x_1) ModularGroup.S ∘ (fun x x_1 => x +ᵥ x_1) v ∘ (fun x x_1 => x • x_1) u [PROOFSTEP] have h_denom := denom_ne_zero g [GOAL] g : SL(2, ℝ) hc : ↑↑g 1 0 ≠ 0 h_denom : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 ⊢ ∃ u v w, (fun x x_1 => x • x_1) g = (fun x x_1 => x +ᵥ x_1) w ∘ (fun x x_1 => x • x_1) ModularGroup.S ∘ (fun x x_1 => x +ᵥ x_1) v ∘ (fun x x_1 => x • x_1) u [PROOFSTEP] induction' g using Matrix.SpecialLinearGroup.fin_two_induction with a b c d h [GOAL] case h g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 hc : ↑↑{ val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) } 1 0 ≠ 0 h_denom : ∀ (z : ℍ), denom (↑toGLPos { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) }) z ≠ 0 ⊢ ∃ u v w, (fun x x_1 => x • x_1) { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) } = (fun x x_1 => x +ᵥ x_1) w ∘ (fun x x_1 => x • x_1) ModularGroup.S ∘ (fun x x_1 => x +ᵥ x_1) v ∘ (fun x x_1 => x • x_1) u [PROOFSTEP] replace hc : c ≠ 0 [GOAL] case hc g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 hc : ↑↑{ val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) } 1 0 ≠ 0 h_denom : ∀ (z : ℍ), denom (↑toGLPos { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) }) z ≠ 0 ⊢ c ≠ 0 [PROOFSTEP] simpa using hc [GOAL] case h g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 h_denom : ∀ (z : ℍ), denom (↑toGLPos { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) }) z ≠ 0 hc : c ≠ 0 ⊢ ∃ u v w, (fun x x_1 => x • x_1) { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) } = (fun x x_1 => x +ᵥ x_1) w ∘ (fun x x_1 => x • x_1) ModularGroup.S ∘ (fun x x_1 => x +ᵥ x_1) v ∘ (fun x x_1 => x • x_1) u [PROOFSTEP] refine' ⟨⟨_, mul_self_pos.mpr hc⟩, c * d, a / c, _⟩ [GOAL] case h g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 h_denom : ∀ (z : ℍ), denom (↑toGLPos { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) }) z ≠ 0 hc : c ≠ 0 ⊢ (fun x x_1 => x • x_1) { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) } = (fun x x_1 => x +ᵥ x_1) (a / c) ∘ (fun x x_1 => x • x_1) ModularGroup.S ∘ (fun x x_1 => x +ᵥ x_1) (c * d) ∘ (fun x x_1 => x • x_1) { val := c * c, property := (_ : 0 < c * c) } [PROOFSTEP] ext1 ⟨z, hz⟩ [GOAL] case h.h.mk g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 h_denom : ∀ (z : ℍ), denom (↑toGLPos { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) }) z ≠ 0 hc : c ≠ 0 z : ℂ hz : 0 < z.im ⊢ (fun x x_1 => x • x_1) { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) } { val := z, property := hz } = ((fun x x_1 => x +ᵥ x_1) (a / c) ∘ (fun x x_1 => x • x_1) ModularGroup.S ∘ (fun x x_1 => x +ᵥ x_1) (c * d) ∘ (fun x x_1 => x • x_1) { val := c * c, property := (_ : 0 < c * c) }) { val := z, property := hz } [PROOFSTEP] ext1 [GOAL] case h.h.mk.h g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 h_denom : ∀ (z : ℍ), denom (↑toGLPos { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) }) z ≠ 0 hc : c ≠ 0 z : ℂ hz : 0 < z.im ⊢ ↑((fun x x_1 => x • x_1) { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) } { val := z, property := hz }) = ↑(((fun x x_1 => x +ᵥ x_1) (a / c) ∘ (fun x x_1 => x • x_1) ModularGroup.S ∘ (fun x x_1 => x +ᵥ x_1) (c * d) ∘ (fun x x_1 => x • x_1) { val := c * c, property := (_ : 0 < c * c) }) { val := z, property := hz }) [PROOFSTEP] suffices (↑a * z + b) / (↑c * z + d) = a / c - (c * d + ↑c * ↑c * z)⁻¹ by -- Porting note: golfed broken proofsimpa only [modular_S_smul, inv_neg, Function.comp_apply, coe_vadd, Complex.ofReal_mul, coe_pos_real_smul, Complex.real_smul, Complex.ofReal_div, coe_mk] [GOAL] g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 h_denom : ∀ (z : ℍ), denom (↑toGLPos { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) }) z ≠ 0 hc : c ≠ 0 z : ℂ hz : 0 < z.im this : (↑a * z + ↑b) / (↑c * z + ↑d) = ↑a / ↑c - (↑c * ↑d + ↑c * ↑c * z)⁻¹ ⊢ ↑((fun x x_1 => x • x_1) { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) } { val := z, property := hz }) = ↑(((fun x x_1 => x +ᵥ x_1) (a / c) ∘ (fun x x_1 => x • x_1) ModularGroup.S ∘ (fun x x_1 => x +ᵥ x_1) (c * d) ∘ (fun x x_1 => x • x_1) { val := c * c, property := (_ : 0 < c * c) }) { val := z, property := hz }) [PROOFSTEP] simpa only [modular_S_smul, inv_neg, Function.comp_apply, coe_vadd, Complex.ofReal_mul, coe_pos_real_smul, Complex.real_smul, Complex.ofReal_div, coe_mk] [GOAL] case h.h.mk.h g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 h_denom : ∀ (z : ℍ), denom (↑toGLPos { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) }) z ≠ 0 hc : c ≠ 0 z : ℂ hz : 0 < z.im ⊢ (↑a * z + ↑b) / (↑c * z + ↑d) = ↑a / ↑c - (↑c * ↑d + ↑c * ↑c * z)⁻¹ [PROOFSTEP] replace hc : (c : ℂ) ≠ 0 [GOAL] case hc g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 h_denom : ∀ (z : ℍ), denom (↑toGLPos { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) }) z ≠ 0 hc : c ≠ 0 z : ℂ hz : 0 < z.im ⊢ ↑c ≠ 0 [PROOFSTEP] norm_cast [GOAL] case h.h.mk.h g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 h_denom : ∀ (z : ℍ), denom (↑toGLPos { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) }) z ≠ 0 z : ℂ hz : 0 < z.im hc : ↑c ≠ 0 ⊢ (↑a * z + ↑b) / (↑c * z + ↑d) = ↑a / ↑c - (↑c * ↑d + ↑c * ↑c * z)⁻¹ [PROOFSTEP] replace h_denom : ↑c * z + d ≠ 0 [GOAL] case h_denom g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 h_denom : ∀ (z : ℍ), denom (↑toGLPos { val := ↑of ![![a, b], ![c, d]], property := (_ : det (↑of ![![a, b], ![c, d]]) = 1) }) z ≠ 0 z : ℂ hz : 0 < z.im hc : ↑c ≠ 0 ⊢ ↑c * z + ↑d ≠ 0 [PROOFSTEP] simpa using h_denom ⟨z, hz⟩ [GOAL] case h.h.mk.h g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 z : ℂ hz : 0 < z.im hc : ↑c ≠ 0 h_denom : ↑c * z + ↑d ≠ 0 ⊢ (↑a * z + ↑b) / (↑c * z + ↑d) = ↑a / ↑c - (↑c * ↑d + ↑c * ↑c * z)⁻¹ [PROOFSTEP] have h_aux : (c : ℂ) * d + ↑c * ↑c * z ≠ 0 := by rw [mul_assoc, ← mul_add, add_comm] exact mul_ne_zero hc h_denom [GOAL] g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 z : ℂ hz : 0 < z.im hc : ↑c ≠ 0 h_denom : ↑c * z + ↑d ≠ 0 ⊢ ↑c * ↑d + ↑c * ↑c * z ≠ 0 [PROOFSTEP] rw [mul_assoc, ← mul_add, add_comm] [GOAL] g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 z : ℂ hz : 0 < z.im hc : ↑c ≠ 0 h_denom : ↑c * z + ↑d ≠ 0 ⊢ ↑c * (↑c * z + ↑d) ≠ 0 [PROOFSTEP] exact mul_ne_zero hc h_denom [GOAL] case h.h.mk.h g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 z : ℂ hz : 0 < z.im hc : ↑c ≠ 0 h_denom : ↑c * z + ↑d ≠ 0 h_aux : ↑c * ↑d + ↑c * ↑c * z ≠ 0 ⊢ (↑a * z + ↑b) / (↑c * z + ↑d) = ↑a / ↑c - (↑c * ↑d + ↑c * ↑c * z)⁻¹ [PROOFSTEP] replace h : (a * d - b * c : ℂ) = (1 : ℂ) [GOAL] case h g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ h : a * d - b * c = 1 z : ℂ hz : 0 < z.im hc : ↑c ≠ 0 h_denom : ↑c * z + ↑d ≠ 0 h_aux : ↑c * ↑d + ↑c * ↑c * z ≠ 0 ⊢ ↑a * ↑d - ↑b * ↑c = 1 [PROOFSTEP] norm_cast [GOAL] case h.h.mk.h g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ z : ℂ hz : 0 < z.im hc : ↑c ≠ 0 h_denom : ↑c * z + ↑d ≠ 0 h_aux : ↑c * ↑d + ↑c * ↑c * z ≠ 0 h : ↑a * ↑d - ↑b * ↑c = 1 ⊢ (↑a * z + ↑b) / (↑c * z + ↑d) = ↑a / ↑c - (↑c * ↑d + ↑c * ↑c * z)⁻¹ [PROOFSTEP] field_simp [GOAL] case h.h.mk.h g : SL(2, ℝ) hc✝ : ↑↑g 1 0 ≠ 0 h_denom✝ : ∀ (z : ℍ), denom (↑toGLPos g) z ≠ 0 a b c d : ℝ z : ℂ hz : 0 < z.im hc : ↑c ≠ 0 h_denom : ↑c * z + ↑d ≠ 0 h_aux : ↑c * ↑d + ↑c * ↑c * z ≠ 0 h : ↑a * ↑d - ↑b * ↑c = 1 ⊢ (↑a * z + ↑b) * (↑c * (↑c * ↑d + ↑c * ↑c * z)) = (↑a * (↑c * ↑d + ↑c * ↑c * z) - ↑c) * (↑c * z + ↑d) [PROOFSTEP] linear_combination (-(z * (c : ℂ) ^ 2) - c * d) * h
-- This file is the source Agda file -- Edit this file not Type.hs -- The warning below will be written to Type.hs module PlutusCore.Generators.NEAT.Type where -- warning to be written to Haskell file: {-# FOREIGN AGDA2HS {- !!! THIS FILE IS GENERATED FROM Type.agda !!! DO NOT EDIT THIS FILE. EDIT Type.agda !!! AND THEN RUN agda2hs ON IT. -} #-} {-# FOREIGN AGDA2HS {-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE StandaloneDeriving #-} import Control.Enumerable import Control.Monad.Except import PlutusCore import PlutusCore.Generators.NEAT.Common #-} open import Relation.Binary.PropositionalEquality open import Haskell.Prelude hiding (m) open import PlutusCore.Generators.NEAT.Common {-# FOREIGN AGDA2HS newtype Neutral a = Neutral { unNeutral :: a } #-} -- * Enumeration -- ** Enumerating types data TypeBuiltinG : Set where TyByteStringG : TypeBuiltinG TyIntegerG : TypeBuiltinG TyBoolG : TypeBuiltinG TyUnitG : TypeBuiltinG TyStringG : TypeBuiltinG TyListG : TypeBuiltinG TyDataG : TypeBuiltinG {-# COMPILE AGDA2HS TypeBuiltinG deriving (Show, Eq, Ord) #-} {-# FOREIGN AGDA2HS deriveEnumerable ''TypeBuiltinG #-} -- NOTE: Unusually, the application case is annotated with a kind. -- The reason is eagerness and efficiency. If we have the kind -- information at the application site, we can check the two -- subterms in parallel, while evaluating as little as possible. variable n m o : Set postulate Kind : Set → Set data TypeG (n : Set) : Set where TyVarG : n → TypeG n TyFunG : TypeG n → TypeG n → TypeG n TyIFixG : TypeG n → Kind ⊤ → TypeG n → TypeG n TyForallG : Kind ⊤ → TypeG (S n) → TypeG n TyBuiltinG : TypeBuiltinG → TypeG n TyLamG : TypeG (S n) → TypeG n TyAppG : TypeG n → TypeG n → Kind ⊤ → TypeG n {-# COMPILE AGDA2HS TypeG deriving (Eq, Ord, Show) #-} {-# FOREIGN AGDA2HS deriving instance Ord (Kind ()) deriveEnumerable ''Kind deriveEnumerable ''TypeG type ClosedTypeG = TypeG Z instance Functor TypeG where fmap = ren #-} ext : (m → n) → S m → S n ext _ FZ = FZ ext f (FS x) = FS (f x) {-# COMPILE AGDA2HS ext #-} ren : (m → n) → TypeG m → TypeG n ren f (TyVarG x) = TyVarG (f x) ren f (TyFunG ty1 ty2) = TyFunG (ren f ty1) (ren f ty2) ren f (TyIFixG ty1 k ty2) = TyIFixG (ren f ty1) k (ren f ty2) ren f (TyForallG k ty) = TyForallG k (ren (ext f) ty) ren _ (TyBuiltinG b) = TyBuiltinG b ren f (TyLamG ty) = TyLamG (ren (ext f) ty) ren f (TyAppG ty1 ty2 k) = TyAppG (ren f ty1) (ren f ty2) k {-# COMPILE AGDA2HS ren #-} ext-cong : {ρ ρ' : m → n} → (∀ x → ρ x ≡ ρ' x) → ∀ x → ext ρ x ≡ ext ρ' x ext-cong p FZ = refl ext-cong p (FS x) = cong FS (p x) ren-cong : {ρ ρ' : m → n} → (∀ x → ρ x ≡ ρ' x) → ∀ t → ren ρ t ≡ ren ρ' t ren-cong p (TyVarG x) = cong TyVarG (p x) ren-cong p (TyFunG ty1 ty2) = cong₂ TyFunG (ren-cong p ty1) (ren-cong p ty2) ren-cong p (TyIFixG ty1 k ty2) = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (ren-cong p ty1) (ren-cong p ty2) ren-cong p (TyForallG k ty) = cong (TyForallG k) (ren-cong (ext-cong p) ty) ren-cong p (TyBuiltinG b) = refl ren-cong p (TyLamG ty) = cong TyLamG (ren-cong (ext-cong p) ty) ren-cong p (TyAppG ty1 ty2 k) = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (ren-cong p ty1) (ren-cong p ty2) -- ext (map for S) satisfies the functor laws ext-id : (x : S m) → ext id x ≡ x ext-id FZ = refl ext-id (FS x) = refl ext-comp : (x : S m)(ρ : m → n)(ρ' : n → o) → ext (ρ' ∘ ρ) x ≡ ext ρ' (ext ρ x) ext-comp FZ ρ ρ' = refl ext-comp (FS x) ρ ρ' = refl -- ren (map for TypeG) satisfies the functor laws ren-id : (ty : TypeG m) → ren id ty ≡ ty ren-id (TyVarG _) = refl ren-id (TyFunG ty1 ty2) = cong₂ TyFunG (ren-id ty1) (ren-id ty2) ren-id (TyIFixG ty1 k ty2) = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (ren-id ty1) (ren-id ty2) ren-id (TyForallG k ty) = cong (TyForallG k) (trans (ren-cong ext-id ty) (ren-id ty)) ren-id (TyBuiltinG _) = refl ren-id (TyLamG ty) = cong TyLamG (trans (ren-cong ext-id ty) (ren-id ty)) ren-id (TyAppG ty1 ty2 k) = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (ren-id ty1) (ren-id ty2) ren-comp : (ty : TypeG m)(ρ : m → n)(ρ' : n → o) → ren (ρ' ∘ ρ) ty ≡ ren ρ' (ren ρ ty) ren-comp (TyVarG x) ρ ρ' = refl ren-comp (TyFunG ty1 ty2) ρ ρ' = cong₂ TyFunG (ren-comp ty1 ρ ρ') (ren-comp ty2 ρ ρ') ren-comp (TyIFixG ty1 k ty2) ρ ρ' = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (ren-comp ty1 ρ ρ') (ren-comp ty2 ρ ρ') ren-comp (TyForallG k ty) ρ ρ' = cong (TyForallG k) (trans (ren-cong (λ x → ext-comp x ρ ρ') ty) (ren-comp ty (ext ρ) (ext ρ'))) ren-comp (TyBuiltinG b) ρ ρ' = refl ren-comp (TyLamG ty) ρ ρ' = cong TyLamG (trans (ren-cong (λ x → ext-comp x ρ ρ') ty) (ren-comp ty (ext ρ) (ext ρ'))) ren-comp (TyAppG ty1 ty2 k) ρ ρ' = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (ren-comp ty1 ρ ρ') (ren-comp ty2 ρ ρ') -- ** Type reduction -- |Extend type substitutions. exts : (n → TypeG m) -> S n → TypeG (S m) exts _ FZ = TyVarG FZ exts s (FS i) = ren FS (s i) -- FS <$> s i {-# COMPILE AGDA2HS exts #-} -- |Simultaneous substitution of type variables. sub : (n -> TypeG m) -> TypeG n -> TypeG m sub s (TyVarG i) = s i sub s (TyFunG ty1 ty2) = TyFunG (sub s ty1) (sub s ty2) sub s (TyIFixG ty1 k ty2) = TyIFixG (sub s ty1) k (sub s ty2) sub s (TyForallG k ty) = TyForallG k (sub (exts s) ty) sub _ (TyBuiltinG tyBuiltin) = TyBuiltinG tyBuiltin sub s (TyLamG ty) = TyLamG (sub (exts s) ty) sub s (TyAppG ty1 ty2 k) = TyAppG (sub s ty1) (sub s ty2) k {-# COMPILE AGDA2HS sub #-} {-# FOREIGN AGDA2HS instance Monad TypeG where a >>= f = sub f a -- return = pure instance Applicative TypeG where (<*>) = ap pure = TyVarG #-} -- sub ((=<<) for TypeG) satisfies the monad laws exts-cong : {σ σ' : m → TypeG n} → (∀ x → σ x ≡ σ' x) → ∀ x → exts σ x ≡ exts σ' x exts-cong p FZ = refl exts-cong p (FS x) = cong (ren FS) (p x) sub-cong : {σ σ' : m → TypeG n} → (∀ x → σ x ≡ σ' x) → ∀ ty → sub σ ty ≡ sub σ' ty sub-cong p (TyVarG x) = p x sub-cong p (TyFunG ty1 ty2) = cong₂ TyFunG (sub-cong p ty1) (sub-cong p ty2) sub-cong p (TyIFixG ty1 k ty2) = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (sub-cong p ty1) (sub-cong p ty2) sub-cong p (TyForallG k ty) = cong (TyForallG k) (sub-cong (exts-cong p) ty) sub-cong p (TyBuiltinG b) = refl sub-cong p (TyLamG ty) = cong TyLamG (sub-cong (exts-cong p) ty) sub-cong p (TyAppG ty1 ty2 k) = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (sub-cong p ty1) (sub-cong p ty2) exts-id : (x : S m) → exts TyVarG x ≡ TyVarG x exts-id FZ = refl exts-id (FS x) = refl sub-id : (t : TypeG m) → sub TyVarG t ≡ t sub-id (TyVarG x) = refl sub-id (TyFunG ty1 ty2) = cong₂ TyFunG (sub-id ty1) (sub-id ty2) sub-id (TyIFixG ty1 k ty2) = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (sub-id ty1) (sub-id ty2) sub-id (TyForallG k ty) = cong (TyForallG k) (trans (sub-cong exts-id ty) (sub-id ty)) sub-id (TyBuiltinG b) = refl sub-id (TyLamG ty) = cong TyLamG (trans (sub-cong exts-id ty) (sub-id ty)) sub-id (TyAppG ty1 ty2 k) = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (sub-id ty1) (sub-id ty2) exts-ext : (x : S m)(ρ : m → n)(σ : n → TypeG o) → exts (σ ∘ ρ) x ≡ exts σ (ext ρ x) exts-ext FZ σ ρ = refl exts-ext (FS x) σ ρ = refl sub-ren : (t : TypeG m)(ρ : m → n)(σ : n → TypeG o) → sub (σ ∘ ρ) t ≡ sub σ (ren ρ t) sub-ren (TyVarG x) ρ σ = refl sub-ren (TyFunG ty1 ty2) ρ σ = cong₂ TyFunG (sub-ren ty1 ρ σ) (sub-ren ty2 ρ σ) sub-ren (TyIFixG ty1 k ty2) ρ σ = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (sub-ren ty1 ρ σ) (sub-ren ty2 ρ σ) sub-ren (TyForallG k ty) ρ σ = cong (TyForallG k) (trans (sub-cong (λ x → exts-ext x ρ σ) ty) (sub-ren ty (ext ρ) (exts σ))) sub-ren (TyBuiltinG b) ρ σ = refl sub-ren (TyLamG ty) ρ σ = cong TyLamG (trans (sub-cong (λ x → exts-ext x ρ σ) ty) (sub-ren ty (ext ρ) (exts σ))) sub-ren (TyAppG ty1 ty2 k) ρ σ = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (sub-ren ty1 ρ σ) (sub-ren ty2 ρ σ) ext-exts : (x : S m)(σ : m → TypeG n)(ρ : n → o) → exts (ren ρ ∘ σ) x ≡ ren (ext ρ) (exts σ x) ext-exts FZ σ ρ = refl ext-exts (FS x) σ ρ = trans (sym (ren-comp (σ x) ρ FS)) (ren-comp (σ x) FS (ext ρ)) ren-sub : (t : TypeG m)(σ : m → TypeG n)(ρ : n → o) → sub (ren ρ ∘ σ) t ≡ ren ρ (sub σ t) ren-sub (TyVarG x) σ ρ = refl ren-sub (TyFunG ty1 ty2) σ ρ = cong₂ TyFunG (ren-sub ty1 σ ρ) (ren-sub ty2 σ ρ) ren-sub (TyIFixG ty1 k ty2) σ ρ = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (ren-sub ty1 σ ρ) (ren-sub ty2 σ ρ) ren-sub (TyForallG k ty) σ ρ = cong (TyForallG k) (trans (sub-cong (λ x → ext-exts x σ ρ) ty) (ren-sub ty (exts σ) (ext ρ))) ren-sub (TyBuiltinG b) σ ρ = refl ren-sub (TyLamG ty) σ ρ = cong TyLamG (trans (sub-cong (λ x → ext-exts x σ ρ) ty) (ren-sub ty (exts σ) (ext ρ))) ren-sub (TyAppG ty1 ty2 k) σ ρ = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (ren-sub ty1 σ ρ) (ren-sub ty2 σ ρ) exts-comp : (x : S m)(σ : m → TypeG n)(σ' : n → TypeG o) → exts (sub σ' ∘ σ) x ≡ sub (exts σ') (exts σ x) exts-comp FZ σ σ' = refl exts-comp (FS x) σ σ' = trans (sym (ren-sub (σ x) σ' FS)) (sub-ren (σ x) FS (exts σ')) sub-comp : (ty : TypeG m)(σ : m → TypeG n)(σ' : n → TypeG o) → sub (sub σ' ∘ σ) ty ≡ sub σ' (sub σ ty) sub-comp (TyVarG x) σ σ' = refl sub-comp (TyFunG ty1 ty2) σ σ' = cong₂ TyFunG (sub-comp ty1 σ σ') (sub-comp ty2 σ σ') sub-comp (TyIFixG ty1 k ty2) σ σ' = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (sub-comp ty1 σ σ') (sub-comp ty2 σ σ') sub-comp (TyForallG k ty) σ σ' = cong (TyForallG k) (trans (sub-cong (λ x → exts-comp x σ σ') ty) (sub-comp ty (exts σ) (exts σ'))) sub-comp (TyBuiltinG b) σ σ' = refl sub-comp (TyLamG ty) σ σ' = cong TyLamG (trans (sub-cong (λ x → exts-comp x σ σ') ty) (sub-comp ty (exts σ) (exts σ'))) sub-comp (TyAppG ty1 ty2 k) σ σ' = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (sub-comp ty1 σ σ') (sub-comp ty2 σ σ')
Require Import Rsequence_def Rsequence_base_facts. Require Import Reals Rfunction_def Rfunction_facts Rextensionality. Require Import Nth_derivative_def Nth_derivative_facts. Require Import Rpser. Require Import Rfunction_classes. Require Import Dequa_def Dequa_facts Dequa_quote. Require Import List. (* Require Import LegacyField_Theory. *) Local Open Scope R_scope. Lemma constant_is_cst : forall (c : R) (rc: infinite_cv_radius (constant_seq c)), forall x, sum _ rc x = c. Proof. intros c rc ; solve_diff_equa ; reflexivity. Qed. Lemma identity_is_id : forall (ri : infinite_cv_radius identity_seq) (di : derivable (sum _ ri)), forall x, derive (sum _ ri) di x = 1. Proof. intros ri di ; solve_diff_equa ; unfold An_deriv, identity_seq, constant_seq, Rseq_shift, Rseq_mult ; intros [ | n] ; simpl ; ring. Qed. Lemma diff_equa_cos : forall (rc : infinite_cv_radius cos_seq), forall x, nth_derive (sum _ rc) (D_infty_Rpser _ rc 2%nat) x = - nth_derive (sum _ rc) (D_infty_Rpser _ rc O) x. Proof. intro rc ; solve_diff_equa ; intro n ; rewrite An_nth_deriv_S', An_nth_deriv_1, (An_deriv_ext _ (- sin_seq)). rewrite An_deriv_opp_compat ; unfold Rseq_opp ; apply Ropp_eq_compat ; apply Deriv_sin_seq_simpl. apply Deriv_cos_seq_simpl. Qed. Lemma diff_equa_sin : forall (rc : infinite_cv_radius sin_seq), forall x, nth_derive (sum _ rc) (D_infty_Rpser _ rc 2%nat) x = - nth_derive (sum _ rc) (D_infty_Rpser _ rc O) x. Proof. intro rc ; solve_diff_equa ; intro n ; rewrite An_nth_deriv_S', An_nth_deriv_1, (An_deriv_ext _ cos_seq) ; [apply Deriv_cos_seq_simpl | apply Deriv_sin_seq_simpl]. Qed. Lemma diff_equa_exp : forall n (re : infinite_cv_radius exp_seq) x, nth_derive (sum _ re) (D_infty_Rpser _ re (S n)) x = nth_derive (sum _ re) (D_infty_Rpser _ re n) x. Proof. intros n re ; solve_diff_equa ; rewrite An_nth_deriv_S', (An_nth_deriv_ext _ exp_seq) ; [reflexivity | apply Deriv_exp_seq_simpl]. Qed. Require Import Commutative_ring_binomial. Lemma Rexp_mult_simpl : forall a b x, Rexp (a * x) * Rexp (b * x) = Rexp ((a + b) * x). Proof. intros a b ; unfold Rexp ; solve_diff_equa. Abort.
lemma finite_set_sum: assumes "finite A" and "\<forall>i\<in>A. finite (B i)" shows "finite (\<Sum>i\<in>A. B i)"
% Replace zero values in a vector with arbitrary small values % % Description % This is a convenient function to avoid methods crashing because % of zero values in a signal. % % Input % x : A vector containing possibly zero values. % % Output % y : The same vector as x with zero values replaced. % % References % https://github.com/covarep/covarep/issues/75 % % Copyright (c) 2011 University of Crete - Computer Science Department % % License % This file is under the LGPL license, 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 3 % of the License, or (at your option) any later version. This file 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. % % This function is part of the Covarep project: http://covarep.github.io/covarep % % Author % Gilles Degottex <[email protected]> function y = replacezeros(x) y = x; idx = find(x==0); y(idx) = eps*rand(1,length(idx));
State Before: x : ℝ ⊢ arccos x = 0 ↔ 1 ≤ x State After: no goals Tactic: simp [arccos, sub_eq_zero]
How to download and update Android Flash File ascom wireless solutions myco 2 cellular acbb sh1 2019? We recommend using latest version Android Flash File ascom wireless solutions myco 2 cellular acbb sh1 device. Easy step by step update Android Flash File latest version, downloads ever release.. Download and update Android Flash File for models: ascom wireless solutions myco cellular gms sh1, ascom wireless solutions myco cellular acba sh1, .
module LightClick.IR.Channel.Normalise.LetFloat import Data.List import Data.Vect import Toolkit.Data.DList import Toolkit.Data.DVect import LightClick.Types import LightClick.Terms import LightClick.IR.ModuleCentric import LightClick.IR.ChannelCentric import LightClick.IR.Channel.Normalise.Error %default total isNF : ChannelIR type -> Bool isNF (CSeq (CSeq this thenThis) andThis) = False isNF (CSeq (CLet _ _ _) (CLet _ _ _)) = False isNF (CSeq (CLet _ _ _) thenThis) = False isNF (CSeq this (CLet _ _ _)) = False isNF (CSeq this thenThis) = isNF this && isNF thenThis isNF (CLet this beThis inThis) = isNF beThis && isNF inThis isNF expr = True letFloat : ChannelIR type -> ChannelIR type letFloat (CSeq (CSeq this thenThis) rest) = CSeq (letFloat this) (CSeq (letFloat thenThis) (letFloat rest)) letFloat (CSeq (CLet outerName beOuterThis inOuterThis) (CLet innerName beInnerThis inInnerThis)) = CLet outerName (letFloat beOuterThis) (CLet innerName (letFloat beInnerThis) (CSeq (letFloat inOuterThis) (letFloat inInnerThis))) letFloat (CSeq (CLet name beThis inThis) thenDoThis) = CLet name (letFloat beThis) (CSeq (letFloat inThis) (letFloat thenDoThis)) letFloat (CSeq this (CLet name beThis inThis)) = CLet name (letFloat beThis) (CSeq (letFloat this) (letFloat inThis)) letFloat (CLet x y z) = CLet x (letFloat y) (letFloat z) letFloat (CSeq x y) = CSeq (letFloat x) (letFloat y) letFloat expr = expr export covering -- due to totality checker not liking recursive calls. runLetFloat : ChannelIR type -> Normalise (ChannelIR type) runLetFloat expr = if isNF expr then Right expr else runLetFloat (letFloat expr) -- [ EOF ]
[STATEMENT] lemma is_character_data_ptr_kind_obtains: assumes "is_character_data_ptr_kind\<^sub>n\<^sub>o\<^sub>d\<^sub>e\<^sub>_\<^sub>p\<^sub>t\<^sub>r node_ptr" obtains character_data_ptr where "cast\<^sub>c\<^sub>h\<^sub>a\<^sub>r\<^sub>a\<^sub>c\<^sub>t\<^sub>e\<^sub>r\<^sub>_\<^sub>d\<^sub>a\<^sub>t\<^sub>a\<^sub>_\<^sub>p\<^sub>t\<^sub>r\<^sub>2\<^sub>n\<^sub>o\<^sub>d\<^sub>e\<^sub>_\<^sub>p\<^sub>t\<^sub>r character_data_ptr = node_ptr" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>character_data_ptr. cast character_data_ptr = node_ptr \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by (metis assms is_character_data_ptr_kind\<^sub>n\<^sub>o\<^sub>d\<^sub>e\<^sub>_\<^sub>p\<^sub>t\<^sub>r_def case_optionE character_data_ptr_casts_commute)